@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 CHANGED
@@ -9000,6 +9000,13 @@ async function showShare(input) {
9000
9000
  var import_ed255195 = require("@noble/curves/ed25519");
9001
9001
  var import_sha2566 = require("@noble/hashes/sha256");
9002
9002
 
9003
+ // src/encryption-origin.ts
9004
+ var TEE_NODE_ORIGIN = "https://tee.node.tinycloud.xyz";
9005
+ var PRODUCTION_NODE_ORIGINS = /* @__PURE__ */ new Set(["https://node.tinycloud.xyz", TEE_NODE_ORIGIN]);
9006
+ function encryptionNodeOrigin(nodeOrigin) {
9007
+ return PRODUCTION_NODE_ORIGINS.has(nodeOrigin) ? TEE_NODE_ORIGIN : nodeOrigin;
9008
+ }
9009
+
9003
9010
  // src/protocol.ts
9004
9011
  var SHARE_V2_PROTOCOL = Object.freeze({
9005
9012
  challengeDomain: "xyz.tinycloud.share/policy-challenge/v2\0",
@@ -9368,7 +9375,7 @@ var ShareRecipientClient = class {
9368
9375
  });
9369
9376
  try {
9370
9377
  this.options.onStage?.("decryption");
9371
- 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 } });
9378
+ 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 } });
9372
9379
  if (!response.ok) throw await recipientHttpError(response, "v3 decrypt invocation rejected");
9373
9380
  const value = object3(await response.json(), "v3 decrypt response");
9374
9381
  const allowed = ["type", "targetNode", "networkId", "invocationCid", "encryptedSymmetricKeyHash", "receiverPublicKeyHash", "wrappedKey", "alg", "keyVersion", "requestHash", "nodeId", "nodeSignature"];
@@ -9511,7 +9518,7 @@ function canonicalViewerUrl(viewerOrigin) {
9511
9518
  }
9512
9519
  async function createNativeShare(sharing, input) {
9513
9520
  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");
9514
- const generated = await sharing.generate({ path: input.path, actions: ["tinycloud.kv/get"], expiry: input.expiresAt });
9521
+ const generated = await sharing.generate({ path: input.path, actions: ["tinycloud.kv/get"], expiry: input.expiresAt, ...input.includePlacement === void 0 ? {} : { includePlacement: input.includePlacement } });
9515
9522
  if (generated.ok !== true) {
9516
9523
  const error = new Error(typeof generated.error?.message === "string" ? generated.error.message : "TinyCloud sharing service rejected delegation generation");
9517
9524
  if (typeof generated.error?.code === "string") Object.assign(error, { code: generated.error.code });