Skip to content

Commit ae26fba

Browse files
committed
fix(js-sha256): wrap logic in a function to prevent optimizer destroy lib
1 parent f30098d commit ae26fba

File tree

4 files changed

+19
-13
lines changed

4 files changed

+19
-13
lines changed

projects/lib/src/token-validation/hash-handler.ts

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
import { Injectable } from '@angular/core';
22

3-
import { sha256 } from './js-sha256';
3+
import { factory } from './js-sha256';
4+
5+
const sha256 = factory();
46

57
/**
68
* Abstraction for crypto algorithms

projects/lib/src/token-validation/js-sha256.js

+8-2
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@
88
*/
99
/*jslint bitwise: true */
1010

11+
12+
function factory() {
13+
1114

1215
var ERROR = 'input is invalid type';
1316
var WINDOW = typeof window === 'object';
@@ -502,5 +505,8 @@
502505
exports.sha224 = createMethod(true);
503506
exports.sha256.hmac = createHmacMethod();
504507
exports.sha224.hmac = createHmacMethod(true);
505-
506-
export { exports as sha256 };
508+
509+
return exports;
510+
}
511+
512+
export { factory };

projects/sample/.browserslistrc

+6-8
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
1-
# This file is currently used by autoprefixer to adjust CSS to support the below specified browsers
2-
# For additional information regarding the format and rule options, please see:
3-
# https://github.com/browserslist/browserslist#queries
4-
# For IE 9-11 support, please uncomment the last line of the file and adjust as needed
5-
> 0.5%
6-
last 2 versions
1+
last 1 Chrome version
2+
last 1 Firefox version
3+
last 2 Edge major versions
4+
last 2 Safari major versions
5+
last 2 iOS major versions
76
Firefox ESR
8-
not dead
9-
# IE 9-11
7+
not IE 11 # Angular supports IE 11 only as an opt-in. To opt-in, remove the 'not' prefix on this line.

tsconfig.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
"experimentalDecorators": true,
1111
"downlevelIteration": true,
1212
"module": "esnext",
13-
"target": "es5",
13+
"target": "es2017",
1414
"typeRoots": ["node_modules/@types"],
1515
"lib": ["es2017", "dom"],
1616
"paths": {
@@ -23,6 +23,6 @@
2323
}
2424
},
2525
"angularCompilerOptions": {
26-
"enableIvy": false
26+
"enableIvy": true
2727
}
2828
}

0 commit comments

Comments
 (0)