@vess-id/ai-identity 0.3.0 → 0.3.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/dist/agent/agent-did-manager.d.ts +50 -0
- package/dist/agent/agent-did-manager.d.ts.map +1 -0
- package/dist/auth/auth-provider.d.ts +51 -0
- package/dist/auth/auth-provider.d.ts.map +1 -0
- package/dist/auth/index.d.ts +2 -0
- package/dist/auth/index.d.ts.map +1 -0
- package/dist/client.d.ts +80 -0
- package/dist/client.d.ts.map +1 -0
- package/dist/config/index.d.ts +30 -0
- package/dist/config/index.d.ts.map +1 -0
- package/dist/constraint/__tests__/fixtures/constraint.fixtures.d.ts +56 -0
- package/dist/constraint/__tests__/fixtures/constraint.fixtures.d.ts.map +1 -0
- package/dist/constraint/constraint-evaluator.d.ts +72 -0
- package/dist/constraint/constraint-evaluator.d.ts.map +1 -0
- package/dist/constraint/index.d.ts +5 -0
- package/dist/constraint/index.d.ts.map +1 -0
- package/dist/did/agent.d.ts +52 -0
- package/dist/did/agent.d.ts.map +1 -0
- package/dist/did/did-utils.d.ts +75 -0
- package/dist/did/did-utils.d.ts.map +1 -0
- package/dist/did/key-manager.d.ts +19 -0
- package/dist/did/key-manager.d.ts.map +1 -0
- package/dist/gateway/gateway-client.d.ts +103 -0
- package/dist/gateway/gateway-client.d.ts.map +1 -0
- package/dist/gateway/index.d.ts +2 -0
- package/dist/gateway/index.d.ts.map +1 -0
- package/dist/grant/grant-manager.d.ts +140 -0
- package/dist/grant/grant-manager.d.ts.map +1 -0
- package/dist/grant/index.d.ts +2 -0
- package/dist/grant/index.d.ts.map +1 -0
- package/dist/identity/device-enroll-manager.d.ts +111 -0
- package/dist/identity/device-enroll-manager.d.ts.map +1 -0
- package/dist/identity/user-identity-manager.d.ts +69 -0
- package/dist/identity/user-identity-manager.d.ts.map +1 -0
- package/dist/identity/user-key-pair-manager.d.ts +22 -0
- package/dist/identity/user-key-pair-manager.d.ts.map +1 -0
- package/dist/index.d.ts +32 -3077
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +351 -45
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +351 -49
- package/dist/index.mjs.map +1 -1
- package/dist/memory/memory-manager.d.ts +71 -0
- package/dist/memory/memory-manager.d.ts.map +1 -0
- package/dist/monitoring/metrics-manager.d.ts +74 -0
- package/dist/monitoring/metrics-manager.d.ts.map +1 -0
- package/dist/organization/disclosure-config-manager.d.ts +61 -0
- package/dist/organization/disclosure-config-manager.d.ts.map +1 -0
- package/dist/organization/key-rotation-manager.d.ts +63 -0
- package/dist/organization/key-rotation-manager.d.ts.map +1 -0
- package/dist/organization/organization-manager.d.ts +38 -0
- package/dist/organization/organization-manager.d.ts.map +1 -0
- package/dist/registry/access-orchestrator.d.ts +183 -0
- package/dist/registry/access-orchestrator.d.ts.map +1 -0
- package/dist/registry/action-registry-json.d.ts +1363 -0
- package/dist/registry/action-registry-json.d.ts.map +1 -0
- package/dist/registry/action-registry.d.ts +65 -0
- package/dist/registry/action-registry.d.ts.map +1 -0
- package/dist/registry/index.d.ts +4 -0
- package/dist/registry/index.d.ts.map +1 -0
- package/dist/revocation/revocation-manager.d.ts +98 -0
- package/dist/revocation/revocation-manager.d.ts.map +1 -0
- package/dist/state/index.d.ts +3 -0
- package/dist/state/index.d.ts.map +1 -0
- package/dist/state/json-state-store.d.ts +24 -0
- package/dist/state/json-state-store.d.ts.map +1 -0
- package/dist/state/state-store.interface.d.ts +37 -0
- package/dist/state/state-store.interface.d.ts.map +1 -0
- package/dist/storage/filesystem-key-storage.d.ts +16 -0
- package/dist/storage/filesystem-key-storage.d.ts.map +1 -0
- package/dist/storage/index.d.ts +4 -0
- package/dist/storage/index.d.ts.map +1 -0
- package/dist/storage/key-storage.interface.d.ts +42 -0
- package/dist/storage/key-storage.interface.d.ts.map +1 -0
- package/dist/storage/memory-key-storage.d.ts +17 -0
- package/dist/storage/memory-key-storage.d.ts.map +1 -0
- package/dist/tool/tool-manager.d.ts +44 -0
- package/dist/tool/tool-manager.d.ts.map +1 -0
- package/dist/utils/crypto.d.ts +22 -0
- package/dist/utils/crypto.d.ts.map +1 -0
- package/dist/utils/sdjwt-client.d.ts +168 -0
- package/dist/utils/sdjwt-client.d.ts.map +1 -0
- package/dist/vc/api-vc-manager.d.ts +40 -0
- package/dist/vc/api-vc-manager.d.ts.map +1 -0
- package/dist/vc/vc-manager.d.ts +55 -0
- package/dist/vc/vc-manager.d.ts.map +1 -0
- package/dist/vp/vp-manager.d.ts +40 -0
- package/dist/vp/vp-manager.d.ts.map +1 -0
- package/package.json +2 -2
- package/dist/index.d.mts +0 -3078
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"action-registry-json.d.ts","sourceRoot":"","sources":["../../src/registry/action-registry-json.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,eAAe;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAuc3B,CAAA"}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { RiskLevel } from '@vess-id/ai-identity-types';
|
|
2
|
+
export type { RiskLevel };
|
|
3
|
+
export type Relation = 'viewer' | 'editor' | 'admin' | 'owner' | 'act_as';
|
|
4
|
+
/** MVPの対象リソース(必要に応じて拡張) */
|
|
5
|
+
export type ResourceType = 'SlackChannel' | 'GitHubRepo' | 'DriveFile';
|
|
6
|
+
/** JSON Schema を受け取るための型。Ajvで別途メタ検証します。 */
|
|
7
|
+
export type JsonSchema = Record<string, unknown>;
|
|
8
|
+
export interface ActionMeta {
|
|
9
|
+
action: string;
|
|
10
|
+
resource_type: ResourceType;
|
|
11
|
+
required_relations: Relation[];
|
|
12
|
+
required_scopes: string[];
|
|
13
|
+
capability?: string;
|
|
14
|
+
input_schema?: JsonSchema;
|
|
15
|
+
constraints?: Record<string, unknown>;
|
|
16
|
+
effects?: string[];
|
|
17
|
+
risk?: RiskLevel;
|
|
18
|
+
version: string;
|
|
19
|
+
}
|
|
20
|
+
export interface CapabilityMeta {
|
|
21
|
+
capability: string;
|
|
22
|
+
description?: string;
|
|
23
|
+
includes: string[];
|
|
24
|
+
version: string;
|
|
25
|
+
}
|
|
26
|
+
export interface ActionRegistry {
|
|
27
|
+
registry_version: string;
|
|
28
|
+
actions: ActionMeta[];
|
|
29
|
+
capabilities?: CapabilityMeta[];
|
|
30
|
+
}
|
|
31
|
+
import Ajv from 'ajv';
|
|
32
|
+
/**
|
|
33
|
+
* Ajv インスタンスを作成。
|
|
34
|
+
* - 本体スキーマ(registry/actions/capabilities)を登録
|
|
35
|
+
* - formats 追加
|
|
36
|
+
* - $id付きで利用
|
|
37
|
+
*/
|
|
38
|
+
export declare function createAjv(): Ajv;
|
|
39
|
+
/**
|
|
40
|
+
* Registry全体の構文検証 + 各Actionの input_schema を「JSON Schemaとして」検証。
|
|
41
|
+
* @returns { ok, errors } 失敗時は diag を含む
|
|
42
|
+
*/
|
|
43
|
+
export declare function validateRegistryObject(registry: unknown): {
|
|
44
|
+
ok: boolean;
|
|
45
|
+
errors?: string[];
|
|
46
|
+
};
|
|
47
|
+
/**
|
|
48
|
+
* JSONファイルからAction Registryを読み込み、完全検証して返す。
|
|
49
|
+
* @throws Error 検証エラー時は詳細メッセージ付きでthrow
|
|
50
|
+
*/
|
|
51
|
+
export declare function loadActionRegistryFromFile(filePath: string): Promise<ActionRegistry>;
|
|
52
|
+
/**
|
|
53
|
+
* 既にパース済みのオブジェクトを検証して返す。
|
|
54
|
+
* @throws Error 検証エラー時は詳細メッセージ付きでthrow
|
|
55
|
+
*/
|
|
56
|
+
export declare function loadActionRegistryFromObject(obj: unknown): ActionRegistry;
|
|
57
|
+
/** アクション名→ActionMeta のルックアップを作成 */
|
|
58
|
+
export declare function indexActions(reg: ActionRegistry): Map<string, ActionMeta>;
|
|
59
|
+
/** Capability名→CapabilityMeta のルックアップを作成 */
|
|
60
|
+
export declare function indexCapabilities(reg: ActionRegistry): Map<string, CapabilityMeta>;
|
|
61
|
+
/** 指定アクションの required_scopes を取得(無ければ空配列) */
|
|
62
|
+
export declare function getRequiredScopes(regIndex: Map<string, ActionMeta>, action: string): string[];
|
|
63
|
+
/** 指定アクションの required_relations(OR解釈)を取得(無ければ空配列) */
|
|
64
|
+
export declare function getRequiredRelations(regIndex: Map<string, ActionMeta>, action: string): Relation[];
|
|
65
|
+
//# sourceMappingURL=action-registry.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"action-registry.d.ts","sourceRoot":"","sources":["../../src/registry/action-registry.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,SAAS,EAAE,MAAM,4BAA4B,CAAA;AACtD,YAAY,EAAE,SAAS,EAAE,CAAA;AACzB,MAAM,MAAM,QAAQ,GAAG,QAAQ,GAAG,QAAQ,GAAG,OAAO,GAAG,OAAO,GAAG,QAAQ,CAAA;AAEzE,2BAA2B;AAC3B,MAAM,MAAM,YAAY,GAAG,cAAc,GAAG,YAAY,GAAG,WAAW,CAAA;AAEtE,2CAA2C;AAC3C,MAAM,MAAM,UAAU,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;AAEhD,MAAM,WAAW,UAAU;IACzB,MAAM,EAAE,MAAM,CAAA;IACd,aAAa,EAAE,YAAY,CAAA;IAC3B,kBAAkB,EAAE,QAAQ,EAAE,CAAA;IAC9B,eAAe,EAAE,MAAM,EAAE,CAAA;IACzB,UAAU,CAAC,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AE,GAAG,CAAC,MAAM,EAAE,UAAU,CAAC,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,EAAE,CAE7F;AAED,oDAAoD;AACpD,wBAAgB,oBAAoB,CAClC,QAAQ,EAAE,GAAG,CAAC,MAAM,EAAE,UAAU,CAAC,EACjC,MAAM,EAAE,MAAM,GACb,QAAQ,EAAE,CAEZ"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export * from './access-orchestrator';
|
|
2
|
+
export { Relation, ResourceType, JsonSchema, ActionMeta, CapabilityMeta, ActionRegistry, createAjv, validateRegistryObject, loadActionRegistryFromFile, loadActionRegistryFromObject, indexActions, indexCapabilities, getRequiredScopes, getRequiredRelations, } from './action-registry';
|
|
3
|
+
export * from "./action-registry-json";
|
|
4
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/registry/index.ts"],"names":[],"mappings":"AAAA,cAAc,uBAAuB,CAAA;AAErC,OAAO,EACL,QAAQ,EACR,YAAY,EACZ,UAAU,EACV,UAAU,EACV,cAAc,EACd,cAAc,EACd,SAAS,EACT,sBAAsB,EACtB,0BAA0B,EAC1B,4BAA4B,EAC5B,YAAY,EACZ,iBAAiB,EACjB,iBAAiB,EACjB,oBAAoB,GACrB,MAAM,mBAAmB,CAAA;AAC1B,cAAc,wBAAwB,CAAA"}
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
export interface RevocationListEntry {
|
|
2
|
+
credentialId: string;
|
|
3
|
+
revocationDate: Date;
|
|
4
|
+
reason?: string;
|
|
5
|
+
revokedBy: string;
|
|
6
|
+
}
|
|
7
|
+
export interface RevocationList {
|
|
8
|
+
id: string;
|
|
9
|
+
issuer: string;
|
|
10
|
+
type: 'StatusList2021' | 'BitStringStatusList';
|
|
11
|
+
statusPurpose: 'revocation' | 'suspension';
|
|
12
|
+
encodedList: string;
|
|
13
|
+
entries: RevocationListEntry[];
|
|
14
|
+
createdAt: Date;
|
|
15
|
+
updatedAt: Date;
|
|
16
|
+
}
|
|
17
|
+
export interface CredentialStatusInfo {
|
|
18
|
+
id: string;
|
|
19
|
+
type: string;
|
|
20
|
+
statusListIndex: number;
|
|
21
|
+
statusListCredential: string;
|
|
22
|
+
revocationReason?: string;
|
|
23
|
+
revocationDate?: Date;
|
|
24
|
+
}
|
|
25
|
+
export declare class RevocationManager {
|
|
26
|
+
private revocationLists;
|
|
27
|
+
private credentialStatuses;
|
|
28
|
+
/**
|
|
29
|
+
* Create a new revocation list
|
|
30
|
+
*/
|
|
31
|
+
createRevocationList(issuer: string, type?: 'StatusList2021' | 'BitStringStatusList', purpose?: 'revocation' | 'suspension'): Promise<RevocationList>;
|
|
32
|
+
/**
|
|
33
|
+
* Add credential to revocation list
|
|
34
|
+
*/
|
|
35
|
+
addCredentialToRevocationList(credentialId: string, listId: string, statusIndex?: number): Promise<CredentialStatusInfo>;
|
|
36
|
+
/**
|
|
37
|
+
* Revoke a credential
|
|
38
|
+
*/
|
|
39
|
+
revokeCredential(credentialId: string, reason?: string, revokedBy?: string): Promise<boolean>;
|
|
40
|
+
/**
|
|
41
|
+
* Check if credential is revoked
|
|
42
|
+
*/
|
|
43
|
+
isCredentialRevoked(credentialId: string): Promise<{
|
|
44
|
+
revoked: boolean;
|
|
45
|
+
reason?: string;
|
|
46
|
+
revokedDate?: Date;
|
|
47
|
+
revokedBy?: string;
|
|
48
|
+
}>;
|
|
49
|
+
/**
|
|
50
|
+
* Get credential status info
|
|
51
|
+
*/
|
|
52
|
+
getCredentialStatus(credentialId: string): Promise<CredentialStatusInfo | null>;
|
|
53
|
+
/**
|
|
54
|
+
* Get revocation list
|
|
55
|
+
*/
|
|
56
|
+
getRevocationList(listId: string): Promise<RevocationList | null>;
|
|
57
|
+
/**
|
|
58
|
+
* Get all revocation lists for an issuer
|
|
59
|
+
*/
|
|
60
|
+
getIssuerRevocationLists(issuer: string): Promise<RevocationList[]>;
|
|
61
|
+
/**
|
|
62
|
+
* Restore/unreovke a credential
|
|
63
|
+
*/
|
|
64
|
+
restoreCredential(credentialId: string): Promise<boolean>;
|
|
65
|
+
/**
|
|
66
|
+
* Create empty bit string
|
|
67
|
+
*/
|
|
68
|
+
private createEmptyBitString;
|
|
69
|
+
/**
|
|
70
|
+
* Set bit in encoded string
|
|
71
|
+
*/
|
|
72
|
+
private setBitInString;
|
|
73
|
+
/**
|
|
74
|
+
* Get bit from encoded string
|
|
75
|
+
*/
|
|
76
|
+
private getBitFromString;
|
|
77
|
+
/**
|
|
78
|
+
* Find next available index in revocation list
|
|
79
|
+
*/
|
|
80
|
+
private findNextAvailableIndex;
|
|
81
|
+
/**
|
|
82
|
+
* Export revocation list in standard format
|
|
83
|
+
*/
|
|
84
|
+
exportRevocationList(listId: string): Promise<{
|
|
85
|
+
'@context': string[];
|
|
86
|
+
id: string;
|
|
87
|
+
type: string[];
|
|
88
|
+
issuer: string;
|
|
89
|
+
validFrom: string;
|
|
90
|
+
credentialSubject: {
|
|
91
|
+
id: string;
|
|
92
|
+
type: string;
|
|
93
|
+
statusPurpose: string;
|
|
94
|
+
encodedList: string;
|
|
95
|
+
};
|
|
96
|
+
} | null>;
|
|
97
|
+
}
|
|
98
|
+
//# sourceMappingURL=revocation-manager.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"revocation-manager.d.ts","sourceRoot":"","sources":["../../src/revocation/revocation-manager.ts"],"names":[],"mappings":"AAEA,MAAM,WAAW,mBAAmB;IAClC,YAAY,EAAE,MAAM,CAAA;IACpB,cAAc,EAAE,IAAI,CAAA;IACpB,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,SAAS,EAAE,MAAM,CAAA;CAClB;AAED,MAAM,WAAW,cAAc;IAC7B,EAAE,EAAE,MAAM,CAAA;IACV,MAAM,EAAE,MAAM,CAAA;IACd,IAAI,EAAE,gBAAgB,GAAG,qBAAqB,CAAA;IAC9C,aAAa,EAAE,YAAY,GA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AEG;IACG,iBAAiB,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,cAAc,GAAG,IAAI,CAAC;IAIvE;;OAEG;IACG,wBAAwB,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,cAAc,EAAE,CAAC;IAIzE;;OAEG;IACG,iBAAiB,CAAC,YAAY,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IA+B/D;;OAEG;IACH,OAAO,CAAC,oBAAoB;IAM5B;;OAEG;IACH,OAAO,CAAC,cAAc;IAkBtB;;OAEG;IACH,OAAO,CAAC,gBAAgB;IAYxB;;OAEG;IACH,OAAO,CAAC,sBAAsB;IAY9B;;OAEG;IACG,oBAAoB,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC;QAClD,UAAU,EAAE,MAAM,EAAE,CAAA;QACpB,EAAE,EAAE,MAAM,CAAA;QACV,IAAI,EAAE,MAAM,EAAE,CAAA;QACd,MAAM,EAAE,MAAM,CAAA;QACd,SAAS,EAAE,MAAM,CAAA;QACjB,iBAAiB,EAAE;YACjB,EAAE,EAAE,MAAM,CAAA;YACV,IAAI,EAAE,MAAM,CAAA;YACZ,aAAa,EAAE,MAAM,CAAA;YACrB,WAAW,EAAE,MAAM,CAAA;SACpB,CAAA;KACF,GAAG,IAAI,CAAC;CAuBV"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/state/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAA;AACrD,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAA"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { IStateStore } from './state-store.interface';
|
|
2
|
+
/**
|
|
3
|
+
* JSON file-based state store.
|
|
4
|
+
* Stores state in ~/.vess/state.json by default.
|
|
5
|
+
* Uses atomic write (temp file → rename) for safety.
|
|
6
|
+
*/
|
|
7
|
+
export declare class JsonStateStore implements IStateStore {
|
|
8
|
+
private filePath;
|
|
9
|
+
private data;
|
|
10
|
+
constructor(filePath?: string);
|
|
11
|
+
get<T = unknown>(key: string): Promise<T | undefined>;
|
|
12
|
+
set<T = unknown>(key: string, value: T): Promise<void>;
|
|
13
|
+
delete(key: string): Promise<boolean>;
|
|
14
|
+
has(key: string): Promise<boolean>;
|
|
15
|
+
getAll(): Promise<Record<string, unknown>>;
|
|
16
|
+
clear(): Promise<void>;
|
|
17
|
+
/**
|
|
18
|
+
* Get the file path used by this store (useful for diagnostics)
|
|
19
|
+
*/
|
|
20
|
+
getFilePath(): string;
|
|
21
|
+
private load;
|
|
22
|
+
private save;
|
|
23
|
+
}
|
|
24
|
+
//# sourceMappingURL=json-state-store.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"json-state-store.d.ts","sourceRoot":"","sources":["../../src/state/json-state-store.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAA;AAErD;;;;GAIG;AACH,qBAAa,cAAe,YAAW,WAAW;IAChD,OAAO,CAAC,QAAQ,CAAQ;IACxB,OAAO,CAAC,IAAI,CAAuC;gBAEvC,QAAQ,CAAC,EAAE,MAAM;IAIvB,GAAG,CAAC,CAAC,GAAG,OAAO,EAAE,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,CAAC,GAAG,SAAS,CAAC;IAKrD,GAAG,CAAC,CAAC,GAAG,OAAO,EAAE,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC;IAMtD,MAAM,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAUrC,GAAG,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAKlC,MAAM,IAAI,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAI1C,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IAK5B;;OAEG;IACH,WAAW,IAAI,MAAM;YAIP,IAAI;YAoBJ,IAAI;CAUnB"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Generic state store interface for persisting application state.
|
|
3
|
+
* Allows different backends: JSON file, SQLite, Postgres, etc.
|
|
4
|
+
*/
|
|
5
|
+
export interface IStateStore {
|
|
6
|
+
/**
|
|
7
|
+
* Get a value by key
|
|
8
|
+
* @param key Dot-notation key (e.g., "auth.token", "events.cursor")
|
|
9
|
+
* @returns The stored value, or undefined if not found
|
|
10
|
+
*/
|
|
11
|
+
get<T = unknown>(key: string): Promise<T | undefined>;
|
|
12
|
+
/**
|
|
13
|
+
* Set a value by key
|
|
14
|
+
* @param key Dot-notation key
|
|
15
|
+
* @param value Value to store
|
|
16
|
+
*/
|
|
17
|
+
set<T = unknown>(key: string, value: T): Promise<void>;
|
|
18
|
+
/**
|
|
19
|
+
* Delete a value by key
|
|
20
|
+
* @param key Dot-notation key
|
|
21
|
+
* @returns true if the key existed and was deleted
|
|
22
|
+
*/
|
|
23
|
+
delete(key: string): Promise<boolean>;
|
|
24
|
+
/**
|
|
25
|
+
* Check if a key exists
|
|
26
|
+
*/
|
|
27
|
+
has(key: string): Promise<boolean>;
|
|
28
|
+
/**
|
|
29
|
+
* Get all stored data as a plain object
|
|
30
|
+
*/
|
|
31
|
+
getAll(): Promise<Record<string, unknown>>;
|
|
32
|
+
/**
|
|
33
|
+
* Clear all stored data
|
|
34
|
+
*/
|
|
35
|
+
clear(): Promise<void>;
|
|
36
|
+
}
|
|
37
|
+
//# sourceMappingURL=state-store.interface.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"state-store.interface.d.ts","sourceRoot":"","sources":["../../src/state/state-store.interface.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,MAAM,WAAW,WAAW;IAC1B;;;;OAIG;IACH,GAAG,CAAC,CAAC,GAAG,OAAO,EAAE,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,CAAC,GAAG,SAAS,CAAC,CAAA;IAErD;;;;OAIG;IACH,GAAG,CAAC,CAAC,GAAG,OAAO,EAAE,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;IAEtD;;;;OAIG;IACH,MAAM,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAAA;IAErC;;OAEG;IACH,GAAG,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAAA;IAElC;;OAEG;IACH,MAAM,IAAI,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAA;IAE1C;;OAEG;IACH,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CAAA;CACvB"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { KeyStorageProvider, KeyStorageConfig } from './key-storage.interface';
|
|
2
|
+
/**
|
|
3
|
+
* Filesystem-based key storage provider
|
|
4
|
+
*/
|
|
5
|
+
export declare class FilesystemKeyStorage implements KeyStorageProvider {
|
|
6
|
+
private keyStorePath;
|
|
7
|
+
constructor(config?: KeyStorageConfig);
|
|
8
|
+
store(id: string, encryptedKey: string): Promise<void>;
|
|
9
|
+
retrieve(id: string): Promise<string | null>;
|
|
10
|
+
delete(id: string): Promise<void>;
|
|
11
|
+
list(): Promise<string[]>;
|
|
12
|
+
isAvailable(): Promise<boolean>;
|
|
13
|
+
private ensureKeyStoreExists;
|
|
14
|
+
private getKeyPath;
|
|
15
|
+
}
|
|
16
|
+
//# sourceMappingURL=filesystem-key-storage.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"filesystem-key-storage.d.ts","sourceRoot":"","sources":["../../src/storage/filesystem-key-storage.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,kBAAkB,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAA;AAE9E;;GAEG;AACH,qBAAa,oBAAqB,YAAW,kBAAkB;IAC7D,OAAO,CAAC,YAAY,CAAQ;gBAEhB,MAAM,CAAC,EAAE,gBAAgB;IAI/B,KAAK,CAAC,EAAE,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAMtD,QAAQ,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC;IAa5C,MAAM,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAYjC,IAAI,IAAI,OAAO,CAAC,MAAM,EAAE,CAAC;IASzB,WAAW,IAAI,OAAO,CAAC,OAAO,CAAC;YASvB,oBAAoB;IAQlC,OAAO,CAAC,UAAU;CAGnB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/storage/index.ts"],"names":[],"mappings":"AAAA,cAAc,yBAAyB,CAAA;AACvC,cAAc,0BAA0B,CAAA;AACxC,cAAc,sBAAsB,CAAA"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Interface for key storage persistence
|
|
3
|
+
* Allows different storage backends (filesystem, database, memory, etc.)
|
|
4
|
+
*/
|
|
5
|
+
export interface KeyStorageProvider {
|
|
6
|
+
/**
|
|
7
|
+
* Store an encrypted key
|
|
8
|
+
* @param id Unique identifier for the key (e.g., DID hash)
|
|
9
|
+
* @param encryptedKey Encrypted key data
|
|
10
|
+
*/
|
|
11
|
+
store(id: string, encryptedKey: string): Promise<void>;
|
|
12
|
+
/**
|
|
13
|
+
* Retrieve an encrypted key
|
|
14
|
+
* @param id Unique identifier for the key
|
|
15
|
+
* @returns Encrypted key data, or null if not found
|
|
16
|
+
*/
|
|
17
|
+
retrieve(id: string): Promise<string | null>;
|
|
18
|
+
/**
|
|
19
|
+
* Delete a key
|
|
20
|
+
* @param id Unique identifier for the key
|
|
21
|
+
*/
|
|
22
|
+
delete(id: string): Promise<void>;
|
|
23
|
+
/**
|
|
24
|
+
* List all stored key identifiers
|
|
25
|
+
* @returns Array of key identifiers
|
|
26
|
+
*/
|
|
27
|
+
list(): Promise<string[]>;
|
|
28
|
+
/**
|
|
29
|
+
* Check if the storage is available and initialized
|
|
30
|
+
*/
|
|
31
|
+
isAvailable(): Promise<boolean>;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Configuration for key storage
|
|
35
|
+
*/
|
|
36
|
+
export interface KeyStorageConfig {
|
|
37
|
+
/** Storage type identifier */
|
|
38
|
+
type: string;
|
|
39
|
+
/** Storage-specific options */
|
|
40
|
+
options?: Record<string, any>;
|
|
41
|
+
}
|
|
42
|
+
//# sourceMappingURL=key-storage.interface.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"key-storage.interface.d.ts","sourceRoot":"","sources":["../../src/storage/key-storage.interface.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,MAAM,WAAW,kBAAkB;IACjC;;;;OAIG;IACH,KAAK,CAAC,EAAE,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;IAEtD;;;;OAIG;IACH,QAAQ,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAAA;IAE5C;;;OAGG;IACH,MAAM,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;IAEjC;;;OAGG;IACH,IAAI,IAAI,OAAO,CAAC,MAAM,EAAE,CAAC,CAAA;IAEzB;;OAEG;IACH,WAAW,IAAI,OAAO,CAAC,OAAO,CAAC,CAAA;CAChC;AAED;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC/B,8BAA8B;IAC9B,IAAI,EAAE,MAAM,CAAA;IACZ,+BAA+B;IAC/B,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAA;CAC9B"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { KeyStorageProvider } from './key-storage.interface';
|
|
2
|
+
/**
|
|
3
|
+
* In-memory key storage provider (for testing)
|
|
4
|
+
*/
|
|
5
|
+
export declare class MemoryKeyStorage implements KeyStorageProvider {
|
|
6
|
+
private keys;
|
|
7
|
+
store(id: string, encryptedKey: string): Promise<void>;
|
|
8
|
+
retrieve(id: string): Promise<string | null>;
|
|
9
|
+
delete(id: string): Promise<void>;
|
|
10
|
+
list(): Promise<string[]>;
|
|
11
|
+
isAvailable(): Promise<boolean>;
|
|
12
|
+
/**
|
|
13
|
+
* Clear all stored keys (for testing)
|
|
14
|
+
*/
|
|
15
|
+
clear(): void;
|
|
16
|
+
}
|
|
17
|
+
//# sourceMappingURL=memory-key-storage.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"memory-key-storage.d.ts","sourceRoot":"","sources":["../../src/storage/memory-key-storage.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAA;AAE5D;;GAEG;AACH,qBAAa,gBAAiB,YAAW,kBAAkB;IACzD,OAAO,CAAC,IAAI,CAAiC;IAEvC,KAAK,CAAC,EAAE,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAItD,QAAQ,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC;IAI5C,MAAM,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAIjC,IAAI,IAAI,OAAO,CAAC,MAAM,EAAE,CAAC;IAIzB,WAAW,IAAI,OAAO,CAAC,OAAO,CAAC;IAIrC;;OAEG;IACH,KAAK,IAAI,IAAI;CAGd"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { ConnectorResponse } from '@vess-id/ai-identity-types';
|
|
2
|
+
import { VPManager } from '../vp/vp-manager';
|
|
3
|
+
export interface ToolDefinition {
|
|
4
|
+
name: string;
|
|
5
|
+
description: string;
|
|
6
|
+
actions: {
|
|
7
|
+
name: string;
|
|
8
|
+
description: string;
|
|
9
|
+
parameters: Record<string, any>;
|
|
10
|
+
}[];
|
|
11
|
+
}
|
|
12
|
+
export declare class ToolManager {
|
|
13
|
+
private vpManager;
|
|
14
|
+
private tools;
|
|
15
|
+
private proxyApiUrl;
|
|
16
|
+
constructor(vpManager?: VPManager);
|
|
17
|
+
/**
|
|
18
|
+
* Invoke a tool action with VC authorization
|
|
19
|
+
*/
|
|
20
|
+
invoke<T = any>(tool: string, action: string, params: Record<string, any>, options: {
|
|
21
|
+
vcs: string[];
|
|
22
|
+
holderDid: string;
|
|
23
|
+
}): Promise<ConnectorResponse<T>>;
|
|
24
|
+
/**
|
|
25
|
+
* List available tools
|
|
26
|
+
*/
|
|
27
|
+
list(): ToolDefinition[];
|
|
28
|
+
/**
|
|
29
|
+
* Get a specific tool definition
|
|
30
|
+
*/
|
|
31
|
+
getTool(name: string): ToolDefinition | undefined;
|
|
32
|
+
/**
|
|
33
|
+
* Register a custom tool
|
|
34
|
+
*/
|
|
35
|
+
registerTool(tool: ToolDefinition): void;
|
|
36
|
+
/**
|
|
37
|
+
* Check if VCs authorize a tool action
|
|
38
|
+
*/
|
|
39
|
+
checkAuthorization(vcs: string[], tool: string, action: string, resourceScope?: Record<string, any>): Promise<boolean>;
|
|
40
|
+
private matchScope;
|
|
41
|
+
private generateChallenge;
|
|
42
|
+
private registerDefaultTools;
|
|
43
|
+
}
|
|
44
|
+
//# sourceMappingURL=tool-manager.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tool-manager.d.ts","sourceRoot":"","sources":["../../src/tool/tool-manager.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAA;AAC9D,OAAO,EAAE,SA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
2
|
+
export interface KeyPair {
|
|
3
|
+
publicKey: any;
|
|
4
|
+
privateKey: any;
|
|
5
|
+
}
|
|
6
|
+
export declare function generateKeyPair(): Promise<KeyPair>;
|
|
7
|
+
export declare function signJWT(payload: any, privateKey: any, options?: {
|
|
8
|
+
issuer?: string;
|
|
9
|
+
audience?: string;
|
|
10
|
+
expiresIn?: string;
|
|
11
|
+
notBefore?: string;
|
|
12
|
+
subject?: string;
|
|
13
|
+
jti?: string;
|
|
14
|
+
}): Promise<string>;
|
|
15
|
+
export declare function verifyJWT(jwt: string, publicKey: any, options?: {
|
|
16
|
+
issuer?: string;
|
|
17
|
+
audience?: string;
|
|
18
|
+
}): Promise<jose.JWTPayload>;
|
|
19
|
+
export declare function generateNonce(): string;
|
|
20
|
+
export declare function getSigner(privateKey: any): Promise<(data: string) => Promise<string>>;
|
|
21
|
+
export declare function getVerifier(publicKey: any): Promise<(data: string, signatureBase64url: string) => Promise<boolean>>;
|
|
22
|
+
//# sourceMappingURL=crypto.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"crypto.d.ts","sourceRoot":"","sources":["../../src/utils/crypto.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,IAAI,MAAM,MAAM,CAAA;AAI5B,MAAM,WAAW,OAAO;IACtB,SAAS,EAAE,GAAG,CAAA;IACd,UAAU,EAAE,GAAG,CAAA;CAChB;AAED,wBAAsB,eAAe,IAAI,OAAO,CAAC,OAAO,CAAC,CA2BxD;AAED,wBAAsB,OAAO,CAC3B,OAAO,EAAE,GAAG,EACZ,UAAU,EAAE,GAAG,EACf,OAAO,CAAC,EAAE;IACR,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,GAAG,CAAC,EAAE,MAAM,CAAA;CACb,GACA,OAAO,CAAC,MAAM,CAAC,CAgBjB;AAED,wBAAsB,SAAS,CAC7B,GAAG,EAAE,MAAM,EACX,SAAS,EAAE,GAAG,EACd,OAAO,CAAC,EAAE;IACR,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,QAAQ,CAAC,EAAE,MAAM,CAAA;CAClB,GACA,OAAO,CAAC,IAAI,CAAC,UAAU,CAAC,CAU1B;AAED,wBAAgB,aAAa,IAAI,MAAM,CAEtC;AAED,wBAAsB,SAAS,CAAC,UAAU,EAAE,GAAG,kBAavB,MAAM,sBAwB7B;AAED,wBAAsB,WAAW,CAAC,SAAS,EAAE,GAAG,kBAY1B,MAAM,sBAAsB,MAAM,uBAmBvD"}
|
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
import { SDJwtVcInstance } from '@sd-jwt/sd-jwt-vc';
|
|
2
|
+
import { KeyManager } from '../did/key-manager';
|
|
3
|
+
import type { DisclosureFrame } from '@sd-jwt/types';
|
|
4
|
+
import type { JWK } from 'jose';
|
|
5
|
+
export declare class SDJwtClient {
|
|
6
|
+
private static instances;
|
|
7
|
+
private static keyManager;
|
|
8
|
+
private static signerCache;
|
|
9
|
+
private static verifierCache;
|
|
10
|
+
private constructor();
|
|
11
|
+
/**
|
|
12
|
+
* Initialize with KeyManager for DID-based key management
|
|
13
|
+
*/
|
|
14
|
+
static setKeyManager(keyManager: KeyManager): void;
|
|
15
|
+
/**
|
|
16
|
+
* Get SDJwtVcInstance for issuer role (VC issuance)
|
|
17
|
+
*/
|
|
18
|
+
static getIssuerInstance(issuerDid: string): Promise<SDJwtVcInstance>;
|
|
19
|
+
/**
|
|
20
|
+
* Get SDJwtVcInstance for holder role (VP presentation)
|
|
21
|
+
*/
|
|
22
|
+
static getHolderInstance(holderDid: string): Promise<SDJwtVcInstance>;
|
|
23
|
+
/**
|
|
24
|
+
* Get SDJwtVcInstance with specified role (backward compatibility)
|
|
25
|
+
*/
|
|
26
|
+
static getSDJwtInstance(did: string, options?: {
|
|
27
|
+
role?: 'issuer' | 'holder';
|
|
28
|
+
}): Promise<SDJwtVcInstance>;
|
|
29
|
+
/**
|
|
30
|
+
* Create a new SDJwtVcInstance with DID-based keys and role
|
|
31
|
+
*/
|
|
32
|
+
private static createInstance;
|
|
33
|
+
/**
|
|
34
|
+
* Create disclosure frame for selective disclosure
|
|
35
|
+
*/
|
|
36
|
+
static createDisclosureFrame<T extends Record<string, any>>(claims: T, selectivelyDisclosable?: string[]): DisclosureFrame<T>;
|
|
37
|
+
/**
|
|
38
|
+
* Issue an SD-JWT with selective disclosure
|
|
39
|
+
*/
|
|
40
|
+
static issueSDJWT(payload: Record<string, any>, _privateKey: any, // Not used since we get key from KeyManager based on issuer DID
|
|
41
|
+
selectiveDisclosureFields?: string[]): Promise<string>;
|
|
42
|
+
/**
|
|
43
|
+
* Verify an SD-JWT
|
|
44
|
+
*/
|
|
45
|
+
static verifySDJWT(credential: string): Promise<{
|
|
46
|
+
valid: boolean;
|
|
47
|
+
payload?: any;
|
|
48
|
+
error?: string;
|
|
49
|
+
}>;
|
|
50
|
+
/**
|
|
51
|
+
* Legacy methods for backward compatibility
|
|
52
|
+
*/
|
|
53
|
+
static createSignerVerifier(): Promise<{
|
|
54
|
+
signer: (data: string) => Promise<string>;
|
|
55
|
+
verifier: (data: string, signatureBase64url: string) => Promise<boolean>;
|
|
56
|
+
}>;
|
|
57
|
+
static generateKeyPair(): Promise<import("./crypto").KeyPair>;
|
|
58
|
+
/**
|
|
59
|
+
* Clear caches for optimization
|
|
60
|
+
*/
|
|
61
|
+
static clearCaches(): void;
|
|
62
|
+
/**
|
|
63
|
+
* Clear cache for specific issuer
|
|
64
|
+
*/
|
|
65
|
+
static clearIssuerCache(issuerDid: string): void;
|
|
66
|
+
/**
|
|
67
|
+
* Get cache statistics
|
|
68
|
+
*/
|
|
69
|
+
static getCacheStats(): {
|
|
70
|
+
instanceCount: number;
|
|
71
|
+
signerCount: number;
|
|
72
|
+
verifierCount: number;
|
|
73
|
+
};
|
|
74
|
+
/**
|
|
75
|
+
* Create a verifier function from an external public key
|
|
76
|
+
* This is used for verifying SD-JWTs when you don't have the private key
|
|
77
|
+
* (e.g., API side verifying credentials issued by MCP)
|
|
78
|
+
*/
|
|
79
|
+
private static getVerifierFromPublicKey;
|
|
80
|
+
/**
|
|
81
|
+
* Get SDJwtVcInstance for verification with an external public key
|
|
82
|
+
* Used when verifying credentials without having the issuer's private key
|
|
83
|
+
*/
|
|
84
|
+
private static getVerificationInstance;
|
|
85
|
+
/**
|
|
86
|
+
* Get SDJwtVcInstance for decoding without verification
|
|
87
|
+
*/
|
|
88
|
+
private static getDecodingInstance;
|
|
89
|
+
/**
|
|
90
|
+
* Verify an SD-JWT with an external public key
|
|
91
|
+
* Use this when you have the issuer's public key but not their private key
|
|
92
|
+
*
|
|
93
|
+
* @param credential - The SD-JWT credential string
|
|
94
|
+
* @param publicKey - The issuer's public key (JWK format)
|
|
95
|
+
* @returns Verification result with valid flag and payload
|
|
96
|
+
*
|
|
97
|
+
* @example
|
|
98
|
+
* ```typescript
|
|
99
|
+
* const publicKey = extractPublicKeyFromDid(issuerDid)
|
|
100
|
+
* const result = await SDJwtClient.verifyWithExternalKey(credential, publicKey)
|
|
101
|
+
* if (result.valid) {
|
|
102
|
+
* console.log('Verified claims:', result.payload.claims)
|
|
103
|
+
* }
|
|
104
|
+
* ```
|
|
105
|
+
*/
|
|
106
|
+
static verifyWithExternalKey(credential: string, publicKey: JWK): Promise<{
|
|
107
|
+
valid: boolean;
|
|
108
|
+
payload?: any;
|
|
109
|
+
claims?: any;
|
|
110
|
+
error?: string;
|
|
111
|
+
}>;
|
|
112
|
+
/**
|
|
113
|
+
* Verify an SD-JWT by extracting the issuer's public key from the DID
|
|
114
|
+
* Automatically resolves did:jwk DIDs
|
|
115
|
+
*
|
|
116
|
+
* @param credential - The SD-JWT credential string
|
|
117
|
+
* @returns Verification result with valid flag and payload
|
|
118
|
+
*
|
|
119
|
+
* @example
|
|
120
|
+
* ```typescript
|
|
121
|
+
* const result = await SDJwtClient.verifyWithIssuerDid(credential)
|
|
122
|
+
* if (result.valid) {
|
|
123
|
+
* console.log('Issuer:', result.payload.iss)
|
|
124
|
+
* }
|
|
125
|
+
* ```
|
|
126
|
+
*/
|
|
127
|
+
static verifyWithIssuerDid(credential: string): Promise<{
|
|
128
|
+
valid: boolean;
|
|
129
|
+
payload?: any;
|
|
130
|
+
claims?: any;
|
|
131
|
+
issuerDid?: string;
|
|
132
|
+
error?: string;
|
|
133
|
+
}>;
|
|
134
|
+
/**
|
|
135
|
+
* Decode an SD-JWT without verification
|
|
136
|
+
* Use this when you need to inspect the credential before verification
|
|
137
|
+
* or when you don't have the issuer's public key
|
|
138
|
+
*
|
|
139
|
+
* WARNING: The returned payload has not been verified!
|
|
140
|
+
* Only use this for inspection purposes, not for authorization decisions.
|
|
141
|
+
*
|
|
142
|
+
* @param credential - The SD-JWT credential string
|
|
143
|
+
* @returns Decoded JWT payload, header, and disclosures
|
|
144
|
+
*
|
|
145
|
+
* @example
|
|
146
|
+
* ```typescript
|
|
147
|
+
* const decoded = await SDJwtClient.decodeWithoutVerification(credential)
|
|
148
|
+
* console.log('Issuer (unverified):', decoded.payload?.iss)
|
|
149
|
+
* console.log('Disclosures:', decoded.disclosures?.length)
|
|
150
|
+
* ```
|
|
151
|
+
*/
|
|
152
|
+
static decodeWithoutVerification(credential: string): Promise<{
|
|
153
|
+
payload?: any;
|
|
154
|
+
header?: any;
|
|
155
|
+
disclosures?: any[];
|
|
156
|
+
claims?: any;
|
|
157
|
+
error?: string;
|
|
158
|
+
}>;
|
|
159
|
+
/**
|
|
160
|
+
* Extract issuer DID from an SD-JWT without verification
|
|
161
|
+
* Useful for determining the issuer before verification
|
|
162
|
+
*
|
|
163
|
+
* @param credential - The SD-JWT credential string
|
|
164
|
+
* @returns The issuer DID or null if not found
|
|
165
|
+
*/
|
|
166
|
+
static extractIssuerDid(credential: string): string | null;
|
|
167
|
+
}
|
|
168
|
+
//# sour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