@sasjs/utils 3.6.4 → 3.6.6

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.
@@ -0,0 +1,27 @@
1
+ #!/bin/bash
2
+
3
+ # Scan staged changes for secrets before anything else runs.
4
+ # The binary is pinned by the @nogoo9/gitleaks devDependency and lands
5
+ # in node_modules/.bin after npm i. Commits are blocked until it is
6
+ # installed so no clone silently skips the secrets scan.
7
+ gitleaks_bin=node_modules/.bin/gitleaks
8
+
9
+ if [ ! -x "$gitleaks_bin" ]; then
10
+ echo "❌ gitleaks not found - run 'npm i' to install it"
11
+ exit 1
12
+ fi
13
+
14
+ if ! "$gitleaks_bin" protect --staged --redact; then
15
+ echo "❌ gitleaks detected a potential secret in your staged changes"
16
+ echo "Remove the secret, or add a .gitleaksignore entry if it is a false positive"
17
+ exit 1
18
+ fi
19
+
20
+ # Avoid commits to the main branch
21
+ BRANCH=`git rev-parse --abbrev-ref HEAD`
22
+
23
+ if [[ "$BRANCH" =~ ^(master|main|develop)$ ]]; then
24
+ echo "You are on branch $BRANCH. Are you sure you want to commit to this branch?"
25
+ echo "If so, commit with -n to bypass the pre-commit hook."
26
+ exit 1
27
+ fi
@@ -0,0 +1,24 @@
1
+ # Hooks for the pre-commit framework - https://pre-commit.com
2
+ #
3
+ # The repo also ships native hooks in .git-hooks/: gitleaks on the staged
4
+ # content before the commit, and the Conventional Commits check on the message.
5
+ # `npm run setup` activates them by setting core.hooksPath - but .npmrc sets
6
+ # ignore-scripts=true, so no install step runs it, and a fresh clone commits
7
+ # unchecked until someone runs it by hand.
8
+ #
9
+ # This file is the standard route instead: install the framework once with
10
+ # `pre-commit install`, and both hooks run on every commit. gitleaks is pinned
11
+ # to an exact release tag, and the message hook calls the script the native
12
+ # hooks already use, so there is one implementation of the rules.
13
+ repos:
14
+ - repo: https://github.com/gitleaks/gitleaks
15
+ rev: v8.30.1
16
+ hooks:
17
+ - id: gitleaks
18
+ - repo: local
19
+ hooks:
20
+ - id: commit-msg
21
+ name: conventional commit
22
+ entry: .git-hooks/commit-msg
23
+ language: script
24
+ stages: [commit-msg]
package/auth/auth.js CHANGED
@@ -1,26 +1,7 @@
1
1
  "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
5
- }) : (function(o, m, k, k2) {
6
- if (k2 === undefined) k2 = k;
7
- o[k2] = m[k];
8
- }));
9
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
10
- Object.defineProperty(o, "default", { enumerable: true, value: v });
11
- }) : function(o, v) {
12
- o["default"] = v;
13
- });
14
- var __importStar = (this && this.__importStar) || function (mod) {
15
- if (mod && mod.__esModule) return mod;
16
- var result = {};
17
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
18
- __setModuleDefault(result, mod);
19
- return result;
20
- };
21
2
  Object.defineProperty(exports, "__esModule", { value: true });
22
3
  exports.decodeToken = exports.hasTokenExpired = exports.isRefreshTokenExpiring = exports.isAccessTokenExpiring = void 0;
