@tinycloud/node-sdk 2.4.0-beta.3 → 2.4.0-beta.6
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-ClOKiSR_.d.cts → core-zT0sxgtZ.d.cts} +14 -2
- package/dist/{core-ClOKiSR_.d.ts → core-zT0sxgtZ.d.ts} +14 -2
- package/dist/core.cjs +287 -201
- 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 +115 -27
- package/dist/core.js.map +1 -1
- package/dist/index.cjs +330 -244
- 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 +119 -31
- 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");
|
|
@@ -17337,6 +17338,25 @@ var MemorySessionStorage = class {
|
|
|
17337
17338
|
};
|
|
17338
17339
|
|
|
17339
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
|
+
}
|
|
17340
17360
|
var NodeUserAuthorization = class {
|
|
17341
17361
|
constructor(config) {
|
|
17342
17362
|
this.extensions = [];
|
|
@@ -17566,20 +17586,18 @@ var NodeUserAuthorization = class {
|
|
|
17566
17586
|
};
|
|
17567
17587
|
}
|
|
17568
17588
|
const rawAbilities = {};
|
|
17589
|
+
const currentDid = (0, import_sdk_core.pkhDid)(address, chainId);
|
|
17569
17590
|
const spaceResources = request.resources.filter((entry) => {
|
|
17570
17591
|
if (entry.service !== import_sdk_core.ENCRYPTION_PERMISSION_SERVICE) {
|
|
17571
17592
|
return true;
|
|
17572
17593
|
}
|
|
17573
|
-
const
|
|
17574
|
-
|
|
17575
|
-
|
|
17576
|
-
|
|
17577
|
-
const
|
|
17578
|
-
|
|
17579
|
-
|
|
17580
|
-
existing.push(action);
|
|
17581
|
-
seen.add(action);
|
|
17582
|
-
}
|
|
17594
|
+
for (const action of entry.actions) {
|
|
17595
|
+
addRawAbility(rawAbilities, entry.path, action);
|
|
17596
|
+
}
|
|
17597
|
+
if (entry.actions.includes(DECRYPT_ACTION)) {
|
|
17598
|
+
const parsed = (0, import_sdk_core.parseNetworkId)(entry.path);
|
|
17599
|
+
if (didPrincipalMatches(parsed.ownerDid, currentDid)) {
|
|
17600
|
+
addRawAbility(rawAbilities, entry.path, NETWORK_CREATE_ACTION);
|
|
17583
17601
|
}
|
|
17584
17602
|
}
|
|
17585
17603
|
return false;
|
|
@@ -18138,30 +18156,33 @@ var NodeUserAuthorization = class {
|
|
|
18138
18156
|
}
|
|
18139
18157
|
};
|
|
18140
18158
|
|
|
18141
|
-
// src/
|
|
18159
|
+
// src/account/AccountService.ts
|
|
18142
18160
|
var import_sdk_core2 = require("@tinycloud/sdk-core");
|
|
18161
|
+
|
|
18162
|
+
// src/DelegatedAccess.ts
|
|
18163
|
+
var import_sdk_core3 = require("@tinycloud/sdk-core");
|
|
18143
18164
|
var DelegatedAccess = class {
|
|
18144
18165
|
constructor(session, delegation, host, invoke2, telemetry) {
|
|
18145
18166
|
this.session = session;
|
|
18146
18167
|
this._delegation = delegation;
|
|
18147
18168
|
this.host = host;
|
|
18148
|
-
this._serviceContext = new
|
|
18169
|
+
this._serviceContext = new import_sdk_core3.ServiceContext({
|
|
18149
18170
|
invoke: invoke2,
|
|
18150
18171
|
fetch: globalThis.fetch.bind(globalThis),
|
|
18151
18172
|
hosts: [host],
|
|
18152
18173
|
telemetry
|
|
18153
18174
|
});
|
|
18154
18175
|
const prefix = this._delegation.path.replace(/\/$/, "");
|
|
18155
|
-
this._kv = new
|
|
18176
|
+
this._kv = new import_sdk_core3.KVService({ prefix });
|
|
18156
18177
|
this._kv.initialize(this._serviceContext);
|
|
18157
18178
|
this._serviceContext.registerService("kv", this._kv);
|
|
18158
|
-
this._sql = new
|
|
18179
|
+
this._sql = new import_sdk_core3.SQLService({});
|
|
18159
18180
|
this._sql.initialize(this._serviceContext);
|
|
18160
18181
|
this._serviceContext.registerService("sql", this._sql);
|
|
18161
|
-
this._duckdb = new
|
|
18182
|
+
this._duckdb = new import_sdk_core3.DuckDbService({});
|
|
18162
18183
|
this._duckdb.initialize(this._serviceContext);
|
|
18163
18184
|
this._serviceContext.registerService("duckdb", this._duckdb);
|
|
18164
|
-
this._hooks = new
|
|
18185
|
+
this._hooks = new import_sdk_core3.HooksService({});
|
|
18165
18186
|
this._hooks.initialize(this._serviceContext);
|
|
18166
18187
|
this._serviceContext.registerService("hooks", this._hooks);
|
|
18167
18188
|
const serviceSession = {
|
|
@@ -18311,7 +18332,7 @@ function createWasmKeyProvider(sessionManager) {
|
|
|
18311
18332
|
}
|
|
18312
18333
|
|
|
18313
18334
|
// src/delegateToHelpers.ts
|
|
18314
|
-
var
|
|
18335
|
+
var import_sdk_core4 = require("@tinycloud/sdk-core");
|
|
18315
18336
|
function legacyParamsToPermissionEntries(actions, path, spaceIdOverride) {
|
|
18316
18337
|
const byService = /* @__PURE__ */ new Map();
|
|
18317
18338
|
for (const a of actions) {
|
|
@@ -18342,7 +18363,7 @@ function legacyParamsToPermissionEntries(actions, path, spaceIdOverride) {
|
|
|
18342
18363
|
}
|
|
18343
18364
|
return entries;
|
|
18344
18365
|
}
|
|
18345
|
-
var DEFAULT_DELEGATION_EXPIRY_MS =
|
|
18366
|
+
var DEFAULT_DELEGATION_EXPIRY_MS = import_sdk_core4.EXPIRY.SESSION_MS;
|
|
18346
18367
|
function resolveExpiryMs(expiry) {
|
|
18347
18368
|
if (expiry === void 0) {
|
|
18348
18369
|
return DEFAULT_DELEGATION_EXPIRY_MS;
|
|
@@ -18355,10 +18376,10 @@ function resolveExpiryMs(expiry) {
|
|
|
18355
18376
|
}
|
|
18356
18377
|
return expiry;
|
|
18357
18378
|
}
|
|
18358
|
-
return (0,
|
|
18379
|
+
return (0, import_sdk_core4.parseExpiry)(expiry);
|
|
18359
18380
|
}
|
|
18360
18381
|
function extractSiweExpiration(siwe) {
|
|
18361
|
-
const parsed = new
|
|
18382
|
+
const parsed = new import_sdk_core4.SiweMessage(siwe);
|
|
18362
18383
|
if (parsed.expirationTime === void 0 || parsed.expirationTime === null) {
|
|
18363
18384
|
return void 0;
|
|
18364
18385
|
}
|
|
@@ -18372,7 +18393,7 @@ function extractSiweExpiration(siwe) {
|
|
|
18372
18393
|
}
|
|
18373
18394
|
|
|
18374
18395
|
// src/NodeSecretsService.ts
|
|
18375
|
-
var
|
|
18396
|
+
var import_sdk_core5 = require("@tinycloud/sdk-core");
|
|
18376
18397
|
var SECRETS_SPACE = "secrets";
|
|
18377
18398
|
function ok() {
|
|
18378
18399
|
return { ok: true, data: void 0 };
|
|
@@ -18405,7 +18426,7 @@ function secretActionName(action) {
|
|
|
18405
18426
|
}
|
|
18406
18427
|
function secretPermissionEntries(name, options, action, encryptionNetworkId) {
|
|
18407
18428
|
const entries = [];
|
|
18408
|
-
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;
|
|
18409
18430
|
entries.push({
|
|
18410
18431
|
service: "tinycloud.kv",
|
|
18411
18432
|
space: SECRETS_SPACE,
|
|
@@ -18484,7 +18505,7 @@ var NodeSecretsService = class {
|
|
|
18484
18505
|
);
|
|
18485
18506
|
} catch (error) {
|
|
18486
18507
|
return secretsError(
|
|
18487
|
-
|
|
18508
|
+
import_sdk_core5.ErrorCodes.INVALID_INPUT,
|
|
18488
18509
|
error instanceof Error ? error.message : String(error),
|
|
18489
18510
|
error instanceof Error ? error : void 0
|
|
18490
18511
|
);
|
|
@@ -18494,7 +18515,7 @@ var NodeSecretsService = class {
|
|
|
18494
18515
|
}
|
|
18495
18516
|
if (!this.config.canEscalate()) {
|
|
18496
18517
|
return secretsError(
|
|
18497
|
-
|
|
18518
|
+
import_sdk_core5.ErrorCodes.PERMISSION_DENIED,
|
|
18498
18519
|
`Cannot autosign ${displayActionUrn(action)} for ${target}; TinyCloudNode needs wallet mode with a signer or privateKey.`
|
|
18499
18520
|
);
|
|
18500
18521
|
}
|
|
@@ -18503,7 +18524,7 @@ var NodeSecretsService = class {
|
|
|
18503
18524
|
return this.restoreUnlockAfterEscalation();
|
|
18504
18525
|
} catch (error) {
|
|
18505
18526
|
return secretsError(
|
|
18506
|
-
|
|
18527
|
+
import_sdk_core5.ErrorCodes.PERMISSION_DENIED,
|
|
18507
18528
|
error instanceof Error ? error.message : `Autosign escalation for ${displayActionUrn(action)} on ${target} failed.`,
|
|
18508
18529
|
error instanceof Error ? error : void 0
|
|
18509
18530
|
);
|
|
@@ -18524,10 +18545,10 @@ var NodeSecretsService = class {
|
|
|
18524
18545
|
return false;
|
|
18525
18546
|
}
|
|
18526
18547
|
const manifests = Array.isArray(manifest) ? manifest : [manifest];
|
|
18527
|
-
const requestedEntries = (0,
|
|
18548
|
+
const requestedEntries = (0, import_sdk_core5.expandPermissionEntries)(permissionEntries);
|
|
18528
18549
|
return requestedEntries.every(
|
|
18529
18550
|
(entry) => manifests.some((candidate) => {
|
|
18530
|
-
const resolved = (0,
|
|
18551
|
+
const resolved = (0, import_sdk_core5.resolveManifest)(candidate);
|
|
18531
18552
|
return resolved.resources.some(
|
|
18532
18553
|
(resource) => resource.service === entry.service && resource.space === entry.space && resource.path === entry.path && entry.actions.every((action) => resource.actions.includes(action))
|
|
18533
18554
|
);
|
|
@@ -18539,13 +18560,13 @@ var NodeSecretsService = class {
|
|
|
18539
18560
|
// src/TinyCloudNode.ts
|
|
18540
18561
|
var DEFAULT_HOST = "https://node.tinycloud.xyz";
|
|
18541
18562
|
var DEFAULT_ENCRYPTION_NETWORK_NAME = "default";
|
|
18542
|
-
var
|
|
18543
|
-
var
|
|
18563
|
+
var NETWORK_CREATE_ACTION2 = "tinycloud.encryption/network.create";
|
|
18564
|
+
var DECRYPT_ACTION2 = "tinycloud.encryption/decrypt";
|
|
18544
18565
|
var NETWORK_ADMIN_TYPE = "tinycloud.encryption.network-admin/v1";
|
|
18545
|
-
var DEFAULT_SESSION_EXPIRATION_MS =
|
|
18546
|
-
function
|
|
18566
|
+
var DEFAULT_SESSION_EXPIRATION_MS = import_sdk_core6.EXPIRY.SESSION_MS;
|
|
18567
|
+
function didPrincipalMatches2(actual, expected) {
|
|
18547
18568
|
try {
|
|
18548
|
-
return (0,
|
|
18569
|
+
return (0, import_sdk_core6.principalDidEquals)(actual, expected);
|
|
18549
18570
|
} catch {
|
|
18550
18571
|
return actual === expected;
|
|
18551
18572
|
}
|
|
@@ -18711,12 +18732,12 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
18711
18732
|
throw new Error("Failed to get session key JWK");
|
|
18712
18733
|
}
|
|
18713
18734
|
this.sessionKeyJwk = JSON.parse(jwkStr);
|
|
18714
|
-
this._capabilityRegistry = new
|
|
18735
|
+
this._capabilityRegistry = new import_sdk_core6.CapabilityKeyRegistry();
|
|
18715
18736
|
this._keyProvider = new WasmKeyProvider({
|
|
18716
18737
|
sessionManager: this.sessionManager
|
|
18717
18738
|
});
|
|
18718
|
-
this.notificationHandler = config.notificationHandler ?? new
|
|
18719
|
-
this._sharingService = new
|
|
18739
|
+
this.notificationHandler = config.notificationHandler ?? new import_sdk_core6.SilentNotificationHandler();
|
|
18740
|
+
this._sharingService = new import_sdk_core6.SharingService({
|
|
18720
18741
|
hosts: [this.config.host],
|
|
18721
18742
|
// session: undefined - not needed for receive()
|
|
18722
18743
|
invoke: this.invokeWithRuntimePermissions,
|
|
@@ -18726,8 +18747,8 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
18726
18747
|
// delegationManager: undefined - not needed for receive()
|
|
18727
18748
|
createKVService: (config2) => {
|
|
18728
18749
|
const prefix = config2.pathPrefix?.replace(/\/$/, "");
|
|
18729
|
-
const kvService = new
|
|
18730
|
-
const kvContext = new
|
|
18750
|
+
const kvService = new import_sdk_core6.KVService({ prefix });
|
|
18751
|
+
const kvContext = new import_sdk_core6.ServiceContext({
|
|
18731
18752
|
invoke: config2.invoke,
|
|
18732
18753
|
fetch: config2.fetch ?? globalThis.fetch.bind(globalThis),
|
|
18733
18754
|
hosts: config2.hosts,
|
|
@@ -18787,7 +18808,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
18787
18808
|
capabilityRequest: config.capabilityRequest,
|
|
18788
18809
|
includeAccountRegistryPermissions: config.includeAccountRegistryPermissions
|
|
18789
18810
|
});
|
|
18790
|
-
this.tc = new
|
|
18811
|
+
this.tc = new import_sdk_core6.TinyCloud(this.auth, {
|
|
18791
18812
|
invokeAny: this.invokeAnyWithRuntimePermissions,
|
|
18792
18813
|
telemetry: config.telemetry
|
|
18793
18814
|
});
|
|
@@ -18848,7 +18869,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
18848
18869
|
*/
|
|
18849
18870
|
get did() {
|
|
18850
18871
|
if (this._address) {
|
|
18851
|
-
return (0,
|
|
18872
|
+
return (0, import_sdk_core6.pkhDid)(this._address, this._chainId);
|
|
18852
18873
|
}
|
|
18853
18874
|
return this.sessionManager.getDID(this.sessionKeyId);
|
|
18854
18875
|
}
|
|
@@ -18882,6 +18903,37 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
18882
18903
|
get spaceId() {
|
|
18883
18904
|
return this.auth?.tinyCloudSession?.spaceId;
|
|
18884
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
|
+
}
|
|
18885
18937
|
/**
|
|
18886
18938
|
* Get the current TinyCloud session.
|
|
18887
18939
|
* Available after signIn().
|
|
@@ -18903,7 +18955,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
18903
18955
|
);
|
|
18904
18956
|
}
|
|
18905
18957
|
await this.wasmBindings.ensureInitialized?.();
|
|
18906
|
-
this._address = (0,
|
|
18958
|
+
this._address = (0, import_sdk_core6.canonicalizeAddress)(await this.signer.getAddress());
|
|
18907
18959
|
this._chainId = await this.signer.getChainId();
|
|
18908
18960
|
this._kv = void 0;
|
|
18909
18961
|
this._sql = void 0;
|
|
@@ -18919,6 +18971,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
18919
18971
|
await this.tc.signIn(options);
|
|
18920
18972
|
this.syncResolvedHostFromAuth();
|
|
18921
18973
|
this.initializeServices();
|
|
18974
|
+
await this.ensureRequestedEncryptionNetworks();
|
|
18922
18975
|
if (this.config.manifest === void 0 && this.config.capabilityRequest === void 0) {
|
|
18923
18976
|
await this.ensureOwnedSpaceHosted(this.ownedSpaceId("secrets"));
|
|
18924
18977
|
}
|
|
@@ -18939,7 +18992,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
18939
18992
|
if (!this.auth || !this.signer) {
|
|
18940
18993
|
throw new Error("Manifest registry write requires wallet mode");
|
|
18941
18994
|
}
|
|
18942
|
-
const accountSpaceId = this.ownedSpaceId(
|
|
18995
|
+
const accountSpaceId = this.ownedSpaceId(import_sdk_core6.ACCOUNT_REGISTRY_SPACE);
|
|
18943
18996
|
await this.ensureOwnedSpaceHosted(accountSpaceId);
|
|
18944
18997
|
const accountKV = this.spaces.get(accountSpaceId).kv;
|
|
18945
18998
|
for (const record of request.registryRecords) {
|
|
@@ -18955,6 +19008,31 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
18955
19008
|
}
|
|
18956
19009
|
}
|
|
18957
19010
|
}
|
|
19011
|
+
requestedEncryptionNetworkIds() {
|
|
19012
|
+
const request = this.capabilityRequest;
|
|
19013
|
+
if (!request) {
|
|
19014
|
+
return [];
|
|
19015
|
+
}
|
|
19016
|
+
const networkIds = /* @__PURE__ */ new Set();
|
|
19017
|
+
for (const resource of request.resources) {
|
|
19018
|
+
if (resource.service === import_sdk_core6.ENCRYPTION_PERMISSION_SERVICE && resource.path.startsWith("urn:tinycloud:encryption:") && resource.actions.includes(DECRYPT_ACTION2)) {
|
|
19019
|
+
networkIds.add(resource.path);
|
|
19020
|
+
}
|
|
19021
|
+
}
|
|
19022
|
+
return [...networkIds];
|
|
19023
|
+
}
|
|
19024
|
+
async ensureRequestedEncryptionNetworks() {
|
|
19025
|
+
if (!this.signer || !this.auth) {
|
|
19026
|
+
return;
|
|
19027
|
+
}
|
|
19028
|
+
for (const networkId of this.requestedEncryptionNetworkIds()) {
|
|
19029
|
+
const parsed = (0, import_sdk_core6.parseNetworkId)(networkId);
|
|
19030
|
+
if (!didPrincipalMatches2(parsed.ownerDid, this.did)) {
|
|
19031
|
+
continue;
|
|
19032
|
+
}
|
|
19033
|
+
await this.ensureEncryptionNetwork(networkId);
|
|
19034
|
+
}
|
|
19035
|
+
}
|
|
18958
19036
|
async ensureOwnedSpaceHosted(spaceId) {
|
|
18959
19037
|
if (!this.auth) {
|
|
18960
19038
|
throw new Error("Owned space hosting requires wallet mode");
|
|
@@ -18967,7 +19045,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
18967
19045
|
if (!host) {
|
|
18968
19046
|
throw new Error("Owned space hosting requires a TinyCloud host");
|
|
18969
19047
|
}
|
|
18970
|
-
const activation = await (0,
|
|
19048
|
+
const activation = await (0, import_sdk_core6.activateSessionWithHost)(host, session.delegationHeader);
|
|
18971
19049
|
if (activation.success && !activation.skipped?.includes(spaceId)) {
|
|
18972
19050
|
return;
|
|
18973
19051
|
}
|
|
@@ -18981,7 +19059,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
18981
19059
|
throw new Error(`Failed to create owned space: ${spaceId}`);
|
|
18982
19060
|
}
|
|
18983
19061
|
await new Promise((resolve) => setTimeout(resolve, 100));
|
|
18984
|
-
const retry = await (0,
|
|
19062
|
+
const retry = await (0, import_sdk_core6.activateSessionWithHost)(host, session.delegationHeader);
|
|
18985
19063
|
if (!retry.success || retry.skipped?.includes(spaceId)) {
|
|
18986
19064
|
throw new Error(
|
|
18987
19065
|
`Failed to activate session after creating owned space ${spaceId}: ${retry.error ?? "space was skipped"}`
|
|
@@ -19023,7 +19101,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
19023
19101
|
if (!hosted) {
|
|
19024
19102
|
throw new Error(`Failed to host owned space: ${spaceId}`);
|
|
19025
19103
|
}
|
|
19026
|
-
const activation = await (0,
|
|
19104
|
+
const activation = await (0, import_sdk_core6.activateSessionWithHost)(
|
|
19027
19105
|
host,
|
|
19028
19106
|
this.auth.tinyCloudSession.delegationHeader
|
|
19029
19107
|
);
|
|
@@ -19056,30 +19134,30 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
19056
19134
|
this._spaceService = void 0;
|
|
19057
19135
|
this._serviceContext = void 0;
|
|
19058
19136
|
this.runtimePermissionGrants = [];
|
|
19059
|
-
const restoredAddress = sessionData.address ? (0,
|
|
19137
|
+
const restoredAddress = sessionData.address ? (0, import_sdk_core6.canonicalizeAddress)(sessionData.address) : void 0;
|
|
19060
19138
|
if (restoredAddress) {
|
|
19061
19139
|
this._address = restoredAddress;
|
|
19062
19140
|
}
|
|
19063
19141
|
if (sessionData.chainId) {
|
|
19064
19142
|
this._chainId = sessionData.chainId;
|
|
19065
19143
|
}
|
|
19066
|
-
this._serviceContext = new
|
|
19144
|
+
this._serviceContext = new import_sdk_core6.ServiceContext({
|
|
19067
19145
|
invoke: this.invokeWithRuntimePermissions,
|
|
19068
19146
|
invokeAny: this.invokeAnyWithRuntimePermissions,
|
|
19069
19147
|
fetch: globalThis.fetch.bind(globalThis),
|
|
19070
19148
|
hosts: [this.config.host],
|
|
19071
19149
|
telemetry: this.config.telemetry
|
|
19072
19150
|
});
|
|
19073
|
-
this._kv = new
|
|
19151
|
+
this._kv = new import_sdk_core6.KVService({});
|
|
19074
19152
|
this._kv.initialize(this._serviceContext);
|
|
19075
19153
|
this._serviceContext.registerService("kv", this._kv);
|
|
19076
|
-
this._sql = new
|
|
19154
|
+
this._sql = new import_sdk_core6.SQLService({});
|
|
19077
19155
|
this._sql.initialize(this._serviceContext);
|
|
19078
19156
|
this._serviceContext.registerService("sql", this._sql);
|
|
19079
|
-
this._duckdb = new
|
|
19157
|
+
this._duckdb = new import_sdk_core6.DuckDbService({});
|
|
19080
19158
|
this._duckdb.initialize(this._serviceContext);
|
|
19081
19159
|
this._serviceContext.registerService("duckdb", this._duckdb);
|
|
19082
|
-
this._hooks = new
|
|
19160
|
+
this._hooks = new import_sdk_core6.HooksService({});
|
|
19083
19161
|
this._hooks.initialize(this._serviceContext);
|
|
19084
19162
|
this._serviceContext.registerService("hooks", this._hooks);
|
|
19085
19163
|
const serviceSession = {
|
|
@@ -19178,7 +19256,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
19178
19256
|
capabilityRequest: this.config.capabilityRequest,
|
|
19179
19257
|
includeAccountRegistryPermissions: this.config.includeAccountRegistryPermissions
|
|
19180
19258
|
});
|
|
19181
|
-
this.tc = new
|
|
19259
|
+
this.tc = new import_sdk_core6.TinyCloud(this.auth, {
|
|
19182
19260
|
invokeAny: this.invokeAnyWithRuntimePermissions,
|
|
19183
19261
|
telemetry: this.config.telemetry
|
|
19184
19262
|
});
|
|
@@ -19223,7 +19301,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
19223
19301
|
capabilityRequest: this.config.capabilityRequest,
|
|
19224
19302
|
includeAccountRegistryPermissions: this.config.includeAccountRegistryPermissions
|
|
19225
19303
|
});
|
|
19226
|
-
this.tc = new
|
|
19304
|
+
this.tc = new import_sdk_core6.TinyCloud(this.auth, {
|
|
19227
19305
|
invokeAny: this.invokeAnyWithRuntimePermissions,
|
|
19228
19306
|
telemetry: this.config.telemetry
|
|
19229
19307
|
});
|
|
@@ -19239,28 +19317,28 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
19239
19317
|
return;
|
|
19240
19318
|
}
|
|
19241
19319
|
this.tc.initializeServices(this.invokeWithRuntimePermissions, [this.config.host]);
|
|
19242
|
-
this._serviceContext = new
|
|
19320
|
+
this._serviceContext = new import_sdk_core6.ServiceContext({
|
|
19243
19321
|
invoke: this.invokeWithRuntimePermissions,
|
|
19244
19322
|
invokeAny: this.invokeAnyWithRuntimePermissions,
|
|
19245
19323
|
fetch: globalThis.fetch.bind(globalThis),
|
|
19246
19324
|
hosts: [this.config.host],
|
|
19247
19325
|
telemetry: this.config.telemetry
|
|
19248
19326
|
});
|
|
19249
|
-
this._kv = new
|
|
19327
|
+
this._kv = new import_sdk_core6.KVService({});
|
|
19250
19328
|
this._kv.initialize(this._serviceContext);
|
|
19251
19329
|
this._serviceContext.registerService("kv", this._kv);
|
|
19252
19330
|
const features = this.nodeFeatures;
|
|
19253
19331
|
if (features.length === 0 || features.includes("sql")) {
|
|
19254
|
-
this._sql = new
|
|
19332
|
+
this._sql = new import_sdk_core6.SQLService({});
|
|
19255
19333
|
this._sql.initialize(this._serviceContext);
|
|
19256
19334
|
this._serviceContext.registerService("sql", this._sql);
|
|
19257
19335
|
}
|
|
19258
19336
|
if (features.length === 0 || features.includes("duckdb")) {
|
|
19259
|
-
this._duckdb = new
|
|
19337
|
+
this._duckdb = new import_sdk_core6.DuckDbService({});
|
|
19260
19338
|
this._duckdb.initialize(this._serviceContext);
|
|
19261
19339
|
this._serviceContext.registerService("duckdb", this._duckdb);
|
|
19262
19340
|
}
|
|
19263
|
-
this._hooks = new
|
|
19341
|
+
this._hooks = new import_sdk_core6.HooksService({});
|
|
19264
19342
|
this._hooks.initialize(this._serviceContext);
|
|
19265
19343
|
this._serviceContext.registerService("hooks", this._hooks);
|
|
19266
19344
|
const serviceSession = {
|
|
@@ -19278,9 +19356,9 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
19278
19356
|
this.initializeV2Services(serviceSession);
|
|
19279
19357
|
}
|
|
19280
19358
|
createSpaceScopedKVService(spaceId) {
|
|
19281
|
-
const kvService = new
|
|
19359
|
+
const kvService = new import_sdk_core6.KVService({});
|
|
19282
19360
|
if (this._serviceContext) {
|
|
19283
|
-
const spaceScopedContext = new
|
|
19361
|
+
const spaceScopedContext = new import_sdk_core6.ServiceContext({
|
|
19284
19362
|
invoke: this._serviceContext.invoke,
|
|
19285
19363
|
fetch: this._serviceContext.fetch,
|
|
19286
19364
|
hosts: this._serviceContext.hosts,
|
|
@@ -19345,7 +19423,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
19345
19423
|
const shared = wasm.vault_x25519_dh(receiverPrivateKey, peerPublic);
|
|
19346
19424
|
return columnDecrypt(shared, ciphertext);
|
|
19347
19425
|
},
|
|
19348
|
-
verifyNodeSignature: (nodeId, message, signature2) => (0,
|
|
19426
|
+
verifyNodeSignature: (nodeId, message, signature2) => (0, import_sdk_core6.verifyDidKeyEd25519Signature)(nodeId, message, signature2)
|
|
19349
19427
|
};
|
|
19350
19428
|
}
|
|
19351
19429
|
async fetchNodeId() {
|
|
@@ -19416,19 +19494,19 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
19416
19494
|
return await response.json();
|
|
19417
19495
|
}
|
|
19418
19496
|
};
|
|
19419
|
-
return new
|
|
19497
|
+
return new import_sdk_core6.EncryptionService({
|
|
19420
19498
|
crypto: crypto2,
|
|
19421
19499
|
signer: {
|
|
19422
19500
|
signDecryptInvocation: async (input) => {
|
|
19423
19501
|
const signed2 = await this.signRawNetworkAuthorization({
|
|
19424
19502
|
targetNode: input.targetNode,
|
|
19425
19503
|
networkId: input.networkId,
|
|
19426
|
-
action:
|
|
19504
|
+
action: DECRYPT_ACTION2,
|
|
19427
19505
|
facts: input.facts
|
|
19428
19506
|
});
|
|
19429
19507
|
return {
|
|
19430
19508
|
...signed2,
|
|
19431
|
-
canonicalBody: (0,
|
|
19509
|
+
canonicalBody: (0, import_sdk_core6.canonicalizeEncryptionJson)(
|
|
19432
19510
|
input.body
|
|
19433
19511
|
)
|
|
19434
19512
|
};
|
|
@@ -19440,14 +19518,14 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
19440
19518
|
},
|
|
19441
19519
|
wellKnown: {
|
|
19442
19520
|
fetchWellKnown: async (principal, discoveryKey) => {
|
|
19443
|
-
if (!this._address || !
|
|
19521
|
+
if (!this._address || !didPrincipalMatches2(principal, this.did)) {
|
|
19444
19522
|
return null;
|
|
19445
19523
|
}
|
|
19446
19524
|
if (!this.config.host) {
|
|
19447
19525
|
return null;
|
|
19448
19526
|
}
|
|
19449
|
-
const publicSpaceId = (0,
|
|
19450
|
-
const result = await
|
|
19527
|
+
const publicSpaceId = (0, import_sdk_core6.makePublicSpaceId)(this._address, this._chainId);
|
|
19528
|
+
const result = await import_sdk_core6.TinyCloud.readPublicSpace(this.config.host, publicSpaceId, discoveryKey);
|
|
19451
19529
|
if (!result.ok) {
|
|
19452
19530
|
return null;
|
|
19453
19531
|
}
|
|
@@ -19470,7 +19548,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
19470
19548
|
}
|
|
19471
19549
|
createVaultService(spaceId, kv) {
|
|
19472
19550
|
const wasm = this.wasmBindings;
|
|
19473
|
-
const vaultCrypto = (0,
|
|
19551
|
+
const vaultCrypto = (0, import_sdk_core6.createVaultCrypto)({
|
|
19474
19552
|
vault_encrypt: wasm.vault_encrypt,
|
|
19475
19553
|
vault_decrypt: wasm.vault_decrypt,
|
|
19476
19554
|
vault_derive_key: wasm.vault_derive_key,
|
|
@@ -19480,7 +19558,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
19480
19558
|
vault_sha256: wasm.vault_sha256
|
|
19481
19559
|
});
|
|
19482
19560
|
const self2 = this;
|
|
19483
|
-
return new
|
|
19561
|
+
return new import_sdk_core6.DataVaultService({
|
|
19484
19562
|
spaceId,
|
|
19485
19563
|
crypto: vaultCrypto,
|
|
19486
19564
|
encryption: {
|
|
@@ -19503,8 +19581,8 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
19503
19581
|
get publicKV() {
|
|
19504
19582
|
return self2._publicKV ?? self2.tc.publicKV;
|
|
19505
19583
|
},
|
|
19506
|
-
readPublicSpace: (host, targetSpaceId, key2) =>
|
|
19507
|
-
makePublicSpaceId:
|
|
19584
|
+
readPublicSpace: (host, targetSpaceId, key2) => import_sdk_core6.TinyCloud.readPublicSpace(host, targetSpaceId, key2),
|
|
19585
|
+
makePublicSpaceId: import_sdk_core6.TinyCloud.makePublicSpaceId,
|
|
19508
19586
|
did: this.did,
|
|
19509
19587
|
address: this._address ?? "",
|
|
19510
19588
|
chainId: this._chainId,
|
|
@@ -19517,7 +19595,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
19517
19595
|
* @internal
|
|
19518
19596
|
*/
|
|
19519
19597
|
initializeV2Services(serviceSession) {
|
|
19520
|
-
this._capabilityRegistry = new
|
|
19598
|
+
this._capabilityRegistry = new import_sdk_core6.CapabilityKeyRegistry();
|
|
19521
19599
|
const tcSession = this.auth?.tinyCloudSession;
|
|
19522
19600
|
if (tcSession && this._address) {
|
|
19523
19601
|
const sessionKey = {
|
|
@@ -19591,13 +19669,13 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
19591
19669
|
}
|
|
19592
19670
|
this._capabilityRegistry.registerKey(sessionKey, delegations);
|
|
19593
19671
|
}
|
|
19594
|
-
this._delegationManager = new
|
|
19672
|
+
this._delegationManager = new import_sdk_core6.DelegationManager({
|
|
19595
19673
|
hosts: [this.config.host],
|
|
19596
19674
|
session: serviceSession,
|
|
19597
19675
|
invoke: this.invokeWithRuntimePermissions,
|
|
19598
19676
|
fetch: globalThis.fetch.bind(globalThis)
|
|
19599
19677
|
});
|
|
19600
|
-
this._spaceService = new
|
|
19678
|
+
this._spaceService = new import_sdk_core6.SpaceService({
|
|
19601
19679
|
hosts: [this.config.host],
|
|
19602
19680
|
session: serviceSession,
|
|
19603
19681
|
invoke: this.wasmBindings.invoke,
|
|
@@ -19754,7 +19832,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
19754
19832
|
...prepared,
|
|
19755
19833
|
signature: signature2
|
|
19756
19834
|
});
|
|
19757
|
-
const activateResult = await (0,
|
|
19835
|
+
const activateResult = await (0, import_sdk_core6.activateSessionWithHost)(
|
|
19758
19836
|
host,
|
|
19759
19837
|
delegationSession.delegationHeader
|
|
19760
19838
|
);
|
|
@@ -19764,7 +19842,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
19764
19842
|
return {
|
|
19765
19843
|
cid: delegationSession.delegationCid,
|
|
19766
19844
|
delegateDID: params.shareKeyDID,
|
|
19767
|
-
delegatorDID: (0,
|
|
19845
|
+
delegatorDID: (0, import_sdk_core6.pkhDid)(session.address, session.chainId),
|
|
19768
19846
|
spaceId: params.spaceId,
|
|
19769
19847
|
path: params.path,
|
|
19770
19848
|
actions: params.actions,
|
|
@@ -19821,7 +19899,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
19821
19899
|
if (!this._sql) {
|
|
19822
19900
|
const features = this.nodeFeatures;
|
|
19823
19901
|
if (features.length > 0 && !features.includes("sql")) {
|
|
19824
|
-
throw new
|
|
19902
|
+
throw new import_sdk_core6.UnsupportedFeatureError("sql", this.config.host, features);
|
|
19825
19903
|
}
|
|
19826
19904
|
throw new Error("Not signed in. Call signIn() first.");
|
|
19827
19905
|
}
|
|
@@ -19845,8 +19923,8 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
19845
19923
|
if (!this._serviceContext || !this._serviceContext.session) {
|
|
19846
19924
|
throw new Error("Not signed in. Call signIn() first.");
|
|
19847
19925
|
}
|
|
19848
|
-
const sql = new
|
|
19849
|
-
const spaceScopedContext = new
|
|
19926
|
+
const sql = new import_sdk_core6.SQLService({});
|
|
19927
|
+
const spaceScopedContext = new import_sdk_core6.ServiceContext({
|
|
19850
19928
|
invoke: this._serviceContext.invoke,
|
|
19851
19929
|
fetch: this._serviceContext.fetch,
|
|
19852
19930
|
hosts: this._serviceContext.hosts,
|
|
@@ -19874,8 +19952,8 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
19874
19952
|
if (!this._serviceContext || !this._serviceContext.session) {
|
|
19875
19953
|
throw new Error("Not signed in. Call signIn() first.");
|
|
19876
19954
|
}
|
|
19877
|
-
const kv = new
|
|
19878
|
-
const spaceScopedContext = new
|
|
19955
|
+
const kv = new import_sdk_core6.KVService({});
|
|
19956
|
+
const spaceScopedContext = new import_sdk_core6.ServiceContext({
|
|
19879
19957
|
invoke: this._serviceContext.invoke,
|
|
19880
19958
|
fetch: this._serviceContext.fetch,
|
|
19881
19959
|
hosts: this._serviceContext.hosts
|
|
@@ -19891,7 +19969,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
19891
19969
|
if (!this._duckdb) {
|
|
19892
19970
|
const features = this.nodeFeatures;
|
|
19893
19971
|
if (features.length > 0 && !features.includes("duckdb")) {
|
|
19894
|
-
throw new
|
|
19972
|
+
throw new import_sdk_core6.UnsupportedFeatureError("duckdb", this.config.host, features);
|
|
19895
19973
|
}
|
|
19896
19974
|
throw new Error("Not signed in. Call signIn() first.");
|
|
19897
19975
|
}
|
|
@@ -19943,16 +20021,16 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
19943
20021
|
type: NETWORK_ADMIN_TYPE,
|
|
19944
20022
|
targetNode,
|
|
19945
20023
|
networkId,
|
|
19946
|
-
bodyHash: (0,
|
|
20024
|
+
bodyHash: (0, import_sdk_core6.canonicalHashHex)(
|
|
19947
20025
|
crypto2.sha256,
|
|
19948
20026
|
body
|
|
19949
20027
|
),
|
|
19950
|
-
action:
|
|
20028
|
+
action: NETWORK_CREATE_ACTION2
|
|
19951
20029
|
};
|
|
19952
20030
|
const signed2 = await this.signRawNetworkAuthorization({
|
|
19953
20031
|
targetNode,
|
|
19954
20032
|
networkId,
|
|
19955
|
-
action:
|
|
20033
|
+
action: NETWORK_CREATE_ACTION2,
|
|
19956
20034
|
facts
|
|
19957
20035
|
});
|
|
19958
20036
|
const response = await fetch(`${this.config.host}/encryption/networks`, {
|
|
@@ -19961,7 +20039,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
19961
20039
|
Authorization: signed2.authorization,
|
|
19962
20040
|
"Content-Type": "application/json"
|
|
19963
20041
|
},
|
|
19964
|
-
body: (0,
|
|
20042
|
+
body: (0, import_sdk_core6.canonicalizeEncryptionJson)(
|
|
19965
20043
|
body
|
|
19966
20044
|
)
|
|
19967
20045
|
});
|
|
@@ -19973,12 +20051,19 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
19973
20051
|
const created = await response.json();
|
|
19974
20052
|
return created.descriptor;
|
|
19975
20053
|
}
|
|
19976
|
-
async ensureEncryptionNetwork(
|
|
19977
|
-
const
|
|
20054
|
+
async ensureEncryptionNetwork(nameOrNetworkId = DEFAULT_ENCRYPTION_NETWORK_NAME) {
|
|
20055
|
+
const networkId = nameOrNetworkId.startsWith("urn:tinycloud:encryption:") ? nameOrNetworkId : this.getDefaultEncryptionNetworkId(nameOrNetworkId);
|
|
20056
|
+
const existing = await this.getEncryptionNetwork(networkId);
|
|
19978
20057
|
if (existing) {
|
|
19979
20058
|
return existing;
|
|
19980
20059
|
}
|
|
19981
|
-
|
|
20060
|
+
const parsed = (0, import_sdk_core6.parseNetworkId)(networkId);
|
|
20061
|
+
if (!didPrincipalMatches2(parsed.ownerDid, this.did)) {
|
|
20062
|
+
throw new Error(
|
|
20063
|
+
`Cannot create encryption network ${networkId}: owner ${parsed.ownerDid} does not match signed-in DID ${this.did}`
|
|
20064
|
+
);
|
|
20065
|
+
}
|
|
20066
|
+
return this.createEncryptionNetwork(parsed.name);
|
|
19982
20067
|
}
|
|
19983
20068
|
/**
|
|
19984
20069
|
* App-facing secrets API backed by the `secrets` space vault.
|
|
@@ -20005,7 +20090,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
20005
20090
|
throw new Error("Not signed in. Call signIn() first.");
|
|
20006
20091
|
}
|
|
20007
20092
|
if (!this._baseSecrets) {
|
|
20008
|
-
this._baseSecrets = new
|
|
20093
|
+
this._baseSecrets = new import_sdk_core6.SecretsService(() => this.space("secrets").vault);
|
|
20009
20094
|
}
|
|
20010
20095
|
return this._baseSecrets;
|
|
20011
20096
|
}
|
|
@@ -20120,19 +20205,19 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
20120
20205
|
async useRuntimeDelegation(delegation) {
|
|
20121
20206
|
const session = this.currentTinyCloudSession();
|
|
20122
20207
|
if (!session) {
|
|
20123
|
-
throw new
|
|
20208
|
+
throw new import_sdk_core6.SessionExpiredError(/* @__PURE__ */ new Date(0));
|
|
20124
20209
|
}
|
|
20125
20210
|
if (delegation.expiry.getTime() <= Date.now()) {
|
|
20126
|
-
throw new
|
|
20211
|
+
throw new import_sdk_core6.SessionExpiredError(delegation.expiry);
|
|
20127
20212
|
}
|
|
20128
20213
|
const expectedDids = [session.verificationMethod, this.sessionDid];
|
|
20129
|
-
if (!expectedDids.some((did) =>
|
|
20214
|
+
if (!expectedDids.some((did) => didPrincipalMatches2(delegation.delegateDID, did))) {
|
|
20130
20215
|
throw new Error(
|
|
20131
20216
|
`Runtime delegation targets ${delegation.delegateDID} but this session key is ${session.verificationMethod}.`
|
|
20132
20217
|
);
|
|
20133
20218
|
}
|
|
20134
20219
|
const targetHost = delegation.host ?? this.config.host;
|
|
20135
|
-
const activateResult = await (0,
|
|
20220
|
+
const activateResult = await (0, import_sdk_core6.activateSessionWithHost)(
|
|
20136
20221
|
targetHost,
|
|
20137
20222
|
delegation.delegationHeader
|
|
20138
20223
|
);
|
|
@@ -20159,13 +20244,13 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
20159
20244
|
}
|
|
20160
20245
|
const session = this.currentTinyCloudSession();
|
|
20161
20246
|
if (!session) {
|
|
20162
|
-
throw new
|
|
20247
|
+
throw new import_sdk_core6.SessionExpiredError(/* @__PURE__ */ new Date(0));
|
|
20163
20248
|
}
|
|
20164
20249
|
const sessionExpiry = extractSiweExpiration(session.siwe);
|
|
20165
20250
|
if (sessionExpiry !== void 0) {
|
|
20166
20251
|
const marginMs = _TinyCloudNode.SESSION_EXPIRY_SAFETY_MARGIN_MS;
|
|
20167
20252
|
if (sessionExpiry.getTime() <= Date.now() + marginMs) {
|
|
20168
|
-
throw new
|
|
20253
|
+
throw new import_sdk_core6.SessionExpiredError(sessionExpiry);
|
|
20169
20254
|
}
|
|
20170
20255
|
}
|
|
20171
20256
|
const expanded = this.expandPermissionEntries(permissions);
|
|
@@ -20228,7 +20313,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
20228
20313
|
...prepared,
|
|
20229
20314
|
signature: signature2
|
|
20230
20315
|
});
|
|
20231
|
-
const activateResult = await (0,
|
|
20316
|
+
const activateResult = await (0, import_sdk_core6.activateSessionWithHost)(
|
|
20232
20317
|
this.config.host,
|
|
20233
20318
|
delegatedSession.delegationHeader
|
|
20234
20319
|
);
|
|
@@ -20401,7 +20486,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
20401
20486
|
];
|
|
20402
20487
|
const abilities = { kv: { "": kvActions } };
|
|
20403
20488
|
const now = /* @__PURE__ */ new Date();
|
|
20404
|
-
const expiryMs =
|
|
20489
|
+
const expiryMs = import_sdk_core6.EXPIRY.EPHEMERAL_MS;
|
|
20405
20490
|
const expirationTime = new Date(now.getTime() + expiryMs);
|
|
20406
20491
|
const prepared = this.wasmBindings.prepareSession({
|
|
20407
20492
|
abilities,
|
|
@@ -20419,7 +20504,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
20419
20504
|
...prepared,
|
|
20420
20505
|
signature: signature2
|
|
20421
20506
|
});
|
|
20422
|
-
const activateResult = await (0,
|
|
20507
|
+
const activateResult = await (0, import_sdk_core6.activateSessionWithHost)(
|
|
20423
20508
|
this.config.host,
|
|
20424
20509
|
delegationSession.delegationHeader
|
|
20425
20510
|
);
|
|
@@ -20446,8 +20531,8 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
20446
20531
|
}]);
|
|
20447
20532
|
}
|
|
20448
20533
|
if (this._serviceContext) {
|
|
20449
|
-
const publicKV = new
|
|
20450
|
-
const publicContext = new
|
|
20534
|
+
const publicKV = new import_sdk_core6.KVService({ prefix: "" });
|
|
20535
|
+
const publicContext = new import_sdk_core6.ServiceContext({
|
|
20451
20536
|
invoke: this.invokeWithRuntimePermissions,
|
|
20452
20537
|
fetch: this._serviceContext.fetch,
|
|
20453
20538
|
hosts: this._serviceContext.hosts,
|
|
@@ -20574,14 +20659,14 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
20574
20659
|
async delegateTo(did, permissions, options) {
|
|
20575
20660
|
const session = this.currentTinyCloudSession();
|
|
20576
20661
|
if (!session) {
|
|
20577
|
-
throw new
|
|
20662
|
+
throw new import_sdk_core6.SessionExpiredError(/* @__PURE__ */ new Date(0));
|
|
20578
20663
|
}
|
|
20579
20664
|
const sessionExpiry = extractSiweExpiration(session.siwe);
|
|
20580
20665
|
if (sessionExpiry !== void 0) {
|
|
20581
20666
|
const now2 = Date.now();
|
|
20582
20667
|
const marginMs = _TinyCloudNode.SESSION_EXPIRY_SAFETY_MARGIN_MS;
|
|
20583
20668
|
if (sessionExpiry.getTime() <= now2 + marginMs) {
|
|
20584
|
-
throw new
|
|
20669
|
+
throw new import_sdk_core6.SessionExpiredError(sessionExpiry);
|
|
20585
20670
|
}
|
|
20586
20671
|
}
|
|
20587
20672
|
if (!Array.isArray(permissions) || permissions.length === 0) {
|
|
@@ -20610,11 +20695,11 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
20610
20695
|
);
|
|
20611
20696
|
return { delegation: delegation2, prompted: true };
|
|
20612
20697
|
}
|
|
20613
|
-
const granted = (0,
|
|
20698
|
+
const granted = (0, import_sdk_core6.parseRecapCapabilities)(
|
|
20614
20699
|
(siwe) => this.wasmBindings.parseRecapFromSiwe(siwe),
|
|
20615
20700
|
session.siwe
|
|
20616
20701
|
);
|
|
20617
|
-
const { subset, missing } = (0,
|
|
20702
|
+
const { subset, missing } = (0, import_sdk_core6.isCapabilitySubset)(expandedEntries, granted);
|
|
20618
20703
|
if (!subset) {
|
|
20619
20704
|
const runtimeGrant = this.findGrantForOperations(
|
|
20620
20705
|
this.permissionEntriesToOperations(expandedEntries, session)
|
|
@@ -20622,7 +20707,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
20622
20707
|
if (runtimeGrant) {
|
|
20623
20708
|
const marginMs = _TinyCloudNode.SESSION_EXPIRY_SAFETY_MARGIN_MS;
|
|
20624
20709
|
if (runtimeGrant.expiresAt.getTime() <= Date.now() + marginMs) {
|
|
20625
|
-
throw new
|
|
20710
|
+
throw new import_sdk_core6.SessionExpiredError(runtimeGrant.expiresAt);
|
|
20626
20711
|
}
|
|
20627
20712
|
const runtimeExpiration = runtimeGrant.expiresAt < effectiveExpiration ? runtimeGrant.expiresAt : effectiveExpiration;
|
|
20628
20713
|
const delegation2 = await this.createDelegationViaRuntimeGrant(
|
|
@@ -20633,7 +20718,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
20633
20718
|
);
|
|
20634
20719
|
return { delegation: delegation2, prompted: false };
|
|
20635
20720
|
}
|
|
20636
|
-
throw new
|
|
20721
|
+
throw new import_sdk_core6.PermissionNotInManifestError(missing, granted);
|
|
20637
20722
|
}
|
|
20638
20723
|
const delegation = await this.createDelegationViaWasmPath(
|
|
20639
20724
|
did,
|
|
@@ -20655,7 +20740,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
20655
20740
|
);
|
|
20656
20741
|
}
|
|
20657
20742
|
const target = request.delegationTargets.find(
|
|
20658
|
-
(entry) =>
|
|
20743
|
+
(entry) => didPrincipalMatches2(entry.did, did)
|
|
20659
20744
|
);
|
|
20660
20745
|
if (!target) {
|
|
20661
20746
|
throw new Error(`No manifest delegation target found for DID ${did}`);
|
|
@@ -20715,7 +20800,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
20715
20800
|
const spaceId = resolvedSpaces.size === 1 ? [...resolvedSpaces][0] : session.spaceId;
|
|
20716
20801
|
const abilities = {};
|
|
20717
20802
|
for (const entry of entries) {
|
|
20718
|
-
const shortService =
|
|
20803
|
+
const shortService = import_sdk_core6.SERVICE_LONG_TO_SHORT[entry.service];
|
|
20719
20804
|
if (shortService === void 0) {
|
|
20720
20805
|
throw new Error(
|
|
20721
20806
|
`delegateTo: unknown service '${entry.service}' \u2014 no short-form mapping`
|
|
@@ -20755,7 +20840,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
20755
20840
|
});
|
|
20756
20841
|
const primary = result.resources[0];
|
|
20757
20842
|
const delegationHeader = { Authorization: result.delegation };
|
|
20758
|
-
const activateResult = await (0,
|
|
20843
|
+
const activateResult = await (0, import_sdk_core6.activateSessionWithHost)(
|
|
20759
20844
|
this.config.host,
|
|
20760
20845
|
delegationHeader
|
|
20761
20846
|
);
|
|
@@ -20790,7 +20875,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
20790
20875
|
const primary = result.resources[0];
|
|
20791
20876
|
const delegationHeader = { Authorization: result.delegation };
|
|
20792
20877
|
const targetHost = grant.delegation.host ?? this.config.host;
|
|
20793
|
-
const activateResult = await (0,
|
|
20878
|
+
const activateResult = await (0, import_sdk_core6.activateSessionWithHost)(
|
|
20794
20879
|
targetHost,
|
|
20795
20880
|
delegationHeader
|
|
20796
20881
|
);
|
|
@@ -20831,10 +20916,10 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
20831
20916
|
return this.wasmBindings.makeSpaceId(session.address, session.chainId, space);
|
|
20832
20917
|
}
|
|
20833
20918
|
expandPermissionEntries(permissions) {
|
|
20834
|
-
return (0,
|
|
20919
|
+
return (0, import_sdk_core6.expandPermissionEntries)(permissions);
|
|
20835
20920
|
}
|
|
20836
20921
|
shortServiceName(service) {
|
|
20837
|
-
const short =
|
|
20922
|
+
const short = import_sdk_core6.SERVICE_LONG_TO_SHORT[service];
|
|
20838
20923
|
if (short === void 0) {
|
|
20839
20924
|
throw new Error(
|
|
20840
20925
|
`unknown service '${service}' \u2014 no short-form mapping`
|
|
@@ -20860,7 +20945,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
20860
20945
|
return abilities;
|
|
20861
20946
|
}
|
|
20862
20947
|
isEncryptionPermissionEntry(entry) {
|
|
20863
|
-
return entry.service ===
|
|
20948
|
+
return entry.service === import_sdk_core6.ENCRYPTION_PERMISSION_SERVICE && entry.path.startsWith("urn:tinycloud:encryption:");
|
|
20864
20949
|
}
|
|
20865
20950
|
permissionsToRawAbilities(entries) {
|
|
20866
20951
|
const rawAbilities = {};
|
|
@@ -20893,11 +20978,11 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
20893
20978
|
}
|
|
20894
20979
|
sessionCoversPermissionEntries(session, entries) {
|
|
20895
20980
|
try {
|
|
20896
|
-
const granted = (0,
|
|
20981
|
+
const granted = (0, import_sdk_core6.parseRecapCapabilities)(
|
|
20897
20982
|
(siwe) => this.wasmBindings.parseRecapFromSiwe(siwe),
|
|
20898
20983
|
session.siwe
|
|
20899
20984
|
);
|
|
20900
|
-
return (0,
|
|
20985
|
+
return (0, import_sdk_core6.isCapabilitySubset)(entries, granted).subset;
|
|
20901
20986
|
} catch {
|
|
20902
20987
|
return false;
|
|
20903
20988
|
}
|
|
@@ -21228,7 +21313,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
21228
21313
|
if (resolvedDelegateDID.endsWith(".eth") && this.config.ensResolver) {
|
|
21229
21314
|
const address = await this.config.ensResolver.resolveAddress(resolvedDelegateDID);
|
|
21230
21315
|
if (!address) throw new Error(`Could not resolve ENS name: ${resolvedDelegateDID}`);
|
|
21231
|
-
resolvedDelegateDID = (0,
|
|
21316
|
+
resolvedDelegateDID = (0, import_sdk_core6.pkhDid)(address, 1);
|
|
21232
21317
|
}
|
|
21233
21318
|
const entries = legacyParamsToPermissionEntries(
|
|
21234
21319
|
params.actions,
|
|
@@ -21243,7 +21328,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
21243
21328
|
);
|
|
21244
21329
|
return result.delegation;
|
|
21245
21330
|
} catch (err) {
|
|
21246
|
-
if (err instanceof
|
|
21331
|
+
if (err instanceof import_sdk_core6.PermissionNotInManifestError) {
|
|
21247
21332
|
} else {
|
|
21248
21333
|
throw err;
|
|
21249
21334
|
}
|
|
@@ -21300,7 +21385,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
21300
21385
|
...prepared,
|
|
21301
21386
|
signature: signature2
|
|
21302
21387
|
});
|
|
21303
|
-
const activateResult = await (0,
|
|
21388
|
+
const activateResult = await (0, import_sdk_core6.activateSessionWithHost)(
|
|
21304
21389
|
this.config.host,
|
|
21305
21390
|
delegationSession.delegationHeader
|
|
21306
21391
|
);
|
|
@@ -21322,7 +21407,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
21322
21407
|
};
|
|
21323
21408
|
const hasKvActions = params.actions.some((a) => a.startsWith("tinycloud.kv/"));
|
|
21324
21409
|
if (hasKvActions && params.includePublicSpace !== false) {
|
|
21325
|
-
const publicSpaceId = (0,
|
|
21410
|
+
const publicSpaceId = (0, import_sdk_core6.makePublicSpaceId)(
|
|
21326
21411
|
this.wasmBindings.ensureEip55(session.address),
|
|
21327
21412
|
session.chainId
|
|
21328
21413
|
);
|
|
@@ -21345,7 +21430,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
21345
21430
|
...publicPrepared,
|
|
21346
21431
|
signature: publicSignature
|
|
21347
21432
|
});
|
|
21348
|
-
const publicActivateResult = await (0,
|
|
21433
|
+
const publicActivateResult = await (0, import_sdk_core6.activateSessionWithHost)(
|
|
21349
21434
|
this.config.host,
|
|
21350
21435
|
publicSession.delegationHeader
|
|
21351
21436
|
);
|
|
@@ -21385,7 +21470,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
21385
21470
|
const targetHost = delegation.host ?? this.config.host;
|
|
21386
21471
|
if (this.isSessionOnly) {
|
|
21387
21472
|
const myDid = this.did;
|
|
21388
|
-
if (!
|
|
21473
|
+
if (!didPrincipalMatches2(delegation.delegateDID, myDid)) {
|
|
21389
21474
|
throw new Error(
|
|
21390
21475
|
`Delegation targets ${delegation.delegateDID} but this user's DID is ${myDid}. The delegation must target this user's DID.`
|
|
21391
21476
|
);
|
|
@@ -21450,7 +21535,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
21450
21535
|
...prepared,
|
|
21451
21536
|
signature: signature2
|
|
21452
21537
|
});
|
|
21453
|
-
const activateResult = await (0,
|
|
21538
|
+
const activateResult = await (0, import_sdk_core6.activateSessionWithHost)(
|
|
21454
21539
|
targetHost,
|
|
21455
21540
|
invokerSession.delegationHeader
|
|
21456
21541
|
);
|
|
@@ -21556,7 +21641,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
21556
21641
|
...prepared,
|
|
21557
21642
|
signature: signature2
|
|
21558
21643
|
});
|
|
21559
|
-
const activateResult = await (0,
|
|
21644
|
+
const activateResult = await (0, import_sdk_core6.activateSessionWithHost)(
|
|
21560
21645
|
targetHost,
|
|
21561
21646
|
subDelegationSession.delegationHeader
|
|
21562
21647
|
);
|
|
@@ -21598,11 +21683,11 @@ TinyCloudNode.registerNodeDefaults({
|
|
|
21598
21683
|
});
|
|
21599
21684
|
|
|
21600
21685
|
// src/index.ts
|
|
21601
|
-
var import_sdk_core7 = require("@tinycloud/sdk-core");
|
|
21602
21686
|
var import_sdk_core8 = require("@tinycloud/sdk-core");
|
|
21687
|
+
var import_sdk_core9 = require("@tinycloud/sdk-core");
|
|
21603
21688
|
|
|
21604
21689
|
// src/storage/FileSessionStorage.ts
|
|
21605
|
-
var
|
|
21690
|
+
var import_sdk_core7 = require("@tinycloud/sdk-core");
|
|
21606
21691
|
var import_fs = require("fs");
|
|
21607
21692
|
var import_path = require("path");
|
|
21608
21693
|
var FileSessionStorage = class {
|
|
@@ -21657,7 +21742,7 @@ var FileSessionStorage = class {
|
|
|
21657
21742
|
try {
|
|
21658
21743
|
const data = (0, import_fs.readFileSync)(filePath, "utf-8");
|
|
21659
21744
|
const parsed = JSON.parse(data);
|
|
21660
|
-
const validation = (0,
|
|
21745
|
+
const validation = (0, import_sdk_core7.validatePersistedSessionData)(parsed);
|
|
21661
21746
|
if (!validation.ok) {
|
|
21662
21747
|
console.warn(`Invalid session data for ${address}:`, validation.error.message);
|
|
21663
21748
|
(0, import_fs.unlinkSync)(filePath);
|
|
@@ -21722,7 +21807,7 @@ var FileSessionStorage = class {
|
|
|
21722
21807
|
};
|
|
21723
21808
|
|
|
21724
21809
|
// src/index.ts
|
|
21725
|
-
var
|
|
21810
|
+
var import_sdk_core10 = require("@tinycloud/sdk-core");
|
|
21726
21811
|
|
|
21727
21812
|
// src/delegation.ts
|
|
21728
21813
|
async function grantAuthRequest(authority, request, options) {
|
|
@@ -21767,7 +21852,6 @@ function deserializeDelegation(data) {
|
|
|
21767
21852
|
}
|
|
21768
21853
|
|
|
21769
21854
|
// src/index.ts
|
|
21770
|
-
var import_sdk_core10 = require("@tinycloud/sdk-core");
|
|
21771
21855
|
var import_sdk_core11 = require("@tinycloud/sdk-core");
|
|
21772
21856
|
var import_sdk_core12 = require("@tinycloud/sdk-core");
|
|
21773
21857
|
var import_sdk_core13 = require("@tinycloud/sdk-core");
|
|
@@ -21778,10 +21862,12 @@ var import_sdk_core17 = require("@tinycloud/sdk-core");
|
|
|
21778
21862
|
var import_sdk_core18 = require("@tinycloud/sdk-core");
|
|
21779
21863
|
var import_sdk_core19 = require("@tinycloud/sdk-core");
|
|
21780
21864
|
var import_sdk_core20 = require("@tinycloud/sdk-core");
|
|
21865
|
+
var import_sdk_core21 = require("@tinycloud/sdk-core");
|
|
21781
21866
|
// Annotate the CommonJS export names for ESM import in node:
|
|
21782
21867
|
0 && (module.exports = {
|
|
21783
21868
|
ACCOUNT_REGISTRY_PATH,
|
|
21784
21869
|
ACCOUNT_REGISTRY_SPACE,
|
|
21870
|
+
AccountService,
|
|
21785
21871
|
AutoApproveSpaceCreationHandler,
|
|
21786
21872
|
CapabilityKeyRegistry,
|
|
21787
21873
|
CapabilityKeyRegistryErrorCodes,
|