New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@sphereon/ssi-sdk-ext.key-utils

Package Overview
Dependencies
Maintainers
4
Versions
355
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@sphereon/ssi-sdk-ext.key-utils - npm Package Compare versions

Comparing version 0.24.1-unstable.54 to 0.24.1-unstable.63

26

dist/functions.js

@@ -40,2 +40,3 @@ "use strict";

const random_1 = require("@ethersproject/random");
const ssi_sdk_ext_x509_utils_1 = require("@sphereon/ssi-sdk-ext.x509-utils");
const ed25519_1 = require("@stablelib/ed25519");

@@ -46,3 +47,2 @@ const elliptic_1 = __importDefault(require("elliptic"));

const types_1 = require("./types");
const x509_1 = require("./x509");
const ssi_types_1 = require("@sphereon/ssi-types");

@@ -68,4 +68,4 @@ exports.logger = ssi_types_1.Loggers.DEFAULT.get('sphereon:key-utils');

case 'RSA': {
const pem = yield (0, x509_1.generateRSAKeyAsPEM)('RSA-PSS', 'SHA-256', 2048);
return (0, x509_1.privateKeyHexFromPEM)(pem);
const pem = yield (0, ssi_sdk_ext_x509_utils_1.generateRSAKeyAsPEM)('RSA-PSS', 'SHA-256', 2048);
return (0, ssi_sdk_ext_x509_utils_1.privateKeyHexFromPEM)(pem);
}

@@ -103,3 +103,3 @@ default:

// If we do not have a privateKeyHex but do have a PEM
privateKeyHex = (0, x509_1.privateKeyHexFromPEM)(key.meta.x509.privateKeyPEM);
privateKeyHex = (0, ssi_sdk_ext_x509_utils_1.privateKeyHexFromPEM)(key.meta.x509.privateKeyPEM);
}

@@ -267,3 +267,3 @@ }

const pubPoint = keyPair.getPublic();
return Object.assign(Object.assign(Object.assign({ alg: 'ES256K' }, (use !== undefined && { use })), { kty: types_1.KeyType.EC, crv: types_1.KeyCurve.Secp256k1, x: (0, x509_1.hexToBase64)(pubPoint.getX().toString('hex'), 'base64url'), y: (0, x509_1.hexToBase64)(pubPoint.getY().toString('hex'), 'base64url') }), ((opts === null || opts === void 0 ? void 0 : opts.isPrivateKey) && { d: (0, x509_1.hexToBase64)(keyPair.getPrivate('hex'), 'base64url') }));
return Object.assign(Object.assign(Object.assign({ alg: 'ES256K' }, (use !== undefined && { use })), { kty: types_1.KeyType.EC, crv: types_1.KeyCurve.Secp256k1, x: (0, ssi_sdk_ext_x509_utils_1.hexToBase64)(pubPoint.getX().toString('hex'), 'base64url'), y: (0, ssi_sdk_ext_x509_utils_1.hexToBase64)(pubPoint.getY().toString('hex'), 'base64url') }), ((opts === null || opts === void 0 ? void 0 : opts.isPrivateKey) && { d: (0, ssi_sdk_ext_x509_utils_1.hexToBase64)(keyPair.getPrivate('hex'), 'base64url') }));
};

