@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
|
@@ -2040,14 +2040,14 @@ declare class TinyCloudNode {
|
|
|
2040
2040
|
signOwnerRevocation(cid: string): Promise<string>;
|
|
2041
2041
|
/** Register a signed policy and sibling roots with this Node's Policy/v3 runtime. */
|
|
2042
2042
|
registerPolicy(params: Omit<RegisterPolicyV3Input, "nodeOrigin" | "fetch">): Promise<RegisterPolicyV3Receipt>;
|
|
2043
|
-
/**
|
|
2043
|
+
/**
|
|
2044
|
+
* Authorize one short-lived v3 delivery. `shareUrl` is the short `/s/<id>#v=4&k=…&c=…` link: the node fetches the
|
|
2045
|
+
* sealed body by id and opens it with the link's key, so the body of the request carries the link and nothing else
|
|
2046
|
+
* of the share. `envelope` is the signed v3 envelope the sender holds; it checks the node's admission here and is
|
|
2047
|
+
* not sent.
|
|
2048
|
+
*/
|
|
2044
2049
|
authorizeShareDeliveryV3(input: {
|
|
2045
2050
|
readonly envelope: Record<string, CanonicalJson | undefined>;
|
|
2046
|
-
/** Canonical sealed recipient envelope: version || nonce || ciphertext+tag. */
|
|
2047
|
-
readonly sealedEnvelope: string;
|
|
2048
|
-
/** Base64url 32-byte envelope key; it must also be the URL fragment key. */
|
|
2049
|
-
readonly envelopeKey: string;
|
|
2050
|
-
readonly shareCid: string;
|
|
2051
2051
|
readonly resourcePath: string;
|
|
2052
2052
|
readonly recipientEmail: string;
|
|
2053
2053
|
readonly shareUrl: string;
|
|
@@ -2056,6 +2056,8 @@ declare class TinyCloudNode {
|
|
|
2056
2056
|
readonly deliveryAudience: string;
|
|
2057
2057
|
/** Stable caller retry identity. It is hashed into the protocol's 16-byte JTI. */
|
|
2058
2058
|
readonly idempotencyKey: string;
|
|
2059
|
+
/** The origins `shareUrl` may be on: the node's `return_origin`. Default: `https://share.tinycloud.xyz`. */
|
|
2060
|
+
readonly trustedOrigins?: readonly string[];
|
|
2059
2061
|
}): Promise<ShareDeliveryAuthorizationV3Receipt>;
|
|
2060
2062
|
private createRootDelegationForSharing;
|
|
2061
2063
|
/**
|
|
@@ -2040,14 +2040,14 @@ declare class TinyCloudNode {
|
|
|
2040
2040
|
signOwnerRevocation(cid: string): Promise<string>;
|
|
2041
2041
|
/** Register a signed policy and sibling roots with this Node's Policy/v3 runtime. */
|
|
2042
2042
|
registerPolicy(params: Omit<RegisterPolicyV3Input, "nodeOrigin" | "fetch">): Promise<RegisterPolicyV3Receipt>;
|
|
2043
|
-
/**
|
|
2043
|
+
/**
|
|
2044
|
+
* Authorize one short-lived v3 delivery. `shareUrl` is the short `/s/<id>#v=4&k=…&c=…` link: the node fetches the
|
|
2045
|
+
* sealed body by id and opens it with the link's key, so the body of the request carries the link and nothing else
|
|
2046
|
+
* of the share. `envelope` is the signed v3 envelope the sender holds; it checks the node's admission here and is
|
|
2047
|
+
* not sent.
|
|
2048
|
+
*/
|
|
2044
2049
|
authorizeShareDeliveryV3(input: {
|
|
2045
2050
|
readonly envelope: Record<string, CanonicalJson | undefined>;
|
|
2046
|
-
/** Canonical sealed recipient envelope: version || nonce || ciphertext+tag. */
|
|
2047
|
-
readonly sealedEnvelope: string;
|
|
2048
|
-
/** Base64url 32-byte envelope key; it must also be the URL fragment key. */
|
|
2049
|
-
readonly envelopeKey: string;
|
|
2050
|
-
readonly shareCid: string;
|
|
2051
2051
|
readonly resourcePath: string;
|
|
2052
2052
|
readonly recipientEmail: string;
|
|
2053
2053
|
readonly shareUrl: string;
|
|
@@ -2056,6 +2056,8 @@ declare class TinyCloudNode {
|
|
|
2056
2056
|
readonly deliveryAudience: string;
|
|
2057
2057
|
/** Stable caller retry identity. It is hashed into the protocol's 16-byte JTI. */
|
|
2058
2058
|
readonly idempotencyKey: string;
|
|
2059
|
+
/** The origins `shareUrl` may be on: the node's `return_origin`. Default: `https://share.tinycloud.xyz`. */
|
|
2060
|
+
readonly trustedOrigins?: readonly string[];
|
|
2059
2061
|
}): Promise<ShareDeliveryAuthorizationV3Receipt>;
|
|
2060
2062
|
private createRootDelegationForSharing;
|
|
2061
2063
|
/**
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { ReplicationOptions, PermissionEntry, TinyCloudSession, KVReplicaStorage, ServiceContext, IWasmBindings, WasmRecapEntry } from '@tinycloud/sdk-core';
|
|
2
2
|
import { ReplicaConsentAnchor, AuthorityRefusal, ReplicationAuthority } from '@tinycloud/sdk-services';
|
|
3
3
|
import { ReplicaSessionStamp, ReplicaDenyInput } from '@tinycloud/sdk-services/kv/replication';
|
|
4
|
-
import { T as TinyCloudNode } from './TinyCloudNode
|
|
4
|
+
import { T as TinyCloudNode } from './TinyCloudNode-BHiKCQ4W.js';
|
|
5
5
|
|
|
6
6
|
/** Constructor-time validation; the space-dependent secrets check runs at sign-in and open. */
|
|
7
7
|
declare function assertValidReplicationConfig(replication: (ReplicationOptions & {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { ReplicationOptions, PermissionEntry, TinyCloudSession, KVReplicaStorage, ServiceContext, IWasmBindings, WasmRecapEntry } from '@tinycloud/sdk-core';
|
|
2
2
|
import { ReplicaConsentAnchor, AuthorityRefusal, ReplicationAuthority } from '@tinycloud/sdk-services';
|
|
3
3
|
import { ReplicaSessionStamp, ReplicaDenyInput } from '@tinycloud/sdk-services/kv/replication';
|
|
4
|
-
import { T as TinyCloudNode } from './TinyCloudNode-
|
|
4
|
+
import { T as TinyCloudNode } from './TinyCloudNode-DrLNh4bs.cjs';
|
|
5
5
|
|
|
6
6
|
/** Constructor-time validation; the space-dependent secrets check runs at sign-in and open. */
|
|
7
7
|
declare function assertValidReplicationConfig(replication: (ReplicationOptions & {
|
package/dist/core.cjs
CHANGED
|
@@ -7422,8 +7422,14 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
7422
7422
|
fetch: globalThis.fetch.bind(globalThis)
|
|
7423
7423
|
});
|
|
7424
7424
|
}
|
|
7425
|
-
/**
|
|
7425
|
+
/**
|
|
7426
|
+
* Authorize one short-lived v3 delivery. `shareUrl` is the short `/s/<id>#v=4&k=…&c=…` link: the node fetches the
|
|
7427
|
+
* sealed body by id and opens it with the link's key, so the body of the request carries the link and nothing else
|
|
7428
|
+
* of the share. `envelope` is the signed v3 envelope the sender holds; it checks the node's admission here and is
|
|
7429
|
+
* not sent.
|
|
7430
|
+
*/
|
|
7426
7431
|
async authorizeShareDeliveryV3(input) {
|
|
7432
|
+
const envelopeRef = await (0, import_sdk_core11.shortDeliveryLinkBodyCid)(input.shareUrl, input.trustedOrigins);
|
|
7427
7433
|
const session = this.currentTinyCloudSession();
|
|
7428
7434
|
const serviceSession = this._serviceContext?.session;
|
|
7429
7435
|
if (!session || !serviceSession) throw new Error("Share delivery requires an authenticated session");
|
|
@@ -7433,15 +7439,12 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
7433
7439
|
}
|
|
7434
7440
|
const jtiDigest = new Uint8Array(await crypto.subtle.digest("SHA-256", idempotencyBytes));
|
|
7435
7441
|
const body = {
|
|
7436
|
-
envelope: input.envelope,
|
|
7437
|
-
sealedEnvelope: input.sealedEnvelope,
|
|
7438
|
-
envelopeKey: input.envelopeKey,
|
|
7439
|
-
shareCid: input.shareCid,
|
|
7440
7442
|
recipientEmail: input.recipientEmail,
|
|
7441
7443
|
shareUrl: input.shareUrl,
|
|
7442
7444
|
documentName: input.documentName,
|
|
7443
7445
|
jti: base64UrlEncode(jtiDigest.slice(0, 16)),
|
|
7444
|
-
|
|
7446
|
+
// Re-normalised through Date, so the sent value is always `YYYY-MM-DDTHH:mm:ss.SSSZ` (UTC, three digits).
|
|
7447
|
+
expiresAt: new Date(input.expiresAt).toISOString()
|
|
7445
7448
|
};
|
|
7446
7449
|
const requestBodyDigest = base64UrlEncode(new Uint8Array(await crypto.subtle.digest("SHA-256", new TextEncoder().encode((0, import_sdk_core11.canonicalizeEncryptionJson)(body)))));
|
|
7447
7450
|
const request = { ...body, requestBodyDigest };
|
|
@@ -7451,9 +7454,16 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
7451
7454
|
headers: { accept: "application/json", "content-type": "application/json", authorization },
|
|
7452
7455
|
body: (0, import_sdk_core11.canonicalizeEncryptionJson)(request)
|
|
7453
7456
|
});
|
|
7454
|
-
if (
|
|
7455
|
-
|
|
7457
|
+
if (response.status === 400 || response.status === 422) throw new import_sdk_core11.ShareDeliveryRefusedError();
|
|
7458
|
+
if (!response.ok) {
|
|
7459
|
+
const reply = await response.text().catch(() => response.statusText);
|
|
7460
|
+
const body2 = (await (0, import_sdk_core11.withoutShareLink)(reply, input.shareUrl)).trim().slice(0, 512);
|
|
7461
|
+
throw Object.assign(new Error(`V3 share delivery authorization failed: HTTP ${response.status}${body2 ? ` - ${body2}` : ""}`), { status: response.status });
|
|
7462
|
+
}
|
|
7463
|
+
const verified = await (0, import_sdk_core11.verifyShareDeliveryAuthorizationV3Bytes)(new Uint8Array(await response.arrayBuffer()), {
|
|
7456
7464
|
request,
|
|
7465
|
+
envelope: input.envelope,
|
|
7466
|
+
envelopeRef,
|
|
7457
7467
|
senderKeyDid: this.credentialHolderDid,
|
|
7458
7468
|
deliveryAudience: input.deliveryAudience
|
|
7459
7469
|
});
|