@tinycloud/node-sdk 3.6.0-beta.7 → 3.6.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/core.cjs +412 -390
- package/dist/core.cjs.map +1 -1
- package/dist/core.d.cts +9 -2
- package/dist/core.d.ts +9 -2
- package/dist/core.js +38 -14
- package/dist/core.js.map +1 -1
- package/dist/index.cjs +470 -450
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +37 -14
- package/dist/index.js.map +1 -1
- package/package.json +4 -4
package/dist/index.cjs
CHANGED
|
@@ -17143,11 +17143,11 @@ function resolvedOptions(options) {
|
|
|
17143
17143
|
verify: options.verify === true
|
|
17144
17144
|
};
|
|
17145
17145
|
}
|
|
17146
|
-
var
|
|
17146
|
+
var import_sdk_core11, scheduler, ReplicationRuntime;
|
|
17147
17147
|
var init_runtime = __esm({
|
|
17148
17148
|
"src/replication/runtime.ts"() {
|
|
17149
17149
|
"use strict";
|
|
17150
|
-
|
|
17150
|
+
import_sdk_core11 = require("@tinycloud/sdk-core");
|
|
17151
17151
|
scheduler = {
|
|
17152
17152
|
now: () => Date.now(),
|
|
17153
17153
|
setTimeout(fn, ms) {
|
|
@@ -17311,7 +17311,7 @@ var init_runtime = __esm({
|
|
|
17311
17311
|
identity = services.canonicalReplicationIdentity({
|
|
17312
17312
|
host: context.hosts[0],
|
|
17313
17313
|
space: session.spaceId,
|
|
17314
|
-
principal: input.principal ?? (0,
|
|
17314
|
+
principal: input.principal ?? (0, import_sdk_core11.pkhDid)(input.address, input.chainId)
|
|
17315
17315
|
});
|
|
17316
17316
|
} catch {
|
|
17317
17317
|
for (const prefix of this.options.prefixes) {
|
|
@@ -17460,11 +17460,11 @@ function verifiedOwnerConsentAnchor(session, wasmBindings, exactVerifiedRecap2)
|
|
|
17460
17460
|
const issuedAt = Date.parse(signedIssuedAt);
|
|
17461
17461
|
if (!Number.isSafeInteger(issuedAt) || issuedAt < 0) return null;
|
|
17462
17462
|
const granted = exactVerifiedRecap2(verified).filter((entry) => entry.space === session.spaceId && entry.service === "kv").map((entry) => ({ ...entry, service: "tinycloud.kv" }));
|
|
17463
|
-
const coversGetAndSync = granted.some((entry) => (0,
|
|
17463
|
+
const coversGetAndSync = granted.some((entry) => (0, import_sdk_core12.isCapabilitySubset)([{
|
|
17464
17464
|
service: "tinycloud.kv",
|
|
17465
17465
|
space: session.spaceId,
|
|
17466
17466
|
path: entry.path,
|
|
17467
|
-
actions: [
|
|
17467
|
+
actions: [import_sdk_core12.KV.GET, import_sdk_core12.KV.SYNC]
|
|
17468
17468
|
}], granted).subset);
|
|
17469
17469
|
return coversGetAndSync ? { at: issuedAt, source: "siwe" } : null;
|
|
17470
17470
|
} catch {
|
|
@@ -17510,7 +17510,7 @@ function caveatBranchesUnconstrained(value) {
|
|
|
17510
17510
|
}
|
|
17511
17511
|
if (!Array.isArray(value)) return false;
|
|
17512
17512
|
try {
|
|
17513
|
-
return (0,
|
|
17513
|
+
return (0, import_sdk_core12.canonicalizeRecapCaveats)(value) === (0, import_sdk_core12.canonicalizeRecapCaveats)(void 0);
|
|
17514
17514
|
} catch {
|
|
17515
17515
|
return false;
|
|
17516
17516
|
}
|
|
@@ -17529,8 +17529,8 @@ function ucanAttCovers(att, space, prefix, ability, options) {
|
|
|
17529
17529
|
const path = kvPathInResource(resource, space);
|
|
17530
17530
|
if (path === void 0) continue;
|
|
17531
17531
|
for (const [granted, caveats] of Object.entries(abilities)) {
|
|
17532
|
-
if (!(0,
|
|
17533
|
-
if (!(0,
|
|
17532
|
+
if (!(0, import_sdk_core12.actionContains)(granted, ability)) continue;
|
|
17533
|
+
if (!(0, import_sdk_core12.isCapabilitySubset)(
|
|
17534
17534
|
[{ service: KV_SERVICE2, space, path: prefix, actions: [ability] }],
|
|
17535
17535
|
[{ service: KV_SERVICE2, space, path, actions: [granted] }]
|
|
17536
17536
|
).subset) continue;
|
|
@@ -17550,7 +17550,7 @@ async function mintNodeReplicationGrant(deviceDid, entries, options, renewalSess
|
|
|
17550
17550
|
assertRenewalParent(prepared.delegationHeader.Authorization, renewalSession);
|
|
17551
17551
|
}
|
|
17552
17552
|
} : options?.expiryMs === void 0 ? void 0 : { expiry: options.expiryMs };
|
|
17553
|
-
const result = await node.delegateTo((0,
|
|
17553
|
+
const result = await node.delegateTo((0, import_sdk_core12.principalDid)(deviceDid), entries, delegateOptions);
|
|
17554
17554
|
return {
|
|
17555
17555
|
ucan: result.delegation.delegationHeader.Authorization,
|
|
17556
17556
|
expiresAt: result.delegation.expiry.getTime()
|
|
@@ -17568,7 +17568,7 @@ function replicationScopeFromSignedSession(input) {
|
|
|
17568
17568
|
for (const resource of Object.keys(grant.att)) {
|
|
17569
17569
|
const space = resource.match(/^(?:tinycloud:\/\/)?(.+?)\/kv(?:\/|$)/)?.[1];
|
|
17570
17570
|
if (space !== input.persistedSpace) continue;
|
|
17571
|
-
const owner = (0,
|
|
17571
|
+
const owner = (0, import_sdk_core12.parseSpaceUri)(space);
|
|
17572
17572
|
if (owner?.owner && owner.address && owner.chainId) return { space, principal: owner.owner };
|
|
17573
17573
|
}
|
|
17574
17574
|
return void 0;
|
|
@@ -17699,18 +17699,18 @@ function createReplicationAuthority(host) {
|
|
|
17699
17699
|
};
|
|
17700
17700
|
return authority;
|
|
17701
17701
|
}
|
|
17702
|
-
var import_siwe3,
|
|
17702
|
+
var import_siwe3, import_sdk_core12, import_replica, parseUcanGrant, KV_GET2, KV_SYNC2, KV_SERVICE2, AUTHORITY_EXPIRY_MARGIN_MS;
|
|
17703
17703
|
var init_authority = __esm({
|
|
17704
17704
|
"src/replication/authority.ts"() {
|
|
17705
17705
|
"use strict";
|
|
17706
17706
|
import_siwe3 = require("siwe");
|
|
17707
|
-
|
|
17707
|
+
import_sdk_core12 = require("@tinycloud/sdk-core");
|
|
17708
17708
|
import_replica = require("@tinycloud/replica");
|
|
17709
17709
|
init_config();
|
|
17710
17710
|
init_authority_sign_in();
|
|
17711
17711
|
parseUcanGrant = import_replica.parseUcanGrant;
|
|
17712
|
-
KV_GET2 =
|
|
17713
|
-
KV_SYNC2 =
|
|
17712
|
+
KV_GET2 = import_sdk_core12.KV.GET;
|
|
17713
|
+
KV_SYNC2 = import_sdk_core12.KV.SYNC;
|
|
17714
17714
|
KV_SERVICE2 = "tinycloud.kv";
|
|
17715
17715
|
AUTHORITY_EXPIRY_MARGIN_MS = 6e4;
|
|
17716
17716
|
}
|
|
@@ -17792,172 +17792,172 @@ var init_gated_network = __esm({
|
|
|
17792
17792
|
var src_exports = {};
|
|
17793
17793
|
__export(src_exports, {
|
|
17794
17794
|
ACCEPTED_MARKER_VERSIONS: () => ACCEPTED_MARKER_VERSIONS,
|
|
17795
|
-
ACCOUNT_REGISTRY_PATH: () =>
|
|
17796
|
-
ACCOUNT_REGISTRY_SPACE: () =>
|
|
17797
|
-
AccountService: () =>
|
|
17798
|
-
AutoApproveSpaceCreationHandler: () =>
|
|
17795
|
+
ACCOUNT_REGISTRY_PATH: () => import_sdk_core17.ACCOUNT_REGISTRY_PATH,
|
|
17796
|
+
ACCOUNT_REGISTRY_SPACE: () => import_sdk_core17.ACCOUNT_REGISTRY_SPACE,
|
|
17797
|
+
AccountService: () => import_sdk_core6.AccountService,
|
|
17798
|
+
AutoApproveSpaceCreationHandler: () => import_sdk_core16.AutoApproveSpaceCreationHandler,
|
|
17799
17799
|
BOOTSTRAP_COMPLETION_MARKER_KEY: () => BOOTSTRAP_COMPLETION_MARKER_KEY,
|
|
17800
17800
|
BOOTSTRAP_COMPLETION_MARKER_VERSION: () => BOOTSTRAP_COMPLETION_MARKER_VERSION,
|
|
17801
|
-
CapabilityKeyRegistry: () =>
|
|
17802
|
-
CapabilityKeyRegistryErrorCodes: () =>
|
|
17803
|
-
CaveatedDelegationUnsupportedError: () =>
|
|
17804
|
-
DECRYPT_ACTION: () =>
|
|
17805
|
-
DECRYPT_FACT_TYPE: () =>
|
|
17806
|
-
DECRYPT_RESULT_TYPE: () =>
|
|
17807
|
-
DEFAULT_ENCRYPTION_ALG: () =>
|
|
17808
|
-
DEFAULT_KEY_VERSION: () =>
|
|
17809
|
-
DEFAULT_MANIFEST_SPACE: () =>
|
|
17810
|
-
DEFAULT_MANIFEST_VERSION: () =>
|
|
17811
|
-
DEFAULT_SIGNED_READ_URL_EXPIRY_MS: () =>
|
|
17812
|
-
DataVaultService: () =>
|
|
17813
|
-
DatabaseHandle: () =>
|
|
17814
|
-
DecryptTransportResponseError: () =>
|
|
17801
|
+
CapabilityKeyRegistry: () => import_sdk_core25.CapabilityKeyRegistry,
|
|
17802
|
+
CapabilityKeyRegistryErrorCodes: () => import_sdk_core25.CapabilityKeyRegistryErrorCodes,
|
|
17803
|
+
CaveatedDelegationUnsupportedError: () => import_sdk_core17.CaveatedDelegationUnsupportedError,
|
|
17804
|
+
DECRYPT_ACTION: () => import_sdk_core22.DECRYPT_ACTION,
|
|
17805
|
+
DECRYPT_FACT_TYPE: () => import_sdk_core22.DECRYPT_FACT_TYPE,
|
|
17806
|
+
DECRYPT_RESULT_TYPE: () => import_sdk_core22.DECRYPT_RESULT_TYPE,
|
|
17807
|
+
DEFAULT_ENCRYPTION_ALG: () => import_sdk_core22.DEFAULT_ENCRYPTION_ALG,
|
|
17808
|
+
DEFAULT_KEY_VERSION: () => import_sdk_core22.DEFAULT_KEY_VERSION,
|
|
17809
|
+
DEFAULT_MANIFEST_SPACE: () => import_sdk_core17.DEFAULT_MANIFEST_SPACE,
|
|
17810
|
+
DEFAULT_MANIFEST_VERSION: () => import_sdk_core17.DEFAULT_MANIFEST_VERSION,
|
|
17811
|
+
DEFAULT_SIGNED_READ_URL_EXPIRY_MS: () => import_sdk_core18.DEFAULT_SIGNED_READ_URL_EXPIRY_MS,
|
|
17812
|
+
DataVaultService: () => import_sdk_core21.DataVaultService,
|
|
17813
|
+
DatabaseHandle: () => import_sdk_core19.DatabaseHandle,
|
|
17814
|
+
DecryptTransportResponseError: () => import_sdk_core22.DecryptTransportResponseError,
|
|
17815
17815
|
DelegatedAccess: () => DelegatedAccess,
|
|
17816
|
-
DelegationErrorCodes: () =>
|
|
17817
|
-
DelegationManager: () =>
|
|
17818
|
-
DuckDbAction: () =>
|
|
17819
|
-
DuckDbDatabaseHandle: () =>
|
|
17820
|
-
DuckDbService: () =>
|
|
17821
|
-
ENCRYPTION_NETWORK_URN_PREFIX: () =>
|
|
17822
|
-
ENCRYPTION_SERVICE: () =>
|
|
17823
|
-
ENCRYPTION_SERVICE_SHORT: () =>
|
|
17824
|
-
ENVELOPE_VERSION: () =>
|
|
17825
|
-
EncryptionService: () =>
|
|
17816
|
+
DelegationErrorCodes: () => import_sdk_core24.DelegationErrorCodes,
|
|
17817
|
+
DelegationManager: () => import_sdk_core24.DelegationManager,
|
|
17818
|
+
DuckDbAction: () => import_sdk_core20.DuckDbAction,
|
|
17819
|
+
DuckDbDatabaseHandle: () => import_sdk_core20.DuckDbDatabaseHandle,
|
|
17820
|
+
DuckDbService: () => import_sdk_core20.DuckDbService,
|
|
17821
|
+
ENCRYPTION_NETWORK_URN_PREFIX: () => import_sdk_core22.ENCRYPTION_NETWORK_URN_PREFIX,
|
|
17822
|
+
ENCRYPTION_SERVICE: () => import_sdk_core22.ENCRYPTION_SERVICE,
|
|
17823
|
+
ENCRYPTION_SERVICE_SHORT: () => import_sdk_core22.ENCRYPTION_SERVICE_SHORT,
|
|
17824
|
+
ENVELOPE_VERSION: () => import_sdk_core22.ENVELOPE_VERSION,
|
|
17825
|
+
EncryptionService: () => import_sdk_core22.EncryptionService,
|
|
17826
17826
|
FileSessionStorage: () => FileSessionStorage,
|
|
17827
|
-
HooksService: () =>
|
|
17828
|
-
IdentityParseError: () =>
|
|
17827
|
+
HooksService: () => import_sdk_core23.HooksService,
|
|
17828
|
+
IdentityParseError: () => import_sdk_core16.IdentityParseError,
|
|
17829
17829
|
InvalidRestoredSessionError: () => InvalidRestoredSessionError,
|
|
17830
|
-
KVService: () =>
|
|
17831
|
-
MAX_SECRET_SCOPE_LENGTH: () =>
|
|
17832
|
-
ManifestValidationError: () =>
|
|
17830
|
+
KVService: () => import_sdk_core18.KVService,
|
|
17831
|
+
MAX_SECRET_SCOPE_LENGTH: () => import_sdk_core21.MAX_SECRET_SCOPE_LENGTH,
|
|
17832
|
+
ManifestValidationError: () => import_sdk_core17.ManifestValidationError,
|
|
17833
17833
|
MemorySessionStorage: () => MemorySessionStorage,
|
|
17834
|
-
NETWORK_NAME_PATTERN: () =>
|
|
17835
|
-
NetworkIdError: () =>
|
|
17834
|
+
NETWORK_NAME_PATTERN: () => import_sdk_core22.NETWORK_NAME_PATTERN,
|
|
17835
|
+
NetworkIdError: () => import_sdk_core22.NetworkIdError,
|
|
17836
17836
|
NodeUserAuthorization: () => NodeUserAuthorization,
|
|
17837
17837
|
NodeWasmBindings: () => NodeWasmBindings,
|
|
17838
|
-
PermissionNotInManifestError: () =>
|
|
17839
|
-
PrefixedKVService: () =>
|
|
17838
|
+
PermissionNotInManifestError: () => import_sdk_core17.PermissionNotInManifestError,
|
|
17839
|
+
PrefixedKVService: () => import_sdk_core18.PrefixedKVService,
|
|
17840
17840
|
PrivateKeySigner: () => PrivateKeySigner,
|
|
17841
|
-
ProtocolMismatchError: () =>
|
|
17841
|
+
ProtocolMismatchError: () => import_sdk_core27.ProtocolMismatchError,
|
|
17842
17842
|
REPLICA_LOGOUT_PENDING_FILE: () => REPLICA_LOGOUT_PENDING_FILE,
|
|
17843
17843
|
RESTORED_GATE_MESSAGE: () => RESTORED_GATE_MESSAGE,
|
|
17844
17844
|
RUNTIME_DELEGATION_REJECTIONS: () => RUNTIME_DELEGATION_REJECTIONS,
|
|
17845
17845
|
RuntimeDelegationRejectedError: () => RuntimeDelegationRejectedError,
|
|
17846
|
-
SECRET_NAME_RE: () =>
|
|
17847
|
-
SECRET_SCOPE_RE: () =>
|
|
17848
|
-
SQLAction: () =>
|
|
17849
|
-
SQLService: () =>
|
|
17850
|
-
STORAGE_FULL_MESSAGE: () =>
|
|
17851
|
-
STORAGE_MANAGE_URL: () =>
|
|
17852
|
-
STORAGE_WRITE_TOO_LARGE_MESSAGE: () =>
|
|
17853
|
-
SecretsService: () =>
|
|
17854
|
-
ServiceContext: () =>
|
|
17855
|
-
SessionExpiredError: () =>
|
|
17856
|
-
SharingService: () =>
|
|
17857
|
-
SilentNotificationHandler: () =>
|
|
17858
|
-
Space: () =>
|
|
17859
|
-
SpaceErrorCodes: () =>
|
|
17860
|
-
SpaceService: () =>
|
|
17861
|
-
TC832_RESERVED_SCOPES: () =>
|
|
17862
|
-
TinyCloud: () =>
|
|
17863
|
-
TinyCloudDebugLogger: () =>
|
|
17846
|
+
SECRET_NAME_RE: () => import_sdk_core21.SECRET_NAME_RE,
|
|
17847
|
+
SECRET_SCOPE_RE: () => import_sdk_core21.SECRET_SCOPE_RE,
|
|
17848
|
+
SQLAction: () => import_sdk_core19.SQLAction,
|
|
17849
|
+
SQLService: () => import_sdk_core19.SQLService,
|
|
17850
|
+
STORAGE_FULL_MESSAGE: () => import_sdk_core16.STORAGE_FULL_MESSAGE,
|
|
17851
|
+
STORAGE_MANAGE_URL: () => import_sdk_core16.STORAGE_MANAGE_URL,
|
|
17852
|
+
STORAGE_WRITE_TOO_LARGE_MESSAGE: () => import_sdk_core16.STORAGE_WRITE_TOO_LARGE_MESSAGE,
|
|
17853
|
+
SecretsService: () => import_sdk_core21.SecretsService,
|
|
17854
|
+
ServiceContext: () => import_sdk_core28.ServiceContext,
|
|
17855
|
+
SessionExpiredError: () => import_sdk_core17.SessionExpiredError,
|
|
17856
|
+
SharingService: () => import_sdk_core24.SharingService,
|
|
17857
|
+
SilentNotificationHandler: () => import_sdk_core16.SilentNotificationHandler,
|
|
17858
|
+
Space: () => import_sdk_core26.Space,
|
|
17859
|
+
SpaceErrorCodes: () => import_sdk_core26.SpaceErrorCodes,
|
|
17860
|
+
SpaceService: () => import_sdk_core26.SpaceService,
|
|
17861
|
+
TC832_RESERVED_SCOPES: () => import_sdk_core21.TC832_RESERVED_SCOPES,
|
|
17862
|
+
TinyCloud: () => import_sdk_core15.TinyCloud,
|
|
17863
|
+
TinyCloudDebugLogger: () => import_sdk_core16.TinyCloudDebugLogger,
|
|
17864
17864
|
TinyCloudNode: () => TinyCloudNode,
|
|
17865
|
-
UnsupportedFeatureError: () =>
|
|
17865
|
+
UnsupportedFeatureError: () => import_sdk_core27.UnsupportedFeatureError,
|
|
17866
17866
|
UnsupportedSessionRestoreError: () => UnsupportedSessionRestoreError,
|
|
17867
|
-
VAULT_PERMISSION_SERVICE: () =>
|
|
17868
|
-
VaultHeaders: () =>
|
|
17869
|
-
VaultPublicSpaceKVActions: () =>
|
|
17870
|
-
VersionCheckError: () =>
|
|
17867
|
+
VAULT_PERMISSION_SERVICE: () => import_sdk_core17.VAULT_PERMISSION_SERVICE,
|
|
17868
|
+
VaultHeaders: () => import_sdk_core21.VaultHeaders,
|
|
17869
|
+
VaultPublicSpaceKVActions: () => import_sdk_core21.VaultPublicSpaceKVActions,
|
|
17870
|
+
VersionCheckError: () => import_sdk_core27.VersionCheckError,
|
|
17871
17871
|
WasmKeyProvider: () => WasmKeyProvider,
|
|
17872
17872
|
activateCompactRuntimeDelegation: () => activateCompactRuntimeDelegation,
|
|
17873
17873
|
activateValidatedRuntimeDelegation: () => activateValidatedRuntimeDelegation,
|
|
17874
|
-
addressStorageKey: () =>
|
|
17875
|
-
appSecretScope: () =>
|
|
17874
|
+
addressStorageKey: () => import_sdk_core16.addressStorageKey,
|
|
17875
|
+
appSecretScope: () => import_sdk_core21.appSecretScope,
|
|
17876
17876
|
assertProfileLogoutClear: () => assertProfileLogoutClear,
|
|
17877
|
-
buildCanonicalDecryptRequest: () =>
|
|
17878
|
-
buildDecryptAttenuation: () =>
|
|
17879
|
-
buildDecryptFacts: () =>
|
|
17880
|
-
buildDecryptInvocation: () =>
|
|
17881
|
-
buildNetworkId: () =>
|
|
17882
|
-
buildSpaceUri: () =>
|
|
17883
|
-
canonicalHashHex: () =>
|
|
17884
|
-
canonicalSignedResponse: () =>
|
|
17885
|
-
canonicalizeAddress: () =>
|
|
17886
|
-
canonicalizeDid: () =>
|
|
17887
|
-
canonicalizeDidUrl: () =>
|
|
17888
|
-
canonicalizeEncryptionJson: () =>
|
|
17889
|
-
canonicalizeNetworkId: () =>
|
|
17890
|
-
canonicalizeSecretScope: () =>
|
|
17891
|
-
checkDecryptInvocationInput: () =>
|
|
17892
|
-
checkNodeInfo: () =>
|
|
17893
|
-
clearTinyCloudDebugLogs: () =>
|
|
17894
|
-
composeManifestRequest: () =>
|
|
17895
|
-
createCapabilityKeyRegistry: () =>
|
|
17896
|
-
createOpenKeyCallbackSigningStrategy: () =>
|
|
17877
|
+
buildCanonicalDecryptRequest: () => import_sdk_core22.buildCanonicalDecryptRequest,
|
|
17878
|
+
buildDecryptAttenuation: () => import_sdk_core22.buildDecryptAttenuation,
|
|
17879
|
+
buildDecryptFacts: () => import_sdk_core22.buildDecryptFacts,
|
|
17880
|
+
buildDecryptInvocation: () => import_sdk_core22.buildDecryptInvocation,
|
|
17881
|
+
buildNetworkId: () => import_sdk_core22.buildNetworkId,
|
|
17882
|
+
buildSpaceUri: () => import_sdk_core26.buildSpaceUri,
|
|
17883
|
+
canonicalHashHex: () => import_sdk_core22.canonicalHashHex,
|
|
17884
|
+
canonicalSignedResponse: () => import_sdk_core22.canonicalSignedResponse,
|
|
17885
|
+
canonicalizeAddress: () => import_sdk_core16.canonicalizeAddress,
|
|
17886
|
+
canonicalizeDid: () => import_sdk_core16.canonicalizeDid,
|
|
17887
|
+
canonicalizeDidUrl: () => import_sdk_core16.canonicalizeDidUrl,
|
|
17888
|
+
canonicalizeEncryptionJson: () => import_sdk_core22.canonicalizeEncryptionJson,
|
|
17889
|
+
canonicalizeNetworkId: () => import_sdk_core16.canonicalizeNetworkId,
|
|
17890
|
+
canonicalizeSecretScope: () => import_sdk_core21.canonicalizeSecretScope,
|
|
17891
|
+
checkDecryptInvocationInput: () => import_sdk_core22.checkDecryptInvocationInput,
|
|
17892
|
+
checkNodeInfo: () => import_sdk_core27.checkNodeInfo,
|
|
17893
|
+
clearTinyCloudDebugLogs: () => import_sdk_core16.clearTinyCloudDebugLogs,
|
|
17894
|
+
composeManifestRequest: () => import_sdk_core17.composeManifestRequest,
|
|
17895
|
+
createCapabilityKeyRegistry: () => import_sdk_core25.createCapabilityKeyRegistry,
|
|
17896
|
+
createOpenKeyCallbackSigningStrategy: () => import_sdk_core4.createOpenKeyCallbackSigningStrategy,
|
|
17897
17897
|
createProfileReplicaPurge: () => createProfileReplicaPurge,
|
|
17898
|
-
createSharingService: () =>
|
|
17899
|
-
createSpaceService: () =>
|
|
17900
|
-
createVaultCrypto: () =>
|
|
17898
|
+
createSharingService: () => import_sdk_core24.createSharingService,
|
|
17899
|
+
createSpaceService: () => import_sdk_core26.createSpaceService,
|
|
17900
|
+
createVaultCrypto: () => import_sdk_core21.createVaultCrypto,
|
|
17901
17901
|
createWasmKeyProvider: () => createWasmKeyProvider,
|
|
17902
|
-
decryptEnvelopeWithKey: () =>
|
|
17902
|
+
decryptEnvelopeWithKey: () => import_sdk_core22.decryptEnvelopeWithKey,
|
|
17903
17903
|
defaultSignStrategy: () => defaultSignStrategy,
|
|
17904
|
-
defaultSpaceCreationHandler: () =>
|
|
17905
|
-
deriveSignedReceiverKey: () =>
|
|
17904
|
+
defaultSpaceCreationHandler: () => import_sdk_core16.defaultSpaceCreationHandler,
|
|
17905
|
+
deriveSignedReceiverKey: () => import_sdk_core22.deriveSignedReceiverKey,
|
|
17906
17906
|
deserializeDelegation: () => deserializeDelegation,
|
|
17907
|
-
didCacheKey: () =>
|
|
17908
|
-
didEquals: () =>
|
|
17909
|
-
disableTinyCloudDebug: () =>
|
|
17910
|
-
discoverNetwork: () =>
|
|
17911
|
-
enableTinyCloudDebug: () =>
|
|
17912
|
-
encryptToNetwork: () =>
|
|
17913
|
-
encryptionBase64Decode: () =>
|
|
17914
|
-
encryptionBase64Encode: () =>
|
|
17915
|
-
encryptionError: () =>
|
|
17916
|
-
encryptionUtf8Decode: () =>
|
|
17917
|
-
encryptionUtf8Encode: () =>
|
|
17918
|
-
ensureNetworkUsableForDecrypt: () =>
|
|
17919
|
-
expandActionShortNames: () =>
|
|
17920
|
-
expandPermissionEntries: () =>
|
|
17921
|
-
expandPermissionEntry: () =>
|
|
17907
|
+
didCacheKey: () => import_sdk_core16.didCacheKey,
|
|
17908
|
+
didEquals: () => import_sdk_core16.didEquals,
|
|
17909
|
+
disableTinyCloudDebug: () => import_sdk_core16.disableTinyCloudDebug,
|
|
17910
|
+
discoverNetwork: () => import_sdk_core22.discoverNetwork,
|
|
17911
|
+
enableTinyCloudDebug: () => import_sdk_core16.enableTinyCloudDebug,
|
|
17912
|
+
encryptToNetwork: () => import_sdk_core22.encryptToNetwork,
|
|
17913
|
+
encryptionBase64Decode: () => import_sdk_core22.encryptionBase64Decode,
|
|
17914
|
+
encryptionBase64Encode: () => import_sdk_core22.encryptionBase64Encode,
|
|
17915
|
+
encryptionError: () => import_sdk_core22.encryptionError,
|
|
17916
|
+
encryptionUtf8Decode: () => import_sdk_core22.encryptionUtf8Decode,
|
|
17917
|
+
encryptionUtf8Encode: () => import_sdk_core22.encryptionUtf8Encode,
|
|
17918
|
+
ensureNetworkUsableForDecrypt: () => import_sdk_core22.ensureNetworkUsableForDecrypt,
|
|
17919
|
+
expandActionShortNames: () => import_sdk_core17.expandActionShortNames,
|
|
17920
|
+
expandPermissionEntries: () => import_sdk_core17.expandPermissionEntries,
|
|
17921
|
+
expandPermissionEntry: () => import_sdk_core17.expandPermissionEntry,
|
|
17922
17922
|
extractSiweExpiration: () => extractSiweExpiration,
|
|
17923
|
-
generateRandomReceiverKey: () =>
|
|
17924
|
-
getTinyCloudDebugLogs: () =>
|
|
17923
|
+
generateRandomReceiverKey: () => import_sdk_core22.generateRandomReceiverKey,
|
|
17924
|
+
getTinyCloudDebugLogs: () => import_sdk_core16.getTinyCloudDebugLogs,
|
|
17925
17925
|
grantAuthRequest: () => grantAuthRequest,
|
|
17926
|
-
hexDecode: () =>
|
|
17927
|
-
hexEncode: () =>
|
|
17928
|
-
installTinyCloudDebugGlobals: () =>
|
|
17929
|
-
isCapabilitySubset: () =>
|
|
17930
|
-
isEvmAddress: () =>
|
|
17931
|
-
isNetworkId: () =>
|
|
17932
|
-
isStorageFullError: () =>
|
|
17933
|
-
loadManifest: () =>
|
|
17926
|
+
hexDecode: () => import_sdk_core22.hexDecode,
|
|
17927
|
+
hexEncode: () => import_sdk_core22.hexEncode,
|
|
17928
|
+
installTinyCloudDebugGlobals: () => import_sdk_core16.installTinyCloudDebugGlobals,
|
|
17929
|
+
isCapabilitySubset: () => import_sdk_core17.isCapabilitySubset,
|
|
17930
|
+
isEvmAddress: () => import_sdk_core16.isEvmAddress,
|
|
17931
|
+
isNetworkId: () => import_sdk_core22.isNetworkId,
|
|
17932
|
+
isStorageFullError: () => import_sdk_core16.isStorageFullError,
|
|
17933
|
+
loadManifest: () => import_sdk_core17.loadManifest,
|
|
17934
17934
|
logoutPrincipalDigest: () => logoutPrincipalDigest,
|
|
17935
|
-
makePkhSpaceId: () =>
|
|
17936
|
-
makePublicSpaceId: () =>
|
|
17937
|
-
networkDiscoveryKey: () =>
|
|
17938
|
-
openWrappedKey: () =>
|
|
17939
|
-
parseCanonicalNetworkId: () =>
|
|
17940
|
-
parseExpiry: () =>
|
|
17941
|
-
parseNetworkId: () =>
|
|
17942
|
-
parsePkhDid: () =>
|
|
17943
|
-
parseSecretCatalogKey: () =>
|
|
17944
|
-
parseSpaceUri: () =>
|
|
17945
|
-
pkhDid: () =>
|
|
17946
|
-
principalDid: () =>
|
|
17947
|
-
principalDidEquals: () =>
|
|
17948
|
-
resolveManifest: () =>
|
|
17949
|
-
resolveSecretListPrefix: () =>
|
|
17950
|
-
resolveSecretPath: () =>
|
|
17951
|
-
resourceCapabilitiesToSpaceAbilitiesMap: () =>
|
|
17935
|
+
makePkhSpaceId: () => import_sdk_core16.makePkhSpaceId,
|
|
17936
|
+
makePublicSpaceId: () => import_sdk_core26.makePublicSpaceId,
|
|
17937
|
+
networkDiscoveryKey: () => import_sdk_core22.networkDiscoveryKey,
|
|
17938
|
+
openWrappedKey: () => import_sdk_core22.openWrappedKey,
|
|
17939
|
+
parseCanonicalNetworkId: () => import_sdk_core16.parseCanonicalNetworkId,
|
|
17940
|
+
parseExpiry: () => import_sdk_core17.parseExpiry,
|
|
17941
|
+
parseNetworkId: () => import_sdk_core22.parseNetworkId,
|
|
17942
|
+
parsePkhDid: () => import_sdk_core16.parsePkhDid,
|
|
17943
|
+
parseSecretCatalogKey: () => import_sdk_core21.parseSecretCatalogKey,
|
|
17944
|
+
parseSpaceUri: () => import_sdk_core26.parseSpaceUri,
|
|
17945
|
+
pkhDid: () => import_sdk_core16.pkhDid,
|
|
17946
|
+
principalDid: () => import_sdk_core16.principalDid,
|
|
17947
|
+
principalDidEquals: () => import_sdk_core16.principalDidEquals,
|
|
17948
|
+
resolveManifest: () => import_sdk_core17.resolveManifest,
|
|
17949
|
+
resolveSecretListPrefix: () => import_sdk_core21.resolveSecretListPrefix,
|
|
17950
|
+
resolveSecretPath: () => import_sdk_core21.resolveSecretPath,
|
|
17951
|
+
resourceCapabilitiesToSpaceAbilitiesMap: () => import_sdk_core17.resourceCapabilitiesToSpaceAbilitiesMap,
|
|
17952
17952
|
serializeDelegation: () => serializeDelegation,
|
|
17953
17953
|
signedCompactUcanExpiry: () => signedCompactUcanExpiry,
|
|
17954
17954
|
siweRuntimeDelegation: () => siweRuntimeDelegation,
|
|
17955
17955
|
sqliteReplicaStorage: () => sqliteReplicaStorage,
|
|
17956
|
-
storageUsageState: () =>
|
|
17957
|
-
tinyCloudDebugLogger: () =>
|
|
17958
|
-
validateEnvelope: () =>
|
|
17959
|
-
validateManifest: () =>
|
|
17960
|
-
verifyDecryptResponse: () =>
|
|
17956
|
+
storageUsageState: () => import_sdk_core16.storageUsageState,
|
|
17957
|
+
tinyCloudDebugLogger: () => import_sdk_core16.tinyCloudDebugLogger,
|
|
17958
|
+
validateEnvelope: () => import_sdk_core22.validateEnvelope,
|
|
17959
|
+
validateManifest: () => import_sdk_core17.validateManifest,
|
|
17960
|
+
verifyDecryptResponse: () => import_sdk_core22.verifyDecryptResponse,
|
|
17961
17961
|
wireOpenKeyAuthorize: () => wireOpenKeyAuthorize
|
|
17962
17962
|
});
|
|
17963
17963
|
module.exports = __toCommonJS(src_exports);
|
|
@@ -18785,18 +18785,31 @@ function getNodeReplicationLoaders() {
|
|
|
18785
18785
|
}
|
|
18786
18786
|
|
|
18787
18787
|
// src/TinyCloudNode.ts
|
|
18788
|
-
var
|
|
18788
|
+
var import_sdk_core10 = require("@tinycloud/sdk-core");
|
|
18789
18789
|
var import_sdk_services3 = require("@tinycloud/sdk-services");
|
|
18790
18790
|
var import_requestLog2 = require("@tinycloud/sdk-services/telemetry/requestLog");
|
|
18791
18791
|
|
|
18792
18792
|
// src/authorization/NodeUserAuthorization.ts
|
|
18793
18793
|
var import_node_crypto = require("crypto");
|
|
18794
18794
|
var import_siwe = require("siwe");
|
|
18795
|
-
var
|
|
18795
|
+
var import_sdk_core5 = require("@tinycloud/sdk-core");
|
|
18796
18796
|
init_authority_sign_in();
|
|
18797
18797
|
|
|
18798
|
-
// src/authorization/
|
|
18798
|
+
// src/authorization/caveatRefusal.ts
|
|
18799
18799
|
var import_sdk_core3 = require("@tinycloud/sdk-core");
|
|
18800
|
+
function refuseCaveated(input) {
|
|
18801
|
+
const caveated = [input ?? []].flat().flatMap((item) => [item, ...item.permissions ?? []]).filter(({ caveats }) => {
|
|
18802
|
+
try {
|
|
18803
|
+
return caveats === null || !(0, import_sdk_core3.recapCaveatsEqual)(caveats, void 0);
|
|
18804
|
+
} catch {
|
|
18805
|
+
return true;
|
|
18806
|
+
}
|
|
18807
|
+
});
|
|
18808
|
+
if (caveated.length) throw new import_sdk_core3.CaveatedDelegationUnsupportedError(caveated);
|
|
18809
|
+
}
|
|
18810
|
+
|
|
18811
|
+
// src/authorization/strategies.ts
|
|
18812
|
+
var import_sdk_core4 = require("@tinycloud/sdk-core");
|
|
18800
18813
|
var defaultSignStrategy = { type: "auto-sign" };
|
|
18801
18814
|
|
|
18802
18815
|
// src/storage/MemorySessionStorage.ts
|
|
@@ -18875,8 +18888,8 @@ function pkhSpaceIdentity(spaceId) {
|
|
|
18875
18888
|
const match = /^(tinycloud:pkh:eip155:\d+:)(0x[0-9a-fA-F]{40})(:.+)$/.exec(spaceId);
|
|
18876
18889
|
return match === null ? spaceId : `${match[1]}${match[2].toLowerCase()}${match[3]}`;
|
|
18877
18890
|
}
|
|
18878
|
-
var DECRYPT_ACTION =
|
|
18879
|
-
var NETWORK_CREATE_ACTION =
|
|
18891
|
+
var DECRYPT_ACTION = import_sdk_core5.ENCRYPTION.DECRYPT;
|
|
18892
|
+
var NETWORK_CREATE_ACTION = import_sdk_core5.ENCRYPTION.NETWORK_CREATE;
|
|
18880
18893
|
function describeHostFailure(result) {
|
|
18881
18894
|
const text = result.error?.trim();
|
|
18882
18895
|
return text ? `${result.status} - ${text}` : `${result.status}`;
|
|
@@ -18904,7 +18917,7 @@ function canonicalOpenKeyManifestSha256Hex(value) {
|
|
|
18904
18917
|
}
|
|
18905
18918
|
function didPrincipalMatches(actual, expected) {
|
|
18906
18919
|
try {
|
|
18907
|
-
return (0,
|
|
18920
|
+
return (0, import_sdk_core5.principalDidEquals)(actual, expected);
|
|
18908
18921
|
} catch {
|
|
18909
18922
|
return actual === expected;
|
|
18910
18923
|
}
|
|
@@ -18920,7 +18933,7 @@ function addRawAbility(rawAbilities, resource, action) {
|
|
|
18920
18933
|
}
|
|
18921
18934
|
}
|
|
18922
18935
|
function primaryManifestSpace(resources) {
|
|
18923
|
-
return resources.find((entry) => entry.space !== "account")?.space ?? resources[0]?.space ??
|
|
18936
|
+
return resources.find((entry) => entry.space !== "account")?.space ?? resources[0]?.space ?? import_sdk_core5.DEFAULT_MANIFEST_SPACE;
|
|
18924
18937
|
}
|
|
18925
18938
|
function cloneAbilitiesMap(actions) {
|
|
18926
18939
|
return Object.fromEntries(
|
|
@@ -18961,30 +18974,30 @@ var NodeUserAuthorization = class {
|
|
|
18961
18974
|
this.spacePrefix = config.spacePrefix ?? "default";
|
|
18962
18975
|
this.defaultActions = config.defaultActions ?? {
|
|
18963
18976
|
kv: {
|
|
18964
|
-
"": [
|
|
18977
|
+
"": [import_sdk_core5.KV.PUT, import_sdk_core5.KV.GET, import_sdk_core5.KV.DEL, import_sdk_core5.KV.LIST, import_sdk_core5.KV.METADATA]
|
|
18965
18978
|
},
|
|
18966
18979
|
sql: {
|
|
18967
|
-
"": [
|
|
18980
|
+
"": [import_sdk_core5.SQL.READ, import_sdk_core5.SQL.WRITE, import_sdk_core5.SQL.SCHEMA, import_sdk_core5.SQL.ADMIN, import_sdk_core5.SQL.EXPORT]
|
|
18968
18981
|
},
|
|
18969
18982
|
duckdb: {
|
|
18970
18983
|
"": [
|
|
18971
|
-
|
|
18972
|
-
|
|
18973
|
-
|
|
18974
|
-
|
|
18975
|
-
|
|
18976
|
-
|
|
18977
|
-
|
|
18984
|
+
import_sdk_core5.DUCKDB.READ,
|
|
18985
|
+
import_sdk_core5.DUCKDB.WRITE,
|
|
18986
|
+
import_sdk_core5.DUCKDB.ADMIN,
|
|
18987
|
+
import_sdk_core5.DUCKDB.DESCRIBE,
|
|
18988
|
+
import_sdk_core5.DUCKDB.EXPORT,
|
|
18989
|
+
import_sdk_core5.DUCKDB.IMPORT,
|
|
18990
|
+
import_sdk_core5.DUCKDB.EXECUTE
|
|
18978
18991
|
]
|
|
18979
18992
|
},
|
|
18980
18993
|
capabilities: {
|
|
18981
|
-
"": [
|
|
18994
|
+
"": [import_sdk_core5.CAPABILITIES.READ]
|
|
18982
18995
|
},
|
|
18983
18996
|
hooks: {
|
|
18984
|
-
"": [
|
|
18997
|
+
"": [import_sdk_core5.HOOKS.SUBSCRIBE, import_sdk_core5.HOOKS.REGISTER, import_sdk_core5.HOOKS.LIST, import_sdk_core5.HOOKS.UNREGISTER]
|
|
18985
18998
|
}
|
|
18986
18999
|
};
|
|
18987
|
-
this.sessionExpirationMs = config.sessionExpirationMs ??
|
|
19000
|
+
this.sessionExpirationMs = config.sessionExpirationMs ?? import_sdk_core5.EXPIRY.SESSION_MS;
|
|
18988
19001
|
this.autoCreateSpace = config.autoCreateSpace ?? false;
|
|
18989
19002
|
this.spaceCreationHandler = config.spaceCreationHandler;
|
|
18990
19003
|
this.tinycloudHosts = config.tinycloudHosts;
|
|
@@ -18993,7 +19006,7 @@ var NodeUserAuthorization = class {
|
|
|
18993
19006
|
this.registryPolicy = config.registryPolicy;
|
|
18994
19007
|
this.newUserHost = config.newUserHost;
|
|
18995
19008
|
this.registryChainId = config.registryChainId;
|
|
18996
|
-
this.registrySequenceStore = config.registrySequenceStore ?? (0,
|
|
19009
|
+
this.registrySequenceStore = config.registrySequenceStore ?? (0, import_sdk_core5.createInMemoryRegistrySequenceStore)();
|
|
18997
19010
|
this.onNodeNotFound = config.onNodeNotFound;
|
|
18998
19011
|
this.autoDiscoverLocalNode = config.autoDiscoverLocalNode;
|
|
18999
19012
|
this.localNodeUrl = config.localNodeUrl;
|
|
@@ -19070,7 +19083,7 @@ var NodeUserAuthorization = class {
|
|
|
19070
19083
|
* {@link ensureTinyCloudHosts}.
|
|
19071
19084
|
*/
|
|
19072
19085
|
setRestoredTinyCloudSession(session, hosts) {
|
|
19073
|
-
const address = (0,
|
|
19086
|
+
const address = (0, import_sdk_core5.canonicalizeAddress)(session.address);
|
|
19074
19087
|
this._tinyCloudSession = { ...session, address };
|
|
19075
19088
|
this._address = address;
|
|
19076
19089
|
this._chainId = session.chainId;
|
|
@@ -19158,7 +19171,7 @@ var NodeUserAuthorization = class {
|
|
|
19158
19171
|
return;
|
|
19159
19172
|
}
|
|
19160
19173
|
if (this.registryPolicy === "fail-closed") {
|
|
19161
|
-
const resolved2 = await (0,
|
|
19174
|
+
const resolved2 = await (0, import_sdk_core5.resolveFailClosedTinyCloudHosts)(address, {
|
|
19162
19175
|
registryUrl: this.tinycloudRegistryUrl,
|
|
19163
19176
|
registryChainId: this.registryChainId,
|
|
19164
19177
|
newUserHost: this.newUserHost,
|
|
@@ -19174,8 +19187,8 @@ var NodeUserAuthorization = class {
|
|
|
19174
19187
|
this.registryVerdict = resolved2.verdict;
|
|
19175
19188
|
return;
|
|
19176
19189
|
}
|
|
19177
|
-
const subject = (0,
|
|
19178
|
-
const resolved = await (0,
|
|
19190
|
+
const subject = (0, import_sdk_core5.pkhDid)(address, chainId);
|
|
19191
|
+
const resolved = await (0, import_sdk_core5.resolveTinyCloudHosts)(subject, {
|
|
19179
19192
|
registryUrl: this.tinycloudRegistryUrl,
|
|
19180
19193
|
fallbackHosts: this.tinycloudFallbackHosts,
|
|
19181
19194
|
autoDiscoverLocalNode: this.autoDiscoverLocalNode,
|
|
@@ -19201,16 +19214,16 @@ var NodeUserAuthorization = class {
|
|
|
19201
19214
|
throw new Error("Must be signed in to create a space");
|
|
19202
19215
|
}
|
|
19203
19216
|
await this.ensureTinyCloudHosts();
|
|
19204
|
-
const subject = (0,
|
|
19217
|
+
const subject = (0, import_sdk_core5.registryOwnerSubjectV1)(this._address, this.registryChainId);
|
|
19205
19218
|
let verdict = this.registryVerdict;
|
|
19206
19219
|
if (verdict?.subject !== subject || verdict.status === "unavailable") {
|
|
19207
|
-
verdict = await (0,
|
|
19220
|
+
verdict = await (0, import_sdk_core5.lookupOwnerRegistryVerdict)(subject, {
|
|
19208
19221
|
registryUrl: this.tinycloudRegistryUrl,
|
|
19209
19222
|
sequenceStore: this.registrySequenceStore
|
|
19210
19223
|
});
|
|
19211
19224
|
this.registryVerdict = verdict;
|
|
19212
19225
|
}
|
|
19213
|
-
(0,
|
|
19226
|
+
(0, import_sdk_core5.assertSpaceCreationAllowed)(verdict, this.primaryTinyCloudHost);
|
|
19214
19227
|
}
|
|
19215
19228
|
requireTinyCloudHosts() {
|
|
19216
19229
|
if (!this.tinycloudHosts || this.tinycloudHosts.length === 0) {
|
|
@@ -19229,7 +19242,7 @@ var NodeUserAuthorization = class {
|
|
|
19229
19242
|
}
|
|
19230
19243
|
async refreshNodeInfo() {
|
|
19231
19244
|
const infoHost = this.primaryTinyCloudHost;
|
|
19232
|
-
const nodeInfo = await (0,
|
|
19245
|
+
const nodeInfo = await (0, import_sdk_core5.checkNodeInfo)(infoHost, this.wasm.protocolVersion());
|
|
19233
19246
|
this._nodeFeatures = nodeInfo.features;
|
|
19234
19247
|
this._nodeFeaturesKnown = true;
|
|
19235
19248
|
this._nodeInfoIdentity = nodeInfo.nodeId ? { host: infoHost, nodeId: nodeInfo.nodeId } : void 0;
|
|
@@ -19282,7 +19295,7 @@ var NodeUserAuthorization = class {
|
|
|
19282
19295
|
if (this._manifest === void 0) {
|
|
19283
19296
|
return void 0;
|
|
19284
19297
|
}
|
|
19285
|
-
this._capabilityRequest = (0,
|
|
19298
|
+
this._capabilityRequest = (0, import_sdk_core5.composeManifestRequest)(
|
|
19286
19299
|
Array.isArray(this._manifest) ? this._manifest : [this._manifest],
|
|
19287
19300
|
{
|
|
19288
19301
|
includeAccountRegistryPermissions: this.includeAccountRegistryPermissions
|
|
@@ -19294,7 +19307,7 @@ var NodeUserAuthorization = class {
|
|
|
19294
19307
|
if (space.startsWith("tinycloud:")) {
|
|
19295
19308
|
return space;
|
|
19296
19309
|
}
|
|
19297
|
-
return (0,
|
|
19310
|
+
return (0, import_sdk_core5.makePkhSpaceId)(address, chainId, space);
|
|
19298
19311
|
}
|
|
19299
19312
|
/**
|
|
19300
19313
|
* The plain-session primary abilities: `defaultActions` (the shared table)
|
|
@@ -19305,10 +19318,10 @@ var NodeUserAuthorization = class {
|
|
|
19305
19318
|
* can't disagree (§4.6).
|
|
19306
19319
|
*/
|
|
19307
19320
|
primaryActionsForSignIn() {
|
|
19308
|
-
const primaryActions = this.includeAccountRegistryPermissions && this.spacePrefix ===
|
|
19309
|
-
if (this.includeAccountRegistryPermissions && this.spacePrefix ===
|
|
19310
|
-
const accountAbilities = (0,
|
|
19311
|
-
|
|
19321
|
+
const primaryActions = this.includeAccountRegistryPermissions && this.spacePrefix === import_sdk_core5.ACCOUNT_REGISTRY_SPACE ? cloneAbilitiesMap(this.defaultActions) : this.defaultActions;
|
|
19322
|
+
if (this.includeAccountRegistryPermissions && this.spacePrefix === import_sdk_core5.ACCOUNT_REGISTRY_SPACE) {
|
|
19323
|
+
const accountAbilities = (0, import_sdk_core5.resourceCapabilitiesToAbilitiesMap)(
|
|
19324
|
+
import_sdk_core5.ACCOUNT_MANIFEST_PERMISSIONS
|
|
19312
19325
|
);
|
|
19313
19326
|
for (const [service, paths] of Object.entries(accountAbilities)) {
|
|
19314
19327
|
const existingPaths = primaryActions[service] ?? (primaryActions[service] = {});
|
|
@@ -19335,11 +19348,11 @@ var NodeUserAuthorization = class {
|
|
|
19335
19348
|
return {
|
|
19336
19349
|
kv: {
|
|
19337
19350
|
"vault/secrets/": [
|
|
19338
|
-
|
|
19339
|
-
|
|
19340
|
-
|
|
19341
|
-
|
|
19342
|
-
|
|
19351
|
+
import_sdk_core5.KV.GET,
|
|
19352
|
+
import_sdk_core5.KV.PUT,
|
|
19353
|
+
import_sdk_core5.KV.DEL,
|
|
19354
|
+
import_sdk_core5.KV.LIST,
|
|
19355
|
+
import_sdk_core5.KV.METADATA
|
|
19343
19356
|
]
|
|
19344
19357
|
}
|
|
19345
19358
|
};
|
|
@@ -19354,7 +19367,7 @@ var NodeUserAuthorization = class {
|
|
|
19354
19367
|
signInPermissionInputs(address, chainId) {
|
|
19355
19368
|
const request = this.getCapabilityRequest();
|
|
19356
19369
|
if (request === void 0) {
|
|
19357
|
-
const primarySpaceId2 = (0,
|
|
19370
|
+
const primarySpaceId2 = (0, import_sdk_core5.makePkhSpaceId)(address, chainId, this.spacePrefix);
|
|
19358
19371
|
const effectivePrimary = this.spacePrefix === "secrets" ? this.secretsPrimaryAbilities() : this.primaryActionsForSignIn();
|
|
19359
19372
|
const kvPaths = effectivePrimary["kv"] ?? {};
|
|
19360
19373
|
return {
|
|
@@ -19368,7 +19381,7 @@ var NodeUserAuthorization = class {
|
|
|
19368
19381
|
};
|
|
19369
19382
|
}
|
|
19370
19383
|
const spaceResources = request.resources.filter(
|
|
19371
|
-
(entry) => entry.service !==
|
|
19384
|
+
(entry) => entry.service !== import_sdk_core5.ENCRYPTION_PERMISSION_SERVICE
|
|
19372
19385
|
);
|
|
19373
19386
|
const primarySpaceName = primaryManifestSpace(spaceResources);
|
|
19374
19387
|
const primarySpaceId = this.resolveSpaceName(
|
|
@@ -19434,21 +19447,21 @@ var NodeUserAuthorization = class {
|
|
|
19434
19447
|
});
|
|
19435
19448
|
}
|
|
19436
19449
|
defaultEncryptionNetworkId(address, chainId) {
|
|
19437
|
-
return `urn:tinycloud:encryption:${(0,
|
|
19450
|
+
return `urn:tinycloud:encryption:${(0, import_sdk_core5.pkhDid)(address, chainId)}:default`;
|
|
19438
19451
|
}
|
|
19439
19452
|
resolveSignInCapabilities(address, chainId) {
|
|
19440
19453
|
const request = this.getCapabilityRequest();
|
|
19441
19454
|
if (request === void 0) {
|
|
19442
19455
|
const defaultNetworkId = this.defaultEncryptionNetworkId(address, chainId);
|
|
19443
|
-
const primarySpaceId2 = (0,
|
|
19444
|
-
const secretsSpaceId = (0,
|
|
19456
|
+
const primarySpaceId2 = (0, import_sdk_core5.makePkhSpaceId)(address, chainId, this.spacePrefix);
|
|
19457
|
+
const secretsSpaceId = (0, import_sdk_core5.makePkhSpaceId)(address, chainId, "secrets");
|
|
19445
19458
|
const primaryActions = this.primaryActionsForSignIn();
|
|
19446
19459
|
const spaceAbilities2 = {
|
|
19447
19460
|
[primarySpaceId2]: primaryActions,
|
|
19448
19461
|
[secretsSpaceId]: this.secretsPrimaryAbilities()
|
|
19449
19462
|
};
|
|
19450
|
-
if (this.includeAccountRegistryPermissions && this.spacePrefix !==
|
|
19451
|
-
spaceAbilities2[(0,
|
|
19463
|
+
if (this.includeAccountRegistryPermissions && this.spacePrefix !== import_sdk_core5.ACCOUNT_REGISTRY_SPACE) {
|
|
19464
|
+
spaceAbilities2[(0, import_sdk_core5.makePkhSpaceId)(address, chainId, import_sdk_core5.ACCOUNT_REGISTRY_SPACE)] = (0, import_sdk_core5.resourceCapabilitiesToAbilitiesMap)(import_sdk_core5.ACCOUNT_MANIFEST_PERMISSIONS);
|
|
19452
19465
|
}
|
|
19453
19466
|
const mergedPrimary = this.mergeReplicationEntries(
|
|
19454
19467
|
spaceAbilities2,
|
|
@@ -19469,16 +19482,16 @@ var NodeUserAuthorization = class {
|
|
|
19469
19482
|
};
|
|
19470
19483
|
}
|
|
19471
19484
|
const rawAbilities = {};
|
|
19472
|
-
const currentDid = (0,
|
|
19485
|
+
const currentDid = (0, import_sdk_core5.pkhDid)(address, chainId);
|
|
19473
19486
|
const spaceResources = request.resources.filter((entry) => {
|
|
19474
|
-
if (entry.service !==
|
|
19487
|
+
if (entry.service !== import_sdk_core5.ENCRYPTION_PERMISSION_SERVICE) {
|
|
19475
19488
|
return true;
|
|
19476
19489
|
}
|
|
19477
19490
|
for (const action of entry.actions) {
|
|
19478
19491
|
addRawAbility(rawAbilities, entry.path, action);
|
|
19479
19492
|
}
|
|
19480
19493
|
if (entry.actions.includes(DECRYPT_ACTION)) {
|
|
19481
|
-
const parsed = (0,
|
|
19494
|
+
const parsed = (0, import_sdk_core5.parseNetworkId)(entry.path);
|
|
19482
19495
|
if (didPrincipalMatches(parsed.ownerDid, currentDid)) {
|
|
19483
19496
|
addRawAbility(rawAbilities, entry.path, NETWORK_CREATE_ACTION);
|
|
19484
19497
|
}
|
|
@@ -19491,7 +19504,7 @@ var NodeUserAuthorization = class {
|
|
|
19491
19504
|
address,
|
|
19492
19505
|
chainId
|
|
19493
19506
|
);
|
|
19494
|
-
const bySpace = (0,
|
|
19507
|
+
const bySpace = (0, import_sdk_core5.resourceCapabilitiesToSpaceAbilitiesMap)(spaceResources);
|
|
19495
19508
|
const spaceAbilities = {};
|
|
19496
19509
|
for (const [space, abilities] of Object.entries(bySpace)) {
|
|
19497
19510
|
spaceAbilities[this.resolveSpaceName(space, address, chainId)] = abilities;
|
|
@@ -19499,7 +19512,7 @@ var NodeUserAuthorization = class {
|
|
|
19499
19512
|
const mergedPrimaryAbilities = this.mergeReplicationEntries(
|
|
19500
19513
|
spaceAbilities,
|
|
19501
19514
|
primarySpaceId,
|
|
19502
|
-
spaceAbilities[primarySpaceId] ?? (0,
|
|
19515
|
+
spaceAbilities[primarySpaceId] ?? (0, import_sdk_core5.resourceCapabilitiesToAbilitiesMap)([]),
|
|
19503
19516
|
augmentSignInEntriesWithReplication({
|
|
19504
19517
|
...this.signInPermissionInputs(address, chainId),
|
|
19505
19518
|
replication: this.replication
|
|
@@ -19571,7 +19584,7 @@ var NodeUserAuthorization = class {
|
|
|
19571
19584
|
await this.ensureTinyCloudHosts();
|
|
19572
19585
|
const host = this.primaryTinyCloudHost;
|
|
19573
19586
|
const spaceId = targetSpaceId ?? this._tinyCloudSession.spaceId;
|
|
19574
|
-
const peerId = await (0,
|
|
19587
|
+
const peerId = await (0, import_sdk_core5.fetchPeerId)(host, spaceId, signal);
|
|
19575
19588
|
const siwe = this.wasm.generateHostSIWEMessage({
|
|
19576
19589
|
address: this._address,
|
|
19577
19590
|
chainId: this._chainId,
|
|
@@ -19601,7 +19614,7 @@ var NodeUserAuthorization = class {
|
|
|
19601
19614
|
}
|
|
19602
19615
|
if (signal?.aborted) throw signal.reason;
|
|
19603
19616
|
const headers = this.wasm.siweToDelegationHeaders({ siwe, signature: signature2 });
|
|
19604
|
-
return (0,
|
|
19617
|
+
return (0, import_sdk_core5.submitHostDelegation)(host, headers, signal);
|
|
19605
19618
|
}
|
|
19606
19619
|
/**
|
|
19607
19620
|
* Create a specific space on the server via host delegation.
|
|
@@ -19640,12 +19653,12 @@ var NodeUserAuthorization = class {
|
|
|
19640
19653
|
await this.ensureTinyCloudHosts();
|
|
19641
19654
|
const host = this.primaryTinyCloudHost;
|
|
19642
19655
|
const primarySpaceId = this._tinyCloudSession.spaceId;
|
|
19643
|
-
const result = await (0,
|
|
19656
|
+
const result = await (0, import_sdk_core5.activateSessionWithHost)(
|
|
19644
19657
|
host,
|
|
19645
19658
|
this._tinyCloudSession.delegationHeader
|
|
19646
19659
|
);
|
|
19647
19660
|
this.recordActivationSkippedSpaces(result, primarySpaceId);
|
|
19648
|
-
const handler = this.spaceCreationHandler ?? (this.autoCreateSpace ? new
|
|
19661
|
+
const handler = this.spaceCreationHandler ?? (this.autoCreateSpace ? new import_sdk_core5.AutoApproveSpaceCreationHandler() : void 0);
|
|
19649
19662
|
const creationContext = {
|
|
19650
19663
|
spaceId: primarySpaceId,
|
|
19651
19664
|
address: this._address,
|
|
@@ -19682,7 +19695,7 @@ var NodeUserAuthorization = class {
|
|
|
19682
19695
|
throw error;
|
|
19683
19696
|
}
|
|
19684
19697
|
await new Promise((resolve2) => setTimeout(resolve2, 100));
|
|
19685
|
-
const retryResult = await (0,
|
|
19698
|
+
const retryResult = await (0, import_sdk_core5.activateSessionWithHost)(
|
|
19686
19699
|
host,
|
|
19687
19700
|
this._tinyCloudSession.delegationHeader
|
|
19688
19701
|
);
|
|
@@ -19723,7 +19736,7 @@ var NodeUserAuthorization = class {
|
|
|
19723
19736
|
throw error;
|
|
19724
19737
|
}
|
|
19725
19738
|
await new Promise((resolve2) => setTimeout(resolve2, 100));
|
|
19726
|
-
const retryResult = await (0,
|
|
19739
|
+
const retryResult = await (0, import_sdk_core5.activateSessionWithHost)(
|
|
19727
19740
|
host,
|
|
19728
19741
|
this._tinyCloudSession.delegationHeader
|
|
19729
19742
|
);
|
|
@@ -19763,6 +19776,7 @@ var NodeUserAuthorization = class {
|
|
|
19763
19776
|
this._lastActivationSkippedSpaceIds = result.status === 404 ? [primarySpaceId] : [];
|
|
19764
19777
|
}
|
|
19765
19778
|
async createBootstrapSession(options) {
|
|
19779
|
+
refuseCaveated(options.capabilityRequest.manifests);
|
|
19766
19780
|
if (!this._address || !this._chainId) {
|
|
19767
19781
|
throw new Error("Must be signed in before creating bootstrap sessions");
|
|
19768
19782
|
}
|
|
@@ -19791,9 +19805,9 @@ var NodeUserAuthorization = class {
|
|
|
19791
19805
|
}
|
|
19792
19806
|
const spaceAbilities = {};
|
|
19793
19807
|
for (const { spaceId, resources } of resourcesBySpace.values()) {
|
|
19794
|
-
spaceAbilities[spaceId] = (0,
|
|
19808
|
+
spaceAbilities[spaceId] = (0, import_sdk_core5.resourceCapabilitiesToAbilitiesMap)(resources);
|
|
19795
19809
|
}
|
|
19796
|
-
const abilities = spaceAbilities[options.spaceId] ?? (0,
|
|
19810
|
+
const abilities = spaceAbilities[options.spaceId] ?? (0, import_sdk_core5.resourceCapabilitiesToAbilitiesMap)([]);
|
|
19797
19811
|
const prepared = this.wasm.prepareSession({
|
|
19798
19812
|
abilities,
|
|
19799
19813
|
spaceAbilities,
|
|
@@ -19864,8 +19878,9 @@ var NodeUserAuthorization = class {
|
|
|
19864
19878
|
* @param options - Optional per-call SIWE overrides for this sign-in only
|
|
19865
19879
|
*/
|
|
19866
19880
|
async signIn(options) {
|
|
19881
|
+
refuseCaveated(this.getCapabilityRequest()?.manifests);
|
|
19867
19882
|
const generation = this.sessionGeneration;
|
|
19868
|
-
const address = (0,
|
|
19883
|
+
const address = (0, import_sdk_core5.canonicalizeAddress)(await this.signer.getAddress());
|
|
19869
19884
|
const chainId = await this.signer.getChainId();
|
|
19870
19885
|
this.assertSignInCurrent(generation);
|
|
19871
19886
|
this._address = address;
|
|
@@ -19917,7 +19932,7 @@ var NodeUserAuthorization = class {
|
|
|
19917
19932
|
siwe: prepared.siwe,
|
|
19918
19933
|
signature: signature2
|
|
19919
19934
|
};
|
|
19920
|
-
const spacesMetadata = this.enablePublicSpace ? { public: (0,
|
|
19935
|
+
const spacesMetadata = this.enablePublicSpace ? { public: (0, import_sdk_core5.makePkhSpaceId)(address, chainId, "public") } : void 0;
|
|
19921
19936
|
const tinyCloudSession = {
|
|
19922
19937
|
address,
|
|
19923
19938
|
chainId,
|
|
@@ -19987,7 +20002,7 @@ var NodeUserAuthorization = class {
|
|
|
19987
20002
|
*/
|
|
19988
20003
|
async signMessage(message, purpose) {
|
|
19989
20004
|
if (!this._address) {
|
|
19990
|
-
this._address = (0,
|
|
20005
|
+
this._address = (0, import_sdk_core5.canonicalizeAddress)(await this.signer.getAddress());
|
|
19991
20006
|
}
|
|
19992
20007
|
if (!this._chainId) {
|
|
19993
20008
|
this._chainId = await this.signer.getChainId();
|
|
@@ -20015,7 +20030,8 @@ var NodeUserAuthorization = class {
|
|
|
20015
20030
|
* ```
|
|
20016
20031
|
*/
|
|
20017
20032
|
async prepareSessionForSigning() {
|
|
20018
|
-
|
|
20033
|
+
refuseCaveated(this.getCapabilityRequest()?.manifests);
|
|
20034
|
+
const address = (0, import_sdk_core5.canonicalizeAddress)(await this.signer.getAddress());
|
|
20019
20035
|
const chainId = await this.signer.getChainId();
|
|
20020
20036
|
const keyId = `session-${Date.now()}`;
|
|
20021
20037
|
this.sessionManager.renameSessionKeyId(this.activeSessionKeyId, keyId);
|
|
@@ -20066,7 +20082,7 @@ var NodeUserAuthorization = class {
|
|
|
20066
20082
|
...prepared,
|
|
20067
20083
|
signature: signature2
|
|
20068
20084
|
});
|
|
20069
|
-
const address = (0,
|
|
20085
|
+
const address = (0, import_sdk_core5.canonicalizeAddress)(await this.signer.getAddress());
|
|
20070
20086
|
const chainId = await this.signer.getChainId();
|
|
20071
20087
|
await this.resolveTinyCloudHostsForSignIn(address, chainId);
|
|
20072
20088
|
const clientSession = {
|
|
@@ -20077,7 +20093,7 @@ var NodeUserAuthorization = class {
|
|
|
20077
20093
|
siwe: prepared.siwe,
|
|
20078
20094
|
signature: signature2
|
|
20079
20095
|
};
|
|
20080
|
-
const spacesMetadata = this.enablePublicSpace ? { public: (0,
|
|
20096
|
+
const spacesMetadata = this.enablePublicSpace ? { public: (0, import_sdk_core5.makePkhSpaceId)(address, chainId, "public") } : void 0;
|
|
20081
20097
|
const tinyCloudSession = {
|
|
20082
20098
|
address,
|
|
20083
20099
|
chainId,
|
|
@@ -20146,6 +20162,7 @@ var NodeUserAuthorization = class {
|
|
|
20146
20162
|
* @param options Optional overrides for the OpenKey request.
|
|
20147
20163
|
*/
|
|
20148
20164
|
async signInWithOpenKey(authorizeFn, options) {
|
|
20165
|
+
refuseCaveated(this.getCapabilityRequest()?.manifests);
|
|
20149
20166
|
if (options?.host !== void 0) {
|
|
20150
20167
|
const overrideHost = options.host.trim();
|
|
20151
20168
|
if (!overrideHost) {
|
|
@@ -20153,7 +20170,7 @@ var NodeUserAuthorization = class {
|
|
|
20153
20170
|
}
|
|
20154
20171
|
this.tinycloudHosts = [overrideHost];
|
|
20155
20172
|
}
|
|
20156
|
-
const signingAddress = (0,
|
|
20173
|
+
const signingAddress = (0, import_sdk_core5.canonicalizeAddress)(await this.signer.getAddress());
|
|
20157
20174
|
const signingChainId = await this.signer.getChainId();
|
|
20158
20175
|
await this.resolveTinyCloudHostsForSignIn(signingAddress, signingChainId);
|
|
20159
20176
|
const { prepared, keyId, jwk } = await this.prepareSessionForSigning();
|
|
@@ -20284,8 +20301,8 @@ var NodeUserAuthorization = class {
|
|
|
20284
20301
|
"signInWithOpenKeyResult requires prepared.siwe (the SDK-generated SIWE the sign-in was proposed with)"
|
|
20285
20302
|
);
|
|
20286
20303
|
}
|
|
20287
|
-
const expectedAddress = (0,
|
|
20288
|
-
if ((0,
|
|
20304
|
+
const expectedAddress = (0, import_sdk_core5.canonicalizeAddress)(await this.signer.getAddress());
|
|
20305
|
+
if ((0, import_sdk_core5.canonicalizeAddress)(result.address) !== expectedAddress) {
|
|
20289
20306
|
throw new Error(
|
|
20290
20307
|
`OpenKey returned signature from ${result.address} but expected ${expectedAddress}`
|
|
20291
20308
|
);
|
|
@@ -20310,15 +20327,15 @@ var NodeUserAuthorization = class {
|
|
|
20310
20327
|
`OpenKey signature verification failed${type ? `: ${type}` : ""}${details}`
|
|
20311
20328
|
);
|
|
20312
20329
|
}
|
|
20313
|
-
if ((0,
|
|
20330
|
+
if ((0, import_sdk_core5.canonicalizeAddress)(parsedSignedSiwe.address) !== expectedAddress) {
|
|
20314
20331
|
throw new Error(
|
|
20315
20332
|
`OpenKey signedMessage.address (${parsedSignedSiwe.address}) does not match local signer address (${expectedAddress})`
|
|
20316
20333
|
);
|
|
20317
20334
|
}
|
|
20318
20335
|
const originalHasRecap = /(?:^|\n)-\s+urn:recap:/i.test(prepared.siwe);
|
|
20319
|
-
const originalFields = (0,
|
|
20320
|
-
const signedFields = (0,
|
|
20321
|
-
const changedFields = (0,
|
|
20336
|
+
const originalFields = (0, import_sdk_core5.extractImmutableSiweFields)(prepared.siwe);
|
|
20337
|
+
const signedFields = (0, import_sdk_core5.extractImmutableSiweFields)(result.signedMessage);
|
|
20338
|
+
const changedFields = (0, import_sdk_core5.diffImmutableSiweFields)(originalFields, signedFields, {
|
|
20322
20339
|
originalHasRecap
|
|
20323
20340
|
});
|
|
20324
20341
|
if (changedFields.length > 0) {
|
|
@@ -20329,20 +20346,20 @@ var NodeUserAuthorization = class {
|
|
|
20329
20346
|
let originalCaps;
|
|
20330
20347
|
let signedCaps;
|
|
20331
20348
|
try {
|
|
20332
|
-
originalCaps = (0,
|
|
20349
|
+
originalCaps = (0, import_sdk_core5.extractRecapAttenuations)(prepared.siwe);
|
|
20333
20350
|
} catch (err2) {
|
|
20334
20351
|
throw new Error(
|
|
20335
20352
|
`Failed to decode prepared SIWE recap: ${err2.message}`
|
|
20336
20353
|
);
|
|
20337
20354
|
}
|
|
20338
20355
|
try {
|
|
20339
|
-
signedCaps = (0,
|
|
20356
|
+
signedCaps = (0, import_sdk_core5.extractRecapAttenuations)(result.signedMessage);
|
|
20340
20357
|
} catch (err2) {
|
|
20341
20358
|
throw new Error(
|
|
20342
20359
|
`Failed to decode OpenKey signedMessage recap: ${err2.message}`
|
|
20343
20360
|
);
|
|
20344
20361
|
}
|
|
20345
|
-
const unauthorized = (0,
|
|
20362
|
+
const unauthorized = (0, import_sdk_core5.unauthorizedRecapCapabilities)(signedCaps, originalCaps);
|
|
20346
20363
|
if (unauthorized.length > 0) {
|
|
20347
20364
|
const previewLimit = 5;
|
|
20348
20365
|
const preview = unauthorized.slice(0, previewLimit).map((u) => `${u.resource}::${u.action}`).join(", ");
|
|
@@ -20359,7 +20376,7 @@ var NodeUserAuthorization = class {
|
|
|
20359
20376
|
const grantedPairs = /* @__PURE__ */ new Set();
|
|
20360
20377
|
const grantedFourPartIndex = /* @__PURE__ */ new Map();
|
|
20361
20378
|
for (const [resource, actions] of Object.entries(signedCaps)) {
|
|
20362
|
-
const { space, path } = (0,
|
|
20379
|
+
const { space, path } = (0, import_sdk_core5.parseCanonicalRecapResource)(resource);
|
|
20363
20380
|
for (const action of Object.keys(actions)) {
|
|
20364
20381
|
grantedPairs.add(`${resource}\0${action}`);
|
|
20365
20382
|
const slashIdx = action.indexOf("/");
|
|
@@ -20595,10 +20612,10 @@ var NodeUserAuthorization = class {
|
|
|
20595
20612
|
};
|
|
20596
20613
|
|
|
20597
20614
|
// src/account/AccountService.ts
|
|
20598
|
-
var
|
|
20615
|
+
var import_sdk_core6 = require("@tinycloud/sdk-core");
|
|
20599
20616
|
|
|
20600
20617
|
// src/DelegatedAccess.ts
|
|
20601
|
-
var
|
|
20618
|
+
var import_sdk_core7 = require("@tinycloud/sdk-core");
|
|
20602
20619
|
var DelegatedAccess = class {
|
|
20603
20620
|
/**
|
|
20604
20621
|
* @param lifetime - Optional owner of this access: its `fetch` is used for
|
|
@@ -20620,16 +20637,16 @@ var DelegatedAccess = class {
|
|
|
20620
20637
|
});
|
|
20621
20638
|
this._serviceContext = lifetime ? lifetime.track(context) : context;
|
|
20622
20639
|
const prefix = this._delegation.path.replace(/\/$/, "");
|
|
20623
|
-
this._kv = new
|
|
20640
|
+
this._kv = new import_sdk_core7.KVService({ prefix });
|
|
20624
20641
|
this._kv.initialize(this._serviceContext);
|
|
20625
20642
|
this._serviceContext.registerService("kv", this._kv);
|
|
20626
|
-
this._sql = new
|
|
20643
|
+
this._sql = new import_sdk_core7.SQLService({});
|
|
20627
20644
|
this._sql.initialize(this._serviceContext);
|
|
20628
20645
|
this._serviceContext.registerService("sql", this._sql);
|
|
20629
|
-
this._duckdb = new
|
|
20646
|
+
this._duckdb = new import_sdk_core7.DuckDbService({});
|
|
20630
20647
|
this._duckdb.initialize(this._serviceContext);
|
|
20631
20648
|
this._serviceContext.registerService("duckdb", this._duckdb);
|
|
20632
|
-
this._hooks = new
|
|
20649
|
+
this._hooks = new import_sdk_core7.HooksService({});
|
|
20633
20650
|
this._hooks.initialize(this._serviceContext);
|
|
20634
20651
|
this._serviceContext.registerService("hooks", this._hooks);
|
|
20635
20652
|
const serviceSession = {
|
|
@@ -20779,7 +20796,7 @@ function createWasmKeyProvider(sessionManager) {
|
|
|
20779
20796
|
}
|
|
20780
20797
|
|
|
20781
20798
|
// src/delegateToHelpers.ts
|
|
20782
|
-
var
|
|
20799
|
+
var import_sdk_core8 = require("@tinycloud/sdk-core");
|
|
20783
20800
|
function legacyParamsToPermissionEntries(actions, path, spaceIdOverride) {
|
|
20784
20801
|
const byService = /* @__PURE__ */ new Map();
|
|
20785
20802
|
for (const a of actions) {
|
|
@@ -20810,7 +20827,7 @@ function legacyParamsToPermissionEntries(actions, path, spaceIdOverride) {
|
|
|
20810
20827
|
}
|
|
20811
20828
|
return entries;
|
|
20812
20829
|
}
|
|
20813
|
-
var DEFAULT_DELEGATION_EXPIRY_MS =
|
|
20830
|
+
var DEFAULT_DELEGATION_EXPIRY_MS = import_sdk_core8.EXPIRY.SESSION_MS;
|
|
20814
20831
|
function resolveExpiryMs(expiry) {
|
|
20815
20832
|
if (expiry === void 0) {
|
|
20816
20833
|
return DEFAULT_DELEGATION_EXPIRY_MS;
|
|
@@ -20823,10 +20840,10 @@ function resolveExpiryMs(expiry) {
|
|
|
20823
20840
|
}
|
|
20824
20841
|
return expiry;
|
|
20825
20842
|
}
|
|
20826
|
-
return (0,
|
|
20843
|
+
return (0, import_sdk_core8.parseExpiry)(expiry);
|
|
20827
20844
|
}
|
|
20828
20845
|
function extractSiweExpiration(siwe) {
|
|
20829
|
-
const parsed = new
|
|
20846
|
+
const parsed = new import_sdk_core8.SiweMessage(siwe);
|
|
20830
20847
|
if (parsed.expirationTime === void 0 || parsed.expirationTime === null) {
|
|
20831
20848
|
return void 0;
|
|
20832
20849
|
}
|
|
@@ -20840,7 +20857,7 @@ function extractSiweExpiration(siwe) {
|
|
|
20840
20857
|
}
|
|
20841
20858
|
|
|
20842
20859
|
// src/NodeSecretsService.ts
|
|
20843
|
-
var
|
|
20860
|
+
var import_sdk_core9 = require("@tinycloud/sdk-core");
|
|
20844
20861
|
var SECRETS_SPACE = "secrets";
|
|
20845
20862
|
function ok() {
|
|
20846
20863
|
return { ok: true, data: void 0 };
|
|
@@ -20873,7 +20890,7 @@ function secretActionName(action) {
|
|
|
20873
20890
|
}
|
|
20874
20891
|
function secretPermissionEntries(name, options, action, space, encryptionNetworkId) {
|
|
20875
20892
|
const entries = [];
|
|
20876
|
-
const path = action === "list" ? (0,
|
|
20893
|
+
const path = action === "list" ? (0, import_sdk_core9.resolveSecretListPrefix)(options) : (0, import_sdk_core9.resolveSecretPath)(name, options).permissionPaths.vault;
|
|
20877
20894
|
entries.push({
|
|
20878
20895
|
service: "tinycloud.kv",
|
|
20879
20896
|
space,
|
|
@@ -20970,7 +20987,7 @@ var NodeSecretsService = class {
|
|
|
20970
20987
|
);
|
|
20971
20988
|
} catch (error) {
|
|
20972
20989
|
return secretsError(
|
|
20973
|
-
|
|
20990
|
+
import_sdk_core9.ErrorCodes.INVALID_INPUT,
|
|
20974
20991
|
error instanceof Error ? error.message : String(error),
|
|
20975
20992
|
error instanceof Error ? error : void 0
|
|
20976
20993
|
);
|
|
@@ -20989,7 +21006,7 @@ var NodeSecretsService = class {
|
|
|
20989
21006
|
}
|
|
20990
21007
|
if (!this.config.canEscalate()) {
|
|
20991
21008
|
return secretsError(
|
|
20992
|
-
|
|
21009
|
+
import_sdk_core9.ErrorCodes.PERMISSION_DENIED,
|
|
20993
21010
|
`Cannot autosign ${displayActionUrn(action)} for ${target}; TinyCloudNode needs wallet mode with a signer or privateKey.`
|
|
20994
21011
|
);
|
|
20995
21012
|
}
|
|
@@ -21002,7 +21019,7 @@ var NodeSecretsService = class {
|
|
|
21002
21019
|
}
|
|
21003
21020
|
escalationError(action, target, error) {
|
|
21004
21021
|
return secretsError(
|
|
21005
|
-
|
|
21022
|
+
import_sdk_core9.ErrorCodes.PERMISSION_DENIED,
|
|
21006
21023
|
error instanceof Error ? error.message : `Autosign escalation for ${displayActionUrn(action)} on ${target} failed.`,
|
|
21007
21024
|
error instanceof Error ? error : void 0
|
|
21008
21025
|
);
|
|
@@ -21022,10 +21039,10 @@ var NodeSecretsService = class {
|
|
|
21022
21039
|
return false;
|
|
21023
21040
|
}
|
|
21024
21041
|
const manifests = Array.isArray(manifest) ? manifest : [manifest];
|
|
21025
|
-
const requestedEntries = (0,
|
|
21042
|
+
const requestedEntries = (0, import_sdk_core9.expandPermissionEntries)(permissionEntries);
|
|
21026
21043
|
return requestedEntries.every(
|
|
21027
21044
|
(entry) => manifests.some((candidate) => {
|
|
21028
|
-
const resolved = (0,
|
|
21045
|
+
const resolved = (0, import_sdk_core9.resolveManifest)(candidate);
|
|
21029
21046
|
return resolved.resources.some(
|
|
21030
21047
|
(resource) => resource.service === entry.service && spaceMatches(
|
|
21031
21048
|
resource.space,
|
|
@@ -21041,8 +21058,8 @@ var NodeSecretsService = class {
|
|
|
21041
21058
|
// src/TinyCloudNode.ts
|
|
21042
21059
|
var DEFAULT_HOST = "https://node.tinycloud.xyz";
|
|
21043
21060
|
var DEFAULT_ENCRYPTION_NETWORK_NAME = "default";
|
|
21044
|
-
var NETWORK_CREATE_ACTION2 =
|
|
21045
|
-
var DECRYPT_ACTION2 =
|
|
21061
|
+
var NETWORK_CREATE_ACTION2 = import_sdk_core10.ENCRYPTION.NETWORK_CREATE;
|
|
21062
|
+
var DECRYPT_ACTION2 = import_sdk_core10.ENCRYPTION.DECRYPT;
|
|
21046
21063
|
var BOOTSTRAP_COMPLETION_MARKER_KEY = "system/bootstrap/complete";
|
|
21047
21064
|
var BOOTSTRAP_COMPLETION_MARKER_VERSION = 1;
|
|
21048
21065
|
var ACCEPTED_MARKER_VERSIONS = [BOOTSTRAP_COMPLETION_MARKER_VERSION];
|
|
@@ -21051,24 +21068,24 @@ function isSecretPayload(value) {
|
|
|
21051
21068
|
return typeof value === "object" && value !== null && "value" in value && typeof value.value === "string" && "createdAt" in value && typeof value.createdAt === "string" && "updatedAt" in value && typeof value.updatedAt === "string";
|
|
21052
21069
|
}
|
|
21053
21070
|
var ROOT_DELEGATION_ACTIONS = [
|
|
21054
|
-
|
|
21055
|
-
|
|
21056
|
-
|
|
21057
|
-
|
|
21058
|
-
|
|
21059
|
-
|
|
21060
|
-
|
|
21061
|
-
|
|
21062
|
-
|
|
21063
|
-
|
|
21064
|
-
|
|
21065
|
-
|
|
21066
|
-
|
|
21067
|
-
|
|
21068
|
-
|
|
21069
|
-
|
|
21071
|
+
import_sdk_core10.KV.PUT,
|
|
21072
|
+
import_sdk_core10.KV.GET,
|
|
21073
|
+
import_sdk_core10.KV.DEL,
|
|
21074
|
+
import_sdk_core10.KV.LIST,
|
|
21075
|
+
import_sdk_core10.KV.METADATA,
|
|
21076
|
+
import_sdk_core10.SQL.READ,
|
|
21077
|
+
import_sdk_core10.SQL.WRITE,
|
|
21078
|
+
import_sdk_core10.SQL.ADMIN,
|
|
21079
|
+
import_sdk_core10.SQL.ALL,
|
|
21080
|
+
import_sdk_core10.DUCKDB.READ,
|
|
21081
|
+
import_sdk_core10.DUCKDB.WRITE,
|
|
21082
|
+
import_sdk_core10.DUCKDB.ADMIN,
|
|
21083
|
+
import_sdk_core10.DUCKDB.DESCRIBE,
|
|
21084
|
+
import_sdk_core10.DUCKDB.EXPORT,
|
|
21085
|
+
import_sdk_core10.DUCKDB.IMPORT,
|
|
21086
|
+
import_sdk_core10.DUCKDB.ALL
|
|
21070
21087
|
];
|
|
21071
|
-
var DEFAULT_SESSION_EXPIRATION_MS =
|
|
21088
|
+
var DEFAULT_SESSION_EXPIRATION_MS = import_sdk_core10.EXPIRY.SESSION_MS;
|
|
21072
21089
|
function unifiedRootAttenuation(capabilities) {
|
|
21073
21090
|
const attenuation = {};
|
|
21074
21091
|
for (const capability of capabilities) {
|
|
@@ -21119,7 +21136,7 @@ function spaceOwnerKey(spaceId) {
|
|
|
21119
21136
|
}
|
|
21120
21137
|
function didPrincipalMatches2(actual, expected) {
|
|
21121
21138
|
try {
|
|
21122
|
-
return (0,
|
|
21139
|
+
return (0, import_sdk_core10.principalDidEquals)(actual, expected);
|
|
21123
21140
|
} catch {
|
|
21124
21141
|
return actual === expected;
|
|
21125
21142
|
}
|
|
@@ -21340,6 +21357,7 @@ function ownerDelegationPermissions(params) {
|
|
|
21340
21357
|
if (!Array.isArray(params.permissions)) {
|
|
21341
21358
|
throw new Error("Owner delegation permissions are invalid");
|
|
21342
21359
|
}
|
|
21360
|
+
refuseCaveated(params.permissions);
|
|
21343
21361
|
permissions.push(...params.permissions.map((permission) => ({
|
|
21344
21362
|
service: permission.service,
|
|
21345
21363
|
path: permission.path,
|
|
@@ -21356,7 +21374,7 @@ function ownerDelegationPermissions(params) {
|
|
|
21356
21374
|
}
|
|
21357
21375
|
const slash = action.indexOf("/");
|
|
21358
21376
|
const service = slash === -1 ? "" : action.slice(0, slash);
|
|
21359
|
-
if (
|
|
21377
|
+
if (import_sdk_core10.SERVICE_LONG_TO_SHORT[service] === void 0) {
|
|
21360
21378
|
throw new Error("Owner delegation capabilities are unsupported");
|
|
21361
21379
|
}
|
|
21362
21380
|
const actions = byService.get(service) ?? [];
|
|
@@ -21372,7 +21390,7 @@ function ownerDelegationPermissions(params) {
|
|
|
21372
21390
|
}
|
|
21373
21391
|
const resources = /* @__PURE__ */ new Set();
|
|
21374
21392
|
for (const permission of permissions) {
|
|
21375
|
-
if (typeof permission.service !== "string" ||
|
|
21393
|
+
if (typeof permission.service !== "string" || import_sdk_core10.SERVICE_LONG_TO_SHORT[permission.service] === void 0 || typeof permission.path !== "string" || permission.path.length === 0 || permission.path.trim() !== permission.path || /[\u0000-\u001f\u007f\\*]/.test(permission.path) || !Array.isArray(permission.actions) || permission.actions.length === 0 || permission.actions.length > 32) {
|
|
21376
21394
|
throw new Error("Owner delegation requires bounded capabilities");
|
|
21377
21395
|
}
|
|
21378
21396
|
const resourceKey = `${permission.service}\0${permission.path}`;
|
|
@@ -21387,9 +21405,9 @@ function ownerDelegationPermissions(params) {
|
|
|
21387
21405
|
}
|
|
21388
21406
|
actions.add(action);
|
|
21389
21407
|
}
|
|
21390
|
-
if (permission.service ===
|
|
21408
|
+
if (permission.service === import_sdk_core10.ENCRYPTION_PERMISSION_SERVICE) {
|
|
21391
21409
|
try {
|
|
21392
|
-
(0,
|
|
21410
|
+
(0, import_sdk_core10.parseNetworkId)(permission.path);
|
|
21393
21411
|
} catch {
|
|
21394
21412
|
throw new Error("Owner delegation encryption permission requires a canonical network URN");
|
|
21395
21413
|
}
|
|
@@ -21401,11 +21419,11 @@ function ownerPermissionsToAbilities(permissions) {
|
|
|
21401
21419
|
const abilities = {};
|
|
21402
21420
|
const rawAbilities = {};
|
|
21403
21421
|
for (const permission of permissions) {
|
|
21404
|
-
if (permission.service ===
|
|
21422
|
+
if (permission.service === import_sdk_core10.ENCRYPTION_PERMISSION_SERVICE) {
|
|
21405
21423
|
rawAbilities[permission.path] = [...permission.actions];
|
|
21406
21424
|
continue;
|
|
21407
21425
|
}
|
|
21408
|
-
const shortService =
|
|
21426
|
+
const shortService = import_sdk_core10.SERVICE_LONG_TO_SHORT[permission.service];
|
|
21409
21427
|
abilities[shortService] ?? (abilities[shortService] = {});
|
|
21410
21428
|
abilities[shortService][permission.path] = [...permission.actions];
|
|
21411
21429
|
}
|
|
@@ -21584,7 +21602,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
21584
21602
|
}
|
|
21585
21603
|
const stamp = await establishReplicaSessionStamp2(
|
|
21586
21604
|
replication.storage,
|
|
21587
|
-
(0,
|
|
21605
|
+
(0, import_sdk_core10.pkhDid)(session.address, session.chainId),
|
|
21588
21606
|
anchor
|
|
21589
21607
|
);
|
|
21590
21608
|
if (epoch !== this.sessionEpoch || attempt !== this.latestSessionAttempt) return void 0;
|
|
@@ -21663,7 +21681,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
21663
21681
|
* and remembers whose storage is full so sign-in and listing skip their
|
|
21664
21682
|
* best-effort writes. Lives as long as this instance, across sign-ins.
|
|
21665
21683
|
*/
|
|
21666
|
-
this.storageFull = new
|
|
21684
|
+
this.storageFull = new import_sdk_core10.StorageFullMonitor((spaceId) => spaceOwnerKey(spaceId) ?? spaceId);
|
|
21667
21685
|
this.invokeWithRuntimePermissions = (session, service, path, action, facts) => {
|
|
21668
21686
|
const operation = {
|
|
21669
21687
|
spaceId: session.spaceId,
|
|
@@ -21714,7 +21732,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
21714
21732
|
if (!granted?.caveats?.length) {
|
|
21715
21733
|
return entry;
|
|
21716
21734
|
}
|
|
21717
|
-
if (entry.caveats !== void 0 && !(0,
|
|
21735
|
+
if (entry.caveats !== void 0 && !(0, import_sdk_core10.recapCaveatsEqual)(entry.caveats, granted.caveats)) {
|
|
21718
21736
|
throw new Error("Invocation caveats do not match signed ReCap authority.");
|
|
21719
21737
|
}
|
|
21720
21738
|
return { ...entry, caveats: cloneRecapCaveats(granted.caveats) };
|
|
@@ -21727,7 +21745,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
21727
21745
|
...config,
|
|
21728
21746
|
host: config.host ?? DEFAULT_HOST,
|
|
21729
21747
|
// One store for every authorization this client creates.
|
|
21730
|
-
registrySequenceStore: config.registrySequenceStore ?? (0,
|
|
21748
|
+
registrySequenceStore: config.registrySequenceStore ?? (0, import_sdk_core10.createInMemoryRegistrySequenceStore)()
|
|
21731
21749
|
};
|
|
21732
21750
|
if (this.config.replication?.enabled) {
|
|
21733
21751
|
const runtime = getNodeReplicationLoaders().runtime().then(({ ReplicationRuntime: ReplicationRuntime2 }) => {
|
|
@@ -21796,11 +21814,11 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
21796
21814
|
this.sessionKeyJwk = sessionKey.jwk;
|
|
21797
21815
|
this._requestLog = config.requestLog === true ? new import_requestLog2.RequestLog() : void 0;
|
|
21798
21816
|
this._serviceGraph = this.createServiceGraphLifetime();
|
|
21799
|
-
this._capabilityRegistry = new
|
|
21817
|
+
this._capabilityRegistry = new import_sdk_core10.CapabilityKeyRegistry();
|
|
21800
21818
|
this._keyProvider = new WasmKeyProvider({
|
|
21801
21819
|
sessionManager: this.sessionManager
|
|
21802
21820
|
});
|
|
21803
|
-
this.notificationHandler = config.notificationHandler ?? new
|
|
21821
|
+
this.notificationHandler = config.notificationHandler ?? new import_sdk_core10.SilentNotificationHandler();
|
|
21804
21822
|
this._sharingService = this.createReceiveOnlySharing();
|
|
21805
21823
|
if (config.signer) {
|
|
21806
21824
|
this.signer = config.signer;
|
|
@@ -21874,13 +21892,13 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
21874
21892
|
async readStorageStatus(options) {
|
|
21875
21893
|
const session = this._serviceContext?.session;
|
|
21876
21894
|
if (!this._serviceContext || !session) {
|
|
21877
|
-
return (0,
|
|
21895
|
+
return (0, import_sdk_core10.err)((0, import_sdk_core10.serviceError)(import_sdk_core10.ErrorCodes.AUTH_REQUIRED, "Not signed in. Call signIn() first.", "storage"));
|
|
21878
21896
|
}
|
|
21879
21897
|
const spaceId = options?.space === void 0 ? session.spaceId : options.space.startsWith("tinycloud:") ? options.space : this.ownedSpaceId(options.space);
|
|
21880
21898
|
const action = "tinycloud.space/info";
|
|
21881
21899
|
if (!this.findGrantForOperation({ spaceId, service: "space", path: "", action })) {
|
|
21882
|
-
return (0,
|
|
21883
|
-
|
|
21900
|
+
return (0, import_sdk_core10.err)((0, import_sdk_core10.serviceError)(
|
|
21901
|
+
import_sdk_core10.ErrorCodes.PERMISSION_DENIED,
|
|
21884
21902
|
`Reading storage status needs ${action} on ${spaceId}, which this session was not granted.`,
|
|
21885
21903
|
"storage",
|
|
21886
21904
|
{ meta: { requiredAction: action, resource: spaceId } }
|
|
@@ -21896,8 +21914,8 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
21896
21914
|
const text = await response.text();
|
|
21897
21915
|
if (!response.ok) {
|
|
21898
21916
|
const unauthorized = response.status === 401 || response.status === 403;
|
|
21899
|
-
return (0,
|
|
21900
|
-
unauthorized ?
|
|
21917
|
+
return (0, import_sdk_core10.err)((0, import_sdk_core10.serviceError)(
|
|
21918
|
+
unauthorized ? import_sdk_core10.ErrorCodes.AUTH_UNAUTHORIZED : import_sdk_core10.ErrorCodes.NETWORK_ERROR,
|
|
21901
21919
|
`Failed to read storage status: ${response.status} - ${text.slice(0, 300)}`,
|
|
21902
21920
|
"storage",
|
|
21903
21921
|
{ meta: { status: response.status, ...unauthorized ? { requiredAction: action, resource: spaceId } : {} } }
|
|
@@ -21909,10 +21927,10 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
21909
21927
|
} catch {
|
|
21910
21928
|
body = void 0;
|
|
21911
21929
|
}
|
|
21912
|
-
const status = (0,
|
|
21930
|
+
const status = (0, import_sdk_core10.parseStorageStatus)(body);
|
|
21913
21931
|
if (!status) {
|
|
21914
|
-
return (0,
|
|
21915
|
-
|
|
21932
|
+
return (0, import_sdk_core10.err)((0, import_sdk_core10.serviceError)(
|
|
21933
|
+
import_sdk_core10.ErrorCodes.STORAGE_STATUS_UNAVAILABLE,
|
|
21916
21934
|
"This TinyCloud node does not report storage usage yet.",
|
|
21917
21935
|
"storage",
|
|
21918
21936
|
{ meta: { status: response.status } }
|
|
@@ -21922,10 +21940,10 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
21922
21940
|
this.storageFull.clearFor(spaceId);
|
|
21923
21941
|
if (spaceOwnerKey(spaceId) === this.currentStorageOwner()) this.storageFull.clearFor(void 0);
|
|
21924
21942
|
}
|
|
21925
|
-
return (0,
|
|
21943
|
+
return (0, import_sdk_core10.ok)(status);
|
|
21926
21944
|
} catch (error) {
|
|
21927
|
-
return (0,
|
|
21928
|
-
|
|
21945
|
+
return (0, import_sdk_core10.err)((0, import_sdk_core10.serviceError)(
|
|
21946
|
+
import_sdk_core10.ErrorCodes.NETWORK_ERROR,
|
|
21929
21947
|
`Failed to read storage status: ${error instanceof Error ? error.message : String(error)}`,
|
|
21930
21948
|
"storage",
|
|
21931
21949
|
{ cause: error instanceof Error ? error : void 0 }
|
|
@@ -21950,7 +21968,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
21950
21968
|
*/
|
|
21951
21969
|
createReceiveOnlySharing() {
|
|
21952
21970
|
const receiveOnlyGraph = this._serviceGraph;
|
|
21953
|
-
return new
|
|
21971
|
+
return new import_sdk_core10.SharingService({
|
|
21954
21972
|
hosts: [this.config.host],
|
|
21955
21973
|
// session: undefined - not needed for receive()
|
|
21956
21974
|
invoke: receiveOnlyGraph.invoke,
|
|
@@ -21965,7 +21983,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
21965
21983
|
},
|
|
21966
21984
|
createKVService: (config) => {
|
|
21967
21985
|
const prefix = config.pathPrefix?.replace(/\/$/, "");
|
|
21968
|
-
const kvService = new
|
|
21986
|
+
const kvService = new import_sdk_core10.KVService({ prefix });
|
|
21969
21987
|
const kvContext = receiveOnlyGraph.track(createServiceContext({
|
|
21970
21988
|
requestSink: receiveOnlyGraph.requestSink,
|
|
21971
21989
|
invoke: config.invoke,
|
|
@@ -22011,7 +22029,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
22011
22029
|
nonce: config.nonce,
|
|
22012
22030
|
siweConfig: config.siweConfig,
|
|
22013
22031
|
manifest: useBootstrapSignInRequest ? void 0 : config.manifest,
|
|
22014
|
-
capabilityRequest: useBootstrapSignInRequest ? config.includeAccountRegistryPermissions === false ?
|
|
22032
|
+
capabilityRequest: useBootstrapSignInRequest ? config.includeAccountRegistryPermissions === false ? import_sdk_core10.BOOTSTRAP_DEFAULT_ONLY_SESSION_REQUEST : import_sdk_core10.BOOTSTRAP_SESSION_REQUESTS.default : config.capabilityRequest,
|
|
22015
22033
|
includeAccountRegistryPermissions: useBootstrapSignInRequest ? false : config.includeAccountRegistryPermissions,
|
|
22016
22034
|
// Sign-in needs only the entry inputs (prefixes + secrets opt-in);
|
|
22017
22035
|
// storage and scheduling never leave TinyCloudNode.
|
|
@@ -22021,7 +22039,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
22021
22039
|
allowSecrets: config.replication.allowSecrets === true
|
|
22022
22040
|
} : void 0
|
|
22023
22041
|
});
|
|
22024
|
-
this.tc = new
|
|
22042
|
+
this.tc = new import_sdk_core10.TinyCloud(this.auth, {
|
|
22025
22043
|
invokeAny: this.invokeAnyWithRuntimePermissions,
|
|
22026
22044
|
telemetry: config.telemetry,
|
|
22027
22045
|
retryPolicy: config.retryPolicy
|
|
@@ -22111,7 +22129,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
22111
22129
|
/** Publish the active owner Node as a session-signed registry record. */
|
|
22112
22130
|
async publishActiveNodeLocation(registryUrl, fetchFn = globalThis.fetch.bind(globalThis)) {
|
|
22113
22131
|
const node = await this.activeNodeIdentity();
|
|
22114
|
-
return (0,
|
|
22132
|
+
return (0, import_sdk_core10.publishLocationRecord)({
|
|
22115
22133
|
registryUrl,
|
|
22116
22134
|
subject: this.credentialHolderDid,
|
|
22117
22135
|
nodeOrigin: node.origin,
|
|
@@ -22128,7 +22146,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
22128
22146
|
*/
|
|
22129
22147
|
get did() {
|
|
22130
22148
|
if (this._address) {
|
|
22131
|
-
return (0,
|
|
22149
|
+
return (0, import_sdk_core10.pkhDid)(this._address, this._chainId);
|
|
22132
22150
|
}
|
|
22133
22151
|
return this.sessionManager.getDID(this.sessionKeyId);
|
|
22134
22152
|
}
|
|
@@ -22165,7 +22183,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
22165
22183
|
/** Normalize signed capabilities without collapsing nested encryption into raw authority. */
|
|
22166
22184
|
projectSignedRecapCapabilities(siwe) {
|
|
22167
22185
|
const projected = this.parseRecapWithCaveats(siwe).map((entry) => {
|
|
22168
|
-
const normalized = (0,
|
|
22186
|
+
const normalized = (0, import_sdk_core10.parseRecapCapabilities)(() => [entry], siwe)[0];
|
|
22169
22187
|
if (normalized.service !== "tinycloud.encryption") return normalized;
|
|
22170
22188
|
if (!this.isEncryptionNetworkOperation("encryption", entry.path, entry.space)) {
|
|
22171
22189
|
return { ...normalized, space: entry.space };
|
|
@@ -22209,14 +22227,14 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
22209
22227
|
if (!this._address) {
|
|
22210
22228
|
return void 0;
|
|
22211
22229
|
}
|
|
22212
|
-
return this.wasmBindings.makeSpaceId(this._address, this._chainId,
|
|
22230
|
+
return this.wasmBindings.makeSpaceId(this._address, this._chainId, import_sdk_core10.ACCOUNT_REGISTRY_SPACE);
|
|
22213
22231
|
}
|
|
22214
22232
|
/**
|
|
22215
22233
|
* Account-level application and delegation helpers.
|
|
22216
22234
|
*/
|
|
22217
22235
|
get account() {
|
|
22218
22236
|
if (!this._account) {
|
|
22219
|
-
this._account = new
|
|
22237
|
+
this._account = new import_sdk_core6.AccountService({
|
|
22220
22238
|
getDid: () => this.did,
|
|
22221
22239
|
getHost: () => this.hosts[0] ?? this.config.host,
|
|
22222
22240
|
getPrimarySpaceId: () => this.spaceId,
|
|
@@ -22274,7 +22292,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
22274
22292
|
async endSession() {
|
|
22275
22293
|
const leavingAddress = this.address ?? this._restoredTcSession?.address;
|
|
22276
22294
|
const leavingChainId = this._chainId;
|
|
22277
|
-
const leavingPrincipal = this.replicaSessionPrincipal ?? (leavingAddress ? (0,
|
|
22295
|
+
const leavingPrincipal = this.replicaSessionPrincipal ?? (leavingAddress ? (0, import_sdk_core10.pkhDid)(leavingAddress, leavingChainId) : void 0);
|
|
22278
22296
|
const leavingAuth = this.auth;
|
|
22279
22297
|
const leavingContext = this._serviceContext;
|
|
22280
22298
|
let denied;
|
|
@@ -22391,12 +22409,12 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
22391
22409
|
this.replicaRestoreGate = void 0;
|
|
22392
22410
|
this._serviceGraph = this.createServiceGraphLifetime();
|
|
22393
22411
|
this.auth = oldAuth;
|
|
22394
|
-
this.tc = this.auth ? new
|
|
22412
|
+
this.tc = this.auth ? new import_sdk_core10.TinyCloud(this.auth, {
|
|
22395
22413
|
invokeAny: this.invokeAnyWithRuntimePermissions,
|
|
22396
22414
|
telemetry: this.config.telemetry,
|
|
22397
22415
|
retryPolicy: this.config.retryPolicy
|
|
22398
22416
|
}) : null;
|
|
22399
|
-
this._capabilityRegistry = new
|
|
22417
|
+
this._capabilityRegistry = new import_sdk_core10.CapabilityKeyRegistry();
|
|
22400
22418
|
this._keyProvider = new WasmKeyProvider({ sessionManager: this.sessionManager });
|
|
22401
22419
|
this._sharingService = this.createReceiveOnlySharing();
|
|
22402
22420
|
}
|
|
@@ -22433,6 +22451,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
22433
22451
|
await this.signInWith(() => this.auth.signInWithOpenKey(authorizeFn, options));
|
|
22434
22452
|
}
|
|
22435
22453
|
async signInWith(performSignIn) {
|
|
22454
|
+
refuseCaveated(this.auth?.capabilityRequest?.manifests);
|
|
22436
22455
|
const epoch = this.sessionEpoch;
|
|
22437
22456
|
const attempt = ++this.latestSessionAttempt;
|
|
22438
22457
|
await this.signOutInFlight;
|
|
@@ -22452,11 +22471,11 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
22452
22471
|
this.pendingAccountRegistrySync?.controller.abort();
|
|
22453
22472
|
await this.accountRegistryTail;
|
|
22454
22473
|
await this.wasmBindings.ensureInitialized?.();
|
|
22455
|
-
const address = (0,
|
|
22474
|
+
const address = (0, import_sdk_core10.canonicalizeAddress)(await this.signer.getAddress());
|
|
22456
22475
|
const chainId = await this.signer.getChainId();
|
|
22457
22476
|
this.assertSessionEpoch(epoch, "Sign-in");
|
|
22458
|
-
const nextPrincipal = (0,
|
|
22459
|
-
const priorPrincipal = this.replicaSessionPrincipal ?? (this.address ? (0,
|
|
22477
|
+
const nextPrincipal = (0, import_sdk_core10.pkhDid)(address, chainId);
|
|
22478
|
+
const priorPrincipal = this.replicaSessionPrincipal ?? (this.address ? (0, import_sdk_core10.pkhDid)(this.address, this._chainId) : void 0);
|
|
22460
22479
|
if (this.config.replication?.enabled && priorPrincipal && priorPrincipal !== nextPrincipal) {
|
|
22461
22480
|
const denial = await this.denyReplicaGate({ reason: "account_switch", principal: priorPrincipal, next: nextPrincipal });
|
|
22462
22481
|
this.replicaRestoreGate = denial?.status === "unguarded" ? "gate_unavailable" : "stamp_stale";
|
|
@@ -22502,7 +22521,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
22502
22521
|
this.hostedOwnedSpaceIds.add(spaceId);
|
|
22503
22522
|
}
|
|
22504
22523
|
this.replicationDelegateSession = void 0;
|
|
22505
|
-
this.replicaSessionPrincipal = (0,
|
|
22524
|
+
this.replicaSessionPrincipal = (0, import_sdk_core10.pkhDid)(address, chainId);
|
|
22506
22525
|
this.replicationScopeError = void 0;
|
|
22507
22526
|
await this.quiesceReplicaRuntime();
|
|
22508
22527
|
this.assertSessionEpoch(epoch, "Sign-in");
|
|
@@ -22526,7 +22545,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
22526
22545
|
await this.ensureRequestedEncryptionNetworks();
|
|
22527
22546
|
this.assertSessionEpoch(epoch, "Sign-in");
|
|
22528
22547
|
if (!bootstrapped && this.config.manifest === void 0 && this.config.capabilityRequest === void 0) {
|
|
22529
|
-
await this.ensureOwnedSpaceHostedById(this.ownedSpaceId(
|
|
22548
|
+
await this.ensureOwnedSpaceHostedById(this.ownedSpaceId(import_sdk_core10.SECRETS_SPACE));
|
|
22530
22549
|
}
|
|
22531
22550
|
this.assertSessionEpoch(epoch, "Sign-in");
|
|
22532
22551
|
if (!bootstrapped) {
|
|
@@ -22569,7 +22588,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
22569
22588
|
this._bootstrapStatus = { skipped: true, reason: "interactive-signer" };
|
|
22570
22589
|
return false;
|
|
22571
22590
|
}
|
|
22572
|
-
const steps = (0,
|
|
22591
|
+
const steps = (0, import_sdk_core10.bootstrapSteps)(this._address, this._chainId);
|
|
22573
22592
|
try {
|
|
22574
22593
|
const decision = await this.resolveBootstrapDecision(steps);
|
|
22575
22594
|
if (decision.action === "skip") {
|
|
@@ -22612,7 +22631,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
22612
22631
|
if (!auth) {
|
|
22613
22632
|
throw new Error("Account bootstrap requires an active wallet session");
|
|
22614
22633
|
}
|
|
22615
|
-
const accountSpaceId = this.ownedSpaceId(
|
|
22634
|
+
const accountSpaceId = this.ownedSpaceId(import_sdk_core10.ACCOUNT_REGISTRY_SPACE);
|
|
22616
22635
|
const skipped = auth.lastActivationSkippedSpaceIds;
|
|
22617
22636
|
if (skipped.includes(accountSpaceId)) return { action: "run", mode: "fresh" };
|
|
22618
22637
|
if (skipped.some((spaceId) => enshrinedSpaceIds.has(spaceId))) {
|
|
@@ -22635,7 +22654,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
22635
22654
|
}
|
|
22636
22655
|
return { action: "run", mode: "repair" };
|
|
22637
22656
|
}
|
|
22638
|
-
if (marker.error.code ===
|
|
22657
|
+
if (marker.error.code === import_sdk_core10.ErrorCodes.KV_NOT_FOUND && this.markerReadIsUnhostedSpace(marker.error.meta)) {
|
|
22639
22658
|
return { action: "run", mode: "fresh" };
|
|
22640
22659
|
}
|
|
22641
22660
|
} catch (err2) {
|
|
@@ -22649,7 +22668,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
22649
22668
|
return { action: "run", mode: "repair" };
|
|
22650
22669
|
}
|
|
22651
22670
|
async readBootstrapCompletionMarker() {
|
|
22652
|
-
return this.kvForSpace(this.ownedSpaceId(
|
|
22671
|
+
return this.kvForSpace(this.ownedSpaceId(import_sdk_core10.ACCOUNT_REGISTRY_SPACE)).get(
|
|
22653
22672
|
BOOTSTRAP_COMPLETION_MARKER_KEY
|
|
22654
22673
|
);
|
|
22655
22674
|
}
|
|
@@ -22658,7 +22677,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
22658
22677
|
throw new Error("Bootstrap completion marker requires an active wallet session");
|
|
22659
22678
|
}
|
|
22660
22679
|
const canonicalStepIds = new Set(
|
|
22661
|
-
(0,
|
|
22680
|
+
(0, import_sdk_core10.bootstrapSteps)(this._address, this._chainId).map((step) => step.id)
|
|
22662
22681
|
);
|
|
22663
22682
|
const providedStepIds = new Set(steps.map((step) => step.id));
|
|
22664
22683
|
if (canonicalStepIds.size !== providedStepIds.size || [...canonicalStepIds].some((stepId) => !providedStepIds.has(stepId))) {
|
|
@@ -22669,7 +22688,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
22669
22688
|
stepIds: [...canonicalStepIds],
|
|
22670
22689
|
completedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
22671
22690
|
};
|
|
22672
|
-
const written = await this.kvForSpace(this.ownedSpaceId(
|
|
22691
|
+
const written = await this.kvForSpace(this.ownedSpaceId(import_sdk_core10.ACCOUNT_REGISTRY_SPACE)).put(
|
|
22673
22692
|
BOOTSTRAP_COMPLETION_MARKER_KEY,
|
|
22674
22693
|
marker
|
|
22675
22694
|
);
|
|
@@ -22716,7 +22735,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
22716
22735
|
const warnings = [];
|
|
22717
22736
|
const primarySession = auth.tinyCloudSession;
|
|
22718
22737
|
const defaultSpaceId = this.ownedSpaceId("default");
|
|
22719
|
-
const canReusePrimaryBootstrapSession = primarySession?.spaceId === defaultSpaceId && auth.capabilityRequest ===
|
|
22738
|
+
const canReusePrimaryBootstrapSession = primarySession?.spaceId === defaultSpaceId && auth.capabilityRequest === import_sdk_core10.BOOTSTRAP_SESSION_REQUESTS.default;
|
|
22720
22739
|
if (steps.some((step) => step.kind === "host")) {
|
|
22721
22740
|
await this.assertMayCreateSpace();
|
|
22722
22741
|
}
|
|
@@ -22735,7 +22754,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
22735
22754
|
try {
|
|
22736
22755
|
session = await auth.createBootstrapSession({
|
|
22737
22756
|
spaceId: step.spaceId,
|
|
22738
|
-
capabilityRequest: step.request ??
|
|
22757
|
+
capabilityRequest: step.request ?? import_sdk_core10.BOOTSTRAP_SESSION_REQUESTS[step.space],
|
|
22739
22758
|
rawAbilities
|
|
22740
22759
|
});
|
|
22741
22760
|
} catch (err2) {
|
|
@@ -22767,7 +22786,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
22767
22786
|
if (!session) {
|
|
22768
22787
|
throw new Error(`Missing bootstrap session for ${step.space}`);
|
|
22769
22788
|
}
|
|
22770
|
-
const activated = await (0,
|
|
22789
|
+
const activated = await (0, import_sdk_core10.activateSessionWithHost)(host, session.delegationHeader, graph.signal).catch((error) => {
|
|
22771
22790
|
graph.assertActive();
|
|
22772
22791
|
throw error;
|
|
22773
22792
|
});
|
|
@@ -22782,7 +22801,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
22782
22801
|
}
|
|
22783
22802
|
this.registerBootstrapRuntimeGrant(
|
|
22784
22803
|
session,
|
|
22785
|
-
|
|
22804
|
+
import_sdk_core10.BOOTSTRAP_SESSION_REQUESTS[step.space],
|
|
22786
22805
|
rawAbilitiesBySpace.get(step.space)
|
|
22787
22806
|
);
|
|
22788
22807
|
}
|
|
@@ -22832,7 +22851,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
22832
22851
|
}
|
|
22833
22852
|
if (step.kind === "seed-applications") {
|
|
22834
22853
|
const registered = await this.account.applications.register(
|
|
22835
|
-
step.manifests.length > 0 ? [...step.manifests] :
|
|
22854
|
+
step.manifests.length > 0 ? [...step.manifests] : import_sdk_core10.TINYCLOUD_SECRETS_BOOTSTRAP_MANIFEST,
|
|
22836
22855
|
// The write is an INSERT OR REPLACE and is safe to repeat during a
|
|
22837
22856
|
// repair, so skip the manifest-hash pre-read.
|
|
22838
22857
|
{ assumeUnregistered: true }
|
|
@@ -22851,7 +22870,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
22851
22870
|
migrations: [
|
|
22852
22871
|
{
|
|
22853
22872
|
id: "001_initial",
|
|
22854
|
-
sql: [...
|
|
22873
|
+
sql: [...import_sdk_core10.SECRET_RECORDS_SCHEMA]
|
|
22855
22874
|
}
|
|
22856
22875
|
]
|
|
22857
22876
|
});
|
|
@@ -23026,7 +23045,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
23026
23045
|
if (!this.auth || !this.signer) {
|
|
23027
23046
|
throw new Error("Manifest registry write requires wallet mode");
|
|
23028
23047
|
}
|
|
23029
|
-
const accountSpaceId = this.ownedSpaceId(
|
|
23048
|
+
const accountSpaceId = this.ownedSpaceId(import_sdk_core10.ACCOUNT_REGISTRY_SPACE);
|
|
23030
23049
|
await this.ensureOwnedSpaceHostedById(accountSpaceId, signal);
|
|
23031
23050
|
if (signal.aborted) throw signal.reason;
|
|
23032
23051
|
const result = await account.applications.register(request.manifests);
|
|
@@ -23041,7 +23060,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
23041
23060
|
const session = context.session;
|
|
23042
23061
|
if (!session) throw new Error("Account registry requires an active service session");
|
|
23043
23062
|
const contexts = [context];
|
|
23044
|
-
const accountSpaceId = this.ownedSpaceId(
|
|
23063
|
+
const accountSpaceId = this.ownedSpaceId(import_sdk_core10.ACCOUNT_REGISTRY_SPACE);
|
|
23045
23064
|
const createScopedContext = (spaceId) => {
|
|
23046
23065
|
const scoped = this._serviceGraph.track(createServiceContext({
|
|
23047
23066
|
requestSink: this._serviceGraph.requestSink,
|
|
@@ -23057,10 +23076,10 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
23057
23076
|
contexts.push(scoped);
|
|
23058
23077
|
return scoped;
|
|
23059
23078
|
};
|
|
23060
|
-
const sql = new
|
|
23079
|
+
const sql = new import_sdk_core10.SQLService({});
|
|
23061
23080
|
const sqlContext = createScopedContext(accountSpaceId);
|
|
23062
23081
|
sql.initialize(sqlContext);
|
|
23063
|
-
const spaces = new
|
|
23082
|
+
const spaces = new import_sdk_core10.SpaceService({
|
|
23064
23083
|
hosts: context.hosts,
|
|
23065
23084
|
session,
|
|
23066
23085
|
invoke: context.invoke,
|
|
@@ -23070,14 +23089,14 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
23070
23089
|
}),
|
|
23071
23090
|
userDid: this.did,
|
|
23072
23091
|
createKVService: (spaceId) => {
|
|
23073
|
-
const kv = new
|
|
23092
|
+
const kv = new import_sdk_core10.KVService({});
|
|
23074
23093
|
kv.initialize(createScopedContext(spaceId));
|
|
23075
23094
|
return kv;
|
|
23076
23095
|
}
|
|
23077
23096
|
});
|
|
23078
23097
|
return {
|
|
23079
23098
|
contexts,
|
|
23080
|
-
account: new
|
|
23099
|
+
account: new import_sdk_core6.AccountService({
|
|
23081
23100
|
getDid: () => this.did,
|
|
23082
23101
|
getHost: () => context.hosts[0] ?? this.config.host,
|
|
23083
23102
|
getPrimarySpaceId: () => session.spaceId,
|
|
@@ -23233,7 +23252,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
23233
23252
|
return true;
|
|
23234
23253
|
}
|
|
23235
23254
|
const indexRead = {
|
|
23236
|
-
spaceId: this.ownedSpaceId(
|
|
23255
|
+
spaceId: this.ownedSpaceId(import_sdk_core10.ACCOUNT_REGISTRY_SPACE),
|
|
23237
23256
|
service: "sql",
|
|
23238
23257
|
path: "account",
|
|
23239
23258
|
action: "tinycloud.sql/read"
|
|
@@ -23261,7 +23280,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
23261
23280
|
stopped(error);
|
|
23262
23281
|
return;
|
|
23263
23282
|
}
|
|
23264
|
-
const verdict = (0,
|
|
23283
|
+
const verdict = (0, import_sdk_core10.authorizationVerdictOf)(error);
|
|
23265
23284
|
const message = error instanceof Error ? error.message : String(error);
|
|
23266
23285
|
const isAuthorizationVerdict = verdict === void 0 ? /^(?:Unauthorized Action\b|(?:(?:request failed|HTTP request failed|status(?: code)?|response status)\s*:\s*)?(?:HTTP\s*)?(?:401|403)\b)/i.test(message) : verdict !== "other";
|
|
23267
23286
|
if (isAuthorizationVerdict) {
|
|
@@ -23271,7 +23290,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
23271
23290
|
);
|
|
23272
23291
|
return;
|
|
23273
23292
|
}
|
|
23274
|
-
if ((0,
|
|
23293
|
+
if ((0, import_sdk_core10.isStorageFullError)(error) || (0, import_sdk_core10.isStorageFullError)(error?.cause) || message.includes(import_sdk_core10.STORAGE_FULL_MESSAGE) || message.includes(import_sdk_core10.STORAGE_WRITE_TOO_LARGE_MESSAGE)) {
|
|
23275
23294
|
console.warn(
|
|
23276
23295
|
"TinyCloud account registry sync stopped: storage is full",
|
|
23277
23296
|
error
|
|
@@ -23309,7 +23328,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
23309
23328
|
}
|
|
23310
23329
|
const networkIds = /* @__PURE__ */ new Set();
|
|
23311
23330
|
for (const resource of request.resources) {
|
|
23312
|
-
if (resource.service ===
|
|
23331
|
+
if (resource.service === import_sdk_core10.ENCRYPTION_PERMISSION_SERVICE && resource.path.startsWith("urn:tinycloud:encryption:") && resource.actions.includes(DECRYPT_ACTION2)) {
|
|
23313
23332
|
networkIds.add(resource.path);
|
|
23314
23333
|
}
|
|
23315
23334
|
}
|
|
@@ -23320,7 +23339,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
23320
23339
|
return;
|
|
23321
23340
|
}
|
|
23322
23341
|
for (const networkId of this.requestedEncryptionNetworkIds()) {
|
|
23323
|
-
const parsed = (0,
|
|
23342
|
+
const parsed = (0, import_sdk_core10.parseNetworkId)(networkId);
|
|
23324
23343
|
if (!didPrincipalMatches2(parsed.ownerDid, this.did)) {
|
|
23325
23344
|
continue;
|
|
23326
23345
|
}
|
|
@@ -23358,7 +23377,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
23358
23377
|
if (!host) {
|
|
23359
23378
|
throw new Error("Owned space hosting requires a TinyCloud host");
|
|
23360
23379
|
}
|
|
23361
|
-
const activation = await (0,
|
|
23380
|
+
const activation = await (0, import_sdk_core10.activateSessionWithHost)(host, session.delegationHeader, signal);
|
|
23362
23381
|
if (activation.success && !activation.skipped?.includes(spaceId)) {
|
|
23363
23382
|
this.confirmedHostedSpaceIds.add(spaceId);
|
|
23364
23383
|
return;
|
|
@@ -23379,7 +23398,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
23379
23398
|
);
|
|
23380
23399
|
}
|
|
23381
23400
|
if (signal?.aborted) throw signal.reason;
|
|
23382
|
-
const retry = await (0,
|
|
23401
|
+
const retry = await (0, import_sdk_core10.activateSessionWithHost)(host, session.delegationHeader, signal);
|
|
23383
23402
|
if (!retry.success || retry.skipped?.includes(spaceId)) {
|
|
23384
23403
|
throw Object.assign(
|
|
23385
23404
|
new Error(
|
|
@@ -23430,7 +23449,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
23430
23449
|
{ cause: hosted }
|
|
23431
23450
|
);
|
|
23432
23451
|
}
|
|
23433
|
-
const activation = await (0,
|
|
23452
|
+
const activation = await (0, import_sdk_core10.activateSessionWithHost)(
|
|
23434
23453
|
host,
|
|
23435
23454
|
session.delegationHeader
|
|
23436
23455
|
);
|
|
@@ -23690,7 +23709,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
23690
23709
|
}
|
|
23691
23710
|
let restoredAddress;
|
|
23692
23711
|
try {
|
|
23693
|
-
restoredAddress = hasPersistedProof ? (0,
|
|
23712
|
+
restoredAddress = hasPersistedProof ? (0, import_sdk_core10.canonicalizeAddress)(sessionData.address) : void 0;
|
|
23694
23713
|
} catch {
|
|
23695
23714
|
throw new InvalidRestoredSessionError("Persisted session has an invalid wallet address.");
|
|
23696
23715
|
}
|
|
@@ -23734,9 +23753,9 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
23734
23753
|
let replicaProtocolMismatch = false;
|
|
23735
23754
|
if (this.config.replication?.enabled) {
|
|
23736
23755
|
try {
|
|
23737
|
-
restoredNodeFeatures = (await (0,
|
|
23756
|
+
restoredNodeFeatures = (await (0, import_sdk_core10.checkNodeInfo)(stagedHost, this.wasmBindings.protocolVersion())).features;
|
|
23738
23757
|
} catch (error) {
|
|
23739
|
-
replicaProtocolMismatch = error instanceof
|
|
23758
|
+
replicaProtocolMismatch = error instanceof import_sdk_core10.ProtocolMismatchError;
|
|
23740
23759
|
}
|
|
23741
23760
|
}
|
|
23742
23761
|
const stagedAddress = restoredAddress;
|
|
@@ -23747,7 +23766,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
23747
23766
|
let replicationScopeUnavailable = false;
|
|
23748
23767
|
if (this.config.replication?.enabled) {
|
|
23749
23768
|
if (stagedAddress !== void 0) {
|
|
23750
|
-
replicationPrincipal = (0,
|
|
23769
|
+
replicationPrincipal = (0, import_sdk_core10.pkhDid)(stagedAddress, stagedChainId);
|
|
23751
23770
|
} else {
|
|
23752
23771
|
try {
|
|
23753
23772
|
const { replicationScopeFromSignedSession: replicationScopeFromSignedSession2 } = await getNodeReplicationLoaders().authority();
|
|
@@ -23796,7 +23815,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
23796
23815
|
}
|
|
23797
23816
|
}
|
|
23798
23817
|
}
|
|
23799
|
-
const stagedNodeDid = stagedAddress ? (0,
|
|
23818
|
+
const stagedNodeDid = stagedAddress ? (0, import_sdk_core10.pkhDid)(stagedAddress, stagedChainId) : canonicalVerificationMethod;
|
|
23800
23819
|
const serviceSession = {
|
|
23801
23820
|
delegationHeader: sessionData.delegationHeader,
|
|
23802
23821
|
delegationCid: sessionData.delegationCid,
|
|
@@ -23824,7 +23843,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
23824
23843
|
stagedSessionExpiry,
|
|
23825
23844
|
stagedRecap
|
|
23826
23845
|
);
|
|
23827
|
-
const stagedAccountSpaceId = stagedAddress ? this.wasmBindings.makeSpaceId(stagedAddress, stagedChainId,
|
|
23846
|
+
const stagedAccountSpaceId = stagedAddress ? this.wasmBindings.makeSpaceId(stagedAddress, stagedChainId, import_sdk_core10.ACCOUNT_REGISTRY_SPACE) : void 0;
|
|
23828
23847
|
const stagedGraph = this.stageRestoredServiceGraph({
|
|
23829
23848
|
host: stagedHost,
|
|
23830
23849
|
manager: stagedManager,
|
|
@@ -23959,7 +23978,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
23959
23978
|
}
|
|
23960
23979
|
stageRestoredServiceGraph(input) {
|
|
23961
23980
|
const graph = this.createServiceGraphLifetime();
|
|
23962
|
-
const core = this.auth ? new
|
|
23981
|
+
const core = this.auth ? new import_sdk_core10.TinyCloud(this.auth, {
|
|
23963
23982
|
invokeAny: graph.invokeAny,
|
|
23964
23983
|
telemetry: this.config.telemetry,
|
|
23965
23984
|
retryPolicy: this.config.retryPolicy
|
|
@@ -23978,16 +23997,16 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
23978
23997
|
telemetry: this.config.telemetry,
|
|
23979
23998
|
retryPolicy: this.config.retryPolicy
|
|
23980
23999
|
}));
|
|
23981
|
-
const kv = new
|
|
24000
|
+
const kv = new import_sdk_core10.KVService({});
|
|
23982
24001
|
kv.initialize(serviceContext);
|
|
23983
24002
|
serviceContext.registerService("kv", kv);
|
|
23984
|
-
const sql = new
|
|
24003
|
+
const sql = new import_sdk_core10.SQLService({});
|
|
23985
24004
|
sql.initialize(serviceContext);
|
|
23986
24005
|
serviceContext.registerService("sql", sql);
|
|
23987
|
-
const duckdb = new
|
|
24006
|
+
const duckdb = new import_sdk_core10.DuckDbService({});
|
|
23988
24007
|
duckdb.initialize(serviceContext);
|
|
23989
24008
|
serviceContext.registerService("duckdb", duckdb);
|
|
23990
|
-
const hooks = new
|
|
24009
|
+
const hooks = new import_sdk_core10.HooksService({});
|
|
23991
24010
|
hooks.initialize(serviceContext);
|
|
23992
24011
|
serviceContext.registerService("hooks", hooks);
|
|
23993
24012
|
serviceContext.setSession(input.serviceSession);
|
|
@@ -24010,7 +24029,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
24010
24029
|
});
|
|
24011
24030
|
vault.initialize(serviceContext);
|
|
24012
24031
|
serviceContext.registerService("vault", vault);
|
|
24013
|
-
const capabilityRegistry = new
|
|
24032
|
+
const capabilityRegistry = new import_sdk_core10.CapabilityKeyRegistry();
|
|
24014
24033
|
if (input.tinyCloudSession) {
|
|
24015
24034
|
const session = input.tinyCloudSession;
|
|
24016
24035
|
const delegations = input.recap.map((entry) => ({
|
|
@@ -24034,7 +24053,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
24034
24053
|
}, delegations);
|
|
24035
24054
|
}
|
|
24036
24055
|
}
|
|
24037
|
-
const delegationManager = new
|
|
24056
|
+
const delegationManager = new import_sdk_core10.DelegationManager({
|
|
24038
24057
|
hosts: [input.host],
|
|
24039
24058
|
accountSpaceId: input.accountSpaceId,
|
|
24040
24059
|
session: input.serviceSession,
|
|
@@ -24044,7 +24063,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
24044
24063
|
fetch: graph.fetch
|
|
24045
24064
|
});
|
|
24046
24065
|
const keyProvider = new WasmKeyProvider({ sessionManager: input.manager });
|
|
24047
|
-
const sharingService = new
|
|
24066
|
+
const sharingService = new import_sdk_core10.SharingService({
|
|
24048
24067
|
hosts: [input.host],
|
|
24049
24068
|
invoke: graph.invoke,
|
|
24050
24069
|
fetch: graph.fetch,
|
|
@@ -24057,7 +24076,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
24057
24076
|
return this.wasmBindings.computeCid(data, codec);
|
|
24058
24077
|
},
|
|
24059
24078
|
createKVService: (config) => {
|
|
24060
|
-
const service = new
|
|
24079
|
+
const service = new import_sdk_core10.KVService({ prefix: config.pathPrefix?.replace(/\/$/, "") });
|
|
24061
24080
|
const context = graph.track(createServiceContext({
|
|
24062
24081
|
requestSink: graph.requestSink,
|
|
24063
24082
|
invoke: config.invoke,
|
|
@@ -24089,7 +24108,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
24089
24108
|
return delegation;
|
|
24090
24109
|
} : void 0
|
|
24091
24110
|
});
|
|
24092
|
-
const spaceService = new
|
|
24111
|
+
const spaceService = new import_sdk_core10.SpaceService({
|
|
24093
24112
|
hosts: [input.host],
|
|
24094
24113
|
session: input.serviceSession,
|
|
24095
24114
|
invoke: graph.invoke,
|
|
@@ -24098,7 +24117,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
24098
24117
|
userDid: input.nodeDid,
|
|
24099
24118
|
createKVService: (spaceId) => {
|
|
24100
24119
|
graph.assertActive();
|
|
24101
|
-
const scopedKv = new
|
|
24120
|
+
const scopedKv = new import_sdk_core10.KVService({});
|
|
24102
24121
|
const context = graph.track(createServiceContext({
|
|
24103
24122
|
requestSink: graph.requestSink,
|
|
24104
24123
|
invoke: graph.invoke,
|
|
@@ -24115,7 +24134,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
24115
24134
|
},
|
|
24116
24135
|
createVaultService: (spaceId) => {
|
|
24117
24136
|
graph.assertActive();
|
|
24118
|
-
const scopedKv = new
|
|
24137
|
+
const scopedKv = new import_sdk_core10.KVService({});
|
|
24119
24138
|
const context = graph.track(createServiceContext({
|
|
24120
24139
|
requestSink: graph.requestSink,
|
|
24121
24140
|
invoke: graph.invoke,
|
|
@@ -24207,7 +24226,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
24207
24226
|
return void 0;
|
|
24208
24227
|
}
|
|
24209
24228
|
if (this.config.registryPolicy === "fail-closed") {
|
|
24210
|
-
const resolved2 = await (0,
|
|
24229
|
+
const resolved2 = await (0, import_sdk_core10.resolveFailClosedTinyCloudHosts)(address, {
|
|
24211
24230
|
registryUrl: this.config.tinycloudRegistryUrl,
|
|
24212
24231
|
registryChainId: this.config.registryChainId,
|
|
24213
24232
|
newUserHost: this.config.newUserHost,
|
|
@@ -24221,7 +24240,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
24221
24240
|
});
|
|
24222
24241
|
return resolved2.hosts[0];
|
|
24223
24242
|
}
|
|
24224
|
-
const resolved = await (0,
|
|
24243
|
+
const resolved = await (0, import_sdk_core10.resolveTinyCloudHosts)((0, import_sdk_core10.pkhDid)(address, chainId), {
|
|
24225
24244
|
registryUrl: this.config.tinycloudRegistryUrl,
|
|
24226
24245
|
fallbackHosts: this.config.tinycloudFallbackHosts,
|
|
24227
24246
|
autoDiscoverLocalNode: this.config.autoDiscoverLocalNode,
|
|
@@ -24273,7 +24292,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
24273
24292
|
nodeAudience: input.nodeAudience,
|
|
24274
24293
|
...input.role === "policy-enforcement" ? { enforcerDid: input.audienceDid } : {}
|
|
24275
24294
|
};
|
|
24276
|
-
const root = await (0,
|
|
24295
|
+
const root = await (0, import_sdk_core10.signCompactUcanRootAuthorization)({
|
|
24277
24296
|
issuerDid: ownerDid,
|
|
24278
24297
|
audienceDid: input.audienceDid,
|
|
24279
24298
|
attenuation: unifiedRootAttenuation(input.capabilities),
|
|
@@ -24315,7 +24334,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
24315
24334
|
if (decision.needsApproval) return void 0;
|
|
24316
24335
|
throw new Error(decision.reason ?? "OpenKey automatic credential signing was rejected");
|
|
24317
24336
|
}
|
|
24318
|
-
if (typeof decision.signature !== "string" || !await (0,
|
|
24337
|
+
if (typeof decision.signature !== "string" || !await (0, import_sdk_core10.verifyEip191MessageSignature)(
|
|
24319
24338
|
request.message,
|
|
24320
24339
|
decision.signature,
|
|
24321
24340
|
request.address
|
|
@@ -24340,7 +24359,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
24340
24359
|
if (approval) {
|
|
24341
24360
|
const decision = await approval(request);
|
|
24342
24361
|
if (!decision.approved) throw new Error(decision.reason ?? "Credential signing was rejected");
|
|
24343
|
-
if (decision.signature !== void 0 && !await (0,
|
|
24362
|
+
if (decision.signature !== void 0 && !await (0, import_sdk_core10.verifyEip191MessageSignature)(
|
|
24344
24363
|
request.message,
|
|
24345
24364
|
decision.signature,
|
|
24346
24365
|
request.address
|
|
@@ -24425,7 +24444,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
24425
24444
|
nonce: this.config.nonce,
|
|
24426
24445
|
siweConfig: this.config.siweConfig,
|
|
24427
24446
|
manifest: useBootstrapSignInRequest ? void 0 : this.config.manifest,
|
|
24428
|
-
capabilityRequest: useBootstrapSignInRequest ? this.config.includeAccountRegistryPermissions === false ?
|
|
24447
|
+
capabilityRequest: useBootstrapSignInRequest ? this.config.includeAccountRegistryPermissions === false ? import_sdk_core10.BOOTSTRAP_DEFAULT_ONLY_SESSION_REQUEST : import_sdk_core10.BOOTSTRAP_SESSION_REQUESTS.default : this.config.capabilityRequest,
|
|
24429
24448
|
includeAccountRegistryPermissions: useBootstrapSignInRequest ? false : this.config.includeAccountRegistryPermissions,
|
|
24430
24449
|
replication: this.config.replication?.enabled === true ? {
|
|
24431
24450
|
enabled: true,
|
|
@@ -24433,7 +24452,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
24433
24452
|
allowSecrets: this.config.replication.allowSecrets === true
|
|
24434
24453
|
} : void 0
|
|
24435
24454
|
});
|
|
24436
|
-
this.tc = new
|
|
24455
|
+
this.tc = new import_sdk_core10.TinyCloud(this.auth, {
|
|
24437
24456
|
invokeAny: this.invokeAnyWithRuntimePermissions,
|
|
24438
24457
|
telemetry: this.config.telemetry,
|
|
24439
24458
|
retryPolicy: this.config.retryPolicy
|
|
@@ -24486,7 +24505,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
24486
24505
|
nonce: this.config.nonce,
|
|
24487
24506
|
siweConfig: this.config.siweConfig,
|
|
24488
24507
|
manifest: useBootstrapSignInRequest ? void 0 : this.config.manifest,
|
|
24489
|
-
capabilityRequest: useBootstrapSignInRequest ? this.config.includeAccountRegistryPermissions === false ?
|
|
24508
|
+
capabilityRequest: useBootstrapSignInRequest ? this.config.includeAccountRegistryPermissions === false ? import_sdk_core10.BOOTSTRAP_DEFAULT_ONLY_SESSION_REQUEST : import_sdk_core10.BOOTSTRAP_SESSION_REQUESTS.default : this.config.capabilityRequest,
|
|
24490
24509
|
includeAccountRegistryPermissions: useBootstrapSignInRequest ? false : this.config.includeAccountRegistryPermissions,
|
|
24491
24510
|
replication: this.config.replication?.enabled === true ? {
|
|
24492
24511
|
enabled: true,
|
|
@@ -24494,7 +24513,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
24494
24513
|
allowSecrets: this.config.replication.allowSecrets === true
|
|
24495
24514
|
} : void 0
|
|
24496
24515
|
});
|
|
24497
|
-
this.tc = new
|
|
24516
|
+
this.tc = new import_sdk_core10.TinyCloud(this.auth, {
|
|
24498
24517
|
invokeAny: this.invokeAnyWithRuntimePermissions,
|
|
24499
24518
|
telemetry: this.config.telemetry,
|
|
24500
24519
|
retryPolicy: this.config.retryPolicy
|
|
@@ -24525,21 +24544,21 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
24525
24544
|
telemetry: this.config.telemetry,
|
|
24526
24545
|
retryPolicy: this.config.retryPolicy
|
|
24527
24546
|
}));
|
|
24528
|
-
this._kv = new
|
|
24547
|
+
this._kv = new import_sdk_core10.KVService({});
|
|
24529
24548
|
this._kv.initialize(this._serviceContext);
|
|
24530
24549
|
this._serviceContext.registerService("kv", this._kv);
|
|
24531
24550
|
const features = this.nodeFeatures;
|
|
24532
24551
|
if (features.length === 0 || features.includes("sql")) {
|
|
24533
|
-
this._sql = new
|
|
24552
|
+
this._sql = new import_sdk_core10.SQLService({});
|
|
24534
24553
|
this._sql.initialize(this._serviceContext);
|
|
24535
24554
|
this._serviceContext.registerService("sql", this._sql);
|
|
24536
24555
|
}
|
|
24537
24556
|
if (features.length === 0 || features.includes("duckdb")) {
|
|
24538
|
-
this._duckdb = new
|
|
24557
|
+
this._duckdb = new import_sdk_core10.DuckDbService({});
|
|
24539
24558
|
this._duckdb.initialize(this._serviceContext);
|
|
24540
24559
|
this._serviceContext.registerService("duckdb", this._duckdb);
|
|
24541
24560
|
}
|
|
24542
|
-
this._hooks = new
|
|
24561
|
+
this._hooks = new import_sdk_core10.HooksService({});
|
|
24543
24562
|
this._hooks.initialize(this._serviceContext);
|
|
24544
24563
|
this._serviceContext.registerService("hooks", this._hooks);
|
|
24545
24564
|
const serviceSession = {
|
|
@@ -24563,7 +24582,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
24563
24582
|
kvService.setReadThroughReady(attached);
|
|
24564
24583
|
}
|
|
24565
24584
|
createSpaceScopedKVService(spaceId) {
|
|
24566
|
-
const kvService = new
|
|
24585
|
+
const kvService = new import_sdk_core10.KVService({});
|
|
24567
24586
|
if (this._serviceContext) {
|
|
24568
24587
|
const spaceScopedContext = this._serviceGraph.track(createServiceContext({
|
|
24569
24588
|
requestSink: this._serviceGraph.requestSink,
|
|
@@ -24660,7 +24679,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
24660
24679
|
const shared = wasm.vault_x25519_dh(receiverPrivateKey, peerPublic);
|
|
24661
24680
|
return columnDecrypt(shared, ciphertext);
|
|
24662
24681
|
},
|
|
24663
|
-
verifyNodeSignature: (nodeId, message, signature2) => (0,
|
|
24682
|
+
verifyNodeSignature: (nodeId, message, signature2) => (0, import_sdk_core10.verifyDidKeyEd25519Signature)(nodeId, message, signature2)
|
|
24664
24683
|
};
|
|
24665
24684
|
}
|
|
24666
24685
|
/**
|
|
@@ -24676,7 +24695,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
24676
24695
|
if (cached) return cached;
|
|
24677
24696
|
const response = await fetch(`${this.config.host}/info`);
|
|
24678
24697
|
if (!response.ok) {
|
|
24679
|
-
throw await (0,
|
|
24698
|
+
throw await (0, import_sdk_core10.httpResponseError)(response, "Failed to fetch node info");
|
|
24680
24699
|
}
|
|
24681
24700
|
const info = await response.json();
|
|
24682
24701
|
if (typeof info.nodeId !== "string" || info.nodeId.length === 0) {
|
|
@@ -24726,7 +24745,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
24726
24745
|
);
|
|
24727
24746
|
if (response.status === 404) return null;
|
|
24728
24747
|
if (!response.ok) {
|
|
24729
|
-
throw await (0,
|
|
24748
|
+
throw await (0, import_sdk_core10.httpResponseError)(response, `Failed to fetch encryption network ${networkId}`);
|
|
24730
24749
|
}
|
|
24731
24750
|
const body = await response.json();
|
|
24732
24751
|
return "descriptor" in body && body.descriptor ? body.descriptor : body;
|
|
@@ -24762,12 +24781,12 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
24762
24781
|
path: networkId,
|
|
24763
24782
|
actions: ["tinycloud.encryption/decrypt"]
|
|
24764
24783
|
}) : void 0;
|
|
24765
|
-
throw new
|
|
24784
|
+
throw new import_sdk_core10.DecryptTransportResponseError(response.status, permissionHint);
|
|
24766
24785
|
}
|
|
24767
24786
|
return await response.json();
|
|
24768
24787
|
}
|
|
24769
24788
|
};
|
|
24770
|
-
return new
|
|
24789
|
+
return new import_sdk_core10.EncryptionService({
|
|
24771
24790
|
crypto: crypto3,
|
|
24772
24791
|
signer: {
|
|
24773
24792
|
signDecryptInvocation: async (input) => {
|
|
@@ -24781,7 +24800,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
24781
24800
|
graph.assertActive();
|
|
24782
24801
|
return {
|
|
24783
24802
|
...signed2,
|
|
24784
|
-
canonicalBody: (0,
|
|
24803
|
+
canonicalBody: (0, import_sdk_core10.canonicalizeEncryptionJson)(
|
|
24785
24804
|
input.body
|
|
24786
24805
|
)
|
|
24787
24806
|
};
|
|
@@ -24813,7 +24832,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
24813
24832
|
if (!address || !didPrincipalMatches2(principal, did)) {
|
|
24814
24833
|
return null;
|
|
24815
24834
|
}
|
|
24816
|
-
const publicSpaceId = (0,
|
|
24835
|
+
const publicSpaceId = (0, import_sdk_core10.makePublicSpaceId)(address, chainId);
|
|
24817
24836
|
const encodedKey = discoveryKey.split("/").map(encodeURIComponent).join("/");
|
|
24818
24837
|
const response = await graph.fetch(
|
|
24819
24838
|
`${host}/public/${encodeURIComponent(publicSpaceId)}/kv/${encodedKey}`,
|
|
@@ -24845,7 +24864,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
24845
24864
|
createVaultService(spaceId, kv, encryptionService = this.getEncryptionService(), nodeContext) {
|
|
24846
24865
|
const wasm = this.wasmBindings;
|
|
24847
24866
|
const serviceGraph = nodeContext?.serviceGraph ?? this._serviceGraph;
|
|
24848
|
-
const vaultCrypto = (0,
|
|
24867
|
+
const vaultCrypto = (0, import_sdk_core10.createVaultCrypto)({
|
|
24849
24868
|
vault_encrypt: wasm.vault_encrypt,
|
|
24850
24869
|
vault_decrypt: wasm.vault_decrypt,
|
|
24851
24870
|
vault_derive_key: wasm.vault_derive_key,
|
|
@@ -24860,7 +24879,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
24860
24879
|
const chainId = nodeContext?.chainId ?? this._chainId;
|
|
24861
24880
|
const host = nodeContext?.host ?? this.config.host;
|
|
24862
24881
|
const ownerDid = this.ownerDidFromSpaceId(spaceId) ?? did;
|
|
24863
|
-
return new
|
|
24882
|
+
return new import_sdk_core10.DataVaultService({
|
|
24864
24883
|
spaceId,
|
|
24865
24884
|
crypto: vaultCrypto,
|
|
24866
24885
|
encryption: {
|
|
@@ -24885,8 +24904,8 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
24885
24904
|
serviceGraph.assertActive();
|
|
24886
24905
|
return self2._publicKV ?? self2.tc.publicKV;
|
|
24887
24906
|
},
|
|
24888
|
-
readPublicSpace: (host2, targetSpaceId, key2) =>
|
|
24889
|
-
makePublicSpaceId:
|
|
24907
|
+
readPublicSpace: (host2, targetSpaceId, key2) => import_sdk_core10.TinyCloud.readPublicSpace(host2, targetSpaceId, key2),
|
|
24908
|
+
makePublicSpaceId: import_sdk_core10.TinyCloud.makePublicSpaceId,
|
|
24890
24909
|
did,
|
|
24891
24910
|
address: address ?? "",
|
|
24892
24911
|
chainId,
|
|
@@ -24900,7 +24919,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
24900
24919
|
*/
|
|
24901
24920
|
initializeV2Services(serviceSession) {
|
|
24902
24921
|
const graph = this._serviceGraph;
|
|
24903
|
-
this._capabilityRegistry = new
|
|
24922
|
+
this._capabilityRegistry = new import_sdk_core10.CapabilityKeyRegistry();
|
|
24904
24923
|
const tcSession = this.auth?.tinyCloudSession;
|
|
24905
24924
|
if (tcSession && this._address) {
|
|
24906
24925
|
const sessionKey = {
|
|
@@ -24940,7 +24959,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
24940
24959
|
}
|
|
24941
24960
|
this._capabilityRegistry.registerKey(sessionKey, delegations);
|
|
24942
24961
|
}
|
|
24943
|
-
this._delegationManager = new
|
|
24962
|
+
this._delegationManager = new import_sdk_core10.DelegationManager({
|
|
24944
24963
|
hosts: [this.config.host],
|
|
24945
24964
|
accountSpaceId: this.accountSpaceId,
|
|
24946
24965
|
session: serviceSession,
|
|
@@ -24949,7 +24968,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
24949
24968
|
signOwnerRevocation: this.signer ? (cid) => this.signOwnerRevocation(cid) : void 0,
|
|
24950
24969
|
fetch: graph.fetch
|
|
24951
24970
|
});
|
|
24952
|
-
this._spaceService = new
|
|
24971
|
+
this._spaceService = new import_sdk_core10.SpaceService({
|
|
24953
24972
|
hosts: [this.config.host],
|
|
24954
24973
|
session: serviceSession,
|
|
24955
24974
|
invoke: graph.invoke,
|
|
@@ -25015,7 +25034,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
25015
25034
|
},
|
|
25016
25035
|
isStorageFull: () => this.ownStorageFull
|
|
25017
25036
|
});
|
|
25018
|
-
this._sharingService = new
|
|
25037
|
+
this._sharingService = new import_sdk_core10.SharingService({
|
|
25019
25038
|
hosts: [this.config.host],
|
|
25020
25039
|
session: serviceSession,
|
|
25021
25040
|
invoke: graph.invoke,
|
|
@@ -25034,7 +25053,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
25034
25053
|
},
|
|
25035
25054
|
createKVService: (config) => {
|
|
25036
25055
|
graph.assertActive();
|
|
25037
|
-
const service = new
|
|
25056
|
+
const service = new import_sdk_core10.KVService({ prefix: config.pathPrefix?.replace(/\/$/, "") });
|
|
25038
25057
|
const context = graph.track(createServiceContext({
|
|
25039
25058
|
requestSink: graph.requestSink,
|
|
25040
25059
|
invoke: config.invoke,
|
|
@@ -25108,7 +25127,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
25108
25127
|
params.notBeforeSecs
|
|
25109
25128
|
);
|
|
25110
25129
|
return {
|
|
25111
|
-
...terminal ? (0,
|
|
25130
|
+
...terminal ? (0, import_sdk_core10.markDelegationTerminal)(result.delegation, params.session.jwk) : { delegation: result.delegation, cid: result.cid },
|
|
25112
25131
|
// Rust serde `rename_all = "camelCase"` emits `delegateDid`
|
|
25113
25132
|
// (lowercase d); the TypeScript interface uses `delegateDID`
|
|
25114
25133
|
// (historical, matches Delegation.delegateDID). Normalize here.
|
|
@@ -25131,15 +25150,15 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
25131
25150
|
}
|
|
25132
25151
|
const permissions = ownerDelegationPermissions(params);
|
|
25133
25152
|
const now = /* @__PURE__ */ new Date();
|
|
25134
|
-
if (!(params.expiresAt instanceof Date) || params.expiresAt.getTime() <= now.getTime() || params.expiresAt.getTime() - now.getTime() >
|
|
25153
|
+
if (!(params.expiresAt instanceof Date) || params.expiresAt.getTime() <= now.getTime() || params.expiresAt.getTime() - now.getTime() > import_sdk_core10.EXPIRY.MAX_MS) {
|
|
25135
25154
|
throw new Error("Owner delegation expiry must be explicit, future, and within EXPIRY.MAX_MS");
|
|
25136
25155
|
}
|
|
25137
25156
|
if (!this.signer) throw new Error("Owner wallet signer is required");
|
|
25138
25157
|
const session = this.currentTinyCloudSession();
|
|
25139
25158
|
if (!session) throw new Error("Owner session is required");
|
|
25140
|
-
const ownerDid = (0,
|
|
25159
|
+
const ownerDid = (0, import_sdk_core10.pkhDid)(session.address, session.chainId);
|
|
25141
25160
|
for (const permission of permissions) {
|
|
25142
|
-
if (permission.service ===
|
|
25161
|
+
if (permission.service === import_sdk_core10.ENCRYPTION_PERMISSION_SERVICE && !(0, import_sdk_core10.principalDidEquals)((0, import_sdk_core10.parseNetworkId)(permission.path).ownerDid, ownerDid)) {
|
|
25143
25162
|
throw new Error("Owner delegation cannot grant a foreign encryption network");
|
|
25144
25163
|
}
|
|
25145
25164
|
}
|
|
@@ -25160,7 +25179,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
25160
25179
|
const signature2 = await this.signer.signMessage(prepared.siwe);
|
|
25161
25180
|
assertOwnerGraphActive();
|
|
25162
25181
|
const delegationSession = this.wasmBindings.completeSessionSetup({ ...prepared, signature: signature2 });
|
|
25163
|
-
const activation = await (0,
|
|
25182
|
+
const activation = await (0, import_sdk_core10.activateSessionWithHost)(host, delegationSession.delegationHeader);
|
|
25164
25183
|
assertOwnerGraphActive();
|
|
25165
25184
|
if (!activation.success) {
|
|
25166
25185
|
throw Object.assign(
|
|
@@ -25221,7 +25240,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
25221
25240
|
/** Register a signed policy and sibling roots with this Node's Policy/v3 runtime. */
|
|
25222
25241
|
async registerPolicy(params) {
|
|
25223
25242
|
this._serviceGraph.assertActive();
|
|
25224
|
-
return (0,
|
|
25243
|
+
return (0, import_sdk_core10.registerPolicyV3)({
|
|
25225
25244
|
...params,
|
|
25226
25245
|
nodeOrigin: this.config.host,
|
|
25227
25246
|
fetch: globalThis.fetch.bind(globalThis)
|
|
@@ -25248,23 +25267,23 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
25248
25267
|
jti: base64UrlEncode(jtiDigest.slice(0, 16)),
|
|
25249
25268
|
expiresAt: new Date(input.expiresAt).toISOString().replace(/\.\d{3}Z$/, "Z")
|
|
25250
25269
|
};
|
|
25251
|
-
const requestBodyDigest = base64UrlEncode(new Uint8Array(await crypto.subtle.digest("SHA-256", new TextEncoder().encode((0,
|
|
25270
|
+
const requestBodyDigest = base64UrlEncode(new Uint8Array(await crypto.subtle.digest("SHA-256", new TextEncoder().encode((0, import_sdk_core10.canonicalizeEncryptionJson)(body)))));
|
|
25252
25271
|
const request = { ...body, requestBodyDigest };
|
|
25253
25272
|
const authorization = authorizationHeader(this.wasmBindings.invoke(serviceSession, "kv", input.resourcePath, "tinycloud.kv/get"));
|
|
25254
25273
|
const response = await fetch(`${this.config.host}/policy/v3/deliveries/authorize`, {
|
|
25255
25274
|
method: "POST",
|
|
25256
25275
|
headers: { accept: "application/json", "content-type": "application/json", authorization },
|
|
25257
|
-
body: (0,
|
|
25276
|
+
body: (0, import_sdk_core10.canonicalizeEncryptionJson)(request)
|
|
25258
25277
|
});
|
|
25259
|
-
if (!response.ok) throw await (0,
|
|
25260
|
-
const verified = (0,
|
|
25278
|
+
if (!response.ok) throw await (0, import_sdk_core10.httpResponseError)(response, "V3 share delivery authorization failed");
|
|
25279
|
+
const verified = (0, import_sdk_core10.validateShareDeliveryAuthorizationV3Bytes)(new Uint8Array(await response.arrayBuffer()), {
|
|
25261
25280
|
request,
|
|
25262
25281
|
senderKeyDid: this.credentialHolderDid,
|
|
25263
25282
|
deliveryAudience: input.deliveryAudience
|
|
25264
25283
|
});
|
|
25265
25284
|
const requestDigest = new Uint8Array(await crypto.subtle.digest(
|
|
25266
25285
|
"SHA-256",
|
|
25267
|
-
new TextEncoder().encode(`${
|
|
25286
|
+
new TextEncoder().encode(`${import_sdk_core10.CREDENTIAL_INVITATION_REQUEST_DOMAIN}${(0, import_sdk_core10.canonicalizeEncryptionJson)(verified.request)}`)
|
|
25268
25287
|
));
|
|
25269
25288
|
return {
|
|
25270
25289
|
...verified,
|
|
@@ -25332,7 +25351,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
25332
25351
|
if (!this._sql) {
|
|
25333
25352
|
const features = this.nodeFeatures;
|
|
25334
25353
|
if (features.length > 0 && !features.includes("sql")) {
|
|
25335
|
-
throw new
|
|
25354
|
+
throw new import_sdk_core10.UnsupportedFeatureError("sql", this.config.host, features);
|
|
25336
25355
|
}
|
|
25337
25356
|
throw new Error("Not signed in. Call signIn() first.");
|
|
25338
25357
|
}
|
|
@@ -25356,7 +25375,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
25356
25375
|
if (!this._serviceContext || !this._serviceContext.session) {
|
|
25357
25376
|
throw new Error("Not signed in. Call signIn() first.");
|
|
25358
25377
|
}
|
|
25359
|
-
const sql = new
|
|
25378
|
+
const sql = new import_sdk_core10.SQLService({});
|
|
25360
25379
|
const spaceScopedContext = this._serviceGraph.track(createServiceContext({
|
|
25361
25380
|
requestSink: this._serviceGraph.requestSink,
|
|
25362
25381
|
invoke: this._serviceContext.invoke,
|
|
@@ -25388,7 +25407,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
25388
25407
|
if (!this._serviceContext || !this._serviceContext.session) {
|
|
25389
25408
|
throw new Error("Not signed in. Call signIn() first.");
|
|
25390
25409
|
}
|
|
25391
|
-
const kv = new
|
|
25410
|
+
const kv = new import_sdk_core10.KVService({});
|
|
25392
25411
|
const spaceScopedContext = this._serviceGraph.track(createServiceContext({
|
|
25393
25412
|
requestSink: this._serviceGraph.requestSink,
|
|
25394
25413
|
invoke: this._serviceContext.invoke,
|
|
@@ -25408,7 +25427,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
25408
25427
|
if (!this._duckdb) {
|
|
25409
25428
|
const features = this.nodeFeatures;
|
|
25410
25429
|
if (features.length > 0 && !features.includes("duckdb")) {
|
|
25411
|
-
throw new
|
|
25430
|
+
throw new import_sdk_core10.UnsupportedFeatureError("duckdb", this.config.host, features);
|
|
25412
25431
|
}
|
|
25413
25432
|
throw new Error("Not signed in. Call signIn() first.");
|
|
25414
25433
|
}
|
|
@@ -25452,7 +25471,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
25452
25471
|
type: NETWORK_ADMIN_TYPE,
|
|
25453
25472
|
targetNode,
|
|
25454
25473
|
networkId,
|
|
25455
|
-
bodyHash: (0,
|
|
25474
|
+
bodyHash: (0, import_sdk_core10.canonicalHashHex)(
|
|
25456
25475
|
crypto3.sha256,
|
|
25457
25476
|
body
|
|
25458
25477
|
),
|
|
@@ -25470,7 +25489,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
25470
25489
|
Authorization: signed2.authorization,
|
|
25471
25490
|
"Content-Type": "application/json"
|
|
25472
25491
|
},
|
|
25473
|
-
body: (0,
|
|
25492
|
+
body: (0, import_sdk_core10.canonicalizeEncryptionJson)(
|
|
25474
25493
|
body
|
|
25475
25494
|
)
|
|
25476
25495
|
});
|
|
@@ -25482,7 +25501,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
25482
25501
|
);
|
|
25483
25502
|
}
|
|
25484
25503
|
if (!response.ok) {
|
|
25485
|
-
throw await (0,
|
|
25504
|
+
throw await (0, import_sdk_core10.httpResponseError)(response, `Failed to create encryption network ${networkId}`);
|
|
25486
25505
|
}
|
|
25487
25506
|
const created = await response.json();
|
|
25488
25507
|
return created.descriptor;
|
|
@@ -25501,7 +25520,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
25501
25520
|
return existing;
|
|
25502
25521
|
}
|
|
25503
25522
|
}
|
|
25504
|
-
const parsed = (0,
|
|
25523
|
+
const parsed = (0, import_sdk_core10.parseNetworkId)(networkId);
|
|
25505
25524
|
if (!didPrincipalMatches2(parsed.ownerDid, this.did)) {
|
|
25506
25525
|
throw new Error(
|
|
25507
25526
|
`Cannot create encryption network ${networkId}: owner ${parsed.ownerDid} does not match signed-in DID ${this.did}`
|
|
@@ -25550,7 +25569,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
25550
25569
|
* normal KV and encryption invocation paths.
|
|
25551
25570
|
*/
|
|
25552
25571
|
async readSecret(input) {
|
|
25553
|
-
const resolved = (0,
|
|
25572
|
+
const resolved = (0, import_sdk_core10.resolveSecretPath)(input.name, { scope: input.scope });
|
|
25554
25573
|
const targetSpace = input.space.startsWith("tinycloud:") ? input.space : this.ownedSpaceId(input.space);
|
|
25555
25574
|
const result = await this.getBaseVault(targetSpace).readNetworkEncrypted(
|
|
25556
25575
|
resolved.vaultKey
|
|
@@ -25584,7 +25603,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
25584
25603
|
const resolvedSpace = spaceId.startsWith("tinycloud:") ? spaceId : this.ownedSpaceId(spaceId);
|
|
25585
25604
|
let secrets = this._baseSecrets.get(resolvedSpace);
|
|
25586
25605
|
if (!secrets) {
|
|
25587
|
-
secrets = new
|
|
25606
|
+
secrets = new import_sdk_core10.SecretsService(() => this.getBaseVault(resolvedSpace));
|
|
25588
25607
|
this._baseSecrets.set(resolvedSpace, secrets);
|
|
25589
25608
|
}
|
|
25590
25609
|
return secrets;
|
|
@@ -25727,7 +25746,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
25727
25746
|
for (const grant of this.runtimePermissionGrants) {
|
|
25728
25747
|
if (grant.provenance === "primary") continue;
|
|
25729
25748
|
for (const operation of grant.operations) {
|
|
25730
|
-
const service =
|
|
25749
|
+
const service = import_sdk_core10.SERVICE_SHORT_TO_LONG[operation.service];
|
|
25731
25750
|
if (service === void 0 || typeof operation.path !== "string" || typeof operation.action !== "string") {
|
|
25732
25751
|
continue;
|
|
25733
25752
|
}
|
|
@@ -25745,7 +25764,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
25745
25764
|
service,
|
|
25746
25765
|
...space === void 0 ? {} : { space },
|
|
25747
25766
|
path: operation.path,
|
|
25748
|
-
caveats: (0,
|
|
25767
|
+
caveats: (0, import_sdk_core10.canonicalizeRecapCaveats)(caveats)
|
|
25749
25768
|
});
|
|
25750
25769
|
const existing = grouped.get(identity);
|
|
25751
25770
|
if (existing === void 0) {
|
|
@@ -25790,7 +25809,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
25790
25809
|
delegationCid: grant.delegationCid,
|
|
25791
25810
|
spaceId: grant.spaceId,
|
|
25792
25811
|
jwk: this.sessionKeyJwk,
|
|
25793
|
-
address: (0,
|
|
25812
|
+
address: (0, import_sdk_core10.canonicalizeAddress)(grant.address),
|
|
25794
25813
|
chainId: grant.chainId,
|
|
25795
25814
|
siwe: grant.siwe,
|
|
25796
25815
|
signature: grant.signature
|
|
@@ -25812,10 +25831,10 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
25812
25831
|
const graph = this._serviceGraph;
|
|
25813
25832
|
const session = this.currentTinyCloudSession();
|
|
25814
25833
|
if (!session) {
|
|
25815
|
-
throw new
|
|
25834
|
+
throw new import_sdk_core10.SessionExpiredError(/* @__PURE__ */ new Date(0));
|
|
25816
25835
|
}
|
|
25817
25836
|
if (delegation.expiry.getTime() <= Date.now()) {
|
|
25818
|
-
throw new
|
|
25837
|
+
throw new import_sdk_core10.SessionExpiredError(delegation.expiry);
|
|
25819
25838
|
}
|
|
25820
25839
|
const expectedDids = [session.verificationMethod, this.sessionDid];
|
|
25821
25840
|
if (!expectedDids.some((did) => didPrincipalMatches2(delegation.delegateDID, did))) {
|
|
@@ -25826,7 +25845,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
25826
25845
|
const targetHost = delegation.host ?? this.config.host;
|
|
25827
25846
|
let activateResult;
|
|
25828
25847
|
try {
|
|
25829
|
-
activateResult = await (0,
|
|
25848
|
+
activateResult = await (0, import_sdk_core10.activateSessionWithHost)(
|
|
25830
25849
|
targetHost,
|
|
25831
25850
|
delegation.delegationHeader,
|
|
25832
25851
|
graph.signal
|
|
@@ -25872,13 +25891,13 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
25872
25891
|
const graph = this._serviceGraph;
|
|
25873
25892
|
const session = this.currentTinyCloudSession();
|
|
25874
25893
|
if (!session) {
|
|
25875
|
-
throw new
|
|
25894
|
+
throw new import_sdk_core10.SessionExpiredError(/* @__PURE__ */ new Date(0));
|
|
25876
25895
|
}
|
|
25877
25896
|
const sessionExpiry = extractSiweExpiration(session.siwe);
|
|
25878
25897
|
if (sessionExpiry !== void 0) {
|
|
25879
25898
|
const marginMs = _TinyCloudNode.SESSION_EXPIRY_SAFETY_MARGIN_MS;
|
|
25880
25899
|
if (sessionExpiry.getTime() <= Date.now() + marginMs) {
|
|
25881
|
-
throw new
|
|
25900
|
+
throw new import_sdk_core10.SessionExpiredError(sessionExpiry);
|
|
25882
25901
|
}
|
|
25883
25902
|
}
|
|
25884
25903
|
const expanded = this.expandPermissionEntries(permissions);
|
|
@@ -25955,7 +25974,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
25955
25974
|
...prepared,
|
|
25956
25975
|
signature: signature2
|
|
25957
25976
|
});
|
|
25958
|
-
const activateResult = await (0,
|
|
25977
|
+
const activateResult = await (0, import_sdk_core10.activateSessionWithHost)(
|
|
25959
25978
|
this.config.host,
|
|
25960
25979
|
delegatedSession.delegationHeader,
|
|
25961
25980
|
graph.signal
|
|
@@ -26128,10 +26147,10 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
26128
26147
|
}
|
|
26129
26148
|
await this.assertMayCreateSpace();
|
|
26130
26149
|
await this.auth.hostPublicSpace(publicSpaceId);
|
|
26131
|
-
const kvActions = [
|
|
26150
|
+
const kvActions = [import_sdk_core10.KV.PUT, import_sdk_core10.KV.GET, import_sdk_core10.KV.DEL, import_sdk_core10.KV.LIST, import_sdk_core10.KV.METADATA];
|
|
26132
26151
|
const abilities = { kv: { "": kvActions } };
|
|
26133
26152
|
const now = /* @__PURE__ */ new Date();
|
|
26134
|
-
const expiryMs =
|
|
26153
|
+
const expiryMs = import_sdk_core10.EXPIRY.EPHEMERAL_MS;
|
|
26135
26154
|
const expirationTime = new Date(now.getTime() + expiryMs);
|
|
26136
26155
|
const prepared = this.wasmBindings.prepareSession({
|
|
26137
26156
|
abilities,
|
|
@@ -26149,7 +26168,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
26149
26168
|
...prepared,
|
|
26150
26169
|
signature: signature2
|
|
26151
26170
|
});
|
|
26152
|
-
const activateResult = await (0,
|
|
26171
|
+
const activateResult = await (0, import_sdk_core10.activateSessionWithHost)(
|
|
26153
26172
|
this.config.host,
|
|
26154
26173
|
delegationSession.delegationHeader
|
|
26155
26174
|
);
|
|
@@ -26179,7 +26198,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
26179
26198
|
}]);
|
|
26180
26199
|
}
|
|
26181
26200
|
if (this._serviceContext) {
|
|
26182
|
-
const publicKV = new
|
|
26201
|
+
const publicKV = new import_sdk_core10.KVService({ prefix: "" });
|
|
26183
26202
|
const publicContext = this._serviceGraph.track(createServiceContext({
|
|
26184
26203
|
requestSink: this._serviceGraph.requestSink,
|
|
26185
26204
|
invoke: this._serviceGraph.invoke,
|
|
@@ -26304,14 +26323,14 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
26304
26323
|
}
|
|
26305
26324
|
const session = this.currentTinyCloudSession();
|
|
26306
26325
|
if (!session) {
|
|
26307
|
-
throw new
|
|
26326
|
+
throw new import_sdk_core10.SessionExpiredError(/* @__PURE__ */ new Date(0));
|
|
26308
26327
|
}
|
|
26309
26328
|
const sessionExpiry = extractSiweExpiration(session.siwe);
|
|
26310
26329
|
if (sessionExpiry !== void 0) {
|
|
26311
26330
|
const now2 = Date.now();
|
|
26312
26331
|
const marginMs = _TinyCloudNode.SESSION_EXPIRY_SAFETY_MARGIN_MS;
|
|
26313
26332
|
if (sessionExpiry.getTime() <= now2 + marginMs) {
|
|
26314
|
-
throw new
|
|
26333
|
+
throw new import_sdk_core10.SessionExpiredError(sessionExpiry);
|
|
26315
26334
|
}
|
|
26316
26335
|
}
|
|
26317
26336
|
if (!Array.isArray(permissions) || permissions.length === 0) {
|
|
@@ -26352,12 +26371,12 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
26352
26371
|
);
|
|
26353
26372
|
if ("refused" in plan) {
|
|
26354
26373
|
if (plan.refused === "SESSION_EXPIRING") {
|
|
26355
|
-
throw new
|
|
26374
|
+
throw new import_sdk_core10.SessionExpiredError(plan.expiredAt ?? sessionExpiry ?? /* @__PURE__ */ new Date(0));
|
|
26356
26375
|
}
|
|
26357
26376
|
if (plan.refused === "CAVEATED_AUTHORITY") {
|
|
26358
|
-
throw new
|
|
26377
|
+
throw new import_sdk_core10.CaveatedDelegationUnsupportedError(plan.caveated ?? []);
|
|
26359
26378
|
}
|
|
26360
|
-
throw new
|
|
26379
|
+
throw new import_sdk_core10.PermissionNotInManifestError(plan.missing ?? [], plan.granted ?? []);
|
|
26361
26380
|
}
|
|
26362
26381
|
if (plan.path === "runtime") {
|
|
26363
26382
|
const delegation2 = await this.createDelegationViaRuntimeGrant(
|
|
@@ -26396,7 +26415,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
26396
26415
|
*/
|
|
26397
26416
|
planDerivation(expandedEntries, session, effectiveExpiration, nowMs) {
|
|
26398
26417
|
const caveatedRequest = expandedEntries.filter(
|
|
26399
|
-
(entry) => !(0,
|
|
26418
|
+
(entry) => !(0, import_sdk_core10.recapCaveatsEqual)(entry.caveats, void 0)
|
|
26400
26419
|
);
|
|
26401
26420
|
if (caveatedRequest.length > 0) {
|
|
26402
26421
|
return { refused: "CAVEATED_AUTHORITY", caveated: caveatedRequest };
|
|
@@ -26537,7 +26556,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
26537
26556
|
}, getNodeReplicationLoaders().gatedNetwork);
|
|
26538
26557
|
return;
|
|
26539
26558
|
}
|
|
26540
|
-
const identityPrincipal = principal ?? (this._address === void 0 ? void 0 : (0,
|
|
26559
|
+
const identityPrincipal = principal ?? (this._address === void 0 ? void 0 : (0, import_sdk_core10.pkhDid)(this._address, this._chainId));
|
|
26541
26560
|
if (identityPrincipal === void 0) return;
|
|
26542
26561
|
const authority = await this.replicationAuthority();
|
|
26543
26562
|
if (epoch !== this.sessionEpoch || attempt !== this.latestSessionAttempt || this._kv !== kv || this._serviceContext !== context) return;
|
|
@@ -26633,7 +26652,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
26633
26652
|
const spaceId = resolvedSpaces.size === 1 ? [...resolvedSpaces][0] : session.spaceId;
|
|
26634
26653
|
const abilities = {};
|
|
26635
26654
|
for (const entry of entries) {
|
|
26636
|
-
const shortService =
|
|
26655
|
+
const shortService = import_sdk_core10.SERVICE_LONG_TO_SHORT[entry.service];
|
|
26637
26656
|
if (shortService === void 0) {
|
|
26638
26657
|
throw new Error(
|
|
26639
26658
|
`delegateTo: unknown service '${entry.service}' \u2014 no short-form mapping`
|
|
@@ -26690,7 +26709,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
26690
26709
|
if (onPrepared) {
|
|
26691
26710
|
await onPrepared(delegation);
|
|
26692
26711
|
}
|
|
26693
|
-
const activateResult = await (0,
|
|
26712
|
+
const activateResult = await (0, import_sdk_core10.activateSessionWithHost)(
|
|
26694
26713
|
this.config.host,
|
|
26695
26714
|
delegationHeader
|
|
26696
26715
|
);
|
|
@@ -26727,7 +26746,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
26727
26746
|
if (onPrepared) {
|
|
26728
26747
|
await onPrepared(delegation);
|
|
26729
26748
|
}
|
|
26730
|
-
const activateResult = await (0,
|
|
26749
|
+
const activateResult = await (0, import_sdk_core10.activateSessionWithHost)(
|
|
26731
26750
|
targetHost,
|
|
26732
26751
|
delegationHeader
|
|
26733
26752
|
);
|
|
@@ -26751,7 +26770,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
26751
26770
|
return this.wasmBindings.makeSpaceId(session.address, session.chainId, space);
|
|
26752
26771
|
}
|
|
26753
26772
|
expandPermissionEntries(permissions) {
|
|
26754
|
-
return (0,
|
|
26773
|
+
return (0, import_sdk_core10.expandPermissionEntries)(permissions);
|
|
26755
26774
|
}
|
|
26756
26775
|
/**
|
|
26757
26776
|
* The current WASM child-delegation APIs accept action-only maps. Refuse any
|
|
@@ -26759,10 +26778,10 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
26759
26778
|
*/
|
|
26760
26779
|
assertDelegationCaveatsPreservable(entries) {
|
|
26761
26780
|
const caveated = entries.filter(
|
|
26762
|
-
(entry) => !(0,
|
|
26781
|
+
(entry) => !(0, import_sdk_core10.recapCaveatsEqual)(entry.caveats, void 0)
|
|
26763
26782
|
);
|
|
26764
26783
|
if (caveated.length > 0) {
|
|
26765
|
-
throw new
|
|
26784
|
+
throw new import_sdk_core10.CaveatedDelegationUnsupportedError(caveated);
|
|
26766
26785
|
}
|
|
26767
26786
|
}
|
|
26768
26787
|
/**
|
|
@@ -26774,7 +26793,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
26774
26793
|
assertRuntimeGrantCaveatsPreservable(entries, requestedOperations, grant) {
|
|
26775
26794
|
const caveated = this.caveatedRuntimeGrantEntries(entries, requestedOperations, grant);
|
|
26776
26795
|
if (caveated.length > 0) {
|
|
26777
|
-
throw new
|
|
26796
|
+
throw new import_sdk_core10.CaveatedDelegationUnsupportedError(caveated);
|
|
26778
26797
|
}
|
|
26779
26798
|
}
|
|
26780
26799
|
/**
|
|
@@ -26791,7 +26810,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
26791
26810
|
const requested = requestedOperations[operationIndex++];
|
|
26792
26811
|
if (!requested) continue;
|
|
26793
26812
|
const constrained = grant.operations.find(
|
|
26794
|
-
(granted) => this.operationCovers(granted, requested) && !(0,
|
|
26813
|
+
(granted) => this.operationCovers(granted, requested) && !(0, import_sdk_core10.recapCaveatsEqual)(granted.caveats, void 0)
|
|
26795
26814
|
);
|
|
26796
26815
|
if (constrained) {
|
|
26797
26816
|
caveated.push({
|
|
@@ -26808,7 +26827,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
26808
26827
|
assertPortableDelegationCaveatsPreservable(delegation) {
|
|
26809
26828
|
const entries = [];
|
|
26810
26829
|
const add3 = (service, space, path, actions, caveats) => {
|
|
26811
|
-
if ((0,
|
|
26830
|
+
if ((0, import_sdk_core10.recapCaveatsEqual)(caveats, void 0)) return;
|
|
26812
26831
|
entries.push({
|
|
26813
26832
|
service: service.startsWith("tinycloud.") ? service : `tinycloud.${service}`,
|
|
26814
26833
|
space,
|
|
@@ -26828,11 +26847,11 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
26828
26847
|
add3(resource.service, resource.space, resource.path, resource.actions, resource.caveats);
|
|
26829
26848
|
}
|
|
26830
26849
|
if (entries.length > 0) {
|
|
26831
|
-
throw new
|
|
26850
|
+
throw new import_sdk_core10.CaveatedDelegationUnsupportedError(entries);
|
|
26832
26851
|
}
|
|
26833
26852
|
}
|
|
26834
26853
|
shortServiceName(service) {
|
|
26835
|
-
const short =
|
|
26854
|
+
const short = import_sdk_core10.SERVICE_LONG_TO_SHORT[service];
|
|
26836
26855
|
if (short === void 0) {
|
|
26837
26856
|
throw new Error(
|
|
26838
26857
|
`unknown service '${service}' \u2014 no short-form mapping`
|
|
@@ -26859,7 +26878,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
26859
26878
|
return abilities;
|
|
26860
26879
|
}
|
|
26861
26880
|
isEncryptionPermissionEntry(entry) {
|
|
26862
|
-
return entry.service ===
|
|
26881
|
+
return entry.service === import_sdk_core10.ENCRYPTION_PERMISSION_SERVICE && this.isEncryptionNetworkOperation("encryption", entry.path, entry.space);
|
|
26863
26882
|
}
|
|
26864
26883
|
isRawRevocationPermissionEntry(entry) {
|
|
26865
26884
|
return entry.service === "tinycloud.delegation" && entry.path === "" && entry.space?.startsWith("urn:cid:") === true && entry.actions.includes("tinycloud.delegation/revoke");
|
|
@@ -26907,7 +26926,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
26907
26926
|
const missing = requested.filter((entry) => {
|
|
26908
26927
|
const raw = this.isEncryptionPermissionEntry(entry) || this.isRawRevocationPermissionEntry(entry);
|
|
26909
26928
|
const comparable = raw && this.isEncryptionPermissionEntry(entry) ? { ...entry, space: "encryption" } : entry;
|
|
26910
|
-
return !(0,
|
|
26929
|
+
return !(0, import_sdk_core10.isCapabilitySubset)([comparable], raw ? rawGranted : spaceGranted).subset;
|
|
26911
26930
|
});
|
|
26912
26931
|
return { subset: missing.length === 0, missing };
|
|
26913
26932
|
}
|
|
@@ -27154,7 +27173,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
27154
27173
|
if (granted.service !== requested.service || !this.actionContains(granted.action, requested.action)) {
|
|
27155
27174
|
return false;
|
|
27156
27175
|
}
|
|
27157
|
-
if (requested.caveats !== void 0 && !(0,
|
|
27176
|
+
if (requested.caveats !== void 0 && !(0, import_sdk_core10.recapCaveatsEqual)(granted.caveats, requested.caveats)) {
|
|
27158
27177
|
return false;
|
|
27159
27178
|
}
|
|
27160
27179
|
if (granted.resource !== void 0 || requested.resource !== void 0) {
|
|
@@ -27176,7 +27195,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
27176
27195
|
if (grantedAction === requestedAction) {
|
|
27177
27196
|
return true;
|
|
27178
27197
|
}
|
|
27179
|
-
if ((0,
|
|
27198
|
+
if ((0, import_sdk_core10.isExplicitOnlyAction)(requestedAction)) {
|
|
27180
27199
|
return false;
|
|
27181
27200
|
}
|
|
27182
27201
|
if (grantedAction.endsWith("/*")) {
|
|
@@ -27288,7 +27307,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
27288
27307
|
if (resolvedDelegateDID.endsWith(".eth") && this.config.ensResolver) {
|
|
27289
27308
|
const address = await this.config.ensResolver.resolveAddress(resolvedDelegateDID);
|
|
27290
27309
|
if (!address) throw new Error(`Could not resolve ENS name: ${resolvedDelegateDID}`);
|
|
27291
|
-
resolvedDelegateDID = (0,
|
|
27310
|
+
resolvedDelegateDID = (0, import_sdk_core10.pkhDid)(address, 1);
|
|
27292
27311
|
}
|
|
27293
27312
|
const entries = legacyParamsToPermissionEntries(
|
|
27294
27313
|
params.actions,
|
|
@@ -27302,7 +27321,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
27302
27321
|
});
|
|
27303
27322
|
return result.delegation;
|
|
27304
27323
|
} catch (err2) {
|
|
27305
|
-
if (err2 instanceof
|
|
27324
|
+
if (err2 instanceof import_sdk_core10.PermissionNotInManifestError) {
|
|
27306
27325
|
} else {
|
|
27307
27326
|
throw err2;
|
|
27308
27327
|
}
|
|
@@ -27362,7 +27381,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
27362
27381
|
...prepared,
|
|
27363
27382
|
signature: signature2
|
|
27364
27383
|
});
|
|
27365
|
-
const activateResult = await (0,
|
|
27384
|
+
const activateResult = await (0, import_sdk_core10.activateSessionWithHost)(
|
|
27366
27385
|
this.config.host,
|
|
27367
27386
|
delegationSession.delegationHeader
|
|
27368
27387
|
);
|
|
@@ -27387,12 +27406,12 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
27387
27406
|
};
|
|
27388
27407
|
const hasKvActions = params.actions.some((a) => a.startsWith("tinycloud.kv/"));
|
|
27389
27408
|
if (hasKvActions && params.includePublicSpace !== false) {
|
|
27390
|
-
const publicSpaceId = (0,
|
|
27409
|
+
const publicSpaceId = (0, import_sdk_core10.makePublicSpaceId)(
|
|
27391
27410
|
this.wasmBindings.ensureEip55(session.address),
|
|
27392
27411
|
session.chainId
|
|
27393
27412
|
);
|
|
27394
27413
|
const publicAbilities = {
|
|
27395
|
-
kv: { "": [
|
|
27414
|
+
kv: { "": [import_sdk_core10.KV.GET, import_sdk_core10.KV.PUT, import_sdk_core10.KV.METADATA] }
|
|
27396
27415
|
};
|
|
27397
27416
|
const publicPrepared = this.wasmBindings.prepareSession({
|
|
27398
27417
|
abilities: publicAbilities,
|
|
@@ -27410,7 +27429,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
27410
27429
|
...publicPrepared,
|
|
27411
27430
|
signature: publicSignature
|
|
27412
27431
|
});
|
|
27413
|
-
const publicActivateResult = await (0,
|
|
27432
|
+
const publicActivateResult = await (0, import_sdk_core10.activateSessionWithHost)(
|
|
27414
27433
|
this.config.host,
|
|
27415
27434
|
publicSession.delegationHeader
|
|
27416
27435
|
);
|
|
@@ -27420,7 +27439,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
27420
27439
|
delegationHeader: publicSession.delegationHeader,
|
|
27421
27440
|
spaceId: publicSpaceId,
|
|
27422
27441
|
path: "",
|
|
27423
|
-
actions: [
|
|
27442
|
+
actions: [import_sdk_core10.KV.GET, import_sdk_core10.KV.PUT, import_sdk_core10.KV.METADATA],
|
|
27424
27443
|
disableSubDelegation: false,
|
|
27425
27444
|
expiry: expirationTime,
|
|
27426
27445
|
delegateDID: params.delegateDID,
|
|
@@ -27518,7 +27537,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
27518
27537
|
...prepared,
|
|
27519
27538
|
signature: signature2
|
|
27520
27539
|
});
|
|
27521
|
-
const activateResult = await (0,
|
|
27540
|
+
const activateResult = await (0, import_sdk_core10.activateSessionWithHost)(
|
|
27522
27541
|
targetHost,
|
|
27523
27542
|
invokerSession.delegationHeader,
|
|
27524
27543
|
graph.signal
|
|
@@ -27579,6 +27598,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
27579
27598
|
*/
|
|
27580
27599
|
async createSubDelegation(parentDelegation, params) {
|
|
27581
27600
|
this.assertPortableDelegationCaveatsPreservable(parentDelegation);
|
|
27601
|
+
refuseCaveated(params.resources);
|
|
27582
27602
|
if (!this.signer) {
|
|
27583
27603
|
throw new Error("Cannot createSubDelegation() in session-only mode. Requires wallet mode.");
|
|
27584
27604
|
}
|
|
@@ -27647,7 +27667,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
27647
27667
|
...prepared,
|
|
27648
27668
|
signature: signature2
|
|
27649
27669
|
});
|
|
27650
|
-
const activateResult = await (0,
|
|
27670
|
+
const activateResult = await (0, import_sdk_core10.activateSessionWithHost)(
|
|
27651
27671
|
targetHost,
|
|
27652
27672
|
subDelegationSession.delegationHeader
|
|
27653
27673
|
);
|
|
@@ -27713,11 +27733,11 @@ registerReplicationLoaders({
|
|
|
27713
27733
|
});
|
|
27714
27734
|
|
|
27715
27735
|
// src/index.ts
|
|
27716
|
-
var import_sdk_core14 = require("@tinycloud/sdk-core");
|
|
27717
27736
|
var import_sdk_core15 = require("@tinycloud/sdk-core");
|
|
27737
|
+
var import_sdk_core16 = require("@tinycloud/sdk-core");
|
|
27718
27738
|
|
|
27719
27739
|
// src/storage/FileSessionStorage.ts
|
|
27720
|
-
var
|
|
27740
|
+
var import_sdk_core13 = require("@tinycloud/sdk-core");
|
|
27721
27741
|
var import_fs = require("fs");
|
|
27722
27742
|
var import_path = require("path");
|
|
27723
27743
|
var FileSessionStorage = class {
|
|
@@ -27772,7 +27792,7 @@ var FileSessionStorage = class {
|
|
|
27772
27792
|
try {
|
|
27773
27793
|
const data = (0, import_fs.readFileSync)(filePath, "utf-8");
|
|
27774
27794
|
const parsed = JSON.parse(data);
|
|
27775
|
-
const validation = (0,
|
|
27795
|
+
const validation = (0, import_sdk_core13.validatePersistedSessionData)(parsed);
|
|
27776
27796
|
if (!validation.ok) {
|
|
27777
27797
|
console.warn(`Invalid session data for ${address}:`, validation.error.message);
|
|
27778
27798
|
(0, import_fs.unlinkSync)(filePath);
|
|
@@ -27881,7 +27901,6 @@ function wireOpenKeyAuthorize(openkey) {
|
|
|
27881
27901
|
}
|
|
27882
27902
|
|
|
27883
27903
|
// src/index.ts
|
|
27884
|
-
var import_sdk_core16 = require("@tinycloud/sdk-core");
|
|
27885
27904
|
var import_sdk_core17 = require("@tinycloud/sdk-core");
|
|
27886
27905
|
var import_sdk_core18 = require("@tinycloud/sdk-core");
|
|
27887
27906
|
var import_sdk_core19 = require("@tinycloud/sdk-core");
|
|
@@ -27893,6 +27912,7 @@ var import_sdk_core24 = require("@tinycloud/sdk-core");
|
|
|
27893
27912
|
var import_sdk_core25 = require("@tinycloud/sdk-core");
|
|
27894
27913
|
var import_sdk_core26 = require("@tinycloud/sdk-core");
|
|
27895
27914
|
var import_sdk_core27 = require("@tinycloud/sdk-core");
|
|
27915
|
+
var import_sdk_core28 = require("@tinycloud/sdk-core");
|
|
27896
27916
|
|
|
27897
27917
|
// src/replication/sqlite.ts
|
|
27898
27918
|
var import_node_async_hooks = require("async_hooks");
|
|
@@ -27900,7 +27920,7 @@ var import_node_crypto2 = require("crypto");
|
|
|
27900
27920
|
var import_node_fs = require("fs");
|
|
27901
27921
|
var import_promises = require("fs/promises");
|
|
27902
27922
|
var import_node_path = require("path");
|
|
27903
|
-
var
|
|
27923
|
+
var import_sdk_core14 = require("@tinycloud/sdk-core");
|
|
27904
27924
|
var import_sdk_services4 = require("@tinycloud/sdk-services");
|
|
27905
27925
|
var import_contractConstants = require("@tinycloud/sdk-services/kv/replication/contractConstants");
|
|
27906
27926
|
init_authority();
|
|
@@ -28443,7 +28463,7 @@ async function realDirectoryExists(path) {
|
|
|
28443
28463
|
return true;
|
|
28444
28464
|
}
|
|
28445
28465
|
function principalOf(did) {
|
|
28446
|
-
return (0,
|
|
28466
|
+
return (0, import_sdk_core14.principalDid)(did);
|
|
28447
28467
|
}
|
|
28448
28468
|
var BASE32 = "abcdefghijklmnopqrstuvwxyz234567";
|
|
28449
28469
|
function sha256Base32(material) {
|
|
@@ -29058,13 +29078,13 @@ transports_fn = async function() {
|
|
|
29058
29078
|
const device = __privateGet(this, _device);
|
|
29059
29079
|
const fetch2 = spec.fetch ?? globalThis.fetch.bind(globalThis);
|
|
29060
29080
|
return (grant) => {
|
|
29061
|
-
const context = new
|
|
29081
|
+
const context = new import_sdk_core14.ServiceContext({
|
|
29062
29082
|
invoke: wasm.invoke,
|
|
29063
29083
|
invokeAny: wasm.invokeAny,
|
|
29064
29084
|
fetch: fetch2,
|
|
29065
29085
|
hosts: [spec.identity.host]
|
|
29066
29086
|
});
|
|
29067
|
-
const kv = new
|
|
29087
|
+
const kv = new import_sdk_core14.KVService({});
|
|
29068
29088
|
kv.initialize(context);
|
|
29069
29089
|
context.registerService("kv", kv);
|
|
29070
29090
|
context.setSession({
|