@@ -21,6 +21,15 @@ import type { WellKnownResponse } from '@forgerock/sdk-types';
2121import type { OidcConfig } from './config.types.js' ;
2222import { AuthorizeErrorResponse , AuthorizeSuccessResponse } from './authorize.request.types.js' ;
2323
24+ /**
25+ * @function authorizeµ
26+ * @description Creates an authorization URL for the OIDC client.
27+ * @param {WellKnownResponse } wellknown - The well-known configuration for the OIDC server.
28+ * @param {OidcConfig } config - The OIDC client configuration.
29+ * @param {CustomLogger } log - The logger instance for logging debug information.
30+ * @param {GetAuthorizationUrlOptions } options - Optional parameters for the authorization request.
31+ * @returns {Micro.Micro<AuthorizeSuccessResponse, AuthorizeErrorResponse, never> } - A micro effect that resolves to the authorization response.
32+ */
2433export async function authorizeµ (
2534 wellknown : WellKnownResponse ,
2635 config : OidcConfig ,
@@ -37,13 +46,18 @@ export async function authorizeµ(
3746 * If we support the pi.flow field, this means we are using a PingOne server.
3847 * PingOne servers do not support redirection through iframes because they
3948 * set iframe's to DENY.
49+ *
50+ * We do not use RTK Query for this because we don't want caching, or store
51+ * updates, and want the request to be made similar to the iframe method below.
52+ *
53+ * This returns a Micro that resolves to the parsed response JSON.
4054 */
4155 return authorizeFetchµ ( url ) . pipe (
4256 Micro . flatMap (
4357 ( response ) : Micro . Micro < AuthorizeSuccessResponse , AuthorizeErrorResponse , never > => {
44- if ( 'authorizeResponse ' in response ) {
45- log . debug ( 'Received authorize response' , response . authorizeResponse ) ;
46- return Micro . succeed ( response . authorizeResponse ) ;
58+ if ( 'code ' in response ) {
59+ log . debug ( 'Received code in response' , response ) ;
60+ return Micro . succeed ( response ) ;
4761 }
4862 log . error ( 'Error in authorize response' , response ) ;
4963 // For redirection, we need to remore `pi.flow` from the options
@@ -57,6 +71,9 @@ export async function authorizeµ(
5771 /**
5872 * If the response mode is not pi.flow, then we are likely using a traditional
5973 * redirect based server supporting iframes. An example would be PingAM.
74+ *
75+ * This returns a Micro that's either the success URL parameters or error URL
76+ * parameters.
6077 */
6178 return authorizeIframeµ ( url , config ) . pipe (
6279 Micro . flatMap (
0 commit comments