@tinycloud/node-sdk 3.6.2-beta.0 → 3.7.0-beta.1
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/dist/{TinyCloudNode--OyL6lZh.d.ts → TinyCloudNode-BHiKCQ4W.d.ts} +8 -6
- package/dist/{TinyCloudNode-BMi72EIk.d.cts → TinyCloudNode-DrLNh4bs.d.cts} +8 -6
- package/dist/{authority-DSG538B7.d.ts → authority-BHVqCPyl.d.ts} +1 -1
- package/dist/{authority-U0m7P2TE.d.cts → authority-BVmX2vCi.d.cts} +1 -1
- package/dist/core.cjs +18 -8
- package/dist/core.cjs.map +1 -1
- package/dist/core.d.cts +2 -2
- package/dist/core.d.ts +2 -2
- package/dist/core.js +22 -9
- package/dist/core.js.map +1 -1
- package/dist/index.cjs +18 -8
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +22 -9
- package/dist/index.js.map +1 -1
- package/dist/replication/authority.d.cts +2 -2
- package/dist/replication/authority.d.ts +2 -2
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -25249,8 +25249,14 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
25249
25249
|
fetch: globalThis.fetch.bind(globalThis)
|
|
25250
25250
|
});
|
|
25251
25251
|
}
|
|
25252
|
-
/**
|
|
25252
|
+
/**
|
|
25253
|
+
* Authorize one short-lived v3 delivery. `shareUrl` is the short `/s/<id>#v=4&k=…&c=…` link: the node fetches the
|
|
25254
|
+
* sealed body by id and opens it with the link's key, so the body of the request carries the link and nothing else
|
|
25255
|
+
* of the share. `envelope` is the signed v3 envelope the sender holds; it checks the node's admission here and is
|
|
25256
|
+
* not sent.
|
|
25257
|
+
*/
|
|
25253
25258
|
async authorizeShareDeliveryV3(input) {
|
|
25259
|
+
const envelopeRef = await (0, import_sdk_core10.shortDeliveryLinkBodyCid)(input.shareUrl, input.trustedOrigins);
|
|
25254
25260
|
const session = this.currentTinyCloudSession();
|
|
25255
25261
|
const serviceSession = this._serviceContext?.session;
|
|
25256
25262
|
if (!session || !serviceSession) throw new Error("Share delivery requires an authenticated session");
|
|
@@ -25260,15 +25266,12 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
25260
25266
|
}
|
|
25261
25267
|
const jtiDigest = new Uint8Array(await crypto.subtle.digest("SHA-256", idempotencyBytes));
|
|
25262
25268
|
const body = {
|
|
25263
|
-
envelope: input.envelope,
|
|
25264
|
-
sealedEnvelope: input.sealedEnvelope,
|
|
25265
|
-
envelopeKey: input.envelopeKey,
|
|
25266
|
-
shareCid: input.shareCid,
|
|
25267
25269
|
recipientEmail: input.recipientEmail,
|
|
25268
25270
|
shareUrl: input.shareUrl,
|
|
25269
25271
|
documentName: input.documentName,
|
|
25270
25272
|
jti: base64UrlEncode(jtiDigest.slice(0, 16)),
|
|
25271
|
-
|
|
25273
|
+
// Re-normalised through Date, so the sent value is always `YYYY-MM-DDTHH:mm:ss.SSSZ` (UTC, three digits).
|
|
25274
|
+
expiresAt: new Date(input.expiresAt).toISOString()
|
|
25272
25275
|
};
|
|
25273
25276
|
const requestBodyDigest = base64UrlEncode(new Uint8Array(await crypto.subtle.digest("SHA-256", new TextEncoder().encode((0, import_sdk_core10.canonicalizeEncryptionJson)(body)))));
|
|
25274
25277
|
const request = { ...body, requestBodyDigest };
|
|
@@ -25278,9 +25281,16 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
25278
25281
|
headers: { accept: "application/json", "content-type": "application/json", authorization },
|
|
25279
25282
|
body: (0, import_sdk_core10.canonicalizeEncryptionJson)(request)
|
|
25280
25283
|
});
|
|
25281
|
-
if (
|
|
25282
|
-
|
|
25284
|
+
if (response.status === 400 || response.status === 422) throw new import_sdk_core10.ShareDeliveryRefusedError();
|
|
25285
|
+
if (!response.ok) {
|
|
25286
|
+
const reply = await response.text().catch(() => response.statusText);
|
|
25287
|
+
const body2 = (await (0, import_sdk_core10.withoutShareLink)(reply, input.shareUrl)).trim().slice(0, 512);
|
|
25288
|
+
throw Object.assign(new Error(`V3 share delivery authorization failed: HTTP ${response.status}${body2 ? ` - ${body2}` : ""}`), { status: response.status });
|
|
25289
|
+
}
|
|
25290
|
+
const verified = await (0, import_sdk_core10.verifyShareDeliveryAuthorizationV3Bytes)(new Uint8Array(await response.arrayBuffer()), {
|
|
25283
25291
|
request,
|
|
25292
|
+
envelope: input.envelope,
|
|
25293
|
+
envelopeRef,
|
|
25284
25294
|
senderKeyDid: this.credentialHolderDid,
|
|
25285
25295
|
deliveryAudience: input.deliveryAudience
|
|
25286
25296
|
});
|