@mablhq/mabl-cli 1.58.20 → 1.58.28

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.
@@ -11,7 +11,7 @@ class MablSymbol {
11
11
  static fromString(formatted) {
12
12
  const regEx = '{{@(?<name>.*)}}';
13
13
  const found = formatted.match(regEx);
14
- if (!found || !found.groups) {
14
+ if (!(found === null || found === void 0 ? void 0 : found.groups)) {
15
15
  throw new Error(`Invalid MablSymbol format: ${formatted}`);
16
16
  }
17
17
  const name = found.groups.name;
@@ -3,19 +3,52 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.CookieUtils = void 0;
4
4
  var CookieUtils;
5
5
  (function (CookieUtils) {
6
- const validCharacterRange = /^[\x21-\x7E]*$/;
7
- const invalidCharaters = /[()<>@,;:\\"\\/\[\]?={}]/;
6
+ CookieUtils.validCookieNameCharacterRange = /^[\x21-\x7E]*$/;
7
+ CookieUtils.invalidCookieNameCharaters = /[()<>@,;:\\"\\/\[\]?={}]/;
8
+ CookieUtils.validCookieValueCharacters = /^(!|[\x23-\x2B]|[\x2D-\x3A]|[\x3C-\x5B]|[\x5D-\x7E])*$/;
9
+ function validateCookieName(name) {
10
+ const trimmed = name.trim();
11
+ if ('' === trimmed) {
12
+ return false;
13
+ }
14
+ if (!CookieUtils.validCookieNameCharacterRange.test(trimmed) ||
15
+ CookieUtils.invalidCookieNameCharaters.test(trimmed)) {
16
+ return false;
17
+ }
18
+ return true;
19
+ }
20
+ CookieUtils.validateCookieName = validateCookieName;
8
21
  function normalizeName(name) {
9
22
  const trimmed = name.trim();
10
23
  if ('' === trimmed) {
11
24
  throw new Error('Cookie name cannot be empty or include only whitespace characters');
12
25
  }
13
- if (!validCharacterRange.test(trimmed) || invalidCharaters.test(trimmed)) {
14
- throw new Error(`Invalid characters found in cookie name [${trimmed}]. Valid characters
15
- include any US-ASCII character except control characters and separators.
16
- `);
17
- }
18
26
  return trimmed;
19
27
  }
20
28
  CookieUtils.normalizeName = normalizeName;
29
+ function validateCookieValue(value) {
30
+ const trimmed = value.trim();
31
+ if ('' === trimmed) {
32
+ return false;
33
+ }
34
+ if (!CookieUtils.validCookieValueCharacters.test(trimmed)) {
35
+ return false;
36
+ }
37
+ return true;
38
+ }
39
+ CookieUtils.validateCookieValue = validateCookieValue;
40
+ function normalizeValue(value) {
41
+ if (!value) {
42
+ throw new Error('Cookie value cannot be empty');
43
+ }
44
+ const trimmed = value.trim();
45
+ const bareValue = trimmed.startsWith('"') && trimmed.endsWith('"')
46
+ ? trimmed.substring(1, trimmed.length - 1)
47
+ : trimmed;
48
+ if ('' === bareValue) {
49
+ throw new Error('Cookie value cannot be empty or include only whitespace characters');
50
+ }
51
+ return trimmed;
52
+ }
53
+ CookieUtils.normalizeValue = normalizeValue;
21
54
  })(CookieUtils = exports.CookieUtils || (exports.CookieUtils = {}));
@@ -5,24 +5,55 @@ const MablStep_1 = require("../MablStep");
5
5
  const MablAction_1 = require("../MablAction");
6
6
  const CookieUtils_1 = require("./CookieUtils");
7
7
  const domUtil_1 = require("../../domUtil");
8
- const validValueCharacters = /^(!|[\x23-\x2B]|[\x2D-\x3A]|[\x3C-\x5B]|[\x5D-\x7E])*$/;
9
8
  class SetCookieStep extends MablStep_1.MablStep {
10
9
  constructor(name, args, actions) {
11
10
  super(name, args, actions);
12
- this.cookieName = CookieUtils_1.CookieUtils.normalizeName(this.getActionArgs()[0].name);
13
- this.cookieValue = SetCookieStep.normalizeValue(this.getActionArgs()[0].value);
11
+ const cookieSelector = this.getActionArgs()[0];
12
+ this.cookieName = CookieUtils_1.CookieUtils.normalizeName(cookieSelector.name);
13
+ this.cookieValue = CookieUtils_1.CookieUtils.normalizeValue(cookieSelector.value);
14
+ const cookieOptions = {
15
+ domain: cookieSelector.domain,
16
+ path: cookieSelector.path,
17
+ expires: cookieSelector.expiry,
18
+ httpOnly: cookieSelector.http_only,
19
+ secure: cookieSelector.secure,
20
+ sameSite: cookieSelector.same_site,
21
+ url: cookieSelector.url,
22
+ };
23
+ if (Object.values(cookieOptions).filter((optionValue) => optionValue !== undefined).length > 0) {
24
+ this.cookieOptions = cookieOptions;
25
+ }
14
26
  }
15
27
  getStepName() {
16
28
  return 'SetCookie';
17
29
  }
18
30
  toStepDescriptor() {
19
- return { name: this.cookieName, value: this.cookieValue };
31
+ return {
32
+ name: this.cookieName,
33
+ value: this.cookieValue,
34
+ options: this.cookieOptions,
35
+ };
20
36
  }
21
37
  static fromYaml(_stepName, stepArgs) {
22
38
  return new SetCookieStep('set_cookie', [stepArgs], []);
23
39
  }
24
40
  toMablscript() {
25
- return `set_cookie({ name : "${(0, domUtil_1.escapeMablscriptString)(this.cookieName)}", value : "${(0, domUtil_1.escapeMablscriptString)(this.cookieValue)}" })`;
41
+ var _a, _b, _c, _d, _e, _f, _g;
42
+ const cookieSelector = {
43
+ name: this.cookieName,
44
+ value: this.cookieValue,
45
+ domain: (_a = this.cookieOptions) === null || _a === void 0 ? void 0 : _a.domain,
46
+ path: (_b = this.cookieOptions) === null || _b === void 0 ? void 0 : _b.path,
47
+ expiry: (_c = this.cookieOptions) === null || _c === void 0 ? void 0 : _c.expires,
48
+ http_only: (_d = this.cookieOptions) === null || _d === void 0 ? void 0 : _d.httpOnly,
49
+ secure: (_e = this.cookieOptions) === null || _e === void 0 ? void 0 : _e.secure,
50
+ same_site: (_f = this.cookieOptions) === null || _f === void 0 ? void 0 : _f.sameSite,
51
+ url: (_g = this.cookieOptions) === null || _g === void 0 ? void 0 : _g.url,
52
+ };
53
+ return `set_cookie(${(0, domUtil_1.buildStepArgumentString)({
54
+ params: cookieSelector,
55
+ legacy: false,
56
+ })})`;
26
57
  }
27
58
  getInputVariables() {
28
59
  return (0, MablAction_1.distinctStrings)([
@@ -30,21 +61,6 @@ class SetCookieStep extends MablStep_1.MablStep {
30
61
  ...MablAction_1.MablAction.findUniqueVariableReferencesInValue(this.cookieValue),
31
62
  ]);
32
63
  }
33
- static normalizeValue(value) {
34
- const trimmed = value.trim();
35
- const bareValue = trimmed.startsWith('"') && trimmed.endsWith('"')
36
- ? trimmed.substring(1, trimmed.length - 1)
37
- : trimmed;
38
- if ('' === bareValue) {
39
- throw new Error('Cookie value cannot be empty or include only whitespace characters');
40
- }
41
- if (!validValueCharacters.test(bareValue)) {
42
- throw new Error(`Invalid characters found in cookie value [${bareValue}].
43
- Valid characters include US-ASCII characters excluding control
44
- characters, whitespace, double-quote, comma, semicolon, and backslash.`);
45
- }
46
- return trimmed;
47
- }
48
64
  }
49
65
  exports.SetCookieStep = SetCookieStep;
50
66
  SetCookieStep.mablScriptStepNames = ['set_cookie'];