mirror of
https://github.com/javascript-obfuscator/javascript-obfuscator
synced 2026-08-09 12:42:29 +00:00
Merge pull request #473 from javascript-obfuscator/enums-export-in-typings
Fixed typings
This commit is contained in:
@@ -3,6 +3,7 @@ Change Log
|
||||
v0.20.3
|
||||
---
|
||||
* Fixed `for-await-of` statement: https://github.com/javascript-obfuscator/javascript-obfuscator/issues/419
|
||||
* Fixed typings. Now string values correctly assignable to enum-like options
|
||||
|
||||
v0.20.2
|
||||
---
|
||||
|
||||
Vendored
+4
-4
File diff suppressed because one or more lines are too long
Vendored
+1
-1
File diff suppressed because one or more lines are too long
Vendored
+1
-1
File diff suppressed because one or more lines are too long
@@ -21,6 +21,7 @@
|
||||
},
|
||||
"types": "index.d.ts",
|
||||
"dependencies": {
|
||||
"@gradecam/tsenum": "^1.2.0",
|
||||
"@nuxtjs/opencollective": "0.2.2",
|
||||
"chalk": "3.0.0",
|
||||
"chance": "1.1.4",
|
||||
|
||||
@@ -1,5 +1,11 @@
|
||||
export enum ObfuscationTarget {
|
||||
Browser = 'browser',
|
||||
BrowserNoEval = 'browser-no-eval',
|
||||
Node = 'node'
|
||||
}
|
||||
import { MakeEnum } from '@gradecam/tsenum';
|
||||
|
||||
export const ObfuscationTarget: Readonly<{
|
||||
BrowserNoEval: string;
|
||||
Node: string;
|
||||
Browser: string;
|
||||
}> = MakeEnum({
|
||||
Browser: 'browser',
|
||||
BrowserNoEval: 'browser-no-eval',
|
||||
Node: 'node'
|
||||
});
|
||||
|
||||
@@ -1,4 +1,9 @@
|
||||
export enum StringArrayEncoding {
|
||||
Base64 = 'base64',
|
||||
Rc4 = 'rc4'
|
||||
}
|
||||
import { MakeEnum } from '@gradecam/tsenum';
|
||||
|
||||
export const StringArrayEncoding: Readonly<{
|
||||
Rc4: string;
|
||||
Base64: string;
|
||||
}> = MakeEnum({
|
||||
Base64: 'base64',
|
||||
Rc4: 'rc4'
|
||||
});
|
||||
|
||||
@@ -1,5 +1,11 @@
|
||||
export enum IdentifierNamesGenerator {
|
||||
DictionaryIdentifierNamesGenerator = 'dictionary',
|
||||
HexadecimalIdentifierNamesGenerator = 'hexadecimal',
|
||||
MangledIdentifierNamesGenerator = 'mangled'
|
||||
}
|
||||
import { MakeEnum } from '@gradecam/tsenum';
|
||||
|
||||
export const IdentifierNamesGenerator: Readonly<{
|
||||
MangledIdentifierNamesGenerator: string;
|
||||
DictionaryIdentifierNamesGenerator: string;
|
||||
HexadecimalIdentifierNamesGenerator: string;
|
||||
}> = MakeEnum({
|
||||
DictionaryIdentifierNamesGenerator: 'dictionary',
|
||||
HexadecimalIdentifierNamesGenerator: 'hexadecimal',
|
||||
MangledIdentifierNamesGenerator: 'mangled'
|
||||
});
|
||||
|
||||
@@ -1,4 +1,9 @@
|
||||
export enum SourceMapMode {
|
||||
Inline = 'inline',
|
||||
Separate = 'separate'
|
||||
}
|
||||
import { MakeEnum } from '@gradecam/tsenum';
|
||||
|
||||
export const SourceMapMode: Readonly<{
|
||||
Separate: string;
|
||||
Inline: string;
|
||||
}> = MakeEnum({
|
||||
Inline: 'inline',
|
||||
Separate: 'separate'
|
||||
});
|
||||
|
||||
Vendored
+5
-3
@@ -1,3 +1,5 @@
|
||||
import { TypeFromEnum } from '@gradecam/tsenum';
|
||||
|
||||
import { TStringArrayEncoding } from '../../types/options/TStringArrayEncoding';
|
||||
|
||||
import { IdentifierNamesGenerator } from '../../enums/generators/identifier-names-generators/IdentifierNamesGenerator';
|
||||
@@ -14,7 +16,7 @@ export interface IOptions {
|
||||
readonly debugProtectionInterval: boolean;
|
||||
readonly disableConsoleOutput: boolean;
|
||||
readonly domainLock: string[];
|
||||
readonly identifierNamesGenerator: IdentifierNamesGenerator;
|
||||
readonly identifierNamesGenerator: TypeFromEnum<typeof IdentifierNamesGenerator>;
|
||||
readonly identifiersDictionary: string[];
|
||||
readonly identifiersPrefix: string;
|
||||
readonly inputFileName: string;
|
||||
@@ -28,13 +30,13 @@ export interface IOptions {
|
||||
readonly sourceMap: boolean;
|
||||
readonly sourceMapBaseUrl: string;
|
||||
readonly sourceMapFileName: string;
|
||||
readonly sourceMapMode: SourceMapMode;
|
||||
readonly sourceMapMode: TypeFromEnum<typeof SourceMapMode>;
|
||||
readonly splitStrings: boolean;
|
||||
readonly splitStringsChunkLength: number;
|
||||
readonly stringArray: boolean;
|
||||
readonly stringArrayEncoding: TStringArrayEncoding;
|
||||
readonly stringArrayThreshold: number;
|
||||
readonly target: ObfuscationTarget;
|
||||
readonly target: TypeFromEnum<typeof ObfuscationTarget>;
|
||||
readonly transformObjectKeys: boolean;
|
||||
readonly unicodeEscapeSequence: boolean;
|
||||
}
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
import { TypeFromEnum } from '@gradecam/tsenum';
|
||||
|
||||
import { inject, injectable } from 'inversify';
|
||||
import { ServiceIdentifiers } from '../container/ServiceIdentifiers';
|
||||
|
||||
@@ -112,7 +114,7 @@ export class Options implements IOptions {
|
||||
IdentifierNamesGenerator.HexadecimalIdentifierNamesGenerator,
|
||||
IdentifierNamesGenerator.MangledIdentifierNamesGenerator
|
||||
])
|
||||
public readonly identifierNamesGenerator!: IdentifierNamesGenerator;
|
||||
public readonly identifierNamesGenerator!: TypeFromEnum<typeof IdentifierNamesGenerator>;
|
||||
|
||||
/**
|
||||
* @type {string}
|
||||
@@ -214,7 +216,7 @@ export class Options implements IOptions {
|
||||
* @type {SourceMapMode}
|
||||
*/
|
||||
@IsIn([SourceMapMode.Inline, SourceMapMode.Separate])
|
||||
public readonly sourceMapMode!: SourceMapMode;
|
||||
public readonly sourceMapMode!: TypeFromEnum<typeof SourceMapMode>;
|
||||
|
||||
/**
|
||||
* @type {boolean}
|
||||
@@ -254,7 +256,7 @@ export class Options implements IOptions {
|
||||
* @type {ObfuscationTarget}
|
||||
*/
|
||||
@IsIn([ObfuscationTarget.Browser, ObfuscationTarget.BrowserNoEval, ObfuscationTarget.Node])
|
||||
public readonly target!: ObfuscationTarget;
|
||||
public readonly target!: TypeFromEnum<typeof ObfuscationTarget>;
|
||||
|
||||
/**
|
||||
* @type {boolean}
|
||||
|
||||
+3
-1
@@ -1,3 +1,5 @@
|
||||
import { TypeFromEnum } from '@gradecam/tsenum';
|
||||
|
||||
import { StringArrayEncoding } from '../../enums/StringArrayEncoding';
|
||||
|
||||
export type TStringArrayEncoding = boolean | StringArrayEncoding;
|
||||
export type TStringArrayEncoding = boolean | TypeFromEnum<typeof StringArrayEncoding>;
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { assert } from 'chai';
|
||||
import { TypeFromEnum } from '@gradecam/tsenum';
|
||||
|
||||
import { IObfuscatedCode } from '../../../src/interfaces/source-code/IObfuscatedCode';
|
||||
|
||||
@@ -673,12 +674,12 @@ describe('JavaScriptObfuscator', () => {
|
||||
const samplesCount: number = 30;
|
||||
|
||||
let areCollisionsExists: boolean = false;
|
||||
let obfuscateFunc: (identifierNamesGenerator: IdentifierNamesGenerator) => string;
|
||||
let obfuscateFunc: (identifierNamesGenerator: TypeFromEnum<typeof IdentifierNamesGenerator>) => string;
|
||||
|
||||
before(() => {
|
||||
const code: string = readFileAsString(__dirname + '/fixtures/custom-nodes-identifier-names-collision.js');
|
||||
|
||||
obfuscateFunc = (identifierNamesGenerator: IdentifierNamesGenerator) => JavaScriptObfuscator.obfuscate(
|
||||
obfuscateFunc = (identifierNamesGenerator: TypeFromEnum<typeof IdentifierNamesGenerator>) => JavaScriptObfuscator.obfuscate(
|
||||
code,
|
||||
{
|
||||
identifierNamesGenerator,
|
||||
@@ -693,7 +694,7 @@ describe('JavaScriptObfuscator', () => {
|
||||
[
|
||||
IdentifierNamesGenerator.DictionaryIdentifierNamesGenerator,
|
||||
IdentifierNamesGenerator.MangledIdentifierNamesGenerator
|
||||
].forEach((identifierNamesGenerator: IdentifierNamesGenerator) => {
|
||||
].forEach((identifierNamesGenerator: TypeFromEnum<typeof IdentifierNamesGenerator>) => {
|
||||
for (let i = 0; i < samplesCount; i++) {
|
||||
try {
|
||||
eval(obfuscateFunc(identifierNamesGenerator));
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import 'reflect-metadata';
|
||||
import { TypeFromEnum } from '@gradecam/tsenum';
|
||||
|
||||
import { ServiceIdentifiers } from '../../../src/container/ServiceIdentifiers';
|
||||
|
||||
@@ -23,7 +24,7 @@ function getObfuscatedCode (
|
||||
sourceMap: string,
|
||||
sourceMapBaseUrl: string,
|
||||
sourceMapFileName: string,
|
||||
sourceMapMode: SourceMapMode
|
||||
sourceMapMode: TypeFromEnum<typeof SourceMapMode>
|
||||
): IObfuscatedCode {
|
||||
const inversifyContainerFacade: IInversifyContainerFacade = new InversifyContainerFacade();
|
||||
|
||||
|
||||
@@ -118,6 +118,11 @@
|
||||
lodash "^4.17.13"
|
||||
to-fast-properties "^2.0.0"
|
||||
|
||||
"@gradecam/tsenum@^1.2.0":
|
||||
version "1.2.0"
|
||||
resolved "https://registry.yarnpkg.com/@gradecam/tsenum/-/tsenum-1.2.0.tgz#0c7c7c86e00e2d9ab8f242c695bec66b26b79319"
|
||||
integrity sha512-61kSGjcgHBncY1WJ1Fc6VwMgHyMWMQ9A8oconZ3iYizWDKKV64JVYDFTRH/vGmaKlTQb0PXAhRzY7qnIBvYikw==
|
||||
|
||||
"@istanbuljs/load-nyc-config@^1.0.0":
|
||||
version "1.0.0"
|
||||
resolved "https://registry.yarnpkg.com/@istanbuljs/load-nyc-config/-/load-nyc-config-1.0.0.tgz#10602de5570baea82f8afbfa2630b24e7a8cfe5b"
|
||||
|
||||
Reference in New Issue
Block a user