@tinycloud/node-sdk 3.11.0-beta.0 → 3.11.0-beta.2
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-BpolXzu5.d.ts → TinyCloudNode-BlNcvo1c.d.ts} +7 -0
- package/dist/{TinyCloudNode-wAQN1Ndh.d.cts → TinyCloudNode-CnVaWnAX.d.cts} +7 -0
- package/dist/{authority-C0JKqTwY.d.cts → authority-B2SLx27M.d.cts} +1 -1
- package/dist/{authority-Cj8MLCkr.d.ts → authority-DHIk5QvV.d.ts} +1 -1
- package/dist/core.cjs +26 -6
- 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 +28 -6
- package/dist/core.js.map +1 -1
- package/dist/encryption-keys.d.cts +1 -1
- package/dist/encryption-keys.d.ts +1 -1
- package/dist/index.cjs +26 -6
- 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 +28 -6
- 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 +4 -4
|
@@ -655,6 +655,13 @@ declare class NodeUserAuthorization implements IUserAuthorization {
|
|
|
655
655
|
private guardSpaceCreation;
|
|
656
656
|
private recordActivationSkippedSpaces;
|
|
657
657
|
createBootstrapSession(options: CreateBootstrapSessionOptions): Promise<TinyCloudSession>;
|
|
658
|
+
/**
|
|
659
|
+
* When a session that starts at `now` ends. Refused with a dated message when
|
|
660
|
+
* the configured lifetime reaches past what a sign-in message can carry,
|
|
661
|
+
* instead of the bare `RangeError` or WASM parse error `toISOString()` and
|
|
662
|
+
* `prepareSession` would otherwise give.
|
|
663
|
+
*/
|
|
664
|
+
private sessionExpiryFrom;
|
|
658
665
|
private persistedData;
|
|
659
666
|
/**
|
|
660
667
|
* Sign in and create a new session.
|
|
@@ -655,6 +655,13 @@ declare class NodeUserAuthorization implements IUserAuthorization {
|
|
|
655
655
|
private guardSpaceCreation;
|
|
656
656
|
private recordActivationSkippedSpaces;
|
|
657
657
|
createBootstrapSession(options: CreateBootstrapSessionOptions): Promise<TinyCloudSession>;
|
|
658
|
+
/**
|
|
659
|
+
* When a session that starts at `now` ends. Refused with a dated message when
|
|
660
|
+
* the configured lifetime reaches past what a sign-in message can carry,
|
|
661
|
+
* instead of the bare `RangeError` or WASM parse error `toISOString()` and
|
|
662
|
+
* `prepareSession` would otherwise give.
|
|
663
|
+
*/
|
|
664
|
+
private sessionExpiryFrom;
|
|
658
665
|
private persistedData;
|
|
659
666
|
/**
|
|
660
667
|
* Sign in and create a new session.
|
|
@@ -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 { ReplicaLocalEraseOutcome, ReplicaPurgeLocalCopyResult, ReplicaPurgeTrigger, ReplicaPurgeFailedEvent, ReplicaSessionStamp, ReplicaDenyInput } from '@tinycloud/sdk-services/kv/replication';
|
|
4
|
-
import { T as TinyCloudNode } from './TinyCloudNode-
|
|
4
|
+
import { T as TinyCloudNode } from './TinyCloudNode-CnVaWnAX.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 & {
|
|
@@ -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 { ReplicaLocalEraseOutcome, ReplicaPurgeLocalCopyResult, ReplicaPurgeTrigger, ReplicaPurgeFailedEvent, ReplicaSessionStamp, ReplicaDenyInput } from '@tinycloud/sdk-services/kv/replication';
|
|
4
|
-
import { T as TinyCloudNode } from './TinyCloudNode-
|
|
4
|
+
import { T as TinyCloudNode } from './TinyCloudNode-BlNcvo1c.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 & {
|
package/dist/core.cjs
CHANGED
|
@@ -1437,7 +1437,7 @@ var NodeUserAuthorization = class {
|
|
|
1437
1437
|
}
|
|
1438
1438
|
const jwk = JSON.parse(jwkString);
|
|
1439
1439
|
const now = /* @__PURE__ */ new Date();
|
|
1440
|
-
const expirationTime =
|
|
1440
|
+
const expirationTime = this.sessionExpiryFrom(now);
|
|
1441
1441
|
const primaryIdentity = pkhSpaceIdentity(options.spaceId);
|
|
1442
1442
|
const resourcesBySpace = /* @__PURE__ */ new Map();
|
|
1443
1443
|
for (const resource of options.capabilityRequest.resources) {
|
|
@@ -1492,6 +1492,17 @@ var NodeUserAuthorization = class {
|
|
|
1492
1492
|
signature
|
|
1493
1493
|
};
|
|
1494
1494
|
}
|
|
1495
|
+
/**
|
|
1496
|
+
* When a session that starts at `now` ends. Refused with a dated message when
|
|
1497
|
+
* the configured lifetime reaches past what a sign-in message can carry,
|
|
1498
|
+
* instead of the bare `RangeError` or WASM parse error `toISOString()` and
|
|
1499
|
+
* `prepareSession` would otherwise give.
|
|
1500
|
+
*/
|
|
1501
|
+
sessionExpiryFrom(now) {
|
|
1502
|
+
const expirationTime = new Date(now.getTime() + this.sessionExpirationMs);
|
|
1503
|
+
(0, import_sdk_core5.assertExpiryWithinTechnicalLimit)(expirationTime, "siwe");
|
|
1504
|
+
return expirationTime;
|
|
1505
|
+
}
|
|
1495
1506
|
persistedData(session, expiresAt, createdAt, replicaStamp) {
|
|
1496
1507
|
return {
|
|
1497
1508
|
address: session.address,
|
|
@@ -1547,7 +1558,7 @@ var NodeUserAuthorization = class {
|
|
|
1547
1558
|
const capabilityPlan = this.resolveSignInCapabilities(address, chainId);
|
|
1548
1559
|
const spaceId = capabilityPlan.spaceId;
|
|
1549
1560
|
const now = /* @__PURE__ */ new Date();
|
|
1550
|
-
const expirationTime =
|
|
1561
|
+
const expirationTime = this.sessionExpiryFrom(now);
|
|
1551
1562
|
const prepared = this.prepareSessionWithResources({
|
|
1552
1563
|
abilities: capabilityPlan.abilities,
|
|
1553
1564
|
...capabilityPlan.spaceAbilities !== void 0 ? { spaceAbilities: capabilityPlan.spaceAbilities } : {},
|
|
@@ -1693,7 +1704,7 @@ var NodeUserAuthorization = class {
|
|
|
1693
1704
|
const capabilityPlan = this.resolveSignInCapabilities(address, chainId);
|
|
1694
1705
|
const spaceId = capabilityPlan.spaceId;
|
|
1695
1706
|
const now = /* @__PURE__ */ new Date();
|
|
1696
|
-
const expirationTime =
|
|
1707
|
+
const expirationTime = this.sessionExpiryFrom(now);
|
|
1697
1708
|
const prepared = this.prepareSessionWithResources({
|
|
1698
1709
|
abilities: capabilityPlan.abilities,
|
|
1699
1710
|
...capabilityPlan.spaceAbilities !== void 0 ? { spaceAbilities: capabilityPlan.spaceAbilities } : {},
|
|
@@ -1756,7 +1767,7 @@ var NodeUserAuthorization = class {
|
|
|
1756
1767
|
siwe: prepared.siwe,
|
|
1757
1768
|
signature
|
|
1758
1769
|
};
|
|
1759
|
-
const expiresAt = lastAnchoredLine(prepared.siwe ?? "", /^Expiration Time: (.+)$/gm) ?? new Date(
|
|
1770
|
+
const expiresAt = lastAnchoredLine(prepared.siwe ?? "", /^Expiration Time: (.+)$/gm) ?? this.sessionExpiryFrom(/* @__PURE__ */ new Date()).toISOString();
|
|
1760
1771
|
const createdAt = lastAnchoredLine(prepared.siwe ?? "", /^Issued At: (.+)$/gm) ?? (/* @__PURE__ */ new Date()).toISOString();
|
|
1761
1772
|
const replicaStamp = await this.establishReplicaStamp?.(tinyCloudSession);
|
|
1762
1773
|
const persistedData = this.persistedData(tinyCloudSession, expiresAt, createdAt, replicaStamp);
|
|
@@ -3705,6 +3716,7 @@ var ServiceGraphLifetime = class {
|
|
|
3705
3716
|
}
|
|
3706
3717
|
combineSignals(signal) {
|
|
3707
3718
|
if (!signal) return this.abortController.signal;
|
|
3719
|
+
if (typeof AbortSignal.any === "function") return AbortSignal.any([signal, this.abortController.signal]);
|
|
3708
3720
|
const combined = new AbortController();
|
|
3709
3721
|
const abort = () => combined.abort();
|
|
3710
3722
|
if (signal.aborted || this.abortController.signal.aborted) {
|
|
@@ -7730,6 +7742,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
7730
7742
|
// DID here and rejects the fragment as an invalid audience DID.
|
|
7731
7743
|
verificationMethod: params.session.verificationMethod.split("#", 1)[0]
|
|
7732
7744
|
};
|
|
7745
|
+
(0, import_sdk_core11.assertExpiryWithinTechnicalLimit)(params.expirationSecs * 1e3, "ucan");
|
|
7733
7746
|
const result = this.wasmBindings.createDelegation(
|
|
7734
7747
|
wasmSession,
|
|
7735
7748
|
params.delegateDID,
|
|
@@ -7762,9 +7775,10 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
7762
7775
|
}
|
|
7763
7776
|
const permissions = ownerDelegationPermissions(params);
|
|
7764
7777
|
const now = /* @__PURE__ */ new Date();
|
|
7765
|
-
if (!(params.expiresAt instanceof Date) || params.expiresAt.getTime() <= now.getTime()
|
|
7766
|
-
throw new Error("Owner delegation expiry must be explicit, future, and
|
|
7778
|
+
if (!(params.expiresAt instanceof Date) || params.expiresAt.getTime() <= now.getTime()) {
|
|
7779
|
+
throw new Error("Owner delegation expiry must be explicit, future, and a valid date");
|
|
7767
7780
|
}
|
|
7781
|
+
(0, import_sdk_core11.assertExpiryWithinTechnicalLimit)(params.expiresAt, "siwe");
|
|
7768
7782
|
if (!this.signer) throw new Error("Owner wallet signer is required");
|
|
7769
7783
|
const session = this.currentTinyCloudSession();
|
|
7770
7784
|
if (!session) throw new Error("Owner session is required");
|
|
@@ -7865,6 +7879,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
7865
7879
|
* not sent.
|
|
7866
7880
|
*/
|
|
7867
7881
|
async authorizeShareDeliveryV3(input) {
|
|
7882
|
+
(0, import_sdk_core11.assertExpiryWithinTechnicalLimit)(new Date(input.expiresAt), "siwe");
|
|
7868
7883
|
const envelopeRef = await (0, import_sdk_core11.shortDeliveryLinkBodyCid)(input.shareUrl, input.trustedOrigins);
|
|
7869
7884
|
const session = this.currentTinyCloudSession();
|
|
7870
7885
|
const serviceSession = this._serviceContext?.session;
|
|
@@ -7917,6 +7932,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
7917
7932
|
};
|
|
7918
7933
|
}
|
|
7919
7934
|
async createRootDelegationForSharing(params, assertActive) {
|
|
7935
|
+
(0, import_sdk_core11.assertExpiryWithinTechnicalLimit)(params.requestedExpiry, "siwe");
|
|
7920
7936
|
try {
|
|
7921
7937
|
return (await this.createOwnerDelegation({
|
|
7922
7938
|
delegateDid: params.shareKeyDID,
|
|
@@ -8613,6 +8629,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
8613
8629
|
if (sessionExpiry !== void 0 && sessionExpiry < expiresAt) {
|
|
8614
8630
|
expiresAt = sessionExpiry;
|
|
8615
8631
|
}
|
|
8632
|
+
(0, import_sdk_core11.assertExpiryWithinTechnicalLimit)(expiresAt, "siwe");
|
|
8616
8633
|
const delegations = [];
|
|
8617
8634
|
let rawEntriesAttached = false;
|
|
8618
8635
|
for (const [spaceId, entries] of bySpace) {
|
|
@@ -10085,6 +10102,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
10085
10102
|
const now = /* @__PURE__ */ new Date();
|
|
10086
10103
|
const expiryMs = params.expiryMs ?? 60 * 60 * 1e3;
|
|
10087
10104
|
const expirationTime = new Date(now.getTime() + expiryMs);
|
|
10105
|
+
(0, import_sdk_core11.assertExpiryWithinTechnicalLimit)(expirationTime, "siwe");
|
|
10088
10106
|
const prepared = this.wasmBindings.prepareSession({
|
|
10089
10107
|
abilities,
|
|
10090
10108
|
address: this.wasmBindings.ensureEip55(session.address),
|
|
@@ -10239,6 +10257,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
10239
10257
|
const { abilities, rawAbilities } = this.buildActivationAbilities(delegation);
|
|
10240
10258
|
const now = /* @__PURE__ */ new Date();
|
|
10241
10259
|
const expirationTime = delegation.expiry;
|
|
10260
|
+
(0, import_sdk_core11.assertExpiryWithinTechnicalLimit)(expirationTime, "siwe");
|
|
10242
10261
|
const prepared = this.wasmBindings.prepareSession({
|
|
10243
10262
|
abilities,
|
|
10244
10263
|
address: this.wasmBindings.ensureEip55(mySession.address),
|
|
@@ -10358,6 +10377,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
10358
10377
|
const now = /* @__PURE__ */ new Date();
|
|
10359
10378
|
const requestedExpiry = params.expiryMs === void 0 ? parentDelegation.expiry : new Date(now.getTime() + params.expiryMs);
|
|
10360
10379
|
const actualExpiry = requestedExpiry > parentDelegation.expiry ? parentDelegation.expiry : requestedExpiry;
|
|
10380
|
+
(0, import_sdk_core11.assertExpiryWithinTechnicalLimit)(actualExpiry, "siwe");
|
|
10361
10381
|
const abilities = {};
|
|
10362
10382
|
const rawAbilities = {};
|
|
10363
10383
|
for (const resource of requestedResources) {
|