@tinycloud/cli 0.9.1-beta.5 → 0.9.1-beta.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -37,7 +37,7 @@ import {
37
37
  tinycloudConfigPath,
38
38
  tinycloudHomePath
39
39
  } from "@tinycloud/operations/state";
40
- var CONFIG_DIR, PROFILES_DIR, CONFIG_FILE, DEFAULT_HOST, DEFAULT_PROFILE, ExitCode;
40
+ var CONFIG_DIR, PROFILES_DIR, CONFIG_FILE, DEFAULT_HOST, DEFAULT_OPENKEY_DEVICE_API_HOST, DEFAULT_PROFILE, DEFAULT_CHAIN_ID, ExitCode;
41
41
  var init_constants = __esm({
42
42
  "src/config/constants.ts"() {
43
43
  "use strict";
@@ -45,7 +45,9 @@ var init_constants = __esm({
45
45
  PROFILES_DIR = profilesPath();
46
46
  CONFIG_FILE = tinycloudConfigPath();
47
47
  DEFAULT_HOST = "https://node.tinycloud.xyz";
48
+ DEFAULT_OPENKEY_DEVICE_API_HOST = "https://api.openkey.so";
48
49
  DEFAULT_PROFILE = "default";
50
+ DEFAULT_CHAIN_ID = 1;
49
51
  ExitCode = {
50
52
  SUCCESS: 0,
51
53
  ERROR: 1,
@@ -6163,7 +6165,7 @@ function eddsa(Point2, cHash, eddsaOpts = {}) {
6163
6165
  });
6164
6166
  const { prehash } = eddsaOpts;
6165
6167
  const { BASE, Fp: Fp2, Fn: Fn2 } = Point2;
6166
- const randomBytes3 = eddsaOpts.randomBytes || randomBytes;
6168
+ const randomBytes5 = eddsaOpts.randomBytes || randomBytes;
6167
6169
  const adjustScalarBytes2 = eddsaOpts.adjustScalarBytes || ((bytes3) => bytes3);
6168
6170
  const domain = eddsaOpts.domain || ((data, ctx, phflag) => {
6169
6171
  _abool2(phflag, "phflag");
@@ -6245,7 +6247,7 @@ function eddsa(Point2, cHash, eddsaOpts = {}) {
6245
6247
  signature: 2 * _size,
6246
6248
  seed: _size
6247
6249
  };
6248
- function randomSecretKey(seed = randomBytes3(lengths.seed)) {
6250
+ function randomSecretKey(seed = randomBytes5(lengths.seed)) {
6249
6251
  return _abytes2(seed, lengths.seed, "seed");
6250
6252
  }
6251
6253
  function keygen(seed) {
@@ -9068,7 +9070,7 @@ function weierstrass(curveDef) {
9068
9070
  function prepSig(msgHash, privateKey, opts = defaultSigOpts) {
9069
9071
  if (["recovered", "canonical"].some((k) => k in opts))
9070
9072
  throw new Error("sign() legacy options not supported");
9071
- const { hash, randomBytes: randomBytes3 } = CURVE;
9073
+ const { hash, randomBytes: randomBytes5 } = CURVE;
9072
9074
  let { lowS, prehash, extraEntropy: ent } = opts;
9073
9075
  if (lowS == null)
9074
9076
  lowS = true;
@@ -9080,7 +9082,7 @@ function weierstrass(curveDef) {
9080
9082
  const d = normPrivateKeyToScalar(privateKey);
9081
9083
  const seedArgs = [int2octets(d), int2octets(h1int)];
9082
9084
  if (ent != null && ent !== false) {
9083
- const e = ent === true ? randomBytes3(Fp2.BYTES) : ent;
9085
+ const e = ent === true ? randomBytes5(Fp2.BYTES) : ent;
9084
9086
  seedArgs.push(ensureBytes2("extraEntropy", e));
9085
9087
  }
9086
9088
  const seed = concatBytes3(...seedArgs);
@@ -14705,7 +14707,7 @@ var init_dist2 = __esm({
14705
14707
  async handleErrorResponse(response, operation) {
14706
14708
  const errorText = await response.text();
14707
14709
  const errorBody = parseServiceErrorBody(errorText);
14708
- const errorCode = this.mapHttpStatusToErrorCode(
14710
+ const errorCode2 = this.mapHttpStatusToErrorCode(
14709
14711
  response.status,
14710
14712
  errorBody.error
14711
14713
  );
@@ -14723,7 +14725,7 @@ var init_dist2 = __esm({
14723
14725
  if (resource) meta.resource = resource;
14724
14726
  }
14725
14727
  return err(
14726
- serviceError(errorCode, message, "sql", { meta })
14728
+ serviceError(errorCode2, message, "sql", { meta })
14727
14729
  );
14728
14730
  }
14729
14731
  mapHttpStatusToErrorCode(status, serverError) {
@@ -15053,7 +15055,7 @@ var init_dist2 = __esm({
15053
15055
  async handleErrorResponse(response, operation) {
15054
15056
  const errorText = await response.text();
15055
15057
  const errorBody = parseServiceErrorBody(errorText);
15056
- const errorCode = this.mapHttpStatusToErrorCode(
15058
+ const errorCode2 = this.mapHttpStatusToErrorCode(
15057
15059
  response.status,
15058
15060
  errorBody.error
15059
15061
  );
@@ -15071,7 +15073,7 @@ var init_dist2 = __esm({
15071
15073
  if (resource) meta.resource = resource;
15072
15074
  }
15073
15075
  return err(
15074
- serviceError(errorCode, message, "duckdb", { meta })
15076
+ serviceError(errorCode2, message, "duckdb", { meta })
15075
15077
  );
15076
15078
  }
15077
15079
  mapHttpStatusToErrorCode(status, serverError) {
@@ -17501,25 +17503,25 @@ function encodeTo(int, target, offset = 0) {
17501
17503
  function encodingLength(int) {
17502
17504
  return varint_default.encodingLength(int);
17503
17505
  }
17504
- function create(code222, digest4) {
17505
- const size2 = digest4.byteLength;
17506
+ function create(code222, digest42) {
17507
+ const size2 = digest42.byteLength;
17506
17508
  const sizeOffset = encodingLength(code222);
17507
17509
  const digestOffset = sizeOffset + encodingLength(size2);
17508
17510
  const bytes3 = new Uint8Array(digestOffset + size2);
17509
17511
  encodeTo(code222, bytes3, 0);
17510
17512
  encodeTo(size2, bytes3, sizeOffset);
17511
- bytes3.set(digest4, digestOffset);
17512
- return new Digest(code222, size2, digest4, bytes3);
17513
+ bytes3.set(digest42, digestOffset);
17514
+ return new Digest(code222, size2, digest42, bytes3);
17513
17515
  }
17514
17516
  function decode4(multihash) {
17515
17517
  const bytes3 = coerce22(multihash);
17516
17518
  const [code222, sizeOffset] = decode3(bytes3);
17517
17519
  const [size2, digestOffset] = decode3(bytes3.subarray(sizeOffset));
17518
- const digest4 = bytes3.subarray(sizeOffset + digestOffset);
17519
- if (digest4.byteLength !== size2) {
17520
+ const digest42 = bytes3.subarray(sizeOffset + digestOffset);
17521
+ if (digest42.byteLength !== size2) {
17520
17522
  throw new Error("Incorrect length");
17521
17523
  }
17522
- return new Digest(code222, size2, digest4, bytes3);
17524
+ return new Digest(code222, size2, digest42, bytes3);
17523
17525
  }
17524
17526
  function equals2(a, b) {
17525
17527
  if (a === b) {
@@ -17612,8 +17614,8 @@ function encodeCID(version3, code222, multihash) {
17612
17614
  return bytes3;
17613
17615
  }
17614
17616
  async function computeCid(bytes3) {
17615
- const digest4 = create(SHA256_CODE, sha256(new Uint8Array(bytes3)));
17616
- return CID.create(1, code, digest4).toString();
17617
+ const digest42 = create(SHA256_CODE, sha256(new Uint8Array(bytes3)));
17618
+ return CID.create(1, code, digest42).toString();
17617
17619
  }
17618
17620
  function isCanonicalRawCid(cidString) {
17619
17621
  let cid2;
@@ -18254,8 +18256,8 @@ async function verifyEnvelopeV3(envelope, options) {
18254
18256
  const expectedBindingDigestHex = hex(sha2562(new TextEncoder().encode(canonicalize2({ enforcerDid: binding.enforcerDid, nodeAudience: binding.nodeAudience }))));
18255
18257
  if (binding.enforcerDid !== parsed.target.nodeAudience || binding.attestationBindingDigestHex !== expectedBindingDigestHex || bindingSignature.signerDid !== binding.nodeAudience || bindingSignature.suite !== "Ed25519" || Date.parse(binding.issuedAt) > Date.now() || Date.parse(binding.expiresAt) <= Date.now() || Date.parse(binding.expiresAt) < Date.parse(parsed.expiry)) return false;
18256
18258
  try {
18257
- const digest4 = sha2562(new TextEncoder().encode(`${ATTESTED_ENFORCER_V2_DOMAIN}${canonicalize2(unsignedBinding)}`));
18258
- if (!ed25519.verify(fromBase64Url(bindingSignature.value), digest4, ed25519PublicKeyFromDidKey(binding.nodeAudience), ED25519_VERIFY_OPTS2)) return false;
18259
+ const digest42 = sha2562(new TextEncoder().encode(`${ATTESTED_ENFORCER_V2_DOMAIN}${canonicalize2(unsignedBinding)}`));
18260
+ if (!ed25519.verify(fromBase64Url(bindingSignature.value), digest42, ed25519PublicKeyFromDidKey(binding.nodeAudience), ED25519_VERIFY_OPTS2)) return false;
18259
18261
  } catch {
18260
18262
  return false;
18261
18263
  }
@@ -19265,25 +19267,25 @@ function encodeTo2(int, target, offset = 0) {
19265
19267
  function encodingLength2(int) {
19266
19268
  return varint_default2.encodingLength(int);
19267
19269
  }
19268
- function create2(code32, digest4) {
19269
- const size2 = digest4.byteLength;
19270
+ function create2(code32, digest42) {
19271
+ const size2 = digest42.byteLength;
19270
19272
  const sizeOffset = encodingLength2(code32);
19271
19273
  const digestOffset = sizeOffset + encodingLength2(size2);
19272
19274
  const bytes3 = new Uint8Array(digestOffset + size2);
19273
19275
  encodeTo2(code32, bytes3, 0);
19274
19276
  encodeTo2(size2, bytes3, sizeOffset);
19275
- bytes3.set(digest4, digestOffset);
19276
- return new Digest2(code32, size2, digest4, bytes3);
19277
+ bytes3.set(digest42, digestOffset);
19278
+ return new Digest2(code32, size2, digest42, bytes3);
19277
19279
  }
19278
19280
  function decode8(multihash) {
19279
19281
  const bytes3 = coerce3(multihash);
19280
19282
  const [code32, sizeOffset] = decode7(bytes3);
19281
19283
  const [size2, digestOffset] = decode7(bytes3.subarray(sizeOffset));
19282
- const digest4 = bytes3.subarray(sizeOffset + digestOffset);
19283
- if (digest4.byteLength !== size2) {
19284
+ const digest42 = bytes3.subarray(sizeOffset + digestOffset);
19285
+ if (digest42.byteLength !== size2) {
19284
19286
  throw new Error("Incorrect length");
19285
19287
  }
19286
- return new Digest2(code32, size2, digest4, bytes3);
19288
+ return new Digest2(code32, size2, digest42, bytes3);
19287
19289
  }
19288
19290
  function equals4(a, b) {
19289
19291
  if (a === b) {
@@ -20110,11 +20112,11 @@ async function notifyShare(input) {
20110
20112
  }
20111
20113
  async function defaultIdempotencyKey(shareId, recipient) {
20112
20114
  const canonicalRecipient = canonicalize2(recipient.trim().toLowerCase());
20113
- const digest4 = new Uint8Array(await crypto.subtle.digest(
20115
+ const digest42 = new Uint8Array(await crypto.subtle.digest(
20114
20116
  "SHA-256",
20115
20117
  new TextEncoder().encode(canonicalRecipient)
20116
20118
  ));
20117
- return `tinycloud-share:${shareId}:${toBase64Url(digest4)}`;
20119
+ return `tinycloud-share:${shareId}:${toBase64Url(digest42)}`;
20118
20120
  }
20119
20121
  function targetKind2(record2) {
20120
20122
  if (record2.targetKind !== void 0) return record2.targetKind;
@@ -24415,10 +24417,10 @@ var init_dist3 = __esm({
24415
24417
  /**
24416
24418
  * Creates a multihash digest.
24417
24419
  */
24418
- constructor(code222, size2, digest4, bytes3) {
24420
+ constructor(code222, size2, digest42, bytes3) {
24419
24421
  this.code = code222;
24420
24422
  this.size = size2;
24421
- this.digest = digest4;
24423
+ this.digest = digest42;
24422
24424
  this.bytes = bytes3;
24423
24425
  }
24424
24426
  };
@@ -24481,8 +24483,8 @@ var init_dist3 = __esm({
24481
24483
  toV1() {
24482
24484
  switch (this.version) {
24483
24485
  case 0: {
24484
- const { code: code222, digest: digest4 } = this.multihash;
24485
- const multihash = create(code222, digest4);
24486
+ const { code: code222, digest: digest42 } = this.multihash;
24487
+ const multihash = create(code222, digest42);
24486
24488
  return _CID.createV1(this.code, multihash);
24487
24489
  }
24488
24490
  case 1: {
@@ -24536,8 +24538,8 @@ var init_dist3 = __esm({
24536
24538
  return new _CID(version3, code222, multihash, bytes3 ?? encodeCID(version3, code222, multihash.bytes));
24537
24539
  } else if (value[cidSymbol] === true) {
24538
24540
  const { version: version3, multihash, code: code222 } = value;
24539
- const digest4 = decode4(multihash);
24540
- return _CID.create(version3, code222, digest4);
24541
+ const digest42 = decode4(multihash);
24542
+ return _CID.create(version3, code222, digest42);
24541
24543
  } else {
24542
24544
  return null;
24543
24545
  }
@@ -24547,11 +24549,11 @@ var init_dist3 = __esm({
24547
24549
  * @param code - Code of the codec content is encoded in, see https://github.com/multiformats/multicodec/blob/master/table.csv
24548
24550
  * @param digest - (Multi)hash of the of the content.
24549
24551
  */
24550
- static create(version3, code222, digest4) {
24552
+ static create(version3, code222, digest42) {
24551
24553
  if (typeof code222 !== "number") {
24552
24554
  throw new Error("String codecs are no longer supported");
24553
24555
  }
24554
- if (!(digest4.bytes instanceof Uint8Array)) {
24556
+ if (!(digest42.bytes instanceof Uint8Array)) {
24555
24557
  throw new Error("Invalid digest");
24556
24558
  }
24557
24559
  switch (version3) {
@@ -24559,12 +24561,12 @@ var init_dist3 = __esm({
24559
24561
  if (code222 !== DAG_PB_CODE) {
24560
24562
  throw new Error(`Version 0 CID must use dag-pb (code: ${DAG_PB_CODE}) block encoding`);
24561
24563
  } else {
24562
- return new _CID(version3, code222, digest4, digest4.bytes);
24564
+ return new _CID(version3, code222, digest42, digest42.bytes);
24563
24565
  }
24564
24566
  }
24565
24567
  case 1: {
24566
- const bytes3 = encodeCID(version3, code222, digest4.bytes);
24567
- return new _CID(version3, code222, digest4, bytes3);
24568
+ const bytes3 = encodeCID(version3, code222, digest42.bytes);
24569
+ return new _CID(version3, code222, digest42, bytes3);
24568
24570
  }
24569
24571
  default: {
24570
24572
  throw new Error("Invalid version");
@@ -24574,8 +24576,8 @@ var init_dist3 = __esm({
24574
24576
  /**
24575
24577
  * Simplified version of `create` for CIDv0.
24576
24578
  */
24577
- static createV0(digest4) {
24578
- return _CID.create(0, DAG_PB_CODE, digest4);
24579
+ static createV0(digest42) {
24580
+ return _CID.create(0, DAG_PB_CODE, digest42);
24579
24581
  }
24580
24582
  /**
24581
24583
  * Simplified version of `create` for CIDv1.
@@ -24583,8 +24585,8 @@ var init_dist3 = __esm({
24583
24585
  * @param code - Content encoding format code.
24584
24586
  * @param digest - Multihash of the content.
24585
24587
  */
24586
- static createV1(code222, digest4) {
24587
- return _CID.create(1, code222, digest4);
24588
+ static createV1(code222, digest42) {
24589
+ return _CID.create(1, code222, digest42);
24588
24590
  }
24589
24591
  /**
24590
24592
  * Decoded a CID from its binary representation. The byte array must contain
@@ -24617,8 +24619,8 @@ var init_dist3 = __esm({
24617
24619
  throw new Error("Incorrect length");
24618
24620
  }
24619
24621
  const digestBytes3 = multihashBytes.subarray(specs.multihashSize - specs.digestSize);
24620
- const digest4 = new Digest(specs.multihashCode, specs.digestSize, digestBytes3, multihashBytes);
24621
- const cid2 = specs.version === 0 ? _CID.createV0(digest4) : _CID.createV1(specs.codec, digest4);
24622
+ const digest42 = new Digest(specs.multihashCode, specs.digestSize, digestBytes3, multihashBytes);
24623
+ const cid2 = specs.version === 0 ? _CID.createV0(digest42) : _CID.createV1(specs.codec, digest42);
24622
24624
  return [cid2, bytes3.subarray(specs.size)];
24623
24625
  }
24624
24626
  /**
@@ -25265,10 +25267,10 @@ var init_dist3 = __esm({
25265
25267
  /**
25266
25268
  * Creates a multihash digest.
25267
25269
  */
25268
- constructor(code32, size2, digest4, bytes3) {
25270
+ constructor(code32, size2, digest42, bytes3) {
25269
25271
  this.code = code32;
25270
25272
  this.size = size2;
25271
- this.digest = digest4;
25273
+ this.digest = digest42;
25272
25274
  this.bytes = bytes3;
25273
25275
  }
25274
25276
  };
@@ -25331,8 +25333,8 @@ var init_dist3 = __esm({
25331
25333
  toV1() {
25332
25334
  switch (this.version) {
25333
25335
  case 0: {
25334
- const { code: code32, digest: digest4 } = this.multihash;
25335
- const multihash = create2(code32, digest4);
25336
+ const { code: code32, digest: digest42 } = this.multihash;
25337
+ const multihash = create2(code32, digest42);
25336
25338
  return _CID2.createV1(this.code, multihash);
25337
25339
  }
25338
25340
  case 1: {
@@ -25386,8 +25388,8 @@ var init_dist3 = __esm({
25386
25388
  return new _CID2(version3, code32, multihash, bytes3 ?? encodeCID2(version3, code32, multihash.bytes));
25387
25389
  } else if (value[cidSymbol2] === true) {
25388
25390
  const { version: version3, multihash, code: code32 } = value;
25389
- const digest4 = decode8(multihash);
25390
- return _CID2.create(version3, code32, digest4);
25391
+ const digest42 = decode8(multihash);
25392
+ return _CID2.create(version3, code32, digest42);
25391
25393
  } else {
25392
25394
  return null;
25393
25395
  }
@@ -25397,11 +25399,11 @@ var init_dist3 = __esm({
25397
25399
  * @param code - Code of the codec content is encoded in, see https://github.com/multiformats/multicodec/blob/master/table.csv
25398
25400
  * @param digest - (Multi)hash of the of the content.
25399
25401
  */
25400
- static create(version3, code32, digest4) {
25402
+ static create(version3, code32, digest42) {
25401
25403
  if (typeof code32 !== "number") {
25402
25404
  throw new Error("String codecs are no longer supported");
25403
25405
  }
25404
- if (!(digest4.bytes instanceof Uint8Array)) {
25406
+ if (!(digest42.bytes instanceof Uint8Array)) {
25405
25407
  throw new Error("Invalid digest");
25406
25408
  }
25407
25409
  switch (version3) {
@@ -25409,12 +25411,12 @@ var init_dist3 = __esm({
25409
25411
  if (code32 !== DAG_PB_CODE2) {
25410
25412
  throw new Error(`Version 0 CID must use dag-pb (code: ${DAG_PB_CODE2}) block encoding`);
25411
25413
  } else {
25412
- return new _CID2(version3, code32, digest4, digest4.bytes);
25414
+ return new _CID2(version3, code32, digest42, digest42.bytes);
25413
25415
  }
25414
25416
  }
25415
25417
  case 1: {
25416
- const bytes3 = encodeCID2(version3, code32, digest4.bytes);
25417
- return new _CID2(version3, code32, digest4, bytes3);
25418
+ const bytes3 = encodeCID2(version3, code32, digest42.bytes);
25419
+ return new _CID2(version3, code32, digest42, bytes3);
25418
25420
  }
25419
25421
  default: {
25420
25422
  throw new Error("Invalid version");
@@ -25424,8 +25426,8 @@ var init_dist3 = __esm({
25424
25426
  /**
25425
25427
  * Simplified version of `create` for CIDv0.
25426
25428
  */
25427
- static createV0(digest4) {
25428
- return _CID2.create(0, DAG_PB_CODE2, digest4);
25429
+ static createV0(digest42) {
25430
+ return _CID2.create(0, DAG_PB_CODE2, digest42);
25429
25431
  }
25430
25432
  /**
25431
25433
  * Simplified version of `create` for CIDv1.
@@ -25433,8 +25435,8 @@ var init_dist3 = __esm({
25433
25435
  * @param code - Content encoding format code.
25434
25436
  * @param digest - Multihash of the content.
25435
25437
  */
25436
- static createV1(code32, digest4) {
25437
- return _CID2.create(1, code32, digest4);
25438
+ static createV1(code32, digest42) {
25439
+ return _CID2.create(1, code32, digest42);
25438
25440
  }
25439
25441
  /**
25440
25442
  * Decoded a CID from its binary representation. The byte array must contain
@@ -25467,8 +25469,8 @@ var init_dist3 = __esm({
25467
25469
  throw new Error("Incorrect length");
25468
25470
  }
25469
25471
  const digestBytes3 = multihashBytes.subarray(specs.multihashSize - specs.digestSize);
25470
- const digest4 = new Digest2(specs.multihashCode, specs.digestSize, digestBytes3, multihashBytes);
25471
- const cid2 = specs.version === 0 ? _CID2.createV0(digest4) : _CID2.createV1(specs.codec, digest4);
25472
+ const digest42 = new Digest2(specs.multihashCode, specs.digestSize, digestBytes3, multihashBytes);
25473
+ const cid2 = specs.version === 0 ? _CID2.createV0(digest42) : _CID2.createV1(specs.codec, digest42);
25472
25474
  return [cid2, bytes3.subarray(specs.size)];
25473
25475
  }
25474
25476
  /**
@@ -26179,25 +26181,25 @@ function encodeTo3(int, target, offset = 0) {
26179
26181
  function encodingLength3(int) {
26180
26182
  return varint_default3.encodingLength(int);
26181
26183
  }
26182
- function create3(code32, digest4) {
26183
- const size2 = digest4.byteLength;
26184
+ function create3(code32, digest42) {
26185
+ const size2 = digest42.byteLength;
26184
26186
  const sizeOffset = encodingLength3(code32);
26185
26187
  const digestOffset = sizeOffset + encodingLength3(size2);
26186
26188
  const bytes22 = new Uint8Array(digestOffset + size2);
26187
26189
  encodeTo3(code32, bytes22, 0);
26188
26190
  encodeTo3(size2, bytes22, sizeOffset);
26189
- bytes22.set(digest4, digestOffset);
26190
- return new Digest3(code32, size2, digest4, bytes22);
26191
+ bytes22.set(digest42, digestOffset);
26192
+ return new Digest3(code32, size2, digest42, bytes22);
26191
26193
  }
26192
26194
  function decode42(multihash) {
26193
26195
  const bytes22 = coerce4(multihash);
26194
26196
  const [code32, sizeOffset] = decode32(bytes22);
26195
26197
  const [size2, digestOffset] = decode32(bytes22.subarray(sizeOffset));
26196
- const digest4 = bytes22.subarray(sizeOffset + digestOffset);
26197
- if (digest4.byteLength !== size2) {
26198
+ const digest42 = bytes22.subarray(sizeOffset + digestOffset);
26199
+ if (digest42.byteLength !== size2) {
26198
26200
  throw new Error("Incorrect length");
26199
26201
  }
26200
- return new Digest3(code32, size2, digest4, bytes22);
26202
+ return new Digest3(code32, size2, digest42, bytes22);
26201
26203
  }
26202
26204
  function equals22(a, b) {
26203
26205
  if (a === b) {
@@ -26322,14 +26324,14 @@ function digest2(input, options2) {
26322
26324
  function from22({ name: name2, code: code32, encode: encode52, minDigestLength, maxDigestLength }) {
26323
26325
  return new Hasher(name2, code32, encode52, minDigestLength, maxDigestLength);
26324
26326
  }
26325
- function createDigest(digest4, code32, truncate) {
26326
- if (truncate != null && truncate !== digest4.byteLength) {
26327
- if (truncate > digest4.byteLength) {
26328
- throw new Error(`Invalid truncate option, must be less than or equal to ${digest4.byteLength}`);
26327
+ function createDigest(digest42, code32, truncate) {
26328
+ if (truncate != null && truncate !== digest42.byteLength) {
26329
+ if (truncate > digest42.byteLength) {
26330
+ throw new Error(`Invalid truncate option, must be less than or equal to ${digest42.byteLength}`);
26329
26331
  }
26330
- digest4 = digest4.subarray(0, truncate);
26332
+ digest42 = digest42.subarray(0, truncate);
26331
26333
  }
26332
- return create3(code32, digest4);
26334
+ return create3(code32, digest42);
26333
26335
  }
26334
26336
  function sha(name2) {
26335
26337
  return async (data) => new Uint8Array(await crypto.subtle.digest(name2, data));
@@ -27639,14 +27641,14 @@ var init_dist4 = __esm({
27639
27641
  /**
27640
27642
  * Creates a multihash digest.
27641
27643
  */
27642
- constructor(code32, size2, digest4, bytes22) {
27644
+ constructor(code32, size2, digest42, bytes22) {
27643
27645
  __publicField(this, "code");
27644
27646
  __publicField(this, "size");
27645
27647
  __publicField(this, "digest");
27646
27648
  __publicField(this, "bytes");
27647
27649
  this.code = code32;
27648
27650
  this.size = size2;
27649
- this.digest = digest4;
27651
+ this.digest = digest42;
27650
27652
  this.bytes = bytes22;
27651
27653
  }
27652
27654
  };
@@ -27710,8 +27712,8 @@ var init_dist4 = __esm({
27710
27712
  toV1() {
27711
27713
  switch (this.version) {
27712
27714
  case 0: {
27713
- const { code: code32, digest: digest4 } = this.multihash;
27714
- const multihash = create3(code32, digest4);
27715
+ const { code: code32, digest: digest42 } = this.multihash;
27716
+ const multihash = create3(code32, digest42);
27715
27717
  return _CID3.createV1(this.code, multihash);
27716
27718
  }
27717
27719
  case 1: {
@@ -27764,8 +27766,8 @@ var init_dist4 = __esm({
27764
27766
  return new _CID3(version3, code32, multihash, bytes22 ?? encodeCID3(version3, code32, multihash.bytes));
27765
27767
  } else if (value[cidSymbol3] === true) {
27766
27768
  const { version: version3, multihash, code: code32 } = value;
27767
- const digest4 = decode42(multihash);
27768
- return _CID3.create(version3, code32, digest4);
27769
+ const digest42 = decode42(multihash);
27770
+ return _CID3.create(version3, code32, digest42);
27769
27771
  } else {
27770
27772
  return null;
27771
27773
  }
@@ -27775,11 +27777,11 @@ var init_dist4 = __esm({
27775
27777
  * @param code - Code of the codec content is encoded in, see https://github.com/multiformats/multicodec/blob/master/table.csv
27776
27778
  * @param digest - (Multi)hash of the of the content.
27777
27779
  */
27778
- static create(version3, code32, digest4) {
27780
+ static create(version3, code32, digest42) {
27779
27781
  if (typeof code32 !== "number") {
27780
27782
  throw new Error("String codecs are no longer supported");
27781
27783
  }
27782
- if (!(digest4.bytes instanceof Uint8Array)) {
27784
+ if (!(digest42.bytes instanceof Uint8Array)) {
27783
27785
  throw new Error("Invalid digest");
27784
27786
  }
27785
27787
  switch (version3) {
@@ -27787,12 +27789,12 @@ var init_dist4 = __esm({
27787
27789
  if (code32 !== DAG_PB_CODE3) {
27788
27790
  throw new Error(`Version 0 CID must use dag-pb (code: ${DAG_PB_CODE3}) block encoding`);
27789
27791
  } else {
27790
- return new _CID3(version3, code32, digest4, digest4.bytes);
27792
+ return new _CID3(version3, code32, digest42, digest42.bytes);
27791
27793
  }
27792
27794
  }
27793
27795
  case 1: {
27794
- const bytes22 = encodeCID3(version3, code32, digest4.bytes);
27795
- return new _CID3(version3, code32, digest4, bytes22);
27796
+ const bytes22 = encodeCID3(version3, code32, digest42.bytes);
27797
+ return new _CID3(version3, code32, digest42, bytes22);
27796
27798
  }
27797
27799
  default: {
27798
27800
  throw new Error("Invalid version");
@@ -27802,8 +27804,8 @@ var init_dist4 = __esm({
27802
27804
  /**
27803
27805
  * Simplified version of `create` for CIDv0.
27804
27806
  */
27805
- static createV0(digest4) {
27806
- return _CID3.create(0, DAG_PB_CODE3, digest4);
27807
+ static createV0(digest42) {
27808
+ return _CID3.create(0, DAG_PB_CODE3, digest42);
27807
27809
  }
27808
27810
  /**
27809
27811
  * Simplified version of `create` for CIDv1.
@@ -27811,8 +27813,8 @@ var init_dist4 = __esm({
27811
27813
  * @param code - Content encoding format code.
27812
27814
  * @param digest - Multihash of the content.
27813
27815
  */
27814
- static createV1(code32, digest4) {
27815
- return _CID3.create(1, code32, digest4);
27816
+ static createV1(code32, digest42) {
27817
+ return _CID3.create(1, code32, digest42);
27816
27818
  }
27817
27819
  /**
27818
27820
  * Decoded a CID from its binary representation. The byte array must contain
@@ -27845,8 +27847,8 @@ var init_dist4 = __esm({
27845
27847
  throw new Error("Incorrect length");
27846
27848
  }
27847
27849
  const digestBytes3 = multihashBytes.subarray(specs.multihashSize - specs.digestSize);
27848
- const digest4 = new Digest3(specs.multihashCode, specs.digestSize, digestBytes3, multihashBytes);
27849
- const cid2 = specs.version === 0 ? _CID3.createV0(digest4) : _CID3.createV1(specs.codec, digest4);
27850
+ const digest42 = new Digest3(specs.multihashCode, specs.digestSize, digestBytes3, multihashBytes);
27851
+ const cid2 = specs.version === 0 ? _CID3.createV0(digest42) : _CID3.createV1(specs.codec, digest42);
27850
27852
  return [cid2, bytes22.subarray(specs.size)];
27851
27853
  }
27852
27854
  /**
@@ -28075,7 +28077,7 @@ var init_dist4 = __esm({
28075
28077
  if (result instanceof Uint8Array) {
28076
28078
  return createDigest(result, this.code, options2?.truncate);
28077
28079
  }
28078
- return result.then((digest4) => createDigest(digest4, this.code, options2?.truncate));
28080
+ return result.then((digest42) => createDigest(digest42, this.code, options2?.truncate));
28079
28081
  } else {
28080
28082
  throw Error("Unknown type, must be binary type");
28081
28083
  }
@@ -30656,6 +30658,385 @@ var init_sdk = __esm({
30656
30658
  }
30657
30659
  });
30658
30660
 
30661
+ // src/auth/local-key.ts
30662
+ import { TCWSessionManager, importKey, initPanicHook } from "@tinycloud/node-sdk-wasm";
30663
+ import { PrivateKeySigner } from "@tinycloud/node-sdk";
30664
+ import { randomBytes as randomBytes3 } from "crypto";
30665
+ function ensureWasm() {
30666
+ if (!wasmInitialized) {
30667
+ initPanicHook();
30668
+ wasmInitialized = true;
30669
+ }
30670
+ }
30671
+ function generateKey2() {
30672
+ ensureWasm();
30673
+ const mgr = new TCWSessionManager();
30674
+ const keyId = mgr.createSessionKey("cli");
30675
+ const jwkStr = mgr.jwk(keyId);
30676
+ if (!jwkStr) throw new Error("Failed to generate key");
30677
+ const jwk = JSON.parse(jwkStr);
30678
+ const did = mgr.getDID(keyId);
30679
+ return { jwk, did };
30680
+ }
30681
+ function keyToDID(jwk) {
30682
+ ensureWasm();
30683
+ const mgr = new TCWSessionManager();
30684
+ const keyId = importKey(mgr, JSON.stringify(jwk), "imported");
30685
+ return mgr.getDID(keyId);
30686
+ }
30687
+ var wasmInitialized;
30688
+ var init_local_key = __esm({
30689
+ "src/auth/local-key.ts"() {
30690
+ "use strict";
30691
+ wasmInitialized = false;
30692
+ }
30693
+ });
30694
+
30695
+ // src/auth/browser-auth.ts
30696
+ import { createServer } from "http";
30697
+ import { createInterface } from "readline";
30698
+ function publicJwkForDelegation(jwk) {
30699
+ const publicJwk = {};
30700
+ for (const [key, value] of Object.entries(jwk)) {
30701
+ if (!PRIVATE_JWK_FIELDS.has(key)) {
30702
+ publicJwk[key] = value;
30703
+ }
30704
+ }
30705
+ return publicJwk;
30706
+ }
30707
+ function validateDelegationCallbackPayload(value) {
30708
+ if (!value || typeof value !== "object") return "expected an object";
30709
+ const v = value;
30710
+ if (!v.delegationHeader || typeof v.delegationHeader !== "object") {
30711
+ return "delegationHeader must be an object";
30712
+ }
30713
+ const auth = v.delegationHeader.Authorization;
30714
+ if (typeof auth !== "string" || !auth) {
30715
+ return "delegationHeader.Authorization must be a non-empty string";
30716
+ }
30717
+ if (typeof v.delegationCid !== "string" || !v.delegationCid) {
30718
+ return "delegationCid must be a non-empty string";
30719
+ }
30720
+ if (typeof v.spaceId !== "string" || !v.spaceId) {
30721
+ return "spaceId must be a non-empty string";
30722
+ }
30723
+ if (v.permissions !== void 0) {
30724
+ if (!Array.isArray(v.permissions)) {
30725
+ return "permissions, when present, must be an array";
30726
+ }
30727
+ for (let i = 0; i < v.permissions.length; i++) {
30728
+ const entry = v.permissions[i];
30729
+ if (!entry || typeof entry !== "object") {
30730
+ return `permissions[${i}] must be an object`;
30731
+ }
30732
+ const e = entry;
30733
+ if (typeof e.service !== "string" || !e.service) {
30734
+ return `permissions[${i}].service must be a non-empty string`;
30735
+ }
30736
+ if (typeof e.space !== "string") {
30737
+ return `permissions[${i}].space must be a string`;
30738
+ }
30739
+ if (typeof e.path !== "string") {
30740
+ return `permissions[${i}].path must be a string`;
30741
+ }
30742
+ if (!Array.isArray(e.actions) || e.actions.some((a) => typeof a !== "string" || !a)) {
30743
+ return `permissions[${i}].actions must be a non-empty string[]`;
30744
+ }
30745
+ }
30746
+ }
30747
+ return null;
30748
+ }
30749
+ var PRIVATE_JWK_FIELDS;
30750
+ var init_browser_auth = __esm({
30751
+ "src/auth/browser-auth.ts"() {
30752
+ "use strict";
30753
+ init_formatter();
30754
+ init_constants();
30755
+ PRIVATE_JWK_FIELDS = /* @__PURE__ */ new Set([
30756
+ "d",
30757
+ "p",
30758
+ "q",
30759
+ "dp",
30760
+ "dq",
30761
+ "qi",
30762
+ "oth",
30763
+ "k"
30764
+ ]);
30765
+ }
30766
+ });
30767
+
30768
+ // src/auth/device-auth.ts
30769
+ var device_auth_exports = {};
30770
+ __export(device_auth_exports, {
30771
+ SHARE_DEVICE_DELEGATION_SECONDS: () => SHARE_DEVICE_DELEGATION_SECONDS,
30772
+ SHARE_DEVICE_PERMISSIONS: () => SHARE_DEVICE_PERMISSIONS,
30773
+ acquireShareDeviceDelegation: () => acquireShareDeviceDelegation,
30774
+ ensureShareDeviceAuthorization: () => ensureShareDeviceAuthorization,
30775
+ mergePrivateJwkIntoSession: () => mergePrivateJwkIntoSession
30776
+ });
30777
+ import {
30778
+ createDecipheriv,
30779
+ createHash,
30780
+ createHmac,
30781
+ createPublicKey,
30782
+ diffieHellman,
30783
+ generateKeyPairSync,
30784
+ randomBytes as randomBytes4
30785
+ } from "crypto";
30786
+ function digest4(value) {
30787
+ return createHash("sha256").update(value).digest("base64url");
30788
+ }
30789
+ function canonicalOrigin(value, label) {
30790
+ const url = new URL(value);
30791
+ const loopback = url.hostname === "127.0.0.1" || url.hostname === "localhost";
30792
+ if (url.origin !== value || url.protocol !== "https:" && !(loopback && url.protocol === "http:")) {
30793
+ throw new Error(`${label} must be a canonical HTTPS origin`);
30794
+ }
30795
+ return value;
30796
+ }
30797
+ function jsonEqual(left, right) {
30798
+ const canonical = (value) => Array.isArray(value) ? value.map(canonical) : value && typeof value === "object" ? Object.fromEntries(Object.entries(value).sort(([a], [b]) => a.localeCompare(b)).map(([key, entry]) => [key, canonical(entry)])) : value;
30799
+ return JSON.stringify(canonical(left)) === JSON.stringify(canonical(right));
30800
+ }
30801
+ function validateStart(value) {
30802
+ if (!value || typeof value !== "object" || Array.isArray(value)) throw new Error("OpenKey returned an invalid device authorization response");
30803
+ const result = value;
30804
+ if (typeof result.transactionId !== "string" || !/^[A-Za-z0-9_-]{20,}$/.test(result.transactionId) || typeof result.userCode !== "string" || !/^[A-Z2-9]{4}-[A-Z2-9]{4}$/.test(result.userCode) || typeof result.verificationUri !== "string" || typeof result.verificationUriComplete !== "string" || !Number.isSafeInteger(result.expiresIn) || Number(result.expiresIn) < 60 || !Number.isSafeInteger(result.interval) || Number(result.interval) < 1) throw new Error("OpenKey returned an invalid device authorization response");
30805
+ canonicalOrigin(new URL(result.verificationUri).origin, "verification URI");
30806
+ if (new URL(result.verificationUriComplete).origin !== new URL(result.verificationUri).origin) {
30807
+ throw new Error("OpenKey returned an invalid verification URI");
30808
+ }
30809
+ return result;
30810
+ }
30811
+ async function responseJson(response) {
30812
+ try {
30813
+ return await response.json();
30814
+ } catch {
30815
+ throw new Error(`OpenKey device authorization failed (HTTP ${response.status})`);
30816
+ }
30817
+ }
30818
+ function errorCode(value) {
30819
+ return value && typeof value === "object" && typeof value.error === "string" ? value.error : void 0;
30820
+ }
30821
+ function publicSessionJwk(value) {
30822
+ const publicJwk = publicJwkForDelegation(value);
30823
+ const record2 = publicJwk;
30824
+ if (record2.kty !== "OKP" || record2.crv !== "Ed25519" || typeof record2.x !== "string") {
30825
+ throw new Error("CLI session key is not a public Ed25519 JWK");
30826
+ }
30827
+ return publicJwk;
30828
+ }
30829
+ function publicRelayJwk(value) {
30830
+ if (!value || typeof value !== "object" || Array.isArray(value)) throw new Error("OpenKey returned an invalid relay key");
30831
+ const jwk = value;
30832
+ if (jwk.kty !== "EC" || jwk.crv !== "P-256" || typeof jwk.x !== "string" || !/^[A-Za-z0-9_-]{43}$/.test(jwk.x) || typeof jwk.y !== "string" || !/^[A-Za-z0-9_-]{43}$/.test(jwk.y) || "d" in jwk) throw new Error("OpenKey returned an invalid relay key");
30833
+ return { kty: "EC", crv: "P-256", x: jwk.x, y: jwk.y };
30834
+ }
30835
+ function decodeCanonicalBase64Url(value, label) {
30836
+ if (typeof value !== "string" || !/^[A-Za-z0-9_-]+$/.test(value)) throw new Error(`OpenKey returned an invalid ${label}`);
30837
+ const decoded = Buffer.from(value, "base64url");
30838
+ if (decoded.toString("base64url") !== value) throw new Error(`OpenKey returned an invalid ${label}`);
30839
+ return decoded;
30840
+ }
30841
+ function deriveRelayKey(sharedSecret, transactionId) {
30842
+ const extracted = createHmac("sha256", Buffer.from(transactionId)).update(sharedSecret).digest();
30843
+ return createHmac("sha256", extracted).update(Buffer.from("openkey-device-relay-v1")).update(Buffer.from([1])).digest();
30844
+ }
30845
+ function decryptRelayResult(envelope, transactionId, privateKey) {
30846
+ if (!envelope || typeof envelope !== "object" || Array.isArray(envelope)) throw new Error("OpenKey returned an invalid encrypted relay result");
30847
+ const relay = envelope;
30848
+ if (relay.version !== 1 || relay.algorithm !== "ECDH-P256-A256GCM") throw new Error("OpenKey returned an unsupported encrypted relay result");
30849
+ const peer = createPublicKey({ key: publicRelayJwk(relay.ephemeralPublicJwk), format: "jwk" });
30850
+ const nonce = decodeCanonicalBase64Url(relay.nonce, "relay nonce");
30851
+ const ciphertext = decodeCanonicalBase64Url(relay.ciphertext, "relay ciphertext");
30852
+ if (nonce.length !== 12 || ciphertext.length <= 16) throw new Error("OpenKey returned an invalid encrypted relay result");
30853
+ const sharedSecret = diffieHellman({ privateKey, publicKey: peer });
30854
+ const key = deriveRelayKey(sharedSecret, transactionId);
30855
+ const decipher = createDecipheriv("aes-256-gcm", key, nonce);
30856
+ decipher.setAAD(Buffer.from(transactionId));
30857
+ decipher.setAuthTag(ciphertext.subarray(ciphertext.length - 16));
30858
+ let value;
30859
+ try {
30860
+ value = JSON.parse(Buffer.concat([decipher.update(ciphertext.subarray(0, -16)), decipher.final()]).toString("utf8"));
30861
+ } catch {
30862
+ throw new Error("OpenKey returned an unreadable encrypted relay result");
30863
+ }
30864
+ if (!value || typeof value !== "object" || Array.isArray(value)) throw new Error("OpenKey returned an invalid encrypted relay result");
30865
+ return value;
30866
+ }
30867
+ function assertShareDelegationPermissions(value) {
30868
+ if (!Array.isArray(value) || value.length !== 1) throw new Error("OpenKey returned a delegation outside the requested Share scope");
30869
+ const permission = value[0];
30870
+ if (!permission || permission.service !== "tinycloud.capabilities" && permission.service !== "capabilities" || permission.space !== "applications" && !(typeof permission.space === "string" && permission.space.endsWith(":applications")) || permission.path !== "" || !Array.isArray(permission.actions) || permission.actions.length !== 1 || permission.actions[0] !== "tinycloud.capabilities/read") throw new Error("OpenKey returned a delegation outside the requested Share scope");
30871
+ }
30872
+ function assertApprovedBinding(input) {
30873
+ if (input.binding.transactionId !== input.transactionId || input.binding.sessionDid !== input.sessionDid || input.binding.nodeOrigin !== input.nodeOrigin || input.binding.shareOrigin !== input.shareOrigin || !jsonEqual(input.binding.permissions, SHARE_DEVICE_PERMISSIONS)) throw new Error("OpenKey returned a delegation with the wrong device binding");
30874
+ const expiresAt = Date.parse(input.binding.delegationExpiresAt);
30875
+ if (!Number.isFinite(expiresAt) || expiresAt <= Date.now() || expiresAt > Date.now() + SHARE_DEVICE_DELEGATION_SECONDS * 1e3 + 3e4) {
30876
+ throw new Error("OpenKey returned a delegation outside the requested expiry window");
30877
+ }
30878
+ if (input.delegation.verificationMethod !== input.sessionDid) {
30879
+ throw new Error("OpenKey returned a delegation for a different CLI session DID");
30880
+ }
30881
+ assertShareDelegationPermissions(input.delegation.permissions);
30882
+ const delegationExpiryValue = input.delegation.expiresAt ?? input.delegation.expirationTime ?? input.delegation.expiry;
30883
+ const delegationExpiresAt = typeof delegationExpiryValue === "string" ? Date.parse(delegationExpiryValue) : Number.NaN;
30884
+ if (!Number.isFinite(delegationExpiresAt) || delegationExpiresAt !== expiresAt) {
30885
+ throw new Error("OpenKey returned a delegation outside the approved expiry window");
30886
+ }
30887
+ if (!input.delegation.jwk || typeof input.delegation.jwk !== "object" || !jsonEqual(publicSessionJwk(input.delegation.jwk), input.publicJwk)) {
30888
+ throw new Error("OpenKey returned a delegation for a different CLI session key");
30889
+ }
30890
+ const invalid = validateDelegationCallbackPayload(input.delegation);
30891
+ if (invalid) throw new Error(`OpenKey returned an invalid delegation: ${invalid}`);
30892
+ }
30893
+ async function acquireShareDeviceDelegation(input) {
30894
+ const openkeyHost = canonicalOrigin(input.openkeyHost ?? DEFAULT_OPENKEY_DEVICE_API_HOST, "OpenKey host");
30895
+ const nodeOrigin = canonicalOrigin(input.nodeOrigin, "TinyCloud node origin");
30896
+ const shareOrigin = canonicalOrigin(input.shareOrigin, "Share origin");
30897
+ const fetchFn = input.fetchFn ?? globalThis.fetch;
30898
+ const deviceSecret = randomBytes4(32).toString("base64url");
30899
+ const codeVerifier = randomBytes4(32).toString("base64url");
30900
+ const relayKeys = generateKeyPairSync("ec", { namedCurve: "prime256v1" });
30901
+ const relayPublicJwk = publicRelayJwk(relayKeys.publicKey.export({ format: "jwk" }));
30902
+ const publicJwk = publicSessionJwk(input.jwk);
30903
+ const startResponse = await fetchFn(`${openkeyHost}/api/device-authorizations`, {
30904
+ method: "POST",
30905
+ credentials: "omit",
30906
+ redirect: "error",
30907
+ referrerPolicy: "no-referrer",
30908
+ headers: { accept: "application/json", "content-type": "application/json" },
30909
+ body: JSON.stringify({
30910
+ deviceSecretHash: digest4(deviceSecret),
30911
+ codeChallenge: digest4(codeVerifier),
30912
+ relayPublicJwk,
30913
+ sessionDid: input.sessionDid,
30914
+ publicJwk,
30915
+ permissions: SHARE_DEVICE_PERMISSIONS,
30916
+ nodeOrigin,
30917
+ shareOrigin,
30918
+ delegationTtlSeconds: SHARE_DEVICE_DELEGATION_SECONDS
30919
+ })
30920
+ });
30921
+ const startValue = await responseJson(startResponse);
30922
+ if (!startResponse.ok) throw new Error(`OpenKey device authorization failed: ${errorCode(startValue) ?? startResponse.status}`);
30923
+ const started = validateStart(startValue);
30924
+ (input.emitInstructions ?? ((value) => {
30925
+ process.stderr.write(`OpenKey device authorization
30926
+ Visit: ${value.verificationUri}
30927
+ Code: ${value.userCode}
30928
+
30929
+ Waiting for approval\u2026
30930
+ `);
30931
+ }))({ verificationUri: started.verificationUri, verificationUriComplete: started.verificationUriComplete, userCode: started.userCode });
30932
+ const deadline = Date.now() + started.expiresIn * 1e3;
30933
+ let interval = started.interval;
30934
+ const wait = input.wait ?? ((milliseconds) => new Promise((resolve2) => setTimeout(resolve2, milliseconds)));
30935
+ while (Date.now() < deadline) {
30936
+ await wait(interval * 1e3);
30937
+ const response = await fetchFn(`${openkeyHost}/api/device-authorizations/token`, {
30938
+ method: "POST",
30939
+ credentials: "omit",
30940
+ redirect: "error",
30941
+ referrerPolicy: "no-referrer",
30942
+ headers: { accept: "application/json", "content-type": "application/json" },
30943
+ body: JSON.stringify({ transactionId: started.transactionId, deviceSecret, codeVerifier })
30944
+ });
30945
+ const value = await responseJson(response);
30946
+ const code4 = errorCode(value);
30947
+ if (response.status === 429 && code4 === "slow_down") {
30948
+ interval += 1;
30949
+ continue;
30950
+ }
30951
+ if (!response.ok) throw new Error(`OpenKey device authorization failed: ${code4 ?? response.status}`);
30952
+ const result = value;
30953
+ if (result.status === "pending") {
30954
+ interval = Math.max(interval, result.interval);
30955
+ continue;
30956
+ }
30957
+ if (result.status !== "approved" || !result.relay || !result.binding) {
30958
+ throw new Error("OpenKey returned an invalid device authorization result");
30959
+ }
30960
+ const delegation = decryptRelayResult(result.relay, started.transactionId, relayKeys.privateKey);
30961
+ assertApprovedBinding({ binding: result.binding, transactionId: started.transactionId, sessionDid: input.sessionDid, nodeOrigin, shareOrigin, publicJwk, delegation });
30962
+ return delegation;
30963
+ }
30964
+ throw new Error("OpenKey device authorization expired before approval");
30965
+ }
30966
+ function mergePrivateJwkIntoSession(session, key) {
30967
+ const sessionJwk = session.jwk;
30968
+ if (!sessionJwk || typeof sessionJwk !== "object") return session;
30969
+ const sessionJwkRecord = sessionJwk;
30970
+ if (typeof sessionJwkRecord.d === "string" && sessionJwkRecord.d.length > 0) return session;
30971
+ const privateParameter = key.d;
30972
+ if (typeof privateParameter !== "string" || privateParameter.length === 0) return session;
30973
+ return { ...session, jwk: { ...sessionJwkRecord, d: privateParameter } };
30974
+ }
30975
+ async function ensureShareDeviceAuthorization(input) {
30976
+ let profile = await ProfileManager.getProfile(input.profileName).catch(() => null);
30977
+ if (profile?.authMethod === "local" && input.allowReplaceLocal !== true) {
30978
+ throw new Error("This profile uses a local owner key. Run `tc auth login --device` explicitly to replace its authentication posture.");
30979
+ }
30980
+ let key = await ProfileManager.getKey(input.profileName);
30981
+ if (!key) {
30982
+ const generated = generateKey2();
30983
+ key = generated.jwk;
30984
+ await ProfileManager.setKey(input.profileName, key);
30985
+ }
30986
+ const sessionDid = keyToDID(key);
30987
+ profile = {
30988
+ ...profile,
30989
+ name: input.profileName,
30990
+ host: input.nodeOrigin,
30991
+ chainId: profile?.chainId ?? DEFAULT_CHAIN_ID,
30992
+ spaceName: profile?.spaceName ?? "applications",
30993
+ did: sessionDid,
30994
+ sessionDid,
30995
+ createdAt: profile?.createdAt ?? (/* @__PURE__ */ new Date()).toISOString(),
30996
+ posture: "owner-openkey",
30997
+ operatorType: profile?.operatorType ?? "human",
30998
+ authMethod: "openkey",
30999
+ openkeyHost: input.openkeyHost ?? profile?.openkeyHost
31000
+ };
31001
+ await ProfileManager.setProfile(input.profileName, profile);
31002
+ const delegation = await acquireShareDeviceDelegation({
31003
+ sessionDid,
31004
+ jwk: key,
31005
+ nodeOrigin: input.nodeOrigin,
31006
+ shareOrigin: input.shareOrigin,
31007
+ openkeyHost: input.openkeyHost ?? profile.openkeyHost,
31008
+ fetchFn: input.fetchFn,
31009
+ emitInstructions: input.emitInstructions,
31010
+ wait: input.wait
31011
+ });
31012
+ const session = mergePrivateJwkIntoSession(delegation, key);
31013
+ await ProfileManager.setSession(input.profileName, session);
31014
+ const updatedProfile = {
31015
+ ...profile,
31016
+ ownerDid: typeof session.ownerDid === "string" ? session.ownerDid : profile.ownerDid,
31017
+ spaceId: typeof session.spaceId === "string" ? session.spaceId : profile.spaceId
31018
+ };
31019
+ await ProfileManager.setProfile(input.profileName, updatedProfile);
31020
+ return { profile: updatedProfile, delegation: session };
31021
+ }
31022
+ var SHARE_DEVICE_DELEGATION_SECONDS, SHARE_DEVICE_PERMISSIONS;
31023
+ var init_device_auth = __esm({
31024
+ "src/auth/device-auth.ts"() {
31025
+ "use strict";
31026
+ init_constants();
31027
+ init_profiles();
31028
+ init_local_key();
31029
+ init_browser_auth();
31030
+ SHARE_DEVICE_DELEGATION_SECONDS = 30 * 24 * 60 * 60;
31031
+ SHARE_DEVICE_PERMISSIONS = [{
31032
+ service: "tinycloud.capabilities",
31033
+ space: "applications",
31034
+ path: "",
31035
+ actions: ["tinycloud.capabilities/read"]
31036
+ }];
31037
+ }
31038
+ });
31039
+
30659
31040
  // src/index.ts
30660
31041
  init_errors();
30661
31042
  import { readFileSync as readFileSync2 } from "fs";
@@ -30966,11 +31347,11 @@ function parseShareTarget(value) {
30966
31347
  if (value.includes("@")) return { kind: "email", address: value };
30967
31348
  throw new CLIError("INVALID_ARGUMENT", "--to must be anyone, a did:, an email address, or domain:example.com", 2);
30968
31349
  }
30969
- function publishServices() {
31350
+ function publishServices(insecureLocalRegistry = false) {
30970
31351
  return {
30971
31352
  ...shareServices.uploadBlob === void 0 ? {} : { uploadBlob: shareServices.uploadBlob },
30972
31353
  ...shareServices.authorizeUpload === void 0 ? {} : { authorizeUpload: shareServices.authorizeUpload },
30973
- ...shareServices.authorizeUpload === void 0 ? {} : { authorizationOrigin: SHARE_ORIGIN },
31354
+ ...shareServices.authorizeUpload === void 0 || insecureLocalRegistry ? {} : { authorizationOrigin: SHARE_ORIGIN },
30974
31355
  ...shareServices.credentials === void 0 ? {} : { credentials: shareServices.credentials },
30975
31356
  ...shareServices.fetchFn === void 0 ? {} : { fetchFn: shareServices.fetchFn }
30976
31357
  };
@@ -31100,7 +31481,7 @@ function registerShareCommand(program2) {
31100
31481
  allowInsecureRegistry: options.insecureRegistry === true,
31101
31482
  notify: options.notify === true,
31102
31483
  targetAdapter: shareServices.targetAdapter,
31103
- ...publishServices()
31484
+ ...publishServices(options.insecureRegistry === true)
31104
31485
  });
31105
31486
  if ("state" in result) {
31106
31487
  if (json) {
@@ -31204,7 +31585,7 @@ function registerShareCommand(program2) {
31204
31585
  allowInsecureRegistry: options.insecureRegistry === true,
31205
31586
  notify: options.notify === true,
31206
31587
  targetAdapter: shareServices.targetAdapter,
31207
- ...publishServices()
31588
+ ...publishServices(options.insecureRegistry === true)
31208
31589
  });
31209
31590
  if ("state" in result) throw new CLIError(result.method === "openkey-device" ? "DEVICE_AUTH_REQUIRED" : "CLAIM_REQUIRED", "recipient authorization is required; continue through the configured authority adapter", 6);
31210
31591
  const record2 = await rememberPublishedShare(result);
@@ -31287,7 +31668,7 @@ init_profiles();
31287
31668
  init_dist3();
31288
31669
  import { readFile as readFile5, writeFile as writeFile2 } from "fs/promises";
31289
31670
  import { join as join6 } from "path";
31290
- import { createHash } from "crypto";
31671
+ import { createHash as createHash2 } from "crypto";
31291
31672
 
31292
31673
  // ../share-envelope/dist/index.js
31293
31674
  init_zod();
@@ -31768,25 +32149,25 @@ function encodeTo4(int, target, offset = 0) {
31768
32149
  function encodingLength4(int) {
31769
32150
  return varint_default4.encodingLength(int);
31770
32151
  }
31771
- function create4(code23, digest4) {
31772
- const size2 = digest4.byteLength;
32152
+ function create4(code23, digest5) {
32153
+ const size2 = digest5.byteLength;
31773
32154
  const sizeOffset = encodingLength4(code23);
31774
32155
  const digestOffset = sizeOffset + encodingLength4(size2);
31775
32156
  const bytes3 = new Uint8Array(digestOffset + size2);
31776
32157
  encodeTo4(code23, bytes3, 0);
31777
32158
  encodeTo4(size2, bytes3, sizeOffset);
31778
- bytes3.set(digest4, digestOffset);
31779
- return new Digest4(code23, size2, digest4, bytes3);
32159
+ bytes3.set(digest5, digestOffset);
32160
+ return new Digest4(code23, size2, digest5, bytes3);
31780
32161
  }
31781
32162
  function decode43(multihash) {
31782
32163
  const bytes3 = coerce5(multihash);
31783
32164
  const [code23, sizeOffset] = decode33(bytes3);
31784
32165
  const [size2, digestOffset] = decode33(bytes3.subarray(sizeOffset));
31785
- const digest4 = bytes3.subarray(sizeOffset + digestOffset);
31786
- if (digest4.byteLength !== size2) {
32166
+ const digest5 = bytes3.subarray(sizeOffset + digestOffset);
32167
+ if (digest5.byteLength !== size2) {
31787
32168
  throw new Error("Incorrect length");
31788
32169
  }
31789
- return new Digest4(code23, size2, digest4, bytes3);
32170
+ return new Digest4(code23, size2, digest5, bytes3);
31790
32171
  }
31791
32172
  function equals23(a, b) {
31792
32173
  if (a === b) {
@@ -31804,10 +32185,10 @@ var Digest4 = class {
31804
32185
  /**
31805
32186
  * Creates a multihash digest.
31806
32187
  */
31807
- constructor(code23, size2, digest4, bytes3) {
32188
+ constructor(code23, size2, digest5, bytes3) {
31808
32189
  this.code = code23;
31809
32190
  this.size = size2;
31810
- this.digest = digest4;
32191
+ this.digest = digest5;
31811
32192
  this.bytes = bytes3;
31812
32193
  }
31813
32194
  };
@@ -31888,8 +32269,8 @@ var CID4 = class _CID4 {
31888
32269
  toV1() {
31889
32270
  switch (this.version) {
31890
32271
  case 0: {
31891
- const { code: code23, digest: digest4 } = this.multihash;
31892
- const multihash = create4(code23, digest4);
32272
+ const { code: code23, digest: digest5 } = this.multihash;
32273
+ const multihash = create4(code23, digest5);
31893
32274
  return _CID4.createV1(this.code, multihash);
31894
32275
  }
31895
32276
  case 1: {
@@ -31943,8 +32324,8 @@ var CID4 = class _CID4 {
31943
32324
  return new _CID4(version3, code23, multihash, bytes3 ?? encodeCID4(version3, code23, multihash.bytes));
31944
32325
  } else if (value[cidSymbol4] === true) {
31945
32326
  const { version: version3, multihash, code: code23 } = value;
31946
- const digest4 = decode43(multihash);
31947
- return _CID4.create(version3, code23, digest4);
32327
+ const digest5 = decode43(multihash);
32328
+ return _CID4.create(version3, code23, digest5);
31948
32329
  } else {
31949
32330
  return null;
31950
32331
  }
@@ -31954,11 +32335,11 @@ var CID4 = class _CID4 {
31954
32335
  * @param code - Code of the codec content is encoded in, see https://github.com/multiformats/multicodec/blob/master/table.csv
31955
32336
  * @param digest - (Multi)hash of the of the content.
31956
32337
  */
31957
- static create(version3, code23, digest4) {
32338
+ static create(version3, code23, digest5) {
31958
32339
  if (typeof code23 !== "number") {
31959
32340
  throw new Error("String codecs are no longer supported");
31960
32341
  }
31961
- if (!(digest4.bytes instanceof Uint8Array)) {
32342
+ if (!(digest5.bytes instanceof Uint8Array)) {
31962
32343
  throw new Error("Invalid digest");
31963
32344
  }
31964
32345
  switch (version3) {
@@ -31966,12 +32347,12 @@ var CID4 = class _CID4 {
31966
32347
  if (code23 !== DAG_PB_CODE4) {
31967
32348
  throw new Error(`Version 0 CID must use dag-pb (code: ${DAG_PB_CODE4}) block encoding`);
31968
32349
  } else {
31969
- return new _CID4(version3, code23, digest4, digest4.bytes);
32350
+ return new _CID4(version3, code23, digest5, digest5.bytes);
31970
32351
  }
31971
32352
  }
31972
32353
  case 1: {
31973
- const bytes3 = encodeCID4(version3, code23, digest4.bytes);
31974
- return new _CID4(version3, code23, digest4, bytes3);
32354
+ const bytes3 = encodeCID4(version3, code23, digest5.bytes);
32355
+ return new _CID4(version3, code23, digest5, bytes3);
31975
32356
  }
31976
32357
  default: {
31977
32358
  throw new Error("Invalid version");
@@ -31981,8 +32362,8 @@ var CID4 = class _CID4 {
31981
32362
  /**
31982
32363
  * Simplified version of `create` for CIDv0.
31983
32364
  */
31984
- static createV0(digest4) {
31985
- return _CID4.create(0, DAG_PB_CODE4, digest4);
32365
+ static createV0(digest5) {
32366
+ return _CID4.create(0, DAG_PB_CODE4, digest5);
31986
32367
  }
31987
32368
  /**
31988
32369
  * Simplified version of `create` for CIDv1.
@@ -31990,8 +32371,8 @@ var CID4 = class _CID4 {
31990
32371
  * @param code - Content encoding format code.
31991
32372
  * @param digest - Multihash of the content.
31992
32373
  */
31993
- static createV1(code23, digest4) {
31994
- return _CID4.create(1, code23, digest4);
32374
+ static createV1(code23, digest5) {
32375
+ return _CID4.create(1, code23, digest5);
31995
32376
  }
31996
32377
  /**
31997
32378
  * Decoded a CID from its binary representation. The byte array must contain
@@ -32024,8 +32405,8 @@ var CID4 = class _CID4 {
32024
32405
  throw new Error("Incorrect length");
32025
32406
  }
32026
32407
  const digestBytes3 = multihashBytes.subarray(specs.multihashSize - specs.digestSize);
32027
- const digest4 = new Digest4(specs.multihashCode, specs.digestSize, digestBytes3, multihashBytes);
32028
- const cid2 = specs.version === 0 ? _CID4.createV0(digest4) : _CID4.createV1(specs.codec, digest4);
32408
+ const digest5 = new Digest4(specs.multihashCode, specs.digestSize, digestBytes3, multihashBytes);
32409
+ const cid2 = specs.version === 0 ? _CID4.createV0(digest5) : _CID4.createV1(specs.codec, digest5);
32029
32410
  return [cid2, bytes3.subarray(specs.size)];
32030
32411
  }
32031
32412
  /**
@@ -32645,6 +33026,7 @@ var MAX_INLINE_BYTES2 = 256 * 1024;
32645
33026
 
32646
33027
  // src/share/adapters.ts
32647
33028
  init_dist4();
33029
+ init_constants();
32648
33030
  var DEFAULT_SHARE_ORIGIN = "https://share.tinycloud.xyz";
32649
33031
  var ShareAuthorityError = class extends Error {
32650
33032
  code;
@@ -32724,8 +33106,8 @@ function createEncryptedProfileHistory(profileName, sessionSigner) {
32724
33106
  const derive = async (salt, legacy = false) => {
32725
33107
  const secret = await profileSecret();
32726
33108
  if (legacy) {
32727
- const digest4 = await crypto.subtle.digest("SHA-256", secret);
32728
- return crypto.subtle.importKey("raw", digest4, { name: "AES-GCM" }, false, ["encrypt", "decrypt"]);
33109
+ const digest5 = await crypto.subtle.digest("SHA-256", secret);
33110
+ return crypto.subtle.importKey("raw", digest5, { name: "AES-GCM" }, false, ["encrypt", "decrypt"]);
32729
33111
  }
32730
33112
  const material = await crypto.subtle.importKey("raw", secret, "PBKDF2", false, ["deriveKey"]);
32731
33113
  return crypto.subtle.deriveKey({ name: "PBKDF2", salt, iterations: 1e5, hash: "SHA-256" }, material, { name: "AES-GCM", length: 256 }, false, ["encrypt", "decrypt"]);
@@ -32796,7 +33178,7 @@ function createEncryptedProfileHistory(profileName, sessionSigner) {
32796
33178
  function createShareAuthorityAdapters(input = {}) {
32797
33179
  const origin = input.origin ?? DEFAULT_SHARE_ORIGIN;
32798
33180
  const fetchFn = input.fetchFn ?? globalThis.fetch;
32799
- const canonicalOrigin = (value, label) => {
33181
+ const canonicalOrigin2 = (value, label) => {
32800
33182
  if (typeof value !== "string") throw new Error(`share ${label} is unavailable`);
32801
33183
  const parsed = new URL(value);
32802
33184
  const loopback = parsed.hostname === "127.0.0.1" || parsed.hostname === "localhost";
@@ -32821,17 +33203,17 @@ function createShareAuthorityAdapters(input = {}) {
32821
33203
  if (decoded.length !== 32 || Buffer.from(decoded).toString("base64url") !== key) throw new Error("share node receipt key is invalid");
32822
33204
  return decoded;
32823
33205
  };
32824
- const nodeOrigin = canonicalOrigin(input.nodeOrigin ?? object3.nodeOrigin, "node origin");
33206
+ const nodeOrigin = canonicalOrigin2(input.nodeOrigin ?? object3.nodeOrigin, "node origin");
32825
33207
  const nodeAudience = typeof object3.nodeAudience === "string" ? object3.nodeAudience : "";
32826
33208
  const enforcerDid = typeof object3.enforcerDid === "string" ? object3.enforcerDid : nodeAudience;
32827
33209
  const nodeInvitationKid = typeof object3.nodeInvitationKid === "string" ? object3.nodeInvitationKid : "";
32828
33210
  if (!nodeAudience.startsWith("did:web:") || !nodeInvitationKid.startsWith(`${nodeAudience}#`) || !enforcerDid.startsWith("did:key:") && enforcerDid !== nodeAudience) throw new Error("share node trust binding is invalid");
32829
33211
  return {
32830
- shareOrigin: canonicalOrigin(object3.shareOrigin, "origin"),
32831
- registryOrigin: canonicalOrigin(object3.registryOrigin, "registry origin"),
33212
+ shareOrigin: canonicalOrigin2(object3.shareOrigin, "origin"),
33213
+ registryOrigin: canonicalOrigin2(object3.registryOrigin, "registry origin"),
32832
33214
  nodeOrigin,
32833
- emailOrigin: canonicalOrigin(input.emailOrigin ?? object3.emailOrigin, "email origin"),
32834
- credentialsOrigin: canonicalOrigin(object3.credentialsOrigin, "credentials origin"),
33215
+ emailOrigin: canonicalOrigin2(input.emailOrigin ?? object3.emailOrigin, "email origin"),
33216
+ credentialsOrigin: canonicalOrigin2(object3.credentialsOrigin, "credentials origin"),
32835
33217
  nodeAudience,
32836
33218
  enforcerDid,
32837
33219
  nodeInvitationKid,
@@ -33065,7 +33447,12 @@ function createShareAuthorityAdapters(input = {}) {
33065
33447
  return {
33066
33448
  targetAdapter,
33067
33449
  authorization,
33068
- records: input.profileName === void 0 ? createEncryptedSessionHistory() : createEncryptedProfileHistory(input.profileName, async (bytes3) => (await authenticatedNode()).signSessionBytes(bytes3)),
33450
+ records: input.profileName === void 0 ? createEncryptedSessionHistory() : createEncryptedProfileHistory(input.profileName, async (bytes3) => {
33451
+ const profileName = await input.profileName();
33452
+ const context = await ProfileManager.resolveContext({ profile: profileName });
33453
+ const { ensureAuthenticated: ensureAuthenticated2 } = await Promise.resolve().then(() => (init_sdk(), sdk_exports));
33454
+ return (await ensureAuthenticated2(context)).signSessionBytes(bytes3);
33455
+ }),
33069
33456
  delivery,
33070
33457
  revocation,
33071
33458
  legacyReader,
@@ -33094,7 +33481,7 @@ function canonicalNodeAudience(origin) {
33094
33481
  return `did:web:${new URL(origin).hostname}`;
33095
33482
  }
33096
33483
  function base64UrlSha256(value) {
33097
- return createHash("sha256").update(value).digest("base64url");
33484
+ return createHash2("sha256").update(value).digest("base64url");
33098
33485
  }
33099
33486
  async function authenticatedNodeForProfile(profileName, host) {
33100
33487
  const context = await ProfileManager.resolveContext({ profile: profileName, host });
@@ -33175,14 +33562,33 @@ function createProductionUploadAuthorizer(input = {}) {
33175
33562
  if (input.testOnly === true) {
33176
33563
  const suppliedSession = input.sessionAuthorization === void 0 ? void 0 : await input.sessionAuthorization();
33177
33564
  if (suppliedSession !== void 0) return suppliedSession;
33178
- const acquired = await input.acquireUploadAuthorization?.({ profileName, upload });
33179
- if (acquired !== void 0) return acquired;
33565
+ const acquired2 = await input.acquireUploadAuthorization?.({ profileName, upload });
33566
+ if (acquired2 !== void 0) return acquired2;
33180
33567
  }
33181
- const profile = await ProfileManager.getProfile(profileName).catch(() => {
33182
- throw new ShareAuthorityError("AUTH_REQUIRED", "share upload requires an initialized profile");
33568
+ const existing = await ProfileManager.getProfile(profileName).catch(() => null);
33569
+ if (existing?.authMethod === "openkey") {
33570
+ try {
33571
+ return await openKeyUploadAuthorization({ fetchFn, origin, profileName, upload, node: await authenticatedNodeForProfile(profileName, existing.host) });
33572
+ } catch (error) {
33573
+ if (!(error instanceof ShareAuthorityError) || error.code !== "AUTH_REQUIRED") throw error;
33574
+ }
33575
+ }
33576
+ const { ensureShareDeviceAuthorization: ensureShareDeviceAuthorization2 } = await Promise.resolve().then(() => (init_device_auth(), device_auth_exports));
33577
+ const nodeOrigin = await (input.nodeOrigin?.() ?? Promise.resolve(existing?.host ?? process.env.TC_HOST ?? DEFAULT_HOST));
33578
+ const acquired = await ensureShareDeviceAuthorization2({
33579
+ profileName,
33580
+ nodeOrigin,
33581
+ shareOrigin: origin,
33582
+ openkeyHost: process.env.TC_OPENKEY_HOST ?? existing?.openkeyHost,
33583
+ fetchFn
33584
+ });
33585
+ return openKeyUploadAuthorization({
33586
+ fetchFn,
33587
+ origin,
33588
+ profileName,
33589
+ upload,
33590
+ node: await authenticatedNodeForProfile(profileName, acquired.profile.host)
33183
33591
  });
33184
- if (profile.authMethod === "openkey") return openKeyUploadAuthorization({ fetchFn, origin, profileName, upload, node: await authenticatedNodeForProfile(profileName, profile.host) });
33185
- throw new ShareAuthorityError("AUTH_REQUIRED", "share upload requires an active OpenKey session");
33186
33592
  };
33187
33593
  }
33188
33594
 
@@ -33204,6 +33610,15 @@ function selectedShareProfile() {
33204
33610
  }
33205
33611
  return process.env.TC_PROFILE;
33206
33612
  }
33613
+ function selectedShareHost() {
33614
+ const args = process.argv.slice(2);
33615
+ for (let index = 0; index < args.length; index += 1) {
33616
+ const value = args[index];
33617
+ if (value === "--host" || value === "-H") return args[index + 1];
33618
+ if (value?.startsWith("--host=")) return value.slice("--host=".length);
33619
+ }
33620
+ return process.env.TC_HOST;
33621
+ }
33207
33622
  program.name("tc").description("TinyCloud CLI \u2014 self-sovereign storage from the terminal").version(version2).option("-p, --profile <name>", "Profile to use").option("-H, --host <url>", "TinyCloud node URL").option("-v, --verbose", "Enable verbose output").option("--no-cache", "Disable caching").option("-q, --quiet", "Suppress non-essential output").option("--json", "Force JSON output");
33208
33623
  program.hook("preAction", async (thisCommand) => {
33209
33624
  const opts = thisCommand.optsWithGlobals();
@@ -33239,7 +33654,8 @@ configureShareCommandServices({
33239
33654
  // touches profile state, and no secret is serialized into a publish result.
33240
33655
  authorizeUpload: createProductionUploadAuthorizer({
33241
33656
  fetchFn: globalThis.fetch,
33242
- profileName: async () => selectedShareProfile() ?? (await ProfileManager.getConfig()).defaultProfile
33657
+ profileName: async () => selectedShareProfile() ?? (await ProfileManager.getConfig()).defaultProfile,
33658
+ nodeOrigin: async () => selectedShareHost() ?? (await ProfileManager.resolveContext({ profile: selectedShareProfile() })).host
33243
33659
  }),
33244
33660
  targetAdapter: shareAuthority.targetAdapter,
33245
33661
  authorization: shareAuthority.authorization,