UNPKG

@okta-dfuhriman/okta-auth-js

Version:
44 lines (42 loc) 1.26 kB
"use strict"; exports.postToParEndpoint = postToParEndpoint; var _errors = require("../../errors"); var _authorize = require("./authorize"); var _http = require("../../http"); /* eslint-disable max-len */ async function postToParEndpoint(sdk, tokenParams) { const { jwtAuthorizationRequest = false, pushAuthorizationUrl: url, extraParams, ...options } = tokenParams || {}; const data = (0, _authorize.convertTokenParamsToOAuthParams)(options); const headers = { 'Content-Type': 'application/x-www-form-urlencoded' }; if (!url) { throw new _errors.AuthSdkError('In order to use push authorization request, a valid URL must be specified in the OktaAuth constructor that will generate the push authorization and return the appropriate response.'); } const now = Math.floor(Date.now() / 1000); const { client_assertion: clientAssertion, expires_in: expiresIn, request_uri: requestUri } = await (0, _http.httpRequest)(sdk, { url, method: 'POST', args: { 'jwt_authorization_request': jwtAuthorizationRequest, ...extraParams, ...data }, headers }); return { clientAssertion, expiresAt: expiresIn + now, requestUri }; } //# sourceMappingURL=par.js.map