fcad-core-dragon 2.0.0-beta.1 → 2.0.0-beta.3

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.
Files changed (118) hide show
  1. package/.editorconfig +33 -33
  2. package/.eslintignore +29 -29
  3. package/{.eslintrc.js → .eslintrc.cjs} +81 -86
  4. package/CHANGELOG +364 -364
  5. package/README.md +71 -71
  6. package/bk.scss +117 -0
  7. package/package.json +61 -63
  8. package/src/$locales/en.json +143 -179
  9. package/src/$locales/fr.json +105 -181
  10. package/src/assets/data/onboardingMessages.json +47 -47
  11. package/src/components/AppBase.vue +1054 -614
  12. package/src/components/AppBaseButton.vue +87 -63
  13. package/src/components/AppBaseErrorDisplay.vue +438 -420
  14. package/src/components/AppBaseFlipCard.vue +84 -83
  15. package/src/components/AppBaseModule.vue +1673 -1842
  16. package/src/components/AppBasePage.vue +779 -312
  17. package/src/components/AppBasePopover.vue +41 -0
  18. package/src/components/AppCompAudio.vue +234 -0
  19. package/src/components/AppCompBranchButtons.vue +552 -582
  20. package/src/components/AppCompButtonProgress.vue +126 -147
  21. package/src/components/AppCompCarousel.vue +298 -192
  22. package/src/components/AppCompInputCheckBoxNext.vue +195 -0
  23. package/src/components/AppCompInputDropdownNext.vue +159 -0
  24. package/src/components/AppCompInputRadioNext.vue +152 -0
  25. package/src/components/{AppCompInputTextBox.vue → AppCompInputTextNext.vue} +106 -91
  26. package/src/components/AppCompInputTextTableNext.vue +141 -0
  27. package/src/components/AppCompInputTextToFillDropdownNext.vue +230 -0
  28. package/src/components/{AppCompInputTextToFillText.vue → AppCompInputTextToFillNext.vue} +171 -164
  29. package/src/components/AppCompJauge.vue +74 -55
  30. package/src/components/AppCompMenu.vue +413 -209
  31. package/src/components/AppCompMenuItem.vue +228 -174
  32. package/src/components/AppCompNavigation.vue +960 -949
  33. package/src/components/AppCompNoteCall.vue +133 -126
  34. package/src/components/AppCompNoteCredit.vue +292 -164
  35. package/src/components/AppCompPlayBar.vue +1218 -1319
  36. package/src/components/AppCompPlayBarNext.vue +2052 -0
  37. package/src/components/AppCompPlayBarProgress.vue +82 -0
  38. package/src/components/AppCompPopUpNext.vue +503 -0
  39. package/src/components/{AppCompQuiz.vue → AppCompQuizNext.vue} +2904 -2989
  40. package/src/components/AppCompQuizRecall.vue +276 -250
  41. package/src/components/AppCompSVGNext.vue +347 -0
  42. package/src/components/AppCompSettingsMenu.vue +172 -171
  43. package/src/components/AppCompTableOfContent.vue +387 -264
  44. package/src/components/AppCompTranscript.vue +24 -19
  45. package/src/components/AppCompVideoPlayer.vue +368 -336
  46. package/src/components/AppCompViewDisplay.vue +6 -6
  47. package/src/components/BaseModule.vue +72 -67
  48. package/src/composables/useQuiz.js +206 -0
  49. package/src/externalComps/ModuleView.vue +22 -0
  50. package/src/externalComps/SummaryView.vue +91 -0
  51. package/src/main.js +272 -227
  52. package/src/mixins/$mediaMixins.js +819 -0
  53. package/src/mixins/timerMixin.js +155 -156
  54. package/src/module/stores/appStore.js +893 -0
  55. package/src/module/xapi/ADL.js +376 -339
  56. package/src/module/xapi/Crypto/Hasher.js +241 -241
  57. package/src/module/xapi/Crypto/WordArray.js +278 -278
  58. package/src/module/xapi/Crypto/algorithms/BufferedBlockAlgorithm.js +103 -103
  59. package/src/module/xapi/Crypto/algorithms/C_algo.js +315 -319
  60. package/src/module/xapi/Crypto/algorithms/HMAC.js +9 -9
  61. package/src/module/xapi/Crypto/algorithms/SHA1.js +9 -9
  62. package/src/module/xapi/Crypto/encoders/Base.js +105 -105
  63. package/src/module/xapi/Crypto/encoders/Base64.js +99 -99
  64. package/src/module/xapi/Crypto/encoders/Hex.js +61 -61
  65. package/src/module/xapi/Crypto/encoders/Latin1.js +61 -61
  66. package/src/module/xapi/Crypto/encoders/Utf8.js +45 -45
  67. package/src/module/xapi/Crypto/index.js +53 -53
  68. package/src/module/xapi/Statement/activity.js +47 -47
  69. package/src/module/xapi/Statement/agent.js +55 -55
  70. package/src/module/xapi/Statement/group.js +26 -26
  71. package/src/module/xapi/Statement/index.js +259 -259
  72. package/src/module/xapi/Statement/statement.js +253 -253
  73. package/src/module/xapi/Statement/statementRef.js +23 -23
  74. package/src/module/xapi/Statement/substatement.js +22 -22
  75. package/src/module/xapi/Statement/verb.js +36 -36
  76. package/src/module/xapi/activitytypes.js +17 -17
  77. package/src/module/xapi/launch.js +157 -157
  78. package/src/module/xapi/utils.js +167 -167
  79. package/src/module/xapi/verbs.js +294 -294
  80. package/src/module/xapi/wrapper.js +1963 -1890
  81. package/src/module/xapi/xapiStatement.js +444 -444
  82. package/src/plugins/bus.js +8 -3
  83. package/src/plugins/gsap.js +14 -17
  84. package/src/plugins/helper.js +308 -295
  85. package/src/plugins/i18n.js +44 -31
  86. package/src/plugins/idb.js +219 -212
  87. package/src/plugins/save.js +37 -37
  88. package/src/plugins/scorm.js +287 -287
  89. package/src/plugins/xapi.js +11 -11
  90. package/src/public/index.html +33 -21
  91. package/src/router/index.js +43 -41
  92. package/src/router/routes.js +312 -337
  93. package/src/shared/generalfuncs.js +210 -188
  94. package/src/shared/validators.js +1069 -249
  95. package/vite.config.js +27 -0
  96. package/.prettierrc.js +0 -5
  97. package/babel.config.js +0 -3
  98. package/src/components/AppBaseDragChoice.vue +0 -91
  99. package/src/components/AppBaseDropZone.vue +0 -112
  100. package/src/components/AppCompBif.vue +0 -120
  101. package/src/components/AppCompDragAndDrop.vue +0 -339
  102. package/src/components/AppCompInputAssociation.vue +0 -332
  103. package/src/components/AppCompInputCheckBox.vue +0 -227
  104. package/src/components/AppCompInputDropdown.vue +0 -184
  105. package/src/components/AppCompInputRadio.vue +0 -169
  106. package/src/components/AppCompInputTextTable.vue +0 -155
  107. package/src/components/AppCompInputTextToFillDropdown.vue +0 -255
  108. package/src/components/AppCompMediaPlayer.vue +0 -397
  109. package/src/components/AppCompPopUp.vue +0 -522
  110. package/src/components/AppCompPopover.vue +0 -27
  111. package/src/components/AppCompSVG.vue +0 -309
  112. package/src/mixins/$pageMixins.js +0 -459
  113. package/src/mixins/$quizMixins.js +0 -456
  114. package/src/module/store.js +0 -895
  115. package/src/plugins/timeManager.js +0 -77
  116. package/src/routes_bckp.js +0 -313
  117. package/src/routes_static.js +0 -344
  118. package/vue.config.js +0 -83
