@tinycloud/sdk-core 3.0.0-beta.12 → 3.0.0-beta.14
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/delegations/index.cjs +23 -3
- package/dist/delegations/index.cjs.map +1 -1
- package/dist/delegations/index.d.cts +2 -2
- package/dist/delegations/index.d.ts +2 -2
- package/dist/delegations/index.js +23 -3
- package/dist/delegations/index.js.map +1 -1
- package/dist/index.cjs +23 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +23 -3
- package/dist/index.js.map +1 -1
- package/dist/{recipient-types.schema-Cz5zJzED.d.cts → recipient-types.schema-lAKNQlxx.d.cts} +1 -0
- package/dist/{recipient-types.schema-Cz5zJzED.d.ts → recipient-types.schema-lAKNQlxx.d.ts} +1 -0
- package/package.json +3 -3
|
@@ -170,6 +170,7 @@ var DelegationErrorSchema = import_zod.z.object({
|
|
|
170
170
|
});
|
|
171
171
|
var DelegationErrorCodes = {
|
|
172
172
|
AUTH_REQUIRED: "AUTH_REQUIRED",
|
|
173
|
+
AUTH_UNAUTHORIZED: "AUTH_UNAUTHORIZED",
|
|
173
174
|
AUTH_EXPIRED: "AUTH_EXPIRED",
|
|
174
175
|
NOT_INITIALIZED: "NOT_INITIALIZED",
|
|
175
176
|
NOT_FOUND: "NOT_FOUND",
|
|
@@ -534,7 +535,7 @@ var CreateDelegationWasmResultSchema = import_zod.z.object({
|
|
|
534
535
|
// src/expiry.ts
|
|
535
536
|
var EPHEMERAL_MS = 60 * 60 * 1e3;
|
|
536
537
|
var SIGNED_READ_URL_MS = 5 * 60 * 1e3;
|
|
537
|
-
var SESSION_MS =
|
|
538
|
+
var SESSION_MS = 30 * 24 * 60 * 60 * 1e3;
|
|
538
539
|
var SHARE_MS = 7 * 24 * 60 * 60 * 1e3;
|
|
539
540
|
var APP_MS = 30 * 24 * 60 * 60 * 1e3;
|
|
540
541
|
var MAX_MS = 10 * 365 * 24 * 60 * 60 * 1e3;
|
|
@@ -5356,6 +5357,13 @@ var ShareRecipientClient = class {
|
|
|
5356
5357
|
};
|
|
5357
5358
|
|
|
5358
5359
|
// src/delegations/SharingService.ts
|
|
5360
|
+
function spaceIdsEqual(left, right) {
|
|
5361
|
+
const normalizeOwnerAddress = (space) => {
|
|
5362
|
+
const match = /^(tinycloud:pkh:eip155:\d+:)(0x[0-9a-fA-F]{40})(:.+)$/.exec(space);
|
|
5363
|
+
return match === null ? space : `${match[1]}${match[2].toLowerCase()}${match[3]}`;
|
|
5364
|
+
};
|
|
5365
|
+
return normalizeOwnerAddress(left) === normalizeOwnerAddress(right);
|
|
5366
|
+
}
|
|
5359
5367
|
function inferShortServiceFromActionUrns(actions) {
|
|
5360
5368
|
let short;
|
|
5361
5369
|
for (const action of actions) {
|
|
@@ -5678,7 +5686,7 @@ var SharingService = class {
|
|
|
5678
5686
|
for (const key of allKeys) {
|
|
5679
5687
|
const delegations = this.registry.getDelegationsForKey(key.id);
|
|
5680
5688
|
for (const delegation of delegations) {
|
|
5681
|
-
if (delegation.spaceId
|
|
5689
|
+
if (delegation.spaceId === void 0 || !spaceIdsEqual(delegation.spaceId, this.session?.spaceId ?? "")) {
|
|
5682
5690
|
continue;
|
|
5683
5691
|
}
|
|
5684
5692
|
if ((delegation.caveats?.length ?? 0) > 0) {
|
|
@@ -5806,11 +5814,23 @@ var SharingService = class {
|
|
|
5806
5814
|
const errorText = await registerRes.text();
|
|
5807
5815
|
const registrationTextActiveError = this.retiredGraphError();
|
|
5808
5816
|
if (registrationTextActiveError) return { ok: false, error: registrationTextActiveError };
|
|
5817
|
+
const message = `Failed to register delegation with server: ${registerRes.status} ${errorText}`;
|
|
5818
|
+
if (registerRes.status === 401 || registerRes.status === 403) {
|
|
5819
|
+
return {
|
|
5820
|
+
ok: false,
|
|
5821
|
+
error: createError2(
|
|
5822
|
+
DelegationErrorCodes.AUTH_UNAUTHORIZED,
|
|
5823
|
+
message,
|
|
5824
|
+
void 0,
|
|
5825
|
+
{ status: registerRes.status }
|
|
5826
|
+
)
|
|
5827
|
+
};
|
|
5828
|
+
}
|
|
5809
5829
|
return {
|
|
5810
5830
|
ok: false,
|
|
5811
5831
|
error: createError2(
|
|
5812
5832
|
DelegationErrorCodes.CREATION_FAILED,
|
|
5813
|
-
|
|
5833
|
+
message
|
|
5814
5834
|
)
|
|
5815
5835
|
};
|
|
5816
5836
|
}
|