@vess-id/ai-identity 0.10.0 → 0.12.0

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.
Files changed (34) hide show
  1. package/README.md +0 -16
  2. package/dist/client.d.ts +0 -14
  3. package/dist/client.d.ts.map +1 -1
  4. package/dist/index.d.mts +456 -153
  5. package/dist/index.d.ts +2 -1
  6. package/dist/index.d.ts.map +1 -1
  7. package/dist/index.js +172 -206
  8. package/dist/index.js.map +1 -1
  9. package/dist/index.mjs +158 -205
  10. package/dist/index.mjs.map +1 -1
  11. package/dist/internal-signature/__tests__/canonical.spec.d.ts +2 -0
  12. package/dist/internal-signature/__tests__/canonical.spec.d.ts.map +1 -0
  13. package/dist/internal-signature/__tests__/signer-roundtrip.spec.d.ts +2 -0
  14. package/dist/internal-signature/__tests__/signer-roundtrip.spec.d.ts.map +1 -0
  15. package/dist/internal-signature/__tests__/signer.spec.d.ts +2 -0
  16. package/dist/internal-signature/__tests__/signer.spec.d.ts.map +1 -0
  17. package/dist/internal-signature/canonical.d.ts +80 -0
  18. package/dist/internal-signature/canonical.d.ts.map +1 -0
  19. package/dist/internal-signature/index.d.ts +17 -0
  20. package/dist/internal-signature/index.d.ts.map +1 -0
  21. package/dist/internal-signature/signer.d.ts +76 -0
  22. package/dist/internal-signature/signer.d.ts.map +1 -0
  23. package/dist/registry/action-registry-json.d.ts +114 -0
  24. package/dist/registry/action-registry-json.d.ts.map +1 -1
  25. package/dist/registry/index.d.ts +2 -0
  26. package/dist/registry/index.d.ts.map +1 -1
  27. package/dist/registry/reauth-constants.d.ts +33 -0
  28. package/dist/registry/reauth-constants.d.ts.map +1 -0
  29. package/dist/vp/kb-jwt-builder.d.ts +89 -0
  30. package/dist/vp/kb-jwt-builder.d.ts.map +1 -0
  31. package/dist/vp/vp-manager.d.ts.map +1 -1
  32. package/package.json +20 -26
  33. package/dist/memory/memory-manager.d.ts +0 -77
  34. package/dist/memory/memory-manager.d.ts.map +0 -1
