8000 Updated readme for BigInt literals support · sec-js/javascript-obfuscator@ca6a2cd · GitHub
[go: up one dir, main page]

Skip to content

Commit ca6a2cd

Browse files
author
sanex3339
committed
Updated readme for BigInt literals support
1 parent 31f3ab9 commit ca6a2cd

File tree

9 files changed

+50
-30
lines changed

9 files changed

+50
-30
lines changed

README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -998,6 +998,12 @@ No. JSX support isn't planned.
998998

999999
See: [`Kind of variables`](#kind-of-variables)
10001000

1001+
### Why I got `null` value instead of `BigInt` number?
1002+
1003+
`BigInt` obfuscation works correctly only in environments that support `BigInt` values. See [ESTree spec](https://github.com/estree/estree/blob/master/es2020.md#bigintliteral)
1004+
1005+
See: [`Kind of variables`](#kind-of-variables)
1006+
10011007
## Backers
10021008

10031009
Support us with a monthly donation and help us continue our activities. [[Become a backer](https://opencollective.com/javascript-obfuscator#backer)]

dist/index.browser.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/index.cli.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/index.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@
5555
"@types/mkdirp": "1.0.0",
5656
"@types/mocha": "7.0.2",
5757
"@types/multimatch": "4.0.0",
58-
"@types/node": "13.13.2",
58+
"@types/node": "13.13.4",
5959
"@types/rimraf": "3.0.0",
6060
"@types/sinon": "9.0.0",
6161
"@types/string-template": "1.0.2",
@@ -69,10 +69,10 @@
6969
"eslint-plugin-jsdoc": "24.0.0",
7070
"eslint-plugin-no-null": "1.0.2",
7171
"eslint-plugin-prefer-arrow": "1.2.0",
72-
"eslint-plugin-unicorn": "18.0.1",
72+
"eslint-plugin-unicorn": "19.0.1",
7373
"fork-ts-checker-notifier-webpack-plugin": "2.0.0",
7474
"fork-ts-checker-webpack-plugin": "4.1.3",
75-
"mocha": "7.1.1",
75+
"mocha": "7.1.2",
7676
"nyc": "15.0.1",
7777
"pjson": "1.0.9",
7878
"pre-commit": "1.2.2",

src/declarations/ESTree.d.ts

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,17 +30,15 @@ declare module 'estree' {
3030

3131
interface SimpleLiteral extends BaseNode {
3232
metadata?: LiteralNodeMetadata;
33+
'x-verbatim-property'?: escodegen.XVerbatimProperty;
3334
}
3435

35-
interface RegExpLiteral extends BaseNode {
36-
metadata?: LiteralNodeMetadata;
37-
}
38-
39-
interface SimpleLiteral extends BaseNode {
40-
'x-verbatim-property'?: escodegen.XVerbatimProperty;
36+
interface BigIntLiteral extends SimpleLiteral {
37+
bigint: string;
4138
}
4239

4340
interface RegExpLiteral extends BaseNode {
41+
metadata?: LiteralNodeMetadata;
4442
'x-verbatim-property'?: escodegen.XVerbatimProperty;
4543
}
4644
}

src/node/NodeGuards.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,14 @@ export class NodeGuards {
5656
return node.type === NodeType.AwaitExpression;
5757
}
5858

59+
/**
60+
* @param {Node} node
61+
* @returns {boolean}
62+
*/
63+
public static isBigIntLiteralNode (node: ESTree.Node): node is ESTree.BigIntLiteral {
64+
return NodeGuards.isLiteralNode(node) && !!(<ESTree.BigIntLiteral>node).bigint;
65+
}
66+
5967
/**
6068
* @param {Node} node
6169
* @returns {boolean}

test/dev/dev.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import { NO_ADDITIONAL_NODES_PRESET } from '../../src/options/presets/NoCustomNo
77

88
let obfuscatedCode: string = JavaScriptObfuscator.obfuscate(
99
`
10-
var foo = 'abc';
10+
var foo = 10n;
1111
`,
1212
{
1313
...NO_ADDITIONAL_NODES_PRESET,

yarn.lock

Lines changed: 25 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -364,10 +364,10 @@
364364
resolved "https://registry.yarnpkg.com/@types/node/-/node-13.9.3.tgz#6356df2647de9eac569f9a52eda3480fa9e70b4d"
365365
integrity sha512-01s+ac4qerwd6RHD+mVbOEsraDHSgUaefQlEdBbUolnQFjKwCr7luvAlEwW1RFojh67u0z4OUTjPn9LEl4zIkA==
366366

367-
"@types/node@13.13.2":
368-
version "13.13.2"
369-
resolved "https://registry.yarnpkg.com/@types/node/-/node-13.13.2.tgz#160d82623610db590a64e8ca81784e11117e5a54"
370-
integrity sha512-LB2R1Oyhpg8gu4SON/mfforE525+Hi/M1ineICEDftqNVTyFg1aRIeGuTvXAoWHc4nbrFncWtJgMmoyRvuGh7A==
367+
"@types/node@13.13.4":
368+
version "13.13.4"
369+
resolved "https://registry.yarnpkg.com/@types/node/-/node-13.13.4.tgz#1581d6c16e3d4803eb079c87d4ac893ee7501c2c"
370+
integrity sha512-x26ur3dSXgv5AwKS0lNfbjpCakGIduWU1DU91Zz58ONRWrIKGunmZBNv4P7N+e27sJkiGDsw/3fT4AtsqQBrBA==
371371

372372
"@types/normalize-package-data@^2.4.0":
373373
version "2.4.0"
@@ -1890,15 +1890,16 @@ eslint-plugin-prefer-arrow@1.2.0:
18901890
resolved "https://registry.yarnpkg.com/eslint-plugin-prefer-arrow/-/eslint-plugin-prefer-arrow-1.2.0.tgz#55f07b07e308f441c09e53a77ad12448ce1b7c29"
18911891
integrity sha512-/iaWpfc6CsGNG/OSElmN1/hZP9WG/EnxoCIFcJHT1utRqk8FRQYoyX7xWHo2O03p/9I2dw2lSNsVOYbpfNSsZQ==
18921892

1893-
eslint-plugin-unicorn@18.0.1:
1894-
version "18.0.1"
1895-
resolved "https://registry.yarnpkg.com/eslint-plugin-unicorn/-/eslint-plugin-unicorn-18.0.1.tgz#8d3285ffa57b2f6b07550b94e62228d93bf61813"
1896-
integrity sha512-Y4bgygek4x4ogeMcSHr6MZi3frBPZ80eIpMOsxew7jAblb53OYflpRh0an62Z6jv/fw7D3TkXauqLOBWbT9adg==
1893+
eslint-plugin-unicorn@19.0.1:
1894+
version "19.0.1"
1895+
resolved "https://registry.yarnpkg.com/eslint-plugin-unicorn/-/eslint-plugin-unicorn-19.0.1.tgz#05eef02f33426b8aa4f21cd5e4785b456335b85b"
1896+
integrity sha512-fu0/h5mHXfBC6EkA3i2vCjsfC8j53+T9txGhNL4fpxJ+1JKsUKfv+tmXDgy0XnLHhFjnOZp4tRWJWbcykeIP2Q==
18971897
dependencies:
18981898
ci-info "^2.0.0"
18991899
clean-regexp "^1.0.0"
19001900
eslint-ast-utils "^1.1.0"
19011901
eslint-template-visitor "^1.1.0"
1902+
eslint-utils "^2.0.0"
19021903
import-modules "^2.0.0"
19031904
lodash "^4.17.15"
19041905
read-pkg-up "^7.0.1"
@@ -3520,10 +3521,10 @@ mixin-deep@^1.2.0:
35203521
for-in "^1.0.2"
35213522
is-extendable "^1.0.1"
35223523

3523-
mkdirp@0.5.3, mkdirp@^0.5.1:
3524-
version "0.5.3"
3525-
resolved "https://registry.yarnpkg.com/mkdirp/-/mkdirp-0.5.3.tgz#5a514b7179259287952881e94410ec5465659f8c"
3526-
integrity sha512-P+2gwrFqx8lhew375MQHHeTlY8AuOJSrGf0R5ddkEndUkmwpgUob/vQuBD1V22/Cw1/lJr4x+EjllSezBThzBg==
3524+
mkdirp@0.5.5:
3525+
version "0.5.5"
3526+
resolved "https://registry.yarnpkg.com/mkdirp/-/mkdirp-0.5.5.tgz#d91cefd62d1436ca0f41620e251288d420099def"
3527+
integrity sha512-NKmAlESf6jMGym1++R0Ra7wvhV+wFW63FaSOFPwRahvea0gMUcGUhVeAg/0BC0wiv9ih5NYPB1Wn1UEI1/L+xQ==
35273528
dependencies:
35283529
minimist "^1.2.5"
35293530

@@ -3532,17 +3533,24 @@ mkdirp@1.0.4:
35323533
resolved "https://registry.yarnpkg.com/mkdirp/-/mkdirp-1.0.4.tgz#3eb5ed62622756d79a5f0e2a221dfebad75c2f7e"
35333534
integrity sha512-vVqVZQyf3WLx2Shd0qJ9xuvqgAyKPLAiqITEtqW0oIUjzo3PePDd6fW9iFz30ef7Ysp/oiWqbhszeGWW2T6Gzw==
35343535

3536+
mkdirp@^0.5.1:
3537+
version "0.5.3"
3538+
resolved "https://registry.yarnpkg.com/mkdirp/-/mkdirp-0.5.3.tgz#5a514b7179259287952881e94410ec5465659f8c"
3539+
integrity sha512-P+2gwrFqx8lhew375MQHHeTlY8AuOJSrGf0R5ddkEndUkmwpgUob/vQuBD1V22/Cw1/lJr4x+EjllSezBThzBg==
3540+
dependencies:
3541+
minimist "^1.2.5"
3542+
35353543
mkdirp@^0.5.3:
35363544
version "0.5.4"
35373545
resolved "https://registry.yarnpkg.com/mkdirp/-/mkdirp-0.5.4.tgz#fd01504a6797ec5c9be81ff43d204961ed64a512"
35383546
integrity sha512-iG9AK/dJLtJ0XNgTuDbSyNS3zECqDlAhnQW4CsNxBG3LQJBbHmRX1egw39DmtOdCAqY+dKXV+sgPgilNWUKMVw==
35393547
dependencies:
35403548
minimist "^1.2.5"
35413549

3542-
mocha@7.1.1:
3543-
version "7.1.1"
3544-
resolved "https://registry.yarnpkg.com/mocha/-/mocha-7.1.1.tgz#89fbb30d09429845b1bb893a830bf5771049a441"
3545-
integrity sha512-3qQsu3ijNS3GkWcccT5Zw0hf/rWvu1fTN9sPvEd81hlwsr30GX2GcDSSoBxo24IR8FelmrAydGC6/1J5QQP4WA==
3550+
mocha@7.1.2:
3551+
version "7.1.2"
3552+
resolved "https://registry.yarnpkg.com/mocha/-/mocha-7.1.2.tgz#8e40d198acf91a52ace122cd7599c9ab857b29e6"
3553+
integrity sha512-o96kdRKMKI3E8U0bjnfqW4QMk12MwZ4mhdBTf+B5a1q9+aq2HRnj+3ZdJu0B/ZhJeK78MgYuv6L8d/rA5AeBJA==
35463554
dependencies:
35473555
ansi-colors "3.2.3"
35483556
browser-stdout "1.3.1"
@@ -3557,7 +3565,7 @@ mocha@7.1.1:
35573565
js-yaml "3.13.1"
35583566
log-symbols "3.0.0"
35593567
minimatch "3.0.4"
3560-
mkdirp "0.5.3"
3568+
mkdirp "0.5.5"
35613569
ms "2.1.1"
35623570
node-environment-flags "1.0.6"
35633571
object.assign "4.1.0"

0 commit comments

Comments
 (0)
0