@pega/auth
Advanced tools
Comparing version 0.2.20 to 0.2.21
@@ -710,3 +710,4 @@ export class PegaAuth { | ||
} | ||
const { clientId, clientSecret, revokeUri, secureCookie } = this.#config; | ||
const { serverType, clientId, clientSecret, revokeUri, secureCookie } = this.#config; | ||
const bLaunchpad = serverType === 'launchpad'; | ||
if (this.isNode && !this.crypto) { | ||
@@ -717,3 +718,3 @@ // Deferring dynamic loading of node libraries til this first method to avoid doing this in constructor | ||
const headers = { 'content-type': this.urlencoded }; | ||
if (clientSecret) { | ||
if (clientSecret && !bLaunchpad) { | ||
const basicCreds = btoa(`${clientId}:${clientSecret}`); | ||
@@ -729,2 +730,6 @@ headers.authorization = `Basic ${basicCreds}`; | ||
} | ||
else if (bLaunchpad) { | ||
formData.append('client_id', clientId); | ||
formData.append('client_secret', clientSecret); | ||
} | ||
if (secureCookie) { | ||
@@ -738,24 +743,29 @@ formData.append('send_token_as_cookie', 'true'); | ||
formData.append('token_type_hint', prop); | ||
return fetch(revokeUri, { | ||
agent: this.#getAgent(), | ||
method: 'POST', | ||
headers: new Headers(headers), | ||
credentials: secureCookie ? 'include' : 'omit', | ||
body: formData.toString() | ||
}) | ||
.then(response => { | ||
if (!response.ok) { | ||
if (revokeUri) { | ||
return fetch(revokeUri, { | ||
agent: this.#getAgent(), | ||
method: 'POST', | ||
headers: new Headers(headers), | ||
credentials: secureCookie ? 'include' : 'omit', | ||
body: formData.toString() | ||
}) | ||
.then(response => { | ||
if (!response.ok) { | ||
// eslint-disable-next-line no-console | ||
console.error(`Error revoking ${prop}:${response.status}`); | ||
} | ||
}) | ||
.catch(e => { | ||
// eslint-disable-next-line no-console | ||
console.error(`Error revoking ${prop}:${response.status}`); | ||
} | ||
}) | ||
.catch(e => { | ||
// eslint-disable-next-line no-console | ||
console.error(`Error revoking ${prop}; ${e}`); | ||
}) | ||
.finally(() => { | ||
this.#dynState.silentAuthFailed = false; | ||
// Also clobber any sessionIndex | ||
this.#updateSessionIndex(null); | ||
}); | ||
console.error(`Error revoking ${prop}; ${e}`); | ||
}) | ||
.finally(() => { | ||
this.#dynState.silentAuthFailed = false; | ||
// Also clobber any sessionIndex | ||
this.#updateSessionIndex(null); | ||
}); | ||
} | ||
this.#dynState.silentAuthFailed = false; | ||
// Also clobber any sessionIndex | ||
this.#updateSessionIndex(null); | ||
} | ||
@@ -762,0 +772,0 @@ // For userinfo endpoint to return meaningful data, endpoint must include appAlias (if specified) and authorize must |
{ | ||
"name": "@pega/auth", | ||
"version": "0.2.20", | ||
"version": "0.2.21", | ||
"description": "Pega OAuth 2.0 Client Library (supports Infinity and Launchpad).", | ||
@@ -29,7 +29,7 @@ "repository": { | ||
"lint:es": "eslint --color --cache --cache-location node_modules/.cache/eslint/ .", | ||
"lint:format": "prettier --color --loglevel warn -c .", | ||
"lint:format": "prettier --color --log-level warn -c .", | ||
"lint:spelling": "cspell --color \"./**/*.@(ts|mts|cts|tsx|js|mjs|cjs|jsx|md|json|html)\" \"./@(*|.*)\" \".vscode/**\"", | ||
"lint:pkg": "sort-package-json --check package.json packages/*/package.json", | ||
"fix:es": "eslint --color --fix --cache --cache-location=node_modules/.cache/eslint/ .", | ||
"fix:format": "prettier --color --loglevel warn -w .", | ||
"fix:format": "prettier --color --log-level warn -w .", | ||
"fix:pkg": "sort-package-json package.json packages/*/package.json" | ||
@@ -36,0 +36,0 @@ }, |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
212092
2305