23
- const jwt_decode_1 = __importStar(require("jwt-decode"));
4
+ const jwt_decode_1 = require("jwt-decode");
24
5
  /**
25
6
  * Checks if the Access Token is expired or is expiring in 1 hour. A default Access Token
26
7
  * lasts 12 hours. If the Access Token expires, the Refresh Token is used to fetch a new
@@ -68,7 +49,7 @@ exports.hasTokenExpired = hasTokenExpired;
68
49
  function isTokenExpiring(token, timeToLiveSeconds) {
69
50
  let payload;
70
51
  try {
71
- payload = (0, jwt_decode_1.default)(token);
52
+ payload = (0, jwt_decode_1.jwtDecode)(token);
72
53
  }
73
54
  catch (err) {
74
55
  // Only tolerate undecodable (opaque / non-JWT) tokens - anything else
@@ -92,7 +73,7 @@ function isTokenExpiring(token, timeToLiveSeconds) {
92
73
  function decodeToken(token) {
93
74
  let payload;
94
75
  try {
95
- payload = (0, jwt_decode_1.default)(token);
76
+ payload = (0, jwt_decode_1.jwtDecode)(token);
96
77
  }
97
78
  catch (err) {
98
79
  throw new Error('Invalid token supplied.');
package/auth/auth.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"auth.js","sourceRoot":"","sources":["../../src/auth/auth.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAAA,yDAAyD;AAGzD;;;;;;;;GAQG;AACH,SAAgB,qBAAqB,CACnC,KAAc,EACd,iBAAiB,GAAG,IAAI;IAExB,IAAI,CAAC,KAAK,EAAE;QACV,OAAO,IAAI,CAAA;KACZ;IACD,OAAO,eAAe,CAAC,KAAK,EAAE,iBAAiB,CAAC,CAAA;AAClD,CAAC;AARD,sDAQC;AAED;;;;;;;;GAQG;AACH,SAAgB,sBAAsB,CACpC,KAAc,EACd,iBAAiB,GAAG,EAAE;IAEtB,IAAI,CAAC,KAAK,EAAE;QACV,OAAO,IAAI,CAAA;KACZ;IACD,OAAO,eAAe,CAAC,KAAK,EAAE,iBAAiB,CAAC,CAAA;AAClD,CAAC;AARD,wDAQC;AAED;;;;GAIG;AACH,SAAgB,eAAe,CAAC,KAAc;IAC5C,IAAI,CAAC,KAAK,EAAE;QACV,OAAO,IAAI,CAAA;KACZ;IACD,OAAO,eAAe,CAAC,KAAK,EAAE,CAAC,CAAC,CAAA;AAClC,CAAC;AALD,0CAKC;AAED,SAAS,eAAe,CAAC,KAAa,EAAE,iBAAyB;IAC/D,IAAI,OAAyB,CAAA;IAC7B,IAAI;QACF,OAAO,GAAG,IAAA,oBAAS,EAAmB,KAAK,CAAC,CAAA;KAC7C;IAAC,OAAO,GAAG,EAAE;QACZ,sEAAsE;QACtE,uCAAuC;QACvC,IAAI,CAAC,CAAC,GAAG,YAAY,8BAAiB,CAAC;YAAE,MAAM,GAAG,CAAA;QAClD,sDAAsD;QACtD,sEAAsE;QACtE,wEAAwE;QACxE,0DAA0D;QAC1D,OAAO,KA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AKC;AAED,SAAS,eAAe,CAAC,KAAa,EAAE,iBAAyB;IAC/D,IAAI,OAAyB,CAAA;IAC7B,IAAI;QACF,OAAO,GAAG,IAAA,sBAAS,EAAmB,KAAK,CAAC,CAAA;KAC7C;IAAC,OAAO,GAAG,EAAE;QACZ,sEAAsE;QACtE,uCAAuC;QACvC,IAAI,CAAC,CAAC,GAAG,YAAY,8BAAiB,CAAC;YAAE,MAAM,GAAG,CAAA;QAClD,sDAAsD;QACtD,sEAAsE;QACtE,wEAAwE;QACxE,0DAA0D;QAC1D,OAAO,KAAK,CAAA;KACb;IAED,gEAAgE;IAChE,uEAAuE;IACvE,qBAAqB;IACrB,IAAI,OAAO,CAAC,GAAG,IAAI,IAAI;QAAE,OAAO,KAAK,CAAA;IAErC,MAAM,UAAU,GAAG,OAAO,CAAC,GAAG,GAAG,IAAI,IAAI,EAAE,CAAC,OAAO,EAAE,GAAG,IAAI,CAAA;IAE5D,OAAO,UAAU,IAAI,iBAAiB,CAAA;AACxC,CAAC;AAED,SAAgB,WAAW,CAAC,KAAa;IACvC,IAAI,OAAqB,CAAA;IACzB,IAAI;QACF,OAAO,GAAG,IAAA,sBAAS,EAAC,KAAK,CAAC,CAAA;KAC3B;IAAC,OAAO,GAAG,EAAE;QACZ,MAAM,IAAI,KAAK,CAAC,yBAAyB,CAAC,CAAA;KAC3C;IAED,OAAO,OAAO,CAAA;AAChB,CAAC;AATD,kCASC"}
package/package.json CHANGED
@@ -39,7 +39,8 @@
39
39
  "test": "jest --config=jest.config.js --coverage",
40
40
  "lint:fix": "npx prettier --write \"{src,test}/**/*.{ts,tsx,js,jsx,html,css,sass,less,json,yml,md,graphql}\"",
41
41
  "lint": "npx prettier --check \"{src,test}/**/*.{ts,tsx,js,jsx,html,css,sass,less,json,yml,md,graphql}\"",
42
- "semantic-release": "semantic-release"
42
+ "semantic-release": "semantic-release",
43
+ "setup": "git config core.hooksPath ./.git-hooks"
43
44
  },
44
45
  "repository": {
45
46
  "type": "git",
@@ -62,20 +63,20 @@
62
63
  "jest-extended": "3.2.4",
63
64
  "semantic-release": "25.0.9",
64
65
  "ts-jest": "29.4.14",
65
- "ts-loader": "9.6.2",
66
66
  "ts-node": "10.9.2",
67
- "typescript": "4.5.4"
67
+ "typescript": "4.5.4",
68
+ "@nogoo9/gitleaks": "8.30.1-post.2"
68
69
  },
