@commercetools-frontend/mc-scripts 27.8.0 → 27.9.1
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/application-runtime/dist/commercetools-frontend-mc-scripts-application-runtime.cjs.dev.js +1 -1
- package/application-runtime/dist/commercetools-frontend-mc-scripts-application-runtime.cjs.prod.js +1 -1
- package/application-runtime/dist/commercetools-frontend-mc-scripts-application-runtime.esm.js +1 -1
- package/cli/dist/commercetools-frontend-mc-scripts-cli.cjs.dev.js +17 -17
- package/cli/dist/commercetools-frontend-mc-scripts-cli.cjs.prod.js +17 -17
- package/cli/dist/commercetools-frontend-mc-scripts-cli.esm.js +17 -17
- package/dist/{build-5cf73f12.esm.js → build-5a0c84e7.esm.js} +8 -8
- package/dist/{build-37bc930a.cjs.dev.js → build-b9cbc1d1.cjs.dev.js} +8 -8
- package/dist/{build-cd4fa021.cjs.prod.js → build-cdeab3a8.cjs.prod.js} +8 -8
- package/dist/{build-vite-e4eeb1a3.cjs.dev.js → build-vite-0e8f3463.cjs.dev.js} +16 -14
- package/dist/{build-vite-377f721f.cjs.prod.js → build-vite-aa0e7242.cjs.prod.js} +16 -14
- package/dist/{build-vite-2ea8a241.esm.js → build-vite-ce3c4fb6.esm.js} +16 -14
- 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/{compile-html-f4ac88cc.cjs.dev.js → compile-html-8679f721.cjs.dev.js} +5 -2
- package/dist/{compile-html-025cd493.esm.js → compile-html-adfef598.esm.js} +4 -2
- package/dist/{compile-html-50fd05ec.cjs.prod.js → compile-html-b80f9651.cjs.prod.js} +5 -2
- package/dist/{config-sync-ce00b14f.cjs.dev.js → config-sync-2b56a941.cjs.dev.js} +17 -17
- package/dist/{config-sync-b4cdfff2.cjs.prod.js → config-sync-41bc7f5e.cjs.prod.js} +17 -17
- package/dist/{config-sync-92843fd3.esm.js → config-sync-7031a7de.esm.js} +17 -17
- package/dist/{config-sync-ci-5f63ed76.esm.js → config-sync-ci-1866c188.esm.js} +25 -20
- package/dist/{config-sync-ci-887a171d.cjs.dev.js → config-sync-ci-6d12f2f3.cjs.dev.js} +27 -22
- package/dist/{config-sync-ci-f154ff74.cjs.prod.js → config-sync-ci-ea943de9.cjs.prod.js} +27 -22
- package/dist/{config-sync-helpers-99d009c2.cjs.dev.js → config-sync-helpers-36985f8c.cjs.dev.js} +57 -48
- package/dist/{config-sync-helpers-2a1ad393.cjs.prod.js → config-sync-helpers-79ccaaad.cjs.prod.js} +55 -46
- package/dist/{config-sync-helpers-131446d1.esm.js → config-sync-helpers-875ef4a4.esm.js} +56 -47
- package/dist/{create-postcss-config-2552844c.cjs.dev.js → create-postcss-config-13cb1cb8.cjs.dev.js} +1 -1
- package/dist/{create-postcss-config-94621a5d.cjs.prod.js → create-postcss-config-1eeb3d9d.cjs.prod.js} +1 -1
- package/dist/{create-postcss-config-fd5f1790.esm.js → create-postcss-config-390e8a52.esm.js} +1 -1
- package/dist/{create-webpack-config-for-development-1a51db3d.cjs.prod.js → create-webpack-config-for-development-6608b4e4.cjs.prod.js} +15 -10
- package/dist/{create-webpack-config-for-development-7be672b8.cjs.dev.js → create-webpack-config-for-development-9a3a3a93.cjs.dev.js} +15 -10
- package/dist/{create-webpack-config-for-development-1d8ac187.esm.js → create-webpack-config-for-development-dd95f3d5.esm.js} +15 -9
- package/dist/{create-webpack-config-for-production-659d28ad.cjs.dev.js → create-webpack-config-for-production-29b34b8c.cjs.dev.js} +8 -8
- package/dist/{create-webpack-config-for-production-d8a4b779.cjs.prod.js → create-webpack-config-for-production-2e6e5036.cjs.prod.js} +8 -8
- package/dist/{create-webpack-config-for-production-25dbb5e6.esm.js → create-webpack-config-for-production-31bb3d24.esm.js} +8 -8
- package/dist/{credentials-storage-fd195144.cjs.dev.js → credentials-storage-1826f1a2.cjs.dev.js} +1 -1
- package/dist/{credentials-storage-ea1c16dc.cjs.prod.js → credentials-storage-60a63c81.cjs.prod.js} +1 -1
- package/dist/{credentials-storage-67deadc3.esm.js → credentials-storage-bfaa78f0.esm.js} +1 -1
- package/dist/{deployment-previews-set-3dae0f4a.esm.js → deployment-previews-set-410cecf1.esm.js} +27 -22
- package/dist/{deployment-previews-set-92355471.cjs.dev.js → deployment-previews-set-a04efad3.cjs.dev.js} +28 -22
- package/dist/{deployment-previews-set-d8d80d4c.cjs.prod.js → deployment-previews-set-bebd7a04.cjs.prod.js} +28 -22
- package/dist/{graphql-requests-f3dc11f7.cjs.dev.js → graphql-requests-1ea68584.cjs.dev.js} +8 -5
- package/dist/{graphql-requests-4d1d361b.cjs.prod.js → graphql-requests-98b1b779.cjs.prod.js} +8 -5
- package/dist/{graphql-requests-ab8202cb.esm.js → graphql-requests-c491206a.esm.js} +8 -5
- package/dist/{i18n-message-complilation-7311cb29.cjs.dev.js → i18n-message-complilation-393d344a.cjs.prod.js} +1 -1
- package/dist/{i18n-message-complilation-7762da61.cjs.prod.js → i18n-message-complilation-3f80e8d6.cjs.dev.js} +1 -1
- package/dist/{i18n-message-complilation-21d3b0aa.esm.js → i18n-message-complilation-8aec9d1b.esm.js} +1 -1
- package/dist/{login-389005dc.cjs.prod.js → login-a99d14e6.cjs.prod.js} +38 -60
- package/dist/{login-093e2fe2.esm.js → login-b935aede.esm.js} +37 -58
- package/dist/{login-3d0c7aec.cjs.dev.js → login-cd99208a.cjs.dev.js} +38 -60
- package/dist/{optimizations-da5a0cfa.cjs.prod.js → optimizations-09a6638c.cjs.prod.js} +8 -5
- package/dist/{optimizations-54382f7b.esm.js → optimizations-1b3f8157.esm.js} +7 -5
- package/dist/{optimizations-56be74d6.cjs.dev.js → optimizations-640ffcac.cjs.dev.js} +8 -5
- package/dist/{package-92325d69.esm.js → package-15124b28.esm.js} +3 -4
- package/dist/{package-29009841.cjs.dev.js → package-90af7dfe.cjs.prod.js} +3 -4
- package/dist/{package-8c1a8425.cjs.prod.js → package-98adb0d5.cjs.dev.js} +3 -4
- package/dist/{paths-39f22b8b.esm.js → paths-7bf7e88e.esm.js} +9 -4
- package/dist/{paths-7768b440.cjs.prod.js → paths-af1a725a.cjs.prod.js} +10 -4
- package/dist/{paths-b76fc753.cjs.dev.js → paths-ec3e3a7d.cjs.dev.js} +10 -4
- package/dist/{serve-b1c12985.cjs.dev.js → serve-760fc169.cjs.dev.js} +13 -14
- package/dist/{serve-3837602d.cjs.prod.js → serve-87ef7d4f.cjs.prod.js} +13 -14
- package/dist/{serve-22475fec.esm.js → serve-ddf30b4c.esm.js} +13 -13
- package/dist/{start-5fcaad9b.esm.js → start-08895b5f.esm.js} +11 -13
- package/dist/{start-ec6bcea2.cjs.dev.js → start-a0945fde.cjs.dev.js} +11 -13
- package/dist/{start-925a7852.cjs.prod.js → start-d9bd5dfb.cjs.prod.js} +11 -13
- package/dist/{start-vite-dd8a1e26.cjs.prod.js → start-vite-00514c35.cjs.prod.js} +5 -4
- package/dist/{start-vite-698c9e82.cjs.dev.js → start-vite-10e49e5c.cjs.dev.js} +5 -4
- package/dist/{start-vite-4b0df191.esm.js → start-vite-745d3123.esm.js} +5 -4
- package/dist/{try-load-nimbus-plugins-a713d7d3.cjs.prod.js → try-load-nimbus-plugins-06ce5d83.cjs.dev.js} +1 -1
- package/dist/{try-load-nimbus-plugins-2f528d8f.esm.js → try-load-nimbus-plugins-526dccbd.esm.js} +1 -1
- package/dist/{try-load-nimbus-plugins-d502a5fe.cjs.dev.js → try-load-nimbus-plugins-59c3a594.cjs.prod.js} +1 -1
- package/dist/{vite-plugin-svgr-de6ee7da.esm.js → vite-plugin-svgr-22c8d518.esm.js} +4 -4
- package/dist/{vite-plugin-svgr-4034a834.cjs.prod.js → vite-plugin-svgr-53ef97c7.cjs.dev.js} +4 -4
- package/dist/{vite-plugin-svgr-7d06f400.cjs.dev.js → vite-plugin-svgr-5de1cad9.cjs.prod.js} +4 -4
- package/package.json +32 -31
- 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 +7 -8
- package/webpack/dist/commercetools-frontend-mc-scripts-webpack.cjs.prod.js +7 -8
- package/webpack/dist/commercetools-frontend-mc-scripts-webpack.esm.js +7 -8
- package/webpack-loaders/i18n-message-compilation-loader/dist/commercetools-frontend-mc-scripts-webpack-loaders-i18n-message-compilation-loader.cjs.dev.js +1 -1
- package/webpack-loaders/i18n-message-compilation-loader/dist/commercetools-frontend-mc-scripts-webpack-loaders-i18n-message-compilation-loader.cjs.prod.js +1 -1
- package/webpack-loaders/i18n-message-compilation-loader/dist/commercetools-frontend-mc-scripts-webpack-loaders-i18n-message-compilation-loader.esm.js +1 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import _Promise from '@babel/runtime-corejs3/core-js-stable/promise';
|
|
2
2
|
import _mapInstanceProperty from '@babel/runtime-corejs3/core-js-stable/instance/map';
|
|
3
3
|
import _startsWithInstanceProperty from '@babel/runtime-corejs3/core-js-stable/instance/starts-with';
|
|
4
|
-
import
|
|
4
|
+
import _concatInstanceProperty from '@babel/runtime-corejs3/core-js-stable/instance/concat';
|
|
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
7
|
import _setTimeout from '@babel/runtime-corejs3/core-js-stable/set-timeout';
|
|
@@ -13,10 +13,10 @@ import crypto from 'node:crypto';
|
|
|
13
13
|
import process, { exit } from 'node:process';
|
|
14
14
|
import chalk from 'chalk';
|
|
15
15
|
import { processConfig } from '@commercetools-frontend/application-config';
|
|
16
|
-
import { p as pkgJson } from './package-
|
|
16
|
+
import { p as pkgJson } from './package-15124b28.esm.js';
|
|
17
17
|
import http from 'node:http';
|
|
18
|
-
import jwtDecode from 'jwt-decode';
|
|
19
|
-
import { C as CredentialsStorage } from './credentials-storage-
|
|
18
|
+
import { jwtDecode } from 'jwt-decode';
|
|
19
|
+
import { C as CredentialsStorage } from './credentials-storage-bfaa78f0.esm.js';
|
|
20
20
|
import '@babel/runtime-corejs3/helpers/classCallCheck';
|
|
21
21
|
import '@babel/runtime-corejs3/helpers/createClass';
|
|
22
22
|
import '@babel/runtime-corejs3/core-js-stable/json/stringify';
|
|
@@ -28,8 +28,8 @@ import './does-file-exist-32618334.esm.js';
|
|
|
28
28
|
function createAuthCallbackServer(options) {
|
|
29
29
|
const server = http.createServer(async (request, response) => {
|
|
30
30
|
try {
|
|
31
|
-
var
|
|
32
|
-
if ((
|
|
31
|
+
var _request$url;
|
|
32
|
+
if ((_request$url = request.url) !== null && _request$url !== void 0 && _includesInstanceProperty(_request$url).call(_request$url, "/".concat(options.clientIdentifier, "/oidc/callback"))) {
|
|
33
33
|
const incomingUrl = new _URL(request.url, 'http://localhost');
|
|
34
34
|
const sessionToken = incomingUrl.searchParams.get('sessionToken');
|
|
35
35
|
const requestedState = incomingUrl.searchParams.get('state');
|
|
@@ -37,7 +37,7 @@ function createAuthCallbackServer(options) {
|
|
|
37
37
|
throw new Error('Invalid authentication flow (missing sessionToken)');
|
|
38
38
|
}
|
|
39
39
|
const decodedSessionToken = jwtDecode(sessionToken);
|
|
40
|
-
if (decodedSessionToken
|
|
40
|
+
if ((decodedSessionToken === null || decodedSessionToken === void 0 ? void 0 : decodedSessionToken.nonce) !== options.nonce) {
|
|
41
41
|
throw new Error('Invalid authentication flow (nonce mismatch)');
|
|
42
42
|
}
|
|
43
43
|
if (requestedState !== options.state) {
|
|
@@ -60,7 +60,7 @@ function createAuthCallbackServer(options) {
|
|
|
60
60
|
response.end(error.message);
|
|
61
61
|
} else {
|
|
62
62
|
console.error(error);
|
|
63
|
-
response.end(
|
|
63
|
+
response.end("Invalid authentication flow.");
|
|
64
64
|
}
|
|
65
65
|
server.close(() => {
|
|
66
66
|
exit();
|
|
@@ -72,14 +72,14 @@ function createAuthCallbackServer(options) {
|
|
|
72
72
|
|
|
73
73
|
const credentialsStorage = new CredentialsStorage();
|
|
74
74
|
const port = 3001;
|
|
75
|
-
const clientIdentifier =
|
|
75
|
+
const clientIdentifier = "mc-scripts-".concat(pkgJson.version);
|
|
76
76
|
const isServerError = error => {
|
|
77
77
|
return error instanceof Error && 'code' in error;
|
|
78
78
|
};
|
|
79
79
|
const startServer = server => new _Promise((resolve, reject) => {
|
|
80
80
|
server.listen(port, 'localhost').on('listening', resolve).on('error', error => {
|
|
81
81
|
if (isServerError(error) && error.code === 'EADDRINUSE') {
|
|
82
|
-
return reject(new Error(
|
|
82
|
+
return reject(new Error("The address \"localhost:".concat(port, "\" is already in use. Are you running a Merchant Center application in other process? Please stop that and try again."), {
|
|
83
83
|
cause: error
|
|
84
84
|
}));
|
|
85
85
|
}
|
|
@@ -115,8 +115,9 @@ const resolveProjectKey = async options => {
|
|
|
115
115
|
return process.env.CTP_PROJECT_KEY;
|
|
116
116
|
}
|
|
117
117
|
try {
|
|
118
|
+
var _applicationConfig$en;
|
|
118
119
|
const applicationConfig = await processConfig();
|
|
119
|
-
return applicationConfig.env.__DEVELOPMENT__
|
|
120
|
+
return (_applicationConfig$en = applicationConfig.env.__DEVELOPMENT__) === null || _applicationConfig$en === void 0 || (_applicationConfig$en = _applicationConfig$en.oidc) === null || _applicationConfig$en === void 0 ? void 0 : _applicationConfig$en.initialProjectKey;
|
|
120
121
|
} catch (error) {
|
|
121
122
|
// It's ok if there's not application config file or if it does not contain the initialProjectKey
|
|
122
123
|
return;
|
|
@@ -125,10 +126,10 @@ const resolveProjectKey = async options => {
|
|
|
125
126
|
const mapOAuthScopesToClaims = scopes => {
|
|
126
127
|
return _mapInstanceProperty(scopes).call(scopes, scope => {
|
|
127
128
|
if (_startsWithInstanceProperty(scope).call(scope, 'view_')) {
|
|
128
|
-
return
|
|
129
|
+
return "view:".concat(scope);
|
|
129
130
|
}
|
|
130
131
|
if (_startsWithInstanceProperty(scope).call(scope, 'manage_')) {
|
|
131
|
-
return
|
|
132
|
+
return "manage:".concat(scope);
|
|
132
133
|
}
|
|
133
134
|
return scope;
|
|
134
135
|
});
|
|
@@ -136,10 +137,12 @@ const mapOAuthScopesToClaims = scopes => {
|
|
|
136
137
|
const mapAdditionalOAuthScopesToClaims = (name, scopes) => {
|
|
137
138
|
return _mapInstanceProperty(scopes).call(scopes, scope => {
|
|
138
139
|
if (_startsWithInstanceProperty(scope).call(scope, 'view_')) {
|
|
139
|
-
|
|
140
|
+
var _context;
|
|
141
|
+
return _concatInstanceProperty(_context = "view/".concat(name, ":")).call(_context, scope);
|
|
140
142
|
}
|
|
141
143
|
if (_startsWithInstanceProperty(scope).call(scope, 'manage_')) {
|
|
142
|
-
|
|
144
|
+
var _context2;
|
|
145
|
+
return _concatInstanceProperty(_context2 = "manage/".concat(name, ":")).call(_context2, scope);
|
|
143
146
|
}
|
|
144
147
|
return scope;
|
|
145
148
|
});
|
|
@@ -151,15 +154,15 @@ const resolveOAuthScopes = async options => {
|
|
|
151
154
|
|
|
152
155
|
// We first check whether the user has set the CTP_OAUTH_SCOPES environment variable
|
|
153
156
|
if (process.env.CTP_OAUTH_SCOPES) {
|
|
154
|
-
var
|
|
155
|
-
return mapOAuthScopesToClaims(((
|
|
157
|
+
var _process$env$CTP_OAUT, _process$env$CTP_OAUT2, _context3;
|
|
158
|
+
return mapOAuthScopesToClaims((_process$env$CTP_OAUT = (_process$env$CTP_OAUT2 = process.env.CTP_OAUTH_SCOPES) === null || _process$env$CTP_OAUT2 === void 0 ? void 0 : _mapInstanceProperty(_context3 = _process$env$CTP_OAUT2.split(',')).call(_context3, scope => _trimInstanceProperty(scope).call(scope))) !== null && _process$env$CTP_OAUT !== void 0 ? _process$env$CTP_OAUT : []);
|
|
156
159
|
}
|
|
157
160
|
try {
|
|
158
|
-
var
|
|
161
|
+
var _applicationConfig$en2, _applicationConfig$en3, _configuredOAuthScope, _configuredOAuthScope2, _configuredAdditional, _configuredAdditional2;
|
|
159
162
|
const applicationConfig = await processConfig();
|
|
160
|
-
const configuredOAuthScopes = applicationConfig.env.__DEVELOPMENT__
|
|
161
|
-
const configuredAdditionalOAuthScopes = applicationConfig.env.__DEVELOPMENT__
|
|
162
|
-
return [...mapOAuthScopesToClaims(configuredOAuthScopes
|
|
163
|
+
const configuredOAuthScopes = (_applicationConfig$en2 = applicationConfig.env.__DEVELOPMENT__) === null || _applicationConfig$en2 === void 0 || (_applicationConfig$en2 = _applicationConfig$en2.oidc) === null || _applicationConfig$en2 === void 0 ? void 0 : _applicationConfig$en2.oAuthScopes;
|
|
164
|
+
const configuredAdditionalOAuthScopes = (_applicationConfig$en3 = applicationConfig.env.__DEVELOPMENT__) === null || _applicationConfig$en3 === void 0 || (_applicationConfig$en3 = _applicationConfig$en3.oidc) === null || _applicationConfig$en3 === void 0 ? void 0 : _applicationConfig$en3.additionalOAuthScopes;
|
|
165
|
+
return [...mapOAuthScopesToClaims((_configuredOAuthScope = configuredOAuthScopes === null || configuredOAuthScopes === void 0 ? void 0 : configuredOAuthScopes.view) !== null && _configuredOAuthScope !== void 0 ? _configuredOAuthScope : []), ...mapOAuthScopesToClaims((_configuredOAuthScope2 = configuredOAuthScopes === null || configuredOAuthScopes === void 0 ? void 0 : configuredOAuthScopes.manage) !== null && _configuredOAuthScope2 !== void 0 ? _configuredOAuthScope2 : []), ...((_configuredAdditional = configuredAdditionalOAuthScopes === null || configuredAdditionalOAuthScopes === void 0 ? void 0 : _flatMapInstanceProperty(configuredAdditionalOAuthScopes).call(configuredAdditionalOAuthScopes, scope => mapAdditionalOAuthScopesToClaims(scope.name, scope.view))) !== null && _configuredAdditional !== void 0 ? _configuredAdditional : []), ...((_configuredAdditional2 = configuredAdditionalOAuthScopes === null || configuredAdditionalOAuthScopes === void 0 ? void 0 : _flatMapInstanceProperty(configuredAdditionalOAuthScopes).call(configuredAdditionalOAuthScopes, scope => mapAdditionalOAuthScopesToClaims(scope.name, scope.manage))) !== null && _configuredAdditional2 !== void 0 ? _configuredAdditional2 : [])];
|
|
163
166
|
} catch (error) {
|
|
164
167
|
// It's ok if there's not application config file or if it does not contain the initialProjectKey
|
|
165
168
|
return [];
|
|
@@ -183,7 +186,7 @@ async function runHeadlessLogin(authUrl) {
|
|
|
183
186
|
let puppeteer;
|
|
184
187
|
try {
|
|
185
188
|
puppeteer = await import('puppeteer');
|
|
186
|
-
} catch {
|
|
189
|
+
} catch (_unused) {
|
|
187
190
|
throw new Error('Puppeteer is required for headless login. Install it with: npm install puppeteer');
|
|
188
191
|
}
|
|
189
192
|
const browser = await puppeteer.default.launch({
|
|
@@ -204,17 +207,9 @@ async function runHeadlessLogin(authUrl) {
|
|
|
204
207
|
// Dismiss cookie banner if present
|
|
205
208
|
// Note: Using string-based evaluate to avoid bundler transforming Array.from
|
|
206
209
|
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
|
-
`);
|
|
210
|
+
await page.evaluate("\n (function() {\n var buttons = Array.from(document.querySelectorAll('button'));\n var acceptBtn = buttons.find(function(btn) {\n return btn.textContent && btn.textContent.includes('Accept all cookies');\n });\n if (acceptBtn) acceptBtn.click();\n })()\n ");
|
|
216
211
|
await new _Promise(resolve => _setTimeout(resolve, 500));
|
|
217
|
-
} catch {
|
|
212
|
+
} catch (_unused2) {
|
|
218
213
|
// Cookie banner not found or already dismissed
|
|
219
214
|
}
|
|
220
215
|
|
|
@@ -223,15 +218,7 @@ async function runHeadlessLogin(authUrl) {
|
|
|
223
218
|
await new _Promise(resolve => _setTimeout(resolve, 500));
|
|
224
219
|
|
|
225
220
|
// 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
|
-
`);
|
|
221
|
+
await page.evaluate("\n (function() {\n var buttons = Array.from(document.querySelectorAll('button'));\n var nextBtn = buttons.find(function(btn) {\n return btn.textContent && btn.textContent.toLowerCase().includes('next');\n });\n if (nextBtn) nextBtn.click();\n })()\n ");
|
|
235
222
|
|
|
236
223
|
// Wait for password field
|
|
237
224
|
await page.waitForSelector('input[name="password"]', {
|
|
@@ -244,15 +231,7 @@ async function runHeadlessLogin(authUrl) {
|
|
|
244
231
|
await new _Promise(resolve => _setTimeout(resolve, 500));
|
|
245
232
|
|
|
246
233
|
// 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
|
-
`);
|
|
234
|
+
await page.evaluate("\n (function() {\n var buttons = Array.from(document.querySelectorAll('button'));\n var submitBtn = buttons.find(function(btn) {\n return btn.textContent && btn.textContent.toLowerCase().includes('submit');\n });\n if (submitBtn) submitBtn.click();\n })()\n ");
|
|
256
235
|
|
|
257
236
|
// Wait for the callback to be processed (the server will close and exit)
|
|
258
237
|
// We just need to keep the browser alive until the redirect happens
|
|
@@ -284,17 +263,17 @@ async function run(options) {
|
|
|
284
263
|
if (!mcApiUrl) {
|
|
285
264
|
throw new Error('No Merchant Center API URL found. Aborting.');
|
|
286
265
|
}
|
|
287
|
-
console.log(
|
|
266
|
+
console.log("Using Merchant Center environment \"".concat(chalk.green(mcApiUrl), "\"."));
|
|
288
267
|
console.log();
|
|
289
268
|
if (!options.force && credentialsStorage.isSessionValid(mcApiUrl)) {
|
|
290
|
-
console.log(
|
|
269
|
+
console.log("You already have a valid session.");
|
|
291
270
|
return;
|
|
292
271
|
}
|
|
293
272
|
const projectKey = await resolveProjectKey(options);
|
|
294
273
|
const oauthScopes = await resolveOAuthScopes(options);
|
|
295
274
|
const scopes = ['openid'];
|
|
296
275
|
if (projectKey) {
|
|
297
|
-
scopes.push(
|
|
276
|
+
scopes.push("project_key:".concat(projectKey));
|
|
298
277
|
_forEachInstanceProperty(oauthScopes).call(oauthScopes, scope => {
|
|
299
278
|
scopes.push(scope);
|
|
300
279
|
});
|
|
@@ -304,7 +283,7 @@ async function run(options) {
|
|
|
304
283
|
const authUrl = new _URL('/login/authorize', mcApiUrl);
|
|
305
284
|
authUrl.searchParams.set('response_type', 'id_token');
|
|
306
285
|
authUrl.searchParams.set('response_mode', 'query');
|
|
307
|
-
authUrl.searchParams.set('client_id',
|
|
286
|
+
authUrl.searchParams.set('client_id', "__local:".concat(clientIdentifier));
|
|
308
287
|
authUrl.searchParams.set('scope', scopes.join(' '));
|
|
309
288
|
authUrl.searchParams.set('state', state);
|
|
310
289
|
authUrl.searchParams.set('nonce', nonce);
|
|
@@ -315,18 +294,18 @@ async function run(options) {
|
|
|
315
294
|
onSuccess: tokenContext => {
|
|
316
295
|
credentialsStorage.setToken(mcApiUrl, tokenContext);
|
|
317
296
|
console.log();
|
|
318
|
-
console.log(chalk.green(
|
|
297
|
+
console.log(chalk.green("Login successful."));
|
|
319
298
|
console.log();
|
|
320
299
|
}
|
|
321
300
|
});
|
|
322
301
|
await startServer(server);
|
|
323
302
|
if (options.headless) {
|
|
324
|
-
console.log(
|
|
303
|
+
console.log("Initiating headless authentication flow using Puppeteer...");
|
|
325
304
|
console.log();
|
|
326
305
|
await runHeadlessLogin(authUrl);
|
|
327
306
|
} else {
|
|
328
|
-
console.log(
|
|
329
|
-
console.log(
|
|
307
|
+
console.log("Initiating the OIDC authentication flow, opening the login page in your browser...");
|
|
308
|
+
console.log(" ".concat(authUrl));
|
|
330
309
|
console.log();
|
|
331
310
|
const open = await import('open');
|
|
332
311
|
await open.default(authUrl.toString());
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
var _Promise = require('@babel/runtime-corejs3/core-js-stable/promise');
|
|
4
4
|
var _mapInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/map');
|
|
5
5
|
var _startsWithInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/starts-with');
|
|
6
|
-
var
|
|
6
|
+
var _concatInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/concat');
|
|
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
9
|
var _setTimeout = require('@babel/runtime-corejs3/core-js-stable/set-timeout');
|
|
@@ -15,10 +15,10 @@ var crypto = require('node:crypto');
|
|
|
15
15
|
var process = require('node:process');
|
|
16
16
|
var chalk = require('chalk');
|
|
17
17
|
var applicationConfig = require('@commercetools-frontend/application-config');
|
|
18
|
-
var _package = require('./package-
|
|
18
|
+
var _package = require('./package-98adb0d5.cjs.dev.js');
|
|
19
19
|
var http = require('node:http');
|
|
20
20
|
var jwtDecode = require('jwt-decode');
|
|
21
|
-
var credentialsStorage$1 = require('./credentials-storage-
|
|
21
|
+
var credentialsStorage$1 = require('./credentials-storage-1826f1a2.cjs.dev.js');
|
|
22
22
|
require('@babel/runtime-corejs3/helpers/classCallCheck');
|
|
23
23
|
require('@babel/runtime-corejs3/helpers/createClass');
|
|
24
24
|
require('@babel/runtime-corejs3/core-js-stable/json/stringify');
|
|
@@ -50,7 +50,7 @@ function _interopNamespace(e) {
|
|
|
50
50
|
var _Promise__default = /*#__PURE__*/_interopDefault(_Promise);
|
|
51
51
|
var _mapInstanceProperty__default = /*#__PURE__*/_interopDefault(_mapInstanceProperty);
|
|
52
52
|
var _startsWithInstanceProperty__default = /*#__PURE__*/_interopDefault(_startsWithInstanceProperty);
|
|
53
|
-
var
|
|
53
|
+
var _concatInstanceProperty__default = /*#__PURE__*/_interopDefault(_concatInstanceProperty);
|
|
54
54
|
var _trimInstanceProperty__default = /*#__PURE__*/_interopDefault(_trimInstanceProperty);
|
|
55
55
|
var _flatMapInstanceProperty__default = /*#__PURE__*/_interopDefault(_flatMapInstanceProperty);
|
|
56
56
|
var _setTimeout__default = /*#__PURE__*/_interopDefault(_setTimeout);
|
|
@@ -62,21 +62,20 @@ var crypto__default = /*#__PURE__*/_interopDefault(crypto);
|
|
|
62
62
|
var process__default = /*#__PURE__*/_interopDefault(process);
|
|
63
63
|
var chalk__default = /*#__PURE__*/_interopDefault(chalk);
|
|
64
64
|
var http__default = /*#__PURE__*/_interopDefault(http);
|
|
65
|
-
var jwtDecode__default = /*#__PURE__*/_interopDefault(jwtDecode);
|
|
66
65
|
|
|
67
66
|
function createAuthCallbackServer(options) {
|
|
68
67
|
const server = http__default["default"].createServer(async (request, response) => {
|
|
69
68
|
try {
|
|
70
|
-
var
|
|
71
|
-
if ((
|
|
69
|
+
var _request$url;
|
|
70
|
+
if ((_request$url = request.url) !== null && _request$url !== void 0 && _includesInstanceProperty__default["default"](_request$url).call(_request$url, "/".concat(options.clientIdentifier, "/oidc/callback"))) {
|
|
72
71
|
const incomingUrl = new _URL__default["default"](request.url, 'http://localhost');
|
|
73
72
|
const sessionToken = incomingUrl.searchParams.get('sessionToken');
|
|
74
73
|
const requestedState = incomingUrl.searchParams.get('state');
|
|
75
74
|
if (!sessionToken) {
|
|
76
75
|
throw new Error('Invalid authentication flow (missing sessionToken)');
|
|
77
76
|
}
|
|
78
|
-
const decodedSessionToken =
|
|
79
|
-
if (decodedSessionToken
|
|
77
|
+
const decodedSessionToken = jwtDecode.jwtDecode(sessionToken);
|
|
78
|
+
if ((decodedSessionToken === null || decodedSessionToken === void 0 ? void 0 : decodedSessionToken.nonce) !== options.nonce) {
|
|
80
79
|
throw new Error('Invalid authentication flow (nonce mismatch)');
|
|
81
80
|
}
|
|
82
81
|
if (requestedState !== options.state) {
|
|
@@ -99,7 +98,7 @@ function createAuthCallbackServer(options) {
|
|
|
99
98
|
response.end(error.message);
|
|
100
99
|
} else {
|
|
101
100
|
console.error(error);
|
|
102
|
-
response.end(
|
|
101
|
+
response.end("Invalid authentication flow.");
|
|
103
102
|
}
|
|
104
103
|
server.close(() => {
|
|
105
104
|
process.exit();
|
|
@@ -111,14 +110,14 @@ function createAuthCallbackServer(options) {
|
|
|
111
110
|
|
|
112
111
|
const credentialsStorage = new credentialsStorage$1.CredentialsStorage();
|
|
113
112
|
const port = 3001;
|
|
114
|
-
const clientIdentifier =
|
|
113
|
+
const clientIdentifier = "mc-scripts-".concat(_package.pkgJson.version);
|
|
115
114
|
const isServerError = error => {
|
|
116
115
|
return error instanceof Error && 'code' in error;
|
|
117
116
|
};
|
|
118
117
|
const startServer = server => new _Promise__default["default"]((resolve, reject) => {
|
|
119
118
|
server.listen(port, 'localhost').on('listening', resolve).on('error', error => {
|
|
120
119
|
if (isServerError(error) && error.code === 'EADDRINUSE') {
|
|
121
|
-
return reject(new Error(
|
|
120
|
+
return reject(new Error("The address \"localhost:".concat(port, "\" is already in use. Are you running a Merchant Center application in other process? Please stop that and try again."), {
|
|
122
121
|
cause: error
|
|
123
122
|
}));
|
|
124
123
|
}
|
|
@@ -154,8 +153,9 @@ const resolveProjectKey = async options => {
|
|
|
154
153
|
return process__default["default"].env.CTP_PROJECT_KEY;
|
|
155
154
|
}
|
|
156
155
|
try {
|
|
156
|
+
var _applicationConfig$en;
|
|
157
157
|
const applicationConfig$1 = await applicationConfig.processConfig();
|
|
158
|
-
return applicationConfig$1.env.__DEVELOPMENT__
|
|
158
|
+
return (_applicationConfig$en = applicationConfig$1.env.__DEVELOPMENT__) === null || _applicationConfig$en === void 0 || (_applicationConfig$en = _applicationConfig$en.oidc) === null || _applicationConfig$en === void 0 ? void 0 : _applicationConfig$en.initialProjectKey;
|
|
159
159
|
} catch (error) {
|
|
160
160
|
// It's ok if there's not application config file or if it does not contain the initialProjectKey
|
|
161
161
|
return;
|
|
@@ -164,10 +164,10 @@ const resolveProjectKey = async options => {
|
|
|
164
164
|
const mapOAuthScopesToClaims = scopes => {
|
|
165
165
|
return _mapInstanceProperty__default["default"](scopes).call(scopes, scope => {
|
|
166
166
|
if (_startsWithInstanceProperty__default["default"](scope).call(scope, 'view_')) {
|
|
167
|
-
return
|
|
167
|
+
return "view:".concat(scope);
|
|
168
168
|
}
|
|
169
169
|
if (_startsWithInstanceProperty__default["default"](scope).call(scope, 'manage_')) {
|
|
170
|
-
return
|
|
170
|
+
return "manage:".concat(scope);
|
|
171
171
|
}
|
|
172
172
|
return scope;
|
|
173
173
|
});
|
|
@@ -175,10 +175,12 @@ const mapOAuthScopesToClaims = scopes => {
|
|
|
175
175
|
const mapAdditionalOAuthScopesToClaims = (name, scopes) => {
|
|
176
176
|
return _mapInstanceProperty__default["default"](scopes).call(scopes, scope => {
|
|
177
177
|
if (_startsWithInstanceProperty__default["default"](scope).call(scope, 'view_')) {
|
|
178
|
-
|
|
178
|
+
var _context;
|
|
179
|
+
return _concatInstanceProperty__default["default"](_context = "view/".concat(name, ":")).call(_context, scope);
|
|
179
180
|
}
|
|
180
181
|
if (_startsWithInstanceProperty__default["default"](scope).call(scope, 'manage_')) {
|
|
181
|
-
|
|
182
|
+
var _context2;
|
|
183
|
+
return _concatInstanceProperty__default["default"](_context2 = "manage/".concat(name, ":")).call(_context2, scope);
|
|
182
184
|
}
|
|
183
185
|
return scope;
|
|
184
186
|
});
|
|
@@ -190,15 +192,15 @@ const resolveOAuthScopes = async options => {
|
|
|
190
192
|
|
|
191
193
|
// We first check whether the user has set the CTP_OAUTH_SCOPES environment variable
|
|
192
194
|
if (process__default["default"].env.CTP_OAUTH_SCOPES) {
|
|
193
|
-
var
|
|
194
|
-
return mapOAuthScopesToClaims(((
|
|
195
|
+
var _process$env$CTP_OAUT, _process$env$CTP_OAUT2, _context3;
|
|
196
|
+
return mapOAuthScopesToClaims((_process$env$CTP_OAUT = (_process$env$CTP_OAUT2 = process__default["default"].env.CTP_OAUTH_SCOPES) === null || _process$env$CTP_OAUT2 === void 0 ? void 0 : _mapInstanceProperty__default["default"](_context3 = _process$env$CTP_OAUT2.split(',')).call(_context3, scope => _trimInstanceProperty__default["default"](scope).call(scope))) !== null && _process$env$CTP_OAUT !== void 0 ? _process$env$CTP_OAUT : []);
|
|
195
197
|
}
|
|
196
198
|
try {
|
|
197
|
-
var
|
|
199
|
+
var _applicationConfig$en2, _applicationConfig$en3, _configuredOAuthScope, _configuredOAuthScope2, _configuredAdditional, _configuredAdditional2;
|
|
198
200
|
const applicationConfig$1 = await applicationConfig.processConfig();
|
|
199
|
-
const configuredOAuthScopes = applicationConfig$1.env.__DEVELOPMENT__
|
|
200
|
-
const configuredAdditionalOAuthScopes = applicationConfig$1.env.__DEVELOPMENT__
|
|
201
|
-
return [...mapOAuthScopesToClaims(configuredOAuthScopes
|
|
201
|
+
const configuredOAuthScopes = (_applicationConfig$en2 = applicationConfig$1.env.__DEVELOPMENT__) === null || _applicationConfig$en2 === void 0 || (_applicationConfig$en2 = _applicationConfig$en2.oidc) === null || _applicationConfig$en2 === void 0 ? void 0 : _applicationConfig$en2.oAuthScopes;
|
|
202
|
+
const configuredAdditionalOAuthScopes = (_applicationConfig$en3 = applicationConfig$1.env.__DEVELOPMENT__) === null || _applicationConfig$en3 === void 0 || (_applicationConfig$en3 = _applicationConfig$en3.oidc) === null || _applicationConfig$en3 === void 0 ? void 0 : _applicationConfig$en3.additionalOAuthScopes;
|
|
203
|
+
return [...mapOAuthScopesToClaims((_configuredOAuthScope = configuredOAuthScopes === null || configuredOAuthScopes === void 0 ? void 0 : configuredOAuthScopes.view) !== null && _configuredOAuthScope !== void 0 ? _configuredOAuthScope : []), ...mapOAuthScopesToClaims((_configuredOAuthScope2 = configuredOAuthScopes === null || configuredOAuthScopes === void 0 ? void 0 : configuredOAuthScopes.manage) !== null && _configuredOAuthScope2 !== void 0 ? _configuredOAuthScope2 : []), ...((_configuredAdditional = configuredAdditionalOAuthScopes === null || configuredAdditionalOAuthScopes === void 0 ? void 0 : _flatMapInstanceProperty__default["default"](configuredAdditionalOAuthScopes).call(configuredAdditionalOAuthScopes, scope => mapAdditionalOAuthScopesToClaims(scope.name, scope.view))) !== null && _configuredAdditional !== void 0 ? _configuredAdditional : []), ...((_configuredAdditional2 = configuredAdditionalOAuthScopes === null || configuredAdditionalOAuthScopes === void 0 ? void 0 : _flatMapInstanceProperty__default["default"](configuredAdditionalOAuthScopes).call(configuredAdditionalOAuthScopes, scope => mapAdditionalOAuthScopesToClaims(scope.name, scope.manage))) !== null && _configuredAdditional2 !== void 0 ? _configuredAdditional2 : [])];
|
|
202
204
|
} catch (error) {
|
|
203
205
|
// It's ok if there's not application config file or if it does not contain the initialProjectKey
|
|
204
206
|
return [];
|
|
@@ -222,7 +224,7 @@ async function runHeadlessLogin(authUrl) {
|
|
|
222
224
|
let puppeteer;
|
|
223
225
|
try {
|
|
224
226
|
puppeteer = await Promise.resolve().then(function () { return /*#__PURE__*/_interopNamespace(require('puppeteer')); });
|
|
225
|
-
} catch {
|
|
227
|
+
} catch (_unused) {
|
|
226
228
|
throw new Error('Puppeteer is required for headless login. Install it with: npm install puppeteer');
|
|
227
229
|
}
|
|
228
230
|
const browser = await puppeteer.default.launch({
|
|
@@ -243,17 +245,9 @@ async function runHeadlessLogin(authUrl) {
|
|
|
243
245
|
// Dismiss cookie banner if present
|
|
244
246
|
// Note: Using string-based evaluate to avoid bundler transforming Array.from
|
|
245
247
|
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
|
-
`);
|
|
248
|
+
await page.evaluate("\n (function() {\n var buttons = Array.from(document.querySelectorAll('button'));\n var acceptBtn = buttons.find(function(btn) {\n return btn.textContent && btn.textContent.includes('Accept all cookies');\n });\n if (acceptBtn) acceptBtn.click();\n })()\n ");
|
|
255
249
|
await new _Promise__default["default"](resolve => _setTimeout__default["default"](resolve, 500));
|
|
256
|
-
} catch {
|
|
250
|
+
} catch (_unused2) {
|
|
257
251
|
// Cookie banner not found or already dismissed
|
|
258
252
|
}
|
|
259
253
|
|
|
@@ -262,15 +256,7 @@ async function runHeadlessLogin(authUrl) {
|
|
|
262
256
|
await new _Promise__default["default"](resolve => _setTimeout__default["default"](resolve, 500));
|
|
263
257
|
|
|
264
258
|
// 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
|
-
`);
|
|
259
|
+
await page.evaluate("\n (function() {\n var buttons = Array.from(document.querySelectorAll('button'));\n var nextBtn = buttons.find(function(btn) {\n return btn.textContent && btn.textContent.toLowerCase().includes('next');\n });\n if (nextBtn) nextBtn.click();\n })()\n ");
|
|
274
260
|
|
|
275
261
|
// Wait for password field
|
|
276
262
|
await page.waitForSelector('input[name="password"]', {
|
|
@@ -283,15 +269,7 @@ async function runHeadlessLogin(authUrl) {
|
|
|
283
269
|
await new _Promise__default["default"](resolve => _setTimeout__default["default"](resolve, 500));
|
|
284
270
|
|
|
285
271
|
// 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
|
-
`);
|
|
272
|
+
await page.evaluate("\n (function() {\n var buttons = Array.from(document.querySelectorAll('button'));\n var submitBtn = buttons.find(function(btn) {\n return btn.textContent && btn.textContent.toLowerCase().includes('submit');\n });\n if (submitBtn) submitBtn.click();\n })()\n ");
|
|
295
273
|
|
|
296
274
|
// Wait for the callback to be processed (the server will close and exit)
|
|
297
275
|
// We just need to keep the browser alive until the redirect happens
|
|
@@ -323,17 +301,17 @@ async function run(options) {
|
|
|
323
301
|
if (!mcApiUrl) {
|
|
324
302
|
throw new Error('No Merchant Center API URL found. Aborting.');
|
|
325
303
|
}
|
|
326
|
-
console.log(
|
|
304
|
+
console.log("Using Merchant Center environment \"".concat(chalk__default["default"].green(mcApiUrl), "\"."));
|
|
327
305
|
console.log();
|
|
328
306
|
if (!options.force && credentialsStorage.isSessionValid(mcApiUrl)) {
|
|
329
|
-
console.log(
|
|
307
|
+
console.log("You already have a valid session.");
|
|
330
308
|
return;
|
|
331
309
|
}
|
|
332
310
|
const projectKey = await resolveProjectKey(options);
|
|
333
311
|
const oauthScopes = await resolveOAuthScopes(options);
|
|
334
312
|
const scopes = ['openid'];
|
|
335
313
|
if (projectKey) {
|
|
336
|
-
scopes.push(
|
|
314
|
+
scopes.push("project_key:".concat(projectKey));
|
|
337
315
|
_forEachInstanceProperty__default["default"](oauthScopes).call(oauthScopes, scope => {
|
|
338
316
|
scopes.push(scope);
|
|
339
317
|
});
|
|
@@ -343,7 +321,7 @@ async function run(options) {
|
|
|
343
321
|
const authUrl = new _URL__default["default"]('/login/authorize', mcApiUrl);
|
|
344
322
|
authUrl.searchParams.set('response_type', 'id_token');
|
|
345
323
|
authUrl.searchParams.set('response_mode', 'query');
|
|
346
|
-
authUrl.searchParams.set('client_id',
|
|
324
|
+
authUrl.searchParams.set('client_id', "__local:".concat(clientIdentifier));
|
|
347
325
|
authUrl.searchParams.set('scope', scopes.join(' '));
|
|
348
326
|
authUrl.searchParams.set('state', state);
|
|
349
327
|
authUrl.searchParams.set('nonce', nonce);
|
|
@@ -354,18 +332,18 @@ async function run(options) {
|
|
|
354
332
|
onSuccess: tokenContext => {
|
|
355
333
|
credentialsStorage.setToken(mcApiUrl, tokenContext);
|
|
356
334
|
console.log();
|
|
357
|
-
console.log(chalk__default["default"].green(
|
|
335
|
+
console.log(chalk__default["default"].green("Login successful."));
|
|
358
336
|
console.log();
|
|
359
337
|
}
|
|
360
338
|
});
|
|
361
339
|
await startServer(server);
|
|
362
340
|
if (options.headless) {
|
|
363
|
-
console.log(
|
|
341
|
+
console.log("Initiating headless authentication flow using Puppeteer...");
|
|
364
342
|
console.log();
|
|
365
343
|
await runHeadlessLogin(authUrl);
|
|
366
344
|
} else {
|
|
367
|
-
console.log(
|
|
368
|
-
console.log(
|
|
345
|
+
console.log("Initiating the OIDC authentication flow, opening the login page in your browser...");
|
|
346
|
+
console.log(" ".concat(authUrl));
|
|
369
347
|
console.log();
|
|
370
348
|
const open = await Promise.resolve().then(function () { return /*#__PURE__*/_interopNamespace(require('open')); });
|
|
371
349
|
await open.default(authUrl.toString());
|
|
@@ -6,6 +6,7 @@ var _reduceInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/ins
|
|
|
6
6
|
var _Object$entries = require('@babel/runtime-corejs3/core-js-stable/object/entries');
|
|
7
7
|
var _filterInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/filter');
|
|
8
8
|
var _includesInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/includes');
|
|
9
|
+
var _concatInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/concat');
|
|
9
10
|
var _Object$keys = require('@babel/runtime-corejs3/core-js-stable/object/keys');
|
|
10
11
|
var _Object$getOwnPropertySymbols = require('@babel/runtime-corejs3/core-js-stable/object/get-own-property-symbols');
|
|
11
12
|
var _Object$getOwnPropertyDescriptor = require('@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptor');
|
|
@@ -21,6 +22,7 @@ var _reduceInstanceProperty__default = /*#__PURE__*/_interopDefault(_reduceInsta
|
|
|
21
22
|
var _Object$entries__default = /*#__PURE__*/_interopDefault(_Object$entries);
|
|
22
23
|
var _filterInstanceProperty__default = /*#__PURE__*/_interopDefault(_filterInstanceProperty);
|
|
23
24
|
var _includesInstanceProperty__default = /*#__PURE__*/_interopDefault(_includesInstanceProperty);
|
|
25
|
+
var _concatInstanceProperty__default = /*#__PURE__*/_interopDefault(_concatInstanceProperty);
|
|
24
26
|
var _Object$keys__default = /*#__PURE__*/_interopDefault(_Object$keys);
|
|
25
27
|
var _Object$getOwnPropertySymbols__default = /*#__PURE__*/_interopDefault(_Object$getOwnPropertySymbols);
|
|
26
28
|
var _Object$getOwnPropertyDescriptor__default = /*#__PURE__*/_interopDefault(_Object$getOwnPropertyDescriptor);
|
|
@@ -43,7 +45,7 @@ function hasJsxRuntime() {
|
|
|
43
45
|
}
|
|
44
46
|
|
|
45
47
|
function ownKeys(e, r) { var t = _Object$keys__default["default"](e); if (_Object$getOwnPropertySymbols__default["default"]) { var o = _Object$getOwnPropertySymbols__default["default"](e); r && (o = _filterInstanceProperty__default["default"](o).call(o, function (r) { return _Object$getOwnPropertyDescriptor__default["default"](e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
46
|
-
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var
|
|
48
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var _context4, _context5; var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? _forEachInstanceProperty__default["default"](_context4 = ownKeys(Object(t), !0)).call(_context4, function (r) { _defineProperty(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors__default["default"] ? _Object$defineProperties__default["default"](e, _Object$getOwnPropertyDescriptors__default["default"](t)) : _forEachInstanceProperty__default["default"](_context5 = ownKeys(Object(t))).call(_context5, function (r) { _Object$defineProperty__default["default"](e, r, _Object$getOwnPropertyDescriptor__default["default"](t, r)); }); } return e; }
|
|
47
49
|
|
|
48
50
|
// Dependencies to be split/grouped into separate chunks for the Webpack build.
|
|
49
51
|
// This is useful to reduce the main bundle size and have more dedicated
|
|
@@ -71,7 +73,8 @@ const removeNonExistantDependencies = (manualChunks, appDependencies) => {
|
|
|
71
73
|
if (existingVendors.length > 0) {
|
|
72
74
|
chunkGroups[chunkName] = existingVendors;
|
|
73
75
|
} else {
|
|
74
|
-
|
|
76
|
+
var _context2;
|
|
77
|
+
console.log(chalk__default["default"].yellow(_concatInstanceProperty__default["default"](_context2 = "\nFiltering out chunk \"".concat(chunkName, "\" because its configured dependencies does not exist in the application: ")).call(_context2, vendors, "\n")));
|
|
75
78
|
}
|
|
76
79
|
return chunkGroups;
|
|
77
80
|
}, {});
|
|
@@ -79,15 +82,15 @@ const removeNonExistantDependencies = (manualChunks, appDependencies) => {
|
|
|
79
82
|
|
|
80
83
|
// Reference: https://webpack.js.org/plugins/split-chunks-plugin/
|
|
81
84
|
function getWepbackCacheGroups(appDependencies) {
|
|
82
|
-
var
|
|
85
|
+
var _context3;
|
|
83
86
|
const filteredDependencies = removeNonExistantDependencies(manualChunks, _Object$keys__default["default"](appDependencies));
|
|
84
|
-
const result = _reduceInstanceProperty__default["default"](
|
|
87
|
+
const result = _reduceInstanceProperty__default["default"](_context3 = _Object$entries__default["default"](filteredDependencies)).call(_context3, (previousChunks, _ref3) => {
|
|
85
88
|
let _ref4 = _slicedToArray(_ref3, 2),
|
|
86
89
|
chunkName = _ref4[0],
|
|
87
90
|
vendors = _ref4[1];
|
|
88
91
|
return _objectSpread(_objectSpread({}, previousChunks), {}, {
|
|
89
92
|
[chunkName]: {
|
|
90
|
-
test: new RegExp(
|
|
93
|
+
test: new RegExp("[\\/]node_modules[\\/](".concat(vendors.join('|'), ")[\\/]")),
|
|
91
94
|
name: chunkName,
|
|
92
95
|
chunks: 'all'
|
|
93
96
|
}
|
|
@@ -4,6 +4,7 @@ import _reduceInstanceProperty from '@babel/runtime-corejs3/core-js-stable/insta
|
|
|
4
4
|
import _Object$entries from '@babel/runtime-corejs3/core-js-stable/object/entries';
|
|
5
5
|
import _filterInstanceProperty from '@babel/runtime-corejs3/core-js-stable/instance/filter';
|
|
6
6
|
import _includesInstanceProperty from '@babel/runtime-corejs3/core-js-stable/instance/includes';
|
|
7
|
+
import _concatInstanceProperty from '@babel/runtime-corejs3/core-js-stable/instance/concat';
|
|
7
8
|
import _Object$keys from '@babel/runtime-corejs3/core-js-stable/object/keys';
|
|
8
9
|
import _Object$getOwnPropertySymbols from '@babel/runtime-corejs3/core-js-stable/object/get-own-property-symbols';
|
|
9
10
|
import _Object$getOwnPropertyDescriptor from '@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptor';
|
|
@@ -26,7 +27,7 @@ function hasJsxRuntime() {
|
|
|
26
27
|
}
|
|
27
28
|
|
|
28
29
|
function ownKeys(e, r) { var t = _Object$keys(e); if (_Object$getOwnPropertySymbols) { var o = _Object$getOwnPropertySymbols(e); r && (o = _filterInstanceProperty(o).call(o, function (r) { return _Object$getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
29
|
-
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var
|
|
30
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var _context4, _context5; var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? _forEachInstanceProperty(_context4 = ownKeys(Object(t), !0)).call(_context4, function (r) { _defineProperty(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(e, _Object$getOwnPropertyDescriptors(t)) : _forEachInstanceProperty(_context5 = ownKeys(Object(t))).call(_context5, function (r) { _Object$defineProperty(e, r, _Object$getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
30
31
|
|
|
31
32
|
// Dependencies to be split/grouped into separate chunks for the Webpack build.
|
|
32
33
|
// This is useful to reduce the main bundle size and have more dedicated
|
|
@@ -54,7 +55,8 @@ const removeNonExistantDependencies = (manualChunks, appDependencies) => {
|
|
|
54
55
|
if (existingVendors.length > 0) {
|
|
55
56
|
chunkGroups[chunkName] = existingVendors;
|
|
56
57
|
} else {
|
|
57
|
-
|
|
58
|
+
var _context2;
|
|
59
|
+
console.log(chalk.yellow(_concatInstanceProperty(_context2 = "\nFiltering out chunk \"".concat(chunkName, "\" because its configured dependencies does not exist in the application: ")).call(_context2, vendors, "\n")));
|
|
58
60
|
}
|
|
59
61
|
return chunkGroups;
|
|
60
62
|
}, {});
|
|
@@ -62,15 +64,15 @@ const removeNonExistantDependencies = (manualChunks, appDependencies) => {
|
|
|
62
64
|
|
|
63
65
|
// Reference: https://webpack.js.org/plugins/split-chunks-plugin/
|
|
64
66
|
function getWepbackCacheGroups(appDependencies) {
|
|
65
|
-
var
|
|
67
|
+
var _context3;
|
|
66
68
|
const filteredDependencies = removeNonExistantDependencies(manualChunks, _Object$keys(appDependencies));
|
|
67
|
-
const result = _reduceInstanceProperty(
|
|
69
|
+
const result = _reduceInstanceProperty(_context3 = _Object$entries(filteredDependencies)).call(_context3, (previousChunks, _ref3) => {
|
|
68
70
|
let _ref4 = _slicedToArray(_ref3, 2),
|
|
69
71
|
chunkName = _ref4[0],
|
|
70
72
|
vendors = _ref4[1];
|
|
71
73
|
return _objectSpread(_objectSpread({}, previousChunks), {}, {
|
|
72
74
|
[chunkName]: {
|
|
73
|
-
test: new RegExp(
|
|
75
|
+
test: new RegExp("[\\/]node_modules[\\/](".concat(vendors.join('|'), ")[\\/]")),
|
|
74
76
|
name: chunkName,
|
|
75
77
|
chunks: 'all'
|
|
76
78
|
}
|