dh-auth-library 1.3.0 → 1.5.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/auth/getLoginHandler.d.ts +7 -1
- package/dist/auth/getSessionHandler.d.ts +7 -1
- package/dist/auth/loginHandler.d.ts +7 -0
- package/dist/auth/loginhandlers/adLoginHandler.d.ts +11 -0
- package/dist/auth/loginhandlers/digidGemachtigdeLoginHandler.d.ts +5 -0
- package/dist/auth/loginhandlers/digidLoginHandler.d.ts +5 -0
- package/dist/auth/loginhandlers/eHerkenningBewindvoerderLoginHandler.d.ts +5 -0
- package/dist/auth/loginhandlers/eHerkenningLoginHandler.d.ts +5 -0
- package/dist/auth/loginhandlers/localhostLoginHandler.d.ts +5 -0
- package/dist/auth/pages/adLoginPage.d.ts +30 -3
- package/dist/auth/pages/digidLoginPage.d.ts +12 -0
- package/dist/auth/pages/eHerkenningLoginPage.d.ts +21 -0
- package/dist/auth/sessionHandler.d.ts +1 -1
- package/dist/auth/utils/sessionFileHelper.d.ts +32 -0
- package/dist/index.cjs.js +154 -10
- package/dist/index.es.js +154 -10
- package/package.json +3 -3
|
@@ -1,3 +1,9 @@
|
|
|
1
1
|
import { AuthType } from '../constants/authTypes';
|
|
2
2
|
import { LoginHandler } from './loginHandler';
|
|
3
|
-
|
|
3
|
+
/**
|
|
4
|
+
* @param authType type of login
|
|
5
|
+
* @param adTargetUrl URL to navigate to before logging in for the `ad-session` auth type (the
|
|
6
|
+
* app behind the firewall), supplied by the consumer of this library. Required when
|
|
7
|
+
* `authType` is `'ad-session'`, ignored otherwise.
|
|
8
|
+
*/
|
|
9
|
+
export declare function getLoginHandler(authType: AuthType, adTargetUrl?: string): LoginHandler;
|
|
@@ -1,2 +1,8 @@
|
|
|
1
1
|
import { TestProfile } from '../constants';
|
|
2
|
-
|
|
2
|
+
/**
|
|
3
|
+
* @param testProfile
|
|
4
|
+
* @param adTargetUrl URL to navigate to before logging in when `testProfile.authType` is
|
|
5
|
+
* `'ad-session'` (the app behind the firewall), supplied by the consumer of this library.
|
|
6
|
+
* Required in that case, ignored otherwise.
|
|
7
|
+
*/
|
|
8
|
+
export declare function getSessionHandler(testProfile: TestProfile, adTargetUrl?: string): import("nl-portal-playwright-libraries").SessionHandler;
|
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
import { Page } from '@playwright/test';
|
|
2
2
|
import { Account } from 'nl-portal-playwright-libraries';
|
|
3
3
|
export interface LoginHandler {
|
|
4
|
+
/**
|
|
5
|
+
* Log in and persist the resulting session to a storage state file.
|
|
6
|
+
*
|
|
7
|
+
* @param page the Playwright page to perform the login on
|
|
8
|
+
* @param account login details, supplied by the consumer of this library
|
|
9
|
+
* @param file path of the storage state file to write the session to
|
|
10
|
+
*/
|
|
4
11
|
loginAndCreateSessionStorage(page: Page, account: Account, file: string): Promise<void>;
|
|
5
12
|
}
|
|
@@ -2,5 +2,16 @@ import { Page } from '@playwright/test';
|
|
|
2
2
|
import { Account } from 'nl-portal-playwright-libraries';
|
|
3
3
|
import { LoginHandler } from '../loginHandler';
|
|
4
4
|
export declare class ADLoginHandler implements LoginHandler {
|
|
5
|
+
private readonly targetUrl;
|
|
6
|
+
/**
|
|
7
|
+
* @param targetUrl URL to navigate to before logging in (the app behind the firewall),
|
|
8
|
+
* supplied by the consumer of this library
|
|
9
|
+
*/
|
|
10
|
+
constructor(targetUrl: string);
|
|
11
|
+
/**
|
|
12
|
+
* @param page the Playwright page to perform the login on
|
|
13
|
+
* @param account login details, supplied by the consumer of this library
|
|
14
|
+
* @param file path of the storage state file to write the session to
|
|
15
|
+
*/
|
|
5
16
|
loginAndCreateSessionStorage(page: Page, account: Account, file: string): Promise<void>;
|
|
6
17
|
}
|
|
@@ -2,5 +2,10 @@ import { Page } from '@playwright/test';
|
|
|
2
2
|
import { Account } from 'nl-portal-playwright-libraries';
|
|
3
3
|
import { LoginHandler } from '../loginHandler';
|
|
4
4
|
export declare class DigidGemachtigdeLoginHandler implements LoginHandler {
|
|
5
|
+
/**
|
|
6
|
+
* @param page the Playwright page to perform the login on
|
|
7
|
+
* @param account login details, supplied by the consumer of this library
|
|
8
|
+
* @param file path of the storage state file to write the session to
|
|
9
|
+
*/
|
|
5
10
|
loginAndCreateSessionStorage(page: Page, account: Account, file: string): Promise<void>;
|
|
6
11
|
}
|
|
@@ -2,5 +2,10 @@ import { Page } from '@playwright/test';
|
|
|
2
2
|
import { Account } from 'nl-portal-playwright-libraries';
|
|
3
3
|
import { LoginHandler } from '../loginHandler';
|
|
4
4
|
export declare class DigidLoginHandler implements LoginHandler {
|
|
5
|
+
/**
|
|
6
|
+
* @param page the Playwright page to perform the login on
|
|
7
|
+
* @param account login details, supplied by the consumer of this library
|
|
8
|
+
* @param file path of the storage state file to write the session to
|
|
9
|
+
*/
|
|
5
10
|
loginAndCreateSessionStorage(page: Page, account: Account, file: string): Promise<void>;
|
|
6
11
|
}
|
|
@@ -2,5 +2,10 @@ import { Page } from '@playwright/test';
|
|
|
2
2
|
import { Account } from 'nl-portal-playwright-libraries';
|
|
3
3
|
import { LoginHandler } from '../loginHandler';
|
|
4
4
|
export declare class EHerkenningBewindvoerderLoginHandler implements LoginHandler {
|
|
5
|
+
/**
|
|
6
|
+
* @param page the Playwright page to perform the login on
|
|
7
|
+
* @param account login details, supplied by the consumer of this library
|
|
8
|
+
* @param file path of the storage state file to write the session to
|
|
9
|
+
*/
|
|
5
10
|
loginAndCreateSessionStorage(page: Page, account: Account, file: string): Promise<void>;
|
|
6
11
|
}
|
|
@@ -2,5 +2,10 @@ import { Page } from '@playwright/test';
|
|
|
2
2
|
import { Account } from 'nl-portal-playwright-libraries';
|
|
3
3
|
import { LoginHandler } from '../loginHandler';
|
|
4
4
|
export declare class EHerkenningLoginHandler implements LoginHandler {
|
|
5
|
+
/**
|
|
6
|
+
* @param page the Playwright page to perform the login on
|
|
7
|
+
* @param account login details, supplied by the consumer of this library
|
|
8
|
+
* @param file path of the storage state file to write the session to
|
|
9
|
+
*/
|
|
5
10
|
loginAndCreateSessionStorage(page: Page, account: Account, file: string): Promise<void>;
|
|
6
11
|
}
|
|
@@ -2,5 +2,10 @@ import { Page } from '@playwright/test';
|
|
|
2
2
|
import { Account } from 'nl-portal-playwright-libraries';
|
|
3
3
|
import { LoginHandler } from '../loginHandler';
|
|
4
4
|
export declare class LocalhostLoginHandler implements LoginHandler {
|
|
5
|
+
/**
|
|
6
|
+
* @param page the Playwright page to perform the login on
|
|
7
|
+
* @param account login details, supplied by the consumer of this library
|
|
8
|
+
* @param file path of the storage state file to write the session to
|
|
9
|
+
*/
|
|
5
10
|
loginAndCreateSessionStorage(page: Page, account: Account, file: string): Promise<void>;
|
|
6
11
|
}
|
|
@@ -14,10 +14,37 @@ export declare class ADLoginPage extends BasePage {
|
|
|
14
14
|
/**
|
|
15
15
|
* Login with the AD account so we can get behind the firewall
|
|
16
16
|
*
|
|
17
|
-
* @param account
|
|
18
|
-
* @param
|
|
17
|
+
* @param account login details, supplied by the consumer of this library
|
|
18
|
+
* @param targetUrl URL to navigate to before logging in (the app behind the firewall),
|
|
19
|
+
* supplied by the consumer of this library — not every consumer has a GZAC account, so
|
|
20
|
+
* this library no longer assumes GZAC as the destination. The consumer is responsible
|
|
21
|
+
* for switching between environments (e.g. test/acc/prod) when building this URL; this
|
|
22
|
+
* library does not do that for you.
|
|
23
|
+
* @param fileName path of the storage state file to write the session to
|
|
24
|
+
*
|
|
25
|
+
* @example
|
|
26
|
+
* // consumer-side lookup, e.g. based on an `ENV` environment variable
|
|
27
|
+
* export const TARGET_URL_BY_ENVIRONMENT = {
|
|
28
|
+
* test: 'https://alg-zgw.test.denhaag.nl/',
|
|
29
|
+
* acc: 'https://alg-zgw.acc.denhaag.nl/',
|
|
30
|
+
* prod: 'https://alg-zgw.denhaag.nl/',
|
|
31
|
+
* } as const;
|
|
32
|
+
*
|
|
33
|
+
* const env = (process.env.ENV ?? 'test') as keyof typeof TARGET_URL_BY_ENVIRONMENT;
|
|
34
|
+
* await adLoginPage.loginWithADAccountAndCreateSession(account, TARGET_URL_BY_ENVIRONMENT[env], fileName);
|
|
19
35
|
*/
|
|
20
|
-
loginWithADAccountAndCreateSession(account: Account, fileName: string): Promise<void>;
|
|
36
|
+
loginWithADAccountAndCreateSession(account: Account, targetUrl: string, fileName: string): Promise<void>;
|
|
21
37
|
tryAgainUntilSuccesful(): Promise<void>;
|
|
38
|
+
/**
|
|
39
|
+
* Determines the GZAC URL to log in against, based on the current environment.
|
|
40
|
+
*
|
|
41
|
+
* @deprecated GZAC-specific and no longer called internally by this library — pass your own
|
|
42
|
+
* target URL to {@link loginWithADAccountAndCreateSession} instead. Kept only so existing
|
|
43
|
+
* GZAC consumers can still derive this URL themselves during migration; will be removed in
|
|
44
|
+
* a future version.
|
|
45
|
+
*
|
|
46
|
+
* Derives the environment from `this.getBaseUrl()` (inherited from `BasePage`), which reads
|
|
47
|
+
* the `PORTAL_BASE_URL` environment variable.
|
|
48
|
+
*/
|
|
22
49
|
getGzacUrl(): string;
|
|
23
50
|
}
|
|
@@ -3,13 +3,25 @@ import { LoginOverzichtPage } from './loginOverzichtPage';
|
|
|
3
3
|
import { Account } from 'nl-portal-playwright-libraries';
|
|
4
4
|
export declare class DigidLoginPage extends LoginOverzichtPage {
|
|
5
5
|
constructor(page: Page);
|
|
6
|
+
/**
|
|
7
|
+
* @param account login details, supplied by the consumer of this library
|
|
8
|
+
* @param fileName path of the storage state file to write the session to
|
|
9
|
+
*/
|
|
6
10
|
loginAndCreateNewSession(account: Account, fileName: string): Promise<void>;
|
|
11
|
+
/**
|
|
12
|
+
* @param account login details, supplied by the consumer of this library
|
|
13
|
+
* @param fileName path of the storage state file to write the session to
|
|
14
|
+
*/
|
|
7
15
|
loginAndCreateNewGemachtigdeSession(account: Account, fileName: string): Promise<void>;
|
|
8
16
|
/**
|
|
9
17
|
* Indien er al een AD sessie is maar voor de verkeerde omgeving
|
|
10
18
|
* Je krijgt dan een speciaal scherm waar je moet bevestigen voordat je door kan
|
|
11
19
|
*/
|
|
12
20
|
handleAnySpecialADLoginScreen(): Promise<void>;
|
|
21
|
+
/**
|
|
22
|
+
* @param account login details, supplied by the consumer of this library
|
|
23
|
+
* @param gemachtigde whether to log in as an authorized representative (machtiging) instead of a regular user
|
|
24
|
+
*/
|
|
13
25
|
loginWithDigid(account: Account, gemachtigde?: boolean): Promise<import("@playwright/test").Response>;
|
|
14
26
|
loginAlsDigidGemachtigde(): Promise<void>;
|
|
15
27
|
}
|
|
@@ -12,10 +12,31 @@ export declare class EHerkenningLoginPage extends LoginOverzichtPage {
|
|
|
12
12
|
private readonly inputBsn;
|
|
13
13
|
private readonly buttonZoek;
|
|
14
14
|
constructor(page: Page);
|
|
15
|
+
/**
|
|
16
|
+
* @param account login details, supplied by the consumer of this library
|
|
17
|
+
*/
|
|
15
18
|
probeerInTeLoggenMetEHerkenning(account: Account): Promise<void>;
|
|
19
|
+
/**
|
|
20
|
+
* @param fileName path of the storage state file to write the session to
|
|
21
|
+
* @param account login details, supplied by the consumer of this library
|
|
22
|
+
*/
|
|
16
23
|
loginWithEHerkenningAndCreateSession(fileName: string, account: Account): Promise<void>;
|
|
24
|
+
/**
|
|
25
|
+
* @param account login details, supplied by the consumer of this library
|
|
26
|
+
*/
|
|
17
27
|
loginWithEHerkenning(account: Account): Promise<void>;
|
|
28
|
+
/**
|
|
29
|
+
* @param fileName path of the storage state file to write the session to
|
|
30
|
+
* @param account login details, supplied by the consumer of this library
|
|
31
|
+
*/
|
|
18
32
|
loginWithEHerkenningVestigingAndCreateSession(fileName: string, account: Account): Promise<void>;
|
|
33
|
+
/**
|
|
34
|
+
* @param account login details, supplied by the consumer of this library
|
|
35
|
+
*/
|
|
19
36
|
loginWithEHerkenningVestiging(account: Account): Promise<void>;
|
|
37
|
+
/**
|
|
38
|
+
* @param gemachtigde login details of the authorized representative (bewindvoerder), supplied by the consumer of this library
|
|
39
|
+
* @param file optional path of the storage state file to write the session to
|
|
40
|
+
*/
|
|
20
41
|
loginAlsProfessioneelBewindvoerder(gemachtigde: Account, file?: string): Promise<void>;
|
|
21
42
|
}
|
|
@@ -7,7 +7,7 @@ export declare const MAX_SESSION_TIME_IN_MINUTES = 10;
|
|
|
7
7
|
* It will also perform the process of setting op the session
|
|
8
8
|
*
|
|
9
9
|
* @param authType type of login
|
|
10
|
-
* @param account
|
|
10
|
+
* @param account login details, supplied by the consumer of this library
|
|
11
11
|
* @param loginHandler that will handle the login itself
|
|
12
12
|
*/
|
|
13
13
|
export declare function createSessionHandler(authType: AuthType, account: Account, loginHandler: LoginHandler): SessionHandler;
|
|
@@ -4,12 +4,44 @@ import { Account } from 'nl-portal-playwright-libraries';
|
|
|
4
4
|
* Easy way to create the filenames for the sessions
|
|
5
5
|
*/
|
|
6
6
|
export declare class SessionFileHelper {
|
|
7
|
+
/**
|
|
8
|
+
* @param browser the browser instance the session file name is based on
|
|
9
|
+
* @param account login details, supplied by the consumer of this library; only `username` is used
|
|
10
|
+
*/
|
|
7
11
|
static getLocalhostFileName(browser: Browser, account: Account): string;
|
|
12
|
+
/**
|
|
13
|
+
* @param browser the browser instance the session file name is based on
|
|
14
|
+
* @param account login details, supplied by the consumer of this library; only `username` is used
|
|
15
|
+
*/
|
|
8
16
|
static getLocalhostFileNameBedrijf(browser: Browser, account: Account): string;
|
|
17
|
+
/**
|
|
18
|
+
* @param browser the browser instance the session file name is based on
|
|
19
|
+
* @param account login details, supplied by the consumer of this library; only `username` is used
|
|
20
|
+
*/
|
|
9
21
|
static getDigidFileName(browser: Browser, account: Account): string;
|
|
22
|
+
/**
|
|
23
|
+
* @param browser the browser instance the session file name is based on
|
|
24
|
+
* @param account login details, supplied by the consumer of this library; only `username` is used
|
|
25
|
+
*/
|
|
10
26
|
static getDigidGemachtigdeFileName(browser: Browser, account: Account): string;
|
|
27
|
+
/**
|
|
28
|
+
* @param browser the browser instance the session file name is based on
|
|
29
|
+
* @param account login details, supplied by the consumer of this library; only `username` is used
|
|
30
|
+
*/
|
|
11
31
|
static getEHerkenningFileName(browser: Browser, account: Account): string;
|
|
32
|
+
/**
|
|
33
|
+
* @param browser the browser instance the session file name is based on
|
|
34
|
+
* @param account login details, supplied by the consumer of this library; only `username` is used
|
|
35
|
+
*/
|
|
12
36
|
static getEHerkenningVestigingFileName(browser: Browser, account: Account): string;
|
|
37
|
+
/**
|
|
38
|
+
* @param browser the browser instance the session file name is based on
|
|
39
|
+
* @param account login details, supplied by the consumer of this library; only `username` is used
|
|
40
|
+
*/
|
|
13
41
|
static getEHerkenningBewindvoerderFileName(browser: Browser, account: Account): string;
|
|
42
|
+
/**
|
|
43
|
+
* @param browser the browser instance the session file name is based on
|
|
44
|
+
* @param account login details, supplied by the consumer of this library; only `username` is used
|
|
45
|
+
*/
|
|
14
46
|
static getADFileName(browser: Browser, account: Account): string;
|
|
15
47
|
}
|
package/dist/index.cjs.js
CHANGED
|
@@ -30,6 +30,11 @@ let node_path = require("node:path");
|
|
|
30
30
|
node_path = __toESM(node_path);
|
|
31
31
|
//#region src/auth/loginhandlers/localhostLoginHandler.ts
|
|
32
32
|
var LocalhostLoginHandler = class {
|
|
33
|
+
/**
|
|
34
|
+
* @param page the Playwright page to perform the login on
|
|
35
|
+
* @param account login details, supplied by the consumer of this library
|
|
36
|
+
* @param file path of the storage state file to write the session to
|
|
37
|
+
*/
|
|
33
38
|
async loginAndCreateSessionStorage(page, account, file) {
|
|
34
39
|
await new nl_portal_playwright_libraries.LocalLoginPage(page).loginAndCreateNewSession(account, file);
|
|
35
40
|
}
|
|
@@ -102,6 +107,10 @@ var DigidLoginPage = class extends LoginOverzichtPage {
|
|
|
102
107
|
constructor(page) {
|
|
103
108
|
super(page);
|
|
104
109
|
}
|
|
110
|
+
/**
|
|
111
|
+
* @param account login details, supplied by the consumer of this library
|
|
112
|
+
* @param fileName path of the storage state file to write the session to
|
|
113
|
+
*/
|
|
105
114
|
async loginAndCreateNewSession(account, fileName) {
|
|
106
115
|
await this.openPage();
|
|
107
116
|
await this.handleAnySpecialADLoginScreen();
|
|
@@ -118,6 +127,10 @@ var DigidLoginPage = class extends LoginOverzichtPage {
|
|
|
118
127
|
}
|
|
119
128
|
await this.page.context().storageState({ path: fileName });
|
|
120
129
|
}
|
|
130
|
+
/**
|
|
131
|
+
* @param account login details, supplied by the consumer of this library
|
|
132
|
+
* @param fileName path of the storage state file to write the session to
|
|
133
|
+
*/
|
|
121
134
|
async loginAndCreateNewGemachtigdeSession(account, fileName) {
|
|
122
135
|
await this.openPage();
|
|
123
136
|
await this.handleAnySpecialADLoginScreen();
|
|
@@ -141,6 +154,10 @@ var DigidLoginPage = class extends LoginOverzichtPage {
|
|
|
141
154
|
await this.page.locator(`//div[contains(@data-test-id,'${node_process.default.env.AD_USER}')]`).first().click();
|
|
142
155
|
} catch (_error) {}
|
|
143
156
|
}
|
|
157
|
+
/**
|
|
158
|
+
* @param account login details, supplied by the consumer of this library
|
|
159
|
+
* @param gemachtigde whether to log in as an authorized representative (machtiging) instead of a regular user
|
|
160
|
+
*/
|
|
144
161
|
async loginWithDigid(account, gemachtigde) {
|
|
145
162
|
await this.page.getByLabel("Inlogoptie 5 van 5: Inloggen").click();
|
|
146
163
|
await this.page.getByLabel("Testen betrouwbaarheidsniveau").selectOption("25");
|
|
@@ -163,6 +180,11 @@ var DigidLoginPage = class extends LoginOverzichtPage {
|
|
|
163
180
|
//#endregion
|
|
164
181
|
//#region src/auth/loginhandlers/digidLoginHandler.ts
|
|
165
182
|
var DigidLoginHandler = class {
|
|
183
|
+
/**
|
|
184
|
+
* @param page the Playwright page to perform the login on
|
|
185
|
+
* @param account login details, supplied by the consumer of this library
|
|
186
|
+
* @param file path of the storage state file to write the session to
|
|
187
|
+
*/
|
|
166
188
|
async loginAndCreateSessionStorage(page, account, file) {
|
|
167
189
|
await new DigidLoginPage(page).loginAndCreateNewSession(account, file);
|
|
168
190
|
}
|
|
@@ -191,6 +213,9 @@ var EHerkenningLoginPage = class extends LoginOverzichtPage {
|
|
|
191
213
|
this.buttonZoek = page.locator("#search-submit");
|
|
192
214
|
this.verderLink = page.getByRole("link", { name: /Verder|Continue|Ga verder/ });
|
|
193
215
|
}
|
|
216
|
+
/**
|
|
217
|
+
* @param account login details, supplied by the consumer of this library
|
|
218
|
+
*/
|
|
194
219
|
async probeerInTeLoggenMetEHerkenning(account) {
|
|
195
220
|
await this.dropdownSelectIdentityProvider.selectOption("Digidentity AD 1.13 (preproduction)");
|
|
196
221
|
await this.page.locator("#remember").click();
|
|
@@ -200,6 +225,10 @@ var EHerkenningLoginPage = class extends LoginOverzichtPage {
|
|
|
200
225
|
await this.textfieldPassword.fill(account.password);
|
|
201
226
|
await this.inloggenKnop.click();
|
|
202
227
|
}
|
|
228
|
+
/**
|
|
229
|
+
* @param fileName path of the storage state file to write the session to
|
|
230
|
+
* @param account login details, supplied by the consumer of this library
|
|
231
|
+
*/
|
|
203
232
|
async loginWithEHerkenningAndCreateSession(fileName, account) {
|
|
204
233
|
await this.openPage();
|
|
205
234
|
try {
|
|
@@ -211,12 +240,19 @@ var EHerkenningLoginPage = class extends LoginOverzichtPage {
|
|
|
211
240
|
await this.loginWithEHerkenning(account);
|
|
212
241
|
await this.page.context().storageState({ path: fileName });
|
|
213
242
|
}
|
|
243
|
+
/**
|
|
244
|
+
* @param account login details, supplied by the consumer of this library
|
|
245
|
+
*/
|
|
214
246
|
async loginWithEHerkenning(account) {
|
|
215
247
|
await this.probeerInTeLoggenMetEHerkenning(account);
|
|
216
248
|
await this.page.waitForTimeout(2e3);
|
|
217
249
|
if (await this.verderKnop.isVisible()) await this.verderKnop.click();
|
|
218
250
|
await this.accepteerCookies();
|
|
219
251
|
}
|
|
252
|
+
/**
|
|
253
|
+
* @param fileName path of the storage state file to write the session to
|
|
254
|
+
* @param account login details, supplied by the consumer of this library
|
|
255
|
+
*/
|
|
220
256
|
async loginWithEHerkenningVestigingAndCreateSession(fileName, account) {
|
|
221
257
|
await this.openPage();
|
|
222
258
|
try {
|
|
@@ -228,12 +264,19 @@ var EHerkenningLoginPage = class extends LoginOverzichtPage {
|
|
|
228
264
|
await this.loginWithEHerkenningVestiging(account);
|
|
229
265
|
await this.page.context().storageState({ path: fileName });
|
|
230
266
|
}
|
|
267
|
+
/**
|
|
268
|
+
* @param account login details, supplied by the consumer of this library
|
|
269
|
+
*/
|
|
231
270
|
async loginWithEHerkenningVestiging(account) {
|
|
232
271
|
await this.probeerInTeLoggenMetEHerkenning(account);
|
|
233
272
|
await this.page.waitForTimeout(2e3);
|
|
234
273
|
if (await this.verderKnop.isVisible()) await this.verderKnop.click();
|
|
235
274
|
await this.accepteerCookies();
|
|
236
275
|
}
|
|
276
|
+
/**
|
|
277
|
+
* @param gemachtigde login details of the authorized representative (bewindvoerder), supplied by the consumer of this library
|
|
278
|
+
* @param file optional path of the storage state file to write the session to
|
|
279
|
+
*/
|
|
237
280
|
async loginAlsProfessioneelBewindvoerder(gemachtigde, file) {
|
|
238
281
|
await this.openPage();
|
|
239
282
|
await this.klikOpProfessioneelBewindvoerderLoginOptie();
|
|
@@ -256,6 +299,11 @@ var EHerkenningLoginPage = class extends LoginOverzichtPage {
|
|
|
256
299
|
//#endregion
|
|
257
300
|
//#region src/auth/loginhandlers/eHerkenningLoginHandler.ts
|
|
258
301
|
var EHerkenningLoginHandler = class {
|
|
302
|
+
/**
|
|
303
|
+
* @param page the Playwright page to perform the login on
|
|
304
|
+
* @param account login details, supplied by the consumer of this library
|
|
305
|
+
* @param file path of the storage state file to write the session to
|
|
306
|
+
*/
|
|
259
307
|
async loginAndCreateSessionStorage(page, account, file) {
|
|
260
308
|
await new EHerkenningLoginPage(page).loginWithEHerkenningVestigingAndCreateSession(file, account);
|
|
261
309
|
}
|
|
@@ -263,6 +311,11 @@ var EHerkenningLoginHandler = class {
|
|
|
263
311
|
//#endregion
|
|
264
312
|
//#region src/auth/loginhandlers/digidGemachtigdeLoginHandler.ts
|
|
265
313
|
var DigidGemachtigdeLoginHandler = class {
|
|
314
|
+
/**
|
|
315
|
+
* @param page the Playwright page to perform the login on
|
|
316
|
+
* @param account login details, supplied by the consumer of this library
|
|
317
|
+
* @param file path of the storage state file to write the session to
|
|
318
|
+
*/
|
|
266
319
|
async loginAndCreateSessionStorage(page, account, file) {
|
|
267
320
|
await new DigidLoginPage(page).loginAndCreateNewGemachtigdeSession(account, file);
|
|
268
321
|
}
|
|
@@ -270,6 +323,11 @@ var DigidGemachtigdeLoginHandler = class {
|
|
|
270
323
|
//#endregion
|
|
271
324
|
//#region src/auth/loginhandlers/eHerkenningBewindvoerderLoginHandler.ts
|
|
272
325
|
var EHerkenningBewindvoerderLoginHandler = class {
|
|
326
|
+
/**
|
|
327
|
+
* @param page the Playwright page to perform the login on
|
|
328
|
+
* @param account login details, supplied by the consumer of this library
|
|
329
|
+
* @param file path of the storage state file to write the session to
|
|
330
|
+
*/
|
|
273
331
|
async loginAndCreateSessionStorage(page, account, file) {
|
|
274
332
|
await new EHerkenningLoginPage(page).loginAlsProfessioneelBewindvoerder(account, file);
|
|
275
333
|
}
|
|
@@ -305,12 +363,28 @@ var ADLoginPage = class ADLoginPage extends nl_portal_playwright_libraries.BaseP
|
|
|
305
363
|
/**
|
|
306
364
|
* Login with the AD account so we can get behind the firewall
|
|
307
365
|
*
|
|
308
|
-
* @param account
|
|
309
|
-
* @param
|
|
366
|
+
* @param account login details, supplied by the consumer of this library
|
|
367
|
+
* @param targetUrl URL to navigate to before logging in (the app behind the firewall),
|
|
368
|
+
* supplied by the consumer of this library — not every consumer has a GZAC account, so
|
|
369
|
+
* this library no longer assumes GZAC as the destination. The consumer is responsible
|
|
370
|
+
* for switching between environments (e.g. test/acc/prod) when building this URL; this
|
|
371
|
+
* library does not do that for you.
|
|
372
|
+
* @param fileName path of the storage state file to write the session to
|
|
373
|
+
*
|
|
374
|
+
* @example
|
|
375
|
+
* // consumer-side lookup, e.g. based on an `ENV` environment variable
|
|
376
|
+
* export const TARGET_URL_BY_ENVIRONMENT = {
|
|
377
|
+
* test: 'https://alg-zgw.test.denhaag.nl/',
|
|
378
|
+
* acc: 'https://alg-zgw.acc.denhaag.nl/',
|
|
379
|
+
* prod: 'https://alg-zgw.denhaag.nl/',
|
|
380
|
+
* } as const;
|
|
381
|
+
*
|
|
382
|
+
* const env = (process.env.ENV ?? 'test') as keyof typeof TARGET_URL_BY_ENVIRONMENT;
|
|
383
|
+
* await adLoginPage.loginWithADAccountAndCreateSession(account, TARGET_URL_BY_ENVIRONMENT[env], fileName);
|
|
310
384
|
*/
|
|
311
|
-
async loginWithADAccountAndCreateSession(account, fileName) {
|
|
385
|
+
async loginWithADAccountAndCreateSession(account, targetUrl, fileName) {
|
|
312
386
|
const adLoginPage = new ADLoginPage(this.page);
|
|
313
|
-
await this.page.goto(
|
|
387
|
+
await this.page.goto(targetUrl);
|
|
314
388
|
await adLoginPage.gebruikersnaamInput.waitFor();
|
|
315
389
|
await adLoginPage.gebruikersnaamInput.fill(account.username);
|
|
316
390
|
await adLoginPage.volgendeInput.click();
|
|
@@ -345,6 +419,17 @@ var ADLoginPage = class ADLoginPage extends nl_portal_playwright_libraries.BaseP
|
|
|
345
419
|
} catch (_error) {}
|
|
346
420
|
}
|
|
347
421
|
}
|
|
422
|
+
/**
|
|
423
|
+
* Determines the GZAC URL to log in against, based on the current environment.
|
|
424
|
+
*
|
|
425
|
+
* @deprecated GZAC-specific and no longer called internally by this library — pass your own
|
|
426
|
+
* target URL to {@link loginWithADAccountAndCreateSession} instead. Kept only so existing
|
|
427
|
+
* GZAC consumers can still derive this URL themselves during migration; will be removed in
|
|
428
|
+
* a future version.
|
|
429
|
+
*
|
|
430
|
+
* Derives the environment from `this.getBaseUrl()` (inherited from `BasePage`), which reads
|
|
431
|
+
* the `PORTAL_BASE_URL` environment variable.
|
|
432
|
+
*/
|
|
348
433
|
getGzacUrl() {
|
|
349
434
|
const baseUrl = this.getBaseUrl();
|
|
350
435
|
if (/klantportaal-zgw.denhaag.nl./.exec(baseUrl)) return gzacUrlProd;
|
|
@@ -356,20 +441,41 @@ var ADLoginPage = class ADLoginPage extends nl_portal_playwright_libraries.BaseP
|
|
|
356
441
|
//#endregion
|
|
357
442
|
//#region src/auth/loginhandlers/adLoginHandler.ts
|
|
358
443
|
var ADLoginHandler = class {
|
|
444
|
+
targetUrl;
|
|
445
|
+
/**
|
|
446
|
+
* @param targetUrl URL to navigate to before logging in (the app behind the firewall),
|
|
447
|
+
* supplied by the consumer of this library
|
|
448
|
+
*/
|
|
449
|
+
constructor(targetUrl) {
|
|
450
|
+
this.targetUrl = targetUrl;
|
|
451
|
+
}
|
|
452
|
+
/**
|
|
453
|
+
* @param page the Playwright page to perform the login on
|
|
454
|
+
* @param account login details, supplied by the consumer of this library
|
|
455
|
+
* @param file path of the storage state file to write the session to
|
|
456
|
+
*/
|
|
359
457
|
async loginAndCreateSessionStorage(page, account, file) {
|
|
360
|
-
await new ADLoginPage(page).loginWithADAccountAndCreateSession(account, file);
|
|
458
|
+
await new ADLoginPage(page).loginWithADAccountAndCreateSession(account, this.targetUrl, file);
|
|
361
459
|
}
|
|
362
460
|
};
|
|
363
461
|
//#endregion
|
|
364
462
|
//#region src/auth/getLoginHandler.ts
|
|
365
|
-
|
|
463
|
+
/**
|
|
464
|
+
* @param authType type of login
|
|
465
|
+
* @param adTargetUrl URL to navigate to before logging in for the `ad-session` auth type (the
|
|
466
|
+
* app behind the firewall), supplied by the consumer of this library. Required when
|
|
467
|
+
* `authType` is `'ad-session'`, ignored otherwise.
|
|
468
|
+
*/
|
|
469
|
+
function getLoginHandler(authType, adTargetUrl) {
|
|
366
470
|
switch (authType) {
|
|
367
471
|
case "digid": return (0, nl_portal_playwright_libraries.isRunningOnLocalhost)() ? new LocalhostLoginHandler() : new DigidLoginHandler();
|
|
368
472
|
case "digid_gemachtigde": return new DigidGemachtigdeLoginHandler();
|
|
369
473
|
case "eherkenning": return (0, nl_portal_playwright_libraries.isRunningOnLocalhost)() ? new LocalhostLoginHandler() : new EHerkenningLoginHandler();
|
|
370
474
|
case "eherkenning_vestiging": return new EHerkenningLoginHandler();
|
|
371
475
|
case "eherkenning_bewindvoerder": return new EHerkenningBewindvoerderLoginHandler();
|
|
372
|
-
case "ad-session":
|
|
476
|
+
case "ad-session":
|
|
477
|
+
if (!adTargetUrl) throw new Error("adTargetUrl is required when authType is 'ad-session'");
|
|
478
|
+
return new ADLoginHandler(adTargetUrl);
|
|
373
479
|
default: throw new Error(`Unsupported auth type: ${authType}. If needed please create a new LoginHandler and register it here in getLoginHandler().`);
|
|
374
480
|
}
|
|
375
481
|
}
|
|
@@ -381,27 +487,59 @@ var environment = node_process.env.ENV ?? "test";
|
|
|
381
487
|
* Easy way to create the filenames for the sessions
|
|
382
488
|
*/
|
|
383
489
|
var SessionFileHelper = class {
|
|
490
|
+
/**
|
|
491
|
+
* @param browser the browser instance the session file name is based on
|
|
492
|
+
* @param account login details, supplied by the consumer of this library; only `username` is used
|
|
493
|
+
*/
|
|
384
494
|
static getLocalhostFileName(browser, account) {
|
|
385
495
|
return node_path.join(sessionsDir, `${browser.browserType().name()}-${environment}-${account.username}.json`);
|
|
386
496
|
}
|
|
497
|
+
/**
|
|
498
|
+
* @param browser the browser instance the session file name is based on
|
|
499
|
+
* @param account login details, supplied by the consumer of this library; only `username` is used
|
|
500
|
+
*/
|
|
387
501
|
static getLocalhostFileNameBedrijf(browser, account) {
|
|
388
502
|
return node_path.join(sessionsDir, `${browser.browserType().name()}-${environment}-${account.username}.json`);
|
|
389
503
|
}
|
|
504
|
+
/**
|
|
505
|
+
* @param browser the browser instance the session file name is based on
|
|
506
|
+
* @param account login details, supplied by the consumer of this library; only `username` is used
|
|
507
|
+
*/
|
|
390
508
|
static getDigidFileName(browser, account) {
|
|
391
509
|
return node_path.join(sessionsDir, `${browser.browserType().name()}-digid-${environment}-${account.username}.json`);
|
|
392
510
|
}
|
|
511
|
+
/**
|
|
512
|
+
* @param browser the browser instance the session file name is based on
|
|
513
|
+
* @param account login details, supplied by the consumer of this library; only `username` is used
|
|
514
|
+
*/
|
|
393
515
|
static getDigidGemachtigdeFileName(browser, account) {
|
|
394
516
|
return node_path.join(sessionsDir, `${browser.browserType().name()}-digid-gemachtigde-${environment}-${account.username}.json`);
|
|
395
517
|
}
|
|
518
|
+
/**
|
|
519
|
+
* @param browser the browser instance the session file name is based on
|
|
520
|
+
* @param account login details, supplied by the consumer of this library; only `username` is used
|
|
521
|
+
*/
|
|
396
522
|
static getEHerkenningFileName(browser, account) {
|
|
397
523
|
return node_path.join(sessionsDir, `${browser.browserType().name()}-eherkenning-${environment}-${account.username}.json`);
|
|
398
524
|
}
|
|
525
|
+
/**
|
|
526
|
+
* @param browser the browser instance the session file name is based on
|
|
527
|
+
* @param account login details, supplied by the consumer of this library; only `username` is used
|
|
528
|
+
*/
|
|
399
529
|
static getEHerkenningVestigingFileName(browser, account) {
|
|
400
530
|
return node_path.join(sessionsDir, `${browser.browserType().name()}-eherkenning-vestiging-${environment}-${account.username}.json`);
|
|
401
531
|
}
|
|
532
|
+
/**
|
|
533
|
+
* @param browser the browser instance the session file name is based on
|
|
534
|
+
* @param account login details, supplied by the consumer of this library; only `username` is used
|
|
535
|
+
*/
|
|
402
536
|
static getEHerkenningBewindvoerderFileName(browser, account) {
|
|
403
537
|
return node_path.join(sessionsDir, `${browser.browserType().name()}-eherkenning-bewindvoerder-${environment}-${account.username}.json`);
|
|
404
538
|
}
|
|
539
|
+
/**
|
|
540
|
+
* @param browser the browser instance the session file name is based on
|
|
541
|
+
* @param account login details, supplied by the consumer of this library; only `username` is used
|
|
542
|
+
*/
|
|
405
543
|
static getADFileName(browser, account) {
|
|
406
544
|
return node_path.join(sessionsDir, `${browser.browserType().name()}-ad-${environment}-${account.username}.json`);
|
|
407
545
|
}
|
|
@@ -414,7 +552,7 @@ var MAX_SESSION_TIME_IN_MINUTES = 10;
|
|
|
414
552
|
* It will also perform the process of setting op the session
|
|
415
553
|
*
|
|
416
554
|
* @param authType type of login
|
|
417
|
-
* @param account
|
|
555
|
+
* @param account login details, supplied by the consumer of this library
|
|
418
556
|
* @param loginHandler that will handle the login itself
|
|
419
557
|
*/
|
|
420
558
|
function createSessionHandler(authType, account, loginHandler) {
|
|
@@ -540,8 +678,14 @@ function getApiTokenFromSession(baseTest, handler) {
|
|
|
540
678
|
}
|
|
541
679
|
//#endregion
|
|
542
680
|
//#region src/auth/getSessionHandler.ts
|
|
543
|
-
|
|
544
|
-
|
|
681
|
+
/**
|
|
682
|
+
* @param testProfile
|
|
683
|
+
* @param adTargetUrl URL to navigate to before logging in when `testProfile.authType` is
|
|
684
|
+
* `'ad-session'` (the app behind the firewall), supplied by the consumer of this library.
|
|
685
|
+
* Required in that case, ignored otherwise.
|
|
686
|
+
*/
|
|
687
|
+
function getSessionHandler(testProfile, adTargetUrl) {
|
|
688
|
+
return createSessionHandler(testProfile.authType, testProfile.account, getLoginHandler(testProfile.authType, adTargetUrl));
|
|
545
689
|
}
|
|
546
690
|
//#endregion
|
|
547
691
|
exports.ADLoginHandler = ADLoginHandler;
|
package/dist/index.es.js
CHANGED
|
@@ -6,6 +6,11 @@ import { TOTP } from "totp-generator";
|
|
|
6
6
|
import * as path from "node:path";
|
|
7
7
|
//#region src/auth/loginhandlers/localhostLoginHandler.ts
|
|
8
8
|
var LocalhostLoginHandler = class {
|
|
9
|
+
/**
|
|
10
|
+
* @param page the Playwright page to perform the login on
|
|
11
|
+
* @param account login details, supplied by the consumer of this library
|
|
12
|
+
* @param file path of the storage state file to write the session to
|
|
13
|
+
*/
|
|
9
14
|
async loginAndCreateSessionStorage(page, account, file) {
|
|
10
15
|
await new LocalLoginPage(page).loginAndCreateNewSession(account, file);
|
|
11
16
|
}
|
|
@@ -78,6 +83,10 @@ var DigidLoginPage = class extends LoginOverzichtPage {
|
|
|
78
83
|
constructor(page) {
|
|
79
84
|
super(page);
|
|
80
85
|
}
|
|
86
|
+
/**
|
|
87
|
+
* @param account login details, supplied by the consumer of this library
|
|
88
|
+
* @param fileName path of the storage state file to write the session to
|
|
89
|
+
*/
|
|
81
90
|
async loginAndCreateNewSession(account, fileName) {
|
|
82
91
|
await this.openPage();
|
|
83
92
|
await this.handleAnySpecialADLoginScreen();
|
|
@@ -94,6 +103,10 @@ var DigidLoginPage = class extends LoginOverzichtPage {
|
|
|
94
103
|
}
|
|
95
104
|
await this.page.context().storageState({ path: fileName });
|
|
96
105
|
}
|
|
106
|
+
/**
|
|
107
|
+
* @param account login details, supplied by the consumer of this library
|
|
108
|
+
* @param fileName path of the storage state file to write the session to
|
|
109
|
+
*/
|
|
97
110
|
async loginAndCreateNewGemachtigdeSession(account, fileName) {
|
|
98
111
|
await this.openPage();
|
|
99
112
|
await this.handleAnySpecialADLoginScreen();
|
|
@@ -117,6 +130,10 @@ var DigidLoginPage = class extends LoginOverzichtPage {
|
|
|
117
130
|
await this.page.locator(`//div[contains(@data-test-id,'${process$1.env.AD_USER}')]`).first().click();
|
|
118
131
|
} catch (_error) {}
|
|
119
132
|
}
|
|
133
|
+
/**
|
|
134
|
+
* @param account login details, supplied by the consumer of this library
|
|
135
|
+
* @param gemachtigde whether to log in as an authorized representative (machtiging) instead of a regular user
|
|
136
|
+
*/
|
|
120
137
|
async loginWithDigid(account, gemachtigde) {
|
|
121
138
|
await this.page.getByLabel("Inlogoptie 5 van 5: Inloggen").click();
|
|
122
139
|
await this.page.getByLabel("Testen betrouwbaarheidsniveau").selectOption("25");
|
|
@@ -139,6 +156,11 @@ var DigidLoginPage = class extends LoginOverzichtPage {
|
|
|
139
156
|
//#endregion
|
|
140
157
|
//#region src/auth/loginhandlers/digidLoginHandler.ts
|
|
141
158
|
var DigidLoginHandler = class {
|
|
159
|
+
/**
|
|
160
|
+
* @param page the Playwright page to perform the login on
|
|
161
|
+
* @param account login details, supplied by the consumer of this library
|
|
162
|
+
* @param file path of the storage state file to write the session to
|
|
163
|
+
*/
|
|
142
164
|
async loginAndCreateSessionStorage(page, account, file) {
|
|
143
165
|
await new DigidLoginPage(page).loginAndCreateNewSession(account, file);
|
|
144
166
|
}
|
|
@@ -167,6 +189,9 @@ var EHerkenningLoginPage = class extends LoginOverzichtPage {
|
|
|
167
189
|
this.buttonZoek = page.locator("#search-submit");
|
|
168
190
|
this.verderLink = page.getByRole("link", { name: /Verder|Continue|Ga verder/ });
|
|
169
191
|
}
|
|
192
|
+
/**
|
|
193
|
+
* @param account login details, supplied by the consumer of this library
|
|
194
|
+
*/
|
|
170
195
|
async probeerInTeLoggenMetEHerkenning(account) {
|
|
171
196
|
await this.dropdownSelectIdentityProvider.selectOption("Digidentity AD 1.13 (preproduction)");
|
|
172
197
|
await this.page.locator("#remember").click();
|
|
@@ -176,6 +201,10 @@ var EHerkenningLoginPage = class extends LoginOverzichtPage {
|
|
|
176
201
|
await this.textfieldPassword.fill(account.password);
|
|
177
202
|
await this.inloggenKnop.click();
|
|
178
203
|
}
|
|
204
|
+
/**
|
|
205
|
+
* @param fileName path of the storage state file to write the session to
|
|
206
|
+
* @param account login details, supplied by the consumer of this library
|
|
207
|
+
*/
|
|
179
208
|
async loginWithEHerkenningAndCreateSession(fileName, account) {
|
|
180
209
|
await this.openPage();
|
|
181
210
|
try {
|
|
@@ -187,12 +216,19 @@ var EHerkenningLoginPage = class extends LoginOverzichtPage {
|
|
|
187
216
|
await this.loginWithEHerkenning(account);
|
|
188
217
|
await this.page.context().storageState({ path: fileName });
|
|
189
218
|
}
|
|
219
|
+
/**
|
|
220
|
+
* @param account login details, supplied by the consumer of this library
|
|
221
|
+
*/
|
|
190
222
|
async loginWithEHerkenning(account) {
|
|
191
223
|
await this.probeerInTeLoggenMetEHerkenning(account);
|
|
192
224
|
await this.page.waitForTimeout(2e3);
|
|
193
225
|
if (await this.verderKnop.isVisible()) await this.verderKnop.click();
|
|
194
226
|
await this.accepteerCookies();
|
|
195
227
|
}
|
|
228
|
+
/**
|
|
229
|
+
* @param fileName path of the storage state file to write the session to
|
|
230
|
+
* @param account login details, supplied by the consumer of this library
|
|
231
|
+
*/
|
|
196
232
|
async loginWithEHerkenningVestigingAndCreateSession(fileName, account) {
|
|
197
233
|
await this.openPage();
|
|
198
234
|
try {
|
|
@@ -204,12 +240,19 @@ var EHerkenningLoginPage = class extends LoginOverzichtPage {
|
|
|
204
240
|
await this.loginWithEHerkenningVestiging(account);
|
|
205
241
|
await this.page.context().storageState({ path: fileName });
|
|
206
242
|
}
|
|
243
|
+
/**
|
|
244
|
+
* @param account login details, supplied by the consumer of this library
|
|
245
|
+
*/
|
|
207
246
|
async loginWithEHerkenningVestiging(account) {
|
|
208
247
|
await this.probeerInTeLoggenMetEHerkenning(account);
|
|
209
248
|
await this.page.waitForTimeout(2e3);
|
|
210
249
|
if (await this.verderKnop.isVisible()) await this.verderKnop.click();
|
|
211
250
|
await this.accepteerCookies();
|
|
212
251
|
}
|
|
252
|
+
/**
|
|
253
|
+
* @param gemachtigde login details of the authorized representative (bewindvoerder), supplied by the consumer of this library
|
|
254
|
+
* @param file optional path of the storage state file to write the session to
|
|
255
|
+
*/
|
|
213
256
|
async loginAlsProfessioneelBewindvoerder(gemachtigde, file) {
|
|
214
257
|
await this.openPage();
|
|
215
258
|
await this.klikOpProfessioneelBewindvoerderLoginOptie();
|
|
@@ -232,6 +275,11 @@ var EHerkenningLoginPage = class extends LoginOverzichtPage {
|
|
|
232
275
|
//#endregion
|
|
233
276
|
//#region src/auth/loginhandlers/eHerkenningLoginHandler.ts
|
|
234
277
|
var EHerkenningLoginHandler = class {
|
|
278
|
+
/**
|
|
279
|
+
* @param page the Playwright page to perform the login on
|
|
280
|
+
* @param account login details, supplied by the consumer of this library
|
|
281
|
+
* @param file path of the storage state file to write the session to
|
|
282
|
+
*/
|
|
235
283
|
async loginAndCreateSessionStorage(page, account, file) {
|
|
236
284
|
await new EHerkenningLoginPage(page).loginWithEHerkenningVestigingAndCreateSession(file, account);
|
|
237
285
|
}
|
|
@@ -239,6 +287,11 @@ var EHerkenningLoginHandler = class {
|
|
|
239
287
|
//#endregion
|
|
240
288
|
//#region src/auth/loginhandlers/digidGemachtigdeLoginHandler.ts
|
|
241
289
|
var DigidGemachtigdeLoginHandler = class {
|
|
290
|
+
/**
|
|
291
|
+
* @param page the Playwright page to perform the login on
|
|
292
|
+
* @param account login details, supplied by the consumer of this library
|
|
293
|
+
* @param file path of the storage state file to write the session to
|
|
294
|
+
*/
|
|
242
295
|
async loginAndCreateSessionStorage(page, account, file) {
|
|
243
296
|
await new DigidLoginPage(page).loginAndCreateNewGemachtigdeSession(account, file);
|
|
244
297
|
}
|
|
@@ -246,6 +299,11 @@ var DigidGemachtigdeLoginHandler = class {
|
|
|
246
299
|
//#endregion
|
|
247
300
|
//#region src/auth/loginhandlers/eHerkenningBewindvoerderLoginHandler.ts
|
|
248
301
|
var EHerkenningBewindvoerderLoginHandler = class {
|
|
302
|
+
/**
|
|
303
|
+
* @param page the Playwright page to perform the login on
|
|
304
|
+
* @param account login details, supplied by the consumer of this library
|
|
305
|
+
* @param file path of the storage state file to write the session to
|
|
306
|
+
*/
|
|
249
307
|
async loginAndCreateSessionStorage(page, account, file) {
|
|
250
308
|
await new EHerkenningLoginPage(page).loginAlsProfessioneelBewindvoerder(account, file);
|
|
251
309
|
}
|
|
@@ -281,12 +339,28 @@ var ADLoginPage = class ADLoginPage extends BasePage {
|
|
|
281
339
|
/**
|
|
282
340
|
* Login with the AD account so we can get behind the firewall
|
|
283
341
|
*
|
|
284
|
-
* @param account
|
|
285
|
-
* @param
|
|
342
|
+
* @param account login details, supplied by the consumer of this library
|
|
343
|
+
* @param targetUrl URL to navigate to before logging in (the app behind the firewall),
|
|
344
|
+
* supplied by the consumer of this library — not every consumer has a GZAC account, so
|
|
345
|
+
* this library no longer assumes GZAC as the destination. The consumer is responsible
|
|
346
|
+
* for switching between environments (e.g. test/acc/prod) when building this URL; this
|
|
347
|
+
* library does not do that for you.
|
|
348
|
+
* @param fileName path of the storage state file to write the session to
|
|
349
|
+
*
|
|
350
|
+
* @example
|
|
351
|
+
* // consumer-side lookup, e.g. based on an `ENV` environment variable
|
|
352
|
+
* export const TARGET_URL_BY_ENVIRONMENT = {
|
|
353
|
+
* test: 'https://alg-zgw.test.denhaag.nl/',
|
|
354
|
+
* acc: 'https://alg-zgw.acc.denhaag.nl/',
|
|
355
|
+
* prod: 'https://alg-zgw.denhaag.nl/',
|
|
356
|
+
* } as const;
|
|
357
|
+
*
|
|
358
|
+
* const env = (process.env.ENV ?? 'test') as keyof typeof TARGET_URL_BY_ENVIRONMENT;
|
|
359
|
+
* await adLoginPage.loginWithADAccountAndCreateSession(account, TARGET_URL_BY_ENVIRONMENT[env], fileName);
|
|
286
360
|
*/
|
|
287
|
-
async loginWithADAccountAndCreateSession(account, fileName) {
|
|
361
|
+
async loginWithADAccountAndCreateSession(account, targetUrl, fileName) {
|
|
288
362
|
const adLoginPage = new ADLoginPage(this.page);
|
|
289
|
-
await this.page.goto(
|
|
363
|
+
await this.page.goto(targetUrl);
|
|
290
364
|
await adLoginPage.gebruikersnaamInput.waitFor();
|
|
291
365
|
await adLoginPage.gebruikersnaamInput.fill(account.username);
|
|
292
366
|
await adLoginPage.volgendeInput.click();
|
|
@@ -321,6 +395,17 @@ var ADLoginPage = class ADLoginPage extends BasePage {
|
|
|
321
395
|
} catch (_error) {}
|
|
322
396
|
}
|
|
323
397
|
}
|
|
398
|
+
/**
|
|
399
|
+
* Determines the GZAC URL to log in against, based on the current environment.
|
|
400
|
+
*
|
|
401
|
+
* @deprecated GZAC-specific and no longer called internally by this library — pass your own
|
|
402
|
+
* target URL to {@link loginWithADAccountAndCreateSession} instead. Kept only so existing
|
|
403
|
+
* GZAC consumers can still derive this URL themselves during migration; will be removed in
|
|
404
|
+
* a future version.
|
|
405
|
+
*
|
|
406
|
+
* Derives the environment from `this.getBaseUrl()` (inherited from `BasePage`), which reads
|
|
407
|
+
* the `PORTAL_BASE_URL` environment variable.
|
|
408
|
+
*/
|
|
324
409
|
getGzacUrl() {
|
|
325
410
|
const baseUrl = this.getBaseUrl();
|
|
326
411
|
if (/klantportaal-zgw.denhaag.nl./.exec(baseUrl)) return gzacUrlProd;
|
|
@@ -332,20 +417,41 @@ var ADLoginPage = class ADLoginPage extends BasePage {
|
|
|
332
417
|
//#endregion
|
|
333
418
|
//#region src/auth/loginhandlers/adLoginHandler.ts
|
|
334
419
|
var ADLoginHandler = class {
|
|
420
|
+
targetUrl;
|
|
421
|
+
/**
|
|
422
|
+
* @param targetUrl URL to navigate to before logging in (the app behind the firewall),
|
|
423
|
+
* supplied by the consumer of this library
|
|
424
|
+
*/
|
|
425
|
+
constructor(targetUrl) {
|
|
426
|
+
this.targetUrl = targetUrl;
|
|
427
|
+
}
|
|
428
|
+
/**
|
|
429
|
+
* @param page the Playwright page to perform the login on
|
|
430
|
+
* @param account login details, supplied by the consumer of this library
|
|
431
|
+
* @param file path of the storage state file to write the session to
|
|
432
|
+
*/
|
|
335
433
|
async loginAndCreateSessionStorage(page, account, file) {
|
|
336
|
-
await new ADLoginPage(page).loginWithADAccountAndCreateSession(account, file);
|
|
434
|
+
await new ADLoginPage(page).loginWithADAccountAndCreateSession(account, this.targetUrl, file);
|
|
337
435
|
}
|
|
338
436
|
};
|
|
339
437
|
//#endregion
|
|
340
438
|
//#region src/auth/getLoginHandler.ts
|
|
341
|
-
|
|
439
|
+
/**
|
|
440
|
+
* @param authType type of login
|
|
441
|
+
* @param adTargetUrl URL to navigate to before logging in for the `ad-session` auth type (the
|
|
442
|
+
* app behind the firewall), supplied by the consumer of this library. Required when
|
|
443
|
+
* `authType` is `'ad-session'`, ignored otherwise.
|
|
444
|
+
*/
|
|
445
|
+
function getLoginHandler(authType, adTargetUrl) {
|
|
342
446
|
switch (authType) {
|
|
343
447
|
case "digid": return isRunningOnLocalhost() ? new LocalhostLoginHandler() : new DigidLoginHandler();
|
|
344
448
|
case "digid_gemachtigde": return new DigidGemachtigdeLoginHandler();
|
|
345
449
|
case "eherkenning": return isRunningOnLocalhost() ? new LocalhostLoginHandler() : new EHerkenningLoginHandler();
|
|
346
450
|
case "eherkenning_vestiging": return new EHerkenningLoginHandler();
|
|
347
451
|
case "eherkenning_bewindvoerder": return new EHerkenningBewindvoerderLoginHandler();
|
|
348
|
-
case "ad-session":
|
|
452
|
+
case "ad-session":
|
|
453
|
+
if (!adTargetUrl) throw new Error("adTargetUrl is required when authType is 'ad-session'");
|
|
454
|
+
return new ADLoginHandler(adTargetUrl);
|
|
349
455
|
default: throw new Error(`Unsupported auth type: ${authType}. If needed please create a new LoginHandler and register it here in getLoginHandler().`);
|
|
350
456
|
}
|
|
351
457
|
}
|
|
@@ -357,27 +463,59 @@ var environment = process$2.env.ENV ?? "test";
|
|
|
357
463
|
* Easy way to create the filenames for the sessions
|
|
358
464
|
*/
|
|
359
465
|
var SessionFileHelper = class {
|
|
466
|
+
/**
|
|
467
|
+
* @param browser the browser instance the session file name is based on
|
|
468
|
+
* @param account login details, supplied by the consumer of this library; only `username` is used
|
|
469
|
+
*/
|
|
360
470
|
static getLocalhostFileName(browser, account) {
|
|
361
471
|
return path.join(sessionsDir, `${browser.browserType().name()}-${environment}-${account.username}.json`);
|
|
362
472
|
}
|
|
473
|
+
/**
|
|
474
|
+
* @param browser the browser instance the session file name is based on
|
|
475
|
+
* @param account login details, supplied by the consumer of this library; only `username` is used
|
|
476
|
+
*/
|
|
363
477
|
static getLocalhostFileNameBedrijf(browser, account) {
|
|
364
478
|
return path.join(sessionsDir, `${browser.browserType().name()}-${environment}-${account.username}.json`);
|
|
365
479
|
}
|
|
480
|
+
/**
|
|
481
|
+
* @param browser the browser instance the session file name is based on
|
|
482
|
+
* @param account login details, supplied by the consumer of this library; only `username` is used
|
|
483
|
+
*/
|
|
366
484
|
static getDigidFileName(browser, account) {
|
|
367
485
|
return path.join(sessionsDir, `${browser.browserType().name()}-digid-${environment}-${account.username}.json`);
|
|
368
486
|
}
|
|
487
|
+
/**
|
|
488
|
+
* @param browser the browser instance the session file name is based on
|
|
489
|
+
* @param account login details, supplied by the consumer of this library; only `username` is used
|
|
490
|
+
*/
|
|
369
491
|
static getDigidGemachtigdeFileName(browser, account) {
|
|
370
492
|
return path.join(sessionsDir, `${browser.browserType().name()}-digid-gemachtigde-${environment}-${account.username}.json`);
|
|
371
493
|
}
|
|
494
|
+
/**
|
|
495
|
+
* @param browser the browser instance the session file name is based on
|
|
496
|
+
* @param account login details, supplied by the consumer of this library; only `username` is used
|
|
497
|
+
*/
|
|
372
498
|
static getEHerkenningFileName(browser, account) {
|
|
373
499
|
return path.join(sessionsDir, `${browser.browserType().name()}-eherkenning-${environment}-${account.username}.json`);
|
|
374
500
|
}
|
|
501
|
+
/**
|
|
502
|
+
* @param browser the browser instance the session file name is based on
|
|
503
|
+
* @param account login details, supplied by the consumer of this library; only `username` is used
|
|
504
|
+
*/
|
|
375
505
|
static getEHerkenningVestigingFileName(browser, account) {
|
|
376
506
|
return path.join(sessionsDir, `${browser.browserType().name()}-eherkenning-vestiging-${environment}-${account.username}.json`);
|
|
377
507
|
}
|
|
508
|
+
/**
|
|
509
|
+
* @param browser the browser instance the session file name is based on
|
|
510
|
+
* @param account login details, supplied by the consumer of this library; only `username` is used
|
|
511
|
+
*/
|
|
378
512
|
static getEHerkenningBewindvoerderFileName(browser, account) {
|
|
379
513
|
return path.join(sessionsDir, `${browser.browserType().name()}-eherkenning-bewindvoerder-${environment}-${account.username}.json`);
|
|
380
514
|
}
|
|
515
|
+
/**
|
|
516
|
+
* @param browser the browser instance the session file name is based on
|
|
517
|
+
* @param account login details, supplied by the consumer of this library; only `username` is used
|
|
518
|
+
*/
|
|
381
519
|
static getADFileName(browser, account) {
|
|
382
520
|
return path.join(sessionsDir, `${browser.browserType().name()}-ad-${environment}-${account.username}.json`);
|
|
383
521
|
}
|
|
@@ -390,7 +528,7 @@ var MAX_SESSION_TIME_IN_MINUTES = 10;
|
|
|
390
528
|
* It will also perform the process of setting op the session
|
|
391
529
|
*
|
|
392
530
|
* @param authType type of login
|
|
393
|
-
* @param account
|
|
531
|
+
* @param account login details, supplied by the consumer of this library
|
|
394
532
|
* @param loginHandler that will handle the login itself
|
|
395
533
|
*/
|
|
396
534
|
function createSessionHandler(authType, account, loginHandler) {
|
|
@@ -516,8 +654,14 @@ function getApiTokenFromSession(baseTest, handler) {
|
|
|
516
654
|
}
|
|
517
655
|
//#endregion
|
|
518
656
|
//#region src/auth/getSessionHandler.ts
|
|
519
|
-
|
|
520
|
-
|
|
657
|
+
/**
|
|
658
|
+
* @param testProfile
|
|
659
|
+
* @param adTargetUrl URL to navigate to before logging in when `testProfile.authType` is
|
|
660
|
+
* `'ad-session'` (the app behind the firewall), supplied by the consumer of this library.
|
|
661
|
+
* Required in that case, ignored otherwise.
|
|
662
|
+
*/
|
|
663
|
+
function getSessionHandler(testProfile, adTargetUrl) {
|
|
664
|
+
return createSessionHandler(testProfile.authType, testProfile.account, getLoginHandler(testProfile.authType, adTargetUrl));
|
|
521
665
|
}
|
|
522
666
|
//#endregion
|
|
523
667
|
export { ADLoginHandler, ADLoginPage, DigidGemachtigdeLoginHandler, DigidLoginHandler, DigidLoginPage, EHerkenningBewindvoerderLoginHandler, EHerkenningLoginHandler, EHerkenningLoginPage, LocalhostLoginHandler, LoginOverzichtPage, MAX_SESSION_TIME_IN_MINUTES, SessionFileHelper, createSessionHandler, getApiTokenFromSession, getLoginHandler, getSessionHandler };
|
package/package.json
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dh-auth-library",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.5.0",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "git+https://github.com/Gemeente-DenHaag/dh-auth-library.git"
|
|
7
7
|
},
|
|
8
|
-
"packageManager": "pnpm@
|
|
8
|
+
"packageManager": "pnpm@12.9.1+sha512.06b055fff5cd20dc12781de173ced3310ce0951bf2ec620211a16045d5444d5c93a663210764ef29a653a610459ba0368f0e74f84d80c54723cf95aae7bc0d6d",
|
|
9
9
|
"description": "Authentication package for all types of login on DH applications",
|
|
10
10
|
"license": "MIT",
|
|
11
11
|
"main": "dist/index.cjs.js",
|
|
@@ -44,7 +44,7 @@
|
|
|
44
44
|
"vite-tsconfig-paths": "^6.1.1"
|
|
45
45
|
},
|
|
46
46
|
"dependencies": {
|
|
47
|
-
"nl-portal-playwright-libraries": "^1.1.
|
|
47
|
+
"nl-portal-playwright-libraries": "^1.1.4",
|
|
48
48
|
"totp-generator": "^2.0.1"
|
|
49
49
|
},
|
|
50
50
|
"keywords": [
|