buckyos 0.7.140 → 0.7.142

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.
Files changed (44) hide show
  1. package/cli/core/auth.ts +2 -3
  2. package/cli/dist/cli.mjs +3 -4
  3. package/cli/dist/cli.mjs.map +1 -1
  4. package/cli/version.ts +1 -1
  5. package/dist/account.d.ts +0 -2
  6. package/dist/account.d.ts.map +1 -1
  7. package/dist/browser.cjs +1 -1
  8. package/dist/browser.mjs +14 -15
  9. package/dist/{executor_client-978a8e1b.js → executor_client-b3ff97ba.js} +8 -8
  10. package/dist/executor_client-b3ff97ba.js.map +1 -0
  11. package/dist/{executor_client-d2c9e854.mjs → executor_client-eb372968.mjs} +56 -152
  12. package/dist/executor_client-eb372968.mjs.map +1 -0
  13. package/dist/index.cjs +1 -1
  14. package/dist/index.mjs +14 -15
  15. package/dist/namelib.d.ts +1 -10
  16. package/dist/namelib.d.ts.map +1 -1
  17. package/dist/ndn_types-08dc9ef1.js +2 -0
  18. package/dist/ndn_types-08dc9ef1.js.map +1 -0
  19. package/dist/{ndn_types-dcb74613.mjs → ndn_types-bbb1f6a6.mjs} +54 -101
  20. package/dist/ndn_types-bbb1f6a6.mjs.map +1 -0
  21. package/dist/node.cjs +1 -1
  22. package/dist/node.mjs +14 -15
  23. package/dist/provision.cjs +2 -2
  24. package/dist/provision.cjs.map +1 -1
  25. package/dist/provision.mjs +18 -12
  26. package/dist/provision.mjs.map +1 -1
  27. package/dist/provision_activate.d.ts.map +1 -1
  28. package/dist/runtime.d.ts +1 -4
  29. package/dist/runtime.d.ts.map +1 -1
  30. package/dist/sdk_core.d.ts.map +1 -1
  31. package/dist/{tus_client-a2f73d53.js → tus_client-65c5fc5e.js} +2 -2
  32. package/dist/{tus_client-a2f73d53.js.map → tus_client-65c5fc5e.js.map} +1 -1
  33. package/dist/{tus_client-8fd4d937.mjs → tus_client-d313689e.mjs} +2 -2
  34. package/dist/{tus_client-8fd4d937.mjs.map → tus_client-d313689e.mjs.map} +1 -1
  35. package/dist/types.d.ts +0 -9
  36. package/dist/types.d.ts.map +1 -1
  37. package/dist/verify-hub-client.d.ts +1 -9
  38. package/dist/verify-hub-client.d.ts.map +1 -1
  39. package/package.json +1 -1
  40. package/dist/executor_client-978a8e1b.js.map +0 -1
  41. package/dist/executor_client-d2c9e854.mjs.map +0 -1
  42. package/dist/ndn_types-324121ae.js +0 -2
  43. package/dist/ndn_types-324121ae.js.map +0 -1
  44. package/dist/ndn_types-dcb74613.mjs.map +0 -1
@@ -35,7 +35,7 @@ var __privateMethod = (obj, member, method) => {
35
35
  return method;
36
36
  };