@@ -290,3 +290,3 @@ /**

const pubPoint = keyPair.getPublic();
return Object.assign(Object.assign(Object.assign({ alg: 'ES256' }, (use !== undefined && { use })), { kty: types_1.KeyType.EC, crv: types_1.KeyCurve.P_256, x: (0, x509_1.hexToBase64)(pubPoint.getX().toString('hex'), 'base64url'), y: (0, x509_1.hexToBase64)(pubPoint.getY().toString('hex'), 'base64url') }), ((opts === null || opts === void 0 ? void 0 : opts.isPrivateKey) && { d: (0, x509_1.hexToBase64)(keyPair.getPrivate('hex'), 'base64url') }));
return Object.assign(Object.assign(Object.assign({ alg: 'ES256' }, (use !== undefined && { use })), { kty: types_1.KeyType.EC, crv: types_1.KeyCurve.P_256, x: (0, ssi_sdk_ext_x509_utils_1.hexToBase64)(pubPoint.getX().toString('hex'), 'base64url'), y: (0, ssi_sdk_ext_x509_utils_1.hexToBase64)(pubPoint.getY().toString('hex'), 'base64url') }), ((opts === null || opts === void 0 ? void 0 : opts.isPrivateKey) && { d: (0, ssi_sdk_ext_x509_utils_1.hexToBase64)(keyPair.getPrivate('hex'), 'base64url') }));
};

@@ -303,3 +303,3 @@ /**

const { use } = opts !== null && opts !== void 0 ? opts : {};
return Object.assign(Object.assign({ alg: 'EdDSA' }, (use !== undefined && { use })), { kty: types_1.KeyType.OKP, crv: (_a = opts === null || opts === void 0 ? void 0 : opts.crv) !== null && _a !== void 0 ? _a : types_1.KeyCurve.Ed25519, x: (0, x509_1.hexToBase64)(publicKeyHex, 'base64url') });
return Object.assign(Object.assign({ alg: 'EdDSA' }, (use !== undefined && { use })), { kty: types_1.KeyType.OKP, crv: (_a = opts === null || opts === void 0 ? void 0 : opts.crv) !== null && _a !== void 0 ? _a : types_1.KeyCurve.Ed25519, x: (0, ssi_sdk_ext_x509_utils_1.hexToBase64)(publicKeyHex, 'base64url') });
};

@@ -314,4 +314,4 @@ const toRSAJwk = (publicKeyHex, opts) => {

}
const publicKeyPEM = (_c = (_b = key === null || key === void 0 ? void 0 : key.meta) === null || _b === void 0 ? void 0 : _b.publicKeyPEM) !== null && _c !== void 0 ? _c : (0, x509_1.hexToPEM)(publicKeyHex, 'public');
return (0, x509_1.PEMToJwk)(publicKeyPEM, 'public');
const publicKeyPEM = (_c = (_b = key === null || key === void 0 ? void 0 : key.meta) === null || _b === void 0 ? void 0 : _b.publicKeyPEM) !== null && _c !== void 0 ? _c : (0, ssi_sdk_ext_x509_utils_1.hexToPEM)(publicKeyHex, 'public');
return (0, ssi_sdk_ext_x509_utils_1.PEMToJwk)(publicKeyPEM, 'public');
};

@@ -340,5 +340,5 @@ const padLeft = (args) => {

const OID = {
[OIDType.Secp256k1]: new Uint8Array([0x06, 0x07, 0x2A, 0x86, 0x48, 0xCE, 0x3D, 0x02, 0x01]),
[OIDType.Secp256r1]: new Uint8Array([0x06, 0x08, 0x2A, 0x86, 0x48, 0xCE, 0x3D, 0x03, 0x01, 0x07]),
[OIDType.Ed25519]: new Uint8Array([0x06, 0x03, 0x2B, 0x65, 0x70])
[OIDType.Secp256k1]: new Uint8Array([0x06, 0x07, 0x2a, 0x86, 0x48, 0xce, 0x3d, 0x02, 0x01]),
[OIDType.Secp256r1]: new Uint8Array([0x06, 0x08, 0x2a, 0x86, 0x48, 0xce, 0x3d, 0x03, 0x01, 0x07]),
[OIDType.Ed25519]: new Uint8Array([0x06, 0x03, 0x2b, 0x65, 0x70]),
};

@@ -384,3 +384,3 @@ const compareUint8Arrays = (a, b) => {

if (derKey[1] & 0x80) {
const lengthBytesCount = derKey[1] & 0x7F;
const lengthBytesCount = derKey[1] & 0x7f;
index += lengthBytesCount;

@@ -387,0 +387,0 @@ }

@@ -7,8 +7,6 @@ /**

*/
export * from './x509';
export * from './functions';
export * from './jwk-jcs';
export * from './types';
export * from './x509/x509-utils';
export * from './digest-methods';
//# sourceMappingURL=index.d.ts.map

@@ -23,8 +23,6 @@ "use strict";

