updated for acme-v2
This commit is contained in:
parent
09593f3778
commit
93096c6ebd
22
README.md
22
README.md
|
@ -1,21 +1,8 @@
|
||||||
<!-- BANNER_TPL_BEGIN -->
|
|
||||||
|
|
||||||
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:
|
|
||||||
|
|
||||||
<a href="mailto:jobs@daplie.com">jobs@daplie.com</a> | [Invest in Daplie on Wefunder](https://daplie.com/invest/) | [Pre-order Cloud](https://daplie.com/preorder/), The World's First Home Server for Everyone
|
|
||||||
|
|
||||||
<!-- BANNER_TPL_END -->
|
|
||||||
|
|
||||||
# rsa-compat.js
|
# 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
|
In order to provide a module that "just works" everywhere, we mix and match methods
|
||||||
from `node.js` core, `ursa`, `forge`, and others.
|
from `node.js` core, `ursa`, `forge`, and others.
|
||||||
|
@ -110,7 +97,8 @@ API
|
||||||
* `RSA.exportPublicPem(keypair)`
|
* `RSA.exportPublicPem(keypair)`
|
||||||
* `RSA.exportPrivateJwk(keypair)`
|
* `RSA.exportPrivateJwk(keypair)`
|
||||||
* `RSA.exportPublicJwk(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.generateCsrPem(keypair, names)`
|
||||||
* `RSA.generateCsrDerWeb64(keypair, names)`
|
* `RSA.generateCsrDerWeb64(keypair, names)`
|
||||||
|
|
||||||
|
|
25
node.js
25
node.js
|
@ -158,15 +158,29 @@ function create(deps) {
|
||||||
};
|
};
|
||||||
|
|
||||||
RSA.signJws = RSA.generateJws = RSA.generateSignatureJws = RSA.generateSignatureJwk =
|
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.import(keypair);
|
||||||
keypair = RSA._internal.importForge(keypair);
|
keypair = RSA._internal.importForge(keypair);
|
||||||
keypair.publicKeyJwk = RSA.exportPublicJwk(keypair);
|
keypair.publicKeyJwk = RSA.exportPublicJwk(keypair);
|
||||||
|
|
||||||
// Compute JWS signature
|
// Compute JWS signature
|
||||||
var protectedHeader = "";
|
var protectedHeader = "";
|
||||||
if (nonce) {
|
if (protect) {
|
||||||
protectedHeader = JSON.stringify({nonce: nonce});
|
protectedHeader = JSON.stringify(protect); // { alg: prot.alg, nonce: prot.nonce, url: prot.url });
|
||||||
}
|
}
|
||||||
var protected64 = RSA.utils.toWebsafeBase64(new Buffer(protectedHeader).toString('base64'));
|
var protected64 = RSA.utils.toWebsafeBase64(new Buffer(protectedHeader).toString('base64'));
|
||||||
var payload64 = RSA.utils.toWebsafeBase64(payload.toString('base64'));
|
var payload64 = RSA.utils.toWebsafeBase64(payload.toString('base64'));
|
||||||
|
@ -181,10 +195,7 @@ function create(deps) {
|
||||||
}
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
header: {
|
header: header
|
||||||
alg: "RS256"
|
|
||||||
, jwk: keypair.publicKeyJwk
|
|
||||||
}
|
|
||||||
, protected: protected64
|
, protected: protected64
|
||||||
, payload: payload64
|
, payload: payload64
|
||||||
, signature: sig64
|
, signature: sig64
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "rsa-compat",
|
"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",
|
"description": "RSA utils that work on Windows, Mac, and Linux with or without C compiler",
|
||||||
"main": "node.js",
|
"main": "node.js",
|
||||||
"bin": {
|
"bin": {
|
||||||
|
|
Loading…
Reference in New Issue