@abapify/adt-playwright 0.4.0 → 0.4.3

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.
@@ -0,0 +1,90 @@
1
+ import { BrowserAuthOptions, BrowserAuthOptions as BrowserAuthOptions$1, BrowserCredentials, BrowserCredentials as BrowserCredentials$1, CookieData, testCredentials, toCookieHeader, toHeaders } from "@abapify/browser-auth";
2
+ import { AdtConfig } from "@abapify/adt-config";
3
+ import { AuthPlugin } from "@abapify/adt-auth";
4
+ //#region src/playwright-auth.d.ts
5
+ type PlaywrightCredentials = BrowserCredentials$1;
6
+ type PlaywrightAuthOptions = BrowserAuthOptions$1;
7
+ /**
8
+ * Playwright authentication object
9
+ */
10
+ declare const playwrightAuth: {
11
+ /**
12
+ * Authenticate using Playwright browser
13
+ */
14
+ authenticate(options: PlaywrightAuthOptions): Promise<PlaywrightCredentials>;
15
+ /**
16
+ * Test if credentials are still valid
17
+ */
18
+ test: typeof testCredentials;
19
+ /**
20
+ * Refresh is not reliable with Okta SSO - always return null to trigger full re-authentication
21
+ */
22
+ refresh(session: {
23
+ auth?: {
24
+ pluginOptions?: {
25
+ log?: (message: string) => void;
26
+ };
27
+ };
28
+ }): Promise<PlaywrightCredentials | null>;
29
+ };
30
+ declare const playwright: {
31
+ /**
32
+ * Authenticate using Playwright browser
33
+ */
34
+ authenticate(options: PlaywrightAuthOptions): Promise<PlaywrightCredentials>;
35
+ /**
36
+ * Test if credentials are still valid
37
+ */
38
+ test: typeof testCredentials;
39
+ /**
40
+ * Refresh is not reliable with Okta SSO - always return null to trigger full re-authentication
41
+ */
42
+ refresh(session: {
43
+ auth?: {
44
+ pluginOptions?: {
45
+ log?: (message: string) => void;
46
+ };
47
+ };
48
+ }): Promise<PlaywrightCredentials | null>;
49
+ };
50
+ //#endregion
51
+ //#region src/auth-plugin.d.ts
52
+ /**
53
+ * Playwright authentication plugin for AuthManager.
54
+ *
55
+ * Implements the standard AuthPlugin interface to integrate Playwright-based
56
+ * browser authentication with the ADT authentication system.
57
+ *
58
+ * @remarks
59
+ * This plugin:
60
+ * - Opens a browser window for SSO authentication
61
+ * - Captures session cookies after successful login
62
+ * - Converts cookies to the format expected by AuthManager
63
+ * - Does NOT support silent refresh (Okta SSO requires user interaction)
64
+ *
65
+ * @example
66
+ * ```typescript
67
+ * // Used internally by AuthManager when destination type is '@abapify/adt-playwright'
68
+ * import authPlugin from '@abapify/adt-playwright';
69
+ *
70
+ * const result = await authPlugin.authenticate({
71
+ * url: 'https://sap-system.example.com',
72
+ * headless: false,
73
+ * userDataDir: true,
74
+ * });
75
+ * ```
76
+ */
77
+ declare const authPlugin: AuthPlugin;
78
+ //#endregion
79
+ //#region src/index.d.ts
80
+ /**
81
+ * Plugin-level options applied to all destinations
82
+ */
83
+ type PlaywrightPluginOptions = BrowserAuthOptions$1;
84
+ /**
85
+ * Wrap a standard config with playwright auth for all destinations.
86
+ */
87
+ declare function withPlaywright(config: AdtConfig, options?: Partial<BrowserAuthOptions$1>): AdtConfig;
88
+ //#endregion
89
+ export { type BrowserAuthOptions, type BrowserCredentials, type CookieData, type PlaywrightAuthOptions, type PlaywrightCredentials, PlaywrightPluginOptions, authPlugin, authPlugin as default, playwright, playwrightAuth, toCookieHeader, toHeaders, withPlaywright };
90
+ //# sourceMappingURL=index.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.mts","names":[],"sources":["../src/playwright-auth.ts","../src/auth-plugin.ts","../src/index.ts"],"mappings":";;;;KAeY,wBAAwB;KACxB,wBAAwB;;;;cAKvB;;;;EAKA,aAAA,SAAA,wBACR,QAAQ;;;;;;;;EAaY,QAAA;IACrB;MAAS;QAAkB,OAAO;;;MAChC,QAAQ;;cAaD;;;;EA7BA,aAAA,SAAA,wBACR,QAAQ;;;;;;;;EAaY,QAAA;IACrB;MAAS;QAAkB,OAAO;;;MAChC,QAAQ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cCkCR,YAAY;;;;;;KCpDN,0BAA0B;;;;iBAetB,eACd,QAAQ,WACR,UAAU,QAAQ,wBACjB"}
package/dist/index.mjs ADDED
@@ -0,0 +1,269 @@
1
+ import { authenticate, testCredentials, toCookieHeader, toHeaders } from "@abapify/browser-auth";
2
+ import { chromium } from "playwright";
3
+
4
+ //#region src/adapter.ts
5
+ /**
6
+ * Playwright Browser Adapter
7
+ *
8
+ * Implements BrowserAdapter interface for Playwright.
9
+ * This is a thin wrapper - all auth logic is in @abapify/browser-auth.
10
+ */
11
+ /**
12
+ * Convert Playwright cookie to CookieData
13
+ */
14
+ function convertCookie(cookie) {
15
+ return {
16
+ name: cookie.name,
17
+ value: cookie.value,
18
+ domain: cookie.domain,
19
+ path: cookie.path,
20
+ expires: cookie.expires,
21
+ httpOnly: cookie.httpOnly,
22
+ secure: cookie.secure,
23
+ sameSite: cookie.sameSite
24
+ };
25
+ }
26
+ /**
27
+ * Create a Playwright browser adapter
28
+ */
29
+ function createPlaywrightAdapter() {
30
+ let context = null;
31
+ let page = null;
32
+ const responseHandlers = [];
33
+ const closeHandlers = [];
34
+ return {
35
+ async launch(options) {
36
+ const { headless, userDataDir, ignoreHTTPSErrors, userAgent } = options;
37
+ if (userDataDir) context = await chromium.launchPersistentContext(userDataDir, {
38
+ headless,
39
+ ignoreHTTPSErrors,
40
+ userAgent
41
+ });
42
+ else context = await (await chromium.launch({ headless })).newContext({
43
+ ignoreHTTPSErrors,
44
+ userAgent
45
+ });
46
+ },
47
+ async newPage() {
48
+ if (!context) throw new Error("Browser not launched");
49
+ page = await context.newPage();
50
+ page.on("response", (response) => {
51
+ const event = {
52
+ url: response.url(),
53
+ status: response.status()
54
+ };
55
+ responseHandlers.forEach((handler) => handler(event));
56
+ });
57
+ page.once("close", () => {
58
+ closeHandlers.forEach((handler) => handler());
59
+ });
60
+ },
61
+ async goto(url, options) {
62
+ if (!page) throw new Error("Page not created");
63
+ await page.goto(url, { timeout: options?.timeout ?? 3e4 }).catch(() => {});
64
+ },
65
+ async getCookies() {
66
+ if (!context) throw new Error("Browser not launched");
67
+ return (await context.cookies()).map(convertCookie);
68
+ },
69
+ async clearCookies(domain) {
70
+ if (!context) throw new Error("Browser not launched");
71
+ const toRemove = (await context.cookies()).filter((c) => c.domain.includes(domain) || domain.includes(c.domain.replace(/^\./, "")));
72
+ for (const cookie of toRemove) await context.clearCookies({
73
+ name: cookie.name,
74
+ domain: cookie.domain
75
+ });
76
+ },
77
+ async getUserAgent() {
78
+ if (!context) throw new Error("Browser not launched");
79
+ const uaPage = await context.newPage();
80
+ const userAgent = await uaPage.evaluate(() => navigator.userAgent);
81
+ await uaPage.close();
82
+ return userAgent;
83
+ },
84
+ async closePage() {
85
+ if (page) {
86
+ await page.close();
87
+ page = null;
88
+ }
89
+ },
90
+ async close() {
91
+ if (context) {
92
+ await context.close();
93
+ context = null;
94
+ }
95
+ },
96
+ onResponse(handler) {
97
+ responseHandlers.push(handler);
98
+ },
99
+ onPageClose(handler) {
100
+ closeHandlers.push(handler);
101
+ }
102
+ };
103
+ }
104
+
105
+ //#endregion
106
+ //#region src/playwright-auth.ts
107
+ /**
108
+ * Playwright Authentication Plugin
109
+ *
110
+ * Thin wrapper around @abapify/browser-auth core.
111
+ * Provides Playwright-specific browser adapter.
112
+ */
113
+ /**
114
+ * Playwright authentication object
115
+ */
116
+ const playwrightAuth = {
117
+ /**
118
+ * Authenticate using Playwright browser
119
+ */
120
+ async authenticate(options) {
121
+ const adapter = createPlaywrightAdapter();
122
+ return authenticate(adapter, options);
123
+ },
124
+ /**
125
+ * Test if credentials are still valid
126
+ */
127
+ test: testCredentials,
128
+ /**
129
+ * Refresh is not reliable with Okta SSO - always return null to trigger full re-authentication
130
+ */
131
+ async refresh(session) {
132
+ (session?.auth?.pluginOptions?.log ?? console.log)("🔄 Session expired, will trigger full re-authentication...");
133
+ return null;
134
+ }
135
+ };
136
+ const playwright = playwrightAuth;
137
+
138
+ //#endregion
139
+ //#region src/auth-plugin.ts
140
+ /** Default session duration when cookies don't specify expiration (8 hours) */
141
+ const DEFAULT_SESSION_DURATION_MS = 288e5;
142
+ /**
143
+ * Determines the session expiration time from cookie data.
144
+ *
145
+ * Examines all cookies and returns the earliest expiration time found.
146
+ * If no cookies have expiration set (common with session cookies),
147
+ * returns a default expiration of 8 hours from now.
148
+ *
149
+ * @param cookies - Array of cookie objects with optional expires field
150
+ * @returns The earliest expiration date, or default 8 hours from now
151
+ *
152
+ * @example
153
+ * // Cookie with expiration
154
+ * getExpiresAt([{ expires: 1732900000 }]) // Returns Date from timestamp
155
+ *
156
+ * @example
157
+ * // Session cookie (no expiration)
158
+ * getExpiresAt([{ expires: 0 }]) // Returns Date 8 hours from now
159
+ */
160
+ function getExpiresAt(cookies) {
161
+ const expirations = cookies.filter((c) => c.expires && c.expires > 0).map((c) => c.expires * 1e3);
162
+ if (expirations.length > 0) return new Date(Math.min(...expirations));
163
+ return new Date(Date.now() + DEFAULT_SESSION_DURATION_MS);
164
+ }
165
+ /**
166
+ * Playwright authentication plugin for AuthManager.
167
+ *
168
+ * Implements the standard AuthPlugin interface to integrate Playwright-based
169
+ * browser authentication with the ADT authentication system.
170
+ *
171
+ * @remarks
172
+ * This plugin:
173
+ * - Opens a browser window for SSO authentication
174
+ * - Captures session cookies after successful login
175
+ * - Converts cookies to the format expected by AuthManager
176
+ * - Does NOT support silent refresh (Okta SSO requires user interaction)
177
+ *
178
+ * @example
179
+ * ```typescript
180
+ * // Used internally by AuthManager when destination type is '@abapify/adt-playwright'
181
+ * import authPlugin from '@abapify/adt-playwright';
182
+ *
183
+ * const result = await authPlugin.authenticate({
184
+ * url: 'https://sap-system.example.com',
185
+ * headless: false,
186
+ * userDataDir: true,
187
+ * });
188
+ * ```
189
+ */
190
+ const authPlugin = {
191
+ /**
192
+ * Authenticate using Playwright browser automation.
193
+ *
194
+ * Opens a browser window, navigates to the SAP system, and waits for
195
+ * the user to complete SSO authentication. Captures cookies and returns
196
+ * them in AuthPluginResult format.
197
+ *
198
+ * @param options - Authentication options including URL and browser settings
199
+ * @returns Promise resolving to credentials in AuthPluginResult format
200
+ */
201
+ async authenticate(options) {
202
+ const credentials = await playwrightAuth.authenticate(options);
203
+ return {
204
+ method: "cookie",
205
+ credentials: {
206
+ cookies: toCookieHeader(credentials),
207
+ expiresAt: getExpiresAt(credentials.cookies)
208
+ }
209
+ };
210
+ },
211
+ /**
212
+ * Attempt to refresh an existing session.
213
+ *
214
+ * @remarks
215
+ * Always returns null because Okta SSO sessions cannot be silently refreshed.
216
+ * When a session expires, full re-authentication with user interaction is required.
217
+ * The AuthManager will handle this by calling authenticate() again.
218
+ *
219
+ * @param _session - The existing session (unused)
220
+ * @returns Always null, indicating refresh is not supported
221
+ */
222
+ async refresh(_session) {
223
+ return null;
224
+ }
225
+ };
226
+
227
+ //#endregion
228
+ //#region src/index.ts
229
+ /**
230
+ * Create a playwright destination config
231
+ */
232
+ function createPlaywrightDestination(options) {
233
+ return {
234
+ type: "@abapify/adt-playwright",
235
+ options
236
+ };
237
+ }
238
+ /**
239
+ * Wrap a standard config with playwright auth for all destinations.
240
+ */
241
+ function withPlaywright(config, options) {
242
+ if (!config.destinations) return config;
243
+ const destinations = {};
244
+ for (const [name, dest] of Object.entries(config.destinations)) if (typeof dest === "object" && "type" in dest) {
245
+ if (dest.type === "@abapify/adt-playwright" || dest.type === "playwright") destinations[name] = {
246
+ type: "@abapify/adt-playwright",
247
+ options: {
248
+ ...options,
249
+ ...dest.options
250
+ }
251
+ };
252
+ else destinations[name] = dest;
253
+ } else if (typeof dest === "string") destinations[name] = createPlaywrightDestination({
254
+ url: dest,
255
+ ...options
256
+ });
257
+ else destinations[name] = createPlaywrightDestination({
258
+ ...options,
259
+ ...dest
260
+ });
261
+ return {
262
+ ...config,
263
+ destinations
264
+ };
265
+ }
266
+
267
+ //#endregion
268
+ export { authPlugin, authPlugin as default, playwright, playwrightAuth, toCookieHeader, toHeaders, withPlaywright };
269
+ //# sourceMappingURL=index.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.mjs","names":[],"sources":["../src/adapter.ts","../src/playwright-auth.ts","../src/auth-plugin.ts","../src/index.ts"],"sourcesContent":["/**\n * Playwright Browser Adapter\n *\n * Implements BrowserAdapter interface for Playwright.\n * This is a thin wrapper - all auth logic is in @abapify/browser-auth.\n */\n\nimport { chromium } from 'playwright';\nimport type { BrowserContext, Page, Cookie } from 'playwright';\nimport type {\n BrowserAdapter,\n CookieData,\n ResponseEvent,\n} from '@abapify/browser-auth';\n\n/**\n * Convert Playwright cookie to CookieData\n */\nfunction convertCookie(cookie: Cookie): CookieData {\n return {\n name: cookie.name,\n value: cookie.value,\n domain: cookie.domain,\n path: cookie.path,\n expires: cookie.expires,\n httpOnly: cookie.httpOnly,\n secure: cookie.secure,\n sameSite: cookie.sameSite as CookieData['sameSite'],\n };\n}\n\n/**\n * Create a Playwright browser adapter\n */\nexport function createPlaywrightAdapter(): BrowserAdapter {\n let context: BrowserContext | null = null;\n let page: Page | null = null;\n\n const responseHandlers: ((event: ResponseEvent) => void)[] = [];\n const closeHandlers: (() => void)[] = [];\n\n return {\n async launch(options) {\n const { headless, userDataDir, ignoreHTTPSErrors, userAgent } = options;\n\n if (userDataDir) {\n // Persistent context - stores cookies/session\n context = await chromium.launchPersistentContext(userDataDir, {\n headless,\n ignoreHTTPSErrors,\n userAgent,\n });\n } else {\n const browser = await chromium.launch({ headless });\n context = await browser.newContext({ ignoreHTTPSErrors, userAgent });\n }\n },\n\n async newPage() {\n if (!context) throw new Error('Browser not launched');\n page = await context.newPage();\n\n // Wire up event handlers\n page.on('response', (response) => {\n const event: ResponseEvent = {\n url: response.url(),\n status: response.status(),\n };\n responseHandlers.forEach((handler) => handler(event));\n });\n\n page.once('close', () => {\n closeHandlers.forEach((handler) => handler());\n });\n },\n\n async goto(url, options) {\n if (!page) throw new Error('Page not created');\n await page\n .goto(url, { timeout: options?.timeout ?? 30000 })\n // Navigation errors are intentionally ignored; caller handles auth via event listeners\n // eslint-disable-next-line @typescript-eslint/no-empty-function\n .catch(() => {});\n },\n\n async getCookies() {\n if (!context) throw new Error('Browser not launched');\n const cookies = await context.cookies();\n return cookies.map(convertCookie);\n },\n\n async clearCookies(domain: string) {\n if (!context) throw new Error('Browser not launched');\n const cookies = await context.cookies();\n const toRemove = cookies.filter(\n (c) =>\n c.domain.includes(domain) ||\n domain.includes(c.domain.replace(/^\\./, '')),\n );\n // Clear each matching cookie individually\n for (const cookie of toRemove) {\n await context.clearCookies({\n name: cookie.name,\n domain: cookie.domain,\n });\n }\n },\n\n async getUserAgent() {\n if (!context) throw new Error('Browser not launched');\n const uaPage = await context.newPage();\n const userAgent = await uaPage.evaluate(() => navigator.userAgent);\n await uaPage.close();\n return userAgent;\n },\n\n async closePage() {\n if (page) {\n await page.close();\n page = null;\n }\n },\n\n async close() {\n if (context) {\n await context.close();\n context = null;\n }\n },\n\n onResponse(handler) {\n responseHandlers.push(handler);\n },\n\n onPageClose(handler) {\n closeHandlers.push(handler);\n },\n };\n}\n","/**\n * Playwright Authentication Plugin\n *\n * Thin wrapper around @abapify/browser-auth core.\n * Provides Playwright-specific browser adapter.\n */\n\nimport { authenticate, testCredentials } from '@abapify/browser-auth';\nimport type {\n BrowserCredentials,\n BrowserAuthOptions,\n} from '@abapify/browser-auth';\nimport { createPlaywrightAdapter } from './adapter';\n\n// Re-export types with Playwright-specific names for backwards compatibility\nexport type PlaywrightCredentials = BrowserCredentials;\nexport type PlaywrightAuthOptions = BrowserAuthOptions;\n\n/**\n * Playwright authentication object\n */\nexport const playwrightAuth = {\n /**\n * Authenticate using Playwright browser\n */\n async authenticate(\n options: PlaywrightAuthOptions,\n ): Promise<PlaywrightCredentials> {\n const adapter = createPlaywrightAdapter();\n return authenticate(adapter, options);\n },\n\n /**\n * Test if credentials are still valid\n */\n test: testCredentials,\n\n /**\n * Refresh is not reliable with Okta SSO - always return null to trigger full re-authentication\n */\n async refresh(session: {\n auth?: { pluginOptions?: { log?: (message: string) => void } };\n }): Promise<PlaywrightCredentials | null> {\n const log = session?.auth?.pluginOptions?.log as\n | ((message: string) => void)\n | undefined;\n (log ?? console.log)(\n '🔄 Session expired, will trigger full re-authentication...',\n );\n return null;\n },\n};\n\n// Re-export utilities\n// Legacy export\nexport const playwright = playwrightAuth;\nexport { toCookieHeader, toHeaders } from '@abapify/browser-auth';\n","/**\n * @fileoverview Playwright Authentication Plugin for AuthManager\n *\n * This module provides the standard auth plugin interface that AuthManager expects.\n * It wraps the Playwright-based browser authentication to return credentials in\n * the format required by the ADT authentication system.\n *\n * @module @abapify/adt-playwright/auth-plugin\n */\n\nimport type {\n AuthPlugin,\n AuthPluginResult,\n AuthPluginOptions,\n AuthSession,\n} from '@abapify/adt-auth';\nimport { playwrightAuth, toCookieHeader } from './playwright-auth';\n\n/** Default session duration when cookies don't specify expiration (8 hours) */\nconst DEFAULT_SESSION_DURATION_MS = 8 * 60 * 60 * 1000;\n\n/**\n * Determines the session expiration time from cookie data.\n *\n * Examines all cookies and returns the earliest expiration time found.\n * If no cookies have expiration set (common with session cookies),\n * returns a default expiration of 8 hours from now.\n *\n * @param cookies - Array of cookie objects with optional expires field\n * @returns The earliest expiration date, or default 8 hours from now\n *\n * @example\n * // Cookie with expiration\n * getExpiresAt([{ expires: 1732900000 }]) // Returns Date from timestamp\n *\n * @example\n * // Session cookie (no expiration)\n * getExpiresAt([{ expires: 0 }]) // Returns Date 8 hours from now\n */\nfunction getExpiresAt(cookies: { expires?: number }[]): Date {\n const expirations = cookies\n .filter((c) => c.expires && c.expires > 0)\n .map((c) => c.expires! * 1000); // Cookie expires is in seconds, convert to ms\n\n if (expirations.length > 0) {\n return new Date(Math.min(...expirations));\n }\n\n return new Date(Date.now() + DEFAULT_SESSION_DURATION_MS);\n}\n\n/**\n * Playwright authentication plugin for AuthManager.\n *\n * Implements the standard AuthPlugin interface to integrate Playwright-based\n * browser authentication with the ADT authentication system.\n *\n * @remarks\n * This plugin:\n * - Opens a browser window for SSO authentication\n * - Captures session cookies after successful login\n * - Converts cookies to the format expected by AuthManager\n * - Does NOT support silent refresh (Okta SSO requires user interaction)\n *\n * @example\n * ```typescript\n * // Used internally by AuthManager when destination type is '@abapify/adt-playwright'\n * import authPlugin from '@abapify/adt-playwright';\n *\n * const result = await authPlugin.authenticate({\n * url: 'https://sap-system.example.com',\n * headless: false,\n * userDataDir: true,\n * });\n * ```\n */\nconst authPlugin: AuthPlugin = {\n /**\n * Authenticate using Playwright browser automation.\n *\n * Opens a browser window, navigates to the SAP system, and waits for\n * the user to complete SSO authentication. Captures cookies and returns\n * them in AuthPluginResult format.\n *\n * @param options - Authentication options including URL and browser settings\n * @returns Promise resolving to credentials in AuthPluginResult format\n */\n async authenticate(options: AuthPluginOptions): Promise<AuthPluginResult> {\n const credentials = await playwrightAuth.authenticate(options);\n const cookieString = toCookieHeader(credentials);\n const expiresAt = getExpiresAt(credentials.cookies);\n\n return {\n method: 'cookie',\n credentials: {\n cookies: cookieString,\n expiresAt,\n },\n };\n },\n\n /**\n * Attempt to refresh an existing session.\n *\n * @remarks\n * Always returns null because Okta SSO sessions cannot be silently refreshed.\n * When a session expires, full re-authentication with user interaction is required.\n * The AuthManager will handle this by calling authenticate() again.\n *\n * @param _session - The existing session (unused)\n * @returns Always null, indicating refresh is not supported\n */\n async refresh(_session: AuthSession): Promise<AuthPluginResult | null> {\n return null;\n },\n};\n\nexport default authPlugin;\n","/**\n * @abapify/adt-playwright\n *\n * Playwright-based SSO authentication plugin for ADT client.\n * Uses @abapify/browser-auth core with Playwright adapter.\n */\n\nimport type { AdtConfig, Destination } from '@abapify/adt-config';\nimport type { BrowserAuthOptions } from '@abapify/browser-auth';\n\n// Re-export types\nexport type {\n PlaywrightCredentials,\n PlaywrightAuthOptions,\n} from './playwright-auth';\nexport type {\n BrowserCredentials,\n BrowserAuthOptions,\n CookieData,\n} from '@abapify/browser-auth';\n\n/**\n * Plugin-level options applied to all destinations\n */\nexport type PlaywrightPluginOptions = BrowserAuthOptions;\n\n/**\n * Create a playwright destination config\n */\nfunction createPlaywrightDestination(options: BrowserAuthOptions): Destination {\n return {\n type: '@abapify/adt-playwright',\n options,\n };\n}\n\n/**\n * Wrap a standard config with playwright auth for all destinations.\n */\nexport function withPlaywright(\n config: AdtConfig,\n options?: Partial<BrowserAuthOptions>,\n): AdtConfig {\n if (!config.destinations) {\n return config;\n }\n\n const destinations: Record<string, Destination> = {};\n\n for (const [name, dest] of Object.entries(config.destinations)) {\n if (typeof dest === 'object' && 'type' in dest) {\n if (\n dest.type === '@abapify/adt-playwright' ||\n dest.type === 'playwright'\n ) {\n destinations[name] = {\n type: '@abapify/adt-playwright',\n options: { ...options, ...(dest.options as BrowserAuthOptions) },\n };\n } else {\n destinations[name] = dest;\n }\n } else if (typeof dest === 'string') {\n destinations[name] = createPlaywrightDestination({\n url: dest,\n ...options,\n });\n } else {\n // Destination-specific options override global options\n destinations[name] = createPlaywrightDestination({\n ...options,\n ...(dest as BrowserAuthOptions),\n });\n }\n }\n\n return { ...config, destinations };\n}\n\n// Main exports\nexport {\n playwrightAuth,\n playwright,\n toCookieHeader,\n toHeaders,\n} from './playwright-auth';\n\n// AuthManager compatibility exports\nexport { default } from './auth-plugin';\nexport { default as authPlugin } from './auth-plugin';\n"],"mappings":";;;;;;;;;;;;;AAkBA,SAAS,cAAc,QAA4B;CACjD,OAAO;EACL,MAAM,OAAO;EACb,OAAO,OAAO;EACd,QAAQ,OAAO;EACf,MAAM,OAAO;EACb,SAAS,OAAO;EAChB,UAAU,OAAO;EACjB,QAAQ,OAAO;EACf,UAAU,OAAO;CACnB;AACF;;;;AAKA,SAAgB,0BAA0C;CACxD,IAAI,UAAiC;CACrC,IAAI,OAAoB;CAExB,MAAM,mBAAuD,CAAC;CAC9D,MAAM,gBAAgC,CAAC;CAEvC,OAAO;EACL,MAAM,OAAO,SAAS;GACpB,MAAM,EAAE,UAAU,aAAa,mBAAmB,cAAc;GAEhE,IAAI,aAEF,UAAU,MAAM,SAAS,wBAAwB,aAAa;IAC5D;IACA;IACA;GACF,CAAC;QAGD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tFA,SAAS,4BAA4B,SAA0C;CAC7E,OAAO;EACL,MAAM;EACN;CACF;AACF;;;;AAKA,SAAgB,eACd,QACA,SACW;CACX,IAAI,CAAC,OAAO,cACV,OAAO;CAGT,MAAM,eAA4C,CAAC;CAEnD,KAAK,MAAM,CAAC,MAAM,SAAS,OAAO,QAAQ,OAAO,YAAY,GAC3D,IAAI,OAAO,SAAS,YAAY,UAAU,MAAM;EAC9C,IACE,KAAK,SAAS,6BACd,KAAK,SAAS,cAEd,aAAa,QAAQ;GACnB,MAAM;GACN,SAAS;IAAE,GAAG;IAAS,GAAI,KAAK;GAA+B;EACjE;OAEA,aAAa,QAAQ;CAEzB,OAAO,IAAI,OAAO,SAAS,UACzB,aAAa,QAAQ,4BAA4B;EAC/C,KAAK;EACL,GAAG;CACL,CAAC;MAGD,aAAa,QAAQ,4BAA4B;EAC/C,GAAG;EACH,GAAI;CACN,CAAC;CAIL,OAAO;EAAE,GAAG;EAAQ;CAAa;AACnC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@abapify/adt-playwright",
3
- "version": "0.4.0",
3
+ "version": "0.4.3",
4
4
  "description": "Playwright-based SSO authentication plugin for ADT client",
5
5
  "license": "MIT",
6
6
  "publishConfig": {
@@ -17,9 +17,9 @@
17
17
  "README.md"
18
18
  ],
19
19
  "dependencies": {
20
- "@abapify/adt-auth": "0.4.0",
21
- "@abapify/adt-config": "0.4.0",
22
- "@abapify/browser-auth": "0.4.0",
20
+ "@abapify/adt-auth": "0.4.3",
21
+ "@abapify/adt-config": "0.4.3",
22
+ "@abapify/browser-auth": "0.4.3",
23
23
  "playwright": "^1.57.0"
24
24
  },
25
25
  "devDependencies": {