@nats-io/nkeys
Advanced tools
Comparing version 2.0.0-1 to 2.0.0-2
{ | ||
"name": "@nats-io/nkeys", | ||
"version": "2.0.0-1", | ||
"version": "2.0.0-2", | ||
"exports": { | ||
@@ -5,0 +5,0 @@ ".": "./src/mod.ts" |
@@ -22,5 +22,5 @@ "use strict"; | ||
const nkeys_1 = require("./nkeys"); | ||
const tweetnacl_1 = __importDefault(require("tweetnacl")); | ||
const nacl_1 = __importDefault(require("./nacl")); | ||
const codec_1 = require("./codec"); | ||
const mod_1 = require("./mod"); | ||
const nkeys_2 = require("./nkeys"); | ||
const base32_1 = require("./base32"); | ||
@@ -49,3 +49,3 @@ const crc16_1 = require("./crc16"); | ||
} | ||
return codec_1.Codec.encode(mod_1.Prefix.Private, this.seed); | ||
return codec_1.Codec.encode(nkeys_2.Prefix.Private, this.seed); | ||
} | ||
@@ -56,4 +56,4 @@ getPublicKey() { | ||
} | ||
const pub = tweetnacl_1.default.scalarMult.base(this.seed); | ||
const buf = codec_1.Codec.encode(mod_1.Prefix.Curve, pub); | ||
const pub = nacl_1.default.scalarMult.base(this.seed); | ||
const buf = codec_1.Codec.encode(nkeys_2.Prefix.Curve, pub); | ||
return new TextDecoder().decode(buf); | ||
@@ -65,3 +65,3 @@ } | ||
} | ||
return codec_1.Codec.encodeSeed(mod_1.Prefix.Curve, this.seed); | ||
return codec_1.Codec.encodeSeed(nkeys_2.Prefix.Curve, this.seed); | ||
} | ||
@@ -80,3 +80,3 @@ sign() { | ||
} | ||
if (raw[0] !== mod_1.Prefix.Curve) { | ||
if (raw[0] !== nkeys_2.Prefix.Curve) { | ||
throw new nkeys_1.NKeysError(nkeys_1.NKeysErrorCode.InvalidPublicKey); | ||
@@ -103,3 +103,3 @@ } | ||
if (!nonce) { | ||
nonce = tweetnacl_1.default.randomBytes(exports.curveNonceLen); | ||
nonce = nacl_1.default.randomBytes(exports.curveNonceLen); | ||
} | ||
@@ -112,3 +112,3 @@ const pub = this.decodePubCurveKey(recipient); | ||
// this is only the encoded payload | ||
const encrypted = tweetnacl_1.default.box(message, nonce, pub, this.seed); | ||
const encrypted = nacl_1.default.box(message, nonce, pub, this.seed); | ||
// the full message is the header+nonce+encrypted | ||
@@ -139,3 +139,3 @@ const fullMessage = new Uint8Array(out.length + encrypted.length); | ||
message = message.slice(exports.curveNonceLen); | ||
return tweetnacl_1.default.box.open(message, nonce, pub, this.seed); | ||
return nacl_1.default.box.open(message, nonce, pub, this.seed); | ||
} | ||
@@ -142,0 +142,0 @@ } |
@@ -23,3 +23,3 @@ "use strict"; | ||
const nkeys_1 = require("./nkeys"); | ||
const tweetnacl_1 = __importDefault(require("tweetnacl")); | ||
const nacl_1 = __importDefault(require("./nacl")); | ||
/** | ||
@@ -51,3 +51,3 @@ * @ignore | ||
const sd = codec_1.Codec.decodeSeed(this.seed); | ||
const kp = tweetnacl_1.default.sign.keyPair.fromSeed(this.getRawSeed()); | ||
const kp = nacl_1.default.sign.keyPair.fromSeed(this.getRawSeed()); | ||
const buf = codec_1.Codec.encode(sd.prefix, kp.publicKey); | ||
@@ -60,3 +60,3 @@ return new TextDecoder().decode(buf); | ||
} | ||
const kp = tweetnacl_1.default.sign.keyPair.fromSeed(this.getRawSeed()); | ||
const kp = nacl_1.default.sign.keyPair.fromSeed(this.getRawSeed()); | ||
return codec_1.Codec.encode(nkeys_1.Prefix.Private, kp.secretKey); | ||
@@ -68,4 +68,4 @@ } | ||
} | ||
const kp = tweetnacl_1.default.sign.keyPair.fromSeed(this.getRawSeed()); | ||
return tweetnacl_1.default.sign.detached(input, kp.secretKey); | ||
const kp = nacl_1.default.sign.keyPair.fromSeed(this.getRawSeed()); | ||
return nacl_1.default.sign.detached(input, kp.secretKey); | ||
} | ||
@@ -76,4 +76,4 @@ verify(input, sig) { | ||
} | ||
const kp = tweetnacl_1.default.sign.keyPair.fromSeed(this.getRawSeed()); | ||
return tweetnacl_1.default.sign.detached.verify(input, sig, kp.publicKey); | ||
const kp = nacl_1.default.sign.keyPair.fromSeed(this.getRawSeed()); | ||
return nacl_1.default.sign.detached.verify(input, sig, kp.publicKey); | ||
} | ||
@@ -80,0 +80,0 @@ clear() { |
@@ -35,3 +35,3 @@ "use strict"; | ||
const curve_1 = require("./curve"); | ||
const tweetnacl_1 = __importDefault(require("tweetnacl")); | ||
const nacl_1 = __importDefault(require("./nacl")); | ||
/** | ||
@@ -42,3 +42,3 @@ * @ignore | ||
const len = prefix === Prefix.Curve ? curve_1.curveKeyLen : 32; | ||
const rawSeed = tweetnacl_1.default.randomBytes(len); | ||
const rawSeed = nacl_1.default.randomBytes(len); | ||
const str = codec_1.Codec.encodeSeed(prefix, new Uint8Array(rawSeed)); | ||
@@ -45,0 +45,0 @@ return prefix === Prefix.Curve |
@@ -23,3 +23,3 @@ "use strict"; | ||
const nkeys_1 = require("./nkeys"); | ||
const tweetnacl_1 = __importDefault(require("tweetnacl")); | ||
const nacl_1 = __importDefault(require("./nacl")); | ||
/** | ||
@@ -62,3 +62,3 @@ * @ignore | ||
const buf = codec_1.Codec._decode(this.publicKey); | ||
return tweetnacl_1.default.sign.detached.verify(input, sig, buf.slice(1)); | ||
return nacl_1.default.sign.detached.verify(input, sig, buf.slice(1)); | ||
} | ||
@@ -65,0 +65,0 @@ clear() { |
@@ -1,1 +0,1 @@ | ||
export declare const version = "2.0.0-1"; | ||
export declare const version = "2.0.0-2"; |
@@ -5,3 +5,3 @@ "use strict"; | ||
// this file is autogenerated - do not edit | ||
exports.version = "2.0.0-1"; | ||
exports.version = "2.0.0-2"; | ||
//# sourceMappingURL=version.js.map |
{ | ||
"name": "@nats-io/nkeys", | ||
"version": "2.0.0-1", | ||
"version": "2.0.0-2", | ||
"description": "A public-key signature system based on Ed25519 for the NATS ecosystem in javascript", | ||
@@ -5,0 +5,0 @@ "main": "lib/mod.js", |
@@ -13,4 +13,6 @@ # nkeys.js | ||
With the 2.0.0 release, the libraries changed npm `nkeys.js` to | ||
`@nats-io/nkeys`. | ||
> [!IMPORTANT] | ||
> | ||
> With the 2.0.0 release, the library changed module name from `nkeys.js` to | ||
> `@nats-io/nkeys`. | ||
@@ -26,3 +28,3 @@ The nkeys.js library works in Deno, Node.js, Bun, and the browser! | ||
```bash | ||
deno add @nats-io/nkeys | ||
deno add jsr:@nats-io/nkeys | ||
``` | ||
@@ -37,3 +39,3 @@ | ||
```bash | ||
npm install nkeys.js | ||
npm install @nats-io/nkeys | ||
``` | ||
@@ -47,4 +49,4 @@ | ||
On your browser projects copy `node_modules/nkeys.js/nkeys.mjs` to your document | ||
root, and then | ||
On your browser use the jsr or npn registry that is compatible with your build | ||
workflow | ||
@@ -51,0 +53,0 @@ ```javascript |
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
125
106520
1656