@commercetools-frontend/mc-scripts 25.0.0 → 25.2.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.
Files changed (84) hide show
  1. package/application-runtime/dist/commercetools-frontend-mc-scripts-application-runtime.cjs.dev.js +1 -1
  2. package/application-runtime/dist/commercetools-frontend-mc-scripts-application-runtime.cjs.prod.js +1 -1
  3. package/application-runtime/dist/commercetools-frontend-mc-scripts-application-runtime.esm.js +1 -1
  4. package/cli/dist/commercetools-frontend-mc-scripts-cli.cjs.dev.js +28 -14
  5. package/cli/dist/commercetools-frontend-mc-scripts-cli.cjs.prod.js +28 -14
  6. package/cli/dist/commercetools-frontend-mc-scripts-cli.esm.js +28 -14
  7. package/dist/{build-50f29fb0.cjs.prod.js → build-182a099c.cjs.prod.js} +7 -7
  8. package/dist/{build-0b4c6b04.esm.js → build-220a1658.esm.js} +7 -7
  9. package/dist/{build-1baf8a00.cjs.dev.js → build-519d246d.cjs.dev.js} +7 -7
  10. package/dist/{build-vite-e26f6c9f.cjs.dev.js → build-vite-837e7c94.cjs.dev.js} +64 -43
  11. package/dist/{build-vite-85211835.esm.js → build-vite-8cae71a0.esm.js} +61 -24
  12. package/dist/{build-vite-4a6c90c2.cjs.prod.js → build-vite-b007241b.cjs.prod.js} +64 -43
  13. package/dist/commercetools-frontend-mc-scripts.cjs.dev.js +1 -1
  14. package/dist/commercetools-frontend-mc-scripts.cjs.prod.js +1 -1
  15. package/dist/commercetools-frontend-mc-scripts.esm.js +1 -1
  16. package/dist/{compile-html-adfef598.esm.js → compile-html-025cd493.esm.js} +2 -4
  17. package/dist/{compile-html-b80f9651.cjs.prod.js → compile-html-50fd05ec.cjs.prod.js} +2 -5
  18. package/dist/{compile-html-8679f721.cjs.dev.js → compile-html-f4ac88cc.cjs.dev.js} +2 -5
  19. package/dist/config-sync-0b96d430.esm.js +255 -0
  20. package/dist/config-sync-b3072939.cjs.prod.js +265 -0
  21. package/dist/config-sync-ci-4a09aa00.cjs.prod.js +305 -0
  22. package/dist/config-sync-ci-85e3fec2.esm.js +294 -0
  23. package/dist/config-sync-ci-eadb8bfc.cjs.dev.js +305 -0
  24. package/dist/config-sync-f8fca39f.cjs.dev.js +265 -0
  25. package/dist/{config-sync-87ba9f28.cjs.prod.js → config-sync-helpers-11fc328f.cjs.prod.js} +193 -326
  26. package/dist/{config-sync-27ca0c93.cjs.dev.js → config-sync-helpers-dab59ed9.cjs.dev.js} +195 -328
  27. package/dist/{config-sync-ff4b1e5b.esm.js → config-sync-helpers-fe6ea729.esm.js} +186 -323
  28. package/dist/{create-postcss-config-34bab342.cjs.prod.js → create-postcss-config-56b74a34.cjs.prod.js} +1 -1
  29. package/dist/{create-postcss-config-0e833724.cjs.dev.js → create-postcss-config-78879a12.cjs.dev.js} +1 -1
  30. package/dist/{create-postcss-config-e6dfba3f.esm.js → create-postcss-config-95f9bf62.esm.js} +1 -1
  31. package/dist/{create-webpack-config-for-development-fe0945ce.cjs.prod.js → create-webpack-config-for-development-3eb1b365.cjs.prod.js} +7 -7
  32. package/dist/{create-webpack-config-for-development-2ac1d86f.cjs.dev.js → create-webpack-config-for-development-62b89920.cjs.dev.js} +7 -7
  33. package/dist/{create-webpack-config-for-development-be2722d6.esm.js → create-webpack-config-for-development-a28736fa.esm.js} +7 -7
  34. package/dist/{create-webpack-config-for-production-66c77849.esm.js → create-webpack-config-for-production-21ea561f.esm.js} +8 -8
  35. package/dist/{create-webpack-config-for-production-2200e554.cjs.prod.js → create-webpack-config-for-production-3b6599db.cjs.prod.js} +8 -8
  36. package/dist/{create-webpack-config-for-production-d2c41a9d.cjs.dev.js → create-webpack-config-for-production-e5ed8805.cjs.dev.js} +8 -8
  37. package/dist/{credentials-storage-381abf27.cjs.prod.js → credentials-storage-6d592cd6.cjs.prod.js} +21 -3
  38. package/dist/{credentials-storage-de220814.cjs.dev.js → credentials-storage-c4c5980e.cjs.dev.js} +21 -3
  39. package/dist/{credentials-storage-7285d7b4.esm.js → credentials-storage-fcc77fb6.esm.js} +21 -3
  40. package/dist/declarations/src/types.d.ts +4 -0
  41. package/dist/{deployment-previews-set-7f9fbfe5.esm.js → deployment-previews-set-7d49e7df.esm.js} +22 -27
  42. package/dist/{deployment-previews-set-3697be5e.cjs.dev.js → deployment-previews-set-8d6a1e99.cjs.dev.js} +22 -28
  43. package/dist/{deployment-previews-set-e92403f7.cjs.prod.js → deployment-previews-set-f8ce3db7.cjs.prod.js} +22 -28
  44. package/dist/{graphql-requests-bab5fcc3.cjs.dev.js → graphql-requests-b57fca4c.cjs.prod.js} +5 -8
  45. package/dist/{graphql-requests-d8bc2292.esm.js → graphql-requests-d2fa2ca7.esm.js} +6 -9
  46. package/dist/{graphql-requests-8ef89149.cjs.prod.js → graphql-requests-da194989.cjs.dev.js} +5 -8
  47. package/dist/{i18n-message-complilation-8aec9d1b.esm.js → i18n-message-complilation-21d3b0aa.esm.js} +1 -1
  48. package/dist/{i18n-message-complilation-3f80e8d6.cjs.dev.js → i18n-message-complilation-7311cb29.cjs.dev.js} +1 -1
  49. package/dist/{i18n-message-complilation-393d344a.cjs.prod.js → i18n-message-complilation-7762da61.cjs.prod.js} +1 -1
  50. package/dist/{login-5fd67aac.cjs.prod.js → login-9774c9cc.cjs.prod.js} +154 -38
  51. package/dist/login-abb38213.esm.js +337 -0
  52. package/dist/{login-9fac9eee.cjs.dev.js → login-f4550251.cjs.dev.js} +154 -38
  53. package/dist/{optimizations-ea21b802.cjs.prod.js → optimizations-7789145e.cjs.dev.js} +5 -8
  54. package/dist/{optimizations-ea71a24a.esm.js → optimizations-bf991634.esm.js} +5 -7
  55. package/dist/{optimizations-ebbeaf88.cjs.dev.js → optimizations-fb93514f.cjs.prod.js} +5 -8
  56. package/dist/{package-ff04bcf7.cjs.dev.js → package-0eebca1b.cjs.dev.js} +21 -11
  57. package/dist/{package-4bdd2ccf.esm.js → package-9e6910b8.esm.js} +21 -11
  58. package/dist/{package-428d5001.cjs.prod.js → package-b9298ce3.cjs.prod.js} +21 -11
  59. package/dist/{paths-7bf7e88e.esm.js → paths-39f22b8b.esm.js} +4 -9
  60. package/dist/{paths-af1a725a.cjs.prod.js → paths-7768b440.cjs.prod.js} +4 -10
  61. package/dist/{paths-ec3e3a7d.cjs.dev.js → paths-b76fc753.cjs.dev.js} +4 -10
  62. package/dist/{serve-04a03d5f.cjs.dev.js → serve-38456e1b.cjs.dev.js} +7 -6
  63. package/dist/{serve-fb1a0f5a.esm.js → serve-be1f9439.esm.js} +6 -6
  64. package/dist/{serve-2a863026.cjs.prod.js → serve-cc4a766d.cjs.prod.js} +7 -6
  65. package/dist/{start-643a55bb.esm.js → start-109f9462.esm.js} +8 -9
  66. package/dist/{start-47ea5e04.cjs.dev.js → start-7765f44c.cjs.dev.js} +8 -9
  67. package/dist/{start-84cdf12b.cjs.prod.js → start-e014127c.cjs.prod.js} +8 -9
  68. package/dist/{start-vite-eea72ba9.cjs.dev.js → start-vite-068e9f73.cjs.dev.js} +3 -4
  69. package/dist/{start-vite-d548c121.cjs.prod.js → start-vite-29078b3a.cjs.prod.js} +3 -4
  70. package/dist/{start-vite-d649d1f3.esm.js → start-vite-7d1161e8.esm.js} +3 -4
  71. package/dist/{vite-plugin-svgr-53ef97c7.cjs.dev.js → vite-plugin-svgr-4034a834.cjs.prod.js} +4 -4
  72. package/dist/{vite-plugin-svgr-5de1cad9.cjs.prod.js → vite-plugin-svgr-7d06f400.cjs.dev.js} +4 -4
  73. package/dist/{vite-plugin-svgr-22c8d518.esm.js → vite-plugin-svgr-de6ee7da.esm.js} +4 -4
  74. package/package.json +21 -11
  75. package/postcss/dist/commercetools-frontend-mc-scripts-postcss.cjs.dev.js +2 -2
  76. package/postcss/dist/commercetools-frontend-mc-scripts-postcss.cjs.prod.js +2 -2
  77. package/postcss/dist/commercetools-frontend-mc-scripts-postcss.esm.js +2 -2
  78. package/webpack/dist/commercetools-frontend-mc-scripts-webpack.cjs.dev.js +6 -6
  79. package/webpack/dist/commercetools-frontend-mc-scripts-webpack.cjs.prod.js +6 -6
  80. package/webpack/dist/commercetools-frontend-mc-scripts-webpack.esm.js +6 -6
  81. package/webpack-loaders/i18n-message-compilation-loader/dist/commercetools-frontend-mc-scripts-webpack-loaders-i18n-message-compilation-loader.cjs.dev.js +1 -1
  82. package/webpack-loaders/i18n-message-compilation-loader/dist/commercetools-frontend-mc-scripts-webpack-loaders-i18n-message-compilation-loader.cjs.prod.js +1 -1
  83. package/webpack-loaders/i18n-message-compilation-loader/dist/commercetools-frontend-mc-scripts-webpack-loaders-i18n-message-compilation-loader.esm.js +1 -1
  84. package/dist/login-9ee43381.esm.js +0 -223
