🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
Book a DemoInstallSign in
Socket

@jupyterlite/contents

Package Overview
Dependencies
Maintainers
5
Versions
102
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@jupyterlite/contents - npm Package Compare versions

Comparing version

to
0.6.0-alpha.8

57

lib/drivefs.d.ts

@@ -43,2 +43,6 @@ import { Contents } from '@jupyterlab/services';

/**
* A unique ID to identify the origin of this request
*/
browsingContextId?: string;
/**
* The path to the file/directory for which the request was sent

@@ -106,3 +110,3 @@ */

export declare abstract class ContentsAPI {
constructor(driveName: string, mountpoint: string, FS: FS, ERRNO_CODES: ERRNO_CODES);
constructor(options: ContentsAPI.IOptions);
lookup(path: string): DriveFS.ILookup;

@@ -133,3 +137,6 @@ getmode(path: string): number;

export declare class ServiceWorkerContentsAPI extends ContentsAPI {
constructor(baseUrl: string, driveName: string, mountpoint: string, FS: FS, ERRNO_CODES: ERRNO_CODES);
/**
* Construct a new ServiceWorkerContentsAPI.
*/
constructor(options: ServiceWorkerContentsAPI.IOptions);
request<T extends TDriveMethod>(data: TDriveRequest<T>): TDriveResponse<T>;

@@ -141,2 +148,3 @@ /**

private _baseUrl;
private _browsingContextId;
}

@@ -164,2 +172,46 @@ export declare class DriveFS {

/**
* A namespace for ContentsAPI configurations, etc.
*/
export declare namespace ContentsAPI {
/**
* Initialization options for a contents API;
*/
interface IOptions {
/**
* The name of the drive to use for the contents API request.
*/
driveName: string;
/**
* Where to mount files in the kernel.
*/
mountpoint: string;
/**
* The filesystem module API.
*/
FS: FS;
/**
* The filesystem error codes.
*/
ERRNO_CODES: ERRNO_CODES;
}
}
/**
* A namespace for ServiceWorkerContentsAPI configurations, etc.
*/
export declare namespace ServiceWorkerContentsAPI {
/**
* Initialization options for a service worker contents API
*/
interface IOptions extends ContentsAPI.IOptions {
/**
* The base URL.
*/
baseUrl: string;
/**
* The ID of the browsing context where the request originated.
*/
browsingContextId: string;
}
}
/**
* A namespace for DriveFS configurations, etc.

@@ -192,4 +244,5 @@ */

mountpoint: string;
browsingContextId?: string;
}
}
export {};

32

lib/drivefs.js

@@ -209,7 +209,7 @@ // Copyright (c) Jupyter Development Team.

