/**
- * POST to the auth endpoint, to redeem a code for a profile object.
- * FIXME: [name] this isn't specific to profile redemption, it works for tokens too
+ * POST to the auth endpoint, to redeem a code for a profile or token.
+ * N.B. this absorbs any errors!
* @param {URL} urlObj
* @param {String} code
* @param {String} codeVerifier
* @param {String} redirectURI
* @returns {Object}
*/
- async redeemProfileCode(urlObj, code, codeVerifier, clientId, redirectURI) {
- const _scope = _fileScope('redeemProfileCode');
+ async redeemCode(urlObj, code, codeVerifier, clientId, redirectURI) {
+ const _scope = _fileScope('redeemCode');
const formData = common.formData({
'grant_type': 'authorization_code',
'code_verifier': codeVerifier,
});
- const postRedeemProfileCodeConfig = Communication._axiosConfig('POST', urlObj, formData, {}, {
+ const postRedeemCodeConfig = Communication._axiosConfig('POST', urlObj, formData, {}, {
[Enum.Header.ContentType]: Enum.ContentType.ApplicationForm,
[Enum.Header.Accept]: `${Enum.ContentType.ApplicationJson}, ${Enum.ContentType.Any};q=0.1`,
});
try {
- const response = await this.axios(postRedeemProfileCodeConfig);
+ const response = await this.axios(postRedeemCodeConfig);
try {
return JSON.parse(response.data);
} catch (e) {
throw e;
}
} catch (e) {
- this.logger.error(_scope, 'redeem profile code request failed', { error: e, url: urlObj.href });
+ this.logger.error(_scope, 'redeem code request failed', { error: e, url: urlObj.href });
return;
}
}
/**
- * Verify a token with an IdP endpoint, using the Authentication header supplied.
+ * Deprecated method name.
+ * @see redeemCode
+ * @param {URL} urlObj
+ * @param {String} code
+ * @param {Strin} codeVerifier
+ * @param {String} clientId
+ * @param {String} redirectURI
+ * @returns {Object}
+ */
+ async redeemProfileCode(urlObj, code, codeVerifier, clientId, redirectURI) {
+ return await this.redeemCode(urlObj, code, codeVerifier, clientId, redirectURI);
+ }
+
+
+ /**
+ * Verify a token with an IdP endpoint, using the Authorization header supplied.
* @param {URL} introspectionUrlObj
* @param {String} authorizationHeader
* @param {String} token
/**
* Attempt to deliver a ticket to an endpoint.
* N.B. does not absorb errors
- * @param {*} ticketEndpointUrlObj
- * @param {*} resourceUrlObj
- * @param {*} subjectUrlObj
- * @param {*} ticket
+ * @param {URL} ticketEndpointUrlObj
+ * @param {URL} resourceUrlObj
+ * @param {URL} subjectUrlObj
+ * @param {String} ticket
* @returns {Promise<AxiosResponse>}
*/
async deliverTicket(ticketEndpointUrlObj, resourceUrlObj, subjectUrlObj, ticket) {