@@ -0,0 +1,89 @@
1
+ /**
2
+ * Single source of truth for Key Binding JWT (KB-JWT) issuance shared across
3
+ * the AIdentity stack. Four production code paths build KB-JWTs and they
4
+ * MUST stay byte-for-byte equivalent so a presentation built on one side is
5
+ * accepted by the verifier on the other:
6
+ *
7
+ * - SDK clients via `VPManager.create()` (this package)
8
+ * - API service via `packages/api/src/vp/vp-creation.service.ts`
9
+ * - Remote MCP via `packages/remote-mcp/src/services/vp-creation.service.ts`
10
+ * - agentd (`@vess-id/vess`) via `VPBuilder.buildVP()`
11
+ * (`packages/agentd/src/wallet/vp-builder.ts`)
12
+ *
13
+ * Historically each path had its own copy of this logic. PR #391 (the
14
+ * commit that made `exp` REQUIRED on the verifier side) updated only two of
15
+ * the three issuer paths known at the time; the SDK was missed and every
16
+ * SDK-built VP started failing at verification time. The follow-up
17
+ * consolidation (commit 02b169aa) brought the SDK in line, but agentd —
18
+ * which had its own KB-JWT literal in `wallet/vp-builder.ts` — was not
19
+ * recognized as a fourth issuer. Staging then rejected every VP from
20
+ * `@vess-id/vess` agentd alpha builds with `KB-JWT missing exp` until the
21
+ * agentd hotfix (this commit's cohort) wired its VPBuilder through
22
+ * `buildKbJwtPayload()`. This module exists so that a future verifier
23
+ * change cannot drift from the issuer side: any update lands in one place
24
+ * and all four paths inherit it.
25
+ */
26
+ /**
27
+ * Default KB-JWT lifetime in seconds. Mirrors the cap enforced by the API's
28
+ * `KeyBindingVerifierService.MAX_KB_JWT_LIFETIME_SECONDS` (also 300).
29
+ *
30
+ * The KB-JWT `exp` is the smaller of:
31
+ * - `iat + KB_JWT_DEFAULT_LIFETIME_SECONDS`
32
+ * - the parent VC's `exp` (so the bearer's freshness window cannot outlive
33
+ * the underlying credential's validity, which is itself bounded by
34
+ * `grant.expiresAt` at issuance time).
35
+ */
36
+ export declare const KB_JWT_DEFAULT_LIFETIME_SECONDS = 300;
37
+ export interface KbJwtPayload {
38
+ iss: string;
39
+ aud: string;
40
+ nonce: string;
41
+ iat: number;
42
+ exp: number;
43
+ }
44
+ export interface BuildKbJwtPayloadArgs {
45
+ /** Holder DID — becomes the KB-JWT `iss` claim. */
46
+ holderDid: string;
47
+ /** Verifier audience (URL or hostname). Will be normalized via {@link normalizeDomain}. */
48
+ audience: string;
49
+ /** Verifier-supplied nonce / challenge. */
50
+ nonce: string;
51
+ /** The parent SD-JWT VC string. Its `exp` (if any) caps the KB-JWT lifetime. */
52
+ vcCredential: string;
53
+ }
54
+ export interface BuildKbJwtPayloadDeps {
55
+ /** Returns the current time in milliseconds. Defaults to `Date.now`. */
56
+ now?: () => number;
57
+ }
58
+ /**
59
+ * Build a Key Binding JWT payload for an SD-JWT VC presentation.
60
+ *
61
+ * Throws when the parent VC is already expired (`vc.exp <= now`). The error
62
+ * message intentionally contains the substring `"VC has expired"` so that
63
+ * downstream catchers (notably remote-mcp's `isCredentialInvalidError`) can
64
+ * detect a stale-credential condition and trigger a re-approval flow rather
65
+ * than surface an opaque issuance failure to the user.
66
+ */
67
+ export declare function buildKbJwtPayload(args: BuildKbJwtPayloadArgs, deps?: BuildKbJwtPayloadDeps): KbJwtPayload;
68
+ /**
69
+ * Best-effort read of the VC's `exp` claim from the SD-JWT outer payload.
70
+ * Returns undefined when the VC is malformed, missing exp, or the field is
71
+ * not a number — callers fall back to {@link KB_JWT_DEFAULT_LIFETIME_SECONDS}
72
+ * in that case so issuance does not break for VCs without an explicit expiry.
73
+ */
74
+ export declare function readVcExpSeconds(sdJwtVc: string): number | undefined;
75
+ /**
76
+ * Normalize a domain string for consistent use as a JWT `aud` claim.
77
+ *
78
+ * The API verifier compares the KB-JWT `aud` against the expected domain by
79
+ * exact string match, so issuer and verifier must agree on the canonical
80
+ * form. We delegate to the URL parser, which strips paths and lowercases
81
+ * the host, then return the resulting `origin`.
82
+ *
83
+ * Inputs without a scheme are assumed to be hostnames; `localhost` (with or
84
+ * without a port) defaults to `http://`, everything else to `https://`. If
85
+ * URL parsing fails, the input is returned unchanged so a caller can still
86
+ * detect the mismatch downstream rather than silently swallowing a typo.
87
+ */
88
+ export declare function normalizeDomain(domain: string): string;
89
+ //# sourceMappingURL=kb-jwt-builder.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"kb-jwt-builder.d.ts","sourceRoot":"","sources":["../../src/vp/kb-jwt-builder.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAEH;;;;;;;;;GASG;AACH,eAAO,MAAM,+BAA+B,MAAM,CAAA;AAElD,MAAM,WAAW,YAAY;IAC3B,GAAG,EAAE,MAAM,CAAA;IACX,GAAG,EAAE,MAAM,CAAA;IACX,KAAK,EAAE,MAAM,CAAA;IACb,GAAG,EAAE,MAAM,CAAA;IACX,GAAG,EAAE,MAAM,CAAA;CACZ;AAED,MAAM,WAAW,qBAAqB;IACpC,mDAAmD;IACnD,SAAS,EAAE,MAAM,CAAA;IACjB,2FAA2F;IAC3F,QAAQ,EAAE,MAAM,CAAA;IAChB,2CAA2C;IAC3C,KAAK,EAAE,MAAM,CAAA;IACb,gFAAgF;IAChF,YAAY,EAAE,MAAM,CAAA;CACrB;AAED,MAAM,WAAW,qBAAqB;IACpC,wEAAwE;IACxE,GAAG,CAAC,EAAE,MAAM,MAAM,CAAA;CACnB;AAED;;;;;;;;GAQG;AACH,wBAAgB,iBAAiB,CAC/B,IAAI,EAAE,qBAAqB,EAC3B,IAAI,GAAE,qBAA0B,GAC/B,YAAY,CAqBd;AAED;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAUpE;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,eAAe,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAgBtD"}
@@ -1 +1 @@
1
- {"version":3,"file":"vp-manager.d.ts","sourceRoot":"","sources":["../../src/vp/vp-manager.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,EAAE,SAAS,EAAE,MAAM,UAAU,CAAA;A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AAE,MAAM,EAAE,EAAE,6BAA6B;IAC5C,OAAO,EAAE;QACP,SAAS,EAAE,MAAM,CAAA;QACjB,SAAS,EAAE,MAAM,CAAA;QACjB,MAAM,EAAE,MAAM,CAAA;QACd,OAAO,CAAC,EAAE,MAAM,CAAA;KACjB,GACA,OAAO,CAAC,MAAM,CAAC;IA6ClB;;OAEG;IACG,MAAM,CACV,KAAK,EAAE,MAAM,EACb,OAAO,EAAE;QACP,iBAAiB,EAAE,MAAM,CAAA;QACzB,cAAc,EAAE,MAAM,CAAA;QACtB,cAAc,CAAC,EAAE,MAAM,CAAA;KACxB,GACA,OAAO,CAAC,sBAAsB,CAAC;IAwClC;;OAEG;IACH,aAAa,CACX,MAAM,EAAE,MAAM,EACd,KAAK,CAAC,EAAE;QACN,IAAI,CAAC,EAAE,MAAM,CAAA;QACb,eAAe,CAAC,EAAE,GAAG,CAAA;KACtB,GACA,SAAS;IAQZ;;OAEG;IACG,MAAM,CACV,KAAK,EAAE,MAAM,EACb,gBAAgB,EAAE,MAAM,GACvB,OAAO,CAAC;QAAE,QAAQ,EAAE,OAAO,CAAC;QAAC,MAAM,CAAC,EAAE,GAAG,CAAA;KAAE,CAAC;CAehD"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vess-id/ai-identity",
3
- "version": "0.10.0",
3
+ "version": "0.12.0",
4
4
  "description": "TypeScript SDK for AI Identity Layer",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.mjs",
@@ -21,40 +21,34 @@
21
21
  "url": "https://github.com/cvoxelprotocol/aidentity.git",
22
22
  "directory": "packages/sdk"
23
23
  },
24
- "scripts": {
25
- "build": "tsup && tsc --declaration --emitDeclarationOnly --outDir dist",
26
- "dev": "tsup --watch",
27
- "test": "jest",
28
- "typecheck": "tsc --noEmit",
29
- "clean": "rm -rf dist node_modules",
30
- "semantic-release": "semantic-release"
31
- },
32
24
  "dependencies": {
33
25
  "@sd-jwt/crypto-nodejs": "^0.15.0",
34
26
  "@sd-jwt/sd-jwt-vc": "^0.15.1",
35
27
  "@sd-jwt/types": "^0.15.0",
36
- "ajv": "^8.17.1",
28
+ "ajv": "^8.18.0",
37
29
  "ajv-formats": "^3.0.1",
38
- "jose": "^5.1.0",
39
- "uuid": "^9.0.0"
30
+ "jose": "^5.10.0",
31
+ "uuid": "^9.0.1"
40
32
  },
41
33
  "devDependencies": {
42
- "@types/jest": "^29.5.0",
43
- "@types/node": "^20.10.0",
44
- "@types/uuid": "^9.0.0",
34
+ "@types/jest": "^29.5.14",
35
+ "@types/node": "^20.19.39",
36
+ "@types/uuid": "^9.0.8",
45
37
  "jest": "^29.7.0",
46
- "ts-jest": "^29.1.0",
47
- "tsup": "^8.0.0",
48
- "typescript": "^5.3.0",
49
- "@semantic-release/commit-analyzer": "^13.0.1",
50
- "@semantic-release/github": "^12.0.6",
51
- "@semantic-release/npm": "^13.0.0",
52
- "@semantic-release/release-notes-generator": "^14.1.0",
53
- "conventional-changelog-conventionalcommits": "^9.3.0",
54
- "semantic-release": "^25.0.3"
38
+ "ts-jest": "^29.4.9",
39
+ "tsup": "^8.5.1",
40
+ "typescript": "^5.9.3"
55
41
  },
56
42
  "publishConfig": {
57
43
  "access": "public"
58
44
  },
59
- "license": "MIT"
60
- }
45
+ "license": "MIT",
46
+ "scripts": {
47
+ "build": "tsup && tsc --declaration --emitDeclarationOnly --outDir dist",
48
+ "dev": "tsup --watch --no-clean",
49
+ "test": "jest",
50
+ "typecheck": "tsc --noEmit",
51
+ "clean": "rm -rf dist node_modules",
52
+ "assert:publish-surface": "node scripts/assert-publish-surface.js"
53
+ }
54
+ }
@@ -1,77 +0,0 @@
1
- import { VPManager } from '../vp/vp-manager';
2
- /**
3
- * NOTE: MemoryManager is currently DORMANT (as of 2026-03-29).
4
- * The API memory endpoints exist but are not actively called in production.
5
- * The server-side implementation (InMemoryProvider) is volatile and not shared across instances.
6
- * Do not rely on this in production until a persistent backend is introduced.
7
- */
8
- export interface MemoryDocument {
9
- id: string;
10
- namespace: string;
11
- content: string;
12
- metadata?: Record<string, any>;
13
- embedding?: number[];
14
- createdAt: string;
15
- updatedAt: string;
16
- }
17
- export interface MemoryQuery {
18
- query: string;
19
- namespace?: string;
20
- limit?: number;
21
- filter?: Record<string, any>;
22
- includeEmbedding?: boolean;
23
- }
24
- export interface MemoryQueryResult {
25
- documents: MemoryDocument[];
26
- scores?: number[];
27
- total: number;
28
- }
29
- export declare class MemoryManager {
30
- private vpManager;
31
- private proxyApiUrl;
32
- constructor(vpManager?: VPManager);
33
- /**
34
- * Write a document to memory
35
- */
36
- write(content: string, options: {
37
- namespace: string;
38
- metadata?: Record<string, any>;
39
- vcs: string[];
40
- holderDid: string;
41
- }): Promise<MemoryDocument>;
42
- /**
43
- * Query memory with vector search
44
- */
45
- query(query: string, options: {
46
- namespace?: string;
47
- limit?: number;
48
- filter?: Record<string, any>;
49
- vcs: string[];
50
- holderDid: string;
51
- }): Promise<MemoryQueryResult>;
52
- /**
53
- * Delete a document from memory
54
- */
55
- delete(documentId: string, options: {
56
- namespace: string;
57
- vcs: string[];
58
- holderDid: string;
59
- }): Promise<void>;
60
- /**
61
- * List documents in a namespace
62
- */
63
- list(options: {
64
- namespace: string;
65
- limit?: number;
66
- offset?: number;
67
- vcs: string[];
68
- holderDid: string;
69
- }): Promise<MemoryQueryResult>;
70
- /**
71
- * Check if VCs authorize memory access
72
- */
73
- checkAuthorization(vcs: string[], action: 'read' | 'write' | 'delete', resource: string): Promise<boolean>;
74
- private matchResource;
75
- private generateChallenge;
76
- }
77
- //# sourceMappingURL=memory-manager.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"memory-manager.d.ts","sourceRoot":"","sources":["../../src/memory/memory-manager.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAA;AAG5C;;;;;GAKG;AAEH,MAAM,WAAW,cAAc;IAC7B,EAAE,EAAE,MAAM,CAAA;IACV,SAAS,EAAE,MA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