export class ContentsAPI {
constructor(driveName, mountpoint, FS, ERRNO_CODES) {
this._driveName = driveName;
this._mountpoint = mountpoint;
this.FS = FS;
this.ERRNO_CODES = ERRNO_CODES;
constructor(options) {
this._driveName = options.driveName;
this._mountpoint = options.mountpoint;
this.FS = options.FS;
this.ERRNO_CODES = options.ERRNO_CODES;
}

@@ -349,5 +349,9 @@ lookup(path) {

export class ServiceWorkerContentsAPI extends ContentsAPI {
constructor(baseUrl, driveName, mountpoint, FS, ERRNO_CODES) {
super(driveName, mountpoint, FS, ERRNO_CODES);
this._baseUrl = baseUrl;
/**
* Construct a new ServiceWorkerContentsAPI.
*/
constructor(options) {
super(options);
this._baseUrl = options.baseUrl;
this._browsingContextId = options.browsingContextId || '';
}

@@ -357,4 +361,9 @@ request(data) {

xhr.open('POST', encodeURI(this.endpoint), false);
// Add the origin browsing context ID to the request
const requestWithBrowsingContextId = {
data,
browsingContextId: this._browsingContextId,
};
try {
xhr.send(JSON.stringify(data));
xhr.send(JSON.stringify(requestWithBrowsingContextId));
}

@@ -392,3 +401,6 @@ catch (e) {

createAPI(options) {
return new ServiceWorkerContentsAPI(options.baseUrl, options.driveName, options.mountpoint, options.FS, options.ERRNO_CODES);
if (!options.browsingContextId || !options.baseUrl) {
throw new Error('Cannot create service-worker API without current browsingContextId');
}
return new ServiceWorkerContentsAPI(options);
}

@@ -395,0 +407,0 @@ mount(mount) {

{
"name": "@jupyterlite/contents",
"version": "0.6.0-alpha.7",
"version": "0.6.0-alpha.8",
"description": "JupyterLite - Contents",

@@ -46,6 +46,6 @@ "homepage": "https://github.com/jupyterlite/jupyterlite",

"dependencies": {
"@jupyterlab/nbformat": "~4.4.0-rc.0",
"@jupyterlab/services": "~7.4.0-rc.0",
"@jupyterlite/localforage": "^0.6.0-alpha.7",
"@lumino/coreutils": "^2.2.0",
"@jupyterlab/nbformat": "~4.4.0",
"@jupyterlab/services": "~7.4.0",
"@jupyterlite/localforage": "^0.6.0-alpha.8",
"@lumino/coreutils": "^2.2.1",
"@types/emscripten": "^1.39.6",

@@ -58,3 +58,3 @@ "localforage": "^1.9.0",

"@babel/preset-env": "^7.12.1",
"@jupyterlab/testutils": "~4.4.0-rc.0",
"@jupyterlab/testutils": "~4.4.0",
"@types/jest": "^29.5.3",

@@ -61,0 +61,0 @@ "@types/mime": "^2.0.3",

@@ -84,2 +84,7 @@ // Copyright (c) Jupyter Development Team.

/**
* A unique ID to identify the origin of this request
*/
browsingContextId?: string;
/**
* The path to the file/directory for which the request was sent

@@ -390,8 +395,8 @@ */

export abstract class ContentsAPI {
constructor(driveName: string, mountpoint: string, FS: FS, ERRNO_CODES: ERRNO_CODES) {
this._driveName = driveName;
this._mountpoint = mountpoint;
constructor(options: ContentsAPI.IOptions) {
this._driveName = options.driveName;
this._mountpoint = options.mountpoint;
this.FS = FS;
this.ERRNO_CODES = ERRNO_CODES;
this.FS = options.FS;
this.ERRNO_CODES = options.ERRNO_CODES;
}

@@ -555,12 +560,10 @@

export class ServiceWorkerContentsAPI extends ContentsAPI {
constructor(
baseUrl: string,
driveName: string,
mountpoint: string,
FS: FS,
ERRNO_CODES: ERRNO_CODES,
) {
super(driveName, mountpoint, FS, ERRNO_CODES);
/**
* Construct a new ServiceWorkerContentsAPI.
*/
constructor(options: ServiceWorkerContentsAPI.IOptions) {
super(options);
this._baseUrl = baseUrl;
this._baseUrl = options.baseUrl;
this._browsingContextId = options.browsingContextId || '';
}

@@ -572,4 +575,10 @@

// Add the origin browsing context ID to the request
const requestWithBrowsingContextId = {
data,
browsingContextId: this._browsingContextId,
};
try {
xhr.send(JSON.stringify(data));
xhr.send(JSON.stringify(requestWithBrowsingContextId));
} catch (e) {

@@ -594,2 +603,3 @@ console.error(e);

private _baseUrl: string;
private _browsingContextId: string;
}

@@ -625,9 +635,9 @@

createAPI(options: DriveFS.IOptions): ContentsAPI {
return new ServiceWorkerContentsAPI(
options.baseUrl,
options.driveName,
options.mountpoint,
options.FS,
options.ERRNO_CODES,
);
if (!options.browsingContextId || !options.baseUrl) {
throw new Error(
'Cannot create service-worker API without current browsingContextId',
);
}
return new ServiceWorkerContentsAPI(options as ServiceWorkerContentsAPI.IOptions);
}

@@ -675,2 +685,52 @@

/**
* A namespace for ContentsAPI configurations, etc.
*/
export namespace ContentsAPI {
/**
* Initialization options for a contents API;
*/
export interface IOptions {
/**
* The name of the drive to use for the contents API request.
*/
driveName: string;
/**
* Where to mount files in the kernel.
*/
mountpoint: string;
/**
* The filesystem module API.
*/
FS: FS;
/**
* The filesystem error codes.
*/
ERRNO_CODES: ERRNO_CODES;
}
}
/**
* A namespace for ServiceWorkerContentsAPI configurations, etc.
*/
export namespace ServiceWorkerContentsAPI {
/**
* Initialization options for a service worker contents API
*/
export interface IOptions extends ContentsAPI.IOptions {
/**
* The base URL.
*/
baseUrl: string;
/**
* The ID of the browsing context where the request originated.
*/
browsingContextId: string;
}
}
/**
* A namespace for DriveFS configurations, etc.

@@ -705,3 +765,4 @@ */

mountpoint: string;
browsingContextId?: string;
}
}

Sorry, the diff of this file is not supported yet