@oxyhq/core 12.4.0 → 12.4.1

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.
@@ -75,9 +75,20 @@ async function refreshDeviceSecretArm(deps) {
75
75
  // Structural read (not `instanceof Error`): the thrown value can be a
76
76
  // plain ApiError-shaped object or come from another realm.
77
77
  const message = error?.message;
78
- return typeof message === 'string' && message.includes('no_active_session')
79
- ? { status: 'no-session' }
80
- : { status: 'invalid-secret' };
78
+ const body = typeof message === 'string' ? message : '';
79
+ // ONLY the server's explicit `invalid_device_secret` proves the presented
80
+ // secret is bad and may clear the durable device credential. `no_active_session`
81
+ // is an authoritative signed-out. ANY OTHER 401 — a middleware/CSRF/proxy 401,
82
+ // an ALB/starting-instance 401, a CORS error page, etc., all common during a
83
+ // deploy/restart window — is NOT proof the secret diverged: treat it as
84
+ // transient and KEEP the credential so a later attempt self-heals. Wiping the
85
+ // credential on an ambiguous 401 is what logged users out on every deploy,
86
+ // ecosystem-wide.
87
+ if (body.includes('invalid_device_secret'))
88
+ return { status: 'invalid-secret' };
89
+ if (body.includes('no_active_session'))
90
+ return { status: 'no-session' };
91
+ return { status: 'transient' };
81
92
  }
82
93
  return { status: 'transient' };
83
94
  }