Skip to content

Commit 47cb76e

Browse files
Merge branch 'master' into rishav/missing-deps
2 parents effb5e8 + 959e87f commit 47cb76e

File tree

8 files changed

+7
-249
lines changed

8 files changed

+7
-249
lines changed

modules/web-crypto-backend/package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
},
2020
"license": "Apache-2.0",
2121
"dependencies": {
22-
"@aws-crypto/ie11-detection": "4.0.0",
2322
"@aws-crypto/supports-web-crypto": "5.2.0",
2423
"@aws-sdk/util-locate-window": "3.310.0",
2524
"tslib": "^2.2.0"

modules/web-crypto-backend/src/backend-factory.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,12 @@
11
// Copyright Amazon.com Inc. or its affiliates. All Rights Reserved.
22
// SPDX-License-Identifier: Apache-2.0
33

4-
import { isMsWindow } from '@aws-crypto/ie11-detection'
54
import {
65
supportsWebCrypto,
76
supportsSubtleCrypto,
87
supportsZeroByteGCM,
98
} from '@aws-crypto/supports-web-crypto'
109
import { generateSynchronousRandomValues } from './synchronous_random_values'
11-
import promisifyMsSubtleCrypto from './promisify-ms-crypto'
1210

1311
type MaybeSubtleCrypto = SubtleCrypto | false
1412
export type WebCryptoBackend =
@@ -140,7 +138,6 @@ export function pluckSubtleCrypto(window: Window): MaybeSubtleCrypto {
140138
// if needed webkitSubtle check should be added here
141139
// see: https://webkit.org/blog/7790/update-on-web-cryptography/
142140
if (supportsWebCrypto(window)) return window.crypto.subtle
143-
if (isMsWindow(window)) return promisifyMsSubtleCrypto(window.msCrypto.subtle)
144141
return false
145142
}
146143

modules/web-crypto-backend/src/promisify-ms-crypto.ts

Lines changed: 0 additions & 38 deletions
This file was deleted.

modules/web-crypto-backend/src/synchronous_random_values.ts

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
// Copyright Amazon.com Inc. or its affiliates. All Rights Reserved.
22
// SPDX-License-Identifier: Apache-2.0
33

4-
import { isMsWindow } from '@aws-crypto/ie11-detection'
54
import { supportsSecureRandom } from '@aws-crypto/supports-web-crypto'
65
import { locateWindow } from '@aws-sdk/util-locate-window'
76

@@ -19,10 +18,6 @@ export function generateSynchronousRandomValues(
1918
return function synchronousRandomValues(byteLength: number): Uint8Array {
2019
if (supportsSecureRandom(globalScope)) {
2120
return globalScope.crypto.getRandomValues(new Uint8Array(byteLength))
22-
} else if (isMsWindow(globalScope)) {
23-
const values = new Uint8Array(byteLength)
24-
globalScope.msCrypto.getRandomValues(values)
25-
return values
2621
}
2722

2823
throw new Error(`Unable to locate a secure random source.`)

modules/web-crypto-backend/test/fixtures.ts

Lines changed: 6 additions & 143 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,12 @@
33

44
export const fakeWindowWebCryptoSupportsZeroByteGCM: Window = {
55
crypto: {
6-
getRandomValues: () => {},
6+
getRandomValues: (array: Uint8Array) => {
7+
for (let i = 0; i < array.length; i++) {
8+
array[i] = Math.floor(Math.random() * 256)
9+
}
10+
return array
11+
},
712
subtle: {
813
async decrypt() {
914
return {} as any
@@ -142,145 +147,3 @@ export const subtleFallbackZeroByteEncryptFail = {
142147
} as any
143148

144149
export const subtleFallbackNoWebCrypto = {} as any
145-
146-
export const fakeWindowIE11OnComplete = {
147-
msCrypto: {
148-
getRandomValues: (values: Uint8Array) => {
149-
return values.fill(1)
150-
},
151-
subtle: {
152-
decrypt() {
153-
const obj = {} as any
154-
setTimeout(() => {
155-
obj.result = true
156-
obj.oncomplete()
157-
})
158-
return obj
159-
},
160-
digest() {
161-
const obj = {} as any
162-
setTimeout(() => {
163-
obj.result = true
164-
obj.oncomplete()
165-
})
166-
return obj
167-
},
168-
encrypt() {
169-
const obj = {} as any
170-
setTimeout(() => {
171-
obj.result = true
172-
obj.oncomplete()
173-
})
174-
return obj
175-
},
176-
exportKey() {
177-
const obj = {} as any
178-
setTimeout(() => {
179-
obj.result = true
180-
obj.oncomplete()
181-
})
182-
return obj
183-
},
184-
generateKey() {
185-
const obj = {} as any
186-
setTimeout(() => {
187-
obj.result = true
188-
obj.oncomplete()
189-
})
190-
return obj
191-
},
192-
importKey() {
193-
const obj = {} as any
194-
setTimeout(() => {
195-
obj.result = true
196-
obj.oncomplete()
197-
})
198-
return obj
199-
},
200-
sign() {
201-
const obj = {} as any
202-
setTimeout(() => {
203-
obj.result = true
204-
obj.oncomplete()
205-
})
206-
return obj
207-
},
208-
verify() {
209-
const obj = {} as any
210-
setTimeout(() => {
211-
obj.result = true
212-
obj.oncomplete()
213-
})
214-
return obj
215-
},
216-
},
217-
},
218-
MSInputMethodContext: {} as any,
219-
} as any
220-
221-
export const fakeWindowIE11OnError = {
222-
msCrypto: {
223-
getRandomValues: (values: Uint8Array) => {
224-
return values.fill(1)
225-
},
226-
subtle: {
227-
decrypt() {
228-
const obj = {} as any
229-
setTimeout(() => {
230-
obj.onerror(new Error('stub error'))
231-
})
232-
return obj
233-
},
234-
digest() {
235-
const obj = {} as any
236-
setTimeout(() => {
237-
obj.onerror(new Error('stub error'))
238-
})
239-
return obj
240-
},
241-
encrypt() {
242-
const obj = {} as any
243-
setTimeout(() => {
244-
obj.onerror(new Error('stub error'))
245-
})
246-
return obj
247-
},
248-
exportKey() {
249-
const obj = {} as any
250-
setTimeout(() => {
251-
obj.onerror(new Error('stub error'))
252-
})
253-
return obj
254-
},
255-
generateKey() {
256-
const obj = {} as any
257-
setTimeout(() => {
258-
obj.onerror(new Error('stub error'))
259-
})
260-
return obj
261-
},
262-
importKey() {
263-
const obj = {} as any
264-
setTimeout(() => {
265-
obj.onerror(new Error('stub error'))
266-
})
267-
return obj
268-
},
269-
sign() {
270-
const obj = {} as any
271-
setTimeout(() => {
272-
obj.onerror(new Error('stub error'))
273-
})
274-
return obj
275-
},
276-
verify() {
277-
const obj = {} as any
278-
setTimeout(() => {
279-
obj.onerror(new Error('stub error'))
280-
})
281-
return obj
282-
},
283-
},
284-
},
285-
MSInputMethodContext: {} as any,
286-
} as any

modules/web-crypto-backend/test/promisify-ms-crypto.test.ts

Lines changed: 0 additions & 36 deletions
This file was deleted.

modules/web-crypto-backend/test/synchronous_random_values.test.ts

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,25 +5,15 @@
55

66
import { expect } from 'chai'
77
import { generateSynchronousRandomValues } from '../src/synchronous_random_values'
8-
import { synchronousRandomValues } from '../src/index'
98
import * as fixtures from './fixtures'
109

1110
describe('synchronousRandomValues', () => {
1211
it('should return random values', () => {
13-
const test = synchronousRandomValues(5)
14-
expect(test).to.be.instanceOf(Uint8Array)
15-
expect(test).lengthOf(5)
16-
})
17-
18-
it('should return msCrypto random values', () => {
1912
const synchronousRandomValues = generateSynchronousRandomValues(
20-
fixtures.fakeWindowIE11OnComplete
13+
fixtures.fakeWindowWebCryptoSupportsZeroByteGCM
2114
)
22-
2315
const test = synchronousRandomValues(5)
2416
expect(test).to.be.instanceOf(Uint8Array)
2517
expect(test).lengthOf(5)
26-
// The random is a stub, so I know the value
27-
expect(test).to.deep.equal(new Uint8Array(5).fill(1))
2818
})
2919
})

package-lock.json

Lines changed: 0 additions & 12 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)