This repository has been archived by the owner on Sep 13, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 44
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Moved to latest msrCrypto library and added tests
- Loading branch information
Showing
10 changed files
with
12,486 additions
and
127 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
function includes(haystack, needle) { | ||
return haystack.indexOf(needle) > -1; | ||
} | ||
|
||
window.Promise = require('bluebird'); | ||
|
||
var ua = navigator.userAgent; | ||
var isSafari = includes(ua, 'Safari') && !includes(ua, 'Chrome'); | ||
var isEdge = includes(ua, 'Edge'); | ||
var isIE11 = !!window.MSInputMethodContext && !!document.documentMode; | ||
require('webcrypto-test-suite')({ | ||
crypto: require('../src/browser.js'), | ||
shouldSkip: function(spec) { | ||
if (isSafari) { | ||
if (includes(spec,'ES512')) return true; | ||
if (includes(spec,'RS384') && includes(spec,'exportKey')) return true; | ||
if (includes(spec,'RS512') && includes(spec,'exportKey')) return true; | ||
} | ||
if (isEdge) { | ||
// Misidentifies private types as public and has no modulesLength or publicExponent | ||
if (includes(spec,'RS256') && includes(spec,'importKey')) return true; | ||
|
||
// Has no modulesLength or publicExponent | ||
if (includes(spec,'RS384') && includes(spec,'importKey')) return true; | ||
if (includes(spec,'RS512') && includes(spec,'importKey')) return true; | ||
|
||
// Should return Uint8Array for publicExponent rather than Int8Array | ||
if (includes(spec,'RS256') && includes(spec,'generateKey')) return true; | ||
if (includes(spec,'RS384') && includes(spec,'generateKey')) return true; | ||
if (includes(spec,'RS512') && includes(spec,'generateKey')) return true; | ||
|
||
// Could not complete the operation due to error c000000d | ||
if (includes(spec,'RS256') && includes(spec,'sign')) return true; | ||
|
||
// Not working at all | ||
if (includes(spec,'ES256')) return true; | ||
if (includes(spec,'ES384')) return true; | ||
if (includes(spec,'ES512')) return true; | ||
} | ||
if (isIE11) { | ||
// All errors are browser events, so there are no error messages to aid debugging | ||
|
||
// Misidentifies private types as public | ||
if (includes(spec,'RS256') && includes(spec,'importKey')) return true; | ||
|
||
// Missing d, q, dq, p, dp (probably because importKey says it's public) | ||
if (includes(spec,'RS256') && includes(spec,'exportKey')) return true; | ||
|
||
// Not working at all | ||
if (includes(spec,'RS256') && includes(spec,'sign')) return true; | ||
if (includes(spec,'RS512') && includes(spec,'sign')) return true; | ||
if (includes(spec,'RS512') && includes(spec,'verify')) return true; | ||
if (includes(spec,'HS512')) return true; | ||
if (includes(spec,'ES256')) return true; | ||
if (includes(spec,'ES384')) return true; | ||
if (includes(spec,'ES512')) return true; | ||
} | ||
} | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
const crypto = require('../src/index'); | ||
|
||
require('webcrypto-test-suite')({ | ||
crypto, | ||
shouldSkip(spec) { | ||
if (spec.includes('ES256') && spec.includes('verify')) return true; | ||
if (spec.includes('ES384') && spec.includes('verify')) return true; | ||
if (spec.includes('ES512')) return true; | ||
} | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
// Include additional mocks not included in the react-native preset | ||
global.window = { | ||
Uint8Array, | ||
Promise | ||
}; | ||
function XMLHttpRequest() {} | ||
XMLHttpRequest.prototype.getResponseHeader = function() {}; | ||
global.XMLHttpRequest = XMLHttpRequest; | ||
|
||
delete global.Buffer; | ||
|
||
jest.mock('b64-lite', () => require('b64-lite/dist/react-native.js')); | ||
jest.mock('str2buf', () => require('str2buf/dist/str2buf.js')); | ||
|
||
const crypto = require('../src/react-native'); | ||
|
||
require('webcrypto-test-suite')({ | ||
crypto, | ||
shouldSkip(spec) { | ||
if (spec.includes('RS256') && spec.includes('generateKey')) return true; | ||
if (spec.includes('RS384') && spec.includes('generateKey')) return true; | ||
if (spec.includes('RS512') && spec.includes('generateKey')) return true; | ||
} | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"preset": "react-native" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
const os = require('os'); | ||
|
||
let browsers = ['ChromeHeadless', 'FirefoxHeadless']; | ||
if (process.platform === 'darwin') { | ||
browsers.push('Safari'); | ||
} else if (process.platform === 'win32' && | ||
os.release().slice(3) === '10.') { | ||
browsers.push('Edge'); | ||
} | ||
|
||
module.exports = function(config) { | ||
config.set({ | ||
frameworks: ['jasmine'], | ||
files: [ | ||
'__tests__/browser.js' | ||
], | ||
preprocessors: { | ||
'__tests__/browser.js': ['webpack'] | ||
}, | ||
webpack: { | ||
mode: 'none', | ||
node: false | ||
}, | ||
reporters: ['progress'], | ||
port: 9876, | ||
colors: true, | ||
// config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG | ||
logLevel: config.LOG_INFO, | ||
autoWatch: true, | ||
browsers, | ||
customLaunchers: { | ||
FirefoxHeadless: { | ||
base: 'Firefox', | ||
flags: ['-headless'] | ||
}, | ||
EdgeVM: { | ||
base: 'VirtualBoxEdge', | ||
keepAlive: true, | ||
uuid: process.env.EDGE_VIRTUAL_BOX_UUID | ||
}, | ||
IE11VM: { | ||
base: 'VirtualBoxIE11', | ||
keepAlive: true, | ||
uuid: process.env.IE11_VIRTUAL_BOX_UUID | ||
} | ||
} | ||
}) | ||
} |
Oops, something went wrong.