@skrr-ai/cli 0.1.66 → 0.1.68

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.
@@ -80,6 +80,26 @@ function publicKeyPath(profile) {
80
80
  function privateKeyPath(profile) {
81
81
  return path.join(profileConfigDir(profile), PRIVATE_KEY_FILENAME);
82
82
  }
83
+ function storedKeyMaterialExists(profile) {
84
+ let files;
85
+ try {
86
+ files = [publicKeyPath(profile), privateKeyPath(profile), enrollmentMarkerPath(profile)];
87
+ }
88
+ catch {
89
+ return true;
90
+ }
91
+ for (const file of files) {
92
+ try {
93
+ fs.lstatSync(file);
94
+ return true;
95
+ }
96
+ catch (err) {
97
+ if (err.code !== 'ENOENT')
98
+ return true;
99
+ }
100
+ }
101
+ return false;
102
+ }
83
103
  function enrollmentMarkerPath(profile) {
84
104
  return path.join(profileConfigDir(profile), ENROLLMENT_MARKER_FILENAME);
85
105
  }
@@ -319,7 +339,7 @@ async function consolidateDeviceIdentity(profile) {
319
339
  * 2. Generate fresh keypair and persist. Failure to persist is a hard
320
340
  * error landing in disabled+persist_failed.
321
341
  */
322
- export async function initDeviceIdentity(profile) {
342
+ export async function initDeviceIdentity(profile, options = {}) {
323
343
  if (_state.kind !== 'uninit')
324
344
  return;
325
345
  if (typeof profile !== 'string' || profile.length === 0) {
@@ -354,6 +374,18 @@ export async function initDeviceIdentity(profile) {
354
374
  });
355
375
  return;
356
376
  }
377
+ // A first install has neither file. If either file already exists, a null
378
+ // load is a lost, corrupt or temporarily unreadable identity. Replacing it
379
+ // during ordinary boot would make the next refresh sign with a key the
380
+ // server has never pinned, turning a local read failure into an unexpected
381
+ // DEVICE_KEY_MISMATCH. Only an explicit interactive login may replace it;
382
+ // that login proves the new key and re-pins it before issuing credentials.
383
+ const hasStoredKey = storedKeyMaterialExists(profile);
384
+ if (hasStoredKey && !options.recoverUnreadable) {
385
+ _state = { kind: 'disabled', reason: 'unreadable_key' };
386
+ emit('recovery_required', false, { profile, reason: 'stored_key_unreadable' });
387
+ return;
388
+ }
357
389
  let fresh;
358
390
  try {
359
391
  fresh = generateDeviceKeyPair();
@@ -393,9 +425,9 @@ export async function initDeviceIdentity(profile) {
393
425
  });
394
426
  }
395
427
  /**
396
- * Reset state. With `clearOnDisk=true` deletes both keypair files —
397
- * used by `oversky logout` / `sky logout` so a freshly-logged-in user
398
- * gets a fresh device identity that the daemon will see on its next start.
428
+ * Reset in-memory state. With `clearOnDisk=true` deletes both keypair files.
429
+ * Machine-wide sign-out may use that option; ordinary CLI sign-out preserves
430
+ * the daemon's pinned identity.
399
431
  */
400
432
  export async function resetDeviceIdentity(opts) {
401
433
  if (opts?.clearOnDisk && opts.profile) {
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@skrr-ai/auth-core",
3
- "version": "0.4.8",
3
+ "version": "0.4.9",
4
4
  "main": "dist/cjs/index.js",
5
5
  "types": "dist/esm/index.d.ts",
6
6
  "exports": {
@@ -44752,6 +44752,10 @@ var gR = Object.freeze({ __proto__: null, acceptAgentIntuition: function(e2, t2,
44752
44752
  return oR.get(e2 ? "".concat(vr(), "?workspaceId=").concat(encodeURIComponent(e2)) : vr());
44753
44753
  }, getStorePublisherFollowOverlay: function(e2) {
44754
44754
  return oR.get(xr(e2));
44755
+ }, getStorePublisherFollows: function(e2) {
44756
+ return oR.get((function(e3) {
44757
+ return "".concat(er(), "/publisher-follows").concat(e3 ? "?cursor=".concat(encodeURIComponent(e3)) : "");
44758
+ })(e2));
44755
44759
  }, getStorePublisherNamespaces: function(e2) {
44756
44760
  return oR.get(hr(e2));
44757
44761
  }, getStorePublisherProfileEditor: function(e2) {
@@ -44767,7 +44771,7 @@ var gR = Object.freeze({ __proto__: null, acceptAgentIntuition: function(e2, t2,
44767
44771
  }, getStoreReleaseAdmissions: function(e2) {
44768
44772
  return oR.get((function(e3) {
44769
44773
  var t2 = new URLSearchParams();
44770
- (null == e3 ? void 0 : e3.state) && t2.set("state", e3.state), (null == e3 ? void 0 : e3.limit) && t2.set("limit", String(e3.limit));
44774
+ (null == e3 ? void 0 : e3.state) && t2.set("state", e3.state), (null == e3 ? void 0 : e3.limit) && t2.set("limit", String(e3.limit)), (null == e3 ? void 0 : e3.artifactAfter) && t2.set("artifactAfter", e3.artifactAfter);
44771
44775
  var n2 = t2.toString();
44772
44776
  return "".concat(er(), "/admissions").concat(n2 ? "?".concat(n2) : "");
44773
44777
  })(e2));
@@ -46890,6 +46894,10 @@ var gR = Object.freeze({ __proto__: null, acceptAgentIntuition: function(e2, t2,
46890
46894
  return oR.patch(Aa(e2), { unarchive: true });
46891
46895
  }, unfollowStorePublisherByHandle: function(e2) {
46892
46896
  return oR.delete(xr(e2));
46897
+ }, unfollowStorePublisherById: function(e2) {
46898
+ return oR.delete((function(e3) {
46899
+ return "".concat(er(), "/publisher-follows/").concat(encodeURIComponent(e3));
46900
+ })(e2));
46893
46901
  }, uninstallStoreAgent: function(e2) {
46894
46902
  var t2 = e2.agentId, n2 = e2.erase;
46895
46903
  return oR.post((function(e3) {