Socket
Socket
Sign inDemoInstall

@trust/webcrypto

Package Overview
Dependencies
Maintainers
7
Versions
19
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@trust/webcrypto - npm Package Compare versions

Comparing version 0.8.3 to 0.8.4

index.d.ts

3

package.json
{
"name": "@trust/webcrypto",
"version": "0.8.3",
"version": "0.8.4",
"description": "WebCrypto API for Node.js",
"main": "src/index.js",
"types": "index.d.ts",
"directories": {

@@ -7,0 +8,0 @@ "test": "test"

@@ -9,2 +9,3 @@ /**

const {TextEncoder, TextDecoder} = require('text-encoding')
const base64url = require('base64url').default

@@ -323,7 +324,7 @@ /**

}
// 3-7. Setupp RSSASSA object
// 3-7. Setup RSSASSA object
let alg = new RSASSA_PKCS1_v1_5({
name: 'RSASSA-PKCS1-v1_5',
modulusLength: (new Buffer(jwk.n, 'base64').length / 2) * 8,
publicExponent: new Uint8Array([0x01, 0x00, 0x01]), // TODO use jwk.e
modulusLength: base64url.toBuffer(jwk.n).length * 8,
publicExponent: new Uint8Array(base64url.toBuffer(jwk.e)),
hash: normalizedHash

@@ -330,0 +331,0 @@ })

@@ -470,3 +470,3 @@ /**

// 6. Setup normalizedKeyAlgorithm
let normalizedKeyAlgorithm = supportedAlgorithms.normalize('importKey', unwrapAlgorithm)
let normalizedKeyAlgorithm = supportedAlgorithms.normalize('importKey', unwrappedKeyAlgorithm)
if (normalizedKeyAlgorithm instanceof Error) {

@@ -473,0 +473,0 @@ // 7. If failed, then try again with op as 'encrypt'

@@ -664,2 +664,10 @@ /**

it('should define modulusLength', () => {
key.algorithm.modulusLength.should.eql(2048)
})
it('should define publicExponent', () => {
key.algorithm.publicExponent.should.eql(new Uint8Array([0x01, 0x00, 0x01]))
})
it('should define extractable', () => {

@@ -694,2 +702,10 @@ key.extractable.should.equal(false)

it('should define modulusLength', () => {
key.algorithm.modulusLength.should.eql(2048)
})
it('should define publicExponent', () => {
key.algorithm.publicExponent.should.eql(new Uint8Array([0x01, 0x00, 0x01]))
})
it('should define extractable', () => {

@@ -696,0 +712,0 @@ key.extractable.should.equal(true)

@@ -1253,3 +1253,58 @@ /**

describe('with valid arguments', () => {
describe('with different key arguments', async () => {
let unwrappedSymmetric;
before(async () => {
let cryptoAlgorithm = {
name: "RSA-OAEP",
modulusLength: 2048,
publicExponent: new Uint8Array([0x01, 0x00, 0x01]),
hash: { name: "SHA-1" }
};
let cryptoSymmetricAlgorithm = {
name: "AES-GCM",
length: 256, //can be 128, 192, or 256
};
let wrappingAlgorithm = {
name: "RSA-OAEP",
hash: {name: "SHA-1"},
};
let asymmetricKey = await crypto.subtle.generateKey(
cryptoAlgorithm,
true,
["encrypt", "decrypt", "wrapKey"]
);
let symmetric = await crypto.subtle.generateKey(
cryptoSymmetricAlgorithm,
true,
["encrypt", "decrypt"]
);
let wrappedSymmetric = await crypto.subtle.wrapKey(
"raw",
symmetric,
asymmetricKey.publicKey,
wrappingAlgorithm
);
unwrappedSymmetric = await crypto.subtle.unwrapKey(
"raw",
wrappedSymmetric,
asymmetricKey.privateKey,
wrappingAlgorithm,
cryptoSymmetricAlgorithm,
false,
["encrypt", "decrypt"]
);
});
it('should resolve the promise', () => {
unwrappedSymmetric.should.be.instanceof(CryptoKey)
})
})
describe('with valid arguments', () => {
let promise, result, error

@@ -1256,0 +1311,0 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc