@forgerock/oidc-client 0.0.0-beta-20250825180717 → 0.0.0-beta-20251003204059
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/src/lib/authorize.request.d.ts +4 -3
- package/dist/src/lib/authorize.request.d.ts.map +1 -1
- package/dist/src/lib/authorize.request.js +87 -20
- package/dist/src/lib/authorize.request.js.map +1 -1
- package/dist/src/lib/authorize.request.types.d.ts +38 -2
- package/dist/src/lib/authorize.request.types.d.ts.map +1 -1
- package/dist/src/lib/authorize.request.utils.d.ts +6 -21
- package/dist/src/lib/authorize.request.utils.d.ts.map +1 -1
- package/dist/src/lib/authorize.request.utils.js +10 -93
- package/dist/src/lib/authorize.request.utils.js.map +1 -1
- package/dist/src/lib/client.store.d.ts +19 -12
- package/dist/src/lib/client.store.d.ts.map +1 -1
- package/dist/src/lib/client.store.js +110 -18
- package/dist/src/lib/client.store.js.map +1 -1
- package/dist/src/lib/client.store.utils.d.ts +14 -2
- package/dist/src/lib/client.store.utils.d.ts.map +1 -1
- package/dist/src/lib/client.types.d.ts +22 -4
- package/dist/src/lib/client.types.d.ts.map +1 -1
- package/dist/src/lib/logout.request.d.ts +6 -9
- package/dist/src/lib/logout.request.d.ts.map +1 -1
- package/dist/src/lib/logout.request.js +22 -8
- package/dist/src/lib/logout.request.js.map +1 -1
- package/dist/src/lib/oidc.api.d.ts +14 -6
- package/dist/src/lib/oidc.api.d.ts.map +1 -1
- package/dist/src/lib/oidc.api.js +124 -0
- package/dist/src/lib/oidc.api.js.map +1 -1
- package/dist/src/types.d.ts +1 -0
- package/dist/src/types.d.ts.map +1 -1
- package/dist/src/types.js +0 -5
- package/dist/src/types.js.map +1 -1
- package/package.json +7 -7
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { CustomLogger } from '@forgerock/sdk-logger';
|
|
2
2
|
import { Micro } from 'effect';
|
|
3
3
|
import type { GetAuthorizationUrlOptions, WellKnownResponse } from '@forgerock/sdk-types';
|
|
4
|
+
import type { AuthorizationError, AuthorizationSuccess } from './authorize.request.types.js';
|
|
5
|
+
import type { createClientStore } from './client.store.utils.js';
|
|
4
6
|
import type { OidcConfig } from './config.types.js';
|
|
5
|
-
import type { AuthorizeErrorResponse, AuthorizeSuccessResponse } from './authorize.request.types.js';
|
|
6
7
|
/**
|
|
7
8
|
* @function authorizeµ
|
|
8
9
|
* @description Creates an authorization URL for the OIDC client.
|
|
@@ -10,7 +11,7 @@ import type { AuthorizeErrorResponse, AuthorizeSuccessResponse } from './authori
|
|
|
10
11
|
* @param {OidcConfig} config - The OIDC client configuration.
|
|
11
12
|
* @param {CustomLogger} log - The logger instance for logging debug information.
|
|
12
13
|
* @param {GetAuthorizationUrlOptions} options - Optional parameters for the authorization request.
|
|
13
|
-
* @returns {Micro.Micro<
|
|
14
|
+
* @returns {Micro.Micro<AuthorizationSuccess, AuthorizationError, never>} - A micro effect that resolves to the authorization response.
|
|
14
15
|
*/
|
|
15
|
-
export declare function authorizeµ(wellknown: WellKnownResponse, config: OidcConfig, log: CustomLogger, options?: GetAuthorizationUrlOptions): Micro.Micro<
|
|
16
|
+
export declare function authorizeµ(wellknown: WellKnownResponse, config: OidcConfig, log: CustomLogger, store: ReturnType<typeof createClientStore>, options?: GetAuthorizationUrlOptions): Micro.Micro<AuthorizationSuccess, AuthorizationError, never>;
|
|
16
17
|
//# sourceMappingURL=authorize.request.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"authorize.request.d.ts","sourceRoot":"","sources":["../../../src/lib/authorize.request.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AACrD,OAAO,EAAE,KAAK,EAAE,MAAM,QAAQ,CAAC;
|
|
1
|
+
{"version":3,"file":"authorize.request.d.ts","sourceRoot":"","sources":["../../../src/lib/authorize.request.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AACrD,OAAO,EAAE,KAAK,EAAE,MAAM,QAAQ,CAAC;AAQ/B,OAAO,KAAK,EAAE,0BAA0B,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AAE1F,OAAO,KAAK,EAAE,kBAAkB,EAAE,oBAAoB,EAAE,MAAM,8BAA8B,CAAC;AAC7F,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AACjE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAGpD;;;;;;;;GAQG;AACH,wBAAgB,UAAU,CACxB,SAAS,EAAE,iBAAiB,EAC5B,MAAM,EAAE,UAAU,EAClB,GAAG,EAAE,YAAY,EACjB,KAAK,EAAE,UAAU,CAAC,OAAO,iBAAiB,CAAC,EAC3C,OAAO,CAAC,EAAE,0BAA0B,gEA8IrC"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { Micro } from 'effect';
|
|
2
|
-
import {
|
|
2
|
+
import { createAuthorizeUrlµ, buildAuthorizeOptionsµ, createAuthorizeErrorµ, } from './authorize.request.utils.js';
|
|
3
|
+
import { oidcApi } from './oidc.api.js';
|
|
3
4
|
/**
|
|
4
5
|
* @function authorizeµ
|
|
5
6
|
* @description Creates an authorization URL for the OIDC client.
|
|
@@ -7,10 +8,10 @@ import { authorizeFetchµ, createAuthorizeUrlµ, authorizeIframeµ, buildAuthori
|
|
|
7
8
|
* @param {OidcConfig} config - The OIDC client configuration.
|
|
8
9
|
* @param {CustomLogger} log - The logger instance for logging debug information.
|
|
9
10
|
* @param {GetAuthorizationUrlOptions} options - Optional parameters for the authorization request.
|
|
10
|
-
* @returns {Micro.Micro<
|
|
11
|
+
* @returns {Micro.Micro<AuthorizationSuccess, AuthorizationError, never>} - A micro effect that resolves to the authorization response.
|
|
11
12
|
*/
|
|
12
|
-
export function authorizeµ(wellknown, config, log, options) {
|
|
13
|
-
return buildAuthorizeOptionsµ(wellknown, config, options).pipe(Micro.flatMap(([url, config, options]) => createAuthorizeUrlµ(url, config, options)), Micro.tap((url) => log.debug('Authorize URL created', url)), Micro.tapError((url) => Micro.sync(() => log.error('Error creating authorize URL', url))), Micro.flatMap(([url,
|
|
13
|
+
export function authorizeµ(wellknown, config, log, store, options) {
|
|
14
|
+
return buildAuthorizeOptionsµ(wellknown, config, options).pipe(Micro.flatMap(([url, config, options]) => createAuthorizeUrlµ(url, config, options)), Micro.tap((url) => log.debug('Authorize URL created', url)), Micro.tapError((url) => Micro.sync(() => log.error('Error creating authorize URL', url))), Micro.flatMap(([url, options]) => {
|
|
14
15
|
if (options.responseMode === 'pi.flow') {
|
|
15
16
|
/**
|
|
16
17
|
* If we support the pi.flow field, this means we are using a PingOne server.
|
|
@@ -22,16 +23,50 @@ export function authorizeµ(wellknown, config, log, options) {
|
|
|
22
23
|
*
|
|
23
24
|
* This returns a Micro that resolves to the parsed response JSON.
|
|
24
25
|
*/
|
|
25
|
-
return authorizeFetch
|
|
26
|
-
if (
|
|
27
|
-
|
|
28
|
-
|
|
26
|
+
return Micro.promise(() => store.dispatch(oidcApi.endpoints.authorizeFetch.initiate({ url }))).pipe(Micro.flatMap(({ error, data }) => {
|
|
27
|
+
if (error) {
|
|
28
|
+
// Check for serialized error
|
|
29
|
+
if (!('status' in error)) {
|
|
30
|
+
// This is a network or fetch error, so return it as-is
|
|
31
|
+
return Micro.fail({
|
|
32
|
+
error: error.code || 'Unknown_Error',
|
|
33
|
+
error_description: error.message || 'An unknown error occurred during authorization',
|
|
34
|
+
type: 'unknown_error',
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
// If there is no data, this is an unknown error
|
|
38
|
+
if (!('data' in error)) {
|
|
39
|
+
return Micro.fail({
|
|
40
|
+
error: 'Unknown_Error',
|
|
41
|
+
error_description: 'An unknown error occurred during authorization',
|
|
42
|
+
type: 'unknown_error',
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
const errorDetails = error.data;
|
|
46
|
+
// If the error is a configuration issue, return it as-is
|
|
47
|
+
if ('statusText' in error && error.statusText === 'CONFIGURATION_ERROR') {
|
|
48
|
+
return Micro.fail(errorDetails);
|
|
49
|
+
}
|
|
50
|
+
// If the error is not a configuration issue, we build a new Authorize URL
|
|
51
|
+
// For redirection, we need to remove `pi.flow` from the options
|
|
52
|
+
const redirectOptions = options;
|
|
53
|
+
delete redirectOptions.responseMode;
|
|
54
|
+
// Create an error with a new Authorize URL
|
|
55
|
+
return createAuthorizeErrorµ(errorDetails, wellknown, options);
|
|
56
|
+
}
|
|
57
|
+
log.debug('Received success response', data);
|
|
58
|
+
if (data.authorizeResponse) {
|
|
59
|
+
// Authorization was successful
|
|
60
|
+
return Micro.succeed(data.authorizeResponse);
|
|
61
|
+
}
|
|
62
|
+
else {
|
|
63
|
+
// This should never be reached, but just in case
|
|
64
|
+
return Micro.fail({
|
|
65
|
+
error: 'Unknown_Error',
|
|
66
|
+
error_description: 'Response schema was not recognized',
|
|
67
|
+
type: 'unknown_error',
|
|
68
|
+
});
|
|
29
69
|
}
|
|
30
|
-
log.error('Error in authorize response', response);
|
|
31
|
-
// For redirection, we need to remove `pi.flow` from the options
|
|
32
|
-
const redirectOptions = options;
|
|
33
|
-
delete redirectOptions.responseMode;
|
|
34
|
-
return createAuthorizeErrorµ(response, wellknown, config, options);
|
|
35
70
|
}));
|
|
36
71
|
}
|
|
37
72
|
else {
|
|
@@ -42,14 +77,46 @@ export function authorizeµ(wellknown, config, log, options) {
|
|
|
42
77
|
* This returns a Micro that's either the success URL parameters or error URL
|
|
43
78
|
* parameters.
|
|
44
79
|
*/
|
|
45
|
-
return authorizeIframe
|
|
46
|
-
if (
|
|
47
|
-
|
|
48
|
-
|
|
80
|
+
return Micro.promise(() => store.dispatch(oidcApi.endpoints.authorizeIframe.initiate({ url }))).pipe(Micro.flatMap(({ error, data }) => {
|
|
81
|
+
if (error) {
|
|
82
|
+
// Check for serialized error
|
|
83
|
+
if (!('status' in error)) {
|
|
84
|
+
// This is a network or fetch error, so return it as-is
|
|
85
|
+
return Micro.fail({
|
|
86
|
+
error: error.code || 'Unknown_Error',
|
|
87
|
+
error_description: error.message || 'An unknown error occurred during authorization',
|
|
88
|
+
type: 'unknown_error',
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
// If there is no data, this is an unknown error
|
|
92
|
+
if (!('data' in error)) {
|
|
93
|
+
return Micro.fail({
|
|
94
|
+
error: 'Unknown_Error',
|
|
95
|
+
error_description: 'An unknown error occurred during authorization',
|
|
96
|
+
type: 'unknown_error',
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
const errorDetails = error.data;
|
|
100
|
+
// If the error is a configuration issue, return it as-is
|
|
101
|
+
if ('statusText' in error && error.statusText === 'CONFIGURATION_ERROR') {
|
|
102
|
+
return Micro.fail(errorDetails);
|
|
103
|
+
}
|
|
104
|
+
// This is an expected error, so combine error with a new Authorize URL
|
|
105
|
+
return createAuthorizeErrorµ(errorDetails, wellknown, options);
|
|
106
|
+
}
|
|
107
|
+
log.debug('Received success response', data);
|
|
108
|
+
if (data) {
|
|
109
|
+
// Authorization was successful
|
|
110
|
+
return Micro.succeed(data);
|
|
111
|
+
}
|
|
112
|
+
else {
|
|
113
|
+
// This should never be reached, but just in case
|
|
114
|
+
return Micro.fail({
|
|
115
|
+
error: 'Unknown_Error',
|
|
116
|
+
error_description: 'Redirect parameters was not recognized',
|
|
117
|
+
type: 'unknown_error',
|
|
118
|
+
});
|
|
49
119
|
}
|
|
50
|
-
log.error('Error in authorize response', response);
|
|
51
|
-
const errorResponse = response;
|
|
52
|
-
return createAuthorizeErrorµ(errorResponse, wellknown, config, options);
|
|
53
120
|
}));
|
|
54
121
|
}
|
|
55
122
|
}));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"authorize.request.js","sourceRoot":"","sources":["../../../src/lib/authorize.request.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,KAAK,EAAE,MAAM,QAAQ,CAAC;AAE/B,OAAO,EACL,
|
|
1
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CAAC,YAAY,CAAC,CAAC;oBAClC,CAAC;oBAED,uEAAuE;oBACvE,OAAO,qBAAqB,CAAC,YAAY,EAAE,SAAS,EAAE,OAAO,CAAC,CAAC;gBACjE,CAAC;gBAED,GAAG,CAAC,KAAK,CAAC,2BAA2B,EAAE,IAAI,CAAC,CAAC;gBAE7C,IAAI,IAAI,EAAE,CAAC;oBACT,+BAA+B;oBAC/B,OAAO,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;gBAC7B,CAAC;qBAAM,CAAC;oBACN,iDAAiD;oBACjD,OAAO,KAAK,CAAC,IAAI,CAAC;wBAChB,KAAK,EAAE,eAAe;wBACtB,iBAAiB,EAAE,wCAAwC;wBAC3D,IAAI,EAAE,eAAe;qBACtB,CAAC,CAAC;gBACL,CAAC;YACH,CAAC,CACF,CACF,CAAC;QACJ,CAAC;IACH,CAAC,CACF,CACF,CAAC;AACJ,CAAC"}
|
|
@@ -1,11 +1,47 @@
|
|
|
1
|
+
export interface AuthorizeErrorResponse {
|
|
2
|
+
id?: string;
|
|
3
|
+
code?: string;
|
|
4
|
+
message?: string;
|
|
5
|
+
details?: [
|
|
6
|
+
{
|
|
7
|
+
code: string;
|
|
8
|
+
message: string;
|
|
9
|
+
}
|
|
10
|
+
];
|
|
11
|
+
}
|
|
1
12
|
export interface AuthorizeSuccessResponse {
|
|
13
|
+
_links?: {
|
|
14
|
+
[key: string]: {
|
|
15
|
+
href: string;
|
|
16
|
+
};
|
|
17
|
+
};
|
|
18
|
+
_embedded?: {
|
|
19
|
+
[key: string]: unknown;
|
|
20
|
+
};
|
|
21
|
+
id?: string;
|
|
22
|
+
environment?: {
|
|
23
|
+
id: string;
|
|
24
|
+
};
|
|
25
|
+
session?: {
|
|
26
|
+
id: string;
|
|
27
|
+
};
|
|
28
|
+
resumeUrl?: string;
|
|
29
|
+
status?: string;
|
|
30
|
+
createdAt?: string;
|
|
31
|
+
expiresAt?: string;
|
|
32
|
+
authorizeResponse?: {
|
|
33
|
+
code: string;
|
|
34
|
+
state: string;
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
export interface AuthorizationSuccess {
|
|
2
38
|
code: string;
|
|
3
39
|
state: string;
|
|
4
40
|
}
|
|
5
|
-
export interface
|
|
41
|
+
export interface AuthorizationError {
|
|
6
42
|
error: string;
|
|
7
43
|
error_description: string;
|
|
8
44
|
redirectUrl?: string;
|
|
9
|
-
type: 'auth_error' | 'argument_error' | 'wellknown_error';
|
|
45
|
+
type: 'auth_error' | 'argument_error' | 'network_error' | 'unknown_error' | 'wellknown_error';
|
|
10
46
|
}
|
|
11
47
|
//# sourceMappingURL=authorize.request.types.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"authorize.request.types.d.ts","sourceRoot":"","sources":["../../../src/lib/authorize.request.types.ts"],"names":[],"mappings":"AAMA,MAAM,WAAW,wBAAwB;IACvC,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;CACf;AAED,MAAM,WAAW,
|
|
1
|
+
{"version":3,"file":"authorize.request.types.d.ts","sourceRoot":"","sources":["../../../src/lib/authorize.request.types.ts"],"names":[],"mappings":"AAMA,MAAM,WAAW,sBAAsB;IACrC,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE;QACR;YACE,IAAI,EAAE,MAAM,CAAC;YACb,OAAO,EAAE,MAAM,CAAC;SACjB;KACF,CAAC;CACH;AAED,MAAM,WAAW,wBAAwB;IACvC,MAAM,CAAC,EAAE;QACP,CAAC,GAAG,EAAE,MAAM,GAAG;YACb,IAAI,EAAE,MAAM,CAAC;SACd,CAAC;KACH,CAAC;IACF,SAAS,CAAC,EAAE;QACV,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;KACxB,CAAC;IACF,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,WAAW,CAAC,EAAE;QACZ,EAAE,EAAE,MAAM,CAAC;KACZ,CAAC;IACF,OAAO,CAAC,EAAE;QACR,EAAE,EAAE,MAAM,CAAC;KACZ,CAAC;IACF,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,iBAAiB,CAAC,EAAE;QAClB,IAAI,EAAE,MAAM,CAAC;QACb,KAAK,EAAE,MAAM,CAAC;KACf,CAAC;CACH;AAED,MAAM,WAAW,oBAAoB;IACnC,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;CACf;AAED,MAAM,WAAW,kBAAkB;IACjC,KAAK,EAAE,MAAM,CAAC;IACd,iBAAiB,EAAE,MAAM,CAAC;IAC1B,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,IAAI,EAAE,YAAY,GAAG,gBAAgB,GAAG,eAAe,GAAG,eAAe,GAAG,iBAAiB,CAAC;CAC/F"}
|
|
@@ -1,23 +1,7 @@
|
|
|
1
1
|
import { Micro } from 'effect';
|
|
2
|
-
import { ResolvedParams } from '@forgerock/iframe-manager';
|
|
3
2
|
import type { WellKnownResponse, GetAuthorizationUrlOptions } from '@forgerock/sdk-types';
|
|
4
|
-
import type {
|
|
3
|
+
import type { AuthorizationError, AuthorizationSuccess } from './authorize.request.types.js';
|
|
5
4
|
import type { OidcConfig } from './config.types.js';
|
|
6
|
-
/**
|
|
7
|
-
* @function authorizeFetchµ
|
|
8
|
-
* @description Fetches the authorization response from the given URL.
|
|
9
|
-
* @param {string} url - The URL to fetch the authorization response from.
|
|
10
|
-
* @returns {Micro.Micro<AuthorizeSuccessResponse, AuthorizeErrorResponse, never>} - A micro effect that resolves to the authorization response.
|
|
11
|
-
*/
|
|
12
|
-
export declare function authorizeFetchµ(url: string): Micro.Micro<AuthorizeSuccessResponse | AuthorizeErrorResponse, AuthorizeErrorResponse, never>;
|
|
13
|
-
/**
|
|
14
|
-
* @function authorizeIframeµ
|
|
15
|
-
* @description Fetches the authorization response from the given URL using an iframe.
|
|
16
|
-
* @param {string} url - The authorization URL to be used for the iframe.
|
|
17
|
-
* @param {OidcConfig} config - The OIDC client configuration.
|
|
18
|
-
* @returns {Micro.Micro<ResolvedParams, AuthorizeErrorResponse, never>}
|
|
19
|
-
*/
|
|
20
|
-
export declare function authorizeIframeµ(url: string, config: OidcConfig): Micro.Micro<ResolvedParams, AuthorizeErrorResponse, never>;
|
|
21
5
|
type BuildAuthorizationData = [string, OidcConfig, GetAuthorizationUrlOptions];
|
|
22
6
|
export type OptionalAuthorizeOptions = Partial<GetAuthorizationUrlOptions>;
|
|
23
7
|
/**
|
|
@@ -28,7 +12,7 @@ export type OptionalAuthorizeOptions = Partial<GetAuthorizationUrlOptions>;
|
|
|
28
12
|
* @param {OptionalAuthorizeOptions} options - Optional parameters for the authorization request.
|
|
29
13
|
* @returns {Micro.Micro<BuildAuthorizationData, AuthorizeErrorResponse, never>}
|
|
30
14
|
*/
|
|
31
|
-
export declare function buildAuthorizeOptionsµ(wellknown: WellKnownResponse, config: OidcConfig, options?: OptionalAuthorizeOptions): Micro.Micro<BuildAuthorizationData,
|
|
15
|
+
export declare function buildAuthorizeOptionsµ(wellknown: WellKnownResponse, config: OidcConfig, options?: OptionalAuthorizeOptions): Micro.Micro<BuildAuthorizationData, AuthorizationError, never>;
|
|
32
16
|
/**
|
|
33
17
|
* @function createAuthorizeErrorµ
|
|
34
18
|
* @description Creates an error response with new Authorize URL for the authorization request.
|
|
@@ -41,15 +25,16 @@ export declare function buildAuthorizeOptionsµ(wellknown: WellKnownResponse, co
|
|
|
41
25
|
export declare function createAuthorizeErrorµ(res: {
|
|
42
26
|
error: string;
|
|
43
27
|
error_description: string;
|
|
44
|
-
}, wellknown: WellKnownResponse,
|
|
28
|
+
}, wellknown: WellKnownResponse, options: GetAuthorizationUrlOptions): Micro.Micro<never, AuthorizationError, never>;
|
|
45
29
|
/**
|
|
46
30
|
* @function createAuthorizeUrlµ
|
|
47
31
|
* @description Creates an authorization URL and related options/config for the Authorize request.
|
|
48
32
|
* @param {string} path - The path to the authorization endpoint.
|
|
49
33
|
* @param { OidcConfig } config - The OIDC client configuration.
|
|
50
34
|
* @param { GetAuthorizationUrlOptions } options - Optional parameters for the authorization request.
|
|
51
|
-
* @returns { Micro.Micro<[string, OidcConfig, GetAuthorizationUrlOptions],
|
|
35
|
+
* @returns { Micro.Micro<[string, OidcConfig, GetAuthorizationUrlOptions], AuthorizationError, never> }
|
|
52
36
|
*/
|
|
53
|
-
export declare function createAuthorizeUrlµ(path: string, config: OidcConfig, options: GetAuthorizationUrlOptions): Micro.Micro<[string,
|
|
37
|
+
export declare function createAuthorizeUrlµ(path: string, config: OidcConfig, options: GetAuthorizationUrlOptions): Micro.Micro<[string, GetAuthorizationUrlOptions], AuthorizationError, never>;
|
|
38
|
+
export declare function handleResponseµ(response: AuthorizationSuccess | AuthorizationError, wellknown: WellKnownResponse, config: OidcConfig, options: GetAuthorizationUrlOptions): Micro.Micro<AuthorizationSuccess, AuthorizationError, never>;
|
|
54
39
|
export {};
|
|
55
40
|
//# sourceMappingURL=authorize.request.utils.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"authorize.request.utils.d.ts","sourceRoot":"","sources":["../../../src/lib/authorize.request.utils.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,KAAK,EAAE,MAAM,QAAQ,CAAC;AAE/B,OAAO,
|
|
1
|
+
{"version":3,"file":"authorize.request.utils.d.ts","sourceRoot":"","sources":["../../../src/lib/authorize.request.utils.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,KAAK,EAAE,MAAM,QAAQ,CAAC;AAE/B,OAAO,KAAK,EAAE,iBAAiB,EAAE,0BAA0B,EAAE,MAAM,sBAAsB,CAAC;AAE1F,OAAO,KAAK,EAAE,kBAAkB,EAAE,oBAAoB,EAAE,MA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} from 'effect';
|
|
9
|
-
import { iFrameManager } from '@forgerock/iframe-manager';
|
|
10
|
-
/**
|
|
11
|
-
* @function authorizeFetchµ
|
|
12
|
-
* @description Fetches the authorization response from the given URL.
|
|
13
|
-
* @param {string} url - The URL to fetch the authorization response from.
|
|
14
|
-
* @returns {Micro.Micro<AuthorizeSuccessResponse, AuthorizeErrorResponse, never>} - A micro effect that resolves to the authorization response.
|
|
15
|
-
*/
|
|
16
|
-
export function authorizeFetchµ(url) {
|
|
17
|
-
return Micro.tryPromise({
|
|
18
|
-
try: async () => {
|
|
19
|
-
const response = await fetch(url, {
|
|
20
|
-
method: 'POST',
|
|
21
|
-
credentials: 'include',
|
|
22
|
-
});
|
|
23
|
-
const resJson = (await response.json());
|
|
24
|
-
if (!resJson || typeof resJson !== 'object') {
|
|
25
|
-
return {
|
|
26
|
-
error: 'Authorization Network Failure',
|
|
27
|
-
error_description: 'Failed to fetch authorization response',
|
|
28
|
-
type: 'auth_error',
|
|
29
|
-
};
|
|
30
|
-
}
|
|
31
|
-
if ('authorizeResponse' in resJson) {
|
|
32
|
-
// Return authorizeResponse as it contains the code and state
|
|
33
|
-
return resJson.authorizeResponse;
|
|
34
|
-
}
|
|
35
|
-
else if ('details' in resJson && resJson.details && Array.isArray(resJson.details)) {
|
|
36
|
-
const details = resJson.details[0];
|
|
37
|
-
// Return error response
|
|
38
|
-
return {
|
|
39
|
-
error: details.code || 'Unknown_Error',
|
|
40
|
-
error_description: details.message || 'An error occurred during authorization',
|
|
41
|
-
type: 'auth_error',
|
|
42
|
-
};
|
|
43
|
-
}
|
|
44
|
-
// Unrecognized response format
|
|
45
|
-
return {
|
|
46
|
-
error: 'Authorization Network Failure',
|
|
47
|
-
error_description: 'Unexpected response format from authorization endpoint',
|
|
48
|
-
type: 'auth_error',
|
|
49
|
-
};
|
|
50
|
-
},
|
|
51
|
-
catch: (err) => {
|
|
52
|
-
let message = 'Error fetching authorization URL';
|
|
53
|
-
if (err instanceof Error) {
|
|
54
|
-
message = err.message;
|
|
55
|
-
}
|
|
56
|
-
return {
|
|
57
|
-
error: 'Authorization Network Failure',
|
|
58
|
-
error_description: message,
|
|
59
|
-
type: 'auth_error',
|
|
60
|
-
};
|
|
61
|
-
},
|
|
62
|
-
});
|
|
63
|
-
}
|
|
64
|
-
/**
|
|
65
|
-
* @function authorizeIframeµ
|
|
66
|
-
* @description Fetches the authorization response from the given URL using an iframe.
|
|
67
|
-
* @param {string} url - The authorization URL to be used for the iframe.
|
|
68
|
-
* @param {OidcConfig} config - The OIDC client configuration.
|
|
69
|
-
* @returns {Micro.Micro<ResolvedParams, AuthorizeErrorResponse, never>}
|
|
70
|
-
*/
|
|
71
|
-
export function authorizeIframeµ(url, config) {
|
|
72
|
-
return Micro.tryPromise({
|
|
73
|
-
try: () => {
|
|
74
|
-
const params = iFrameManager().getParamsByRedirect({
|
|
75
|
-
url,
|
|
76
|
-
/***
|
|
77
|
-
* https://datatracker.ietf.org/doc/html/rfc6749#section-4.1.2
|
|
78
|
-
* The client MUST ignore unrecognized response parameters.
|
|
79
|
-
*/
|
|
80
|
-
successParams: ['code', 'state'],
|
|
81
|
-
errorParams: ['error', 'error_description'],
|
|
82
|
-
timeout: config.serverConfig.timeout || 3000,
|
|
83
|
-
});
|
|
84
|
-
return params;
|
|
85
|
-
},
|
|
86
|
-
catch: (err) => {
|
|
87
|
-
let message = 'Error calling authorization URL';
|
|
88
|
-
if (err instanceof Error) {
|
|
89
|
-
message = err.message;
|
|
90
|
-
}
|
|
91
|
-
return {
|
|
92
|
-
error: 'Authorization Network Failure',
|
|
93
|
-
error_description: message,
|
|
94
|
-
type: 'auth_error',
|
|
95
|
-
};
|
|
96
|
-
},
|
|
97
|
-
});
|
|
98
|
-
}
|
|
99
9
|
/**
|
|
100
10
|
* @function buildAuthorizeOptionsµ
|
|
101
11
|
* @description Builds the authorization options for the OIDC client.
|
|
@@ -128,7 +38,7 @@ export function buildAuthorizeOptionsµ(wellknown, config, options) {
|
|
|
128
38
|
* @param { GetAuthorizationUrlOptions } options- Optional parameters for the authorization request.
|
|
129
39
|
* @returns { Micro.Micro<never, AuthorizeErrorResponse, never> }
|
|
130
40
|
*/
|
|
131
|
-
export function createAuthorizeErrorµ(res, wellknown,
|
|
41
|
+
export function createAuthorizeErrorµ(res, wellknown, options) {
|
|
132
42
|
return Micro.tryPromise({
|
|
133
43
|
try: () => createAuthorizeUrl(wellknown.authorization_endpoint, {
|
|
134
44
|
...options,
|
|
@@ -159,7 +69,7 @@ export function createAuthorizeErrorµ(res, wellknown, config, options) {
|
|
|
159
69
|
* @param {string} path - The path to the authorization endpoint.
|
|
160
70
|
* @param { OidcConfig } config - The OIDC client configuration.
|
|
161
71
|
* @param { GetAuthorizationUrlOptions } options - Optional parameters for the authorization request.
|
|
162
|
-
* @returns { Micro.Micro<[string, OidcConfig, GetAuthorizationUrlOptions],
|
|
72
|
+
* @returns { Micro.Micro<[string, OidcConfig, GetAuthorizationUrlOptions], AuthorizationError, never> }
|
|
163
73
|
*/
|
|
164
74
|
export function createAuthorizeUrlµ(path, config, options) {
|
|
165
75
|
return Micro.tryPromise({
|
|
@@ -168,7 +78,6 @@ export function createAuthorizeUrlµ(path, config, options) {
|
|
|
168
78
|
...options,
|
|
169
79
|
prompt: 'none',
|
|
170
80
|
}),
|
|
171
|
-
config,
|
|
172
81
|
options,
|
|
173
82
|
],
|
|
174
83
|
catch: (error) => {
|
|
@@ -184,4 +93,12 @@ export function createAuthorizeUrlµ(path, config, options) {
|
|
|
184
93
|
},
|
|
185
94
|
});
|
|
186
95
|
}
|
|
96
|
+
export function handleResponseµ(response, wellknown, config, options) {
|
|
97
|
+
if ('code' in response) {
|
|
98
|
+
return Micro.sync(() => response);
|
|
99
|
+
}
|
|
100
|
+
else {
|
|
101
|
+
return createAuthorizeErrorµ(response, wellknown, options);
|
|
102
|
+
}
|
|
103
|
+
}
|
|
187
104
|
//# sourceMappingURL=authorize.request.utils.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"authorize.request.utils.js","sourceRoot":"","sources":["../../../src/lib/authorize.request.utils.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AACzD,OAAO,EAAE,KAAK,EAAE,MAAM,QAAQ,CAAC;
|
|
1
|
+
{"version":3,"file":"authorize.request.utils.js","sourceRoot":"","sources":["../../../src/lib/authorize.request.utils.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AACzD,OAAO,EAAE,KAAK,EAAE,MAAM,QAAQ,CAAC;AAU/B;;;;;;;GAOG;AACH,MAAM,UAAU,sBAAsB,CACpC,SAA4B,EAC5B,MAAkB,EAClB,OAAkC;IAElC,MAAM,QAAQ,GAAG,SAAS,CAAC,wBAAwB,EAAE,QAAQ,CAAC,SAAS,CAAC,CAAC;IACzE,OAAO,KAAK,CAAC,IAAI,CACf,GAA2B,EAAE,CAAC;QAC5B,SAAS,CAAC,sBAAsB;QAChC,MAAM;QACN;YACE,QAAQ,EAAE,MAAM,CAAC,QAAQ;YACzB,WAAW,EAAE,MAAM,CAAC,WAAW;YAC/B,KAAK,EAAE,MAAM,CAAC,KAAK,IAAI,QAAQ;YAC/B,YAAY,EAAE,MAAM,CAAC,YAAY,IAAI,MAAM;YAC3C,GAAG,CAAC,QAAQ,IAAI,EAAE,YAAY,EAAE,SAAS,EAAE,CAAC;YAC5C,GAAG,OAAO;SACX;KACF,CACF,CAAC;AACJ,CAAC;AAED;;;;;;;;GAQG;AACH,MAAM,UAAU,qBAAqB,CACnC,GAAiD,EACjD,SAA4B,EAC5B,OAAmC;IAEnC,OAAO,KAAK,CAAC,UAAU,CAAC;QACtB,GAAG,EAAE,GAAG,EAAE,CACR,kBAAkB,CAAC,SAAS,CAAC,sBAAsB,EAAE;YACnD,GAAG,OAAO;SACX,CAAC;QACJ,KAAK,EAAE,CAAC,KAAK,EAAE,E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AAM,IAAI,QAAQ,EAAE,CAAC;QACvB,OAAO,KAAK,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,QAAQ,CAAC,CAAC;IACpC,CAAC;SAAM,CAAC;QACN,OAAO,qBAAqB,CAAC,QAAQ,EAAE,SAAS,EAAE,OAAO,CAAC,CAAC;IAC7D,CAAC;AACH,CAAC"}
|
|
@@ -2,10 +2,10 @@ import { CustomLogger, LogLevel } from '@forgerock/sdk-logger';
|
|
|
2
2
|
import { StorageConfig } from '@forgerock/storage';
|
|
3
3
|
import type { ActionTypes, RequestMiddleware } from '@forgerock/sdk-request-middleware';
|
|
4
4
|
import type { GenericError, GetAuthorizationUrlOptions } from '@forgerock/sdk-types';
|
|
5
|
-
import type { GetTokensOptions,
|
|
5
|
+
import type { GetTokensOptions, LogoutErrorResult, LogoutSuccessResult, RevokeErrorResult, RevokeSuccessResult, UserInfoResponse } from './client.types.js';
|
|
6
6
|
import type { OauthTokens, OidcConfig } from './config.types.js';
|
|
7
|
-
import type {
|
|
8
|
-
import type { TokenExchangeErrorResponse
|
|
7
|
+
import type { AuthorizationError, AuthorizationSuccess } from './authorize.request.types.js';
|
|
8
|
+
import type { TokenExchangeErrorResponse } from './exchange.types.js';
|
|
9
9
|
/**
|
|
10
10
|
* @function oidc
|
|
11
11
|
* @description Factory function to create an OIDC client with methods for authorization, token exchange,
|
|
@@ -35,7 +35,7 @@ export declare function oidc<ActionType extends ActionTypes = ActionTypes>({ con
|
|
|
35
35
|
*/
|
|
36
36
|
authorize?: undefined;
|
|
37
37
|
/**
|
|
38
|
-
* An object containing methods for token
|
|
38
|
+
* An object containing methods for token management
|
|
39
39
|
*/
|
|
40
40
|
token?: undefined;
|
|
41
41
|
/**
|
|
@@ -59,10 +59,10 @@ export declare function oidc<ActionType extends ActionTypes = ActionTypes>({ con
|
|
|
59
59
|
* @param {GetAuthorizationUrlOptions} options - Optional parameters to customize the authorization URL.
|
|
60
60
|
* @returns {Promise<AuthorizeErrorResponse | AuthorizeSuccessResponse>} - Returns a promise that resolves to the authorization URL or an error response.
|
|
61
61
|
*/
|
|
62
|
-
background: (options?: GetAuthorizationUrlOptions) => Promise<
|
|
62
|
+
background: (options?: GetAuthorizationUrlOptions) => Promise<AuthorizationSuccess | AuthorizationError>;
|
|
63
63
|
};
|
|
64
64
|
/**
|
|
65
|
-
* An object containing methods for token
|
|
65
|
+
* An object containing methods for token management
|
|
66
66
|
*/
|
|
67
67
|
token: {
|
|
68
68
|
/**
|
|
@@ -79,9 +79,16 @@ export declare function oidc<ActionType extends ActionTypes = ActionTypes>({ con
|
|
|
79
79
|
* @method get
|
|
80
80
|
* @description Retrieves the current OAuth tokens from storage, or auto-renew if backgroundRenew is true.
|
|
81
81
|
* @param {GetTokensOptions} param - An object containing options for the token retrieval.
|
|
82
|
-
* @returns {Promise<OauthTokens | TokenExchangeErrorResponse |
|
|
82
|
+
* @returns {Promise<OauthTokens | TokenExchangeErrorResponse | AuthorizationError | GenericError>}
|
|
83
83
|
*/
|
|
84
|
-
get: (options?: GetTokensOptions) => Promise<OauthTokens | TokenExchangeErrorResponse |
|
|
84
|
+
get: (options?: GetTokensOptions) => Promise<OauthTokens | TokenExchangeErrorResponse | AuthorizationError | GenericError>;
|
|
85
|
+
/**
|
|
86
|
+
* @method revoke
|
|
87
|
+
* @description Revokes an access token using the revocation endpoint from the wellknown configuration.
|
|
88
|
+
* It requires an access token stored in the configured storage.
|
|
89
|
+
* @returns {Promise<GenericError | RevokeSuccessResult | RevokeErrorResult>} - Returns a promise that resolves to the revoke response or an error response.
|
|
90
|
+
*/
|
|
91
|
+
revoke: () => Promise<GenericError | RevokeSuccessResult | RevokeErrorResult>;
|
|
85
92
|
};
|
|
86
93
|
/**
|
|
87
94
|
* An object containing methods for user info retrieval and logout
|
|
@@ -91,16 +98,16 @@ export declare function oidc<ActionType extends ActionTypes = ActionTypes>({ con
|
|
|
91
98
|
* @method info
|
|
92
99
|
* @description Retrieves user information using the userinfo endpoint from the wellknown configuration.
|
|
93
100
|
* It requires an access token stored in the configured storage.
|
|
94
|
-
* @returns {Promise<GenericError |
|
|
101
|
+
* @returns {Promise<GenericError | UserInfoResponse>} - Returns a promise that resolves to user information or an error response.
|
|
95
102
|
*/
|
|
96
|
-
info: () => Promise<GenericError |
|
|
103
|
+
info: () => Promise<GenericError | UserInfoResponse>;
|
|
97
104
|
/**
|
|
98
105
|
* @method logout
|
|
99
106
|
* @description Logs out the user by revoking tokens and clearing the storage.
|
|
100
107
|
* It uses the end session endpoint from the wellknown configuration.
|
|
101
|
-
* @returns {Promise<GenericError |
|
|
108
|
+
* @returns {Promise<GenericError | LogoutSuccessResult | LogoutErrorResult>} - Returns a promise that resolves to the logout response or an error.
|
|
102
109
|
*/
|
|
103
|
-
logout: () => Promise<GenericError |
|
|
110
|
+
logout: () => Promise<GenericError | LogoutSuccessResult | LogoutErrorResult>;
|
|
104
111
|
};
|
|
105
112
|
error?: undefined;
|
|
106
113
|
type?: undefined;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.store.d.ts","sourceRoot":"","sources":["../../../src/lib/client.store.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,YAAY,EAAsB,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AAEnF,OAAO,EAAiB,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAUlE,OAAO,KAAK,EAAE,WAAW,EAAE,iBAAiB,EAAE,MAAM,mCAAmC,CAAC;AACxF,OAAO,KAAK,EAAE,YAAY,EAAE,0BAA0B,EAAE,MAAM,sBAAsB,CAAC;AAErF,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"client.store.d.ts","sourceRoot":"","sources":["../../../src/lib/client.store.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,YAAY,EAAsB,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AAEnF,OAAO,EAAiB,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAUlE,OAAO,KAAK,EAAE,WAAW,EAAE,iBAAiB,EAAE,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