@tinycloud/node-sdk 2.4.0-beta.1 → 2.4.0-beta.3
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-Dbzm1kA_.d.cts → core-ClOKiSR_.d.cts} +67 -2
- package/dist/{core-Dbzm1kA_.d.ts → core-ClOKiSR_.d.ts} +67 -2
- package/dist/core.cjs +17 -1
- package/dist/core.cjs.map +1 -1
- package/dist/core.d.cts +1 -1
- package/dist/core.d.ts +1 -1
- package/dist/core.js +17 -1
- package/dist/core.js.map +1 -1
- package/dist/index.cjs +45 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +44 -1
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -17126,6 +17126,7 @@ __export(index_exports, {
|
|
|
17126
17126
|
expandPermissionEntries: () => import_sdk_core9.expandPermissionEntries,
|
|
17127
17127
|
expandPermissionEntry: () => import_sdk_core9.expandPermissionEntry,
|
|
17128
17128
|
generateRandomReceiverKey: () => import_sdk_core14.generateRandomReceiverKey,
|
|
17129
|
+
grantAuthRequest: () => grantAuthRequest,
|
|
17129
17130
|
hexDecode: () => import_sdk_core14.hexDecode,
|
|
17130
17131
|
hexEncode: () => import_sdk_core14.hexEncode,
|
|
17131
17132
|
isCapabilitySubset: () => import_sdk_core9.isCapabilitySubset,
|
|
@@ -21104,7 +21105,23 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
21104
21105
|
if (granted.resource !== void 0 || requested.resource !== void 0) {
|
|
21105
21106
|
return granted.resource !== void 0 && requested.resource !== void 0 && granted.resource === requested.resource && this.pathContains(granted.path, requested.path);
|
|
21106
21107
|
}
|
|
21107
|
-
return granted.spaceId !== void 0 && requested.spaceId !== void 0 && granted.spaceId
|
|
21108
|
+
return granted.spaceId !== void 0 && requested.spaceId !== void 0 && this.spaceIdsEqual(granted.spaceId, requested.spaceId) && this.pathContains(granted.path, requested.path);
|
|
21109
|
+
}
|
|
21110
|
+
// Space IDs are `tinycloud:pkh:eip155:<chain>:<0xADDR>:<name>`. The embedded
|
|
21111
|
+
// EIP-155 address is case-insensitive, but the CLI canonicalizes it to
|
|
21112
|
+
// lowercase when building a space URI while stored runtime delegations keep
|
|
21113
|
+
// the EIP-55 checksummed form — so a byte-for-byte compare spuriously rejects
|
|
21114
|
+
// an otherwise-valid grant. Lowercase ONLY the `eip155:<chain>:0x<addr>`
|
|
21115
|
+
// segment and leave everything else (crucially the case-sensitive space NAME)
|
|
21116
|
+
// byte-exact. Mirrors the CLI's `normalizeSpaceForCompare` (OPENKEY_SCOPE_MISMATCH fix).
|
|
21117
|
+
spaceIdsEqual(a, b) {
|
|
21118
|
+
return this.normalizeSpaceAddress(a) === this.normalizeSpaceAddress(b);
|
|
21119
|
+
}
|
|
21120
|
+
normalizeSpaceAddress(space) {
|
|
21121
|
+
return space.replace(
|
|
21122
|
+
/(eip155:\d+:)(0x[0-9a-fA-F]{40})/,
|
|
21123
|
+
(_match, prefix, addr) => prefix + addr.toLowerCase()
|
|
21124
|
+
);
|
|
21108
21125
|
}
|
|
21109
21126
|
actionContains(grantedAction, requestedAction) {
|
|
21110
21127
|
if (grantedAction === requestedAction) {
|
|
@@ -21708,6 +21725,32 @@ var FileSessionStorage = class {
|
|
|
21708
21725
|
var import_sdk_core9 = require("@tinycloud/sdk-core");
|
|
21709
21726
|
|
|
21710
21727
|
// src/delegation.ts
|
|
21728
|
+
async function grantAuthRequest(authority, request, options) {
|
|
21729
|
+
if (request.kind !== "tinycloud.auth.request") {
|
|
21730
|
+
throw new Error(
|
|
21731
|
+
`grantAuthRequest expects a tinycloud.auth.request artifact, got "${request.kind}".`
|
|
21732
|
+
);
|
|
21733
|
+
}
|
|
21734
|
+
if (!Array.isArray(request.requested) || request.requested.length === 0) {
|
|
21735
|
+
throw new Error("grantAuthRequest request has no requested capabilities.");
|
|
21736
|
+
}
|
|
21737
|
+
const expiry = options?.expiry ?? request.requestedExpiry;
|
|
21738
|
+
const result = await authority.delegateTo(
|
|
21739
|
+
request.sessionDid,
|
|
21740
|
+
request.requested,
|
|
21741
|
+
expiry !== void 0 ? { expiry } : void 0
|
|
21742
|
+
);
|
|
21743
|
+
return {
|
|
21744
|
+
kind: "tinycloud.auth.delegation",
|
|
21745
|
+
version: 1,
|
|
21746
|
+
requestId: request.requestId,
|
|
21747
|
+
delegationCid: result.delegation.cid,
|
|
21748
|
+
delegation: result.delegation,
|
|
21749
|
+
permissions: request.requested,
|
|
21750
|
+
expiry: result.delegation.expiry.toISOString(),
|
|
21751
|
+
prompted: result.prompted
|
|
21752
|
+
};
|
|
21753
|
+
}
|
|
21711
21754
|
function serializeDelegation(delegation) {
|
|
21712
21755
|
return JSON.stringify({
|
|
21713
21756
|
...delegation,
|
|
@@ -21838,6 +21881,7 @@ var import_sdk_core20 = require("@tinycloud/sdk-core");
|
|
|
21838
21881
|
expandPermissionEntries,
|
|
21839
21882
|
expandPermissionEntry,
|
|
21840
21883
|
generateRandomReceiverKey,
|
|
21884
|
+
grantAuthRequest,
|
|
21841
21885
|
hexDecode,
|
|
21842
21886
|
hexEncode,
|
|
21843
21887
|
isCapabilitySubset,
|