@abapify/adt-puppeteer 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.
- package/README.md +1 -1
- package/dist/index.d.mts +68 -0
- package/dist/index.d.mts.map +1 -0
- package/dist/index.mjs +214 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +4 -4
package/README.md
CHANGED
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,68 @@
|
|
|
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/puppeteer-auth.d.ts
|
|
5
|
+
type PuppeteerCredentials = BrowserCredentials$1;
|
|
6
|
+
type PuppeteerAuthOptions = BrowserAuthOptions$1;
|
|
7
|
+
/**
|
|
8
|
+
* Puppeteer authentication object
|
|
9
|
+
*/
|
|
10
|
+
declare const puppeteerAuth: {
|
|
11
|
+
/**
|
|
12
|
+
* Authenticate using Puppeteer browser
|
|
13
|
+
*/
|
|
14
|
+
authenticate(options: PuppeteerAuthOptions): Promise<PuppeteerCredentials>;
|
|
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<PuppeteerCredentials | null>;
|
|
29
|
+
};
|
|
30
|
+
declare const puppeteer: {
|
|
31
|
+
/**
|
|
32
|
+
* Authenticate using Puppeteer browser
|
|
33
|
+
*/
|
|
34
|
+
authenticate(options: PuppeteerAuthOptions): Promise<PuppeteerCredentials>;
|
|
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<PuppeteerCredentials | null>;
|
|
49
|
+
};
|
|
50
|
+
//#endregion
|
|
51
|
+
//#region src/auth-plugin.d.ts
|
|
52
|
+
/**
|
|
53
|
+
* Standard auth plugin that conforms to AuthPluginResult interface.
|
|
54
|
+
*/
|
|
55
|
+
declare const authPlugin: AuthPlugin;
|
|
56
|
+
//#endregion
|
|
57
|
+
//#region src/index.d.ts
|
|
58
|
+
/**
|
|
59
|
+
* Plugin-level options applied to all destinations
|
|
60
|
+
*/
|
|
61
|
+
type PuppeteerPluginOptions = BrowserAuthOptions$1;
|
|
62
|
+
/**
|
|
63
|
+
* Wrap a standard config with puppeteer auth for all destinations.
|
|
64
|
+
*/
|
|
65
|
+
declare function withPuppeteer(config: AdtConfig, options?: Partial<BrowserAuthOptions$1>): AdtConfig;
|
|
66
|
+
//#endregion
|
|
67
|
+
export { type BrowserAuthOptions, type BrowserCredentials, type CookieData, type PuppeteerAuthOptions, type PuppeteerCredentials, PuppeteerPluginOptions, authPlugin, authPlugin as default, puppeteer, puppeteerAuth, toCookieHeader, toHeaders, withPuppeteer };
|
|
68
|
+
//# sourceMappingURL=index.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.mts","names":[],"sources":["../src/puppeteer-auth.ts","../src/auth-plugin.ts","../src/index.ts"],"mappings":";;;;KAeY,uBAAuB;KACvB,uBAAuB;;;;cAKtB;;;;EAKA,aAAA,SAAA,uBACR,QAAQ;;;;;;;;EAaY,QAAA;IACrB;MAAS;QAAkB,OAAO;;;MAChC,QAAQ;;cAaD;;;;EA7BA,aAAA,SAAA,uBACR,QAAQ;;;;;;;;EAaY,QAAA;IACrB;MAAS;QAAkB,OAAO;;;MAChC,QAAQ;;;;;;;cCVR,YAAY;;;;;;KCRN,yBAAyB;;;;iBAerB,cACd,QAAQ,WACR,UAAU,QAAQ,wBACjB"}
|
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,214 @@
|
|
|
1
|
+
import { authenticate, testCredentials, toCookieHeader, toHeaders } from "@abapify/browser-auth";
|
|
2
|
+
import puppeteer$1 from "puppeteer";
|
|
3
|
+
|
|
4
|
+
//#region src/adapter.ts
|
|
5
|
+
/**
|
|
6
|
+
* Puppeteer Browser Adapter
|
|
7
|
+
*
|
|
8
|
+
* Implements BrowserAdapter interface for Puppeteer.
|
|
9
|
+
* This is a thin wrapper - all auth logic is in @abapify/browser-auth.
|
|
10
|
+
*/
|
|
11
|
+
/**
|
|
12
|
+
* Convert Puppeteer 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 Puppeteer browser adapter
|
|
28
|
+
*/
|
|
29
|
+
function createPuppeteerAdapter() {
|
|
30
|
+
let browser = null;
|
|
31
|
+
let page = null;
|
|
32
|
+
let launchOptions = {};
|
|
33
|
+
const responseHandlers = [];
|
|
34
|
+
const closeHandlers = [];
|
|
35
|
+
return {
|
|
36
|
+
async launch(options) {
|
|
37
|
+
const { headless, userDataDir, ignoreHTTPSErrors, userAgent } = options;
|
|
38
|
+
launchOptions = {
|
|
39
|
+
ignoreHTTPSErrors,
|
|
40
|
+
userAgent
|
|
41
|
+
};
|
|
42
|
+
browser = await puppeteer$1.launch({
|
|
43
|
+
headless,
|
|
44
|
+
userDataDir,
|
|
45
|
+
args: userAgent ? [`--user-agent=${userAgent}`] : []
|
|
46
|
+
});
|
|
47
|
+
},
|
|
48
|
+
async newPage() {
|
|
49
|
+
if (!browser) throw new Error("Browser not launched");
|
|
50
|
+
page = await browser.newPage();
|
|
51
|
+
if (launchOptions.ignoreHTTPSErrors) await page.setBypassCSP(true);
|
|
52
|
+
page.on("response", (response) => {
|
|
53
|
+
const event = {
|
|
54
|
+
url: response.url(),
|
|
55
|
+
status: response.status()
|
|
56
|
+
};
|
|
57
|
+
responseHandlers.forEach((handler) => handler(event));
|
|
58
|
+
});
|
|
59
|
+
page.once("close", () => {
|
|
60
|
+
closeHandlers.forEach((handler) => handler());
|
|
61
|
+
});
|
|
62
|
+
},
|
|
63
|
+
async goto(url, options) {
|
|
64
|
+
if (!page) throw new Error("Page not created");
|
|
65
|
+
await page.goto(url, {
|
|
66
|
+
waitUntil: "domcontentloaded",
|
|
67
|
+
timeout: options?.timeout ?? 3e4
|
|
68
|
+
}).catch(() => {});
|
|
69
|
+
},
|
|
70
|
+
async getCookies() {
|
|
71
|
+
if (!page) throw new Error("Page not created");
|
|
72
|
+
const { cookies } = await (await page.createCDPSession()).send("Network.getAllCookies");
|
|
73
|
+
return cookies.map(convertCookie);
|
|
74
|
+
},
|
|
75
|
+
async clearCookies(domain) {
|
|
76
|
+
if (!page) throw new Error("Page not created");
|
|
77
|
+
const client = await page.createCDPSession();
|
|
78
|
+
const { cookies } = await client.send("Network.getAllCookies");
|
|
79
|
+
const toRemove = cookies.filter((c) => c.domain.includes(domain) || domain.includes(c.domain.replace(/^\./, "")));
|
|
80
|
+
for (const cookie of toRemove) await client.send("Network.deleteCookies", {
|
|
81
|
+
name: cookie.name,
|
|
82
|
+
domain: cookie.domain
|
|
83
|
+
});
|
|
84
|
+
},
|
|
85
|
+
async getUserAgent() {
|
|
86
|
+
if (!page) throw new Error("Page not created");
|
|
87
|
+
return page.evaluate(() => navigator.userAgent);
|
|
88
|
+
},
|
|
89
|
+
async closePage() {
|
|
90
|
+
if (page) {
|
|
91
|
+
await page.close();
|
|
92
|
+
page = null;
|
|
93
|
+
}
|
|
94
|
+
},
|
|
95
|
+
async close() {
|
|
96
|
+
if (browser) {
|
|
97
|
+
await browser.close();
|
|
98
|
+
browser = null;
|
|
99
|
+
}
|
|
100
|
+
},
|
|
101
|
+
onResponse(handler) {
|
|
102
|
+
responseHandlers.push(handler);
|
|
103
|
+
},
|
|
104
|
+
onPageClose(handler) {
|
|
105
|
+
closeHandlers.push(handler);
|
|
106
|
+
}
|
|
107
|
+
};
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
//#endregion
|
|
111
|
+
//#region src/puppeteer-auth.ts
|
|
112
|
+
/**
|
|
113
|
+
* Puppeteer Authentication Plugin
|
|
114
|
+
*
|
|
115
|
+
* Thin wrapper around @abapify/browser-auth core.
|
|
116
|
+
* Provides Puppeteer-specific browser adapter.
|
|
117
|
+
*/
|
|
118
|
+
/**
|
|
119
|
+
* Puppeteer authentication object
|
|
120
|
+
*/
|
|
121
|
+
const puppeteerAuth = {
|
|
122
|
+
/**
|
|
123
|
+
* Authenticate using Puppeteer browser
|
|
124
|
+
*/
|
|
125
|
+
async authenticate(options) {
|
|
126
|
+
const adapter = createPuppeteerAdapter();
|
|
127
|
+
return authenticate(adapter, options);
|
|
128
|
+
},
|
|
129
|
+
/**
|
|
130
|
+
* Test if credentials are still valid
|
|
131
|
+
*/
|
|
132
|
+
test: testCredentials,
|
|
133
|
+
/**
|
|
134
|
+
* Refresh is not reliable with Okta SSO - always return null to trigger full re-authentication
|
|
135
|
+
*/
|
|
136
|
+
async refresh(session) {
|
|
137
|
+
(session?.auth?.pluginOptions?.log ?? console.log)("🔄 Session expired, will trigger full re-authentication...");
|
|
138
|
+
return null;
|
|
139
|
+
}
|
|
140
|
+
};
|
|
141
|
+
const puppeteer = puppeteerAuth;
|
|
142
|
+
|
|
143
|
+
//#endregion
|
|
144
|
+
//#region src/auth-plugin.ts
|
|
145
|
+
/**
|
|
146
|
+
* Get earliest expiration from cookies, or default to 8 hours
|
|
147
|
+
*/
|
|
148
|
+
function getExpiresAt(cookies) {
|
|
149
|
+
const expirations = cookies.filter((c) => c.expires && c.expires > 0).map((c) => c.expires * 1e3);
|
|
150
|
+
if (expirations.length > 0) return new Date(Math.min(...expirations));
|
|
151
|
+
return new Date(Date.now() + 288e5);
|
|
152
|
+
}
|
|
153
|
+
/**
|
|
154
|
+
* Standard auth plugin that conforms to AuthPluginResult interface.
|
|
155
|
+
*/
|
|
156
|
+
const authPlugin = {
|
|
157
|
+
async authenticate(options) {
|
|
158
|
+
const credentials = await puppeteerAuth.authenticate(options);
|
|
159
|
+
return {
|
|
160
|
+
method: "cookie",
|
|
161
|
+
credentials: {
|
|
162
|
+
cookies: toCookieHeader(credentials),
|
|
163
|
+
expiresAt: getExpiresAt(credentials.cookies)
|
|
164
|
+
}
|
|
165
|
+
};
|
|
166
|
+
},
|
|
167
|
+
async refresh(_session) {
|
|
168
|
+
return null;
|
|
169
|
+
}
|
|
170
|
+
};
|
|
171
|
+
|
|
172
|
+
//#endregion
|
|
173
|
+
//#region src/index.ts
|
|
174
|
+
/**
|
|
175
|
+
* Create a puppeteer destination config
|
|
176
|
+
*/
|
|
177
|
+
function createPuppeteerDestination(options) {
|
|
178
|
+
return {
|
|
179
|
+
type: "@abapify/adt-puppeteer",
|
|
180
|
+
options
|
|
181
|
+
};
|
|
182
|
+
}
|
|
183
|
+
/**
|
|
184
|
+
* Wrap a standard config with puppeteer auth for all destinations.
|
|
185
|
+
*/
|
|
186
|
+
function withPuppeteer(config, options) {
|
|
187
|
+
if (!config.destinations) return config;
|
|
188
|
+
const destinations = {};
|
|
189
|
+
for (const [name, dest] of Object.entries(config.destinations)) if (typeof dest === "object" && "type" in dest) {
|
|
190
|
+
if (dest.type === "@abapify/adt-puppeteer" || dest.type === "puppeteer") destinations[name] = {
|
|
191
|
+
type: "@abapify/adt-puppeteer",
|
|
192
|
+
options: {
|
|
193
|
+
...options,
|
|
194
|
+
...dest.options
|
|
195
|
+
}
|
|
196
|
+
};
|
|
197
|
+
else destinations[name] = dest;
|
|
198
|
+
} else if (typeof dest === "string") destinations[name] = createPuppeteerDestination({
|
|
199
|
+
url: dest,
|
|
200
|
+
...options
|
|
201
|
+
});
|
|
202
|
+
else destinations[name] = createPuppeteerDestination({
|
|
203
|
+
...dest,
|
|
204
|
+
...options
|
|
205
|
+
});
|
|
206
|
+
return {
|
|
207
|
+
...config,
|
|
208
|
+
destinations
|
|
209
|
+
};
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
//#endregion
|
|
213
|
+
export { authPlugin, authPlugin as default, puppeteer, puppeteerAuth, toCookieHeader, toHeaders, withPuppeteer };
|
|
214
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.mjs","names":["puppeteer"],"sources":["../src/adapter.ts","../src/puppeteer-auth.ts","../src/auth-plugin.ts","../src/index.ts"],"sourcesContent":["/**\n * Puppeteer Browser Adapter\n *\n * Implements BrowserAdapter interface for Puppeteer.\n * This is a thin wrapper - all auth logic is in @abapify/browser-auth.\n */\n\nimport puppeteer from 'puppeteer';\nimport type { Browser, Page, Protocol } from 'puppeteer';\nimport type {\n BrowserAdapter,\n CookieData,\n ResponseEvent,\n} from '@abapify/browser-auth';\n\n/**\n * Convert Puppeteer cookie to CookieData\n */\nfunction convertCookie(cookie: Protocol.Network.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 Puppeteer browser adapter\n */\nexport function createPuppeteerAdapter(): BrowserAdapter {\n let browser: Browser | null = null;\n let page: Page | null = null;\n let launchOptions: { ignoreHTTPSErrors?: boolean; userAgent?: string } = {};\n\n const responseHandlers: ((event: ResponseEvent) => void)[] = [];\n const closeHandlers: (() => void)[] = [];\n\n return {\n async launch(options: {\n headless: boolean;\n userDataDir?: string;\n ignoreHTTPSErrors?: boolean;\n userAgent?: string;\n }) {\n const { headless, userDataDir, ignoreHTTPSErrors, userAgent } = options;\n launchOptions = { ignoreHTTPSErrors, userAgent };\n\n browser = await puppeteer.launch({\n headless,\n userDataDir,\n args: userAgent ? [`--user-agent=${userAgent}`] : [],\n });\n },\n\n async newPage() {\n if (!browser) throw new Error('Browser not launched');\n page = await browser.newPage();\n\n // Set page-level options\n if (launchOptions.ignoreHTTPSErrors) {\n await page.setBypassCSP(true);\n }\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: string, options?: { timeout?: number }) {\n if (!page) throw new Error('Page not created');\n await page\n .goto(url, {\n waitUntil: 'domcontentloaded',\n timeout: options?.timeout ?? 30000,\n })\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(): Promise<CookieData[]> {\n if (!page) throw new Error('Page not created');\n const client = await page.createCDPSession();\n const { cookies } = await client.send('Network.getAllCookies');\n return cookies.map(convertCookie);\n },\n\n async clearCookies(domain: string): Promise<void> {\n if (!page) throw new Error('Page not created');\n const client = await page.createCDPSession();\n const { cookies } = await client.send('Network.getAllCookies');\n const toRemove = cookies.filter(\n (c) =>\n c.domain.includes(domain) ||\n domain.includes(c.domain.replace(/^\\./, '')),\n );\n for (const cookie of toRemove) {\n await client.send('Network.deleteCookies', {\n name: cookie.name,\n domain: cookie.domain,\n });\n }\n },\n\n async getUserAgent(): Promise<string> {\n if (!page) throw new Error('Page not created');\n return page.evaluate(() => navigator.userAgent);\n },\n\n async closePage() {\n if (page) {\n await page.close();\n page = null;\n }\n },\n\n async close() {\n if (browser) {\n await browser.close();\n browser = null;\n }\n },\n\n onResponse(handler: (event: ResponseEvent) => void) {\n responseHandlers.push(handler);\n },\n\n onPageClose(handler: () => void) {\n closeHandlers.push(handler);\n },\n };\n}\n","/**\n * Puppeteer Authentication Plugin\n *\n * Thin wrapper around @abapify/browser-auth core.\n * Provides Puppeteer-specific browser adapter.\n */\n\nimport { authenticate, testCredentials } from '@abapify/browser-auth';\nimport type {\n BrowserCredentials,\n BrowserAuthOptions,\n} from '@abapify/browser-auth';\nimport { createPuppeteerAdapter } from './adapter';\n\n// Re-export types with Puppeteer-specific names for backwards compatibility\nexport type PuppeteerCredentials = BrowserCredentials;\nexport type PuppeteerAuthOptions = BrowserAuthOptions;\n\n/**\n * Puppeteer authentication object\n */\nexport const puppeteerAuth = {\n /**\n * Authenticate using Puppeteer browser\n */\n async authenticate(\n options: PuppeteerAuthOptions,\n ): Promise<PuppeteerCredentials> {\n const adapter = createPuppeteerAdapter();\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<PuppeteerCredentials | 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 puppeteer = puppeteerAuth;\nexport { toCookieHeader, toHeaders } from '@abapify/browser-auth';\n","/**\n * Standard authPlugin export for AuthManager compatibility\n *\n * Wraps puppeteerAuth to return AuthPluginResult format expected by AuthManager.\n */\n\nimport type {\n AuthPlugin,\n AuthPluginResult,\n AuthPluginOptions,\n AuthSession,\n} from '@abapify/adt-auth';\nimport { puppeteerAuth, toCookieHeader } from './puppeteer-auth';\n\n/**\n * Get earliest expiration from cookies, or default to 8 hours\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); // Convert seconds to ms\n\n if (expirations.length > 0) {\n return new Date(Math.min(...expirations));\n }\n // Default fallback if no expiration set\n return new Date(Date.now() + 8 * 60 * 60 * 1000);\n}\n\n/**\n * Standard auth plugin that conforms to AuthPluginResult interface.\n */\nconst authPlugin: AuthPlugin = {\n async authenticate(options: AuthPluginOptions): Promise<AuthPluginResult> {\n const credentials = await puppeteerAuth.authenticate(options);\n const cookieString = toCookieHeader(credentials);\n\n return {\n method: 'cookie',\n credentials: {\n cookies: cookieString,\n expiresAt: getExpiresAt(credentials.cookies),\n },\n };\n },\n\n async refresh(_session: AuthSession): Promise<AuthPluginResult | null> {\n // Don't try to refresh - Okta SSO cookies can't be silently refreshed\n return null;\n },\n};\n\nexport default authPlugin;\n","/**\n * @abapify/adt-puppeteer\n *\n * Puppeteer-based SSO authentication plugin for ADT client.\n * Uses @abapify/browser-auth core with Puppeteer 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 PuppeteerCredentials,\n PuppeteerAuthOptions,\n} from './puppeteer-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 PuppeteerPluginOptions = BrowserAuthOptions;\n\n/**\n * Create a puppeteer destination config\n */\nfunction createPuppeteerDestination(options: BrowserAuthOptions): Destination {\n return {\n type: '@abapify/adt-puppeteer',\n options,\n };\n}\n\n/**\n * Wrap a standard config with puppeteer auth for all destinations.\n */\nexport function withPuppeteer(\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 (dest.type === '@abapify/adt-puppeteer' || dest.type === 'puppeteer') {\n destinations[name] = {\n type: '@abapify/adt-puppeteer',\n options: { ...options, ...(dest.options as BrowserAuthOptions) },\n };\n } else {\n destinations[name] = dest;\n }\n } else if (typeof dest === 'string') {\n destinations[name] = createPuppeteerDestination({\n url: dest,\n ...options,\n });\n } else {\n destinations[name] = createPuppeteerDestination({\n ...(dest as BrowserAuthOptions),\n ...options,\n });\n }\n }\n\n return { ...config, destinations };\n}\n\n// Main exports\nexport {\n puppeteerAuth,\n puppeteer,\n toCookieHeader,\n toHeaders,\n} from './puppeteer-auth';\n\n// AuthManager compatibility exports\nexport { default } from './auth-plugin';\nexport { default as authPlugin } from './auth-plugin';\n"],"mappings":";;;;;;;;;;;;;AAkBA,SAAS,cAAc,QAA6C;CAClE,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,yBAAyC;CACvD,IAAI,UAA0B;CAC9B,IAAI,OAAoB;CACxB,IAAI,gBAAqE,CAAC;CAE1E,MAAM,mBAAuD,CAAC;CAC9D,MAAM,gBAAgC,CAAC;CAEvC,OAAO;EACL,MAAM,OAAO,SAKV;GACD,MAAM,EAAE,UAAU,aAAa,mBAAmB,cAAc;GAChE,gBAAgB;IAAE;IAAmB;GAAU;GAE/C,UAAU,MAAMA,YAAU,OAAO;IAC/B;IACA;IACA,MAAM,YAAY,CAAC,gBAAgB,WAAW,IAAI,CAAC;GACrD,CAAC;E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B,cACd,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,IAAI,KAAK,SAAS,4BAA4B,KAAK,SAAS,aAC1D,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,2BAA2B;EAC9C,KAAK;EACL,GAAG;CACL,CAAC;MAED,aAAa,QAAQ,2BAA2B;EAC9C,GAAI;EACJ,GAAG;CACL,CAAC;CAIL,OAAO;EAAE,GAAG;EAAQ;CAAa;AACnC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@abapify/adt-puppeteer",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.3",
|
|
4
4
|
"description": "Puppeteer-based authentication for SAP ADT (SSO/IDP)",
|
|
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.
|
|
21
|
-
"@abapify/adt-config": "0.4.
|
|
22
|
-
"@abapify/browser-auth": "0.4.
|
|
20
|
+
"@abapify/adt-auth": "0.4.3",
|
|
21
|
+
"@abapify/adt-config": "0.4.3",
|
|
22
|
+
"@abapify/browser-auth": "0.4.3",
|
|
23
23
|
"puppeteer": "^24.0.0"
|
|
24
24
|
},
|
|
25
25
|
"peerDependencies": {
|