@forgerock/oidc-client 1.2.0 → 2.0.0
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/README.md +294 -2
- package/dist/src/index.d.ts +1 -1
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +8 -1
- package/dist/src/index.js.map +1 -0
- package/dist/src/lib/authorize.request.d.ts +18 -0
- package/dist/src/lib/authorize.request.d.ts.map +1 -0
- package/dist/src/lib/authorize.request.js +125 -0
- package/dist/src/lib/authorize.request.js.map +1 -0
- package/dist/src/lib/authorize.request.types.d.ts +50 -0
- package/dist/src/lib/authorize.request.types.d.ts.map +1 -0
- package/dist/src/lib/authorize.request.types.js +2 -0
- package/dist/src/lib/authorize.request.types.js.map +1 -0
- package/dist/src/lib/authorize.request.utils.d.ts +35 -0
- package/dist/src/lib/authorize.request.utils.d.ts.map +1 -0
- package/dist/src/lib/authorize.request.utils.js +101 -0
- package/dist/src/lib/authorize.request.utils.js.map +1 -0
- package/dist/src/lib/authorize.slice.d.ts +5 -0
- package/dist/src/lib/authorize.slice.d.ts.map +1 -0
- package/dist/src/lib/authorize.slice.js +27 -0
- package/dist/src/lib/authorize.slice.js.map +1 -0
- package/dist/src/lib/client.store.d.ts +115 -0
- package/dist/src/lib/client.store.d.ts.map +1 -0
- package/dist/src/lib/client.store.js +435 -0
- package/dist/src/lib/client.store.js.map +1 -0
- package/dist/src/lib/client.store.utils.d.ts +104 -0
- package/dist/src/lib/client.store.utils.d.ts.map +1 -0
- package/dist/src/lib/client.store.utils.js +92 -0
- package/dist/src/lib/client.store.utils.js.map +1 -0
- package/dist/src/lib/client.types.d.ts +37 -0
- package/dist/src/lib/client.types.d.ts.map +1 -0
- package/dist/src/lib/client.types.js +2 -0
- package/dist/src/lib/client.types.js.map +1 -0
- package/dist/src/lib/config.types.d.ts +19 -0
- package/dist/src/lib/config.types.d.ts.map +1 -0
- package/dist/src/lib/config.types.js +2 -0
- package/dist/src/lib/config.types.js.map +1 -0
- package/dist/src/lib/exchange.request.d.ts +18 -0
- package/dist/src/lib/exchange.request.d.ts.map +1 -0
- package/dist/src/lib/exchange.request.js +22 -0
- package/dist/src/lib/exchange.request.js.map +1 -0
- package/dist/src/lib/exchange.types.d.ts +21 -0
- package/dist/src/lib/exchange.types.d.ts.map +1 -0
- package/dist/src/lib/exchange.types.js +2 -0
- package/dist/src/lib/exchange.types.js.map +1 -0
- package/dist/src/lib/exchange.utils.d.ts +28 -0
- package/dist/src/lib/exchange.utils.d.ts.map +1 -0
- package/dist/src/lib/exchange.utils.js +55 -0
- package/dist/src/lib/exchange.utils.js.map +1 -0
- package/dist/src/lib/logout.request.d.ts +13 -0
- package/dist/src/lib/logout.request.d.ts.map +1 -0
- package/dist/src/lib/logout.request.js +47 -0
- package/dist/src/lib/logout.request.js.map +1 -0
- package/dist/src/lib/oidc.api.d.ts +33 -0
- package/dist/src/lib/oidc.api.d.ts.map +1 -0
- package/dist/src/lib/oidc.api.js +295 -0
- package/dist/src/lib/oidc.api.js.map +1 -0
- package/dist/src/lib/oidc.api.utils.d.ts +3 -0
- package/dist/src/lib/oidc.api.utils.d.ts.map +1 -0
- package/dist/src/lib/oidc.api.utils.js +9 -0
- package/dist/src/lib/oidc.api.utils.js.map +1 -0
- package/dist/src/lib/token.utils.d.ts +2 -0
- package/dist/src/lib/token.utils.d.ts.map +1 -0
- package/dist/src/lib/token.utils.js +15 -0
- package/dist/src/lib/token.utils.js.map +1 -0
- package/dist/src/lib/wellknown.api.d.ts +236 -0
- package/dist/src/lib/wellknown.api.d.ts.map +1 -0
- package/dist/src/lib/wellknown.api.js +55 -0
- package/dist/src/lib/wellknown.api.js.map +1 -0
- package/dist/src/types.d.ts +9 -0
- package/dist/src/types.d.ts.map +1 -0
- package/dist/src/types.js +10 -0
- package/dist/src/types.js.map +1 -0
- package/dist/tsconfig.lib.tsbuildinfo +1 -1
- package/package.json +35 -10
- package/CHANGELOG.md +0 -11
- package/dist/src/lib/token-store.d.ts +0 -12
- package/dist/src/lib/token-store.d.ts.map +0 -1
- package/dist/src/lib/token-store.js +0 -9
- package/dist/src/lib/token-store.test-d.d.ts +0 -2
- package/dist/src/lib/token-store.test-d.d.ts.map +0 -1
- package/dist/src/lib/token-store.test-d.js +0 -43
- package/eslint.config.mjs +0 -22
- package/src/index.ts +0 -1
- package/src/lib/token-store.test-d.ts +0 -52
- package/src/lib/token-store.test.ts +0 -38
- package/src/lib/token-store.ts +0 -10
- package/tsconfig.json +0 -22
- package/tsconfig.lib.json +0 -40
- package/tsconfig.spec.json +0 -41
- package/typedoc.json +0 -4
- package/vite.config.ts +0 -23
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2025 Ping Identity Corporation. All rights reserved.
|
|
3
|
+
*
|
|
4
|
+
* This software may be modified and distributed under the terms
|
|
5
|
+
* of the MIT license. See the LICENSE file for details.
|
|
6
|
+
*/
|
|
7
|
+
import { createAuthorizeUrl } from '@forgerock/sdk-oidc';
|
|
8
|
+
import { Micro } from 'effect';
|
|
9
|
+
/**
|
|
10
|
+
* @function buildAuthorizeOptionsµ
|
|
11
|
+
* @description Builds the authorization options for the OIDC client.
|
|
12
|
+
* @param {WellknownResponse} wellknown - The well-known configuration for the OIDC server.
|
|
13
|
+
* @param {OptionalAuthorizeOptions} options - Optional parameters for the authorization request.
|
|
14
|
+
* @returns {Micro.Micro<BuildAuthorizationData, AuthorizationError, never>}
|
|
15
|
+
*/
|
|
16
|
+
export function buildAuthorizeOptionsµ(wellknown, config, options) {
|
|
17
|
+
const isPiFlow = wellknown.response_modes_supported?.includes('pi.flow');
|
|
18
|
+
return Micro.sync(() => [
|
|
19
|
+
wellknown.authorization_endpoint,
|
|
20
|
+
{
|
|
21
|
+
clientId: config.clientId,
|
|
22
|
+
redirectUri: config.redirectUri,
|
|
23
|
+
scope: config.scope || 'openid',
|
|
24
|
+
responseType: config.responseType || 'code',
|
|
25
|
+
...(isPiFlow && { responseMode: 'pi.flow' }),
|
|
26
|
+
...options,
|
|
27
|
+
},
|
|
28
|
+
]);
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* @function createAuthorizeErrorµ
|
|
32
|
+
* @description Creates an error response with new Authorize URL for the authorization request.
|
|
33
|
+
* @param { error: string; error_description: string } res - The error response from the authorization request.
|
|
34
|
+
* @param {WellknownResponse} wellknown- The well-known configuration for the OIDC server.
|
|
35
|
+
* @param { OidcConfig } config- The OIDC client configuration.
|
|
36
|
+
* @param { GetAuthorizationUrlOptions } options- Optional parameters for the authorization request.
|
|
37
|
+
* @returns { Micro.Micro<never, AuthorizationError, never> }
|
|
38
|
+
*/
|
|
39
|
+
export function createAuthorizeErrorµ(res, wellknown, options) {
|
|
40
|
+
return Micro.tryPromise({
|
|
41
|
+
try: () => createAuthorizeUrl(wellknown.authorization_endpoint, {
|
|
42
|
+
...options,
|
|
43
|
+
}),
|
|
44
|
+
catch: (error) => {
|
|
45
|
+
let message = 'Error creating authorization URL';
|
|
46
|
+
if (error instanceof Error) {
|
|
47
|
+
message = error.message;
|
|
48
|
+
}
|
|
49
|
+
return {
|
|
50
|
+
error: 'AuthorizationUrlError',
|
|
51
|
+
error_description: message,
|
|
52
|
+
type: 'auth_error',
|
|
53
|
+
};
|
|
54
|
+
},
|
|
55
|
+
}).pipe(Micro.flatMap((url) => {
|
|
56
|
+
return Micro.fail({
|
|
57
|
+
error: res.error,
|
|
58
|
+
error_description: res.error_description,
|
|
59
|
+
type: 'auth_error',
|
|
60
|
+
redirectUrl: url,
|
|
61
|
+
});
|
|
62
|
+
}));
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* @function createAuthorizeUrlµ
|
|
66
|
+
* @description Creates an authorization URL and related options/config for the Authorize request.
|
|
67
|
+
* @param {string} path - The path to the authorization endpoint.
|
|
68
|
+
* @param { GetAuthorizationUrlOptions } options - Optional parameters for the authorization request.
|
|
69
|
+
* @returns { Micro.Micro<[string, GetAuthorizationUrlOptions], AuthorizationError, never> }
|
|
70
|
+
*/
|
|
71
|
+
export function createAuthorizeUrlµ(path, options) {
|
|
72
|
+
return Micro.tryPromise({
|
|
73
|
+
try: async () => [
|
|
74
|
+
await createAuthorizeUrl(path, {
|
|
75
|
+
...options,
|
|
76
|
+
prompt: 'none',
|
|
77
|
+
}),
|
|
78
|
+
options,
|
|
79
|
+
],
|
|
80
|
+
catch: (error) => {
|
|
81
|
+
let message = 'Error creating authorization URL';
|
|
82
|
+
if (error instanceof Error) {
|
|
83
|
+
message = error.message;
|
|
84
|
+
}
|
|
85
|
+
return {
|
|
86
|
+
error: 'AuthorizationUrlError',
|
|
87
|
+
error_description: message,
|
|
88
|
+
type: 'auth_error',
|
|
89
|
+
};
|
|
90
|
+
},
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
export function handleResponseµ(response, wellknown, options) {
|
|
94
|
+
if ('code' in response) {
|
|
95
|
+
return Micro.sync(() => response);
|
|
96
|
+
}
|
|
97
|
+
else {
|
|
98
|
+
return createAuthorizeErrorµ(response, wellknown, options);
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
//# sourceMappingURL=authorize.request.utils.js.map
|
|
@@ -0,0 +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;AAW/B;;;;;;GAMG;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;YACE,QAAQ,EAAE,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AAC;YACf,MAAM,kBAAkB,CAAC,IAAI,EAAE;gBAC7B,GAAG,OAAO;gBACV,MAAM,EAAE,MAAM;aACf,CAAC;YACF,OAAO;SACR;QACD,KAAK,EAAE,CAAC,KAAK,EAAE,EAAE;YACf,IAAI,OAAO,GAAG,kCAAkC,CAAC;YACjD,IAAI,KAAK,YAAY,KAAK,EAAE,CAAC;gBAC3B,OAAO,GAAG,KAAK,CAAC,OAAO,CAAC;YAC1B,CAAC;YACD,OAAO;gBACL,KAAK,EAAE,uBAAuB;gBAC9B,iBAAiB,EAAE,OAAO;gBAC1B,IAAI,EAAE,YAAY;aACV,CAAC;QACb,CAAC;KACF,CAAC,CAAC;AACL,CAAC;AAED,MAAM,UAAU,eAAe,CAC7B,QAAmD,EACnD,SAA4B,EAC5B,OAAmC;IAEnC,IAAI,MAAM,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"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
declare const authorizeSlice: import("@reduxjs/toolkit/query").Api<import("@reduxjs/toolkit/query").BaseQueryFn<string | import("@reduxjs/toolkit/query").FetchArgs, unknown, import("@reduxjs/toolkit/query").FetchBaseQueryError, {}, import("@reduxjs/toolkit/query").FetchBaseQueryMeta>, {
|
|
2
|
+
handleAuthorize: import("@reduxjs/toolkit/query").QueryDefinition<string, import("@reduxjs/toolkit/query").BaseQueryFn<string | import("@reduxjs/toolkit/query").FetchArgs, unknown, import("@reduxjs/toolkit/query").FetchBaseQueryError, {}, import("@reduxjs/toolkit/query").FetchBaseQueryMeta>, never, string, "authorizeSlice", unknown>;
|
|
3
|
+
}, "authorizeSlice", never, typeof import("@reduxjs/toolkit/query").coreModuleName>;
|
|
4
|
+
export { authorizeSlice };
|
|
5
|
+
//# sourceMappingURL=authorize.slice.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"authorize.slice.d.ts","sourceRoot":"","sources":["../../../src/lib/authorize.slice.ts"],"names":[],"mappings":"AAQA,QAAA,MAAM,cAAc;;mFAkBlB,CAAC;AAEH,OAAO,EAAE,cAAc,EAAE,CAAC"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2025 Ping Identity Corporation. All rights reserved.
|
|
3
|
+
*
|
|
4
|
+
* This software may be modified and distributed under the terms
|
|
5
|
+
* of the MIT license. See the LICENSE file for details.
|
|
6
|
+
*/
|
|
7
|
+
import { createApi, fetchBaseQuery } from '@reduxjs/toolkit/query';
|
|
8
|
+
const authorizeSlice = createApi({
|
|
9
|
+
reducerPath: 'authorizeSlice',
|
|
10
|
+
baseQuery: fetchBaseQuery({
|
|
11
|
+
credentials: 'include',
|
|
12
|
+
prepareHeaders: (headers) => {
|
|
13
|
+
headers.set('Content-Type', 'application/json');
|
|
14
|
+
headers.set('Accept', 'application/json');
|
|
15
|
+
headers.set('x-requested-with', 'ping-sdk');
|
|
16
|
+
headers.set('x-requested-platform', 'javascript');
|
|
17
|
+
return headers;
|
|
18
|
+
},
|
|
19
|
+
}),
|
|
20
|
+
endpoints: (builder) => ({
|
|
21
|
+
handleAuthorize: builder.query({
|
|
22
|
+
query: (authorizeUrl) => authorizeUrl,
|
|
23
|
+
}),
|
|
24
|
+
}),
|
|
25
|
+
});
|
|
26
|
+
export { authorizeSlice };
|
|
27
|
+
//# sourceMappingURL=authorize.slice.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"authorize.slice.js","sourceRoot":"","sources":["../../../src/lib/authorize.slice.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,EAAE,SAAS,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAEnE,MAAM,cAAc,GAAG,SAAS,CAAC;IAC/B,WAAW,EAAE,gBAAgB;IAC7B,SAAS,EAAE,cAAc,CAAC;QACxB,WAAW,EAAE,SAAS;QACtB,cAAc,EAAE,CAAC,OAAO,EAAE,EAAE;YAC1B,OAAO,CAAC,GAAG,CAAC,cAAc,EAAE,kBAAkB,CAAC,CAAC;YAChD,OAAO,CAAC,GAAG,CAAC,QAAQ,EAAE,kBAAkB,CAAC,CAAC;YAC1C,OAAO,CAAC,GAAG,CAAC,kBAAkB,EAAE,UAAU,CAAC,CAAC;YAC5C,OAAO,CAAC,GAAG,CAAC,sBAAsB,EAAE,YAAY,CAAC,CAAC;YAElD,OAAO,OAAO,CAAC;QACjB,CAAC;KACF,CAAC;IACF,SAAS,EAAE,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC;QACvB,eAAe,EAAE,OAAO,CAAC,KAAK,CAAiB;YAC7C,KAAK,EAAE,CAAC,YAAY,EAAE,EAAE,CAAC,YAAY;SACtC,CAAC;KACH,CAAC;CACH,CAAC,CAAC;AAEH,OAAO,EAAE,cAAc,EAAE,CAAC"}
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
import type { ActionTypes, RequestMiddleware } from '@forgerock/sdk-request-middleware';
|
|
2
|
+
import type { GenericError, GetAuthorizationUrlOptions } from '@forgerock/sdk-types';
|
|
3
|
+
import type { CustomLogger, LogLevel } from '@forgerock/sdk-logger';
|
|
4
|
+
import type { StorageConfig } from '@forgerock/storage';
|
|
5
|
+
import type { GetTokensOptions, LogoutErrorResult, LogoutSuccessResult, RevokeErrorResult, RevokeSuccessResult, UserInfoResponse } from './client.types.js';
|
|
6
|
+
import type { OauthTokens, OidcConfig } from './config.types.js';
|
|
7
|
+
import type { AuthorizationError, AuthorizationSuccess } from './authorize.request.types.js';
|
|
8
|
+
import type { TokenExchangeErrorResponse } from './exchange.types.js';
|
|
9
|
+
/**
|
|
10
|
+
* @function oidc
|
|
11
|
+
* @description Factory function to create an OIDC client with methods for authorization, token exchange,
|
|
12
|
+
* user info retrieval, and logout. It initializes the client with the provided configuration,
|
|
13
|
+
* request middleware, logger, and storage options.
|
|
14
|
+
* @param param - configuration object containing the OIDC client configuration, request middleware, logger,
|
|
15
|
+
* @param {OidcConfig} param.config - OIDC configuration including server details, client ID, redirect URI,
|
|
16
|
+
* storage options, scope, and response type.
|
|
17
|
+
* @param {RequestMiddleware} param.requestMiddleware - optional array of request middleware functions to process requests.
|
|
18
|
+
* @param {{ level: LogLevel, custom: CustomLogger }} param.logger - optional logger configuration with log level and custom logger.
|
|
19
|
+
* @param {Partial<StorageConfig>} param.storage - optional storage configuration for persisting OIDC tokens.
|
|
20
|
+
* @returns {ReturnType<typeof oidc>} - Returns an object with methods for authorization, token exchange, user info retrieval, and logout.
|
|
21
|
+
*/
|
|
22
|
+
export declare function oidc<ActionType extends ActionTypes = ActionTypes>({ config, requestMiddleware, logger, storage, }: {
|
|
23
|
+
config: OidcConfig;
|
|
24
|
+
requestMiddleware?: RequestMiddleware<ActionType>[];
|
|
25
|
+
logger?: {
|
|
26
|
+
level: LogLevel;
|
|
27
|
+
custom?: CustomLogger;
|
|
28
|
+
};
|
|
29
|
+
storage?: Partial<StorageConfig>;
|
|
30
|
+
}): Promise<{
|
|
31
|
+
error: string;
|
|
32
|
+
type: string;
|
|
33
|
+
/**
|
|
34
|
+
* An object containing methods for the creation, and background use, of the authorization URL
|
|
35
|
+
*/
|
|
36
|
+
authorize?: undefined;
|
|
37
|
+
/**
|
|
38
|
+
* An object containing methods for token management
|
|
39
|
+
*/
|
|
40
|
+
token?: undefined;
|
|
41
|
+
/**
|
|
42
|
+
* An object containing methods for user info retrieval and logout
|
|
43
|
+
*/
|
|
44
|
+
user?: undefined;
|
|
45
|
+
} | {
|
|
46
|
+
/**
|
|
47
|
+
* An object containing methods for the creation, and background use, of the authorization URL
|
|
48
|
+
*/
|
|
49
|
+
authorize: {
|
|
50
|
+
/**
|
|
51
|
+
* @method url
|
|
52
|
+
* @description Creates an authorization URL with the provided options or defaults from the configuration.
|
|
53
|
+
* @param {GetAuthorizationUrlOptions} options - Optional parameters to customize the authorization URL.
|
|
54
|
+
* @returns {Promise<string | GenericError>} - Returns a promise that resolves to the authorization URL or an error.
|
|
55
|
+
*/
|
|
56
|
+
url: (options?: GetAuthorizationUrlOptions) => Promise<string | GenericError>;
|
|
57
|
+
/**
|
|
58
|
+
* @function background - Initiates the authorization process in the background, returning code and state or an error.
|
|
59
|
+
* @param {GetAuthorizationUrlOptions} options - Optional parameters to customize the authorization URL.
|
|
60
|
+
* @returns {Promise<AuthorizeErrorResponse | AuthorizeSuccessResponse>} - Returns a promise that resolves to code and state or an error response.
|
|
61
|
+
*/
|
|
62
|
+
background: (options?: GetAuthorizationUrlOptions) => Promise<AuthorizationSuccess | AuthorizationError>;
|
|
63
|
+
};
|
|
64
|
+
/**
|
|
65
|
+
* An object containing methods for token management
|
|
66
|
+
*/
|
|
67
|
+
token: {
|
|
68
|
+
/**
|
|
69
|
+
* @method exchange
|
|
70
|
+
* @description Exchanges an authorization code for tokens using the token endpoint from the wellknown
|
|
71
|
+
* configuration and stores them in the configured storage.
|
|
72
|
+
* @param {string} code - The authorization code received from the authorization server.
|
|
73
|
+
* @param {string} state - The state parameter from the authorization URL creation.
|
|
74
|
+
* @param {Partial<StorageConfig>} options - Optional storage configuration for persisting tokens.
|
|
75
|
+
* @returns {Promise<OauthTokens | GenericError | TokenExchangeErrorResponse>}
|
|
76
|
+
*/
|
|
77
|
+
exchange: (code: string, state: string, options?: Partial<StorageConfig>) => Promise<OauthTokens | TokenExchangeErrorResponse | GenericError>;
|
|
78
|
+
/**
|
|
79
|
+
* @method get
|
|
80
|
+
* @description Retrieves the current OAuth tokens from storage, or auto-renew if backgroundRenew is true.
|
|
81
|
+
* @param {GetTokensOptions} param - An object containing options for the token retrieval.
|
|
82
|
+
* @returns {Promise<OauthTokens | TokenExchangeErrorResponse | AuthorizationError | GenericError>}
|
|
83
|
+
*/
|
|
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>;
|
|
92
|
+
};
|
|
93
|
+
/**
|
|
94
|
+
* An object containing methods for user info retrieval and logout
|
|
95
|
+
*/
|
|
96
|
+
user: {
|
|
97
|
+
/**
|
|
98
|
+
* @method info
|
|
99
|
+
* @description Retrieves user information using the userinfo endpoint from the wellknown configuration.
|
|
100
|
+
* It requires an access token stored in the configured storage.
|
|
101
|
+
* @returns {Promise<GenericError | UserInfoResponse>} - Returns a promise that resolves to user information or an error response.
|
|
102
|
+
*/
|
|
103
|
+
info: () => Promise<GenericError | UserInfoResponse>;
|
|
104
|
+
/**
|
|
105
|
+
* @method logout
|
|
106
|
+
* @description Logs out the user by revoking tokens and clearing the storage.
|
|
107
|
+
* It uses the end session endpoint from the wellknown configuration.
|
|
108
|
+
* @returns {Promise<GenericError | LogoutSuccessResult | LogoutErrorResult>} - Returns a promise that resolves to the logout response or an error.
|
|
109
|
+
*/
|
|
110
|
+
logout: () => Promise<GenericError | LogoutSuccessResult | LogoutErrorResult>;
|
|
111
|
+
};
|
|
112
|
+
error?: undefined;
|
|
113
|
+
type?: undefined;
|
|
114
|
+
}>;
|
|
115
|
+
//# sourceMappingURL=client.store.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.store.d.ts","sourceRoot":"","sources":["../../../src/lib/client.store.ts"],"names":[],"mappings":"AAkBA,OAAO,KAAK,EAAE,WAAW,EAAE,iBAAiB,EAAE,MAAM,mCAAmC,CAAC;AACxF,OA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