@kya-os/consent 0.1.46 → 0.1.48
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/README.md +89 -0
- package/dist/bundle/index.d.ts +2 -0
- package/dist/bundle/index.d.ts.map +1 -1
- package/dist/bundle/index.js +1 -0
- package/dist/bundle/index.js.map +1 -1
- package/dist/bundle/inline.d.ts.map +1 -1
- package/dist/bundle/inline.js +4 -4
- package/dist/bundle/inline.js.map +1 -1
- package/dist/capabilities/registry.d.ts.map +1 -1
- package/dist/capabilities/registry.js +5 -1
- package/dist/capabilities/registry.js.map +1 -1
- package/dist/cedar/compile.d.ts +67 -2
- package/dist/cedar/compile.d.ts.map +1 -1
- package/dist/cedar/compile.js +34 -5
- package/dist/cedar/compile.js.map +1 -1
- package/dist/cedar/index.d.ts +1 -0
- package/dist/cedar/index.d.ts.map +1 -1
- package/dist/cedar/index.js.map +1 -1
- package/dist/cjs/bundle/index.js +3 -1
- package/dist/cjs/bundle/index.js.map +1 -1
- package/dist/cjs/bundle/inline.js +4 -4
- package/dist/cjs/bundle/inline.js.map +1 -1
- package/dist/cjs/capabilities/registry.js +5 -1
- package/dist/cjs/capabilities/registry.js.map +1 -1
- package/dist/cjs/cedar/compile.js +34 -5
- package/dist/cjs/cedar/compile.js.map +1 -1
- package/dist/cjs/cedar/index.js.map +1 -1
- package/dist/cjs/components/consent-action-bar.js +16 -5
- package/dist/cjs/components/consent-action-bar.js.map +1 -1
- package/dist/cjs/components/consent-capabilities-screen.js +92 -37
- package/dist/cjs/components/consent-capabilities-screen.js.map +1 -1
- package/dist/cjs/components/consent-capability-card.js +35 -4
- package/dist/cjs/components/consent-capability-card.js.map +1 -1
- package/dist/cjs/components/mcp-consent.js +91 -25
- package/dist/cjs/components/mcp-consent.js.map +1 -1
- package/dist/cjs/constants/capabilities.js +10 -0
- package/dist/cjs/constants/capabilities.js.map +1 -0
- package/dist/cjs/constants/index.js +3 -1
- package/dist/cjs/constants/index.js.map +1 -1
- package/dist/cjs/mcp-app/inline.js +2 -2
- package/dist/cjs/mcp-app/inline.js.map +1 -1
- package/dist/cjs/resolution/credential-capabilities.js +16 -0
- package/dist/cjs/resolution/credential-capabilities.js.map +1 -1
- package/dist/cjs/resolution/selected-capabilities.js +73 -0
- package/dist/cjs/resolution/selected-capabilities.js.map +1 -0
- package/dist/cjs/schemas/capabilities.schemas.js +14 -2
- package/dist/cjs/schemas/capabilities.schemas.js.map +1 -1
- package/dist/cjs/security/identity-assertion.js +69 -0
- package/dist/cjs/security/identity-assertion.js.map +1 -0
- package/dist/cjs/security/index.js +1 -0
- package/dist/cjs/security/index.js.map +1 -1
- package/dist/cjs/types/capabilities.types.js +55 -0
- package/dist/cjs/types/capabilities.types.js.map +1 -1
- package/dist/components/consent-action-bar.d.ts +2 -0
- package/dist/components/consent-action-bar.d.ts.map +1 -1
- package/dist/components/consent-action-bar.js +16 -5
- package/dist/components/consent-action-bar.js.map +1 -1
- package/dist/components/consent-capabilities-screen.d.ts +18 -5
- package/dist/components/consent-capabilities-screen.d.ts.map +1 -1
- package/dist/components/consent-capabilities-screen.js +92 -37
- package/dist/components/consent-capabilities-screen.js.map +1 -1
- package/dist/components/consent-capability-card.d.ts +2 -0
- package/dist/components/consent-capability-card.d.ts.map +1 -1
- package/dist/components/consent-capability-card.js +35 -4
- package/dist/components/consent-capability-card.js.map +1 -1
- package/dist/components/mcp-consent.d.ts +30 -0
- package/dist/components/mcp-consent.d.ts.map +1 -1
- package/dist/components/mcp-consent.js +92 -26
- package/dist/components/mcp-consent.js.map +1 -1
- package/dist/consent.js +280 -48
- package/dist/consent.min.js +200 -153
- package/dist/constants/capabilities.d.ts +7 -0
- package/dist/constants/capabilities.d.ts.map +1 -0
- package/dist/constants/capabilities.js +7 -0
- package/dist/constants/capabilities.js.map +1 -0
- package/dist/constants/index.d.ts +1 -0
- package/dist/constants/index.d.ts.map +1 -1
- package/dist/constants/index.js +1 -0
- package/dist/constants/index.js.map +1 -1
- package/dist/mcp-app/inline.d.ts.map +1 -1
- package/dist/mcp-app/inline.js +2 -2
- package/dist/mcp-app/inline.js.map +1 -1
- package/dist/resolution/credential-capabilities.d.ts +15 -2
- package/dist/resolution/credential-capabilities.d.ts.map +1 -1
- package/dist/resolution/credential-capabilities.js +15 -0
- package/dist/resolution/credential-capabilities.js.map +1 -1
- package/dist/resolution/selected-capabilities.d.ts +26 -0
- package/dist/resolution/selected-capabilities.d.ts.map +1 -0
- package/dist/resolution/selected-capabilities.js +69 -0
- package/dist/resolution/selected-capabilities.js.map +1 -0
- package/dist/schemas/api.schemas.d.ts +88 -68
- package/dist/schemas/api.schemas.d.ts.map +1 -1
- package/dist/schemas/branding.schemas.d.ts +2 -2
- package/dist/schemas/capabilities.schemas.d.ts +58 -12
- package/dist/schemas/capabilities.schemas.d.ts.map +1 -1
- package/dist/schemas/capabilities.schemas.js +14 -2
- package/dist/schemas/capabilities.schemas.js.map +1 -1
- package/dist/schemas/config.schemas.d.ts +140 -100
- package/dist/schemas/config.schemas.d.ts.map +1 -1
- package/dist/security/identity-assertion.d.ts +49 -0
- package/dist/security/identity-assertion.d.ts.map +1 -0
- package/dist/security/identity-assertion.js +66 -0
- package/dist/security/identity-assertion.js.map +1 -0
- package/dist/security/index.d.ts +1 -0
- package/dist/security/index.d.ts.map +1 -1
- package/dist/security/index.js +1 -0
- package/dist/security/index.js.map +1 -1
- package/dist/types/capabilities.types.d.ts +69 -0
- package/dist/types/capabilities.types.d.ts.map +1 -1
- package/dist/types/capabilities.types.js +53 -1
- package/dist/types/capabilities.types.js.map +1 -1
- package/package.json +6 -4
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"inline.js","sourceRoot":"","sources":["../../../src/mcp-app/inline.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;GAWG;;;AAEH,sEAAsE;AACzD,QAAA,oBAAoB,GAAW
|
|
1
|
+
{"version":3,"file":"inline.js","sourceRoot":"","sources":["../../../src/mcp-app/inline.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;GAWG;;;AAEH,sEAAsE;AACzD,QAAA,oBAAoB,GAAW,mnxvBAAmnxvB,CAAC;AAEhqxvB,4CAA4C;AAC/B,QAAA,yBAAyB,GAAW,MAAM,CAAC"}
|
|
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.shouldRenderCapabilityScreen = shouldRenderCapabilityScreen;
|
|
4
4
|
exports.shouldSelectAllCapabilities = shouldSelectAllCapabilities;
|
|
5
5
|
exports.areCredentialsComplete = areCredentialsComplete;
|
|
6
|
+
exports.shouldRenderScopesInteractive = shouldRenderScopesInteractive;
|
|
6
7
|
exports.capabilityIdsFor = capabilityIdsFor;
|
|
7
8
|
exports.capabilitySeedKey = capabilitySeedKey;
|
|
8
9
|
const modes_types_js_1 = require("../types/modes.types.js");
|
|
@@ -30,6 +31,21 @@ function areCredentialsComplete(formData) {
|
|
|
30
31
|
return ((formData.username?.trim().length ?? 0) > 0 &&
|
|
31
32
|
(formData.password?.trim().length ?? 0) > 0);
|
|
32
33
|
}
|
|
34
|
+
/**
|
|
35
|
+
* Whether the legacy scope-selection checkboxes (`renderPermissions` /
|
|
36
|
+
* `<consent-permissions>`) should render as interactive. When a signed
|
|
37
|
+
* identity assertion is bound to the request, `handleApprove` always posts
|
|
38
|
+
* the full requested scope set - the assertion binds a hash of that full
|
|
39
|
+
* set, so a user-narrowed subset would fail the mint gate's hash check and
|
|
40
|
+
* 403 (see the comment on the `scopes` form-data append in mcp-consent.ts).
|
|
41
|
+
* Letting the user uncheck a scope that will be granted regardless is a
|
|
42
|
+
* consent-accuracy bug, so this path drops to display-only rows instead.
|
|
43
|
+
* Interactive narrowing returns once the deferred subset-binding follow-up
|
|
44
|
+
* ships.
|
|
45
|
+
*/
|
|
46
|
+
function shouldRenderScopesInteractive(identityAssertion) {
|
|
47
|
+
return !identityAssertion;
|
|
48
|
+
}
|
|
33
49
|
/**
|
|
34
50
|
* Which capabilities count as selected. In disclosure mode every capability is
|
|
35
51
|
* granted, so all ids are returned; otherwise the operator's `defaultOn` seeds
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"credential-capabilities.js","sourceRoot":"","sources":["../../../src/resolution/credential-capabilities.ts"],"names":[],"mappings":";;AAaA,oEAKC;AAOD,kEAEC;AAED,wDAOC;AAOD,4CAOC;AASD,8CAKC;
|
|
1
|
+
{"version":3,"file":"credential-capabilities.js","sourceRoot":"","sources":["../../../src/resolution/credential-capabilities.ts"],"names":[],"mappings":";;AAaA,oEAKC;AAOD,kEAEC;AAED,wDAOC;AAcD,sEAIC;AAOD,4CAOC;AASD,8CAKC;AAlFD,4DAAoE;AAGpE;;;;GAIG;AACH,MAAM,uBAAuB,GAAwB;IACnD,2BAAU,CAAC,YAAY;IACvB,2BAAU,CAAC,WAAW;CACvB,CAAC;AAEF,SAAgB,4BAA4B,CAC1C,IAAc,EACd,eAAuB;IAEvB,OAAO,eAAe,GAAG,CAAC,IAAI,uBAAuB,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;AACvE,CAAC;AAED;;;;GAIG;AACH,SAAgB,2BAA2B,CAAC,IAAc;IACxD,OAAO,IAAI,KAAK,2BAAU,CAAC,WAAW,CAAC;AACzC,CAAC;AAED,SAAgB,sBAAsB,CACpC,QAAgC;IAEhC,OAAO,CACL,CAAC,QAAQ,CAAC,QAAQ,EAAE,IAAI,EAAE,CAAC,MAAM,IAAI,CAAC,CAAC,GAAG,CAAC;QAC3C,CAAC,QAAQ,CAAC,QAAQ,EAAE,IAAI,EAAE,CAAC,MAAM,IAAI,CAAC,CAAC,GAAG,CAAC,CAC5C,CAAC;AACJ,CAAC;AAED;;;;;;;;;;;GAWG;AACH,SAAgB,6BAA6B,CAC3C,iBAAqC;IAErC,OAAO,CAAC,iBAAiB,CAAC;AAC5B,CAAC;AAED;;;;GAIG;AACH,SAAgB,gBAAgB,CAC9B,YAAiE,EACjE,cAAuB;IAEvB,OAAO,YAAY;SAChB,MAAM,CAAC,CAAC,UAAU,EAAE,EAAE,CAAC,cAAc,IAAI,UAAU,CAAC,SAAS,CAAC;SAC9D,GAAG,CAAC,CAAC,UAAU,EAAE,EAAE,CAAC,UAAU,CAAC,EAAE,CAAC,CAAC;AACxC,CAAC;AAED;;;;;;GAMG;AACH,SAAgB,iBAAiB,CAC/B,YAAiE,EACjE,WAAoB;IAEpB,OAAO,GAAG,WAAW,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,YAAY,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC;AAC7E,CAAC"}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.projectRequestedCapabilities = projectRequestedCapabilities;
|
|
4
|
+
exports.resolveCapabilitySelection = resolveCapabilitySelection;
|
|
5
|
+
const MAPPING_ERROR = "The displayed capability scopes do not match the requested permissions. Contact the service operator.";
|
|
6
|
+
const SELECTION_ERROR = "Select at least one listed permission.";
|
|
7
|
+
function strings(value) {
|
|
8
|
+
return Array.isArray(value) && value.every((item) => typeof item === "string" && item.length > 0);
|
|
9
|
+
}
|
|
10
|
+
function sameSet(left, right) {
|
|
11
|
+
return left.size === right.size && [...left].every((value) => right.has(value));
|
|
12
|
+
}
|
|
13
|
+
/** Project a registry or project catalog onto this request before disclosure.
|
|
14
|
+
* Never rewrite a broader Cedar template as if it were an exact grant policy. */
|
|
15
|
+
function projectRequestedCapabilities(requestedScopes, capabilities) {
|
|
16
|
+
if (!strings(requestedScopes) || requestedScopes.length === 0 ||
|
|
17
|
+
capabilities.length === 0 || capabilities.some((capability) => !capability || typeof capability.id !== "string" || !capability.id ||
|
|
18
|
+
!strings(capability.scopes) || capability.scopes.length === 0)) {
|
|
19
|
+
return { ok: false, error: MAPPING_ERROR };
|
|
20
|
+
}
|
|
21
|
+
const knownIds = new Set(capabilities.map((capability) => capability.id));
|
|
22
|
+
const requested = new Set(requestedScopes);
|
|
23
|
+
const disclosed = new Set(capabilities.flatMap((capability) => capability.scopes));
|
|
24
|
+
// Credential session keys hash the requested array, including duplicates.
|
|
25
|
+
// Reject ambiguous requests instead of silently normalizing their key.
|
|
26
|
+
if (requested.size !== requestedScopes.length ||
|
|
27
|
+
knownIds.size !== capabilities.length || [...requested].some((scope) => !disclosed.has(scope))) {
|
|
28
|
+
return { ok: false, error: MAPPING_ERROR };
|
|
29
|
+
}
|
|
30
|
+
const projected = capabilities.flatMap((capability) => {
|
|
31
|
+
const scopes = requestedScopes.filter((scope) => capability.scopes.includes(scope));
|
|
32
|
+
if (scopes.length === 0)
|
|
33
|
+
return [];
|
|
34
|
+
return [{
|
|
35
|
+
...capability,
|
|
36
|
+
scopes,
|
|
37
|
+
// Keep the operator's exact policy only when its full scope set applies.
|
|
38
|
+
cedar: scopes.length === new Set(capability.scopes).size ? capability.cedar : "",
|
|
39
|
+
}];
|
|
40
|
+
});
|
|
41
|
+
return { ok: true, capabilities: projected };
|
|
42
|
+
}
|
|
43
|
+
/** Derive the posted scope set from the reviewed capability IDs, without aliases
|
|
44
|
+
* or implicit widening. An assertion-bound or credential grant is indivisible. */
|
|
45
|
+
function resolveCapabilitySelection(requestedScopes, capabilities, detail, requireAll = false) {
|
|
46
|
+
const projection = projectRequestedCapabilities(requestedScopes, capabilities);
|
|
47
|
+
if (!projection.ok)
|
|
48
|
+
return projection;
|
|
49
|
+
const requestedCapabilities = projection.capabilities;
|
|
50
|
+
const knownIds = new Set(requestedCapabilities.map((capability) => capability.id));
|
|
51
|
+
if (!detail || typeof detail !== "object" ||
|
|
52
|
+
!("selectedCapabilityIds" in detail) || !strings(detail.selectedCapabilityIds) ||
|
|
53
|
+
!("selectedScopes" in detail) || !strings(detail.selectedScopes)) {
|
|
54
|
+
return { ok: false, error: SELECTION_ERROR };
|
|
55
|
+
}
|
|
56
|
+
const selectedIds = new Set(detail.selectedCapabilityIds);
|
|
57
|
+
if (selectedIds.size === 0 || selectedIds.size !== detail.selectedCapabilityIds.length ||
|
|
58
|
+
[...selectedIds].some((id) => !knownIds.has(id))) {
|
|
59
|
+
return { ok: false, error: SELECTION_ERROR };
|
|
60
|
+
}
|
|
61
|
+
if (requireAll && selectedIds.size !== knownIds.size) {
|
|
62
|
+
return { ok: false, error: "This grant requires every listed permission. Select all permissions or deny the request." };
|
|
63
|
+
}
|
|
64
|
+
const selectedScopes = new Set(requestedCapabilities
|
|
65
|
+
.filter((capability) => selectedIds.has(capability.id))
|
|
66
|
+
.flatMap((capability) => capability.scopes));
|
|
67
|
+
if (!sameSet(selectedScopes, new Set(detail.selectedScopes))) {
|
|
68
|
+
return { ok: false, error: SELECTION_ERROR };
|
|
69
|
+
}
|
|
70
|
+
// Preserve the canonical request ordering used by credential session keys.
|
|
71
|
+
return { ok: true, scopes: requestedScopes.filter((scope) => selectedScopes.has(scope)) };
|
|
72
|
+
}
|
|
73
|
+
//# sourceMappingURL=selected-capabilities.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"selected-capabilities.js","sourceRoot":"","sources":["../../../src/resolution/selected-capabilities.ts"],"names":[],"mappings":";;AAwBA,oEA8BC;AAID,gEA+BC;AA/ED,MAAM,aAAa,GACjB,uGAAuG,CAAC;AAC1G,MAAM,eAAe,GAAG,wCAAwC,CAAC;AAEjE,SAAS,OAAO,CAAC,KAAc;IAC7B,OAAO,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,IAAI,KAAK,CAAC,KAAK,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,OAAO,IAAI,KAAK,QAAQ,IAAI,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;AACpG,CAAC;AAED,SAAS,OAAO,CAAC,IAAiB,EAAE,KAAkB;IACpD,OAAO,IAAI,CAAC,IAAI,KAAK,KAAK,CAAC,IAA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EAAE,CAAC;IAC/C,CAAC;IACD,2EAA2E;IAC3E,OAAO,EAAE,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,eAAe,CAAC,MAAM,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,cAAc,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC;AAC5F,CAAC"}
|
|
@@ -15,6 +15,7 @@ exports.validateCapability = validateCapability;
|
|
|
15
15
|
exports.validateCapabilityGroup = validateCapabilityGroup;
|
|
16
16
|
exports.validateAgentMetadata = validateAgentMetadata;
|
|
17
17
|
const zod_1 = require("zod");
|
|
18
|
+
const capabilities_types_js_1 = require("../types/capabilities.types.js");
|
|
18
19
|
/**
|
|
19
20
|
* Risk classification.
|
|
20
21
|
*/
|
|
@@ -52,8 +53,15 @@ exports.CedarPolicySchema = zod_1.z
|
|
|
52
53
|
.refine((value) => /^\s*(permit|forbid)\s*\(/.test(value), "Cedar fragment must begin with `permit (` or `forbid (`");
|
|
53
54
|
/**
|
|
54
55
|
* A single capability row.
|
|
56
|
+
*
|
|
57
|
+
* First-Contact Scope Cap (design doc section 3, rule 1): a `high` or
|
|
58
|
+
* `critical` capability can never carry `defaultOn: true`. That combination
|
|
59
|
+
* would ship a not-probe-eligible capability pre-checked, which is exactly
|
|
60
|
+
* what the scope cap exists to prevent, so it is rejected at the schema
|
|
61
|
+
* layer rather than left to individual renderers to catch.
|
|
55
62
|
*/
|
|
56
|
-
exports.CapabilitySchema = zod_1.z
|
|
63
|
+
exports.CapabilitySchema = zod_1.z
|
|
64
|
+
.object({
|
|
57
65
|
id: zod_1.z
|
|
58
66
|
.string()
|
|
59
67
|
.min(1, "Capability id is required")
|
|
@@ -76,7 +84,11 @@ exports.CapabilitySchema = zod_1.z.object({
|
|
|
76
84
|
.min(1, "At least one scope is required")
|
|
77
85
|
.max(20, "At most 20 scopes per capability"),
|
|
78
86
|
category: zod_1.z.string().max(80).optional(),
|
|
79
|
-
})
|
|
87
|
+
})
|
|
88
|
+
.refine((capability) => (0, capabilities_types_js_1.isProbeEligible)(capability.riskLevel) || !capability.defaultOn, (capability) => ({
|
|
89
|
+
message: `Capability \`${capability.id}\` has riskLevel \`${capability.riskLevel}\` and cannot ship with defaultOn: true (First-Contact Scope Cap, section 3, rule 1)`,
|
|
90
|
+
path: ["defaultOn"],
|
|
91
|
+
}));
|
|
80
92
|
/**
|
|
81
93
|
* Capability group (optional clustering).
|
|
82
94
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"capabilities.schemas.js","sourceRoot":"","sources":["../../../src/schemas/capabilities.schemas.ts"],"names":[],"mappings":";AAAA;;;;;;;;;GASG;;;
|
|
1
|
+
{"version":3,"file":"capabilities.schemas.js","sourceRoot":"","sources":["../../../src/schemas/capabilities.schemas.ts"],"names":[],"mappings":";AAAA;;;;;;;;;GASG;;;AAoJH,gDAIC;AAED,0DAIC;AAED,sDAIC;AAlKD,6BAAwB;AAExB,0EAAiE;AAEjE;;GAEG;AACU,QAAA,eAAe,GAAG,OAAC,CAAC,IAAI,CAAC,CAAC,KAAK,EAAE,QAAQ,EAAE,MAAM,EAAE,UAAU,CAAC,CAAC,CAAC;AAE7E;;GAEG;AACU,QAAA,oBAAoB,GAAG,OAAC,CAAC,IAAI,CAAC;IACzC,QAAQ;IACR,MAAM;IACN,MAAM;IACN,KAAK;IACL,SAAS;IACT,QAAQ;IACR,KAAK;IACL,OAAO;IACP,MAAM;IACN,UAAU;IACV,MAAM;IACN,KAAK;IACL,MAAM;IACN,SAAS;IACT,SAAS;CACV,CAAC,CAAC;AAEH;;;;;GAKG;AACU,QAAA,iBAAiB,GAAG,OAAC;KAC/B,MAAM,EAAE;KACR,GAAG,CAAC,CAAC,EAAE,gCAAgC,CAAC;KACxC,GAAG,CAAC,IAAI,EAAE,gDAAgD,CAAC;KAC3D,MAAM,CACL,CAAC,KAAK,EAAE,EAAE,CAAC,0BAA0B,CAAC,IAAI,CAAC,KAAK,CAAC,EACjD,yDAAyD,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,CAAC,IAAI,CAAC,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC,CAAC;AAI5D;;GAEG;AACU,QAAA,0BAA0B,GAAG,OAAC,CAAC,MAAM,CAAC;IACjD,SAAS,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC;IACrC,QAAQ,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC;IACpC,GAAG,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC;IAC/B,UAAU,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC;CACvC,CAAC,CAAC;AAMH,SAAgB,kBAAkB,CAChC,KAAc;IAEd,OAAO,wBAAgB,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;AAC3C,CAAC;AAED,SAAgB,uBAAuB,CACrC,KAAc;IAEd,OAAO,6BAAqB,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;AAChD,CAAC;AAED,SAAgB,qBAAqB,CACnC,KAAc;IAEd,OAAO,2BAAmB,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;AAC9C,CAAC"}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Identity Assertion Fragment Parsing
|
|
4
|
+
*
|
|
5
|
+
* Part of the consent-approve auth-gate fix
|
|
6
|
+
* (docs/superpowers/specs/2026-07-29-consent-approve-auth-gate-design.md §3.1).
|
|
7
|
+
* After credential/OAuth sign-in, the worker mints a grant-bound signed
|
|
8
|
+
* identity assertion and redirects the browser to the clickwrap consent
|
|
9
|
+
* screen carrying it in the URL **fragment**
|
|
10
|
+
* (`.../consent#identity_assertion=<token>`) rather than a query param.
|
|
11
|
+
* Fragments are never sent to the server — not in access logs, not in
|
|
12
|
+
* `Referer` — so this is the only way the assertion can be delivered without
|
|
13
|
+
* leaking it. That also means the server-rendered shell can never see it to
|
|
14
|
+
* pass it down as an attribute; the component must read `location.hash`
|
|
15
|
+
* itself once mounted in the browser.
|
|
16
|
+
*
|
|
17
|
+
* This module holds the pure parsing logic so it can be unit-tested in this
|
|
18
|
+
* package's node-environment vitest suite, which has no DOM and cannot mount
|
|
19
|
+
* the Lit component to exercise `location.hash` directly.
|
|
20
|
+
*
|
|
21
|
+
* @module @kya-os/consent/security/identity-assertion
|
|
22
|
+
*/
|
|
23
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
24
|
+
exports.parseIdentityAssertionFromHash = parseIdentityAssertionFromHash;
|
|
25
|
+
/**
|
|
26
|
+
* Parse the `identity_assertion` value out of a URL fragment.
|
|
27
|
+
*
|
|
28
|
+
* Accepts a raw `location.hash`-shaped string, with or without its leading
|
|
29
|
+
* `#`. Returns `undefined` when the key is absent, the value is empty, or
|
|
30
|
+
* the fragment is empty/nullish. Never throws.
|
|
31
|
+
*
|
|
32
|
+
* @param hash - The fragment string, e.g. `location.hash`
|
|
33
|
+
* (`"#identity_assertion=abc"`)
|
|
34
|
+
* @returns The decoded assertion token, or `undefined` if not present
|
|
35
|
+
*
|
|
36
|
+
* @example
|
|
37
|
+
* ```typescript
|
|
38
|
+
* parseIdentityAssertionFromHash('#identity_assertion=abc123')
|
|
39
|
+
* // => 'abc123'
|
|
40
|
+
*
|
|
41
|
+
* parseIdentityAssertionFromHash('#a=1&identity_assertion=abc&b=2')
|
|
42
|
+
* // => 'abc'
|
|
43
|
+
*
|
|
44
|
+
* parseIdentityAssertionFromHash('#a=1&b=2')
|
|
45
|
+
* // => undefined
|
|
46
|
+
*
|
|
47
|
+
* parseIdentityAssertionFromHash('')
|
|
48
|
+
* // => undefined
|
|
49
|
+
* ```
|
|
50
|
+
*/
|
|
51
|
+
function parseIdentityAssertionFromHash(hash) {
|
|
52
|
+
if (!hash)
|
|
53
|
+
return undefined;
|
|
54
|
+
const withoutLeadingHash = hash.startsWith("#") ? hash.slice(1) : hash;
|
|
55
|
+
if (!withoutLeadingHash)
|
|
56
|
+
return undefined;
|
|
57
|
+
try {
|
|
58
|
+
const params = new URLSearchParams(withoutLeadingHash);
|
|
59
|
+
const value = params.get("identity_assertion");
|
|
60
|
+
return value ? value : undefined;
|
|
61
|
+
}
|
|
62
|
+
catch {
|
|
63
|
+
// URLSearchParams is very lenient and does not throw in practice, but
|
|
64
|
+
// guard anyway - a parsing failure here must never crash the consent
|
|
65
|
+
// screen, it should just mean "no assertion found".
|
|
66
|
+
return undefined;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
//# sourceMappingURL=identity-assertion.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"identity-assertion.js","sourceRoot":"","sources":["../../../src/security/identity-assertion.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;;AA4BH,wEAkBC;AA5CD;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,SAAgB,8BAA8B,CAC5C,IAA+B;IAE/B,IAAI,CAAC,IAAI;QAAE,OAAO,SAAS,CAAC;IAE5B,MAAM,kBAAkB,GAAG,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;IACvE,IAAI,CAAC,kBAAkB;QAAE,OAAO,SAAS,CAAC;IAE1C,IAAI,CAAC;QACH,MAAM,MAAM,GAAG,IAAI,eAAe,CAAC,kBAAkB,CAAC,CAAC;QACvD,MAAM,KAAK,GAAG,MAAM,CAAC,GAAG,CAAC,oBAAoB,CAAC,CAAC;QAC/C,OAAO,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,SAAS,CAAC;IACnC,CAAC;IAAC,MAAM,CAAC;QACP,sEAAsE;QACtE,qEAAqE;QACrE,oDAAoD;QACpD,OAAO,SAAS,CAAC;IACnB,CAAC;AACH,CAAC"}
|
|
@@ -23,4 +23,5 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
23
23
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
24
24
|
__exportStar(require("./escape.js"), exports);
|
|
25
25
|
__exportStar(require("./validators.js"), exports);
|
|
26
|
+
__exportStar(require("./identity-assertion.js"), exports);
|
|
26
27
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/security/index.ts"],"names":[],"mappings":";AAAA;;;;;;GAMG;;;;;;;;;;;;;;;;AAEH,8CAA4B;AAC5B,kDAAgC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/security/index.ts"],"names":[],"mappings":";AAAA;;;;;;GAMG;;;;;;;;;;;;;;;;AAEH,8CAA4B;AAC5B,kDAAgC;AAChC,0DAAwC"}
|
|
@@ -9,4 +9,59 @@
|
|
|
9
9
|
* @module @kya-os/consent/types/capabilities
|
|
10
10
|
*/
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.isProbeEligible = isProbeEligible;
|
|
13
|
+
exports.isCappedAtProbe = isCappedAtProbe;
|
|
14
|
+
/**
|
|
15
|
+
* Whether a capability at this risk level may be probed, that is granted to
|
|
16
|
+
* a relationship that has not cleared the First-Contact Scope Cap (design
|
|
17
|
+
* doc "First-Contact Scope Cap, Consent-Phishing Defense (RFC-4 companion)",
|
|
18
|
+
* section 3). `high` and `critical` capabilities are never probe-eligible:
|
|
19
|
+
* they are structurally unmintable at first contact regardless of operator
|
|
20
|
+
* configuration (rule 2) and can never ship pre-checked (rule 1).
|
|
21
|
+
*
|
|
22
|
+
* Deliberately an allowlist (`riskLevel` must be exactly `"low"` or
|
|
23
|
+
* `"medium"`), not a denylist. `riskLevel`'s type is `RiskLevel`, but the
|
|
24
|
+
* caller in `compileCapabilitiesToCedar` does no runtime re-validation, so a
|
|
25
|
+
* value that started as unchecked data (a DB column, a JSON payload, a
|
|
26
|
+
* legacy/typo string like `"High"` or `"severe"`) reaches this function as
|
|
27
|
+
* raw data despite the type annotation. A denylist (`riskLevel !== "high" &&
|
|
28
|
+
* riskLevel !== "critical"`) fails OPEN on any such non-canonical value,
|
|
29
|
+
* treating it as probe-eligible and emitting it to a first-contact or
|
|
30
|
+
* unverified agent, the exact escalation this gate exists to prevent. The
|
|
31
|
+
* allowlist form is strictly more defensive and behaves identically on
|
|
32
|
+
* schema-validated input, where `riskLevel` is already constrained to this
|
|
33
|
+
* union.
|
|
34
|
+
*/
|
|
35
|
+
function isProbeEligible(riskLevel) {
|
|
36
|
+
return riskLevel === "low" || riskLevel === "medium";
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Whether `value` parses as a real point in time in the past. Guards
|
|
40
|
+
* `connectedAt`, which reaches `isCappedAtProbe` as a plain string (the
|
|
41
|
+
* `z.string().datetime()` schema check applies at the `AgentMetadata`
|
|
42
|
+
* ingestion boundary, not necessarily on every `RelationshipContext` this
|
|
43
|
+
* function receives) — a truthy-but-malformed value like `"not-a-date"`
|
|
44
|
+
* must not read as an established relationship.
|
|
45
|
+
*/
|
|
46
|
+
function isValidPastTimestamp(value) {
|
|
47
|
+
const parsed = Date.parse(value);
|
|
48
|
+
return Number.isFinite(parsed) && parsed <= Date.now();
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Whether the requesting agent is capped at `probe`: it presented no valid,
|
|
52
|
+
* verified Entity Card (rule 3), or the relationship is first contact, that
|
|
53
|
+
* is `connectedAt` is absent or unparseable (rule 2). Per the design doc,
|
|
54
|
+
* neither condition is ever raised by assurance vector, relationship age, or
|
|
55
|
+
* click count.
|
|
56
|
+
*
|
|
57
|
+
* `agent` itself may be absent: real stored configs exist with no agent
|
|
58
|
+
* metadata at all, not merely `verified: false`. That counts as unverified
|
|
59
|
+
* too, so this fails closed rather than throwing.
|
|
60
|
+
*/
|
|
61
|
+
function isCappedAtProbe(agent) {
|
|
62
|
+
return (!agent ||
|
|
63
|
+
!agent.verified ||
|
|
64
|
+
!agent.connectedAt ||
|
|
65
|
+
!isValidPastTimestamp(agent.connectedAt));
|
|
66
|
+
}
|
|
12
67
|
//# sourceMappingURL=capabilities.types.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"capabilities.types.js","sourceRoot":"","sources":["../../../src/types/capabilities.types.ts"],"names":[],"mappings":";AAAA;;;;;;;;GAQG"}
|
|
1
|
+
{"version":3,"file":"capabilities.types.js","sourceRoot":"","sources":["../../../src/types/capabilities.types.ts"],"names":[],"mappings":";AAAA;;;;;;;;GAQG;;AAiDH,0CAEC;AAkCD,0CAOC;AAhED;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,SAAgB,eAAe,CAAC,SAAoB;IAClD,OAAO,SAAS,KAAK,KAAK,IAAI,SAAS,KAAK,QAAQ,CAAC;AACvD,CAAC;AAUD;;;;;;;GAOG;AACH,SAAS,oBAAoB,CAAC,KAAa;IACzC,MAAM,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;IACjC,OAAO,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,IAAI,MAAM,IAAI,IAAI,CAAC,GAAG,EAAE,CAAC;AACzD,CAAC;AAED;;;;;;;;;;GAUG;AACH,SAAgB,eAAe,CAAC,KAAsC;IACpE,OAAO,CACL,CAAC,KAAK;QACN,CAAC,KAAK,CAAC,QAAQ;QACf,CAAC,KAAK,CAAC,WAAW;QAClB,CAAC,oBAAoB,CAAC,KAAK,CAAC,WAAW,CAAC,CACzC,CAAC;AACJ,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"consent-action-bar.d.ts","sourceRoot":"","sources":["../../src/components/consent-action-bar.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,EAAE,UAAU,EAAa,MAAM,KAAK,CAAC;AAI5C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,gCAAgC,CAAC;AAEnE,qBACa,gBAAiB,SAAQ,UAAU;IAClB,SAAS,SAAM;IACf,KAAK,EAAE,YAAY,CAAW;IAC7B,QAAQ,UAAS;IACjB,OAAO,UAAS;
|
|
1
|
+
{"version":3,"file":"consent-action-bar.d.ts","sourceRoot":"","sources":["../../src/components/consent-action-bar.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,EAAE,UAAU,EAAa,MAAM,KAAK,CAAC;AAI5C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,gCAAgC,CAAC;AAEnE,qBACa,gBAAiB,SAAQ,UAAU;IAClB,SAAS,SAAM;IACf,KAAK,EAAE,YAAY,CAAW;IAC7B,QAAQ,UAAS;IACjB,OAAO,UAAS;IACU,WAAW,SAAM;IACjB,WAAW,SAAM;IAExE,OAAgB,MAAM,0BAkDpB;IAEF,OAAO,CAAC,SAAS;IAOjB,OAAO,CAAC,QAAQ;IAOP,MAAM;CAiChB;AAED,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,qBAAqB;QAC7B,oBAAoB,EAAE,gBAAgB,CAAC;KACxC;CACF"}
|
|
@@ -26,6 +26,8 @@ let ConsentActionBar = class ConsentActionBar extends LitElement {
|
|
|
26
26
|
this.theme = "light";
|
|
27
27
|
this.disabled = false;
|
|
28
28
|
this.loading = false;
|
|
29
|
+
this.submitLabel = "";
|
|
30
|
+
this.cancelLabel = "";
|
|
29
31
|
}
|
|
30
32
|
emitAllow() {
|
|
31
33
|
if (this.disabled || this.loading)
|
|
@@ -38,17 +40,18 @@ let ConsentActionBar = class ConsentActionBar extends LitElement {
|
|
|
38
40
|
this.dispatchEvent(new CustomEvent("consent-deny", { bubbles: true, composed: true }));
|
|
39
41
|
}
|
|
40
42
|
render() {
|
|
41
|
-
const allowLabel = this.theme === "dark"
|
|
43
|
+
const allowLabel = this.submitLabel || (this.theme === "dark"
|
|
42
44
|
? CONSENT_COPY_TOKENS.actions.allowAccess
|
|
43
45
|
: `${formatToken(CONSENT_COPY_TOKENS.actions.allowAgentTemplate, {
|
|
44
46
|
Agent: this.agentName || "this agent",
|
|
45
|
-
})}
|
|
46
|
-
const denyLabel = this.theme === "dark"
|
|
47
|
+
})} →`);
|
|
48
|
+
const denyLabel = this.cancelLabel || (this.theme === "dark"
|
|
47
49
|
? CONSENT_COPY_TOKENS.actions.deny
|
|
48
|
-
: CONSENT_COPY_TOKENS.actions.notNow;
|
|
50
|
+
: CONSENT_COPY_TOKENS.actions.notNow);
|
|
49
51
|
return html `
|
|
50
52
|
<button
|
|
51
53
|
class="primary"
|
|
54
|
+
part="submit"
|
|
52
55
|
type="button"
|
|
53
56
|
?disabled=${this.disabled || this.loading}
|
|
54
57
|
@click=${this.emitAllow}
|
|
@@ -57,6 +60,7 @@ let ConsentActionBar = class ConsentActionBar extends LitElement {
|
|
|
57
60
|
</button>
|
|
58
61
|
<button
|
|
59
62
|
class="secondary"
|
|
63
|
+
part="cancel"
|
|
60
64
|
type="button"
|
|
61
65
|
?disabled=${this.loading}
|
|
62
66
|
@click=${this.emitDeny}
|
|
@@ -78,7 +82,7 @@ ConsentActionBar.styles = css `
|
|
|
78
82
|
width: 100%;
|
|
79
83
|
padding: 14px 18px;
|
|
80
84
|
border-radius: 999px;
|
|
81
|
-
font-size: 15px;
|
|
85
|
+
font-size: var(--cs-action-font-size, 15px);
|
|
82
86
|
font-weight: 500;
|
|
83
87
|
font-family: inherit;
|
|
84
88
|
cursor: pointer;
|
|
@@ -97,6 +101,7 @@ ConsentActionBar.styles = css `
|
|
|
97
101
|
}
|
|
98
102
|
|
|
99
103
|
.primary {
|
|
104
|
+
min-height: var(--cs-action-min-height, 0px);
|
|
100
105
|
background: var(--cs-surface-accent, #0F172A);
|
|
101
106
|
color: var(--cs-surface-accent-text, #FFFFFF);
|
|
102
107
|
}
|
|
@@ -128,6 +133,12 @@ __decorate([
|
|
|
128
133
|
__decorate([
|
|
129
134
|
property({ type: Boolean })
|
|
130
135
|
], ConsentActionBar.prototype, "loading", void 0);
|
|
136
|
+
__decorate([
|
|
137
|
+
property({ type: String, attribute: "submit-label" })
|
|
138
|
+
], ConsentActionBar.prototype, "submitLabel", void 0);
|
|
139
|
+
__decorate([
|
|
140
|
+
property({ type: String, attribute: "cancel-label" })
|
|
141
|
+
], ConsentActionBar.prototype, "cancelLabel", void 0);
|
|
131
142
|
ConsentActionBar = __decorate([
|
|
132
143
|
customElement("consent-action-bar")
|
|
133
144
|
], ConsentActionBar);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"consent-action-bar.js","sourceRoot":"","sources":["../../src/components/consent-action-bar.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;;;;;;;AAEH,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,GAAG,EAAE,MAAM,KAAK,CAAC;AAC5C,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAE5D,OAAO,EAAE,mBAAmB,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAI9D,IAAM,gBAAgB,GAAtB,MAAM,gBAAiB,SAAQ,UAAU;IAAzC;;QACuB,cAAS,GAAG,EAAE,CAAC;QACf,UAAK,GAAiB,OAAO,CAAC;QAC7B,aAAQ,GAAG,KAAK,CAAC;QACjB,YAAO,GAAG,KAAK,CAAC;
|
|
1
|
+
{"version":3,"file":"consent-action-bar.js","sourceRoot":"","sources":["../../src/components/consent-action-bar.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;;;;;;;AAEH,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,GAAG,EAAE,MAAM,KAAK,CAAC;AAC5C,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAE5D,OAAO,EAAE,mBAAmB,EAAE,WAAW,EAAE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A;;;;;oBAKK,IAAI,CAAC,QAAQ,IAAI,IAAI,CAAC,OAAO;iBAChC,IAAI,CAAC,SAAS;;UAErB,UAAU;;;;;;oBAMA,IAAI,CAAC,OAAO;iBACf,IAAI,CAAC,QAAQ;;UAEpB,SAAS;;KAEd,CAAC;IACJ,CAAC;;AAlGe,uBAAM,GAAG,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkD3B,AAlDqB,CAkDpB;AAzD0B;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;mDAAgB;AACf;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;+CAA+B;AAC7B;IAA5B,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;kDAAkB;AACjB;IAA5B,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;iDAAiB;AACU;IAAtD,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,cAAc,EAAE,CAAC;qDAAkB;AACjB;IAAtD,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,cAAc,EAAE,CAAC;qDAAkB;AAN7D,gBAAgB;IAD5B,aAAa,CAAC,oBAAoB,CAAC;GACvB,gBAAgB,CA2G5B"}
|
|
@@ -8,15 +8,15 @@
|
|
|
8
8
|
* permissions list otherwise.
|
|
9
9
|
*
|
|
10
10
|
* This component is purely presentational. It accepts the resolved data
|
|
11
|
-
* (capabilities, agent metadata, copy values) and emits `
|
|
12
|
-
* `
|
|
11
|
+
* (capabilities, agent metadata, copy values) and emits `capabilities-allow` /
|
|
12
|
+
* `capabilities-deny` events so the parent can submit the form / close the
|
|
13
13
|
* window. Selection state for the checkboxes is owned here to keep the
|
|
14
14
|
* parent simple.
|
|
15
15
|
*
|
|
16
16
|
* @module components/consent-capabilities-screen
|
|
17
17
|
*/
|
|
18
18
|
import { LitElement } from "lit";
|
|
19
|
-
import type {
|
|
19
|
+
import type { ConsentScopeCapability, AgentMetadata, ConsentTheme, CedarTemplateContext } from "../types/capabilities.types.js";
|
|
20
20
|
import "./consent-agent-header.js";
|
|
21
21
|
import "./consent-capability-card.js";
|
|
22
22
|
import "./consent-action-bar.js";
|
|
@@ -24,7 +24,7 @@ import "./consent-footer.js";
|
|
|
24
24
|
import "./consent-revocation-notice.js";
|
|
25
25
|
import "./consent-connector-header.js";
|
|
26
26
|
/**
|
|
27
|
-
* Detail emitted on `
|
|
27
|
+
* Detail emitted on `capabilities-allow`: the set of capability ids the user
|
|
28
28
|
* approved. The parent uses this to compose the granted list.
|
|
29
29
|
*/
|
|
30
30
|
export interface CapabilitiesApproveDetail {
|
|
@@ -32,7 +32,12 @@ export interface CapabilitiesApproveDetail {
|
|
|
32
32
|
selectedScopes: string[];
|
|
33
33
|
}
|
|
34
34
|
export declare class ConsentCapabilitiesScreen extends LitElement {
|
|
35
|
-
|
|
35
|
+
static readonly features: Readonly<{
|
|
36
|
+
version: 1;
|
|
37
|
+
scopesOnly: true;
|
|
38
|
+
slots: readonly ["identity", "details", "notice", "footer"];
|
|
39
|
+
}>;
|
|
40
|
+
capabilities: ConsentScopeCapability[];
|
|
36
41
|
agentMetadata: AgentMetadata | undefined;
|
|
37
42
|
cedarContext: CedarTemplateContext | undefined;
|
|
38
43
|
orgName: string;
|
|
@@ -42,6 +47,11 @@ export declare class ConsentCapabilitiesScreen extends LitElement {
|
|
|
42
47
|
theme: ConsentTheme;
|
|
43
48
|
howItWorksUrl: string;
|
|
44
49
|
loading: boolean;
|
|
50
|
+
/** Blocks approval while allowing the human to decline. */
|
|
51
|
+
disabled: boolean;
|
|
52
|
+
description: string;
|
|
53
|
+
submitLabel: string;
|
|
54
|
+
cancelLabel: string;
|
|
45
55
|
/**
|
|
46
56
|
* Seed every capability as selected. The credential path grants a fixed,
|
|
47
57
|
* all-or-nothing scope set, so every capability starts checked — the rows
|
|
@@ -72,6 +82,8 @@ export declare class ConsentCapabilitiesScreen extends LitElement {
|
|
|
72
82
|
* reach this screen the same way it reaches the other consent screens.
|
|
73
83
|
*/
|
|
74
84
|
serverLogoUrl: string;
|
|
85
|
+
/** Fixed grants require every disclosed capability to remain selected. */
|
|
86
|
+
requireAll: boolean;
|
|
75
87
|
private selected;
|
|
76
88
|
/**
|
|
77
89
|
* Last capability set this component seeded `selected` from, per
|
|
@@ -93,6 +105,7 @@ export declare class ConsentCapabilitiesScreen extends LitElement {
|
|
|
93
105
|
static styles: import("lit").CSSResult;
|
|
94
106
|
private hostStyle;
|
|
95
107
|
private onCapabilityToggle;
|
|
108
|
+
private get approvalDisabled();
|
|
96
109
|
private onAllow;
|
|
97
110
|
private onDeny;
|
|
98
111
|
private compileCapabilityCedar;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"consent-capabilities-screen.d.ts","sourceRoot":"","sources":["../../src/components/consent-capabilities-screen.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,EAAE,UAAU,EAAsB,MAAM,KAAK,CAAC;AAKrD,OAAO,KAAK,EACV,
|
|
1
|
+
{"version":3,"file":"consent-capabilities-screen.d.ts","sourceRoot":"","sources":["../../src/components/consent-capabilities-screen.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,EAAE,UAAU,EAAsB,MAAM,KAAK,CAAC;AAKrD,OAAO,KAAK,EACV,sBAAsB,EACtB,aAAa,EACb,YAAY,EACZ,oBAAoB,EACrB,MAAM,gCAAgC,CAAC;AAOxC,OAAO,2BAA2B,CAAC;AACnC,OAAO,8BAA8B,CAAC;AACtC,OAAO,yBAAyB,CAAC;AACjC,OAAO,qBAAqB,CAAC;AAC7B,OAAO,gCAAgC,CAAC;AACxC,OAAO,+BAA+B,CAAC;AAEvC;;;GAGG;AACH,MAAM,WAAW,yBAAyB;IACxC,qBAAqB,EAAE,MAAM,EAAE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