@tinycloud/node-sdk 3.11.0-beta.2 → 3.11.1-beta.0
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-BlNcvo1c.d.ts → TinyCloudNode-AUotFGzy.d.ts} +3 -2
- package/dist/{TinyCloudNode-CnVaWnAX.d.cts → TinyCloudNode-BmpjkpWR.d.cts} +3 -2
- package/dist/{WasmKeyProvider-BKCPRC-c.d.cts → WasmKeyProvider-OA0LqmTg.d.cts} +2 -0
- package/dist/{WasmKeyProvider-BKCPRC-c.d.ts → WasmKeyProvider-OA0LqmTg.d.ts} +2 -0
- package/dist/{authority-B2SLx27M.d.cts → authority-BYSEyjDI.d.cts} +1 -1
- package/dist/{authority-DHIk5QvV.d.ts → authority-dRnJD4iL.d.ts} +1 -1
- package/dist/core.cjs +34 -10
- package/dist/core.cjs.map +1 -1
- package/dist/core.d.cts +3 -3
- package/dist/core.d.ts +3 -3
- package/dist/core.js +35 -11
- 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 +34 -10
- 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 +35 -11
- 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
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { NamedKeyClient } from '@tinycloud/sdk-services/encryption/named-keys';
|
|
2
2
|
export { DecryptManyResult, KeyCallOptions, KeyDescriptor, KeyEncryptOptions, NamedKeyClient, NamedKeyEnvelope, NamedKeyError, NamedKeyErrorCode, PublicKeyDescriptor, buildKeyAdminFacts, buildKeyDescribeFacts } from '@tinycloud/sdk-services/encryption/named-keys';
|
|
3
|
-
import { T as TinyCloudNode } from './TinyCloudNode-
|
|
3
|
+
import { T as TinyCloudNode } from './TinyCloudNode-BmpjkpWR.cjs';
|
|
4
4
|
import '@tinycloud/sdk-core';
|
|
5
5
|
import '@tinycloud/sdk-services/kv/replication';
|
|
6
6
|
import '@tinycloud/sdk-services';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { NamedKeyClient } from '@tinycloud/sdk-services/encryption/named-keys';
|
|
2
2
|
export { DecryptManyResult, KeyCallOptions, KeyDescriptor, KeyEncryptOptions, NamedKeyClient, NamedKeyEnvelope, NamedKeyError, NamedKeyErrorCode, PublicKeyDescriptor, buildKeyAdminFacts, buildKeyDescribeFacts } from '@tinycloud/sdk-services/encryption/named-keys';
|
|
3
|
-
import { T as TinyCloudNode } from './TinyCloudNode-
|
|
3
|
+
import { T as TinyCloudNode } from './TinyCloudNode-AUotFGzy.js';
|
|
4
4
|
import '@tinycloud/sdk-core';
|
|
5
5
|
import '@tinycloud/sdk-services/kv/replication';
|
|
6
6
|
import '@tinycloud/sdk-services';
|
package/dist/index.cjs
CHANGED
|
@@ -18968,6 +18968,18 @@ var MemorySessionStorage = class {
|
|
|
18968
18968
|
}
|
|
18969
18969
|
};
|
|
18970
18970
|
|
|
18971
|
+
// src/storage/clearPersistedSessionIfOwn.ts
|
|
18972
|
+
async function clearPersistedSessionIfOwn(storage, address, ownSignature) {
|
|
18973
|
+
if (ownSignature !== void 0) {
|
|
18974
|
+
try {
|
|
18975
|
+
const stored = await storage.load(address);
|
|
18976
|
+
if (stored !== null && stored.signature !== ownSignature) return;
|
|
18977
|
+
} catch {
|
|
18978
|
+
}
|
|
18979
|
+
}
|
|
18980
|
+
await storage.clear(address);
|
|
18981
|
+
}
|
|
18982
|
+
|
|
18971
18983
|
// src/authorization/NodeUserAuthorization.ts
|
|
18972
18984
|
function assertMaxExpiresAt(value) {
|
|
18973
18985
|
if (value === void 0 || typeof value === "function") return;
|
|
@@ -20784,12 +20796,13 @@ var NodeUserAuthorization = class {
|
|
|
20784
20796
|
};
|
|
20785
20797
|
}
|
|
20786
20798
|
/**
|
|
20787
|
-
* Clear persisted session data.
|
|
20799
|
+
* Clear persisted session data. With `ownSignature`, a stored session that provably has a different
|
|
20800
|
+
* signature (a newer sign-in for the same address) is left alone.
|
|
20788
20801
|
*/
|
|
20789
|
-
async clearPersistedSession(address) {
|
|
20802
|
+
async clearPersistedSession(address, ownSignature) {
|
|
20790
20803
|
const targetAddress = address ?? this._address;
|
|
20791
20804
|
if (targetAddress) {
|
|
20792
|
-
await this.sessionStorage
|
|
20805
|
+
await clearPersistedSessionIfOwn(this.sessionStorage, targetAddress, ownSignature);
|
|
20793
20806
|
}
|
|
20794
20807
|
}
|
|
20795
20808
|
/**
|
|
@@ -22579,6 +22592,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
22579
22592
|
const leavingChainId = this._chainId;
|
|
22580
22593
|
const leavingPrincipal = this.replicaSessionPrincipal ?? (leavingAddress ? (0, import_sdk_core10.pkhDid)(leavingAddress, leavingChainId) : void 0);
|
|
22581
22594
|
const leavingAuth = this.auth;
|
|
22595
|
+
const leavingSignature = leavingAuth?.tinyCloudSession?.signature ?? this._restoredTcSession?.signature;
|
|
22582
22596
|
const leavingContext = this._serviceContext;
|
|
22583
22597
|
let denied;
|
|
22584
22598
|
let erased;
|
|
@@ -22595,7 +22609,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
22595
22609
|
if (denied) erased = await this.eraseReplicaLocalCopy("sign_out", denied.status);
|
|
22596
22610
|
} finally {
|
|
22597
22611
|
if (leavingAddress) {
|
|
22598
|
-
await (leavingAuth ? leavingAuth.clearPersistedSession(leavingAddress) : this.config.sessionStorage
|
|
22612
|
+
await (leavingAuth ? leavingAuth.clearPersistedSession(leavingAddress, leavingSignature) : this.config.sessionStorage && clearPersistedSessionIfOwn(this.config.sessionStorage, leavingAddress, leavingSignature));
|
|
22599
22613
|
}
|
|
22600
22614
|
}
|
|
22601
22615
|
}
|
|
@@ -28341,10 +28355,22 @@ var FileSessionStorage = class {
|
|
|
28341
28355
|
async save(address, session) {
|
|
28342
28356
|
const filePath = this.getFilePath(address);
|
|
28343
28357
|
const data = JSON.stringify(session, null, 2);
|
|
28344
|
-
|
|
28358
|
+
const tempPath = `${filePath}.${process.pid}.${process.hrtime.bigint()}.tmp`;
|
|
28359
|
+
try {
|
|
28360
|
+
(0, import_fs.writeFileSync)(tempPath, data, { mode: 384, flag: "wx" });
|
|
28361
|
+
(0, import_fs.renameSync)(tempPath, filePath);
|
|
28362
|
+
} catch (error) {
|
|
28363
|
+
try {
|
|
28364
|
+
(0, import_fs.unlinkSync)(tempPath);
|
|
28365
|
+
} catch {
|
|
28366
|
+
}
|
|
28367
|
+
throw error;
|
|
28368
|
+
}
|
|
28345
28369
|
}
|
|
28346
28370
|
/**
|
|
28347
28371
|
* Load a session for an address.
|
|
28372
|
+
*
|
|
28373
|
+
* Rejects when the file exists but cannot be read or parsed; the file is left in place.
|
|
28348
28374
|
*/
|
|
28349
28375
|
async load(address) {
|
|
28350
28376
|
const filePath = this.getFilePath(address);
|
|
@@ -28368,11 +28394,9 @@ var FileSessionStorage = class {
|
|
|
28368
28394
|
}
|
|
28369
28395
|
return session;
|
|
28370
28396
|
} catch (error) {
|
|
28371
|
-
|
|
28372
|
-
|
|
28373
|
-
|
|
28374
|
-
}
|
|
28375
|
-
return null;
|
|
28397
|
+
throw new Error(
|
|
28398
|
+
`Could not read session file ${filePath}: ${error}`
|
|
28399
|
+
);
|
|
28376
28400
|
}
|
|
28377
28401
|
}
|
|
28378
28402
|
/**
|