@kya-os/mcp 1.13.0 → 1.14.2
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/CHANGELOG.md +71 -0
- package/README.md +12 -0
- package/dist/card/delegation.d.ts +4 -4
- package/dist/card/delegation.d.ts.map +1 -1
- package/dist/card/delegation.js +2 -2
- package/dist/card/delegation.js.map +1 -1
- package/dist/card/revocation.d.ts +9 -3
- package/dist/card/revocation.d.ts.map +1 -1
- package/dist/card/revocation.js +6 -53
- package/dist/card/revocation.js.map +1 -1
- package/dist/card/verify.d.ts +2 -2
- package/dist/card/verify.d.ts.map +1 -1
- package/dist/card/verify.js.map +1 -1
- package/dist/delegation/bitstring.d.ts +6 -0
- package/dist/delegation/bitstring.d.ts.map +1 -1
- package/dist/delegation/bitstring.js +8 -48
- package/dist/delegation/bitstring.js.map +1 -1
- package/dist/delegation/did-key-resolver.d.ts +4 -0
- package/dist/delegation/did-key-resolver.d.ts.map +1 -1
- package/dist/delegation/did-key-resolver.js +2 -2
- package/dist/delegation/did-key-resolver.js.map +1 -1
- package/dist/delegation/index.d.ts +1 -0
- package/dist/delegation/index.d.ts.map +1 -1
- package/dist/delegation/index.js +1 -0
- package/dist/delegation/index.js.map +1 -1
- package/dist/delegation/statuslist-manager.d.ts.map +1 -1
- package/dist/delegation/statuslist-manager.js +4 -11
- package/dist/delegation/statuslist-manager.js.map +1 -1
- package/dist/delegation/vc-jwt-verify.d.ts.map +1 -1
- package/dist/delegation/vc-jwt-verify.js +5 -3
- package/dist/delegation/vc-jwt-verify.js.map +1 -1
- package/dist/delegation/vc-verification-checks.d.ts.map +1 -1
- package/dist/delegation/vc-verification-checks.js +3 -2
- package/dist/delegation/vc-verification-checks.js.map +1 -1
- package/dist/delegation/verification-method-key.d.ts +15 -0
- package/dist/delegation/verification-method-key.d.ts.map +1 -0
- package/dist/delegation/verification-method-key.js +56 -0
- package/dist/delegation/verification-method-key.js.map +1 -0
- package/dist/integrations/cheqd/dlr.d.ts +9 -1
- package/dist/integrations/cheqd/dlr.d.ts.map +1 -1
- package/dist/integrations/cheqd/dlr.js +25 -0
- package/dist/integrations/cheqd/dlr.js.map +1 -1
- package/dist/integrations/cheqd/index.d.ts +1 -0
- package/dist/integrations/cheqd/index.d.ts.map +1 -1
- package/dist/integrations/cheqd/index.js +1 -0
- package/dist/integrations/cheqd/index.js.map +1 -1
- package/dist/integrations/cheqd/statuslist-resolver.d.ts +74 -0
- package/dist/integrations/cheqd/statuslist-resolver.d.ts.map +1 -0
- package/dist/integrations/cheqd/statuslist-resolver.js +138 -0
- package/dist/integrations/cheqd/statuslist-resolver.js.map +1 -0
- package/dist/middleware/with-kya-os.delegation-gate.d.ts.map +1 -1
- package/dist/middleware/with-kya-os.delegation-gate.js +13 -53
- package/dist/middleware/with-kya-os.delegation-gate.js.map +1 -1
- package/dist/middleware/with-kya-os.delegation-verify.d.ts +23 -10
- package/dist/middleware/with-kya-os.delegation-verify.d.ts.map +1 -1
- package/dist/middleware/with-kya-os.delegation-verify.js +68 -2
- package/dist/middleware/with-kya-os.delegation-verify.js.map +1 -1
- package/dist/utils/statuslist-bits.d.ts +51 -0
- package/dist/utils/statuslist-bits.d.ts.map +1 -0
- package/dist/utils/statuslist-bits.js +106 -0
- package/dist/utils/statuslist-bits.js.map +1 -0
- package/package.json +13 -13
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Status-list primitives — the ONE home for the mechanics every W3C
|
|
3
|
+
* status-list reader AND publisher in this package shares (StatusList2021 /
|
|
4
|
+
* Bitstring Status List v1.0): canonical index parsing, bounded payload
|
|
5
|
+
* inflation, the MSB-first bit read, and the anchor-fitness guard.
|
|
6
|
+
*
|
|
7
|
+
* Consumers: `delegation/bitstring.ts` (+ `statuslist-manager.ts`) and
|
|
8
|
+
* `card/revocation.ts` — previously each carried its own copy of exactly this
|
|
9
|
+
* knowledge, with the drift risk the source comments could only pledge away.
|
|
10
|
+
* The seams' POLICIES stay where they are (the delegation path throws and the
|
|
11
|
+
* caller maps to `status_unresolvable`; the card path catches everything into
|
|
12
|
+
* `FAIL_CLOSED` and models freshness) — only the mechanics live here.
|
|
13
|
+
*
|
|
14
|
+
* FAIL-CLOSED throughout: a non-canonical index, an oversized inflation, or
|
|
15
|
+
* an unreadable bit throws rather than reading as "not revoked".
|
|
16
|
+
*/
|
|
17
|
+
import { base64urlDecodeToBytes } from './base64.js';
|
|
18
|
+
import { isRecord } from './guards.js';
|
|
19
|
+
/**
|
|
20
|
+
* Hard ceiling on an INFLATED status bitstring (16 MiB ≈ 134M entries — far
|
|
21
|
+
* beyond any herd-privacy list). A fixed cap costs nothing legitimate while
|
|
22
|
+
* stopping a decompression bomb; exceeding it throws (fail-closed).
|
|
23
|
+
*/
|
|
24
|
+
export const MAX_STATUS_LIST_BYTES = 16 * 1024 * 1024;
|
|
25
|
+
/**
|
|
26
|
+
* The W3C Bitstring Status List `encodedList` multibase prefix (base64url,
|
|
27
|
+
* no padding). A gzip stream's fixed magic byte (0x1f) makes its base64url
|
|
28
|
+
* start with `H`, never `u`, so a leading `u` is unambiguously the multibase
|
|
29
|
+
* code rather than payload.
|
|
30
|
+
*/
|
|
31
|
+
export const MULTIBASE_BASE64URL = 'u';
|
|
32
|
+
/**
|
|
33
|
+
* Parse a decimal `statusListIndex` (a non-negative integer expressed as a
|
|
34
|
+
* string), fail-closed. Canonical decimal ONLY: `Number()` alone would coerce
|
|
35
|
+
* whitespace (`" "` → 0), hex (`"0x2A"` → 42), `"+42"`, and `"1e1"` → 10 —
|
|
36
|
+
* silently reading a DIFFERENT (often clear) bit than the credential names,
|
|
37
|
+
* so a revoked credential could read as live.
|
|
38
|
+
*/
|
|
39
|
+
export function parseStatusListIndex(raw) {
|
|
40
|
+
if (!/^[0-9]+$/.test(raw)) {
|
|
41
|
+
throw new Error(`Invalid statusListIndex "${raw}" — must be a canonical non-negative decimal`);
|
|
42
|
+
}
|
|
43
|
+
const index = Number(raw);
|
|
44
|
+
if (!Number.isSafeInteger(index)) {
|
|
45
|
+
throw new Error(`statusListIndex "${raw}" exceeds the safe integer range`);
|
|
46
|
+
}
|
|
47
|
+
return index;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Decode a status-list `encodedList` to the raw bitstring: strip the optional
|
|
51
|
+
* multibase `u` prefix, base64url-decode, run the injected decompressor, and
|
|
52
|
+
* re-check the {@link MAX_STATUS_LIST_BYTES} cap POST-inflation as a backstop
|
|
53
|
+
* (a production decompressor SHOULD also bound output during inflation).
|
|
54
|
+
* The decompressor is the bare-function common denominator — an
|
|
55
|
+
* object-shaped `DecompressionFunction` adapts inline:
|
|
56
|
+
* `(b) => decompressor.decompress(b)`.
|
|
57
|
+
*/
|
|
58
|
+
export async function decodeStatusListPayload(encodedList, decompress) {
|
|
59
|
+
const payload = encodedList[0] === MULTIBASE_BASE64URL ? encodedList.slice(1) : encodedList;
|
|
60
|
+
const inflated = await decompress(base64urlDecodeToBytes(payload));
|
|
61
|
+
if (inflated.length > MAX_STATUS_LIST_BYTES) {
|
|
62
|
+
throw new Error(`Status list too large: ${inflated.length} bytes exceeds ${MAX_STATUS_LIST_BYTES}`);
|
|
63
|
+
}
|
|
64
|
+
return inflated instanceof Uint8Array ? inflated : new Uint8Array(inflated);
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Read the status bit at `index` — MSB-first within each byte (W3C Bitstring
|
|
68
|
+
* encoding). Uses FULL-PRECISION arithmetic (`Math.floor(index / 8)`) rather
|
|
69
|
+
* than 32-bit bitwise ops, which coerce to uint32 first: an index ≥ 2^32
|
|
70
|
+
* would silently wrap onto a low byte and read the WRONG — often clear — bit,
|
|
71
|
+
* turning an out-of-range index that MUST fail-closed into a fail-OPEN "not
|
|
72
|
+
* revoked". NaN/negative/fractional/out-of-buffer indexes throw.
|
|
73
|
+
*/
|
|
74
|
+
export function readStatusBit(bits, index) {
|
|
75
|
+
const byte = Number.isInteger(index) && index >= 0
|
|
76
|
+
? bits[Math.floor(index / 8)]
|
|
77
|
+
: undefined;
|
|
78
|
+
if (byte === undefined) {
|
|
79
|
+
throw new Error(`Bit index ${index} out of range for the status list`);
|
|
80
|
+
}
|
|
81
|
+
return (byte & (0x80 >> index % 8)) !== 0;
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Assert a status-list credential is fit to ANCHOR (publish) — signed, and
|
|
85
|
+
* actually carrying a bitstring. Method-agnostic on purpose: the cheqd DLR
|
|
86
|
+
* publisher enforces it today; any future anchoring integration (another
|
|
87
|
+
* DLR-bearing DID method, a different chain) imports the same guard rather
|
|
88
|
+
* than re-deriving "what makes a status list publishable". An unsigned or
|
|
89
|
+
* bitstring-less list anchored on-chain would be an unverifiable — and
|
|
90
|
+
* therefore fail-closed-unusable — revocation source for every holder.
|
|
91
|
+
*/
|
|
92
|
+
export function assertAnchorableStatusListCredential(content) {
|
|
93
|
+
if (!isRecord(content)) {
|
|
94
|
+
throw new Error('Status list credential must be an object');
|
|
95
|
+
}
|
|
96
|
+
if (!content.proof) {
|
|
97
|
+
throw new Error('Refusing to publish an UNSIGNED status list credential');
|
|
98
|
+
}
|
|
99
|
+
const subject = content.credentialSubject;
|
|
100
|
+
if (!isRecord(subject) ||
|
|
101
|
+
typeof subject.encodedList !== 'string' ||
|
|
102
|
+
subject.encodedList.length === 0) {
|
|
103
|
+
throw new Error('Status list credential is missing credentialSubject.encodedList');
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
//# sourceMappingURL=statuslist-bits.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"statuslist-bits.js","sourceRoot":"","sources":["../../src/utils/statuslist-bits.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AACH,OAAO,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAC;AACrD,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAEvC;;;;GAIG;AACH,MAAM,CAAC,MAAM,qBAAq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GAAG,MAAM,CAAC,SAAS,CAAC,KAAK,CAAC,IAAI,KAAK,IAAI,CAAC;QAChD,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,GAAG,CAAC,CAAC,CAAC;QAC7B,CAAC,CAAC,SAAS,CAAC;IACd,IAAI,IAAI,KAAK,SAAS,EAAE,CAAC;QACvB,MAAM,IAAI,KAAK,CACb,aAAa,KAAK,mCAAmC,CACtD,CAAC;IACJ,CAAC;IACD,OAAO,CAAC,IAAI,GAAG,CAAC,IAAI,IAAI,KAAK,GAAG,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC;AAC5C,CAAC;AAED;;;;;;;;GAQG;AACH,MAAM,UAAU,oCAAoC,CAAC,OAAgB;IACnE,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,EAAE,CAAC;QACvB,MAAM,IAAI,KAAK,CAAC,0CAA0C,CAAC,CAAC;IAC9D,CAAC;IACD,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE,CAAC;QACnB,MAAM,IAAI,KAAK,CAAC,wDAAwD,CAAC,CAAC;IAC5E,CAAC;IACD,MAAM,OAAO,GAAG,OAAO,CAAC,iBAAiB,CAAC;IAC1C,IACE,CAAC,QAAQ,CAAC,OAAO,CAAC;QAClB,OAAO,OAAO,CAAC,WAAW,KAAK,QAAQ;QACvC,OAAO,CAAC,WAAW,CAAC,MAAM,KAAK,CAAC,EAChC,CAAC;QACD,MAAM,IAAI,KAAK,CACb,iEAAiE,CAClE,CAAC;IACJ,CAAC;AACH,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kya-os/mcp",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.14.2",
|
|
4
4
|
"description": "Reference implementation of the KYA-OS protocol for Model Context Protocol servers: identity, delegation, proofs, sessions, and verifiable audit trails",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -115,9 +115,9 @@
|
|
|
115
115
|
"example:audit-trail": "npx tsx examples/audit-trail/walkthrough.ts"
|
|
116
116
|
},
|
|
117
117
|
"dependencies": {
|
|
118
|
-
"jose": "^6.2.
|
|
119
|
-
"json-canonicalize": "
|
|
120
|
-
"zod": "^4.3
|
|
118
|
+
"jose": "^6.2.8",
|
|
119
|
+
"json-canonicalize": "2.0.0",
|
|
120
|
+
"zod": "^4.4.3"
|
|
121
121
|
},
|
|
122
122
|
"peerDependencies": {
|
|
123
123
|
"@modelcontextprotocol/sdk": ">=1.0.0"
|
|
@@ -129,20 +129,20 @@
|
|
|
129
129
|
},
|
|
130
130
|
"devDependencies": {
|
|
131
131
|
"@eslint/js": "^10.0.1",
|
|
132
|
-
"@kya-os/consent": "^0.1.
|
|
133
|
-
"@modelcontextprotocol/sdk": "^1.
|
|
132
|
+
"@kya-os/consent": "^0.1.47",
|
|
133
|
+
"@modelcontextprotocol/sdk": "^1.30.0",
|
|
134
134
|
"@types/express": "^5.0.6",
|
|
135
|
-
"@types/node": "^26.0
|
|
136
|
-
"@typescript-eslint/eslint-plugin": "^8.
|
|
137
|
-
"@typescript-eslint/parser": "^8.
|
|
135
|
+
"@types/node": "^26.2.0",
|
|
136
|
+
"@typescript-eslint/eslint-plugin": "^8.67.0",
|
|
137
|
+
"@typescript-eslint/parser": "^8.67.0",
|
|
138
138
|
"@vitest/coverage-v8": "^4.1.10",
|
|
139
139
|
"ajv": "^8.20.0",
|
|
140
140
|
"commander": "^15.0.0",
|
|
141
|
-
"eslint": "^10.
|
|
141
|
+
"eslint": "^10.8.1",
|
|
142
142
|
"express": "^5.2.1",
|
|
143
|
-
"tsx": "^4.
|
|
144
|
-
"typescript": "^5.
|
|
145
|
-
"typescript-eslint": "^8.
|
|
143
|
+
"tsx": "^4.23.12",
|
|
144
|
+
"typescript": "^5.9.3",
|
|
145
|
+
"typescript-eslint": "^8.67.0",
|
|
146
146
|
"vitest": "^4.1.10"
|
|
147
147
|
},
|
|
148
148
|
"keywords": [
|