@layr8/sdk 0.1.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/README.md +582 -0
- package/dist/backoff.d.ts +10 -0
- package/dist/backoff.d.ts.map +1 -0
- package/dist/backoff.js +20 -0
- package/dist/backoff.js.map +1 -0
- package/dist/channel.d.ts +88 -0
- package/dist/channel.d.ts.map +1 -0
- package/dist/channel.js +522 -0
- package/dist/channel.js.map +1 -0
- package/dist/client.d.ts +119 -0
- package/dist/client.d.ts.map +1 -0
- package/dist/client.js +509 -0
- package/dist/client.js.map +1 -0
- package/dist/config.d.ts +49 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +42 -0
- package/dist/config.js.map +1 -0
- package/dist/credentials.d.ts +55 -0
- package/dist/credentials.d.ts.map +1 -0
- package/dist/credentials.js +5 -0
- package/dist/credentials.js.map +1 -0
- package/dist/errors.d.ts +91 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/errors.js +132 -0
- package/dist/errors.js.map +1 -0
- package/dist/handler.d.ts +28 -0
- package/dist/handler.d.ts.map +1 -0
- package/dist/handler.js +51 -0
- package/dist/handler.js.map +1 -0
- package/dist/index.d.ts +16 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +8 -0
- package/dist/index.js.map +1 -0
- package/dist/message.d.ts +67 -0
- package/dist/message.d.ts.map +1 -0
- package/dist/message.js +77 -0
- package/dist/message.js.map +1 -0
- package/dist/presentations.d.ts +24 -0
- package/dist/presentations.d.ts.map +1 -0
- package/dist/presentations.js +5 -0
- package/dist/presentations.js.map +1 -0
- package/dist/rest.d.ts +33 -0
- package/dist/rest.d.ts.map +1 -0
- package/dist/rest.js +150 -0
- package/dist/rest.js.map +1 -0
- package/package.json +38 -0
package/dist/client.js
ADDED
|
@@ -0,0 +1,509 @@
|
|
|
1
|
+
import { EventEmitter } from "node:events";
|
|
2
|
+
import { resolveConfig } from "./config.js";
|
|
3
|
+
import { AlreadyConnectedError, ClientClosedError, ErrorKind, NotConnectedError, ProblemReportError, SDKError, ServerRejectError, } from "./errors.js";
|
|
4
|
+
import { HandlerRegistry, PASS } from "./handler.js";
|
|
5
|
+
import { generateId, marshalDIDComm, parseDIDComm, } from "./message.js";
|
|
6
|
+
import { PhoenixChannel } from "./channel.js";
|
|
7
|
+
import { RestClient, restUrlFromWebSocket } from "./rest.js";
|
|
8
|
+
function toError(err) {
|
|
9
|
+
return err instanceof Error ? err : new Error(String(err));
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Layr8Client is the main entry point for interacting with the Layr8 platform.
|
|
13
|
+
*
|
|
14
|
+
* Lifecycle: new Layr8Client → handle (register handlers) → connect → ... → close
|
|
15
|
+
*
|
|
16
|
+
* Extends EventEmitter for "disconnect" and "reconnect" events.
|
|
17
|
+
*/
|
|
18
|
+
export class Layr8Client extends EventEmitter {
|
|
19
|
+
cfg;
|
|
20
|
+
onError;
|
|
21
|
+
registry = new HandlerRegistry();
|
|
22
|
+
channel = null;
|
|
23
|
+
connected = false;
|
|
24
|
+
isClosed = false;
|
|
25
|
+
agentDid;
|
|
26
|
+
rest;
|
|
27
|
+
/** Correlation map for Request/Response pattern: threadId → {resolve, reject} */
|
|
28
|
+
pending = new Map();
|
|
29
|
+
constructor(onError, cfg = {}) {
|
|
30
|
+
super();
|
|
31
|
+
if (typeof onError !== "function") {
|
|
32
|
+
throw new TypeError("ErrorHandler is required: pass logErrors() or a custom (error: SDKError) => void");
|
|
33
|
+
}
|
|
34
|
+
this.onError = onError;
|
|
35
|
+
this.cfg = resolveConfig(cfg);
|
|
36
|
+
this.agentDid = this.cfg.agentDid;
|
|
37
|
+
this.rest = new RestClient(restUrlFromWebSocket(this.cfg.nodeUrl), this.cfg.apiKey);
|
|
38
|
+
}
|
|
39
|
+
/** The agent's DID — either provided in Config or assigned by the node on connect(). */
|
|
40
|
+
get did() {
|
|
41
|
+
return this.agentDid;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Register a handler for a DIDComm message type.
|
|
45
|
+
* Must be called BEFORE connect(). Throws AlreadyConnectedError after.
|
|
46
|
+
*/
|
|
47
|
+
handle(msgType, fn, opts) {
|
|
48
|
+
if (this.connected) {
|
|
49
|
+
throw new AlreadyConnectedError();
|
|
50
|
+
}
|
|
51
|
+
this.registry.register(msgType, fn, opts);
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Register a catch-all handler for any message type not matched by a specific handler.
|
|
55
|
+
* Must be called BEFORE connect(). Throws AlreadyConnectedError after.
|
|
56
|
+
*/
|
|
57
|
+
handleAll(fn, opts) {
|
|
58
|
+
if (this.connected) {
|
|
59
|
+
throw new AlreadyConnectedError();
|
|
60
|
+
}
|
|
61
|
+
this.registry.registerCatchAll(fn, opts);
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* EventEmitter.emit() is synchronous and propagates listener exceptions.
|
|
65
|
+
* For SDK-internal events that fire on hot paths (inbound dispatch,
|
|
66
|
+
* outbound send), a throwing listener must NOT break the path — otherwise
|
|
67
|
+
* a pending request() can hang indefinitely. Route any throw to onError.
|
|
68
|
+
*/
|
|
69
|
+
safeEmit(event, msg) {
|
|
70
|
+
try {
|
|
71
|
+
this.emit(event, msg);
|
|
72
|
+
}
|
|
73
|
+
catch (err) {
|
|
74
|
+
this.onError(new SDKError(ErrorKind.HandlerException, {
|
|
75
|
+
messageId: msg.id,
|
|
76
|
+
type: msg.type,
|
|
77
|
+
from: msg.from,
|
|
78
|
+
cause: err instanceof Error ? err : new Error(String(err)),
|
|
79
|
+
}));
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Establish WebSocket connection and join the Phoenix Channel
|
|
84
|
+
* with protocols derived from registered handlers.
|
|
85
|
+
*/
|
|
86
|
+
async connect(signal) {
|
|
87
|
+
if (this.connected)
|
|
88
|
+
throw new AlreadyConnectedError();
|
|
89
|
+
if (this.isClosed)
|
|
90
|
+
throw new ClientClosedError();
|
|
91
|
+
const protocols = this.registry.protocols();
|
|
92
|
+
// Always subscribe to the problem-report protocol so nodes can deliver
|
|
93
|
+
// problem reports back to us (e.g., when B is disconnected or passes).
|
|
94
|
+
const PROBLEM_REPORT_PROTOCOL = "https://didcomm.org/report-problem/2.0";
|
|
95
|
+
if (!protocols.includes("*") && !protocols.includes(PROBLEM_REPORT_PROTOCOL)) {
|
|
96
|
+
protocols.push(PROBLEM_REPORT_PROTOCOL);
|
|
97
|
+
}
|
|
98
|
+
const channel = new PhoenixChannel(this.cfg.nodeUrl, this.cfg.apiKey, this.cfg.agentDid, {
|
|
99
|
+
onMessage: (payload) => this.handleInboundMessage(payload),
|
|
100
|
+
onDisconnect: (err) => this.emit("disconnect", err),
|
|
101
|
+
onReconnect: () => this.emit("reconnect"),
|
|
102
|
+
}, this.cfg.didSpec);
|
|
103
|
+
await channel.connect(protocols, signal);
|
|
104
|
+
// If no DID was provided, use the one assigned by the node
|
|
105
|
+
if (!this.agentDid && channel.assignedDID()) {
|
|
106
|
+
this.agentDid = channel.assignedDID();
|
|
107
|
+
}
|
|
108
|
+
this.channel = channel;
|
|
109
|
+
this.connected = true;
|
|
110
|
+
}
|
|
111
|
+
/** Gracefully shut down the client connection. */
|
|
112
|
+
async close() {
|
|
113
|
+
if (this.isClosed)
|
|
114
|
+
return;
|
|
115
|
+
this.isClosed = true;
|
|
116
|
+
this.connected = false;
|
|
117
|
+
if (this.channel) {
|
|
118
|
+
this.channel.close();
|
|
119
|
+
this.channel = null;
|
|
120
|
+
}
|
|
121
|
+
// Reject all pending requests
|
|
122
|
+
for (const [threadId, pending] of this.pending) {
|
|
123
|
+
pending.reject(new ClientClosedError());
|
|
124
|
+
this.pending.delete(threadId);
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
/**
|
|
128
|
+
* Send a message. By default waits for server acknowledgment.
|
|
129
|
+
* Pass `{ fireAndForget: true }` to skip waiting for the server reply.
|
|
130
|
+
*/
|
|
131
|
+
async send(msg, opts) {
|
|
132
|
+
if (!this.connected || !this.channel) {
|
|
133
|
+
throw new NotConnectedError();
|
|
134
|
+
}
|
|
135
|
+
const internal = this.fillMessage(msg);
|
|
136
|
+
if (opts?.fireAndForget) {
|
|
137
|
+
this.sendMessageFireAndForget(internal);
|
|
138
|
+
return;
|
|
139
|
+
}
|
|
140
|
+
await this.sendMessageAcked(internal);
|
|
141
|
+
}
|
|
142
|
+
/**
|
|
143
|
+
* Send a message and wait for a correlated response.
|
|
144
|
+
* Throws on timeout (AbortSignal), ProblemReportError, or NotConnectedError.
|
|
145
|
+
*/
|
|
146
|
+
async request(msg, opts) {
|
|
147
|
+
if (!this.connected || !this.channel) {
|
|
148
|
+
throw new NotConnectedError();
|
|
149
|
+
}
|
|
150
|
+
const internal = this.fillMessage(msg);
|
|
151
|
+
if (!internal.threadId) {
|
|
152
|
+
internal.threadId = generateId();
|
|
153
|
+
}
|
|
154
|
+
if (opts?.parentThread) {
|
|
155
|
+
internal.parentThreadId = opts.parentThread;
|
|
156
|
+
}
|
|
157
|
+
return new Promise((resolve, reject) => {
|
|
158
|
+
const signal = opts?.signal;
|
|
159
|
+
if (signal?.aborted) {
|
|
160
|
+
reject(signal.reason ?? new Error("aborted"));
|
|
161
|
+
return;
|
|
162
|
+
}
|
|
163
|
+
const cleanup = () => {
|
|
164
|
+
this.pending.delete(internal.threadId);
|
|
165
|
+
signal?.removeEventListener("abort", onAbort);
|
|
166
|
+
};
|
|
167
|
+
const onAbort = () => {
|
|
168
|
+
cleanup();
|
|
169
|
+
reject(signal.reason ?? new Error("aborted"));
|
|
170
|
+
};
|
|
171
|
+
signal?.addEventListener("abort", onAbort, { once: true });
|
|
172
|
+
this.pending.set(internal.threadId, {
|
|
173
|
+
resolve: (resp) => {
|
|
174
|
+
cleanup();
|
|
175
|
+
// Check if response is a problem report
|
|
176
|
+
if (resp.type ===
|
|
177
|
+
"https://didcomm.org/report-problem/2.0/problem-report") {
|
|
178
|
+
const body = ((resp.bodyRaw ?? resp.body) ?? {});
|
|
179
|
+
const attachments = (resp.attachments ?? []);
|
|
180
|
+
reject(new ProblemReportError(body?.code ?? "unknown", body?.comment ?? "unknown error", body, attachments));
|
|
181
|
+
return;
|
|
182
|
+
}
|
|
183
|
+
resolve(resp);
|
|
184
|
+
},
|
|
185
|
+
reject: (err) => {
|
|
186
|
+
cleanup();
|
|
187
|
+
reject(err);
|
|
188
|
+
},
|
|
189
|
+
});
|
|
190
|
+
this.emit("outbound", internal);
|
|
191
|
+
this.channel.send("message", JSON.parse(marshalDIDComm(internal)))
|
|
192
|
+
.then((reply) => {
|
|
193
|
+
if (reply.status === "error") {
|
|
194
|
+
cleanup();
|
|
195
|
+
reject(new ServerRejectError(reply.reason || reply.status));
|
|
196
|
+
return;
|
|
197
|
+
}
|
|
198
|
+
// Server accepted, keep waiting for DIDComm response
|
|
199
|
+
})
|
|
200
|
+
.catch((err) => {
|
|
201
|
+
cleanup();
|
|
202
|
+
reject(err);
|
|
203
|
+
});
|
|
204
|
+
});
|
|
205
|
+
}
|
|
206
|
+
// --- W3C Verifiable Credential APIs (REST, no WebSocket required) ---
|
|
207
|
+
/**
|
|
208
|
+
* Sign a W3C Verifiable Credential using the issuer's assertion key.
|
|
209
|
+
* Defaults: issuer = client.did, format = "compact_jwt".
|
|
210
|
+
*/
|
|
211
|
+
async signCredential(credential, options) {
|
|
212
|
+
const body = {
|
|
213
|
+
credential,
|
|
214
|
+
issuer_did: options?.issuerDid ?? this.agentDid,
|
|
215
|
+
format: options?.format ?? "compact_jwt",
|
|
216
|
+
};
|
|
217
|
+
const result = await this.rest.post("/api/v1/credentials/sign", body);
|
|
218
|
+
return result.signed_credential;
|
|
219
|
+
}
|
|
220
|
+
/**
|
|
221
|
+
* Verify a signed credential using the verifier DID's assertion key.
|
|
222
|
+
* Defaults: verifier = client.did.
|
|
223
|
+
*/
|
|
224
|
+
async verifyCredential(signedCredential, options) {
|
|
225
|
+
const body = {
|
|
226
|
+
signed_credential: signedCredential,
|
|
227
|
+
verifier_did: options?.verifierDid ?? this.agentDid,
|
|
228
|
+
};
|
|
229
|
+
return this.rest.post("/api/v1/credentials/verify", body);
|
|
230
|
+
}
|
|
231
|
+
/**
|
|
232
|
+
* Store a signed credential JWT for a holder.
|
|
233
|
+
* Defaults: holder = client.did.
|
|
234
|
+
*/
|
|
235
|
+
async storeCredential(credentialJwt, options) {
|
|
236
|
+
const body = {
|
|
237
|
+
holder_did: options?.holderDid ?? this.agentDid,
|
|
238
|
+
credential_jwt: credentialJwt,
|
|
239
|
+
};
|
|
240
|
+
if (options?.issuerDid) {
|
|
241
|
+
body.issuer_did = options.issuerDid;
|
|
242
|
+
}
|
|
243
|
+
if (options?.validUntil) {
|
|
244
|
+
body.valid_until = options.validUntil.toISOString();
|
|
245
|
+
}
|
|
246
|
+
return this.rest.post("/api/v1/credentials", body);
|
|
247
|
+
}
|
|
248
|
+
/**
|
|
249
|
+
* List all stored credentials for a holder.
|
|
250
|
+
* Defaults: holder = client.did.
|
|
251
|
+
*/
|
|
252
|
+
async listCredentials(options) {
|
|
253
|
+
const holderDid = options?.holderDid ?? this.agentDid;
|
|
254
|
+
const path = "/api/v1/credentials?holder_did=" + encodeURIComponent(holderDid);
|
|
255
|
+
const result = await this.rest.get(path);
|
|
256
|
+
return result.credentials;
|
|
257
|
+
}
|
|
258
|
+
/** Retrieve a stored credential by ID. */
|
|
259
|
+
async getCredential(credentialId) {
|
|
260
|
+
const path = "/api/v1/credentials/" + encodeURIComponent(credentialId);
|
|
261
|
+
return this.rest.get(path);
|
|
262
|
+
}
|
|
263
|
+
// --- W3C Verifiable Presentation APIs (REST, no WebSocket required) ---
|
|
264
|
+
/**
|
|
265
|
+
* Sign a W3C Verifiable Presentation wrapping one or more signed credentials.
|
|
266
|
+
* Uses the holder's authentication key (not assertion key).
|
|
267
|
+
* Defaults: holder = client.did, format = "compact_jwt".
|
|
268
|
+
*/
|
|
269
|
+
async signPresentation(credentials, options) {
|
|
270
|
+
const body = {
|
|
271
|
+
credentials,
|
|
272
|
+
holder_did: options?.holderDid ?? this.agentDid,
|
|
273
|
+
format: options?.format ?? "compact_jwt",
|
|
274
|
+
};
|
|
275
|
+
if (options?.nonce) {
|
|
276
|
+
body.nonce = options.nonce;
|
|
277
|
+
}
|
|
278
|
+
const result = await this.rest.post("/api/v1/presentations/sign", body);
|
|
279
|
+
return result.signed_presentation;
|
|
280
|
+
}
|
|
281
|
+
/**
|
|
282
|
+
* Verify a signed presentation using the verifier DID's authentication key.
|
|
283
|
+
* Defaults: verifier = client.did.
|
|
284
|
+
*/
|
|
285
|
+
async verifyPresentation(signedPresentation, options) {
|
|
286
|
+
const body = {
|
|
287
|
+
signed_presentation: signedPresentation,
|
|
288
|
+
verifier_did: options?.verifierDid ?? this.agentDid,
|
|
289
|
+
};
|
|
290
|
+
return this.rest.post("/api/v1/presentations/verify", body);
|
|
291
|
+
}
|
|
292
|
+
sendReplyMessage(resp, original) {
|
|
293
|
+
try {
|
|
294
|
+
const internal = this.fillMessage(resp);
|
|
295
|
+
if (!internal.to.length && original.from) {
|
|
296
|
+
internal.to = [original.from];
|
|
297
|
+
}
|
|
298
|
+
if (!internal.threadId) {
|
|
299
|
+
internal.threadId = original.threadId || original.id;
|
|
300
|
+
}
|
|
301
|
+
this.sendMessage(internal);
|
|
302
|
+
}
|
|
303
|
+
catch (err) {
|
|
304
|
+
this.onError(new SDKError(ErrorKind.TransportWrite, {
|
|
305
|
+
messageId: original.id,
|
|
306
|
+
type: original.type,
|
|
307
|
+
from: original.from,
|
|
308
|
+
cause: toError(err),
|
|
309
|
+
}));
|
|
310
|
+
}
|
|
311
|
+
}
|
|
312
|
+
handleInboundMessage(payload) {
|
|
313
|
+
let msg;
|
|
314
|
+
try {
|
|
315
|
+
msg = parseDIDComm(payload);
|
|
316
|
+
}
|
|
317
|
+
catch (err) {
|
|
318
|
+
this.onError(new SDKError(ErrorKind.ParseFailure, {
|
|
319
|
+
cause: toError(err),
|
|
320
|
+
raw: payload,
|
|
321
|
+
}));
|
|
322
|
+
return;
|
|
323
|
+
}
|
|
324
|
+
// Observability hook before dispatch — observers see every parsed message
|
|
325
|
+
// regardless of how it gets routed. A throwing listener must NOT break
|
|
326
|
+
// dispatch (e.g. cause a pending request() to hang).
|
|
327
|
+
this.safeEmit("inbound", msg);
|
|
328
|
+
// Check if this is a response to a pending Request (by thread ID).
|
|
329
|
+
// For most replies the responder reuses our thid → match by threadId.
|
|
330
|
+
// For DIDComm 2 problem-reports (and other corrective protocols) the
|
|
331
|
+
// responder typically sets pthid = our thid and starts a fresh thid
|
|
332
|
+
// for the report itself; match by parentThreadId in that case.
|
|
333
|
+
const matchKey = (msg.threadId && this.pending.has(msg.threadId)) ? msg.threadId :
|
|
334
|
+
(msg.parentThreadId && this.pending.has(msg.parentThreadId)) ? msg.parentThreadId :
|
|
335
|
+
undefined;
|
|
336
|
+
if (matchKey) {
|
|
337
|
+
const pending = this.pending.get(matchKey);
|
|
338
|
+
if (pending) {
|
|
339
|
+
this.pending.delete(matchKey);
|
|
340
|
+
// Send dispatch_reply so the node's PluginRouter doesn't time out
|
|
341
|
+
// Send dispatch_reply so the node's PluginRouter doesn't time out.
|
|
342
|
+
// Only when the node advertises reply_protocol — legacy nodes don't
|
|
343
|
+
// recognize the event and may drop the connection.
|
|
344
|
+
if (this.channel.replyProtocol()) {
|
|
345
|
+
this.sendDispatchReply(msg.id, "handled");
|
|
346
|
+
}
|
|
347
|
+
pending.resolve(msg);
|
|
348
|
+
return;
|
|
349
|
+
}
|
|
350
|
+
}
|
|
351
|
+
const useReplyProtocol = this.channel.replyProtocol();
|
|
352
|
+
// Route to registered handler
|
|
353
|
+
const entry = this.registry.lookup(msg.type);
|
|
354
|
+
if (!entry) {
|
|
355
|
+
if (useReplyProtocol) {
|
|
356
|
+
this.sendDispatchReply(msg.id, "pass");
|
|
357
|
+
}
|
|
358
|
+
this.onError(new SDKError(ErrorKind.NoHandler, {
|
|
359
|
+
messageId: msg.id,
|
|
360
|
+
type: msg.type,
|
|
361
|
+
from: msg.from,
|
|
362
|
+
}));
|
|
363
|
+
return;
|
|
364
|
+
}
|
|
365
|
+
if (useReplyProtocol) {
|
|
366
|
+
// New mode: no ack, use dispatch_reply after handler
|
|
367
|
+
this.runHandlerWithReply(entry.fn, msg);
|
|
368
|
+
}
|
|
369
|
+
else {
|
|
370
|
+
// Legacy mode: ack before handler
|
|
371
|
+
if (!entry.manualAck) {
|
|
372
|
+
try {
|
|
373
|
+
this.channel.sendAck([msg.id]);
|
|
374
|
+
}
|
|
375
|
+
catch {
|
|
376
|
+
// Best-effort ack
|
|
377
|
+
}
|
|
378
|
+
}
|
|
379
|
+
else {
|
|
380
|
+
msg.ackFn = (id) => {
|
|
381
|
+
this.channel.sendAck([id]);
|
|
382
|
+
};
|
|
383
|
+
}
|
|
384
|
+
this.runHandler(entry.fn, msg);
|
|
385
|
+
}
|
|
386
|
+
}
|
|
387
|
+
async runHandler(fn, msg) {
|
|
388
|
+
let resp;
|
|
389
|
+
try {
|
|
390
|
+
resp = await fn(msg);
|
|
391
|
+
}
|
|
392
|
+
catch (err) {
|
|
393
|
+
const error = toError(err);
|
|
394
|
+
this.onError(new SDKError(ErrorKind.HandlerException, {
|
|
395
|
+
messageId: msg.id,
|
|
396
|
+
type: msg.type,
|
|
397
|
+
from: msg.from,
|
|
398
|
+
cause: error,
|
|
399
|
+
}));
|
|
400
|
+
this.sendProblemReport(msg, error);
|
|
401
|
+
return;
|
|
402
|
+
}
|
|
403
|
+
if (resp && resp !== PASS) {
|
|
404
|
+
this.sendReplyMessage(resp, msg);
|
|
405
|
+
}
|
|
406
|
+
}
|
|
407
|
+
async runHandlerWithReply(fn, msg) {
|
|
408
|
+
let resp;
|
|
409
|
+
try {
|
|
410
|
+
resp = await fn(msg);
|
|
411
|
+
}
|
|
412
|
+
catch (err) {
|
|
413
|
+
const error = toError(err);
|
|
414
|
+
this.onError(new SDKError(ErrorKind.HandlerException, {
|
|
415
|
+
messageId: msg.id,
|
|
416
|
+
type: msg.type,
|
|
417
|
+
from: msg.from,
|
|
418
|
+
cause: error,
|
|
419
|
+
}));
|
|
420
|
+
this.sendDispatchReply(msg.id, "error", error.name, error.message);
|
|
421
|
+
return;
|
|
422
|
+
}
|
|
423
|
+
if (resp === PASS) {
|
|
424
|
+
this.sendDispatchReply(msg.id, "pass");
|
|
425
|
+
return;
|
|
426
|
+
}
|
|
427
|
+
// Send dispatch_reply BEFORE the response message. The node's channel
|
|
428
|
+
// processes WebSocket events sequentially; if the response targets a
|
|
429
|
+
// remote node, the channel blocks during HTTP delivery. Sending
|
|
430
|
+
// dispatch_reply first ensures the PluginRouter's receive unblocks
|
|
431
|
+
// before that blocking send.
|
|
432
|
+
this.sendDispatchReply(msg.id, "handled");
|
|
433
|
+
if (resp) {
|
|
434
|
+
this.sendReplyMessage(resp, msg);
|
|
435
|
+
}
|
|
436
|
+
}
|
|
437
|
+
sendDispatchReply(messageId, status, code, message) {
|
|
438
|
+
try {
|
|
439
|
+
const payload = { message_id: messageId, status };
|
|
440
|
+
if (code)
|
|
441
|
+
payload.code = code;
|
|
442
|
+
if (message)
|
|
443
|
+
payload.message = message;
|
|
444
|
+
this.channel.sendFireAndForget("dispatch_reply", payload);
|
|
445
|
+
}
|
|
446
|
+
catch {
|
|
447
|
+
// Best-effort
|
|
448
|
+
}
|
|
449
|
+
}
|
|
450
|
+
sendProblemReport(original, err) {
|
|
451
|
+
try {
|
|
452
|
+
const threadId = original.threadId || original.id;
|
|
453
|
+
const report = {
|
|
454
|
+
id: generateId(),
|
|
455
|
+
type: "https://didcomm.org/report-problem/2.0/problem-report",
|
|
456
|
+
from: this.agentDid,
|
|
457
|
+
to: original.from ? [original.from] : [],
|
|
458
|
+
threadId,
|
|
459
|
+
parentThreadId: "",
|
|
460
|
+
body: {
|
|
461
|
+
code: "e.p.xfer.cant-process",
|
|
462
|
+
comment: err.message,
|
|
463
|
+
},
|
|
464
|
+
};
|
|
465
|
+
this.sendMessage(report);
|
|
466
|
+
}
|
|
467
|
+
catch {
|
|
468
|
+
// Best-effort: if we can't send the problem report (e.g., connection
|
|
469
|
+
// lost), swallow the error to avoid masking the original handler failure.
|
|
470
|
+
}
|
|
471
|
+
}
|
|
472
|
+
fillMessage(msg) {
|
|
473
|
+
return {
|
|
474
|
+
id: msg.id || generateId(),
|
|
475
|
+
type: msg.type || "",
|
|
476
|
+
from: msg.from || this.agentDid,
|
|
477
|
+
to: msg.to || [],
|
|
478
|
+
threadId: msg.threadId || "",
|
|
479
|
+
parentThreadId: msg.parentThreadId || "",
|
|
480
|
+
body: msg.body ?? null,
|
|
481
|
+
...(msg.attachments ? { attachments: msg.attachments } : {}),
|
|
482
|
+
};
|
|
483
|
+
}
|
|
484
|
+
async sendMessageAcked(msg) {
|
|
485
|
+
if (!this.channel)
|
|
486
|
+
throw new NotConnectedError();
|
|
487
|
+
const data = marshalDIDComm(msg);
|
|
488
|
+
this.safeEmit("outbound", msg);
|
|
489
|
+
const reply = await this.channel.send("message", JSON.parse(data));
|
|
490
|
+
if (reply.status === "error") {
|
|
491
|
+
throw new ServerRejectError(reply.reason || reply.status);
|
|
492
|
+
}
|
|
493
|
+
}
|
|
494
|
+
sendMessageFireAndForget(msg) {
|
|
495
|
+
if (!this.channel)
|
|
496
|
+
throw new NotConnectedError();
|
|
497
|
+
const data = marshalDIDComm(msg);
|
|
498
|
+
this.safeEmit("outbound", msg);
|
|
499
|
+
this.channel.sendFireAndForget("message", JSON.parse(data));
|
|
500
|
+
}
|
|
501
|
+
sendMessage(msg) {
|
|
502
|
+
if (!this.channel)
|
|
503
|
+
throw new NotConnectedError();
|
|
504
|
+
const data = marshalDIDComm(msg);
|
|
505
|
+
this.safeEmit("outbound", msg);
|
|
506
|
+
this.channel.sendFireAndForget("message", JSON.parse(data));
|
|
507
|
+
}
|
|
508
|
+
}
|
|
509
|
+
//# sourceMappingURL=client.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.js","sourceRoot":"","sources":["../src/client.ts"],"names":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,CAAC,IAAI,CAAC,OAAO;YAAE,MAAM,IAAI,iBAAiB,EAAE,CAAC;QACjD,MAAM,IAAI,GAAG,cAAc,CAAC,GAAG,CAAC,CAAC;QACjC,IAAI,CAAC,QAAQ,CAAC,UAAU,EAAE,GAAG,CAAC,CAAC;QAC/B,IAAI,CAAC,OAAO,CAAC,iBAAiB,CAAC,SAAS,EAAE,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC;IAC9D,CAAC;IAEO,WAAW,CAAC,GAAoB;QACtC,IAAI,CAAC,IAAI,CAAC,OAAO;YAAE,MAAM,IAAI,iBAAiB,EAAE,CAAC;QACjD,MAAM,IAAI,GAAG,cAAc,CAAC,GAAG,CAAC,CAAC;QACjC,IAAI,CAAC,QAAQ,CAAC,UAAU,EAAE,GAAG,CAAC,CAAC;QAC/B,IAAI,CAAC,OAAO,CAAC,iBAAiB,CAAC,SAAS,EAAE,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC;IAC9D,CAAC;CACF"}
|
package/dist/config.d.ts
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/** Verification method purpose for DID creation. */
|
|
2
|
+
export interface VerificationMethod {
|
|
3
|
+
/** Key purpose: authentication, assertionMethod, keyAgreement, capabilityInvocation, capabilityDelegation. */
|
|
4
|
+
purpose: string;
|
|
5
|
+
/** Key type. Defaults based on purpose (e.g., Ed25519VerificationKey2020 for authentication). */
|
|
6
|
+
type?: string;
|
|
7
|
+
/** Curve for JsonWebKey2020: Ed25519, X25519, P-256, P-384, P-521, secp256k1. */
|
|
8
|
+
curve?: string;
|
|
9
|
+
/** Optional key ID. */
|
|
10
|
+
id?: string;
|
|
11
|
+
}
|
|
12
|
+
/** DID specification for the cloud-node join handshake. */
|
|
13
|
+
export interface DidSpec {
|
|
14
|
+
/** How to handle DID creation: Create (create if not found), Require (must exist), Update (create or update). */
|
|
15
|
+
mode?: string;
|
|
16
|
+
/** Where to store the DID: persistent (database) or ephemeral (memory only). */
|
|
17
|
+
storage?: string;
|
|
18
|
+
/** Optional label for the DID. */
|
|
19
|
+
label?: string;
|
|
20
|
+
/** Optional type metadata (e.g., "plugin", "service"). */
|
|
21
|
+
type?: string;
|
|
22
|
+
/** Cryptographic verification methods to create. */
|
|
23
|
+
verificationMethods?: VerificationMethod[];
|
|
24
|
+
/** Optional controller DID for the created DID document. Defaults to the node DID. */
|
|
25
|
+
controller?: string;
|
|
26
|
+
}
|
|
27
|
+
/** Default DID specification matching the original hardcoded behavior. */
|
|
28
|
+
export declare const DEFAULT_DID_SPEC: Required<DidSpec>;
|
|
29
|
+
/** Configuration for a Layr8 client. */
|
|
30
|
+
export interface Config {
|
|
31
|
+
/** WebSocket URL of the Layr8 cloud-node. Fallback: LAYR8_NODE_URL env. */
|
|
32
|
+
nodeUrl?: string;
|
|
33
|
+
/** Authentication key for the cloud-node. Fallback: LAYR8_API_KEY env. */
|
|
34
|
+
apiKey?: string;
|
|
35
|
+
/** DID identity of this agent. If empty, an ephemeral DID is created on connect(). Fallback: LAYR8_AGENT_DID env. */
|
|
36
|
+
agentDid?: string;
|
|
37
|
+
/** DID specification for the cloud-node join handshake. Merged with defaults. */
|
|
38
|
+
didSpec?: DidSpec;
|
|
39
|
+
}
|
|
40
|
+
/** Resolved configuration with required fields guaranteed present. */
|
|
41
|
+
export interface ResolvedConfig {
|
|
42
|
+
nodeUrl: string;
|
|
43
|
+
apiKey: string;
|
|
44
|
+
agentDid: string;
|
|
45
|
+
didSpec: Required<DidSpec>;
|
|
46
|
+
}
|
|
47
|
+
/** Fills empty fields from environment variables and validates required fields. */
|
|
48
|
+
export declare function resolveConfig(cfg: Config): ResolvedConfig;
|
|
49
|
+
//# sourceMappingURL=config.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAEA,oDAAoD;AACpD,MAAM,WAAW,kBAAkB;IACjC,8GAA8G;I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ID specification matching the original hardcoded behavior. */
|
|
3
|
+
export const DEFAULT_DID_SPEC = {
|
|
4
|
+
mode: "Create",
|
|
5
|
+
storage: "ephemeral",
|
|
6
|
+
label: "",
|
|
7
|
+
type: "plugin",
|
|
8
|
+
controller: "",
|
|
9
|
+
verificationMethods: [
|
|
10
|
+
{ purpose: "authentication" },
|
|
11
|
+
{ purpose: "assertionMethod" },
|
|
12
|
+
{ purpose: "keyAgreement" },
|
|
13
|
+
],
|
|
14
|
+
};
|
|
15
|
+
/** Fills empty fields from environment variables and validates required fields. */
|
|
16
|
+
export function resolveConfig(cfg) {
|
|
17
|
+
const nodeUrl = cfg.nodeUrl || process.env.LAYR8_NODE_URL || "";
|
|
18
|
+
const apiKey = cfg.apiKey || process.env.LAYR8_API_KEY || "";
|
|
19
|
+
const agentDid = cfg.agentDid || process.env.LAYR8_AGENT_DID || "";
|
|
20
|
+
if (!nodeUrl) {
|
|
21
|
+
throw new Layr8Error("nodeUrl is required (set in Config or LAYR8_NODE_URL env)");
|
|
22
|
+
}
|
|
23
|
+
// Normalize HTTP(S) URLs to WebSocket scheme.
|
|
24
|
+
// In production, the /plugin_socket endpoint serves WebSocket over HTTPS.
|
|
25
|
+
let normalizedUrl = nodeUrl;
|
|
26
|
+
if (normalizedUrl.startsWith("https://")) {
|
|
27
|
+
normalizedUrl = "wss://" + normalizedUrl.slice("https://".length);
|
|
28
|
+
}
|
|
29
|
+
else if (normalizedUrl.startsWith("http://")) {
|
|
30
|
+
normalizedUrl = "ws://" + normalizedUrl.slice("http://".length);
|
|
31
|
+
}
|
|
32
|
+
if (!apiKey) {
|
|
33
|
+
throw new Layr8Error("apiKey is required (set in Config or LAYR8_API_KEY env)");
|
|
34
|
+
}
|
|
35
|
+
const didSpec = {
|
|
36
|
+
...DEFAULT_DID_SPEC,
|
|
37
|
+
...cfg.didSpec,
|
|
38
|
+
verificationMethods: cfg.didSpec?.verificationMethods ?? DEFAULT_DID_SPEC.verificationMethods,
|
|
39
|
+
};
|
|
40
|
+
return { nodeUrl: normalizedUrl, apiKey, agentDid, didSpec };
|
|
41
|
+
}
|
|
42
|
+
//# sourceMappingURL=config.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AA8BzC,0EAA0E;AAC1E,MAAM,CAAC,MAAM,gBAAgB,GAAsB;IACjD,IAAI,EAAE,QAAQ;IACd,OAAO,EAAE,WAAW;IACpB,KAAK,EAAE,EAAE;IACT,IAAI,EAAE,QAAQ;IACd,UAAU,EAAE,EAAE;IACd,mBAAmB,EAAE;QACnB,EAAE,OAAO,EAAE,gBAAgB,EAAE;QAC7B,EAAE,OAAO,EAAE,iBAAiB,EAAE;QAC9B,EAAE,OAAO,EAAE,cAAc,EAAE;KAC5B;CACF,CAAC;AAsBF,mFAAmF;AACnF,MAAM,UAAU,aAAa,CAAC,GAAW;IACvC,MAAM,OAAO,GAAG,GAAG,CAAC,OAAO,IAAI,OAAO,CAAC,GAAG,CAAC,cAAc,IAAI,EAAE,CAAC;IAChE,MAAM,MAAM,GAAG,GAAG,CAAC,MAAM,IAAI,OAAO,CAAC,GAAG,CAAC,aAAa,IAAI,EAAE,CAAC;IAC7D,MAAM,QAAQ,GAAG,GAAG,CAAC,QAAQ,IAAI,OAAO,CAAC,GAAG,CAAC,eAAe,IAAI,EAAE,CAAC;IAEnE,IAAI,CAAC,OAAO,EAAE,CAAC;QACb,MAAM,IAAI,UAAU,CAClB,2DAA2D,CAC5D,CAAC;IACJ,CAAC;IAED,8CAA8C;IAC9C,0EAA0E;IAC1E,IAAI,aAAa,GAAG,OAAO,CAAC;IAC5B,IAAI,aAAa,CAAC,UAAU,CAAC,UAAU,CAAC,EAAE,CAAC;QACzC,aAAa,GAAG,QAAQ,GAAG,aAAa,CAAC,KAAK,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC;IACpE,C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