@nats-io/nkeys
Advanced tools
Comparing version 1.2.0-7 to 1.2.0-8
{ | ||
"name": "@nats-io/nkeys", | ||
"version": "1.2.0-7", | ||
"version": "1.2.0-8", | ||
"exports": { | ||
".": "./modules/esm/mod.ts" | ||
".": "./src/mod.ts" | ||
}, | ||
@@ -20,3 +20,6 @@ "test": { | ||
] | ||
}, | ||
"imports": { | ||
"tweetnacl": "npm:tweetnacl@1.0.3" | ||
} | ||
} |
@@ -19,3 +19,3 @@ "use strict"; | ||
const assert = require("node:assert"); | ||
const { createAccount, createOperator, createUser, fromPublic, fromSeed, decode, encode, NKeysErrorCode, } = require("../lib/index"); | ||
const { createAccount, createOperator, createUser, fromPublic, fromSeed, decode, encode, NKeysErrorCode, } = require("../lib/mod"); | ||
const { createCluster, createServer, Prefix, } = require("../lib/nkeys"); | ||
@@ -22,0 +22,0 @@ const { Codec } = require("../lib/codec"); |
@@ -101,3 +101,3 @@ "use strict"; | ||
catch (ex) { | ||
throw new nkeys_1.NKeysError(nkeys_1.NKeysErrorCode.InvalidEncoding, ex); | ||
throw new nkeys_1.NKeysError(nkeys_1.NKeysErrorCode.InvalidEncoding, { cause: ex }); | ||
} | ||
@@ -104,0 +104,0 @@ const checkOffset = raw.byteLength - 2; |
@@ -16,6 +16,9 @@ "use strict"; | ||
*/ | ||
var __importDefault = (this && this.__importDefault) || function (mod) { | ||
return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.CurveKP = exports.curveNonceLen = exports.curveKeyLen = void 0; | ||
const nkeys_1 = require("./nkeys"); | ||
const helper_1 = require("./helper"); | ||
const tweetnacl_1 = __importDefault(require("tweetnacl")); | ||
const codec_1 = require("./codec"); | ||
@@ -52,3 +55,3 @@ const mod_1 = require("./mod"); | ||
} | ||
const pub = (0, helper_1.getEd25519Helper)().scalarBaseMultiply(this.seed); | ||
const pub = tweetnacl_1.default.scalarMult.base(this.seed); | ||
const buf = codec_1.Codec.encode(mod_1.Prefix.Curve, pub); | ||
@@ -89,3 +92,3 @@ return new TextDecoder().decode(buf); | ||
catch (ex) { | ||
throw new nkeys_1.NKeysError(nkeys_1.NKeysErrorCode.InvalidRecipient, ex); | ||
throw new nkeys_1.NKeysError(nkeys_1.NKeysErrorCode.InvalidRecipient, { cause: ex }); | ||
} | ||
@@ -98,3 +101,3 @@ } | ||
if (!nonce) { | ||
nonce = (0, helper_1.getEd25519Helper)().randomBytes(exports.curveNonceLen); | ||
nonce = tweetnacl_1.default.randomBytes(exports.curveNonceLen); | ||
} | ||
@@ -107,3 +110,3 @@ const pub = this.decodePubCurveKey(recipient); | ||
// this is only the encoded payload | ||
const encrypted = (0, helper_1.getEd25519Helper)().seal(message, nonce, pub, this.seed); | ||
const encrypted = tweetnacl_1.default.box(message, nonce, pub, this.seed); | ||
// the full message is the header+nonce+encrypted | ||
@@ -134,3 +137,3 @@ const fullMessage = new Uint8Array(out.length + encrypted.length); | ||
message = message.slice(exports.curveNonceLen); | ||
return (0, helper_1.getEd25519Helper)().open(message, nonce, pub, this.seed); | ||
return tweetnacl_1.default.box.open(message, nonce, pub, this.seed); | ||
} | ||
@@ -137,0 +140,0 @@ } |
@@ -20,10 +20,5 @@ /** | ||
} | ||
export {}; | ||
/** | ||
* @ignore | ||
*/ | ||
export declare function setEd25519Helper(lib: Ed25519Helper): void; | ||
/** | ||
* @ignore | ||
*/ | ||
export declare function getEd25519Helper(): Ed25519Helper; | ||
export {}; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.setEd25519Helper = setEd25519Helper; | ||
exports.getEd25519Helper = getEd25519Helper; | ||
/** | ||
* @ignore | ||
*/ | ||
let helper; | ||
/** | ||
* @ignore | ||
*/ | ||
function setEd25519Helper(lib) { | ||
helper = lib; | ||
} | ||
/** | ||
* @ignore | ||
*/ | ||
function getEd25519Helper() { | ||
return helper; | ||
} | ||
//# sourceMappingURL=helper.js.map |
@@ -16,2 +16,5 @@ "use strict"; | ||
*/ | ||
var __importDefault = (this && this.__importDefault) || function (mod) { | ||
return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
@@ -21,3 +24,3 @@ exports.KP = void 0; | ||
const nkeys_1 = require("./nkeys"); | ||
const helper_1 = require("./helper"); | ||
const tweetnacl_1 = __importDefault(require("tweetnacl")); | ||
/** | ||
@@ -49,3 +52,3 @@ * @ignore | ||
const sd = codec_1.Codec.decodeSeed(this.seed); | ||
const kp = (0, helper_1.getEd25519Helper)().fromSeed(this.getRawSeed()); | ||
const kp = tweetnacl_1.default.sign.keyPair.fromSeed(this.getRawSeed()); | ||
const buf = codec_1.Codec.encode(sd.prefix, kp.publicKey); | ||
@@ -58,3 +61,3 @@ return new TextDecoder().decode(buf); | ||
} | ||
const kp = (0, helper_1.getEd25519Helper)().fromSeed(this.getRawSeed()); | ||
const kp = tweetnacl_1.default.sign.keyPair.fromSeed(this.getRawSeed()); | ||
return codec_1.Codec.encode(nkeys_1.Prefix.Private, kp.secretKey); | ||
@@ -66,4 +69,4 @@ } | ||
} | ||
const kp = (0, helper_1.getEd25519Helper)().fromSeed(this.getRawSeed()); | ||
return (0, helper_1.getEd25519Helper)().sign(input, kp.secretKey); | ||
const kp = tweetnacl_1.default.sign.keyPair.fromSeed(this.getRawSeed()); | ||
return tweetnacl_1.default.sign.detached(input, kp.secretKey); | ||
} | ||
@@ -74,4 +77,4 @@ verify(input, sig) { | ||
} | ||
const kp = (0, helper_1.getEd25519Helper)().fromSeed(this.getRawSeed()); | ||
return (0, helper_1.getEd25519Helper)().verify(input, sig, kp.publicKey); | ||
const kp = tweetnacl_1.default.sign.keyPair.fromSeed(this.getRawSeed()); | ||
return tweetnacl_1.default.sign.detached.verify(input, sig, kp.publicKey); | ||
} | ||
@@ -78,0 +81,0 @@ clear() { |
@@ -137,13 +137,4 @@ /** | ||
export declare class NKeysError extends Error { | ||
name: string; | ||
code: string; | ||
chainedError?: Error; | ||
/** | ||
* @param {NKeysErrorCode} code | ||
* @param {Error} [chainedError] | ||
* @constructor | ||
* | ||
* @api private | ||
*/ | ||
constructor(code: NKeysErrorCode, chainedError?: Error); | ||
constructor(code: NKeysErrorCode, options?: ErrorOptions); | ||
} |
"use strict"; | ||
var __importDefault = (this && this.__importDefault) || function (mod) { | ||
return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
@@ -31,4 +34,4 @@ exports.NKeysError = exports.NKeysErrorCode = exports.Prefixes = exports.Prefix = void 0; | ||
const codec_1 = require("./codec"); | ||
const helper_1 = require("./helper"); | ||
const curve_1 = require("./curve"); | ||
const tweetnacl_1 = __importDefault(require("tweetnacl")); | ||
/** | ||
@@ -39,3 +42,3 @@ * @ignore | ||
const len = prefix === Prefix.Curve ? curve_1.curveKeyLen : 32; | ||
const rawSeed = (0, helper_1.getEd25519Helper)().randomBytes(len); | ||
const rawSeed = tweetnacl_1.default.randomBytes(len); | ||
const str = codec_1.Codec.encodeSeed(prefix, new Uint8Array(rawSeed)); | ||
@@ -216,17 +219,6 @@ return prefix === Prefix.Curve | ||
class NKeysError extends Error { | ||
name; | ||
code; | ||
chainedError; | ||
/** | ||
* @param {NKeysErrorCode} code | ||
* @param {Error} [chainedError] | ||
* @constructor | ||
* | ||
* @api private | ||
*/ | ||
constructor(code, chainedError) { | ||
super(code); | ||
this.name = "NKeysError"; | ||
constructor(code, options) { | ||
super(code, options); | ||
this.code = code; | ||
this.chainedError = chainedError; | ||
} | ||
@@ -233,0 +225,0 @@ } |
@@ -16,2 +16,5 @@ "use strict"; | ||
*/ | ||
var __importDefault = (this && this.__importDefault) || function (mod) { | ||
return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
@@ -21,3 +24,3 @@ exports.PublicKey = void 0; | ||
const nkeys_1 = require("./nkeys"); | ||
const helper_1 = require("./helper"); | ||
const tweetnacl_1 = __importDefault(require("tweetnacl")); | ||
/** | ||
@@ -60,3 +63,3 @@ * @ignore | ||
const buf = codec_1.Codec._decode(this.publicKey); | ||
return (0, helper_1.getEd25519Helper)().verify(input, sig, buf.slice(1)); | ||
return tweetnacl_1.default.sign.detached.verify(input, sig, buf.slice(1)); | ||
} | ||
@@ -63,0 +66,0 @@ clear() { |
@@ -1,1 +0,1 @@ | ||
export declare const version = "1.2.0-7"; | ||
export declare const version = "1.2.0-8"; |
@@ -5,3 +5,3 @@ "use strict"; | ||
// this file is autogenerated - do not edit | ||
exports.version = "1.2.0-7"; | ||
exports.version = "1.2.0-8"; | ||
//# sourceMappingURL=version.js.map |
{ | ||
"name": "@nats-io/nkeys", | ||
"version": "1.2.0-7", | ||
"version": "1.2.0-8", | ||
"description": "A public-key signature system based on Ed25519 for the NATS ecosystem in javascript", | ||
"main": "lib/index.js", | ||
"types": "lib/index.d.ts", | ||
"main": "lib/mod.js", | ||
"types": "lib/mod.d.ts", | ||
"scripts": { | ||
@@ -11,6 +11,6 @@ "init": "mkdir -p build", | ||
"fmt": "deno fmt src/ examples/ modules/ test/ node_test/", | ||
"cjs": "deno run --allow-all bin/cjs-fix-imports.ts -o build/ src/ modules/cjs/ node_test/", | ||
"generate": "deno run -A bin/generate_version.ts && deno run -A ./bin/tweetnacl-esm.ts", | ||
"cjs": "deno run --allow-all bin/cjs-fix-imports.ts -o build/ src/ node_test/", | ||
"generate": "deno run -A bin/generate_version.ts", | ||
"stage": "npm run init && npm run generate && npm run cjs && tsc", | ||
"prepare": "npm run clean && npm run stage && npm run generate && deno bundle modules/esm/mod.ts nkeys.mjs", | ||
"prepare": "npm run clean && npm run stage && npm run generate", | ||
"test": "npm run clean && npm run prepare && node --test && deno test -A test/", | ||
@@ -38,3 +38,3 @@ "cover": "npm run clean && npm run prepare && deno test --coverage=coverage -A test/ && deno coverage ./coverage --lcov > ./coverage/out.lcov && genhtml -o ./coverage/html ./coverage/out.lcov && open ./coverage/html/index.html", | ||
"dependencies": { | ||
"tweetnacl": "1.0.3" | ||
"tweetnacl": "^1.0.3" | ||
}, | ||
@@ -41,0 +41,0 @@ "devDependencies": { |
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
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
118639
44
1669
Updatedtweetnacl@^1.0.3