@okta/auth-foundation 0.6.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/LICENSE +189 -0
- package/THIRD-PARTY-NOTICES.md +5 -0
- package/dist/esm/Credential/Credential.js +219 -0
- package/dist/esm/Credential/Credential.js.map +1 -0
- package/dist/esm/Credential/CredentialCoordinator.js +160 -0
- package/dist/esm/Credential/CredentialCoordinator.js.map +1 -0
- package/dist/esm/Credential/CredentialDataSource.js +61 -0
- package/dist/esm/Credential/CredentialDataSource.js.map +1 -0
- package/dist/esm/Credential/TokenStorage.js +99 -0
- package/dist/esm/Credential/TokenStorage.js.map +1 -0
- package/dist/esm/FetchClient.js +91 -0
- package/dist/esm/FetchClient.js.map +1 -0
- package/dist/esm/Token.js +274 -0
- package/dist/esm/Token.js.map +1 -0
- package/dist/esm/TokenOrchestrator.js +56 -0
- package/dist/esm/TokenOrchestrator.js.map +1 -0
- package/dist/esm/core.js +59 -0
- package/dist/esm/core.js.map +1 -0
- package/dist/esm/crypto/index.js +60 -0
- package/dist/esm/crypto/index.js.map +1 -0
- package/dist/esm/errors/APIClientError.js +19 -0
- package/dist/esm/errors/APIClientError.js.map +1 -0
- package/dist/esm/errors/AuthSdkError.js +22 -0
- package/dist/esm/errors/AuthSdkError.js.map +1 -0
- package/dist/esm/errors/CredentialError.js +19 -0
- package/dist/esm/errors/CredentialError.js.map +1 -0
- package/dist/esm/errors/DPoPError.js +19 -0
- package/dist/esm/errors/DPoPError.js.map +1 -0
- package/dist/esm/errors/JWTError.js +19 -0
- package/dist/esm/errors/JWTError.js.map +1 -0
- package/dist/esm/errors/NetworkError.js +19 -0
- package/dist/esm/errors/NetworkError.js.map +1 -0
- package/dist/esm/errors/OAuth2Error.js +34 -0
- package/dist/esm/errors/OAuth2Error.js.map +1 -0
- package/dist/esm/errors/TokenError.js +19 -0
- package/dist/esm/errors/TokenError.js.map +1 -0
- package/dist/esm/errors/TokenOrchestratorError.js +19 -0
- package/dist/esm/errors/TokenOrchestratorError.js.map +1 -0
- package/dist/esm/http/APIClient.js +172 -0
- package/dist/esm/http/APIClient.js.map +1 -0
- package/dist/esm/http/oktaUserAgent.js +23 -0
- package/dist/esm/http/oktaUserAgent.js.map +1 -0
- package/dist/esm/http/requests/APIRequest.js +41 -0
- package/dist/esm/http/requests/APIRequest.js.map +1 -0
- package/dist/esm/http/requests/OAuth2Request.js +38 -0
- package/dist/esm/http/requests/OAuth2Request.js.map +1 -0
- package/dist/esm/http/wwwAuthenticate.js +48 -0
- package/dist/esm/http/wwwAuthenticate.js.map +1 -0
- package/dist/esm/index.js +64 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/internal.js +17 -0
- package/dist/esm/internal.js.map +1 -0
- package/dist/esm/jwt/IDTokenValidator.js +115 -0
- package/dist/esm/jwt/IDTokenValidator.js.map +1 -0
- package/dist/esm/jwt/JWK.js +48 -0
- package/dist/esm/jwt/JWK.js.map +1 -0
- package/dist/esm/jwt/JWT.js +159 -0
- package/dist/esm/jwt/JWT.js.map +1 -0
- package/dist/esm/jwt/TokenHashValidator.js +44 -0
- package/dist/esm/jwt/TokenHashValidator.js.map +1 -0
- package/dist/esm/oauth2/client.js +386 -0
- package/dist/esm/oauth2/client.js.map +1 -0
- package/dist/esm/oauth2/configuration.js +86 -0
- package/dist/esm/oauth2/configuration.js.map +1 -0
- package/dist/esm/oauth2/dpop/index.js +84 -0
- package/dist/esm/oauth2/dpop/index.js.map +1 -0
- package/dist/esm/oauth2/dpop/nonceCache.js +31 -0
- package/dist/esm/oauth2/dpop/nonceCache.js.map +1 -0
- package/dist/esm/oauth2/dpop/storage.js +39 -0
- package/dist/esm/oauth2/dpop/storage.js.map +1 -0
- package/dist/esm/oauth2/pkce.js +33 -0
- package/dist/esm/oauth2/pkce.js.map +1 -0
- package/dist/esm/oauth2/requests/UserInfo.js +40 -0
- package/dist/esm/oauth2/requests/UserInfo.js.map +1 -0
- package/dist/esm/platform/Platform.js +54 -0
- package/dist/esm/platform/Platform.js.map +1 -0
- package/dist/esm/platform/defaults.js +28 -0
- package/dist/esm/platform/defaults.js.map +1 -0
- package/dist/esm/types/oauth.js +41 -0
- package/dist/esm/types/oauth.js.map +1 -0
- package/dist/esm/utils/EventEmitter.js +63 -0
- package/dist/esm/utils/EventEmitter.js.map +1 -0
- package/dist/esm/utils/PromiseQueue.js +50 -0
- package/dist/esm/utils/PromiseQueue.js.map +1 -0
- package/dist/esm/utils/TaskBridge.js +242 -0
- package/dist/esm/utils/TaskBridge.js.map +1 -0
- package/dist/esm/utils/TimeCoordinator.js +77 -0
- package/dist/esm/utils/TimeCoordinator.js.map +1 -0
- package/dist/esm/utils/buildUrl.js +23 -0
- package/dist/esm/utils/buildUrl.js.map +1 -0
- package/dist/esm/utils/equality.js +38 -0
- package/dist/esm/utils/equality.js.map +1 -0
- package/dist/esm/utils/getSearchParam.js +24 -0
- package/dist/esm/utils/getSearchParam.js.map +1 -0
- package/dist/esm/utils/hashObject.js +30 -0
- package/dist/esm/utils/hashObject.js.map +1 -0
- package/dist/esm/utils/ignoreUndefineds.js +24 -0
- package/dist/esm/utils/ignoreUndefineds.js.map +1 -0
- package/dist/esm/utils/merge.js +47 -0
- package/dist/esm/utils/merge.js.map +1 -0
- package/dist/esm/utils/pause.js +20 -0
- package/dist/esm/utils/pause.js.map +1 -0
- package/dist/esm/utils/toRelativeUrl.js +19 -0
- package/dist/esm/utils/toRelativeUrl.js.map +1 -0
- package/dist/esm/utils/validators.js +32 -0
- package/dist/esm/utils/validators.js.map +1 -0
- package/dist/types/Credential/Credential.d.ts +292 -0
- package/dist/types/Credential/CredentialCoordinator.d.ts +103 -0
- package/dist/types/Credential/CredentialDataSource.d.ts +75 -0
- package/dist/types/Credential/TokenStorage.d.ts +116 -0
- package/dist/types/Credential/index.d.ts +8 -0
- package/dist/types/FetchClient.d.ts +28 -0
- package/dist/types/Token.d.ts +246 -0
- package/dist/types/TokenOrchestrator.d.ts +64 -0
- package/dist/types/core.d.ts +21 -0
- package/dist/types/crypto/index.d.ts +32 -0
- package/dist/types/errors/APIClientError.d.ts +12 -0
- package/dist/types/errors/AuthSdkError.d.ts +20 -0
- package/dist/types/errors/CredentialError.d.ts +12 -0
- package/dist/types/errors/DPoPError.d.ts +12 -0
- package/dist/types/errors/JWTError.d.ts +12 -0
- package/dist/types/errors/NetworkError.d.ts +12 -0
- package/dist/types/errors/OAuth2Error.d.ts +17 -0
- package/dist/types/errors/TokenError.d.ts +12 -0
- package/dist/types/errors/TokenOrchestratorError.d.ts +12 -0
- package/dist/types/errors/index.d.ts +13 -0
- package/dist/types/http/APIClient.d.ts +113 -0
- package/dist/types/http/index.d.ts +6 -0
- package/dist/types/http/oktaUserAgent.d.ts +8 -0
- package/dist/types/http/requests/APIRequest.d.ts +19 -0
- package/dist/types/http/requests/OAuth2Request.d.ts +30 -0
- package/dist/types/http/wwwAuthenticate.d.ts +32 -0
- package/dist/types/index.d.ts +4 -0
- package/dist/types/internal.d.ts +8 -0
- package/dist/types/jwt/IDTokenValidator.d.ts +38 -0
- package/dist/types/jwt/JWK.d.ts +31 -0
- package/dist/types/jwt/JWT.d.ts +107 -0
- package/dist/types/jwt/TokenHashValidator.d.ts +13 -0
- package/dist/types/jwt/index.d.ts +8 -0
- package/dist/types/oauth2/client.d.ts +120 -0
- package/dist/types/oauth2/configuration.d.ts +56 -0
- package/dist/types/oauth2/dpop/index.d.ts +70 -0
- package/dist/types/oauth2/dpop/nonceCache.d.ts +27 -0
- package/dist/types/oauth2/dpop/storage.d.ts +27 -0
- package/dist/types/oauth2/dpop/types.d.ts +52 -0
- package/dist/types/oauth2/pkce.d.ts +23 -0
- package/dist/types/oauth2/requests/UserInfo.d.ts +32 -0
- package/dist/types/platform/Platform.d.ts +121 -0
- package/dist/types/platform/defaults.d.ts +10 -0
- package/dist/types/types/index.d.ts +6 -0
- package/dist/types/types/lib.d.ts +106 -0
- package/dist/types/types/oauth.d.ts +117 -0
- package/dist/types/types/openid.d.ts +320 -0
- package/dist/types/utils/EventEmitter.d.ts +29 -0
- package/dist/types/utils/PromiseQueue.d.ts +18 -0
- package/dist/types/utils/TaskBridge.d.ts +153 -0
- package/dist/types/utils/TimeCoordinator.d.ts +49 -0
- package/dist/types/utils/buildUrl.d.ts +10 -0
- package/dist/types/utils/equality.d.ts +19 -0
- package/dist/types/utils/getSearchParam.d.ts +13 -0
- package/dist/types/utils/hashObject.d.ts +6 -0
- package/dist/types/utils/ignoreUndefineds.d.ts +14 -0
- package/dist/types/utils/index.d.ts +13 -0
- package/dist/types/utils/merge.d.ts +16 -0
- package/dist/types/utils/pause.d.ts +15 -0
- package/dist/types/utils/toRelativeUrl.d.ts +10 -0
- package/dist/types/utils/validators.d.ts +6 -0
- package/package.json +1 -0
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module
|
|
3
|
+
* @mergeModuleWith OAuth2
|
|
4
|
+
*/
|
|
5
|
+
import type { JsonPrimitive } from '../../types/index.ts';
|
|
6
|
+
import { Token } from '../../Token.ts';
|
|
7
|
+
import { OAuth2Request } from '../../http/index.ts';
|
|
8
|
+
/**
|
|
9
|
+
* @group OAuth2Request
|
|
10
|
+
*/
|
|
11
|
+
export interface UserInfo {
|
|
12
|
+
[key: string]: JsonPrimitive;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* @internal
|
|
16
|
+
*/
|
|
17
|
+
export declare namespace UserInfo {
|
|
18
|
+
/**
|
|
19
|
+
* @internal
|
|
20
|
+
*/
|
|
21
|
+
interface RequestParams extends OAuth2Request.RequestParams {
|
|
22
|
+
token: Token;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* @internal
|
|
26
|
+
*/
|
|
27
|
+
class Request extends OAuth2Request {
|
|
28
|
+
token: Token;
|
|
29
|
+
constructor(params: RequestParams);
|
|
30
|
+
get url(): string;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
import { AuthSdkError } from '../errors/AuthSdkError.ts';
|
|
2
|
+
import type { DPoPSigningAuthority } from '../oauth2/dpop/index.ts';
|
|
3
|
+
import type { TimeCoordinator } from '../utils/TimeCoordinator.ts';
|
|
4
|
+
import type { DPoPNonceCache } from '../oauth2/dpop/index.ts';
|
|
5
|
+
/**
|
|
6
|
+
* The required Platform dependencies
|
|
7
|
+
*/
|
|
8
|
+
export interface PlatformDependencies {
|
|
9
|
+
TimeCoordinator: TimeCoordinator;
|
|
10
|
+
DPoPSigningAuthority: DPoPSigningAuthority;
|
|
11
|
+
DPoPNonceCache: DPoPNonceCache;
|
|
12
|
+
}
|
|
13
|
+
export declare class PlatformRegistryError extends AuthSdkError {
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* A singleton registry of globally-available singleton dependencies which can
|
|
17
|
+
* provide platform-specific default implementations and enable overriding as needed
|
|
18
|
+
*
|
|
19
|
+
* For example, the {@link TimeCoordinator} should be globally available to be a
|
|
20
|
+
* centralized entity to perform all time calculations. Registering the {@link TimeCoordinator}
|
|
21
|
+
* as a {@link Platform} dependency enables consumers to access the {@link TimeCoordinator} via
|
|
22
|
+
*
|
|
23
|
+
* @example
|
|
24
|
+
* ```
|
|
25
|
+
* import { Platform } from '@okta/auth-foundation';
|
|
26
|
+
* const currentTime = Platform.TimeCoordinator.now();
|
|
27
|
+
* ```
|
|
28
|
+
*
|
|
29
|
+
* To enable tree-shaking and prevent including default implementations (bundle bloat) which
|
|
30
|
+
* will be instantaneously overwritten, default implementations can be selectively included.
|
|
31
|
+
*
|
|
32
|
+
* @remarks
|
|
33
|
+
* Use `import * from '@okta/auth-foundation'` for standard usage, including all default platform
|
|
34
|
+
* dependency implementations.
|
|
35
|
+
*
|
|
36
|
+
* Use `import * from '@okta/auth-foundation/core'` for deeper customizations of platform dependencies,
|
|
37
|
+
* this does not include any default implementations. {@link PlatformRegistryError} will be thrown if
|
|
38
|
+
* a dependency is used before an implementation is provided
|
|
39
|
+
*/
|
|
40
|
+
export declare class PlatformRegistry implements PlatformDependencies {
|
|
41
|
+
#private;
|
|
42
|
+
/**
|
|
43
|
+
* Override default platform dependencies globally
|
|
44
|
+
*
|
|
45
|
+
* This pattern will include the default implementations within the resulting bundle,
|
|
46
|
+
* causing essentially dead code to be bundled. This will likely be acceptable for
|
|
47
|
+
* most standard use cases. For scenarios where deeper customizations are required
|
|
48
|
+
* see {@link PlatformRegistry.registerDefaultsLoader}
|
|
49
|
+
*
|
|
50
|
+
* @remarks
|
|
51
|
+
* Call this once at application startup before using any SDK components.
|
|
52
|
+
* Partial updates are supported - only override what you need.
|
|
53
|
+
*/
|
|
54
|
+
configure(dependencies: Partial<PlatformDependencies>): void;
|
|
55
|
+
/**
|
|
56
|
+
* Registers a loader to provide the platform dependency default implementations
|
|
57
|
+
*
|
|
58
|
+
* When a deeper customization of platform dependencies is required, this method can
|
|
59
|
+
* be used to provide custom implementations of platform dependencies without including
|
|
60
|
+
* the provided default implementations in any resulting bundle.
|
|
61
|
+
*
|
|
62
|
+
* This pattern is not recommended for standard SDK usage and should only be used if deep
|
|
63
|
+
* customization is required (like providing support to an otherwise unsupported runtime environment)
|
|
64
|
+
*
|
|
65
|
+
* For standard usage, see {@link PlatformRegistry.configure}
|
|
66
|
+
*
|
|
67
|
+
* @remarks
|
|
68
|
+
* Call this once at application startup before using any SDK components.
|
|
69
|
+
*
|
|
70
|
+
* @example
|
|
71
|
+
* ```
|
|
72
|
+
* // src/auth.ts
|
|
73
|
+
* import { Platform } from '@okta/auth-foundation/core'; // ensure "/core" is imported specifically
|
|
74
|
+
*
|
|
75
|
+
* Platform.registerDefaultsLoader(() => ({
|
|
76
|
+
* TimeCoordinator: MyCustomTimeCoordinator
|
|
77
|
+
* // define other dependencies
|
|
78
|
+
* }));
|
|
79
|
+
*
|
|
80
|
+
* // ensure this module is loaded before any other '@okta/*' dependencies
|
|
81
|
+
* ```
|
|
82
|
+
*/
|
|
83
|
+
registerDefaultsLoader(loader: () => PlatformDependencies): void;
|
|
84
|
+
/**
|
|
85
|
+
* @internal
|
|
86
|
+
* Resets loaded dependencies. For testing purposes mostly.
|
|
87
|
+
*/
|
|
88
|
+
reset(): void;
|
|
89
|
+
/**
|
|
90
|
+
* @internal
|
|
91
|
+
* Get all current dependencies (configured or defaults)
|
|
92
|
+
*/
|
|
93
|
+
protected get resolved(): PlatformDependencies;
|
|
94
|
+
/**
|
|
95
|
+
* @internal
|
|
96
|
+
* Override in subclasses to provide platform-specific defaults
|
|
97
|
+
*/
|
|
98
|
+
protected getDefaults(): PlatformDependencies;
|
|
99
|
+
/**
|
|
100
|
+
* Get the current TimeCoordinator instance
|
|
101
|
+
*
|
|
102
|
+
* @remarks
|
|
103
|
+
* Returns configured override or factory default
|
|
104
|
+
*/
|
|
105
|
+
get TimeCoordinator(): TimeCoordinator;
|
|
106
|
+
/**
|
|
107
|
+
* Get the current DPoPSigningAuthority instance
|
|
108
|
+
*
|
|
109
|
+
* @remarks
|
|
110
|
+
* Returns configured override or factory default
|
|
111
|
+
*/
|
|
112
|
+
get DPoPSigningAuthority(): DPoPSigningAuthority;
|
|
113
|
+
/**
|
|
114
|
+
* Get the current DPoPNonceCache instance
|
|
115
|
+
*
|
|
116
|
+
* @remarks
|
|
117
|
+
* Returns configured override or factory default
|
|
118
|
+
*/
|
|
119
|
+
get DPoPNonceCache(): DPoPNonceCache;
|
|
120
|
+
}
|
|
121
|
+
export declare const Platform: PlatformRegistry;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { PlatformDependencies } from './Platform.ts';
|
|
2
|
+
import { DefaultTimeCoordinator } from '../utils/TimeCoordinator.ts';
|
|
3
|
+
declare const TimeCoordinator: DefaultTimeCoordinator;
|
|
4
|
+
export { TimeCoordinator };
|
|
5
|
+
/**
|
|
6
|
+
* @internal
|
|
7
|
+
* *DO NOT IMPORT THIS FILE* in any location other than `src/index.ts` to avoid including default
|
|
8
|
+
* platform implementations in bundle output
|
|
9
|
+
*/
|
|
10
|
+
export declare const PlatformDefaults: PlatformDependencies;
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module
|
|
3
|
+
* @mergeModuleWith Core
|
|
4
|
+
*/
|
|
5
|
+
/** @internal */
|
|
6
|
+
export type Constructor<T = Record<string, unknown>> = new (...args: any[]) => T;
|
|
7
|
+
/** @internal */
|
|
8
|
+
export type AnyFunction<T = any> = (...args: any[]) => T;
|
|
9
|
+
/** @internal */
|
|
10
|
+
export type Mixin<T extends AnyFunction> = InstanceType<ReturnType<T>>;
|
|
11
|
+
/** @internal */
|
|
12
|
+
export type Nullable<T> = {
|
|
13
|
+
[K in keyof T]: T[K] | null;
|
|
14
|
+
};
|
|
15
|
+
/** @internal */
|
|
16
|
+
export type Neverable<T> = {
|
|
17
|
+
[K in keyof T]: T[K] | never;
|
|
18
|
+
};
|
|
19
|
+
/** @internal */
|
|
20
|
+
export type Nullify<T> = {
|
|
21
|
+
[K in keyof T]: null;
|
|
22
|
+
};
|
|
23
|
+
/** @internal */
|
|
24
|
+
export type Neverify<T> = {
|
|
25
|
+
[K in keyof T]: never;
|
|
26
|
+
};
|
|
27
|
+
export type JsonPrimitive = string | number | boolean | null;
|
|
28
|
+
export type JsonRecord = {
|
|
29
|
+
[key in string]?: Json | JsonPrimitive;
|
|
30
|
+
};
|
|
31
|
+
export type JsonArray = (Json | JsonPrimitive)[];
|
|
32
|
+
export type Json = JsonRecord | JsonArray;
|
|
33
|
+
/** @internal */
|
|
34
|
+
export type SubSet<T extends Record<string, any>, K extends keyof T, R extends T[K]> = Omit<T, K> & {
|
|
35
|
+
[P in K]: R;
|
|
36
|
+
};
|
|
37
|
+
/**
|
|
38
|
+
* @internal
|
|
39
|
+
* Discrimintated Union
|
|
40
|
+
*
|
|
41
|
+
* Required<Pick<T, K>> – The property K is required.
|
|
42
|
+
* Partial<Record<Exclude<Keys, K>, undefined>> – All other keys in the union are explicitly set undefined (or omitted).
|
|
43
|
+
* Omit<T, Keys> – All extra properties outside of Keys are freely allowed.
|
|
44
|
+
* The union [K in Keys] ... [Keys] generates one type for each allowed key.
|
|
45
|
+
*/
|
|
46
|
+
export type DiscrimUnion<T, Keys extends keyof T = keyof T> = {
|
|
47
|
+
[K in Keys]: Required<Pick<T, K>> & Partial<Record<Exclude<Keys, K>, undefined>> & Omit<T, Keys>;
|
|
48
|
+
}[Keys];
|
|
49
|
+
/**
|
|
50
|
+
* A duration of time, in seconds
|
|
51
|
+
*/
|
|
52
|
+
export type TimeInterval = number;
|
|
53
|
+
/**
|
|
54
|
+
* Number of seconds elapsed since midnight, Jan 1, 1970 UTC
|
|
55
|
+
*/
|
|
56
|
+
export type EpochTimestamp = number;
|
|
57
|
+
export type Seconds = number;
|
|
58
|
+
/**
|
|
59
|
+
* An entity which can be respresented as a primitive (like string)
|
|
60
|
+
*/
|
|
61
|
+
export interface RawRepresentable<T = string> {
|
|
62
|
+
get rawValue(): T;
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Defines utility methods to determine if an entity has expired
|
|
66
|
+
* or when it will expire in the future
|
|
67
|
+
*/
|
|
68
|
+
export interface Expires {
|
|
69
|
+
get expiresAt(): Date | undefined;
|
|
70
|
+
get expiresIn(): TimeInterval;
|
|
71
|
+
get isExpired(): boolean;
|
|
72
|
+
get isValid(): boolean;
|
|
73
|
+
get issuedAt(): Date | undefined;
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* An entity which can be converted to a JSON representation, usually used for serialization
|
|
77
|
+
*/
|
|
78
|
+
export interface JSONSerializable {
|
|
79
|
+
toJSON(): JsonRecord;
|
|
80
|
+
}
|
|
81
|
+
export type RequestAuthorizerInit = RequestInit & {
|
|
82
|
+
dpopNonce?: string;
|
|
83
|
+
};
|
|
84
|
+
/**
|
|
85
|
+
* An entity which can sign an outgoing {@link !Request}, minimally adding a `Authorization` header
|
|
86
|
+
*/
|
|
87
|
+
export interface RequestAuthorizer {
|
|
88
|
+
authorize(input: string | URL | Request, init?: RequestAuthorizerInit): Promise<Request>;
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* An entity which opens a communication channel (and therefore will need to close the channel)
|
|
92
|
+
*/
|
|
93
|
+
export interface Broadcaster {
|
|
94
|
+
close(): void;
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* A communication channel which follows a similar API pattern to {@link !BroadcastChannel}
|
|
98
|
+
*/
|
|
99
|
+
export interface BroadcastChannelLike<M extends JsonRecord, E = object> {
|
|
100
|
+
name: string;
|
|
101
|
+
onmessage: ((message: {
|
|
102
|
+
data: M & E;
|
|
103
|
+
}, reply?: (data: M) => any) => any) | null;
|
|
104
|
+
postMessage(message: M): void;
|
|
105
|
+
close(): void;
|
|
106
|
+
}
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module
|
|
3
|
+
* @mergeModuleWith OAuth2
|
|
4
|
+
*/
|
|
5
|
+
import type { JWK, JWKS } from '../jwt/index.ts';
|
|
6
|
+
import type { ConfigurationParams } from '../oauth2/configuration.ts';
|
|
7
|
+
import type { OpenIdConfiguration } from './openid.ts';
|
|
8
|
+
/**
|
|
9
|
+
* JSON format of an error response from an OAuth2 server
|
|
10
|
+
*
|
|
11
|
+
* @group Types
|
|
12
|
+
*/
|
|
13
|
+
export interface OAuth2ErrorResponse {
|
|
14
|
+
readonly error: string;
|
|
15
|
+
readonly errorDescription?: string;
|
|
16
|
+
readonly error_description?: string;
|
|
17
|
+
readonly errorUri?: string;
|
|
18
|
+
readonly error_uri?: string;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Predicate for {@link OAuth2ErrorResponse}
|
|
22
|
+
*
|
|
23
|
+
* @group Types
|
|
24
|
+
*/
|
|
25
|
+
export declare function isOAuth2ErrorResponse(input: unknown): input is OAuth2ErrorResponse;
|
|
26
|
+
export { OpenIdConfiguration };
|
|
27
|
+
/**
|
|
28
|
+
* Predicate for {@link OpenIdConfiguration}
|
|
29
|
+
*
|
|
30
|
+
* @group Types
|
|
31
|
+
*/
|
|
32
|
+
export declare function isOpenIdConfiguration(input: unknown): input is OpenIdConfiguration;
|
|
33
|
+
/**
|
|
34
|
+
* Predicate for {@link Core.JWK | JWK}
|
|
35
|
+
*
|
|
36
|
+
* @group Types
|
|
37
|
+
*/
|
|
38
|
+
export declare function isJWK(input: unknown): input is JWK;
|
|
39
|
+
/**
|
|
40
|
+
* Predicate for {@link Core.JWKS | JWKS}
|
|
41
|
+
*
|
|
42
|
+
* @group Types
|
|
43
|
+
*/
|
|
44
|
+
export declare function isJWKS(input: unknown): input is JWKS;
|
|
45
|
+
export type { ConfigurationParams };
|
|
46
|
+
/**
|
|
47
|
+
* Parameters needed to define an OAuth2 flow
|
|
48
|
+
*
|
|
49
|
+
* @group Types
|
|
50
|
+
*/
|
|
51
|
+
export type OAuth2Params = {
|
|
52
|
+
issuer: string | URL;
|
|
53
|
+
clientId: string;
|
|
54
|
+
scopes: string | string[];
|
|
55
|
+
dpop?: boolean;
|
|
56
|
+
};
|
|
57
|
+
/**
|
|
58
|
+
* Possible values of `grant_type` for a `/token` request
|
|
59
|
+
*
|
|
60
|
+
* @group Types
|
|
61
|
+
*/
|
|
62
|
+
export type GrantType = 'authorization_code' | 'refresh_token';
|
|
63
|
+
/**
|
|
64
|
+
* Possible values of `token_type` from a `/token` response
|
|
65
|
+
*
|
|
66
|
+
* @group Types
|
|
67
|
+
*/
|
|
68
|
+
export type TokenType = 'Bearer' | 'DPoP';
|
|
69
|
+
/**
|
|
70
|
+
* Possible values of {@link OAuth2.Configuration.authentication} property.
|
|
71
|
+
* Determines how the {@link OAuth2Client} will sign OAuth2 requests
|
|
72
|
+
*
|
|
73
|
+
* @group Types
|
|
74
|
+
*/
|
|
75
|
+
export type ClientAuthentication = 'none';
|
|
76
|
+
export interface APIClientConfiguration {
|
|
77
|
+
readonly baseURL: URL;
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Possible types of `acr_values` for OAuth2 requests
|
|
81
|
+
*
|
|
82
|
+
* @group Types
|
|
83
|
+
*/
|
|
84
|
+
export type AcrValues = OktaAcrValues | string | string[];
|
|
85
|
+
/**
|
|
86
|
+
* Possible `acr_values` of Okta Authorization Servers
|
|
87
|
+
*
|
|
88
|
+
* @group Types
|
|
89
|
+
*
|
|
90
|
+
* @see
|
|
91
|
+
* https://developer.okta.com/docs/api/openapi/okta-oauth/oauth/tag/OrgAS/#tag/OrgAS/operation/authorize!in=query&path=acr_values&t=request
|
|
92
|
+
*/
|
|
93
|
+
export type OktaAcrValues =
|
|
94
|
+
/**
|
|
95
|
+
* Phishing-Resistant
|
|
96
|
+
*/
|
|
97
|
+
'phr' |
|
|
98
|
+
/**
|
|
99
|
+
* Phishing-Resistant Hardware-Protected
|
|
100
|
+
*/
|
|
101
|
+
'phrh' |
|
|
102
|
+
/**
|
|
103
|
+
* Any one factor
|
|
104
|
+
*/
|
|
105
|
+
'urn:okta:loa:1fa:any' |
|
|
106
|
+
/**
|
|
107
|
+
* Password only
|
|
108
|
+
*/
|
|
109
|
+
'urn:okta:loa:1fa:pwd' |
|
|
110
|
+
/**
|
|
111
|
+
* Any two factors
|
|
112
|
+
*/
|
|
113
|
+
'urn:okta:loa:2fa:any' |
|
|
114
|
+
/**
|
|
115
|
+
* Any two factors, if possible. Any two factors are presented only if the user is enrolled, otherwise any one factor is presented.
|
|
116
|
+
*/
|
|
117
|
+
'urn:okta:loa:2fa:any:ifpossible';
|