From 93096c6ebda262ff543b6aa4da0aa65e85edfd3b Mon Sep 17 00:00:00 2001 From: AJ ONeal Date: Tue, 20 Mar 2018 21:33:26 -0600 Subject: [PATCH] updated for acme-v2 --- README.md | 22 +++++----------------- node.js | 25 ++++++++++++++++++------- package.json | 2 +- 3 files changed, 24 insertions(+), 25 deletions(-) diff --git a/README.md b/README.md index 17aecb5..0caf41d 100644 --- a/README.md +++ b/README.md @@ -1,21 +1,8 @@ - - -About Daplie: We're taking back the Internet! --------------- - -Down with Google, Apple, and Facebook! - -We're re-decentralizing the web and making it read-write again - one home cloud system at a time. - -Tired of serving the Empire? Come join the Rebel Alliance: - -jobs@daplie.com | [Invest in Daplie on Wefunder](https://daplie.com/invest/) | [Pre-order Cloud](https://daplie.com/preorder/), The World's First Home Server for Everyone - - - # rsa-compat.js -JavaScript RSA utils that work on Windows, Mac, and Linux, with or without C compiler (x64, x86, and ARM) +| Sponsored by [ppl](https://ppl.family). Created at [Daplie](https://dapliefounder.com). + +JavaScript RSA utils that work on Windows, Mac, and Linux with or without C compiler In order to provide a module that "just works" everywhere, we mix and match methods from `node.js` core, `ursa`, `forge`, and others. @@ -110,7 +97,8 @@ API * `RSA.exportPublicPem(keypair)` * `RSA.exportPrivateJwk(keypair)` * `RSA.exportPublicJwk(keypair)` -* `RSA.signJws(keypair, payload, nonce)` +* `RSA.signJws(keypair, header, protect, payload)` + * (deprecated `RSA.signJws(keypair, payload, nonce)`) * `RSA.generateCsrPem(keypair, names)` * `RSA.generateCsrDerWeb64(keypair, names)` diff --git a/node.js b/node.js index d0b660d..d5415f1 100644 --- a/node.js +++ b/node.js @@ -158,15 +158,29 @@ function create(deps) { }; RSA.signJws = RSA.generateJws = RSA.generateSignatureJws = RSA.generateSignatureJwk = - function (keypair, payload, nonce) { + function (keypair, header, protect, payload) { + // old (keypair, payload, nonce) + var nonce; + if ('string' === typeof protect || ('undefined' === typeof protect && 'undefined' === typeof payload)) { + console.warn("deprecation notice: new signature for signJws(keypair, header, protect, payload)"); + // old API + payload = header; + nonce = protect; + protect = undefined; + header = { + alg: "RS256" + , jwk: keypair.publicKeyJwk + }; + protect = { nonce: nonce }; + } keypair = RSA._internal.import(keypair); keypair = RSA._internal.importForge(keypair); keypair.publicKeyJwk = RSA.exportPublicJwk(keypair); // Compute JWS signature var protectedHeader = ""; - if (nonce) { - protectedHeader = JSON.stringify({nonce: nonce}); + if (protect) { + protectedHeader = JSON.stringify(protect); // { alg: prot.alg, nonce: prot.nonce, url: prot.url }); } var protected64 = RSA.utils.toWebsafeBase64(new Buffer(protectedHeader).toString('base64')); var payload64 = RSA.utils.toWebsafeBase64(payload.toString('base64')); @@ -181,10 +195,7 @@ function create(deps) { } return { - header: { - alg: "RS256" - , jwk: keypair.publicKeyJwk - } + header: header , protected: protected64 , payload: payload64 , signature: sig64 diff --git a/package.json b/package.json index 6177f7e..e3a1c0f 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "rsa-compat", - "version": "1.2.7", + "version": "1.3.0", "description": "RSA utils that work on Windows, Mac, and Linux with or without C compiler", "main": "node.js", "bin": {