Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(pass-style): Use endowed passStyleOf if at global symbol #1794

Merged
merged 1 commit into from
Sep 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions packages/pass-style/endow.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { PassStyleOfEndowmentSymbol } from './src/passStyleOf.js';
1 change: 1 addition & 0 deletions packages/pass-style/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
"exports": {
".": "./index.js",
"./tools.js": "./tools.js",
"./endow.js": "./endow.js",
mhofman marked this conversation as resolved.
Show resolved Hide resolved
"./package.json": "./package.json"
},
"scripts": {
Expand Down
13 changes: 7 additions & 6 deletions packages/pass-style/src/passStyleOf.js
Original file line number Diff line number Diff line change
Expand Up @@ -190,10 +190,13 @@ const makePassStyleOf = passStyleHelpers => {
return harden(passStyleOf);
};

export const PassStyleOfEndowmentSymbol = Symbol.for('@endo passStyleOf');

/**
* If there is already a `VataData` global containing a `passStyleOf`,
* then presumably it was endowed for us by liveslots, so we should use
* and export that one instead. Other software may have left it for us here,
* If there is already a PassStyleOfEndowmentSymbol property on the global,
* then presumably it was endowed for us by liveslots with a `passStyleOf`
* function, so we should use and export that one instead.
* Other software may have left it for us here,
* but it would require write access to our global, or the ability to
* provide endowments to our global, both of which seems adequate as a test of
* whether it is authorized to serve the same role as liveslots.
Expand All @@ -205,9 +208,7 @@ const makePassStyleOf = passStyleHelpers => {
* @type {PassStyleOf}
*/
export const passStyleOf =
// UNTIL https://github.com/endojs/endo/issues/1514
// Prefer: globalThis?.VatData?.passStyleOf ||
(globalThis && globalThis.VatData && globalThis.VatData.passStyleOf) ||
(globalThis && globalThis[PassStyleOfEndowmentSymbol]) ||
makePassStyleOf([
erights marked this conversation as resolved.
Show resolved Hide resolved
CopyArrayHelper,
CopyRecordHelper,
Expand Down