@forgerock/iframe-manager 2.0.0 → 2.1.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/dist/src/lib/iframe-manager.effects.d.ts +4 -0
- package/dist/src/lib/iframe-manager.effects.d.ts.map +1 -1
- package/dist/src/lib/iframe-manager.effects.js +49 -15
- package/dist/tsconfig.lib.tsbuildinfo +1 -1
- package/package.json +8 -1
- package/CHANGELOG.md +0 -32
- package/coverage/base.css +0 -224
- package/coverage/block-navigation.js +0 -87
- package/coverage/coverage-final.json +0 -3
- package/coverage/favicon.png +0 -0
- package/coverage/index.html +0 -131
- package/coverage/prettify.css +0 -1
- package/coverage/prettify.js +0 -2
- package/coverage/sort-arrow-sprite.png +0 -0
- package/coverage/sorter.js +0 -210
- package/coverage/src/index.html +0 -116
- package/coverage/src/index.ts.html +0 -88
- package/coverage/src/lib/iframe-manager.effects.ts.html +0 -604
- package/coverage/src/lib/index.html +0 -116
- package/eslint.config.mjs +0 -22
- package/src/index.ts +0 -1
- package/src/lib/iframe-manager.effects.ts +0 -173
- package/tsconfig.json +0 -16
- package/tsconfig.lib.json +0 -34
- package/tsconfig.spec.json +0 -41
- package/typedoc.json +0 -4
- package/vite.config.ts +0 -0
|
@@ -1,116 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
<!doctype html>
|
|
3
|
-
<html lang="en">
|
|
4
|
-
|
|
5
|
-
<head>
|
|
6
|
-
<title>Code coverage report for src/lib</title>
|
|
7
|
-
<meta charset="utf-8" />
|
|
8
|
-
<link rel="stylesheet" href="../../prettify.css" />
|
|
9
|
-
<link rel="stylesheet" href="../../base.css" />
|
|
10
|
-
<link rel="shortcut icon" type="image/x-icon" href="../../favicon.png" />
|
|
11
|
-
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
|
12
|
-
<style type='text/css'>
|
|
13
|
-
.coverage-summary .sorter {
|
|
14
|
-
background-image: url(../../sort-arrow-sprite.png);
|
|
15
|
-
}
|
|
16
|
-
</style>
|
|
17
|
-
</head>
|
|
18
|
-
|
|
19
|
-
<body>
|
|
20
|
-
<div class='wrapper'>
|
|
21
|
-
<div class='pad1'>
|
|
22
|
-
<h1><a href="../../index.html">All files</a> src/lib</h1>
|
|
23
|
-
<div class='clearfix'>
|
|
24
|
-
|
|
25
|
-
<div class='fl pad1y space-right2'>
|
|
26
|
-
<span class="strong">0% </span>
|
|
27
|
-
<span class="quiet">Statements</span>
|
|
28
|
-
<span class='fraction'>0/105</span>
|
|
29
|
-
</div>
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
<div class='fl pad1y space-right2'>
|
|
33
|
-
<span class="strong">100% </span>
|
|
34
|
-
<span class="quiet">Branches</span>
|
|
35
|
-
<span class='fraction'>1/1</span>
|
|
36
|
-
</div>
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
<div class='fl pad1y space-right2'>
|
|
40
|
-
<span class="strong">100% </span>
|
|
41
|
-
<span class="quiet">Functions</span>
|
|
42
|
-
<span class='fraction'>1/1</span>
|
|
43
|
-
</div>
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
<div class='fl pad1y space-right2'>
|
|
47
|
-
<span class="strong">0% </span>
|
|
48
|
-
<span class="quiet">Lines</span>
|
|
49
|
-
<span class='fraction'>0/105</span>
|
|
50
|
-
</div>
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
</div>
|
|
54
|
-
<p class="quiet">
|
|
55
|
-
Press <em>n</em> or <em>j</em> to go to the next uncovered block, <em>b</em>, <em>p</em> or <em>k</em> for the previous block.
|
|
56
|
-
</p>
|
|
57
|
-
<template id="filterTemplate">
|
|
58
|
-
<div class="quiet">
|
|
59
|
-
Filter:
|
|
60
|
-
<input type="search" id="fileSearch">
|
|
61
|
-
</div>
|
|
62
|
-
</template>
|
|
63
|
-
</div>
|
|
64
|
-
<div class='status-line low'></div>
|
|
65
|
-
<div class="pad1">
|
|
66
|
-
<table class="coverage-summary">
|
|
67
|
-
<thead>
|
|
68
|
-
<tr>
|
|
69
|
-
<th data-col="file" data-fmt="html" data-html="true" class="file">File</th>
|
|
70
|
-
<th data-col="pic" data-type="number" data-fmt="html" data-html="true" class="pic"></th>
|
|
71
|
-
<th data-col="statements" data-type="number" data-fmt="pct" class="pct">Statements</th>
|
|
72
|
-
<th data-col="statements_raw" data-type="number" data-fmt="html" class="abs"></th>
|
|
73
|
-
<th data-col="branches" data-type="number" data-fmt="pct" class="pct">Branches</th>
|
|
74
|
-
<th data-col="branches_raw" data-type="number" data-fmt="html" class="abs"></th>
|
|
75
|
-
<th data-col="functions" data-type="number" data-fmt="pct" class="pct">Functions</th>
|
|
76
|
-
<th data-col="functions_raw" data-type="number" data-fmt="html" class="abs"></th>
|
|
77
|
-
<th data-col="lines" data-type="number" data-fmt="pct" class="pct">Lines</th>
|
|
78
|
-
<th data-col="lines_raw" data-type="number" data-fmt="html" class="abs"></th>
|
|
79
|
-
</tr>
|
|
80
|
-
</thead>
|
|
81
|
-
<tbody><tr>
|
|
82
|
-
<td class="file low" data-value="iframe-manager.effects.ts"><a href="iframe-manager.effects.ts.html">iframe-manager.effects.ts</a></td>
|
|
83
|
-
<td data-value="0" class="pic low">
|
|
84
|
-
<div class="chart"><div class="cover-fill" style="width: 0%"></div><div class="cover-empty" style="width: 100%"></div></div>
|
|
85
|
-
</td>
|
|
86
|
-
<td data-value="0" class="pct low">0%</td>
|
|
87
|
-
<td data-value="105" class="abs low">0/105</td>
|
|
88
|
-
<td data-value="100" class="pct high">100%</td>
|
|
89
|
-
<td data-value="1" class="abs high">1/1</td>
|
|
90
|
-
<td data-value="100" class="pct high">100%</td>
|
|
91
|
-
<td data-value="1" class="abs high">1/1</td>
|
|
92
|
-
<td data-value="0" class="pct low">0%</td>
|
|
93
|
-
<td data-value="105" class="abs low">0/105</td>
|
|
94
|
-
</tr>
|
|
95
|
-
|
|
96
|
-
</tbody>
|
|
97
|
-
</table>
|
|
98
|
-
</div>
|
|
99
|
-
<div class='push'></div><!-- for sticky footer -->
|
|
100
|
-
</div><!-- /wrapper -->
|
|
101
|
-
<div class='footer quiet pad2 space-top1 center small'>
|
|
102
|
-
Code coverage generated by
|
|
103
|
-
<a href="https://istanbul.js.org/" target="_blank" rel="noopener noreferrer">istanbul</a>
|
|
104
|
-
at 2026-03-19T17:04:15.646Z
|
|
105
|
-
</div>
|
|
106
|
-
<script src="../../prettify.js"></script>
|
|
107
|
-
<script>
|
|
108
|
-
window.onload = function () {
|
|
109
|
-
prettyPrint();
|
|
110
|
-
};
|
|
111
|
-
</script>
|
|
112
|
-
<script src="../../sorter.js"></script>
|
|
113
|
-
<script src="../../block-navigation.js"></script>
|
|
114
|
-
</body>
|
|
115
|
-
</html>
|
|
116
|
-
|
package/eslint.config.mjs
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import baseConfig from '../../../eslint.config.mjs';
|
|
2
|
-
|
|
3
|
-
export default [
|
|
4
|
-
...baseConfig,
|
|
5
|
-
{
|
|
6
|
-
files: ['**/*.json'],
|
|
7
|
-
rules: {
|
|
8
|
-
'@nx/dependency-checks': [
|
|
9
|
-
'warn',
|
|
10
|
-
{
|
|
11
|
-
ignoredFiles: [
|
|
12
|
-
'{projectRoot}/eslint.config.{js,cjs,mjs}',
|
|
13
|
-
'{projectRoot}/vite.config.{js,ts,mjs,mts}',
|
|
14
|
-
],
|
|
15
|
-
},
|
|
16
|
-
],
|
|
17
|
-
},
|
|
18
|
-
languageOptions: {
|
|
19
|
-
parser: (await import('jsonc-eslint-parser')).default,
|
|
20
|
-
},
|
|
21
|
-
},
|
|
22
|
-
];
|
package/src/index.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './lib/iframe-manager.effects.js';
|
|
@@ -1,173 +0,0 @@
|
|
|
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
|
-
|
|
8
|
-
/* eslint-disable @typescript-eslint/no-empty-function */
|
|
9
|
-
|
|
10
|
-
export interface GetParamsFromIFrameOptions {
|
|
11
|
-
/** The URL to load in the iframe. */
|
|
12
|
-
url: string;
|
|
13
|
-
/** Timeout in milliseconds for the entire operation. */
|
|
14
|
-
timeout: number;
|
|
15
|
-
/** Array of query parameter keys expected upon successful completion. */
|
|
16
|
-
successParams: string[];
|
|
17
|
-
/** Array of query parameter keys indicating an error occurred. */
|
|
18
|
-
errorParams: string[];
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
export type ResolvedParams = Record<string, string>;
|
|
22
|
-
|
|
23
|
-
type Noop = () => void;
|
|
24
|
-
|
|
25
|
-
function hasErrorParams(params: URLSearchParams, errorParams: string[]): boolean {
|
|
26
|
-
for (const key of errorParams) {
|
|
27
|
-
if (params.has(key)) {
|
|
28
|
-
return true;
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
return false;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
// Helper function to check if all required success params are present
|
|
35
|
-
function hasSomeSuccessParams(params: URLSearchParams, successParams: string[]): boolean {
|
|
36
|
-
return successParams.some((key) => params.has(key));
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
function searchParamsToRecord(params: URLSearchParams): ResolvedParams {
|
|
40
|
-
const result: ResolvedParams = {};
|
|
41
|
-
params.forEach((value, key) => {
|
|
42
|
-
result[key] = value;
|
|
43
|
-
});
|
|
44
|
-
return result;
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
/**
|
|
48
|
-
* Initializes the Iframe Manager effect.
|
|
49
|
-
* @returns An object containing the API for managing iframe requests.
|
|
50
|
-
*/
|
|
51
|
-
export function iFrameManager() {
|
|
52
|
-
/**
|
|
53
|
-
* Creates a hidden iframe to navigate to the specified URL,
|
|
54
|
-
* waits for a redirect back to the application's origin,
|
|
55
|
-
* and resolves/rejects based on the query parameters found in the redirect URL.
|
|
56
|
-
* IMPORTANT: This relies on the final redirect target being on the SAME ORIGIN
|
|
57
|
-
* as the parent window due to browser security restrictions (Same-Origin Policy).
|
|
58
|
-
* Accessing contentWindow.location of a cross-origin iframe will fail.
|
|
59
|
-
*
|
|
60
|
-
* @param options - The options for the iframe request (URL, timeout, success/error params).
|
|
61
|
-
* @returns A Promise that resolves with the parsed query parameters on success or
|
|
62
|
-
* when error params are present; rejects on timeout or if unable to access iframe content.
|
|
63
|
-
*/
|
|
64
|
-
return {
|
|
65
|
-
getParamsByRedirect: (options: GetParamsFromIFrameOptions): Promise<ResolvedParams> => {
|
|
66
|
-
const { url, timeout, successParams, errorParams } = options;
|
|
67
|
-
|
|
68
|
-
if (
|
|
69
|
-
!successParams ||
|
|
70
|
-
!errorParams ||
|
|
71
|
-
successParams.length === 0 ||
|
|
72
|
-
errorParams.length === 0
|
|
73
|
-
) {
|
|
74
|
-
const error = new Error('successParams and errorParams must be provided');
|
|
75
|
-
throw error;
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
return new Promise<ResolvedParams>((resolve, reject) => {
|
|
79
|
-
let iframe: HTMLIFrameElement | null = null;
|
|
80
|
-
let timerId: ReturnType<typeof setTimeout> | null = null;
|
|
81
|
-
|
|
82
|
-
let onLoadHandler: () => void = () => {};
|
|
83
|
-
let cleanup: Noop = () => {};
|
|
84
|
-
|
|
85
|
-
cleanup = (): void => {
|
|
86
|
-
if (!iframe && !timerId) return;
|
|
87
|
-
|
|
88
|
-
if (timerId) {
|
|
89
|
-
clearTimeout(timerId);
|
|
90
|
-
timerId = null;
|
|
91
|
-
}
|
|
92
|
-
if (iframe) {
|
|
93
|
-
iframe.removeEventListener('load', onLoadHandler);
|
|
94
|
-
if (iframe.parentNode) {
|
|
95
|
-
iframe.remove();
|
|
96
|
-
}
|
|
97
|
-
iframe = null;
|
|
98
|
-
}
|
|
99
|
-
onLoadHandler = () => {};
|
|
100
|
-
cleanup = () => {};
|
|
101
|
-
};
|
|
102
|
-
|
|
103
|
-
onLoadHandler = (): void => {
|
|
104
|
-
try {
|
|
105
|
-
if (iframe && iframe.contentWindow) {
|
|
106
|
-
const currentIframeHref = iframe.contentWindow.location.href;
|
|
107
|
-
|
|
108
|
-
if (currentIframeHref === 'about:blank' || !currentIframeHref) {
|
|
109
|
-
return; // Wait for actual navigation
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
const redirectUrl = new URL(currentIframeHref);
|
|
113
|
-
const searchParams = redirectUrl.searchParams;
|
|
114
|
-
const parsedParams = searchParamsToRecord(searchParams);
|
|
115
|
-
|
|
116
|
-
// 1. Check for Error Parameters
|
|
117
|
-
if (hasErrorParams(searchParams, errorParams)) {
|
|
118
|
-
cleanup();
|
|
119
|
-
resolve(parsedParams); // Resolve with all parsed params for context
|
|
120
|
-
return;
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
// 2. Check for Success Parameters
|
|
124
|
-
if (hasSomeSuccessParams(searchParams, successParams)) {
|
|
125
|
-
cleanup();
|
|
126
|
-
resolve(parsedParams); // Resolve with all parsed params
|
|
127
|
-
return;
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
/*
|
|
131
|
-
* 3. Neither Error nor Success: Intermediate Redirect?
|
|
132
|
-
* If neither error nor all required success params are found,
|
|
133
|
-
* assume it's an intermediate step in the redirect flow.
|
|
134
|
-
* Do nothing, let the timeout eventually handle non-resolving states
|
|
135
|
-
* or wait for the next 'load' event.
|
|
136
|
-
*/
|
|
137
|
-
}
|
|
138
|
-
} catch {
|
|
139
|
-
// This likely means a cross-origin navigation occurred where access is denied.
|
|
140
|
-
cleanup();
|
|
141
|
-
reject({
|
|
142
|
-
type: 'internal_error',
|
|
143
|
-
message: 'unexpected failure',
|
|
144
|
-
});
|
|
145
|
-
}
|
|
146
|
-
};
|
|
147
|
-
|
|
148
|
-
try {
|
|
149
|
-
iframe = document.createElement('iframe');
|
|
150
|
-
iframe.style.display = 'none'; // Hide the iframe
|
|
151
|
-
iframe.addEventListener('load', onLoadHandler);
|
|
152
|
-
document.body.appendChild(iframe);
|
|
153
|
-
|
|
154
|
-
timerId = setTimeout(() => {
|
|
155
|
-
cleanup();
|
|
156
|
-
reject({
|
|
157
|
-
type: 'internal_error',
|
|
158
|
-
message: 'iframe timed out',
|
|
159
|
-
});
|
|
160
|
-
}, timeout);
|
|
161
|
-
|
|
162
|
-
iframe.src = url;
|
|
163
|
-
} catch {
|
|
164
|
-
cleanup(); // Attempt cleanup even if setup failed partially
|
|
165
|
-
reject({
|
|
166
|
-
type: 'internal_error',
|
|
167
|
-
message: 'error setting up iframe',
|
|
168
|
-
});
|
|
169
|
-
}
|
|
170
|
-
});
|
|
171
|
-
},
|
|
172
|
-
};
|
|
173
|
-
}
|
package/tsconfig.json
DELETED
package/tsconfig.lib.json
DELETED
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"extends": "../../../tsconfig.base.json",
|
|
3
|
-
"compilerOptions": {
|
|
4
|
-
"baseUrl": ".",
|
|
5
|
-
"outDir": "dist",
|
|
6
|
-
"tsBuildInfoFile": "dist/tsconfig.lib.tsbuildinfo",
|
|
7
|
-
"emitDeclarationOnly": false,
|
|
8
|
-
"module": "nodenext",
|
|
9
|
-
"moduleResolution": "nodenext",
|
|
10
|
-
"forceConsistentCasingInFileNames": true,
|
|
11
|
-
"strict": true,
|
|
12
|
-
"importHelpers": true,
|
|
13
|
-
"noImplicitOverride": true,
|
|
14
|
-
"noImplicitReturns": true,
|
|
15
|
-
"noFallthroughCasesInSwitch": true,
|
|
16
|
-
"types": ["node"]
|
|
17
|
-
},
|
|
18
|
-
"include": ["src/**/*.ts"],
|
|
19
|
-
"references": [],
|
|
20
|
-
"exclude": [
|
|
21
|
-
"vite.config.ts",
|
|
22
|
-
"vite.config.mts",
|
|
23
|
-
"vitest.config.ts",
|
|
24
|
-
"vitest.config.mts",
|
|
25
|
-
"src/**/*.test.ts",
|
|
26
|
-
"src/**/*.spec.ts",
|
|
27
|
-
"src/**/*.test.tsx",
|
|
28
|
-
"src/**/*.spec.tsx",
|
|
29
|
-
"src/**/*.test.js",
|
|
30
|
-
"src/**/*.spec.js",
|
|
31
|
-
"src/**/*.test.jsx",
|
|
32
|
-
"src/**/*.spec.jsx"
|
|
33
|
-
]
|
|
34
|
-
}
|
package/tsconfig.spec.json
DELETED
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"extends": "../../../tsconfig.base.json",
|
|
3
|
-
"compilerOptions": {
|
|
4
|
-
"outDir": "./out-tsc/vitest",
|
|
5
|
-
"types": [
|
|
6
|
-
"vitest/globals",
|
|
7
|
-
"vitest/importMeta",
|
|
8
|
-
"vite/client",
|
|
9
|
-
"node",
|
|
10
|
-
"vitest"
|
|
11
|
-
],
|
|
12
|
-
"module": "nodenext",
|
|
13
|
-
"moduleResolution": "nodenext",
|
|
14
|
-
"forceConsistentCasingInFileNames": true,
|
|
15
|
-
"strict": true,
|
|
16
|
-
"importHelpers": true,
|
|
17
|
-
"noImplicitOverride": true,
|
|
18
|
-
"noImplicitReturns": true,
|
|
19
|
-
"noFallthroughCasesInSwitch": true
|
|
20
|
-
},
|
|
21
|
-
"include": [
|
|
22
|
-
"vite.config.ts",
|
|
23
|
-
"vite.config.mts",
|
|
24
|
-
"vitest.config.ts",
|
|
25
|
-
"vitest.config.mts",
|
|
26
|
-
"src/**/*.test.ts",
|
|
27
|
-
"src/**/*.spec.ts",
|
|
28
|
-
"src/**/*.test.tsx",
|
|
29
|
-
"src/**/*.spec.tsx",
|
|
30
|
-
"src/**/*.test.js",
|
|
31
|
-
"src/**/*.spec.js",
|
|
32
|
-
"src/**/*.test.jsx",
|
|
33
|
-
"src/**/*.spec.jsx",
|
|
34
|
-
"src/**/*.d.ts"
|
|
35
|
-
],
|
|
36
|
-
"references": [
|
|
37
|
-
{
|
|
38
|
-
"path": "./tsconfig.lib.json"
|
|
39
|
-
}
|
|
40
|
-
]
|
|
41
|
-
}
|
package/typedoc.json
DELETED
package/vite.config.ts
DELETED
|
Binary file
|