@tinycloud/node-sdk 3.6.0-beta.5 → 3.6.0-beta.7
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/core.cjs +2 -22
- package/dist/core.cjs.map +1 -1
- package/dist/core.js +10 -34
- package/dist/core.js.map +1 -1
- package/dist/credential-pending-store.cjs +4 -0
- package/dist/credential-pending-store.cjs.map +1 -1
- package/dist/credential-pending-store.d.cts +6 -2
- package/dist/credential-pending-store.d.ts +6 -2
- package/dist/credential-pending-store.js +2 -0
- package/dist/credential-pending-store.js.map +1 -1
- package/dist/credentials.cjs +53 -3
- package/dist/credentials.cjs.map +1 -1
- package/dist/credentials.d.cts +1 -1
- package/dist/credentials.d.ts +1 -1
- package/dist/credentials.js +51 -2
- package/dist/credentials.js.map +1 -1
- package/dist/{email-proof-Blhdm4ox.d.cts → email-proof-GXXQhIff.d.cts} +23 -2
- package/dist/{email-proof-Blhdm4ox.d.ts → email-proof-GXXQhIff.d.ts} +23 -2
- package/dist/index.cjs +2 -22
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +16 -40
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -17430,7 +17430,7 @@ __export(authority_exports, {
|
|
|
17430
17430
|
});
|
|
17431
17431
|
import { SiweMessage as SiweMessage4 } from "siwe";
|
|
17432
17432
|
import {
|
|
17433
|
-
actionContains
|
|
17433
|
+
actionContains,
|
|
17434
17434
|
KV as KV4,
|
|
17435
17435
|
canonicalizeRecapCaveats as canonicalizeRecapCaveats3,
|
|
17436
17436
|
isCapabilitySubset as isCapabilitySubset3,
|
|
@@ -17546,7 +17546,7 @@ function ucanAttCovers(att, space, prefix, ability, options) {
|
|
|
17546
17546
|
const path = kvPathInResource(resource, space);
|
|
17547
17547
|
if (path === void 0) continue;
|
|
17548
17548
|
for (const [granted, caveats] of Object.entries(abilities)) {
|
|
17549
|
-
if (!
|
|
17549
|
+
if (!actionContains(granted, ability)) continue;
|
|
17550
17550
|
if (!isCapabilitySubset3(
|
|
17551
17551
|
[{ service: KV_SERVICE2, space, path: prefix, actions: [ability] }],
|
|
17552
17552
|
[{ service: KV_SERVICE2, space, path, actions: [granted] }]
|
|
@@ -18708,7 +18708,7 @@ import {
|
|
|
18708
18708
|
KV as KV3,
|
|
18709
18709
|
SQL as SQL2,
|
|
18710
18710
|
DUCKDB as DUCKDB2,
|
|
18711
|
-
ENCRYPTION as
|
|
18711
|
+
ENCRYPTION as ENCRYPTION2,
|
|
18712
18712
|
EXPIRY as EXPIRY3,
|
|
18713
18713
|
canonicalHashHex,
|
|
18714
18714
|
canonicalizeEncryptionJson,
|
|
@@ -18720,7 +18720,7 @@ import {
|
|
|
18720
18720
|
createInMemoryRegistrySequenceStore as createInMemoryRegistrySequenceStore2,
|
|
18721
18721
|
publishLocationRecord,
|
|
18722
18722
|
principalDidEquals as principalDidEquals3,
|
|
18723
|
-
parseNetworkId as
|
|
18723
|
+
parseNetworkId as parseNetworkId2,
|
|
18724
18724
|
resolveSecretPath as resolveSecretPath2,
|
|
18725
18725
|
registerPolicyV3,
|
|
18726
18726
|
CREDENTIAL_INVITATION_REQUEST_DOMAIN,
|
|
@@ -20775,11 +20775,7 @@ function createWasmKeyProvider(sessionManager) {
|
|
|
20775
20775
|
|
|
20776
20776
|
// src/delegateToHelpers.ts
|
|
20777
20777
|
import {
|
|
20778
|
-
actionContains,
|
|
20779
|
-
ENCRYPTION as ENCRYPTION2,
|
|
20780
20778
|
parseExpiry,
|
|
20781
|
-
isNetworkId,
|
|
20782
|
-
parseNetworkId as parseNetworkId2,
|
|
20783
20779
|
SiweMessage as SiweMessage2,
|
|
20784
20780
|
EXPIRY as EXPIRY2
|
|
20785
20781
|
} from "@tinycloud/sdk-core";
|
|
@@ -20814,16 +20810,6 @@ function legacyParamsToPermissionEntries(actions, path, spaceIdOverride) {
|
|
|
20814
20810
|
return entries;
|
|
20815
20811
|
}
|
|
20816
20812
|
var DEFAULT_DELEGATION_EXPIRY_MS = EXPIRY2.SESSION_MS;
|
|
20817
|
-
var SHARE_NETWORK_NAME_RE = /^share-[a-z0-9][a-z0-9-]{15,35}$/;
|
|
20818
|
-
function grantsCappedDecrypt(path, actions) {
|
|
20819
|
-
if (!actions.some((action) => actionContains(action, ENCRYPTION2.DECRYPT))) {
|
|
20820
|
-
return false;
|
|
20821
|
-
}
|
|
20822
|
-
return !(isNetworkId(path) && SHARE_NETWORK_NAME_RE.test(parseNetworkId2(path).name));
|
|
20823
|
-
}
|
|
20824
|
-
function includesDecrypt(entries) {
|
|
20825
|
-
return entries.some((entry) => grantsCappedDecrypt(entry.path, entry.actions));
|
|
20826
|
-
}
|
|
20827
20813
|
function resolveExpiryMs(expiry) {
|
|
20828
20814
|
if (expiry === void 0) {
|
|
20829
20815
|
return DEFAULT_DELEGATION_EXPIRY_MS;
|
|
@@ -21013,8 +20999,7 @@ var NodeSecretsService = class {
|
|
|
21013
20999
|
);
|
|
21014
21000
|
}
|
|
21015
21001
|
try {
|
|
21016
|
-
|
|
21017
|
-
await grant(escalation);
|
|
21002
|
+
await this.config.grantPermissions(escalation);
|
|
21018
21003
|
return this.restoreUnlockAfterEscalation();
|
|
21019
21004
|
} catch (error) {
|
|
21020
21005
|
return this.escalationError(action, target, error);
|
|
@@ -21061,8 +21046,8 @@ var NodeSecretsService = class {
|
|
|
21061
21046
|
// src/TinyCloudNode.ts
|
|
21062
21047
|
var DEFAULT_HOST = "https://node.tinycloud.xyz";
|
|
21063
21048
|
var DEFAULT_ENCRYPTION_NETWORK_NAME = "default";
|
|
21064
|
-
var NETWORK_CREATE_ACTION2 =
|
|
21065
|
-
var DECRYPT_ACTION2 =
|
|
21049
|
+
var NETWORK_CREATE_ACTION2 = ENCRYPTION2.NETWORK_CREATE;
|
|
21050
|
+
var DECRYPT_ACTION2 = ENCRYPTION2.DECRYPT;
|
|
21066
21051
|
var BOOTSTRAP_COMPLETION_MARKER_KEY = "system/bootstrap/complete";
|
|
21067
21052
|
var BOOTSTRAP_COMPLETION_MARKER_VERSION = 1;
|
|
21068
21053
|
var ACCEPTED_MARKER_VERSIONS = [BOOTSTRAP_COMPLETION_MARKER_VERSION];
|
|
@@ -21409,7 +21394,7 @@ function ownerDelegationPermissions(params) {
|
|
|
21409
21394
|
}
|
|
21410
21395
|
if (permission.service === ENCRYPTION_PERMISSION_SERVICE2) {
|
|
21411
21396
|
try {
|
|
21412
|
-
|
|
21397
|
+
parseNetworkId2(permission.path);
|
|
21413
21398
|
} catch {
|
|
21414
21399
|
throw new Error("Owner delegation encryption permission requires a canonical network URN");
|
|
21415
21400
|
}
|
|
@@ -21432,8 +21417,6 @@ function ownerPermissionsToAbilities(permissions) {
|
|
|
21432
21417
|
return { abilities, rawAbilities };
|
|
21433
21418
|
}
|
|
21434
21419
|
var TERMINAL_DELEGATION_REQUIRES_SESSION_KEY = "disableSubDelegation requires a session-key delegation to a did:key (not did:pkh); use the session-key DID or drop the flag";
|
|
21435
|
-
var DECRYPT_GRANT_MAX_EXPIRY_MS = 60 * 60 * 1e3;
|
|
21436
|
-
var SECRET_GET_GRANT_EXPIRY_MS = 59 * 60 * 1e3;
|
|
21437
21420
|
function base64UrlEncode(bytes) {
|
|
21438
21421
|
const alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_";
|
|
21439
21422
|
let output = "";
|
|
@@ -23342,7 +23325,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
23342
23325
|
return;
|
|
23343
23326
|
}
|
|
23344
23327
|
for (const networkId of this.requestedEncryptionNetworkIds()) {
|
|
23345
|
-
const parsed =
|
|
23328
|
+
const parsed = parseNetworkId2(networkId);
|
|
23346
23329
|
if (!didPrincipalMatches2(parsed.ownerDid, this.did)) {
|
|
23347
23330
|
continue;
|
|
23348
23331
|
}
|
|
@@ -25161,7 +25144,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
25161
25144
|
if (!session) throw new Error("Owner session is required");
|
|
25162
25145
|
const ownerDid = pkhDid2(session.address, session.chainId);
|
|
25163
25146
|
for (const permission of permissions) {
|
|
25164
|
-
if (permission.service === ENCRYPTION_PERMISSION_SERVICE2 && !principalDidEquals3(
|
|
25147
|
+
if (permission.service === ENCRYPTION_PERMISSION_SERVICE2 && !principalDidEquals3(parseNetworkId2(permission.path).ownerDid, ownerDid)) {
|
|
25165
25148
|
throw new Error("Owner delegation cannot grant a foreign encryption network");
|
|
25166
25149
|
}
|
|
25167
25150
|
}
|
|
@@ -25523,7 +25506,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
25523
25506
|
return existing;
|
|
25524
25507
|
}
|
|
25525
25508
|
}
|
|
25526
|
-
const parsed =
|
|
25509
|
+
const parsed = parseNetworkId2(networkId);
|
|
25527
25510
|
if (!didPrincipalMatches2(parsed.ownerDid, this.did)) {
|
|
25528
25511
|
throw new Error(
|
|
25529
25512
|
`Cannot create encryption network ${networkId}: owner ${parsed.ownerDid} does not match signed-in DID ${this.did}`
|
|
@@ -25556,7 +25539,6 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
25556
25539
|
getManifest: () => this.manifest,
|
|
25557
25540
|
hasPermissions: (permissions) => this.hasRuntimePermissions(permissions),
|
|
25558
25541
|
grantPermissions: (additional) => this.grantRuntimePermissions(additional),
|
|
25559
|
-
grantGetPermissions: (additional) => this.grantRuntimePermissions(additional, { expiry: SECRET_GET_GRANT_EXPIRY_MS }),
|
|
25560
25542
|
uncoveredEntries: (permissions) => permissions.filter((entry) => !this.hasRuntimePermissions([entry])),
|
|
25561
25543
|
canEscalate: () => this.signer !== void 0 && this.tc !== void 0,
|
|
25562
25544
|
getEncryptionNetworkId: () => this.getEncryptionNetworkIdForSpace(resolvedSpace),
|
|
@@ -25905,13 +25887,6 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
25905
25887
|
}
|
|
25906
25888
|
}
|
|
25907
25889
|
const expanded = this.expandPermissionEntries(permissions);
|
|
25908
|
-
const requestsDecrypt = includesDecrypt(expanded);
|
|
25909
|
-
const requestedExpiryMs = requestsDecrypt && options?.expiry === void 0 ? DECRYPT_GRANT_MAX_EXPIRY_MS : resolveExpiryMs(options?.expiry);
|
|
25910
|
-
if (requestsDecrypt && requestedExpiryMs > DECRYPT_GRANT_MAX_EXPIRY_MS) {
|
|
25911
|
-
throw Object.assign(new Error("decrypt grants last at most one hour"), {
|
|
25912
|
-
code: "DECRYPT_EXPIRY_TOO_LONG"
|
|
25913
|
-
});
|
|
25914
|
-
}
|
|
25915
25890
|
if (this.sessionCoversPermissionEntries(session, expanded)) {
|
|
25916
25891
|
return [];
|
|
25917
25892
|
}
|
|
@@ -25942,6 +25917,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
25942
25917
|
bySpace.set(session.spaceId, []);
|
|
25943
25918
|
}
|
|
25944
25919
|
const now = /* @__PURE__ */ new Date();
|
|
25920
|
+
const requestedExpiryMs = resolveExpiryMs(options?.expiry);
|
|
25945
25921
|
let expiresAt = new Date(now.getTime() + requestedExpiryMs);
|
|
25946
25922
|
if (sessionExpiry !== void 0 && sessionExpiry < expiresAt) {
|
|
25947
25923
|
expiresAt = sessionExpiry;
|
|
@@ -27992,9 +27968,9 @@ import {
|
|
|
27992
27968
|
import {
|
|
27993
27969
|
EncryptionService as EncryptionService2,
|
|
27994
27970
|
DecryptTransportResponseError as DecryptTransportResponseError2,
|
|
27995
|
-
parseNetworkId as
|
|
27971
|
+
parseNetworkId as parseNetworkId3,
|
|
27996
27972
|
buildNetworkId,
|
|
27997
|
-
isNetworkId
|
|
27973
|
+
isNetworkId,
|
|
27998
27974
|
networkDiscoveryKey,
|
|
27999
27975
|
NetworkIdError,
|
|
28000
27976
|
ENCRYPTION_NETWORK_URN_PREFIX,
|
|
@@ -30713,7 +30689,7 @@ export {
|
|
|
30713
30689
|
installTinyCloudDebugGlobals,
|
|
30714
30690
|
isCapabilitySubset4 as isCapabilitySubset,
|
|
30715
30691
|
isEvmAddress,
|
|
30716
|
-
|
|
30692
|
+
isNetworkId,
|
|
30717
30693
|
isStorageFullError2 as isStorageFullError,
|
|
30718
30694
|
loadManifest,
|
|
30719
30695
|
logoutPrincipalDigest,
|
|
@@ -30723,7 +30699,7 @@ export {
|
|
|
30723
30699
|
openWrappedKey,
|
|
30724
30700
|
parseCanonicalNetworkId,
|
|
30725
30701
|
parseExpiry2 as parseExpiry,
|
|
30726
|
-
|
|
30702
|
+
parseNetworkId3 as parseNetworkId,
|
|
30727
30703
|
parsePkhDid,
|
|
30728
30704
|
parseSecretCatalogKey,
|
|
30729
30705
|
parseSpaceUri3 as parseSpaceUri,
|