@criipto/oidc
Advanced tools
Comparing version 1.1.3 to 1.2.0
export { generate as generatePKCE } from './pkce'; | ||
export { parseQueryResponse, parseURLResponse } from './response'; | ||
import { type OpenIDConfiguration } from './OpenIDConfiguration'; | ||
import { AuthorizeResponse } from './response'; | ||
import { ErrorResponse } from './response'; | ||
export { OpenIDConfigurationManager, type OpenIDConfiguration } from './OpenIDConfiguration'; | ||
@@ -36,2 +36,12 @@ export declare function buildLogoutURL(configuration: OpenIDConfiguration, options: { | ||
code_verifier: string; | ||
}): Promise<AuthorizeResponse>; | ||
} | { | ||
code: string; | ||
redirect_uri: string; | ||
client_secret: string; | ||
}): Promise<{ | ||
id_token: string; | ||
access_token: string; | ||
} | ErrorResponse>; | ||
export declare function userInfo(configuration: OpenIDConfiguration, accessToken: string): Promise<{ | ||
[key: string]: string; | ||
} | ErrorResponse>; |
@@ -12,3 +12,3 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.codeExchange = exports.parseAuthorizeOptionsFromUrl = exports.buildAuthorizeURL = exports.buildLogoutURL = exports.OpenIDConfigurationManager = exports.parseURLResponse = exports.parseQueryResponse = exports.generatePKCE = void 0; | ||
exports.userInfo = exports.codeExchange = exports.parseAuthorizeOptionsFromUrl = exports.buildAuthorizeURL = exports.buildLogoutURL = exports.OpenIDConfigurationManager = exports.parseURLResponse = exports.parseQueryResponse = exports.generatePKCE = void 0; | ||
var pkce_1 = require("./pkce"); | ||
@@ -70,16 +70,35 @@ Object.defineProperty(exports, "generatePKCE", { enumerable: true, get: function () { return pkce_1.generate; } }); | ||
body.append('redirect_uri', options.redirect_uri); | ||
body.append('code_verifier', options.code_verifier); | ||
if ("code_verifier" in options) | ||
body.append('code_verifier', options.code_verifier); | ||
const response = yield fetch(configuration.token_endpoint, { | ||
method: 'POST', | ||
headers: Object.assign({ 'Content-Type': 'application/x-www-form-urlencoded' }, ("client_secret" in options ? { | ||
Authorization: "Basic " + btoa(`${configuration.client_id}:${options.client_secret}`) | ||
} : {})), | ||
credentials: 'omit', | ||
body: body.toString() | ||
}); | ||
const payload = yield response.json(); | ||
if (payload.error) | ||
return { error: payload.error, error_description: payload.error_description }; | ||
return { id_token: payload.id_token, access_token: payload.access_token }; | ||
}); | ||
} | ||
exports.codeExchange = codeExchange; | ||
function userInfo(configuration, accessToken) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
const response = yield fetch(configuration.userinfo_endpoint, { | ||
method: 'GET', | ||
headers: { | ||
'Content-Type': 'application/x-www-form-urlencoded' | ||
Authorization: `Bearer ${accessToken}` | ||
}, | ||
credentials: 'omit', | ||
body: body.toString() | ||
}); | ||
const payload = yield response.json(); | ||
return { id_token: payload.id_token }; | ||
if (payload.error) | ||
return { error: payload.error, error_description: payload.error_description, state: payload.state }; | ||
return payload; | ||
}); | ||
} | ||
exports.codeExchange = codeExchange; | ||
exports.userInfo = userInfo; | ||
//# sourceMappingURL=index.js.map |
{ | ||
"name": "@criipto/oidc", | ||
"version": "1.1.3", | ||
"version": "1.2.0", | ||
"description": "", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
24604
350
3