@tinycloud/node-sdk 3.0.0-beta.2 → 3.0.0-beta.6
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/{core-C6Czyr52.d.cts → core-UWQ41yuo.d.cts} +18 -1
- package/dist/{core-C6Czyr52.d.ts → core-UWQ41yuo.d.ts} +18 -1
- package/dist/core.cjs +31 -0
- package/dist/core.cjs.map +1 -1
- package/dist/core.d.cts +1 -1
- package/dist/core.d.ts +1 -1
- package/dist/core.js +32 -0
- package/dist/core.js.map +1 -1
- package/dist/index.cjs +31 -0
- 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 +32 -0
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -22269,6 +22269,37 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
22269
22269
|
const responseBytes = new Uint8Array(await response.arrayBuffer());
|
|
22270
22270
|
return (0, import_sdk_core7.validateShareDeliveryAuthorizationBytes)(responseBytes, { request, nodeProof: input.nodeProof, credentialsAudience: input.credentialsAudience });
|
|
22271
22271
|
}
|
|
22272
|
+
/** Authorize one short-lived v3 delivery against the signed v3 envelope and registered roots. */
|
|
22273
|
+
async authorizeShareDeliveryV3(input) {
|
|
22274
|
+
const session = this.currentTinyCloudSession();
|
|
22275
|
+
const serviceSession = this._serviceContext?.session;
|
|
22276
|
+
if (!session || !serviceSession) throw new Error("Share delivery requires an authenticated session");
|
|
22277
|
+
const body = {
|
|
22278
|
+
envelope: input.envelope,
|
|
22279
|
+
sealedEnvelope: input.sealedEnvelope,
|
|
22280
|
+
envelopeKey: input.envelopeKey,
|
|
22281
|
+
shareCid: input.shareCid,
|
|
22282
|
+
recipientEmail: input.recipientEmail,
|
|
22283
|
+
shareUrl: input.shareUrl,
|
|
22284
|
+
documentName: input.documentName,
|
|
22285
|
+
jti: base64UrlEncode(crypto.getRandomValues(new Uint8Array(16))),
|
|
22286
|
+
expiresAt: input.expiresAt
|
|
22287
|
+
};
|
|
22288
|
+
const requestBodyDigest = base64UrlEncode(new Uint8Array(await crypto.subtle.digest("SHA-256", new TextEncoder().encode((0, import_sdk_core7.canonicalizeEncryptionJson)(body)))));
|
|
22289
|
+
const request = { ...body, requestBodyDigest };
|
|
22290
|
+
const authorization = authorizationHeader(this.invokeAnyWithRuntimePermissions(serviceSession, [{ spaceId: session.spaceId, service: "kv", path: input.resourcePath, action: "tinycloud.kv/get" }]));
|
|
22291
|
+
const response = await fetch(`${this.config.host}/share/v3/deliveries/authorize`, {
|
|
22292
|
+
method: "POST",
|
|
22293
|
+
headers: { accept: "application/json", "content-type": "application/json", authorization },
|
|
22294
|
+
body: (0, import_sdk_core7.canonicalizeEncryptionJson)(request)
|
|
22295
|
+
});
|
|
22296
|
+
if (!response.ok) throw new Error(`V3 share delivery authorization failed: ${response.status}`);
|
|
22297
|
+
return (0, import_sdk_core7.validateShareDeliveryAuthorizationV3Bytes)(new Uint8Array(await response.arrayBuffer()), {
|
|
22298
|
+
request,
|
|
22299
|
+
nodeProof: input.nodeProof,
|
|
22300
|
+
credentialsAudience: input.credentialsAudience
|
|
22301
|
+
});
|
|
22302
|
+
}
|
|
22272
22303
|
async createRootDelegationForSharing(params, assertActive) {
|
|
22273
22304
|
try {
|
|
22274
22305
|
return (await this.createOwnerDelegation({
|