@ropean/sso-client 0.0.4 → 0.0.5
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/dist/idp.d.ts +4 -0
- package/dist/idp.d.ts.map +1 -1
- package/dist/idp.js +58 -4
- package/dist/idp.js.map +1 -1
- package/package.json +15 -14
package/dist/idp.d.ts
CHANGED
|
@@ -8,8 +8,12 @@ export interface TokenResponse {
|
|
|
8
8
|
scope?: string;
|
|
9
9
|
}
|
|
10
10
|
export interface IdpErrorBody {
|
|
11
|
+
/** Machine-readable error code. Always a string. */
|
|
11
12
|
error: string;
|
|
13
|
+
/** Human-readable message. Always a string when present. */
|
|
12
14
|
error_description?: string;
|
|
15
|
+
/** Raw error payload from the IdP, for debugging. */
|
|
16
|
+
raw?: unknown;
|
|
13
17
|
}
|
|
14
18
|
export declare class IdpError extends Error {
|
|
15
19
|
readonly status: number;
|
package/dist/idp.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"idp.d.ts","sourceRoot":"","sources":["../src/idp.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAGvD,MAAM,WAAW,aAAa;IAC5B,YAAY,EAAE,MAAM,CAAC;IACrB,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,MAAM,CAAC;IACnB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,YAAY;IAC3B,KAAK,EAAE,MAAM,CAAC;IACd,iBAAiB,CAAC,EAAE,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"idp.d.ts","sourceRoot":"","sources":["../src/idp.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAGvD,M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
|
|
3
3
|
status;
|
|
4
4
|
body;
|
|
5
5
|
constructor(status, body) {
|
|
6
|
-
|
|
6
|
+
// Guard against non-string message fields collapsing to "[object Object]".
|
|
7
|
+
super(coerceString(body.error_description) || coerceString(body.error) || `idp_error (HTTP ${status})`);
|
|
7
8
|
this.status = status;
|
|
8
9
|
this.body = body;
|
|
10
|
+
this.name = 'IdpError';
|
|
9
11
|
}
|
|
10
12
|
}
|
|
13
|
+
/** Coerce any value to a meaningful string, never "[object Object]". */
|
|
14
|
+
function coerceString(value) {
|
|
15
|
+
if (value == null)
|
|
16
|
+
return undefined;
|
|
17
|
+
if (typeof value === 'string')
|
|
18
|
+
return value || undefined;
|
|
19
|
+
if (typeof value === 'number' || typeof value === 'boolean')
|
|
20
|
+
return String(value);
|
|
21
|
+
// For objects/arrays fall back to JSON so the caller still sees the content.
|
|
22
|
+
try {
|
|
23
|
+
return JSON.stringify(value);
|
|
24
|
+
}
|
|
25
|
+
catch {
|
|
26
|
+
return undefined;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Normalize an arbitrary error payload into a flat {error, error_description}.
|
|
31
|
+
* Handles standard OAuth ({error, error_description} strings) AND the IdP's
|
|
32
|
+
* envelope ({success, error: {code, message}, meta}), plus loose fallbacks.
|
|
33
|
+
*/
|
|
34
|
+
function normalizeErrorBody(json, status, rawText) {
|
|
35
|
+
const obj = (json && typeof json === 'object' ? json : {});
|
|
36
|
+
const errField = obj.error;
|
|
37
|
+
// Case 1: standard OAuth — error is a string.
|
|
38
|
+
if (typeof errField === 'string') {
|
|
39
|
+
return {
|
|
40
|
+
error: errField || 'idp_error',
|
|
41
|
+
error_description: coerceString(obj.error_description) ?? coerceString(obj.message),
|
|
42
|
+
raw: json,
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
// Case 2: nested envelope — error is an object like {code, message}.
|
|
46
|
+
if (errField && typeof errField === 'object') {
|
|
47
|
+
const nested = errField;
|
|
48
|
+
return {
|
|
49
|
+
error: coerceString(nested.code) ?? coerceString(nested.error) ?? 'idp_error',
|
|
50
|
+
error_description: coerceString(nested.message) ?? coerceString(nested.description) ?? coerceString(errField),
|
|
51
|
+
raw: json,
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
// Case 3: no `error` field — try top-level code/message, else raw text.
|
|
55
|
+
const fallback = coerceString(obj.message) ?? coerceString(obj.error_description) ?? (rawText.trim() || undefined);
|
|
56
|
+
return {
|
|
57
|
+
error: coerceString(obj.code) ?? 'idp_error',
|
|
58
|
+
error_description: fallback ? fallback.slice(0, 500) : `HTTP ${status}`,
|
|
59
|
+
raw: json ?? rawText,
|
|
60
|
+
};
|
|
61
|
+
}
|
|
11
62
|
async function postForm(url, body) {
|
|
12
63
|
const res = await fetch(url, {
|
|
13
64
|
method: 'POST',
|
|
@@ -20,11 +71,14 @@ async function postForm(url, body) {
|
|
|
20
71
|
json = text ? JSON.parse(text) : {};
|
|
21
72
|
}
|
|
22
73
|
catch {
|
|
23
|
-
throw new IdpError(res.status, {
|
|
74
|
+
throw new IdpError(res.status, {
|
|
75
|
+
error: 'idp_invalid_response',
|
|
76
|
+
error_description: text.slice(0, 500) || `HTTP ${res.status}`,
|
|
77
|
+
raw: text,
|
|
78
|
+
});
|
|
24
79
|
}
|
|
25
80
|
if (!res.ok) {
|
|
26
|
-
|
|
27
|
-
throw new IdpError(res.status, { error: err.error ?? 'idp_error', error_description: err.error_description });
|
|
81
|
+
throw new IdpError(res.status, normalizeErrorBody(json, res.status, text));
|
|
28
82
|
}
|
|
29
83
|
return json;
|
|
30
84
|
}
|
package/dist/idp.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"idp.js","sourceRoot":"","sources":["../src/idp.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"idp.js","sourceRoot":"","sources":["../src/idp.ts"],"names":[],"mappings":"AACA,O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from './types.js';\nimport { deriveEndpoints } from './config.js';\n\nexport interface TokenResponse {\n access_token: string;\n token_type: string;\n expires_in: number;\n refresh_token?: string;\n id_token?: string;\n scope?: string;\n}\n\nexport interface IdpErrorBody {\n /** Machine-readable error code. Always a string. */\n error: string;\n /** Human-readable message. Always a string when present. */\n error_description?: string;\n /** Raw error payload from the IdP, for debugging. */\n raw?: unknown;\n}\n\nexport class IdpError extends Error {\n constructor(\n public readonly status: number,\n public readonly body: IdpErrorBody,\n ) {\n // Guard against non-string message fields collapsing to \"[object Object]\".\n super(coerceString(body.error_description) || coerceString(body.error) || `idp_error (HTTP ${status})`);\n this.name = 'IdpError';\n }\n}\n\n/** Coerce any value to a meaningful string, never \"[object Object]\". */\nfunction coerceString(value: unknown): string | undefined {\n if (value == null) return undefined;\n if (typeof value === 'string') return value || undefined;\n if (typeof value === 'number' || typeof value === 'boolean') return String(value);\n // For objects/arrays fall back to JSON so the caller still sees the content.\n try {\n return JSON.stringify(value);\n } catch {\n return undefined;\n }\n}\n\n/**\n * Normalize an arbitrary error payload into a flat {error, error_description}.\n * Handles standard OAuth ({error, error_description} strings) AND the IdP's\n * envelope ({success, error: {code, message}, meta}), plus loose fallbacks.\n */\nfunction normalizeErrorBody(json: unknown, status: number, rawText: string): IdpErrorBody {\n const obj = (json && typeof json === 'object' ? (json as Record<string, unknown>) : {}) as Record<string, unknown>;\n const errField = obj.error;\n\n // Case 1: standard OAuth — error is a string.\n if (typeof errField === 'string') {\n return {\n error: errField || 'idp_error',\n error_description: coerceString(obj.error_description) ?? coerceString(obj.message),\n raw: json,\n };\n }\n\n // Case 2: nested envelope — error is an object like {code, message}.\n if (errField && typeof errField === 'object') {\n const nested = errField as Record<string, unknown>;\n return {\n error: coerceString(nested.code) ?? coerceString(nested.error) ?? 'idp_error',\n error_description: coerceString(nested.message) ?? coerceString(nested.description) ?? coerceString(errField),\n raw: json,\n };\n }\n\n // Case 3: no `error` field — try top-level code/message, else raw text.\n const fallback = coerceString(obj.message) ?? coerceString(obj.error_description) ?? (rawText.trim() || undefined);\n return {\n error: coerceString(obj.code) ?? 'idp_error',\n error_description: fallback ? fallback.slice(0, 500) : `HTTP ${status}`,\n raw: json ?? rawText,\n };\n}\n\nasync function postForm(url: string, body: URLSearchParams): Promise<unknown> {\n const res = await fetch(url, {\n method: 'POST',\n headers: { 'Content-Type': 'application/x-www-form-urlencoded' },\n body: body.toString(),\n });\n const text = await res.text();\n let json: unknown;\n try {\n json = text ? JSON.parse(text) : {};\n } catch {\n throw new IdpError(res.status, {\n error: 'idp_invalid_response',\n error_description: text.slice(0, 500) || `HTTP ${res.status}`,\n raw: text,\n });\n }\n if (!res.ok) {\n throw new IdpError(res.status, normalizeErrorBody(json, res.status, text));\n }\n return json;\n}\n\nexport async function exchangeAuthorizationCode(\n config: SsoConfig,\n params: { code: string; codeVerifier: string },\n): Promise<TokenResponse> {\n const body = new URLSearchParams({\n grant_type: 'authorization_code',\n code: params.code,\n redirect_uri: config.redirectUri,\n client_id: config.clientId,\n client_secret: config.clientSecret,\n code_verifier: params.codeVerifier,\n });\n return (await postForm(deriveEndpoints(config.issuer).tokenEndpoint, body)) as TokenResponse;\n}\n\nexport async function refreshAccessToken(config: SsoConfig, refreshToken: string): Promise<TokenResponse> {\n const body = new URLSearchParams({\n grant_type: 'refresh_token',\n refresh_token: refreshToken,\n client_id: config.clientId,\n client_secret: config.clientSecret,\n });\n return (await postForm(deriveEndpoints(config.issuer).tokenEndpoint, body)) as TokenResponse;\n}\n\nexport interface ClientCredentialsOptions {\n /** Requested scopes. Defaults to 'agent:invoke'. */\n scope?: string;\n /** Intended audience (resource server's client_id). Defaults to 'agents'. */\n audience?: string;\n}\n\nexport async function fetchClientCredentialsToken(\n config: M2mConfig,\n options?: ClientCredentialsOptions,\n): Promise<TokenResponse> {\n const body = new URLSearchParams({\n grant_type: 'client_credentials',\n client_id: config.clientId,\n client_secret: config.clientSecret,\n scope: options?.scope ?? 'agent:invoke',\n audience: options?.audience ?? config.audience ?? 'agents',\n });\n return (await postForm(deriveEndpoints(config.issuer).tokenEndpoint, body)) as TokenResponse;\n}\n\nexport async function revokeRefreshToken(config: SsoConfig, refreshToken: string): Promise<void> {\n const body = new URLSearchParams({\n token: refreshToken,\n client_id: config.clientId,\n client_secret: config.clientSecret,\n });\n try {\n await postForm(deriveEndpoints(config.issuer).revokeEndpoint, body);\n } catch {\n // best-effort: revocation failures shouldn't block logout\n }\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,18 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ropean/sso-client",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.5",
|
|
4
4
|
"description": "Portable OAuth 2.0 + OIDC SSO module. Node.js, CF Workers, CF Pages, Vercel Edge — one API.",
|
|
5
|
-
"license": "MIT",
|
|
6
|
-
"author": "ropean",
|
|
7
|
-
"homepage": "https://github.com/ropean/sso-client#readme",
|
|
8
|
-
"repository": {
|
|
9
|
-
"type": "git",
|
|
10
|
-
"url": "https://github.com/ropean/sso-client.git",
|
|
11
|
-
"directory": "packages/core"
|
|
12
|
-
},
|
|
13
|
-
"bugs": {
|
|
14
|
-
"url": "https://github.com/ropean/sso-client/issues"
|
|
15
|
-
},
|
|
16
5
|
"keywords": [
|
|
17
6
|
"sso",
|
|
18
7
|
"oauth2",
|
|
@@ -24,9 +13,17 @@
|
|
|
24
13
|
"session",
|
|
25
14
|
"auth"
|
|
26
15
|
],
|
|
27
|
-
"
|
|
28
|
-
|
|
16
|
+
"homepage": "https://github.com/ropean/sso-client#readme",
|
|
17
|
+
"bugs": {
|
|
18
|
+
"url": "https://github.com/ropean/sso-client/issues"
|
|
29
19
|
},
|
|
20
|
+
"repository": {
|
|
21
|
+
"type": "git",
|
|
22
|
+
"url": "https://github.com/ropean/sso-client.git",
|
|
23
|
+
"directory": "packages/core"
|
|
24
|
+
},
|
|
25
|
+
"license": "MIT",
|
|
26
|
+
"author": "ropean",
|
|
30
27
|
"type": "module",
|
|
31
28
|
"exports": {
|
|
32
29
|
".": {
|
|
@@ -79,9 +76,13 @@
|
|
|
79
76
|
"optional": true
|
|
80
77
|
}
|
|
81
78
|
},
|
|
79
|
+
"publishConfig": {
|
|
80
|
+
"access": "public"
|
|
81
|
+
},
|
|
82
82
|
"scripts": {
|
|
83
83
|
"build": "tsc -p tsconfig.json",
|
|
84
84
|
"check": "node scripts/check.mjs",
|
|
85
|
+
"format": "prettier --write .",
|
|
85
86
|
"format:check": "prettier --check .",
|
|
86
87
|
"lint": "oxlint --deny-warnings src",
|
|
87
88
|
"test": "vitest run",
|