69
70
  "dependencies": {
70
- "@fast-csv/format": "4.3.5",
71
+ "@fast-csv/format": "5.0.7",
71
72
  "@types/fs-extra": "11.0.4",
72
73
  "@types/prompts": "2.4.9",
73
74
  "chalk": "4.1.1",
74
75
  "cli-table": "0.3.11",
75
76
  "consola": "3.4.2",
76
77
  "fs-extra": "11.4.1",
77
- "jwt-decode": "3.1.2",
78
+ "jwt-decode": "4.0.0",
78
79
  "prompts": "2.4.2"
79
80
  },
80
- "version": "3.6.4"
81
+ "version": "3.6.6"
81
82
  }
package/utils/url.d.ts CHANGED
@@ -1,3 +1,14 @@
1
1
  export declare const urlOrigin: (str: string) => string;
2
+ /**
3
+ * The literal prefix is checked as well as the parsed protocol, because the URL
4
+ * parser normalises a backslash to a forward slash for special schemes:
5
+ * `new URL('http:\\server')` yields `http://server`. `valid-url`, which these
6
+ * replaced, required the literal prefix and so rejected such input.
7
+ *
8
+ * The prefix comparison is case-insensitive: the parser lowercases the scheme,
9
+ * so `HTTP://example.com` is a usable URL, and `valid-url` compared the scheme
10
+ * case-insensitively too. A backslash still fails, since it is not a slash in
11
+ * either case.
12
+ */
2
13
  export declare const isHttpUri: (str: string) => boolean;
3
14
  export declare const isHttpsUri: (str: string) => boolean;
package/utils/url.js CHANGED
@@ -23,8 +23,29 @@ const hasHttpProtocol = (str, protocol) => {
23
23
  return false;
24
24
  }
25
25
  };
26
- const isHttpUri = (str) => hasHttpProtocol(str, 'http:');
26
+ // The parser strips ASCII tab, newline and carriage return before parsing, so
27
+ // `new URL('http://exa\tmple.com')` yields `http://example.com`. Those are
28
+ // illegal in a URL, and `valid-url` rejected them.
29
+ const hasControlChars = (str) => /[\u0000-\u001F\u007F]/.test(str);
30
+ /**
31
+ * The literal prefix is checked as well as the parsed protocol, because the URL
32
+ * parser normalises a backslash to a forward slash for special schemes:
33
+ * `new URL('http:\\server')` yields `http://server`. `valid-url`, which these
34
+ * replaced, required the literal prefix and so rejected such input.
35
+ *
36
+ * The prefix comparison is case-insensitive: the parser lowercases the scheme,
37
+ * so `HTTP://example.com` is a usable URL, and `valid-url` compared the scheme
38
+ * case-insensitively too. A backslash still fails, since it is not a slash in
39
+ * either case.
40
+ */
41
+ const isHttpUri = (str) => typeof str === 'string' &&
42
+ !hasControlChars(str) &&
43
+ str.toLowerCase().startsWith('http://') &&
44
+ hasHttpProtocol(str, 'http:');
27
45
  exports.isHttpUri = isHttpUri;
28
- const isHttpsUri = (str) => hasHttpProtocol(str, 'https:');
46
+ const isHttpsUri = (str) => typeof str === 'string' &&
47
+ !hasControlChars(str) &&
48
+ str.toLowerCase().startsWith('https://') &&
49
+ hasHttpProtocol(str, 'https:');
29
50
  exports.isHttpsUri = isHttpsUri;
30
51
  //# sourceMappingURL=url.js.map
package/utils/url.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"url.js","sourceRoot":"","sources":["../../src/utils/url.ts"],"names":[],"mappings":";;;AAAO,MAAM,SAAS,GAAG,CAAC,GAAW,EAAE,EAAE;IACvC,IAAI,GAAG,KAAK,EAAE;QAAE,OAAO,GAAG,CAAA;IAE1B,IAAI,MAAM,CAAA;IAEV,IAAI;QACF,MAAM,GAAG,IAAI,GAAG,CAAC,GAAG,CAAC,CAAC,MAAM,CAAA;KAC7B;IAAC,OAAO,CAAC,EAAE;QACV,MAAM,IAAI,KAAK,CAAC,cAAc,CAAC,CAAA;KAChC;IAED,OAAO,MAAM,CAAA;AACf,CAAC,CAAA;AAZY,QAAA,SAAS,aAYrB;AAED,MAAM,eAAe,GAAG,CAAC,GAAW,EAAE,QAAgB,EAAE,EAAE;IACxD,IAAI;QACF,MAAM,GAAG,GAAG,IAAI,GA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