fcad-core-dragon 2.1.1 → 2.1.2

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 (160) hide show
  1. package/.editorconfig +7 -7
  2. package/.gitlab-ci.yml +124 -0
  3. package/.prettierrc +11 -11
  4. package/.vscode/extensions.json +8 -8
  5. package/.vscode/settings.json +46 -16
  6. package/CHANGELOG +520 -520
  7. package/README.md +57 -57
  8. package/documentation/.vitepress/config.js +114 -114
  9. package/documentation/api-examples.md +49 -49
  10. package/documentation/composants/app-base-button.md +58 -58
  11. package/documentation/composants/app-base-error-display.md +59 -59
  12. package/documentation/composants/app-base-popover.md +68 -68
  13. package/documentation/composants/app-comp-audio.md +75 -75
  14. package/documentation/composants/app-comp-branch-buttons.md +111 -111
  15. package/documentation/composants/app-comp-button-progress.md +53 -53
  16. package/documentation/composants/app-comp-carousel.md +53 -53
  17. package/documentation/composants/app-comp-container.md +53 -53
  18. package/documentation/composants/app-comp-input-checkbox-next.md +42 -42
  19. package/documentation/composants/app-comp-input-dropdown-next.md +34 -34
  20. package/documentation/composants/app-comp-input-radio-next.md +39 -39
  21. package/documentation/composants/app-comp-input-text-next.md +35 -35
  22. package/documentation/composants/app-comp-input-text-table-next.md +34 -34
  23. package/documentation/composants/app-comp-input-text-to-fill-dropdown-next.md +53 -53
  24. package/documentation/composants/app-comp-input-text-to-fill-next.md +31 -31
  25. package/documentation/composants/app-comp-jauge.md +31 -31
  26. package/documentation/composants/app-comp-menu-item.md +55 -55
  27. package/documentation/composants/app-comp-menu.md +29 -29
  28. package/documentation/composants/app-comp-navigation.md +41 -41
  29. package/documentation/composants/app-comp-note-call.md +53 -53
  30. package/documentation/composants/app-comp-note-credit.md +53 -53
  31. package/documentation/composants/app-comp-play-bar-next.md +53 -53
  32. package/documentation/composants/app-comp-pop-up-next.md +93 -93
  33. package/documentation/composants/app-comp-quiz-next.md +235 -235
  34. package/documentation/composants/app-comp-quiz-recall.md +53 -53
  35. package/documentation/composants/app-comp-svg-next.md +53 -53
  36. package/documentation/composants/app-comp-table-of-content.md +50 -50
  37. package/documentation/composants/app-comp-video-player.md +82 -82
  38. package/documentation/composants.md +46 -46
  39. package/documentation/composants_critiques/ModelPageComposant.md +53 -53
  40. package/documentation/composants_critiques/app-base-module.md +43 -43
  41. package/documentation/composants_critiques/app-base-page.md +48 -48
  42. package/documentation/composants_critiques/app-base.md +311 -311
  43. package/documentation/composants_critiques/main.md +15 -15
  44. package/documentation/demarrage.md +50 -50
  45. package/documentation/deploiement.md +57 -57
  46. package/documentation/index.md +33 -33
  47. package/documentation/markdown-examples.md +85 -85
  48. package/documentation/public/vite.svg +14 -14
  49. package/documentation/public/vuejs.svg +1 -1
  50. package/documentation/public/vuetify.svg +5 -5
  51. package/eslint.config.js +60 -60
  52. package/junit-report.xml +182 -0
  53. package/package.json +66 -59
  54. package/playwright/index.html +12 -0
  55. package/playwright/index.js +21 -0
  56. package/playwright-ct.config.js +95 -0
  57. package/src/$locales/en.json +157 -157
  58. package/src/$locales/fr.json +120 -120
  59. package/src/assets/data/onboardingMessages.json +47 -47
  60. package/src/components/AppBase.vue +1171 -1169
  61. package/src/components/AppBaseButton.vue +90 -95
  62. package/src/components/AppBaseErrorDisplay.vue +438 -438
  63. package/src/components/AppBaseFlipCard.vue +84 -84
  64. package/src/components/AppBaseModule.vue +1639 -1634
  65. package/src/components/AppBasePage.vue +867 -866
  66. package/src/components/AppBasePopover.vue +41 -41
  67. package/src/components/AppBaseSkeleton.vue +66 -66
  68. package/src/components/AppCompAudio.vue +261 -256
  69. package/src/components/AppCompBranchButtons.vue +508 -508
  70. package/src/components/AppCompButtonProgress.vue +137 -132
  71. package/src/components/AppCompCarousel.vue +342 -336
  72. package/src/components/AppCompContainer.vue +29 -29
  73. package/src/components/AppCompInputCheckBoxNx.vue +325 -323
  74. package/src/components/AppCompInputDropdownNx.vue +302 -299
  75. package/src/components/AppCompInputRadioNx.vue +287 -284
  76. package/src/components/AppCompInputTextNx.vue +156 -153
  77. package/src/components/AppCompInputTextTableNx.vue +205 -202
  78. package/src/components/AppCompInputTextToFillDropdownNx.vue +343 -340
  79. package/src/components/AppCompInputTextToFillNx.vue +316 -313
  80. package/src/components/AppCompJauge.vue +81 -81
  81. package/src/components/AppCompMenu.vue +6 -1
  82. package/src/components/AppCompMenuItem.vue +246 -240
  83. package/src/components/AppCompNavigation.vue +977 -972
  84. package/src/components/AppCompNoteCall.vue +167 -161
  85. package/src/components/AppCompNoteCredit.vue +496 -491
  86. package/src/components/AppCompPlayBarNext.vue +2290 -2288
  87. package/src/components/AppCompPopUpNext.vue +508 -504
  88. package/src/components/AppCompQuizNext.vue +515 -510
  89. package/src/components/AppCompQuizRecall.vue +355 -350
  90. package/src/components/AppCompSVGNext.vue +346 -346
  91. package/src/components/AppCompSettingsMenu.vue +177 -172
  92. package/src/components/AppCompTableOfContent.vue +433 -427
  93. package/src/components/AppCompVideoPlayer.vue +377 -377
  94. package/src/components/AppCompViewDisplay.vue +6 -6
  95. package/src/components/BaseModule.vue +55 -55
  96. package/src/composables/useIdleDetector.js +56 -56
  97. package/src/composables/useQuiz.js +89 -89
  98. package/src/composables/useTimer.js +172 -172
  99. package/src/directives/nvdaFix.js +53 -53
  100. package/src/externalComps/ModuleView.vue +22 -22
  101. package/src/externalComps/SummaryView.vue +91 -91
  102. package/src/main.js +493 -476
  103. package/src/module/stores/appStore.js +960 -947
  104. package/src/module/xapi/ADL.js +520 -520
  105. package/src/module/xapi/Crypto/Hasher.js +241 -241
  106. package/src/module/xapi/Crypto/WordArray.js +278 -278
  107. package/src/module/xapi/Crypto/algorithms/BufferedBlockAlgorithm.js +103 -103
  108. package/src/module/xapi/Crypto/algorithms/C_algo.js +315 -315
  109. package/src/module/xapi/Crypto/algorithms/HMAC.js +9 -9
  110. package/src/module/xapi/Crypto/algorithms/SHA1.js +9 -9
  111. package/src/module/xapi/Crypto/encoders/Base.js +105 -105
  112. package/src/module/xapi/Crypto/encoders/Base64.js +99 -99
  113. package/src/module/xapi/Crypto/encoders/Hex.js +61 -61
  114. package/src/module/xapi/Crypto/encoders/Latin1.js +61 -61
  115. package/src/module/xapi/Crypto/encoders/Utf8.js +45 -45
  116. package/src/module/xapi/Crypto/index.js +53 -53
  117. package/src/module/xapi/Statement/activity.js +47 -47
  118. package/src/module/xapi/Statement/agent.js +55 -55
  119. package/src/module/xapi/Statement/group.js +26 -26
  120. package/src/module/xapi/Statement/index.js +259 -259
  121. package/src/module/xapi/Statement/statement.js +253 -253
  122. package/src/module/xapi/Statement/statementRef.js +23 -23
  123. package/src/module/xapi/Statement/substatement.js +22 -22
  124. package/src/module/xapi/Statement/verb.js +36 -36
  125. package/src/module/xapi/activitytypes.js +17 -17
  126. package/src/module/xapi/launch.js +157 -157
  127. package/src/module/xapi/utils.js +167 -167
  128. package/src/module/xapi/verbs.js +294 -294
  129. package/src/module/xapi/wrapper.js +1895 -1895
  130. package/src/module/xapi/xapiStatement.js +444 -444
  131. package/src/plugins/analytics.js +34 -34
  132. package/src/plugins/bus.js +12 -8
  133. package/src/plugins/gsap.js +17 -17
  134. package/src/plugins/helper.js +355 -358
  135. package/src/plugins/i18n.js +27 -26
  136. package/src/plugins/idb.js +227 -227
  137. package/src/plugins/save.js +37 -37
  138. package/src/plugins/scorm.js +287 -287
  139. package/src/plugins/xapi.js +11 -11
  140. package/src/public/index.html +33 -33
  141. package/src/router/index.js +57 -57
  142. package/src/router/routes.js +312 -312
  143. package/src/shared/generalfuncs.js +344 -344
  144. package/src/shared/validators.js +1018 -1018
  145. package/tests/component/AppBaseButton.spec.js +53 -0
  146. package/tests/component/pinia.spec.js +24 -0
  147. package/{src/components/tests__ → tests/unit}/AppBaseButton.spec.js +53 -53
  148. package/tests/unit/AppCompInputCheckBoxNx.spec.js +59 -0
  149. package/tests/unit/AppCompInputDropdownNx.spec.js +51 -0
  150. package/tests/unit/AppCompInputRadioNx.spec.js +59 -0
  151. package/tests/unit/AppCompInputTextNx.spec.js +44 -0
  152. package/tests/unit/AppCompInputTextTableNx.spec.js +77 -0
  153. package/tests/unit/AppCompInputTextToFillDropdownNx.spec.js +60 -0
  154. package/tests/unit/AppCompInputTextToFillNx.spec.js +45 -0
  155. package/tests/unit/AppCompQuizNext.spec.js +114 -0
  156. package/tests/unit/AppCompVideoPlayer.spec.js +177 -0
  157. package/{src/components/tests__ → tests/unit}/useTimer.spec.js +91 -91
  158. package/vitest.config.js +28 -19
  159. package/vitest.setup.js +28 -0
  160. package/src/components/AppBaseButton.test.js +0 -21
@@ -1,315 +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, 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
+ 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
+ }
@@ -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
+ }