37
37
  var _listener, _listeners, _cancelled, _allowInsecure, _gzip, _headers, _method, _timeout, _url, _body, _bodyType, _creds, _preflight, _process, _retry, _signal, _throttle, _getUrlFunc, _send, send_fn, _statusCode, _statusMessage, _headers2, _body2, _request, _error, _names, _data, _dataLength, _writeData, writeData_fn, _data2, _offset, _bytesRead, _parent, _maxInflation, _incrementBytesRead, incrementBytesRead_fn, _peekBytes, peekBytes_fn, _r, _s, _v, _networkV, _privateKey, _options, _type, _to, _data3, _nonce, _gasLimit, _gasPrice, _maxPriorityFeePerGas, _maxFeePerGas, _value, _chainId, _sig, _accessList, _maxFeePerBlobGas, _blobVersionedHashes, _kzg, _blobs, _auths, _blobWrapperVersion, _getSerialized, getSerialized_fn, _types, _fullTypes, _encoderCache, _getEncoder, getEncoder_fn, _offset2, _tokens, _subTokenString, subTokenString_fn, _walkAsync, walkAsync_fn, _getCoder, getCoder_fn, _errors, _events, _functions, _abiCoder, _getFunction, getFunction_fn, _getEvent, getEvent_fn, _transactions, _logs, _startBlock, _iface, _iface2, _filter, _a, _supports2544, _resolver, _fetch, fetch_fn, _getResolver, getResolver_fn, _url2, _processFunc, _name, _chainId2, _plugins, _provider, _poller, _interval, _blockNumber, _poll, poll_fn, _provider2, _poll2, _running, _tag, _lastBlock, _filter2, _hash, _provider3, _filter3, _poller2, _running2, _blockNumber2, _poll3, poll_fn2, _subs, _plugins2, _pausedState, _destroyed, _networkPromise, _anyNetwork, _performCache, _lastBlockNumber, _nextTimer, _timers, _disableCcipRead, _requestRate, _requestTimes, _options2, _getDelay, getDelay_fn, _perform, perform_fn, _call, call_fn, _checkNetwork, checkNetwork_fn, _getAccountValue, getAccountValue_fn, _getBlock, getBlock_fn, _hasSub, hasSub_fn, _getSub, getSub_fn, _throwUnsupported, throwUnsupported_fn, _provider4, _filterIdPromise, _poller3, _running3, _network, _hault, _poll4, poll_fn3, _teardown, teardown_fn, _event, _options3, _nextId, _payloads, _drainTimer, _notReady, _network2, _pendingDetectNetwork, _scheduleDrain, scheduleDrain_fn, _pollingInterval, _connect, _signingKey, _data4, _checksum, _words, _loadWords, loadWords_fn, _account, account_fn, _fromSeed, fromSeed_fn, _fromAccount, fromAccount_fn;
38
- import { v as DID, w as getBrowserIdentityRaw, x as clearBrowserUserInfo, y as saveBrowserIdentity, z as saveBrowserUserInfo, A as getBrowserUserInfo, B as clearBrowserIdentity, q as parseBuckyOSOwnerDocument, h as hashPassword, C as saveLocalAccountInfo, E as cleanLocalAccountInfo, F as canonicalize, G as signJwtEdDSA, H as ChunkId, I as sha256Bytes, J as FileObject, O as ObjId, K as DirObject, S as SimpleChunkList } from "./ndn_types-dcb74613.mjs";
38
+ import { u as DID, v as getBrowserIdentityRaw, w as clearBrowserUserInfo, x as saveBrowserIdentity, y as saveBrowserUserInfo, z as getBrowserUserInfo, A as clearBrowserIdentity, N as NODE_IDENTITY_SCHEMA_V2, f as isBuckyOSLocalNodeIdentityConfig, o as parseBuckyOSOwnerDocument, h as hashPassword, B as saveLocalAccountInfo, C as cleanLocalAccountInfo, E as canonicalize, F as signJwtEdDSA, G as ChunkId, H as sha256Bytes, I as FileObject, O as ObjId, J as DirObject, S as SimpleChunkList } from "./ndn_types-bbb1f6a6.mjs";
39
39
  class RPCError extends Error {
40
40
  constructor(message, code, data) {
41
41
  super(message);
@@ -497,21 +497,6 @@ class VerifyHubClient {
497
497
  }
498
498
  return this.rpcClient.call("verify_token", payload);
499
499
  }
500
- static normalizeLoginResponse(response) {
501
- if ("user_info" in response) {
502
- return {
503
- user_name: response.user_info.show_name,
504
- user_id: response.user_info.user_id,
505
- user_type: response.user_info.user_type,
506
- session_token: response.session_token,
507
- refresh_token: response.refresh_token
508
- };
509
- }
510
- if (!response.session_token) {
511
- throw new RPCError("login_by_password response missing session_token");
512
- }
513
- return response;
514
- }
515
500
  }
