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

@dfinity/rosetta-client

Package Overview
Dependencies
Maintainers
1
Versions
13
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@dfinity/rosetta-client - npm Package Compare versions

Comparing version 0.5.1 to 0.5.2

14

CHANGELOG.md

@@ -0,1 +1,15 @@

# `0.5.2`
- Add `seed_from_pem` to support loading a private key from a PEM file generated
by `dfx identity` command. (#42)
# `0.5.1`
- Fix `signed_transaction_decode` to work with upstream changes. (#34)
# `0.5.0`
- Fix a quadratic slowdown in offline combine implementation. (#33)
- Misc documentation fixes. (#33)
# `0.4.0`

@@ -2,0 +16,0 @@

39

lib/key.js

@@ -0,4 +1,6 @@

const asn1Validator = require("node-forge/lib/asn1-validator");
const assert = require("assert").strict;
const agent = require("@dfinity/agent");
const crc = require("crc");
const forge = require("node-forge");
const tweetnacl = require("tweetnacl");

@@ -54,2 +56,26 @@ const { sha224 } = require("./hash");

function seed_from_pem(pem) {
const msg = forge.pem.decode(pem)[0];
assert(msg.type === "PRIVATE KEY");
assert(!(msg.procType && msg.procType.type === "ENCRYPTED"));
const obj = forge.asn1.fromDer(msg.body);
const capture = {};
const errors = [];
const valid = forge.asn1.validate(
obj,
asn1Validator.privateKeyValidator,
capture,
errors
);
assert(valid);
const seed = Buffer.from(
forge.asn1.fromDer(capture.privateKey).value,
"binary"
);
assert(seed.byteLength === 32);
return seed;
}
exports.seed_from_pem = seed_from_pem;
/**

@@ -80,14 +106,3 @@ *

const DER_PREFIX = Buffer.from([
0x30,
0x2a,
0x30,
0x05,
0x06,
0x03,
0x2b,
0x65,
0x70,
0x03,
0x21,
0x00,
0x30, 0x2a, 0x30, 0x05, 0x06, 0x03, 0x2b, 0x65, 0x70, 0x03, 0x21, 0x00,
]);

@@ -94,0 +109,0 @@

{
"name": "@dfinity/rosetta-client",
"version": "0.5.1",
"version": "0.5.2",
"main": "./index.js",

@@ -31,9 +31,10 @@ "type": "commonjs",

"dependencies": {
"@dfinity/agent": "^0.8.3",
"@dfinity/agent": "^0.8.9",
"axios": "^0.21.1",
"cbor": "^7.0.4",
"cbor": "^7.0.5",
"crc": "^3.8.0",
"google-protobuf": "^3.15.8",
"google-protobuf": "^3.17.1",
"js-sha256": "^0.9.0",
"json-bigint": "^1.0.0",
"node-forge": "^0.10.0",
"tweetnacl": "^1.0.3"

@@ -43,7 +44,7 @@ },

"0x": "^4.10.2",
"node-inspect-extracted": "^1.0.5",
"node-inspect-extracted": "^1.0.7",
"patch-package": "^6.4.7",
"webpack": "^5.33.2",
"webpack-cli": "^4.6.0"
"webpack": "^5.38.1",
"webpack-cli": "^4.7.0"
}
}

@@ -17,3 +17,3 @@ # `@dfinity/rosetta-client`

let { randomBytes } = require("crypto");
let { key_new, key_to_pub_key } = require("@dfinity/rosetta-client");
let { key_new, key_to_pub_key, seed_from_pem } = require("@dfinity/rosetta-client");

@@ -36,2 +36,11 @@ // Derive an ED25519 private key from a system random seed. The private key's

// You can also load the seed from the identity PEM file generated by dfx, and
// use that to generate the private key for this library.
//
// 您也可以从 dfx 生成的 PEM 文件中读取种子,并用其生成本库的私钥。
seed = seed_from_pem(
readFileSync("/home/username/.config/dfx/identity/default/identity.pem")
);
privateKey = key_new(seed);
// Use key_to_pub_key() to derive a public key from a private key. The public

@@ -38,0 +47,0 @@ // key's type is Buffer.

Sorry, the diff of this file is too big to display

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