keri 0.0.0-dev.0ddd65e → 0.0.0-dev.2223857

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.
Files changed (122) hide show
  1. package/dist/controller/controller.d.ts +109 -0
  2. package/dist/controller/controller.js +545 -0
  3. package/dist/controller/controller.js.map +1 -0
  4. package/dist/controller/encrypt.d.ts +45 -0
  5. package/dist/controller/encrypt.js +120 -0
  6. package/dist/controller/encrypt.js.map +1 -0
  7. package/dist/core/credential-event.d.ts +58 -0
  8. package/dist/core/credential-event.js +28 -0
  9. package/dist/core/credential-event.js.map +1 -0
  10. package/dist/core/credential.d.ts +79 -0
  11. package/dist/core/credential.js +25 -0
  12. package/dist/core/credential.js.map +1 -0
  13. package/dist/core/digest.d.ts +1 -0
  14. package/dist/core/digest.js +7 -0
  15. package/dist/core/digest.js.map +1 -0
  16. package/dist/core/endpoint-discovery.d.ts +20 -0
  17. package/dist/core/endpoint-discovery.js +60 -0
  18. package/dist/core/endpoint-discovery.js.map +1 -0
  19. package/dist/core/events.d.ts +12 -0
  20. package/dist/core/events.js +25 -0
  21. package/dist/core/events.js.map +1 -0
  22. package/dist/core/kawa.d.ts +17 -0
  23. package/dist/core/kawa.js +79 -0
  24. package/dist/core/kawa.js.map +1 -0
  25. package/dist/core/key-event-log.d.ts +13 -0
  26. package/dist/core/key-event-log.js +154 -0
  27. package/dist/core/key-event-log.js.map +1 -0
  28. package/dist/core/key-event.d.ts +96 -0
  29. package/dist/core/key-event.js +89 -0
  30. package/dist/core/key-event.js.map +1 -0
  31. package/dist/core/keys.d.ts +9 -0
  32. package/dist/core/keys.js +17 -0
  33. package/dist/core/keys.js.map +1 -0
  34. package/dist/core/mailbox-client.d.ts +17 -0
  35. package/dist/core/mailbox-client.js +57 -0
  36. package/dist/core/mailbox-client.js.map +1 -0
  37. package/dist/core/main.d.ts +47 -0
  38. package/dist/core/main.js +44 -0
  39. package/dist/core/main.js.map +1 -0
  40. package/dist/core/receipt-event.d.ts +15 -0
  41. package/dist/core/receipt-event.js +13 -0
  42. package/dist/core/receipt-event.js.map +1 -0
  43. package/dist/core/registry-event.d.ts +28 -0
  44. package/dist/core/registry-event.js +18 -0
  45. package/dist/core/registry-event.js.map +1 -0
  46. package/dist/core/routed-event.d.ts +73 -0
  47. package/dist/core/routed-event.js +53 -0
  48. package/dist/core/routed-event.js.map +1 -0
  49. package/dist/core/said.d.ts +4 -0
  50. package/dist/core/said.js +26 -0
  51. package/dist/core/said.js.map +1 -0
  52. package/dist/core/sign.d.ts +5 -0
  53. package/dist/core/sign.js +10 -0
  54. package/dist/core/sign.js.map +1 -0
  55. package/dist/core/threshold.d.ts +6 -0
  56. package/dist/core/threshold.js +58 -0
  57. package/dist/core/threshold.js.map +1 -0
  58. package/dist/core/verify.d.ts +14 -0
  59. package/dist/core/verify.js +43 -0
  60. package/dist/core/verify.js.map +1 -0
  61. package/dist/main.d.ts +2 -2
  62. package/dist/main.js +3 -2
  63. package/dist/main.js.map +1 -0
  64. package/dist/storage/sqlite/node-sqlite.d.ts +12 -0
  65. package/dist/storage/sqlite/node-sqlite.js +25 -0
  66. package/dist/storage/sqlite/node-sqlite.js.map +1 -0
  67. package/dist/storage/sqlite/schema.d.ts +2 -0
  68. package/dist/storage/sqlite/schema.js +49 -0
  69. package/dist/storage/sqlite/schema.js.map +1 -0
  70. package/dist/storage/sqlite/sqlite-database.d.ts +13 -0
  71. package/dist/storage/sqlite/sqlite-database.js +2 -0
  72. package/dist/storage/sqlite/sqlite-database.js.map +1 -0
  73. package/dist/storage/sqlite/storage-sqlite.d.ts +26 -0
  74. package/dist/storage/sqlite/storage-sqlite.js +213 -0
  75. package/dist/storage/sqlite/storage-sqlite.js.map +1 -0
  76. package/package.json +38 -26
  77. package/dist/cli/main.d.ts +0 -2
  78. package/dist/cli/main.js +0 -72
  79. package/dist/data-type.d.ts +0 -9
  80. package/dist/data-type.js +0 -1
  81. package/dist/db/event-store.d.ts +0 -20
  82. package/dist/db/event-store.js +0 -1
  83. package/dist/db/sqlite-db.d.ts +0 -13
  84. package/dist/db/sqlite-db.js +0 -123
  85. package/dist/events/common.d.ts +0 -6
  86. package/dist/events/common.js +0 -1
  87. package/dist/events/incept.d.ts +0 -26
  88. package/dist/events/incept.js +0 -28
  89. package/dist/events/interact.d.ts +0 -17
  90. package/dist/events/interact.js +0 -21
  91. package/dist/events/main.d.ts +0 -4
  92. package/dist/events/main.js +0 -4
  93. package/dist/events/reply.d.ts +0 -15
  94. package/dist/events/reply.js +0 -20
  95. package/dist/keri/habitat.d.ts +0 -20
  96. package/dist/keri/habitat.js +0 -130
  97. package/dist/keri/keri.d.ts +0 -26
  98. package/dist/keri/keri.js +0 -43
  99. package/dist/keystore/encrypt.d.ts +0 -2
  100. package/dist/keystore/encrypt.js +0 -38
  101. package/dist/keystore/keystore-fs.d.ts +0 -13
  102. package/dist/keystore/keystore-fs.js +0 -50
  103. package/dist/keystore/keystore-web.d.ts +0 -12
  104. package/dist/keystore/keystore-web.js +0 -48
  105. package/dist/keystore/keystore.d.ts +0 -15
  106. package/dist/keystore/keystore.js +0 -1
  107. package/dist/main-common.d.ts +0 -9
  108. package/dist/main-common.js +0 -8
  109. package/dist/main-web.d.ts +0 -2
  110. package/dist/main-web.js +0 -2
  111. package/dist/parser/base64.d.ts +0 -6
  112. package/dist/parser/base64.js +0 -74
  113. package/dist/parser/buffered-reader.d.ts +0 -5
  114. package/dist/parser/buffered-reader.js +0 -47
  115. package/dist/parser/cesr-encoding.d.ts +0 -34
  116. package/dist/parser/cesr-encoding.js +0 -158
  117. package/dist/parser/codes.d.ts +0 -143
  118. package/dist/parser/codes.js +0 -266
  119. package/dist/parser/parser.d.ts +0 -16
  120. package/dist/parser/parser.js +0 -161
  121. package/dist/parser/version.d.ts +0 -11
  122. package/dist/parser/version.js +0 -56