516
501
  const TASK_MANAGER_SERVICE_UNIQUE_ID = "task-manager";
517
502
  const TASK_MANAGER_SERVICE_NAME = "task-manager";
@@ -3926,27 +3911,22 @@ class BuckyOSRuntime {
3926
3911
  }, claims, material.keyPem);
3927
3912
  }
3928
3913
  async loadLocalSigningMaterial() {
3929
- await importNodeModule$1("node:fs/promises");
3930
3914
  const path = await importNodeModule$1("node:path");
3931
3915
  const configuredUserId = this.getOwnerUserId();
3932
3916
  if (!configuredUserId) {
3933
3917
  const etcDir = await this.getBuckyOSEtcDir();
3934
- const deviceName = await this.readDeviceNameFromNodeIdentityPath(path.join(etcDir, "node_identity.json"));
3935
- if (!deviceName) {
3936
- throw new Error(`failed to resolve userid from ${path.join(etcDir, "node_identity.json")} device_mini_doc_jwt`);
3918
+ const nodeIdentityPath = path.join(etcDir, "node_identity.json");
3919
+ const metadata = await this.readNodeIdentityMetadata(nodeIdentityPath);
3920
+ if (!metadata) {
3921
+ throw new Error(`failed to load ${NODE_IDENTITY_SCHEMA_V2} node identity from ${nodeIdentityPath}`);
3937
3922
  }
3938
- const keyPem = await this.readPemFile(path.join(etcDir, "node_private_key.pem"));
3939
- if (!keyPem) {
3940
- throw new Error(`failed to load node_private_key.pem from ${etcDir}`);
3923
+ const material = await this.loadDeviceSigningMaterial(etcDir, metadata);
3924
+ if (!material) {
3925
+ throw new Error(`failed to load authentication private key of ${metadata.deviceDid}`);
3941
3926
  }
3942
- this.config.userid = deviceName;
3943
- this.config.ownerUserId = deviceName;
3944
- return {
3945
- keyPem,
3946
- issuer: deviceName,
3947
- subject: deviceName,
3948
- sourcePath: path.join(etcDir, "node_private_key.pem")
3949
- };
3927
+ this.config.userid = metadata.deviceName;
3928
+ this.config.ownerUserId = metadata.deviceName;
3929
+ return material;
3950
3930
  }
3951
3931
  const roots = await this.getPrivateKeySearchRoots();
3952
3932
  const deviceMaterial = await this.tryLoadDeviceSigningMaterial(configuredUserId, roots);
@@ -4005,45 +3985,19 @@ class BuckyOSRuntime {
4005
3985
  async readNodeIdentityMetadata(nodeIdentityPath) {
4006
3986
  const fs = await importNodeModule$1("node:fs/promises");
4007
3987
  try {
4008
- const raw = await fs.readFile(nodeIdentityPath, "utf8");
4009
- const parsed = JSON.parse(raw);
4010
- const deviceName = this.extractDeviceNameFromIdentityPayload(parsed);
3988
+ const parsed = JSON.parse(await fs.readFile(nodeIdentityPath, "utf8"));
3989
+ if (!isBuckyOSLocalNodeIdentityConfig(parsed)) {
3990
+ return null;
3991
+ }
4011
3992
  return {
4012
- deviceName,
4013
- deviceDid: typeof parsed.device_did === "string" ? parsed.device_did.trim() || null : null,
4014
- zoneDid: typeof parsed.zone_did === "string" ? parsed.zone_did.trim() || null : null,
4015
- zoneName: typeof parsed.zone_name === "string" ? parsed.zone_name.trim() || null : null
3993
+ deviceName: parsed.device_name,
3994
+ deviceDid: parsed.device_did,
3995
+ zoneDid: parsed.zone_did
4016
3996
  };
4017
3997
  } catch {
4018
3998
  return null;
4019
3999
  }
4020
4000
  }
4021
- extractDeviceNameFromIdentityPayload(payload) {
4022
- const directName = typeof payload.device_name === "string" ? payload.device_name.trim() : "";
4023
- if (directName) {
4024
- return directName;
4025
- }
4026
- const miniDocJwt = typeof payload.device_mini_doc_jwt === "string" ? payload.device_mini_doc_jwt : null;
4027
- const miniDocClaims = parseSessionTokenClaims(miniDocJwt);
4028
- const miniDocName = typeof (miniDocClaims == null ? void 0 : miniDocClaims.n) === "string" ? miniDocClaims.n.trim() : "";
4029
- if (miniDocName) {
4030
- return miniDocName;
4031
- }
4032
- const deviceDocJwt = typeof payload.device_doc_jwt === "string" ? payload.device_doc_jwt : null;
4033
- const deviceDocClaims = parseSessionTokenClaims(deviceDocJwt);
4034
- for (const claimKey of ["name", "sub"]) {
4035
- const claimValue = deviceDocClaims == null ? void 0 : deviceDocClaims[claimKey];
4036
- const candidate = typeof claimValue === "string" ? claimValue.trim() : "";
4037
- if (candidate) {
4038
- return candidate;
4039
- }
4040
- }
4041
- return null;
4042
- }
4043
- async readDeviceNameFromNodeIdentityPath(nodeIdentityPath) {
4044
- const metadata = await this.readNodeIdentityMetadata(nodeIdentityPath);
4045
- return (metadata == null ? void 0 : metadata.deviceName) ?? null;
4046
- }
4047
4001
  async tryLoadDeviceSigningMaterial(userId, roots) {
4048
4002
  const path = await importNodeModule$1("node:path");
4049
4003
  const candidateDirs = [
@@ -4052,44 +4006,41 @@ class BuckyOSRuntime {
4052
4006
  ];
4053
4007
  for (const dir of Array.from(new Set(candidateDirs))) {
4054
4008
  const metadata = await this.readNodeIdentityMetadata(path.join(dir, "node_identity.json"));
4055
- const deviceName = (metadata == null ? void 0 : metadata.deviceName) ?? null;
4056
- if (!deviceName || deviceName !== userId) {
4009
+ if (!metadata || metadata.deviceName !== userId) {
4057
4010
  continue;
4058
4011
  }
4059
- for (const keyPath of await this.deviceKeyPathCandidates(dir, (metadata == null ? void 0 : metadata.deviceDid) ?? null)) {
4060
- const keyPem = await this.readPemFile(keyPath);
4061
- if (!keyPem) {
4062
- continue;
4063
- }
4064
- return {
4065
- keyPem,
4066
- issuer: deviceName,
4067
- subject: deviceName,
4068
- sourcePath: keyPath
4069
- };
4012
+ const material = await this.loadDeviceSigningMaterial(dir, metadata);
4013
+ if (material) {
4014
+ return material;
4070
4015
  }
4071
4016
  }
4072
4017
  return null;
4073
4018
  }
4074
- // node_identity schema v2 stores the device authentication key in the
4075
- // identity-roots security dir (keyed by the device DID); v1 layouts keep a
4076
- // node_private_key.pem next to node_identity.json.
4077
- async deviceKeyPathCandidates(identityDir, deviceDid) {
4019
+ // The device authentication key lives in the identity-roots security dir,
4020
+ // keyed by the device DID.
4021
+ async loadDeviceSigningMaterial(identityDir, metadata) {
4078
4022
  const path = await importNodeModule$1("node:path");
4079
- const candidates = [];
4080
- if (deviceDid) {
4081
- try {
4082
- const dirName = DID.fromStr(deviceDid).toFilename();
4083
- const keyFileName = "authentication.private.pem";
4084
- candidates.push(path.join(identityDir, "security", dirName, keyFileName));
4085
- const env = getProcessEnv();
4086
- const securityRoot = trimToNull$2(env.BUCKYOS_SECURITY_ROOT) ?? path.join(trimToNull$2(env.BUCKYOS_ROOT) ?? "/opt/buckyos", "security");
4087
- candidates.push(path.join(securityRoot, dirName, keyFileName));
4088
- } catch {
4023
+ const dirName = DID.fromStr(metadata.deviceDid).toFilename();
4024
+ const keyFileName = "authentication.private.pem";
4025
+ const securityRoot = trimToNull$2(getProcessEnv().BUCKYOS_SECURITY_ROOT) ?? path.join(await this.getBuckyOSRootDir(), "security");
4026
+ const keyPaths = [
4027
+ // dev/test layout: security root under the node dir itself
4028
+ path.join(identityDir, "security", dirName, keyFileName),
4029
+ // deployed layout: $BUCKYOS_SECURITY_ROOT or $BUCKYOS_ROOT/security
4030
+ path.join(securityRoot, dirName, keyFileName)
4031
+ ];
4032
+ for (const keyPath of keyPaths) {
4033
+ const keyPem = await this.readPemFile(keyPath);
4034
+ if (keyPem) {
4035
+ return {
4036
+ keyPem,
4037
+ issuer: metadata.deviceName,
4038
+ subject: metadata.deviceName,
4039
+ sourcePath: keyPath
4040
+ };
4089
4041
  }
4090
4042
  }
4091
- candidates.push(path.join(identityDir, "node_private_key.pem"));
4092
- return candidates;
4043
+ return null;
4093
4044
  }
4094
4045
  async tryLoadUserSigningMaterial(userId, roots) {
4095
4046
  var _a2;
@@ -4121,35 +4072,6 @@ class BuckyOSRuntime {
4121
4072
  }
4122
4073
  return null;
4123
4074
  }
4124
- async tryResolveDeviceNameFromSearchRoots(roots) {
4125
- const path = await importNodeModule$1("node:path");
4126
- const env = getProcessEnv();
4127
- const fromEnv = trimToNull$2(env.BUCKYOS_THIS_DEVICE_NAME);
4128
- if (fromEnv) {
4129
- return fromEnv;
4130
- }
4131
- for (const key of ["BUCKYOS_THIS_DEVICE", "BUCKYOS_THIS_DEVICE_INFO"]) {
4132
- const raw = trimToNull$2(env[key]);
4133
- if (!raw) {
4134
- continue;
4135
- }
4136
- try {
4137
- const parsed = JSON.parse(raw);
4138
- if (typeof parsed.name === "string" && parsed.name.trim().length > 0) {
4139
- return parsed.name.trim();
4140
- }
4141
- } catch {
4142
- }
4143
- }
4144
- for (const root of roots) {
4145
- const nodeIdentityPath = path.join(root, "node_identity.json");
4146
- const deviceName = await this.readDeviceNameFromNodeIdentityPath(nodeIdentityPath);
4147
- if (deviceName) {
4148
- return deviceName;
4149
- }
4150
- }
4151
- return null;
4152
- }
4153
4075
  async tryResolveZoneHostFromSearchRoots(roots) {
4154
4076
  var _a2;
4155
4077
  const fs = await importNodeModule$1("node:fs/promises");
@@ -4162,16 +4084,9 @@ class BuckyOSRuntime {
4162
4084
  for (const root of roots) {
4163
4085
  const nodeIdentityPath = path.join(root, "node_identity.json");
4164
4086
  const metadata = await this.readNodeIdentityMetadata(nodeIdentityPath);
4165
- if (!metadata) {
4166
- continue;
4087
+ if (metadata) {
4088
+ return resolveZoneHostFromDid(metadata.zoneDid);
4167
4089
  }
4168
- if (metadata.zoneName) {
4169
- return metadata.zoneName;
4170
- }
4171
- if (!metadata.zoneDid) {
4172
- continue;
4173
- }
4174
- return resolveZoneHostFromDid(metadata.zoneDid);
4175
4090
  }
4176
4091
  for (const root of roots) {
4177
4092
  const userConfigPath = path.join(root, "user_config.json");
@@ -5129,7 +5044,6 @@ class BuckyOSSDK {
5129
5044
  var _a2;
5130
5045
  const finalConfig = this.buildRuntimeConfig(appid, config);
5131
5046
  if (this.target !== "node" && isBrowserRuntime() && !config) {
5132
- localStorage.removeItem("zone_host_name");
5133
5047
  let zoneHostName = localStorage.getItem("zone_host_name_v2");
5134
5048
  if (zoneHostName) {
5135
5049
  finalConfig.zoneHost = zoneHostName;
@@ -5269,20 +5183,19 @@ class BuckyOSSDK {
5269
5183
  try {
5270
5184
  const verifyHubClient = this.getVerifyHubClient();
5271
5185
  verifyHubClient.setSeq(loginNonce);
5272
- const accountResponse = await verifyHubClient.loginByPassword({
5186
+ const response = await verifyHubClient.loginByPassword({
5273
5187
  username,
5274
5188
  password: passwordHash,
5275
5189
  target: resolvedTarget,
5276
5190
  login_nonce: loginNonce,
5277
5191
  source_url: typeof window !== "undefined" ? window.location.href : void 0
5278
5192
  });
5279
- const normalized = VerifyHubClient.normalizeLoginResponse(accountResponse);
5280
5193
  const accountInfo = {
5281
- user_name: normalized.user_name,
5282
- user_id: normalized.user_id,
5283
- user_type: normalized.user_type,
5284
- session_token: normalized.session_token,
5285
- refresh_token: normalized.refresh_token
5194
+ user_name: response.user_info.show_name,
5195
+ user_id: response.user_info.user_id,
5196
+ user_type: response.user_info.user_type,
5197
+ session_token: response.session_token,
5198
+ refresh_token: response.refresh_token
5286
5199
  };
5287
5200
  if (isBrowserStorageAvailable()) {
5288
5201
  saveLocalAccountInfo(appId, accountInfo);
@@ -5290,7 +5203,7 @@ class BuckyOSSDK {
5290
5203
  saveBrowserUserInfo({
5291
5204
  user_name: accountInfo.user_name,
5292
5205
  user_id: accountInfo.user_id,
5293
- user_type: normalized.user_type
5206
+ user_type: response.user_info.user_type
5294
5207
  });
5295
5208
  }
5296
5209
  this.currentAccountInfo = accountInfo;
@@ -5573,16 +5486,7 @@ class BuckyOSSDK {
5573
5486
  }
5574
5487
  const doc = await response.json();
5575
5488
  const hostname = typeof doc.hostname === "string" ? doc.hostname.trim() : "";
5576
- if (hostname.length > 0) {
5577
- return hostname;
5578
- }
5579
- if (typeof doc.id === "string") {
5580
- const match = doc.id.match(/^did:web:([^/?#]+)/);
5581
- if (match && match[1]) {
5582
- return match[1];
5583
- }
5584
- }
5585
- return null;
5489
+ return hostname.length > 0 ? hostname : null;
5586
5490
  } catch {
5587
5491
  return null;
5588
5492
  }
@@ -28627,7 +28531,7 @@ async function uploadChunkViaTus(endpoint, file, chunkInfo, chunkIndex, fileHash
28627
28531
  const logicalPath = chunkInfo.chunkId;
28628
28532
  let tusModule;
28629
28533
  try {
28630
- tusModule = await import("./tus_client-8fd4d937.mjs");
28534
+ tusModule = await import("./tus_client-d313689e.mjs");
28631
28535
  } catch (error) {
28632
28536
  const message = error instanceof Error ? error.message : String(error);
28633
28537
  throw new NdmError("UPLOAD_FAILED", `Failed to load tus-js-client: ${message}`);
@@ -29927,4 +29831,4 @@ export {
29927
29831
  NOTIFY_TEXT_CONTROL_ID as y,
29928
29832
  NOTIFY_ACTION_ANSWER as z
29929
29833
  };
29930
- //# sourceMappingURL=executor_client-d2c9e854.mjs.map
29834
+ //# sourceMappingURL=executor_client-eb372968.mjs.map