@tinycloud/node-sdk 2.4.0-beta.5 → 2.4.0-beta.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{core-BSQqoLAd.d.cts → core-iwTdsebf.d.cts} +13 -1
- package/dist/{core-BSQqoLAd.d.ts → core-iwTdsebf.d.ts} +13 -1
- package/dist/core.cjs +262 -193
- 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 +80 -12
- package/dist/core.js.map +1 -1
- package/dist/index.cjs +305 -236
- 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 +80 -12
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -17025,134 +17025,135 @@ 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
|
-
|
|
17031
|
-
|
|
17032
|
-
|
|
17033
|
-
|
|
17034
|
-
|
|
17035
|
-
|
|
17036
|
-
|
|
17037
|
-
|
|
17038
|
-
|
|
17039
|
-
|
|
17040
|
-
|
|
17041
|
-
|
|
17042
|
-
|
|
17028
|
+
ACCOUNT_REGISTRY_PATH: () => import_sdk_core10.ACCOUNT_REGISTRY_PATH,
|
|
17029
|
+
ACCOUNT_REGISTRY_SPACE: () => import_sdk_core10.ACCOUNT_REGISTRY_SPACE,
|
|
17030
|
+
AccountService: () => import_sdk_core2.AccountService,
|
|
17031
|
+
AutoApproveSpaceCreationHandler: () => import_sdk_core9.AutoApproveSpaceCreationHandler,
|
|
17032
|
+
CapabilityKeyRegistry: () => import_sdk_core18.CapabilityKeyRegistry,
|
|
17033
|
+
CapabilityKeyRegistryErrorCodes: () => import_sdk_core18.CapabilityKeyRegistryErrorCodes,
|
|
17034
|
+
DECRYPT_ACTION: () => import_sdk_core15.DECRYPT_ACTION,
|
|
17035
|
+
DECRYPT_FACT_TYPE: () => import_sdk_core15.DECRYPT_FACT_TYPE,
|
|
17036
|
+
DECRYPT_RESULT_TYPE: () => import_sdk_core15.DECRYPT_RESULT_TYPE,
|
|
17037
|
+
DEFAULT_ENCRYPTION_ALG: () => import_sdk_core15.DEFAULT_ENCRYPTION_ALG,
|
|
17038
|
+
DEFAULT_KEY_VERSION: () => import_sdk_core15.DEFAULT_KEY_VERSION,
|
|
17039
|
+
DEFAULT_MANIFEST_SPACE: () => import_sdk_core10.DEFAULT_MANIFEST_SPACE,
|
|
17040
|
+
DEFAULT_MANIFEST_VERSION: () => import_sdk_core10.DEFAULT_MANIFEST_VERSION,
|
|
17041
|
+
DEFAULT_SIGNED_READ_URL_EXPIRY_MS: () => import_sdk_core11.DEFAULT_SIGNED_READ_URL_EXPIRY_MS,
|
|
17042
|
+
DataVaultService: () => import_sdk_core14.DataVaultService,
|
|
17043
|
+
DatabaseHandle: () => import_sdk_core12.DatabaseHandle,
|
|
17043
17044
|
DelegatedAccess: () => DelegatedAccess,
|
|
17044
|
-
DelegationErrorCodes: () =>
|
|
17045
|
-
DelegationManager: () =>
|
|
17046
|
-
DuckDbAction: () =>
|
|
17047
|
-
DuckDbDatabaseHandle: () =>
|
|
17048
|
-
DuckDbService: () =>
|
|
17049
|
-
ENCRYPTION_NETWORK_URN_PREFIX: () =>
|
|
17050
|
-
ENCRYPTION_SERVICE: () =>
|
|
17051
|
-
ENCRYPTION_SERVICE_SHORT: () =>
|
|
17052
|
-
ENVELOPE_VERSION: () =>
|
|
17053
|
-
EncryptionService: () =>
|
|
17045
|
+
DelegationErrorCodes: () => import_sdk_core17.DelegationErrorCodes,
|
|
17046
|
+
DelegationManager: () => import_sdk_core17.DelegationManager,
|
|
17047
|
+
DuckDbAction: () => import_sdk_core13.DuckDbAction,
|
|
17048
|
+
DuckDbDatabaseHandle: () => import_sdk_core13.DuckDbDatabaseHandle,
|
|
17049
|
+
DuckDbService: () => import_sdk_core13.DuckDbService,
|
|
17050
|
+
ENCRYPTION_NETWORK_URN_PREFIX: () => import_sdk_core15.ENCRYPTION_NETWORK_URN_PREFIX,
|
|
17051
|
+
ENCRYPTION_SERVICE: () => import_sdk_core15.ENCRYPTION_SERVICE,
|
|
17052
|
+
ENCRYPTION_SERVICE_SHORT: () => import_sdk_core15.ENCRYPTION_SERVICE_SHORT,
|
|
17053
|
+
ENVELOPE_VERSION: () => import_sdk_core15.ENVELOPE_VERSION,
|
|
17054
|
+
EncryptionService: () => import_sdk_core15.EncryptionService,
|
|
17054
17055
|
FileSessionStorage: () => FileSessionStorage,
|
|
17055
|
-
HooksService: () =>
|
|
17056
|
-
IdentityParseError: () =>
|
|
17057
|
-
KVService: () =>
|
|
17058
|
-
ManifestValidationError: () =>
|
|
17056
|
+
HooksService: () => import_sdk_core16.HooksService,
|
|
17057
|
+
IdentityParseError: () => import_sdk_core9.IdentityParseError,
|
|
17058
|
+
KVService: () => import_sdk_core11.KVService,
|
|
17059
|
+
ManifestValidationError: () => import_sdk_core10.ManifestValidationError,
|
|
17059
17060
|
MemorySessionStorage: () => MemorySessionStorage,
|
|
17060
|
-
NETWORK_NAME_PATTERN: () =>
|
|
17061
|
-
NetworkIdError: () =>
|
|
17061
|
+
NETWORK_NAME_PATTERN: () => import_sdk_core15.NETWORK_NAME_PATTERN,
|
|
17062
|
+
NetworkIdError: () => import_sdk_core15.NetworkIdError,
|
|
17062
17063
|
NodeUserAuthorization: () => NodeUserAuthorization,
|
|
17063
17064
|
NodeWasmBindings: () => NodeWasmBindings,
|
|
17064
|
-
PermissionNotInManifestError: () =>
|
|
17065
|
-
PrefixedKVService: () =>
|
|
17065
|
+
PermissionNotInManifestError: () => import_sdk_core10.PermissionNotInManifestError,
|
|
17066
|
+
PrefixedKVService: () => import_sdk_core11.PrefixedKVService,
|
|
17066
17067
|
PrivateKeySigner: () => PrivateKeySigner,
|
|
17067
|
-
ProtocolMismatchError: () =>
|
|
17068
|
-
SECRET_NAME_RE: () =>
|
|
17069
|
-
SQLAction: () =>
|
|
17070
|
-
SQLService: () =>
|
|
17071
|
-
SecretsService: () =>
|
|
17072
|
-
ServiceContext: () =>
|
|
17073
|
-
SessionExpiredError: () =>
|
|
17074
|
-
SharingService: () =>
|
|
17075
|
-
SilentNotificationHandler: () =>
|
|
17076
|
-
Space: () =>
|
|
17077
|
-
SpaceErrorCodes: () =>
|
|
17078
|
-
SpaceService: () =>
|
|
17079
|
-
TinyCloud: () =>
|
|
17068
|
+
ProtocolMismatchError: () => import_sdk_core20.ProtocolMismatchError,
|
|
17069
|
+
SECRET_NAME_RE: () => import_sdk_core14.SECRET_NAME_RE,
|
|
17070
|
+
SQLAction: () => import_sdk_core12.SQLAction,
|
|
17071
|
+
SQLService: () => import_sdk_core12.SQLService,
|
|
17072
|
+
SecretsService: () => import_sdk_core14.SecretsService,
|
|
17073
|
+
ServiceContext: () => import_sdk_core21.ServiceContext,
|
|
17074
|
+
SessionExpiredError: () => import_sdk_core10.SessionExpiredError,
|
|
17075
|
+
SharingService: () => import_sdk_core17.SharingService,
|
|
17076
|
+
SilentNotificationHandler: () => import_sdk_core9.SilentNotificationHandler,
|
|
17077
|
+
Space: () => import_sdk_core19.Space,
|
|
17078
|
+
SpaceErrorCodes: () => import_sdk_core19.SpaceErrorCodes,
|
|
17079
|
+
SpaceService: () => import_sdk_core19.SpaceService,
|
|
17080
|
+
TinyCloud: () => import_sdk_core8.TinyCloud,
|
|
17080
17081
|
TinyCloudNode: () => TinyCloudNode,
|
|
17081
|
-
UnsupportedFeatureError: () =>
|
|
17082
|
-
VAULT_PERMISSION_SERVICE: () =>
|
|
17083
|
-
VaultHeaders: () =>
|
|
17084
|
-
VaultPublicSpaceKVActions: () =>
|
|
17085
|
-
VersionCheckError: () =>
|
|
17082
|
+
UnsupportedFeatureError: () => import_sdk_core20.UnsupportedFeatureError,
|
|
17083
|
+
VAULT_PERMISSION_SERVICE: () => import_sdk_core10.VAULT_PERMISSION_SERVICE,
|
|
17084
|
+
VaultHeaders: () => import_sdk_core14.VaultHeaders,
|
|
17085
|
+
VaultPublicSpaceKVActions: () => import_sdk_core14.VaultPublicSpaceKVActions,
|
|
17086
|
+
VersionCheckError: () => import_sdk_core20.VersionCheckError,
|
|
17086
17087
|
WasmKeyProvider: () => WasmKeyProvider,
|
|
17087
|
-
addressStorageKey: () =>
|
|
17088
|
-
buildCanonicalDecryptRequest: () =>
|
|
17089
|
-
buildDecryptAttenuation: () =>
|
|
17090
|
-
buildDecryptFacts: () =>
|
|
17091
|
-
buildDecryptInvocation: () =>
|
|
17092
|
-
buildNetworkId: () =>
|
|
17093
|
-
buildSpaceUri: () =>
|
|
17094
|
-
canonicalHashHex: () =>
|
|
17095
|
-
canonicalSignedResponse: () =>
|
|
17096
|
-
canonicalizeAddress: () =>
|
|
17097
|
-
canonicalizeDid: () =>
|
|
17098
|
-
canonicalizeDidUrl: () =>
|
|
17099
|
-
canonicalizeEncryptionJson: () =>
|
|
17100
|
-
canonicalizeNetworkId: () =>
|
|
17101
|
-
canonicalizeSecretScope: () =>
|
|
17102
|
-
checkDecryptInvocationInput: () =>
|
|
17103
|
-
checkNodeInfo: () =>
|
|
17104
|
-
composeManifestRequest: () =>
|
|
17105
|
-
createCapabilityKeyRegistry: () =>
|
|
17106
|
-
createSharingService: () =>
|
|
17107
|
-
createSpaceService: () =>
|
|
17108
|
-
createVaultCrypto: () =>
|
|
17088
|
+
addressStorageKey: () => import_sdk_core9.addressStorageKey,
|
|
17089
|
+
buildCanonicalDecryptRequest: () => import_sdk_core15.buildCanonicalDecryptRequest,
|
|
17090
|
+
buildDecryptAttenuation: () => import_sdk_core15.buildDecryptAttenuation,
|
|
17091
|
+
buildDecryptFacts: () => import_sdk_core15.buildDecryptFacts,
|
|
17092
|
+
buildDecryptInvocation: () => import_sdk_core15.buildDecryptInvocation,
|
|
17093
|
+
buildNetworkId: () => import_sdk_core15.buildNetworkId,
|
|
17094
|
+
buildSpaceUri: () => import_sdk_core19.buildSpaceUri,
|
|
17095
|
+
canonicalHashHex: () => import_sdk_core15.canonicalHashHex,
|
|
17096
|
+
canonicalSignedResponse: () => import_sdk_core15.canonicalSignedResponse,
|
|
17097
|
+
canonicalizeAddress: () => import_sdk_core9.canonicalizeAddress,
|
|
17098
|
+
canonicalizeDid: () => import_sdk_core9.canonicalizeDid,
|
|
17099
|
+
canonicalizeDidUrl: () => import_sdk_core9.canonicalizeDidUrl,
|
|
17100
|
+
canonicalizeEncryptionJson: () => import_sdk_core15.canonicalizeEncryptionJson,
|
|
17101
|
+
canonicalizeNetworkId: () => import_sdk_core9.canonicalizeNetworkId,
|
|
17102
|
+
canonicalizeSecretScope: () => import_sdk_core14.canonicalizeSecretScope,
|
|
17103
|
+
checkDecryptInvocationInput: () => import_sdk_core15.checkDecryptInvocationInput,
|
|
17104
|
+
checkNodeInfo: () => import_sdk_core20.checkNodeInfo,
|
|
17105
|
+
composeManifestRequest: () => import_sdk_core10.composeManifestRequest,
|
|
17106
|
+
createCapabilityKeyRegistry: () => import_sdk_core18.createCapabilityKeyRegistry,
|
|
17107
|
+
createSharingService: () => import_sdk_core17.createSharingService,
|
|
17108
|
+
createSpaceService: () => import_sdk_core19.createSpaceService,
|
|
17109
|
+
createVaultCrypto: () => import_sdk_core14.createVaultCrypto,
|
|
17109
17110
|
createWasmKeyProvider: () => createWasmKeyProvider,
|
|
17110
|
-
decryptEnvelopeWithKey: () =>
|
|
17111
|
+
decryptEnvelopeWithKey: () => import_sdk_core15.decryptEnvelopeWithKey,
|
|
17111
17112
|
defaultSignStrategy: () => defaultSignStrategy,
|
|
17112
|
-
defaultSpaceCreationHandler: () =>
|
|
17113
|
-
deriveSignedReceiverKey: () =>
|
|
17113
|
+
defaultSpaceCreationHandler: () => import_sdk_core9.defaultSpaceCreationHandler,
|
|
17114
|
+
deriveSignedReceiverKey: () => import_sdk_core15.deriveSignedReceiverKey,
|
|
17114
17115
|
deserializeDelegation: () => deserializeDelegation,
|
|
17115
|
-
didCacheKey: () =>
|
|
17116
|
-
didEquals: () =>
|
|
17117
|
-
discoverNetwork: () =>
|
|
17118
|
-
encryptToNetwork: () =>
|
|
17119
|
-
encryptionBase64Decode: () =>
|
|
17120
|
-
encryptionBase64Encode: () =>
|
|
17121
|
-
encryptionError: () =>
|
|
17122
|
-
encryptionUtf8Decode: () =>
|
|
17123
|
-
encryptionUtf8Encode: () =>
|
|
17124
|
-
ensureNetworkUsableForDecrypt: () =>
|
|
17125
|
-
expandActionShortNames: () =>
|
|
17126
|
-
expandPermissionEntries: () =>
|
|
17127
|
-
expandPermissionEntry: () =>
|
|
17128
|
-
generateRandomReceiverKey: () =>
|
|
17116
|
+
didCacheKey: () => import_sdk_core9.didCacheKey,
|
|
17117
|
+
didEquals: () => import_sdk_core9.didEquals,
|
|
17118
|
+
discoverNetwork: () => import_sdk_core15.discoverNetwork,
|
|
17119
|
+
encryptToNetwork: () => import_sdk_core15.encryptToNetwork,
|
|
17120
|
+
encryptionBase64Decode: () => import_sdk_core15.encryptionBase64Decode,
|
|
17121
|
+
encryptionBase64Encode: () => import_sdk_core15.encryptionBase64Encode,
|
|
17122
|
+
encryptionError: () => import_sdk_core15.encryptionError,
|
|
17123
|
+
encryptionUtf8Decode: () => import_sdk_core15.encryptionUtf8Decode,
|
|
17124
|
+
encryptionUtf8Encode: () => import_sdk_core15.encryptionUtf8Encode,
|
|
17125
|
+
ensureNetworkUsableForDecrypt: () => import_sdk_core15.ensureNetworkUsableForDecrypt,
|
|
17126
|
+
expandActionShortNames: () => import_sdk_core10.expandActionShortNames,
|
|
17127
|
+
expandPermissionEntries: () => import_sdk_core10.expandPermissionEntries,
|
|
17128
|
+
expandPermissionEntry: () => import_sdk_core10.expandPermissionEntry,
|
|
17129
|
+
generateRandomReceiverKey: () => import_sdk_core15.generateRandomReceiverKey,
|
|
17129
17130
|
grantAuthRequest: () => grantAuthRequest,
|
|
17130
|
-
hexDecode: () =>
|
|
17131
|
-
hexEncode: () =>
|
|
17132
|
-
isCapabilitySubset: () =>
|
|
17133
|
-
isEvmAddress: () =>
|
|
17134
|
-
isNetworkId: () =>
|
|
17135
|
-
loadManifest: () =>
|
|
17136
|
-
makePkhSpaceId: () =>
|
|
17137
|
-
makePublicSpaceId: () =>
|
|
17138
|
-
networkDiscoveryKey: () =>
|
|
17139
|
-
openWrappedKey: () =>
|
|
17140
|
-
parseCanonicalNetworkId: () =>
|
|
17141
|
-
parseExpiry: () =>
|
|
17142
|
-
parseNetworkId: () =>
|
|
17143
|
-
parsePkhDid: () =>
|
|
17144
|
-
parseSpaceUri: () =>
|
|
17145
|
-
pkhDid: () =>
|
|
17146
|
-
principalDid: () =>
|
|
17147
|
-
principalDidEquals: () =>
|
|
17148
|
-
resolveManifest: () =>
|
|
17149
|
-
resolveSecretListPrefix: () =>
|
|
17150
|
-
resolveSecretPath: () =>
|
|
17151
|
-
resourceCapabilitiesToSpaceAbilitiesMap: () =>
|
|
17131
|
+
hexDecode: () => import_sdk_core15.hexDecode,
|
|
17132
|
+
hexEncode: () => import_sdk_core15.hexEncode,
|
|
17133
|
+
isCapabilitySubset: () => import_sdk_core10.isCapabilitySubset,
|
|
17134
|
+
isEvmAddress: () => import_sdk_core9.isEvmAddress,
|
|
17135
|
+
isNetworkId: () => import_sdk_core15.isNetworkId,
|
|
17136
|
+
loadManifest: () => import_sdk_core10.loadManifest,
|
|
17137
|
+
makePkhSpaceId: () => import_sdk_core9.makePkhSpaceId,
|
|
17138
|
+
makePublicSpaceId: () => import_sdk_core19.makePublicSpaceId,
|
|
17139
|
+
networkDiscoveryKey: () => import_sdk_core15.networkDiscoveryKey,
|
|
17140
|
+
openWrappedKey: () => import_sdk_core15.openWrappedKey,
|
|
17141
|
+
parseCanonicalNetworkId: () => import_sdk_core9.parseCanonicalNetworkId,
|
|
17142
|
+
parseExpiry: () => import_sdk_core10.parseExpiry,
|
|
17143
|
+
parseNetworkId: () => import_sdk_core15.parseNetworkId,
|
|
17144
|
+
parsePkhDid: () => import_sdk_core9.parsePkhDid,
|
|
17145
|
+
parseSpaceUri: () => import_sdk_core19.parseSpaceUri,
|
|
17146
|
+
pkhDid: () => import_sdk_core9.pkhDid,
|
|
17147
|
+
principalDid: () => import_sdk_core9.principalDid,
|
|
17148
|
+
principalDidEquals: () => import_sdk_core9.principalDidEquals,
|
|
17149
|
+
resolveManifest: () => import_sdk_core10.resolveManifest,
|
|
17150
|
+
resolveSecretListPrefix: () => import_sdk_core14.resolveSecretListPrefix,
|
|
17151
|
+
resolveSecretPath: () => import_sdk_core14.resolveSecretPath,
|
|
17152
|
+
resourceCapabilitiesToSpaceAbilitiesMap: () => import_sdk_core10.resourceCapabilitiesToSpaceAbilitiesMap,
|
|
17152
17153
|
serializeDelegation: () => serializeDelegation,
|
|
17153
|
-
validateEnvelope: () =>
|
|
17154
|
-
validateManifest: () =>
|
|
17155
|
-
verifyDecryptResponse: () =>
|
|
17154
|
+
validateEnvelope: () => import_sdk_core15.validateEnvelope,
|
|
17155
|
+
validateManifest: () => import_sdk_core10.validateManifest,
|
|
17156
|
+
verifyDecryptResponse: () => import_sdk_core15.verifyDecryptResponse
|
|
17156
17157
|
});
|
|
17157
17158
|
module.exports = __toCommonJS(index_exports);
|
|
17158
17159
|
|
|
@@ -17257,7 +17258,7 @@ var PrivateKeySigner = class {
|
|
|
17257
17258
|
};
|
|
17258
17259
|
|
|
17259
17260
|
// src/TinyCloudNode.ts
|
|
17260
|
-
var
|
|
17261
|
+
var import_sdk_core6 = require("@tinycloud/sdk-core");
|
|
17261
17262
|
|
|
17262
17263
|
// src/authorization/NodeUserAuthorization.ts
|
|
17263
17264
|
var import_sdk_core = require("@tinycloud/sdk-core");
|
|
@@ -18155,30 +18156,33 @@ var NodeUserAuthorization = class {
|
|
|
18155
18156
|
}
|
|
18156
18157
|
};
|
|
18157
18158
|
|
|
18158
|
-
// src/
|
|
18159
|
+
// src/account/AccountService.ts
|
|
18159
18160
|
var import_sdk_core2 = require("@tinycloud/sdk-core");
|
|
18161
|
+
|
|
18162
|
+
// src/DelegatedAccess.ts
|
|
18163
|
+
var import_sdk_core3 = require("@tinycloud/sdk-core");
|
|
18160
18164
|
var DelegatedAccess = class {
|
|
18161
18165
|
constructor(session, delegation, host, invoke2, telemetry) {
|
|
18162
18166
|
this.session = session;
|
|
18163
18167
|
this._delegation = delegation;
|
|
18164
18168
|
this.host = host;
|
|
18165
|
-
this._serviceContext = new
|
|
18169
|
+
this._serviceContext = new import_sdk_core3.ServiceContext({
|
|
18166
18170
|
invoke: invoke2,
|
|
18167
18171
|
fetch: globalThis.fetch.bind(globalThis),
|
|
18168
18172
|
hosts: [host],
|
|
18169
18173
|
telemetry
|
|
18170
18174
|
});
|
|
18171
18175
|
const prefix = this._delegation.path.replace(/\/$/, "");
|
|
18172
|
-
this._kv = new
|
|
18176
|
+
this._kv = new import_sdk_core3.KVService({ prefix });
|
|
18173
18177
|
this._kv.initialize(this._serviceContext);
|
|
18174
18178
|
this._serviceContext.registerService("kv", this._kv);
|
|
18175
|
-
this._sql = new
|
|
18179
|
+
this._sql = new import_sdk_core3.SQLService({});
|
|
18176
18180
|
this._sql.initialize(this._serviceContext);
|
|
18177
18181
|
this._serviceContext.registerService("sql", this._sql);
|
|
18178
|
-
this._duckdb = new
|
|
18182
|
+
this._duckdb = new import_sdk_core3.DuckDbService({});
|
|
18179
18183
|
this._duckdb.initialize(this._serviceContext);
|
|
18180
18184
|
this._serviceContext.registerService("duckdb", this._duckdb);
|
|
18181
|
-
this._hooks = new
|
|
18185
|
+
this._hooks = new import_sdk_core3.HooksService({});
|
|
18182
18186
|
this._hooks.initialize(this._serviceContext);
|
|
18183
18187
|
this._serviceContext.registerService("hooks", this._hooks);
|
|
18184
18188
|
const serviceSession = {
|
|
@@ -18328,7 +18332,7 @@ function createWasmKeyProvider(sessionManager) {
|
|
|
18328
18332
|
}
|
|
18329
18333
|
|
|
18330
18334
|
// src/delegateToHelpers.ts
|
|
18331
|
-
var
|
|
18335
|
+
var import_sdk_core4 = require("@tinycloud/sdk-core");
|
|
18332
18336
|
function legacyParamsToPermissionEntries(actions, path, spaceIdOverride) {
|
|
18333
18337
|
const byService = /* @__PURE__ */ new Map();
|
|
18334
18338
|
for (const a of actions) {
|
|
@@ -18359,7 +18363,7 @@ function legacyParamsToPermissionEntries(actions, path, spaceIdOverride) {
|
|
|
18359
18363
|
}
|
|
18360
18364
|
return entries;
|
|
18361
18365
|
}
|
|
18362
|
-
var DEFAULT_DELEGATION_EXPIRY_MS =
|
|
18366
|
+
var DEFAULT_DELEGATION_EXPIRY_MS = import_sdk_core4.EXPIRY.SESSION_MS;
|
|
18363
18367
|
function resolveExpiryMs(expiry) {
|
|
18364
18368
|
if (expiry === void 0) {
|
|
18365
18369
|
return DEFAULT_DELEGATION_EXPIRY_MS;
|
|
@@ -18372,10 +18376,10 @@ function resolveExpiryMs(expiry) {
|
|
|
18372
18376
|
}
|
|
18373
18377
|
return expiry;
|
|
18374
18378
|
}
|
|
18375
|
-
return (0,
|
|
18379
|
+
return (0, import_sdk_core4.parseExpiry)(expiry);
|
|
18376
18380
|
}
|
|
18377
18381
|
function extractSiweExpiration(siwe) {
|
|
18378
|
-
const parsed = new
|
|
18382
|
+
const parsed = new import_sdk_core4.SiweMessage(siwe);
|
|
18379
18383
|
if (parsed.expirationTime === void 0 || parsed.expirationTime === null) {
|
|
18380
18384
|
return void 0;
|
|
18381
18385
|
}
|
|
@@ -18389,7 +18393,7 @@ function extractSiweExpiration(siwe) {
|
|
|
18389
18393
|
}
|
|
18390
18394
|
|
|
18391
18395
|
// src/NodeSecretsService.ts
|
|
18392
|
-
var
|
|
18396
|
+
var import_sdk_core5 = require("@tinycloud/sdk-core");
|
|
18393
18397
|
var SECRETS_SPACE = "secrets";
|
|
18394
18398
|
function ok() {
|
|
18395
18399
|
return { ok: true, data: void 0 };
|
|
@@ -18422,7 +18426,7 @@ function secretActionName(action) {
|
|
|
18422
18426
|
}
|
|
18423
18427
|
function secretPermissionEntries(name, options, action, encryptionNetworkId) {
|
|
18424
18428
|
const entries = [];
|
|
18425
|
-
const path = action === "list" ? (0,
|
|
18429
|
+
const path = action === "list" ? (0, import_sdk_core5.resolveSecretListPrefix)(options) : (0, import_sdk_core5.resolveSecretPath)(name, options).permissionPaths.vault;
|
|
18426
18430
|
entries.push({
|
|
18427
18431
|
service: "tinycloud.kv",
|
|
18428
18432
|
space: SECRETS_SPACE,
|
|
@@ -18501,7 +18505,7 @@ var NodeSecretsService = class {
|
|
|
18501
18505
|
);
|
|
18502
18506
|
} catch (error) {
|
|
18503
18507
|
return secretsError(
|
|
18504
|
-
|
|
18508
|
+
import_sdk_core5.ErrorCodes.INVALID_INPUT,
|
|
18505
18509
|
error instanceof Error ? error.message : String(error),
|
|
18506
18510
|
error instanceof Error ? error : void 0
|
|
18507
18511
|
);
|
|
@@ -18511,7 +18515,7 @@ var NodeSecretsService = class {
|
|
|
18511
18515
|
}
|
|
18512
18516
|
if (!this.config.canEscalate()) {
|
|
18513
18517
|
return secretsError(
|
|
18514
|
-
|
|
18518
|
+
import_sdk_core5.ErrorCodes.PERMISSION_DENIED,
|
|
18515
18519
|
`Cannot autosign ${displayActionUrn(action)} for ${target}; TinyCloudNode needs wallet mode with a signer or privateKey.`
|
|
18516
18520
|
);
|
|
18517
18521
|
}
|
|
@@ -18520,7 +18524,7 @@ var NodeSecretsService = class {
|
|
|
18520
18524
|
return this.restoreUnlockAfterEscalation();
|
|
18521
18525
|
} catch (error) {
|
|
18522
18526
|
return secretsError(
|
|
18523
|
-
|
|
18527
|
+
import_sdk_core5.ErrorCodes.PERMISSION_DENIED,
|
|
18524
18528
|
error instanceof Error ? error.message : `Autosign escalation for ${displayActionUrn(action)} on ${target} failed.`,
|
|
18525
18529
|
error instanceof Error ? error : void 0
|
|
18526
18530
|
);
|
|
@@ -18541,10 +18545,10 @@ var NodeSecretsService = class {
|
|
|
18541
18545
|
return false;
|
|
18542
18546
|
}
|
|
18543
18547
|
const manifests = Array.isArray(manifest) ? manifest : [manifest];
|
|
18544
|
-
const requestedEntries = (0,
|
|
18548
|
+
const requestedEntries = (0, import_sdk_core5.expandPermissionEntries)(permissionEntries);
|
|
18545
18549
|
return requestedEntries.every(
|
|
18546
18550
|
(entry) => manifests.some((candidate) => {
|
|
18547
|
-
const resolved = (0,
|
|
18551
|
+
const resolved = (0, import_sdk_core5.resolveManifest)(candidate);
|
|
18548
18552
|
return resolved.resources.some(
|
|
18549
18553
|
(resource) => resource.service === entry.service && resource.space === entry.space && resource.path === entry.path && entry.actions.every((action) => resource.actions.includes(action))
|
|
18550
18554
|
);
|
|
@@ -18559,10 +18563,10 @@ var DEFAULT_ENCRYPTION_NETWORK_NAME = "default";
|
|
|
18559
18563
|
var NETWORK_CREATE_ACTION2 = "tinycloud.encryption/network.create";
|
|
18560
18564
|
var DECRYPT_ACTION2 = "tinycloud.encryption/decrypt";
|
|
18561
18565
|
var NETWORK_ADMIN_TYPE = "tinycloud.encryption.network-admin/v1";
|
|
18562
|
-
var DEFAULT_SESSION_EXPIRATION_MS =
|
|
18566
|
+
var DEFAULT_SESSION_EXPIRATION_MS = import_sdk_core6.EXPIRY.SESSION_MS;
|
|
18563
18567
|
function didPrincipalMatches2(actual, expected) {
|
|
18564
18568
|
try {
|
|
18565
|
-
return (0,
|
|
18569
|
+
return (0, import_sdk_core6.principalDidEquals)(actual, expected);
|
|
18566
18570
|
} catch {
|
|
18567
18571
|
return actual === expected;
|
|
18568
18572
|
}
|
|
@@ -18728,12 +18732,12 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
18728
18732
|
throw new Error("Failed to get session key JWK");
|
|
18729
18733
|
}
|
|
18730
18734
|
this.sessionKeyJwk = JSON.parse(jwkStr);
|
|
18731
|
-
this._capabilityRegistry = new
|
|
18735
|
+
this._capabilityRegistry = new import_sdk_core6.CapabilityKeyRegistry();
|
|
18732
18736
|
this._keyProvider = new WasmKeyProvider({
|
|
18733
18737
|
sessionManager: this.sessionManager
|
|
18734
18738
|
});
|
|
18735
|
-
this.notificationHandler = config.notificationHandler ?? new
|
|
18736
|
-
this._sharingService = new
|
|
18739
|
+
this.notificationHandler = config.notificationHandler ?? new import_sdk_core6.SilentNotificationHandler();
|
|
18740
|
+
this._sharingService = new import_sdk_core6.SharingService({
|
|
18737
18741
|
hosts: [this.config.host],
|
|
18738
18742
|
// session: undefined - not needed for receive()
|
|
18739
18743
|
invoke: this.invokeWithRuntimePermissions,
|
|
@@ -18743,8 +18747,8 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
18743
18747
|
// delegationManager: undefined - not needed for receive()
|
|
18744
18748
|
createKVService: (config2) => {
|
|
18745
18749
|
const prefix = config2.pathPrefix?.replace(/\/$/, "");
|
|
18746
|
-
const kvService = new
|
|
18747
|
-
const kvContext = new
|
|
18750
|
+
const kvService = new import_sdk_core6.KVService({ prefix });
|
|
18751
|
+
const kvContext = new import_sdk_core6.ServiceContext({
|
|
18748
18752
|
invoke: config2.invoke,
|
|
18749
18753
|
fetch: config2.fetch ?? globalThis.fetch.bind(globalThis),
|
|
18750
18754
|
hosts: config2.hosts,
|
|
@@ -18804,7 +18808,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
18804
18808
|
capabilityRequest: config.capabilityRequest,
|
|
18805
18809
|
includeAccountRegistryPermissions: config.includeAccountRegistryPermissions
|
|
18806
18810
|
});
|
|
18807
|
-
this.tc = new
|
|
18811
|
+
this.tc = new import_sdk_core6.TinyCloud(this.auth, {
|
|
18808
18812
|
invokeAny: this.invokeAnyWithRuntimePermissions,
|
|
18809
18813
|
telemetry: config.telemetry
|
|
18810
18814
|
});
|
|
@@ -18865,7 +18869,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
18865
18869
|
*/
|
|
18866
18870
|
get did() {
|
|
18867
18871
|
if (this._address) {
|
|
18868
|
-
return (0,
|
|
18872
|
+
return (0, import_sdk_core6.pkhDid)(this._address, this._chainId);
|
|
18869
18873
|
}
|
|
18870
18874
|
return this.sessionManager.getDID(this.sessionKeyId);
|
|
18871
18875
|
}
|
|
@@ -18899,6 +18903,37 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
18899
18903
|
get spaceId() {
|
|
18900
18904
|
return this.auth?.tinyCloudSession?.spaceId;
|
|
18901
18905
|
}
|
|
18906
|
+
/**
|
|
18907
|
+
* Get the account space ID for this wallet identity.
|
|
18908
|
+
* Available after wallet-backed sign-in or a restored session with address metadata.
|
|
18909
|
+
*/
|
|
18910
|
+
get accountSpaceId() {
|
|
18911
|
+
if (!this._address) {
|
|
18912
|
+
return void 0;
|
|
18913
|
+
}
|
|
18914
|
+
return this.wasmBindings.makeSpaceId(this._address, this._chainId, import_sdk_core6.ACCOUNT_REGISTRY_SPACE);
|
|
18915
|
+
}
|
|
18916
|
+
/**
|
|
18917
|
+
* Account-level application and delegation helpers.
|
|
18918
|
+
*/
|
|
18919
|
+
get account() {
|
|
18920
|
+
if (!this._account) {
|
|
18921
|
+
this._account = new import_sdk_core2.AccountService({
|
|
18922
|
+
getDid: () => this.did,
|
|
18923
|
+
getHost: () => this.hosts[0] ?? this.config.host,
|
|
18924
|
+
getPrimarySpaceId: () => this.spaceId,
|
|
18925
|
+
getAccountSpaceId: () => this.accountSpaceId,
|
|
18926
|
+
getSpaces: () => this.spaces,
|
|
18927
|
+
getAccountDb: () => this.accountSpaceId ? this.sqlForSpace(this.accountSpaceId).db("account") : void 0,
|
|
18928
|
+
ensureAccountSpaceHosted: async () => {
|
|
18929
|
+
if (this.accountSpaceId && this.auth) {
|
|
18930
|
+
await this.ensureOwnedSpaceHosted(this.accountSpaceId);
|
|
18931
|
+
}
|
|
18932
|
+
}
|
|
18933
|
+
});
|
|
18934
|
+
}
|
|
18935
|
+
return this._account;
|
|
18936
|
+
}
|
|
18902
18937
|
/**
|
|
18903
18938
|
* Get the current TinyCloud session.
|
|
18904
18939
|
* Available after signIn().
|
|
@@ -18920,7 +18955,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
18920
18955
|
);
|
|
18921
18956
|
}
|
|
18922
18957
|
await this.wasmBindings.ensureInitialized?.();
|
|
18923
|
-
this._address = (0,
|
|
18958
|
+
this._address = (0, import_sdk_core6.canonicalizeAddress)(await this.signer.getAddress());
|
|
18924
18959
|
this._chainId = await this.signer.getChainId();
|
|
18925
18960
|
this._kv = void 0;
|
|
18926
18961
|
this._sql = void 0;
|
|
@@ -18940,7 +18975,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
18940
18975
|
if (this.config.manifest === void 0 && this.config.capabilityRequest === void 0) {
|
|
18941
18976
|
await this.ensureOwnedSpaceHosted(this.ownedSpaceId("secrets"));
|
|
18942
18977
|
}
|
|
18943
|
-
|
|
18978
|
+
this.scheduleAccountRegistrySync();
|
|
18944
18979
|
this.notificationHandler.success("Successfully signed in");
|
|
18945
18980
|
}
|
|
18946
18981
|
ownedSpaceId(name) {
|
|
@@ -18957,21 +18992,42 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
18957
18992
|
if (!this.auth || !this.signer) {
|
|
18958
18993
|
throw new Error("Manifest registry write requires wallet mode");
|
|
18959
18994
|
}
|
|
18960
|
-
const accountSpaceId = this.ownedSpaceId(
|
|
18995
|
+
const accountSpaceId = this.ownedSpaceId(import_sdk_core6.ACCOUNT_REGISTRY_SPACE);
|
|
18961
18996
|
await this.ensureOwnedSpaceHosted(accountSpaceId);
|
|
18962
|
-
const
|
|
18963
|
-
|
|
18964
|
-
|
|
18965
|
-
|
|
18966
|
-
|
|
18967
|
-
|
|
18968
|
-
|
|
18969
|
-
|
|
18970
|
-
|
|
18971
|
-
|
|
18972
|
-
|
|
18997
|
+
const result = await this.account.applications.register(request.manifests);
|
|
18998
|
+
if (!result.ok) {
|
|
18999
|
+
throw new Error(
|
|
19000
|
+
`Failed to write manifest registry records: ${result.error.message}`
|
|
19001
|
+
);
|
|
19002
|
+
}
|
|
19003
|
+
}
|
|
19004
|
+
scheduleAccountRegistrySync() {
|
|
19005
|
+
void this.withAccountRegistryRetry(async () => {
|
|
19006
|
+
await this.writeManifestRegistryRecords();
|
|
19007
|
+
const spaces = await this.account.spaces.syncAccessible();
|
|
19008
|
+
if (!spaces.ok) {
|
|
19009
|
+
throw new Error(`Failed to sync account spaces: ${spaces.error.message}`);
|
|
19010
|
+
}
|
|
19011
|
+
});
|
|
19012
|
+
}
|
|
19013
|
+
async withAccountRegistryRetry(task) {
|
|
19014
|
+
const delays = [250, 1e3, 3e3];
|
|
19015
|
+
let lastError;
|
|
19016
|
+
for (let attempt = 0; attempt < delays.length; attempt += 1) {
|
|
19017
|
+
try {
|
|
19018
|
+
await task();
|
|
19019
|
+
return;
|
|
19020
|
+
} catch (error) {
|
|
19021
|
+
lastError = error;
|
|
19022
|
+
if (attempt < delays.length - 1) {
|
|
19023
|
+
await new Promise((resolve) => setTimeout(resolve, delays[attempt]));
|
|
19024
|
+
}
|
|
18973
19025
|
}
|
|
18974
19026
|
}
|
|
19027
|
+
console.warn(
|
|
19028
|
+
"TinyCloud account registry sync failed after retries",
|
|
19029
|
+
lastError
|
|
19030
|
+
);
|
|
18975
19031
|
}
|
|
18976
19032
|
requestedEncryptionNetworkIds() {
|
|
18977
19033
|
const request = this.capabilityRequest;
|
|
@@ -18980,7 +19036,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
18980
19036
|
}
|
|
18981
19037
|
const networkIds = /* @__PURE__ */ new Set();
|
|
18982
19038
|
for (const resource of request.resources) {
|
|
18983
|
-
if (resource.service ===
|
|
19039
|
+
if (resource.service === import_sdk_core6.ENCRYPTION_PERMISSION_SERVICE && resource.path.startsWith("urn:tinycloud:encryption:") && resource.actions.includes(DECRYPT_ACTION2)) {
|
|
18984
19040
|
networkIds.add(resource.path);
|
|
18985
19041
|
}
|
|
18986
19042
|
}
|
|
@@ -18991,7 +19047,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
18991
19047
|
return;
|
|
18992
19048
|
}
|
|
18993
19049
|
for (const networkId of this.requestedEncryptionNetworkIds()) {
|
|
18994
|
-
const parsed = (0,
|
|
19050
|
+
const parsed = (0, import_sdk_core6.parseNetworkId)(networkId);
|
|
18995
19051
|
if (!didPrincipalMatches2(parsed.ownerDid, this.did)) {
|
|
18996
19052
|
continue;
|
|
18997
19053
|
}
|
|
@@ -19010,7 +19066,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
19010
19066
|
if (!host) {
|
|
19011
19067
|
throw new Error("Owned space hosting requires a TinyCloud host");
|
|
19012
19068
|
}
|
|
19013
|
-
const activation = await (0,
|
|
19069
|
+
const activation = await (0, import_sdk_core6.activateSessionWithHost)(host, session.delegationHeader);
|
|
19014
19070
|
if (activation.success && !activation.skipped?.includes(spaceId)) {
|
|
19015
19071
|
return;
|
|
19016
19072
|
}
|
|
@@ -19024,7 +19080,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
19024
19080
|
throw new Error(`Failed to create owned space: ${spaceId}`);
|
|
19025
19081
|
}
|
|
19026
19082
|
await new Promise((resolve) => setTimeout(resolve, 100));
|
|
19027
|
-
const retry = await (0,
|
|
19083
|
+
const retry = await (0, import_sdk_core6.activateSessionWithHost)(host, session.delegationHeader);
|
|
19028
19084
|
if (!retry.success || retry.skipped?.includes(spaceId)) {
|
|
19029
19085
|
throw new Error(
|
|
19030
19086
|
`Failed to activate session after creating owned space ${spaceId}: ${retry.error ?? "space was skipped"}`
|
|
@@ -19066,7 +19122,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
19066
19122
|
if (!hosted) {
|
|
19067
19123
|
throw new Error(`Failed to host owned space: ${spaceId}`);
|
|
19068
19124
|
}
|
|
19069
|
-
const activation = await (0,
|
|
19125
|
+
const activation = await (0, import_sdk_core6.activateSessionWithHost)(
|
|
19070
19126
|
host,
|
|
19071
19127
|
this.auth.tinyCloudSession.delegationHeader
|
|
19072
19128
|
);
|
|
@@ -19075,6 +19131,15 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
19075
19131
|
`Failed to activate session for owned space ${spaceId}: ${activation.error ?? "space was skipped"}`
|
|
19076
19132
|
);
|
|
19077
19133
|
}
|
|
19134
|
+
void this.account.spaces.register({
|
|
19135
|
+
spaceId,
|
|
19136
|
+
name,
|
|
19137
|
+
ownerDid: this.did,
|
|
19138
|
+
type: "owned",
|
|
19139
|
+
permissions: ["*"],
|
|
19140
|
+
status: "active"
|
|
19141
|
+
}).catch(() => {
|
|
19142
|
+
});
|
|
19078
19143
|
return spaceId;
|
|
19079
19144
|
}
|
|
19080
19145
|
/**
|
|
@@ -19099,30 +19164,30 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
19099
19164
|
this._spaceService = void 0;
|
|
19100
19165
|
this._serviceContext = void 0;
|
|
19101
19166
|
this.runtimePermissionGrants = [];
|
|
19102
|
-
const restoredAddress = sessionData.address ? (0,
|
|
19167
|
+
const restoredAddress = sessionData.address ? (0, import_sdk_core6.canonicalizeAddress)(sessionData.address) : void 0;
|
|
19103
19168
|
if (restoredAddress) {
|
|
19104
19169
|
this._address = restoredAddress;
|
|
19105
19170
|
}
|
|
19106
19171
|
if (sessionData.chainId) {
|
|
19107
19172
|
this._chainId = sessionData.chainId;
|
|
19108
19173
|
}
|
|
19109
|
-
this._serviceContext = new
|
|
19174
|
+
this._serviceContext = new import_sdk_core6.ServiceContext({
|
|
19110
19175
|
invoke: this.invokeWithRuntimePermissions,
|
|
19111
19176
|
invokeAny: this.invokeAnyWithRuntimePermissions,
|
|
19112
19177
|
fetch: globalThis.fetch.bind(globalThis),
|
|
19113
19178
|
hosts: [this.config.host],
|
|
19114
19179
|
telemetry: this.config.telemetry
|
|
19115
19180
|
});
|
|
19116
|
-
this._kv = new
|
|
19181
|
+
this._kv = new import_sdk_core6.KVService({});
|
|
19117
19182
|
this._kv.initialize(this._serviceContext);
|
|
19118
19183
|
this._serviceContext.registerService("kv", this._kv);
|
|
19119
|
-
this._sql = new
|
|
19184
|
+
this._sql = new import_sdk_core6.SQLService({});
|
|
19120
19185
|
this._sql.initialize(this._serviceContext);
|
|
19121
19186
|
this._serviceContext.registerService("sql", this._sql);
|
|
19122
|
-
this._duckdb = new
|
|
19187
|
+
this._duckdb = new import_sdk_core6.DuckDbService({});
|
|
19123
19188
|
this._duckdb.initialize(this._serviceContext);
|
|
19124
19189
|
this._serviceContext.registerService("duckdb", this._duckdb);
|
|
19125
|
-
this._hooks = new
|
|
19190
|
+
this._hooks = new import_sdk_core6.HooksService({});
|
|
19126
19191
|
this._hooks.initialize(this._serviceContext);
|
|
19127
19192
|
this._serviceContext.registerService("hooks", this._hooks);
|
|
19128
19193
|
const serviceSession = {
|
|
@@ -19221,7 +19286,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
19221
19286
|
capabilityRequest: this.config.capabilityRequest,
|
|
19222
19287
|
includeAccountRegistryPermissions: this.config.includeAccountRegistryPermissions
|
|
19223
19288
|
});
|
|
19224
|
-
this.tc = new
|
|
19289
|
+
this.tc = new import_sdk_core6.TinyCloud(this.auth, {
|
|
19225
19290
|
invokeAny: this.invokeAnyWithRuntimePermissions,
|
|
19226
19291
|
telemetry: this.config.telemetry
|
|
19227
19292
|
});
|
|
@@ -19266,7 +19331,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
19266
19331
|
capabilityRequest: this.config.capabilityRequest,
|
|
19267
19332
|
includeAccountRegistryPermissions: this.config.includeAccountRegistryPermissions
|
|
19268
19333
|
});
|
|
19269
|
-
this.tc = new
|
|
19334
|
+
this.tc = new import_sdk_core6.TinyCloud(this.auth, {
|
|
19270
19335
|
invokeAny: this.invokeAnyWithRuntimePermissions,
|
|
19271
19336
|
telemetry: this.config.telemetry
|
|
19272
19337
|
});
|
|
@@ -19282,28 +19347,28 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
19282
19347
|
return;
|
|
19283
19348
|
}
|
|
19284
19349
|
this.tc.initializeServices(this.invokeWithRuntimePermissions, [this.config.host]);
|
|
19285
|
-
this._serviceContext = new
|
|
19350
|
+
this._serviceContext = new import_sdk_core6.ServiceContext({
|
|
19286
19351
|
invoke: this.invokeWithRuntimePermissions,
|
|
19287
19352
|
invokeAny: this.invokeAnyWithRuntimePermissions,
|
|
19288
19353
|
fetch: globalThis.fetch.bind(globalThis),
|
|
19289
19354
|
hosts: [this.config.host],
|
|
19290
19355
|
telemetry: this.config.telemetry
|
|
19291
19356
|
});
|
|
19292
|
-
this._kv = new
|
|
19357
|
+
this._kv = new import_sdk_core6.KVService({});
|
|
19293
19358
|
this._kv.initialize(this._serviceContext);
|
|
19294
19359
|
this._serviceContext.registerService("kv", this._kv);
|
|
19295
19360
|
const features = this.nodeFeatures;
|
|
19296
19361
|
if (features.length === 0 || features.includes("sql")) {
|
|
19297
|
-
this._sql = new
|
|
19362
|
+
this._sql = new import_sdk_core6.SQLService({});
|
|
19298
19363
|
this._sql.initialize(this._serviceContext);
|
|
19299
19364
|
this._serviceContext.registerService("sql", this._sql);
|
|
19300
19365
|
}
|
|
19301
19366
|
if (features.length === 0 || features.includes("duckdb")) {
|
|
19302
|
-
this._duckdb = new
|
|
19367
|
+
this._duckdb = new import_sdk_core6.DuckDbService({});
|
|
19303
19368
|
this._duckdb.initialize(this._serviceContext);
|
|
19304
19369
|
this._serviceContext.registerService("duckdb", this._duckdb);
|
|
19305
19370
|
}
|
|
19306
|
-
this._hooks = new
|
|
19371
|
+
this._hooks = new import_sdk_core6.HooksService({});
|
|
19307
19372
|
this._hooks.initialize(this._serviceContext);
|
|
19308
19373
|
this._serviceContext.registerService("hooks", this._hooks);
|
|
19309
19374
|
const serviceSession = {
|
|
@@ -19321,9 +19386,9 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
19321
19386
|
this.initializeV2Services(serviceSession);
|
|
19322
19387
|
}
|
|
19323
19388
|
createSpaceScopedKVService(spaceId) {
|
|
19324
|
-
const kvService = new
|
|
19389
|
+
const kvService = new import_sdk_core6.KVService({});
|
|
19325
19390
|
if (this._serviceContext) {
|
|
19326
|
-
const spaceScopedContext = new
|
|
19391
|
+
const spaceScopedContext = new import_sdk_core6.ServiceContext({
|
|
19327
19392
|
invoke: this._serviceContext.invoke,
|
|
19328
19393
|
fetch: this._serviceContext.fetch,
|
|
19329
19394
|
hosts: this._serviceContext.hosts,
|
|
@@ -19388,7 +19453,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
19388
19453
|
const shared = wasm.vault_x25519_dh(receiverPrivateKey, peerPublic);
|
|
19389
19454
|
return columnDecrypt(shared, ciphertext);
|
|
19390
19455
|
},
|
|
19391
|
-
verifyNodeSignature: (nodeId, message, signature2) => (0,
|
|
19456
|
+
verifyNodeSignature: (nodeId, message, signature2) => (0, import_sdk_core6.verifyDidKeyEd25519Signature)(nodeId, message, signature2)
|
|
19392
19457
|
};
|
|
19393
19458
|
}
|
|
19394
19459
|
async fetchNodeId() {
|
|
@@ -19459,7 +19524,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
19459
19524
|
return await response.json();
|
|
19460
19525
|
}
|
|
19461
19526
|
};
|
|
19462
|
-
return new
|
|
19527
|
+
return new import_sdk_core6.EncryptionService({
|
|
19463
19528
|
crypto: crypto2,
|
|
19464
19529
|
signer: {
|
|
19465
19530
|
signDecryptInvocation: async (input) => {
|
|
@@ -19471,7 +19536,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
19471
19536
|
});
|
|
19472
19537
|
return {
|
|
19473
19538
|
...signed2,
|
|
19474
|
-
canonicalBody: (0,
|
|
19539
|
+
canonicalBody: (0, import_sdk_core6.canonicalizeEncryptionJson)(
|
|
19475
19540
|
input.body
|
|
19476
19541
|
)
|
|
19477
19542
|
};
|
|
@@ -19489,8 +19554,8 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
19489
19554
|
if (!this.config.host) {
|
|
19490
19555
|
return null;
|
|
19491
19556
|
}
|
|
19492
|
-
const publicSpaceId = (0,
|
|
19493
|
-
const result = await
|
|
19557
|
+
const publicSpaceId = (0, import_sdk_core6.makePublicSpaceId)(this._address, this._chainId);
|
|
19558
|
+
const result = await import_sdk_core6.TinyCloud.readPublicSpace(this.config.host, publicSpaceId, discoveryKey);
|
|
19494
19559
|
if (!result.ok) {
|
|
19495
19560
|
return null;
|
|
19496
19561
|
}
|
|
@@ -19513,7 +19578,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
19513
19578
|
}
|
|
19514
19579
|
createVaultService(spaceId, kv) {
|
|
19515
19580
|
const wasm = this.wasmBindings;
|
|
19516
|
-
const vaultCrypto = (0,
|
|
19581
|
+
const vaultCrypto = (0, import_sdk_core6.createVaultCrypto)({
|
|
19517
19582
|
vault_encrypt: wasm.vault_encrypt,
|
|
19518
19583
|
vault_decrypt: wasm.vault_decrypt,
|
|
19519
19584
|
vault_derive_key: wasm.vault_derive_key,
|
|
@@ -19523,7 +19588,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
19523
19588
|
vault_sha256: wasm.vault_sha256
|
|
19524
19589
|
});
|
|
19525
19590
|
const self2 = this;
|
|
19526
|
-
return new
|
|
19591
|
+
return new import_sdk_core6.DataVaultService({
|
|
19527
19592
|
spaceId,
|
|
19528
19593
|
crypto: vaultCrypto,
|
|
19529
19594
|
encryption: {
|
|
@@ -19546,8 +19611,8 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
19546
19611
|
get publicKV() {
|
|
19547
19612
|
return self2._publicKV ?? self2.tc.publicKV;
|
|
19548
19613
|
},
|
|
19549
|
-
readPublicSpace: (host, targetSpaceId, key2) =>
|
|
19550
|
-
makePublicSpaceId:
|
|
19614
|
+
readPublicSpace: (host, targetSpaceId, key2) => import_sdk_core6.TinyCloud.readPublicSpace(host, targetSpaceId, key2),
|
|
19615
|
+
makePublicSpaceId: import_sdk_core6.TinyCloud.makePublicSpaceId,
|
|
19551
19616
|
did: this.did,
|
|
19552
19617
|
address: this._address ?? "",
|
|
19553
19618
|
chainId: this._chainId,
|
|
@@ -19560,7 +19625,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
19560
19625
|
* @internal
|
|
19561
19626
|
*/
|
|
19562
19627
|
initializeV2Services(serviceSession) {
|
|
19563
|
-
this._capabilityRegistry = new
|
|
19628
|
+
this._capabilityRegistry = new import_sdk_core6.CapabilityKeyRegistry();
|
|
19564
19629
|
const tcSession = this.auth?.tinyCloudSession;
|
|
19565
19630
|
if (tcSession && this._address) {
|
|
19566
19631
|
const sessionKey = {
|
|
@@ -19634,13 +19699,13 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
19634
19699
|
}
|
|
19635
19700
|
this._capabilityRegistry.registerKey(sessionKey, delegations);
|
|
19636
19701
|
}
|
|
19637
|
-
this._delegationManager = new
|
|
19702
|
+
this._delegationManager = new import_sdk_core6.DelegationManager({
|
|
19638
19703
|
hosts: [this.config.host],
|
|
19639
19704
|
session: serviceSession,
|
|
19640
19705
|
invoke: this.invokeWithRuntimePermissions,
|
|
19641
19706
|
fetch: globalThis.fetch.bind(globalThis)
|
|
19642
19707
|
});
|
|
19643
|
-
this._spaceService = new
|
|
19708
|
+
this._spaceService = new import_sdk_core6.SpaceService({
|
|
19644
19709
|
hosts: [this.config.host],
|
|
19645
19710
|
session: serviceSession,
|
|
19646
19711
|
invoke: this.wasmBindings.invoke,
|
|
@@ -19692,6 +19757,9 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
19692
19757
|
}
|
|
19693
19758
|
};
|
|
19694
19759
|
}
|
|
19760
|
+
},
|
|
19761
|
+
onSpaceRegistered: async (space) => {
|
|
19762
|
+
await this.account.spaces.register(space);
|
|
19695
19763
|
}
|
|
19696
19764
|
});
|
|
19697
19765
|
this._sharingService.updateConfig({
|
|
@@ -19797,7 +19865,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
19797
19865
|
...prepared,
|
|
19798
19866
|
signature: signature2
|
|
19799
19867
|
});
|
|
19800
|
-
const activateResult = await (0,
|
|
19868
|
+
const activateResult = await (0, import_sdk_core6.activateSessionWithHost)(
|
|
19801
19869
|
host,
|
|
19802
19870
|
delegationSession.delegationHeader
|
|
19803
19871
|
);
|
|
@@ -19807,7 +19875,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
19807
19875
|
return {
|
|
19808
19876
|
cid: delegationSession.delegationCid,
|
|
19809
19877
|
delegateDID: params.shareKeyDID,
|
|
19810
|
-
delegatorDID: (0,
|
|
19878
|
+
delegatorDID: (0, import_sdk_core6.pkhDid)(session.address, session.chainId),
|
|
19811
19879
|
spaceId: params.spaceId,
|
|
19812
19880
|
path: params.path,
|
|
19813
19881
|
actions: params.actions,
|
|
@@ -19864,7 +19932,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
19864
19932
|
if (!this._sql) {
|
|
19865
19933
|
const features = this.nodeFeatures;
|
|
19866
19934
|
if (features.length > 0 && !features.includes("sql")) {
|
|
19867
|
-
throw new
|
|
19935
|
+
throw new import_sdk_core6.UnsupportedFeatureError("sql", this.config.host, features);
|
|
19868
19936
|
}
|
|
19869
19937
|
throw new Error("Not signed in. Call signIn() first.");
|
|
19870
19938
|
}
|
|
@@ -19888,8 +19956,8 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
19888
19956
|
if (!this._serviceContext || !this._serviceContext.session) {
|
|
19889
19957
|
throw new Error("Not signed in. Call signIn() first.");
|
|
19890
19958
|
}
|
|
19891
|
-
const sql = new
|
|
19892
|
-
const spaceScopedContext = new
|
|
19959
|
+
const sql = new import_sdk_core6.SQLService({});
|
|
19960
|
+
const spaceScopedContext = new import_sdk_core6.ServiceContext({
|
|
19893
19961
|
invoke: this._serviceContext.invoke,
|
|
19894
19962
|
fetch: this._serviceContext.fetch,
|
|
19895
19963
|
hosts: this._serviceContext.hosts,
|
|
@@ -19917,8 +19985,8 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
19917
19985
|
if (!this._serviceContext || !this._serviceContext.session) {
|
|
19918
19986
|
throw new Error("Not signed in. Call signIn() first.");
|
|
19919
19987
|
}
|
|
19920
|
-
const kv = new
|
|
19921
|
-
const spaceScopedContext = new
|
|
19988
|
+
const kv = new import_sdk_core6.KVService({});
|
|
19989
|
+
const spaceScopedContext = new import_sdk_core6.ServiceContext({
|
|
19922
19990
|
invoke: this._serviceContext.invoke,
|
|
19923
19991
|
fetch: this._serviceContext.fetch,
|
|
19924
19992
|
hosts: this._serviceContext.hosts
|
|
@@ -19934,7 +20002,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
19934
20002
|
if (!this._duckdb) {
|
|
19935
20003
|
const features = this.nodeFeatures;
|
|
19936
20004
|
if (features.length > 0 && !features.includes("duckdb")) {
|
|
19937
|
-
throw new
|
|
20005
|
+
throw new import_sdk_core6.UnsupportedFeatureError("duckdb", this.config.host, features);
|
|
19938
20006
|
}
|
|
19939
20007
|
throw new Error("Not signed in. Call signIn() first.");
|
|
19940
20008
|
}
|
|
@@ -19986,7 +20054,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
19986
20054
|
type: NETWORK_ADMIN_TYPE,
|
|
19987
20055
|
targetNode,
|
|
19988
20056
|
networkId,
|
|
19989
|
-
bodyHash: (0,
|
|
20057
|
+
bodyHash: (0, import_sdk_core6.canonicalHashHex)(
|
|
19990
20058
|
crypto2.sha256,
|
|
19991
20059
|
body
|
|
19992
20060
|
),
|
|
@@ -20004,7 +20072,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
20004
20072
|
Authorization: signed2.authorization,
|
|
20005
20073
|
"Content-Type": "application/json"
|
|
20006
20074
|
},
|
|
20007
|
-
body: (0,
|
|
20075
|
+
body: (0, import_sdk_core6.canonicalizeEncryptionJson)(
|
|
20008
20076
|
body
|
|
20009
20077
|
)
|
|
20010
20078
|
});
|
|
@@ -20022,7 +20090,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
20022
20090
|
if (existing) {
|
|
20023
20091
|
return existing;
|
|
20024
20092
|
}
|
|
20025
|
-
const parsed = (0,
|
|
20093
|
+
const parsed = (0, import_sdk_core6.parseNetworkId)(networkId);
|
|
20026
20094
|
if (!didPrincipalMatches2(parsed.ownerDid, this.did)) {
|
|
20027
20095
|
throw new Error(
|
|
20028
20096
|
`Cannot create encryption network ${networkId}: owner ${parsed.ownerDid} does not match signed-in DID ${this.did}`
|
|
@@ -20055,7 +20123,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
20055
20123
|
throw new Error("Not signed in. Call signIn() first.");
|
|
20056
20124
|
}
|
|
20057
20125
|
if (!this._baseSecrets) {
|
|
20058
|
-
this._baseSecrets = new
|
|
20126
|
+
this._baseSecrets = new import_sdk_core6.SecretsService(() => this.space("secrets").vault);
|
|
20059
20127
|
}
|
|
20060
20128
|
return this._baseSecrets;
|
|
20061
20129
|
}
|
|
@@ -20170,10 +20238,10 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
20170
20238
|
async useRuntimeDelegation(delegation) {
|
|
20171
20239
|
const session = this.currentTinyCloudSession();
|
|
20172
20240
|
if (!session) {
|
|
20173
|
-
throw new
|
|
20241
|
+
throw new import_sdk_core6.SessionExpiredError(/* @__PURE__ */ new Date(0));
|
|
20174
20242
|
}
|
|
20175
20243
|
if (delegation.expiry.getTime() <= Date.now()) {
|
|
20176
|
-
throw new
|
|
20244
|
+
throw new import_sdk_core6.SessionExpiredError(delegation.expiry);
|
|
20177
20245
|
}
|
|
20178
20246
|
const expectedDids = [session.verificationMethod, this.sessionDid];
|
|
20179
20247
|
if (!expectedDids.some((did) => didPrincipalMatches2(delegation.delegateDID, did))) {
|
|
@@ -20182,7 +20250,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
20182
20250
|
);
|
|
20183
20251
|
}
|
|
20184
20252
|
const targetHost = delegation.host ?? this.config.host;
|
|
20185
|
-
const activateResult = await (0,
|
|
20253
|
+
const activateResult = await (0, import_sdk_core6.activateSessionWithHost)(
|
|
20186
20254
|
targetHost,
|
|
20187
20255
|
delegation.delegationHeader
|
|
20188
20256
|
);
|
|
@@ -20209,13 +20277,13 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
20209
20277
|
}
|
|
20210
20278
|
const session = this.currentTinyCloudSession();
|
|
20211
20279
|
if (!session) {
|
|
20212
|
-
throw new
|
|
20280
|
+
throw new import_sdk_core6.SessionExpiredError(/* @__PURE__ */ new Date(0));
|
|
20213
20281
|
}
|
|
20214
20282
|
const sessionExpiry = extractSiweExpiration(session.siwe);
|
|
20215
20283
|
if (sessionExpiry !== void 0) {
|
|
20216
20284
|
const marginMs = _TinyCloudNode.SESSION_EXPIRY_SAFETY_MARGIN_MS;
|
|
20217
20285
|
if (sessionExpiry.getTime() <= Date.now() + marginMs) {
|
|
20218
|
-
throw new
|
|
20286
|
+
throw new import_sdk_core6.SessionExpiredError(sessionExpiry);
|
|
20219
20287
|
}
|
|
20220
20288
|
}
|
|
20221
20289
|
const expanded = this.expandPermissionEntries(permissions);
|
|
@@ -20278,7 +20346,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
20278
20346
|
...prepared,
|
|
20279
20347
|
signature: signature2
|
|
20280
20348
|
});
|
|
20281
|
-
const activateResult = await (0,
|
|
20349
|
+
const activateResult = await (0, import_sdk_core6.activateSessionWithHost)(
|
|
20282
20350
|
this.config.host,
|
|
20283
20351
|
delegatedSession.delegationHeader
|
|
20284
20352
|
);
|
|
@@ -20451,7 +20519,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
20451
20519
|
];
|
|
20452
20520
|
const abilities = { kv: { "": kvActions } };
|
|
20453
20521
|
const now = /* @__PURE__ */ new Date();
|
|
20454
|
-
const expiryMs =
|
|
20522
|
+
const expiryMs = import_sdk_core6.EXPIRY.EPHEMERAL_MS;
|
|
20455
20523
|
const expirationTime = new Date(now.getTime() + expiryMs);
|
|
20456
20524
|
const prepared = this.wasmBindings.prepareSession({
|
|
20457
20525
|
abilities,
|
|
@@ -20469,7 +20537,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
20469
20537
|
...prepared,
|
|
20470
20538
|
signature: signature2
|
|
20471
20539
|
});
|
|
20472
|
-
const activateResult = await (0,
|
|
20540
|
+
const activateResult = await (0, import_sdk_core6.activateSessionWithHost)(
|
|
20473
20541
|
this.config.host,
|
|
20474
20542
|
delegationSession.delegationHeader
|
|
20475
20543
|
);
|
|
@@ -20496,8 +20564,8 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
20496
20564
|
}]);
|
|
20497
20565
|
}
|
|
20498
20566
|
if (this._serviceContext) {
|
|
20499
|
-
const publicKV = new
|
|
20500
|
-
const publicContext = new
|
|
20567
|
+
const publicKV = new import_sdk_core6.KVService({ prefix: "" });
|
|
20568
|
+
const publicContext = new import_sdk_core6.ServiceContext({
|
|
20501
20569
|
invoke: this.invokeWithRuntimePermissions,
|
|
20502
20570
|
fetch: this._serviceContext.fetch,
|
|
20503
20571
|
hosts: this._serviceContext.hosts,
|
|
@@ -20624,14 +20692,14 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
20624
20692
|
async delegateTo(did, permissions, options) {
|
|
20625
20693
|
const session = this.currentTinyCloudSession();
|
|
20626
20694
|
if (!session) {
|
|
20627
|
-
throw new
|
|
20695
|
+
throw new import_sdk_core6.SessionExpiredError(/* @__PURE__ */ new Date(0));
|
|
20628
20696
|
}
|
|
20629
20697
|
const sessionExpiry = extractSiweExpiration(session.siwe);
|
|
20630
20698
|
if (sessionExpiry !== void 0) {
|
|
20631
20699
|
const now2 = Date.now();
|
|
20632
20700
|
const marginMs = _TinyCloudNode.SESSION_EXPIRY_SAFETY_MARGIN_MS;
|
|
20633
20701
|
if (sessionExpiry.getTime() <= now2 + marginMs) {
|
|
20634
|
-
throw new
|
|
20702
|
+
throw new import_sdk_core6.SessionExpiredError(sessionExpiry);
|
|
20635
20703
|
}
|
|
20636
20704
|
}
|
|
20637
20705
|
if (!Array.isArray(permissions) || permissions.length === 0) {
|
|
@@ -20660,11 +20728,11 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
20660
20728
|
);
|
|
20661
20729
|
return { delegation: delegation2, prompted: true };
|
|
20662
20730
|
}
|
|
20663
|
-
const granted = (0,
|
|
20731
|
+
const granted = (0, import_sdk_core6.parseRecapCapabilities)(
|
|
20664
20732
|
(siwe) => this.wasmBindings.parseRecapFromSiwe(siwe),
|
|
20665
20733
|
session.siwe
|
|
20666
20734
|
);
|
|
20667
|
-
const { subset, missing } = (0,
|
|
20735
|
+
const { subset, missing } = (0, import_sdk_core6.isCapabilitySubset)(expandedEntries, granted);
|
|
20668
20736
|
if (!subset) {
|
|
20669
20737
|
const runtimeGrant = this.findGrantForOperations(
|
|
20670
20738
|
this.permissionEntriesToOperations(expandedEntries, session)
|
|
@@ -20672,7 +20740,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
20672
20740
|
if (runtimeGrant) {
|
|
20673
20741
|
const marginMs = _TinyCloudNode.SESSION_EXPIRY_SAFETY_MARGIN_MS;
|
|
20674
20742
|
if (runtimeGrant.expiresAt.getTime() <= Date.now() + marginMs) {
|
|
20675
|
-
throw new
|
|
20743
|
+
throw new import_sdk_core6.SessionExpiredError(runtimeGrant.expiresAt);
|
|
20676
20744
|
}
|
|
20677
20745
|
const runtimeExpiration = runtimeGrant.expiresAt < effectiveExpiration ? runtimeGrant.expiresAt : effectiveExpiration;
|
|
20678
20746
|
const delegation2 = await this.createDelegationViaRuntimeGrant(
|
|
@@ -20683,7 +20751,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
20683
20751
|
);
|
|
20684
20752
|
return { delegation: delegation2, prompted: false };
|
|
20685
20753
|
}
|
|
20686
|
-
throw new
|
|
20754
|
+
throw new import_sdk_core6.PermissionNotInManifestError(missing, granted);
|
|
20687
20755
|
}
|
|
20688
20756
|
const delegation = await this.createDelegationViaWasmPath(
|
|
20689
20757
|
did,
|
|
@@ -20765,7 +20833,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
20765
20833
|
const spaceId = resolvedSpaces.size === 1 ? [...resolvedSpaces][0] : session.spaceId;
|
|
20766
20834
|
const abilities = {};
|
|
20767
20835
|
for (const entry of entries) {
|
|
20768
|
-
const shortService =
|
|
20836
|
+
const shortService = import_sdk_core6.SERVICE_LONG_TO_SHORT[entry.service];
|
|
20769
20837
|
if (shortService === void 0) {
|
|
20770
20838
|
throw new Error(
|
|
20771
20839
|
`delegateTo: unknown service '${entry.service}' \u2014 no short-form mapping`
|
|
@@ -20805,7 +20873,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
20805
20873
|
});
|
|
20806
20874
|
const primary = result.resources[0];
|
|
20807
20875
|
const delegationHeader = { Authorization: result.delegation };
|
|
20808
|
-
const activateResult = await (0,
|
|
20876
|
+
const activateResult = await (0, import_sdk_core6.activateSessionWithHost)(
|
|
20809
20877
|
this.config.host,
|
|
20810
20878
|
delegationHeader
|
|
20811
20879
|
);
|
|
@@ -20840,7 +20908,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
20840
20908
|
const primary = result.resources[0];
|
|
20841
20909
|
const delegationHeader = { Authorization: result.delegation };
|
|
20842
20910
|
const targetHost = grant.delegation.host ?? this.config.host;
|
|
20843
|
-
const activateResult = await (0,
|
|
20911
|
+
const activateResult = await (0, import_sdk_core6.activateSessionWithHost)(
|
|
20844
20912
|
targetHost,
|
|
20845
20913
|
delegationHeader
|
|
20846
20914
|
);
|
|
@@ -20881,10 +20949,10 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
20881
20949
|
return this.wasmBindings.makeSpaceId(session.address, session.chainId, space);
|
|
20882
20950
|
}
|
|
20883
20951
|
expandPermissionEntries(permissions) {
|
|
20884
|
-
return (0,
|
|
20952
|
+
return (0, import_sdk_core6.expandPermissionEntries)(permissions);
|
|
20885
20953
|
}
|
|
20886
20954
|
shortServiceName(service) {
|
|
20887
|
-
const short =
|
|
20955
|
+
const short = import_sdk_core6.SERVICE_LONG_TO_SHORT[service];
|
|
20888
20956
|
if (short === void 0) {
|
|
20889
20957
|
throw new Error(
|
|
20890
20958
|
`unknown service '${service}' \u2014 no short-form mapping`
|
|
@@ -20910,7 +20978,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
20910
20978
|
return abilities;
|
|
20911
20979
|
}
|
|
20912
20980
|
isEncryptionPermissionEntry(entry) {
|
|
20913
|
-
return entry.service ===
|
|
20981
|
+
return entry.service === import_sdk_core6.ENCRYPTION_PERMISSION_SERVICE && entry.path.startsWith("urn:tinycloud:encryption:");
|
|
20914
20982
|
}
|
|
20915
20983
|
permissionsToRawAbilities(entries) {
|
|
20916
20984
|
const rawAbilities = {};
|
|
@@ -20943,11 +21011,11 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
20943
21011
|
}
|
|
20944
21012
|
sessionCoversPermissionEntries(session, entries) {
|
|
20945
21013
|
try {
|
|
20946
|
-
const granted = (0,
|
|
21014
|
+
const granted = (0, import_sdk_core6.parseRecapCapabilities)(
|
|
20947
21015
|
(siwe) => this.wasmBindings.parseRecapFromSiwe(siwe),
|
|
20948
21016
|
session.siwe
|
|
20949
21017
|
);
|
|
20950
|
-
return (0,
|
|
21018
|
+
return (0, import_sdk_core6.isCapabilitySubset)(entries, granted).subset;
|
|
20951
21019
|
} catch {
|
|
20952
21020
|
return false;
|
|
20953
21021
|
}
|
|
@@ -21278,7 +21346,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
21278
21346
|
if (resolvedDelegateDID.endsWith(".eth") && this.config.ensResolver) {
|
|
21279
21347
|
const address = await this.config.ensResolver.resolveAddress(resolvedDelegateDID);
|
|
21280
21348
|
if (!address) throw new Error(`Could not resolve ENS name: ${resolvedDelegateDID}`);
|
|
21281
|
-
resolvedDelegateDID = (0,
|
|
21349
|
+
resolvedDelegateDID = (0, import_sdk_core6.pkhDid)(address, 1);
|
|
21282
21350
|
}
|
|
21283
21351
|
const entries = legacyParamsToPermissionEntries(
|
|
21284
21352
|
params.actions,
|
|
@@ -21293,7 +21361,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
21293
21361
|
);
|
|
21294
21362
|
return result.delegation;
|
|
21295
21363
|
} catch (err) {
|
|
21296
|
-
if (err instanceof
|
|
21364
|
+
if (err instanceof import_sdk_core6.PermissionNotInManifestError) {
|
|
21297
21365
|
} else {
|
|
21298
21366
|
throw err;
|
|
21299
21367
|
}
|
|
@@ -21350,7 +21418,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
21350
21418
|
...prepared,
|
|
21351
21419
|
signature: signature2
|
|
21352
21420
|
});
|
|
21353
|
-
const activateResult = await (0,
|
|
21421
|
+
const activateResult = await (0, import_sdk_core6.activateSessionWithHost)(
|
|
21354
21422
|
this.config.host,
|
|
21355
21423
|
delegationSession.delegationHeader
|
|
21356
21424
|
);
|
|
@@ -21372,7 +21440,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
21372
21440
|
};
|
|
21373
21441
|
const hasKvActions = params.actions.some((a) => a.startsWith("tinycloud.kv/"));
|
|
21374
21442
|
if (hasKvActions && params.includePublicSpace !== false) {
|
|
21375
|
-
const publicSpaceId = (0,
|
|
21443
|
+
const publicSpaceId = (0, import_sdk_core6.makePublicSpaceId)(
|
|
21376
21444
|
this.wasmBindings.ensureEip55(session.address),
|
|
21377
21445
|
session.chainId
|
|
21378
21446
|
);
|
|
@@ -21395,7 +21463,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
21395
21463
|
...publicPrepared,
|
|
21396
21464
|
signature: publicSignature
|
|
21397
21465
|
});
|
|
21398
|
-
const publicActivateResult = await (0,
|
|
21466
|
+
const publicActivateResult = await (0, import_sdk_core6.activateSessionWithHost)(
|
|
21399
21467
|
this.config.host,
|
|
21400
21468
|
publicSession.delegationHeader
|
|
21401
21469
|
);
|
|
@@ -21500,7 +21568,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
21500
21568
|
...prepared,
|
|
21501
21569
|
signature: signature2
|
|
21502
21570
|
});
|
|
21503
|
-
const activateResult = await (0,
|
|
21571
|
+
const activateResult = await (0, import_sdk_core6.activateSessionWithHost)(
|
|
21504
21572
|
targetHost,
|
|
21505
21573
|
invokerSession.delegationHeader
|
|
21506
21574
|
);
|
|
@@ -21606,7 +21674,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
21606
21674
|
...prepared,
|
|
21607
21675
|
signature: signature2
|
|
21608
21676
|
});
|
|
21609
|
-
const activateResult = await (0,
|
|
21677
|
+
const activateResult = await (0, import_sdk_core6.activateSessionWithHost)(
|
|
21610
21678
|
targetHost,
|
|
21611
21679
|
subDelegationSession.delegationHeader
|
|
21612
21680
|
);
|
|
@@ -21648,11 +21716,11 @@ TinyCloudNode.registerNodeDefaults({
|
|
|
21648
21716
|
});
|
|
21649
21717
|
|
|
21650
21718
|
// src/index.ts
|
|
21651
|
-
var import_sdk_core7 = require("@tinycloud/sdk-core");
|
|
21652
21719
|
var import_sdk_core8 = require("@tinycloud/sdk-core");
|
|
21720
|
+
var import_sdk_core9 = require("@tinycloud/sdk-core");
|
|
21653
21721
|
|
|
21654
21722
|
// src/storage/FileSessionStorage.ts
|
|
21655
|
-
var
|
|
21723
|
+
var import_sdk_core7 = require("@tinycloud/sdk-core");
|
|
21656
21724
|
var import_fs = require("fs");
|
|
21657
21725
|
var import_path = require("path");
|
|
21658
21726
|
var FileSessionStorage = class {
|
|
@@ -21707,7 +21775,7 @@ var FileSessionStorage = class {
|
|
|
21707
21775
|
try {
|
|
21708
21776
|
const data = (0, import_fs.readFileSync)(filePath, "utf-8");
|
|
21709
21777
|
const parsed = JSON.parse(data);
|
|
21710
|
-
const validation = (0,
|
|
21778
|
+
const validation = (0, import_sdk_core7.validatePersistedSessionData)(parsed);
|
|
21711
21779
|
if (!validation.ok) {
|
|
21712
21780
|
console.warn(`Invalid session data for ${address}:`, validation.error.message);
|
|
21713
21781
|
(0, import_fs.unlinkSync)(filePath);
|
|
@@ -21772,7 +21840,7 @@ var FileSessionStorage = class {
|
|
|
21772
21840
|
};
|
|
21773
21841
|
|
|
21774
21842
|
// src/index.ts
|
|
21775
|
-
var
|
|
21843
|
+
var import_sdk_core10 = require("@tinycloud/sdk-core");
|
|
21776
21844
|
|
|
21777
21845
|
// src/delegation.ts
|
|
21778
21846
|
async function grantAuthRequest(authority, request, options) {
|
|
@@ -21817,7 +21885,6 @@ function deserializeDelegation(data) {
|
|
|
21817
21885
|
}
|
|
21818
21886
|
|
|
21819
21887
|
// src/index.ts
|
|
21820
|
-
var import_sdk_core10 = require("@tinycloud/sdk-core");
|
|
21821
21888
|
var import_sdk_core11 = require("@tinycloud/sdk-core");
|
|
21822
21889
|
var import_sdk_core12 = require("@tinycloud/sdk-core");
|
|
21823
21890
|
var import_sdk_core13 = require("@tinycloud/sdk-core");
|
|
@@ -21828,10 +21895,12 @@ var import_sdk_core17 = require("@tinycloud/sdk-core");
|
|
|
21828
21895
|
var import_sdk_core18 = require("@tinycloud/sdk-core");
|
|
21829
21896
|
var import_sdk_core19 = require("@tinycloud/sdk-core");
|
|
21830
21897
|
var import_sdk_core20 = require("@tinycloud/sdk-core");
|
|
21898
|
+
var import_sdk_core21 = require("@tinycloud/sdk-core");
|
|
21831
21899
|
// Annotate the CommonJS export names for ESM import in node:
|
|
21832
21900
|
0 && (module.exports = {
|
|
21833
21901
|
ACCOUNT_REGISTRY_PATH,
|
|
21834
21902
|
ACCOUNT_REGISTRY_SPACE,
|
|
21903
|
+
AccountService,
|
|
21835
21904
|
AutoApproveSpaceCreationHandler,
|
|
21836
21905
|
CapabilityKeyRegistry,
|
|
21837
21906
|
CapabilityKeyRegistryErrorCodes,
|