@minca/core 0.1.8 → 0.1.10

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 (157) hide show
  1. package/README.md +1 -1
  2. package/dist/files/file-id.d.ts +51 -0
  3. package/dist/files/file-id.d.ts.map +1 -0
  4. package/dist/files/file-id.js +97 -0
  5. package/dist/files/file-id.js.map +1 -0
  6. package/dist/files/seal.d.ts +20 -0
  7. package/dist/files/seal.d.ts.map +1 -0
  8. package/dist/files/seal.js +77 -0
  9. package/dist/files/seal.js.map +1 -0
  10. package/dist/files/space-files.d.ts +51 -0
  11. package/dist/files/space-files.d.ts.map +1 -0
  12. package/dist/files/space-files.js +476 -0
  13. package/dist/files/space-files.js.map +1 -0
  14. package/dist/identity/abilities.d.ts +3 -3
  15. package/dist/identity/abilities.d.ts.map +1 -1
  16. package/dist/identity/abilities.js +9 -11
  17. package/dist/identity/abilities.js.map +1 -1
  18. package/dist/identity/root-signer.d.ts +0 -5
  19. package/dist/identity/root-signer.d.ts.map +1 -1
  20. package/dist/identity/root-signer.js +0 -1
  21. package/dist/identity/root-signer.js.map +1 -1
  22. package/dist/index.d.ts +5 -4
  23. package/dist/index.d.ts.map +1 -1
  24. package/dist/index.js +3 -2
  25. package/dist/index.js.map +1 -1
  26. package/dist/node/api.d.ts +5 -1
  27. package/dist/node/api.d.ts.map +1 -1
  28. package/dist/node/api.js +10 -2
  29. package/dist/node/api.js.map +1 -1
  30. package/dist/node/carrier.d.ts +17 -2
  31. package/dist/node/carrier.d.ts.map +1 -1
  32. package/dist/node/carrier.js +26 -4
  33. package/dist/node/carrier.js.map +1 -1
  34. package/dist/node/copy.d.ts +0 -4
  35. package/dist/node/copy.d.ts.map +1 -1
  36. package/dist/node/copy.js +26 -0
  37. package/dist/node/copy.js.map +1 -1
  38. package/dist/node/host.d.ts +66 -1
  39. package/dist/node/host.d.ts.map +1 -1
  40. package/dist/node/host.js +571 -5
  41. package/dist/node/host.js.map +1 -1
  42. package/dist/node/index.d.ts +2 -2
  43. package/dist/node/index.d.ts.map +1 -1
  44. package/dist/node/index.js +1 -1
  45. package/dist/node/index.js.map +1 -1
  46. package/dist/node/node.d.ts.map +1 -1
  47. package/dist/node/node.js +328 -269
  48. package/dist/node/node.js.map +1 -1
  49. package/dist/node/remote.d.ts +6 -5
  50. package/dist/node/remote.d.ts.map +1 -1
  51. package/dist/node/remote.js +141 -194
  52. package/dist/node/remote.js.map +1 -1
  53. package/dist/node/space-runtime.d.ts +9 -0
  54. package/dist/node/space-runtime.d.ts.map +1 -1
  55. package/dist/node/space-runtime.js +194 -98
  56. package/dist/node/space-runtime.js.map +1 -1
  57. package/dist/node/stores.d.ts +44 -8
  58. package/dist/node/stores.d.ts.map +1 -1
  59. package/dist/node/stores.js +44 -7
  60. package/dist/node/stores.js.map +1 -1
  61. package/dist/node/types.d.ts +77 -10
  62. package/dist/node/types.d.ts.map +1 -1
  63. package/dist/node/usage.d.ts +54 -0
  64. package/dist/node/usage.d.ts.map +1 -0
  65. package/dist/node/usage.js +201 -0
  66. package/dist/node/usage.js.map +1 -0
  67. package/dist/node/worker.d.ts +1 -1
  68. package/dist/node/worker.d.ts.map +1 -1
  69. package/dist/node/worker.js +10 -6
  70. package/dist/node/worker.js.map +1 -1
  71. package/dist/schema/version.d.ts +5 -0
  72. package/dist/schema/version.d.ts.map +1 -1
  73. package/dist/schema/version.js +1 -0
  74. package/dist/schema/version.js.map +1 -1
  75. package/dist/schemas/fragments.d.ts +23 -2
  76. package/dist/schemas/fragments.d.ts.map +1 -1
  77. package/dist/schemas/fragments.js +5 -2
  78. package/dist/schemas/fragments.js.map +1 -1
  79. package/dist/schemas/library/annotations.d.ts +24 -0
  80. package/dist/schemas/library/annotations.d.ts.map +1 -1
  81. package/dist/schemas/library/community.d.ts +24 -0
  82. package/dist/schemas/library/community.d.ts.map +1 -1
  83. package/dist/schemas/library/life.d.ts +72 -0
  84. package/dist/schemas/library/life.d.ts.map +1 -1
  85. package/dist/schemas/library/media.d.ts +144 -0
  86. package/dist/schemas/library/media.d.ts.map +1 -1
  87. package/dist/schemas/library/money.d.ts +24 -0
  88. package/dist/schemas/library/money.d.ts.map +1 -1
  89. package/dist/schemas/library/publishing.d.ts +96 -0
  90. package/dist/schemas/library/publishing.d.ts.map +1 -1
  91. package/dist/schemas/library/social.d.ts +72 -0
  92. package/dist/schemas/library/social.d.ts.map +1 -1
  93. package/dist/session/auth.d.ts +20 -0
  94. package/dist/session/auth.d.ts.map +1 -1
  95. package/dist/session/auth.js +88 -64
  96. package/dist/session/auth.js.map +1 -1
  97. package/dist/session/connect.d.ts +50 -8
  98. package/dist/session/connect.d.ts.map +1 -1
  99. package/dist/session/connect.js +91 -27
  100. package/dist/session/connect.js.map +1 -1
  101. package/dist/session/connection.d.ts +39 -6
  102. package/dist/session/connection.d.ts.map +1 -1
  103. package/dist/session/connection.js +107 -38
  104. package/dist/session/connection.js.map +1 -1
  105. package/dist/session/hosting.d.ts +88 -28
  106. package/dist/session/hosting.d.ts.map +1 -1
  107. package/dist/session/hosting.js +137 -6
  108. package/dist/session/hosting.js.map +1 -1
  109. package/dist/session/index.d.ts +5 -5
  110. package/dist/session/index.d.ts.map +1 -1
  111. package/dist/session/index.js +2 -2
  112. package/dist/session/index.js.map +1 -1
  113. package/dist/session/places.d.ts +2 -0
  114. package/dist/session/places.d.ts.map +1 -1
  115. package/dist/session/places.js +8 -2
  116. package/dist/session/places.js.map +1 -1
  117. package/dist/space/account-registry.d.ts +27 -4
  118. package/dist/space/account-registry.d.ts.map +1 -1
  119. package/dist/space/account-registry.js +25 -3
  120. package/dist/space/account-registry.js.map +1 -1
  121. package/dist/space/roles.d.ts +59 -140
  122. package/dist/space/roles.d.ts.map +1 -1
  123. package/dist/space/roles.js +328 -427
  124. package/dist/space/roles.js.map +1 -1
  125. package/dist/storage/blob/directory.d.ts +14 -0
  126. package/dist/storage/blob/directory.d.ts.map +1 -0
  127. package/dist/storage/blob/directory.js +80 -0
  128. package/dist/storage/blob/directory.js.map +1 -0
  129. package/dist/storage/folder-adapter.d.ts +22 -0
  130. package/dist/storage/folder-adapter.d.ts.map +1 -1
  131. package/dist/storage/folder-adapter.js +5 -5
  132. package/dist/storage/folder-adapter.js.map +1 -1
  133. package/dist/storage/mirror.d.ts +9 -2
  134. package/dist/storage/mirror.d.ts.map +1 -1
  135. package/dist/storage/mirror.js +60 -35
  136. package/dist/storage/mirror.js.map +1 -1
  137. package/dist/storage/segment.d.ts +7 -2
  138. package/dist/storage/segment.d.ts.map +1 -1
  139. package/dist/storage/segment.js +25 -3
  140. package/dist/storage/segment.js.map +1 -1
  141. package/dist/sync/sync-engine.d.ts +2 -0
  142. package/dist/sync/sync-engine.d.ts.map +1 -1
  143. package/dist/sync/sync-engine.js +5 -0
  144. package/dist/sync/sync-engine.js.map +1 -1
  145. package/dist/sync/sync-messages.d.ts +24 -0
  146. package/dist/sync/sync-messages.d.ts.map +1 -1
  147. package/dist/sync/sync-messages.js.map +1 -1
  148. package/docs/actions.md +3 -3
  149. package/docs/agents.md +2 -2
  150. package/docs/blueprints-and-guides.md +20 -1
  151. package/docs/bots.md +1 -1
  152. package/docs/node.md +138 -75
  153. package/docs/sign-in.md +16 -9
  154. package/docs/spaces.md +18 -10
  155. package/docs/standard-library.md +16 -20
  156. package/docs/storage.md +121 -16
  157. package/package.json +1 -1
