keri 0.0.0-dev.8b7f24e → 0.0.0-dev.973a137
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/LICENSE +201 -0
- package/README.md +3 -0
- package/dist/cesr/array-utils.d.ts +3 -0
- package/dist/cesr/array-utils.js +29 -0
- package/dist/cesr/array-utils.js.map +1 -0
- package/dist/cesr/attachments-reader.d.ts +10 -0
- package/dist/cesr/attachments-reader.js +281 -0
- package/dist/cesr/attachments-reader.js.map +1 -0
- package/dist/cesr/attachments.d.ts +66 -0
- package/dist/cesr/attachments.js +108 -0
- package/dist/cesr/attachments.js.map +1 -0
- package/dist/cesr/codes.d.ts +1208 -0
- package/dist/cesr/codes.js +309 -0
- package/dist/cesr/codes.js.map +1 -0
- package/dist/cesr/counter.d.ts +114 -0
- package/dist/cesr/counter.js +78 -0
- package/dist/cesr/counter.js.map +1 -0
- package/dist/cesr/frame.d.ts +31 -0
- package/dist/cesr/frame.js +99 -0
- package/dist/cesr/frame.js.map +1 -0
- package/dist/cesr/genus.d.ts +18 -0
- package/dist/cesr/genus.js +57 -0
- package/dist/cesr/genus.js.map +1 -0
- package/dist/cesr/groups/generic-map.d.ts +11 -0
- package/dist/cesr/groups/generic-map.js +51 -0
- package/dist/cesr/groups/generic-map.js.map +1 -0
- package/dist/cesr/indexer.d.ts +68 -0
- package/dist/cesr/indexer.js +171 -0
- package/dist/cesr/indexer.js.map +1 -0
- package/dist/cesr/main.d.ts +9 -0
- package/dist/cesr/main.js +10 -0
- package/dist/cesr/main.js.map +1 -0
- package/dist/cesr/matter.d.ts +160 -0
- package/dist/cesr/matter.js +301 -0
- package/dist/cesr/matter.js.map +1 -0
- package/dist/cesr/message.d.ts +17 -0
- package/dist/cesr/message.js +81 -0
- package/dist/cesr/message.js.map +1 -0
- package/dist/cesr/parse.d.ts +37 -0
- package/dist/cesr/parse.js +138 -0
- package/dist/cesr/parse.js.map +1 -0
- package/dist/cesr/shifting.d.ts +7 -0
- package/dist/cesr/shifting.js +10 -0
- package/dist/cesr/shifting.js.map +1 -0
- package/dist/cesr/version-string.d.ts +35 -0
- package/dist/cesr/version-string.js +146 -0
- package/dist/cesr/version-string.js.map +1 -0
- package/dist/cli/cli.d.ts +5 -0
- package/dist/cli/cli.js +73 -0
- package/dist/cli/cli.js.map +1 -0
- package/dist/cli/input.d.ts +1 -0
- package/dist/cli/input.js +22 -0
- package/dist/cli/input.js.map +1 -0
- package/dist/cli/node-cli.d.ts +2 -0
- package/dist/cli/node-cli.js +19 -0
- package/dist/cli/node-cli.js.map +1 -0
- package/dist/controller/controller.d.ts +40 -29
- package/dist/controller/controller.js +120 -25
- package/dist/controller/controller.js.map +1 -1
- package/dist/controller/main.d.ts +1 -0
- package/dist/controller/main.js +2 -0
- package/dist/controller/main.js.map +1 -0
- package/dist/core/credential-event.d.ts +5 -9
- package/dist/core/credential-event.js +1 -1
- package/dist/core/credential-event.js.map +1 -1
- package/dist/core/credential.d.ts +1 -1
- package/dist/core/credential.js +2 -2
- package/dist/core/credential.js.map +1 -1
- package/dist/core/digest.js +3 -3
- package/dist/core/digest.js.map +1 -1
- package/dist/core/endpoint-discovery.d.ts +4 -4
- package/dist/core/endpoint-discovery.js.map +1 -1
- package/dist/core/events.js +2 -2
- package/dist/core/events.js.map +1 -1
- package/dist/core/kawa.d.ts +2 -2
- package/dist/core/kawa.js +7 -38
- package/dist/core/kawa.js.map +1 -1
- package/dist/core/key-event-log.d.ts +50 -6
- package/dist/core/key-event-log.js +154 -20
- package/dist/core/key-event-log.js.map +1 -1
- package/dist/core/key-event.d.ts +23 -10
- package/dist/core/key-event.js +66 -2
- package/dist/core/key-event.js.map +1 -1
- package/dist/core/keys.d.ts +2 -1
- package/dist/core/keys.js +10 -10
- package/dist/core/keys.js.map +1 -1
- package/dist/core/mailbox-client.d.ts +7 -1
- package/dist/core/mailbox-client.js +37 -19
- package/dist/core/mailbox-client.js.map +1 -1
- package/dist/core/main.d.ts +30 -21
- package/dist/core/main.js +17 -13
- package/dist/core/main.js.map +1 -1
- package/dist/core/receipt-event.d.ts +2 -2
- package/dist/core/receipt-event.js +1 -1
- package/dist/core/receipt-event.js.map +1 -1
- package/dist/core/registry-event.d.ts +3 -5
- package/dist/core/registry-event.js +1 -1
- package/dist/core/registry-event.js.map +1 -1
- package/dist/core/routed-event.d.ts +7 -13
- package/dist/core/routed-event.js +2 -2
- package/dist/core/routed-event.js.map +1 -1
- package/dist/core/said.js +9 -6
- package/dist/core/said.js.map +1 -1
- package/dist/core/sign.js +3 -3
- package/dist/core/sign.js.map +1 -1
- package/dist/core/verify.d.ts +11 -2
- package/dist/core/verify.js +30 -11
- package/dist/core/verify.js.map +1 -1
- package/dist/core/witness-client.d.ts +8 -0
- package/dist/core/witness-client.js +39 -0
- package/dist/core/witness-client.js.map +1 -0
- package/dist/encoding/base64.d.ts +4 -0
- package/dist/encoding/base64.js +82 -0
- package/dist/encoding/base64.js.map +1 -0
- package/dist/encoding/main.d.ts +2 -0
- package/dist/encoding/main.js +3 -0
- package/dist/encoding/main.js.map +1 -0
- package/dist/encoding/utf8.d.ts +2 -0
- package/dist/encoding/utf8.js +9 -0
- package/dist/encoding/utf8.js.map +1 -0
- package/dist/logging/main.d.ts +15 -0
- package/dist/logging/main.js +25 -0
- package/dist/logging/main.js.map +1 -0
- package/dist/mailbox/mailbox-router.d.ts +6 -0
- package/dist/mailbox/mailbox-router.js +88 -0
- package/dist/mailbox/mailbox-router.js.map +1 -0
- package/dist/mailbox/mailbox.d.ts +27 -0
- package/dist/mailbox/mailbox.js +101 -0
- package/dist/mailbox/mailbox.js.map +1 -0
- package/dist/mailbox/main.d.ts +3 -0
- package/dist/mailbox/main.js +3 -0
- package/dist/mailbox/main.js.map +1 -0
- package/dist/main.d.ts +2 -1
- package/dist/main.js +1 -1
- package/dist/main.js.map +1 -1
- package/dist/nodejs-utils/main.d.ts +2 -0
- package/dist/nodejs-utils/main.js +2 -0
- package/dist/nodejs-utils/main.js.map +1 -0
- package/dist/nodejs-utils/serve.d.ts +6 -0
- package/dist/nodejs-utils/serve.js +68 -0
- package/dist/nodejs-utils/serve.js.map +1 -0
- package/dist/{storage/sqlite/storage-sqlite.d.ts → sqlite-storage/main.d.ts} +10 -8
- package/dist/{storage/sqlite/storage-sqlite.js → sqlite-storage/main.js} +38 -12
- package/dist/sqlite-storage/main.js.map +1 -0
- package/dist/sqlite-storage/node-sqlite.js.map +1 -0
- package/dist/sqlite-storage/schema.js +67 -0
- package/dist/sqlite-storage/schema.js.map +1 -0
- package/dist/sqlite-storage/sqlite-database.js.map +1 -0
- package/dist/storage/credential-storage.d.ts +8 -0
- package/dist/storage/credential-storage.js +2 -0
- package/dist/storage/credential-storage.js.map +1 -0
- package/dist/storage/key-event-storage.d.ts +10 -0
- package/dist/storage/key-event-storage.js +2 -0
- package/dist/storage/key-event-storage.js.map +1 -0
- package/dist/storage/mailbox-server-storage.d.ts +9 -0
- package/dist/storage/mailbox-server-storage.js +2 -0
- package/dist/storage/mailbox-server-storage.js.map +1 -0
- package/dist/storage/mailbox-storage.d.ts +4 -0
- package/dist/storage/mailbox-storage.js +2 -0
- package/dist/storage/mailbox-storage.js.map +1 -0
- package/dist/storage/main.d.ts +5 -0
- package/dist/storage/main.js +2 -0
- package/dist/storage/main.js.map +1 -0
- package/dist/storage/private-key-storage.d.ts +5 -0
- package/dist/storage/private-key-storage.js +2 -0
- package/dist/storage/private-key-storage.js.map +1 -0
- package/dist/witness/main.d.ts +3 -0
- package/dist/witness/main.js +3 -0
- package/dist/witness/main.js.map +1 -0
- package/dist/witness/witness-router.d.ts +6 -0
- package/dist/witness/witness-router.js +120 -0
- package/dist/witness/witness-router.js.map +1 -0
- package/dist/witness/witness.d.ts +26 -0
- package/dist/witness/witness.js +164 -0
- package/dist/witness/witness.js.map +1 -0
- package/package.json +24 -20
- package/dist/storage/sqlite/node-sqlite.js.map +0 -1
- package/dist/storage/sqlite/schema.js +0 -49
- package/dist/storage/sqlite/schema.js.map +0 -1
- package/dist/storage/sqlite/sqlite-database.js.map +0 -1
- package/dist/storage/sqlite/storage-sqlite.js.map +0 -1
- /package/dist/{storage/sqlite → sqlite-storage}/node-sqlite.d.ts +0 -0
- /package/dist/{storage/sqlite → sqlite-storage}/node-sqlite.js +0 -0
- /package/dist/{storage/sqlite → sqlite-storage}/schema.d.ts +0 -0
- /package/dist/{storage/sqlite → sqlite-storage}/sqlite-database.d.ts +0 -0
- /package/dist/{storage/sqlite → sqlite-storage}/sqlite-database.js +0 -0
package/dist/core/keys.js
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
import { cesr } from "cesr";
|
|
2
1
|
import { ed25519 } from "@noble/curves/ed25519.js";
|
|
3
2
|
import { blake3 } from "@noble/hashes/blake3.js";
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
3
|
+
import { encodeText, Matter } from "../cesr/main.js";
|
|
4
|
+
export function generateKeyPair(options) {
|
|
5
|
+
const privateKey = options?.seed
|
|
6
|
+
? blake3(new TextEncoder().encode(options.seed), { dkLen: 32 })
|
|
7
7
|
: crypto.getRandomValues(new Uint8Array(32));
|
|
8
8
|
const rawPublicKey = ed25519.getPublicKey(privateKey);
|
|
9
|
-
const
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
9
|
+
const code = options?.nonTransferable ? Matter.Code.Ed25519N : Matter.Code.Ed25519;
|
|
10
|
+
const publicKey = encodeText(new Matter({ code, raw: rawPublicKey }));
|
|
11
|
+
const publicKeyDigest = encodeText(new Matter({
|
|
12
|
+
code: Matter.Code.Blake3_256,
|
|
13
|
+
raw: blake3.create({ dkLen: 32 }).update(new TextEncoder().encode(publicKey)).digest(),
|
|
14
|
+
}));
|
|
15
15
|
return { privateKey, publicKey, publicKeyDigest };
|
|
16
16
|
}
|
|
17
17
|
//# sourceMappingURL=keys.js.map
|
package/dist/core/keys.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"keys.js","sourceRoot":"","sources":["../../src/core/keys.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"keys.js","sourceRoot":"","sources":["../../src/core/keys.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,0BAA0B,CAAC;AACnD,OAAO,EAAE,MAAM,EAAE,MAAM,yBAAyB,CAAC;AACjD,OAAO,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AAarD,MAAM,UAAU,eAAe,CAAC,OAAgC;IAC9D,MAAM,UAAU,GAAG,OAAO,EAAE,IAAI;QAC9B,CAAC,CAAC,MAAM,CAAC,IAAI,WAAW,EAAE,CAAC,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,EAAE,KAAK,EAAE,EAAE,EAAE,CAAC;QAC/D,CAAC,CAAC,MAAM,CAAC,eAAe,CAAC,IAAI,UAAU,CAAC,EAAE,CAAC,CAAC,CAAC;IAE/C,MAAM,YAAY,GAAG,OAAO,CAAC,YAAY,CAAC,UAAU,CAAC,CAAC;IACtD,MAAM,IAAI,GAAG,OAAO,EAAE,eAAe,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC;IACnF,MAAM,SAAS,GAAG,UAAU,CAAC,IAAI,MAAM,CAAC,EAAE,IAAI,EAAE,GAAG,EAAE,YAAY,EAAE,CAAC,CAAC,CAAC;IAEtE,MAAM,eAAe,GAAG,UAAU,CAChC,IAAI,MAAM,CAAC;QACT,IAAI,EAAE,MAAM,CAAC,IAAI,CAAC,UAAU;QAC5B,GAAG,EAAE,MAAM,CAAC,MAAM,CAAC,EAAE,KAAK,EAAE,EAAE,EAAE,CAAC,CAAC,MAAM,CAAC,IAAI,WAAW,EAAE,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC,CAAC,MAAM,EAAE;KACvF,CAAC,CACH,CAAC;IAEF,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,eAAe,EAAE,CAAC;AACpD,CAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type Message } from "cesr";
|
|
1
|
+
import { type Message } from "../cesr/main.ts";
|
|
2
2
|
export interface MailboxClientOptions {
|
|
3
3
|
/**
|
|
4
4
|
* The SAID of the mailbox controller.
|
|
@@ -8,8 +8,14 @@ export interface MailboxClientOptions {
|
|
|
8
8
|
* The URL of the mailbox server to send messages to.
|
|
9
9
|
*/
|
|
10
10
|
url: string;
|
|
11
|
+
/**
|
|
12
|
+
* Optional fetch implementation to use for sending messages.
|
|
13
|
+
* Defaults to the global `fetch` function.
|
|
14
|
+
*/
|
|
15
|
+
fetch?: typeof globalThis.fetch;
|
|
11
16
|
}
|
|
12
17
|
export declare class MailboxClient {
|
|
18
|
+
#private;
|
|
13
19
|
readonly url: string;
|
|
14
20
|
readonly id: string;
|
|
15
21
|
constructor(options: MailboxClientOptions);
|
|
@@ -1,20 +1,53 @@
|
|
|
1
|
-
import { parse } from "cesr";
|
|
1
|
+
import { encodeText, parse } from "../cesr/main.js";
|
|
2
|
+
async function parseEventStream(body) {
|
|
3
|
+
const reader = body.getReader();
|
|
4
|
+
const decoder = new TextDecoder();
|
|
5
|
+
const messages = [];
|
|
6
|
+
let buffer = "";
|
|
7
|
+
async function flushLine(line) {
|
|
8
|
+
if (line.startsWith("data: ")) {
|
|
9
|
+
messages.push(...(await Array.fromAsync(parse(line.slice(6)))));
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
while (true) {
|
|
13
|
+
const { done, value } = await reader.read();
|
|
14
|
+
if (done) {
|
|
15
|
+
break;
|
|
16
|
+
}
|
|
17
|
+
buffer += decoder.decode(value, { stream: true });
|
|
18
|
+
const lines = buffer.split("\n");
|
|
19
|
+
buffer = lines.pop() ?? "";
|
|
20
|
+
for (const line of lines) {
|
|
21
|
+
await flushLine(line);
|
|
22
|
+
}
|
|
23
|
+
// Long-poll SSE servers (e.g. KERIpy) keep the stream open after sending
|
|
24
|
+
// a snapshot. Once we have at least one message, stop reading and return.
|
|
25
|
+
if (messages.length > 0) {
|
|
26
|
+
await reader.cancel();
|
|
27
|
+
return messages;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
await flushLine(buffer);
|
|
31
|
+
return messages;
|
|
32
|
+
}
|
|
2
33
|
export class MailboxClient {
|
|
3
34
|
url;
|
|
4
35
|
id;
|
|
36
|
+
#fetch;
|
|
5
37
|
constructor(options) {
|
|
6
38
|
this.url = options.url;
|
|
7
39
|
this.id = options.id;
|
|
40
|
+
this.#fetch = options.fetch ?? globalThis.fetch;
|
|
8
41
|
}
|
|
9
42
|
async sendMessage(message, signal) {
|
|
10
43
|
const url = new URL("/", this.url);
|
|
11
44
|
const body = JSON.stringify(message.body);
|
|
12
45
|
const headers = {
|
|
13
46
|
"Content-Type": "application/cesr+json",
|
|
14
|
-
"CESR-ATTACHMENT": message.attachments.
|
|
47
|
+
"CESR-ATTACHMENT": encodeText(message.attachments.frames()),
|
|
15
48
|
"CESR-DESTINATION": this.id,
|
|
16
49
|
};
|
|
17
|
-
const response = await fetch(url, {
|
|
50
|
+
const response = await this.#fetch(url, {
|
|
18
51
|
method: "POST",
|
|
19
52
|
body,
|
|
20
53
|
headers,
|
|
@@ -31,22 +64,7 @@ export class MailboxClient {
|
|
|
31
64
|
return [];
|
|
32
65
|
}
|
|
33
66
|
if (contentType === "text/event-stream") {
|
|
34
|
-
|
|
35
|
-
while (true) {
|
|
36
|
-
const { done, value } = await reader.read();
|
|
37
|
-
if (done) {
|
|
38
|
-
break;
|
|
39
|
-
}
|
|
40
|
-
const str = new TextDecoder().decode(value);
|
|
41
|
-
for (const line of str.split("\n")) {
|
|
42
|
-
if (line.startsWith("data: ")) {
|
|
43
|
-
const data = line.slice(6);
|
|
44
|
-
const message = await Array.fromAsync(parse(data));
|
|
45
|
-
reader.cancel("Got message, cancelling reader");
|
|
46
|
-
return message;
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
}
|
|
67
|
+
return await parseEventStream(response.body);
|
|
50
68
|
}
|
|
51
69
|
if (contentType?.startsWith("application/json")) {
|
|
52
70
|
return [];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mailbox-client.js","sourceRoot":"","sources":["../../src/core/mailbox-client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAgB,KAAK,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"mailbox-client.js","sourceRoot":"","sources":["../../src/core/mailbox-client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAgB,KAAK,EAAE,MAAM,iBAAiB,CAAC;AAElE,KAAK,UAAU,gBAAgB,CAAC,IAAgC;IAC9D,MAAM,MAAM,GAAG,IAAI,CAAC,SAAS,EAAE,CAAC;IAChC,MAAM,OAAO,GAAG,IAAI,WAAW,EAAE,CAAC;IAClC,MAAM,QAAQ,GAAc,EAAE,CAAC;IAC/B,IAAI,MAAM,GAAG,EAAE,CAAC;IAEhB,KAAK,UAAU,SAAS,CAAC,IAAY;QACnC,IAAI,IAAI,CAAC,UAAU,CAAC,QAAQ,CAAC,EAAE,CAAC;YAC9B,QAAQ,CAAC,IAAI,CAAC,GAAG,CAAC,MAAM,KAAK,CAAC,SAAS,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;QAClE,CAAC;IACH,CAAC;IAED,OAAO,IAAI,EAAE,CAAC;QACZ,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,GAAG,MAAM,MAAM,CAAC,IAAI,EAAE,CAAC;QAC5C,IAAI,IAAI,EAAE,CAAC;YACT,MAAM;QACR,CAAC;QACD,MAAM,IAAI,OAAO,CAAC,MAAM,CAAC,KAAK,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC;QAClD,MAAM,KAAK,GAAG,MAAM,CAAC,KAAK,CAAC,IAAI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YACP,MAAM;SACP,CAAC,CAAC;QAEH,IAAI,CAAC,QAAQ,CAAC,EAAE,EAAE,CAAC;YACjB,MAAM,IAAI,KAAK,CAAC,yBAAyB,QAAQ,CAAC,MAAM,IAAI,QAAQ,CAAC,UAAU,EAAE,CAAC,CAAC;QACrF,CAAC;QAED,IAAI,CAAC,QAAQ,CAAC,IAAI,EAAE,CAAC;YACnB,OAAO,EAAE,CAAC;QACZ,CAAC;QAED,MAAM,WAAW,GAAG,QAAQ,CAAC,OAAO,CAAC,GAAG,CAAC,cAAc,CAAC,CAAC;QACzD,IAAI,CAAC,WAAW,EAAE,CAAC;YACjB,OAAO,EAAE,CAAC;QACZ,CAAC;QAED,IAAI,WAAW,KAAK,mBAAmB,EAAE,CAAC;YACxC,OAAO,MAAM,gBAAgB,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;QAC/C,CAAC;QAED,IAAI,WAAW,EAAE,UAAU,CAAC,kBAAkB,CAAC,EAAE,CAAC;YAChD,OAAO,EAAE,CAAC;QACZ,CAAC;QAED,OAAO,MAAM,KAAK,CAAC,SAAS,CAAC,KAAK,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC;IACrD,CAAC;CACF"}
|
package/dist/core/main.d.ts
CHANGED
|
@@ -1,34 +1,43 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { receipt } from "./receipt-event.ts";
|
|
3
|
-
import { incept, interact, rotate } from "./key-event.ts";
|
|
4
|
-
import { incept as registry } from "./registry-event.ts";
|
|
1
|
+
import { createCredential } from "./credential.ts";
|
|
5
2
|
import { issue, revoke } from "./credential-event.ts";
|
|
3
|
+
import { digest } from "./digest.ts";
|
|
6
4
|
import { formatDate } from "./events.ts";
|
|
5
|
+
import { delegatedIncept, delegatedRotate, incept, interact, rotate } from "./key-event.ts";
|
|
7
6
|
import { generateKeyPair } from "./keys.ts";
|
|
8
|
-
import {
|
|
7
|
+
import { receipt } from "./receipt-event.ts";
|
|
8
|
+
import { incept as registry } from "./registry-event.ts";
|
|
9
|
+
import { exchange, query, reply } from "./routed-event.ts";
|
|
9
10
|
import { sign } from "./sign.ts";
|
|
10
|
-
import {
|
|
11
|
-
|
|
12
|
-
export {
|
|
13
|
-
export { Message, Attachments } from "cesr";
|
|
14
|
-
export { type KeyEvent } from "./key-event.ts";
|
|
15
|
-
export { KeyEventLog } from "./key-event-log.ts";
|
|
16
|
-
export type { KeyState, InceptEvent, InteractEvent, RotateEvent, KeyEventBody } from "./key-event.ts";
|
|
17
|
-
export type { KeyPair } from "./keys.ts";
|
|
18
|
-
export type { RegistryInceptEvent } from "./registry-event.ts";
|
|
19
|
-
export type { IssueEvent, RevokeEvent } from "./credential-event.ts";
|
|
20
|
-
export type { ReplyEvent, ExchangeEvent } from "./routed-event.ts";
|
|
11
|
+
import { verifyThreshold } from "./verify.ts";
|
|
12
|
+
export { Attachments, type AttachmentsInit, type FirstSeenReplayCouple, type Frame, Message, type MessageBody, type NonTransReceiptCouple, type PathedMaterialCouple, type SealSourceCouple, type SealSourceTriple, type TransIdxSigGroup, type TransLastIdxSigGroup, VersionString, } from "../cesr/main.ts";
|
|
13
|
+
export type { Credential, CredentialBody, CredentialBodyInit, CredentialEdges, CredentialRules, CredentialSubject, } from "./credential.ts";
|
|
21
14
|
export { createCredential } from "./credential.ts";
|
|
22
|
-
export type {
|
|
15
|
+
export type { IssueEventBody as IssueEvent, IssueEventInit, RevokeEventBody as RevokeEvent, RevokeEventInit, } from "./credential-event.ts";
|
|
16
|
+
export type { Endpoint, EndRoleRecord, LocationRecord } from "./endpoint-discovery.ts";
|
|
23
17
|
export { resolveEndRole, resolveLocation } from "./endpoint-discovery.ts";
|
|
24
|
-
export type {
|
|
25
|
-
export type { VerifyResult } from "./verify.ts";
|
|
26
|
-
export { MailboxClient } from "./mailbox-client.ts";
|
|
18
|
+
export type { WitnessEndpoint } from "./kawa.ts";
|
|
27
19
|
export { submitToWitnesses } from "./kawa.ts";
|
|
20
|
+
export type { DelegatedInceptArgs, DelegatedRotateArgs, DipEventBody, DrtEventBody, InceptArgs, InceptEventBody, InteractArgs, InteractEventBody, KeyEvent, KeyEventBody, KeyState, RotateArgs, RotateEventBody, } from "./key-event.ts";
|
|
21
|
+
export { delegatedIncept, delegatedRotate } from "./key-event.ts";
|
|
22
|
+
export { isKelEventType, KeyEventLog } from "./key-event-log.ts";
|
|
23
|
+
export type { GenerateKeyPairOptions, KeyPair } from "./keys.ts";
|
|
24
|
+
export { generateKeyPair } from "./keys.ts";
|
|
25
|
+
export type { MailboxClientOptions } from "./mailbox-client.ts";
|
|
26
|
+
export { MailboxClient } from "./mailbox-client.ts";
|
|
27
|
+
export type { ReceiptEventBody, ReceiptEventInit } from "./receipt-event.ts";
|
|
28
|
+
export type { RegistryInceptEventBody, RegistryInceptEventInit } from "./registry-event.ts";
|
|
29
|
+
export type { ExchangeEventBody, ExchangeEventInit, QueryEventBody, QueryEventInit, ReplyEventBody, ReplyEventInit, } from "./routed-event.ts";
|
|
30
|
+
export type { SignOptions } from "./sign.ts";
|
|
31
|
+
export { sign } from "./sign.ts";
|
|
32
|
+
export type { Threshold } from "./threshold.ts";
|
|
33
|
+
export type { VerifyOptions, VerifyResult } from "./verify.ts";
|
|
34
|
+
export { verifySignature } from "./verify.ts";
|
|
28
35
|
export declare const keri: {
|
|
29
36
|
incept: typeof incept;
|
|
30
37
|
interact: typeof interact;
|
|
31
38
|
rotate: typeof rotate;
|
|
39
|
+
delegatedIncept: typeof delegatedIncept;
|
|
40
|
+
delegatedRotate: typeof delegatedRotate;
|
|
32
41
|
registry: typeof registry;
|
|
33
42
|
issue: typeof issue;
|
|
34
43
|
revoke: typeof revoke;
|
|
@@ -39,7 +48,7 @@ export declare const keri: {
|
|
|
39
48
|
receipt: typeof receipt;
|
|
40
49
|
utils: {
|
|
41
50
|
sign: typeof sign;
|
|
42
|
-
|
|
51
|
+
verifyThreshold: typeof verifyThreshold;
|
|
43
52
|
formatDate: typeof formatDate;
|
|
44
53
|
generateKeyPair: typeof generateKeyPair;
|
|
45
54
|
digest: typeof digest;
|
package/dist/core/main.js
CHANGED
|
@@ -1,27 +1,31 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { receipt } from "./receipt-event.js";
|
|
3
|
-
import { incept, interact, rotate } from "./key-event.js";
|
|
4
|
-
import { incept as registry } from "./registry-event.js";
|
|
1
|
+
import { createCredential } from "./credential.js";
|
|
5
2
|
import { issue, revoke } from "./credential-event.js";
|
|
3
|
+
import { digest } from "./digest.js";
|
|
6
4
|
import { formatDate } from "./events.js";
|
|
5
|
+
import { delegatedIncept, delegatedRotate, incept, interact, rotate } from "./key-event.js";
|
|
7
6
|
import { generateKeyPair } from "./keys.js";
|
|
8
|
-
import {
|
|
7
|
+
import { receipt } from "./receipt-event.js";
|
|
8
|
+
import { incept as registry } from "./registry-event.js";
|
|
9
|
+
import { exchange, query, reply } from "./routed-event.js";
|
|
9
10
|
import { sign } from "./sign.js";
|
|
10
|
-
import {
|
|
11
|
-
|
|
12
|
-
export { sign } from "./sign.js";
|
|
13
|
-
export { Message, Attachments } from "cesr";
|
|
14
|
-
export {} from "./key-event.js";
|
|
15
|
-
export { KeyEventLog } from "./key-event-log.js";
|
|
11
|
+
import { verifyThreshold } from "./verify.js";
|
|
12
|
+
export { Attachments, Message, VersionString, } from "../cesr/main.js";
|
|
16
13
|
export { createCredential } from "./credential.js";
|
|
17
14
|
export { resolveEndRole, resolveLocation } from "./endpoint-discovery.js";
|
|
18
|
-
export { MailboxClient } from "./mailbox-client.js";
|
|
19
15
|
export { submitToWitnesses } from "./kawa.js";
|
|
16
|
+
export { delegatedIncept, delegatedRotate } from "./key-event.js";
|
|
17
|
+
export { isKelEventType, KeyEventLog } from "./key-event-log.js";
|
|
18
|
+
export { generateKeyPair } from "./keys.js";
|
|
19
|
+
export { MailboxClient } from "./mailbox-client.js";
|
|
20
|
+
export { sign } from "./sign.js";
|
|
21
|
+
export { verifySignature } from "./verify.js";
|
|
20
22
|
export const keri = {
|
|
21
23
|
// Key events
|
|
22
24
|
incept,
|
|
23
25
|
interact,
|
|
24
26
|
rotate,
|
|
27
|
+
delegatedIncept,
|
|
28
|
+
delegatedRotate,
|
|
25
29
|
// Registry
|
|
26
30
|
registry,
|
|
27
31
|
issue,
|
|
@@ -35,7 +39,7 @@ export const keri = {
|
|
|
35
39
|
receipt,
|
|
36
40
|
utils: {
|
|
37
41
|
sign,
|
|
38
|
-
|
|
42
|
+
verifyThreshold,
|
|
39
43
|
formatDate,
|
|
40
44
|
generateKeyPair,
|
|
41
45
|
digest,
|
package/dist/core/main.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"main.js","sourceRoot":"","sources":["../../src/core/main.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"main.js","sourceRoot":"","sources":["../../src/core/main.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AACnD,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AACtD,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACrC,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAC5F,OAAO,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AAC5C,OAAO,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAC7C,OAAO,EAAE,MAAM,IAAI,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AACzD,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAC3D,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAE9C,OAAO,EACL,WAAW,EAIX,OAAO,EAQP,aAAa,GACd,MAAM,iBAAiB,CAAC;AASzB,OAAO,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AAQnD,OAAO,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAE1E,OAAO,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAC;AAgB9C,OAAO,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAClE,OAAO,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAEjE,OAAO,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AAG5C,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAYpD,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAGjC,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAE9C,MAAM,CAAC,MAAM,IAAI,GAAG;IAClB,aAAa;IACb,MAAM;IACN,QAAQ;IACR,MAAM;IACN,eAAe;IACf,eAAe;IACf,WAAW;IACX,QAAQ;IACR,KAAK;IACL,MAAM;IACN,UAAU,EAAE,gBAAgB;IAC5B,SAAS;IACT,QAAQ;IACR,KAAK;IACL,KAAK;IACL,UAAU;IACV,OAAO;IACP,KAAK,EAAE;QACL,IAAI;QACJ,eAAe;QACf,UAAU;QACV,eAAe;QACf,MAAM;KACP;CACF,CAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Message } from "cesr";
|
|
1
|
+
import { Message } from "../cesr/main.ts";
|
|
2
2
|
export interface ReceiptEventInit {
|
|
3
3
|
d: string;
|
|
4
4
|
i: string;
|
|
@@ -12,4 +12,4 @@ export type ReceiptEventBody = {
|
|
|
12
12
|
s: string;
|
|
13
13
|
};
|
|
14
14
|
export type ReceiptEvent = Message<ReceiptEventBody>;
|
|
15
|
-
export declare function receipt(args: ReceiptEventInit):
|
|
15
|
+
export declare function receipt(args: ReceiptEventInit): ReceiptEvent;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"receipt-event.js","sourceRoot":"","sources":["../../src/core/receipt-event.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"receipt-event.js","sourceRoot":"","sources":["../../src/core/receipt-event.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC;AAC1C,OAAO,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAmBzD,MAAM,UAAU,OAAO,CAAC,IAAsB;IAC5C,MAAM,IAAI,GAAG,WAAW,CACtB;QACE,CAAC,EAAE,aAAa;QAChB,CAAC,EAAE,KAAK;QACR,CAAC,EAAE,IAAI,CAAC,CAAC;QACT,CAAC,EAAE,IAAI,CAAC,CAAC;QACT,CAAC,EAAE,IAAI,CAAC,CAAC;KACV,EACD,EAAE,MAAM,EAAE,EAAE,EAAE,CACf,CAAC;IAEF,OAAO,IAAI,OAAO,CAAmB,IAAI,CAAC,CAAC;AAC7C,CAAC"}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { Message } from "cesr";
|
|
1
|
+
import { Message } from "../cesr/main.ts";
|
|
2
2
|
export interface RegistryInceptEventInit {
|
|
3
3
|
ii: string;
|
|
4
4
|
n?: string;
|
|
5
5
|
}
|
|
6
|
-
export type
|
|
6
|
+
export type RegistryInceptEventBody = {
|
|
7
7
|
v: string;
|
|
8
8
|
t: "vcp";
|
|
9
9
|
d: string;
|
|
@@ -23,6 +23,4 @@ export type RegistryEventBody = {
|
|
|
23
23
|
[key: string]: unknown;
|
|
24
24
|
};
|
|
25
25
|
export type RegistryEvent = Message<RegistryEventBody>;
|
|
26
|
-
export declare function incept(args: RegistryInceptEventInit): Message<
|
|
27
|
-
v: string;
|
|
28
|
-
}>;
|
|
26
|
+
export declare function incept(args: RegistryInceptEventInit): Message<RegistryInceptEventBody>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"registry-event.js","sourceRoot":"","sources":["../../src/core/registry-event.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"registry-event.js","sourceRoot":"","sources":["../../src/core/registry-event.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC;AAC1C,OAAO,EAAE,aAAa,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AA8BtE,MAAM,UAAU,MAAM,CAAC,IAA6B;IAClD,MAAM,IAAI,GAAG,WAAW,CACtB;QACE,CAAC,EAAE,aAAa;QAChB,CAAC,EAAE,KAAK;QACR,CAAC,EAAE,EAAE;QACL,CAAC,EAAE,EAAE;QACL,EAAE,EAAE,IAAI,CAAC,EAAE;QACX,CAAC,EAAE,GAAG;QACN,CAAC,EAAE,CAAC,IAAI,CAAC;QACT,EAAE,EAAE,GAAG;QACP,CAAC,EAAE,EAAE;QACL,CAAC,EAAE,IAAI,CAAC,CAAC,IAAI,WAAW,EAAE;KAC3B,EACD,EAAE,MAAM,EAAE,CAAC,GAAG,EAAE,GAAG,CAAC,EAAE,MAAM,EAAE,IAAI,EAAE,CACrC,CAAC;IAEF,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;AAC3B,CAAC"}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { Message } from "cesr";
|
|
1
|
+
import { Message } from "../cesr/main.ts";
|
|
2
2
|
export interface QueryEventInit {
|
|
3
3
|
dt?: Date;
|
|
4
4
|
r?: string;
|
|
5
5
|
rr?: string;
|
|
6
6
|
q: Record<string, unknown>;
|
|
7
7
|
}
|
|
8
|
-
export type
|
|
8
|
+
export type QueryEventBody = {
|
|
9
9
|
v: string;
|
|
10
10
|
t: "qry";
|
|
11
11
|
d: string;
|
|
@@ -19,7 +19,7 @@ export interface ReplyEventInit {
|
|
|
19
19
|
r: string;
|
|
20
20
|
a: Record<string, unknown>;
|
|
21
21
|
}
|
|
22
|
-
export type
|
|
22
|
+
export type ReplyEventBody = {
|
|
23
23
|
v: string;
|
|
24
24
|
t: "rpy";
|
|
25
25
|
d: string;
|
|
@@ -35,12 +35,8 @@ export type RoutedEventBody = {
|
|
|
35
35
|
[key: string]: unknown;
|
|
36
36
|
};
|
|
37
37
|
export type RoutedEvent = Message<RoutedEventBody>;
|
|
38
|
-
export declare function query(args: QueryEventInit): Message<
|
|
39
|
-
|
|
40
|
-
}>;
|
|
41
|
-
export declare function reply(args: ReplyEventInit): Message<ReplyEvent & {
|
|
42
|
-
v: string;
|
|
43
|
-
}>;
|
|
38
|
+
export declare function query(args: QueryEventInit): Message<QueryEventBody>;
|
|
39
|
+
export declare function reply(args: ReplyEventInit): Message<ReplyEventBody>;
|
|
44
40
|
export interface ExchangeEventInit {
|
|
45
41
|
sender: string;
|
|
46
42
|
recipient?: string;
|
|
@@ -55,7 +51,7 @@ export interface ExchangeEmbedding {
|
|
|
55
51
|
d: string;
|
|
56
52
|
[key: string]: string | Record<string, unknown>;
|
|
57
53
|
}
|
|
58
|
-
export interface
|
|
54
|
+
export interface ExchangeEventBody extends Record<string, unknown> {
|
|
59
55
|
v: string;
|
|
60
56
|
t: "exn";
|
|
61
57
|
d: string;
|
|
@@ -68,6 +64,4 @@ export interface ExchangeEvent extends Record<string, unknown> {
|
|
|
68
64
|
a: Record<string, unknown>;
|
|
69
65
|
e: Record<string, string | Record<string, unknown>>;
|
|
70
66
|
}
|
|
71
|
-
export declare function exchange(args: ExchangeEventInit): Message<
|
|
72
|
-
v: string;
|
|
73
|
-
}>;
|
|
67
|
+
export declare function exchange(args: ExchangeEventInit): Message<ExchangeEventBody>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Attachments, Message } from "cesr";
|
|
1
|
+
import { Attachments, Message } from "../cesr/main.js";
|
|
2
2
|
import { DUMMY_VERSION, encodeEvent, formatDate } from "./events.js";
|
|
3
3
|
import { saidify } from "./said.js";
|
|
4
4
|
export function query(args) {
|
|
@@ -30,7 +30,7 @@ export function exchange(args) {
|
|
|
30
30
|
for (const [key, message] of Object.entries(args.embeds ?? {})) {
|
|
31
31
|
embeds[key] = message.body;
|
|
32
32
|
attachments.PathedMaterialCouples.push({
|
|
33
|
-
path:
|
|
33
|
+
path: `-${["e", key].join("-")}`,
|
|
34
34
|
attachments: message.attachments,
|
|
35
35
|
grouped: true,
|
|
36
36
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"routed-event.js","sourceRoot":"","sources":["../../src/core/routed-event.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,OAAO,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"routed-event.js","sourceRoot":"","sources":["../../src/core/routed-event.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC;AACvD,OAAO,EAAE,aAAa,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACrE,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AA4CpC,MAAM,UAAU,KAAK,CAAC,IAAoB;IACxC,MAAM,IAAI,GAAG,WAAW,CAAiB;QACvC,CAAC,EAAE,aAAa;QAChB,CAAC,EAAE,KAAK;QACR,CAAC,EAAE,EAAE;QACL,EAAE,EAAE,UAAU,CAAC,IAAI,CAAC,EAAE,IAAI,IAAI,IAAI,EAAE,CAAC;QACrC,CAAC,EAAE,IAAI,CAAC,CAAC,IAAI,EAAE;QACf,EAAE,EAAE,IAAI,CAAC,EAAE,IAAI,EAAE;QACjB,CAAC,EAAE,IAAI,CAAC,CAAC;KACV,CAAC,CAAC;IAEH,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;AAC3B,CAAC;AAED,MAAM,UAAU,KAAK,CAAC,IAAoB;IACxC,MAAM,IAAI,GAAG,WAAW,CAAiB;QACvC,CAAC,EAAE,aAAa;QAChB,CAAC,EAAE,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AAE,IAAI,CAAC,MAAM,IAAI,EAAE;QACpB,CAAC,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,OAAO,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE;KAC7C,CAAC,CAAC;IAEH,OAAO,IAAI,OAAO,CAAC,IAAI,EAAE,WAAW,CAAC,CAAC;AACxC,CAAC"}
|
package/dist/core/said.js
CHANGED
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
import { blake3 } from "@noble/hashes/blake3.js";
|
|
2
|
-
import {
|
|
2
|
+
import { encodeText, Matter } from "../cesr/main.js";
|
|
3
3
|
function calculateSaid(event) {
|
|
4
|
-
const digest =
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
4
|
+
const digest = encodeText(new Matter({
|
|
5
|
+
code: Matter.Code.Blake3_256,
|
|
6
|
+
raw: blake3
|
|
7
|
+
.create({ dkLen: 32 })
|
|
8
|
+
.update(new TextEncoder().encode(JSON.stringify(event)))
|
|
9
|
+
.digest(),
|
|
10
|
+
}));
|
|
11
|
+
return digest;
|
|
9
12
|
}
|
|
10
13
|
export function saidify(event, labels) {
|
|
11
14
|
if (!labels?.length) {
|
package/dist/core/said.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"said.js","sourceRoot":"","sources":["../../src/core/said.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,yBAAyB,CAAC;AACjD,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"said.js","sourceRoot":"","sources":["../../src/core/said.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,yBAAyB,CAAC;AACjD,OAAO,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AAErD,SAAS,aAAa,CAAC,KAA8B;IACnD,MAAM,MAAM,GAAG,UAAU,CACvB,IAAI,MAAM,CAAC;QACT,IAAI,EAAE,MAAM,CAAC,IAAI,CAAC,UAAU;QAC5B,GAAG,EAAE,MAAM;aACR,MAAM,CAAC,EAAE,KAAK,EAAE,EAAE,EAAE,CAAC;aACrB,MAAM,CAAC,IAAI,WAAW,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,CAAC;aACvD,MAAM,EAAE;KACZ,CAAC,CACH,CAAC;IACF,OAAO,MAAM,CAAC;AAChB,CAAC;AAMD,MAAM,UAAU,OAAO,CAAoC,KAAQ,EAAE,MAAiB;IACpF,IAAI,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC;QACpB,OAAO,KAAK,CAAC;IACf,CAAC;IAED,MAAM,MAAM,GAAG,aAAa,CAAC,KAAK,CAAC,CAAC;IACpC,MAAM,MAAM,GAA4B,EAAE,CAAC;IAE3C,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;QACjD,IAAI,MAAM,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE,CAAC;YACzB,MAAM,CAAC,GAAG,CAAC,GAAG,MAAM,CAAC;QACvB,CAAC;aAAM,CAAC;YACN,MAAM,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC;QACtB,CAAC;IACH,CAAC;IAED,OAAO,MAAW,CAAC;AACrB,CAAC"}
|
package/dist/core/sign.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { ed25519 } from "@noble/curves/ed25519.js";
|
|
2
|
-
import {
|
|
2
|
+
import { encodeText, Indexer, Matter } from "../cesr/main.js";
|
|
3
3
|
export function sign(payload, options) {
|
|
4
4
|
const signature = ed25519.sign(payload, options.key);
|
|
5
5
|
if (options.index !== undefined && options.index !== null) {
|
|
6
|
-
return Indexer.crypto.ed25519_sig(signature, options.index)
|
|
6
|
+
return encodeText(Indexer.crypto.ed25519_sig(signature, options.index));
|
|
7
7
|
}
|
|
8
|
-
return
|
|
8
|
+
return encodeText(Matter.crypto.ed25519_sig(signature));
|
|
9
9
|
}
|
|
10
10
|
//# sourceMappingURL=sign.js.map
|
package/dist/core/sign.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sign.js","sourceRoot":"","sources":["../../src/core/sign.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,0BAA0B,CAAC;AACnD,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"sign.js","sourceRoot":"","sources":["../../src/core/sign.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,0BAA0B,CAAC;AACnD,OAAO,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AAO9D,MAAM,UAAU,IAAI,CAAC,OAAmB,EAAE,OAAoB;IAC5D,MAAM,SAAS,GAAG,OAAO,CAAC,IAAI,CAAC,OAAO,EAAE,OAAO,CAAC,GAAG,CAAC,CAAC;IAErD,IAAI,OAAO,CAAC,KAAK,KAAK,SAAS,IAAI,OAAO,CAAC,KAAK,KAAK,IAAI,EAAE,CAAC;QAC1D,OAAO,UAAU,CAAC,OAAO,CAAC,MAAM,CAAC,WAAW,CAAC,SAAS,EAAE,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC;IAC1E,CAAC;IAED,OAAO,UAAU,CAAC,MAAM,CAAC,MAAM,CAAC,WAAW,CAAC,SAAS,CAAC,CAAC,CAAC;AAC1D,CAAC"}
|
package/dist/core/verify.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { Matter } from "../cesr/main.ts";
|
|
1
2
|
import { type Threshold } from "./threshold.ts";
|
|
2
3
|
export interface VerifyOptions {
|
|
3
4
|
threshold: Threshold;
|
|
@@ -6,9 +7,17 @@ export interface VerifyOptions {
|
|
|
6
7
|
}
|
|
7
8
|
export type VerifyResult = {
|
|
8
9
|
ok: true;
|
|
10
|
+
error?: null;
|
|
9
11
|
} | {
|
|
10
12
|
ok: false;
|
|
11
13
|
error: string;
|
|
12
14
|
};
|
|
13
|
-
export declare function
|
|
14
|
-
export declare function
|
|
15
|
+
export declare function verifySignature(payload: Uint8Array, key: Matter, sig: Uint8Array): boolean;
|
|
16
|
+
export declare function verifyThreshold(payload: Uint8Array, options: VerifyOptions): VerifyResult;
|
|
17
|
+
export declare function verifyThresholdOrThrow(payload: Uint8Array, options: VerifyOptions): void;
|
|
18
|
+
/**
|
|
19
|
+
* Validates that every signature present is cryptographically valid for its key,
|
|
20
|
+
* but does NOT check that the threshold is met.
|
|
21
|
+
*/
|
|
22
|
+
export declare function verifySignatures(payload: Uint8Array, options: VerifyOptions): VerifyResult;
|
|
23
|
+
export declare function verifySignaturesOrThrow(payload: Uint8Array, options: VerifyOptions): void;
|
package/dist/core/verify.js
CHANGED
|
@@ -1,20 +1,16 @@
|
|
|
1
1
|
import { ed25519 } from "@noble/curves/ed25519.js";
|
|
2
|
-
import { Indexer, Matter } from "cesr";
|
|
2
|
+
import { Indexer, Matter } from "../cesr/main.js";
|
|
3
3
|
import { parseThreshold } from "./threshold.js";
|
|
4
|
-
function verifySignature(payload, key, sig) {
|
|
4
|
+
export function verifySignature(payload, key, sig) {
|
|
5
5
|
switch (key.code) {
|
|
6
6
|
case Matter.Code.Ed25519:
|
|
7
7
|
case Matter.Code.Ed25519N:
|
|
8
|
-
|
|
9
|
-
// We can check the code of the signature,
|
|
10
|
-
// but it does not really matter since it will be verified correctly regardless.
|
|
11
|
-
// Anyway, revisit later
|
|
12
|
-
return ed25519.verify(sig.raw, payload, key.raw);
|
|
8
|
+
return ed25519.verify(sig, payload, key.raw);
|
|
13
9
|
default:
|
|
14
10
|
throw new Error(`Unsupported key code: ${key.code}`);
|
|
15
11
|
}
|
|
16
12
|
}
|
|
17
|
-
export function
|
|
13
|
+
export function verifyThreshold(payload, options) {
|
|
18
14
|
const keys = options.keys.map((key) => Matter.parse(key));
|
|
19
15
|
const sigs = options.sigs.map((sig) => Indexer.parse(sig));
|
|
20
16
|
const threshold = parseThreshold(options.threshold, options.keys.length);
|
|
@@ -24,7 +20,7 @@ export function verify(payload, options) {
|
|
|
24
20
|
if (!sig) {
|
|
25
21
|
continue;
|
|
26
22
|
}
|
|
27
|
-
if (!verifySignature(payload, keys[idx], sig)) {
|
|
23
|
+
if (!verifySignature(payload, keys[idx], sig.raw)) {
|
|
28
24
|
return { ok: false, error: `Invalid signature for key at index ${idx}` };
|
|
29
25
|
}
|
|
30
26
|
sum += threshold.weights[idx];
|
|
@@ -34,8 +30,31 @@ export function verify(payload, options) {
|
|
|
34
30
|
}
|
|
35
31
|
return { ok: true };
|
|
36
32
|
}
|
|
37
|
-
export function
|
|
38
|
-
const result =
|
|
33
|
+
export function verifyThresholdOrThrow(payload, options) {
|
|
34
|
+
const result = verifyThreshold(payload, options);
|
|
35
|
+
if (!result.ok) {
|
|
36
|
+
throw new Error(result.error);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Validates that every signature present is cryptographically valid for its key,
|
|
41
|
+
* but does NOT check that the threshold is met.
|
|
42
|
+
*/
|
|
43
|
+
export function verifySignatures(payload, options) {
|
|
44
|
+
const keys = options.keys.map((key) => Matter.parse(key));
|
|
45
|
+
const sigs = options.sigs.map((sig) => Indexer.parse(sig));
|
|
46
|
+
for (let idx = 0; idx < keys.length; idx++) {
|
|
47
|
+
const sig = sigs.find((s) => s.index === idx);
|
|
48
|
+
if (!sig)
|
|
49
|
+
continue;
|
|
50
|
+
if (!verifySignature(payload, keys[idx], sig.raw)) {
|
|
51
|
+
return { ok: false, error: `Invalid signature for key at index ${idx}` };
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
return { ok: true };
|
|
55
|
+
}
|
|
56
|
+
export function verifySignaturesOrThrow(payload, options) {
|
|
57
|
+
const result = verifySignatures(payload, options);
|
|
39
58
|
if (!result.ok) {
|
|
40
59
|
throw new Error(result.error);
|
|
41
60
|
}
|
package/dist/core/verify.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"verify.js","sourceRoot":"","sources":["../../src/core/verify.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,0BAA0B,CAAC;AACnD,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"verify.js","sourceRoot":"","sources":["../../src/core/verify.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,0BAA0B,CAAC;AACnD,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AAClD,OAAO,EAAE,cAAc,EAAkB,MAAM,gBAAgB,CAAC;AAkBhE,MAAM,UAAU,eAAe,CAAC,OAAmB,EAAE,GAAW,EAAE,GAAe;IAC/E,QAAQ,GAAG,CAAC,IAAI,EAAE,CAAC;QACjB,KAAK,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC;QACzB,KAAK,MAAM,CAAC,IAAI,CAAC,QAAQ;YACvB,OAAO,OAAO,CAAC,MAAM,CAAC,GAAG,EAAE,OAAO,EAAE,GAAG,CAAC,GAAG,CAAC,CAAC;QAC/C;YACE,MAAM,IAAI,KAAK,CAAC,yBAAyB,GAAG,CAAC,IAAI,EAAE,CAAC,CAAC;IACzD,CAAC;AACH,CAAC;AAED,MAAM,UAAU,eAAe,CAAC,OAAmB,EAAE,OAAsB;IACzE,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC;IAC1D,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC;IAC3D,MAAM,SAAS,GAAG,cAAc,CAAC,OAAO,CAAC,SA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AAO,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC;IAC1D,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC;IAE3D,KAAK,IAAI,GAAG,GAAG,CAAC,EAAE,GAAG,GAAG,IAAI,CAAC,MAAM,EAAE,GAAG,EAAE,EAAE,CAAC;QAC3C,MAAM,GAAG,GAAG,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,KAAK,KAAK,GAAG,CAAC,CAAC;QAC9C,IAAI,CAAC,GAAG;YAAE,SAAS;QACnB,IAAI,CAAC,eAAe,CAAC,OAAO,EAAE,IAAI,CAAC,GAAG,CAAC,EAAE,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC;YAClD,OAAO,EAAE,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE,sCAAsC,GAAG,EAAE,EAAE,CAAC;QAC3E,CAAC;IACH,CAAC;IAED,OAAO,EAAE,EAAE,EAAE,IAAI,EAAE,CAAC;AACtB,CAAC;AAED,MAAM,UAAU,uBAAuB,CAAC,OAAmB,EAAE,OAAsB;IACjF,MAAM,MAAM,GAAG,gBAAgB,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;IAClD,IAAI,CAAC,MAAM,CAAC,EAAE,EAAE,CAAC;QACf,MAAM,IAAI,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IAChC,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { type Message } from "../cesr/main.ts";
|
|
2
|
+
import type { KeyEventBody } from "./key-event.ts";
|
|
3
|
+
import type { ReceiptEvent } from "./receipt-event.ts";
|
|
4
|
+
export declare class WitnessClient {
|
|
5
|
+
#private;
|
|
6
|
+
constructor(url: string, fetch?: typeof globalThis.fetch);
|
|
7
|
+
receipt(event: Message<KeyEventBody>): Promise<ReceiptEvent>;
|
|
8
|
+
}
|