@tinycloud/share-sdk 1.0.0-beta.5 → 1.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 +7 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +12 -8
- package/dist/index.d.ts +12 -8
- package/dist/index.js +7 -1
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -6099,6 +6099,7 @@ function redactPublishedShare(result) {
|
|
|
6099
6099
|
target: { ...result.metadata.target },
|
|
6100
6100
|
resource: { ...result.metadata.resource },
|
|
6101
6101
|
actions: [...result.metadata.actions],
|
|
6102
|
+
...result.metadata.expiryClamped === void 0 ? {} : { expiryClamped: result.metadata.expiryClamped },
|
|
6102
6103
|
expiresAt: result.metadata.expiresAt,
|
|
6103
6104
|
display: { ...result.metadata.display }
|
|
6104
6105
|
}
|
|
@@ -6611,6 +6612,7 @@ async function publishTargetShare(input) {
|
|
|
6611
6612
|
...input.actions === void 0 ? {} : { actions: input.actions },
|
|
6612
6613
|
target,
|
|
6613
6614
|
expiresAt,
|
|
6615
|
+
expiryWasExplicit: input.expiryWasExplicit ?? input.expiresAt !== void 0,
|
|
6614
6616
|
origin: input.origin,
|
|
6615
6617
|
...input.notify === void 0 ? {} : { notify: input.notify }
|
|
6616
6618
|
});
|
|
@@ -8558,7 +8560,11 @@ function canonicalViewerUrl(viewerOrigin) {
|
|
|
8558
8560
|
async function createNativeShare(sharing, input) {
|
|
8559
8561
|
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");
|
|
8560
8562
|
const generated = await sharing.generate({ path: input.path, actions: ["tinycloud.kv/get"], expiry: input.expiresAt });
|
|
8561
|
-
if (generated.ok !== true)
|
|
8563
|
+
if (generated.ok !== true) {
|
|
8564
|
+
const error = new Error(typeof generated.error?.message === "string" ? generated.error.message : "TinyCloud sharing service rejected delegation generation");
|
|
8565
|
+
if (typeof generated.error?.code === "string") Object.assign(error, { code: generated.error.code });
|
|
8566
|
+
throw error;
|
|
8567
|
+
}
|
|
8562
8568
|
if (typeof generated.data?.token !== "string" || typeof generated.data.delegation?.cid !== "string" || !(generated.data.expiresAt instanceof Date)) throw new Error("TinyCloud sharing service returned incomplete delegation metadata");
|
|
8563
8569
|
const delegation = sharing.decodeLink(generated.data.token);
|
|
8564
8570
|
if (typeof delegation.spaceId !== "string" || delegation.spaceId.length === 0 || typeof delegation.path !== "string" || delegation.path.length === 0) throw new Error("TinyCloud sharing service returned a non-canonical delegation authority");
|