@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":"config.schemas.d.ts","sourceRoot":"","sources":["../../src/schemas/config.schemas.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,qBAAqB,EAAE,MAAM,uBAAuB,CAAC;AAgB9D;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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAEtC,CAAC;AAEH,MAAM,MAAM,+BAA+B,GAAG,CAAC,CAAC,KAAK,CACnD,OAAO,2BAA2B,CACnC,CAAC;AAEF;;GAEG;AAEH,wBAAgB,qBAAqB,CACnC,MAAM,EAAE,OAAO,GACd,CAAC,CAAC,mBAAmB,CAAC,OAAO,EAAE,uBAAuB,CAAC,CAEzD;AAED,wBAAgB,uBAAuB,CACrC,QAAQ,EAAE,OAAO,GAChB,CAAC,CAAC,mBAAmB,CAAC,OAAO,EAAE,CAAC,CAAC,KAAK,CAAC,OAAO,qBAAqB,CAAC,CAAC,CAEvE;AAED,wBAAgB,mBAAmB,CACjC,KAAK,EAAE,OAAO,GACb,CAAC,CAAC,mBAAmB,CAAC,OAAO,EAAE,4BAA4B,CAAC,CAE9D"}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Identity Assertion Fragment Parsing
|
|
3
|
+
*
|
|
4
|
+
* Part of the consent-approve auth-gate fix
|
|
5
|
+
* (docs/superpowers/specs/2026-07-29-consent-approve-auth-gate-design.md §3.1).
|
|
6
|
+
* After credential/OAuth sign-in, the worker mints a grant-bound signed
|
|
7
|
+
* identity assertion and redirects the browser to the clickwrap consent
|
|
8
|
+
* screen carrying it in the URL **fragment**
|
|
9
|
+
* (`.../consent#identity_assertion=<token>`) rather than a query param.
|
|
10
|
+
* Fragments are never sent to the server — not in access logs, not in
|
|
11
|
+
* `Referer` — so this is the only way the assertion can be delivered without
|
|
12
|
+
* leaking it. That also means the server-rendered shell can never see it to
|
|
13
|
+
* pass it down as an attribute; the component must read `location.hash`
|
|
14
|
+
* itself once mounted in the browser.
|
|
15
|
+
*
|
|
16
|
+
* This module holds the pure parsing logic so it can be unit-tested in this
|
|
17
|
+
* package's node-environment vitest suite, which has no DOM and cannot mount
|
|
18
|
+
* the Lit component to exercise `location.hash` directly.
|
|
19
|
+
*
|
|
20
|
+
* @module @kya-os/consent/security/identity-assertion
|
|
21
|
+
*/
|
|
22
|
+
/**
|
|
23
|
+
* Parse the `identity_assertion` value out of a URL fragment.
|
|
24
|
+
*
|
|
25
|
+
* Accepts a raw `location.hash`-shaped string, with or without its leading
|
|
26
|
+
* `#`. Returns `undefined` when the key is absent, the value is empty, or
|
|
27
|
+
* the fragment is empty/nullish. Never throws.
|
|
28
|
+
*
|
|
29
|
+
* @param hash - The fragment string, e.g. `location.hash`
|
|
30
|
+
* (`"#identity_assertion=abc"`)
|
|
31
|
+
* @returns The decoded assertion token, or `undefined` if not present
|
|
32
|
+
*
|
|
33
|
+
* @example
|
|
34
|
+
* ```typescript
|
|
35
|
+
* parseIdentityAssertionFromHash('#identity_assertion=abc123')
|
|
36
|
+
* // => 'abc123'
|
|
37
|
+
*
|
|
38
|
+
* parseIdentityAssertionFromHash('#a=1&identity_assertion=abc&b=2')
|
|
39
|
+
* // => 'abc'
|
|
40
|
+
*
|
|
41
|
+
* parseIdentityAssertionFromHash('#a=1&b=2')
|
|
42
|
+
* // => undefined
|
|
43
|
+
*
|
|
44
|
+
* parseIdentityAssertionFromHash('')
|
|
45
|
+
* // => undefined
|
|
46
|
+
* ```
|
|
47
|
+
*/
|
|
48
|
+
export declare function parseIdentityAssertionFromHash(hash: string | undefined | null): string | undefined;
|
|
49
|
+
//# sourceMappingURL=identity-assertion.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"identity-assertion.d.ts","sourceRoot":"","sources":["../../src/security/identity-assertion.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,wBAAgB,8BAA8B,CAC5C,IAAI,EAAE,MAAM,GAAG,SAAS,GAAG,IAAI,GAC9B,MAAM,GAAG,SAAS,CAgBpB"}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Identity Assertion Fragment Parsing
|
|
3
|
+
*
|
|
4
|
+
* Part of the consent-approve auth-gate fix
|
|
5
|
+
* (docs/superpowers/specs/2026-07-29-consent-approve-auth-gate-design.md §3.1).
|
|
6
|
+
* After credential/OAuth sign-in, the worker mints a grant-bound signed
|
|
7
|
+
* identity assertion and redirects the browser to the clickwrap consent
|
|
8
|
+
* screen carrying it in the URL **fragment**
|
|
9
|
+
* (`.../consent#identity_assertion=<token>`) rather than a query param.
|
|
10
|
+
* Fragments are never sent to the server — not in access logs, not in
|
|
11
|
+
* `Referer` — so this is the only way the assertion can be delivered without
|
|
12
|
+
* leaking it. That also means the server-rendered shell can never see it to
|
|
13
|
+
* pass it down as an attribute; the component must read `location.hash`
|
|
14
|
+
* itself once mounted in the browser.
|
|
15
|
+
*
|
|
16
|
+
* This module holds the pure parsing logic so it can be unit-tested in this
|
|
17
|
+
* package's node-environment vitest suite, which has no DOM and cannot mount
|
|
18
|
+
* the Lit component to exercise `location.hash` directly.
|
|
19
|
+
*
|
|
20
|
+
* @module @kya-os/consent/security/identity-assertion
|
|
21
|
+
*/
|
|
22
|
+
/**
|
|
23
|
+
* Parse the `identity_assertion` value out of a URL fragment.
|
|
24
|
+
*
|
|
25
|
+
* Accepts a raw `location.hash`-shaped string, with or without its leading
|
|
26
|
+
* `#`. Returns `undefined` when the key is absent, the value is empty, or
|
|
27
|
+
* the fragment is empty/nullish. Never throws.
|
|
28
|
+
*
|
|
29
|
+
* @param hash - The fragment string, e.g. `location.hash`
|
|
30
|
+
* (`"#identity_assertion=abc"`)
|
|
31
|
+
* @returns The decoded assertion token, or `undefined` if not present
|
|
32
|
+
*
|
|
33
|
+
* @example
|
|
34
|
+
* ```typescript
|
|
35
|
+
* parseIdentityAssertionFromHash('#identity_assertion=abc123')
|
|
36
|
+
* // => 'abc123'
|
|
37
|
+
*
|
|
38
|
+
* parseIdentityAssertionFromHash('#a=1&identity_assertion=abc&b=2')
|
|
39
|
+
* // => 'abc'
|
|
40
|
+
*
|
|
41
|
+
* parseIdentityAssertionFromHash('#a=1&b=2')
|
|
42
|
+
* // => undefined
|
|
43
|
+
*
|
|
44
|
+
* parseIdentityAssertionFromHash('')
|
|
45
|
+
* // => undefined
|
|
46
|
+
* ```
|
|
47
|
+
*/
|
|
48
|
+
export function parseIdentityAssertionFromHash(hash) {
|
|
49
|
+
if (!hash)
|
|
50
|
+
return undefined;
|
|
51
|
+
const withoutLeadingHash = hash.startsWith("#") ? hash.slice(1) : hash;
|
|
52
|
+
if (!withoutLeadingHash)
|
|
53
|
+
return undefined;
|
|
54
|
+
try {
|
|
55
|
+
const params = new URLSearchParams(withoutLeadingHash);
|
|
56
|
+
const value = params.get("identity_assertion");
|
|
57
|
+
return value ? value : undefined;
|
|
58
|
+
}
|
|
59
|
+
catch {
|
|
60
|
+
// URLSearchParams is very lenient and does not throw in practice, but
|
|
61
|
+
// guard anyway - a parsing failure here must never crash the consent
|
|
62
|
+
// screen, it should just mean "no assertion found".
|
|
63
|
+
return undefined;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
//# 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;AAEH;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,MAAM,UAAU,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"}
|
package/dist/security/index.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/security/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,cAAc,aAAa,CAAC;AAC5B,cAAc,iBAAiB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/security/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,cAAc,aAAa,CAAC;AAC5B,cAAc,iBAAiB,CAAC;AAChC,cAAc,yBAAyB,CAAC"}
|
package/dist/security/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/security/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,cAAc,aAAa,CAAC;AAC5B,cAAc,iBAAiB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/security/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,cAAc,aAAa,CAAC;AAC5B,cAAc,iBAAiB,CAAC;AAChC,cAAc,yBAAyB,CAAC"}
|
|
@@ -10,8 +10,69 @@
|
|
|
10
10
|
/**
|
|
11
11
|
* Risk classification for a capability. Used to surface the amber `HIGHER RISK`
|
|
12
12
|
* chip on capability rows when riskLevel is `high` or `critical`.
|
|
13
|
+
*
|
|
14
|
+
* Name collision, not a shared type: `kya-os-mcp`'s agent-reputation gate
|
|
15
|
+
* (`kya-os-mcp/src/auth/handshake.ts`, `AgentReputation.riskLevel`) has its
|
|
16
|
+
* own field of the same name for a different question, "how risky is this
|
|
17
|
+
* agent's reputation" rather than "how risky is this capability grant", and
|
|
18
|
+
* its members don't match this union:
|
|
19
|
+
*
|
|
20
|
+
* value | this RiskLevel (capability) | kya-os-mcp riskLevel (reputation)
|
|
21
|
+
* ----------- | ---------------------------- | ----------------------------------
|
|
22
|
+
* "low" | yes | yes
|
|
23
|
+
* "medium" | yes | yes
|
|
24
|
+
* "high" | yes | yes
|
|
25
|
+
* "critical" | yes | no
|
|
26
|
+
* "unknown" | no | yes
|
|
27
|
+
*
|
|
28
|
+
* TypeScript's structural union check catches a straight mismatch at a
|
|
29
|
+
* typed call site, but that protection disappears the moment either value
|
|
30
|
+
* passes through a plain `string` (a DB column, a JSON payload logged and
|
|
31
|
+
* re-parsed, a query param). Treat the two as unrelated concepts that
|
|
32
|
+
* happen to share a name, not as one enum reused across packages.
|
|
13
33
|
*/
|
|
14
34
|
export type RiskLevel = "low" | "medium" | "high" | "critical";
|
|
35
|
+
/**
|
|
36
|
+
* Whether a capability at this risk level may be probed, that is granted to
|
|
37
|
+
* a relationship that has not cleared the First-Contact Scope Cap (design
|
|
38
|
+
* doc "First-Contact Scope Cap, Consent-Phishing Defense (RFC-4 companion)",
|
|
39
|
+
* section 3). `high` and `critical` capabilities are never probe-eligible:
|
|
40
|
+
* they are structurally unmintable at first contact regardless of operator
|
|
41
|
+
* configuration (rule 2) and can never ship pre-checked (rule 1).
|
|
42
|
+
*
|
|
43
|
+
* Deliberately an allowlist (`riskLevel` must be exactly `"low"` or
|
|
44
|
+
* `"medium"`), not a denylist. `riskLevel`'s type is `RiskLevel`, but the
|
|
45
|
+
* caller in `compileCapabilitiesToCedar` does no runtime re-validation, so a
|
|
46
|
+
* value that started as unchecked data (a DB column, a JSON payload, a
|
|
47
|
+
* legacy/typo string like `"High"` or `"severe"`) reaches this function as
|
|
48
|
+
* raw data despite the type annotation. A denylist (`riskLevel !== "high" &&
|
|
49
|
+
* riskLevel !== "critical"`) fails OPEN on any such non-canonical value,
|
|
50
|
+
* treating it as probe-eligible and emitting it to a first-contact or
|
|
51
|
+
* unverified agent, the exact escalation this gate exists to prevent. The
|
|
52
|
+
* allowlist form is strictly more defensive and behaves identically on
|
|
53
|
+
* schema-validated input, where `riskLevel` is already constrained to this
|
|
54
|
+
* union.
|
|
55
|
+
*/
|
|
56
|
+
export declare function isProbeEligible(riskLevel: RiskLevel): boolean;
|
|
57
|
+
/**
|
|
58
|
+
* Minimum agent-relationship facts needed to decide whether a capability
|
|
59
|
+
* grant may rise above `probe`. Mirrors `AgentMetadata.verified` /
|
|
60
|
+
* `connectedAt`; deliberately a subset so callers can pass either the full
|
|
61
|
+
* agent tile or just the two fields that matter here.
|
|
62
|
+
*/
|
|
63
|
+
export type RelationshipContext = Pick<AgentMetadata, "verified" | "connectedAt">;
|
|
64
|
+
/**
|
|
65
|
+
* Whether the requesting agent is capped at `probe`: it presented no valid,
|
|
66
|
+
* verified Entity Card (rule 3), or the relationship is first contact, that
|
|
67
|
+
* is `connectedAt` is absent or unparseable (rule 2). Per the design doc,
|
|
68
|
+
* neither condition is ever raised by assurance vector, relationship age, or
|
|
69
|
+
* click count.
|
|
70
|
+
*
|
|
71
|
+
* `agent` itself may be absent: real stored configs exist with no agent
|
|
72
|
+
* metadata at all, not merely `verified: false`. That counts as unverified
|
|
73
|
+
* too, so this fails closed rather than throwing.
|
|
74
|
+
*/
|
|
75
|
+
export declare function isCappedAtProbe(agent: RelationshipContext | undefined): boolean;
|
|
15
76
|
/**
|
|
16
77
|
* Allowlist of icon tokens recognized by `<consent-capability-card>`. Operators
|
|
17
78
|
* pick from this list in the WYSIWYG editor; unknown tokens fall back to a
|
|
@@ -54,6 +115,14 @@ export interface Capability {
|
|
|
54
115
|
/** Optional grouping label shown above a cluster of related capabilities. */
|
|
55
116
|
category?: string;
|
|
56
117
|
}
|
|
118
|
+
/**
|
|
119
|
+
* Presentation data for a host that authorizes literal scopes without Cedar.
|
|
120
|
+
* This does not change the authored Capability schema or Cedar compilation.
|
|
121
|
+
* The host remains responsible for enforcing the reviewed scopes and limits.
|
|
122
|
+
*/
|
|
123
|
+
export type ConsentScopeCapability = Omit<Capability, "cedar"> & {
|
|
124
|
+
cedar?: string;
|
|
125
|
+
};
|
|
57
126
|
/**
|
|
58
127
|
* Optional grouping wrapper, e.g. group several capabilities under
|
|
59
128
|
* "Browse + cart" vs "Checkout".
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"capabilities.types.d.ts","sourceRoot":"","sources":["../../src/types/capabilities.types.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH
|
|
1
|
+
{"version":3,"file":"capabilities.types.d.ts","sourceRoot":"","sources":["../../src/types/capabilities.types.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,MAAM,MAAM,SAAS,GAAG,KAAK,GAAG,QAAQ,GAAG,MAAM,GAAG,UAAU,CAAC;AAE/D;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAgB,eAAe,CAAC,SAAS,EAAE,SAAS,GAAG,OAAO,CAE7D;AAED;;;;;GAKG;AACH,MAAM,MAAM,mBAAmB,GAAG,IAAI,CAAC,aAAa,EAAE,UAAU,GAAG,aAAa,CAAC,CAAC;AAelF;;;;;;;;;;GAUG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,mBAAmB,GAAG,SAAS,GAAG,OAAO,CAO/E;AAED;;;;GAIG;AACH,MAAM,MAAM,cAAc,GACtB,QAAQ,GACR,MAAM,GACN,MAAM,GACN,KAAK,GACL,SAAS,GACT,QAAQ,GACR,KAAK,GACL,OAAO,GACP,MAAM,GACN,UAAU,GACV,MAAM,GACN,KAAK,GACL,MAAM,GACN,SAAS,GACT,SAAS,CAAC;AAEd;;;;;;;;GAQG;AACH,MAAM,WAAW,UAAU;IACzB,0CAA0C;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AAoB;IACnC,gEAAgE;IAChE,SAAS,EAAE,MAAM,CAAC;IAElB,8DAA8D;IAC9D,QAAQ,EAAE,MAAM,CAAC;IAEjB,kFAAkF;IAClF,GAAG,EAAE,MAAM,CAAC;IAEZ,iGAAiG;IACjG,UAAU,EAAE,MAAM,CAAC;CACpB;AAED;;;GAGG;AACH,MAAM,WAAW,gBAAgB;IAC/B,oDAAoD;IACpD,OAAO,EAAE,MAAM,EAAE,CAAC;IAElB,wEAAwE;IACxE,QAAQ,EAAE,MAAM,CAAC;IAEjB,kEAAkE;IAClE,UAAU,EAAE,MAAM,EAAE,CAAC;CACtB"}
|
|
@@ -7,5 +7,57 @@
|
|
|
7
7
|
*
|
|
8
8
|
* @module @kya-os/consent/types/capabilities
|
|
9
9
|
*/
|
|
10
|
-
|
|
10
|
+
/**
|
|
11
|
+
* Whether a capability at this risk level may be probed, that is granted to
|
|
12
|
+
* a relationship that has not cleared the First-Contact Scope Cap (design
|
|
13
|
+
* doc "First-Contact Scope Cap, Consent-Phishing Defense (RFC-4 companion)",
|
|
14
|
+
* section 3). `high` and `critical` capabilities are never probe-eligible:
|
|
15
|
+
* they are structurally unmintable at first contact regardless of operator
|
|
16
|
+
* configuration (rule 2) and can never ship pre-checked (rule 1).
|
|
17
|
+
*
|
|
18
|
+
* Deliberately an allowlist (`riskLevel` must be exactly `"low"` or
|
|
19
|
+
* `"medium"`), not a denylist. `riskLevel`'s type is `RiskLevel`, but the
|
|
20
|
+
* caller in `compileCapabilitiesToCedar` does no runtime re-validation, so a
|
|
21
|
+
* value that started as unchecked data (a DB column, a JSON payload, a
|
|
22
|
+
* legacy/typo string like `"High"` or `"severe"`) reaches this function as
|
|
23
|
+
* raw data despite the type annotation. A denylist (`riskLevel !== "high" &&
|
|
24
|
+
* riskLevel !== "critical"`) fails OPEN on any such non-canonical value,
|
|
25
|
+
* treating it as probe-eligible and emitting it to a first-contact or
|
|
26
|
+
* unverified agent, the exact escalation this gate exists to prevent. The
|
|
27
|
+
* allowlist form is strictly more defensive and behaves identically on
|
|
28
|
+
* schema-validated input, where `riskLevel` is already constrained to this
|
|
29
|
+
* union.
|
|
30
|
+
*/
|
|
31
|
+
export function isProbeEligible(riskLevel) {
|
|
32
|
+
return riskLevel === "low" || riskLevel === "medium";
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Whether `value` parses as a real point in time in the past. Guards
|
|
36
|
+
* `connectedAt`, which reaches `isCappedAtProbe` as a plain string (the
|
|
37
|
+
* `z.string().datetime()` schema check applies at the `AgentMetadata`
|
|
38
|
+
* ingestion boundary, not necessarily on every `RelationshipContext` this
|
|
39
|
+
* function receives) — a truthy-but-malformed value like `"not-a-date"`
|
|
40
|
+
* must not read as an established relationship.
|
|
41
|
+
*/
|
|
42
|
+
function isValidPastTimestamp(value) {
|
|
43
|
+
const parsed = Date.parse(value);
|
|
44
|
+
return Number.isFinite(parsed) && parsed <= Date.now();
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Whether the requesting agent is capped at `probe`: it presented no valid,
|
|
48
|
+
* verified Entity Card (rule 3), or the relationship is first contact, that
|
|
49
|
+
* is `connectedAt` is absent or unparseable (rule 2). Per the design doc,
|
|
50
|
+
* neither condition is ever raised by assurance vector, relationship age, or
|
|
51
|
+
* click count.
|
|
52
|
+
*
|
|
53
|
+
* `agent` itself may be absent: real stored configs exist with no agent
|
|
54
|
+
* metadata at all, not merely `verified: false`. That counts as unverified
|
|
55
|
+
* too, so this fails closed rather than throwing.
|
|
56
|
+
*/
|
|
57
|
+
export function isCappedAtProbe(agent) {
|
|
58
|
+
return (!agent ||
|
|
59
|
+
!agent.verified ||
|
|
60
|
+
!agent.connectedAt ||
|
|
61
|
+
!isValidPastTimestamp(agent.connectedAt));
|
|
62
|
+
}
|
|
11
63
|
//# 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;AA4BH;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,MAAM,UAAU,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,MAAM,UAAU,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"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kya-os/consent",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.48",
|
|
4
4
|
"description": "Canonical consent page types, styles, and utilities for MCP-I and AgentShield",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -80,8 +80,8 @@
|
|
|
80
80
|
"./consent.min.js": "./dist/consent.min.js"
|
|
81
81
|
},
|
|
82
82
|
"scripts": {
|
|
83
|
-
"build": "tsc -p tsconfig.build.json && npm run build:
|
|
84
|
-
"build:cjs": "tsc -p tsconfig.cjs.json &&
|
|
83
|
+
"build": "tsc -p tsconfig.build.json && npm run build:bundle && npm run build:inline && npm run build:mcp-app && npm run build:cjs && npm run verify:bundles",
|
|
84
|
+
"build:cjs": "tsc -p tsconfig.cjs.json && node scripts/write-cjs-package.js",
|
|
85
85
|
"build:bundle": "esbuild src/bundle/index.ts --bundle --format=esm --target=es2020 --outfile=dist/consent.js && esbuild src/bundle/index.ts --bundle --format=esm --target=es2020 --minify --outfile=dist/consent.min.js",
|
|
86
86
|
"build:inline": "node scripts/generate-inline-bundle.js && tsc src/bundle/inline.ts --declaration --outDir dist/bundle --module esnext --moduleResolution bundler --target es2020",
|
|
87
87
|
"build:mcp-app": "node scripts/generate-mcp-app-bundle.js && tsc src/mcp-app/inline.ts src/mcp-app/index.ts src/mcp-app/types.ts --declaration --outDir dist/mcp-app --module esnext --moduleResolution bundler --target es2020",
|
|
@@ -92,7 +92,9 @@
|
|
|
92
92
|
"lint": "eslint .",
|
|
93
93
|
"format": "prettier --write \"src/**/*.{ts,tsx}\"",
|
|
94
94
|
"clean": "rm -rf dist .turbo node_modules",
|
|
95
|
-
"prepublishOnly": "npm run build && node ../create-mcpi-app/scripts/validate-no-workspace.js"
|
|
95
|
+
"prepublishOnly": "npm run build && node ../create-mcpi-app/scripts/validate-no-workspace.js",
|
|
96
|
+
"test:browser": "python3 scripts/test-capabilities-browser.py && python3 scripts/test-mcp-consent-selection.py",
|
|
97
|
+
"verify:bundles": "node scripts/verify-bundles.js"
|
|
96
98
|
},
|
|
97
99
|
"sideEffects": [
|
|
98
100
|
"./src/components/*.ts",
|