@okta/spa-platform 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 +26 -0
- package/dist/esm/Credential/Credential.js.map +1 -0
- package/dist/esm/Credential/CredentialCoordinator.js +128 -0
- package/dist/esm/Credential/CredentialCoordinator.js.map +1 -0
- package/dist/esm/Credential/CredentialDataSource.js +24 -0
- package/dist/esm/Credential/CredentialDataSource.js.map +1 -0
- package/dist/esm/Credential/TokenStorage.js +275 -0
- package/dist/esm/Credential/TokenStorage.js.map +1 -0
- package/dist/esm/FetchClient/index.js +21 -0
- package/dist/esm/FetchClient/index.js.map +1 -0
- package/dist/esm/flows/AuthorizationCodeFlow.js +137 -0
- package/dist/esm/flows/AuthorizationCodeFlow.js.map +1 -0
- package/dist/esm/flows/SessionLogoutFlow.js +45 -0
- package/dist/esm/flows/SessionLogoutFlow.js.map +1 -0
- package/dist/esm/flows/TransactionStorage.js +32 -0
- package/dist/esm/flows/TransactionStorage.js.map +1 -0
- package/dist/esm/index.js +36 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/orchestrators/AuthorizationCodeFlowOrchestrator.js +124 -0
- package/dist/esm/orchestrators/AuthorizationCodeFlowOrchestrator.js.map +1 -0
- package/dist/esm/orchestrators/HostOrchestrator/Host.js +161 -0
- package/dist/esm/orchestrators/HostOrchestrator/Host.js.map +1 -0
- package/dist/esm/orchestrators/HostOrchestrator/OrchestrationBridge.js +37 -0
- package/dist/esm/orchestrators/HostOrchestrator/OrchestrationBridge.js.map +1 -0
- package/dist/esm/orchestrators/HostOrchestrator/SubApp.js +139 -0
- package/dist/esm/orchestrators/HostOrchestrator/SubApp.js.map +1 -0
- package/dist/esm/orchestrators/HostOrchestrator/index.js +45 -0
- package/dist/esm/orchestrators/HostOrchestrator/index.js.map +1 -0
- package/dist/esm/platform/OAuth2Client.js +30 -0
- package/dist/esm/platform/OAuth2Client.js.map +1 -0
- package/dist/esm/platform/defaults.js +25 -0
- package/dist/esm/platform/defaults.js.map +1 -0
- package/dist/esm/platform/dpop/authority.js +19 -0
- package/dist/esm/platform/dpop/authority.js.map +1 -0
- package/dist/esm/platform/dpop/nonceCache.js +32 -0
- package/dist/esm/platform/dpop/nonceCache.js.map +1 -0
- package/dist/esm/platform/index.js +21 -0
- package/dist/esm/platform/index.js.map +1 -0
- package/dist/esm/utils/IndexedDBStore.js +117 -0
- package/dist/esm/utils/IndexedDBStore.js.map +1 -0
- package/dist/esm/utils/LocalBroadcastChannel.js +114 -0
- package/dist/esm/utils/LocalBroadcastChannel.js.map +1 -0
- package/dist/esm/utils/LocalStorageCache.js +78 -0
- package/dist/esm/utils/LocalStorageCache.js.map +1 -0
- package/dist/esm/utils/SynchronizedResult.js +101 -0
- package/dist/esm/utils/SynchronizedResult.js.map +1 -0
- package/dist/esm/utils/UserAgent.js +18 -0
- package/dist/esm/utils/UserAgent.js.map +1 -0
- package/dist/esm/utils/isModernBrowser.js +25 -0
- package/dist/esm/utils/isModernBrowser.js.map +1 -0
- package/dist/types/Credential/Credential.d.ts +20 -0
- package/dist/types/Credential/CredentialCoordinator.d.ts +28 -0
- package/dist/types/Credential/CredentialDataSource.d.ts +9 -0
- package/dist/types/Credential/TokenStorage.d.ts +56 -0
- package/dist/types/Credential/index.d.ts +5 -0
- package/dist/types/FetchClient/index.d.ts +13 -0
- package/dist/types/flows/AuthorizationCodeFlow.d.ts +95 -0
- package/dist/types/flows/SessionLogoutFlow.d.ts +9 -0
- package/dist/types/flows/TransactionStorage.d.ts +9 -0
- package/dist/types/flows/index.d.ts +6 -0
- package/dist/types/index.d.ts +18 -0
- package/dist/types/orchestrators/AuthorizationCodeFlowOrchestrator.d.ts +55 -0
- package/dist/types/orchestrators/HostOrchestrator/Host.d.ts +21 -0
- package/dist/types/orchestrators/HostOrchestrator/OrchestrationBridge.d.ts +10 -0
- package/dist/types/orchestrators/HostOrchestrator/SubApp.d.ts +29 -0
- package/dist/types/orchestrators/HostOrchestrator/index.d.ts +170 -0
- package/dist/types/orchestrators/index.d.ts +5 -0
- package/dist/types/platform/OAuth2Client.d.ts +13 -0
- package/dist/types/platform/defaults.d.ts +2 -0
- package/dist/types/platform/dpop/authority.d.ts +6 -0
- package/dist/types/platform/dpop/index.d.ts +5 -0
- package/dist/types/platform/dpop/nonceCache.d.ts +16 -0
- package/dist/types/platform/index.d.ts +12 -0
- package/dist/types/utils/IndexedDBStore.d.ts +20 -0
- package/dist/types/utils/LocalBroadcastChannel.d.ts +39 -0
- package/dist/types/utils/LocalStorageCache.d.ts +35 -0
- package/dist/types/utils/SynchronizedResult.d.ts +40 -0
- package/dist/types/utils/UserAgent.d.ts +6 -0
- package/dist/types/utils/isModernBrowser.d.ts +9 -0
- package/package.json +1 -0
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Copyright (c) 2015-present, Okta, Inc. and/or its affiliates. All rights reserved.
|
|
3
|
+
* The Okta software accompanied by this notice is provided pursuant to the Apache License, Version 2.0 (the "License.")
|
|
4
|
+
*
|
|
5
|
+
* You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0.
|
|
6
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
7
|
+
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
|
8
|
+
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
9
|
+
*
|
|
10
|
+
* See the License for the specific language governing permissions and limitations under the License.
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
const defaultOptions = {
|
|
14
|
+
timeout: 8000,
|
|
15
|
+
lockFreedDelay: 500,
|
|
16
|
+
retries: 2,
|
|
17
|
+
};
|
|
18
|
+
function sleep(ms) {
|
|
19
|
+
return new Promise(resolve => setTimeout(resolve, ms));
|
|
20
|
+
}
|
|
21
|
+
class SynchronizedResult {
|
|
22
|
+
name;
|
|
23
|
+
task;
|
|
24
|
+
channel;
|
|
25
|
+
options = { ...defaultOptions };
|
|
26
|
+
constructor(name, task, options = {}) {
|
|
27
|
+
this.name = name;
|
|
28
|
+
this.task = task;
|
|
29
|
+
this.channel = new BroadcastChannel(name);
|
|
30
|
+
this.options = { ...defaultOptions, ...options };
|
|
31
|
+
}
|
|
32
|
+
onResultFromOtherTab() {
|
|
33
|
+
const { deseralizer } = this.options;
|
|
34
|
+
return new Promise((resolve) => {
|
|
35
|
+
this.channel.onmessage = (event) => {
|
|
36
|
+
const item = deseralizer ? deseralizer(event.data) : event.data;
|
|
37
|
+
resolve(item);
|
|
38
|
+
};
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
async onLockFreedPlusDelay() {
|
|
42
|
+
await navigator.locks.request(this.name, async () => { });
|
|
43
|
+
await sleep(this.options.lockFreedDelay);
|
|
44
|
+
return 'FREED';
|
|
45
|
+
}
|
|
46
|
+
async onTimeout() {
|
|
47
|
+
await sleep(this.options.timeout);
|
|
48
|
+
return 'TIMEOUT';
|
|
49
|
+
}
|
|
50
|
+
async whenLockIsTaken() {
|
|
51
|
+
const { retries } = this.options;
|
|
52
|
+
const result = await Promise.race([
|
|
53
|
+
this.onResultFromOtherTab(),
|
|
54
|
+
this.onLockFreedPlusDelay(),
|
|
55
|
+
this.onTimeout()
|
|
56
|
+
]);
|
|
57
|
+
this.channel.onmessage = () => { };
|
|
58
|
+
if (result === 'FREED' || result === 'TIMEOUT') {
|
|
59
|
+
if (retries > 0) {
|
|
60
|
+
return this.exec();
|
|
61
|
+
}
|
|
62
|
+
else {
|
|
63
|
+
throw new Error('Task was unable to fulfill');
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
return result;
|
|
67
|
+
}
|
|
68
|
+
async whenLockIsGranted() {
|
|
69
|
+
const { seralizer } = this.options;
|
|
70
|
+
let result;
|
|
71
|
+
try {
|
|
72
|
+
result = await this.task();
|
|
73
|
+
}
|
|
74
|
+
catch (err) {
|
|
75
|
+
this.channel.postMessage(err);
|
|
76
|
+
throw err;
|
|
77
|
+
}
|
|
78
|
+
this.channel.postMessage(seralizer ? seralizer(result) : result);
|
|
79
|
+
return result;
|
|
80
|
+
}
|
|
81
|
+
async exec(overrides = {}) {
|
|
82
|
+
this.options = { ...this.options, ...overrides };
|
|
83
|
+
try {
|
|
84
|
+
return await navigator.locks.request(this.name, { ifAvailable: true }, async (lock) => {
|
|
85
|
+
if (!lock) {
|
|
86
|
+
return this.whenLockIsTaken();
|
|
87
|
+
}
|
|
88
|
+
return this.whenLockIsGranted();
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
finally {
|
|
92
|
+
this.close();
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
close() {
|
|
96
|
+
this.channel.close();
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
export { SynchronizedResult };
|
|
101
|
+
//# sourceMappingURL=SynchronizedResult.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SynchronizedResult.js","sources":["../../../../src/utils/SynchronizedResult.ts"],"sourcesContent":[null],"names":[],"mappings":";;;;;;;;;;;;AAiBA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAM,cAAc,CAAA,CAAA,CAA8B,CAAA;IAEhD,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAO,EAAE,CAAA,CAAA,CAAA,CAAI,CAAA;AACb,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAc,EAAE,CAAA,CAAA,CAAG,CAAA;AACnB,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAO,EAAE,CAAC,CAAA;CACX,CAAA;AAED,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAS,CAAA,CAAA,CAAA,CAAA,CAAK,CAAE,CAAA,CAAU,C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CAAO,CAAA,CAAA,CAAA,CAAI,CAAC,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAiB,CAAA,CAAE,CAAA;AACjC,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAC,CAAC,CAAA;QACJ,CAAA;gBACQ,CAAA;AACN,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAI,CAAC,CAAA,CAAA,CAAA,CAAA,CAAK,CAAA,CAAE,CAAA;QACd,CAAA;IACF,CAAA;IAQO,KAAK,CAAA,CAAA,CAAA,CAAA;AACV,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAI,CAAC,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAO,CAAC,KAAK,CAAA,CAAE,CAAA;IACtB,CAAA;AACD,CAAA;;"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Copyright (c) 2015-present, Okta, Inc. and/or its affiliates. All rights reserved.
|
|
3
|
+
* The Okta software accompanied by this notice is provided pursuant to the Apache License, Version 2.0 (the "License.")
|
|
4
|
+
*
|
|
5
|
+
* You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0.
|
|
6
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
7
|
+
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
|
8
|
+
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
9
|
+
*
|
|
10
|
+
* See the License for the specific language governing permissions and limitations under the License.
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
function isFirefox() {
|
|
14
|
+
return navigator.userAgent.toLowerCase().includes('firefox');
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export { isFirefox };
|
|
18
|
+
//# sourceMappingURL=UserAgent.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"UserAgent.js","sources":["../../../../src/utils/UserAgent.ts"],"sourcesContent":[null],"names":[],"mappings":";;;;;;;;;;;;SAMgB,SAAS,CAAA,CAAA,CAAA,CAAA;IACvB,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAO,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAS,CAAC,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAS,CAAC,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAW,CAAA,CAAE,CAAC,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAQ,CAAC,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAS,CAAC,CAAA;AAC9D,CAAA;;"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Copyright (c) 2015-present, Okta, Inc. and/or its affiliates. All rights reserved.
|
|
3
|
+
* The Okta software accompanied by this notice is provided pursuant to the Apache License, Version 2.0 (the "License.")
|
|
4
|
+
*
|
|
5
|
+
* You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0.
|
|
6
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
7
|
+
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
|
8
|
+
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
9
|
+
*
|
|
10
|
+
* See the License for the specific language governing permissions and limitations under the License.
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
function isModernBrowser() {
|
|
14
|
+
if (navigator && navigator.locks &&
|
|
15
|
+
crypto && crypto.subtle &&
|
|
16
|
+
BroadcastChannel &&
|
|
17
|
+
AbortController && AbortSignal
|
|
18
|
+
) {
|
|
19
|
+
return true;
|
|
20
|
+
}
|
|
21
|
+
return false;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export { isModernBrowser };
|
|
25
|
+
//# sourceMappingURL=isModernBrowser.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"isModernBrowser.js","sources":["../../../../src/utils/isModernBrowser.ts"],"sourcesContent":[null],"names":[],"mappings":";;;;;;;;;;;;SAUgB,eAAe,CAAA,CAAA,CAAA,CAAA;AAC7B,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CACE,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAS,CAAA,CAAA,CAAA,CAAI,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAS,CAAC,CAAA,CAAA,CAAA,CAAA,CAAK,CAAA,CAAA,CAAA;AAC5B,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAM,CAAA,CAAA,CAAA,CAAI,CAAA,CAAA,CAAA,CAAA,CAAA,CAAM,CAAC,CAAA,CAAA,CAAA,CAAA,CAAA,CAAM,CAAA,CAAA,CAAA;AACvB,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAgB,CAAA,CAAA,CAAA;QAChB,eAAe,CAAA,CAAA,CAAA,CAAI,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA;MACnB,CAAA;AACA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,OAAO,CAAA,CAAA,CAAA,CAAI,CAAA;IACb,CAAA;AAEA,CAAA,CAAA,CAAA,CAAA,OAAO,CAAA,CAAA,CAAA,CAAA,CAAK,CAAA;AACd,CAAA;;"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module
|
|
3
|
+
* @mergeModuleWith Platform
|
|
4
|
+
*/
|
|
5
|
+
import { Credential as CredentialBase, type RequestAuthorizer, type JSONSerializable } from '@okta/auth-foundation/core';
|
|
6
|
+
/**
|
|
7
|
+
* A browser-specific implementation of `@okta/auth-foundation` {@link AuthFoundation!Credential | Credential}
|
|
8
|
+
*
|
|
9
|
+
* @group Credential
|
|
10
|
+
* @noInheritDoc
|
|
11
|
+
*/
|
|
12
|
+
export declare class Credential extends CredentialBase implements RequestAuthorizer, JSONSerializable {
|
|
13
|
+
/**
|
|
14
|
+
* Closes the underlying BroadcastChannel, useful for testing environments to avoid open handles
|
|
15
|
+
*
|
|
16
|
+
* @see
|
|
17
|
+
* {@link https://jestjs.io/docs/cli#--detectopenhandles | jest --detectOpenHandles}
|
|
18
|
+
*/
|
|
19
|
+
static close(): void;
|
|
20
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @packageDocumentation
|
|
3
|
+
* @internal
|
|
4
|
+
*/
|
|
5
|
+
import type { TokenStorage, JsonPrimitive, JsonRecord } from '@okta/auth-foundation/core';
|
|
6
|
+
import { CredentialCoordinator, CredentialCoordinatorImpl as CredentialCoordinatorBase } from '@okta/auth-foundation/core';
|
|
7
|
+
/**
|
|
8
|
+
* Browser-specific implementation of {@link CredentialCoordinator}
|
|
9
|
+
*
|
|
10
|
+
* @internal
|
|
11
|
+
*/
|
|
12
|
+
export declare class CredentialCoordinatorImpl extends CredentialCoordinatorBase implements CredentialCoordinator {
|
|
13
|
+
private readonly id;
|
|
14
|
+
private readonly channel;
|
|
15
|
+
constructor(CredentialConstructor: (ConstructorParameters<typeof CredentialCoordinatorBase>)[0]);
|
|
16
|
+
get tokenStorage(): TokenStorage;
|
|
17
|
+
set tokenStorage(tokenStorage: TokenStorage);
|
|
18
|
+
protected broadcast(eventName: string, data: Record<string, JsonPrimitive | JsonRecord>): void;
|
|
19
|
+
protected registerTabListeners(): void;
|
|
20
|
+
clear(localOnly?: boolean): Promise<void>;
|
|
21
|
+
/**
|
|
22
|
+
* Closes the underlying BroadcastChannel, useful for testing environments to avoid open handles
|
|
23
|
+
*
|
|
24
|
+
* @see
|
|
25
|
+
* {@link https://jestjs.io/docs/cli#--detectopenhandles | jest --detectOpenHandles}
|
|
26
|
+
*/
|
|
27
|
+
close(): void;
|
|
28
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @packageDocumentation
|
|
3
|
+
* @internal
|
|
4
|
+
*/
|
|
5
|
+
import { type ConfigurationParams, DefaultCredentialDataSource as BaseCredentialDataSource, CredentialDataSource } from '@okta/auth-foundation/core';
|
|
6
|
+
import { OAuth2Client } from '../platform/index.ts';
|
|
7
|
+
export declare class DefaultCredentialDataSource extends BaseCredentialDataSource implements CredentialDataSource {
|
|
8
|
+
protected createOAuth2Client(params: ConfigurationParams): OAuth2Client;
|
|
9
|
+
}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @packageDocumentation
|
|
3
|
+
* @internal
|
|
4
|
+
*/
|
|
5
|
+
import { Token, type TokenStorage, type TokenStorageEvents, EventEmitter } from '@okta/auth-foundation/core';
|
|
6
|
+
import { IndexedDBStore } from '../utils/IndexedDBStore.ts';
|
|
7
|
+
/**
|
|
8
|
+
* Default implementation of TokenStorage backend by `localStorage`
|
|
9
|
+
* @internal
|
|
10
|
+
*/
|
|
11
|
+
export declare class BrowserTokenStorage implements TokenStorage {
|
|
12
|
+
#private;
|
|
13
|
+
private static version;
|
|
14
|
+
tokenPrefix: string;
|
|
15
|
+
encryptionKeyStore: IndexedDBStore<CryptoKey>;
|
|
16
|
+
encryptionKeyName: string;
|
|
17
|
+
includeClaims: boolean;
|
|
18
|
+
encryptAtRest: boolean;
|
|
19
|
+
supportLegacyStructure: boolean;
|
|
20
|
+
readonly emitter: EventEmitter<TokenStorageEvents>;
|
|
21
|
+
get defaultCredentialKey(): string;
|
|
22
|
+
set defaultCredentialKey(key: string);
|
|
23
|
+
get defaultTokenId(): string | null;
|
|
24
|
+
protected idToStoreKey(id: string): string;
|
|
25
|
+
protected legacyStoreKey(id: string): string;
|
|
26
|
+
setDefaultTokenId(id: string | null): Promise<void>;
|
|
27
|
+
private saveDefault;
|
|
28
|
+
allIDs(): Promise<string[]>;
|
|
29
|
+
add(token: Token, metadata?: Token.Metadata): Promise<void>;
|
|
30
|
+
replace(id: string, token: Token): Promise<void>;
|
|
31
|
+
remove(id: string): Promise<void>;
|
|
32
|
+
get(id: string): Promise<Token | null>;
|
|
33
|
+
getMetadata(id: string): Promise<Token.Metadata | null>;
|
|
34
|
+
setMetadata(metadata: Token.Metadata): Promise<void>;
|
|
35
|
+
clear(): Promise<void>;
|
|
36
|
+
protected writeToStorage(token: Token, metadata: Record<string, any>): Promise<void>;
|
|
37
|
+
protected readFromStorage(id: string): Promise<Record<string, any> | null>;
|
|
38
|
+
protected writeLegacy(token: Token, metadata: Record<string, any>): void;
|
|
39
|
+
protected convertFromLegacy(id: string): {
|
|
40
|
+
token: any;
|
|
41
|
+
metadata: any;
|
|
42
|
+
} | null;
|
|
43
|
+
/**
|
|
44
|
+
* Handles errors thrown when reading a token from storage
|
|
45
|
+
*/
|
|
46
|
+
protected handleReadError(error: unknown, id: string): Promise<null>;
|
|
47
|
+
/**
|
|
48
|
+
* Handles errors thrown when decrypting a stored token
|
|
49
|
+
*/
|
|
50
|
+
protected handleDecryptionError(error: Error, id: string): Promise<null>;
|
|
51
|
+
protected getEncryptionKey(): Promise<CryptoKey>;
|
|
52
|
+
protected generateEncryptionKey(): Promise<CryptoKey>;
|
|
53
|
+
protected removeEncryptionKeyIfEmpty(): Promise<void>;
|
|
54
|
+
protected encrypt(plainText: string, iv: string): Promise<ArrayBuffer>;
|
|
55
|
+
protected decrypt(encryptedText: string, iv: string): Promise<ArrayBuffer>;
|
|
56
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { FetchClient as FetchClientBase, type DPoPNonceCache } from '@okta/auth-foundation/core';
|
|
2
|
+
/**
|
|
3
|
+
* @module FetchClient
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* Wrapper around {@link fetch} to perform authenticated requests to a resource server
|
|
7
|
+
*
|
|
8
|
+
* The provided {@link TokenOrchestrator} is used to retrieve a {@link Token} which matches the criteria passed in via
|
|
9
|
+
* {@link TokenOrchestrator.AuthorizeParams}, like `issuer`, `client` and `scopes`. Once a valid {@link Token} is found, the request is made
|
|
10
|
+
*/
|
|
11
|
+
export declare class FetchClient extends FetchClientBase {
|
|
12
|
+
protected readonly dpopNonceCache: DPoPNonceCache;
|
|
13
|
+
}
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import { type OAuth2ErrorResponse } from '@okta/auth-foundation/core';
|
|
2
|
+
import { AuthorizationCodeFlow as AuthorizationCodeFlowBase } from '@okta/oauth2-flows';
|
|
3
|
+
/** @internal */
|
|
4
|
+
type PostMessageListenerOptions = {
|
|
5
|
+
state: string;
|
|
6
|
+
expectedOrigin: string;
|
|
7
|
+
timeout?: number;
|
|
8
|
+
};
|
|
9
|
+
/** @internal */
|
|
10
|
+
declare function bindOktaPostMessageListener({ state, expectedOrigin, timeout }: PostMessageListenerOptions): Promise<AuthorizationCodeFlow.RedirectValues | OAuth2ErrorResponse>;
|
|
11
|
+
export declare class AuthorizationCodeFlow extends AuthorizationCodeFlowBase {
|
|
12
|
+
/**
|
|
13
|
+
* Performs a browser full-page redirect to the `Authorization Server` `/authorize` endpoint.
|
|
14
|
+
* Once authentication is successful, the user will be redirected back to the provided `redirectUri`
|
|
15
|
+
*
|
|
16
|
+
* @group Authorize Methods
|
|
17
|
+
*
|
|
18
|
+
* @remarks
|
|
19
|
+
* This method returns a `Promise` that will never fulfill; a browser redirect will occur first
|
|
20
|
+
*
|
|
21
|
+
* @see
|
|
22
|
+
* {@link AuthorizationCodeFlow.resume}
|
|
23
|
+
*/
|
|
24
|
+
static PerformRedirect(flow: AuthorizationCodeFlow): Promise<void>;
|
|
25
|
+
/** @internal */
|
|
26
|
+
protected static prepareOktaPostMessage(flow: AuthorizationCodeFlow): Promise<{
|
|
27
|
+
authorizeUrl: URL;
|
|
28
|
+
context: AuthorizationCodeFlowBase.Context;
|
|
29
|
+
}>;
|
|
30
|
+
/** @internal */
|
|
31
|
+
protected static processOktaPostMessage(flow: AuthorizationCodeFlow, result: Awaited<ReturnType<typeof bindOktaPostMessageListener>>, context: AuthorizationCodeFlow.Context): Promise<AuthorizationCodeFlowBase.Result>;
|
|
32
|
+
/**
|
|
33
|
+
* Fulfills the `/authorize` request within a hidden iframe and therefore does *not* require a redirect.
|
|
34
|
+
* This requires an existing cookie-based session with the IDP and is susceptible to third-party cookie restrictions.
|
|
35
|
+
*
|
|
36
|
+
* @group Authorize Methods
|
|
37
|
+
*
|
|
38
|
+
* @remarks
|
|
39
|
+
* This approach is not recommended for most common use cases and may be deprecated in the future.
|
|
40
|
+
* Use {@link AuthorizationCodeFlow.PerformRedirect} instead
|
|
41
|
+
*
|
|
42
|
+
* @returns
|
|
43
|
+
* Returns a {@link Platform.Token | Token} and the {@link AuthorizationCodeFlow.Context} used to request the token
|
|
44
|
+
*
|
|
45
|
+
* @see
|
|
46
|
+
* - {@link https://auth0.com/docs/authenticate/login/configure-silent-authentication | Silent Authentication}
|
|
47
|
+
* - {@link https://developers.google.com/privacy-sandbox/cookies | Third-party Cookie Deprecation}
|
|
48
|
+
*/
|
|
49
|
+
static PerformSilently(flow: AuthorizationCodeFlow): Promise<AuthorizationCodeFlow.Result>;
|
|
50
|
+
/**
|
|
51
|
+
* Read carefully before use. This method (and popup pattern at large) has quite a few "gotchas"
|
|
52
|
+
*
|
|
53
|
+
* Fulfills `/authorize` requests in a popup window. Not necessarily recommended for primary authentication flows,
|
|
54
|
+
* but can be useful for step up authentication flows.
|
|
55
|
+
*
|
|
56
|
+
* @group Authorize Methods
|
|
57
|
+
*
|
|
58
|
+
* @remarks
|
|
59
|
+
* Utilizing external IDPs in a popup window may be susceptible to the IDP's `Cross-Origin-Opener-Policy`. Depending on their policy value,
|
|
60
|
+
* the loading the IDP in a popup window may cause the popup window to create a new browsing context group (BCG), seperate from the main
|
|
61
|
+
* browser window. The authentication flow will be unable to complete if this occurs. It's recommended to avoid using this method (and a popup
|
|
62
|
+
* in general) when utilizing external IDPs.
|
|
63
|
+
*
|
|
64
|
+
* {@link https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Cross-Origin-Opener-Policy | Cross-Origin-Opener-Policy}
|
|
65
|
+
* {@link https://developer.mozilla.org/en-US/docs/Glossary/Browsing_context | Browsing Context Group}
|
|
66
|
+
*
|
|
67
|
+
* @param flow - instance of {@link AuthorizationCodeFlow} to be used
|
|
68
|
+
*
|
|
69
|
+
* @param popupWindow - Optionally, a `Window` object (representing a popup window) can be provided.
|
|
70
|
+
* Providing a popup reference can be useful when control over the popup's attributes, like name and size, is required.
|
|
71
|
+
*
|
|
72
|
+
* In addition, the popup window will first load the base route (`/`) of the web application. Some browser implement heustistics which
|
|
73
|
+
* can block popups spawned from `async` processes. Loading the base route before navigating to `/authorize` helps reduce the likelihood
|
|
74
|
+
* the popup gets blocked. To override this behavior, provide a popup reference
|
|
75
|
+
*
|
|
76
|
+
* @returns {@link AuthorizationCodeFlow.PopupResult}
|
|
77
|
+
* On success, the return value will be `{ completed: true, token: {@link Platform.Token | Token}, context: {@link AuthorizationCodeFlow.Context} }`
|
|
78
|
+
* On failure, the return value will be `{ completed: false; reason: 'closed' | 'blocked' }`
|
|
79
|
+
* - `'closed'` indicates the user manually closed the popup window
|
|
80
|
+
* - `'blocked'` indicates the popup window was unable to be opened (presumably by a popup blocker or browser heustistics)
|
|
81
|
+
*/
|
|
82
|
+
static PerformInPopup(flow: AuthorizationCodeFlow, popupWindow?: Window): Promise<AuthorizationCodeFlow.PopupResult>;
|
|
83
|
+
}
|
|
84
|
+
export declare namespace AuthorizationCodeFlow {
|
|
85
|
+
type RedirectValues = AuthorizationCodeFlowBase.RedirectValues;
|
|
86
|
+
type Result = AuthorizationCodeFlowBase.Result;
|
|
87
|
+
type Context = AuthorizationCodeFlowBase.Context;
|
|
88
|
+
type PopupResult = (Result & {
|
|
89
|
+
completed: true;
|
|
90
|
+
}) | {
|
|
91
|
+
completed: false;
|
|
92
|
+
reason: 'closed' | 'blocked';
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
export {};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { SessionLogoutFlow as SessionLogoutFlowBase } from '@okta/oauth2-flows';
|
|
2
|
+
export declare class SessionLogoutFlow extends SessionLogoutFlowBase {
|
|
3
|
+
static PerformPostRedirect(logoutUrl: URL, options?: Partial<SessionLogoutFlow.PostRedirectOptions>): Promise<unknown>;
|
|
4
|
+
}
|
|
5
|
+
export declare namespace SessionLogoutFlow {
|
|
6
|
+
type PostRedirectOptions = {
|
|
7
|
+
parentElement: HTMLElement;
|
|
8
|
+
};
|
|
9
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { JsonRecord } from '@okta/auth-foundation/core';
|
|
2
|
+
import type { TransactionStorage } from '@okta/oauth2-flows';
|
|
3
|
+
export declare class BrowserTransactionStorage implements TransactionStorage {
|
|
4
|
+
#private;
|
|
5
|
+
private static version;
|
|
6
|
+
get(key: string): Promise<JsonRecord | undefined>;
|
|
7
|
+
add(key: string, item: JsonRecord): Promise<void>;
|
|
8
|
+
remove(key: string): Promise<void>;
|
|
9
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @packageDocumentation
|
|
3
|
+
* @internal
|
|
4
|
+
*/
|
|
5
|
+
export * from './platform/defaults.ts';
|
|
6
|
+
export * from '@okta/auth-foundation/core';
|
|
7
|
+
export { Credential } from './Credential/Credential.ts';
|
|
8
|
+
export { CredentialCoordinatorImpl } from './Credential/CredentialCoordinator.ts';
|
|
9
|
+
export { BrowserTokenStorage } from './Credential/TokenStorage.ts';
|
|
10
|
+
export { DefaultCredentialDataSource } from './Credential/CredentialDataSource.ts';
|
|
11
|
+
export { FetchClient } from './FetchClient/index.ts';
|
|
12
|
+
export * from './orchestrators/index.ts';
|
|
13
|
+
export * from './flows/index.ts';
|
|
14
|
+
export { DefaultSigningAuthority } from './platform/dpop/authority.ts';
|
|
15
|
+
export { clearDPoPKeyPairs } from './platform/index.ts';
|
|
16
|
+
export { PersistentCache } from './platform/dpop/nonceCache.ts';
|
|
17
|
+
export { OAuth2Client } from './platform/OAuth2Client.ts';
|
|
18
|
+
export * from './utils/isModernBrowser.ts';
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module
|
|
3
|
+
* @mergeModuleWith TokenOrchestrators
|
|
4
|
+
*/
|
|
5
|
+
import { Token, TokenOrchestrator, EventEmitter } from '@okta/auth-foundation/core';
|
|
6
|
+
import { AuthorizationCodeFlow } from '../flows/index.ts';
|
|
7
|
+
import { Credential } from '../Credential/index.ts';
|
|
8
|
+
/**
|
|
9
|
+
* An implementation of {@link AuthFoundation!TokenOrchestrator | TokenOrchestrator} leveraging
|
|
10
|
+
* {@link https://developer.okta.com/docs/concepts/oauth-openid/#authorization-code-flow-with-pkce-flow | Authorization Code Flow }
|
|
11
|
+
* @public
|
|
12
|
+
*/
|
|
13
|
+
export declare class AuthorizationCodeFlowOrchestrator<E extends AuthorizationCodeFlowOrchestrator.Events = AuthorizationCodeFlowOrchestrator.Events> extends TokenOrchestrator<E> {
|
|
14
|
+
readonly flow: AuthorizationCodeFlow;
|
|
15
|
+
protected readonly emitter: EventEmitter<E>;
|
|
16
|
+
options: AuthorizationCodeFlowOrchestrator.Options;
|
|
17
|
+
constructor(flow: AuthorizationCodeFlow, init?: AuthorizationCodeFlowOrchestrator.Init);
|
|
18
|
+
/**
|
|
19
|
+
* Defines how to handle the authorization code redirect
|
|
20
|
+
*
|
|
21
|
+
* throws if an OAuth2 error is returned
|
|
22
|
+
*/
|
|
23
|
+
resumeFlow(redirectUri?: string): Promise<Record<string, any>>;
|
|
24
|
+
/**
|
|
25
|
+
* Defines how to search storage for an existing token
|
|
26
|
+
*/
|
|
27
|
+
selectCredential(options: TokenOrchestrator.AuthorizeParams): Promise<Credential | null>;
|
|
28
|
+
/**
|
|
29
|
+
* Defines how to store a newly acquired token
|
|
30
|
+
*/
|
|
31
|
+
protected storeCredential(token: Token, tags?: string[] | undefined): Promise<Credential>;
|
|
32
|
+
/**
|
|
33
|
+
* Defines how to request a token from Authorization Server
|
|
34
|
+
*/
|
|
35
|
+
protected requestToken(params: TokenOrchestrator.AuthorizeParams): Promise<Token | null>;
|
|
36
|
+
/**
|
|
37
|
+
* Determines if a valid token already exists in storage, otherwise requests a new token
|
|
38
|
+
*/
|
|
39
|
+
getToken(params?: TokenOrchestrator.AuthorizeParams): Promise<Token | null>;
|
|
40
|
+
}
|
|
41
|
+
export declare namespace AuthorizationCodeFlowOrchestrator {
|
|
42
|
+
type Options = {
|
|
43
|
+
avoidPrompting: boolean;
|
|
44
|
+
emitBeforeRedirect: boolean;
|
|
45
|
+
getOriginalUri: () => string;
|
|
46
|
+
tags?: string[];
|
|
47
|
+
};
|
|
48
|
+
type Init = Partial<Options>;
|
|
49
|
+
type Events = {
|
|
50
|
+
'login_prompt_required': {
|
|
51
|
+
done: () => void;
|
|
52
|
+
params: TokenOrchestrator.AuthorizeParams;
|
|
53
|
+
};
|
|
54
|
+
} & TokenOrchestrator.Events;
|
|
55
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { HostOrchestrator as HO } from './index.ts';
|
|
2
|
+
import { Token, EventEmitter, type Emitter, TokenOrchestrator } from '@okta/auth-foundation/core';
|
|
3
|
+
export declare abstract class HostOrchestrator<E extends HO.HostEvents = HO.HostEvents> implements Emitter<E> {
|
|
4
|
+
#private;
|
|
5
|
+
protected readonly name: string;
|
|
6
|
+
protected readonly emitter: EventEmitter<E>;
|
|
7
|
+
id: string;
|
|
8
|
+
constructor(name: string, options?: HO.HostOptions);
|
|
9
|
+
on(...args: Parameters<EventEmitter<E>['on']>): EventEmitter<E>;
|
|
10
|
+
off(...args: Parameters<EventEmitter<E>['off']>): EventEmitter<E>;
|
|
11
|
+
get isActive(): boolean;
|
|
12
|
+
protected shouldActive(): boolean;
|
|
13
|
+
activate(): void;
|
|
14
|
+
close(): void;
|
|
15
|
+
protected parseRequest<K extends keyof HO.RequestEvent>(request: HO.RequestEvent[K], replyFn: any): Promise<any>;
|
|
16
|
+
protected handleHostActivated({ hostId }: HO.ActivatedEvent): void;
|
|
17
|
+
protected handleTokenRequest(event: HO.TokenRequest): Promise<HO.TokenResponse>;
|
|
18
|
+
protected handleAuthorizeRequest(event: HO.AuthorizeRequest): Promise<HO.AuthorizeResponse>;
|
|
19
|
+
protected handleProfileRequest(event: HO.TokenRequest): Promise<HO.ProfileResponse>;
|
|
20
|
+
abstract findToken(params: TokenOrchestrator.AuthorizeParams): Promise<Token | null | HO.ErrorResponse>;
|
|
21
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { HostOrchestrator } from './index.ts';
|
|
2
|
+
import { TaskBridge } from '@okta/auth-foundation/core';
|
|
3
|
+
export declare class OrchestrationBridge extends TaskBridge<HostOrchestrator.RequestEvent, HostOrchestrator.ResponseEvent> {
|
|
4
|
+
static targetOrigin: string;
|
|
5
|
+
static allowedOrigins: string[];
|
|
6
|
+
private readonly options;
|
|
7
|
+
constructor(name: string, options?: HostOrchestrator.HostOptions & HostOrchestrator.SubAppOptions);
|
|
8
|
+
protected createBridgeChannel(): TaskBridge.BridgeChannel<HostOrchestrator.RequestEvent[keyof HostOrchestrator.RequestEvent]>;
|
|
9
|
+
protected createTaskChannel<K extends keyof HostOrchestrator.RequestEvent & keyof HostOrchestrator.ResponseEvent>(name: string): TaskBridge.TaskChannel<HostOrchestrator.ResponseEvent[K]>;
|
|
10
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { HostOrchestrator as HO } from './index.ts';
|
|
2
|
+
import { Token, TokenOrchestrator, EventEmitter } from '@okta/auth-foundation/core';
|
|
3
|
+
export type SubAppBroadcastOptions = {
|
|
4
|
+
timeout: number;
|
|
5
|
+
};
|
|
6
|
+
export declare class SubAppOrchestrator<E extends HO.SubAppEvents = HO.SubAppEvents> extends TokenOrchestrator<E> {
|
|
7
|
+
#private;
|
|
8
|
+
readonly name: string;
|
|
9
|
+
readonly id: string;
|
|
10
|
+
protected readonly authParams: TokenOrchestrator.AuthorizeParams;
|
|
11
|
+
protected readonly emitter: EventEmitter<E>;
|
|
12
|
+
defaultTimeout: number;
|
|
13
|
+
constructor(name: string, options?: HO.SubAppOptions);
|
|
14
|
+
protected broadcast<K extends keyof HO.RequestEvent & keyof HO.ResponseEvent>(eventName: K, data: HO.RequestEvent[K]['data'], options?: SubAppBroadcastOptions): Promise<HO.ResponseEvent[K]>;
|
|
15
|
+
protected getTokenCacheKey(params: TokenOrchestrator.AuthorizeParams): Promise<string>;
|
|
16
|
+
protected ping(timeout: number): Promise<boolean>;
|
|
17
|
+
pingHost({ interval, attempts }?: {
|
|
18
|
+
interval?: number | undefined;
|
|
19
|
+
attempts?: number | undefined;
|
|
20
|
+
}): Promise<boolean>;
|
|
21
|
+
protected requestToken(params: TokenOrchestrator.AuthorizeParams): Promise<Token | null>;
|
|
22
|
+
/**
|
|
23
|
+
* Retrieves a valid {@link Platform.Token | Token} to be used within an application
|
|
24
|
+
*/
|
|
25
|
+
getToken(params?: TokenOrchestrator.AuthorizeParams): Promise<Token | null>;
|
|
26
|
+
authorize(input: string | URL | Request, init?: RequestInit & {
|
|
27
|
+
dpopNonce?: string;
|
|
28
|
+
} & TokenOrchestrator.AuthorizeParams): Promise<Request>;
|
|
29
|
+
}
|