@siafoundation/sia-storage 0.1.2 → 0.1.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +41 -3
- package/dist/{chunk-QYQQIWFH.js → chunk-YOMDUMYW.js} +7 -3
- package/dist/chunk-YOMDUMYW.js.map +1 -0
- package/dist/index.d.ts +59 -6
- package/dist/index.js +120 -29
- package/dist/index.js.map +1 -1
- package/dist/index.node.d.ts +40 -15
- package/dist/next.js +1 -1
- package/dist/sia-storage-sw.js +2 -2
- package/dist/stream-worker.js +111 -14
- package/dist/stream-worker.js.map +1 -1
- package/package.json +8 -7
- package/wasm/sia_storage_wasm.d.ts +61 -38
- package/wasm/sia_storage_wasm.js +141 -40
- package/wasm/sia_storage_wasm_bg.wasm +0 -0
- package/wasm/sia_storage_wasm_bg.wasm.d.ts +10 -4
- package/dist/chunk-QYQQIWFH.js.map +0 -1
|
@@ -5,6 +5,7 @@ export const __wbg_appkey_free: (a: number, b: number) => void;
|
|
|
5
5
|
export const __wbg_builder_free: (a: number, b: number) => void;
|
|
6
6
|
export const __wbg_keyrecord_free: (a: number, b: number) => void;
|
|
7
7
|
export const __wbg_objectevent_free: (a: number, b: number) => void;
|
|
8
|
+
export const __wbg_objectsummary_free: (a: number, b: number) => void;
|
|
8
9
|
export const __wbg_packedupload_free: (a: number, b: number) => void;
|
|
9
10
|
export const __wbg_pinnedobject_free: (a: number, b: number) => void;
|
|
10
11
|
export const __wbg_sdk_free: (a: number, b: number) => void;
|
|
@@ -23,7 +24,7 @@ export const builder_register: (a: number, b: number, c: number) => any;
|
|
|
23
24
|
export const builder_requestConnection: (a: number) => any;
|
|
24
25
|
export const builder_responseUrl: (a: number) => [number, number, number, number];
|
|
25
26
|
export const builder_waitForApproval: (a: number) => any;
|
|
26
|
-
export const encodedSize: (a: number, b: number, c: number) => number;
|
|
27
|
+
export const encodedSize: (a: number, b: number, c: number) => [number, number, number];
|
|
27
28
|
export const generateRecoveryPhrase: () => [number, number];
|
|
28
29
|
export const init: () => void;
|
|
29
30
|
export const keyrecord_description: (a: number) => [number, number];
|
|
@@ -33,6 +34,11 @@ export const objectevent_deleted: (a: number) => number;
|
|
|
33
34
|
export const objectevent_id: (a: number) => [number, number];
|
|
34
35
|
export const objectevent_object: (a: number) => number;
|
|
35
36
|
export const objectevent_updatedAt: (a: number) => any;
|
|
37
|
+
export const objectsummary_createdAt: (a: number) => any;
|
|
38
|
+
export const objectsummary_id: (a: number) => [number, number];
|
|
39
|
+
export const objectsummary_metadata: (a: number) => [number, number];
|
|
40
|
+
export const objectsummary_size: (a: number) => number;
|
|
41
|
+
export const objectsummary_updatedAt: (a: number) => any;
|
|
36
42
|
export const packedupload_add: (a: number, b: any) => any;
|
|
37
43
|
export const packedupload_cancel: (a: number) => void;
|
|
38
44
|
export const packedupload_finalize: (a: number) => any;
|
|
@@ -63,13 +69,12 @@ export const sdk_objectEvents: (a: number, b: any, c: number) => any;
|
|
|
63
69
|
export const sdk_objectFromShareUrl: (a: number, b: number, c: number) => any;
|
|
64
70
|
export const sdk_objectShareUrl: (a: number, b: number, c: any) => [number, number, number, number];
|
|
65
71
|
export const sdk_pinObject: (a: number, b: number) => any;
|
|
66
|
-
export const sdk_pruneSlabs: (a: number) => any;
|
|
72
|
+
export const sdk_pruneSlabs: (a: number, b: number) => any;
|
|
67
73
|
export const sdk_revokeSharingKey: (a: number, b: number) => any;
|
|
68
74
|
export const sdk_shareObject: (a: number, b: number, c: number) => any;
|
|
69
75
|
export const sdk_sharedObjects: (a: number, b: number, c: number, d: number) => any;
|
|
70
76
|
export const sdk_sharingKey: (a: number, b: number) => any;
|
|
71
77
|
export const sdk_sharingKeys: (a: number, b: number, c: number) => any;
|
|
72
|
-
export const sdk_slab: (a: number, b: number, c: number) => any;
|
|
73
78
|
export const sdk_unshareObject: (a: number, b: number, c: number, d: number) => any;
|
|
74
79
|
export const sdk_updateObjectMetadata: (a: number, b: number) => any;
|
|
75
80
|
export const sdk_upload: (a: number, b: number, c: any, d: number) => any;
|
|
@@ -79,6 +84,7 @@ export const sharedsdk_connect: (a: number, b: number, c: number, d: number) =>
|
|
|
79
84
|
export const sharedsdk_download: (a: number, b: number, c: number) => [number, number, number];
|
|
80
85
|
export const sharedsdk_hosts: (a: number, b: number) => any;
|
|
81
86
|
export const sharedsdk_object: (a: number, b: number, c: number) => any;
|
|
87
|
+
export const sharedsdk_objectSummaries: (a: number, b: number, c: number) => any;
|
|
82
88
|
export const sharedsdk_objects: (a: number, b: number, c: number) => any;
|
|
83
89
|
export const sharedsdk_stats: (a: number) => any;
|
|
84
90
|
export const sharingkey_fromSeed: (a: number, b: number) => [number, number, number];
|
|
@@ -103,7 +109,7 @@ export const wasm_bindgen_a939ac12ad536d64___convert__closures_____invoke___wasm
|
|
|
103
109
|
export const wasm_bindgen_a939ac12ad536d64___convert__closures_____invoke___wasm_bindgen_a939ac12ad536d64___sys__Undefined__core_608f92abc48d28da___result__Result_____wasm_bindgen_a939ac12ad536d64___JsError___true_: (a: number, b: number, c: any) => [number, number];
|
|
104
110
|
export const wasm_bindgen_a939ac12ad536d64___convert__closures_____invoke___wasm_bindgen_a939ac12ad536d64___sys__Undefined__core_608f92abc48d28da___result__Result_____wasm_bindgen_a939ac12ad536d64___JsError___true__3: (a: number, b: number, c: any) => [number, number];
|
|
105
111
|
export const wasm_bindgen_a939ac12ad536d64___convert__closures_____invoke___wasm_bindgen_a939ac12ad536d64___sys__Undefined__core_608f92abc48d28da___result__Result_____wasm_bindgen_a939ac12ad536d64___JsError___true__4: (a: number, b: number, c: any) => [number, number];
|
|
106
|
-
export const
|
|
112
|
+
export const wasm_bindgen_a939ac12ad536d64___convert__closures_____invoke___js_sys_32e95d01f2c64d55___Function_fn_wasm_bindgen_a939ac12ad536d64___JsValue_____wasm_bindgen_a939ac12ad536d64___sys__Undefined___js_sys_32e95d01f2c64d55___Function_fn_wasm_bindgen_a939ac12ad536d64___JsValue_____wasm_bindgen_a939ac12ad536d64___sys__Undefined_______true_: (a: number, b: number, c: any, d: any) => void;
|
|
107
113
|
export const wasm_bindgen_a939ac12ad536d64___convert__closures_____invoke___wasm_bindgen_a939ac12ad536d64___JsValue______true_: (a: number, b: number, c: any) => void;
|
|
108
114
|
export const wasm_bindgen_a939ac12ad536d64___convert__closures_____invoke_______true_: (a: number, b: number) => void;
|
|
109
115
|
export const __wbindgen_malloc: (a: number, b: number) => number;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/stream/errors.ts","../src/stream/protocol.ts"],"sourcesContent":["/** Only sanitized strings cross the diagnostic boundary, never raw SDK objects. */\nexport function streamErrorMessage(error: unknown): string {\n const message =\n error instanceof Error\n ? error.message\n : typeof error === 'string'\n ? error\n : 'Unknown streaming failure'\n return message\n .replace(/\\b(?:https?|wss?|sia):\\/\\/[^\\s\"'<>]+/gi, '[URL redacted]')\n .replace(/(?:bearer\\s+)[^\\s,;]+/gi, 'Bearer [redacted]')\n .replace(\n /((?:seed|share|token|key|authorization)\\s*[=:]\\s*)[^\\s,;]+/gi,\n '$1[redacted]',\n )\n .replace(/[a-f0-9]{64,}/gi, '[redacted]')\n .replace(/[\\r\\n\\t]/g, ' ')\n .slice(0, 1000)\n}\n\nexport function reportStreamError(\n error: unknown,\n name: string,\n range: { offset: number; length: number } | undefined,\n) {\n const message = streamErrorMessage(error)\n // One string rather than an object, so it reads the same in every console.\n const bytes = range\n ? ` bytes ${range.offset}-${range.offset + range.length - 1}`\n : ''\n console.error(`[Sia stream] ${streamErrorMessage(name)}${bytes}: ${message}`)\n return message\n}\n","/**\n * Messages between a page and its streaming service worker.\n *\n * Stream URLs carry only the page's client id and a random token. When the\n * worker meets a token it does not know, it asks the page that made it for the\n * file and the share's credentials. The page and a worker can come from\n * different deployed versions, so the worker checks the page's reply before\n * using it.\n */\nimport type {\n AppMetadata,\n SealedObject,\n} from '../../wasm/sia_storage_wasm.js'\n\n/**\n * What the worker connects its own SDK with. A `SharedSdk` reconnects from its\n * sharing key's seed, and an `Sdk` from its app key, as hex, and app metadata.\n */\nexport type Connection =\n | { kind: 'shared'; indexerUrl: string; seed: string }\n | { kind: 'app'; indexerUrl: string; appKey: string; appMeta: AppMetadata }\n\nexport type SourceDetails = {\n // One per opened SDK, so the worker can release it as a whole.\n session: string\n connection: Connection\n objectId: string\n // An `Sdk`'s object, sealed with its app key, so the worker can open it\n // without a lookup. A `SharedSdk`'s object is looked up by `objectId`.\n sealed?: SealedObject\n name: string\n mime: string\n size: number\n}\n\n/** Page to worker. */\nexport type PageMessage =\n | { type: 'sia-client' }\n | { type: 'sia-release'; token: string }\n | { type: 'sia-release-share'; session: string }\n\n/** Worker to page. */\nexport type WorkerMessage =\n | { type: 'sia-source'; token: string }\n | {\n type: 'sia-stream-error'\n token: string\n message: string\n offset?: number\n length?: number\n }\n\n/** The worker's answer to `sia-client`. */\nexport type ClientReply = { clientId: string; supported: boolean }\n\n/** The page's answer to `sia-source`. */\nexport type SourceReply =\n | ({ type: 'source' } & SourceDetails)\n | { type: 'error' }\n\n// Stream URLs sit under the worker's scope, so a download's navigation, which\n// only a worker whose scope covers the URL can answer, reaches it on sites\n// served from a sub-path too.\nconst STREAM_PATH = /\\/__sia_stream__\\/([^/]+)\\/([^/]+)\\/[^/]+$/\n\n/** `scope` is the worker registration's scope URL, which ends in a slash. */\nexport function streamPath(scope: string, clientId: string, token: string) {\n return `${scope}__sia_stream__/${clientId}/${token}/file`\n}\n\nexport function parseStreamPath(pathname: string) {\n const match = STREAM_PATH.exec(pathname)\n return match ? { clientId: match[1]!, token: match[2]! } : undefined\n}\n\ntype Fields = Record<string, unknown> | null | undefined\n\nconst strings = (data: Fields, fields: string[]) =>\n fields.every((field) => typeof data?.[field] === 'string')\n\n/** Checked on both sides, so bad metadata fails in `openStreams`, not per request. */\nexport function isAppMetadata(value: unknown): value is AppMetadata {\n return strings(value as Fields, ['appId', 'name', 'description', 'serviceUrl'])\n}\n\nfunction isConnection(value: unknown): value is Connection {\n const data = value as Fields\n if (data?.kind === 'shared') return strings(data, ['indexerUrl', 'seed'])\n return (\n data?.kind === 'app' &&\n strings(data, ['indexerUrl', 'appKey']) &&\n isAppMetadata(data.appMeta)\n )\n}\n\nexport function isSourceReply(\n reply: unknown,\n): reply is { type: 'source' } & SourceDetails {\n const data = reply as Fields\n return (\n data?.type === 'source' &&\n strings(data, ['session', 'objectId', 'name', 'mime']) &&\n isConnection(data.connection) &&\n (data.connection.kind === 'shared' ||\n (typeof data.sealed === 'object' && data.sealed !== null)) &&\n Number.isSafeInteger(data.size) &&\n (data.size as number) >= 0\n )\n}\n\n/**\n * Posts `message` with a reply port and resolves with the first reply. Rejects\n * after `timeout` ms, or when `signal` aborts.\n */\nexport function requestReply(\n target: { postMessage(message: unknown, transfer: Transferable[]): void },\n message: unknown,\n { timeout, signal }: { timeout?: number; signal?: AbortSignal },\n): Promise<unknown> {\n return new Promise((resolve, reject) => {\n const { port1, port2 } = new MessageChannel()\n const timer =\n timeout === undefined\n ? undefined\n : setTimeout(\n () => settle(() => reject(new Error('No reply in time.'))),\n timeout,\n )\n const abort = () => settle(() => reject(signal?.reason))\n function settle(outcome: () => void) {\n clearTimeout(timer)\n signal?.removeEventListener('abort', abort)\n port1.close()\n port2.close()\n outcome()\n }\n if (signal?.aborted) return abort()\n signal?.addEventListener('abort', abort, { once: true })\n port1.onmessage = ({ data }) => settle(() => resolve(data))\n port1.onmessageerror = () =>\n settle(() => reject(new Error('Unreadable reply.')))\n try {\n target.postMessage(message, [port2])\n } catch (error) {\n settle(() => reject(error))\n }\n })\n}\n"],"mappings":";AACO,SAAS,mBAAmB,OAAwB;AACzD,QAAM,UACJ,iBAAiB,QACb,MAAM,UACN,OAAO,UAAU,WACf,QACA;AACR,SAAO,QACJ,QAAQ,0CAA0C,gBAAgB,EAClE,QAAQ,2BAA2B,mBAAmB,EACtD;AAAA,IACC;AAAA,IACA;AAAA,EACF,EACC,QAAQ,mBAAmB,YAAY,EACvC,QAAQ,aAAa,GAAG,EACxB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