@okta/auth-foundation 0.6.0 → 0.9.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 +136 -0
- package/claude.md +256 -0
- package/dist/esm/Credential/Credential.js +17 -14
- package/dist/esm/Credential/Credential.js.map +1 -1
- package/dist/esm/Credential/CredentialCoordinator.js +6 -2
- package/dist/esm/Credential/CredentialCoordinator.js.map +1 -1
- package/dist/esm/Credential/CredentialDataSource.js +6 -4
- package/dist/esm/Credential/CredentialDataSource.js.map +1 -1
- package/dist/esm/Credential/TokenStorage.js +3 -0
- package/dist/esm/Credential/TokenStorage.js.map +1 -1
- package/dist/esm/FetchClient.js +5 -1
- package/dist/esm/FetchClient.js.map +1 -1
- package/dist/esm/Token.js +1 -0
- package/dist/esm/Token.js.map +1 -1
- package/dist/esm/TokenOrchestrator.js +4 -1
- package/dist/esm/TokenOrchestrator.js.map +1 -1
- package/dist/esm/http/APIClient.js +4 -0
- package/dist/esm/http/APIClient.js.map +1 -1
- package/dist/esm/http/oktaUserAgent.js +1 -1
- package/dist/esm/http/requests/APIRequest.js.map +1 -1
- package/dist/esm/http/requests/OAuth2Request.js.map +1 -1
- package/dist/esm/http/wwwAuthenticate.js.map +1 -1
- package/dist/esm/jwt/IDTokenValidator.js +3 -0
- package/dist/esm/jwt/IDTokenValidator.js.map +1 -1
- package/dist/esm/jwt/JWK.js.map +1 -1
- package/dist/esm/jwt/JWT.js.map +1 -1
- package/dist/esm/jwt/TokenHashValidator.js.map +1 -1
- package/dist/esm/oauth2/client.js +14 -9
- package/dist/esm/oauth2/client.js.map +1 -1
- package/dist/esm/oauth2/configuration.js +7 -3
- package/dist/esm/oauth2/configuration.js.map +1 -1
- package/dist/esm/oauth2/dpop/index.js.map +1 -1
- package/dist/esm/oauth2/dpop/nonceCache.js.map +1 -1
- package/dist/esm/oauth2/dpop/storage.js.map +1 -1
- package/dist/esm/oauth2/pkce.js.map +1 -1
- package/dist/esm/oauth2/requests/UserInfo.js.map +1 -1
- package/dist/esm/platform/Platform.js.map +1 -1
- package/dist/esm/platform/defaults.js.map +1 -1
- package/dist/esm/types/oauth.js.map +1 -1
- package/dist/esm/utils/EventEmitter.js +29 -1
- package/dist/esm/utils/EventEmitter.js.map +1 -1
- package/dist/esm/utils/TaskBridge.js +13 -0
- package/dist/esm/utils/TaskBridge.js.map +1 -1
- package/dist/esm/utils/TimeCoordinator.js.map +1 -1
- package/dist/esm/utils/merge.js.map +1 -1
- package/dist/esm/utils/pause.js.map +1 -1
- package/dist/types/Credential/Credential.d.ts +38 -21
- package/dist/types/Credential/CredentialCoordinator.d.ts +10 -3
- package/dist/types/Credential/CredentialDataSource.d.ts +2 -1
- package/dist/types/Credential/TokenStorage.d.ts +13 -2
- package/dist/types/FetchClient.d.ts +26 -5
- package/dist/types/Token.d.ts +23 -11
- package/dist/types/TokenOrchestrator.d.ts +61 -11
- package/dist/types/http/APIClient.d.ts +220 -8
- package/dist/types/http/index.d.ts +5 -0
- package/dist/types/http/requests/APIRequest.d.ts +28 -2
- package/dist/types/http/requests/OAuth2Request.d.ts +12 -2
- package/dist/types/http/wwwAuthenticate.d.ts +10 -2
- package/dist/types/jwt/IDTokenValidator.d.ts +46 -3
- package/dist/types/jwt/JWK.d.ts +35 -0
- package/dist/types/jwt/JWT.d.ts +126 -4
- package/dist/types/jwt/TokenHashValidator.d.ts +6 -0
- package/dist/types/oauth2/client.d.ts +95 -11
- package/dist/types/oauth2/configuration.d.ts +81 -7
- package/dist/types/oauth2/dpop/index.d.ts +10 -5
- package/dist/types/oauth2/dpop/nonceCache.d.ts +18 -0
- package/dist/types/oauth2/dpop/storage.d.ts +1 -0
- package/dist/types/oauth2/dpop/types.d.ts +7 -0
- package/dist/types/oauth2/pkce.d.ts +19 -0
- package/dist/types/oauth2/requests/UserInfo.d.ts +2 -1
- package/dist/types/platform/Platform.d.ts +51 -3
- package/dist/types/platform/defaults.d.ts +1 -0
- package/dist/types/types/lib.d.ts +16 -2
- package/dist/types/types/oauth.d.ts +5 -5
- package/dist/types/types/openid.d.ts +50 -234
- package/dist/types/utils/EventEmitter.d.ts +84 -2
- package/dist/types/utils/TaskBridge.d.ts +9 -1
- package/dist/types/utils/TimeCoordinator.d.ts +2 -0
- package/dist/types/utils/merge.d.ts +2 -0
- package/dist/types/utils/pause.d.ts +1 -0
- package/package.json +1 -1
|
@@ -4,53 +4,127 @@
|
|
|
4
4
|
*/
|
|
5
5
|
import type { ClientAuthentication, APIClientConfiguration, JSONSerializable, JsonRecord, OAuth2Params, DiscrimUnion } from '../types/index.ts';
|
|
6
6
|
import { APIClient } from '../http/index.ts';
|
|
7
|
+
/** @internal */
|
|
7
8
|
export type OAuth2ClientConfigurations = DiscrimUnion<OAuth2Params & {
|
|
8
9
|
baseURL: URL | string;
|
|
9
10
|
discoveryURL?: URL | string;
|
|
10
11
|
}, 'issuer' | 'baseURL'>;
|
|
12
|
+
/**
|
|
13
|
+
* Configuration options for {@link OAuth2Client}
|
|
14
|
+
* @group OAuth2Client
|
|
15
|
+
*/
|
|
11
16
|
export type OAuth2ClientOptions = {
|
|
12
17
|
authentication?: ClientAuthentication;
|
|
13
18
|
allowHTTP?: boolean;
|
|
14
19
|
syncClockWithAuthorizationServer?: boolean;
|
|
15
20
|
};
|
|
16
21
|
/**
|
|
17
|
-
* @
|
|
18
|
-
* @
|
|
22
|
+
* Options to provide to {@link Configuration} at instantiation
|
|
23
|
+
* @group OAuth2Client
|
|
24
|
+
* @interface
|
|
19
25
|
*/
|
|
20
26
|
export type ConfigurationParams = OAuth2ClientConfigurations & OAuth2ClientOptions;
|
|
21
27
|
/**
|
|
22
|
-
* @
|
|
28
|
+
* Options to customize the behavior of a {@link OAuth2Client} instance
|
|
29
|
+
* @group OAuth2Client
|
|
30
|
+
*
|
|
31
|
+
* @see
|
|
32
|
+
* {@link https://datatracker.ietf.org/doc/html/rfc8414 | RFC 8414: OAuth 2.0 Authorization Server Metadata}
|
|
23
33
|
*/
|
|
24
34
|
export declare class Configuration extends APIClient.Configuration implements APIClientConfiguration, JSONSerializable {
|
|
35
|
+
/**
|
|
36
|
+
* URL of the authorization server.
|
|
37
|
+
*/
|
|
25
38
|
readonly issuer: URL;
|
|
39
|
+
/**
|
|
40
|
+
* URL of the authorization server's Metadata document
|
|
41
|
+
* @defaultValue
|
|
42
|
+
* ```ts
|
|
43
|
+
* this.issuer + '/.well-known/openid-configuration'
|
|
44
|
+
* ```
|
|
45
|
+
*
|
|
46
|
+
* @see
|
|
47
|
+
* {@link https://datatracker.ietf.org/doc/html/rfc8414#section-3 | RFC 8414: Obtaining Authorization Server Metadata}
|
|
48
|
+
*/
|
|
26
49
|
readonly discoveryURL: URL;
|
|
50
|
+
/**
|
|
51
|
+
* Authorization server client identifier.
|
|
52
|
+
*
|
|
53
|
+
* @remarks
|
|
54
|
+
* The client identifier will be generated by the authorization server during client registration.
|
|
55
|
+
*
|
|
56
|
+
* @see
|
|
57
|
+
* {@link https://datatracker.ietf.org/doc/html/rfc6749#section-2.2 | RFC 6749: Client Identifier}
|
|
58
|
+
*/
|
|
27
59
|
readonly clientId: string;
|
|
60
|
+
/**
|
|
61
|
+
* Default `scope` value to be provided in authenication and token requests to the authorization server.
|
|
62
|
+
*
|
|
63
|
+
* @see
|
|
64
|
+
* * {@link https://developer.okta.com/docs/api/openapi/okta-oauth/oauth/orgas/authorize#orgas/authorize/t=request&in=query&path=scope | Okta Auth Server}
|
|
65
|
+
* * {@link https://developer.okta.com/docs/api/oauth2 | Okta Scopes}
|
|
66
|
+
* * {@link https://datatracker.ietf.org/doc/html/rfc6749#section-3.3 | RFC 6749: Access Token Scope}
|
|
67
|
+
*/
|
|
28
68
|
scopes: string;
|
|
69
|
+
/**
|
|
70
|
+
* Enum for possible authentication stratgies for authorization server requests. Defaults to `none` (aka public client)
|
|
71
|
+
*
|
|
72
|
+
* @see
|
|
73
|
+
* {@link https://datatracker.ietf.org/doc/html/rfc6749#section-2.3 | RFC 6749: Client Authentication}
|
|
74
|
+
*/
|
|
29
75
|
authentication: ClientAuthentication;
|
|
30
76
|
/**
|
|
31
77
|
* When `true`, issuer and other .well-known endpoints can be HTTP. Defaults to `false`
|
|
32
78
|
*/
|
|
33
79
|
allowHTTP: boolean;
|
|
34
80
|
/**
|
|
35
|
-
* When `true`, the `Date` header from HTTP requests made to the
|
|
36
|
-
* used to calculate a clock skew between the
|
|
81
|
+
* When `true`, the `Date` header from HTTP requests made to the authorization server will be
|
|
82
|
+
* used to calculate a clock skew between the authorization server and the system clock. This is
|
|
37
83
|
* useful for situations when the client's system clock is set to something other than the "true time".
|
|
38
84
|
*
|
|
39
85
|
* Defaults to `true`.
|
|
40
86
|
*
|
|
41
87
|
* @remarks
|
|
42
|
-
* By default, the `Date` header is not safelisted for CORS requests. The
|
|
43
|
-
* to include the `Date` header in the `allow-control-
|
|
88
|
+
* By default, the `Date` header is not safelisted for CORS requests. The authorization Server will need
|
|
89
|
+
* to include the `Date` header in the `allow-control-expose-headers` for this feature to work properly
|
|
90
|
+
* when requests the authorization server and application are hosted on different origins.
|
|
44
91
|
*
|
|
45
92
|
* Reference: https://developer.mozilla.org/en-US/docs/Glossary/CORS-safelisted_response_header
|
|
46
93
|
*/
|
|
47
94
|
syncClockWithAuthorizationServer: boolean;
|
|
95
|
+
/**
|
|
96
|
+
* @defaultValue
|
|
97
|
+
* ```ts
|
|
98
|
+
* {
|
|
99
|
+
* allowHTTP: false,
|
|
100
|
+
* syncClockWithAuthorizationServer: true,
|
|
101
|
+
* authentication: 'none',
|
|
102
|
+
*
|
|
103
|
+
* // inherited from APIClient
|
|
104
|
+
* dpop: false
|
|
105
|
+
* }
|
|
106
|
+
* ```
|
|
107
|
+
*/
|
|
48
108
|
static DefaultOptions: Required<OAuth2ClientOptions> & typeof APIClient.Configuration.DefaultOptions;
|
|
49
109
|
constructor(params: ConfigurationParams);
|
|
50
110
|
/**
|
|
51
111
|
* Alias to {@link issuer} for backwards compatibility
|
|
52
112
|
*/
|
|
53
113
|
get baseURL(): URL;
|
|
114
|
+
/**
|
|
115
|
+
* Determines whether a parameter collection matches the configuration of this client
|
|
116
|
+
*/
|
|
54
117
|
matches(params: OAuth2Params): boolean;
|
|
118
|
+
/**
|
|
119
|
+
* Returns configurations values of the client, omitting OAuth2 parameters
|
|
120
|
+
*
|
|
121
|
+
* @see {@link Configuration.toJSON}
|
|
122
|
+
*/
|
|
123
|
+
getOptions(): OAuth2ClientOptions;
|
|
124
|
+
/**
|
|
125
|
+
* Returns JSON representation of the client's configuration
|
|
126
|
+
*
|
|
127
|
+
* @see {@link Configuration.getOptions}
|
|
128
|
+
*/
|
|
55
129
|
toJSON(): JsonRecord;
|
|
56
130
|
}
|
|
@@ -8,22 +8,27 @@ import { DPoPNonceCache } from './nonceCache.ts';
|
|
|
8
8
|
export { DPoPNonceCache, DPoPStorage };
|
|
9
9
|
export type { DPoPHeaders, DPoPClaims, DPoPProofParams };
|
|
10
10
|
/**
|
|
11
|
+
* A Platform-level singleton for performing `DPoP` operations. The {@link DPoPSigningAuthority} is
|
|
12
|
+
* reasonable for mangaging `DPoP` key pairs and generate `DPoP` proofs for outgoing {@link !Request}s
|
|
11
13
|
* @group DPoP
|
|
12
|
-
*
|
|
13
14
|
*/
|
|
14
15
|
export interface DPoPSigningAuthority {
|
|
15
16
|
createDPoPKeyPair: () => Promise<string>;
|
|
16
17
|
deleteDPoPKeyPair: (keyPairId: string) => Promise<void>;
|
|
17
18
|
clearDPoPKeyPairs: () => Promise<void>;
|
|
19
|
+
/**
|
|
20
|
+
* Generates a `DPoP` proof for the provided {@link !Request} and writes the `dpop` request header.
|
|
21
|
+
*
|
|
22
|
+
* @see {@link https://datatracker.ietf.org/doc/html/rfc9449#section-4 | RFC 9449 - DPoP Proof JWTs}
|
|
23
|
+
*/
|
|
18
24
|
sign: (request: Request, params: Omit<DPoPProofParams, 'request'>) => Promise<Request>;
|
|
19
25
|
}
|
|
20
26
|
/**
|
|
21
|
-
* @internal
|
|
22
|
-
* @group DPoP
|
|
23
27
|
* Default implementation of a DPoP Signing Authority.
|
|
24
28
|
* Signs outgoing network requests with a dpop proof (private key JWT) as well as
|
|
25
29
|
* creates, stores and retrieves the Crypto Key Pairs necessary for the signing operation
|
|
26
|
-
*
|
|
30
|
+
* @group DPoP
|
|
31
|
+
* @internal
|
|
27
32
|
*/
|
|
28
33
|
export declare class DPoPSigningAuthorityImpl implements DPoPSigningAuthority {
|
|
29
34
|
private readonly store;
|
|
@@ -64,7 +69,7 @@ export declare class DPoPSigningAuthorityImpl implements DPoPSigningAuthority {
|
|
|
64
69
|
* Signs an outgoing network requests with a DPoP proof
|
|
65
70
|
* @param request - outgoing network request to be sign with a DPoP proof
|
|
66
71
|
* @param params - the required component necessary to generate the DPoP proof
|
|
67
|
-
* @returns
|
|
72
|
+
* @returns The provided {@link !Request} with an append `dpop` header
|
|
68
73
|
*/
|
|
69
74
|
sign(request: Request, params: Omit<DPoPProofParams, 'request'>): Promise<Request>;
|
|
70
75
|
}
|
|
@@ -3,7 +3,25 @@
|
|
|
3
3
|
* @mergeModuleWith OAuth2
|
|
4
4
|
*/
|
|
5
5
|
/**
|
|
6
|
+
* > The intent is that clients need to keep only one nonce value and
|
|
7
|
+
* servers need to keep a window of recent nonces.
|
|
8
|
+
*
|
|
9
|
+
* via https://datatracker.ietf.org/doc/html/rfc9449#section-8
|
|
10
|
+
*
|
|
11
|
+
* Authorization servers may provide the same `dpop-nonce` value for a window of time.
|
|
12
|
+
* The `DPoPNonceCache` serves as a cache of these nonce values to avoid unnecessary
|
|
13
|
+
* failures. {@link OAuth2.DPoPSigningAuthority.sign | DPoPSigningAuthority.sign} will
|
|
14
|
+
* use nonce values from the cache when available.
|
|
15
|
+
*
|
|
16
|
+
* @remarks
|
|
17
|
+
* A `DPoPNonceCache` instance will be create for each {@link Networking.APIClient | APIClient} instance,
|
|
18
|
+
* but `DPoPNonceCache` implementations will often share a common store
|
|
19
|
+
*
|
|
6
20
|
* @group DPoP
|
|
21
|
+
* @see
|
|
22
|
+
* * {@link https://datatracker.ietf.org/doc/html/rfc9449#section-11.3 | RFC 9449 - DPoP Nonce Downgrade}
|
|
23
|
+
* * {@link https://datatracker.ietf.org/doc/html/rfc9449#section-8 | RFC 9449 - Authorization Server-Provided Nonce}
|
|
24
|
+
* * {@link https://datatracker.ietf.org/doc/html/rfc9449#section-9 | RFC 9449 - Resource Server-Provided Nonce}
|
|
7
25
|
*/
|
|
8
26
|
export interface DPoPNonceCache {
|
|
9
27
|
getNonce(key: string): Promise<string | undefined>;
|
|
@@ -4,7 +4,10 @@
|
|
|
4
4
|
*/
|
|
5
5
|
import type { JsonRecord } from '../../types/index.ts';
|
|
6
6
|
/**
|
|
7
|
+
* `JWT` claims associated with a `DPoP` proof
|
|
7
8
|
* @group DPoP
|
|
9
|
+
*
|
|
10
|
+
* @see {@link https://datatracker.ietf.org/doc/html/rfc9449#section-4.2-3 | RFC 9499 - DPoP Proof Claims}
|
|
8
11
|
*/
|
|
9
12
|
export interface DPoPClaims extends JsonRecord {
|
|
10
13
|
/**
|
|
@@ -33,7 +36,10 @@ export interface DPoPClaims extends JsonRecord {
|
|
|
33
36
|
ath?: string;
|
|
34
37
|
}
|
|
35
38
|
/**
|
|
39
|
+
* `JWT` header parameters for a `DPoP` proof
|
|
36
40
|
* @group DPoP
|
|
41
|
+
*
|
|
42
|
+
* @see {@link https://datatracker.ietf.org/doc/html/rfc9449#section-4.2-1 | RFC 9499 - DPoP Proof Header}
|
|
37
43
|
*/
|
|
38
44
|
export interface DPoPHeaders {
|
|
39
45
|
alg: 'RS256';
|
|
@@ -41,6 +47,7 @@ export interface DPoPHeaders {
|
|
|
41
47
|
jwk: JsonWebKey;
|
|
42
48
|
}
|
|
43
49
|
/**
|
|
50
|
+
* Parameters required to generate a `DPoP` proof
|
|
44
51
|
* @group DPoP
|
|
45
52
|
*/
|
|
46
53
|
export interface DPoPProofParams {
|
|
@@ -3,21 +3,40 @@
|
|
|
3
3
|
* @mergeModuleWith OAuth2
|
|
4
4
|
*/
|
|
5
5
|
/**
|
|
6
|
+
* Defines the properties returned by {@link PKCE.generate}
|
|
6
7
|
* @group PKCE
|
|
7
8
|
*/
|
|
8
9
|
export type PKCE = PKCE.Challenge & PKCE.Verifier;
|
|
10
|
+
/**
|
|
11
|
+
* Generates a `PKCE` challenge and verifier.
|
|
12
|
+
*
|
|
13
|
+
* @remarks
|
|
14
|
+
* Currently `S256` is the only hashing algorithm available. Per spec, `plain` (unhashed) challenges
|
|
15
|
+
* are valid for client which are unable to perform `S256`, but this isn't implemented within this client
|
|
16
|
+
*/
|
|
9
17
|
declare function generatePKCE(method?: string): Promise<PKCE>;
|
|
10
18
|
/**
|
|
11
19
|
* @group PKCE
|
|
12
20
|
*/
|
|
13
21
|
export declare namespace PKCE {
|
|
22
|
+
/**
|
|
23
|
+
* Represents PKCE `code_challenge`
|
|
24
|
+
*
|
|
25
|
+
* @see {@link https://datatracker.ietf.org/doc/html/rfc7636#section-4.2 | RFC 7636 - Client Creates the Code Challenge}
|
|
26
|
+
*/
|
|
14
27
|
type Challenge = {
|
|
15
28
|
challenge: string;
|
|
16
29
|
method: string;
|
|
17
30
|
};
|
|
31
|
+
/**
|
|
32
|
+
* Represents PKCE `code_verifier`
|
|
33
|
+
*
|
|
34
|
+
* @see {@link https://datatracker.ietf.org/doc/html/rfc7636#section-4.1 | RFC 7636 - Client Creates the Code Verifier}
|
|
35
|
+
*/
|
|
18
36
|
type Verifier = {
|
|
19
37
|
verifier: string;
|
|
20
38
|
};
|
|
39
|
+
/** @reexport */
|
|
21
40
|
const generate: typeof generatePKCE;
|
|
22
41
|
}
|
|
23
42
|
export {};
|
|
@@ -6,7 +6,8 @@ import type { JsonPrimitive } from '../../types/index.ts';
|
|
|
6
6
|
import { Token } from '../../Token.ts';
|
|
7
7
|
import { OAuth2Request } from '../../http/index.ts';
|
|
8
8
|
/**
|
|
9
|
-
* @
|
|
9
|
+
* @inline
|
|
10
|
+
* @internal
|
|
10
11
|
*/
|
|
11
12
|
export interface UserInfo {
|
|
12
13
|
[key: string]: JsonPrimitive;
|
|
@@ -1,18 +1,65 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `Platform` is a registry of platform-wide **singleton** dependencies (time, DPoP key signing, DPoP
|
|
3
|
+
* nonce storage, etc.) that are shared across the whole SDK ecosystem, rather than constructed
|
|
4
|
+
* per-instance by whatever class happens to need them.
|
|
5
|
+
*
|
|
6
|
+
* Some of these dependencies vary by JS environment - `DPoPSigningAuthority` and `DPoPNonceCache`
|
|
7
|
+
* need genuinely different implementations in a browser vs. React Native, since they lean on
|
|
8
|
+
* environment-specific crypto/storage APIs. Others, like `TimeCoordinator`, aren't tied to any
|
|
9
|
+
* particular runtime at all; they're registered here simply because the SDK needs exactly *one*
|
|
10
|
+
* shared instance (e.g. for clock-skew coordination) rather than one per consumer. Either way,
|
|
11
|
+
* funneling both kinds of dependency through the same `Platform` registry gives every part of the
|
|
12
|
+
* SDK one consistent, easy pattern for overriding behavior, instead of each dependency inventing
|
|
13
|
+
* its own configuration mechanism.
|
|
14
|
+
*
|
|
15
|
+
* Most consumers never need to touch this module directly. Platform packages like [@okta/spa-platform](/api/spa-platform/)
|
|
16
|
+
* or [@okta/react-native-platform](/api/spa-platform/) already register the right implementations for their environment,
|
|
17
|
+
* and importing from `@okta/auth-foundation` pulls in working defaults out of the box.
|
|
18
|
+
*
|
|
19
|
+
* Reach for `Platform` yourself only if you need to override a specific dependency (for example,
|
|
20
|
+
* providing a custom `TimeCoordinator` in tests) via {@link PlatformRegistry.configure}, or you're
|
|
21
|
+
* adding support for a runtime this SDK doesn't already target, via
|
|
22
|
+
* {@link PlatformRegistry.registerDefaultsLoader}.
|
|
23
|
+
*
|
|
24
|
+
* @remarks
|
|
25
|
+
* By convention, every `@okta/*` SDK package exports a `/core` entry point alongside its default
|
|
26
|
+
* entry point. The default entry point (e.g. `@okta/auth-foundation`) calls
|
|
27
|
+
* {@link PlatformRegistry.registerDefaultsLoader} on your behalf with that platform's default
|
|
28
|
+
* implementations already wired up - simple to use, but it means those defaults are always
|
|
29
|
+
* included in your bundle, even if you go on to override them.
|
|
30
|
+
*
|
|
31
|
+
* The `/core` entry point (e.g. `@okta/auth-foundation/core`) is identical, *except* it skips that
|
|
32
|
+
* `registerDefaultsLoader` call. This gives you a way to fully replace a `Platform` dependency
|
|
33
|
+
* without ever pulling its default implementation into your bundle - useful if the default is
|
|
34
|
+
* heavy, or simply not needed for your use case. If you go this route, you must call
|
|
35
|
+
* {@link PlatformRegistry.registerDefaultsLoader} yourself before any other SDK code runs, or
|
|
36
|
+
* {@link PlatformRegistryError} will be thrown the first time a dependency is accessed.
|
|
37
|
+
* @module Platform
|
|
38
|
+
*/
|
|
1
39
|
import { AuthSdkError } from '../errors/AuthSdkError.ts';
|
|
2
40
|
import type { DPoPSigningAuthority } from '../oauth2/dpop/index.ts';
|
|
3
41
|
import type { TimeCoordinator } from '../utils/TimeCoordinator.ts';
|
|
4
42
|
import type { DPoPNonceCache } from '../oauth2/dpop/index.ts';
|
|
5
43
|
/**
|
|
6
|
-
* The required Platform dependencies
|
|
44
|
+
* The required {@link Platform} dependencies
|
|
7
45
|
*/
|
|
8
46
|
export interface PlatformDependencies {
|
|
47
|
+
/** {@inheritDoc Core.TimeCoordinator} */
|
|
9
48
|
TimeCoordinator: TimeCoordinator;
|
|
49
|
+
/** {@inheritDoc OAuth2.DPoPSigningAuthority} */
|
|
10
50
|
DPoPSigningAuthority: DPoPSigningAuthority;
|
|
51
|
+
/** {@inheritDoc OAuth2.DPoPNonceCache} */
|
|
11
52
|
DPoPNonceCache: DPoPNonceCache;
|
|
12
53
|
}
|
|
54
|
+
/**
|
|
55
|
+
* Thrown when the {@link Platform} registry cannot resolve a dependency.
|
|
56
|
+
*/
|
|
13
57
|
export declare class PlatformRegistryError extends AuthSdkError {
|
|
14
58
|
}
|
|
15
59
|
/**
|
|
60
|
+
* > [!Warning]
|
|
61
|
+
* > **DO NOT** construct an instance of this `PlatformRegistry`. Use `import { Platform } from '@okta/auth-foundation'`.
|
|
62
|
+
*
|
|
16
63
|
* A singleton registry of globally-available singleton dependencies which can
|
|
17
64
|
* provide platform-specific default implementations and enable overriding as needed
|
|
18
65
|
*
|
|
@@ -21,7 +68,7 @@ export declare class PlatformRegistryError extends AuthSdkError {
|
|
|
21
68
|
* as a {@link Platform} dependency enables consumers to access the {@link TimeCoordinator} via
|
|
22
69
|
*
|
|
23
70
|
* @example
|
|
24
|
-
* ```
|
|
71
|
+
* ```ts
|
|
25
72
|
* import { Platform } from '@okta/auth-foundation';
|
|
26
73
|
* const currentTime = Platform.TimeCoordinator.now();
|
|
27
74
|
* ```
|
|
@@ -68,7 +115,7 @@ export declare class PlatformRegistry implements PlatformDependencies {
|
|
|
68
115
|
* Call this once at application startup before using any SDK components.
|
|
69
116
|
*
|
|
70
117
|
* @example
|
|
71
|
-
* ```
|
|
118
|
+
* ```ts
|
|
72
119
|
* // src/auth.ts
|
|
73
120
|
* import { Platform } from '@okta/auth-foundation/core'; // ensure "/core" is imported specifically
|
|
74
121
|
*
|
|
@@ -118,4 +165,5 @@ export declare class PlatformRegistry implements PlatformDependencies {
|
|
|
118
165
|
*/
|
|
119
166
|
get DPoPNonceCache(): DPoPNonceCache;
|
|
120
167
|
}
|
|
168
|
+
/** @internal */
|
|
121
169
|
export declare const Platform: PlatformRegistry;
|
|
@@ -24,12 +24,20 @@ export type Nullify<T> = {
|
|
|
24
24
|
export type Neverify<T> = {
|
|
25
25
|
[K in keyof T]: never;
|
|
26
26
|
};
|
|
27
|
+
/**
|
|
28
|
+
* Primitive types representable in `JSON` objects.
|
|
29
|
+
*/
|
|
27
30
|
export type JsonPrimitive = string | number | boolean | null;
|
|
31
|
+
/**
|
|
32
|
+
* Type respresentation of a `JSON` object.
|
|
33
|
+
*/
|
|
28
34
|
export type JsonRecord = {
|
|
29
35
|
[key in string]?: Json | JsonPrimitive;
|
|
30
36
|
};
|
|
31
|
-
|
|
32
|
-
|
|
37
|
+
/**
|
|
38
|
+
* Type respresentation of a `JSON` object or array.
|
|
39
|
+
*/
|
|
40
|
+
export type Json = JsonRecord | (Json | JsonPrimitive)[];
|
|
33
41
|
/** @internal */
|
|
34
42
|
export type SubSet<T extends Record<string, any>, K extends keyof T, R extends T[K]> = Omit<T, K> & {
|
|
35
43
|
[P in K]: R;
|
|
@@ -54,6 +62,9 @@ export type TimeInterval = number;
|
|
|
54
62
|
* Number of seconds elapsed since midnight, Jan 1, 1970 UTC
|
|
55
63
|
*/
|
|
56
64
|
export type EpochTimestamp = number;
|
|
65
|
+
/**
|
|
66
|
+
* Alias for `number`, but more descriptive
|
|
67
|
+
*/
|
|
57
68
|
export type Seconds = number;
|
|
58
69
|
/**
|
|
59
70
|
* An entity which can be respresented as a primitive (like string)
|
|
@@ -78,6 +89,9 @@ export interface Expires {
|
|
|
78
89
|
export interface JSONSerializable {
|
|
79
90
|
toJSON(): JsonRecord;
|
|
80
91
|
}
|
|
92
|
+
/**
|
|
93
|
+
* @inline
|
|
94
|
+
*/
|
|
81
95
|
export type RequestAuthorizerInit = RequestInit & {
|
|
82
96
|
dpopNonce?: string;
|
|
83
97
|
};
|
|
@@ -6,7 +6,7 @@ import type { JWK, JWKS } from '../jwt/index.ts';
|
|
|
6
6
|
import type { ConfigurationParams } from '../oauth2/configuration.ts';
|
|
7
7
|
import type { OpenIdConfiguration } from './openid.ts';
|
|
8
8
|
/**
|
|
9
|
-
* JSON format of an error response
|
|
9
|
+
* JSON format of an error response returned by authorization server
|
|
10
10
|
*
|
|
11
11
|
* @group Types
|
|
12
12
|
*/
|
|
@@ -25,19 +25,19 @@ export interface OAuth2ErrorResponse {
|
|
|
25
25
|
export declare function isOAuth2ErrorResponse(input: unknown): input is OAuth2ErrorResponse;
|
|
26
26
|
export { OpenIdConfiguration };
|
|
27
27
|
/**
|
|
28
|
-
*
|
|
28
|
+
* Type predicate for {@link OpenIdConfiguration}
|
|
29
29
|
*
|
|
30
30
|
* @group Types
|
|
31
31
|
*/
|
|
32
32
|
export declare function isOpenIdConfiguration(input: unknown): input is OpenIdConfiguration;
|
|
33
33
|
/**
|
|
34
|
-
*
|
|
34
|
+
* Type predicate for {@link Core.JWK | JWK}
|
|
35
35
|
*
|
|
36
36
|
* @group Types
|
|
37
37
|
*/
|
|
38
38
|
export declare function isJWK(input: unknown): input is JWK;
|
|
39
39
|
/**
|
|
40
|
-
*
|
|
40
|
+
* Type predicate for {@link Core.JWKS | JWKS}
|
|
41
41
|
*
|
|
42
42
|
* @group Types
|
|
43
43
|
*/
|
|
@@ -83,7 +83,7 @@ export interface APIClientConfiguration {
|
|
|
83
83
|
*/
|
|
84
84
|
export type AcrValues = OktaAcrValues | string | string[];
|
|
85
85
|
/**
|
|
86
|
-
* Possible `acr_values` of Okta
|
|
86
|
+
* Possible `acr_values` of Okta authorization servers
|
|
87
87
|
*
|
|
88
88
|
* @group Types
|
|
89
89
|
*
|