@skrr-ai/auth-core 0.1.2
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/README.md +21 -0
- package/dist/cjs/aead.d.ts +24 -0
- package/dist/cjs/aead.js +65 -0
- package/dist/cjs/authExpiredDetector.d.ts +65 -0
- package/dist/cjs/authExpiredDetector.js +89 -0
- package/dist/cjs/authHelper.d.ts +51 -0
- package/dist/cjs/authHelper.js +321 -0
- package/dist/cjs/credentialEnvelope.d.ts +85 -0
- package/dist/cjs/credentialEnvelope.js +230 -0
- package/dist/cjs/credentialEnvelopeBridge.d.ts +116 -0
- package/dist/cjs/credentialEnvelopeBridge.js +637 -0
- package/dist/cjs/credentialResolver.d.ts +278 -0
- package/dist/cjs/credentialResolver.js +423 -0
- package/dist/cjs/daemonPair.d.ts +172 -0
- package/dist/cjs/daemonPair.js +495 -0
- package/dist/cjs/daemonScopes.d.ts +74 -0
- package/dist/cjs/daemonScopes.js +84 -0
- package/dist/cjs/deviceIdentityBridge.d.ts +113 -0
- package/dist/cjs/deviceIdentityBridge.js +591 -0
- package/dist/cjs/deviceKey.d.ts +167 -0
- package/dist/cjs/deviceKey.js +332 -0
- package/dist/cjs/fdToken.d.ts +17 -0
- package/dist/cjs/fdToken.js +238 -0
- package/dist/cjs/harnessTrust.d.ts +72 -0
- package/dist/cjs/harnessTrust.js +103 -0
- package/dist/cjs/headers-helper.d.ts +25 -0
- package/dist/cjs/headers-helper.js +323 -0
- package/dist/cjs/index.d.ts +37 -0
- package/dist/cjs/index.js +305 -0
- package/dist/cjs/jwtUtils.d.ts +35 -0
- package/dist/cjs/jwtUtils.js +61 -0
- package/dist/cjs/kek/index.d.ts +89 -0
- package/dist/cjs/kek/index.js +208 -0
- package/dist/cjs/kek/linux.d.ts +92 -0
- package/dist/cjs/kek/linux.js +596 -0
- package/dist/cjs/kek/macos.d.ts +112 -0
- package/dist/cjs/kek/macos.js +599 -0
- package/dist/cjs/kek/types.d.ts +111 -0
- package/dist/cjs/kek/types.js +43 -0
- package/dist/cjs/kek/windows.d.ts +71 -0
- package/dist/cjs/kek/windows.js +350 -0
- package/dist/cjs/kek/zeroize-registry.d.ts +44 -0
- package/dist/cjs/kek/zeroize-registry.js +63 -0
- package/dist/cjs/legacyStatePreflight.d.ts +67 -0
- package/dist/cjs/legacyStatePreflight.js +78 -0
- package/dist/cjs/localIdentity.d.ts +54 -0
- package/dist/cjs/localIdentity.js +57 -0
- package/dist/cjs/loginLocalhost.d.ts +115 -0
- package/dist/cjs/loginLocalhost.js +368 -0
- package/dist/cjs/loginWithLocalhost.d.ts +131 -0
- package/dist/cjs/loginWithLocalhost.js +359 -0
- package/dist/cjs/machineId.d.ts +35 -0
- package/dist/cjs/machineId.js +239 -0
- package/dist/cjs/messages.d.ts +9 -0
- package/dist/cjs/messages.js +44 -0
- package/dist/cjs/package.json +3 -0
- package/dist/cjs/pkce.d.ts +62 -0
- package/dist/cjs/pkce.js +158 -0
- package/dist/cjs/recoveryCode.d.ts +61 -0
- package/dist/cjs/recoveryCode.js +213 -0
- package/dist/cjs/refresh.d.ts +215 -0
- package/dist/cjs/refresh.js +877 -0
- package/dist/cjs/refreshClassification.d.ts +53 -0
- package/dist/cjs/refreshClassification.js +105 -0
- package/dist/cjs/refreshScheduler.d.ts +53 -0
- package/dist/cjs/refreshScheduler.js +332 -0
- package/dist/cjs/runtime.d.ts +149 -0
- package/dist/cjs/runtime.js +136 -0
- package/dist/cjs/spawnEnv.d.ts +76 -0
- package/dist/cjs/spawnEnv.js +153 -0
- package/dist/cjs/ttlParser.d.ts +54 -0
- package/dist/cjs/ttlParser.js +87 -0
- package/dist/cjs/types.d.ts +91 -0
- package/dist/cjs/types.js +26 -0
- package/dist/esm/aead.d.ts +24 -0
- package/dist/esm/aead.js +57 -0
- package/dist/esm/authExpiredDetector.d.ts +65 -0
- package/dist/esm/authExpiredDetector.js +85 -0
- package/dist/esm/authHelper.d.ts +51 -0
- package/dist/esm/authHelper.js +311 -0
- package/dist/esm/credentialEnvelope.d.ts +85 -0
- package/dist/esm/credentialEnvelope.js +213 -0
- package/dist/esm/credentialEnvelopeBridge.d.ts +116 -0
- package/dist/esm/credentialEnvelopeBridge.js +620 -0
- package/dist/esm/credentialResolver.d.ts +278 -0
- package/dist/esm/credentialResolver.js +414 -0
- package/dist/esm/daemonPair.d.ts +172 -0
- package/dist/esm/daemonPair.js +476 -0
- package/dist/esm/daemonScopes.d.ts +74 -0
- package/dist/esm/daemonScopes.js +80 -0
- package/dist/esm/deviceIdentityBridge.d.ts +113 -0
- package/dist/esm/deviceIdentityBridge.js +572 -0
- package/dist/esm/deviceKey.d.ts +167 -0
- package/dist/esm/deviceKey.js +320 -0
- package/dist/esm/fdToken.d.ts +17 -0
- package/dist/esm/fdToken.js +231 -0
- package/dist/esm/harnessTrust.d.ts +72 -0
- package/dist/esm/harnessTrust.js +97 -0
- package/dist/esm/headers-helper.d.ts +25 -0
- package/dist/esm/headers-helper.js +316 -0
- package/dist/esm/index.d.ts +37 -0
- package/dist/esm/index.js +144 -0
- package/dist/esm/jwtUtils.d.ts +35 -0
- package/dist/esm/jwtUtils.js +57 -0
- package/dist/esm/kek/index.d.ts +89 -0
- package/dist/esm/kek/index.js +162 -0
- package/dist/esm/kek/linux.d.ts +92 -0
- package/dist/esm/kek/linux.js +585 -0
- package/dist/esm/kek/macos.d.ts +112 -0
- package/dist/esm/kek/macos.js +586 -0
- package/dist/esm/kek/types.d.ts +111 -0
- package/dist/esm/kek/types.js +39 -0
- package/dist/esm/kek/windows.d.ts +71 -0
- package/dist/esm/kek/windows.js +344 -0
- package/dist/esm/kek/zeroize-registry.d.ts +44 -0
- package/dist/esm/kek/zeroize-registry.js +58 -0
- package/dist/esm/legacyStatePreflight.d.ts +67 -0
- package/dist/esm/legacyStatePreflight.js +71 -0
- package/dist/esm/localIdentity.d.ts +54 -0
- package/dist/esm/localIdentity.js +54 -0
- package/dist/esm/loginLocalhost.d.ts +115 -0
- package/dist/esm/loginLocalhost.js +355 -0
- package/dist/esm/loginWithLocalhost.d.ts +131 -0
- package/dist/esm/loginWithLocalhost.js +353 -0
- package/dist/esm/machineId.d.ts +35 -0
- package/dist/esm/machineId.js +231 -0
- package/dist/esm/messages.d.ts +9 -0
- package/dist/esm/messages.js +40 -0
- package/dist/esm/pkce.d.ts +62 -0
- package/dist/esm/pkce.js +148 -0
- package/dist/esm/recoveryCode.d.ts +61 -0
- package/dist/esm/recoveryCode.js +207 -0
- package/dist/esm/refresh.d.ts +215 -0
- package/dist/esm/refresh.js +863 -0
- package/dist/esm/refreshClassification.d.ts +53 -0
- package/dist/esm/refreshClassification.js +106 -0
- package/dist/esm/refreshScheduler.d.ts +53 -0
- package/dist/esm/refreshScheduler.js +329 -0
- package/dist/esm/runtime.d.ts +149 -0
- package/dist/esm/runtime.js +121 -0
- package/dist/esm/spawnEnv.d.ts +76 -0
- package/dist/esm/spawnEnv.js +149 -0
- package/dist/esm/ttlParser.d.ts +54 -0
- package/dist/esm/ttlParser.js +83 -0
- package/dist/esm/types.d.ts +91 -0
- package/dist/esm/types.js +21 -0
- package/package.json +82 -0
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared types & error classes used across refresh, refreshScheduler, and
|
|
3
|
+
* fdToken modules. Lives in its own file so consumers can `import type` from
|
|
4
|
+
* the package without dragging in side-effecting modules.
|
|
5
|
+
*/
|
|
6
|
+
export interface TokenPair {
|
|
7
|
+
/**
|
|
8
|
+
* Legacy daemon/cli/web access JWT. Null after Stage-E #1 step 4
|
|
9
|
+
* for daemon-scope refresh responses: the JWT-daemon substrate has
|
|
10
|
+
* been retired and only `opaqueAccessToken` is shipped. Non-daemon
|
|
11
|
+
* scopes (cli, web) still receive a non-null JWT here.
|
|
12
|
+
*/
|
|
13
|
+
accessToken: string | null;
|
|
14
|
+
/** Epoch ms. */
|
|
15
|
+
accessExpiresAt: number;
|
|
16
|
+
refreshToken: string;
|
|
17
|
+
/** Epoch ms. */
|
|
18
|
+
refreshExpiresAt: number;
|
|
19
|
+
/**
|
|
20
|
+
* Stage-E #1 — opaque `osk_dmn_*` daemon access token co-issued
|
|
21
|
+
* with the JWT for daemon-scope sessions. Optional during the
|
|
22
|
+
* dark-ship migration window:
|
|
23
|
+
*
|
|
24
|
+
* - `undefined` / absent: server didn't co-issue (older API,
|
|
25
|
+
* non-daemon scope, or `OVERSKY_DMN_OPAQUE_DISABLED=1` set).
|
|
26
|
+
* Daemon authenticates with the JWT (legacy behavior).
|
|
27
|
+
* - `null`: server co-issued but the value is explicitly null
|
|
28
|
+
* (kill switch tripped mid-rotation, or write failed). Daemon
|
|
29
|
+
* callers MUST treat this as "clear any cached opaque slot
|
|
30
|
+
* so we don't keep using a stale opaque after its row was
|
|
31
|
+
* family-revoked".
|
|
32
|
+
* - `string`: opaque plaintext. Daemon stores in keychain and
|
|
33
|
+
* prefers over JWT for the next handshake (gated by
|
|
34
|
+
* `OVERSKY_PREFER_OPAQUE_DAEMON_TOKEN`, default on).
|
|
35
|
+
*
|
|
36
|
+
* Expires in lockstep with `accessExpiresAt` (server-side they're
|
|
37
|
+
* minted in the same transaction with identical TTL). The pair
|
|
38
|
+
* intentionally does NOT carry a separate `opaqueAccessExpiresAt`.
|
|
39
|
+
*/
|
|
40
|
+
opaqueAccessToken?: string | null;
|
|
41
|
+
/**
|
|
42
|
+
* Production-hardening 2026-05-06 — soft backoff hint from the server
|
|
43
|
+
* indicating the fleet refresh-QPS is high and the daemon SHOULD
|
|
44
|
+
* defer its next proactive refresh by this many seconds (plus its
|
|
45
|
+
* own jitter). Distinct from a 429 Retry-After: this is advisory,
|
|
46
|
+
* the rotation already succeeded, and the daemon's correctness is
|
|
47
|
+
* not at risk if it ignores the hint. Honoring it lets a fleet
|
|
48
|
+
* stretch its refresh-cadence under load WITHOUT any rejected
|
|
49
|
+
* requests.
|
|
50
|
+
*
|
|
51
|
+
* Sourced from the response's `X-Refresh-Backoff` header (or
|
|
52
|
+
* `Retry-After` when present on a 200). Absent when the server
|
|
53
|
+
* isn't backpressuring or the header parser failed.
|
|
54
|
+
*/
|
|
55
|
+
softBackoffSeconds?: number;
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Server-emitted permanent-failure codes.
|
|
59
|
+
*
|
|
60
|
+
* Three groups, all permanent (no amount of retry helps):
|
|
61
|
+
* - REFRESH_* — refresh-token specific (most common path).
|
|
62
|
+
* - TOKEN_* — access-token specific (server pushes 4402 close;
|
|
63
|
+
* daemon classifies as TOKEN_INVALID/TOKEN_EXPIRED).
|
|
64
|
+
* - SESSION_REVOKED — admin/forensic revoke; whole family burned.
|
|
65
|
+
* - UNKNOWN_401 — server returned 401 with a code we don't
|
|
66
|
+
* recognize. Treated as permanent (better to prompt
|
|
67
|
+
* re-auth than to loop forever) but tagged
|
|
68
|
+
* distinctly so monitoring can surface server-side
|
|
69
|
+
* bugs separately from real expirations.
|
|
70
|
+
*
|
|
71
|
+
* Production-hardening 2026-05-06 — widened from the original 4-value
|
|
72
|
+
* union to include `TOKEN_INVALID`, `TOKEN_EXPIRED`, and `UNKNOWN_401`
|
|
73
|
+
* to match the codes the daemon and client UX actually emit/render.
|
|
74
|
+
* Without this, the client `describeAuthFailure` exhaustiveness check
|
|
75
|
+
* was silently broken for the non-REFRESH branches.
|
|
76
|
+
*/
|
|
77
|
+
export type PermanentAuthReason = 'REFRESH_INVALID' | 'REFRESH_REUSED' | 'REFRESH_EXPIRED' | 'SESSION_REVOKED' | 'TOKEN_INVALID' | 'TOKEN_EXPIRED' | 'UNKNOWN_401';
|
|
78
|
+
export declare class PermanentAuthFailure extends Error {
|
|
79
|
+
readonly code: PermanentAuthReason;
|
|
80
|
+
constructor(code: PermanentAuthReason, message: string);
|
|
81
|
+
}
|
|
82
|
+
export declare class TransientAuthFailure extends Error {
|
|
83
|
+
readonly cause?: unknown;
|
|
84
|
+
constructor(message: string, cause?: unknown);
|
|
85
|
+
}
|
|
86
|
+
export interface ReauthState {
|
|
87
|
+
code: string;
|
|
88
|
+
message?: string;
|
|
89
|
+
/** Epoch ms. */
|
|
90
|
+
at: number;
|
|
91
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared types & error classes used across refresh, refreshScheduler, and
|
|
3
|
+
* fdToken modules. Lives in its own file so consumers can `import type` from
|
|
4
|
+
* the package without dragging in side-effecting modules.
|
|
5
|
+
*/
|
|
6
|
+
export class PermanentAuthFailure extends Error {
|
|
7
|
+
code;
|
|
8
|
+
constructor(code, message) {
|
|
9
|
+
super(message);
|
|
10
|
+
this.name = 'PermanentAuthFailure';
|
|
11
|
+
this.code = code;
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
export class TransientAuthFailure extends Error {
|
|
15
|
+
cause;
|
|
16
|
+
constructor(message, cause) {
|
|
17
|
+
super(message);
|
|
18
|
+
this.name = 'TransientAuthFailure';
|
|
19
|
+
this.cause = cause;
|
|
20
|
+
}
|
|
21
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@skrr-ai/auth-core",
|
|
3
|
+
"version": "0.1.2",
|
|
4
|
+
"description": "Shared auth substrate (token store, refresh, scheduler, fd handoff) for the OverSky daemon and CLI.",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "dist/cjs/index.js",
|
|
7
|
+
"module": "dist/esm/index.js",
|
|
8
|
+
"types": "dist/esm/index.d.ts",
|
|
9
|
+
"exports": {
|
|
10
|
+
".": {
|
|
11
|
+
"import": {
|
|
12
|
+
"types": "./dist/esm/index.d.ts",
|
|
13
|
+
"default": "./dist/esm/index.js"
|
|
14
|
+
},
|
|
15
|
+
"require": {
|
|
16
|
+
"types": "./dist/cjs/index.d.ts",
|
|
17
|
+
"default": "./dist/cjs/index.js"
|
|
18
|
+
}
|
|
19
|
+
},
|
|
20
|
+
"./refresh-classification": {
|
|
21
|
+
"import": {
|
|
22
|
+
"types": "./dist/esm/refreshClassification.d.ts",
|
|
23
|
+
"default": "./dist/esm/refreshClassification.js"
|
|
24
|
+
},
|
|
25
|
+
"require": {
|
|
26
|
+
"types": "./dist/cjs/refreshClassification.d.ts",
|
|
27
|
+
"default": "./dist/cjs/refreshClassification.js"
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
},
|
|
31
|
+
"files": [
|
|
32
|
+
"dist/**/*.js",
|
|
33
|
+
"dist/**/*.d.ts",
|
|
34
|
+
"dist/cjs/package.json",
|
|
35
|
+
"README.md",
|
|
36
|
+
"package.json"
|
|
37
|
+
],
|
|
38
|
+
"scripts": {
|
|
39
|
+
"build": "npm run clean && npm run build:esm && npm run build:cjs && node scripts/finalize-cjs.cjs",
|
|
40
|
+
"build:esm": "tsc -p tsconfig.json",
|
|
41
|
+
"build:cjs": "tsc -p tsconfig.cjs.json",
|
|
42
|
+
"clean": "rimraf dist",
|
|
43
|
+
"test": "node --import tsx --test 'src/**/*.test.ts' 'src/**/*.spec.ts'",
|
|
44
|
+
"test:smoke": "node --import tsx --test 'src/**/*.real-smoke.test.ts'",
|
|
45
|
+
"prepack": "npm run build"
|
|
46
|
+
},
|
|
47
|
+
"dependencies": {
|
|
48
|
+
"proper-lockfile": "^4.1.2",
|
|
49
|
+
"tweetnacl": "^1.0.3"
|
|
50
|
+
},
|
|
51
|
+
"devDependencies": {
|
|
52
|
+
"@types/node": "^20.17.12",
|
|
53
|
+
"@types/proper-lockfile": "^4.1.4",
|
|
54
|
+
"rimraf": "^5.0.5",
|
|
55
|
+
"tsx": "^4.19.2",
|
|
56
|
+
"typescript": "^5.7.3"
|
|
57
|
+
},
|
|
58
|
+
"engines": {
|
|
59
|
+
"node": ">=22.0.0"
|
|
60
|
+
},
|
|
61
|
+
"publishConfig": {
|
|
62
|
+
"access": "public"
|
|
63
|
+
},
|
|
64
|
+
"license": "UNLICENSED",
|
|
65
|
+
"author": "OverSky",
|
|
66
|
+
"homepage": "https://oversky.ai",
|
|
67
|
+
"bugs": {
|
|
68
|
+
"url": "https://github.com/dush1023/OverSky/issues"
|
|
69
|
+
},
|
|
70
|
+
"repository": {
|
|
71
|
+
"type": "git",
|
|
72
|
+
"url": "https://github.com/dush1023/OverSky.git",
|
|
73
|
+
"directory": "packages/auth-core"
|
|
74
|
+
},
|
|
75
|
+
"keywords": [
|
|
76
|
+
"oversky",
|
|
77
|
+
"auth",
|
|
78
|
+
"cli",
|
|
79
|
+
"daemon",
|
|
80
|
+
"token-refresh"
|
|
81
|
+
]
|
|
82
|
+
}
|