nervepay 1.0.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.
- package/CHANGELOG.md +117 -0
- package/LICENSE +21 -0
- package/README.md +532 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +449 -0
- package/dist/index.js.map +1 -0
- package/dist/setup.d.ts +9 -0
- package/dist/setup.d.ts.map +1 -0
- package/dist/setup.js +391 -0
- package/dist/setup.js.map +1 -0
- package/dist/tools/gateway.d.ts +96 -0
- package/dist/tools/gateway.d.ts.map +1 -0
- package/dist/tools/gateway.js +99 -0
- package/dist/tools/gateway.js.map +1 -0
- package/dist/tools/identity.d.ts +85 -0
- package/dist/tools/identity.d.ts.map +1 -0
- package/dist/tools/identity.js +42 -0
- package/dist/tools/identity.js.map +1 -0
- package/dist/tools/orchestration.d.ts +111 -0
- package/dist/tools/orchestration.d.ts.map +1 -0
- package/dist/tools/orchestration.js +83 -0
- package/dist/tools/orchestration.js.map +1 -0
- package/dist/tools/vault.d.ts +39 -0
- package/dist/tools/vault.d.ts.map +1 -0
- package/dist/tools/vault.js +57 -0
- package/dist/tools/vault.js.map +1 -0
- package/dist/utils/client.d.ts +42 -0
- package/dist/utils/client.d.ts.map +1 -0
- package/dist/utils/client.js +100 -0
- package/dist/utils/client.js.map +1 -0
- package/dist/utils/crypto.d.ts +28 -0
- package/dist/utils/crypto.d.ts.map +1 -0
- package/dist/utils/crypto.js +108 -0
- package/dist/utils/crypto.js.map +1 -0
- package/openclaw.plugin.json +63 -0
- package/package.json +59 -0
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Identity management tools - DID registration and authentication
|
|
3
|
+
*/
|
|
4
|
+
import type { NervePayClient } from '../utils/client.js';
|
|
5
|
+
export interface RegisterPendingParams {
|
|
6
|
+
name: string;
|
|
7
|
+
description?: string;
|
|
8
|
+
}
|
|
9
|
+
export interface RegisterPendingResult {
|
|
10
|
+
did: string;
|
|
11
|
+
private_key: string;
|
|
12
|
+
public_key: string;
|
|
13
|
+
mnemonic: string;
|
|
14
|
+
session_id: string;
|
|
15
|
+
claim_url: string;
|
|
16
|
+
status: string;
|
|
17
|
+
}
|
|
18
|
+
export interface ClaimStatusResult {
|
|
19
|
+
status: 'pending' | 'claimed' | 'expired' | 'revoked';
|
|
20
|
+
agent_did?: string;
|
|
21
|
+
claimed_at?: string;
|
|
22
|
+
user_id?: string;
|
|
23
|
+
}
|
|
24
|
+
export interface WhoAmIResult {
|
|
25
|
+
agent_did: string;
|
|
26
|
+
name: string;
|
|
27
|
+
public_key: string;
|
|
28
|
+
capabilities: {
|
|
29
|
+
max_spending_limit_usd?: number;
|
|
30
|
+
allowed_operations?: string[];
|
|
31
|
+
};
|
|
32
|
+
reputation_score: number;
|
|
33
|
+
created_at: string;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Register a new pending agent identity
|
|
37
|
+
* Agent can authenticate immediately, human claim is optional but recommended
|
|
38
|
+
*/
|
|
39
|
+
export declare function registerPendingIdentity(client: NervePayClient, params: RegisterPendingParams): Promise<RegisterPendingResult>;
|
|
40
|
+
/**
|
|
41
|
+
* Check claim status of a pending registration
|
|
42
|
+
*/
|
|
43
|
+
export declare function checkClaimStatus(client: NervePayClient, sessionId: string): Promise<ClaimStatusResult>;
|
|
44
|
+
/**
|
|
45
|
+
* Test authentication and get agent info
|
|
46
|
+
*/
|
|
47
|
+
export declare function whoami(client: NervePayClient): Promise<WhoAmIResult>;
|
|
48
|
+
/**
|
|
49
|
+
* Get agent capabilities
|
|
50
|
+
*/
|
|
51
|
+
export declare function getCapabilities(client: NervePayClient): Promise<{
|
|
52
|
+
capabilities: any;
|
|
53
|
+
}>;
|
|
54
|
+
/**
|
|
55
|
+
* Verify another agent's identity (public endpoint)
|
|
56
|
+
*/
|
|
57
|
+
export declare function verifyAgent(client: NervePayClient, did: string): Promise<{
|
|
58
|
+
verified: boolean;
|
|
59
|
+
agent: {
|
|
60
|
+
did: string;
|
|
61
|
+
name: string;
|
|
62
|
+
reputation_score: number;
|
|
63
|
+
created_at: string;
|
|
64
|
+
};
|
|
65
|
+
}>;
|
|
66
|
+
/**
|
|
67
|
+
* Resolve DID document
|
|
68
|
+
*/
|
|
69
|
+
export declare function resolveDid(client: NervePayClient, did: string): Promise<{
|
|
70
|
+
'@context': string[];
|
|
71
|
+
id: string;
|
|
72
|
+
verificationMethod: Array<{
|
|
73
|
+
id: string;
|
|
74
|
+
type: string;
|
|
75
|
+
controller: string;
|
|
76
|
+
publicKeyBase58: string;
|
|
77
|
+
}>;
|
|
78
|
+
authentication: string[];
|
|
79
|
+
service?: Array<{
|
|
80
|
+
id: string;
|
|
81
|
+
type: string;
|
|
82
|
+
serviceEndpoint: string;
|
|
83
|
+
}>;
|
|
84
|
+
}>;
|
|
85
|
+
//# sourceMappingURL=identity.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"identity.d.ts","sourceRoot":"","sources":["../../src/tools/identity.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAEzD,MAAM,WAAW,qBAAqB;IACpC,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED,MAAM,WAAW,qBAAqB;IACpC,GAAG,EAAE,MAAM,CAAC;IACZ,WAAW,EAAE,MAAM,CAAC;IACpB,UAAU,EAAE,MAAM,CAAC;IACnB,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,EAAE,MAAM,CAAC;IACnB,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,iBAAiB;IAChC,MAAM,EAAE,SAAS,GAAG,SAAS,GAAG,SAAS,GAAG,SAAS,CAAC;IACtD,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,UAAU,CAAC,EAAE,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,CAAC;IACrB,EAAE,EAAE,MAAM,CAAC;IACX,kBAAkB,EAAE,KAAK,CAAC;QACxB,EAAE,EAAE,MAAM,CAAC;QACX,IAAI,EAAE,MAAM,CAAC;QACb,UAAU,EAAE,MAAM,CAAC;QACnB,eAAe,EAAE,MAAM,CAAC;KACzB,CAAC,CAAC;IACH,cAAc,EAAE,MAAM,EAAE,CAAC;IACzB,OAAO,CAAC,EAAE,KAAK,CAAC;QACd,EAAE,EAAE,MAAM,CAAC;QACX,IAAI,EAAE,MAAM,CAAC;QACb,eAAe,EAAE,MAAM,CAAC;KACzB,CAAC,CAAC;CACJ,CAAC,CAED"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Identity management tools - DID registration and authentication
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* Register a new pending agent identity
|
|
6
|
+
* Agent can authenticate immediately, human claim is optional but recommended
|
|
7
|
+
*/
|
|
8
|
+
export async function registerPendingIdentity(client, params) {
|
|
9
|
+
return client.post('/v1/agent-identity/register-pending', params, false // no auth needed
|
|
10
|
+
);
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Check claim status of a pending registration
|
|
14
|
+
*/
|
|
15
|
+
export async function checkClaimStatus(client, sessionId) {
|
|
16
|
+
return client.get(`/v1/agent-identity/register-pending/${sessionId}/status`, false);
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Test authentication and get agent info
|
|
20
|
+
*/
|
|
21
|
+
export async function whoami(client) {
|
|
22
|
+
return client.get('/v1/agent-identity/whoami', true);
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Get agent capabilities
|
|
26
|
+
*/
|
|
27
|
+
export async function getCapabilities(client) {
|
|
28
|
+
return client.get('/v1/agent-identity/capabilities', true);
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Verify another agent's identity (public endpoint)
|
|
32
|
+
*/
|
|
33
|
+
export async function verifyAgent(client, did) {
|
|
34
|
+
return client.get(`/v1/agent-identity/verify/${did}`, false);
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Resolve DID document
|
|
38
|
+
*/
|
|
39
|
+
export async function resolveDid(client, did) {
|
|
40
|
+
return client.get(`/v1/did/resolve/${did}`, false);
|
|
41
|
+
}
|
|
42
|
+
//# sourceMappingURL=identity.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"identity.js","sourceRoot":"","sources":["../../src/tools/identity.ts"],"names":[],"mappings":"AAAA;;GAEG;AAsCH;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,uBAAuB,CAC3C,MAAsB,EACtB,MAA6B;IAE7B,OAAO,MAAM,CAAC,IAAI,CAChB,qCAAqC,EACrC,MAAM,EACN,KAAK,CAAC,iBAAiB;KACxB,CAAC;AACJ,CAAC;AAED;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,gBAAgB,CACpC,MAAsB,EACtB,SAAiB;IAEjB,OAAO,MAAM,CAAC,GAAG,CACf,uCAAuC,SAAS,SAAS,EACzD,KAAK,CACN,CAAC;AACJ,CAAC;AAED;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,MAAM,CAAC,MAAsB;IACjD,OAAO,MAAM,CAAC,GAAG,CAAe,2BAA2B,EAAE,IAAI,CAAC,CAAC;AACrE,CAAC;AAED;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,eAAe,CACnC,MAAsB;IAEtB,OAAO,MAAM,CAAC,GAAG,CAAC,iCAAiC,EAAE,IAAI,CAAC,CAAC;AAC7D,CAAC;AAED;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,WAAW,CAC/B,MAAsB,EACtB,GAAW;IAUX,OAAO,MAAM,CAAC,GAAG,CAAC,6BAA6B,GAAG,EAAE,EAAE,KAAK,CAAC,CAAC;AAC/D,CAAC;AAED;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,UAAU,CAC9B,MAAsB,EACtB,GAAW;IAiBX,OAAO,MAAM,CAAC,GAAG,CAAC,mBAAmB,GAAG,EAAE,EAAE,KAAK,CAAC,CAAC;AACrD,CAAC"}
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Orchestration tools - Multi-agent task management
|
|
3
|
+
*/
|
|
4
|
+
import type { NervePayClient } from '../utils/client.js';
|
|
5
|
+
export interface CreateOrchestrationParams {
|
|
6
|
+
gateway_id: string;
|
|
7
|
+
name: string;
|
|
8
|
+
prd: string;
|
|
9
|
+
context?: Record<string, any>;
|
|
10
|
+
}
|
|
11
|
+
export interface Orchestration {
|
|
12
|
+
id: string;
|
|
13
|
+
name: string;
|
|
14
|
+
gateway_id: string;
|
|
15
|
+
agent_did: string;
|
|
16
|
+
status: 'pending' | 'running' | 'paused' | 'completed' | 'failed' | 'cancelled';
|
|
17
|
+
progress_percentage: number;
|
|
18
|
+
total_tasks: number;
|
|
19
|
+
completed_tasks: number;
|
|
20
|
+
failed_tasks: number;
|
|
21
|
+
created_at: string;
|
|
22
|
+
started_at?: string;
|
|
23
|
+
completed_at?: string;
|
|
24
|
+
}
|
|
25
|
+
export interface Task {
|
|
26
|
+
id: string;
|
|
27
|
+
orchestration_id: string;
|
|
28
|
+
title: string;
|
|
29
|
+
description: string;
|
|
30
|
+
status: 'pending' | 'running' | 'completed' | 'failed' | 'blocked';
|
|
31
|
+
priority: number;
|
|
32
|
+
depends_on?: string[];
|
|
33
|
+
openclaw_run_id?: string;
|
|
34
|
+
openclaw_session_key?: string;
|
|
35
|
+
result?: any;
|
|
36
|
+
error?: string;
|
|
37
|
+
created_at: string;
|
|
38
|
+
started_at?: string;
|
|
39
|
+
completed_at?: string;
|
|
40
|
+
}
|
|
41
|
+
export interface OrchestrationEvent {
|
|
42
|
+
id: string;
|
|
43
|
+
orchestration_id: string;
|
|
44
|
+
event_type: string;
|
|
45
|
+
event_data: Record<string, any>;
|
|
46
|
+
created_at: string;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Create a new orchestration run
|
|
50
|
+
*/
|
|
51
|
+
export declare function createOrchestration(client: NervePayClient, params: CreateOrchestrationParams): Promise<Orchestration>;
|
|
52
|
+
/**
|
|
53
|
+
* List orchestrations
|
|
54
|
+
*/
|
|
55
|
+
export declare function listOrchestrations(client: NervePayClient, filters?: {
|
|
56
|
+
status?: string;
|
|
57
|
+
gateway_id?: string;
|
|
58
|
+
}): Promise<{
|
|
59
|
+
orchestrations: Orchestration[];
|
|
60
|
+
}>;
|
|
61
|
+
/**
|
|
62
|
+
* Get orchestration by ID
|
|
63
|
+
*/
|
|
64
|
+
export declare function getOrchestration(client: NervePayClient, orchestrationId: string): Promise<Orchestration>;
|
|
65
|
+
/**
|
|
66
|
+
* Start orchestration (decomposes PRD and spawns tasks)
|
|
67
|
+
*/
|
|
68
|
+
export declare function startOrchestration(client: NervePayClient, orchestrationId: string): Promise<{
|
|
69
|
+
status: string;
|
|
70
|
+
}>;
|
|
71
|
+
/**
|
|
72
|
+
* Pause orchestration
|
|
73
|
+
*/
|
|
74
|
+
export declare function pauseOrchestration(client: NervePayClient, orchestrationId: string): Promise<{
|
|
75
|
+
status: string;
|
|
76
|
+
}>;
|
|
77
|
+
/**
|
|
78
|
+
* Cancel orchestration
|
|
79
|
+
*/
|
|
80
|
+
export declare function cancelOrchestration(client: NervePayClient, orchestrationId: string): Promise<{
|
|
81
|
+
status: string;
|
|
82
|
+
}>;
|
|
83
|
+
/**
|
|
84
|
+
* List tasks for an orchestration
|
|
85
|
+
*/
|
|
86
|
+
export declare function listTasks(client: NervePayClient, orchestrationId: string, filters?: {
|
|
87
|
+
status?: string;
|
|
88
|
+
}): Promise<{
|
|
89
|
+
tasks: Task[];
|
|
90
|
+
}>;
|
|
91
|
+
/**
|
|
92
|
+
* Retry a failed task
|
|
93
|
+
*/
|
|
94
|
+
export declare function retryTask(client: NervePayClient, orchestrationId: string, taskId: string): Promise<{
|
|
95
|
+
status: string;
|
|
96
|
+
}>;
|
|
97
|
+
/**
|
|
98
|
+
* Get orchestration events (audit trail)
|
|
99
|
+
*/
|
|
100
|
+
export declare function getOrchestrationEvents(client: NervePayClient, orchestrationId: string): Promise<{
|
|
101
|
+
events: OrchestrationEvent[];
|
|
102
|
+
}>;
|
|
103
|
+
/**
|
|
104
|
+
* Helper: Wait for orchestration to complete
|
|
105
|
+
*/
|
|
106
|
+
export declare function waitForCompletion(client: NervePayClient, orchestrationId: string, options?: {
|
|
107
|
+
pollIntervalMs?: number;
|
|
108
|
+
timeoutMs?: number;
|
|
109
|
+
onProgress?: (orch: Orchestration) => void;
|
|
110
|
+
}): Promise<Orchestration>;
|
|
111
|
+
//# sourceMappingURL=orchestration.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"orchestration.d.ts","sourceRoot":"","sources":["../../src/tools/orchestration.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAEzD,MAAM,WAAW,yBAAyB;IACxC,UAAU,EAAE,MAAM,CAAC;IACnB,IAAI,EAAE,MAAM,CAAC;IACb,GAAG,EAAE,MAAM,CAAC;IACZ,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;CAC/B;AAED,MAAM,WAAW,aAAa;IAC5B,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,EAAE,MAAM,CAAC;IACnB,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,SAAS,GAAG,SAAS,GAAG,QAAQ,GAAG,WAAW,GAAG,QAAQ,GAAG,WAAW,CAAC;IAChF,mBAAmB,EAAE,MAAM,CAAC;IAC5B,WAAW,EAAE,MAAM,CAAC;IACpB,eAAe,EAAE,MAAM,CAAC;IACxB,YAAY,EAAE,MAAM,CAAC;IACrB,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,YAA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I,EAAE,aAAa,KAAK,IAAI,CAAC;CACvC,GACL,OAAO,CAAC,aAAa,CAAC,CAwBxB"}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Orchestration tools - Multi-agent task management
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* Create a new orchestration run
|
|
6
|
+
*/
|
|
7
|
+
export async function createOrchestration(client, params) {
|
|
8
|
+
return client.post('/v1/orchestration/runs', params, true);
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* List orchestrations
|
|
12
|
+
*/
|
|
13
|
+
export async function listOrchestrations(client, filters) {
|
|
14
|
+
const query = new URLSearchParams(filters).toString();
|
|
15
|
+
const path = query ? `/v1/orchestration/runs?${query}` : '/v1/orchestration/runs';
|
|
16
|
+
return client.get(path, true);
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Get orchestration by ID
|
|
20
|
+
*/
|
|
21
|
+
export async function getOrchestration(client, orchestrationId) {
|
|
22
|
+
return client.get(`/v1/orchestration/runs/${orchestrationId}`, true);
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Start orchestration (decomposes PRD and spawns tasks)
|
|
26
|
+
*/
|
|
27
|
+
export async function startOrchestration(client, orchestrationId) {
|
|
28
|
+
return client.post(`/v1/orchestration/runs/${orchestrationId}/start`, {}, true);
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Pause orchestration
|
|
32
|
+
*/
|
|
33
|
+
export async function pauseOrchestration(client, orchestrationId) {
|
|
34
|
+
return client.post(`/v1/orchestration/runs/${orchestrationId}/pause`, {}, true);
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Cancel orchestration
|
|
38
|
+
*/
|
|
39
|
+
export async function cancelOrchestration(client, orchestrationId) {
|
|
40
|
+
return client.post(`/v1/orchestration/runs/${orchestrationId}/cancel`, {}, true);
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* List tasks for an orchestration
|
|
44
|
+
*/
|
|
45
|
+
export async function listTasks(client, orchestrationId, filters) {
|
|
46
|
+
const query = new URLSearchParams(filters).toString();
|
|
47
|
+
const path = query
|
|
48
|
+
? `/v1/orchestration/runs/${orchestrationId}/tasks?${query}`
|
|
49
|
+
: `/v1/orchestration/runs/${orchestrationId}/tasks`;
|
|
50
|
+
return client.get(path, true);
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Retry a failed task
|
|
54
|
+
*/
|
|
55
|
+
export async function retryTask(client, orchestrationId, taskId) {
|
|
56
|
+
return client.post(`/v1/orchestration/runs/${orchestrationId}/tasks/${taskId}/retry`, {}, true);
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Get orchestration events (audit trail)
|
|
60
|
+
*/
|
|
61
|
+
export async function getOrchestrationEvents(client, orchestrationId) {
|
|
62
|
+
return client.get(`/v1/orchestration/runs/${orchestrationId}/events`, true);
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Helper: Wait for orchestration to complete
|
|
66
|
+
*/
|
|
67
|
+
export async function waitForCompletion(client, orchestrationId, options = {}) {
|
|
68
|
+
const { pollIntervalMs = 5000, timeoutMs = 3600000, // 1 hour
|
|
69
|
+
onProgress, } = options;
|
|
70
|
+
const startTime = Date.now();
|
|
71
|
+
while (Date.now() - startTime < timeoutMs) {
|
|
72
|
+
const orch = await getOrchestration(client, orchestrationId);
|
|
73
|
+
if (onProgress) {
|
|
74
|
+
onProgress(orch);
|
|
75
|
+
}
|
|
76
|
+
if (['completed', 'failed', 'cancelled'].includes(orch.status)) {
|
|
77
|
+
return orch;
|
|
78
|
+
}
|
|
79
|
+
await new Promise(resolve => setTimeout(resolve, pollIntervalMs));
|
|
80
|
+
}
|
|
81
|
+
throw new Error(`Orchestration timed out after ${timeoutMs}ms`);
|
|
82
|
+
}
|
|
83
|
+
//# sourceMappingURL=orchestration.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":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,CAAC;YACf,UAAU,CAAC,IAAI,CAAC,CAAC;QACnB,CAAC;QAED,IAAI,CAAC,WAAW,EAAE,QAAQ,EAAE,WAAW,CAAC,CAAC,QAAQ,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC;YAC/D,OAAO,IAAI,CAAC;QACd,CAAC;QAED,MAAM,IAAI,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC,UAAU,CAAC,OAAO,EAAE,cAAc,CAAC,CAAC,CAAC;IACpE,CAAC;IAED,MAAM,IAAI,KAAK,CAAC,iCAAiC,SAAS,IAAI,CAAC,CAAC;AAClE,CAAC"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Vault tools - Secure secrets management
|
|
3
|
+
*/
|
|
4
|
+
import type { NervePayClient } from '../utils/client.js';
|
|
5
|
+
export interface Secret {
|
|
6
|
+
id: string;
|
|
7
|
+
name: string;
|
|
8
|
+
description?: string;
|
|
9
|
+
created_at: string;
|
|
10
|
+
updated_at: string;
|
|
11
|
+
}
|
|
12
|
+
export interface SecretWithValue extends Secret {
|
|
13
|
+
value: string;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* List all secrets (metadata only, no values)
|
|
17
|
+
*/
|
|
18
|
+
export declare function listSecrets(client: NervePayClient): Promise<{
|
|
19
|
+
secrets: Secret[];
|
|
20
|
+
}>;
|
|
21
|
+
/**
|
|
22
|
+
* Get secret value by name
|
|
23
|
+
*/
|
|
24
|
+
export declare function getSecret(client: NervePayClient, secretName: string): Promise<{
|
|
25
|
+
secret: SecretWithValue;
|
|
26
|
+
}>;
|
|
27
|
+
/**
|
|
28
|
+
* Helper: Get multiple secrets at once
|
|
29
|
+
*/
|
|
30
|
+
export declare function getSecrets(client: NervePayClient, secretNames: string[]): Promise<Record<string, string>>;
|
|
31
|
+
/**
|
|
32
|
+
* Helper: Get secret or return default value
|
|
33
|
+
*/
|
|
34
|
+
export declare function getSecretOrDefault(client: NervePayClient, secretName: string, defaultValue: string): Promise<string>;
|
|
35
|
+
/**
|
|
36
|
+
* Helper: Check if secret exists
|
|
37
|
+
*/
|
|
38
|
+
export declare function hasSecret(client: NervePayClient, secretName: string): Promise<boolean>;
|
|
39
|
+
//# sourceMappingURL=vault.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"vault.d.ts","sourceRoot":"","sources":["../../src/tools/vault.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAEzD,MAAM,WAAW,MAAM;IACrB,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,eAAgB,SAAQ,MAAM;IAC7C,KAAK,EAAE,MAAM,CAAC;CACf;AAED;;GAEG;AACH,wBAAsB,WAAW,CAC/B,MAAM,EAAE,cAAc,GACrB,OAAO,CAAC;IAAE,OAAO,EAAE,MAAM,EAAE,CAAA;CAAE,CAAC,CAEhC;AAED;;GAEG;AACH,wBAAsB,SAAS,CAC7B,MAAM,EAAE,cAAc,EACtB,UAAU,EAAE,MAAM,GACjB,OAAO,CAAC;IAAE,MAAM,EAAE,eAAe,CAAA;CAAE,CAAC,CAEtC;AAED;;GAEG;AACH,wBAAsB,UAAU,CAC9B,MAAM,EAAE,cAAc,EACtB,WAAW,EAAE,MAAM,EAAE,GACpB,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAcjC;AAED;;GAEG;AACH,wBAAsB,kBAAkB,CACtC,MAAM,EAAE,cAAc,EACtB,UAAU,EAAE,MAAM,EAClB,YAAY,EAAE,MAAM,GACnB,OAAO,CAAC,MAAM,CAAC,CAOjB;AAED;;GAEG;AACH,wBAAsB,SAAS,CAC7B,MAAM,EAAE,cAAc,EACtB,UAAU,EAAE,MAAM,GACjB,OAAO,CAAC,OAAO,CAAC,CAOlB"}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Vault tools - Secure secrets management
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* List all secrets (metadata only, no values)
|
|
6
|
+
*/
|
|
7
|
+
export async function listSecrets(client) {
|
|
8
|
+
return client.get('/v1/vault/secrets', true);
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Get secret value by name
|
|
12
|
+
*/
|
|
13
|
+
export async function getSecret(client, secretName) {
|
|
14
|
+
return client.get(`/v1/vault/secrets/${secretName}`, true);
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Helper: Get multiple secrets at once
|
|
18
|
+
*/
|
|
19
|
+
export async function getSecrets(client, secretNames) {
|
|
20
|
+
const results = {};
|
|
21
|
+
for (const name of secretNames) {
|
|
22
|
+
try {
|
|
23
|
+
const { secret } = await getSecret(client, name);
|
|
24
|
+
results[name] = secret.value;
|
|
25
|
+
}
|
|
26
|
+
catch (err) {
|
|
27
|
+
// Secret not found or access denied
|
|
28
|
+
console.warn(`Failed to retrieve secret "${name}":`, err);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
return results;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Helper: Get secret or return default value
|
|
35
|
+
*/
|
|
36
|
+
export async function getSecretOrDefault(client, secretName, defaultValue) {
|
|
37
|
+
try {
|
|
38
|
+
const { secret } = await getSecret(client, secretName);
|
|
39
|
+
return secret.value;
|
|
40
|
+
}
|
|
41
|
+
catch {
|
|
42
|
+
return defaultValue;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Helper: Check if secret exists
|
|
47
|
+
*/
|
|
48
|
+
export async function hasSecret(client, secretName) {
|
|
49
|
+
try {
|
|
50
|
+
const { secrets } = await listSecrets(client);
|
|
51
|
+
return secrets.some(s => s.name === secretName);
|
|
52
|
+
}
|
|
53
|
+
catch {
|
|
54
|
+
return false;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
//# sourceMappingURL=vault.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"vault.js","sourceRoot":"","sources":["../../src/tools/vault.ts"],"names":[],"mappings":"AAAA;;GAEG;AAgBH;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,WAAW,CAC/B,MAAsB;IAEtB,OAAO,MAAM,CAAC,GAAG,CAAC,mBAAmB,EAAE,IAAI,CAAC,CAAC;AAC/C,CAAC;AAED;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,SAAS,CAC7B,MAAsB,EACtB,UAAkB;IAElB,OAAO,MAAM,CAAC,GAAG,CAAC,qBAAqB,UAAU,EAAE,EAAE,IAAI,CAAC,CAAC;AAC7D,CAAC;AAED;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,UAAU,CAC9B,MAAsB,EACtB,WAAqB;IAErB,MAAM,OAAO,GAA2B,EAAE,CAAC;IAE3C,KAAK,MAAM,IAAI,IAAI,WAAW,EAAE,CAAC;QAC/B,IAAI,CAAC;YACH,MAAM,EAAE,MAAM,EAAE,GAAG,MAAM,SAAS,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;YACjD,OAAO,CAAC,IAAI,CAAC,GAAG,MAAM,CAAC,KAAK,CAAC;QAC/B,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACb,oCAAoC;YACpC,OAAO,CAAC,IAAI,CAAC,8BAA8B,IAAI,IAAI,EAAE,GAAG,CAAC,CAAC;QAC5D,CAAC;IACH,CAAC;IAED,OAAO,OAAO,CAAC;AACjB,CAAC;AAED;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,kBAAkB,CACtC,MAAsB,EACtB,UAAkB,EAClB,YAAoB;IAEpB,IAAI,CAAC;QACH,MAAM,EAAE,MAAM,EAAE,GAAG,MAAM,SAAS,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC;QACvD,OAAO,MAAM,CAAC,KAAK,CAAC;IACtB,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,YAAY,CAAC;IACtB,CAAC;AACH,CAAC;AAED;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,SAAS,CAC7B,MAAsB,EACtB,UAAkB;IAElB,IAAI,CAAC;QACH,MAAM,EAAE,OAAO,EAAE,GAAG,MAAM,WAAW,CAAC,MAAM,CAAC,CAAC;QAC9C,OAAO,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,KAAK,UAAU,CAAC,CAAC;IAClD,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,KAAK,CAAC;IACf,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* NervePay API client with Ed25519 authentication
|
|
3
|
+
*/
|
|
4
|
+
export interface NervePayConfig {
|
|
5
|
+
apiUrl: string;
|
|
6
|
+
agentDid?: string;
|
|
7
|
+
privateKey?: string;
|
|
8
|
+
}
|
|
9
|
+
export type AuthHeaders = Record<string, string>;
|
|
10
|
+
export declare class NervePayClient {
|
|
11
|
+
private config;
|
|
12
|
+
constructor(config: NervePayConfig);
|
|
13
|
+
/**
|
|
14
|
+
* Generate authentication headers for a request
|
|
15
|
+
*/
|
|
16
|
+
private authHeaders;
|
|
17
|
+
/**
|
|
18
|
+
* Make an API request
|
|
19
|
+
*/
|
|
20
|
+
request<T = any>(method: string, urlPath: string, body?: any, authenticated?: boolean): Promise<T>;
|
|
21
|
+
/**
|
|
22
|
+
* GET request
|
|
23
|
+
*/
|
|
24
|
+
get<T = any>(urlPath: string, authenticated?: boolean): Promise<T>;
|
|
25
|
+
/**
|
|
26
|
+
* POST request
|
|
27
|
+
*/
|
|
28
|
+
post<T = any>(urlPath: string, body: any, authenticated?: boolean): Promise<T>;
|
|
29
|
+
/**
|
|
30
|
+
* PUT request
|
|
31
|
+
*/
|
|
32
|
+
put<T = any>(urlPath: string, body: any, authenticated?: boolean): Promise<T>;
|
|
33
|
+
/**
|
|
34
|
+
* DELETE request
|
|
35
|
+
*/
|
|
36
|
+
delete<T = any>(urlPath: string, authenticated?: boolean): Promise<T>;
|
|
37
|
+
/**
|
|
38
|
+
* Update config (e.g., after registering identity)
|
|
39
|
+
*/
|
|
40
|
+
updateConfig(updates: Partial<NervePayConfig>): void;
|
|
41
|
+
}
|
|
42
|
+
//# sourceMappingURL=client.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/utils/client.ts"],"names":[],"mappings":"AAAA;;GAEG;AAIH,MAAM,WAAW,cAAc;IAC7B,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED,MAAM,MAAM,WAAW,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;AAEjD,qBAAa,cAAc;IACzB,OAAO,CAAC,MAAM,CAAiB;gBAEnB,MAAM,EAAE,cAAc;IAIlC;;OAEG;YACW,WAAW;IAwCzB;;OAEG;IACG,OAAO,CAAC,CAAC,GAAG,GAAG,EACnB,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,MAAM,EACf,IAAI,CAAC,EAAE,GAAG,EACV,aAAa,GAAE,OAAc,GAC5B,OAAO,CAAC,CAAC,CAAC;IAiCb;;OAEG;IACG,GAAG,CAAC,CAAC,GAAG,GAAG,EAAE,OAAO,EAAE,MAAM,EAAE,aAAa,GAAE,OAAe,GAAG,OAAO,CAAC,CAAC,CAAC;IAI/E;;OAEG;IACG,IAAI,CAAC,CAAC,GAAG,GAAG,EAChB,OAAO,EAAE,MAAM,EACf,IAAI,EAAE,GAAG,EACT,aAAa,GAAE,OAAc,GAC5B,OAAO,CAAC,CAAC,CAAC;IAIb;;OAEG;IACG,GAAG,CAAC,CAAC,GAAG,GAAG,EACf,OAAO,EAAE,MAAM,EACf,IAAI,EAAE,GAAG,EACT,aAAa,GAAE,OAAc,GAC5B,OAAO,CAAC,CAAC,CAAC;IAIb;;OAEG;IACG,MAAM,CAAC,CAAC,GAAG,GAAG,EAClB,OAAO,EAAE,MAAM,EACf,aAAa,GAAE,OAAc,GAC5B,OAAO,CAAC,CAAC,CAAC;IAIb;;OAEG;IACH,YAAY,CAAC,OAAO,EAAE,OAAO,CAAC,cAAc,CAAC,GAAG,IAAI;CAGrD"}
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* NervePay API client with Ed25519 authentication
|
|
3
|
+
*/
|
|
4
|
+
import { signPayload, sha256Hash, randomUUID } from './crypto.js';
|
|
5
|
+
export class NervePayClient {
|
|
6
|
+
config;
|
|
7
|
+
constructor(config) {
|
|
8
|
+
this.config = config;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Generate authentication headers for a request
|
|
12
|
+
*/
|
|
13
|
+
async authHeaders(method, urlPath, body) {
|
|
14
|
+
if (!this.config.agentDid || !this.config.privateKey) {
|
|
15
|
+
return { 'Content-Type': 'application/json' };
|
|
16
|
+
}
|
|
17
|
+
const nonce = randomUUID();
|
|
18
|
+
const timestamp = new Date().toISOString();
|
|
19
|
+
// Split path and query
|
|
20
|
+
const [pathOnly, queryStr] = urlPath.split('?');
|
|
21
|
+
// Hash body if present
|
|
22
|
+
const bodyHash = body ? sha256Hash(body) : null;
|
|
23
|
+
// Create signature payload
|
|
24
|
+
const payload = {
|
|
25
|
+
method: method.toUpperCase(),
|
|
26
|
+
path: pathOnly,
|
|
27
|
+
query: queryStr || null,
|
|
28
|
+
body: bodyHash,
|
|
29
|
+
nonce,
|
|
30
|
+
timestamp,
|
|
31
|
+
agent_did: this.config.agentDid,
|
|
32
|
+
};
|
|
33
|
+
const signature = await signPayload(this.config.privateKey, payload);
|
|
34
|
+
return {
|
|
35
|
+
'Content-Type': 'application/json',
|
|
36
|
+
'Agent-DID': this.config.agentDid,
|
|
37
|
+
'X-Agent-Signature': signature,
|
|
38
|
+
'X-Agent-Nonce': nonce,
|
|
39
|
+
'X-Signature-Timestamp': timestamp,
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Make an API request
|
|
44
|
+
*/
|
|
45
|
+
async request(method, urlPath, body, authenticated = true) {
|
|
46
|
+
const bodyStr = body ? JSON.stringify(body) : null;
|
|
47
|
+
const headers = authenticated
|
|
48
|
+
? await this.authHeaders(method, urlPath, bodyStr)
|
|
49
|
+
: { 'Content-Type': 'application/json' };
|
|
50
|
+
const url = `${this.config.apiUrl}${urlPath}`;
|
|
51
|
+
const resp = await fetch(url, {
|
|
52
|
+
method,
|
|
53
|
+
headers,
|
|
54
|
+
body: bodyStr || undefined,
|
|
55
|
+
});
|
|
56
|
+
const text = await resp.text();
|
|
57
|
+
let data;
|
|
58
|
+
try {
|
|
59
|
+
data = JSON.parse(text);
|
|
60
|
+
}
|
|
61
|
+
catch {
|
|
62
|
+
data = text;
|
|
63
|
+
}
|
|
64
|
+
if (!resp.ok) {
|
|
65
|
+
throw new Error(`${method} ${urlPath}: ${resp.status} — ${JSON.stringify(data)}`);
|
|
66
|
+
}
|
|
67
|
+
return data;
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* GET request
|
|
71
|
+
*/
|
|
72
|
+
async get(urlPath, authenticated = false) {
|
|
73
|
+
return this.request('GET', urlPath, null, authenticated);
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* POST request
|
|
77
|
+
*/
|
|
78
|
+
async post(urlPath, body, authenticated = true) {
|
|
79
|
+
return this.request('POST', urlPath, body, authenticated);
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* PUT request
|
|
83
|
+
*/
|
|
84
|
+
async put(urlPath, body, authenticated = true) {
|
|
85
|
+
return this.request('PUT', urlPath, body, authenticated);
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* DELETE request
|
|
89
|
+
*/
|
|
90
|
+
async delete(urlPath, authenticated = true) {
|
|
91
|
+
return this.request('DELETE', urlPath, null, authenticated);
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* Update config (e.g., after registering identity)
|
|
95
|
+
*/
|
|
96
|
+
updateConfig(updates) {
|
|
97
|
+
this.config = { ...this.config, ...updates };
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
//# sourceMappingURL=client.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.js","sourceRoot":"","sources":["../../src/utils/client.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAUlE,MAAM,OAAO,cAAc;IACjB,MAAM,CAAiB;IAE/B,YAAY,MAAsB;QAChC,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;IACvB,CAAC;IAED;;OAEG;IACK,KAAK,CAAC,WAAW,CACvB,MAAc,EACd,OAAe,EACf,IAAmB;QAEnB,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,QAAQ,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,UAAU,EAAE,CAAC;YACrD,OAAO,EAAE,cAAc,EAAE,kBAAkB,EAAE,CAAC;QAChD,CAAC;QAED,MAAM,KAAK,GAAG,UAAU,EAAE,CAAC;QAC3B,MAAM,SAAS,GAAG,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC;QAE3C,uBAAuB;QACvB,MAAM,CAAC,QAAQ,EAAE,QAAQ,CAAC,GAAG,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;QAEhD,uBAAuB;QACvB,MAAM,QAAQ,GAAG,IAAI,CAAC,CAAC,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;QAEhD,2BAA2B;QAC3B,MAAM,OAAO,GAAG;YAC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ryptographic utilities for NervePay authentication
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* Decode Base58 string to bytes
|
|
6
|
+
*/
|
|
7
|
+
export declare function decodeBase58(str: string): Uint8Array;
|
|
8
|
+
/**
|
|
9
|
+
* Encode bytes to Base58
|
|
10
|
+
*/
|
|
11
|
+
export declare function encodeBase58(bytes: Uint8Array): string;
|
|
12
|
+
/**
|
|
13
|
+
* Sign a payload with Ed25519 private key
|
|
14
|
+
*/
|
|
15
|
+
export declare function signPayload(privateKeyBase58: string, payload: Record<string, any>): Promise<string>;
|
|
16
|
+
/**
|
|
17
|
+
* Verify an Ed25519 signature
|
|
18
|
+
*/
|
|
19
|
+
export declare function verifySignature(publicKeyBase58: string, payload: Record<string, any>, signatureBase64: string): Promise<boolean>;
|
|
20
|
+
/**
|
|
21
|
+
* Generate SHA-256 hash of string
|
|
22
|
+
*/
|
|
23
|
+
export declare function sha256Hash(data: string): string;
|
|
24
|
+
/**
|
|
25
|
+
* Generate random UUID v4
|
|
26
|
+
*/
|
|
27
|
+
export declare function randomUUID(): string;
|
|
28
|
+
//# sourceMappingURL=crypto.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"crypto.d.ts","sourceRoot":"","sources":["../../src/utils/crypto.ts"],"names":[],"mappings":"AAAA;;GAEG;AASH;;GAEG;AACH,wBAAgB,YAAY,CAAC,GAAG,EAAE,MAAM,GAAG,UAAU,CA6BpD;AAED;;GAEG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE,UAAU,GAAG,MAAM,CAwBtD;AAED;;GAEG;AACH,wBAAsB,WAAW,CAC/B,gBAAgB,EAAE,MAAM,EACxB,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAC3B,OAAO,CAAC,MAAM,CAAC,CAkBjB;AAED;;GAEG;AACH,wBAAsB,eAAe,CACnC,eAAe,EAAE,MAAM,EACvB,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAC5B,eAAe,EAAE,MAAM,GACtB,OAAO,CAAC,OAAO,CAAC,CAWlB;AAED;;GAEG;AACH,wBAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAG/C;AAED;;GAEG;AACH,wBAAgB,UAAU,IAAI,MAAM,CAEnC"}
|