@fluidframework/tree-agent-ses 2.63.0 → 2.70.0-360753
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/executor.d.ts +2 -2
- package/dist/executor.d.ts.map +1 -1
- package/dist/executor.js.map +1 -1
- package/lib/executor.d.ts +2 -2
- package/lib/executor.d.ts.map +1 -1
- package/lib/executor.js.map +1 -1
- package/package.json +5 -7
- package/src/executor.ts +2 -2
package/dist/executor.d.ts
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
5
|
import "ses";
|
|
6
|
-
import type {
|
|
6
|
+
import type { AsynchronousEditor } from "@fluidframework/tree-agent/alpha";
|
|
7
7
|
/**
|
|
8
8
|
* Create an implementation of {@link @fluidframework/tree-agent#SemanticAgentOptions.executeEdit} that uses the SES library
|
|
9
9
|
* to run the provided code in a secure environment.
|
|
@@ -18,5 +18,5 @@ export declare function createSesEditExecutor(options?: {
|
|
|
18
18
|
[key: string]: unknown;
|
|
19
19
|
};
|
|
20
20
|
lockdownOptions?: Record<string, unknown>;
|
|
21
|
-
}):
|
|
21
|
+
}): AsynchronousEditor;
|
|
22
22
|
//# sourceMappingURL=executor.d.ts.map
|
package/dist/executor.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"executor.d.ts","sourceRoot":"","sources":["../src/executor.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,KAAK,CAAC;AAEb,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"executor.d.ts","sourceRoot":"","sources":["../src/executor.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,KAAK,CAAC;AAEb,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,kCAAkC,CAAC;AAO3E;;;;;;;GAOG;AACH,wBAAgB,qBAAqB,CAAC,OAAO,CAAC,EAAE;IAC/C,kBAA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;oBACjD,KAAK,EAAE,IAAI;oBACX,QAAQ,EAAE,KAAK;oBACf,YAAY,EAAE,KAAK;oBACnB,UAAU,EAAE,KAAK;iBACjB,CAAC,CAAC;YACJ,CAAC;iBAAM,CAAC;gBACP,MAAM,KAAK,CAAC;YACb,CAAC;QACF,CAAC;IACF,CAAC;IAED,OAAO,KAAK,EAAE,OAAgC,EAAE,IAAY,EAAE,EAAE;QAC/D,MAAM,kBAAkB,GAAG;YAC1B,GAAG,OAAO,EAAE,kBAAkB;YAC9B,OAAO,EAAE;gBACR,GAAG,MAAM,CAAC,WAAW,CAAC,cAAc,CAAC;gBACrC,OAAO;aACP;SACD,CAAC;QAEF,MAAM,WAAW,GAAG,IAAI,WAAW,CAAC,EAAE,GAAG,kBAAkB,EAAE,WAAW,EAAE,IAAI,EAAE,CAAC,CAAC;QAClF,MAAM,WAAW,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;IAClC,CAAC,CAAC;AACH,CAAC;AAhDD,sDAgDC;AAED;;GAEG;AACH,SAAS,aAAa,CAAC,KAAc;IACpC,IAAI,KAAK,YAAY,KAAK,EAAE,CAAC;QAC5B,OAAO,KAAK,CAAC,OAAO,CAAC;IACtB,CAAC;IACD,IAAI,CAAC;QACJ,OAAO,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;IAC9B,CAAC;IAAC,MAAM,CAAC;QACR,OAAO,MAAM,CAAC,KAAK,CAAC,CAAC;IACtB,CAAC;AACF,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\n// eslint-disable-next-line import/no-unassigned-import\nimport \"ses\";\n\nimport type {
|
|
1
|
+
{"version":3,"file":"executor.js","sourceRoot":"","sources":["../src/executor.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,uDAAuD;AACvD,eAAa;AAIb;;GAEG;AACH,MAAM,cAAc,GAAG,MAAM,CAAC,GAAG,CAAC,uBAAuB,CAAC,CA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,EAAE,WAAW,EAAE,IAAI,EAAE,CAAC,CAAC;QAClF,MAAM,WAAW,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;IAClC,CAAC,CAAC;AACH,CAAC;AAhDD,sDAgDC;AAED;;GAEG;AACH,SAAS,aAAa,CAAC,KAAc;IACpC,IAAI,KAAK,YAAY,KAAK,EAAE,CAAC;QAC5B,OAAO,KAAK,CAAC,OAAO,CAAC;IACtB,CAAC;IACD,IAAI,CAAC;QACJ,OAAO,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;IAC9B,CAAC;IAAC,MAAM,CAAC;QACR,OAAO,MAAM,CAAC,KAAK,CAAC,CAAC;IACtB,CAAC;AACF,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\n// eslint-disable-next-line import/no-unassigned-import\nimport \"ses\";\n\nimport type { AsynchronousEditor } from \"@fluidframework/tree-agent/alpha\";\n\n/**\n * Used to track whether the SES `lockdown` function has already been called by this module.\n */\nconst lockdownSymbol = Symbol.for(\"tree-agent.ses.locked\");\n\n/**\n * Create an implementation of {@link @fluidframework/tree-agent#SemanticAgentOptions.executeEdit} that uses the SES library\n * to run the provided code in a secure environment.\n * @param options - Optional configuration for the underlying SES compartment and lockdown invocation.\n * @returns A function that can be used as the {@link @fluidframework/tree-agent#SemanticAgentOptions.executeEdit | executeEdit} callback.\n * @remarks This function will call the SES `lockdown` API the first time it is invoked. For best performance, create the executor once during application initialization.\n * @alpha\n */\nexport function createSesEditExecutor(options?: {\n\tcompartmentOptions?: { globals?: Map<string, unknown>; [key: string]: unknown };\n\tlockdownOptions?: Record<string, unknown>;\n}): AsynchronousEditor {\n\tconst optionsGlobals: Map<string, unknown> =\n\t\toptions?.compartmentOptions?.globals ?? new Map<string, unknown>();\n\n\tif (optionsGlobals.has(\"context\") === true) {\n\t\tthrow new Error(\n\t\t\t\"The 'context' global is reserved and cannot be overridden in the compartment options.\",\n\t\t);\n\t}\n\n\tif (!(lockdownSymbol in globalThis)) {\n\t\ttry {\n\t\t\tlockdown(options?.lockdownOptions);\n\t\t\tObject.defineProperty(globalThis, lockdownSymbol, {\n\t\t\t\tvalue: true,\n\t\t\t\twritable: false,\n\t\t\t\tconfigurable: false,\n\t\t\t\tenumerable: false,\n\t\t\t});\n\t\t} catch (error: unknown) {\n\t\t\tif (toErrorString(error).includes(\"SES_ALREADY_LOCKED_DOWN\")) {\n\t\t\t\tObject.defineProperty(globalThis, lockdownSymbol, {\n\t\t\t\t\tvalue: true,\n\t\t\t\t\twritable: false,\n\t\t\t\t\tconfigurable: false,\n\t\t\t\t\tenumerable: false,\n\t\t\t\t});\n\t\t\t} else {\n\t\t\t\tthrow error;\n\t\t\t}\n\t\t}\n\t}\n\n\treturn async (context: Record<string, unknown>, code: string) => {\n\t\tconst compartmentOptions = {\n\t\t\t...options?.compartmentOptions,\n\t\t\tglobals: {\n\t\t\t\t...Object.fromEntries(optionsGlobals),\n\t\t\t\tcontext,\n\t\t\t},\n\t\t};\n\n\t\tconst compartment = new Compartment({ ...compartmentOptions, __options__: true });\n\t\tawait compartment.evaluate(code);\n\t};\n}\n\n/**\n * Stringify an unknown error value.\n */\nfunction toErrorString(error: unknown): string {\n\tif (error instanceof Error) {\n\t\treturn error.message;\n\t}\n\ttry {\n\t\treturn JSON.stringify(error);\n\t} catch {\n\t\treturn String(error);\n\t}\n}\n"]}
|
package/lib/executor.d.ts
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
5
|
import "ses";
|
|
6
|
-
import type {
|
|
6
|
+
import type { AsynchronousEditor } from "@fluidframework/tree-agent/alpha";
|
|
7
7
|
/**
|
|
8
8
|
* Create an implementation of {@link @fluidframework/tree-agent#SemanticAgentOptions.executeEdit} that uses the SES library
|
|
9
9
|
* to run the provided code in a secure environment.
|
|
@@ -18,5 +18,5 @@ export declare function createSesEditExecutor(options?: {
|
|
|
18
18
|
[key: string]: unknown;
|
|
19
19
|
};
|
|
20
20
|
lockdownOptions?: Record<string, unknown>;
|
|
21
|
-
}):
|
|
21
|
+
}): AsynchronousEditor;
|
|
22
22
|
//# sourceMappingURL=executor.d.ts.map
|
package/lib/executor.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"executor.d.ts","sourceRoot":"","sources":["../src/executor.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,KAAK,CAAC;AAEb,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"executor.d.ts","sourceRoot":"","sources":["../src/executor.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,KAAK,CAAC;AAEb,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,kCAAkC,CAAC;AAO3E;;;;;;;GAOG;AACH,wBAAgB,qBAAqB,CAAC,OAAO,CAAC,EAAE;IAC/C,kBAAkB,CAAC,EAAE;QAAE,OAAO,CAAC,EAAE,GAAG,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;QAAC,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAA;KAAE,CAAC;IAChF,eAAe,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CAC1C,GAAG,kBAAkB,CA6CrB"}
|
package/lib/executor.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"executor.js","sourceRoot":"","sources":["../src/executor.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,uDAAuD;AACvD,OAAO,KAAK,CAAC;AAIb;;GAEG;AACH,MAAM,cAAc,GAAG,MAAM,CAAC,GAAG,CAAC,uBAAuB,CAAC,CAAC;AAE3D;;;;;;;GAOG;AACH,MAAM,UAAU,qBAAqB,CAAC,OAGrC;IACA,MAAM,cAAc,GACnB,OAAO,EAAE,kBAAkB,EAAE,OAAO,IAAI,IAAI,GAAG,EAAmB,CAAC;IAEpE,I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Aa,CAAC,KAAc;IACpC,IAAI,KAAK,YAAY,KAAK,EAAE,CAAC;QAC5B,OAAO,KAAK,CAAC,OAAO,CAAC;IACtB,CAAC;IACD,IAAI,CAAC;QACJ,OAAO,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;IAC9B,CAAC;IAAC,MAAM,CAAC;QACR,OAAO,MAAM,CAAC,KAAK,CAAC,CAAC;IACtB,CAAC;AACF,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\n// eslint-disable-next-line import/no-unassigned-import\nimport \"ses\";\n\nimport type {
|
|
1
|
+
{"version":3,"file":"executor.js","sourceRoot":"","sources":["../src/executor.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,uDAAuD;AACvD,OAAO,KAAK,CAAC;AAIb;;GAEG;AACH,MAAM,cAAc,GAAG,MAAM,CAAC,GAAG,CAAC,uBAAuB,CAAC,CAAC;AAE3D;;;;;;;GAOG;AACH,MAAM,UAAU,qBAAqB,CAAC,OAGrC;IACA,MAAM,cAAc,GACnB,OAAO,EAAE,kBAAkB,EAAE,OAAO,IAAI,IAAI,GAAG,EAAmB,CAAC;IAEpE,IAAI,cAAc,CAAC,GAAG,CAAC,SAAS,CAAC,KAAK,IAAI,EAAE,CAAC;QAC5C,MAAM,IAAI,KAAK,CACd,uFAAuF,CACvF,CAAC;IACH,CAAC;IAED,IAAI,CAAC,CAAC,cAAc,IAAI,UAAU,CAAC,EAAE,CAAC;QACrC,IAAI,CAAC;YACJ,QAAQ,CAAC,OAAO,EAAE,eAAe,CAAC,CAAC;YACnC,MAAM,CAAC,cAAc,CAAC,UAAU,EAAE,cAAc,EAAE;gBACjD,KAAK,EAAE,IAAI;gBACX,QAAQ,EAAE,KAAK;gBACf,YAAY,EAAE,KAAK;gBACnB,UAAU,EAAE,KAAK;aACjB,CAAC,CAAC;QACJ,CAAC;QAAC,OAAO,KAAc,EAAE,CAAC;YACzB,IAAI,aAAa,CAAC,KAAK,CAAC,CAAC,QAAQ,CAAC,yBAAyB,CAAC,EAAE,CAAC;gBAC9D,MAAM,CAAC,cAAc,CAAC,UAAU,EAAE,cAAc,EAAE;oBACjD,KAAK,EAAE,IAAI;oBACX,QAAQ,EAAE,KAAK;oBACf,YAAY,EAAE,KAAK;oBACnB,UAAU,EAAE,KAAK;iBACjB,CAAC,CAAC;YACJ,CAAC;iBAAM,CAAC;gBACP,MAAM,KAAK,CAAC;YACb,CAAC;QACF,CAAC;IACF,CAAC;IAED,OAAO,KAAK,EAAE,OAAgC,EAAE,IAAY,EAAE,EAAE;QAC/D,MAAM,kBAAkB,GAAG;YAC1B,GAAG,OAAO,EAAE,kBAAkB;YAC9B,OAAO,EAAE;gBACR,GAAG,MAAM,CAAC,WAAW,CAAC,cAAc,CAAC;gBACrC,OAAO;aACP;SACD,CAAC;QAEF,MAAM,WAAW,GAAG,IAAI,WAAW,CAAC,EAAE,GAAG,kBAAkB,EAAE,WAAW,EAAE,IAAI,EAAE,CAAC,CAAC;QAClF,MAAM,WAAW,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;IAClC,CAAC,CAAC;AACH,CAAC;AAED;;GAEG;AACH,SAAS,aAAa,CAAC,KAAc;IACpC,IAAI,KAAK,YAAY,KAAK,EAAE,CAAC;QAC5B,OAAO,KAAK,CAAC,OAAO,CAAC;IACtB,CAAC;IACD,IAAI,CAAC;QACJ,OAAO,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;IAC9B,CAAC;IAAC,MAAM,CAAC;QACR,OAAO,MAAM,CAAC,KAAK,CAAC,CAAC;IACtB,CAAC;AACF,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\n// eslint-disable-next-line import/no-unassigned-import\nimport \"ses\";\n\nimport type { AsynchronousEditor } from \"@fluidframework/tree-agent/alpha\";\n\n/**\n * Used to track whether the SES `lockdown` function has already been called by this module.\n */\nconst lockdownSymbol = Symbol.for(\"tree-agent.ses.locked\");\n\n/**\n * Create an implementation of {@link @fluidframework/tree-agent#SemanticAgentOptions.executeEdit} that uses the SES library\n * to run the provided code in a secure environment.\n * @param options - Optional configuration for the underlying SES compartment and lockdown invocation.\n * @returns A function that can be used as the {@link @fluidframework/tree-agent#SemanticAgentOptions.executeEdit | executeEdit} callback.\n * @remarks This function will call the SES `lockdown` API the first time it is invoked. For best performance, create the executor once during application initialization.\n * @alpha\n */\nexport function createSesEditExecutor(options?: {\n\tcompartmentOptions?: { globals?: Map<string, unknown>; [key: string]: unknown };\n\tlockdownOptions?: Record<string, unknown>;\n}): AsynchronousEditor {\n\tconst optionsGlobals: Map<string, unknown> =\n\t\toptions?.compartmentOptions?.globals ?? new Map<string, unknown>();\n\n\tif (optionsGlobals.has(\"context\") === true) {\n\t\tthrow new Error(\n\t\t\t\"The 'context' global is reserved and cannot be overridden in the compartment options.\",\n\t\t);\n\t}\n\n\tif (!(lockdownSymbol in globalThis)) {\n\t\ttry {\n\t\t\tlockdown(options?.lockdownOptions);\n\t\t\tObject.defineProperty(globalThis, lockdownSymbol, {\n\t\t\t\tvalue: true,\n\t\t\t\twritable: false,\n\t\t\t\tconfigurable: false,\n\t\t\t\tenumerable: false,\n\t\t\t});\n\t\t} catch (error: unknown) {\n\t\t\tif (toErrorString(error).includes(\"SES_ALREADY_LOCKED_DOWN\")) {\n\t\t\t\tObject.defineProperty(globalThis, lockdownSymbol, {\n\t\t\t\t\tvalue: true,\n\t\t\t\t\twritable: false,\n\t\t\t\t\tconfigurable: false,\n\t\t\t\t\tenumerable: false,\n\t\t\t\t});\n\t\t\t} else {\n\t\t\t\tthrow error;\n\t\t\t}\n\t\t}\n\t}\n\n\treturn async (context: Record<string, unknown>, code: string) => {\n\t\tconst compartmentOptions = {\n\t\t\t...options?.compartmentOptions,\n\t\t\tglobals: {\n\t\t\t\t...Object.fromEntries(optionsGlobals),\n\t\t\t\tcontext,\n\t\t\t},\n\t\t};\n\n\t\tconst compartment = new Compartment({ ...compartmentOptions, __options__: true });\n\t\tawait compartment.evaluate(code);\n\t};\n}\n\n/**\n * Stringify an unknown error value.\n */\nfunction toErrorString(error: unknown): string {\n\tif (error instanceof Error) {\n\t\treturn error.message;\n\t}\n\ttry {\n\t\treturn JSON.stringify(error);\n\t} catch {\n\t\treturn String(error);\n\t}\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fluidframework/tree-agent-ses",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.70.0-360753",
|
|
4
4
|
"description": "SES integration helpers for @fluidframework/tree-agent",
|
|
5
5
|
"homepage": "https://fluidframework.com",
|
|
6
6
|
"repository": {
|
|
@@ -69,18 +69,18 @@
|
|
|
69
69
|
"temp-directory": "nyc/.nyc_output"
|
|
70
70
|
},
|
|
71
71
|
"dependencies": {
|
|
72
|
-
"@fluidframework/tree-agent": "
|
|
72
|
+
"@fluidframework/tree-agent": "2.70.0-360753",
|
|
73
73
|
"ses": "^1.14.0"
|
|
74
74
|
},
|
|
75
75
|
"devDependencies": {
|
|
76
76
|
"@arethetypeswrong/cli": "^0.17.1",
|
|
77
77
|
"@biomejs/biome": "~1.9.3",
|
|
78
|
-
"@fluid-internal/mocha-test-setup": "
|
|
78
|
+
"@fluid-internal/mocha-test-setup": "2.70.0-360753",
|
|
79
79
|
"@fluid-tools/build-cli": "^0.58.3",
|
|
80
80
|
"@fluidframework/build-common": "^2.0.3",
|
|
81
81
|
"@fluidframework/build-tools": "^0.58.3",
|
|
82
82
|
"@fluidframework/eslint-config-fluid": "^6.0.0",
|
|
83
|
-
"@fluidframework/tree": "
|
|
83
|
+
"@fluidframework/tree": "2.70.0-360753",
|
|
84
84
|
"@microsoft/api-extractor": "7.52.11",
|
|
85
85
|
"@types/mocha": "^10.0.10",
|
|
86
86
|
"@types/node": "^18.19.0",
|
|
@@ -109,9 +109,7 @@
|
|
|
109
109
|
}
|
|
110
110
|
},
|
|
111
111
|
"typeValidation": {
|
|
112
|
-
"disabled": true
|
|
113
|
-
"broken": {},
|
|
114
|
-
"entrypoint": "internal"
|
|
112
|
+
"disabled": true
|
|
115
113
|
},
|
|
116
114
|
"scripts": {
|
|
117
115
|
"api": "fluid-build . --task api",
|
package/src/executor.ts
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
// eslint-disable-next-line import/no-unassigned-import
|
|
7
7
|
import "ses";
|
|
8
8
|
|
|
9
|
-
import type {
|
|
9
|
+
import type { AsynchronousEditor } from "@fluidframework/tree-agent/alpha";
|
|
10
10
|
|
|
11
11
|
/**
|
|
12
12
|
* Used to track whether the SES `lockdown` function has already been called by this module.
|
|
@@ -24,7 +24,7 @@ const lockdownSymbol = Symbol.for("tree-agent.ses.locked");
|
|
|
24
24
|
export function createSesEditExecutor(options?: {
|
|
25
25
|
compartmentOptions?: { globals?: Map<string, unknown>; [key: string]: unknown };
|
|
26
26
|
lockdownOptions?: Record<string, unknown>;
|
|
27
|
-
}):
|
|
27
|
+
}): AsynchronousEditor {
|
|
28
28
|
const optionsGlobals: Map<string, unknown> =
|
|
29
29
|
options?.compartmentOptions?.globals ?? new Map<string, unknown>();
|
|
30
30
|
|