@vess-id/ai-identity 0.3.0 → 0.3.1
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 +350 -45
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +350 -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,50 @@
|
|
|
1
|
+
import { KeyManager } from '../did/key-manager';
|
|
2
|
+
/**
|
|
3
|
+
* Agent DID Manager
|
|
4
|
+
* Manages DID generation and lifecycle for AI Agents specifically
|
|
5
|
+
*/
|
|
6
|
+
export declare class AgentDIDManager {
|
|
7
|
+
private keyManager;
|
|
8
|
+
private agentDIDMap;
|
|
9
|
+
constructor(keyManager?: KeyManager);
|
|
10
|
+
/**
|
|
11
|
+
* Generate a new DID for an AI Agent
|
|
12
|
+
*/
|
|
13
|
+
generateAgentDID(agentId: string): Promise<string>;
|
|
14
|
+
/**
|
|
15
|
+
* Get DID for a specific agent
|
|
16
|
+
*/
|
|
17
|
+
getAgentDID(agentId: string): Promise<string>;
|
|
18
|
+
/**
|
|
19
|
+
* Check if agent has a DID
|
|
20
|
+
*/
|
|
21
|
+
hasAgentDID(agentId: string): Promise<boolean>;
|
|
22
|
+
/**
|
|
23
|
+
* Get agent's key pair
|
|
24
|
+
*/
|
|
25
|
+
getAgentKeyPair(agentId: string): Promise<any>;
|
|
26
|
+
/**
|
|
27
|
+
* Delete agent DID and associated keys
|
|
28
|
+
*/
|
|
29
|
+
deleteAgentDID(agentId: string): Promise<void>;
|
|
30
|
+
/**
|
|
31
|
+
* List all agent DIDs
|
|
32
|
+
*/
|
|
33
|
+
listAgentDIDs(): Promise<Array<{
|
|
34
|
+
agentId: string;
|
|
35
|
+
did: string;
|
|
36
|
+
}>>;
|
|
37
|
+
/**
|
|
38
|
+
* Save agent ID -> DID mapping to persistent storage
|
|
39
|
+
*/
|
|
40
|
+
private saveAgentDIDMapping;
|
|
41
|
+
/**
|
|
42
|
+
* Load agent ID -> DID mapping from persistent storage
|
|
43
|
+
*/
|
|
44
|
+
private loadAgentDIDMapping;
|
|
45
|
+
/**
|
|
46
|
+
* Delete agent ID -> DID mapping from persistent storage
|
|
47
|
+
*/
|
|
48
|
+
private deleteAgentDIDMapping;
|
|
49
|
+
}
|
|
50
|
+
//# sourceMappingURL=agent-did-manager.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agent-did-manager.d.ts","sourceRoot":"","sources":["../../src/agent/agent-did-manager.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAA;AAI/C;;;GAGG;AACH,qBAAa,eAAe;IAC1B,OAAO,CAAC,UAAU,CAAY;IAC9B,OAAO,CAAC,WAAW,CAAiC;gBAExC,UAAU,CAAC,EAAE,UAAU;IAInC;;OAEG;IACG,gBAAgB,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAiBxD;;OAEG;IACG,WAAW,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAgBnD;;OAEG;IACG,WAAW,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IASpD;;OAEG;IACG,eAAe,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC;IAcpD;;OAEG;IACG,cAAc,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAiBpD;;OAEG;IACG,aAAa,IAAI,OAAO,CAAC,KAAK,CAAC;QAAE,OAAO,EAAE,MAAM,CAAC;QAAC,GAAG,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IA8BvE;;OAEG;YACW,mBAAmB;IAYjC;;OAEG;YACW,mBAAmB;IAcjC;;OAEG;YACW,qBAAqB;CAapC"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { IStateStore } from '../state/state-store.interface';
|
|
2
|
+
import { GatewayClient, ApiKeyValidationResult } from '../gateway/gateway-client';
|
|
3
|
+
/**
|
|
4
|
+
* Authentication state persisted in the StateStore
|
|
5
|
+
*/
|
|
6
|
+
export interface AuthState {
|
|
7
|
+
apiKey: string;
|
|
8
|
+
apiUrl: string;
|
|
9
|
+
userId?: string;
|
|
10
|
+
projectId?: string;
|
|
11
|
+
scopes?: string[];
|
|
12
|
+
authenticatedAt: string;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Authentication provider that validates API keys and persists auth state.
|
|
16
|
+
* Used by CLI and MCP to authenticate against the Gateway API.
|
|
17
|
+
*/
|
|
18
|
+
export declare class AuthProvider {
|
|
19
|
+
private stateStore;
|
|
20
|
+
private gatewayClient;
|
|
21
|
+
constructor(stateStore: IStateStore, gatewayClient: GatewayClient);
|
|
22
|
+
/**
|
|
23
|
+
* Authenticate with an API key. Validates against the Gateway and
|
|
24
|
+
* persists the result in the StateStore.
|
|
25
|
+
*
|
|
26
|
+
* @returns The validation result
|
|
27
|
+
*/
|
|
28
|
+
login(apiKey: string, apiUrl: string, projectId?: string): Promise<ApiKeyValidationResult>;
|
|
29
|
+
/**
|
|
30
|
+
* Get the current auth state from the StateStore.
|
|
31
|
+
* Returns undefined if not authenticated.
|
|
32
|
+
*/
|
|
33
|
+
getAuthState(): Promise<AuthState | undefined>;
|
|
34
|
+
/**
|
|
35
|
+
* Check if we have stored auth credentials
|
|
36
|
+
*/
|
|
37
|
+
isAuthenticated(): Promise<boolean>;
|
|
38
|
+
/**
|
|
39
|
+
* Clear auth state (logout)
|
|
40
|
+
*/
|
|
41
|
+
logout(): Promise<void>;
|
|
42
|
+
/**
|
|
43
|
+
* Get the stored API key, or undefined if not authenticated
|
|
44
|
+
*/
|
|
45
|
+
getApiKey(): Promise<string | undefined>;
|
|
46
|
+
/**
|
|
47
|
+
* Get the stored API URL, or undefined if not authenticated
|
|
48
|
+
*/
|
|
49
|
+
getApiUrl(): Promise<string | undefined>;
|
|
50
|
+
}
|
|
51
|
+
//# sourceMappingURL=auth-provider.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"auth-provider.d.ts","sourceRoot":"","sources":["../../src/auth/auth-provider.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,gCAAgC,CAAA;AAC5D,OAAO,EAAE,aAAa,EAAE,sBAAsB,EAAE,MAAM,2BAA2B,CAAA;AAEjF;;GAEG;AACH,MAAM,WAAW,SAAS;IACxB,MAAM,EAAE,MAAM,CAAA;IACd,MAAM,EAAE,MAAM,CAAA;IACd,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,MAAM,CAAC,EAAE,MAAM,EAAE,CAAA;IACjB,eAAe,EAAE,MAAM,CAAA;CACxB;AAED;;;GAGG;AACH,qBAAa,YAAY;IACvB,OAAO,CAAC,UAAU,CAAa;IAC/B,OAAO,CAAC,aAAa,CAAe;gBAExB,UAAU,EAAE,WAAW,EAAE,aAAa,EAAE,aAAa;IAKjE;;;;;OAKG;IACG,KAAK,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,SAAS,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,sBAAsB,CAAC;IAkBhG;;;OAGG;IACG,YAAY,IAAI,OAAO,CAAC,SAAS,GAAG,SAAS,CAAC;IAIpD;;OAEG;IACG,eAAe,IAAI,OAAO,CAAC,OAAO,CAAC;IAKzC;;OAEG;IACG,MAAM,IAAI,OAAO,CAAC,IAAI,CAAC;IAI7B;;OAEG;IACG,SAAS,IAAI,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC;IAK9C;;OAEG;IACG,SAAS,IAAI,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC;CAI/C"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/auth/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAA"}
|
package/dist/client.d.ts
ADDED
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { AIdentityConfig } from './config';
|
|
2
|
+
import { AgentManager } from './did/agent';
|
|
3
|
+
import { UserIdentityManager } from './identity/user-identity-manager';
|
|
4
|
+
import { VCManager } from './vc/vc-manager';
|
|
5
|
+
import { VPManager } from './vp/vp-manager';
|
|
6
|
+
import { ToolManager } from './tool/tool-manager';
|
|
7
|
+
import { MemoryManager } from './memory/memory-manager';
|
|
8
|
+
import { OrganizationManager } from './organization/organization-manager';
|
|
9
|
+
import { GrantManager } from './grant/grant-manager';
|
|
10
|
+
import { Agent, ConnectorResponse } from '@vess-id/ai-identity-types';
|
|
11
|
+
export declare class AIdentityClient {
|
|
12
|
+
readonly agent: AgentManager;
|
|
13
|
+
readonly user: UserIdentityManager;
|
|
14
|
+
readonly vc: VCManager;
|
|
15
|
+
readonly vp: VPManager;
|
|
16
|
+
readonly tool: ToolManager;
|
|
17
|
+
readonly memory: MemoryManager;
|
|
18
|
+
readonly organization: OrganizationManager;
|
|
19
|
+
readonly grant: GrantManager;
|
|
20
|
+
private keyManager;
|
|
21
|
+
private currentAgent?;
|
|
22
|
+
constructor(config?: AIdentityConfig, password?: string);
|
|
23
|
+
/**
|
|
24
|
+
* Quick setup: Create or load an agent
|
|
25
|
+
*/
|
|
26
|
+
setup(did?: string): Promise<Agent>;
|
|
27
|
+
/**
|
|
28
|
+
* Get current agent
|
|
29
|
+
*/
|
|
30
|
+
getCurrentAgent(): Agent | undefined;
|
|
31
|
+
/**
|
|
32
|
+
* Get current user DID
|
|
33
|
+
*/
|
|
34
|
+
getCurrentUserDID(): Promise<string>;
|
|
35
|
+
/**
|
|
36
|
+
* Create or reset user identity
|
|
37
|
+
*/
|
|
38
|
+
resetUserIdentity(): Promise<string>;
|
|
39
|
+
/**
|
|
40
|
+
* Issue a VC for tool permission
|
|
41
|
+
* Enhanced to support User → Agent delegation pattern
|
|
42
|
+
*/
|
|
43
|
+
issueToolPermission(tool: string, action: string, options: {
|
|
44
|
+
subjectDid?: string;
|
|
45
|
+
agentId?: string;
|
|
46
|
+
issuerDid?: string;
|
|
47
|
+
resourceScope?: Record<string, any>;
|
|
48
|
+
expiresIn?: string;
|
|
49
|
+
}): Promise<string>;
|
|
50
|
+
/**
|
|
51
|
+
* Issue a VC for data access
|
|
52
|
+
* Enhanced to support User → Agent delegation pattern
|
|
53
|
+
*/
|
|
54
|
+
issueDataAccess(resource: string, actions: ('read' | 'write' | 'delete')[], options: {
|
|
55
|
+
subjectDid?: string;
|
|
56
|
+
agentId?: string;
|
|
57
|
+
issuerDid?: string;
|
|
58
|
+
expiresIn?: string;
|
|
59
|
+
}): Promise<string>;
|
|
60
|
+
/**
|
|
61
|
+
* Invoke a tool with automatic VP creation
|
|
62
|
+
*/
|
|
63
|
+
invokeTool<T = any>(tool: string, action: string, params: Record<string, any>, vcs: string[]): Promise<ConnectorResponse<T>>;
|
|
64
|
+
/**
|
|
65
|
+
* Write to memory with automatic VP creation
|
|
66
|
+
*/
|
|
67
|
+
writeMemory(content: string, namespace: string, vcs: string[], metadata?: Record<string, any>): Promise<import("./memory/memory-manager").MemoryDocument>;
|
|
68
|
+
/**
|
|
69
|
+
* Query memory with automatic VP creation
|
|
70
|
+
*/
|
|
71
|
+
queryMemory(query: string, vcs: string[], options?: {
|
|
72
|
+
namespace?: string;
|
|
73
|
+
limit?: number;
|
|
74
|
+
filter?: Record<string, any>;
|
|
75
|
+
}): Promise<import("./memory/memory-manager").MemoryQueryResult>;
|
|
76
|
+
}
|
|
77
|
+
export declare function getClient(config?: AIdentityConfig, password?: string): AIdentityClient;
|
|
78
|
+
export * from '@vess-id/ai-identity-types';
|
|
79
|
+
export { configure, AIdentityConfig } from './config';
|
|
80
|
+
//# sourceMappingURL=client.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAa,MAAM,UAAU,CAAA;AACrD,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAE1C,OAAO,EAAE,mBAAmB,EAAE,MAAM,kCAAkC,CAAA;AACtE,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAA;AAC3C,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAA;AAC3C,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAA;AACjD,OAAO,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAA;AACvD,OAAO,EAAE,mBAAmB,EAAE,MAAM,qCAAqC,CAAA;AACzE,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAA;AACpD,OAAO,EACL,KAAK,EACL,iBAAiB,EAClB,MAAM,4BAA4B,CAAA;AAEnC,qBAAa,eAAe;IAC1B,SAAgB,KAAK,EAAE,YAAY,CAAA;IACnC,SAAgB,IAAI,EAAE,mBAAmB,CAAA;IACzC,SAAgB,EAAE,EAAE,SAAS,CAAA;IAC7B,SAAgB,EAAE,EAAE,SAAS,CAAA;IAC7B,SAAgB,IAAI,EAAE,WAAW,CAAA;IACjC,SAAgB,MAAM,EAAE,aAAa,CAAA;IACrC,SAAgB,YAAY,EAAE,mBAAmB,CAAA;IACjD,SAAgB,KAAK,EAAE,YAAY,CAAA;IAEnC,OAAO,CAAC,UAAU,CAAY;IAC9B,OAAO,CAAC,YAAY,CAAC,CAAO;gBAEhB,MAAM,CAAC,EAAE,eAAe,EAAE,QAAQ,CAAC,EAAE,MAAM;IAmBvD;;OAEG;IACG,KAAK,CAAC,GAAG,CA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AC,MAAM,EAAE,GAAG,CAAC;IAehC;;OAEG;IACG,WAAW,CACf,KAAK,EAAE,MAAM,EACb,GAAG,EAAE,MAAM,EAAE,EACb,OAAO,CAAC,EAAE;QACR,SAAS,CAAC,EAAE,MAAM,CAAA;QAClB,KAAK,CAAC,EAAE,MAAM,CAAA;QACd,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAA;KAC7B;CAaJ;AAKD,wBAAgB,SAAS,CAAC,MAAM,CAAC,EAAE,eAAe,EAAE,QAAQ,CAAC,EAAE,MAAM,GAAG,eAAe,CAKtF;AAGD,cAAc,4BAA4B,CAAA;AAC1C,OAAO,EAAE,SAAS,EAAE,eAAe,EAAE,MAAM,UAAU,CAAA"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
export interface AIdentityConfig {
|
|
2
|
+
didApi?: {
|
|
3
|
+
baseUrl: string;
|
|
4
|
+
apiKey?: string;
|
|
5
|
+
bearerToken?: string;
|
|
6
|
+
};
|
|
7
|
+
issuerApi?: {
|
|
8
|
+
baseUrl: string;
|
|
9
|
+
apiKey?: string;
|
|
10
|
+
bearerToken?: string;
|
|
11
|
+
};
|
|
12
|
+
verifierApi?: {
|
|
13
|
+
baseUrl: string;
|
|
14
|
+
apiKey?: string;
|
|
15
|
+
bearerToken?: string;
|
|
16
|
+
};
|
|
17
|
+
proxyApi?: {
|
|
18
|
+
baseUrl: string;
|
|
19
|
+
};
|
|
20
|
+
storage?: {
|
|
21
|
+
keyStorePath?: string;
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
export declare function configure(config: AIdentityConfig): void;
|
|
25
|
+
export declare function getConfig(): AIdentityConfig;
|
|
26
|
+
export declare function getDidApiUrl(path: string): string;
|
|
27
|
+
export declare function getIssuerApiUrl(path: string): string;
|
|
28
|
+
export declare function getVerifierApiUrl(path: string): string;
|
|
29
|
+
export declare function getApiHeaders(apiType: 'did' | 'issuer' | 'verifier'): any;
|
|
30
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/config/index.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,eAAe;IAC9B,MAAM,CAAC,EAAE;QACP,OAAO,EAAE,MAAM,CAAA;QACf,MAAM,CAAC,EAAE,MAAM,CAAA;QACf,WAAW,CAAC,EAAE,MAAM,CAAA;KACrB,CAAA;IACD,SAAS,CAAC,EAAE;QACV,OAAO,EAAE,MAAM,CAAA;QACf,MAAM,CAAC,EAAE,MAAM,CAAA;QACf,WAAW,CAAC,EAAE,MAAM,CAAA;KACrB,CAAA;IACD,WAAW,CAAC,EAAE;QACZ,OAAO,EAAE,MAAM,CAAA;QACf,MAAM,CAAC,EAAE,MAAM,CAAA;QACf,WAAW,CAAC,EAAE,MAAM,CAAA;KACrB,CAAA;IACD,QAAQ,CAAC,EAAE;QACT,OAAO,EAAE,MAAM,CAAA;KAChB,CAAA;IACD,OAAO,CAAC,EAAE;QACR,YAAY,CAAC,EAAE,MAAM,CAAA;KACtB,CAAA;CACF;AAID,wBAAgB,SAAS,CAAC,MAAM,EAAE,eAAe,GAAG,IAAI,CAEvD;AAED,wBAAgB,SAAS,IAAI,eAAe,CAE3C;AAED,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAMjD;AAED,wBAAgB,eAAe,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAMpD;AAED,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAMtD;AAED,wBAAgB,aAAa,CAAC,OAAO,EAAE,KAAK,GAAG,QAAQ,GAAG,UAAU,GAAG,GAAG,CA+BzE"}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { GrantConstraints, TimeWindowConstraint, EvaluationContext } from '@vess-id/ai-identity-types';
|
|
2
|
+
export declare const mockExecutorDid = "did:key:z6MkiY62766b1LJkExWMsM3QG4WtX23zJpRgVLwZBKQhyt6d";
|
|
3
|
+
/**
|
|
4
|
+
* Create mock time window constraint
|
|
5
|
+
*/
|
|
6
|
+
export declare const createMockTimeWindow: (overrides?: Partial<TimeWindowConstraint>) => TimeWindowConstraint;
|
|
7
|
+
/**
|
|
8
|
+
* Create mock constraints
|
|
9
|
+
*/
|
|
10
|
+
export declare const createMockConstraints: (overrides?: Partial<GrantConstraints>) => GrantConstraints;
|
|
11
|
+
/**
|
|
12
|
+
* Create mock evaluation context
|
|
13
|
+
*/
|
|
14
|
+
export declare const createMockContext: (overrides?: Partial<EvaluationContext>) => EvaluationContext;
|
|
15
|
+
/**
|
|
16
|
+
* Create constraints that should pass all checks
|
|
17
|
+
*/
|
|
18
|
+
export declare const createPassingConstraints: () => GrantConstraints;
|
|
19
|
+
/**
|
|
20
|
+
* Create constraints that should fail time window check
|
|
21
|
+
*/
|
|
22
|
+
export declare const createFailingTimeWindowConstraints: () => GrantConstraints;
|
|
23
|
+
/**
|
|
24
|
+
* Create constraints that should fail invocation limit
|
|
25
|
+
*/
|
|
26
|
+
export declare const createExhaustedConstraints: () => GrantConstraints;
|
|
27
|
+
/**
|
|
28
|
+
* Create constraints that should fail IP check
|
|
29
|
+
*/
|
|
30
|
+
export declare const createRestrictedIpConstraints: () => GrantConstraints;
|
|
31
|
+
/**
|
|
32
|
+
* Create overnight time window (e.g., 22:00-06:00)
|
|
33
|
+
*/
|
|
34
|
+
export declare const createOvernightTimeWindow: () => TimeWindowConstraint;
|
|
35
|
+
/**
|
|
36
|
+
* Test IPs for various scenarios
|
|
37
|
+
*/
|
|
38
|
+
export declare const testIps: {
|
|
39
|
+
inRange192: string;
|
|
40
|
+
inRange10: string;
|
|
41
|
+
outOfRange: string;
|
|
42
|
+
localhost: string;
|
|
43
|
+
ipv6Localhost: string;
|
|
44
|
+
ipv6Public: string;
|
|
45
|
+
};
|
|
46
|
+
/**
|
|
47
|
+
* Test timestamps for various scenarios
|
|
48
|
+
*/
|
|
49
|
+
export declare const createTestTimestamps: () => {
|
|
50
|
+
weekdayMorning: Date;
|
|
51
|
+
weekdayEvening: Date;
|
|
52
|
+
weekendMorning: Date;
|
|
53
|
+
midnight: Date;
|
|
54
|
+
now: Date;
|
|
55
|
+
};
|
|
56
|
+
//# sourceMappingURL=constraint.fixtures.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constraint.fixtures.d.ts","sourceRoot":"","sources":["../../../../src/constraint/__tests__/fixtures/constraint.fixtures.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,gBAAgB,EAChB,oBAAoB,EACpB,iBAAiB,EAClB,MAAM,4BAA4B,CAAA;AAGnC,eAAO,MAAM,eAAe,6DAA6D,CAAA;AAEzF;;GAEG;AACH,eAAO,MAAM,oBAAoB,GAAI,YAAW,OAAO,CAAC,oBAAoB,CAAM,KAAG,oBAMnF,CAAA;AAEF;;GAEG;AACH,eAAO,MAAM,qBAAqB,GAAI,YAAW,OAAO,CAAC,gBAAgB,CAAM,KAAG,gBAOhF,CAAA;AAEF;;GAEG;AACH,eAAO,MAAM,iBAAiB,GAAI,YAAW,OAAO,CAAC,iBAAiB,CAAM,KAAG,iBAc7E,CAAA;AAEF;;GAEG;AACH,eAAO,MAAM,wBAAwB,QAAO,gBAW1C,CAAA;AAEF;;GAEG;AACH,eAAO,MAAM,kCAAkC,QAAO,gBAOpD,CAAA;AAEF;;GAEG;AACH,eAAO,MAAM,0BAA0B,QAAO,gBAE5C,CAAA;AAEF;;GAEG;AACH,eAAO,MAAM,6BAA6B,QAAO,gBAE/C,CAAA;AAEF;;GAEG;AACH,eAAO,MAAM,yBAAyB,QAAO,oBAK3C,CAAA;AAEF;;GAEG;AACH,eAAO,MAAM,OAAO;;;;;;;CAOnB,CAAA;AAED;;GAEG;AACH,eAAO,MAAM,oBAAoB;;;;;;CAchC,CAAA"}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ConstraintEvaluator
|
|
3
|
+
* Grant制約の評価ロジック
|
|
4
|
+
*/
|
|
5
|
+
import { GrantConstraints, TimeWindowConstraint, EvaluationContext, ConstraintEvaluationResult, ConstraintViolation, ConstraintWarning } from '@vess-id/ai-identity-types';
|
|
6
|
+
export interface ConstraintEvaluatorOptions {
|
|
7
|
+
/** 警告を発する残り実行回数の閾値 */
|
|
8
|
+
invocationWarningThreshold?: number;
|
|
9
|
+
/** 警告を発するリスクスコアの閾値(riskThresholdに対する割合) */
|
|
10
|
+
riskWarningRatio?: number;
|
|
11
|
+
/** デフォルトタイムゾーン */
|
|
12
|
+
defaultTimezone?: string;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* 制約評価クラス
|
|
16
|
+
*/
|
|
17
|
+
export declare class ConstraintEvaluator {
|
|
18
|
+
private options;
|
|
19
|
+
constructor(options?: Partial<ConstraintEvaluatorOptions>);
|
|
20
|
+
/**
|
|
21
|
+
* 制約を総合評価
|
|
22
|
+
*/
|
|
23
|
+
evaluate(constraints: GrantConstraints, context: EvaluationContext, currentInvocations: number, expiresAt?: Date): ConstraintEvaluationResult;
|
|
24
|
+
/**
|
|
25
|
+
* 期限チェック
|
|
26
|
+
*/
|
|
27
|
+
checkExpiration(grantExpiresAt?: Date, constraintExpiresAt?: string): {
|
|
28
|
+
violation?: ConstraintViolation;
|
|
29
|
+
};
|
|
30
|
+
/**
|
|
31
|
+
* 実行回数チェック
|
|
32
|
+
*/
|
|
33
|
+
checkInvocationLimit(maxInvocations?: number, currentInvocations?: number): {
|
|
34
|
+
violation?: ConstraintViolation;
|
|
35
|
+
warning?: ConstraintWarning;
|
|
36
|
+
};
|
|
37
|
+
/**
|
|
38
|
+
* 時間帯チェック
|
|
39
|
+
*/
|
|
40
|
+
checkTimeWindow(timeWindow: TimeWindowConstraint, currentTime: Date): {
|
|
41
|
+
violation?: ConstraintViolation;
|
|
42
|
+
warning?: ConstraintWarning;
|
|
43
|
+
};
|
|
44
|
+
/**
|
|
45
|
+
* IPアドレスチェック
|
|
46
|
+
*/
|
|
47
|
+
checkIpAllowlist(allowlist: string[], ipAddress: string): {
|
|
48
|
+
violation?: ConstraintViolation;
|
|
49
|
+
};
|
|
50
|
+
/**
|
|
51
|
+
* リスクスコアチェック
|
|
52
|
+
*/
|
|
53
|
+
checkRiskThreshold(threshold: number, currentScore: number): {
|
|
54
|
+
violation?: ConstraintViolation;
|
|
55
|
+
warning?: ConstraintWarning;
|
|
56
|
+
};
|
|
57
|
+
private getDayOfWeekInTimezone;
|
|
58
|
+
private getTimeInTimezone;
|
|
59
|
+
private getDayName;
|
|
60
|
+
private timeToMinutes;
|
|
61
|
+
private isIpInCidr;
|
|
62
|
+
private ipToNumber;
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* デフォルトのConstraintEvaluatorインスタンス
|
|
66
|
+
*/
|
|
67
|
+
export declare const defaultConstraintEvaluator: ConstraintEvaluator;
|
|
68
|
+
/**
|
|
69
|
+
* 簡易評価関数
|
|
70
|
+
*/
|
|
71
|
+
export declare function evaluateConstraints(constraints: GrantConstraints, context: EvaluationContext, currentInvocations: number, expiresAt?: Date): ConstraintEvaluationResult;
|
|
72
|
+
//# sourceMappingURL=constraint-evaluator.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constraint-evaluator.d.ts","sourceRoot":"","sources":["../../src/constraint/constraint-evaluator.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EACL,gBAAgB,EAChB,oBAAoB,EACpB,iBAAiB,EACjB,0BAA0B,EAC1B,mBAAmB,EACnB,iBAAiB,EAClB,MAAM,4BAA4B,CAAA;AAEnC,MAAM,WAAW,0BAA0B;IACzC,sBAAsB;IACtB,0BAA0B,CAAC,EAAE,MAAM,CAAA;IACnC,2CAA2C;IAC3C,gBAAgB,CAAC,EAAE,MAAM,CAAA;IACzB,kBAAkB;IAClB,eAAe,CAAC,EAAE,MAAM,CAAA;CACzB;AAQD;;GAEG;AACH,qBAAa,mBAAm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AAA;AAEnE;;GAEG;AACH,wBAAgB,mBAAmB,CACjC,WAAW,EAAE,gBAAgB,EAC7B,OAAO,EAAE,iBAAiB,EAC1B,kBAAkB,EAAE,MAAM,EAC1B,SAAS,CAAC,EAAE,IAAI,GACf,0BAA0B,CAE5B"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/constraint/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EACL,mBAAmB,EACnB,0BAA0B,EAC1B,0BAA0B,EAC1B,mBAAmB,EACpB,MAAM,wBAAwB,CAAA"}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { Agent, DIDDocument } from '@vess-id/ai-identity-types';
|
|
2
|
+
import { KeyManager } from './key-manager';
|
|
3
|
+
export declare class AgentManager {
|
|
4
|
+
private keyManager;
|
|
5
|
+
private agentDIDManager;
|
|
6
|
+
constructor(keyManager?: KeyManager);
|
|
7
|
+
/**
|
|
8
|
+
* Create a new AI agent with unique ID and DID
|
|
9
|
+
*/
|
|
10
|
+
create(metadata?: Record<string, any>): Promise<Agent & {
|
|
11
|
+
id: string;
|
|
12
|
+
}>;
|
|
13
|
+
/**
|
|
14
|
+
* Get agent DID by agent ID
|
|
15
|
+
*/
|
|
16
|
+
getAgentDID(agentId: string): Promise<string>;
|
|
17
|
+
/**
|
|
18
|
+
* Get agent by ID
|
|
19
|
+
*/
|
|
20
|
+
getAgent(agentId: string): Promise<Agent & {
|
|
21
|
+
id: string;
|
|
22
|
+
}>;
|
|
23
|
+
/**
|
|
24
|
+
* Delete an agent and its DID
|
|
25
|
+
*/
|
|
26
|
+
deleteAgent(agentId: string): Promise<void>;
|
|
27
|
+
/**
|
|
28
|
+
* Resolve a DID to get DID Document
|
|
29
|
+
*/
|
|
30
|
+
resolve(did: string): Promise<DIDDocument>;
|
|
31
|
+
/**
|
|
32
|
+
* Export agent with private key (for backup)
|
|
33
|
+
*/
|
|
34
|
+
export(did: string): Promise<{
|
|
35
|
+
agent: Agent;
|
|
36
|
+
privateKey: any;
|
|
37
|
+
}>;
|
|
38
|
+
/**
|
|
39
|
+
* Import agent from backup
|
|
40
|
+
*/
|
|
41
|
+
import(agent: Agent, privateKey: any): Promise<void>;
|
|
42
|
+
/**
|
|
43
|
+
* List all locally stored agents
|
|
44
|
+
*/
|
|
45
|
+
list(): Promise<Array<Agent & {
|
|
46
|
+
id: string;
|
|
47
|
+
}>>;
|
|
48
|
+
private createDidDocument;
|
|
49
|
+
private resolveDidJwkLocally;
|
|
50
|
+
private registerDid;
|
|
51
|
+
}
|
|
52
|
+
//# sourceMappingURL=agent.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agent.d.ts","sourceRoot":"","sources":["../../src/did/agent.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAA;AAE/D,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAA;AAI1C,qBAAa,YAAY;IACvB,OAAO,CAAC,UAAU,CAAY;IAC9B,OAAO,CAAC,eAAe,CAAiB;gBAE5B,UAAU,CAAC,EAAE,UAAU;IAKnC;;OAEG;IACG,MAAM,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,OAAO,CAAC,KAAK,GAAG;QAAE,EAAE,EAAE,MAAM,CAAA;KAAE,CAAC;IA8B7E;;OAEG;IACG,WAAW,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAInD;;OAEG;IACG,QAAQ,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,KAAK,GAAG;QAAE,EAAE,EAAE,MAAM,CAAA;KAAE,CAAC;IAYhE;;OAEG;IACG,WAAW,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAIjD;;OAEG;IACG,OAAO,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,CAAC;IAuBhD;;OAEG;IACG,MAAM,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;QAAE,KAAK,EAAE,KAAK,CAAC;QAAC,UAAU,EAAE,GAAG,CAAA;KAAE,CAAC;IAiBrE;;OAEG;IACG,MAAM,CAAC,KAAK,EAAE,KAAK,EAAE,UAAU,EAAE,GAAG,GAAG,OAAO,CAAC,IAAI,CAAC;IAI1D;;OAEG;IACG,IAAI,IAAI,OAAO,CAAC,KAAK,CAAC,KAAK,GAAG;QAAE,EAAE,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IAqBlD,OAAO,CAAC,iBAAiB;IAqB3B,OAAO,CAAC,oBAAoB;YAQd,WAAW;CAK1B"}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* DID Utilities
|
|
3
|
+
*
|
|
4
|
+
* Common utility functions for DID operations.
|
|
5
|
+
* These functions are shared across AgentDIDManager, EphemeralDIDManager,
|
|
6
|
+
* UserIdentityManager, and UserRootDIDManager.
|
|
7
|
+
*/
|
|
8
|
+
import type { JWK } from 'jose';
|
|
9
|
+
/**
|
|
10
|
+
* Public key JWK properties for did:jwk creation
|
|
11
|
+
*/
|
|
12
|
+
export interface PublicKeyJWK {
|
|
13
|
+
kty: string;
|
|
14
|
+
crv?: string;
|
|
15
|
+
x?: string;
|
|
16
|
+
y?: string;
|
|
17
|
+
use?: string;
|
|
18
|
+
alg?: string;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Create did:jwk from a public key JWK
|
|
22
|
+
*
|
|
23
|
+
* @param publicKey - The public key JWK (can include private key fields, they will be filtered)
|
|
24
|
+
* @returns The did:jwk string
|
|
25
|
+
*
|
|
26
|
+
* @example
|
|
27
|
+
* ```typescript
|
|
28
|
+
* const keyPair = await SDJwtClient.generateKeyPair()
|
|
29
|
+
* const did = createDidJwk(keyPair.publicKey)
|
|
30
|
+
* // => did:jwk:eyJrdHkiOiJFQyIsImNydiI6IlAtMjU2IiwieCI6Ii4uLiIsInkiOiIuLi4ifQ
|
|
31
|
+
* ```
|
|
32
|
+
*/
|
|
33
|
+
export declare function createDidJwk(publicKey: JWK | PublicKeyJWK): string;
|
|
34
|
+
/**
|
|
35
|
+
* Extract public key JWK from a private key JWK
|
|
36
|
+
*
|
|
37
|
+
* @param privateKey - The private key JWK containing the 'd' parameter
|
|
38
|
+
* @returns The public key JWK (without private key material)
|
|
39
|
+
*
|
|
40
|
+
* @example
|
|
41
|
+
* ```typescript
|
|
42
|
+
* const keyPair = await SDJwtClient.generateKeyPair()
|
|
43
|
+
* const publicKey = extractPublicKey(keyPair.privateKey)
|
|
44
|
+
* ```
|
|
45
|
+
*/
|
|
46
|
+
export declare function extractPublicKey(privateKey: JWK): JWK;
|
|
47
|
+
/**
|
|
48
|
+
* Extract public key JWK from a did:jwk string
|
|
49
|
+
*
|
|
50
|
+
* @param did - The did:jwk string
|
|
51
|
+
* @returns The public key JWK decoded from the DID
|
|
52
|
+
* @throws Error if the DID is not in did:jwk format
|
|
53
|
+
*
|
|
54
|
+
* @example
|
|
55
|
+
* ```typescript
|
|
56
|
+
* const publicKey = extractPublicKeyFromDid('did:jwk:eyJrdHkiOiJFQyIsImNydiI6IlAtMjU2IiwieCI6Ii4uLiIsInkiOiIuLi4ifQ')
|
|
57
|
+
* ```
|
|
58
|
+
*/
|
|
59
|
+
export declare function extractPublicKeyFromDid(did: string): JWK;
|
|
60
|
+
/**
|
|
61
|
+
* Validate that a string is a valid did:jwk
|
|
62
|
+
*
|
|
63
|
+
* @param did - The string to validate
|
|
64
|
+
* @returns true if valid did:jwk, false otherwise
|
|
65
|
+
*/
|
|
66
|
+
export declare function isValidDidJwk(did: string): boolean;
|
|
67
|
+
/**
|
|
68
|
+
* Get the key ID (kid) from a did:jwk
|
|
69
|
+
* Following the did:jwk specification, the key ID is the DID with #0 appended
|
|
70
|
+
*
|
|
71
|
+
* @param did - The did:jwk string
|
|
72
|
+
* @returns The key ID
|
|
73
|
+
*/
|
|
74
|
+
export declare function getKeyIdFromDid(did: string): string;
|
|
75
|
+
//# sourceMappingURL=did-utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"did-utils.d.ts","sourceRoot":"","sources":["../../src/did/did-utils.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,MAAM,CAAA;AAE/B;;GAEG;AACH,MAAM,WAAW,YAAY;IAC3B,GAAG,EAAE,MAAM,CAAA;IACX,GAAG,CAAC,EAAE,MAAM,CAAA;IACZ,CAAC,CAAC,EAAE,MAAM,CAAA;IACV,CAAC,CAAC,EAAE,MAAM,CAAA;IACV,GAAG,CAAC,EAAE,MAAM,CAAA;IACZ,GAAG,CAAC,EAAE,MAAM,CAAA;CACb;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,YAAY,CAAC,SAAS,EAAE,GAAG,GAAG,YAAY,GAAG,MAAM,CAiBlE;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,gBAAgB,CAAC,UAAU,EAAE,GAAG,GAAG,GAAG,CAIrD;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,uBAAuB,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAOxD;AAED;;;;;GAKG;AACH,wBAAgB,aAAa,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAYlD;AAED;;;;;;GAMG;AACH,wBAAgB,eAAe,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAEnD"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { KeyStorageProvider } from '../storage';
|
|
2
|
+
export declare class KeyManager {
|
|
3
|
+
private encryptionKey?;
|
|
4
|
+
private storageProvider;
|
|
5
|
+
constructor(password?: string, storageProvider?: KeyStorageProvider);
|
|
6
|
+
private createDefaultStorageProvider;
|
|
7
|
+
storeKey(did: string, privateKey: any): Promise<void>;
|
|
8
|
+
getKey(did: string): Promise<any | null>;
|
|
9
|
+
deleteKey(did: string): Promise<void>;
|
|
10
|
+
listDids(): Promise<string[]>;
|
|
11
|
+
/**
|
|
12
|
+
* Check if storage is available
|
|
13
|
+
*/
|
|
14
|
+
isAvailable(): Promise<boolean>;
|
|
15
|
+
private didFromKeyId;
|
|
16
|
+
private encrypt;
|
|
17
|
+
private decrypt;
|
|
18
|
+
}
|
|
19
|
+
//# sourceMappingURL=key-manager.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"key-manager.d.ts","sourceRoot":"","sources":["../../src/did/key-manager.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,kBAAkB,EAAwB,MAAM,YAAY,CAAA;AAGrE,qBAAa,UAAU;IACrB,OAAO,CAAC,aAAa,CAAC,CAAQ;IAC9B,OAAO,CAAC,eAAe,CAAoB;gBAE/B,QAAQ,CAAC,EAAE,MAAM,EAAE,eAAe,CAAC,EAAE,kBAAkB;IAUnE,OAAO,CAAC,4BAA4B;IAU9B,QAAQ,CAAC,GAAG,EAAE,MAAM,EAAE,UAAU,EAAE,GAAG,GAAG,OAAO,CAAC,IAAI,CAAC;IAQrD,MAAM,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,GAAG,GAAG,IAAI,CAAC;IAYxC,SAAS,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAKrC,QAAQ,IAAI,OAAO,CAAC,MAAM,EAAE,CAAC;IAKnC;;OAEG;IACG,WAAW,IAAI,OAAO,CAAC,OAAO,CAAC;IASrC,OAAO,CAAC,YAAY;IAOpB,OAAO,CAAC,OAAO;IAoBf,OAAO,CAAC,OAAO;CAqBhB"}
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import { IStateStore } from '../state/state-store.interface';
|
|
2
|
+
/**
|
|
3
|
+
* Event returned from the Gateway /events endpoint
|
|
4
|
+
*/
|
|
5
|
+
export interface GatewayEvent {
|
|
6
|
+
id: string;
|
|
7
|
+
type: string;
|
|
8
|
+
source: string;
|
|
9
|
+
timestamp: string;
|
|
10
|
+
data: Record<string, unknown>;
|
|
11
|
+
metadata?: Record<string, unknown>;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Response from getEvents
|
|
15
|
+
*/
|
|
16
|
+
export interface GetEventsResponse {
|
|
17
|
+
events: GatewayEvent[];
|
|
18
|
+
cursor?: string;
|
|
19
|
+
hasMore: boolean;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Response from ackEvent
|
|
23
|
+
*/
|
|
24
|
+
export interface AckEventResponse {
|
|
25
|
+
success: boolean;
|
|
26
|
+
eventId: string;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Options for getEvents
|
|
30
|
+
*/
|
|
31
|
+
export interface GetEventsOptions {
|
|
32
|
+
cursor?: string;
|
|
33
|
+
limit?: number;
|
|
34
|
+
/** Long-poll wait time in seconds (0 = no wait) */
|
|
35
|
+
waitSeconds?: number;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Gateway API client for event-based communication.
|
|
39
|
+
* Used by CLI (runner/daemon) and any other consumer that needs
|
|
40
|
+
* to long-poll for events and acknowledge them.
|
|
41
|
+
*
|
|
42
|
+
* baseUrl should be the API root without trailing path segments
|
|
43
|
+
* (e.g. "https://api.aidentity.io" or "http://localhost:3000").
|
|
44
|
+
*/
|
|
45
|
+
export declare class GatewayClient {
|
|
46
|
+
private baseUrl;
|
|
47
|
+
private stateStore?;
|
|
48
|
+
private apiKey?;
|
|
49
|
+
private sessionToken?;
|
|
50
|
+
constructor(options: {
|
|
51
|
+
baseUrl: string;
|
|
52
|
+
stateStore?: IStateStore;
|
|
53
|
+
apiKey?: string;
|
|
54
|
+
sessionToken?: string;
|
|
55
|
+
});
|
|
56
|
+
/**
|
|
57
|
+
* Set session token for authenticated requests
|
|
58
|
+
*/
|
|
59
|
+
setSessionToken(token: string): void;
|
|
60
|
+
/**
|
|
61
|
+
* Fetch events from the Gateway.
|
|
62
|
+
* If cursor is not provided, attempts to load it from StateStore.
|
|
63
|
+
*
|
|
64
|
+
* NOTE: The /events long-poll endpoint may not be implemented on the API server yet.
|
|
65
|
+
* This client is designed to work once the endpoint is available.
|
|
66
|
+
*/
|
|
67
|
+
getEvents(options?: GetEventsOptions): Promise<GetEventsResponse>;
|
|
68
|
+
/**
|
|
69
|
+
* Acknowledge an event (mark as processed).
|
|
70
|
+
*
|
|
71
|
+
* NOTE: The /events/:id/ack endpoint may not be implemented on the API server yet.
|
|
72
|
+
*/
|
|
73
|
+
ackEvent(eventId: string): Promise<AckEventResponse>;
|
|
74
|
+
/**
|
|
75
|
+
* Validate an API key against the Gateway.
|
|
76
|
+
*
|
|
77
|
+
* @param apiKey API key to validate
|
|
78
|
+
* @param projectId Optional project scope
|
|
79
|
+
* @param requiredScopes Scopes the caller needs — callers should pass the
|
|
80
|
+
* scopes relevant to their context (e.g. MCP passes
|
|
81
|
+
* ['mcp:tools:*', 'mcp:memory:*']).
|
|
82
|
+
*/
|
|
83
|
+
validateApiKey(apiKey: string, projectId?: string, requiredScopes?: string[]): Promise<ApiKeyValidationResult>;
|
|
84
|
+
private buildHeaders;
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* Result of API key validation
|
|
88
|
+
*/
|
|
89
|
+
export interface ApiKeyValidationResult {
|
|
90
|
+
valid: boolean;
|
|
91
|
+
userId?: string;
|
|
92
|
+
projectId?: string;
|
|
93
|
+
scopes?: string[];
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* Error class for Gateway API errors
|
|
97
|
+
*/
|
|
98
|
+
export declare class GatewayError extends Error {
|
|
99
|
+
readonly statusCode: number;
|
|
100
|
+
readonly responseBody: string;
|
|
101
|
+
constructor(message: string, statusCode: number, responseBody: string);
|
|
102
|
+
}
|
|
103
|
+
//# sourceMappingURL=gateway-client.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":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