Skip to content

Commit b2da60e

Browse files
authored
Rename files in preparation for TS migration (#343)
1 parent 6f5280e commit b2da60e

32 files changed

+871
-453
lines changed

.eslintrc.json

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,31 @@
66
"es2020": true
77
},
88
"root": true,
9-
"extends": ["eslint:recommended", "prettier"],
9+
"parser": "@typescript-eslint/parser",
10+
"plugins": ["@typescript-eslint", "deprecation"],
11+
"parserOptions": {
12+
"project": "./tsconfig.eslint.json"
13+
},
14+
"extends": [
15+
"eslint:recommended",
16+
"plugin:@typescript-eslint/eslint-recommended",
17+
"plugin:@typescript-eslint/recommended",
18+
"prettier"
19+
],
1020
"rules": {
1121
"no-console": "error",
12-
"no-unused-vars": "error",
22+
"no-unused-vars": "warn",
1323
"no-prototype-builtins": "error",
1424
"one-var": ["error", "never"],
1525
"no-duplicate-imports": "error",
1626
"no-use-before-define": "error",
1727
"curly": "error",
1828
"eqeqeq": ["error", "smart"],
1929
"no-var": "error",
20-
"prefer-const": "error"
30+
"prefer-const": "error",
31+
"deprecation/deprecation": "warn",
32+
"@typescript-eslint/no-non-null-assertion": "error",
33+
"@typescript-eslint/no-unused-vars": "warn",
34+
"@typescript-eslint/no-this-alias": "warn"
2135
}
2236
}

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,5 +51,5 @@ jobs:
5151
with:
5252
node-version: "lts/*"
5353
- run: |
54-
npm ci
54+
npm ci
5555
npm run lint

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
lib/
12
node_modules/
23
p.js
34
p.txt

.mocharc.json

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
{
22
"diff": true,
3-
"extension": "spec.js",
3+
"extension": "spec.ts",
44
"package": "./package.json",
55
"recursive": true,
66
"reporter": "spec",
7-
"require": ["choma"],
8-
"spec": "test/*.js",
9-
"watch-files": "test/*.js"
7+
"require": ["choma", "ts-node/register"],
8+
"spec": "test/*.spec.ts",
9+
"watch-files": "test/*.spec.ts",
10+
"colors": true
1011
}

.nycrc.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
{
2+
"extends": "@istanbuljs/nyc-config-typescript",
23
"all": true,
34
"check-coverage": false,
45
"reporter": ["lcov", "text"],
5-
"include": ["lib/**"]
6+
"include": ["src"]
67
}

.prettierignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
# Ignore artifacts:
2+
lib
23
node_modules
34
package-lock.json
45
.eslintcache

README.md

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ var SignedXml = require("xml-crypto").SignedXml,
7777
var xml = "<library>" + "<book>" + "<name>Harry Potter</name>" + "</book>" + "</library>";
7878

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

331-
SignedXml.CanonicalizationAlgorithms["http://MyTransformation"] = MyTransformation;
332-
SignedXml.CanonicalizationAlgorithms["http://MyCanonicalization"] = MyCanonicalization;
333-
SignedXml.HashAlgorithms["http://myDigestAlgorithm"] = MyDigest;
334-
SignedXml.SignatureAlgorithms["http://mySigningAlgorithm"] = MySignatureAlgorithm;
331+
signedXml.CanonicalizationAlgorithms["http://MyTransformation"] = MyTransformation;
332+
signedXml.CanonicalizationAlgorithms["http://MyCanonicalization"] = MyCanonicalization;
333+
signedXml.HashAlgorithms["http://myDigestAlgorithm"] = MyDigest;
334+
signedXml.SignatureAlgorithms["http://mySigningAlgorithm"] = MySignatureAlgorithm;
335335
```
336336

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

349349
var sig = new SignedXml(options);
350350

351-
sig.addReference(
352-
"//*[local-name(.)='x']",
353-
["http://MyTransformation"],
354-
"http://myDigestAlgorithm"
355-
);
351+
sig.addReference({
352+
xpath: "//*[local-name(.)='x']",
353+
transforms: ["http://MyTransformation"],
354+
digestAlgorithm: "http://myDigestAlgorithm",
355+
});
356356

357-
sig.addReference(xpath);
357+
sig.addReference({ xpath });
358358
sig.computeSignature(xml);
359359
fs.writeFileSync(dest, sig.getSignedXml());
360360
}
@@ -437,7 +437,7 @@ var SignedXml = require("xml-crypto").SignedXml,
437437
var xml = "<library>" + "<book>" + "<name>Harry Potter</name>" + "</book>" + "</library>";
438438

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

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

0 commit comments

Comments
 (0)