@commercetools-frontend/mc-scripts 25.1.0 → 26.0.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/cli/dist/commercetools-frontend-mc-scripts-cli.cjs.dev.js +20 -7
- package/cli/dist/commercetools-frontend-mc-scripts-cli.cjs.prod.js +20 -7
- package/cli/dist/commercetools-frontend-mc-scripts-cli.esm.js +20 -7
- package/dist/{build-0a5986d1.cjs.dev.js → build-201624d0.cjs.dev.js} +4 -4
- package/dist/{build-dbcd0936.esm.js → build-607506eb.esm.js} +4 -4
- package/dist/{build-ec10df64.cjs.prod.js → build-c3b700bd.cjs.prod.js} +4 -4
- package/dist/{build-vite-16b1a575.cjs.dev.js → build-vite-837e7c94.cjs.dev.js} +56 -34
- package/dist/{build-vite-59e1f185.esm.js → build-vite-8cae71a0.esm.js} +53 -15
- package/dist/{build-vite-5d317720.cjs.prod.js → build-vite-b007241b.cjs.prod.js} +56 -34
- package/dist/commercetools-frontend-mc-scripts.cjs.dev.js +1 -1
- package/dist/commercetools-frontend-mc-scripts.cjs.prod.js +1 -1
- package/dist/commercetools-frontend-mc-scripts.esm.js +1 -1
- package/dist/config-sync-32b19a2a.cjs.dev.js +265 -0
- package/dist/config-sync-57743d92.esm.js +255 -0
- package/dist/config-sync-c3fb301b.cjs.prod.js +265 -0
- package/dist/config-sync-ci-2823fd2e.cjs.prod.js +305 -0
- package/dist/config-sync-ci-8a073525.cjs.dev.js +305 -0
- package/dist/config-sync-ci-fb0d5c7e.esm.js +294 -0
- package/dist/{config-sync-e7f53a98.esm.js → config-sync-helpers-17f05f8f.esm.js} +154 -283
- package/dist/{config-sync-ce05c66c.cjs.prod.js → config-sync-helpers-2239c279.cjs.prod.js} +162 -287
- package/dist/{config-sync-dbb43993.cjs.dev.js → config-sync-helpers-9bd96619.cjs.dev.js} +162 -287
- package/dist/{create-postcss-config-0a86560d.esm.js → create-postcss-config-6c26f1d5.esm.js} +1 -1
- package/dist/{create-postcss-config-381b636b.cjs.dev.js → create-postcss-config-73d94525.cjs.dev.js} +1 -1
- package/dist/{create-postcss-config-91c09596.cjs.prod.js → create-postcss-config-929430f6.cjs.prod.js} +1 -1
- package/dist/{create-webpack-config-for-development-488742b2.cjs.dev.js → create-webpack-config-for-development-3a6f3fac.cjs.dev.js} +2 -2
- package/dist/{create-webpack-config-for-development-37677a49.cjs.prod.js → create-webpack-config-for-development-4749aed7.cjs.prod.js} +2 -2
- package/dist/{create-webpack-config-for-development-df3f7f7f.esm.js → create-webpack-config-for-development-fb17e299.esm.js} +2 -2
- package/dist/{create-webpack-config-for-production-e22f78d2.esm.js → create-webpack-config-for-production-23f194fc.esm.js} +14 -14
- package/dist/{create-webpack-config-for-production-46d817cc.cjs.dev.js → create-webpack-config-for-production-b836a125.cjs.dev.js} +15 -15
- package/dist/{create-webpack-config-for-production-aad64e2a.cjs.prod.js → create-webpack-config-for-production-ee70e601.cjs.prod.js} +15 -15
- package/dist/{credentials-storage-0b89aa0e.cjs.prod.js → credentials-storage-6d592cd6.cjs.prod.js} +20 -2
- package/dist/{credentials-storage-cbb5c559.cjs.dev.js → credentials-storage-c4c5980e.cjs.dev.js} +20 -2
- package/dist/{credentials-storage-4464313c.esm.js → credentials-storage-fcc77fb6.esm.js} +20 -2
- package/dist/declarations/src/types.d.ts +4 -0
- package/dist/{deployment-previews-set-636fb1a3.cjs.prod.js → deployment-previews-set-46172936.cjs.prod.js} +3 -3
- package/dist/{deployment-previews-set-4edd48db.cjs.dev.js → deployment-previews-set-50752e76.cjs.dev.js} +3 -3
- package/dist/{deployment-previews-set-bbef95d2.esm.js → deployment-previews-set-e2c508a2.esm.js} +3 -3
- package/dist/{graphql-requests-23f7ddb1.cjs.dev.js → graphql-requests-79116775.cjs.dev.js} +2 -2
- package/dist/{graphql-requests-0a6eeb3a.cjs.prod.js → graphql-requests-9d9289e2.cjs.prod.js} +2 -2
- package/dist/{graphql-requests-14074b2b.esm.js → graphql-requests-c56947a9.esm.js} +3 -3
- package/dist/{login-a6fd5fbf.cjs.dev.js → login-2ae319b6.cjs.dev.js} +130 -11
- package/dist/{login-1b222f33.esm.js → login-66cf38b8.esm.js} +127 -10
- package/dist/{login-54ebae96.cjs.prod.js → login-fc126950.cjs.prod.js} +130 -11
- package/dist/{package-a34835d9.esm.js → package-0974229d.esm.js} +21 -11
- package/dist/{package-e1f7242c.cjs.prod.js → package-8d902e4f.cjs.dev.js} +21 -11
- package/dist/{package-d8b1f4c0.cjs.dev.js → package-f3555da1.cjs.prod.js} +21 -11
- package/dist/{start-0be8a294.cjs.prod.js → start-6233d44d.cjs.prod.js} +3 -3
- package/dist/{start-890895df.esm.js → start-6406e20a.esm.js} +3 -3
- package/dist/{start-37ec4a7e.cjs.dev.js → start-94c67c51.cjs.dev.js} +3 -3
- package/package.json +21 -11
- package/postcss/dist/commercetools-frontend-mc-scripts-postcss.cjs.dev.js +2 -2
- package/postcss/dist/commercetools-frontend-mc-scripts-postcss.cjs.prod.js +2 -2
- package/postcss/dist/commercetools-frontend-mc-scripts-postcss.esm.js +2 -2
- package/webpack/dist/commercetools-frontend-mc-scripts-webpack.cjs.dev.js +4 -4
- package/webpack/dist/commercetools-frontend-mc-scripts-webpack.cjs.prod.js +4 -4
- package/webpack/dist/commercetools-frontend-mc-scripts-webpack.esm.js +4 -4
package/dist/{graphql-requests-0a6eeb3a.cjs.prod.js → graphql-requests-9d9289e2.cjs.prod.js}
RENAMED
|
@@ -14,9 +14,9 @@ var chalk = require('chalk');
|
|
|
14
14
|
var graphql = require('graphql');
|
|
15
15
|
var graphqlRequest = require('graphql-request');
|
|
16
16
|
var constants = require('@commercetools-frontend/constants');
|
|
17
|
-
var credentialsStorage$1 = require('./credentials-storage-
|
|
17
|
+
var credentialsStorage$1 = require('./credentials-storage-6d592cd6.cjs.prod.js');
|
|
18
18
|
var createHttpUserAgent = require('@commercetools/http-user-agent');
|
|
19
|
-
var _package = require('./package-
|
|
19
|
+
var _package = require('./package-f3555da1.cjs.prod.js');
|
|
20
20
|
|
|
21
21
|
function _interopDefault (e) { return e && e.__esModule ? e : { 'default': e }; }
|
|
22
22
|
|
|
@@ -12,9 +12,9 @@ import chalk from 'chalk';
|
|
|
12
12
|
import { print } from 'graphql';
|
|
13
13
|
import { GraphQLClient, ClientError } from 'graphql-request';
|
|
14
14
|
import { GRAPHQL_TARGETS, SUPPORTED_HEADERS } from '@commercetools-frontend/constants';
|
|
15
|
-
import { C as CredentialsStorage } from './credentials-storage-
|
|
15
|
+
import { C as CredentialsStorage } from './credentials-storage-fcc77fb6.esm.js';
|
|
16
16
|
import createHttpUserAgent from '@commercetools/http-user-agent';
|
|
17
|
-
import { p as pkgJson } from './package-
|
|
17
|
+
import { p as pkgJson } from './package-0974229d.esm.js';
|
|
18
18
|
|
|
19
19
|
const userAgent = createHttpUserAgent({
|
|
20
20
|
name: 'graphql-request',
|
|
@@ -252,4 +252,4 @@ const updateCustomApplicationDeploymentPreview = async _ref9 => {
|
|
|
252
252
|
return updatedDeploymentPreviewResult.updateCustomApplicationDeploymentPreview;
|
|
253
253
|
};
|
|
254
254
|
|
|
255
|
-
export {
|
|
255
|
+
export { createCustomView as a, updateCustomView as b, createCustomApplication as c, fetchCustomApplication as d, fetchCustomView as e, fetchUserOrganizations as f, updateCustomApplicationDeploymentPreview as g, createCustomApplicationDeploymentPreview as h, updateCustomApplication as u };
|
|
@@ -6,21 +6,22 @@ var _startsWithInstanceProperty = require('@babel/runtime-corejs3/core-js-stable
|
|
|
6
6
|
var _bindInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/bind');
|
|
7
7
|
var _trimInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/trim');
|
|
8
8
|
var _flatMapInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/flat-map');
|
|
9
|
+
var _setTimeout = require('@babel/runtime-corejs3/core-js-stable/set-timeout');
|
|
10
|
+
var _Date$now = require('@babel/runtime-corejs3/core-js-stable/date/now');
|
|
11
|
+
var _includesInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/includes');
|
|
9
12
|
var _forEachInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/for-each');
|
|
10
13
|
var _URL = require('@babel/runtime-corejs3/core-js-stable/url');
|
|
11
14
|
var crypto = require('node:crypto');
|
|
12
15
|
var process = require('node:process');
|
|
13
16
|
var chalk = require('chalk');
|
|
14
17
|
var applicationConfig = require('@commercetools-frontend/application-config');
|
|
15
|
-
var _package = require('./package-
|
|
16
|
-
var _includesInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/includes');
|
|
18
|
+
var _package = require('./package-8d902e4f.cjs.dev.js');
|
|
17
19
|
var http = require('node:http');
|
|
18
20
|
var jwtDecode = require('jwt-decode');
|
|
19
|
-
var credentialsStorage$1 = require('./credentials-storage-
|
|
21
|
+
var credentialsStorage$1 = require('./credentials-storage-c4c5980e.cjs.dev.js');
|
|
20
22
|
require('@babel/runtime-corejs3/helpers/classCallCheck');
|
|
21
23
|
require('@babel/runtime-corejs3/helpers/createClass');
|
|
22
24
|
require('@babel/runtime-corejs3/core-js-stable/json/stringify');
|
|
23
|
-
require('@babel/runtime-corejs3/core-js-stable/date/now');
|
|
24
25
|
require('node:fs');
|
|
25
26
|
require('node:os');
|
|
26
27
|
require('node:path');
|
|
@@ -52,12 +53,14 @@ var _startsWithInstanceProperty__default = /*#__PURE__*/_interopDefault(_startsW
|
|
|
52
53
|
var _bindInstanceProperty__default = /*#__PURE__*/_interopDefault(_bindInstanceProperty);
|
|
53
54
|
var _trimInstanceProperty__default = /*#__PURE__*/_interopDefault(_trimInstanceProperty);
|
|
54
55
|
var _flatMapInstanceProperty__default = /*#__PURE__*/_interopDefault(_flatMapInstanceProperty);
|
|
56
|
+
var _setTimeout__default = /*#__PURE__*/_interopDefault(_setTimeout);
|
|
57
|
+
var _Date$now__default = /*#__PURE__*/_interopDefault(_Date$now);
|
|
58
|
+
var _includesInstanceProperty__default = /*#__PURE__*/_interopDefault(_includesInstanceProperty);
|
|
55
59
|
var _forEachInstanceProperty__default = /*#__PURE__*/_interopDefault(_forEachInstanceProperty);
|
|
56
60
|
var _URL__default = /*#__PURE__*/_interopDefault(_URL);
|
|
57
61
|
var crypto__default = /*#__PURE__*/_interopDefault(crypto);
|
|
58
62
|
var process__default = /*#__PURE__*/_interopDefault(process);
|
|
59
63
|
var chalk__default = /*#__PURE__*/_interopDefault(chalk);
|
|
60
|
-
var _includesInstanceProperty__default = /*#__PURE__*/_interopDefault(_includesInstanceProperty);
|
|
61
64
|
var http__default = /*#__PURE__*/_interopDefault(http);
|
|
62
65
|
var jwtDecode__default = /*#__PURE__*/_interopDefault(jwtDecode);
|
|
63
66
|
|
|
@@ -205,6 +208,116 @@ const generateRandomHash = function () {
|
|
|
205
208
|
let length = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 16;
|
|
206
209
|
return crypto__default["default"].randomBytes(length).toString('hex');
|
|
207
210
|
};
|
|
211
|
+
|
|
212
|
+
/**
|
|
213
|
+
* Performs headless login using Puppeteer.
|
|
214
|
+
* Requires IDENTITY_EMAIL and IDENTITY_PASSWORD environment variables.
|
|
215
|
+
*/
|
|
216
|
+
async function runHeadlessLogin(authUrl) {
|
|
217
|
+
const email = process__default["default"].env.IDENTITY_EMAIL;
|
|
218
|
+
const password = process__default["default"].env.IDENTITY_PASSWORD;
|
|
219
|
+
if (!email || !password) {
|
|
220
|
+
throw new Error('Headless login requires IDENTITY_EMAIL and IDENTITY_PASSWORD environment variables');
|
|
221
|
+
}
|
|
222
|
+
let puppeteer;
|
|
223
|
+
try {
|
|
224
|
+
puppeteer = await Promise.resolve().then(function () { return /*#__PURE__*/_interopNamespace(require('puppeteer')); });
|
|
225
|
+
} catch {
|
|
226
|
+
throw new Error('Puppeteer is required for headless login. Install it with: npm install puppeteer');
|
|
227
|
+
}
|
|
228
|
+
const browser = await puppeteer.default.launch({
|
|
229
|
+
headless: 'new',
|
|
230
|
+
args: ['--no-sandbox', '--disable-setuid-sandbox']
|
|
231
|
+
});
|
|
232
|
+
try {
|
|
233
|
+
const page = await browser.newPage();
|
|
234
|
+
await page.goto(authUrl.toString(), {
|
|
235
|
+
waitUntil: 'networkidle2'
|
|
236
|
+
});
|
|
237
|
+
|
|
238
|
+
// Wait for the login page to load
|
|
239
|
+
await page.waitForSelector('input[name="identifier"]', {
|
|
240
|
+
timeout: 30000
|
|
241
|
+
});
|
|
242
|
+
|
|
243
|
+
// Dismiss cookie banner if present
|
|
244
|
+
// Note: Using string-based evaluate to avoid bundler transforming Array.from
|
|
245
|
+
try {
|
|
246
|
+
await page.evaluate(`
|
|
247
|
+
(function() {
|
|
248
|
+
var buttons = Array.from(document.querySelectorAll('button'));
|
|
249
|
+
var acceptBtn = buttons.find(function(btn) {
|
|
250
|
+
return btn.textContent && btn.textContent.includes('Accept all cookies');
|
|
251
|
+
});
|
|
252
|
+
if (acceptBtn) acceptBtn.click();
|
|
253
|
+
})()
|
|
254
|
+
`);
|
|
255
|
+
await new _Promise__default["default"](resolve => _setTimeout__default["default"](resolve, 500));
|
|
256
|
+
} catch {
|
|
257
|
+
// Cookie banner not found or already dismissed
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
// Fill in email
|
|
261
|
+
await page.type('input[name="identifier"]', email);
|
|
262
|
+
await new _Promise__default["default"](resolve => _setTimeout__default["default"](resolve, 500));
|
|
263
|
+
|
|
264
|
+
// Click "Next" button
|
|
265
|
+
await page.evaluate(`
|
|
266
|
+
(function() {
|
|
267
|
+
var buttons = Array.from(document.querySelectorAll('button'));
|
|
268
|
+
var nextBtn = buttons.find(function(btn) {
|
|
269
|
+
return btn.textContent && btn.textContent.toLowerCase().includes('next');
|
|
270
|
+
});
|
|
271
|
+
if (nextBtn) nextBtn.click();
|
|
272
|
+
})()
|
|
273
|
+
`);
|
|
274
|
+
|
|
275
|
+
// Wait for password field
|
|
276
|
+
await page.waitForSelector('input[name="password"]', {
|
|
277
|
+
visible: true,
|
|
278
|
+
timeout: 30000
|
|
279
|
+
});
|
|
280
|
+
|
|
281
|
+
// Fill in password
|
|
282
|
+
await page.type('input[name="password"]', password);
|
|
283
|
+
await new _Promise__default["default"](resolve => _setTimeout__default["default"](resolve, 500));
|
|
284
|
+
|
|
285
|
+
// Click "Submit" button
|
|
286
|
+
await page.evaluate(`
|
|
287
|
+
(function() {
|
|
288
|
+
var buttons = Array.from(document.querySelectorAll('button'));
|
|
289
|
+
var submitBtn = buttons.find(function(btn) {
|
|
290
|
+
return btn.textContent && btn.textContent.toLowerCase().includes('submit');
|
|
291
|
+
});
|
|
292
|
+
if (submitBtn) submitBtn.click();
|
|
293
|
+
})()
|
|
294
|
+
`);
|
|
295
|
+
|
|
296
|
+
// Wait for the callback to be processed (the server will close and exit)
|
|
297
|
+
// We just need to keep the browser alive until the redirect happens
|
|
298
|
+
const startTime = _Date$now__default["default"]();
|
|
299
|
+
const timeout = 60000;
|
|
300
|
+
while (_Date$now__default["default"]() - startTime < timeout) {
|
|
301
|
+
await new _Promise__default["default"](resolve => _setTimeout__default["default"](resolve, 500));
|
|
302
|
+
const currentUrl = page.url();
|
|
303
|
+
if (_includesInstanceProperty__default["default"](currentUrl).call(currentUrl, 'sessionToken=')) {
|
|
304
|
+
// Token was captured by the callback server, we can exit
|
|
305
|
+
break;
|
|
306
|
+
}
|
|
307
|
+
const pageContent = await page.content();
|
|
308
|
+
if (_includesInstanceProperty__default["default"](pageContent).call(pageContent, 'Invalid credentials') || _includesInstanceProperty__default["default"](pageContent).call(pageContent, 'invalid_grant')) {
|
|
309
|
+
throw new Error('Invalid credentials');
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
// Check if page shows success (callback server response)
|
|
313
|
+
if (_includesInstanceProperty__default["default"](pageContent).call(pageContent, 'Success!')) {
|
|
314
|
+
break;
|
|
315
|
+
}
|
|
316
|
+
}
|
|
317
|
+
} finally {
|
|
318
|
+
await browser.close();
|
|
319
|
+
}
|
|
320
|
+
}
|
|
208
321
|
async function run(options) {
|
|
209
322
|
const mcApiUrl = await resolveMcApiUrl(options);
|
|
210
323
|
if (!mcApiUrl) {
|
|
@@ -246,12 +359,18 @@ async function run(options) {
|
|
|
246
359
|
}
|
|
247
360
|
});
|
|
248
361
|
await startServer(server);
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
362
|
+
if (options.headless) {
|
|
363
|
+
console.log(`Initiating headless authentication flow using Puppeteer...`);
|
|
364
|
+
console.log();
|
|
365
|
+
await runHeadlessLogin(authUrl);
|
|
366
|
+
} else {
|
|
367
|
+
console.log(`Initiating the OIDC authentication flow, opening the login page in your browser...`);
|
|
368
|
+
console.log(` ${authUrl}`);
|
|
369
|
+
console.log();
|
|
370
|
+
const open = await Promise.resolve().then(function () { return /*#__PURE__*/_interopNamespace(require('open')); });
|
|
371
|
+
await open.default(authUrl.toString());
|
|
372
|
+
console.log('Waiting for the OIDC authentication to complete...');
|
|
373
|
+
}
|
|
255
374
|
}
|
|
256
375
|
|
|
257
376
|
exports["default"] = run;
|
|
@@ -4,21 +4,22 @@ import _startsWithInstanceProperty from '@babel/runtime-corejs3/core-js-stable/i
|
|
|
4
4
|
import _bindInstanceProperty from '@babel/runtime-corejs3/core-js-stable/instance/bind';
|
|
5
5
|
import _trimInstanceProperty from '@babel/runtime-corejs3/core-js-stable/instance/trim';
|
|
6
6
|
import _flatMapInstanceProperty from '@babel/runtime-corejs3/core-js-stable/instance/flat-map';
|
|
7
|
+
import _setTimeout from '@babel/runtime-corejs3/core-js-stable/set-timeout';
|
|
8
|
+
import _Date$now from '@babel/runtime-corejs3/core-js-stable/date/now';
|
|
9
|
+
import _includesInstanceProperty from '@babel/runtime-corejs3/core-js-stable/instance/includes';
|
|
7
10
|
import _forEachInstanceProperty from '@babel/runtime-corejs3/core-js-stable/instance/for-each';
|
|
8
11
|
import _URL from '@babel/runtime-corejs3/core-js-stable/url';
|
|
9
12
|
import crypto from 'node:crypto';
|
|
10
13
|
import process, { exit } from 'node:process';
|
|
11
14
|
import chalk from 'chalk';
|
|
12
15
|
import { processConfig } from '@commercetools-frontend/application-config';
|
|
13
|
-
import { p as pkgJson } from './package-
|
|
14
|
-
import _includesInstanceProperty from '@babel/runtime-corejs3/core-js-stable/instance/includes';
|
|
16
|
+
import { p as pkgJson } from './package-0974229d.esm.js';
|
|
15
17
|
import http from 'node:http';
|
|
16
18
|
import jwtDecode from 'jwt-decode';
|
|
17
|
-
import { C as CredentialsStorage } from './credentials-storage-
|
|
19
|
+
import { C as CredentialsStorage } from './credentials-storage-fcc77fb6.esm.js';
|
|
18
20
|
import '@babel/runtime-corejs3/helpers/classCallCheck';
|
|
19
21
|
import '@babel/runtime-corejs3/helpers/createClass';
|
|
20
22
|
import '@babel/runtime-corejs3/core-js-stable/json/stringify';
|
|
21
|
-
import '@babel/runtime-corejs3/core-js-stable/date/now';
|
|
22
23
|
import 'node:fs';
|
|
23
24
|
import 'node:os';
|
|
24
25
|
import 'node:path';
|
|
@@ -168,6 +169,116 @@ const generateRandomHash = function () {
|
|
|
168
169
|
let length = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 16;
|
|
169
170
|
return crypto.randomBytes(length).toString('hex');
|
|
170
171
|
};
|
|
172
|
+
|
|
173
|
+
/**
|
|
174
|
+
* Performs headless login using Puppeteer.
|
|
175
|
+
* Requires IDENTITY_EMAIL and IDENTITY_PASSWORD environment variables.
|
|
176
|
+
*/
|
|
177
|
+
async function runHeadlessLogin(authUrl) {
|
|
178
|
+
const email = process.env.IDENTITY_EMAIL;
|
|
179
|
+
const password = process.env.IDENTITY_PASSWORD;
|
|
180
|
+
if (!email || !password) {
|
|
181
|
+
throw new Error('Headless login requires IDENTITY_EMAIL and IDENTITY_PASSWORD environment variables');
|
|
182
|
+
}
|
|
183
|
+
let puppeteer;
|
|
184
|
+
try {
|
|
185
|
+
puppeteer = await import('puppeteer');
|
|
186
|
+
} catch {
|
|
187
|
+
throw new Error('Puppeteer is required for headless login. Install it with: npm install puppeteer');
|
|
188
|
+
}
|
|
189
|
+
const browser = await puppeteer.default.launch({
|
|
190
|
+
headless: 'new',
|
|
191
|
+
args: ['--no-sandbox', '--disable-setuid-sandbox']
|
|
192
|
+
});
|
|
193
|
+
try {
|
|
194
|
+
const page = await browser.newPage();
|
|
195
|
+
await page.goto(authUrl.toString(), {
|
|
196
|
+
waitUntil: 'networkidle2'
|
|
197
|
+
});
|
|
198
|
+
|
|
199
|
+
// Wait for the login page to load
|
|
200
|
+
await page.waitForSelector('input[name="identifier"]', {
|
|
201
|
+
timeout: 30000
|
|
202
|
+
});
|
|
203
|
+
|
|
204
|
+
// Dismiss cookie banner if present
|
|
205
|
+
// Note: Using string-based evaluate to avoid bundler transforming Array.from
|
|
206
|
+
try {
|
|
207
|
+
await page.evaluate(`
|
|
208
|
+
(function() {
|
|
209
|
+
var buttons = Array.from(document.querySelectorAll('button'));
|
|
210
|
+
var acceptBtn = buttons.find(function(btn) {
|
|
211
|
+
return btn.textContent && btn.textContent.includes('Accept all cookies');
|
|
212
|
+
});
|
|
213
|
+
if (acceptBtn) acceptBtn.click();
|
|
214
|
+
})()
|
|
215
|
+
`);
|
|
216
|
+
await new _Promise(resolve => _setTimeout(resolve, 500));
|
|
217
|
+
} catch {
|
|
218
|
+
// Cookie banner not found or already dismissed
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
// Fill in email
|
|
222
|
+
await page.type('input[name="identifier"]', email);
|
|
223
|
+
await new _Promise(resolve => _setTimeout(resolve, 500));
|
|
224
|
+
|
|
225
|
+
// Click "Next" button
|
|
226
|
+
await page.evaluate(`
|
|
227
|
+
(function() {
|
|
228
|
+
var buttons = Array.from(document.querySelectorAll('button'));
|
|
229
|
+
var nextBtn = buttons.find(function(btn) {
|
|
230
|
+
return btn.textContent && btn.textContent.toLowerCase().includes('next');
|
|
231
|
+
});
|
|
232
|
+
if (nextBtn) nextBtn.click();
|
|
233
|
+
})()
|
|
234
|
+
`);
|
|
235
|
+
|
|
236
|
+
// Wait for password field
|
|
237
|
+
await page.waitForSelector('input[name="password"]', {
|
|
238
|
+
visible: true,
|
|
239
|
+
timeout: 30000
|
|
240
|
+
});
|
|
241
|
+
|
|
242
|
+
// Fill in password
|
|
243
|
+
await page.type('input[name="password"]', password);
|
|
244
|
+
await new _Promise(resolve => _setTimeout(resolve, 500));
|
|
245
|
+
|
|
246
|
+
// Click "Submit" button
|
|
247
|
+
await page.evaluate(`
|
|
248
|
+
(function() {
|
|
249
|
+
var buttons = Array.from(document.querySelectorAll('button'));
|
|
250
|
+
var submitBtn = buttons.find(function(btn) {
|
|
251
|
+
return btn.textContent && btn.textContent.toLowerCase().includes('submit');
|
|
252
|
+
});
|
|
253
|
+
if (submitBtn) submitBtn.click();
|
|
254
|
+
})()
|
|
255
|
+
`);
|
|
256
|
+
|
|
257
|
+
// Wait for the callback to be processed (the server will close and exit)
|
|
258
|
+
// We just need to keep the browser alive until the redirect happens
|
|
259
|
+
const startTime = _Date$now();
|
|
260
|
+
const timeout = 60000;
|
|
261
|
+
while (_Date$now() - startTime < timeout) {
|
|
262
|
+
await new _Promise(resolve => _setTimeout(resolve, 500));
|
|
263
|
+
const currentUrl = page.url();
|
|
264
|
+
if (_includesInstanceProperty(currentUrl).call(currentUrl, 'sessionToken=')) {
|
|
265
|
+
// Token was captured by the callback server, we can exit
|
|
266
|
+
break;
|
|
267
|
+
}
|
|
268
|
+
const pageContent = await page.content();
|
|
269
|
+
if (_includesInstanceProperty(pageContent).call(pageContent, 'Invalid credentials') || _includesInstanceProperty(pageContent).call(pageContent, 'invalid_grant')) {
|
|
270
|
+
throw new Error('Invalid credentials');
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
// Check if page shows success (callback server response)
|
|
274
|
+
if (_includesInstanceProperty(pageContent).call(pageContent, 'Success!')) {
|
|
275
|
+
break;
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
} finally {
|
|
279
|
+
await browser.close();
|
|
280
|
+
}
|
|
281
|
+
}
|
|
171
282
|
async function run(options) {
|
|
172
283
|
const mcApiUrl = await resolveMcApiUrl(options);
|
|
173
284
|
if (!mcApiUrl) {
|
|
@@ -209,12 +320,18 @@ async function run(options) {
|
|
|
209
320
|
}
|
|
210
321
|
});
|
|
211
322
|
await startServer(server);
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
323
|
+
if (options.headless) {
|
|
324
|
+
console.log(`Initiating headless authentication flow using Puppeteer...`);
|
|
325
|
+
console.log();
|
|
326
|
+
await runHeadlessLogin(authUrl);
|
|
327
|
+
} else {
|
|
328
|
+
console.log(`Initiating the OIDC authentication flow, opening the login page in your browser...`);
|
|
329
|
+
console.log(` ${authUrl}`);
|
|
330
|
+
console.log();
|
|
331
|
+
const open = await import('open');
|
|
332
|
+
await open.default(authUrl.toString());
|
|
333
|
+
console.log('Waiting for the OIDC authentication to complete...');
|
|
334
|
+
}
|
|
218
335
|
}
|
|
219
336
|
|
|
220
337
|
export { run as default };
|
|
@@ -6,21 +6,22 @@ var _startsWithInstanceProperty = require('@babel/runtime-corejs3/core-js-stable
|
|
|
6
6
|
var _bindInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/bind');
|
|
7
7
|
var _trimInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/trim');
|
|
8
8
|
var _flatMapInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/flat-map');
|
|
9
|
+
var _setTimeout = require('@babel/runtime-corejs3/core-js-stable/set-timeout');
|
|
10
|
+
var _Date$now = require('@babel/runtime-corejs3/core-js-stable/date/now');
|
|
11
|
+
var _includesInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/includes');
|
|
9
12
|
var _forEachInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/for-each');
|
|
10
13
|
var _URL = require('@babel/runtime-corejs3/core-js-stable/url');
|
|
11
14
|
var crypto = require('node:crypto');
|
|
12
15
|
var process = require('node:process');
|
|
13
16
|
var chalk = require('chalk');
|
|
14
17
|
var applicationConfig = require('@commercetools-frontend/application-config');
|
|
15
|
-
var _package = require('./package-
|
|
16
|
-
var _includesInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/includes');
|
|
18
|
+
var _package = require('./package-f3555da1.cjs.prod.js');
|
|
17
19
|
var http = require('node:http');
|
|
18
20
|
var jwtDecode = require('jwt-decode');
|
|
19
|
-
var credentialsStorage$1 = require('./credentials-storage-
|
|
21
|
+
var credentialsStorage$1 = require('./credentials-storage-6d592cd6.cjs.prod.js');
|
|
20
22
|
require('@babel/runtime-corejs3/helpers/classCallCheck');
|
|
21
23
|
require('@babel/runtime-corejs3/helpers/createClass');
|
|
22
24
|
require('@babel/runtime-corejs3/core-js-stable/json/stringify');
|
|
23
|
-
require('@babel/runtime-corejs3/core-js-stable/date/now');
|
|
24
25
|
require('node:fs');
|
|
25
26
|
require('node:os');
|
|
26
27
|
require('node:path');
|
|
@@ -52,12 +53,14 @@ var _startsWithInstanceProperty__default = /*#__PURE__*/_interopDefault(_startsW
|
|
|
52
53
|
var _bindInstanceProperty__default = /*#__PURE__*/_interopDefault(_bindInstanceProperty);
|
|
53
54
|
var _trimInstanceProperty__default = /*#__PURE__*/_interopDefault(_trimInstanceProperty);
|
|
54
55
|
var _flatMapInstanceProperty__default = /*#__PURE__*/_interopDefault(_flatMapInstanceProperty);
|
|
56
|
+
var _setTimeout__default = /*#__PURE__*/_interopDefault(_setTimeout);
|
|
57
|
+
var _Date$now__default = /*#__PURE__*/_interopDefault(_Date$now);
|
|
58
|
+
var _includesInstanceProperty__default = /*#__PURE__*/_interopDefault(_includesInstanceProperty);
|
|
55
59
|
var _forEachInstanceProperty__default = /*#__PURE__*/_interopDefault(_forEachInstanceProperty);
|
|
56
60
|
var _URL__default = /*#__PURE__*/_interopDefault(_URL);
|
|
57
61
|
var crypto__default = /*#__PURE__*/_interopDefault(crypto);
|
|
58
62
|
var process__default = /*#__PURE__*/_interopDefault(process);
|
|
59
63
|
var chalk__default = /*#__PURE__*/_interopDefault(chalk);
|
|
60
|
-
var _includesInstanceProperty__default = /*#__PURE__*/_interopDefault(_includesInstanceProperty);
|
|
61
64
|
var http__default = /*#__PURE__*/_interopDefault(http);
|
|
62
65
|
var jwtDecode__default = /*#__PURE__*/_interopDefault(jwtDecode);
|
|
63
66
|
|
|
@@ -205,6 +208,116 @@ const generateRandomHash = function () {
|
|
|
205
208
|
let length = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 16;
|
|
206
209
|
return crypto__default["default"].randomBytes(length).toString('hex');
|
|
207
210
|
};
|
|
211
|
+
|
|
212
|
+
/**
|
|
213
|
+
* Performs headless login using Puppeteer.
|
|
214
|
+
* Requires IDENTITY_EMAIL and IDENTITY_PASSWORD environment variables.
|
|
215
|
+
*/
|
|
216
|
+
async function runHeadlessLogin(authUrl) {
|
|
217
|
+
const email = process__default["default"].env.IDENTITY_EMAIL;
|
|
218
|
+
const password = process__default["default"].env.IDENTITY_PASSWORD;
|
|
219
|
+
if (!email || !password) {
|
|
220
|
+
throw new Error('Headless login requires IDENTITY_EMAIL and IDENTITY_PASSWORD environment variables');
|
|
221
|
+
}
|
|
222
|
+
let puppeteer;
|
|
223
|
+
try {
|
|
224
|
+
puppeteer = await Promise.resolve().then(function () { return /*#__PURE__*/_interopNamespace(require('puppeteer')); });
|
|
225
|
+
} catch {
|
|
226
|
+
throw new Error('Puppeteer is required for headless login. Install it with: npm install puppeteer');
|
|
227
|
+
}
|
|
228
|
+
const browser = await puppeteer.default.launch({
|
|
229
|
+
headless: 'new',
|
|
230
|
+
args: ['--no-sandbox', '--disable-setuid-sandbox']
|
|
231
|
+
});
|
|
232
|
+
try {
|
|
233
|
+
const page = await browser.newPage();
|
|
234
|
+
await page.goto(authUrl.toString(), {
|
|
235
|
+
waitUntil: 'networkidle2'
|
|
236
|
+
});
|
|
237
|
+
|
|
238
|
+
// Wait for the login page to load
|
|
239
|
+
await page.waitForSelector('input[name="identifier"]', {
|
|
240
|
+
timeout: 30000
|
|
241
|
+
});
|
|
242
|
+
|
|
243
|
+
// Dismiss cookie banner if present
|
|
244
|
+
// Note: Using string-based evaluate to avoid bundler transforming Array.from
|
|
245
|
+
try {
|
|
246
|
+
await page.evaluate(`
|
|
247
|
+
(function() {
|
|
248
|
+
var buttons = Array.from(document.querySelectorAll('button'));
|
|
249
|
+
var acceptBtn = buttons.find(function(btn) {
|
|
250
|
+
return btn.textContent && btn.textContent.includes('Accept all cookies');
|
|
251
|
+
});
|
|
252
|
+
if (acceptBtn) acceptBtn.click();
|
|
253
|
+
})()
|
|
254
|
+
`);
|
|
255
|
+
await new _Promise__default["default"](resolve => _setTimeout__default["default"](resolve, 500));
|
|
256
|
+
} catch {
|
|
257
|
+
// Cookie banner not found or already dismissed
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
// Fill in email
|
|
261
|
+
await page.type('input[name="identifier"]', email);
|
|
262
|
+
await new _Promise__default["default"](resolve => _setTimeout__default["default"](resolve, 500));
|
|
263
|
+
|
|
264
|
+
// Click "Next" button
|
|
265
|
+
await page.evaluate(`
|
|
266
|
+
(function() {
|
|
267
|
+
var buttons = Array.from(document.querySelectorAll('button'));
|
|
268
|
+
var nextBtn = buttons.find(function(btn) {
|
|
269
|
+
return btn.textContent && btn.textContent.toLowerCase().includes('next');
|
|
270
|
+
});
|
|
271
|
+
if (nextBtn) nextBtn.click();
|
|
272
|
+
})()
|
|
273
|
+
`);
|
|
274
|
+
|
|
275
|
+
// Wait for password field
|
|
276
|
+
await page.waitForSelector('input[name="password"]', {
|
|
277
|
+
visible: true,
|
|
278
|
+
timeout: 30000
|
|
279
|
+
});
|
|
280
|
+
|
|
281
|
+
// Fill in password
|
|
282
|
+
await page.type('input[name="password"]', password);
|
|
283
|
+
await new _Promise__default["default"](resolve => _setTimeout__default["default"](resolve, 500));
|
|
284
|
+
|
|
285
|
+
// Click "Submit" button
|
|
286
|
+
await page.evaluate(`
|
|
287
|
+
(function() {
|
|
288
|
+
var buttons = Array.from(document.querySelectorAll('button'));
|
|
289
|
+
var submitBtn = buttons.find(function(btn) {
|
|
290
|
+
return btn.textContent && btn.textContent.toLowerCase().includes('submit');
|
|
291
|
+
});
|
|
292
|
+
if (submitBtn) submitBtn.click();
|
|
293
|
+
})()
|
|
294
|
+
`);
|
|
295
|
+
|
|
296
|
+
// Wait for the callback to be processed (the server will close and exit)
|
|
297
|
+
// We just need to keep the browser alive until the redirect happens
|
|
298
|
+
const startTime = _Date$now__default["default"]();
|
|
299
|
+
const timeout = 60000;
|
|
300
|
+
while (_Date$now__default["default"]() - startTime < timeout) {
|
|
301
|
+
await new _Promise__default["default"](resolve => _setTimeout__default["default"](resolve, 500));
|
|
302
|
+
const currentUrl = page.url();
|
|
303
|
+
if (_includesInstanceProperty__default["default"](currentUrl).call(currentUrl, 'sessionToken=')) {
|
|
304
|
+
// Token was captured by the callback server, we can exit
|
|
305
|
+
break;
|
|
306
|
+
}
|
|
307
|
+
const pageContent = await page.content();
|
|
308
|
+
if (_includesInstanceProperty__default["default"](pageContent).call(pageContent, 'Invalid credentials') || _includesInstanceProperty__default["default"](pageContent).call(pageContent, 'invalid_grant')) {
|
|
309
|
+
throw new Error('Invalid credentials');
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
// Check if page shows success (callback server response)
|
|
313
|
+
if (_includesInstanceProperty__default["default"](pageContent).call(pageContent, 'Success!')) {
|
|
314
|
+
break;
|
|
315
|
+
}
|
|
316
|
+
}
|
|
317
|
+
} finally {
|
|
318
|
+
await browser.close();
|
|
319
|
+
}
|
|
320
|
+
}
|
|
208
321
|
async function run(options) {
|
|
209
322
|
const mcApiUrl = await resolveMcApiUrl(options);
|
|
210
323
|
if (!mcApiUrl) {
|
|
@@ -246,12 +359,18 @@ async function run(options) {
|
|
|
246
359
|
}
|
|
247
360
|
});
|
|
248
361
|
await startServer(server);
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
362
|
+
if (options.headless) {
|
|
363
|
+
console.log(`Initiating headless authentication flow using Puppeteer...`);
|
|
364
|
+
console.log();
|
|
365
|
+
await runHeadlessLogin(authUrl);
|
|
366
|
+
} else {
|
|
367
|
+
console.log(`Initiating the OIDC authentication flow, opening the login page in your browser...`);
|
|
368
|
+
console.log(` ${authUrl}`);
|
|
369
|
+
console.log();
|
|
370
|
+
const open = await Promise.resolve().then(function () { return /*#__PURE__*/_interopNamespace(require('open')); });
|
|
371
|
+
await open.default(authUrl.toString());
|
|
372
|
+
console.log('Waiting for the OIDC authentication to complete...');
|
|
373
|
+
}
|
|
255
374
|
}
|
|
256
375
|
|
|
257
376
|
exports["default"] = run;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
var pkgJson = {
|
|
2
2
|
name: "@commercetools-frontend/mc-scripts",
|
|
3
|
-
version: "
|
|
3
|
+
version: "26.0.0",
|
|
4
4
|
description: "Configuration and scripts for developing a MC application",
|
|
5
5
|
bugs: "https://github.com/commercetools/merchant-center-application-kit/issues",
|
|
6
6
|
repository: {
|
|
@@ -61,13 +61,13 @@ var pkgJson = {
|
|
|
61
61
|
"@babel/plugin-proposal-do-expressions": "^7.22.5",
|
|
62
62
|
"@babel/runtime": "^7.22.15",
|
|
63
63
|
"@babel/runtime-corejs3": "^7.22.15",
|
|
64
|
-
"@commercetools-frontend/application-components": "
|
|
65
|
-
"@commercetools-frontend/application-config": "
|
|
66
|
-
"@commercetools-frontend/assets": "
|
|
67
|
-
"@commercetools-frontend/babel-preset-mc-app": "
|
|
68
|
-
"@commercetools-frontend/constants": "
|
|
69
|
-
"@commercetools-frontend/mc-dev-authentication": "
|
|
70
|
-
"@commercetools-frontend/mc-html-template": "
|
|
64
|
+
"@commercetools-frontend/application-components": "26.0.0",
|
|
65
|
+
"@commercetools-frontend/application-config": "26.0.0",
|
|
66
|
+
"@commercetools-frontend/assets": "26.0.0",
|
|
67
|
+
"@commercetools-frontend/babel-preset-mc-app": "26.0.0",
|
|
68
|
+
"@commercetools-frontend/constants": "26.0.0",
|
|
69
|
+
"@commercetools-frontend/mc-dev-authentication": "26.0.0",
|
|
70
|
+
"@commercetools-frontend/mc-html-template": "26.0.0",
|
|
71
71
|
"@commercetools/http-user-agent": "3.0.0",
|
|
72
72
|
"@emotion/babel-plugin": "^11.13.5",
|
|
73
73
|
"@formatjs/cli-lib": "^6.3.8",
|
|
@@ -85,6 +85,7 @@ var pkgJson = {
|
|
|
85
85
|
autoprefixer: "^10.4.15",
|
|
86
86
|
"babel-loader": "8.4.1",
|
|
87
87
|
"babel-plugin-formatjs": "^10.5.25",
|
|
88
|
+
"babel-plugin-react-compiler": "^1.0.0",
|
|
88
89
|
browserslist: "^4.28.1",
|
|
89
90
|
chalk: "4.1.2",
|
|
90
91
|
commander: "^13.1.0",
|
|
@@ -94,13 +95,14 @@ var pkgJson = {
|
|
|
94
95
|
dotenv: "16.6.1",
|
|
95
96
|
"dotenv-expand": "8.0.3",
|
|
96
97
|
"fs-extra": "10.1.0",
|
|
98
|
+
glob: "^10.5.0",
|
|
97
99
|
graphql: "16.11.0",
|
|
98
100
|
"graphql-request": "5.2.0",
|
|
99
101
|
"graphql-tag": "^2.12.6",
|
|
100
102
|
"html-webpack-plugin": "5.6.3",
|
|
101
103
|
"json-loader": "0.5.7",
|
|
102
104
|
"jwt-decode": "3.1.2",
|
|
103
|
-
lodash: "4.17.
|
|
105
|
+
lodash: "4.17.23",
|
|
104
106
|
"mini-css-extract-plugin": "2.9.4",
|
|
105
107
|
moment: "^2.29.4",
|
|
106
108
|
"moment-locales-webpack-plugin": "1.2.0",
|
|
@@ -128,8 +130,7 @@ var pkgJson = {
|
|
|
128
130
|
url: "^0.11.0",
|
|
129
131
|
vite: "~6.4.0",
|
|
130
132
|
"vite-bundle-analyzer": "0.23.0",
|
|
131
|
-
|
|
132
|
-
webpack: "5.101.1",
|
|
133
|
+
webpack: "5.105.1",
|
|
133
134
|
"webpack-bundle-analyzer": "4.10.2",
|
|
134
135
|
"webpack-dev-server": "4.15.2",
|
|
135
136
|
webpackbar: "5.0.2"
|
|
@@ -146,10 +147,19 @@ var pkgJson = {
|
|
|
146
147
|
"jest-mock": "29.7.0",
|
|
147
148
|
memfs: "^4.8.2",
|
|
148
149
|
msw: "^1.3.5",
|
|
150
|
+
puppeteer: "20.9.0",
|
|
149
151
|
rimraf: "6.0.1"
|
|
150
152
|
},
|
|
151
153
|
engines: {
|
|
152
154
|
node: "18.x || 20.x || >=22.0.0"
|
|
155
|
+
},
|
|
156
|
+
peerDependencies: {
|
|
157
|
+
puppeteer: ">=20.0.0"
|
|
158
|
+
},
|
|
159
|
+
peerDependenciesMeta: {
|
|
160
|
+
puppeteer: {
|
|
161
|
+
optional: true
|
|
162
|
+
}
|
|
153
163
|
}
|
|
154
164
|
};
|
|
155
165
|
|