*/
__exportStar(require("./x509"), exports);
__exportStar(require("./functions"), exports);
__exportStar(require("./jwk-jcs"), exports);
__exportStar(require("./types"), exports);
__exportStar(require("./x509/x509-utils"), exports);
__exportStar(require("./digest-methods"), exports);
//# sourceMappingURL=index.js.map
import type { ByteView } from 'multiformats/codecs/interface';
import type { JsonWebKey } from 'did-resolver';
/**

@@ -4,0 +3,0 @@ * Encodes a JWK into a Uint8Array. Only the required JWK members are encoded.

{
"name": "@sphereon/ssi-sdk-ext.key-utils",
"description": "Sphereon SSI-SDK plugin for key creation.",
"version": "0.24.1-unstable.54+5ce83cc",
"version": "0.24.1-unstable.63+adfc57a",
"source": "src/index.ts",

@@ -14,2 +14,3 @@ "main": "dist/index.js",

"@ethersproject/random": "^5.7.0",
"@sphereon/ssi-sdk-ext.x509-utils": "0.24.1-unstable.63+adfc57a",
"@sphereon/ssi-types": "0.29.1-next.46",

@@ -52,3 +53,3 @@ "@stablelib/ed25519": "^1.0.3",

],
"gitHead": "5ce83cca64d55b664a2b0e6eb04660d299e2655c"
"gitHead": "adfc57aea4001853b32c0a0b0c910ea79ed83edf"
}
import { randomBytes } from '@ethersproject/random'
import { PEMToJwk, generateRSAKeyAsPEM, hexToBase64, privateKeyHexFromPEM, hexToPEM } from '@sphereon/ssi-sdk-ext.x509-utils'
import { generateKeyPair as generateSigningKeyPair } from '@stablelib/ed25519'

@@ -10,6 +11,3 @@ import { IAgentContext, IKey, IKeyManager, ManagedKeyInfo, MinimalImportableKey } from '@veramo/core'

import { ENC_KEY_ALGS, IImportProvidedOrGeneratedKeyArgs, JWK, JwkKeyUse, KeyCurve, KeyType, SIG_KEY_ALGS, TKeyType } from './types'
import { generateRSAKeyAsPEM, hexToBase64, hexToPEM, PEMToJwk, privateKeyHexFromPEM } from './x509'
import { Loggers } from '@sphereon/ssi-types'
export const logger = Loggers.DEFAULT.get('sphereon:key-utils')

@@ -357,16 +355,14 @@

enum OIDType {
Secp256k1,
Secp256r1,
Ed25519
Ed25519,
}
const OID: Record<OIDType, Uint8Array> = {
[OIDType.Secp256k1]: new Uint8Array([0x06, 0x07, 0x2A, 0x86, 0x48, 0xCE, 0x3D, 0x02, 0x01]),
[OIDType.Secp256r1]: new Uint8Array([0x06, 0x08, 0x2A, 0x86, 0x48, 0xCE, 0x3D, 0x03, 0x01, 0x07]),
[OIDType.Ed25519]: new Uint8Array([0x06, 0x03, 0x2B, 0x65, 0x70])
[OIDType.Secp256k1]: new Uint8Array([0x06, 0x07, 0x2a, 0x86, 0x48, 0xce, 0x3d, 0x02, 0x01]),
[OIDType.Secp256r1]: new Uint8Array([0x06, 0x08, 0x2a, 0x86, 0x48, 0xce, 0x3d, 0x03, 0x01, 0x07]),
[OIDType.Ed25519]: new Uint8Array([0x06, 0x03, 0x2b, 0x65, 0x70]),
}
const compareUint8Arrays = (a: Uint8Array, b: Uint8Array): boolean => {

@@ -396,5 +392,5 @@ if (a.length !== b.length) {

case 'Secp256k1':
return OID[OIDType.Secp256k1]
return OID[OIDType.Secp256k1]
case 'Secp256r1':
return OID[OIDType.Secp256r1]
return OID[OIDType.Secp256r1]
case 'Ed25519':

@@ -409,6 +405,3 @@ return OID[OIDType.Ed25519]

export const asn1DerToRawPublicKey = (
derKey: Uint8Array,
keyType: TKeyType
): Uint8Array => {
export const asn1DerToRawPublicKey = (derKey: Uint8Array, keyType: TKeyType): Uint8Array => {
if (!isAsn1Der(derKey)) {

@@ -420,3 +413,3 @@ throw new Error('Invalid DER encoding: Expected to start with sequence tag')

if (derKey[1] & 0x80) {
const lengthBytesCount = derKey[1] & 0x7F
const lengthBytesCount = derKey[1] & 0x7f
index += lengthBytesCount

@@ -474,3 +467,2 @@ }

export const hexStringFromUint8Array = (value: Uint8Array): string => u8a.toString(value, 'base16')

@@ -7,7 +7,5 @@ /**

*/
export * from './x509'
export * from './functions'
export * from './jwk-jcs'
export * from './types'
export * from './x509/x509-utils'
export * from './digest-methods'
import { TextDecoder, TextEncoder } from 'web-encoding'
import isPlainObject from 'lodash.isplainobject'
import type { ByteView } from 'multiformats/codecs/interface'
import type { JsonWebKey } from 'did-resolver'

@@ -6,0 +5,0 @@ const textEncoder = new TextEncoder()

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

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