@@ -1,5 +1,5 @@
1
1
  import { compile } from '@formatjs/cli-lib';
2
- import { g as getI18nMessageFormat, h as handleMessageCompilationError } from '../../../dist/i18n-message-complilation-8aec9d1b.esm.js';
2
+ import { g as getI18nMessageFormat, h as handleMessageCompilationError } from '../../../dist/i18n-message-complilation-21d3b0aa.esm.js';
3
3
  import '@babel/runtime-corejs3/core-js-stable/object/values';
4
4
  import 'chalk';
5
5
 
@@ -1,223 +0,0 @@
1
- import _Promise from '@babel/runtime-corejs3/core-js-stable/promise';
2
- import _mapInstanceProperty from '@babel/runtime-corejs3/core-js-stable/instance/map';
3
- import _startsWithInstanceProperty from '@babel/runtime-corejs3/core-js-stable/instance/starts-with';
4
- import _concatInstanceProperty from '@babel/runtime-corejs3/core-js-stable/instance/concat';
5
- import _trimInstanceProperty from '@babel/runtime-corejs3/core-js-stable/instance/trim';
6
- import _flatMapInstanceProperty from '@babel/runtime-corejs3/core-js-stable/instance/flat-map';
7
- import _forEachInstanceProperty from '@babel/runtime-corejs3/core-js-stable/instance/for-each';
8
- import _URL from '@babel/runtime-corejs3/core-js-stable/url';
9
- import crypto from 'node:crypto';
10
- import process, { exit } from 'node:process';
11
- import chalk from 'chalk';
12
- import { processConfig } from '@commercetools-frontend/application-config';
13
- import { p as pkgJson } from './package-4bdd2ccf.esm.js';
14
- import _includesInstanceProperty from '@babel/runtime-corejs3/core-js-stable/instance/includes';
15
- import http from 'node:http';
16
- import jwtDecode from 'jwt-decode';
17
- import { C as CredentialsStorage } from './credentials-storage-7285d7b4.esm.js';
18
- import '@babel/runtime-corejs3/helpers/classCallCheck';
19
- import '@babel/runtime-corejs3/helpers/createClass';
20
- import '@babel/runtime-corejs3/core-js-stable/json/stringify';
21
- import '@babel/runtime-corejs3/core-js-stable/date/now';
22
- import 'node:fs';
23
- import 'node:os';
24
- import 'node:path';
25
- import './does-file-exist-32618334.esm.js';
26
-
27
- function createAuthCallbackServer(options) {
28
- const server = http.createServer(async (request, response) => {
29
- try {
30
- var _request$url;
31
- if ((_request$url = request.url) !== null && _request$url !== void 0 && _includesInstanceProperty(_request$url).call(_request$url, "/".concat(options.clientIdentifier, "/oidc/callback"))) {
32
- const incomingUrl = new _URL(request.url, 'http://localhost');
33
- const sessionToken = incomingUrl.searchParams.get('sessionToken');
34
- const requestedState = incomingUrl.searchParams.get('state');
35
- if (!sessionToken) {
36
- throw new Error('Invalid authentication flow (missing sessionToken)');
37
- }
38
- const decodedSessionToken = jwtDecode(sessionToken);
39
- if ((decodedSessionToken === null || decodedSessionToken === void 0 ? void 0 : decodedSessionToken.nonce) !== options.nonce) {
40
- throw new Error('Invalid authentication flow (nonce mismatch)');
41
- }
42
- if (requestedState !== options.state) {
43
- throw new Error('Invalid authentication flow (state mismatch)');
44
- }
45
- options.onSuccess({
46
- token: sessionToken,
47
- expiresAt: decodedSessionToken.exp
48
- });
49
- response.setHeader('content-type', 'text/html');
50
- response.end('Success!');
51
- server.close(() => {
52
- exit();
53
- });
54
- }
55
- } catch (error) {
56
- response.setHeader('content-type', 'text/html');
57
- if (error instanceof Error) {
58
- console.error(error.message);
59
- response.end(error.message);
60
- } else {
61
- console.error(error);
62
- response.end("Invalid authentication flow.");
63
- }
64
- server.close(() => {
65
- exit();
66
- });
67
- }
68
- });
69
- return server;
70
- }
71
-
72
- const credentialsStorage = new CredentialsStorage();
73
- const port = 3001;
74
- const clientIdentifier = "mc-scripts-".concat(pkgJson.version);
75
- const isServerError = error => {
76
- return error instanceof Error && 'code' in error;
77
- };
78
- const startServer = server => new _Promise((resolve, reject) => {
79
- server.listen(port, 'localhost').on('listening', resolve).on('error', error => {
80
- if (isServerError(error) && error.code === 'EADDRINUSE') {
81
- 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."), {
82
- cause: error
83
- }));
84
- }
85
- return reject(new Error('Problem starting server', {
86
- cause: error
87
- }));
88
- }).on('close', () => {
89
- process.exit();
90
- });
91
- });
92
- const resolveMcApiUrl = async options => {
93
- if (options.mcApiUrl) {
94
- return options.mcApiUrl;
95
- }
96
-
97
- // We first check whether the user has set the MC_API_URL environment variable
98
- if (process.env.MC_API_URL) {
99
- return process.env.MC_API_URL;
100
- }
101
-
102
- // If not, we parse the configuration and check if it's defined over there
103
- const applicationConfig = await processConfig();
104
- const mcApiUrl = applicationConfig.env.mcApiUrl;
105
- return mcApiUrl;
106
- };
107
- const resolveProjectKey = async options => {
108
- if (options.projectKey) {
109
- return options.projectKey;
110
- }
111
-
112
- // We first check whether the user has set the CTP_PROJECT_KEY environment variable
113
- if (process.env.CTP_PROJECT_KEY) {
114
- return process.env.CTP_PROJECT_KEY;
115
- }
116
- try {
117
- var _applicationConfig$en;
118
- const applicationConfig = await processConfig();
119
- 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
- } catch (error) {
121
- // It's ok if there's not application config file or if it does not contain the initialProjectKey
122
- return;
123
- }
124
- };
125
- const mapOAuthScopesToClaims = scopes => {
126
- return _mapInstanceProperty(scopes).call(scopes, scope => {
127
- if (_startsWithInstanceProperty(scope).call(scope, 'view_')) {
128
- return "view:".concat(scope);
129
- }
130
- if (_startsWithInstanceProperty(scope).call(scope, 'manage_')) {
131
- return "manage:".concat(scope);
132
- }
133
- return scope;
134
- });
135
- };
136
- const mapAdditionalOAuthScopesToClaims = (name, scopes) => {
137
- return _mapInstanceProperty(scopes).call(scopes, scope => {
138
- if (_startsWithInstanceProperty(scope).call(scope, 'view_')) {
139
- var _context;
140
- return _concatInstanceProperty(_context = "view/".concat(name, ":")).call(_context, scope);
141
- }
142
- if (_startsWithInstanceProperty(scope).call(scope, 'manage_')) {
143
- var _context2;
144
- return _concatInstanceProperty(_context2 = "manage/".concat(name, ":")).call(_context2, scope);
145
- }
146
- return scope;
147
- });
148
- };
149
- const resolveOAuthScopes = async options => {
150
- if (options.oauthScope) {
151
- return mapOAuthScopesToClaims(options.oauthScope);
152
- }
153
-
154
- // We first check whether the user has set the CTP_OAUTH_SCOPES environment variable
155
- if (process.env.CTP_OAUTH_SCOPES) {
156
- var _process$env$CTP_OAUT, _process$env$CTP_OAUT2, _context3;
157
- 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 : []);
158
- }
159
- try {
160
- var _applicationConfig$en2, _applicationConfig$en3, _configuredOAuthScope, _configuredOAuthScope2, _configuredAdditional, _configuredAdditional2;
161
- const applicationConfig = await processConfig();
162
- 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;
163
- 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;
164
- 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 : [])];
165
- } catch (error) {
166
- // It's ok if there's not application config file or if it does not contain the initialProjectKey
167
- return [];
168
- }
169
- };
170
- const generateRandomHash = function () {
171
- let length = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 16;
172
- return crypto.randomBytes(length).toString('hex');
173
- };
174
- async function run(options) {
175
- const mcApiUrl = await resolveMcApiUrl(options);
176
- if (!mcApiUrl) {
177
- throw new Error('No Merchant Center API URL found. Aborting.');
178
- }
179
- console.log("Using Merchant Center environment \"".concat(chalk.green(mcApiUrl), "\"."));
180
- console.log();
181
- if (!options.force && credentialsStorage.isSessionValid(mcApiUrl)) {
182
- console.log("You already have a valid session.");
183
- return;
184
- }
185
- const projectKey = await resolveProjectKey(options);
186
- const oauthScopes = await resolveOAuthScopes(options);
187
- const scopes = ['openid'];
188
- if (projectKey) {
189
- scopes.push("project_key:".concat(projectKey));
190
- _forEachInstanceProperty(oauthScopes).call(oauthScopes, scope => {
191
- scopes.push(scope);
192
- });
193
- }
194
- const state = generateRandomHash();
195
- const nonce = generateRandomHash();
196
- const authUrl = new _URL('/login/authorize', mcApiUrl);
197
- authUrl.searchParams.set('response_type', 'id_token');
198
- authUrl.searchParams.set('response_mode', 'query');
199
- authUrl.searchParams.set('client_id', "__local:".concat(clientIdentifier));
200
- authUrl.searchParams.set('scope', scopes.join(' '));
201
- authUrl.searchParams.set('state', state);
202
- authUrl.searchParams.set('nonce', nonce);
203
- const server = createAuthCallbackServer({
204
- clientIdentifier,
205
- state,
206
- nonce,
207
- onSuccess: tokenContext => {
208
- credentialsStorage.setToken(mcApiUrl, tokenContext);
209
- console.log();
210
- console.log(chalk.green("Login successful."));
211
- console.log();
212
- }
213
- });
214
- await startServer(server);
215
- console.log("Initiating the OIDC authentication flow, opening the login page in your browser...");
216
- console.log(" ".concat(authUrl));
217
- console.log();
218
- const open = await import('open');
219
- await open.default(authUrl.toString());
220
- console.log('Waiting for the OIDC authentication to complete...');
221
- }
222
-
223
- export { run as default };