@tinycloud/node-sdk 2.4.0-beta.9 → 2.4.1-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{core-iwTdsebf.d.cts → core-D01sn2vf.d.cts} +134 -7
- package/dist/{core-iwTdsebf.d.ts → core-D01sn2vf.d.ts} +134 -7
- package/dist/core.cjs +810 -268
- package/dist/core.cjs.map +1 -1
- package/dist/core.d.cts +2 -2
- package/dist/core.d.ts +2 -2
- package/dist/core.js +601 -54
- package/dist/core.js.map +1 -1
- package/dist/index.cjs +853 -311
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +601 -54
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -17025,135 +17025,143 @@ var require_utils2 = __commonJS({
|
|
|
17025
17025
|
// src/index.ts
|
|
17026
17026
|
var index_exports = {};
|
|
17027
17027
|
__export(index_exports, {
|
|
17028
|
-
ACCOUNT_REGISTRY_PATH: () =>
|
|
17029
|
-
ACCOUNT_REGISTRY_SPACE: () =>
|
|
17030
|
-
AccountService: () =>
|
|
17031
|
-
AutoApproveSpaceCreationHandler: () =>
|
|
17032
|
-
CapabilityKeyRegistry: () =>
|
|
17033
|
-
CapabilityKeyRegistryErrorCodes: () =>
|
|
17034
|
-
DECRYPT_ACTION: () =>
|
|
17035
|
-
DECRYPT_FACT_TYPE: () =>
|
|
17036
|
-
DECRYPT_RESULT_TYPE: () =>
|
|
17037
|
-
DEFAULT_ENCRYPTION_ALG: () =>
|
|
17038
|
-
DEFAULT_KEY_VERSION: () =>
|
|
17039
|
-
DEFAULT_MANIFEST_SPACE: () =>
|
|
17040
|
-
DEFAULT_MANIFEST_VERSION: () =>
|
|
17041
|
-
DEFAULT_SIGNED_READ_URL_EXPIRY_MS: () =>
|
|
17042
|
-
DataVaultService: () =>
|
|
17043
|
-
DatabaseHandle: () =>
|
|
17028
|
+
ACCOUNT_REGISTRY_PATH: () => import_sdk_core11.ACCOUNT_REGISTRY_PATH,
|
|
17029
|
+
ACCOUNT_REGISTRY_SPACE: () => import_sdk_core11.ACCOUNT_REGISTRY_SPACE,
|
|
17030
|
+
AccountService: () => import_sdk_core3.AccountService,
|
|
17031
|
+
AutoApproveSpaceCreationHandler: () => import_sdk_core10.AutoApproveSpaceCreationHandler,
|
|
17032
|
+
CapabilityKeyRegistry: () => import_sdk_core19.CapabilityKeyRegistry,
|
|
17033
|
+
CapabilityKeyRegistryErrorCodes: () => import_sdk_core19.CapabilityKeyRegistryErrorCodes,
|
|
17034
|
+
DECRYPT_ACTION: () => import_sdk_core16.DECRYPT_ACTION,
|
|
17035
|
+
DECRYPT_FACT_TYPE: () => import_sdk_core16.DECRYPT_FACT_TYPE,
|
|
17036
|
+
DECRYPT_RESULT_TYPE: () => import_sdk_core16.DECRYPT_RESULT_TYPE,
|
|
17037
|
+
DEFAULT_ENCRYPTION_ALG: () => import_sdk_core16.DEFAULT_ENCRYPTION_ALG,
|
|
17038
|
+
DEFAULT_KEY_VERSION: () => import_sdk_core16.DEFAULT_KEY_VERSION,
|
|
17039
|
+
DEFAULT_MANIFEST_SPACE: () => import_sdk_core11.DEFAULT_MANIFEST_SPACE,
|
|
17040
|
+
DEFAULT_MANIFEST_VERSION: () => import_sdk_core11.DEFAULT_MANIFEST_VERSION,
|
|
17041
|
+
DEFAULT_SIGNED_READ_URL_EXPIRY_MS: () => import_sdk_core12.DEFAULT_SIGNED_READ_URL_EXPIRY_MS,
|
|
17042
|
+
DataVaultService: () => import_sdk_core15.DataVaultService,
|
|
17043
|
+
DatabaseHandle: () => import_sdk_core13.DatabaseHandle,
|
|
17044
17044
|
DelegatedAccess: () => DelegatedAccess,
|
|
17045
|
-
DelegationErrorCodes: () =>
|
|
17046
|
-
DelegationManager: () =>
|
|
17047
|
-
DuckDbAction: () =>
|
|
17048
|
-
DuckDbDatabaseHandle: () =>
|
|
17049
|
-
DuckDbService: () =>
|
|
17050
|
-
ENCRYPTION_NETWORK_URN_PREFIX: () =>
|
|
17051
|
-
ENCRYPTION_SERVICE: () =>
|
|
17052
|
-
ENCRYPTION_SERVICE_SHORT: () =>
|
|
17053
|
-
ENVELOPE_VERSION: () =>
|
|
17054
|
-
EncryptionService: () =>
|
|
17045
|
+
DelegationErrorCodes: () => import_sdk_core18.DelegationErrorCodes,
|
|
17046
|
+
DelegationManager: () => import_sdk_core18.DelegationManager,
|
|
17047
|
+
DuckDbAction: () => import_sdk_core14.DuckDbAction,
|
|
17048
|
+
DuckDbDatabaseHandle: () => import_sdk_core14.DuckDbDatabaseHandle,
|
|
17049
|
+
DuckDbService: () => import_sdk_core14.DuckDbService,
|
|
17050
|
+
ENCRYPTION_NETWORK_URN_PREFIX: () => import_sdk_core16.ENCRYPTION_NETWORK_URN_PREFIX,
|
|
17051
|
+
ENCRYPTION_SERVICE: () => import_sdk_core16.ENCRYPTION_SERVICE,
|
|
17052
|
+
ENCRYPTION_SERVICE_SHORT: () => import_sdk_core16.ENCRYPTION_SERVICE_SHORT,
|
|
17053
|
+
ENVELOPE_VERSION: () => import_sdk_core16.ENVELOPE_VERSION,
|
|
17054
|
+
EncryptionService: () => import_sdk_core16.EncryptionService,
|
|
17055
17055
|
FileSessionStorage: () => FileSessionStorage,
|
|
17056
|
-
HooksService: () =>
|
|
17057
|
-
IdentityParseError: () =>
|
|
17058
|
-
KVService: () =>
|
|
17059
|
-
ManifestValidationError: () =>
|
|
17056
|
+
HooksService: () => import_sdk_core17.HooksService,
|
|
17057
|
+
IdentityParseError: () => import_sdk_core10.IdentityParseError,
|
|
17058
|
+
KVService: () => import_sdk_core12.KVService,
|
|
17059
|
+
ManifestValidationError: () => import_sdk_core11.ManifestValidationError,
|
|
17060
17060
|
MemorySessionStorage: () => MemorySessionStorage,
|
|
17061
|
-
NETWORK_NAME_PATTERN: () =>
|
|
17062
|
-
NetworkIdError: () =>
|
|
17061
|
+
NETWORK_NAME_PATTERN: () => import_sdk_core16.NETWORK_NAME_PATTERN,
|
|
17062
|
+
NetworkIdError: () => import_sdk_core16.NetworkIdError,
|
|
17063
17063
|
NodeUserAuthorization: () => NodeUserAuthorization,
|
|
17064
17064
|
NodeWasmBindings: () => NodeWasmBindings,
|
|
17065
|
-
PermissionNotInManifestError: () =>
|
|
17066
|
-
PrefixedKVService: () =>
|
|
17065
|
+
PermissionNotInManifestError: () => import_sdk_core11.PermissionNotInManifestError,
|
|
17066
|
+
PrefixedKVService: () => import_sdk_core12.PrefixedKVService,
|
|
17067
17067
|
PrivateKeySigner: () => PrivateKeySigner,
|
|
17068
|
-
ProtocolMismatchError: () =>
|
|
17069
|
-
SECRET_NAME_RE: () =>
|
|
17070
|
-
SQLAction: () =>
|
|
17071
|
-
SQLService: () =>
|
|
17072
|
-
SecretsService: () =>
|
|
17073
|
-
ServiceContext: () =>
|
|
17074
|
-
SessionExpiredError: () =>
|
|
17075
|
-
SharingService: () =>
|
|
17076
|
-
SilentNotificationHandler: () =>
|
|
17077
|
-
Space: () =>
|
|
17078
|
-
SpaceErrorCodes: () =>
|
|
17079
|
-
SpaceService: () =>
|
|
17080
|
-
TinyCloud: () =>
|
|
17068
|
+
ProtocolMismatchError: () => import_sdk_core21.ProtocolMismatchError,
|
|
17069
|
+
SECRET_NAME_RE: () => import_sdk_core15.SECRET_NAME_RE,
|
|
17070
|
+
SQLAction: () => import_sdk_core13.SQLAction,
|
|
17071
|
+
SQLService: () => import_sdk_core13.SQLService,
|
|
17072
|
+
SecretsService: () => import_sdk_core15.SecretsService,
|
|
17073
|
+
ServiceContext: () => import_sdk_core22.ServiceContext,
|
|
17074
|
+
SessionExpiredError: () => import_sdk_core11.SessionExpiredError,
|
|
17075
|
+
SharingService: () => import_sdk_core18.SharingService,
|
|
17076
|
+
SilentNotificationHandler: () => import_sdk_core10.SilentNotificationHandler,
|
|
17077
|
+
Space: () => import_sdk_core20.Space,
|
|
17078
|
+
SpaceErrorCodes: () => import_sdk_core20.SpaceErrorCodes,
|
|
17079
|
+
SpaceService: () => import_sdk_core20.SpaceService,
|
|
17080
|
+
TinyCloud: () => import_sdk_core9.TinyCloud,
|
|
17081
|
+
TinyCloudDebugLogger: () => import_sdk_core10.TinyCloudDebugLogger,
|
|
17081
17082
|
TinyCloudNode: () => TinyCloudNode,
|
|
17082
|
-
UnsupportedFeatureError: () =>
|
|
17083
|
-
VAULT_PERMISSION_SERVICE: () =>
|
|
17084
|
-
VaultHeaders: () =>
|
|
17085
|
-
VaultPublicSpaceKVActions: () =>
|
|
17086
|
-
VersionCheckError: () =>
|
|
17083
|
+
UnsupportedFeatureError: () => import_sdk_core21.UnsupportedFeatureError,
|
|
17084
|
+
VAULT_PERMISSION_SERVICE: () => import_sdk_core11.VAULT_PERMISSION_SERVICE,
|
|
17085
|
+
VaultHeaders: () => import_sdk_core15.VaultHeaders,
|
|
17086
|
+
VaultPublicSpaceKVActions: () => import_sdk_core15.VaultPublicSpaceKVActions,
|
|
17087
|
+
VersionCheckError: () => import_sdk_core21.VersionCheckError,
|
|
17087
17088
|
WasmKeyProvider: () => WasmKeyProvider,
|
|
17088
|
-
addressStorageKey: () =>
|
|
17089
|
-
buildCanonicalDecryptRequest: () =>
|
|
17090
|
-
buildDecryptAttenuation: () =>
|
|
17091
|
-
buildDecryptFacts: () =>
|
|
17092
|
-
buildDecryptInvocation: () =>
|
|
17093
|
-
buildNetworkId: () =>
|
|
17094
|
-
buildSpaceUri: () =>
|
|
17095
|
-
canonicalHashHex: () =>
|
|
17096
|
-
canonicalSignedResponse: () =>
|
|
17097
|
-
canonicalizeAddress: () =>
|
|
17098
|
-
canonicalizeDid: () =>
|
|
17099
|
-
canonicalizeDidUrl: () =>
|
|
17100
|
-
canonicalizeEncryptionJson: () =>
|
|
17101
|
-
canonicalizeNetworkId: () =>
|
|
17102
|
-
canonicalizeSecretScope: () =>
|
|
17103
|
-
checkDecryptInvocationInput: () =>
|
|
17104
|
-
checkNodeInfo: () =>
|
|
17105
|
-
|
|
17106
|
-
|
|
17107
|
-
|
|
17108
|
-
|
|
17109
|
-
|
|
17089
|
+
addressStorageKey: () => import_sdk_core10.addressStorageKey,
|
|
17090
|
+
buildCanonicalDecryptRequest: () => import_sdk_core16.buildCanonicalDecryptRequest,
|
|
17091
|
+
buildDecryptAttenuation: () => import_sdk_core16.buildDecryptAttenuation,
|
|
17092
|
+
buildDecryptFacts: () => import_sdk_core16.buildDecryptFacts,
|
|
17093
|
+
buildDecryptInvocation: () => import_sdk_core16.buildDecryptInvocation,
|
|
17094
|
+
buildNetworkId: () => import_sdk_core16.buildNetworkId,
|
|
17095
|
+
buildSpaceUri: () => import_sdk_core20.buildSpaceUri,
|
|
17096
|
+
canonicalHashHex: () => import_sdk_core16.canonicalHashHex,
|
|
17097
|
+
canonicalSignedResponse: () => import_sdk_core16.canonicalSignedResponse,
|
|
17098
|
+
canonicalizeAddress: () => import_sdk_core10.canonicalizeAddress,
|
|
17099
|
+
canonicalizeDid: () => import_sdk_core10.canonicalizeDid,
|
|
17100
|
+
canonicalizeDidUrl: () => import_sdk_core10.canonicalizeDidUrl,
|
|
17101
|
+
canonicalizeEncryptionJson: () => import_sdk_core16.canonicalizeEncryptionJson,
|
|
17102
|
+
canonicalizeNetworkId: () => import_sdk_core10.canonicalizeNetworkId,
|
|
17103
|
+
canonicalizeSecretScope: () => import_sdk_core15.canonicalizeSecretScope,
|
|
17104
|
+
checkDecryptInvocationInput: () => import_sdk_core16.checkDecryptInvocationInput,
|
|
17105
|
+
checkNodeInfo: () => import_sdk_core21.checkNodeInfo,
|
|
17106
|
+
clearTinyCloudDebugLogs: () => import_sdk_core10.clearTinyCloudDebugLogs,
|
|
17107
|
+
composeManifestRequest: () => import_sdk_core11.composeManifestRequest,
|
|
17108
|
+
createCapabilityKeyRegistry: () => import_sdk_core19.createCapabilityKeyRegistry,
|
|
17109
|
+
createOpenKeyCallbackSigningStrategy: () => import_sdk_core.createOpenKeyCallbackSigningStrategy,
|
|
17110
|
+
createSharingService: () => import_sdk_core18.createSharingService,
|
|
17111
|
+
createSpaceService: () => import_sdk_core20.createSpaceService,
|
|
17112
|
+
createVaultCrypto: () => import_sdk_core15.createVaultCrypto,
|
|
17110
17113
|
createWasmKeyProvider: () => createWasmKeyProvider,
|
|
17111
|
-
decryptEnvelopeWithKey: () =>
|
|
17114
|
+
decryptEnvelopeWithKey: () => import_sdk_core16.decryptEnvelopeWithKey,
|
|
17112
17115
|
defaultSignStrategy: () => defaultSignStrategy,
|
|
17113
|
-
defaultSpaceCreationHandler: () =>
|
|
17114
|
-
deriveSignedReceiverKey: () =>
|
|
17116
|
+
defaultSpaceCreationHandler: () => import_sdk_core10.defaultSpaceCreationHandler,
|
|
17117
|
+
deriveSignedReceiverKey: () => import_sdk_core16.deriveSignedReceiverKey,
|
|
17115
17118
|
deserializeDelegation: () => deserializeDelegation,
|
|
17116
|
-
didCacheKey: () =>
|
|
17117
|
-
didEquals: () =>
|
|
17118
|
-
|
|
17119
|
-
|
|
17120
|
-
|
|
17121
|
-
|
|
17122
|
-
|
|
17123
|
-
|
|
17124
|
-
|
|
17125
|
-
|
|
17126
|
-
|
|
17127
|
-
|
|
17128
|
-
|
|
17129
|
-
|
|
17119
|
+
didCacheKey: () => import_sdk_core10.didCacheKey,
|
|
17120
|
+
didEquals: () => import_sdk_core10.didEquals,
|
|
17121
|
+
disableTinyCloudDebug: () => import_sdk_core10.disableTinyCloudDebug,
|
|
17122
|
+
discoverNetwork: () => import_sdk_core16.discoverNetwork,
|
|
17123
|
+
enableTinyCloudDebug: () => import_sdk_core10.enableTinyCloudDebug,
|
|
17124
|
+
encryptToNetwork: () => import_sdk_core16.encryptToNetwork,
|
|
17125
|
+
encryptionBase64Decode: () => import_sdk_core16.encryptionBase64Decode,
|
|
17126
|
+
encryptionBase64Encode: () => import_sdk_core16.encryptionBase64Encode,
|
|
17127
|
+
encryptionError: () => import_sdk_core16.encryptionError,
|
|
17128
|
+
encryptionUtf8Decode: () => import_sdk_core16.encryptionUtf8Decode,
|
|
17129
|
+
encryptionUtf8Encode: () => import_sdk_core16.encryptionUtf8Encode,
|
|
17130
|
+
ensureNetworkUsableForDecrypt: () => import_sdk_core16.ensureNetworkUsableForDecrypt,
|
|
17131
|
+
expandActionShortNames: () => import_sdk_core11.expandActionShortNames,
|
|
17132
|
+
expandPermissionEntries: () => import_sdk_core11.expandPermissionEntries,
|
|
17133
|
+
expandPermissionEntry: () => import_sdk_core11.expandPermissionEntry,
|
|
17134
|
+
generateRandomReceiverKey: () => import_sdk_core16.generateRandomReceiverKey,
|
|
17135
|
+
getTinyCloudDebugLogs: () => import_sdk_core10.getTinyCloudDebugLogs,
|
|
17130
17136
|
grantAuthRequest: () => grantAuthRequest,
|
|
17131
|
-
hexDecode: () =>
|
|
17132
|
-
hexEncode: () =>
|
|
17133
|
-
|
|
17134
|
-
|
|
17135
|
-
|
|
17136
|
-
|
|
17137
|
-
|
|
17138
|
-
|
|
17139
|
-
|
|
17140
|
-
|
|
17141
|
-
|
|
17142
|
-
|
|
17143
|
-
|
|
17144
|
-
|
|
17145
|
-
|
|
17146
|
-
|
|
17147
|
-
|
|
17148
|
-
|
|
17149
|
-
|
|
17150
|
-
|
|
17151
|
-
|
|
17152
|
-
|
|
17137
|
+
hexDecode: () => import_sdk_core16.hexDecode,
|
|
17138
|
+
hexEncode: () => import_sdk_core16.hexEncode,
|
|
17139
|
+
installTinyCloudDebugGlobals: () => import_sdk_core10.installTinyCloudDebugGlobals,
|
|
17140
|
+
isCapabilitySubset: () => import_sdk_core11.isCapabilitySubset,
|
|
17141
|
+
isEvmAddress: () => import_sdk_core10.isEvmAddress,
|
|
17142
|
+
isNetworkId: () => import_sdk_core16.isNetworkId,
|
|
17143
|
+
loadManifest: () => import_sdk_core11.loadManifest,
|
|
17144
|
+
makePkhSpaceId: () => import_sdk_core10.makePkhSpaceId,
|
|
17145
|
+
makePublicSpaceId: () => import_sdk_core20.makePublicSpaceId,
|
|
17146
|
+
networkDiscoveryKey: () => import_sdk_core16.networkDiscoveryKey,
|
|
17147
|
+
openWrappedKey: () => import_sdk_core16.openWrappedKey,
|
|
17148
|
+
parseCanonicalNetworkId: () => import_sdk_core10.parseCanonicalNetworkId,
|
|
17149
|
+
parseExpiry: () => import_sdk_core11.parseExpiry,
|
|
17150
|
+
parseNetworkId: () => import_sdk_core16.parseNetworkId,
|
|
17151
|
+
parsePkhDid: () => import_sdk_core10.parsePkhDid,
|
|
17152
|
+
parseSpaceUri: () => import_sdk_core20.parseSpaceUri,
|
|
17153
|
+
pkhDid: () => import_sdk_core10.pkhDid,
|
|
17154
|
+
principalDid: () => import_sdk_core10.principalDid,
|
|
17155
|
+
principalDidEquals: () => import_sdk_core10.principalDidEquals,
|
|
17156
|
+
resolveManifest: () => import_sdk_core11.resolveManifest,
|
|
17157
|
+
resolveSecretListPrefix: () => import_sdk_core15.resolveSecretListPrefix,
|
|
17158
|
+
resolveSecretPath: () => import_sdk_core15.resolveSecretPath,
|
|
17159
|
+
resourceCapabilitiesToSpaceAbilitiesMap: () => import_sdk_core11.resourceCapabilitiesToSpaceAbilitiesMap,
|
|
17153
17160
|
serializeDelegation: () => serializeDelegation,
|
|
17154
|
-
|
|
17155
|
-
|
|
17156
|
-
|
|
17161
|
+
tinyCloudDebugLogger: () => import_sdk_core10.tinyCloudDebugLogger,
|
|
17162
|
+
validateEnvelope: () => import_sdk_core16.validateEnvelope,
|
|
17163
|
+
validateManifest: () => import_sdk_core11.validateManifest,
|
|
17164
|
+
verifyDecryptResponse: () => import_sdk_core16.verifyDecryptResponse
|
|
17157
17165
|
});
|
|
17158
17166
|
module.exports = __toCommonJS(index_exports);
|
|
17159
17167
|
|
|
@@ -17258,12 +17266,13 @@ var PrivateKeySigner = class {
|
|
|
17258
17266
|
};
|
|
17259
17267
|
|
|
17260
17268
|
// src/TinyCloudNode.ts
|
|
17261
|
-
var
|
|
17269
|
+
var import_sdk_core7 = require("@tinycloud/sdk-core");
|
|
17262
17270
|
|
|
17263
17271
|
// src/authorization/NodeUserAuthorization.ts
|
|
17264
|
-
var
|
|
17272
|
+
var import_sdk_core2 = require("@tinycloud/sdk-core");
|
|
17265
17273
|
|
|
17266
17274
|
// src/authorization/strategies.ts
|
|
17275
|
+
var import_sdk_core = require("@tinycloud/sdk-core");
|
|
17267
17276
|
var defaultSignStrategy = { type: "auto-sign" };
|
|
17268
17277
|
|
|
17269
17278
|
// src/storage/MemorySessionStorage.ts
|
|
@@ -17342,7 +17351,7 @@ var DECRYPT_ACTION = "tinycloud.encryption/decrypt";
|
|
|
17342
17351
|
var NETWORK_CREATE_ACTION = "tinycloud.encryption/network.create";
|
|
17343
17352
|
function didPrincipalMatches(actual, expected) {
|
|
17344
17353
|
try {
|
|
17345
|
-
return (0,
|
|
17354
|
+
return (0, import_sdk_core2.principalDidEquals)(actual, expected);
|
|
17346
17355
|
} catch {
|
|
17347
17356
|
return actual === expected;
|
|
17348
17357
|
}
|
|
@@ -17361,6 +17370,7 @@ var NodeUserAuthorization = class {
|
|
|
17361
17370
|
constructor(config) {
|
|
17362
17371
|
this.extensions = [];
|
|
17363
17372
|
this._nodeFeatures = [];
|
|
17373
|
+
this._lastActivationSkippedSpaceIds = [];
|
|
17364
17374
|
this.wasm = config.wasmBindings;
|
|
17365
17375
|
this.signer = config.signer;
|
|
17366
17376
|
this.signStrategy = config.signStrategy ?? defaultSignStrategy;
|
|
@@ -17383,7 +17393,7 @@ var NodeUserAuthorization = class {
|
|
|
17383
17393
|
"": [
|
|
17384
17394
|
"tinycloud.sql/read",
|
|
17385
17395
|
"tinycloud.sql/write",
|
|
17386
|
-
"tinycloud.sql/
|
|
17396
|
+
"tinycloud.sql/schema",
|
|
17387
17397
|
"tinycloud.sql/admin",
|
|
17388
17398
|
"tinycloud.sql/export"
|
|
17389
17399
|
]
|
|
@@ -17411,7 +17421,7 @@ var NodeUserAuthorization = class {
|
|
|
17411
17421
|
]
|
|
17412
17422
|
}
|
|
17413
17423
|
};
|
|
17414
|
-
this.sessionExpirationMs = config.sessionExpirationMs ??
|
|
17424
|
+
this.sessionExpirationMs = config.sessionExpirationMs ?? import_sdk_core2.EXPIRY.SESSION_MS;
|
|
17415
17425
|
this.autoCreateSpace = config.autoCreateSpace ?? false;
|
|
17416
17426
|
this.spaceCreationHandler = config.spaceCreationHandler;
|
|
17417
17427
|
this.tinycloudHosts = config.tinycloudHosts;
|
|
@@ -17475,19 +17485,55 @@ var NodeUserAuthorization = class {
|
|
|
17475
17485
|
* `siwe` is the load-bearing one because `extractSiweExpiration` returns
|
|
17476
17486
|
* undefined for missing SIWEs and the SDK then treats the session as
|
|
17477
17487
|
* expired-at-epoch-zero.
|
|
17488
|
+
*
|
|
17489
|
+
* @param hosts - The TinyCloud hosts this session was created against,
|
|
17490
|
+
* as persisted in {@link PersistedSessionData.tinycloudHosts}. When
|
|
17491
|
+
* present (and non-empty) they are adopted directly so the restored
|
|
17492
|
+
* session resolves to the same node as the original sign-in without
|
|
17493
|
+
* re-running registry/fallback resolution. When absent (old session)
|
|
17494
|
+
* hosts are resolved lazily on the first host-needing call via
|
|
17495
|
+
* {@link ensureTinyCloudHosts}.
|
|
17478
17496
|
*/
|
|
17479
|
-
setRestoredTinyCloudSession(session) {
|
|
17480
|
-
const address = (0,
|
|
17497
|
+
setRestoredTinyCloudSession(session, hosts) {
|
|
17498
|
+
const address = (0, import_sdk_core2.canonicalizeAddress)(session.address);
|
|
17481
17499
|
this._tinyCloudSession = { ...session, address };
|
|
17482
17500
|
this._address = address;
|
|
17483
17501
|
this._chainId = session.chainId;
|
|
17502
|
+
if ((!this.tinycloudHosts || this.tinycloudHosts.length === 0) && hosts && hosts.length > 0) {
|
|
17503
|
+
this.tinycloudHosts = [...hosts];
|
|
17504
|
+
}
|
|
17505
|
+
}
|
|
17506
|
+
/**
|
|
17507
|
+
* Ensure `tinycloudHosts` are resolved before a host-needing call.
|
|
17508
|
+
*
|
|
17509
|
+
* Fresh sign-in resolves hosts up front; a restored session may not have
|
|
17510
|
+
* (old persisted sessions predate {@link PersistedSessionData.tinycloudHosts}).
|
|
17511
|
+
* This guard makes a restored session resolve the node exactly like a fresh
|
|
17512
|
+
* sign-in — persisted hosts are preferred (already set by
|
|
17513
|
+
* {@link setRestoredTinyCloudSession}), otherwise the registry/fallback
|
|
17514
|
+
* resolution runs lazily here. Idempotent: {@link resolveTinyCloudHostsForSignIn}
|
|
17515
|
+
* early-returns when hosts are already set.
|
|
17516
|
+
*
|
|
17517
|
+
* Throws if hosts are unset and the restored session has no address/chainId
|
|
17518
|
+
* to resolve from — a real failure that must surface, not be masked.
|
|
17519
|
+
*/
|
|
17520
|
+
async ensureTinyCloudHosts() {
|
|
17521
|
+
if (this.tinycloudHosts && this.tinycloudHosts.length > 0) {
|
|
17522
|
+
return;
|
|
17523
|
+
}
|
|
17524
|
+
if (this._address === void 0 || this._chainId === void 0) {
|
|
17525
|
+
throw new Error(
|
|
17526
|
+
"Cannot resolve TinyCloud hosts: no address/chainId available. Sign in or restore a session first."
|
|
17527
|
+
);
|
|
17528
|
+
}
|
|
17529
|
+
await this.resolveTinyCloudHostsForSignIn(this._address, this._chainId);
|
|
17484
17530
|
}
|
|
17485
17531
|
async resolveTinyCloudHostsForSignIn(address, chainId) {
|
|
17486
17532
|
if (this.tinycloudHosts && this.tinycloudHosts.length > 0) {
|
|
17487
17533
|
return;
|
|
17488
17534
|
}
|
|
17489
|
-
const subject = (0,
|
|
17490
|
-
const resolved = await (0,
|
|
17535
|
+
const subject = (0, import_sdk_core2.pkhDid)(address, chainId);
|
|
17536
|
+
const resolved = await (0, import_sdk_core2.resolveTinyCloudHosts)(subject, {
|
|
17491
17537
|
registryUrl: this.tinycloudRegistryUrl,
|
|
17492
17538
|
fallbackHosts: this.tinycloudFallbackHosts
|
|
17493
17539
|
});
|
|
@@ -17505,6 +17551,9 @@ var NodeUserAuthorization = class {
|
|
|
17505
17551
|
get nodeFeatures() {
|
|
17506
17552
|
return this._nodeFeatures;
|
|
17507
17553
|
}
|
|
17554
|
+
get lastActivationSkippedSpaceIds() {
|
|
17555
|
+
return [...this._lastActivationSkippedSpaceIds];
|
|
17556
|
+
}
|
|
17508
17557
|
/**
|
|
17509
17558
|
* Compute the `abilities` map the WASM `prepareSession` call should
|
|
17510
17559
|
* see at sign-in time.
|
|
@@ -17538,7 +17587,7 @@ var NodeUserAuthorization = class {
|
|
|
17538
17587
|
if (this._manifest === void 0) {
|
|
17539
17588
|
return void 0;
|
|
17540
17589
|
}
|
|
17541
|
-
this._capabilityRequest = (0,
|
|
17590
|
+
this._capabilityRequest = (0, import_sdk_core2.composeManifestRequest)(
|
|
17542
17591
|
Array.isArray(this._manifest) ? this._manifest : [this._manifest],
|
|
17543
17592
|
{
|
|
17544
17593
|
includeAccountRegistryPermissions: this.includeAccountRegistryPermissions
|
|
@@ -17550,17 +17599,17 @@ var NodeUserAuthorization = class {
|
|
|
17550
17599
|
if (space.startsWith("tinycloud:")) {
|
|
17551
17600
|
return space;
|
|
17552
17601
|
}
|
|
17553
|
-
return (0,
|
|
17602
|
+
return (0, import_sdk_core2.makePkhSpaceId)(address, chainId, space);
|
|
17554
17603
|
}
|
|
17555
17604
|
defaultEncryptionNetworkId(address, chainId) {
|
|
17556
|
-
return `urn:tinycloud:encryption:${(0,
|
|
17605
|
+
return `urn:tinycloud:encryption:${(0, import_sdk_core2.pkhDid)(address, chainId)}:default`;
|
|
17557
17606
|
}
|
|
17558
17607
|
resolveSignInCapabilities(address, chainId) {
|
|
17559
17608
|
const request = this.getCapabilityRequest();
|
|
17560
17609
|
if (request === void 0) {
|
|
17561
17610
|
const defaultNetworkId = this.defaultEncryptionNetworkId(address, chainId);
|
|
17562
|
-
const primarySpaceId2 = (0,
|
|
17563
|
-
const secretsSpaceId = (0,
|
|
17611
|
+
const primarySpaceId2 = (0, import_sdk_core2.makePkhSpaceId)(address, chainId, this.spacePrefix);
|
|
17612
|
+
const secretsSpaceId = (0, import_sdk_core2.makePkhSpaceId)(address, chainId, "secrets");
|
|
17564
17613
|
return {
|
|
17565
17614
|
abilities: this.defaultActions,
|
|
17566
17615
|
spaceId: primarySpaceId2,
|
|
@@ -17587,35 +17636,35 @@ var NodeUserAuthorization = class {
|
|
|
17587
17636
|
};
|
|
17588
17637
|
}
|
|
17589
17638
|
const rawAbilities = {};
|
|
17590
|
-
const currentDid = (0,
|
|
17639
|
+
const currentDid = (0, import_sdk_core2.pkhDid)(address, chainId);
|
|
17591
17640
|
const spaceResources = request.resources.filter((entry) => {
|
|
17592
|
-
if (entry.service !==
|
|
17641
|
+
if (entry.service !== import_sdk_core2.ENCRYPTION_PERMISSION_SERVICE) {
|
|
17593
17642
|
return true;
|
|
17594
17643
|
}
|
|
17595
17644
|
for (const action of entry.actions) {
|
|
17596
17645
|
addRawAbility(rawAbilities, entry.path, action);
|
|
17597
17646
|
}
|
|
17598
17647
|
if (entry.actions.includes(DECRYPT_ACTION)) {
|
|
17599
|
-
const parsed = (0,
|
|
17648
|
+
const parsed = (0, import_sdk_core2.parseNetworkId)(entry.path);
|
|
17600
17649
|
if (didPrincipalMatches(parsed.ownerDid, currentDid)) {
|
|
17601
17650
|
addRawAbility(rawAbilities, entry.path, NETWORK_CREATE_ACTION);
|
|
17602
17651
|
}
|
|
17603
17652
|
}
|
|
17604
17653
|
return false;
|
|
17605
17654
|
});
|
|
17606
|
-
const primarySpaceName = spaceResources.find((entry) => entry.space !== "account")?.space ??
|
|
17655
|
+
const primarySpaceName = spaceResources.find((entry) => entry.space !== "account")?.space ?? import_sdk_core2.DEFAULT_MANIFEST_SPACE;
|
|
17607
17656
|
const primarySpaceId = this.resolveSpaceName(
|
|
17608
17657
|
primarySpaceName,
|
|
17609
17658
|
address,
|
|
17610
17659
|
chainId
|
|
17611
17660
|
);
|
|
17612
|
-
const bySpace = (0,
|
|
17661
|
+
const bySpace = (0, import_sdk_core2.resourceCapabilitiesToSpaceAbilitiesMap)(spaceResources);
|
|
17613
17662
|
const spaceAbilities = {};
|
|
17614
17663
|
for (const [space, abilities] of Object.entries(bySpace)) {
|
|
17615
17664
|
spaceAbilities[this.resolveSpaceName(space, address, chainId)] = abilities;
|
|
17616
17665
|
}
|
|
17617
17666
|
return {
|
|
17618
|
-
abilities: spaceAbilities[primarySpaceId] ?? (0,
|
|
17667
|
+
abilities: spaceAbilities[primarySpaceId] ?? (0, import_sdk_core2.resourceCapabilitiesToAbilitiesMap)([]),
|
|
17619
17668
|
spaceId: primarySpaceId,
|
|
17620
17669
|
spaceAbilities,
|
|
17621
17670
|
rawAbilities: Object.keys(rawAbilities).length > 0 ? rawAbilities : void 0
|
|
@@ -17677,9 +17726,10 @@ var NodeUserAuthorization = class {
|
|
|
17677
17726
|
if (!this._tinyCloudSession || !this._address || !this._chainId) {
|
|
17678
17727
|
throw new Error("Must be signed in to host space");
|
|
17679
17728
|
}
|
|
17729
|
+
await this.ensureTinyCloudHosts();
|
|
17680
17730
|
const host = this.primaryTinyCloudHost;
|
|
17681
17731
|
const spaceId = targetSpaceId ?? this._tinyCloudSession.spaceId;
|
|
17682
|
-
const peerId = await (0,
|
|
17732
|
+
const peerId = await (0, import_sdk_core2.fetchPeerId)(host, spaceId);
|
|
17683
17733
|
const siwe = this.wasm.generateHostSIWEMessage({
|
|
17684
17734
|
address: this._address,
|
|
17685
17735
|
chainId: this._chainId,
|
|
@@ -17690,7 +17740,7 @@ var NodeUserAuthorization = class {
|
|
|
17690
17740
|
});
|
|
17691
17741
|
const signature2 = await this.signMessage(siwe);
|
|
17692
17742
|
const headers = this.wasm.siweToDelegationHeaders({ siwe, signature: signature2 });
|
|
17693
|
-
const result = await (0,
|
|
17743
|
+
const result = await (0, import_sdk_core2.submitHostDelegation)(host, headers);
|
|
17694
17744
|
return result.success;
|
|
17695
17745
|
}
|
|
17696
17746
|
/**
|
|
@@ -17719,13 +17769,15 @@ var NodeUserAuthorization = class {
|
|
|
17719
17769
|
if (!this._tinyCloudSession) {
|
|
17720
17770
|
throw new Error("Must be signed in to ensure space exists");
|
|
17721
17771
|
}
|
|
17772
|
+
await this.ensureTinyCloudHosts();
|
|
17722
17773
|
const host = this.primaryTinyCloudHost;
|
|
17723
17774
|
const primarySpaceId = this._tinyCloudSession.spaceId;
|
|
17724
|
-
const result = await (0,
|
|
17775
|
+
const result = await (0, import_sdk_core2.activateSessionWithHost)(
|
|
17725
17776
|
host,
|
|
17726
17777
|
this._tinyCloudSession.delegationHeader
|
|
17727
17778
|
);
|
|
17728
|
-
|
|
17779
|
+
this.recordActivationSkippedSpaces(result, primarySpaceId);
|
|
17780
|
+
const handler = this.spaceCreationHandler ?? (this.autoCreateSpace ? new import_sdk_core2.AutoApproveSpaceCreationHandler() : void 0);
|
|
17729
17781
|
const creationContext = {
|
|
17730
17782
|
spaceId: primarySpaceId,
|
|
17731
17783
|
address: this._address,
|
|
@@ -17759,7 +17811,7 @@ var NodeUserAuthorization = class {
|
|
|
17759
17811
|
throw error;
|
|
17760
17812
|
}
|
|
17761
17813
|
await new Promise((resolve) => setTimeout(resolve, 100));
|
|
17762
|
-
const retryResult = await (0,
|
|
17814
|
+
const retryResult = await (0, import_sdk_core2.activateSessionWithHost)(
|
|
17763
17815
|
host,
|
|
17764
17816
|
this._tinyCloudSession.delegationHeader
|
|
17765
17817
|
);
|
|
@@ -17796,7 +17848,7 @@ var NodeUserAuthorization = class {
|
|
|
17796
17848
|
throw error;
|
|
17797
17849
|
}
|
|
17798
17850
|
await new Promise((resolve) => setTimeout(resolve, 100));
|
|
17799
|
-
const retryResult = await (0,
|
|
17851
|
+
const retryResult = await (0, import_sdk_core2.activateSessionWithHost)(
|
|
17800
17852
|
host,
|
|
17801
17853
|
this._tinyCloudSession.delegationHeader
|
|
17802
17854
|
);
|
|
@@ -17812,6 +17864,66 @@ var NodeUserAuthorization = class {
|
|
|
17812
17864
|
}
|
|
17813
17865
|
throw new Error(`Failed to activate session: ${result.error}`);
|
|
17814
17866
|
}
|
|
17867
|
+
recordActivationSkippedSpaces(result, primarySpaceId) {
|
|
17868
|
+
if (result.success) {
|
|
17869
|
+
this._lastActivationSkippedSpaceIds = result.skipped ?? [];
|
|
17870
|
+
return;
|
|
17871
|
+
}
|
|
17872
|
+
this._lastActivationSkippedSpaceIds = result.status === 404 ? [primarySpaceId] : [];
|
|
17873
|
+
}
|
|
17874
|
+
async createBootstrapSession(options) {
|
|
17875
|
+
if (!this._address || !this._chainId) {
|
|
17876
|
+
throw new Error("Must be signed in before creating bootstrap sessions");
|
|
17877
|
+
}
|
|
17878
|
+
const address = this._address;
|
|
17879
|
+
const chainId = this._chainId;
|
|
17880
|
+
const keyId = `bootstrap-${Date.now()}-${Math.random().toString(36).slice(2)}`;
|
|
17881
|
+
this.sessionManager.createSessionKey(keyId);
|
|
17882
|
+
const jwkString = this.sessionManager.jwk(keyId);
|
|
17883
|
+
if (!jwkString) {
|
|
17884
|
+
throw new Error("Failed to create bootstrap session key");
|
|
17885
|
+
}
|
|
17886
|
+
const jwk = JSON.parse(jwkString);
|
|
17887
|
+
const now = /* @__PURE__ */ new Date();
|
|
17888
|
+
const expirationTime = new Date(now.getTime() + this.sessionExpirationMs);
|
|
17889
|
+
const abilities = (0, import_sdk_core2.resourceCapabilitiesToAbilitiesMap)(
|
|
17890
|
+
options.capabilityRequest.resources
|
|
17891
|
+
);
|
|
17892
|
+
const prepared = this.wasm.prepareSession({
|
|
17893
|
+
abilities,
|
|
17894
|
+
...options.rawAbilities !== void 0 ? { rawAbilities: options.rawAbilities } : {},
|
|
17895
|
+
address,
|
|
17896
|
+
chainId,
|
|
17897
|
+
domain: this.domain,
|
|
17898
|
+
issuedAt: now.toISOString(),
|
|
17899
|
+
expirationTime: expirationTime.toISOString(),
|
|
17900
|
+
spaceId: options.spaceId,
|
|
17901
|
+
jwk,
|
|
17902
|
+
...this.buildSiweOverrides()
|
|
17903
|
+
});
|
|
17904
|
+
const signature2 = await this.requestSignature({
|
|
17905
|
+
address,
|
|
17906
|
+
chainId,
|
|
17907
|
+
message: prepared.siwe,
|
|
17908
|
+
type: "siwe"
|
|
17909
|
+
});
|
|
17910
|
+
const session = this.wasm.completeSessionSetup({
|
|
17911
|
+
...prepared,
|
|
17912
|
+
signature: signature2
|
|
17913
|
+
});
|
|
17914
|
+
return {
|
|
17915
|
+
address,
|
|
17916
|
+
chainId,
|
|
17917
|
+
sessionKey: keyId,
|
|
17918
|
+
spaceId: options.spaceId,
|
|
17919
|
+
delegationCid: session.delegationCid,
|
|
17920
|
+
delegationHeader: session.delegationHeader,
|
|
17921
|
+
verificationMethod: this.sessionManager.getDID(keyId),
|
|
17922
|
+
jwk,
|
|
17923
|
+
siwe: prepared.siwe,
|
|
17924
|
+
signature: signature2
|
|
17925
|
+
};
|
|
17926
|
+
}
|
|
17815
17927
|
/**
|
|
17816
17928
|
* Sign in and create a new session.
|
|
17817
17929
|
*
|
|
@@ -17824,7 +17936,7 @@ var NodeUserAuthorization = class {
|
|
|
17824
17936
|
* @param options - Optional per-call SIWE overrides for this sign-in only
|
|
17825
17937
|
*/
|
|
17826
17938
|
async signIn(options) {
|
|
17827
|
-
this._address = (0,
|
|
17939
|
+
this._address = (0, import_sdk_core2.canonicalizeAddress)(await this.signer.getAddress());
|
|
17828
17940
|
this._chainId = await this.signer.getChainId();
|
|
17829
17941
|
const address = this._address;
|
|
17830
17942
|
const chainId = this._chainId;
|
|
@@ -17871,7 +17983,7 @@ var NodeUserAuthorization = class {
|
|
|
17871
17983
|
siwe: prepared.siwe,
|
|
17872
17984
|
signature: signature2
|
|
17873
17985
|
};
|
|
17874
|
-
const spacesMetadata = this.enablePublicSpace ? { public: (0,
|
|
17986
|
+
const spacesMetadata = this.enablePublicSpace ? { public: (0, import_sdk_core2.makePkhSpaceId)(address, chainId, "public") } : void 0;
|
|
17875
17987
|
const tinyCloudSession = {
|
|
17876
17988
|
address,
|
|
17877
17989
|
chainId,
|
|
@@ -17900,14 +18012,15 @@ var NodeUserAuthorization = class {
|
|
|
17900
18012
|
},
|
|
17901
18013
|
expiresAt: expirationTime.toISOString(),
|
|
17902
18014
|
createdAt: now.toISOString(),
|
|
17903
|
-
version: "1.0"
|
|
18015
|
+
version: "1.0",
|
|
18016
|
+
tinycloudHosts: this.tinycloudHosts
|
|
17904
18017
|
};
|
|
17905
18018
|
await this.sessionStorage.save(address, persistedData);
|
|
17906
18019
|
this._session = clientSession;
|
|
17907
18020
|
this._tinyCloudSession = tinyCloudSession;
|
|
17908
18021
|
this._address = address;
|
|
17909
18022
|
this._chainId = chainId;
|
|
17910
|
-
const nodeInfo = await (0,
|
|
18023
|
+
const nodeInfo = await (0, import_sdk_core2.checkNodeInfo)(
|
|
17911
18024
|
this.primaryTinyCloudHost,
|
|
17912
18025
|
this.wasm.protocolVersion()
|
|
17913
18026
|
);
|
|
@@ -17946,7 +18059,7 @@ var NodeUserAuthorization = class {
|
|
|
17946
18059
|
*/
|
|
17947
18060
|
async signMessage(message) {
|
|
17948
18061
|
if (!this._address) {
|
|
17949
|
-
this._address = (0,
|
|
18062
|
+
this._address = (0, import_sdk_core2.canonicalizeAddress)(await this.signer.getAddress());
|
|
17950
18063
|
}
|
|
17951
18064
|
if (!this._chainId) {
|
|
17952
18065
|
this._chainId = await this.signer.getChainId();
|
|
@@ -17973,7 +18086,7 @@ var NodeUserAuthorization = class {
|
|
|
17973
18086
|
* ```
|
|
17974
18087
|
*/
|
|
17975
18088
|
async prepareSessionForSigning() {
|
|
17976
|
-
const address = (0,
|
|
18089
|
+
const address = (0, import_sdk_core2.canonicalizeAddress)(await this.signer.getAddress());
|
|
17977
18090
|
const chainId = await this.signer.getChainId();
|
|
17978
18091
|
const keyId = `session-${Date.now()}`;
|
|
17979
18092
|
this.sessionManager.renameSessionKeyId("default", keyId);
|
|
@@ -18023,7 +18136,7 @@ var NodeUserAuthorization = class {
|
|
|
18023
18136
|
...prepared,
|
|
18024
18137
|
signature: signature2
|
|
18025
18138
|
});
|
|
18026
|
-
const address = (0,
|
|
18139
|
+
const address = (0, import_sdk_core2.canonicalizeAddress)(await this.signer.getAddress());
|
|
18027
18140
|
const chainId = await this.signer.getChainId();
|
|
18028
18141
|
await this.resolveTinyCloudHostsForSignIn(address, chainId);
|
|
18029
18142
|
const clientSession = {
|
|
@@ -18034,7 +18147,7 @@ var NodeUserAuthorization = class {
|
|
|
18034
18147
|
siwe: prepared.siwe,
|
|
18035
18148
|
signature: signature2
|
|
18036
18149
|
};
|
|
18037
|
-
const spacesMetadata = this.enablePublicSpace ? { public: (0,
|
|
18150
|
+
const spacesMetadata = this.enablePublicSpace ? { public: (0, import_sdk_core2.makePkhSpaceId)(address, chainId, "public") } : void 0;
|
|
18038
18151
|
const tinyCloudSession = {
|
|
18039
18152
|
address,
|
|
18040
18153
|
chainId,
|
|
@@ -18067,14 +18180,15 @@ var NodeUserAuthorization = class {
|
|
|
18067
18180
|
},
|
|
18068
18181
|
expiresAt,
|
|
18069
18182
|
createdAt,
|
|
18070
|
-
version: "1.0"
|
|
18183
|
+
version: "1.0",
|
|
18184
|
+
tinycloudHosts: this.tinycloudHosts
|
|
18071
18185
|
};
|
|
18072
18186
|
await this.sessionStorage.save(address, persistedData);
|
|
18073
18187
|
this._session = clientSession;
|
|
18074
18188
|
this._tinyCloudSession = tinyCloudSession;
|
|
18075
18189
|
this._address = address;
|
|
18076
18190
|
this._chainId = chainId;
|
|
18077
|
-
const nodeInfo = await (0,
|
|
18191
|
+
const nodeInfo = await (0, import_sdk_core2.checkNodeInfo)(
|
|
18078
18192
|
this.primaryTinyCloudHost,
|
|
18079
18193
|
this.wasm.protocolVersion()
|
|
18080
18194
|
);
|
|
@@ -18158,32 +18272,33 @@ var NodeUserAuthorization = class {
|
|
|
18158
18272
|
};
|
|
18159
18273
|
|
|
18160
18274
|
// src/account/AccountService.ts
|
|
18161
|
-
var
|
|
18275
|
+
var import_sdk_core3 = require("@tinycloud/sdk-core");
|
|
18162
18276
|
|
|
18163
18277
|
// src/DelegatedAccess.ts
|
|
18164
|
-
var
|
|
18278
|
+
var import_sdk_core4 = require("@tinycloud/sdk-core");
|
|
18165
18279
|
var DelegatedAccess = class {
|
|
18166
|
-
constructor(session, delegation, host, invoke2, telemetry) {
|
|
18280
|
+
constructor(session, delegation, host, invoke2, invokeAny2, telemetry) {
|
|
18167
18281
|
this.session = session;
|
|
18168
18282
|
this._delegation = delegation;
|
|
18169
18283
|
this.host = host;
|
|
18170
|
-
this._serviceContext = new
|
|
18284
|
+
this._serviceContext = new import_sdk_core4.ServiceContext({
|
|
18171
18285
|
invoke: invoke2,
|
|
18286
|
+
invokeAny: invokeAny2,
|
|
18172
18287
|
fetch: globalThis.fetch.bind(globalThis),
|
|
18173
18288
|
hosts: [host],
|
|
18174
18289
|
telemetry
|
|
18175
18290
|
});
|
|
18176
18291
|
const prefix = this._delegation.path.replace(/\/$/, "");
|
|
18177
|
-
this._kv = new
|
|
18292
|
+
this._kv = new import_sdk_core4.KVService({ prefix });
|
|
18178
18293
|
this._kv.initialize(this._serviceContext);
|
|
18179
18294
|
this._serviceContext.registerService("kv", this._kv);
|
|
18180
|
-
this._sql = new
|
|
18295
|
+
this._sql = new import_sdk_core4.SQLService({});
|
|
18181
18296
|
this._sql.initialize(this._serviceContext);
|
|
18182
18297
|
this._serviceContext.registerService("sql", this._sql);
|
|
18183
|
-
this._duckdb = new
|
|
18298
|
+
this._duckdb = new import_sdk_core4.DuckDbService({});
|
|
18184
18299
|
this._duckdb.initialize(this._serviceContext);
|
|
18185
18300
|
this._serviceContext.registerService("duckdb", this._duckdb);
|
|
18186
|
-
this._hooks = new
|
|
18301
|
+
this._hooks = new import_sdk_core4.HooksService({});
|
|
18187
18302
|
this._hooks.initialize(this._serviceContext);
|
|
18188
18303
|
this._serviceContext.registerService("hooks", this._hooks);
|
|
18189
18304
|
const serviceSession = {
|
|
@@ -18333,7 +18448,7 @@ function createWasmKeyProvider(sessionManager) {
|
|
|
18333
18448
|
}
|
|
18334
18449
|
|
|
18335
18450
|
// src/delegateToHelpers.ts
|
|
18336
|
-
var
|
|
18451
|
+
var import_sdk_core5 = require("@tinycloud/sdk-core");
|
|
18337
18452
|
function legacyParamsToPermissionEntries(actions, path, spaceIdOverride) {
|
|
18338
18453
|
const byService = /* @__PURE__ */ new Map();
|
|
18339
18454
|
for (const a of actions) {
|
|
@@ -18364,7 +18479,7 @@ function legacyParamsToPermissionEntries(actions, path, spaceIdOverride) {
|
|
|
18364
18479
|
}
|
|
18365
18480
|
return entries;
|
|
18366
18481
|
}
|
|
18367
|
-
var DEFAULT_DELEGATION_EXPIRY_MS =
|
|
18482
|
+
var DEFAULT_DELEGATION_EXPIRY_MS = import_sdk_core5.EXPIRY.SESSION_MS;
|
|
18368
18483
|
function resolveExpiryMs(expiry) {
|
|
18369
18484
|
if (expiry === void 0) {
|
|
18370
18485
|
return DEFAULT_DELEGATION_EXPIRY_MS;
|
|
@@ -18377,10 +18492,10 @@ function resolveExpiryMs(expiry) {
|
|
|
18377
18492
|
}
|
|
18378
18493
|
return expiry;
|
|
18379
18494
|
}
|
|
18380
|
-
return (0,
|
|
18495
|
+
return (0, import_sdk_core5.parseExpiry)(expiry);
|
|
18381
18496
|
}
|
|
18382
18497
|
function extractSiweExpiration(siwe) {
|
|
18383
|
-
const parsed = new
|
|
18498
|
+
const parsed = new import_sdk_core5.SiweMessage(siwe);
|
|
18384
18499
|
if (parsed.expirationTime === void 0 || parsed.expirationTime === null) {
|
|
18385
18500
|
return void 0;
|
|
18386
18501
|
}
|
|
@@ -18394,7 +18509,7 @@ function extractSiweExpiration(siwe) {
|
|
|
18394
18509
|
}
|
|
18395
18510
|
|
|
18396
18511
|
// src/NodeSecretsService.ts
|
|
18397
|
-
var
|
|
18512
|
+
var import_sdk_core6 = require("@tinycloud/sdk-core");
|
|
18398
18513
|
var SECRETS_SPACE = "secrets";
|
|
18399
18514
|
function ok() {
|
|
18400
18515
|
return { ok: true, data: void 0 };
|
|
@@ -18425,12 +18540,12 @@ function displayActionUrn(action) {
|
|
|
18425
18540
|
function secretActionName(action) {
|
|
18426
18541
|
return action;
|
|
18427
18542
|
}
|
|
18428
|
-
function secretPermissionEntries(name, options, action, encryptionNetworkId) {
|
|
18543
|
+
function secretPermissionEntries(name, options, action, space, encryptionNetworkId) {
|
|
18429
18544
|
const entries = [];
|
|
18430
|
-
const path = action === "list" ? (0,
|
|
18545
|
+
const path = action === "list" ? (0, import_sdk_core6.resolveSecretListPrefix)(options) : (0, import_sdk_core6.resolveSecretPath)(name, options).permissionPaths.vault;
|
|
18431
18546
|
entries.push({
|
|
18432
18547
|
service: "tinycloud.kv",
|
|
18433
|
-
space
|
|
18548
|
+
space,
|
|
18434
18549
|
path,
|
|
18435
18550
|
actions: [secretActionName(action)],
|
|
18436
18551
|
skipPrefix: true
|
|
@@ -18445,11 +18560,23 @@ function secretPermissionEntries(name, options, action, encryptionNetworkId) {
|
|
|
18445
18560
|
}
|
|
18446
18561
|
return entries;
|
|
18447
18562
|
}
|
|
18563
|
+
function normalizeSpace(space, resolveSpace) {
|
|
18564
|
+
if (!space) return void 0;
|
|
18565
|
+
if (space.startsWith("tinycloud:")) return space;
|
|
18566
|
+
return resolveSpace?.(space) ?? space;
|
|
18567
|
+
}
|
|
18568
|
+
function spaceMatches(granted, requested, resolveSpace) {
|
|
18569
|
+
if (!granted || !requested) return false;
|
|
18570
|
+
return normalizeSpace(granted, resolveSpace) === normalizeSpace(requested, resolveSpace);
|
|
18571
|
+
}
|
|
18448
18572
|
var NodeSecretsService = class {
|
|
18449
18573
|
constructor(config) {
|
|
18450
18574
|
this.config = config;
|
|
18451
18575
|
this.shouldRestoreUnlock = false;
|
|
18452
18576
|
}
|
|
18577
|
+
get space() {
|
|
18578
|
+
return this.config.space ?? SECRETS_SPACE;
|
|
18579
|
+
}
|
|
18453
18580
|
get vault() {
|
|
18454
18581
|
return this.service.vault;
|
|
18455
18582
|
}
|
|
@@ -18502,11 +18629,12 @@ var NodeSecretsService = class {
|
|
|
18502
18629
|
name,
|
|
18503
18630
|
options,
|
|
18504
18631
|
action,
|
|
18632
|
+
this.space,
|
|
18505
18633
|
action === "get" ? this.config.getEncryptionNetworkId?.() : void 0
|
|
18506
18634
|
);
|
|
18507
18635
|
} catch (error) {
|
|
18508
18636
|
return secretsError(
|
|
18509
|
-
|
|
18637
|
+
import_sdk_core6.ErrorCodes.INVALID_INPUT,
|
|
18510
18638
|
error instanceof Error ? error.message : String(error),
|
|
18511
18639
|
error instanceof Error ? error : void 0
|
|
18512
18640
|
);
|
|
@@ -18516,7 +18644,7 @@ var NodeSecretsService = class {
|
|
|
18516
18644
|
}
|
|
18517
18645
|
if (!this.config.canEscalate()) {
|
|
18518
18646
|
return secretsError(
|
|
18519
|
-
|
|
18647
|
+
import_sdk_core6.ErrorCodes.PERMISSION_DENIED,
|
|
18520
18648
|
`Cannot autosign ${displayActionUrn(action)} for ${target}; TinyCloudNode needs wallet mode with a signer or privateKey.`
|
|
18521
18649
|
);
|
|
18522
18650
|
}
|
|
@@ -18525,7 +18653,7 @@ var NodeSecretsService = class {
|
|
|
18525
18653
|
return this.restoreUnlockAfterEscalation();
|
|
18526
18654
|
} catch (error) {
|
|
18527
18655
|
return secretsError(
|
|
18528
|
-
|
|
18656
|
+
import_sdk_core6.ErrorCodes.PERMISSION_DENIED,
|
|
18529
18657
|
error instanceof Error ? error.message : `Autosign escalation for ${displayActionUrn(action)} on ${target} failed.`,
|
|
18530
18658
|
error instanceof Error ? error : void 0
|
|
18531
18659
|
);
|
|
@@ -18546,12 +18674,12 @@ var NodeSecretsService = class {
|
|
|
18546
18674
|
return false;
|
|
18547
18675
|
}
|
|
18548
18676
|
const manifests = Array.isArray(manifest) ? manifest : [manifest];
|
|
18549
|
-
const requestedEntries = (0,
|
|
18677
|
+
const requestedEntries = (0, import_sdk_core6.expandPermissionEntries)(permissionEntries);
|
|
18550
18678
|
return requestedEntries.every(
|
|
18551
18679
|
(entry) => manifests.some((candidate) => {
|
|
18552
|
-
const resolved = (0,
|
|
18680
|
+
const resolved = (0, import_sdk_core6.resolveManifest)(candidate);
|
|
18553
18681
|
return resolved.resources.some(
|
|
18554
|
-
(resource) => resource.service === entry.service && resource.space
|
|
18682
|
+
(resource) => resource.service === entry.service && spaceMatches(resource.space, entry.space, this.config.resolveSpace) && resource.path === entry.path && entry.actions.every((action) => resource.actions.includes(action))
|
|
18555
18683
|
);
|
|
18556
18684
|
})
|
|
18557
18685
|
);
|
|
@@ -18564,14 +18692,31 @@ var DEFAULT_ENCRYPTION_NETWORK_NAME = "default";
|
|
|
18564
18692
|
var NETWORK_CREATE_ACTION2 = "tinycloud.encryption/network.create";
|
|
18565
18693
|
var DECRYPT_ACTION2 = "tinycloud.encryption/decrypt";
|
|
18566
18694
|
var NETWORK_ADMIN_TYPE = "tinycloud.encryption.network-admin/v1";
|
|
18567
|
-
var DEFAULT_SESSION_EXPIRATION_MS =
|
|
18695
|
+
var DEFAULT_SESSION_EXPIRATION_MS = import_sdk_core7.EXPIRY.SESSION_MS;
|
|
18696
|
+
function isOpenKeyAutoSignStrategy(strategy) {
|
|
18697
|
+
return strategy?.openKeyAutoSign === true;
|
|
18698
|
+
}
|
|
18568
18699
|
function didPrincipalMatches2(actual, expected) {
|
|
18569
18700
|
try {
|
|
18570
|
-
return (0,
|
|
18701
|
+
return (0, import_sdk_core7.principalDidEquals)(actual, expected);
|
|
18571
18702
|
} catch {
|
|
18572
18703
|
return actual === expected;
|
|
18573
18704
|
}
|
|
18574
18705
|
}
|
|
18706
|
+
function sharingActionsToAbilities(path, actions) {
|
|
18707
|
+
var _a;
|
|
18708
|
+
const abilities = {};
|
|
18709
|
+
for (const action of actions) {
|
|
18710
|
+
const slash = action.indexOf("/");
|
|
18711
|
+
if (slash === -1) return void 0;
|
|
18712
|
+
const shortService = import_sdk_core7.SERVICE_LONG_TO_SHORT[action.slice(0, slash)];
|
|
18713
|
+
if (shortService === void 0) return void 0;
|
|
18714
|
+
abilities[shortService] ?? (abilities[shortService] = {});
|
|
18715
|
+
(_a = abilities[shortService])[path] ?? (_a[path] = []);
|
|
18716
|
+
abilities[shortService][path].push(action);
|
|
18717
|
+
}
|
|
18718
|
+
return Object.keys(abilities).length > 0 ? abilities : void 0;
|
|
18719
|
+
}
|
|
18575
18720
|
function base64UrlEncode(bytes) {
|
|
18576
18721
|
const alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_";
|
|
18577
18722
|
let output = "";
|
|
@@ -18684,6 +18829,8 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
18684
18829
|
this.auth = null;
|
|
18685
18830
|
this.tc = null;
|
|
18686
18831
|
this._chainId = 1;
|
|
18832
|
+
this._baseSecrets = /* @__PURE__ */ new Map();
|
|
18833
|
+
this._secrets = /* @__PURE__ */ new Map();
|
|
18687
18834
|
this.runtimePermissionGrants = [];
|
|
18688
18835
|
this.invokeWithRuntimePermissions = (session, service, path, action, facts) => {
|
|
18689
18836
|
return this.wasmBindings.invoke(
|
|
@@ -18733,12 +18880,12 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
18733
18880
|
throw new Error("Failed to get session key JWK");
|
|
18734
18881
|
}
|
|
18735
18882
|
this.sessionKeyJwk = JSON.parse(jwkStr);
|
|
18736
|
-
this._capabilityRegistry = new
|
|
18883
|
+
this._capabilityRegistry = new import_sdk_core7.CapabilityKeyRegistry();
|
|
18737
18884
|
this._keyProvider = new WasmKeyProvider({
|
|
18738
18885
|
sessionManager: this.sessionManager
|
|
18739
18886
|
});
|
|
18740
|
-
this.notificationHandler = config.notificationHandler ?? new
|
|
18741
|
-
this._sharingService = new
|
|
18887
|
+
this.notificationHandler = config.notificationHandler ?? new import_sdk_core7.SilentNotificationHandler();
|
|
18888
|
+
this._sharingService = new import_sdk_core7.SharingService({
|
|
18742
18889
|
hosts: [this.config.host],
|
|
18743
18890
|
// session: undefined - not needed for receive()
|
|
18744
18891
|
invoke: this.invokeWithRuntimePermissions,
|
|
@@ -18748,8 +18895,8 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
18748
18895
|
// delegationManager: undefined - not needed for receive()
|
|
18749
18896
|
createKVService: (config2) => {
|
|
18750
18897
|
const prefix = config2.pathPrefix?.replace(/\/$/, "");
|
|
18751
|
-
const kvService = new
|
|
18752
|
-
const kvContext = new
|
|
18898
|
+
const kvService = new import_sdk_core7.KVService({ prefix });
|
|
18899
|
+
const kvContext = new import_sdk_core7.ServiceContext({
|
|
18753
18900
|
invoke: config2.invoke,
|
|
18754
18901
|
fetch: config2.fetch ?? globalThis.fetch.bind(globalThis),
|
|
18755
18902
|
hosts: config2.hosts,
|
|
@@ -18789,9 +18936,10 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
18789
18936
|
* @internal
|
|
18790
18937
|
*/
|
|
18791
18938
|
setupAuth(config) {
|
|
18939
|
+
const useBootstrapSignInRequest = this.shouldUseBootstrapSignInRequest(config);
|
|
18792
18940
|
this.auth = new NodeUserAuthorization({
|
|
18793
18941
|
signer: this.signer,
|
|
18794
|
-
signStrategy: { type: "auto-sign" },
|
|
18942
|
+
signStrategy: config.signStrategy ?? { type: "auto-sign" },
|
|
18795
18943
|
wasmBindings: this.wasmBindings,
|
|
18796
18944
|
sessionStorage: config.sessionStorage ?? new MemorySessionStorage(),
|
|
18797
18945
|
domain: this.siweDomain,
|
|
@@ -18800,20 +18948,23 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
18800
18948
|
tinycloudHosts: this.explicitHost ? [this.explicitHost] : void 0,
|
|
18801
18949
|
tinycloudRegistryUrl: config.tinycloudRegistryUrl,
|
|
18802
18950
|
tinycloudFallbackHosts: config.tinycloudFallbackHosts,
|
|
18803
|
-
autoCreateSpace: config.autoCreateSpace,
|
|
18951
|
+
autoCreateSpace: useBootstrapSignInRequest ? false : config.autoCreateSpace,
|
|
18804
18952
|
enablePublicSpace: config.enablePublicSpace ?? true,
|
|
18805
|
-
spaceCreationHandler: config.spaceCreationHandler,
|
|
18953
|
+
spaceCreationHandler: useBootstrapSignInRequest ? void 0 : config.spaceCreationHandler,
|
|
18806
18954
|
nonce: config.nonce,
|
|
18807
18955
|
siweConfig: config.siweConfig,
|
|
18808
|
-
manifest: config.manifest,
|
|
18809
|
-
capabilityRequest: config.capabilityRequest,
|
|
18810
|
-
includeAccountRegistryPermissions: config.includeAccountRegistryPermissions
|
|
18956
|
+
manifest: useBootstrapSignInRequest ? void 0 : config.manifest,
|
|
18957
|
+
capabilityRequest: useBootstrapSignInRequest ? import_sdk_core7.BOOTSTRAP_SESSION_REQUESTS.default : config.capabilityRequest,
|
|
18958
|
+
includeAccountRegistryPermissions: useBootstrapSignInRequest ? false : config.includeAccountRegistryPermissions
|
|
18811
18959
|
});
|
|
18812
|
-
this.tc = new
|
|
18960
|
+
this.tc = new import_sdk_core7.TinyCloud(this.auth, {
|
|
18813
18961
|
invokeAny: this.invokeAnyWithRuntimePermissions,
|
|
18814
18962
|
telemetry: config.telemetry
|
|
18815
18963
|
});
|
|
18816
18964
|
}
|
|
18965
|
+
shouldUseBootstrapSignInRequest(config) {
|
|
18966
|
+
return config.autoBootstrapAccount !== false && config.manifest === void 0 && config.capabilityRequest === void 0 && (config.prefix ?? "default") === "default" && isOpenKeyAutoSignStrategy(config.signStrategy);
|
|
18967
|
+
}
|
|
18817
18968
|
syncResolvedHostFromAuth() {
|
|
18818
18969
|
const host = this.auth?.hosts[0];
|
|
18819
18970
|
if (host) {
|
|
@@ -18870,7 +19021,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
18870
19021
|
*/
|
|
18871
19022
|
get did() {
|
|
18872
19023
|
if (this._address) {
|
|
18873
|
-
return (0,
|
|
19024
|
+
return (0, import_sdk_core7.pkhDid)(this._address, this._chainId);
|
|
18874
19025
|
}
|
|
18875
19026
|
return this.sessionManager.getDID(this.sessionKeyId);
|
|
18876
19027
|
}
|
|
@@ -18912,14 +19063,14 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
18912
19063
|
if (!this._address) {
|
|
18913
19064
|
return void 0;
|
|
18914
19065
|
}
|
|
18915
|
-
return this.wasmBindings.makeSpaceId(this._address, this._chainId,
|
|
19066
|
+
return this.wasmBindings.makeSpaceId(this._address, this._chainId, import_sdk_core7.ACCOUNT_REGISTRY_SPACE);
|
|
18916
19067
|
}
|
|
18917
19068
|
/**
|
|
18918
19069
|
* Account-level application and delegation helpers.
|
|
18919
19070
|
*/
|
|
18920
19071
|
get account() {
|
|
18921
19072
|
if (!this._account) {
|
|
18922
|
-
this._account = new
|
|
19073
|
+
this._account = new import_sdk_core3.AccountService({
|
|
18923
19074
|
getDid: () => this.did,
|
|
18924
19075
|
getHost: () => this.hosts[0] ?? this.config.host,
|
|
18925
19076
|
getPrimarySpaceId: () => this.spaceId,
|
|
@@ -18928,7 +19079,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
18928
19079
|
getAccountDb: () => this.accountSpaceId ? this.sqlForSpace(this.accountSpaceId).db("account") : void 0,
|
|
18929
19080
|
ensureAccountSpaceHosted: async () => {
|
|
18930
19081
|
if (this.accountSpaceId && this.auth) {
|
|
18931
|
-
await this.
|
|
19082
|
+
await this.ensureOwnedSpaceHostedById(this.accountSpaceId);
|
|
18932
19083
|
}
|
|
18933
19084
|
}
|
|
18934
19085
|
});
|
|
@@ -18942,6 +19093,13 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
18942
19093
|
get session() {
|
|
18943
19094
|
return this.auth?.tinyCloudSession;
|
|
18944
19095
|
}
|
|
19096
|
+
/**
|
|
19097
|
+
* Get the currently active session in the shape callers can persist and later
|
|
19098
|
+
* pass back to {@link restoreSession}.
|
|
19099
|
+
*/
|
|
19100
|
+
get restorableSession() {
|
|
19101
|
+
return this.currentTinyCloudSession();
|
|
19102
|
+
}
|
|
18945
19103
|
/**
|
|
18946
19104
|
* Sign in and create a new session.
|
|
18947
19105
|
* This creates the user's space if it doesn't exist.
|
|
@@ -18956,7 +19114,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
18956
19114
|
);
|
|
18957
19115
|
}
|
|
18958
19116
|
await this.wasmBindings.ensureInitialized?.();
|
|
18959
|
-
this._address = (0,
|
|
19117
|
+
this._address = (0, import_sdk_core7.canonicalizeAddress)(await this.signer.getAddress());
|
|
18960
19118
|
this._chainId = await this.signer.getChainId();
|
|
18961
19119
|
this._kv = void 0;
|
|
18962
19120
|
this._sql = void 0;
|
|
@@ -18964,19 +19122,22 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
18964
19122
|
this._hooks = void 0;
|
|
18965
19123
|
this._vault = void 0;
|
|
18966
19124
|
this._encryption = void 0;
|
|
18967
|
-
this._baseSecrets
|
|
18968
|
-
this._secrets
|
|
19125
|
+
this._baseSecrets.clear();
|
|
19126
|
+
this._secrets.clear();
|
|
18969
19127
|
this._spaceService = void 0;
|
|
18970
19128
|
this._serviceContext = void 0;
|
|
18971
19129
|
this.runtimePermissionGrants = [];
|
|
18972
19130
|
await this.tc.signIn(options);
|
|
18973
19131
|
this.syncResolvedHostFromAuth();
|
|
18974
19132
|
this.initializeServices();
|
|
19133
|
+
const bootstrapped = await this.bootstrapAccountIfNeeded();
|
|
18975
19134
|
await this.ensureRequestedEncryptionNetworks();
|
|
18976
|
-
if (this.config.manifest === void 0 && this.config.capabilityRequest === void 0) {
|
|
18977
|
-
await this.
|
|
19135
|
+
if (!bootstrapped && this.config.manifest === void 0 && this.config.capabilityRequest === void 0) {
|
|
19136
|
+
await this.ensureOwnedSpaceHostedById(this.ownedSpaceId(import_sdk_core7.SECRETS_SPACE));
|
|
19137
|
+
}
|
|
19138
|
+
if (!bootstrapped) {
|
|
19139
|
+
this.scheduleAccountRegistrySync();
|
|
18978
19140
|
}
|
|
18979
|
-
this.scheduleAccountRegistrySync();
|
|
18980
19141
|
this.notificationHandler.success("Successfully signed in");
|
|
18981
19142
|
}
|
|
18982
19143
|
ownedSpaceId(name) {
|
|
@@ -18985,6 +19146,208 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
18985
19146
|
}
|
|
18986
19147
|
return this.wasmBindings.makeSpaceId(this._address, this._chainId, name);
|
|
18987
19148
|
}
|
|
19149
|
+
async bootstrapAccountIfNeeded() {
|
|
19150
|
+
if (this.config.autoBootstrapAccount === false) {
|
|
19151
|
+
return false;
|
|
19152
|
+
}
|
|
19153
|
+
if (!this.auth || !this._address) {
|
|
19154
|
+
return false;
|
|
19155
|
+
}
|
|
19156
|
+
const steps = (0, import_sdk_core7.bootstrapSteps)(this._address, this._chainId);
|
|
19157
|
+
if (!await this.isFreshBootstrapAccount(steps)) {
|
|
19158
|
+
return false;
|
|
19159
|
+
}
|
|
19160
|
+
await this.runAccountBootstrap(steps);
|
|
19161
|
+
return true;
|
|
19162
|
+
}
|
|
19163
|
+
async isFreshBootstrapAccount(steps) {
|
|
19164
|
+
const enshrinedSpaceIds = /* @__PURE__ */ new Set();
|
|
19165
|
+
for (const step of steps) {
|
|
19166
|
+
if (step.kind === "session") {
|
|
19167
|
+
enshrinedSpaceIds.add(step.spaceId);
|
|
19168
|
+
}
|
|
19169
|
+
}
|
|
19170
|
+
const skipped = this.auth.lastActivationSkippedSpaceIds;
|
|
19171
|
+
if (skipped.some((spaceId) => enshrinedSpaceIds.has(spaceId))) {
|
|
19172
|
+
return true;
|
|
19173
|
+
}
|
|
19174
|
+
try {
|
|
19175
|
+
const indexed = await this.account.index.spaces.list();
|
|
19176
|
+
if (indexed.ok && indexed.data.length === 0) {
|
|
19177
|
+
return true;
|
|
19178
|
+
}
|
|
19179
|
+
} catch {
|
|
19180
|
+
}
|
|
19181
|
+
try {
|
|
19182
|
+
const spaces = await this.account.spaces.list();
|
|
19183
|
+
return spaces.ok && spaces.data.length === 0;
|
|
19184
|
+
} catch {
|
|
19185
|
+
return false;
|
|
19186
|
+
}
|
|
19187
|
+
}
|
|
19188
|
+
async runAccountBootstrap(steps) {
|
|
19189
|
+
if (!this.auth || !this._address) {
|
|
19190
|
+
throw new Error("Account bootstrap requires an active wallet session");
|
|
19191
|
+
}
|
|
19192
|
+
const host = this.hosts[0] ?? this.config.host;
|
|
19193
|
+
if (!host) {
|
|
19194
|
+
throw new Error("Account bootstrap requires a TinyCloud host");
|
|
19195
|
+
}
|
|
19196
|
+
const auth = this.auth;
|
|
19197
|
+
const sessions = /* @__PURE__ */ new Map();
|
|
19198
|
+
const rawAbilitiesBySpace = /* @__PURE__ */ new Map();
|
|
19199
|
+
const primarySession = auth.tinyCloudSession;
|
|
19200
|
+
const defaultSpaceId = this.ownedSpaceId("default");
|
|
19201
|
+
const canReusePrimaryBootstrapSession = primarySession?.spaceId === defaultSpaceId && auth.capabilityRequest === import_sdk_core7.BOOTSTRAP_SESSION_REQUESTS.default;
|
|
19202
|
+
for (const step of steps) {
|
|
19203
|
+
if (step.kind !== "session") continue;
|
|
19204
|
+
if (step.space === "default" && canReusePrimaryBootstrapSession && primarySession) {
|
|
19205
|
+
sessions.set(step.space, primarySession);
|
|
19206
|
+
continue;
|
|
19207
|
+
}
|
|
19208
|
+
const rawAbilities = step.rawAbilities;
|
|
19209
|
+
if (rawAbilities) {
|
|
19210
|
+
rawAbilitiesBySpace.set(step.space, rawAbilities);
|
|
19211
|
+
}
|
|
19212
|
+
const session = await auth.createBootstrapSession({
|
|
19213
|
+
spaceId: step.spaceId,
|
|
19214
|
+
capabilityRequest: step.request ?? import_sdk_core7.BOOTSTRAP_SESSION_REQUESTS[step.space],
|
|
19215
|
+
rawAbilities
|
|
19216
|
+
});
|
|
19217
|
+
sessions.set(step.space, session);
|
|
19218
|
+
}
|
|
19219
|
+
for (const step of steps) {
|
|
19220
|
+
if (step.kind !== "host") continue;
|
|
19221
|
+
const hosted = await auth.hostOwnedSpace(step.spaceId);
|
|
19222
|
+
if (!hosted) {
|
|
19223
|
+
throw new Error(`Failed to host bootstrap space: ${step.spaceId}`);
|
|
19224
|
+
}
|
|
19225
|
+
}
|
|
19226
|
+
await new Promise((resolve) => setTimeout(resolve, 100));
|
|
19227
|
+
for (const step of steps) {
|
|
19228
|
+
if (step.kind !== "activate") continue;
|
|
19229
|
+
const session = sessions.get(step.space);
|
|
19230
|
+
if (!session) {
|
|
19231
|
+
throw new Error(`Missing bootstrap session for ${step.space}`);
|
|
19232
|
+
}
|
|
19233
|
+
const activated = await (0, import_sdk_core7.activateSessionWithHost)(host, session.delegationHeader);
|
|
19234
|
+
if (!activated.success || activated.skipped?.includes(step.spaceId)) {
|
|
19235
|
+
throw new Error(
|
|
19236
|
+
`Failed to activate bootstrap session for ${step.spaceId}: ${activated.error ?? "space was skipped"}`
|
|
19237
|
+
);
|
|
19238
|
+
}
|
|
19239
|
+
this.registerBootstrapRuntimeGrant(
|
|
19240
|
+
session,
|
|
19241
|
+
import_sdk_core7.BOOTSTRAP_SESSION_REQUESTS[step.space],
|
|
19242
|
+
rawAbilitiesBySpace.get(step.space)
|
|
19243
|
+
);
|
|
19244
|
+
}
|
|
19245
|
+
for (const step of steps) {
|
|
19246
|
+
if (step.kind === "account-index-schema") {
|
|
19247
|
+
const ensured = await this.account.index.ensure();
|
|
19248
|
+
if (!ensured.ok) {
|
|
19249
|
+
throw new Error(`Failed to create account index schema: ${ensured.error.message}`);
|
|
19250
|
+
}
|
|
19251
|
+
}
|
|
19252
|
+
if (step.kind === "seed-spaces") {
|
|
19253
|
+
for (const space of step.spaces) {
|
|
19254
|
+
const registered = await this.account.spaces.register({
|
|
19255
|
+
spaceId: space.spaceId,
|
|
19256
|
+
name: space.name,
|
|
19257
|
+
ownerDid: this.did,
|
|
19258
|
+
type: "owned",
|
|
19259
|
+
permissions: ["*"],
|
|
19260
|
+
status: "active"
|
|
19261
|
+
});
|
|
19262
|
+
if (!registered.ok) {
|
|
19263
|
+
throw new Error(
|
|
19264
|
+
`Failed to seed account space ${space.spaceId}: ${registered.error.message}`
|
|
19265
|
+
);
|
|
19266
|
+
}
|
|
19267
|
+
}
|
|
19268
|
+
}
|
|
19269
|
+
if (step.kind === "seed-applications") {
|
|
19270
|
+
const registered = await this.account.applications.register(
|
|
19271
|
+
step.manifests.length > 0 ? [...step.manifests] : import_sdk_core7.TINYCLOUD_SECRETS_BOOTSTRAP_MANIFEST
|
|
19272
|
+
);
|
|
19273
|
+
if (!registered.ok) {
|
|
19274
|
+
throw new Error(`Failed to seed bootstrap applications: ${registered.error.message}`);
|
|
19275
|
+
}
|
|
19276
|
+
}
|
|
19277
|
+
if (step.kind === "encryption-network-create") {
|
|
19278
|
+
await this.ensureEncryptionNetwork(step.networkId);
|
|
19279
|
+
}
|
|
19280
|
+
if (step.kind === "secret-records-schema") {
|
|
19281
|
+
const db = this.sqlForSpace(step.spaceId).db(step.database);
|
|
19282
|
+
const migrated = await db.migrations.apply({
|
|
19283
|
+
namespace: "tinycloud.secrets.records",
|
|
19284
|
+
migrations: [
|
|
19285
|
+
{
|
|
19286
|
+
id: "001_initial",
|
|
19287
|
+
sql: [...import_sdk_core7.SECRET_RECORDS_SCHEMA]
|
|
19288
|
+
}
|
|
19289
|
+
]
|
|
19290
|
+
});
|
|
19291
|
+
if (!migrated.ok) {
|
|
19292
|
+
throw new Error(
|
|
19293
|
+
`Failed to create secret_records schema: ${migrated.error.message}`
|
|
19294
|
+
);
|
|
19295
|
+
}
|
|
19296
|
+
}
|
|
19297
|
+
}
|
|
19298
|
+
}
|
|
19299
|
+
registerBootstrapRuntimeGrant(session, request, rawAbilities) {
|
|
19300
|
+
const operations = [];
|
|
19301
|
+
for (const resource of request.resources) {
|
|
19302
|
+
const service = resource.service.startsWith("tinycloud.") ? this.shortServiceName(resource.service) : resource.service;
|
|
19303
|
+
const spaceId = resource.space.startsWith("tinycloud:") ? resource.space : this.ownedSpaceId(resource.space);
|
|
19304
|
+
for (const action of resource.actions) {
|
|
19305
|
+
operations.push({
|
|
19306
|
+
spaceId,
|
|
19307
|
+
service,
|
|
19308
|
+
path: resource.path,
|
|
19309
|
+
action
|
|
19310
|
+
});
|
|
19311
|
+
}
|
|
19312
|
+
}
|
|
19313
|
+
for (const [resource, actions2] of Object.entries(rawAbilities ?? {})) {
|
|
19314
|
+
for (const action of actions2) {
|
|
19315
|
+
operations.push({
|
|
19316
|
+
resource,
|
|
19317
|
+
service: "encryption",
|
|
19318
|
+
path: resource,
|
|
19319
|
+
action
|
|
19320
|
+
});
|
|
19321
|
+
}
|
|
19322
|
+
}
|
|
19323
|
+
const expiresAt = extractSiweExpiration(session.siwe) ?? this.getSessionExpiry();
|
|
19324
|
+
const actions = [...new Set(operations.map((operation) => operation.action))];
|
|
19325
|
+
this.runtimePermissionGrants.push({
|
|
19326
|
+
session: {
|
|
19327
|
+
delegationHeader: session.delegationHeader,
|
|
19328
|
+
delegationCid: session.delegationCid,
|
|
19329
|
+
spaceId: session.spaceId,
|
|
19330
|
+
verificationMethod: session.verificationMethod,
|
|
19331
|
+
jwk: session.jwk
|
|
19332
|
+
},
|
|
19333
|
+
delegation: {
|
|
19334
|
+
cid: session.delegationCid,
|
|
19335
|
+
delegationHeader: session.delegationHeader,
|
|
19336
|
+
delegateDID: session.verificationMethod,
|
|
19337
|
+
delegatorDID: this.did,
|
|
19338
|
+
spaceId: session.spaceId,
|
|
19339
|
+
path: "",
|
|
19340
|
+
actions,
|
|
19341
|
+
expiry: expiresAt,
|
|
19342
|
+
allowSubDelegation: true,
|
|
19343
|
+
ownerAddress: session.address,
|
|
19344
|
+
chainId: session.chainId,
|
|
19345
|
+
host: this.config.host
|
|
19346
|
+
},
|
|
19347
|
+
operations,
|
|
19348
|
+
expiresAt
|
|
19349
|
+
});
|
|
19350
|
+
}
|
|
18988
19351
|
async writeManifestRegistryRecords() {
|
|
18989
19352
|
const request = this.capabilityRequest;
|
|
18990
19353
|
if (!request || request.registryRecords.length === 0) {
|
|
@@ -18993,8 +19356,8 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
18993
19356
|
if (!this.auth || !this.signer) {
|
|
18994
19357
|
throw new Error("Manifest registry write requires wallet mode");
|
|
18995
19358
|
}
|
|
18996
|
-
const accountSpaceId = this.ownedSpaceId(
|
|
18997
|
-
await this.
|
|
19359
|
+
const accountSpaceId = this.ownedSpaceId(import_sdk_core7.ACCOUNT_REGISTRY_SPACE);
|
|
19360
|
+
await this.ensureOwnedSpaceHostedById(accountSpaceId);
|
|
18998
19361
|
const result = await this.account.applications.register(request.manifests);
|
|
18999
19362
|
if (!result.ok) {
|
|
19000
19363
|
throw new Error(
|
|
@@ -19004,6 +19367,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
19004
19367
|
}
|
|
19005
19368
|
scheduleAccountRegistrySync() {
|
|
19006
19369
|
void this.withAccountRegistryRetry(async () => {
|
|
19370
|
+
void this.account.index.ensure();
|
|
19007
19371
|
await this.writeManifestRegistryRecords();
|
|
19008
19372
|
const spaces = await this.account.spaces.syncAccessible();
|
|
19009
19373
|
if (!spaces.ok) {
|
|
@@ -19037,7 +19401,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
19037
19401
|
}
|
|
19038
19402
|
const networkIds = /* @__PURE__ */ new Set();
|
|
19039
19403
|
for (const resource of request.resources) {
|
|
19040
|
-
if (resource.service ===
|
|
19404
|
+
if (resource.service === import_sdk_core7.ENCRYPTION_PERMISSION_SERVICE && resource.path.startsWith("urn:tinycloud:encryption:") && resource.actions.includes(DECRYPT_ACTION2)) {
|
|
19041
19405
|
networkIds.add(resource.path);
|
|
19042
19406
|
}
|
|
19043
19407
|
}
|
|
@@ -19048,14 +19412,14 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
19048
19412
|
return;
|
|
19049
19413
|
}
|
|
19050
19414
|
for (const networkId of this.requestedEncryptionNetworkIds()) {
|
|
19051
|
-
const parsed = (0,
|
|
19415
|
+
const parsed = (0, import_sdk_core7.parseNetworkId)(networkId);
|
|
19052
19416
|
if (!didPrincipalMatches2(parsed.ownerDid, this.did)) {
|
|
19053
19417
|
continue;
|
|
19054
19418
|
}
|
|
19055
19419
|
await this.ensureEncryptionNetwork(networkId);
|
|
19056
19420
|
}
|
|
19057
19421
|
}
|
|
19058
|
-
async
|
|
19422
|
+
async ensureOwnedSpaceHostedById(spaceId) {
|
|
19059
19423
|
if (!this.auth) {
|
|
19060
19424
|
throw new Error("Owned space hosting requires wallet mode");
|
|
19061
19425
|
}
|
|
@@ -19067,7 +19431,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
19067
19431
|
if (!host) {
|
|
19068
19432
|
throw new Error("Owned space hosting requires a TinyCloud host");
|
|
19069
19433
|
}
|
|
19070
|
-
const activation = await (0,
|
|
19434
|
+
const activation = await (0, import_sdk_core7.activateSessionWithHost)(host, session.delegationHeader);
|
|
19071
19435
|
if (activation.success && !activation.skipped?.includes(spaceId)) {
|
|
19072
19436
|
return;
|
|
19073
19437
|
}
|
|
@@ -19081,7 +19445,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
19081
19445
|
throw new Error(`Failed to create owned space: ${spaceId}`);
|
|
19082
19446
|
}
|
|
19083
19447
|
await new Promise((resolve) => setTimeout(resolve, 100));
|
|
19084
|
-
const retry = await (0,
|
|
19448
|
+
const retry = await (0, import_sdk_core7.activateSessionWithHost)(host, session.delegationHeader);
|
|
19085
19449
|
if (!retry.success || retry.skipped?.includes(spaceId)) {
|
|
19086
19450
|
throw new Error(
|
|
19087
19451
|
`Failed to activate session after creating owned space ${spaceId}: ${retry.error ?? "space was skipped"}`
|
|
@@ -19098,7 +19462,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
19098
19462
|
* caller is the root authority of their own owned spaces, so no additional
|
|
19099
19463
|
* delegation is required.
|
|
19100
19464
|
*
|
|
19101
|
-
* Unlike {@link
|
|
19465
|
+
* Unlike {@link ensureOwnedSpaceHostedById}, this always submits the host
|
|
19102
19466
|
* delegation rather than inferring hosting from session activation: a space
|
|
19103
19467
|
* the current session has never referenced is reported neither as
|
|
19104
19468
|
* `activated` nor `skipped`, so activation-based detection would wrongly
|
|
@@ -19123,7 +19487,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
19123
19487
|
if (!hosted) {
|
|
19124
19488
|
throw new Error(`Failed to host owned space: ${spaceId}`);
|
|
19125
19489
|
}
|
|
19126
|
-
const activation = await (0,
|
|
19490
|
+
const activation = await (0, import_sdk_core7.activateSessionWithHost)(
|
|
19127
19491
|
host,
|
|
19128
19492
|
this.auth.tinyCloudSession.delegationHeader
|
|
19129
19493
|
);
|
|
@@ -19143,6 +19507,91 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
19143
19507
|
});
|
|
19144
19508
|
return spaceId;
|
|
19145
19509
|
}
|
|
19510
|
+
/**
|
|
19511
|
+
* Ensure one of this user's owned spaces (e.g. `"secrets"`) is hosted on the
|
|
19512
|
+
* server.
|
|
19513
|
+
*
|
|
19514
|
+
* At sign-in, a full-authority session auto-hosts the owner's `secrets`
|
|
19515
|
+
* space, but a session created with a manifest / capabilityRequest does not.
|
|
19516
|
+
* Such a session can therefore hold valid `tinycloud.kv/*` capabilities for
|
|
19517
|
+
* the owned `secrets` space yet still fail its first scoped
|
|
19518
|
+
* `secrets.put(...)` with `404 Space not found`, because the space was never
|
|
19519
|
+
* registered on the node.
|
|
19520
|
+
*
|
|
19521
|
+
* Calling this resolves `name` to the owner's owned-space URI
|
|
19522
|
+
* (`tinycloud:pkh:eip155:<chain>:<addr>:<name>`). It first consults the
|
|
19523
|
+
* account-space spaces registry (`account/spaces/{space_id}`, the canonical
|
|
19524
|
+
* KV source of truth, fronted by a best-effort SQLite index): if the space is
|
|
19525
|
+
* already registered/hosted it returns the URI WITHOUT submitting a host
|
|
19526
|
+
* delegation, avoiding a redundant host-SIWE signature prompt for owners who
|
|
19527
|
+
* already use the space. Only when the space is absent — or the registry
|
|
19528
|
+
* check fails for any reason (e.g. a cold SQLite index reporting
|
|
19529
|
+
* `no such table: spaces`) — does it fall through to {@link hostOwnedSpace}.
|
|
19530
|
+
*
|
|
19531
|
+
* The registry check is purely an optimization: any failure falls back to
|
|
19532
|
+
* hosting, and the host SIWE is idempotent server-side, so re-hosting an
|
|
19533
|
+
* existing space remains a safe no-op. Must be called after {@link signIn}.
|
|
19534
|
+
*
|
|
19535
|
+
* @param name - The owned space name (e.g. `"secrets"`).
|
|
19536
|
+
* @returns The hosted owned-space URI.
|
|
19537
|
+
*/
|
|
19538
|
+
async ensureOwnedSpaceHosted(name) {
|
|
19539
|
+
if (!this.auth || !this.auth.tinyCloudSession) {
|
|
19540
|
+
throw new Error("Not signed in. Call signIn() first.");
|
|
19541
|
+
}
|
|
19542
|
+
const spaceId = this.ownedSpaceId(name);
|
|
19543
|
+
if (await this.isOwnedSpaceRegistered(spaceId)) {
|
|
19544
|
+
return spaceId;
|
|
19545
|
+
}
|
|
19546
|
+
const hosted = await this.hostOwnedSpace(name);
|
|
19547
|
+
try {
|
|
19548
|
+
await this.account.spaces.register({
|
|
19549
|
+
spaceId,
|
|
19550
|
+
name,
|
|
19551
|
+
ownerDid: this.did,
|
|
19552
|
+
type: "owned",
|
|
19553
|
+
permissions: ["*"],
|
|
19554
|
+
status: "active"
|
|
19555
|
+
});
|
|
19556
|
+
} catch {
|
|
19557
|
+
}
|
|
19558
|
+
return hosted;
|
|
19559
|
+
}
|
|
19560
|
+
/**
|
|
19561
|
+
* Check whether an owned space is already registered/hosted by consulting the
|
|
19562
|
+
* account spaces registry.
|
|
19563
|
+
*
|
|
19564
|
+
* Source of truth is the canonical KV registry record
|
|
19565
|
+
* `account/spaces/{space_id}`, read here via `account.spaces.get(spaceId)`.
|
|
19566
|
+
* The KV path is used (rather than `syncAccessible()`) because it works under
|
|
19567
|
+
* a manifest/recap session with NO extra prompt: the composed manifest recap
|
|
19568
|
+
* already grants `tinycloud.kv get/list` on the account space `spaces/`
|
|
19569
|
+
* prefix, whereas `syncAccessible()` depends on `tinycloud.space/list`, which
|
|
19570
|
+
* a recap session does not hold. Before reading, it consults the fast SQLite
|
|
19571
|
+
* index (`account.index.spaces.list()`) as a best-effort short-circuit; on a
|
|
19572
|
+
* cold index (`no such table: spaces`) or any other index failure it falls
|
|
19573
|
+
* back to the canonical KV read.
|
|
19574
|
+
*
|
|
19575
|
+
* This is a best-effort optimization. ANY failure of the check path (missing
|
|
19576
|
+
* table, KV error, missing record, thrown exception) resolves to `false` so
|
|
19577
|
+
* the caller falls through to hosting — per the directive, "if it fails in any
|
|
19578
|
+
* way then create the space".
|
|
19579
|
+
*/
|
|
19580
|
+
async isOwnedSpaceRegistered(spaceId) {
|
|
19581
|
+
try {
|
|
19582
|
+
const indexed = await this.account.index.spaces.list();
|
|
19583
|
+
if (indexed.ok && indexed.data.some((space) => space.spaceId === spaceId)) {
|
|
19584
|
+
return true;
|
|
19585
|
+
}
|
|
19586
|
+
} catch {
|
|
19587
|
+
}
|
|
19588
|
+
try {
|
|
19589
|
+
const record = await this.account.spaces.get(spaceId);
|
|
19590
|
+
return record.ok;
|
|
19591
|
+
} catch {
|
|
19592
|
+
return false;
|
|
19593
|
+
}
|
|
19594
|
+
}
|
|
19146
19595
|
/**
|
|
19147
19596
|
* Restore a previously established session from stored delegation data.
|
|
19148
19597
|
*
|
|
@@ -19160,35 +19609,43 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
19160
19609
|
this._hooks = void 0;
|
|
19161
19610
|
this._vault = void 0;
|
|
19162
19611
|
this._encryption = void 0;
|
|
19163
|
-
this._baseSecrets
|
|
19164
|
-
this._secrets
|
|
19612
|
+
this._baseSecrets.clear();
|
|
19613
|
+
this._secrets.clear();
|
|
19165
19614
|
this._spaceService = void 0;
|
|
19166
19615
|
this._serviceContext = void 0;
|
|
19167
19616
|
this.runtimePermissionGrants = [];
|
|
19168
|
-
const restoredAddress = sessionData.address ? (0,
|
|
19617
|
+
const restoredAddress = sessionData.address ? (0, import_sdk_core7.canonicalizeAddress)(sessionData.address) : void 0;
|
|
19169
19618
|
if (restoredAddress) {
|
|
19170
19619
|
this._address = restoredAddress;
|
|
19171
19620
|
}
|
|
19172
19621
|
if (sessionData.chainId) {
|
|
19173
19622
|
this._chainId = sessionData.chainId;
|
|
19174
19623
|
}
|
|
19175
|
-
|
|
19624
|
+
const resolvedHost = await this.resolveRestoredHost(
|
|
19625
|
+
sessionData.tinycloudHosts,
|
|
19626
|
+
restoredAddress,
|
|
19627
|
+
sessionData.chainId
|
|
19628
|
+
);
|
|
19629
|
+
if (resolvedHost) {
|
|
19630
|
+
this.config.host = resolvedHost;
|
|
19631
|
+
}
|
|
19632
|
+
this._serviceContext = new import_sdk_core7.ServiceContext({
|
|
19176
19633
|
invoke: this.invokeWithRuntimePermissions,
|
|
19177
19634
|
invokeAny: this.invokeAnyWithRuntimePermissions,
|
|
19178
19635
|
fetch: globalThis.fetch.bind(globalThis),
|
|
19179
19636
|
hosts: [this.config.host],
|
|
19180
19637
|
telemetry: this.config.telemetry
|
|
19181
19638
|
});
|
|
19182
|
-
this._kv = new
|
|
19639
|
+
this._kv = new import_sdk_core7.KVService({});
|
|
19183
19640
|
this._kv.initialize(this._serviceContext);
|
|
19184
19641
|
this._serviceContext.registerService("kv", this._kv);
|
|
19185
|
-
this._sql = new
|
|
19642
|
+
this._sql = new import_sdk_core7.SQLService({});
|
|
19186
19643
|
this._sql.initialize(this._serviceContext);
|
|
19187
19644
|
this._serviceContext.registerService("sql", this._sql);
|
|
19188
|
-
this._duckdb = new
|
|
19645
|
+
this._duckdb = new import_sdk_core7.DuckDbService({});
|
|
19189
19646
|
this._duckdb.initialize(this._serviceContext);
|
|
19190
19647
|
this._serviceContext.registerService("duckdb", this._duckdb);
|
|
19191
|
-
this._hooks = new
|
|
19648
|
+
this._hooks = new import_sdk_core7.HooksService({});
|
|
19192
19649
|
this._hooks.initialize(this._serviceContext);
|
|
19193
19650
|
this._serviceContext.registerService("hooks", this._hooks);
|
|
19194
19651
|
const serviceSession = {
|
|
@@ -19217,12 +19674,45 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
19217
19674
|
signature: sessionData.signature ?? ""
|
|
19218
19675
|
};
|
|
19219
19676
|
if (this.auth) {
|
|
19220
|
-
this.auth.setRestoredTinyCloudSession(
|
|
19677
|
+
this.auth.setRestoredTinyCloudSession(
|
|
19678
|
+
tcSession,
|
|
19679
|
+
this.config.host ? [this.config.host] : void 0
|
|
19680
|
+
);
|
|
19221
19681
|
} else {
|
|
19222
19682
|
this._restoredTcSession = tcSession;
|
|
19223
19683
|
}
|
|
19224
19684
|
}
|
|
19225
19685
|
}
|
|
19686
|
+
/**
|
|
19687
|
+
* Resolve the host a restored session should target.
|
|
19688
|
+
*
|
|
19689
|
+
* Mirrors fresh sign-in host resolution but for the restore path:
|
|
19690
|
+
* an explicit/pinned host always wins, then the hosts the session was
|
|
19691
|
+
* persisted with, then a lazy registry/fallback resolution for sessions
|
|
19692
|
+
* that predate the persisted `tinycloudHosts` field. Returns `undefined`
|
|
19693
|
+
* only when there's nothing to resolve from (no explicit host, no
|
|
19694
|
+
* persisted hosts, and no address/chainId) — in which case the existing
|
|
19695
|
+
* `config.host` (default) is left in place.
|
|
19696
|
+
*
|
|
19697
|
+
* Resolution failures are surfaced, not swallowed: a genuinely broken
|
|
19698
|
+
* registry lookup throws rather than silently falling back to a wrong host.
|
|
19699
|
+
*/
|
|
19700
|
+
async resolveRestoredHost(persistedHosts, address, chainId) {
|
|
19701
|
+
if (this.explicitHost) {
|
|
19702
|
+
return this.explicitHost;
|
|
19703
|
+
}
|
|
19704
|
+
if (persistedHosts && persistedHosts.length > 0) {
|
|
19705
|
+
return persistedHosts[0];
|
|
19706
|
+
}
|
|
19707
|
+
if (address === void 0 || chainId === void 0) {
|
|
19708
|
+
return void 0;
|
|
19709
|
+
}
|
|
19710
|
+
const resolved = await (0, import_sdk_core7.resolveTinyCloudHosts)((0, import_sdk_core7.pkhDid)(address, chainId), {
|
|
19711
|
+
registryUrl: this.config.tinycloudRegistryUrl,
|
|
19712
|
+
fallbackHosts: this.config.tinycloudFallbackHosts
|
|
19713
|
+
});
|
|
19714
|
+
return resolved.hosts[0];
|
|
19715
|
+
}
|
|
19226
19716
|
/**
|
|
19227
19717
|
* Resolve the currently-active TinyCloudSession, preferring the auth
|
|
19228
19718
|
* layer's value (wallet mode) and falling back to the node-level
|
|
@@ -19267,9 +19757,11 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
19267
19757
|
);
|
|
19268
19758
|
}
|
|
19269
19759
|
this.signer = _TinyCloudNode.nodeDefaults.createSigner(privateKey);
|
|
19760
|
+
const authConfig = { ...this.config, prefix };
|
|
19761
|
+
const useBootstrapSignInRequest = this.shouldUseBootstrapSignInRequest(authConfig);
|
|
19270
19762
|
this.auth = new NodeUserAuthorization({
|
|
19271
19763
|
signer: this.signer,
|
|
19272
|
-
signStrategy: { type: "auto-sign" },
|
|
19764
|
+
signStrategy: this.config.signStrategy ?? { type: "auto-sign" },
|
|
19273
19765
|
wasmBindings: this.wasmBindings,
|
|
19274
19766
|
sessionStorage: options?.sessionStorage ?? this.config.sessionStorage ?? new MemorySessionStorage(),
|
|
19275
19767
|
domain: this.siweDomain,
|
|
@@ -19278,16 +19770,16 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
19278
19770
|
tinycloudHosts: this.explicitHost ? [this.explicitHost] : void 0,
|
|
19279
19771
|
tinycloudRegistryUrl: this.config.tinycloudRegistryUrl,
|
|
19280
19772
|
tinycloudFallbackHosts: this.config.tinycloudFallbackHosts,
|
|
19281
|
-
autoCreateSpace: this.config.autoCreateSpace,
|
|
19773
|
+
autoCreateSpace: useBootstrapSignInRequest ? false : this.config.autoCreateSpace,
|
|
19282
19774
|
enablePublicSpace: this.config.enablePublicSpace ?? true,
|
|
19283
|
-
spaceCreationHandler: this.config.spaceCreationHandler,
|
|
19775
|
+
spaceCreationHandler: useBootstrapSignInRequest ? void 0 : this.config.spaceCreationHandler,
|
|
19284
19776
|
nonce: this.config.nonce,
|
|
19285
19777
|
siweConfig: this.config.siweConfig,
|
|
19286
|
-
manifest: this.config.manifest,
|
|
19287
|
-
capabilityRequest: this.config.capabilityRequest,
|
|
19288
|
-
includeAccountRegistryPermissions: this.config.includeAccountRegistryPermissions
|
|
19778
|
+
manifest: useBootstrapSignInRequest ? void 0 : this.config.manifest,
|
|
19779
|
+
capabilityRequest: useBootstrapSignInRequest ? import_sdk_core7.BOOTSTRAP_SESSION_REQUESTS.default : this.config.capabilityRequest,
|
|
19780
|
+
includeAccountRegistryPermissions: useBootstrapSignInRequest ? false : this.config.includeAccountRegistryPermissions
|
|
19289
19781
|
});
|
|
19290
|
-
this.tc = new
|
|
19782
|
+
this.tc = new import_sdk_core7.TinyCloud(this.auth, {
|
|
19291
19783
|
invokeAny: this.invokeAnyWithRuntimePermissions,
|
|
19292
19784
|
telemetry: this.config.telemetry
|
|
19293
19785
|
});
|
|
@@ -19312,9 +19804,11 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
19312
19804
|
}
|
|
19313
19805
|
const prefix = options?.prefix ?? "default";
|
|
19314
19806
|
this.signer = signer;
|
|
19807
|
+
const authConfig = { ...this.config, prefix };
|
|
19808
|
+
const useBootstrapSignInRequest = this.shouldUseBootstrapSignInRequest(authConfig);
|
|
19315
19809
|
this.auth = new NodeUserAuthorization({
|
|
19316
19810
|
signer: this.signer,
|
|
19317
|
-
signStrategy: { type: "auto-sign" },
|
|
19811
|
+
signStrategy: this.config.signStrategy ?? { type: "auto-sign" },
|
|
19318
19812
|
wasmBindings: this.wasmBindings,
|
|
19319
19813
|
sessionStorage: options?.sessionStorage ?? this.config.sessionStorage ?? new MemorySessionStorage(),
|
|
19320
19814
|
domain: this.siweDomain,
|
|
@@ -19323,16 +19817,16 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
19323
19817
|
tinycloudHosts: this.explicitHost ? [this.explicitHost] : void 0,
|
|
19324
19818
|
tinycloudRegistryUrl: this.config.tinycloudRegistryUrl,
|
|
19325
19819
|
tinycloudFallbackHosts: this.config.tinycloudFallbackHosts,
|
|
19326
|
-
autoCreateSpace: this.config.autoCreateSpace,
|
|
19820
|
+
autoCreateSpace: useBootstrapSignInRequest ? false : this.config.autoCreateSpace,
|
|
19327
19821
|
enablePublicSpace: this.config.enablePublicSpace ?? true,
|
|
19328
|
-
spaceCreationHandler: this.config.spaceCreationHandler,
|
|
19822
|
+
spaceCreationHandler: useBootstrapSignInRequest ? void 0 : this.config.spaceCreationHandler,
|
|
19329
19823
|
nonce: this.config.nonce,
|
|
19330
19824
|
siweConfig: this.config.siweConfig,
|
|
19331
|
-
manifest: this.config.manifest,
|
|
19332
|
-
capabilityRequest: this.config.capabilityRequest,
|
|
19333
|
-
includeAccountRegistryPermissions: this.config.includeAccountRegistryPermissions
|
|
19825
|
+
manifest: useBootstrapSignInRequest ? void 0 : this.config.manifest,
|
|
19826
|
+
capabilityRequest: useBootstrapSignInRequest ? import_sdk_core7.BOOTSTRAP_SESSION_REQUESTS.default : this.config.capabilityRequest,
|
|
19827
|
+
includeAccountRegistryPermissions: useBootstrapSignInRequest ? false : this.config.includeAccountRegistryPermissions
|
|
19334
19828
|
});
|
|
19335
|
-
this.tc = new
|
|
19829
|
+
this.tc = new import_sdk_core7.TinyCloud(this.auth, {
|
|
19336
19830
|
invokeAny: this.invokeAnyWithRuntimePermissions,
|
|
19337
19831
|
telemetry: this.config.telemetry
|
|
19338
19832
|
});
|
|
@@ -19348,28 +19842,28 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
19348
19842
|
return;
|
|
19349
19843
|
}
|
|
19350
19844
|
this.tc.initializeServices(this.invokeWithRuntimePermissions, [this.config.host]);
|
|
19351
|
-
this._serviceContext = new
|
|
19845
|
+
this._serviceContext = new import_sdk_core7.ServiceContext({
|
|
19352
19846
|
invoke: this.invokeWithRuntimePermissions,
|
|
19353
19847
|
invokeAny: this.invokeAnyWithRuntimePermissions,
|
|
19354
19848
|
fetch: globalThis.fetch.bind(globalThis),
|
|
19355
19849
|
hosts: [this.config.host],
|
|
19356
19850
|
telemetry: this.config.telemetry
|
|
19357
19851
|
});
|
|
19358
|
-
this._kv = new
|
|
19852
|
+
this._kv = new import_sdk_core7.KVService({});
|
|
19359
19853
|
this._kv.initialize(this._serviceContext);
|
|
19360
19854
|
this._serviceContext.registerService("kv", this._kv);
|
|
19361
19855
|
const features = this.nodeFeatures;
|
|
19362
19856
|
if (features.length === 0 || features.includes("sql")) {
|
|
19363
|
-
this._sql = new
|
|
19857
|
+
this._sql = new import_sdk_core7.SQLService({});
|
|
19364
19858
|
this._sql.initialize(this._serviceContext);
|
|
19365
19859
|
this._serviceContext.registerService("sql", this._sql);
|
|
19366
19860
|
}
|
|
19367
19861
|
if (features.length === 0 || features.includes("duckdb")) {
|
|
19368
|
-
this._duckdb = new
|
|
19862
|
+
this._duckdb = new import_sdk_core7.DuckDbService({});
|
|
19369
19863
|
this._duckdb.initialize(this._serviceContext);
|
|
19370
19864
|
this._serviceContext.registerService("duckdb", this._duckdb);
|
|
19371
19865
|
}
|
|
19372
|
-
this._hooks = new
|
|
19866
|
+
this._hooks = new import_sdk_core7.HooksService({});
|
|
19373
19867
|
this._hooks.initialize(this._serviceContext);
|
|
19374
19868
|
this._serviceContext.registerService("hooks", this._hooks);
|
|
19375
19869
|
const serviceSession = {
|
|
@@ -19387,9 +19881,9 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
19387
19881
|
this.initializeV2Services(serviceSession);
|
|
19388
19882
|
}
|
|
19389
19883
|
createSpaceScopedKVService(spaceId) {
|
|
19390
|
-
const kvService = new
|
|
19884
|
+
const kvService = new import_sdk_core7.KVService({});
|
|
19391
19885
|
if (this._serviceContext) {
|
|
19392
|
-
const spaceScopedContext = new
|
|
19886
|
+
const spaceScopedContext = new import_sdk_core7.ServiceContext({
|
|
19393
19887
|
invoke: this._serviceContext.invoke,
|
|
19394
19888
|
fetch: this._serviceContext.fetch,
|
|
19395
19889
|
hosts: this._serviceContext.hosts,
|
|
@@ -19406,6 +19900,20 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
19406
19900
|
getDefaultEncryptionNetworkId(name = DEFAULT_ENCRYPTION_NETWORK_NAME) {
|
|
19407
19901
|
return `urn:tinycloud:encryption:${this.did}:${name}`;
|
|
19408
19902
|
}
|
|
19903
|
+
getEncryptionNetworkIdForSpace(spaceId, name = DEFAULT_ENCRYPTION_NETWORK_NAME) {
|
|
19904
|
+
const ownerDid = this.ownerDidFromSpaceId(spaceId) ?? this.did;
|
|
19905
|
+
return `urn:tinycloud:encryption:${ownerDid}:${name}`;
|
|
19906
|
+
}
|
|
19907
|
+
ownerDidFromSpaceId(spaceId) {
|
|
19908
|
+
if (!spaceId.startsWith("tinycloud:")) return void 0;
|
|
19909
|
+
const body = spaceId.slice("tinycloud:".length);
|
|
19910
|
+
const lastSeparator = body.lastIndexOf(":");
|
|
19911
|
+
if (lastSeparator <= 0) return void 0;
|
|
19912
|
+
const owner = body.slice(0, lastSeparator);
|
|
19913
|
+
if (owner.startsWith("did:")) return owner;
|
|
19914
|
+
if (!owner.includes(":")) return void 0;
|
|
19915
|
+
return `did:${owner}`;
|
|
19916
|
+
}
|
|
19409
19917
|
requireServiceSession() {
|
|
19410
19918
|
const session = this._serviceContext?.session;
|
|
19411
19919
|
if (!session) {
|
|
@@ -19454,7 +19962,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
19454
19962
|
const shared = wasm.vault_x25519_dh(receiverPrivateKey, peerPublic);
|
|
19455
19963
|
return columnDecrypt(shared, ciphertext);
|
|
19456
19964
|
},
|
|
19457
|
-
verifyNodeSignature: (nodeId, message, signature2) => (0,
|
|
19965
|
+
verifyNodeSignature: (nodeId, message, signature2) => (0, import_sdk_core7.verifyDidKeyEd25519Signature)(nodeId, message, signature2)
|
|
19458
19966
|
};
|
|
19459
19967
|
}
|
|
19460
19968
|
async fetchNodeId() {
|
|
@@ -19525,7 +20033,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
19525
20033
|
return await response.json();
|
|
19526
20034
|
}
|
|
19527
20035
|
};
|
|
19528
|
-
return new
|
|
20036
|
+
return new import_sdk_core7.EncryptionService({
|
|
19529
20037
|
crypto: crypto2,
|
|
19530
20038
|
signer: {
|
|
19531
20039
|
signDecryptInvocation: async (input) => {
|
|
@@ -19537,7 +20045,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
19537
20045
|
});
|
|
19538
20046
|
return {
|
|
19539
20047
|
...signed2,
|
|
19540
|
-
canonicalBody: (0,
|
|
20048
|
+
canonicalBody: (0, import_sdk_core7.canonicalizeEncryptionJson)(
|
|
19541
20049
|
input.body
|
|
19542
20050
|
)
|
|
19543
20051
|
};
|
|
@@ -19555,8 +20063,8 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
19555
20063
|
if (!this.config.host) {
|
|
19556
20064
|
return null;
|
|
19557
20065
|
}
|
|
19558
|
-
const publicSpaceId = (0,
|
|
19559
|
-
const result = await
|
|
20066
|
+
const publicSpaceId = (0, import_sdk_core7.makePublicSpaceId)(this._address, this._chainId);
|
|
20067
|
+
const result = await import_sdk_core7.TinyCloud.readPublicSpace(this.config.host, publicSpaceId, discoveryKey);
|
|
19560
20068
|
if (!result.ok) {
|
|
19561
20069
|
return null;
|
|
19562
20070
|
}
|
|
@@ -19579,7 +20087,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
19579
20087
|
}
|
|
19580
20088
|
createVaultService(spaceId, kv) {
|
|
19581
20089
|
const wasm = this.wasmBindings;
|
|
19582
|
-
const vaultCrypto = (0,
|
|
20090
|
+
const vaultCrypto = (0, import_sdk_core7.createVaultCrypto)({
|
|
19583
20091
|
vault_encrypt: wasm.vault_encrypt,
|
|
19584
20092
|
vault_decrypt: wasm.vault_decrypt,
|
|
19585
20093
|
vault_derive_key: wasm.vault_derive_key,
|
|
@@ -19589,11 +20097,11 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
19589
20097
|
vault_sha256: wasm.vault_sha256
|
|
19590
20098
|
});
|
|
19591
20099
|
const self2 = this;
|
|
19592
|
-
return new
|
|
20100
|
+
return new import_sdk_core7.DataVaultService({
|
|
19593
20101
|
spaceId,
|
|
19594
20102
|
crypto: vaultCrypto,
|
|
19595
20103
|
encryption: {
|
|
19596
|
-
networkId: this.
|
|
20104
|
+
networkId: this.getEncryptionNetworkIdForSpace(spaceId),
|
|
19597
20105
|
service: this.getEncryptionService(),
|
|
19598
20106
|
decryptCapabilityProof: () => ({
|
|
19599
20107
|
proofs: [this.requireServiceSession().delegationCid]
|
|
@@ -19612,8 +20120,8 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
19612
20120
|
get publicKV() {
|
|
19613
20121
|
return self2._publicKV ?? self2.tc.publicKV;
|
|
19614
20122
|
},
|
|
19615
|
-
readPublicSpace: (host, targetSpaceId, key2) =>
|
|
19616
|
-
makePublicSpaceId:
|
|
20123
|
+
readPublicSpace: (host, targetSpaceId, key2) => import_sdk_core7.TinyCloud.readPublicSpace(host, targetSpaceId, key2),
|
|
20124
|
+
makePublicSpaceId: import_sdk_core7.TinyCloud.makePublicSpaceId,
|
|
19617
20125
|
did: this.did,
|
|
19618
20126
|
address: this._address ?? "",
|
|
19619
20127
|
chainId: this._chainId,
|
|
@@ -19626,7 +20134,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
19626
20134
|
* @internal
|
|
19627
20135
|
*/
|
|
19628
20136
|
initializeV2Services(serviceSession) {
|
|
19629
|
-
this._capabilityRegistry = new
|
|
20137
|
+
this._capabilityRegistry = new import_sdk_core7.CapabilityKeyRegistry();
|
|
19630
20138
|
const tcSession = this.auth?.tinyCloudSession;
|
|
19631
20139
|
if (tcSession && this._address) {
|
|
19632
20140
|
const sessionKey = {
|
|
@@ -19700,13 +20208,13 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
19700
20208
|
}
|
|
19701
20209
|
this._capabilityRegistry.registerKey(sessionKey, delegations);
|
|
19702
20210
|
}
|
|
19703
|
-
this._delegationManager = new
|
|
20211
|
+
this._delegationManager = new import_sdk_core7.DelegationManager({
|
|
19704
20212
|
hosts: [this.config.host],
|
|
19705
20213
|
session: serviceSession,
|
|
19706
20214
|
invoke: this.invokeWithRuntimePermissions,
|
|
19707
20215
|
fetch: globalThis.fetch.bind(globalThis)
|
|
19708
20216
|
});
|
|
19709
|
-
this._spaceService = new
|
|
20217
|
+
this._spaceService = new import_sdk_core7.SpaceService({
|
|
19710
20218
|
hosts: [this.config.host],
|
|
19711
20219
|
session: serviceSession,
|
|
19712
20220
|
invoke: this.wasmBindings.invoke,
|
|
@@ -19724,6 +20232,9 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
19724
20232
|
}
|
|
19725
20233
|
return vaultService;
|
|
19726
20234
|
},
|
|
20235
|
+
createSecretsService: (spaceId) => {
|
|
20236
|
+
return this.secretsForSpace(spaceId);
|
|
20237
|
+
},
|
|
19727
20238
|
// Enable space.delegations.create() via SIWE-based delegation
|
|
19728
20239
|
createDelegation: async (params) => {
|
|
19729
20240
|
try {
|
|
@@ -19846,11 +20357,10 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
19846
20357
|
try {
|
|
19847
20358
|
const host = this.config.host;
|
|
19848
20359
|
const now = /* @__PURE__ */ new Date();
|
|
19849
|
-
const abilities =
|
|
19850
|
-
|
|
19851
|
-
|
|
19852
|
-
|
|
19853
|
-
};
|
|
20360
|
+
const abilities = sharingActionsToAbilities(params.path, params.actions);
|
|
20361
|
+
if (!abilities) {
|
|
20362
|
+
return void 0;
|
|
20363
|
+
}
|
|
19854
20364
|
const prepared = this.wasmBindings.prepareSession({
|
|
19855
20365
|
abilities,
|
|
19856
20366
|
address: this.wasmBindings.ensureEip55(session.address),
|
|
@@ -19866,7 +20376,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
19866
20376
|
...prepared,
|
|
19867
20377
|
signature: signature2
|
|
19868
20378
|
});
|
|
19869
|
-
const activateResult = await (0,
|
|
20379
|
+
const activateResult = await (0, import_sdk_core7.activateSessionWithHost)(
|
|
19870
20380
|
host,
|
|
19871
20381
|
delegationSession.delegationHeader
|
|
19872
20382
|
);
|
|
@@ -19876,7 +20386,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
19876
20386
|
return {
|
|
19877
20387
|
cid: delegationSession.delegationCid,
|
|
19878
20388
|
delegateDID: params.shareKeyDID,
|
|
19879
|
-
delegatorDID: (0,
|
|
20389
|
+
delegatorDID: (0, import_sdk_core7.pkhDid)(session.address, session.chainId),
|
|
19880
20390
|
spaceId: params.spaceId,
|
|
19881
20391
|
path: params.path,
|
|
19882
20392
|
actions: params.actions,
|
|
@@ -19933,7 +20443,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
19933
20443
|
if (!this._sql) {
|
|
19934
20444
|
const features = this.nodeFeatures;
|
|
19935
20445
|
if (features.length > 0 && !features.includes("sql")) {
|
|
19936
|
-
throw new
|
|
20446
|
+
throw new import_sdk_core7.UnsupportedFeatureError("sql", this.config.host, features);
|
|
19937
20447
|
}
|
|
19938
20448
|
throw new Error("Not signed in. Call signIn() first.");
|
|
19939
20449
|
}
|
|
@@ -19957,8 +20467,8 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
19957
20467
|
if (!this._serviceContext || !this._serviceContext.session) {
|
|
19958
20468
|
throw new Error("Not signed in. Call signIn() first.");
|
|
19959
20469
|
}
|
|
19960
|
-
const sql = new
|
|
19961
|
-
const spaceScopedContext = new
|
|
20470
|
+
const sql = new import_sdk_core7.SQLService({});
|
|
20471
|
+
const spaceScopedContext = new import_sdk_core7.ServiceContext({
|
|
19962
20472
|
invoke: this._serviceContext.invoke,
|
|
19963
20473
|
fetch: this._serviceContext.fetch,
|
|
19964
20474
|
hosts: this._serviceContext.hosts,
|
|
@@ -19986,8 +20496,8 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
19986
20496
|
if (!this._serviceContext || !this._serviceContext.session) {
|
|
19987
20497
|
throw new Error("Not signed in. Call signIn() first.");
|
|
19988
20498
|
}
|
|
19989
|
-
const kv = new
|
|
19990
|
-
const spaceScopedContext = new
|
|
20499
|
+
const kv = new import_sdk_core7.KVService({});
|
|
20500
|
+
const spaceScopedContext = new import_sdk_core7.ServiceContext({
|
|
19991
20501
|
invoke: this._serviceContext.invoke,
|
|
19992
20502
|
fetch: this._serviceContext.fetch,
|
|
19993
20503
|
hosts: this._serviceContext.hosts
|
|
@@ -20003,7 +20513,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
20003
20513
|
if (!this._duckdb) {
|
|
20004
20514
|
const features = this.nodeFeatures;
|
|
20005
20515
|
if (features.length > 0 && !features.includes("duckdb")) {
|
|
20006
|
-
throw new
|
|
20516
|
+
throw new import_sdk_core7.UnsupportedFeatureError("duckdb", this.config.host, features);
|
|
20007
20517
|
}
|
|
20008
20518
|
throw new Error("Not signed in. Call signIn() first.");
|
|
20009
20519
|
}
|
|
@@ -20055,7 +20565,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
20055
20565
|
type: NETWORK_ADMIN_TYPE,
|
|
20056
20566
|
targetNode,
|
|
20057
20567
|
networkId,
|
|
20058
|
-
bodyHash: (0,
|
|
20568
|
+
bodyHash: (0, import_sdk_core7.canonicalHashHex)(
|
|
20059
20569
|
crypto2.sha256,
|
|
20060
20570
|
body
|
|
20061
20571
|
),
|
|
@@ -20073,7 +20583,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
20073
20583
|
Authorization: signed2.authorization,
|
|
20074
20584
|
"Content-Type": "application/json"
|
|
20075
20585
|
},
|
|
20076
|
-
body: (0,
|
|
20586
|
+
body: (0, import_sdk_core7.canonicalizeEncryptionJson)(
|
|
20077
20587
|
body
|
|
20078
20588
|
)
|
|
20079
20589
|
});
|
|
@@ -20091,7 +20601,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
20091
20601
|
if (existing) {
|
|
20092
20602
|
return existing;
|
|
20093
20603
|
}
|
|
20094
|
-
const parsed = (0,
|
|
20604
|
+
const parsed = (0, import_sdk_core7.parseNetworkId)(networkId);
|
|
20095
20605
|
if (!didPrincipalMatches2(parsed.ownerDid, this.did)) {
|
|
20096
20606
|
throw new Error(
|
|
20097
20607
|
`Cannot create encryption network ${networkId}: owner ${parsed.ownerDid} does not match signed-in DID ${this.did}`
|
|
@@ -20106,27 +20616,49 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
20106
20616
|
if (!this._spaceService) {
|
|
20107
20617
|
throw new Error("Not signed in. Call signIn() first.");
|
|
20108
20618
|
}
|
|
20109
|
-
|
|
20110
|
-
|
|
20111
|
-
|
|
20619
|
+
return this.secretsForSpace("secrets");
|
|
20620
|
+
}
|
|
20621
|
+
/**
|
|
20622
|
+
* App-facing secrets API backed by the requested space's vault.
|
|
20623
|
+
*/
|
|
20624
|
+
secretsForSpace(spaceId) {
|
|
20625
|
+
if (!this._spaceService) {
|
|
20626
|
+
throw new Error("Not signed in. Call signIn() first.");
|
|
20627
|
+
}
|
|
20628
|
+
const resolvedSpace = spaceId.startsWith("tinycloud:") ? spaceId : this.ownedSpaceId(spaceId);
|
|
20629
|
+
let secrets = this._secrets.get(resolvedSpace);
|
|
20630
|
+
if (!secrets) {
|
|
20631
|
+
secrets = new NodeSecretsService({
|
|
20632
|
+
getService: () => this.getBaseSecrets(resolvedSpace),
|
|
20633
|
+
space: resolvedSpace,
|
|
20112
20634
|
getManifest: () => this.manifest,
|
|
20113
20635
|
hasPermissions: (permissions) => this.hasRuntimePermissions(permissions),
|
|
20114
20636
|
grantPermissions: (additional) => this.grantRuntimePermissions(additional),
|
|
20115
20637
|
canEscalate: () => this.signer !== void 0 && this.tc !== void 0,
|
|
20116
|
-
getEncryptionNetworkId: () => this.
|
|
20638
|
+
getEncryptionNetworkId: () => this.getEncryptionNetworkIdForSpace(resolvedSpace),
|
|
20639
|
+
resolveSpace: (space) => space.startsWith("tinycloud:") ? space : this.ownedSpaceId(space),
|
|
20117
20640
|
getUnlockSigner: () => this.signer ?? void 0
|
|
20118
20641
|
});
|
|
20642
|
+
this._secrets.set(resolvedSpace, secrets);
|
|
20119
20643
|
}
|
|
20120
|
-
return
|
|
20644
|
+
return secrets;
|
|
20121
20645
|
}
|
|
20122
|
-
getBaseSecrets() {
|
|
20646
|
+
getBaseSecrets(spaceId) {
|
|
20123
20647
|
if (!this._spaceService) {
|
|
20124
20648
|
throw new Error("Not signed in. Call signIn() first.");
|
|
20125
20649
|
}
|
|
20126
|
-
|
|
20127
|
-
|
|
20650
|
+
const resolvedSpace = spaceId.startsWith("tinycloud:") ? spaceId : this.ownedSpaceId(spaceId);
|
|
20651
|
+
let secrets = this._baseSecrets.get(resolvedSpace);
|
|
20652
|
+
if (!secrets) {
|
|
20653
|
+
const kvService = this.createSpaceScopedKVService(resolvedSpace);
|
|
20654
|
+
const vaultService = this.createVaultService(resolvedSpace, kvService);
|
|
20655
|
+
if (this._serviceContext) {
|
|
20656
|
+
vaultService.initialize(this._serviceContext);
|
|
20657
|
+
}
|
|
20658
|
+
secrets = new import_sdk_core7.SecretsService(() => vaultService);
|
|
20659
|
+
this._baseSecrets.set(resolvedSpace, secrets);
|
|
20128
20660
|
}
|
|
20129
|
-
return
|
|
20661
|
+
return secrets;
|
|
20130
20662
|
}
|
|
20131
20663
|
/**
|
|
20132
20664
|
* Hooks write stream subscription API.
|
|
@@ -20239,10 +20771,10 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
20239
20771
|
async useRuntimeDelegation(delegation) {
|
|
20240
20772
|
const session = this.currentTinyCloudSession();
|
|
20241
20773
|
if (!session) {
|
|
20242
|
-
throw new
|
|
20774
|
+
throw new import_sdk_core7.SessionExpiredError(/* @__PURE__ */ new Date(0));
|
|
20243
20775
|
}
|
|
20244
20776
|
if (delegation.expiry.getTime() <= Date.now()) {
|
|
20245
|
-
throw new
|
|
20777
|
+
throw new import_sdk_core7.SessionExpiredError(delegation.expiry);
|
|
20246
20778
|
}
|
|
20247
20779
|
const expectedDids = [session.verificationMethod, this.sessionDid];
|
|
20248
20780
|
if (!expectedDids.some((did) => didPrincipalMatches2(delegation.delegateDID, did))) {
|
|
@@ -20251,7 +20783,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
20251
20783
|
);
|
|
20252
20784
|
}
|
|
20253
20785
|
const targetHost = delegation.host ?? this.config.host;
|
|
20254
|
-
const activateResult = await (0,
|
|
20786
|
+
const activateResult = await (0, import_sdk_core7.activateSessionWithHost)(
|
|
20255
20787
|
targetHost,
|
|
20256
20788
|
delegation.delegationHeader
|
|
20257
20789
|
);
|
|
@@ -20278,13 +20810,13 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
20278
20810
|
}
|
|
20279
20811
|
const session = this.currentTinyCloudSession();
|
|
20280
20812
|
if (!session) {
|
|
20281
|
-
throw new
|
|
20813
|
+
throw new import_sdk_core7.SessionExpiredError(/* @__PURE__ */ new Date(0));
|
|
20282
20814
|
}
|
|
20283
20815
|
const sessionExpiry = extractSiweExpiration(session.siwe);
|
|
20284
20816
|
if (sessionExpiry !== void 0) {
|
|
20285
20817
|
const marginMs = _TinyCloudNode.SESSION_EXPIRY_SAFETY_MARGIN_MS;
|
|
20286
20818
|
if (sessionExpiry.getTime() <= Date.now() + marginMs) {
|
|
20287
|
-
throw new
|
|
20819
|
+
throw new import_sdk_core7.SessionExpiredError(sessionExpiry);
|
|
20288
20820
|
}
|
|
20289
20821
|
}
|
|
20290
20822
|
const expanded = this.expandPermissionEntries(permissions);
|
|
@@ -20347,7 +20879,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
20347
20879
|
...prepared,
|
|
20348
20880
|
signature: signature2
|
|
20349
20881
|
});
|
|
20350
|
-
const activateResult = await (0,
|
|
20882
|
+
const activateResult = await (0, import_sdk_core7.activateSessionWithHost)(
|
|
20351
20883
|
this.config.host,
|
|
20352
20884
|
delegatedSession.delegationHeader
|
|
20353
20885
|
);
|
|
@@ -20520,7 +21052,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
20520
21052
|
];
|
|
20521
21053
|
const abilities = { kv: { "": kvActions } };
|
|
20522
21054
|
const now = /* @__PURE__ */ new Date();
|
|
20523
|
-
const expiryMs =
|
|
21055
|
+
const expiryMs = import_sdk_core7.EXPIRY.EPHEMERAL_MS;
|
|
20524
21056
|
const expirationTime = new Date(now.getTime() + expiryMs);
|
|
20525
21057
|
const prepared = this.wasmBindings.prepareSession({
|
|
20526
21058
|
abilities,
|
|
@@ -20538,7 +21070,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
20538
21070
|
...prepared,
|
|
20539
21071
|
signature: signature2
|
|
20540
21072
|
});
|
|
20541
|
-
const activateResult = await (0,
|
|
21073
|
+
const activateResult = await (0, import_sdk_core7.activateSessionWithHost)(
|
|
20542
21074
|
this.config.host,
|
|
20543
21075
|
delegationSession.delegationHeader
|
|
20544
21076
|
);
|
|
@@ -20565,8 +21097,8 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
20565
21097
|
}]);
|
|
20566
21098
|
}
|
|
20567
21099
|
if (this._serviceContext) {
|
|
20568
|
-
const publicKV = new
|
|
20569
|
-
const publicContext = new
|
|
21100
|
+
const publicKV = new import_sdk_core7.KVService({ prefix: "" });
|
|
21101
|
+
const publicContext = new import_sdk_core7.ServiceContext({
|
|
20570
21102
|
invoke: this.invokeWithRuntimePermissions,
|
|
20571
21103
|
fetch: this._serviceContext.fetch,
|
|
20572
21104
|
hosts: this._serviceContext.hosts,
|
|
@@ -20693,14 +21225,14 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
20693
21225
|
async delegateTo(did, permissions, options) {
|
|
20694
21226
|
const session = this.currentTinyCloudSession();
|
|
20695
21227
|
if (!session) {
|
|
20696
|
-
throw new
|
|
21228
|
+
throw new import_sdk_core7.SessionExpiredError(/* @__PURE__ */ new Date(0));
|
|
20697
21229
|
}
|
|
20698
21230
|
const sessionExpiry = extractSiweExpiration(session.siwe);
|
|
20699
21231
|
if (sessionExpiry !== void 0) {
|
|
20700
21232
|
const now2 = Date.now();
|
|
20701
21233
|
const marginMs = _TinyCloudNode.SESSION_EXPIRY_SAFETY_MARGIN_MS;
|
|
20702
21234
|
if (sessionExpiry.getTime() <= now2 + marginMs) {
|
|
20703
|
-
throw new
|
|
21235
|
+
throw new import_sdk_core7.SessionExpiredError(sessionExpiry);
|
|
20704
21236
|
}
|
|
20705
21237
|
}
|
|
20706
21238
|
if (!Array.isArray(permissions) || permissions.length === 0) {
|
|
@@ -20729,11 +21261,11 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
20729
21261
|
);
|
|
20730
21262
|
return { delegation: delegation2, prompted: true };
|
|
20731
21263
|
}
|
|
20732
|
-
const granted = (0,
|
|
21264
|
+
const granted = (0, import_sdk_core7.parseRecapCapabilities)(
|
|
20733
21265
|
(siwe) => this.wasmBindings.parseRecapFromSiwe(siwe),
|
|
20734
21266
|
session.siwe
|
|
20735
21267
|
);
|
|
20736
|
-
const { subset, missing } = (0,
|
|
21268
|
+
const { subset, missing } = (0, import_sdk_core7.isCapabilitySubset)(expandedEntries, granted);
|
|
20737
21269
|
if (!subset) {
|
|
20738
21270
|
const runtimeGrant = this.findGrantForOperations(
|
|
20739
21271
|
this.permissionEntriesToOperations(expandedEntries, session)
|
|
@@ -20741,7 +21273,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
20741
21273
|
if (runtimeGrant) {
|
|
20742
21274
|
const marginMs = _TinyCloudNode.SESSION_EXPIRY_SAFETY_MARGIN_MS;
|
|
20743
21275
|
if (runtimeGrant.expiresAt.getTime() <= Date.now() + marginMs) {
|
|
20744
|
-
throw new
|
|
21276
|
+
throw new import_sdk_core7.SessionExpiredError(runtimeGrant.expiresAt);
|
|
20745
21277
|
}
|
|
20746
21278
|
const runtimeExpiration = runtimeGrant.expiresAt < effectiveExpiration ? runtimeGrant.expiresAt : effectiveExpiration;
|
|
20747
21279
|
const delegation2 = await this.createDelegationViaRuntimeGrant(
|
|
@@ -20752,7 +21284,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
20752
21284
|
);
|
|
20753
21285
|
return { delegation: delegation2, prompted: false };
|
|
20754
21286
|
}
|
|
20755
|
-
throw new
|
|
21287
|
+
throw new import_sdk_core7.PermissionNotInManifestError(missing, granted);
|
|
20756
21288
|
}
|
|
20757
21289
|
const delegation = await this.createDelegationViaWasmPath(
|
|
20758
21290
|
did,
|
|
@@ -20834,7 +21366,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
20834
21366
|
const spaceId = resolvedSpaces.size === 1 ? [...resolvedSpaces][0] : session.spaceId;
|
|
20835
21367
|
const abilities = {};
|
|
20836
21368
|
for (const entry of entries) {
|
|
20837
|
-
const shortService =
|
|
21369
|
+
const shortService = import_sdk_core7.SERVICE_LONG_TO_SHORT[entry.service];
|
|
20838
21370
|
if (shortService === void 0) {
|
|
20839
21371
|
throw new Error(
|
|
20840
21372
|
`delegateTo: unknown service '${entry.service}' \u2014 no short-form mapping`
|
|
@@ -20874,7 +21406,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
20874
21406
|
});
|
|
20875
21407
|
const primary = result.resources[0];
|
|
20876
21408
|
const delegationHeader = { Authorization: result.delegation };
|
|
20877
|
-
const activateResult = await (0,
|
|
21409
|
+
const activateResult = await (0, import_sdk_core7.activateSessionWithHost)(
|
|
20878
21410
|
this.config.host,
|
|
20879
21411
|
delegationHeader
|
|
20880
21412
|
);
|
|
@@ -20909,7 +21441,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
20909
21441
|
const primary = result.resources[0];
|
|
20910
21442
|
const delegationHeader = { Authorization: result.delegation };
|
|
20911
21443
|
const targetHost = grant.delegation.host ?? this.config.host;
|
|
20912
|
-
const activateResult = await (0,
|
|
21444
|
+
const activateResult = await (0, import_sdk_core7.activateSessionWithHost)(
|
|
20913
21445
|
targetHost,
|
|
20914
21446
|
delegationHeader
|
|
20915
21447
|
);
|
|
@@ -20950,10 +21482,10 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
20950
21482
|
return this.wasmBindings.makeSpaceId(session.address, session.chainId, space);
|
|
20951
21483
|
}
|
|
20952
21484
|
expandPermissionEntries(permissions) {
|
|
20953
|
-
return (0,
|
|
21485
|
+
return (0, import_sdk_core7.expandPermissionEntries)(permissions);
|
|
20954
21486
|
}
|
|
20955
21487
|
shortServiceName(service) {
|
|
20956
|
-
const short =
|
|
21488
|
+
const short = import_sdk_core7.SERVICE_LONG_TO_SHORT[service];
|
|
20957
21489
|
if (short === void 0) {
|
|
20958
21490
|
throw new Error(
|
|
20959
21491
|
`unknown service '${service}' \u2014 no short-form mapping`
|
|
@@ -20979,7 +21511,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
20979
21511
|
return abilities;
|
|
20980
21512
|
}
|
|
20981
21513
|
isEncryptionPermissionEntry(entry) {
|
|
20982
|
-
return entry.service ===
|
|
21514
|
+
return entry.service === import_sdk_core7.ENCRYPTION_PERMISSION_SERVICE && entry.path.startsWith("urn:tinycloud:encryption:");
|
|
20983
21515
|
}
|
|
20984
21516
|
permissionsToRawAbilities(entries) {
|
|
20985
21517
|
const rawAbilities = {};
|
|
@@ -21012,11 +21544,11 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
21012
21544
|
}
|
|
21013
21545
|
sessionCoversPermissionEntries(session, entries) {
|
|
21014
21546
|
try {
|
|
21015
|
-
const granted = (0,
|
|
21547
|
+
const granted = (0, import_sdk_core7.parseRecapCapabilities)(
|
|
21016
21548
|
(siwe) => this.wasmBindings.parseRecapFromSiwe(siwe),
|
|
21017
21549
|
session.siwe
|
|
21018
21550
|
);
|
|
21019
|
-
return (0,
|
|
21551
|
+
return (0, import_sdk_core7.isCapabilitySubset)(entries, granted).subset;
|
|
21020
21552
|
} catch {
|
|
21021
21553
|
return false;
|
|
21022
21554
|
}
|
|
@@ -21347,7 +21879,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
21347
21879
|
if (resolvedDelegateDID.endsWith(".eth") && this.config.ensResolver) {
|
|
21348
21880
|
const address = await this.config.ensResolver.resolveAddress(resolvedDelegateDID);
|
|
21349
21881
|
if (!address) throw new Error(`Could not resolve ENS name: ${resolvedDelegateDID}`);
|
|
21350
|
-
resolvedDelegateDID = (0,
|
|
21882
|
+
resolvedDelegateDID = (0, import_sdk_core7.pkhDid)(address, 1);
|
|
21351
21883
|
}
|
|
21352
21884
|
const entries = legacyParamsToPermissionEntries(
|
|
21353
21885
|
params.actions,
|
|
@@ -21362,7 +21894,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
21362
21894
|
);
|
|
21363
21895
|
return result.delegation;
|
|
21364
21896
|
} catch (err) {
|
|
21365
|
-
if (err instanceof
|
|
21897
|
+
if (err instanceof import_sdk_core7.PermissionNotInManifestError) {
|
|
21366
21898
|
} else {
|
|
21367
21899
|
throw err;
|
|
21368
21900
|
}
|
|
@@ -21419,7 +21951,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
21419
21951
|
...prepared,
|
|
21420
21952
|
signature: signature2
|
|
21421
21953
|
});
|
|
21422
|
-
const activateResult = await (0,
|
|
21954
|
+
const activateResult = await (0, import_sdk_core7.activateSessionWithHost)(
|
|
21423
21955
|
this.config.host,
|
|
21424
21956
|
delegationSession.delegationHeader
|
|
21425
21957
|
);
|
|
@@ -21441,7 +21973,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
21441
21973
|
};
|
|
21442
21974
|
const hasKvActions = params.actions.some((a) => a.startsWith("tinycloud.kv/"));
|
|
21443
21975
|
if (hasKvActions && params.includePublicSpace !== false) {
|
|
21444
|
-
const publicSpaceId = (0,
|
|
21976
|
+
const publicSpaceId = (0, import_sdk_core7.makePublicSpaceId)(
|
|
21445
21977
|
this.wasmBindings.ensureEip55(session.address),
|
|
21446
21978
|
session.chainId
|
|
21447
21979
|
);
|
|
@@ -21464,7 +21996,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
21464
21996
|
...publicPrepared,
|
|
21465
21997
|
signature: publicSignature
|
|
21466
21998
|
});
|
|
21467
|
-
const publicActivateResult = await (0,
|
|
21999
|
+
const publicActivateResult = await (0, import_sdk_core7.activateSessionWithHost)(
|
|
21468
22000
|
this.config.host,
|
|
21469
22001
|
publicSession.delegationHeader
|
|
21470
22002
|
);
|
|
@@ -21540,6 +22072,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
21540
22072
|
delegation,
|
|
21541
22073
|
targetHost,
|
|
21542
22074
|
this.wasmBindings.invoke,
|
|
22075
|
+
this.wasmBindings.invokeAny,
|
|
21543
22076
|
this.config.telemetry
|
|
21544
22077
|
);
|
|
21545
22078
|
}
|
|
@@ -21569,7 +22102,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
21569
22102
|
...prepared,
|
|
21570
22103
|
signature: signature2
|
|
21571
22104
|
});
|
|
21572
|
-
const activateResult = await (0,
|
|
22105
|
+
const activateResult = await (0, import_sdk_core7.activateSessionWithHost)(
|
|
21573
22106
|
targetHost,
|
|
21574
22107
|
invokerSession.delegationHeader
|
|
21575
22108
|
);
|
|
@@ -21605,6 +22138,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
21605
22138
|
delegation,
|
|
21606
22139
|
targetHost,
|
|
21607
22140
|
this.wasmBindings.invoke,
|
|
22141
|
+
this.wasmBindings.invokeAny,
|
|
21608
22142
|
this.config.telemetry
|
|
21609
22143
|
);
|
|
21610
22144
|
}
|
|
@@ -21675,7 +22209,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
21675
22209
|
...prepared,
|
|
21676
22210
|
signature: signature2
|
|
21677
22211
|
});
|
|
21678
|
-
const activateResult = await (0,
|
|
22212
|
+
const activateResult = await (0, import_sdk_core7.activateSessionWithHost)(
|
|
21679
22213
|
targetHost,
|
|
21680
22214
|
subDelegationSession.delegationHeader
|
|
21681
22215
|
);
|
|
@@ -21717,11 +22251,11 @@ TinyCloudNode.registerNodeDefaults({
|
|
|
21717
22251
|
});
|
|
21718
22252
|
|
|
21719
22253
|
// src/index.ts
|
|
21720
|
-
var import_sdk_core8 = require("@tinycloud/sdk-core");
|
|
21721
22254
|
var import_sdk_core9 = require("@tinycloud/sdk-core");
|
|
22255
|
+
var import_sdk_core10 = require("@tinycloud/sdk-core");
|
|
21722
22256
|
|
|
21723
22257
|
// src/storage/FileSessionStorage.ts
|
|
21724
|
-
var
|
|
22258
|
+
var import_sdk_core8 = require("@tinycloud/sdk-core");
|
|
21725
22259
|
var import_fs = require("fs");
|
|
21726
22260
|
var import_path = require("path");
|
|
21727
22261
|
var FileSessionStorage = class {
|
|
@@ -21776,7 +22310,7 @@ var FileSessionStorage = class {
|
|
|
21776
22310
|
try {
|
|
21777
22311
|
const data = (0, import_fs.readFileSync)(filePath, "utf-8");
|
|
21778
22312
|
const parsed = JSON.parse(data);
|
|
21779
|
-
const validation = (0,
|
|
22313
|
+
const validation = (0, import_sdk_core8.validatePersistedSessionData)(parsed);
|
|
21780
22314
|
if (!validation.ok) {
|
|
21781
22315
|
console.warn(`Invalid session data for ${address}:`, validation.error.message);
|
|
21782
22316
|
(0, import_fs.unlinkSync)(filePath);
|
|
@@ -21841,7 +22375,7 @@ var FileSessionStorage = class {
|
|
|
21841
22375
|
};
|
|
21842
22376
|
|
|
21843
22377
|
// src/index.ts
|
|
21844
|
-
var
|
|
22378
|
+
var import_sdk_core11 = require("@tinycloud/sdk-core");
|
|
21845
22379
|
|
|
21846
22380
|
// src/delegation.ts
|
|
21847
22381
|
async function grantAuthRequest(authority, request, options) {
|
|
@@ -21886,7 +22420,6 @@ function deserializeDelegation(data) {
|
|
|
21886
22420
|
}
|
|
21887
22421
|
|
|
21888
22422
|
// src/index.ts
|
|
21889
|
-
var import_sdk_core11 = require("@tinycloud/sdk-core");
|
|
21890
22423
|
var import_sdk_core12 = require("@tinycloud/sdk-core");
|
|
21891
22424
|
var import_sdk_core13 = require("@tinycloud/sdk-core");
|
|
21892
22425
|
var import_sdk_core14 = require("@tinycloud/sdk-core");
|
|
@@ -21897,6 +22430,7 @@ var import_sdk_core18 = require("@tinycloud/sdk-core");
|
|
|
21897
22430
|
var import_sdk_core19 = require("@tinycloud/sdk-core");
|
|
21898
22431
|
var import_sdk_core20 = require("@tinycloud/sdk-core");
|
|
21899
22432
|
var import_sdk_core21 = require("@tinycloud/sdk-core");
|
|
22433
|
+
var import_sdk_core22 = require("@tinycloud/sdk-core");
|
|
21900
22434
|
// Annotate the CommonJS export names for ESM import in node:
|
|
21901
22435
|
0 && (module.exports = {
|
|
21902
22436
|
ACCOUNT_REGISTRY_PATH,
|
|
@@ -21952,6 +22486,7 @@ var import_sdk_core21 = require("@tinycloud/sdk-core");
|
|
|
21952
22486
|
SpaceErrorCodes,
|
|
21953
22487
|
SpaceService,
|
|
21954
22488
|
TinyCloud,
|
|
22489
|
+
TinyCloudDebugLogger,
|
|
21955
22490
|
TinyCloudNode,
|
|
21956
22491
|
UnsupportedFeatureError,
|
|
21957
22492
|
VAULT_PERMISSION_SERVICE,
|
|
@@ -21976,8 +22511,10 @@ var import_sdk_core21 = require("@tinycloud/sdk-core");
|
|
|
21976
22511
|
canonicalizeSecretScope,
|
|
21977
22512
|
checkDecryptInvocationInput,
|
|
21978
22513
|
checkNodeInfo,
|
|
22514
|
+
clearTinyCloudDebugLogs,
|
|
21979
22515
|
composeManifestRequest,
|
|
21980
22516
|
createCapabilityKeyRegistry,
|
|
22517
|
+
createOpenKeyCallbackSigningStrategy,
|
|
21981
22518
|
createSharingService,
|
|
21982
22519
|
createSpaceService,
|
|
21983
22520
|
createVaultCrypto,
|
|
@@ -21989,7 +22526,9 @@ var import_sdk_core21 = require("@tinycloud/sdk-core");
|
|
|
21989
22526
|
deserializeDelegation,
|
|
21990
22527
|
didCacheKey,
|
|
21991
22528
|
didEquals,
|
|
22529
|
+
disableTinyCloudDebug,
|
|
21992
22530
|
discoverNetwork,
|
|
22531
|
+
enableTinyCloudDebug,
|
|
21993
22532
|
encryptToNetwork,
|
|
21994
22533
|
encryptionBase64Decode,
|
|
21995
22534
|
encryptionBase64Encode,
|
|
@@ -22001,9 +22540,11 @@ var import_sdk_core21 = require("@tinycloud/sdk-core");
|
|
|
22001
22540
|
expandPermissionEntries,
|
|
22002
22541
|
expandPermissionEntry,
|
|
22003
22542
|
generateRandomReceiverKey,
|
|
22543
|
+
getTinyCloudDebugLogs,
|
|
22004
22544
|
grantAuthRequest,
|
|
22005
22545
|
hexDecode,
|
|
22006
22546
|
hexEncode,
|
|
22547
|
+
installTinyCloudDebugGlobals,
|
|
22007
22548
|
isCapabilitySubset,
|
|
22008
22549
|
isEvmAddress,
|
|
22009
22550
|
isNetworkId,
|
|
@@ -22025,6 +22566,7 @@ var import_sdk_core21 = require("@tinycloud/sdk-core");
|
|
|
22025
22566
|
resolveSecretPath,
|
|
22026
22567
|
resourceCapabilitiesToSpaceAbilitiesMap,
|
|
22027
22568
|
serializeDelegation,
|
|
22569
|
+
tinyCloudDebugLogger,
|
|
22028
22570
|
validateEnvelope,
|
|
22029
22571
|
validateManifest,
|
|
22030
22572
|
verifyDecryptResponse
|