Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@cloud-cryptographic-wallet/asn1-parser

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@cloud-cryptographic-wallet/asn1-parser - npm Package Compare versions

Comparing version 0.0.2 to 0.0.3

dist/index.cjs

10

dist/index.d.ts

@@ -1,2 +0,8 @@

export * from "./parse-public-key.js";
export * from "./parse-signature.js";
declare function parsePublicKey(inputBuffer: ArrayBuffer): ArrayBuffer;
declare function parseSignature(inputBuffer: ArrayBuffer): {
r: ArrayBuffer;
s: ArrayBuffer;
};
export { parsePublicKey, parseSignature };

51

dist/index.js

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

export * from "./parse-public-key.js";
export * from "./parse-signature.js";
// src/parse-public-key.ts
import * as asn1js from "asn1js";
function parsePublicKey(inputBuffer) {
const schema = new asn1js.Sequence({
value: [
new asn1js.Sequence({
value: [new asn1js.ObjectIdentifier(), new asn1js.ObjectIdentifier()]
}),
new asn1js.BitString({ name: "publicKey" })
]
});
const parsed = asn1js.verifySchema(inputBuffer, schema);
const publicKey = parsed.result.publicKey.valueBlock.valueHex;
return publicKey.slice(1);
}
// src/parse-signature.ts
import * as asn1js2 from "asn1js";
function normalize(inputBuffer) {
if (inputBuffer.byteLength === 32) {
return inputBuffer;
}
if (inputBuffer.byteLength === 33) {
return inputBuffer.slice(1);
}
if (inputBuffer.byteLength === 31) {
return new Uint8Array([0, ...new Uint8Array(inputBuffer)]).buffer;
}
throw new Error(`parseSignature: Unexpected byte length of inputBuffer. actual: ${inputBuffer.byteLength}`);
}
function parseSignature(inputBuffer) {
const schema = new asn1js2.Sequence({
value: [
new asn1js2.Integer({ name: "r" }),
new asn1js2.Integer({ name: "s" })
]
});
const parsed = asn1js2.verifySchema(inputBuffer, schema);
if (!parsed.verified) {
throw new Error("parseSignature: failed to parse");
}
const r = parsed.result.r.valueBlock.valueHex;
const s = parsed.result.s.valueBlock.valueHex;
return { r: normalize(r), s: normalize(s) };
}
export {
parsePublicKey,
parseSignature
};
//# sourceMappingURL=index.js.map
{
"name": "@cloud-cryptographic-wallet/asn1-parser",
"version": "0.0.2",
"version": "0.0.3",
"repository": {

@@ -11,3 +11,8 @@ "type": "git",

"main": "./dist/index.js",
"exports": "./dist/index.js",
"exports": {
"import": "./dist/index.js",
"require": "./dist/index.cjs",
"node": "./dist/index.cjs",
"default": "./dist/index.js"
},
"types": "./dist/index.d.ts",

@@ -27,4 +32,3 @@ "engines": {

"scripts": {
"prebuild": "rm -rf dist",
"build": "tsc"
"build": "tsup"
},

@@ -35,6 +39,7 @@ "dependencies": {

"devDependencies": {
"@cloud-cryptographic-wallet/signer": "^0.0.3",
"@types/asn1js": "^2.0.2"
"@cloud-cryptographic-wallet/signer": "^0.0.4",
"@types/asn1js": "^2.0.2",
"tsup": "^5.12.1"
},
"gitHead": "302d5d14fd3294b3218fc2d2137418573b8c022c"
"gitHead": "a4c4787f203e0fec56267b0ca4a1f90df172d168"
}

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