package/README.md CHANGED
@@ -234,7 +234,7 @@ One npm workspace. Everything imports the protocol as `@minca/core`.
234
234
  | Sync, storage adapters, data folders and locking them, mirrors | [storage](https://github.com/leifriksheim/minca/blob/main/packages/core/docs/storage.md) | [05 Sync and storage](https://github.com/leifriksheim/minca/blob/main/spec/05-sync-and-storage.md) |
235
235
  | Hosting: keeping spaces online, payment, bots a host runs | [packages/cli](https://github.com/leifriksheim/minca/blob/main/packages/cli/README.md) | [08 Hosting](https://github.com/leifriksheim/minca/blob/main/spec/08-hosting.md) |
236
236
  | The CLI, the always-on node, agents and MCP | [packages/cli](https://github.com/leifriksheim/minca/blob/main/packages/cli/README.md), [agents](https://github.com/leifriksheim/minca/blob/main/packages/core/docs/agents.md) | [06 Nodes and sessions](https://github.com/leifriksheim/minca/blob/main/spec/06-nodes-and-sessions.md) |
237
- | The app, Liquid and mini apps | [apps/example](https://github.com/leifriksheim/minca/blob/main/apps/example/README.md) | — |
237
+ | The app, and its ready-made apps | [apps/example](https://github.com/leifriksheim/minca/blob/main/apps/example/README.md), [apps/liquid](https://github.com/leifriksheim/minca/blob/main/apps/liquid/README.md) | — |
238
238
  | Planned work | [docs](https://github.com/leifriksheim/minca/blob/main/packages/core/docs/README.md#planned-in-the-library) | [spec](https://github.com/leifriksheim/minca/blob/main/spec/README.md) |
239
239
 
240
240
  </details>
@@ -0,0 +1,51 @@
1
+ /**
2
+ * What names a file, and how what arrives is checked (spec 05 §16.6).
3
+ *
4
+ * A file is cut into chunks of `CHUNK` bytes. Its chunk list is the SHA-256
5
+ * of each, in order; its id is the SHA-256 of its size and that list. So a
6
+ * reader checks the list once against the id, then each chunk as it comes:
7
+ * a video plays before it is whole, and a bad peer wastes at most a chunk.
8
+ */
9
+ import type { Version } from '../types.js';
10
+ /** A chunk, and the record size of the files' encryption: one record is one chunk */
11
+ export declare const CHUNK = 262144;
12
+ /** The largest file, in bytes as stored */
13
+ export declare const MAX_FILE_SIZE: number;
14
+ /** Files a version names that peers take */
15
+ export declare const MAX_FILES = 16;
16
+ /** A file as a version names it: its id and its size as stored */
17
+ export interface FileName {
18
+ readonly hash: string;
19
+ readonly size: number;
20
+ }
21
+ /**
22
+ * The files a version names, as every peer takes them: in order, the first
23
+ * 16 well-formed entries with distinct ids; none on a delete. Never a reason
24
+ * to refuse the version.
25
+ */
26
+ export declare function filesOf(version: Pick<Version, 'deleted'> & {
27
+ readonly files?: unknown;
28
+ }): FileName[];
29
+ /** How many chunks a file of this size has */
30
+ export declare const chunkCount: (size: number) => number;
31
+ /** How long chunk `index` of a file of this size is */
32
+ export declare const chunkLength: (size: number, index: number) => number;
33
+ /** The SHA-256 of each chunk, in order, concatenated */
34
+ export declare function chunkListOf(bytes: Uint8Array): Promise<Uint8Array>;
35
+ /** A file's id: SHA-256 of its size, as 8 bytes big-endian, and its chunk list */
36
+ export declare function fileIdOf(size: number, list: Uint8Array): Promise<string>;
37
+ /** Whether a chunk list is the one this file's id names: exactly its length, and giving the id */
38
+ export declare function listFits(file: FileName, list: Uint8Array): Promise<boolean>;
39
+ /**
40
+ * Whether these are the bytes of chunk `index`: its length, and the hash the
41
+ * list gives it. Without a list, only a file of one chunk can be checked: by
42
+ * its id.
43
+ */
44
+ export declare function chunkFits(file: FileName, list: Uint8Array | null, index: number, bytes: Uint8Array): Promise<boolean>;
45
+ /**
46
+ * The files a body refers to: every object in it shaped as a file reference
47
+ * (`hash`, `size`, `key` and `salt`, as `addFile` gives one). What the node
48
+ * names on a version it writes, so the envelope and the body agree.
49
+ */
50
+ export declare function fileRefsIn(body: unknown): FileName[];
51
+ //# sourceMappingURL=file-id.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"file-id.d.ts","sourceRoot":"","sources":["../../src/files/file-id.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAK3C,qFAAqF;AACrF,eAAO,MAAM,KAAK,SAAU,CAAC;AAC7B,2CAA2C;AAC3C,eAAO,MAAM,aAAa,QAAU,CAAC;AACrC,4CAA4C;AAC5C,eAAO,MAAM,SAAS,KAAK,CAAC;AAE5B,kEAAkE;AAClE,MAAM,WAAW,QAAQ;IACvB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;CACvB;AAaD;;;;GAIG;AACH,wBAAgB,OAAO,CAAC,OAAO,EAAE,IAAI,CAAC,OAAO,EAAE,SAAS,CAAC,GAAG;IAAE,QAAQ,CAAC,KAAK,CAAC,EAAE,OAAO,CAAA;CAAE,GAAG,QAAQ,EAAE,CAWpG;AAED,8CAA8C;AAC9C,eAAO,MAAM,UAAU,SAAU,MAAM,KAAG,MAAiC,CAAC;AAE5E,uDAAuD;AACvD,eAAO,MAAM,WAAW,SAAU,MAAM,SAAS,MAAM,KAAG,MACoB,CAAC;AAE/E,wDAAwD;AACxD,wBAAsB,WAAW,CAAC,KAAK,EAAE,UAAU,GAAG,OAAO,CAAC,UAAU,CAAC,CAIxE;AAED,kFAAkF;AAClF,wBAAsB,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,UAAU,GAAG,OAAO,CAAC,MAAM,CAAC,CAI9E;AAED,kGAAkG;AAClG,wBAAsB,QAAQ,CAAC,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,UAAU,GAAG,OAAO,CAAC,OAAO,CAAC,CAEjF;AAED;;;;GAIG;AACH,wBAAsB,SAAS,CAC7B,IAAI,EAAE,QAAQ,EACd,IAAI,EAAE,UAAU,GAAG,IAAI,EACvB,KAAK,EAAE,MAAM,EACb,KAAK,EAAE,UAAU,GAChB,OAAO,CAAC,OAAO,CAAC,CAMlB;AAED;;;;GAIG;AACH,wBAAgB,UAAU,CAAC,IAAI,EAAE,OAAO,GAAG,QAAQ,EAAE,CAepD"}
@@ -0,0 +1,97 @@
1
+ import { sha256 } from '../utils/hash.js';
2
+ import { bytesToHex, concatBytes } from '../utils/encoding.js';
3
+ import { isRecord } from '../utils/guards.js';
4
+ /** A chunk, and the record size of the files' encryption: one record is one chunk */
5
+ export const CHUNK = 262_144;
6
+ /** The largest file, in bytes as stored */
7
+ export const MAX_FILE_SIZE = 2 ** 31;
8
+ /** Files a version names that peers take */
9
+ export const MAX_FILES = 16;
10
+ const HASH = /^[0-9a-f]{64}$/;
11
+ const isFileName = (value) => isRecord(value) &&
12
+ typeof value.hash === 'string' &&
13
+ HASH.test(value.hash) &&
14
+ typeof value.size === 'number' &&
15
+ Number.isSafeInteger(value.size) &&
16
+ value.size >= 1 &&
17
+ value.size <= MAX_FILE_SIZE;
18
+ /**
19
+ * The files a version names, as every peer takes them: in order, the first
20
+ * 16 well-formed entries with distinct ids; none on a delete. Never a reason
21
+ * to refuse the version.
22
+ */
23
+ export function filesOf(version) {
24
+ if (version.deleted || !Array.isArray(version.files))
25
+ return [];
26
+ const taken = [];
27
+ const seen = new Set();
28
+ for (const entry of version.files) {
29
+ if (taken.length === MAX_FILES)
30
+ break;
31
+ if (!isFileName(entry) || seen.has(entry.hash))
32
+ continue;
33
+ seen.add(entry.hash);
34
+ taken.push({ hash: entry.hash, size: entry.size });
35
+ }
36
+ return taken;
37
+ }
38
+ /** How many chunks a file of this size has */
39
+ export const chunkCount = (size) => Math.ceil(size / CHUNK);
40
+ /** How long chunk `index` of a file of this size is */
41
+ export const chunkLength = (size, index) => index < chunkCount(size) - 1 ? CHUNK : size - (chunkCount(size) - 1) * CHUNK;
42
+ /** The SHA-256 of each chunk, in order, concatenated */
43
+ export async function chunkListOf(bytes) {
44
+ const hashes = [];
45
+ for (let at = 0; at < bytes.length; at += CHUNK)
46
+ hashes.push(await sha256(bytes.subarray(at, at + CHUNK)));
47
+ return concatBytes(...hashes);
48
+ }
49
+ /** A file's id: SHA-256 of its size, as 8 bytes big-endian, and its chunk list */
50
+ export async function fileIdOf(size, list) {
51
+ const length = new Uint8Array(8);
52
+ new DataView(length.buffer).setBigUint64(0, BigInt(size));
53
+ return bytesToHex(await sha256(concatBytes(length, list)));
54
+ }
55
+ /** Whether a chunk list is the one this file's id names: exactly its length, and giving the id */
56
+ export async function listFits(file, list) {
57
+ return list.length === 32 * chunkCount(file.size) && (await fileIdOf(file.size, list)) === file.hash;
58
+ }
59
+ /**
60
+ * Whether these are the bytes of chunk `index`: its length, and the hash the
61
+ * list gives it. Without a list, only a file of one chunk can be checked: by
62
+ * its id.
63
+ */
64
+ export async function chunkFits(file, list, index, bytes) {
65
+ if (index < 0 || index >= chunkCount(file.size) || bytes.length !== chunkLength(file.size, index))
66
+ return false;
67
+ const hash = await sha256(bytes);
68
+ if (list)
69
+ return bytesToHex(hash) === bytesToHex(list.subarray(32 * index, 32 * index + 32));
70
+ return chunkCount(file.size) === 1 && (await fileIdOf(file.size, hash)) === file.hash;
71
+ }
72
+ /**
73
+ * The files a body refers to: every object in it shaped as a file reference
74
+ * (`hash`, `size`, `key` and `salt`, as `addFile` gives one). What the node
75
+ * names on a version it writes, so the envelope and the body agree.
76
+ */
77
+ export function fileRefsIn(body) {
78
+ const found = new Map();
79
+ const walk = (value, depth) => {
80
+ if (depth > 32)
81
+ return;
82
+ if (Array.isArray(value)) {
83
+ for (const item of value)
84
+ walk(item, depth + 1);
85
+ return;
86
+ }
87
+ if (!isRecord(value))
88
+ return;
89
+ if (isFileName(value) && typeof value.key === 'string' && typeof value.salt === 'string')
90
+ found.set(value.hash, { hash: value.hash, size: value.size });
91
+ for (const item of Object.values(value))
92
+ walk(item, depth + 1);
93
+ };
94
+ walk(body, 0);
95
+ return [...found.values()];
96
+ }
97
+ //# sourceMappingURL=file-id.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"file-id.js","sourceRoot":"","sources":["../../src/files/file-id.ts"],"names":[],"mappings":"AASA,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAC1C,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAC/D,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAE9C,qFAAqF;AACrF,MAAM,CAAC,MAAM,KAAK,GAAG,OAAO,CAAC;AAC7B,2CAA2C;AAC3C,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,IAAI,EAAE,CAAC;AACrC,4CAA4C;AAC5C,MAAM,CAAC,MAAM,SAAS,GAAG,EAAE,CAAC;AAQ5B,MAAM,IAAI,GAAG,gBAAgB,CAAC;AAE9B,MAAM,UAAU,GAAG,CAAC,KAAc,EAAqB,EAAE,CACvD,QAAQ,CAAC,KAAK,CAAC;IACf,OAAO,KAAK,CAAC,IAAI,KAAK,QAAQ;IAC9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I,EAAE,IAAI,EAAE,KAAK,CAAC,IAAI,EAAE,CAAC,CAAC;QAChE,KAAK,MAAM,IAAI,IAAI,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC;YAAE,IAAI,CAAC,IAAI,EAAE,KAAK,GAAG,CAAC,CAAC,CAAC;IACjE,CAAC,CAAC;IACF,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC;IACd,OAAO,CAAC,GAAG,KAAK,CAAC,MAAM,EAAE,CAAC,CAAC;AAC7B,CAAC"}
@@ -0,0 +1,20 @@
1
+ /** What opens a sealed file: carried in the body, never on the outside */
2
+ export interface FileKey {
3
+ /** 16 random bytes, base64url: RFC 8188's input keying material */
4
+ readonly key: string;
5
+ /** 16 random bytes, base64url */
6
+ readonly salt: string;
7
+ }
8
+ /** Seals a file under a fresh key and salt. `rs` is RFC 8188's record size; files use `CHUNK`. */
9
+ export declare function sealFile(plain: Uint8Array, rs?: number, key?: FileKey): Promise<{
10
+ readonly bytes: Uint8Array;
11
+ readonly key: FileKey;
12
+ }>;
13
+ /**
14
+ * Opens records of a sealed file, one at a time, in any order: what a reader
15
+ * seeking in a video needs. Throws for a record that is not that one, whole.
16
+ */
17
+ export declare function fileOpener(key: FileKey): (record: Uint8Array, index: number, last: boolean) => Promise<Uint8Array>;
18
+ /** Opens a whole sealed file */
19
+ export declare function openFile(bytes: Uint8Array, key: FileKey, rs?: number): Promise<Uint8Array>;
20
+ //# sourceMappingURL=seal.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"seal.d.ts","sourceRoot":"","sources":["../../src/files/seal.ts"],"names":[],"mappings":"AAWA,0EAA0E;AAC1E,MAAM,WAAW,OAAO;IACtB,mEAAmE;IACnE,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,iCAAiC;IACjC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;CACvB;AAoCD,kGAAkG;AAClG,wBAAsB,QAAQ,CAC5B,KAAK,EAAE,UAAU,EACjB,EAAE,GAAE,MAAc,EAClB,GAAG,GAAE,OAGJ,GACA,OAAO,CAAC;IAAE,QAAQ,CAAC,KAAK,EAAE,UAAU,CAAC;IAAC,QAAQ,CAAC,GAAG,EAAE,OAAO,CAAA;CAAE,CAAC,CAehE;AAED;;;GAGG;AACH,wBAAgB,UAAU,CACxB,GAAG,EAAE,OAAO,GACX,CAAC,MAAM,EAAE,UAAU,EAAE,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,KAAK,OAAO,CAAC,UAAU,CAAC,CAa3E;AAED,gCAAgC;AAChC,wBAAsB,QAAQ,CAAC,KAAK,EAAE,UAAU,EAAE,GAAG,EAAE,OAAO,EAAE,EAAE,GAAE,MAAc,GAAG,OAAO,CAAC,UAAU,CAAC,CAOvG"}
@@ -0,0 +1,77 @@
1
+ /**
2
+ * A file's bytes, sealed: the records of RFC 8188's `aes128gcm` content
3
+ * coding, without its header (spec 05 §16.6). The key and salt it would carry
4
+ * are in the body instead, so records line up with chunks: record `i` is
5
+ * chunk `i`. Every file is sealed, in a public space too, under a key of its
6
+ * own.
7
+ */
8
+ import { CHUNK } from './file-id.js';
9
+ import { bufferSource } from '../utils/guards.js';
10
+ import { base64UrlDecode, base64UrlEncode, concatBytes, utf8Encode } from '../utils/encoding.js';
11
+ const subtle = () => globalThis.crypto.subtle;
12
+ /** RFC 8188 §2.2 and §2.3: the content-encryption key and the base nonce, by HKDF-SHA-256 */
13
+ async function derive(key) {
14
+ const ikm = await subtle().importKey('raw', bufferSource(base64UrlDecode(key.key)), 'HKDF', false, [
15
+ 'deriveBits',
16
+ ]);
17
+ const salt = bufferSource(base64UrlDecode(key.salt));
18
+ const bits = (info, length) => subtle().deriveBits({ name: 'HKDF', hash: 'SHA-256', salt, info: utf8Encode(info) }, ikm, length);
19
+ const cek = await subtle().importKey('raw', await bits('Content-Encoding: aes128gcm\0', 128), 'AES-GCM', false, ['encrypt', 'decrypt']);
20
+ return { cek, nonce: new Uint8Array(await bits('Content-Encoding: nonce\0', 96)) };
21
+ }
22
+ /** The nonce of record `index`: the base nonce XOR the index, big-endian */
23
+ function nonceFor(base, index) {
24
+ const nonce = new Uint8Array(base);
25
+ let rest = index;
26
+ for (let i = nonce.length - 1; i >= 0 && rest > 0; i--) {
27
+ nonce[i] ^= rest & 0xff;
28
+ rest = Math.floor(rest / 256);
29
+ }
30
+ return nonce;
31
+ }
32
+ /** Plaintext bytes in a full record: the record, less the tag and the delimiter */
33
+ const plainPerRecord = (rs) => rs - 17;
34
+ /** Seals a file under a fresh key and salt. `rs` is RFC 8188's record size; files use `CHUNK`. */
35
+ export async function sealFile(plain, rs = CHUNK, key = {
36
+ key: base64UrlEncode(globalThis.crypto.getRandomValues(new Uint8Array(16))),
37
+ salt: base64UrlEncode(globalThis.crypto.getRandomValues(new Uint8Array(16))),
38
+ }) {
39
+ const { cek, nonce } = await derive(key);
40
+ const per = plainPerRecord(rs);
41
+ const count = Math.max(1, Math.ceil(plain.length / per));
42
+ const records = [];
43
+ for (let i = 0; i < count; i++) {
44
+ const last = i === count - 1;
45
+ const piece = concatBytes(plain.subarray(i * per, (i + 1) * per), new Uint8Array([last ? 2 : 1]));
46
+ records.push(new Uint8Array(await subtle().encrypt({ name: 'AES-GCM', iv: nonceFor(nonce, i) }, cek, bufferSource(piece))));
47
+ }
48
+ return { bytes: concatBytes(...records), key };
49
+ }
50
+ /**
51
+ * Opens records of a sealed file, one at a time, in any order: what a reader
52
+ * seeking in a video needs. Throws for a record that is not that one, whole.
53
+ */
54
+ export function fileOpener(key) {
55
+ const derived = derive(key);
56
+ return async (record, index, last) => {
57
+ const { cek, nonce } = await derived;
58
+ const piece = new Uint8Array(await subtle().decrypt({ name: 'AES-GCM', iv: nonceFor(nonce, index) }, cek, bufferSource(record)));
59
+ // The delimiter: 2 on the last record, 1 on every other, with only zeros (padding) after it.
60
+ let end = piece.length - 1;
61
+ while (end >= 0 && piece[end] === 0)
62
+ end--;
63
+ if (end < 0 || piece[end] !== (last ? 2 : 1))
64
+ throw new Error('Not this file’s record');
65
+ return piece.subarray(0, end);
66
+ };
67
+ }
68
+ /** Opens a whole sealed file */
69
+ export async function openFile(bytes, key, rs = CHUNK) {
70
+ const open = fileOpener(key);
71
+ const count = Math.max(1, Math.ceil(bytes.length / rs));
72
+ const pieces = [];
73
+ for (let i = 0; i < count; i++)
74
+ pieces.push(await open(bytes.subarray(i * rs, (i + 1) * rs), i, i === count - 1));
75
+ return concatBytes(...pieces);
76
+ }
77
+ //# sourceMappingURL=seal.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"seal.js","sourceRoot":"","sources":["../../src/files/seal.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,EAAE,KAAK,EAAE,MAAM,cAAc,CAAC;AACrC,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,eAAe,EAAE,eAAe,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAUjG,MAAM,MAAM,GAAG,GAAG,EAAE,CAAC,UAAU,CAAC,MAAM,CAAC,MAAM,CAAC;AAE9C,6FAA6F;AAC7F,KAAK,UAAU,MAAM,CAAC,GAAY;IAChC,MAAM,GAAG,GAAG,MAAM,MAAM,EAAE,CAAC,SAAS,CAAC,KAAK,EAAE,YAAY,CAAC,eAAe,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,EAAE,MAAM,EAAE,KAAK,EAAE;QACjG,YAAY;KACb,CAAC,CAAC;IACH,MAAM,IAAI,GAAG,YAAY,CAAC,eAAe,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC;IACrD,MAAM,IAAI,GAAG,CAAC,IAAY,EAAE,MAAc,EAAE,EAAE,CAC5C,MAAM,EAAE,CAAC,UAAU,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,SAAS,EAAE,IAAI,EAAE,IAAI,EAAE,UAAU,CAAC,IAAI,CAAC,EAAE,EAAE,GAAG,EAAE,MAAM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,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,KAAK,KAAK,GAAG,CAAC,CAAC,CAAC,CAAC;IACpF,OAAO,WAAW,CAAC,GAAG,MAAM,CAAC,CAAC;AAChC,CAAC"}
@@ -0,0 +1,51 @@
1
+ /**
2
+ * A space's files on this node (spec 05 §16.6): kept as entries in the
3
+ * space's own store, fetched from peers or mirrors chunk by chunk and checked
4
+ * as they come, served to peers, and dropped with the bodies that name them.
5
+ *
6
+ * ```
7
+ * f/<id>/list the chunk list
8
+ * f/<id>/<n> chunk n
9
+ * f/<id>/own added here and not yet named: the time it was added
10
+ * ```
11
+ */
12
+ import type { StorageAdapter, Version } from '../types.js';
13
+ import type { StorageProvider } from '../storage/storage-provider.js';
14
+ import type { BlobStore } from '../storage/blob-store.js';
15
+ import type { SyncMessageBody } from '../sync/sync-messages.js';
16
+ import { type FileName } from './file-id.js';
17
+ import { type FileKey } from './seal.js';
18
+ /** What `addFile` gives back: what names the file on a version, and what opens it, for the body */
19
+ export type SealedFile = FileName & FileKey;
20
+ /** A mirror a space's files are kept in, as its store writer */
21
+ export interface FileMirror {
22
+ readonly store: BlobStore;
23
+ readonly writer: string;
24
+ }
25
+ export interface SpaceFilesConfig {
26
+ readonly space: string;
27
+ readonly adapter: StorageAdapter;
28
+ readonly storage: StorageProvider;
29
+ /** Sends a sync message to a peer */
30
+ readonly send: (peer: string, message: SyncMessageBody) => void;
31
+ /** The peers connected now */
32
+ readonly peers: () => ReadonlyArray<string>;
33
+ /** Mirrors the space is kept in */
34
+ readonly mirrors?: () => ReadonlyArray<FileMirror>;
35
+ /** Whether a version stands: a version that doesn't, though kept whole, keeps no files here */
36
+ readonly stands?: (version: Version) => Promise<boolean>;
37
+ }
38
+ export type SpaceFiles = ReturnType<typeof createSpaceFiles>;
39
+ export declare function createSpaceFiles(config: SpaceFilesConfig): Readonly<{
40
+ add: (plain: Uint8Array) => Promise<SealedFile>;
41
+ read: (file: FileName) => Promise<Uint8Array>;
42
+ /** Opens a file a body refers to */
43
+ open: (ref: SealedFile) => Promise<Uint8Array>;
44
+ onMessage: (peer: string, message: unknown) => Promise<void>;
45
+ /** Something changed in the store: which files are named is worked out again */
46
+ changed(): void;
47
+ tidy: () => Promise<void>;
48
+ fetchAll: () => Promise<void>;
49
+ close(): void;
50
+ }>;
51
+ //# sourceMappingURL=space-files.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"space-files.d.ts","sourceRoot":"","sources":["../../src/files/space-files.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,OAAO,KAAK,EAAE,cAAc,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAC3D,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,gCAAgC,CAAC;AACtE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,0BAA0B,CAAC;AAC1D,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAC;AAChE,OAAO,EAUL,KAAK,QAAQ,EACd,MAAM,cAAc,CAAC;AACtB,OAAO,EAAsB,KAAK,OAAO,EAAE,MAAM,WAAW,CAAC;AAI7D,mGAAmG;AACnG,MAAM,MAAM,UAAU,GAAG,QAAQ,GAAG,OAAO,CAAC;AAE5C,gEAAgE;AAChE,MAAM,WAAW,UAAU;IACzB,QAAQ,CAAC,KAAK,EAAE,SAAS,CAAC;IAC1B,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;CACzB;AAED,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,OAAO,EAAE,cAAc,CAAC;IACjC,QAAQ,CAAC,OAAO,EAAE,eAAe,CAAC;IAClC,qCAAqC;IACrC,QAAQ,CAAC,IAAI,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,eAAe,KAAK,IAAI,CAAC;IAChE,8BAA8B;IAC9B,QAAQ,CAAC,KAAK,EAAE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