@lindorm/rsa 0.1.0 → 0.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +16 -0
- package/dist/classes/RsaKit.d.ts +0 -1
- package/dist/classes/RsaKit.d.ts.map +1 -1
- package/dist/classes/RsaKit.js +9 -9
- package/dist/classes/RsaKit.js.map +1 -1
- package/dist/index.d.ts +0 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +0 -1
- package/dist/index.js.map +1 -1
- package/dist/types/index.d.ts +1 -3
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/index.js +1 -3
- package/dist/types/index.js.map +1 -1
- package/dist/types/rsa-kit.d.ts +18 -0
- package/dist/types/rsa-kit.d.ts.map +1 -0
- package/dist/types/{types.js → rsa-kit.js} +1 -1
- package/dist/types/rsa-kit.js.map +1 -0
- package/dist/utils/private/get-options.d.ts +6 -0
- package/dist/utils/private/get-options.d.ts.map +1 -0
- package/dist/utils/private/get-options.js +43 -0
- package/dist/utils/private/get-options.js.map +1 -0
- package/dist/utils/private/map-algorithm.d.ts +4 -0
- package/dist/utils/private/map-algorithm.d.ts.map +1 -0
- package/dist/utils/private/map-algorithm.js +15 -0
- package/dist/utils/private/map-algorithm.js.map +1 -0
- package/dist/utils/private/rsa-signature.d.ts +3 -3
- package/dist/utils/private/rsa-signature.d.ts.map +1 -1
- package/dist/utils/private/rsa-signature.js +13 -31
- package/dist/utils/private/rsa-signature.js.map +1 -1
- package/package.json +7 -4
- package/dist/enums/RsaAlgorithm.d.ts +0 -9
- package/dist/enums/RsaAlgorithm.d.ts.map +0 -1
- package/dist/enums/RsaAlgorithm.js +0 -13
- package/dist/enums/RsaAlgorithm.js.map +0 -1
- package/dist/enums/RsaFormat.d.ts +0 -6
- package/dist/enums/RsaFormat.d.ts.map +0 -1
- package/dist/enums/RsaFormat.js +0 -10
- package/dist/enums/RsaFormat.js.map +0 -1
- package/dist/enums/index.d.ts +0 -3
- package/dist/enums/index.d.ts.map +0 -1
- package/dist/enums/index.js +0 -19
- package/dist/enums/index.js.map +0 -1
- package/dist/types/rsa-signature-class.d.ts +0 -8
- package/dist/types/rsa-signature-class.d.ts.map +0 -1
- package/dist/types/rsa-signature-class.js +0 -3
- package/dist/types/rsa-signature-class.js.map +0 -1
- package/dist/types/rsa-signature.d.ts +0 -16
- package/dist/types/rsa-signature.d.ts.map +0 -1
- package/dist/types/rsa-signature.js +0 -3
- package/dist/types/rsa-signature.js.map +0 -1
- package/dist/types/types.d.ts +0 -3
- package/dist/types/types.d.ts.map +0 -1
- package/dist/types/types.js.map +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,22 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
## [0.1.2](https://github.com/lindorm-io/monorepo/compare/@lindorm/rsa@0.1.1...@lindorm/rsa@0.1.2) (2024-05-19)
|
|
7
|
+
|
|
8
|
+
### Bug Fixes
|
|
9
|
+
|
|
10
|
+
- align with kryptos changes ([344c4e2](https://github.com/lindorm-io/monorepo/commit/344c4e2fad07e66c91f7e0820bfc929c1f8ffcab))
|
|
11
|
+
- improve kryptos generate method ([9e7098d](https://github.com/lindorm-io/monorepo/commit/9e7098d4b219b11140e28e554ffd573204772249))
|
|
12
|
+
- simplify interfaces with kryptos metadata ([c4075d2](https://github.com/lindorm-io/monorepo/commit/c4075d2e133c2fe0a1fafa548da68db34b3407c6))
|
|
13
|
+
- use crypto constants ([2fc218e](https://github.com/lindorm-io/monorepo/commit/2fc218e8c279d23bdb386421a9896bbf9896e72b))
|
|
14
|
+
|
|
15
|
+
## [0.1.1](https://github.com/lindorm-io/monorepo/compare/@lindorm/rsa@0.1.0...@lindorm/rsa@0.1.1) (2024-05-12)
|
|
16
|
+
|
|
17
|
+
### Bug Fixes
|
|
18
|
+
|
|
19
|
+
- rename signature to hash ([e2a536e](https://github.com/lindorm-io/monorepo/commit/e2a536e712e81e61bb8c16c447a734a8aa67eca2))
|
|
20
|
+
- upgrade code style for better alignment ([2fc8205](https://github.com/lindorm-io/monorepo/commit/2fc82054fdce72d58a0a6b504643eaecddbb60fa))
|
|
21
|
+
|
|
6
22
|
# 0.1.0 (2024-05-11)
|
|
7
23
|
|
|
8
24
|
### Features
|
package/dist/classes/RsaKit.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RsaKit.d.ts","sourceRoot":"","sources":["../../src/classes/RsaKit.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"RsaKit.d.ts","sourceRoot":"","sources":["../../src/classes/RsaKit.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAOzC,qBAAa,MAAM;IACjB,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAe;IACtC,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAc;gBAEnB,OAAO,EAAE,aAAa;IAUlC,IAAI,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM;IAQ1B,MAAM,CAAC,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,OAAO;IAShD,MAAM,CAAC,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,IAAI;CAQrD"}
|
package/dist/classes/RsaKit.js
CHANGED
|
@@ -1,27 +1,28 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.RsaKit = void 0;
|
|
4
|
+
const kryptos_1 = require("@lindorm/kryptos");
|
|
5
|
+
const errors_1 = require("../errors");
|
|
4
6
|
const rsa_signature_1 = require("../utils/private/rsa-signature");
|
|
5
7
|
class RsaKit {
|
|
6
|
-
algorithm;
|
|
7
8
|
format;
|
|
8
9
|
kryptos;
|
|
9
10
|
constructor(options) {
|
|
10
|
-
this.
|
|
11
|
-
|
|
11
|
+
this.format = options.format ?? "base64";
|
|
12
|
+
if (!kryptos_1.Kryptos.isRsa(options.kryptos)) {
|
|
13
|
+
throw new errors_1.RsaError("Invalid Kryptos instance");
|
|
14
|
+
}
|
|
12
15
|
this.kryptos = options.kryptos;
|
|
13
16
|
}
|
|
14
17
|
sign(data) {
|
|
15
|
-
return (0, rsa_signature_1.
|
|
16
|
-
algorithm: this.algorithm,
|
|
18
|
+
return (0, rsa_signature_1._createRsaSignature)({
|
|
17
19
|
data,
|
|
18
20
|
format: this.format,
|
|
19
21
|
kryptos: this.kryptos,
|
|
20
22
|
});
|
|
21
23
|
}
|
|
22
24
|
verify(data, signature) {
|
|
23
|
-
return (0, rsa_signature_1.
|
|
24
|
-
algorithm: this.algorithm,
|
|
25
|
+
return (0, rsa_signature_1._verifyRsaSignature)({
|
|
25
26
|
data,
|
|
26
27
|
format: this.format,
|
|
27
28
|
kryptos: this.kryptos,
|
|
@@ -29,8 +30,7 @@ class RsaKit {
|
|
|
29
30
|
});
|
|
30
31
|
}
|
|
31
32
|
assert(data, signature) {
|
|
32
|
-
return (0, rsa_signature_1.
|
|
33
|
-
algorithm: this.algorithm,
|
|
33
|
+
return (0, rsa_signature_1._assertRsaSignature)({
|
|
34
34
|
data,
|
|
35
35
|
format: this.format,
|
|
36
36
|
kryptos: this.kryptos,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RsaKit.js","sourceRoot":"","sources":["../../src/classes/RsaKit.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"RsaKit.js","sourceRoot":"","sources":["../../src/classes/RsaKit.ts"],"names":[],"mappings":";;;AAAA,8CAAwD;AAExD,sCAAqC;AAErC,kEAIwC;AAExC,MAAa,MAAM;IACA,MAAM,CAAe;IACrB,OAAO,CAAc;IAEtC,YAAmB,OAAsB;QACvC,IAAI,CAAC,MAAM,GAAG,OAAO,CAAC,MAAM,IAAI,QAAQ,CAAC;QAEzC,IAAI,CAAC,iBAAO,CAAC,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC;YACpC,MAAM,IAAI,iBAAQ,CAAC,0BAA0B,CAAC,CAAC;QACjD,CAAC;QAED,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC;IACjC,CAAC;IAEM,IAAI,CAAC,IAAY;QACtB,OAAO,IAAA,mCAAmB,EAAC;YACzB,IAAI;YACJ,MAAM,EAAE,IAAI,CAAC,MAAM;YACnB,OAAO,EAAE,IAAI,CAAC,OAAO;SACtB,CAAC,CAAC;IACL,CAAC;IAEM,MAAM,CAAC,IAAY,EAAE,SAAiB;QAC3C,OAAO,IAAA,mCAAmB,EAAC;YACzB,IAAI;YACJ,MAAM,EAAE,IAAI,CAAC,MAAM;YACnB,OAAO,EAAE,IAAI,CAAC,OAAO;YACrB,SAAS;SACV,CAAC,CAAC;IACL,CAAC;IAEM,MAAM,CAAC,IAAY,EAAE,SAAiB;QAC3C,OAAO,IAAA,mCAAmB,EAAC;YACzB,IAAI;YACJ,MAAM,EAAE,IAAI,CAAC,MAAM;YACnB,OAAO,EAAE,IAAI,CAAC,OAAO;YACrB,SAAS;SACV,CAAC,CAAC;IACL,CAAC;CACF;AAvCD,wBAuCC"}
|
package/dist/index.d.ts
CHANGED
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAC;AAC1B,cAAc,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAC;AAC1B,cAAc,UAAU,CAAC;AACzB,cAAc,SAAS,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -15,7 +15,6 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
17
|
__exportStar(require("./classes"), exports);
|
|
18
|
-
__exportStar(require("./enums"), exports);
|
|
19
18
|
__exportStar(require("./errors"), exports);
|
|
20
19
|
__exportStar(require("./types"), exports);
|
|
21
20
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,4CAA0B;AAC1B,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,4CAA0B;AAC1B,2CAAyB;AACzB,0CAAwB"}
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAAA,cAAc,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAC"}
|
package/dist/types/index.js
CHANGED
|
@@ -14,7 +14,5 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./rsa-
|
|
18
|
-
__exportStar(require("./rsa-signature-class"), exports);
|
|
19
|
-
__exportStar(require("./types"), exports);
|
|
17
|
+
__exportStar(require("./rsa-kit"), exports);
|
|
20
18
|
//# sourceMappingURL=index.js.map
|
package/dist/types/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,4CAA0B"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { IKryptos, IKryptosRsa } from "@lindorm/kryptos";
|
|
2
|
+
import { BufferFormat } from "@lindorm/types";
|
|
3
|
+
export type CreateRsaSignatureOptions = {
|
|
4
|
+
data: string;
|
|
5
|
+
format: BufferFormat;
|
|
6
|
+
kryptos: IKryptosRsa;
|
|
7
|
+
};
|
|
8
|
+
export type VerifyRsaSignatureOptions = {
|
|
9
|
+
data: string;
|
|
10
|
+
format: BufferFormat;
|
|
11
|
+
kryptos: IKryptosRsa;
|
|
12
|
+
signature: string;
|
|
13
|
+
};
|
|
14
|
+
export type RsaKitOptions = {
|
|
15
|
+
format?: BufferFormat;
|
|
16
|
+
kryptos: IKryptos;
|
|
17
|
+
};
|
|
18
|
+
//# sourceMappingURL=rsa-kit.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rsa-kit.d.ts","sourceRoot":"","sources":["../../src/types/rsa-kit.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AACzD,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAE9C,MAAM,MAAM,yBAAyB,GAAG;IACtC,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,YAAY,CAAC;IACrB,OAAO,EAAE,WAAW,CAAC;CACtB,CAAC;AAEF,MAAM,MAAM,yBAAyB,GAAG;IACtC,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,YAAY,CAAC;IACrB,OAAO,EAAE,WAAW,CAAC;IACrB,SAAS,EAAE,MAAM,CAAC;CACnB,CAAC;AAEF,MAAM,MAAM,aAAa,GAAG;IAC1B,MAAM,CAAC,EAAE,YAAY,CAAC;IACtB,OAAO,EAAE,QAAQ,CAAC;CACnB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rsa-kit.js","sourceRoot":"","sources":["../../src/types/rsa-kit.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import { IKryptosRsa } from "@lindorm/kryptos";
|
|
3
|
+
import { SignPrivateKeyInput, VerifyPublicKeyInput } from "crypto";
|
|
4
|
+
export declare const _getSignKey: (kryptos: IKryptosRsa) => SignPrivateKeyInput | string;
|
|
5
|
+
export declare const _getVerifyKey: (kryptos: IKryptosRsa) => VerifyPublicKeyInput | string;
|
|
6
|
+
//# sourceMappingURL=get-options.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-options.d.ts","sourceRoot":"","sources":["../../../src/utils/private/get-options.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAE/C,OAAO,EAAE,mBAAmB,EAAE,oBAAoB,EAAE,MAAM,QAAQ,CAAC;AAKnE,eAAO,MAAM,WAAW,YAAa,WAAW,KAAG,mBAAmB,GAAG,MAoBxE,CAAC;AAEF,eAAO,MAAM,aAAa,YAAa,WAAW,KAAG,oBAAoB,GAAG,MAoB3E,CAAC"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports._getVerifyKey = exports._getSignKey = void 0;
|
|
4
|
+
const constants_1 = require("constants");
|
|
5
|
+
const errors_1 = require("../../errors");
|
|
6
|
+
const RSA_PKCS1_SALT_LENGTH = 32;
|
|
7
|
+
const _getSignKey = (kryptos) => {
|
|
8
|
+
const { privateKey } = kryptos.export("pem");
|
|
9
|
+
if (!privateKey) {
|
|
10
|
+
throw new errors_1.RsaError("Private key not found in key set", { debug: { kryptos } });
|
|
11
|
+
}
|
|
12
|
+
if (kryptos.algorithm.startsWith("PS")) {
|
|
13
|
+
return {
|
|
14
|
+
key: privateKey,
|
|
15
|
+
padding: constants_1.RSA_PKCS1_PSS_PADDING,
|
|
16
|
+
saltLength: RSA_PKCS1_SALT_LENGTH,
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
if (kryptos.algorithm.startsWith("RS")) {
|
|
20
|
+
return privateKey;
|
|
21
|
+
}
|
|
22
|
+
throw new errors_1.RsaError("Unsupported RSA algorithm", { debug: { kryptos } });
|
|
23
|
+
};
|
|
24
|
+
exports._getSignKey = _getSignKey;
|
|
25
|
+
const _getVerifyKey = (kryptos) => {
|
|
26
|
+
const { publicKey } = kryptos.export("pem");
|
|
27
|
+
if (!publicKey) {
|
|
28
|
+
throw new errors_1.RsaError("Public key not found in key set", { debug: { kryptos } });
|
|
29
|
+
}
|
|
30
|
+
if (kryptos.algorithm.startsWith("PS")) {
|
|
31
|
+
return {
|
|
32
|
+
key: publicKey,
|
|
33
|
+
padding: constants_1.RSA_PKCS1_PSS_PADDING,
|
|
34
|
+
saltLength: RSA_PKCS1_SALT_LENGTH,
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
if (kryptos.algorithm.startsWith("RS")) {
|
|
38
|
+
return publicKey;
|
|
39
|
+
}
|
|
40
|
+
throw new errors_1.RsaError("Unsupported RSA algorithm", { debug: { kryptos } });
|
|
41
|
+
};
|
|
42
|
+
exports._getVerifyKey = _getVerifyKey;
|
|
43
|
+
//# sourceMappingURL=get-options.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-options.js","sourceRoot":"","sources":["../../../src/utils/private/get-options.ts"],"names":[],"mappings":";;;AACA,yCAAkD;AAElD,yCAAwC;AAExC,MAAM,qBAAqB,GAAG,EAAW,CAAC;AAEnC,MAAM,WAAW,GAAG,CAAC,OAAoB,EAAgC,EAAE;IAChF,MAAM,EAAE,UAAU,EAAE,GAAG,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IAE7C,IAAI,CAAC,UAAU,EAAE,CAAC;QAChB,MAAM,IAAI,iBAAQ,CAAC,kCAAkC,EAAE,EAAE,KAAK,EAAE,EAAE,OAAO,EAAE,EAAE,CAAC,CAAC;IACjF,CAAC;IAED,IAAI,OAAO,CAAC,SAAS,CAAC,UAAU,CAAC,IAAI,CAAC,EAAE,CAAC;QACvC,OAAO;YACL,GAAG,EAAE,UAAU;YACf,OAAO,EAAE,iCAAqB;YAC9B,UAAU,EAAE,qBAAqB;SAClC,CAAC;IACJ,CAAC;IAED,IAAI,OAAO,CAAC,SAAS,CAAC,UAAU,CAAC,IAAI,CAAC,EAAE,CAAC;QACvC,OAAO,UAAU,CAAC;IACpB,CAAC;IAED,MAAM,IAAI,iBAAQ,CAAC,2BAA2B,EAAE,EAAE,KAAK,EAAE,EAAE,OAAO,EAAE,EAAE,CAAC,CAAC;AAC1E,CAAC,CAAC;AApBW,QAAA,WAAW,eAoBtB;AAEK,MAAM,aAAa,GAAG,CAAC,OAAoB,EAAiC,EAAE;IACnF,MAAM,EAAE,SAAS,EAAE,GAAG,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IAE5C,IAAI,CAAC,SAAS,EAAE,CAAC;QACf,MAAM,IAAI,iBAAQ,CAAC,iCAAiC,EAAE,EAAE,KAAK,EAAE,EAAE,OAAO,EAAE,EAAE,CAAC,CAAC;IAChF,CAAC;IAED,IAAI,OAAO,CAAC,SAAS,CAAC,UAAU,CAAC,IAAI,CAAC,EAAE,CAAC;QACvC,OAAO;YACL,GAAG,EAAE,SAAS;YACd,OAAO,EAAE,iCAAqB;YAC9B,UAAU,EAAE,qBAAqB;SAClC,CAAC;IACJ,CAAC;IAED,IAAI,OAAO,CAAC,SAAS,CAAC,UAAU,CAAC,IAAI,CAAC,EAAE,CAAC;QACvC,OAAO,SAAS,CAAC;IACnB,CAAC;IAED,MAAM,IAAI,iBAAQ,CAAC,2BAA2B,EAAE,EAAE,KAAK,EAAE,EAAE,OAAO,EAAE,EAAE,CAAC,CAAC;AAC1E,CAAC,CAAC;AApBW,QAAA,aAAa,iBAoBxB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"map-algorithm.d.ts","sourceRoot":"","sources":["../../../src/utils/private/map-algorithm.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC/C,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAG9C,eAAO,MAAM,gBAAgB,YAAa,WAAW,KAAG,YAMvD,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports._mapRsaAlgorithm = void 0;
|
|
4
|
+
const errors_1 = require("../../errors");
|
|
5
|
+
const _mapRsaAlgorithm = (kryptos) => {
|
|
6
|
+
if (kryptos.algorithm.endsWith("256"))
|
|
7
|
+
return "SHA256";
|
|
8
|
+
if (kryptos.algorithm.endsWith("384"))
|
|
9
|
+
return "SHA384";
|
|
10
|
+
if (kryptos.algorithm.endsWith("512"))
|
|
11
|
+
return "SHA512";
|
|
12
|
+
throw new errors_1.RsaError("Unsupported RSA algorithm", { debug: { kryptos } });
|
|
13
|
+
};
|
|
14
|
+
exports._mapRsaAlgorithm = _mapRsaAlgorithm;
|
|
15
|
+
//# sourceMappingURL=map-algorithm.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"map-algorithm.js","sourceRoot":"","sources":["../../../src/utils/private/map-algorithm.ts"],"names":[],"mappings":";;;AAEA,yCAAwC;AAEjC,MAAM,gBAAgB,GAAG,CAAC,OAAoB,EAAgB,EAAE;IACrE,IAAI,OAAO,CAAC,SAAS,CAAC,QAAQ,CAAC,KAAK,CAAC;QAAE,OAAO,QAAQ,CAAC;IACvD,IAAI,OAAO,CAAC,SAAS,CAAC,QAAQ,CAAC,KAAK,CAAC;QAAE,OAAO,QAAQ,CAAC;IACvD,IAAI,OAAO,CAAC,SAAS,CAAC,QAAQ,CAAC,KAAK,CAAC;QAAE,OAAO,QAAQ,CAAC;IAEvD,MAAM,IAAI,iBAAQ,CAAC,2BAA2B,EAAE,EAAE,KAAK,EAAE,EAAE,OAAO,EAAE,EAAE,CAAC,CAAC;AAC1E,CAAC,CAAC;AANW,QAAA,gBAAgB,oBAM3B"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { CreateRsaSignatureOptions, VerifyRsaSignatureOptions } from "../../types";
|
|
2
|
-
export declare const
|
|
3
|
-
export declare const
|
|
4
|
-
export declare const
|
|
2
|
+
export declare const _createRsaSignature: ({ data, format, kryptos }: CreateRsaSignatureOptions) => string;
|
|
3
|
+
export declare const _verifyRsaSignature: ({ data, format, kryptos, signature, }: VerifyRsaSignatureOptions) => boolean;
|
|
4
|
+
export declare const _assertRsaSignature: (options: VerifyRsaSignatureOptions) => void;
|
|
5
5
|
//# sourceMappingURL=rsa-signature.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rsa-signature.d.ts","sourceRoot":"","sources":["../../../src/utils/private/rsa-signature.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"rsa-signature.d.ts","sourceRoot":"","sources":["../../../src/utils/private/rsa-signature.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,yBAAyB,EAAE,yBAAyB,EAAE,MAAM,aAAa,CAAC;AAInF,eAAO,MAAM,mBAAmB,8BAA+B,yBAAyB,KAAG,MACE,CAAC;AAE9F,eAAO,MAAM,mBAAmB,0CAK7B,yBAAyB,KAAG,OAIuB,CAAC;AAEvD,eAAO,MAAM,mBAAmB,YAAa,yBAAyB,KAAG,IAGxE,CAAC"}
|
|
@@ -1,39 +1,21 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
4
|
-
const kryptos_1 = require("@lindorm/kryptos");
|
|
3
|
+
exports._assertRsaSignature = exports._verifyRsaSignature = exports._createRsaSignature = void 0;
|
|
5
4
|
const crypto_1 = require("crypto");
|
|
6
5
|
const errors_1 = require("../../errors");
|
|
7
|
-
const
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
};
|
|
19
|
-
exports.createRsaSignature = createRsaSignature;
|
|
20
|
-
const verifyRsaSignature = (options) => {
|
|
21
|
-
const { algorithm = "RSA-SHA256", data, format = "base64url", kryptos, signature } = options;
|
|
22
|
-
if (!kryptos_1.Kryptos.isRsa(kryptos)) {
|
|
23
|
-
throw new errors_1.RsaError("Invalid kryptos type");
|
|
24
|
-
}
|
|
25
|
-
const { publicKey } = kryptos.export("pem");
|
|
26
|
-
if (!publicKey) {
|
|
27
|
-
throw new errors_1.RsaError("Public key not found in key set");
|
|
28
|
-
}
|
|
29
|
-
const verifier = (0, crypto_1.createVerify)(algorithm).update(data).end();
|
|
30
|
-
return verifier.verify(publicKey, signature, format);
|
|
31
|
-
};
|
|
32
|
-
exports.verifyRsaSignature = verifyRsaSignature;
|
|
33
|
-
const assertRsaSignature = (options) => {
|
|
34
|
-
if ((0, exports.verifyRsaSignature)(options))
|
|
6
|
+
const get_options_1 = require("./get-options");
|
|
7
|
+
const map_algorithm_1 = require("./map-algorithm");
|
|
8
|
+
const _createRsaSignature = ({ data, format, kryptos }) => (0, crypto_1.createSign)((0, map_algorithm_1._mapRsaAlgorithm)(kryptos)).update(data).end().sign((0, get_options_1._getSignKey)(kryptos), format);
|
|
9
|
+
exports._createRsaSignature = _createRsaSignature;
|
|
10
|
+
const _verifyRsaSignature = ({ data, format, kryptos, signature, }) => (0, crypto_1.createVerify)((0, map_algorithm_1._mapRsaAlgorithm)(kryptos))
|
|
11
|
+
.update(data)
|
|
12
|
+
.end()
|
|
13
|
+
.verify((0, get_options_1._getVerifyKey)(kryptos), signature, format);
|
|
14
|
+
exports._verifyRsaSignature = _verifyRsaSignature;
|
|
15
|
+
const _assertRsaSignature = (options) => {
|
|
16
|
+
if ((0, exports._verifyRsaSignature)(options))
|
|
35
17
|
return;
|
|
36
18
|
throw new errors_1.RsaError("Invalid signature");
|
|
37
19
|
};
|
|
38
|
-
exports.
|
|
20
|
+
exports._assertRsaSignature = _assertRsaSignature;
|
|
39
21
|
//# sourceMappingURL=rsa-signature.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rsa-signature.js","sourceRoot":"","sources":["../../../src/utils/private/rsa-signature.ts"],"names":[],"mappings":";;;AAAA,
|
|
1
|
+
{"version":3,"file":"rsa-signature.js","sourceRoot":"","sources":["../../../src/utils/private/rsa-signature.ts"],"names":[],"mappings":";;;AAAA,mCAAkD;AAClD,yCAAwC;AAExC,+CAA2D;AAC3D,mDAAmD;AAE5C,MAAM,mBAAmB,GAAG,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAA6B,EAAU,EAAE,CAClG,IAAA,mBAAU,EAAC,IAAA,gCAAgB,EAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,IAAA,yBAAW,EAAC,OAAO,CAAC,EAAE,MAAM,CAAC,CAAC;AADjF,QAAA,mBAAmB,uBAC8D;AAEvF,MAAM,mBAAmB,GAAG,CAAC,EAClC,IAAI,EACJ,MAAM,EACN,OAAO,EACP,SAAS,GACiB,EAAW,EAAE,CACvC,IAAA,qBAAY,EAAC,IAAA,gCAAgB,EAAC,OAAO,CAAC,CAAC;KACpC,MAAM,CAAC,IAAI,CAAC;KACZ,GAAG,EAAE;KACL,MAAM,CAAC,IAAA,2BAAa,EAAC,OAAO,CAAC,EAAE,SAAS,EAAE,MAAM,CAAC,CAAC;AAT1C,QAAA,mBAAmB,uBASuB;AAEhD,MAAM,mBAAmB,GAAG,CAAC,OAAkC,EAAQ,EAAE;IAC9E,IAAI,IAAA,2BAAmB,EAAC,OAAO,CAAC;QAAE,OAAO;IACzC,MAAM,IAAI,iBAAQ,CAAC,mBAAmB,CAAC,CAAC;AAC1C,CAAC,CAAC;AAHW,QAAA,mBAAmB,uBAG9B"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lindorm/rsa",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.2",
|
|
4
4
|
"license": "AGPL-3.0-or-later",
|
|
5
5
|
"author": "Jonn Nilsson",
|
|
6
6
|
"repository": {
|
|
@@ -26,8 +26,11 @@
|
|
|
26
26
|
"update": "ncu -u"
|
|
27
27
|
},
|
|
28
28
|
"dependencies": {
|
|
29
|
-
"@lindorm/errors": "^0.1.
|
|
30
|
-
"@lindorm/kryptos": "^0.
|
|
29
|
+
"@lindorm/errors": "^0.1.5",
|
|
30
|
+
"@lindorm/kryptos": "^0.3.0"
|
|
31
31
|
},
|
|
32
|
-
"
|
|
32
|
+
"devDependencies": {
|
|
33
|
+
"@lindorm/types": "^0.1.4"
|
|
34
|
+
},
|
|
35
|
+
"gitHead": "677a485cb48b37f891f25a46f417b033cbfec9e2"
|
|
33
36
|
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"RsaAlgorithm.d.ts","sourceRoot":"","sources":["../../src/enums/RsaAlgorithm.ts"],"names":[],"mappings":"AAAA,oBAAY,YAAY;IACtB,UAAU,eAAe;IACzB,UAAU,eAAe;IACzB,UAAU,eAAe;IACzB,MAAM,WAAW;IACjB,MAAM,WAAW;IACjB,MAAM,WAAW;CAClB"}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.RsaAlgorithm = void 0;
|
|
4
|
-
var RsaAlgorithm;
|
|
5
|
-
(function (RsaAlgorithm) {
|
|
6
|
-
RsaAlgorithm["RSA_SHA256"] = "RSA-SHA256";
|
|
7
|
-
RsaAlgorithm["RSA_SHA384"] = "RSA-SHA384";
|
|
8
|
-
RsaAlgorithm["RSA_SHA512"] = "RSA-SHA512";
|
|
9
|
-
RsaAlgorithm["SHA256"] = "sha256";
|
|
10
|
-
RsaAlgorithm["SHA384"] = "sha384";
|
|
11
|
-
RsaAlgorithm["SHA512"] = "sha512";
|
|
12
|
-
})(RsaAlgorithm || (exports.RsaAlgorithm = RsaAlgorithm = {}));
|
|
13
|
-
//# sourceMappingURL=RsaAlgorithm.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"RsaAlgorithm.js","sourceRoot":"","sources":["../../src/enums/RsaAlgorithm.ts"],"names":[],"mappings":";;;AAAA,IAAY,YAOX;AAPD,WAAY,YAAY;IACtB,yCAAyB,CAAA;IACzB,yCAAyB,CAAA;IACzB,yCAAyB,CAAA;IACzB,iCAAiB,CAAA;IACjB,iCAAiB,CAAA;IACjB,iCAAiB,CAAA;AACnB,CAAC,EAPW,YAAY,4BAAZ,YAAY,QAOvB"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"RsaFormat.d.ts","sourceRoot":"","sources":["../../src/enums/RsaFormat.ts"],"names":[],"mappings":"AAAA,oBAAY,SAAS;IACnB,MAAM,WAAW;IACjB,UAAU,cAAc;IACxB,GAAG,QAAQ;CACZ"}
|
package/dist/enums/RsaFormat.js
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.RsaFormat = void 0;
|
|
4
|
-
var RsaFormat;
|
|
5
|
-
(function (RsaFormat) {
|
|
6
|
-
RsaFormat["BASE64"] = "base64";
|
|
7
|
-
RsaFormat["BASE64_URL"] = "base64url";
|
|
8
|
-
RsaFormat["HEX"] = "hex";
|
|
9
|
-
})(RsaFormat || (exports.RsaFormat = RsaFormat = {}));
|
|
10
|
-
//# sourceMappingURL=RsaFormat.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"RsaFormat.js","sourceRoot":"","sources":["../../src/enums/RsaFormat.ts"],"names":[],"mappings":";;;AAAA,IAAY,SAIX;AAJD,WAAY,SAAS;IACnB,8BAAiB,CAAA;IACjB,qCAAwB,CAAA;IACxB,wBAAW,CAAA;AACb,CAAC,EAJW,SAAS,yBAAT,SAAS,QAIpB"}
|
package/dist/enums/index.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/enums/index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAC;AAC/B,cAAc,aAAa,CAAC"}
|
package/dist/enums/index.js
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./RsaAlgorithm"), exports);
|
|
18
|
-
__exportStar(require("./RsaFormat"), exports);
|
|
19
|
-
//# sourceMappingURL=index.js.map
|
package/dist/enums/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/enums/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,iDAA+B;AAC/B,8CAA4B"}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { Kryptos } from "@lindorm/kryptos";
|
|
2
|
-
import { BufferFormat, SignatureAlgorithm } from "./types";
|
|
3
|
-
export type RsaKitOptions = {
|
|
4
|
-
algorithm?: SignatureAlgorithm;
|
|
5
|
-
format?: BufferFormat;
|
|
6
|
-
kryptos: Kryptos;
|
|
7
|
-
};
|
|
8
|
-
//# sourceMappingURL=rsa-signature-class.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"rsa-signature-class.d.ts","sourceRoot":"","sources":["../../src/types/rsa-signature-class.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAC3C,OAAO,EAAE,YAAY,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAC;AAE3D,MAAM,MAAM,aAAa,GAAG;IAC1B,SAAS,CAAC,EAAE,kBAAkB,CAAC;IAC/B,MAAM,CAAC,EAAE,YAAY,CAAC;IACtB,OAAO,EAAE,OAAO,CAAC;CAClB,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"rsa-signature-class.js","sourceRoot":"","sources":["../../src/types/rsa-signature-class.ts"],"names":[],"mappings":""}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { Kryptos } from "@lindorm/kryptos";
|
|
2
|
-
import { BufferFormat, SignatureAlgorithm } from "./types";
|
|
3
|
-
export type CreateRsaSignatureOptions = {
|
|
4
|
-
algorithm?: SignatureAlgorithm;
|
|
5
|
-
data: string;
|
|
6
|
-
format?: BufferFormat;
|
|
7
|
-
kryptos: Kryptos;
|
|
8
|
-
};
|
|
9
|
-
export type VerifyRsaSignatureOptions = {
|
|
10
|
-
algorithm?: SignatureAlgorithm;
|
|
11
|
-
data: string;
|
|
12
|
-
format?: BufferFormat;
|
|
13
|
-
kryptos: Kryptos;
|
|
14
|
-
signature: string;
|
|
15
|
-
};
|
|
16
|
-
//# sourceMappingURL=rsa-signature.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"rsa-signature.d.ts","sourceRoot":"","sources":["../../src/types/rsa-signature.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAC3C,OAAO,EAAE,YAAY,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAC;AAE3D,MAAM,MAAM,yBAAyB,GAAG;IACtC,SAAS,CAAC,EAAE,kBAAkB,CAAC;IAC/B,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,CAAC,EAAE,YAAY,CAAC;IACtB,OAAO,EAAE,OAAO,CAAC;CAClB,CAAC;AAEF,MAAM,MAAM,yBAAyB,GAAG;IACtC,SAAS,CAAC,EAAE,kBAAkB,CAAC;IAC/B,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,CAAC,EAAE,YAAY,CAAC;IACtB,OAAO,EAAE,OAAO,CAAC;IACjB,SAAS,EAAE,MAAM,CAAC;CACnB,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"rsa-signature.js","sourceRoot":"","sources":["../../src/types/rsa-signature.ts"],"names":[],"mappings":""}
|
package/dist/types/types.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/types/types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,YAAY,GAAG,QAAQ,GAAG,WAAW,GAAG,KAAK,CAAC;AAE1D,MAAM,MAAM,kBAAkB,GAC1B,YAAY,GACZ,YAAY,GACZ,YAAY,GACZ,QAAQ,GACR,QAAQ,GACR,QAAQ,CAAC"}
|
package/dist/types/types.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/types/types.ts"],"names":[],"mappings":""}
|