keri 0.0.0-dev.0ddd65e → 0.0.0-dev.3258b67
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/__main__.d.ts +10 -0
- package/dist/cesr/__main__.js +11 -0
- package/dist/cesr/__main__.js.map +1 -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 +273 -0
- package/dist/cesr/attachments-reader.js.map +1 -0
- package/dist/cesr/attachments.d.ts +68 -0
- package/dist/cesr/attachments.js +116 -0
- package/dist/cesr/attachments.js.map +1 -0
- package/dist/cesr/codec.d.ts +26 -0
- package/dist/cesr/codec.js +26 -0
- package/dist/cesr/codec.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 +117 -0
- package/dist/cesr/counter.js +93 -0
- package/dist/cesr/counter.js.map +1 -0
- package/dist/cesr/frame.d.ts +36 -0
- package/dist/cesr/frame.js +97 -0
- package/dist/cesr/frame.js.map +1 -0
- package/dist/cesr/genus.d.ts +21 -0
- package/dist/cesr/genus.js +66 -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 +59 -0
- package/dist/cesr/groups/generic-map.js.map +1 -0
- package/dist/cesr/indexer.d.ts +70 -0
- package/dist/cesr/indexer.js +177 -0
- package/dist/cesr/indexer.js.map +1 -0
- package/dist/cesr/matter.d.ts +163 -0
- package/dist/cesr/matter.js +311 -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 +137 -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 +147 -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.js +19 -0
- package/dist/cli/node-cli.js.map +1 -0
- package/dist/controller/controller.d.ts +111 -0
- package/dist/controller/controller.js +549 -0
- package/dist/controller/controller.js.map +1 -0
- package/dist/controller/encrypt.d.ts +45 -0
- package/dist/controller/encrypt.js +120 -0
- package/dist/controller/encrypt.js.map +1 -0
- package/dist/core/credential-event.d.ts +58 -0
- package/dist/core/credential-event.js +28 -0
- package/dist/core/credential-event.js.map +1 -0
- package/dist/core/credential.d.ts +79 -0
- package/dist/core/credential.js +25 -0
- package/dist/core/credential.js.map +1 -0
- package/dist/core/digest.d.ts +1 -0
- package/dist/core/digest.js +7 -0
- package/dist/core/digest.js.map +1 -0
- package/dist/core/endpoint-discovery.d.ts +20 -0
- package/dist/core/endpoint-discovery.js +60 -0
- package/dist/core/endpoint-discovery.js.map +1 -0
- package/dist/core/events.d.ts +12 -0
- package/dist/core/events.js +25 -0
- package/dist/core/events.js.map +1 -0
- package/dist/core/kawa.d.ts +17 -0
- package/dist/core/kawa.js +87 -0
- package/dist/core/kawa.js.map +1 -0
- package/dist/core/key-event-log.d.ts +13 -0
- package/dist/core/key-event-log.js +153 -0
- package/dist/core/key-event-log.js.map +1 -0
- package/dist/core/key-event.d.ts +96 -0
- package/dist/core/key-event.js +88 -0
- package/dist/core/key-event.js.map +1 -0
- package/dist/core/keys.d.ts +9 -0
- package/dist/core/keys.js +17 -0
- package/dist/core/keys.js.map +1 -0
- package/dist/core/mailbox-client.d.ts +23 -0
- package/dist/core/mailbox-client.js +59 -0
- package/dist/core/mailbox-client.js.map +1 -0
- package/dist/core/main.d.ts +51 -0
- package/dist/core/main.js +43 -0
- package/dist/core/main.js.map +1 -0
- package/dist/core/receipt-event.d.ts +15 -0
- package/dist/core/receipt-event.js +13 -0
- package/dist/core/receipt-event.js.map +1 -0
- package/dist/core/registry-event.d.ts +28 -0
- package/dist/core/registry-event.js +18 -0
- package/dist/core/registry-event.js.map +1 -0
- package/dist/core/routed-event.d.ts +73 -0
- package/dist/core/routed-event.js +53 -0
- package/dist/core/routed-event.js.map +1 -0
- package/dist/core/said.d.ts +4 -0
- package/dist/core/said.js +26 -0
- package/dist/core/said.js.map +1 -0
- package/dist/core/sign.d.ts +5 -0
- package/dist/core/sign.js +10 -0
- package/dist/core/sign.js.map +1 -0
- package/dist/core/threshold.d.ts +6 -0
- package/dist/core/threshold.js +58 -0
- package/dist/core/threshold.js.map +1 -0
- package/dist/core/verify.d.ts +15 -0
- package/dist/core/verify.js +43 -0
- package/dist/core/verify.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/utf8.d.ts +2 -0
- package/dist/encoding/utf8.js +9 -0
- package/dist/encoding/utf8.js.map +1 -0
- package/dist/main.d.ts +3 -2
- package/dist/main.js +4 -2
- package/dist/main.js.map +1 -0
- package/dist/storage/sqlite/node-sqlite.d.ts +12 -0
- package/dist/storage/sqlite/node-sqlite.js +25 -0
- package/dist/storage/sqlite/node-sqlite.js.map +1 -0
- package/dist/storage/sqlite/schema.d.ts +2 -0
- package/dist/storage/sqlite/schema.js +49 -0
- package/dist/storage/sqlite/schema.js.map +1 -0
- package/dist/storage/sqlite/sqlite-database.d.ts +13 -0
- package/dist/storage/sqlite/sqlite-database.js +2 -0
- package/dist/storage/sqlite/sqlite-database.js.map +1 -0
- package/dist/storage/sqlite/storage-sqlite.d.ts +26 -0
- package/dist/storage/sqlite/storage-sqlite.js +213 -0
- package/dist/storage/sqlite/storage-sqlite.js.map +1 -0
- package/dist/witness/app.d.ts +9 -0
- package/dist/witness/app.js +91 -0
- package/dist/witness/app.js.map +1 -0
- package/dist/witness/env.d.ts +1 -0
- package/dist/witness/env.js +8 -0
- package/dist/witness/env.js.map +1 -0
- package/dist/witness/event-storage.d.ts +8 -0
- package/dist/witness/event-storage.js +2 -0
- package/dist/witness/event-storage.js.map +1 -0
- package/dist/witness/local.js +48 -0
- package/dist/witness/local.js.map +1 -0
- package/dist/witness/main.d.ts +6 -0
- package/dist/witness/main.js +4 -0
- package/dist/witness/main.js.map +1 -0
- package/dist/witness/parser.d.ts +3 -0
- package/dist/witness/parser.js +7 -0
- package/dist/witness/parser.js.map +1 -0
- package/dist/witness/seed.d.ts +1 -0
- package/dist/witness/seed.js +5 -0
- package/dist/witness/seed.js.map +1 -0
- package/dist/witness/witness.d.ts +16 -0
- package/dist/witness/witness.js +59 -0
- package/dist/witness/witness.js.map +1 -0
- package/package.json +46 -26
- package/dist/cli/main.js +0 -72
- package/dist/data-type.d.ts +0 -9
- package/dist/db/event-store.d.ts +0 -20
- package/dist/db/event-store.js +0 -1
- package/dist/db/sqlite-db.d.ts +0 -13
- package/dist/db/sqlite-db.js +0 -123
- package/dist/events/common.d.ts +0 -6
- package/dist/events/common.js +0 -1
- package/dist/events/incept.d.ts +0 -26
- package/dist/events/incept.js +0 -28
- package/dist/events/interact.d.ts +0 -17
- package/dist/events/interact.js +0 -21
- package/dist/events/main.d.ts +0 -4
- package/dist/events/main.js +0 -4
- package/dist/events/reply.d.ts +0 -15
- package/dist/events/reply.js +0 -20
- package/dist/keri/habitat.d.ts +0 -20
- package/dist/keri/habitat.js +0 -130
- package/dist/keri/keri.d.ts +0 -26
- package/dist/keri/keri.js +0 -43
- package/dist/keystore/encrypt.d.ts +0 -2
- package/dist/keystore/encrypt.js +0 -38
- package/dist/keystore/keystore-fs.d.ts +0 -13
- package/dist/keystore/keystore-fs.js +0 -50
- package/dist/keystore/keystore-web.d.ts +0 -12
- package/dist/keystore/keystore-web.js +0 -48
- package/dist/keystore/keystore.d.ts +0 -15
- package/dist/keystore/keystore.js +0 -1
- package/dist/main-common.d.ts +0 -9
- package/dist/main-common.js +0 -8
- package/dist/main-web.d.ts +0 -2
- package/dist/main-web.js +0 -2
- package/dist/parser/base64.d.ts +0 -6
- package/dist/parser/base64.js +0 -74
- package/dist/parser/buffered-reader.d.ts +0 -5
- package/dist/parser/buffered-reader.js +0 -47
- package/dist/parser/cesr-encoding.d.ts +0 -34
- package/dist/parser/cesr-encoding.js +0 -158
- package/dist/parser/codes.d.ts +0 -143
- package/dist/parser/codes.js +0 -266
- package/dist/parser/parser.d.ts +0 -16
- package/dist/parser/parser.js +0 -161
- package/dist/parser/version.d.ts +0 -11
- package/dist/parser/version.js +0 -56
- /package/dist/cli/{main.d.ts → node-cli.d.ts} +0 -0
- /package/dist/{data-type.js → witness/local.d.ts} +0 -0
package/package.json
CHANGED
|
@@ -1,45 +1,65 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "keri",
|
|
3
|
-
"version": "0.0.0-dev.
|
|
3
|
+
"version": "0.0.0-dev.3258b67",
|
|
4
|
+
"repository": {
|
|
5
|
+
"type": "git",
|
|
6
|
+
"url": "git+https://github.com/lenkan/keri-js.git"
|
|
7
|
+
},
|
|
4
8
|
"scripts": {
|
|
5
|
-
"lint": "eslint && prettier --check . && tsc --noEmit",
|
|
6
|
-
"lint:fix": "eslint --fix && prettier --write .",
|
|
7
9
|
"build": "tsc -p tsconfig.build.json",
|
|
8
|
-
"
|
|
9
|
-
"
|
|
10
|
+
"dev": "tsc -p tsconfig.build.json --watch",
|
|
11
|
+
"test": "node --test --no-warnings 'src/**/*.test.ts'",
|
|
12
|
+
"test:integration": "node --test --no-warnings 'test_integration/**/*.test.ts'",
|
|
13
|
+
"test:interop": "node --no-warnings scripts/run-scripts.ts",
|
|
14
|
+
"test:vector": "node --test --no-warnings 'test_vectors/**/*.test.ts'",
|
|
15
|
+
"lint": "biome check .",
|
|
16
|
+
"lint:fix": "biome check --write .",
|
|
17
|
+
"check": "tsc --noEmit",
|
|
18
|
+
"clean": "node scripts/clean.ts",
|
|
19
|
+
"format": "biome format --write .",
|
|
20
|
+
"docs:build": "typedoc",
|
|
21
|
+
"docs:serve": "concurrently \"serve docs\" \"typedoc --watch --preserveWatchOutput\""
|
|
10
22
|
},
|
|
11
|
-
"
|
|
12
|
-
"keri": "./
|
|
23
|
+
"imports": {
|
|
24
|
+
"#keri/*": "./src/*"
|
|
13
25
|
},
|
|
14
26
|
"exports": {
|
|
15
27
|
".": "./dist/main.js",
|
|
16
|
-
"./
|
|
28
|
+
"./sqlite-storage": "./dist/storage/sqlite/storage-sqlite.js",
|
|
29
|
+
"./witness": "./dist/witness/main.js",
|
|
30
|
+
"./witness/local": "./dist/witness/local.js"
|
|
17
31
|
},
|
|
18
32
|
"files": [
|
|
19
33
|
"dist"
|
|
20
34
|
],
|
|
21
35
|
"type": "module",
|
|
22
|
-
"author": "",
|
|
23
|
-
"license": "
|
|
24
|
-
"description": "",
|
|
36
|
+
"author": "Daniel Lenksjö",
|
|
37
|
+
"license": "Apache-2.0",
|
|
38
|
+
"description": "KERI for JavaScript",
|
|
39
|
+
"devEngines": {
|
|
40
|
+
"runtime": {
|
|
41
|
+
"name": "node",
|
|
42
|
+
"version": ">=24",
|
|
43
|
+
"onFail": "warn"
|
|
44
|
+
}
|
|
45
|
+
},
|
|
25
46
|
"engines": {
|
|
26
47
|
"node": ">=22"
|
|
27
48
|
},
|
|
28
|
-
"devDependencies": {
|
|
29
|
-
"@eslint/js": "^9.17.0",
|
|
30
|
-
"@types/node": "^22.9.1",
|
|
31
|
-
"commander": "^12.1.0",
|
|
32
|
-
"eslint": "^9.17.0",
|
|
33
|
-
"eslint-config-prettier": "^9.1.0",
|
|
34
|
-
"globals": "^15.12.0",
|
|
35
|
-
"prettier": "^3.3.3",
|
|
36
|
-
"typescript": "^5.7.3",
|
|
37
|
-
"typescript-eslint": "^8.19.0"
|
|
38
|
-
},
|
|
39
49
|
"dependencies": {
|
|
40
|
-
"@
|
|
41
|
-
"@noble/
|
|
42
|
-
"@noble/
|
|
43
|
-
"@noble/
|
|
50
|
+
"@hono/node-server": "^1.19.5",
|
|
51
|
+
"@noble/curves": "^2.0.0",
|
|
52
|
+
"@noble/ed25519": "^3.0.0",
|
|
53
|
+
"@noble/hashes": "^2.0.0",
|
|
54
|
+
"@noble/secp256k1": "^3.0.0",
|
|
55
|
+
"hono": "^4.9.9"
|
|
56
|
+
},
|
|
57
|
+
"devDependencies": {
|
|
58
|
+
"@biomejs/biome": "^2.4.9",
|
|
59
|
+
"@types/node": "^22.15.30",
|
|
60
|
+
"concurrently": "^9.2.1",
|
|
61
|
+
"serve": "^14.2.5",
|
|
62
|
+
"typedoc": "^0.28.14",
|
|
63
|
+
"typescript": "^6.0.2"
|
|
44
64
|
}
|
|
45
65
|
}
|
package/dist/cli/main.js
DELETED
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
import { program } from "commander";
|
|
3
|
-
import { parse } from "../parser/parser.js";
|
|
4
|
-
import { FileSystemKeyStore } from "../keystore/keystore-fs.js";
|
|
5
|
-
import { SqliteEventStore } from "../db/sqlite-db.js";
|
|
6
|
-
import { Habitat } from "../keri/habitat.js";
|
|
7
|
-
const db = new SqliteEventStore({ filename: ".keri/db.sqlite" });
|
|
8
|
-
db.init();
|
|
9
|
-
program.command("parse").action(async () => {
|
|
10
|
-
const stream = process.stdin;
|
|
11
|
-
for await (const event of parse(ReadableStream.from(stream))) {
|
|
12
|
-
console.log(event);
|
|
13
|
-
}
|
|
14
|
-
});
|
|
15
|
-
program
|
|
16
|
-
.command("keygen")
|
|
17
|
-
.requiredOption("--passcode <passcode>")
|
|
18
|
-
.action(async ({ passcode }) => {
|
|
19
|
-
const keystore = new FileSystemKeyStore({ dir: ".keri/keys", passphrase: passcode });
|
|
20
|
-
await keystore.incept();
|
|
21
|
-
});
|
|
22
|
-
program.command("resolve <oobi>").action(async (oobi) => {
|
|
23
|
-
const response = await fetch(oobi);
|
|
24
|
-
if (!response.ok) {
|
|
25
|
-
throw new Error(`Failed to fetch oobi: ${response.status} ${response.statusText}`);
|
|
26
|
-
}
|
|
27
|
-
if (!response.body) {
|
|
28
|
-
throw new Error(`No body in response`);
|
|
29
|
-
}
|
|
30
|
-
for await (const event of parse(response.body)) {
|
|
31
|
-
db.saveEvent(event.payload);
|
|
32
|
-
}
|
|
33
|
-
});
|
|
34
|
-
program
|
|
35
|
-
.command("incept")
|
|
36
|
-
.requiredOption("--passcode <passcode>")
|
|
37
|
-
.option("--wit <wit>")
|
|
38
|
-
.action(async ({ passcode, wit }) => {
|
|
39
|
-
if (typeof passcode !== "string") {
|
|
40
|
-
throw new Error(`Invalid passcode`);
|
|
41
|
-
}
|
|
42
|
-
const keystore = new FileSystemKeyStore({ dir: ".keri/keys", passphrase: passcode });
|
|
43
|
-
const hab = new Habitat({ db, keystore });
|
|
44
|
-
const wits = [];
|
|
45
|
-
if (typeof wit === "string") {
|
|
46
|
-
wits.push(wit);
|
|
47
|
-
}
|
|
48
|
-
const result = await hab.create({ wits });
|
|
49
|
-
console.dir(result);
|
|
50
|
-
});
|
|
51
|
-
program
|
|
52
|
-
.command("interact")
|
|
53
|
-
.requiredOption("--passcode <passcode>")
|
|
54
|
-
.requiredOption("--aid <aid>")
|
|
55
|
-
.action(async ({ passcode, aid }) => {
|
|
56
|
-
if (typeof passcode !== "string") {
|
|
57
|
-
throw new Error(`Invalid passcode`);
|
|
58
|
-
}
|
|
59
|
-
if (typeof aid !== "string") {
|
|
60
|
-
throw new Error(`Invalid aid`);
|
|
61
|
-
}
|
|
62
|
-
const keystore = new FileSystemKeyStore({ dir: ".keri/keys", passphrase: passcode });
|
|
63
|
-
const hab = new Habitat({ db, keystore });
|
|
64
|
-
const payload = await hab.interact(aid);
|
|
65
|
-
console.dir(payload);
|
|
66
|
-
});
|
|
67
|
-
program.command("export").action(async () => {
|
|
68
|
-
for (const event of await db.list()) {
|
|
69
|
-
console.log(event);
|
|
70
|
-
}
|
|
71
|
-
});
|
|
72
|
-
program.parse(process.argv);
|
package/dist/data-type.d.ts
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
export type DataValue = string | number | boolean | DataObject | DataArray;
|
|
2
|
-
export type DataArray = DataValue[];
|
|
3
|
-
/**
|
|
4
|
-
* Defines a data object that can be serialized to JSON.
|
|
5
|
-
* E.g. key events and acdc objects
|
|
6
|
-
*/
|
|
7
|
-
export interface DataObject {
|
|
8
|
-
[x: string]: DataValue;
|
|
9
|
-
}
|
package/dist/db/event-store.d.ts
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import type { KeyEvent } from "../events/main.ts";
|
|
2
|
-
export interface KeyEventMessage<T extends KeyEvent = KeyEvent> {
|
|
3
|
-
event: T;
|
|
4
|
-
attachments: KeyEventAttachment[];
|
|
5
|
-
}
|
|
6
|
-
export interface ListArgs {
|
|
7
|
-
i?: string;
|
|
8
|
-
d?: string;
|
|
9
|
-
t?: string;
|
|
10
|
-
r?: string;
|
|
11
|
-
}
|
|
12
|
-
export interface KeyEventAttachment {
|
|
13
|
-
code: string;
|
|
14
|
-
value: string;
|
|
15
|
-
}
|
|
16
|
-
export interface EventStore {
|
|
17
|
-
list(args?: ListArgs): Promise<KeyEventMessage[]>;
|
|
18
|
-
saveEvent(event: KeyEvent): Promise<void>;
|
|
19
|
-
saveAttachment(eventId: string, attachment: KeyEventAttachment): Promise<void>;
|
|
20
|
-
}
|
package/dist/db/event-store.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
package/dist/db/sqlite-db.d.ts
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import type { KeyEvent } from "../events/main.ts";
|
|
2
|
-
import type { EventStore, KeyEventAttachment, KeyEventMessage, ListArgs } from "./event-store.ts";
|
|
3
|
-
export interface SqliteEventStoreOptions {
|
|
4
|
-
filename?: string;
|
|
5
|
-
}
|
|
6
|
-
export declare class SqliteEventStore implements EventStore {
|
|
7
|
-
#private;
|
|
8
|
-
constructor(options?: SqliteEventStoreOptions);
|
|
9
|
-
init(): void;
|
|
10
|
-
saveEvent(event: KeyEvent): Promise<void>;
|
|
11
|
-
saveAttachment(id: string, attachment: KeyEventAttachment): Promise<void>;
|
|
12
|
-
list(args?: ListArgs): Promise<KeyEventMessage[]>;
|
|
13
|
-
}
|
package/dist/db/sqlite-db.js
DELETED
|
@@ -1,123 +0,0 @@
|
|
|
1
|
-
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
|
|
2
|
-
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
3
|
-
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
4
|
-
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
5
|
-
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
6
|
-
};
|
|
7
|
-
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
8
|
-
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
9
|
-
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
10
|
-
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
11
|
-
};
|
|
12
|
-
var _SqliteEventStore_db;
|
|
13
|
-
import { DatabaseSync } from "node:sqlite";
|
|
14
|
-
import { existsSync, mkdirSync } from "node:fs";
|
|
15
|
-
import { dirname } from "node:path";
|
|
16
|
-
function parseRow(row) {
|
|
17
|
-
if (!row || typeof row !== "object") {
|
|
18
|
-
throw new Error(`Row not found`);
|
|
19
|
-
}
|
|
20
|
-
const data = "event_data" in row && row["event_data"];
|
|
21
|
-
if (!data || typeof data !== "string") {
|
|
22
|
-
throw new Error(`Unexpected row format`);
|
|
23
|
-
}
|
|
24
|
-
if ("attachments" in row && typeof row["attachments"] !== "string") {
|
|
25
|
-
throw new Error(`Unexpected row format`);
|
|
26
|
-
}
|
|
27
|
-
const attachments = JSON.parse(row["attachments"] || "[]");
|
|
28
|
-
if (!Array.isArray(attachments)) {
|
|
29
|
-
throw new Error(`Unexpected row format`);
|
|
30
|
-
}
|
|
31
|
-
return {
|
|
32
|
-
event: JSON.parse(data),
|
|
33
|
-
attachments: attachments.filter((att) => att.code && att.value),
|
|
34
|
-
};
|
|
35
|
-
}
|
|
36
|
-
function ensureDirSync(filename) {
|
|
37
|
-
const dir = dirname(filename);
|
|
38
|
-
if (!existsSync(dir)) {
|
|
39
|
-
mkdirSync(dir);
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
export class SqliteEventStore {
|
|
43
|
-
constructor(options = {}) {
|
|
44
|
-
_SqliteEventStore_db.set(this, void 0);
|
|
45
|
-
if (options.filename) {
|
|
46
|
-
ensureDirSync(options.filename);
|
|
47
|
-
}
|
|
48
|
-
__classPrivateFieldSet(this, _SqliteEventStore_db, new DatabaseSync(options.filename ?? ":memory:"), "f");
|
|
49
|
-
}
|
|
50
|
-
init() {
|
|
51
|
-
__classPrivateFieldGet(this, _SqliteEventStore_db, "f").exec(`
|
|
52
|
-
CREATE TABLE IF NOT EXISTS events (
|
|
53
|
-
event_id TEXT PRIMARY KEY,
|
|
54
|
-
event_data JSON NOT NULL
|
|
55
|
-
);
|
|
56
|
-
`);
|
|
57
|
-
__classPrivateFieldGet(this, _SqliteEventStore_db, "f").exec(`
|
|
58
|
-
CREATE TABLE IF NOT EXISTS attachments (
|
|
59
|
-
event_id TEXT NOT NULL,
|
|
60
|
-
attachment_code TEXT NOT NULL,
|
|
61
|
-
attachment_value TEXT NOT NULL,
|
|
62
|
-
FOREIGN KEY(event_id) REFERENCES events(event_id)
|
|
63
|
-
PRIMARY KEY(event_id, attachment_code, attachment_value)
|
|
64
|
-
);
|
|
65
|
-
`);
|
|
66
|
-
}
|
|
67
|
-
async saveEvent(event) {
|
|
68
|
-
const sql = `
|
|
69
|
-
INSERT INTO events (event_id, event_data)
|
|
70
|
-
VALUES ($id, $data) ON CONFLICT(event_id) DO NOTHING;
|
|
71
|
-
`;
|
|
72
|
-
__classPrivateFieldGet(this, _SqliteEventStore_db, "f").prepare(sql).run({
|
|
73
|
-
id: event.d,
|
|
74
|
-
data: JSON.stringify(event),
|
|
75
|
-
});
|
|
76
|
-
}
|
|
77
|
-
async saveAttachment(id, attachment) {
|
|
78
|
-
const sql = `
|
|
79
|
-
INSERT INTO attachments (event_id, attachment_code, attachment_value)
|
|
80
|
-
VALUES ($id, $group, $data)
|
|
81
|
-
ON CONFLICT(event_id, attachment_code, attachment_value) DO NOTHING;
|
|
82
|
-
`;
|
|
83
|
-
__classPrivateFieldGet(this, _SqliteEventStore_db, "f").prepare(sql).run({
|
|
84
|
-
id: id,
|
|
85
|
-
group: attachment.code,
|
|
86
|
-
data: attachment.value,
|
|
87
|
-
});
|
|
88
|
-
}
|
|
89
|
-
async list(args = {}) {
|
|
90
|
-
const filter = [];
|
|
91
|
-
const params = {};
|
|
92
|
-
if (args.i) {
|
|
93
|
-
filter.push("json_extract(event_data, '$.i') = $i");
|
|
94
|
-
params["i"] = args.i;
|
|
95
|
-
}
|
|
96
|
-
if (args.d) {
|
|
97
|
-
filter.push("json_extract(event_data, '$.d') = $d");
|
|
98
|
-
params["d"] = args.d;
|
|
99
|
-
}
|
|
100
|
-
if (args.t) {
|
|
101
|
-
filter.push("json_extract(event_data, '$.t') = $t");
|
|
102
|
-
params["t"] = args.t;
|
|
103
|
-
}
|
|
104
|
-
if (args.r) {
|
|
105
|
-
filter.push("json_extract(event_data, '$.r') = $r");
|
|
106
|
-
params["r"] = args.r;
|
|
107
|
-
}
|
|
108
|
-
const sql = `
|
|
109
|
-
SELECT
|
|
110
|
-
event_data,
|
|
111
|
-
json_group_array(json_object('code', attachment_code, 'value', attachment_value)) as attachments
|
|
112
|
-
FROM
|
|
113
|
-
events
|
|
114
|
-
LEFT JOIN attachments ON events.event_id = attachments.event_id
|
|
115
|
-
${filter.length ? "WHERE " + filter.join(" AND ") : ""}
|
|
116
|
-
GROUP BY events.event_id
|
|
117
|
-
ORDER BY json_extract(event_data, '$.sn') DESC;
|
|
118
|
-
`;
|
|
119
|
-
const rows = __classPrivateFieldGet(this, _SqliteEventStore_db, "f").prepare(sql).all(params);
|
|
120
|
-
return rows.map(parseRow);
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
_SqliteEventStore_db = new WeakMap();
|
package/dist/events/common.d.ts
DELETED
package/dist/events/common.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
package/dist/events/incept.d.ts
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import type { DataArray } from "../data-type.ts";
|
|
2
|
-
import type { Threshold } from "./common.ts";
|
|
3
|
-
export interface InceptArgs {
|
|
4
|
-
k: string[];
|
|
5
|
-
kt: Threshold;
|
|
6
|
-
n: string[];
|
|
7
|
-
nt: Threshold;
|
|
8
|
-
b?: string[];
|
|
9
|
-
bt?: string;
|
|
10
|
-
}
|
|
11
|
-
export interface InceptEvent {
|
|
12
|
-
v: string;
|
|
13
|
-
t: "icp";
|
|
14
|
-
d: string;
|
|
15
|
-
i: string;
|
|
16
|
-
s: string;
|
|
17
|
-
kt: Threshold;
|
|
18
|
-
k: string[];
|
|
19
|
-
nt: Threshold;
|
|
20
|
-
n: string[];
|
|
21
|
-
bt: string;
|
|
22
|
-
b: string[];
|
|
23
|
-
c: string[];
|
|
24
|
-
a: DataArray;
|
|
25
|
-
}
|
|
26
|
-
export declare function incept(data: InceptArgs): InceptEvent;
|
package/dist/events/incept.js
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import { blake3 } from "@noble/hashes/blake3";
|
|
2
|
-
import cesr from "../parser/cesr-encoding.js";
|
|
3
|
-
import { MatterCode } from "../parser/codes.js";
|
|
4
|
-
import { versify } from "../parser/version.js";
|
|
5
|
-
export function incept(data) {
|
|
6
|
-
const event = versify({
|
|
7
|
-
t: "icp",
|
|
8
|
-
d: "#".repeat(44),
|
|
9
|
-
i: "#".repeat(44),
|
|
10
|
-
s: "0",
|
|
11
|
-
kt: data.kt,
|
|
12
|
-
k: data.k,
|
|
13
|
-
nt: data.nt,
|
|
14
|
-
n: data.n,
|
|
15
|
-
bt: data.bt ?? "0",
|
|
16
|
-
b: data.b ?? [],
|
|
17
|
-
c: [],
|
|
18
|
-
a: [],
|
|
19
|
-
});
|
|
20
|
-
const encoder = new TextEncoder();
|
|
21
|
-
const digest = cesr.encode(MatterCode.Blake3_256, blake3
|
|
22
|
-
.create({ dkLen: 32 })
|
|
23
|
-
.update(encoder.encode(JSON.stringify(event)))
|
|
24
|
-
.digest());
|
|
25
|
-
event["d"] = digest;
|
|
26
|
-
event["i"] = digest;
|
|
27
|
-
return event;
|
|
28
|
-
}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import type { DataArray } from "../data-type.ts";
|
|
2
|
-
export interface InteractArgs {
|
|
3
|
-
i: string;
|
|
4
|
-
s: string;
|
|
5
|
-
p: string;
|
|
6
|
-
a: DataArray;
|
|
7
|
-
}
|
|
8
|
-
export interface InteractEvent {
|
|
9
|
-
v: string;
|
|
10
|
-
t: "ixn";
|
|
11
|
-
d: string;
|
|
12
|
-
i: string;
|
|
13
|
-
s: string;
|
|
14
|
-
p: string;
|
|
15
|
-
a: DataArray;
|
|
16
|
-
}
|
|
17
|
-
export declare function interact(data: InteractArgs): InteractEvent;
|
package/dist/events/interact.js
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { blake3 } from "@noble/hashes/blake3";
|
|
2
|
-
import cesr from "../parser/cesr-encoding.js";
|
|
3
|
-
import { MatterCode } from "../parser/codes.js";
|
|
4
|
-
import { versify } from "../parser/version.js";
|
|
5
|
-
export function interact(data) {
|
|
6
|
-
const event = versify({
|
|
7
|
-
t: "ixn",
|
|
8
|
-
d: "#".repeat(44),
|
|
9
|
-
i: data.i,
|
|
10
|
-
s: data.s,
|
|
11
|
-
p: data.p,
|
|
12
|
-
a: data.a,
|
|
13
|
-
});
|
|
14
|
-
const encoder = new TextEncoder();
|
|
15
|
-
const digest = cesr.encode(MatterCode.Blake3_256, blake3
|
|
16
|
-
.create({ dkLen: 32 })
|
|
17
|
-
.update(encoder.encode(JSON.stringify(event)))
|
|
18
|
-
.digest());
|
|
19
|
-
event["d"] = digest;
|
|
20
|
-
return Object.freeze(event);
|
|
21
|
-
}
|
package/dist/events/main.d.ts
DELETED
package/dist/events/main.js
DELETED
package/dist/events/reply.d.ts
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import type { DataObject } from "../data-type.ts";
|
|
2
|
-
export interface ReplyArgs {
|
|
3
|
-
dt?: string;
|
|
4
|
-
r: string;
|
|
5
|
-
a: DataObject;
|
|
6
|
-
}
|
|
7
|
-
export interface ReplyEvent {
|
|
8
|
-
v: string;
|
|
9
|
-
t: "rpy";
|
|
10
|
-
d: string;
|
|
11
|
-
dt: string;
|
|
12
|
-
r: string;
|
|
13
|
-
a: DataObject;
|
|
14
|
-
}
|
|
15
|
-
export declare function reply(data: ReplyArgs): ReplyEvent;
|
package/dist/events/reply.js
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { blake3 } from "@noble/hashes/blake3";
|
|
2
|
-
import cesr from "../parser/cesr-encoding.js";
|
|
3
|
-
import { MatterCode } from "../parser/codes.js";
|
|
4
|
-
import { versify } from "../parser/version.js";
|
|
5
|
-
export function reply(data) {
|
|
6
|
-
const event = versify({
|
|
7
|
-
t: "rpy",
|
|
8
|
-
d: "#".repeat(44),
|
|
9
|
-
dt: data.dt ?? new Date().toISOString(),
|
|
10
|
-
r: data.r,
|
|
11
|
-
a: data.a,
|
|
12
|
-
});
|
|
13
|
-
const encoder = new TextEncoder();
|
|
14
|
-
const digest = cesr.encode(MatterCode.Blake3_256, blake3
|
|
15
|
-
.create({ dkLen: 32 })
|
|
16
|
-
.update(encoder.encode(JSON.stringify(event)))
|
|
17
|
-
.digest());
|
|
18
|
-
event["d"] = digest;
|
|
19
|
-
return event;
|
|
20
|
-
}
|
package/dist/keri/habitat.d.ts
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import type { EventStore, KeyEventMessage } from "../db/event-store.ts";
|
|
2
|
-
import type { KeyStore } from "../keystore/keystore.ts";
|
|
3
|
-
import type { InteractEvent, InceptEvent } from "../events/main.ts";
|
|
4
|
-
export interface HabitatDeps {
|
|
5
|
-
keystore: KeyStore;
|
|
6
|
-
db: EventStore;
|
|
7
|
-
}
|
|
8
|
-
export interface InceptIdentifierArgs {
|
|
9
|
-
wits: string[];
|
|
10
|
-
toad?: number;
|
|
11
|
-
}
|
|
12
|
-
export declare class Habitat {
|
|
13
|
-
#private;
|
|
14
|
-
constructor(deps: HabitatDeps);
|
|
15
|
-
create(args: InceptIdentifierArgs): Promise<InceptEvent>;
|
|
16
|
-
interact(aid: string): Promise<InteractEvent>;
|
|
17
|
-
resolve(oobi: string): Promise<void>;
|
|
18
|
-
submit(eventId: string): Promise<void>;
|
|
19
|
-
list(id: string): Promise<KeyEventMessage[]>;
|
|
20
|
-
}
|
package/dist/keri/habitat.js
DELETED
|
@@ -1,130 +0,0 @@
|
|
|
1
|
-
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
|
|
2
|
-
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
3
|
-
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
4
|
-
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
5
|
-
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
6
|
-
};
|
|
7
|
-
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
8
|
-
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
9
|
-
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
10
|
-
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
11
|
-
};
|
|
12
|
-
var _Habitat_db, _Habitat_keystore;
|
|
13
|
-
import { cesr, CounterCode } from "../main-common.js";
|
|
14
|
-
import { parse } from "../parser/parser.js";
|
|
15
|
-
import { resolveKeyState, submit } from "./keri.js";
|
|
16
|
-
import { interact, incept } from "../events/main.js";
|
|
17
|
-
export class Habitat {
|
|
18
|
-
constructor(deps) {
|
|
19
|
-
_Habitat_db.set(this, void 0);
|
|
20
|
-
_Habitat_keystore.set(this, void 0);
|
|
21
|
-
__classPrivateFieldSet(this, _Habitat_db, deps.db, "f");
|
|
22
|
-
__classPrivateFieldSet(this, _Habitat_keystore, deps.keystore, "f");
|
|
23
|
-
}
|
|
24
|
-
async create(args) {
|
|
25
|
-
const keys = [await __classPrivateFieldGet(this, _Habitat_keystore, "f").incept(), await __classPrivateFieldGet(this, _Habitat_keystore, "f").incept()];
|
|
26
|
-
const toad = args.toad ?? (args.wits.length === 0 ? 0 : args.wits.length === 1 ? 1 : args.wits.length - 1);
|
|
27
|
-
const payload = incept({
|
|
28
|
-
kt: "1",
|
|
29
|
-
k: keys.map((key) => key.current),
|
|
30
|
-
nt: "1",
|
|
31
|
-
n: keys.map((key) => key.next),
|
|
32
|
-
bt: toad.toString(),
|
|
33
|
-
b: args.wits,
|
|
34
|
-
});
|
|
35
|
-
await __classPrivateFieldGet(this, _Habitat_db, "f").saveEvent(payload);
|
|
36
|
-
const raw = new TextEncoder().encode(JSON.stringify(payload));
|
|
37
|
-
await Promise.all(keys.map(async (key, index) => {
|
|
38
|
-
const sig = await __classPrivateFieldGet(this, _Habitat_keystore, "f").sign(key.current, raw);
|
|
39
|
-
await __classPrivateFieldGet(this, _Habitat_db, "f").saveAttachment(payload.d, {
|
|
40
|
-
code: CounterCode.ControllerIdxSigs,
|
|
41
|
-
value: cesr.index(sig, index),
|
|
42
|
-
});
|
|
43
|
-
}));
|
|
44
|
-
await this.submit(payload.d);
|
|
45
|
-
return payload;
|
|
46
|
-
}
|
|
47
|
-
async interact(aid) {
|
|
48
|
-
const events = await __classPrivateFieldGet(this, _Habitat_db, "f").list({ i: aid });
|
|
49
|
-
if (events.length === 0) {
|
|
50
|
-
throw new Error(`Could not find aid ${aid}`);
|
|
51
|
-
}
|
|
52
|
-
const state = resolveKeyState(events.map((e) => e.event));
|
|
53
|
-
const payload = interact({
|
|
54
|
-
i: aid,
|
|
55
|
-
s: (parseInt(state.s, 16) + 1).toString(),
|
|
56
|
-
a: [],
|
|
57
|
-
p: state.event,
|
|
58
|
-
});
|
|
59
|
-
await __classPrivateFieldGet(this, _Habitat_db, "f").saveEvent(payload);
|
|
60
|
-
const raw = new TextEncoder().encode(JSON.stringify(payload));
|
|
61
|
-
await Promise.all(state.keys.map(async (key, index) => {
|
|
62
|
-
const sig = await __classPrivateFieldGet(this, _Habitat_keystore, "f").sign(key, raw);
|
|
63
|
-
await __classPrivateFieldGet(this, _Habitat_db, "f").saveAttachment(payload.d, {
|
|
64
|
-
code: CounterCode.ControllerIdxSigs,
|
|
65
|
-
value: cesr.index(sig, index),
|
|
66
|
-
});
|
|
67
|
-
}));
|
|
68
|
-
await this.submit(payload.d);
|
|
69
|
-
return payload;
|
|
70
|
-
}
|
|
71
|
-
async resolve(oobi) {
|
|
72
|
-
const response = await fetch(oobi);
|
|
73
|
-
if (!response.ok) {
|
|
74
|
-
throw new Error(`Failed to fetch oobi: ${response.status} ${response.statusText}`);
|
|
75
|
-
}
|
|
76
|
-
if (!response.body) {
|
|
77
|
-
throw new Error(`No body in response`);
|
|
78
|
-
}
|
|
79
|
-
for await (const event of parse(response.body)) {
|
|
80
|
-
__classPrivateFieldGet(this, _Habitat_db, "f").saveEvent(event.payload);
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
async submit(eventId) {
|
|
84
|
-
const [event] = await __classPrivateFieldGet(this, _Habitat_db, "f").list({ d: eventId });
|
|
85
|
-
if (!event || !("i" in event.event && typeof event.event.i === "string")) {
|
|
86
|
-
throw new Error("No such event");
|
|
87
|
-
}
|
|
88
|
-
const [inception] = await __classPrivateFieldGet(this, _Habitat_db, "f").list({ i: event.event.i, t: "icp" });
|
|
89
|
-
if (!inception) {
|
|
90
|
-
throw new Error("No inception event found");
|
|
91
|
-
}
|
|
92
|
-
const state = resolveKeyState([inception.event]);
|
|
93
|
-
const locations = await __classPrivateFieldGet(this, _Habitat_db, "f").list({ t: "rpy", r: "/loc/scheme" });
|
|
94
|
-
const witnessEndpoints = await Promise.all(state.wits.map((wit) => {
|
|
95
|
-
const result = locations.map((loc) => loc.event).find((rpy) => rpy.a.eid === wit);
|
|
96
|
-
if (!result) {
|
|
97
|
-
throw new Error(`No location found for wit ${wit}`);
|
|
98
|
-
}
|
|
99
|
-
return result.a.url;
|
|
100
|
-
}));
|
|
101
|
-
for (const wit of witnessEndpoints) {
|
|
102
|
-
const response = await submit({
|
|
103
|
-
event: event.event,
|
|
104
|
-
signatures: {
|
|
105
|
-
controllers: event.attachments
|
|
106
|
-
.filter((attachment) => attachment.code === CounterCode.ControllerIdxSigs)
|
|
107
|
-
.map((attachment) => attachment.value),
|
|
108
|
-
witnesses: [],
|
|
109
|
-
},
|
|
110
|
-
}, wit);
|
|
111
|
-
for await (const receipt of parse(response)) {
|
|
112
|
-
await __classPrivateFieldGet(this, _Habitat_db, "f").saveEvent(receipt.payload);
|
|
113
|
-
let code = null;
|
|
114
|
-
for (const attachment of receipt.attachments) {
|
|
115
|
-
if (attachment.startsWith("-")) {
|
|
116
|
-
code = attachment;
|
|
117
|
-
}
|
|
118
|
-
else if (code) {
|
|
119
|
-
await __classPrivateFieldGet(this, _Habitat_db, "f").saveAttachment(receipt.payload.d, { code: code, value: attachment });
|
|
120
|
-
code = null;
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
|
-
}
|
|
125
|
-
}
|
|
126
|
-
async list(id) {
|
|
127
|
-
return __classPrivateFieldGet(this, _Habitat_db, "f").list({ i: id });
|
|
128
|
-
}
|
|
129
|
-
}
|
|
130
|
-
_Habitat_db = new WeakMap(), _Habitat_keystore = new WeakMap();
|