@tinycloud/cli 0.9.0-beta.7 → 0.9.0-beta.9
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/index.js +248 -41
- package/dist/index.js.map +1 -1
- package/dist/legacy-entry.js +372 -61
- package/dist/legacy-entry.js.map +1 -1
- package/package.json +3 -3
package/dist/legacy-entry.js
CHANGED
|
@@ -11764,16 +11764,16 @@ function ensureNetworkUsableForDecrypt(descriptor) {
|
|
|
11764
11764
|
})
|
|
11765
11765
|
};
|
|
11766
11766
|
}
|
|
11767
|
-
function encryptToNetwork(
|
|
11767
|
+
function encryptToNetwork(crypto22, input) {
|
|
11768
11768
|
parseNetworkId(input.networkId);
|
|
11769
11769
|
const alg = input.alg ?? DEFAULT_ENCRYPTION_ALG;
|
|
11770
11770
|
const keyVersion = input.keyVersion ?? DEFAULT_KEY_VERSION;
|
|
11771
|
-
const symmetricKey =
|
|
11772
|
-
const ciphertext =
|
|
11773
|
-
const wrapped =
|
|
11771
|
+
const symmetricKey = crypto22.randomBytes(32);
|
|
11772
|
+
const ciphertext = crypto22.authEncrypt(symmetricKey, input.plaintext, input.aad);
|
|
11773
|
+
const wrapped = crypto22.sealToNetworkKey(input.networkPublicKey, symmetricKey);
|
|
11774
11774
|
const encryptedSymmetricKey = base64Encode2(wrapped);
|
|
11775
11775
|
const encryptedSymmetricKeyHash = canonicalHashHex(
|
|
11776
|
-
|
|
11776
|
+
crypto22.sha256,
|
|
11777
11777
|
encryptedSymmetricKey
|
|
11778
11778
|
);
|
|
11779
11779
|
const envelope = {
|
|
@@ -11789,7 +11789,7 @@ function encryptToNetwork(crypto23, input) {
|
|
|
11789
11789
|
};
|
|
11790
11790
|
return { envelope, symmetricKey };
|
|
11791
11791
|
}
|
|
11792
|
-
function validateEnvelope(
|
|
11792
|
+
function validateEnvelope(crypto22, envelope) {
|
|
11793
11793
|
if (envelope === null || typeof envelope !== "object") {
|
|
11794
11794
|
return {
|
|
11795
11795
|
ok: false,
|
|
@@ -11845,7 +11845,7 @@ function validateEnvelope(crypto23, envelope) {
|
|
|
11845
11845
|
})
|
|
11846
11846
|
};
|
|
11847
11847
|
}
|
|
11848
|
-
const expectedHash = canonicalHashHex(
|
|
11848
|
+
const expectedHash = canonicalHashHex(crypto22.sha256, e.encryptedSymmetricKey);
|
|
11849
11849
|
if (expectedHash !== e.encryptedSymmetricKeyHash) {
|
|
11850
11850
|
return {
|
|
11851
11851
|
ok: false,
|
|
@@ -11857,10 +11857,10 @@ function validateEnvelope(crypto23, envelope) {
|
|
|
11857
11857
|
}
|
|
11858
11858
|
return { ok: true, data: e };
|
|
11859
11859
|
}
|
|
11860
|
-
function decryptEnvelopeWithKey(
|
|
11860
|
+
function decryptEnvelopeWithKey(crypto22, envelope, symmetricKey) {
|
|
11861
11861
|
const ciphertext = base64Decode2(envelope.ciphertext);
|
|
11862
11862
|
const aad = envelope.aad !== void 0 ? base64Decode2(envelope.aad) : void 0;
|
|
11863
|
-
return
|
|
11863
|
+
return crypto22.authDecrypt(symmetricKey, ciphertext, aad);
|
|
11864
11864
|
}
|
|
11865
11865
|
function buildCanonicalDecryptRequest(input) {
|
|
11866
11866
|
const canonicalBody = canonicalize(input.body);
|
|
@@ -11894,7 +11894,7 @@ function buildDecryptFacts(input) {
|
|
|
11894
11894
|
keyVersion: input.body.keyVersion
|
|
11895
11895
|
};
|
|
11896
11896
|
}
|
|
11897
|
-
function checkDecryptInvocationInput(
|
|
11897
|
+
function checkDecryptInvocationInput(crypto22, input) {
|
|
11898
11898
|
if (input.body.type !== DECRYPT_FACT_TYPE) {
|
|
11899
11899
|
return {
|
|
11900
11900
|
ok: false,
|
|
@@ -11999,7 +11999,7 @@ function checkDecryptInvocationInput(crypto23, input) {
|
|
|
11999
11999
|
const canonicalBody = canonicalize(
|
|
12000
12000
|
input.body
|
|
12001
12001
|
);
|
|
12002
|
-
const expectedBodyHash = canonicalHashHex(
|
|
12002
|
+
const expectedBodyHash = canonicalHashHex(crypto22.sha256, input.body);
|
|
12003
12003
|
if (expectedBodyHash !== input.facts.bodyHash) {
|
|
12004
12004
|
return {
|
|
12005
12005
|
ok: false,
|
|
@@ -12011,8 +12011,8 @@ function checkDecryptInvocationInput(crypto23, input) {
|
|
|
12011
12011
|
}
|
|
12012
12012
|
return { ok: true, data: input, canonicalBody };
|
|
12013
12013
|
}
|
|
12014
|
-
async function buildDecryptInvocation(
|
|
12015
|
-
const checked = checkDecryptInvocationInput(
|
|
12014
|
+
async function buildDecryptInvocation(crypto22, signer, input) {
|
|
12015
|
+
const checked = checkDecryptInvocationInput(crypto22, input);
|
|
12016
12016
|
if (!checked.ok) {
|
|
12017
12017
|
return checked;
|
|
12018
12018
|
}
|
|
@@ -12057,7 +12057,7 @@ function canonicalSignedResponse(response) {
|
|
|
12057
12057
|
return canonicalize(rest);
|
|
12058
12058
|
}
|
|
12059
12059
|
function verifyDecryptResponse(input) {
|
|
12060
|
-
const { crypto:
|
|
12060
|
+
const { crypto: crypto22, request, facts, invocationCid, requestBodyHash, response } = input;
|
|
12061
12061
|
if (response.type !== DECRYPT_RESULT_TYPE) {
|
|
12062
12062
|
return {
|
|
12063
12063
|
ok: false,
|
|
@@ -12140,7 +12140,7 @@ function verifyDecryptResponse(input) {
|
|
|
12140
12140
|
};
|
|
12141
12141
|
}
|
|
12142
12142
|
const expectedRequestHash = hexEncode2(
|
|
12143
|
-
|
|
12143
|
+
crypto22.sha256(utf8Encode(`${invocationCid}${requestBodyHash}`))
|
|
12144
12144
|
);
|
|
12145
12145
|
if (response.requestHash !== expectedRequestHash) {
|
|
12146
12146
|
return {
|
|
@@ -12164,7 +12164,7 @@ function verifyDecryptResponse(input) {
|
|
|
12164
12164
|
canonicalSignedResponse(response)
|
|
12165
12165
|
);
|
|
12166
12166
|
const signatureBytes = base64Decode2(response.nodeSignature);
|
|
12167
|
-
if (!
|
|
12167
|
+
if (!crypto22.verifyNodeSignature(response.nodeId, signedBytes, signatureBytes)) {
|
|
12168
12168
|
return {
|
|
12169
12169
|
ok: false,
|
|
12170
12170
|
error: encryptionError({
|
|
@@ -12174,9 +12174,9 @@ function verifyDecryptResponse(input) {
|
|
|
12174
12174
|
}
|
|
12175
12175
|
return { ok: true, data: response };
|
|
12176
12176
|
}
|
|
12177
|
-
function openWrappedKey(
|
|
12177
|
+
function openWrappedKey(crypto22, receiverPrivateKey, response) {
|
|
12178
12178
|
const wrapped = base64Decode2(response.wrappedKey);
|
|
12179
|
-
return
|
|
12179
|
+
return crypto22.openWithReceiverKey(receiverPrivateKey, wrapped);
|
|
12180
12180
|
}
|
|
12181
12181
|
function encOk(data) {
|
|
12182
12182
|
return { ok: true, data };
|
|
@@ -23956,12 +23956,6 @@ var init_dist3 = __esm({
|
|
|
23956
23956
|
|
|
23957
23957
|
// ../sdk-core/dist/index.js
|
|
23958
23958
|
import { SiweMessage } from "siwe";
|
|
23959
|
-
import crypto22 from "crypto";
|
|
23960
|
-
import { Buffer as Buffer2 } from "buffer";
|
|
23961
|
-
import { Buffer as Buffer3 } from "buffer";
|
|
23962
|
-
import { Buffer as Buffer4 } from "buffer";
|
|
23963
|
-
import { Buffer as Buffer5 } from "buffer";
|
|
23964
|
-
import { isIPv4, isIPv6, isIP as ipVersion } from "net";
|
|
23965
23959
|
function equals5(aa, bb) {
|
|
23966
23960
|
if (aa === bb) {
|
|
23967
23961
|
return true;
|
|
@@ -24406,6 +24400,9 @@ function createDigest(digest4, code3, truncate) {
|
|
|
24406
24400
|
}
|
|
24407
24401
|
return create3(code3, digest4);
|
|
24408
24402
|
}
|
|
24403
|
+
function sha(name2) {
|
|
24404
|
+
return async (data) => new Uint8Array(await crypto.subtle.digest(name2, data));
|
|
24405
|
+
}
|
|
24409
24406
|
function parseStrictRfc33392(value) {
|
|
24410
24407
|
if (!/^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2})(\.\d+)?(Z|[+-]\d{2}:\d{2})$/.test(
|
|
24411
24408
|
value
|
|
@@ -24465,11 +24462,8 @@ function equals32(a, b) {
|
|
|
24465
24462
|
}
|
|
24466
24463
|
return true;
|
|
24467
24464
|
}
|
|
24468
|
-
function asUint8Array(buf) {
|
|
24469
|
-
return new Uint8Array(buf.buffer, buf.byteOffset, buf.byteLength);
|
|
24470
|
-
}
|
|
24471
24465
|
function allocUnsafe(size2 = 0) {
|
|
24472
|
-
return
|
|
24466
|
+
return new Uint8Array(size2);
|
|
24473
24467
|
}
|
|
24474
24468
|
function encodingLength22(value) {
|
|
24475
24469
|
if (value < N122) {
|
|
@@ -24633,8 +24627,20 @@ function decode62(buf, offset = 0) {
|
|
|
24633
24627
|
return decodeUint8ArrayList(buf, offset);
|
|
24634
24628
|
}
|
|
24635
24629
|
}
|
|
24630
|
+
function asUint8Array(buf) {
|
|
24631
|
+
return buf;
|
|
24632
|
+
}
|
|
24636
24633
|
function concat2(arrays, length22) {
|
|
24637
|
-
|
|
24634
|
+
if (length22 == null) {
|
|
24635
|
+
length22 = arrays.reduce((acc, curr) => acc + curr.length, 0);
|
|
24636
|
+
}
|
|
24637
|
+
const output = allocUnsafe(length22);
|
|
24638
|
+
let offset = 0;
|
|
24639
|
+
for (const arr of arrays) {
|
|
24640
|
+
output.set(arr, offset);
|
|
24641
|
+
offset += arr.length;
|
|
24642
|
+
}
|
|
24643
|
+
return asUint8Array(output);
|
|
24638
24644
|
}
|
|
24639
24645
|
function createCodec(name2, prefix, encode52, decode72) {
|
|
24640
24646
|
return {
|
|
@@ -24655,9 +24661,6 @@ function fromString2(string2, encoding = "utf8") {
|
|
|
24655
24661
|
if (base33 == null) {
|
|
24656
24662
|
throw new Error(`Unsupported encoding "${encoding}"`);
|
|
24657
24663
|
}
|
|
24658
|
-
if (encoding === "utf8" || encoding === "utf-8") {
|
|
24659
|
-
return asUint8Array(Buffer4.from(string2, "utf-8"));
|
|
24660
|
-
}
|
|
24661
24664
|
return base33.decoder.decode(`${base33.prefix}${string2}`);
|
|
24662
24665
|
}
|
|
24663
24666
|
function toString2(array, encoding = "utf8") {
|
|
@@ -24665,11 +24668,29 @@ function toString2(array, encoding = "utf8") {
|
|
|
24665
24668
|
if (base33 == null) {
|
|
24666
24669
|
throw new Error(`Unsupported encoding "${encoding}"`);
|
|
24667
24670
|
}
|
|
24668
|
-
if (encoding === "utf8" || encoding === "utf-8") {
|
|
24669
|
-
return Buffer5.from(array.buffer, array.byteOffset, array.byteLength).toString("utf8");
|
|
24670
|
-
}
|
|
24671
24671
|
return base33.encoder.encode(array).substring(1);
|
|
24672
24672
|
}
|
|
24673
|
+
function parseIPv4(input) {
|
|
24674
|
+
if (input.length > MAX_IPV4_LENGTH) {
|
|
24675
|
+
return void 0;
|
|
24676
|
+
}
|
|
24677
|
+
return parser.new(input).parseWith(() => parser.readIPv4Addr());
|
|
24678
|
+
}
|
|
24679
|
+
function parseIPv6(input) {
|
|
24680
|
+
if (input.includes("%")) {
|
|
24681
|
+
input = input.split("%")[0];
|
|
24682
|
+
}
|
|
24683
|
+
if (input.length > MAX_IPV6_LENGTH) {
|
|
24684
|
+
return void 0;
|
|
24685
|
+
}
|
|
24686
|
+
return parser.new(input).parseWith(() => parser.readIPv6Addr());
|
|
24687
|
+
}
|
|
24688
|
+
function isIPv4(input) {
|
|
24689
|
+
return Boolean(parseIPv4(input));
|
|
24690
|
+
}
|
|
24691
|
+
function isIPv6(input) {
|
|
24692
|
+
return Boolean(parseIPv6(input));
|
|
24693
|
+
}
|
|
24673
24694
|
function bytesToString(base33) {
|
|
24674
24695
|
return (buf) => {
|
|
24675
24696
|
return toString2(buf, base33);
|
|
@@ -25365,7 +25386,7 @@ function decodeBase64Url(value) {
|
|
|
25365
25386
|
}
|
|
25366
25387
|
return Uint8Array.from(bytes2);
|
|
25367
25388
|
}
|
|
25368
|
-
var import_ms, __defProp3, __typeError, __defNormalProp, __export3, __publicField, __accessCheck, __privateGet, __privateAdd, __privateSet, EnsDataSchema, SiweConfigSchema, ClientSessionSchema, base32_exports, empty3, src3, _brrp__multiformats_scope_baseX3, base_x_default3, Encoder3, Decoder3, ComposedDecoder3, Codec3, base323, base32upper3, base32pad3, base32padupper3, base32hex3, base32hexupper3, base32hexpad3, base32hexpadupper3, base32z3, base36_exports, base363, base36upper3, base58_exports, base58btc3, base58flickr3, encode_13, MSB3, REST3, MSBALL3, INT3, decode22, MSB$13, REST$13, N13, N23, N33, N43, N53, N63, N73, N83, N93, length3, varint3, _brrp_varint3, varint_default3, Digest3, cache3, _a, CID3, DAG_PB_CODE3, SHA_256_CODE3, cidSymbol3, objectHasOwn, textEncoder, objectHasOwn2, CEILING_SERVICES, GRANTABLE_ACTIONS, base10_exports, base10, base16_exports, base16, base16upper, base2_exports, base22, base256emoji_exports, alphabet, alphabetBytesToChars, alphabetCharsToBytes, base256emoji, base64_exports, base642, base64pad2, base64url2, base64urlpad2, base8_exports, base8, identity_exports, identity, textEncoder2, textDecoder, identity_exports2, code2, name, encode42, identity2,
|
|
25389
|
+
var import_ms, __defProp3, __typeError, __defNormalProp, __export3, __publicField, __accessCheck, __privateGet, __privateAdd, __privateSet, EnsDataSchema, SiweConfigSchema, ClientSessionSchema, base32_exports, empty3, src3, _brrp__multiformats_scope_baseX3, base_x_default3, Encoder3, Decoder3, ComposedDecoder3, Codec3, base323, base32upper3, base32pad3, base32padupper3, base32hex3, base32hexupper3, base32hexpad3, base32hexpadupper3, base32z3, base36_exports, base363, base36upper3, base58_exports, base58btc3, base58flickr3, encode_13, MSB3, REST3, MSBALL3, INT3, decode22, MSB$13, REST$13, N13, N23, N33, N43, N53, N63, N73, N83, N93, length3, varint3, _brrp_varint3, varint_default3, Digest3, cache3, _a, CID3, DAG_PB_CODE3, SHA_256_CODE3, cidSymbol3, objectHasOwn, textEncoder, objectHasOwn2, CEILING_SERVICES, GRANTABLE_ACTIONS, base10_exports, base10, base16_exports, base16, base16upper, base2_exports, base22, base256emoji_exports, alphabet, alphabetBytesToChars, alphabetCharsToBytes, base256emoji, base64_exports, base642, base64pad2, base64url2, base64urlpad2, base8_exports, base8, identity_exports, identity, textEncoder2, textDecoder, identity_exports2, code2, name, encode42, identity2, sha2_browser_exports, DEFAULT_MIN_DIGEST_LENGTH, Hasher, sha2562, sha5122, bases, hashes, textEncoder3, objectHasOwn3, TRANSCRIPT_SHARE_BOOTSTRAP_SCHEMA, OWNER_NODE_ENDPOINT_SCHEMA, W3C_VC_CREDENTIAL_VERIFIER, objectHasOwn4, POLICY_ENGINE_CHALLENGE_RESPONSE_SCHEMA, POLICY_ENGINE_DENIAL_SCHEMA, POLICY_ENGINE_GRANT_PRESENTATION_DENIAL_CODES, JsonValueSchema, Rfc3339Schema, SignedRecordSchema, PolicyEngineSchema, OwnerNodeSchema, ResourceHintSchema, BootstrapSchema, SignatureSchema, ChallengeSchema, ChallengeResponseSchema, DenialSchema, ErrorEnvelopeDenialSchema, WireDelegationSchema, ResolveResponseSchema, DelegateReceiptSchema, SqlReadResponseSchema, KvReadResponseSchema, LISTEN_SQL_STATEMENT_CATALOG, LISTEN_SQL_STATEMENT_BY_NAME, JWKSchema, KeyTypeSchema, KeyInfoSchema, DelegationErrorSchema, DelegationSchema, DelegationStatusSchema, DelegationRevocationReceiptSchema, AccountDelegationResourceSchema, AccountDelegationDateSchema, AccountDelegationRecordSchema, AccountDelegationPageSchema, AccountDelegationQueryOptionsSchema, CapabilityEntrySchema, DelegationRecordSchema, CreateDelegationParamsSchema, DelegationChainSchema, DelegationChainV2Schema, DelegationDirectionSchema, DelegationFiltersSchema, SpaceOwnershipSchema, SpaceInfoSchema, ShareSchemaSchema, ShareLinkSchema, ShareLinkDataSchema, IngestOptionsSchema, GenerateShareParamsSchema, DelegationManagerConfigSchema, KeyProviderSchema, DelegationApiResponseSchema, DelegatedResourceSchema, CreateDelegationWasmParamsSchema, CreateDelegationWasmResultSchema, EPHEMERAL_MS, SIGNED_READ_URL_MS, SESSION_MS, SHARE_MS, APP_MS, MAX_MS, EXPIRY, DEFAULT_SIGNED_READ_URL_EXPIRY_MS2, EncodedShareDataSchema, ReceiveOptionsSchema, SharingServiceConfigSchema, DEFAULT_KNOWLEDGE_ROOT, ManifestValidationError, SERVICE_SHORT_TO_LONG, SERVICE_LONG_TO_SHORT, DEFAULT_MAX_INLINE_BYTES, MAX_SHARE_CONTENT_BYTES, MAX_SEALED_SHARE_CONTENT_BYTES, MAX_SHARE_ARTIFACT_BYTES, PUBLISHED_AAD, ShareRecipientTargetSchema, ShareResourceSchema, ShareActionSchema, ShareRecipientPolicySchema, ShareRecipientClientOptionsSchema, ShareNativeActionSchema, ShareWireActionSchema, ShareContentSourceSchema, ShareAddressedRecipientSchema, ShareAddressedDelegationRequestV2Schema, ShareAddressedDelegationEnvelopeV2Schema, ShareAddressedDelegationResponseV2Schema, ShareNativeResponseEntrySchema, ShareNativeResponseBase, ShareNativeResponseSchema, MAX_NATIVE_CURSOR_BYTES, DEFAULT_EXPIRY_MS2, MAX_CONTENT_BYTES2, ethereumAddressPattern, EnsDataSchema2, PersistedTinyCloudSessionSchema, PersistedSessionDataSchema, TinyCloudSessionSchema, SpaceConfigSchema, SpaceServiceConfigSchema, SpaceDelegationParamsSchema, ServerDelegationInfoSchema, ServerDelegationsResponseSchema, ServerOwnedSpaceSchema, ServerOwnedSpacesResponseSchema, ServerCreateSpaceResponseSchema, ServerSpaceInfoResponseSchema, AutoApproveSpaceCreationHandler, defaultSpaceCreationHandler, N122, N222, N322, N422, N522, N622, N722, MSB22, REST22, string, ascii, BASES, bases_default, InvalidMultiaddrError, ValidationError, InvalidParametersError, UnknownProtocolError, Parser, MAX_IPV6_LENGTH, MAX_IPV4_LENGTH, parser, CODE_IP4, CODE_TCP, CODE_UDP, CODE_DCCP, CODE_IP6, CODE_IP6ZONE, CODE_IPCIDR, CODE_DNS, CODE_DNS4, CODE_DNS6, CODE_DNSADDR, CODE_SCTP, CODE_UDT, CODE_UTP, CODE_UNIX, CODE_P2P, CODE_ONION, CODE_ONION3, CODE_GARLIC64, CODE_GARLIC32, CODE_TLS, CODE_SNI, CODE_NOISE, CODE_QUIC, CODE_QUIC_V1, CODE_WEBTRANSPORT, CODE_CERTHASH, CODE_HTTP, CODE_HTTP_PATH, CODE_HTTPS, CODE_WS, CODE_WSS, CODE_P2P_WEBSOCKET_STAR, CODE_P2P_STARDUST, CODE_P2P_WEBRTC_STAR, CODE_P2P_WEBRTC_DIRECT, CODE_WEBRTC_DIRECT, CODE_WEBRTC, CODE_P2P_CIRCUIT, CODE_MEMORY, ip4ToBytes, ip6ToBytes, ip4ToString, ip6ToString, decoders, anybaseDecoder, validatePort, V, Registry, registry, codecs, inspect, symbol, _a2, _components, _string, _bytes, _Multiaddr, Multiaddr, ASSUME_HTTP_CODES, interpreters, word, boundry, v4, v6segment, v6, v46Exact, v4exact, v6exact, ipRegex, toString3, DEFAULT_TINYCLOUD_LOCATION_REGISTRY_URL, LOCAL_LOOPBACK_PROBE_TIMEOUT_MS, LOCAL_LINK_PROBE_TIMEOUT_MS, LOCAL_LINK_HOST_SUFFIX, LocationRecordValidationError, defaultLocalNodeIdentityStore, DNS_LABEL_REGEX;
|
|
25369
25390
|
var init_dist4 = __esm({
|
|
25370
25391
|
"../sdk-core/dist/index.js"() {
|
|
25371
25392
|
"use strict";
|
|
@@ -26049,8 +26070,8 @@ var init_dist4 = __esm({
|
|
|
26049
26070
|
name = "identity";
|
|
26050
26071
|
encode42 = coerce4;
|
|
26051
26072
|
identity2 = { code: code2, name, encode: encode42, digest };
|
|
26052
|
-
|
|
26053
|
-
__export3(
|
|
26073
|
+
sha2_browser_exports = {};
|
|
26074
|
+
__export3(sha2_browser_exports, {
|
|
26054
26075
|
sha256: () => sha2562,
|
|
26055
26076
|
sha512: () => sha5122
|
|
26056
26077
|
});
|
|
@@ -26091,15 +26112,15 @@ var init_dist4 = __esm({
|
|
|
26091
26112
|
sha2562 = from22({
|
|
26092
26113
|
name: "sha2-256",
|
|
26093
26114
|
code: 18,
|
|
26094
|
-
encode: (
|
|
26115
|
+
encode: sha("SHA-256")
|
|
26095
26116
|
});
|
|
26096
26117
|
sha5122 = from22({
|
|
26097
26118
|
name: "sha2-512",
|
|
26098
26119
|
code: 19,
|
|
26099
|
-
encode: (
|
|
26120
|
+
encode: sha("SHA-512")
|
|
26100
26121
|
});
|
|
26101
26122
|
bases = { ...identity_exports, ...base2_exports, ...base8_exports, ...base10_exports, ...base16_exports, ...base32_exports, ...base36_exports, ...base58_exports, ...base64_exports, ...base256emoji_exports };
|
|
26102
|
-
hashes = { ...
|
|
26123
|
+
hashes = { ...sha2_browser_exports, ...identity_exports2 };
|
|
26103
26124
|
textEncoder3 = new TextEncoder();
|
|
26104
26125
|
objectHasOwn3 = Object.hasOwn ?? Object.prototype.hasOwnProperty.call.bind(
|
|
26105
26126
|
Object.prototype.hasOwnProperty
|
|
@@ -27214,6 +27235,192 @@ var init_dist4 = __esm({
|
|
|
27214
27235
|
}
|
|
27215
27236
|
};
|
|
27216
27237
|
__publicField(UnknownProtocolError, "name", "UnknownProtocolError");
|
|
27238
|
+
Parser = class {
|
|
27239
|
+
constructor() {
|
|
27240
|
+
__publicField(this, "index", 0);
|
|
27241
|
+
__publicField(this, "input", "");
|
|
27242
|
+
}
|
|
27243
|
+
new(input) {
|
|
27244
|
+
this.index = 0;
|
|
27245
|
+
this.input = input;
|
|
27246
|
+
return this;
|
|
27247
|
+
}
|
|
27248
|
+
/** Run a parser, and restore the pre-parse state if it fails. */
|
|
27249
|
+
readAtomically(fn) {
|
|
27250
|
+
const index = this.index;
|
|
27251
|
+
const result = fn();
|
|
27252
|
+
if (result === void 0) {
|
|
27253
|
+
this.index = index;
|
|
27254
|
+
}
|
|
27255
|
+
return result;
|
|
27256
|
+
}
|
|
27257
|
+
/** Run a parser, but fail if the entire input wasn't consumed. Doesn't run atomically. */
|
|
27258
|
+
parseWith(fn) {
|
|
27259
|
+
const result = fn();
|
|
27260
|
+
if (this.index !== this.input.length) {
|
|
27261
|
+
return void 0;
|
|
27262
|
+
}
|
|
27263
|
+
return result;
|
|
27264
|
+
}
|
|
27265
|
+
/** Peek the next character from the input */
|
|
27266
|
+
peekChar() {
|
|
27267
|
+
if (this.index >= this.input.length) {
|
|
27268
|
+
return void 0;
|
|
27269
|
+
}
|
|
27270
|
+
return this.input[this.index];
|
|
27271
|
+
}
|
|
27272
|
+
/** Read the next character from the input */
|
|
27273
|
+
readChar() {
|
|
27274
|
+
if (this.index >= this.input.length) {
|
|
27275
|
+
return void 0;
|
|
27276
|
+
}
|
|
27277
|
+
return this.input[this.index++];
|
|
27278
|
+
}
|
|
27279
|
+
/** Read the next character from the input if it matches the target. */
|
|
27280
|
+
readGivenChar(target) {
|
|
27281
|
+
return this.readAtomically(() => {
|
|
27282
|
+
const char = this.readChar();
|
|
27283
|
+
if (char !== target) {
|
|
27284
|
+
return void 0;
|
|
27285
|
+
}
|
|
27286
|
+
return char;
|
|
27287
|
+
});
|
|
27288
|
+
}
|
|
27289
|
+
/**
|
|
27290
|
+
* Helper for reading separators in an indexed loop. Reads the separator
|
|
27291
|
+
* character iff index > 0, then runs the parser. When used in a loop,
|
|
27292
|
+
* the separator character will only be read on index > 0 (see
|
|
27293
|
+
* readIPv4Addr for an example)
|
|
27294
|
+
*/
|
|
27295
|
+
readSeparator(sep2, index, inner) {
|
|
27296
|
+
return this.readAtomically(() => {
|
|
27297
|
+
if (index > 0) {
|
|
27298
|
+
if (this.readGivenChar(sep2) === void 0) {
|
|
27299
|
+
return void 0;
|
|
27300
|
+
}
|
|
27301
|
+
}
|
|
27302
|
+
return inner();
|
|
27303
|
+
});
|
|
27304
|
+
}
|
|
27305
|
+
/**
|
|
27306
|
+
* Read a number off the front of the input in the given radix, stopping
|
|
27307
|
+
* at the first non-digit character or eof. Fails if the number has more
|
|
27308
|
+
* digits than max_digits or if there is no number.
|
|
27309
|
+
*/
|
|
27310
|
+
readNumber(radix, maxDigits, allowZeroPrefix, maxBytes) {
|
|
27311
|
+
return this.readAtomically(() => {
|
|
27312
|
+
let result = 0;
|
|
27313
|
+
let digitCount = 0;
|
|
27314
|
+
const leadingChar = this.peekChar();
|
|
27315
|
+
if (leadingChar === void 0) {
|
|
27316
|
+
return void 0;
|
|
27317
|
+
}
|
|
27318
|
+
const hasLeadingZero = leadingChar === "0";
|
|
27319
|
+
const maxValue2 = 2 ** (8 * maxBytes) - 1;
|
|
27320
|
+
while (true) {
|
|
27321
|
+
const digit = this.readAtomically(() => {
|
|
27322
|
+
const char = this.readChar();
|
|
27323
|
+
if (char === void 0) {
|
|
27324
|
+
return void 0;
|
|
27325
|
+
}
|
|
27326
|
+
const num2 = Number.parseInt(char, radix);
|
|
27327
|
+
if (Number.isNaN(num2)) {
|
|
27328
|
+
return void 0;
|
|
27329
|
+
}
|
|
27330
|
+
return num2;
|
|
27331
|
+
});
|
|
27332
|
+
if (digit === void 0) {
|
|
27333
|
+
break;
|
|
27334
|
+
}
|
|
27335
|
+
result *= radix;
|
|
27336
|
+
result += digit;
|
|
27337
|
+
if (result > maxValue2) {
|
|
27338
|
+
return void 0;
|
|
27339
|
+
}
|
|
27340
|
+
digitCount += 1;
|
|
27341
|
+
if (maxDigits !== void 0) {
|
|
27342
|
+
if (digitCount > maxDigits) {
|
|
27343
|
+
return void 0;
|
|
27344
|
+
}
|
|
27345
|
+
}
|
|
27346
|
+
}
|
|
27347
|
+
if (digitCount === 0) {
|
|
27348
|
+
return void 0;
|
|
27349
|
+
} else if (!allowZeroPrefix && hasLeadingZero && digitCount > 1) {
|
|
27350
|
+
return void 0;
|
|
27351
|
+
} else {
|
|
27352
|
+
return result;
|
|
27353
|
+
}
|
|
27354
|
+
});
|
|
27355
|
+
}
|
|
27356
|
+
/** Read an IPv4 address. */
|
|
27357
|
+
readIPv4Addr() {
|
|
27358
|
+
return this.readAtomically(() => {
|
|
27359
|
+
const out = new Uint8Array(4);
|
|
27360
|
+
for (let i = 0; i < out.length; i++) {
|
|
27361
|
+
const ix = this.readSeparator(".", i, () => this.readNumber(10, 3, false, 1));
|
|
27362
|
+
if (ix === void 0) {
|
|
27363
|
+
return void 0;
|
|
27364
|
+
}
|
|
27365
|
+
out[i] = ix;
|
|
27366
|
+
}
|
|
27367
|
+
return out;
|
|
27368
|
+
});
|
|
27369
|
+
}
|
|
27370
|
+
/** Read an IPv6 Address. */
|
|
27371
|
+
readIPv6Addr() {
|
|
27372
|
+
const readGroups = (groups) => {
|
|
27373
|
+
for (let i = 0; i < groups.length / 2; i++) {
|
|
27374
|
+
const ix = i * 2;
|
|
27375
|
+
if (i < groups.length - 3) {
|
|
27376
|
+
const ipv4 = this.readSeparator(":", i, () => this.readIPv4Addr());
|
|
27377
|
+
if (ipv4 !== void 0) {
|
|
27378
|
+
groups[ix] = ipv4[0];
|
|
27379
|
+
groups[ix + 1] = ipv4[1];
|
|
27380
|
+
groups[ix + 2] = ipv4[2];
|
|
27381
|
+
groups[ix + 3] = ipv4[3];
|
|
27382
|
+
return [ix + 4, true];
|
|
27383
|
+
}
|
|
27384
|
+
}
|
|
27385
|
+
const group = this.readSeparator(":", i, () => this.readNumber(16, 4, true, 2));
|
|
27386
|
+
if (group === void 0) {
|
|
27387
|
+
return [ix, false];
|
|
27388
|
+
}
|
|
27389
|
+
groups[ix] = group >> 8;
|
|
27390
|
+
groups[ix + 1] = group & 255;
|
|
27391
|
+
}
|
|
27392
|
+
return [groups.length, false];
|
|
27393
|
+
};
|
|
27394
|
+
return this.readAtomically(() => {
|
|
27395
|
+
const head = new Uint8Array(16);
|
|
27396
|
+
const [headSize, headIp4] = readGroups(head);
|
|
27397
|
+
if (headSize === 16) {
|
|
27398
|
+
return head;
|
|
27399
|
+
}
|
|
27400
|
+
if (headIp4) {
|
|
27401
|
+
return void 0;
|
|
27402
|
+
}
|
|
27403
|
+
if (this.readGivenChar(":") === void 0) {
|
|
27404
|
+
return void 0;
|
|
27405
|
+
}
|
|
27406
|
+
if (this.readGivenChar(":") === void 0) {
|
|
27407
|
+
return void 0;
|
|
27408
|
+
}
|
|
27409
|
+
const tail = new Uint8Array(14);
|
|
27410
|
+
const limit = 16 - (headSize + 2);
|
|
27411
|
+
const [tailSize] = readGroups(tail.subarray(0, limit));
|
|
27412
|
+
head.set(tail.subarray(0, tailSize), 16 - tailSize);
|
|
27413
|
+
return head;
|
|
27414
|
+
});
|
|
27415
|
+
}
|
|
27416
|
+
/** Read an IP Address, either IPv4 or IPv6. */
|
|
27417
|
+
readIPAddr() {
|
|
27418
|
+
return this.readIPv4Addr() ?? this.readIPv6Addr();
|
|
27419
|
+
}
|
|
27420
|
+
};
|
|
27421
|
+
MAX_IPV6_LENGTH = 45;
|
|
27422
|
+
MAX_IPV4_LENGTH = 15;
|
|
27423
|
+
parser = new Parser();
|
|
27217
27424
|
CODE_IP4 = 4;
|
|
27218
27425
|
CODE_TCP = 6;
|
|
27219
27426
|
CODE_UDP = 273;
|
|
@@ -29772,9 +29979,52 @@ function buildAuthUrl(did, options = {}) {
|
|
|
29772
29979
|
if (options.expiry !== void 0) {
|
|
29773
29980
|
params.set("expiry", String(options.expiry));
|
|
29774
29981
|
}
|
|
29982
|
+
params.set("protocolVersion", "1");
|
|
29775
29983
|
const base4 = options.openkeyHost ?? DEFAULT_OPENKEY_HOST;
|
|
29776
29984
|
return `${base4}/delegate?${params.toString()}`;
|
|
29777
29985
|
}
|
|
29986
|
+
function validateDelegationCallbackPayload(value) {
|
|
29987
|
+
if (!value || typeof value !== "object") return "expected an object";
|
|
29988
|
+
const v = value;
|
|
29989
|
+
if (!v.delegationHeader || typeof v.delegationHeader !== "object") {
|
|
29990
|
+
return "delegationHeader must be an object";
|
|
29991
|
+
}
|
|
29992
|
+
const auth = v.delegationHeader.Authorization;
|
|
29993
|
+
if (typeof auth !== "string" || !auth) {
|
|
29994
|
+
return "delegationHeader.Authorization must be a non-empty string";
|
|
29995
|
+
}
|
|
29996
|
+
if (typeof v.delegationCid !== "string" || !v.delegationCid) {
|
|
29997
|
+
return "delegationCid must be a non-empty string";
|
|
29998
|
+
}
|
|
29999
|
+
if (typeof v.spaceId !== "string" || !v.spaceId) {
|
|
30000
|
+
return "spaceId must be a non-empty string";
|
|
30001
|
+
}
|
|
30002
|
+
if (v.permissions !== void 0) {
|
|
30003
|
+
if (!Array.isArray(v.permissions)) {
|
|
30004
|
+
return "permissions, when present, must be an array";
|
|
30005
|
+
}
|
|
30006
|
+
for (let i = 0; i < v.permissions.length; i++) {
|
|
30007
|
+
const entry = v.permissions[i];
|
|
30008
|
+
if (!entry || typeof entry !== "object") {
|
|
30009
|
+
return `permissions[${i}] must be an object`;
|
|
30010
|
+
}
|
|
30011
|
+
const e = entry;
|
|
30012
|
+
if (typeof e.service !== "string" || !e.service) {
|
|
30013
|
+
return `permissions[${i}].service must be a non-empty string`;
|
|
30014
|
+
}
|
|
30015
|
+
if (typeof e.space !== "string") {
|
|
30016
|
+
return `permissions[${i}].space must be a string`;
|
|
30017
|
+
}
|
|
30018
|
+
if (typeof e.path !== "string") {
|
|
30019
|
+
return `permissions[${i}].path must be a string`;
|
|
30020
|
+
}
|
|
30021
|
+
if (!Array.isArray(e.actions) || e.actions.some((a) => typeof a !== "string" || !a)) {
|
|
30022
|
+
return `permissions[${i}].actions must be a non-empty string[]`;
|
|
30023
|
+
}
|
|
30024
|
+
}
|
|
30025
|
+
}
|
|
30026
|
+
return null;
|
|
30027
|
+
}
|
|
29778
30028
|
function shouldOpenBrowser(options) {
|
|
29779
30029
|
if (options.noPopup) return false;
|
|
29780
30030
|
const env = process.env.TC_AUTH_NO_POPUP ?? process.env.TC_NO_POPUP;
|
|
@@ -29801,12 +30051,18 @@ async function callbackFlow(did, options = {}) {
|
|
|
29801
30051
|
}
|
|
29802
30052
|
function parsePasteInput(input) {
|
|
29803
30053
|
const trimmed = input.trim();
|
|
30054
|
+
let parsed;
|
|
29804
30055
|
try {
|
|
29805
|
-
|
|
30056
|
+
parsed = JSON.parse(trimmed);
|
|
29806
30057
|
} catch {
|
|
29807
30058
|
const decoded = Buffer.from(trimmed, "base64").toString("utf-8");
|
|
29808
|
-
|
|
30059
|
+
parsed = JSON.parse(decoded);
|
|
29809
30060
|
}
|
|
30061
|
+
const invalid = validateDelegationCallbackPayload(parsed);
|
|
30062
|
+
if (invalid) {
|
|
30063
|
+
throw new Error(`Invalid delegation code: ${invalid}`);
|
|
30064
|
+
}
|
|
30065
|
+
return parsed;
|
|
29810
30066
|
}
|
|
29811
30067
|
const server = createServer((req, res) => {
|
|
29812
30068
|
if (req.method === "POST" && req.url === "/callback") {
|
|
@@ -29817,6 +30073,13 @@ async function callbackFlow(did, options = {}) {
|
|
|
29817
30073
|
req.on("end", () => {
|
|
29818
30074
|
try {
|
|
29819
30075
|
const data = JSON.parse(body);
|
|
30076
|
+
const invalid = validateDelegationCallbackPayload(data);
|
|
30077
|
+
if (invalid) {
|
|
30078
|
+
res.writeHead(400, { "Content-Type": "application/json" });
|
|
30079
|
+
res.end(JSON.stringify({ error: invalid }));
|
|
30080
|
+
settle({ error: new Error(`Invalid delegation payload: ${invalid}`) });
|
|
30081
|
+
return;
|
|
30082
|
+
}
|
|
29820
30083
|
res.writeHead(200, {
|
|
29821
30084
|
"Content-Type": "application/json",
|
|
29822
30085
|
"Access-Control-Allow-Origin": "*"
|
|
@@ -29903,18 +30166,24 @@ Open this URL in a browser to authenticate:
|
|
|
29903
30166
|
return new Promise((resolve4, reject) => {
|
|
29904
30167
|
rl.question("Paste delegation code: ", (input) => {
|
|
29905
30168
|
rl.close();
|
|
30169
|
+
let parsed;
|
|
29906
30170
|
try {
|
|
29907
|
-
|
|
29908
|
-
resolve4(data);
|
|
30171
|
+
parsed = JSON.parse(input.trim());
|
|
29909
30172
|
} catch {
|
|
29910
30173
|
try {
|
|
29911
30174
|
const decoded = Buffer.from(input.trim(), "base64").toString("utf-8");
|
|
29912
|
-
|
|
29913
|
-
resolve4(data);
|
|
30175
|
+
parsed = JSON.parse(decoded);
|
|
29914
30176
|
} catch {
|
|
29915
30177
|
reject(new Error("Invalid delegation code. Expected JSON or base64-encoded JSON."));
|
|
30178
|
+
return;
|
|
29916
30179
|
}
|
|
29917
30180
|
}
|
|
30181
|
+
const invalid = validateDelegationCallbackPayload(parsed);
|
|
30182
|
+
if (invalid) {
|
|
30183
|
+
reject(new Error(`Invalid delegation code: ${invalid}`));
|
|
30184
|
+
return;
|
|
30185
|
+
}
|
|
30186
|
+
resolve4(parsed);
|
|
29918
30187
|
});
|
|
29919
30188
|
});
|
|
29920
30189
|
}
|
|
@@ -30169,6 +30438,7 @@ function registerAuthCommand(program) {
|
|
|
30169
30438
|
const delegationCids2 = [];
|
|
30170
30439
|
let expiry2;
|
|
30171
30440
|
const openkeyHost = resolveOpenKeyHost(profile);
|
|
30441
|
+
const openkeyEffective = [];
|
|
30172
30442
|
for (const group of groupPermissionsBySpace(requested)) {
|
|
30173
30443
|
const delegationData = await startAuthFlow(profile.did, {
|
|
30174
30444
|
jwk: key,
|
|
@@ -30183,13 +30453,15 @@ function registerAuthCommand(program) {
|
|
|
30183
30453
|
noPopup: options.popup === false
|
|
30184
30454
|
});
|
|
30185
30455
|
const delegation = portableFromOpenKeyDelegation(delegationData, group, ctx.host);
|
|
30186
|
-
const
|
|
30456
|
+
const effective = permissionsFromDelegation(delegation);
|
|
30457
|
+
openkeyEffective.push(...effective);
|
|
30458
|
+
const stored = storedAdditionalDelegation(delegation, effective);
|
|
30187
30459
|
await appendAdditionalDelegation(ctx.profile, stored);
|
|
30188
30460
|
await node.useRuntimeDelegation(delegation);
|
|
30189
30461
|
delegationCids2.push(delegation.cid);
|
|
30190
30462
|
expiry2 = delegation.expiry.toISOString();
|
|
30191
30463
|
await appendGrantHistory(ctx.profile, {
|
|
30192
|
-
addedCaps:
|
|
30464
|
+
addedCaps: effective,
|
|
30193
30465
|
source: options.manifest ? "manifest" : "cli",
|
|
30194
30466
|
delegationCid: delegation.cid,
|
|
30195
30467
|
expiry: expiry2
|
|
@@ -30197,7 +30469,7 @@ function registerAuthCommand(program) {
|
|
|
30197
30469
|
}
|
|
30198
30470
|
outputJson({
|
|
30199
30471
|
changed: delegationCids2.length > 0,
|
|
30200
|
-
added:
|
|
30472
|
+
added: openkeyEffective,
|
|
30201
30473
|
delegationCid: delegationCids2[0],
|
|
30202
30474
|
delegationCids: delegationCids2,
|
|
30203
30475
|
expiry: expiry2
|
|
@@ -30222,8 +30494,10 @@ function registerAuthCommand(program) {
|
|
|
30222
30494
|
await persistCurrentLocalSession(ctx.profile, profile, node.restorableSession);
|
|
30223
30495
|
const delegationCids = [];
|
|
30224
30496
|
let expiry;
|
|
30497
|
+
const localEffective = [];
|
|
30225
30498
|
for (const delegation of delegations) {
|
|
30226
30499
|
const covering = permissionsFromDelegation(delegation);
|
|
30500
|
+
localEffective.push(...covering);
|
|
30227
30501
|
const stored = storedAdditionalDelegation(delegation, covering);
|
|
30228
30502
|
await appendAdditionalDelegation(ctx.profile, stored);
|
|
30229
30503
|
delegationCids.push(delegation.cid);
|
|
@@ -30241,7 +30515,7 @@ function registerAuthCommand(program) {
|
|
|
30241
30515
|
}
|
|
30242
30516
|
outputJson({
|
|
30243
30517
|
changed: true,
|
|
30244
|
-
added:
|
|
30518
|
+
added: localEffective,
|
|
30245
30519
|
delegationCid: delegationCids[0],
|
|
30246
30520
|
delegationCids,
|
|
30247
30521
|
expiry
|
|
@@ -30700,13 +30974,14 @@ async function ensureDelegationAuthority(params) {
|
|
|
30700
30974
|
expiry: params.expiryOption
|
|
30701
30975
|
});
|
|
30702
30976
|
const delegation = portableFromOpenKeyDelegation(delegationData, group, params.ctx.host);
|
|
30977
|
+
const effective = permissionsFromDelegation(delegation);
|
|
30703
30978
|
await appendAdditionalDelegation(
|
|
30704
30979
|
params.ctx.profile,
|
|
30705
|
-
storedAdditionalDelegation(delegation,
|
|
30980
|
+
storedAdditionalDelegation(delegation, effective)
|
|
30706
30981
|
);
|
|
30707
30982
|
await params.node.useRuntimeDelegation(delegation);
|
|
30708
30983
|
await appendGrantHistory(params.ctx.profile, {
|
|
30709
|
-
addedCaps:
|
|
30984
|
+
addedCaps: effective,
|
|
30710
30985
|
source: "cli",
|
|
30711
30986
|
delegationCid: delegation.cid,
|
|
30712
30987
|
expiry: delegation.expiry.toISOString()
|
|
@@ -30838,7 +31113,7 @@ function groupPermissionsBySpace(permissions) {
|
|
|
30838
31113
|
rawEntries.push(permission);
|
|
30839
31114
|
continue;
|
|
30840
31115
|
}
|
|
30841
|
-
const key = normalizeSpaceForCompare(permission.space);
|
|
31116
|
+
const key = normalizeSpaceForCompare(permission.space ?? "");
|
|
30842
31117
|
const group = groups.get(key) ?? [];
|
|
30843
31118
|
group.push(permission);
|
|
30844
31119
|
groups.set(key, group);
|
|
@@ -30871,7 +31146,7 @@ function portableFromOpenKeyDelegation(data, permissions, host) {
|
|
|
30871
31146
|
const primary = permissions.find((permission) => !isRawPermission(permission)) ?? permissions[0];
|
|
30872
31147
|
const returnedSpace = String(data.spaceId ?? primary.space ?? "encryption");
|
|
30873
31148
|
const expectedSpaces = new Set(
|
|
30874
|
-
permissions.filter((permission) => !isRawPermission(permission)).map((permission) => normalizeSpaceForCompare(permission.space))
|
|
31149
|
+
permissions.filter((permission) => !isRawPermission(permission)).map((permission) => normalizeSpaceForCompare(permission.space ?? ""))
|
|
30875
31150
|
);
|
|
30876
31151
|
const matchesExpectedSpace = expectedSpaces.size === 1 && returnedSpaceMatchesExpected(returnedSpace, Array.from(expectedSpaces)[0]);
|
|
30877
31152
|
if (expectedSpaces.size > 0 && !matchesExpectedSpace) {
|
|
@@ -30882,18 +31157,54 @@ function portableFromOpenKeyDelegation(data, permissions, host) {
|
|
|
30882
31157
|
);
|
|
30883
31158
|
}
|
|
30884
31159
|
const expiry = inferDelegationExpiry(data);
|
|
31160
|
+
const requestedPairs = new Set(
|
|
31161
|
+
permissions.flatMap(
|
|
31162
|
+
(p) => isRawPermission(p) ? p.actions.map((a) => `${p.service}|${p.space ?? ""}|${p.path}|${a}`) : p.actions.map((a) => `${p.service}|${normalizeSpaceForCompare(p.space ?? "")}|${p.path}|${a}`)
|
|
31163
|
+
)
|
|
31164
|
+
);
|
|
31165
|
+
const returnedPermissions = Array.isArray(data.permissions) ? data.permissions : null;
|
|
31166
|
+
const resources = (returnedPermissions ?? permissions).map((permission) => {
|
|
31167
|
+
const service = permission.service.startsWith("tinycloud.") ? permission.service.slice("tinycloud.".length) : permission.service;
|
|
31168
|
+
const rawService = permission.service.startsWith("tinycloud.") ? permission.service : `tinycloud.${service}`;
|
|
31169
|
+
const permSpace = permission.space ?? "";
|
|
31170
|
+
if (returnedPermissions) {
|
|
31171
|
+
const rawSpace = isRawPermission({
|
|
31172
|
+
service: rawService,
|
|
31173
|
+
space: permSpace,
|
|
31174
|
+
path: permission.path,
|
|
31175
|
+
actions: []
|
|
31176
|
+
}) ? permSpace : normalizeSpaceForCompare(permSpace);
|
|
31177
|
+
for (const action of permission.actions) {
|
|
31178
|
+
const key = `${rawService}|${rawSpace}|${permission.path}|${action}`;
|
|
31179
|
+
if (!requestedPairs.has(key)) {
|
|
31180
|
+
throw new CLIError(
|
|
31181
|
+
"OPENKEY_GRANT_BROADENED",
|
|
31182
|
+
`OpenKey returned grant ${rawService}/${action} on ${permSpace}/${permission.path} that was not requested.`,
|
|
31183
|
+
ExitCode.PERMISSION_DENIED
|
|
31184
|
+
);
|
|
31185
|
+
}
|
|
31186
|
+
}
|
|
31187
|
+
}
|
|
31188
|
+
const resolvedSpace = isRawPermission({
|
|
31189
|
+
service: rawService,
|
|
31190
|
+
space: permSpace,
|
|
31191
|
+
path: permission.path,
|
|
31192
|
+
actions: []
|
|
31193
|
+
}) ? permSpace : returnedSpace;
|
|
31194
|
+
return {
|
|
31195
|
+
service,
|
|
31196
|
+
space: resolvedSpace,
|
|
31197
|
+
path: permission.path,
|
|
31198
|
+
actions: [...permission.actions]
|
|
31199
|
+
};
|
|
31200
|
+
});
|
|
30885
31201
|
return {
|
|
30886
31202
|
cid: String(data.delegationCid),
|
|
30887
31203
|
delegationHeader: data.delegationHeader,
|
|
30888
31204
|
spaceId: returnedSpace,
|
|
30889
31205
|
path: primary.path,
|
|
30890
31206
|
actions: primary.actions,
|
|
30891
|
-
resources
|
|
30892
|
-
service: permission.service.startsWith("tinycloud.") ? permission.service.slice("tinycloud.".length) : permission.service,
|
|
30893
|
-
space: isRawPermission(permission) ? permission.space : returnedSpace,
|
|
30894
|
-
path: permission.path,
|
|
30895
|
-
actions: [...permission.actions]
|
|
30896
|
-
})),
|
|
31207
|
+
resources,
|
|
30897
31208
|
expiry,
|
|
30898
31209
|
delegateDID: String(data.verificationMethod),
|
|
30899
31210
|
ownerAddress: String(data.address ?? ""),
|