Socket
Socket
Sign inDemoInstall

@0xpass/passport

Package Overview
Dependencies
Maintainers
3
Versions
39
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@0xpass/passport - npm Package Compare versions

Comparing version 1.0.0 to 1.0.1

6

CHANGELOG.md
# @0xpass/passport
## 1.0.1
### Patch Changes
- f943c97: Remove reliance on window api
## 1.0.0

@@ -4,0 +10,0 @@

13

dist/index.js

@@ -5,17 +5,18 @@ import axios from 'axios';

const cryptoObj = typeof window !== "undefined" ? window.crypto : crypto;
const LOCAL_RSA_PUBLIC_KEY = "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAsl8sLC46QMKa400EnVfz+bEU2JJHXsXcwIGMItRJ3ZM3XZSzAmELJPh3lAlXyhktq2Cl0w0PuaH//fCQm5/3Rm48ytcdBmvwh3zpCnUylS3eJKF15L2xMb8eQf6nnNMnucnrhvDfdCL5ZZlkn2FDB4/UJpgPfrHivK69gaeT725g89gWvKmEG7+RGoXLPEXU4UyHxYyMMCDwxH2fE+jN53FG8JlwuLu1cbTYxgYIxf4Um+CvYp7irlGfvxP+Ws9lkBJ+MtCishod/7ytJD9jpbYf6BUAHSAeWeNBbkgSdmPSia4Mi2wPXeqmzmovjfJfWSiaCW+wFuMyCGVx/g/znQIDAQAB";
const TESTNET_RSA_PUBLIC_KEY = "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAvQOa1gkatuN6KjaS4KEWsVZAN9i4Cf0j9jlmBW5RwCJ3Bxo32McP7axt4Ev6sMWM24lpCgXgu68S9KBYRcrcEB6dRcaupFGd+ER7M518fiJ0VtCZ+XRnmwn9fqEvotp9DPZOysJkUQ60kugCRKwNvfZzAFcDiubwiqsUY2sCm943a/u9Hym51SEetG+ZFPJZFOBqwRSGkOgGZ+9Ac7ITE+bWLCZk9DlzRu+BIoDOFzXZIn+/0a0X8BnLtRY4g50aew4J+4OllQagBbhYnPMvYExYIEUx6bdjQicw0Js6s2pHr+SFAX23kQtbVOVxb5+KEGp1d+6Q4Gx7FBoyWI5qPQIDAQAB";
const generateAesKey = async () => {
const cryptoKey = await window.crypto.subtle.generateKey({
const cryptoKey = await cryptoObj.subtle.generateKey({
name: "AES-GCM",
length: 256,
}, true, ["encrypt", "decrypt"]);
return await window.crypto.subtle.exportKey("raw", cryptoKey);
return await cryptoObj.subtle.exportKey("raw", cryptoKey);
};
const importKey = async (keyFormat, encryptionKey, algo, keyUsages, extractable = false) => {
return window.crypto.subtle.importKey(keyFormat, encryptionKey, algo, extractable, keyUsages);
return cryptoObj.subtle.importKey(keyFormat, encryptionKey, algo, extractable, keyUsages);
};
const encrypt = async (algo, key, data) => {
try {
return await window.crypto.subtle.encrypt(algo, key, data);
return await cryptoObj.subtle.encrypt(algo, key, data);
}

@@ -29,3 +30,3 @@ catch (error) {

try {
return await window.crypto.subtle.decrypt(algo, key, data);
return await cryptoObj.subtle.decrypt(algo, key, data);
}

@@ -49,3 +50,3 @@ catch (error) {

]);
const iv = window.crypto.getRandomValues(new Uint8Array(12)); // Initialization vector
const iv = cryptoObj.getRandomValues(new Uint8Array(12)); // Initialization vector
encrypted = await encrypt({ name: "AES-GCM", iv }, cryptoKey, data);

@@ -52,0 +53,0 @@ const combined = new Uint8Array(iv.length + encrypted.byteLength);

{
"name": "@0xpass/passport",
"version": "1.0.0",
"version": "1.0.1",
"description": "",

@@ -5,0 +5,0 @@ "main": "dist/index.js",

@@ -0,1 +1,3 @@

const cryptoObj = typeof window !== "undefined" ? window.crypto : crypto;
export const LOCAL_RSA_PUBLIC_KEY =

@@ -8,3 +10,3 @@ "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAsl8sLC46QMKa400EnVfz+bEU2JJHXsXcwIGMItRJ3ZM3XZSzAmELJPh3lAlXyhktq2Cl0w0PuaH//fCQm5/3Rm48ytcdBmvwh3zpCnUylS3eJKF15L2xMb8eQf6nnNMnucnrhvDfdCL5ZZlkn2FDB4/UJpgPfrHivK69gaeT725g89gWvKmEG7+RGoXLPEXU4UyHxYyMMCDwxH2fE+jN53FG8JlwuLu1cbTYxgYIxf4Um+CvYp7irlGfvxP+Ws9lkBJ+MtCishod/7ytJD9jpbYf6BUAHSAeWeNBbkgSdmPSia4Mi2wPXeqmzmovjfJfWSiaCW+wFuMyCGVx/g/znQIDAQAB";

export const generateKeyPair = async () => {
const keyPair = await window.crypto.subtle.generateKey(
const keyPair = await cryptoObj.subtle.generateKey(
{

@@ -18,4 +20,4 @@ name: "ECDSA",

const publicKey = await window.crypto.subtle.exportKey("spki", keyPair.publicKey);
const privateKey = await window.crypto.subtle.exportKey("pkcs8", keyPair.privateKey);
const publicKey = await cryptoObj.subtle.exportKey("spki", keyPair.publicKey);
const privateKey = await cryptoObj.subtle.exportKey("pkcs8", keyPair.privateKey);

@@ -38,3 +40,3 @@ const publicKeyPem = arrayBufferToPem(publicKey);

export const generateAesKey = async () => {
const cryptoKey = await window.crypto.subtle.generateKey(
const cryptoKey = await cryptoObj.subtle.generateKey(
{

@@ -47,7 +49,7 @@ name: "AES-GCM",

);
return await window.crypto.subtle.exportKey("raw", cryptoKey);
return await cryptoObj.subtle.exportKey("raw", cryptoKey);
};
export const importKey = async (keyFormat, encryptionKey, algo, keyUsages, extractable = false) => {
return window.crypto.subtle.importKey(keyFormat, encryptionKey, algo, extractable, keyUsages);
return cryptoObj.subtle.importKey(keyFormat, encryptionKey, algo, extractable, keyUsages);
};

@@ -57,3 +59,3 @@

try {
return await window.crypto.subtle.encrypt(algo, key, data);
return await cryptoObj.subtle.encrypt(algo, key, data);
} catch (error) {

@@ -67,3 +69,3 @@ console.error("Encryption error:", error);

try {
return await window.crypto.subtle.decrypt(algo, key, data);
return await cryptoObj.subtle.decrypt(algo, key, data);
} catch (error) {

@@ -95,3 +97,3 @@ console.error("Decryption error:", error);

const iv = window.crypto.getRandomValues(new Uint8Array(12)); // Initialization vector
const iv = cryptoObj.getRandomValues(new Uint8Array(12)); // Initialization vector
encrypted = await encrypt({ name: "AES-GCM", iv }, cryptoKey, data);

@@ -98,0 +100,0 @@

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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