@baukit/auth-node 0.3.0
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/LICENSE +21 -0
- package/README.md +76 -0
- package/dist/cache.d.ts +38 -0
- package/dist/cache.d.ts.map +1 -0
- package/dist/cache.js +316 -0
- package/dist/cache.js.map +1 -0
- package/dist/device-flow.d.ts +80 -0
- package/dist/device-flow.d.ts.map +1 -0
- package/dist/device-flow.js +567 -0
- package/dist/device-flow.js.map +1 -0
- package/dist/errors.d.ts +13 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/errors.js +38 -0
- package/dist/errors.js.map +1 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +4 -0
- package/dist/index.js.map +1 -0
- package/package.json +52 -0
package/dist/errors.js
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
const SAFE_MESSAGES = {
|
|
2
|
+
aborted: 'OIDC operation was cancelled.',
|
|
3
|
+
cache_corrupt: 'The local authentication cache is invalid.',
|
|
4
|
+
cache_lock_timeout: 'Timed out waiting for the local authentication cache lock.',
|
|
5
|
+
cache_permission: 'The local authentication cache permissions are unsafe.',
|
|
6
|
+
cache_read_failed: 'Could not read the local authentication cache.',
|
|
7
|
+
cache_symlink: 'The local authentication cache must not use symbolic links.',
|
|
8
|
+
cache_write_failed: 'Could not update the local authentication cache.',
|
|
9
|
+
device_authorization_denied: 'OIDC device authorization was denied.',
|
|
10
|
+
device_authorization_expired: 'OIDC device authorization expired.',
|
|
11
|
+
device_authorization_failed: 'OIDC device authorization failed.',
|
|
12
|
+
discovery_failed: 'OIDC provider discovery failed.',
|
|
13
|
+
endpoint_policy_violation: 'OIDC endpoint did not satisfy the configured security policy.',
|
|
14
|
+
invalid_device_response: 'OIDC provider returned an invalid device authorization response.',
|
|
15
|
+
invalid_discovery_document: 'OIDC provider returned invalid discovery metadata.',
|
|
16
|
+
invalid_token_response: 'OIDC provider returned an invalid token response.',
|
|
17
|
+
issuer_mismatch: 'OIDC provider issuer did not match an allowed issuer.',
|
|
18
|
+
login_timeout: 'OIDC device authorization timed out.',
|
|
19
|
+
no_cached_session: 'No usable OIDC session is available.',
|
|
20
|
+
refresh_failed: 'OIDC token refresh failed.',
|
|
21
|
+
};
|
|
22
|
+
/** An authentication failure whose message never includes tokens or provider response bodies. */
|
|
23
|
+
export class AuthNodeError extends Error {
|
|
24
|
+
code;
|
|
25
|
+
retryable;
|
|
26
|
+
status;
|
|
27
|
+
constructor(code, options = {}) {
|
|
28
|
+
super(SAFE_MESSAGES[code]);
|
|
29
|
+
this.name = 'AuthNodeError';
|
|
30
|
+
this.code = code;
|
|
31
|
+
this.retryable = options.retryable ?? false;
|
|
32
|
+
this.status = options.status;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
export function safeAuthNodeErrorMessage(cause) {
|
|
36
|
+
return cause instanceof AuthNodeError ? SAFE_MESSAGES[cause.code] : 'OIDC authentication failed.';
|
|
37
|
+
}
|
|
38
|
+
//# sourceMappingURL=errors.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAqBA,MAAM,aAAa,GAAG;IACpB,OAAO,EAAE,+BAA+B;IACxC,aAAa,EAAE,4CAA4C;IAC3D,kBAAkB,EAAE,4DAA4D;IAChF,gBAAgB,EAAE,wDAAwD;IAC1E,iBAAiB,EAAE,gDAAgD;IACnE,aAAa,EAAE,6DAA6D;IAC5E,kBAAkB,EAAE,kDAAkD;IACtE,2BAA2B,EAAE,uCAAuC;IACpE,4BAA4B,EAAE,oCAAoC;IAClE,2BAA2B,EAAE,mCAAmC;IAChE,gBAAgB,EAAE,iCAAiC;IACnD,yBAAyB,EAAE,+DAA+D;IAC1F,uBAAuB,EAAE,kEAAkE;IAC3F,0BAA0B,EAAE,oDAAoD;IAChF,sBAAsB,EAAE,mDAAmD;IAC3E,eAAe,EAAE,uDAAuD;IACxE,aAAa,EAAE,sCAAsC;IACrD,iBAAiB,EAAE,sCAAsC;IACzD,cAAc,EAAE,4BAA4B;CACQ,CAAC;AAEvD,iGAAiG;AACjG,MAAM,OAAO,aAAc,SAAQ,KAAK;IACtB,IAAI,CAAoB;IACxB,SAAS,CAAU;IACnB,MAAM,CAAqB;IAE3C,YACE,IAAuB,EACvB,UAAsE,EAAE;QAExE,KAAK,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC,CAAC;QAC3B,IAAI,CAAC,IAAI,GAAG,eAAe,CAAC;QAC5B,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,SAAS,GAAG,OAAO,CAAC,SAAS,IAAI,KAAK,CAAC;QAC5C,IAAI,CAAC,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAC/B,CAAC;CACF;AAED,MAAM,UAAU,wBAAwB,CAAC,KAAc;IACrD,OAAO,KAAK,YAAY,aAAa,CAAC,CAAC,CAAC,aAAa,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,6BAA6B,CAAC;AACpG,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export { defaultTokenCachePath, NodeTokenCache, type CachedTokenProfile, type NodeTokenCacheOptions, type TokenCacheTransaction, } from './cache.js';
|
|
2
|
+
export { decodeDisplayOnlyClaims, DeviceFlowClient, discoverDeviceProvider, type AccessTokenOptions, type DeviceFlowClientConfig, type DeviceFlowEnvironment, type DeviceFlowPresentation, type DeviceFlowStatus, type DeviceProviderRequestOptions, type DeviceVerification, type DisplayOnlyClaims, type EndpointPolicy, type LoginOptions, type OidcDeviceMetadata, } from './device-flow.js';
|
|
3
|
+
export { AuthNodeError, safeAuthNodeErrorMessage, type AuthNodeErrorCode } from './errors.js';
|
|
4
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,qBAAqB,EACrB,cAAc,EACd,KAAK,kBAAkB,EACvB,KAAK,qBAAqB,EAC1B,KAAK,qBAAqB,GAC3B,MAAM,YAAY,CAAC;AACpB,OAAO,EACL,uBAAuB,EACvB,gBAAgB,EAChB,sBAAsB,EACtB,KAAK,kBAAkB,EACvB,KAAK,sBAAsB,EAC3B,KAAK,qBAAqB,EAC1B,KAAK,sBAAsB,EAC3B,KAAK,gBAAgB,EACrB,KAAK,4BAA4B,EACjC,KAAK,kBAAkB,EACvB,KAAK,iBAAiB,EACtB,KAAK,cAAc,EACnB,KAAK,YAAY,EACjB,KAAK,kBAAkB,GACxB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,aAAa,EAAE,wBAAwB,EAAE,KAAK,iBAAiB,EAAE,MAAM,aAAa,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export { defaultTokenCachePath, NodeTokenCache, } from './cache.js';
|
|
2
|
+
export { decodeDisplayOnlyClaims, DeviceFlowClient, discoverDeviceProvider, } from './device-flow.js';
|
|
3
|
+
export { AuthNodeError, safeAuthNodeErrorMessage } from './errors.js';
|
|
4
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,qBAAqB,EACrB,cAAc,GAIf,MAAM,YAAY,CAAC;AACpB,OAAO,EACL,uBAAuB,EACvB,gBAAgB,EAChB,sBAAsB,GAYvB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,aAAa,EAAE,wBAAwB,EAA0B,MAAM,aAAa,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@baukit/auth-node",
|
|
3
|
+
"version": "0.3.0",
|
|
4
|
+
"description": "Node OIDC device authorization with S256 PKCE, refresh rotation, and a locked token cache.",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"author": "Patrick Koss",
|
|
7
|
+
"homepage": "https://github.com/PatrickKoss/baukit#readme",
|
|
8
|
+
"repository": {
|
|
9
|
+
"type": "git",
|
|
10
|
+
"url": "git+https://github.com/PatrickKoss/baukit.git",
|
|
11
|
+
"directory": "typescript/packages/auth-node"
|
|
12
|
+
},
|
|
13
|
+
"bugs": {
|
|
14
|
+
"url": "https://github.com/PatrickKoss/baukit/issues"
|
|
15
|
+
},
|
|
16
|
+
"publishConfig": {
|
|
17
|
+
"access": "public"
|
|
18
|
+
},
|
|
19
|
+
"type": "module",
|
|
20
|
+
"engines": {
|
|
21
|
+
"node": ">=24.0.0"
|
|
22
|
+
},
|
|
23
|
+
"types": "./dist/index.d.ts",
|
|
24
|
+
"exports": {
|
|
25
|
+
".": {
|
|
26
|
+
"types": "./dist/index.d.ts",
|
|
27
|
+
"import": "./dist/index.js"
|
|
28
|
+
},
|
|
29
|
+
"./device-flow": {
|
|
30
|
+
"types": "./dist/device-flow.d.ts",
|
|
31
|
+
"import": "./dist/device-flow.js"
|
|
32
|
+
}
|
|
33
|
+
},
|
|
34
|
+
"files": [
|
|
35
|
+
"dist",
|
|
36
|
+
"README.md",
|
|
37
|
+
"LICENSE"
|
|
38
|
+
],
|
|
39
|
+
"devDependencies": {
|
|
40
|
+
"@playwright/test": "1.62.1",
|
|
41
|
+
"@types/node": "24.10.1",
|
|
42
|
+
"typescript": "6.0.3"
|
|
43
|
+
},
|
|
44
|
+
"scripts": {
|
|
45
|
+
"build": "tsc -p tsconfig.json",
|
|
46
|
+
"test": "vitest run --config ../../vitest.config.ts",
|
|
47
|
+
"test:conformance": "vitest run --config ../../vitest.config.ts src/conformance.test.ts",
|
|
48
|
+
"test:conformance:keycloak": "pnpm run build && node scripts/keycloak-conformance.mjs",
|
|
49
|
+
"lint": "eslint src --max-warnings=0",
|
|
50
|
+
"format:check": "prettier --check src scripts package.json tsconfig.json tsconfig.test.json"
|
|
51
|
+
}
|
|
52
|
+
}
|