@tinycloud/node-sdk 2.3.1-beta.0 → 2.4.0-beta.10
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-D2hPECHW.d.cts → core-DiVEwp2P.d.cts} +125 -4
- package/dist/{core-D2hPECHW.d.ts → core-DiVEwp2P.d.ts} +125 -4
- package/dist/core.cjs +421 -216
- 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 +250 -43
- package/dist/core.js.map +1 -1
- package/dist/index.cjs +492 -259
- 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 +281 -47
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -17025,133 +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: () =>
|
|
17129
|
-
|
|
17130
|
-
|
|
17131
|
-
|
|
17132
|
-
|
|
17133
|
-
|
|
17134
|
-
|
|
17135
|
-
|
|
17136
|
-
|
|
17137
|
-
|
|
17138
|
-
|
|
17139
|
-
|
|
17140
|
-
|
|
17141
|
-
|
|
17142
|
-
|
|
17143
|
-
|
|
17144
|
-
|
|
17145
|
-
|
|
17146
|
-
|
|
17147
|
-
|
|
17148
|
-
|
|
17149
|
-
|
|
17150
|
-
|
|
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,
|
|
17130
|
+
grantAuthRequest: () => grantAuthRequest,
|
|
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,
|
|
17151
17153
|
serializeDelegation: () => serializeDelegation,
|
|
17152
|
-
validateEnvelope: () =>
|
|
17153
|
-
validateManifest: () =>
|
|
17154
|
-
verifyDecryptResponse: () =>
|
|
17154
|
+
validateEnvelope: () => import_sdk_core15.validateEnvelope,
|
|
17155
|
+
validateManifest: () => import_sdk_core10.validateManifest,
|
|
17156
|
+
verifyDecryptResponse: () => import_sdk_core15.verifyDecryptResponse
|
|
17155
17157
|
});
|
|
17156
17158
|
module.exports = __toCommonJS(index_exports);
|
|
17157
17159
|
|
|
@@ -17256,7 +17258,7 @@ var PrivateKeySigner = class {
|
|
|
17256
17258
|
};
|
|
17257
17259
|
|
|
17258
17260
|
// src/TinyCloudNode.ts
|
|
17259
|
-
var
|
|
17261
|
+
var import_sdk_core6 = require("@tinycloud/sdk-core");
|
|
17260
17262
|
|
|
17261
17263
|
// src/authorization/NodeUserAuthorization.ts
|
|
17262
17264
|
var import_sdk_core = require("@tinycloud/sdk-core");
|
|
@@ -17336,6 +17338,25 @@ var MemorySessionStorage = class {
|
|
|
17336
17338
|
};
|
|
17337
17339
|
|
|
17338
17340
|
// src/authorization/NodeUserAuthorization.ts
|
|
17341
|
+
var DECRYPT_ACTION = "tinycloud.encryption/decrypt";
|
|
17342
|
+
var NETWORK_CREATE_ACTION = "tinycloud.encryption/network.create";
|
|
17343
|
+
function didPrincipalMatches(actual, expected) {
|
|
17344
|
+
try {
|
|
17345
|
+
return (0, import_sdk_core.principalDidEquals)(actual, expected);
|
|
17346
|
+
} catch {
|
|
17347
|
+
return actual === expected;
|
|
17348
|
+
}
|
|
17349
|
+
}
|
|
17350
|
+
function addRawAbility(rawAbilities, resource, action) {
|
|
17351
|
+
const actions = rawAbilities[resource];
|
|
17352
|
+
if (actions === void 0) {
|
|
17353
|
+
rawAbilities[resource] = [action];
|
|
17354
|
+
return;
|
|
17355
|
+
}
|
|
17356
|
+
if (!actions.includes(action)) {
|
|
17357
|
+
actions.push(action);
|
|
17358
|
+
}
|
|
17359
|
+
}
|
|
17339
17360
|
var NodeUserAuthorization = class {
|
|
17340
17361
|
constructor(config) {
|
|
17341
17362
|
this.extensions = [];
|
|
@@ -17362,6 +17383,7 @@ var NodeUserAuthorization = class {
|
|
|
17362
17383
|
"": [
|
|
17363
17384
|
"tinycloud.sql/read",
|
|
17364
17385
|
"tinycloud.sql/write",
|
|
17386
|
+
"tinycloud.sql/ddl",
|
|
17365
17387
|
"tinycloud.sql/admin",
|
|
17366
17388
|
"tinycloud.sql/export"
|
|
17367
17389
|
]
|
|
@@ -17565,20 +17587,18 @@ var NodeUserAuthorization = class {
|
|
|
17565
17587
|
};
|
|
17566
17588
|
}
|
|
17567
17589
|
const rawAbilities = {};
|
|
17590
|
+
const currentDid = (0, import_sdk_core.pkhDid)(address, chainId);
|
|
17568
17591
|
const spaceResources = request.resources.filter((entry) => {
|
|
17569
17592
|
if (entry.service !== import_sdk_core.ENCRYPTION_PERMISSION_SERVICE) {
|
|
17570
17593
|
return true;
|
|
17571
17594
|
}
|
|
17572
|
-
const
|
|
17573
|
-
|
|
17574
|
-
|
|
17575
|
-
|
|
17576
|
-
const
|
|
17577
|
-
|
|
17578
|
-
|
|
17579
|
-
existing.push(action);
|
|
17580
|
-
seen.add(action);
|
|
17581
|
-
}
|
|
17595
|
+
for (const action of entry.actions) {
|
|
17596
|
+
addRawAbility(rawAbilities, entry.path, action);
|
|
17597
|
+
}
|
|
17598
|
+
if (entry.actions.includes(DECRYPT_ACTION)) {
|
|
17599
|
+
const parsed = (0, import_sdk_core.parseNetworkId)(entry.path);
|
|
17600
|
+
if (didPrincipalMatches(parsed.ownerDid, currentDid)) {
|
|
17601
|
+
addRawAbility(rawAbilities, entry.path, NETWORK_CREATE_ACTION);
|
|
17582
17602
|
}
|
|
17583
17603
|
}
|
|
17584
17604
|
return false;
|
|
@@ -18137,30 +18157,33 @@ var NodeUserAuthorization = class {
|
|
|
18137
18157
|
}
|
|
18138
18158
|
};
|
|
18139
18159
|
|
|
18140
|
-
// src/
|
|
18160
|
+
// src/account/AccountService.ts
|
|
18141
18161
|
var import_sdk_core2 = require("@tinycloud/sdk-core");
|
|
18162
|
+
|
|
18163
|
+
// src/DelegatedAccess.ts
|
|
18164
|
+
var import_sdk_core3 = require("@tinycloud/sdk-core");
|
|
18142
18165
|
var DelegatedAccess = class {
|
|
18143
18166
|
constructor(session, delegation, host, invoke2, telemetry) {
|
|
18144
18167
|
this.session = session;
|
|
18145
18168
|
this._delegation = delegation;
|
|
18146
18169
|
this.host = host;
|
|
18147
|
-
this._serviceContext = new
|
|
18170
|
+
this._serviceContext = new import_sdk_core3.ServiceContext({
|
|
18148
18171
|
invoke: invoke2,
|
|
18149
18172
|
fetch: globalThis.fetch.bind(globalThis),
|
|
18150
18173
|
hosts: [host],
|
|
18151
18174
|
telemetry
|
|
18152
18175
|
});
|
|
18153
18176
|
const prefix = this._delegation.path.replace(/\/$/, "");
|
|
18154
|
-
this._kv = new
|
|
18177
|
+
this._kv = new import_sdk_core3.KVService({ prefix });
|
|
18155
18178
|
this._kv.initialize(this._serviceContext);
|
|
18156
18179
|
this._serviceContext.registerService("kv", this._kv);
|
|
18157
|
-
this._sql = new
|
|
18180
|
+
this._sql = new import_sdk_core3.SQLService({});
|
|
18158
18181
|
this._sql.initialize(this._serviceContext);
|
|
18159
18182
|
this._serviceContext.registerService("sql", this._sql);
|
|
18160
|
-
this._duckdb = new
|
|
18183
|
+
this._duckdb = new import_sdk_core3.DuckDbService({});
|
|
18161
18184
|
this._duckdb.initialize(this._serviceContext);
|
|
18162
18185
|
this._serviceContext.registerService("duckdb", this._duckdb);
|
|
18163
|
-
this._hooks = new
|
|
18186
|
+
this._hooks = new import_sdk_core3.HooksService({});
|
|
18164
18187
|
this._hooks.initialize(this._serviceContext);
|
|
18165
18188
|
this._serviceContext.registerService("hooks", this._hooks);
|
|
18166
18189
|
const serviceSession = {
|
|
@@ -18310,7 +18333,7 @@ function createWasmKeyProvider(sessionManager) {
|
|
|
18310
18333
|
}
|
|
18311
18334
|
|
|
18312
18335
|
// src/delegateToHelpers.ts
|
|
18313
|
-
var
|
|
18336
|
+
var import_sdk_core4 = require("@tinycloud/sdk-core");
|
|
18314
18337
|
function legacyParamsToPermissionEntries(actions, path, spaceIdOverride) {
|
|
18315
18338
|
const byService = /* @__PURE__ */ new Map();
|
|
18316
18339
|
for (const a of actions) {
|
|
@@ -18341,7 +18364,7 @@ function legacyParamsToPermissionEntries(actions, path, spaceIdOverride) {
|
|
|
18341
18364
|
}
|
|
18342
18365
|
return entries;
|
|
18343
18366
|
}
|
|
18344
|
-
var DEFAULT_DELEGATION_EXPIRY_MS =
|
|
18367
|
+
var DEFAULT_DELEGATION_EXPIRY_MS = import_sdk_core4.EXPIRY.SESSION_MS;
|
|
18345
18368
|
function resolveExpiryMs(expiry) {
|
|
18346
18369
|
if (expiry === void 0) {
|
|
18347
18370
|
return DEFAULT_DELEGATION_EXPIRY_MS;
|
|
@@ -18354,10 +18377,10 @@ function resolveExpiryMs(expiry) {
|
|
|
18354
18377
|
}
|
|
18355
18378
|
return expiry;
|
|
18356
18379
|
}
|
|
18357
|
-
return (0,
|
|
18380
|
+
return (0, import_sdk_core4.parseExpiry)(expiry);
|
|
18358
18381
|
}
|
|
18359
18382
|
function extractSiweExpiration(siwe) {
|
|
18360
|
-
const parsed = new
|
|
18383
|
+
const parsed = new import_sdk_core4.SiweMessage(siwe);
|
|
18361
18384
|
if (parsed.expirationTime === void 0 || parsed.expirationTime === null) {
|
|
18362
18385
|
return void 0;
|
|
18363
18386
|
}
|
|
@@ -18371,7 +18394,7 @@ function extractSiweExpiration(siwe) {
|
|
|
18371
18394
|
}
|
|
18372
18395
|
|
|
18373
18396
|
// src/NodeSecretsService.ts
|
|
18374
|
-
var
|
|
18397
|
+
var import_sdk_core5 = require("@tinycloud/sdk-core");
|
|
18375
18398
|
var SECRETS_SPACE = "secrets";
|
|
18376
18399
|
function ok() {
|
|
18377
18400
|
return { ok: true, data: void 0 };
|
|
@@ -18404,7 +18427,7 @@ function secretActionName(action) {
|
|
|
18404
18427
|
}
|
|
18405
18428
|
function secretPermissionEntries(name, options, action, encryptionNetworkId) {
|
|
18406
18429
|
const entries = [];
|
|
18407
|
-
const path = action === "list" ? (0,
|
|
18430
|
+
const path = action === "list" ? (0, import_sdk_core5.resolveSecretListPrefix)(options) : (0, import_sdk_core5.resolveSecretPath)(name, options).permissionPaths.vault;
|
|
18408
18431
|
entries.push({
|
|
18409
18432
|
service: "tinycloud.kv",
|
|
18410
18433
|
space: SECRETS_SPACE,
|
|
@@ -18483,7 +18506,7 @@ var NodeSecretsService = class {
|
|
|
18483
18506
|
);
|
|
18484
18507
|
} catch (error) {
|
|
18485
18508
|
return secretsError(
|
|
18486
|
-
|
|
18509
|
+
import_sdk_core5.ErrorCodes.INVALID_INPUT,
|
|
18487
18510
|
error instanceof Error ? error.message : String(error),
|
|
18488
18511
|
error instanceof Error ? error : void 0
|
|
18489
18512
|
);
|
|
@@ -18493,7 +18516,7 @@ var NodeSecretsService = class {
|
|
|
18493
18516
|
}
|
|
18494
18517
|
if (!this.config.canEscalate()) {
|
|
18495
18518
|
return secretsError(
|
|
18496
|
-
|
|
18519
|
+
import_sdk_core5.ErrorCodes.PERMISSION_DENIED,
|
|
18497
18520
|
`Cannot autosign ${displayActionUrn(action)} for ${target}; TinyCloudNode needs wallet mode with a signer or privateKey.`
|
|
18498
18521
|
);
|
|
18499
18522
|
}
|
|
@@ -18502,7 +18525,7 @@ var NodeSecretsService = class {
|
|
|
18502
18525
|
return this.restoreUnlockAfterEscalation();
|
|
18503
18526
|
} catch (error) {
|
|
18504
18527
|
return secretsError(
|
|
18505
|
-
|
|
18528
|
+
import_sdk_core5.ErrorCodes.PERMISSION_DENIED,
|
|
18506
18529
|
error instanceof Error ? error.message : `Autosign escalation for ${displayActionUrn(action)} on ${target} failed.`,
|
|
18507
18530
|
error instanceof Error ? error : void 0
|
|
18508
18531
|
);
|
|
@@ -18523,10 +18546,10 @@ var NodeSecretsService = class {
|
|
|
18523
18546
|
return false;
|
|
18524
18547
|
}
|
|
18525
18548
|
const manifests = Array.isArray(manifest) ? manifest : [manifest];
|
|
18526
|
-
const requestedEntries = (0,
|
|
18549
|
+
const requestedEntries = (0, import_sdk_core5.expandPermissionEntries)(permissionEntries);
|
|
18527
18550
|
return requestedEntries.every(
|
|
18528
18551
|
(entry) => manifests.some((candidate) => {
|
|
18529
|
-
const resolved = (0,
|
|
18552
|
+
const resolved = (0, import_sdk_core5.resolveManifest)(candidate);
|
|
18530
18553
|
return resolved.resources.some(
|
|
18531
18554
|
(resource) => resource.service === entry.service && resource.space === entry.space && resource.path === entry.path && entry.actions.every((action) => resource.actions.includes(action))
|
|
18532
18555
|
);
|
|
@@ -18538,13 +18561,13 @@ var NodeSecretsService = class {
|
|
|
18538
18561
|
// src/TinyCloudNode.ts
|
|
18539
18562
|
var DEFAULT_HOST = "https://node.tinycloud.xyz";
|
|
18540
18563
|
var DEFAULT_ENCRYPTION_NETWORK_NAME = "default";
|
|
18541
|
-
var
|
|
18542
|
-
var
|
|
18564
|
+
var NETWORK_CREATE_ACTION2 = "tinycloud.encryption/network.create";
|
|
18565
|
+
var DECRYPT_ACTION2 = "tinycloud.encryption/decrypt";
|
|
18543
18566
|
var NETWORK_ADMIN_TYPE = "tinycloud.encryption.network-admin/v1";
|
|
18544
|
-
var DEFAULT_SESSION_EXPIRATION_MS =
|
|
18545
|
-
function
|
|
18567
|
+
var DEFAULT_SESSION_EXPIRATION_MS = import_sdk_core6.EXPIRY.SESSION_MS;
|
|
18568
|
+
function didPrincipalMatches2(actual, expected) {
|
|
18546
18569
|
try {
|
|
18547
|
-
return (0,
|
|
18570
|
+
return (0, import_sdk_core6.principalDidEquals)(actual, expected);
|
|
18548
18571
|
} catch {
|
|
18549
18572
|
return actual === expected;
|
|
18550
18573
|
}
|
|
@@ -18710,12 +18733,12 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
18710
18733
|
throw new Error("Failed to get session key JWK");
|
|
18711
18734
|
}
|
|
18712
18735
|
this.sessionKeyJwk = JSON.parse(jwkStr);
|
|
18713
|
-
this._capabilityRegistry = new
|
|
18736
|
+
this._capabilityRegistry = new import_sdk_core6.CapabilityKeyRegistry();
|
|
18714
18737
|
this._keyProvider = new WasmKeyProvider({
|
|
18715
18738
|
sessionManager: this.sessionManager
|
|
18716
18739
|
});
|
|
18717
|
-
this.notificationHandler = config.notificationHandler ?? new
|
|
18718
|
-
this._sharingService = new
|
|
18740
|
+
this.notificationHandler = config.notificationHandler ?? new import_sdk_core6.SilentNotificationHandler();
|
|
18741
|
+
this._sharingService = new import_sdk_core6.SharingService({
|
|
18719
18742
|
hosts: [this.config.host],
|
|
18720
18743
|
// session: undefined - not needed for receive()
|
|
18721
18744
|
invoke: this.invokeWithRuntimePermissions,
|
|
@@ -18725,8 +18748,8 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
18725
18748
|
// delegationManager: undefined - not needed for receive()
|
|
18726
18749
|
createKVService: (config2) => {
|
|
18727
18750
|
const prefix = config2.pathPrefix?.replace(/\/$/, "");
|
|
18728
|
-
const kvService = new
|
|
18729
|
-
const kvContext = new
|
|
18751
|
+
const kvService = new import_sdk_core6.KVService({ prefix });
|
|
18752
|
+
const kvContext = new import_sdk_core6.ServiceContext({
|
|
18730
18753
|
invoke: config2.invoke,
|
|
18731
18754
|
fetch: config2.fetch ?? globalThis.fetch.bind(globalThis),
|
|
18732
18755
|
hosts: config2.hosts,
|
|
@@ -18786,7 +18809,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
18786
18809
|
capabilityRequest: config.capabilityRequest,
|
|
18787
18810
|
includeAccountRegistryPermissions: config.includeAccountRegistryPermissions
|
|
18788
18811
|
});
|
|
18789
|
-
this.tc = new
|
|
18812
|
+
this.tc = new import_sdk_core6.TinyCloud(this.auth, {
|
|
18790
18813
|
invokeAny: this.invokeAnyWithRuntimePermissions,
|
|
18791
18814
|
telemetry: config.telemetry
|
|
18792
18815
|
});
|
|
@@ -18847,7 +18870,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
18847
18870
|
*/
|
|
18848
18871
|
get did() {
|
|
18849
18872
|
if (this._address) {
|
|
18850
|
-
return (0,
|
|
18873
|
+
return (0, import_sdk_core6.pkhDid)(this._address, this._chainId);
|
|
18851
18874
|
}
|
|
18852
18875
|
return this.sessionManager.getDID(this.sessionKeyId);
|
|
18853
18876
|
}
|
|
@@ -18881,6 +18904,37 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
18881
18904
|
get spaceId() {
|
|
18882
18905
|
return this.auth?.tinyCloudSession?.spaceId;
|
|
18883
18906
|
}
|
|
18907
|
+
/**
|
|
18908
|
+
* Get the account space ID for this wallet identity.
|
|
18909
|
+
* Available after wallet-backed sign-in or a restored session with address metadata.
|
|
18910
|
+
*/
|
|
18911
|
+
get accountSpaceId() {
|
|
18912
|
+
if (!this._address) {
|
|
18913
|
+
return void 0;
|
|
18914
|
+
}
|
|
18915
|
+
return this.wasmBindings.makeSpaceId(this._address, this._chainId, import_sdk_core6.ACCOUNT_REGISTRY_SPACE);
|
|
18916
|
+
}
|
|
18917
|
+
/**
|
|
18918
|
+
* Account-level application and delegation helpers.
|
|
18919
|
+
*/
|
|
18920
|
+
get account() {
|
|
18921
|
+
if (!this._account) {
|
|
18922
|
+
this._account = new import_sdk_core2.AccountService({
|
|
18923
|
+
getDid: () => this.did,
|
|
18924
|
+
getHost: () => this.hosts[0] ?? this.config.host,
|
|
18925
|
+
getPrimarySpaceId: () => this.spaceId,
|
|
18926
|
+
getAccountSpaceId: () => this.accountSpaceId,
|
|
18927
|
+
getSpaces: () => this.spaces,
|
|
18928
|
+
getAccountDb: () => this.accountSpaceId ? this.sqlForSpace(this.accountSpaceId).db("account") : void 0,
|
|
18929
|
+
ensureAccountSpaceHosted: async () => {
|
|
18930
|
+
if (this.accountSpaceId && this.auth) {
|
|
18931
|
+
await this.ensureOwnedSpaceHostedById(this.accountSpaceId);
|
|
18932
|
+
}
|
|
18933
|
+
}
|
|
18934
|
+
});
|
|
18935
|
+
}
|
|
18936
|
+
return this._account;
|
|
18937
|
+
}
|
|
18884
18938
|
/**
|
|
18885
18939
|
* Get the current TinyCloud session.
|
|
18886
18940
|
* Available after signIn().
|
|
@@ -18902,7 +18956,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
18902
18956
|
);
|
|
18903
18957
|
}
|
|
18904
18958
|
await this.wasmBindings.ensureInitialized?.();
|
|
18905
|
-
this._address = (0,
|
|
18959
|
+
this._address = (0, import_sdk_core6.canonicalizeAddress)(await this.signer.getAddress());
|
|
18906
18960
|
this._chainId = await this.signer.getChainId();
|
|
18907
18961
|
this._kv = void 0;
|
|
18908
18962
|
this._sql = void 0;
|
|
@@ -18918,10 +18972,11 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
18918
18972
|
await this.tc.signIn(options);
|
|
18919
18973
|
this.syncResolvedHostFromAuth();
|
|
18920
18974
|
this.initializeServices();
|
|
18975
|
+
await this.ensureRequestedEncryptionNetworks();
|
|
18921
18976
|
if (this.config.manifest === void 0 && this.config.capabilityRequest === void 0) {
|
|
18922
|
-
await this.
|
|
18977
|
+
await this.ensureOwnedSpaceHostedById(this.ownedSpaceId("secrets"));
|
|
18923
18978
|
}
|
|
18924
|
-
|
|
18979
|
+
this.scheduleAccountRegistrySync();
|
|
18925
18980
|
this.notificationHandler.success("Successfully signed in");
|
|
18926
18981
|
}
|
|
18927
18982
|
ownedSpaceId(name) {
|
|
@@ -18938,23 +18993,69 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
18938
18993
|
if (!this.auth || !this.signer) {
|
|
18939
18994
|
throw new Error("Manifest registry write requires wallet mode");
|
|
18940
18995
|
}
|
|
18941
|
-
const accountSpaceId = this.ownedSpaceId(
|
|
18942
|
-
await this.
|
|
18943
|
-
const
|
|
18944
|
-
|
|
18945
|
-
|
|
18946
|
-
|
|
18947
|
-
|
|
18948
|
-
|
|
18949
|
-
|
|
18950
|
-
|
|
18951
|
-
|
|
18952
|
-
|
|
18953
|
-
|
|
18996
|
+
const accountSpaceId = this.ownedSpaceId(import_sdk_core6.ACCOUNT_REGISTRY_SPACE);
|
|
18997
|
+
await this.ensureOwnedSpaceHostedById(accountSpaceId);
|
|
18998
|
+
const result = await this.account.applications.register(request.manifests);
|
|
18999
|
+
if (!result.ok) {
|
|
19000
|
+
throw new Error(
|
|
19001
|
+
`Failed to write manifest registry records: ${result.error.message}`
|
|
19002
|
+
);
|
|
19003
|
+
}
|
|
19004
|
+
}
|
|
19005
|
+
scheduleAccountRegistrySync() {
|
|
19006
|
+
void this.withAccountRegistryRetry(async () => {
|
|
19007
|
+
await this.writeManifestRegistryRecords();
|
|
19008
|
+
const spaces = await this.account.spaces.syncAccessible();
|
|
19009
|
+
if (!spaces.ok) {
|
|
19010
|
+
throw new Error(`Failed to sync account spaces: ${spaces.error.message}`);
|
|
19011
|
+
}
|
|
19012
|
+
});
|
|
19013
|
+
}
|
|
19014
|
+
async withAccountRegistryRetry(task) {
|
|
19015
|
+
const delays = [250, 1e3, 3e3];
|
|
19016
|
+
let lastError;
|
|
19017
|
+
for (let attempt = 0; attempt < delays.length; attempt += 1) {
|
|
19018
|
+
try {
|
|
19019
|
+
await task();
|
|
19020
|
+
return;
|
|
19021
|
+
} catch (error) {
|
|
19022
|
+
lastError = error;
|
|
19023
|
+
if (attempt < delays.length - 1) {
|
|
19024
|
+
await new Promise((resolve) => setTimeout(resolve, delays[attempt]));
|
|
19025
|
+
}
|
|
18954
19026
|
}
|
|
18955
19027
|
}
|
|
19028
|
+
console.warn(
|
|
19029
|
+
"TinyCloud account registry sync failed after retries",
|
|
19030
|
+
lastError
|
|
19031
|
+
);
|
|
18956
19032
|
}
|
|
18957
|
-
|
|
19033
|
+
requestedEncryptionNetworkIds() {
|
|
19034
|
+
const request = this.capabilityRequest;
|
|
19035
|
+
if (!request) {
|
|
19036
|
+
return [];
|
|
19037
|
+
}
|
|
19038
|
+
const networkIds = /* @__PURE__ */ new Set();
|
|
19039
|
+
for (const resource of request.resources) {
|
|
19040
|
+
if (resource.service === import_sdk_core6.ENCRYPTION_PERMISSION_SERVICE && resource.path.startsWith("urn:tinycloud:encryption:") && resource.actions.includes(DECRYPT_ACTION2)) {
|
|
19041
|
+
networkIds.add(resource.path);
|
|
19042
|
+
}
|
|
19043
|
+
}
|
|
19044
|
+
return [...networkIds];
|
|
19045
|
+
}
|
|
19046
|
+
async ensureRequestedEncryptionNetworks() {
|
|
19047
|
+
if (!this.signer || !this.auth) {
|
|
19048
|
+
return;
|
|
19049
|
+
}
|
|
19050
|
+
for (const networkId of this.requestedEncryptionNetworkIds()) {
|
|
19051
|
+
const parsed = (0, import_sdk_core6.parseNetworkId)(networkId);
|
|
19052
|
+
if (!didPrincipalMatches2(parsed.ownerDid, this.did)) {
|
|
19053
|
+
continue;
|
|
19054
|
+
}
|
|
19055
|
+
await this.ensureEncryptionNetwork(networkId);
|
|
19056
|
+
}
|
|
19057
|
+
}
|
|
19058
|
+
async ensureOwnedSpaceHostedById(spaceId) {
|
|
18958
19059
|
if (!this.auth) {
|
|
18959
19060
|
throw new Error("Owned space hosting requires wallet mode");
|
|
18960
19061
|
}
|
|
@@ -18966,7 +19067,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
18966
19067
|
if (!host) {
|
|
18967
19068
|
throw new Error("Owned space hosting requires a TinyCloud host");
|
|
18968
19069
|
}
|
|
18969
|
-
const activation = await (0,
|
|
19070
|
+
const activation = await (0, import_sdk_core6.activateSessionWithHost)(host, session.delegationHeader);
|
|
18970
19071
|
if (activation.success && !activation.skipped?.includes(spaceId)) {
|
|
18971
19072
|
return;
|
|
18972
19073
|
}
|
|
@@ -18980,13 +19081,91 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
18980
19081
|
throw new Error(`Failed to create owned space: ${spaceId}`);
|
|
18981
19082
|
}
|
|
18982
19083
|
await new Promise((resolve) => setTimeout(resolve, 100));
|
|
18983
|
-
const retry = await (0,
|
|
19084
|
+
const retry = await (0, import_sdk_core6.activateSessionWithHost)(host, session.delegationHeader);
|
|
18984
19085
|
if (!retry.success || retry.skipped?.includes(spaceId)) {
|
|
18985
19086
|
throw new Error(
|
|
18986
19087
|
`Failed to activate session after creating owned space ${spaceId}: ${retry.error ?? "space was skipped"}`
|
|
18987
19088
|
);
|
|
18988
19089
|
}
|
|
18989
19090
|
}
|
|
19091
|
+
/**
|
|
19092
|
+
* Host one of this user's owned spaces by name (e.g. `"applications"`).
|
|
19093
|
+
*
|
|
19094
|
+
* Resolves the name to the owned space URI
|
|
19095
|
+
* (`tinycloud:pkh:eip155:<chain>:<addr>:<name>`) and registers it on the
|
|
19096
|
+
* server via the host-SIWE delegation flow, so subsequent KV/SQL writes to
|
|
19097
|
+
* that space succeed instead of returning `404 - Space not found`. The
|
|
19098
|
+
* caller is the root authority of their own owned spaces, so no additional
|
|
19099
|
+
* delegation is required.
|
|
19100
|
+
*
|
|
19101
|
+
* Unlike {@link ensureOwnedSpaceHostedById}, this always submits the host
|
|
19102
|
+
* delegation rather than inferring hosting from session activation: a space
|
|
19103
|
+
* the current session has never referenced is reported neither as
|
|
19104
|
+
* `activated` nor `skipped`, so activation-based detection would wrongly
|
|
19105
|
+
* skip the host. The host SIWE is idempotent server-side, so re-hosting an
|
|
19106
|
+
* existing space is a safe no-op. Must be called after {@link signIn}.
|
|
19107
|
+
*
|
|
19108
|
+
* @param name - The owned space name (e.g. `"applications"`).
|
|
19109
|
+
* @returns The hosted space URI.
|
|
19110
|
+
*/
|
|
19111
|
+
async hostOwnedSpace(name) {
|
|
19112
|
+
if (!this.auth || !this.auth.tinyCloudSession) {
|
|
19113
|
+
throw new Error("Not signed in. Call signIn() first.");
|
|
19114
|
+
}
|
|
19115
|
+
const spaceId = this.ownedSpaceId(name);
|
|
19116
|
+
const host = this.hosts[0] ?? this.config.host;
|
|
19117
|
+
if (!host) {
|
|
19118
|
+
throw new Error("Owned space hosting requires a TinyCloud host");
|
|
19119
|
+
}
|
|
19120
|
+
const hosted = await this.auth.hostOwnedSpace(
|
|
19121
|
+
spaceId
|
|
19122
|
+
);
|
|
19123
|
+
if (!hosted) {
|
|
19124
|
+
throw new Error(`Failed to host owned space: ${spaceId}`);
|
|
19125
|
+
}
|
|
19126
|
+
const activation = await (0, import_sdk_core6.activateSessionWithHost)(
|
|
19127
|
+
host,
|
|
19128
|
+
this.auth.tinyCloudSession.delegationHeader
|
|
19129
|
+
);
|
|
19130
|
+
if (!activation.success || activation.skipped?.includes(spaceId)) {
|
|
19131
|
+
throw new Error(
|
|
19132
|
+
`Failed to activate session for owned space ${spaceId}: ${activation.error ?? "space was skipped"}`
|
|
19133
|
+
);
|
|
19134
|
+
}
|
|
19135
|
+
void this.account.spaces.register({
|
|
19136
|
+
spaceId,
|
|
19137
|
+
name,
|
|
19138
|
+
ownerDid: this.did,
|
|
19139
|
+
type: "owned",
|
|
19140
|
+
permissions: ["*"],
|
|
19141
|
+
status: "active"
|
|
19142
|
+
}).catch(() => {
|
|
19143
|
+
});
|
|
19144
|
+
return spaceId;
|
|
19145
|
+
}
|
|
19146
|
+
/**
|
|
19147
|
+
* Ensure one of this user's owned spaces (e.g. `"secrets"`) is hosted on the
|
|
19148
|
+
* server.
|
|
19149
|
+
*
|
|
19150
|
+
* At sign-in, a full-authority session auto-hosts the owner's `secrets`
|
|
19151
|
+
* space, but a session created with a manifest / capabilityRequest does not.
|
|
19152
|
+
* Such a session can therefore hold valid `tinycloud.kv/*` capabilities for
|
|
19153
|
+
* the owned `secrets` space yet still fail its first scoped
|
|
19154
|
+
* `secrets.put(...)` with `404 Space not found`, because the space was never
|
|
19155
|
+
* registered on the node.
|
|
19156
|
+
*
|
|
19157
|
+
* Calling this resolves `name` to the owner's owned-space URI
|
|
19158
|
+
* (`tinycloud:pkh:eip155:<chain>:<addr>:<name>`) and hosts it via the
|
|
19159
|
+
* host-SIWE delegation flow. The host SIWE is idempotent server-side, so it
|
|
19160
|
+
* is safe to call whether or not the space already exists; do not gate it on
|
|
19161
|
+
* a prior existence check. Must be called after {@link signIn}.
|
|
19162
|
+
*
|
|
19163
|
+
* @param name - The owned space name (e.g. `"secrets"`).
|
|
19164
|
+
* @returns The hosted owned-space URI.
|
|
19165
|
+
*/
|
|
19166
|
+
async ensureOwnedSpaceHosted(name) {
|
|
19167
|
+
return this.hostOwnedSpace(name);
|
|
19168
|
+
}
|
|
18990
19169
|
/**
|
|
18991
19170
|
* Restore a previously established session from stored delegation data.
|
|
18992
19171
|
*
|
|
@@ -19009,30 +19188,30 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
19009
19188
|
this._spaceService = void 0;
|
|
19010
19189
|
this._serviceContext = void 0;
|
|
19011
19190
|
this.runtimePermissionGrants = [];
|
|
19012
|
-
const restoredAddress = sessionData.address ? (0,
|
|
19191
|
+
const restoredAddress = sessionData.address ? (0, import_sdk_core6.canonicalizeAddress)(sessionData.address) : void 0;
|
|
19013
19192
|
if (restoredAddress) {
|
|
19014
19193
|
this._address = restoredAddress;
|
|
19015
19194
|
}
|
|
19016
19195
|
if (sessionData.chainId) {
|
|
19017
19196
|
this._chainId = sessionData.chainId;
|
|
19018
19197
|
}
|
|
19019
|
-
this._serviceContext = new
|
|
19198
|
+
this._serviceContext = new import_sdk_core6.ServiceContext({
|
|
19020
19199
|
invoke: this.invokeWithRuntimePermissions,
|
|
19021
19200
|
invokeAny: this.invokeAnyWithRuntimePermissions,
|
|
19022
19201
|
fetch: globalThis.fetch.bind(globalThis),
|
|
19023
19202
|
hosts: [this.config.host],
|
|
19024
19203
|
telemetry: this.config.telemetry
|
|
19025
19204
|
});
|
|
19026
|
-
this._kv = new
|
|
19205
|
+
this._kv = new import_sdk_core6.KVService({});
|
|
19027
19206
|
this._kv.initialize(this._serviceContext);
|
|
19028
19207
|
this._serviceContext.registerService("kv", this._kv);
|
|
19029
|
-
this._sql = new
|
|
19208
|
+
this._sql = new import_sdk_core6.SQLService({});
|
|
19030
19209
|
this._sql.initialize(this._serviceContext);
|
|
19031
19210
|
this._serviceContext.registerService("sql", this._sql);
|
|
19032
|
-
this._duckdb = new
|
|
19211
|
+
this._duckdb = new import_sdk_core6.DuckDbService({});
|
|
19033
19212
|
this._duckdb.initialize(this._serviceContext);
|
|
19034
19213
|
this._serviceContext.registerService("duckdb", this._duckdb);
|
|
19035
|
-
this._hooks = new
|
|
19214
|
+
this._hooks = new import_sdk_core6.HooksService({});
|
|
19036
19215
|
this._hooks.initialize(this._serviceContext);
|
|
19037
19216
|
this._serviceContext.registerService("hooks", this._hooks);
|
|
19038
19217
|
const serviceSession = {
|
|
@@ -19131,7 +19310,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
19131
19310
|
capabilityRequest: this.config.capabilityRequest,
|
|
19132
19311
|
includeAccountRegistryPermissions: this.config.includeAccountRegistryPermissions
|
|
19133
19312
|
});
|
|
19134
|
-
this.tc = new
|
|
19313
|
+
this.tc = new import_sdk_core6.TinyCloud(this.auth, {
|
|
19135
19314
|
invokeAny: this.invokeAnyWithRuntimePermissions,
|
|
19136
19315
|
telemetry: this.config.telemetry
|
|
19137
19316
|
});
|
|
@@ -19176,7 +19355,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
19176
19355
|
capabilityRequest: this.config.capabilityRequest,
|
|
19177
19356
|
includeAccountRegistryPermissions: this.config.includeAccountRegistryPermissions
|
|
19178
19357
|
});
|
|
19179
|
-
this.tc = new
|
|
19358
|
+
this.tc = new import_sdk_core6.TinyCloud(this.auth, {
|
|
19180
19359
|
invokeAny: this.invokeAnyWithRuntimePermissions,
|
|
19181
19360
|
telemetry: this.config.telemetry
|
|
19182
19361
|
});
|
|
@@ -19192,28 +19371,28 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
19192
19371
|
return;
|
|
19193
19372
|
}
|
|
19194
19373
|
this.tc.initializeServices(this.invokeWithRuntimePermissions, [this.config.host]);
|
|
19195
|
-
this._serviceContext = new
|
|
19374
|
+
this._serviceContext = new import_sdk_core6.ServiceContext({
|
|
19196
19375
|
invoke: this.invokeWithRuntimePermissions,
|
|
19197
19376
|
invokeAny: this.invokeAnyWithRuntimePermissions,
|
|
19198
19377
|
fetch: globalThis.fetch.bind(globalThis),
|
|
19199
19378
|
hosts: [this.config.host],
|
|
19200
19379
|
telemetry: this.config.telemetry
|
|
19201
19380
|
});
|
|
19202
|
-
this._kv = new
|
|
19381
|
+
this._kv = new import_sdk_core6.KVService({});
|
|
19203
19382
|
this._kv.initialize(this._serviceContext);
|
|
19204
19383
|
this._serviceContext.registerService("kv", this._kv);
|
|
19205
19384
|
const features = this.nodeFeatures;
|
|
19206
19385
|
if (features.length === 0 || features.includes("sql")) {
|
|
19207
|
-
this._sql = new
|
|
19386
|
+
this._sql = new import_sdk_core6.SQLService({});
|
|
19208
19387
|
this._sql.initialize(this._serviceContext);
|
|
19209
19388
|
this._serviceContext.registerService("sql", this._sql);
|
|
19210
19389
|
}
|
|
19211
19390
|
if (features.length === 0 || features.includes("duckdb")) {
|
|
19212
|
-
this._duckdb = new
|
|
19391
|
+
this._duckdb = new import_sdk_core6.DuckDbService({});
|
|
19213
19392
|
this._duckdb.initialize(this._serviceContext);
|
|
19214
19393
|
this._serviceContext.registerService("duckdb", this._duckdb);
|
|
19215
19394
|
}
|
|
19216
|
-
this._hooks = new
|
|
19395
|
+
this._hooks = new import_sdk_core6.HooksService({});
|
|
19217
19396
|
this._hooks.initialize(this._serviceContext);
|
|
19218
19397
|
this._serviceContext.registerService("hooks", this._hooks);
|
|
19219
19398
|
const serviceSession = {
|
|
@@ -19231,9 +19410,9 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
19231
19410
|
this.initializeV2Services(serviceSession);
|
|
19232
19411
|
}
|
|
19233
19412
|
createSpaceScopedKVService(spaceId) {
|
|
19234
|
-
const kvService = new
|
|
19413
|
+
const kvService = new import_sdk_core6.KVService({});
|
|
19235
19414
|
if (this._serviceContext) {
|
|
19236
|
-
const spaceScopedContext = new
|
|
19415
|
+
const spaceScopedContext = new import_sdk_core6.ServiceContext({
|
|
19237
19416
|
invoke: this._serviceContext.invoke,
|
|
19238
19417
|
fetch: this._serviceContext.fetch,
|
|
19239
19418
|
hosts: this._serviceContext.hosts,
|
|
@@ -19298,7 +19477,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
19298
19477
|
const shared = wasm.vault_x25519_dh(receiverPrivateKey, peerPublic);
|
|
19299
19478
|
return columnDecrypt(shared, ciphertext);
|
|
19300
19479
|
},
|
|
19301
|
-
verifyNodeSignature: (nodeId, message, signature2) => (0,
|
|
19480
|
+
verifyNodeSignature: (nodeId, message, signature2) => (0, import_sdk_core6.verifyDidKeyEd25519Signature)(nodeId, message, signature2)
|
|
19302
19481
|
};
|
|
19303
19482
|
}
|
|
19304
19483
|
async fetchNodeId() {
|
|
@@ -19369,19 +19548,19 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
19369
19548
|
return await response.json();
|
|
19370
19549
|
}
|
|
19371
19550
|
};
|
|
19372
|
-
return new
|
|
19551
|
+
return new import_sdk_core6.EncryptionService({
|
|
19373
19552
|
crypto: crypto2,
|
|
19374
19553
|
signer: {
|
|
19375
19554
|
signDecryptInvocation: async (input) => {
|
|
19376
19555
|
const signed2 = await this.signRawNetworkAuthorization({
|
|
19377
19556
|
targetNode: input.targetNode,
|
|
19378
19557
|
networkId: input.networkId,
|
|
19379
|
-
action:
|
|
19558
|
+
action: DECRYPT_ACTION2,
|
|
19380
19559
|
facts: input.facts
|
|
19381
19560
|
});
|
|
19382
19561
|
return {
|
|
19383
19562
|
...signed2,
|
|
19384
|
-
canonicalBody: (0,
|
|
19563
|
+
canonicalBody: (0, import_sdk_core6.canonicalizeEncryptionJson)(
|
|
19385
19564
|
input.body
|
|
19386
19565
|
)
|
|
19387
19566
|
};
|
|
@@ -19393,14 +19572,14 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
19393
19572
|
},
|
|
19394
19573
|
wellKnown: {
|
|
19395
19574
|
fetchWellKnown: async (principal, discoveryKey) => {
|
|
19396
|
-
if (!this._address || !
|
|
19575
|
+
if (!this._address || !didPrincipalMatches2(principal, this.did)) {
|
|
19397
19576
|
return null;
|
|
19398
19577
|
}
|
|
19399
19578
|
if (!this.config.host) {
|
|
19400
19579
|
return null;
|
|
19401
19580
|
}
|
|
19402
|
-
const publicSpaceId = (0,
|
|
19403
|
-
const result = await
|
|
19581
|
+
const publicSpaceId = (0, import_sdk_core6.makePublicSpaceId)(this._address, this._chainId);
|
|
19582
|
+
const result = await import_sdk_core6.TinyCloud.readPublicSpace(this.config.host, publicSpaceId, discoveryKey);
|
|
19404
19583
|
if (!result.ok) {
|
|
19405
19584
|
return null;
|
|
19406
19585
|
}
|
|
@@ -19423,7 +19602,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
19423
19602
|
}
|
|
19424
19603
|
createVaultService(spaceId, kv) {
|
|
19425
19604
|
const wasm = this.wasmBindings;
|
|
19426
|
-
const vaultCrypto = (0,
|
|
19605
|
+
const vaultCrypto = (0, import_sdk_core6.createVaultCrypto)({
|
|
19427
19606
|
vault_encrypt: wasm.vault_encrypt,
|
|
19428
19607
|
vault_decrypt: wasm.vault_decrypt,
|
|
19429
19608
|
vault_derive_key: wasm.vault_derive_key,
|
|
@@ -19433,7 +19612,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
19433
19612
|
vault_sha256: wasm.vault_sha256
|
|
19434
19613
|
});
|
|
19435
19614
|
const self2 = this;
|
|
19436
|
-
return new
|
|
19615
|
+
return new import_sdk_core6.DataVaultService({
|
|
19437
19616
|
spaceId,
|
|
19438
19617
|
crypto: vaultCrypto,
|
|
19439
19618
|
encryption: {
|
|
@@ -19456,8 +19635,8 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
19456
19635
|
get publicKV() {
|
|
19457
19636
|
return self2._publicKV ?? self2.tc.publicKV;
|
|
19458
19637
|
},
|
|
19459
|
-
readPublicSpace: (host, targetSpaceId, key2) =>
|
|
19460
|
-
makePublicSpaceId:
|
|
19638
|
+
readPublicSpace: (host, targetSpaceId, key2) => import_sdk_core6.TinyCloud.readPublicSpace(host, targetSpaceId, key2),
|
|
19639
|
+
makePublicSpaceId: import_sdk_core6.TinyCloud.makePublicSpaceId,
|
|
19461
19640
|
did: this.did,
|
|
19462
19641
|
address: this._address ?? "",
|
|
19463
19642
|
chainId: this._chainId,
|
|
@@ -19470,7 +19649,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
19470
19649
|
* @internal
|
|
19471
19650
|
*/
|
|
19472
19651
|
initializeV2Services(serviceSession) {
|
|
19473
|
-
this._capabilityRegistry = new
|
|
19652
|
+
this._capabilityRegistry = new import_sdk_core6.CapabilityKeyRegistry();
|
|
19474
19653
|
const tcSession = this.auth?.tinyCloudSession;
|
|
19475
19654
|
if (tcSession && this._address) {
|
|
19476
19655
|
const sessionKey = {
|
|
@@ -19544,13 +19723,13 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
19544
19723
|
}
|
|
19545
19724
|
this._capabilityRegistry.registerKey(sessionKey, delegations);
|
|
19546
19725
|
}
|
|
19547
|
-
this._delegationManager = new
|
|
19726
|
+
this._delegationManager = new import_sdk_core6.DelegationManager({
|
|
19548
19727
|
hosts: [this.config.host],
|
|
19549
19728
|
session: serviceSession,
|
|
19550
19729
|
invoke: this.invokeWithRuntimePermissions,
|
|
19551
19730
|
fetch: globalThis.fetch.bind(globalThis)
|
|
19552
19731
|
});
|
|
19553
|
-
this._spaceService = new
|
|
19732
|
+
this._spaceService = new import_sdk_core6.SpaceService({
|
|
19554
19733
|
hosts: [this.config.host],
|
|
19555
19734
|
session: serviceSession,
|
|
19556
19735
|
invoke: this.wasmBindings.invoke,
|
|
@@ -19602,6 +19781,9 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
19602
19781
|
}
|
|
19603
19782
|
};
|
|
19604
19783
|
}
|
|
19784
|
+
},
|
|
19785
|
+
onSpaceRegistered: async (space) => {
|
|
19786
|
+
await this.account.spaces.register(space);
|
|
19605
19787
|
}
|
|
19606
19788
|
});
|
|
19607
19789
|
this._sharingService.updateConfig({
|
|
@@ -19707,7 +19889,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
19707
19889
|
...prepared,
|
|
19708
19890
|
signature: signature2
|
|
19709
19891
|
});
|
|
19710
|
-
const activateResult = await (0,
|
|
19892
|
+
const activateResult = await (0, import_sdk_core6.activateSessionWithHost)(
|
|
19711
19893
|
host,
|
|
19712
19894
|
delegationSession.delegationHeader
|
|
19713
19895
|
);
|
|
@@ -19717,7 +19899,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
19717
19899
|
return {
|
|
19718
19900
|
cid: delegationSession.delegationCid,
|
|
19719
19901
|
delegateDID: params.shareKeyDID,
|
|
19720
|
-
delegatorDID: (0,
|
|
19902
|
+
delegatorDID: (0, import_sdk_core6.pkhDid)(session.address, session.chainId),
|
|
19721
19903
|
spaceId: params.spaceId,
|
|
19722
19904
|
path: params.path,
|
|
19723
19905
|
actions: params.actions,
|
|
@@ -19774,7 +19956,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
19774
19956
|
if (!this._sql) {
|
|
19775
19957
|
const features = this.nodeFeatures;
|
|
19776
19958
|
if (features.length > 0 && !features.includes("sql")) {
|
|
19777
|
-
throw new
|
|
19959
|
+
throw new import_sdk_core6.UnsupportedFeatureError("sql", this.config.host, features);
|
|
19778
19960
|
}
|
|
19779
19961
|
throw new Error("Not signed in. Call signIn() first.");
|
|
19780
19962
|
}
|
|
@@ -19798,8 +19980,8 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
19798
19980
|
if (!this._serviceContext || !this._serviceContext.session) {
|
|
19799
19981
|
throw new Error("Not signed in. Call signIn() first.");
|
|
19800
19982
|
}
|
|
19801
|
-
const sql = new
|
|
19802
|
-
const spaceScopedContext = new
|
|
19983
|
+
const sql = new import_sdk_core6.SQLService({});
|
|
19984
|
+
const spaceScopedContext = new import_sdk_core6.ServiceContext({
|
|
19803
19985
|
invoke: this._serviceContext.invoke,
|
|
19804
19986
|
fetch: this._serviceContext.fetch,
|
|
19805
19987
|
hosts: this._serviceContext.hosts,
|
|
@@ -19827,8 +20009,8 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
19827
20009
|
if (!this._serviceContext || !this._serviceContext.session) {
|
|
19828
20010
|
throw new Error("Not signed in. Call signIn() first.");
|
|
19829
20011
|
}
|
|
19830
|
-
const kv = new
|
|
19831
|
-
const spaceScopedContext = new
|
|
20012
|
+
const kv = new import_sdk_core6.KVService({});
|
|
20013
|
+
const spaceScopedContext = new import_sdk_core6.ServiceContext({
|
|
19832
20014
|
invoke: this._serviceContext.invoke,
|
|
19833
20015
|
fetch: this._serviceContext.fetch,
|
|
19834
20016
|
hosts: this._serviceContext.hosts
|
|
@@ -19844,7 +20026,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
19844
20026
|
if (!this._duckdb) {
|
|
19845
20027
|
const features = this.nodeFeatures;
|
|
19846
20028
|
if (features.length > 0 && !features.includes("duckdb")) {
|
|
19847
|
-
throw new
|
|
20029
|
+
throw new import_sdk_core6.UnsupportedFeatureError("duckdb", this.config.host, features);
|
|
19848
20030
|
}
|
|
19849
20031
|
throw new Error("Not signed in. Call signIn() first.");
|
|
19850
20032
|
}
|
|
@@ -19896,16 +20078,16 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
19896
20078
|
type: NETWORK_ADMIN_TYPE,
|
|
19897
20079
|
targetNode,
|
|
19898
20080
|
networkId,
|
|
19899
|
-
bodyHash: (0,
|
|
20081
|
+
bodyHash: (0, import_sdk_core6.canonicalHashHex)(
|
|
19900
20082
|
crypto2.sha256,
|
|
19901
20083
|
body
|
|
19902
20084
|
),
|
|
19903
|
-
action:
|
|
20085
|
+
action: NETWORK_CREATE_ACTION2
|
|
19904
20086
|
};
|
|
19905
20087
|
const signed2 = await this.signRawNetworkAuthorization({
|
|
19906
20088
|
targetNode,
|
|
19907
20089
|
networkId,
|
|
19908
|
-
action:
|
|
20090
|
+
action: NETWORK_CREATE_ACTION2,
|
|
19909
20091
|
facts
|
|
19910
20092
|
});
|
|
19911
20093
|
const response = await fetch(`${this.config.host}/encryption/networks`, {
|
|
@@ -19914,7 +20096,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
19914
20096
|
Authorization: signed2.authorization,
|
|
19915
20097
|
"Content-Type": "application/json"
|
|
19916
20098
|
},
|
|
19917
|
-
body: (0,
|
|
20099
|
+
body: (0, import_sdk_core6.canonicalizeEncryptionJson)(
|
|
19918
20100
|
body
|
|
19919
20101
|
)
|
|
19920
20102
|
});
|
|
@@ -19926,12 +20108,19 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
19926
20108
|
const created = await response.json();
|
|
19927
20109
|
return created.descriptor;
|
|
19928
20110
|
}
|
|
19929
|
-
async ensureEncryptionNetwork(
|
|
19930
|
-
const
|
|
20111
|
+
async ensureEncryptionNetwork(nameOrNetworkId = DEFAULT_ENCRYPTION_NETWORK_NAME) {
|
|
20112
|
+
const networkId = nameOrNetworkId.startsWith("urn:tinycloud:encryption:") ? nameOrNetworkId : this.getDefaultEncryptionNetworkId(nameOrNetworkId);
|
|
20113
|
+
const existing = await this.getEncryptionNetwork(networkId);
|
|
19931
20114
|
if (existing) {
|
|
19932
20115
|
return existing;
|
|
19933
20116
|
}
|
|
19934
|
-
|
|
20117
|
+
const parsed = (0, import_sdk_core6.parseNetworkId)(networkId);
|
|
20118
|
+
if (!didPrincipalMatches2(parsed.ownerDid, this.did)) {
|
|
20119
|
+
throw new Error(
|
|
20120
|
+
`Cannot create encryption network ${networkId}: owner ${parsed.ownerDid} does not match signed-in DID ${this.did}`
|
|
20121
|
+
);
|
|
20122
|
+
}
|
|
20123
|
+
return this.createEncryptionNetwork(parsed.name);
|
|
19935
20124
|
}
|
|
19936
20125
|
/**
|
|
19937
20126
|
* App-facing secrets API backed by the `secrets` space vault.
|
|
@@ -19958,7 +20147,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
19958
20147
|
throw new Error("Not signed in. Call signIn() first.");
|
|
19959
20148
|
}
|
|
19960
20149
|
if (!this._baseSecrets) {
|
|
19961
|
-
this._baseSecrets = new
|
|
20150
|
+
this._baseSecrets = new import_sdk_core6.SecretsService(() => this.space("secrets").vault);
|
|
19962
20151
|
}
|
|
19963
20152
|
return this._baseSecrets;
|
|
19964
20153
|
}
|
|
@@ -20073,19 +20262,19 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
20073
20262
|
async useRuntimeDelegation(delegation) {
|
|
20074
20263
|
const session = this.currentTinyCloudSession();
|
|
20075
20264
|
if (!session) {
|
|
20076
|
-
throw new
|
|
20265
|
+
throw new import_sdk_core6.SessionExpiredError(/* @__PURE__ */ new Date(0));
|
|
20077
20266
|
}
|
|
20078
20267
|
if (delegation.expiry.getTime() <= Date.now()) {
|
|
20079
|
-
throw new
|
|
20268
|
+
throw new import_sdk_core6.SessionExpiredError(delegation.expiry);
|
|
20080
20269
|
}
|
|
20081
20270
|
const expectedDids = [session.verificationMethod, this.sessionDid];
|
|
20082
|
-
if (!expectedDids.some((did) =>
|
|
20271
|
+
if (!expectedDids.some((did) => didPrincipalMatches2(delegation.delegateDID, did))) {
|
|
20083
20272
|
throw new Error(
|
|
20084
20273
|
`Runtime delegation targets ${delegation.delegateDID} but this session key is ${session.verificationMethod}.`
|
|
20085
20274
|
);
|
|
20086
20275
|
}
|
|
20087
20276
|
const targetHost = delegation.host ?? this.config.host;
|
|
20088
|
-
const activateResult = await (0,
|
|
20277
|
+
const activateResult = await (0, import_sdk_core6.activateSessionWithHost)(
|
|
20089
20278
|
targetHost,
|
|
20090
20279
|
delegation.delegationHeader
|
|
20091
20280
|
);
|
|
@@ -20112,13 +20301,13 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
20112
20301
|
}
|
|
20113
20302
|
const session = this.currentTinyCloudSession();
|
|
20114
20303
|
if (!session) {
|
|
20115
|
-
throw new
|
|
20304
|
+
throw new import_sdk_core6.SessionExpiredError(/* @__PURE__ */ new Date(0));
|
|
20116
20305
|
}
|
|
20117
20306
|
const sessionExpiry = extractSiweExpiration(session.siwe);
|
|
20118
20307
|
if (sessionExpiry !== void 0) {
|
|
20119
20308
|
const marginMs = _TinyCloudNode.SESSION_EXPIRY_SAFETY_MARGIN_MS;
|
|
20120
20309
|
if (sessionExpiry.getTime() <= Date.now() + marginMs) {
|
|
20121
|
-
throw new
|
|
20310
|
+
throw new import_sdk_core6.SessionExpiredError(sessionExpiry);
|
|
20122
20311
|
}
|
|
20123
20312
|
}
|
|
20124
20313
|
const expanded = this.expandPermissionEntries(permissions);
|
|
@@ -20181,7 +20370,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
20181
20370
|
...prepared,
|
|
20182
20371
|
signature: signature2
|
|
20183
20372
|
});
|
|
20184
|
-
const activateResult = await (0,
|
|
20373
|
+
const activateResult = await (0, import_sdk_core6.activateSessionWithHost)(
|
|
20185
20374
|
this.config.host,
|
|
20186
20375
|
delegatedSession.delegationHeader
|
|
20187
20376
|
);
|
|
@@ -20354,7 +20543,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
20354
20543
|
];
|
|
20355
20544
|
const abilities = { kv: { "": kvActions } };
|
|
20356
20545
|
const now = /* @__PURE__ */ new Date();
|
|
20357
|
-
const expiryMs =
|
|
20546
|
+
const expiryMs = import_sdk_core6.EXPIRY.EPHEMERAL_MS;
|
|
20358
20547
|
const expirationTime = new Date(now.getTime() + expiryMs);
|
|
20359
20548
|
const prepared = this.wasmBindings.prepareSession({
|
|
20360
20549
|
abilities,
|
|
@@ -20372,7 +20561,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
20372
20561
|
...prepared,
|
|
20373
20562
|
signature: signature2
|
|
20374
20563
|
});
|
|
20375
|
-
const activateResult = await (0,
|
|
20564
|
+
const activateResult = await (0, import_sdk_core6.activateSessionWithHost)(
|
|
20376
20565
|
this.config.host,
|
|
20377
20566
|
delegationSession.delegationHeader
|
|
20378
20567
|
);
|
|
@@ -20399,8 +20588,8 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
20399
20588
|
}]);
|
|
20400
20589
|
}
|
|
20401
20590
|
if (this._serviceContext) {
|
|
20402
|
-
const publicKV = new
|
|
20403
|
-
const publicContext = new
|
|
20591
|
+
const publicKV = new import_sdk_core6.KVService({ prefix: "" });
|
|
20592
|
+
const publicContext = new import_sdk_core6.ServiceContext({
|
|
20404
20593
|
invoke: this.invokeWithRuntimePermissions,
|
|
20405
20594
|
fetch: this._serviceContext.fetch,
|
|
20406
20595
|
hosts: this._serviceContext.hosts,
|
|
@@ -20527,14 +20716,14 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
20527
20716
|
async delegateTo(did, permissions, options) {
|
|
20528
20717
|
const session = this.currentTinyCloudSession();
|
|
20529
20718
|
if (!session) {
|
|
20530
|
-
throw new
|
|
20719
|
+
throw new import_sdk_core6.SessionExpiredError(/* @__PURE__ */ new Date(0));
|
|
20531
20720
|
}
|
|
20532
20721
|
const sessionExpiry = extractSiweExpiration(session.siwe);
|
|
20533
20722
|
if (sessionExpiry !== void 0) {
|
|
20534
20723
|
const now2 = Date.now();
|
|
20535
20724
|
const marginMs = _TinyCloudNode.SESSION_EXPIRY_SAFETY_MARGIN_MS;
|
|
20536
20725
|
if (sessionExpiry.getTime() <= now2 + marginMs) {
|
|
20537
|
-
throw new
|
|
20726
|
+
throw new import_sdk_core6.SessionExpiredError(sessionExpiry);
|
|
20538
20727
|
}
|
|
20539
20728
|
}
|
|
20540
20729
|
if (!Array.isArray(permissions) || permissions.length === 0) {
|
|
@@ -20563,11 +20752,11 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
20563
20752
|
);
|
|
20564
20753
|
return { delegation: delegation2, prompted: true };
|
|
20565
20754
|
}
|
|
20566
|
-
const granted = (0,
|
|
20755
|
+
const granted = (0, import_sdk_core6.parseRecapCapabilities)(
|
|
20567
20756
|
(siwe) => this.wasmBindings.parseRecapFromSiwe(siwe),
|
|
20568
20757
|
session.siwe
|
|
20569
20758
|
);
|
|
20570
|
-
const { subset, missing } = (0,
|
|
20759
|
+
const { subset, missing } = (0, import_sdk_core6.isCapabilitySubset)(expandedEntries, granted);
|
|
20571
20760
|
if (!subset) {
|
|
20572
20761
|
const runtimeGrant = this.findGrantForOperations(
|
|
20573
20762
|
this.permissionEntriesToOperations(expandedEntries, session)
|
|
@@ -20575,7 +20764,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
20575
20764
|
if (runtimeGrant) {
|
|
20576
20765
|
const marginMs = _TinyCloudNode.SESSION_EXPIRY_SAFETY_MARGIN_MS;
|
|
20577
20766
|
if (runtimeGrant.expiresAt.getTime() <= Date.now() + marginMs) {
|
|
20578
|
-
throw new
|
|
20767
|
+
throw new import_sdk_core6.SessionExpiredError(runtimeGrant.expiresAt);
|
|
20579
20768
|
}
|
|
20580
20769
|
const runtimeExpiration = runtimeGrant.expiresAt < effectiveExpiration ? runtimeGrant.expiresAt : effectiveExpiration;
|
|
20581
20770
|
const delegation2 = await this.createDelegationViaRuntimeGrant(
|
|
@@ -20586,7 +20775,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
20586
20775
|
);
|
|
20587
20776
|
return { delegation: delegation2, prompted: false };
|
|
20588
20777
|
}
|
|
20589
|
-
throw new
|
|
20778
|
+
throw new import_sdk_core6.PermissionNotInManifestError(missing, granted);
|
|
20590
20779
|
}
|
|
20591
20780
|
const delegation = await this.createDelegationViaWasmPath(
|
|
20592
20781
|
did,
|
|
@@ -20608,7 +20797,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
20608
20797
|
);
|
|
20609
20798
|
}
|
|
20610
20799
|
const target = request.delegationTargets.find(
|
|
20611
|
-
(entry) =>
|
|
20800
|
+
(entry) => didPrincipalMatches2(entry.did, did)
|
|
20612
20801
|
);
|
|
20613
20802
|
if (!target) {
|
|
20614
20803
|
throw new Error(`No manifest delegation target found for DID ${did}`);
|
|
@@ -20668,7 +20857,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
20668
20857
|
const spaceId = resolvedSpaces.size === 1 ? [...resolvedSpaces][0] : session.spaceId;
|
|
20669
20858
|
const abilities = {};
|
|
20670
20859
|
for (const entry of entries) {
|
|
20671
|
-
const shortService =
|
|
20860
|
+
const shortService = import_sdk_core6.SERVICE_LONG_TO_SHORT[entry.service];
|
|
20672
20861
|
if (shortService === void 0) {
|
|
20673
20862
|
throw new Error(
|
|
20674
20863
|
`delegateTo: unknown service '${entry.service}' \u2014 no short-form mapping`
|
|
@@ -20708,7 +20897,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
20708
20897
|
});
|
|
20709
20898
|
const primary = result.resources[0];
|
|
20710
20899
|
const delegationHeader = { Authorization: result.delegation };
|
|
20711
|
-
const activateResult = await (0,
|
|
20900
|
+
const activateResult = await (0, import_sdk_core6.activateSessionWithHost)(
|
|
20712
20901
|
this.config.host,
|
|
20713
20902
|
delegationHeader
|
|
20714
20903
|
);
|
|
@@ -20743,7 +20932,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
20743
20932
|
const primary = result.resources[0];
|
|
20744
20933
|
const delegationHeader = { Authorization: result.delegation };
|
|
20745
20934
|
const targetHost = grant.delegation.host ?? this.config.host;
|
|
20746
|
-
const activateResult = await (0,
|
|
20935
|
+
const activateResult = await (0, import_sdk_core6.activateSessionWithHost)(
|
|
20747
20936
|
targetHost,
|
|
20748
20937
|
delegationHeader
|
|
20749
20938
|
);
|
|
@@ -20784,10 +20973,10 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
20784
20973
|
return this.wasmBindings.makeSpaceId(session.address, session.chainId, space);
|
|
20785
20974
|
}
|
|
20786
20975
|
expandPermissionEntries(permissions) {
|
|
20787
|
-
return (0,
|
|
20976
|
+
return (0, import_sdk_core6.expandPermissionEntries)(permissions);
|
|
20788
20977
|
}
|
|
20789
20978
|
shortServiceName(service) {
|
|
20790
|
-
const short =
|
|
20979
|
+
const short = import_sdk_core6.SERVICE_LONG_TO_SHORT[service];
|
|
20791
20980
|
if (short === void 0) {
|
|
20792
20981
|
throw new Error(
|
|
20793
20982
|
`unknown service '${service}' \u2014 no short-form mapping`
|
|
@@ -20813,7 +21002,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
20813
21002
|
return abilities;
|
|
20814
21003
|
}
|
|
20815
21004
|
isEncryptionPermissionEntry(entry) {
|
|
20816
|
-
return entry.service ===
|
|
21005
|
+
return entry.service === import_sdk_core6.ENCRYPTION_PERMISSION_SERVICE && entry.path.startsWith("urn:tinycloud:encryption:");
|
|
20817
21006
|
}
|
|
20818
21007
|
permissionsToRawAbilities(entries) {
|
|
20819
21008
|
const rawAbilities = {};
|
|
@@ -20846,11 +21035,11 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
20846
21035
|
}
|
|
20847
21036
|
sessionCoversPermissionEntries(session, entries) {
|
|
20848
21037
|
try {
|
|
20849
|
-
const granted = (0,
|
|
21038
|
+
const granted = (0, import_sdk_core6.parseRecapCapabilities)(
|
|
20850
21039
|
(siwe) => this.wasmBindings.parseRecapFromSiwe(siwe),
|
|
20851
21040
|
session.siwe
|
|
20852
21041
|
);
|
|
20853
|
-
return (0,
|
|
21042
|
+
return (0, import_sdk_core6.isCapabilitySubset)(entries, granted).subset;
|
|
20854
21043
|
} catch {
|
|
20855
21044
|
return false;
|
|
20856
21045
|
}
|
|
@@ -21058,7 +21247,23 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
21058
21247
|
if (granted.resource !== void 0 || requested.resource !== void 0) {
|
|
21059
21248
|
return granted.resource !== void 0 && requested.resource !== void 0 && granted.resource === requested.resource && this.pathContains(granted.path, requested.path);
|
|
21060
21249
|
}
|
|
21061
|
-
return granted.spaceId !== void 0 && requested.spaceId !== void 0 && granted.spaceId
|
|
21250
|
+
return granted.spaceId !== void 0 && requested.spaceId !== void 0 && this.spaceIdsEqual(granted.spaceId, requested.spaceId) && this.pathContains(granted.path, requested.path);
|
|
21251
|
+
}
|
|
21252
|
+
// Space IDs are `tinycloud:pkh:eip155:<chain>:<0xADDR>:<name>`. The embedded
|
|
21253
|
+
// EIP-155 address is case-insensitive, but the CLI canonicalizes it to
|
|
21254
|
+
// lowercase when building a space URI while stored runtime delegations keep
|
|
21255
|
+
// the EIP-55 checksummed form — so a byte-for-byte compare spuriously rejects
|
|
21256
|
+
// an otherwise-valid grant. Lowercase ONLY the `eip155:<chain>:0x<addr>`
|
|
21257
|
+
// segment and leave everything else (crucially the case-sensitive space NAME)
|
|
21258
|
+
// byte-exact. Mirrors the CLI's `normalizeSpaceForCompare` (OPENKEY_SCOPE_MISMATCH fix).
|
|
21259
|
+
spaceIdsEqual(a, b) {
|
|
21260
|
+
return this.normalizeSpaceAddress(a) === this.normalizeSpaceAddress(b);
|
|
21261
|
+
}
|
|
21262
|
+
normalizeSpaceAddress(space) {
|
|
21263
|
+
return space.replace(
|
|
21264
|
+
/(eip155:\d+:)(0x[0-9a-fA-F]{40})/,
|
|
21265
|
+
(_match, prefix, addr) => prefix + addr.toLowerCase()
|
|
21266
|
+
);
|
|
21062
21267
|
}
|
|
21063
21268
|
actionContains(grantedAction, requestedAction) {
|
|
21064
21269
|
if (grantedAction === requestedAction) {
|
|
@@ -21165,7 +21370,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
21165
21370
|
if (resolvedDelegateDID.endsWith(".eth") && this.config.ensResolver) {
|
|
21166
21371
|
const address = await this.config.ensResolver.resolveAddress(resolvedDelegateDID);
|
|
21167
21372
|
if (!address) throw new Error(`Could not resolve ENS name: ${resolvedDelegateDID}`);
|
|
21168
|
-
resolvedDelegateDID = (0,
|
|
21373
|
+
resolvedDelegateDID = (0, import_sdk_core6.pkhDid)(address, 1);
|
|
21169
21374
|
}
|
|
21170
21375
|
const entries = legacyParamsToPermissionEntries(
|
|
21171
21376
|
params.actions,
|
|
@@ -21180,7 +21385,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
21180
21385
|
);
|
|
21181
21386
|
return result.delegation;
|
|
21182
21387
|
} catch (err) {
|
|
21183
|
-
if (err instanceof
|
|
21388
|
+
if (err instanceof import_sdk_core6.PermissionNotInManifestError) {
|
|
21184
21389
|
} else {
|
|
21185
21390
|
throw err;
|
|
21186
21391
|
}
|
|
@@ -21237,7 +21442,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
21237
21442
|
...prepared,
|
|
21238
21443
|
signature: signature2
|
|
21239
21444
|
});
|
|
21240
|
-
const activateResult = await (0,
|
|
21445
|
+
const activateResult = await (0, import_sdk_core6.activateSessionWithHost)(
|
|
21241
21446
|
this.config.host,
|
|
21242
21447
|
delegationSession.delegationHeader
|
|
21243
21448
|
);
|
|
@@ -21259,7 +21464,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
21259
21464
|
};
|
|
21260
21465
|
const hasKvActions = params.actions.some((a) => a.startsWith("tinycloud.kv/"));
|
|
21261
21466
|
if (hasKvActions && params.includePublicSpace !== false) {
|
|
21262
|
-
const publicSpaceId = (0,
|
|
21467
|
+
const publicSpaceId = (0, import_sdk_core6.makePublicSpaceId)(
|
|
21263
21468
|
this.wasmBindings.ensureEip55(session.address),
|
|
21264
21469
|
session.chainId
|
|
21265
21470
|
);
|
|
@@ -21282,7 +21487,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
21282
21487
|
...publicPrepared,
|
|
21283
21488
|
signature: publicSignature
|
|
21284
21489
|
});
|
|
21285
|
-
const publicActivateResult = await (0,
|
|
21490
|
+
const publicActivateResult = await (0, import_sdk_core6.activateSessionWithHost)(
|
|
21286
21491
|
this.config.host,
|
|
21287
21492
|
publicSession.delegationHeader
|
|
21288
21493
|
);
|
|
@@ -21322,7 +21527,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
21322
21527
|
const targetHost = delegation.host ?? this.config.host;
|
|
21323
21528
|
if (this.isSessionOnly) {
|
|
21324
21529
|
const myDid = this.did;
|
|
21325
|
-
if (!
|
|
21530
|
+
if (!didPrincipalMatches2(delegation.delegateDID, myDid)) {
|
|
21326
21531
|
throw new Error(
|
|
21327
21532
|
`Delegation targets ${delegation.delegateDID} but this user's DID is ${myDid}. The delegation must target this user's DID.`
|
|
21328
21533
|
);
|
|
@@ -21387,7 +21592,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
21387
21592
|
...prepared,
|
|
21388
21593
|
signature: signature2
|
|
21389
21594
|
});
|
|
21390
|
-
const activateResult = await (0,
|
|
21595
|
+
const activateResult = await (0, import_sdk_core6.activateSessionWithHost)(
|
|
21391
21596
|
targetHost,
|
|
21392
21597
|
invokerSession.delegationHeader
|
|
21393
21598
|
);
|
|
@@ -21493,7 +21698,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
21493
21698
|
...prepared,
|
|
21494
21699
|
signature: signature2
|
|
21495
21700
|
});
|
|
21496
|
-
const activateResult = await (0,
|
|
21701
|
+
const activateResult = await (0, import_sdk_core6.activateSessionWithHost)(
|
|
21497
21702
|
targetHost,
|
|
21498
21703
|
subDelegationSession.delegationHeader
|
|
21499
21704
|
);
|
|
@@ -21535,11 +21740,11 @@ TinyCloudNode.registerNodeDefaults({
|
|
|
21535
21740
|
});
|
|
21536
21741
|
|
|
21537
21742
|
// src/index.ts
|
|
21538
|
-
var import_sdk_core7 = require("@tinycloud/sdk-core");
|
|
21539
21743
|
var import_sdk_core8 = require("@tinycloud/sdk-core");
|
|
21744
|
+
var import_sdk_core9 = require("@tinycloud/sdk-core");
|
|
21540
21745
|
|
|
21541
21746
|
// src/storage/FileSessionStorage.ts
|
|
21542
|
-
var
|
|
21747
|
+
var import_sdk_core7 = require("@tinycloud/sdk-core");
|
|
21543
21748
|
var import_fs = require("fs");
|
|
21544
21749
|
var import_path = require("path");
|
|
21545
21750
|
var FileSessionStorage = class {
|
|
@@ -21594,7 +21799,7 @@ var FileSessionStorage = class {
|
|
|
21594
21799
|
try {
|
|
21595
21800
|
const data = (0, import_fs.readFileSync)(filePath, "utf-8");
|
|
21596
21801
|
const parsed = JSON.parse(data);
|
|
21597
|
-
const validation = (0,
|
|
21802
|
+
const validation = (0, import_sdk_core7.validatePersistedSessionData)(parsed);
|
|
21598
21803
|
if (!validation.ok) {
|
|
21599
21804
|
console.warn(`Invalid session data for ${address}:`, validation.error.message);
|
|
21600
21805
|
(0, import_fs.unlinkSync)(filePath);
|
|
@@ -21659,9 +21864,35 @@ var FileSessionStorage = class {
|
|
|
21659
21864
|
};
|
|
21660
21865
|
|
|
21661
21866
|
// src/index.ts
|
|
21662
|
-
var
|
|
21867
|
+
var import_sdk_core10 = require("@tinycloud/sdk-core");
|
|
21663
21868
|
|
|
21664
21869
|
// src/delegation.ts
|
|
21870
|
+
async function grantAuthRequest(authority, request, options) {
|
|
21871
|
+
if (request.kind !== "tinycloud.auth.request") {
|
|
21872
|
+
throw new Error(
|
|
21873
|
+
`grantAuthRequest expects a tinycloud.auth.request artifact, got "${request.kind}".`
|
|
21874
|
+
);
|
|
21875
|
+
}
|
|
21876
|
+
if (!Array.isArray(request.requested) || request.requested.length === 0) {
|
|
21877
|
+
throw new Error("grantAuthRequest request has no requested capabilities.");
|
|
21878
|
+
}
|
|
21879
|
+
const expiry = options?.expiry ?? request.requestedExpiry;
|
|
21880
|
+
const result = await authority.delegateTo(
|
|
21881
|
+
request.sessionDid,
|
|
21882
|
+
request.requested,
|
|
21883
|
+
expiry !== void 0 ? { expiry } : void 0
|
|
21884
|
+
);
|
|
21885
|
+
return {
|
|
21886
|
+
kind: "tinycloud.auth.delegation",
|
|
21887
|
+
version: 1,
|
|
21888
|
+
requestId: request.requestId,
|
|
21889
|
+
delegationCid: result.delegation.cid,
|
|
21890
|
+
delegation: result.delegation,
|
|
21891
|
+
permissions: request.requested,
|
|
21892
|
+
expiry: result.delegation.expiry.toISOString(),
|
|
21893
|
+
prompted: result.prompted
|
|
21894
|
+
};
|
|
21895
|
+
}
|
|
21665
21896
|
function serializeDelegation(delegation) {
|
|
21666
21897
|
return JSON.stringify({
|
|
21667
21898
|
...delegation,
|
|
@@ -21678,7 +21909,6 @@ function deserializeDelegation(data) {
|
|
|
21678
21909
|
}
|
|
21679
21910
|
|
|
21680
21911
|
// src/index.ts
|
|
21681
|
-
var import_sdk_core10 = require("@tinycloud/sdk-core");
|
|
21682
21912
|
var import_sdk_core11 = require("@tinycloud/sdk-core");
|
|
21683
21913
|
var import_sdk_core12 = require("@tinycloud/sdk-core");
|
|
21684
21914
|
var import_sdk_core13 = require("@tinycloud/sdk-core");
|
|
@@ -21689,10 +21919,12 @@ var import_sdk_core17 = require("@tinycloud/sdk-core");
|
|
|
21689
21919
|
var import_sdk_core18 = require("@tinycloud/sdk-core");
|
|
21690
21920
|
var import_sdk_core19 = require("@tinycloud/sdk-core");
|
|
21691
21921
|
var import_sdk_core20 = require("@tinycloud/sdk-core");
|
|
21922
|
+
var import_sdk_core21 = require("@tinycloud/sdk-core");
|
|
21692
21923
|
// Annotate the CommonJS export names for ESM import in node:
|
|
21693
21924
|
0 && (module.exports = {
|
|
21694
21925
|
ACCOUNT_REGISTRY_PATH,
|
|
21695
21926
|
ACCOUNT_REGISTRY_SPACE,
|
|
21927
|
+
AccountService,
|
|
21696
21928
|
AutoApproveSpaceCreationHandler,
|
|
21697
21929
|
CapabilityKeyRegistry,
|
|
21698
21930
|
CapabilityKeyRegistryErrorCodes,
|
|
@@ -21792,6 +22024,7 @@ var import_sdk_core20 = require("@tinycloud/sdk-core");
|
|
|
21792
22024
|
expandPermissionEntries,
|
|
21793
22025
|
expandPermissionEntry,
|
|
21794
22026
|
generateRandomReceiverKey,
|
|
22027
|
+
grantAuthRequest,
|
|
21795
22028
|
hexDecode,
|
|
21796
22029
|
hexEncode,
|
|
21797
22030
|
isCapabilitySubset,
|