Skip to content

Commit

Permalink
Export crypto
Browse files Browse the repository at this point in the history
  • Loading branch information
michielbdejong committed Jul 29, 2020
1 parent e34127f commit b55a38c
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 6 deletions.
7 changes: 1 addition & 6 deletions src/algorithms/RSASSA-PKCS1-v1_5.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,9 @@
* @ignore
*/
const base64url = require('base64url')
let crypto = require('isomorphic-webcrypto')
let crypto = require('../crypto')
const TextEncoder = require('../text-encoder')

// FIXME:
if (!crypto.subtle && !!crypto.default) {
crypto = crypto.default
}

/**
* RSASSA-PKCS1-v1_5
*/
Expand Down
3 changes: 3 additions & 0 deletions src/crypto.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
const imported = require('isomorphic-webcrypto')

module.exports = (imported.default ? imported.default : imported)
2 changes: 2 additions & 0 deletions src/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/**
* @module JSON Object Signing and Encryption (JOSE)
*/
const crypto = require('./crypto')
const JWA = require('./jose/JWA')
const JWK = require('./jose/JWK')
const JWKSet = require('./jose/JWKSet')
Expand All @@ -11,6 +12,7 @@ const JWS = require('./jose/JWS')
* Export
*/
module.exports = {
crypto,
JWA,
JWK,
JWKSet,
Expand Down
28 changes: 28 additions & 0 deletions test/cryptoSpec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
'use strict'

/**
* Test dependencies
*/
const chai = require('chai')
const chaiAsPromised = require('chai-as-promised')

/**
* Assertions
*/
chai.should()
chai.use(chaiAsPromised)
let expect = chai.expect

/**
* Code under test
*/
const Index = require('../src/')

/**
* Tests
*/
describe('Index', () => {
it('exports crypto', () => {
return Object.keys(Index.crypto).should.deep.equal(['subtle'])
})
})

0 comments on commit b55a38c

Please sign in to comment.