@tinycloud/share-sdk 1.5.0-beta.3 → 1.5.0-beta.5
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 +9 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +9 -2
- package/dist/index.js.map +1 -1
- package/dist/share-index.cjs.map +1 -1
- package/dist/share-index.js.map +1 -1
- package/dist/share-root.cjs +14 -5
- package/dist/share-root.cjs.map +1 -1
- package/dist/share-root.js +14 -5
- package/dist/share-root.js.map +1 -1
- package/dist/web-recipient.cjs +8 -1
- package/dist/web-recipient.cjs.map +1 -1
- package/dist/web-recipient.js +8 -1
- package/dist/web-recipient.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -320,6 +320,7 @@ interface NativeSharingService {
|
|
|
320
320
|
readonly path: string;
|
|
321
321
|
readonly actions: string[];
|
|
322
322
|
readonly expiry: Date;
|
|
323
|
+
readonly includePlacement?: boolean;
|
|
323
324
|
}): Promise<unknown>;
|
|
324
325
|
receive(token: string, options: {
|
|
325
326
|
readonly autoSubdelegate: false;
|
|
@@ -335,6 +336,7 @@ declare function createNativeShare(sharing: NativeSharingService, input: {
|
|
|
335
336
|
readonly path: string;
|
|
336
337
|
readonly expiresAt: Date;
|
|
337
338
|
readonly viewerOrigin: string;
|
|
339
|
+
readonly includePlacement?: boolean;
|
|
338
340
|
}): Promise<NativeShareResult>;
|
|
339
341
|
/** Extract only a single tc1 fragment. Path/query/mixed legacy forms are refused. */
|
|
340
342
|
declare function parseNativeShareUrl(value: string): string;
|
package/dist/index.d.ts
CHANGED
|
@@ -320,6 +320,7 @@ interface NativeSharingService {
|
|
|
320
320
|
readonly path: string;
|
|
321
321
|
readonly actions: string[];
|
|
322
322
|
readonly expiry: Date;
|
|
323
|
+
readonly includePlacement?: boolean;
|
|
323
324
|
}): Promise<unknown>;
|
|
324
325
|
receive(token: string, options: {
|
|
325
326
|
readonly autoSubdelegate: false;
|
|
@@ -335,6 +336,7 @@ declare function createNativeShare(sharing: NativeSharingService, input: {
|
|
|
335
336
|
readonly path: string;
|
|
336
337
|
readonly expiresAt: Date;
|
|
337
338
|
readonly viewerOrigin: string;
|
|
339
|
+
readonly includePlacement?: boolean;
|
|
338
340
|
}): Promise<NativeShareResult>;
|
|
339
341
|
/** Extract only a single tc1 fragment. Path/query/mixed legacy forms are refused. */
|
|
340
342
|
declare function parseNativeShareUrl(value: string): string;
|
package/dist/index.js
CHANGED
|
@@ -8887,6 +8887,13 @@ async function showShare(input) {
|
|
|
8887
8887
|
import { ed25519 as ed255195, x25519 } from "@noble/curves/ed25519";
|
|
8888
8888
|
import { sha256 as sha2567 } from "@noble/hashes/sha256";
|
|
8889
8889
|
|
|
8890
|
+
// src/encryption-origin.ts
|
|
8891
|
+
var TEE_NODE_ORIGIN = "https://tee.node.tinycloud.xyz";
|
|
8892
|
+
var PRODUCTION_NODE_ORIGINS = /* @__PURE__ */ new Set(["https://node.tinycloud.xyz", TEE_NODE_ORIGIN]);
|
|
8893
|
+
function encryptionNodeOrigin(nodeOrigin) {
|
|
8894
|
+
return PRODUCTION_NODE_ORIGINS.has(nodeOrigin) ? TEE_NODE_ORIGIN : nodeOrigin;
|
|
8895
|
+
}
|
|
8896
|
+
|
|
8890
8897
|
// src/protocol.ts
|
|
8891
8898
|
var SHARE_V2_PROTOCOL = Object.freeze({
|
|
8892
8899
|
challengeDomain: "xyz.tinycloud.share/policy-challenge/v2\0",
|
|
@@ -9255,7 +9262,7 @@ var ShareRecipientClient = class {
|
|
|
9255
9262
|
});
|
|
9256
9263
|
try {
|
|
9257
9264
|
this.options.onStage?.("decryption");
|
|
9258
|
-
const response = await this.fetchFn(new URL("/invoke", this.options.nodeOrigin), { method: "POST", redirect: "error", headers: { accept: "application/json", "content-type": "application/json", Authorization: invocation.authorization }, body: JSON.stringify(body), ...this.options.signal === void 0 ? {} : { signal: this.options.signal } });
|
|
9265
|
+
const response = await this.fetchFn(new URL("/invoke", encryptionNodeOrigin(this.options.nodeOrigin)), { method: "POST", redirect: "error", headers: { accept: "application/json", "content-type": "application/json", Authorization: invocation.authorization }, body: JSON.stringify(body), ...this.options.signal === void 0 ? {} : { signal: this.options.signal } });
|
|
9259
9266
|
if (!response.ok) throw await recipientHttpError(response, "v3 decrypt invocation rejected");
|
|
9260
9267
|
const value = object3(await response.json(), "v3 decrypt response");
|
|
9261
9268
|
const allowed = ["type", "targetNode", "networkId", "invocationCid", "encryptedSymmetricKeyHash", "receiverPublicKeyHash", "wrappedKey", "alg", "keyVersion", "requestHash", "nodeId", "nodeSignature"];
|
|
@@ -9398,7 +9405,7 @@ function canonicalViewerUrl(viewerOrigin) {
|
|
|
9398
9405
|
}
|
|
9399
9406
|
async function createNativeShare(sharing, input) {
|
|
9400
9407
|
if (!input.path || input.path.startsWith("/") || input.path.endsWith("/") || input.path.includes("..") || input.path.includes("//")) throw new TypeError("native share path must be one canonical TinyCloud KV key");
|
|
9401
|
-
const generated = await sharing.generate({ path: input.path, actions: ["tinycloud.kv/get"], expiry: input.expiresAt });
|
|
9408
|
+
const generated = await sharing.generate({ path: input.path, actions: ["tinycloud.kv/get"], expiry: input.expiresAt, ...input.includePlacement === void 0 ? {} : { includePlacement: input.includePlacement } });
|
|
9402
9409
|
if (generated.ok !== true) {
|
|
9403
9410
|
const error = new Error(typeof generated.error?.message === "string" ? generated.error.message : "TinyCloud sharing service rejected delegation generation");
|
|
9404
9411
|
if (typeof generated.error?.code === "string") Object.assign(error, { code: generated.error.code });
|