Skip to content

Commit b55a38c

Browse files
Export crypto
1 parent e34127f commit b55a38c

4 files changed

Lines changed: 34 additions & 6 deletions

File tree

src/algorithms/RSASSA-PKCS1-v1_5.js

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,9 @@
55
* @ignore
66
*/
77
const base64url = require('base64url')
8-
let crypto = require('isomorphic-webcrypto')
8+
let crypto = require('../crypto')
99
const TextEncoder = require('../text-encoder')
1010

11-
// FIXME:
12-
if (!crypto.subtle && !!crypto.default) {
13-
crypto = crypto.default
14-
}
15-
1611
/**
1712
* RSASSA-PKCS1-v1_5
1813
*/

src/crypto.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
const imported = require('isomorphic-webcrypto')
2+
3+
module.exports = (imported.default ? imported.default : imported)

src/index.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
/**
22
* @module JSON Object Signing and Encryption (JOSE)
33
*/
4+
const crypto = require('./crypto')
45
const JWA = require('./jose/JWA')
56
const JWK = require('./jose/JWK')
67
const JWKSet = require('./jose/JWKSet')
@@ -11,6 +12,7 @@ const JWS = require('./jose/JWS')
1112
* Export
1213
*/
1314
module.exports = {
15+
crypto,
1416
JWA,
1517
JWK,
1618
JWKSet,

test/cryptoSpec.js

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
'use strict'
2+
3+
/**
4+
* Test dependencies
5+
*/
6+
const chai = require('chai')
7+
const chaiAsPromised = require('chai-as-promised')
8+
9+
/**
10+
* Assertions
11+
*/
12+
chai.should()
13+
chai.use(chaiAsPromised)
14+
let expect = chai.expect
15+
16+
/**
17+
* Code under test
18+
*/
19+
const Index = require('../src/')
20+
21+
/**
22+
* Tests
23+
*/
24+
describe('Index', () => {
25+
it('exports crypto', () => {
26+
return Object.keys(Index.crypto).should.deep.equal(['subtle'])
27+
})
28+
})

0 commit comments

Comments
 (0)