Skip to content

Commit

Permalink
Rename files in preparation for TS migration (#343)
Browse files Browse the repository at this point in the history
  • Loading branch information
cjbarth authored Jul 14, 2023
1 parent 6f5280e commit b2da60e
Show file tree
Hide file tree
Showing 32 changed files with 871 additions and 453 deletions.
20 changes: 17 additions & 3 deletions .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,31 @@
"es2020": true
},
"root": true,
"extends": ["eslint:recommended", "prettier"],
"parser": "@typescript-eslint/parser",
"plugins": ["@typescript-eslint", "deprecation"],
"parserOptions": {
"project": "./tsconfig.eslint.json"
},
"extends": [
"eslint:recommended",
"plugin:@typescript-eslint/eslint-recommended",
"plugin:@typescript-eslint/recommended",
"prettier"
],
"rules": {
"no-console": "error",
"no-unused-vars": "error",
"no-unused-vars": "warn",
"no-prototype-builtins": "error",
"one-var": ["error", "never"],
"no-duplicate-imports": "error",
"no-use-before-define": "error",
"curly": "error",
"eqeqeq": ["error", "smart"],
"no-var": "error",
"prefer-const": "error"
"prefer-const": "error",
"deprecation/deprecation": "warn",
"@typescript-eslint/no-non-null-assertion": "error",
"@typescript-eslint/no-unused-vars": "warn",
"@typescript-eslint/no-this-alias": "warn"
}
}
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,5 +51,5 @@ jobs:
with:
node-version: "lts/*"
- run: |
npm ci
npm ci
npm run lint
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
lib/
node_modules/
p.js
p.txt
Expand Down
9 changes: 5 additions & 4 deletions .mocharc.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
{
"diff": true,
"extension": "spec.js",
"extension": "spec.ts",
"package": "./package.json",
"recursive": true,
"reporter": "spec",
"require": ["choma"],
"spec": "test/*.js",
"watch-files": "test/*.js"
"require": ["choma", "ts-node/register"],
"spec": "test/*.spec.ts",
"watch-files": "test/*.spec.ts",
"colors": true
}
3 changes: 2 additions & 1 deletion .nycrc.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"extends": "@istanbuljs/nyc-config-typescript",
"all": true,
"check-coverage": false,
"reporter": ["lcov", "text"],
"include": ["lib/**"]
"include": ["src"]
}
1 change: 1 addition & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# Ignore artifacts:
lib
node_modules
package-lock.json
.eslintcache
Expand Down
26 changes: 13 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ var SignedXml = require("xml-crypto").SignedXml,
var xml = "<library>" + "<book>" + "<name>Harry Potter</name>" + "</book>" + "</library>";

var sig = new SignedXml({ privateKey: fs.readFileSync("client.pem") });
sig.addReference("//*[local-name(.)='book']");
sig.addReference({ xpath: "//*[local-name(.)='book']" });
sig.computeSignature(xml);
fs.writeFileSync("signed.xml", sig.getSignedXml());
```
Expand Down Expand Up @@ -328,10 +328,10 @@ Now you need to register the new algorithms:
```javascript
/*register all the custom algorithms*/

SignedXml.CanonicalizationAlgorithms["http://MyTransformation"] = MyTransformation;
SignedXml.CanonicalizationAlgorithms["http://MyCanonicalization"] = MyCanonicalization;
SignedXml.HashAlgorithms["http://myDigestAlgorithm"] = MyDigest;
SignedXml.SignatureAlgorithms["http://mySigningAlgorithm"] = MySignatureAlgorithm;
signedXml.CanonicalizationAlgorithms["http://MyTransformation"] = MyTransformation;
signedXml.CanonicalizationAlgorithms["http://MyCanonicalization"] = MyCanonicalization;
signedXml.HashAlgorithms["http://myDigestAlgorithm"] = MyDigest;
signedXml.SignatureAlgorithms["http://mySigningAlgorithm"] = MySignatureAlgorithm;
```

Now do the signing. Note how we configure the signature to use the above algorithms:
Expand All @@ -348,13 +348,13 @@ function signXml(xml, xpath, key, dest) {

var sig = new SignedXml(options);

sig.addReference(
"//*[local-name(.)='x']",
["http://MyTransformation"],
"http://myDigestAlgorithm"
);
sig.addReference({
xpath: "//*[local-name(.)='x']",
transforms: ["http://MyTransformation"],
digestAlgorithm: "http://myDigestAlgorithm",
});

sig.addReference(xpath);
sig.addReference({ xpath });
sig.computeSignature(xml);
fs.writeFileSync(dest, sig.getSignedXml());
}
Expand Down Expand Up @@ -437,7 +437,7 @@ var SignedXml = require("xml-crypto").SignedXml,
var xml = "<library>" + "<book>" + "<name>Harry Potter</name>" + "</book>" + "</library>";

var sig = new SignedXml({ privateKey: fs.readFileSync("client.pem") });
sig.addReference("//*[local-name(.)='book']");
sig.addReference({ xpath: "//*[local-name(.)='book']" });
sig.computeSignature(xml, {
prefix: "ds",
});
Expand All @@ -460,7 +460,7 @@ var SignedXml = require("xml-crypto").SignedXml,
var xml = "<library>" + "<book>" + "<name>Harry Potter</name>" + "</book>" + "</library>";

var sig = new SignedXml({ privateKey: fs.readFileSync("client.pem") });
sig.addReference("//*[local-name(.)='book']");
sig.addReference({ xpath: "//*[local-name(.)='book']" });
sig.computeSignature(xml, {
location: { reference: "//*[local-name(.)='book']", action: "after" }, //This will place the signature after the book element
});
Expand Down
Loading

0 comments on commit b2da60e

Please sign in to comment.