@foxy.io/elements 1.59.0 → 1.60.1
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/cdn/foxy-access-recovery-form.js +1 -1
- package/dist/cdn/foxy-address-card.js +1 -1
- package/dist/cdn/foxy-address-form.js +1 -1
- package/dist/cdn/foxy-admin-subscription-card.js +1 -1
- package/dist/cdn/foxy-admin-subscription-form.js +1 -1
- package/dist/cdn/foxy-admin-transaction-card.js +1 -1
- package/dist/cdn/foxy-api-browser.js +1 -1
- package/dist/cdn/foxy-applied-coupon-code-card.js +1 -1
- package/dist/cdn/foxy-applied-coupon-code-form.js +1 -1
- package/dist/cdn/foxy-applied-tax-card.js +1 -1
- package/dist/cdn/foxy-attribute-card.js +1 -1
- package/dist/cdn/foxy-attribute-form.js +1 -1
- package/dist/cdn/foxy-billing-address-card.js +1 -1
- package/dist/cdn/foxy-cancellation-form.js +1 -1
- package/dist/cdn/foxy-cart-card.js +1 -1
- package/dist/cdn/foxy-cart-form.js +1 -1
- package/dist/cdn/foxy-client-card.js +1 -1
- package/dist/cdn/foxy-client-form.js +1 -1
- package/dist/cdn/foxy-collection-page.js +1 -1
- package/dist/cdn/foxy-collection-pages.js +1 -1
- package/dist/cdn/foxy-copy-to-clipboard.js +1 -1
- package/dist/cdn/foxy-coupon-card.js +1 -1
- package/dist/cdn/foxy-coupon-code-card.js +1 -1
- package/dist/cdn/foxy-coupon-code-form.js +1 -1
- package/dist/cdn/foxy-coupon-codes-form.js +1 -1
- package/dist/cdn/foxy-coupon-detail-card.js +1 -1
- package/dist/cdn/foxy-coupon-form.js +1 -1
- package/dist/cdn/foxy-custom-field-card.js +1 -1
- package/dist/cdn/foxy-custom-field-form.js +1 -1
- package/dist/cdn/foxy-customer-api.js +1 -1
- package/dist/cdn/foxy-customer-card.js +1 -1
- package/dist/cdn/foxy-customer-form.js +1 -1
- package/dist/cdn/foxy-customer-portal-settings-form.js +1 -1
- package/dist/cdn/foxy-customer-portal-settings.js +1 -1
- package/dist/cdn/foxy-customer-portal.js +1 -1
- package/dist/cdn/foxy-customer.js +1 -1
- package/dist/cdn/foxy-customers-table.js +1 -1
- package/dist/cdn/foxy-discount-builder.js +1 -1
- package/dist/cdn/foxy-discount-card.js +1 -1
- package/dist/cdn/foxy-discount-detail-card.js +1 -1
- package/dist/cdn/foxy-donation.js +1 -1
- package/dist/cdn/foxy-downloadable-card.js +1 -1
- package/dist/cdn/foxy-downloadable-form.js +1 -1
- package/dist/cdn/foxy-email-template-card.js +1 -1
- package/dist/cdn/foxy-email-template-form.js +1 -1
- package/dist/cdn/foxy-error-entry-card.js +1 -1
- package/dist/cdn/foxy-experimental-add-to-cart-builder.js +1 -1
- package/dist/cdn/foxy-filter-attribute-card.js +1 -1
- package/dist/cdn/foxy-filter-attribute-form.js +1 -1
- package/dist/cdn/foxy-form-dialog.js +1 -1
- package/dist/cdn/foxy-generate-codes-form.js +1 -1
- package/dist/cdn/foxy-gift-card-card.js +1 -1
- package/dist/cdn/foxy-gift-card-code-card.js +1 -1
- package/dist/cdn/foxy-gift-card-code-form.js +1 -1
- package/dist/cdn/foxy-gift-card-code-log-card.js +1 -1
- package/dist/cdn/foxy-gift-card-codes-form.js +1 -1
- package/dist/cdn/foxy-gift-card-form.js +1 -1
- package/dist/cdn/foxy-i18n-editor.js +1 -1
- package/dist/cdn/foxy-integration-card.js +1 -1
- package/dist/cdn/foxy-integration-form.js +1 -1
- package/dist/cdn/foxy-item-card.js +1 -1
- package/dist/cdn/foxy-item-category-card.js +1 -1
- package/dist/cdn/foxy-item-category-form.js +1 -1
- package/dist/cdn/foxy-item-form.js +1 -1
- package/dist/cdn/foxy-item-option-card.js +1 -1
- package/dist/cdn/foxy-item-option-form.js +1 -1
- package/dist/cdn/foxy-items-form.js +1 -1
- package/dist/cdn/foxy-native-integration-card.js +1 -1
- package/dist/cdn/foxy-native-integration-form.js +1 -1
- package/dist/cdn/foxy-nucleon-element.js +1 -1
- package/dist/cdn/foxy-pagination.js +1 -1
- package/dist/cdn/foxy-passkey-card.js +1 -1
- package/dist/cdn/foxy-passkey-form.js +1 -1
- package/dist/cdn/foxy-payment-card-embed.js +1 -1
- package/dist/cdn/foxy-payment-card.js +1 -1
- package/dist/cdn/foxy-payment-method-card.js +1 -1
- package/dist/cdn/foxy-payments-api-fraud-protection-card.js +1 -1
- package/dist/cdn/foxy-payments-api-fraud-protection-form.js +1 -1
- package/dist/cdn/foxy-payments-api-payment-method-card.js +1 -1
- package/dist/cdn/foxy-payments-api-payment-method-form.js +1 -1
- package/dist/cdn/foxy-payments-api-payment-preset-card.js +1 -1
- package/dist/cdn/foxy-payments-api-payment-preset-form.js +1 -1
- package/dist/cdn/foxy-query-builder.js +1 -1
- package/dist/cdn/foxy-report-form.js +1 -1
- package/dist/cdn/foxy-reports-table.js +6 -6
- package/dist/cdn/foxy-shipment-card.js +1 -1
- package/dist/cdn/foxy-shipping-container-card.js +1 -1
- package/dist/cdn/foxy-shipping-drop-type-card.js +1 -1
- package/dist/cdn/foxy-shipping-method-card.js +1 -1
- package/dist/cdn/foxy-shipping-service-card.js +1 -1
- package/dist/cdn/foxy-sign-in-form.js +1 -1
- package/dist/cdn/foxy-store-card.js +1 -1
- package/dist/cdn/foxy-store-form.js +1 -1
- package/dist/cdn/foxy-store-shipping-method-form.js +1 -1
- package/dist/cdn/foxy-store-transaction-folder-card.js +1 -1
- package/dist/cdn/foxy-store-transaction-folder-form.js +1 -1
- package/dist/cdn/foxy-subscription-card.js +1 -1
- package/dist/cdn/foxy-subscription-form.js +1 -1
- package/dist/cdn/foxy-subscription-settings-form.js +1 -1
- package/dist/cdn/foxy-subscriptions-table.js +1 -1
- package/dist/cdn/foxy-table.js +1 -1
- package/dist/cdn/foxy-tax-card.js +1 -1
- package/dist/cdn/foxy-tax-form.js +1 -1
- package/dist/cdn/foxy-template-config-form.js +1 -1
- package/dist/cdn/foxy-template-form.js +1 -1
- package/dist/cdn/foxy-template-set-card.js +1 -1
- package/dist/cdn/foxy-template-set-form.js +1 -1
- package/dist/cdn/foxy-transaction-card.js +1 -1
- package/dist/cdn/foxy-transaction.js +1 -1
- package/dist/cdn/foxy-transactions-table.js +1 -1
- package/dist/cdn/foxy-update-payment-method-form.js +1 -1
- package/dist/cdn/foxy-user-card.js +1 -1
- package/dist/cdn/foxy-user-form.js +1 -1
- package/dist/cdn/foxy-user-invitation-card.js +1 -1
- package/dist/cdn/foxy-user-invitation-form.js +1 -1
- package/dist/cdn/foxy-users-table.js +1 -1
- package/dist/cdn/foxy-webhook-card.js +1 -1
- package/dist/cdn/foxy-webhook-form.js +1 -1
- package/dist/cdn/foxy-webhook-log-card.js +1 -1
- package/dist/cdn/foxy-webhook-status-card.js +1 -1
- package/dist/cdn/{shared-7b6a899b.js → shared-091e97f3.js} +1 -1
- package/dist/cdn/shared-0996f4d0.js +1 -0
- package/dist/cdn/{shared-3991076b.js → shared-0b0ab3d2.js} +1 -1
- package/dist/cdn/{shared-14713ead.js → shared-18707481.js} +1 -1
- package/dist/cdn/{shared-336e73ce.js → shared-222b23bb.js} +1 -1
- package/dist/cdn/shared-2fbff8e7.js +1 -0
- package/dist/cdn/{shared-8ec1b077.js → shared-32a39c0b.js} +1 -1
- package/dist/cdn/shared-345b07f1.js +1 -0
- package/dist/cdn/{shared-bc74cd11.js → shared-3a61d8a6.js} +1 -1
- package/dist/cdn/{shared-1e9df11c.js → shared-3ef23488.js} +1 -1
- package/dist/cdn/{shared-33d770fe.js → shared-40a2705c.js} +1 -1
- package/dist/cdn/{shared-cb5305b9.js → shared-41f93e6c.js} +1 -1
- package/dist/cdn/{shared-45649d84.js → shared-4ab85bea.js} +1 -1
- package/dist/cdn/{shared-28fa98d7.js → shared-4ed4b075.js} +1 -1
- package/dist/cdn/{shared-20841d9c.js → shared-56278a3c.js} +1 -1
- package/dist/cdn/{shared-d743ec15.js → shared-5e7defee.js} +1 -1
- package/dist/cdn/{shared-59dfee2c.js → shared-7b15217c.js} +1 -1
- package/dist/cdn/{shared-1a814f90.js → shared-7e28c953.js} +1 -1
- package/dist/cdn/{shared-2652e98e.js → shared-8292d44e.js} +1 -1
- package/dist/cdn/shared-87e17c02.js +1 -0
- package/dist/cdn/{shared-a1bec4a0.js → shared-88f841ff.js} +1 -1
- package/dist/cdn/{shared-3eca56ee.js → shared-8be109a9.js} +1 -1
- package/dist/cdn/{shared-9f8b593b.js → shared-8f5c8c08.js} +1 -1
- package/dist/cdn/{shared-be20875c.js → shared-9b290320.js} +1 -1
- package/dist/cdn/{shared-b84996e5.js → shared-a95a66b8.js} +1 -1
- package/dist/cdn/{shared-4cc16cdf.js → shared-ac536c67.js} +1 -1
- package/dist/cdn/{shared-a44fcc6a.js → shared-ad5617ef.js} +1 -1
- package/dist/cdn/{shared-38e0a818.js → shared-af4f71bf.js} +1 -1
- package/dist/cdn/{shared-50ef1d5a.js → shared-c85c1864.js} +1 -1
- package/dist/cdn/{shared-760a2243.js → shared-cda51ccf.js} +1 -1
- package/dist/cdn/{shared-db17c9ee.js → shared-d2f777dc.js} +1 -1
- package/dist/cdn/{shared-fdf6df5c.js → shared-e9f9face.js} +1 -1
- package/dist/cdn/{shared-3baa9cc9.js → shared-eb349085.js} +1 -1
- package/dist/cdn/{shared-19b475f7.js → shared-f9c8881a.js} +1 -1
- package/dist/cdn/translations/user-invitation-form/en.json +4 -0
- package/dist/elements/public/AdminSubscriptionCard/AdminSubscriptionCard.js +3 -3
- package/dist/elements/public/AdminSubscriptionCard/AdminSubscriptionCard.js.map +1 -1
- package/dist/elements/public/UserInvitationForm/internal/InternalUserInvitationFormScopeControl/InternalUserInvitationFormScopeControl.d.ts +5 -2
- package/dist/elements/public/UserInvitationForm/internal/InternalUserInvitationFormScopeControl/InternalUserInvitationFormScopeControl.js +28 -8
- package/dist/elements/public/UserInvitationForm/internal/InternalUserInvitationFormScopeControl/InternalUserInvitationFormScopeControl.js.map +1 -1
- package/dist/utils/group-invitation-scopes.d.ts +1 -1
- package/dist/utils/group-invitation-scopes.js +4 -2
- package/dist/utils/group-invitation-scopes.js.map +1 -1
- package/dist/utils/invitation-scope.d.ts +1 -1
- package/dist/utils/invitation-scope.js +9 -10
- package/dist/utils/invitation-scope.js.map +1 -1
- package/dist/utils/user-scope.js +2 -2
- package/dist/utils/user-scope.js.map +1 -1
- package/package.json +1 -1
- package/dist/cdn/shared-36f1e29f.js +0 -1
- package/dist/cdn/shared-559b648a.js +0 -1
- package/dist/cdn/shared-ab1f5f1f.js +0 -1
- package/dist/cdn/shared-da3393a5.js +0 -1
|
@@ -63,9 +63,8 @@ export function serializeScope(selection) {
|
|
|
63
63
|
COLLECTIONS.forEach(collection => {
|
|
64
64
|
var _a;
|
|
65
65
|
const level = (_a = selection.levels[collection]) !== null && _a !== void 0 ? _a : 'none';
|
|
66
|
-
// Full emits both tokens rather than write alone
|
|
67
|
-
//
|
|
68
|
-
// read-only access to that collection — the anomaly would propagate down the chain.
|
|
66
|
+
// Full emits both tokens rather than write alone, so anything that still compares tokens
|
|
67
|
+
// literally, without write covering read, sees read access too.
|
|
69
68
|
if (level === 'full')
|
|
70
69
|
tokens.push(`${collection}_read`, `${collection}_write`);
|
|
71
70
|
else if (level === 'read')
|
|
@@ -94,14 +93,16 @@ export function canGrantLevel(grantable, collection, level) {
|
|
|
94
93
|
return true;
|
|
95
94
|
if (grantable.storeFullAccess)
|
|
96
95
|
return true;
|
|
97
|
-
const
|
|
96
|
+
const hasWrite = grantable.tokens.has(`${collection}_write`);
|
|
98
97
|
if (level === 'read')
|
|
99
|
-
return
|
|
100
|
-
return
|
|
98
|
+
return hasWrite || grantable.tokens.has(`${collection}_read`);
|
|
99
|
+
return hasWrite;
|
|
101
100
|
}
|
|
102
101
|
/** Whether the granter can give `collection` a resend grant. */
|
|
103
102
|
export function canGrantResend(grantable, collection) {
|
|
104
|
-
return grantable.storeFullAccess ||
|
|
103
|
+
return (grantable.storeFullAccess ||
|
|
104
|
+
grantable.tokens.has(`${collection}_write`) ||
|
|
105
|
+
grantable.tokens.has(`${collection}_resend`));
|
|
105
106
|
}
|
|
106
107
|
/**
|
|
107
108
|
* Whether the "read-only access to everything" preset can be offered.
|
|
@@ -112,8 +113,6 @@ export function canGrantResend(grantable, collection) {
|
|
|
112
113
|
* the gap.
|
|
113
114
|
*/
|
|
114
115
|
export function canGrantReadPreset(grantable) {
|
|
115
|
-
|
|
116
|
-
return true;
|
|
117
|
-
return COLLECTIONS.every(collection => grantable.tokens.has(`${collection}_read`));
|
|
116
|
+
return COLLECTIONS.every(collection => canGrantLevel(grantable, collection, 'read'));
|
|
118
117
|
}
|
|
119
118
|
//# sourceMappingURL=invitation-scope.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"invitation-scope.js","sourceRoot":"","sources":["../../src/utils/invitation-scope.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,qCAAkC;AAoBpE,MAAM,QAAQ,GAAG,CAAC,KAAyB,EAAe,EAAE;IAC1D,OAAO,IAAI,GAAG,CAAC,CAAC,KAAK,aAAL,KAAK,cAAL,KAAK,GAAI,EAAE,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC;AAC/E,CAAC,CAAC;AAEF,iFAAiF;AACjF,MAAM,UAAU,UAAU,CAAC,KAAyB;IAClD,MAAM,MAAM,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC;IAC/B,MAAM,KAAK,GAAG,IAAI,GAAG,EAAU,CAAC;IAChC,MAAM,MAAM,GAA0B,EAAE,CAAC;IAEzC,WAAW,CAAC,OAAO,CAAC,UAAU,CAAC,EAAE;QAC/B,MAAM,IAAI,GAAG,GAAG,UAAU,OAAO,CAAC;QAClC,MAAM,KAAK,GAAG,GAAG,UAAU,QAAQ,CAAC;QAEpC,oFAAoF;QACpF,uEAAuE;QACvE,IAAI,MAAM,CAAC,GAAG,C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,CAAC,CAC7C,CAAC;AACJ,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,kBAAkB,CAAC,SAAoB;IACrD,OAAO,WAAW,CAAC,KAAK,CAAC,UAAU,CAAC,EAAE,CAAC,aAAa,CAAC,SAAS,EAAE,UAAU,EAAE,MAAM,CAAC,CAAC,CAAC;AACvF,CAAC","sourcesContent":["import { COLLECTIONS, RESENDABLE } from './group-invitation-scopes';\n\n/** Access level a single collection can be granted at. */\nexport type Level = 'none' | 'read' | 'full';\n\nexport type Selection = {\n /** `null` means nothing has been chosen yet, which the form's v8n rule rejects. */\n preset: 'store' | 'read' | 'custom' | null;\n /** Level per collection, keyed by the tokens in `COLLECTIONS`. Always fully populated. */\n levels: Record<string, Level>;\n /** Collections with their own `_resend` token. The API includes resend in `full`. */\n resend: string[];\n /**\n * Tokens this UI does not model, carried through untouched. `client_full_access` and\n * `user_full_access` are valid grants the API accepts but the matrix cannot express, so\n * dropping them on a round trip would silently revoke access the invitation already had.\n */\n extra: string[];\n};\n\nconst tokenize = (scope: string | undefined): Set<string> => {\n return new Set((scope ?? '').split(/\\s+/).filter(token => token.length > 0));\n};\n\n/** Parses an invitation's space-separated `scope` string into a UI selection. */\nexport function parseScope(scope: string | undefined): Selection {\n const tokens = tokenize(scope);\n const known = new Set<string>();\n const levels: Record<string, Level> = {};\n\n COLLECTIONS.forEach(collection => {\n const read = `${collection}_read`;\n const write = `${collection}_write`;\n\n // A write token means full access whether or not the read token is present. The API\n // treats write as implying read, so a lone write is still full access.\n if (tokens.has(write)) levels[collection] = 'full';\n else if (tokens.has(read)) levels[collection] = 'read';\n else levels[collection] = 'none';\n\n if (tokens.has(read)) known.add(read);\n if (tokens.has(write)) known.add(write);\n });\n\n const resend = RESENDABLE.filter(collection => {\n const token = `${collection}_resend`;\n if (!tokens.has(token)) return false;\n known.add(token);\n return true;\n });\n\n const isStore = tokens.has('store_full_access');\n if (isStore) known.add('store_full_access');\n\n const extra = [...tokens].filter(token => !known.has(token));\n\n let preset: Selection['preset'];\n\n if (isStore) {\n preset = 'store';\n } else if (!tokens.size) {\n preset = null;\n } else if (\n !resend.length &&\n !extra.length &&\n COLLECTIONS.every(collection => levels[collection] === 'read')\n ) {\n preset = 'read';\n } else {\n preset = 'custom';\n }\n\n return { preset, levels, resend, extra: [...extra] };\n}\n\n/** Serializes a UI selection back into a space-separated `scope` string. */\nexport function serializeScope(selection: Selection): string {\n // The store wildcard does NOT supersede `client_full_access` / `user_full_access`:\n // the API treats all three as distinct, independently-granted\n // always-allowed tokens. Dropping preserved extras here would silently revoke whichever\n // of those the invitation already held.\n if (selection.preset === 'store') return ['store_full_access', ...selection.extra].join(' ');\n\n const tokens: string[] = [];\n\n COLLECTIONS.forEach(collection => {\n const level = selection.levels[collection] ?? 'none';\n\n // Full emits both tokens rather than write alone, so anything that still compares tokens\n // literally, without write covering read, sees read access too.\n if (level === 'full') tokens.push(`${collection}_read`, `${collection}_write`);\n else if (level === 'read') tokens.push(`${collection}_read`);\n });\n\n RESENDABLE.forEach(collection => {\n if (selection.resend.includes(collection)) tokens.push(`${collection}_resend`);\n });\n\n return [...tokens, ...selection.extra].join(' ');\n}\n\n/** The granter's own scope, prepared for membership checks. */\nexport type Grantable = { storeFullAccess: boolean; tokens: Set<string> };\n\n/**\n * Prepares the granting user's scope for grantability checks.\n *\n * The server is the enforcement boundary — it rejects any\n * token the granter does not hold. These helpers exist so the UI never offers a grant that\n * would be rejected, not to implement the restriction.\n */\nexport function getGrantable(granterScope: string | undefined): Grantable {\n const tokens = tokenize(granterScope);\n return { storeFullAccess: tokens.has('store_full_access'), tokens };\n}\n\n/** Whether the granter can give `collection` at `level`. */\nexport function canGrantLevel(grantable: Grantable, collection: string, level: Level): boolean {\n if (level === 'none') return true;\n if (grantable.storeFullAccess) return true;\n\n const hasWrite = grantable.tokens.has(`${collection}_write`);\n if (level === 'read') return hasWrite || grantable.tokens.has(`${collection}_read`);\n\n return hasWrite;\n}\n\n/** Whether the granter can give `collection` a resend grant. */\nexport function canGrantResend(grantable: Grantable, collection: string): boolean {\n return (\n grantable.storeFullAccess ||\n grantable.tokens.has(`${collection}_write`) ||\n grantable.tokens.has(`${collection}_resend`)\n );\n}\n\n/**\n * Whether the \"read-only access to everything\" preset can be offered.\n *\n * It is hidden unless the granter can deliver all 20 reads. Silently redefining it as\n * \"read-only on whatever I happen to be able to share\" would make one preset mean different\n * things to different admins, which is a worse trap than an absent option — `Custom` covers\n * the gap.\n */\nexport function canGrantReadPreset(grantable: Grantable): boolean {\n return COLLECTIONS.every(collection => canGrantLevel(grantable, collection, 'read'));\n}\n"]}
|
package/dist/utils/user-scope.js
CHANGED
|
@@ -14,9 +14,9 @@ export function parseUserScope(scope) {
|
|
|
14
14
|
const canWrite = (c) => tokens.has(`${c}_write`) || (c === 'users' && tokens.has('user_full_access'));
|
|
15
15
|
return {
|
|
16
16
|
canWrite,
|
|
17
|
-
// A write scope satisfies a read check in the API.
|
|
17
|
+
// A write scope satisfies a read or resend check in the API.
|
|
18
18
|
canRead: c => canWrite(c) || tokens.has(`${c}_read`),
|
|
19
|
-
canResend: c => tokens.has(`${c}_resend`),
|
|
19
|
+
canResend: c => canWrite(c) || tokens.has(`${c}_resend`),
|
|
20
20
|
};
|
|
21
21
|
}
|
|
22
22
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"user-scope.js","sourceRoot":"","sources":["../../src/utils/user-scope.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,qCAAkC;AAqBxD;;;;GAIG;AACH,MAAM,UAAU,cAAc,CAAC,KAAgC;IAC7D,MAAM,MAAM,GAAG,IAAI,GAAG,CAAC,CAAC,KAAK,aAAL,KAAK,cAAL,KAAK,GAAI,EAAE,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC;IACrF,IAAI,MAAM,CAAC,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C,CAAC,CAAC;IAC1D,IAAI,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,KAAK,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC;QAAE,OAAO,GAAG,CAAC;IACnD,IAAI,IAAI,CAAC,MAAM;QAAE,SAAS,CAAC,YAAY,CAAC,GAAG,CAAC,MAAM,EAAE,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;;QAC/D,SAAS,CAAC,YAAY,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;IAE3C,OAAO,SAAS,CAAC,QAAQ,EAAE,CAAC;AAC9B,CAAC","sourcesContent":["import { COLLECTIONS } from './group-invitation-scopes';\n\n/** `users` is not an invitation collection, but `user_full_access` grants it. */\nexport type ScopeCollection = (typeof COLLECTIONS)[number] | 'users';\n\nexport type UserScope = {\n canRead(collection: ScopeCollection): boolean;\n canWrite(collection: ScopeCollection): boolean;\n canResend(collection: ScopeCollection): boolean;\n};\n\nexport type ScopeRule = {\n /** Control path (as used by `hiddencontrols` / `readonlycontrols`) this rule applies to. */\n path: string;\n collection: ScopeCollection;\n /** Permission required to show the control. Defaults to `read`. */\n need?: 'read' | 'write' | 'resend';\n /** Show the control, but make it readonly when the user cannot write the collection. */\n readonlyIfNoWrite?: boolean;\n};\n\n/**\n * Parses a space-separated API token scope. Returns `null` when the scope does not restrict\n * store collections (no scope, `store_full_access`, or no collection tokens), meaning the UI\n * must stay unchanged.\n */\nexport function parseUserScope(scope: string | null | undefined): UserScope | null {\n const tokens = new Set((scope ?? '').split(/\\s+/).filter(token => token.length > 0));\n if (tokens.has('store_full_access')) return null;\n\n const isStoreScoped = COLLECTIONS.some(\n c => tokens.has(`${c}_read`) || tokens.has(`${c}_write`) || tokens.has(`${c}_resend`)\n );\n if (!isStoreScoped) return null;\n\n const canWrite = (c: ScopeCollection) =>\n tokens.has(`${c}_write`) || (c === 'users' && tokens.has('user_full_access'));\n\n return {\n canWrite,\n // A write scope satisfies a read or resend check in the API.\n canRead: c => canWrite(c) || tokens.has(`${c}_read`),\n canResend: c => canWrite(c) || tokens.has(`${c}_resend`),\n };\n}\n\n/**\n * Returns `true` when the scope can read the collection, or when the scope does not restrict\n * store collections at all (unset, `store_full_access`, no collection tokens).\n */\nexport function canReadCollection(\n scope: string | null | undefined,\n collection: ScopeCollection\n): boolean {\n return parseUserScope(scope)?.canRead(collection) ?? true;\n}\n\n/** Turns scope rules into control selectors to hide or make readonly. */\nexport function getScopeSelectors(\n scope: UserScope | null,\n rules: ScopeRule[],\n own: ScopeCollection | null\n): { hidden: string[]; readonly: string[]; readonlyAll: boolean } {\n const result = { hidden: [] as string[], readonly: [] as string[], readonlyAll: false };\n if (!scope) return result;\n\n const check = { read: scope.canRead, write: scope.canWrite, resend: scope.canResend };\n\n for (const { path, collection, need = 'read', readonlyIfNoWrite } of rules) {\n if (!check[need](collection)) result.hidden.push(path);\n else if (readonlyIfNoWrite && !scope.canWrite(collection)) result.readonly.push(path);\n }\n\n // Own collection with no read access is left alone: the API's \"Access denied\" covers it.\n if (own && scope.canRead(own) && !scope.canWrite(own)) {\n result.readonlyAll = true;\n result.hidden.push('delete', 'create');\n }\n\n return result;\n}\n\n/**\n * Collection that gates a zoomed rel. A rel that is not listed (items, discounts, applied\n * taxes, attributes...) belongs to its parent, which is already readable, so it is kept.\n */\nconst ZOOM_COLLECTIONS: Record<string, ScopeCollection> = {\n applied_gift_card_codes: 'gift_cards',\n billing_addresses: 'transactions',\n cart: 'carts',\n coupon: 'coupons',\n coupon_code: 'coupons',\n customer: 'customers',\n default_billing_address: 'customers',\n default_payment_method: 'customers',\n default_shipping_address: 'customers',\n downloadable: 'downloadables',\n email_template: 'templates',\n folder: 'transactions',\n gift_card: 'gift_cards',\n gift_card_code: 'gift_cards',\n gift_card_code_logs: 'gift_cards',\n item_category: 'item_categories',\n last_transaction: 'transactions',\n original_transaction: 'transactions',\n payments: 'transactions',\n shipments: 'transactions',\n store: 'stores',\n subscription: 'subscriptions',\n tax: 'taxes',\n template_set: 'templates',\n transaction: 'transactions',\n transaction_template: 'carts',\n};\n\n/**\n * Removes the zoom paths the scope can't read from a URL. The API denies the whole request\n * when one zoomed resource can't be read. Returns the URL unchanged when the scope does not\n * restrict store collections.\n */\nexport function filterZoom(url: string, scope: string | null | undefined): string {\n const userScope = parseUserScope(scope);\n if (!userScope || !url.includes('zoom=')) return url;\n\n const parsedURL = new URL(url);\n const paths = (parsedURL.searchParams.get('zoom') ?? '').split(',').filter(Boolean);\n const isReadable = (rel: string) => {\n const collection = ZOOM_COLLECTIONS[rel];\n return !collection || userScope.canRead(collection);\n };\n\n // Keep the readable start of each path: `items:item_category` becomes `items`.\n const trimmed = paths.map(path => {\n const rels = path.split(':');\n const end = rels.findIndex(rel => !isReadable(rel));\n return end === -1 ? path : rels.slice(0, end).join(':');\n });\n\n const kept = Array.from(new Set(trimmed.filter(Boolean)));\n if (kept.join(',') === paths.join(',')) return url;\n if (kept.length) parsedURL.searchParams.set('zoom', kept.join(','));\n else parsedURL.searchParams.delete('zoom');\n\n return parsedURL.toString();\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{i as a}from"./shared-50ef1d5a.js";async function t(t){try{return await t}catch(t){if(t instanceof Response&&await a(t))return;throw t}}export{t as i};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import"./foxy-spinner.js";import{I as e}from"./shared-20841d9c.js";customElements.define("foxy-internal-card",e);
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{p as t,c as n}from"./shared-da3393a5.js";function r(t){return(null==t?void 0:t._links["fx:cart"])?"carts":(null==t?void 0:t._links["fx:transaction"])?"transactions":null}function s(r,s,a){var i;if(!t(r))return!0;const c=t=>n(r,t),o=null!==(i=null==s?void 0:s._links)&&void 0!==i?i:{};if(o["fx:transaction"]&&c("transactions"))return!0;return!(!c("carts")||!o["fx:cart"]&&(!o["fx:subscription"]||!c("subscriptions")))&&(!(a&&!a.currency_code)||!!c("templates")&&(""!==a.template_set_uri||c("stores")))}export{s as c,r as g};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
const s=["carts","coupons","customers","customer_portal_settings","downloadables","gift_cards","integrations","item_categories","payment_settings","reporting","shipping_integrations","shipping_settings","stores","subscriptions","subscription_settings","taxes","templates","transactions","user_invitations","webhooks"],e=["transactions","webhooks","taxes"];function t(t){const n=new Set((null!=t?t:"").split(/\s+/).filter((s=>s.length>0)));if(n.has("store_full_access"))return{storeFullAccess:!0,full:[],read:[],resend:[]};const a=[],r=[],o=[];return s.forEach((s=>{n.has(`${s}_write`)?a.push(s):n.has(`${s}_read`)&&r.push(s);e.includes(s)&&n.has(`${s}_resend`)&&o.push(s)})),{storeFullAccess:!1,full:a,read:r,resend:o}}function n(e){const t=new Set((null!=e?e:"").split(/\s+/).filter((s=>s.length>0)));if(t.has("store_full_access"))return null;if(!s.some((s=>t.has(`${s}_read`)||t.has(`${s}_write`)||t.has(`${s}_resend`))))return null;const n=s=>t.has(`${s}_write`)||"users"===s&&t.has("user_full_access");return{canWrite:n,canRead:s=>n(s)||t.has(`${s}_read`),canResend:s=>t.has(`${s}_resend`)}}function a(s,e){var t,a;return null===(a=null===(t=n(s))||void 0===t?void 0:t.canRead(e))||void 0===a||a}function r(s,e,t){const n={hidden:[],readonly:[],readonlyAll:!1};if(!s)return n;const a={read:s.canRead,write:s.canWrite,resend:s.canResend};for(const{path:t,collection:r,need:o="read",readonlyIfNoWrite:i}of e)a[o](r)?i&&!s.canWrite(r)&&n.readonly.push(t):n.hidden.push(t);return t&&s.canRead(t)&&!s.canWrite(t)&&(n.readonlyAll=!0,n.hidden.push("delete","create")),n}const o={applied_gift_card_codes:"gift_cards",billing_addresses:"transactions",cart:"carts",coupon:"coupons",coupon_code:"coupons",customer:"customers",default_billing_address:"customers",default_payment_method:"customers",default_shipping_address:"customers",downloadable:"downloadables",email_template:"templates",folder:"transactions",gift_card:"gift_cards",gift_card_code:"gift_cards",gift_card_code_logs:"gift_cards",item_category:"item_categories",last_transaction:"transactions",original_transaction:"transactions",payments:"transactions",shipments:"transactions",store:"stores",subscription:"subscriptions",tax:"taxes",template_set:"templates",transaction:"transactions",transaction_template:"carts"};function i(s,e){var t;const a=n(e);if(!a||!s.includes("zoom="))return s;const r=new URL(s),i=(null!==(t=r.searchParams.get("zoom"))&&void 0!==t?t:"").split(",").filter(Boolean),c=i.map((s=>{const e=s.split(":"),t=e.findIndex((s=>!(s=>{const e=o[s];return!e||a.canRead(e)})(s)));return-1===t?s:e.slice(0,t).join(":")})),l=Array.from(new Set(c.filter(Boolean)));return l.join(",")===i.join(",")?s:(l.length?r.searchParams.set("zoom",l.join(",")):r.searchParams.delete("zoom"),r.toString())}export{s as C,e as R,t as a,a as c,i as f,r as g,n as p};
|