@substrate-system/keys 0.2.7 → 0.2.9
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/dist/_base.cjs +244 -0
- package/dist/_base.cjs.map +7 -0
- package/dist/_base.js +231 -0
- package/dist/_base.js.map +7 -0
- package/dist/_base.min.cjs +2 -0
- package/dist/_base.min.cjs.map +7 -0
- package/dist/_base.min.js +4 -0
- package/dist/_base.min.js.map +7 -0
- package/dist/aes/index.cjs +1 -0
- package/dist/aes/index.cjs.map +2 -2
- package/dist/aes/index.d.ts +15 -0
- package/dist/aes/index.d.ts.map +1 -1
- package/dist/aes/index.js +1 -0
- package/dist/aes/index.js.map +2 -2
- package/dist/aes/index.min.cjs +1 -1
- package/dist/aes/index.min.cjs.map +3 -3
- package/dist/aes/index.min.js +1 -1
- package/dist/aes/index.min.js.map +2 -2
- package/dist/constants.cjs +83 -0
- package/dist/constants.cjs.map +7 -0
- package/dist/constants.js +63 -0
- package/dist/constants.js.map +7 -0
- package/dist/constants.min.cjs +2 -0
- package/dist/constants.min.cjs.map +7 -0
- package/dist/constants.min.js +2 -0
- package/dist/constants.min.js.map +7 -0
- package/dist/ecc/index.min.js.map +2 -2
- package/dist/errors.cjs +90 -0
- package/dist/errors.cjs.map +7 -0
- package/dist/errors.js +71 -0
- package/dist/errors.js.map +7 -0
- package/dist/errors.min.cjs +2 -0
- package/dist/errors.min.cjs.map +7 -0
- package/dist/errors.min.js +2 -0
- package/dist/errors.min.js.map +7 -0
- package/dist/index.cjs +44 -0
- package/dist/index.cjs.map +7 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +7 -0
- package/dist/index.min.cjs +2 -0
- package/dist/index.min.cjs.map +7 -0
- package/dist/index.min.js +2 -2
- package/dist/index.min.js.map +7 -0
- package/dist/meta.json +329 -3
- package/dist/rsa/index.min.js.map +2 -2
- package/dist/types.cjs +72 -0
- package/dist/types.cjs.map +7 -0
- package/dist/types.js +52 -0
- package/dist/types.js.map +7 -0
- package/dist/types.min.cjs +2 -0
- package/dist/types.min.cjs.map +7 -0
- package/dist/types.min.js +2 -0
- package/dist/types.min.js.map +7 -0
- package/dist/util.cjs +445 -0
- package/dist/util.cjs.map +7 -0
- package/dist/util.js +434 -0
- package/dist/util.js.map +7 -0
- package/dist/util.min.cjs +4 -0
- package/dist/util.min.cjs.map +7 -0
- package/dist/util.min.js +4 -0
- package/dist/util.min.js.map +7 -0
- package/package.json +5 -5
package/dist/errors.cjs
ADDED
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from))
|
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
20
|
+
var errors_exports = {};
|
|
21
|
+
__export(errors_exports, {
|
|
22
|
+
ECCNotEnabled: () => ECCNotEnabled,
|
|
23
|
+
InvalidKeyUse: () => InvalidKeyUse,
|
|
24
|
+
InvalidMaxValue: () => InvalidMaxValue,
|
|
25
|
+
KeyDoesNotExist: () => KeyDoesNotExist,
|
|
26
|
+
NotKey: () => NotKey,
|
|
27
|
+
NotKeyPair: () => NotKeyPair,
|
|
28
|
+
UnsupportedCrypto: () => UnsupportedCrypto,
|
|
29
|
+
checkIsKey: () => checkIsKey,
|
|
30
|
+
checkIsKeyPair: () => checkIsKeyPair,
|
|
31
|
+
checkValidCryptoSystem: () => checkValidCryptoSystem,
|
|
32
|
+
checkValidKeyUse: () => checkValidKeyUse,
|
|
33
|
+
default: () => errors_default
|
|
34
|
+
});
|
|
35
|
+
module.exports = __toCommonJS(errors_exports);
|
|
36
|
+
var import_types = require("./types.js");
|
|
37
|
+
const KeyDoesNotExist = new Error("Key does not exist. Make sure you properly instantiated the keystore.");
|
|
38
|
+
const NotKeyPair = new Error("Retrieved a symmetric key when an asymmetric keypair was expected. Please use a different key name.");
|
|
39
|
+
const NotKey = new Error("Retrieved an asymmetric keypair when an symmetric key was expected. Please use a different key name.");
|
|
40
|
+
const ECCNotEnabled = new Error("ECC is not enabled for this browser. Please use RSA instead.");
|
|
41
|
+
const UnsupportedCrypto = new Error("Cryptosystem not supported. Please use ECC or RSA");
|
|
42
|
+
const InvalidKeyUse = new Error("Invalid key use. Please use 'exchange' or 'write'");
|
|
43
|
+
const InvalidMaxValue = new Error("Max must be less than 256 and greater than 0");
|
|
44
|
+
function checkIsKeyPair(keypair) {
|
|
45
|
+
if (!keypair || keypair === null) {
|
|
46
|
+
throw KeyDoesNotExist;
|
|
47
|
+
} else if (keypair.privateKey === void 0) {
|
|
48
|
+
throw NotKeyPair;
|
|
49
|
+
}
|
|
50
|
+
return keypair;
|
|
51
|
+
}
|
|
52
|
+
__name(checkIsKeyPair, "checkIsKeyPair");
|
|
53
|
+
function checkIsKey(key) {
|
|
54
|
+
if (!key || key === null) {
|
|
55
|
+
throw KeyDoesNotExist;
|
|
56
|
+
} else if (key.privateKey !== void 0 || key.algorithm === void 0) {
|
|
57
|
+
throw NotKey;
|
|
58
|
+
}
|
|
59
|
+
return key;
|
|
60
|
+
}
|
|
61
|
+
__name(checkIsKey, "checkIsKey");
|
|
62
|
+
function checkValidCryptoSystem(type) {
|
|
63
|
+
checkValid(type, [import_types.CryptoSystem.ECC, import_types.CryptoSystem.RSA], UnsupportedCrypto);
|
|
64
|
+
}
|
|
65
|
+
__name(checkValidCryptoSystem, "checkValidCryptoSystem");
|
|
66
|
+
function checkValidKeyUse(use) {
|
|
67
|
+
checkValid(use, [import_types.KeyUse.Exchange, import_types.KeyUse.Write, import_types.KeyUse.Sign], InvalidKeyUse);
|
|
68
|
+
}
|
|
69
|
+
__name(checkValidKeyUse, "checkValidKeyUse");
|
|
70
|
+
function checkValid(toCheck, opts, error) {
|
|
71
|
+
const match = opts.some((opt) => opt === toCheck);
|
|
72
|
+
if (!match) {
|
|
73
|
+
throw error;
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
__name(checkValid, "checkValid");
|
|
77
|
+
var errors_default = {
|
|
78
|
+
KeyDoesNotExist,
|
|
79
|
+
NotKeyPair,
|
|
80
|
+
NotKey,
|
|
81
|
+
ECCNotEnabled,
|
|
82
|
+
UnsupportedCrypto,
|
|
83
|
+
InvalidKeyUse,
|
|
84
|
+
checkIsKeyPair,
|
|
85
|
+
checkIsKey,
|
|
86
|
+
checkValidCryptoSystem,
|
|
87
|
+
checkValidKeyUse,
|
|
88
|
+
InvalidMaxValue
|
|
89
|
+
};
|
|
90
|
+
//# sourceMappingURL=errors.cjs.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/errors.ts"],
|
|
4
|
+
"sourcesContent": ["import { KeyUse, CryptoSystem } from './types.js'\n\nexport const KeyDoesNotExist = new Error('Key does not exist. Make sure you ' +\n 'properly instantiated the keystore.')\nexport const NotKeyPair = new Error('Retrieved a symmetric key when an ' +\n 'asymmetric keypair was expected. Please use a different key name.')\nexport const NotKey = new Error('Retrieved an asymmetric keypair when an ' +\n 'symmetric key was expected. Please use a different key name.')\nexport const ECCNotEnabled = new Error('ECC is not enabled for this browser.' +\n ' Please use RSA instead.')\nexport const UnsupportedCrypto = new Error('Cryptosystem not supported. ' +\n 'Please use ECC or RSA')\nexport const InvalidKeyUse = new Error('Invalid key use. Please use ' +\n \"'exchange' or 'write'\")\nexport const InvalidMaxValue = new Error('Max must be less than 256 and ' +\n ' greater than 0')\n\nexport function checkIsKeyPair (keypair: any): CryptoKeyPair {\n if (!keypair || keypair === null) {\n throw KeyDoesNotExist\n } else if (keypair.privateKey === undefined) {\n throw NotKeyPair\n }\n return keypair as CryptoKeyPair\n}\n\nexport function checkIsKey (key: any): CryptoKey {\n if (!key || key === null) {\n throw KeyDoesNotExist\n } else if (key.privateKey !== undefined || key.algorithm === undefined) {\n throw NotKey\n }\n return key\n}\n\nexport function checkValidCryptoSystem (type:CryptoSystem): void {\n checkValid(type, [CryptoSystem.ECC, CryptoSystem.RSA], UnsupportedCrypto)\n}\n\nexport function checkValidKeyUse (use:KeyUse): void {\n checkValid(use, [KeyUse.Exchange, KeyUse.Write, KeyUse.Sign], InvalidKeyUse)\n}\n\nfunction checkValid<T> (toCheck:T, opts:T[], error:Error):void {\n const match = opts.some(opt => opt === toCheck)\n if (!match) {\n throw error\n }\n}\n\nexport default {\n KeyDoesNotExist,\n NotKeyPair,\n NotKey,\n ECCNotEnabled,\n UnsupportedCrypto,\n InvalidKeyUse,\n checkIsKeyPair,\n checkIsKey,\n checkValidCryptoSystem,\n checkValidKeyUse,\n InvalidMaxValue,\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAAqC;AAE9B,MAAM,kBAAkB,IAAI,MAAM,uEACA;AAClC,MAAM,aAAa,IAAI,MAAM,qGACmC;AAChE,MAAM,SAAS,IAAI,MAAM,sGACkC;AAC3D,MAAM,gBAAgB,IAAI,MAAM,8DACT;AACvB,MAAM,oBAAoB,IAAI,MAAM,mDAChB;AACpB,MAAM,gBAAgB,IAAI,MAAM,mDACZ;AACpB,MAAM,kBAAkB,IAAI,MAAM,+CACpB;AAEd,SAAS,eAAgB,SAA6B;AACzD,MAAI,CAAC,WAAW,YAAY,MAAM;AAC9B,UAAM;AAAA,EACV,WAAW,QAAQ,eAAe,QAAW;AACzC,UAAM;AAAA,EACV;AACA,SAAO;AACX;AAPgB;AAST,SAAS,WAAY,KAAqB;AAC7C,MAAI,CAAC,OAAO,QAAQ,MAAM;AACtB,UAAM;AAAA,EACV,WAAW,IAAI,eAAe,UAAa,IAAI,cAAc,QAAW;AACpE,UAAM;AAAA,EACV;AACA,SAAO;AACX;AAPgB;AAST,SAAS,uBAAwB,MAAyB;AAC7D,aAAW,MAAM,CAAC,0BAAa,KAAK,0BAAa,GAAG,GAAG,iBAAiB;AAC5E;AAFgB;AAIT,SAAS,iBAAkB,KAAkB;AAChD,aAAW,KAAK,CAAC,oBAAO,UAAU,oBAAO,OAAO,oBAAO,IAAI,GAAG,aAAa;AAC/E;AAFgB;AAIhB,SAAS,WAAe,SAAW,MAAU,OAAkB;AAC3D,QAAM,QAAQ,KAAK,KAAK,SAAO,QAAQ,OAAO;AAC9C,MAAI,CAAC,OAAO;AACR,UAAM;AAAA,EACV;AACJ;AALS;AAOT,IAAO,iBAAQ;AAAA,EACX;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACJ;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
package/dist/errors.js
ADDED
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
3
|
+
import { KeyUse, CryptoSystem } from "./types.js";
|
|
4
|
+
const KeyDoesNotExist = new Error("Key does not exist. Make sure you properly instantiated the keystore.");
|
|
5
|
+
const NotKeyPair = new Error("Retrieved a symmetric key when an asymmetric keypair was expected. Please use a different key name.");
|
|
6
|
+
const NotKey = new Error("Retrieved an asymmetric keypair when an symmetric key was expected. Please use a different key name.");
|
|
7
|
+
const ECCNotEnabled = new Error("ECC is not enabled for this browser. Please use RSA instead.");
|
|
8
|
+
const UnsupportedCrypto = new Error("Cryptosystem not supported. Please use ECC or RSA");
|
|
9
|
+
const InvalidKeyUse = new Error("Invalid key use. Please use 'exchange' or 'write'");
|
|
10
|
+
const InvalidMaxValue = new Error("Max must be less than 256 and greater than 0");
|
|
11
|
+
function checkIsKeyPair(keypair) {
|
|
12
|
+
if (!keypair || keypair === null) {
|
|
13
|
+
throw KeyDoesNotExist;
|
|
14
|
+
} else if (keypair.privateKey === void 0) {
|
|
15
|
+
throw NotKeyPair;
|
|
16
|
+
}
|
|
17
|
+
return keypair;
|
|
18
|
+
}
|
|
19
|
+
__name(checkIsKeyPair, "checkIsKeyPair");
|
|
20
|
+
function checkIsKey(key) {
|
|
21
|
+
if (!key || key === null) {
|
|
22
|
+
throw KeyDoesNotExist;
|
|
23
|
+
} else if (key.privateKey !== void 0 || key.algorithm === void 0) {
|
|
24
|
+
throw NotKey;
|
|
25
|
+
}
|
|
26
|
+
return key;
|
|
27
|
+
}
|
|
28
|
+
__name(checkIsKey, "checkIsKey");
|
|
29
|
+
function checkValidCryptoSystem(type) {
|
|
30
|
+
checkValid(type, [CryptoSystem.ECC, CryptoSystem.RSA], UnsupportedCrypto);
|
|
31
|
+
}
|
|
32
|
+
__name(checkValidCryptoSystem, "checkValidCryptoSystem");
|
|
33
|
+
function checkValidKeyUse(use) {
|
|
34
|
+
checkValid(use, [KeyUse.Exchange, KeyUse.Write, KeyUse.Sign], InvalidKeyUse);
|
|
35
|
+
}
|
|
36
|
+
__name(checkValidKeyUse, "checkValidKeyUse");
|
|
37
|
+
function checkValid(toCheck, opts, error) {
|
|
38
|
+
const match = opts.some((opt) => opt === toCheck);
|
|
39
|
+
if (!match) {
|
|
40
|
+
throw error;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
__name(checkValid, "checkValid");
|
|
44
|
+
var errors_default = {
|
|
45
|
+
KeyDoesNotExist,
|
|
46
|
+
NotKeyPair,
|
|
47
|
+
NotKey,
|
|
48
|
+
ECCNotEnabled,
|
|
49
|
+
UnsupportedCrypto,
|
|
50
|
+
InvalidKeyUse,
|
|
51
|
+
checkIsKeyPair,
|
|
52
|
+
checkIsKey,
|
|
53
|
+
checkValidCryptoSystem,
|
|
54
|
+
checkValidKeyUse,
|
|
55
|
+
InvalidMaxValue
|
|
56
|
+
};
|
|
57
|
+
export {
|
|
58
|
+
ECCNotEnabled,
|
|
59
|
+
InvalidKeyUse,
|
|
60
|
+
InvalidMaxValue,
|
|
61
|
+
KeyDoesNotExist,
|
|
62
|
+
NotKey,
|
|
63
|
+
NotKeyPair,
|
|
64
|
+
UnsupportedCrypto,
|
|
65
|
+
checkIsKey,
|
|
66
|
+
checkIsKeyPair,
|
|
67
|
+
checkValidCryptoSystem,
|
|
68
|
+
checkValidKeyUse,
|
|
69
|
+
errors_default as default
|
|
70
|
+
};
|
|
71
|
+
//# sourceMappingURL=errors.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/errors.ts"],
|
|
4
|
+
"sourcesContent": ["import { KeyUse, CryptoSystem } from './types.js'\n\nexport const KeyDoesNotExist = new Error('Key does not exist. Make sure you ' +\n 'properly instantiated the keystore.')\nexport const NotKeyPair = new Error('Retrieved a symmetric key when an ' +\n 'asymmetric keypair was expected. Please use a different key name.')\nexport const NotKey = new Error('Retrieved an asymmetric keypair when an ' +\n 'symmetric key was expected. Please use a different key name.')\nexport const ECCNotEnabled = new Error('ECC is not enabled for this browser.' +\n ' Please use RSA instead.')\nexport const UnsupportedCrypto = new Error('Cryptosystem not supported. ' +\n 'Please use ECC or RSA')\nexport const InvalidKeyUse = new Error('Invalid key use. Please use ' +\n \"'exchange' or 'write'\")\nexport const InvalidMaxValue = new Error('Max must be less than 256 and ' +\n ' greater than 0')\n\nexport function checkIsKeyPair (keypair: any): CryptoKeyPair {\n if (!keypair || keypair === null) {\n throw KeyDoesNotExist\n } else if (keypair.privateKey === undefined) {\n throw NotKeyPair\n }\n return keypair as CryptoKeyPair\n}\n\nexport function checkIsKey (key: any): CryptoKey {\n if (!key || key === null) {\n throw KeyDoesNotExist\n } else if (key.privateKey !== undefined || key.algorithm === undefined) {\n throw NotKey\n }\n return key\n}\n\nexport function checkValidCryptoSystem (type:CryptoSystem): void {\n checkValid(type, [CryptoSystem.ECC, CryptoSystem.RSA], UnsupportedCrypto)\n}\n\nexport function checkValidKeyUse (use:KeyUse): void {\n checkValid(use, [KeyUse.Exchange, KeyUse.Write, KeyUse.Sign], InvalidKeyUse)\n}\n\nfunction checkValid<T> (toCheck:T, opts:T[], error:Error):void {\n const match = opts.some(opt => opt === toCheck)\n if (!match) {\n throw error\n }\n}\n\nexport default {\n KeyDoesNotExist,\n NotKeyPair,\n NotKey,\n ECCNotEnabled,\n UnsupportedCrypto,\n InvalidKeyUse,\n checkIsKeyPair,\n checkIsKey,\n checkValidCryptoSystem,\n checkValidKeyUse,\n InvalidMaxValue,\n}\n"],
|
|
5
|
+
"mappings": ";;AAAA,SAAS,QAAQ,oBAAoB;AAE9B,MAAM,kBAAkB,IAAI,MAAM,uEACA;AAClC,MAAM,aAAa,IAAI,MAAM,qGACmC;AAChE,MAAM,SAAS,IAAI,MAAM,sGACkC;AAC3D,MAAM,gBAAgB,IAAI,MAAM,8DACT;AACvB,MAAM,oBAAoB,IAAI,MAAM,mDAChB;AACpB,MAAM,gBAAgB,IAAI,MAAM,mDACZ;AACpB,MAAM,kBAAkB,IAAI,MAAM,+CACpB;AAEd,SAAS,eAAgB,SAA6B;AACzD,MAAI,CAAC,WAAW,YAAY,MAAM;AAC9B,UAAM;AAAA,EACV,WAAW,QAAQ,eAAe,QAAW;AACzC,UAAM;AAAA,EACV;AACA,SAAO;AACX;AAPgB;AAST,SAAS,WAAY,KAAqB;AAC7C,MAAI,CAAC,OAAO,QAAQ,MAAM;AACtB,UAAM;AAAA,EACV,WAAW,IAAI,eAAe,UAAa,IAAI,cAAc,QAAW;AACpE,UAAM;AAAA,EACV;AACA,SAAO;AACX;AAPgB;AAST,SAAS,uBAAwB,MAAyB;AAC7D,aAAW,MAAM,CAAC,aAAa,KAAK,aAAa,GAAG,GAAG,iBAAiB;AAC5E;AAFgB;AAIT,SAAS,iBAAkB,KAAkB;AAChD,aAAW,KAAK,CAAC,OAAO,UAAU,OAAO,OAAO,OAAO,IAAI,GAAG,aAAa;AAC/E;AAFgB;AAIhB,SAAS,WAAe,SAAW,MAAU,OAAkB;AAC3D,QAAM,QAAQ,KAAK,KAAK,SAAO,QAAQ,OAAO;AAC9C,MAAI,CAAC,OAAO;AACR,UAAM;AAAA,EACV;AACJ;AALS;AAOT,IAAO,iBAAQ;AAAA,EACX;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACJ;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";var a=Object.defineProperty;var E=Object.getOwnPropertyDescriptor;var K=Object.getOwnPropertyNames;var v=Object.prototype.hasOwnProperty;var s=(e,t)=>a(e,"name",{value:t,configurable:!0});var P=(e,t)=>{for(var n in t)a(e,n,{get:t[n],enumerable:!0})},k=(e,t,n,y)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of K(t))!v.call(e,r)&&r!==n&&a(e,r,{get:()=>t[r],enumerable:!(y=E(t,r))||y.enumerable});return e};var S=e=>k(a({},"__esModule",{value:!0}),e);var I={};P(I,{ECCNotEnabled:()=>h,InvalidKeyUse:()=>u,InvalidMaxValue:()=>m,KeyDoesNotExist:()=>i,NotKey:()=>d,NotKeyPair:()=>c,UnsupportedCrypto:()=>p,checkIsKey:()=>x,checkIsKeyPair:()=>f,checkValidCryptoSystem:()=>w,checkValidKeyUse:()=>C,default:()=>g});module.exports=S(I);var o=require("./types.js");const i=new Error("Key does not exist. Make sure you properly instantiated the keystore."),c=new Error("Retrieved a symmetric key when an asymmetric keypair was expected. Please use a different key name."),d=new Error("Retrieved an asymmetric keypair when an symmetric key was expected. Please use a different key name."),h=new Error("ECC is not enabled for this browser. Please use RSA instead."),p=new Error("Cryptosystem not supported. Please use ECC or RSA"),u=new Error("Invalid key use. Please use 'exchange' or 'write'"),m=new Error("Max must be less than 256 and greater than 0");function f(e){if(!e||e===null)throw i;if(e.privateKey===void 0)throw c;return e}s(f,"checkIsKeyPair");function x(e){if(!e||e===null)throw i;if(e.privateKey!==void 0||e.algorithm===void 0)throw d;return e}s(x,"checkIsKey");function w(e){l(e,[o.CryptoSystem.ECC,o.CryptoSystem.RSA],p)}s(w,"checkValidCryptoSystem");function C(e){l(e,[o.KeyUse.Exchange,o.KeyUse.Write,o.KeyUse.Sign],u)}s(C,"checkValidKeyUse");function l(e,t,n){if(!t.some(r=>r===e))throw n}s(l,"checkValid");var g={KeyDoesNotExist:i,NotKeyPair:c,NotKey:d,ECCNotEnabled:h,UnsupportedCrypto:p,InvalidKeyUse:u,checkIsKeyPair:f,checkIsKey:x,checkValidCryptoSystem:w,checkValidKeyUse:C,InvalidMaxValue:m};
|
|
2
|
+
//# sourceMappingURL=errors.min.cjs.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/errors.ts"],
|
|
4
|
+
"sourcesContent": ["import { KeyUse, CryptoSystem } from './types.js'\n\nexport const KeyDoesNotExist = new Error('Key does not exist. Make sure you ' +\n 'properly instantiated the keystore.')\nexport const NotKeyPair = new Error('Retrieved a symmetric key when an ' +\n 'asymmetric keypair was expected. Please use a different key name.')\nexport const NotKey = new Error('Retrieved an asymmetric keypair when an ' +\n 'symmetric key was expected. Please use a different key name.')\nexport const ECCNotEnabled = new Error('ECC is not enabled for this browser.' +\n ' Please use RSA instead.')\nexport const UnsupportedCrypto = new Error('Cryptosystem not supported. ' +\n 'Please use ECC or RSA')\nexport const InvalidKeyUse = new Error('Invalid key use. Please use ' +\n \"'exchange' or 'write'\")\nexport const InvalidMaxValue = new Error('Max must be less than 256 and ' +\n ' greater than 0')\n\nexport function checkIsKeyPair (keypair: any): CryptoKeyPair {\n if (!keypair || keypair === null) {\n throw KeyDoesNotExist\n } else if (keypair.privateKey === undefined) {\n throw NotKeyPair\n }\n return keypair as CryptoKeyPair\n}\n\nexport function checkIsKey (key: any): CryptoKey {\n if (!key || key === null) {\n throw KeyDoesNotExist\n } else if (key.privateKey !== undefined || key.algorithm === undefined) {\n throw NotKey\n }\n return key\n}\n\nexport function checkValidCryptoSystem (type:CryptoSystem): void {\n checkValid(type, [CryptoSystem.ECC, CryptoSystem.RSA], UnsupportedCrypto)\n}\n\nexport function checkValidKeyUse (use:KeyUse): void {\n checkValid(use, [KeyUse.Exchange, KeyUse.Write, KeyUse.Sign], InvalidKeyUse)\n}\n\nfunction checkValid<T> (toCheck:T, opts:T[], error:Error):void {\n const match = opts.some(opt => opt === toCheck)\n if (!match) {\n throw error\n }\n}\n\nexport default {\n KeyDoesNotExist,\n NotKeyPair,\n NotKey,\n ECCNotEnabled,\n UnsupportedCrypto,\n InvalidKeyUse,\n checkIsKeyPair,\n checkIsKey,\n checkValidCryptoSystem,\n checkValidKeyUse,\n InvalidMaxValue,\n}\n"],
|
|
5
|
+
"mappings": "4dAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,mBAAAE,EAAA,kBAAAC,EAAA,oBAAAC,EAAA,oBAAAC,EAAA,WAAAC,EAAA,eAAAC,EAAA,sBAAAC,EAAA,eAAAC,EAAA,mBAAAC,EAAA,2BAAAC,EAAA,qBAAAC,EAAA,YAAAC,IAAA,eAAAC,EAAAd,GAAA,IAAAe,EAAqC,sBAE9B,MAAMC,EAAkB,IAAI,MAAM,uEACA,EAC5BC,EAAa,IAAI,MAAM,qGACmC,EAC1DC,EAAS,IAAI,MAAM,sGACkC,EACrDC,EAAgB,IAAI,MAAM,8DACT,EACjBC,EAAoB,IAAI,MAAM,mDAChB,EACdC,EAAgB,IAAI,MAAM,mDACZ,EACdC,EAAkB,IAAI,MAAM,+CACpB,EAEd,SAASC,EAAgBC,EAA6B,CACzD,GAAI,CAACA,GAAWA,IAAY,KACxB,MAAMR,EACH,GAAIQ,EAAQ,aAAe,OAC9B,MAAMP,EAEV,OAAOO,CACX,CAPgBC,EAAAF,EAAA,kBAST,SAASG,EAAYC,EAAqB,CAC7C,GAAI,CAACA,GAAOA,IAAQ,KAChB,MAAMX,EACH,GAAIW,EAAI,aAAe,QAAaA,EAAI,YAAc,OACzD,MAAMT,EAEV,OAAOS,CACX,CAPgBF,EAAAC,EAAA,cAST,SAASE,EAAwBC,EAAyB,CAC7DC,EAAWD,EAAM,CAAC,eAAa,IAAK,eAAa,GAAG,EAAGT,CAAiB,CAC5E,CAFgBK,EAAAG,EAAA,0BAIT,SAASG,EAAkBC,EAAkB,CAChDF,EAAWE,EAAK,CAAC,SAAO,SAAU,SAAO,MAAO,SAAO,IAAI,EAAGX,CAAa,CAC/E,CAFgBI,EAAAM,EAAA,oBAIhB,SAASD,EAAeG,EAAWC,EAAUC,EAAkB,CAE3D,GAAI,CADUD,EAAK,KAAKE,GAAOA,IAAQH,CAAO,EAE1C,MAAME,CAEd,CALSV,EAAAK,EAAA,cAOT,IAAOO,EAAQ,CACX,gBAAArB,EACA,WAAAC,EACA,OAAAC,EACA,cAAAC,EACA,kBAAAC,EACA,cAAAC,EACA,eAAAE,EACA,WAAAG,EACA,uBAAAE,EACA,iBAAAG,EACA,gBAAAT,CACJ",
|
|
6
|
+
"names": ["errors_exports", "__export", "ECCNotEnabled", "InvalidKeyUse", "InvalidMaxValue", "KeyDoesNotExist", "NotKey", "NotKeyPair", "UnsupportedCrypto", "checkIsKey", "checkIsKeyPair", "checkValidCryptoSystem", "checkValidKeyUse", "errors_default", "__toCommonJS", "import_types", "KeyDoesNotExist", "NotKeyPair", "NotKey", "ECCNotEnabled", "UnsupportedCrypto", "InvalidKeyUse", "InvalidMaxValue", "checkIsKeyPair", "keypair", "__name", "checkIsKey", "key", "checkValidCryptoSystem", "type", "checkValid", "checkValidKeyUse", "use", "toCheck", "opts", "error", "opt", "errors_default"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
var c=Object.defineProperty;var t=(e,r)=>c(e,"name",{value:r,configurable:!0});var o=new Error("Key does not exist. Make sure you properly instantiated the keystore."),n=new Error("Retrieved a symmetric key when an asymmetric keypair was expected. Please use a different key name."),p=new Error("Retrieved an asymmetric keypair when an symmetric key was expected. Please use a different key name."),d=new Error("ECC is not enabled for this browser. Please use RSA instead."),i=new Error("Cryptosystem not supported. Please use ECC or RSA"),s=new Error("Invalid key use. Please use 'exchange' or 'write'"),u=new Error("Max must be less than 256 and greater than 0");function m(e){if(!e||e===null)throw o;if(e.privateKey===void 0)throw n;return e}t(m,"checkIsKeyPair");function l(e){if(!e||e===null)throw o;if(e.privateKey!==void 0||e.algorithm===void 0)throw p;return e}t(l,"checkIsKey");function f(e){y(e,["ecc","rsa"],i)}t(f,"checkValidCryptoSystem");function w(e){y(e,["exchange","write","signing"],s)}t(w,"checkValidKeyUse");function y(e,r,a){if(!r.some(x=>x===e))throw a}t(y,"checkValid");var g={KeyDoesNotExist:o,NotKeyPair:n,NotKey:p,ECCNotEnabled:d,UnsupportedCrypto:i,InvalidKeyUse:s,checkIsKeyPair:m,checkIsKey:l,checkValidCryptoSystem:f,checkValidKeyUse:w,InvalidMaxValue:u};export{d as ECCNotEnabled,s as InvalidKeyUse,u as InvalidMaxValue,o as KeyDoesNotExist,p as NotKey,n as NotKeyPair,i as UnsupportedCrypto,l as checkIsKey,m as checkIsKeyPair,f as checkValidCryptoSystem,w as checkValidKeyUse,g as default};
|
|
2
|
+
//# sourceMappingURL=errors.min.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/errors.ts"],
|
|
4
|
+
"sourcesContent": ["import { KeyUse, CryptoSystem } from './types.js'\n\nexport const KeyDoesNotExist = new Error('Key does not exist. Make sure you ' +\n 'properly instantiated the keystore.')\nexport const NotKeyPair = new Error('Retrieved a symmetric key when an ' +\n 'asymmetric keypair was expected. Please use a different key name.')\nexport const NotKey = new Error('Retrieved an asymmetric keypair when an ' +\n 'symmetric key was expected. Please use a different key name.')\nexport const ECCNotEnabled = new Error('ECC is not enabled for this browser.' +\n ' Please use RSA instead.')\nexport const UnsupportedCrypto = new Error('Cryptosystem not supported. ' +\n 'Please use ECC or RSA')\nexport const InvalidKeyUse = new Error('Invalid key use. Please use ' +\n \"'exchange' or 'write'\")\nexport const InvalidMaxValue = new Error('Max must be less than 256 and ' +\n ' greater than 0')\n\nexport function checkIsKeyPair (keypair: any): CryptoKeyPair {\n if (!keypair || keypair === null) {\n throw KeyDoesNotExist\n } else if (keypair.privateKey === undefined) {\n throw NotKeyPair\n }\n return keypair as CryptoKeyPair\n}\n\nexport function checkIsKey (key: any): CryptoKey {\n if (!key || key === null) {\n throw KeyDoesNotExist\n } else if (key.privateKey !== undefined || key.algorithm === undefined) {\n throw NotKey\n }\n return key\n}\n\nexport function checkValidCryptoSystem (type:CryptoSystem): void {\n checkValid(type, [CryptoSystem.ECC, CryptoSystem.RSA], UnsupportedCrypto)\n}\n\nexport function checkValidKeyUse (use:KeyUse): void {\n checkValid(use, [KeyUse.Exchange, KeyUse.Write, KeyUse.Sign], InvalidKeyUse)\n}\n\nfunction checkValid<T> (toCheck:T, opts:T[], error:Error):void {\n const match = opts.some(opt => opt === toCheck)\n if (!match) {\n throw error\n }\n}\n\nexport default {\n KeyDoesNotExist,\n NotKeyPair,\n NotKey,\n ECCNotEnabled,\n UnsupportedCrypto,\n InvalidKeyUse,\n checkIsKeyPair,\n checkIsKey,\n checkValidCryptoSystem,\n checkValidKeyUse,\n InvalidMaxValue,\n}\n"],
|
|
5
|
+
"mappings": "+EAEO,IAAMA,EAAkB,IAAI,MAAM,uEACA,EAC5BC,EAAa,IAAI,MAAM,qGACmC,EAC1DC,EAAS,IAAI,MAAM,sGACkC,EACrDC,EAAgB,IAAI,MAAM,8DACT,EACjBC,EAAoB,IAAI,MAAM,mDAChB,EACdC,EAAgB,IAAI,MAAM,mDACZ,EACdC,EAAkB,IAAI,MAAM,+CACpB,EAEd,SAASC,EAAgBC,EAA6B,CACzD,GAAI,CAACA,GAAWA,IAAY,KACxB,MAAMR,EACH,GAAIQ,EAAQ,aAAe,OAC9B,MAAMP,EAEV,OAAOO,CACX,CAPgBC,EAAAF,EAAA,kBAST,SAASG,EAAYC,EAAqB,CAC7C,GAAI,CAACA,GAAOA,IAAQ,KAChB,MAAMX,EACH,GAAIW,EAAI,aAAe,QAAaA,EAAI,YAAc,OACzD,MAAMT,EAEV,OAAOS,CACX,CAPgBF,EAAAC,EAAA,cAST,SAASE,EAAwBC,EAAyB,CAC7DC,EAAWD,EAAM,YAAmC,EAAGT,CAAiB,CAC5E,CAFgBK,EAAAG,EAAA,0BAIT,SAASG,EAAkBC,EAAkB,CAChDF,EAAWE,EAAK,6BAA2C,EAAGX,CAAa,CAC/E,CAFgBI,EAAAM,EAAA,oBAIhB,SAASD,EAAeG,EAAWC,EAAUC,EAAkB,CAE3D,GAAI,CADUD,EAAK,KAAKE,GAAOA,IAAQH,CAAO,EAE1C,MAAME,CAEd,CALSV,EAAAK,EAAA,cAOT,IAAOO,EAAQ,CACX,gBAAArB,EACA,WAAAC,EACA,OAAAC,EACA,cAAAC,EACA,kBAAAC,EACA,cAAAC,EACA,eAAAE,EACA,WAAAG,EACA,uBAAAE,EACA,iBAAAG,EACA,gBAAAT,CACJ",
|
|
6
|
+
"names": ["KeyDoesNotExist", "NotKeyPair", "NotKey", "ECCNotEnabled", "UnsupportedCrypto", "InvalidKeyUse", "InvalidMaxValue", "checkIsKeyPair", "keypair", "__name", "checkIsKey", "key", "checkValidCryptoSystem", "type", "checkValid", "checkValidKeyUse", "use", "toCheck", "opts", "error", "opt", "errors_default"]
|
|
7
|
+
}
|
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
21
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
22
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
23
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
24
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
25
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
26
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
27
|
+
mod
|
|
28
|
+
));
|
|
29
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
30
|
+
var index_exports = {};
|
|
31
|
+
__export(index_exports, {
|
|
32
|
+
aes: () => aes,
|
|
33
|
+
ecc: () => ecc,
|
|
34
|
+
getDeviceName: () => import_base.getDeviceName,
|
|
35
|
+
rsa: () => rsa
|
|
36
|
+
});
|
|
37
|
+
module.exports = __toCommonJS(index_exports);
|
|
38
|
+
__reExport(index_exports, require("./types.js"), module.exports);
|
|
39
|
+
var rsa = __toESM(require("./rsa/index.js"), 1);
|
|
40
|
+
var ecc = __toESM(require("./ecc/index.js"), 1);
|
|
41
|
+
var aes = __toESM(require("./aes/index.js"), 1);
|
|
42
|
+
__reExport(index_exports, require("./_base.js"), module.exports);
|
|
43
|
+
var import_base = require("./_base.js");
|
|
44
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/index.ts"],
|
|
4
|
+
"sourcesContent": ["export * from './types.js'\nexport * as rsa from './rsa/index.js'\nexport * as ecc from './ecc/index.js'\nexport * as aes from './aes/index.js'\nexport * from './_base.js'\nexport { getDeviceName } from './_base.js'\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,0BAAc,uBAAd;AACA,UAAqB;AACrB,UAAqB;AACrB,UAAqB;AACrB,0BAAc,uBAJd;AAKA,kBAA8B;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
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,YAAY,CAAA;AAC1B,OAAO,KAAK,GAAG,MAAM,gBAAgB,CAAA;AACrC,OAAO,KAAK,GAAG,MAAM,gBAAgB,CAAA;AACrC,OAAO,KAAK,GAAG,MAAM,gBAAgB,CAAA"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAA;AAC1B,OAAO,KAAK,GAAG,MAAM,gBAAgB,CAAA;AACrC,OAAO,KAAK,GAAG,MAAM,gBAAgB,CAAA;AACrC,OAAO,KAAK,GAAG,MAAM,gBAAgB,CAAA;AACrC,cAAc,YAAY,CAAA;AAC1B,OAAO,EAAE,aAAa,EAAE,MAAM,YAAY,CAAA"}
|
package/dist/index.js
CHANGED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/index.ts"],
|
|
4
|
+
"sourcesContent": ["export * from './types.js'\nexport * as rsa from './rsa/index.js'\nexport * as ecc from './ecc/index.js'\nexport * as aes from './aes/index.js'\nexport * from './_base.js'\nexport { getDeviceName } from './_base.js'\n"],
|
|
5
|
+
"mappings": "AAAA,cAAc;AACd,YAAY,SAAS;AACrB,YAAY,SAAS;AACrB,YAAY,SAAS;AACrB,cAAc;AACd,SAAS,qBAAqB;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";var g=Object.create;var p=Object.defineProperty;var i=Object.getOwnPropertyDescriptor;var v=Object.getOwnPropertyNames;var D=Object.getPrototypeOf,N=Object.prototype.hasOwnProperty;var b=(r,e)=>{for(var o in e)p(r,o,{get:e[o],enumerable:!0})},f=(r,e,o,s)=>{if(e&&typeof e=="object"||typeof e=="function")for(let a of v(e))!N.call(r,a)&&a!==o&&p(r,a,{get:()=>e[a],enumerable:!(s=i(e,a))||s.enumerable});return r},t=(r,e,o)=>(f(r,e,"default"),o&&f(o,e,"default")),x=(r,e,o)=>(o=r!=null?g(D(r)):{},f(e||!r||!r.__esModule?p(o,"default",{value:r,enumerable:!0}):o,r)),d=r=>f(p({},"__esModule",{value:!0}),r);var m={};b(m,{aes:()=>k,ecc:()=>j,getDeviceName:()=>c.getDeviceName,rsa:()=>h});module.exports=d(m);t(m,require("./types.js"),module.exports);var h=x(require("./rsa/index.js"),1),j=x(require("./ecc/index.js"),1),k=x(require("./aes/index.js"),1);t(m,require("./_base.js"),module.exports);var c=require("./_base.js");
|
|
2
|
+
//# sourceMappingURL=index.min.cjs.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/index.ts"],
|
|
4
|
+
"sourcesContent": ["export * from './types.js'\nexport * as rsa from './rsa/index.js'\nexport * as ecc from './ecc/index.js'\nexport * as aes from './aes/index.js'\nexport * from './_base.js'\nexport { getDeviceName } from './_base.js'\n"],
|
|
5
|
+
"mappings": "wmBAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,SAAAE,EAAA,QAAAC,EAAA,0CAAAC,IAAA,eAAAC,EAAAL,GAAAM,EAAAN,EAAc,sBAAd,gBACA,IAAAI,EAAqB,+BACrBD,EAAqB,+BACrBD,EAAqB,+BACrBI,EAAAN,EAAc,sBAJd,gBAKA,IAAAO,EAA8B",
|
|
6
|
+
"names": ["index_exports", "__export", "aes", "ecc", "rsa", "__toCommonJS", "__reExport", "import_base"]
|
|
7
|
+
}
|