@tinycloud/node-sdk 3.0.0-beta.5 → 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/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({