@@ -0,0 +1,213 @@
1
+ import { migrate } from "./schema.js";
2
+ export { NodeSqliteDatabase } from "./node-sqlite.js";
3
+ import { Message, Attachments, } from "../../core/main.js";
4
+ function parseRow(result) {
5
+ if (!("event_json" in result) || typeof result.event_json !== "string") {
6
+ throw new Error("Row does not contain event_json");
7
+ }
8
+ if (!("attachments" in result) || typeof result.attachments !== "string") {
9
+ throw new Error("Row does not contain attachments");
10
+ }
11
+ const body = JSON.parse(result.event_json);
12
+ const atc = Attachments.parse(new TextEncoder().encode(result.attachments)) ?? new Attachments();
13
+ return new Message(body, atc);
14
+ }
15
+ function prepareRow(message) {
16
+ if (message.version.protocol === "ACDC") {
17
+ const body = message.body;
18
+ return {
19
+ event_id: body.d,
20
+ protocol: message.version.protocol,
21
+ type: "credential",
22
+ sn: null,
23
+ event_json: JSON.stringify(body),
24
+ attachments: message.attachments.text(),
25
+ };
26
+ }
27
+ switch (message.body.t) {
28
+ case "icp":
29
+ case "rot":
30
+ case "ixn": {
31
+ const body = message.body;
32
+ return {
33
+ event_id: body.d,
34
+ protocol: message.version.protocol,
35
+ type: body.t,
36
+ sn: parseInt(body.s, 16),
37
+ event_json: JSON.stringify(body),
38
+ attachments: message.attachments.text(),
39
+ };
40
+ }
41
+ case "vcp": {
42
+ const body = message.body;
43
+ return {
44
+ event_id: body.d,
45
+ protocol: message.version.protocol,
46
+ type: body.t,
47
+ sn: null,
48
+ event_json: JSON.stringify(body),
49
+ attachments: message.attachments.text(),
50
+ };
51
+ }
52
+ case "iss":
53
+ case "rev": {
54
+ const body = message.body;
55
+ return {
56
+ event_id: body.d,
57
+ protocol: message.version.protocol,
58
+ type: body.t,
59
+ sn: null,
60
+ event_json: JSON.stringify(body),
61
+ attachments: message.attachments.text(),
62
+ };
63
+ }
64
+ default: {
65
+ const body = message.body;
66
+ return {
67
+ event_id: typeof body.d === "string" ? body.d : null,
68
+ protocol: message.version.protocol,
69
+ type: typeof body.t === "string" ? body.t : null,
70
+ sn: null,
71
+ event_json: JSON.stringify(body),
72
+ attachments: message.attachments.text(),
73
+ };
74
+ }
75
+ }
76
+ }
77
+ export class SqliteControllerStorage {
78
+ #db;
79
+ constructor(db) {
80
+ migrate(db);
81
+ this.#db = db;
82
+ }
83
+ #queryOne(sql, params) {
84
+ const result = Array.from(this.#db.iterate(sql, params))[0];
85
+ return result ? result : undefined;
86
+ }
87
+ saveKey(publicKey, digest, encryptedPrivKey) {
88
+ const statement = [
89
+ "INSERT INTO key_info(public_key, public_key_digest, encrypted_private_key)",
90
+ "VALUES ($public_key, $digest, $encrypted_private_key)",
91
+ "ON CONFLICT (public_key) DO NOTHING",
92
+ ].join("\n");
93
+ this.#db.execute(statement, {
94
+ public_key: publicKey,
95
+ digest,
96
+ encrypted_private_key: encryptedPrivKey,
97
+ });
98
+ }
99
+ getKey(publicKey) {
100
+ const statement = ["SELECT encrypted_private_key FROM key_info", "WHERE public_key = $public_key", "LIMIT 1"].join("\n");
101
+ const result = this.#queryOne(statement, { public_key: publicKey });
102
+ if (!result || typeof result.encrypted_private_key !== "string") {
103
+ throw new Error(`Key not found for public key: ${publicKey}`);
104
+ }
105
+ return result.encrypted_private_key;
106
+ }
107
+ getPublicKeyByDigest(digest) {
108
+ const statement = ["SELECT public_key FROM key_info", "WHERE public_key_digest = $digest", "LIMIT 1"].join("\n");
109
+ const result = this.#queryOne(statement, { digest });
110
+ if (!result || typeof result.public_key !== "string") {
111
+ throw new Error(`Key not found for digest: ${digest}`);
112
+ }
113
+ return result.public_key;
114
+ }
115
+ saveMessage(message) {
116
+ const statement = [
117
+ "INSERT INTO event(event_id, protocol, type, sn, event_json, attachments)",
118
+ "VALUES ($event_id, $protocol, $type, $sn, $event_json, $attachments)",
119
+ "ON CONFLICT(event_id) DO NOTHING",
120
+ ].join("\n");
121
+ this.#db.execute(statement, prepareRow(message));
122
+ }
123
+ *getReplies(filter = {}) {
124
+ const conditions = ["type = 'rpy'"];
125
+ const params = {};
126
+ if (filter.eid !== undefined) {
127
+ conditions.push("json_extract(event_json, '$.a.eid') = $eid");
128
+ params.eid = filter.eid;
129
+ }
130
+ if (filter.route !== undefined) {
131
+ conditions.push("json_extract(event_json, '$.r') = $route");
132
+ params.route = filter.route;
133
+ }
134
+ if (filter.cid !== undefined) {
135
+ conditions.push("json_extract(event_json, '$.a.cid') = $cid");
136
+ params.cid = filter.cid;
137
+ }
138
+ const statement = [
139
+ "SELECT event_json, attachments FROM event",
140
+ "WHERE " + conditions.join(" AND "),
141
+ "ORDER BY sn ASC",
142
+ ].join("\n");
143
+ for (const result of this.#db.iterate(statement, params)) {
144
+ yield parseRow(result);
145
+ }
146
+ }
147
+ *getKeyEvents(prefix) {
148
+ const statement = [
149
+ "SELECT event_json, attachments",
150
+ "FROM event",
151
+ "WHERE json_extract(event_json, '$.i') = $prefix",
152
+ "AND type in ('icp', 'rot', 'ixn')",
153
+ "ORDER BY sn ASC",
154
+ ].join("\n");
155
+ for (const result of this.#db.iterate(statement, { prefix })) {
156
+ yield parseRow(result);
157
+ }
158
+ }
159
+ *getCredentialEvents(id) {
160
+ const statement = [
161
+ "SELECT event_json, attachments",
162
+ "FROM event",
163
+ "WHERE type IN ('iss', 'rev') AND json_extract(event_json, '$.i') = $id",
164
+ "ORDER BY rowid ASC",
165
+ ].join("\n");
166
+ for (const row of this.#db.iterate(statement, { id })) {
167
+ yield parseRow(row);
168
+ }
169
+ }
170
+ getRegistry(id) {
171
+ const statement = [
172
+ "SELECT event_json, attachments",
173
+ "FROM event",
174
+ "WHERE type = 'vcp' AND json_extract(event_json, '$.i') = $id",
175
+ "LIMIT 1",
176
+ ].join("\n");
177
+ const result = this.#queryOne(statement, { id });
178
+ return result ? parseRow(result) : null;
179
+ }
180
+ *getRegistriesByOwner(owner) {
181
+ const statement = [
182
+ "SELECT event_json, attachments",
183
+ "FROM event",
184
+ "WHERE type = 'vcp' AND json_extract(event_json, '$.ii') = $owner",
185
+ "ORDER BY rowid ASC",
186
+ ].join("\n");
187
+ for (const row of this.#db.iterate(statement, { owner })) {
188
+ yield parseRow(row);
189
+ }
190
+ }
191
+ getCredential(id) {
192
+ const statement = ["SELECT event_json, attachments", "FROM event", "WHERE event_id = $id", "LIMIT 1"].join("\n");
193
+ const result = this.#queryOne(statement, { id });
194
+ return result ? parseRow(result).body : null;
195
+ }
196
+ getCredentialsByRegistry(registryId) {
197
+ const statement = [
198
+ "SELECT event_json, attachments",
199
+ "FROM event",
200
+ "WHERE json_extract(event_json, '$.ri') = $registry_id",
201
+ ].join("\n");
202
+ return Array.from(this.#db.iterate(statement, { registry_id: registryId })).map((row) => parseRow(row).body);
203
+ }
204
+ getMailboxOffset(prefix, topic) {
205
+ const result = this.#queryOne("SELECT offset FROM mailbox_cursor WHERE prefix = $prefix AND topic = $topic LIMIT 1", { prefix, topic });
206
+ return typeof result?.offset === "number" ? result.offset : 0;
207
+ }
208
+ saveMailboxOffset(prefix, topic, offset) {
209
+ this.#db.execute("INSERT INTO mailbox_cursor(prefix, topic, offset) VALUES ($prefix, $topic, $offset) " +
210
+ "ON CONFLICT(prefix, topic) DO UPDATE SET offset = $offset", { prefix, topic, offset });
211
+ }
212
+ }
213
+ //# sourceMappingURL=storage-sqlite.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"storage-sqlite.js","sourceRoot":"","sources":["../../../src/storage/sqlite/storage-sqlite.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAEtC,OAAO,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AAEtD,OAAO,EACL,OAAO,EACP,WAAW,GAQZ,MAAM,oBAAoB,CAAC;AAI5B,SAAS,QAAQ,CAAwB,MAAW;IAClD,IAAI,CAAC,CAAC,YAAY,IAAI,MAAM,CAAC,IAAI,OAAO,MAAM,CAAC,UAAU,KAAK,QAAQ,EAAE,CAAC;QACvE,MAAM,IAAI,KAAK,CAAC,iCAAiC,CAAC,CAAC;IACrD,CAAC;IAED,IAAI,CAAC,CAAC,aAAa,IAAI,MAAM,CAAC,IAAI,OAAO,MAAM,CAAC,WAAW,KAAK,QAAQ,EAAE,CAAC;QACzE,MAAM,IAAI,KAAK,CAAC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E,CAAC,GAAG,EAAE,EAAE,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,IAAsB,CAC9C,CAAC;IACJ,CAAC;IAED,gBAAgB,CAAC,MAAc,EAAE,KAAa;QAC5C,MAAM,MAAM,GAAG,IAAI,CAAC,SAAS,CAC3B,qFAAqF,EACrF,EAAE,MAAM,EAAE,KAAK,EAAE,CAClB,CAAC;QACF,OAAO,OAAO,MAAM,EAAE,MAAM,KAAK,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC;IAChE,CAAC;IAED,iBAAiB,CAAC,MAAc,EAAE,KAAa,EAAE,MAAc;QAC7D,IAAI,CAAC,GAAG,CAAC,OAAO,CACd,sFAAsF;YACpF,2DAA2D,EAC7D,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,CAC1B,CAAC;IACJ,CAAC;CACF"}
package/package.json CHANGED
@@ -1,45 +1,57 @@
1
1
  {
2
2
  "name": "keri",
3
- "version": "0.0.0-dev.0ddd65e",
3
+ "version": "0.0.0-dev.2223857",
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
- "test": "node --no-warnings --experimental-strip-types --experimental-sqlite scripts/run-test.ts",
9
- "clean": "node scripts/clean.js"
10
+ "dev": "tsc -p tsconfig.build.json --watch",
11
+ "test": "node --conditions=source --test --no-warnings 'src/**/*.test.ts'",
12
+ "test:integration": "node --conditions=source --test --no-warnings 'test_integration/**/*.test.ts'",
13
+ "test:interop": "node --conditions=source --no-warnings scripts/run-scripts.ts",
14
+ "lint": "eslint",
15
+ "check": "tsc --noEmit",
16
+ "format": "prettier --write .",
17
+ "format:check": "prettier --check ."
10
18
  },
