@sovrahq/kms-core 1.4.0-4
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/LICENSE +201 -0
- package/dist/decorators/vc-suite.decorator.d.ts +4 -0
- package/dist/decorators/vc-suite.decorator.js +12 -0
- package/dist/decorators/vc-suite.decorator.js.map +1 -0
- package/dist/index.d.ts +16 -0
- package/dist/index.js +33 -0
- package/dist/index.js.map +1 -0
- package/dist/models/keypair.d.ts +10 -0
- package/dist/models/keypair.js +3 -0
- package/dist/models/keypair.js.map +1 -0
- package/dist/models/kms-storage.d.ts +7 -0
- package/dist/models/kms-storage.js +3 -0
- package/dist/models/kms-storage.js.map +1 -0
- package/dist/models/kms.d.ts +51 -0
- package/dist/models/kms.js +3 -0
- package/dist/models/kms.js.map +1 -0
- package/dist/models/lang.d.ts +6 -0
- package/dist/models/lang.js +11 -0
- package/dist/models/lang.js.map +1 -0
- package/dist/models/secret.d.ts +4 -0
- package/dist/models/secret.js +3 -0
- package/dist/models/secret.js.map +1 -0
- package/dist/models/suites/bbsbls2020.suite.d.ts +6 -0
- package/dist/models/suites/bbsbls2020.suite.js +3 -0
- package/dist/models/suites/bbsbls2020.suite.js.map +1 -0
- package/dist/models/suites/didcomm/didcomm-message-media-type.d.ts +88 -0
- package/dist/models/suites/didcomm/didcomm-message-media-type.js +24 -0
- package/dist/models/suites/didcomm/didcomm-message-media-type.js.map +1 -0
- package/dist/models/suites/didcomm/didcomm-message.d.ts +7 -0
- package/dist/models/suites/didcomm/didcomm-message.js +3 -0
- package/dist/models/suites/didcomm/didcomm-message.js.map +1 -0
- package/dist/models/suites/didcomm/didcomm-packed-message.d.ts +22 -0
- package/dist/models/suites/didcomm/didcomm-packed-message.js +3 -0
- package/dist/models/suites/didcomm/didcomm-packed-message.js.map +1 -0
- package/dist/models/suites/didcomm/didcomm-signed-message.d.ts +41 -0
- package/dist/models/suites/didcomm/didcomm-signed-message.js +3 -0
- package/dist/models/suites/didcomm/didcomm-signed-message.js.map +1 -0
- package/dist/models/suites/didcomm.suite.d.ts +26 -0
- package/dist/models/suites/didcomm.suite.js +3 -0
- package/dist/models/suites/didcomm.suite.js.map +1 -0
- package/dist/models/suites/es256k-signer.suite.d.ts +15 -0
- package/dist/models/suites/es256k-signer.suite.js +3 -0
- package/dist/models/suites/es256k-signer.suite.js.map +1 -0
- package/dist/models/suites/selective-disclosure-zkp.suite.d.ts +6 -0
- package/dist/models/suites/selective-disclosure-zkp.suite.js +3 -0
- package/dist/models/suites/selective-disclosure-zkp.suite.js.map +1 -0
- package/dist/models/suites/vc.suite.d.ts +13 -0
- package/dist/models/suites/vc.suite.js +3 -0
- package/dist/models/suites/vc.suite.js.map +1 -0
- package/dist/models/supported-suites.d.ts +13 -0
- package/dist/models/supported-suites.js +27 -0
- package/dist/models/supported-suites.js.map +1 -0
- package/dist/utils/base-converter.d.ts +28 -0
- package/dist/utils/base-converter.js +113 -0
- package/dist/utils/base-converter.js.map +1 -0
- package/package.json +40 -0
- package/readme.md +57 -0
- package/src/decorators/vc-suite.decorator.ts +11 -0
- package/src/index.ts +16 -0
- package/src/models/keypair.ts +14 -0
- package/src/models/kms-storage.ts +10 -0
- package/src/models/kms.ts +49 -0
- package/src/models/lang.ts +6 -0
- package/src/models/secret.ts +4 -0
- package/src/models/suites/bbsbls2020.suite.ts +8 -0
- package/src/models/suites/didcomm/didcomm-message-media-type.ts +103 -0
- package/src/models/suites/didcomm/didcomm-message.ts +8 -0
- package/src/models/suites/didcomm/didcomm-packed-message.ts +20 -0
- package/src/models/suites/didcomm/didcomm-signed-message.ts +40 -0
- package/src/models/suites/didcomm.suite.ts +34 -0
- package/src/models/suites/es256k-signer.suite.ts +15 -0
- package/src/models/suites/selective-disclosure-zkp.suite.ts +7 -0
- package/src/models/suites/vc.suite.ts +16 -0
- package/src/models/supported-suites.ts +22 -0
- package/src/utils/base-converter.ts +137 -0
- package/tsconfig.json +20 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"didcomm-signed-message.js","sourceRoot":"","sources":["../../../../src/models/suites/didcomm/didcomm-signed-message.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { IKeyPair } from "../keypair";
|
|
2
|
+
import { DIDCommMessagePacking, IDIDCommMessage, IPackedDIDCommMessage } from "./didcomm/didcomm-message-media-type";
|
|
3
|
+
export interface IDidCommKeyPair extends IKeyPair {
|
|
4
|
+
keyType: 'curve25519' | 'Ed25519' | 'x25519' | 'Secp256k1';
|
|
5
|
+
}
|
|
6
|
+
export interface IDIDCommSuite {
|
|
7
|
+
load(secrets: IDidCommKeyPair): any;
|
|
8
|
+
create(): Promise<IDidCommKeyPair>;
|
|
9
|
+
pack(encrypt: boolean, toHexKeys: string[], documentToSign: string): Promise<string>;
|
|
10
|
+
unpack: (encryptedDocument: string) => Promise<any>;
|
|
11
|
+
}
|
|
12
|
+
export interface IDIDCommV2Suite {
|
|
13
|
+
load(secrets: IDidCommKeyPair): any;
|
|
14
|
+
create(): Promise<IDidCommKeyPair>;
|
|
15
|
+
pack(params: {
|
|
16
|
+
senderVerificationMethodId: string;
|
|
17
|
+
toKeys: {
|
|
18
|
+
verificationMethodId: string;
|
|
19
|
+
publicKeyHex: string;
|
|
20
|
+
publicKeyCrv?: string;
|
|
21
|
+
}[];
|
|
22
|
+
message: IDIDCommMessage;
|
|
23
|
+
packing: DIDCommMessagePacking;
|
|
24
|
+
}): Promise<IPackedDIDCommMessage>;
|
|
25
|
+
unpack: (jwe: any) => Promise<any>;
|
|
26
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"didcomm.suite.js","sourceRoot":"","sources":["../../../src/models/suites/didcomm.suite.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { LANG } from "../lang";
|
|
2
|
+
import { IKeyPair } from "../keypair";
|
|
3
|
+
import { IJWK } from "../../utils/base-converter";
|
|
4
|
+
export interface IES256kKeyPair extends IKeyPair {
|
|
5
|
+
readonly mnemonic?: string;
|
|
6
|
+
readonly curve?: string;
|
|
7
|
+
}
|
|
8
|
+
export interface IES256kSuite {
|
|
9
|
+
load(IEthrKeyPair: IES256kKeyPair): Promise<void>;
|
|
10
|
+
create(params: {
|
|
11
|
+
lang: LANG;
|
|
12
|
+
}): Promise<IES256kKeyPair>;
|
|
13
|
+
sign(content: string): Promise<string>;
|
|
14
|
+
verifySignature(originalContent: string, flatSignature: any, publicKey: IJWK): Promise<boolean>;
|
|
15
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"es256k-signer.suite.js","sourceRoot":"","sources":["../../../src/models/suites/es256k-signer.suite.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { DIDDocument } from "@sovrahq/did-core";
|
|
2
|
+
import { VerifiableCredential } from "@sovrahq/vc-core";
|
|
3
|
+
import { IVCSuite } from "./vc.suite";
|
|
4
|
+
export interface SelectiveDisclosureZKPSuite extends IVCSuite {
|
|
5
|
+
deriveVC(signedDocument: VerifiableCredential, deriveProofFrame: string, didDocumentResolver: (did: string) => Promise<DIDDocument>): Promise<VerifiableCredential>;
|
|
6
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"selective-disclosure-zkp.suite.js","sourceRoot":"","sources":["../../../src/models/suites/selective-disclosure-zkp.suite.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { Purpose } from "@sovrahq/did-core";
|
|
2
|
+
import { IKeyPair } from "../keypair";
|
|
3
|
+
export interface IVCJsonLDKeyPair extends IKeyPair {
|
|
4
|
+
readonly id?: string;
|
|
5
|
+
readonly controller?: string;
|
|
6
|
+
}
|
|
7
|
+
export interface IVCSuite {
|
|
8
|
+
loadSuite(params: {
|
|
9
|
+
secrets: IVCJsonLDKeyPair;
|
|
10
|
+
useCache: boolean;
|
|
11
|
+
}): any;
|
|
12
|
+
sign: (documentToSign: string, did: string, verificationMethodId: string, porpuse: Purpose) => Promise<any>;
|
|
13
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"vc.suite.js","sourceRoot":"","sources":["../../../src/models/suites/vc.suite.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export declare enum Suite {
|
|
2
|
+
ES256k = "es256k",
|
|
3
|
+
DIDComm = "didcomm",
|
|
4
|
+
DIDCommV2 = "didcommv2",
|
|
5
|
+
Bbsbls2020 = "bbsbls2020",
|
|
6
|
+
RsaSignature2018 = "rsaSignature2018",
|
|
7
|
+
Ed25519Suite = "ed25519Suite"
|
|
8
|
+
}
|
|
9
|
+
export declare enum VCSuite {
|
|
10
|
+
Bbsbls2020 = "bbsbls2020",
|
|
11
|
+
RsaSignature2018 = "rsaSignature2018"
|
|
12
|
+
}
|
|
13
|
+
export declare function getTypeBySuite(suite: Suite): "X25519KeyAgreementKey2019" | "Bls12381G1Key2020" | "RsaSignature2018";
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getTypeBySuite = exports.VCSuite = exports.Suite = void 0;
|
|
4
|
+
var Suite;
|
|
5
|
+
(function (Suite) {
|
|
6
|
+
Suite["ES256k"] = "es256k";
|
|
7
|
+
Suite["DIDComm"] = "didcomm";
|
|
8
|
+
Suite["DIDCommV2"] = "didcommv2";
|
|
9
|
+
Suite["Bbsbls2020"] = "bbsbls2020";
|
|
10
|
+
Suite["RsaSignature2018"] = "rsaSignature2018";
|
|
11
|
+
Suite["Ed25519Suite"] = "ed25519Suite";
|
|
12
|
+
})(Suite = exports.Suite || (exports.Suite = {}));
|
|
13
|
+
var VCSuite;
|
|
14
|
+
(function (VCSuite) {
|
|
15
|
+
VCSuite["Bbsbls2020"] = "bbsbls2020";
|
|
16
|
+
VCSuite["RsaSignature2018"] = "rsaSignature2018";
|
|
17
|
+
})(VCSuite = exports.VCSuite || (exports.VCSuite = {}));
|
|
18
|
+
function getTypeBySuite(suite) {
|
|
19
|
+
switch (suite) {
|
|
20
|
+
case Suite.DIDComm: return "X25519KeyAgreementKey2019";
|
|
21
|
+
case Suite.Bbsbls2020: return "Bls12381G1Key2020";
|
|
22
|
+
case Suite.RsaSignature2018: return "RsaSignature2018";
|
|
23
|
+
}
|
|
24
|
+
return null;
|
|
25
|
+
}
|
|
26
|
+
exports.getTypeBySuite = getTypeBySuite;
|
|
27
|
+
//# sourceMappingURL=supported-suites.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"supported-suites.js","sourceRoot":"","sources":["../../src/models/supported-suites.ts"],"names":[],"mappings":";;;AAAA,IAAY,KAOX;AAPD,WAAY,KAAK;IACb,0BAAiB,CAAA;IACjB,4BAAmB,CAAA;IACnB,gCAAuB,CAAA;IACvB,kCAAyB,CAAA;IACzB,8CAAqC,CAAA;IACrC,sCAA6B,CAAA;AACjC,CAAC,EAPW,KAAK,GAAL,aAAK,KAAL,aAAK,QAOhB;AAED,IAAY,OAGX;AAHD,WAAY,OAAO;IACf,oCAAyB,CAAA;IACzB,gDAAqC,CAAA;AACzC,CAAC,EAHW,OAAO,GAAP,eAAO,KAAP,eAAO,QAGlB;AAED,SAAgB,cAAc,CAAC,KAAY;IACvC,QAAQ,KAAK,EAAE;QACX,KAAK,KAAK,CAAC,OAAO,CAAC,CAAC,OAAO,2BAA2B,CAAC;QACvD,KAAK,KAAK,CAAC,UAAU,CAAC,CAAC,OAAO,mBAAmB,CAAC;QAClD,KAAK,KAAK,CAAC,gBAAgB,CAAC,CAAC,OAAO,kBAAkB,CAAC;KAC1D;IACD,OAAO,IAAI,CAAC;AAChB,CAAC;AAPD,wCAOC"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
export declare enum Base {
|
|
2
|
+
Hex = "hex",
|
|
3
|
+
Base58 = "base58",
|
|
4
|
+
Base64 = "base64",
|
|
5
|
+
JWK = "jwk"
|
|
6
|
+
}
|
|
7
|
+
export interface IJWK {
|
|
8
|
+
kty: string;
|
|
9
|
+
crv: string;
|
|
10
|
+
x: string;
|
|
11
|
+
y?: string;
|
|
12
|
+
}
|
|
13
|
+
export declare class BaseConverter {
|
|
14
|
+
private static hex2base64url;
|
|
15
|
+
static getPrivateJWKfromHex(_privKey: string, pubKey: string): {
|
|
16
|
+
crv: string;
|
|
17
|
+
kty: string;
|
|
18
|
+
d: string;
|
|
19
|
+
x: string;
|
|
20
|
+
y: string;
|
|
21
|
+
};
|
|
22
|
+
static convert(value: any, fromBase: Base, toBase: Base, keyType?: string): any;
|
|
23
|
+
private static hexToJWK;
|
|
24
|
+
private static base64url;
|
|
25
|
+
private static JWKToHex;
|
|
26
|
+
private static fromHexString;
|
|
27
|
+
private static toHexString;
|
|
28
|
+
}
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.BaseConverter = exports.Base = void 0;
|
|
4
|
+
var multibase = require("multibase");
|
|
5
|
+
var bs58 = require("bs58");
|
|
6
|
+
var base64_1 = require("multiformats/bases/base64");
|
|
7
|
+
var text_encoding_1 = require("text-encoding");
|
|
8
|
+
var Base;
|
|
9
|
+
(function (Base) {
|
|
10
|
+
Base["Hex"] = "hex";
|
|
11
|
+
Base["Base58"] = "base58";
|
|
12
|
+
Base["Base64"] = "base64";
|
|
13
|
+
Base["JWK"] = "jwk";
|
|
14
|
+
})(Base = exports.Base || (exports.Base = {}));
|
|
15
|
+
var BaseConverter = /** @class */ (function () {
|
|
16
|
+
function BaseConverter() {
|
|
17
|
+
}
|
|
18
|
+
BaseConverter.hex2base64url = function (dataHex) {
|
|
19
|
+
var buffer = Buffer.from(dataHex, "hex");
|
|
20
|
+
var base64 = buffer.toString("base64");
|
|
21
|
+
var base64url = base64
|
|
22
|
+
.replace(/\+/g, "-")
|
|
23
|
+
.replace(/\//g, "_")
|
|
24
|
+
.replace(/=/g, "");
|
|
25
|
+
return base64url;
|
|
26
|
+
};
|
|
27
|
+
BaseConverter.getPrivateJWKfromHex = function (_privKey, pubKey) {
|
|
28
|
+
var privKey = _privKey;
|
|
29
|
+
// remove 0x and 0x04 to be used in jose library
|
|
30
|
+
privKey = privKey.replace("0x", "");
|
|
31
|
+
pubKey = pubKey.replace("0x04", "");
|
|
32
|
+
return {
|
|
33
|
+
crv: "secp256k1",
|
|
34
|
+
kty: "EC",
|
|
35
|
+
d: BaseConverter.hex2base64url(privKey),
|
|
36
|
+
x: BaseConverter.hex2base64url(pubKey.substr(0, 64)),
|
|
37
|
+
y: BaseConverter.hex2base64url(pubKey.substr(64, 64))
|
|
38
|
+
};
|
|
39
|
+
};
|
|
40
|
+
BaseConverter.convert = function (value, fromBase, toBase, keyType) {
|
|
41
|
+
if (fromBase == Base.Base58 && toBase == Base.Hex) {
|
|
42
|
+
var hex = this.toHexString(bs58.decode(value));
|
|
43
|
+
return hex;
|
|
44
|
+
}
|
|
45
|
+
if (fromBase == Base.Hex && toBase == Base.Base58) {
|
|
46
|
+
return bs58.encode(Buffer.from(value, "hex"));
|
|
47
|
+
}
|
|
48
|
+
if (fromBase == Base.Hex && toBase == Base.JWK) {
|
|
49
|
+
return this.hexToJWK(value, keyType);
|
|
50
|
+
}
|
|
51
|
+
if (fromBase == Base.JWK && toBase == Base.Hex) {
|
|
52
|
+
return this.JWKToHex(value);
|
|
53
|
+
}
|
|
54
|
+
if (fromBase == Base.Base58 && toBase == Base.JWK) {
|
|
55
|
+
var hex = this.toHexString(bs58.decode(value));
|
|
56
|
+
return this.hexToJWK(hex, keyType);
|
|
57
|
+
}
|
|
58
|
+
if (fromBase == Base.JWK && toBase == Base.Base58) {
|
|
59
|
+
return bs58.encode(Buffer.from(this.JWKToHex(value).replace("0x", ""), "hex"));
|
|
60
|
+
}
|
|
61
|
+
};
|
|
62
|
+
BaseConverter.hexToJWK = function (value, keyType) {
|
|
63
|
+
// OKP support (Ed25519 / X25519) — x-only, no y
|
|
64
|
+
if (keyType === 'OKP' || keyType === 'Ed25519' || keyType === 'X25519') {
|
|
65
|
+
var hex = value.replace('0x04', '').replace('0x', '');
|
|
66
|
+
var xBuf = Buffer.from(hex, 'hex');
|
|
67
|
+
var crv = keyType === 'X25519' ? 'X25519' : 'Ed25519';
|
|
68
|
+
var b64 = xBuf.toString('base64').replace(/\+/g, '-').replace(/\//g, '_').replace(/=+$/, '');
|
|
69
|
+
return { kty: 'OKP', crv: crv, x: b64 };
|
|
70
|
+
}
|
|
71
|
+
value = value.replace("0x04", "");
|
|
72
|
+
value = value.replace("0x", "");
|
|
73
|
+
return {
|
|
74
|
+
kty: "EC",
|
|
75
|
+
crv: keyType,
|
|
76
|
+
x: this.base64url(Buffer.from(value.substring(0, value.length / 2), "hex")),
|
|
77
|
+
y: this.base64url(Buffer.from(value.substring(value.length / 2), "hex")),
|
|
78
|
+
};
|
|
79
|
+
};
|
|
80
|
+
BaseConverter.base64url = function (buffer) {
|
|
81
|
+
var decoder = new text_encoding_1.TextDecoder();
|
|
82
|
+
var bytes = multibase.encode("base64url", buffer);
|
|
83
|
+
return decoder.decode(bytes).slice(1);
|
|
84
|
+
};
|
|
85
|
+
BaseConverter.JWKToHex = function (value) {
|
|
86
|
+
// OKP support (Ed25519, X25519) — only x, no y
|
|
87
|
+
if (value.kty === 'OKP' || value.crv === 'Ed25519' || value.crv === 'X25519') {
|
|
88
|
+
var xStr = value.x || '';
|
|
89
|
+
var padded = xStr.replace(/-/g, '+').replace(/_/g, '/');
|
|
90
|
+
while (padded.length % 4)
|
|
91
|
+
padded += '=';
|
|
92
|
+
return '0x' + Buffer.from(padded, 'base64').toString('hex');
|
|
93
|
+
}
|
|
94
|
+
if (value.kty == "RSA" && value.n) {
|
|
95
|
+
return "0x".concat(Buffer.from(base64_1.base64url.baseDecode(value.n)).toString("hex"));
|
|
96
|
+
}
|
|
97
|
+
else if (value.x && value.y) {
|
|
98
|
+
var b1 = Buffer.from(base64_1.base64url.baseDecode(value.x)).toString("hex");
|
|
99
|
+
var b2 = Buffer.from(base64_1.base64url.baseDecode(value.y)).toString("hex");
|
|
100
|
+
return "0x".concat(b1).concat(b2);
|
|
101
|
+
}
|
|
102
|
+
throw new Error("This JWK To Hex conversion is not supported: " + JSON.stringify(value));
|
|
103
|
+
};
|
|
104
|
+
BaseConverter.fromHexString = function (hexString) {
|
|
105
|
+
return Uint8Array.from(hexString.match(/.{1,2}/g).map(function (byte) { return parseInt(byte, 16); }));
|
|
106
|
+
};
|
|
107
|
+
BaseConverter.toHexString = function (bytes) {
|
|
108
|
+
return bytes.reduce(function (str, byte) { return str + byte.toString(16).padStart(2, "0"); }, "");
|
|
109
|
+
};
|
|
110
|
+
return BaseConverter;
|
|
111
|
+
}());
|
|
112
|
+
exports.BaseConverter = BaseConverter;
|
|
113
|
+
//# sourceMappingURL=base-converter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"base-converter.js","sourceRoot":"","sources":["../../src/utils/base-converter.ts"],"names":[],"mappings":";;;AAAA,IAAI,SAAS,GAAG,OAAO,CAAC,WAAW,CAAC,CAAC;AACrC,IAAI,IAAI,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;AAC3B,oDAA0E;AAC1E,+CAA4C;AAE5C,IAAY,IAKX;AALD,WAAY,IAAI;IACd,mBAAW,CAAA;IACX,yBAAiB,CAAA;IACjB,yBAAiB,CAAA;IACjB,mBAAW,CAAA;AACb,CAAC,EALW,IAAI,GAAJ,YAAI,KAAJ,YAAI,QAKf;AASD;IAAA;IAqHA,CAAC;IApHgB,2BAAa,GAA5B,UAA6B,OAAO;QAClC,IAAM,MAAM,GAAG,MAAM,CAAC,IAAI,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;QAC3C,IAAM,MAAM,GAAG,MAAM,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;QACzC,IAAM,SAAS,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KAAK,CAAC,SAAS,CAAC,CAAC,GAAG,CAAC,UAAC,IAAI,IAAK,OAAA,QAAQ,CAAC,IAAI,EAAE,EAAE,CAAC,EAAlB,CAAkB,CAAC,CAC7D;IAFD,CAEC,CAAC;IAEW,yBAAW,GAAG,UAAC,KAAK;QACjC,OAAA,KAAK,CAAC,MAAM,CAAC,UAAC,GAAG,EAAE,IAAI,IAAK,OAAA,GAAG,GAAG,IAAI,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAC,EAAxC,CAAwC,EAAE,EAAE,CAAC;IAAzE,CAAyE,CAAC;IAC9E,oBAAC;CAAA,AArHD,IAqHC;AArHY,sCAAa"}
|
package/package.json
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@sovrahq/kms-core",
|
|
3
|
+
"version": "1.4.0-4",
|
|
4
|
+
"description": "",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"typings": "dist/index.d.ts",
|
|
7
|
+
"scripts": {
|
|
8
|
+
"start": "ts-node src/index.ts",
|
|
9
|
+
"build": "tsc",
|
|
10
|
+
"test": "echo \"Error: no test specified\" && exit 1"
|
|
11
|
+
},
|
|
12
|
+
"keywords": [],
|
|
13
|
+
"author": "QuarkID",
|
|
14
|
+
"license": "Apache-2.0",
|
|
15
|
+
"devDependencies": {
|
|
16
|
+
"@types/node": "^17.0.27",
|
|
17
|
+
"jest": "^28.0.3",
|
|
18
|
+
"nodemon": "^2.0.15",
|
|
19
|
+
"ts-node": "^10.4.0",
|
|
20
|
+
"typescript": "^4.5.4"
|
|
21
|
+
},
|
|
22
|
+
"peerDependencies": {
|
|
23
|
+
"@sovrahq/did-core": "1.1.2",
|
|
24
|
+
"@sovrahq/vc-core": "1.1.0-2"
|
|
25
|
+
},
|
|
26
|
+
"dependencies": {
|
|
27
|
+
"@sovrahq/did-core": "1.1.2",
|
|
28
|
+
"@sovrahq/vc-core": "1.1.0-2",
|
|
29
|
+
"base64url": "^3.0.1",
|
|
30
|
+
"bs58": "^5.0.0",
|
|
31
|
+
"did-jwt": "^6.11.0",
|
|
32
|
+
"jsonld": "^5.2.0",
|
|
33
|
+
"multibase": "^4.0.6",
|
|
34
|
+
"multiformats": "^9.6.5",
|
|
35
|
+
"text-encoding": "^0.7.0"
|
|
36
|
+
},
|
|
37
|
+
"publishConfig": {
|
|
38
|
+
"access": "public"
|
|
39
|
+
}
|
|
40
|
+
}
|
package/readme.md
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
# Extrimian - KMS Core
|
|
2
|
+
This package exposes interfaces to be implemented by KMS concrete implementations like Extrimian KMS Client.
|
|
3
|
+
|
|
4
|
+
## Interfaces and Enums
|
|
5
|
+
```
|
|
6
|
+
export interface KMSStorage {
|
|
7
|
+
add(key: string, data: any): Promise<void>;
|
|
8
|
+
get(key: string): Promise<any>;
|
|
9
|
+
getAll(): Promise<Map<string, any>>;
|
|
10
|
+
update(key: string, data: any);
|
|
11
|
+
remove(key: string);
|
|
12
|
+
}
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
```
|
|
16
|
+
export interface IKeyPair {
|
|
17
|
+
readonly privateKey: string;
|
|
18
|
+
readonly publicKey: string;
|
|
19
|
+
}
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
```
|
|
23
|
+
export interface IKMS {
|
|
24
|
+
create(suite: Suite): Promise<{ publicKeyJWK: IJWK }>;
|
|
25
|
+
sign(suite: Suite, publicKeyJWK: IJWK, content: any): Promise<string>;
|
|
26
|
+
signVC(suite: Suite,
|
|
27
|
+
publicKeyJWK: IJWK,
|
|
28
|
+
vc: any,
|
|
29
|
+
did: string,
|
|
30
|
+
verificationMethodId: string,
|
|
31
|
+
purpose: Purpose): Promise<VerifiableCredential>;
|
|
32
|
+
pack(publicKeyJWK: IJWK, toHexPublicKeys: string[], contentToSign: string): Promise<string>;
|
|
33
|
+
unpack(publicKeyJWK: IJWK, packedContent: string): Promise<string>;
|
|
34
|
+
export(publicKeyJWK: IJWK): Promise<any>;
|
|
35
|
+
getPublicKeysBySuiteType(suite: Suite): Promise<IJWK[]>;
|
|
36
|
+
getAllPublicKeys(): Promise<IJWK[]>;
|
|
37
|
+
}
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
```
|
|
41
|
+
export enum LANG {
|
|
42
|
+
en = 'en',
|
|
43
|
+
es = 'es',
|
|
44
|
+
fr = 'fr',
|
|
45
|
+
it = 'it',
|
|
46
|
+
}
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
```
|
|
50
|
+
export enum Suite {
|
|
51
|
+
ES256k = "es256k",
|
|
52
|
+
DIDComm = "didcomm",
|
|
53
|
+
Bbsbls2020 = "bbsbls2020"
|
|
54
|
+
}
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
This package does not add functionality or features, it just exposes interfaces to be used by other packages.
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { Suite } from "../models/supported-suites";
|
|
2
|
+
|
|
3
|
+
const suites: Map<Suite, new (...args: never[]) => any> = new Map();
|
|
4
|
+
|
|
5
|
+
const suiteDecorator = (suiteType: any) => {
|
|
6
|
+
return (target: new (...args: never[]) => any) => {
|
|
7
|
+
suites.set(suiteType, target);
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export { suiteDecorator, suites };
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export * from './decorators/vc-suite.decorator';
|
|
2
|
+
export * from './models/keypair';
|
|
3
|
+
export * from './models/kms-storage';
|
|
4
|
+
export * from './models/kms';
|
|
5
|
+
export * from './models/lang';
|
|
6
|
+
export * from './models/secret';
|
|
7
|
+
export * from './models/suites/bbsbls2020.suite';
|
|
8
|
+
export * from './models/suites/didcomm.suite';
|
|
9
|
+
export * from './models/suites/didcomm/didcomm-message-media-type';
|
|
10
|
+
export * from './models/suites/didcomm/didcomm-signed-message';
|
|
11
|
+
export * from './models/suites/didcomm/didcomm-packed-message';
|
|
12
|
+
export * from "./models/suites/selective-disclosure-zkp.suite";
|
|
13
|
+
export * from './models/suites/es256k-signer.suite';
|
|
14
|
+
export * from './models/suites/vc.suite';
|
|
15
|
+
export * from './models/supported-suites';
|
|
16
|
+
export * from "./utils/base-converter";
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { IJWK } from "../utils/base-converter";
|
|
2
|
+
import { Suite } from "./supported-suites";
|
|
3
|
+
|
|
4
|
+
export interface IKeyPair {
|
|
5
|
+
readonly privateKey: string;
|
|
6
|
+
readonly publicKey: string;
|
|
7
|
+
|
|
8
|
+
readonly privateKeyJWK?: IJWK;
|
|
9
|
+
readonly publicKeyJWK?: IJWK;
|
|
10
|
+
|
|
11
|
+
readonly keyType?: string;
|
|
12
|
+
|
|
13
|
+
suite?: Suite;
|
|
14
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { Secret } from "./secret";
|
|
2
|
+
import { Suite } from "./supported-suites";
|
|
3
|
+
|
|
4
|
+
export interface KMSStorage {
|
|
5
|
+
add(key: string, data: any): Promise<void>;
|
|
6
|
+
get(key: string): Promise<any>;
|
|
7
|
+
getAll(): Promise<Map<string, any>>;
|
|
8
|
+
update(key: string, data: any);
|
|
9
|
+
remove(key: string);
|
|
10
|
+
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { DIDCommMessage, Purpose } from "@sovrahq/did-core";
|
|
2
|
+
import { VerifiableCredential } from "@sovrahq/vc-core";
|
|
3
|
+
import { IJWK } from "../utils/base-converter";
|
|
4
|
+
import { IKeyPair } from "./keypair";
|
|
5
|
+
import { DIDCommMessagePacking, IDIDCommMessage, IPackedDIDCommMessage } from "./suites/didcomm/didcomm-message-media-type";
|
|
6
|
+
import { DIDCommPackedMessage } from "./suites/didcomm/didcomm-packed-message";
|
|
7
|
+
import { Suite } from "./supported-suites";
|
|
8
|
+
|
|
9
|
+
export interface IKMS {
|
|
10
|
+
create(suite: Suite): Promise<{ publicKeyJWK: IJWK }>;
|
|
11
|
+
sign(suite: Suite, publicKeyJWK: IJWK, content: any): Promise<string>;
|
|
12
|
+
verifySignature(publicKeyJWK: IJWK, originalContent: string, signature: string): Promise<boolean>;
|
|
13
|
+
signVC(suite: Suite,
|
|
14
|
+
publicKeyJWK: IJWK,
|
|
15
|
+
vc: any,
|
|
16
|
+
did: string,
|
|
17
|
+
verificationMethodId: string,
|
|
18
|
+
purpose: Purpose): Promise<VerifiableCredential>;
|
|
19
|
+
signVCPresentation(params: {
|
|
20
|
+
publicKeyJWK: IJWK,
|
|
21
|
+
presentationObject: any,
|
|
22
|
+
did: string,
|
|
23
|
+
verificationMethodId: string,
|
|
24
|
+
purpose: Purpose
|
|
25
|
+
}): Promise<any>;
|
|
26
|
+
deriveVC(params: { vc: VerifiableCredential, frame: any }): Promise<VerifiableCredential>;
|
|
27
|
+
pack(publicKeyJWK: IJWK, toHexPublicKeys: string[], contentToSign: string): Promise<string>;
|
|
28
|
+
packv2(publicKeyJWK: IJWK,
|
|
29
|
+
senderVerificationMethodId: string,
|
|
30
|
+
toHexPublicKeys: string[],
|
|
31
|
+
message: IDIDCommMessage,
|
|
32
|
+
packing: DIDCommMessagePacking): Promise<IPackedDIDCommMessage>;
|
|
33
|
+
packDIDCommV2(params: {
|
|
34
|
+
senderVerificationMethodId?: string,
|
|
35
|
+
recipientVerificationMethodIds: string[],
|
|
36
|
+
message: IDIDCommMessage,
|
|
37
|
+
packing: DIDCommMessagePacking
|
|
38
|
+
}): Promise<{ packedMessage: any | DIDCommPackedMessage }>;
|
|
39
|
+
unpack(publicKeyJWK: IJWK, packedContent: string): Promise<string>;
|
|
40
|
+
unpackv2(publicKeyJWK: IJWK, jwe: any): Promise<string>;
|
|
41
|
+
unpackvDIDCommV2(receiptDID: string, packedMessage: any | DIDCommPackedMessage): Promise<{ message: DIDCommMessage, metaData: { packing: DIDCommMessagePacking } }>;
|
|
42
|
+
export(publicKeyJWK: IJWK): Promise<any>;
|
|
43
|
+
import(key: {
|
|
44
|
+
publicKeyHex: string,
|
|
45
|
+
secret: IKeyPair
|
|
46
|
+
}): Promise<void>;
|
|
47
|
+
getPublicKeysBySuiteType(suite: Suite): Promise<IJWK[]>;
|
|
48
|
+
getAllPublicKeys(): Promise<IJWK[]>;
|
|
49
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { IKeyPair } from "../keypair";
|
|
2
|
+
import { Purpose } from "@sovrahq/did-core";
|
|
3
|
+
import { IVCJsonLDKeyPair, IVCSuite } from "./vc.suite";
|
|
4
|
+
|
|
5
|
+
export interface IBbsBls2020Suite extends IVCSuite {
|
|
6
|
+
create: () => Promise<IVCJsonLDKeyPair>;
|
|
7
|
+
sign: (documentToSign: string, did: string, verificationMethodId: string, porpuse: Purpose) => Promise<any>;
|
|
8
|
+
}
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The DIDComm message structure.
|
|
3
|
+
* See https://identity.foundation/didcomm-messaging/spec/#plaintext-message-structure
|
|
4
|
+
*
|
|
5
|
+
* @beta This API may change without a BREAKING CHANGE notice.
|
|
6
|
+
*/
|
|
7
|
+
export interface IDIDCommMessage {
|
|
8
|
+
type: string
|
|
9
|
+
from?: string
|
|
10
|
+
to: string[]
|
|
11
|
+
thid?: string
|
|
12
|
+
pthid?: string
|
|
13
|
+
id: string
|
|
14
|
+
expires_time?: string
|
|
15
|
+
created_time?: string
|
|
16
|
+
next?: string
|
|
17
|
+
from_prior?: string
|
|
18
|
+
body: any
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Extra options when packing a DIDComm message.
|
|
23
|
+
*
|
|
24
|
+
* @beta - This API may change without a BREAKING CHANGE notice.
|
|
25
|
+
*/
|
|
26
|
+
export interface IDIDCommOptions {
|
|
27
|
+
/**
|
|
28
|
+
* Add extra recipients for the packed message.
|
|
29
|
+
*/
|
|
30
|
+
bcc?: string[]
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Represents different DIDComm v2 message encapsulation.
|
|
35
|
+
*
|
|
36
|
+
* @beta This API may change without a BREAKING CHANGE notice.
|
|
37
|
+
*/
|
|
38
|
+
export enum DIDCommMessageMediaType {
|
|
39
|
+
/**
|
|
40
|
+
* A plain JSON DIDComm message
|
|
41
|
+
*/
|
|
42
|
+
PLAIN = 'application/didcomm-plain+json',
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* A JWS signed DIDComm message
|
|
46
|
+
*/
|
|
47
|
+
SIGNED = 'application/didcomm-signed+json',
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* A JWE encrypted DIDComm message
|
|
51
|
+
*/
|
|
52
|
+
ENCRYPTED = 'application/didcomm-encrypted+json',
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* The possible types of message packing.
|
|
57
|
+
*
|
|
58
|
+
* `authcrypt`, `anoncrypt`, `anoncrypt+authcrypt`, and `anoncrypt+jws` will produce `DIDCommMessageMediaType.ENCRYPTED` messages.
|
|
59
|
+
*
|
|
60
|
+
* `jws` will produce `DIDCommMessageMediaType.SIGNED` messages.
|
|
61
|
+
*
|
|
62
|
+
* `none` will produce `DIDCommMessageMediaType.PLAIN` messages.
|
|
63
|
+
*
|
|
64
|
+
*
|
|
65
|
+
* @beta This API may change without a BREAKING CHANGE notice.
|
|
66
|
+
*/
|
|
67
|
+
export type DIDCommMessagePacking =
|
|
68
|
+
| 'authcrypt'
|
|
69
|
+
| 'anoncrypt'
|
|
70
|
+
| 'jws'
|
|
71
|
+
| 'none'
|
|
72
|
+
| 'anoncrypt+authcrypt'
|
|
73
|
+
| 'anoncrypt+jws'
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* Metadata resulting from unpacking a DIDComm v2 message.
|
|
77
|
+
*
|
|
78
|
+
* @beta This API may change without a BREAKING CHANGE notice.
|
|
79
|
+
*/
|
|
80
|
+
export interface IDIDCommMessageMetaData {
|
|
81
|
+
packing: DIDCommMessagePacking
|
|
82
|
+
// from_prior, reuse transport etc.
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* The result of unpacking a DIDComm v2 message.
|
|
87
|
+
*
|
|
88
|
+
* @beta This API may change without a BREAKING CHANGE notice.
|
|
89
|
+
*/
|
|
90
|
+
export interface IUnpackedDIDCommMessage {
|
|
91
|
+
metaData: IDIDCommMessageMetaData
|
|
92
|
+
message: IDIDCommMessage
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
* The result of packing a DIDComm v2 message.
|
|
97
|
+
* The message is always serialized as string.
|
|
98
|
+
*
|
|
99
|
+
* @beta This API may change without a BREAKING CHANGE notice.
|
|
100
|
+
*/
|
|
101
|
+
export interface IPackedDIDCommMessage {
|
|
102
|
+
message: string
|
|
103
|
+
}
|