@@ -1,319 +1,315 @@
1
- import { WordArray } from '../WordArray'
2
- import { Hasher } from '../Hasher'
3
- import { Base } from '../encoders/Base'
4
- import { Utf8 } from '../encoders/Utf8'
5
- /**
6
- * Algorithm namespace.
7
- */
8
- export const C_algo = function() {
9
- // Reusable Variables
10
- let W = [],
11
- K = [],
12
- H = []
13
-
14
- return {
15
- /**
16
- * SHA-1 hash algorithm.
17
- */
18
- SHA1: Hasher.extend({
19
- _doReset: function() {
20
- this._hash = new WordArray.init([
21
- 0x67452301,
22
- 0xefcdab89,
23
- 0x98badcfe,
24
- 0x10325476,
25
- 0xc3d2e1f0
26
- ])
27
- },
28
-
29
- _doProcessBlock: function(M, offset) {
30
- // Shortcut
31
- let H = this._hash.words
32
-
33
- // Working let iables
34
- let a = H[0]
35
- let b = H[1]
36
- let c = H[2]
37
- let d = H[3]
38
- let e = H[4]
39
-
40
- // Computation
41
- for (let i = 0; i < 80; i++) {
42
- if (i < 16) {
43
- W[i] = M[offset + i] | 0
44
- } else {
45
- let n = W[i - 3] ^ W[i - 8] ^ W[i - 14] ^ W[i - 16]
46
- W[i] = (n << 1) | (n >>> 31)
47
- }
48
-
49
- let t = ((a << 5) | (a >>> 27)) + e + W[i]
50
- if (i < 20) {
51
- t += ((b & c) | (~b & d)) + 0x5a827999
52
- } else if (i < 40) {
53
- t += (b ^ c ^ d) + 0x6ed9eba1
54
- } else if (i < 60) {
55
- t += ((b & c) | (b & d) | (c & d)) - 0x70e44324
56
- } /* if (i < 80) */ else {
57
- t += (b ^ c ^ d) - 0x359d3e2a
58
- }
59
-
60
- e = d
61
- d = c
62
- c = (b << 30) | (b >>> 2)
63
- b = a
64
- a = t
65
- }
66
-
67
- // Intermediate hash value
68
- H[0] = (H[0] + a) | 0
69
- H[1] = (H[1] + b) | 0
70
- H[2] = (H[2] + c) | 0
71
- H[3] = (H[3] + d) | 0
72
- H[4] = (H[4] + e) | 0
73
- },
74
-
75
- _doFinalize: function() {
76
- // Shortcuts
77
- let data = this._data
78
- let dataWords = data.words
79
-
80
- let nBitsTotal = this._nDataBytes * 8
81
- let nBitsLeft = data.sigBytes * 8
82
-
83
- // Add padding
84
- dataWords[nBitsLeft >>> 5] |= 0x80 << (24 - (nBitsLeft % 32))
85
- dataWords[(((nBitsLeft + 64) >>> 9) << 4) + 14] = Math.floor(
86
- nBitsTotal / 0x100000000
87
- )
88
- dataWords[(((nBitsLeft + 64) >>> 9) << 4) + 15] = nBitsTotal
89
- data.sigBytes = dataWords.length * 4
90
-
91
- // Hash final blocks
92
- this._process()
93
-
94
- // Return final computed hash
95
- return this._hash
96
- },
97
-
98
- clone: function() {
99
- let clone = Hasher.clone.call(this)
100
- clone._hash = this._hash.clone()
101
-
102
- return clone
103
- }
104
- }),
105
- /**
106
- * HMAC algorithm.
107
- */
108
- HMAC: Base.extend({
109
- /**
110
- * Initializes a newly created HMAC.
111
- *
112
- * @param {Hasher} hasher The hash algorithm to use.
113
- * @param {WordArray|string} key The secret key.
114
- * @example
115
- * let hmacHasher = CryptoJS.algo.HMAC.create(CryptoJS.algo.SHA256, key);
116
- */
117
- init: function(hasher, key) {
118
- // Init hasher
119
- hasher = this._hasher = new hasher.init()
120
-
121
- // Convert string to WordArray, else assume WordArray already
122
- if (typeof key == 'string') {
123
- key = Utf8.parse(key)
124
- }
125
-
126
- // Shortcuts
127
- let hasherBlockSize = hasher.blockSize
128
- let hasherBlockSizeBytes = hasherBlockSize * 4
129
-
130
- // Allow arbitrary length keys
131
- if (key.sigBytes > hasherBlockSizeBytes) {
132
- key = hasher.finalize(key)
133
- }
134
-
135
- // Clamp excess bits
136
- key.clamp()
137
-
138
- // Clone key for inner and outer pads
139
- let oKey = (this._oKey = key.clone())
140
- let iKey = (this._iKey = key.clone())
141
-
142
- // Shortcuts
143
- let oKeyWords = oKey.words
144
- let iKeyWords = iKey.words
145
-
146
- // XOR keys with pad constants
147
- for (let i = 0; i < hasherBlockSize; i++) {
148
- oKeyWords[i] ^= 0x5c5c5c5c
149
- iKeyWords[i] ^= 0x36363636
150
- }
151
- oKey.sigBytes = iKey.sigBytes = hasherBlockSizeBytes
152
-
153
- // Set initial values
154
- this.reset()
155
- },
156
-
157
- /**
158
- * Resets this HMAC to its initial state.
159
- * @example
160
- * hmacHasher.reset();
161
- */
162
- reset: function() {
163
- // Shortcut
164
- let hasher = this._hasher
165
-
166
- // Reset
167
- hasher.reset()
168
- hasher.update(this._iKey)
169
- },
170
-
171
- /**
172
- * Updates this HMAC with a message.
173
- * @param {WordArray|string} messageUpdate The message to append.
174
- * @return {HMAC} This HMAC instance.
175
- * @example
176
- * hmacHasher.update('message');
177
- * hmacHasher.update(wordArray);
178
- */
179
- update: function(messageUpdate) {
180
- this._hasher.update(messageUpdate)
181
-
182
- // Chainable
183
- return this
184
- },
185
-
186
- /**
187
- * Finalizes the HMAC computation.
188
- * Note that the finalize operation is effectively a destructive, read-once operation.
189
- *
190
- * @param {WordArray|string} messageUpdate (Optional) A final message update.
191
- * @return {WordArray} The HMAC.
192
- * @example
193
- * let hmac = hmacHasher.finalize();
194
- * let hmac = hmacHasher.finalize('message');
195
- * let hmac = hmacHasher.finalize(wordArray);
196
- */
197
- finalize: function(messageUpdate) {
198
- // Shortcut
199
- let hasher = this._hasher
200
-
201
- // Compute HMAC
202
- let innerHash = hasher.finalize(messageUpdate)
203
- hasher.reset()
204
- let hmac = hasher.finalize(this._oKey.clone().concat(innerHash))
205
-
206
- return hmac
207
- }
208
- }),
209
-
210
- /**
211
- * SHA-256 hash algorithm.
212
- */
213
- SHA256: Hasher.extend({
214
- _doReset: function() {
215
- this._hash = new WordArray.init(H.slice(0))
216
- },
217
-
218
- _doProcessBlock: function(M, offset) {
219
- // Shortcut
220
- let H = this._hash.words
221
-
222
- // Working variables
223
- let a = H[0]
224
- let b = H[1]
225
- let c = H[2]
226
- let d = H[3]
227
- let e = H[4]
228
- let f = H[5]
229
- let g = H[6]
230
- let h = H[7]
231
-
232
- // Computation
233
- for (let i = 0; i < 64; i++) {
234
- if (i < 16) {
235
- W[i] = M[offset + i] | 0
236
- } else {
237
- let gamma0x = W[i - 15]
238
- let gamma0 =
239
- ((gamma0x << 25) | (gamma0x >>> 7)) ^
240
- ((gamma0x << 14) | (gamma0x >>> 18)) ^
241
- (gamma0x >>> 3)
242
-
243
- let gamma1x = W[i - 2]
244
- let gamma1 =
245
- ((gamma1x << 15) | (gamma1x >>> 17)) ^
246
- ((gamma1x << 13) | (gamma1x >>> 19)) ^
247
- (gamma1x >>> 10)
248
-
249
- W[i] = gamma0 + W[i - 7] + gamma1 + W[i - 16]
250
- }
251
-
252
- let ch = (e & f) ^ (~e & g)
253
- let maj = (a & b) ^ (a & c) ^ (b & c)
254
-
255
- let sigma0 =
256
- ((a << 30) | (a >>> 2)) ^
257
- ((a << 19) | (a >>> 13)) ^
258
- ((a << 10) | (a >>> 22))
259
- let sigma1 =
260
- ((e << 26) | (e >>> 6)) ^
261
- ((e << 21) | (e >>> 11)) ^
262
- ((e << 7) | (e >>> 25))
263
-
264
- let t1 = h + sigma1 + ch + K[i] + W[i]
265
- let t2 = sigma0 + maj
266
-
267
- h = g
268
- g = f
269
- f = e
270
- e = (d + t1) | 0
271
- d = c
272
- c = b
273
- b = a
274
- a = (t1 + t2) | 0
275
- }
276
-
277
- // Intermediate hash value
278
- H[0] = (H[0] + a) | 0
279
- H[1] = (H[1] + b) | 0
280
- H[2] = (H[2] + c) | 0
281
- H[3] = (H[3] + d) | 0
282
- H[4] = (H[4] + e) | 0
283
- H[5] = (H[5] + f) | 0
284
- H[6] = (H[6] + g) | 0
285
- H[7] = (H[7] + h) | 0
286
- },
287
-
288
- _doFinalize: function() {
289
- // Shortcuts
290
- let data = this._data
291
- let dataWords = data.words
292
-
293
- let nBitsTotal = this._nDataBytes * 8
294
- let nBitsLeft = data.sigBytes * 8
295
-
296
- // Add padding
297
- dataWords[nBitsLeft >>> 5] |= 0x80 << (24 - (nBitsLeft % 32))
298
- dataWords[(((nBitsLeft + 64) >>> 9) << 4) + 14] = Math.floor(
299
- nBitsTotal / 0x100000000
300
- )
301
- dataWords[(((nBitsLeft + 64) >>> 9) << 4) + 15] = nBitsTotal
302
- data.sigBytes = dataWords.length * 4
303
-
304
- // Hash final blocks
305
- this._process()
306
-
307
- // Return final computed hash
308
- return this._hash
309
- },
310
-
311
- clone: function() {
312
- let clone = Hasher.clone.call(this)
313
- clone._hash = this._hash.clone()
314
-
315
- return clone
316
- }
317
- })
318
- }
319
- }
1
+ import { WordArray } from '../WordArray'
2
+ import { Hasher } from '../Hasher'
3
+ import { Base } from '../encoders/Base'
4
+ import { Utf8 } from '../encoders/Utf8'
5
+ /**
6
+ * Algorithm namespace.
7
+ */
8
+ export const C_algo = function () {
9
+ // Reusable Variables
10
+ let W = [],
11
+ K = [],
12
+ H = []
13
+
14
+ return {
15
+ /**
16
+ * SHA-1 hash algorithm.
17
+ */
18
+ SHA1: Hasher.extend({
19
+ _doReset: function () {
20
+ this._hash = new WordArray.init([
21
+ 0x67452301, 0xefcdab89, 0x98badcfe, 0x10325476, 0xc3d2e1f0
22
+ ])
23
+ },
24
+
25
+ _doProcessBlock: function (M, offset) {
26
+ // Shortcut
27
+ let H = this._hash.words
28
+
29
+ // Working let iables
30
+ let a = H[0]
31
+ let b = H[1]
32
+ let c = H[2]
33
+ let d = H[3]
34
+ let e = H[4]
35
+
36
+ // Computation
37
+ for (let i = 0; i < 80; i++) {
38
+ if (i < 16) {
39
+ W[i] = M[offset + i] | 0
40
+ } else {
41
+ let n = W[i - 3] ^ W[i - 8] ^ W[i - 14] ^ W[i - 16]
42
+ W[i] = (n << 1) | (n >>> 31)
43
+ }
44
+
45
+ let t = ((a << 5) | (a >>> 27)) + e + W[i]
46
+ if (i < 20) {
47
+ t += ((b & c) | (~b & d)) + 0x5a827999
48
+ } else if (i < 40) {
49
+ t += (b ^ c ^ d) + 0x6ed9eba1
50
+ } else if (i < 60) {
51
+ t += ((b & c) | (b & d) | (c & d)) - 0x70e44324
52
+ } /* if (i < 80) */ else {
53
+ t += (b ^ c ^ d) - 0x359d3e2a
54
+ }
55
+
56
+ e = d
57
+ d = c
58
+ c = (b << 30) | (b >>> 2)
59
+ b = a
60
+ a = t
61
+ }
62
+
63
+ // Intermediate hash value
64
+ H[0] = (H[0] + a) | 0
65
+ H[1] = (H[1] + b) | 0
66
+ H[2] = (H[2] + c) | 0
67
+ H[3] = (H[3] + d) | 0
68
+ H[4] = (H[4] + e) | 0
69
+ },
70
+
71
+ _doFinalize: function () {
72
+ // Shortcuts
73
+ let data = this._data
74
+ let dataWords = data.words
75
+
76
+ let nBitsTotal = this._nDataBytes * 8
77
+ let nBitsLeft = data.sigBytes * 8
78
+
79
+ // Add padding
80
+ dataWords[nBitsLeft >>> 5] |= 0x80 << (24 - (nBitsLeft % 32))
81
+ dataWords[(((nBitsLeft + 64) >>> 9) << 4) + 14] = Math.floor(
82
+ nBitsTotal / 0x100000000
83
+ )
84
+ dataWords[(((nBitsLeft + 64) >>> 9) << 4) + 15] = nBitsTotal
85
+ data.sigBytes = dataWords.length * 4
86
+
87
+ // Hash final blocks
88
+ this._process()
89
+
90
+ // Return final computed hash
91
+ return this._hash
92
+ },
93
+
94
+ clone: function () {
95
+ let clone = Hasher.clone.call(this)
96
+ clone._hash = this._hash.clone()
97
+
98
+ return clone
99
+ }
100
+ }),
101
+ /**
102
+ * HMAC algorithm.
103
+ */
104
+ HMAC: Base.extend({
105
+ /**
106
+ * Initializes a newly created HMAC.
107
+ *
108
+ * @param {Hasher} hasher The hash algorithm to use.
109
+ * @param {WordArray|string} key The secret key.
110
+ * @example
111
+ * let hmacHasher = CryptoJS.algo.HMAC.create(CryptoJS.algo.SHA256, key);
112
+ */
113
+ init: function (hasher, key) {
114
+ // Init hasher
115
+ hasher = this._hasher = new hasher.init()
116
+
117
+ // Convert string to WordArray, else assume WordArray already
118
+ if (typeof key == 'string') {
119
+ key = Utf8.parse(key)
120
+ }
121
+
122
+ // Shortcuts
123
+ let hasherBlockSize = hasher.blockSize
124
+ let hasherBlockSizeBytes = hasherBlockSize * 4
125
+
126
+ // Allow arbitrary length keys
127
+ if (key.sigBytes > hasherBlockSizeBytes) {
128
+ key = hasher.finalize(key)
129
+ }
130
+
131
+ // Clamp excess bits
132
+ key.clamp()
133
+
134
+ // Clone key for inner and outer pads
135
+ let oKey = (this._oKey = key.clone())
136
+ let iKey = (this._iKey = key.clone())
137
+
138
+ // Shortcuts
139
+ let oKeyWords = oKey.words
140
+ let iKeyWords = iKey.words
141
+
142
+ // XOR keys with pad constants
143
+ for (let i = 0; i < hasherBlockSize; i++) {
144
+ oKeyWords[i] ^= 0x5c5c5c5c
145
+ iKeyWords[i] ^= 0x36363636
146
+ }
147
+ oKey.sigBytes = iKey.sigBytes = hasherBlockSizeBytes
148
+
149
+ // Set initial values
150
+ this.reset()
151
+ },
152
+
153
+ /**
154
+ * Resets this HMAC to its initial state.
155
+ * @example
156
+ * hmacHasher.reset();
157
+ */
158
+ reset: function () {
159
+ // Shortcut
160
+ let hasher = this._hasher
161
+
162
+ // Reset
163
+ hasher.reset()
164
+ hasher.update(this._iKey)
165
+ },
166
+
167
+ /**
168
+ * Updates this HMAC with a message.
169
+ * @param {WordArray|string} messageUpdate The message to append.
170
+ * @return {HMAC} This HMAC instance.
171
+ * @example
172
+ * hmacHasher.update('message');
173
+ * hmacHasher.update(wordArray);
174
+ */
175
+ update: function (messageUpdate) {
176
+ this._hasher.update(messageUpdate)
177
+
178
+ // Chainable
179
+ return this
180
+ },
181
+
182
+ /**
183
+ * Finalizes the HMAC computation.
184
+ * Note that the finalize operation is effectively a destructive, read-once operation.
185
+ *
186
+ * @param {WordArray|string} messageUpdate (Optional) A final message update.
187
+ * @return {WordArray} The HMAC.
188
+ * @example
189
+ * let hmac = hmacHasher.finalize();
190
+ * let hmac = hmacHasher.finalize('message');
191
+ * let hmac = hmacHasher.finalize(wordArray);
192
+ */
193
+ finalize: function (messageUpdate) {
194
+ // Shortcut
195
+ let hasher = this._hasher
196
+
197
+ // Compute HMAC
198
+ let innerHash = hasher.finalize(messageUpdate)
199
+ hasher.reset()
200
+ let hmac = hasher.finalize(this._oKey.clone().concat(innerHash))
201
+
202
+ return hmac
203
+ }
204
+ }),
205
+
206
+ /**
207
+ * SHA-256 hash algorithm.
208
+ */
209
+ SHA256: Hasher.extend({
210
+ _doReset: function () {
211
+ this._hash = new WordArray.init(H.slice(0))
212
+ },
213
+
214
+ _doProcessBlock: function (M, offset) {
215
+ // Shortcut
216
+ let H = this._hash.words
217
+
218
+ // Working variables
219
+ let a = H[0]
220
+ let b = H[1]
221
+ let c = H[2]
222
+ let d = H[3]
223
+ let e = H[4]
224
+ let f = H[5]
225
+ let g = H[6]
226
+ let h = H[7]
227
+
228
+ // Computation
229
+ for (let i = 0; i < 64; i++) {
230
+ if (i < 16) {
231
+ W[i] = M[offset + i] | 0
232
+ } else {
233
+ let gamma0x = W[i - 15]
234
+ let gamma0 =
235
+ ((gamma0x << 25) | (gamma0x >>> 7)) ^
236
+ ((gamma0x << 14) | (gamma0x >>> 18)) ^
237
+ (gamma0x >>> 3)
238
+
239
+ let gamma1x = W[i - 2]
240
+ let gamma1 =
241
+ ((gamma1x << 15) | (gamma1x >>> 17)) ^
242
+ ((gamma1x << 13) | (gamma1x >>> 19)) ^
243
+ (gamma1x >>> 10)
244
+
245
+ W[i] = gamma0 + W[i - 7] + gamma1 + W[i - 16]
246
+ }
247
+
248
+ let ch = (e & f) ^ (~e & g)
249
+ let maj = (a & b) ^ (a & c) ^ (b & c)
250
+
251
+ let sigma0 =
252
+ ((a << 30) | (a >>> 2)) ^
253
+ ((a << 19) | (a >>> 13)) ^
254
+ ((a << 10) | (a >>> 22))
255
+ let sigma1 =
256
+ ((e << 26) | (e >>> 6)) ^
257
+ ((e << 21) | (e >>> 11)) ^
258
+ ((e << 7) | (e >>> 25))
259
+
260
+ let t1 = h + sigma1 + ch + K[i] + W[i]
261
+ let t2 = sigma0 + maj
262
+
263
+ h = g
264
+ g = f
265
+ f = e
266
+ e = (d + t1) | 0
267
+ d = c
268
+ c = b
269
+ b = a
270
+ a = (t1 + t2) | 0
271
+ }
272
+
273
+ // Intermediate hash value
274
+ H[0] = (H[0] + a) | 0
275
+ H[1] = (H[1] + b) | 0
276
+ H[2] = (H[2] + c) | 0
277
+ H[3] = (H[3] + d) | 0
278
+ H[4] = (H[4] + e) | 0
279
+ H[5] = (H[5] + f) | 0
280
+ H[6] = (H[6] + g) | 0
281
+ H[7] = (H[7] + h) | 0
282
+ },
283
+
284
+ _doFinalize: function () {
285
+ // Shortcuts
286
+ let data = this._data
287
+ let dataWords = data.words
288
+
289
+ let nBitsTotal = this._nDataBytes * 8
290
+ let nBitsLeft = data.sigBytes * 8
291
+
292
+ // Add padding
293
+ dataWords[nBitsLeft >>> 5] |= 0x80 << (24 - (nBitsLeft % 32))
294
+ dataWords[(((nBitsLeft + 64) >>> 9) << 4) + 14] = Math.floor(
295
+ nBitsTotal / 0x100000000
296
+ )
297
+ dataWords[(((nBitsLeft + 64) >>> 9) << 4) + 15] = nBitsTotal
298
+ data.sigBytes = dataWords.length * 4
299
+
300
+ // Hash final blocks
301
+ this._process()
302
+
303
+ // Return final computed hash
304
+ return this._hash
305
+ },
306
+
307
+ clone: function () {
308
+ let clone = Hasher.clone.call(this)
309
+ clone._hash = this._hash.clone()
310
+
311
+ return clone
312
+ }
313
+ })
314
+ }
315
+ }
@@ -1,9 +1,9 @@
1
- //import { WordArray } from './WordArray'
2
- import { C_algo } from './C_algo'
3
- /**
4
- * SHA-1 hash algorithm.
5
- */
6
- export const SHA1 = function() {
7
- let sha1 = C_algo().SHA1
8
- return sha1
9
- }
1
+ //import { WordArray } from './WordArray'
2
+ import { C_algo } from './C_algo'
3
+ /**
4
+ * SHA-1 hash algorithm.
5
+ */
6
+ export const SHA1 = function () {
7
+ let sha1 = C_algo().SHA1
8
+ return sha1
9
+ }