11
- "bin": {
12
- "keri": "./dist/cli/main.js"
19
+ "imports": {
20
+ "#keri": "./src/main.ts",
21
+ "#keri/core": "./src/core/main.ts",
22
+ "#keri/sqlite-storage": "./src/storage/sqlite/storage-sqlite.ts"
13
23
  },
14
24
  "exports": {
15
25
  ".": "./dist/main.js",
16
- "./web": "./dist/main-web.js"
26
+ "./sqlite-storage": "./dist/storage/sqlite/storage-sqlite.js"
17
27
  },
18
28
  "files": [
19
29
  "dist"
20
30
  ],
21
31
  "type": "module",
22
- "author": "",
23
- "license": "ISC",
24
- "description": "",
32
+ "author": "Daniel Lenksjö",
33
+ "license": "Apache-2.0",
34
+ "description": "KERI for JavaScript",
35
+ "devEngines": {
36
+ "runtime": {
37
+ "name": "node",
38
+ "version": ">=24",
39
+ "onFail": "warn"
40
+ },
41
+ "packageManager": {
42
+ "name": "npm",
43
+ "version": ">=11",
44
+ "onFail": "warn"
45
+ }
46
+ },
25
47
  "engines": {
26
48
  "node": ">=22"
27
49
  },
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
50
  "dependencies": {
40
- "@noble/curves": "^1.6.0",
41
- "@noble/ed25519": "^2.2.2",
42
- "@noble/hashes": "^1.5.0",
43
- "@noble/secp256k1": "^2.2.2"
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
+ "cesr": "*"
44
56
  }
45
57
  }
@@ -1,2 +0,0 @@
1
- #!/usr/bin/env node
2
- export {};
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);
@@ -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/data-type.js DELETED
@@ -1 +0,0 @@
1
- export {};
@@ -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
- }
@@ -1 +0,0 @@
1
- export {};
@@ -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
- }
@@ -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();
@@ -1,6 +0,0 @@
1
- export interface KeyEvent {
2
- v: string;
3
- t: string;
4
- d: string;
5
- }
6
- export type Threshold = string | string[];
@@ -1 +0,0 @@
1
- export {};
@@ -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;
@@ -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;
@@ -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
- }