diff --git a/build/libs/generated/ssi/client/enums.d.ts b/build/libs/generated/ssi/client/enums.d.ts new file mode 100644 index 0000000..2ef4244 --- /dev/null +++ b/build/libs/generated/ssi/client/enums.d.ts @@ -0,0 +1,35 @@ +export declare const protobufPackage = "hypersign.ssi.client"; +/** The messages defined here are meant only meant for TS client. */ +export declare enum VerificationMethodRelationships { + authentication = "authentication", + assertionMethod = "assertionMethod", + keyAgreement = "keyAgreement", + capabilityInvocation = "capabilityInvocation", + capabilityDelegation = "capabilityDelegation" +} +export declare function verificationMethodRelationshipsFromJSON(object: any): VerificationMethodRelationships; +export declare function verificationMethodRelationshipsToJSON(object: VerificationMethodRelationships): string; +export declare function verificationMethodRelationshipsToNumber(object: VerificationMethodRelationships): number; +export declare enum VerificationMethodTypes { + Ed25519VerificationKey2020 = "Ed25519VerificationKey2020", + EcdsaSecp256k1VerificationKey2019 = "EcdsaSecp256k1VerificationKey2019", + EcdsaSecp256k1RecoveryMethod2020 = "EcdsaSecp256k1RecoveryMethod2020", + X25519KeyAgreementKey2020 = "X25519KeyAgreementKey2020", + X25519KeyAgreementKeyEIP5630 = "X25519KeyAgreementKeyEIP5630", + Bls12381G2Key2020 = "Bls12381G2Key2020", + BabyJubJubKey2021 = "BabyJubJubKey2021" +} +export declare function verificationMethodTypesFromJSON(object: any): VerificationMethodTypes; +export declare function verificationMethodTypesToJSON(object: VerificationMethodTypes): string; +export declare function verificationMethodTypesToNumber(object: VerificationMethodTypes): number; +export declare enum ProofTypes { + Ed25519Signature2020 = "Ed25519Signature2020", + EcdsaSecp256k1Signature2019 = "EcdsaSecp256k1Signature2019", + EcdsaSecp256k1RecoverySignature2020 = "EcdsaSecp256k1RecoverySignature2020", + BJJSignature2021 = "BJJSignature2021", + BbsBlsSignature2020 = "BbsBlsSignature2020" +} +export declare function proofTypesFromJSON(object: any): ProofTypes; +export declare function proofTypesToJSON(object: ProofTypes): string; +export declare function proofTypesToNumber(object: ProofTypes): number; +//# sourceMappingURL=enums.d.ts.map \ No newline at end of file diff --git a/build/libs/generated/ssi/client/enums.d.ts.map b/build/libs/generated/ssi/client/enums.d.ts.map new file mode 100644 index 0000000..29aaf49 --- /dev/null +++ b/build/libs/generated/ssi/client/enums.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"enums.d.ts","sourceRoot":"","sources":["../../../../../libs/generated/ssi/client/enums.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,eAAe,yBAAyB,CAAC;AAEtD,oEAAoE;AAEpE,oBAAY,+BAA+B;IACvC,cAAc,mBAAmB;IACjC,eAAe,oBAAoB;IACnC,YAAY,iBAAiB;IAC7B,oBAAoB,yBAAyB;IAC7C,oBAAoB,yBAAyB;CAChD;AAED,wBAAgB,uCAAuC,CAAC,MAAM,EAAE,GAAG,GAAG,+BAA+B,CAoBpG;AAED,wBAAgB,qCAAqC,CAAC,MAAM,EAAE,+BAA+B,GAAG,MAAM,CAerG;AAED,wBAAgB,uCAAuC,CAAC,MAAM,EAAE,+BAA+B,GAAG,MAAM,CAevG;AAED,oBAAY,uBAAuB;IAC/B,0BAA0B,+BAA+B;IACzD,iCAAiC,sCAAsC;IACvE,gCAAgC,qCAAqC;IACrE,yBAAyB,8BAA8B;IACvD,4BAA4B,iCAAiC;IAC7D,iBAAiB,sBAAsB;IACvC,iBAAiB,sBAAsB;CAC1C;AAED,wBAAgB,+BAA+B,CAAC,MAAM,EAAE,GAAG,GAAG,uBAAuB,CA0BpF;AAED,wBAAgB,6BAA6B,CAAC,MAAM,EAAE,uBAAuB,GAAG,MAAM,CAmBrF;AAED,wBAAgB,+BAA+B,CAAC,MAAM,EAAE,uBAAuB,GAAG,MAAM,CAmBvF;AAED,oBAAY,UAAU;IAClB,oBAAoB,yBAAyB;IAC7C,2BAA2B,gCAAgC;IAC3D,mCAAmC,wCAAwC;IAC3E,gBAAgB,qBAAqB;IACrC,mBAAmB,wBAAwB;CAC9C;AAED,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,GAAG,GAAG,UAAU,CAoB1D;AAED,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,UAAU,GAAG,MAAM,CAe3D;AAED,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,UAAU,GAAG,MAAM,CAe7D"} \ No newline at end of file diff --git a/build/libs/generated/ssi/client/enums.js b/build/libs/generated/ssi/client/enums.js new file mode 100644 index 0000000..c1d92a2 --- /dev/null +++ b/build/libs/generated/ssi/client/enums.js @@ -0,0 +1,214 @@ +"use strict"; +/* eslint-disable */ +Object.defineProperty(exports, "__esModule", { value: true }); +exports.proofTypesToNumber = exports.proofTypesToJSON = exports.proofTypesFromJSON = exports.ProofTypes = exports.verificationMethodTypesToNumber = exports.verificationMethodTypesToJSON = exports.verificationMethodTypesFromJSON = exports.VerificationMethodTypes = exports.verificationMethodRelationshipsToNumber = exports.verificationMethodRelationshipsToJSON = exports.verificationMethodRelationshipsFromJSON = exports.VerificationMethodRelationships = exports.protobufPackage = void 0; +exports.protobufPackage = "hypersign.ssi.client"; +/** The messages defined here are meant only meant for TS client. */ +var VerificationMethodRelationships; +(function (VerificationMethodRelationships) { + VerificationMethodRelationships["authentication"] = "authentication"; + VerificationMethodRelationships["assertionMethod"] = "assertionMethod"; + VerificationMethodRelationships["keyAgreement"] = "keyAgreement"; + VerificationMethodRelationships["capabilityInvocation"] = "capabilityInvocation"; + VerificationMethodRelationships["capabilityDelegation"] = "capabilityDelegation"; +})(VerificationMethodRelationships = exports.VerificationMethodRelationships || (exports.VerificationMethodRelationships = {})); +function verificationMethodRelationshipsFromJSON(object) { + switch (object) { + case 0: + case "authentication": + return VerificationMethodRelationships.authentication; + case 1: + case "assertionMethod": + return VerificationMethodRelationships.assertionMethod; + case 2: + case "keyAgreement": + return VerificationMethodRelationships.keyAgreement; + case 3: + case "capabilityInvocation": + return VerificationMethodRelationships.capabilityInvocation; + case 4: + case "capabilityDelegation": + return VerificationMethodRelationships.capabilityDelegation; + default: + throw new globalThis.Error("Unrecognized enum value " + object + " for enum VerificationMethodRelationships"); + } +} +exports.verificationMethodRelationshipsFromJSON = verificationMethodRelationshipsFromJSON; +function verificationMethodRelationshipsToJSON(object) { + switch (object) { + case VerificationMethodRelationships.authentication: + return "authentication"; + case VerificationMethodRelationships.assertionMethod: + return "assertionMethod"; + case VerificationMethodRelationships.keyAgreement: + return "keyAgreement"; + case VerificationMethodRelationships.capabilityInvocation: + return "capabilityInvocation"; + case VerificationMethodRelationships.capabilityDelegation: + return "capabilityDelegation"; + default: + throw new globalThis.Error("Unrecognized enum value " + object + " for enum VerificationMethodRelationships"); + } +} +exports.verificationMethodRelationshipsToJSON = verificationMethodRelationshipsToJSON; +function verificationMethodRelationshipsToNumber(object) { + switch (object) { + case VerificationMethodRelationships.authentication: + return 0; + case VerificationMethodRelationships.assertionMethod: + return 1; + case VerificationMethodRelationships.keyAgreement: + return 2; + case VerificationMethodRelationships.capabilityInvocation: + return 3; + case VerificationMethodRelationships.capabilityDelegation: + return 4; + default: + throw new globalThis.Error("Unrecognized enum value " + object + " for enum VerificationMethodRelationships"); + } +} +exports.verificationMethodRelationshipsToNumber = verificationMethodRelationshipsToNumber; +var VerificationMethodTypes; +(function (VerificationMethodTypes) { + VerificationMethodTypes["Ed25519VerificationKey2020"] = "Ed25519VerificationKey2020"; + VerificationMethodTypes["EcdsaSecp256k1VerificationKey2019"] = "EcdsaSecp256k1VerificationKey2019"; + VerificationMethodTypes["EcdsaSecp256k1RecoveryMethod2020"] = "EcdsaSecp256k1RecoveryMethod2020"; + VerificationMethodTypes["X25519KeyAgreementKey2020"] = "X25519KeyAgreementKey2020"; + VerificationMethodTypes["X25519KeyAgreementKeyEIP5630"] = "X25519KeyAgreementKeyEIP5630"; + VerificationMethodTypes["Bls12381G2Key2020"] = "Bls12381G2Key2020"; + VerificationMethodTypes["BabyJubJubKey2021"] = "BabyJubJubKey2021"; +})(VerificationMethodTypes = exports.VerificationMethodTypes || (exports.VerificationMethodTypes = {})); +function verificationMethodTypesFromJSON(object) { + switch (object) { + case 0: + case "Ed25519VerificationKey2020": + return VerificationMethodTypes.Ed25519VerificationKey2020; + case 1: + case "EcdsaSecp256k1VerificationKey2019": + return VerificationMethodTypes.EcdsaSecp256k1VerificationKey2019; + case 2: + case "EcdsaSecp256k1RecoveryMethod2020": + return VerificationMethodTypes.EcdsaSecp256k1RecoveryMethod2020; + case 3: + case "X25519KeyAgreementKey2020": + return VerificationMethodTypes.X25519KeyAgreementKey2020; + case 4: + case "X25519KeyAgreementKeyEIP5630": + return VerificationMethodTypes.X25519KeyAgreementKeyEIP5630; + case 5: + case "Bls12381G2Key2020": + return VerificationMethodTypes.Bls12381G2Key2020; + case 6: + case "BabyJubJubKey2021": + return VerificationMethodTypes.BabyJubJubKey2021; + default: + throw new globalThis.Error("Unrecognized enum value " + object + " for enum VerificationMethodTypes"); + } +} +exports.verificationMethodTypesFromJSON = verificationMethodTypesFromJSON; +function verificationMethodTypesToJSON(object) { + switch (object) { + case VerificationMethodTypes.Ed25519VerificationKey2020: + return "Ed25519VerificationKey2020"; + case VerificationMethodTypes.EcdsaSecp256k1VerificationKey2019: + return "EcdsaSecp256k1VerificationKey2019"; + case VerificationMethodTypes.EcdsaSecp256k1RecoveryMethod2020: + return "EcdsaSecp256k1RecoveryMethod2020"; + case VerificationMethodTypes.X25519KeyAgreementKey2020: + return "X25519KeyAgreementKey2020"; + case VerificationMethodTypes.X25519KeyAgreementKeyEIP5630: + return "X25519KeyAgreementKeyEIP5630"; + case VerificationMethodTypes.Bls12381G2Key2020: + return "Bls12381G2Key2020"; + case VerificationMethodTypes.BabyJubJubKey2021: + return "BabyJubJubKey2021"; + default: + throw new globalThis.Error("Unrecognized enum value " + object + " for enum VerificationMethodTypes"); + } +} +exports.verificationMethodTypesToJSON = verificationMethodTypesToJSON; +function verificationMethodTypesToNumber(object) { + switch (object) { + case VerificationMethodTypes.Ed25519VerificationKey2020: + return 0; + case VerificationMethodTypes.EcdsaSecp256k1VerificationKey2019: + return 1; + case VerificationMethodTypes.EcdsaSecp256k1RecoveryMethod2020: + return 2; + case VerificationMethodTypes.X25519KeyAgreementKey2020: + return 3; + case VerificationMethodTypes.X25519KeyAgreementKeyEIP5630: + return 4; + case VerificationMethodTypes.Bls12381G2Key2020: + return 5; + case VerificationMethodTypes.BabyJubJubKey2021: + return 6; + default: + throw new globalThis.Error("Unrecognized enum value " + object + " for enum VerificationMethodTypes"); + } +} +exports.verificationMethodTypesToNumber = verificationMethodTypesToNumber; +var ProofTypes; +(function (ProofTypes) { + ProofTypes["Ed25519Signature2020"] = "Ed25519Signature2020"; + ProofTypes["EcdsaSecp256k1Signature2019"] = "EcdsaSecp256k1Signature2019"; + ProofTypes["EcdsaSecp256k1RecoverySignature2020"] = "EcdsaSecp256k1RecoverySignature2020"; + ProofTypes["BJJSignature2021"] = "BJJSignature2021"; + ProofTypes["BbsBlsSignature2020"] = "BbsBlsSignature2020"; +})(ProofTypes = exports.ProofTypes || (exports.ProofTypes = {})); +function proofTypesFromJSON(object) { + switch (object) { + case 0: + case "Ed25519Signature2020": + return ProofTypes.Ed25519Signature2020; + case 1: + case "EcdsaSecp256k1Signature2019": + return ProofTypes.EcdsaSecp256k1Signature2019; + case 2: + case "EcdsaSecp256k1RecoverySignature2020": + return ProofTypes.EcdsaSecp256k1RecoverySignature2020; + case 3: + case "BJJSignature2021": + return ProofTypes.BJJSignature2021; + case 4: + case "BbsBlsSignature2020": + return ProofTypes.BbsBlsSignature2020; + default: + throw new globalThis.Error("Unrecognized enum value " + object + " for enum ProofTypes"); + } +} +exports.proofTypesFromJSON = proofTypesFromJSON; +function proofTypesToJSON(object) { + switch (object) { + case ProofTypes.Ed25519Signature2020: + return "Ed25519Signature2020"; + case ProofTypes.EcdsaSecp256k1Signature2019: + return "EcdsaSecp256k1Signature2019"; + case ProofTypes.EcdsaSecp256k1RecoverySignature2020: + return "EcdsaSecp256k1RecoverySignature2020"; + case ProofTypes.BJJSignature2021: + return "BJJSignature2021"; + case ProofTypes.BbsBlsSignature2020: + return "BbsBlsSignature2020"; + default: + throw new globalThis.Error("Unrecognized enum value " + object + " for enum ProofTypes"); + } +} +exports.proofTypesToJSON = proofTypesToJSON; +function proofTypesToNumber(object) { + switch (object) { + case ProofTypes.Ed25519Signature2020: + return 0; + case ProofTypes.EcdsaSecp256k1Signature2019: + return 1; + case ProofTypes.EcdsaSecp256k1RecoverySignature2020: + return 2; + case ProofTypes.BJJSignature2021: + return 3; + case ProofTypes.BbsBlsSignature2020: + return 4; + default: + throw new globalThis.Error("Unrecognized enum value " + object + " for enum ProofTypes"); + } +} +exports.proofTypesToNumber = proofTypesToNumber; diff --git a/build/libs/generated/ssi/clientSpec.d.ts b/build/libs/generated/ssi/clientSpec.d.ts deleted file mode 100644 index c20f923..0000000 --- a/build/libs/generated/ssi/clientSpec.d.ts +++ /dev/null @@ -1,19 +0,0 @@ -import { Writer, Reader } from "protobufjs/minimal"; -export declare const protobufPackage = "hypersignprotocol.hidnode.ssi"; -export interface ClientSpec { - type: string; - adr036SignerAddress: string; -} -export declare const ClientSpec: { - encode(message: ClientSpec, writer?: Writer): Writer; - decode(input: Reader | Uint8Array, length?: number): ClientSpec; - fromJSON(object: any): ClientSpec; - toJSON(message: ClientSpec): unknown; - fromPartial(object: DeepPartial): ClientSpec; -}; -type Builtin = Date | Function | Uint8Array | string | number | undefined; -export type DeepPartial = T extends Builtin ? T : T extends Array ? Array> : T extends ReadonlyArray ? ReadonlyArray> : T extends {} ? { - [K in keyof T]?: DeepPartial; -} : Partial; -export {}; -//# sourceMappingURL=clientSpec.d.ts.map \ No newline at end of file diff --git a/build/libs/generated/ssi/clientSpec.d.ts.map b/build/libs/generated/ssi/clientSpec.d.ts.map deleted file mode 100644 index b9671da..0000000 --- a/build/libs/generated/ssi/clientSpec.d.ts.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"clientSpec.d.ts","sourceRoot":"","sources":["../../../../libs/generated/ssi/clientSpec.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAEpD,eAAO,MAAM,eAAe,kCAAkC,CAAC;AAE/D,MAAM,WAAW,UAAU;IACzB,IAAI,EAAE,MAAM,CAAC;IACb,mBAAmB,EAAE,MAAM,CAAC;CAC7B;AAID,eAAO,MAAM,UAAU;oBACL,UAAU,WAAU,MAAM,GAAqB,MAAM;kBAUvD,MAAM,GAAG,UAAU,WAAW,MAAM,GAAG,UAAU;qBAqB9C,GAAG,GAAG,UAAU;oBAkBjB,UAAU,GAAG,OAAO;wBAQhB,YAAY,UAAU,CAAC,GAAG,UAAU;CAiBzD,CAAC;AAEF,KAAK,OAAO,GAAG,IAAI,GAAG,QAAQ,GAAG,UAAU,GAAG,MAAM,GAAG,MAAM,GAAG,SAAS,CAAC;AAC1E,MAAM,MAAM,WAAW,CAAC,CAAC,IAAI,CAAC,SAAS,OAAO,GAC1C,CAAC,GACD,CAAC,SAAS,KAAK,CAAC,MAAM,CAAC,CAAC,GACxB,KAAK,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,GACrB,CAAC,SAAS,aAAa,CAAC,MAAM,CAAC,CAAC,GAChC,aAAa,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,GAC7B,CAAC,SAAS,EAAE,GACZ;KAAG,CAAC,IAAI,MAAM,CAAC,CAAC,CAAC,EAAE,WAAW,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;CAAE,GACtC,OAAO,CAAC,CAAC,CAAC,CAAC"} \ No newline at end of file diff --git a/build/libs/generated/ssi/clientSpec.js b/build/libs/generated/ssi/clientSpec.js deleted file mode 100644 index a03b943..0000000 --- a/build/libs/generated/ssi/clientSpec.js +++ /dev/null @@ -1,79 +0,0 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.ClientSpec = exports.protobufPackage = void 0; -/* eslint-disable */ -const minimal_1 = require("protobufjs/minimal"); -exports.protobufPackage = "hypersignprotocol.hidnode.ssi"; -const baseClientSpec = { type: "", adr036SignerAddress: "" }; -exports.ClientSpec = { - encode(message, writer = minimal_1.Writer.create()) { - if (message.type !== "") { - writer.uint32(10).string(message.type); - } - if (message.adr036SignerAddress !== "") { - writer.uint32(18).string(message.adr036SignerAddress); - } - return writer; - }, - decode(input, length) { - const reader = input instanceof Uint8Array ? new minimal_1.Reader(input) : input; - let end = length === undefined ? reader.len : reader.pos + length; - const message = Object.assign({}, baseClientSpec); - while (reader.pos < end) { - const tag = reader.uint32(); - switch (tag >>> 3) { - case 1: - message.type = reader.string(); - break; - case 2: - message.adr036SignerAddress = reader.string(); - break; - default: - reader.skipType(tag & 7); - break; - } - } - return message; - }, - fromJSON(object) { - const message = Object.assign({}, baseClientSpec); - if (object.type !== undefined && object.type !== null) { - message.type = String(object.type); - } - else { - message.type = ""; - } - if (object.adr036SignerAddress !== undefined && - object.adr036SignerAddress !== null) { - message.adr036SignerAddress = String(object.adr036SignerAddress); - } - else { - message.adr036SignerAddress = ""; - } - return message; - }, - toJSON(message) { - const obj = {}; - message.type !== undefined && (obj.type = message.type); - message.adr036SignerAddress !== undefined && - (obj.adr036SignerAddress = message.adr036SignerAddress); - return obj; - }, - fromPartial(object) { - const message = Object.assign({}, baseClientSpec); - if (object.type !== undefined && object.type !== null) { - message.type = object.type; - } - else { - message.type = ""; - } - if (object.adr036SignerAddress !== undefined && - object.adr036SignerAddress !== null) { - message.adr036SignerAddress = object.adr036SignerAddress; - } - else { - message.adr036SignerAddress = ""; - } - return message; - }, -}; diff --git a/build/libs/generated/ssi/client_spec.d.ts b/build/libs/generated/ssi/client_spec.d.ts new file mode 100644 index 0000000..0628f65 --- /dev/null +++ b/build/libs/generated/ssi/client_spec.d.ts @@ -0,0 +1,10 @@ +export declare const protobufPackage = "hypersign.ssi.v1"; +export declare enum ClientSpecType { + CLIENT_SPEC_TYPE_NONE = "CLIENT_SPEC_TYPE_NONE", + CLIENT_SPEC_TYPE_COSMOS_ADR036 = "CLIENT_SPEC_TYPE_COSMOS_ADR036", + CLIENT_SPEC_TYPE_ETH_PERSONAL_SIGN = "CLIENT_SPEC_TYPE_ETH_PERSONAL_SIGN" +} +export declare function clientSpecTypeFromJSON(object: any): ClientSpecType; +export declare function clientSpecTypeToJSON(object: ClientSpecType): string; +export declare function clientSpecTypeToNumber(object: ClientSpecType): number; +//# sourceMappingURL=client_spec.d.ts.map \ No newline at end of file diff --git a/build/libs/generated/ssi/client_spec.d.ts.map b/build/libs/generated/ssi/client_spec.d.ts.map new file mode 100644 index 0000000..dad058a --- /dev/null +++ b/build/libs/generated/ssi/client_spec.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"client_spec.d.ts","sourceRoot":"","sources":["../../../../libs/generated/ssi/client_spec.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,eAAe,qBAAqB,CAAC;AAElD,oBAAY,cAAc;IACxB,qBAAqB,0BAA0B;IAC/C,8BAA8B,mCAAmC;IACjE,kCAAkC,uCAAuC;CAC1E;AAED,wBAAgB,sBAAsB,CAAC,MAAM,EAAE,GAAG,GAAG,cAAc,CAclE;AAED,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,cAAc,GAAG,MAAM,CAWnE;AAED,wBAAgB,sBAAsB,CAAC,MAAM,EAAE,cAAc,GAAG,MAAM,CAWrE"} \ No newline at end of file diff --git a/build/libs/generated/ssi/client_spec.js b/build/libs/generated/ssi/client_spec.js new file mode 100644 index 0000000..cc08fbf --- /dev/null +++ b/build/libs/generated/ssi/client_spec.js @@ -0,0 +1,53 @@ +"use strict"; +/* eslint-disable */ +Object.defineProperty(exports, "__esModule", { value: true }); +exports.clientSpecTypeToNumber = exports.clientSpecTypeToJSON = exports.clientSpecTypeFromJSON = exports.ClientSpecType = exports.protobufPackage = void 0; +exports.protobufPackage = "hypersign.ssi.v1"; +var ClientSpecType; +(function (ClientSpecType) { + ClientSpecType["CLIENT_SPEC_TYPE_NONE"] = "CLIENT_SPEC_TYPE_NONE"; + ClientSpecType["CLIENT_SPEC_TYPE_COSMOS_ADR036"] = "CLIENT_SPEC_TYPE_COSMOS_ADR036"; + ClientSpecType["CLIENT_SPEC_TYPE_ETH_PERSONAL_SIGN"] = "CLIENT_SPEC_TYPE_ETH_PERSONAL_SIGN"; +})(ClientSpecType = exports.ClientSpecType || (exports.ClientSpecType = {})); +function clientSpecTypeFromJSON(object) { + switch (object) { + case 0: + case "CLIENT_SPEC_TYPE_NONE": + return ClientSpecType.CLIENT_SPEC_TYPE_NONE; + case 1: + case "CLIENT_SPEC_TYPE_COSMOS_ADR036": + return ClientSpecType.CLIENT_SPEC_TYPE_COSMOS_ADR036; + case 2: + case "CLIENT_SPEC_TYPE_ETH_PERSONAL_SIGN": + return ClientSpecType.CLIENT_SPEC_TYPE_ETH_PERSONAL_SIGN; + default: + throw new globalThis.Error("Unrecognized enum value " + object + " for enum ClientSpecType"); + } +} +exports.clientSpecTypeFromJSON = clientSpecTypeFromJSON; +function clientSpecTypeToJSON(object) { + switch (object) { + case ClientSpecType.CLIENT_SPEC_TYPE_NONE: + return "CLIENT_SPEC_TYPE_NONE"; + case ClientSpecType.CLIENT_SPEC_TYPE_COSMOS_ADR036: + return "CLIENT_SPEC_TYPE_COSMOS_ADR036"; + case ClientSpecType.CLIENT_SPEC_TYPE_ETH_PERSONAL_SIGN: + return "CLIENT_SPEC_TYPE_ETH_PERSONAL_SIGN"; + default: + throw new globalThis.Error("Unrecognized enum value " + object + " for enum ClientSpecType"); + } +} +exports.clientSpecTypeToJSON = clientSpecTypeToJSON; +function clientSpecTypeToNumber(object) { + switch (object) { + case ClientSpecType.CLIENT_SPEC_TYPE_NONE: + return 0; + case ClientSpecType.CLIENT_SPEC_TYPE_COSMOS_ADR036: + return 1; + case ClientSpecType.CLIENT_SPEC_TYPE_ETH_PERSONAL_SIGN: + return 2; + default: + throw new globalThis.Error("Unrecognized enum value " + object + " for enum ClientSpecType"); + } +} +exports.clientSpecTypeToNumber = clientSpecTypeToNumber; diff --git a/build/libs/generated/ssi/credential.d.ts b/build/libs/generated/ssi/credential.d.ts deleted file mode 100644 index 9637338..0000000 --- a/build/libs/generated/ssi/credential.d.ts +++ /dev/null @@ -1,64 +0,0 @@ -import { Writer, Reader } from "protobufjs/minimal"; -export declare const protobufPackage = "hypersignprotocol.hidnode.ssi"; -export interface Claim { - id: string; - currentStatus: string; - statusReason: string; -} -export interface CredentialStatus { - claim: Claim | undefined; - issuer: string; - issuanceDate: string; - expirationDate: string; - credentialHash: string; -} -export interface CredentialProof { - type: string; - created: string; - updated: string; - verificationMethod: string; - proofPurpose: string; - proofValue: string; -} -export interface Credential { - claim: Claim | undefined; - issuer: string; - issuanceDate: string; - expirationDate: string; - credentialHash: string; - proof: CredentialProof | undefined; -} -export declare const Claim: { - encode(message: Claim, writer?: Writer): Writer; - decode(input: Reader | Uint8Array, length?: number): Claim; - fromJSON(object: any): Claim; - toJSON(message: Claim): unknown; - fromPartial(object: DeepPartial): Claim; -}; -export declare const CredentialStatus: { - encode(message: CredentialStatus, writer?: Writer): Writer; - decode(input: Reader | Uint8Array, length?: number): CredentialStatus; - fromJSON(object: any): CredentialStatus; - toJSON(message: CredentialStatus): unknown; - fromPartial(object: DeepPartial): CredentialStatus; -}; -export declare const CredentialProof: { - encode(message: CredentialProof, writer?: Writer): Writer; - decode(input: Reader | Uint8Array, length?: number): CredentialProof; - fromJSON(object: any): CredentialProof; - toJSON(message: CredentialProof): unknown; - fromPartial(object: DeepPartial): CredentialProof; -}; -export declare const Credential: { - encode(message: Credential, writer?: Writer): Writer; - decode(input: Reader | Uint8Array, length?: number): Credential; - fromJSON(object: any): Credential; - toJSON(message: Credential): unknown; - fromPartial(object: DeepPartial): Credential; -}; -type Builtin = Date | Function | Uint8Array | string | number | undefined; -export type DeepPartial = T extends Builtin ? T : T extends Array ? Array> : T extends ReadonlyArray ? ReadonlyArray> : T extends {} ? { - [K in keyof T]?: DeepPartial; -} : Partial; -export {}; -//# sourceMappingURL=credential.d.ts.map \ No newline at end of file diff --git a/build/libs/generated/ssi/credential.d.ts.map b/build/libs/generated/ssi/credential.d.ts.map deleted file mode 100644 index c28a04b..0000000 --- a/build/libs/generated/ssi/credential.d.ts.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"credential.d.ts","sourceRoot":"","sources":["../../../../libs/generated/ssi/credential.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAEpD,eAAO,MAAM,eAAe,kCAAkC,CAAC;AAE/D,MAAM,WAAW,KAAK;IACpB,EAAE,EAAE,MAAM,CAAC;IACX,aAAa,EAAE,MAAM,CAAC;IACtB,YAAY,EAAE,MAAM,CAAC;CACtB;AAED,MAAM,WAAW,gBAAgB;IAC/B,KAAK,EAAE,KAAK,GAAG,SAAS,CAAC;IACzB,MAAM,EAAE,MAAM,CAAC;IACf,YAAY,EAAE,MAAM,CAAC;IACrB,cAAc,EAAE,MAAM,CAAC;IACvB,cAAc,EAAE,MAAM,CAAC;CACxB;AAED,MAAM,WAAW,eAAe;IAC9B,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;IAChB,kBAAkB,EAAE,MAAM,CAAC;IAC3B,YAAY,EAAE,MAAM,CAAC;IACrB,UAAU,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,UAAU;IACzB,KAAK,EAAE,KAAK,GAAG,SAAS,CAAC;IACzB,MAAM,EAAE,MAAM,CAAC;IACf,YAAY,EAAE,MAAM,CAAC;IACrB,cAAc,EAAE,MAAM,CAAC;IACvB,cAAc,EAAE,MAAM,CAAC;IACvB,KAAK,EAAE,eAAe,GAAG,SAAS,CAAC;CACpC;AAID,eAAO,MAAM,KAAK;oBACA,KAAK,WAAU,MAAM,GAAqB,MAAM;kBAalD,MAAM,GAAG,UAAU,WAAW,MAAM,GAAG,KAAK;qBAwBzC,GAAG,GAAG,KAAK;oBAoBZ,KAAK,GAAG,OAAO;wBAUX,YAAY,KAAK,CAAC,GAAG,KAAK;CAmB/C,CAAC;AASF,eAAO,MAAM,gBAAgB;oBACX,gBAAgB,WAAU,MAAM,GAAqB,MAAM;kBAmB7D,MAAM,GAAG,UAAU,WAAW,MAAM,GAAG,gBAAgB;qBA8BpD,GAAG,GAAG,gBAAgB;oBA8BvB,gBAAgB,GAAG,OAAO;wBActB,YAAY,gBAAgB,CAAC,GAAG,gBAAgB;CA6BrE,CAAC;AAWF,eAAO,MAAM,eAAe;oBACV,eAAe,WAAU,MAAM,GAAqB,MAAM;kBAsB5D,MAAM,GAAG,UAAU,WAAW,MAAM,GAAG,eAAe;qBAiCnD,GAAG,GAAG,eAAe;oBAsCtB,eAAe,GAAG,OAAO;wBAarB,YAAY,eAAe,CAAC,GAAG,eAAe;CAqCnE,CAAC;AASF,eAAO,MAAM,UAAU;oBACL,UAAU,WAAU,MAAM,GAAqB,MAAM;kBAsBvD,MAAM,GAAG,UAAU,WAAW,MAAM,GAAG,UAAU;qBAiC9C,GAAG,GAAG,UAAU;oBAmCjB,UAAU,GAAG,OAAO;wBAkBhB,YAAY,UAAU,CAAC,GAAG,UAAU;CAkCzD,CAAC;AAEF,KAAK,OAAO,GAAG,IAAI,GAAG,QAAQ,GAAG,UAAU,GAAG,MAAM,GAAG,MAAM,GAAG,SAAS,CAAC;AAC1E,MAAM,MAAM,WAAW,CAAC,CAAC,IAAI,CAAC,SAAS,OAAO,GAC1C,CAAC,GACD,CAAC,SAAS,KAAK,CAAC,MAAM,CAAC,CAAC,GACxB,KAAK,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,GACrB,CAAC,SAAS,aAAa,CAAC,MAAM,CAAC,CAAC,GAChC,aAAa,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,GAC7B,CAAC,SAAS,EAAE,GACZ;KAAG,CAAC,IAAI,MAAM,CAAC,CAAC,CAAC,EAAE,WAAW,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;CAAE,GACtC,OAAO,CAAC,CAAC,CAAC,CAAC"} \ No newline at end of file diff --git a/build/libs/generated/ssi/credential.js b/build/libs/generated/ssi/credential.js deleted file mode 100644 index 971b159..0000000 --- a/build/libs/generated/ssi/credential.js +++ /dev/null @@ -1,548 +0,0 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.Credential = exports.CredentialProof = exports.CredentialStatus = exports.Claim = exports.protobufPackage = void 0; -/* eslint-disable */ -const minimal_1 = require("protobufjs/minimal"); -exports.protobufPackage = "hypersignprotocol.hidnode.ssi"; -const baseClaim = { id: "", currentStatus: "", statusReason: "" }; -exports.Claim = { - encode(message, writer = minimal_1.Writer.create()) { - if (message.id !== "") { - writer.uint32(10).string(message.id); - } - if (message.currentStatus !== "") { - writer.uint32(18).string(message.currentStatus); - } - if (message.statusReason !== "") { - writer.uint32(26).string(message.statusReason); - } - return writer; - }, - decode(input, length) { - const reader = input instanceof Uint8Array ? new minimal_1.Reader(input) : input; - let end = length === undefined ? reader.len : reader.pos + length; - const message = Object.assign({}, baseClaim); - while (reader.pos < end) { - const tag = reader.uint32(); - switch (tag >>> 3) { - case 1: - message.id = reader.string(); - break; - case 2: - message.currentStatus = reader.string(); - break; - case 3: - message.statusReason = reader.string(); - break; - default: - reader.skipType(tag & 7); - break; - } - } - return message; - }, - fromJSON(object) { - const message = Object.assign({}, baseClaim); - if (object.id !== undefined && object.id !== null) { - message.id = String(object.id); - } - else { - message.id = ""; - } - if (object.currentStatus !== undefined && object.currentStatus !== null) { - message.currentStatus = String(object.currentStatus); - } - else { - message.currentStatus = ""; - } - if (object.statusReason !== undefined && object.statusReason !== null) { - message.statusReason = String(object.statusReason); - } - else { - message.statusReason = ""; - } - return message; - }, - toJSON(message) { - const obj = {}; - message.id !== undefined && (obj.id = message.id); - message.currentStatus !== undefined && - (obj.currentStatus = message.currentStatus); - message.statusReason !== undefined && - (obj.statusReason = message.statusReason); - return obj; - }, - fromPartial(object) { - const message = Object.assign({}, baseClaim); - if (object.id !== undefined && object.id !== null) { - message.id = object.id; - } - else { - message.id = ""; - } - if (object.currentStatus !== undefined && object.currentStatus !== null) { - message.currentStatus = object.currentStatus; - } - else { - message.currentStatus = ""; - } - if (object.statusReason !== undefined && object.statusReason !== null) { - message.statusReason = object.statusReason; - } - else { - message.statusReason = ""; - } - return message; - }, -}; -const baseCredentialStatus = { - issuer: "", - issuanceDate: "", - expirationDate: "", - credentialHash: "", -}; -exports.CredentialStatus = { - encode(message, writer = minimal_1.Writer.create()) { - if (message.claim !== undefined) { - exports.Claim.encode(message.claim, writer.uint32(10).fork()).ldelim(); - } - if (message.issuer !== "") { - writer.uint32(18).string(message.issuer); - } - if (message.issuanceDate !== "") { - writer.uint32(26).string(message.issuanceDate); - } - if (message.expirationDate !== "") { - writer.uint32(34).string(message.expirationDate); - } - if (message.credentialHash !== "") { - writer.uint32(42).string(message.credentialHash); - } - return writer; - }, - decode(input, length) { - const reader = input instanceof Uint8Array ? new minimal_1.Reader(input) : input; - let end = length === undefined ? reader.len : reader.pos + length; - const message = Object.assign({}, baseCredentialStatus); - while (reader.pos < end) { - const tag = reader.uint32(); - switch (tag >>> 3) { - case 1: - message.claim = exports.Claim.decode(reader, reader.uint32()); - break; - case 2: - message.issuer = reader.string(); - break; - case 3: - message.issuanceDate = reader.string(); - break; - case 4: - message.expirationDate = reader.string(); - break; - case 5: - message.credentialHash = reader.string(); - break; - default: - reader.skipType(tag & 7); - break; - } - } - return message; - }, - fromJSON(object) { - const message = Object.assign({}, baseCredentialStatus); - if (object.claim !== undefined && object.claim !== null) { - message.claim = exports.Claim.fromJSON(object.claim); - } - else { - message.claim = undefined; - } - if (object.issuer !== undefined && object.issuer !== null) { - message.issuer = String(object.issuer); - } - else { - message.issuer = ""; - } - if (object.issuanceDate !== undefined && object.issuanceDate !== null) { - message.issuanceDate = String(object.issuanceDate); - } - else { - message.issuanceDate = ""; - } - if (object.expirationDate !== undefined && object.expirationDate !== null) { - message.expirationDate = String(object.expirationDate); - } - else { - message.expirationDate = ""; - } - if (object.credentialHash !== undefined && object.credentialHash !== null) { - message.credentialHash = String(object.credentialHash); - } - else { - message.credentialHash = ""; - } - return message; - }, - toJSON(message) { - const obj = {}; - message.claim !== undefined && - (obj.claim = message.claim ? exports.Claim.toJSON(message.claim) : undefined); - message.issuer !== undefined && (obj.issuer = message.issuer); - message.issuanceDate !== undefined && - (obj.issuanceDate = message.issuanceDate); - message.expirationDate !== undefined && - (obj.expirationDate = message.expirationDate); - message.credentialHash !== undefined && - (obj.credentialHash = message.credentialHash); - return obj; - }, - fromPartial(object) { - const message = Object.assign({}, baseCredentialStatus); - if (object.claim !== undefined && object.claim !== null) { - message.claim = exports.Claim.fromPartial(object.claim); - } - else { - message.claim = undefined; - } - if (object.issuer !== undefined && object.issuer !== null) { - message.issuer = object.issuer; - } - else { - message.issuer = ""; - } - if (object.issuanceDate !== undefined && object.issuanceDate !== null) { - message.issuanceDate = object.issuanceDate; - } - else { - message.issuanceDate = ""; - } - if (object.expirationDate !== undefined && object.expirationDate !== null) { - message.expirationDate = object.expirationDate; - } - else { - message.expirationDate = ""; - } - if (object.credentialHash !== undefined && object.credentialHash !== null) { - message.credentialHash = object.credentialHash; - } - else { - message.credentialHash = ""; - } - return message; - }, -}; -const baseCredentialProof = { - type: "", - created: "", - updated: "", - verificationMethod: "", - proofPurpose: "", - proofValue: "", -}; -exports.CredentialProof = { - encode(message, writer = minimal_1.Writer.create()) { - if (message.type !== "") { - writer.uint32(10).string(message.type); - } - if (message.created !== "") { - writer.uint32(18).string(message.created); - } - if (message.updated !== "") { - writer.uint32(26).string(message.updated); - } - if (message.verificationMethod !== "") { - writer.uint32(34).string(message.verificationMethod); - } - if (message.proofPurpose !== "") { - writer.uint32(42).string(message.proofPurpose); - } - if (message.proofValue !== "") { - writer.uint32(50).string(message.proofValue); - } - return writer; - }, - decode(input, length) { - const reader = input instanceof Uint8Array ? new minimal_1.Reader(input) : input; - let end = length === undefined ? reader.len : reader.pos + length; - const message = Object.assign({}, baseCredentialProof); - while (reader.pos < end) { - const tag = reader.uint32(); - switch (tag >>> 3) { - case 1: - message.type = reader.string(); - break; - case 2: - message.created = reader.string(); - break; - case 3: - message.updated = reader.string(); - break; - case 4: - message.verificationMethod = reader.string(); - break; - case 5: - message.proofPurpose = reader.string(); - break; - case 6: - message.proofValue = reader.string(); - break; - default: - reader.skipType(tag & 7); - break; - } - } - return message; - }, - fromJSON(object) { - const message = Object.assign({}, baseCredentialProof); - if (object.type !== undefined && object.type !== null) { - message.type = String(object.type); - } - else { - message.type = ""; - } - if (object.created !== undefined && object.created !== null) { - message.created = String(object.created); - } - else { - message.created = ""; - } - if (object.updated !== undefined && object.updated !== null) { - message.updated = String(object.updated); - } - else { - message.updated = ""; - } - if (object.verificationMethod !== undefined && - object.verificationMethod !== null) { - message.verificationMethod = String(object.verificationMethod); - } - else { - message.verificationMethod = ""; - } - if (object.proofPurpose !== undefined && object.proofPurpose !== null) { - message.proofPurpose = String(object.proofPurpose); - } - else { - message.proofPurpose = ""; - } - if (object.proofValue !== undefined && object.proofValue !== null) { - message.proofValue = String(object.proofValue); - } - else { - message.proofValue = ""; - } - return message; - }, - toJSON(message) { - const obj = {}; - message.type !== undefined && (obj.type = message.type); - message.created !== undefined && (obj.created = message.created); - message.updated !== undefined && (obj.updated = message.updated); - message.verificationMethod !== undefined && - (obj.verificationMethod = message.verificationMethod); - message.proofPurpose !== undefined && - (obj.proofPurpose = message.proofPurpose); - message.proofValue !== undefined && (obj.proofValue = message.proofValue); - return obj; - }, - fromPartial(object) { - const message = Object.assign({}, baseCredentialProof); - if (object.type !== undefined && object.type !== null) { - message.type = object.type; - } - else { - message.type = ""; - } - if (object.created !== undefined && object.created !== null) { - message.created = object.created; - } - else { - message.created = ""; - } - if (object.updated !== undefined && object.updated !== null) { - message.updated = object.updated; - } - else { - message.updated = ""; - } - if (object.verificationMethod !== undefined && - object.verificationMethod !== null) { - message.verificationMethod = object.verificationMethod; - } - else { - message.verificationMethod = ""; - } - if (object.proofPurpose !== undefined && object.proofPurpose !== null) { - message.proofPurpose = object.proofPurpose; - } - else { - message.proofPurpose = ""; - } - if (object.proofValue !== undefined && object.proofValue !== null) { - message.proofValue = object.proofValue; - } - else { - message.proofValue = ""; - } - return message; - }, -}; -const baseCredential = { - issuer: "", - issuanceDate: "", - expirationDate: "", - credentialHash: "", -}; -exports.Credential = { - encode(message, writer = minimal_1.Writer.create()) { - if (message.claim !== undefined) { - exports.Claim.encode(message.claim, writer.uint32(10).fork()).ldelim(); - } - if (message.issuer !== "") { - writer.uint32(18).string(message.issuer); - } - if (message.issuanceDate !== "") { - writer.uint32(26).string(message.issuanceDate); - } - if (message.expirationDate !== "") { - writer.uint32(34).string(message.expirationDate); - } - if (message.credentialHash !== "") { - writer.uint32(42).string(message.credentialHash); - } - if (message.proof !== undefined) { - exports.CredentialProof.encode(message.proof, writer.uint32(50).fork()).ldelim(); - } - return writer; - }, - decode(input, length) { - const reader = input instanceof Uint8Array ? new minimal_1.Reader(input) : input; - let end = length === undefined ? reader.len : reader.pos + length; - const message = Object.assign({}, baseCredential); - while (reader.pos < end) { - const tag = reader.uint32(); - switch (tag >>> 3) { - case 1: - message.claim = exports.Claim.decode(reader, reader.uint32()); - break; - case 2: - message.issuer = reader.string(); - break; - case 3: - message.issuanceDate = reader.string(); - break; - case 4: - message.expirationDate = reader.string(); - break; - case 5: - message.credentialHash = reader.string(); - break; - case 6: - message.proof = exports.CredentialProof.decode(reader, reader.uint32()); - break; - default: - reader.skipType(tag & 7); - break; - } - } - return message; - }, - fromJSON(object) { - const message = Object.assign({}, baseCredential); - if (object.claim !== undefined && object.claim !== null) { - message.claim = exports.Claim.fromJSON(object.claim); - } - else { - message.claim = undefined; - } - if (object.issuer !== undefined && object.issuer !== null) { - message.issuer = String(object.issuer); - } - else { - message.issuer = ""; - } - if (object.issuanceDate !== undefined && object.issuanceDate !== null) { - message.issuanceDate = String(object.issuanceDate); - } - else { - message.issuanceDate = ""; - } - if (object.expirationDate !== undefined && object.expirationDate !== null) { - message.expirationDate = String(object.expirationDate); - } - else { - message.expirationDate = ""; - } - if (object.credentialHash !== undefined && object.credentialHash !== null) { - message.credentialHash = String(object.credentialHash); - } - else { - message.credentialHash = ""; - } - if (object.proof !== undefined && object.proof !== null) { - message.proof = exports.CredentialProof.fromJSON(object.proof); - } - else { - message.proof = undefined; - } - return message; - }, - toJSON(message) { - const obj = {}; - message.claim !== undefined && - (obj.claim = message.claim ? exports.Claim.toJSON(message.claim) : undefined); - message.issuer !== undefined && (obj.issuer = message.issuer); - message.issuanceDate !== undefined && - (obj.issuanceDate = message.issuanceDate); - message.expirationDate !== undefined && - (obj.expirationDate = message.expirationDate); - message.credentialHash !== undefined && - (obj.credentialHash = message.credentialHash); - message.proof !== undefined && - (obj.proof = message.proof - ? exports.CredentialProof.toJSON(message.proof) - : undefined); - return obj; - }, - fromPartial(object) { - const message = Object.assign({}, baseCredential); - if (object.claim !== undefined && object.claim !== null) { - message.claim = exports.Claim.fromPartial(object.claim); - } - else { - message.claim = undefined; - } - if (object.issuer !== undefined && object.issuer !== null) { - message.issuer = object.issuer; - } - else { - message.issuer = ""; - } - if (object.issuanceDate !== undefined && object.issuanceDate !== null) { - message.issuanceDate = object.issuanceDate; - } - else { - message.issuanceDate = ""; - } - if (object.expirationDate !== undefined && object.expirationDate !== null) { - message.expirationDate = object.expirationDate; - } - else { - message.expirationDate = ""; - } - if (object.credentialHash !== undefined && object.credentialHash !== null) { - message.credentialHash = object.credentialHash; - } - else { - message.credentialHash = ""; - } - if (object.proof !== undefined && object.proof !== null) { - message.proof = exports.CredentialProof.fromPartial(object.proof); - } - else { - message.proof = undefined; - } - return message; - }, -}; diff --git a/build/libs/generated/ssi/credential_schema.d.ts b/build/libs/generated/ssi/credential_schema.d.ts new file mode 100644 index 0000000..53ccc68 --- /dev/null +++ b/build/libs/generated/ssi/credential_schema.d.ts @@ -0,0 +1,331 @@ +import _m0 from "protobufjs/minimal"; +import { DocumentProof } from "./proof"; +export declare const protobufPackage = "hypersign.ssi.v1"; +export interface CredentialSchemaDocument { + "@context"?: string[] | undefined; + type?: string | undefined; + modelVersion?: string | undefined; + id?: string | undefined; + name?: string | undefined; + author?: string | undefined; + authored?: string | undefined; + schema?: CredentialSchemaProperty | undefined; +} +export interface CredentialSchemaProperty { + schema?: string | undefined; + description?: string | undefined; + type?: string | undefined; + properties?: string | undefined; + required?: string[] | undefined; + additionalProperties?: boolean | undefined; +} +export interface CredentialSchemaState { + credentialSchemaDocument?: CredentialSchemaDocument | undefined; + credentialSchemaProof?: DocumentProof | undefined; +} +export declare const CredentialSchemaDocument: { + encode(message: CredentialSchemaDocument, writer?: _m0.Writer): _m0.Writer; + decode(input: _m0.Reader | Uint8Array, length?: number): CredentialSchemaDocument; + fromJSON(object: any): CredentialSchemaDocument; + toJSON(message: CredentialSchemaDocument): unknown; + create]: never; }) | undefined; + type?: string | undefined; + modelVersion?: string | undefined; + id?: string | undefined; + name?: string | undefined; + author?: string | undefined; + authored?: string | undefined; + schema?: ({ + schema?: string | undefined; + description?: string | undefined; + type?: string | undefined; + properties?: string | undefined; + required?: string[] | undefined; + additionalProperties?: boolean | undefined; + } & { + schema?: string | undefined; + description?: string | undefined; + type?: string | undefined; + properties?: string | undefined; + required?: (string[] & string[] & { [K_1 in Exclude]: never; }) | undefined; + additionalProperties?: boolean | undefined; + } & { [K_2 in Exclude]: never; }) | undefined; + } & { [K_3 in Exclude]: never; }>(base?: I | undefined): CredentialSchemaDocument; + fromPartial]: never; }) | undefined; + type?: string | undefined; + modelVersion?: string | undefined; + id?: string | undefined; + name?: string | undefined; + author?: string | undefined; + authored?: string | undefined; + schema?: ({ + schema?: string | undefined; + description?: string | undefined; + type?: string | undefined; + properties?: string | undefined; + required?: string[] | undefined; + additionalProperties?: boolean | undefined; + } & { + schema?: string | undefined; + description?: string | undefined; + type?: string | undefined; + properties?: string | undefined; + required?: (string[] & string[] & { [K_5 in Exclude]: never; }) | undefined; + additionalProperties?: boolean | undefined; + } & { [K_6 in Exclude]: never; }) | undefined; + } & { [K_7 in Exclude]: never; }>(object: I_1): CredentialSchemaDocument; +}; +export declare const CredentialSchemaProperty: { + encode(message: CredentialSchemaProperty, writer?: _m0.Writer): _m0.Writer; + decode(input: _m0.Reader | Uint8Array, length?: number): CredentialSchemaProperty; + fromJSON(object: any): CredentialSchemaProperty; + toJSON(message: CredentialSchemaProperty): unknown; + create]: never; }) | undefined; + additionalProperties?: boolean | undefined; + } & { [K_1 in Exclude]: never; }>(base?: I | undefined): CredentialSchemaProperty; + fromPartial]: never; }) | undefined; + additionalProperties?: boolean | undefined; + } & { [K_3 in Exclude]: never; }>(object: I_1): CredentialSchemaProperty; +}; +export declare const CredentialSchemaState: { + encode(message: CredentialSchemaState, writer?: _m0.Writer): _m0.Writer; + decode(input: _m0.Reader | Uint8Array, length?: number): CredentialSchemaState; + fromJSON(object: any): CredentialSchemaState; + toJSON(message: CredentialSchemaState): unknown; + create]: never; }) | undefined; + type?: string | undefined; + modelVersion?: string | undefined; + id?: string | undefined; + name?: string | undefined; + author?: string | undefined; + authored?: string | undefined; + schema?: ({ + schema?: string | undefined; + description?: string | undefined; + type?: string | undefined; + properties?: string | undefined; + required?: string[] | undefined; + additionalProperties?: boolean | undefined; + } & { + schema?: string | undefined; + description?: string | undefined; + type?: string | undefined; + properties?: string | undefined; + required?: (string[] & string[] & { [K_1 in Exclude]: never; }) | undefined; + additionalProperties?: boolean | undefined; + } & { [K_2 in Exclude]: never; }) | undefined; + } & { [K_3 in Exclude]: never; }) | undefined; + credentialSchemaProof?: ({ + type?: string | undefined; + created?: string | undefined; + verificationMethod?: string | undefined; + proofPurpose?: string | undefined; + proofValue?: string | undefined; + clientSpecType?: import("./client_spec").ClientSpecType | undefined; + } & { + type?: string | undefined; + created?: string | undefined; + verificationMethod?: string | undefined; + proofPurpose?: string | undefined; + proofValue?: string | undefined; + clientSpecType?: import("./client_spec").ClientSpecType | undefined; + } & { [K_4 in Exclude]: never; }) | undefined; + } & { [K_5 in Exclude]: never; }>(base?: I | undefined): CredentialSchemaState; + fromPartial]: never; }) | undefined; + type?: string | undefined; + modelVersion?: string | undefined; + id?: string | undefined; + name?: string | undefined; + author?: string | undefined; + authored?: string | undefined; + schema?: ({ + schema?: string | undefined; + description?: string | undefined; + type?: string | undefined; + properties?: string | undefined; + required?: string[] | undefined; + additionalProperties?: boolean | undefined; + } & { + schema?: string | undefined; + description?: string | undefined; + type?: string | undefined; + properties?: string | undefined; + required?: (string[] & string[] & { [K_7 in Exclude]: never; }) | undefined; + additionalProperties?: boolean | undefined; + } & { [K_8 in Exclude]: never; }) | undefined; + } & { [K_9 in Exclude]: never; }) | undefined; + credentialSchemaProof?: ({ + type?: string | undefined; + created?: string | undefined; + verificationMethod?: string | undefined; + proofPurpose?: string | undefined; + proofValue?: string | undefined; + clientSpecType?: import("./client_spec").ClientSpecType | undefined; + } & { + type?: string | undefined; + created?: string | undefined; + verificationMethod?: string | undefined; + proofPurpose?: string | undefined; + proofValue?: string | undefined; + clientSpecType?: import("./client_spec").ClientSpecType | undefined; + } & { [K_10 in Exclude]: never; }) | undefined; + } & { [K_11 in Exclude]: never; }>(object: I_1): CredentialSchemaState; +}; +type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined; +export type DeepPartial = T extends Builtin ? T : T extends globalThis.Array ? globalThis.Array> : T extends ReadonlyArray ? ReadonlyArray> : T extends {} ? { + [K in keyof T]?: DeepPartial; +} : Partial; +type KeysOfUnion = T extends T ? keyof T : never; +export type Exact = P extends Builtin ? P : P & { + [K in keyof P]: Exact; +} & { + [K in Exclude>]: never; +}; +export {}; +//# sourceMappingURL=credential_schema.d.ts.map \ No newline at end of file diff --git a/build/libs/generated/ssi/credential_schema.d.ts.map b/build/libs/generated/ssi/credential_schema.d.ts.map new file mode 100644 index 0000000..857792e --- /dev/null +++ b/build/libs/generated/ssi/credential_schema.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"credential_schema.d.ts","sourceRoot":"","sources":["../../../../libs/generated/ssi/credential_schema.ts"],"names":[],"mappings":"AACA,OAAO,GAAG,MAAM,oBAAoB,CAAC;AACrC,OAAO,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAExC,eAAO,MAAM,eAAe,qBAAqB,CAAC;AAElD,MAAM,WAAW,wBAAwB;IACvC,UAAU,CAAC,EAAE,MAAM,EAAE,GAAG,SAAS,CAAC;IAClC,IAAI,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC1B,YAAY,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAClC,EAAE,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IACxB,IAAI,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC1B,MAAM,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC5B,QAAQ,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC9B,MAAM,CAAC,EAAE,wBAAwB,GAAG,SAAS,CAAC;CAC/C;AAED,MAAM,WAAW,wBAAwB;IACvC,MAAM,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC5B,WAAW,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IACjC,IAAI,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC1B,UAAU,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAChC,QAAQ,CAAC,EAAE,MAAM,EAAE,GAAG,SAAS,CAAC;IAChC,oBAAoB,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC;CAC5C;AAED,MAAM,WAAW,qBAAqB;IACpC,wBAAwB,CAAC,EAAE,wBAAwB,GAAG,SAAS,CAAC;IAChE,qBAAqB,CAAC,EAAE,aAAa,GAAG,SAAS,CAAC;CACnD;AAMD,eAAO,MAAM,wBAAwB;oBACnB,wBAAwB,WAAU,IAAI,MAAM,GAAyB,IAAI,MAAM;kBA8BjF,IAAI,MAAM,GAAG,UAAU,WAAW,MAAM,GAAG,wBAAwB;qBA2EhE,GAAG,GAAG,wBAAwB;oBAe/B,wBAAwB,GAAG,OAAO;;;eApJ3C,MAAM,GAAG,SAAS;uBACV,MAAM,GAAG,SAAS;aAC5B,MAAM,GAAG,SAAS;eAChB,MAAM,GAAG,SAAS;iBAChB,MAAM,GAAG,SAAS;mBAChB,MAAM,GAAG,SAAS;;qBAKpB,MAAM,GAAG,SAAS;0BACb,MAAM,GAAG,SAAS;mBACzB,MAAM,GAAG,SAAS;yBACZ,MAAM,GAAG,SAAS;;mCAER,OAAO,GAAG,SAAS;;;;eAfnC,MAAM,GAAG,SAAS;uBACV,MAAM,GAAG,SAAS;aAC5B,MAAM,GAAG,SAAS;eAChB,MAAM,GAAG,SAAS;iBAChB,MAAM,GAAG,SAAS;mBAChB,MAAM,GAAG,SAAS;;qBAKpB,MAAM,GAAG,SAAS;0BACb,MAAM,GAAG,SAAS;mBACzB,MAAM,GAAG,SAAS;yBACZ,MAAM,GAAG,SAAS;;mCAER,OAAO,GAAG,SAAS;;qBALjC,MAAM,GAAG,SAAS;0BACb,MAAM,GAAG,SAAS;mBACzB,MAAM,GAAG,SAAS;yBACZ,MAAM,GAAG,SAAS;;mCAER,OAAO,GAAG,SAAS;;sGAkKmC,wBAAwB;;;eAjL9F,MAAM,GAAG,SAAS;uBACV,MAAM,GAAG,SAAS;aAC5B,MAAM,GAAG,SAAS;eAChB,MAAM,GAAG,SAAS;iBAChB,MAAM,GAAG,SAAS;mBAChB,MAAM,GAAG,SAAS;;qBAKpB,MAAM,GAAG,SAAS;0BACb,MAAM,GAAG,SAAS;mBACzB,MAAM,GAAG,SAAS;yBACZ,MAAM,GAAG,SAAS;;mCAER,OAAO,GAAG,SAAS;;;;eAfnC,MAAM,GAAG,SAAS;uBACV,MAAM,GAAG,SAAS;aAC5B,MAAM,GAAG,SAAS;eAChB,MAAM,GAAG,SAAS;iBAChB,MAAM,GAAG,SAAS;mBAChB,MAAM,GAAG,SAAS;;qBAKpB,MAAM,GAAG,SAAS;0BACb,MAAM,GAAG,SAAS;mBACzB,MAAM,GAAG,SAAS;yBACZ,MAAM,GAAG,SAAS;;mCAER,OAAO,GAAG,SAAS;;qBALjC,MAAM,GAAG,SAAS;0BACb,MAAM,GAAG,SAAS;mBACzB,MAAM,GAAG,SAAS;yBACZ,MAAM,GAAG,SAAS;;mCAER,OAAO,GAAG,SAAS;;+FAqKyC,wBAAwB;CAc5G,CAAC;AAMF,eAAO,MAAM,wBAAwB;oBACnB,wBAAwB,WAAU,IAAI,MAAM,GAAyB,IAAI,MAAM;kBAwBjF,IAAI,MAAM,GAAG,UAAU,WAAW,MAAM,GAAG,wBAAwB;qBA6DhE,GAAG,GAAG,wBAAwB;oBAe/B,wBAAwB,GAAG,OAAO;;iBAnSzC,MAAM,GAAG,SAAS;sBACb,MAAM,GAAG,SAAS;eACzB,MAAM,GAAG,SAAS;qBACZ,MAAM,GAAG,SAAS;;+BAER,OAAO,GAAG,SAAS;;iBALjC,MAAM,GAAG,SAAS;sBACb,MAAM,GAAG,SAAS;eACzB,MAAM,GAAG,SAAS;qBACZ,MAAM,GAAG,SAAS;;+BAER,OAAO,GAAG,SAAS;sGAqTmC,wBAAwB;;iBA1T5F,MAAM,GAAG,SAAS;sBACb,MAAM,GAAG,SAAS;eACzB,MAAM,GAAG,SAAS;qBACZ,MAAM,GAAG,SAAS;;+BAER,OAAO,GAAG,SAAS;;iBALjC,MAAM,GAAG,SAAS;sBACb,MAAM,GAAG,SAAS;eACzB,MAAM,GAAG,SAAS;qBACZ,MAAM,GAAG,SAAS;;+BAER,OAAO,GAAG,SAAS;+FAwTyC,wBAAwB;CAU5G,CAAC;AAMF,eAAO,MAAM,qBAAqB;oBAChB,qBAAqB,WAAU,IAAI,MAAM,GAAyB,IAAI,MAAM;kBAU9E,IAAI,MAAM,GAAG,UAAU,WAAW,MAAM,GAAG,qBAAqB;qBA8B7D,GAAG,GAAG,qBAAqB;oBAW5B,qBAAqB,GAAG,OAAO;;;;mBA3YxC,MAAM,GAAG,SAAS;2BACV,MAAM,GAAG,SAAS;iBAC5B,MAAM,GAAG,SAAS;mBAChB,MAAM,GAAG,SAAS;qBAChB,MAAM,GAAG,SAAS;uBAChB,MAAM,GAAG,SAAS;;yBAKpB,MAAM,GAAG,SAAS;8BACb,MAAM,GAAG,SAAS;uBACzB,MAAM,GAAG,SAAS;6BACZ,MAAM,GAAG,SAAS;;uCAER,OAAO,GAAG,SAAS;;;;;;;;;;;;;;mBAfnC,MAAM,GAAG,SAAS;2BACV,MAAM,GAAG,SAAS;iBAC5B,MAAM,GAAG,SAAS;mBAChB,MAAM,GAAG,SAAS;qBAChB,MAAM,GAAG,SAAS;uBAChB,MAAM,GAAG,SAAS;;yBAKpB,MAAM,GAAG,SAAS;8BACb,MAAM,GAAG,SAAS;uBACzB,MAAM,GAAG,SAAS;6BACZ,MAAM,GAAG,SAAS;;uCAER,OAAO,GAAG,SAAS;;;;mBAfnC,MAAM,GAAG,SAAS;2BACV,MAAM,GAAG,SAAS;iBAC5B,MAAM,GAAG,SAAS;mBAChB,MAAM,GAAG,SAAS;qBAChB,MAAM,GAAG,SAAS;uBAChB,MAAM,GAAG,SAAS;;yBAKpB,MAAM,GAAG,SAAS;8BACb,MAAM,GAAG,SAAS;uBACzB,MAAM,GAAG,SAAS;6BACZ,MAAM,GAAG,SAAS;;uCAER,OAAO,GAAG,SAAS;;yBALjC,MAAM,GAAG,SAAS;8BACb,MAAM,GAAG,SAAS;uBACzB,MAAM,GAAG,SAAS;6BACZ,MAAM,GAAG,SAAS;;uCAER,OAAO,GAAG,SAAS;;;;;;;;;;;;;;;;;;mGAuYgC,qBAAqB;;;;mBAtZxF,MAAM,GAAG,SAAS;2BACV,MAAM,GAAG,SAAS;iBAC5B,MAAM,GAAG,SAAS;mBAChB,MAAM,GAAG,SAAS;qBAChB,MAAM,GAAG,SAAS;uBAChB,MAAM,GAAG,SAAS;;yBAKpB,MAAM,GAAG,SAAS;8BACb,MAAM,GAAG,SAAS;uBACzB,MAAM,GAAG,SAAS;6BACZ,MAAM,GAAG,SAAS;;uCAER,OAAO,GAAG,SAAS;;;;;;;;;;;;;;mBAfnC,MAAM,GAAG,SAAS;2BACV,MAAM,GAAG,SAAS;iBAC5B,MAAM,GAAG,SAAS;mBAChB,MAAM,GAAG,SAAS;qBAChB,MAAM,GAAG,SAAS;uBAChB,MAAM,GAAG,SAAS;;yBAKpB,MAAM,GAAG,SAAS;8BACb,MAAM,GAAG,SAAS;uBACzB,MAAM,GAAG,SAAS;6BACZ,MAAM,GAAG,SAAS;;uCAER,OAAO,GAAG,SAAS;;;;mBAfnC,MAAM,GAAG,SAAS;2BACV,MAAM,GAAG,SAAS;iBAC5B,MAAM,GAAG,SAAS;mBAChB,MAAM,GAAG,SAAS;qBAChB,MAAM,GAAG,SAAS;uBAChB,MAAM,GAAG,SAAS;;yBAKpB,MAAM,GAAG,SAAS;8BACb,MAAM,GAAG,SAAS;uBACzB,MAAM,GAAG,SAAS;6BACZ,MAAM,GAAG,SAAS;;uCAER,OAAO,GAAG,SAAS;;yBALjC,MAAM,GAAG,SAAS;8BACb,MAAM,GAAG,SAAS;uBACzB,MAAM,GAAG,SAAS;6BACZ,MAAM,GAAG,SAAS;;uCAER,OAAO,GAAG,SAAS;;;;;;;;;;;;;;;;;;6FA0YsC,qBAAqB;CAYtG,CAAC;AAEF,KAAK,OAAO,GAAG,IAAI,GAAG,QAAQ,GAAG,UAAU,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,SAAS,CAAC;AAEpF,MAAM,MAAM,WAAW,CAAC,CAAC,IAAI,CAAC,SAAS,OAAO,GAAG,CAAC,GAC9C,CAAC,SAAS,UAAU,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,GAAG,UAAU,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,GACtE,CAAC,SAAS,aAAa,CAAC,MAAM,CAAC,CAAC,GAAG,aAAa,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,GAChE,CAAC,SAAS,EAAE,GAAG;KAAG,CAAC,IAAI,MAAM,CAAC,CAAC,CAAC,EAAE,WAAW,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;CAAE,GACrD,OAAO,CAAC,CAAC,CAAC,CAAC;AAEf,KAAK,WAAW,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,GAAG,MAAM,CAAC,GAAG,KAAK,CAAC;AACpD,MAAM,MAAM,KAAK,CAAC,CAAC,EAAE,CAAC,SAAS,CAAC,IAAI,CAAC,SAAS,OAAO,GAAG,CAAC,GACrD,CAAC,GAAG;KAAG,CAAC,IAAI,MAAM,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC;CAAE,GAAG;KAAG,CAAC,IAAI,OAAO,CAAC,MAAM,CAAC,EAAE,WAAW,CAAC,CAAC,CAAC,CAAC,GAAG,KAAK;CAAE,CAAC"} \ No newline at end of file diff --git a/build/libs/generated/ssi/credential_schema.js b/build/libs/generated/ssi/credential_schema.js new file mode 100644 index 0000000..9253c4c --- /dev/null +++ b/build/libs/generated/ssi/credential_schema.js @@ -0,0 +1,383 @@ +"use strict"; +var __importDefault = (this && this.__importDefault) || function (mod) { + return (mod && mod.__esModule) ? mod : { "default": mod }; +}; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.CredentialSchemaState = exports.CredentialSchemaProperty = exports.CredentialSchemaDocument = exports.protobufPackage = void 0; +/* eslint-disable */ +const minimal_1 = __importDefault(require("protobufjs/minimal")); +const proof_1 = require("./proof"); +exports.protobufPackage = "hypersign.ssi.v1"; +function createBaseCredentialSchemaDocument() { + return {}; +} +exports.CredentialSchemaDocument = { + encode(message, writer = minimal_1.default.Writer.create()) { + if (message["@context"] !== undefined && message["@context"].length !== 0) { + for (const v of message["@context"]) { + writer.uint32(10).string(v); + } + } + if (message.type !== undefined && message.type !== "") { + writer.uint32(18).string(message.type); + } + if (message.modelVersion !== undefined && message.modelVersion !== "") { + writer.uint32(26).string(message.modelVersion); + } + if (message.id !== undefined && message.id !== "") { + writer.uint32(34).string(message.id); + } + if (message.name !== undefined && message.name !== "") { + writer.uint32(42).string(message.name); + } + if (message.author !== undefined && message.author !== "") { + writer.uint32(50).string(message.author); + } + if (message.authored !== undefined && message.authored !== "") { + writer.uint32(58).string(message.authored); + } + if (message.schema !== undefined) { + exports.CredentialSchemaProperty.encode(message.schema, writer.uint32(66).fork()).ldelim(); + } + return writer; + }, + decode(input, length) { + const reader = input instanceof minimal_1.default.Reader ? input : minimal_1.default.Reader.create(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseCredentialSchemaDocument(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + if (tag !== 10) { + break; + } + if (message["@context"] === undefined) { + message["@context"] = []; + } + message["@context"].push(reader.string()); + continue; + case 2: + if (tag !== 18) { + break; + } + message.type = reader.string(); + continue; + case 3: + if (tag !== 26) { + break; + } + message.modelVersion = reader.string(); + continue; + case 4: + if (tag !== 34) { + break; + } + message.id = reader.string(); + continue; + case 5: + if (tag !== 42) { + break; + } + message.name = reader.string(); + continue; + case 6: + if (tag !== 50) { + break; + } + message.author = reader.string(); + continue; + case 7: + if (tag !== 58) { + break; + } + message.authored = reader.string(); + continue; + case 8: + if (tag !== 66) { + break; + } + message.schema = exports.CredentialSchemaProperty.decode(reader, reader.uint32()); + continue; + } + if ((tag & 7) === 4 || tag === 0) { + break; + } + reader.skipType(tag & 7); + } + return message; + }, + fromJSON(object) { + return { + "@context": globalThis.Array.isArray(object === null || object === void 0 ? void 0 : object["@context"]) + ? object["@context"].map((e) => globalThis.String(e)) + : undefined, + type: isSet(object.type) ? globalThis.String(object.type) : undefined, + modelVersion: isSet(object.modelVersion) ? globalThis.String(object.modelVersion) : undefined, + id: isSet(object.id) ? globalThis.String(object.id) : undefined, + name: isSet(object.name) ? globalThis.String(object.name) : undefined, + author: isSet(object.author) ? globalThis.String(object.author) : undefined, + authored: isSet(object.authored) ? globalThis.String(object.authored) : undefined, + schema: isSet(object.schema) ? exports.CredentialSchemaProperty.fromJSON(object.schema) : undefined, + }; + }, + toJSON(message) { + var _a; + const obj = {}; + if ((_a = message["@context"]) === null || _a === void 0 ? void 0 : _a.length) { + obj["@context"] = message["@context"]; + } + if (message.type !== undefined && message.type !== "") { + obj.type = message.type; + } + if (message.modelVersion !== undefined && message.modelVersion !== "") { + obj.modelVersion = message.modelVersion; + } + if (message.id !== undefined && message.id !== "") { + obj.id = message.id; + } + if (message.name !== undefined && message.name !== "") { + obj.name = message.name; + } + if (message.author !== undefined && message.author !== "") { + obj.author = message.author; + } + if (message.authored !== undefined && message.authored !== "") { + obj.authored = message.authored; + } + if (message.schema !== undefined) { + obj.schema = exports.CredentialSchemaProperty.toJSON(message.schema); + } + return obj; + }, + create(base) { + return exports.CredentialSchemaDocument.fromPartial(base !== null && base !== void 0 ? base : {}); + }, + fromPartial(object) { + var _a, _b, _c, _d, _e, _f, _g; + const message = createBaseCredentialSchemaDocument(); + message["@context"] = ((_a = object["@context"]) === null || _a === void 0 ? void 0 : _a.map((e) => e)) || undefined; + message.type = (_b = object.type) !== null && _b !== void 0 ? _b : undefined; + message.modelVersion = (_c = object.modelVersion) !== null && _c !== void 0 ? _c : undefined; + message.id = (_d = object.id) !== null && _d !== void 0 ? _d : undefined; + message.name = (_e = object.name) !== null && _e !== void 0 ? _e : undefined; + message.author = (_f = object.author) !== null && _f !== void 0 ? _f : undefined; + message.authored = (_g = object.authored) !== null && _g !== void 0 ? _g : undefined; + message.schema = (object.schema !== undefined && object.schema !== null) + ? exports.CredentialSchemaProperty.fromPartial(object.schema) + : undefined; + return message; + }, +}; +function createBaseCredentialSchemaProperty() { + return {}; +} +exports.CredentialSchemaProperty = { + encode(message, writer = minimal_1.default.Writer.create()) { + if (message.schema !== undefined && message.schema !== "") { + writer.uint32(10).string(message.schema); + } + if (message.description !== undefined && message.description !== "") { + writer.uint32(18).string(message.description); + } + if (message.type !== undefined && message.type !== "") { + writer.uint32(26).string(message.type); + } + if (message.properties !== undefined && message.properties !== "") { + writer.uint32(34).string(message.properties); + } + if (message.required !== undefined && message.required.length !== 0) { + for (const v of message.required) { + writer.uint32(42).string(v); + } + } + if (message.additionalProperties === true) { + writer.uint32(48).bool(message.additionalProperties); + } + return writer; + }, + decode(input, length) { + const reader = input instanceof minimal_1.default.Reader ? input : minimal_1.default.Reader.create(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseCredentialSchemaProperty(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + if (tag !== 10) { + break; + } + message.schema = reader.string(); + continue; + case 2: + if (tag !== 18) { + break; + } + message.description = reader.string(); + continue; + case 3: + if (tag !== 26) { + break; + } + message.type = reader.string(); + continue; + case 4: + if (tag !== 34) { + break; + } + message.properties = reader.string(); + continue; + case 5: + if (tag !== 42) { + break; + } + if (message.required === undefined) { + message.required = []; + } + message.required.push(reader.string()); + continue; + case 6: + if (tag !== 48) { + break; + } + message.additionalProperties = reader.bool(); + continue; + } + if ((tag & 7) === 4 || tag === 0) { + break; + } + reader.skipType(tag & 7); + } + return message; + }, + fromJSON(object) { + return { + schema: isSet(object.schema) ? globalThis.String(object.schema) : undefined, + description: isSet(object.description) ? globalThis.String(object.description) : undefined, + type: isSet(object.type) ? globalThis.String(object.type) : undefined, + properties: isSet(object.properties) ? globalThis.String(object.properties) : undefined, + required: globalThis.Array.isArray(object === null || object === void 0 ? void 0 : object.required) + ? object.required.map((e) => globalThis.String(e)) + : undefined, + additionalProperties: isSet(object.additionalProperties) + ? globalThis.Boolean(object.additionalProperties) + : undefined, + }; + }, + toJSON(message) { + var _a; + const obj = {}; + if (message.schema !== undefined && message.schema !== "") { + obj.schema = message.schema; + } + if (message.description !== undefined && message.description !== "") { + obj.description = message.description; + } + if (message.type !== undefined && message.type !== "") { + obj.type = message.type; + } + if (message.properties !== undefined && message.properties !== "") { + obj.properties = message.properties; + } + if ((_a = message.required) === null || _a === void 0 ? void 0 : _a.length) { + obj.required = message.required; + } + if (message.additionalProperties === true) { + obj.additionalProperties = message.additionalProperties; + } + return obj; + }, + create(base) { + return exports.CredentialSchemaProperty.fromPartial(base !== null && base !== void 0 ? base : {}); + }, + fromPartial(object) { + var _a, _b, _c, _d, _e, _f; + const message = createBaseCredentialSchemaProperty(); + message.schema = (_a = object.schema) !== null && _a !== void 0 ? _a : undefined; + message.description = (_b = object.description) !== null && _b !== void 0 ? _b : undefined; + message.type = (_c = object.type) !== null && _c !== void 0 ? _c : undefined; + message.properties = (_d = object.properties) !== null && _d !== void 0 ? _d : undefined; + message.required = ((_e = object.required) === null || _e === void 0 ? void 0 : _e.map((e) => e)) || undefined; + message.additionalProperties = (_f = object.additionalProperties) !== null && _f !== void 0 ? _f : undefined; + return message; + }, +}; +function createBaseCredentialSchemaState() { + return {}; +} +exports.CredentialSchemaState = { + encode(message, writer = minimal_1.default.Writer.create()) { + if (message.credentialSchemaDocument !== undefined) { + exports.CredentialSchemaDocument.encode(message.credentialSchemaDocument, writer.uint32(10).fork()).ldelim(); + } + if (message.credentialSchemaProof !== undefined) { + proof_1.DocumentProof.encode(message.credentialSchemaProof, writer.uint32(18).fork()).ldelim(); + } + return writer; + }, + decode(input, length) { + const reader = input instanceof minimal_1.default.Reader ? input : minimal_1.default.Reader.create(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseCredentialSchemaState(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + if (tag !== 10) { + break; + } + message.credentialSchemaDocument = exports.CredentialSchemaDocument.decode(reader, reader.uint32()); + continue; + case 2: + if (tag !== 18) { + break; + } + message.credentialSchemaProof = proof_1.DocumentProof.decode(reader, reader.uint32()); + continue; + } + if ((tag & 7) === 4 || tag === 0) { + break; + } + reader.skipType(tag & 7); + } + return message; + }, + fromJSON(object) { + return { + credentialSchemaDocument: isSet(object.credentialSchemaDocument) + ? exports.CredentialSchemaDocument.fromJSON(object.credentialSchemaDocument) + : undefined, + credentialSchemaProof: isSet(object.credentialSchemaProof) + ? proof_1.DocumentProof.fromJSON(object.credentialSchemaProof) + : undefined, + }; + }, + toJSON(message) { + const obj = {}; + if (message.credentialSchemaDocument !== undefined) { + obj.credentialSchemaDocument = exports.CredentialSchemaDocument.toJSON(message.credentialSchemaDocument); + } + if (message.credentialSchemaProof !== undefined) { + obj.credentialSchemaProof = proof_1.DocumentProof.toJSON(message.credentialSchemaProof); + } + return obj; + }, + create(base) { + return exports.CredentialSchemaState.fromPartial(base !== null && base !== void 0 ? base : {}); + }, + fromPartial(object) { + const message = createBaseCredentialSchemaState(); + message.credentialSchemaDocument = + (object.credentialSchemaDocument !== undefined && object.credentialSchemaDocument !== null) + ? exports.CredentialSchemaDocument.fromPartial(object.credentialSchemaDocument) + : undefined; + message.credentialSchemaProof = + (object.credentialSchemaProof !== undefined && object.credentialSchemaProof !== null) + ? proof_1.DocumentProof.fromPartial(object.credentialSchemaProof) + : undefined; + return message; + }, +}; +function isSet(value) { + return value !== null && value !== undefined; +} diff --git a/build/libs/generated/ssi/credential_status.d.ts b/build/libs/generated/ssi/credential_status.d.ts new file mode 100644 index 0000000..8f0c1f9 --- /dev/null +++ b/build/libs/generated/ssi/credential_status.d.ts @@ -0,0 +1,189 @@ +import _m0 from "protobufjs/minimal"; +import { DocumentProof } from "./proof"; +export declare const protobufPackage = "hypersign.ssi.v1"; +export interface CredentialStatusDocument { + "@context"?: string[] | undefined; + id?: string | undefined; + revoked?: boolean | undefined; + suspended?: boolean | undefined; + remarks?: string | undefined; + issuer?: string | undefined; + issuanceDate?: string | undefined; + credentialMerkleRootHash?: string | undefined; +} +export interface CredentialStatusState { + credentialStatusDocument?: CredentialStatusDocument | undefined; + credentialStatusProof?: DocumentProof | undefined; +} +export declare const CredentialStatusDocument: { + encode(message: CredentialStatusDocument, writer?: _m0.Writer): _m0.Writer; + decode(input: _m0.Reader | Uint8Array, length?: number): CredentialStatusDocument; + fromJSON(object: any): CredentialStatusDocument; + toJSON(message: CredentialStatusDocument): unknown; + create]: never; }) | undefined; + id?: string | undefined; + revoked?: boolean | undefined; + suspended?: boolean | undefined; + remarks?: string | undefined; + issuer?: string | undefined; + issuanceDate?: string | undefined; + credentialMerkleRootHash?: string | undefined; + } & { [K_1 in Exclude]: never; }>(base?: I | undefined): CredentialStatusDocument; + fromPartial]: never; }) | undefined; + id?: string | undefined; + revoked?: boolean | undefined; + suspended?: boolean | undefined; + remarks?: string | undefined; + issuer?: string | undefined; + issuanceDate?: string | undefined; + credentialMerkleRootHash?: string | undefined; + } & { [K_3 in Exclude]: never; }>(object: I_1): CredentialStatusDocument; +}; +export declare const CredentialStatusState: { + encode(message: CredentialStatusState, writer?: _m0.Writer): _m0.Writer; + decode(input: _m0.Reader | Uint8Array, length?: number): CredentialStatusState; + fromJSON(object: any): CredentialStatusState; + toJSON(message: CredentialStatusState): unknown; + create]: never; }) | undefined; + id?: string | undefined; + revoked?: boolean | undefined; + suspended?: boolean | undefined; + remarks?: string | undefined; + issuer?: string | undefined; + issuanceDate?: string | undefined; + credentialMerkleRootHash?: string | undefined; + } & { [K_1 in Exclude]: never; }) | undefined; + credentialStatusProof?: ({ + type?: string | undefined; + created?: string | undefined; + verificationMethod?: string | undefined; + proofPurpose?: string | undefined; + proofValue?: string | undefined; + clientSpecType?: import("./client_spec").ClientSpecType | undefined; + } & { + type?: string | undefined; + created?: string | undefined; + verificationMethod?: string | undefined; + proofPurpose?: string | undefined; + proofValue?: string | undefined; + clientSpecType?: import("./client_spec").ClientSpecType | undefined; + } & { [K_2 in Exclude]: never; }) | undefined; + } & { [K_3 in Exclude]: never; }>(base?: I | undefined): CredentialStatusState; + fromPartial]: never; }) | undefined; + id?: string | undefined; + revoked?: boolean | undefined; + suspended?: boolean | undefined; + remarks?: string | undefined; + issuer?: string | undefined; + issuanceDate?: string | undefined; + credentialMerkleRootHash?: string | undefined; + } & { [K_5 in Exclude]: never; }) | undefined; + credentialStatusProof?: ({ + type?: string | undefined; + created?: string | undefined; + verificationMethod?: string | undefined; + proofPurpose?: string | undefined; + proofValue?: string | undefined; + clientSpecType?: import("./client_spec").ClientSpecType | undefined; + } & { + type?: string | undefined; + created?: string | undefined; + verificationMethod?: string | undefined; + proofPurpose?: string | undefined; + proofValue?: string | undefined; + clientSpecType?: import("./client_spec").ClientSpecType | undefined; + } & { [K_6 in Exclude]: never; }) | undefined; + } & { [K_7 in Exclude]: never; }>(object: I_1): CredentialStatusState; +}; +type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined; +export type DeepPartial = T extends Builtin ? T : T extends globalThis.Array ? globalThis.Array> : T extends ReadonlyArray ? ReadonlyArray> : T extends {} ? { + [K in keyof T]?: DeepPartial; +} : Partial; +type KeysOfUnion = T extends T ? keyof T : never; +export type Exact = P extends Builtin ? P : P & { + [K in keyof P]: Exact; +} & { + [K in Exclude>]: never; +}; +export {}; +//# sourceMappingURL=credential_status.d.ts.map \ No newline at end of file diff --git a/build/libs/generated/ssi/credential_status.d.ts.map b/build/libs/generated/ssi/credential_status.d.ts.map new file mode 100644 index 0000000..7392346 --- /dev/null +++ b/build/libs/generated/ssi/credential_status.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"credential_status.d.ts","sourceRoot":"","sources":["../../../../libs/generated/ssi/credential_status.ts"],"names":[],"mappings":"AACA,OAAO,GAAG,MAAM,oBAAoB,CAAC;AACrC,OAAO,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAExC,eAAO,MAAM,eAAe,qBAAqB,CAAC;AAElD,MAAM,WAAW,wBAAwB;IACvC,UAAU,CAAC,EAAE,MAAM,EAAE,GAAG,SAAS,CAAC;IAClC,EAAE,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IACxB,OAAO,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC;IAC9B,SAAS,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC;IAChC,OAAO,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC7B,MAAM,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC5B,YAAY,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAClC,wBAAwB,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;CAC/C;AAED,MAAM,WAAW,qBAAqB;IACpC,wBAAwB,CAAC,EAAE,wBAAwB,GAAG,SAAS,CAAC;IAChE,qBAAqB,CAAC,EAAE,aAAa,GAAG,SAAS,CAAC;CACnD;AAMD,eAAO,MAAM,wBAAwB;oBACnB,wBAAwB,WAAU,IAAI,MAAM,GAAyB,IAAI,MAAM;kBA8BjF,IAAI,MAAM,GAAG,UAAU,WAAW,MAAM,GAAG,wBAAwB;qBA2EhE,GAAG,GAAG,wBAAwB;oBAiB/B,wBAAwB,GAAG,OAAO;;;aA7I7C,MAAM,GAAG,SAAS;kBACb,OAAO,GAAG,SAAS;oBACjB,OAAO,GAAG,SAAS;kBACrB,MAAM,GAAG,SAAS;iBACnB,MAAM,GAAG,SAAS;uBACZ,MAAM,GAAG,SAAS;mCACN,MAAM,GAAG,SAAS;;;aANxC,MAAM,GAAG,SAAS;kBACb,OAAO,GAAG,SAAS;oBACjB,OAAO,GAAG,SAAS;kBACrB,MAAM,GAAG,SAAS;iBACnB,MAAM,GAAG,SAAS;uBACZ,MAAM,GAAG,SAAS;mCACN,MAAM,GAAG,SAAS;sGAoKgC,wBAAwB;;;aA1KhG,MAAM,GAAG,SAAS;kBACb,OAAO,GAAG,SAAS;oBACjB,OAAO,GAAG,SAAS;kBACrB,MAAM,GAAG,SAAS;iBACnB,MAAM,GAAG,SAAS;uBACZ,MAAM,GAAG,SAAS;mCACN,MAAM,GAAG,SAAS;;;aANxC,MAAM,GAAG,SAAS;kBACb,OAAO,GAAG,SAAS;oBACjB,OAAO,GAAG,SAAS;kBACrB,MAAM,GAAG,SAAS;iBACnB,MAAM,GAAG,SAAS;uBACZ,MAAM,GAAG,SAAS;mCACN,MAAM,GAAG,SAAS;+FAuKsC,wBAAwB;CAY5G,CAAC;AAMF,eAAO,MAAM,qBAAqB;oBAChB,qBAAqB,WAAU,IAAI,MAAM,GAAyB,IAAI,MAAM;kBAU9E,IAAI,MAAM,GAAG,UAAU,WAAW,MAAM,GAAG,qBAAqB;qBA8B7D,GAAG,GAAG,qBAAqB;oBAW5B,qBAAqB,GAAG,OAAO;;;;iBAnP1C,MAAM,GAAG,SAAS;sBACb,OAAO,GAAG,SAAS;wBACjB,OAAO,GAAG,SAAS;sBACrB,MAAM,GAAG,SAAS;qBACnB,MAAM,GAAG,SAAS;2BACZ,MAAM,GAAG,SAAS;uCACN,MAAM,GAAG,SAAS;;;;;;;;;;;;;iBANxC,MAAM,GAAG,SAAS;sBACb,OAAO,GAAG,SAAS;wBACjB,OAAO,GAAG,SAAS;sBACrB,MAAM,GAAG,SAAS;qBACnB,MAAM,GAAG,SAAS;2BACZ,MAAM,GAAG,SAAS;uCACN,MAAM,GAAG,SAAS;;;iBANxC,MAAM,GAAG,SAAS;sBACb,OAAO,GAAG,SAAS;wBACjB,OAAO,GAAG,SAAS;sBACrB,MAAM,GAAG,SAAS;qBACnB,MAAM,GAAG,SAAS;2BACZ,MAAM,GAAG,SAAS;uCACN,MAAM,GAAG,SAAS;;;;;;;;;;;;;;;;;mGAwP6B,qBAAqB;;;;iBA9P1F,MAAM,GAAG,SAAS;sBACb,OAAO,GAAG,SAAS;wBACjB,OAAO,GAAG,SAAS;sBACrB,MAAM,GAAG,SAAS;qBACnB,MAAM,GAAG,SAAS;2BACZ,MAAM,GAAG,SAAS;uCACN,MAAM,GAAG,SAAS;;;;;;;;;;;;;iBANxC,MAAM,GAAG,SAAS;sBACb,OAAO,GAAG,SAAS;wBACjB,OAAO,GAAG,SAAS;sBACrB,MAAM,GAAG,SAAS;qBACnB,MAAM,GAAG,SAAS;2BACZ,MAAM,GAAG,SAAS;uCACN,MAAM,GAAG,SAAS;;;iBANxC,MAAM,GAAG,SAAS;sBACb,OAAO,GAAG,SAAS;wBACjB,OAAO,GAAG,SAAS;sBACrB,MAAM,GAAG,SAAS;qBACnB,MAAM,GAAG,SAAS;2BACZ,MAAM,GAAG,SAAS;uCACN,MAAM,GAAG,SAAS;;;;;;;;;;;;;;;;;4FA2PmC,qBAAqB;CAYtG,CAAC;AAEF,KAAK,OAAO,GAAG,IAAI,GAAG,QAAQ,GAAG,UAAU,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,SAAS,CAAC;AAEpF,MAAM,MAAM,WAAW,CAAC,CAAC,IAAI,CAAC,SAAS,OAAO,GAAG,CAAC,GAC9C,CAAC,SAAS,UAAU,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,GAAG,UAAU,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,GACtE,CAAC,SAAS,aAAa,CAAC,MAAM,CAAC,CAAC,GAAG,aAAa,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,GAChE,CAAC,SAAS,EAAE,GAAG;KAAG,CAAC,IAAI,MAAM,CAAC,CAAC,CAAC,EAAE,WAAW,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;CAAE,GACrD,OAAO,CAAC,CAAC,CAAC,CAAC;AAEf,KAAK,WAAW,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,GAAG,MAAM,CAAC,GAAG,KAAK,CAAC;AACpD,MAAM,MAAM,KAAK,CAAC,CAAC,EAAE,CAAC,SAAS,CAAC,IAAI,CAAC,SAAS,OAAO,GAAG,CAAC,GACrD,CAAC,GAAG;KAAG,CAAC,IAAI,MAAM,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC;CAAE,GAAG;KAAG,CAAC,IAAI,OAAO,CAAC,MAAM,CAAC,EAAE,WAAW,CAAC,CAAC,CAAC,CAAC,GAAG,KAAK;CAAE,CAAC"} \ No newline at end of file diff --git a/build/libs/generated/ssi/credential_status.js b/build/libs/generated/ssi/credential_status.js new file mode 100644 index 0000000..0b6f9ab --- /dev/null +++ b/build/libs/generated/ssi/credential_status.js @@ -0,0 +1,250 @@ +"use strict"; +var __importDefault = (this && this.__importDefault) || function (mod) { + return (mod && mod.__esModule) ? mod : { "default": mod }; +}; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.CredentialStatusState = exports.CredentialStatusDocument = exports.protobufPackage = void 0; +/* eslint-disable */ +const minimal_1 = __importDefault(require("protobufjs/minimal")); +const proof_1 = require("./proof"); +exports.protobufPackage = "hypersign.ssi.v1"; +function createBaseCredentialStatusDocument() { + return {}; +} +exports.CredentialStatusDocument = { + encode(message, writer = minimal_1.default.Writer.create()) { + if (message["@context"] !== undefined && message["@context"].length !== 0) { + for (const v of message["@context"]) { + writer.uint32(10).string(v); + } + } + if (message.id !== undefined && message.id !== "") { + writer.uint32(18).string(message.id); + } + if (message.revoked === true) { + writer.uint32(24).bool(message.revoked); + } + if (message.suspended === true) { + writer.uint32(32).bool(message.suspended); + } + if (message.remarks !== undefined && message.remarks !== "") { + writer.uint32(42).string(message.remarks); + } + if (message.issuer !== undefined && message.issuer !== "") { + writer.uint32(50).string(message.issuer); + } + if (message.issuanceDate !== undefined && message.issuanceDate !== "") { + writer.uint32(58).string(message.issuanceDate); + } + if (message.credentialMerkleRootHash !== undefined && message.credentialMerkleRootHash !== "") { + writer.uint32(66).string(message.credentialMerkleRootHash); + } + return writer; + }, + decode(input, length) { + const reader = input instanceof minimal_1.default.Reader ? input : minimal_1.default.Reader.create(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseCredentialStatusDocument(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + if (tag !== 10) { + break; + } + if (message["@context"] === undefined) { + message["@context"] = []; + } + message["@context"].push(reader.string()); + continue; + case 2: + if (tag !== 18) { + break; + } + message.id = reader.string(); + continue; + case 3: + if (tag !== 24) { + break; + } + message.revoked = reader.bool(); + continue; + case 4: + if (tag !== 32) { + break; + } + message.suspended = reader.bool(); + continue; + case 5: + if (tag !== 42) { + break; + } + message.remarks = reader.string(); + continue; + case 6: + if (tag !== 50) { + break; + } + message.issuer = reader.string(); + continue; + case 7: + if (tag !== 58) { + break; + } + message.issuanceDate = reader.string(); + continue; + case 8: + if (tag !== 66) { + break; + } + message.credentialMerkleRootHash = reader.string(); + continue; + } + if ((tag & 7) === 4 || tag === 0) { + break; + } + reader.skipType(tag & 7); + } + return message; + }, + fromJSON(object) { + return { + "@context": globalThis.Array.isArray(object === null || object === void 0 ? void 0 : object["@context"]) + ? object["@context"].map((e) => globalThis.String(e)) + : undefined, + id: isSet(object.id) ? globalThis.String(object.id) : undefined, + revoked: isSet(object.revoked) ? globalThis.Boolean(object.revoked) : undefined, + suspended: isSet(object.suspended) ? globalThis.Boolean(object.suspended) : undefined, + remarks: isSet(object.remarks) ? globalThis.String(object.remarks) : undefined, + issuer: isSet(object.issuer) ? globalThis.String(object.issuer) : undefined, + issuanceDate: isSet(object.issuanceDate) ? globalThis.String(object.issuanceDate) : undefined, + credentialMerkleRootHash: isSet(object.credentialMerkleRootHash) + ? globalThis.String(object.credentialMerkleRootHash) + : undefined, + }; + }, + toJSON(message) { + var _a; + const obj = {}; + if ((_a = message["@context"]) === null || _a === void 0 ? void 0 : _a.length) { + obj["@context"] = message["@context"]; + } + if (message.id !== undefined && message.id !== "") { + obj.id = message.id; + } + if (message.revoked === true) { + obj.revoked = message.revoked; + } + if (message.suspended === true) { + obj.suspended = message.suspended; + } + if (message.remarks !== undefined && message.remarks !== "") { + obj.remarks = message.remarks; + } + if (message.issuer !== undefined && message.issuer !== "") { + obj.issuer = message.issuer; + } + if (message.issuanceDate !== undefined && message.issuanceDate !== "") { + obj.issuanceDate = message.issuanceDate; + } + if (message.credentialMerkleRootHash !== undefined && message.credentialMerkleRootHash !== "") { + obj.credentialMerkleRootHash = message.credentialMerkleRootHash; + } + return obj; + }, + create(base) { + return exports.CredentialStatusDocument.fromPartial(base !== null && base !== void 0 ? base : {}); + }, + fromPartial(object) { + var _a, _b, _c, _d, _e, _f, _g, _h; + const message = createBaseCredentialStatusDocument(); + message["@context"] = ((_a = object["@context"]) === null || _a === void 0 ? void 0 : _a.map((e) => e)) || undefined; + message.id = (_b = object.id) !== null && _b !== void 0 ? _b : undefined; + message.revoked = (_c = object.revoked) !== null && _c !== void 0 ? _c : undefined; + message.suspended = (_d = object.suspended) !== null && _d !== void 0 ? _d : undefined; + message.remarks = (_e = object.remarks) !== null && _e !== void 0 ? _e : undefined; + message.issuer = (_f = object.issuer) !== null && _f !== void 0 ? _f : undefined; + message.issuanceDate = (_g = object.issuanceDate) !== null && _g !== void 0 ? _g : undefined; + message.credentialMerkleRootHash = (_h = object.credentialMerkleRootHash) !== null && _h !== void 0 ? _h : undefined; + return message; + }, +}; +function createBaseCredentialStatusState() { + return {}; +} +exports.CredentialStatusState = { + encode(message, writer = minimal_1.default.Writer.create()) { + if (message.credentialStatusDocument !== undefined) { + exports.CredentialStatusDocument.encode(message.credentialStatusDocument, writer.uint32(10).fork()).ldelim(); + } + if (message.credentialStatusProof !== undefined) { + proof_1.DocumentProof.encode(message.credentialStatusProof, writer.uint32(18).fork()).ldelim(); + } + return writer; + }, + decode(input, length) { + const reader = input instanceof minimal_1.default.Reader ? input : minimal_1.default.Reader.create(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseCredentialStatusState(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + if (tag !== 10) { + break; + } + message.credentialStatusDocument = exports.CredentialStatusDocument.decode(reader, reader.uint32()); + continue; + case 2: + if (tag !== 18) { + break; + } + message.credentialStatusProof = proof_1.DocumentProof.decode(reader, reader.uint32()); + continue; + } + if ((tag & 7) === 4 || tag === 0) { + break; + } + reader.skipType(tag & 7); + } + return message; + }, + fromJSON(object) { + return { + credentialStatusDocument: isSet(object.credentialStatusDocument) + ? exports.CredentialStatusDocument.fromJSON(object.credentialStatusDocument) + : undefined, + credentialStatusProof: isSet(object.credentialStatusProof) + ? proof_1.DocumentProof.fromJSON(object.credentialStatusProof) + : undefined, + }; + }, + toJSON(message) { + const obj = {}; + if (message.credentialStatusDocument !== undefined) { + obj.credentialStatusDocument = exports.CredentialStatusDocument.toJSON(message.credentialStatusDocument); + } + if (message.credentialStatusProof !== undefined) { + obj.credentialStatusProof = proof_1.DocumentProof.toJSON(message.credentialStatusProof); + } + return obj; + }, + create(base) { + return exports.CredentialStatusState.fromPartial(base !== null && base !== void 0 ? base : {}); + }, + fromPartial(object) { + const message = createBaseCredentialStatusState(); + message.credentialStatusDocument = + (object.credentialStatusDocument !== undefined && object.credentialStatusDocument !== null) + ? exports.CredentialStatusDocument.fromPartial(object.credentialStatusDocument) + : undefined; + message.credentialStatusProof = + (object.credentialStatusProof !== undefined && object.credentialStatusProof !== null) + ? proof_1.DocumentProof.fromPartial(object.credentialStatusProof) + : undefined; + return message; + }, +}; +function isSet(value) { + return value !== null && value !== undefined; +} diff --git a/build/libs/generated/ssi/did.d.ts b/build/libs/generated/ssi/did.d.ts index b5f07b7..6cbb041 100644 --- a/build/libs/generated/ssi/did.d.ts +++ b/build/libs/generated/ssi/did.d.ts @@ -1,93 +1,533 @@ -import { ClientSpec } from "./clientSpec"; -import { Writer, Reader } from "protobufjs/minimal"; -export declare const protobufPackage = "hypersignprotocol.hidnode.ssi"; -export interface Did { - context: string[]; - id: string; - controller: string[]; - alsoKnownAs: string[]; - verificationMethod: VerificationMethod[]; - authentication: string[]; - assertionMethod: string[]; - keyAgreement: string[]; - capabilityInvocation: string[]; - capabilityDelegation: string[]; - service: Service[]; +import _m0 from "protobufjs/minimal"; +export declare const protobufPackage = "hypersign.ssi.v1"; +export interface DidDocument { + "@context"?: string[] | undefined; + id?: string | undefined; + controller?: string[] | undefined; + alsoKnownAs?: string[] | undefined; + verificationMethod?: VerificationMethod[] | undefined; + authentication?: string[] | undefined; + assertionMethod?: string[] | undefined; + keyAgreement?: string[] | undefined; + capabilityInvocation?: string[] | undefined; + capabilityDelegation?: string[] | undefined; + service?: Service[] | undefined; } -export interface Metadata { - created: string; - updated: string; - deactivated: boolean; - versionId: string; +export interface DidDocumentMetadata { + created?: string | undefined; + updated?: string | undefined; + deactivated?: boolean | undefined; + versionId?: string | undefined; } export interface VerificationMethod { - id: string; - type: string; - controller: string; + id?: string | undefined; + type?: string | undefined; + controller?: string | undefined; /** If value is provided, `blockchainAccountId` must be empty */ - publicKeyMultibase: string; + publicKeyMultibase?: string | undefined; /** If value is provided, `publicKeyMultibase` must be empty */ - blockchainAccountId: string; + blockchainAccountId?: string | undefined; } export interface Service { - id: string; - type: string; - serviceEndpoint: string; -} -export interface SignInfo { - verification_method_id: string; - signature: string; - clientSpec: ClientSpec | undefined; + id?: string | undefined; + type?: string | undefined; + serviceEndpoint?: string | undefined; } export interface DidDocumentState { - didDocument: Did | undefined; - didDocumentMetadata: Metadata | undefined; + didDocument?: DidDocument | undefined; + didDocumentMetadata?: DidDocumentMetadata | undefined; } -export declare const Did: { - encode(message: Did, writer?: Writer): Writer; - decode(input: Reader | Uint8Array, length?: number): Did; - fromJSON(object: any): Did; - toJSON(message: Did): unknown; - fromPartial(object: DeepPartial): Did; +export declare const DidDocument: { + encode(message: DidDocument, writer?: _m0.Writer): _m0.Writer; + decode(input: _m0.Reader | Uint8Array, length?: number): DidDocument; + fromJSON(object: any): DidDocument; + toJSON(message: DidDocument): unknown; + create]: never; }) | undefined; + id?: string | undefined; + controller?: (string[] & string[] & { [K_1 in Exclude]: never; }) | undefined; + alsoKnownAs?: (string[] & string[] & { [K_2 in Exclude]: never; }) | undefined; + verificationMethod?: ({ + id?: string | undefined; + type?: string | undefined; + controller?: string | undefined; + publicKeyMultibase?: string | undefined; + blockchainAccountId?: string | undefined; + }[] & ({ + id?: string | undefined; + type?: string | undefined; + controller?: string | undefined; + publicKeyMultibase?: string | undefined; + blockchainAccountId?: string | undefined; + } & { + id?: string | undefined; + type?: string | undefined; + controller?: string | undefined; + publicKeyMultibase?: string | undefined; + blockchainAccountId?: string | undefined; + } & { [K_3 in Exclude]: never; })[] & { [K_4 in Exclude]: never; }) | undefined; + authentication?: (string[] & string[] & { [K_5 in Exclude]: never; }) | undefined; + assertionMethod?: (string[] & string[] & { [K_6 in Exclude]: never; }) | undefined; + keyAgreement?: (string[] & string[] & { [K_7 in Exclude]: never; }) | undefined; + capabilityInvocation?: (string[] & string[] & { [K_8 in Exclude]: never; }) | undefined; + capabilityDelegation?: (string[] & string[] & { [K_9 in Exclude]: never; }) | undefined; + service?: ({ + id?: string | undefined; + type?: string | undefined; + serviceEndpoint?: string | undefined; + }[] & ({ + id?: string | undefined; + type?: string | undefined; + serviceEndpoint?: string | undefined; + } & { + id?: string | undefined; + type?: string | undefined; + serviceEndpoint?: string | undefined; + } & { [K_10 in Exclude]: never; })[] & { [K_11 in Exclude]: never; }) | undefined; + } & { [K_12 in Exclude]: never; }>(base?: I | undefined): DidDocument; + fromPartial]: never; }) | undefined; + id?: string | undefined; + controller?: (string[] & string[] & { [K_14 in Exclude]: never; }) | undefined; + alsoKnownAs?: (string[] & string[] & { [K_15 in Exclude]: never; }) | undefined; + verificationMethod?: ({ + id?: string | undefined; + type?: string | undefined; + controller?: string | undefined; + publicKeyMultibase?: string | undefined; + blockchainAccountId?: string | undefined; + }[] & ({ + id?: string | undefined; + type?: string | undefined; + controller?: string | undefined; + publicKeyMultibase?: string | undefined; + blockchainAccountId?: string | undefined; + } & { + id?: string | undefined; + type?: string | undefined; + controller?: string | undefined; + publicKeyMultibase?: string | undefined; + blockchainAccountId?: string | undefined; + } & { [K_16 in Exclude]: never; })[] & { [K_17 in Exclude]: never; }) | undefined; + authentication?: (string[] & string[] & { [K_18 in Exclude]: never; }) | undefined; + assertionMethod?: (string[] & string[] & { [K_19 in Exclude]: never; }) | undefined; + keyAgreement?: (string[] & string[] & { [K_20 in Exclude]: never; }) | undefined; + capabilityInvocation?: (string[] & string[] & { [K_21 in Exclude]: never; }) | undefined; + capabilityDelegation?: (string[] & string[] & { [K_22 in Exclude]: never; }) | undefined; + service?: ({ + id?: string | undefined; + type?: string | undefined; + serviceEndpoint?: string | undefined; + }[] & ({ + id?: string | undefined; + type?: string | undefined; + serviceEndpoint?: string | undefined; + } & { + id?: string | undefined; + type?: string | undefined; + serviceEndpoint?: string | undefined; + } & { [K_23 in Exclude]: never; })[] & { [K_24 in Exclude]: never; }) | undefined; + } & { [K_25 in Exclude]: never; }>(object: I_1): DidDocument; }; -export declare const Metadata: { - encode(message: Metadata, writer?: Writer): Writer; - decode(input: Reader | Uint8Array, length?: number): Metadata; - fromJSON(object: any): Metadata; - toJSON(message: Metadata): unknown; - fromPartial(object: DeepPartial): Metadata; +export declare const DidDocumentMetadata: { + encode(message: DidDocumentMetadata, writer?: _m0.Writer): _m0.Writer; + decode(input: _m0.Reader | Uint8Array, length?: number): DidDocumentMetadata; + fromJSON(object: any): DidDocumentMetadata; + toJSON(message: DidDocumentMetadata): unknown; + create]: never; }>(base?: I | undefined): DidDocumentMetadata; + fromPartial]: never; }>(object: I_1): DidDocumentMetadata; }; export declare const VerificationMethod: { - encode(message: VerificationMethod, writer?: Writer): Writer; - decode(input: Reader | Uint8Array, length?: number): VerificationMethod; + encode(message: VerificationMethod, writer?: _m0.Writer): _m0.Writer; + decode(input: _m0.Reader | Uint8Array, length?: number): VerificationMethod; fromJSON(object: any): VerificationMethod; toJSON(message: VerificationMethod): unknown; - fromPartial(object: DeepPartial): VerificationMethod; + create]: never; }>(base?: I | undefined): VerificationMethod; + fromPartial]: never; }>(object: I_1): VerificationMethod; }; export declare const Service: { - encode(message: Service, writer?: Writer): Writer; - decode(input: Reader | Uint8Array, length?: number): Service; + encode(message: Service, writer?: _m0.Writer): _m0.Writer; + decode(input: _m0.Reader | Uint8Array, length?: number): Service; fromJSON(object: any): Service; toJSON(message: Service): unknown; - fromPartial(object: DeepPartial): Service; -}; -export declare const SignInfo: { - encode(message: SignInfo, writer?: Writer): Writer; - decode(input: Reader | Uint8Array, length?: number): SignInfo; - fromJSON(object: any): SignInfo; - toJSON(message: SignInfo): unknown; - fromPartial(object: DeepPartial): SignInfo; + create]: never; }>(base?: I | undefined): Service; + fromPartial]: never; }>(object: I_1): Service; }; export declare const DidDocumentState: { - encode(message: DidDocumentState, writer?: Writer): Writer; - decode(input: Reader | Uint8Array, length?: number): DidDocumentState; + encode(message: DidDocumentState, writer?: _m0.Writer): _m0.Writer; + decode(input: _m0.Reader | Uint8Array, length?: number): DidDocumentState; fromJSON(object: any): DidDocumentState; toJSON(message: DidDocumentState): unknown; - fromPartial(object: DeepPartial): DidDocumentState; + create]: never; }) | undefined; + id?: string | undefined; + controller?: (string[] & string[] & { [K_1 in Exclude]: never; }) | undefined; + alsoKnownAs?: (string[] & string[] & { [K_2 in Exclude]: never; }) | undefined; + verificationMethod?: ({ + id?: string | undefined; + type?: string | undefined; + controller?: string | undefined; + publicKeyMultibase?: string | undefined; + blockchainAccountId?: string | undefined; + }[] & ({ + id?: string | undefined; + type?: string | undefined; + controller?: string | undefined; + publicKeyMultibase?: string | undefined; + blockchainAccountId?: string | undefined; + } & { + id?: string | undefined; + type?: string | undefined; + controller?: string | undefined; + publicKeyMultibase?: string | undefined; + blockchainAccountId?: string | undefined; + } & { [K_3 in Exclude]: never; })[] & { [K_4 in Exclude]: never; }) | undefined; + authentication?: (string[] & string[] & { [K_5 in Exclude]: never; }) | undefined; + assertionMethod?: (string[] & string[] & { [K_6 in Exclude]: never; }) | undefined; + keyAgreement?: (string[] & string[] & { [K_7 in Exclude]: never; }) | undefined; + capabilityInvocation?: (string[] & string[] & { [K_8 in Exclude]: never; }) | undefined; + capabilityDelegation?: (string[] & string[] & { [K_9 in Exclude]: never; }) | undefined; + service?: ({ + id?: string | undefined; + type?: string | undefined; + serviceEndpoint?: string | undefined; + }[] & ({ + id?: string | undefined; + type?: string | undefined; + serviceEndpoint?: string | undefined; + } & { + id?: string | undefined; + type?: string | undefined; + serviceEndpoint?: string | undefined; + } & { [K_10 in Exclude]: never; })[] & { [K_11 in Exclude]: never; }) | undefined; + } & { [K_12 in Exclude]: never; }) | undefined; + didDocumentMetadata?: ({ + created?: string | undefined; + updated?: string | undefined; + deactivated?: boolean | undefined; + versionId?: string | undefined; + } & { + created?: string | undefined; + updated?: string | undefined; + deactivated?: boolean | undefined; + versionId?: string | undefined; + } & { [K_13 in Exclude]: never; }) | undefined; + } & { [K_14 in Exclude]: never; }>(base?: I | undefined): DidDocumentState; + fromPartial]: never; }) | undefined; + id?: string | undefined; + controller?: (string[] & string[] & { [K_16 in Exclude]: never; }) | undefined; + alsoKnownAs?: (string[] & string[] & { [K_17 in Exclude]: never; }) | undefined; + verificationMethod?: ({ + id?: string | undefined; + type?: string | undefined; + controller?: string | undefined; + publicKeyMultibase?: string | undefined; + blockchainAccountId?: string | undefined; + }[] & ({ + id?: string | undefined; + type?: string | undefined; + controller?: string | undefined; + publicKeyMultibase?: string | undefined; + blockchainAccountId?: string | undefined; + } & { + id?: string | undefined; + type?: string | undefined; + controller?: string | undefined; + publicKeyMultibase?: string | undefined; + blockchainAccountId?: string | undefined; + } & { [K_18 in Exclude]: never; })[] & { [K_19 in Exclude]: never; }) | undefined; + authentication?: (string[] & string[] & { [K_20 in Exclude]: never; }) | undefined; + assertionMethod?: (string[] & string[] & { [K_21 in Exclude]: never; }) | undefined; + keyAgreement?: (string[] & string[] & { [K_22 in Exclude]: never; }) | undefined; + capabilityInvocation?: (string[] & string[] & { [K_23 in Exclude]: never; }) | undefined; + capabilityDelegation?: (string[] & string[] & { [K_24 in Exclude]: never; }) | undefined; + service?: ({ + id?: string | undefined; + type?: string | undefined; + serviceEndpoint?: string | undefined; + }[] & ({ + id?: string | undefined; + type?: string | undefined; + serviceEndpoint?: string | undefined; + } & { + id?: string | undefined; + type?: string | undefined; + serviceEndpoint?: string | undefined; + } & { [K_25 in Exclude]: never; })[] & { [K_26 in Exclude]: never; }) | undefined; + } & { [K_27 in Exclude]: never; }) | undefined; + didDocumentMetadata?: ({ + created?: string | undefined; + updated?: string | undefined; + deactivated?: boolean | undefined; + versionId?: string | undefined; + } & { + created?: string | undefined; + updated?: string | undefined; + deactivated?: boolean | undefined; + versionId?: string | undefined; + } & { [K_28 in Exclude]: never; }) | undefined; + } & { [K_29 in Exclude]: never; }>(object: I_1): DidDocumentState; }; -type Builtin = Date | Function | Uint8Array | string | number | undefined; -export type DeepPartial = T extends Builtin ? T : T extends Array ? Array> : T extends ReadonlyArray ? ReadonlyArray> : T extends {} ? { +type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined; +export type DeepPartial = T extends Builtin ? T : T extends globalThis.Array ? globalThis.Array> : T extends ReadonlyArray ? ReadonlyArray> : T extends {} ? { [K in keyof T]?: DeepPartial; } : Partial; +type KeysOfUnion = T extends T ? keyof T : never; +export type Exact = P extends Builtin ? P : P & { + [K in keyof P]: Exact; +} & { + [K in Exclude>]: never; +}; export {}; //# sourceMappingURL=did.d.ts.map \ No newline at end of file diff --git a/build/libs/generated/ssi/did.d.ts.map b/build/libs/generated/ssi/did.d.ts.map index fd5c535..95bce78 100644 --- a/build/libs/generated/ssi/did.d.ts.map +++ b/build/libs/generated/ssi/did.d.ts.map @@ -1 +1 @@ -{"version":3,"file":"did.d.ts","sourceRoot":"","sources":["../../../../libs/generated/ssi/did.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAEpD,eAAO,MAAM,eAAe,kCAAkC,CAAC;AAE/D,MAAM,WAAW,GAAG;IAClB,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,EAAE,EAAE,MAAM,CAAC;IACX,UAAU,EAAE,MAAM,EAAE,CAAC;IACrB,WAAW,EAAE,MAAM,EAAE,CAAC;IACtB,kBAAkB,EAAE,kBAAkB,EAAE,CAAC;IACzC,cAAc,EAAE,MAAM,EAAE,CAAC;IACzB,eAAe,EAAE,MAAM,EAAE,CAAC;IAC1B,YAAY,EAAE,MAAM,EAAE,CAAC;IACvB,oBAAoB,EAAE,MAAM,EAAE,CAAC;IAC/B,oBAAoB,EAAE,MAAM,EAAE,CAAC;IAC/B,OAAO,EAAE,OAAO,EAAE,CAAC;CACpB;AAED,MAAM,WAAW,QAAQ;IACvB,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;IAChB,WAAW,EAAE,OAAO,CAAC;IACrB,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,WAAW,kBAAkB;IACjC,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,EAAE,MAAM,CAAC;IACnB,gEAAgE;IAChE,kBAAkB,EAAE,MAAM,CAAC;IAC3B,+DAA+D;IAC/D,mBAAmB,EAAE,MAAM,CAAC;CAC7B;AAED,MAAM,WAAW,OAAO;IACtB,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,eAAe,EAAE,MAAM,CAAC;CACzB;AAED,MAAM,WAAW,QAAQ;IACvB,sBAAsB,EAAE,MAAM,CAAC;IAC/B,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,EAAE,UAAU,GAAG,SAAS,CAAC;CACpC;AAED,MAAM,WAAW,gBAAgB;IAC/B,WAAW,EAAE,GAAG,GAAG,SAAS,CAAC;IAC7B,mBAAmB,EAAE,QAAQ,GAAG,SAAS,CAAC;CAC3C;AAcD,eAAO,MAAM,GAAG;oBACE,GAAG,WAAU,MAAM,GAAqB,MAAM;kBAqChD,MAAM,GAAG,UAAU,WAAW,MAAM,GAAG,GAAG;qBA4DvC,GAAG,GAAG,GAAG;oBAkFV,GAAG,GAAG,OAAO;wBA4DT,YAAY,GAAG,CAAC,GAAG,GAAG;CAiF3C,CAAC;AASF,eAAO,MAAM,QAAQ;oBACH,QAAQ,WAAU,MAAM,GAAqB,MAAM;kBAgBrD,MAAM,GAAG,UAAU,WAAW,MAAM,GAAG,QAAQ;qBA2B5C,GAAG,GAAG,QAAQ;oBAyBf,QAAQ,GAAG,OAAO;wBAUd,YAAY,QAAQ,CAAC,GAAG,QAAQ;CAwBrD,CAAC;AAUF,eAAO,MAAM,kBAAkB;oBAElB,kBAAkB,WACnB,MAAM,GACb,MAAM;kBAmBK,MAAM,GAAG,UAAU,WAAW,MAAM,GAAG,kBAAkB;qBA8BtD,GAAG,GAAG,kBAAkB;oBAoCzB,kBAAkB,GAAG,OAAO;wBAYxB,YAAY,kBAAkB,CAAC,GAAG,kBAAkB;CAmCzE,CAAC;AAIF,eAAO,MAAM,OAAO;oBACF,OAAO,WAAU,MAAM,GAAqB,MAAM;kBAapD,MAAM,GAAG,UAAU,WAAW,MAAM,GAAG,OAAO;qBAwB3C,GAAG,GAAG,OAAO;oBAuBd,OAAO,GAAG,OAAO;wBASb,YAAY,OAAO,CAAC,GAAG,OAAO;CAsBnD,CAAC;AAIF,eAAO,MAAM,QAAQ;oBACH,QAAQ,WAAU,MAAM,GAAqB,MAAM;kBAarD,MAAM,GAAG,UAAU,WAAW,MAAM,GAAG,QAAQ;qBAwB5C,GAAG,GAAG,QAAQ;oBAuBf,QAAQ,GAAG,OAAO;wBAYd,YAAY,QAAQ,CAAC,GAAG,QAAQ;CAsBrD,CAAC;AAIF,eAAO,MAAM,gBAAgB;oBACX,gBAAgB,WAAU,MAAM,GAAqB,MAAM;kBAa7D,MAAM,GAAG,UAAU,WAAW,MAAM,GAAG,gBAAgB;qBAwBpD,GAAG,GAAG,gBAAgB;oBAoBvB,gBAAgB,GAAG,OAAO;wBAatB,YAAY,gBAAgB,CAAC,GAAG,gBAAgB;CAmBrE,CAAC;AAEF,KAAK,OAAO,GAAG,IAAI,GAAG,QAAQ,GAAG,UAAU,GAAG,MAAM,GAAG,MAAM,GAAG,SAAS,CAAC;AAC1E,MAAM,MAAM,WAAW,CAAC,CAAC,IAAI,CAAC,SAAS,OAAO,GAC1C,CAAC,GACD,CAAC,SAAS,KAAK,CAAC,MAAM,CAAC,CAAC,GACxB,KAAK,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,GACrB,CAAC,SAAS,aAAa,CAAC,MAAM,CAAC,CAAC,GAChC,aAAa,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,GAC7B,CAAC,SAAS,EAAE,GACZ;KAAG,CAAC,IAAI,MAAM,CAAC,CAAC,CAAC,EAAE,WAAW,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;CAAE,GACtC,OAAO,CAAC,CAAC,CAAC,CAAC"} \ No newline at end of file +{"version":3,"file":"did.d.ts","sourceRoot":"","sources":["../../../../libs/generated/ssi/did.ts"],"names":[],"mappings":"AACA,OAAO,GAAG,MAAM,oBAAoB,CAAC;AAErC,eAAO,MAAM,eAAe,qBAAqB,CAAC;AAElD,MAAM,WAAW,WAAW;IAC1B,UAAU,CAAC,EAAE,MAAM,EAAE,GAAG,SAAS,CAAC;IAClC,EAAE,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IACxB,UAAU,CAAC,EAAE,MAAM,EAAE,GAAG,SAAS,CAAC;IAClC,WAAW,CAAC,EAAE,MAAM,EAAE,GAAG,SAAS,CAAC;IACnC,kBAAkB,CAAC,EAAE,kBAAkB,EAAE,GAAG,SAAS,CAAC;IACtD,cAAc,CAAC,EAAE,MAAM,EAAE,GAAG,SAAS,CAAC;IACtC,eAAe,CAAC,EAAE,MAAM,EAAE,GAAG,SAAS,CAAC;IACvC,YAAY,CAAC,EAAE,MAAM,EAAE,GAAG,SAAS,CAAC;IACpC,oBAAoB,CAAC,EAAE,MAAM,EAAE,GAAG,SAAS,CAAC;IAC5C,oBAAoB,CAAC,EAAE,MAAM,EAAE,GAAG,SAAS,CAAC;IAC5C,OAAO,CAAC,EAAE,OAAO,EAAE,GAAG,SAAS,CAAC;CACjC;AAED,MAAM,WAAW,mBAAmB;IAClC,OAAO,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC7B,OAAO,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC7B,WAAW,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC;IAClC,SAAS,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;CAChC;AAED,MAAM,WAAW,kBAAkB;IACjC,EAAE,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IACxB,IAAI,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC1B,UAAU,CAAC,EACT,MAAM,GACN,SAAS,CAAC;IACZ,gEAAgE;IAChE,kBAAkB,CAAC,EACjB,MAAM,GACN,SAAS,CAAC;IACZ,+DAA+D;IAC/D,mBAAmB,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;CAC1C;AAED,MAAM,WAAW,OAAO;IACtB,EAAE,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IACxB,IAAI,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC1B,eAAe,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;CACtC;AAED,MAAM,WAAW,gBAAgB;IAC/B,WAAW,CAAC,EAAE,WAAW,GAAG,SAAS,CAAC;IACtC,mBAAmB,CAAC,EAAE,mBAAmB,GAAG,SAAS,CAAC;CACvD;AAMD,eAAO,MAAM,WAAW;oBACN,WAAW,WAAU,IAAI,MAAM,GAAyB,IAAI,MAAM;kBAyDpE,IAAI,MAAM,GAAG,UAAU,WAAW,MAAM,GAAG,WAAW;qBA2HnD,GAAG,GAAG,WAAW;oBAoClB,WAAW,GAAG,OAAO;;;aAzQhC,MAAM,GAAG,SAAS;;;;iBAoBlB,MAAM,GAAG,SAAS;mBAChB,MAAM,GAAG,SAAS;yBAEvB,MAAM,GACN,SAAS;iCAGT,MAAM,GACN,SAAS;kCAEW,MAAM,GAAG,SAAS;;;;;;;;iBAInC,MAAM,GAAG,SAAS;mBAChB,MAAM,GAAG,SAAS;8BACP,MAAM,GAAG,SAAS;;;;aApC/B,MAAM,GAAG,SAAS;;;;iBAoBlB,MAAM,GAAG,SAAS;mBAChB,MAAM,GAAG,SAAS;yBAEvB,MAAM,GACN,SAAS;iCAGT,MAAM,GACN,SAAS;kCAEW,MAAM,GAAG,SAAS;;iBAVnC,MAAM,GAAG,SAAS;mBAChB,MAAM,GAAG,SAAS;yBAEvB,MAAM,GACN,SAAS;iCAGT,MAAM,GACN,SAAS;kCAEW,MAAM,GAAG,SAAS;;iBAVnC,MAAM,GAAG,SAAS;mBAChB,MAAM,GAAG,SAAS;yBAEvB,MAAM,GACN,SAAS;iCAGT,MAAM,GACN,SAAS;kCAEW,MAAM,GAAG,SAAS;;iBAVnC,MAAM,GAAG,SAAS;mBAChB,MAAM,GAAG,SAAS;yBAEvB,MAAM,GACN,SAAS;iCAGT,MAAM,GACN,SAAS;kCAEW,MAAM,GAAG,SAAS;;;;;;;;iBAInC,MAAM,GAAG,SAAS;mBAChB,MAAM,GAAG,SAAS;8BACP,MAAM,GAAG,SAAS;;iBAF/B,MAAM,GAAG,SAAS;mBAChB,MAAM,GAAG,SAAS;8BACP,MAAM,GAAG,SAAS;;iBAF/B,MAAM,GAAG,SAAS;mBAChB,MAAM,GAAG,SAAS;8BACP,MAAM,GAAG,SAAS;;iBAF/B,MAAM,GAAG,SAAS;mBAChB,MAAM,GAAG,SAAS;8BACP,MAAM,GAAG,SAAS;;0FA2Q4B,WAAW;;;aA/StE,MAAM,GAAG,SAAS;;;;iBAoBlB,MAAM,GAAG,SAAS;mBAChB,MAAM,GAAG,SAAS;yBAEvB,MAAM,GACN,SAAS;iCAGT,MAAM,GACN,SAAS;kCAEW,MAAM,GAAG,SAAS;;;;;;;;iBAInC,MAAM,GAAG,SAAS;mBAChB,MAAM,GAAG,SAAS;8BACP,MAAM,GAAG,SAAS;;;;aApC/B,MAAM,GAAG,SAAS;;;;iBAoBlB,MAAM,GAAG,SAAS;mBAChB,MAAM,GAAG,SAAS;yBAEvB,MAAM,GACN,SAAS;iCAGT,MAAM,GACN,SAAS;kCAEW,MAAM,GAAG,SAAS;;iBAVnC,MAAM,GAAG,SAAS;mBAChB,MAAM,GAAG,SAAS;yBAEvB,MAAM,GACN,SAAS;iCAGT,MAAM,GACN,SAAS;kCAEW,MAAM,GAAG,SAAS;;iBAVnC,MAAM,GAAG,SAAS;mBAChB,MAAM,GAAG,SAAS;yBAEvB,MAAM,GACN,SAAS;iCAGT,MAAM,GACN,SAAS;kCAEW,MAAM,GAAG,SAAS;;iBAVnC,MAAM,GAAG,SAAS;mBAChB,MAAM,GAAG,SAAS;yBAEvB,MAAM,GACN,SAAS;iCAGT,MAAM,GACN,SAAS;kCAEW,MAAM,GAAG,SAAS;;;;;;;;iBAInC,MAAM,GAAG,SAAS;mBAChB,MAAM,GAAG,SAAS;8BACP,MAAM,GAAG,SAAS;;iBAF/B,MAAM,GAAG,SAAS;mBAChB,MAAM,GAAG,SAAS;8BACP,MAAM,GAAG,SAAS;;iBAF/B,MAAM,GAAG,SAAS;mBAChB,MAAM,GAAG,SAAS;8BACP,MAAM,GAAG,SAAS;;iBAF/B,MAAM,GAAG,SAAS;mBAChB,MAAM,GAAG,SAAS;8BACP,MAAM,GAAG,SAAS;;mFA8QkC,WAAW;CAelF,CAAC;AAMF,eAAO,MAAM,mBAAmB;oBACd,mBAAmB,WAAU,IAAI,MAAM,GAAyB,IAAI,MAAM;kBAgB5E,IAAI,MAAM,GAAG,UAAU,WAAW,MAAM,GAAG,mBAAmB;qBA4C3D,GAAG,GAAG,mBAAmB;oBAS1B,mBAAmB,GAAG,OAAO;;kBAhYnC,MAAM,GAAG,SAAS;kBAClB,MAAM,GAAG,SAAS;sBACd,OAAO,GAAG,SAAS;oBACrB,MAAM,GAAG,SAAS;;kBAHpB,MAAM,GAAG,SAAS;kBAClB,MAAM,GAAG,SAAS;sBACd,OAAO,GAAG,SAAS;oBACrB,MAAM,GAAG,SAAS;+FA8Y0C,mBAAmB;;kBAjZjF,MAAM,GAAG,SAAS;kBAClB,MAAM,GAAG,SAAS;sBACd,OAAO,GAAG,SAAS;oBACrB,MAAM,GAAG,SAAS;;kBAHpB,MAAM,GAAG,SAAS;kBAClB,MAAM,GAAG,SAAS;sBACd,OAAO,GAAG,SAAS;oBACrB,MAAM,GAAG,SAAS;0FAiZgD,mBAAmB;CAQlG,CAAC;AAMF,eAAO,MAAM,kBAAkB;oBACb,kBAAkB,WAAU,IAAI,MAAM,GAAyB,IAAI,MAAM;kBAmB3E,IAAI,MAAM,GAAG,UAAU,WAAW,MAAM,GAAG,kBAAkB;qBAmD1D,GAAG,GAAG,kBAAkB;oBAYzB,kBAAkB,GAAG,OAAO;;aA9evC,MAAM,GAAG,SAAS;eAChB,MAAM,GAAG,SAAS;qBAEvB,MAAM,GACN,SAAS;6BAGT,MAAM,GACN,SAAS;8BAEW,MAAM,GAAG,SAAS;;aAVnC,MAAM,GAAG,SAAS;eAChB,MAAM,GAAG,SAAS;qBAEvB,MAAM,GACN,SAAS;6BAGT,MAAM,GACN,SAAS;8BAEW,MAAM,GAAG,SAAS;8FAwf+B,kBAAkB;;aAlgBpF,MAAM,GAAG,SAAS;eAChB,MAAM,GAAG,SAAS;qBAEvB,MAAM,GACN,SAAS;6BAGT,MAAM,GACN,SAAS;8BAEW,MAAM,GAAG,SAAS;;aAVnC,MAAM,GAAG,SAAS;eAChB,MAAM,GAAG,SAAS;qBAEvB,MAAM,GACN,SAAS;6BAGT,MAAM,GACN,SAAS;8BAEW,MAAM,GAAG,SAAS;yFA2fqC,kBAAkB;CAShG,CAAC;AAMF,eAAO,MAAM,OAAO;oBACF,OAAO,WAAU,IAAI,MAAM,GAAyB,IAAI,MAAM;kBAahE,IAAI,MAAM,GAAG,UAAU,WAAW,MAAM,GAAG,OAAO;qBAqC/C,GAAG,GAAG,OAAO;oBAQd,OAAO,GAAG,OAAO;;aAjkB5B,MAAM,GAAG,SAAS;eAChB,MAAM,GAAG,SAAS;0BACP,MAAM,GAAG,SAAS;;aAF/B,MAAM,GAAG,SAAS;eAChB,MAAM,GAAG,SAAS;0BACP,MAAM,GAAG,SAAS;mFA6kBwB,OAAO;;aA/kB9D,MAAM,GAAG,SAAS;eAChB,MAAM,GAAG,SAAS;0BACP,MAAM,GAAG,SAAS;;aAF/B,MAAM,GAAG,SAAS;eAChB,MAAM,GAAG,SAAS;0BACP,MAAM,GAAG,SAAS;8EAglB8B,OAAO;CAO1E,CAAC;AAMF,eAAO,MAAM,gBAAgB;oBACX,gBAAgB,WAAU,IAAI,MAAM,GAAyB,IAAI,MAAM;kBAUzE,IAAI,MAAM,GAAG,UAAU,WAAW,MAAM,GAAG,gBAAgB;qBA8BxD,GAAG,GAAG,gBAAgB;oBASvB,gBAAgB,GAAG,OAAO;;;;iBAnrBrC,MAAM,GAAG,SAAS;;;;qBAoBlB,MAAM,GAAG,SAAS;uBAChB,MAAM,GAAG,SAAS;6BAEvB,MAAM,GACN,SAAS;qCAGT,MAAM,GACN,SAAS;sCAEW,MAAM,GAAG,SAAS;;;;;;;;qBAInC,MAAM,GAAG,SAAS;uBAChB,MAAM,GAAG,SAAS;kCACP,MAAM,GAAG,SAAS;;;;sBAvB1B,MAAM,GAAG,SAAS;sBAClB,MAAM,GAAG,SAAS;0BACd,OAAO,GAAG,SAAS;wBACrB,MAAM,GAAG,SAAS;;;;;iBAhBzB,MAAM,GAAG,SAAS;;;;qBAoBlB,MAAM,GAAG,SAAS;uBAChB,MAAM,GAAG,SAAS;6BAEvB,MAAM,GACN,SAAS;qCAGT,MAAM,GACN,SAAS;sCAEW,MAAM,GAAG,SAAS;;;;;;;;qBAInC,MAAM,GAAG,SAAS;uBAChB,MAAM,GAAG,SAAS;kCACP,MAAM,GAAG,SAAS;;;;iBApC/B,MAAM,GAAG,SAAS;;;;qBAoBlB,MAAM,GAAG,SAAS;uBAChB,MAAM,GAAG,SAAS;6BAEvB,MAAM,GACN,SAAS;qCAGT,MAAM,GACN,SAAS;sCAEW,MAAM,GAAG,SAAS;;qBAVnC,MAAM,GAAG,SAAS;uBAChB,MAAM,GAAG,SAAS;6BAEvB,MAAM,GACN,SAAS;qCAGT,MAAM,GACN,SAAS;sCAEW,MAAM,GAAG,SAAS;;qBAVnC,MAAM,GAAG,SAAS;uBAChB,MAAM,GAAG,SAAS;6BAEvB,MAAM,GACN,SAAS;qCAGT,MAAM,GACN,SAAS;sCAEW,MAAM,GAAG,SAAS;;qBAVnC,MAAM,GAAG,SAAS;uBAChB,MAAM,GAAG,SAAS;6BAEvB,MAAM,GACN,SAAS;qCAGT,MAAM,GACN,SAAS;sCAEW,MAAM,GAAG,SAAS;;;;;;;;qBAInC,MAAM,GAAG,SAAS;uBAChB,MAAM,GAAG,SAAS;kCACP,MAAM,GAAG,SAAS;;qBAF/B,MAAM,GAAG,SAAS;uBAChB,MAAM,GAAG,SAAS;kCACP,MAAM,GAAG,SAAS;;qBAF/B,MAAM,GAAG,SAAS;uBAChB,MAAM,GAAG,SAAS;kCACP,MAAM,GAAG,SAAS;;qBAF/B,MAAM,GAAG,SAAS;uBAChB,MAAM,GAAG,SAAS;kCACP,MAAM,GAAG,SAAS;;;;sBAvB1B,MAAM,GAAG,SAAS;sBAClB,MAAM,GAAG,SAAS;0BACd,OAAO,GAAG,SAAS;wBACrB,MAAM,GAAG,SAAS;;sBAHpB,MAAM,GAAG,SAAS;sBAClB,MAAM,GAAG,SAAS;0BACd,OAAO,GAAG,SAAS;wBACrB,MAAM,GAAG,SAAS;;+FA8qBuC,gBAAgB;;;;iBA9rBhF,MAAM,GAAG,SAAS;;;;qBAoBlB,MAAM,GAAG,SAAS;uBAChB,MAAM,GAAG,SAAS;6BAEvB,MAAM,GACN,SAAS;qCAGT,MAAM,GACN,SAAS;sCAEW,MAAM,GAAG,SAAS;;;;;;;;qBAInC,MAAM,GAAG,SAAS;uBAChB,MAAM,GAAG,SAAS;kCACP,MAAM,GAAG,SAAS;;;;sBAvB1B,MAAM,GAAG,SAAS;sBAClB,MAAM,GAAG,SAAS;0BACd,OAAO,GAAG,SAAS;wBACrB,MAAM,GAAG,SAAS;;;;;iBAhBzB,MAAM,GAAG,SAAS;;;;qBAoBlB,MAAM,GAAG,SAAS;uBAChB,MAAM,GAAG,SAAS;6BAEvB,MAAM,GACN,SAAS;qCAGT,MAAM,GACN,SAAS;sCAEW,MAAM,GAAG,SAAS;;;;;;;;qBAInC,MAAM,GAAG,SAAS;uBAChB,MAAM,GAAG,SAAS;kCACP,MAAM,GAAG,SAAS;;;;iBApC/B,MAAM,GAAG,SAAS;;;;qBAoBlB,MAAM,GAAG,SAAS;uBAChB,MAAM,GAAG,SAAS;6BAEvB,MAAM,GACN,SAAS;qCAGT,MAAM,GACN,SAAS;sCAEW,MAAM,GAAG,SAAS;;qBAVnC,MAAM,GAAG,SAAS;uBAChB,MAAM,GAAG,SAAS;6BAEvB,MAAM,GACN,SAAS;qCAGT,MAAM,GACN,SAAS;sCAEW,MAAM,GAAG,SAAS;;qBAVnC,MAAM,GAAG,SAAS;uBAChB,MAAM,GAAG,SAAS;6BAEvB,MAAM,GACN,SAAS;qCAGT,MAAM,GACN,SAAS;sCAEW,MAAM,GAAG,SAAS;;qBAVnC,MAAM,GAAG,SAAS;uBAChB,MAAM,GAAG,SAAS;6BAEvB,MAAM,GACN,SAAS;qCAGT,MAAM,GACN,SAAS;sCAEW,MAAM,GAAG,SAAS;;;;;;;;qBAInC,MAAM,GAAG,SAAS;uBAChB,MAAM,GAAG,SAAS;kCACP,MAAM,GAAG,SAAS;;qBAF/B,MAAM,GAAG,SAAS;uBAChB,MAAM,GAAG,SAAS;kCACP,MAAM,GAAG,SAAS;;qBAF/B,MAAM,GAAG,SAAS;uBAChB,MAAM,GAAG,SAAS;kCACP,MAAM,GAAG,SAAS;;qBAF/B,MAAM,GAAG,SAAS;uBAChB,MAAM,GAAG,SAAS;kCACP,MAAM,GAAG,SAAS;;;;sBAvB1B,MAAM,GAAG,SAAS;sBAClB,MAAM,GAAG,SAAS;0BACd,OAAO,GAAG,SAAS;wBACrB,MAAM,GAAG,SAAS;;sBAHpB,MAAM,GAAG,SAAS;sBAClB,MAAM,GAAG,SAAS;0BACd,OAAO,GAAG,SAAS;wBACrB,MAAM,GAAG,SAAS;;wFAirB6C,gBAAgB;CAU5F,CAAC;AAEF,KAAK,OAAO,GAAG,IAAI,GAAG,QAAQ,GAAG,UAAU,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,SAAS,CAAC;AAEpF,MAAM,MAAM,WAAW,CAAC,CAAC,IAAI,CAAC,SAAS,OAAO,GAAG,CAAC,GAC9C,CAAC,SAAS,UAAU,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,GAAG,UAAU,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,GACtE,CAAC,SAAS,aAAa,CAAC,MAAM,CAAC,CAAC,GAAG,aAAa,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,GAChE,CAAC,SAAS,EAAE,GAAG;KAAG,CAAC,IAAI,MAAM,CAAC,CAAC,CAAC,EAAE,WAAW,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;CAAE,GACrD,OAAO,CAAC,CAAC,CAAC,CAAC;AAEf,KAAK,WAAW,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,GAAG,MAAM,CAAC,GAAG,KAAK,CAAC;AACpD,MAAM,MAAM,KAAK,CAAC,CAAC,EAAE,CAAC,SAAS,CAAC,IAAI,CAAC,SAAS,OAAO,GAAG,CAAC,GACrD,CAAC,GAAG;KAAG,CAAC,IAAI,MAAM,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC;CAAE,GAAG;KAAG,CAAC,IAAI,OAAO,CAAC,MAAM,CAAC,EAAE,WAAW,CAAC,CAAC,CAAC,CAAC,GAAG,KAAK;CAAE,CAAC"} \ No newline at end of file diff --git a/build/libs/generated/ssi/did.js b/build/libs/generated/ssi/did.js index 979c98b..c79ac69 100644 --- a/build/libs/generated/ssi/did.js +++ b/build/libs/generated/ssi/did.js @@ -1,844 +1,635 @@ "use strict"; +var __importDefault = (this && this.__importDefault) || function (mod) { + return (mod && mod.__esModule) ? mod : { "default": mod }; +}; Object.defineProperty(exports, "__esModule", { value: true }); -exports.DidDocumentState = exports.SignInfo = exports.Service = exports.VerificationMethod = exports.Metadata = exports.Did = exports.protobufPackage = void 0; +exports.DidDocumentState = exports.Service = exports.VerificationMethod = exports.DidDocumentMetadata = exports.DidDocument = exports.protobufPackage = void 0; /* eslint-disable */ -const clientSpec_1 = require("./clientSpec"); -const minimal_1 = require("protobufjs/minimal"); -exports.protobufPackage = "hypersignprotocol.hidnode.ssi"; -const baseDid = { - context: "", - id: "", - controller: "", - alsoKnownAs: "", - authentication: "", - assertionMethod: "", - keyAgreement: "", - capabilityInvocation: "", - capabilityDelegation: "", -}; -exports.Did = { - encode(message, writer = minimal_1.Writer.create()) { - for (const v of message.context) { - writer.uint32(10).string(v); +const minimal_1 = __importDefault(require("protobufjs/minimal")); +exports.protobufPackage = "hypersign.ssi.v1"; +function createBaseDidDocument() { + return {}; +} +exports.DidDocument = { + encode(message, writer = minimal_1.default.Writer.create()) { + if (message["@context"] !== undefined && message["@context"].length !== 0) { + for (const v of message["@context"]) { + writer.uint32(10).string(v); + } } - if (message.id !== "") { + if (message.id !== undefined && message.id !== "") { writer.uint32(18).string(message.id); } - for (const v of message.controller) { - writer.uint32(26).string(v); + if (message.controller !== undefined && message.controller.length !== 0) { + for (const v of message.controller) { + writer.uint32(26).string(v); + } } - for (const v of message.alsoKnownAs) { - writer.uint32(34).string(v); + if (message.alsoKnownAs !== undefined && message.alsoKnownAs.length !== 0) { + for (const v of message.alsoKnownAs) { + writer.uint32(34).string(v); + } } - for (const v of message.verificationMethod) { - exports.VerificationMethod.encode(v, writer.uint32(42).fork()).ldelim(); + if (message.verificationMethod !== undefined && message.verificationMethod.length !== 0) { + for (const v of message.verificationMethod) { + exports.VerificationMethod.encode(v, writer.uint32(42).fork()).ldelim(); + } } - for (const v of message.authentication) { - writer.uint32(50).string(v); + if (message.authentication !== undefined && message.authentication.length !== 0) { + for (const v of message.authentication) { + writer.uint32(50).string(v); + } } - for (const v of message.assertionMethod) { - writer.uint32(58).string(v); + if (message.assertionMethod !== undefined && message.assertionMethod.length !== 0) { + for (const v of message.assertionMethod) { + writer.uint32(58).string(v); + } } - for (const v of message.keyAgreement) { - writer.uint32(66).string(v); + if (message.keyAgreement !== undefined && message.keyAgreement.length !== 0) { + for (const v of message.keyAgreement) { + writer.uint32(66).string(v); + } } - for (const v of message.capabilityInvocation) { - writer.uint32(74).string(v); + if (message.capabilityInvocation !== undefined && message.capabilityInvocation.length !== 0) { + for (const v of message.capabilityInvocation) { + writer.uint32(74).string(v); + } } - for (const v of message.capabilityDelegation) { - writer.uint32(82).string(v); + if (message.capabilityDelegation !== undefined && message.capabilityDelegation.length !== 0) { + for (const v of message.capabilityDelegation) { + writer.uint32(82).string(v); + } } - for (const v of message.service) { - exports.Service.encode(v, writer.uint32(90).fork()).ldelim(); + if (message.service !== undefined && message.service.length !== 0) { + for (const v of message.service) { + exports.Service.encode(v, writer.uint32(90).fork()).ldelim(); + } } return writer; }, decode(input, length) { - const reader = input instanceof Uint8Array ? new minimal_1.Reader(input) : input; + const reader = input instanceof minimal_1.default.Reader ? input : minimal_1.default.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; - const message = Object.assign({}, baseDid); - message.context = []; - message.controller = []; - message.alsoKnownAs = []; - message.verificationMethod = []; - message.authentication = []; - message.assertionMethod = []; - message.keyAgreement = []; - message.capabilityInvocation = []; - message.capabilityDelegation = []; - message.service = []; + const message = createBaseDidDocument(); while (reader.pos < end) { const tag = reader.uint32(); switch (tag >>> 3) { case 1: - message.context.push(reader.string()); - break; + if (tag !== 10) { + break; + } + if (message["@context"] === undefined) { + message["@context"] = []; + } + message["@context"].push(reader.string()); + continue; case 2: + if (tag !== 18) { + break; + } message.id = reader.string(); - break; + continue; case 3: + if (tag !== 26) { + break; + } + if (message.controller === undefined) { + message.controller = []; + } message.controller.push(reader.string()); - break; + continue; case 4: + if (tag !== 34) { + break; + } + if (message.alsoKnownAs === undefined) { + message.alsoKnownAs = []; + } message.alsoKnownAs.push(reader.string()); - break; + continue; case 5: + if (tag !== 42) { + break; + } + if (message.verificationMethod === undefined) { + message.verificationMethod = []; + } message.verificationMethod.push(exports.VerificationMethod.decode(reader, reader.uint32())); - break; + continue; case 6: + if (tag !== 50) { + break; + } + if (message.authentication === undefined) { + message.authentication = []; + } message.authentication.push(reader.string()); - break; + continue; case 7: + if (tag !== 58) { + break; + } + if (message.assertionMethod === undefined) { + message.assertionMethod = []; + } message.assertionMethod.push(reader.string()); - break; + continue; case 8: + if (tag !== 66) { + break; + } + if (message.keyAgreement === undefined) { + message.keyAgreement = []; + } message.keyAgreement.push(reader.string()); - break; + continue; case 9: + if (tag !== 74) { + break; + } + if (message.capabilityInvocation === undefined) { + message.capabilityInvocation = []; + } message.capabilityInvocation.push(reader.string()); - break; + continue; case 10: + if (tag !== 82) { + break; + } + if (message.capabilityDelegation === undefined) { + message.capabilityDelegation = []; + } message.capabilityDelegation.push(reader.string()); - break; + continue; case 11: + if (tag !== 90) { + break; + } + if (message.service === undefined) { + message.service = []; + } message.service.push(exports.Service.decode(reader, reader.uint32())); - break; - default: - reader.skipType(tag & 7); - break; + continue; } + if ((tag & 7) === 4 || tag === 0) { + break; + } + reader.skipType(tag & 7); } return message; }, fromJSON(object) { - const message = Object.assign({}, baseDid); - message.context = []; - message.controller = []; - message.alsoKnownAs = []; - message.verificationMethod = []; - message.authentication = []; - message.assertionMethod = []; - message.keyAgreement = []; - message.capabilityInvocation = []; - message.capabilityDelegation = []; - message.service = []; - if (object.context !== undefined && object.context !== null) { - for (const e of object.context) { - message.context.push(String(e)); - } - } - if (object.id !== undefined && object.id !== null) { - message.id = String(object.id); - } - else { - message.id = ""; - } - if (object.controller !== undefined && object.controller !== null) { - for (const e of object.controller) { - message.controller.push(String(e)); - } - } - if (object.alsoKnownAs !== undefined && object.alsoKnownAs !== null) { - for (const e of object.alsoKnownAs) { - message.alsoKnownAs.push(String(e)); - } - } - if (object.verificationMethod !== undefined && - object.verificationMethod !== null) { - for (const e of object.verificationMethod) { - message.verificationMethod.push(exports.VerificationMethod.fromJSON(e)); - } - } - if (object.authentication !== undefined && object.authentication !== null) { - for (const e of object.authentication) { - message.authentication.push(String(e)); - } - } - if (object.assertionMethod !== undefined && - object.assertionMethod !== null) { - for (const e of object.assertionMethod) { - message.assertionMethod.push(String(e)); - } - } - if (object.keyAgreement !== undefined && object.keyAgreement !== null) { - for (const e of object.keyAgreement) { - message.keyAgreement.push(String(e)); - } - } - if (object.capabilityInvocation !== undefined && - object.capabilityInvocation !== null) { - for (const e of object.capabilityInvocation) { - message.capabilityInvocation.push(String(e)); - } - } - if (object.capabilityDelegation !== undefined && - object.capabilityDelegation !== null) { - for (const e of object.capabilityDelegation) { - message.capabilityDelegation.push(String(e)); - } - } - if (object.service !== undefined && object.service !== null) { - for (const e of object.service) { - message.service.push(exports.Service.fromJSON(e)); - } - } - return message; + return { + "@context": globalThis.Array.isArray(object === null || object === void 0 ? void 0 : object["@context"]) + ? object["@context"].map((e) => globalThis.String(e)) + : undefined, + id: isSet(object.id) ? globalThis.String(object.id) : undefined, + controller: globalThis.Array.isArray(object === null || object === void 0 ? void 0 : object.controller) + ? object.controller.map((e) => globalThis.String(e)) + : undefined, + alsoKnownAs: globalThis.Array.isArray(object === null || object === void 0 ? void 0 : object.alsoKnownAs) + ? object.alsoKnownAs.map((e) => globalThis.String(e)) + : undefined, + verificationMethod: globalThis.Array.isArray(object === null || object === void 0 ? void 0 : object.verificationMethod) + ? object.verificationMethod.map((e) => exports.VerificationMethod.fromJSON(e)) + : undefined, + authentication: globalThis.Array.isArray(object === null || object === void 0 ? void 0 : object.authentication) + ? object.authentication.map((e) => globalThis.String(e)) + : undefined, + assertionMethod: globalThis.Array.isArray(object === null || object === void 0 ? void 0 : object.assertionMethod) + ? object.assertionMethod.map((e) => globalThis.String(e)) + : undefined, + keyAgreement: globalThis.Array.isArray(object === null || object === void 0 ? void 0 : object.keyAgreement) + ? object.keyAgreement.map((e) => globalThis.String(e)) + : undefined, + capabilityInvocation: globalThis.Array.isArray(object === null || object === void 0 ? void 0 : object.capabilityInvocation) + ? object.capabilityInvocation.map((e) => globalThis.String(e)) + : undefined, + capabilityDelegation: globalThis.Array.isArray(object === null || object === void 0 ? void 0 : object.capabilityDelegation) + ? object.capabilityDelegation.map((e) => globalThis.String(e)) + : undefined, + service: globalThis.Array.isArray(object === null || object === void 0 ? void 0 : object.service) + ? object.service.map((e) => exports.Service.fromJSON(e)) + : undefined, + }; }, toJSON(message) { + var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k; const obj = {}; - if (message.context) { - obj.context = message.context.map((e) => e); - } - else { - obj.context = []; - } - message.id !== undefined && (obj.id = message.id); - if (message.controller) { - obj.controller = message.controller.map((e) => e); - } - else { - obj.controller = []; - } - if (message.alsoKnownAs) { - obj.alsoKnownAs = message.alsoKnownAs.map((e) => e); - } - else { - obj.alsoKnownAs = []; + if ((_a = message["@context"]) === null || _a === void 0 ? void 0 : _a.length) { + obj["@context"] = message["@context"]; } - if (message.verificationMethod) { - obj.verificationMethod = message.verificationMethod.map((e) => e ? exports.VerificationMethod.toJSON(e) : undefined); + if (message.id !== undefined && message.id !== "") { + obj.id = message.id; } - else { - obj.verificationMethod = []; + if ((_b = message.controller) === null || _b === void 0 ? void 0 : _b.length) { + obj.controller = message.controller; } - if (message.authentication) { - obj.authentication = message.authentication.map((e) => e); + if ((_c = message.alsoKnownAs) === null || _c === void 0 ? void 0 : _c.length) { + obj.alsoKnownAs = message.alsoKnownAs; } - else { - obj.authentication = []; + if ((_d = message.verificationMethod) === null || _d === void 0 ? void 0 : _d.length) { + obj.verificationMethod = message.verificationMethod.map((e) => exports.VerificationMethod.toJSON(e)); } - if (message.assertionMethod) { - obj.assertionMethod = message.assertionMethod.map((e) => e); + if ((_e = message.authentication) === null || _e === void 0 ? void 0 : _e.length) { + obj.authentication = message.authentication; } - else { - obj.assertionMethod = []; + if ((_f = message.assertionMethod) === null || _f === void 0 ? void 0 : _f.length) { + obj.assertionMethod = message.assertionMethod; } - if (message.keyAgreement) { - obj.keyAgreement = message.keyAgreement.map((e) => e); + if ((_g = message.keyAgreement) === null || _g === void 0 ? void 0 : _g.length) { + obj.keyAgreement = message.keyAgreement; } - else { - obj.keyAgreement = []; + if ((_h = message.capabilityInvocation) === null || _h === void 0 ? void 0 : _h.length) { + obj.capabilityInvocation = message.capabilityInvocation; } - if (message.capabilityInvocation) { - obj.capabilityInvocation = message.capabilityInvocation.map((e) => e); + if ((_j = message.capabilityDelegation) === null || _j === void 0 ? void 0 : _j.length) { + obj.capabilityDelegation = message.capabilityDelegation; } - else { - obj.capabilityInvocation = []; - } - if (message.capabilityDelegation) { - obj.capabilityDelegation = message.capabilityDelegation.map((e) => e); - } - else { - obj.capabilityDelegation = []; - } - if (message.service) { - obj.service = message.service.map((e) => e ? exports.Service.toJSON(e) : undefined); - } - else { - obj.service = []; + if ((_k = message.service) === null || _k === void 0 ? void 0 : _k.length) { + obj.service = message.service.map((e) => exports.Service.toJSON(e)); } return obj; }, + create(base) { + return exports.DidDocument.fromPartial(base !== null && base !== void 0 ? base : {}); + }, fromPartial(object) { - const message = Object.assign({}, baseDid); - message.context = []; - message.controller = []; - message.alsoKnownAs = []; - message.verificationMethod = []; - message.authentication = []; - message.assertionMethod = []; - message.keyAgreement = []; - message.capabilityInvocation = []; - message.capabilityDelegation = []; - message.service = []; - if (object.context !== undefined && object.context !== null) { - for (const e of object.context) { - message.context.push(e); - } - } - if (object.id !== undefined && object.id !== null) { - message.id = object.id; - } - else { - message.id = ""; - } - if (object.controller !== undefined && object.controller !== null) { - for (const e of object.controller) { - message.controller.push(e); - } - } - if (object.alsoKnownAs !== undefined && object.alsoKnownAs !== null) { - for (const e of object.alsoKnownAs) { - message.alsoKnownAs.push(e); - } - } - if (object.verificationMethod !== undefined && - object.verificationMethod !== null) { - for (const e of object.verificationMethod) { - message.verificationMethod.push(exports.VerificationMethod.fromPartial(e)); - } - } - if (object.authentication !== undefined && object.authentication !== null) { - for (const e of object.authentication) { - message.authentication.push(e); - } - } - if (object.assertionMethod !== undefined && - object.assertionMethod !== null) { - for (const e of object.assertionMethod) { - message.assertionMethod.push(e); - } - } - if (object.keyAgreement !== undefined && object.keyAgreement !== null) { - for (const e of object.keyAgreement) { - message.keyAgreement.push(e); - } - } - if (object.capabilityInvocation !== undefined && - object.capabilityInvocation !== null) { - for (const e of object.capabilityInvocation) { - message.capabilityInvocation.push(e); - } - } - if (object.capabilityDelegation !== undefined && - object.capabilityDelegation !== null) { - for (const e of object.capabilityDelegation) { - message.capabilityDelegation.push(e); - } - } - if (object.service !== undefined && object.service !== null) { - for (const e of object.service) { - message.service.push(exports.Service.fromPartial(e)); - } - } + var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l; + const message = createBaseDidDocument(); + message["@context"] = ((_a = object["@context"]) === null || _a === void 0 ? void 0 : _a.map((e) => e)) || undefined; + message.id = (_b = object.id) !== null && _b !== void 0 ? _b : undefined; + message.controller = ((_c = object.controller) === null || _c === void 0 ? void 0 : _c.map((e) => e)) || undefined; + message.alsoKnownAs = ((_d = object.alsoKnownAs) === null || _d === void 0 ? void 0 : _d.map((e) => e)) || undefined; + message.verificationMethod = ((_e = object.verificationMethod) === null || _e === void 0 ? void 0 : _e.map((e) => exports.VerificationMethod.fromPartial(e))) || undefined; + message.authentication = ((_f = object.authentication) === null || _f === void 0 ? void 0 : _f.map((e) => e)) || undefined; + message.assertionMethod = ((_g = object.assertionMethod) === null || _g === void 0 ? void 0 : _g.map((e) => e)) || undefined; + message.keyAgreement = ((_h = object.keyAgreement) === null || _h === void 0 ? void 0 : _h.map((e) => e)) || undefined; + message.capabilityInvocation = ((_j = object.capabilityInvocation) === null || _j === void 0 ? void 0 : _j.map((e) => e)) || undefined; + message.capabilityDelegation = ((_k = object.capabilityDelegation) === null || _k === void 0 ? void 0 : _k.map((e) => e)) || undefined; + message.service = ((_l = object.service) === null || _l === void 0 ? void 0 : _l.map((e) => exports.Service.fromPartial(e))) || undefined; return message; }, }; -const baseMetadata = { - created: "", - updated: "", - deactivated: false, - versionId: "", -}; -exports.Metadata = { - encode(message, writer = minimal_1.Writer.create()) { - if (message.created !== "") { +function createBaseDidDocumentMetadata() { + return {}; +} +exports.DidDocumentMetadata = { + encode(message, writer = minimal_1.default.Writer.create()) { + if (message.created !== undefined && message.created !== "") { writer.uint32(10).string(message.created); } - if (message.updated !== "") { + if (message.updated !== undefined && message.updated !== "") { writer.uint32(18).string(message.updated); } if (message.deactivated === true) { writer.uint32(24).bool(message.deactivated); } - if (message.versionId !== "") { + if (message.versionId !== undefined && message.versionId !== "") { writer.uint32(34).string(message.versionId); } return writer; }, decode(input, length) { - const reader = input instanceof Uint8Array ? new minimal_1.Reader(input) : input; + const reader = input instanceof minimal_1.default.Reader ? input : minimal_1.default.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; - const message = Object.assign({}, baseMetadata); + const message = createBaseDidDocumentMetadata(); while (reader.pos < end) { const tag = reader.uint32(); switch (tag >>> 3) { case 1: + if (tag !== 10) { + break; + } message.created = reader.string(); - break; + continue; case 2: + if (tag !== 18) { + break; + } message.updated = reader.string(); - break; + continue; case 3: + if (tag !== 24) { + break; + } message.deactivated = reader.bool(); - break; + continue; case 4: + if (tag !== 34) { + break; + } message.versionId = reader.string(); - break; - default: - reader.skipType(tag & 7); - break; + continue; } + if ((tag & 7) === 4 || tag === 0) { + break; + } + reader.skipType(tag & 7); } return message; }, fromJSON(object) { - const message = Object.assign({}, baseMetadata); - if (object.created !== undefined && object.created !== null) { - message.created = String(object.created); - } - else { - message.created = ""; - } - if (object.updated !== undefined && object.updated !== null) { - message.updated = String(object.updated); - } - else { - message.updated = ""; - } - if (object.deactivated !== undefined && object.deactivated !== null) { - message.deactivated = Boolean(object.deactivated); - } - else { - message.deactivated = false; - } - if (object.versionId !== undefined && object.versionId !== null) { - message.versionId = String(object.versionId); - } - else { - message.versionId = ""; - } - return message; + return { + created: isSet(object.created) ? globalThis.String(object.created) : undefined, + updated: isSet(object.updated) ? globalThis.String(object.updated) : undefined, + deactivated: isSet(object.deactivated) ? globalThis.Boolean(object.deactivated) : undefined, + versionId: isSet(object.versionId) ? globalThis.String(object.versionId) : undefined, + }; }, toJSON(message) { const obj = {}; - message.created !== undefined && (obj.created = message.created); - message.updated !== undefined && (obj.updated = message.updated); - message.deactivated !== undefined && - (obj.deactivated = message.deactivated); - message.versionId !== undefined && (obj.versionId = message.versionId); - return obj; - }, - fromPartial(object) { - const message = Object.assign({}, baseMetadata); - if (object.created !== undefined && object.created !== null) { - message.created = object.created; - } - else { - message.created = ""; - } - if (object.updated !== undefined && object.updated !== null) { - message.updated = object.updated; + if (message.created !== undefined && message.created !== "") { + obj.created = message.created; } - else { - message.updated = ""; + if (message.updated !== undefined && message.updated !== "") { + obj.updated = message.updated; } - if (object.deactivated !== undefined && object.deactivated !== null) { - message.deactivated = object.deactivated; - } - else { - message.deactivated = false; - } - if (object.versionId !== undefined && object.versionId !== null) { - message.versionId = object.versionId; + if (message.deactivated === true) { + obj.deactivated = message.deactivated; } - else { - message.versionId = ""; + if (message.versionId !== undefined && message.versionId !== "") { + obj.versionId = message.versionId; } + return obj; + }, + create(base) { + return exports.DidDocumentMetadata.fromPartial(base !== null && base !== void 0 ? base : {}); + }, + fromPartial(object) { + var _a, _b, _c, _d; + const message = createBaseDidDocumentMetadata(); + message.created = (_a = object.created) !== null && _a !== void 0 ? _a : undefined; + message.updated = (_b = object.updated) !== null && _b !== void 0 ? _b : undefined; + message.deactivated = (_c = object.deactivated) !== null && _c !== void 0 ? _c : undefined; + message.versionId = (_d = object.versionId) !== null && _d !== void 0 ? _d : undefined; return message; }, }; -const baseVerificationMethod = { - id: "", - type: "", - controller: "", - publicKeyMultibase: "", - blockchainAccountId: "", -}; +function createBaseVerificationMethod() { + return {}; +} exports.VerificationMethod = { - encode(message, writer = minimal_1.Writer.create()) { - if (message.id !== "") { + encode(message, writer = minimal_1.default.Writer.create()) { + if (message.id !== undefined && message.id !== "") { writer.uint32(10).string(message.id); } - if (message.type !== "") { + if (message.type !== undefined && message.type !== "") { writer.uint32(18).string(message.type); } - if (message.controller !== "") { + if (message.controller !== undefined && message.controller !== "") { writer.uint32(26).string(message.controller); } - if (message.publicKeyMultibase !== "") { + if (message.publicKeyMultibase !== undefined && message.publicKeyMultibase !== "") { writer.uint32(34).string(message.publicKeyMultibase); } - if (message.blockchainAccountId !== "") { + if (message.blockchainAccountId !== undefined && message.blockchainAccountId !== "") { writer.uint32(42).string(message.blockchainAccountId); } return writer; }, decode(input, length) { - const reader = input instanceof Uint8Array ? new minimal_1.Reader(input) : input; + const reader = input instanceof minimal_1.default.Reader ? input : minimal_1.default.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; - const message = Object.assign({}, baseVerificationMethod); + const message = createBaseVerificationMethod(); while (reader.pos < end) { const tag = reader.uint32(); switch (tag >>> 3) { case 1: + if (tag !== 10) { + break; + } message.id = reader.string(); - break; + continue; case 2: + if (tag !== 18) { + break; + } message.type = reader.string(); - break; + continue; case 3: + if (tag !== 26) { + break; + } message.controller = reader.string(); - break; + continue; case 4: + if (tag !== 34) { + break; + } message.publicKeyMultibase = reader.string(); - break; + continue; case 5: + if (tag !== 42) { + break; + } message.blockchainAccountId = reader.string(); - break; - default: - reader.skipType(tag & 7); - break; + continue; } + if ((tag & 7) === 4 || tag === 0) { + break; + } + reader.skipType(tag & 7); } return message; }, fromJSON(object) { - const message = Object.assign({}, baseVerificationMethod); - if (object.id !== undefined && object.id !== null) { - message.id = String(object.id); - } - else { - message.id = ""; - } - if (object.type !== undefined && object.type !== null) { - message.type = String(object.type); - } - else { - message.type = ""; - } - if (object.controller !== undefined && object.controller !== null) { - message.controller = String(object.controller); - } - else { - message.controller = ""; - } - if (object.publicKeyMultibase !== undefined && - object.publicKeyMultibase !== null) { - message.publicKeyMultibase = String(object.publicKeyMultibase); - } - else { - message.publicKeyMultibase = ""; - } - if (object.blockchainAccountId !== undefined && - object.blockchainAccountId !== null) { - message.blockchainAccountId = String(object.blockchainAccountId); - } - else { - message.blockchainAccountId = ""; - } - return message; + return { + id: isSet(object.id) ? globalThis.String(object.id) : undefined, + type: isSet(object.type) ? globalThis.String(object.type) : undefined, + controller: isSet(object.controller) ? globalThis.String(object.controller) : undefined, + publicKeyMultibase: isSet(object.publicKeyMultibase) ? globalThis.String(object.publicKeyMultibase) : undefined, + blockchainAccountId: isSet(object.blockchainAccountId) + ? globalThis.String(object.blockchainAccountId) + : undefined, + }; }, toJSON(message) { const obj = {}; - message.id !== undefined && (obj.id = message.id); - message.type !== undefined && (obj.type = message.type); - message.controller !== undefined && (obj.controller = message.controller); - message.publicKeyMultibase !== undefined && - (obj.publicKeyMultibase = message.publicKeyMultibase); - message.blockchainAccountId !== undefined && - (obj.blockchainAccountId = message.blockchainAccountId); - return obj; - }, - fromPartial(object) { - const message = Object.assign({}, baseVerificationMethod); - if (object.id !== undefined && object.id !== null) { - message.id = object.id; - } - else { - message.id = ""; - } - if (object.type !== undefined && object.type !== null) { - message.type = object.type; - } - else { - message.type = ""; + if (message.id !== undefined && message.id !== "") { + obj.id = message.id; } - if (object.controller !== undefined && object.controller !== null) { - message.controller = object.controller; + if (message.type !== undefined && message.type !== "") { + obj.type = message.type; } - else { - message.controller = ""; + if (message.controller !== undefined && message.controller !== "") { + obj.controller = message.controller; } - if (object.publicKeyMultibase !== undefined && - object.publicKeyMultibase !== null) { - message.publicKeyMultibase = object.publicKeyMultibase; + if (message.publicKeyMultibase !== undefined && message.publicKeyMultibase !== "") { + obj.publicKeyMultibase = message.publicKeyMultibase; } - else { - message.publicKeyMultibase = ""; - } - if (object.blockchainAccountId !== undefined && - object.blockchainAccountId !== null) { - message.blockchainAccountId = object.blockchainAccountId; - } - else { - message.blockchainAccountId = ""; + if (message.blockchainAccountId !== undefined && message.blockchainAccountId !== "") { + obj.blockchainAccountId = message.blockchainAccountId; } + return obj; + }, + create(base) { + return exports.VerificationMethod.fromPartial(base !== null && base !== void 0 ? base : {}); + }, + fromPartial(object) { + var _a, _b, _c, _d, _e; + const message = createBaseVerificationMethod(); + message.id = (_a = object.id) !== null && _a !== void 0 ? _a : undefined; + message.type = (_b = object.type) !== null && _b !== void 0 ? _b : undefined; + message.controller = (_c = object.controller) !== null && _c !== void 0 ? _c : undefined; + message.publicKeyMultibase = (_d = object.publicKeyMultibase) !== null && _d !== void 0 ? _d : undefined; + message.blockchainAccountId = (_e = object.blockchainAccountId) !== null && _e !== void 0 ? _e : undefined; return message; }, }; -const baseService = { id: "", type: "", serviceEndpoint: "" }; +function createBaseService() { + return {}; +} exports.Service = { - encode(message, writer = minimal_1.Writer.create()) { - if (message.id !== "") { + encode(message, writer = minimal_1.default.Writer.create()) { + if (message.id !== undefined && message.id !== "") { writer.uint32(10).string(message.id); } - if (message.type !== "") { + if (message.type !== undefined && message.type !== "") { writer.uint32(18).string(message.type); } - if (message.serviceEndpoint !== "") { + if (message.serviceEndpoint !== undefined && message.serviceEndpoint !== "") { writer.uint32(26).string(message.serviceEndpoint); } return writer; }, decode(input, length) { - const reader = input instanceof Uint8Array ? new minimal_1.Reader(input) : input; + const reader = input instanceof minimal_1.default.Reader ? input : minimal_1.default.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; - const message = Object.assign({}, baseService); + const message = createBaseService(); while (reader.pos < end) { const tag = reader.uint32(); switch (tag >>> 3) { case 1: + if (tag !== 10) { + break; + } message.id = reader.string(); - break; + continue; case 2: + if (tag !== 18) { + break; + } message.type = reader.string(); - break; + continue; case 3: + if (tag !== 26) { + break; + } message.serviceEndpoint = reader.string(); - break; - default: - reader.skipType(tag & 7); - break; + continue; + } + if ((tag & 7) === 4 || tag === 0) { + break; } + reader.skipType(tag & 7); } return message; }, fromJSON(object) { - const message = Object.assign({}, baseService); - if (object.id !== undefined && object.id !== null) { - message.id = String(object.id); - } - else { - message.id = ""; - } - if (object.type !== undefined && object.type !== null) { - message.type = String(object.type); - } - else { - message.type = ""; - } - if (object.serviceEndpoint !== undefined && - object.serviceEndpoint !== null) { - message.serviceEndpoint = String(object.serviceEndpoint); - } - else { - message.serviceEndpoint = ""; - } - return message; + return { + id: isSet(object.id) ? globalThis.String(object.id) : undefined, + type: isSet(object.type) ? globalThis.String(object.type) : undefined, + serviceEndpoint: isSet(object.serviceEndpoint) ? globalThis.String(object.serviceEndpoint) : undefined, + }; }, toJSON(message) { const obj = {}; - message.id !== undefined && (obj.id = message.id); - message.type !== undefined && (obj.type = message.type); - message.serviceEndpoint !== undefined && - (obj.serviceEndpoint = message.serviceEndpoint); - return obj; - }, - fromPartial(object) { - const message = Object.assign({}, baseService); - if (object.id !== undefined && object.id !== null) { - message.id = object.id; + if (message.id !== undefined && message.id !== "") { + obj.id = message.id; } - else { - message.id = ""; + if (message.type !== undefined && message.type !== "") { + obj.type = message.type; } - if (object.type !== undefined && object.type !== null) { - message.type = object.type; + if (message.serviceEndpoint !== undefined && message.serviceEndpoint !== "") { + obj.serviceEndpoint = message.serviceEndpoint; } - else { - message.type = ""; - } - if (object.serviceEndpoint !== undefined && - object.serviceEndpoint !== null) { - message.serviceEndpoint = object.serviceEndpoint; - } - else { - message.serviceEndpoint = ""; - } - return message; - }, -}; -const baseSignInfo = { verification_method_id: "", signature: "" }; -exports.SignInfo = { - encode(message, writer = minimal_1.Writer.create()) { - if (message.verification_method_id !== "") { - writer.uint32(10).string(message.verification_method_id); - } - if (message.signature !== "") { - writer.uint32(18).string(message.signature); - } - if (message.clientSpec !== undefined) { - clientSpec_1.ClientSpec.encode(message.clientSpec, writer.uint32(26).fork()).ldelim(); - } - return writer; - }, - decode(input, length) { - const reader = input instanceof Uint8Array ? new minimal_1.Reader(input) : input; - let end = length === undefined ? reader.len : reader.pos + length; - const message = Object.assign({}, baseSignInfo); - while (reader.pos < end) { - const tag = reader.uint32(); - switch (tag >>> 3) { - case 1: - message.verification_method_id = reader.string(); - break; - case 2: - message.signature = reader.string(); - break; - case 3: - message.clientSpec = clientSpec_1.ClientSpec.decode(reader, reader.uint32()); - break; - default: - reader.skipType(tag & 7); - break; - } - } - return message; - }, - fromJSON(object) { - const message = Object.assign({}, baseSignInfo); - if (object.verification_method_id !== undefined && - object.verification_method_id !== null) { - message.verification_method_id = String(object.verification_method_id); - } - else { - message.verification_method_id = ""; - } - if (object.signature !== undefined && object.signature !== null) { - message.signature = String(object.signature); - } - else { - message.signature = ""; - } - if (object.clientSpec !== undefined && object.clientSpec !== null) { - message.clientSpec = clientSpec_1.ClientSpec.fromJSON(object.clientSpec); - } - else { - message.clientSpec = undefined; - } - return message; - }, - toJSON(message) { - const obj = {}; - message.verification_method_id !== undefined && - (obj.verification_method_id = message.verification_method_id); - message.signature !== undefined && (obj.signature = message.signature); - message.clientSpec !== undefined && - (obj.clientSpec = message.clientSpec - ? clientSpec_1.ClientSpec.toJSON(message.clientSpec) - : undefined); return obj; }, + create(base) { + return exports.Service.fromPartial(base !== null && base !== void 0 ? base : {}); + }, fromPartial(object) { - const message = Object.assign({}, baseSignInfo); - if (object.verification_method_id !== undefined && - object.verification_method_id !== null) { - message.verification_method_id = object.verification_method_id; - } - else { - message.verification_method_id = ""; - } - if (object.signature !== undefined && object.signature !== null) { - message.signature = object.signature; - } - else { - message.signature = ""; - } - if (object.clientSpec !== undefined && object.clientSpec !== null) { - message.clientSpec = clientSpec_1.ClientSpec.fromPartial(object.clientSpec); - } - else { - message.clientSpec = undefined; - } + var _a, _b, _c; + const message = createBaseService(); + message.id = (_a = object.id) !== null && _a !== void 0 ? _a : undefined; + message.type = (_b = object.type) !== null && _b !== void 0 ? _b : undefined; + message.serviceEndpoint = (_c = object.serviceEndpoint) !== null && _c !== void 0 ? _c : undefined; return message; }, }; -const baseDidDocumentState = {}; +function createBaseDidDocumentState() { + return {}; +} exports.DidDocumentState = { - encode(message, writer = minimal_1.Writer.create()) { + encode(message, writer = minimal_1.default.Writer.create()) { if (message.didDocument !== undefined) { - exports.Did.encode(message.didDocument, writer.uint32(10).fork()).ldelim(); + exports.DidDocument.encode(message.didDocument, writer.uint32(10).fork()).ldelim(); } if (message.didDocumentMetadata !== undefined) { - exports.Metadata.encode(message.didDocumentMetadata, writer.uint32(18).fork()).ldelim(); + exports.DidDocumentMetadata.encode(message.didDocumentMetadata, writer.uint32(18).fork()).ldelim(); } return writer; }, decode(input, length) { - const reader = input instanceof Uint8Array ? new minimal_1.Reader(input) : input; + const reader = input instanceof minimal_1.default.Reader ? input : minimal_1.default.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; - const message = Object.assign({}, baseDidDocumentState); + const message = createBaseDidDocumentState(); while (reader.pos < end) { const tag = reader.uint32(); switch (tag >>> 3) { case 1: - message.didDocument = exports.Did.decode(reader, reader.uint32()); - break; + if (tag !== 10) { + break; + } + message.didDocument = exports.DidDocument.decode(reader, reader.uint32()); + continue; case 2: - message.didDocumentMetadata = exports.Metadata.decode(reader, reader.uint32()); - break; - default: - reader.skipType(tag & 7); - break; + if (tag !== 18) { + break; + } + message.didDocumentMetadata = exports.DidDocumentMetadata.decode(reader, reader.uint32()); + continue; + } + if ((tag & 7) === 4 || tag === 0) { + break; } + reader.skipType(tag & 7); } return message; }, fromJSON(object) { - const message = Object.assign({}, baseDidDocumentState); - if (object.didDocument !== undefined && object.didDocument !== null) { - message.didDocument = exports.Did.fromJSON(object.didDocument); - } - else { - message.didDocument = undefined; - } - if (object.didDocumentMetadata !== undefined && - object.didDocumentMetadata !== null) { - message.didDocumentMetadata = exports.Metadata.fromJSON(object.didDocumentMetadata); - } - else { - message.didDocumentMetadata = undefined; - } - return message; + return { + didDocument: isSet(object.didDocument) ? exports.DidDocument.fromJSON(object.didDocument) : undefined, + didDocumentMetadata: isSet(object.didDocumentMetadata) + ? exports.DidDocumentMetadata.fromJSON(object.didDocumentMetadata) + : undefined, + }; }, toJSON(message) { const obj = {}; - message.didDocument !== undefined && - (obj.didDocument = message.didDocument - ? exports.Did.toJSON(message.didDocument) - : undefined); - message.didDocumentMetadata !== undefined && - (obj.didDocumentMetadata = message.didDocumentMetadata - ? exports.Metadata.toJSON(message.didDocumentMetadata) - : undefined); + if (message.didDocument !== undefined) { + obj.didDocument = exports.DidDocument.toJSON(message.didDocument); + } + if (message.didDocumentMetadata !== undefined) { + obj.didDocumentMetadata = exports.DidDocumentMetadata.toJSON(message.didDocumentMetadata); + } return obj; }, + create(base) { + return exports.DidDocumentState.fromPartial(base !== null && base !== void 0 ? base : {}); + }, fromPartial(object) { - const message = Object.assign({}, baseDidDocumentState); - if (object.didDocument !== undefined && object.didDocument !== null) { - message.didDocument = exports.Did.fromPartial(object.didDocument); - } - else { - message.didDocument = undefined; - } - if (object.didDocumentMetadata !== undefined && - object.didDocumentMetadata !== null) { - message.didDocumentMetadata = exports.Metadata.fromPartial(object.didDocumentMetadata); - } - else { - message.didDocumentMetadata = undefined; - } + const message = createBaseDidDocumentState(); + message.didDocument = (object.didDocument !== undefined && object.didDocument !== null) + ? exports.DidDocument.fromPartial(object.didDocument) + : undefined; + message.didDocumentMetadata = (object.didDocumentMetadata !== undefined && object.didDocumentMetadata !== null) + ? exports.DidDocumentMetadata.fromPartial(object.didDocumentMetadata) + : undefined; return message; }, }; +function isSet(value) { + return value !== null && value !== undefined; +} diff --git a/build/libs/generated/ssi/genesis.d.ts b/build/libs/generated/ssi/genesis.d.ts new file mode 100644 index 0000000..9d8a658 --- /dev/null +++ b/build/libs/generated/ssi/genesis.d.ts @@ -0,0 +1,34 @@ +import _m0 from "protobufjs/minimal"; +export declare const protobufPackage = "hypersign.ssi.v1"; +/** GenesisState defines the ssi module's genesis state. */ +export interface GenesisState { + chainNamespace?: string | undefined; +} +export declare const GenesisState: { + encode(message: GenesisState, writer?: _m0.Writer): _m0.Writer; + decode(input: _m0.Reader | Uint8Array, length?: number): GenesisState; + fromJSON(object: any): GenesisState; + toJSON(message: GenesisState): unknown; + create]: never; }>(base?: I | undefined): GenesisState; + fromPartial]: never; }>(object: I_1): GenesisState; +}; +type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined; +export type DeepPartial = T extends Builtin ? T : T extends globalThis.Array ? globalThis.Array> : T extends ReadonlyArray ? ReadonlyArray> : T extends {} ? { + [K in keyof T]?: DeepPartial; +} : Partial; +type KeysOfUnion = T extends T ? keyof T : never; +export type Exact = P extends Builtin ? P : P & { + [K in keyof P]: Exact; +} & { + [K in Exclude>]: never; +}; +export {}; +//# sourceMappingURL=genesis.d.ts.map \ No newline at end of file diff --git a/build/libs/generated/ssi/genesis.d.ts.map b/build/libs/generated/ssi/genesis.d.ts.map new file mode 100644 index 0000000..081917a --- /dev/null +++ b/build/libs/generated/ssi/genesis.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"genesis.d.ts","sourceRoot":"","sources":["../../../../libs/generated/ssi/genesis.ts"],"names":[],"mappings":"AACA,OAAO,GAAG,MAAM,oBAAoB,CAAC;AAErC,eAAO,MAAM,eAAe,qBAAqB,CAAC;AAElD,2DAA2D;AAC3D,MAAM,WAAW,YAAY;IAC3B,cAAc,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;CACrC;AAMD,eAAO,MAAM,YAAY;oBACP,YAAY,WAAU,IAAI,MAAM,GAAyB,IAAI,MAAM;kBAOrE,IAAI,MAAM,GAAG,UAAU,WAAW,MAAM,GAAG,YAAY;qBAuBpD,GAAG,GAAG,YAAY;oBAInB,YAAY,GAAG,OAAO;;yBA1CrB,MAAM,GAAG,SAAS;;yBAAlB,MAAM,GAAG,SAAS;sFAkD8B,YAAY;;yBAlD5D,MAAM,GAAG,SAAS;;yBAAlB,MAAM,GAAG,SAAS;iFAqDoC,YAAY;CAKpF,CAAC;AAEF,KAAK,OAAO,GAAG,IAAI,GAAG,QAAQ,GAAG,UAAU,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,SAAS,CAAC;AAEpF,MAAM,MAAM,WAAW,CAAC,CAAC,IAAI,CAAC,SAAS,OAAO,GAAG,CAAC,GAC9C,CAAC,SAAS,UAAU,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,GAAG,UAAU,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,GACtE,CAAC,SAAS,aAAa,CAAC,MAAM,CAAC,CAAC,GAAG,aAAa,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,GAChE,CAAC,SAAS,EAAE,GAAG;KAAG,CAAC,IAAI,MAAM,CAAC,CAAC,CAAC,EAAE,WAAW,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;CAAE,GACrD,OAAO,CAAC,CAAC,CAAC,CAAC;AAEf,KAAK,WAAW,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,GAAG,MAAM,CAAC,GAAG,KAAK,CAAC;AACpD,MAAM,MAAM,KAAK,CAAC,CAAC,EAAE,CAAC,SAAS,CAAC,IAAI,CAAC,SAAS,OAAO,GAAG,CAAC,GACrD,CAAC,GAAG;KAAG,CAAC,IAAI,MAAM,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC;CAAE,GAAG;KAAG,CAAC,IAAI,OAAO,CAAC,MAAM,CAAC,EAAE,WAAW,CAAC,CAAC,CAAC,CAAC,GAAG,KAAK;CAAE,CAAC"} \ No newline at end of file diff --git a/build/libs/generated/ssi/genesis.js b/build/libs/generated/ssi/genesis.js new file mode 100644 index 0000000..3e5d7d0 --- /dev/null +++ b/build/libs/generated/ssi/genesis.js @@ -0,0 +1,63 @@ +"use strict"; +var __importDefault = (this && this.__importDefault) || function (mod) { + return (mod && mod.__esModule) ? mod : { "default": mod }; +}; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.GenesisState = exports.protobufPackage = void 0; +/* eslint-disable */ +const minimal_1 = __importDefault(require("protobufjs/minimal")); +exports.protobufPackage = "hypersign.ssi.v1"; +function createBaseGenesisState() { + return {}; +} +exports.GenesisState = { + encode(message, writer = minimal_1.default.Writer.create()) { + if (message.chainNamespace !== undefined && message.chainNamespace !== "") { + writer.uint32(10).string(message.chainNamespace); + } + return writer; + }, + decode(input, length) { + const reader = input instanceof minimal_1.default.Reader ? input : minimal_1.default.Reader.create(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseGenesisState(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + if (tag !== 10) { + break; + } + message.chainNamespace = reader.string(); + continue; + } + if ((tag & 7) === 4 || tag === 0) { + break; + } + reader.skipType(tag & 7); + } + return message; + }, + fromJSON(object) { + return { chainNamespace: isSet(object.chainNamespace) ? globalThis.String(object.chainNamespace) : undefined }; + }, + toJSON(message) { + const obj = {}; + if (message.chainNamespace !== undefined && message.chainNamespace !== "") { + obj.chainNamespace = message.chainNamespace; + } + return obj; + }, + create(base) { + return exports.GenesisState.fromPartial(base !== null && base !== void 0 ? base : {}); + }, + fromPartial(object) { + var _a; + const message = createBaseGenesisState(); + message.chainNamespace = (_a = object.chainNamespace) !== null && _a !== void 0 ? _a : undefined; + return message; + }, +}; +function isSet(value) { + return value !== null && value !== undefined; +} diff --git a/build/libs/generated/ssi/proof.d.ts b/build/libs/generated/ssi/proof.d.ts new file mode 100644 index 0000000..dedd534 --- /dev/null +++ b/build/libs/generated/ssi/proof.d.ts @@ -0,0 +1,59 @@ +import _m0 from "protobufjs/minimal"; +import { ClientSpecType } from "./client_spec"; +export declare const protobufPackage = "hypersign.ssi.v1"; +export interface DocumentProof { + type?: string | undefined; + created?: string | undefined; + verificationMethod?: string | undefined; + proofPurpose?: string | undefined; + proofValue?: string | undefined; + clientSpecType?: ClientSpecType | undefined; +} +export declare const DocumentProof: { + encode(message: DocumentProof, writer?: _m0.Writer): _m0.Writer; + decode(input: _m0.Reader | Uint8Array, length?: number): DocumentProof; + fromJSON(object: any): DocumentProof; + toJSON(message: DocumentProof): unknown; + create]: never; }>(base?: I | undefined): DocumentProof; + fromPartial]: never; }>(object: I_1): DocumentProof; +}; +type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined; +export type DeepPartial = T extends Builtin ? T : T extends globalThis.Array ? globalThis.Array> : T extends ReadonlyArray ? ReadonlyArray> : T extends {} ? { + [K in keyof T]?: DeepPartial; +} : Partial; +type KeysOfUnion = T extends T ? keyof T : never; +export type Exact = P extends Builtin ? P : P & { + [K in keyof P]: Exact; +} & { + [K in Exclude>]: never; +}; +export {}; +//# sourceMappingURL=proof.d.ts.map \ No newline at end of file diff --git a/build/libs/generated/ssi/proof.d.ts.map b/build/libs/generated/ssi/proof.d.ts.map new file mode 100644 index 0000000..15a3175 --- /dev/null +++ b/build/libs/generated/ssi/proof.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"proof.d.ts","sourceRoot":"","sources":["../../../../libs/generated/ssi/proof.ts"],"names":[],"mappings":"AACA,OAAO,GAAG,MAAM,oBAAoB,CAAC;AACrC,OAAO,EAAE,cAAc,EAAwE,MAAM,eAAe,CAAC;AAErH,eAAO,MAAM,eAAe,qBAAqB,CAAC;AAElD,MAAM,WAAW,aAAa;IAC5B,IAAI,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC1B,OAAO,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC7B,kBAAkB,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IACxC,YAAY,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAClC,UAAU,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAChC,cAAc,CAAC,EAAE,cAAc,GAAG,SAAS,CAAC;CAC7C;AAMD,eAAO,MAAM,aAAa;oBACR,aAAa,WAAU,IAAI,MAAM,GAAyB,IAAI,MAAM;kBAsBtE,IAAI,MAAM,GAAG,UAAU,WAAW,MAAM,GAAG,aAAa;qBA0DrD,GAAG,GAAG,aAAa;oBAWpB,aAAa,GAAG,OAAO;;eAxGhC,MAAM,GAAG,SAAS;kBACf,MAAM,GAAG,SAAS;6BACP,MAAM,GAAG,SAAS;uBACxB,MAAM,GAAG,SAAS;qBACpB,MAAM,GAAG,SAAS;yBACd,cAAc,GAAG,SAAS;;eALpC,MAAM,GAAG,SAAS;kBACf,MAAM,GAAG,SAAS;6BACP,MAAM,GAAG,SAAS;uBACxB,MAAM,GAAG,SAAS;qBACpB,MAAM,GAAG,SAAS;yBACd,cAAc,GAAG,SAAS;yFA0HuB,aAAa;;eA/HxE,MAAM,GAAG,SAAS;kBACf,MAAM,GAAG,SAAS;6BACP,MAAM,GAAG,SAAS;uBACxB,MAAM,GAAG,SAAS;qBACpB,MAAM,GAAG,SAAS;yBACd,cAAc,GAAG,SAAS;;eALpC,MAAM,GAAG,SAAS;kBACf,MAAM,GAAG,SAAS;6BACP,MAAM,GAAG,SAAS;uBACxB,MAAM,GAAG,SAAS;qBACpB,MAAM,GAAG,SAAS;yBACd,cAAc,GAAG,SAAS;oFA6H6B,aAAa;CAUtF,CAAC;AAEF,KAAK,OAAO,GAAG,IAAI,GAAG,QAAQ,GAAG,UAAU,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,SAAS,CAAC;AAEpF,MAAM,MAAM,WAAW,CAAC,CAAC,IAAI,CAAC,SAAS,OAAO,GAAG,CAAC,GAC9C,CAAC,SAAS,UAAU,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,GAAG,UAAU,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,GACtE,CAAC,SAAS,aAAa,CAAC,MAAM,CAAC,CAAC,GAAG,aAAa,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,GAChE,CAAC,SAAS,EAAE,GAAG;KAAG,CAAC,IAAI,MAAM,CAAC,CAAC,CAAC,EAAE,WAAW,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;CAAE,GACrD,OAAO,CAAC,CAAC,CAAC,CAAC;AAEf,KAAK,WAAW,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,GAAG,MAAM,CAAC,GAAG,KAAK,CAAC;AACpD,MAAM,MAAM,KAAK,CAAC,CAAC,EAAE,CAAC,SAAS,CAAC,IAAI,CAAC,SAAS,OAAO,GAAG,CAAC,GACrD,CAAC,GAAG;KAAG,CAAC,IAAI,MAAM,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC;CAAE,GAAG;KAAG,CAAC,IAAI,OAAO,CAAC,MAAM,CAAC,EAAE,WAAW,CAAC,CAAC,CAAC,CAAC,GAAG,KAAK;CAAE,CAAC"} \ No newline at end of file diff --git a/build/libs/generated/ssi/proof.js b/build/libs/generated/ssi/proof.js new file mode 100644 index 0000000..40dc775 --- /dev/null +++ b/build/libs/generated/ssi/proof.js @@ -0,0 +1,136 @@ +"use strict"; +var __importDefault = (this && this.__importDefault) || function (mod) { + return (mod && mod.__esModule) ? mod : { "default": mod }; +}; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.DocumentProof = exports.protobufPackage = void 0; +/* eslint-disable */ +const minimal_1 = __importDefault(require("protobufjs/minimal")); +const client_spec_1 = require("./client_spec"); +exports.protobufPackage = "hypersign.ssi.v1"; +function createBaseDocumentProof() { + return {}; +} +exports.DocumentProof = { + encode(message, writer = minimal_1.default.Writer.create()) { + if (message.type !== undefined && message.type !== "") { + writer.uint32(10).string(message.type); + } + if (message.created !== undefined && message.created !== "") { + writer.uint32(18).string(message.created); + } + if (message.verificationMethod !== undefined && message.verificationMethod !== "") { + writer.uint32(26).string(message.verificationMethod); + } + if (message.proofPurpose !== undefined && message.proofPurpose !== "") { + writer.uint32(34).string(message.proofPurpose); + } + if (message.proofValue !== undefined && message.proofValue !== "") { + writer.uint32(42).string(message.proofValue); + } + if (message.clientSpecType !== undefined && message.clientSpecType !== client_spec_1.ClientSpecType.CLIENT_SPEC_TYPE_NONE) { + writer.uint32(48).int32((0, client_spec_1.clientSpecTypeToNumber)(message.clientSpecType)); + } + return writer; + }, + decode(input, length) { + const reader = input instanceof minimal_1.default.Reader ? input : minimal_1.default.Reader.create(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseDocumentProof(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + if (tag !== 10) { + break; + } + message.type = reader.string(); + continue; + case 2: + if (tag !== 18) { + break; + } + message.created = reader.string(); + continue; + case 3: + if (tag !== 26) { + break; + } + message.verificationMethod = reader.string(); + continue; + case 4: + if (tag !== 34) { + break; + } + message.proofPurpose = reader.string(); + continue; + case 5: + if (tag !== 42) { + break; + } + message.proofValue = reader.string(); + continue; + case 6: + if (tag !== 48) { + break; + } + message.clientSpecType = (0, client_spec_1.clientSpecTypeFromJSON)(reader.int32()); + continue; + } + if ((tag & 7) === 4 || tag === 0) { + break; + } + reader.skipType(tag & 7); + } + return message; + }, + fromJSON(object) { + return { + type: isSet(object.type) ? globalThis.String(object.type) : undefined, + created: isSet(object.created) ? globalThis.String(object.created) : undefined, + verificationMethod: isSet(object.verificationMethod) ? globalThis.String(object.verificationMethod) : undefined, + proofPurpose: isSet(object.proofPurpose) ? globalThis.String(object.proofPurpose) : undefined, + proofValue: isSet(object.proofValue) ? globalThis.String(object.proofValue) : undefined, + clientSpecType: isSet(object.clientSpecType) ? (0, client_spec_1.clientSpecTypeFromJSON)(object.clientSpecType) : undefined, + }; + }, + toJSON(message) { + const obj = {}; + if (message.type !== undefined && message.type !== "") { + obj.type = message.type; + } + if (message.created !== undefined && message.created !== "") { + obj.created = message.created; + } + if (message.verificationMethod !== undefined && message.verificationMethod !== "") { + obj.verificationMethod = message.verificationMethod; + } + if (message.proofPurpose !== undefined && message.proofPurpose !== "") { + obj.proofPurpose = message.proofPurpose; + } + if (message.proofValue !== undefined && message.proofValue !== "") { + obj.proofValue = message.proofValue; + } + if (message.clientSpecType !== undefined && message.clientSpecType !== client_spec_1.ClientSpecType.CLIENT_SPEC_TYPE_NONE) { + obj.clientSpecType = (0, client_spec_1.clientSpecTypeToJSON)(message.clientSpecType); + } + return obj; + }, + create(base) { + return exports.DocumentProof.fromPartial(base !== null && base !== void 0 ? base : {}); + }, + fromPartial(object) { + var _a, _b, _c, _d, _e, _f; + const message = createBaseDocumentProof(); + message.type = (_a = object.type) !== null && _a !== void 0 ? _a : undefined; + message.created = (_b = object.created) !== null && _b !== void 0 ? _b : undefined; + message.verificationMethod = (_c = object.verificationMethod) !== null && _c !== void 0 ? _c : undefined; + message.proofPurpose = (_d = object.proofPurpose) !== null && _d !== void 0 ? _d : undefined; + message.proofValue = (_e = object.proofValue) !== null && _e !== void 0 ? _e : undefined; + message.clientSpecType = (_f = object.clientSpecType) !== null && _f !== void 0 ? _f : undefined; + return message; + }, +}; +function isSet(value) { + return value !== null && value !== undefined; +} diff --git a/build/libs/generated/ssi/schema.d.ts b/build/libs/generated/ssi/schema.d.ts deleted file mode 100644 index d49282a..0000000 --- a/build/libs/generated/ssi/schema.d.ts +++ /dev/null @@ -1,70 +0,0 @@ -import { Writer, Reader } from "protobufjs/minimal"; -export declare const protobufPackage = "hypersignprotocol.hidnode.ssi"; -export interface SchemaDocument { - type: string; - modelVersion: string; - id: string; - name: string; - author: string; - authored: string; - schema: SchemaProperty | undefined; -} -export interface SchemaProperty { - schema: string; - description: string; - type: string; - properties: string; - required: string[]; - additionalProperties: boolean; -} -export interface SchemaProof { - type: string; - created: string; - verificationMethod: string; - proofPurpose: string; - proofValue: string; -} -export interface Schema { - type: string; - modelVersion: string; - id: string; - name: string; - author: string; - authored: string; - schema: SchemaProperty | undefined; - proof: SchemaProof | undefined; -} -export declare const SchemaDocument: { - encode(message: SchemaDocument, writer?: Writer): Writer; - decode(input: Reader | Uint8Array, length?: number): SchemaDocument; - fromJSON(object: any): SchemaDocument; - toJSON(message: SchemaDocument): unknown; - fromPartial(object: DeepPartial): SchemaDocument; -}; -export declare const SchemaProperty: { - encode(message: SchemaProperty, writer?: Writer): Writer; - decode(input: Reader | Uint8Array, length?: number): SchemaProperty; - fromJSON(object: any): SchemaProperty; - toJSON(message: SchemaProperty): unknown; - fromPartial(object: DeepPartial): SchemaProperty; -}; -export declare const SchemaProof: { - encode(message: SchemaProof, writer?: Writer): Writer; - decode(input: Reader | Uint8Array, length?: number): SchemaProof; - fromJSON(object: any): SchemaProof; - toJSON(message: SchemaProof): unknown; - fromPartial(object: DeepPartial): SchemaProof; -}; -export declare const Schema: { - encode(message: Schema, writer?: Writer): Writer; - decode(input: Reader | Uint8Array, length?: number): Schema; - fromJSON(object: any): Schema; - toJSON(message: Schema): unknown; - fromPartial(object: DeepPartial): Schema; -}; -type Builtin = Date | Function | Uint8Array | string | number | undefined; -export type DeepPartial = T extends Builtin ? T : T extends Array ? Array> : T extends ReadonlyArray ? ReadonlyArray> : T extends {} ? { - [K in keyof T]?: DeepPartial; -} : Partial; -export {}; -//# sourceMappingURL=schema.d.ts.map \ No newline at end of file diff --git a/build/libs/generated/ssi/schema.d.ts.map b/build/libs/generated/ssi/schema.d.ts.map deleted file mode 100644 index b8905ee..0000000 --- a/build/libs/generated/ssi/schema.d.ts.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../../../libs/generated/ssi/schema.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAEpD,eAAO,MAAM,eAAe,kCAAkC,CAAC;AAE/D,MAAM,WAAW,cAAc;IAC7B,IAAI,EAAE,MAAM,CAAC;IACb,YAAY,EAAE,MAAM,CAAC;IACrB,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,cAAc,GAAG,SAAS,CAAC;CACpC;AAED,MAAM,WAAW,cAAc;IAC7B,MAAM,EAAE,MAAM,CAAC;IACf,WAAW,EAAE,MAAM,CAAC;IACpB,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,EAAE,MAAM,CAAC;IACnB,QAAQ,EAAE,MAAM,EAAE,CAAC;IACnB,oBAAoB,EAAE,OAAO,CAAC;CAC/B;AAED,MAAM,WAAW,WAAW;IAC1B,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,kBAAkB,EAAE,MAAM,CAAC;IAC3B,YAAY,EAAE,MAAM,CAAC;IACrB,UAAU,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,MAAM;IACrB,IAAI,EAAE,MAAM,CAAC;IACb,YAAY,EAAE,MAAM,CAAC;IACrB,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,cAAc,GAAG,SAAS,CAAC;IACnC,KAAK,EAAE,WAAW,GAAG,SAAS,CAAC;CAChC;AAWD,eAAO,MAAM,cAAc;oBACT,cAAc,WAAU,MAAM,GAAqB,MAAM;kBAyB3D,MAAM,GAAG,UAAU,WAAW,MAAM,GAAG,cAAc;qBAoClD,GAAG,GAAG,cAAc;oBAwCrB,cAAc,GAAG,OAAO;wBAgBpB,YAAY,cAAc,CAAC,GAAG,cAAc;CAuCjE,CAAC;AAWF,eAAO,MAAM,cAAc;oBACT,cAAc,WAAU,MAAM,GAAqB,MAAM;kBAsB3D,MAAM,GAAG,UAAU,WAAW,MAAM,GAAG,cAAc;qBAkClD,GAAG,GAAG,cAAc;oBAuCrB,cAAc,GAAG,OAAO;wBAiBpB,YAAY,cAAc,CAAC,GAAG,cAAc;CAsCjE,CAAC;AAUF,eAAO,MAAM,WAAW;oBACN,WAAW,WAAU,MAAM,GAAqB,MAAM;kBAmBxD,MAAM,GAAG,UAAU,WAAW,MAAM,GAAG,WAAW;qBA8B/C,GAAG,GAAG,WAAW;oBAiClB,WAAW,GAAG,OAAO;wBAYjB,YAAY,WAAW,CAAC,GAAG,WAAW;CAgC3D,CAAC;AAWF,eAAO,MAAM,MAAM;oBACD,MAAM,WAAU,MAAM,GAAqB,MAAM;kBA4BnD,MAAM,GAAG,UAAU,WAAW,MAAM,GAAG,MAAM;qBAuC1C,GAAG,GAAG,MAAM;oBA6Cb,MAAM,GAAG,OAAO;wBAoBZ,YAAY,MAAM,CAAC,GAAG,MAAM;CA4CjD,CAAC;AAEF,KAAK,OAAO,GAAG,IAAI,GAAG,QAAQ,GAAG,UAAU,GAAG,MAAM,GAAG,MAAM,GAAG,SAAS,CAAC;AAC1E,MAAM,MAAM,WAAW,CAAC,CAAC,IAAI,CAAC,SAAS,OAAO,GAC1C,CAAC,GACD,CAAC,SAAS,KAAK,CAAC,MAAM,CAAC,CAAC,GACxB,KAAK,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,GACrB,CAAC,SAAS,aAAa,CAAC,MAAM,CAAC,CAAC,GAChC,aAAa,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,GAC7B,CAAC,SAAS,EAAE,GACZ;KAAG,CAAC,IAAI,MAAM,CAAC,CAAC,CAAC,EAAE,WAAW,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;CAAE,GACtC,OAAO,CAAC,CAAC,CAAC,CAAC"} \ No newline at end of file diff --git a/build/libs/generated/ssi/schema.js b/build/libs/generated/ssi/schema.js deleted file mode 100644 index fdbf2fe..0000000 --- a/build/libs/generated/ssi/schema.js +++ /dev/null @@ -1,680 +0,0 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.Schema = exports.SchemaProof = exports.SchemaProperty = exports.SchemaDocument = exports.protobufPackage = void 0; -/* eslint-disable */ -const minimal_1 = require("protobufjs/minimal"); -exports.protobufPackage = "hypersignprotocol.hidnode.ssi"; -const baseSchemaDocument = { - type: "", - modelVersion: "", - id: "", - name: "", - author: "", - authored: "", -}; -exports.SchemaDocument = { - encode(message, writer = minimal_1.Writer.create()) { - if (message.type !== "") { - writer.uint32(10).string(message.type); - } - if (message.modelVersion !== "") { - writer.uint32(18).string(message.modelVersion); - } - if (message.id !== "") { - writer.uint32(26).string(message.id); - } - if (message.name !== "") { - writer.uint32(34).string(message.name); - } - if (message.author !== "") { - writer.uint32(42).string(message.author); - } - if (message.authored !== "") { - writer.uint32(50).string(message.authored); - } - if (message.schema !== undefined) { - exports.SchemaProperty.encode(message.schema, writer.uint32(58).fork()).ldelim(); - } - return writer; - }, - decode(input, length) { - const reader = input instanceof Uint8Array ? new minimal_1.Reader(input) : input; - let end = length === undefined ? reader.len : reader.pos + length; - const message = Object.assign({}, baseSchemaDocument); - while (reader.pos < end) { - const tag = reader.uint32(); - switch (tag >>> 3) { - case 1: - message.type = reader.string(); - break; - case 2: - message.modelVersion = reader.string(); - break; - case 3: - message.id = reader.string(); - break; - case 4: - message.name = reader.string(); - break; - case 5: - message.author = reader.string(); - break; - case 6: - message.authored = reader.string(); - break; - case 7: - message.schema = exports.SchemaProperty.decode(reader, reader.uint32()); - break; - default: - reader.skipType(tag & 7); - break; - } - } - return message; - }, - fromJSON(object) { - const message = Object.assign({}, baseSchemaDocument); - if (object.type !== undefined && object.type !== null) { - message.type = String(object.type); - } - else { - message.type = ""; - } - if (object.modelVersion !== undefined && object.modelVersion !== null) { - message.modelVersion = String(object.modelVersion); - } - else { - message.modelVersion = ""; - } - if (object.id !== undefined && object.id !== null) { - message.id = String(object.id); - } - else { - message.id = ""; - } - if (object.name !== undefined && object.name !== null) { - message.name = String(object.name); - } - else { - message.name = ""; - } - if (object.author !== undefined && object.author !== null) { - message.author = String(object.author); - } - else { - message.author = ""; - } - if (object.authored !== undefined && object.authored !== null) { - message.authored = String(object.authored); - } - else { - message.authored = ""; - } - if (object.schema !== undefined && object.schema !== null) { - message.schema = exports.SchemaProperty.fromJSON(object.schema); - } - else { - message.schema = undefined; - } - return message; - }, - toJSON(message) { - const obj = {}; - message.type !== undefined && (obj.type = message.type); - message.modelVersion !== undefined && - (obj.modelVersion = message.modelVersion); - message.id !== undefined && (obj.id = message.id); - message.name !== undefined && (obj.name = message.name); - message.author !== undefined && (obj.author = message.author); - message.authored !== undefined && (obj.authored = message.authored); - message.schema !== undefined && - (obj.schema = message.schema - ? exports.SchemaProperty.toJSON(message.schema) - : undefined); - return obj; - }, - fromPartial(object) { - const message = Object.assign({}, baseSchemaDocument); - if (object.type !== undefined && object.type !== null) { - message.type = object.type; - } - else { - message.type = ""; - } - if (object.modelVersion !== undefined && object.modelVersion !== null) { - message.modelVersion = object.modelVersion; - } - else { - message.modelVersion = ""; - } - if (object.id !== undefined && object.id !== null) { - message.id = object.id; - } - else { - message.id = ""; - } - if (object.name !== undefined && object.name !== null) { - message.name = object.name; - } - else { - message.name = ""; - } - if (object.author !== undefined && object.author !== null) { - message.author = object.author; - } - else { - message.author = ""; - } - if (object.authored !== undefined && object.authored !== null) { - message.authored = object.authored; - } - else { - message.authored = ""; - } - if (object.schema !== undefined && object.schema !== null) { - message.schema = exports.SchemaProperty.fromPartial(object.schema); - } - else { - message.schema = undefined; - } - return message; - }, -}; -const baseSchemaProperty = { - schema: "", - description: "", - type: "", - properties: "", - required: "", - additionalProperties: false, -}; -exports.SchemaProperty = { - encode(message, writer = minimal_1.Writer.create()) { - if (message.schema !== "") { - writer.uint32(10).string(message.schema); - } - if (message.description !== "") { - writer.uint32(18).string(message.description); - } - if (message.type !== "") { - writer.uint32(26).string(message.type); - } - if (message.properties !== "") { - writer.uint32(34).string(message.properties); - } - for (const v of message.required) { - writer.uint32(42).string(v); - } - if (message.additionalProperties === true) { - writer.uint32(48).bool(message.additionalProperties); - } - return writer; - }, - decode(input, length) { - const reader = input instanceof Uint8Array ? new minimal_1.Reader(input) : input; - let end = length === undefined ? reader.len : reader.pos + length; - const message = Object.assign({}, baseSchemaProperty); - message.required = []; - while (reader.pos < end) { - const tag = reader.uint32(); - switch (tag >>> 3) { - case 1: - message.schema = reader.string(); - break; - case 2: - message.description = reader.string(); - break; - case 3: - message.type = reader.string(); - break; - case 4: - message.properties = reader.string(); - break; - case 5: - message.required.push(reader.string()); - break; - case 6: - message.additionalProperties = reader.bool(); - break; - default: - reader.skipType(tag & 7); - break; - } - } - return message; - }, - fromJSON(object) { - const message = Object.assign({}, baseSchemaProperty); - message.required = []; - if (object.schema !== undefined && object.schema !== null) { - message.schema = String(object.schema); - } - else { - message.schema = ""; - } - if (object.description !== undefined && object.description !== null) { - message.description = String(object.description); - } - else { - message.description = ""; - } - if (object.type !== undefined && object.type !== null) { - message.type = String(object.type); - } - else { - message.type = ""; - } - if (object.properties !== undefined && object.properties !== null) { - message.properties = String(object.properties); - } - else { - message.properties = ""; - } - if (object.required !== undefined && object.required !== null) { - for (const e of object.required) { - message.required.push(String(e)); - } - } - if (object.additionalProperties !== undefined && - object.additionalProperties !== null) { - message.additionalProperties = Boolean(object.additionalProperties); - } - else { - message.additionalProperties = false; - } - return message; - }, - toJSON(message) { - const obj = {}; - message.schema !== undefined && (obj.schema = message.schema); - message.description !== undefined && - (obj.description = message.description); - message.type !== undefined && (obj.type = message.type); - message.properties !== undefined && (obj.properties = message.properties); - if (message.required) { - obj.required = message.required.map((e) => e); - } - else { - obj.required = []; - } - message.additionalProperties !== undefined && - (obj.additionalProperties = message.additionalProperties); - return obj; - }, - fromPartial(object) { - const message = Object.assign({}, baseSchemaProperty); - message.required = []; - if (object.schema !== undefined && object.schema !== null) { - message.schema = object.schema; - } - else { - message.schema = ""; - } - if (object.description !== undefined && object.description !== null) { - message.description = object.description; - } - else { - message.description = ""; - } - if (object.type !== undefined && object.type !== null) { - message.type = object.type; - } - else { - message.type = ""; - } - if (object.properties !== undefined && object.properties !== null) { - message.properties = object.properties; - } - else { - message.properties = ""; - } - if (object.required !== undefined && object.required !== null) { - for (const e of object.required) { - message.required.push(e); - } - } - if (object.additionalProperties !== undefined && - object.additionalProperties !== null) { - message.additionalProperties = object.additionalProperties; - } - else { - message.additionalProperties = false; - } - return message; - }, -}; -const baseSchemaProof = { - type: "", - created: "", - verificationMethod: "", - proofPurpose: "", - proofValue: "", -}; -exports.SchemaProof = { - encode(message, writer = minimal_1.Writer.create()) { - if (message.type !== "") { - writer.uint32(10).string(message.type); - } - if (message.created !== "") { - writer.uint32(18).string(message.created); - } - if (message.verificationMethod !== "") { - writer.uint32(34).string(message.verificationMethod); - } - if (message.proofPurpose !== "") { - writer.uint32(42).string(message.proofPurpose); - } - if (message.proofValue !== "") { - writer.uint32(50).string(message.proofValue); - } - return writer; - }, - decode(input, length) { - const reader = input instanceof Uint8Array ? new minimal_1.Reader(input) : input; - let end = length === undefined ? reader.len : reader.pos + length; - const message = Object.assign({}, baseSchemaProof); - while (reader.pos < end) { - const tag = reader.uint32(); - switch (tag >>> 3) { - case 1: - message.type = reader.string(); - break; - case 2: - message.created = reader.string(); - break; - case 4: - message.verificationMethod = reader.string(); - break; - case 5: - message.proofPurpose = reader.string(); - break; - case 6: - message.proofValue = reader.string(); - break; - default: - reader.skipType(tag & 7); - break; - } - } - return message; - }, - fromJSON(object) { - const message = Object.assign({}, baseSchemaProof); - if (object.type !== undefined && object.type !== null) { - message.type = String(object.type); - } - else { - message.type = ""; - } - if (object.created !== undefined && object.created !== null) { - message.created = String(object.created); - } - else { - message.created = ""; - } - if (object.verificationMethod !== undefined && - object.verificationMethod !== null) { - message.verificationMethod = String(object.verificationMethod); - } - else { - message.verificationMethod = ""; - } - if (object.proofPurpose !== undefined && object.proofPurpose !== null) { - message.proofPurpose = String(object.proofPurpose); - } - else { - message.proofPurpose = ""; - } - if (object.proofValue !== undefined && object.proofValue !== null) { - message.proofValue = String(object.proofValue); - } - else { - message.proofValue = ""; - } - return message; - }, - toJSON(message) { - const obj = {}; - message.type !== undefined && (obj.type = message.type); - message.created !== undefined && (obj.created = message.created); - message.verificationMethod !== undefined && - (obj.verificationMethod = message.verificationMethod); - message.proofPurpose !== undefined && - (obj.proofPurpose = message.proofPurpose); - message.proofValue !== undefined && (obj.proofValue = message.proofValue); - return obj; - }, - fromPartial(object) { - const message = Object.assign({}, baseSchemaProof); - if (object.type !== undefined && object.type !== null) { - message.type = object.type; - } - else { - message.type = ""; - } - if (object.created !== undefined && object.created !== null) { - message.created = object.created; - } - else { - message.created = ""; - } - if (object.verificationMethod !== undefined && - object.verificationMethod !== null) { - message.verificationMethod = object.verificationMethod; - } - else { - message.verificationMethod = ""; - } - if (object.proofPurpose !== undefined && object.proofPurpose !== null) { - message.proofPurpose = object.proofPurpose; - } - else { - message.proofPurpose = ""; - } - if (object.proofValue !== undefined && object.proofValue !== null) { - message.proofValue = object.proofValue; - } - else { - message.proofValue = ""; - } - return message; - }, -}; -const baseSchema = { - type: "", - modelVersion: "", - id: "", - name: "", - author: "", - authored: "", -}; -exports.Schema = { - encode(message, writer = minimal_1.Writer.create()) { - if (message.type !== "") { - writer.uint32(10).string(message.type); - } - if (message.modelVersion !== "") { - writer.uint32(18).string(message.modelVersion); - } - if (message.id !== "") { - writer.uint32(26).string(message.id); - } - if (message.name !== "") { - writer.uint32(34).string(message.name); - } - if (message.author !== "") { - writer.uint32(42).string(message.author); - } - if (message.authored !== "") { - writer.uint32(50).string(message.authored); - } - if (message.schema !== undefined) { - exports.SchemaProperty.encode(message.schema, writer.uint32(58).fork()).ldelim(); - } - if (message.proof !== undefined) { - exports.SchemaProof.encode(message.proof, writer.uint32(66).fork()).ldelim(); - } - return writer; - }, - decode(input, length) { - const reader = input instanceof Uint8Array ? new minimal_1.Reader(input) : input; - let end = length === undefined ? reader.len : reader.pos + length; - const message = Object.assign({}, baseSchema); - while (reader.pos < end) { - const tag = reader.uint32(); - switch (tag >>> 3) { - case 1: - message.type = reader.string(); - break; - case 2: - message.modelVersion = reader.string(); - break; - case 3: - message.id = reader.string(); - break; - case 4: - message.name = reader.string(); - break; - case 5: - message.author = reader.string(); - break; - case 6: - message.authored = reader.string(); - break; - case 7: - message.schema = exports.SchemaProperty.decode(reader, reader.uint32()); - break; - case 8: - message.proof = exports.SchemaProof.decode(reader, reader.uint32()); - break; - default: - reader.skipType(tag & 7); - break; - } - } - return message; - }, - fromJSON(object) { - const message = Object.assign({}, baseSchema); - if (object.type !== undefined && object.type !== null) { - message.type = String(object.type); - } - else { - message.type = ""; - } - if (object.modelVersion !== undefined && object.modelVersion !== null) { - message.modelVersion = String(object.modelVersion); - } - else { - message.modelVersion = ""; - } - if (object.id !== undefined && object.id !== null) { - message.id = String(object.id); - } - else { - message.id = ""; - } - if (object.name !== undefined && object.name !== null) { - message.name = String(object.name); - } - else { - message.name = ""; - } - if (object.author !== undefined && object.author !== null) { - message.author = String(object.author); - } - else { - message.author = ""; - } - if (object.authored !== undefined && object.authored !== null) { - message.authored = String(object.authored); - } - else { - message.authored = ""; - } - if (object.schema !== undefined && object.schema !== null) { - message.schema = exports.SchemaProperty.fromJSON(object.schema); - } - else { - message.schema = undefined; - } - if (object.proof !== undefined && object.proof !== null) { - message.proof = exports.SchemaProof.fromJSON(object.proof); - } - else { - message.proof = undefined; - } - return message; - }, - toJSON(message) { - const obj = {}; - message.type !== undefined && (obj.type = message.type); - message.modelVersion !== undefined && - (obj.modelVersion = message.modelVersion); - message.id !== undefined && (obj.id = message.id); - message.name !== undefined && (obj.name = message.name); - message.author !== undefined && (obj.author = message.author); - message.authored !== undefined && (obj.authored = message.authored); - message.schema !== undefined && - (obj.schema = message.schema - ? exports.SchemaProperty.toJSON(message.schema) - : undefined); - message.proof !== undefined && - (obj.proof = message.proof - ? exports.SchemaProof.toJSON(message.proof) - : undefined); - return obj; - }, - fromPartial(object) { - const message = Object.assign({}, baseSchema); - if (object.type !== undefined && object.type !== null) { - message.type = object.type; - } - else { - message.type = ""; - } - if (object.modelVersion !== undefined && object.modelVersion !== null) { - message.modelVersion = object.modelVersion; - } - else { - message.modelVersion = ""; - } - if (object.id !== undefined && object.id !== null) { - message.id = object.id; - } - else { - message.id = ""; - } - if (object.name !== undefined && object.name !== null) { - message.name = object.name; - } - else { - message.name = ""; - } - if (object.author !== undefined && object.author !== null) { - message.author = object.author; - } - else { - message.author = ""; - } - if (object.authored !== undefined && object.authored !== null) { - message.authored = object.authored; - } - else { - message.authored = ""; - } - if (object.schema !== undefined && object.schema !== null) { - message.schema = exports.SchemaProperty.fromPartial(object.schema); - } - else { - message.schema = undefined; - } - if (object.proof !== undefined && object.proof !== null) { - message.proof = exports.SchemaProof.fromPartial(object.proof); - } - else { - message.proof = undefined; - } - return message; - }, -}; diff --git a/build/libs/generated/ssi/tx.d.ts b/build/libs/generated/ssi/tx.d.ts index 25a262c..7859e3f 100644 --- a/build/libs/generated/ssi/tx.d.ts +++ b/build/libs/generated/ssi/tx.d.ts @@ -1,146 +1,1418 @@ -import { Reader, Writer } from "protobufjs/minimal"; -import { Did, SignInfo } from "./did"; -import { SchemaDocument, SchemaProof } from "./schema"; -import { ClientSpec } from "./clientSpec"; -import { CredentialStatus, CredentialProof } from "./credential"; -export declare const protobufPackage = "hypersignprotocol.hidnode.ssi"; -export interface MsgCreateDID { - didDocString: Did | undefined; - signatures: SignInfo[]; - creator: string; -} -export interface MsgCreateDIDResponse { - id: number; +import _m0 from "protobufjs/minimal"; +import { CredentialSchemaDocument } from "./credential_schema"; +import { CredentialStatusDocument } from "./credential_status"; +import { DidDocument } from "./did"; +import { DocumentProof } from "./proof"; +export declare const protobufPackage = "hypersign.ssi.v1"; +export interface MsgRegisterDID { + didDocument?: DidDocument | undefined; + didDocumentProofs?: DocumentProof[] | undefined; + txAuthor?: string | undefined; +} +export interface MsgRegisterDIDResponse { } export interface MsgUpdateDID { - didDocString: Did | undefined; - version_id: string; - signatures: SignInfo[]; - creator: string; + didDocument?: DidDocument | undefined; + didDocumentProofs?: DocumentProof[] | undefined; + versionId?: string | undefined; + txAuthor?: string | undefined; } export interface MsgUpdateDIDResponse { - updateId: string; -} -export interface MsgCreateSchema { - creator: string; - schemaDoc: SchemaDocument | undefined; - schemaProof: SchemaProof | undefined; - clientSpec: ClientSpec | undefined; -} -export interface MsgCreateSchemaResponse { - id: number; } export interface MsgDeactivateDID { - creator: string; - didId: string; - version_id: string; - signatures: SignInfo[]; + didDocumentId?: string | undefined; + didDocumentProofs?: DocumentProof[] | undefined; + versionId?: string | undefined; + txAuthor?: string | undefined; } export interface MsgDeactivateDIDResponse { - id: number; +} +export interface MsgRegisterCredentialSchema { + credentialSchemaDocument?: CredentialSchemaDocument | undefined; + credentialSchemaProof?: DocumentProof | undefined; + txAuthor?: string | undefined; +} +export interface MsgRegisterCredentialSchemaResponse { +} +export interface MsgUpdateCredentialSchema { + credentialSchemaDocument?: CredentialSchemaDocument | undefined; + credentialSchemaProof?: DocumentProof | undefined; + txAuthor?: string | undefined; +} +export interface MsgUpdateCredentialSchemaResponse { } export interface MsgRegisterCredentialStatus { - creator: string; - credentialStatus: CredentialStatus | undefined; - proof: CredentialProof | undefined; - clientSpec: ClientSpec | undefined; + credentialStatusDocument?: CredentialStatusDocument | undefined; + credentialStatusProof?: DocumentProof | undefined; + txAuthor?: string | undefined; } export interface MsgRegisterCredentialStatusResponse { - id: number; -} -export declare const MsgCreateDID: { - encode(message: MsgCreateDID, writer?: Writer): Writer; - decode(input: Reader | Uint8Array, length?: number): MsgCreateDID; - fromJSON(object: any): MsgCreateDID; - toJSON(message: MsgCreateDID): unknown; - fromPartial(object: DeepPartial): MsgCreateDID; +} +export interface MsgUpdateCredentialStatus { + credentialStatusDocument?: CredentialStatusDocument | undefined; + credentialStatusProof?: DocumentProof | undefined; + txAuthor?: string | undefined; +} +export interface MsgUpdateCredentialStatusResponse { +} +export declare const MsgRegisterDID: { + encode(message: MsgRegisterDID, writer?: _m0.Writer): _m0.Writer; + decode(input: _m0.Reader | Uint8Array, length?: number): MsgRegisterDID; + fromJSON(object: any): MsgRegisterDID; + toJSON(message: MsgRegisterDID): unknown; + create]: never; }) | undefined; + id?: string | undefined; + controller?: (string[] & string[] & { [K_1 in Exclude]: never; }) | undefined; + alsoKnownAs?: (string[] & string[] & { [K_2 in Exclude]: never; }) | undefined; + verificationMethod?: ({ + id?: string | undefined; + type?: string | undefined; + controller?: string | undefined; + publicKeyMultibase?: string | undefined; + blockchainAccountId?: string | undefined; + }[] & ({ + id?: string | undefined; + type?: string | undefined; + controller?: string | undefined; + publicKeyMultibase?: string | undefined; + blockchainAccountId?: string | undefined; + } & { + id?: string | undefined; + type?: string | undefined; + controller?: string | undefined; + publicKeyMultibase?: string | undefined; + blockchainAccountId?: string | undefined; + } & { [K_3 in Exclude]: never; })[] & { [K_4 in Exclude]: never; }) | undefined; + authentication?: (string[] & string[] & { [K_5 in Exclude]: never; }) | undefined; + assertionMethod?: (string[] & string[] & { [K_6 in Exclude]: never; }) | undefined; + keyAgreement?: (string[] & string[] & { [K_7 in Exclude]: never; }) | undefined; + capabilityInvocation?: (string[] & string[] & { [K_8 in Exclude]: never; }) | undefined; + capabilityDelegation?: (string[] & string[] & { [K_9 in Exclude]: never; }) | undefined; + service?: ({ + id?: string | undefined; + type?: string | undefined; + serviceEndpoint?: string | undefined; + }[] & ({ + id?: string | undefined; + type?: string | undefined; + serviceEndpoint?: string | undefined; + } & { + id?: string | undefined; + type?: string | undefined; + serviceEndpoint?: string | undefined; + } & { [K_10 in Exclude]: never; })[] & { [K_11 in Exclude]: never; }) | undefined; + } & { [K_12 in Exclude]: never; }) | undefined; + didDocumentProofs?: ({ + type?: string | undefined; + created?: string | undefined; + verificationMethod?: string | undefined; + proofPurpose?: string | undefined; + proofValue?: string | undefined; + clientSpecType?: import("./client_spec").ClientSpecType | undefined; + }[] & ({ + type?: string | undefined; + created?: string | undefined; + verificationMethod?: string | undefined; + proofPurpose?: string | undefined; + proofValue?: string | undefined; + clientSpecType?: import("./client_spec").ClientSpecType | undefined; + } & { + type?: string | undefined; + created?: string | undefined; + verificationMethod?: string | undefined; + proofPurpose?: string | undefined; + proofValue?: string | undefined; + clientSpecType?: import("./client_spec").ClientSpecType | undefined; + } & { [K_13 in Exclude]: never; })[] & { [K_14 in Exclude]: never; }) | undefined; + txAuthor?: string | undefined; + } & { [K_15 in Exclude]: never; }>(base?: I | undefined): MsgRegisterDID; + fromPartial]: never; }) | undefined; + id?: string | undefined; + controller?: (string[] & string[] & { [K_17 in Exclude]: never; }) | undefined; + alsoKnownAs?: (string[] & string[] & { [K_18 in Exclude]: never; }) | undefined; + verificationMethod?: ({ + id?: string | undefined; + type?: string | undefined; + controller?: string | undefined; + publicKeyMultibase?: string | undefined; + blockchainAccountId?: string | undefined; + }[] & ({ + id?: string | undefined; + type?: string | undefined; + controller?: string | undefined; + publicKeyMultibase?: string | undefined; + blockchainAccountId?: string | undefined; + } & { + id?: string | undefined; + type?: string | undefined; + controller?: string | undefined; + publicKeyMultibase?: string | undefined; + blockchainAccountId?: string | undefined; + } & { [K_19 in Exclude]: never; })[] & { [K_20 in Exclude]: never; }) | undefined; + authentication?: (string[] & string[] & { [K_21 in Exclude]: never; }) | undefined; + assertionMethod?: (string[] & string[] & { [K_22 in Exclude]: never; }) | undefined; + keyAgreement?: (string[] & string[] & { [K_23 in Exclude]: never; }) | undefined; + capabilityInvocation?: (string[] & string[] & { [K_24 in Exclude]: never; }) | undefined; + capabilityDelegation?: (string[] & string[] & { [K_25 in Exclude]: never; }) | undefined; + service?: ({ + id?: string | undefined; + type?: string | undefined; + serviceEndpoint?: string | undefined; + }[] & ({ + id?: string | undefined; + type?: string | undefined; + serviceEndpoint?: string | undefined; + } & { + id?: string | undefined; + type?: string | undefined; + serviceEndpoint?: string | undefined; + } & { [K_26 in Exclude]: never; })[] & { [K_27 in Exclude]: never; }) | undefined; + } & { [K_28 in Exclude]: never; }) | undefined; + didDocumentProofs?: ({ + type?: string | undefined; + created?: string | undefined; + verificationMethod?: string | undefined; + proofPurpose?: string | undefined; + proofValue?: string | undefined; + clientSpecType?: import("./client_spec").ClientSpecType | undefined; + }[] & ({ + type?: string | undefined; + created?: string | undefined; + verificationMethod?: string | undefined; + proofPurpose?: string | undefined; + proofValue?: string | undefined; + clientSpecType?: import("./client_spec").ClientSpecType | undefined; + } & { + type?: string | undefined; + created?: string | undefined; + verificationMethod?: string | undefined; + proofPurpose?: string | undefined; + proofValue?: string | undefined; + clientSpecType?: import("./client_spec").ClientSpecType | undefined; + } & { [K_29 in Exclude]: never; })[] & { [K_30 in Exclude]: never; }) | undefined; + txAuthor?: string | undefined; + } & { [K_31 in Exclude]: never; }>(object: I_1): MsgRegisterDID; }; -export declare const MsgCreateDIDResponse: { - encode(message: MsgCreateDIDResponse, writer?: Writer): Writer; - decode(input: Reader | Uint8Array, length?: number): MsgCreateDIDResponse; - fromJSON(object: any): MsgCreateDIDResponse; - toJSON(message: MsgCreateDIDResponse): unknown; - fromPartial(object: DeepPartial): MsgCreateDIDResponse; +export declare const MsgRegisterDIDResponse: { + encode(_: MsgRegisterDIDResponse, writer?: _m0.Writer): _m0.Writer; + decode(input: _m0.Reader | Uint8Array, length?: number): MsgRegisterDIDResponse; + fromJSON(_: any): MsgRegisterDIDResponse; + toJSON(_: MsgRegisterDIDResponse): unknown; + create]: never; }>(base?: I | undefined): MsgRegisterDIDResponse; + fromPartial]: never; }>(_: I_1): MsgRegisterDIDResponse; }; export declare const MsgUpdateDID: { - encode(message: MsgUpdateDID, writer?: Writer): Writer; - decode(input: Reader | Uint8Array, length?: number): MsgUpdateDID; + encode(message: MsgUpdateDID, writer?: _m0.Writer): _m0.Writer; + decode(input: _m0.Reader | Uint8Array, length?: number): MsgUpdateDID; fromJSON(object: any): MsgUpdateDID; toJSON(message: MsgUpdateDID): unknown; - fromPartial(object: DeepPartial): MsgUpdateDID; + create]: never; }) | undefined; + id?: string | undefined; + controller?: (string[] & string[] & { [K_1 in Exclude]: never; }) | undefined; + alsoKnownAs?: (string[] & string[] & { [K_2 in Exclude]: never; }) | undefined; + verificationMethod?: ({ + id?: string | undefined; + type?: string | undefined; + controller?: string | undefined; + publicKeyMultibase?: string | undefined; + blockchainAccountId?: string | undefined; + }[] & ({ + id?: string | undefined; + type?: string | undefined; + controller?: string | undefined; + publicKeyMultibase?: string | undefined; + blockchainAccountId?: string | undefined; + } & { + id?: string | undefined; + type?: string | undefined; + controller?: string | undefined; + publicKeyMultibase?: string | undefined; + blockchainAccountId?: string | undefined; + } & { [K_3 in Exclude]: never; })[] & { [K_4 in Exclude]: never; }) | undefined; + authentication?: (string[] & string[] & { [K_5 in Exclude]: never; }) | undefined; + assertionMethod?: (string[] & string[] & { [K_6 in Exclude]: never; }) | undefined; + keyAgreement?: (string[] & string[] & { [K_7 in Exclude]: never; }) | undefined; + capabilityInvocation?: (string[] & string[] & { [K_8 in Exclude]: never; }) | undefined; + capabilityDelegation?: (string[] & string[] & { [K_9 in Exclude]: never; }) | undefined; + service?: ({ + id?: string | undefined; + type?: string | undefined; + serviceEndpoint?: string | undefined; + }[] & ({ + id?: string | undefined; + type?: string | undefined; + serviceEndpoint?: string | undefined; + } & { + id?: string | undefined; + type?: string | undefined; + serviceEndpoint?: string | undefined; + } & { [K_10 in Exclude]: never; })[] & { [K_11 in Exclude]: never; }) | undefined; + } & { [K_12 in Exclude]: never; }) | undefined; + didDocumentProofs?: ({ + type?: string | undefined; + created?: string | undefined; + verificationMethod?: string | undefined; + proofPurpose?: string | undefined; + proofValue?: string | undefined; + clientSpecType?: import("./client_spec").ClientSpecType | undefined; + }[] & ({ + type?: string | undefined; + created?: string | undefined; + verificationMethod?: string | undefined; + proofPurpose?: string | undefined; + proofValue?: string | undefined; + clientSpecType?: import("./client_spec").ClientSpecType | undefined; + } & { + type?: string | undefined; + created?: string | undefined; + verificationMethod?: string | undefined; + proofPurpose?: string | undefined; + proofValue?: string | undefined; + clientSpecType?: import("./client_spec").ClientSpecType | undefined; + } & { [K_13 in Exclude]: never; })[] & { [K_14 in Exclude]: never; }) | undefined; + versionId?: string | undefined; + txAuthor?: string | undefined; + } & { [K_15 in Exclude]: never; }>(base?: I | undefined): MsgUpdateDID; + fromPartial]: never; }) | undefined; + id?: string | undefined; + controller?: (string[] & string[] & { [K_17 in Exclude]: never; }) | undefined; + alsoKnownAs?: (string[] & string[] & { [K_18 in Exclude]: never; }) | undefined; + verificationMethod?: ({ + id?: string | undefined; + type?: string | undefined; + controller?: string | undefined; + publicKeyMultibase?: string | undefined; + blockchainAccountId?: string | undefined; + }[] & ({ + id?: string | undefined; + type?: string | undefined; + controller?: string | undefined; + publicKeyMultibase?: string | undefined; + blockchainAccountId?: string | undefined; + } & { + id?: string | undefined; + type?: string | undefined; + controller?: string | undefined; + publicKeyMultibase?: string | undefined; + blockchainAccountId?: string | undefined; + } & { [K_19 in Exclude]: never; })[] & { [K_20 in Exclude]: never; }) | undefined; + authentication?: (string[] & string[] & { [K_21 in Exclude]: never; }) | undefined; + assertionMethod?: (string[] & string[] & { [K_22 in Exclude]: never; }) | undefined; + keyAgreement?: (string[] & string[] & { [K_23 in Exclude]: never; }) | undefined; + capabilityInvocation?: (string[] & string[] & { [K_24 in Exclude]: never; }) | undefined; + capabilityDelegation?: (string[] & string[] & { [K_25 in Exclude]: never; }) | undefined; + service?: ({ + id?: string | undefined; + type?: string | undefined; + serviceEndpoint?: string | undefined; + }[] & ({ + id?: string | undefined; + type?: string | undefined; + serviceEndpoint?: string | undefined; + } & { + id?: string | undefined; + type?: string | undefined; + serviceEndpoint?: string | undefined; + } & { [K_26 in Exclude]: never; })[] & { [K_27 in Exclude]: never; }) | undefined; + } & { [K_28 in Exclude]: never; }) | undefined; + didDocumentProofs?: ({ + type?: string | undefined; + created?: string | undefined; + verificationMethod?: string | undefined; + proofPurpose?: string | undefined; + proofValue?: string | undefined; + clientSpecType?: import("./client_spec").ClientSpecType | undefined; + }[] & ({ + type?: string | undefined; + created?: string | undefined; + verificationMethod?: string | undefined; + proofPurpose?: string | undefined; + proofValue?: string | undefined; + clientSpecType?: import("./client_spec").ClientSpecType | undefined; + } & { + type?: string | undefined; + created?: string | undefined; + verificationMethod?: string | undefined; + proofPurpose?: string | undefined; + proofValue?: string | undefined; + clientSpecType?: import("./client_spec").ClientSpecType | undefined; + } & { [K_29 in Exclude]: never; })[] & { [K_30 in Exclude]: never; }) | undefined; + versionId?: string | undefined; + txAuthor?: string | undefined; + } & { [K_31 in Exclude]: never; }>(object: I_1): MsgUpdateDID; }; export declare const MsgUpdateDIDResponse: { - encode(message: MsgUpdateDIDResponse, writer?: Writer): Writer; - decode(input: Reader | Uint8Array, length?: number): MsgUpdateDIDResponse; - fromJSON(object: any): MsgUpdateDIDResponse; - toJSON(message: MsgUpdateDIDResponse): unknown; - fromPartial(object: DeepPartial): MsgUpdateDIDResponse; -}; -export declare const MsgCreateSchema: { - encode(message: MsgCreateSchema, writer?: Writer): Writer; - decode(input: Reader | Uint8Array, length?: number): MsgCreateSchema; - fromJSON(object: any): MsgCreateSchema; - toJSON(message: MsgCreateSchema): unknown; - fromPartial(object: DeepPartial): MsgCreateSchema; -}; -export declare const MsgCreateSchemaResponse: { - encode(message: MsgCreateSchemaResponse, writer?: Writer): Writer; - decode(input: Reader | Uint8Array, length?: number): MsgCreateSchemaResponse; - fromJSON(object: any): MsgCreateSchemaResponse; - toJSON(message: MsgCreateSchemaResponse): unknown; - fromPartial(object: DeepPartial): MsgCreateSchemaResponse; + encode(_: MsgUpdateDIDResponse, writer?: _m0.Writer): _m0.Writer; + decode(input: _m0.Reader | Uint8Array, length?: number): MsgUpdateDIDResponse; + fromJSON(_: any): MsgUpdateDIDResponse; + toJSON(_: MsgUpdateDIDResponse): unknown; + create]: never; }>(base?: I | undefined): MsgUpdateDIDResponse; + fromPartial]: never; }>(_: I_1): MsgUpdateDIDResponse; }; export declare const MsgDeactivateDID: { - encode(message: MsgDeactivateDID, writer?: Writer): Writer; - decode(input: Reader | Uint8Array, length?: number): MsgDeactivateDID; + encode(message: MsgDeactivateDID, writer?: _m0.Writer): _m0.Writer; + decode(input: _m0.Reader | Uint8Array, length?: number): MsgDeactivateDID; fromJSON(object: any): MsgDeactivateDID; toJSON(message: MsgDeactivateDID): unknown; - fromPartial(object: DeepPartial): MsgDeactivateDID; + create]: never; })[] & { [K_1 in Exclude]: never; }) | undefined; + versionId?: string | undefined; + txAuthor?: string | undefined; + } & { [K_2 in Exclude]: never; }>(base?: I | undefined): MsgDeactivateDID; + fromPartial]: never; })[] & { [K_4 in Exclude]: never; }) | undefined; + versionId?: string | undefined; + txAuthor?: string | undefined; + } & { [K_5 in Exclude]: never; }>(object: I_1): MsgDeactivateDID; }; export declare const MsgDeactivateDIDResponse: { - encode(message: MsgDeactivateDIDResponse, writer?: Writer): Writer; - decode(input: Reader | Uint8Array, length?: number): MsgDeactivateDIDResponse; - fromJSON(object: any): MsgDeactivateDIDResponse; - toJSON(message: MsgDeactivateDIDResponse): unknown; - fromPartial(object: DeepPartial): MsgDeactivateDIDResponse; + encode(_: MsgDeactivateDIDResponse, writer?: _m0.Writer): _m0.Writer; + decode(input: _m0.Reader | Uint8Array, length?: number): MsgDeactivateDIDResponse; + fromJSON(_: any): MsgDeactivateDIDResponse; + toJSON(_: MsgDeactivateDIDResponse): unknown; + create]: never; }>(base?: I | undefined): MsgDeactivateDIDResponse; + fromPartial]: never; }>(_: I_1): MsgDeactivateDIDResponse; +}; +export declare const MsgRegisterCredentialSchema: { + encode(message: MsgRegisterCredentialSchema, writer?: _m0.Writer): _m0.Writer; + decode(input: _m0.Reader | Uint8Array, length?: number): MsgRegisterCredentialSchema; + fromJSON(object: any): MsgRegisterCredentialSchema; + toJSON(message: MsgRegisterCredentialSchema): unknown; + create]: never; }) | undefined; + type?: string | undefined; + modelVersion?: string | undefined; + id?: string | undefined; + name?: string | undefined; + author?: string | undefined; + authored?: string | undefined; + schema?: ({ + schema?: string | undefined; + description?: string | undefined; + type?: string | undefined; + properties?: string | undefined; + required?: string[] | undefined; + additionalProperties?: boolean | undefined; + } & { + schema?: string | undefined; + description?: string | undefined; + type?: string | undefined; + properties?: string | undefined; + required?: (string[] & string[] & { [K_1 in Exclude]: never; }) | undefined; + additionalProperties?: boolean | undefined; + } & { [K_2 in Exclude]: never; }) | undefined; + } & { [K_3 in Exclude]: never; }) | undefined; + credentialSchemaProof?: ({ + type?: string | undefined; + created?: string | undefined; + verificationMethod?: string | undefined; + proofPurpose?: string | undefined; + proofValue?: string | undefined; + clientSpecType?: import("./client_spec").ClientSpecType | undefined; + } & { + type?: string | undefined; + created?: string | undefined; + verificationMethod?: string | undefined; + proofPurpose?: string | undefined; + proofValue?: string | undefined; + clientSpecType?: import("./client_spec").ClientSpecType | undefined; + } & { [K_4 in Exclude]: never; }) | undefined; + txAuthor?: string | undefined; + } & { [K_5 in Exclude]: never; }>(base?: I | undefined): MsgRegisterCredentialSchema; + fromPartial]: never; }) | undefined; + type?: string | undefined; + modelVersion?: string | undefined; + id?: string | undefined; + name?: string | undefined; + author?: string | undefined; + authored?: string | undefined; + schema?: ({ + schema?: string | undefined; + description?: string | undefined; + type?: string | undefined; + properties?: string | undefined; + required?: string[] | undefined; + additionalProperties?: boolean | undefined; + } & { + schema?: string | undefined; + description?: string | undefined; + type?: string | undefined; + properties?: string | undefined; + required?: (string[] & string[] & { [K_7 in Exclude]: never; }) | undefined; + additionalProperties?: boolean | undefined; + } & { [K_8 in Exclude]: never; }) | undefined; + } & { [K_9 in Exclude]: never; }) | undefined; + credentialSchemaProof?: ({ + type?: string | undefined; + created?: string | undefined; + verificationMethod?: string | undefined; + proofPurpose?: string | undefined; + proofValue?: string | undefined; + clientSpecType?: import("./client_spec").ClientSpecType | undefined; + } & { + type?: string | undefined; + created?: string | undefined; + verificationMethod?: string | undefined; + proofPurpose?: string | undefined; + proofValue?: string | undefined; + clientSpecType?: import("./client_spec").ClientSpecType | undefined; + } & { [K_10 in Exclude]: never; }) | undefined; + txAuthor?: string | undefined; + } & { [K_11 in Exclude]: never; }>(object: I_1): MsgRegisterCredentialSchema; +}; +export declare const MsgRegisterCredentialSchemaResponse: { + encode(_: MsgRegisterCredentialSchemaResponse, writer?: _m0.Writer): _m0.Writer; + decode(input: _m0.Reader | Uint8Array, length?: number): MsgRegisterCredentialSchemaResponse; + fromJSON(_: any): MsgRegisterCredentialSchemaResponse; + toJSON(_: MsgRegisterCredentialSchemaResponse): unknown; + create]: never; }>(base?: I | undefined): MsgRegisterCredentialSchemaResponse; + fromPartial]: never; }>(_: I_1): MsgRegisterCredentialSchemaResponse; +}; +export declare const MsgUpdateCredentialSchema: { + encode(message: MsgUpdateCredentialSchema, writer?: _m0.Writer): _m0.Writer; + decode(input: _m0.Reader | Uint8Array, length?: number): MsgUpdateCredentialSchema; + fromJSON(object: any): MsgUpdateCredentialSchema; + toJSON(message: MsgUpdateCredentialSchema): unknown; + create]: never; }) | undefined; + type?: string | undefined; + modelVersion?: string | undefined; + id?: string | undefined; + name?: string | undefined; + author?: string | undefined; + authored?: string | undefined; + schema?: ({ + schema?: string | undefined; + description?: string | undefined; + type?: string | undefined; + properties?: string | undefined; + required?: string[] | undefined; + additionalProperties?: boolean | undefined; + } & { + schema?: string | undefined; + description?: string | undefined; + type?: string | undefined; + properties?: string | undefined; + required?: (string[] & string[] & { [K_1 in Exclude]: never; }) | undefined; + additionalProperties?: boolean | undefined; + } & { [K_2 in Exclude]: never; }) | undefined; + } & { [K_3 in Exclude]: never; }) | undefined; + credentialSchemaProof?: ({ + type?: string | undefined; + created?: string | undefined; + verificationMethod?: string | undefined; + proofPurpose?: string | undefined; + proofValue?: string | undefined; + clientSpecType?: import("./client_spec").ClientSpecType | undefined; + } & { + type?: string | undefined; + created?: string | undefined; + verificationMethod?: string | undefined; + proofPurpose?: string | undefined; + proofValue?: string | undefined; + clientSpecType?: import("./client_spec").ClientSpecType | undefined; + } & { [K_4 in Exclude]: never; }) | undefined; + txAuthor?: string | undefined; + } & { [K_5 in Exclude]: never; }>(base?: I | undefined): MsgUpdateCredentialSchema; + fromPartial]: never; }) | undefined; + type?: string | undefined; + modelVersion?: string | undefined; + id?: string | undefined; + name?: string | undefined; + author?: string | undefined; + authored?: string | undefined; + schema?: ({ + schema?: string | undefined; + description?: string | undefined; + type?: string | undefined; + properties?: string | undefined; + required?: string[] | undefined; + additionalProperties?: boolean | undefined; + } & { + schema?: string | undefined; + description?: string | undefined; + type?: string | undefined; + properties?: string | undefined; + required?: (string[] & string[] & { [K_7 in Exclude]: never; }) | undefined; + additionalProperties?: boolean | undefined; + } & { [K_8 in Exclude]: never; }) | undefined; + } & { [K_9 in Exclude]: never; }) | undefined; + credentialSchemaProof?: ({ + type?: string | undefined; + created?: string | undefined; + verificationMethod?: string | undefined; + proofPurpose?: string | undefined; + proofValue?: string | undefined; + clientSpecType?: import("./client_spec").ClientSpecType | undefined; + } & { + type?: string | undefined; + created?: string | undefined; + verificationMethod?: string | undefined; + proofPurpose?: string | undefined; + proofValue?: string | undefined; + clientSpecType?: import("./client_spec").ClientSpecType | undefined; + } & { [K_10 in Exclude]: never; }) | undefined; + txAuthor?: string | undefined; + } & { [K_11 in Exclude]: never; }>(object: I_1): MsgUpdateCredentialSchema; +}; +export declare const MsgUpdateCredentialSchemaResponse: { + encode(_: MsgUpdateCredentialSchemaResponse, writer?: _m0.Writer): _m0.Writer; + decode(input: _m0.Reader | Uint8Array, length?: number): MsgUpdateCredentialSchemaResponse; + fromJSON(_: any): MsgUpdateCredentialSchemaResponse; + toJSON(_: MsgUpdateCredentialSchemaResponse): unknown; + create]: never; }>(base?: I | undefined): MsgUpdateCredentialSchemaResponse; + fromPartial]: never; }>(_: I_1): MsgUpdateCredentialSchemaResponse; }; export declare const MsgRegisterCredentialStatus: { - encode(message: MsgRegisterCredentialStatus, writer?: Writer): Writer; - decode(input: Reader | Uint8Array, length?: number): MsgRegisterCredentialStatus; + encode(message: MsgRegisterCredentialStatus, writer?: _m0.Writer): _m0.Writer; + decode(input: _m0.Reader | Uint8Array, length?: number): MsgRegisterCredentialStatus; fromJSON(object: any): MsgRegisterCredentialStatus; toJSON(message: MsgRegisterCredentialStatus): unknown; - fromPartial(object: DeepPartial): MsgRegisterCredentialStatus; + create]: never; }) | undefined; + id?: string | undefined; + revoked?: boolean | undefined; + suspended?: boolean | undefined; + remarks?: string | undefined; + issuer?: string | undefined; + issuanceDate?: string | undefined; + credentialMerkleRootHash?: string | undefined; + } & { [K_1 in Exclude]: never; }) | undefined; + credentialStatusProof?: ({ + type?: string | undefined; + created?: string | undefined; + verificationMethod?: string | undefined; + proofPurpose?: string | undefined; + proofValue?: string | undefined; + clientSpecType?: import("./client_spec").ClientSpecType | undefined; + } & { + type?: string | undefined; + created?: string | undefined; + verificationMethod?: string | undefined; + proofPurpose?: string | undefined; + proofValue?: string | undefined; + clientSpecType?: import("./client_spec").ClientSpecType | undefined; + } & { [K_2 in Exclude]: never; }) | undefined; + txAuthor?: string | undefined; + } & { [K_3 in Exclude]: never; }>(base?: I | undefined): MsgRegisterCredentialStatus; + fromPartial]: never; }) | undefined; + id?: string | undefined; + revoked?: boolean | undefined; + suspended?: boolean | undefined; + remarks?: string | undefined; + issuer?: string | undefined; + issuanceDate?: string | undefined; + credentialMerkleRootHash?: string | undefined; + } & { [K_5 in Exclude]: never; }) | undefined; + credentialStatusProof?: ({ + type?: string | undefined; + created?: string | undefined; + verificationMethod?: string | undefined; + proofPurpose?: string | undefined; + proofValue?: string | undefined; + clientSpecType?: import("./client_spec").ClientSpecType | undefined; + } & { + type?: string | undefined; + created?: string | undefined; + verificationMethod?: string | undefined; + proofPurpose?: string | undefined; + proofValue?: string | undefined; + clientSpecType?: import("./client_spec").ClientSpecType | undefined; + } & { [K_6 in Exclude]: never; }) | undefined; + txAuthor?: string | undefined; + } & { [K_7 in Exclude]: never; }>(object: I_1): MsgRegisterCredentialStatus; }; export declare const MsgRegisterCredentialStatusResponse: { - encode(message: MsgRegisterCredentialStatusResponse, writer?: Writer): Writer; - decode(input: Reader | Uint8Array, length?: number): MsgRegisterCredentialStatusResponse; - fromJSON(object: any): MsgRegisterCredentialStatusResponse; - toJSON(message: MsgRegisterCredentialStatusResponse): unknown; - fromPartial(object: DeepPartial): MsgRegisterCredentialStatusResponse; + encode(_: MsgRegisterCredentialStatusResponse, writer?: _m0.Writer): _m0.Writer; + decode(input: _m0.Reader | Uint8Array, length?: number): MsgRegisterCredentialStatusResponse; + fromJSON(_: any): MsgRegisterCredentialStatusResponse; + toJSON(_: MsgRegisterCredentialStatusResponse): unknown; + create]: never; }>(base?: I | undefined): MsgRegisterCredentialStatusResponse; + fromPartial]: never; }>(_: I_1): MsgRegisterCredentialStatusResponse; +}; +export declare const MsgUpdateCredentialStatus: { + encode(message: MsgUpdateCredentialStatus, writer?: _m0.Writer): _m0.Writer; + decode(input: _m0.Reader | Uint8Array, length?: number): MsgUpdateCredentialStatus; + fromJSON(object: any): MsgUpdateCredentialStatus; + toJSON(message: MsgUpdateCredentialStatus): unknown; + create]: never; }) | undefined; + id?: string | undefined; + revoked?: boolean | undefined; + suspended?: boolean | undefined; + remarks?: string | undefined; + issuer?: string | undefined; + issuanceDate?: string | undefined; + credentialMerkleRootHash?: string | undefined; + } & { [K_1 in Exclude]: never; }) | undefined; + credentialStatusProof?: ({ + type?: string | undefined; + created?: string | undefined; + verificationMethod?: string | undefined; + proofPurpose?: string | undefined; + proofValue?: string | undefined; + clientSpecType?: import("./client_spec").ClientSpecType | undefined; + } & { + type?: string | undefined; + created?: string | undefined; + verificationMethod?: string | undefined; + proofPurpose?: string | undefined; + proofValue?: string | undefined; + clientSpecType?: import("./client_spec").ClientSpecType | undefined; + } & { [K_2 in Exclude]: never; }) | undefined; + txAuthor?: string | undefined; + } & { [K_3 in Exclude]: never; }>(base?: I | undefined): MsgUpdateCredentialStatus; + fromPartial]: never; }) | undefined; + id?: string | undefined; + revoked?: boolean | undefined; + suspended?: boolean | undefined; + remarks?: string | undefined; + issuer?: string | undefined; + issuanceDate?: string | undefined; + credentialMerkleRootHash?: string | undefined; + } & { [K_5 in Exclude]: never; }) | undefined; + credentialStatusProof?: ({ + type?: string | undefined; + created?: string | undefined; + verificationMethod?: string | undefined; + proofPurpose?: string | undefined; + proofValue?: string | undefined; + clientSpecType?: import("./client_spec").ClientSpecType | undefined; + } & { + type?: string | undefined; + created?: string | undefined; + verificationMethod?: string | undefined; + proofPurpose?: string | undefined; + proofValue?: string | undefined; + clientSpecType?: import("./client_spec").ClientSpecType | undefined; + } & { [K_6 in Exclude]: never; }) | undefined; + txAuthor?: string | undefined; + } & { [K_7 in Exclude]: never; }>(object: I_1): MsgUpdateCredentialStatus; +}; +export declare const MsgUpdateCredentialStatusResponse: { + encode(_: MsgUpdateCredentialStatusResponse, writer?: _m0.Writer): _m0.Writer; + decode(input: _m0.Reader | Uint8Array, length?: number): MsgUpdateCredentialStatusResponse; + fromJSON(_: any): MsgUpdateCredentialStatusResponse; + toJSON(_: MsgUpdateCredentialStatusResponse): unknown; + create]: never; }>(base?: I | undefined): MsgUpdateCredentialStatusResponse; + fromPartial]: never; }>(_: I_1): MsgUpdateCredentialStatusResponse; }; -/** Msg defines the Msg service. */ export interface Msg { - CreateDID(request: MsgCreateDID): Promise; + RegisterDID(request: MsgRegisterDID): Promise; UpdateDID(request: MsgUpdateDID): Promise; - CreateSchema(request: MsgCreateSchema): Promise; DeactivateDID(request: MsgDeactivateDID): Promise; + RegisterCredentialSchema(request: MsgRegisterCredentialSchema): Promise; + UpdateCredentialSchema(request: MsgUpdateCredentialSchema): Promise; RegisterCredentialStatus(request: MsgRegisterCredentialStatus): Promise; + UpdateCredentialStatus(request: MsgUpdateCredentialStatus): Promise; } +export declare const MsgServiceName = "hypersign.ssi.v1.Msg"; export declare class MsgClientImpl implements Msg { private readonly rpc; - constructor(rpc: Rpc); - CreateDID(request: MsgCreateDID): Promise; + private readonly service; + constructor(rpc: Rpc, opts?: { + service?: string; + }); + RegisterDID(request: MsgRegisterDID): Promise; UpdateDID(request: MsgUpdateDID): Promise; - CreateSchema(request: MsgCreateSchema): Promise; DeactivateDID(request: MsgDeactivateDID): Promise; + RegisterCredentialSchema(request: MsgRegisterCredentialSchema): Promise; + UpdateCredentialSchema(request: MsgUpdateCredentialSchema): Promise; RegisterCredentialStatus(request: MsgRegisterCredentialStatus): Promise; + UpdateCredentialStatus(request: MsgUpdateCredentialStatus): Promise; } interface Rpc { request(service: string, method: string, data: Uint8Array): Promise; } -type Builtin = Date | Function | Uint8Array | string | number | undefined; -export type DeepPartial = T extends Builtin ? T : T extends Array ? Array> : T extends ReadonlyArray ? ReadonlyArray> : T extends {} ? { +type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined; +export type DeepPartial = T extends Builtin ? T : T extends globalThis.Array ? globalThis.Array> : T extends ReadonlyArray ? ReadonlyArray> : T extends {} ? { [K in keyof T]?: DeepPartial; } : Partial; +type KeysOfUnion = T extends T ? keyof T : never; +export type Exact = P extends Builtin ? P : P & { + [K in keyof P]: Exact; +} & { + [K in Exclude>]: never; +}; export {}; //# sourceMappingURL=tx.d.ts.map \ No newline at end of file diff --git a/build/libs/generated/ssi/tx.d.ts.map b/build/libs/generated/ssi/tx.d.ts.map index 7892130..e928332 100644 --- a/build/libs/generated/ssi/tx.d.ts.map +++ b/build/libs/generated/ssi/tx.d.ts.map @@ -1 +1 @@ -{"version":3,"file":"tx.d.ts","sourceRoot":"","sources":["../../../../libs/generated/ssi/tx.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAmB,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAErE,OAAO,EAAE,GAAG,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACtC,OAAO,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AACvD,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,gBAAgB,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAEjE,eAAO,MAAM,eAAe,kCAAkC,CAAC;AAE/D,MAAM,WAAW,YAAY;IAC3B,YAAY,EAAE,GAAG,GAAG,SAAS,CAAC;IAC9B,UAAU,EAAE,QAAQ,EAAE,CAAC;IACvB,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,oBAAoB;IACnC,EAAE,EAAE,MAAM,CAAC;CACZ;AAED,MAAM,WAAW,YAAY;IAC3B,YAAY,EAAE,GAAG,GAAG,SAAS,CAAC;IAC9B,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,QAAQ,EAAE,CAAC;IACvB,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,oBAAoB;IACnC,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,WAAW,eAAe;IAC9B,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,cAAc,GAAG,SAAS,CAAC;IACtC,WAAW,EAAE,WAAW,GAAG,SAAS,CAAC;IACrC,UAAU,EAAE,UAAU,GAAG,SAAS,CAAC;CACpC;AAED,MAAM,WAAW,uBAAuB;IACtC,EAAE,EAAE,MAAM,CAAC;CACZ;AAED,MAAM,WAAW,gBAAgB;IAC/B,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,MAAM,CAAC;IACd,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,QAAQ,EAAE,CAAC;CACxB;AAED,MAAM,WAAW,wBAAwB;IACvC,EAAE,EAAE,MAAM,CAAC;CACZ;AAED,MAAM,WAAW,2BAA2B;IAC1C,OAAO,EAAE,MAAM,CAAC;IAChB,gBAAgB,EAAE,gBAAgB,GAAG,SAAS,CAAC;IAC/C,KAAK,EAAE,eAAe,GAAG,SAAS,CAAC;IACnC,UAAU,EAAE,UAAU,GAAG,SAAS,CAAC;CACpC;AAED,MAAM,WAAW,mCAAmC;IAClD,EAAE,EAAE,MAAM,CAAC;CACZ;AAID,eAAO,MAAM,YAAY;oBACP,YAAY,WAAU,MAAM,GAAqB,MAAM;kBAazD,MAAM,GAAG,UAAU,WAAW,MAAM,GAAG,YAAY;qBAyBhD,GAAG,GAAG,YAAY;oBAqBnB,YAAY,GAAG,OAAO;wBAiBlB,YAAY,YAAY,CAAC,GAAG,YAAY;CAoB7D,CAAC;AAIF,eAAO,MAAM,oBAAoB;oBAEpB,oBAAoB,WACrB,MAAM,GACb,MAAM;kBAOK,MAAM,GAAG,UAAU,WAAW,MAAM,GAAG,oBAAoB;qBAkBxD,GAAG,GAAG,oBAAoB;oBAU3B,oBAAoB,GAAG,OAAO;wBAM1B,YAAY,oBAAoB,CAAC,GAAG,oBAAoB;CAS7E,CAAC;AAIF,eAAO,MAAM,YAAY;oBACP,YAAY,WAAU,MAAM,GAAqB,MAAM;kBAgBzD,MAAM,GAAG,UAAU,WAAW,MAAM,GAAG,YAAY;qBA4BhD,GAAG,GAAG,YAAY;oBA0BnB,YAAY,GAAG,OAAO;wBAkBlB,YAAY,YAAY,CAAC,GAAG,YAAY;CAyB7D,CAAC;AAIF,eAAO,MAAM,oBAAoB;oBAEpB,oBAAoB,WACrB,MAAM,GACb,MAAM;kBAOK,MAAM,GAAG,UAAU,WAAW,MAAM,GAAG,oBAAoB;qBAkBxD,GAAG,GAAG,oBAAoB;oBAU3B,oBAAoB,GAAG,OAAO;wBAM1B,YAAY,oBAAoB,CAAC,GAAG,oBAAoB;CAS7E,CAAC;AAIF,eAAO,MAAM,eAAe;oBACV,eAAe,WAAU,MAAM,GAAqB,MAAM;kBAsB5D,MAAM,GAAG,UAAU,WAAW,MAAM,GAAG,eAAe;qBA2BnD,GAAG,GAAG,eAAe;oBAyBtB,eAAe,GAAG,OAAO;wBAkBrB,YAAY,eAAe,CAAC,GAAG,eAAe;CAwBnE,CAAC;AAIF,eAAO,MAAM,uBAAuB;oBAEvB,uBAAuB,WACxB,MAAM,GACb,MAAM;kBAOK,MAAM,GAAG,UAAU,WAAW,MAAM,GAAG,uBAAuB;qBAoB3D,GAAG,GAAG,uBAAuB;oBAY9B,uBAAuB,GAAG,OAAO;wBAOvC,YAAY,uBAAuB,CAAC,GAC3C,uBAAuB;CAW3B,CAAC;AAIF,eAAO,MAAM,gBAAgB;oBACX,gBAAgB,WAAU,MAAM,GAAqB,MAAM;kBAgB7D,MAAM,GAAG,UAAU,WAAW,MAAM,GAAG,gBAAgB;qBA4BpD,GAAG,GAAG,gBAAgB;oBA0BvB,gBAAgB,GAAG,OAAO;wBAetB,YAAY,gBAAgB,CAAC,GAAG,gBAAgB;CAyBrE,CAAC;AAIF,eAAO,MAAM,wBAAwB;oBAExB,wBAAwB,WACzB,MAAM,GACb,MAAM;kBAQA,MAAM,GAAG,UAAU,WACjB,MAAM,GACd,wBAAwB;qBAoBV,GAAG,GAAG,wBAAwB;oBAY/B,wBAAwB,GAAG,OAAO;wBAOxC,YAAY,wBAAwB,CAAC,GAC5C,wBAAwB;CAW5B,CAAC;AAIF,eAAO,MAAM,2BAA2B;oBAE3B,2BAA2B,WAC5B,MAAM,GACb,MAAM;kBAoBA,MAAM,GAAG,UAAU,WACjB,MAAM,GACd,2BAA2B;qBAgCb,GAAG,GAAG,2BAA2B;oBAgClC,2BAA2B,GAAG,OAAO;wBAmB3C,YAAY,2BAA2B,CAAC,GAC/C,2BAA2B;CA+B/B,CAAC;AAIF,eAAO,MAAM,mCAAmC;oBAEnC,mCAAmC,WACpC,MAAM,GACb,MAAM;kBAQA,MAAM,GAAG,UAAU,WACjB,MAAM,GACd,mCAAmC;qBAoBrB,GAAG,GAAG,mCAAmC;oBAY1C,mCAAmC,GAAG,OAAO;wBAOnD,YAAY,mCAAmC,CAAC,GACvD,mCAAmC;CAWvC,CAAC;AAEF,mCAAmC;AACnC,MAAM,WAAW,GAAG;IAClB,SAAS,CAAC,OAAO,EAAE,YAAY,GAAG,OAAO,CAAC,oBAAoB,CAAC,CAAC;IAChE,SAAS,CAAC,OAAO,EAAE,YAAY,GAAG,OAAO,CAAC,oBAAoB,CAAC,CAAC;IAChE,YAAY,CAAC,OAAO,EAAE,eAAe,GAAG,OAAO,CAAC,uBAAuB,CAAC,CAAC;IACzE,aAAa,CAAC,OAAO,EAAE,gBAAgB,GAAG,OAAO,CAAC,wBAAwB,CAAC,CAAC;IAC5E,wBAAwB,CACtB,OAAO,EAAE,2BAA2B,GACnC,OAAO,CAAC,mCAAmC,CAAC,CAAC;CACjD;AAED,qBAAa,aAAc,YAAW,GAAG;IACvC,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAM;gBACd,GAAG,EAAE,GAAG;IAGpB,SAAS,CAAC,OAAO,EAAE,YAAY,GAAG,OAAO,CAAC,oBAAoB,CAAC;IAY/D,SAAS,CAAC,OAAO,EAAE,YAAY,GAAG,OAAO,CAAC,oBAAoB,CAAC;IAY/D,YAAY,CAAC,OAAO,EAAE,eAAe,GAAG,OAAO,CAAC,uBAAuB,CAAC;IAYxE,aAAa,CAAC,OAAO,EAAE,gBAAgB,GAAG,OAAO,CAAC,wBAAwB,CAAC;IAY3E,wBAAwB,CACtB,OAAO,EAAE,2BAA2B,GACnC,OAAO,CAAC,mCAAmC,CAAC;CAWhD;AAED,UAAU,GAAG;IACX,OAAO,CACL,OAAO,EAAE,MAAM,EACf,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,UAAU,GACf,OAAO,CAAC,UAAU,CAAC,CAAC;CACxB;AAYD,KAAK,OAAO,GAAG,IAAI,GAAG,QAAQ,GAAG,UAAU,GAAG,MAAM,GAAG,MAAM,GAAG,SAAS,CAAC;AAC1E,MAAM,MAAM,WAAW,CAAC,CAAC,IAAI,CAAC,SAAS,OAAO,GAC1C,CAAC,GACD,CAAC,SAAS,KAAK,CAAC,MAAM,CAAC,CAAC,GACxB,KAAK,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,GACrB,CAAC,SAAS,aAAa,CAAC,MAAM,CAAC,CAAC,GAChC,aAAa,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,GAC7B,CAAC,SAAS,EAAE,GACZ;KAAG,CAAC,IAAI,MAAM,CAAC,CAAC,CAAC,EAAE,WAAW,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;CAAE,GACtC,OAAO,CAAC,CAAC,CAAC,CAAC"} \ No newline at end of file +{"version":3,"file":"tx.d.ts","sourceRoot":"","sources":["../../../../libs/generated/ssi/tx.ts"],"names":[],"mappings":"AACA,OAAO,GAAG,MAAM,oBAAoB,CAAC;AACrC,OAAO,EAAE,wBAAwB,EAAE,MAAM,qBAAqB,CAAC;AAC/D,OAAO,EAAE,wBAAwB,EAAE,MAAM,qBAAqB,CAAC;AAC/D,OAAO,EAAE,WAAW,EAAE,MAAM,OAAO,CAAC;AACpC,OAAO,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAExC,eAAO,MAAM,eAAe,qBAAqB,CAAC;AAElD,MAAM,WAAW,cAAc;IAC7B,WAAW,CAAC,EAAE,WAAW,GAAG,SAAS,CAAC;IACtC,iBAAiB,CAAC,EAAE,aAAa,EAAE,GAAG,SAAS,CAAC;IAChD,QAAQ,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;CAC/B;AAED,MAAM,WAAW,sBAAsB;CACtC;AAED,MAAM,WAAW,YAAY;IAC3B,WAAW,CAAC,EAAE,WAAW,GAAG,SAAS,CAAC;IACtC,iBAAiB,CAAC,EAAE,aAAa,EAAE,GAAG,SAAS,CAAC;IAChD,SAAS,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC/B,QAAQ,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;CAC/B;AAED,MAAM,WAAW,oBAAoB;CACpC;AAED,MAAM,WAAW,gBAAgB;IAC/B,aAAa,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IACnC,iBAAiB,CAAC,EAAE,aAAa,EAAE,GAAG,SAAS,CAAC;IAChD,SAAS,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC/B,QAAQ,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;CAC/B;AAED,MAAM,WAAW,wBAAwB;CACxC;AAED,MAAM,WAAW,2BAA2B;IAC1C,wBAAwB,CAAC,EAAE,wBAAwB,GAAG,SAAS,CAAC;IAChE,qBAAqB,CAAC,EAAE,aAAa,GAAG,SAAS,CAAC;IAClD,QAAQ,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;CAC/B;AAED,MAAM,WAAW,mCAAmC;CACnD;AAED,MAAM,WAAW,yBAAyB;IACxC,wBAAwB,CAAC,EAAE,wBAAwB,GAAG,SAAS,CAAC;IAChE,qBAAqB,CAAC,EAAE,aAAa,GAAG,SAAS,CAAC;IAClD,QAAQ,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;CAC/B;AAED,MAAM,WAAW,iCAAiC;CACjD;AAED,MAAM,WAAW,2BAA2B;IAC1C,wBAAwB,CAAC,EAAE,wBAAwB,GAAG,SAAS,CAAC;IAChE,qBAAqB,CAAC,EAAE,aAAa,GAAG,SAAS,CAAC;IAClD,QAAQ,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;CAC/B;AAED,MAAM,WAAW,mCAAmC;CACnD;AAED,MAAM,WAAW,yBAAyB;IACxC,wBAAwB,CAAC,EAAE,wBAAwB,GAAG,SAAS,CAAC;IAChE,qBAAqB,CAAC,EAAE,aAAa,GAAG,SAAS,CAAC;IAClD,QAAQ,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;CAC/B;AAED,MAAM,WAAW,iCAAiC;CACjD;AAMD,eAAO,MAAM,cAAc;oBACT,cAAc,WAAU,IAAI,MAAM,GAAyB,IAAI,MAAM;kBAevE,IAAI,MAAM,GAAG,UAAU,WAAW,MAAM,GAAG,cAAc;qBAwCtD,GAAG,GAAG,cAAc;oBAUrB,cAAc,GAAG,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;mBApI7B,MAAM,GAAG,SAAS;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;mBAAlB,MAAM,GAAG,SAAS;6FAkJsC,cAAc;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;mBAlJtE,MAAM,GAAG,SAAS;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;mBAAlB,MAAM,GAAG,SAAS;sFAqJ4C,cAAc;CASxF,CAAC;AAMF,eAAO,MAAM,sBAAsB;cACvB,sBAAsB,WAAU,IAAI,MAAM,GAAyB,IAAI,MAAM;kBAIzE,IAAI,MAAM,GAAG,UAAU,WAAW,MAAM,GAAG,sBAAsB;gBAgBnE,GAAG,GAAG,sBAAsB;cAI9B,sBAAsB,GAAG,OAAO;kGAKiC,sBAAsB;+FAGrB,sBAAsB;CAInG,CAAC;AAMF,eAAO,MAAM,YAAY;oBACP,YAAY,WAAU,IAAI,MAAM,GAAyB,IAAI,MAAM;kBAkBrE,IAAI,MAAM,GAAG,UAAU,WAAW,MAAM,GAAG,YAAY;qBA+CpD,GAAG,GAAG,YAAY;oBAWnB,YAAY,GAAG,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;oBAnR1B,MAAM,GAAG,SAAS;mBACnB,MAAM,GAAG,SAAS;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;oBADjB,MAAM,GAAG,SAAS;mBACnB,MAAM,GAAG,SAAS;2FAmSoC,YAAY;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;oBApSjE,MAAM,GAAG,SAAS;mBACnB,MAAM,GAAG,SAAS;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;oBADjB,MAAM,GAAG,SAAS;mBACnB,MAAM,GAAG,SAAS;oFAsS0C,YAAY;CAUpF,CAAC;AAMF,eAAO,MAAM,oBAAoB;cACrB,oBAAoB,WAAU,IAAI,MAAM,GAAyB,IAAI,MAAM;kBAIvE,IAAI,MAAM,GAAG,UAAU,WAAW,MAAM,GAAG,oBAAoB;gBAgBjE,GAAG,GAAG,oBAAoB;cAI5B,oBAAoB,GAAG,OAAO;kGAKiC,oBAAoB;+FAGnB,oBAAoB;CAI/F,CAAC;AAMF,eAAO,MAAM,gBAAgB;oBACX,gBAAgB,WAAU,IAAI,MAAM,GAAyB,IAAI,MAAM;kBAkBzE,IAAI,MAAM,GAAG,UAAU,WAAW,MAAM,GAAG,gBAAgB;qBA+CxD,GAAG,GAAG,gBAAgB;oBAWvB,gBAAgB,GAAG,OAAO;;wBAva1B,MAAM,GAAG,SAAS;;;;;;;;;oBAEtB,MAAM,GAAG,SAAS;mBACnB,MAAM,GAAG,SAAS;;wBAHb,MAAM,GAAG,SAAS;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;oBAEtB,MAAM,GAAG,SAAS;mBACnB,MAAM,GAAG,SAAS;8FAqbwC,gBAAgB;;wBAxbrE,MAAM,GAAG,SAAS;;;;;;;;;oBAEtB,MAAM,GAAG,SAAS;mBACnB,MAAM,GAAG,SAAS;;wBAHb,MAAM,GAAG,SAAS;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;oBAEtB,MAAM,GAAG,SAAS;mBACnB,MAAM,GAAG,SAAS;uFAwb8C,gBAAgB;CAQ5F,CAAC;AAMF,eAAO,MAAM,wBAAwB;cACzB,wBAAwB,WAAU,IAAI,MAAM,GAAyB,IAAI,MAAM;kBAI3E,IAAI,MAAM,GAAG,UAAU,WAAW,MAAM,GAAG,wBAAwB;gBAgBrE,GAAG,GAAG,wBAAwB;cAIhC,wBAAwB,GAAG,OAAO;kGAKiC,wBAAwB;+FAGvB,wBAAwB;CAIvG,CAAC;AAMF,eAAO,MAAM,2BAA2B;oBACtB,2BAA2B,WAAU,IAAI,MAAM,GAAyB,IAAI,MAAM;kBAapF,IAAI,MAAM,GAAG,UAAU,WAAW,MAAM,GAAG,2BAA2B;qBAqCnE,GAAG,GAAG,2BAA2B;oBAYlC,2BAA2B,GAAG,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;mBAviB1C,MAAM,GAAG,SAAS;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;mBAAlB,MAAM,GAAG,SAAS;yGAqjBmD,2BAA2B;;;;;;;;;;;;;;;;;;;;;;;;;;;mBArjBhG,MAAM,GAAG,SAAS;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;mBAAlB,MAAM,GAAG,SAAS;mGAwjByD,2BAA2B;CAalH,CAAC;AAMF,eAAO,MAAM,mCAAmC;cACpC,mCAAmC,WAAU,IAAI,MAAM,GAAyB,IAAI,MAAM;kBAItF,IAAI,MAAM,GAAG,UAAU,WAAW,MAAM,GAAG,mCAAmC;gBAgBhF,GAAG,GAAG,mCAAmC;cAI3C,mCAAmC,GAAG,OAAO;kGAOpD,mCAAmC;+FAKnC,mCAAmC;CAIvC,CAAC;AAMF,eAAO,MAAM,yBAAyB;oBACpB,yBAAyB,WAAU,IAAI,MAAM,GAAyB,IAAI,MAAM;kBAalF,IAAI,MAAM,GAAG,UAAU,WAAW,MAAM,GAAG,yBAAyB;qBAqCjE,GAAG,GAAG,yBAAyB;oBAYhC,yBAAyB,GAAG,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;mBAhrBxC,MAAM,GAAG,SAAS;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;mBAAlB,MAAM,GAAG,SAAS;uGA8rBiD,yBAAyB;;;;;;;;;;;;;;;;;;;;;;;;;;;mBA9rB5F,MAAM,GAAG,SAAS;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;mBAAlB,MAAM,GAAG,SAAS;iGAisBuD,yBAAyB;CAa9G,CAAC;AAMF,eAAO,MAAM,iCAAiC;cAClC,iCAAiC,WAAU,IAAI,MAAM,GAAyB,IAAI,MAAM;kBAIpF,IAAI,MAAM,GAAG,UAAU,WAAW,MAAM,GAAG,iCAAiC;gBAgB9E,GAAG,GAAG,iCAAiC;cAIzC,iCAAiC,GAAG,OAAO;kGAOlD,iCAAiC;+FAKjC,iCAAiC;CAIrC,CAAC;AAMF,eAAO,MAAM,2BAA2B;oBACtB,2BAA2B,WAAU,IAAI,MAAM,GAAyB,IAAI,MAAM;kBAapF,IAAI,MAAM,GAAG,UAAU,WAAW,MAAM,GAAG,2BAA2B;qBAqCnE,GAAG,GAAG,2BAA2B;oBAYlC,2BAA2B,GAAG,OAAO;;;;;;;;;;;;;;;;;;;;mBAzzB1C,MAAM,GAAG,SAAS;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;mBAAlB,MAAM,GAAG,SAAS;yGAu0BmD,2BAA2B;;;;;;;;;;;;;;;;;;;;mBAv0BhG,MAAM,GAAG,SAAS;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;mBAAlB,MAAM,GAAG,SAAS;kGA00ByD,2BAA2B;CAalH,CAAC;AAMF,eAAO,MAAM,mCAAmC;cACpC,mCAAmC,WAAU,IAAI,MAAM,GAAyB,IAAI,MAAM;kBAItF,IAAI,MAAM,GAAG,UAAU,WAAW,MAAM,GAAG,mCAAmC;gBAgBhF,GAAG,GAAG,mCAAmC;cAI3C,mCAAmC,GAAG,OAAO;kGAOpD,mCAAmC;+FAKnC,mCAAmC;CAIvC,CAAC;AAMF,eAAO,MAAM,yBAAyB;oBACpB,yBAAyB,WAAU,IAAI,MAAM,GAAyB,IAAI,MAAM;kBAalF,IAAI,MAAM,GAAG,UAAU,WAAW,MAAM,GAAG,yBAAyB;qBAqCjE,GAAG,GAAG,yBAAyB;oBAYhC,yBAAyB,GAAG,OAAO;;;;;;;;;;;;;;;;;;;;mBAl8BxC,MAAM,GAAG,SAAS;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;mBAAlB,MAAM,GAAG,SAAS;uGAg9BiD,yBAAyB;;;;;;;;;;;;;;;;;;;;mBAh9B5F,MAAM,GAAG,SAAS;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;mBAAlB,MAAM,GAAG,SAAS;gGAm9BuD,yBAAyB;CAa9G,CAAC;AAMF,eAAO,MAAM,iCAAiC;cAClC,iCAAiC,WAAU,IAAI,MAAM,GAAyB,IAAI,MAAM;kBAIpF,IAAI,MAAM,GAAG,UAAU,WAAW,MAAM,GAAG,iCAAiC;gBAgB9E,GAAG,GAAG,iCAAiC;cAIzC,iCAAiC,GAAG,OAAO;kGAOlD,iCAAiC;+FAKjC,iCAAiC;CAIrC,CAAC;AAEF,MAAM,WAAW,GAAG;IAClB,WAAW,CAAC,OAAO,EAAE,cAAc,GAAG,OAAO,CAAC,sBAAsB,CAAC,CAAC;IACtE,SAAS,CAAC,OAAO,EAAE,YAAY,GAAG,OAAO,CAAC,oBAAoB,CAAC,CAAC;IAChE,aAAa,CAAC,OAAO,EAAE,gBAAgB,GAAG,OAAO,CAAC,wBAAwB,CAAC,CAAC;IAC5E,wBAAwB,CAAC,OAAO,EAAE,2BAA2B,GAAG,OAAO,CAAC,mCAAmC,CAAC,CAAC;IAC7G,sBAAsB,CAAC,OAAO,EAAE,yBAAyB,GAAG,OAAO,CAAC,iCAAiC,CAAC,CAAC;IACvG,wBAAwB,CAAC,OAAO,EAAE,2BAA2B,GAAG,OAAO,CAAC,mCAAmC,CAAC,CAAC;IAC7G,sBAAsB,CAAC,OAAO,EAAE,yBAAyB,GAAG,OAAO,CAAC,iCAAiC,CAAC,CAAC;CACxG;AAED,eAAO,MAAM,cAAc,yBAAyB,CAAC;AACrD,qBAAa,aAAc,YAAW,GAAG;IACvC,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAM;IAC1B,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAS;gBACrB,GAAG,EAAE,GAAG,EAAE,IAAI,CAAC,EAAE;QAAE,OAAO,CAAC,EAAE,MAAM,CAAA;KAAE;IAWjD,WAAW,CAAC,OAAO,EAAE,cAAc,GAAG,OAAO,CAAC,sBAAsB,CAAC;IAMrE,SAAS,CAAC,OAAO,EAAE,YAAY,GAAG,OAAO,CAAC,oBAAoB,CAAC;IAM/D,aAAa,CAAC,OAAO,EAAE,gBAAgB,GAAG,OAAO,CAAC,wBAAwB,CAAC;IAM3E,wBAAwB,CAAC,OAAO,EAAE,2BAA2B,GAAG,OAAO,CAAC,mCAAmC,CAAC;IAM5G,sBAAsB,CAAC,OAAO,EAAE,yBAAyB,GAAG,OAAO,CAAC,iCAAiC,CAAC;IAMtG,wBAAwB,CAAC,OAAO,EAAE,2BAA2B,GAAG,OAAO,CAAC,mCAAmC,CAAC;IAM5G,sBAAsB,CAAC,OAAO,EAAE,yBAAyB,GAAG,OAAO,CAAC,iCAAiC,CAAC;CAKvG;AAED,UAAU,GAAG;IACX,OAAO,CAAC,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,UAAU,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC;CACjF;AAED,KAAK,OAAO,GAAG,IAAI,GAAG,QAAQ,GAAG,UAAU,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,SAAS,CAAC;AAEpF,MAAM,MAAM,WAAW,CAAC,CAAC,IAAI,CAAC,SAAS,OAAO,GAAG,CAAC,GAC9C,CAAC,SAAS,UAAU,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,GAAG,UAAU,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,GACtE,CAAC,SAAS,aAAa,CAAC,MAAM,CAAC,CAAC,GAAG,aAAa,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,GAChE,CAAC,SAAS,EAAE,GAAG;KAAG,CAAC,IAAI,MAAM,CAAC,CAAC,CAAC,EAAE,WAAW,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;CAAE,GACrD,OAAO,CAAC,CAAC,CAAC,CAAC;AAEf,KAAK,WAAW,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,GAAG,MAAM,CAAC,GAAG,KAAK,CAAC;AACpD,MAAM,MAAM,KAAK,CAAC,CAAC,EAAE,CAAC,SAAS,CAAC,IAAI,CAAC,SAAS,OAAO,GAAG,CAAC,GACrD,CAAC,GAAG;KAAG,CAAC,IAAI,MAAM,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC;CAAE,GAAG;KAAG,CAAC,IAAI,OAAO,CAAC,MAAM,CAAC,EAAE,WAAW,CAAC,CAAC,CAAC,CAAC,GAAG,KAAK;CAAE,CAAC"} \ No newline at end of file diff --git a/build/libs/generated/ssi/tx.js b/build/libs/generated/ssi/tx.js index b556213..d601172 100644 --- a/build/libs/generated/ssi/tx.js +++ b/build/libs/generated/ssi/tx.js @@ -1,882 +1,988 @@ "use strict"; +var __importDefault = (this && this.__importDefault) || function (mod) { + return (mod && mod.__esModule) ? mod : { "default": mod }; +}; Object.defineProperty(exports, "__esModule", { value: true }); -exports.MsgClientImpl = exports.MsgRegisterCredentialStatusResponse = exports.MsgRegisterCredentialStatus = exports.MsgDeactivateDIDResponse = exports.MsgDeactivateDID = exports.MsgCreateSchemaResponse = exports.MsgCreateSchema = exports.MsgUpdateDIDResponse = exports.MsgUpdateDID = exports.MsgCreateDIDResponse = exports.MsgCreateDID = exports.protobufPackage = void 0; +exports.MsgClientImpl = exports.MsgServiceName = exports.MsgUpdateCredentialStatusResponse = exports.MsgUpdateCredentialStatus = exports.MsgRegisterCredentialStatusResponse = exports.MsgRegisterCredentialStatus = exports.MsgUpdateCredentialSchemaResponse = exports.MsgUpdateCredentialSchema = exports.MsgRegisterCredentialSchemaResponse = exports.MsgRegisterCredentialSchema = exports.MsgDeactivateDIDResponse = exports.MsgDeactivateDID = exports.MsgUpdateDIDResponse = exports.MsgUpdateDID = exports.MsgRegisterDIDResponse = exports.MsgRegisterDID = exports.protobufPackage = void 0; /* eslint-disable */ -const minimal_1 = require("protobufjs/minimal"); +const minimal_1 = __importDefault(require("protobufjs/minimal")); +const credential_schema_1 = require("./credential_schema"); +const credential_status_1 = require("./credential_status"); const did_1 = require("./did"); -const schema_1 = require("./schema"); -const clientSpec_1 = require("./clientSpec"); -const credential_1 = require("./credential"); -exports.protobufPackage = "hypersignprotocol.hidnode.ssi"; -const baseMsgCreateDID = { creator: "" }; -exports.MsgCreateDID = { - encode(message, writer = minimal_1.Writer.create()) { - if (message.didDocString !== undefined) { - did_1.Did.encode(message.didDocString, writer.uint32(10).fork()).ldelim(); - } - for (const v of message.signatures) { - did_1.SignInfo.encode(v, writer.uint32(18).fork()).ldelim(); - } - if (message.creator !== "") { - writer.uint32(26).string(message.creator); +const proof_1 = require("./proof"); +exports.protobufPackage = "hypersign.ssi.v1"; +function createBaseMsgRegisterDID() { + return {}; +} +exports.MsgRegisterDID = { + encode(message, writer = minimal_1.default.Writer.create()) { + if (message.didDocument !== undefined) { + did_1.DidDocument.encode(message.didDocument, writer.uint32(10).fork()).ldelim(); + } + if (message.didDocumentProofs !== undefined && message.didDocumentProofs.length !== 0) { + for (const v of message.didDocumentProofs) { + proof_1.DocumentProof.encode(v, writer.uint32(18).fork()).ldelim(); + } + } + if (message.txAuthor !== undefined && message.txAuthor !== "") { + writer.uint32(26).string(message.txAuthor); } return writer; }, decode(input, length) { - const reader = input instanceof Uint8Array ? new minimal_1.Reader(input) : input; + const reader = input instanceof minimal_1.default.Reader ? input : minimal_1.default.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; - const message = Object.assign({}, baseMsgCreateDID); - message.signatures = []; + const message = createBaseMsgRegisterDID(); while (reader.pos < end) { const tag = reader.uint32(); switch (tag >>> 3) { case 1: - message.didDocString = did_1.Did.decode(reader, reader.uint32()); - break; + if (tag !== 10) { + break; + } + message.didDocument = did_1.DidDocument.decode(reader, reader.uint32()); + continue; case 2: - message.signatures.push(did_1.SignInfo.decode(reader, reader.uint32())); - break; + if (tag !== 18) { + break; + } + if (message.didDocumentProofs === undefined) { + message.didDocumentProofs = []; + } + message.didDocumentProofs.push(proof_1.DocumentProof.decode(reader, reader.uint32())); + continue; case 3: - message.creator = reader.string(); - break; - default: - reader.skipType(tag & 7); - break; + if (tag !== 26) { + break; + } + message.txAuthor = reader.string(); + continue; + } + if ((tag & 7) === 4 || tag === 0) { + break; } + reader.skipType(tag & 7); } return message; }, fromJSON(object) { - const message = Object.assign({}, baseMsgCreateDID); - message.signatures = []; - if (object.didDocString !== undefined && object.didDocString !== null) { - message.didDocString = did_1.Did.fromJSON(object.didDocString); - } - else { - message.didDocString = undefined; - } - if (object.signatures !== undefined && object.signatures !== null) { - for (const e of object.signatures) { - message.signatures.push(did_1.SignInfo.fromJSON(e)); - } - } - if (object.creator !== undefined && object.creator !== null) { - message.creator = String(object.creator); - } - else { - message.creator = ""; - } - return message; + return { + didDocument: isSet(object.didDocument) ? did_1.DidDocument.fromJSON(object.didDocument) : undefined, + didDocumentProofs: globalThis.Array.isArray(object === null || object === void 0 ? void 0 : object.didDocumentProofs) + ? object.didDocumentProofs.map((e) => proof_1.DocumentProof.fromJSON(e)) + : undefined, + txAuthor: isSet(object.txAuthor) ? globalThis.String(object.txAuthor) : undefined, + }; }, toJSON(message) { + var _a; const obj = {}; - message.didDocString !== undefined && - (obj.didDocString = message.didDocString - ? did_1.Did.toJSON(message.didDocString) - : undefined); - if (message.signatures) { - obj.signatures = message.signatures.map((e) => e ? did_1.SignInfo.toJSON(e) : undefined); + if (message.didDocument !== undefined) { + obj.didDocument = did_1.DidDocument.toJSON(message.didDocument); + } + if ((_a = message.didDocumentProofs) === null || _a === void 0 ? void 0 : _a.length) { + obj.didDocumentProofs = message.didDocumentProofs.map((e) => proof_1.DocumentProof.toJSON(e)); } - else { - obj.signatures = []; + if (message.txAuthor !== undefined && message.txAuthor !== "") { + obj.txAuthor = message.txAuthor; } - message.creator !== undefined && (obj.creator = message.creator); return obj; }, + create(base) { + return exports.MsgRegisterDID.fromPartial(base !== null && base !== void 0 ? base : {}); + }, fromPartial(object) { - const message = Object.assign({}, baseMsgCreateDID); - message.signatures = []; - if (object.didDocString !== undefined && object.didDocString !== null) { - message.didDocString = did_1.Did.fromPartial(object.didDocString); - } - else { - message.didDocString = undefined; - } - if (object.signatures !== undefined && object.signatures !== null) { - for (const e of object.signatures) { - message.signatures.push(did_1.SignInfo.fromPartial(e)); - } - } - if (object.creator !== undefined && object.creator !== null) { - message.creator = object.creator; - } - else { - message.creator = ""; - } + var _a, _b; + const message = createBaseMsgRegisterDID(); + message.didDocument = (object.didDocument !== undefined && object.didDocument !== null) + ? did_1.DidDocument.fromPartial(object.didDocument) + : undefined; + message.didDocumentProofs = ((_a = object.didDocumentProofs) === null || _a === void 0 ? void 0 : _a.map((e) => proof_1.DocumentProof.fromPartial(e))) || undefined; + message.txAuthor = (_b = object.txAuthor) !== null && _b !== void 0 ? _b : undefined; return message; }, }; -const baseMsgCreateDIDResponse = { id: 0 }; -exports.MsgCreateDIDResponse = { - encode(message, writer = minimal_1.Writer.create()) { - if (message.id !== 0) { - writer.uint32(8).uint64(message.id); - } +function createBaseMsgRegisterDIDResponse() { + return {}; +} +exports.MsgRegisterDIDResponse = { + encode(_, writer = minimal_1.default.Writer.create()) { return writer; }, decode(input, length) { - const reader = input instanceof Uint8Array ? new minimal_1.Reader(input) : input; + const reader = input instanceof minimal_1.default.Reader ? input : minimal_1.default.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; - const message = Object.assign({}, baseMsgCreateDIDResponse); + const message = createBaseMsgRegisterDIDResponse(); while (reader.pos < end) { const tag = reader.uint32(); switch (tag >>> 3) { - case 1: - message.id = longToNumber(reader.uint64()); - break; - default: - reader.skipType(tag & 7); - break; } + if ((tag & 7) === 4 || tag === 0) { + break; + } + reader.skipType(tag & 7); } return message; }, - fromJSON(object) { - const message = Object.assign({}, baseMsgCreateDIDResponse); - if (object.id !== undefined && object.id !== null) { - message.id = Number(object.id); - } - else { - message.id = 0; - } - return message; + fromJSON(_) { + return {}; }, - toJSON(message) { + toJSON(_) { const obj = {}; - message.id !== undefined && (obj.id = message.id); return obj; }, - fromPartial(object) { - const message = Object.assign({}, baseMsgCreateDIDResponse); - if (object.id !== undefined && object.id !== null) { - message.id = object.id; - } - else { - message.id = 0; - } + create(base) { + return exports.MsgRegisterDIDResponse.fromPartial(base !== null && base !== void 0 ? base : {}); + }, + fromPartial(_) { + const message = createBaseMsgRegisterDIDResponse(); return message; }, }; -const baseMsgUpdateDID = { version_id: "", creator: "" }; +function createBaseMsgUpdateDID() { + return {}; +} exports.MsgUpdateDID = { - encode(message, writer = minimal_1.Writer.create()) { - if (message.didDocString !== undefined) { - did_1.Did.encode(message.didDocString, writer.uint32(10).fork()).ldelim(); + encode(message, writer = minimal_1.default.Writer.create()) { + if (message.didDocument !== undefined) { + did_1.DidDocument.encode(message.didDocument, writer.uint32(10).fork()).ldelim(); } - if (message.version_id !== "") { - writer.uint32(18).string(message.version_id); + if (message.didDocumentProofs !== undefined && message.didDocumentProofs.length !== 0) { + for (const v of message.didDocumentProofs) { + proof_1.DocumentProof.encode(v, writer.uint32(18).fork()).ldelim(); + } } - for (const v of message.signatures) { - did_1.SignInfo.encode(v, writer.uint32(26).fork()).ldelim(); + if (message.versionId !== undefined && message.versionId !== "") { + writer.uint32(26).string(message.versionId); } - if (message.creator !== "") { - writer.uint32(34).string(message.creator); + if (message.txAuthor !== undefined && message.txAuthor !== "") { + writer.uint32(34).string(message.txAuthor); } return writer; }, decode(input, length) { - const reader = input instanceof Uint8Array ? new minimal_1.Reader(input) : input; + const reader = input instanceof minimal_1.default.Reader ? input : minimal_1.default.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; - const message = Object.assign({}, baseMsgUpdateDID); - message.signatures = []; + const message = createBaseMsgUpdateDID(); while (reader.pos < end) { const tag = reader.uint32(); switch (tag >>> 3) { case 1: - message.didDocString = did_1.Did.decode(reader, reader.uint32()); - break; + if (tag !== 10) { + break; + } + message.didDocument = did_1.DidDocument.decode(reader, reader.uint32()); + continue; case 2: - message.version_id = reader.string(); - break; + if (tag !== 18) { + break; + } + if (message.didDocumentProofs === undefined) { + message.didDocumentProofs = []; + } + message.didDocumentProofs.push(proof_1.DocumentProof.decode(reader, reader.uint32())); + continue; case 3: - message.signatures.push(did_1.SignInfo.decode(reader, reader.uint32())); - break; + if (tag !== 26) { + break; + } + message.versionId = reader.string(); + continue; case 4: - message.creator = reader.string(); - break; - default: - reader.skipType(tag & 7); - break; + if (tag !== 34) { + break; + } + message.txAuthor = reader.string(); + continue; } + if ((tag & 7) === 4 || tag === 0) { + break; + } + reader.skipType(tag & 7); } return message; }, fromJSON(object) { - const message = Object.assign({}, baseMsgUpdateDID); - message.signatures = []; - if (object.didDocString !== undefined && object.didDocString !== null) { - message.didDocString = did_1.Did.fromJSON(object.didDocString); - } - else { - message.didDocString = undefined; - } - if (object.version_id !== undefined && object.version_id !== null) { - message.version_id = String(object.version_id); - } - else { - message.version_id = ""; - } - if (object.signatures !== undefined && object.signatures !== null) { - for (const e of object.signatures) { - message.signatures.push(did_1.SignInfo.fromJSON(e)); - } - } - if (object.creator !== undefined && object.creator !== null) { - message.creator = String(object.creator); - } - else { - message.creator = ""; - } - return message; + return { + didDocument: isSet(object.didDocument) ? did_1.DidDocument.fromJSON(object.didDocument) : undefined, + didDocumentProofs: globalThis.Array.isArray(object === null || object === void 0 ? void 0 : object.didDocumentProofs) + ? object.didDocumentProofs.map((e) => proof_1.DocumentProof.fromJSON(e)) + : undefined, + versionId: isSet(object.versionId) ? globalThis.String(object.versionId) : undefined, + txAuthor: isSet(object.txAuthor) ? globalThis.String(object.txAuthor) : undefined, + }; }, toJSON(message) { + var _a; const obj = {}; - message.didDocString !== undefined && - (obj.didDocString = message.didDocString - ? did_1.Did.toJSON(message.didDocString) - : undefined); - message.version_id !== undefined && (obj.version_id = message.version_id); - if (message.signatures) { - obj.signatures = message.signatures.map((e) => e ? did_1.SignInfo.toJSON(e) : undefined); - } - else { - obj.signatures = []; - } - message.creator !== undefined && (obj.creator = message.creator); - return obj; - }, - fromPartial(object) { - const message = Object.assign({}, baseMsgUpdateDID); - message.signatures = []; - if (object.didDocString !== undefined && object.didDocString !== null) { - message.didDocString = did_1.Did.fromPartial(object.didDocString); - } - else { - message.didDocString = undefined; + if (message.didDocument !== undefined) { + obj.didDocument = did_1.DidDocument.toJSON(message.didDocument); } - if (object.version_id !== undefined && object.version_id !== null) { - message.version_id = object.version_id; + if ((_a = message.didDocumentProofs) === null || _a === void 0 ? void 0 : _a.length) { + obj.didDocumentProofs = message.didDocumentProofs.map((e) => proof_1.DocumentProof.toJSON(e)); } - else { - message.version_id = ""; + if (message.versionId !== undefined && message.versionId !== "") { + obj.versionId = message.versionId; } - if (object.signatures !== undefined && object.signatures !== null) { - for (const e of object.signatures) { - message.signatures.push(did_1.SignInfo.fromPartial(e)); - } - } - if (object.creator !== undefined && object.creator !== null) { - message.creator = object.creator; - } - else { - message.creator = ""; + if (message.txAuthor !== undefined && message.txAuthor !== "") { + obj.txAuthor = message.txAuthor; } + return obj; + }, + create(base) { + return exports.MsgUpdateDID.fromPartial(base !== null && base !== void 0 ? base : {}); + }, + fromPartial(object) { + var _a, _b, _c; + const message = createBaseMsgUpdateDID(); + message.didDocument = (object.didDocument !== undefined && object.didDocument !== null) + ? did_1.DidDocument.fromPartial(object.didDocument) + : undefined; + message.didDocumentProofs = ((_a = object.didDocumentProofs) === null || _a === void 0 ? void 0 : _a.map((e) => proof_1.DocumentProof.fromPartial(e))) || undefined; + message.versionId = (_b = object.versionId) !== null && _b !== void 0 ? _b : undefined; + message.txAuthor = (_c = object.txAuthor) !== null && _c !== void 0 ? _c : undefined; return message; }, }; -const baseMsgUpdateDIDResponse = { updateId: "" }; +function createBaseMsgUpdateDIDResponse() { + return {}; +} exports.MsgUpdateDIDResponse = { - encode(message, writer = minimal_1.Writer.create()) { - if (message.updateId !== "") { - writer.uint32(10).string(message.updateId); - } + encode(_, writer = minimal_1.default.Writer.create()) { return writer; }, decode(input, length) { - const reader = input instanceof Uint8Array ? new minimal_1.Reader(input) : input; + const reader = input instanceof minimal_1.default.Reader ? input : minimal_1.default.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; - const message = Object.assign({}, baseMsgUpdateDIDResponse); + const message = createBaseMsgUpdateDIDResponse(); while (reader.pos < end) { const tag = reader.uint32(); switch (tag >>> 3) { - case 1: - message.updateId = reader.string(); - break; - default: - reader.skipType(tag & 7); - break; } + if ((tag & 7) === 4 || tag === 0) { + break; + } + reader.skipType(tag & 7); } return message; }, - fromJSON(object) { - const message = Object.assign({}, baseMsgUpdateDIDResponse); - if (object.updateId !== undefined && object.updateId !== null) { - message.updateId = String(object.updateId); - } - else { - message.updateId = ""; - } - return message; + fromJSON(_) { + return {}; }, - toJSON(message) { + toJSON(_) { const obj = {}; - message.updateId !== undefined && (obj.updateId = message.updateId); return obj; }, - fromPartial(object) { - const message = Object.assign({}, baseMsgUpdateDIDResponse); - if (object.updateId !== undefined && object.updateId !== null) { - message.updateId = object.updateId; - } - else { - message.updateId = ""; - } + create(base) { + return exports.MsgUpdateDIDResponse.fromPartial(base !== null && base !== void 0 ? base : {}); + }, + fromPartial(_) { + const message = createBaseMsgUpdateDIDResponse(); return message; }, }; -const baseMsgCreateSchema = { creator: "" }; -exports.MsgCreateSchema = { - encode(message, writer = minimal_1.Writer.create()) { - if (message.creator !== "") { - writer.uint32(10).string(message.creator); +function createBaseMsgDeactivateDID() { + return {}; +} +exports.MsgDeactivateDID = { + encode(message, writer = minimal_1.default.Writer.create()) { + if (message.didDocumentId !== undefined && message.didDocumentId !== "") { + writer.uint32(10).string(message.didDocumentId); } - if (message.schemaDoc !== undefined) { - schema_1.SchemaDocument.encode(message.schemaDoc, writer.uint32(18).fork()).ldelim(); + if (message.didDocumentProofs !== undefined && message.didDocumentProofs.length !== 0) { + for (const v of message.didDocumentProofs) { + proof_1.DocumentProof.encode(v, writer.uint32(18).fork()).ldelim(); + } } - if (message.schemaProof !== undefined) { - schema_1.SchemaProof.encode(message.schemaProof, writer.uint32(26).fork()).ldelim(); + if (message.versionId !== undefined && message.versionId !== "") { + writer.uint32(26).string(message.versionId); } - if (message.clientSpec !== undefined) { - clientSpec_1.ClientSpec.encode(message.clientSpec, writer.uint32(34).fork()).ldelim(); + if (message.txAuthor !== undefined && message.txAuthor !== "") { + writer.uint32(34).string(message.txAuthor); } return writer; }, decode(input, length) { - const reader = input instanceof Uint8Array ? new minimal_1.Reader(input) : input; + const reader = input instanceof minimal_1.default.Reader ? input : minimal_1.default.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; - const message = Object.assign({}, baseMsgCreateSchema); + const message = createBaseMsgDeactivateDID(); while (reader.pos < end) { const tag = reader.uint32(); switch (tag >>> 3) { case 1: - message.creator = reader.string(); - break; + if (tag !== 10) { + break; + } + message.didDocumentId = reader.string(); + continue; case 2: - message.schemaDoc = schema_1.SchemaDocument.decode(reader, reader.uint32()); - break; + if (tag !== 18) { + break; + } + if (message.didDocumentProofs === undefined) { + message.didDocumentProofs = []; + } + message.didDocumentProofs.push(proof_1.DocumentProof.decode(reader, reader.uint32())); + continue; case 3: - message.schemaProof = schema_1.SchemaProof.decode(reader, reader.uint32()); - break; + if (tag !== 26) { + break; + } + message.versionId = reader.string(); + continue; case 4: - message.clientSpec = clientSpec_1.ClientSpec.decode(reader, reader.uint32()); - break; - default: - reader.skipType(tag & 7); - break; + if (tag !== 34) { + break; + } + message.txAuthor = reader.string(); + continue; + } + if ((tag & 7) === 4 || tag === 0) { + break; } + reader.skipType(tag & 7); } return message; }, fromJSON(object) { - const message = Object.assign({}, baseMsgCreateSchema); - if (object.creator !== undefined && object.creator !== null) { - message.creator = String(object.creator); - } - else { - message.creator = ""; - } - if (object.schemaDoc !== undefined && object.schemaDoc !== null) { - message.schemaDoc = schema_1.SchemaDocument.fromJSON(object.schemaDoc); - } - else { - message.schemaDoc = undefined; + return { + didDocumentId: isSet(object.didDocumentId) ? globalThis.String(object.didDocumentId) : undefined, + didDocumentProofs: globalThis.Array.isArray(object === null || object === void 0 ? void 0 : object.didDocumentProofs) + ? object.didDocumentProofs.map((e) => proof_1.DocumentProof.fromJSON(e)) + : undefined, + versionId: isSet(object.versionId) ? globalThis.String(object.versionId) : undefined, + txAuthor: isSet(object.txAuthor) ? globalThis.String(object.txAuthor) : undefined, + }; + }, + toJSON(message) { + var _a; + const obj = {}; + if (message.didDocumentId !== undefined && message.didDocumentId !== "") { + obj.didDocumentId = message.didDocumentId; } - if (object.schemaProof !== undefined && object.schemaProof !== null) { - message.schemaProof = schema_1.SchemaProof.fromJSON(object.schemaProof); + if ((_a = message.didDocumentProofs) === null || _a === void 0 ? void 0 : _a.length) { + obj.didDocumentProofs = message.didDocumentProofs.map((e) => proof_1.DocumentProof.toJSON(e)); } - else { - message.schemaProof = undefined; + if (message.versionId !== undefined && message.versionId !== "") { + obj.versionId = message.versionId; } - if (object.clientSpec !== undefined && object.clientSpec !== null) { - message.clientSpec = clientSpec_1.ClientSpec.fromJSON(object.clientSpec); + if (message.txAuthor !== undefined && message.txAuthor !== "") { + obj.txAuthor = message.txAuthor; } - else { - message.clientSpec = undefined; + return obj; + }, + create(base) { + return exports.MsgDeactivateDID.fromPartial(base !== null && base !== void 0 ? base : {}); + }, + fromPartial(object) { + var _a, _b, _c, _d; + const message = createBaseMsgDeactivateDID(); + message.didDocumentId = (_a = object.didDocumentId) !== null && _a !== void 0 ? _a : undefined; + message.didDocumentProofs = ((_b = object.didDocumentProofs) === null || _b === void 0 ? void 0 : _b.map((e) => proof_1.DocumentProof.fromPartial(e))) || undefined; + message.versionId = (_c = object.versionId) !== null && _c !== void 0 ? _c : undefined; + message.txAuthor = (_d = object.txAuthor) !== null && _d !== void 0 ? _d : undefined; + return message; + }, +}; +function createBaseMsgDeactivateDIDResponse() { + return {}; +} +exports.MsgDeactivateDIDResponse = { + encode(_, writer = minimal_1.default.Writer.create()) { + return writer; + }, + decode(input, length) { + const reader = input instanceof minimal_1.default.Reader ? input : minimal_1.default.Reader.create(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseMsgDeactivateDIDResponse(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + } + if ((tag & 7) === 4 || tag === 0) { + break; + } + reader.skipType(tag & 7); } return message; }, - toJSON(message) { + fromJSON(_) { + return {}; + }, + toJSON(_) { const obj = {}; - message.creator !== undefined && (obj.creator = message.creator); - message.schemaDoc !== undefined && - (obj.schemaDoc = message.schemaDoc - ? schema_1.SchemaDocument.toJSON(message.schemaDoc) - : undefined); - message.schemaProof !== undefined && - (obj.schemaProof = message.schemaProof - ? schema_1.SchemaProof.toJSON(message.schemaProof) - : undefined); - message.clientSpec !== undefined && - (obj.clientSpec = message.clientSpec - ? clientSpec_1.ClientSpec.toJSON(message.clientSpec) - : undefined); return obj; }, - fromPartial(object) { - const message = Object.assign({}, baseMsgCreateSchema); - if (object.creator !== undefined && object.creator !== null) { - message.creator = object.creator; - } - else { - message.creator = ""; + create(base) { + return exports.MsgDeactivateDIDResponse.fromPartial(base !== null && base !== void 0 ? base : {}); + }, + fromPartial(_) { + const message = createBaseMsgDeactivateDIDResponse(); + return message; + }, +}; +function createBaseMsgRegisterCredentialSchema() { + return {}; +} +exports.MsgRegisterCredentialSchema = { + encode(message, writer = minimal_1.default.Writer.create()) { + if (message.credentialSchemaDocument !== undefined) { + credential_schema_1.CredentialSchemaDocument.encode(message.credentialSchemaDocument, writer.uint32(10).fork()).ldelim(); } - if (object.schemaDoc !== undefined && object.schemaDoc !== null) { - message.schemaDoc = schema_1.SchemaDocument.fromPartial(object.schemaDoc); + if (message.credentialSchemaProof !== undefined) { + proof_1.DocumentProof.encode(message.credentialSchemaProof, writer.uint32(18).fork()).ldelim(); } - else { - message.schemaDoc = undefined; + if (message.txAuthor !== undefined && message.txAuthor !== "") { + writer.uint32(26).string(message.txAuthor); } - if (object.schemaProof !== undefined && object.schemaProof !== null) { - message.schemaProof = schema_1.SchemaProof.fromPartial(object.schemaProof); + return writer; + }, + decode(input, length) { + const reader = input instanceof minimal_1.default.Reader ? input : minimal_1.default.Reader.create(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseMsgRegisterCredentialSchema(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + if (tag !== 10) { + break; + } + message.credentialSchemaDocument = credential_schema_1.CredentialSchemaDocument.decode(reader, reader.uint32()); + continue; + case 2: + if (tag !== 18) { + break; + } + message.credentialSchemaProof = proof_1.DocumentProof.decode(reader, reader.uint32()); + continue; + case 3: + if (tag !== 26) { + break; + } + message.txAuthor = reader.string(); + continue; + } + if ((tag & 7) === 4 || tag === 0) { + break; + } + reader.skipType(tag & 7); } - else { - message.schemaProof = undefined; + return message; + }, + fromJSON(object) { + return { + credentialSchemaDocument: isSet(object.credentialSchemaDocument) + ? credential_schema_1.CredentialSchemaDocument.fromJSON(object.credentialSchemaDocument) + : undefined, + credentialSchemaProof: isSet(object.credentialSchemaProof) + ? proof_1.DocumentProof.fromJSON(object.credentialSchemaProof) + : undefined, + txAuthor: isSet(object.txAuthor) ? globalThis.String(object.txAuthor) : undefined, + }; + }, + toJSON(message) { + const obj = {}; + if (message.credentialSchemaDocument !== undefined) { + obj.credentialSchemaDocument = credential_schema_1.CredentialSchemaDocument.toJSON(message.credentialSchemaDocument); } - if (object.clientSpec !== undefined && object.clientSpec !== null) { - message.clientSpec = clientSpec_1.ClientSpec.fromPartial(object.clientSpec); + if (message.credentialSchemaProof !== undefined) { + obj.credentialSchemaProof = proof_1.DocumentProof.toJSON(message.credentialSchemaProof); } - else { - message.clientSpec = undefined; + if (message.txAuthor !== undefined && message.txAuthor !== "") { + obj.txAuthor = message.txAuthor; } + return obj; + }, + create(base) { + return exports.MsgRegisterCredentialSchema.fromPartial(base !== null && base !== void 0 ? base : {}); + }, + fromPartial(object) { + var _a; + const message = createBaseMsgRegisterCredentialSchema(); + message.credentialSchemaDocument = + (object.credentialSchemaDocument !== undefined && object.credentialSchemaDocument !== null) + ? credential_schema_1.CredentialSchemaDocument.fromPartial(object.credentialSchemaDocument) + : undefined; + message.credentialSchemaProof = + (object.credentialSchemaProof !== undefined && object.credentialSchemaProof !== null) + ? proof_1.DocumentProof.fromPartial(object.credentialSchemaProof) + : undefined; + message.txAuthor = (_a = object.txAuthor) !== null && _a !== void 0 ? _a : undefined; return message; }, }; -const baseMsgCreateSchemaResponse = { id: 0 }; -exports.MsgCreateSchemaResponse = { - encode(message, writer = minimal_1.Writer.create()) { - if (message.id !== 0) { - writer.uint32(8).uint64(message.id); - } +function createBaseMsgRegisterCredentialSchemaResponse() { + return {}; +} +exports.MsgRegisterCredentialSchemaResponse = { + encode(_, writer = minimal_1.default.Writer.create()) { return writer; }, decode(input, length) { - const reader = input instanceof Uint8Array ? new minimal_1.Reader(input) : input; + const reader = input instanceof minimal_1.default.Reader ? input : minimal_1.default.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; - const message = Object.assign({}, baseMsgCreateSchemaResponse); + const message = createBaseMsgRegisterCredentialSchemaResponse(); while (reader.pos < end) { const tag = reader.uint32(); switch (tag >>> 3) { - case 1: - message.id = longToNumber(reader.uint64()); - break; - default: - reader.skipType(tag & 7); - break; } + if ((tag & 7) === 4 || tag === 0) { + break; + } + reader.skipType(tag & 7); } return message; }, - fromJSON(object) { - const message = Object.assign({}, baseMsgCreateSchemaResponse); - if (object.id !== undefined && object.id !== null) { - message.id = Number(object.id); - } - else { - message.id = 0; - } - return message; + fromJSON(_) { + return {}; }, - toJSON(message) { + toJSON(_) { const obj = {}; - message.id !== undefined && (obj.id = message.id); return obj; }, - fromPartial(object) { - const message = Object.assign({}, baseMsgCreateSchemaResponse); - if (object.id !== undefined && object.id !== null) { - message.id = object.id; - } - else { - message.id = 0; - } + create(base) { + return exports.MsgRegisterCredentialSchemaResponse.fromPartial(base !== null && base !== void 0 ? base : {}); + }, + fromPartial(_) { + const message = createBaseMsgRegisterCredentialSchemaResponse(); return message; }, }; -const baseMsgDeactivateDID = { creator: "", didId: "", version_id: "" }; -exports.MsgDeactivateDID = { - encode(message, writer = minimal_1.Writer.create()) { - if (message.creator !== "") { - writer.uint32(10).string(message.creator); - } - if (message.didId !== "") { - writer.uint32(18).string(message.didId); +function createBaseMsgUpdateCredentialSchema() { + return {}; +} +exports.MsgUpdateCredentialSchema = { + encode(message, writer = minimal_1.default.Writer.create()) { + if (message.credentialSchemaDocument !== undefined) { + credential_schema_1.CredentialSchemaDocument.encode(message.credentialSchemaDocument, writer.uint32(10).fork()).ldelim(); } - if (message.version_id !== "") { - writer.uint32(26).string(message.version_id); + if (message.credentialSchemaProof !== undefined) { + proof_1.DocumentProof.encode(message.credentialSchemaProof, writer.uint32(18).fork()).ldelim(); } - for (const v of message.signatures) { - did_1.SignInfo.encode(v, writer.uint32(34).fork()).ldelim(); + if (message.txAuthor !== undefined && message.txAuthor !== "") { + writer.uint32(26).string(message.txAuthor); } return writer; }, decode(input, length) { - const reader = input instanceof Uint8Array ? new minimal_1.Reader(input) : input; + const reader = input instanceof minimal_1.default.Reader ? input : minimal_1.default.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; - const message = Object.assign({}, baseMsgDeactivateDID); - message.signatures = []; + const message = createBaseMsgUpdateCredentialSchema(); while (reader.pos < end) { const tag = reader.uint32(); switch (tag >>> 3) { case 1: - message.creator = reader.string(); - break; + if (tag !== 10) { + break; + } + message.credentialSchemaDocument = credential_schema_1.CredentialSchemaDocument.decode(reader, reader.uint32()); + continue; case 2: - message.didId = reader.string(); - break; + if (tag !== 18) { + break; + } + message.credentialSchemaProof = proof_1.DocumentProof.decode(reader, reader.uint32()); + continue; case 3: - message.version_id = reader.string(); - break; - case 4: - message.signatures.push(did_1.SignInfo.decode(reader, reader.uint32())); - break; - default: - reader.skipType(tag & 7); - break; + if (tag !== 26) { + break; + } + message.txAuthor = reader.string(); + continue; + } + if ((tag & 7) === 4 || tag === 0) { + break; } + reader.skipType(tag & 7); } return message; }, fromJSON(object) { - const message = Object.assign({}, baseMsgDeactivateDID); - message.signatures = []; - if (object.creator !== undefined && object.creator !== null) { - message.creator = String(object.creator); - } - else { - message.creator = ""; - } - if (object.didId !== undefined && object.didId !== null) { - message.didId = String(object.didId); - } - else { - message.didId = ""; - } - if (object.version_id !== undefined && object.version_id !== null) { - message.version_id = String(object.version_id); - } - else { - message.version_id = ""; - } - if (object.signatures !== undefined && object.signatures !== null) { - for (const e of object.signatures) { - message.signatures.push(did_1.SignInfo.fromJSON(e)); - } - } - return message; + return { + credentialSchemaDocument: isSet(object.credentialSchemaDocument) + ? credential_schema_1.CredentialSchemaDocument.fromJSON(object.credentialSchemaDocument) + : undefined, + credentialSchemaProof: isSet(object.credentialSchemaProof) + ? proof_1.DocumentProof.fromJSON(object.credentialSchemaProof) + : undefined, + txAuthor: isSet(object.txAuthor) ? globalThis.String(object.txAuthor) : undefined, + }; }, toJSON(message) { const obj = {}; - message.creator !== undefined && (obj.creator = message.creator); - message.didId !== undefined && (obj.didId = message.didId); - message.version_id !== undefined && (obj.version_id = message.version_id); - if (message.signatures) { - obj.signatures = message.signatures.map((e) => e ? did_1.SignInfo.toJSON(e) : undefined); + if (message.credentialSchemaDocument !== undefined) { + obj.credentialSchemaDocument = credential_schema_1.CredentialSchemaDocument.toJSON(message.credentialSchemaDocument); + } + if (message.credentialSchemaProof !== undefined) { + obj.credentialSchemaProof = proof_1.DocumentProof.toJSON(message.credentialSchemaProof); } - else { - obj.signatures = []; + if (message.txAuthor !== undefined && message.txAuthor !== "") { + obj.txAuthor = message.txAuthor; } return obj; }, + create(base) { + return exports.MsgUpdateCredentialSchema.fromPartial(base !== null && base !== void 0 ? base : {}); + }, fromPartial(object) { - const message = Object.assign({}, baseMsgDeactivateDID); - message.signatures = []; - if (object.creator !== undefined && object.creator !== null) { - message.creator = object.creator; - } - else { - message.creator = ""; - } - if (object.didId !== undefined && object.didId !== null) { - message.didId = object.didId; - } - else { - message.didId = ""; - } - if (object.version_id !== undefined && object.version_id !== null) { - message.version_id = object.version_id; - } - else { - message.version_id = ""; - } - if (object.signatures !== undefined && object.signatures !== null) { - for (const e of object.signatures) { - message.signatures.push(did_1.SignInfo.fromPartial(e)); - } - } + var _a; + const message = createBaseMsgUpdateCredentialSchema(); + message.credentialSchemaDocument = + (object.credentialSchemaDocument !== undefined && object.credentialSchemaDocument !== null) + ? credential_schema_1.CredentialSchemaDocument.fromPartial(object.credentialSchemaDocument) + : undefined; + message.credentialSchemaProof = + (object.credentialSchemaProof !== undefined && object.credentialSchemaProof !== null) + ? proof_1.DocumentProof.fromPartial(object.credentialSchemaProof) + : undefined; + message.txAuthor = (_a = object.txAuthor) !== null && _a !== void 0 ? _a : undefined; return message; }, }; -const baseMsgDeactivateDIDResponse = { id: 0 }; -exports.MsgDeactivateDIDResponse = { - encode(message, writer = minimal_1.Writer.create()) { - if (message.id !== 0) { - writer.uint32(8).uint64(message.id); - } +function createBaseMsgUpdateCredentialSchemaResponse() { + return {}; +} +exports.MsgUpdateCredentialSchemaResponse = { + encode(_, writer = minimal_1.default.Writer.create()) { return writer; }, decode(input, length) { - const reader = input instanceof Uint8Array ? new minimal_1.Reader(input) : input; + const reader = input instanceof minimal_1.default.Reader ? input : minimal_1.default.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; - const message = Object.assign({}, baseMsgDeactivateDIDResponse); + const message = createBaseMsgUpdateCredentialSchemaResponse(); while (reader.pos < end) { const tag = reader.uint32(); switch (tag >>> 3) { - case 1: - message.id = longToNumber(reader.uint64()); - break; - default: - reader.skipType(tag & 7); - break; } + if ((tag & 7) === 4 || tag === 0) { + break; + } + reader.skipType(tag & 7); } return message; }, - fromJSON(object) { - const message = Object.assign({}, baseMsgDeactivateDIDResponse); - if (object.id !== undefined && object.id !== null) { - message.id = Number(object.id); - } - else { - message.id = 0; - } - return message; + fromJSON(_) { + return {}; }, - toJSON(message) { + toJSON(_) { const obj = {}; - message.id !== undefined && (obj.id = message.id); return obj; }, - fromPartial(object) { - const message = Object.assign({}, baseMsgDeactivateDIDResponse); - if (object.id !== undefined && object.id !== null) { - message.id = object.id; - } - else { - message.id = 0; - } + create(base) { + return exports.MsgUpdateCredentialSchemaResponse.fromPartial(base !== null && base !== void 0 ? base : {}); + }, + fromPartial(_) { + const message = createBaseMsgUpdateCredentialSchemaResponse(); return message; }, }; -const baseMsgRegisterCredentialStatus = { creator: "" }; +function createBaseMsgRegisterCredentialStatus() { + return {}; +} exports.MsgRegisterCredentialStatus = { - encode(message, writer = minimal_1.Writer.create()) { - if (message.creator !== "") { - writer.uint32(10).string(message.creator); + encode(message, writer = minimal_1.default.Writer.create()) { + if (message.credentialStatusDocument !== undefined) { + credential_status_1.CredentialStatusDocument.encode(message.credentialStatusDocument, writer.uint32(10).fork()).ldelim(); } - if (message.credentialStatus !== undefined) { - credential_1.CredentialStatus.encode(message.credentialStatus, writer.uint32(18).fork()).ldelim(); + if (message.credentialStatusProof !== undefined) { + proof_1.DocumentProof.encode(message.credentialStatusProof, writer.uint32(18).fork()).ldelim(); } - if (message.proof !== undefined) { - credential_1.CredentialProof.encode(message.proof, writer.uint32(26).fork()).ldelim(); - } - if (message.clientSpec !== undefined) { - clientSpec_1.ClientSpec.encode(message.clientSpec, writer.uint32(34).fork()).ldelim(); + if (message.txAuthor !== undefined && message.txAuthor !== "") { + writer.uint32(26).string(message.txAuthor); } return writer; }, decode(input, length) { - const reader = input instanceof Uint8Array ? new minimal_1.Reader(input) : input; + const reader = input instanceof minimal_1.default.Reader ? input : minimal_1.default.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; - const message = Object.assign({}, baseMsgRegisterCredentialStatus); + const message = createBaseMsgRegisterCredentialStatus(); while (reader.pos < end) { const tag = reader.uint32(); switch (tag >>> 3) { case 1: - message.creator = reader.string(); - break; + if (tag !== 10) { + break; + } + message.credentialStatusDocument = credential_status_1.CredentialStatusDocument.decode(reader, reader.uint32()); + continue; case 2: - message.credentialStatus = credential_1.CredentialStatus.decode(reader, reader.uint32()); - break; + if (tag !== 18) { + break; + } + message.credentialStatusProof = proof_1.DocumentProof.decode(reader, reader.uint32()); + continue; case 3: - message.proof = credential_1.CredentialProof.decode(reader, reader.uint32()); - break; - case 4: - message.clientSpec = clientSpec_1.ClientSpec.decode(reader, reader.uint32()); - break; - default: - reader.skipType(tag & 7); - break; + if (tag !== 26) { + break; + } + message.txAuthor = reader.string(); + continue; } + if ((tag & 7) === 4 || tag === 0) { + break; + } + reader.skipType(tag & 7); } return message; }, fromJSON(object) { - const message = Object.assign({}, baseMsgRegisterCredentialStatus); - if (object.creator !== undefined && object.creator !== null) { - message.creator = String(object.creator); - } - else { - message.creator = ""; - } - if (object.credentialStatus !== undefined && - object.credentialStatus !== null) { - message.credentialStatus = credential_1.CredentialStatus.fromJSON(object.credentialStatus); - } - else { - message.credentialStatus = undefined; - } - if (object.proof !== undefined && object.proof !== null) { - message.proof = credential_1.CredentialProof.fromJSON(object.proof); + return { + credentialStatusDocument: isSet(object.credentialStatusDocument) + ? credential_status_1.CredentialStatusDocument.fromJSON(object.credentialStatusDocument) + : undefined, + credentialStatusProof: isSet(object.credentialStatusProof) + ? proof_1.DocumentProof.fromJSON(object.credentialStatusProof) + : undefined, + txAuthor: isSet(object.txAuthor) ? globalThis.String(object.txAuthor) : undefined, + }; + }, + toJSON(message) { + const obj = {}; + if (message.credentialStatusDocument !== undefined) { + obj.credentialStatusDocument = credential_status_1.CredentialStatusDocument.toJSON(message.credentialStatusDocument); } - else { - message.proof = undefined; + if (message.credentialStatusProof !== undefined) { + obj.credentialStatusProof = proof_1.DocumentProof.toJSON(message.credentialStatusProof); } - if (object.clientSpec !== undefined && object.clientSpec !== null) { - message.clientSpec = clientSpec_1.ClientSpec.fromJSON(object.clientSpec); + if (message.txAuthor !== undefined && message.txAuthor !== "") { + obj.txAuthor = message.txAuthor; } - else { - message.clientSpec = undefined; + return obj; + }, + create(base) { + return exports.MsgRegisterCredentialStatus.fromPartial(base !== null && base !== void 0 ? base : {}); + }, + fromPartial(object) { + var _a; + const message = createBaseMsgRegisterCredentialStatus(); + message.credentialStatusDocument = + (object.credentialStatusDocument !== undefined && object.credentialStatusDocument !== null) + ? credential_status_1.CredentialStatusDocument.fromPartial(object.credentialStatusDocument) + : undefined; + message.credentialStatusProof = + (object.credentialStatusProof !== undefined && object.credentialStatusProof !== null) + ? proof_1.DocumentProof.fromPartial(object.credentialStatusProof) + : undefined; + message.txAuthor = (_a = object.txAuthor) !== null && _a !== void 0 ? _a : undefined; + return message; + }, +}; +function createBaseMsgRegisterCredentialStatusResponse() { + return {}; +} +exports.MsgRegisterCredentialStatusResponse = { + encode(_, writer = minimal_1.default.Writer.create()) { + return writer; + }, + decode(input, length) { + const reader = input instanceof minimal_1.default.Reader ? input : minimal_1.default.Reader.create(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseMsgRegisterCredentialStatusResponse(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + } + if ((tag & 7) === 4 || tag === 0) { + break; + } + reader.skipType(tag & 7); } return message; }, - toJSON(message) { + fromJSON(_) { + return {}; + }, + toJSON(_) { const obj = {}; - message.creator !== undefined && (obj.creator = message.creator); - message.credentialStatus !== undefined && - (obj.credentialStatus = message.credentialStatus - ? credential_1.CredentialStatus.toJSON(message.credentialStatus) - : undefined); - message.proof !== undefined && - (obj.proof = message.proof - ? credential_1.CredentialProof.toJSON(message.proof) - : undefined); - message.clientSpec !== undefined && - (obj.clientSpec = message.clientSpec - ? clientSpec_1.ClientSpec.toJSON(message.clientSpec) - : undefined); return obj; }, - fromPartial(object) { - const message = Object.assign({}, baseMsgRegisterCredentialStatus); - if (object.creator !== undefined && object.creator !== null) { - message.creator = object.creator; - } - else { - message.creator = ""; + create(base) { + return exports.MsgRegisterCredentialStatusResponse.fromPartial(base !== null && base !== void 0 ? base : {}); + }, + fromPartial(_) { + const message = createBaseMsgRegisterCredentialStatusResponse(); + return message; + }, +}; +function createBaseMsgUpdateCredentialStatus() { + return {}; +} +exports.MsgUpdateCredentialStatus = { + encode(message, writer = minimal_1.default.Writer.create()) { + if (message.credentialStatusDocument !== undefined) { + credential_status_1.CredentialStatusDocument.encode(message.credentialStatusDocument, writer.uint32(10).fork()).ldelim(); } - if (object.credentialStatus !== undefined && - object.credentialStatus !== null) { - message.credentialStatus = credential_1.CredentialStatus.fromPartial(object.credentialStatus); + if (message.credentialStatusProof !== undefined) { + proof_1.DocumentProof.encode(message.credentialStatusProof, writer.uint32(18).fork()).ldelim(); } - else { - message.credentialStatus = undefined; + if (message.txAuthor !== undefined && message.txAuthor !== "") { + writer.uint32(26).string(message.txAuthor); } - if (object.proof !== undefined && object.proof !== null) { - message.proof = credential_1.CredentialProof.fromPartial(object.proof); + return writer; + }, + decode(input, length) { + const reader = input instanceof minimal_1.default.Reader ? input : minimal_1.default.Reader.create(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseMsgUpdateCredentialStatus(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + if (tag !== 10) { + break; + } + message.credentialStatusDocument = credential_status_1.CredentialStatusDocument.decode(reader, reader.uint32()); + continue; + case 2: + if (tag !== 18) { + break; + } + message.credentialStatusProof = proof_1.DocumentProof.decode(reader, reader.uint32()); + continue; + case 3: + if (tag !== 26) { + break; + } + message.txAuthor = reader.string(); + continue; + } + if ((tag & 7) === 4 || tag === 0) { + break; + } + reader.skipType(tag & 7); } - else { - message.proof = undefined; + return message; + }, + fromJSON(object) { + return { + credentialStatusDocument: isSet(object.credentialStatusDocument) + ? credential_status_1.CredentialStatusDocument.fromJSON(object.credentialStatusDocument) + : undefined, + credentialStatusProof: isSet(object.credentialStatusProof) + ? proof_1.DocumentProof.fromJSON(object.credentialStatusProof) + : undefined, + txAuthor: isSet(object.txAuthor) ? globalThis.String(object.txAuthor) : undefined, + }; + }, + toJSON(message) { + const obj = {}; + if (message.credentialStatusDocument !== undefined) { + obj.credentialStatusDocument = credential_status_1.CredentialStatusDocument.toJSON(message.credentialStatusDocument); } - if (object.clientSpec !== undefined && object.clientSpec !== null) { - message.clientSpec = clientSpec_1.ClientSpec.fromPartial(object.clientSpec); + if (message.credentialStatusProof !== undefined) { + obj.credentialStatusProof = proof_1.DocumentProof.toJSON(message.credentialStatusProof); } - else { - message.clientSpec = undefined; + if (message.txAuthor !== undefined && message.txAuthor !== "") { + obj.txAuthor = message.txAuthor; } + return obj; + }, + create(base) { + return exports.MsgUpdateCredentialStatus.fromPartial(base !== null && base !== void 0 ? base : {}); + }, + fromPartial(object) { + var _a; + const message = createBaseMsgUpdateCredentialStatus(); + message.credentialStatusDocument = + (object.credentialStatusDocument !== undefined && object.credentialStatusDocument !== null) + ? credential_status_1.CredentialStatusDocument.fromPartial(object.credentialStatusDocument) + : undefined; + message.credentialStatusProof = + (object.credentialStatusProof !== undefined && object.credentialStatusProof !== null) + ? proof_1.DocumentProof.fromPartial(object.credentialStatusProof) + : undefined; + message.txAuthor = (_a = object.txAuthor) !== null && _a !== void 0 ? _a : undefined; return message; }, }; -const baseMsgRegisterCredentialStatusResponse = { id: 0 }; -exports.MsgRegisterCredentialStatusResponse = { - encode(message, writer = minimal_1.Writer.create()) { - if (message.id !== 0) { - writer.uint32(8).uint64(message.id); - } +function createBaseMsgUpdateCredentialStatusResponse() { + return {}; +} +exports.MsgUpdateCredentialStatusResponse = { + encode(_, writer = minimal_1.default.Writer.create()) { return writer; }, decode(input, length) { - const reader = input instanceof Uint8Array ? new minimal_1.Reader(input) : input; + const reader = input instanceof minimal_1.default.Reader ? input : minimal_1.default.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; - const message = Object.assign({}, baseMsgRegisterCredentialStatusResponse); + const message = createBaseMsgUpdateCredentialStatusResponse(); while (reader.pos < end) { const tag = reader.uint32(); switch (tag >>> 3) { - case 1: - message.id = longToNumber(reader.uint64()); - break; - default: - reader.skipType(tag & 7); - break; } + if ((tag & 7) === 4 || tag === 0) { + break; + } + reader.skipType(tag & 7); } return message; }, - fromJSON(object) { - const message = Object.assign({}, baseMsgRegisterCredentialStatusResponse); - if (object.id !== undefined && object.id !== null) { - message.id = Number(object.id); - } - else { - message.id = 0; - } - return message; + fromJSON(_) { + return {}; }, - toJSON(message) { + toJSON(_) { const obj = {}; - message.id !== undefined && (obj.id = message.id); return obj; }, - fromPartial(object) { - const message = Object.assign({}, baseMsgRegisterCredentialStatusResponse); - if (object.id !== undefined && object.id !== null) { - message.id = object.id; - } - else { - message.id = 0; - } + create(base) { + return exports.MsgUpdateCredentialStatusResponse.fromPartial(base !== null && base !== void 0 ? base : {}); + }, + fromPartial(_) { + const message = createBaseMsgUpdateCredentialStatusResponse(); return message; }, }; +exports.MsgServiceName = "hypersign.ssi.v1.Msg"; class MsgClientImpl { - constructor(rpc) { + constructor(rpc, opts) { + this.service = (opts === null || opts === void 0 ? void 0 : opts.service) || exports.MsgServiceName; this.rpc = rpc; + this.RegisterDID = this.RegisterDID.bind(this); + this.UpdateDID = this.UpdateDID.bind(this); + this.DeactivateDID = this.DeactivateDID.bind(this); + this.RegisterCredentialSchema = this.RegisterCredentialSchema.bind(this); + this.UpdateCredentialSchema = this.UpdateCredentialSchema.bind(this); + this.RegisterCredentialStatus = this.RegisterCredentialStatus.bind(this); + this.UpdateCredentialStatus = this.UpdateCredentialStatus.bind(this); } - CreateDID(request) { - const data = exports.MsgCreateDID.encode(request).finish(); - const promise = this.rpc.request("hypersignprotocol.hidnode.ssi.Msg", "CreateDID", data); - return promise.then((data) => exports.MsgCreateDIDResponse.decode(new minimal_1.Reader(data))); + RegisterDID(request) { + const data = exports.MsgRegisterDID.encode(request).finish(); + const promise = this.rpc.request(this.service, "RegisterDID", data); + return promise.then((data) => exports.MsgRegisterDIDResponse.decode(minimal_1.default.Reader.create(data))); } UpdateDID(request) { const data = exports.MsgUpdateDID.encode(request).finish(); - const promise = this.rpc.request("hypersignprotocol.hidnode.ssi.Msg", "UpdateDID", data); - return promise.then((data) => exports.MsgUpdateDIDResponse.decode(new minimal_1.Reader(data))); - } - CreateSchema(request) { - const data = exports.MsgCreateSchema.encode(request).finish(); - const promise = this.rpc.request("hypersignprotocol.hidnode.ssi.Msg", "CreateSchema", data); - return promise.then((data) => exports.MsgCreateSchemaResponse.decode(new minimal_1.Reader(data))); + const promise = this.rpc.request(this.service, "UpdateDID", data); + return promise.then((data) => exports.MsgUpdateDIDResponse.decode(minimal_1.default.Reader.create(data))); } DeactivateDID(request) { const data = exports.MsgDeactivateDID.encode(request).finish(); - const promise = this.rpc.request("hypersignprotocol.hidnode.ssi.Msg", "DeactivateDID", data); - return promise.then((data) => exports.MsgDeactivateDIDResponse.decode(new minimal_1.Reader(data))); + const promise = this.rpc.request(this.service, "DeactivateDID", data); + return promise.then((data) => exports.MsgDeactivateDIDResponse.decode(minimal_1.default.Reader.create(data))); + } + RegisterCredentialSchema(request) { + const data = exports.MsgRegisterCredentialSchema.encode(request).finish(); + const promise = this.rpc.request(this.service, "RegisterCredentialSchema", data); + return promise.then((data) => exports.MsgRegisterCredentialSchemaResponse.decode(minimal_1.default.Reader.create(data))); + } + UpdateCredentialSchema(request) { + const data = exports.MsgUpdateCredentialSchema.encode(request).finish(); + const promise = this.rpc.request(this.service, "UpdateCredentialSchema", data); + return promise.then((data) => exports.MsgUpdateCredentialSchemaResponse.decode(minimal_1.default.Reader.create(data))); } RegisterCredentialStatus(request) { const data = exports.MsgRegisterCredentialStatus.encode(request).finish(); - const promise = this.rpc.request("hypersignprotocol.hidnode.ssi.Msg", "RegisterCredentialStatus", data); - return promise.then((data) => exports.MsgRegisterCredentialStatusResponse.decode(new minimal_1.Reader(data))); + const promise = this.rpc.request(this.service, "RegisterCredentialStatus", data); + return promise.then((data) => exports.MsgRegisterCredentialStatusResponse.decode(minimal_1.default.Reader.create(data))); + } + UpdateCredentialStatus(request) { + const data = exports.MsgUpdateCredentialStatus.encode(request).finish(); + const promise = this.rpc.request(this.service, "UpdateCredentialStatus", data); + return promise.then((data) => exports.MsgUpdateCredentialStatusResponse.decode(minimal_1.default.Reader.create(data))); } } exports.MsgClientImpl = MsgClientImpl; -var globalThis = (() => { - if (typeof globalThis !== "undefined") - return globalThis; - if (typeof self !== "undefined") - return self; - if (typeof window !== "undefined") - return window; - if (typeof global !== "undefined") - return global; - throw "Unable to locate global object"; -})(); -function longToNumber(long) { - if (long.gt(Number.MAX_SAFE_INTEGER)) { - throw new globalThis.Error("Value is larger than Number.MAX_SAFE_INTEGER"); - } - return long.toNumber(); +function isSet(value) { + return value !== null && value !== undefined; } -// if (util.Long !== Long) { -// util.Long = Long as any; -// configure(); -// } diff --git a/build/libs/w3cache/v1/X25519KeyAgreementKeyEIP5630.json b/build/libs/w3cache/v1/X25519KeyAgreementKeyEIP5630.json new file mode 100644 index 0000000..a66852a --- /dev/null +++ b/build/libs/w3cache/v1/X25519KeyAgreementKeyEIP5630.json @@ -0,0 +1,36 @@ +{ + "@context": { + "id": "@id", + "type": "@type", + "@protected": true, + "proof": { + "@id": "https://w3id.org/security#proof", + "@type": "@id", + "@container": "@graph" + }, + "X25519KeyAgreementKeyEIP5630": { + "@id": "https://w3id.org/security#X25519KeyAgreementKeyEIP5630", + "@context": { + "@protected": true, + "id": "@id", + "type": "@type", + "controller": { + "@id": "https://w3id.org/security#controller", + "@type": "@id" + }, + "revoked": { + "@id": "https://w3id.org/security#revoked", + "@type": "http://www.w3.org/2001/XMLSchema#dateTime" + }, + "publicKeyMultibase": { + "@id": "https://w3id.org/security#publicKeyMultibase", + "@type": "https://w3id.org/security#multibase" + }, + "blockchainAccountId": { + "@id": "https://w3c.github.io/vc-data-integrity/vocab/security/vocabulary.jsonld#blockchainAccountId", + "@type": "https://w3id.org/security#blockchainAccountId" + } + } + } + } +} diff --git a/build/libs/w3cache/v1/credentialStatus.json b/build/libs/w3cache/v1/credentialStatus.json new file mode 100644 index 0000000..ea8b996 --- /dev/null +++ b/build/libs/w3cache/v1/credentialStatus.json @@ -0,0 +1,33 @@ +{ + "@context": { + "@protected": true, + "@version": 1.1, + "hypersign-vocab": "urn:uuid:13fe9318-bb82-4d95-8bf5-8e7fdf8b2026#", + "xsd": "http://www.w3.org/2001/XMLSchema#", + "id": "@id", + "revoked": { + "@id": "hypersign-vocab:revoked", + "@type": "xsd:boolean" + }, + "suspended": { + "@id": "hypersign-vocab:suspended", + "@type": "xsd:boolean" + }, + "remarks": { + "@id": "hypersign-vocab:remarks", + "@type": "xsd:string" + }, + "issuer": { + "@id": "hypersign-vocab:issuer", + "@type": "xsd:string" + }, + "issuanceDate": { + "@id": "hypersign-vocab:issuanceDate", + "@type": "xsd:dateTime" + }, + "credentialMerkleRootHash": { + "@id": "hypersign-vocab:credentialMerkleRootHash", + "@type": "xsd:string" + } + } +} diff --git a/build/libs/w3cache/v1/credential_schema.json b/build/libs/w3cache/v1/credential_schema.json new file mode 100644 index 0000000..cfada75 --- /dev/null +++ b/build/libs/w3cache/v1/credential_schema.json @@ -0,0 +1,47 @@ +{ + "@context": { + "@version": 1.1, + "hypersign-vocab": "urn:uuid:13fe9318-bb82-4d95-8bf5-8e7fdf8b2026#", + "xsd": "http://www.w3.org/2001/XMLSchema#", + "id": "@id", + "type": { + "@id": "hypersign-vocab:type" + }, + "modelVersion": { + "@id": "hypersign-vocab:modelVersion", + "@type": "xsd:string" + }, + "name": { + "@id": "hypersign-vocab:name", + "@type": "xsd:string" + }, + "author": { + "@id": "hypersign-vocab:author", + "@type": "xsd:string" + }, + "authored": { + "@id": "hypersign-vocab:authored", + "@type": "xsd:dateTime" + }, + "schema": { + "@id": "hypersign-vocab:schema", + "@type": "xsd:string" + }, + "additionalProperties": { + "@id": "hypersign-vocab:additionalProperties", + "@type": "xsd:boolean" + }, + "description": { + "@id": "hypersign-vocab:description", + "@type": "xsd:string" + }, + "properties": { + "@id": "hypersign-vocab:properties", + "@type": "xsd:string" + }, + "required": { + "@id": "hypersign-vocab:required", + "@container": "@set" + } + } +} diff --git a/build/libs/w3cache/v1/credentials.json b/build/libs/w3cache/v1/credentials.json index abd36f3..05be100 100644 --- a/build/libs/w3cache/v1/credentials.json +++ b/build/libs/w3cache/v1/credentials.json @@ -21,20 +21,46 @@ "@version": 1.1, "@protected": true, "id": "@id", - "type": "@type", - "cred": "https://www.w3.org/2018/credentials#", - "JsonSchemaValidator2018": "cred:JsonSchemaValidator2018" + "type": "https://www.w3.org/2018/credentials#JsonSchemaValidator2018" } }, - "credentialStatus": { "@id": "cred:credentialStatus", "@type": "@id" }, - "credentialSubject": { "@id": "cred:credentialSubject", "@type": "@id" }, - "evidence": { "@id": "cred:evidence", "@type": "@id" }, - "expirationDate": { "@id": "cred:expirationDate", "@type": "xsd:dateTime" }, - "holder": { "@id": "cred:holder", "@type": "@id" }, - "issued": { "@id": "cred:issued", "@type": "xsd:dateTime" }, - "issuer": { "@id": "cred:issuer", "@type": "@id" }, - "issuanceDate": { "@id": "cred:issuanceDate", "@type": "xsd:dateTime" }, - "proof": { "@id": "sec:proof", "@type": "@id", "@container": "@graph" }, + "credentialStatus": { + "@id": "cred:credentialStatus", + "@type": "@id" + }, + "credentialSubject": { + "@id": "cred:credentialSubject", + "@type": "@id" + }, + "evidence": { + "@id": "cred:evidence", + "@type": "@id" + }, + "expirationDate": { + "@id": "cred:expirationDate", + "@type": "xsd:dateTime" + }, + "holder": { + "@id": "cred:holder", + "@type": "@id" + }, + "issued": { + "@id": "cred:issued", + "@type": "xsd:dateTime" + }, + "issuer": { + "@id": "cred:issuer", + "@type": "@id" + }, + "issuanceDate": { + "@id": "cred:issuanceDate", + "@type": "xsd:dateTime" + }, + "proof": { + "@id": "sec:proof", + "@type": "@id", + "@container": "@graph" + }, "refreshService": { "@id": "cred:refreshService", "@type": "@id", @@ -47,9 +73,18 @@ "ManualRefreshService2018": "cred:ManualRefreshService2018" } }, - "termsOfUse": { "@id": "cred:termsOfUse", "@type": "@id" }, - "validFrom": { "@id": "cred:validFrom", "@type": "xsd:dateTime" }, - "validUntil": { "@id": "cred:validUntil", "@type": "xsd:dateTime" } + "termsOfUse": { + "@id": "cred:termsOfUse", + "@type": "@id" + }, + "validFrom": { + "@id": "cred:validFrom", + "@type": "xsd:dateTime" + }, + "validUntil": { + "@id": "cred:validUntil", + "@type": "xsd:dateTime" + } } }, "VerifiablePresentation": { @@ -61,9 +96,20 @@ "type": "@type", "cred": "https://www.w3.org/2018/credentials#", "sec": "https://w3id.org/security#", - "holder": { "@id": "cred:holder", "@type": "@id" }, - "proof": { "@id": "sec:proof", "@type": "@id", "@container": "@graph" }, - "verifiableCredential": { "@id": "cred:verifiableCredential", "@type": "@id", "@container": "@graph" } + "holder": { + "@id": "cred:holder", + "@type": "@id" + }, + "proof": { + "@id": "sec:proof", + "@type": "@id", + "@container": "@graph" + }, + "verifiableCredential": { + "@id": "cred:verifiableCredential", + "@type": "@id", + "@container": "@graph" + } } }, "EcdsaSecp256k1Signature2019": { @@ -76,9 +122,15 @@ "sec": "https://w3id.org/security#", "xsd": "http://www.w3.org/2001/XMLSchema#", "challenge": "sec:challenge", - "created": { "@id": "http://purl.org/dc/terms/created", "@type": "xsd:dateTime" }, + "created": { + "@id": "http://purl.org/dc/terms/created", + "@type": "xsd:dateTime" + }, "domain": "sec:domain", - "expires": { "@id": "sec:expiration", "@type": "xsd:dateTime" }, + "expires": { + "@id": "sec:expiration", + "@type": "xsd:dateTime" + }, "jws": "sec:jws", "nonce": "sec:nonce", "proofPurpose": { @@ -90,12 +142,23 @@ "id": "@id", "type": "@type", "sec": "https://w3id.org/security#", - "assertionMethod": { "@id": "sec:assertionMethod", "@type": "@id", "@container": "@set" }, - "authentication": { "@id": "sec:authenticationMethod", "@type": "@id", "@container": "@set" } + "assertionMethod": { + "@id": "sec:assertionMethod", + "@type": "@id", + "@container": "@set" + }, + "authentication": { + "@id": "sec:authenticationMethod", + "@type": "@id", + "@container": "@set" + } } }, "proofValue": "sec:proofValue", - "verificationMethod": { "@id": "sec:verificationMethod", "@type": "@id" } + "verificationMethod": { + "@id": "sec:verificationMethod", + "@type": "@id" + } } }, "EcdsaSecp256r1Signature2019": { @@ -108,9 +171,15 @@ "sec": "https://w3id.org/security#", "xsd": "http://www.w3.org/2001/XMLSchema#", "challenge": "sec:challenge", - "created": { "@id": "http://purl.org/dc/terms/created", "@type": "xsd:dateTime" }, + "created": { + "@id": "http://purl.org/dc/terms/created", + "@type": "xsd:dateTime" + }, "domain": "sec:domain", - "expires": { "@id": "sec:expiration", "@type": "xsd:dateTime" }, + "expires": { + "@id": "sec:expiration", + "@type": "xsd:dateTime" + }, "jws": "sec:jws", "nonce": "sec:nonce", "proofPurpose": { @@ -122,12 +191,23 @@ "id": "@id", "type": "@type", "sec": "https://w3id.org/security#", - "assertionMethod": { "@id": "sec:assertionMethod", "@type": "@id", "@container": "@set" }, - "authentication": { "@id": "sec:authenticationMethod", "@type": "@id", "@container": "@set" } + "assertionMethod": { + "@id": "sec:assertionMethod", + "@type": "@id", + "@container": "@set" + }, + "authentication": { + "@id": "sec:authenticationMethod", + "@type": "@id", + "@container": "@set" + } } }, "proofValue": "sec:proofValue", - "verificationMethod": { "@id": "sec:verificationMethod", "@type": "@id" } + "verificationMethod": { + "@id": "sec:verificationMethod", + "@type": "@id" + } } }, "Ed25519Signature2018": { @@ -140,9 +220,15 @@ "sec": "https://w3id.org/security#", "xsd": "http://www.w3.org/2001/XMLSchema#", "challenge": "sec:challenge", - "created": { "@id": "http://purl.org/dc/terms/created", "@type": "xsd:dateTime" }, + "created": { + "@id": "http://purl.org/dc/terms/created", + "@type": "xsd:dateTime" + }, "domain": "sec:domain", - "expires": { "@id": "sec:expiration", "@type": "xsd:dateTime" }, + "expires": { + "@id": "sec:expiration", + "@type": "xsd:dateTime" + }, "jws": "sec:jws", "nonce": "sec:nonce", "proofPurpose": { @@ -154,12 +240,23 @@ "id": "@id", "type": "@type", "sec": "https://w3id.org/security#", - "assertionMethod": { "@id": "sec:assertionMethod", "@type": "@id", "@container": "@set" }, - "authentication": { "@id": "sec:authenticationMethod", "@type": "@id", "@container": "@set" } + "assertionMethod": { + "@id": "sec:assertionMethod", + "@type": "@id", + "@container": "@set" + }, + "authentication": { + "@id": "sec:authenticationMethod", + "@type": "@id", + "@container": "@set" + } } }, "proofValue": "sec:proofValue", - "verificationMethod": { "@id": "sec:verificationMethod", "@type": "@id" } + "verificationMethod": { + "@id": "sec:verificationMethod", + "@type": "@id" + } } }, "RsaSignature2018": { @@ -168,9 +265,15 @@ "@version": 1.1, "@protected": true, "challenge": "sec:challenge", - "created": { "@id": "http://purl.org/dc/terms/created", "@type": "xsd:dateTime" }, + "created": { + "@id": "http://purl.org/dc/terms/created", + "@type": "xsd:dateTime" + }, "domain": "sec:domain", - "expires": { "@id": "sec:expiration", "@type": "xsd:dateTime" }, + "expires": { + "@id": "sec:expiration", + "@type": "xsd:dateTime" + }, "jws": "sec:jws", "nonce": "sec:nonce", "proofPurpose": { @@ -182,14 +285,29 @@ "id": "@id", "type": "@type", "sec": "https://w3id.org/security#", - "assertionMethod": { "@id": "sec:assertionMethod", "@type": "@id", "@container": "@set" }, - "authentication": { "@id": "sec:authenticationMethod", "@type": "@id", "@container": "@set" } + "assertionMethod": { + "@id": "sec:assertionMethod", + "@type": "@id", + "@container": "@set" + }, + "authentication": { + "@id": "sec:authenticationMethod", + "@type": "@id", + "@container": "@set" + } } }, "proofValue": "sec:proofValue", - "verificationMethod": { "@id": "sec:verificationMethod", "@type": "@id" } + "verificationMethod": { + "@id": "sec:verificationMethod", + "@type": "@id" + } } }, - "proof": { "@id": "https://w3id.org/security#proof", "@type": "@id", "@container": "@graph" } + "proof": { + "@id": "https://w3id.org/security#proof", + "@type": "@id", + "@container": "@graph" + } } } diff --git a/build/libs/w3cache/v1/hypersignCredentialStatus2023.json b/build/libs/w3cache/v1/hypersignCredentialStatus2023.json new file mode 100644 index 0000000..0a2f54e --- /dev/null +++ b/build/libs/w3cache/v1/hypersignCredentialStatus2023.json @@ -0,0 +1,14 @@ +{ + "@context": { + "@protected": true, + "hypersign-vocab": "urn:uuid:13fe9318-bb82-4d95-8bf5-8e7fdf8b2026#", + "HypersignCredentialStatus2023": { + "@id": "hypersign-vocab:HypersignCredentialStatus2023", + "@context": { + "@protected": true, + "id": "@id", + "type": "@type" + } + } + } +} diff --git a/build/libs/w3cache/v1/index.d.ts.map b/build/libs/w3cache/v1/index.d.ts.map index 099230d..4e87354 100644 --- a/build/libs/w3cache/v1/index.d.ts.map +++ b/build/libs/w3cache/v1/index.d.ts.map @@ -1 +1 @@ -{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../libs/w3cache/v1/index.ts"],"names":[],"mappings":";AAgDA,wBAUE"} \ No newline at end of file +{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../libs/w3cache/v1/index.ts"],"names":[],"mappings":";AA6MA,wBAUE"} \ No newline at end of file diff --git a/build/libs/w3cache/v1/index.js b/build/libs/w3cache/v1/index.js index 53fcac9..4e0a878 100644 --- a/build/libs/w3cache/v1/index.js +++ b/build/libs/w3cache/v1/index.js @@ -21,34 +21,182 @@ const vc_data_integrety_json_1 = __importDefault(require("./vc-data-integrety.js const lds_ecdsa_secp256k1_recovery2020_json_1 = __importDefault(require("./lds-ecdsa-secp256k1-recovery2020.json")); const schema_org_json_1 = __importDefault(require("./schema_org.json")); const x25519_key_agreement_2020_v1_json_1 = __importDefault(require("./x25519-key-agreement-2020-v1.json")); +const X25519KeyAgreementKeyEIP5630_json_1 = __importDefault(require("./X25519KeyAgreementKeyEIP5630.json")); +const credentialStatus_json_1 = __importDefault(require("./credentialStatus.json")); +const credential_schema_json_1 = __importDefault(require("./credential_schema.json")); +const hypersignCredentialStatus2023_json_1 = __importDefault(require("./hypersignCredentialStatus2023.json")); // Ref: https://github.com/digitalbazaar/jsonld.js/#custom-document-loader let nodeDocumentLoader; if (typeof window === 'undefined') { - nodeDocumentLoader = jsonld_1.default.documentLoaders.node(); + nodeDocumentLoader = jsonld_1.default.documentLoaders.node; } else { - nodeDocumentLoader = jsonld_1.default.documentLoaders.xhr(); + nodeDocumentLoader = jsonld_1.default.documentLoaders.xhr; } const did_wellknown_json_1 = __importDefault(require("./did-wellknown.json")); const CONTEXTS = Object.freeze({ - "https://www.w3.org/ns/did/v1": Object.assign({}, did_json_1.default), - "https://w3id.org/security/suites/ed25519-2020/v1": Object.assign({}, ed25519_signature_2020_json_1.default), - "https://w3id.org/security/v2": Object.assign({}, security_v2_json_1.default), - "https://www.w3.org/2018/credentials/v1": Object.assign({}, credentials_json_1.default), - "https://w3c.github.io/vc-data-integrity/vocab/security/vocabulary.jsonld": Object.assign({}, vc_data_integrety_json_1.default), - "https://w3id.org/security/suites/secp256k1recovery-2020/v2": Object.assign({}, lds_ecdsa_secp256k1_recovery2020_json_1.default), - "https://schema.org": Object.assign({}, schema_org_json_1.default), - "https://digitalbazaar.github.io/x25519-key-agreement-2020-context/contexts/x25519-key-agreement-2020-v1.jsonld": Object.assign({}, x25519_key_agreement_2020_v1_json_1.default), - "https://identity.foundation/.well-known/did-configuration/v1": Object.assign({}, did_wellknown_json_1.default) + 'https://www.w3.org/ns/did/v1': Object.assign({}, did_json_1.default), + 'https://w3id.org/security/suites/ed25519-2020/v1': Object.assign({}, ed25519_signature_2020_json_1.default), + 'https://w3id.org/security/v2': Object.assign({}, security_v2_json_1.default), + 'https://www.w3.org/2018/credentials/v1': Object.assign({}, credentials_json_1.default), + 'https://w3c.github.io/vc-data-integrity/vocab/security/vocabulary.jsonld': Object.assign({}, vc_data_integrety_json_1.default), + 'https://w3id.org/security/suites/secp256k1recovery-2020/v2': Object.assign({}, lds_ecdsa_secp256k1_recovery2020_json_1.default), + 'https://schema.org': Object.assign({}, schema_org_json_1.default), + 'https://ns.did.ai/suites/x25519-2020/v1': Object.assign({}, x25519_key_agreement_2020_v1_json_1.default), + 'https://identity.foundation/.well-known/did-configuration/v1': Object.assign({}, did_wellknown_json_1.default), + 'https://raw.githubusercontent.com/hypersign-protocol/hypersign-contexts/main/BabyJubJubKey2021.jsonld': { + '@context': { + id: '@id', + type: '@type', + '@protected': true, + 'hypersign-vocab': 'urn:uuid:13fe9318-bb82-4d95-8bf5-8e7fdf8b2026#', + BabyJubJubKey2021: { + '@id': 'hypersign-vocab:BabyJubJubKey2021', + '@context': { + id: '@id', + type: '@type', + controller: { + '@id': 'https://w3id.org/security#controller', + '@type': '@id', + }, + publicKeyMultibase: { + '@id': 'https://w3id.org/security#publicKeyMultibase', + '@type': 'https://w3id.org/security#multibase', + }, + }, + }, + }, + }, + 'https://raw.githubusercontent.com/hypersign-protocol/hypersign-contexts/main/X25519KeyAgreementKeyEIP5630.jsonld': Object.assign({}, X25519KeyAgreementKeyEIP5630_json_1.default), + 'https://raw.githubusercontent.com/hypersign-protocol/hypersign-contexts/main/CredentialStatus.jsonld': Object.assign({}, credentialStatus_json_1.default), + 'https://raw.githubusercontent.com/hypersign-protocol/hypersign-contexts/main/CredentialSchema.jsonld': Object.assign({}, credential_schema_json_1.default), + 'https://raw.githubusercontent.com/hypersign-protocol/hypersign-contexts/main/HypersignCredentialStatus2023.jsonld': Object.assign({}, hypersignCredentialStatus2023_json_1.default), + 'https://raw.githubusercontent.com/hypersign-protocol/hypersign-contexts/main/BJJSignature2021.jsonld': { + '@context': { + '@version': 1.1, + id: '@id', + type: '@type', + proof: { + '@id': 'https://w3id.org/security#proof', + '@type': '@id', + '@container': '@graph', + }, + BJJSignature2021: { + '@id': 'https://w3id.org/security#BJJSignature2021', + '@context': { + '@version': 1.1, + '@protected': true, + id: '@id', + type: '@type', + challenge: 'https://w3id.org/security#challenge', + created: { + '@id': 'http://purl.org/dc/terms/created', + '@type': 'http://www.w3.org/2001/XMLSchema#dateTime', + }, + domain: 'https://w3id.org/security#domain', + proofValue: 'https://w3id.org/security#proofValue', + credentialRoot: 'https://w3id.org/security#credentialRoot', + nonce: 'https://w3id.org/security#nonce', + proofPurpose: { + '@id': 'https://w3id.org/security#proofPurpose', + '@type': '@vocab', + '@context': { + '@version': 1.1, + '@protected': true, + id: '@id', + type: '@type', + assertionMethod: { + '@id': 'https://w3id.org/security#assertionMethod', + '@type': '@id', + '@container': '@set', + }, + authentication: { + '@id': 'https://w3id.org/security#authenticationMethod', + '@type': '@id', + '@container': '@set', + }, + }, + }, + verificationMethod: { + '@id': 'https://w3id.org/security#verificationMethod', + '@type': '@id', + }, + }, + }, + BabyJubJubSignatureProof2021: { + '@id': 'https://w3id.org/security#BabyJubJubSignatureProof2021', + '@context': { + '@version': 1.1, + '@protected': true, + id: '@id', + type: '@type', + challenge: 'https://w3id.org/security#challenge', + created: { + '@id': 'http://purl.org/dc/terms/created', + '@type': 'http://www.w3.org/2001/XMLSchema#dateTime', + }, + domain: 'https://w3id.org/security#domain', + nonce: 'https://w3id.org/security#nonce', + proofPurpose: { + '@id': 'https://w3id.org/security#proofPurpose', + '@type': '@vocab', + '@context': { + '@version': 1.1, + '@protected': true, + id: '@id', + type: '@type', + sec: 'https://w3id.org/security#', + assertionMethod: { + '@id': 'https://w3id.org/security#assertionMethod', + '@type': '@id', + '@container': '@set', + }, + authentication: { + '@id': 'https://w3id.org/security#authenticationMethod', + '@type': '@id', + '@container': '@set', + }, + }, + }, + proofValue: 'https://w3id.org/security#proofValue', + credentialRoot: 'https://w3id.org/security#credentialRoot', + verificationMethod: { + '@id': 'https://w3id.org/security#verificationMethod', + '@type': '@id', + }, + }, + }, + }, + }, + 'https://raw.githubusercontent.com/hypersign-protocol/hypersign-contexts/main/LinkedDomains.jsonld': { + '@context': { + '@protected': true, + id: '@id', + type: '@type', + LinkedDomains: { + '@id': 'https://www.w3.org/ns/did#LinkedDomains', + '@type': '@id', + '@context': { + '@protected': true, + id: '@id', + type: '@type', + serviceEndpoint: { + '@id': 'https://www.w3.org/ns/did#serviceEndpoint', + '@type': '@id', + }, + }, + }, + }, + }, }); exports.default = (url, options) => __awaiter(void 0, void 0, void 0, function* () { if (url in CONTEXTS) { return { contextUrl: null, document: CONTEXTS[url], - documentUrl: url // this is the actual context URL after redirects + documentUrl: url, // this is the actual context URL after redirects }; } - // call the default documentLoader + // call the default documentLoader return nodeDocumentLoader(url); }); diff --git a/build/src/constants.d.ts b/build/src/constants.d.ts index 9a5f718..130fceb 100644 --- a/build/src/constants.d.ts +++ b/build/src/constants.d.ts @@ -1,19 +1,21 @@ +import { ProofTypes, VerificationMethodRelationships, VerificationMethodTypes } from '../libs/generated/ssi/client/enums'; export declare const compactProof = false; export declare const HYPERSIGN_TESTNET_RPC = "https://rpc.jagrat.hypersign.id"; export declare const HYPERSIGN_TESTNET_REST = "https://api.jagrat.hypersign.id"; export declare const HYPERSIGN_MAINNET_RPC = "http://localhost:26657"; export declare const HYPERSIGN_MAINNET_REST = "http://localhost:1317"; -export declare const HID_COSMOS_MODULE = "/hypersignprotocol.hidnode.ssi"; +export declare const HID_COSMOS_MODULE = "/hypersign.ssi.v1"; export declare const HYPERSIGN_NETWORK_DID_PATH = "hypersign-protocol/hidnode/ssi/did"; export declare const HYPERSIGN_NETWORK_SCHEMA_PATH = "hypersign-protocol/hidnode/ssi/schema"; export declare const HYPERSIGN_NETWORK_CREDENTIALSTATUS_PATH = "hypersign-protocol/hidnode/ssi/credential"; export declare const HYPERSIGN_NETWORK_BANK_BALANCE_PATH = "/bank/balances/"; export declare enum HIDRpcEnums { - MsgCreateDID = "MsgCreateDID", + MsgRegisterDID = "MsgRegisterDID", MsgUpdateDID = "MsgUpdateDID", MsgDeactivateDID = "MsgDeactivateDID", - MsgCreateSchema = "MsgCreateSchema", - MsgRegisterCredentialStatus = "MsgRegisterCredentialStatus" + MsgRegisterCredentialSchema = "MsgRegisterCredentialSchema", + MsgRegisterCredentialStatus = "MsgRegisterCredentialStatus", + MsgUpdateCredentialStatus = "MsgUpdateCredentialStatus" } export declare enum CredentialStatusEnums { LIVE = "Live", @@ -32,8 +34,10 @@ export declare const DID_Ed25519VerificationKey2020: { NAMESPACE: string; DID_BASE_CONTEXT: string; DID_KEYAGREEMENT_CONTEXT: string; + DID_Ed25519_CONTEXT_2020: string; VERIFICATION_METHOD_TYPE: string; BLOCKCHAINACCOUNTID_CONTEXT: string; + SIGNATURE_TYPE: ProofTypes; }; export declare const DID_EcdsaSecp256k1RecoveryMethod2020: { CONTROLLER_CONTEXT: string; @@ -43,7 +47,9 @@ export declare const DID_EcdsaSecp256k1RecoveryMethod2020: { DID_BASE_CONTEXT: string; DID_KEYAGREEMENT_CONTEXT: string; BLOCKCHAINACCOUNTID_CONTEXT: string; - VERIFICATION_METHOD_TYPE: string; + SECP256K12020_RECOVERY_CONTEXT: string; + VERIFICATION_METHOD_TYPE: VerificationMethodTypes; + SIGNATURE_TYPE: ProofTypes; }; export declare const DID_EcdsaSecp256k1VerificationKey2019: { CONTROLLER_CONTEXT: string; @@ -52,10 +58,25 @@ export declare const DID_EcdsaSecp256k1VerificationKey2019: { NAMESPACE: string; DID_BASE_CONTEXT: string; BLOCKCHAINACCOUNTID_CONTEXT: string; + SECP256K12020_VERIFICATION_CONTEXT: string; + VERIFICATION_METHOD_TYPE: VerificationMethodTypes; + SIGNATURE_TYPE: ProofTypes; +}; +export declare const DID_BabyJubJubKey2021: { + CONTROLLER_CONTEXT: string; + SCHEME: string; + METHOD: string; + NAMESPACE: string; + DID_BASE_CONTEXT: string; + DID_KEYAGREEMENT_CONTEXT: string; + DID_BABYJUBJUBKEY2021: string; + BABYJUBJUBSIGNATURE: string; VERIFICATION_METHOD_TYPE: string; + BLOCKCHAINACCOUNTID_CONTEXT: string; + SIGNATURE_TYPE: ProofTypes; }; export declare enum CAIP_10_PREFIX { - "eip155" = "eip155" + 'eip155' = "eip155" } export declare const DID: { CONTROLLER_CONTEXT: string; @@ -63,7 +84,7 @@ export declare const DID: { METHOD: string; NAMESPACE: string; DID_BASE_CONTEXT: string; - VERIFICATION_METHOD_TYPE: string; + VERIFICATION_METHOD_TYPE: VerificationMethodTypes; BLOCKCHAINACCOUNTID_CONTEXT: string; }; export declare const VC: { @@ -73,12 +94,14 @@ export declare const VC: { PREFIX: string; CREDENTAIL_SCHEMA_VALIDATOR_TYPE: string; CREDENTAIL_STATUS_TYPE: string; + CREDENTIAL_STATUS_CONTEXT: string; + CONTEXT_HypersignCredentialStatus2023: string; CREDENTAIL_BASE_CONTEXT: string; CREDENTAIL_SECURITY_CONTEXT_V2: string; - CREDENTAIL_SECURITY_SUITE: string; + CREDENTIAIL_SECURITY_SUITE: string; CREDENTAIL_ECDSA_SECURITY_SUITE: string; - PROOF_PURPOSE: string; - VERIFICATION_METHOD_TYPE: string; + PROOF_PURPOSE: VerificationMethodRelationships; + VERIFICATION_METHOD_TYPE: ProofTypes; CRED_STATUS_TYPES: typeof CredentialStatusEnums; CRED_STATUS_REASON_TYPES: typeof CredentialStatusReasonEnums; }; @@ -94,8 +117,9 @@ export declare const SCHEMA: { NAMESPACE: string; SCHEMA_JSON: string; SCHEMA_TYPE: string; - SIGNATURE_TYPE: string; - PROOF_PURPOSE: string; + SIGNATURE_TYPE: ProofTypes; + PROOF_PURPOSE: VerificationMethodRelationships; + SCHEMA_CONTEXT: string; }; export declare const KEY_HEADERS: { MULTICODEC_ED25519_PUB_HEADER: Uint8Array; @@ -106,4 +130,14 @@ export declare const HID_DECIMAL = 6; export declare const HID_DNOMINATION = "uhid"; export declare const HID_MIN_GAS = "200000"; export declare const HID_MIN_FEE = "5000"; +export declare const GAS_FEE_API_URL: (baseUrl: any) => string; +export declare const GAS_FEE_METHODS: { + Register_Did: string; + Update_Did: string; + Deactivate_Did: string; + Register_Cred_Schema: string; + Update_Cred_Schema: string; + Register_Cred_Status: string; + Update_Cred_Status: string; +}; //# sourceMappingURL=constants.d.ts.map \ No newline at end of file diff --git a/build/src/constants.d.ts.map b/build/src/constants.d.ts.map index be93795..b1e2644 100644 --- a/build/src/constants.d.ts.map +++ b/build/src/constants.d.ts.map @@ -1 +1 @@ -{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../src/constants.ts"],"names":[],"mappings":"AACA,eAAO,MAAM,YAAY,QAAQ,CAAC;AAElC,eAAO,MAAM,qBAAqB,oCAAoC,CAAC;AACvE,eAAO,MAAM,sBAAsB,oCAAoC,CAAC;AAExE,eAAO,MAAM,qBAAqB,2BAA2B,CAAC;AAC9D,eAAO,MAAM,sBAAsB,0BAA0B,CAAC;AAE9D,eAAO,MAAM,iBAAiB,mCAAmC,CAAC;AAClE,eAAO,MAAM,0BAA0B,uCAAuC,CAAC;AAC/E,eAAO,MAAM,6BAA6B,0CAA0C,CAAC;AACrF,eAAO,MAAM,uCAAuC,8CAA8C,CAAC;AACnG,eAAO,MAAM,mCAAmC,oBAAoB,CAAC;AAErE,oBAAY,WAAW;IACrB,YAAY,iBAAiB;IAC7B,YAAY,iBAAiB;IAC7B,gBAAgB,qBAAqB;IACrC,eAAe,oBAAoB;IACnC,2BAA2B,gCAAgC;CAC5D;AAGD,oBAAY,qBAAqB;IAE7B,IAAI,SAAS;IACb,OAAO,YAAU;IACjB,SAAS,cAAY;CACxB;AACD,oBAAY,2BAA2B;IACnC,IAAI,uBAAuB;IAC3B,OAAO,0BAAwB;IAC/B,SAAS,4BAA0B;CACtC;AAKD,eAAO,MAAM,8BAA8B;;;;;;;;;CAU1C,CAAC;AAGF,eAAO,MAAM,oCAAoC;;;;;;;;;CAShD,CAAC;AAIF,eAAO,MAAM,qCAAqC;;;;;;;;CAQjD,CAAC;AAGF,oBAAY,cAAc;IACxB,QAAQ,WAAS;CAClB;AAGD,eAAO,MAAM,GAAG;;;;;;;;CASf,CAAC;AAIF,eAAO,MAAM,EAAE;;;;;;;;;;;;;;;CAiBd,CAAA;AAGD,eAAO,MAAM,EAAE;;;;;CAKd,CAAC;AAGF,eAAO,MAAM,MAAM;;;;;;;;CAQlB,CAAC;AAGF,eAAO,MAAM,WAAW;;;CAGvB,CAAC;AAGF,eAAO,MAAM,SAAS,QAAQ,CAAC;AAC/B,eAAO,MAAM,WAAW,IAAI,CAAC;AAC7B,eAAO,MAAM,eAAe,SAAS,CAAC;AACtC,eAAO,MAAM,WAAW,WAAW,CAAC;AACpC,eAAO,MAAM,WAAW,SAAS,CAAC"} \ No newline at end of file +{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../src/constants.ts"],"names":[],"mappings":"AACA,OAAO,EACL,UAAU,EACV,+BAA+B,EAC/B,uBAAuB,EACxB,MAAM,oCAAoC,CAAC;AAC5C,eAAO,MAAM,YAAY,QAAQ,CAAC;AAElC,eAAO,MAAM,qBAAqB,oCAAoC,CAAC;AACvE,eAAO,MAAM,sBAAsB,oCAAoC,CAAC;AAExE,eAAO,MAAM,qBAAqB,2BAA2B,CAAC;AAC9D,eAAO,MAAM,sBAAsB,0BAA0B,CAAC;AAE9D,eAAO,MAAM,iBAAiB,sBAAsB,CAAC;AACrD,eAAO,MAAM,0BAA0B,uCAAuC,CAAC;AAC/E,eAAO,MAAM,6BAA6B,0CAA0C,CAAC;AACrF,eAAO,MAAM,uCAAuC,8CAA8C,CAAC;AACnG,eAAO,MAAM,mCAAmC,oBAAoB,CAAC;AAErE,oBAAY,WAAW;IACrB,cAAc,mBAAmB;IACjC,YAAY,iBAAiB;IAC7B,gBAAgB,qBAAqB;IACrC,2BAA2B,gCAAgC;IAC3D,2BAA2B,gCAAgC;IAC3D,yBAAyB,8BAA8B;CACxD;AAGD,oBAAY,qBAAqB;IAC/B,IAAI,SAAS;IACb,OAAO,YAAY;IACnB,SAAS,cAAc;CACxB;AACD,oBAAY,2BAA2B;IACrC,IAAI,uBAAuB;IAC3B,OAAO,0BAA0B;IACjC,SAAS,4BAA4B;CACtC;AAED,eAAO,MAAM,8BAA8B;;;;;;;;;;;CAW1C,CAAC;AAEF,eAAO,MAAM,oCAAoC;;;;;;;;;;;CAYhD,CAAC;AAEF,eAAO,MAAM,qCAAqC;;;;;;;;;;CAUjD,CAAC;AAEF,eAAO,MAAM,qBAAqB;;;;;;;;;;;;CAejC,CAAC;AAEF,oBAAY,cAAc;IACxB,QAAQ,WAAW;CACpB;AAED,eAAO,MAAM,GAAG;;;;;;;;CAQf,CAAC;AAIF,eAAO,MAAM,EAAE;;;;;;;;;;;;;;;;;CAmBd,CAAC;AAGF,eAAO,MAAM,EAAE;;;;;CAKd,CAAC;AAGF,eAAO,MAAM,MAAM;;;;;;;;;CAUlB,CAAC;AAGF,eAAO,MAAM,WAAW;;;CAGvB,CAAC;AAGF,eAAO,MAAM,SAAS,QAAQ,CAAC;AAC/B,eAAO,MAAM,WAAW,IAAI,CAAC;AAC7B,eAAO,MAAM,eAAe,SAAS,CAAC;AACtC,eAAO,MAAM,WAAW,WAAW,CAAC;AACpC,eAAO,MAAM,WAAW,SAAS,CAAC;AAIlC,eAAO,MAAM,eAAe,0BAA8E,CAAA;AAC1G,eAAO,MAAM,eAAe;;;;;;;;CAS3B,CAAA"} \ No newline at end of file diff --git a/build/src/constants.js b/build/src/constants.js index 3313cb6..bb4770f 100644 --- a/build/src/constants.js +++ b/build/src/constants.js @@ -1,23 +1,25 @@ 'use strict'; Object.defineProperty(exports, "__esModule", { value: true }); -exports.HID_MIN_FEE = exports.HID_MIN_GAS = exports.HID_DNOMINATION = exports.HID_DECIMAL = exports.GAS_PRICE = exports.KEY_HEADERS = exports.SCHEMA = exports.VP = exports.VC = exports.DID = exports.CAIP_10_PREFIX = exports.DID_EcdsaSecp256k1VerificationKey2019 = exports.DID_EcdsaSecp256k1RecoveryMethod2020 = exports.DID_Ed25519VerificationKey2020 = exports.CredentialStatusReasonEnums = exports.CredentialStatusEnums = exports.HIDRpcEnums = exports.HYPERSIGN_NETWORK_BANK_BALANCE_PATH = exports.HYPERSIGN_NETWORK_CREDENTIALSTATUS_PATH = exports.HYPERSIGN_NETWORK_SCHEMA_PATH = exports.HYPERSIGN_NETWORK_DID_PATH = exports.HID_COSMOS_MODULE = exports.HYPERSIGN_MAINNET_REST = exports.HYPERSIGN_MAINNET_RPC = exports.HYPERSIGN_TESTNET_REST = exports.HYPERSIGN_TESTNET_RPC = exports.compactProof = void 0; +exports.GAS_FEE_METHODS = exports.GAS_FEE_API_URL = exports.HID_MIN_FEE = exports.HID_MIN_GAS = exports.HID_DNOMINATION = exports.HID_DECIMAL = exports.GAS_PRICE = exports.KEY_HEADERS = exports.SCHEMA = exports.VP = exports.VC = exports.DID = exports.CAIP_10_PREFIX = exports.DID_BabyJubJubKey2021 = exports.DID_EcdsaSecp256k1VerificationKey2019 = exports.DID_EcdsaSecp256k1RecoveryMethod2020 = exports.DID_Ed25519VerificationKey2020 = exports.CredentialStatusReasonEnums = exports.CredentialStatusEnums = exports.HIDRpcEnums = exports.HYPERSIGN_NETWORK_BANK_BALANCE_PATH = exports.HYPERSIGN_NETWORK_CREDENTIALSTATUS_PATH = exports.HYPERSIGN_NETWORK_SCHEMA_PATH = exports.HYPERSIGN_NETWORK_DID_PATH = exports.HID_COSMOS_MODULE = exports.HYPERSIGN_MAINNET_REST = exports.HYPERSIGN_MAINNET_RPC = exports.HYPERSIGN_TESTNET_REST = exports.HYPERSIGN_TESTNET_RPC = exports.compactProof = void 0; +const enums_1 = require("../libs/generated/ssi/client/enums"); exports.compactProof = false; exports.HYPERSIGN_TESTNET_RPC = 'https://rpc.jagrat.hypersign.id'; exports.HYPERSIGN_TESTNET_REST = 'https://api.jagrat.hypersign.id'; exports.HYPERSIGN_MAINNET_RPC = 'http://localhost:26657'; exports.HYPERSIGN_MAINNET_REST = 'http://localhost:1317'; -exports.HID_COSMOS_MODULE = '/hypersignprotocol.hidnode.ssi'; +exports.HID_COSMOS_MODULE = '/hypersign.ssi.v1'; exports.HYPERSIGN_NETWORK_DID_PATH = 'hypersign-protocol/hidnode/ssi/did'; exports.HYPERSIGN_NETWORK_SCHEMA_PATH = 'hypersign-protocol/hidnode/ssi/schema'; exports.HYPERSIGN_NETWORK_CREDENTIALSTATUS_PATH = 'hypersign-protocol/hidnode/ssi/credential'; exports.HYPERSIGN_NETWORK_BANK_BALANCE_PATH = '/bank/balances/'; var HIDRpcEnums; (function (HIDRpcEnums) { - HIDRpcEnums["MsgCreateDID"] = "MsgCreateDID"; + HIDRpcEnums["MsgRegisterDID"] = "MsgRegisterDID"; HIDRpcEnums["MsgUpdateDID"] = "MsgUpdateDID"; HIDRpcEnums["MsgDeactivateDID"] = "MsgDeactivateDID"; - HIDRpcEnums["MsgCreateSchema"] = "MsgCreateSchema"; + HIDRpcEnums["MsgRegisterCredentialSchema"] = "MsgRegisterCredentialSchema"; HIDRpcEnums["MsgRegisterCredentialStatus"] = "MsgRegisterCredentialStatus"; + HIDRpcEnums["MsgUpdateCredentialStatus"] = "MsgUpdateCredentialStatus"; })(HIDRpcEnums = exports.HIDRpcEnums || (exports.HIDRpcEnums = {})); Object.freeze(HIDRpcEnums); var CredentialStatusEnums; @@ -38,9 +40,11 @@ exports.DID_Ed25519VerificationKey2020 = { METHOD: 'hid', NAMESPACE: 'testnet', DID_BASE_CONTEXT: 'https://www.w3.org/ns/did/v1', - DID_KEYAGREEMENT_CONTEXT: "https://digitalbazaar.github.io/x25519-key-agreement-2020-context/contexts/x25519-key-agreement-2020-v1.jsonld", + DID_KEYAGREEMENT_CONTEXT: 'https://ns.did.ai/suites/x25519-2020/v1', + DID_Ed25519_CONTEXT_2020: 'https://w3id.org/security/suites/ed25519-2020/v1', VERIFICATION_METHOD_TYPE: 'Ed25519VerificationKey2020', BLOCKCHAINACCOUNTID_CONTEXT: 'https://w3c.github.io/vc-data-integrity/vocab/security/vocabulary.jsonld', + SIGNATURE_TYPE: enums_1.ProofTypes.Ed25519Signature2020, }; exports.DID_EcdsaSecp256k1RecoveryMethod2020 = { CONTROLLER_CONTEXT: 'https://w3id.org/security/v2', @@ -48,9 +52,11 @@ exports.DID_EcdsaSecp256k1RecoveryMethod2020 = { METHOD: 'hid', NAMESPACE: 'testnet', DID_BASE_CONTEXT: 'https://www.w3.org/ns/did/v1', - DID_KEYAGREEMENT_CONTEXT: "https://github.com/hypersign-protocol/hid-ssi-js-sdk/blob/develop/libs/w3cache/v1/X25519KeyAgreementKeyEIP5630.json", + DID_KEYAGREEMENT_CONTEXT: 'https://raw.githubusercontent.com/hypersign-protocol/hypersign-contexts/main/X25519KeyAgreementKeyEIP5630.jsonld', BLOCKCHAINACCOUNTID_CONTEXT: 'https://w3c.github.io/vc-data-integrity/vocab/security/vocabulary.jsonld', - VERIFICATION_METHOD_TYPE: 'EcdsaSecp256k1RecoveryMethod2020', + SECP256K12020_RECOVERY_CONTEXT: 'https://ns.did.ai/suites/secp256k1-2020/v1', + VERIFICATION_METHOD_TYPE: enums_1.VerificationMethodTypes.EcdsaSecp256k1RecoveryMethod2020, + SIGNATURE_TYPE: enums_1.ProofTypes.EcdsaSecp256k1RecoverySignature2020, }; exports.DID_EcdsaSecp256k1VerificationKey2019 = { CONTROLLER_CONTEXT: 'https://w3id.org/security/v2', @@ -59,7 +65,22 @@ exports.DID_EcdsaSecp256k1VerificationKey2019 = { NAMESPACE: 'testnet', DID_BASE_CONTEXT: 'https://www.w3.org/ns/did/v1', BLOCKCHAINACCOUNTID_CONTEXT: 'https://w3c.github.io/vc-data-integrity/vocab/security/vocabulary.jsonld', - VERIFICATION_METHOD_TYPE: 'EcdsaSecp256k1VerificationKey2019', + SECP256K12020_VERIFICATION_CONTEXT: 'https://ns.did.ai/suites/secp256k1-2019/v1', + VERIFICATION_METHOD_TYPE: enums_1.VerificationMethodTypes.EcdsaSecp256k1VerificationKey2019, + SIGNATURE_TYPE: enums_1.ProofTypes.EcdsaSecp256k1Signature2019, +}; +exports.DID_BabyJubJubKey2021 = { + CONTROLLER_CONTEXT: 'https://w3id.org/security/v2', + SCHEME: 'did', + METHOD: 'hid', + NAMESPACE: 'testnet', + DID_BASE_CONTEXT: 'https://www.w3.org/ns/did/v1', + DID_KEYAGREEMENT_CONTEXT: 'https://ns.did.ai/suites/x25519-2020/v1', + DID_BABYJUBJUBKEY2021: 'https://raw.githubusercontent.com/hypersign-protocol/hypersign-contexts/main/BabyJubJubKey2021.jsonld', + BABYJUBJUBSIGNATURE: 'https://raw.githubusercontent.com/hypersign-protocol/hypersign-contexts/main/BJJSignature2021.jsonld', + VERIFICATION_METHOD_TYPE: 'BabyJubJubKey2021', + BLOCKCHAINACCOUNTID_CONTEXT: 'https://w3c.github.io/vc-data-integrity/vocab/security/vocabulary.jsonld', + SIGNATURE_TYPE: enums_1.ProofTypes.BJJSignature2021, }; var CAIP_10_PREFIX; (function (CAIP_10_PREFIX) { @@ -71,25 +92,27 @@ exports.DID = { METHOD: 'hid', NAMESPACE: 'testnet', DID_BASE_CONTEXT: 'https://www.w3.org/ns/did/v1', - VERIFICATION_METHOD_TYPE: 'Ed25519VerificationKey2020', + VERIFICATION_METHOD_TYPE: enums_1.VerificationMethodTypes.Ed25519VerificationKey2020, BLOCKCHAINACCOUNTID_CONTEXT: 'https://w3c.github.io/vc-data-integrity/vocab/security/vocabulary.jsonld', }; Object.freeze(exports.DID); exports.VC = { - SCHEME: "vc", - METHOD: "hid", - NAMESPACE: "testnet", - PREFIX: "vc:" + exports.DID.METHOD + ":" + exports.DID.NAMESPACE + ":", - CREDENTAIL_SCHEMA_VALIDATOR_TYPE: "JsonSchemaValidator2018", - CREDENTAIL_STATUS_TYPE: "CredentialStatusList2017", - CREDENTAIL_BASE_CONTEXT: "https://www.w3.org/2018/credentials/v1", - CREDENTAIL_SECURITY_CONTEXT_V2: "https://w3id.org/security/v2", - CREDENTAIL_SECURITY_SUITE: "https://w3id.org/security/suites/ed25519-2020/v1", - CREDENTAIL_ECDSA_SECURITY_SUITE: "https://w3id.org/security/suites/secp256k1recovery-2020/v2", - PROOF_PURPOSE: "assertion", - VERIFICATION_METHOD_TYPE: "Ed25519Signature2020", + SCHEME: 'vc', + METHOD: 'hid', + NAMESPACE: 'testnet', + PREFIX: 'vc:' + exports.DID.METHOD + ':' + exports.DID.NAMESPACE + ':', + CREDENTAIL_SCHEMA_VALIDATOR_TYPE: 'JsonSchemaValidator2018', + CREDENTAIL_STATUS_TYPE: 'HypersignCredentialStatus2023', + CREDENTIAL_STATUS_CONTEXT: 'https://raw.githubusercontent.com/hypersign-protocol/hypersign-contexts/main/CredentialStatus.jsonld', + CONTEXT_HypersignCredentialStatus2023: 'https://raw.githubusercontent.com/hypersign-protocol/hypersign-contexts/main/HypersignCredentialStatus2023.jsonld', + CREDENTAIL_BASE_CONTEXT: 'https://www.w3.org/2018/credentials/v1', + CREDENTAIL_SECURITY_CONTEXT_V2: 'https://w3id.org/security/v2', + CREDENTIAIL_SECURITY_SUITE: 'https://w3id.org/security/suites/ed25519-2020/v1', + CREDENTAIL_ECDSA_SECURITY_SUITE: 'https://w3id.org/security/suites/secp256k1recovery-2020/v2', + PROOF_PURPOSE: enums_1.VerificationMethodRelationships.assertionMethod, + VERIFICATION_METHOD_TYPE: enums_1.ProofTypes.Ed25519Signature2020, CRED_STATUS_TYPES: CredentialStatusEnums, - CRED_STATUS_REASON_TYPES: CredentialStatusReasonEnums + CRED_STATUS_REASON_TYPES: CredentialStatusReasonEnums, }; Object.freeze(exports.VC); exports.VP = { @@ -105,8 +128,9 @@ exports.SCHEMA = { NAMESPACE: 'testnet', SCHEMA_JSON: 'http://json-schema.org/draft-07/schema', SCHEMA_TYPE: 'https://w3c-ccg.github.io/vc-json-schemas/v1/schema/1.0/schema.json', - SIGNATURE_TYPE: "Ed25519Signature2020", - PROOF_PURPOSE: "assertion", + SIGNATURE_TYPE: enums_1.ProofTypes.Ed25519Signature2020, + PROOF_PURPOSE: enums_1.VerificationMethodRelationships.assertionMethod, + SCHEMA_CONTEXT: 'https://raw.githubusercontent.com/hypersign-protocol/hypersign-contexts/main/CredentialSchema.jsonld', }; Object.freeze(exports.SCHEMA); exports.KEY_HEADERS = { @@ -119,3 +143,14 @@ exports.HID_DECIMAL = 6; exports.HID_DNOMINATION = 'uhid'; exports.HID_MIN_GAS = '200000'; exports.HID_MIN_FEE = '5000'; +const GAS_FEE_API_URL = (baseUrl) => { return `${baseUrl}/hypersign-protocol/hidnode/ssi/fixedfee`; }; +exports.GAS_FEE_API_URL = GAS_FEE_API_URL; +exports.GAS_FEE_METHODS = { + Register_Did: "register_did_fee", + Update_Did: "update_did_fee", + Deactivate_Did: "deactivate_did_fee", + Register_Cred_Schema: "register_credential_schema_fee", + Update_Cred_Schema: "update_credential_schema_fee", + Register_Cred_Status: "register_credential_status_fee", + Update_Cred_Status: "update_credential_status_fee" +}; diff --git a/build/src/credential/ICredential.d.ts b/build/src/credential/ICredential.d.ts index c4795b3..a3c2f26 100644 --- a/build/src/credential/ICredential.d.ts +++ b/build/src/credential/ICredential.d.ts @@ -4,7 +4,8 @@ * Author: Hypermine Core Team */ import { TypedDataField } from '@ethersproject/abstract-signer'; -import { CredentialStatus, CredentialProof, Credential } from '../../libs/generated/ssi/credential'; +import { CredentialStatusDocument as CredentialStatus, CredentialStatusState as Credential } from '../../libs/generated/ssi/credential_status'; +import { DocumentProof as CredentialProof } from '../../libs/generated/ssi/proof'; import { DeliverTxResponse } from '@cosmjs/stargate'; export interface ISchema { id: string; @@ -73,16 +74,22 @@ export interface ICredentialMethods { privateKeyMultibase: string; status: string; statusReason?: string; - }): Promise; + }): Promise; resolveCredentialStatus(params: { credentialId: string; - }): Promise; + }): Promise; checkCredentialStatus(params: { credentialId: string; }): Promise<{ verified: boolean; }>; } +export interface IResolveCredential extends CredentialStatus { + proof: CredentialProof; +} export interface ICredentialRPC { credentialRestEP: string; registerCredentialStatus(credentialStatus: CredentialStatus, proof: CredentialProof): Promise; diff --git a/build/src/credential/ICredential.d.ts.map b/build/src/credential/ICredential.d.ts.map index d2f0b74..9617ec7 100644 --- a/build/src/credential/ICredential.d.ts.map +++ b/build/src/credential/ICredential.d.ts.map @@ -1 +1 @@ -{"version":3,"file":"ICredential.d.ts","sourceRoot":"","sources":["../../../src/credential/ICredential.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,EAAE,cAAc,EAAE,MAAM,gCAAgC,CAAC;AAEhE,OAAO,EAAE,gBAAgB,EAAE,eAAe,EAAE,UAAU,EAAE,MAAM,qCAAqC,CAAC;AACpG,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAUrD,MAAM,WAAW,OAAO;IACtB,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;CACd;AAED,MAAM,WAAW,iBAAiB;IAChC,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;CACd;AAED,MAAM,WAAW,gBAAgB;IAC/B,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,YAAY,EAAE,MAAM,CAAC;IACrB,kBAAkB,EAAE,MAAM,CAAC;IAC3B,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,UAAU,EAAE,MAAM,CAAC;IACnB,oBAAoB,EAAE,MAAM,CAAC;IAC7B,MAAM,EAAE;QACN,MAAM,EAAE,MAAM,CAAC;QACf,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,cAAc,EAAE,CAAC,GAAG,MAAM,CAAC;KAClD,CAAC;CACH;AAGD,MAAM,WAAW,qBAAqB;IACpC,UAAU,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;IAC1B,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;IACpB,MAAM,EAAE,MAAM,CAAC;IACf,YAAY,EAAE,MAAM,CAAC;IACrB,cAAc,EAAE,MAAM,CAAC;IACvB,iBAAiB,EAAE,MAAM,CAAC;IAC1B,gBAAgB,EAAE,OAAO,CAAC;IAG1B,gBAAgB,EAAE,iBAAiB,CAAC;IAEpC,KAAK,CAAC,EAAE,gBAAgB,CAAC;CAC1B;AAED,MAAM,WAAW,kBAAkB;IACjC,QAAQ,CAAC,MAAM,EAAE;QACf,QAAQ,EAAE,MAAM,CAAC;QACjB,UAAU,CAAC,EAAE,MAAM,CAAC;QACpB,mBAAmB,CAAC,EAAE,IAAI,CAAC;QAC3B,aAAa,CAAC,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;QAC9B,IAAI,CAAC,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;QACrB,SAAS,EAAE,MAAM,CAAC;QAClB,cAAc,EAAE,MAAM,CAAC;QACvB,MAAM,EAAE,MAAM,CAAC;KAChB,GAAG,OAAO,CAAC,qBAAqB,CAAC,CAAC;IAEnC,KAAK,CAAC,MAAM,EAAE;QACZ,UAAU,EAAE,qBAAqB,CAAC;QAClC,SAAS,EAAE,MAAM,CAAC;QAClB,mBAAmB,EAAE,MAAM,CAAC;QAC5B,kBAAkB,CAAC,EAAE,OAAO,CAAC;KAC9B,GAAG,OAAO,CAAC;QACV,gBAAgB,EAAE,qBAAqB,CAAC;QACxC,gBAAgB,EAAE,gBAAgB,CAAC;QACnC,qBAAqB,EAAE,eAAe,CAAC;QACvC,kCAAkC,CAAC,EAAE,iBAAiB,CAAC;KACxD,CAAC,CAAC;IAEH,MAAM,CAAC,MAAM,EAAE;QACb,UAAU,EAAE,qBAAqB,CAAC;QAClC,SAAS,EAAE,MAAM,CAAC;QAClB,oBAAoB,EAAE,MAAM,CAAC;KAC9B,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;IAEpB,sBAAsB,CAAC,MAAM,EAAE;QAC7B,gBAAgB,EAAE,gBAAgB,CAAC;QACnC,SAAS,EAAE,MAAM,CAAC;QAClB,oBAAoB,EAAE,MAAM,CAAC;QAC7B,mBAAmB,EAAE,MAAM,CAAC;QAC5B,MAAM,EAAE,MAAM,CAAC;QACf,YAAY,CAAC,EAAE,MAAM,CAAC;KACvB,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAAC;IAE/B,uBAAuB,CAAC,MAAM,EAAE;QAAE,YAAY,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAAC;IACrF,qBAAqB,CAAC,MAAM,EAAE;QAAE,YAAY,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC;QAAE,QAAQ,EAAE,OAAO,CAAA;KAAE,CAAC,CAAC;CACzF;AAED,MAAM,WAAW,cAAc;IAC7B,gBAAgB,EAAE,MAAM,CAAC;IACzB,wBAAwB,CAAC,gBAAgB,EAAE,gBAAgB,EAAE,KAAK,EAAE,eAAe,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAAC;IACjH,uBAAuB,CAAC,YAAY,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC;IACnE,kCAAkC,CAAC,gBAAgB,EAAE,gBAAgB,EAAE,KAAK,EAAE,eAAe,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;IAChH,4BAA4B,CAAC,UAAU,EAAE,KAAK,CAAC,GAAG,CAAC,EAAE,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAAC;CACpF"} \ No newline at end of file +{"version":3,"file":"ICredential.d.ts","sourceRoot":"","sources":["../../../src/credential/ICredential.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,EAAE,cAAc,EAAE,MAAM,gCAAgC,CAAC;AAEhE,OAAO,EACL,wBAAwB,IAAI,gBAAgB,EAC5C,qBAAqB,IAAI,UAAU,EACpC,MAAM,4CAA4C,CAAC;AACpD,OAAO,EAAE,aAAa,IAAI,eAAe,EAAE,MAAM,gCAAgC,CAAC;AAElF,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAUrD,MAAM,WAAW,OAAO;IACtB,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;CACd;AAED,MAAM,WAAW,iBAAiB;IAChC,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;CACd;AAED,MAAM,WAAW,gBAAgB;IAC/B,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,YAAY,EAAE,MAAM,CAAC;IACrB,kBAAkB,EAAE,MAAM,CAAC;IAC3B,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,UAAU,EAAE,MAAM,CAAC;IACnB,oBAAoB,EAAE,MAAM,CAAC;IAC7B,MAAM,EAAE;QACN,MAAM,EAAE,MAAM,CAAC;QACf,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,cAAc,EAAE,CAAC,GAAG,MAAM,CAAC;KAClD,CAAC;CACH;AAGD,MAAM,WAAW,qBAAqB;IACpC,UAAU,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;IAC1B,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;IACpB,MAAM,EAAE,MAAM,CAAC;IACf,YAAY,EAAE,MAAM,CAAC;IACrB,cAAc,EAAE,MAAM,CAAC;IACvB,iBAAiB,EAAE,MAAM,CAAC;IAC1B,gBAAgB,EAAE,OAAO,CAAC;IAG1B,gBAAgB,EAAE,iBAAiB,CAAC;IAEpC,KAAK,CAAC,EAAE,gBAAgB,CAAC;CAC1B;AAED,MAAM,WAAW,kBAAkB;IACjC,QAAQ,CAAC,MAAM,EAAE;QACf,QAAQ,EAAE,MAAM,CAAC;QACjB,UAAU,CAAC,EAAE,MAAM,CAAC;QACpB,mBAAmB,CAAC,EAAE,IAAI,CAAC;QAC3B,aAAa,CAAC,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;QAC9B,IAAI,CAAC,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;QACrB,SAAS,EAAE,MAAM,CAAC;QAClB,cAAc,EAAE,MAAM,CAAC;QACvB,MAAM,EAAE,MAAM,CAAC;KAChB,GAAG,OAAO,CAAC,qBAAqB,CAAC,CAAC;IAEnC,KAAK,CAAC,MAAM,EAAE;QACZ,UAAU,EAAE,qBAAqB,CAAC;QAClC,SAAS,EAAE,MAAM,CAAC;QAClB,mBAAmB,EAAE,MAAM,CAAC;QAC5B,kBAAkB,CAAC,EAAE,OAAO,CAAC;KAC9B,GAAG,OAAO,CAAC;QACV,gBAAgB,EAAE,qBAAqB,CAAC;QACxC,gBAAgB,EAAE,gBAAgB,CAAC;QACnC,qBAAqB,EAAE,eAAe,CAAC;QACvC,kCAAkC,CAAC,EAAE,iBAAiB,CAAC;KACxD,CAAC,CAAC;IAEH,MAAM,CAAC,MAAM,EAAE;QACb,UAAU,EAAE,qBAAqB,CAAC;QAClC,SAAS,EAAE,MAAM,CAAC;QAClB,oBAAoB,EAAE,MAAM,CAAC;KAC9B,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;IAEpB,sBAAsB,CAAC,MAAM,EAAE;QAC7B,gBAAgB,EAAE,gBAAgB,CAAC;QACnC,SAAS,EAAE,MAAM,CAAC;QAClB,oBAAoB,EAAE,MAAM,CAAC;QAC7B,mBAAmB,EAAE,MAAM,CAAC;QAC5B,MAAM,EAAE,MAAM,CAAC;QACf,YAAY,CAAC,EAAE,MAAM,CAAC;KACvB,GAAG,OAAO,CAAC,iBAAiB,GAAG;QAAE,gBAAgB,EAAE,gBAAgB,CAAC;QAAC,UAAU,EAAE,GAAG,CAAA;KAAE,CAAC,CAAC;IAEzF,uBAAuB,CAAC,MAAM,EAAE;QAAE,YAAY,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC,kBAAkB,CAAC,CAAC;IACvF,qBAAqB,CAAC,MAAM,EAAE;QAAE,YAAY,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC;QAAE,QAAQ,EAAE,OAAO,CAAA;KAAE,CAAC,CAAC;CACzF;AAED,MAAM,WAAW,kBAAmB,SAAQ,gBAAgB;IAC1D,KAAK,EAAE,eAAe,CAAC;CACxB;AAED,MAAM,WAAW,cAAc;IAC7B,gBAAgB,EAAE,MAAM,CAAC;IACzB,wBAAwB,CAAC,gBAAgB,EAAE,gBAAgB,EAAE,KAAK,EAAE,eAAe,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAAC;IACjH,uBAAuB,CAAC,YAAY,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC;IACnE,kCAAkC,CAAC,gBAAgB,EAAE,gBAAgB,EAAE,KAAK,EAAE,eAAe,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;IAChH,4BAA4B,CAAC,UAAU,EAAE,KAAK,CAAC,GAAG,CAAC,EAAE,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAAC;CACpF"} \ No newline at end of file diff --git a/build/src/credential/bjjvc.d.ts b/build/src/credential/bjjvc.d.ts new file mode 100644 index 0000000..b1dd01e --- /dev/null +++ b/build/src/credential/bjjvc.d.ts @@ -0,0 +1,179 @@ +import { DidDocument as Did } from '../../libs/generated/ssi/did'; +import { ICredentialMethods, IVerifiableCredential, ICredentialStatus, ISchema, ICredentialProof, IResolveCredential } from './ICredential'; +import { CredentialStatusDocument as CredentialStatus } from '../../libs/generated/ssi/credential_status'; +import { DocumentProof as CredentialProof } from '../../libs/generated/ssi/proof'; +import { DeliverTxResponse } from '@cosmjs/stargate'; +import { OfflineSigner } from '@cosmjs/proto-signing'; +export default class HypersignBJJVerifiableCredential implements ICredentialMethods, IVerifiableCredential { + '@context': Array; + id: string; + type: Array; + issuer: string; + issuanceDate: string; + expirationDate: string; + credentialSubject: object; + credentialSchema: ISchema; + proof: ICredentialProof; + credentialStatus: ICredentialStatus; + private credStatusRPC; + private credentialApiService; + private namespace; + private hsSchema; + private hsDid; + documentL: any; + constructor(params?: { + namespace?: string; + offlineSigner?: OfflineSigner; + nodeRpcEndpoint?: string; + nodeRestEndpoint?: string; + entityApiSecretKey?: string; + }); + private _jsonLdSign; + private _dateNow; + private _getId; + private _toTitleCase; + /** + * Initialise the offlinesigner to interact with Hypersign blockchain + */ + init(): Promise; + /** + * Generates a new credential document + * @params + * - params.schemaId : Hypersign schema id + * - params.subjectDid : DID of the subject, if not provided, will be taken from subjectDidDocSigned + * - params.schemaContext : + * - params.type : + * - params.issuerDid : DID of the issuer + * - params.expirationDate : Date of the expiration for this credential + * - params.fields : Schema fields values for this credential + * @returns {Promise} Result a credential document + */ + generate(params: { + schemaId?: string; + subjectDid?: string; + subjectDidDocSigned?: JSON; + schemaContext?: Array; + type?: Array; + issuerDid: string; + expirationDate: string; + fields: object; + }): Promise; + /** + * Generates signed credentials document and registers its status on Hypersign blockchain + * @params + * - params.credential : Hypersign credentail document + * - params.privateKeyMultibase : P + * - params.issuerDid : DID of the issuer + * - params.verificationMethodId : Verifcation Method of Issuer + * @returns {Promise<{ + * signedCredential: IVerifiableCredential; + * credentialStatus: CredentialStatus; + * credentialStatusProof: CredentialProof; + * credentialStatusRegistrationResult?: DeliverTxResponse; + * }>} + */ + issue(params: { + credential: IVerifiableCredential; + issuerDid: string; + verificationMethodId: string; + privateKeyMultibase: string; + registerCredential?: boolean; + issuerDidDoc?: JSON; + }): Promise<{ + signedCredential: IVerifiableCredential; + credentialStatus: CredentialStatus; + credentialStatusProof: CredentialProof; + credentialStatusRegistrationResult?: DeliverTxResponse; + }>; + /** + * Verfies signed/issued credential + * @params + * - params.credential : Signed Hypersign credentail document of type IVerifiableCredential + * - params.issuerDid : DID of the issuer + * - params.verificationMethodId : Verifcation Method of Issuer + * @returns {Promise} + */ + verify(params: { + credential: IVerifiableCredential; + issuerDid?: string; + issuerDidDocument?: Did; + verificationMethodId: string; + }): Promise; + /** + * Resolves credential status from Hypersign Blokchain + * @params + * - params.credentialId : Verifiable credential id + * @returns {Promise} + */ + resolveCredentialStatus(params: { + credentialId: string; + }): Promise; + /** + * Update credential status in blockchain Hypersign Blokchain + * @params + * - params.credentialStatus : Status of the credential of type CredentialStatus + * - params.issuerDid : DID of the issuer + * - params.verificationMethodId : verificationMethodId + * - params.privateKeyMultibase : privateKey of the issuer + * - params.status : Status LIVE/REVOKE/SUSPENDED + * - params.statusReason : Reason for the status change + * @returns {Promise} + */ + updateCredentialStatus(params: { + credentialStatus: CredentialStatus; + issuerDid: string; + verificationMethodId: string; + privateKeyMultibase: string; + status: string; + statusReason?: string; + }): Promise; + /** + * Check status of credential on Hypersign Chain + * @param + * - params.credentialId : Credential Id + * @returns {Promise<{ verified: boolean }>} + */ + checkCredentialStatus(params: { + credentialId: string; + }): Promise<{ + verified: boolean; + }>; + /** + * Register credential status on Hypersign Chain + * @param + * - params.credentialStatus : Credential status + * - params.credentialStatusProof : Status proof of the credential + * @returns {Promise<{ transactionHash: string }>} + */ + registerCredentialStatus(params: { + credentialStatus: CredentialStatus; + credentialStatusProof: CredentialProof; + }): Promise<{ + transactionHash: string; + }>; + /** + * Generate transaction message + * @param + * - params.credentialStatus : Credential status + * - params.credentialStatusProof : Status proof of the credential + * @returns {Promise<{typeUrl: string, value: MsgRegisterCredentialStatus}>} + */ + generateRegisterCredentialStatusTxnMessage(credentialStatus: CredentialStatus, proof: CredentialProof): Promise<{ + typeUrl: string; + value: import("../../libs/generated/ssi/tx").MsgRegisterCredentialStatus; + }>; + /** + * Register multiple credential status + * @param + * - params.txnMessage : Array of transaction message + * @returns {Promise} + */ + registerCredentialStatusTxnBulk(txnMessage: []): Promise; + generateSeletiveDisclosure(param: { + verifiableCredential: IVerifiableCredential; + frame: object; + verificationMethodId: string; + issuerDid: string; + }): Promise; +} +//# sourceMappingURL=bjjvc.d.ts.map \ No newline at end of file diff --git a/build/src/credential/bjjvc.d.ts.map b/build/src/credential/bjjvc.d.ts.map new file mode 100644 index 0000000..3d48b17 --- /dev/null +++ b/build/src/credential/bjjvc.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"bjjvc.d.ts","sourceRoot":"","sources":["../../../src/credential/bjjvc.ts"],"names":[],"mappings":"AAWA,OAAO,EAAE,WAAW,IAAI,GAAG,EAAmC,MAAM,8BAA8B,CAAC;AAOnG,OAAO,EACL,kBAAkB,EAClB,qBAAqB,EACrB,iBAAiB,EACjB,OAAO,EACP,gBAAgB,EAChB,kBAAkB,EACnB,MAAM,eAAe,CAAC;AAEvB,OAAO,EACL,wBAAwB,IAAI,gBAAgB,EAG7C,MAAM,4CAA4C,CAAC;AACpD,OAAO,EAAE,aAAa,IAAI,eAAe,EAAE,MAAM,gCAAgC,CAAC;AAClF,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AACrD,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAYtD,MAAM,CAAC,OAAO,OAAO,gCAAiC,YAAW,kBAAkB,EAAE,qBAAqB;IACjG,UAAU,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;IAC1B,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;IACpB,MAAM,EAAE,MAAM,CAAC;IACf,YAAY,EAAE,MAAM,CAAC;IACrB,cAAc,EAAE,MAAM,CAAC;IACvB,iBAAiB,EAAE,MAAM,CAAC;IAC1B,gBAAgB,EAAE,OAAO,CAAC;IAC1B,KAAK,EAAE,gBAAgB,CAAC;IACxB,gBAAgB,EAAE,iBAAiB,CAAC;IAC3C,OAAO,CAAC,aAAa,CAAuB;IAC5C,OAAO,CAAC,oBAAoB,CAA4B;IACxD,OAAO,CAAC,SAAS,CAAS;IAC1B,OAAO,CAAC,QAAQ,CAAkB;IAClC,OAAO,CAAC,KAAK,CAAe;IACrB,SAAS,EAAE,GAAG,CAAC;gBAEpB,MAAM,GAAE;QACN,SAAS,CAAC,EAAE,MAAM,CAAC;QACnB,aAAa,CAAC,EAAE,aAAa,CAAC;QAC9B,eAAe,CAAC,EAAE,MAAM,CAAC;QACzB,gBAAgB,CAAC,EAAE,MAAM,CAAC;QAC1B,kBAAkB,CAAC,EAAE,MAAM,CAAC;KACxB;YAmCM,WAAW;IAsBzB,OAAO,CAAC,QAAQ;YAQF,MAAM;YAWN,YAAY;IAG1B;;OAEG;IACU,IAAI;IAcjB;;;;;;;;;;;OAWG;IACU,QAAQ,CAAC,MAAM,EAAE;QAC5B,QAAQ,CAAC,EAAE,MAAM,CAAC;QAClB,UAAU,CAAC,EAAE,MAAM,CAAC;QACpB,mBAAmB,CAAC,EAAE,IAAI,CAAC;QAC3B,aAAa,CAAC,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;QAC9B,IAAI,CAAC,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;QACrB,SAAS,EAAE,MAAM,CAAC;QAClB,cAAc,EAAE,MAAM,CAAC;QACvB,MAAM,EAAE,MAAM,CAAC;KAChB,GAAG,OAAO,CAAC,qBAAqB,CAAC;IAsJlC;;;;;;;;;;;;;OAaG;IACU,KAAK,CAAC,MAAM,EAAE;QACzB,UAAU,EAAE,qBAAqB,CAAC;QAClC,SAAS,EAAE,MAAM,CAAC;QAClB,oBAAoB,EAAE,MAAM,CAAC;QAC7B,mBAAmB,EAAE,MAAM,CAAC;QAC5B,kBAAkB,CAAC,EAAE,OAAO,CAAC;QAC7B,YAAY,CAAC,EAAE,IAAI,CAAC;KACrB,GAAG,OAAO,CAAC;QACV,gBAAgB,EAAE,qBAAqB,CAAC;QACxC,gBAAgB,EAAE,gBAAgB,CAAC;QACnC,qBAAqB,EAAE,eAAe,CAAC;QACvC,kCAAkC,CAAC,EAAE,iBAAiB,CAAC;KACxD,CAAC;IAmJF;;;;;;;OAOG;IACU,MAAM,CAAC,MAAM,EAAE;QAC1B,UAAU,EAAE,qBAAqB,CAAC;QAClC,SAAS,CAAC,EAAE,MAAM,CAAC;QACnB,iBAAiB,CAAC,EAAE,GAAG,CAAC;QACxB,oBAAoB,EAAE,MAAM,CAAC;KAC9B,GAAG,OAAO,CAAC,GAAG,CAAC;IAuEhB;;;;;OAKG;IACU,uBAAuB,CAAC,MAAM,EAAE;QAAE,YAAY,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC,kBAAkB,CAAC;IAiBnG;;;;;;;;;;OAUG;IACU,sBAAsB,CAAC,MAAM,EAAE;QAC1C,gBAAgB,EAAE,gBAAgB,CAAC;QACnC,SAAS,EAAE,MAAM,CAAC;QAClB,oBAAoB,EAAE,MAAM,CAAC;QAC7B,mBAAmB,EAAE,MAAM,CAAC;QAC5B,MAAM,EAAE,MAAM,CAAC;QACf,YAAY,CAAC,EAAE,MAAM,CAAC;KACvB,GAAG,OAAO,CAAC,iBAAiB,CAAC;IAqF9B;;;;;OAKG;IAEU,qBAAqB,CAAC,MAAM,EAAE;QAAE,YAAY,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC;QAAE,QAAQ,EAAE,OAAO,CAAA;KAAE,CAAC;IA+BpG;;;;;;OAMG;IACU,wBAAwB,CAAC,MAAM,EAAE;QAC5C,gBAAgB,EAAE,gBAAgB,CAAC;QACnC,qBAAqB,EAAE,eAAe,CAAC;KACxC,GAAG,OAAO,CAAC;QAAE,eAAe,EAAE,MAAM,CAAA;KAAE,CAAC;IAiCxC;;;;;;OAMG;IACU,0CAA0C,CAAC,gBAAgB,EAAE,gBAAgB,EAAE,KAAK,EAAE,eAAe;;;;IAalH;;;;;OAKG;IAEU,+BAA+B,CAAC,UAAU,EAAE,EAAE;IAiB9C,0BAA0B,CAAC,KAAK,EAAE;QAC7C,oBAAoB,EAAE,qBAAqB,CAAC;QAC5C,KAAK,EAAE,MAAM,CAAC;QACd,oBAAoB,EAAE,MAAM,CAAC;QAC7B,SAAS,EAAE,MAAM,CAAC;KACnB;CA2CF"} \ No newline at end of file diff --git a/build/src/credential/bjjvc.js b/build/src/credential/bjjvc.js new file mode 100644 index 0000000..5778639 --- /dev/null +++ b/build/src/credential/bjjvc.js @@ -0,0 +1,746 @@ +"use strict"; +var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + var desc = Object.getOwnPropertyDescriptor(m, k); + if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { + desc = { enumerable: true, get: function() { return m[k]; } }; + } + Object.defineProperty(o, k2, desc); +}) : (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + o[k2] = m[k]; +})); +var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { + Object.defineProperty(o, "default", { enumerable: true, value: v }); +}) : function(o, v) { + o["default"] = v; +}); +var __importStar = (this && this.__importStar) || function (mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); + __setModuleDefault(result, mod); + return result; +}; +var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { + function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } + return new (P || (P = Promise))(function (resolve, reject) { + function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } + function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } + function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } + step((generator = generator.apply(thisArg, _arguments || [])).next()); + }); +}; +var __importDefault = (this && this.__importDefault) || function (mod) { + return (mod && mod.__esModule) ? mod : { "default": mod }; +}; +Object.defineProperty(exports, "__esModule", { value: true }); +/** + * Copyright (c) 2023, Hypermine Pvt. Ltd. + * All rights reserved. + * Author: Hypermine Core Team + */ +const jsonld_signatures_1 = __importDefault(require("jsonld-signatures")); +const jsonld_signatures_2 = require("jsonld-signatures"); +const utils_1 = __importDefault(require("../utils")); +const schema_1 = __importDefault(require("../schema/schema")); +const did_1 = __importDefault(require("../did/did")); +const jsonSchemaValidator = __importStar(require("@cfworker/json-schema")); +const jsonld_signatures_3 = __importDefault(require("jsonld-signatures")); +const { AssertionProofPurpose } = jsonld_signatures_3.default.purposes; +const credRPC_1 = require("./credRPC"); +const constants_1 = require("../constants"); +const v1_1 = __importDefault(require("../../libs/w3cache/v1")); +const jsonld_signatures_4 = require("jsonld-signatures"); +const credential_service_1 = __importDefault(require("../ssiApi/services/credential/credential.service")); +const constant = __importStar(require("../constants")); +const babyjubjub2021_1 = require("babyjubjub2021"); +const babyjubjubsignature2021_1 = require("babyjubjubsignature2021"); +const { Merklizer } = require('@iden3/js-jsonld-merklization'); +const documentLoader = (0, jsonld_signatures_4.extendContextLoader)(v1_1.default); +class HypersignBJJVerifiableCredential { + constructor(params = {}) { + const { namespace, offlineSigner, nodeRpcEndpoint, nodeRestEndpoint, entityApiSecretKey } = params; + this.documentL = documentLoader; + this.namespace = namespace && namespace != '' ? namespace : ''; + const nodeRPCEp = nodeRpcEndpoint ? nodeRpcEndpoint : 'MAIN'; + const nodeRestEp = nodeRestEndpoint ? nodeRestEndpoint : ''; + const offlineConstuctorParams = { offlineSigner, nodeRpcEndpoint: nodeRPCEp, nodeRestEndpoint: nodeRestEp }; + this.credStatusRPC = new credRPC_1.CredentialRPC(offlineConstuctorParams); + this.hsDid = new did_1.default(offlineConstuctorParams); + this.hsSchema = new schema_1.default(offlineConstuctorParams); + if (entityApiSecretKey && entityApiSecretKey != '') { + this.credentialApiService = new credential_service_1.default(entityApiSecretKey); + this.credStatusRPC = null; + } + else { + this.credentialApiService = null; + } + this['@context'] = []; + this.id = ''; + this.type = []; + this.issuer = ''; + this.issuanceDate = ''; + this.expirationDate = ''; + this.credentialSubject = {}; + this.credentialSchema = { + id: '', + type: constants_1.VC.CREDENTAIL_SCHEMA_VALIDATOR_TYPE, + }; + this.credentialStatus = { + id: '', + type: constants_1.VC.CREDENTAIL_STATUS_TYPE, + }; + this.proof = {}; + } + _jsonLdSign(params) { + return __awaiter(this, void 0, void 0, function* () { + const { credentialStatus, privateKeyMultibase, verificationMethodId } = params; + const keyPair = yield babyjubjub2021_1.BabyJubJubKeys2021.fromKeys({ + options: { id: verificationMethodId, controller: verificationMethodId }, + privateKeyMultibase: privateKeyMultibase, + publicKeyMultibase: params.publicKeyMultibase, + }); + const suite = new babyjubjubsignature2021_1.BabyJubJubSignature2021Suite({ key: keyPair, verificationMethod: verificationMethodId }); + const signedCredStatus = yield jsonld_signatures_3.default.sign(credentialStatus, { + suite, + purpose: new AssertionProofPurpose(), + documentLoader: v1_1.default, + }); + return signedCredStatus.proof; + }); + } + _dateNow(date) { + if (date) { + return new Date(date).toISOString().slice(0, -5) + 'Z'; + } + else { + return new Date(new Date().getTime() - 100000).toISOString().slice(0, -5) + 'Z'; + } + } + _getId() { + return __awaiter(this, void 0, void 0, function* () { + const uuid = yield utils_1.default.getUUID(); + let id; + if (this.namespace && this.namespace != '') { + id = `${constants_1.VC.SCHEME}:${constants_1.VC.METHOD}:${this.namespace}:${uuid}`; + } + else { + id = `${constants_1.VC.SCHEME}:${constants_1.VC.METHOD}:${uuid}`; + } + return id; + }); + } + _toTitleCase(status) { + return __awaiter(this, void 0, void 0, function* () { + return status.charAt(0).toUpperCase() + status.slice(1).toLowerCase(); + }); + } + /** + * Initialise the offlinesigner to interact with Hypersign blockchain + */ + init() { + return __awaiter(this, void 0, void 0, function* () { + if (!this.credStatusRPC && !this.credentialApiService) { + throw new Error('HID-SSI-SDK:: Error: HypersignVerifiableCredential class is not instantiated with Offlinesigner or have not been initilized with entityApiSecretKey'); + } + if (this.credStatusRPC) { + yield this.credStatusRPC.init(); + } + if (this.credentialApiService) { + yield this.credentialApiService.auth(); + } + }); + } + /** + * Generates a new credential document + * @params + * - params.schemaId : Hypersign schema id + * - params.subjectDid : DID of the subject, if not provided, will be taken from subjectDidDocSigned + * - params.schemaContext : + * - params.type : + * - params.issuerDid : DID of the issuer + * - params.expirationDate : Date of the expiration for this credential + * - params.fields : Schema fields values for this credential + * @returns {Promise} Result a credential document + */ + generate(params) { + return __awaiter(this, void 0, void 0, function* () { + let schemaDoc = {}; + if (params.subjectDid && params.subjectDidDocSigned) { + throw new Error('HID-SSI-SDK:: Error: Both subjectDid and subjectDidDoc cannot be passed'); + } + if (!this.credStatusRPC) { + throw new Error('HID-SSI-SDK:: Error: HypersignVerifiableCredential class is not instantiated with Offlinesigner or have not been initilized'); + } + const issuerDid = params.issuerDid; + const subjectDid = params.subjectDid; + let resolvedsubjectDidDoc; + // const { didDocument: issuerDidDoc } = await this.hsDid.resolve({ did: issuerDid }); + if (params.subjectDid) { + // resolvedsubjectDidDoc = await this.hsDid.resolve({ did: params.subjectDid }); + } + else if (params.subjectDidDocSigned) { + resolvedsubjectDidDoc = {}; + resolvedsubjectDidDoc.didDocument = params.subjectDidDocSigned; + } + else { + throw new Error('HID-SSI-SDK:: Error: Could not resolve the subjectDid or subjectDidDoc'); + } + // const { didDocument: subjectDidDoc } = resolvedsubjectDidDoc; + // if (!issuerDidDoc) { + // throw new Error('HID-SSI-SDK:: Error: Could not fetch issuer did doc, issuer did = ' + issuerDid); + // } + // if (!subjectDidDoc) { + // throw new Error('HID-SSI-SDK:: Error: Could not fetch subject did doc, subject did = ' + subjectDid); + // } + if (params && params.schemaContext && params.type) { + try { + const context = Array(); + context.push(constants_1.VC.CREDENTAIL_BASE_CONTEXT); + context.push(constant.DID_BabyJubJubKey2021.BABYJUBJUBSIGNATURE); + params.schemaContext.forEach((x) => { + context.push(x); + }); + const issuerDid = params.issuerDid; + const subjectDid = params.subjectDid; + const expirationDate = params.expirationDate; + const credentialSubject = params.fields; + const vc = {}; + vc['@context'] = context; + vc.id = yield this._getId(); + vc.type = []; + vc.type.push('VerifiableCredential'); + params.type.forEach((x) => { + vc.type.push(x); + }); + vc.issuer = issuerDid; + vc.issuanceDate = this._dateNow(new Date(new Date().getTime() - 100000).toISOString()); + vc.expirationDate = this._dateNow(expirationDate); + vc.credentialSubject = credentialSubject; + vc.credentialSubject['id'] = subjectDid; //subjectDid && subjectDid != undefined ? subjectDid : subjectDidDoc.id; + // TODO: confusion here is, what would be the status of this credential at the time of its creation? + // If this properpty is present , then checkStatus() must be passed at the time of verification of the credential + // Ref: https://github.com/digitalbazaar/vc-js/blob/7e14ef27bc688194635077d243d9025c0020448b/test/10-verify.spec.js#L188 + vc.credentialStatus = { + id: this.credStatusRPC.credentialRestEP + '/' + vc.id, + type: this.credentialStatus.type, + }; + return vc; + } + catch (error) { + throw new Error('HID-SSI-SDK:: Error: Could not create credential, error = ' + error); + } + } + else if (!params.schemaId) { + throw new Error('HID-SSI-SDK:: Error: schemaId is required when schemaContext and type not passed'); + } + try { + schemaDoc = yield this.hsSchema.resolve({ schemaId: params.schemaId }); + } + catch (e) { + throw new Error('HID-SSI-SDK:: Error: Could not resolve the schema from schemaId = ' + params.schemaId); + } + // TODO: do proper check for date and time + //if(params.expirationDate < new Date()) throw new Error("Expiration date can not be lesser than current date") + const vc = {}; + // const schemaInternal = schemaDoc.schema as SchemaProperty; + // const schemaProperties = JSON.parse(schemaInternal.properties as string); + // const schemaName = schemaDoc.name as string; + // context + // vc['@context'] = this._getCredentialContext(params.schemaId, schemaProperties, schemaName); + vc['@context'] = [ + constants_1.VC.CREDENTAIL_BASE_CONTEXT, + constant.DID_BabyJubJubKey2021.DID_BABYJUBJUBKEY2021, + constant.DID_BabyJubJubKey2021.BABYJUBJUBSIGNATURE, + ]; + vc['@context'].push(constants_1.VC.CONTEXT_HypersignCredentialStatus2023); + const JsonSchema = this.hsSchema.vcJsonSchema(schemaDoc); + vc['@context'].push(JsonSchema.$metadata.jsonLdContext); + /// TODO: need to implement this properly + vc.id = yield this._getId(); + // Type + vc.type = []; + vc.type.push('VerifiableCredential'); + vc.type.push(schemaDoc.name); + vc.expirationDate = this._dateNow(params.expirationDate); + vc.issuanceDate = this._dateNow(); // TODO: need to remove this. + vc.issuer = issuerDid; + vc.credentialSubject = {}; + // ToDo: Implement Schema validation (JSON Schema Validator) + const validator = new jsonSchemaValidator.Validator(JsonSchema, '2020-12', true); + const result = validator.validate({ + credentialSubject: Object.assign({}, params.fields), + }); + if (!result.valid) { + throw result.errors; + } + // vc.credentialSubject = { + // ...this._getCredentialSubject(schemaDoc.schema as SchemaProperty, params.fields), + // }; + vc.credentialSubject = params.fields; + vc.credentialSubject['id'] = subjectDid; // subjectDid && subjectDid != undefined ? subjectDid : subjectDidDoc.id; + vc.credentialSchema = { + id: schemaDoc.id, + type: this.credentialSchema.type, + }; + // TODO: confusion here is, what would be the status of this credential at the time of its creation? + // If this properpty is present , then checkStatus() must be passed at the time of verification of the credential + // Ref: https://github.com/digitalbazaar/vc-js/blob/7e14ef27bc688194635077d243d9025c0020448b/test/10-verify.spec.js#L188 + vc.credentialStatus = { + id: this.credStatusRPC.credentialRestEP + '/' + vc.id, + type: this.credentialStatus.type, + }; + return vc; + }); + } + /** + * Generates signed credentials document and registers its status on Hypersign blockchain + * @params + * - params.credential : Hypersign credentail document + * - params.privateKeyMultibase : P + * - params.issuerDid : DID of the issuer + * - params.verificationMethodId : Verifcation Method of Issuer + * @returns {Promise<{ + * signedCredential: IVerifiableCredential; + * credentialStatus: CredentialStatus; + * credentialStatusProof: CredentialProof; + * credentialStatusRegistrationResult?: DeliverTxResponse; + * }>} + */ + issue(params) { + return __awaiter(this, void 0, void 0, function* () { + if (!params.verificationMethodId) { + throw new Error('HID-SSI-SDK:: Error: params.verificationMethodId is required to issue credential'); + } + if (!params.credential) { + throw new Error('HID-SSI-SDK:: Error: params.credential is required to issue credential'); + } + if (!params.privateKeyMultibase) { + throw new Error('HID-SSI-SDK:: Error: params.privateKeyMultibase is required to issue credential'); + } + if (!params.issuerDid) { + throw new Error('HID-SSI-SDK:: Error: params.issuerDid is required to issue credential'); + } + if (!this.credStatusRPC) { + throw new Error('HID-SSI-SDK:: Error: HypersignVerifiableCredential class is not instantiated with Offlinesigner or have not been initilized'); + } + if (params.registerCredential == undefined) { + params.registerCredential = true; + } + // const { didDocument: signerDidDoc } = await this.hsDid.resolve({ did: params.issuerDid }); + let signerDidDoc; + if (params.issuerDidDoc) { + console.log('Got issuerDID doc so no need to resolve'); + signerDidDoc = params.issuerDidDoc; + } + else { + console.log('Did not get issuerDID doc, need to resolve'); + signerDidDoc = (yield this.hsDid.resolve({ did: params.issuerDid })).didDocument; + } + if (signerDidDoc === null || signerDidDoc === undefined) + throw new Error('HID-SSI-SDK:: Error: Could not resolve issuerDid = ' + params.issuerDid); + const publicKeyId = params.verificationMethodId; + const publicKeyVerMethod = signerDidDoc['verificationMethod'].find((x) => x.id == publicKeyId); + if (!publicKeyVerMethod) { + throw new Error('HID-SSI-SDK:: Error: Could not find verification method for id = ' + params.verificationMethodId); + } + const keyPair = yield babyjubjub2021_1.BabyJubJubKeys2021.fromKeys({ + privateKeyMultibase: params.privateKeyMultibase, + publicKeyMultibase: publicKeyVerMethod.publicKeyMultibase, + options: { + id: publicKeyVerMethod.id, + controller: publicKeyVerMethod.controller, + }, + }); + const suite = new babyjubjubsignature2021_1.BabyJubJubSignature2021Suite({ + verificationMethod: publicKeyId, + key: keyPair, + }); + /// Before we issue the credential the credential status has to be added + /// for that we will call RegisterCredentialStatus RPC + // Let us generate credentialHash first + // generating hash using merkelroot hash + const merkelizerObj = yield Merklizer.merklizeJSONLD(JSON.stringify(params.credential), { + documentLoader, + }); + let credentialHash = yield merkelizerObj.mt.root(); + credentialHash = Buffer.from(credentialHash.bytes).toString('hex'); + const credentialStatus = { + '@context': [constant.VC.CREDENTIAL_STATUS_CONTEXT, constant.DID_BabyJubJubKey2021.BABYJUBJUBSIGNATURE], + id: params.credential.id, + issuer: params.credential.issuer, + issuanceDate: params.credential.issuanceDate, + remarks: 'Credential is active', + credentialMerkleRootHash: credentialHash, + }; + const credProof = yield this._jsonLdSign({ + credentialStatus, + privateKeyMultibase: params.privateKeyMultibase, + verificationMethodId: params.verificationMethodId, + publicKeyMultibase: publicKeyVerMethod.publicKeyMultibase, + }); + let issuerDID; + if (params.issuerDidDoc) { + console.log('Got issuerDID doc so no need to resolve'); + issuerDID = params.issuerDidDoc; + } + else { + console.log('Did not get issuerDID doc, need to resolve'); + issuerDID = (yield this.hsDid.resolve({ did: params.credential.issuer })).didDocument; + } + if (issuerDID === null || issuerDID === undefined) + throw new Error('Could not resolve issuerDid = ' + params.credential.issuer); + const credIssuerDidDoc = issuerDID; + const credIssuerController = credIssuerDidDoc.controller; + if (!credIssuerController.includes(params.issuerDid)) { + throw new Error(params.issuerDid + ' is not a controller of ' + params.credential.issuer); + } + /// RegisterCRedeRPC + const signedVC = yield jsonld_signatures_1.default.sign(params.credential, { + purpose: new jsonld_signatures_2.purposes.AssertionProofPurpose({ + controller: { + '@context': ['https://www.w3.org/ns/did/v1'], + id: issuerDID.id, + assertionMethod: issuerDID.assertionMethod, + }, + }), + suite, + documentLoader, + }); + let credentialStatusRegistrationResult; + if (params.registerCredential) { + credentialStatusRegistrationResult = yield this.credStatusRPC.registerCredentialStatus(credentialStatus, credProof); + if (!credentialStatusRegistrationResult || credentialStatusRegistrationResult.code != 0) { + throw new Error('HID-SSI-SDK:: Error while issuing the credential error = ' + credentialStatusRegistrationResult.rawLog); + } + return { + signedCredential: signedVC, + credentialStatus, + credentialStatusProof: credProof, + credentialStatusRegistrationResult, + }; + } + return { signedCredential: signedVC, credentialStatus, credentialStatusProof: credProof }; + }); + } + // Ref: https://github.com/digitalbazaar/vc-js/blob/44ca660f62ad3569f338eaaaecb11a7b09949bd2/lib/vc.js#L251 + /** + * Verfies signed/issued credential + * @params + * - params.credential : Signed Hypersign credentail document of type IVerifiableCredential + * - params.issuerDid : DID of the issuer + * - params.verificationMethodId : Verifcation Method of Issuer + * @returns {Promise} + */ + verify(params) { + return __awaiter(this, void 0, void 0, function* () { + if (!params.credential) { + throw new Error('HID-SSI-SDK:: params.credential is required to verify credential'); + } + if (!params.credential.proof) { + throw new Error('HID-SSI-SDK:: params.credential.proof is required to verify credential'); + } + if (!params.verificationMethodId) { + throw new Error('HID-SSI-SDK:: Error: params.verificationMethodId is required to verify credential'); + } + // if (!params.issuerDid) { + // throw new Error('HID-SSI-SDK:: Error: params.issuerDid is required to verify credential'); + // } + if (!params.issuerDid && !params.issuerDidDocument) { + throw new Error('HID-SSI-SDK:: Error: params.issuerDid or params.issuerDidDocument is required to verify credential'); + } + let issuerDID; + if (params.issuerDid) { + const { didDocument } = yield this.hsDid.resolve({ did: params.issuerDid }); + issuerDID = didDocument; + } + else { + issuerDID = params.issuerDidDocument; + } + const issuerDidDoc = issuerDID; + const publicKeyId = params.verificationMethodId; + const publicKeyVerMethod = issuerDidDoc.verificationMethod.find((x) => x.id == publicKeyId); + const keyPair = yield babyjubjub2021_1.BabyJubJubKeys2021.fromKeys({ + publicKeyMultibase: publicKeyVerMethod.publicKeyMultibase, + options: { + id: publicKeyVerMethod.id, + controller: publicKeyVerMethod.controller, + }, + }); + const suite = new babyjubjubsignature2021_1.BabyJubJubSignature2021Suite({ + verificationMethod: publicKeyId, + key: keyPair, + }); + /* eslint-disable */ + const thats = this; + /* eslint-enable */ + const result = yield jsonld_signatures_1.default.verify(params.credential, { + purpose: new jsonld_signatures_2.purposes.AssertionProofPurpose({ + controller: { + '@context': ['https://www.w3.org/ns/did/v1'], + id: issuerDID.id, + assertionMethod: issuerDID.assertionMethod, + }, + }), + suite, + documentLoader, + }); + const statusCheck = yield thats.checkCredentialStatus({ credentialId: params.credential.id }); + result.statusResult = statusCheck; + return result; + }); + } + /** + * Resolves credential status from Hypersign Blokchain + * @params + * - params.credentialId : Verifiable credential id + * @returns {Promise} + */ + resolveCredentialStatus(params) { + return __awaiter(this, void 0, void 0, function* () { + if (!params || !params.credentialId) + throw new Error('HID-SSI-SDK:: Error: params.credentialId is required to resolve credential status'); + let credentialStatus = {}; + if (!this.credStatusRPC) { + throw new Error('HID-SSI-SDK:: Error: HypersignVerifiableCred is not instantiated with Offlinesigner or not initialized'); + } + credentialStatus = yield this.credStatusRPC.resolveCredentialStatus(params.credentialId); + const response = Object.assign(Object.assign({}, credentialStatus.credentialStatusDocument), { proof: credentialStatus.credentialStatusProof }); + return response; + }); + } + /** + * Update credential status in blockchain Hypersign Blokchain + * @params + * - params.credentialStatus : Status of the credential of type CredentialStatus + * - params.issuerDid : DID of the issuer + * - params.verificationMethodId : verificationMethodId + * - params.privateKeyMultibase : privateKey of the issuer + * - params.status : Status LIVE/REVOKE/SUSPENDED + * - params.statusReason : Reason for the status change + * @returns {Promise} + */ + updateCredentialStatus(params) { + var _a; + return __awaiter(this, void 0, void 0, function* () { + if (!params.verificationMethodId) { + throw new Error('HID-SSI-SDK:: Error: params.verificationMethodId is required to update credential status'); + } + if (!params.credentialStatus) { + throw new Error('HID-SSI-SDK:: Error: params.credentialStatus is required to update credential status'); + } + if (!params.privateKeyMultibase) { + throw new Error('HID-SSI-SDK:: Error: params.privateKeyMultibase is required to update credential status'); + } + if (!params.issuerDid) { + throw new Error('HID-SSI-SDK:: Error: params.issuerDid is required to update credential status'); + } + if (!params.status) { + throw new Error('HID-SSI-SDK:: Error: params.status is required to update credential status'); + } + if (!this.credStatusRPC) { + throw new Error('HID-SSI-SDK:: Error: HypersignVerifiableCredential class is not instantiated with Offlinesigner or have not been initilized'); + } + const { didDocument: signerDidDoc } = yield this.hsDid.resolve({ did: params.issuerDid }); + if (!signerDidDoc) + throw new Error('Could not resolve issuerDid = ' + params.issuerDid); + // TODO: take verification method from params + const publicKeyId = params.verificationMethodId; // TODO: bad idea - should not hardcode it. + const publicKeyVerMethod = signerDidDoc['verificationMethod'].find((x) => x.id == publicKeyId); + /// Before we issue the credential the credential status has to be added + /// for that we will call RegisterCredentialStatus RPC + // Let us generate credentialHash first + const status = yield this._toTitleCase(params.status); + if (!Object.values(constants_1.CredentialStatusEnums).includes(status)) { + throw new Error(`HID-SSI-SDK:: Error: params.status is invalid`); + } + const claim = params.credentialStatus; + const credentialStatus = { + '@context': [constant.VC.CREDENTIAL_STATUS_CONTEXT, constant.DID_BabyJubJubKey2021.BABYJUBJUBSIGNATURE], + id: claim.id, + remarks: (_a = params.statusReason) !== null && _a !== void 0 ? _a : constants_1.VC.CRED_STATUS_REASON_TYPES[params.status], + issuer: params.credentialStatus.issuer, + issuanceDate: params.credentialStatus.issuanceDate, + credentialMerkleRootHash: params.credentialStatus.credentialMerkleRootHash, + }; + if (status === constants_1.VC.CRED_STATUS_TYPES.REVOKED) { + credentialStatus['revoked'] = true; + } + else if (status === constants_1.VC.CRED_STATUS_TYPES.SUSPENDED) { + credentialStatus['suspended'] = true; + } + const proofValue = yield this._jsonLdSign({ + credentialStatus, + privateKeyMultibase: params.privateKeyMultibase, + verificationMethodId: params.verificationMethodId, + publicKeyMultibase: publicKeyVerMethod.publicKeyMultibase, + }); + const { didDocument: issuerDID } = yield this.hsDid.resolve({ did: params.credentialStatus.issuer }); + const issuerDidDoc = issuerDID; + const issuerDidDocController = issuerDidDoc.controller; + const verificationMethodController = params.verificationMethodId.split('#')[0]; + if (!issuerDidDocController.includes(verificationMethodController)) { + throw new Error('HID-SSI-SDK:: Error: params.verificationMethodId does not belong to issuerDid'); + } + const { didDocument: controllerDidDoc } = yield this.hsDid.resolve({ did: verificationMethodController }); + if (!controllerDidDoc) + throw new Error('HID-SSI-SDK:: Error: params.verificationMethodId does not belong to issuerDid'); + /// UpdateCredRPC + const resp = yield this.credStatusRPC.updateCredentialStatus(credentialStatus, proofValue); + if (!resp || resp.code != 0) { + throw new Error('HID-SSI-SDK:: Error while revoking the credential error = ' + resp.rawLog); + } + return resp; + }); + } + /** + * Check status of credential on Hypersign Chain + * @param + * - params.credentialId : Credential Id + * @returns {Promise<{ verified: boolean }>} + */ + checkCredentialStatus(params) { + var _a, _b; + return __awaiter(this, void 0, void 0, function* () { + if (!params || !params.credentialId) + throw new Error('HID-SSI-SDK:: Error: params.credentialId is required to resolve credential status'); + const { credentialId } = params; + let credentialStatus = {}; + if (!this.credStatusRPC) { + throw new Error('HID-SSI-SDK:: Error: HypersignVerifiableCred is not instantiated with Offlinesigner'); + } + credentialStatus = yield this.credStatusRPC.resolveCredentialStatus(credentialId); + if (!credentialStatus) { + throw new Error('HID-SSI-SDK:: Error: while checking credential status of credentialID ' + credentialId); + } + // const claim: Claim = credentialStatus.claim as Claim; + const { remarks: statusReason } = credentialStatus.credentialStatusDocument; + let currentStatus; + /// TODO: probably we should also verify the credential HASH by recalculating the hash of the crdential and + // matching with credentialHash property. + // const { credentialHash } = credentialStatus; + if (!((_a = credentialStatus.credentialStatusDocument) === null || _a === void 0 ? void 0 : _a.revoked) && !((_b = credentialStatus.credentialStatusDocument) === null || _b === void 0 ? void 0 : _b.suspended)) { + currentStatus = constants_1.VC.CRED_STATUS_TYPES.LIVE; + } + if (currentStatus != constants_1.VC.CRED_STATUS_TYPES.LIVE) { + console.log('WARN: Credential status is not LIVE, currentStatus ' + currentStatus); + console.log('WARN: Status reason is ' + statusReason); + return { verified: false }; + } + return { verified: true }; + }); + } + /** + * Register credential status on Hypersign Chain + * @param + * - params.credentialStatus : Credential status + * - params.credentialStatusProof : Status proof of the credential + * @returns {Promise<{ transactionHash: string }>} + */ + registerCredentialStatus(params) { + return __awaiter(this, void 0, void 0, function* () { + const { credentialStatus, credentialStatusProof } = params; + if (!credentialStatus || !credentialStatusProof) + throw new Error('HID-SSI-SDK:: Error: credentialStatus and credentialStatusProof are required to register credential status'); + if (!this.credStatusRPC && !this.credentialApiService) { + throw new Error('HID-SSI-SDK:: Error: HypersignVerifiableCredential class is not instantiated with Offlinesigner or have not been initilized with entityApiSecret'); + } + let resp = {}; + if (this.credStatusRPC) { + const result = yield this.credStatusRPC.registerCredentialStatus(credentialStatus, credentialStatusProof); + if (!result || result.code != 0) { + throw new Error('HID-SSI-SDK:: Error while issuing the credential error = ' + result.rawLog); + } + resp.transactionHash = result.transactionHash; + } + else if (this.credentialApiService) { + resp = yield this.credentialApiService.registerCredentialStatus({ + credentialStatus, + credentialStatusProof, + namespace: this.namespace, + }); + } + return resp; + }); + } + /** + * Generate transaction message + * @param + * - params.credentialStatus : Credential status + * - params.credentialStatusProof : Status proof of the credential + * @returns {Promise<{typeUrl: string, value: MsgRegisterCredentialStatus}>} + */ + generateRegisterCredentialStatusTxnMessage(credentialStatus, proof) { + return __awaiter(this, void 0, void 0, function* () { + if (!credentialStatus || !proof) + throw new Error('HID-SSI-SDK:: Error: credentialStatus and proof are required to register credential status'); + if (!this.credStatusRPC) { + throw new Error('HID-SSI-SDK:: Error: HypersignVerifiableCredential class is not instantiated with Offlinesigner or have not been initilized'); + } + const txnMessage = yield this.credStatusRPC.generateCredentialStatusTxnMessage(credentialStatus, proof); + return txnMessage; + }); + } + /** + * Register multiple credential status + * @param + * - params.txnMessage : Array of transaction message + * @returns {Promise} + */ + registerCredentialStatusTxnBulk(txnMessage) { + return __awaiter(this, void 0, void 0, function* () { + if (!txnMessage || txnMessage.length <= 0) + throw new Error('HID-SSI-SDK:: Error: txnMessage is required to register credential status'); + if (!this.credStatusRPC) { + throw new Error('HID-SSI-SDK:: Error: HypersignVerifiableCredential class is not instantiated with Offlinesigner or have not been initilized'); + } + const resp = yield this.credStatusRPC.registerCredentialStatusBulk(txnMessage); + if (!resp || resp.code != 0) { + throw new Error('HID-SSI-SDK:: Error while issuing the credential error = ' + resp.rawLog); + } + return resp; + }); + } + generateSeletiveDisclosure(param) { + var _a; + return __awaiter(this, void 0, void 0, function* () { + if (!param.verifiableCredential) { + throw new Error('HID-SSI-SDK:: verifiableCredential is required'); + } + if (!param.frame) { + throw new Error('HID-SSI-SDK:: frame is required'); + } + if (!param.verificationMethodId) { + throw new Error('HID-SSI-SDK:: verificationMethodId is required'); + } + if (!param.issuerDid) { + throw new Error('HID-SSI-SDK:: issuerDid is required'); + } + param.frame['@context'] = param.verifiableCredential['@context']; + const { didDocument: signerDidDoc } = yield this.hsDid.resolve({ did: param.issuerDid }); + const credIssuerDidDoc = signerDidDoc; + const vm = (_a = credIssuerDidDoc.verificationMethod) === null || _a === void 0 ? void 0 : _a.find((vm) => vm.id == param.verificationMethodId); + const suite = babyjubjub2021_1.BabyJubJubKeys2021.fromKeys({ + publicKeyMultibase: vm === null || vm === void 0 ? void 0 : vm.publicKeyMultibase, + options: { + id: param.verificationMethodId, + controller: param.issuerDid, + }, + }); + const verifyCredential = yield this.verify({ + credential: param.verifiableCredential, + issuerDid: param.issuerDid, + verificationMethodId: param.verificationMethodId, + }); + if (!verifyCredential.verified == true) { + throw new Error('proofDocument cannot be verified'); + } + return yield (0, babyjubjubsignature2021_1.deriveProof)(param.verifiableCredential, param.frame, { + suite, + documentLoader, + }); + }); + } +} +exports.default = HypersignBJJVerifiableCredential; diff --git a/build/src/credential/credRPC.d.ts b/build/src/credential/credRPC.d.ts index 2747821..79f5fb1 100644 --- a/build/src/credential/credRPC.d.ts +++ b/build/src/credential/credRPC.d.ts @@ -6,11 +6,13 @@ import * as generatedProto from '../../libs/generated/ssi/tx'; import { DeliverTxResponse } from '@cosmjs/stargate'; import { ICredentialRPC } from './ICredential'; -import { CredentialStatus, CredentialProof, Credential } from '../../libs/generated/ssi/credential'; +import { CredentialStatusDocument as CredentialStatus, CredentialStatusState as Credential } from '../../libs/generated/ssi/credential_status'; +import { DocumentProof as CredentialProof } from '../../libs/generated/ssi/proof'; import { OfflineSigner } from '@cosmjs/proto-signing'; export declare class CredentialRPC implements ICredentialRPC { credentialRestEP: string; private hidClient; + private nodeRestEp; constructor({ offlineSigner, nodeRpcEndpoint, nodeRestEndpoint, }: { offlineSigner?: OfflineSigner; nodeRpcEndpoint: string; @@ -24,5 +26,6 @@ export declare class CredentialRPC implements ICredentialRPC { }>; registerCredentialStatusBulk(txMessages: []): Promise; resolveCredentialStatus(credentialId: string): Promise; + updateCredentialStatus(credentialStatus: CredentialStatus, proof: CredentialProof): Promise; } //# sourceMappingURL=credRPC.d.ts.map \ No newline at end of file diff --git a/build/src/credential/credRPC.d.ts.map b/build/src/credential/credRPC.d.ts.map index 153d7e7..b118c2c 100644 --- a/build/src/credential/credRPC.d.ts.map +++ b/build/src/credential/credRPC.d.ts.map @@ -1 +1 @@ -{"version":3,"file":"credRPC.d.ts","sourceRoot":"","sources":["../../../src/credential/credRPC.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,KAAK,cAAc,MAAM,6BAA6B,CAAC;AAC9D,OAAO,EAAyB,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAG5E,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAC/C,OAAO,EAAE,gBAAgB,EAAE,eAAe,EAAE,UAAU,EAAE,MAAM,qCAAqC,CAAC;AACpG,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAEtD,qBAAa,aAAc,YAAW,cAAc;IAC3C,gBAAgB,EAAE,MAAM,CAAC;IAChC,OAAO,CAAC,SAAS,CAAM;gBAEX,EACV,aAAa,EACb,eAAe,EACf,gBAAgB,GACjB,EAAE;QACD,aAAa,CAAC,EAAE,aAAa,CAAC;QAC9B,eAAe,EAAE,MAAM,CAAC;QACxB,gBAAgB,EAAE,MAAM,CAAC;KAC1B;IAWK,IAAI;IAOJ,wBAAwB,CAC5B,gBAAgB,EAAE,gBAAgB,EAClC,KAAK,EAAE,eAAe,GACrB,OAAO,CAAC,iBAAiB,CAAC;IAkCvB,kCAAkC,CAAC,gBAAgB,EAAE,gBAAgB,EAAE,KAAK,EAAE,eAAe;;;;IAuB7F,4BAA4B,CAAC,UAAU,EAAE,EAAE;IAe3C,uBAAuB,CAAC,YAAY,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,CAAC;CA6BzE"} \ No newline at end of file +{"version":3,"file":"credRPC.d.ts","sourceRoot":"","sources":["../../../src/credential/credRPC.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,KAAK,cAAc,MAAM,6BAA6B,CAAC;AAC9D,OAAO,EAAyB,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAG5E,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAC/C,OAAO,EACL,wBAAwB,IAAI,gBAAgB,EAC5C,qBAAqB,IAAI,UAAU,EACpC,MAAM,4CAA4C,CAAC;AACpD,OAAO,EAAE,aAAa,IAAI,eAAe,EAAE,MAAM,gCAAgC,CAAC;AAClF,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAItD,qBAAa,aAAc,YAAW,cAAc;IAC3C,gBAAgB,EAAE,MAAM,CAAC;IAChC,OAAO,CAAC,SAAS,CAAM;IACvB,OAAO,CAAC,UAAU,CAAS;gBAEf,EACV,aAAa,EACb,eAAe,EACf,gBAAgB,GACjB,EAAE;QACD,aAAa,CAAC,EAAE,aAAa,CAAC;QAC9B,eAAe,EAAE,MAAM,CAAC;QACxB,gBAAgB,EAAE,MAAM,CAAC;KAC1B;IAYK,IAAI;IAOJ,wBAAwB,CAC5B,gBAAgB,EAAE,gBAAgB,EAClC,KAAK,EAAE,eAAe,GACrB,OAAO,CAAC,iBAAiB,CAAC;IA6CvB,kCAAkC,CAAC,gBAAgB,EAAE,gBAAgB,EAAE,KAAK,EAAE,eAAe;;;;IAsB7F,4BAA4B,CAAC,UAAU,EAAE,EAAE;IA6B3C,uBAAuB,CAAC,YAAY,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,CAAC;IA6BlE,sBAAsB,CAAC,gBAAgB,EAAE,gBAAgB,EAAE,KAAK,EAAE,eAAe,GAAG,OAAO,CAAC,iBAAiB,CAAC;CA4CrH"} \ No newline at end of file diff --git a/build/src/credential/credRPC.js b/build/src/credential/credRPC.js index 35ca09c..8fe6faa 100644 --- a/build/src/credential/credRPC.js +++ b/build/src/credential/credRPC.js @@ -45,6 +45,8 @@ const constants_1 = require("../constants"); const generatedProto = __importStar(require("../../libs/generated/ssi/tx")); const axios_1 = __importDefault(require("axios")); const client_1 = require("../hid/client"); +const utils_1 = __importDefault(require("../utils")); +const constants = __importStar(require("../constants")); class CredentialRPC { constructor({ offlineSigner, nodeRpcEndpoint, nodeRestEndpoint, }) { if (offlineSigner) { @@ -53,6 +55,7 @@ class CredentialRPC { else { this.hidClient = null; } + this.nodeRestEp = nodeRestEndpoint; this.credentialRestEP = (client_1.HIDClient.hidNodeRestEndpoint ? client_1.HIDClient.hidNodeRestEndpoint : nodeRestEndpoint) + constants_1.HYPERSIGN_NETWORK_CREDENTIALSTATUS_PATH; @@ -80,14 +83,26 @@ class CredentialRPC { const txMessage = { typeUrl, value: generatedProto[constants_1.HIDRpcEnums.MsgRegisterCredentialStatus].fromPartial({ - credentialStatus, - proof, - creator: client_1.HIDClient.getHidWalletAddress(), + credentialStatusDocument: credentialStatus, + credentialStatusProof: proof, + txAuthor: client_1.HIDClient.getHidWalletAddress(), }), }; - const fee = 'auto'; + const amount = yield utils_1.default.fetchFee(constants.GAS_FEE_METHODS.Register_Cred_Status, this.nodeRestEp); + const fee = { + amount: [ + { + denom: 'uhid', + amount: amount, + }, + ], + gas: '200000', + }; const hidClient = client_1.HIDClient.getHidClient(); const txResult = yield hidClient.signAndBroadcast(client_1.HIDClient.getHidWalletAddress(), [txMessage], fee); + if (txResult.code !== 0) { + throw new Error(`${txResult.rawLog}`); + } return txResult; }); } @@ -103,9 +118,9 @@ class CredentialRPC { const txMessage = { typeUrl, value: generatedProto[constants_1.HIDRpcEnums.MsgRegisterCredentialStatus].fromPartial({ - credentialStatus, - proof, - creator: client_1.HIDClient.getHidWalletAddress(), + credentialStatusDocument: credentialStatus, + credentialStatusProof: proof, + txAuthor: client_1.HIDClient.getHidWalletAddress(), }), }; return txMessage; @@ -116,9 +131,22 @@ class CredentialRPC { if (!this.hidClient) { throw new Error('HID-SSI-SDK:: Error: CredentialRPC class is not initialise with offlinesigner'); } - const fee = 'auto'; + const txLenght = txMessages.length; + const amount = (txLenght * parseInt(yield utils_1.default.fetchFee(constants.GAS_FEE_METHODS.Register_Cred_Status, this.nodeRestEp))).toString(); + const fee = { + amount: [ + { + denom: 'uhid', + amount: amount, + }, + ], + gas: '200000', + }; const hidClient = client_1.HIDClient.getHidClient(); const txResult = yield hidClient.signAndBroadcast(client_1.HIDClient.getHidWalletAddress(), txMessages, fee); + if (txResult.code !== 0) { + throw new Error(`${txResult.rawLog}`); + } return txResult; }); } @@ -132,8 +160,8 @@ class CredentialRPC { if (!response.data) { throw new Error('Could not resolve credential status of credentialId ' + credentialId); } - const credStatus = response.data.credStatus; - if (!credStatus || !credStatus.claim || !credStatus.proof) { + const credStatus = response.data.credentialStatus; + if (!credStatus || !credStatus.credentialStatusDocument || !credStatus.credentialStatusProof) { throw new Error('No credential status found. Probably invalid credentialId'); } return credStatus; @@ -147,12 +175,50 @@ class CredentialRPC { credentialHash: '', proof: null, }; - if (!credStatus || !credStatus.claim || !credStatus.proof) { + if (!credStatus || !credStatus.credentialStatusDocument || !credStatus.credentialStatusProof) { throw new Error('No credential status found. Probably invalid credentialId'); } return credStatus; } }); } + updateCredentialStatus(credentialStatus, proof) { + return __awaiter(this, void 0, void 0, function* () { + if (!credentialStatus) { + throw new Error('CredentialStatus must be passed as a param while registerting credential status'); + } + if (!proof) { + throw new Error('Proof must be passed as a param while registering crdential status'); + } + if (!this.hidClient) { + throw new Error('HID-SSI-SDK:: Error: CredentialRPC class is not initialise with offlinesigner'); + } + const typeUrl = `${constants_1.HID_COSMOS_MODULE}.${constants_1.HIDRpcEnums.MsgUpdateCredentialStatus}`; + const txMessage = { + typeUrl, + value: generatedProto[constants_1.HIDRpcEnums.MsgUpdateCredentialStatus].fromPartial({ + credentialStatusDocument: credentialStatus, + credentialStatusProof: proof, + txAuthor: client_1.HIDClient.getHidWalletAddress(), + }), + }; + const amount = yield utils_1.default.fetchFee(constants.GAS_FEE_METHODS.Update_Cred_Status, this.nodeRestEp); + const fee = { + amount: [ + { + denom: 'uhid', + amount: amount, + }, + ], + gas: '200000', + }; + const hidClient = client_1.HIDClient.getHidClient(); + const txResult = yield hidClient.signAndBroadcast(client_1.HIDClient.getHidWalletAddress(), [txMessage], fee); + if (txResult.code !== 0) { + throw new Error(`${txResult.rawLog}`); + } + return txResult; + }); + } } exports.CredentialRPC = CredentialRPC; diff --git a/build/src/credential/vc.d.ts b/build/src/credential/vc.d.ts index 8037c60..6125c22 100644 --- a/build/src/credential/vc.d.ts +++ b/build/src/credential/vc.d.ts @@ -1,8 +1,11 @@ -import { ICredentialMethods, IVerifiableCredential, ICredentialStatus, ISchema, ICredentialProof } from './ICredential'; -import { CredentialStatus, CredentialProof } from '../../libs/generated/ssi/credential'; +import { ICredentialMethods, IVerifiableCredential, ICredentialStatus, ISchema, ICredentialProof, IResolveCredential } from './ICredential'; +import { CredentialStatusDocument as CredentialStatus } from '../../libs/generated/ssi/credential_status'; +import { DocumentProof as CredentialProof } from '../../libs/generated/ssi/proof'; import { DeliverTxResponse } from '@cosmjs/stargate'; import { OfflineSigner } from '@cosmjs/proto-signing'; import { IClientSpec } from '../did/IDID'; +import HypersignBJJVerifiableCredential from './bjjvc'; +import Web3 from 'web3'; export default class HypersignVerifiableCredential implements ICredentialMethods, IVerifiableCredential { '@context': Array; id: string; @@ -19,6 +22,7 @@ export default class HypersignVerifiableCredential implements ICredentialMethods private namespace; private hsSchema; private hsDid; + bjjVC: HypersignBJJVerifiableCredential; constructor(params?: { namespace?: string; offlineSigner?: OfflineSigner; @@ -26,13 +30,12 @@ export default class HypersignVerifiableCredential implements ICredentialMethods nodeRestEndpoint?: string; entityApiSecretKey?: string; }); - private _sign; + private _jsonLdSign; private _dateNow; - private _sha256Hash; private _getId; private _checkIfAllRequiredPropsAreSent; private _getCredentialSubject; - private _getCredentialContext; + private _toTitleCase; /** * Initialise the offlinesigner to interact with Hypersign blockchain */ @@ -102,11 +105,11 @@ export default class HypersignVerifiableCredential implements ICredentialMethods * Resolves credential status from Hypersign Blokchain * @params * - params.credentialId : Verifiable credential id - * @returns {Promise} + * @returns {Promise} */ resolveCredentialStatus(params: { credentialId: string; - }): Promise; + }): Promise; /** * Update credential status in blockchain Hypersign Blokchain * @params @@ -125,7 +128,11 @@ export default class HypersignVerifiableCredential implements ICredentialMethods privateKeyMultibase: string; status: string; statusReason?: string; - }): Promise; + readonly?: boolean; + }): Promise; /** * Check status of credential on Hypersign Chain * @param @@ -186,7 +193,8 @@ export default class HypersignVerifiableCredential implements ICredentialMethods issuerDid: string; verificationMethodId: string; type?: string; - web3Obj: any; + web3Obj?: Web3 | undefined; + privateKey?: string; registerCredential?: boolean; domain?: string; clientSpec?: IClientSpec; @@ -206,7 +214,6 @@ export default class HypersignVerifiableCredential implements ICredentialMethods credential: IVerifiableCredential; issuerDid: string; verificationMethodId: string; - web3Obj: any; }): Promise; } //# sourceMappingURL=vc.d.ts.map \ No newline at end of file diff --git a/build/src/credential/vc.d.ts.map b/build/src/credential/vc.d.ts.map index cc72c1a..7c79efa 100644 --- a/build/src/credential/vc.d.ts.map +++ b/build/src/credential/vc.d.ts.map @@ -1 +1 @@ -{"version":3,"file":"vc.d.ts","sourceRoot":"","sources":["../../../src/credential/vc.ts"],"names":[],"mappings":"AAgBA,OAAO,EAAE,kBAAkB,EAAE,qBAAqB,EAAE,iBAAiB,EAAE,OAAO,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AAExH,OAAO,EAAE,gBAAgB,EAAE,eAAe,EAAqB,MAAM,qCAAqC,CAAC;AAC3G,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AACrD,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAItD,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAO1C,MAAM,CAAC,OAAO,OAAO,6BAA8B,YAAW,kBAAkB,EAAE,qBAAqB;IAC9F,UAAU,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;IAC1B,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;IACpB,MAAM,EAAE,MAAM,CAAC;IACf,YAAY,EAAE,MAAM,CAAC;IACrB,cAAc,EAAE,MAAM,CAAC;IACvB,iBAAiB,EAAE,MAAM,CAAC;IAC1B,gBAAgB,EAAE,OAAO,CAAC;IAC1B,KAAK,EAAE,gBAAgB,CAAC;IACxB,gBAAgB,EAAE,iBAAiB,CAAC;IAC3C,OAAO,CAAC,aAAa,CAAuB;IAC5C,OAAO,CAAC,oBAAoB,CAA4B;IACxD,OAAO,CAAC,SAAS,CAAS;IAC1B,OAAO,CAAC,QAAQ,CAAkB;IAClC,OAAO,CAAC,KAAK,CAAe;gBAG1B,MAAM,GAAE;QACN,SAAS,CAAC,EAAE,MAAM,CAAC;QACnB,aAAa,CAAC,EAAE,aAAa,CAAC;QAC9B,eAAe,CAAC,EAAE,MAAM,CAAC;QACzB,gBAAgB,CAAC,EAAE,MAAM,CAAC;QAC1B,kBAAkB,CAAC,EAAE,MAAM,CAAC;KACxB;YAoCM,KAAK;IAcnB,OAAO,CAAC,QAAQ;IAQhB,OAAO,CAAC,WAAW;YAKL,MAAM;IAWpB,OAAO,CAAC,+BAA+B,CAErC;IAEF,OAAO,CAAC,qBAAqB,CAgC3B;IAKF,OAAO,CAAC,qBAAqB,CAyB3B;IAEF;;OAEG;IACU,IAAI;IAcjB;;;;;;;;;;;OAWG;IACU,QAAQ,CAAC,MAAM,EAAE;QAC5B,QAAQ,CAAC,EAAE,MAAM,CAAC;QAClB,UAAU,CAAC,EAAE,MAAM,CAAC;QACpB,mBAAmB,CAAC,EAAE,IAAI,CAAC;QAC3B,aAAa,CAAC,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;QAC9B,IAAI,CAAC,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;QACrB,SAAS,EAAE,MAAM,CAAC;QAClB,cAAc,EAAE,MAAM,CAAC;QACvB,MAAM,EAAE,MAAM,CAAC;KAChB,GAAG,OAAO,CAAC,qBAAqB,CAAC;IA8HlC;;;;;;;;;;;;;OAaG;IACU,KAAK,CAAC,MAAM,EAAE;QACzB,UAAU,EAAE,qBAAqB,CAAC;QAClC,SAAS,EAAE,MAAM,CAAC;QAClB,oBAAoB,EAAE,MAAM,CAAC;QAC7B,mBAAmB,EAAE,MAAM,CAAC;QAC5B,kBAAkB,CAAC,EAAE,OAAO,CAAC;KAC9B,GAAG,OAAO,CAAC;QACV,gBAAgB,EAAE,qBAAqB,CAAC;QACxC,gBAAgB,EAAE,gBAAgB,CAAC;QACnC,qBAAqB,EAAE,eAAe,CAAC;QACvC,kCAAkC,CAAC,EAAE,iBAAiB,CAAC;KACxD,CAAC;IA0IF;;;;;;;OAOG;IACU,MAAM,CAAC,MAAM,EAAE;QAC1B,UAAU,EAAE,qBAAqB,CAAC;QAClC,SAAS,EAAE,MAAM,CAAC;QAClB,oBAAoB,EAAE,MAAM,CAAC;KAC9B,GAAG,OAAO,CAAC,MAAM,CAAC;IA8DnB;;;;;OAKG;IACU,uBAAuB,CAAC,MAAM,EAAE;QAAE,YAAY,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC,gBAAgB,CAAC;IAajG;;;;;;;;;;OAUG;IACU,sBAAsB,CAAC,MAAM,EAAE;QAC1C,gBAAgB,EAAE,gBAAgB,CAAC;QACnC,SAAS,EAAE,MAAM,CAAC;QAClB,oBAAoB,EAAE,MAAM,CAAC;QAC7B,mBAAmB,EAAE,MAAM,CAAC;QAC5B,MAAM,EAAE,MAAM,CAAC;QACf,YAAY,CAAC,EAAE,MAAM,CAAC;KACvB,GAAG,OAAO,CAAC,iBAAiB,CAAC;IAgH9B;;;;;OAKG;IAEU,qBAAqB,CAAC,MAAM,EAAE;QAAE,YAAY,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC;QAAE,QAAQ,EAAE,OAAO,CAAA;KAAE,CAAC;IA4BpG;;;;;;OAMG;IACU,wBAAwB,CAAC,MAAM,EAAE;QAC5C,gBAAgB,EAAE,gBAAgB,CAAC;QACnC,qBAAqB,EAAE,eAAe,CAAC;KACxC,GAAG,OAAO,CAAC;QAAE,eAAe,EAAE,MAAM,CAAA;KAAE,CAAC;IAiCxC;;;;;;OAMG;IACU,0CAA0C,CAAC,gBAAgB,EAAE,gBAAgB,EAAE,KAAK,EAAE,eAAe;;;;IAalH;;;;;OAKG;IAEU,+BAA+B,CAAC,UAAU,EAAE,EAAE;IAgB3D;;;;;;;;;;;;OAYG;IAEU,iBAAiB,CAAC,MAAM,EAAE;QACrC,UAAU,EAAE,qBAAqB,CAAC;QAClC,SAAS,EAAE,MAAM,CAAC;QAClB,oBAAoB,EAAE,MAAM,CAAC;QAC7B,IAAI,CAAC,EAAE,MAAM,CAAC;QACd,OAAO,MAAC;QACR,kBAAkB,CAAC,EAAE,OAAO,CAAC;QAC7B,MAAM,CAAC,EAAE,MAAM,CAAC;QAChB,UAAU,CAAC,EAAE,WAAW,CAAC;KAC1B;;;IAqED;;;;;;;;OAQG;IAEU,kBAAkB,CAAC,MAAM,EAAE;QACtC,UAAU,EAAE,qBAAqB,CAAC;QAClC,SAAS,EAAE,MAAM,CAAC;QAClB,oBAAoB,EAAE,MAAM,CAAC;QAC7B,OAAO,MAAC;KACT,GAAG,OAAO,CAAC,MAAM,CAAC;CAmCpB"} \ No newline at end of file +{"version":3,"file":"vc.d.ts","sourceRoot":"","sources":["../../../src/credential/vc.ts"],"names":[],"mappings":"AAqBA,OAAO,EACL,kBAAkB,EAClB,qBAAqB,EACrB,iBAAiB,EACjB,OAAO,EACP,gBAAgB,EAChB,kBAAkB,EACnB,MAAM,eAAe,CAAC;AAEvB,OAAO,EACL,wBAAwB,IAAI,gBAAgB,EAG7C,MAAM,4CAA4C,CAAC;AACpD,OAAO,EAAE,aAAa,IAAI,eAAe,EAAE,MAAM,gCAAgC,CAAC;AAClF,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AACrD,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAGtD,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAM1C,OAAO,gCAAgC,MAAM,SAAS,CAAC;AACvD,OAAO,IAAI,MAAM,MAAM,CAAC;AAIxB,MAAM,CAAC,OAAO,OAAO,6BAA8B,YAAW,kBAAkB,EAAE,qBAAqB;IAC9F,UAAU,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;IAC1B,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;IACpB,MAAM,EAAE,MAAM,CAAC;IACf,YAAY,EAAE,MAAM,CAAC;IACrB,cAAc,EAAE,MAAM,CAAC;IACvB,iBAAiB,EAAE,MAAM,CAAC;IAC1B,gBAAgB,EAAE,OAAO,CAAC;IAC1B,KAAK,EAAE,gBAAgB,CAAC;IACxB,gBAAgB,EAAE,iBAAiB,CAAC;IAC3C,OAAO,CAAC,aAAa,CAAuB;IAC5C,OAAO,CAAC,oBAAoB,CAA4B;IACxD,OAAO,CAAC,SAAS,CAAS;IAC1B,OAAO,CAAC,QAAQ,CAAkB;IAClC,OAAO,CAAC,KAAK,CAAe;IACrB,KAAK,EAAE,gCAAgC,CAAC;gBAG7C,MAAM,GAAE;QACN,SAAS,CAAC,EAAE,MAAM,CAAC;QACnB,aAAa,CAAC,EAAE,aAAa,CAAC;QAC9B,eAAe,CAAC,EAAE,MAAM,CAAC;QACzB,gBAAgB,CAAC,EAAE,MAAM,CAAC;QAC1B,kBAAkB,CAAC,EAAE,MAAM,CAAC;KACxB;YAqCM,WAAW;IAqBzB,OAAO,CAAC,QAAQ;YAQF,MAAM;IAWpB,OAAO,CAAC,+BAA+B,CAErC;IAEF,OAAO,CAAC,qBAAqB,CAgC3B;YAmCY,YAAY;IAG1B;;OAEG;IACU,IAAI;IAcjB;;;;;;;;;;;OAWG;IACU,QAAQ,CAAC,MAAM,EAAE;QAC5B,QAAQ,CAAC,EAAE,MAAM,CAAC;QAClB,UAAU,CAAC,EAAE,MAAM,CAAC;QACpB,mBAAmB,CAAC,EAAE,IAAI,CAAC;QAC3B,aAAa,CAAC,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;QAC9B,IAAI,CAAC,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;QACrB,SAAS,EAAE,MAAM,CAAC;QAClB,cAAc,EAAE,MAAM,CAAC;QACvB,MAAM,EAAE,MAAM,CAAC;KAChB,GAAG,OAAO,CAAC,qBAAqB,CAAC;IA+IlC;;;;;;;;;;;;;OAaG;IACU,KAAK,CAAC,MAAM,EAAE;QACzB,UAAU,EAAE,qBAAqB,CAAC;QAClC,SAAS,EAAE,MAAM,CAAC;QAClB,oBAAoB,EAAE,MAAM,CAAC;QAC7B,mBAAmB,EAAE,MAAM,CAAC;QAC5B,kBAAkB,CAAC,EAAE,OAAO,CAAC;KAC9B,GAAG,OAAO,CAAC;QACV,gBAAgB,EAAE,qBAAqB,CAAC;QACxC,gBAAgB,EAAE,gBAAgB,CAAC;QACnC,qBAAqB,EAAE,eAAe,CAAC;QACvC,kCAAkC,CAAC,EAAE,iBAAiB,CAAC;KACxD,CAAC;IA8HF;;;;;;;OAOG;IACU,MAAM,CAAC,MAAM,EAAE;QAC1B,UAAU,EAAE,qBAAqB,CAAC;QAClC,SAAS,EAAE,MAAM,CAAC;QAClB,oBAAoB,EAAE,MAAM,CAAC;KAC9B,GAAG,OAAO,CAAC,MAAM,CAAC;IA4DnB;;;;;OAKG;IACU,uBAAuB,CAAC,MAAM,EAAE;QAAE,YAAY,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC,kBAAkB,CAAC;IAiBnG;;;;;;;;;;OAUG;IACU,sBAAsB,CAAC,MAAM,EAAE;QAC1C,gBAAgB,EAAE,gBAAgB,CAAC;QACnC,SAAS,EAAE,MAAM,CAAC;QAClB,oBAAoB,EAAE,MAAM,CAAC;QAC7B,mBAAmB,EAAE,MAAM,CAAC;QAC5B,MAAM,EAAE,MAAM,CAAC;QACf,YAAY,CAAC,EAAE,MAAM,CAAC;QACtB,QAAQ,CAAC,EAAE,OAAO,CAAC;KACpB,GAAG,OAAO,CAAC,iBAAiB,GAAG;QAAE,gBAAgB,EAAE,gBAAgB,CAAC;QAAC,UAAU,EAAE,GAAG,CAAA;KAAE,CAAC;IA2GxF;;;;;OAKG;IAEU,qBAAqB,CAAC,MAAM,EAAE;QAAE,YAAY,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC;QAAE,QAAQ,EAAE,OAAO,CAAA;KAAE,CAAC;IA+BpG;;;;;;OAMG;IACU,wBAAwB,CAAC,MAAM,EAAE;QAC5C,gBAAgB,EAAE,gBAAgB,CAAC;QACnC,qBAAqB,EAAE,eAAe,CAAC;KACxC,GAAG,OAAO,CAAC;QAAE,eAAe,EAAE,MAAM,CAAA;KAAE,CAAC;IAiCxC;;;;;;OAMG;IACU,0CAA0C,CAAC,gBAAgB,EAAE,gBAAgB,EAAE,KAAK,EAAE,eAAe;;;;IAalH;;;;;OAKG;IAEU,+BAA+B,CAAC,UAAU,EAAE,EAAE;IAiB3D;;;;;;;;;;;;OAYG;IAEU,iBAAiB,CAAC,MAAM,EAAE;QACrC,UAAU,EAAE,qBAAqB,CAAC;QAClC,SAAS,EAAE,MAAM,CAAC;QAClB,oBAAoB,EAAE,MAAM,CAAC;QAC7B,IAAI,CAAC,EAAE,MAAM,CAAC;QACd,OAAO,CAAC,EAAE,IAAI,GAAG,SAAS,CAAC;QAC3B,UAAU,CAAC,EAAE,MAAM,CAAC;QACpB,kBAAkB,CAAC,EAAE,OAAO,CAAC;QAC7B,MAAM,CAAC,EAAE,MAAM,CAAC;QAChB,UAAU,CAAC,EAAE,WAAW,CAAC;KAC1B;;;IAiFD;;;;;;;;OAQG;IAEU,kBAAkB,CAAC,MAAM,EAAE;QACtC,UAAU,EAAE,qBAAqB,CAAC;QAClC,SAAS,EAAE,MAAM,CAAC;QAClB,oBAAoB,EAAE,MAAM,CAAC;KAC9B,GAAG,OAAO,CAAC,MAAM,CAAC;CAsCpB"} \ No newline at end of file diff --git a/build/src/credential/vc.js b/build/src/credential/vc.js index cef4b6f..699ce11 100644 --- a/build/src/credential/vc.js +++ b/build/src/credential/vc.js @@ -1,4 +1,27 @@ "use strict"; +var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + var desc = Object.getOwnPropertyDescriptor(m, k); + if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { + desc = { enumerable: true, get: function() { return m[k]; } }; + } + Object.defineProperty(o, k2, desc); +}) : (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + o[k2] = m[k]; +})); +var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { + Object.defineProperty(o, "default", { enumerable: true, value: v }); +}) : function(o, v) { + o["default"] = v; +}); +var __importStar = (this && this.__importStar) || function (mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); + __setModuleDefault(result, mod); + return result; +}; var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } return new (P || (P = Promise))(function (resolve, reject) { @@ -17,23 +40,26 @@ Object.defineProperty(exports, "__esModule", { value: true }); * All rights reserved. * Author: Hypermine Core Team */ -const jsonld_signatures_1 = require("jsonld-signatures"); -const vc_js_1 = __importDefault(require("vc-js")); +const jsonld_signatures_1 = __importDefault(require("jsonld-signatures")); +const jsonld_signatures_2 = require("jsonld-signatures"); const utils_1 = __importDefault(require("../utils")); const schema_1 = __importDefault(require("../schema/schema")); const did_1 = __importDefault(require("../did/did")); +const jsonSchemaValidator = __importStar(require("@cfworker/json-schema")); const ed25519_verification_key_2020_1 = require("@digitalbazaar/ed25519-verification-key-2020"); const ed25519_signature_2020_1 = require("@digitalbazaar/ed25519-signature-2020"); -const ed25519 = require('@stablelib/ed25519'); +const jsonld_signatures_3 = __importDefault(require("jsonld-signatures")); +const { AssertionProofPurpose } = jsonld_signatures_3.default.purposes; const credRPC_1 = require("./credRPC"); const constants_1 = require("../constants"); -const credential_1 = require("../../libs/generated/ssi/credential"); -const crypto_1 = __importDefault(require("crypto")); const v1_1 = __importDefault(require("../../libs/w3cache/v1")); const ethereumeip712signature2021suite_1 = require("ethereumeip712signature2021suite"); -const jsonld_signatures_2 = require("jsonld-signatures"); +const jsonld_signatures_4 = require("jsonld-signatures"); const credential_service_1 = __importDefault(require("../ssiApi/services/credential/credential.service")); -const documentLoader = (0, jsonld_signatures_2.extendContextLoader)(v1_1.default); +const constant = __importStar(require("../constants")); +const bjjvc_1 = __importDefault(require("./bjjvc")); +const { Merklizer } = require('@iden3/js-jsonld-merklization'); +const documentLoader = (0, jsonld_signatures_4.extendContextLoader)(v1_1.default); class HypersignVerifiableCredential { constructor(params = {}) { this._checkIfAllRequiredPropsAreSent = (sentAttributes, requiredProps) => { @@ -66,31 +92,6 @@ class HypersignVerifiableCredential { }); return cs; }; - // - // TODO: https://www.w3.org/TR/vc-data-model/#data-schemas - // TODO: handle schemaUrl variable properly later. - this._getCredentialContext = (schemaId, schemaProperties) => { - const context = []; - let schemaUrl; - if (this.hsSchema && this.hsSchema.schemaRpc) { - schemaUrl = `${this.hsSchema.schemaRpc.schemaRestEp}/${schemaId}:`; - } - else { - throw new Error('Error: HypersigSchema object may not be initialized'); - } - context.push(constants_1.VC.CREDENTAIL_BASE_CONTEXT); - //context.push(VC.CREDENTAIL_SECURITY_SUITE); - context.push({ - hs: schemaUrl, - }); - const props = Object.keys(schemaProperties); - props.forEach((x) => { - const obj = {}; - obj[x] = `hs:${x}`; - context.push(obj); - }); - return context; - }; const { namespace, offlineSigner, nodeRpcEndpoint, nodeRestEndpoint, entityApiSecretKey } = params; this.namespace = namespace && namespace != '' ? namespace : ''; const nodeRPCEp = nodeRpcEndpoint ? nodeRpcEndpoint : 'MAIN'; @@ -122,18 +123,23 @@ class HypersignVerifiableCredential { type: constants_1.VC.CREDENTAIL_STATUS_TYPE, }; this.proof = {}; + this.bjjVC = new bjjvc_1.default(params); } - _sign(params) { + _jsonLdSign(params) { return __awaiter(this, void 0, void 0, function* () { - const { privateKeyMultibase: privateKeyMultibaseConverted } = utils_1.default.convertEd25519verificationkey2020toStableLibKeysInto({ - privKey: params.privateKeyMultibase, + const { credentialStatus, privateKeyMultibase, verificationMethodId } = params; + const keyPair = yield ed25519_verification_key_2020_1.Ed25519VerificationKey2020.from({ + id: verificationMethodId, + privateKeyMultibase: privateKeyMultibase, + publicKeyMultibase: params.publicKeyMultibase, + }); + const suite = new ed25519_signature_2020_1.Ed25519Signature2020({ key: keyPair }); + const signedCredStatus = yield jsonld_signatures_3.default.sign(credentialStatus, { + suite, + purpose: new AssertionProofPurpose(), + documentLoader: v1_1.default, }); - // TODO: do proper checck of paramaters - const credentialStatus = JSON.parse(params.message); - const credentialBytes = (yield credential_1.CredentialStatus.encode(credentialStatus)).finish(); - // const messageBytes = Buffer.from(params.message); - const signed = ed25519.sign(privateKeyMultibaseConverted, credentialBytes); - return Buffer.from(signed).toString('base64'); + return signedCredStatus.proof; }); } _dateNow(date) { @@ -144,10 +150,6 @@ class HypersignVerifiableCredential { return new Date(new Date().getTime() - 100000).toISOString().slice(0, -5) + 'Z'; } } - _sha256Hash(message) { - const sha256 = crypto_1.default.createHash('sha256'); - return sha256.update(message).digest('hex'); - } _getId() { return __awaiter(this, void 0, void 0, function* () { const uuid = yield utils_1.default.getUUID(); @@ -161,6 +163,39 @@ class HypersignVerifiableCredential { return id; }); } + // + // TODO: https://www.w3.org/TR/vc-data-model/#data-schemas + // TODO: handle schemaUrl variable properly later. + // private _getCredentialContext = (schemaId: string, schemaProperties: object, schemaName: string) => { + // const context: any = []; + // let schemaUrl; + // if (this.hsSchema && this.hsSchema.schemaRpc) { + // schemaUrl = `${this.hsSchema.schemaRpc.schemaRestEp}/${schemaId}:`; + // } else { + // throw new Error('Error: HypersigSchema object may not be initialized'); + // } + // context.push(VC.CREDENTAIL_BASE_CONTEXT); + // // context.push(VC.CREDENTAIL_SECURITY_SUITE); + // context.push({ + // hs: schemaUrl, + // }); + // context.push({ + // [schemaName]: `hs:${schemaName}`, + // }); + // const props: Array = Object.keys(schemaProperties); + // props.forEach((x) => { + // const obj = {}; + // obj[x] = `hs:${x}`; + // context.push(obj); + // }); + // context.push(VC.CONTEXT_HypersignCredentialStatus2023); + // return context; + // }; + _toTitleCase(status) { + return __awaiter(this, void 0, void 0, function* () { + return status.charAt(0).toUpperCase() + status.slice(1).toLowerCase(); + }); + } /** * Initialise the offlinesigner to interact with Hypersign blockchain */ @@ -202,7 +237,6 @@ class HypersignVerifiableCredential { const subjectDid = params.subjectDid; let resolvedsubjectDidDoc; const { didDocument: issuerDidDoc } = yield this.hsDid.resolve({ did: issuerDid }); - // if (params.subjectDid) { resolvedsubjectDidDoc = yield this.hsDid.resolve({ did: params.subjectDid }); } @@ -269,10 +303,15 @@ class HypersignVerifiableCredential { // TODO: do proper check for date and time //if(params.expirationDate < new Date()) throw new Error("Expiration date can not be lesser than current date") const vc = {}; - const schemaInternal = schemaDoc.schema; - const schemaProperties = JSON.parse(schemaInternal.properties); + // const schemaInternal = schemaDoc.schema as SchemaProperty; + // const schemaProperties = JSON.parse(schemaInternal.properties as string); + // const schemaName = schemaDoc.name as string; // context - vc['@context'] = this._getCredentialContext(params.schemaId, schemaProperties); + // vc['@context'] = this._getCredentialContext(params.schemaId, schemaProperties, schemaName); + vc['@context'] = [constants_1.VC.CREDENTAIL_BASE_CONTEXT]; + vc['@context'].push(constants_1.VC.CONTEXT_HypersignCredentialStatus2023); + const JsonSchema = this.hsSchema.vcJsonSchema(schemaDoc); + vc['@context'].push(JsonSchema.$metadata.jsonLdContext); /// TODO: need to implement this properly vc.id = yield this._getId(); // Type @@ -283,7 +322,18 @@ class HypersignVerifiableCredential { vc.issuanceDate = this._dateNow(); // TODO: need to remove this. vc.issuer = issuerDid; vc.credentialSubject = {}; - vc.credentialSubject = Object.assign({}, this._getCredentialSubject(schemaDoc.schema, params.fields)); + // ToDo: Implement Schema validation (JSON Schema Validator) + const validator = new jsonSchemaValidator.Validator(JsonSchema, '2020-12', true); + const result = validator.validate({ + credentialSubject: Object.assign({}, params.fields), + }); + if (!result.valid) { + throw result.errors; + } + // vc.credentialSubject = { + // ...this._getCredentialSubject(schemaDoc.schema as SchemaProperty, params.fields), + // }; + vc.credentialSubject = params.fields; vc.credentialSubject['id'] = subjectDid && subjectDid != undefined ? subjectDid : subjectDidDoc.id; vc.credentialSchema = { id: schemaDoc.id, @@ -336,16 +386,11 @@ class HypersignVerifiableCredential { const { didDocument: signerDidDoc } = yield this.hsDid.resolve({ did: params.issuerDid }); if (signerDidDoc === null || signerDidDoc === undefined) throw new Error('HID-SSI-SDK:: Error: Could not resolve issuerDid = ' + params.issuerDid); - // TODO: take verification method from params - const publicKeyId = params.verificationMethodId; // TODO: bad idea - should not hardcode it. + const publicKeyId = params.verificationMethodId; const publicKeyVerMethod = signerDidDoc['verificationMethod'].find((x) => x.id == publicKeyId); if (!publicKeyVerMethod) { throw new Error('HID-SSI-SDK:: Error: Could not find verification method for id = ' + params.verificationMethodId); } - const convertedKeyPair = utils_1.default.convertedStableLibKeysIntoEd25519verificationkey2020({ - publicKey: publicKeyVerMethod.publicKeyMultibase, - }); - publicKeyVerMethod['publicKeyMultibase'] = convertedKeyPair.publicKeyMultibase; const keyPair = yield ed25519_verification_key_2020_1.Ed25519VerificationKey2020.from(Object.assign({ privateKeyMultibase: params.privateKeyMultibase }, publicKeyVerMethod)); const suite = new ed25519_signature_2020_1.Ed25519Signature2020({ verificationMethod: publicKeyId, @@ -354,23 +399,29 @@ class HypersignVerifiableCredential { /// Before we issue the credential the credential status has to be added /// for that we will call RegisterCredentialStatus RPC // Let us generate credentialHash first - const credentialHash = this._sha256Hash(JSON.stringify(params.credential)); + // generating hash using merkelroot hash + const merkelizerObj = yield Merklizer.merklizeJSONLD(JSON.stringify(params.credential), { + documentLoader, + }); + let credentialHash = yield merkelizerObj.mt.root(); + credentialHash = Buffer.from(credentialHash.bytes).toString('hex'); const credentialStatus = { - claim: { - id: params.credential.id, - currentStatus: constants_1.VC.CRED_STATUS_TYPES.LIVE, - statusReason: 'Credential is active', - }, + '@context': [ + constant.VC.CREDENTIAL_STATUS_CONTEXT, + constant.DID_Ed25519VerificationKey2020.DID_Ed25519_CONTEXT_2020, + ], + id: params.credential.id, issuer: params.credential.issuer, issuanceDate: params.credential.issuanceDate, - expirationDate: params.credential.expirationDate, - credentialHash, + remarks: 'Credential is active', + credentialMerkleRootHash: credentialHash, }; - const proofValue = yield this._sign({ - message: JSON.stringify(credentialStatus), + const credProof = yield this._jsonLdSign({ + credentialStatus, privateKeyMultibase: params.privateKeyMultibase, + verificationMethodId: params.verificationMethodId, + publicKeyMultibase: publicKeyVerMethod.publicKeyMultibase, }); - // check params.issuer is a controller of params.credential.issuer const { didDocument: issuerDID } = yield this.hsDid.resolve({ did: params.credential.issuer }); if (issuerDID === null || issuerDID === undefined) throw new Error('Could not resolve issuerDid = ' + params.credential.issuer); @@ -379,40 +430,32 @@ class HypersignVerifiableCredential { if (!credIssuerController.includes(params.issuerDid)) { throw new Error(params.issuerDid + ' is not a controller of ' + params.credential.issuer); } - // const issuerDidDoc: Did = issuerDID as Did; - // const issuerPublicKeyId = params.verificationMethodId; - // const issuerPublicKeyVerMethod: VerificationMethod = issuerDidDoc.verificationMethod.find( - // (x) => x.id == issuerPublicKeyId - // ) as VerificationMethod; - const issuerPublicKeyVerMethod = publicKeyVerMethod; - const proof = { - type: constants_1.VC.VERIFICATION_METHOD_TYPE, - created: this._dateNow(), - updated: this._dateNow(), - verificationMethod: issuerPublicKeyVerMethod.id, - proofValue, - proofPurpose: constants_1.VC.PROOF_PURPOSE, - }; /// RegisterCRedeRPC - const signedVC = yield vc_js_1.default.issue({ - credential: params.credential, + const signedVC = yield jsonld_signatures_1.default.sign(params.credential, { + purpose: new jsonld_signatures_2.purposes.AssertionProofPurpose({ + controller: { + '@context': ['https://www.w3.org/ns/did/v1'], + id: issuerDID.id, + assertionMethod: issuerDID.assertionMethod, + }, + }), suite, documentLoader, }); let credentialStatusRegistrationResult; if (params.registerCredential) { - credentialStatusRegistrationResult = yield this.credStatusRPC.registerCredentialStatus(credentialStatus, proof); + credentialStatusRegistrationResult = yield this.credStatusRPC.registerCredentialStatus(credentialStatus, credProof); if (!credentialStatusRegistrationResult || credentialStatusRegistrationResult.code != 0) { throw new Error('HID-SSI-SDK:: Error while issuing the credential error = ' + credentialStatusRegistrationResult.rawLog); } return { signedCredential: signedVC, credentialStatus, - credentialStatusProof: proof, + credentialStatusProof: credProof, credentialStatusRegistrationResult, }; } - return { signedCredential: signedVC, credentialStatus, credentialStatusProof: proof }; + return { signedCredential: signedVC, credentialStatus, credentialStatusProof: credProof }; }); } // Ref: https://github.com/digitalbazaar/vc-js/blob/44ca660f62ad3569f338eaaaecb11a7b09949bd2/lib/vc.js#L251 @@ -442,12 +485,6 @@ class HypersignVerifiableCredential { const issuerDidDoc = issuerDID; const publicKeyId = params.verificationMethodId; const publicKeyVerMethod = issuerDidDoc.verificationMethod.find((x) => x.id == publicKeyId); - // TODO: Get rid of this hack later. - // Convert 45 byte publick key into 48 - const { publicKeyMultibase } = utils_1.default.convertedStableLibKeysIntoEd25519verificationkey2020({ - publicKey: publicKeyVerMethod.publicKeyMultibase, - }); - publicKeyVerMethod.publicKeyMultibase = publicKeyMultibase; const assertionController = { '@context': constants_1.DID.CONTROLLER_CONTEXT, id: issuerDidDoc.id, @@ -461,17 +498,19 @@ class HypersignVerifiableCredential { /* eslint-disable */ const that = this; /* eslint-enable */ - const result = yield vc_js_1.default.verifyCredential({ - credential: params.credential, - controller: assertionController, + const result = yield jsonld_signatures_1.default.verify(params.credential, { + purpose: new jsonld_signatures_2.purposes.AssertionProofPurpose({ + controller: { + '@context': ['https://www.w3.org/ns/did/v1'], + id: issuerDID.id, + assertionMethod: issuerDID.assertionMethod, + }, + }), suite, documentLoader, - checkStatus: function (options) { - return __awaiter(this, void 0, void 0, function* () { - return yield that.checkCredentialStatus({ credentialId: options.credential.id }); - }); - }, }); + const statusCheck = yield that.checkCredentialStatus({ credentialId: params.credential.id }); + result.statusResult = statusCheck; return result; }); } @@ -479,7 +518,7 @@ class HypersignVerifiableCredential { * Resolves credential status from Hypersign Blokchain * @params * - params.credentialId : Verifiable credential id - * @returns {Promise} + * @returns {Promise} */ resolveCredentialStatus(params) { return __awaiter(this, void 0, void 0, function* () { @@ -490,7 +529,8 @@ class HypersignVerifiableCredential { throw new Error('HID-SSI-SDK:: Error: HypersignVerifiableCred is not instantiated with Offlinesigner or not initialized'); } credentialStatus = yield this.credStatusRPC.resolveCredentialStatus(params.credentialId); - return credentialStatus; + const response = Object.assign(Object.assign({}, credentialStatus.credentialStatusDocument), { proof: credentialStatus.credentialStatusProof }); + return response; }); } /** @@ -505,7 +545,11 @@ class HypersignVerifiableCredential { * @returns {Promise} */ updateCredentialStatus(params) { + var _a; return __awaiter(this, void 0, void 0, function* () { + if (!params.readonly) { + params.readonly = false; + } if (!params.verificationMethodId) { throw new Error('HID-SSI-SDK:: Error: params.verificationMethodId is required to update credential status'); } @@ -530,10 +574,6 @@ class HypersignVerifiableCredential { // TODO: take verification method from params const publicKeyId = params.verificationMethodId; // TODO: bad idea - should not hardcode it. const publicKeyVerMethod = signerDidDoc['verificationMethod'].find((x) => x.id == publicKeyId); - const convertedKeyPair = utils_1.default.convertedStableLibKeysIntoEd25519verificationkey2020({ - publicKey: publicKeyVerMethod.publicKeyMultibase, - }); - publicKeyVerMethod['publicKeyMultibase'] = convertedKeyPair.publicKeyMultibase; const keyPair = yield ed25519_verification_key_2020_1.Ed25519VerificationKey2020.from(Object.assign({ privateKeyMultibase: params.privateKeyMultibase }, publicKeyVerMethod)); const suite = new ed25519_signature_2020_1.Ed25519Signature2020({ verificationMethod: publicKeyId, @@ -542,22 +582,33 @@ class HypersignVerifiableCredential { /// Before we issue the credential the credential status has to be added /// for that we will call RegisterCredentialStatus RPC // Let us generate credentialHash first - params.status = params.status.toUpperCase(); - const claim = params.credentialStatus.claim; + const status = yield this._toTitleCase(params.status); + if (!Object.values(constants_1.CredentialStatusEnums).includes(status)) { + throw new Error(`HID-SSI-SDK:: Error: params.status is invalid`); + } + const claim = params.credentialStatus; const credentialStatus = { - claim: { - id: claim.id, - currentStatus: constants_1.VC.CRED_STATUS_TYPES[params.status], - statusReason: params.statusReason ? params.statusReason : constants_1.VC.CRED_STATUS_REASON_TYPES[params.status], - }, + '@context': [ + constant.VC.CREDENTIAL_STATUS_CONTEXT, + constant.DID_Ed25519VerificationKey2020.DID_Ed25519_CONTEXT_2020, + ], + id: claim.id, + remarks: (_a = params.statusReason) !== null && _a !== void 0 ? _a : constants_1.VC.CRED_STATUS_REASON_TYPES[params.status], issuer: params.credentialStatus.issuer, issuanceDate: params.credentialStatus.issuanceDate, - expirationDate: params.credentialStatus.expirationDate, - credentialHash: params.credentialStatus.credentialHash, + credentialMerkleRootHash: params.credentialStatus.credentialMerkleRootHash, }; - const proofValue = yield this._sign({ - message: JSON.stringify(credentialStatus), + if (status === constants_1.VC.CRED_STATUS_TYPES.REVOKED) { + credentialStatus['revoked'] = true; + } + else if (status === constants_1.VC.CRED_STATUS_TYPES.SUSPENDED) { + credentialStatus['suspended'] = true; + } + const proofValue = yield this._jsonLdSign({ + credentialStatus, privateKeyMultibase: params.privateKeyMultibase, + verificationMethodId: params.verificationMethodId, + publicKeyMultibase: publicKeyVerMethod.publicKeyMultibase, }); const { didDocument: issuerDID } = yield this.hsDid.resolve({ did: params.credentialStatus.issuer }); const issuerDidDoc = issuerDID; @@ -569,20 +620,14 @@ class HypersignVerifiableCredential { const { didDocument: controllerDidDoc } = yield this.hsDid.resolve({ did: verificationMethodController }); if (!controllerDidDoc) throw new Error('HID-SSI-SDK:: Error: params.verificationMethodId does not belong to issuerDid'); - const didDocofController = controllerDidDoc; - const issuerPublicKeyId = params.verificationMethodId; - const issuerPublicKeyVerMethod = didDocofController.verificationMethod.find((x) => x.id == issuerPublicKeyId); - const proof = { - type: constants_1.VC.VERIFICATION_METHOD_TYPE, - created: params.credentialStatus.issuanceDate, - updated: this._dateNow(), - verificationMethod: issuerPublicKeyVerMethod.id, - proofValue, - proofPurpose: constants_1.VC.PROOF_PURPOSE, - }; - /// RegisterCRedeRPC - // We use the same RPC (i.e. MsgRegisterCredentialStatus) for register and update of credential status on blockchain - const resp = yield this.credStatusRPC.registerCredentialStatus(credentialStatus, proof); + if (params.readonly == true) { + return { + credentialStatus, + proofValue, + }; + } + /// UpdateCredRPC + const resp = yield this.credStatusRPC.updateCredentialStatus(credentialStatus, proofValue); if (!resp || resp.code != 0) { throw new Error('HID-SSI-SDK:: Error while revoking the credential error = ' + resp.rawLog); } @@ -596,6 +641,7 @@ class HypersignVerifiableCredential { * @returns {Promise<{ verified: boolean }>} */ checkCredentialStatus(params) { + var _a, _b; return __awaiter(this, void 0, void 0, function* () { if (!params || !params.credentialId) throw new Error('HID-SSI-SDK:: Error: params.credentialId is required to resolve credential status'); @@ -608,11 +654,15 @@ class HypersignVerifiableCredential { if (!credentialStatus) { throw new Error('HID-SSI-SDK:: Error: while checking credential status of credentialID ' + credentialId); } - const claim = credentialStatus.claim; - const { currentStatus, statusReason } = claim; + // const claim: Claim = credentialStatus.claim as Claim; + const { remarks: statusReason } = credentialStatus.credentialStatusDocument; + let currentStatus; /// TODO: probably we should also verify the credential HASH by recalculating the hash of the crdential and // matching with credentialHash property. // const { credentialHash } = credentialStatus; + if (!((_a = credentialStatus.credentialStatusDocument) === null || _a === void 0 ? void 0 : _a.revoked) && !((_b = credentialStatus.credentialStatusDocument) === null || _b === void 0 ? void 0 : _b.suspended)) { + currentStatus = constants_1.VC.CRED_STATUS_TYPES.LIVE; + } if (currentStatus != constants_1.VC.CRED_STATUS_TYPES.LIVE) { console.log('WARN: Credential status is not LIVE, currentStatus ' + currentStatus); console.log('WARN: Status reason is ' + statusReason); @@ -680,7 +730,7 @@ class HypersignVerifiableCredential { */ registerCredentialStatusTxnBulk(txnMessage) { return __awaiter(this, void 0, void 0, function* () { - if (!txnMessage) + if (!txnMessage || txnMessage.length <= 0) throw new Error('HID-SSI-SDK:: Error: txnMessage is required to register credential status'); if (!this.credStatusRPC) { throw new Error('HID-SSI-SDK:: Error: HypersignVerifiableCredential class is not instantiated with Offlinesigner or have not been initilized'); @@ -719,8 +769,8 @@ class HypersignVerifiableCredential { if (!this.credStatusRPC) { throw new Error('HID-SSI-SDK:: Error: HypersignVerifiableCredential class is not instantiated with Offlinesigner or have not been initilized'); } - if (!params.web3Obj) { - throw new Error('HID-SSI-SDK:: Error: prams.web3Obj should be passed'); + if (!params.web3Obj && !params.privateKey) { + throw new Error('HID-SSI-SDK:: Error: prams.web3Obj or prams.privateKey should be passed'); } if (params.type == undefined) { params.type = 'Document'; @@ -736,10 +786,23 @@ class HypersignVerifiableCredential { if (!publicKeyVerMethod) { throw new Error('HID-SSI-SDK:: Error: Could not find verification method for id = ' + params.verificationMethodId); } - const EthereumEip712Signature2021obj = new ethereumeip712signature2021suite_1.EthereumEip712Signature2021({}, params.web3Obj); + let EthereumEip712Signature2021obj; + if (params.privateKey) { + EthereumEip712Signature2021obj = new ethereumeip712signature2021suite_1.EthereumEip712Signature2021({}); + yield EthereumEip712Signature2021obj.fromPrivateKey(params.privateKey); + } + else { + EthereumEip712Signature2021obj = new ethereumeip712signature2021suite_1.EthereumEip712Signature2021({}, params.web3Obj); + } const proof = yield EthereumEip712Signature2021obj.createProof({ document: params.credential, - purpose: new jsonld_signatures_1.purposes.AssertionProofPurpose(), + purpose: new jsonld_signatures_2.purposes.AssertionProofPurpose({ + controller: { + '@context': ['https://w3id.org/security/v2'], + id: signerDidDoc.id, + assertionMethod: [params.verificationMethodId], + }, + }), verificationMethod: params.verificationMethodId, primaryType: params.type, date: new Date().toISOString(), @@ -787,20 +850,23 @@ class HypersignVerifiableCredential { if (!params.issuerDid) { throw new Error('HID-SSI-SDK:: Error: params.issuerDid is required to verify credential'); } - if (!params.web3Obj) { - throw new Error('HID-SSI-SDK:: Error: prams.web3Obj should be passed'); - } const { didDocument } = yield this.hsDid.resolve({ did: params.issuerDid }); if (didDocument === null || didDocument === undefined) throw new Error('HID-SSI-SDK:: Error: Could not resolve issuerDid = ' + params.issuerDid); - const EthereumEip712Signature2021obj = new ethereumeip712signature2021suite_1.EthereumEip712Signature2021({}, params.web3Obj); + const EthereumEip712Signature2021obj = new ethereumeip712signature2021suite_1.EthereumEip712Signature2021({}); const { proof } = params.credential; const verificationResult = yield EthereumEip712Signature2021obj.verifyProof({ proof: proof, document: params.credential, types: proof.eip712.types, domain: proof.eip712.domain, - purpose: new jsonld_signatures_1.purposes.AssertionProofPurpose(), + purpose: new jsonld_signatures_2.purposes.AssertionProofPurpose({ + controller: { + '@context': ['https://w3id.org/security/v2'], + id: didDocument.id, + assertionMethod: [params.verificationMethodId], + }, + }), documentLoader, }); return verificationResult; diff --git a/build/src/did/IDID.d.ts b/build/src/did/IDID.d.ts index 9927653..4697d0a 100644 --- a/build/src/did/IDID.d.ts +++ b/build/src/did/IDID.d.ts @@ -3,46 +3,40 @@ * All rights reserved. * Author: Hypermine Core Team */ -import { Did as IDidProto, Metadata, VerificationMethod, Service, Did, SignInfo } from '../../libs/generated/ssi/did'; -import { ClientSpec } from '../../libs/generated/ssi/clientSpec'; +import { DidDocument as IDidProto, DidDocumentMetadata as Metadata, VerificationMethod, Service, DidDocument } from '../../libs/generated/ssi/did'; +import { DocumentProof as SignInfo } from '../../libs/generated/ssi/proof'; import Web3 from 'web3'; +import { ProofTypes, VerificationMethodRelationships, VerificationMethodTypes } from '../../libs/generated/ssi/client/enums'; export interface IPublicKey { '@context': string; id: string; type: string; publicKeyBase58: string; } -export declare enum IVerificationRelationships { - authentication = "authentication", - assertionMethod = "assertionMethod", - keyAgreement = "keyAgreement", - capabilityInvocation = "capabilityInvocation", - capabilityDelegation = "capabilityDelegation" -} -export declare enum IKeyType { - Ed25519VerificationKey2020 = "Ed25519VerificationKey2020", - EcdsaSecp256k1VerificationKey2019 = "EcdsaSecp256k1VerificationKey2019", - EcdsaSecp256k1RecoveryMethod2020 = "EcdsaSecp256k1RecoveryMethod2020", - X25519KeyAgreementKey2020 = "X25519KeyAgreementKey2020", - X25519KeyAgreementKeyEIP5630 = "X25519KeyAgreementKeyEIP5630" -} export declare enum IClientSpec { 'eth-personalSign' = "eth-personalSign", 'cosmos-ADR036' = "cosmos-ADR036" } -export interface ExtendedClientSpec extends ClientSpec { +export declare enum SupportedPurpose { + 'assertionMethod' = "assertionMethod", + 'authentication' = "authentication" +} +export interface ExtendedClientSpec { type: IClientSpec; - adr036SignerAddress: string; + adr036SignerAddress?: string; } export interface ISignInfo { verification_method_id: string; signature: string; clientSpec?: ExtendedClientSpec | undefined; + created: string; + type?: ProofTypes; } export interface IController { '@context': string; id: string; - authentication: Array; + authentication?: Array; + assertionMethod?: Array; } export interface IParams { doc: object; @@ -80,28 +74,31 @@ export interface IDID { generate(params: { methodSpecificId?: string; publicKeyMultibase: string; - verificationRelationships: IVerificationRelationships[]; - }): Promise; + verificationRelationships: VerificationMethodRelationships[]; + }): Promise; register(params: { - didDocument: Did; + didDocument: DidDocument; privateKeyMultibase?: string; verificationMethodId?: string; signData?: ISignData[]; }): Promise<{ - didDocument: Did; + didDocument: DidDocument; transactionHash: string; }>; resolve(params: { did: string; - ed25519verificationkey2020?: boolean; }): Promise; update(params: { - didDocument: Did; + didDocument: DidDocument; privateKeyMultibase: string; verificationMethodId: string; versionId: string; }): Promise<{ transactionHash: string; + } | { + didDocument: any; + signInfos: any; + versionId: any; }>; deactivate(params: { didDocument: object; @@ -112,7 +109,7 @@ export interface IDID { transactionHash: string; }>; sign(params: { - didDocument: Did; + didDocument: DidDocument; privateKeyMultibase: string; challenge: string; domain: string; @@ -120,70 +117,73 @@ export interface IDID { verificationMethodId: string; }): Promise; verify(params: { - didDocument: Did; + didDocument: DidDocument; verificationMethodId: string; challenge: string; domain?: string; }): Promise; addVerificationMethod(params: { did?: string; - didDocument?: Did; - type: IKeyType; + didDocument?: DidDocument; + type: VerificationMethodTypes; id?: string; controller?: string; publicKeyMultibase?: string; blockchainAccountId?: string; - }): Promise; + }): Promise; createByClientSpec(params: { methodSpecificId: string; publicKey?: string; address: string; chainId: string; clientSpec: IClientSpec; - verificationRelationships?: IVerificationRelationships[]; - }): Promise; + verificationRelationships?: VerificationMethodRelationships[]; + }): Promise; registerByClientSpec(params: { - didDocument: Did; + didDocument: DidDocument; signInfos: SignInfo[]; }): Promise<{ - didDocument: Did; + didDocument: DidDocument; transactionHash: string; }>; updateByClientSpec(params: { - didDocument: Did; + didDocument: DidDocument; versionId: string; signInfos: SignInfo[]; }): Promise<{ transactionHash: string; }>; deactivateByClientSpec(params: { - didDocument: Did; + didDocument: DidDocument; signInfos: SignInfo[]; versionId: string; }): Promise<{ transactionHash: string; }>; signAndRegisterByClientSpec(params: { - didDocument: Did; + didDocument: DidDocument; address: string; verificationMethodId: string; web3: Web3 | any; clientSpec: IClientSpec; chainId?: string; }): Promise<{ - didDocument: Did; + didDocument: DidDocument; transactionHash: string; }>; signByClientSpec(params: { - didDocument: Did; + didDocument: DidDocument; clientSpec: IClientSpec; address: string; web3: Web3 | any; chainId?: string; - }): Promise<{ - didDocument: Did; - signature: string; - }>; + verificationMethodId: any; + }): Promise; + createSignInfos(params: { + didDocument: DidDocument; + privateKeyMultibase: string; + verificationMethodId: string; + }): Promise>; } export interface IDIDResolve { didDocument: IDidDocument; @@ -226,7 +226,7 @@ export interface IDidDocument { export interface ISignData { verificationMethodId: string; privateKeyMultibase: string; - type: IKeyType; + type: VerificationMethodTypes; } export {}; //# sourceMappingURL=IDID.d.ts.map \ No newline at end of file diff --git a/build/src/did/IDID.d.ts.map b/build/src/did/IDID.d.ts.map index 4ef16fc..4212dea 100644 --- a/build/src/did/IDID.d.ts.map +++ b/build/src/did/IDID.d.ts.map @@ -1 +1 @@ -{"version":3,"file":"IDID.d.ts","sourceRoot":"","sources":["../../../src/did/IDID.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,GAAG,IAAI,SAAS,EAAE,QAAQ,EAAE,kBAAkB,EAAE,OAAO,EAAE,GAAG,EAAE,QAAQ,EAAE,MAAM,8BAA8B,CAAC;AACtH,OAAO,EAAE,UAAU,EAAE,MAAM,qCAAqC,CAAC;AACjE,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB,MAAM,WAAW,UAAU;IACzB,UAAU,EAAE,MAAM,CAAC;IACnB,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,eAAe,EAAE,MAAM,CAAC;CACzB;AAED,oBAAY,0BAA0B;IACpC,cAAc,mBAAmB;IACjC,eAAe,oBAAoB;IACnC,YAAY,iBAAiB;IAC7B,oBAAoB,yBAAyB;IAC7C,oBAAoB,yBAAyB;CAC9C;AAED,oBAAY,QAAQ;IAClB,0BAA0B,+BAA+B;IACzD,iCAAiC,sCAAsC;IACvE,gCAAgC,qCAAqC;IACrE,yBAAyB,8BAA8B;IACvD,4BAA4B,iCAAiC;CAC9D;AAED,oBAAY,WAAW;IACrB,kBAAkB,qBAAqB;IACvC,eAAe,kBAAkB;CAClC;AAED,MAAM,WAAW,kBAAmB,SAAQ,UAAU;IACpD,IAAI,EAAE,WAAW,CAAC;IAClB,mBAAmB,EAAE,MAAM,CAAC;CAC7B;AAED,MAAM,WAAW,SAAS;IACxB,sBAAsB,EAAE,MAAM,CAAC;IAC/B,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,CAAC,EAAE,kBAAkB,GAAG,SAAS,CAAC;CAC7C;AAED,MAAM,WAAW,WAAW;IAC1B,UAAU,EAAE,MAAM,CAAC;IACnB,EAAE,EAAE,MAAM,CAAC;IACX,cAAc,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;CAC/B;AAED,MAAM,WAAW,OAAO;IACtB,GAAG,EAAE,MAAM,CAAC;IACZ,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,SAAS,EAAE,UAAU,CAAC;IACtB,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,EAAE,WAAW,CAAC;IACxB,GAAG,EAAE,MAAM,CAAC;IACZ,oBAAoB,EAAE,MAAM,CAAC;CAC9B;AAED,MAAM,WAAW,IAAK,SAAQ,SAAS;IACrC,UAAU,EAAE,KAAK,CAAC,GAAG,CAAC,CAAC;CACxB;AAED,UAAU,MAAM;IACd,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,kBAAkB,EAAE,MAAM,CAAC;IAC3B,YAAY,EAAE,MAAM,CAAC;IACrB,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,kBAAmB,SAAQ,SAAS;IACnD,KAAK,EAAE,MAAM,CAAC;CACf;AAED,MAAM,WAAW,IAAI;IACnB,YAAY,CAAC,MAAM,EAAE;QACnB,IAAI,CAAC,EAAE,MAAM,CAAC;QACd,UAAU,CAAC,EAAE,MAAM,CAAC;KACrB,GAAG,OAAO,CAAC;QAAE,mBAAmB,EAAE,MAAM,CAAC;QAAC,kBAAkB,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IAEzE,QAAQ,CAAC,MAAM,EAAE;QACf,gBAAgB,CAAC,EAAE,MAAM,CAAC;QAC1B,kBAAkB,EAAE,MAAM,CAAC;QAC3B,yBAAyB,EAAE,0BAA0B,EAAE,CAAC;KACzD,GAAG,OAAO,CAAC,GAAG,CAAC,CAAC;IAEjB,QAAQ,CAAC,MAAM,EAAE;QACf,WAAW,EAAE,GAAG,CAAC;QACjB,mBAAmB,CAAC,EAAE,MAAM,CAAC;QAC7B,oBAAoB,CAAC,EAAE,MAAM,CAAC;QAC9B,QAAQ,CAAC,EAAE,SAAS,EAAE,CAAC;KACxB,GAAG,OAAO,CAAC;QAAE,WAAW,EAAE,GAAG,CAAC;QAAC,eAAe,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IAE3D,OAAO,CAAC,MAAM,EAAE;QAAE,GAAG,EAAE,MAAM,CAAC;QAAC,0BAA0B,CAAC,EAAE,OAAO,CAAA;KAAE,GAAG,OAAO,CAAC,WAAW,CAAC,CAAC;IAE7F,MAAM,CAAC,MAAM,EAAE;QACb,WAAW,EAAE,GAAG,CAAC;QACjB,mBAAmB,EAAE,MAAM,CAAC;QAC5B,oBAAoB,EAAE,MAAM,CAAC;QAC7B,SAAS,EAAE,MAAM,CAAC;KACnB,GAAG,OAAO,CAAC;QAAE,eAAe,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IAEzC,UAAU,CAAC,MAAM,EAAE;QACjB,WAAW,EAAE,MAAM,CAAC;QACpB,mBAAmB,EAAE,MAAM,CAAC;QAC5B,oBAAoB,EAAE,MAAM,CAAC;QAC7B,SAAS,EAAE,MAAM,CAAC;KACnB,GAAG,OAAO,CAAC;QAAE,eAAe,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IAGzC,IAAI,CAAC,MAAM,EAAE;QACX,WAAW,EAAE,GAAG,CAAC;QACjB,mBAAmB,EAAE,MAAM,CAAC;QAC5B,SAAS,EAAE,MAAM,CAAC;QAClB,MAAM,EAAE,MAAM,CAAC;QACf,GAAG,EAAE,MAAM,CAAC;QACZ,oBAAoB,EAAE,MAAM,CAAC;KAC9B,GAAG,OAAO,CAAC,kBAAkB,CAAC,CAAC;IAEhC,MAAM,CAAC,MAAM,EAAE;QACb,WAAW,EAAE,GAAG,CAAC;QACjB,oBAAoB,EAAE,MAAM,CAAC;QAC7B,SAAS,EAAE,MAAM,CAAC;QAClB,MAAM,CAAC,EAAE,MAAM,CAAC;KACjB,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;IAEpB,qBAAqB,CAAC,MAAM,EAAE;QAC5B,GAAG,CAAC,EAAE,MAAM,CAAC;QACb,WAAW,CAAC,EAAE,GAAG,CAAC;QAClB,IAAI,EAAE,QAAQ,CAAC;QACf,EAAE,CAAC,EAAE,MAAM,CAAC;QACZ,UAAU,CAAC,EAAE,MAAM,CAAC;QACpB,kBAAkB,CAAC,EAAE,MAAM,CAAC;QAC5B,mBAAmB,CAAC,EAAE,MAAM,CAAC;KAC9B,GAAG,OAAO,CAAC,GAAG,CAAC,CAAC;IAEjB,kBAAkB,CAAC,MAAM,EAAE;QACzB,gBAAgB,EAAE,MAAM,CAAC;QACzB,SAAS,CAAC,EAAE,MAAM,CAAC;QACnB,OAAO,EAAE,MAAM,CAAC;QAChB,OAAO,EAAE,MAAM,CAAC;QAChB,UAAU,EAAE,WAAW,CAAC;QACxB,yBAAyB,CAAC,EAAE,0BAA0B,EAAE,CAAC;KAC1D,GAAG,OAAO,CAAC,GAAG,CAAC,CAAC;IACjB,oBAAoB,CAAC,MAAM,EAAE;QAC3B,WAAW,EAAE,GAAG,CAAC;QACjB,SAAS,EAAE,QAAQ,EAAE,CAAC;KACvB,GAAG,OAAO,CAAC;QAAE,WAAW,EAAE,GAAG,CAAC;QAAC,eAAe,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IAE3D,kBAAkB,CAAC,MAAM,EAAE;QACzB,WAAW,EAAE,GAAG,CAAC;QACjB,SAAS,EAAE,MAAM,CAAC;QAClB,SAAS,EAAE,QAAQ,EAAE,CAAC;KACvB,GAAG,OAAO,CAAC;QAAE,eAAe,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IAEzC,sBAAsB,CAAC,MAAM,EAAE;QAC7B,WAAW,EAAE,GAAG,CAAC;QACjB,SAAS,EAAE,QAAQ,EAAE,CAAC;QACtB,SAAS,EAAE,MAAM,CAAC;KACnB,GAAG,OAAO,CAAC;QAAE,eAAe,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IAEzC,2BAA2B,CAAC,MAAM,EAAE;QAClC,WAAW,EAAE,GAAG,CAAC;QACjB,OAAO,EAAE,MAAM,CAAC;QAChB,oBAAoB,EAAE,MAAM,CAAC;QAC7B,IAAI,EAAE,IAAI,GAAG,GAAG,CAAC;QACjB,UAAU,EAAE,WAAW,CAAC;QACxB,OAAO,CAAC,EAAE,MAAM,CAAC;KAClB,GAAG,OAAO,CAAC;QAAE,WAAW,EAAE,GAAG,CAAC;QAAC,eAAe,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IAC3D,gBAAgB,CAAC,MAAM,EAAE;QACvB,WAAW,EAAE,GAAG,CAAC;QACjB,UAAU,EAAE,WAAW,CAAC;QACxB,OAAO,EAAE,MAAM,CAAC;QAChB,IAAI,EAAE,IAAI,GAAG,GAAG,CAAC;QACjB,OAAO,CAAC,EAAE,MAAM,CAAC;KAClB,GAAG,OAAO,CAAC;QAAE,WAAW,EAAE,GAAG,CAAC;QAAC,SAAS,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;CACtD;AAED,MAAM,WAAW,WAAW;IAC1B,WAAW,EAAE,YAAY,CAAC;IAC1B,mBAAmB,EAAE,QAAQ,CAAC;CAC/B;AAED,MAAM,WAAW,OAAO;IACtB,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,UAAU,CAAC;CAClB;AAED,MAAM,WAAW,iBAAiB;IAChC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,0DAA0D;IAC1D,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,eAAe,EAAE,MAAM,CAAC;IACjC,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,IAAI,CAAC,EAAE,SAAS,OAAO,EAAE,CAAC;IACnC,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;CAC5B;AAED,MAAM,WAAW,OAAO;IACtB,WAAW,CAAC,MAAM,EAAE,SAAS,EAAE,SAAS,EAAE,QAAQ,EAAE,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAAC;IAClF,SAAS,CAAC,MAAM,EAAE,SAAS,GAAG,GAAG,EAAE,SAAS,EAAE,QAAQ,EAAE,EAAE,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAAC;IACzG,aAAa,CAAC,GAAG,EAAE,MAAM,EAAE,SAAS,EAAE,QAAQ,EAAE,EAAE,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAAC;IACjG,UAAU,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,CAAC,CAAC;IAC9C,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;CACvB;AAED,MAAM,WAAW,YAAY;IAC3B,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,EAAE,EAAE,MAAM,CAAC;IACX,UAAU,EAAE,MAAM,EAAE,CAAC;IACrB,WAAW,EAAE,MAAM,EAAE,CAAC;IACtB,kBAAkB,EAAE,KAAK,CAAC,kBAAkB,CAAC,CAAC;IAC9C,cAAc,EAAE,MAAM,EAAE,CAAC;IACzB,eAAe,EAAE,MAAM,EAAE,CAAC;IAC1B,YAAY,EAAE,MAAM,EAAE,CAAC;IACvB,oBAAoB,EAAE,MAAM,EAAE,CAAC;IAC/B,oBAAoB,EAAE,MAAM,EAAE,CAAC;IAC/B,OAAO,EAAE,OAAO,EAAE,CAAC;CACpB;AAED,MAAM,WAAW,SAAS;IACxB,oBAAoB,EAAE,MAAM,CAAC;IAC7B,mBAAmB,EAAE,MAAM,CAAC;IAC5B,IAAI,EAAE,QAAQ,CAAC;CAChB"} \ No newline at end of file +{"version":3,"file":"IDID.d.ts","sourceRoot":"","sources":["../../../src/did/IDID.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EACL,WAAW,IAAI,SAAS,EACxB,mBAAmB,IAAI,QAAQ,EAC/B,kBAAkB,EAClB,OAAO,EACP,WAAW,EACZ,MAAM,8BAA8B,CAAC;AACtC,OAAO,EAAE,aAAa,IAAI,QAAQ,EAAE,MAAM,gCAAgC,CAAC;AAC3E,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EACL,UAAU,EACV,+BAA+B,EAC/B,uBAAuB,EACxB,MAAM,uCAAuC,CAAC;AAE/C,MAAM,WAAW,UAAU;IACzB,UAAU,EAAE,MAAM,CAAC;IACnB,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,eAAe,EAAE,MAAM,CAAC;CACzB;AAED,oBAAY,WAAW;IACrB,kBAAkB,qBAAqB;IACvC,eAAe,kBAAkB;CAClC;AACD,oBAAY,gBAAgB;IAC1B,iBAAiB,oBAAoB;IACrC,gBAAgB,mBAAmB;CACpC;AACD,MAAM,WAAW,kBAAkB;IACjC,IAAI,EAAE,WAAW,CAAC;IAClB,mBAAmB,CAAC,EAAE,MAAM,CAAC;CAC9B;AACD,MAAM,WAAW,SAAS;IACxB,sBAAsB,EAAE,MAAM,CAAC;IAC/B,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,CAAC,EAAE,kBAAkB,GAAG,SAAS,CAAC;IAC5C,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,UAAU,CAAC;CACnB;AAED,MAAM,WAAW,WAAW;IAC1B,UAAU,EAAE,MAAM,CAAC;IACnB,EAAE,EAAE,MAAM,CAAC;IACX,cAAc,CAAC,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;IAC/B,eAAe,CAAC,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;CACjC;AAED,MAAM,WAAW,OAAO;IACtB,GAAG,EAAE,MAAM,CAAC;IACZ,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,SAAS,EAAE,UAAU,CAAC;IACtB,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,EAAE,WAAW,CAAC;IACxB,GAAG,EAAE,MAAM,CAAC;IACZ,oBAAoB,EAAE,MAAM,CAAC;CAC9B;AAED,MAAM,WAAW,IAAK,SAAQ,SAAS;IACrC,UAAU,EAAE,KAAK,CAAC,GAAG,CAAC,CAAC;CACxB;AAED,UAAU,MAAM;IACd,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,kBAAkB,EAAE,MAAM,CAAC;IAC3B,YAAY,EAAE,MAAM,CAAC;IACrB,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,kBAAmB,SAAQ,SAAS;IACnD,KAAK,EAAE,MAAM,CAAC;CACf;AAED,MAAM,WAAW,IAAI;IACnB,YAAY,CAAC,MAAM,EAAE;QACnB,IAAI,CAAC,EAAE,MAAM,CAAC;QACd,UAAU,CAAC,EAAE,MAAM,CAAC;KACrB,GAAG,OAAO,CAAC;QAAE,mBAAmB,EAAE,MAAM,CAAC;QAAC,kBAAkB,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IAEzE,QAAQ,CAAC,MAAM,EAAE;QACf,gBAAgB,CAAC,EAAE,MAAM,CAAC;QAC1B,kBAAkB,EAAE,MAAM,CAAC;QAC3B,yBAAyB,EAAE,+BAA+B,EAAE,CAAC;KAC9D,GAAG,OAAO,CAAC,WAAW,CAAC,CAAC;IAEzB,QAAQ,CAAC,MAAM,EAAE;QACf,WAAW,EAAE,WAAW,CAAC;QACzB,mBAAmB,CAAC,EAAE,MAAM,CAAC;QAC7B,oBAAoB,CAAC,EAAE,MAAM,CAAC;QAC9B,QAAQ,CAAC,EAAE,SAAS,EAAE,CAAC;KACxB,GAAG,OAAO,CAAC;QAAE,WAAW,EAAE,WAAW,CAAC;QAAC,eAAe,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IAEnE,OAAO,CAAC,MAAM,EAAE;QAAE,GAAG,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC,WAAW,CAAC,CAAC;IAEvD,MAAM,CAAC,MAAM,EAAE;QACb,WAAW,EAAE,WAAW,CAAC;QACzB,mBAAmB,EAAE,MAAM,CAAC;QAC5B,oBAAoB,EAAE,MAAM,CAAC;QAC7B,SAAS,EAAE,MAAM,CAAC;KACnB,GAAG,OAAO,CAAC;QAAE,eAAe,EAAE,MAAM,CAAA;KAAE,GAAG;QAAE,WAAW,MAAC;QAAC,SAAS,MAAC;QAAC,SAAS,MAAA;KAAE,CAAC,CAAC;IAEjF,UAAU,CAAC,MAAM,EAAE;QACjB,WAAW,EAAE,MAAM,CAAC;QACpB,mBAAmB,EAAE,MAAM,CAAC;QAC5B,oBAAoB,EAAE,MAAM,CAAC;QAC7B,SAAS,EAAE,MAAM,CAAC;KACnB,GAAG,OAAO,CAAC;QAAE,eAAe,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IAGzC,IAAI,CAAC,MAAM,EAAE;QACX,WAAW,EAAE,WAAW,CAAC;QACzB,mBAAmB,EAAE,MAAM,CAAC;QAC5B,SAAS,EAAE,MAAM,CAAC;QAClB,MAAM,EAAE,MAAM,CAAC;QACf,GAAG,EAAE,MAAM,CAAC;QACZ,oBAAoB,EAAE,MAAM,CAAC;KAC9B,GAAG,OAAO,CAAC,kBAAkB,CAAC,CAAC;IAEhC,MAAM,CAAC,MAAM,EAAE;QACb,WAAW,EAAE,WAAW,CAAC;QACzB,oBAAoB,EAAE,MAAM,CAAC;QAC7B,SAAS,EAAE,MAAM,CAAC;QAClB,MAAM,CAAC,EAAE,MAAM,CAAC;KACjB,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;IAEpB,qBAAqB,CAAC,MAAM,EAAE;QAC5B,GAAG,CAAC,EAAE,MAAM,CAAC;QACb,WAAW,CAAC,EAAE,WAAW,CAAC;QAC1B,IAAI,EAAE,uBAAuB,CAAC;QAC9B,EAAE,CAAC,EAAE,MAAM,CAAC;QACZ,UAAU,CAAC,EAAE,MAAM,CAAC;QACpB,kBAAkB,CAAC,EAAE,MAAM,CAAC;QAC5B,mBAAmB,CAAC,EAAE,MAAM,CAAC;KAC9B,GAAG,OAAO,CAAC,WAAW,CAAC,CAAC;IAEzB,kBAAkB,CAAC,MAAM,EAAE;QACzB,gBAAgB,EAAE,MAAM,CAAC;QACzB,SAAS,CAAC,EAAE,MAAM,CAAC;QACnB,OAAO,EAAE,MAAM,CAAC;QAChB,OAAO,EAAE,MAAM,CAAC;QAChB,UAAU,EAAE,WAAW,CAAC;QACxB,yBAAyB,CAAC,EAAE,+BAA+B,EAAE,CAAC;KAC/D,GAAG,OAAO,CAAC,WAAW,CAAC,CAAC;IACzB,oBAAoB,CAAC,MAAM,EAAE;QAC3B,WAAW,EAAE,WAAW,CAAC;QACzB,SAAS,EAAE,QAAQ,EAAE,CAAC;KACvB,GAAG,OAAO,CAAC;QAAE,WAAW,EAAE,WAAW,CAAC;QAAC,eAAe,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IAEnE,kBAAkB,CAAC,MAAM,EAAE;QACzB,WAAW,EAAE,WAAW,CAAC;QACzB,SAAS,EAAE,MAAM,CAAC;QAClB,SAAS,EAAE,QAAQ,EAAE,CAAC;KACvB,GAAG,OAAO,CAAC;QAAE,eAAe,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IAEzC,sBAAsB,CAAC,MAAM,EAAE;QAC7B,WAAW,EAAE,WAAW,CAAC;QACzB,SAAS,EAAE,QAAQ,EAAE,CAAC;QACtB,SAAS,EAAE,MAAM,CAAC;KACnB,GAAG,OAAO,CAAC;QAAE,eAAe,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IAEzC,2BAA2B,CAAC,MAAM,EAAE;QAClC,WAAW,EAAE,WAAW,CAAC;QACzB,OAAO,EAAE,MAAM,CAAC;QAChB,oBAAoB,EAAE,MAAM,CAAC;QAC7B,IAAI,EAAE,IAAI,GAAG,GAAG,CAAC;QACjB,UAAU,EAAE,WAAW,CAAC;QACxB,OAAO,CAAC,EAAE,MAAM,CAAC;KAClB,GAAG,OAAO,CAAC;QAAE,WAAW,EAAE,WAAW,CAAC;QAAC,eAAe,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IACnE,gBAAgB,CAAC,MAAM,EAAE;QACvB,WAAW,EAAE,WAAW,CAAC;QACzB,UAAU,EAAE,WAAW,CAAC;QACxB,OAAO,EAAE,MAAM,CAAC;QAChB,IAAI,EAAE,IAAI,GAAG,GAAG,CAAC;QACjB,OAAO,CAAC,EAAE,MAAM,CAAC;QACjB,oBAAoB,MAAC;KACtB,GAAG,OAAO,CAAC,kBAAkB,CAAC,CAAC;IAChC,eAAe,CAAC,MAAM,EAAE;QACtB,WAAW,EAAE,WAAW,CAAC;QACzB,mBAAmB,EAAE,MAAM,CAAC;QAC5B,oBAAoB,EAAE,MAAM,CAAC;KAC9B,GAAG,OAAO,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC,CAAC;CAC/B;AAED,MAAM,WAAW,WAAW;IAC1B,WAAW,EAAE,YAAY,CAAC;IAC1B,mBAAmB,EAAE,QAAQ,CAAC;CAC/B;AAED,MAAM,WAAW,OAAO;IACtB,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,UAAU,CAAC;CAClB;AAED,MAAM,WAAW,iBAAiB;IAChC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,0DAA0D;IAC1D,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,eAAe,EAAE,MAAM,CAAC;IACjC,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,IAAI,CAAC,EAAE,SAAS,OAAO,EAAE,CAAC;IACnC,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;CAC5B;AAED,MAAM,WAAW,OAAO;IACtB,WAAW,CAAC,MAAM,EAAE,SAAS,EAAE,SAAS,EAAE,QAAQ,EAAE,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAAC;IAClF,SAAS,CAAC,MAAM,EAAE,SAAS,GAAG,GAAG,EAAE,SAAS,EAAE,QAAQ,EAAE,EAAE,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAAC;IACzG,aAAa,CAAC,GAAG,EAAE,MAAM,EAAE,SAAS,EAAE,QAAQ,EAAE,EAAE,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAAC;IACjG,UAAU,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,CAAC,CAAC;IAC9C,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;CACvB;AAED,MAAM,WAAW,YAAY;IAC3B,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,EAAE,EAAE,MAAM,CAAC;IACX,UAAU,EAAE,MAAM,EAAE,CAAC;IACrB,WAAW,EAAE,MAAM,EAAE,CAAC;IACtB,kBAAkB,EAAE,KAAK,CAAC,kBAAkB,CAAC,CAAC;IAC9C,cAAc,EAAE,MAAM,EAAE,CAAC;IACzB,eAAe,EAAE,MAAM,EAAE,CAAC;IAC1B,YAAY,EAAE,MAAM,EAAE,CAAC;IACvB,oBAAoB,EAAE,MAAM,EAAE,CAAC;IAC/B,oBAAoB,EAAE,MAAM,EAAE,CAAC;IAC/B,OAAO,EAAE,OAAO,EAAE,CAAC;CACpB;AAED,MAAM,WAAW,SAAS;IACxB,oBAAoB,EAAE,MAAM,CAAC;IAC7B,mBAAmB,EAAE,MAAM,CAAC;IAC5B,IAAI,EAAE,uBAAuB,CAAC;CAC/B"} \ No newline at end of file diff --git a/build/src/did/IDID.js b/build/src/did/IDID.js index d0fea09..efa6a61 100644 --- a/build/src/did/IDID.js +++ b/build/src/did/IDID.js @@ -5,25 +5,14 @@ * Author: Hypermine Core Team */ Object.defineProperty(exports, "__esModule", { value: true }); -exports.IClientSpec = exports.IKeyType = exports.IVerificationRelationships = void 0; -var IVerificationRelationships; -(function (IVerificationRelationships) { - IVerificationRelationships["authentication"] = "authentication"; - IVerificationRelationships["assertionMethod"] = "assertionMethod"; - IVerificationRelationships["keyAgreement"] = "keyAgreement"; - IVerificationRelationships["capabilityInvocation"] = "capabilityInvocation"; - IVerificationRelationships["capabilityDelegation"] = "capabilityDelegation"; -})(IVerificationRelationships = exports.IVerificationRelationships || (exports.IVerificationRelationships = {})); -var IKeyType; -(function (IKeyType) { - IKeyType["Ed25519VerificationKey2020"] = "Ed25519VerificationKey2020"; - IKeyType["EcdsaSecp256k1VerificationKey2019"] = "EcdsaSecp256k1VerificationKey2019"; - IKeyType["EcdsaSecp256k1RecoveryMethod2020"] = "EcdsaSecp256k1RecoveryMethod2020"; - IKeyType["X25519KeyAgreementKey2020"] = "X25519KeyAgreementKey2020"; - IKeyType["X25519KeyAgreementKeyEIP5630"] = "X25519KeyAgreementKeyEIP5630"; -})(IKeyType = exports.IKeyType || (exports.IKeyType = {})); +exports.SupportedPurpose = exports.IClientSpec = void 0; var IClientSpec; (function (IClientSpec) { IClientSpec["eth-personalSign"] = "eth-personalSign"; IClientSpec["cosmos-ADR036"] = "cosmos-ADR036"; })(IClientSpec = exports.IClientSpec || (exports.IClientSpec = {})); +var SupportedPurpose; +(function (SupportedPurpose) { + SupportedPurpose["assertionMethod"] = "assertionMethod"; + SupportedPurpose["authentication"] = "authentication"; +})(SupportedPurpose = exports.SupportedPurpose || (exports.SupportedPurpose = {})); diff --git a/build/src/did/bjjdid.d.ts b/build/src/did/bjjdid.d.ts new file mode 100644 index 0000000..f1914d1 --- /dev/null +++ b/build/src/did/bjjdid.d.ts @@ -0,0 +1,230 @@ +import { DidDocument as Did } from '../../libs/generated/ssi/did'; +import { DocumentProof, DocumentProof as SignInfo } from '../../libs/generated/ssi/proof'; +import { IDID, IDIDResolve, ISignedDIDDocument, IClientSpec, ISignData, ISignInfo } from './IDID'; +import { VerificationMethodRelationships, VerificationMethodTypes } from '../../libs/generated/ssi/client/enums'; +import { OfflineSigner } from '@cosmjs/proto-signing'; +/** Class representing HypersignDID */ +export default class HypersignBJJDID implements IDID { + private didrpc; + private didAPIService; + namespace: string; + /** + * Creates instance of HypersignDID class + * @constructor + * @params + * - params.namespace : namespace of did id, Default 'did:hid' + * - params.offlineSigner : signer of type OfflineSigner + * - params.nodeRpcEndpoint : RPC endpoint of the Hypersign blockchain, Default 'TEST' + * - params.nodeRestEndpoint : REST endpoint of the Hypersign blockchain + */ + constructor(params?: { + namespace?: string; + offlineSigner?: OfflineSigner; + nodeRpcEndpoint?: string; + nodeRestEndpoint?: string; + entityApiSecretKey?: string; + }); + sign(params: { + didDocument: Did; + privateKeyMultibase: string; + challenge: string; + domain: string; + did: string; + verificationMethodId: string; + }): Promise; + verify(params: { + didDocument: Did; + verificationMethodId: string; + challenge: string; + domain?: string | undefined; + }): Promise; + addVerificationMethod(params: { + did?: string | undefined; + didDocument?: Did | undefined; + type: VerificationMethodTypes; + id?: string | undefined; + controller?: string | undefined; + publicKeyMultibase?: string | undefined; + blockchainAccountId?: string | undefined; + }): Promise; + createByClientSpec(params: { + methodSpecificId: string; + publicKey?: string | undefined; + address: string; + chainId: string; + clientSpec: IClientSpec; + verificationRelationships?: VerificationMethodRelationships[] | undefined; + }): Promise; + registerByClientSpec(params: { + didDocument: Did; + signInfos: DocumentProof[]; + }): Promise<{ + didDocument: Did; + transactionHash: string; + }>; + updateByClientSpec(params: { + didDocument: Did; + versionId: string; + signInfos: DocumentProof[]; + }): Promise<{ + transactionHash: string; + }>; + deactivateByClientSpec(params: { + didDocument: Did; + signInfos: DocumentProof[]; + versionId: string; + }): Promise<{ + transactionHash: string; + }>; + signAndRegisterByClientSpec(params: { + didDocument: Did; + address: string; + verificationMethodId: string; + web3: any; + clientSpec: IClientSpec; + chainId?: string | undefined; + }): Promise<{ + didDocument: Did; + transactionHash: string; + }>; + signByClientSpec(params: { + didDocument: Did; + clientSpec: IClientSpec; + address: string; + web3: any; + chainId?: string | undefined; + verificationMethodId: any; + }): Promise; + private _getDateTime; + private _jsonLdSign; + private _getId; + private _filterVerificationRelationships; + /** + * Creates a new DID Document from wallet address + * @params + * - params.blockChainAccountId : + * - params.methodSpecificId : methodSpecificId (min 32 bit alhanumeric) else it will generate new random methodSpecificId or may be walletaddress + * @returns {Promise} DidDocument object + */ + private _getBlockChainAccountID; + init(): Promise; + /** + * Generate a new key pair of type Ed25519VerificationKey2020 + * @params params.seed - Optional, Seed to generate the key pair, if not passed, random seed will be taken + * @params params.controller - Optional, controller field + * @returns {Promise} The key pair of type Ed25519 + */ + generateKeys(params: { + mnemonic?: string; + controller?: string; + }): Promise<{ + privateKeyMultibase: string; + publicKeyMultibase: string; + }>; + /** + * Generates a new DID Document + * @params + * - params.publicKeyMultibase : public key + * - params.methodSpecificId : Optional methodSpecificId (min 32 bit alhanumeric) else it will generate new random methodSpecificId + * - params.verificationRelationships: Optional, verification relationships where you want to add your verificaiton method ids + * @returns {Promise} DidDocument object + */ + generate(params: { + methodSpecificId?: string; + publicKeyMultibase: string; + verificationRelationships?: VerificationMethodRelationships[]; + }): Promise; + private prepareDidDocument; + /** + * Register a new DID and Document in Hypersign blockchain - an onchain activity + * @params + * - params.didDocument : LD did document + * - params.privateKeyMultibase : Private Key to sign the doc + * - params.verificationMethodId : VerificationMethodId of the document + * @returns {Promise} Result of the registration + */ + register(params: { + didDocument: Did; + privateKeyMultibase?: string; + verificationMethodId: string; + signData?: ISignData[]; + }): Promise<{ + didDocument: Did; + transactionHash: string; + }>; + /** + * Generate signature + * @params + * - params.didDocument : LD did document + * - params.privateKeyMultibase : Private Key to sign the doc + * - params.verificationMethodId : VerificationMethodId of the document + * @returns {Promise} Generate Array + */ + createSignInfos(params: { + didDocument: Did; + privateKeyMultibase: string; + verificationMethodId: string; + }): Promise>; + /** + * Resolves a DID into DIDDocument from Hypersign blockchain - an onchain activity + * @params + * - params.did : DID + * @returns {Promise} didDocument and didDocumentMetadata + */ + resolve(params: { + did: string; + }): Promise; + /** + * Update a DIDDocument in Hypersign blockchain - an onchain activity + * @params + * - params.didDocument : LD did document + * - params.privateKeyMultibase : Private Key to sign the doc + * - params.verificationMethodId : VerificationMethodId of the document + * - params.versionId : Version of the document + * @returns {Promise<{ transactionHash: string }>} Result of the update operation + */ + update(params: { + didDocument: Did; + privateKeyMultibase: string; + verificationMethodId: string; + versionId: string; + readonly?: boolean; + otherSignInfo?: Array; + }): Promise<{ + transactionHash: string; + } | { + didDocument: any; + signInfos: any; + versionId: any; + }>; + /** + * Deactivate a DIDDocument in Hypersign blockchain - an onchain activity + * @params + * - params.didDocument : LD did document + * - params.privateKeyMultibase : Private Key to sign the doc + * - params.verificationMethodId : VerificationMethodId of the document + * - params.versionId : Version of the document + * @returns {Promise} Result of the deactivatee operation + */ + deactivate(params: { + didDocument: Did; + privateKeyMultibase: string; + verificationMethodId: string; + versionId: string; + }): Promise<{ + transactionHash: string; + }>; + /** + * Signs a DIDDocument + * @params + * - params.didDocument : Did document to be signed + * - params.privateKeyMultibase : private key in multibase format (base58 digitalbazar format) + * - params.challenge : challenge is a random string generated by the client + * - params.did : did of the user + * - params.domain : domain is the domain of the DID Document that is being authenticated + * - params.verificationMethodId : verificationMethodId of the DID + * @returns {Promise} Signed DID Document + */ + private _isValidMultibaseBase58String; +} +//# sourceMappingURL=bjjdid.d.ts.map \ No newline at end of file diff --git a/build/src/did/bjjdid.d.ts.map b/build/src/did/bjjdid.d.ts.map new file mode 100644 index 0000000..9288e3a --- /dev/null +++ b/build/src/did/bjjdid.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"bjjdid.d.ts","sourceRoot":"","sources":["../../../src/did/bjjdid.ts"],"names":[],"mappings":"AAYA,OAAO,EAAE,WAAW,IAAI,GAAG,EAA+B,MAAM,8BAA8B,CAAC;AAC/F,OAAO,EAAE,aAAa,EAAE,aAAa,IAAI,QAAQ,EAAE,MAAM,gCAAgC,CAAC;AAK1F,OAAO,EAAE,IAAI,EAAQ,WAAW,EAAW,kBAAkB,EAAE,WAAW,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,QAAQ,CAAC;AACjH,OAAO,EAAE,+BAA+B,EAAE,uBAAuB,EAAE,MAAM,uCAAuC,CAAC;AACjH,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AA+JtD,sCAAsC;AACtC,MAAM,CAAC,OAAO,OAAO,eAAgB,YAAW,IAAI;IAClD,OAAO,CAAC,MAAM,CAAiB;IAC/B,OAAO,CAAC,aAAa,CAAwB;IACtC,SAAS,EAAE,MAAM,CAAC;IAEzB;;;;;;;;OAQG;gBAED,MAAM,GAAE;QACN,SAAS,CAAC,EAAE,MAAM,CAAC;QACnB,aAAa,CAAC,EAAE,aAAa,CAAC;QAC9B,eAAe,CAAC,EAAE,MAAM,CAAC;QACzB,gBAAgB,CAAC,EAAE,MAAM,CAAC;QAC1B,kBAAkB,CAAC,EAAE,MAAM,CAAC;KACxB;IAoBR,IAAI,CAAC,MAAM,EAAE;QACX,WAAW,EAAE,GAAG,CAAC;QACjB,mBAAmB,EAAE,MAAM,CAAC;QAC5B,SAAS,EAAE,MAAM,CAAC;QAClB,MAAM,EAAE,MAAM,CAAC;QACf,GAAG,EAAE,MAAM,CAAC;QACZ,oBAAoB,EAAE,MAAM,CAAC;KAC9B,GAAG,OAAO,CAAC,kBAAkB,CAAC;IAG/B,MAAM,CAAC,MAAM,EAAE;QACb,WAAW,EAAE,GAAG,CAAC;QACjB,oBAAoB,EAAE,MAAM,CAAC;QAC7B,SAAS,EAAE,MAAM,CAAC;QAClB,MAAM,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;KAC7B,GAAG,OAAO,CAAC,MAAM,CAAC;IAGnB,qBAAqB,CAAC,MAAM,EAAE;QAC5B,GAAG,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;QACzB,WAAW,CAAC,EAAE,GAAG,GAAG,SAAS,CAAC;QAC9B,IAAI,EAAE,uBAAuB,CAAC;QAE9B,EAAE,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;QACxB,UAAU,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;QAChC,kBAAkB,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;QACxC,mBAAmB,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;KAC1C,GAAG,OAAO,CAAC,GAAG,CAAC;IAGhB,kBAAkB,CAAC,MAAM,EAAE;QACzB,gBAAgB,EAAE,MAAM,CAAC;QACzB,SAAS,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;QAC/B,OAAO,EAAE,MAAM,CAAC;QAChB,OAAO,EAAE,MAAM,CAAC;QAChB,UAAU,EAAE,WAAW,CAAC;QACxB,yBAAyB,CAAC,EAAE,+BAA+B,EAAE,GAAG,SAAS,CAAC;KAC3E,GAAG,OAAO,CAAC,GAAG,CAAC;IAGhB,oBAAoB,CAAC,MAAM,EAAE;QAC3B,WAAW,EAAE,GAAG,CAAC;QACjB,SAAS,EAAE,aAAa,EAAE,CAAC;KAC5B,GAAG,OAAO,CAAC;QAAE,WAAW,EAAE,GAAG,CAAC;QAAC,eAAe,EAAE,MAAM,CAAA;KAAE,CAAC;IAG1D,kBAAkB,CAAC,MAAM,EAAE;QACzB,WAAW,EAAE,GAAG,CAAC;QACjB,SAAS,EAAE,MAAM,CAAC;QAClB,SAAS,EAAE,aAAa,EAAE,CAAC;KAC5B,GAAG,OAAO,CAAC;QAAE,eAAe,EAAE,MAAM,CAAA;KAAE,CAAC;IAGxC,sBAAsB,CAAC,MAAM,EAAE;QAC7B,WAAW,EAAE,GAAG,CAAC;QACjB,SAAS,EAAE,aAAa,EAAE,CAAC;QAC3B,SAAS,EAAE,MAAM,CAAC;KACnB,GAAG,OAAO,CAAC;QAAE,eAAe,EAAE,MAAM,CAAA;KAAE,CAAC;IAGxC,2BAA2B,CAAC,MAAM,EAAE;QAClC,WAAW,EAAE,GAAG,CAAC;QACjB,OAAO,EAAE,MAAM,CAAC;QAChB,oBAAoB,EAAE,MAAM,CAAC;QAC7B,IAAI,EAAE,GAAG,CAAC;QACV,UAAU,EAAE,WAAW,CAAC;QACxB,OAAO,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;KAC9B,GAAG,OAAO,CAAC;QAAE,WAAW,EAAE,GAAG,CAAC;QAAC,eAAe,EAAE,MAAM,CAAA;KAAE,CAAC;IAG1D,gBAAgB,CAAC,MAAM,EAAE;QACvB,WAAW,EAAE,GAAG,CAAC;QACjB,UAAU,EAAE,WAAW,CAAC;QACxB,OAAO,EAAE,MAAM,CAAC;QAChB,IAAI,EAAE,GAAG,CAAC;QACV,OAAO,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;QAC7B,oBAAoB,EAAE,GAAG,CAAC;KAC3B,GAAG,OAAO,CAAC,kBAAkB,CAAC;IAI/B,OAAO,CAAC,YAAY;YAIN,WAAW;IA0BzB,OAAO,CAAC,MAAM,CAUZ;IAEF,OAAO,CAAC,gCAAgC;IAgBxC;;;;;;OAMG;IACH,OAAO,CAAC,uBAAuB;IAWlB,IAAI;IAcjB;;;;;OAKG;IACU,YAAY,CAAC,MAAM,EAAE;QAChC,QAAQ,CAAC,EAAE,MAAM,CAAC;QAClB,UAAU,CAAC,EAAE,MAAM,CAAC;KACrB,GAAG,OAAO,CAAC;QAAE,mBAAmB,EAAE,MAAM,CAAC;QAAC,kBAAkB,EAAE,MAAM,CAAA;KAAE,CAAC;IAkBxE;;;;;;;OAOG;IACU,QAAQ,CAAC,MAAM,EAAE;QAC5B,gBAAgB,CAAC,EAAE,MAAM,CAAC;QAC1B,kBAAkB,EAAE,MAAM,CAAC;QAC3B,yBAAyB,CAAC,EAAE,+BAA+B,EAAE,CAAC;KAC/D,GAAG,OAAO,CAAC,GAAG,CAAC;IAgChB,OAAO,CAAC,kBAAkB;IA8E1B;;;;;;;OAOG;IACU,QAAQ,CAAC,MAAM,EAAE;QAC5B,WAAW,EAAE,GAAG,CAAC;QACjB,mBAAmB,CAAC,EAAE,MAAM,CAAC;QAC7B,oBAAoB,EAAE,MAAM,CAAC;QAC7B,QAAQ,CAAC,EAAE,SAAS,EAAE,CAAC;KACxB,GAAG,OAAO,CAAC;QAAE,WAAW,EAAE,GAAG,CAAC;QAAC,eAAe,EAAE,MAAM,CAAA;KAAE,CAAC;IAqH1D;;;;;;;OAOG;IACU,eAAe,CAAC,MAAM,EAAE;QACnC,WAAW,EAAE,GAAG,CAAC;QACjB,mBAAmB,EAAE,MAAM,CAAC;QAC5B,oBAAoB,EAAE,MAAM,CAAC;KAC9B,GAAG,OAAO,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC;IAyC7B;;;;;OAKG;IACU,OAAO,CAAC,MAAM,EAAE;QAAE,GAAG,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC,WAAW,CAAC;IAgBnE;;;;;;;;OAQG;IACU,MAAM,CAAC,MAAM,EAAE;QAC1B,WAAW,EAAE,GAAG,CAAC;QACjB,mBAAmB,EAAE,MAAM,CAAC;QAC5B,oBAAoB,EAAE,MAAM,CAAC;QAC7B,SAAS,EAAE,MAAM,CAAC;QAClB,QAAQ,CAAC,EAAE,OAAO,CAAC;QACnB,aAAa,CAAC,EAAE,KAAK,CAAC,QAAQ,CAAC,CAAC;KACjC,GAAG,OAAO,CAAC;QAAE,eAAe,EAAE,MAAM,CAAA;KAAE,GAAG;QAAE,WAAW,MAAC;QAAC,SAAS,MAAC;QAAC,SAAS,MAAA;KAAE,CAAC;IA8DhF;;;;;;;;OAQG;IACU,UAAU,CAAC,MAAM,EAAE;QAC9B,WAAW,EAAE,GAAG,CAAC;QACjB,mBAAmB,EAAE,MAAM,CAAC;QAC5B,oBAAoB,EAAE,MAAM,CAAC;QAC7B,SAAS,EAAE,MAAM,CAAC;KACnB,GAAG,OAAO,CAAC;QAAE,eAAe,EAAE,MAAM,CAAA;KAAE,CAAC;IAqDxC;;;;;;;;;;OAUG;IAEH,OAAO,CAAC,6BAA6B,CAGnC;CAaH"} \ No newline at end of file diff --git a/build/src/did/bjjdid.js b/build/src/did/bjjdid.js new file mode 100644 index 0000000..f8e16c4 --- /dev/null +++ b/build/src/did/bjjdid.js @@ -0,0 +1,798 @@ +"use strict"; +var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + var desc = Object.getOwnPropertyDescriptor(m, k); + if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { + desc = { enumerable: true, get: function() { return m[k]; } }; + } + Object.defineProperty(o, k2, desc); +}) : (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + o[k2] = m[k]; +})); +var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { + Object.defineProperty(o, "default", { enumerable: true, value: v }); +}) : function(o, v) { + o["default"] = v; +}); +var __importStar = (this && this.__importStar) || function (mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); + __setModuleDefault(result, mod); + return result; +}; +var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { + function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } + return new (P || (P = Promise))(function (resolve, reject) { + function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } + function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } + function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } + step((generator = generator.apply(thisArg, _arguments || [])).next()); + }); +}; +var __importDefault = (this && this.__importDefault) || function (mod) { + return (mod && mod.__esModule) ? mod : { "default": mod }; +}; +Object.defineProperty(exports, "__esModule", { value: true }); +/** + * Copyright (c) 2023, Hypermine Pvt. Ltd. + * All rights reserved. + * Author: Hypermine Core Team + */ +const constant = __importStar(require("../constants")); +const jsonld_signatures_1 = __importDefault(require("jsonld-signatures")); +const { AssertionProofPurpose } = jsonld_signatures_1.default.purposes; +const didRPC_1 = require("./didRPC"); +const utils_1 = __importDefault(require("../utils")); +const babyjubjub2021_1 = require("babyjubjub2021"); +const babyjubjubsignature2021_1 = require("babyjubjubsignature2021"); +const web3_1 = __importDefault(require("web3")); +const did_service_1 = __importDefault(require("../ssiApi/services/did/did.service")); +const enums_1 = require("../../libs/generated/ssi/client/enums"); +const v1_1 = __importDefault(require("../../libs/w3cache/v1")); +const documentLoader = jsonld_signatures_1.default.extendContextLoader(v1_1.default); +class DIDDocument { + constructor(publicKey, blockchainAccountId, id, keyType, verificationRelationships) { + let vm; + switch (keyType) { + case enums_1.VerificationMethodTypes.Ed25519VerificationKey2020: { + this['@context'] = [ + constant['DID_' + keyType].DID_BASE_CONTEXT, + constant['DID_' + keyType].DID_BABYJUBJUBKEY2021, + ]; + this.id = id; + this.controller = [this.id]; + this.alsoKnownAs = [this.id]; + vm = { + id: this.id + '#key-1', + type: constant['DID_' + keyType].VERIFICATION_METHOD_TYPE, + controller: this.id, + publicKeyMultibase: publicKey, + }; + const verificationMethod = vm; + this.verificationMethod = [verificationMethod]; + this.authentication = []; + this.assertionMethod = []; + this.keyAgreement = []; + this.capabilityInvocation = []; + this.capabilityDelegation = []; + verificationRelationships === null || verificationRelationships === void 0 ? void 0 : verificationRelationships.forEach((value) => { + const vmId = verificationMethod.id; + this[value] = [vmId]; + }); + // TODO: we should take services object in consntructor + this.service = []; + break; + } + case enums_1.VerificationMethodTypes.EcdsaSecp256k1RecoveryMethod2020: { + this['@context'] = [ + constant['DID_' + keyType].DID_BASE_CONTEXT, + constant['DID_' + keyType].SECP256K12020_RECOVERY_CONTEXT, + ]; + this.id = id; + this.controller = [this.id]; + this.alsoKnownAs = [this.id]; + vm = { + id: this.id + '#key-1', + type: constant['DID_' + keyType].VERIFICATION_METHOD_TYPE, + controller: this.id, + blockchainAccountId: blockchainAccountId, + }; + const verificationMethod = vm; + this.verificationMethod = [verificationMethod]; + this.authentication = []; + this.assertionMethod = []; + this.keyAgreement = []; + this.capabilityInvocation = []; + this.capabilityDelegation = []; + verificationRelationships === null || verificationRelationships === void 0 ? void 0 : verificationRelationships.forEach((value) => { + const vmId = verificationMethod.id; + this[value] = [vmId]; + }); + // TODO: we should take services object in consntructor + this.service = []; + break; + } + case enums_1.VerificationMethodTypes.EcdsaSecp256k1VerificationKey2019: { + this['@context'] = [ + constant['DID_' + keyType].DID_BASE_CONTEXT, + constant['DID_' + keyType].SECP256K12020_VERIFICATION_CONTEXT, + ]; + this.id = id; + this.controller = [this.id]; + this.alsoKnownAs = [this.id]; + vm = { + id: this.id + '#key-1', + type: constant['DID_' + keyType].VERIFICATION_METHOD_TYPE, + controller: this.id, + publicKeyMultibase: publicKey, + blockchainAccountId: blockchainAccountId, + }; + const verificationMethod = vm; + this.verificationMethod = [verificationMethod]; + this.authentication = []; + this.assertionMethod = []; + this.keyAgreement = []; + this.capabilityInvocation = []; + this.capabilityDelegation = []; + verificationRelationships === null || verificationRelationships === void 0 ? void 0 : verificationRelationships.forEach((value) => { + const vmId = verificationMethod.id; + this[value] = [vmId]; + }); + // TODO: we should take services object in consntructor + this.service = []; + break; + } + case enums_1.VerificationMethodTypes.BabyJubJubKey2021: { + this['@context'] = [ + constant['DID_' + keyType].DID_BASE_CONTEXT, + constant['DID_' + keyType].DID_BABYJUBJUBKEY2021, + constant['DID_' + keyType].BABYJUBJUBSIGNATURE, + ]; + this.id = id; + this.controller = [this.id]; + vm = { + id: this.id + '#key-1', + type: constant['DID_' + keyType].VERIFICATION_METHOD_TYPE, + controller: this.id, + publicKeyMultibase: publicKey, + }; + const verificationMethod = vm; + this.verificationMethod = [verificationMethod]; + // eslint-disable-next-line @typescript-eslint/no-this-alias + this.authentication = [vm.id]; + this.assertionMethod = [vm.id]; + this.keyAgreement = []; + this.capabilityInvocation = []; + this.capabilityDelegation = []; + verificationRelationships === null || verificationRelationships === void 0 ? void 0 : verificationRelationships.forEach((value) => { + const vmId = verificationMethod.id; + this[value] = [vmId]; + }); + // TODO: we should take services object in consntructor + this.service = []; + break; + } + default: + throw new Error('Invalid'); + } + } +} +/** Class representing HypersignDID */ +class HypersignBJJDID { + /** + * Creates instance of HypersignDID class + * @constructor + * @params + * - params.namespace : namespace of did id, Default 'did:hid' + * - params.offlineSigner : signer of type OfflineSigner + * - params.nodeRpcEndpoint : RPC endpoint of the Hypersign blockchain, Default 'TEST' + * - params.nodeRestEndpoint : REST endpoint of the Hypersign blockchain + */ + constructor(params = {}) { + this._getId = (methodSpecificId) => { + if (methodSpecificId && methodSpecificId.length < 32) { + throw new Error('HID-SSI-SDK:: Error: methodSpecificId should be of minimum size 32'); + } + let did = ''; + did = + this.namespace && this.namespace != '' + ? `${constant.DID.SCHEME}:${constant.DID.METHOD}:${this.namespace}:${methodSpecificId}` + : `${constant.DID.SCHEME}:${constant.DID.METHOD}:${methodSpecificId}`; + return did; + }; + /** + * Signs a DIDDocument + * @params + * - params.didDocument : Did document to be signed + * - params.privateKeyMultibase : private key in multibase format (base58 digitalbazar format) + * - params.challenge : challenge is a random string generated by the client + * - params.did : did of the user + * - params.domain : domain is the domain of the DID Document that is being authenticated + * - params.verificationMethodId : verificationMethodId of the DID + * @returns {Promise} Signed DID Document + */ + this._isValidMultibaseBase58String = (str) => { + const multibaseBase58Regex = /^z([1-9A-HJ-NP-Za-km-z]+)$/; + return multibaseBase58Regex.test(str); + }; + const { offlineSigner, namespace, nodeRpcEndpoint, nodeRestEndpoint, entityApiSecretKey } = params; + const nodeRPCEp = nodeRpcEndpoint ? nodeRpcEndpoint : 'MAIN'; + const nodeRestEp = nodeRestEndpoint ? nodeRestEndpoint : ''; + const rpcConstructorParams = { + offlineSigner, + nodeRpcEndpoint: nodeRPCEp, + nodeRestEndpoint: nodeRestEp, + }; + this.didrpc = new didRPC_1.DIDRpc(rpcConstructorParams); + if (entityApiSecretKey && entityApiSecretKey != '') { + this.didAPIService = new did_service_1.default(entityApiSecretKey); + this.didrpc = null; + } + else { + this.didAPIService = null; + } + this.namespace = namespace ? namespace : ''; + } + sign(params) { + throw new Error('Method not implemented.'); + } + verify(params) { + throw new Error('Method not implemented.'); + } + addVerificationMethod(params) { + throw new Error('Method not implemented.'); + } + createByClientSpec(params) { + throw new Error('Method not implemented.'); + } + registerByClientSpec(params) { + throw new Error('Method not implemented.'); + } + updateByClientSpec(params) { + throw new Error('Method not implemented.'); + } + deactivateByClientSpec(params) { + throw new Error('Method not implemented.'); + } + signAndRegisterByClientSpec(params) { + throw new Error('Method not implemented.'); + } + signByClientSpec(params) { + throw new Error('Method not implemented.'); + } + _getDateTime() { + return new Date(new Date().getTime() - 100000).toISOString().slice(0, -5) + 'Z'; + } + _jsonLdSign(params) { + var _a; + return __awaiter(this, void 0, void 0, function* () { + const { didDocument, privateKeyMultibase, verificationMethodId } = params; + const publicKeyId = verificationMethodId + 'assertionMethod'; + const pubKey = (_a = didDocument.assertionMethod) === null || _a === void 0 ? void 0 : _a.find((item) => item.id === publicKeyId); + const publicKeyMultibase1 = pubKey === null || pubKey === void 0 ? void 0 : pubKey.publicKeyMultibase; + const keyPair = babyjubjub2021_1.BabyJubJubKeys2021.fromKeys({ + options: { + id: publicKeyId, + controller: publicKeyId, + }, + privateKeyMultibase: privateKeyMultibase, + publicKeyMultibase: publicKeyMultibase1, + }); + const suite = new babyjubjubsignature2021_1.BabyJubJubSignature2021Suite({ key: keyPair }); + const signedDidDocument = (yield jsonld_signatures_1.default.sign(didDocument, { + suite, + purpose: new AssertionProofPurpose(), + documentLoader, + })); + return signedDidDocument.proof; + }); + } + _filterVerificationRelationships(verificationRelationships) { + let vR = [ + enums_1.VerificationMethodRelationships.assertionMethod, + enums_1.VerificationMethodRelationships.authentication, + ]; + if (verificationRelationships && verificationRelationships.length > 0) { + const set1 = new Set(vR); + const set2 = new Set(verificationRelationships); + vR = Array.from(set1).filter((value) => set2.has(value)); + } + return vR; + } + /** + * Creates a new DID Document from wallet address + * @params + * - params.blockChainAccountId : + * - params.methodSpecificId : methodSpecificId (min 32 bit alhanumeric) else it will generate new random methodSpecificId or may be walletaddress + * @returns {Promise} DidDocument object + */ + _getBlockChainAccountID(chainId, address) { + try { + const web3 = new web3_1.default(); + const inDecimelChainId = web3.utils.hexToNumber(chainId); + const blockChainAccountId = constant.CAIP_10_PREFIX.eip155 + ':' + inDecimelChainId + ':' + address; + return blockChainAccountId; + } + catch (error) { + throw new Error('HID-SSI-SDK:: Error: unsupported chain Id'); + } + } + init() { + return __awaiter(this, void 0, void 0, function* () { + if (!this.didrpc && !this.didAPIService) { + throw new Error('HID-SSI-SDK:: Error: HypersignDID class is not instantiated with Offlinesigner or have not been initilized with entityApiSecretKey'); + } + if (this.didrpc) { + yield this.didrpc.init(); + } + if (this.didAPIService) { + yield this.didAPIService.auth(); + } + }); + } + /** + * Generate a new key pair of type Ed25519VerificationKey2020 + * @params params.seed - Optional, Seed to generate the key pair, if not passed, random seed will be taken + * @params params.controller - Optional, controller field + * @returns {Promise} The key pair of type Ed25519 + */ + generateKeys(params) { + return __awaiter(this, void 0, void 0, function* () { + let edKeyPair; + if (params && params.mnemonic && params.controller) { + edKeyPair = yield babyjubjub2021_1.BabyJubJubKeys2021.from(params.mnemonic, { + id: params.controller, + }); + } + else if (params && params.controller) { + edKeyPair = yield babyjubjub2021_1.BabyJubJubKeys2021.generate({ id: params.controller }); + } + else if (params && params.mnemonic) { + edKeyPair = yield babyjubjub2021_1.BabyJubJubKeys2021.from(params.mnemonic); + } + else { + edKeyPair = yield babyjubjub2021_1.BabyJubJubKeys2021.generate(); + } + return Object.assign({}, edKeyPair); + }); + } + /** + * Generates a new DID Document + * @params + * - params.publicKeyMultibase : public key + * - params.methodSpecificId : Optional methodSpecificId (min 32 bit alhanumeric) else it will generate new random methodSpecificId + * - params.verificationRelationships: Optional, verification relationships where you want to add your verificaiton method ids + * @returns {Promise} DidDocument object + */ + generate(params) { + return __awaiter(this, void 0, void 0, function* () { + let verificationRelationships = []; + if (params.verificationRelationships && params.verificationRelationships.length > 0) { + if (params.verificationRelationships.includes(enums_1.VerificationMethodRelationships.keyAgreement)) { + throw new Error('HID-SSI-SDK:: Error: keyAgreement is not allowed in verificationRelationships'); + } + verificationRelationships = this._filterVerificationRelationships(params.verificationRelationships); + } + else { + verificationRelationships = this._filterVerificationRelationships([]); + } + if (!params.publicKeyMultibase) { + throw new Error('HID-SSI-SDK:: Error: params.publicKeyMultibase is required to generate new did didoc'); + } + const publicKeyMultibase1 = params.publicKeyMultibase; + const methodSpecificId = publicKeyMultibase1; + let didId; + if (params.methodSpecificId) { + didId = this._getId(params.methodSpecificId); + } + else { + didId = this._getId(methodSpecificId); + } + const newDid = new DIDDocument(publicKeyMultibase1, '', didId, enums_1.VerificationMethodTypes.BabyJubJubKey2021, verificationRelationships); + return utils_1.default.jsonToLdConvertor(Object.assign({}, newDid)); + }); + } + prepareDidDocument(did) { + const did1 = {}; + Object.assign(did1, did); + delete did1.alsoKnownAs; + // TODO FIx + did1.assertionMethod = []; + did1.authentication = []; + did1.capabilityDelegation = []; + did1.capabilityInvocation = []; + did1.keyAgreement = []; + if (did.assertionMethod) { + did.assertionMethod.forEach((x) => { + var _a; + const vm = (_a = did.verificationMethod) === null || _a === void 0 ? void 0 : _a.find((vm) => vm.id === x); + if (vm) { + did1.assertionMethod.push({ + id: vm.id + 'assertionMethod', + type: vm.type, + publicKeyMultibase: vm.publicKeyMultibase, + }); + } + }); + } + if (did.authentication) { + did.authentication.forEach((x) => { + var _a; + const vm = (_a = did.verificationMethod) === null || _a === void 0 ? void 0 : _a.find((vm) => vm.id === x); + if (vm) { + did1.authentication.push({ + id: vm.id + 'authentication', + type: vm.type, + publicKeyMultibase: vm.publicKeyMultibase, + }); + } + }); + } + if (did.capabilityDelegation) { + did.capabilityDelegation.forEach((x) => { + var _a; + const vm = (_a = did.verificationMethod) === null || _a === void 0 ? void 0 : _a.find((vm) => vm.id === x); + if (vm) { + did1.capabilityDelegation.push({ + id: vm.id + 'capabilityDelegation', + type: vm.type, + publicKeyMultibase: vm.publicKeyMultibase, + }); + } + }); + } + if (did.capabilityInvocation) { + did.capabilityInvocation.forEach((x) => { + var _a; + const vm = (_a = did.verificationMethod) === null || _a === void 0 ? void 0 : _a.find((vm) => vm.id === x); + if (vm) { + did1.capabilityInvocation.push({ + id: vm.id + 'capabilityInvocation', + type: vm.type, + publicKeyMultibase: vm.publicKeyMultibase, + }); + } + }); + } + if (did.keyAgreement) { + did.keyAgreement.forEach((x) => { + var _a; + const vm = (_a = did.verificationMethod) === null || _a === void 0 ? void 0 : _a.find((vm) => vm.id === x); + if (vm) { + did1.keyAgreement.push({ + id: vm.id + 'keyAgreement', + type: vm.type, + publicKeyMultibase: vm.publicKeyMultibase, + }); + } + }); + } + delete did1.verificationMethod; + return did1; + } + /** + * Register a new DID and Document in Hypersign blockchain - an onchain activity + * @params + * - params.didDocument : LD did document + * - params.privateKeyMultibase : Private Key to sign the doc + * - params.verificationMethodId : VerificationMethodId of the document + * @returns {Promise} Result of the registration + */ + register(params) { + return __awaiter(this, void 0, void 0, function* () { + //ToDO check if did exists + const response = {}; + // TODO: this method MUST also accept signature/proof + if (!params.didDocument || Object.keys(params.didDocument).length === 0) { + throw new Error('HID-SSI-SDK:: Error: params.didDocString is required to register a did'); + } + if (!this.didrpc && !this.didAPIService) { + throw new Error('HID-SSI-SDK:: Error: HypersignDID class is not instantiated with "Offlinesigner" or have not been initilized with "EntityAPISecreKey"'); + } + let { didDocument } = params; + const didDoc = didDocument; + const signInfos = []; + if (!params.signData) { + if (!params.privateKeyMultibase) { + throw new Error('HID-SSI-SDK:: Error: params.privateKeyMultibase is required to register a did'); + } + if (!params.verificationMethodId) { + throw new Error('HID-SSI-SDK:: Error: params.verificationMethodId is required to register a did'); + } + const { privateKeyMultibase, verificationMethodId } = params; + let signature; + let createdAt; + if (!didDocument['@context']) { + throw new Error('HID-SSI-SDK:: Error: didDocument is not in Ld-json format'); + } + else { + didDocument = utils_1.default.removeEmptyString(didDocument); + const prepareDidDocument = this.prepareDidDocument(didDocument); + const proof = yield this._jsonLdSign({ + didDocument: prepareDidDocument, + privateKeyMultibase, + verificationMethodId, + }); + signature = proof.proofValue; + createdAt = proof.created; + } + signInfos.push({ + type: constant['DID_BabyJubJubKey2021'].SIGNATURE_TYPE, + created: createdAt !== null && createdAt !== void 0 ? createdAt : this._getDateTime(), + verificationMethod: verificationMethodId, + proofPurpose: enums_1.VerificationMethodRelationships.assertionMethod, + proofValue: signature, + }); + } + else { + if (params.signData.length < 1) { + throw new Error('HID-SSI-SDK:: Error: params.signInfos must be a non empty array'); + } + for (const i in params.signData) { + if (!params.signData[i].verificationMethodId) { + throw new Error(`HID-SSI-SDK:: Error: params.signData[${i}].verificationMethodId is required to register a did`); + } + if (!params.signData[i].privateKeyMultibase) { + throw new Error(`HID-SSI-SDK:: Error: params.signData[${i}].privateKeyMultibase is required to register a did`); + } + if (!params.signData[i].type) { + throw new Error(`HID-SSI-SDK:: Error: params.signData[${i}].type is required to register a did`); + } + const { type, privateKeyMultibase, verificationMethodId } = params.signData[i]; + let createdAt; + if (type !== enums_1.VerificationMethodTypes.X25519KeyAgreementKey2020 && + type !== enums_1.VerificationMethodTypes.X25519KeyAgreementKeyEIP5630) { + let signature; + if (!didDocument['@context']) { + throw new Error('HID-SSI-SDK:: Error: didDocument is not in Ld-json format'); + } + else { + didDocument = utils_1.default.removeEmptyString(didDocument); + const prepareDidDocument = this.prepareDidDocument(didDocument); + const proof = yield this._jsonLdSign({ + didDocument: prepareDidDocument, + privateKeyMultibase, + verificationMethodId, + }); + signature = proof.proofValue; + createdAt = proof.created; + } + signInfos.push({ + type: constant['DID_BabyJubJubKey2021'].SIGNATURE_TYPE, + created: createdAt !== null && createdAt !== void 0 ? createdAt : this._getDateTime(), + verificationMethod: verificationMethodId, + proofPurpose: enums_1.VerificationMethodRelationships.assertionMethod, + proofValue: signature, + }); + delete didDocument['proof']; + } + } + } + if (this.didrpc) { + const result = yield this.didrpc.registerDID(didDoc, signInfos); + if (result.code !== 0) { + throw new Error(result.rawLog); + } + response.didDocument = params.didDocument; + response.transactionHash = result.transactionHash; + } + else if (this.didAPIService) { + const newSignInfos = signInfos; + const result = yield this.didAPIService.registerDid({ + didDocument, + signInfos: newSignInfos, + }); + response.didDocument = didDocument; + response.transactionHash = result.transactionHash; + } + return response; + }); + } + /** + * Generate signature + * @params + * - params.didDocument : LD did document + * - params.privateKeyMultibase : Private Key to sign the doc + * - params.verificationMethodId : VerificationMethodId of the document + * @returns {Promise} Generate Array + */ + createSignInfos(params) { + return __awaiter(this, void 0, void 0, function* () { + if (!params.didDocument || Object.keys(params.didDocument).length === 0) { + throw new Error('HID-SSI-SDK:: Error: params.didDocument is required to create signature of a did'); + } + if (!params.privateKeyMultibase) { + throw new Error('HID-SSI-SDK:: Error: params.privateKeyMultibase is required to create signature of a did'); + } + if (!params.verificationMethodId) { + throw new Error('HID-SSI-SDK:: Error: params.verificationMethodId is required to create signature of a did'); + } + let { didDocument } = params; + const signInfos = []; + const { privateKeyMultibase, verificationMethodId } = params; + let signature; + let createdAt; + let type; + if (!didDocument['@context']) { + throw new Error('HID-SSI-SDK:: Error: didDocument is not in Ld-json format'); + } + else { + didDocument = this.prepareDidDocument(didDocument); + didDocument = utils_1.default.removeEmptyString(didDocument); + const proof = yield this._jsonLdSign({ + didDocument, + privateKeyMultibase, + verificationMethodId, + }); + signature = proof.proofValue; + createdAt = proof.created; + type = proof.type; + } + signInfos.push({ + type, + signature, + verification_method_id: verificationMethodId, + created: createdAt, + clientSpec: undefined, + }); + return signInfos; + }); + } + /** + * Resolves a DID into DIDDocument from Hypersign blockchain - an onchain activity + * @params + * - params.did : DID + * @returns {Promise} didDocument and didDocumentMetadata + */ + resolve(params) { + return __awaiter(this, void 0, void 0, function* () { + let result = {}; + if (!params.did) { + throw new Error('HID-SSI-SDK:: Error: params.did is required to resolve a did'); + } + if (this.didrpc) { + result = yield this.didrpc.resolveDID(params.did); + } + else if (this.didAPIService) { + result = yield this.didAPIService.resolveDid({ did: params.did }); + } + return { + didDocument: utils_1.default.jsonToLdConvertor(result.didDocument), + didDocumentMetadata: result.didDocumentMetadata, + }; + }); + } + /** + * Update a DIDDocument in Hypersign blockchain - an onchain activity + * @params + * - params.didDocument : LD did document + * - params.privateKeyMultibase : Private Key to sign the doc + * - params.verificationMethodId : VerificationMethodId of the document + * - params.versionId : Version of the document + * @returns {Promise<{ transactionHash: string }>} Result of the update operation + */ + update(params) { + var _a; + return __awaiter(this, void 0, void 0, function* () { + const response = {}; + if (!params.didDocument) { + throw new Error('HID-SSI-SDK:: Error: params.didDocument is required to update a did'); + } + if (!params.privateKeyMultibase) { + throw new Error('HID-SSI-SDK:: Error: params.privateKeyMultibase is required to update a did'); + } + if (!params.verificationMethodId) { + throw new Error('HID-SSI-SDK:: Error: params.verificationMethodId is required to update a did'); + } + if (!params.versionId) { + throw new Error('HID-SSI-SDK:: Error: params.versionId is required to update a did'); + } + if (!this.didrpc && !this.didAPIService) { + throw new Error('HID-SSI-SDK:: Error: HypersignDID class is not instantiated with "Offlinesigner" or have not been initilized with "EntityAPISecreKey"'); + } + const { didDocument, privateKeyMultibase, verificationMethodId, versionId } = params; + const prepareDidDocument = this.prepareDidDocument(didDocument); + const proof = yield this._jsonLdSign({ + didDocument: prepareDidDocument, + privateKeyMultibase, + verificationMethodId, + }); + let signInfos = [ + { + type: constant['DID_BabyJubJubKey2021'].SIGNATURE_TYPE, + created: (_a = proof.created) !== null && _a !== void 0 ? _a : this._getDateTime(), + verificationMethod: verificationMethodId, + proofPurpose: enums_1.VerificationMethodRelationships.assertionMethod, + proofValue: proof.proofValue, + }, + ]; + if (params.otherSignInfo) { + signInfos = [...signInfos, ...params.otherSignInfo]; + } + if (params.readonly === true) { + return { + didDocument, + signInfos, + versionId, + }; + } + if (this.didrpc) { + const result = yield this.didrpc.updateDID(didDocument, signInfos, versionId); + response.transactionHash = result.transactionHash; + } + else if (this.didAPIService) { + const newSignInfos = signInfos; + const result = yield this.didAPIService.updateDid({ + didDocument: didDocument, + signInfos: newSignInfos, + deactivate: false, + }); + response.transactionHash = result.transactionHash; + } + return response; + }); + } + /** + * Deactivate a DIDDocument in Hypersign blockchain - an onchain activity + * @params + * - params.didDocument : LD did document + * - params.privateKeyMultibase : Private Key to sign the doc + * - params.verificationMethodId : VerificationMethodId of the document + * - params.versionId : Version of the document + * @returns {Promise} Result of the deactivatee operation + */ + deactivate(params) { + var _a; + return __awaiter(this, void 0, void 0, function* () { + const response = {}; + if (!params.didDocument) { + throw new Error('HID-SSI-SDK:: Error: params.didDocument is required to deactivate a did'); + } + if (!params.privateKeyMultibase) { + throw new Error('HID-SSI-SDK:: Error: params.privateKeyMultibase is required to deactivate a did'); + } + if (!params.verificationMethodId) { + throw new Error('HID-SSI-SDK:: Error: params.verificationMethodId is required to deactivate a did'); + } + if (!params.versionId) { + throw new Error('HID-SSI-SDK:: Error: params.versionId is required to deactivate a did'); + } + if (!this.didrpc && !this.didAPIService) { + throw new Error('HID-SSI-SDK:: Error: HypersignDID class is not instantiated with "Offlinesigner" or have not been initilized with "EntityAPISecreKey"'); + } + const { didDocument, privateKeyMultibase, verificationMethodId, versionId } = params; + const prepareDidDocument = this.prepareDidDocument(didDocument); + const proof = yield this._jsonLdSign({ + didDocument: prepareDidDocument, + privateKeyMultibase, + verificationMethodId, + }); + const signInfos = [ + { + type: constant['DID_BabyJubJubKey2021'].SIGNATURE_TYPE, + created: (_a = proof.created) !== null && _a !== void 0 ? _a : this._getDateTime(), + verificationMethod: verificationMethodId, + proofPurpose: enums_1.VerificationMethodRelationships.assertionMethod, + proofValue: proof.proofValue, + }, + ]; + if (this.didrpc) { + const result = yield this.didrpc.deactivateDID(didDocument.id, signInfos, versionId); + response.transactionHash = result.transactionHash; + } + else if (this.didAPIService) { + const newSignInfos = signInfos; + const result = yield this.didAPIService.updateDid({ + didDocument: didDocument, + signInfos: newSignInfos, + deactivate: true, + }); + response.transactionHash = result.transactionHash; + } + return response; + }); + } +} +exports.default = HypersignBJJDID; diff --git a/build/src/did/did.d.ts b/build/src/did/did.d.ts index d48e91e..d151b38 100644 --- a/build/src/did/did.d.ts +++ b/build/src/did/did.d.ts @@ -1,12 +1,16 @@ -import { Did, SignInfo } from '../../libs/generated/ssi/did'; +import { DidDocument as Did } from '../../libs/generated/ssi/did'; +import { DocumentProof as SignInfo } from '../../libs/generated/ssi/proof'; import Web3 from 'web3'; -import { IDID, IDIDResolve, ISignedDIDDocument, IKeyType, IClientSpec, IVerificationRelationships, ISignData } from './IDID'; +import { IDID, IDIDResolve, ISignedDIDDocument, IClientSpec, ISignData, ISignInfo, SupportedPurpose } from './IDID'; +import { VerificationMethodRelationships, VerificationMethodTypes } from '../../libs/generated/ssi/client/enums'; import { OfflineSigner } from '@cosmjs/proto-signing'; +import HypersignBJJDId from './bjjdid'; /** Class representing HypersignDID */ export default class HypersignDID implements IDID { private didrpc; private didAPIService; namespace: string; + bjjDID: HypersignBJJDId; /** * Creates instance of HypersignDID class * @constructor @@ -23,7 +27,10 @@ export default class HypersignDID implements IDID { nodeRestEndpoint?: string; entityApiSecretKey?: string; }); - private _sign; + private _getDateTime; + private _jsonLdSign; + private _jsonLdNormalize; + private _concat; private _getId; private _filterVerificationRelationships; /** @@ -59,7 +66,7 @@ export default class HypersignDID implements IDID { generate(params: { methodSpecificId?: string; publicKeyMultibase: string; - verificationRelationships?: IVerificationRelationships[]; + verificationRelationships?: VerificationMethodRelationships[]; }): Promise; /** * Register a new DID and Document in Hypersign blockchain - an onchain activity @@ -78,21 +85,27 @@ export default class HypersignDID implements IDID { didDocument: Did; transactionHash: string; }>; + /** + * Generate signature + * @params + * - params.didDocument : LD did document + * - params.privateKeyMultibase : Private Key to sign the doc + * - params.verificationMethodId : VerificationMethodId of the document + * @returns {Promise} Generate Array + */ createSignInfos(params: { didDocument: Did; privateKeyMultibase: string; verificationMethodId: string; - }): Promise>; + }): Promise>; /** * Resolves a DID into DIDDocument from Hypersign blockchain - an onchain activity * @params * - params.did : DID - * - params.ed25519verificationkey2020 : *Optional* True/False * @returns {Promise} didDocument and didDocumentMetadata */ resolve(params: { did: string; - ed25519verificationkey2020?: boolean; }): Promise; /** * Update a DIDDocument in Hypersign blockchain - an onchain activity @@ -108,8 +121,14 @@ export default class HypersignDID implements IDID { privateKeyMultibase: string; verificationMethodId: string; versionId: string; + readonly?: boolean; + otherSignInfo?: Array; }): Promise<{ transactionHash: string; + } | { + didDocument: any; + signInfos: any; + versionId: any; }>; /** * Deactivate a DIDDocument in Hypersign blockchain - an onchain activity @@ -137,31 +156,35 @@ export default class HypersignDID implements IDID { * - params.did : did of the user * - params.domain : domain is the domain of the DID Document that is being authenticated * - params.verificationMethodId : verificationMethodId of the DID + * - params.purpose : purpose of Auth (authentication or assertionMethod) * @returns {Promise} Signed DID Document */ sign(params: { - didDocument: Did; + didDocument?: Did; privateKeyMultibase: string; challenge: string; domain: string; - did: string; + did?: string; verificationMethodId: string; + purpose?: SupportedPurpose; }): Promise; /** * Verifies a signed DIDDocument * @params * - params.didDocument : Signed DID Document * - params.privateKey : private key in multibase format (base58 digitalbazar format) - * - params.challenge : challenge is a random string generated by the client + * - params.challenge : challenge is a random string generated by the client required for authentication purpose * - params.did : did of the user * - params.domain : domain is the domain of the DID Document that is being authenticated + * - params.purpose : purpose of Auth (authentication or assertion) * @returns Promise<{ verificationResult }> Verification Result */ verify(params: { didDocument: Did; verificationMethodId: string; - challenge: string; + challenge?: string; domain?: string; + purpose?: SupportedPurpose; }): Promise; private _isValidMultibaseBase58String; /** @@ -181,7 +204,7 @@ export default class HypersignDID implements IDID { address: string; chainId: string; clientSpec: IClientSpec; - verificationRelationships?: IVerificationRelationships[]; + verificationRelationships?: VerificationMethodRelationships[]; }): Promise; /** * Register did on chain generated using wallet @@ -192,7 +215,7 @@ export default class HypersignDID implements IDID { */ registerByClientSpec(params: { didDocument: Did; - signInfos: SignInfo[]; + signInfos: ISignInfo[]; }): Promise<{ didDocument: Did; transactionHash: string; @@ -208,7 +231,7 @@ export default class HypersignDID implements IDID { updateByClientSpec(params: { didDocument: Did; versionId: string; - signInfos: SignInfo[]; + signInfos: ISignInfo[]; }): Promise<{ transactionHash: string; }>; @@ -222,7 +245,7 @@ export default class HypersignDID implements IDID { */ deactivateByClientSpec(params: { didDocument: Did; - signInfos: SignInfo[]; + signInfos: ISignInfo[]; versionId: string; }): Promise<{ transactionHash: string; @@ -257,18 +280,17 @@ export default class HypersignDID implements IDID { * - params.address : Checksum address from web3 wallet * - params.web3 : web3 object * - params.chainId : Optional, chainId - * @returns {Promise<{ didDocument: Did; signature: string }>} + * - params.verificationMethodId : verificationMEthodId for generating signature + * @returns {Promise} */ signByClientSpec(params: { didDocument: Did; clientSpec: IClientSpec; address: string; web3: Web3 | any; + verificationMethodId: string; chainId?: string; - }): Promise<{ - didDocument: Did; - signature: string; - }>; + }): Promise; /** * Add verification method * @param @@ -284,7 +306,7 @@ export default class HypersignDID implements IDID { addVerificationMethod(params: { did?: string; didDocument?: Did; - type: IKeyType; + type: VerificationMethodTypes; id?: string; controller?: string; publicKeyMultibase?: string; diff --git a/build/src/did/did.d.ts.map b/build/src/did/did.d.ts.map index 41da3e4..a1ba7fd 100644 --- a/build/src/did/did.d.ts.map +++ b/build/src/did/did.d.ts.map @@ -1 +1 @@ -{"version":3,"file":"did.d.ts","sourceRoot":"","sources":["../../../src/did/did.ts"],"names":[],"mappings":"AAWA,OAAO,EAAE,GAAG,EAA+B,QAAQ,EAAE,MAAM,8BAA8B,CAAC;AAG1F,OAAO,IAAI,MAAM,MAAM,CAAC;AAIxB,OAAO,EAEL,IAAI,EAEJ,WAAW,EAIX,kBAAkB,EAClB,QAAQ,EACR,WAAW,EACX,0BAA0B,EAC1B,SAAS,EAEV,MAAM,QAAQ,CAAC;AAEhB,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAiHtD,sCAAsC;AACtC,MAAM,CAAC,OAAO,OAAO,YAAa,YAAW,IAAI;IAC/C,OAAO,CAAC,MAAM,CAAiB;IAC/B,OAAO,CAAC,aAAa,CAAwB;IACtC,SAAS,EAAE,MAAM,CAAC;IAEzB;;;;;;;;OAQG;gBAED,MAAM,GAAE;QACN,SAAS,CAAC,EAAE,MAAM,CAAC;QACnB,aAAa,CAAC,EAAE,aAAa,CAAC;QAC9B,eAAe,CAAC,EAAE,MAAM,CAAC;QACzB,gBAAgB,CAAC,EAAE,MAAM,CAAC;QAC1B,kBAAkB,CAAC,EAAE,MAAM,CAAC;KACxB;YAqBM,KAAK;IAcnB,OAAO,CAAC,MAAM,CAUZ;IAEF,OAAO,CAAC,gCAAgC;IAkBxC;;;;;;OAMG;IACH,OAAO,CAAC,uBAAuB;IAWlB,IAAI;IAcjB;;;;;OAKG;IACU,YAAY,CAAC,MAAM,EAAE;QAChC,IAAI,CAAC,EAAE,MAAM,GAAG,UAAU,CAAC;QAC3B,UAAU,CAAC,EAAE,MAAM,CAAC;KACrB,GAAG,OAAO,CAAC;QAAE,mBAAmB,EAAE,MAAM,CAAC;QAAC,kBAAkB,EAAE,MAAM,CAAA;KAAE,CAAC;IAmBxE;;;;;;;OAOG;IACU,QAAQ,CAAC,MAAM,EAAE;QAC5B,gBAAgB,CAAC,EAAE,MAAM,CAAC;QAC1B,kBAAkB,EAAE,MAAM,CAAC;QAC3B,yBAAyB,CAAC,EAAE,0BAA0B,EAAE,CAAC;KAC1D,GAAG,OAAO,CAAC,GAAG,CAAC;IAmChB;;;;;;;OAOG;IACU,QAAQ,CAAC,MAAM,EAAE;QAC5B,WAAW,EAAE,GAAG,CAAC;QACjB,mBAAmB,CAAC,EAAE,MAAM,CAAC;QAC7B,oBAAoB,CAAC,EAAE,MAAM,CAAC;QAC9B,QAAQ,CAAC,EAAE,SAAS,EAAE,CAAC;KACxB,GAAG,OAAO,CAAC;QAAE,WAAW,EAAE,GAAG,CAAC;QAAC,eAAe,EAAE,MAAM,CAAA;KAAE,CAAC;IAgF7C,eAAe,CAAC,MAAM,EAAE;QACnC,WAAW,EAAE,GAAG,CAAC;QACjB,mBAAmB,EAAE,MAAM,CAAC;QAC5B,oBAAoB,EAAE,MAAM,CAAC;KAC9B,GAAG,OAAO,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;IAkB5B;;;;;;OAMG;IACU,OAAO,CAAC,MAAM,EAAE;QAAE,GAAG,EAAE,MAAM,CAAC;QAAC,0BAA0B,CAAC,EAAE,OAAO,CAAA;KAAE,GAAG,OAAO,CAAC,WAAW,CAAC;IA6BzG;;;;;;;;OAQG;IACU,MAAM,CAAC,MAAM,EAAE;QAC1B,WAAW,EAAE,GAAG,CAAC;QACjB,mBAAmB,EAAE,MAAM,CAAC;QAC5B,oBAAoB,EAAE,MAAM,CAAC;QAC7B,SAAS,EAAE,MAAM,CAAC;KACnB,GAAG,OAAO,CAAC;QAAE,eAAe,EAAE,MAAM,CAAA;KAAE,CAAC;IAiDxC;;;;;;;;OAQG;IACU,UAAU,CAAC,MAAM,EAAE;QAC9B,WAAW,EAAE,GAAG,CAAC;QACjB,mBAAmB,EAAE,MAAM,CAAC;QAC5B,oBAAoB,EAAE,MAAM,CAAC;QAC7B,SAAS,EAAE,MAAM,CAAC;KACnB,GAAG,OAAO,CAAC;QAAE,eAAe,EAAE,MAAM,CAAA;KAAE,CAAC;IAiDxC;;;;;;;;;;OAUG;IACU,IAAI,CAAC,MAAM,EAAE;QACxB,WAAW,EAAE,GAAG,CAAC;QACjB,mBAAmB,EAAE,MAAM,CAAC;QAC5B,SAAS,EAAE,MAAM,CAAC;QAClB,MAAM,EAAE,MAAM,CAAC;QACf,GAAG,EAAE,MAAM,CAAC;QACZ,oBAAoB,EAAE,MAAM,CAAC;KAC9B,GAAG,OAAO,CAAC,kBAAkB,CAAC;IA+D/B;;;;;;;;;OASG;IACU,MAAM,CAAC,MAAM,EAAE;QAC1B,WAAW,EAAE,GAAG,CAAC;QACjB,oBAAoB,EAAE,MAAM,CAAC;QAC7B,SAAS,EAAE,MAAM,CAAC;QAClB,MAAM,CAAC,EAAE,MAAM,CAAC;KACjB,GAAG,OAAO,CAAC,MAAM,CAAC;IAiEnB,OAAO,CAAC,6BAA6B,CAGnC;IAEF;;;;;;;;;;OAUG;IACU,kBAAkB,CAAC,MAAM,EAAE;QACtC,gBAAgB,EAAE,MAAM,CAAC;QACzB,SAAS,CAAC,EAAE,MAAM,CAAC;QACnB,OAAO,EAAE,MAAM,CAAC;QAChB,OAAO,EAAE,MAAM,CAAC;QAChB,UAAU,EAAE,WAAW,CAAC;QACxB,yBAAyB,CAAC,EAAE,0BAA0B,EAAE,CAAC;KAC1D,GAAG,OAAO,CAAC,GAAG,CAAC;IAmFhB;;;;;;OAMG;IAEU,oBAAoB,CAAC,MAAM,EAAE;QACxC,WAAW,EAAE,GAAG,CAAC;QACjB,SAAS,EAAE,QAAQ,EAAE,CAAC;KACvB,GAAG,OAAO,CAAC;QAAE,WAAW,EAAE,GAAG,CAAC;QAAC,eAAe,EAAE,MAAM,CAAA;KAAE,CAAC;IAsE1D;;;;;;;OAOG;IACU,kBAAkB,CAAC,MAAM,EAAE;QACtC,WAAW,EAAE,GAAG,CAAC;QACjB,SAAS,EAAE,MAAM,CAAC;QAClB,SAAS,EAAE,QAAQ,EAAE,CAAC;KACvB,GAAG,OAAO,CAAC;QAAE,eAAe,EAAE,MAAM,CAAA;KAAE,CAAC;IAiExC;;;;;;;OAOG;IACU,sBAAsB,CAAC,MAAM,EAAE;QAC1C,WAAW,EAAE,GAAG,CAAC;QACjB,SAAS,EAAE,QAAQ,EAAE,CAAC;QACtB,SAAS,EAAE,MAAM,CAAC;KACnB,GAAG,OAAO,CAAC;QAAE,eAAe,EAAE,MAAM,CAAA;KAAE,CAAC;IAgExC;;;;;;;;;;OAUG;IACU,2BAA2B,CAAC,MAAM,EAAE;QAC/C,WAAW,EAAE,GAAG,CAAC;QACjB,OAAO,EAAE,MAAM,CAAC;QAChB,oBAAoB,EAAE,MAAM,CAAC;QAC7B,IAAI,EAAE,IAAI,GAAG,GAAG,CAAC;QACjB,UAAU,EAAE,WAAW,CAAC;QACxB,OAAO,CAAC,EAAE,MAAM,CAAC;KAClB,GAAG,OAAO,CAAC;QAAE,WAAW,EAAE,GAAG,CAAC;QAAC,eAAe,EAAE,MAAM,CAAA;KAAE,CAAC;IAmD1D;;;;;;;;;OASG;IACU,gBAAgB,CAAC,MAAM,EAAE;QACpC,WAAW,EAAE,GAAG,CAAC;QACjB,UAAU,EAAE,WAAW,CAAC;QACxB,OAAO,EAAE,MAAM,CAAC;QAChB,IAAI,EAAE,IAAI,GAAG,GAAG,CAAC;QACjB,OAAO,CAAC,EAAE,MAAM,CAAC;KAClB,GAAG,OAAO,CAAC;QAAE,WAAW,EAAE,GAAG,CAAC;QAAC,SAAS,EAAE,MAAM,CAAA;KAAE,CAAC;IAgEpD;;;;;;;;;;;OAWG;IACU,qBAAqB,CAAC,MAAM,EAAE;QACzC,GAAG,CAAC,EAAE,MAAM,CAAC;QACb,WAAW,CAAC,EAAE,GAAG,CAAC;QAClB,IAAI,EAAE,QAAQ,CAAC;QACf,EAAE,CAAC,EAAE,MAAM,CAAC;QACZ,UAAU,CAAC,EAAE,MAAM,CAAC;QACpB,kBAAkB,CAAC,EAAE,MAAM,CAAC;QAC5B,mBAAmB,CAAC,EAAE,MAAM,CAAC;KAC9B,GAAG,OAAO,CAAC,GAAG,CAAC;CAoHjB"} \ No newline at end of file +{"version":3,"file":"did.d.ts","sourceRoot":"","sources":["../../../src/did/did.ts"],"names":[],"mappings":"AAUA,OAAO,EAAE,WAAW,IAAI,GAAG,EAA4C,MAAM,8BAA8B,CAAC;AAC5G,OAAO,EAAiB,aAAa,IAAI,QAAQ,EAAE,MAAM,gCAAgC,CAAC;AAG1F,OAAO,IAAI,MAAM,MAAM,CAAC;AAKxB,OAAO,EACL,IAAI,EAEJ,WAAW,EAGX,kBAAkB,EAClB,WAAW,EACX,SAAS,EACT,SAAS,EACT,gBAAgB,EACjB,MAAM,QAAQ,CAAC;AAChB,OAAO,EAEL,+BAA+B,EAC/B,uBAAuB,EACxB,MAAM,uCAAuC,CAAC;AAC/C,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAItD,OAAO,eAAe,MAAM,UAAU,CAAC;AAuHvC,sCAAsC;AACtC,MAAM,CAAC,OAAO,OAAO,YAAa,YAAW,IAAI;IAC/C,OAAO,CAAC,MAAM,CAAiB;IAC/B,OAAO,CAAC,aAAa,CAAwB;IACtC,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,eAAe,CAAC;IAE/B;;;;;;;;OAQG;gBAED,MAAM,GAAE;QACN,SAAS,CAAC,EAAE,MAAM,CAAC;QACnB,aAAa,CAAC,EAAE,aAAa,CAAC;QAC9B,eAAe,CAAC,EAAE,MAAM,CAAC;QACzB,gBAAgB,CAAC,EAAE,MAAM,CAAC;QAC1B,kBAAkB,CAAC,EAAE,MAAM,CAAC;KACxB;IAuBR,OAAO,CAAC,YAAY;YAIN,WAAW;YAuBX,gBAAgB;IAQ9B,OAAO,CAAC,OAAO;IAMf,OAAO,CAAC,MAAM,CAUZ;IAEF,OAAO,CAAC,gCAAgC;IAkBxC;;;;;;OAMG;IACH,OAAO,CAAC,uBAAuB;IAWlB,IAAI;IAcjB;;;;;OAKG;IACU,YAAY,CAAC,MAAM,EAAE;QAChC,IAAI,CAAC,EAAE,MAAM,GAAG,UAAU,CAAC;QAC3B,UAAU,CAAC,EAAE,MAAM,CAAC;KACrB,GAAG,OAAO,CAAC;QAAE,mBAAmB,EAAE,MAAM,CAAC;QAAC,kBAAkB,EAAE,MAAM,CAAA;KAAE,CAAC;IAmBxE;;;;;;;OAOG;IACU,QAAQ,CAAC,MAAM,EAAE;QAC5B,gBAAgB,CAAC,EAAE,MAAM,CAAC;QAC1B,kBAAkB,EAAE,MAAM,CAAC;QAC3B,yBAAyB,CAAC,EAAE,+BAA+B,EAAE,CAAC;KAC/D,GAAG,OAAO,CAAC,GAAG,CAAC;IAgChB;;;;;;;OAOG;IACU,QAAQ,CAAC,MAAM,EAAE;QAC5B,WAAW,EAAE,GAAG,CAAC;QACjB,mBAAmB,CAAC,EAAE,MAAM,CAAC;QAC7B,oBAAoB,CAAC,EAAE,MAAM,CAAC;QAC9B,QAAQ,CAAC,EAAE,SAAS,EAAE,CAAC;KACxB,GAAG,OAAO,CAAC;QAAE,WAAW,EAAE,GAAG,CAAC;QAAC,eAAe,EAAE,MAAM,CAAA;KAAE,CAAC;IA6G1D;;;;;;;OAOG;IACU,eAAe,CAAC,MAAM,EAAE;QACnC,WAAW,EAAE,GAAG,CAAC;QACjB,mBAAmB,EAAE,MAAM,CAAC;QAC5B,oBAAoB,EAAE,MAAM,CAAC;KAC9B,GAAG,OAAO,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC;IAwC7B;;;;;OAKG;IACU,OAAO,CAAC,MAAM,EAAE;QAAE,GAAG,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC,WAAW,CAAC;IAkBnE;;;;;;;;OAQG;IACU,MAAM,CAAC,MAAM,EAAE;QAC1B,WAAW,EAAE,GAAG,CAAC;QACjB,mBAAmB,EAAE,MAAM,CAAC;QAC5B,oBAAoB,EAAE,MAAM,CAAC;QAC7B,SAAS,EAAE,MAAM,CAAC;QAClB,QAAQ,CAAC,EAAE,OAAO,CAAC;QACnB,aAAa,CAAC,EAAE,KAAK,CAAC,QAAQ,CAAC,CAAC;KACjC,GAAG,OAAO,CAAC;QAAE,eAAe,EAAE,MAAM,CAAA;KAAE,GAAG;QAAE,WAAW,MAAC;QAAC,SAAS,MAAC;QAAC,SAAS,MAAA;KAAE,CAAC;IAkEhF;;;;;;;;OAQG;IACU,UAAU,CAAC,MAAM,EAAE;QAC9B,WAAW,EAAE,GAAG,CAAC;QACjB,mBAAmB,EAAE,MAAM,CAAC;QAC5B,oBAAoB,EAAE,MAAM,CAAC;QAC7B,SAAS,EAAE,MAAM,CAAC;KACnB,GAAG,OAAO,CAAC;QAAE,eAAe,EAAE,MAAM,CAAA;KAAE,CAAC;IAsDxC;;;;;;;;;;;OAWG;IACU,IAAI,CAAC,MAAM,EAAE;QACxB,WAAW,CAAC,EAAE,GAAG,CAAC;QAClB,mBAAmB,EAAE,MAAM,CAAC;QAC5B,SAAS,EAAE,MAAM,CAAC;QAClB,MAAM,EAAE,MAAM,CAAC;QACf,GAAG,CAAC,EAAE,MAAM,CAAC;QACb,oBAAoB,EAAE,MAAM,CAAC;QAC7B,OAAO,CAAC,EAAE,gBAAgB,CAAC;KAC5B,GAAG,OAAO,CAAC,kBAAkB,CAAC;IA0E/B;;;;;;;;;;OAUG;IACU,MAAM,CAAC,MAAM,EAAE;QAC1B,WAAW,EAAE,GAAG,CAAC;QACjB,oBAAoB,EAAE,MAAM,CAAC;QAC7B,SAAS,CAAC,EAAE,MAAM,CAAC;QACnB,MAAM,CAAC,EAAE,MAAM,CAAC;QAChB,OAAO,CAAC,EAAE,gBAAgB,CAAC;KAC5B,GAAG,OAAO,CAAC,MAAM,CAAC;IAuEnB,OAAO,CAAC,6BAA6B,CAGnC;IAEF;;;;;;;;;;OAUG;IACU,kBAAkB,CAAC,MAAM,EAAE;QACtC,gBAAgB,EAAE,MAAM,CAAC;QACzB,SAAS,CAAC,EAAE,MAAM,CAAC;QACnB,OAAO,EAAE,MAAM,CAAC;QAChB,OAAO,EAAE,MAAM,CAAC;QAChB,UAAU,EAAE,WAAW,CAAC;QACxB,yBAAyB,CAAC,EAAE,+BAA+B,EAAE,CAAC;KAC/D,GAAG,OAAO,CAAC,GAAG,CAAC;IA2FhB;;;;;;OAMG;IAEU,oBAAoB,CAAC,MAAM,EAAE;QACxC,WAAW,EAAE,GAAG,CAAC;QACjB,SAAS,EAAE,SAAS,EAAE,CAAC;KACxB,GAAG,OAAO,CAAC;QAAE,WAAW,EAAE,GAAG,CAAC;QAAC,eAAe,EAAE,MAAM,CAAA;KAAE,CAAC;IA2F1D;;;;;;;OAOG;IACU,kBAAkB,CAAC,MAAM,EAAE;QACtC,WAAW,EAAE,GAAG,CAAC;QACjB,SAAS,EAAE,MAAM,CAAC;QAClB,SAAS,EAAE,SAAS,EAAE,CAAC;KACxB,GAAG,OAAO,CAAC;QAAE,eAAe,EAAE,MAAM,CAAA;KAAE,CAAC;IA6ExC;;;;;;;OAOG;IACU,sBAAsB,CAAC,MAAM,EAAE;QAC1C,WAAW,EAAE,GAAG,CAAC;QACjB,SAAS,EAAE,SAAS,EAAE,CAAC;QACvB,SAAS,EAAE,MAAM,CAAC;KACnB,GAAG,OAAO,CAAC;QAAE,eAAe,EAAE,MAAM,CAAA;KAAE,CAAC;IA6ExC;;;;;;;;;;OAUG;IACU,2BAA2B,CAAC,MAAM,EAAE;QAC/C,WAAW,EAAE,GAAG,CAAC;QACjB,OAAO,EAAE,MAAM,CAAC;QAChB,oBAAoB,EAAE,MAAM,CAAC;QAC7B,IAAI,EAAE,IAAI,GAAG,GAAG,CAAC;QACjB,UAAU,EAAE,WAAW,CAAC;QACxB,OAAO,CAAC,EAAE,MAAM,CAAC;KAClB,GAAG,OAAO,CAAC;QAAE,WAAW,EAAE,GAAG,CAAC;QAAC,eAAe,EAAE,MAAM,CAAA;KAAE,CAAC;IAqD1D;;;;;;;;;;OAUG;IACU,gBAAgB,CAAC,MAAM,EAAE;QACpC,WAAW,EAAE,GAAG,CAAC;QACjB,UAAU,EAAE,WAAW,CAAC;QACxB,OAAO,EAAE,MAAM,CAAC;QAChB,IAAI,EAAE,IAAI,GAAG,GAAG,CAAC;QACjB,oBAAoB,EAAE,MAAM,CAAC;QAC7B,OAAO,CAAC,EAAE,MAAM,CAAC;KAClB,GAAG,OAAO,CAAC,kBAAkB,CAAC;IAwH/B;;;;;;;;;;;OAWG;IACU,qBAAqB,CAAC,MAAM,EAAE;QACzC,GAAG,CAAC,EAAE,MAAM,CAAC;QACb,WAAW,CAAC,EAAE,GAAG,CAAC;QAClB,IAAI,EAAE,uBAAuB,CAAC;QAC9B,EAAE,CAAC,EAAE,MAAM,CAAC;QACZ,UAAU,CAAC,EAAE,MAAM,CAAC;QACpB,kBAAkB,CAAC,EAAE,MAAM,CAAC;QAC5B,mBAAmB,CAAC,EAAE,MAAM,CAAC;KAC9B,GAAG,OAAO,CAAC,GAAG,CAAC;CA6HjB"} \ No newline at end of file diff --git a/build/src/did/did.js b/build/src/did/did.js index 72a76b0..9a480dd 100644 --- a/build/src/did/did.js +++ b/build/src/did/did.js @@ -42,23 +42,27 @@ Object.defineProperty(exports, "__esModule", { value: true }); */ const constant = __importStar(require("../constants")); const jsonld_signatures_1 = __importDefault(require("jsonld-signatures")); -const { AuthenticationProofPurpose } = jsonld_signatures_1.default.purposes; +const { AuthenticationProofPurpose, AssertionProofPurpose } = jsonld_signatures_1.default.purposes; const didRPC_1 = require("./didRPC"); const utils_1 = __importDefault(require("../utils")); -const ed25519 = require('@stablelib/ed25519'); -const did_1 = require("../../libs/generated/ssi/did"); const ed25519_verification_key_2020_1 = require("@digitalbazaar/ed25519-verification-key-2020"); const ed25519_signature_2020_1 = require("@digitalbazaar/ed25519-signature-2020"); const web3_1 = __importDefault(require("web3")); const did_service_1 = __importDefault(require("../ssiApi/services/did/did.service")); +const jsonld_1 = __importDefault(require("jsonld")); +const crypto_1 = __importDefault(require("crypto")); const IDID_1 = require("./IDID"); +const enums_1 = require("../../libs/generated/ssi/client/enums"); const v1_1 = __importDefault(require("../../libs/w3cache/v1")); +const client_spec_1 = require("../../libs/generated/ssi/client_spec"); +const bjjdid_1 = __importDefault(require("./bjjdid")); +const documentLoader = jsonld_signatures_1.default.extendContextLoader(v1_1.default); class DIDDocument { constructor(publicKey, blockchainAccountId, id, keyType, verificationRelationships) { let vm; switch (keyType) { - case IDID_1.IKeyType.Ed25519VerificationKey2020: { - this.context = [constant['DID_' + keyType].DID_BASE_CONTEXT]; + case enums_1.VerificationMethodTypes.Ed25519VerificationKey2020: { + this['@context'] = [constant['DID_' + keyType].DID_BASE_CONTEXT, constant.VC.CREDENTIAIL_SECURITY_SUITE]; this.id = id; this.controller = [this.id]; this.alsoKnownAs = [this.id]; @@ -67,7 +71,6 @@ class DIDDocument { type: constant['DID_' + keyType].VERIFICATION_METHOD_TYPE, controller: this.id, publicKeyMultibase: publicKey, - blockchainAccountId: '', }; const verificationMethod = vm; this.verificationMethod = [verificationMethod]; @@ -77,14 +80,18 @@ class DIDDocument { this.capabilityInvocation = []; this.capabilityDelegation = []; verificationRelationships === null || verificationRelationships === void 0 ? void 0 : verificationRelationships.forEach((value) => { - this[value] = [verificationMethod.id]; + const vmId = verificationMethod.id; + this[value] = [vmId]; }); // TODO: we should take services object in consntructor this.service = []; break; } - case IDID_1.IKeyType.EcdsaSecp256k1RecoveryMethod2020: { - this.context = [constant['DID_' + keyType].DID_BASE_CONTEXT]; + case enums_1.VerificationMethodTypes.EcdsaSecp256k1RecoveryMethod2020: { + this['@context'] = [ + constant['DID_' + keyType].DID_BASE_CONTEXT, + constant['DID_' + keyType].SECP256K12020_RECOVERY_CONTEXT, + ]; this.id = id; this.controller = [this.id]; this.alsoKnownAs = [this.id]; @@ -102,17 +109,21 @@ class DIDDocument { this.capabilityInvocation = []; this.capabilityDelegation = []; verificationRelationships === null || verificationRelationships === void 0 ? void 0 : verificationRelationships.forEach((value) => { - this[value] = [verificationMethod.id]; + const vmId = verificationMethod.id; + this[value] = [vmId]; }); // TODO: we should take services object in consntructor this.service = []; break; } - case IDID_1.IKeyType.EcdsaSecp256k1VerificationKey2019: { - this.context = [constant['DID_' + keyType].DID_BASE_CONTEXT]; + case enums_1.VerificationMethodTypes.EcdsaSecp256k1VerificationKey2019: { + this['@context'] = [ + constant['DID_' + keyType].DID_BASE_CONTEXT, + constant['DID_' + keyType].SECP256K12020_VERIFICATION_CONTEXT, + ]; this.id = id; this.controller = [this.id]; - this.alsoKnownAs = []; + this.alsoKnownAs = [this.id]; vm = { id: this.id + '#key-1', type: constant['DID_' + keyType].VERIFICATION_METHOD_TYPE, @@ -128,7 +139,8 @@ class DIDDocument { this.capabilityInvocation = []; this.capabilityDelegation = []; verificationRelationships === null || verificationRelationships === void 0 ? void 0 : verificationRelationships.forEach((value) => { - this[value] = [verificationMethod.id]; + const vmId = verificationMethod.id; + this[value] = [vmId]; }); // TODO: we should take services object in consntructor this.service = []; @@ -183,26 +195,54 @@ class HypersignDID { this.didAPIService = null; } this.namespace = namespace ? namespace : ''; + this.bjjDID = new bjjdid_1.default(params); + } + _getDateTime() { + return new Date(new Date().getTime() - 100000).toISOString().slice(0, -5) + 'Z'; } - _sign(params) { + _jsonLdSign(params) { + var _a; return __awaiter(this, void 0, void 0, function* () { - const { privateKeyMultibase: privateKeyMultibaseConverted } = utils_1.default.convertEd25519verificationkey2020toStableLibKeysInto({ - privKey: params.privateKeyMultibase, + const { didDocument, privateKeyMultibase, verificationMethodId } = params; + const publicKeyId = verificationMethodId; + const pubKey = (_a = didDocument.verificationMethod) === null || _a === void 0 ? void 0 : _a.find((item) => item.id === publicKeyId); + const publicKeyMultibase1 = pubKey === null || pubKey === void 0 ? void 0 : pubKey.publicKeyMultibase; + const keyPair = yield ed25519_verification_key_2020_1.Ed25519VerificationKey2020.from({ + id: publicKeyId, + privateKeyMultibase: privateKeyMultibase, + publicKeyMultibase: publicKeyMultibase1, }); - const { didDocString } = params; - // TODO: do proper checck of paramaters - const did = JSON.parse(didDocString); - const didBytes = (yield did_1.Did.encode(did)).finish(); - const signed = ed25519.sign(privateKeyMultibaseConverted, didBytes); - return Buffer.from(signed).toString('base64'); + const suite = new ed25519_signature_2020_1.Ed25519Signature2020({ key: keyPair }); + const signedDidDocument = (yield jsonld_signatures_1.default.sign(didDocument, { + suite, + purpose: new AssertionProofPurpose(), + documentLoader, + })); + return signedDidDocument; }); } + _jsonLdNormalize(params) { + return __awaiter(this, void 0, void 0, function* () { + const docToNormalize = params.doc; + const normalizedoc = yield jsonld_1.default.normalize(docToNormalize, { + format: 'application/n-quads', + algorithm: 'URDNA2015', + }); + return normalizedoc; + }); + } + _concat(arr1, arr2) { + const concatenatedArr = new Uint8Array(arr1.length + arr2.length); + concatenatedArr.set(arr1, 0); + concatenatedArr.set(arr2, arr1.length); + return concatenatedArr; + } _filterVerificationRelationships(verificationRelationships) { let vR = [ - IDID_1.IVerificationRelationships.assertionMethod, - IDID_1.IVerificationRelationships.authentication, - IDID_1.IVerificationRelationships.capabilityDelegation, - IDID_1.IVerificationRelationships.capabilityInvocation, + enums_1.VerificationMethodRelationships.assertionMethod, + enums_1.VerificationMethodRelationships.authentication, + enums_1.VerificationMethodRelationships.capabilityDelegation, + enums_1.VerificationMethodRelationships.capabilityInvocation, ]; if (verificationRelationships && verificationRelationships.length > 0) { const set1 = new Set(vR); @@ -281,7 +321,7 @@ class HypersignDID { return __awaiter(this, void 0, void 0, function* () { let verificationRelationships = []; if (params.verificationRelationships && params.verificationRelationships.length > 0) { - if (params.verificationRelationships.includes(IDID_1.IVerificationRelationships.keyAgreement)) { + if (params.verificationRelationships.includes(enums_1.VerificationMethodRelationships.keyAgreement)) { throw new Error('HID-SSI-SDK:: Error: keyAgreement is not allowed in verificationRelationships'); } verificationRelationships = this._filterVerificationRelationships(params.verificationRelationships); @@ -292,9 +332,7 @@ class HypersignDID { if (!params.publicKeyMultibase) { throw new Error('HID-SSI-SDK:: Error: params.publicKeyMultibase is required to generate new did didoc'); } - const { publicKeyMultibase: publicKeyMultibase1 } = utils_1.default.convertEd25519verificationkey2020toStableLibKeysInto({ - publicKey: params.publicKeyMultibase, - }); + const publicKeyMultibase1 = params.publicKeyMultibase; const methodSpecificId = publicKeyMultibase1; let didId; if (params.methodSpecificId) { @@ -303,7 +341,7 @@ class HypersignDID { else { didId = this._getId(methodSpecificId); } - const newDid = new DIDDocument(publicKeyMultibase1, '', didId, IDID_1.IKeyType.Ed25519VerificationKey2020, verificationRelationships); + const newDid = new DIDDocument(publicKeyMultibase1, '', didId, enums_1.VerificationMethodTypes.Ed25519VerificationKey2020, verificationRelationships); return utils_1.default.jsonToLdConvertor(Object.assign({}, newDid)); }); } @@ -325,9 +363,8 @@ class HypersignDID { if (!this.didrpc && !this.didAPIService) { throw new Error('HID-SSI-SDK:: Error: HypersignDID class is not instantiated with "Offlinesigner" or have not been initilized with "EntityAPISecreKey"'); } - const { didDocument } = params; - const didDocStringJson = utils_1.default.ldToJsonConvertor(didDocument); - const didDoc = didDocStringJson; + let { didDocument } = params; + const didDoc = didDocument; const signInfos = []; if (!params.signData) { if (!params.privateKeyMultibase) { @@ -337,14 +374,28 @@ class HypersignDID { throw new Error('HID-SSI-SDK:: Error: params.verificationMethodId is required to register a did'); } const { privateKeyMultibase, verificationMethodId } = params; - const signature = yield this._sign({ - didDocString: JSON.stringify(didDocStringJson), - privateKeyMultibase, - }); + let signature; + let createdAt; + if (!didDocument['@context']) { + throw new Error('HID-SSI-SDK:: Error: didDocument is not in Ld-json format'); + } + else { + didDocument = utils_1.default.removeEmptyString(didDocument); + const signedDidDoc = yield this._jsonLdSign({ + didDocument: didDocument, + privateKeyMultibase, + verificationMethodId, + }); + const { proof } = signedDidDoc; + signature = proof.proofValue; + createdAt = proof.created; + } signInfos.push({ - signature, - verification_method_id: verificationMethodId, - clientSpec: undefined, + type: constant['DID_Ed25519VerificationKey2020'].SIGNATURE_TYPE, + created: createdAt !== null && createdAt !== void 0 ? createdAt : this._getDateTime(), + verificationMethod: verificationMethodId, + proofPurpose: enums_1.VerificationMethodRelationships.assertionMethod, + proofValue: signature, }); } else { @@ -362,16 +413,32 @@ class HypersignDID { throw new Error(`HID-SSI-SDK:: Error: params.signData[${i}].type is required to register a did`); } const { type, privateKeyMultibase, verificationMethodId } = params.signData[i]; - if (type !== IDID_1.IKeyType.X25519KeyAgreementKey2020 && type !== IDID_1.IKeyType.X25519KeyAgreementKeyEIP5630) { - const signature = yield this._sign({ - didDocString: JSON.stringify(didDocStringJson), - privateKeyMultibase, - }); + let createdAt; + if (type !== enums_1.VerificationMethodTypes.X25519KeyAgreementKey2020 && + type !== enums_1.VerificationMethodTypes.X25519KeyAgreementKeyEIP5630) { + let signature; + if (!didDocument['@context']) { + throw new Error('HID-SSI-SDK:: Error: didDocument is not in Ld-json format'); + } + else { + didDocument = utils_1.default.removeEmptyString(didDocument); + const signedDidDoc = yield this._jsonLdSign({ + didDocument: didDocument, + privateKeyMultibase, + verificationMethodId, + }); + const { proof } = signedDidDoc; + signature = proof.proofValue; + createdAt = proof.created; + } signInfos.push({ - signature, - verification_method_id: verificationMethodId, - clientSpec: undefined, + type: constant['DID_Ed25519VerificationKey2020'].SIGNATURE_TYPE, + created: createdAt !== null && createdAt !== void 0 ? createdAt : this._getDateTime(), + verificationMethod: verificationMethodId, + proofPurpose: enums_1.VerificationMethodRelationships.assertionMethod, + proofValue: signature, }); + delete didDocument['proof']; } } } @@ -392,21 +459,52 @@ class HypersignDID { return response; }); } + /** + * Generate signature + * @params + * - params.didDocument : LD did document + * - params.privateKeyMultibase : Private Key to sign the doc + * - params.verificationMethodId : VerificationMethodId of the document + * @returns {Promise} Generate Array + */ createSignInfos(params) { return __awaiter(this, void 0, void 0, function* () { - const { didDocument } = params; - const didDocStringJson = utils_1.default.ldToJsonConvertor(didDocument); - const didDoc = didDocStringJson; + if (!params.didDocument || Object.keys(params.didDocument).length === 0) { + throw new Error('HID-SSI-SDK:: Error: params.didDocument is required to create signature of a did'); + } + if (!params.privateKeyMultibase) { + throw new Error('HID-SSI-SDK:: Error: params.privateKeyMultibase is required to create signature of a did'); + } + if (!params.verificationMethodId) { + throw new Error('HID-SSI-SDK:: Error: params.verificationMethodId is required to create signature of a did'); + } + let { didDocument } = params; const signInfos = []; const { privateKeyMultibase, verificationMethodId } = params; - const signature = yield this._sign({ - didDocString: JSON.stringify(didDocStringJson), - privateKeyMultibase, - }); + let signature; + let createdAt; + let type; + if (!didDocument['@context']) { + throw new Error('HID-SSI-SDK:: Error: didDocument is not in Ld-json format'); + } + else { + didDocument = utils_1.default.removeEmptyString(didDocument); + const signedDidDocument = yield this._jsonLdSign({ + didDocument, + privateKeyMultibase, + verificationMethodId, + }); + const { proof } = signedDidDocument; + signature = proof.proofValue; + createdAt = proof.created; + type = proof.type; + } signInfos.push({ signature, verification_method_id: verificationMethodId, + created: createdAt, clientSpec: undefined, + type, }); return signInfos; }); @@ -415,7 +513,6 @@ class HypersignDID { * Resolves a DID into DIDDocument from Hypersign blockchain - an onchain activity * @params * - params.did : DID - * - params.ed25519verificationkey2020 : *Optional* True/False * @returns {Promise} didDocument and didDocumentMetadata */ resolve(params) { @@ -426,19 +523,6 @@ class HypersignDID { } if (this.didrpc) { result = yield this.didrpc.resolveDID(params.did); - if (params.ed25519verificationkey2020) { - const didDoc = result.didDocument; - const verificationMethods = didDoc.verificationMethod; - verificationMethods.forEach((verificationMethod) => { - if (verificationMethod.type === constant.DID.VERIFICATION_METHOD_TYPE) { - const ed25519PublicKey = utils_1.default.convertedStableLibKeysIntoEd25519verificationkey2020({ - publicKey: verificationMethod.publicKeyMultibase, - }); - verificationMethod.publicKeyMultibase = ed25519PublicKey.publicKeyMultibase; - } - }); - didDoc.verificationMethod = verificationMethods; - } } else if (this.didAPIService) { result = yield this.didAPIService.resolveDid({ did: params.did }); @@ -459,7 +543,11 @@ class HypersignDID { * @returns {Promise<{ transactionHash: string }>} Result of the update operation */ update(params) { + var _a; return __awaiter(this, void 0, void 0, function* () { + if (!params.readonly) { + params.readonly = false; + } const response = {}; if (!params.didDocument) { throw new Error('HID-SSI-SDK:: Error: params.didDocument is required to update a did'); @@ -476,25 +564,40 @@ class HypersignDID { if (!this.didrpc && !this.didAPIService) { throw new Error('HID-SSI-SDK:: Error: HypersignDID class is not instantiated with "Offlinesigner" or have not been initilized with "EntityAPISecreKey"'); } - const { didDocument, privateKeyMultibase, verificationMethodId, versionId } = params; - const didDocStringJson = utils_1.default.ldToJsonConvertor(didDocument); - const signature = yield this._sign({ didDocString: JSON.stringify(didDocStringJson), privateKeyMultibase }); - const didDoc = didDocStringJson; - const signInfos = [ + const { didDocument, privateKeyMultibase, verificationMethodId, versionId, otherSignInfo } = params; + const signedDidDocument = yield this._jsonLdSign({ + didDocument, + privateKeyMultibase, + verificationMethodId, + }); + const { proof } = signedDidDocument; + let signInfos = [ { - signature, - verification_method_id: verificationMethodId, - clientSpec: undefined, + type: constant['DID_Ed25519VerificationKey2020'].SIGNATURE_TYPE, + created: (_a = proof.created) !== null && _a !== void 0 ? _a : this._getDateTime(), + verificationMethod: verificationMethodId, + proofPurpose: enums_1.VerificationMethodRelationships.assertionMethod, + proofValue: proof.proofValue, }, ]; + if (otherSignInfo) { + signInfos = [...signInfos, ...otherSignInfo]; + } + if (params.readonly === true) { + return { + didDocument, + signInfos, + versionId, + }; + } if (this.didrpc) { - const result = yield this.didrpc.updateDID(didDoc, signInfos, versionId); + const result = yield this.didrpc.updateDID(didDocument, signInfos, versionId); response.transactionHash = result.transactionHash; } else if (this.didAPIService) { const newSignInfos = signInfos; const result = yield this.didAPIService.updateDid({ - didDocument: didDoc, + didDocument: didDocument, signInfos: newSignInfos, deactivate: false, }); @@ -513,6 +616,7 @@ class HypersignDID { * @returns {Promise} Result of the deactivatee operation */ deactivate(params) { + var _a; return __awaiter(this, void 0, void 0, function* () { const response = {}; if (!params.didDocument) { @@ -531,18 +635,23 @@ class HypersignDID { throw new Error('HID-SSI-SDK:: Error: HypersignDID class is not instantiated with "Offlinesigner" or have not been initilized with "EntityAPISecreKey"'); } const { didDocument, privateKeyMultibase, verificationMethodId, versionId } = params; - const didDocStringJson = utils_1.default.ldToJsonConvertor(didDocument); - const signature = yield this._sign({ didDocString: JSON.stringify(didDocStringJson), privateKeyMultibase }); - const didDoc = didDocStringJson; + const signedDidDocument = yield this._jsonLdSign({ + didDocument, + privateKeyMultibase, + verificationMethodId, + }); + const { proof } = signedDidDocument; const signInfos = [ { - signature, - verification_method_id: verificationMethodId, - clientSpec: undefined, + type: constant['DID_Ed25519VerificationKey2020'].SIGNATURE_TYPE, + created: (_a = proof.created) !== null && _a !== void 0 ? _a : this._getDateTime(), + verificationMethod: verificationMethodId, + proofPurpose: enums_1.VerificationMethodRelationships.assertionMethod, + proofValue: proof.proofValue, }, ]; if (this.didrpc) { - const result = yield this.didrpc.deactivateDID(didDoc.id, signInfos, versionId); + const result = yield this.didrpc.deactivateDID(didDocument.id, signInfos, versionId); response.transactionHash = result.transactionHash; } else if (this.didAPIService) { @@ -566,21 +675,18 @@ class HypersignDID { * - params.did : did of the user * - params.domain : domain is the domain of the DID Document that is being authenticated * - params.verificationMethodId : verificationMethodId of the DID + * - params.purpose : purpose of Auth (authentication or assertionMethod) * @returns {Promise} Signed DID Document */ sign(params) { + var _a; return __awaiter(this, void 0, void 0, function* () { const { privateKeyMultibase, challenge, domain, did, didDocument, verificationMethodId } = params; let resolveddoc; if (!privateKeyMultibase) { throw new Error('HID-SSI-SDK:: Error: params.privateKey is required to sign a did'); } - if (!challenge) { - throw new Error('HID-SSI-SDK:: Error: params.challenge is required to sign a did'); - } - if (!domain) { - throw new Error('HID-SSI-SDK:: Error: params.domain is required to sign a did'); - } + const didAuthType = (_a = params.purpose) !== null && _a !== void 0 ? _a : 'authentication'; try { // if did is prvovided then resolve the did doc from the blockchain or else use the did doc provided in the params object to sign the did doc with the proof if (did && this.didrpc) { @@ -588,7 +694,7 @@ class HypersignDID { } else if (didDocument) { resolveddoc = {}; - resolveddoc.didDocument = didDocument; + resolveddoc.didDocument = utils_1.default.removeEmptyString(didDocument); } else { throw new Error('HID-SSI-SDK:: Error: params.did or params.didDocument is required to sign a did'); @@ -597,35 +703,56 @@ class HypersignDID { catch (error) { throw new Error(`HID-SSI-SDK:: Error: could not resolve did ${did}`); } - const publicKeyId = verificationMethodId; - const pubkey = resolveddoc.didDocument.verificationMethod.find((item) => item.id === publicKeyId); - if (!pubkey) { - throw new Error('HID-SSI-SDK:: Error: Incorrect verification method id'); + let signedDidDocument; + if (didAuthType === 'authentication') { + if (!challenge) { + throw new Error('HID-SSI-SDK:: Error: params.challenge is required to sign a did'); + } + if (!domain) { + throw new Error('HID-SSI-SDK:: Error: params.domain is required to sign a did'); + } + const publicKeyId = verificationMethodId; + const pubkey = resolveddoc.didDocument.verificationMethod.find((item) => item.id === publicKeyId); + if (!pubkey) { + throw new Error('HID-SSI-SDK:: Error: Incorrect verification method id'); + } + const publicKeyMultibase1 = pubkey.publicKeyMultibase; + const keyPair = yield ed25519_verification_key_2020_1.Ed25519VerificationKey2020.from({ + id: publicKeyId, + privateKeyMultibase, + publicKeyMultibase: publicKeyMultibase1, + }); + const suite = new ed25519_signature_2020_1.Ed25519Signature2020({ + verificationMethod: publicKeyId, + key: keyPair, + }); + const didDocumentLd = resolveddoc.didDocument; + const controller = { + '@context': constant.DID.CONTROLLER_CONTEXT, + id: publicKeyId, + authentication: didDocumentLd.authentication, + }; + signedDidDocument = (yield jsonld_signatures_1.default.sign(didDocumentLd, { + suite, + purpose: new AuthenticationProofPurpose({ + controller, + challenge, + domain, + }), + documentLoader, + compactProof: constant.compactProof, + })); + } + else if (didAuthType === 'assertionMethod') { + signedDidDocument = yield this._jsonLdSign({ + didDocument: resolveddoc.didDocument, + privateKeyMultibase, + verificationMethodId, + }); + } + else { + throw new Error(`HID-SSI-SDK:: Error: unsupported purpose ${params.purpose}`); } - const { publicKeyMultibase: publicKeyMultibase1 } = utils_1.default.convertedStableLibKeysIntoEd25519verificationkey2020({ - publicKey: pubkey.publicKeyMultibase, - }); - const keyPair = yield ed25519_verification_key_2020_1.Ed25519VerificationKey2020.from({ - id: publicKeyId, - privateKeyMultibase, - publicKeyMultibase: publicKeyMultibase1, - }); - const suite = new ed25519_signature_2020_1.Ed25519Signature2020({ - verificationMethod: publicKeyId, - key: keyPair, - }); - const didDocumentLd = utils_1.default.jsonToLdConvertor(resolveddoc.didDocument); - didDocumentLd['@context'].push(constant.VC.CREDENTAIL_SECURITY_SUITE); - // didDocumentLd['@context'].push(constant.VC.CREDENTAIL_ECDSA_SECURITY_SUITE) - const signedDidDocument = (yield jsonld_signatures_1.default.sign(didDocumentLd, { - suite, - purpose: new AuthenticationProofPurpose({ - challenge, - domain, - }), - documentLoader: v1_1.default, - compactProof: constant.compactProof, - })); return signedDidDocument; }); } @@ -634,12 +761,14 @@ class HypersignDID { * @params * - params.didDocument : Signed DID Document * - params.privateKey : private key in multibase format (base58 digitalbazar format) - * - params.challenge : challenge is a random string generated by the client + * - params.challenge : challenge is a random string generated by the client required for authentication purpose * - params.did : did of the user * - params.domain : domain is the domain of the DID Document that is being authenticated + * - params.purpose : purpose of Auth (authentication or assertion) * @returns Promise<{ verificationResult }> Verification Result */ verify(params) { + var _a, _b; return __awaiter(this, void 0, void 0, function* () { const { didDocument, verificationMethodId, challenge, domain } = params; if (!didDocument) { @@ -651,20 +780,16 @@ class HypersignDID { if (!verificationMethodId) { throw new Error('HID-SSI-SDK:: Error: params.verificationMethodId is required to verify a did'); } - if (!challenge) { - throw new Error('HID-SSI-SDK:: Error: params.challenge is required to verify a did'); - } - const didDoc = didDocument; + const didAuthType = (_a = params.purpose) !== null && _a !== void 0 ? _a : 'authentication'; + const didDoc = utils_1.default.removeEmptyString(didDocument); const publicKeyId = verificationMethodId; - const pubkey = didDoc.verificationMethod.find((item) => item.id === publicKeyId); + const pubkey = (_b = didDoc.verificationMethod) === null || _b === void 0 ? void 0 : _b.find((item) => item.id === publicKeyId); if (!pubkey) { throw new Error('HID-SSI-SDK:: Error: could not find verification method for verificationMethodId: ' + verificationMethodId + ' in did document'); } - const { publicKeyMultibase: publicKeyMultibase1 } = utils_1.default.convertedStableLibKeysIntoEd25519verificationkey2020({ - publicKey: pubkey.publicKeyMultibase, - }); + const publicKeyMultibase1 = pubkey.publicKeyMultibase; const keyPair = yield ed25519_verification_key_2020_1.Ed25519VerificationKey2020.from({ id: publicKeyId, publicKeyMultibase: publicKeyMultibase1, @@ -673,20 +798,40 @@ class HypersignDID { key: keyPair, }); suite.date = new Date(new Date().getTime() - 100000).toISOString(); - const controller = { - '@context': constant.DID.CONTROLLER_CONTEXT, - id: publicKeyId, - authentication: didDoc.authentication, - }; - const purpose = new AuthenticationProofPurpose({ - controller, - challenge, - domain, - }); + let controller; + let purpose; + if (didAuthType === 'authentication') { + if (!challenge) { + throw new Error('HID-SSI-SDK:: Error: params.challenge is required to verify a did'); + } + controller = { + '@context': constant.DID.CONTROLLER_CONTEXT, + id: publicKeyId, + authentication: didDoc.authentication, + }; + purpose = new AuthenticationProofPurpose({ + controller, + challenge, + domain, + }); + } + else if (didAuthType === 'assertionMethod') { + controller = { + '@context': constant.DID.CONTROLLER_CONTEXT, + id: publicKeyId, + assertionMethod: didDoc.assertionMethod, + }; + purpose = new AssertionProofPurpose({ + controller, + }); + } + else { + throw new Error(`HID-SSI-SDK:: Error: unsupported purpose ${params.purpose}`); + } const result = yield jsonld_signatures_1.default.verify(didDoc, { suite, purpose: purpose, - documentLoader: v1_1.default, + documentLoader, compactProof: constant.compactProof, }); return result; @@ -727,7 +872,7 @@ class HypersignDID { let didDoc; let verificationRelationships = []; if (params.verificationRelationships && params.verificationRelationships.length > 0) { - if (params.verificationRelationships.includes(IDID_1.IVerificationRelationships.keyAgreement)) { + if (params.verificationRelationships.includes(enums_1.VerificationMethodRelationships.keyAgreement)) { throw new Error('HID-SSI-SDK:: Error: keyAgreement is not allowed in verificationRelationships'); } verificationRelationships = this._filterVerificationRelationships(params.verificationRelationships); @@ -739,25 +884,25 @@ class HypersignDID { case IDID_1.IClientSpec['eth-personalSign']: { const blockChainAccountId = this._getBlockChainAccountID(params.chainId, params.address); const didId = this._getId(params.methodSpecificId); - const newDid = new DIDDocument('', blockChainAccountId, didId, IDID_1.IKeyType.EcdsaSecp256k1RecoveryMethod2020, verificationRelationships); - didDoc = utils_1.default.jsonToLdConvertor(Object.assign({}, newDid)); + const newDid = new DIDDocument('', blockChainAccountId, didId, enums_1.VerificationMethodTypes.EcdsaSecp256k1RecoveryMethod2020, verificationRelationships); + didDoc = Object.assign({}, newDid); delete didDoc.service; break; } case IDID_1.IClientSpec['cosmos-ADR036']: { if (!params.publicKey) { throw new Error('HID-SSI-SDK:: Error: params.publicKey is required to create didoc for ' + - IDID_1.IKeyType.EcdsaSecp256k1VerificationKey2019); + enums_1.VerificationMethodTypes.EcdsaSecp256k1VerificationKey2019); } if (!this._isValidMultibaseBase58String(params.publicKey)) { throw new Error('HID-SSI-SDK:: Error: params.publicKey mustbe multibase encoded base58 string for ' + - IDID_1.IKeyType.EcdsaSecp256k1VerificationKey2019); + enums_1.VerificationMethodTypes.EcdsaSecp256k1VerificationKey2019); } const multibasePublicKey = params.publicKey; const didId = this._getId(params.methodSpecificId); const blockChainAccountId = 'cosmos:' + params.chainId + ':' + params.address; - const newDid = new DIDDocument(multibasePublicKey, blockChainAccountId, didId, IDID_1.IKeyType.EcdsaSecp256k1VerificationKey2019); - didDoc = utils_1.default.jsonToLdConvertor(Object.assign({}, newDid)); + const newDid = new DIDDocument(multibasePublicKey, blockChainAccountId, didId, enums_1.VerificationMethodTypes.EcdsaSecp256k1VerificationKey2019, verificationRelationships); + didDoc = Object.assign({}, newDid); break; } default: { @@ -767,6 +912,12 @@ class HypersignDID { return didDoc; }); } + // public generateKeyPairBabyJubJub() { + // return; + // } + // public async createDIDbyBabyJubJub() { + // return; + // } // using in API /** * Register did on chain generated using wallet @@ -776,7 +927,6 @@ class HypersignDID { * @returns {Promise<{didDocument: Did,transactionHash: string }>} */ registerByClientSpec(params) { - var _a, _b, _c, _d; return __awaiter(this, void 0, void 0, function* () { const response = {}; if (!params.didDocument || Object.keys(params.didDocument).length === 0) { @@ -798,28 +948,55 @@ class HypersignDID { throw new Error('HID-SSI-SDK:: Error: params.signInfos must be a non empty array'); } for (const i in params.signInfos) { - if (!params.signInfos[i].verification_method_id) { + if (!params.signInfos[i]['verification_method_id']) { throw new Error(`HID-SSI-SDK:: Error: params.signInfos[${i}].verification_method_id is required to register a did`); } - const clientSpec = params.signInfos[i].clientSpec; + const clientSpec = params.signInfos[i]['clientSpec']; if (clientSpec && clientSpec.type && !(clientSpec.type in IDID_1.IClientSpec)) { throw new Error(`HID-SSI-SDK:: Error: params.signInfos[${0}].clientSpec is invalid`); } - if (((_a = params.signInfos[i].clientSpec) === null || _a === void 0 ? void 0 : _a.type) === IDID_1.IClientSpec['cosmos-ADR036']) { - if (((_b = params.signInfos[i].clientSpec) === null || _b === void 0 ? void 0 : _b.adr036SignerAddress) === '' || - ((_c = params.signInfos[i].clientSpec) === null || _c === void 0 ? void 0 : _c.adr036SignerAddress) === undefined) { - throw new Error(`HID-SSI-SDK:: Error: params.signInfos[${i}].adr036SignerAddress is required to register a did, when clientSpec type is${(_d = params.signInfos[i].clientSpec) === null || _d === void 0 ? void 0 : _d.type} `); + if (clientSpec === undefined) { + if (!params.signInfos[i].type) { + throw new Error(`HID-SSI-SDK:: Error: params.signInfos[${i}].type is required to register a did if clientSpec is not passed or undefined`); } } - if (!params.signInfos[i].signature) { + if (!params.signInfos[i]['signature']) { throw new Error(`HID-SSI-SDK:: Error: params.signInfos[${i}].signature is required to register a did`); } } - const didDocStringJson = utils_1.default.ldToJsonConvertor(params.didDocument); - const didDoc = didDocStringJson; + const didDoc = params.didDocument; const { signInfos } = params; if (this.didrpc) { - const result = yield this.didrpc.registerDID(didDoc, signInfos); + const proofs = []; + signInfos.forEach((sign) => { + var _a, _b; + let type; + let clientSpec; + if (((_a = sign.clientSpec) === null || _a === void 0 ? void 0 : _a.type) === IDID_1.IClientSpec['eth-personalSign']) { + type = constant['DID_EcdsaSecp256k1RecoveryMethod2020'].SIGNATURE_TYPE; + clientSpec = client_spec_1.ClientSpecType.CLIENT_SPEC_TYPE_ETH_PERSONAL_SIGN; + } + else if (((_b = sign['clientSpec']) === null || _b === void 0 ? void 0 : _b.type) === IDID_1.IClientSpec['cosmos-ADR036']) { + type = constant['DID_EcdsaSecp256k1VerificationKey2019'].SIGNATURE_TYPE; + clientSpec = client_spec_1.ClientSpecType.CLIENT_SPEC_TYPE_COSMOS_ADR036; + } + else if (sign['clientSpec'] === undefined) { + type = sign.type; + } + else { + throw new Error('Invalid clientSpec type'); + } + const proof = { + type, + created: sign['created'], + verificationMethod: sign['verification_method_id'], + proofPurpose: enums_1.VerificationMethodRelationships.assertionMethod, + proofValue: sign['signature'], + clientSpecType: clientSpec, + }; + proofs.push(proof); + }); + const result = yield this.didrpc.registerDID(didDoc, proofs); response.didDocument = didDoc; response.transactionHash = result.transactionHash; } @@ -845,7 +1022,6 @@ class HypersignDID { * @returns {Promise<{ transactionHash: string }>} Result of the update operation */ updateByClientSpec(params) { - var _a, _b, _c, _d; return __awaiter(this, void 0, void 0, function* () { const response = {}; if (!this.didrpc && !this.didAPIService) { @@ -861,20 +1037,14 @@ class HypersignDID { throw new Error('HID-SSI-SDK:: Error: params.signInfos must be a non empty array'); } for (const i in params.signInfos) { - if (!params.signInfos[i].verification_method_id) { + if (!params.signInfos[i]['verification_method_id']) { throw new Error(`HID-SSI-SDK:: Error: params.signInfos[${i}].verification_method_id is required to register a did`); } - const clientSpec = params.signInfos[i].clientSpec; + const clientSpec = params.signInfos[i]['clientSpec']; if (clientSpec && clientSpec.type && !(clientSpec.type in IDID_1.IClientSpec)) { throw new Error(`HID-SSI-SDK:: Error: params.signInfos[${0}].clientSpec is invalid`); } - if (((_a = params.signInfos[i].clientSpec) === null || _a === void 0 ? void 0 : _a.type) === IDID_1.IClientSpec['cosmos-ADR036']) { - if (((_b = params.signInfos[i].clientSpec) === null || _b === void 0 ? void 0 : _b.adr036SignerAddress) === '' || - ((_c = params.signInfos[i].clientSpec) === null || _c === void 0 ? void 0 : _c.adr036SignerAddress) === undefined) { - throw new Error(`HID-SSI-SDK:: Error: params.signInfos[${i}].adr036SignerAddress is required to register a did, when clientSpec type is${(_d = params.signInfos[i].clientSpec) === null || _d === void 0 ? void 0 : _d.type} `); - } - } - if (!params.signInfos[i].signature) { + if (!params.signInfos[i]['signature']) { throw new Error(`HID-SSI-SDK:: Error: params.signInfos[${i}].signature is required to register a did`); } } @@ -883,7 +1053,33 @@ class HypersignDID { } const { didDocument, signInfos, versionId } = params; if (this.didrpc) { - const result = yield this.didrpc.updateDID(didDocument, signInfos, versionId); + const proofs = []; + signInfos.forEach((sign) => { + var _a, _b; + let type; + let clientSpec; + if (((_a = sign['clientSpec']) === null || _a === void 0 ? void 0 : _a.type) === IDID_1.IClientSpec['eth-personalSign']) { + type = constant['DID_EcdsaSecp256k1RecoveryMethod2020'].SIGNATURE_TYPE; + clientSpec = client_spec_1.ClientSpecType.CLIENT_SPEC_TYPE_ETH_PERSONAL_SIGN; + } + else if (((_b = sign['clientSpec']) === null || _b === void 0 ? void 0 : _b.type) === IDID_1.IClientSpec['cosmos-ADR036']) { + type = constant['DID_EcdsaSecp256k1VerificationKey2019'].SIGNATURE_TYPE; + clientSpec = client_spec_1.ClientSpecType.CLIENT_SPEC_TYPE_COSMOS_ADR036; + } + else { + throw new Error('Invalid clientSpec type'); + } + const proof = { + type, + created: sign['created'], + verificationMethod: sign['verification_method_id'], + proofPurpose: enums_1.VerificationMethodRelationships.assertionMethod, + proofValue: sign['signature'], + clientSpecType: clientSpec, + }; + proofs.push(proof); + }); + const result = yield this.didrpc.updateDID(didDocument, proofs, versionId); response.transactionHash = result.transactionHash; } else if (this.didAPIService) { @@ -908,7 +1104,6 @@ class HypersignDID { * @returns {Promise<{ transactionHash: string }>} Result of the update operation */ deactivateByClientSpec(params) { - var _a, _b, _c, _d; return __awaiter(this, void 0, void 0, function* () { const response = {}; if (!this.didrpc && !this.didAPIService) { @@ -924,20 +1119,14 @@ class HypersignDID { throw new Error('HID-SSI-SDK:: Error: params.signInfos must be a non empty array'); } for (const i in params.signInfos) { - if (!params.signInfos[i].verification_method_id) { + if (!params.signInfos[i]['verification_method_id']) { throw new Error(`HID-SSI-SDK:: Error: params.signInfos[${i}].verification_method_id is required to deactivate a did`); } - const clientSpec = params.signInfos[i].clientSpec; + const clientSpec = params.signInfos[i]['clientSpec']; if (clientSpec && clientSpec.type && !(clientSpec.type in IDID_1.IClientSpec)) { throw new Error(`HID-SSI-SDK:: Error: params.signInfos[${0}].clientSpec is invalid`); } - if (((_a = params.signInfos[i].clientSpec) === null || _a === void 0 ? void 0 : _a.type) === IDID_1.IClientSpec['cosmos-ADR036']) { - if (((_b = params.signInfos[i].clientSpec) === null || _b === void 0 ? void 0 : _b.adr036SignerAddress) === '' || - ((_c = params.signInfos[i].clientSpec) === null || _c === void 0 ? void 0 : _c.adr036SignerAddress) === undefined) { - throw new Error(`HID-SSI-SDK:: Error: params.signInfos[${i}].adr036SignerAddress is required to deactivate a did, when clientSpec type is${(_d = params.signInfos[i].clientSpec) === null || _d === void 0 ? void 0 : _d.type} `); - } - } - if (!params.signInfos[i].signature) { + if (!params.signInfos[i]['signature']) { throw new Error(`HID-SSI-SDK:: Error: params.signInfos[${i}].signature is required to deactivate a did`); } } @@ -947,7 +1136,33 @@ class HypersignDID { const { didDocument, signInfos, versionId } = params; const didDoc = didDocument; if (this.didrpc) { - const result = yield this.didrpc.deactivateDID(didDoc.id, signInfos, versionId); + const proofs = []; + signInfos.forEach((sign) => { + var _a, _b; + let type; + let clientSpec; + if (((_a = sign['clientSpec']) === null || _a === void 0 ? void 0 : _a.type) === IDID_1.IClientSpec['eth-personalSign']) { + type = constant['DID_EcdsaSecp256k1RecoveryMethod2020'].SIGNATURE_TYPE; + clientSpec = client_spec_1.ClientSpecType.CLIENT_SPEC_TYPE_ETH_PERSONAL_SIGN; + } + else if (((_b = sign['clientSpec']) === null || _b === void 0 ? void 0 : _b.type) === IDID_1.IClientSpec['cosmos-ADR036']) { + type = constant['DID_EcdsaSecp256k1VerificationKey2019'].SIGNATURE_TYPE; + clientSpec = client_spec_1.ClientSpecType.CLIENT_SPEC_TYPE_COSMOS_ADR036; + } + else { + throw new Error('Invalid clientSpec type'); + } + const proof = { + type, + created: sign['created'], + verificationMethod: sign['verification_method_id'], + proofPurpose: enums_1.VerificationMethodRelationships.assertionMethod, + proofValue: sign['signature'], + clientSpecType: clientSpec, + }; + proofs.push(proof); + }); + const result = yield this.didrpc.deactivateDID(didDoc.id, proofs, versionId); response.transactionHash = result.transactionHash; } else if (this.didAPIService) { @@ -996,27 +1211,29 @@ class HypersignDID { if (!params.address) { throw new Error('HID-SSI-SDK:: Error: params.address is required to sign a did'); } - const { didDocument, signature } = yield this.signByClientSpec({ + const signedDidDoc = yield this.signByClientSpec({ didDocument: params.didDocument, clientSpec: params.clientSpec, address: params.address, web3: params.web3, chainId: params.chainId, + verificationMethodId: params.verificationMethodId, }); const signInfos = [ { - signature, + signature: signedDidDoc.proof.proofValue, verification_method_id: params.verificationMethodId, + created: signedDidDoc.proof.created, clientSpec: { - type: params.clientSpec, - adr036SignerAddress: params.clientSpec === IDID_1.IClientSpec['cosmos-ADR036'] ? params.address : '', + type: params.clientSpec === IDID_1.IClientSpec['cosmos-ADR036'] + ? IDID_1.IClientSpec['cosmos-ADR036'] + : IDID_1.IClientSpec['eth-personalSign'], }, }, ]; return yield this.registerByClientSpec({ - didDocument, + didDocument: params.didDocument, signInfos, - // only for [cosmos-ADR036] }); }); } @@ -1028,9 +1245,11 @@ class HypersignDID { * - params.address : Checksum address from web3 wallet * - params.web3 : web3 object * - params.chainId : Optional, chainId - * @returns {Promise<{ didDocument: Did; signature: string }>} + * - params.verificationMethodId : verificationMEthodId for generating signature + * @returns {Promise} */ signByClientSpec(params) { + var _a; return __awaiter(this, void 0, void 0, function* () { if (this['window'] === 'undefined') { throw new Error('HID-SSI-SDK:: Error: Running in non browser mode'); @@ -1038,6 +1257,9 @@ class HypersignDID { if (!params.didDocument) { throw Error('HID-SSI-SDK:: Error: params.didDocument is required to sign'); } + if (params.didDocument['proof']) { + throw new Error('HID-SSI-SDK:: Error: params.didDocument should not contain proof in it'); + } if (!params.address) { throw new Error('HID-SSI-SDK:: Error: params.address is required to sign a did'); } @@ -1050,34 +1272,77 @@ class HypersignDID { if (!params.web3) { throw new Error('HID-SSI-SDK:: Error: params.web3 is required to sign'); } + if (!params.verificationMethodId) { + throw new Error('HID-SSI-SDK:: Error: params.verificationMethodId is required to sign'); + } + const vmId = (_a = params.didDocument.verificationMethod) === null || _a === void 0 ? void 0 : _a.find((x) => x.id == params.verificationMethodId); + if (!vmId || vmId == undefined) { + throw new Error(`HID-SSI_SDK:: Error: invalid verificationMethodId`); + } + const didDoc = utils_1.default.removeEmptyString(params.didDocument); switch (params.clientSpec) { case IDID_1.IClientSpec['eth-personalSign']: { - const didDocStringJson = utils_1.default.ldToJsonConvertor(params.didDocument); - const didDoc = didDocStringJson; - const signature = yield params.web3.eth.personal.sign(JSON.stringify(didDoc, (key, value) => { + // normalize didDoc with JSON LD + const normalizedDidDoc = yield this._jsonLdNormalize({ doc: didDoc }); + const normalizedDidDocHash = new Uint8Array(Buffer.from(crypto_1.default.createHash('sha256').update(normalizedDidDoc).digest('hex'), 'hex')); + // construct proof + const proof = { + '@context': didDoc['@context'], + type: enums_1.ProofTypes.EcdsaSecp256k1RecoverySignature2020, + created: this._getDateTime(), + verificationMethod: params.verificationMethodId, + proofPurpose: enums_1.VerificationMethodRelationships.assertionMethod, + }; + // normalize proof with JSON LD + const normalizedProof = yield this._jsonLdNormalize({ doc: proof }); + delete proof['@context']; + const normalizedProofHash = new Uint8Array(Buffer.from(crypto_1.default.createHash('sha256').update(normalizedProof).digest('hex'), 'hex')); + const combinedHash = yield this._concat(normalizedProofHash, normalizedDidDocHash); + const didDocJsonDigest = { + didId: didDoc.id, + didDocDigest: Buffer.from(combinedHash).toString('hex'), + }; + const signature = yield params.web3.eth.personal.sign(JSON.stringify(didDocJsonDigest, (key, value) => { if (value === '' || (Array.isArray(value) && value.length === 0)) { return undefined; } return value; }), params.address); - return { didDocument: didDoc, signature }; + proof['proofValue'] = signature; + proof['clientSpecType'] = client_spec_1.ClientSpecType.CLIENT_SPEC_TYPE_ETH_PERSONAL_SIGN; + didDoc['proof'] = proof; + return didDoc; } case IDID_1.IClientSpec['cosmos-ADR036']: { if (!params.chainId) { throw new Error('HID-SSI-SDK:: Error: params.chainId is required to sign for clientSpec ' + IDID_1.IClientSpec['cosmos-ADR036'] + ' and keyType ' + - IDID_1.IKeyType.EcdsaSecp256k1VerificationKey2019); + enums_1.VerificationMethodTypes.EcdsaSecp256k1VerificationKey2019); } - const didDocStringJson = utils_1.default.ldToJsonConvertor(params.didDocument); - const didDoc = didDocStringJson; - const didDocBytes = (yield did_1.Did.encode(didDoc)).finish(); + const normalizedDidDoc = yield this._jsonLdNormalize({ doc: didDoc }); + const normalizedDidDochash = new Uint8Array(Buffer.from(crypto_1.default.createHash('sha256').update(normalizedDidDoc).digest('hex'), 'hex')); + // construct proof + const proof = { + '@context': didDoc['@context'], + type: enums_1.ProofTypes.EcdsaSecp256k1Signature2019, + created: this._getDateTime(), + verificationMethod: params.verificationMethodId, + proofPurpose: enums_1.VerificationMethodRelationships.assertionMethod, + }; + const normalizedProof = yield this._jsonLdNormalize({ doc: proof }); + delete proof['@context']; + const normalizedProofHash = new Uint8Array(Buffer.from(crypto_1.default.createHash('sha256').update(normalizedProof).digest('hex'), 'hex')); + const combinedHash = yield this._concat(normalizedProofHash, normalizedDidDochash); const signRespObj = yield params.web3.requestMethod('signArbitrary', [ params.chainId, params.address, - didDocBytes, + combinedHash, ]); - return { didDocument: didDoc, signature: signRespObj['signature'] }; + proof['proofValue'] = signRespObj['signature']; + proof['clientSpecType'] = client_spec_1.ClientSpecType.CLIENT_SPEC_TYPE_COSMOS_ADR036; + didDoc['proof'] = proof; + return didDoc; } default: throw Error('HID-SSI-SDK:: Error: Invalid clientSpec'); @@ -1108,7 +1373,7 @@ class HypersignDID { throw new Error('HID-SSI-SDK:: Error: params.type is required to addVerificationMethod'); } const { type } = params; - if (!(type in IDID_1.IKeyType)) { + if (!(type in enums_1.VerificationMethodTypes)) { throw new Error('HID-SSI-SDK:: Error: params.type is invalid'); } try { @@ -1134,29 +1399,28 @@ class HypersignDID { catch (e) { throw new Error(`HID-SSI-SDK:: Error: could not resolve did ${params.did}`); } - if (type === IDID_1.IKeyType.EcdsaSecp256k1RecoveryMethod2020 && + if (type === enums_1.VerificationMethodTypes.EcdsaSecp256k1RecoveryMethod2020 && (!params.blockchainAccountId || params.blockchainAccountId.trim() === '')) { throw new Error(`HID-SSI-SDK:: Error: params.blockchainAccountId is required for keyType ${params.type}`); } - if (type === IDID_1.IKeyType.EcdsaSecp256k1RecoveryMethod2020 && (!params.id || params.id.trim() === '')) { + if (type === enums_1.VerificationMethodTypes.EcdsaSecp256k1RecoveryMethod2020 && (!params.id || params.id.trim() === '')) { throw new Error(`HID-SSI-SDK:: Error: params.id is required for keyType ${params.type}`); } - if (type === IDID_1.IKeyType.EcdsaSecp256k1VerificationKey2019 && + if (type === enums_1.VerificationMethodTypes.EcdsaSecp256k1VerificationKey2019 && (!params.blockchainAccountId || params.blockchainAccountId.trim() === '' || !params.publicKeyMultibase || params.publicKeyMultibase.trim() === '')) { throw new Error(`HID-SSI-SDK:: Error: params.blockchainAccountId and params.publicKeyMultibase is required for keyType ${params.type}`); } - if ((type === IDID_1.IKeyType.Ed25519VerificationKey2020 || - type === IDID_1.IKeyType.X25519KeyAgreementKey2020 || - type === IDID_1.IKeyType.X25519KeyAgreementKeyEIP5630) && + if ((type === enums_1.VerificationMethodTypes.Ed25519VerificationKey2020 || + type === enums_1.VerificationMethodTypes.X25519KeyAgreementKey2020 || + type === enums_1.VerificationMethodTypes.X25519KeyAgreementKeyEIP5630) && !params.publicKeyMultibase) { throw new Error('HID-SSI-SDK:: Error: params.publicKeyMultibase is required to addVerificationMethod'); } const verificationMethod = {}; - let { didDocument } = resolvedDidDoc; - didDocument = utils_1.default.ldToJsonConvertor(didDocument); + const { didDocument } = resolvedDidDoc; if (params.id) { const checkIfVmIdExists = didDocument.verificationMethod.some((vm) => vm.id === params.id); if (checkIfVmIdExists) { @@ -1167,21 +1431,18 @@ class HypersignDID { verificationMethod['id'] = (_a = params === null || params === void 0 ? void 0 : params.id) !== null && _a !== void 0 ? _a : `${didDocument.id}#key-${VMLength + 1}`; verificationMethod['type'] = type; verificationMethod['controller'] = didDocument.id; - if (type !== IDID_1.IKeyType.EcdsaSecp256k1RecoveryMethod2020) { - if (type === IDID_1.IKeyType.Ed25519VerificationKey2020) { - const { publicKeyMultibase: publicKeyMultibase1 } = utils_1.default.convertEd25519verificationkey2020toStableLibKeysInto({ - publicKey: params.publicKeyMultibase, - }); - verificationMethod['publicKeyMultibase'] = publicKeyMultibase1; - } - else { - verificationMethod['publicKeyMultibase'] = (_b = params === null || params === void 0 ? void 0 : params.publicKeyMultibase) !== null && _b !== void 0 ? _b : ''; - } + if (type !== enums_1.VerificationMethodTypes.EcdsaSecp256k1RecoveryMethod2020) { + verificationMethod['publicKeyMultibase'] = (_b = params === null || params === void 0 ? void 0 : params.publicKeyMultibase) !== null && _b !== void 0 ? _b : ''; + } + if (type !== enums_1.VerificationMethodTypes.Ed25519VerificationKey2020) { + verificationMethod['blockchainAccountId'] = (_c = params === null || params === void 0 ? void 0 : params.blockchainAccountId) !== null && _c !== void 0 ? _c : ''; + } + if (type == enums_1.VerificationMethodTypes.BabyJubJubKey2021) { + delete verificationMethod['blockchainAccountId']; } - verificationMethod['blockchainAccountId'] = (_c = params === null || params === void 0 ? void 0 : params.blockchainAccountId) !== null && _c !== void 0 ? _c : ''; didDocument.verificationMethod.push(verificationMethod); - if (verificationMethod['type'] === IDID_1.IKeyType.X25519KeyAgreementKey2020 || - verificationMethod['type'] === IDID_1.IKeyType.X25519KeyAgreementKeyEIP5630) { + if (verificationMethod['type'] === enums_1.VerificationMethodTypes.X25519KeyAgreementKey2020 || + verificationMethod['type'] === enums_1.VerificationMethodTypes.X25519KeyAgreementKeyEIP5630) { didDocument.keyAgreement.push(verificationMethod['id']); } else { @@ -1190,16 +1451,26 @@ class HypersignDID { didDocument.capabilityDelegation.push(verificationMethod['id']); didDocument.capabilityInvocation.push(verificationMethod['id']); } - if (verificationMethod['type'] === IDID_1.IKeyType.X25519KeyAgreementKey2020) { - const newContext = constant['DID_' + IDID_1.IKeyType.Ed25519VerificationKey2020].DID_KEYAGREEMENT_CONTEXT; - if (!didDocument['context'].includes(newContext)) { - didDocument['context'].push(newContext); + if (verificationMethod['type'] === enums_1.VerificationMethodTypes.X25519KeyAgreementKey2020) { + const newContext = constant['DID_' + enums_1.VerificationMethodTypes.Ed25519VerificationKey2020].DID_KEYAGREEMENT_CONTEXT; + if (!didDocument['@context'].includes(newContext)) { + didDocument['@context'].push(newContext); + } + } + if (verificationMethod['type'] === enums_1.VerificationMethodTypes.X25519KeyAgreementKeyEIP5630) { + const newContext = constant['DID_' + enums_1.VerificationMethodTypes.EcdsaSecp256k1RecoveryMethod2020].DID_KEYAGREEMENT_CONTEXT; + if (!didDocument['@context'].includes(newContext)) { + didDocument['@context'].push(newContext); } } - if (verificationMethod['type'] === IDID_1.IKeyType.X25519KeyAgreementKeyEIP5630) { - const newContext = constant['DID_' + IDID_1.IKeyType.EcdsaSecp256k1RecoveryMethod2020].DID_KEYAGREEMENT_CONTEXT; - if (!didDocument['context'].includes(newContext)) { - didDocument['context'].push(newContext); + if (verificationMethod['type'] === enums_1.VerificationMethodTypes.BabyJubJubKey2021) { + const newContext = constant['DID_' + enums_1.VerificationMethodTypes.BabyJubJubKey2021].DID_BABYJUBJUBKEY2021; + if (!didDocument['@context'].includes(newContext)) { + didDocument['@context'].push(newContext); + } + const newContext1 = constant['DID_' + enums_1.VerificationMethodTypes.BabyJubJubKey2021].BABYJUBJUBSIGNATURE; + if (!didDocument['@context'].includes(newContext1)) { + didDocument['@context'].push(newContext1); } } return didDocument; diff --git a/build/src/did/didRPC.d.ts b/build/src/did/didRPC.d.ts index 1a411c4..002d0b8 100644 --- a/build/src/did/didRPC.d.ts +++ b/build/src/did/didRPC.d.ts @@ -3,17 +3,20 @@ * All rights reserved. * Author: Hypermine Core Team */ -import { Did as IDidProto, SignInfo } from '../../libs/generated/ssi/did'; +import { DidDocument as IDidProto } from '../../libs/generated/ssi/did'; +import { DocumentProof as SignInfo } from '../../libs/generated/ssi/proof'; import { IDIDResolve, IDIDRpc, DeliverTxResponse } from './IDID'; import { OfflineSigner } from '@cosmjs/proto-signing'; export declare class DIDRpc implements IDIDRpc { private didRestEp; private hidClient; + private nodeRestEp; constructor({ offlineSigner, nodeRpcEndpoint, nodeRestEndpoint, }: { offlineSigner?: OfflineSigner; nodeRpcEndpoint: string; nodeRestEndpoint: string; }); + private getSigningStargateClient; init(): Promise; registerDID(didDoc: IDidProto, signInfos: SignInfo[]): Promise; updateDID(didDoc: IDidProto, signInfos: SignInfo[], versionId: string): Promise; diff --git a/build/src/did/didRPC.d.ts.map b/build/src/did/didRPC.d.ts.map index 4c9ca85..26ad031 100644 --- a/build/src/did/didRPC.d.ts.map +++ b/build/src/did/didRPC.d.ts.map @@ -1 +1 @@ -{"version":3,"file":"didRPC.d.ts","sourceRoot":"","sources":["../../../src/did/didRPC.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH,OAAO,EAAE,GAAG,IAAI,SAAS,EAAE,QAAQ,EAAE,MAAM,8BAA8B,CAAC;AAK1E,OAAO,EAAe,WAAW,EAAE,OAAO,EAAY,iBAAiB,EAAE,MAAM,QAAQ,CAAC;AACxF,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAEtD,qBAAa,MAAO,YAAW,OAAO;IACpC,OAAO,CAAC,SAAS,CAAS;IAC1B,OAAO,CAAC,SAAS,CAAmB;gBACxB,EACV,aAAa,EACb,eAAe,EACf,gBAAgB,GACjB,EAAE;QACD,aAAa,CAAC,EAAE,aAAa,CAAC;QAC9B,eAAe,EAAE,MAAM,CAAC;QACxB,gBAAgB,EAAE,MAAM,CAAC;KAC1B;IAUK,IAAI;IAOJ,WAAW,CAAC,MAAM,EAAE,SAAS,EAAE,SAAS,EAAE,QAAQ,EAAE,GAAG,OAAO,CAAC,iBAAiB,CAAC;IAqBjF,SAAS,CAAC,MAAM,EAAE,SAAS,EAAE,SAAS,EAAE,QAAQ,EAAE,EAAE,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,iBAAiB,CAAC;IAyBlG,aAAa,CAAC,GAAG,EAAE,MAAM,EAAE,SAAS,EAAE,QAAQ,EAAE,EAAE,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,iBAAiB,CAAC;IAwBhG,UAAU,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,CAAC;CAYpD"} \ No newline at end of file +{"version":3,"file":"didRPC.d.ts","sourceRoot":"","sources":["../../../src/did/didRPC.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH,OAAO,EAAE,WAAW,IAAI,SAAS,EAAE,MAAM,8BAA8B,CAAC;AACxE,OAAO,EAAE,aAAa,IAAI,QAAQ,EAAE,MAAM,gCAAgC,CAAC;AAK3E,OAAO,EAAE,WAAW,EAAE,OAAO,EAAE,iBAAiB,EAAE,MAAM,QAAQ,CAAC;AACjE,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAGtD,qBAAa,MAAO,YAAW,OAAO;IACpC,OAAO,CAAC,SAAS,CAAS;IAC1B,OAAO,CAAC,SAAS,CAAmB;IACpC,OAAO,CAAC,UAAU,CAAS;gBACf,EACV,aAAa,EACb,eAAe,EACf,gBAAgB,GACjB,EAAE;QACD,aAAa,CAAC,EAAE,aAAa,CAAC;QAC9B,eAAe,EAAE,MAAM,CAAC;QACxB,gBAAgB,EAAE,MAAM,CAAC;KAC1B;IAWD,OAAO,CAAC,wBAAwB;IAQ1B,IAAI;IAOJ,WAAW,CAAC,MAAM,EAAE,SAAS,EAAE,SAAS,EAAE,QAAQ,EAAE,GAAG,OAAO,CAAC,iBAAiB,CAAC;IAmCjF,SAAS,CAAC,MAAM,EAAE,SAAS,EAAE,SAAS,EAAE,QAAQ,EAAE,EAAE,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,iBAAiB,CAAC;IAoClG,aAAa,CAAC,GAAG,EAAE,MAAM,EAAE,SAAS,EAAE,QAAQ,EAAE,EAAE,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,iBAAiB,CAAC;IAmChG,UAAU,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,CAAC;CAWpD"} \ No newline at end of file diff --git a/build/src/did/didRPC.js b/build/src/did/didRPC.js index 239be33..ff22c92 100644 --- a/build/src/did/didRPC.js +++ b/build/src/did/didRPC.js @@ -45,6 +45,8 @@ const constants_1 = require("../constants"); const generatedProto = __importStar(require("../../libs/generated/ssi/tx")); const axios_1 = __importDefault(require("axios")); const client_1 = require("../hid/client"); +const utils_1 = __importDefault(require("../utils")); +const constants = __importStar(require("../constants")); class DIDRpc { constructor({ offlineSigner, nodeRpcEndpoint, nodeRestEndpoint, }) { if (offlineSigner) { @@ -53,9 +55,17 @@ class DIDRpc { else { this.hidClient = null; } + this.nodeRestEp = nodeRestEndpoint; this.didRestEp = (client_1.HIDClient.hidNodeRestEndpoint ? client_1.HIDClient.hidNodeRestEndpoint : nodeRestEndpoint) + constants_1.HYPERSIGN_NETWORK_DID_PATH; } + getSigningStargateClient() { + const client = client_1.HIDClient.getHidClient(); + if (!client) { + throw new Error('HID-SSI-SDK:: Error: DIDRpc class is not initialise with offlinesigner'); + } + return client; + } init() { return __awaiter(this, void 0, void 0, function* () { if (!this.hidClient) { @@ -69,23 +79,37 @@ class DIDRpc { if (!this.hidClient) { throw new Error('HID-SSI-SDK:: Error: DIDRpc class is not initialise with offlinesigner'); } - const typeUrl = `${constants_1.HID_COSMOS_MODULE}.${constants_1.HIDRpcEnums.MsgCreateDID}`; + delete didDoc['proof']; + const typeUrl = `${constants_1.HID_COSMOS_MODULE}.${constants_1.HIDRpcEnums.MsgRegisterDID}`; const txMessage = { typeUrl, - value: generatedProto[constants_1.HIDRpcEnums.MsgCreateDID].fromPartial({ - didDocString: didDoc, - signatures: signInfos, - creator: client_1.HIDClient.getHidWalletAddress(), + value: generatedProto[constants_1.HIDRpcEnums.MsgRegisterDID].fromPartial({ + didDocument: didDoc, + didDocumentProofs: signInfos, + txAuthor: client_1.HIDClient.getHidWalletAddress(), }), }; - const fee = 'auto'; + const amount = yield utils_1.default.fetchFee(constants.GAS_FEE_METHODS.Register_Did, this.nodeRestEp); + const fee = { + amount: [ + { + denom: 'uhid', + amount, + }, + ], + gas: '200000', + }; const hidClient = client_1.HIDClient.getHidClient(); const txResult = yield hidClient.signAndBroadcast(client_1.HIDClient.getHidWalletAddress(), [txMessage], fee); + if (txResult.code !== 0) { + throw new Error(`${txResult.rawLog}`); + } return txResult; }); } updateDID(didDoc, signInfos, versionId) { return __awaiter(this, void 0, void 0, function* () { + delete didDoc['proof']; if (!this.hidClient) { throw new Error('HID-SSI-SDK:: Error: DIDRpc class is not initialise with offlinesigner'); } @@ -93,16 +117,27 @@ class DIDRpc { const txMessage = { typeUrl, value: generatedProto[constants_1.HIDRpcEnums.MsgUpdateDID].fromPartial({ - didDocString: didDoc, - signatures: signInfos, - creator: client_1.HIDClient.getHidWalletAddress(), - version_id: versionId, + didDocument: didDoc, + didDocumentProofs: signInfos, + txAuthor: client_1.HIDClient.getHidWalletAddress(), + versionId: versionId, }), }; - // TODO: need to find a way to make it dynamic - const fee = 'auto'; - const hidClient = client_1.HIDClient.getHidClient(); + const amount = yield utils_1.default.fetchFee(constants.GAS_FEE_METHODS.Update_Did, this.nodeRestEp); + const fee = { + amount: [ + { + denom: 'uhid', + amount, + }, + ], + gas: '200000', + }; + const hidClient = this.getSigningStargateClient(); const txResult = yield hidClient.signAndBroadcast(client_1.HIDClient.getHidWalletAddress(), [txMessage], fee); + if (txResult.code !== 0) { + throw new Error(`${txResult.rawLog}`); + } return txResult; }); } @@ -115,22 +150,32 @@ class DIDRpc { const txMessage = { typeUrl, value: generatedProto[constants_1.HIDRpcEnums.MsgDeactivateDID].fromPartial({ - didId: did, - signatures: signInfos, - creator: client_1.HIDClient.getHidWalletAddress(), - version_id: versionId, + didDocumentId: did, + didDocumentProofs: signInfos, + txAuthor: client_1.HIDClient.getHidWalletAddress(), + versionId: versionId, }), }; - // TODO: need to find a way to make it dynamic - const fee = 'auto'; + const amount = yield utils_1.default.fetchFee(constants.GAS_FEE_METHODS.Deactivate_Did, this.nodeRestEp); + const fee = { + amount: [ + { + denom: 'uhid', + amount, + }, + ], + gas: '200000', + }; const hidClient = client_1.HIDClient.getHidClient(); const txResult = yield hidClient.signAndBroadcast(client_1.HIDClient.getHidWalletAddress(), [txMessage], fee); + if (txResult.code !== 0) { + throw new Error(`${txResult.rawLog}`); + } return txResult; }); } resolveDID(did) { return __awaiter(this, void 0, void 0, function* () { - did = did + ':'; // TODO: we need to sort this out ... need to remove later const get_didUrl = `${this.didRestEp}/${did}`; let response; try { diff --git a/build/src/index.d.ts b/build/src/index.d.ts index 6252391..6a632fd 100644 --- a/build/src/index.d.ts +++ b/build/src/index.d.ts @@ -3,11 +3,14 @@ import HypersignVerifiableCredential from './credential/vc'; import HypersignVerifiablePresentation from './presentation/vp'; import HypersignSchema from './schema/schema'; import { OfflineSigner } from '@cosmjs/proto-signing'; -import { IClientSpec, IKeyType, ISignInfo, IVerificationRelationships } from './did/IDID'; -import { Did } from '../libs/generated/ssi/did'; +import { IClientSpec, ISignInfo, SupportedPurpose } from './did/IDID'; +import { VerificationMethodTypes as IKeyType } from '../libs/generated/ssi/client/enums'; +import { VerificationMethodRelationships as IVerificationRelationships } from '../libs/generated/ssi/client/enums'; +import { DidDocument as Did } from '../libs/generated/ssi/did'; import { IVerifiableCredential } from './credential/ICredential'; -import { Schema } from '../libs/generated/ssi/schema'; +import { CredentialSchemaDocument as Schema } from '../libs/generated/ssi/credential_schema'; import { IVerifiablePresentation } from './presentation/IPresentation'; +import HypersignBJJVerifiableCredential from './credential/bjjvc'; declare class HypersignSSISdk { did: HypersignDID; vc: HypersignVerifiableCredential; @@ -27,5 +30,5 @@ declare class HypersignSSISdk { }); init(): Promise; } -export { HypersignSSISdk, HypersignDID, HypersignSchema, HypersignVerifiableCredential, HypersignVerifiablePresentation, IVerificationRelationships, IKeyType, ISignInfo, IClientSpec, Did, IVerifiableCredential, IVerifiablePresentation, Schema, }; +export { HypersignSSISdk, HypersignDID, HypersignSchema, HypersignVerifiableCredential, HypersignVerifiablePresentation, IVerificationRelationships, HypersignBJJVerifiableCredential, IKeyType, ISignInfo, IClientSpec, Did, IVerifiableCredential, IVerifiablePresentation, Schema, SupportedPurpose, }; //# sourceMappingURL=index.d.ts.map \ No newline at end of file diff --git a/build/src/index.d.ts.map b/build/src/index.d.ts.map index e54219b..9f2f590 100644 --- a/build/src/index.d.ts.map +++ b/build/src/index.d.ts.map @@ -1 +1 @@ -{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,YAAY,MAAM,WAAW,CAAC;AACrC,OAAO,6BAA6B,MAAM,iBAAiB,CAAC;AAC5D,OAAO,+BAA+B,MAAM,mBAAmB,CAAC;AAChE,OAAO,eAAe,MAAM,iBAAiB,CAAC;AAC9C,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AACtD,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,SAAS,EAAE,0BAA0B,EAAE,MAAM,YAAY,CAAC;AAC1F,OAAO,EAAE,GAAG,EAAE,MAAM,2BAA2B,CAAC;AAChD,OAAO,EAAE,qBAAqB,EAAE,MAAM,0BAA0B,CAAC;AACjE,OAAO,EAAE,MAAM,EAAE,MAAM,8BAA8B,CAAC;AACtD,OAAO,EAAE,uBAAuB,EAAE,MAAM,8BAA8B,CAAC;AAEvE,cAAM,eAAe;IACnB,GAAG,EAAE,YAAY,CAAC;IAClB,EAAE,EAAE,6BAA6B,CAAC;IAClC,EAAE,EAAE,+BAA+B,CAAC;IACpC,MAAM,EAAE,eAAe,CAAC;IACxB,OAAO,CAAC,SAAS,CAAS;IAC1B,OAAO,CAAC,MAAM,CAAgB;IAC9B,OAAO,CAAC,eAAe,CAAS;IAChC,OAAO,CAAC,gBAAgB,CAAS;IACjC,OAAO,CAAC,kBAAkB,CAAS;gBACvB,MAAM,EAAE;QAClB,aAAa,EAAE,aAAa,CAAC;QAC7B,eAAe,CAAC,EAAE,MAAM,CAAC;QACzB,gBAAgB,CAAC,EAAE,MAAM,CAAC;QAC1B,SAAS,CAAC,EAAE,MAAM,CAAC;QACnB,kBAAkB,CAAC,EAAE,MAAM,CAAC;KAC7B;IAqBK,IAAI;CAKX;AAED,OAAO,EACL,eAAe,EACf,YAAY,EACZ,eAAe,EACf,6BAA6B,EAC7B,+BAA+B,EAC/B,0BAA0B,EAC1B,QAAQ,EACR,SAAS,EACT,WAAW,EACX,GAAG,EACH,qBAAqB,EACrB,uBAAuB,EACvB,MAAM,GACP,CAAC"} \ No newline at end of file +{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,YAAY,MAAM,WAAW,CAAC;AAErC,OAAO,6BAA6B,MAAM,iBAAiB,CAAC;AAC5D,OAAO,+BAA+B,MAAM,mBAAmB,CAAC;AAChE,OAAO,eAAe,MAAM,iBAAiB,CAAC;AAC9C,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AACtD,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AACtE,OAAO,EAAE,uBAAuB,IAAI,QAAQ,EAAE,MAAM,oCAAoC,CAAC;AACzF,OAAO,EAAE,+BAA+B,IAAI,0BAA0B,EAAE,MAAM,oCAAoC,CAAC;AACnH,OAAO,EAAE,WAAW,IAAI,GAAG,EAAE,MAAM,2BAA2B,CAAC;AAC/D,OAAO,EAAE,qBAAqB,EAAE,MAAM,0BAA0B,CAAC;AACjE,OAAO,EAAE,wBAAwB,IAAI,MAAM,EAAE,MAAM,yCAAyC,CAAC;AAC7F,OAAO,EAAE,uBAAuB,EAAE,MAAM,8BAA8B,CAAC;AACvE,OAAO,gCAAgC,MAAM,oBAAoB,CAAC;AAElE,cAAM,eAAe;IACnB,GAAG,EAAE,YAAY,CAAC;IAClB,EAAE,EAAE,6BAA6B,CAAC;IAClC,EAAE,EAAE,+BAA+B,CAAC;IACpC,MAAM,EAAE,eAAe,CAAC;IACxB,OAAO,CAAC,SAAS,CAAS;IAC1B,OAAO,CAAC,MAAM,CAAgB;IAC9B,OAAO,CAAC,eAAe,CAAS;IAChC,OAAO,CAAC,gBAAgB,CAAS;IACjC,OAAO,CAAC,kBAAkB,CAAS;gBACvB,MAAM,EAAE;QAClB,aAAa,EAAE,aAAa,CAAC;QAC7B,eAAe,CAAC,EAAE,MAAM,CAAC;QACzB,gBAAgB,CAAC,EAAE,MAAM,CAAC;QAC1B,SAAS,CAAC,EAAE,MAAM,CAAC;QACnB,kBAAkB,CAAC,EAAE,MAAM,CAAC;KAC7B;IAuBK,IAAI;CAQX;AAED,OAAO,EACL,eAAe,EACf,YAAY,EACZ,eAAe,EACf,6BAA6B,EAC7B,+BAA+B,EAC/B,0BAA0B,EAC1B,gCAAgC,EAChC,QAAQ,EACR,SAAS,EACT,WAAW,EACX,GAAG,EACH,qBAAqB,EACrB,uBAAuB,EACvB,MAAM,EACN,gBAAgB,GACjB,CAAC"} \ No newline at end of file diff --git a/build/src/index.js b/build/src/index.js index 95a2ebb..cfb2fda 100644 --- a/build/src/index.js +++ b/build/src/index.js @@ -12,9 +12,10 @@ var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); -exports.Schema = exports.Did = exports.IClientSpec = exports.IKeyType = exports.IVerificationRelationships = exports.HypersignVerifiablePresentation = exports.HypersignVerifiableCredential = exports.HypersignSchema = exports.HypersignDID = exports.HypersignSSISdk = void 0; +exports.SupportedPurpose = exports.Schema = exports.Did = exports.IClientSpec = exports.IKeyType = exports.HypersignBJJVerifiableCredential = exports.IVerificationRelationships = exports.HypersignVerifiablePresentation = exports.HypersignVerifiableCredential = exports.HypersignSchema = exports.HypersignDID = exports.HypersignSSISdk = void 0; const did_1 = __importDefault(require("./did/did")); exports.HypersignDID = did_1.default; +const bjjdid_1 = __importDefault(require("./did/bjjdid")); const vc_1 = __importDefault(require("./credential/vc")); exports.HypersignVerifiableCredential = vc_1.default; const vp_1 = __importDefault(require("./presentation/vp")); @@ -23,12 +24,17 @@ const schema_1 = __importDefault(require("./schema/schema")); exports.HypersignSchema = schema_1.default; const IDID_1 = require("./did/IDID"); Object.defineProperty(exports, "IClientSpec", { enumerable: true, get: function () { return IDID_1.IClientSpec; } }); -Object.defineProperty(exports, "IKeyType", { enumerable: true, get: function () { return IDID_1.IKeyType; } }); -Object.defineProperty(exports, "IVerificationRelationships", { enumerable: true, get: function () { return IDID_1.IVerificationRelationships; } }); +Object.defineProperty(exports, "SupportedPurpose", { enumerable: true, get: function () { return IDID_1.SupportedPurpose; } }); +const enums_1 = require("../libs/generated/ssi/client/enums"); +Object.defineProperty(exports, "IKeyType", { enumerable: true, get: function () { return enums_1.VerificationMethodTypes; } }); +const enums_2 = require("../libs/generated/ssi/client/enums"); +Object.defineProperty(exports, "IVerificationRelationships", { enumerable: true, get: function () { return enums_2.VerificationMethodRelationships; } }); const did_2 = require("../libs/generated/ssi/did"); -Object.defineProperty(exports, "Did", { enumerable: true, get: function () { return did_2.Did; } }); -const schema_2 = require("../libs/generated/ssi/schema"); -Object.defineProperty(exports, "Schema", { enumerable: true, get: function () { return schema_2.Schema; } }); +Object.defineProperty(exports, "Did", { enumerable: true, get: function () { return did_2.DidDocument; } }); +const credential_schema_1 = require("../libs/generated/ssi/credential_schema"); +Object.defineProperty(exports, "Schema", { enumerable: true, get: function () { return credential_schema_1.CredentialSchemaDocument; } }); +const bjjvc_1 = __importDefault(require("./credential/bjjvc")); +exports.HypersignBJJVerifiableCredential = bjjvc_1.default; class HypersignSSISdk { constructor(params) { const { offlineSigner, nodeRpcEndpoint, nodeRestEndpoint, namespace, entityApiSecretKey } = params; @@ -45,15 +51,20 @@ class HypersignSSISdk { entityApiSecretKey: this.entityApiSecretKey, }; this.did = new did_1.default(constructorParams); + this.did.bjjDID = new bjjdid_1.default(constructorParams); this.schema = new schema_1.default(constructorParams); this.vc = new vc_1.default(constructorParams); + this.vc.bjjVC = new bjjvc_1.default(constructorParams); this.vp = new vp_1.default(constructorParams); } init() { return __awaiter(this, void 0, void 0, function* () { yield this.did.init(); + yield this.did.bjjDID.init(); yield this.schema.init(); + yield this.schema.hypersignBjjschema.init(); yield this.vc.init(); + yield this.vc.bjjVC.init(); }); } } diff --git a/build/src/presentation/IPresentation.d.ts b/build/src/presentation/IPresentation.d.ts index 52672c4..c6d8451 100644 --- a/build/src/presentation/IPresentation.d.ts +++ b/build/src/presentation/IPresentation.d.ts @@ -2,7 +2,7 @@ import { IVerifiableCredential } from '../credential/ICredential'; export interface IVerifiablePresentation { id: string; type: Array; - verifiableCredential: Array | Array; + verifiableCredential: Array; holder: string; proof: object; } @@ -17,6 +17,7 @@ export interface IPresentationMethods { privateKeyMultibase: string; challenge: string; verificationMethodId: string; + domain?: string; }): Promise; verify(params: { signedPresentation: IVerifiablePresentation; diff --git a/build/src/presentation/IPresentation.d.ts.map b/build/src/presentation/IPresentation.d.ts.map index ed0d58e..5b75002 100644 --- a/build/src/presentation/IPresentation.d.ts.map +++ b/build/src/presentation/IPresentation.d.ts.map @@ -1 +1 @@ -{"version":3,"file":"IPresentation.d.ts","sourceRoot":"","sources":["../../../src/presentation/IPresentation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,MAAM,2BAA2B,CAAC;AAqBlE,MAAM,WAAW,uBAAuB;IACtC,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;IACpB,oBAAoB,EAAE,KAAK,CAAC,qBAAqB,CAAC,GAAG,KAAK,CAAC,MAAM,CAAC,CAAC;IACnE,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,MAAM,CAAC;CACf;AAED,MAAM,WAAW,oBAAoB;IACnC,QAAQ,CAAC,MAAM,EAAE;QAAE,qBAAqB,EAAE,KAAK,CAAC,qBAAqB,CAAC,CAAC;QAAC,SAAS,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;IAE9G,IAAI,CAAC,MAAM,EAAE;QACX,YAAY,EAAE,uBAAuB,CAAC;QACtC,SAAS,EAAE,MAAM,CAAC;QAClB,mBAAmB,EAAE,MAAM,CAAC;QAC5B,SAAS,EAAE,MAAM,CAAC;QAClB,oBAAoB,EAAE,MAAM,CAAC;KAC9B,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;IAEpB,MAAM,CAAC,MAAM,EAAE;QACb,kBAAkB,EAAE,uBAAuB,CAAC;QAC5C,SAAS,EAAE,MAAM,CAAC;QAClB,MAAM,CAAC,EAAE,MAAM,CAAC;QAChB,SAAS,EAAE,MAAM,CAAC;QAClB,SAAS,EAAE,MAAM,CAAC;QAClB,0BAA0B,EAAE,MAAM,CAAC;QACnC,0BAA0B,EAAE,MAAM,CAAC;KACpC,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;IACpB,gBAAgB,CAAC,MAAM,EAAE;QACvB,YAAY,EAAE,uBAAuB,CAAC;QACtC,SAAS,CAAC,EAAE,MAAM,CAAC;QACnB,oBAAoB,EAAE,MAAM,CAAC;QAC7B,OAAO,MAAC;QACR,MAAM,CAAC,EAAE,MAAM,CAAC;QAChB,SAAS,CAAC,EAAE,MAAM,CAAC;KACpB,GAAG,OAAO,CAAC,uBAAuB,CAAC,CAAC;IACrC,kBAAkB,CAAC,MAAM,EAAE;QACzB,kBAAkB,EAAE,uBAAuB,CAAC;QAC5C,SAAS,CAAC,EAAE,MAAM,CAAC;QACnB,MAAM,CAAC,EAAE,MAAM,CAAC;QAChB,SAAS,EAAE,MAAM,CAAC;QAClB,SAAS,CAAC,EAAE,MAAM,CAAC;QACnB,kBAAkB,CAAC,EAAE,IAAI,CAAC;QAC1B,0BAA0B,EAAE,MAAM,CAAC;QACnC,0BAA0B,EAAE,MAAM,CAAC;QACnC,OAAO,MAAC;KACT,GAAG,OAAO,CAAC;QACV,QAAQ,EAAE,OAAO,CAAC;QAClB,iBAAiB,MAAC;QAClB,kBAAkB,MAAC;QACnB,KAAK,MAAC;KACP,CAAC,CAAC;CACJ"} \ No newline at end of file +{"version":3,"file":"IPresentation.d.ts","sourceRoot":"","sources":["../../../src/presentation/IPresentation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,MAAM,2BAA2B,CAAC;AAqBlE,MAAM,WAAW,uBAAuB;IACtC,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;IACpB,oBAAoB,EAAE,KAAK,CAAC,qBAAqB,CAAC,CAAC;IACnD,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,MAAM,CAAC;CACf;AAED,MAAM,WAAW,oBAAoB;IACnC,QAAQ,CAAC,MAAM,EAAE;QAAE,qBAAqB,EAAE,KAAK,CAAC,qBAAqB,CAAC,CAAC;QAAC,SAAS,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;IAE9G,IAAI,CAAC,MAAM,EAAE;QACX,YAAY,EAAE,uBAAuB,CAAC;QACtC,SAAS,EAAE,MAAM,CAAC;QAClB,mBAAmB,EAAE,MAAM,CAAC;QAC5B,SAAS,EAAE,MAAM,CAAC;QAClB,oBAAoB,EAAE,MAAM,CAAC;QAC7B,MAAM,CAAC,EAAE,MAAM,CAAC;KACjB,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;IAEpB,MAAM,CAAC,MAAM,EAAE;QACb,kBAAkB,EAAE,uBAAuB,CAAC;QAC5C,SAAS,EAAE,MAAM,CAAC;QAClB,MAAM,CAAC,EAAE,MAAM,CAAC;QAChB,SAAS,EAAE,MAAM,CAAC;QAClB,SAAS,EAAE,MAAM,CAAC;QAClB,0BAA0B,EAAE,MAAM,CAAC;QACnC,0BAA0B,EAAE,MAAM,CAAC;KACpC,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;IACpB,gBAAgB,CAAC,MAAM,EAAE;QACvB,YAAY,EAAE,uBAAuB,CAAC;QACtC,SAAS,CAAC,EAAE,MAAM,CAAC;QACnB,oBAAoB,EAAE,MAAM,CAAC;QAC7B,OAAO,MAAC;QACR,MAAM,CAAC,EAAE,MAAM,CAAC;QAChB,SAAS,CAAC,EAAE,MAAM,CAAC;KACpB,GAAG,OAAO,CAAC,uBAAuB,CAAC,CAAC;IACrC,kBAAkB,CAAC,MAAM,EAAE;QACzB,kBAAkB,EAAE,uBAAuB,CAAC;QAC5C,SAAS,CAAC,EAAE,MAAM,CAAC;QACnB,MAAM,CAAC,EAAE,MAAM,CAAC;QAChB,SAAS,EAAE,MAAM,CAAC;QAClB,SAAS,CAAC,EAAE,MAAM,CAAC;QACnB,kBAAkB,CAAC,EAAE,IAAI,CAAC;QAC1B,0BAA0B,EAAE,MAAM,CAAC;QACnC,0BAA0B,EAAE,MAAM,CAAC;QACnC,OAAO,MAAC;KACT,GAAG,OAAO,CAAC;QACV,QAAQ,EAAE,OAAO,CAAC;QAClB,iBAAiB,MAAC;QAClB,kBAAkB,MAAC;QACnB,KAAK,MAAC;KACP,CAAC,CAAC;CACJ"} \ No newline at end of file diff --git a/build/src/presentation/bjjVp.d.ts b/build/src/presentation/bjjVp.d.ts new file mode 100644 index 0000000..77100d8 --- /dev/null +++ b/build/src/presentation/bjjVp.d.ts @@ -0,0 +1,107 @@ +/** + * Copyright (c) 2023, Hypermine Pvt. Ltd. + * All rights reserved. + * Author: Hypermine Core Team + */ +import { IVerifiableCredential } from '../credential/ICredential'; +import { IPresentationMethods, IVerifiablePresentation } from './IPresentation'; +import { BabyJubJubSignatureProof2021 } from 'babyjubjubsignature2021'; +export default class HyperSignBJJVP implements IPresentationMethods, IVerifiablePresentation { + private hsDid; + private vc; + id: string; + type: Array; + verifiableCredential: Array; + holder: string; + proof: object; + namespace: string; + constructor(params?: { + namespace?: string; + nodeRpcEndpoint?: string; + nodeRestEndpoint?: string; + }); + signByClientSpec(params: { + presentation: IVerifiablePresentation; + holderDid?: string | undefined; + verificationMethodId: string; + web3Obj: any; + domain?: string | undefined; + challenge?: string | undefined; + }): Promise; + verifyByClientSpec(params: { + signedPresentation: IVerifiablePresentation; + challenge?: string | undefined; + domain?: string | undefined; + issuerDid: string; + holderDid?: string | undefined; + holderDidDocSigned?: JSON | undefined; + holderVerificationMethodId: string; + issuerVerificationMethodId: string; + web3Obj: any; + }): Promise<{ + verified: boolean; + credentialResults: any; + presentationResult: any; + error: any; + }>; + private _getId; + /** + * Generates a new presentation document + * @params + * - params.verifiableCredentials: Array of Verifiable Credentials + * - params.holderDid : DID of the subject + * @returns {Promise} + */ + generate(params: { + verifiableCredentials: Array; + holderDid: string; + }): Promise; + /** + * Signs a new presentation document + * @params + * - params.presentation : Array of Verifiable Credentials + * - params.holderDid : *Optional* DID of the subject + * - params.holderDidDocSigned : *Optional* DID Doc of the subject + * - params.verificationMethodId : verificationMethodId of holder + * - params.privateKeyMultibase : Private key associated with the verification method + * - params.challenge : Any random challenge + * - params.domain : Domain url + * @returns {Promise} + */ + sign(params: { + presentation: IVerifiablePresentation; + holderDid?: string; + holderDidDocSigned?: JSON; + verificationMethodId: string; + privateKeyMultibase: string; + challenge: string; + domain?: string; + }): Promise; + /** + * Verifies signed presentation document + * @params + * - params.signedPresentation : Signed presentation document + * - params.holderDid : DID of the subject + * - params.holderDidDocSigned : DIDdocument of the subject + * - params.holderVerificationMethodId : verificationMethodId of holder + * - params.issuerDid : DID of the issuer + * - params.issuerVerificationMethodId : verificationMethodId of issuer + * - params.domain : Optional domain + * - params.challenge : Random challenge + * @returns {Promise} + */ + verify(params: { + signedPresentation: IVerifiablePresentation; + challenge: string; + domain?: string; + issuerDid: string; + holderDid?: string; + holderDidDocSigned?: JSON; + holderVerificationMethodId: string; + issuerVerificationMethodId: string; + }): Promise; + verifyProof(derivedProofs: any, params: { + suite: BabyJubJubSignatureProof2021; + }): Promise; +} +//# sourceMappingURL=bjjVp.d.ts.map \ No newline at end of file diff --git a/build/src/presentation/bjjVp.d.ts.map b/build/src/presentation/bjjVp.d.ts.map new file mode 100644 index 0000000..d3cb78d --- /dev/null +++ b/build/src/presentation/bjjVp.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"bjjVp.d.ts","sourceRoot":"","sources":["../../../src/presentation/bjjVp.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AASH,OAAO,EAAE,qBAAqB,EAAE,MAAM,2BAA2B,CAAC;AAGlE,OAAO,EAAE,oBAAoB,EAAE,uBAAuB,EAAE,MAAM,iBAAiB,CAAC;AAGhF,OAAO,EAAgC,4BAA4B,EAAE,MAAM,yBAAyB,CAAC;AAIrG,MAAM,CAAC,OAAO,OAAO,cAAe,YAAW,oBAAoB,EAAE,uBAAuB;IAC1F,OAAO,CAAC,KAAK,CAAe;IAC5B,OAAO,CAAC,EAAE,CAAgC;IAC1C,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;IACpB,oBAAoB,EAAE,KAAK,CAAC,qBAAqB,CAAC,CAAC;IACnD,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,MAAM,CAAC;IACd,SAAS,EAAE,MAAM,CAAC;gBAEhB,MAAM,GAAE;QACN,SAAS,CAAC,EAAE,MAAM,CAAC;QACnB,eAAe,CAAC,EAAE,MAAM,CAAC;QACzB,gBAAgB,CAAC,EAAE,MAAM,CAAC;KACtB;IAkBR,gBAAgB,CAAC,MAAM,EAAE;QACvB,YAAY,EAAE,uBAAuB,CAAC;QACtC,SAAS,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;QAC/B,oBAAoB,EAAE,MAAM,CAAC;QAC7B,OAAO,EAAE,GAAG,CAAC;QACb,MAAM,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;QAC5B,SAAS,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;KAChC,GAAG,OAAO,CAAC,uBAAuB,CAAC;IAGpC,kBAAkB,CAAC,MAAM,EAAE;QACzB,kBAAkB,EAAE,uBAAuB,CAAC;QAC5C,SAAS,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;QAC/B,MAAM,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;QAC5B,SAAS,EAAE,MAAM,CAAC;QAClB,SAAS,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;QAC/B,kBAAkB,CAAC,EAAE,IAAI,GAAG,SAAS,CAAC;QACtC,0BAA0B,EAAE,MAAM,CAAC;QACnC,0BAA0B,EAAE,MAAM,CAAC;QACnC,OAAO,EAAE,GAAG,CAAC;KACd,GAAG,OAAO,CAAC;QAAE,QAAQ,EAAE,OAAO,CAAC;QAAC,iBAAiB,EAAE,GAAG,CAAC;QAAC,kBAAkB,EAAE,GAAG,CAAC;QAAC,KAAK,EAAE,GAAG,CAAA;KAAE,CAAC;YAIjF,MAAM;IAWpB;;;;;;OAMG;IACG,QAAQ,CAAC,MAAM,EAAE;QAAE,qBAAqB,EAAE,KAAK,CAAC,qBAAqB,CAAC,CAAC;QAAC,SAAS,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC,MAAM,CAAC;IAUnH;;;;;;;;;;;OAWG;IACG,IAAI,CAAC,MAAM,EAAE;QACjB,YAAY,EAAE,uBAAuB,CAAC;QACtC,SAAS,CAAC,EAAE,MAAM,CAAC;QACnB,kBAAkB,CAAC,EAAE,IAAI,CAAC;QAC1B,oBAAoB,EAAE,MAAM,CAAC;QAC7B,mBAAmB,EAAE,MAAM,CAAC;QAC5B,SAAS,EAAE,MAAM,CAAC;QAClB,MAAM,CAAC,EAAE,MAAM,CAAC;KACjB,GAAG,OAAO,CAAC,uBAAuB,CAAC;IAgFpC;;;;;;;;;;;;OAYG;IACG,MAAM,CAAC,MAAM,EAAE;QACnB,kBAAkB,EAAE,uBAAuB,CAAC;QAC5C,SAAS,EAAE,MAAM,CAAC;QAClB,MAAM,CAAC,EAAE,MAAM,CAAC;QAChB,SAAS,EAAE,MAAM,CAAC;QAClB,SAAS,CAAC,EAAE,MAAM,CAAC;QACnB,kBAAkB,CAAC,EAAE,IAAI,CAAC;QAC1B,0BAA0B,EAAE,MAAM,CAAC;QACnC,0BAA0B,EAAE,MAAM,CAAC;KACpC,GAAG,OAAO,CAAC,MAAM,CAAC;IA0Hb,WAAW,CACf,aAAa,KAAA,EACb,MAAM,EAAE;QACN,KAAK,EAAE,4BAA4B,CAAC;KACrC;CAgBJ"} \ No newline at end of file diff --git a/build/src/presentation/bjjVp.js b/build/src/presentation/bjjVp.js new file mode 100644 index 0000000..2bacfb9 --- /dev/null +++ b/build/src/presentation/bjjVp.js @@ -0,0 +1,298 @@ +"use strict"; +/** + * Copyright (c) 2023, Hypermine Pvt. Ltd. + * All rights reserved. + * Author: Hypermine Core Team + */ +var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { + function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } + return new (P || (P = Promise))(function (resolve, reject) { + function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } + function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } + function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } + step((generator = generator.apply(thisArg, _arguments || [])).next()); + }); +}; +var __importDefault = (this && this.__importDefault) || function (mod) { + return (mod && mod.__esModule) ? mod : { "default": mod }; +}; +Object.defineProperty(exports, "__esModule", { value: true }); +const vc_js_1 = __importDefault(require("vc-js")); +const jsonld_signatures_1 = __importDefault(require("jsonld-signatures")); +const did_1 = __importDefault(require("../did/did")); +const utils_1 = __importDefault(require("../utils")); +const vc_1 = __importDefault(require("../credential/vc")); +const { AuthenticationProofPurpose, AssertionProofPurpose } = jsonld_signatures_1.default.purposes; +const constants_1 = require("../constants"); +const v1_1 = __importDefault(require("../../libs/w3cache/v1")); +const babyjubjub2021_1 = require("babyjubjub2021"); +const babyjubjubsignature2021_1 = require("babyjubjubsignature2021"); +const documentLoader = jsonld_signatures_1.default.extendContextLoader(v1_1.default); +class HyperSignBJJVP { + constructor(params = {}) { + const { namespace, nodeRpcEndpoint, nodeRestEndpoint } = params; + this.namespace = namespace && namespace != '' ? namespace : ''; + const nodeRPCEp = nodeRpcEndpoint ? nodeRpcEndpoint : 'MAIN'; + const nodeRestEp = nodeRestEndpoint ? nodeRestEndpoint : ''; + const offlineConstuctorParams = { nodeRpcEndpoint: nodeRPCEp, nodeRestEndpoint: nodeRestEp }; + this.vc = new vc_1.default(offlineConstuctorParams); + this.hsDid = new did_1.default(offlineConstuctorParams); + this.id = ''; + this.type = []; + this.verifiableCredential = []; + this.holder = ''; + this.proof = {}; + } + signByClientSpec(params) { + throw new Error('Method not implemented.'); + } + verifyByClientSpec(params) { + throw new Error('Method not implemented.'); + } + _getId() { + return __awaiter(this, void 0, void 0, function* () { + const uuid = yield utils_1.default.getUUID(); + let id; + if (this.namespace && this.namespace != '') { + id = `${constants_1.VP.SCHEME}:${constants_1.VP.METHOD}:${this.namespace}:${uuid}`; + } + else { + id = `${constants_1.VP.SCHEME}:${constants_1.VP.METHOD}:${uuid}`; + } + return id; + }); + } + /** + * Generates a new presentation document + * @params + * - params.verifiableCredentials: Array of Verifiable Credentials + * - params.holderDid : DID of the subject + * @returns {Promise} + */ + generate(params) { + return __awaiter(this, void 0, void 0, function* () { + const id = yield this._getId(); + const presentation = vc_js_1.default.createPresentation({ + verifiableCredential: params.verifiableCredentials, + id: id, + holder: params.holderDid, + }); + return presentation; + }); + } + /** + * Signs a new presentation document + * @params + * - params.presentation : Array of Verifiable Credentials + * - params.holderDid : *Optional* DID of the subject + * - params.holderDidDocSigned : *Optional* DID Doc of the subject + * - params.verificationMethodId : verificationMethodId of holder + * - params.privateKeyMultibase : Private key associated with the verification method + * - params.challenge : Any random challenge + * - params.domain : Domain url + * @returns {Promise} + */ + sign(params) { + return __awaiter(this, void 0, void 0, function* () { + if (params.holderDid && params.holderDidDocSigned) { + throw new Error('HID-SSI-SDK:: Either holderDid or holderDidDocSigned should be provided'); + } + if (!params.privateKeyMultibase) { + throw new Error('HID-SSI-SDK:: params.privateKeyMultibase is required for signing a presentation'); + } + if (!params.presentation) { + throw new Error('HID-SSI-SDK:: params.presentation is required for signing a presentation'); + } + if (!params.challenge) { + throw new Error('HID-SSI-SDK:: params.challenge is required for signing a presentation'); + } + if (!params.verificationMethodId) { + throw new Error('HID-SSI-SDK:: params.verificationMethodId is required for signing a presentation'); + } + if (!this.hsDid) { + throw new Error('HID-SSI-SDK:: Error: HypersignVerifiableCredential class is not instantiated with Offlinesigner or have not been initilized'); + } + let resolvedDidDoc; + if (params.holderDid) { + resolvedDidDoc = yield this.hsDid.resolve({ did: params.holderDid }); + } + else if (params.holderDidDocSigned) { + resolvedDidDoc = {}; + resolvedDidDoc.didDocument = params.holderDidDocSigned; + } + else { + throw new Error('HID-SSI-SDK:: params.holderDid or params.holderDidDocSigned is required for signing a presentation'); + } + const { didDocument: signerDidDoc } = resolvedDidDoc; + // TODO: take verification method from params + const publicKeyId = params.verificationMethodId; // TODO: bad idea - should not hardcode it. + const publicKeyVerMethod = signerDidDoc['verificationMethod'].find((x) => x.id == publicKeyId); + const keyPair = yield babyjubjub2021_1.BabyJubJubKeys2021.fromKeys({ + privateKeyMultibase: params.privateKeyMultibase, + publicKeyMultibase: publicKeyVerMethod.publicKeyMultibase, + options: { + id: publicKeyVerMethod.id, + controller: publicKeyVerMethod.controller, + }, + }); + const suite = new babyjubjubsignature2021_1.BabyJubJubSignature2021Suite({ + verificationMethod: publicKeyId, + key: keyPair, + }); + params.presentation['@context'].push('https://raw.githubusercontent.com/hypersign-protocol/hypersign-contexts/main/BJJSignature2021.jsonld'); + const signedVP = yield jsonld_signatures_1.default.sign(params.presentation, { + suite, + purpose: new AuthenticationProofPurpose({ + controller: { + '@context': ['https://www.w3.org/2018/credentials/v1'], + id: publicKeyId, + authentication: [publicKeyId], + }, + domain: params.domain, + challenge: params.challenge, + }), + documentLoader, + }); + return signedVP; + }); + } + // https://github.com/digitalbazaar/vc-js/blob/44ca660f62ad3569f338eaaaecb11a7b09949bd2/lib/vc.js#L392 + /** + * Verifies signed presentation document + * @params + * - params.signedPresentation : Signed presentation document + * - params.holderDid : DID of the subject + * - params.holderDidDocSigned : DIDdocument of the subject + * - params.holderVerificationMethodId : verificationMethodId of holder + * - params.issuerDid : DID of the issuer + * - params.issuerVerificationMethodId : verificationMethodId of issuer + * - params.domain : Optional domain + * - params.challenge : Random challenge + * @returns {Promise} + */ + verify(params) { + var _a, _b; + return __awaiter(this, void 0, void 0, function* () { + /* eslint-disable */ + const that = this; + if (params.holderDid && params.holderDidDocSigned) { + throw new Error('HID-SSI-SDK:: Either holderDid or holderDidDocSigned should be provided'); + } + if (!params.issuerDid) { + throw new Error('HID-SSI-SDK:: params.issuerDid is required for verifying a presentation'); + } + if (!params.challenge) { + throw new Error('HID-SSI-SDK:: params.challenge is required for verifying a presentation'); + } + if (!params.holderVerificationMethodId) { + throw new Error('HID-SSI-SDK:: params.holderVerificationMethodId is required for verifying a presentation'); + } + if (!params.issuerVerificationMethodId) { + throw new Error('HID-SSI-SDK:: params.issuerVerificationMethodId is required for verifying a presentation'); + } + if (!this.vc || !this.hsDid) { + throw new Error('HID-SSI-SDK:: Error: HypersignVerifiableCredential class is not instantiated with Offlinesigner or have not been initilized'); + } + if (!params.signedPresentation.proof) { + throw new Error('HID-SSI-SDK:: params.signedPresentation must be signed'); + } + ///--------------------------------------- + /// Holder + let resolvedDidDoc; + if (params.holderDid) { + resolvedDidDoc = yield this.hsDid.resolve({ did: params.holderDid }); + } + else if (params.holderDidDocSigned) { + resolvedDidDoc = {}; + resolvedDidDoc.didDocument = params.holderDidDocSigned; + } + else { + throw new Error('Either holderDid or holderDidDocSigned should be provided'); + } + const credentialResult = Array(); + const verifiableCredential = params.signedPresentation.verifiableCredential; + for (let i = 0; i < verifiableCredential.length; i++) { + if (((_a = verifiableCredential[i].proof) === null || _a === void 0 ? void 0 : _a.type) === 'BabyJubJubSignatureProof2021') { + const res = yield this.hsDid.resolve({ did: verifiableCredential[i].issuer }); + const didDocument = res.didDocument; + const vm = didDocument.verificationMethod.find((x) => x.id == params.issuerVerificationMethodId); + const credentailRes = yield this.verifyProof(verifiableCredential[i], { + suite: new babyjubjubsignature2021_1.BabyJubJubSignatureProof2021({ + key: yield babyjubjub2021_1.BabyJubJubKeys2021.fromKeys({ + publicKeyMultibase: vm === null || vm === void 0 ? void 0 : vm.publicKeyMultibase, + options: { + id: vm === null || vm === void 0 ? void 0 : vm.id, + controller: vm === null || vm === void 0 ? void 0 : vm.controller, + }, + }), + }), + }); + credentialResult.push(credentailRes); + } + else { + const credentailRes = yield that.vc.bjjVC.verify({ + credential: verifiableCredential[i], + issuerDid: verifiableCredential[i].issuer, + verificationMethodId: (_b = verifiableCredential[i].proof) === null || _b === void 0 ? void 0 : _b.verificationMethod, + }); + credentialResult.push(credentailRes); + } + } + const { didDocument: holderDID } = resolvedDidDoc; + const holderDidDoc = holderDID; + const holderPublicKeyId = params.holderVerificationMethodId; + const holderPublicKeyVerMethod = holderDidDoc.verificationMethod.find((x) => x.id == holderPublicKeyId); + const holderController = { + '@context': constants_1.DID.CONTROLLER_CONTEXT, + id: holderDidDoc.id, + authentication: holderDidDoc.authentication, + }; + // TODO: need to use domainname. + const presentationPurpose = new AuthenticationProofPurpose({ + controller: holderController, + domain: params.domain, + challenge: params.challenge, + }); + const keyPair = yield babyjubjub2021_1.BabyJubJubKeys2021.fromKeys({ + publicKeyMultibase: holderPublicKeyVerMethod.publicKeyMultibase, + options: { + id: holderPublicKeyVerMethod.id, + controller: holderPublicKeyVerMethod.controller, + }, + }); + const vpSuite_holder = new babyjubjubsignature2021_1.BabyJubJubSignature2021Suite({ + verificationMethod: holderPublicKeyId, + key: keyPair, + }); + /* eslint-enable */ + const result = yield jsonld_signatures_1.default.verify(params.signedPresentation, { + purpose: presentationPurpose, + suite: vpSuite_holder, + documentLoader, + // checkStatus: async function (options) { + // return await that.vc.checkCredentialStatus({ credentialId: options.credential.id }); + // }, + }); + result.results.push({ credentialResult }); + return result; + }); + } + verifyProof(derivedProofs, params) { + return __awaiter(this, void 0, void 0, function* () { + const id = derivedProofs.proof.verificationMethod; + const result = yield jsonld_signatures_1.default.verify(derivedProofs, { + suite: params.suite, + purpose: new AssertionProofPurpose({ + controller: { + '@context': ['https://www.w3.org/ns/did/v1'], + id, + assertionMethod: [id], + }, + }), + documentLoader, + }); + return result; + }); + } +} +exports.default = HyperSignBJJVP; diff --git a/build/src/presentation/vp.d.ts b/build/src/presentation/vp.d.ts index 13ce436..d40777d 100644 --- a/build/src/presentation/vp.d.ts +++ b/build/src/presentation/vp.d.ts @@ -5,9 +5,11 @@ */ import { IVerifiableCredential } from '../credential/ICredential'; import { IPresentationMethods, IVerifiablePresentation } from './IPresentation'; +import HyperSignBJJVP from './bjjVp'; export default class HypersignVerifiablePresentation implements IPresentationMethods, IVerifiablePresentation { private hsDid; private vc; + bjjVp: HyperSignBJJVP; id: string; type: Array; verifiableCredential: Array; @@ -40,6 +42,7 @@ export default class HypersignVerifiablePresentation implements IPresentationMet * - params.verificationMethodId : verificationMethodId of holder * - params.privateKeyMultibase : Private key associated with the verification method * - params.challenge : Any random challenge + * - params.domain : Domain url * @returns {Promise} */ sign(params: { @@ -49,6 +52,7 @@ export default class HypersignVerifiablePresentation implements IPresentationMet verificationMethodId: string; privateKeyMultibase: string; challenge: string; + domain?: string; }): Promise; /** * Verifies signed presentation document @@ -90,7 +94,7 @@ export default class HypersignVerifiablePresentation implements IPresentationMet verificationMethodId: string; web3Obj: any; domain?: string; - challenge?: string; + challenge: string; }): Promise; /** * Verifies signed presentation document diff --git a/build/src/presentation/vp.d.ts.map b/build/src/presentation/vp.d.ts.map index f3e348e..f4747da 100644 --- a/build/src/presentation/vp.d.ts.map +++ b/build/src/presentation/vp.d.ts.map @@ -1 +1 @@ -{"version":3,"file":"vp.d.ts","sourceRoot":"","sources":["../../../src/presentation/vp.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAWH,OAAO,EAAE,qBAAqB,EAAE,MAAM,2BAA2B,CAAC;AAGlE,OAAO,EAAE,oBAAoB,EAAE,uBAAuB,EAAE,MAAM,iBAAiB,CAAC;AAOhF,MAAM,CAAC,OAAO,OAAO,+BAAgC,YAAW,oBAAoB,EAAE,uBAAuB;IAC3G,OAAO,CAAC,KAAK,CAAsB;IACnC,OAAO,CAAC,EAAE,CAAgC;IAC1C,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;IACpB,oBAAoB,EAAE,KAAK,CAAC,qBAAqB,CAAC,CAAC;IACnD,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,MAAM,CAAC;IACd,SAAS,EAAE,MAAM,CAAC;gBAEhB,MAAM,GAAE;QACN,SAAS,CAAC,EAAE,MAAM,CAAC;QACnB,eAAe,CAAC,EAAE,MAAM,CAAC;QACzB,gBAAgB,CAAC,EAAE,MAAM,CAAC;KACtB;YAkBM,MAAM;IAWpB;;;;;;OAMG;IACG,QAAQ,CAAC,MAAM,EAAE;QAAE,qBAAqB,EAAE,KAAK,CAAC,qBAAqB,CAAC,CAAC;QAAC,SAAS,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC,MAAM,CAAC;IAUnH;;;;;;;;;;OAUG;IACG,IAAI,CAAC,MAAM,EAAE;QACjB,YAAY,EAAE,uBAAuB,CAAC;QACtC,SAAS,CAAC,EAAE,MAAM,CAAC;QACnB,kBAAkB,CAAC,EAAE,IAAI,CAAC;QAC1B,oBAAoB,EAAE,MAAM,CAAC;QAC7B,mBAAmB,EAAE,MAAM,CAAC;QAC5B,SAAS,EAAE,MAAM,CAAC;KACnB,GAAG,OAAO,CAAC,uBAAuB,CAAC;IAwEpC;;;;;;;;;;;;OAYG;IACG,MAAM,CAAC,MAAM,EAAE;QACnB,kBAAkB,EAAE,uBAAuB,CAAC;QAC5C,SAAS,EAAE,MAAM,CAAC;QAClB,MAAM,CAAC,EAAE,MAAM,CAAC;QAChB,SAAS,EAAE,MAAM,CAAC;QAClB,SAAS,CAAC,EAAE,MAAM,CAAC;QACnB,kBAAkB,CAAC,EAAE,IAAI,CAAC;QAC1B,0BAA0B,EAAE,MAAM,CAAC;QACnC,0BAA0B,EAAE,MAAM,CAAC;KACpC,GAAG,OAAO,CAAC,MAAM,CAAC;IA8JnB;;;;;;;;;;OAUG;IACG,gBAAgB,CAAC,MAAM,EAAE;QAC7B,YAAY,EAAE,uBAAuB,CAAC;QACtC,SAAS,CAAC,EAAE,MAAM,CAAC;QACnB,oBAAoB,EAAE,MAAM,CAAC;QAC7B,OAAO,MAAC;QACR,MAAM,CAAC,EAAE,MAAM,CAAC;QAChB,SAAS,CAAC,EAAE,MAAM,CAAC;KACpB,GAAG,OAAO,CAAC,uBAAuB,CAAC;IAuDpC;;;;;;;;;;;;;OAaG;IAEG,kBAAkB,CAAC,MAAM,EAAE;QAC/B,kBAAkB,EAAE,uBAAuB,CAAC;QAC5C,SAAS,CAAC,EAAE,MAAM,CAAC;QACnB,MAAM,CAAC,EAAE,MAAM,CAAC;QAChB,SAAS,EAAE,MAAM,CAAC;QAClB,SAAS,CAAC,EAAE,MAAM,CAAC;QACnB,kBAAkB,CAAC,EAAE,IAAI,CAAC;QAC1B,0BAA0B,EAAE,MAAM,CAAC;QACnC,0BAA0B,EAAE,MAAM,CAAC;QACnC,OAAO,MAAC;KACT;;;;;;CAmKF"} \ No newline at end of file +{"version":3,"file":"vp.d.ts","sourceRoot":"","sources":["../../../src/presentation/vp.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAWH,OAAO,EAAE,qBAAqB,EAAE,MAAM,2BAA2B,CAAC;AAGlE,OAAO,EAAE,oBAAoB,EAAE,uBAAuB,EAAE,MAAM,iBAAiB,CAAC;AAIhF,OAAO,cAAc,MAAM,SAAS,CAAC;AAIrC,MAAM,CAAC,OAAO,OAAO,+BAAgC,YAAW,oBAAoB,EAAE,uBAAuB;IAC3G,OAAO,CAAC,KAAK,CAAsB;IACnC,OAAO,CAAC,EAAE,CAAgC;IACnC,KAAK,EAAE,cAAc,CAAC;IAC7B,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;IACpB,oBAAoB,EAAE,KAAK,CAAC,qBAAqB,CAAC,CAAC;IACnD,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,MAAM,CAAC;IACd,SAAS,EAAE,MAAM,CAAC;gBAEhB,MAAM,GAAE;QACN,SAAS,CAAC,EAAE,MAAM,CAAC;QACnB,eAAe,CAAC,EAAE,MAAM,CAAC;QACzB,gBAAgB,CAAC,EAAE,MAAM,CAAC;KACtB;YAmBM,MAAM;IAWpB;;;;;;OAMG;IACG,QAAQ,CAAC,MAAM,EAAE;QAAE,qBAAqB,EAAE,KAAK,CAAC,qBAAqB,CAAC,CAAC;QAAC,SAAS,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC,MAAM,CAAC;IAUnH;;;;;;;;;;;OAWG;IACG,IAAI,CAAC,MAAM,EAAE;QACjB,YAAY,EAAE,uBAAuB,CAAC;QACtC,SAAS,CAAC,EAAE,MAAM,CAAC;QACnB,kBAAkB,CAAC,EAAE,IAAI,CAAC;QAC1B,oBAAoB,EAAE,MAAM,CAAC;QAC7B,mBAAmB,EAAE,MAAM,CAAC;QAC5B,SAAS,EAAE,MAAM,CAAC;QAClB,MAAM,CAAC,EAAE,MAAM,CAAC;KACjB,GAAG,OAAO,CAAC,uBAAuB,CAAC;IAmEpC;;;;;;;;;;;;OAYG;IACG,MAAM,CAAC,MAAM,EAAE;QACnB,kBAAkB,EAAE,uBAAuB,CAAC;QAC5C,SAAS,EAAE,MAAM,CAAC;QAClB,MAAM,CAAC,EAAE,MAAM,CAAC;QAChB,SAAS,EAAE,MAAM,CAAC;QAClB,SAAS,CAAC,EAAE,MAAM,CAAC;QACnB,kBAAkB,CAAC,EAAE,IAAI,CAAC;QAC1B,0BAA0B,EAAE,MAAM,CAAC;QACnC,0BAA0B,EAAE,MAAM,CAAC;KACpC,GAAG,OAAO,CAAC,MAAM,CAAC;IA+InB;;;;;;;;;;OAUG;IACG,gBAAgB,CAAC,MAAM,EAAE;QAC7B,YAAY,EAAE,uBAAuB,CAAC;QACtC,SAAS,CAAC,EAAE,MAAM,CAAC;QACnB,oBAAoB,EAAE,MAAM,CAAC;QAC7B,OAAO,MAAC;QACR,MAAM,CAAC,EAAE,MAAM,CAAC;QAChB,SAAS,EAAE,MAAM,CAAC;KACnB,GAAG,OAAO,CAAC,uBAAuB,CAAC;IAyDpC;;;;;;;;;;;;;OAaG;IAEG,kBAAkB,CAAC,MAAM,EAAE;QAC/B,kBAAkB,EAAE,uBAAuB,CAAC;QAC5C,SAAS,CAAC,EAAE,MAAM,CAAC;QACnB,MAAM,CAAC,EAAE,MAAM,CAAC;QAChB,SAAS,EAAE,MAAM,CAAC;QAClB,SAAS,CAAC,EAAE,MAAM,CAAC;QACnB,kBAAkB,CAAC,EAAE,IAAI,CAAC;QAC1B,0BAA0B,EAAE,MAAM,CAAC;QACnC,0BAA0B,EAAE,MAAM,CAAC;QACnC,OAAO,MAAC;KACT;;;;;;CA2JF"} \ No newline at end of file diff --git a/build/src/presentation/vp.js b/build/src/presentation/vp.js index d2690de..8706b66 100644 --- a/build/src/presentation/vp.js +++ b/build/src/presentation/vp.js @@ -30,7 +30,8 @@ const constants_1 = require("../constants"); const v1_1 = __importDefault(require("../../libs/w3cache/v1")); const jsonld_signatures_2 = require("jsonld-signatures"); const ethereumeip712signature2021suite_1 = require("ethereumeip712signature2021suite"); -const documentLoader = v1_1.default; +const bjjVp_1 = __importDefault(require("./bjjVp")); +const documentLoader = jsonld_signatures_1.default.extendContextLoader(v1_1.default); class HypersignVerifiablePresentation { constructor(params = {}) { const { namespace, nodeRpcEndpoint, nodeRestEndpoint } = params; @@ -45,6 +46,7 @@ class HypersignVerifiablePresentation { this.verifiableCredential = []; this.holder = ''; this.proof = {}; + this.bjjVp = new bjjVp_1.default(params); } _getId() { return __awaiter(this, void 0, void 0, function* () { @@ -86,6 +88,7 @@ class HypersignVerifiablePresentation { * - params.verificationMethodId : verificationMethodId of holder * - params.privateKeyMultibase : Private key associated with the verification method * - params.challenge : Any random challenge + * - params.domain : Domain url * @returns {Promise} */ sign(params) { @@ -97,13 +100,13 @@ class HypersignVerifiablePresentation { throw new Error('HID-SSI-SDK:: params.privateKeyMultibase is required for signing a presentation'); } if (!params.presentation) { - throw new Error('HID-SSI-SDK:: params.presentation is required for signinng a presentation'); + throw new Error('HID-SSI-SDK:: params.presentation is required for signing a presentation'); } if (!params.challenge) { - throw new Error('HID-SSI-SDK:: params.challenge is required for signinng a presentation'); + throw new Error('HID-SSI-SDK:: params.challenge is required for signing a presentation'); } if (!params.verificationMethodId) { - throw new Error('HID-SSI-SDK:: params.verificationMethodId is required for signinng a presentation'); + throw new Error('HID-SSI-SDK:: params.verificationMethodId is required for signing a presentation'); } if (!this.hsDid) { throw new Error('HID-SSI-SDK:: Error: HypersignVerifiableCredential class is not instantiated with Offlinesigner or have not been initilized'); @@ -117,16 +120,12 @@ class HypersignVerifiablePresentation { resolvedDidDoc.didDocument = params.holderDidDocSigned; } else { - throw new Error('HID-SSI-SDK:: params.holderDid or params.holderDidDocSigned is required for signinng a presentation'); + throw new Error('HID-SSI-SDK:: params.holderDid or params.holderDidDocSigned is required for signing a presentation'); } const { didDocument: signerDidDoc } = resolvedDidDoc; // TODO: take verification method from params const publicKeyId = params.verificationMethodId; // TODO: bad idea - should not hardcode it. const publicKeyVerMethod = signerDidDoc['verificationMethod'].find((x) => x.id == publicKeyId); - const convertedKeyPair = utils_1.default.convertedStableLibKeysIntoEd25519verificationkey2020({ - publicKey: publicKeyVerMethod.publicKeyMultibase, - }); - publicKeyVerMethod['publicKeyMultibase'] = convertedKeyPair.publicKeyMultibase; const keyPair = yield ed25519_verification_key_2020_1.Ed25519VerificationKey2020.from(Object.assign({ privateKeyMultibase: params.privateKeyMultibase }, publicKeyVerMethod)); const suite = new ed25519_signature_2020_1.Ed25519Signature2020({ verificationMethod: publicKeyId, @@ -137,6 +136,7 @@ class HypersignVerifiablePresentation { suite, challenge: params.challenge, documentLoader, + domain: params.domain, }); return signedVP; }); @@ -195,11 +195,6 @@ class HypersignVerifiablePresentation { const holderDidDoc = holderDID; const holderPublicKeyId = params.holderVerificationMethodId; const holderPublicKeyVerMethod = holderDidDoc.verificationMethod.find((x) => x.id == holderPublicKeyId); - // Connvert the 45 byte pub key of holder into 48 byte - const { publicKeyMultibase: holderPublicKeyMultibase } = utils_1.default.convertedStableLibKeysIntoEd25519verificationkey2020({ - publicKey: holderPublicKeyVerMethod.publicKeyMultibase, - }); - holderPublicKeyVerMethod.publicKeyMultibase = holderPublicKeyMultibase; const holderController = { '@context': constants_1.DID.CONTROLLER_CONTEXT, id: holderDidDoc.id, @@ -209,6 +204,7 @@ class HypersignVerifiablePresentation { const presentationPurpose = new AuthenticationProofPurpose({ controller: holderController, challenge: params.challenge, + domain: params.domain, }); const keyPair = yield ed25519_verification_key_2020_1.Ed25519VerificationKey2020.from(Object.assign({ privateKeyMultibase: '' }, holderPublicKeyVerMethod)); const vpSuite_holder = new ed25519_signature_2020_1.Ed25519Signature2020({ @@ -218,8 +214,8 @@ class HypersignVerifiablePresentation { ///--------------------------------------- /// Issuer const { didDocument: issuerDID } = yield this.hsDid.resolve({ did: params.issuerDid }); - if (issuerDID === null || issuerDID === undefined) { - throw new Error('Issuer DID is not registered'); + if (issuerDID === null || issuerDID === undefined || Object.keys(issuerDID).length === 0) { + throw new Error(`Issuer DID ${issuerDID} is invalid or not registered on the blockchain`); } const issuerDidDoc = issuerDID; const issuerDidDocController = issuerDidDoc.controller; @@ -236,11 +232,6 @@ class HypersignVerifiablePresentation { const controllerDidDoc = controllerDidDocT; issuerPublicKeyVerMethod = controllerDidDoc.verificationMethod.find((x) => x.id == issuerPublicKeyId); } - // Connvert the 45 byte pub key of issuer into 48 byte - const { publicKeyMultibase: issuerPublicKeyMultibase } = utils_1.default.convertedStableLibKeysIntoEd25519verificationkey2020({ - publicKey: issuerPublicKeyVerMethod.publicKeyMultibase, - }); - issuerPublicKeyVerMethod.publicKeyMultibase = issuerPublicKeyMultibase; const issuerController = { '@context': constants_1.DID.CONTROLLER_CONTEXT, id: issuerDidDoc.id, @@ -263,7 +254,7 @@ class HypersignVerifiablePresentation { purpose, suite: [vpSuite_holder, vcSuite_issuer], documentLoader, - unsignedPresentation: true, + unsignedPresentation: false, checkStatus: function (options) { return __awaiter(this, void 0, void 0, function* () { return yield that.vc.checkCredentialStatus({ credentialId: options.credential.id }); @@ -287,16 +278,19 @@ class HypersignVerifiablePresentation { signByClientSpec(params) { return __awaiter(this, void 0, void 0, function* () { if (!params.holderDid) { - throw new Error('HID-SSI-SDK:: Either holderDid or holderDidDocSigned should be provided'); + throw new Error('HID-SSI-SDK:: params.holderDid is required to sign a presentation'); } if (!params.presentation) { - throw new Error('HID-SSI-SDK:: params.presentation is required for signinng a presentation'); + throw new Error('HID-SSI-SDK:: params.presentation is required for signing a presentation'); } if (!params.challenge) { - throw new Error('HID-SSI-SDK:: params.challenge is required for signinng a presentation'); + throw new Error('HID-SSI-SDK:: params.challenge is required for signing a presentation'); } if (!params.verificationMethodId) { - throw new Error('HID-SSI-SDK:: params.verificationMethodId is required for signinng a presentation'); + throw new Error('HID-SSI-SDK:: params.verificationMethodId is required for signing a presentation'); + } + if (!params.web3Obj || Object.keys(params.web3Obj).length === 0) { + throw new Error('HID-SSI-SDK:: Error: params.web3Obj is required to sign a presentation'); } if (!this.hsDid) { throw new Error('HID-SSI-SDK:: Error: HypersignVerifiableCredential class is not instantiated with Offlinesigner or have not been initilized'); @@ -312,8 +306,8 @@ class HypersignVerifiablePresentation { params.presentation.verifiableCredential.forEach((vc) => { return vcs.push(jcs_1.JCS.cannonicalize(vc)); }); - params.presentation.verifiableCredential = Array(); - params.presentation.verifiableCredential = vcs; + // params.presentation.verifiableCredential = Array(); + // params.presentation.verifiableCredential = vcs; const EthereumEip712Signature2021obj = new ethereumeip712signature2021suite_1.EthereumEip712Signature2021({}, params.web3Obj); const proof = yield EthereumEip712Signature2021obj.createProof({ document: params.presentation, @@ -394,12 +388,6 @@ class HypersignVerifiablePresentation { const publicKeyId = params.issuerVerificationMethodId; const issuerDidDoc = issuerDID; const publicKeyVerMethod = issuerDidDoc.verificationMethod.find((x) => x.id == publicKeyId); - // TODO: Get rid of this hack later. - // Convert 45 byte publick key into 48 - const { publicKeyMultibase } = utils_1.default.convertedStableLibKeysIntoEd25519verificationkey2020({ - publicKey: publicKeyVerMethod.publicKeyMultibase, - }); - publicKeyVerMethod.publicKeyMultibase = publicKeyMultibase; const assertionController = { '@context': ['DID.CONTROLLER_CONTEXT'], id: issuerDidDoc.id, diff --git a/build/src/schema/ISchema.d.ts b/build/src/schema/ISchema.d.ts index fb7ea95..8a9ed33 100644 --- a/build/src/schema/ISchema.d.ts +++ b/build/src/schema/ISchema.d.ts @@ -3,7 +3,8 @@ * All rights reserved. * Author: Hypermine Core Team */ -import { Schema, SchemaDocument } from '../../libs/generated/ssi/schema'; +import { CredentialSchemaDocument as SchemaDocument } from '../../libs/generated/ssi/credential_schema'; +import { DocumentProof } from '../../libs/generated/ssi/proof'; export interface ISchemaFields { type: string; format?: string; @@ -22,14 +23,17 @@ export interface ISchemaMethods { privateKeyMultibase: string; schema: SchemaDocument; verificationMethodId: string; - }): Promise; + }): Promise; register(params: { - schema: Schema; + schema: IResolveSchema; }): Promise<{ transactionHash: string; }>; resolve(params: { schemaId: string; - }): Promise; + }): Promise; +} +export interface IResolveSchema extends SchemaDocument { + proof?: DocumentProof; } //# sourceMappingURL=ISchema.d.ts.map \ No newline at end of file diff --git a/build/src/schema/ISchema.d.ts.map b/build/src/schema/ISchema.d.ts.map index cd743f3..3e564e4 100644 --- a/build/src/schema/ISchema.d.ts.map +++ b/build/src/schema/ISchema.d.ts.map @@ -1 +1 @@ -{"version":3,"file":"ISchema.d.ts","sourceRoot":"","sources":["../../../src/schema/ISchema.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAA0B,MAAM,EAAE,cAAc,EAAE,MAAM,iCAAiC,CAAC;AACjG,MAAM,WAAW,aAAa;IAC5B,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,EAAE,OAAO,CAAC;CACrB;AAED,MAAM,WAAW,cAAc;IAC7B,QAAQ,CAAC,MAAM,EAAE;QACf,IAAI,EAAE,MAAM,CAAC;QACb,WAAW,CAAC,EAAE,MAAM,CAAC;QACrB,MAAM,EAAE,MAAM,CAAC;QACf,MAAM,CAAC,EAAE,KAAK,CAAC,aAAa,CAAC,CAAC;QAC9B,oBAAoB,EAAE,OAAO,CAAC;KAC/B,GAAG,OAAO,CAAC,cAAc,CAAC,CAAC;IAE5B,IAAI,CAAC,MAAM,EAAE;QAAE,mBAAmB,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,cAAc,CAAC;QAAC,oBAAoB,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;IAErH,QAAQ,CAAC,MAAM,EAAE;QAAE,MAAM,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC;QAAE,eAAe,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IAE3E,OAAO,CAAC,MAAM,EAAE;QAAE,QAAQ,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;CACxD"} \ No newline at end of file +{"version":3,"file":"ISchema.d.ts","sourceRoot":"","sources":["../../../src/schema/ISchema.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAEL,wBAAwB,IAAI,cAAc,EAC3C,MAAM,4CAA4C,CAAC;AACpD,OAAO,EAAE,aAAa,EAAE,MAAM,gCAAgC,CAAC;AAC/D,MAAM,WAAW,aAAa;IAC5B,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,EAAE,OAAO,CAAC;CACrB;AAED,MAAM,WAAW,cAAc;IAC7B,QAAQ,CAAC,MAAM,EAAE;QACf,IAAI,EAAE,MAAM,CAAC;QACb,WAAW,CAAC,EAAE,MAAM,CAAC;QACrB,MAAM,EAAE,MAAM,CAAC;QACf,MAAM,CAAC,EAAE,KAAK,CAAC,aAAa,CAAC,CAAC;QAC9B,oBAAoB,EAAE,OAAO,CAAC;KAC/B,GAAG,OAAO,CAAC,cAAc,CAAC,CAAC;IAE5B,IAAI,CAAC,MAAM,EAAE;QACX,mBAAmB,EAAE,MAAM,CAAC;QAC5B,MAAM,EAAE,cAAc,CAAC;QACvB,oBAAoB,EAAE,MAAM,CAAC;KAC9B,GAAG,OAAO,CAAC,cAAc,CAAC,CAAC;IAE5B,QAAQ,CAAC,MAAM,EAAE;QAAE,MAAM,EAAE,cAAc,CAAA;KAAE,GAAG,OAAO,CAAC;QAAE,eAAe,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IAEnF,OAAO,CAAC,MAAM,EAAE;QAAE,QAAQ,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC,cAAc,CAAC,CAAC;CAChE;AAED,MAAM,WAAW,cAAe,SAAQ,cAAc;IACpD,KAAK,CAAC,EAAE,aAAa,CAAC;CACvB"} \ No newline at end of file diff --git a/build/src/schema/bjjSchema.d.ts b/build/src/schema/bjjSchema.d.ts new file mode 100644 index 0000000..5e12a8b --- /dev/null +++ b/build/src/schema/bjjSchema.d.ts @@ -0,0 +1,111 @@ +/** + * Copyright (c) 2023, Hypermine Pvt. Ltd. + * All rights reserved. + * Author: Hypermine Core Team + */ +import { CredentialSchemaDocument as SchemaDocument, CredentialSchemaProperty as SchemaProperty } from '../../libs/generated/ssi/credential_schema'; +import { SchemaRpc } from './schemaRPC'; +import { ISchemaFields, ISchemaMethods, IResolveSchema } from './ISchema'; +import { OfflineSigner } from '@cosmjs/proto-signing'; +export default class HypersignBJJSchema implements ISchemaMethods { + '@context': Array; + type: string; + modelVersion: string; + id: string; + name: string; + author: string; + authored: string; + schema: SchemaProperty; + schemaRpc: SchemaRpc | null; + namespace: string; + private schemaApiService; + private hsDid; + constructor(params?: { + namespace?: string; + offlineSigner?: OfflineSigner; + nodeRpcEndpoint?: string; + nodeRestEndpoint?: string; + entityApiSecretKey?: string; + }); + private _getSchemaId; + private _getDateTime; + private isPascalCase; + private _jsonLdSign; + /** + * Initialise the offlinesigner to interact with Hypersign blockchain + */ + init(): Promise; + /** + * Generates a new schema doc without proof + * @params + * - params.name : Name of the schema + * - params.description : Optional - Description of the schema + * - params.author : DID of the author + * - params.fields : Schema fields of type ISchemaFields + * - params.additionalProperties : If additionalProperties can be added, boolean + * @returns {Promise} SchemaDocument object + */ + generate(params: { + name: string; + description?: string; + author: string; + fields?: Array; + additionalProperties: boolean; + }): Promise; + /** + * Signs a schema document and attaches proof + * @params + * - params.schema : The schema document without proof + * - params.privateKeyMultibase : Private Key to sign the doc + * - params.verificationMethodId : VerificationMethodId of the document + * @returns {Promise} Schema with proof + */ + sign(params: { + privateKeyMultibase: string; + schema: SchemaDocument; + verificationMethodId: string; + }): Promise; + /** + * Register a schema Document in Hypersign blockchain - an onchain activity + * @params + * - params.schema : The schema document with schemaProof + * @returns {Promise} Result of the registration + */ + register(params: { + schema: IResolveSchema; + }): Promise<{ + transactionHash: string; + }>; + /** + * Resolves a schema document with schemId from Hypersign blockchain - an onchain activity + * @params + * - params.schemaId : Id of the schema document + * @returns {Promise} Returns schema document + */ + resolve(params: { + schemaId: string; + }): Promise; + vcJsonSchema(schemaResolved: IResolveSchema): { + $schema: string; + description: string | undefined; + properties: { + credentialSubject: { + description: string; + title: string; + properties: { + id: { + description: string; + title: string; + format: string; + type: string; + }; + }; + required: string[] | undefined; + type: string; + }; + }; + type: string; + required: string[]; + }; +} +//# sourceMappingURL=bjjSchema.d.ts.map \ No newline at end of file diff --git a/build/src/schema/bjjSchema.d.ts.map b/build/src/schema/bjjSchema.d.ts.map new file mode 100644 index 0000000..25ac0e8 --- /dev/null +++ b/build/src/schema/bjjSchema.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"bjjSchema.d.ts","sourceRoot":"","sources":["../../../src/schema/bjjSchema.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAGL,wBAAwB,IAAI,cAAc,EAC1C,wBAAwB,IAAI,cAAc,EAC3C,MAAM,4CAA4C,CAAC;AAEpD,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAIxC,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAE1E,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAWtD,MAAM,CAAC,OAAO,OAAO,kBAAmB,YAAW,cAAc;IAC/D,UAAU,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;IAC1B,IAAI,EAAE,MAAM,CAAC;IACb,YAAY,EAAE,MAAM,CAAC;IACrB,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,cAAc,CAAC;IACvB,SAAS,EAAE,SAAS,GAAG,IAAI,CAAC;IAC5B,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,CAAC,gBAAgB,CAA0B;IAClD,OAAO,CAAC,KAAK,CAAe;gBAE1B,MAAM,GAAE;QACN,SAAS,CAAC,EAAE,MAAM,CAAC;QACnB,aAAa,CAAC,EAAE,aAAa,CAAC;QAC9B,eAAe,CAAC,EAAE,MAAM,CAAC;QACzB,gBAAgB,CAAC,EAAE,MAAM,CAAC;QAC1B,kBAAkB,CAAC,EAAE,MAAM,CAAC;KACxB;YAgCM,YAAY;IAY1B,OAAO,CAAC,YAAY;IAIpB,OAAO,CAAC,YAAY;YAKN,WAAW;IAyBzB;;OAEG;IACU,IAAI;IAcjB;;;;;;;;;OASG;IACU,QAAQ,CAAC,MAAM,EAAE;QAC5B,IAAI,EAAE,MAAM,CAAC;QACb,WAAW,CAAC,EAAE,MAAM,CAAC;QACrB,MAAM,EAAE,MAAM,CAAC;QACf,MAAM,CAAC,EAAE,KAAK,CAAC,aAAa,CAAC,CAAC;QAC9B,oBAAoB,EAAE,OAAO,CAAC;KAC/B,GAAG,OAAO,CAAC,cAAc,CAAC;IAwD3B;;;;;;;OAOG;IACU,IAAI,CAAC,MAAM,EAAE;QACxB,mBAAmB,EAAE,MAAM,CAAC;QAC5B,MAAM,EAAE,cAAc,CAAC;QACvB,oBAAoB,EAAE,MAAM,CAAC;KAC9B,GAAG,OAAO,CAAC,cAAc,CAAC;IAiC3B;;;;;OAKG;IACU,QAAQ,CAAC,MAAM,EAAE;QAAE,MAAM,EAAE,cAAc,CAAA;KAAE,GAAG,OAAO,CAAC;QAAE,eAAe,EAAE,MAAM,CAAA;KAAE,CAAC;IAiC/F;;;;;OAKG;IACU,OAAO,CAAC,MAAM,EAAE;QAAE,QAAQ,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC,cAAc,CAAC;IA8BpE,YAAY,CAAC,cAAc,EAAE,cAAc;;;;;;;;;;;;;;;;;;;;;;CAsEnD"} \ No newline at end of file diff --git a/build/src/schema/bjjSchema.js b/build/src/schema/bjjSchema.js new file mode 100644 index 0000000..075980f --- /dev/null +++ b/build/src/schema/bjjSchema.js @@ -0,0 +1,381 @@ +"use strict"; +/** + * Copyright (c) 2023, Hypermine Pvt. Ltd. + * All rights reserved. + * Author: Hypermine Core Team + */ +var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + var desc = Object.getOwnPropertyDescriptor(m, k); + if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { + desc = { enumerable: true, get: function() { return m[k]; } }; + } + Object.defineProperty(o, k2, desc); +}) : (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + o[k2] = m[k]; +})); +var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { + Object.defineProperty(o, "default", { enumerable: true, value: v }); +}) : function(o, v) { + o["default"] = v; +}); +var __importStar = (this && this.__importStar) || function (mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); + __setModuleDefault(result, mod); + return result; +}; +var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { + function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } + return new (P || (P = Promise))(function (resolve, reject) { + function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } + function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } + function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } + step((generator = generator.apply(thisArg, _arguments || [])).next()); + }); +}; +var __importDefault = (this && this.__importDefault) || function (mod) { + return (mod && mod.__esModule) ? mod : { "default": mod }; +}; +Object.defineProperty(exports, "__esModule", { value: true }); +const schemaRPC_1 = require("./schemaRPC"); +const constants = __importStar(require("../constants")); +const jsonld_signatures_1 = __importDefault(require("jsonld-signatures")); +const { AssertionProofPurpose } = jsonld_signatures_1.default.purposes; +const utils_1 = __importDefault(require("../utils")); +const jsonld_signatures_2 = require("jsonld-signatures"); +const schema_service_1 = __importDefault(require("../ssiApi/services/schema/schema.service")); +const v1_1 = __importDefault(require("../../libs/w3cache/v1")); +const documentLoader = (0, jsonld_signatures_2.extendContextLoader)(v1_1.default); +const did_1 = __importDefault(require("../did/did")); +const babyjubjub2021_1 = require("babyjubjub2021"); +const babyjubjubsignature2021_1 = require("babyjubjubsignature2021"); +class HypersignBJJSchema { + constructor(params = {}) { + const { namespace, offlineSigner, nodeRpcEndpoint, nodeRestEndpoint, entityApiSecretKey } = params; + const nodeRPCEp = nodeRpcEndpoint ? nodeRpcEndpoint : 'MAIN'; + const nodeRestEp = nodeRestEndpoint ? nodeRestEndpoint : ''; + this.schemaRpc = new schemaRPC_1.SchemaRpc({ offlineSigner, nodeRpcEndpoint: nodeRPCEp, nodeRestEndpoint: nodeRestEp }); + this.hsDid = new did_1.default({ offlineSigner, nodeRpcEndpoint: nodeRPCEp, nodeRestEndpoint: nodeRestEp }); + if (entityApiSecretKey && entityApiSecretKey != '') { + this.schemaApiService = new schema_service_1.default(entityApiSecretKey); + this.schemaRpc = null; + } + else { + this.schemaApiService = null; + } + this['@context'] = [constants.SCHEMA.SCHEMA_CONTEXT, constants.DID_BabyJubJubKey2021.BABYJUBJUBSIGNATURE]; + this.namespace = namespace && namespace != '' ? namespace : ''; + (this.type = constants.SCHEMA.SCHEMA_TYPE), + (this.modelVersion = '1.0'), + (this.id = ''), + (this.name = ''), + (this.author = ''), + (this.authored = ''); + this.schema = { + schema: '', + description: '', + type: '', + properties: '', + required: [], + additionalProperties: false, + }; + } + // Ref: + _getSchemaId() { + return __awaiter(this, void 0, void 0, function* () { + const b = yield utils_1.default.getUUID(); + // ID Structure -> sch:::: + let id; + if (this.namespace && this.namespace != '') { + id = `${constants.SCHEMA.SCHEME}:${constants.SCHEMA.METHOD}:${this.namespace}:${b}:${this.modelVersion}`; + } + else { + id = `${constants.SCHEMA.SCHEME}:${constants.SCHEMA.METHOD}:${b}:${this.modelVersion}`; + } + return id; + }); + } + _getDateTime() { + return new Date(new Date().getTime() - 100000).toISOString().slice(0, -5) + 'Z'; + } + isPascalCase(inputString) { + const pattern = /^[A-Z][a-zA-Z0-9]*$/; + return pattern.test(inputString); + } + _jsonLdSign(params) { + return __awaiter(this, void 0, void 0, function* () { + const { schema, privateKeyMultibase, verificationMethodId } = params; + const keyPair = yield babyjubjub2021_1.BabyJubJubKeys2021.fromKeys({ + options: { + controller: verificationMethodId, + id: verificationMethodId, + }, + privateKeyMultibase: privateKeyMultibase, + publicKeyMultibase: params.publicKeyMultibase, + }); + const suite = new babyjubjubsignature2021_1.BabyJubJubSignature2021Suite({ key: keyPair }); + const signedSchema = yield jsonld_signatures_1.default.sign(schema, { + suite, + purpose: new AssertionProofPurpose(), + documentLoader, + }); + return signedSchema.proof; + }); + } + /** + * Initialise the offlinesigner to interact with Hypersign blockchain + */ + init() { + return __awaiter(this, void 0, void 0, function* () { + if (!this.schemaRpc && !this.schemaApiService) { + throw new Error('HID-SSI-SDK:: Error: HypersignVerifiableCredential class is not instantiated with Offlinesigner or have not been initilized with entityApiSecretKey'); + } + if (this.schemaRpc) { + yield this.schemaRpc.init(); + } + if (this.schemaApiService) { + yield this.schemaApiService.auth(); + } + }); + } + /** + * Generates a new schema doc without proof + * @params + * - params.name : Name of the schema + * - params.description : Optional - Description of the schema + * - params.author : DID of the author + * - params.fields : Schema fields of type ISchemaFields + * - params.additionalProperties : If additionalProperties can be added, boolean + * @returns {Promise} SchemaDocument object + */ + generate(params) { + var _a; + return __awaiter(this, void 0, void 0, function* () { + if (!params.author) + throw new Error('HID-SSI-SDK:: Error: Author must be passed'); + if (!this.isPascalCase(params.name)) + throw new Error('HID-SSI-SDK:: Error: schema name should always be in PascalCase'); + this['@context'] = [constants.SCHEMA.SCHEMA_CONTEXT, constants.DID_BabyJubJubKey2021.BABYJUBJUBSIGNATURE]; + this.id = yield this._getSchemaId(); + this.name = params.name; + this.author = params.author; + this.authored = this._getDateTime(); + this.schema = { + schema: constants.SCHEMA.SCHEMA_JSON, + description: params.description ? params.description : '', + type: 'https://schema.org/object', + properties: '', + required: [], + additionalProperties: params.additionalProperties, + }; + const t = {}; + if (params.fields && params.fields.length > 0) { + params.fields.forEach((prop) => { + var _a; + if (!prop.name) + throw new Error("HID-SSI-SDK:: Error: All fields must contains property 'name'"); + const schemaPropsObj = {}; + schemaPropsObj.propName = prop.name; + schemaPropsObj.val = {}; + schemaPropsObj.val.type = (_a = prop === null || prop === void 0 ? void 0 : prop.type) !== null && _a !== void 0 ? _a : 'string'; + if (prop.format) + schemaPropsObj.val.format = prop.format; + t[schemaPropsObj.propName] = schemaPropsObj.val; + if (prop.isRequired) { + this.schema.required.push(prop.name); + } + }); + this.schema.properties = JSON.stringify(t); + } + if (!this.schema.additionalProperties) { + delete this.schema.additionalProperties; + } + if (((_a = this.schema.required) === null || _a === void 0 ? void 0 : _a.length) == 0) { + delete this.schema.required; + } + return { + '@context': this['@context'], + type: this.type, + modelVersion: this.modelVersion, + id: this.id, + name: this.name, + author: this.author, + authored: this.authored, + schema: this.schema, + }; + }); + } + /** + * Signs a schema document and attaches proof + * @params + * - params.schema : The schema document without proof + * - params.privateKeyMultibase : Private Key to sign the doc + * - params.verificationMethodId : VerificationMethodId of the document + * @returns {Promise} Schema with proof + */ + sign(params) { + return __awaiter(this, void 0, void 0, function* () { + if (!params.privateKeyMultibase) + throw new Error('HID-SSI-SDK:: Error: params.privateKeyMultibase must be passed'); + if (!params.verificationMethodId) + throw new Error('HID-SSI-SDK:: Error: params.verificationMethodId must be passed'); + if (!params.schema) + throw new Error('HID-SSI-SDK:: Error: Schema must be passed'); + const { schema, privateKeyMultibase, verificationMethodId } = params; + const schemaDoc = params.schema; + const { didDocument } = yield this.hsDid.resolve({ did: schema.author }); + if (!didDocument) { + throw new Error('HID-SSI-SDK:: Error: can not resolve the author'); + } + const verificationMethod = didDocument['verificationMethod'].find((x) => x.id == verificationMethodId); + if (!verificationMethod) { + throw new Error('HID-SSI-SDK:: Error: verificationMethod not matched'); + } + const proof = yield this._jsonLdSign({ + schema, + privateKeyMultibase, + verificationMethodId, + publicKeyMultibase: verificationMethod.publicKeyMultibase, + }); + schemaDoc['proof'] = {}; + const schemaToReturn = schemaDoc; + if (proof) { + schemaToReturn['proof'] = Object.assign(Object.assign({}, schemaToReturn['proof']), proof); + } + return schemaToReturn; + }); + } + /** + * Register a schema Document in Hypersign blockchain - an onchain activity + * @params + * - params.schema : The schema document with schemaProof + * @returns {Promise} Result of the registration + */ + register(params) { + return __awaiter(this, void 0, void 0, function* () { + if (!params.schema) + throw new Error('HID-SSI-SDK:: Error: schema must be passed'); + if (!params.schema['proof']) + throw new Error('HID-SSI-SDK:: Error: schema.proof must be passed'); + if (!params.schema['proof'].created) + throw new Error('HID-SSI-SDK:: Error: schema.proof must Contain created'); + if (!params.schema['proof'].proofPurpose) + throw new Error('HID-SSI-SDK:: Error: schema.proof must Contain proofPurpose'); + if (!params.schema['proof'].proofValue) + throw new Error('HID-SSI-SDK:: Error: schema.proof must Contain proofValue'); + if (!params.schema['proof'].type) + throw new Error('HID-SSI-SDK:: Error: schema.proof must Contain type'); + if (!params.schema['proof'].verificationMethod) + throw new Error('HID-SSI-SDK:: Error: schema.proof must Contain verificationMethod'); + if (!this.schemaRpc && !this.schemaApiService) { + throw new Error('HID-SSI-SDK:: Error: HypersignSchema class is not instantiated with Offlinesigner or have not been initilized with entityApiSecret'); + } + const response = {}; + const schemaDoc = params.schema; + const proof = schemaDoc['proof']; + if (this.schemaRpc) { + const result = yield this.schemaRpc.registerSchema(schemaDoc, proof); + response.transactionHash = result.transactionHash; + } + else if (this.schemaApiService) { + const result = yield this.schemaApiService.registerSchema({ + schemaDocument: params.schema, + schemaProof: params.schema['proof'], + }); + response.transactionHash = result.transactionHash; + } + return response; + }); + } + /** + * Resolves a schema document with schemId from Hypersign blockchain - an onchain activity + * @params + * - params.schemaId : Id of the schema document + * @returns {Promise} Returns schema document + */ + resolve(params) { + return __awaiter(this, void 0, void 0, function* () { + if (!params.schemaId) + throw new Error('HID-SSI-SDK:: Error: SchemaId must be passed'); + if (!this.schemaRpc) { + throw new Error('HID-SSI-SDK:: Error: HypersignSchema class is not instantiated with Offlinesigner or have not been initilized'); + } + const schemaArr = yield this.schemaRpc.resolveSchema(params.schemaId); + if (!schemaArr || schemaArr.length < 0) { + throw new Error('HID-SSI-SDK:: Error: No schema found, id = ' + params.schemaId); + } + const schemaT = schemaArr[0]; + const schema = { + credentialSchemaDocument: schemaArr[0].schema ? schemaArr[0] : schemaT.credentialSchemaDocument, + credentialSchemaProof: schemaArr[0].proof ? schemaArr[0].proof : schemaT.credentialSchemaProof, + }; + const response = Object.assign(Object.assign({}, schema.credentialSchemaDocument), { proof: schema.credentialSchemaProof }); + // Competable Schema with https://www.w3.org/TR/vc-json-schema/#jsonschema currently not used + return response; + }); + } + vcJsonSchema(schemaResolved) { + var _a, _b, _c; + const schemaWrapper = schemaResolved; + const properties = JSON.parse((_a = schemaResolved.schema) === null || _a === void 0 ? void 0 : _a.properties); + const ld = {}; + const schemaProp = {}; + Object.entries(properties).forEach((elm) => { + ld[elm[0]] = { + '@id': 'https://hypersign-schema.org/' + elm[0], + // eslint-disable-next-line @typescript-eslint/ban-ts-comment + // @ts-ignore + '@type': 'xsd:' + elm[1].type, + }; + schemaProp[elm[0]] = { + description: `Enter value for ${elm[0]}`, + title: `${elm[0]}`, + // eslint-disable-next-line @typescript-eslint/ban-ts-comment + // @ts-ignore + type: elm[1].type, + }; + }); + const jsonLdcontext = { + '@protected': true, + '@version': 1.1, + id: '@id', + type: '@type', + // eslint-disable-next-line @typescript-eslint/ban-ts-comment + // @ts-ignore + [schemaWrapper.name]: { + '@context': Object.assign({ '@propagate': true, '@protected': true, xsd: 'http://www.w3.org/2001/XMLSchema#' }, ld), + '@id': 'https://hypersign-schema.org', + }, + }; + const schemaDoc = { + $schema: 'https://json-schema.org/draft/2020-12/schema', + description: (_b = schemaWrapper.schema) === null || _b === void 0 ? void 0 : _b.description, + properties: { + credentialSubject: { + description: 'Stores the data of the credential', + title: 'Credential subject', + properties: Object.assign({ id: { + description: 'Stores the DID of the subject that owns the credential', + title: 'Credential subject ID', + format: 'uri', + type: 'string', + } }, schemaProp), + required: (_c = schemaWrapper.schema) === null || _c === void 0 ? void 0 : _c.required, + type: 'object', + }, + }, + type: 'object', + required: ['credentialSubject'], + }; + schemaDoc['$metadata'] = { + type: schemaWrapper.name, + version: 1.0, + jsonLdContext: { '@context': Object.assign({}, jsonLdcontext) }, + }; + return schemaDoc; + } +} +exports.default = HypersignBJJSchema; diff --git a/build/src/schema/schema.d.ts b/build/src/schema/schema.d.ts index 61202b8..71f35ea 100644 --- a/build/src/schema/schema.d.ts +++ b/build/src/schema/schema.d.ts @@ -3,11 +3,13 @@ * All rights reserved. * Author: Hypermine Core Team */ -import { Schema, SchemaDocument, SchemaProperty } from '../../libs/generated/ssi/schema'; +import { CredentialSchemaDocument as SchemaDocument, CredentialSchemaProperty as SchemaProperty } from '../../libs/generated/ssi/credential_schema'; import { SchemaRpc } from './schemaRPC'; -import { ISchemaFields, ISchemaMethods } from './ISchema'; +import { ISchemaFields, ISchemaMethods, IResolveSchema } from './ISchema'; import { OfflineSigner } from '@cosmjs/proto-signing'; +import HypersignBJJSchema from './bjjSchema'; export default class HyperSignSchema implements ISchemaMethods { + '@context': Array; type: string; modelVersion: string; id: string; @@ -18,6 +20,8 @@ export default class HyperSignSchema implements ISchemaMethods { schemaRpc: SchemaRpc | null; namespace: string; private schemaApiService; + private hsDid; + hypersignBjjschema: HypersignBJJSchema; constructor(params?: { namespace?: string; offlineSigner?: OfflineSigner; @@ -27,6 +31,8 @@ export default class HyperSignSchema implements ISchemaMethods { }); private _getSchemaId; private _getDateTime; + private isPascalCase; + private _jsonLdSign; /** * Initialise the offlinesigner to interact with Hypersign blockchain */ @@ -54,13 +60,13 @@ export default class HyperSignSchema implements ISchemaMethods { * - params.schema : The schema document without proof * - params.privateKeyMultibase : Private Key to sign the doc * - params.verificationMethodId : VerificationMethodId of the document - * @returns {Promise} Schema with proof + * @returns {Promise} Schema with proof */ sign(params: { privateKeyMultibase: string; schema: SchemaDocument; verificationMethodId: string; - }): Promise; + }): Promise; /** * Register a schema Document in Hypersign blockchain - an onchain activity * @params @@ -68,7 +74,7 @@ export default class HyperSignSchema implements ISchemaMethods { * @returns {Promise} Result of the registration */ register(params: { - schema: Schema; + schema: IResolveSchema; }): Promise<{ transactionHash: string; }>; @@ -76,10 +82,32 @@ export default class HyperSignSchema implements ISchemaMethods { * Resolves a schema document with schemId from Hypersign blockchain - an onchain activity * @params * - params.schemaId : Id of the schema document - * @returns {Promise} Returns schema document + * @returns {Promise} Returns schema document */ resolve(params: { schemaId: string; - }): Promise; + }): Promise; + vcJsonSchema(schemaResolved: IResolveSchema): { + $schema: string; + description: string | undefined; + properties: { + credentialSubject: { + description: string; + title: string; + properties: { + id: { + description: string; + title: string; + format: string; + type: string; + }; + }; + required: string[] | undefined; + type: string; + }; + }; + type: string; + required: string[]; + }; } //# sourceMappingURL=schema.d.ts.map \ No newline at end of file diff --git a/build/src/schema/schema.d.ts.map b/build/src/schema/schema.d.ts.map index 97d87de..18177ce 100644 --- a/build/src/schema/schema.d.ts.map +++ b/build/src/schema/schema.d.ts.map @@ -1 +1 @@ -{"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../../src/schema/schema.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,MAAM,EAAE,cAAc,EAAe,cAAc,EAAE,MAAM,iCAAiC,CAAC;AACtG,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAExC,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAE1D,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAKtD,MAAM,CAAC,OAAO,OAAO,eAAgB,YAAW,cAAc;IAC5D,IAAI,EAAE,MAAM,CAAC;IACb,YAAY,EAAE,MAAM,CAAC;IACrB,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,cAAc,CAAC;IACvB,SAAS,EAAE,SAAS,GAAG,IAAI,CAAC;IAC5B,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,CAAC,gBAAgB,CAA0B;gBAEhD,MAAM,GAAE;QACN,SAAS,CAAC,EAAE,MAAM,CAAC;QACnB,aAAa,CAAC,EAAE,aAAa,CAAC;QAC9B,eAAe,CAAC,EAAE,MAAM,CAAC;QACzB,gBAAgB,CAAC,EAAE,MAAM,CAAC;QAC1B,kBAAkB,CAAC,EAAE,MAAM,CAAC;KACxB;YA8BM,YAAY;IAY1B,OAAO,CAAC,YAAY;IAIpB;;OAEG;IACU,IAAI;IAcjB;;;;;;;;;OASG;IACU,QAAQ,CAAC,MAAM,EAAE;QAC5B,IAAI,EAAE,MAAM,CAAC;QACb,WAAW,CAAC,EAAE,MAAM,CAAC;QACrB,MAAM,EAAE,MAAM,CAAC;QACf,MAAM,CAAC,EAAE,KAAK,CAAC,aAAa,CAAC,CAAC;QAC9B,oBAAoB,EAAE,OAAO,CAAC;KAC/B,GAAG,OAAO,CAAC,cAAc,CAAC;IAkD3B;;;;;;;OAOG;IACU,IAAI,CAAC,MAAM,EAAE;QACxB,mBAAmB,EAAE,MAAM,CAAC;QAC5B,MAAM,EAAE,cAAc,CAAC;QACvB,oBAAoB,EAAE,MAAM,CAAC;KAC9B,GAAG,OAAO,CAAC,MAAM,CAAC;IA2BnB;;;;;OAKG;IACU,QAAQ,CAAC,MAAM,EAAE;QAAE,MAAM,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC;QAAE,eAAe,EAAE,MAAM,CAAA;KAAE,CAAC;IA8BvF;;;;;OAKG;IACU,OAAO,CAAC,MAAM,EAAE;QAAE,QAAQ,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC,MAAM,CAAC;CAepE"} \ No newline at end of file +{"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../../src/schema/schema.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAGL,wBAAwB,IAAI,cAAc,EAC1C,wBAAwB,IAAI,cAAc,EAC3C,MAAM,4CAA4C,CAAC;AAEpD,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAIxC,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAE1E,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAWtD,OAAO,kBAAkB,MAAM,aAAa,CAAC;AAC7C,MAAM,CAAC,OAAO,OAAO,eAAgB,YAAW,cAAc;IAC5D,UAAU,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;IAC1B,IAAI,EAAE,MAAM,CAAC;IACb,YAAY,EAAE,MAAM,CAAC;IACrB,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,cAAc,CAAC;IACvB,SAAS,EAAE,SAAS,GAAG,IAAI,CAAC;IAC5B,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,CAAC,gBAAgB,CAA0B;IAClD,OAAO,CAAC,KAAK,CAAe;IACrB,kBAAkB,EAAE,kBAAkB,CAAC;gBAE5C,MAAM,GAAE;QACN,SAAS,CAAC,EAAE,MAAM,CAAC;QACnB,aAAa,CAAC,EAAE,aAAa,CAAC;QAC9B,eAAe,CAAC,EAAE,MAAM,CAAC;QACzB,gBAAgB,CAAC,EAAE,MAAM,CAAC;QAC1B,kBAAkB,CAAC,EAAE,MAAM,CAAC;KACxB;YAiCM,YAAY;IAY1B,OAAO,CAAC,YAAY;IAIpB,OAAO,CAAC,YAAY;YAIN,WAAW;IAqBzB;;OAEG;IACU,IAAI;IAcjB;;;;;;;;;OASG;IACU,QAAQ,CAAC,MAAM,EAAE;QAC5B,IAAI,EAAE,MAAM,CAAC;QACb,WAAW,CAAC,EAAE,MAAM,CAAC;QACrB,MAAM,EAAE,MAAM,CAAC;QACf,MAAM,CAAC,EAAE,KAAK,CAAC,aAAa,CAAC,CAAC;QAC9B,oBAAoB,EAAE,OAAO,CAAC;KAC/B,GAAG,OAAO,CAAC,cAAc,CAAC;IA2D3B;;;;;;;OAOG;IACU,IAAI,CAAC,MAAM,EAAE;QACxB,mBAAmB,EAAE,MAAM,CAAC;QAC5B,MAAM,EAAE,cAAc,CAAC;QACvB,oBAAoB,EAAE,MAAM,CAAC;KAC9B,GAAG,OAAO,CAAC,cAAc,CAAC;IAiC3B;;;;;OAKG;IACU,QAAQ,CAAC,MAAM,EAAE;QAAE,MAAM,EAAE,cAAc,CAAA;KAAE,GAAG,OAAO,CAAC;QAAE,eAAe,EAAE,MAAM,CAAA;KAAE,CAAC;IAiC/F;;;;;OAKG;IACU,OAAO,CAAC,MAAM,EAAE;QAAE,QAAQ,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC,cAAc,CAAC;IA8BpE,YAAY,CAAC,cAAc,EAAE,cAAc;;;;;;;;;;;;;;;;;;;;;;CAsEnD"} \ No newline at end of file diff --git a/build/src/schema/schema.js b/build/src/schema/schema.js index 8501f2d..9eaffb2 100644 --- a/build/src/schema/schema.js +++ b/build/src/schema/schema.js @@ -40,18 +40,26 @@ var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); -const schema_1 = require("../../libs/generated/ssi/schema"); const schemaRPC_1 = require("./schemaRPC"); const constants = __importStar(require("../constants")); +const jsonld_signatures_1 = __importDefault(require("jsonld-signatures")); +const { AssertionProofPurpose } = jsonld_signatures_1.default.purposes; const utils_1 = __importDefault(require("../utils")); +const jsonld_signatures_2 = require("jsonld-signatures"); +const ed25519_signature_2020_1 = require("@digitalbazaar/ed25519-signature-2020"); const schema_service_1 = __importDefault(require("../ssiApi/services/schema/schema.service")); -const ed25519 = require('@stablelib/ed25519'); +const v1_1 = __importDefault(require("../../libs/w3cache/v1")); +const documentLoader = (0, jsonld_signatures_2.extendContextLoader)(v1_1.default); +const ed25519_verification_key_2020_1 = require("@digitalbazaar/ed25519-verification-key-2020"); +const did_1 = __importDefault(require("../did/did")); +const bjjSchema_1 = __importDefault(require("./bjjSchema")); class HyperSignSchema { constructor(params = {}) { const { namespace, offlineSigner, nodeRpcEndpoint, nodeRestEndpoint, entityApiSecretKey } = params; const nodeRPCEp = nodeRpcEndpoint ? nodeRpcEndpoint : 'MAIN'; const nodeRestEp = nodeRestEndpoint ? nodeRestEndpoint : ''; this.schemaRpc = new schemaRPC_1.SchemaRpc({ offlineSigner, nodeRpcEndpoint: nodeRPCEp, nodeRestEndpoint: nodeRestEp }); + this.hsDid = new did_1.default({ offlineSigner, nodeRpcEndpoint: nodeRPCEp, nodeRestEndpoint: nodeRestEp }); if (entityApiSecretKey && entityApiSecretKey != '') { this.schemaApiService = new schema_service_1.default(entityApiSecretKey); this.schemaRpc = null; @@ -59,6 +67,7 @@ class HyperSignSchema { else { this.schemaApiService = null; } + this['@context'] = [constants.SCHEMA.SCHEMA_CONTEXT]; this.namespace = namespace && namespace != '' ? namespace : ''; (this.type = constants.SCHEMA.SCHEMA_TYPE), (this.modelVersion = '1.0'), @@ -74,6 +83,7 @@ class HyperSignSchema { required: [], additionalProperties: false, }; + this.hypersignBjjschema = new bjjSchema_1.default(params); } // Ref: _getSchemaId() { @@ -93,6 +103,27 @@ class HyperSignSchema { _getDateTime() { return new Date(new Date().getTime() - 100000).toISOString().slice(0, -5) + 'Z'; } + isPascalCase(inputString) { + const pattern = /^[A-Z][a-zA-Z0-9]*$/; + return pattern.test(inputString); + } + _jsonLdSign(params) { + return __awaiter(this, void 0, void 0, function* () { + const { schema, privateKeyMultibase, verificationMethodId } = params; + const keyPair = yield ed25519_verification_key_2020_1.Ed25519VerificationKey2020.from({ + id: verificationMethodId, + privateKeyMultibase: privateKeyMultibase, + publicKeyMultibase: params.publicKeyMultibase, + }); + const suite = new ed25519_signature_2020_1.Ed25519Signature2020({ key: keyPair }); + const signedSchema = yield jsonld_signatures_1.default.sign(schema, { + suite, + purpose: new AssertionProofPurpose(), + documentLoader, + }); + return signedSchema.proof; + }); + } /** * Initialise the offlinesigner to interact with Hypersign blockchain */ @@ -120,9 +151,13 @@ class HyperSignSchema { * @returns {Promise} SchemaDocument object */ generate(params) { + var _a; return __awaiter(this, void 0, void 0, function* () { if (!params.author) throw new Error('HID-SSI-SDK:: Error: Author must be passed'); + if (!this.isPascalCase(params.name)) + throw new Error('HID-SSI-SDK:: Error: schema name should always be in PascalCase'); + this['@context'] = [constants.SCHEMA.SCHEMA_CONTEXT]; this.id = yield this._getSchemaId(); this.name = params.name; this.author = params.author; @@ -130,7 +165,7 @@ class HyperSignSchema { this.schema = { schema: constants.SCHEMA.SCHEMA_JSON, description: params.description ? params.description : '', - type: 'object', + type: 'https://schema.org/object', properties: '', required: [], additionalProperties: params.additionalProperties, @@ -138,10 +173,13 @@ class HyperSignSchema { const t = {}; if (params.fields && params.fields.length > 0) { params.fields.forEach((prop) => { + var _a; + if (!prop.name) + throw new Error("HID-SSI-SDK:: Error: All fields must contains property 'name'"); const schemaPropsObj = {}; schemaPropsObj.propName = prop.name; schemaPropsObj.val = {}; - schemaPropsObj.val.type = prop.type; + schemaPropsObj.val.type = (_a = prop === null || prop === void 0 ? void 0 : prop.type) !== null && _a !== void 0 ? _a : 'string'; if (prop.format) schemaPropsObj.val.format = prop.format; t[schemaPropsObj.propName] = schemaPropsObj.val; @@ -151,7 +189,14 @@ class HyperSignSchema { }); this.schema.properties = JSON.stringify(t); } + if (!this.schema.additionalProperties) { + delete this.schema.additionalProperties; + } + if (((_a = this.schema.required) === null || _a === void 0 ? void 0 : _a.length) == 0) { + delete this.schema.required; + } return { + '@context': this['@context'], type: this.type, modelVersion: this.modelVersion, id: this.id, @@ -168,7 +213,7 @@ class HyperSignSchema { * - params.schema : The schema document without proof * - params.privateKeyMultibase : Private Key to sign the doc * - params.verificationMethodId : VerificationMethodId of the document - * @returns {Promise} Schema with proof + * @returns {Promise} Schema with proof */ sign(params) { return __awaiter(this, void 0, void 0, function* () { @@ -178,22 +223,28 @@ class HyperSignSchema { throw new Error('HID-SSI-SDK:: Error: params.verificationMethodId must be passed'); if (!params.schema) throw new Error('HID-SSI-SDK:: Error: Schema must be passed'); - const { privateKeyMultibase: privateKeyMultibaseConverted } = utils_1.default.convertEd25519verificationkey2020toStableLibKeysInto({ - privKey: params.privateKeyMultibase, - }); + const { schema, privateKeyMultibase, verificationMethodId } = params; const schemaDoc = params.schema; - const dataBytes = (yield schema_1.Schema.encode(schemaDoc)).finish(); - const signed = ed25519.sign(privateKeyMultibaseConverted, dataBytes); - const proof = { - type: constants.SCHEMA.SIGNATURE_TYPE, - created: this._getDateTime(), - verificationMethod: params.verificationMethodId, - proofPurpose: constants.SCHEMA.PROOF_PURPOSE, - proofValue: Buffer.from(signed).toString('base64'), - }; - schemaDoc.proof = {}; - Object.assign(schemaDoc.proof, Object.assign({}, proof)); - return schemaDoc; + const { didDocument } = yield this.hsDid.resolve({ did: schema.author }); + if (!didDocument) { + throw new Error('HID-SSI-SDK:: Error: can not resolve the author'); + } + const verificationMethod = didDocument['verificationMethod'].find((x) => x.id == verificationMethodId); + if (!verificationMethod) { + throw new Error('HID-SSI-SDK:: Error: verificationMethod not matched'); + } + const proof = yield this._jsonLdSign({ + schema, + privateKeyMultibase, + verificationMethodId, + publicKeyMultibase: verificationMethod.publicKeyMultibase, + }); + schemaDoc['proof'] = {}; + const schemaToReturn = schemaDoc; + if (proof) { + schemaToReturn['proof'] = Object.assign(Object.assign({}, schemaToReturn['proof']), proof); + } + return schemaToReturn; }); } /** @@ -206,30 +257,32 @@ class HyperSignSchema { return __awaiter(this, void 0, void 0, function* () { if (!params.schema) throw new Error('HID-SSI-SDK:: Error: schema must be passed'); - if (!params.schema.proof) + if (!params.schema['proof']) throw new Error('HID-SSI-SDK:: Error: schema.proof must be passed'); - if (!params.schema.proof.created) + if (!params.schema['proof'].created) throw new Error('HID-SSI-SDK:: Error: schema.proof must Contain created'); - if (!params.schema.proof.proofPurpose) + if (!params.schema['proof'].proofPurpose) throw new Error('HID-SSI-SDK:: Error: schema.proof must Contain proofPurpose'); - if (!params.schema.proof.proofValue) + if (!params.schema['proof'].proofValue) throw new Error('HID-SSI-SDK:: Error: schema.proof must Contain proofValue'); - if (!params.schema.proof.type) + if (!params.schema['proof'].type) throw new Error('HID-SSI-SDK:: Error: schema.proof must Contain type'); - if (!params.schema.proof.verificationMethod) + if (!params.schema['proof'].verificationMethod) throw new Error('HID-SSI-SDK:: Error: schema.proof must Contain verificationMethod'); if (!this.schemaRpc && !this.schemaApiService) { throw new Error('HID-SSI-SDK:: Error: HypersignSchema class is not instantiated with Offlinesigner or have not been initilized with entityApiSecret'); } const response = {}; + const schemaDoc = params.schema; + const proof = schemaDoc['proof']; if (this.schemaRpc) { - const result = yield this.schemaRpc.createSchema(params.schema, params.schema.proof); + const result = yield this.schemaRpc.registerSchema(schemaDoc, proof); response.transactionHash = result.transactionHash; } else if (this.schemaApiService) { const result = yield this.schemaApiService.registerSchema({ schemaDocument: params.schema, - schemaProof: params.schema.proof, + schemaProof: params.schema['proof'], }); response.transactionHash = result.transactionHash; } @@ -240,7 +293,7 @@ class HyperSignSchema { * Resolves a schema document with schemId from Hypersign blockchain - an onchain activity * @params * - params.schemaId : Id of the schema document - * @returns {Promise} Returns schema document + * @returns {Promise} Returns schema document */ resolve(params) { return __awaiter(this, void 0, void 0, function* () { @@ -253,9 +306,75 @@ class HyperSignSchema { if (!schemaArr || schemaArr.length < 0) { throw new Error('HID-SSI-SDK:: Error: No schema found, id = ' + params.schemaId); } - const schema = schemaArr[0]; - return schema; + const schemaT = schemaArr[0]; + const schema = { + credentialSchemaDocument: schemaArr[0].schema ? schemaArr[0] : schemaT.credentialSchemaDocument, + credentialSchemaProof: schemaArr[0].proof ? schemaArr[0].proof : schemaT.credentialSchemaProof, + }; + const response = Object.assign(Object.assign({}, schema.credentialSchemaDocument), { proof: schema.credentialSchemaProof }); + // Competable Schema with https://www.w3.org/TR/vc-json-schema/#jsonschema currently not used + return response; + }); + } + vcJsonSchema(schemaResolved) { + var _a, _b, _c; + const schemaWrapper = schemaResolved; + const properties = JSON.parse((_a = schemaResolved.schema) === null || _a === void 0 ? void 0 : _a.properties); + const ld = {}; + const schemaProp = {}; + Object.entries(properties).forEach((elm) => { + ld[elm[0]] = { + '@id': 'https://hypersign-schema.org/' + elm[0], + // eslint-disable-next-line @typescript-eslint/ban-ts-comment + // @ts-ignore + '@type': 'xsd:' + elm[1].type, + }; + schemaProp[elm[0]] = { + description: `Enter value for ${elm[0]}`, + title: `${elm[0]}`, + // eslint-disable-next-line @typescript-eslint/ban-ts-comment + // @ts-ignore + type: elm[1].type, + }; }); + const jsonLdcontext = { + '@protected': true, + '@version': 1.1, + id: '@id', + type: '@type', + // eslint-disable-next-line @typescript-eslint/ban-ts-comment + // @ts-ignore + [schemaWrapper.name]: { + '@context': Object.assign({ '@propagate': true, '@protected': true, xsd: 'http://www.w3.org/2001/XMLSchema#' }, ld), + '@id': 'https://hypersign-schema.org', + }, + }; + const schemaDoc = { + $schema: 'https://json-schema.org/draft/2020-12/schema', + description: (_b = schemaWrapper.schema) === null || _b === void 0 ? void 0 : _b.description, + properties: { + credentialSubject: { + description: 'Stores the data of the credential', + title: 'Credential subject', + properties: Object.assign({ id: { + description: 'Stores the DID of the subject that owns the credential', + title: 'Credential subject ID', + format: 'uri', + type: 'string', + } }, schemaProp), + required: (_c = schemaWrapper.schema) === null || _c === void 0 ? void 0 : _c.required, + type: 'object', + }, + }, + type: 'object', + required: ['credentialSubject'], + }; + schemaDoc['$metadata'] = { + type: schemaWrapper.name, + version: 1.0, + jsonLdContext: { '@context': Object.assign({}, jsonLdcontext) }, + }; + return schemaDoc; } } exports.default = HyperSignSchema; diff --git a/build/src/schema/schemaRPC.d.ts b/build/src/schema/schemaRPC.d.ts index c9c7f50..f22d43b 100644 --- a/build/src/schema/schemaRPC.d.ts +++ b/build/src/schema/schemaRPC.d.ts @@ -4,22 +4,25 @@ * Author: Hypermine Core Team */ import { OfflineSigner } from '@cosmjs/proto-signing'; -import { Schema, SchemaProof } from '../../libs/generated/ssi/schema'; +import { CredentialSchemaDocument } from '../../libs/generated/ssi/credential_schema'; +import { DocumentProof as SchemaProof } from '../../libs/generated/ssi/proof'; import { DeliverTxResponse } from '@cosmjs/stargate'; +import { CredentialSchemaDocument as SchemaDocument } from '../../libs/generated/ssi/credential_schema'; export interface ISchemaRPC { - createSchema(schema: Schema, proof: SchemaProof): Promise; + registerSchema(schema: SchemaDocument, proof: SchemaProof): Promise; resolveSchema(schemaId: string): Promise; } export declare class SchemaRpc implements ISchemaRPC { schemaRestEp: string; private hidClient; + private nodeRestEp; constructor({ offlineSigner, nodeRpcEndpoint, nodeRestEndpoint, }: { offlineSigner?: OfflineSigner; nodeRpcEndpoint: string; nodeRestEndpoint: string; }); init(): Promise; - createSchema(schema: Schema, proof: SchemaProof): Promise; + registerSchema(schema: CredentialSchemaDocument, proof: SchemaProof): Promise; resolveSchema(schemaId: string): Promise>; } //# sourceMappingURL=schemaRPC.d.ts.map \ No newline at end of file diff --git a/build/src/schema/schemaRPC.d.ts.map b/build/src/schema/schemaRPC.d.ts.map index a238d20..1cc4ea5 100644 --- a/build/src/schema/schemaRPC.d.ts.map +++ b/build/src/schema/schemaRPC.d.ts.map @@ -1 +1 @@ -{"version":3,"file":"schemaRPC.d.ts","sourceRoot":"","sources":["../../../src/schema/schemaRPC.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAGtD,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,iCAAiC,CAAC;AACtE,OAAO,EAAE,iBAAiB,EAAyB,MAAM,kBAAkB,CAAC;AAE5E,MAAM,WAAW,UAAU;IACzB,YAAY,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,WAAW,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;IAClE,aAAa,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;CAClD;AAED,qBAAa,SAAU,YAAW,UAAU;IACnC,YAAY,EAAE,MAAM,CAAC;IAC5B,OAAO,CAAC,SAAS,CAAM;gBAEX,EACV,aAAa,EACb,eAAe,EACf,gBAAgB,GACjB,EAAE;QACD,aAAa,CAAC,EAAE,aAAa,CAAC;QAC9B,eAAe,EAAE,MAAM,CAAC;QACxB,gBAAgB,EAAE,MAAM,CAAC;KAC1B;IASK,IAAI;IAOJ,YAAY,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,WAAW,GAAG,OAAO,CAAC,iBAAiB,CAAC;IAuB5E,aAAa,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;CAM9D"} \ No newline at end of file +{"version":3,"file":"schemaRPC.d.ts","sourceRoot":"","sources":["../../../src/schema/schemaRPC.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAGtD,OAAO,EAAE,wBAAwB,EAAmC,MAAM,4CAA4C,CAAC;AACvH,OAAO,EAAE,aAAa,IAAI,WAAW,EAAE,MAAM,gCAAgC,CAAC;AAC9E,OAAO,EAAE,iBAAiB,EAAyB,MAAM,kBAAkB,CAAC;AAC5E,OAAO,EAAE,wBAAwB,IAAI,cAAc,EAAE,MAAM,4CAA4C,CAAC;AAIxG,MAAM,WAAW,UAAU;IACzB,cAAc,CAAC,MAAM,EAAE,cAAc,EAAE,KAAK,EAAE,WAAW,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;IAC5E,aAAa,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;CAClD;AAED,qBAAa,SAAU,YAAW,UAAU;IACnC,YAAY,EAAE,MAAM,CAAC;IAC5B,OAAO,CAAC,SAAS,CAAM;IACvB,OAAO,CAAC,UAAU,CAAS;gBAEf,EACV,aAAa,EACb,eAAe,EACf,gBAAgB,GACjB,EAAE;QACD,aAAa,CAAC,EAAE,aAAa,CAAC;QAC9B,eAAe,EAAE,MAAM,CAAC;QACxB,gBAAgB,EAAE,MAAM,CAAC;KAC1B;IAWK,IAAI;IAOJ,cAAc,CAAC,MAAM,EAAE,wBAAwB,EAAE,KAAK,EAAE,WAAW,GAAG,OAAO,CAAC,iBAAiB,CAAC;IA+BhG,aAAa,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;CAa9D"} \ No newline at end of file diff --git a/build/src/schema/schemaRPC.js b/build/src/schema/schemaRPC.js index 53c95bd..05451f6 100644 --- a/build/src/schema/schemaRPC.js +++ b/build/src/schema/schemaRPC.js @@ -45,6 +45,8 @@ const constants_1 = require("../constants"); const generatedProto = __importStar(require("../../libs/generated/ssi/tx")); const axios_1 = __importDefault(require("axios")); const client_1 = require("../hid/client"); +const utils_1 = __importDefault(require("../utils")); +const constants = __importStar(require("../constants")); class SchemaRpc { constructor({ offlineSigner, nodeRpcEndpoint, nodeRestEndpoint, }) { if (offlineSigner) { @@ -53,6 +55,7 @@ class SchemaRpc { else { this.hidClient = null; } + this.nodeRestEp = nodeRestEndpoint; this.schemaRestEp = client_1.HIDClient.hidNodeRestEndpoint + constants_1.HYPERSIGN_NETWORK_SCHEMA_PATH; } init() { @@ -63,24 +66,35 @@ class SchemaRpc { yield this.hidClient.init(); }); } - createSchema(schema, proof) { + registerSchema(schema, proof) { return __awaiter(this, void 0, void 0, function* () { if (!this.hidClient) { throw new Error('HID-SSI-SDK:: Error: SchemaRpc class is not initialise with offlinesigner'); } - const typeUrl = `${constants_1.HID_COSMOS_MODULE}.${constants_1.HIDRpcEnums.MsgCreateSchema}`; + const typeUrl = `${constants_1.HID_COSMOS_MODULE}.${constants_1.HIDRpcEnums.MsgRegisterCredentialSchema}`; const txMessage = { typeUrl, - value: generatedProto[constants_1.HIDRpcEnums.MsgCreateSchema].fromJSON({ - schemaDoc: schema, - schemaProof: proof, - creator: client_1.HIDClient.getHidWalletAddress(), + value: generatedProto[constants_1.HIDRpcEnums.MsgRegisterCredentialSchema].fromPartial({ + credentialSchemaDocument: schema, + credentialSchemaProof: proof, + txAuthor: client_1.HIDClient.getHidWalletAddress(), }), }; - // TODO: need to find a way to make it dynamic - const fee = 'auto'; + const amount = yield utils_1.default.fetchFee(constants.GAS_FEE_METHODS.Register_Cred_Schema, this.nodeRestEp); + const fee = { + amount: [ + { + denom: 'uhid', + amount, + }, + ], + gas: '200000', + }; const hidClient = client_1.HIDClient.getHidClient(); const txResult = yield hidClient.signAndBroadcast(client_1.HIDClient.getHidWalletAddress(), [txMessage], fee); + if (txResult.code !== 0) { + throw new Error(`${txResult.rawLog}`); + } return txResult; }); } @@ -88,8 +102,12 @@ class SchemaRpc { return __awaiter(this, void 0, void 0, function* () { const getSchemaUrl = `${this.schemaRestEp}/${schemaId}:`; const response = yield axios_1.default.get(getSchemaUrl); - const { schema } = response.data; - return schema; + const { credentialSchemas } = response.data; + if (credentialSchemas === undefined) { + const { schema } = response.data; + return schema; + } + return credentialSchemas; }); } } diff --git a/build/src/ssiApi/api-constant.js b/build/src/ssiApi/api-constant.js index 30c198c..41810f1 100644 --- a/build/src/ssiApi/api-constant.js +++ b/build/src/ssiApi/api-constant.js @@ -2,8 +2,8 @@ Object.defineProperty(exports, "__esModule", { value: true }); exports.APIENDPOINT = void 0; exports.APIENDPOINT = { - STUDIO_API_BASE_URL: 'http://localhost:3001/api/v1', - // STUDIO_API_BASE_URL: 'https://api.entity.hypersign.id/api/v1', + // STUDIO_API_BASE_URL: 'http://localhost:3001/api/v1', + STUDIO_API_BASE_URL: 'https://api.entity.hypersign.id/api/v1', STUDIO_API_ORIGIN: 'https://entity.hypersign.id', AUTH: '/app/oauth', DID: { diff --git a/build/src/ssiApi/services/credential/ICredentialApi.d.ts b/build/src/ssiApi/services/credential/ICredentialApi.d.ts index 21b9e47..8315515 100644 --- a/build/src/ssiApi/services/credential/ICredentialApi.d.ts +++ b/build/src/ssiApi/services/credential/ICredentialApi.d.ts @@ -1,5 +1,6 @@ import { DeliverTxResponse } from "@cosmjs/stargate"; -import { CredentialProof, CredentialStatus } from "../../../../libs/generated/ssi/credential"; +import { CredentialStatusDocument as CredentialStatus } from "../../../../libs/generated/ssi/credential_status"; +import { DocumentProof as CredentialProof } from "../../../../libs/generated/ssi/proof"; export interface IRegisterCredStatus { credentialStatus: CredentialStatus; credentialStatusProof: CredentialProof; diff --git a/build/src/ssiApi/services/credential/ICredentialApi.d.ts.map b/build/src/ssiApi/services/credential/ICredentialApi.d.ts.map index 0f85a72..9d0480e 100644 --- a/build/src/ssiApi/services/credential/ICredentialApi.d.ts.map +++ b/build/src/ssiApi/services/credential/ICredentialApi.d.ts.map @@ -1 +1 @@ -{"version":3,"file":"ICredentialApi.d.ts","sourceRoot":"","sources":["../../../../../src/ssiApi/services/credential/ICredentialApi.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AACrD,OAAO,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,2CAA2C,CAAC;AAE9F,MAAM,WAAW,mBAAmB;IAChC,gBAAgB,EAAE,gBAAgB,CAAC;IACnC,qBAAqB,EAAE,eAAe,CAAC;IACvC,SAAS,EAAE,MAAM,CAAA;CACpB;AACD,MAAM,WAAW,kBAAkB;IAC/B,IAAI,IAAI,IAAI,CAAC;IACb,wBAAwB,CAAC,MAAM,EAAE,mBAAmB,GAAG,OAAO,CAAC,IAAI,CAAC,iBAAiB,EAAE,iBAAiB,CAAC,CAAC,CAAA;CAC7G"} \ No newline at end of file +{"version":3,"file":"ICredentialApi.d.ts","sourceRoot":"","sources":["../../../../../src/ssiApi/services/credential/ICredentialApi.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AACrD,OAAO,EAAE,wBAAwB,IAAI,gBAAgB,EAAE,MAAM,kDAAkD,CAAC;AAChH,OAAO,EAAE,aAAa,IAAI,eAAe,EAAE,MAAM,sCAAsC,CAAC;AACxF,MAAM,WAAW,mBAAmB;IAChC,gBAAgB,EAAE,gBAAgB,CAAC;IACnC,qBAAqB,EAAE,eAAe,CAAC;IACvC,SAAS,EAAE,MAAM,CAAA;CACpB;AACD,MAAM,WAAW,kBAAkB;IAC/B,IAAI,IAAI,IAAI,CAAC;IACb,wBAAwB,CAAC,MAAM,EAAE,mBAAmB,GAAG,OAAO,CAAC,IAAI,CAAC,iBAAiB,EAAE,iBAAiB,CAAC,CAAC,CAAA;CAC7G"} \ No newline at end of file diff --git a/build/src/ssiApi/services/did/IDIDApi.d.ts b/build/src/ssiApi/services/did/IDIDApi.d.ts index e5af127..d2ea2fe 100644 --- a/build/src/ssiApi/services/did/IDIDApi.d.ts +++ b/build/src/ssiApi/services/did/IDIDApi.d.ts @@ -1,11 +1,11 @@ -import { Did } from "../../../../libs/generated/ssi/did"; -import { IDIDResolve, IKeyType, IVerificationRelationships } from "../../../did/IDID"; -import { ISignInfo } from '../../../did/IDID'; +import { DidDocument as Did } from "../../../../libs/generated/ssi/did"; +import { IDIDResolve, ISignInfo } from "../../../did/IDID"; +import { VerificationMethodTypes, VerificationMethodRelationships as IVerificationRelationships } from "../../../../libs/generated/ssi/client/enums"; export interface IGenerateDid { namespace: string; methodSpecificId?: string; options?: { - keyType: IKeyType; + keyType: VerificationMethodTypes; chainId: string; publicKey: string; walletAddress: string; diff --git a/build/src/ssiApi/services/did/IDIDApi.d.ts.map b/build/src/ssiApi/services/did/IDIDApi.d.ts.map index 7665170..5b2033d 100644 --- a/build/src/ssiApi/services/did/IDIDApi.d.ts.map +++ b/build/src/ssiApi/services/did/IDIDApi.d.ts.map @@ -1 +1 @@ -{"version":3,"file":"IDIDApi.d.ts","sourceRoot":"","sources":["../../../../../src/ssiApi/services/did/IDIDApi.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,oCAAoC,CAAC;AACzD,OAAO,EAAe,WAAW,EAAE,QAAQ,EAAE,0BAA0B,EAAE,MAAM,mBAAmB,CAAC;AACnG,OAAO,EAAE,SAAS,EAAE,MAAO,mBAAmB,CAAC;AAC/C,MAAM,WAAW,YAAY;IACzB,SAAS,EAAC,MAAM,CAAC;IACjB,gBAAgB,CAAC,EAAC,MAAM,CAAC;IACzB,OAAO,CAAC,EAAC;QACL,OAAO,EAAC,QAAQ,CAAC;QACjB,OAAO,EAAC,MAAM,CAAC;QACf,SAAS,EAAC,MAAM,CAAC;QACjB,aAAa,EAAC,MAAM,CAAC;QACrB,yBAAyB,EAAC,0BAA0B,EAAE,CAAA;KACzD,CAAA;CACJ;AAED,MAAM,WAAW,SAAS;IACtB,WAAW,EAAC,GAAG,CAAC;IAChB,oBAAoB,CAAC,EAAC,MAAM,CAAC;IAC7B,SAAS,CAAC,EAAC,KAAK,CAAC,SAAS,CAAC,CAAA;CAE9B;AAED,MAAM,WAAW,OAAQ,SAAQ,SAAS;IACtC,UAAU,EAAC,OAAO,CAAA;CACrB;AAGD,MAAM,WAAW,cAAc;IAC3B,IAAI,IAAG,IAAI,CAAC;IACZ,WAAW,CAAC,MAAM,EAAC,YAAY,GAAE,OAAO,CAAC,GAAG,CAAC,CAAA;IAC7C,WAAW,CAAC,MAAM,EAAC,SAAS,GAAE,OAAO,CAAC;QAAE,WAAW,EAAE,GAAG,CAAC;QAAC,eAAe,EAAE,MAAM,CAAA;KAAE,CAAC,CAAA;IACpF,UAAU,CAAC,MAAM,EAAC;QAAC,GAAG,EAAC,MAAM,CAAA;KAAC,GAAE,OAAO,CAAC,WAAW,CAAC,CAAA;IACpD,SAAS,CAAC,MAAM,EAAC,OAAO,GAAE,OAAO,CAAC;QAAC,eAAe,EAAE,MAAM,CAAA;KAAC,CAAC,CAAA;CAC/D"} \ No newline at end of file +{"version":3,"file":"IDIDApi.d.ts","sourceRoot":"","sources":["../../../../../src/ssiApi/services/did/IDIDApi.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,IAAI,GAAG,EAAE,MAAM,oCAAoC,CAAC;AACxE,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAC3D,OAAO,EAAE,uBAAuB,EAAE,+BAA+B,IAAI,0BAA0B,EAAE,MAAM,6CAA6C,CAAC;AACrJ,MAAM,WAAW,YAAY;IACzB,SAAS,EAAC,MAAM,CAAC;IACjB,gBAAgB,CAAC,EAAC,MAAM,CAAC;IACzB,OAAO,CAAC,EAAC;QACL,OAAO,EAAE,uBAAuB,CAAC;QACjC,OAAO,EAAC,MAAM,CAAC;QACf,SAAS,EAAC,MAAM,CAAC;QACjB,aAAa,EAAC,MAAM,CAAC;QACrB,yBAAyB,EAAC,0BAA0B,EAAE,CAAA;KACzD,CAAA;CACJ;AAED,MAAM,WAAW,SAAS;IACtB,WAAW,EAAC,GAAG,CAAC;IAChB,oBAAoB,CAAC,EAAC,MAAM,CAAC;IAC7B,SAAS,CAAC,EAAC,KAAK,CAAC,SAAS,CAAC,CAAA;CAE9B;AAED,MAAM,WAAW,OAAQ,SAAQ,SAAS;IACtC,UAAU,EAAC,OAAO,CAAA;CACrB;AAGD,MAAM,WAAW,cAAc;IAC3B,IAAI,IAAG,IAAI,CAAC;IACZ,WAAW,CAAC,MAAM,EAAC,YAAY,GAAE,OAAO,CAAC,GAAG,CAAC,CAAA;IAC7C,WAAW,CAAC,MAAM,EAAC,SAAS,GAAE,OAAO,CAAC;QAAE,WAAW,EAAE,GAAG,CAAC;QAAC,eAAe,EAAE,MAAM,CAAA;KAAE,CAAC,CAAA;IACpF,UAAU,CAAC,MAAM,EAAC;QAAC,GAAG,EAAC,MAAM,CAAA;KAAC,GAAE,OAAO,CAAC,WAAW,CAAC,CAAA;IACpD,SAAS,CAAC,MAAM,EAAC,OAAO,GAAE,OAAO,CAAC;QAAC,eAAe,EAAE,MAAM,CAAA;KAAC,CAAC,CAAA;CAC/D"} \ No newline at end of file diff --git a/build/src/ssiApi/services/did/did.service.d.ts b/build/src/ssiApi/services/did/did.service.d.ts index 45bd35a..d54b49e 100644 --- a/build/src/ssiApi/services/did/did.service.d.ts +++ b/build/src/ssiApi/services/did/did.service.d.ts @@ -1,4 +1,4 @@ -import { Did } from '../../../../libs/generated/ssi/did'; +import { DidDocument as Did } from '../../../../libs/generated/ssi/did'; import { IDIDResolve } from '../../../did/IDID'; import { IDidApiService, IGenerateDid, IRegister, IUpdate } from './IDIDApi'; export default class DidApiService implements IDidApiService { diff --git a/build/src/ssiApi/services/did/did.service.d.ts.map b/build/src/ssiApi/services/did/did.service.d.ts.map index 2e69635..2ab8560 100644 --- a/build/src/ssiApi/services/did/did.service.d.ts.map +++ b/build/src/ssiApi/services/did/did.service.d.ts.map @@ -1 +1 @@ -{"version":3,"file":"did.service.d.ts","sourceRoot":"","sources":["../../../../../src/ssiApi/services/did/did.service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAY,MAAM,oCAAoC,CAAC;AACnE,OAAO,EAAe,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAI7D,OAAO,EAAE,cAAc,EAAE,YAAY,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAG7E,MAAM,CAAC,OAAO,OAAO,aAAc,YAAW,cAAc;IAC1D,OAAO,CAAC,WAAW,CAAQ;IAC3B,OAAO,CAAC,WAAW,CAAC;gBACR,MAAM,EAAE,MAAM;IAOb,IAAI;IAIjB;;;;;;;;;;;;OAYG;IACU,WAAW,CAAC,MAAM,EAAE,YAAY,GAAG,OAAO,CAAC,GAAG,CAAC;IA2B5D;;;;;;;;;;MAUE;IACW,WAAW,CAAC,MAAM,EAAE,SAAS,GAAG,OAAO,CAAC;QAAE,WAAW,EAAE,GAAG,CAAC;QAAC,eAAe,EAAE,MAAM,CAAA;KAAE,CAAC;IAiEnG;;;;OAIG;IACU,UAAU,CAAC,MAAM,EAAE;QAAE,GAAG,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC,WAAW,CAAC;IAwBtE;;;;;;;;;;QAUI;IAES,SAAS,CAAC,MAAM,EAAE,OAAO,GAAG,OAAO,CAAC;QAAE,eAAe,EAAE,MAAM,CAAA;KAAE,CAAC;CA0D9E"} \ No newline at end of file +{"version":3,"file":"did.service.d.ts","sourceRoot":"","sources":["../../../../../src/ssiApi/services/did/did.service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,IAAI,GAAG,EAAE,MAAM,oCAAoC,CAAC;AACxE,OAAO,EAAe,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAI7D,OAAO,EAAE,cAAc,EAAE,YAAY,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAG7E,MAAM,CAAC,OAAO,OAAO,aAAc,YAAW,cAAc;IAC1D,OAAO,CAAC,WAAW,CAAQ;IAC3B,OAAO,CAAC,WAAW,CAAC;gBACR,MAAM,EAAE,MAAM;IAOb,IAAI;IAIjB;;;;;;;;;;;;OAYG;IACU,WAAW,CAAC,MAAM,EAAE,YAAY,GAAG,OAAO,CAAC,GAAG,CAAC;IA2B5D;;;;;;;;;;MAUE;IACW,WAAW,CAAC,MAAM,EAAE,SAAS,GAAG,OAAO,CAAC;QAAE,WAAW,EAAE,GAAG,CAAC;QAAC,eAAe,EAAE,MAAM,CAAA;KAAE,CAAC;IA+CnG;;;;OAIG;IACU,UAAU,CAAC,MAAM,EAAE;QAAE,GAAG,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC,WAAW,CAAC;IAwBtE;;;;;;;;;;QAUI;IAES,SAAS,CAAC,MAAM,EAAE,OAAO,GAAG,OAAO,CAAC;QAAE,eAAe,EAAE,MAAM,CAAA;KAAE,CAAC;CA+C9E"} \ No newline at end of file diff --git a/build/src/ssiApi/services/did/did.service.js b/build/src/ssiApi/services/did/did.service.js index 8ff6c05..13e3f22 100644 --- a/build/src/ssiApi/services/did/did.service.js +++ b/build/src/ssiApi/services/did/did.service.js @@ -12,7 +12,6 @@ var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); -const IDID_1 = require("../../../did/IDID"); const api_constant_1 = require("../../api-constant"); const apiAuth_1 = require("../../apiAuth/apiAuth"); const node_fetch_1 = __importDefault(require("node-fetch")); @@ -83,7 +82,6 @@ class DidApiService { * @return {Promise} */ registerDid(params) { - var _a, _b, _c, _d; return __awaiter(this, void 0, void 0, function* () { if (!params.didDocument || Object.keys(params.didDocument).length === 0) { throw new Error('HID-SSI-SDK:: Error: params.didDocument is required to register a did'); @@ -101,18 +99,6 @@ class DidApiService { if (!params.signInfos[i].verification_method_id) { throw new Error(`HID-SSI-SDK:: Error: params.signInfos[${i}].verification_method_id is required to register a did`); } - // if (!params.signInfos[i].clientSpec) { - // throw new Error(`HID-SSI-SDK:: Error: params.signInfos[${i}].clientSpec is required to register a did`); - // } - // if (params.signInfos[i].clientSpec && !(params.signInfos[i].clientSpec.type in IClientSpec)) { - // throw new Error('HID-SSI-SDK:: Error: params.clientSpec is invalid'); - // } - if (((_a = params.signInfos[i].clientSpec) === null || _a === void 0 ? void 0 : _a.type) === IDID_1.IClientSpec['cosmos-ADR036']) { - if (((_b = params.signInfos[i].clientSpec) === null || _b === void 0 ? void 0 : _b.adr036SignerAddress) === '' || - ((_c = params.signInfos[i].clientSpec) === null || _c === void 0 ? void 0 : _c.adr036SignerAddress) === undefined) { - throw new Error(`HID-SSI-SDK:: Error: params.signInfos[${i}].adr036SignerAddress is required to register a did, when clientSpec type is${(_d = params.signInfos[i].clientSpec) === null || _d === void 0 ? void 0 : _d.type} `); - } - } if (!params.signInfos[i].signature) { throw new Error(`HID-SSI-SDK:: Error: params.signInfos[${i}].signature is required to register a did`); } @@ -185,9 +171,7 @@ class DidApiService { * @return {Promise} */ updateDid(params) { - var _a, _b, _c, _d; return __awaiter(this, void 0, void 0, function* () { - console.log('did services'); if (!params.didDocument || Object.keys(params.didDocument).length === 0) { throw new Error('HID-SSI-SDK:: Error: params.didDocument is required to update a did'); } @@ -204,12 +188,6 @@ class DidApiService { if (!params.signInfos[i].verification_method_id) { throw new Error(`HID-SSI-SDK:: Error: params.signInfos[${i}].verification_method_id is required to update a did`); } - if (((_a = params.signInfos[i].clientSpec) === null || _a === void 0 ? void 0 : _a.type) === IDID_1.IClientSpec['cosmos-ADR036']) { - if (((_b = params.signInfos[i].clientSpec) === null || _b === void 0 ? void 0 : _b.adr036SignerAddress) === '' || - ((_c = params.signInfos[i].clientSpec) === null || _c === void 0 ? void 0 : _c.adr036SignerAddress) === undefined) { - throw new Error(`HID-SSI-SDK:: Error: params.signInfos[${i}].adr036SignerAddress is required to update a did, when clientSpec type is${(_d = params.signInfos[i].clientSpec) === null || _d === void 0 ? void 0 : _d.type} `); - } - } if (!params.signInfos[i].signature) { throw new Error(`HID-SSI-SDK:: Error: params.signInfos[${i}].signature is required to register a did`); } diff --git a/build/src/ssiApi/services/schema/ISchemaApi.d.ts b/build/src/ssiApi/services/schema/ISchemaApi.d.ts index 89393f4..74110bd 100644 --- a/build/src/ssiApi/services/schema/ISchemaApi.d.ts +++ b/build/src/ssiApi/services/schema/ISchemaApi.d.ts @@ -1,5 +1,6 @@ import { DeliverTxResponse } from "@cosmjs/stargate"; -import { SchemaDocument, SchemaProof } from "../../../../libs/generated/ssi/schema"; +import { CredentialSchemaDocument as SchemaDocument } from "../../../../libs/generated/ssi/credential_schema"; +import { DocumentProof as SchemaProof } from '../../../../libs/generated/ssi/proof'; export interface IRegisterSchema { schemaDocument: SchemaDocument; schemaProof: SchemaProof; diff --git a/build/src/ssiApi/services/schema/ISchemaApi.d.ts.map b/build/src/ssiApi/services/schema/ISchemaApi.d.ts.map index 3bf0814..9b15589 100644 --- a/build/src/ssiApi/services/schema/ISchemaApi.d.ts.map +++ b/build/src/ssiApi/services/schema/ISchemaApi.d.ts.map @@ -1 +1 @@ -{"version":3,"file":"ISchemaApi.d.ts","sourceRoot":"","sources":["../../../../../src/ssiApi/services/schema/ISchemaApi.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AACrD,OAAO,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,uCAAuC,CAAC;AAEpF,MAAM,WAAW,eAAe;IAC5B,cAAc,EAAE,cAAc,CAAC;IAC/B,WAAW,EAAE,WAAW,CAAA;CAC3B;AAED,MAAM,WAAW,cAAc;IAC3B,IAAI,IAAI,IAAI,CAAC;IACb,cAAc,CAAC,MAAM,EAAE,eAAe,GAAG,OAAO,CAAC,IAAI,CAAC,iBAAiB,EAAE,iBAAiB,CAAC,CAAC,CAAA;CAC/F"} \ No newline at end of file +{"version":3,"file":"ISchemaApi.d.ts","sourceRoot":"","sources":["../../../../../src/ssiApi/services/schema/ISchemaApi.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AACrD,OAAO,EAAE,wBAAwB,IAAI,cAAc,EAAE,MAAM,kDAAkD,CAAC;AAE9G,OAAO,EAAE,aAAa,IAAI,WAAW,EAAE,MAAM,sCAAsC,CAAA;AACnF,MAAM,WAAW,eAAe;IAC5B,cAAc,EAAE,cAAc,CAAC;IAC/B,WAAW,EAAE,WAAW,CAAA;CAC3B;AAED,MAAM,WAAW,cAAc;IAC3B,IAAI,IAAI,IAAI,CAAC;IACb,cAAc,CAAC,MAAM,EAAE,eAAe,GAAG,OAAO,CAAC,IAAI,CAAC,iBAAiB,EAAE,iBAAiB,CAAC,CAAC,CAAA;CAC/F"} \ No newline at end of file diff --git a/build/src/tests/bjj/bjjTestScenario.spec.d.ts b/build/src/tests/bjj/bjjTestScenario.spec.d.ts new file mode 100644 index 0000000..75e6038 --- /dev/null +++ b/build/src/tests/bjj/bjjTestScenario.spec.d.ts @@ -0,0 +1,2 @@ +export {}; +//# sourceMappingURL=bjjTestScenario.spec.d.ts.map \ No newline at end of file diff --git a/build/src/tests/bjj/bjjTestScenario.spec.d.ts.map b/build/src/tests/bjj/bjjTestScenario.spec.d.ts.map new file mode 100644 index 0000000..e369782 --- /dev/null +++ b/build/src/tests/bjj/bjjTestScenario.spec.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"bjjTestScenario.spec.d.ts","sourceRoot":"","sources":["../../../../src/tests/bjj/bjjTestScenario.spec.ts"],"names":[],"mappings":""} \ No newline at end of file diff --git a/build/src/tests/bjj/bjjTestScenario.spec.js b/build/src/tests/bjj/bjjTestScenario.spec.js new file mode 100644 index 0000000..88ba2f2 --- /dev/null +++ b/build/src/tests/bjj/bjjTestScenario.spec.js @@ -0,0 +1,481 @@ +"use strict"; +var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { + function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } + return new (P || (P = Promise))(function (resolve, reject) { + function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } + function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } + function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } + step((generator = generator.apply(thisArg, _arguments || [])).next()); + }); +}; +Object.defineProperty(exports, "__esModule", { value: true }); +const index_1 = require("../../index"); +const chai_1 = require("chai"); +const config_1 = require("../config"); +const enums_1 = require("../../../libs/generated/ssi/client/enums"); +let offlineSigner; +let hsSdk; +let privateKeyMultibase; +let publicKeyMultibase; +let didDocument; +let didDocId; +let subjectDid; +let verificationMethodId; +let bjjPubKey; +let bjjPrivKey; +let schemaObject; +let signedSchema; +let schemaId; +let credentialDetail; +let signedVC; +let unsignedverifiablePresentation; +let issuerDidDoc; +let issuerDid; +let holderDidDoc; +let holderDid; +let signedVerifiablePresentation; +let challenge; +let credenStatus; +let credentialStatusId; +let credentialId; +let verifiableCredentialPresentationId; +let IssuerKp; +let holderKp; +const schemaBody = { + name: 'TestSchema', + description: 'This is a test schema generation', + author: '', + fields: [{ name: 'name', type: 'string', isRequired: true }], + additionalProperties: false, +}; +const credentialBody = { + schemaId: '', + subjectDid: '', + type: [], + issuerDid: '', + fields: { name: 'Varsha' }, + expirationDate: '', +}; +const issueCredentialBody = { + credential: credentialDetail, + issuerDid: didDocId, + verificationMethodId, + privateKeyMultibase: privateKeyMultibase, + registerCredential: true, +}; +beforeEach(function () { + return __awaiter(this, void 0, void 0, function* () { + offlineSigner = yield (0, config_1.createWallet)(config_1.mnemonic); + const params = { + offlineSigner, + nodeRestEndpoint: config_1.hidNodeEp.rest, + nodeRpcEndpoint: config_1.hidNodeEp.rpc, + namespace: config_1.hidNodeEp.namespace, + }; + hsSdk = new index_1.HypersignSSISdk(params); + yield hsSdk.init(); + }); +}); +describe('DID Test scenarios', () => { + describe('#generateKeys() method to generate publicKyeMultibase and privateKeyMultiBase', function () { + it('should return publickeyMultibase and privateKeyMultibase', function () { + return __awaiter(this, void 0, void 0, function* () { + const kp = yield hsSdk.did.generateKeys(); + privateKeyMultibase = kp.privateKeyMultibase; + publicKeyMultibase = kp.publicKeyMultibase; + const bjjKp = yield hsSdk.did.bjjDID.generateKeys(); + bjjPubKey = bjjKp.publicKeyMultibase; + bjjPrivKey = bjjKp.privateKeyMultibase; + }); + }); + }); + describe('Bjj test scenario', function () { + it('Should be able to generate and register a DID using the Ed25519 key type, and update it by adding a Baby JubJub (BJJ) verification method (VM)', function () { + return __awaiter(this, void 0, void 0, function* () { + didDocument = yield hsSdk.did.generate({ publicKeyMultibase }); + didDocId = didDocument['id']; + verificationMethodId = didDocument['verificationMethod'][0].id; + yield hsSdk.did.register({ + didDocument, + privateKeyMultibase, + verificationMethodId, + }); + const didDocWithBjjVM = yield hsSdk.did.addVerificationMethod({ + didDocument, + type: enums_1.VerificationMethodTypes.BabyJubJubKey2021, + publicKeyMultibase: bjjPubKey, + }); + const resolvedDid = yield hsSdk.did.resolve({ did: didDocId }); + delete didDocWithBjjVM.alsoKnownAs; + const bjjSign = yield hsSdk.did.bjjDID.update({ + didDocument: didDocWithBjjVM, + privateKeyMultibase: bjjPrivKey, + verificationMethodId: didDocWithBjjVM.verificationMethod[1].id, + versionId: resolvedDid.didDocumentMetadata.versionId, + readonly: true, + }); + yield hsSdk.did.update({ + didDocument: didDocWithBjjVM, + privateKeyMultibase, + verificationMethodId: verificationMethodId, + versionId: resolvedDid.didDocumentMetadata.versionId, + otherSignInfo: bjjSign.signInfos, + }); + const resolvedBjjDid = yield hsSdk.did.resolve({ did: didDocId }); + // console.log(resolvedBjjDid) + }); + }); + it('Should be able to generate and register a DID using the Bjj key type, and update it by adding a Ed255 verification method (VM)', function () { + return __awaiter(this, void 0, void 0, function* () { + const holderDidDocument = yield hsSdk.did.bjjDID.generate({ publicKeyMultibase: bjjPubKey }); + subjectDid = holderDidDocument['id']; + const verificationMethodId = holderDidDocument['verificationMethod'][0].id; + yield hsSdk.did.bjjDID.register({ + didDocument: holderDidDocument, + privateKeyMultibase: bjjPrivKey, + verificationMethodId, + }); + const didDocWithEdd255VM = yield hsSdk.did.addVerificationMethod({ + didDocument: holderDidDocument, + type: enums_1.VerificationMethodTypes.Ed25519VerificationKey2020, + publicKeyMultibase, + }); + const resolvedDid = yield hsSdk.did.resolve({ did: subjectDid }); + delete didDocWithEdd255VM.alsoKnownAs; + const ed255Sign = yield hsSdk.did.update({ + didDocument: didDocWithEdd255VM, + privateKeyMultibase: privateKeyMultibase, + verificationMethodId: didDocWithEdd255VM.verificationMethod[1].id, + versionId: resolvedDid.didDocumentMetadata.versionId, + readonly: true, + }); + delete didDocWithEdd255VM.proof; + yield hsSdk.did.bjjDID.update({ + didDocument: didDocWithEdd255VM, + privateKeyMultibase: bjjPrivKey, + verificationMethodId: verificationMethodId, + versionId: resolvedDid.didDocumentMetadata.versionId, + otherSignInfo: ed255Sign.signInfos, + }); + const resolvedBjjDid = yield hsSdk.did.resolve({ did: subjectDid }); + // console.log(resolvedBjjDid.didDocument.verificationMethod, 'resolvedBjjDid'); + }); + }); + }); + describe('Register did with two vm together', function () { + it('Should be able to generate a DID BJJ and register it by adding Ed255 VM', function () { + return __awaiter(this, void 0, void 0, function* () { + const ed25519Kp = yield hsSdk.did.generateKeys(); + IssuerKp = yield hsSdk.did.bjjDID.generateKeys(); + issuerDidDoc = yield hsSdk.did.bjjDID.generate({ publicKeyMultibase: IssuerKp.publicKeyMultibase }); + issuerDid = issuerDidDoc['id']; + const verificationMethodId = issuerDidDoc['verificationMethod'][0].id; + const didDocWithEdd255VM = yield hsSdk.did.addVerificationMethod({ + didDocument: issuerDidDoc, + type: enums_1.VerificationMethodTypes.Ed25519VerificationKey2020, + publicKeyMultibase: ed25519Kp.publicKeyMultibase, + }); + delete didDocWithEdd255VM.alsoKnownAs; + let ed255Sign = yield hsSdk.did.createSignInfos({ + didDocument: didDocWithEdd255VM, + privateKeyMultibase: ed25519Kp.privateKeyMultibase, + verificationMethodId: didDocWithEdd255VM.verificationMethod[1].id, + }); + ed255Sign = ed255Sign[0]; + delete didDocWithEdd255VM.proof; + let bjjSign = yield hsSdk.did.bjjDID.createSignInfos({ + didDocument: didDocWithEdd255VM, + privateKeyMultibase: IssuerKp.privateKeyMultibase, + verificationMethodId: verificationMethodId, + }); + bjjSign = bjjSign[0]; + const registeredDid = yield hsSdk.did.registerByClientSpec({ + didDocument: didDocWithEdd255VM, + signInfos: [ + { + type: bjjSign.type, + verification_method_id: bjjSign.verification_method_id, + signature: bjjSign.signature, + created: bjjSign.created + }, + { + type: ed255Sign.type, + verification_method_id: ed255Sign.verification_method_id, + signature: ed255Sign.signature, + created: ed255Sign.created + }, + ] + }); + //console.log(registeredDid) + }); + }); + it('Should be able to generate a Ed255 Did and register it by adding Bjj VM', function () { + return __awaiter(this, void 0, void 0, function* () { + const ed25519Kp = yield hsSdk.did.generateKeys(); + holderKp = yield hsSdk.did.bjjDID.generateKeys(); + holderDidDoc = yield hsSdk.did.generate({ publicKeyMultibase: ed25519Kp.publicKeyMultibase }); + holderDid = holderDidDoc['id']; + const verificationMethodId = holderDidDoc['verificationMethod'][0].id; + const didDocWithBJJVM = yield hsSdk.did.addVerificationMethod({ + didDocument: holderDidDoc, + type: enums_1.VerificationMethodTypes.BabyJubJubKey2021, + publicKeyMultibase: holderKp.publicKeyMultibase, + }); + delete didDocWithBJJVM.alsoKnownAs; + let bjjSign = yield hsSdk.did.bjjDID.createSignInfos({ + didDocument: didDocWithBJJVM, + privateKeyMultibase: holderKp.privateKeyMultibase, + verificationMethodId: didDocWithBJJVM.verificationMethod[1].id, + }); + bjjSign = bjjSign[0]; + let ed255Sign = yield hsSdk.did.createSignInfos({ + didDocument: didDocWithBJJVM, + privateKeyMultibase: ed25519Kp.privateKeyMultibase, + verificationMethodId, + }); + ed255Sign = ed255Sign[0]; + const registeredDid = yield hsSdk.did.registerByClientSpec({ + didDocument: didDocWithBJJVM, + signInfos: [ + { + type: 'Ed25519Signature2020', + verification_method_id: verificationMethodId, + signature: ed255Sign.signature, + created: ed255Sign.created + }, + { + type: 'BJJSignature2021', + verification_method_id: bjjSign.verification_method_id, + signature: bjjSign.signature, + created: bjjSign.created + }, + ] + }); + // console.log(registeredDid) + }); + }); + }); +}); +describe('#generate() method to create schema', function () { + it('should be able to create a new schema', function () { + return __awaiter(this, void 0, void 0, function* () { + const tempSchemaBody = Object.assign({}, schemaBody); + tempSchemaBody.author = issuerDid; + schemaObject = yield hsSdk.schema.hypersignBjjschema.generate(tempSchemaBody); + schemaId = schemaObject['id']; + (0, chai_1.expect)(schemaObject).to.be.a('object'); + (0, chai_1.should)().exist(schemaObject['type']); + (0, chai_1.should)().exist(schemaObject['modelVersion']); + (0, chai_1.should)().exist(schemaObject['id']); + (0, chai_1.should)().exist(schemaObject['name']); + (0, chai_1.should)().exist(schemaObject['author']); + (0, chai_1.should)().exist(schemaObject['authored']); + (0, chai_1.should)().exist(schemaObject['schema']); + (0, chai_1.expect)(schemaObject.schema).to.be.a('object'); + (0, chai_1.expect)(schemaObject['name']).to.be.equal(tempSchemaBody.name); + (0, chai_1.expect)(schemaObject['author']).to.be.equal(tempSchemaBody.author); + }); + }); +}); +describe('#sign() function to sign schema', function () { + it('should be able to sign newly created schema', function () { + return __awaiter(this, void 0, void 0, function* () { + const tempSchemaBody = JSON.parse(JSON.stringify(schemaObject)); + signedSchema = yield hsSdk.schema.hypersignBjjschema.sign({ + privateKeyMultibase: IssuerKp.privateKeyMultibase, + schema: tempSchemaBody, + verificationMethodId: issuerDidDoc.verificationMethod[0].id, + }); + (0, chai_1.expect)(signedSchema).to.be.a('object'); + (0, chai_1.should)().exist(signedSchema.proof); + (0, chai_1.should)().exist(signedSchema.proof.type); + (0, chai_1.should)().exist(signedSchema.proof.verificationMethod); + (0, chai_1.should)().exist(signedSchema.proof.proofPurpose); + (0, chai_1.should)().exist(signedSchema.proof.proofValue); + (0, chai_1.should)().exist(signedSchema.proof.created); + (0, chai_1.should)().exist(signedSchema.type); + (0, chai_1.should)().exist(signedSchema.modelVersion); + (0, chai_1.should)().exist(signedSchema.author); + (0, chai_1.should)().exist(signedSchema['id']); + (0, chai_1.should)().exist(signedSchema['name']); + (0, chai_1.should)().exist(signedSchema['author']); + (0, chai_1.should)().exist(signedSchema['authored']); + (0, chai_1.should)().exist(signedSchema['schema']); + }); + }); +}); +describe('#register() function to register schema on blockchain', function () { + it('should be able to register schema on blockchain', function () { + return __awaiter(this, void 0, void 0, function* () { + const registeredSchema = yield hsSdk.schema.hypersignBjjschema.register({ + schema: signedSchema, + }); + (0, chai_1.should)().exist(registeredSchema.transactionHash); + }); + }); +}); +describe('Verifiable Credential Opearations', () => { + describe('#generate() method to generate a credential', function () { + it('should be able to generate new credential for a schema with subject DID', function () { + return __awaiter(this, void 0, void 0, function* () { + const expirationDate = new Date('12/11/2027'); + const tempCredentialBody = Object.assign({}, credentialBody); + tempCredentialBody.schemaId = schemaId; + tempCredentialBody.subjectDid = holderDid; + tempCredentialBody['expirationDate'] = expirationDate.toString(); + tempCredentialBody.issuerDid = issuerDid; + tempCredentialBody.fields = { name: 'varsha' }; + credentialDetail = yield hsSdk.vc.bjjVC.generate(tempCredentialBody); + (0, chai_1.expect)(credentialDetail).to.be.a('object'); + (0, chai_1.should)().exist(credentialDetail['@context']); + (0, chai_1.should)().exist(credentialDetail['id']); + credentialId = credentialDetail.id; + (0, chai_1.should)().exist(credentialDetail['type']); + (0, chai_1.should)().exist(credentialDetail['issuanceDate']); + (0, chai_1.should)().exist(credentialDetail['issuer']); + (0, chai_1.should)().exist(credentialDetail['credentialSubject']); + (0, chai_1.should)().exist(credentialDetail['credentialStatus']); + (0, chai_1.expect)(credentialDetail['credentialStatus'].type).to.be.equal('HypersignCredentialStatus2023'); + }); + }); + }); + describe('#issueCredential() method for issuing credential', function () { + it('should be able to issue credential with credential status registered on chain', function () { + return __awaiter(this, void 0, void 0, function* () { + const tempIssueCredentialBody = Object.assign({}, issueCredentialBody); + tempIssueCredentialBody.credential = credentialDetail; + tempIssueCredentialBody.issuerDid = issuerDid; + tempIssueCredentialBody.verificationMethodId = issuerDidDoc.verificationMethod[0].id; + tempIssueCredentialBody.privateKeyMultibase = IssuerKp.privateKeyMultibase; + const issuedCredResult = yield hsSdk.vc.bjjVC.issue(tempIssueCredentialBody); + const { signedCredential, credentialStatus, credentialStatusProof, credentialStatusRegistrationResult } = issuedCredResult; + signedVC = signedCredential; + credenStatus = credentialStatus; + credentialId = signedVC.id; + credentialStatusId = signedCredential['credentialStatus'].id; + (0, chai_1.expect)(signedCredential).to.be.a('object'); + (0, chai_1.should)().exist(signedCredential['@context']); + (0, chai_1.should)().exist(signedCredential['id']); + (0, chai_1.should)().exist(signedCredential['type']); + (0, chai_1.should)().exist(signedCredential['issuanceDate']); + (0, chai_1.should)().exist(signedCredential['issuer']); + (0, chai_1.should)().exist(signedCredential['credentialSubject']); + (0, chai_1.should)().exist(signedCredential['credentialSchema']); + (0, chai_1.should)().exist(signedCredential['credentialStatus']); + (0, chai_1.should)().exist(signedCredential['proof']); + (0, chai_1.expect)(signedCredential['id']).to.be.equal(tempIssueCredentialBody.credential.id); + (0, chai_1.expect)(credentialStatus).to.be.a('object'); + (0, chai_1.should)().exist(credentialStatus['@context']); + (0, chai_1.should)().exist(credentialStatus['id']); + (0, chai_1.should)().exist(credentialStatus['issuer']); + (0, chai_1.should)().exist(credentialStatus['issuanceDate']); + (0, chai_1.should)().exist(credentialStatus['credentialMerkleRootHash']); + (0, chai_1.expect)(credentialStatusProof).to.be.a('object'); + (0, chai_1.should)().exist(credentialStatusProof['type']); + (0, chai_1.should)().exist(credentialStatusProof['created']); + (0, chai_1.should)().exist(credentialStatusProof['verificationMethod']); + (0, chai_1.should)().exist(credentialStatusProof['proofPurpose']); + (0, chai_1.should)().exist(credentialStatusProof['proofValue']); + (0, chai_1.expect)(credentialStatusRegistrationResult).to.be.a('object'); + (0, chai_1.should)().exist(credentialStatusRegistrationResult['height']); + (0, chai_1.should)().exist(credentialStatusRegistrationResult['transactionHash']); + (0, chai_1.should)().exist(credentialStatusRegistrationResult['gasUsed']); + (0, chai_1.should)().exist(credentialStatusRegistrationResult['gasWanted']); + }); + }); + }); + describe('#verifyCredential() method to verify a credential', function () { + it('should be able to verify credential', function () { + return __awaiter(this, void 0, void 0, function* () { + const params = { + credential: signedVC, + issuerDid: issuerDid, + verificationMethodId: issuerDidDoc.verificationMethod[0].id, + }; + const verificationResult = yield hsSdk.vc.bjjVC.verify(params); + (0, chai_1.expect)(verificationResult).to.be.a('object'); + (0, chai_1.should)().exist(verificationResult.verified); + (0, chai_1.expect)(verificationResult.verified).to.be.equal(true); + (0, chai_1.should)().exist(verificationResult.results); + (0, chai_1.expect)(verificationResult.results).to.be.a('array'); + (0, chai_1.should)().exist(verificationResult.statusResult); + (0, chai_1.expect)(verificationResult.statusResult.verified).to.be.equal(true); + }); + }); + }); +}); +describe('Verifiable Presentation Operataions', () => { + describe('#generate() method to generate new presentation document', () => { + it('should be able to generate a new presentation document', () => __awaiter(void 0, void 0, void 0, function* () { + const presentationBody = { + verifiableCredentials: [credentialDetail], + holderDid: holderDid, + }; + const tempPresentationBody = Object.assign({}, presentationBody); + tempPresentationBody.verifiableCredentials[0] = credentialDetail; + tempPresentationBody.holderDid = holderDid; + unsignedverifiablePresentation = yield hsSdk.vp.bjjVp.generate(tempPresentationBody); + (0, chai_1.should)().exist(unsignedverifiablePresentation['@context']); + (0, chai_1.should)().exist(unsignedverifiablePresentation['type']); + (0, chai_1.expect)(unsignedverifiablePresentation.type[0]).to.be.equal('VerifiablePresentation'); + (0, chai_1.should)().exist(unsignedverifiablePresentation['verifiableCredential']); + (0, chai_1.expect)(unsignedverifiablePresentation.verifiableCredential).to.be.a('array'); + (0, chai_1.should)().exist(unsignedverifiablePresentation['id']); + (0, chai_1.should)().exist(unsignedverifiablePresentation['holder']); + verifiableCredentialPresentationId = unsignedverifiablePresentation.id; + })); + }); + describe('#sign() method to sign presentation document', () => { + const signPresentationBody = { + presentation: unsignedverifiablePresentation, + holderDid: '', + verificationMethodId: '', + privateKeyMultibase: '', + challenge, + }; + it('should be able a sign presentation document', () => __awaiter(void 0, void 0, void 0, function* () { + const tempSignPresentationBody = Object.assign({}, signPresentationBody); + tempSignPresentationBody.presentation = unsignedverifiablePresentation; + tempSignPresentationBody.holderDid = holderDid; + tempSignPresentationBody.verificationMethodId = holderDidDoc.verificationMethod[1].id; + tempSignPresentationBody.privateKeyMultibase = holderKp.privateKeyMultibase; + tempSignPresentationBody.challenge = "abc"; + tempSignPresentationBody['domain'] = "http://xyz.com"; + signedVerifiablePresentation = yield hsSdk.vp.bjjVp.sign(tempSignPresentationBody); + (0, chai_1.should)().exist(signedVerifiablePresentation['@context']); + (0, chai_1.should)().exist(signedVerifiablePresentation['type']); + (0, chai_1.expect)(signedVerifiablePresentation.type[0]).to.be.equal('VerifiablePresentation'); + (0, chai_1.should)().exist(signedVerifiablePresentation['verifiableCredential']); + (0, chai_1.expect)(signedVerifiablePresentation.id).to.be.equal(verifiableCredentialPresentationId); + })); + }); + describe('#verify() method to verify a signed presentation document', () => { + const verifyPresentationBody = { + signedPresentation: signedVerifiablePresentation, + holderDid: '', + holderVerificationMethodId: '', + issuerVerificationMethodId: verificationMethodId, + privateKey: privateKeyMultibase, + challenge, + issuerDid: didDocId, + }; + it('should be able to verify signed presentation document', () => __awaiter(void 0, void 0, void 0, function* () { + const tempverifyPresentationBody = Object.assign({}, verifyPresentationBody); + tempverifyPresentationBody.signedPresentation = signedVerifiablePresentation; + tempverifyPresentationBody.issuerDid = issuerDid; + tempverifyPresentationBody.holderDid = holderDid; + tempverifyPresentationBody.holderVerificationMethodId = holderDidDoc.verificationMethod[1].id; + tempverifyPresentationBody.issuerVerificationMethodId = issuerDidDoc.verificationMethod[0].id; + tempverifyPresentationBody.challenge = "abc"; + tempverifyPresentationBody['domain'] = "http://xyz.com"; + const verifiedPresentationDetail = yield hsSdk.vp.bjjVp.verify(tempverifyPresentationBody); + (0, chai_1.should)().exist(verifiedPresentationDetail['verified']); + (0, chai_1.expect)(verifiedPresentationDetail.verified).to.be.equal(true); + (0, chai_1.should)().exist(verifiedPresentationDetail['results']); + (0, chai_1.expect)(verifiedPresentationDetail.results).to.be.a('array'); + (0, chai_1.expect)(verifiedPresentationDetail.results[1].credentialResult).to.be.a('array'); + (0, chai_1.expect)(verifiedPresentationDetail.results[1].credentialResult.length).to.be.greaterThan(0); + (0, chai_1.expect)(verifiedPresentationDetail.results[1].credentialResult[0].verified).to.be.equal(true); + })); + }); +}); diff --git a/build/src/tests/bjj/credential/bjj_credential.spec.d.ts b/build/src/tests/bjj/credential/bjj_credential.spec.d.ts new file mode 100644 index 0000000..8c0c0c6 --- /dev/null +++ b/build/src/tests/bjj/credential/bjj_credential.spec.d.ts @@ -0,0 +1,2 @@ +export {}; +//# sourceMappingURL=bjj_credential.spec.d.ts.map \ No newline at end of file diff --git a/build/src/tests/bjj/credential/bjj_credential.spec.d.ts.map b/build/src/tests/bjj/credential/bjj_credential.spec.d.ts.map new file mode 100644 index 0000000..2801b5f --- /dev/null +++ b/build/src/tests/bjj/credential/bjj_credential.spec.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"bjj_credential.spec.d.ts","sourceRoot":"","sources":["../../../../../src/tests/bjj/credential/bjj_credential.spec.ts"],"names":[],"mappings":""} \ No newline at end of file diff --git a/build/src/tests/bjj/credential/bjj_credential.spec.js b/build/src/tests/bjj/credential/bjj_credential.spec.js new file mode 100644 index 0000000..92c01e1 --- /dev/null +++ b/build/src/tests/bjj/credential/bjj_credential.spec.js @@ -0,0 +1,1175 @@ +"use strict"; +var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { + function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } + return new (P || (P = Promise))(function (resolve, reject) { + function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } + function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } + function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } + step((generator = generator.apply(thisArg, _arguments || [])).next()); + }); +}; +Object.defineProperty(exports, "__esModule", { value: true }); +const index_1 = require("../../../index"); +const chai_1 = require("chai"); +const config_1 = require("../../config"); +let issuerPrivateKeyMultibase; +let issuerPublicKeyMultibase; +let holderPrivateKeyMultibase; +let holderPublicKeyMultibase; +let offlineSigner; +let hsSdk; +let credentialDetail3; +let issuedCredResult2; +let issuedCredResult; +let credentialStatusId; +const credentialTransMessage = []; +let credentialDetail2; +let credenStatus; +let verificationMethod; +let schemaObject; +let signedSchema; +let schemaId; +let subjectDid; +let issuerDid; +let issuerDidDoc; +let subjectDidDoc; +let credentialDetail; +let credentialId; +let signedVC; +let selectiveDisclosure; +let credentialStatus2; +let credentialStatusProof2; +let signedVC1; +const issueCredentialBody = { + credential: credentialDetail, + issuerDid, + verificationMethodId: '', + privateKeyMultibase: issuerPrivateKeyMultibase, + registerCredential: true, +}; +const schemaBody = { + name: 'TestSchema', + description: 'This is a test schema generation', + author: '', + fields: [ + { name: 'name', type: 'string', isRequired: false }, + { name: 'address', type: 'string', isRequired: true }, + ], + additionalProperties: false, +}; +const credentialBody = { + schemaId: '', + subjectDid: '', + type: [], + issuerDid: '', + fields: { name: 'Varsha', address: 'Random address' }, + expirationDate: '', +}; +beforeEach(function () { + return __awaiter(this, void 0, void 0, function* () { + offlineSigner = yield (0, config_1.createWallet)(config_1.mnemonic); + const params = { + offlineSigner, + nodeRestEndpoint: config_1.hidNodeEp.rest, + nodeRpcEndpoint: config_1.hidNodeEp.rpc, + namespace: config_1.hidNodeEp.namespace, + }; + hsSdk = new index_1.HypersignSSISdk(params); + yield hsSdk.init(); + }); +}); +describe('#generateKeys() method to generate publicKyeMultibase and privateKeyMultiBase', function () { + it('should return publickeyMultibase and privateKeyMultibase', function () { + return __awaiter(this, void 0, void 0, function* () { + const kp = yield hsSdk.did.bjjDID.generateKeys(); + issuerPrivateKeyMultibase = kp.privateKeyMultibase; + issuerPublicKeyMultibase = kp.publicKeyMultibase; + (0, chai_1.expect)(kp).to.be.a('object'); + (0, chai_1.should)().exist(kp.privateKeyMultibase); + (0, chai_1.should)().exist(kp.publicKeyMultibase); + (0, chai_1.should)().not.exist(kp.id); + }); + }); +}); +describe('DID Operation', () => { + describe('#generate() method to generate new did', function () { + it('should be able to generate a issuer did using babyJubJub', () => __awaiter(this, void 0, void 0, function* () { + issuerDidDoc = yield hsSdk.did.bjjDID.generate({ + publicKeyMultibase: issuerPublicKeyMultibase, + }); + issuerDid = issuerDidDoc.id; + verificationMethod = issuerDidDoc.verificationMethod; + (0, chai_1.expect)(issuerDidDoc).to.be.a('object'); + (0, chai_1.should)().exist(issuerDidDoc['@context']); + (0, chai_1.should)().exist(issuerDidDoc['id']); + (0, chai_1.should)().exist(issuerDidDoc['controller']); + (0, chai_1.should)().exist(issuerDidDoc['verificationMethod']); + (0, chai_1.expect)(issuerDidDoc['verificationMethod'] && + issuerDidDoc['authentication'] && + issuerDidDoc['assertionMethod'] && + issuerDidDoc['keyAgreement'] && + issuerDidDoc['capabilityInvocation'] && + issuerDidDoc['capabilityDelegation'] && + issuerDidDoc['service']).to.be.a('array'); + (0, chai_1.expect)(verificationMethod[0].type).to.be.equal('BabyJubJubKey2021'); + (0, chai_1.should)().exist(issuerDidDoc['authentication']); + (0, chai_1.should)().exist(issuerDidDoc['assertionMethod']); + (0, chai_1.should)().exist(issuerDidDoc['keyAgreement']); + (0, chai_1.should)().exist(issuerDidDoc['capabilityInvocation']); + (0, chai_1.should)().exist(issuerDidDoc['capabilityDelegation']); + (0, chai_1.should)().exist(issuerDidDoc['service']); + (0, chai_1.expect)(issuerDidDoc['authentication'].length).to.be.greaterThan(0); + (0, chai_1.expect)(issuerDidDoc['assertionMethod'].length).to.be.greaterThan(0); + (0, chai_1.expect)(issuerDidDoc['capabilityInvocation'].length).to.be.equal(0); + (0, chai_1.expect)(issuerDidDoc['capabilityDelegation'].length).to.be.equal(0); + (0, chai_1.expect)(issuerDidDoc['keyAgreement'].length).to.be.equal(0); + (0, chai_1.expect)(issuerDidDoc['service'].length).to.be.equal(0); + })); + it('should be able to genrate a did for holder', () => __awaiter(this, void 0, void 0, function* () { + const kp = yield hsSdk.did.bjjDID.generateKeys(); + holderPrivateKeyMultibase = kp.privateKeyMultibase; + holderPublicKeyMultibase = kp.publicKeyMultibase; + subjectDidDoc = yield hsSdk.did.bjjDID.generate({ + publicKeyMultibase: holderPublicKeyMultibase, + }); + subjectDid = subjectDidDoc.id; + })); + }); + describe('#register() method to register did', function () { + it('should be able to register did generated using BabyJubJubKey', () => __awaiter(this, void 0, void 0, function* () { + const registerDid = yield hsSdk.did.bjjDID.register({ + didDocument: issuerDidDoc, + privateKeyMultibase: issuerPrivateKeyMultibase, + verificationMethodId: verificationMethod[0].id, + }); + issuerDidDoc = registerDid.didDocument; + (0, chai_1.expect)(issuerDidDoc).to.be.a('object'); + (0, chai_1.should)().exist(issuerDidDoc['@context']); + (0, chai_1.should)().exist(issuerDidDoc['id']); + (0, chai_1.should)().exist(issuerDidDoc['controller']); + (0, chai_1.should)().exist(issuerDidDoc['verificationMethod']); + (0, chai_1.expect)(issuerDidDoc['verificationMethod'] && + issuerDidDoc['authentication'] && + issuerDidDoc['assertionMethod'] && + issuerDidDoc['keyAgreement'] && + issuerDidDoc['capabilityInvocation'] && + issuerDidDoc['capabilityDelegation'] && + issuerDidDoc['service']).to.be.a('array'); + (0, chai_1.expect)(verificationMethod[0].type).to.be.equal('BabyJubJubKey2021'); + (0, chai_1.should)().exist(issuerDidDoc['authentication']); + (0, chai_1.should)().exist(issuerDidDoc['assertionMethod']); + (0, chai_1.should)().exist(issuerDidDoc['keyAgreement']); + (0, chai_1.should)().exist(issuerDidDoc['capabilityInvocation']); + (0, chai_1.should)().exist(issuerDidDoc['capabilityDelegation']); + (0, chai_1.should)().exist(issuerDidDoc['service']); + (0, chai_1.expect)(issuerDidDoc['authentication'].length).to.be.greaterThan(0); + (0, chai_1.expect)(issuerDidDoc['assertionMethod'].length).to.be.greaterThan(0); + (0, chai_1.expect)(issuerDidDoc['capabilityInvocation'].length).to.be.equal(0); + (0, chai_1.expect)(issuerDidDoc['capabilityDelegation'].length).to.be.equal(0); + (0, chai_1.expect)(issuerDidDoc['keyAgreement'].length).to.be.equal(0); + (0, chai_1.expect)(issuerDidDoc['service'].length).to.be.equal(0); + (0, chai_1.should)().exist(registerDid.transactionHash); + })); + it('should be able to register did for holder', () => __awaiter(this, void 0, void 0, function* () { + const registerDid = yield hsSdk.did.bjjDID.register({ + didDocument: subjectDidDoc, + privateKeyMultibase: holderPrivateKeyMultibase, + verificationMethodId: subjectDidDoc.verificationMethod[0].id, + }); + subjectDidDoc = registerDid.didDocument; + })); + }); +}); +describe('Schema Operations', () => { + describe('#generate() method to create schema', function () { + it('should be able to generate new schema', function () { + return __awaiter(this, void 0, void 0, function* () { + const tempSchemaBody = Object.assign({}, schemaBody); + tempSchemaBody.author = issuerDid; + schemaObject = yield hsSdk.schema.hypersignBjjschema.generate(tempSchemaBody); + schemaId = schemaObject['id']; + (0, chai_1.expect)(schemaObject).to.be.a('object'); + (0, chai_1.should)().exist(schemaObject['type']); + (0, chai_1.should)().exist(schemaObject['modelVersion']); + (0, chai_1.should)().exist(schemaObject['id']); + (0, chai_1.should)().exist(schemaObject['name']); + (0, chai_1.should)().exist(schemaObject['author']); + (0, chai_1.should)().exist(schemaObject['authored']); + (0, chai_1.should)().exist(schemaObject['schema']); + (0, chai_1.expect)(schemaObject.schema).to.be.a('object'); + (0, chai_1.expect)(schemaObject['name']).to.be.equal(tempSchemaBody.name); + (0, chai_1.expect)(schemaObject['author']).to.be.equal(tempSchemaBody.author); + (0, chai_1.expect)(schemaObject['schema'].required).to.be.a('array'); + }); + }); + }); + describe('#sign() method to sign a schema', function () { + it('should be able to sign newly created schema', () => __awaiter(this, void 0, void 0, function* () { + signedSchema = yield yield hsSdk.schema.hypersignBjjschema.sign({ + privateKeyMultibase: issuerPrivateKeyMultibase, + schema: schemaObject, + verificationMethodId: issuerDidDoc['assertionMethod'][0], + }); + (0, chai_1.expect)(signedSchema).to.be.a('object'); + (0, chai_1.should)().exist(signedSchema.type); + (0, chai_1.should)().exist(signedSchema.modelVersion); + (0, chai_1.should)().exist(signedSchema['id']); + (0, chai_1.should)().exist(signedSchema['name']); + (0, chai_1.should)().exist(signedSchema['author']); + (0, chai_1.should)().exist(signedSchema['authored']); + (0, chai_1.should)().exist(signedSchema['schema']); + (0, chai_1.should)().exist(signedSchema.schema.schema); + (0, chai_1.should)().exist(signedSchema.schema.description); + (0, chai_1.should)().exist(signedSchema.schema.type); + (0, chai_1.should)().exist(signedSchema.schema.properties); + (0, chai_1.should)().exist(signedSchema.schema.required); + (0, chai_1.should)().exist(signedSchema.proof); + (0, chai_1.should)().exist(signedSchema.proof.type); + (0, chai_1.expect)(signedSchema.proof.type).to.be.equal('BJJSignature2021'); + (0, chai_1.should)().exist(signedSchema.proof.created); + (0, chai_1.should)().exist(signedSchema.proof.verificationMethod); + (0, chai_1.should)().exist(signedSchema.proof.proofPurpose); + (0, chai_1.expect)(signedSchema.proof.proofPurpose).to.be.equal('assertionMethod'); + (0, chai_1.should)().exist(signedSchema.proof.proofValue); + })); + }); + describe('#register() method to register a schema', function () { + it('should be able to register newly created schema', () => __awaiter(this, void 0, void 0, function* () { + const registerdSchema = yield hsSdk.schema.hypersignBjjschema.register({ schema: signedSchema }); + (0, chai_1.should)().exist(registerdSchema.transactionHash); + })); + }); + describe('#resolve() method to resolve a schema', function () { + it('Should be able to resolve schema from blockchain', () => __awaiter(this, void 0, void 0, function* () { + const resolvedSchema = yield hsSdk.schema.hypersignBjjschema.resolve({ schemaId }); + (0, chai_1.should)().exist(resolvedSchema.context); + (0, chai_1.should)().exist(resolvedSchema.type); + (0, chai_1.should)().exist(resolvedSchema.modelVersion); + (0, chai_1.should)().exist(resolvedSchema.id); + (0, chai_1.should)().exist(resolvedSchema.name); + (0, chai_1.should)().exist(resolvedSchema.author); + (0, chai_1.should)().exist(resolvedSchema.authored); + (0, chai_1.should)().exist(resolvedSchema.schema); + (0, chai_1.should)().exist(resolvedSchema.schema.schema); + (0, chai_1.should)().exist(resolvedSchema.schema.description); + (0, chai_1.should)().exist(resolvedSchema.schema.type); + (0, chai_1.should)().exist(resolvedSchema.schema.properties); + (0, chai_1.should)().exist(resolvedSchema.schema.required); + (0, chai_1.should)().exist(resolvedSchema.schema.additionalProperties); + (0, chai_1.should)().exist(resolvedSchema.proof); + (0, chai_1.should)().exist(resolvedSchema.proof.type); + (0, chai_1.should)().exist(resolvedSchema.proof.created); + (0, chai_1.should)().exist(resolvedSchema.proof.verificationMethod); + (0, chai_1.should)().exist(resolvedSchema.proof.proofPurpose); + (0, chai_1.should)().exist(resolvedSchema.proof.proofValue); + (0, chai_1.should)().exist(resolvedSchema.proof.clientSpecType); + (0, chai_1.expect)(resolvedSchema.proof.clientSpecType).to.be.equal('CLIENT_SPEC_TYPE_NONE'); + })); + }); +}); +describe('Credential Operation', () => { + describe('#generate() method to generate a credential', function () { + it('should not be able to generate new credential for a schema as both subjectDid and subjectDidDocSigned is passed', function () { + return __awaiter(this, void 0, void 0, function* () { + const tempCredentialBody = Object.assign({}, credentialBody); + tempCredentialBody.issuerDid = issuerDid; + tempCredentialBody.subjectDid = subjectDid; + tempCredentialBody['subjectDidDocSigned'] = subjectDidDoc; + return hsSdk.vc.bjjVC.generate(tempCredentialBody).catch(function (err) { + (0, chai_1.expect)(function () { + throw err; + }).to.throw(Error, 'HID-SSI-SDK:: Error: Both subjectDid and subjectDidDoc cannot be passed'); + }); + }); + }); + it('should not be able to generate new credential for a schema as not able to resolve subjectDid or subjectDidDoc as neither subjectDid nor subjectDidDocSigned is passed', function () { + return __awaiter(this, void 0, void 0, function* () { + const tempCredentialBody = Object.assign({}, credentialBody); + tempCredentialBody.issuerDid = issuerDid; + return hsSdk.vc.bjjVC.generate(tempCredentialBody).catch(function (err) { + (0, chai_1.expect)(function () { + throw err; + }).to.throw(Error, 'HID-SSI-SDK:: Error: Could not resolve the subjectDid or subjectDidDoc'); + }); + }); + }); + it('should not be able to generate new credential for a schema as nether schemaId nor schema Context is passed', function () { + return __awaiter(this, void 0, void 0, function* () { + const tempCredentialBody = Object.assign({}, credentialBody); + tempCredentialBody.issuerDid = issuerDid; + tempCredentialBody['subjectDidDocSigned'] = subjectDidDoc; + return hsSdk.vc.bjjVC.generate(tempCredentialBody).catch(function (err) { + (0, chai_1.expect)(function () { + throw err; + }).to.throw(Error, 'schemaId is required when schemaContext and type not passed'); + }); + }); + }); + it('should not be able to generate new credential for a schema as wrong issuer did is passed', function () { + return __awaiter(this, void 0, void 0, function* () { + const tempCredentialBody = Object.assign({}, credentialBody); + tempCredentialBody.schemaId = schemaId; + tempCredentialBody.issuerDid = issuerDid + 'xyz'; + tempCredentialBody['subjectDidDocSigned'] = subjectDidDoc; + return hsSdk.vc.bjjVC.generate(tempCredentialBody).catch(function (err) { + (0, chai_1.expect)(function () { + throw err; + }).to.throw(Error, `HID-SSI-SDK:: Error: Could not fetch issuer did doc, issuer did = ${tempCredentialBody.issuerDid}`); + }); + }); + }); + it('should not be able to generate new credential for a schema as not able to get subject did doc based on subjectDid passed', function () { + return __awaiter(this, void 0, void 0, function* () { + const tempCredentialBody = Object.assign({}, credentialBody); + tempCredentialBody.schemaId = schemaId; + tempCredentialBody.issuerDid = issuerDid; + tempCredentialBody['subjectDid'] = subjectDid; + return hsSdk.vc.bjjVC.generate(tempCredentialBody).catch(function (err) { + (0, chai_1.expect)(function () { + throw err; + }).to.throw(Error, `HID-SSI-SDK:: Error: Could not fetch subject did doc, subject did ${tempCredentialBody.subjectDid}`); + }); + }); + }); + it('should not be able to generate new credential for a schema as expiration date is passed in wrong format', function () { + return __awaiter(this, void 0, void 0, function* () { + const todaysDate = new Date(); + const tempExpirationDate = todaysDate.setDate(todaysDate.getDate() + 2); + const expirationDate = tempExpirationDate.toString(); + const tempCredentialBody = Object.assign({}, credentialBody); + tempCredentialBody.schemaId = schemaId; + tempCredentialBody['subjectDidDocSigned'] = subjectDidDoc; + tempCredentialBody['expirationDate'] = expirationDate.toString(); + tempCredentialBody.issuerDid = issuerDid; + return hsSdk.vc.bjjVC.generate(tempCredentialBody).catch(function (err) { + (0, chai_1.expect)(function () { + throw err; + }).to.throw(Error, 'Invalid time value'); + }); + }); + }); + it('should not be able to generate new credential for a schema as additional properties in schema is set to false but sending additional properties in field value at the time of generating credential', function () { + return __awaiter(this, void 0, void 0, function* () { + const expirationDate = new Date('12/11/2027'); + const tempCredentialBody = Object.assign({}, credentialBody); + tempCredentialBody.schemaId = schemaId; + tempCredentialBody['subjectDidDocSigned'] = subjectDidDoc; + tempCredentialBody['expirationDate'] = expirationDate.toString(); + tempCredentialBody.issuerDid = issuerDid; + tempCredentialBody.fields['type'] = 'string'; + tempCredentialBody.fields['value'] = 'Varsha'; + tempCredentialBody.fields['name'] = 'name'; + return hsSdk.vc.bjjVC.generate(tempCredentialBody).catch(function (err) { + (0, chai_1.expect)(function () { + throw err; + }).to.throw(Error, `Only ["${schemaBody.fields[0].name}"] attributes are possible. additionalProperties is false in the schema`); + }); + }); + }); + it('should be able to generate a credential', () => __awaiter(this, void 0, void 0, function* () { + const expirationDate = new Date('12/11/2027'); + const tempCredentialBody = Object.assign({}, credentialBody); + tempCredentialBody.schemaId = schemaId; + tempCredentialBody.subjectDid = subjectDid; + tempCredentialBody['expirationDate'] = expirationDate.toString(); + tempCredentialBody.issuerDid = issuerDid; + tempCredentialBody.fields = { name: 'varsha', address: 'random address' }; + credentialDetail = yield hsSdk.vc.bjjVC.generate(tempCredentialBody); + (0, chai_1.expect)(credentialDetail).to.be.a('object'); + (0, chai_1.should)().exist(credentialDetail['@context']); + (0, chai_1.should)().exist(credentialDetail['id']); + credentialId = credentialDetail.id; + (0, chai_1.should)().exist(credentialDetail['type']); + (0, chai_1.should)().exist(credentialDetail['issuanceDate']); + (0, chai_1.should)().exist(credentialDetail['issuer']); + (0, chai_1.should)().exist(credentialDetail['credentialSubject']); + (0, chai_1.should)().exist(credentialDetail['credentialStatus']); + (0, chai_1.expect)(credentialDetail['credentialStatus'].type).to.be.equal('HypersignCredentialStatus2023'); + })); + it('should be able to generate new credential for testing bulk registration', function () { + return __awaiter(this, void 0, void 0, function* () { + const expirationDate = new Date('11/11/2027'); + const tempCredentialBody = Object.assign({}, credentialBody); + tempCredentialBody.schemaId = schemaId; + tempCredentialBody.subjectDid = subjectDid; + tempCredentialBody['expirationDate'] = expirationDate.toString(); + tempCredentialBody.issuerDid = issuerDid; + tempCredentialBody['fields'] = { name: 'varsha', address: 'random address' }; + credentialDetail2 = yield hsSdk.vc.bjjVC.generate(tempCredentialBody); + (0, chai_1.expect)(credentialDetail).to.be.a('object'); + (0, chai_1.should)().exist(credentialDetail['@context']); + (0, chai_1.should)().exist(credentialDetail['id']); + (0, chai_1.should)().exist(credentialDetail['type']); + (0, chai_1.should)().exist(credentialDetail['issuanceDate']); + (0, chai_1.should)().exist(credentialDetail['issuer']); + (0, chai_1.should)().exist(credentialDetail['credentialSubject']); + (0, chai_1.should)().exist(credentialDetail['credentialSchema']); + (0, chai_1.should)().exist(credentialDetail['credentialStatus']); + (0, chai_1.expect)(credentialDetail['credentialStatus'].type).to.be.equal('HypersignCredentialStatus2023'); + }); + }); + it('should be able to generate new credential even without offlinesigner passed to constructor to test bulkRegistration', function () { + return __awaiter(this, void 0, void 0, function* () { + const expirationDate = new Date('11/11/2027'); + const tempCredentialBody = Object.assign({}, credentialBody); + tempCredentialBody.schemaId = schemaId; + tempCredentialBody.subjectDid = subjectDid; + tempCredentialBody['expirationDate'] = expirationDate.toString(); + tempCredentialBody.issuerDid = issuerDid; + tempCredentialBody.fields = { name: 'varsha', address: 'random address' }; + credentialDetail3 = yield yield hsSdk.vc.bjjVC.generate(tempCredentialBody); + (0, chai_1.expect)(credentialDetail).to.be.a('object'); + (0, chai_1.should)().exist(credentialDetail['@context']); + (0, chai_1.should)().exist(credentialDetail['id']); + (0, chai_1.should)().exist(credentialDetail['type']); + (0, chai_1.should)().exist(credentialDetail['issuanceDate']); + (0, chai_1.should)().exist(credentialDetail['issuer']); + (0, chai_1.should)().exist(credentialDetail['credentialSubject']); + (0, chai_1.should)().exist(credentialDetail['credentialSchema']); + (0, chai_1.should)().exist(credentialDetail['credentialStatus']); + (0, chai_1.expect)(credentialDetail['credentialStatus'].type).to.be.equal('HypersignCredentialStatus2023'); + }); + }); + }); + describe('#issueCredential() method for issuing credential', function () { + it('should not be able to issueCredential as verificationMethodId is null or empty', function () { + return __awaiter(this, void 0, void 0, function* () { + const tempIssueCredentialBody = Object.assign({}, issueCredentialBody); + tempIssueCredentialBody.credential = credentialDetail; + tempIssueCredentialBody.issuerDid = issuerDid; + tempIssueCredentialBody.verificationMethodId = ''; + tempIssueCredentialBody.privateKeyMultibase = issuerPrivateKeyMultibase; + return yield hsSdk.vc.bjjVC.issue(tempIssueCredentialBody).catch(function (err) { + (0, chai_1.expect)(function () { + throw err; + }).to.throw(Error, 'HID-SSI-SDK:: Error: params.verificationMethodId is required to issue credential'); + }); + }); + }); + it('should not be able to issueCredential as credentialObject is null or undefined', function () { + return __awaiter(this, void 0, void 0, function* () { + const tempIssueCredentialBody = Object.assign({}, issueCredentialBody); + tempIssueCredentialBody.credential = undefined; + tempIssueCredentialBody.issuerDid = issuerDid; + tempIssueCredentialBody.verificationMethodId = verificationMethod[0].id; + tempIssueCredentialBody.privateKeyMultibase = issuerPrivateKeyMultibase; + return yield hsSdk.vc.bjjVC.issue(tempIssueCredentialBody).catch(function (err) { + (0, chai_1.expect)(function () { + throw err; + }).to.throw(Error, 'HID-SSI-SDK:: Error: params.credential is required to issue credential'); + }); + }); + }); + it('should not be able to issueCredential as privateKey is null or empty', function () { + return __awaiter(this, void 0, void 0, function* () { + const tempIssueCredentialBody = Object.assign({}, issueCredentialBody); + tempIssueCredentialBody.credential = credentialDetail; + tempIssueCredentialBody.issuerDid = issuerDid; + tempIssueCredentialBody.verificationMethodId = verificationMethod[0].id; + tempIssueCredentialBody.privateKeyMultibase = ''; + return yield hsSdk.vc.bjjVC.issue(tempIssueCredentialBody).catch(function (err) { + (0, chai_1.expect)(function () { + throw err; + }).to.throw(Error, 'HID-SSI-SDK:: Error: params.privateKeyMultibase is required to issue credential'); + }); + }); + }); + it('should not be able to issueCredential as issuerDid is null or empty', function () { + return __awaiter(this, void 0, void 0, function* () { + const tempIssueCredentialBody = Object.assign({}, issueCredentialBody); + tempIssueCredentialBody.credential = credentialDetail; + tempIssueCredentialBody.issuerDid = ''; + tempIssueCredentialBody.verificationMethodId = verificationMethod[0].id; + tempIssueCredentialBody.privateKeyMultibase = issuerPrivateKeyMultibase; + return yield hsSdk.vc.bjjVC.issue(tempIssueCredentialBody).catch(function (err) { + (0, chai_1.expect)(function () { + throw err; + }).to.throw(Error, 'HID-SSI-SDK:: Error: params.issuerDid is required to issue credential'); + }); + }); + }); + it('should be able to issue credential with credential status registered on chain', function () { + return __awaiter(this, void 0, void 0, function* () { + const tempIssueCredentialBody = Object.assign({}, issueCredentialBody); + tempIssueCredentialBody.credential = credentialDetail; + tempIssueCredentialBody.issuerDid = issuerDid; + tempIssueCredentialBody.verificationMethodId = verificationMethod[0].id; + tempIssueCredentialBody.privateKeyMultibase = issuerPrivateKeyMultibase; + const issuedCredResult = yield hsSdk.vc.bjjVC.issue(tempIssueCredentialBody); + const { signedCredential, credentialStatus, credentialStatusProof, credentialStatusRegistrationResult } = issuedCredResult; + signedVC = {}; + Object.assign(signedVC, signedCredential); + signedVC1 = signedCredential; + credenStatus = credentialStatus; + credentialId = signedVC.id; + credentialStatusId = signedCredential['credentialStatus'].id; + (0, chai_1.expect)(signedCredential).to.be.a('object'); + (0, chai_1.should)().exist(signedCredential['@context']); + (0, chai_1.should)().exist(signedCredential['id']); + (0, chai_1.should)().exist(signedCredential['type']); + (0, chai_1.should)().exist(signedCredential['issuanceDate']); + (0, chai_1.should)().exist(signedCredential['issuer']); + (0, chai_1.should)().exist(signedCredential['credentialSubject']); + (0, chai_1.should)().exist(signedCredential['credentialSchema']); + (0, chai_1.should)().exist(signedCredential['credentialStatus']); + (0, chai_1.should)().exist(signedCredential['proof']); + (0, chai_1.expect)(signedCredential['id']).to.be.equal(tempIssueCredentialBody.credential.id); + (0, chai_1.expect)(credentialStatus).to.be.a('object'); + (0, chai_1.should)().exist(credentialStatus['@context']); + (0, chai_1.should)().exist(credentialStatus['id']); + (0, chai_1.should)().exist(credentialStatus['issuer']); + (0, chai_1.should)().exist(credentialStatus['issuanceDate']); + (0, chai_1.should)().exist(credentialStatus['credentialMerkleRootHash']); + (0, chai_1.should)().exist(credentialStatus['proof']); + (0, chai_1.should)().exist(credentialStatus['proof'].type); + (0, chai_1.expect)(credentialStatus['proof'].type).to.be.equal('BJJSignature2021'); + (0, chai_1.expect)(credentialStatusProof).to.be.a('object'); + (0, chai_1.should)().exist(credentialStatusProof['type']); + (0, chai_1.expect)(credentialStatusProof['type']).to.be.equal('BJJSignature2021'); + (0, chai_1.should)().exist(credentialStatusProof['created']); + (0, chai_1.should)().exist(credentialStatusProof['verificationMethod']); + (0, chai_1.should)().exist(credentialStatusProof['proofPurpose']); + (0, chai_1.should)().exist(credentialStatusProof['proofValue']); + (0, chai_1.expect)(credentialStatusRegistrationResult).to.be.a('object'); + (0, chai_1.should)().exist(credentialStatusRegistrationResult['height']); + (0, chai_1.should)().exist(credentialStatusRegistrationResult['transactionHash']); + (0, chai_1.should)().exist(credentialStatusRegistrationResult['gasUsed']); + (0, chai_1.should)().exist(credentialStatusRegistrationResult['gasWanted']); + }); + }); + it('should be able to issue credential without having the credential status registered on chain', function () { + return __awaiter(this, void 0, void 0, function* () { + const expirationDate = new Date('12/11/2027'); + const tempCredentialBody = Object.assign({}, credentialBody); + tempCredentialBody.schemaId = schemaId; + // tempCredentialBody['subjectDidDocSigned'] = holderSignedDidDoc; + tempCredentialBody['expirationDate'] = expirationDate.toString(); + tempCredentialBody.issuerDid = issuerDid; + tempCredentialBody.subjectDid = subjectDid; + tempCredentialBody.fields = { name: 'varsha', address: 'random address' }; + const credentialDetail = yield hsSdk.vc.bjjVC.generate(tempCredentialBody); + const tempIssueCredentialBody = Object.assign({}, issueCredentialBody); + tempIssueCredentialBody.credential = credentialDetail; + tempIssueCredentialBody.issuerDid = issuerDid; + tempIssueCredentialBody.verificationMethodId = verificationMethod[0].id; + tempIssueCredentialBody.privateKeyMultibase = issuerPrivateKeyMultibase; + tempIssueCredentialBody.registerCredential = false; + const issuedCredResult = yield hsSdk.vc.bjjVC.issue(tempIssueCredentialBody); + const { signedCredential, credentialStatus, credentialStatusProof, credentialStatusRegistrationResult } = issuedCredResult; + credentialStatus2 = credentialStatus; + credentialStatusProof2 = credentialStatusProof; + (0, chai_1.expect)(signedCredential).to.be.a('object'); + (0, chai_1.expect)(credentialStatus).to.be.a('object'); + (0, chai_1.expect)(credentialStatusProof).to.be.a('object'); + (0, chai_1.should)().not.exist(credentialStatusRegistrationResult); + }); + }); + it('should be able to issue credential without having the credential status registered on chain to test bulkRegistration', function () { + return __awaiter(this, void 0, void 0, function* () { + const tempIssueCredentialBody = Object.assign({}, issueCredentialBody); + tempIssueCredentialBody.credential = credentialDetail2; + tempIssueCredentialBody.issuerDid = issuerDid; + tempIssueCredentialBody.verificationMethodId = verificationMethod[0].id; + tempIssueCredentialBody.privateKeyMultibase = issuerPrivateKeyMultibase; + tempIssueCredentialBody.registerCredential = false; + issuedCredResult = yield hsSdk.vc.bjjVC.issue(tempIssueCredentialBody); + const { signedCredential, credentialStatus, credentialStatusProof, credentialStatusRegistrationResult } = issuedCredResult; + (0, chai_1.expect)(signedCredential).to.be.a('object'); + (0, chai_1.expect)(credentialStatus).to.be.a('object'); + (0, chai_1.expect)(credentialStatusProof).to.be.a('object'); + (0, chai_1.should)().not.exist(credentialStatusRegistrationResult); + }); + }); + it('should be able to issue credential without having the credential status registered on chain to test bulkRegistration', function () { + return __awaiter(this, void 0, void 0, function* () { + const tempIssueCredentialBody = Object.assign({}, issueCredentialBody); + tempIssueCredentialBody.credential = credentialDetail3; + tempIssueCredentialBody.issuerDid = issuerDid; + tempIssueCredentialBody.verificationMethodId = verificationMethod[0].id; + tempIssueCredentialBody.privateKeyMultibase = issuerPrivateKeyMultibase; + tempIssueCredentialBody.registerCredential = false; + issuedCredResult2 = yield hsSdk.vc.bjjVC.issue(tempIssueCredentialBody); + const { signedCredential, credentialStatus, credentialStatusProof, credentialStatusRegistrationResult } = issuedCredResult; + (0, chai_1.expect)(signedCredential).to.be.a('object'); + (0, chai_1.expect)(credentialStatus).to.be.a('object'); + (0, chai_1.expect)(credentialStatusProof).to.be.a('object'); + (0, chai_1.should)().not.exist(credentialStatusRegistrationResult); + }); + }); + }); + describe('#generateSeletiveDisclosure() method for genertaaing sd', function () { + const presentationBody = { + verifiableCredential: signedVC1, + verificationMethodId: '', + issuerDid, + }; + it('should not be able to generate a sd presentation document as verfiableCredential is not passed or null', function () { + return __awaiter(this, void 0, void 0, function* () { + const tempPresentationBody = Object.assign({}, presentationBody); + tempPresentationBody.verifiableCredential = null; + return hsSdk.vc.bjjVC.generateSeletiveDisclosure(tempPresentationBody).catch(function (err) { + (0, chai_1.expect)(function () { + throw err; + }).to.throw(Error, 'HID-SSI-SDK:: verifiableCredential is required'); + }); + }); + }); + it('should not be able to generate a sd presentation document as frame is not passed or null', function () { + return __awaiter(this, void 0, void 0, function* () { + const tempPresentationBody = Object.assign({}, presentationBody); + tempPresentationBody.verifiableCredential = signedVC; + tempPresentationBody['frame'] = null; + return hsSdk.vc.bjjVC.generateSeletiveDisclosure(tempPresentationBody).catch(function (err) { + (0, chai_1.expect)(function () { + throw err; + }).to.throw(Error, 'HID-SSI-SDK:: frame is required'); + }); + }); + }); + it('should not be able to generate a sd presentation document as verificationMethodId is not passed', function () { + return __awaiter(this, void 0, void 0, function* () { + const tempPresentationBody = Object.assign({}, presentationBody); + tempPresentationBody.verifiableCredential = signedVC; + const revelDocument = { + type: ['VerifiableCredential', 'TestSchema'], + expirationDate: {}, + issuanceDate: {}, + issuer: {}, + credentialSubject: { + '@explicit': true, + id: {}, + }, + }; + tempPresentationBody['frame'] = revelDocument; + return hsSdk.vc.bjjVC.generateSeletiveDisclosure(tempPresentationBody).catch(function (err) { + (0, chai_1.expect)(function () { + throw err; + }).to.throw(Error, 'HID-SSI-SDK:: verificationMethodId is required'); + }); + }); + }); + it('should not be able to generate a sd presentation document as issuerDid is not passed', function () { + return __awaiter(this, void 0, void 0, function* () { + const tempPresentationBody = Object.assign({}, presentationBody); + tempPresentationBody.verifiableCredential = signedVC; + const revelDocument = { + type: ['VerifiableCredential', 'TestSchema'], + expirationDate: {}, + issuanceDate: {}, + issuer: {}, + credentialSubject: { + '@explicit': true, + id: {}, + }, + }; + tempPresentationBody['frame'] = revelDocument; + tempPresentationBody.verificationMethodId = verificationMethod[0].id; + tempPresentationBody.issuerDid = ''; + return hsSdk.vc.bjjVC.generateSeletiveDisclosure(tempPresentationBody).catch(function (err) { + (0, chai_1.expect)(function () { + throw err; + }).to.throw(Error, 'HID-SSI-SDK:: issuerDid is required'); + }); + }); + }); + it('should be able to generate a sd document', () => __awaiter(this, void 0, void 0, function* () { + const presentationBody = { + verifiableCredential: {}, + frame: {}, + verificationMethodId: verificationMethod[0].id, + issuerDid, + }; + const revelDocument = { + type: ['VerifiableCredential', 'TestSchema'], + expirationDate: {}, + issuanceDate: {}, + issuer: {}, + credentialSubject: { + '@explicit': true, + id: {}, + }, + }; + const tempPresentationBody = Object.assign({}, presentationBody); + tempPresentationBody.verifiableCredential = signedVC1; + tempPresentationBody.frame = revelDocument; + tempPresentationBody.issuerDid = issuerDid; + tempPresentationBody.verificationMethodId = verificationMethod[0].id; + selectiveDisclosure = yield hsSdk.vc.bjjVC.generateSeletiveDisclosure(tempPresentationBody); + (0, chai_1.should)().exist(selectiveDisclosure['@context']); + (0, chai_1.should)().exist(selectiveDisclosure['id']); + (0, chai_1.expect)(selectiveDisclosure['id']).to.be.equal(credentialId); + (0, chai_1.should)().exist(selectiveDisclosure['type']); + (0, chai_1.should)().exist(selectiveDisclosure['credentialSchema']); + (0, chai_1.should)().exist(selectiveDisclosure['credentialStatus']); + (0, chai_1.should)().exist(selectiveDisclosure['credentialSubject']); + (0, chai_1.expect)(selectiveDisclosure['credentialSubject']).to.be.equal(subjectDid); + (0, chai_1.should)().exist(selectiveDisclosure['expirationDate']); + (0, chai_1.should)().exist(selectiveDisclosure['issuanceDate']); + (0, chai_1.should)().exist(selectiveDisclosure['issuer']); + (0, chai_1.expect)(selectiveDisclosure['issuer']).to.be.equal(issuerDid); + (0, chai_1.should)().exist(selectiveDisclosure['proof']); + (0, chai_1.should)().exist(selectiveDisclosure['proof'].type); + (0, chai_1.expect)(selectiveDisclosure['proof'].type).to.be.equal('BabyJubJubSignatureProof2021'); + (0, chai_1.should)().exist(selectiveDisclosure['proof'].created); + (0, chai_1.should)().exist(selectiveDisclosure['proof'].verificationMethod); + (0, chai_1.should)().exist(selectiveDisclosure['proof'].proofPurpose); + (0, chai_1.should)().exist(selectiveDisclosure['proof'].credentialRoot); + (0, chai_1.should)().exist(selectiveDisclosure['proof'].proofValue); + })); + }); + describe('#verify() method for verifying credential', function () { + it('should be able to verify credential', function () { + return __awaiter(this, void 0, void 0, function* () { + const params = { + credential: signedVC1, + issuerDid, + verificationMethodId: verificationMethod[0].id, + }; + const verificationResult = yield hsSdk.vc.bjjVC.verify(params); + (0, chai_1.expect)(verificationResult).to.be.a('object'); + (0, chai_1.should)().exist(verificationResult.verified); + (0, chai_1.expect)(verificationResult.verified).to.be.equal(true); + (0, chai_1.should)().exist(verificationResult.results); + (0, chai_1.expect)(verificationResult.results).to.be.a('array'); + (0, chai_1.should)().exist(verificationResult.statusResult); + (0, chai_1.expect)(verificationResult.statusResult.verified).to.be.equal(true); + }); + }); + it('should not be able to verify credential as verificationMethodId is null or empty', function () { + return __awaiter(this, void 0, void 0, function* () { + const params = { + credential: signedVC, + issuerDid, + verificationMethodId: verificationMethod[0].id, + }; + params.verificationMethodId = ''; + return hsSdk.vc.bjjVC.verify(params).catch(function (err) { + (0, chai_1.expect)(function () { + throw err; + }).to.throw(Error, 'HID-SSI-SDK:: Error: params.verificationMethodId is required to verify credential'); + }); + }); + }); + it('should not be able to verify credential as issuerDid is null or empty', function () { + return __awaiter(this, void 0, void 0, function* () { + const params = { + credential: signedVC, + issuerDid, + verificationMethodId: verificationMethod[0].id, + }; + params.issuerDid = ''; + return hsSdk.vc.bjjVC.verify(params).catch(function (err) { + (0, chai_1.expect)(function () { + throw err; + }).to.throw(Error, 'HID-SSI-SDK:: Error: params.issuerDid or params.issuerDidDocument is required to verify credential'); + }); + }); + }); + it('should not be able to verify credential as proof is null or undefined', function () { + return __awaiter(this, void 0, void 0, function* () { + const params = { + credential: signedVC, + issuerDid, + verificationMethodId: verificationMethod[0].id, + }; + if (params.credential) { + params.credential.proof = undefined; + } + return hsSdk.vc.bjjVC.verify(params).catch(function (err) { + (0, chai_1.expect)(function () { + throw err; + }).to.throw(Error, 'HID-SSI-SDK:: params.credential.proof is required to verify credential'); + }); + }); + }); + it('should not be able to verify credential as credential is null or undefined', function () { + return __awaiter(this, void 0, void 0, function* () { + const params = { + credential: signedVC, + issuerDid, + verificationMethodId: verificationMethod[0].id, + }; + params.credential = null; + return hsSdk.vc.bjjVC.verify(params).catch(function (err) { + (0, chai_1.expect)(function () { + throw err; + }).to.throw(Error, 'HID-SSI-SDK:: params.credential is required to verify credential'); + }); + }); + }); + }); +}); +describe('Verifiable Credential Status Opearations', () => { + describe('#checkCredentialStatus() method to check status of the credential', function () { + it('should not be able to check credential as credentialId is null or empty', function () { + return __awaiter(this, void 0, void 0, function* () { + return hsSdk.vc.bjjVC.checkCredentialStatus().catch(function (err) { + (0, chai_1.expect)(function () { + throw err; + }).to.throw(Error, 'HID-SSI-SDK:: Error: params.credentialId is required to resolve credential status'); + }); + }); + }); + it('should not be able to check credential as credentialId is invalid', function () { + return __awaiter(this, void 0, void 0, function* () { + return hsSdk.vc.bjjVC.checkCredentialStatus({ credentialId: credentialId + 'x' }).catch(function (err) { + (0, chai_1.expect)(function () { + throw err; + }).to.throw(Error, 'No credential status found. Probably invalid credentialId'); + }); + }); + }); + it('should be able to check credential status', function () { + return __awaiter(this, void 0, void 0, function* () { + const credentialStatus = yield hsSdk.vc.bjjVC.checkCredentialStatus({ credentialId: credentialId }); + (0, chai_1.expect)(credentialStatus).to.be.a('object'); + (0, chai_1.should)().exist(credentialStatus.verified); + (0, chai_1.expect)(credentialStatus.verified).to.be.equal(true); + }); + }); + }); + describe('#resolveCredentialStatus() method to resolve status of the credential from blockchain', function () { + it('should not be able to resolve credential as credentialId is not passed', function () { + return __awaiter(this, void 0, void 0, function* () { + return hsSdk.vc.bjjVC.resolveCredentialStatus({ credentialId: '' }).catch(function (err) { + (0, chai_1.expect)(function () { + throw err; + }).to.throw(Error, 'HID-SSI-SDK:: Error: params.credentialId is required to resolve credential status'); + }); + }); + }); + it('should be able to check credential status', function () { + return __awaiter(this, void 0, void 0, function* () { + const credentialStatus = yield hsSdk.vc.bjjVC.resolveCredentialStatus({ credentialId: credentialId }); + (0, chai_1.expect)(credentialStatus).to.be.a('object'); + (0, chai_1.should)().exist(credentialStatus.revoked); + (0, chai_1.should)().exist(credentialStatus.suspended); + (0, chai_1.should)().exist(credentialStatus.remarks); + (0, chai_1.should)().exist(credentialStatus.issuer); + (0, chai_1.should)().exist(credentialStatus.issuanceDate); + (0, chai_1.should)().exist(credentialStatus.credentialMerkleRootHash); + (0, chai_1.should)().exist(credentialStatus.proof); + }); + }); + }); + describe('#updateCredentialStatus this method is to change credential status to revoked or suspended', function () { + it('should not be able to update credential as verificationMethodId is not passed', function () { + return __awaiter(this, void 0, void 0, function* () { + const tempParams = { + credentialStatus: credenStatus, + issuerDid, + verificationMethodId: '', + privateKeyMultibase: issuerPrivateKeyMultibase, + status: 'SUSPENDED', + statusReason: 'Suspending this credential for some time', + }; + tempParams.verificationMethodId = ''; + return hsSdk.vc.bjjVC.updateCredentialStatus(tempParams).catch(function (err) { + (0, chai_1.expect)(function () { + throw err; + }).to.throw(Error, 'HID-SSI-SDK:: Error: params.verificationMethodId is required to update credential status'); + }); + }); + }); + it('should not be able to update credential as privateKey is not passed', function () { + return __awaiter(this, void 0, void 0, function* () { + const tempParams = { + credentialStatus: credenStatus, + issuerDid, + verificationMethodId: verificationMethod[0].id, + privateKeyMultibase: '', + status: 'SUSPENDED', + statusReason: 'Suspending this credential for some time', + }; + tempParams.verificationMethodId = verificationMethod[0].id; + tempParams.credentialStatus = credenStatus; + tempParams.privateKeyMultibase = ''; + return hsSdk.vc.bjjVC.updateCredentialStatus(tempParams).catch(function (err) { + (0, chai_1.expect)(function () { + throw err; + }).to.throw(Error, 'HID-SSI-SDK:: Error: params.privateKeyMultibase is required to update credential status'); + }); + }); + }); + it('should not be able to update credential as issuerDid is not passed', function () { + return __awaiter(this, void 0, void 0, function* () { + const tempParams = { + credentialStatus: credenStatus, + issuerDid: '', + verificationMethodId: verificationMethod[0].id, + privateKeyMultibase: issuerPrivateKeyMultibase, + status: 'SUSPENDED', + statusReason: 'Suspending this credential for some time', + }; + tempParams.verificationMethodId = verificationMethod[0].id; + tempParams.credentialStatus = credenStatus; + tempParams.privateKeyMultibase = issuerPrivateKeyMultibase; + tempParams.issuerDid = ''; + return hsSdk.vc.bjjVC.updateCredentialStatus(tempParams).catch(function (err) { + (0, chai_1.expect)(function () { + throw err; + }).to.throw(Error, 'HID-SSI-SDK:: Error: params.issuerDid is required to update credential status'); + }); + }); + }); + it('should not be able to update credential as status is not passed', function () { + return __awaiter(this, void 0, void 0, function* () { + const tempParams = { + credentialStatus: credenStatus, + issuerDid, + verificationMethodId: verificationMethod[0].id, + privateKeyMultibase: issuerPrivateKeyMultibase, + status: '', + statusReason: 'Suspending this credential for some time', + }; + tempParams.verificationMethodId = verificationMethod[0].id; + tempParams.credentialStatus = credenStatus; + tempParams.privateKeyMultibase = issuerPrivateKeyMultibase; + tempParams.issuerDid = issuerDid; + tempParams.status = ''; + return hsSdk.vc.bjjVC.updateCredentialStatus(tempParams).catch(function (err) { + (0, chai_1.expect)(function () { + throw err; + }).to.throw(Error, 'HID-SSI-SDK:: Error: params.status is required to update credential status'); + }); + }); + }); + it('should not be able to update credential as status passed is invalid', function () { + return __awaiter(this, void 0, void 0, function* () { + const tempParams = { + credentialStatus: credenStatus, + issuerDid, + verificationMethodId: verificationMethod[0].id, + privateKeyMultibase: issuerPrivateKeyMultibase, + status: 'svgsdvjif', + statusReason: 'Suspending this credential for some time', + }; + tempParams.verificationMethodId = verificationMethod[0].id; + tempParams.credentialStatus = credenStatus; + tempParams.privateKeyMultibase = issuerPrivateKeyMultibase; + tempParams.issuerDid = issuerDid; + tempParams.status = 'svgsdvjif'; + return hsSdk.vc.bjjVC.updateCredentialStatus(tempParams).catch(function (err) { + (0, chai_1.expect)(function () { + throw err; + }).to.throw(Error, `HID-SSI-SDK:: Error: params.status is invalid`); + }); + }); + }); + it('should be able to change credential status to suspended', function () { + return __awaiter(this, void 0, void 0, function* () { + const credentialStatus = yield hsSdk.vc.bjjVC.resolveCredentialStatus({ credentialId }); + const params = { + credentialStatus, + issuerDid, + verificationMethodId: verificationMethod[0].id, + privateKeyMultibase: issuerPrivateKeyMultibase, + status: 'SUSPENDED', + statusReason: 'Suspending this credential for some time', + }; + const updatedCredResult = yield hsSdk.vc.bjjVC.updateCredentialStatus(params); + (0, chai_1.expect)(updatedCredResult).to.be.a('object'); + (0, chai_1.expect)(updatedCredResult.code).to.be.equal(0); + (0, chai_1.expect)(updatedCredResult.transactionHash).to.be.a('string'); + }); + }); + it('should not be able to suspend a suspended credential status', function () { + return __awaiter(this, void 0, void 0, function* () { + const credentialStatus = yield hsSdk.vc.bjjVC.resolveCredentialStatus({ credentialId }); + const params = { + credentialStatus: credentialStatus, + issuerDid, + verificationMethodId: verificationMethod[0].id, + privateKeyMultibase: issuerPrivateKeyMultibase, + status: 'SUSPENDED', + statusReason: 'Suspending this credential for some time', + }; + return hsSdk.vc.bjjVC.updateCredentialStatus(params).catch(function (err) { + (0, chai_1.expect)(function () { + throw err; + }).to.throw(Error, 'failed to execute message; message index: 0: incoming Credential Status Document does not have any changes: invalid Credential Status'); + }); + }); + }); + it('should be able to change credential status to Live', function () { + return __awaiter(this, void 0, void 0, function* () { + const credentialStatus = yield hsSdk.vc.bjjVC.resolveCredentialStatus({ credentialId }); + const params = { + credentialStatus, + issuerDid, + verificationMethodId: verificationMethod[0].id, + privateKeyMultibase: issuerPrivateKeyMultibase, + status: 'LIVE', + statusReason: 'Setting the status to LIVE', + }; + const updatedCredResult = yield hsSdk.vc.bjjVC.updateCredentialStatus(params); + (0, chai_1.expect)(updatedCredResult).to.be.a('object'); + (0, chai_1.expect)(updatedCredResult.code).to.be.equal(0); + (0, chai_1.expect)(updatedCredResult.transactionHash).to.be.a('string'); + }); + }); + it('should be able to change credential status to Revoke', function () { + return __awaiter(this, void 0, void 0, function* () { + const credentialStatus = yield hsSdk.vc.bjjVC.resolveCredentialStatus({ credentialId }); + const params = { + credentialStatus, + issuerDid, + verificationMethodId: verificationMethod[0].id, + privateKeyMultibase: issuerPrivateKeyMultibase, + status: 'REVOKED', + statusReason: 'Revoking the credential', + }; + const updatedCredResult = yield hsSdk.vc.bjjVC.updateCredentialStatus(params); + (0, chai_1.expect)(updatedCredResult).to.be.a('object'); + (0, chai_1.expect)(updatedCredResult.code).to.be.equal(0); + (0, chai_1.expect)(updatedCredResult.transactionHash).to.be.a('string'); + }); + }); + it('should not be able to revoke a revoked credential status', function () { + return __awaiter(this, void 0, void 0, function* () { + const credentialStatus = yield hsSdk.vc.bjjVC.resolveCredentialStatus({ credentialId }); + const params = { + credentialStatus, + issuerDid, + verificationMethodId: verificationMethod[0].id, + privateKeyMultibase: issuerPrivateKeyMultibase, + status: 'REVOKED', + statusReason: 'Revoking the credential', + }; + return hsSdk.vc.bjjVC.updateCredentialStatus(params).catch(function (err) { + (0, chai_1.expect)(function () { + throw err; + }).to.throw(Error, 'failed to execute message; message index: 0: incoming Credential Status Document does not have any changes: invalid Credential Status'); + }); + }); + }); + it('should not be able to change the status of credential as it is revoked', function () { + return __awaiter(this, void 0, void 0, function* () { + const credentialStatus = yield hsSdk.vc.bjjVC.resolveCredentialStatus({ credentialId }); + const params = { + credentialStatus, + issuerDid, + verificationMethodId: verificationMethod[0].id, + privateKeyMultibase: issuerPrivateKeyMultibase, + status: 'SUSPENDED', + statusReason: 'Suspending this credential for some time', + }; + return hsSdk.vc.bjjVC.updateCredentialStatus(params).catch(function (err) { + (0, chai_1.expect)(err.message).to.include(`failed to execute message; message index: 0: credential status ${credentialId} could not be updated since it is revoked: invalid Credential Status`); + }); + }); + }); + }); + describe('#registerCredentialStatus() method to register credential on blockchain', function () { + it('should not be able to register credential as credentialStatusProof is not passed', function () { + return __awaiter(this, void 0, void 0, function* () { + return hsSdk.vc.bjjVC.registerCredentialStatus({ credentialStatus: credentialStatus2 }).catch(function (err) { + (0, chai_1.expect)(function () { + throw err; + }).to.throw(Error, 'HID-SSI-SDK:: Error: credentialStatus and credentialStatusProof are required to register credential status'); + }); + }); + }); + it('should not be able to register credential as credentialStatus is not passed', function () { + return __awaiter(this, void 0, void 0, function* () { + return hsSdk.vc.bjjVC + .registerCredentialStatus({ credentialStatusProof: credentialStatusProof2 }) + .catch(function (err) { + (0, chai_1.expect)(function () { + throw err; + }).to.throw(Error, 'HID-SSI-SDK:: Error: credentialStatus and credentialStatusProof are required to register credential status'); + }); + }); + }); + it('should be able to register credential on blockchain', function () { + return __awaiter(this, void 0, void 0, function* () { + const registerCredDetail = yield hsSdk.vc.bjjVC.registerCredentialStatus({ + credentialStatus: credentialStatus2, + credentialStatusProof: credentialStatusProof2, + }); + (0, chai_1.expect)(registerCredDetail).to.be.a('object'); + (0, chai_1.should)().exist(registerCredDetail.transactionHash); + }); + }); + it('should not be able to register credential on blockchain as stutus already registerd on chain', function () { + return __awaiter(this, void 0, void 0, function* () { + return hsSdk.vc.bjjVC + .registerCredentialStatus({ + credentialStatus: credentialStatus2, + credentialStatusProof: credentialStatusProof2, + }) + .catch(function (err) { + (0, chai_1.expect)(function () { + throw err; + }).to.throw('failed to execute message; message index: 0: credential status document already exists'); + }); + }); + }); + }); + describe('#generateRegisterCredentialStatusTxnMessage() method to generate transaction message for credential2', function () { + it('should not be able to generatecredential status TxnMessage as credentialStatus is not passed', function () { + return __awaiter(this, void 0, void 0, function* () { + const credentialStatus = null; + const credentialStatusProof = issuedCredResult.credentialStatusProof; + return hsSdk.vc.bjjVC + .generateRegisterCredentialStatusTxnMessage(credentialStatus, credentialStatusProof) + .catch(function (err) { + (0, chai_1.expect)(function () { + throw err; + }).to.throw(Error, 'HID-SSI-SDK:: Error: credentialStatus and proof are required to register credential status'); + }); + }); + }); + it('should not be able to generatecredential status TxnMessage as credentialStatusProof is not passed', function () { + return __awaiter(this, void 0, void 0, function* () { + const credentialStatus = issuedCredResult.credentialStatus; + const credentialStatusProof = null; + return hsSdk.vc.bjjVC + .generateRegisterCredentialStatusTxnMessage(credentialStatus, credentialStatusProof) + .catch(function (err) { + (0, chai_1.expect)(function () { + throw err; + }).to.throw(Error, 'HID-SSI-SDK:: Error: credentialStatus and proof are required to register credential status'); + }); + }); + }); + it('should be able to generate credential status TxnMessage', function () { + return __awaiter(this, void 0, void 0, function* () { + const credentialStatus = issuedCredResult.credentialStatus; + const credentialStatusProof = issuedCredResult.credentialStatusProof; + const credentialStatus2 = issuedCredResult2.credentialStatus; + const credentialStatusProof2 = issuedCredResult2.credentialStatusProof; + const txnMessage1 = yield hsSdk.vc.bjjVC.generateRegisterCredentialStatusTxnMessage(credentialStatus, credentialStatusProof); + credentialTransMessage.push(txnMessage1); + const txnMessage2 = yield hsSdk.vc.bjjVC.generateRegisterCredentialStatusTxnMessage(credentialStatus2, credentialStatusProof2); + credentialTransMessage.push(txnMessage2); + (0, chai_1.expect)(txnMessage1).to.be.a('object'); + (0, chai_1.should)().exist(txnMessage1.typeUrl); + (0, chai_1.should)().exist(txnMessage1.value); + (0, chai_1.should)().exist(txnMessage1.value.credentialStatusDocument); + (0, chai_1.should)().exist(txnMessage1.value.credentialStatusProof); + (0, chai_1.should)().exist(txnMessage1.value.txAuthor); + }); + }); + }); + describe('#registerCredentialStatusTxnBulk() method to register credential on blockchain', function () { + it('should not be able to register multiple credential as txnMessage is not passed', function () { + return __awaiter(this, void 0, void 0, function* () { + const txnMessage = []; + return hsSdk.vc.bjjVC.registerCredentialStatusTxnBulk(txnMessage).catch(function (err) { + (0, chai_1.expect)(function () { + throw err; + }).to.throw(Error, 'HID-SSI-SDK:: Error: txnMessage is required to register credential status'); + }); + }); + }); + it('should be able to register credential on blockchain in a bulk', function () { + return __awaiter(this, void 0, void 0, function* () { + const registerCredDetail = yield hsSdk.vc.bjjVC.registerCredentialStatusTxnBulk(credentialTransMessage); + (0, chai_1.expect)(registerCredDetail).to.be.a('object'); + (0, chai_1.should)().exist(registerCredDetail.transactionHash); + }); + }); + }); +}); +// add testcase for sd diff --git a/build/src/tests/bjj/did/bjj_did.spec.d.ts b/build/src/tests/bjj/did/bjj_did.spec.d.ts new file mode 100644 index 0000000..1fff86b --- /dev/null +++ b/build/src/tests/bjj/did/bjj_did.spec.d.ts @@ -0,0 +1,2 @@ +export {}; +//# sourceMappingURL=bjj_did.spec.d.ts.map \ No newline at end of file diff --git a/build/src/tests/bjj/did/bjj_did.spec.d.ts.map b/build/src/tests/bjj/did/bjj_did.spec.d.ts.map new file mode 100644 index 0000000..a2a8441 --- /dev/null +++ b/build/src/tests/bjj/did/bjj_did.spec.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"bjj_did.spec.d.ts","sourceRoot":"","sources":["../../../../../src/tests/bjj/did/bjj_did.spec.ts"],"names":[],"mappings":""} \ No newline at end of file diff --git a/build/src/tests/bjj/did/bjj_did.spec.js b/build/src/tests/bjj/did/bjj_did.spec.js new file mode 100644 index 0000000..eaa4ca6 --- /dev/null +++ b/build/src/tests/bjj/did/bjj_did.spec.js @@ -0,0 +1,497 @@ +"use strict"; +var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { + function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } + return new (P || (P = Promise))(function (resolve, reject) { + function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } + function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } + function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } + step((generator = generator.apply(thisArg, _arguments || [])).next()); + }); +}; +Object.defineProperty(exports, "__esModule", { value: true }); +const index_1 = require("../../../index"); +const chai_1 = require("chai"); +const config_1 = require("../../config"); +let privateKeyMultibase; +let publicKeyMultibase; +let offlineSigner; +let hsSdk; +let didDocument; +let verificationMethod; +let didDocId; +let versionId; +beforeEach(function () { + return __awaiter(this, void 0, void 0, function* () { + offlineSigner = yield (0, config_1.createWallet)(config_1.mnemonic); + const params = { + offlineSigner, + nodeRestEndpoint: config_1.hidNodeEp.rest, + nodeRpcEndpoint: config_1.hidNodeEp.rpc, + namespace: config_1.hidNodeEp.namespace, + }; + hsSdk = new index_1.HypersignSSISdk(params); + yield hsSdk.init(); + }); +}); +describe('DID Test scenarios for BabyJubJub key', () => { + //remove seed while creating did so that wallet can generate different did every time + describe('#generateKeys() method to generate publicKyeMultibase and privateKeyMultiBase', function () { + it('should return publickeyMultibase and privateKeyMultibase', function () { + return __awaiter(this, void 0, void 0, function* () { + const kp = yield hsSdk.did.bjjDID.generateKeys(); + privateKeyMultibase = kp.privateKeyMultibase; + publicKeyMultibase = kp.publicKeyMultibase; + (0, chai_1.expect)(kp).to.be.a('object'); + (0, chai_1.should)().exist(kp.privateKeyMultibase); + (0, chai_1.should)().exist(kp.publicKeyMultibase); + (0, chai_1.should)().not.exist(kp.id); + }); + }); + }); + describe('#generate() method to generate new did', function () { + it('should not be able to generate did document and throw error as publicKeyMultibase passed is null or empty', function () { + return hsSdk.did.bjjDID.generate({ publicKeyMultibase: '' }).catch(function (err) { + (0, chai_1.expect)(function () { + throw err; + }).to.throw(Error, 'HID-SSI-SDK:: Error: params.publicKeyMultibase is required to generate new did didoc'); + }); + }); + it('should be able to generate a did using babyJubJub', () => __awaiter(this, void 0, void 0, function* () { + didDocument = yield hsSdk.did.bjjDID.generate({ + publicKeyMultibase + }); + didDocId = didDocument.id; + verificationMethod = didDocument.verificationMethod; + (0, chai_1.expect)(didDocument).to.be.a('object'); + (0, chai_1.should)().exist(didDocument['@context']); + (0, chai_1.should)().exist(didDocument['id']); + (0, chai_1.should)().exist(didDocument['controller']); + (0, chai_1.should)().exist(didDocument['verificationMethod']); + (0, chai_1.expect)(didDocument['verificationMethod'] && + didDocument['authentication'] && + didDocument['assertionMethod'] && + didDocument['keyAgreement'] && + didDocument['capabilityInvocation'] && + didDocument['capabilityDelegation'] && + didDocument['service']).to.be.a('array'); + (0, chai_1.expect)(verificationMethod[0].type).to.be.equal('BabyJubJubKey2021'); + (0, chai_1.should)().exist(didDocument['authentication']); + (0, chai_1.should)().exist(didDocument['assertionMethod']); + (0, chai_1.should)().exist(didDocument['keyAgreement']); + (0, chai_1.should)().exist(didDocument['capabilityInvocation']); + (0, chai_1.should)().exist(didDocument['capabilityDelegation']); + (0, chai_1.should)().exist(didDocument['service']); + (0, chai_1.expect)(didDocument['authentication'].length).to.be.greaterThan(0); + (0, chai_1.expect)(didDocument['assertionMethod'].length).to.be.greaterThan(0); + (0, chai_1.expect)(didDocument['capabilityInvocation'].length).to.be.equal(0); + (0, chai_1.expect)(didDocument['capabilityDelegation'].length).to.be.equal(0); + (0, chai_1.expect)(didDocument['keyAgreement'].length).to.be.equal(0); + (0, chai_1.expect)(didDocument['service'].length).to.be.equal(0); + })); + it('should be able to generate a did using babyJubJub with passed verification relationships', () => __awaiter(this, void 0, void 0, function* () { + const didDocument = yield hsSdk.did.bjjDID.generate({ + publicKeyMultibase, + verificationRelationships: ['authentication', 'assertionMethod'], + }); + (0, chai_1.expect)(didDocument).to.be.a('object'); + (0, chai_1.should)().exist(didDocument['@context']); + (0, chai_1.should)().exist(didDocument['id']); + (0, chai_1.should)().exist(didDocument['controller']); + (0, chai_1.should)().exist(didDocument['verificationMethod']); + (0, chai_1.expect)(didDocument['verificationMethod'] && + didDocument['authentication'] && + didDocument['assertionMethod'] && + didDocument['keyAgreement'] && + didDocument['capabilityInvocation'] && + didDocument['capabilityDelegation'] && + didDocument['service']).to.be.a('array'); + (0, chai_1.expect)(verificationMethod[0].type).to.be.equal('BabyJubJubKey2021'); + (0, chai_1.should)().exist(didDocument['authentication']); + (0, chai_1.should)().exist(didDocument['assertionMethod']); + (0, chai_1.should)().exist(didDocument['keyAgreement']); + (0, chai_1.should)().exist(didDocument['capabilityInvocation']); + (0, chai_1.should)().exist(didDocument['capabilityDelegation']); + (0, chai_1.should)().exist(didDocument['service']); + (0, chai_1.expect)(didDocument['authentication'].length).to.be.greaterThan(0); + (0, chai_1.expect)(didDocument['assertionMethod'].length).to.be.greaterThan(0); + (0, chai_1.expect)(didDocument['capabilityInvocation'].length).to.be.equal(0); + (0, chai_1.expect)(didDocument['capabilityDelegation'].length).to.be.equal(0); + (0, chai_1.expect)(didDocument['keyAgreement'].length).to.be.equal(0); + (0, chai_1.expect)(didDocument['service'].length).to.be.equal(0); + })); + }); + describe('#register() method to register did', function () { + it('should not able to register did document and throw error as didDocument is not passed or it is empty', function () { + return hsSdk.did.bjjDID + .register({ didDocument: {}, privateKeyMultibase, verificationMethodId: verificationMethod[0].id }) + .catch(function (err) { + (0, chai_1.expect)(function () { + throw err; + }).to.throw(Error, 'HID-SSI-SDK:: Error: params.didDocString is required to register a did'); + }); + }); + it('should not be able to register did document as privateKeyMultibase is null or empty', function () { + return hsSdk.did.bjjDID + .register({ didDocument, privateKeyMultibase: '', verificationMethodId: verificationMethod[0].id }) + .catch(function (err) { + (0, chai_1.expect)(function () { + throw err; + }).to.throw(Error, 'HID-SSI-SDK:: Error: params.privateKeyMultibase is required to register a did'); + }); + }); + it('should not be able to register did document as verificationMethodId is null or empty', function () { + return hsSdk.did.bjjDID + .register({ didDocument, privateKeyMultibase, verificationMethodId: '' }) + .catch(function (err) { + (0, chai_1.expect)(function () { + throw err; + }).to.throw(Error, 'HID-SSI-SDK:: Error: params.verificationMethodId is required to register a did'); + }); + }); + it('should not be able to register did document as didDocument is not in Ld-json fromat', function () { + const didDoc = JSON.parse(JSON.stringify(didDocument)); + didDoc.context = didDoc['@context']; + delete didDoc['@context']; + return hsSdk.did.bjjDID + .register({ didDocument: didDoc, privateKeyMultibase, verificationMethodId: verificationMethod[0].id }) + .catch(function (err) { + (0, chai_1.expect)(function () { + throw err; + }).to.throw(Error, 'HID-SSI-SDK:: Error: didDocument is not in Ld-json format'); + }); + }); + it('should not be able to register a did document as neither privateKeyMultibase nor verificationMethodId is passed and signData passed is empty array', () => __awaiter(this, void 0, void 0, function* () { + return hsSdk.did.bjjDID.register({ didDocument, signData: [] }).catch(function (err) { + (0, chai_1.expect)(function () { + throw err; + }).to.throw(Error, 'HID-SSI-SDK:: Error: params.signInfos must be a non empty array'); + }); + })); + it('should not be able to register a did document as verificationMethodId is not passed inside signData', () => __awaiter(this, void 0, void 0, function* () { + return hsSdk.did.bjjDID.register({ didDocument, signData: [{ privateKeyMultibase: privateKeyMultibase }] }).catch(function (err) { + (0, chai_1.expect)(function () { + throw err; + }).to.throw(Error, 'HID-SSI-SDK:: Error: params.signData[0].verificationMethodId is required to register a did'); + }); + })); + it('should not be able to register a did document as verificationMethodId is not passed inside signData', () => __awaiter(this, void 0, void 0, function* () { + return hsSdk.did.bjjDID.register({ didDocument, signData: [{ privateKeyMultibase: privateKeyMultibase }] }).catch(function (err) { + (0, chai_1.expect)(function () { + throw err; + }).to.throw(Error, 'HID-SSI-SDK:: Error: params.signData[0].verificationMethodId is required to register a did'); + }); + })); + it('should not be able to register a did document as privateKeyMultibase is not passed inside signData', () => __awaiter(this, void 0, void 0, function* () { + return hsSdk.did.bjjDID + .register({ + didDocument, + signData: [ + { + verificationMethodId: verificationMethod[0].id, + }, + ], + }) + .catch(function (err) { + (0, chai_1.expect)(function () { + throw err; + }).to.throw(Error, 'HID-SSI-SDK:: Error: params.signData[0].privateKeyMultibase is required to register a did'); + }); + })); + it('should not be able to register a did document as type is not passed inside signData', () => __awaiter(this, void 0, void 0, function* () { + return hsSdk.did.bjjDID + .register({ + didDocument, + signData: [ + { + verificationMethodId: verificationMethod[0].id, + privateKeyMultibase: privateKeyMultibase, + }, + ], + }) + .catch(function (err) { + (0, chai_1.expect)(function () { + throw err; + }).to.throw(Error, 'HID-SSI-SDK:: Error: params.signData[0].type is required to register a did'); + }); + })); + it('should be able to register did generated using BabyJubJubKey', () => __awaiter(this, void 0, void 0, function* () { + const registerDid = yield hsSdk.did.bjjDID.register({ + didDocument: didDocument, + privateKeyMultibase, + verificationMethodId: verificationMethod[0].id + }); + didDocument = registerDid.didDocument; + (0, chai_1.expect)(didDocument).to.be.a('object'); + (0, chai_1.should)().exist(didDocument['@context']); + (0, chai_1.should)().exist(didDocument['id']); + (0, chai_1.should)().exist(didDocument['controller']); + (0, chai_1.should)().exist(didDocument['verificationMethod']); + (0, chai_1.expect)(didDocument['verificationMethod'] && + didDocument['authentication'] && + didDocument['assertionMethod'] && + didDocument['keyAgreement'] && + didDocument['capabilityInvocation'] && + didDocument['capabilityDelegation'] && + didDocument['service']).to.be.a('array'); + (0, chai_1.expect)(verificationMethod[0].type).to.be.equal('BabyJubJubKey2021'); + (0, chai_1.should)().exist(didDocument['authentication']); + (0, chai_1.should)().exist(didDocument['assertionMethod']); + (0, chai_1.should)().exist(didDocument['keyAgreement']); + (0, chai_1.should)().exist(didDocument['capabilityInvocation']); + (0, chai_1.should)().exist(didDocument['capabilityDelegation']); + (0, chai_1.should)().exist(didDocument['service']); + (0, chai_1.expect)(didDocument['authentication'].length).to.be.greaterThan(0); + (0, chai_1.expect)(didDocument['assertionMethod'].length).to.be.greaterThan(0); + (0, chai_1.expect)(didDocument['capabilityInvocation'].length).to.be.equal(0); + (0, chai_1.expect)(didDocument['capabilityDelegation'].length).to.be.equal(0); + (0, chai_1.expect)(didDocument['keyAgreement'].length).to.be.equal(0); + (0, chai_1.expect)(didDocument['service'].length).to.be.equal(0); + (0, chai_1.should)().exist(registerDid.transactionHash); + })); + it('should not be able to register didDocument as didDocument is already registered', function () { + return __awaiter(this, void 0, void 0, function* () { + return yield hsSdk.did.bjjDID.register({ + didDocument, + privateKeyMultibase, + verificationMethodId: verificationMethod[0].id, + }).catch(function (err) { + (0, chai_1.expect)(function () { + throw err; + }).to.throw(Error, `failed to execute message; message index: 0: ${didDocId}: didDoc already exists`); + }); + }); + }); + }); + describe('#resolve() method to resolve did', function () { + it('should not able to resolve did document and throw error as didDocId is not passed', function () { + return hsSdk.did.bjjDID.resolve({ params: { did: '' } }).catch(function (err) { + (0, chai_1.expect)(function () { + throw err; + }).to.throw(Error, 'HID-SSI-SDK:: Error: params.did is required to resolve a did'); + }); + }); + it('should be able to resolve did', () => __awaiter(this, void 0, void 0, function* () { + const resolvedDid = yield hsSdk.did.bjjDID.resolve({ + did: didDocId + }); + versionId = resolvedDid.didDocumentMetadata.versionId; + didDocument = resolvedDid.didDocument; + const didDocumentmetaData = resolvedDid.didDocumentMetadata; + (0, chai_1.expect)(didDocument).to.be.a('object'); + (0, chai_1.should)().exist(didDocument['@context']); + (0, chai_1.should)().exist(didDocument['id']); + (0, chai_1.should)().exist(didDocument['controller']); + (0, chai_1.should)().exist(didDocument['verificationMethod']); + (0, chai_1.expect)(didDocument['verificationMethod'] && + didDocument['authentication'] && + didDocument['assertionMethod'] && + didDocument['keyAgreement'] && + didDocument['capabilityInvocation'] && + didDocument['capabilityDelegation'] && + didDocument['service']).to.be.a('array'); + (0, chai_1.expect)(verificationMethod[0].type).to.be.equal('BabyJubJubKey2021'); + (0, chai_1.should)().exist(didDocument['authentication']); + (0, chai_1.should)().exist(didDocument['assertionMethod']); + (0, chai_1.should)().exist(didDocument['keyAgreement']); + (0, chai_1.should)().exist(didDocument['capabilityInvocation']); + (0, chai_1.should)().exist(didDocument['capabilityDelegation']); + (0, chai_1.should)().exist(didDocument['service']); + (0, chai_1.expect)(didDocument['authentication'].length).to.be.greaterThan(0); + (0, chai_1.expect)(didDocument['assertionMethod'].length).to.be.greaterThan(0); + (0, chai_1.expect)(didDocument['capabilityInvocation'].length).to.be.equal(0); + (0, chai_1.expect)(didDocument['capabilityDelegation'].length).to.be.equal(0); + (0, chai_1.expect)(didDocument['keyAgreement'].length).to.be.equal(0); + (0, chai_1.expect)(didDocument['service'].length).to.be.equal(0); + (0, chai_1.expect)(didDocumentmetaData).to.be.a('object'); + (0, chai_1.should)().exist(didDocumentmetaData.created); + (0, chai_1.should)().exist(didDocumentmetaData.updated); + (0, chai_1.should)().exist(didDocumentmetaData.deactivated); + (0, chai_1.should)().exist(didDocumentmetaData.versionId); + (0, chai_1.expect)(didDocumentmetaData.created).to.be.equal(didDocumentmetaData.updated); + })); + }); + describe('#update() method to update a did', function () { + it('should not be able to update did document as privateKeyMultibase is null or empty', function () { + return hsSdk.did.bjjDID + .update({ didDocument, privateKeyMultibase: '', verificationMethodId: verificationMethod[0].id, versionId: '1.0' }) + .catch(function (err) { + (0, chai_1.expect)(function () { + throw err; + }).to.throw(Error, 'HID-SSI-SDK:: Error: params.privateKeyMultibase is required to update a did'); + }); + }); + it('should not be able to update did document as verificationMethodId is null or empty', function () { + return hsSdk.did.bjjDID + .update({ didDocument, privateKeyMultibase, verificationMethodId: '', versionId: '1.0' }) + .catch(function (err) { + (0, chai_1.expect)(function () { + throw err; + }).to.throw(Error, 'HID-SSI-SDK:: Error: params.verificationMethodId is required to update a did'); + }); + }); + it('should not be able to update did document as versionId is null or empty', function () { + return hsSdk.did.bjjDID + .update({ didDocument, privateKeyMultibase, verificationMethodId: verificationMethod[0].id, versionId: '' }) + .catch(function (err) { + (0, chai_1.expect)(function () { + throw err; + }).to.throw(Error, 'HID-SSI-SDK:: Error: params.versionId is required to update a did'); + }); + }); + it('should not be able to update did document as versionId passed is incorrect', function () { + const updateBody = { didDocument, privateKeyMultibase, verificationMethodId: verificationMethod[0].id, versionId: '1.0.1' }; + const didDoc = JSON.parse(JSON.stringify(didDocument)); + updateBody['didDocument'] = didDoc; + updateBody['didDocument']['authentication'] = []; + return hsSdk.did.bjjDID.update(updateBody).catch(function (err) { + (0, chai_1.expect)(function () { + throw err; + }).to.throw(Error, `failed to execute message; message index: 0: Expected ${didDocId} with version ${versionId}. Got version ${updateBody.versionId}: unexpected DID version`); + }); + }); + it('should not be able to update did document as there is no change in didDocument', function () { + const updateBody = { didDocument, privateKeyMultibase, verificationMethodId: verificationMethod[0].id, versionId: '1.0.1' }; + const didDoc = JSON.parse(JSON.stringify(didDocument)); + updateBody['didDocument'] = didDoc; + return hsSdk.did.bjjDID.update(updateBody).catch(function (err) { + (0, chai_1.expect)(function () { + throw err; + }).to.throw(Error, "failed to execute message; message index: 0: incoming DID Document does not have any changes: didDoc is invalid"); + }); + }); + it('should be able to update did generated using BabyJubJubKey', () => __awaiter(this, void 0, void 0, function* () { + const newDidDoc = JSON.parse(JSON.stringify(didDocument)); + newDidDoc['authentication'] = []; + const updatedDid = yield hsSdk.did.bjjDID.update({ + didDocument: newDidDoc, + privateKeyMultibase, + verificationMethodId: verificationMethod[0].id, + versionId + }); + (0, chai_1.should)().exist(updatedDid.transactionHash); + })); + }); + describe('#resolve() method to resolve did', function () { + it('should be able to resolve did after updation', () => __awaiter(this, void 0, void 0, function* () { + const resolvedDid = yield hsSdk.did.bjjDID.resolve({ + did: didDocId + }); + versionId = resolvedDid.didDocumentMetadata.versionId; + didDocument = resolvedDid.didDocument; + const didDocumentmetaData = resolvedDid.didDocumentMetadata; + (0, chai_1.expect)(didDocument).to.be.a('object'); + (0, chai_1.should)().exist(didDocument['@context']); + (0, chai_1.should)().exist(didDocument['id']); + (0, chai_1.should)().exist(didDocument['controller']); + (0, chai_1.should)().exist(didDocument['verificationMethod']); + (0, chai_1.expect)(didDocument['verificationMethod'] && + didDocument['authentication'] && + didDocument['assertionMethod'] && + didDocument['keyAgreement'] && + didDocument['capabilityInvocation'] && + didDocument['capabilityDelegation'] && + didDocument['service']).to.be.a('array'); + (0, chai_1.expect)(verificationMethod[0].type).to.be.equal('BabyJubJubKey2021'); + (0, chai_1.should)().exist(didDocument['authentication']); + (0, chai_1.should)().exist(didDocument['assertionMethod']); + (0, chai_1.should)().exist(didDocument['keyAgreement']); + (0, chai_1.should)().exist(didDocument['capabilityInvocation']); + (0, chai_1.should)().exist(didDocument['capabilityDelegation']); + (0, chai_1.should)().exist(didDocument['service']); + // expect(didDocument['authentication'].length).to.be.greaterThan(0) + (0, chai_1.expect)(didDocument['assertionMethod'].length).to.be.greaterThan(0); + (0, chai_1.expect)(didDocument['capabilityInvocation'].length).to.be.equal(0); + (0, chai_1.expect)(didDocument['capabilityDelegation'].length).to.be.equal(0); + (0, chai_1.expect)(didDocument['keyAgreement'].length).to.be.equal(0); + (0, chai_1.expect)(didDocument['service'].length).to.be.equal(0); + (0, chai_1.expect)(didDocumentmetaData).to.be.a('object'); + (0, chai_1.should)().exist(didDocumentmetaData.created); + (0, chai_1.should)().exist(didDocumentmetaData.updated); + (0, chai_1.should)().exist(didDocumentmetaData.deactivated); + (0, chai_1.should)().exist(didDocumentmetaData.versionId); + const date1 = new Date(didDocumentmetaData.updated); + const date2 = new Date(didDocumentmetaData.created); + (0, chai_1.expect)(date1).to.be.greaterThan(date2); + })); + }); + describe('#deactivate() method to deactivate a did document', function () { + it('should not be able to deactivate did document as privateKeyMultibase is null or empty', function () { + return hsSdk.did.bjjDID + .deactivate({ didDocument, privateKeyMultibase: '', verificationMethodId: verificationMethod[0].id, versionId: '1.0' }) + .catch(function (err) { + (0, chai_1.expect)(function () { + throw err; + }).to.throw(Error, 'HID-SSI-SDK:: Error: params.privateKeyMultibase is required to deactivate a did'); + }); + }); + it('should not be able to deactivate did document as verificationMethodId is null or empty', function () { + return hsSdk.did.bjjDID + .deactivate({ didDocument, privateKeyMultibase, verificationMethodId: '', versionId: '1.0' }) + .catch(function (err) { + (0, chai_1.expect)(function () { + throw err; + }).to.throw(Error, 'HID-SSI-SDK:: Error: params.verificationMethodId is required to deactivate a did'); + }); + }); + it('should not be able to deactivate did document as versionId is null or empty', function () { + return hsSdk.did.bjjDID + .deactivate({ didDocument, privateKeyMultibase, verificationMethodId: verificationMethod[0].id, versionId: '' }) + .catch(function (err) { + (0, chai_1.expect)(function () { + throw err; + }).to.throw(Error, 'HID-SSI-SDK:: Error: params.versionId is required to deactivate a did'); + }); + }); + it('should not be able to deactivate did document as versionId passed is incorrect', function () { + const didDoc = JSON.parse(JSON.stringify(didDocument)); + const deactivateBody = { didDocument: didDoc, privateKeyMultibase, verificationMethodId: verificationMethod[0].id, versionId: '1.0.1' }; + return hsSdk.did.bjjDID.deactivate(deactivateBody).catch(function (err) { + (0, chai_1.expect)(function () { + throw err; + }).to.throw(Error, `failed to execute message; message index: 0: Expected ${didDocId} with version ${versionId}. Got version 1.0.1: unexpected DID version`); + }); + }); + it('should be able to deactivate did generated using BabyJubJubKey', () => __awaiter(this, void 0, void 0, function* () { + const updatedDid = yield hsSdk.did.bjjDID.deactivate({ + didDocument: didDocument, + privateKeyMultibase, + verificationMethodId: verificationMethod[0].id, + versionId + }); + (0, chai_1.should)().exist(updatedDid.transactionHash); + })); + it('should not be able to deactivate did document as its already deactivated', function () { + return __awaiter(this, void 0, void 0, function* () { + const didDocTodeactivate = JSON.parse(JSON.stringify(didDocument)); + return hsSdk.did.bjjDID.deactivate({ + didDocument: didDocTodeactivate, + privateKeyMultibase, + verificationMethodId: verificationMethod[0].id, + versionId, + }).catch(function (err) { + (0, chai_1.expect)(function () { + throw err; + }).to.throw(Error, `failed to execute message; message index: 0: DID Document ${didDocId} is already deactivated: didDoc is deactivated`); + }); + }); + }); + it('should be able to resolve did after deactivation and deactivated should be true', () => __awaiter(this, void 0, void 0, function* () { + const resolvedDid = yield hsSdk.did.bjjDID.resolve({ + did: didDocId + }); + versionId = resolvedDid.didDocumentMetadata.versionId; + didDocument = resolvedDid.didDocument; + const didDocumentmetaData = resolvedDid.didDocumentMetadata; + (0, chai_1.expect)(didDocument).to.be.a('object'); + (0, chai_1.expect)(didDocumentmetaData).to.be.a('object'); + (0, chai_1.should)().exist(didDocumentmetaData.created); + (0, chai_1.should)().exist(didDocumentmetaData.updated); + (0, chai_1.should)().exist(didDocumentmetaData.deactivated); + (0, chai_1.expect)(didDocumentmetaData.deactivated).to.be.equal(true); + (0, chai_1.should)().exist(didDocumentmetaData.versionId); + const date1 = new Date(didDocumentmetaData.updated); + const date2 = new Date(didDocumentmetaData.created); + (0, chai_1.expect)(date1).to.be.greaterThan(date2); + })); + }); +}); diff --git a/build/src/tests/bjj/presentation/bjj_vp.spec.d.ts b/build/src/tests/bjj/presentation/bjj_vp.spec.d.ts new file mode 100644 index 0000000..8b6ff37 --- /dev/null +++ b/build/src/tests/bjj/presentation/bjj_vp.spec.d.ts @@ -0,0 +1,2 @@ +export {}; +//# sourceMappingURL=bjj_vp.spec.d.ts.map \ No newline at end of file diff --git a/build/src/tests/bjj/presentation/bjj_vp.spec.d.ts.map b/build/src/tests/bjj/presentation/bjj_vp.spec.d.ts.map new file mode 100644 index 0000000..18c76bf --- /dev/null +++ b/build/src/tests/bjj/presentation/bjj_vp.spec.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"bjj_vp.spec.d.ts","sourceRoot":"","sources":["../../../../../src/tests/bjj/presentation/bjj_vp.spec.ts"],"names":[],"mappings":""} \ No newline at end of file diff --git a/build/src/tests/bjj/presentation/bjj_vp.spec.js b/build/src/tests/bjj/presentation/bjj_vp.spec.js new file mode 100644 index 0000000..e31dac1 --- /dev/null +++ b/build/src/tests/bjj/presentation/bjj_vp.spec.js @@ -0,0 +1,723 @@ +"use strict"; +var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { + function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } + return new (P || (P = Promise))(function (resolve, reject) { + function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } + function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } + function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } + step((generator = generator.apply(thisArg, _arguments || [])).next()); + }); +}; +Object.defineProperty(exports, "__esModule", { value: true }); +const index_1 = require("../../../index"); +const chai_1 = require("chai"); +const config_1 = require("../../config"); +let issuerPrivateKeyMultibase; +let issuerPublicKeyMultibase; +let holderPrivateKeyMultibase; +let holderPublicKeyMultibase; +let offlineSigner; +let hsSdk; +let credentialStatusId; +let credenStatus; +let verificationMethod; +let schemaObject; +let signedSchema; +let schemaId; +let subjectDid; +let signedVC1; +let issuerDid; +let issuerDidDoc; +let subjectDidDoc; +let credentialDetail; +let credentialId; +let signedVp1; +let signedVC; +let unsignedSdVerifiablePresentation; +let unsignedVerifiablePresentation; +let signedVp; +let signedSdVp; +let selectiveDisclosure; +const issueCredentialBody = { + credential: credentialDetail, + issuerDid, + verificationMethodId: '', + privateKeyMultibase: issuerPrivateKeyMultibase, + registerCredential: true, +}; +const schemaBody = { + name: 'TestSchema', + description: 'This is a test schema generation', + author: '', + fields: [ + { name: 'name', type: 'string', isRequired: false }, + { name: 'address', type: 'string', isRequired: true }, + ], + additionalProperties: false, +}; +const credentialBody = { + schemaId: '', + subjectDid: '', + type: [], + issuerDid: '', + fields: { name: 'Varsha', address: 'Random address' }, + expirationDate: '', +}; +beforeEach(function () { + return __awaiter(this, void 0, void 0, function* () { + offlineSigner = yield (0, config_1.createWallet)(config_1.mnemonic); + const params = { + offlineSigner, + nodeRestEndpoint: config_1.hidNodeEp.rest, + nodeRpcEndpoint: config_1.hidNodeEp.rpc, + namespace: config_1.hidNodeEp.namespace, + }; + hsSdk = new index_1.HypersignSSISdk(params); + yield hsSdk.init(); + }); +}); +describe('#generateKeys() method to generate publicKyeMultibase and privateKeyMultiBase', function () { + it('should return publickeyMultibase and privateKeyMultibase', function () { + return __awaiter(this, void 0, void 0, function* () { + const kp = yield hsSdk.did.bjjDID.generateKeys(); + issuerPrivateKeyMultibase = kp.privateKeyMultibase; + issuerPublicKeyMultibase = kp.publicKeyMultibase; + (0, chai_1.expect)(kp).to.be.a('object'); + (0, chai_1.should)().exist(kp.privateKeyMultibase); + (0, chai_1.should)().exist(kp.publicKeyMultibase); + (0, chai_1.should)().not.exist(kp.id); + }); + }); +}); +/** + * DID creation and registration + */ +describe('DID Operation', () => { + describe('#generate() method to generate new did', function () { + it('should be able to generate a issuer did using babyJubJub', () => __awaiter(this, void 0, void 0, function* () { + issuerDidDoc = yield hsSdk.did.bjjDID.generate({ + publicKeyMultibase: issuerPublicKeyMultibase, + }); + issuerDid = issuerDidDoc.id; + verificationMethod = issuerDidDoc.verificationMethod; + (0, chai_1.expect)(issuerDidDoc).to.be.a('object'); + (0, chai_1.should)().exist(issuerDidDoc['@context']); + (0, chai_1.should)().exist(issuerDidDoc['id']); + (0, chai_1.should)().exist(issuerDidDoc['controller']); + (0, chai_1.should)().exist(issuerDidDoc['verificationMethod']); + (0, chai_1.expect)(issuerDidDoc['verificationMethod'] && + issuerDidDoc['authentication'] && + issuerDidDoc['assertionMethod'] && + issuerDidDoc['keyAgreement'] && + issuerDidDoc['capabilityInvocation'] && + issuerDidDoc['capabilityDelegation'] && + issuerDidDoc['service']).to.be.a('array'); + (0, chai_1.expect)(verificationMethod[0].type).to.be.equal('BabyJubJubKey2021'); + (0, chai_1.should)().exist(issuerDidDoc['authentication']); + (0, chai_1.should)().exist(issuerDidDoc['assertionMethod']); + (0, chai_1.should)().exist(issuerDidDoc['keyAgreement']); + (0, chai_1.should)().exist(issuerDidDoc['capabilityInvocation']); + (0, chai_1.should)().exist(issuerDidDoc['capabilityDelegation']); + (0, chai_1.should)().exist(issuerDidDoc['service']); + (0, chai_1.expect)(issuerDidDoc['authentication'].length).to.be.greaterThan(0); + (0, chai_1.expect)(issuerDidDoc['assertionMethod'].length).to.be.greaterThan(0); + (0, chai_1.expect)(issuerDidDoc['capabilityInvocation'].length).to.be.equal(0); + (0, chai_1.expect)(issuerDidDoc['capabilityDelegation'].length).to.be.equal(0); + (0, chai_1.expect)(issuerDidDoc['keyAgreement'].length).to.be.equal(0); + (0, chai_1.expect)(issuerDidDoc['service'].length).to.be.equal(0); + })); + it('should be able to genrate a did for holder', () => __awaiter(this, void 0, void 0, function* () { + const kp = yield hsSdk.did.bjjDID.generateKeys(); + holderPrivateKeyMultibase = kp.privateKeyMultibase; + holderPublicKeyMultibase = kp.publicKeyMultibase; + subjectDidDoc = yield hsSdk.did.bjjDID.generate({ + publicKeyMultibase: holderPublicKeyMultibase, + }); + subjectDid = subjectDidDoc.id; + })); + }); + describe('#register() method to register did', function () { + it('should be able to register did generated using BabyJubJubKey', () => __awaiter(this, void 0, void 0, function* () { + const registerDid = yield hsSdk.did.bjjDID.register({ + didDocument: issuerDidDoc, + privateKeyMultibase: issuerPrivateKeyMultibase, + verificationMethodId: verificationMethod[0].id, + }); + issuerDidDoc = registerDid.didDocument; + (0, chai_1.expect)(issuerDidDoc).to.be.a('object'); + (0, chai_1.should)().exist(issuerDidDoc['@context']); + (0, chai_1.should)().exist(issuerDidDoc['id']); + (0, chai_1.should)().exist(issuerDidDoc['controller']); + (0, chai_1.should)().exist(issuerDidDoc['verificationMethod']); + (0, chai_1.expect)(issuerDidDoc['verificationMethod'] && + issuerDidDoc['authentication'] && + issuerDidDoc['assertionMethod'] && + issuerDidDoc['keyAgreement'] && + issuerDidDoc['capabilityInvocation'] && + issuerDidDoc['capabilityDelegation'] && + issuerDidDoc['service']).to.be.a('array'); + (0, chai_1.expect)(verificationMethod[0].type).to.be.equal('BabyJubJubKey2021'); + (0, chai_1.should)().exist(issuerDidDoc['authentication']); + (0, chai_1.should)().exist(issuerDidDoc['assertionMethod']); + (0, chai_1.should)().exist(issuerDidDoc['keyAgreement']); + (0, chai_1.should)().exist(issuerDidDoc['capabilityInvocation']); + (0, chai_1.should)().exist(issuerDidDoc['capabilityDelegation']); + (0, chai_1.should)().exist(issuerDidDoc['service']); + (0, chai_1.expect)(issuerDidDoc['authentication'].length).to.be.greaterThan(0); + (0, chai_1.expect)(issuerDidDoc['assertionMethod'].length).to.be.greaterThan(0); + (0, chai_1.expect)(issuerDidDoc['capabilityInvocation'].length).to.be.equal(0); + (0, chai_1.expect)(issuerDidDoc['capabilityDelegation'].length).to.be.equal(0); + (0, chai_1.expect)(issuerDidDoc['keyAgreement'].length).to.be.equal(0); + (0, chai_1.expect)(issuerDidDoc['service'].length).to.be.equal(0); + (0, chai_1.should)().exist(registerDid.transactionHash); + })); + it('should be able to register did for holder', () => __awaiter(this, void 0, void 0, function* () { + const registerDid = yield hsSdk.did.bjjDID.register({ + didDocument: subjectDidDoc, + privateKeyMultibase: holderPrivateKeyMultibase, + verificationMethodId: subjectDidDoc.verificationMethod[0].id, + }); + subjectDidDoc = registerDid.didDocument; + })); + }); +}); +// /** +// * Schema Creation and Registration +// */ +describe('Schema Operations', () => { + describe('#generate() method to create schema', function () { + it('should be able to generate new schema', function () { + return __awaiter(this, void 0, void 0, function* () { + const tempSchemaBody = Object.assign({}, schemaBody); + tempSchemaBody.author = issuerDid; + schemaObject = yield hsSdk.schema.hypersignBjjschema.generate(tempSchemaBody); + schemaId = schemaObject['id']; + (0, chai_1.expect)(schemaObject).to.be.a('object'); + (0, chai_1.should)().exist(schemaObject['type']); + (0, chai_1.should)().exist(schemaObject['modelVersion']); + (0, chai_1.should)().exist(schemaObject['id']); + (0, chai_1.should)().exist(schemaObject['name']); + (0, chai_1.should)().exist(schemaObject['author']); + (0, chai_1.should)().exist(schemaObject['authored']); + (0, chai_1.should)().exist(schemaObject['schema']); + (0, chai_1.expect)(schemaObject.schema).to.be.a('object'); + (0, chai_1.expect)(schemaObject['name']).to.be.equal(tempSchemaBody.name); + (0, chai_1.expect)(schemaObject['author']).to.be.equal(tempSchemaBody.author); + (0, chai_1.expect)(schemaObject['schema'].required).to.be.a('array'); + }); + }); + }); + describe('#sign() method to sign a schema', function () { + it('should be able to sign newly created schema', () => __awaiter(this, void 0, void 0, function* () { + signedSchema = yield yield hsSdk.schema.hypersignBjjschema.sign({ + privateKeyMultibase: issuerPrivateKeyMultibase, + schema: schemaObject, + verificationMethodId: issuerDidDoc['assertionMethod'][0], + }); + (0, chai_1.expect)(signedSchema).to.be.a('object'); + (0, chai_1.should)().exist(signedSchema.type); + (0, chai_1.should)().exist(signedSchema.modelVersion); + (0, chai_1.should)().exist(signedSchema['id']); + (0, chai_1.should)().exist(signedSchema['name']); + (0, chai_1.should)().exist(signedSchema['author']); + (0, chai_1.should)().exist(signedSchema['authored']); + (0, chai_1.should)().exist(signedSchema['schema']); + (0, chai_1.should)().exist(signedSchema.schema.schema); + (0, chai_1.should)().exist(signedSchema.schema.description); + (0, chai_1.should)().exist(signedSchema.schema.type); + (0, chai_1.should)().exist(signedSchema.schema.properties); + (0, chai_1.should)().exist(signedSchema.schema.required); + (0, chai_1.should)().exist(signedSchema.proof); + (0, chai_1.should)().exist(signedSchema.proof.type); + (0, chai_1.expect)(signedSchema.proof.type).to.be.equal('BJJSignature2021'); + (0, chai_1.should)().exist(signedSchema.proof.created); + (0, chai_1.should)().exist(signedSchema.proof.verificationMethod); + (0, chai_1.should)().exist(signedSchema.proof.proofPurpose); + (0, chai_1.expect)(signedSchema.proof.proofPurpose).to.be.equal('assertionMethod'); + (0, chai_1.should)().exist(signedSchema.proof.proofValue); + })); + }); + describe('#register() method to register a schema', function () { + it('should be able to register newly created schema', () => __awaiter(this, void 0, void 0, function* () { + const registerdSchema = yield hsSdk.schema.hypersignBjjschema.register({ schema: signedSchema }); + (0, chai_1.should)().exist(registerdSchema.transactionHash); + })); + }); + describe('#resolve() method to resolve a schema', function () { + it('Should be able to resolve schema from blockchain', () => __awaiter(this, void 0, void 0, function* () { + const resolvedSchema = yield hsSdk.schema.hypersignBjjschema.resolve({ schemaId }); + (0, chai_1.should)().exist(resolvedSchema.context); + (0, chai_1.should)().exist(resolvedSchema.type); + (0, chai_1.should)().exist(resolvedSchema.modelVersion); + (0, chai_1.should)().exist(resolvedSchema.id); + (0, chai_1.should)().exist(resolvedSchema.name); + (0, chai_1.should)().exist(resolvedSchema.author); + (0, chai_1.should)().exist(resolvedSchema.authored); + (0, chai_1.should)().exist(resolvedSchema.schema); + (0, chai_1.should)().exist(resolvedSchema.schema.schema); + (0, chai_1.should)().exist(resolvedSchema.schema.description); + (0, chai_1.should)().exist(resolvedSchema.schema.type); + (0, chai_1.should)().exist(resolvedSchema.schema.properties); + (0, chai_1.should)().exist(resolvedSchema.schema.required); + (0, chai_1.should)().exist(resolvedSchema.schema.additionalProperties); + (0, chai_1.should)().exist(resolvedSchema.proof); + (0, chai_1.should)().exist(resolvedSchema.proof.type); + (0, chai_1.should)().exist(resolvedSchema.proof.created); + (0, chai_1.should)().exist(resolvedSchema.proof.verificationMethod); + (0, chai_1.should)().exist(resolvedSchema.proof.proofPurpose); + (0, chai_1.should)().exist(resolvedSchema.proof.proofValue); + (0, chai_1.should)().exist(resolvedSchema.proof.clientSpecType); + (0, chai_1.expect)(resolvedSchema.proof.clientSpecType).to.be.equal('CLIENT_SPEC_TYPE_NONE'); + })); + }); +}); +// /** +// * Test cases related to credential +// */ +describe('Credential Operation', () => { + describe('#generate() method to generate a credential', function () { + it('should be able to generate a credential', () => __awaiter(this, void 0, void 0, function* () { + const expirationDate = new Date('12/11/2027'); + const tempCredentialBody = Object.assign({}, credentialBody); + tempCredentialBody.schemaId = schemaId; + tempCredentialBody.subjectDid = subjectDid; + tempCredentialBody['expirationDate'] = expirationDate.toString(); + tempCredentialBody.issuerDid = issuerDid; + tempCredentialBody.fields = { name: 'varsha', address: 'random address' }; + credentialDetail = yield hsSdk.vc.bjjVC.generate(tempCredentialBody); + (0, chai_1.expect)(credentialDetail).to.be.a('object'); + (0, chai_1.should)().exist(credentialDetail['@context']); + (0, chai_1.should)().exist(credentialDetail['id']); + credentialId = credentialDetail.id; + (0, chai_1.should)().exist(credentialDetail['type']); + (0, chai_1.should)().exist(credentialDetail['issuanceDate']); + (0, chai_1.should)().exist(credentialDetail['issuer']); + (0, chai_1.should)().exist(credentialDetail['credentialSubject']); + (0, chai_1.should)().exist(credentialDetail['credentialStatus']); + (0, chai_1.expect)(credentialDetail['credentialStatus'].type).to.be.equal('HypersignCredentialStatus2023'); + })); + }); + describe('#issueCredential() method for issuing credential', function () { + it('should be able to issue credential with credential status registered on chain', function () { + return __awaiter(this, void 0, void 0, function* () { + const tempIssueCredentialBody = Object.assign({}, issueCredentialBody); + tempIssueCredentialBody.credential = credentialDetail; + tempIssueCredentialBody.issuerDid = issuerDid; + tempIssueCredentialBody.verificationMethodId = verificationMethod[0].id; + tempIssueCredentialBody.privateKeyMultibase = issuerPrivateKeyMultibase; + const issuedCredResult = yield hsSdk.vc.bjjVC.issue(tempIssueCredentialBody); + const { signedCredential, credentialStatus, credentialStatusProof, credentialStatusRegistrationResult } = issuedCredResult; + signedVC1 = {}; + Object.assign(signedVC1, signedCredential); + signedVC = signedCredential; + credenStatus = credentialStatus; + credentialId = signedVC.id; + credentialStatusId = signedCredential['credentialStatus'].id; + (0, chai_1.expect)(signedCredential).to.be.a('object'); + (0, chai_1.should)().exist(signedCredential['@context']); + (0, chai_1.should)().exist(signedCredential['id']); + (0, chai_1.should)().exist(signedCredential['type']); + (0, chai_1.should)().exist(signedCredential['issuanceDate']); + (0, chai_1.should)().exist(signedCredential['issuer']); + (0, chai_1.should)().exist(signedCredential['credentialSubject']); + (0, chai_1.should)().exist(signedCredential['credentialSchema']); + (0, chai_1.should)().exist(signedCredential['credentialStatus']); + (0, chai_1.should)().exist(signedCredential['proof']); + (0, chai_1.expect)(signedCredential['id']).to.be.equal(tempIssueCredentialBody.credential.id); + (0, chai_1.expect)(credentialStatus).to.be.a('object'); + (0, chai_1.should)().exist(credentialStatus['@context']); + (0, chai_1.should)().exist(credentialStatus['id']); + (0, chai_1.should)().exist(credentialStatus['issuer']); + (0, chai_1.should)().exist(credentialStatus['issuanceDate']); + (0, chai_1.should)().exist(credentialStatus['credentialMerkleRootHash']); + (0, chai_1.should)().exist(credentialStatus['proof']); + (0, chai_1.should)().exist(credentialStatus['proof'].type); + (0, chai_1.expect)(credentialStatus['proof'].type).to.be.equal('BJJSignature2021'); + (0, chai_1.expect)(credentialStatusProof).to.be.a('object'); + (0, chai_1.should)().exist(credentialStatusProof['type']); + (0, chai_1.expect)(credentialStatusProof['type']).to.be.equal('BJJSignature2021'); + (0, chai_1.should)().exist(credentialStatusProof['created']); + (0, chai_1.should)().exist(credentialStatusProof['verificationMethod']); + (0, chai_1.should)().exist(credentialStatusProof['proofPurpose']); + (0, chai_1.should)().exist(credentialStatusProof['proofValue']); + (0, chai_1.expect)(credentialStatusRegistrationResult).to.be.a('object'); + (0, chai_1.should)().exist(credentialStatusRegistrationResult['height']); + (0, chai_1.should)().exist(credentialStatusRegistrationResult['transactionHash']); + (0, chai_1.should)().exist(credentialStatusRegistrationResult['gasUsed']); + (0, chai_1.should)().exist(credentialStatusRegistrationResult['gasWanted']); + }); + }); + }); + describe('#generateSeletiveDisclosure() method for genertaing sd', function () { + const presentationBody = { + verifiableCredential: signedVC1, + frame: {}, + verificationMethodId: '', + issuerDid, + }; + it('should be able to generate a sd document', () => __awaiter(this, void 0, void 0, function* () { + const revelDocument = { + type: ['VerifiableCredential', 'TestSchema'], + expirationDate: {}, + issuanceDate: {}, + issuer: {}, + credentialSubject: { + '@explicit': true, + id: {}, + }, + }; + const tempPresentationBody = Object.assign({}, presentationBody); + tempPresentationBody.verifiableCredential = signedVC1; + tempPresentationBody.frame = revelDocument; + tempPresentationBody.issuerDid = issuerDid; + tempPresentationBody.verificationMethodId = verificationMethod[0].id; + selectiveDisclosure = yield hsSdk.vc.bjjVC.generateSeletiveDisclosure(tempPresentationBody); + (0, chai_1.should)().exist(selectiveDisclosure['@context']); + (0, chai_1.should)().exist(selectiveDisclosure['id']); + (0, chai_1.expect)(selectiveDisclosure['id']).to.be.equal(credentialId); + (0, chai_1.should)().exist(selectiveDisclosure['type']); + (0, chai_1.should)().exist(selectiveDisclosure['credentialSchema']); + (0, chai_1.should)().exist(selectiveDisclosure['credentialStatus']); + (0, chai_1.should)().exist(selectiveDisclosure['credentialSubject']); + (0, chai_1.expect)(selectiveDisclosure['credentialSubject']).to.be.equal(subjectDid); + (0, chai_1.should)().exist(selectiveDisclosure['expirationDate']); + (0, chai_1.should)().exist(selectiveDisclosure['issuanceDate']); + (0, chai_1.should)().exist(selectiveDisclosure['issuer']); + (0, chai_1.expect)(selectiveDisclosure['issuer']).to.be.equal(issuerDid); + (0, chai_1.should)().exist(selectiveDisclosure['proof']); + (0, chai_1.should)().exist(selectiveDisclosure['proof'].type); + (0, chai_1.expect)(selectiveDisclosure['proof'].type).to.be.equal('BabyJubJubSignatureProof2021'); + (0, chai_1.should)().exist(selectiveDisclosure['proof'].created); + (0, chai_1.should)().exist(selectiveDisclosure['proof'].verificationMethod); + (0, chai_1.should)().exist(selectiveDisclosure['proof'].proofPurpose); + (0, chai_1.should)().exist(selectiveDisclosure['proof'].credentialRoot); + (0, chai_1.should)().exist(selectiveDisclosure['proof'].proofValue); + })); + }); +}); +// /** +// * Test cases related to verifiable presentation +// */ +describe('Verifiable Presentation Operataions', () => { + describe('#generate() method to generate new presentation document', () => { + it('should be able to generate a new presentation for sd document', () => __awaiter(void 0, void 0, void 0, function* () { + const presentationBody = { + verifiableCredentials: [selectiveDisclosure], + holderDid: subjectDid, + }; + const tempPresentationBody = Object.assign({}, presentationBody); + tempPresentationBody.holderDid = subjectDid; + unsignedSdVerifiablePresentation = yield hsSdk.vp.bjjVp.generate(tempPresentationBody); + (0, chai_1.should)().exist(unsignedSdVerifiablePresentation['@context']); + (0, chai_1.should)().exist(unsignedSdVerifiablePresentation['type']); + (0, chai_1.expect)(unsignedSdVerifiablePresentation.type[0]).to.be.equal('VerifiablePresentation'); + (0, chai_1.should)().exist(unsignedSdVerifiablePresentation['verifiableCredential']); + (0, chai_1.expect)(unsignedSdVerifiablePresentation.verifiableCredential).to.be.a('array'); + (0, chai_1.should)().exist(unsignedSdVerifiablePresentation['id']); + (0, chai_1.should)().exist(unsignedSdVerifiablePresentation['holder']); + })); + it('should be able to generate a presentation for credential document', () => __awaiter(void 0, void 0, void 0, function* () { + const presentationBody = { + verifiableCredentials: [signedVC1], + holderDid: subjectDid, + }; + const tempPresentationBody = Object.assign({}, presentationBody); + tempPresentationBody.holderDid = subjectDid; + unsignedVerifiablePresentation = yield hsSdk.vp.bjjVp.generate(tempPresentationBody); + (0, chai_1.should)().exist(unsignedVerifiablePresentation['@context']); + (0, chai_1.should)().exist(unsignedVerifiablePresentation['type']); + (0, chai_1.expect)(unsignedVerifiablePresentation.type[0]).to.be.equal('VerifiablePresentation'); + (0, chai_1.should)().exist(unsignedVerifiablePresentation['verifiableCredential']); + (0, chai_1.expect)(unsignedVerifiablePresentation.verifiableCredential).to.be.a('array'); + (0, chai_1.should)().exist(unsignedVerifiablePresentation['id']); + (0, chai_1.should)().exist(unsignedVerifiablePresentation['holder']); + })); + }); + describe('#sign() method to sign presentation of credential', () => { + const signPresentaionBody = { + presentation: unsignedVerifiablePresentation, + holderDid: subjectDid, + verificationMethodId: '', + privateKeyMultibase: holderPrivateKeyMultibase, + challenge: 'abc', + domain: 'www.xyz.com', + }; + it('should not be able to sign a presentation as both holderDidDoc as well did is passed', () => __awaiter(void 0, void 0, void 0, function* () { + const tempSignPresentaionBody = Object.assign({}, signPresentaionBody); + tempSignPresentaionBody['holderDid'] = subjectDid; + tempSignPresentaionBody['holderDidDocSigned'] = subjectDidDoc; + return hsSdk.vp.bjjVp.sign(tempSignPresentaionBody).catch(function (err) { + (0, chai_1.expect)(function () { + throw err; + }).to.throw(Error, 'HID-SSI-SDK:: Either holderDid or holderDidDocSigned should be provided'); + }); + })); + it('should not be able to sign a presentation as privateKeyMultibase is not passed', () => __awaiter(void 0, void 0, void 0, function* () { + const tempSignPresentaionBody = Object.assign({}, signPresentaionBody); + tempSignPresentaionBody['holderDid'] = subjectDid; + tempSignPresentaionBody['privateKeyMultibase'] = ''; + return hsSdk.vp.bjjVp.sign(tempSignPresentaionBody).catch(function (err) { + (0, chai_1.expect)(function () { + throw err; + }).to.throw(Error, 'HID-SSI-SDK:: params.privateKeyMultibase is required for signing a presentation'); + }); + })); + it('should not be able to sign a presentation as presentation is not passed', () => __awaiter(void 0, void 0, void 0, function* () { + const tempSignPresentaionBody = Object.assign({}, signPresentaionBody); + tempSignPresentaionBody['holderDid'] = subjectDid; + tempSignPresentaionBody['privateKeyMultibase'] = holderPrivateKeyMultibase; + tempSignPresentaionBody['presentation'] = null; + return hsSdk.vp.bjjVp.sign(tempSignPresentaionBody).catch(function (err) { + (0, chai_1.expect)(function () { + throw err; + }).to.throw(Error, 'HID-SSI-SDK:: params.presentation is required for signing a presentation'); + }); + })); + it('should not be able to sign a presentation as verificationMethodId is not passed', () => __awaiter(void 0, void 0, void 0, function* () { + const tempSignPresentaionBody = Object.assign({}, signPresentaionBody); + tempSignPresentaionBody['holderDid'] = subjectDid; + tempSignPresentaionBody['privateKeyMultibase'] = holderPrivateKeyMultibase; + tempSignPresentaionBody['presentation'] = unsignedVerifiablePresentation; + tempSignPresentaionBody['challenge'] = 'abc'; + return hsSdk.vp.bjjVp.sign(tempSignPresentaionBody).catch(function (err) { + (0, chai_1.expect)(function () { + throw err; + }).to.throw(Error, 'HID-SSI-SDK:: params.verificationMethodId is required for signing a presentation'); + }); + })); + it('should be able to sign a selective discloser presentation document', () => __awaiter(void 0, void 0, void 0, function* () { + const presentationBody = { + presentation: unsignedSdVerifiablePresentation, + holderDid: subjectDid, + verificationMethodId: subjectDidDoc.authentication[0], + privateKeyMultibase: holderPrivateKeyMultibase, + challenge: 'abc', + domain: 'www.xyz.com', + }; + signedSdVp = yield hsSdk.vp.bjjVp.sign(presentationBody); + (0, chai_1.should)().exist(signedSdVp['@context']); + (0, chai_1.should)().exist(signedSdVp['type']); + (0, chai_1.expect)(signedSdVp.type[0]).to.be.equal('VerifiablePresentation'); + (0, chai_1.should)().exist(signedSdVp['verifiableCredential']); + (0, chai_1.should)().exist(signedSdVp['id']); + (0, chai_1.should)().exist(signedSdVp['holder']); + (0, chai_1.should)().exist(signedSdVp['proof']); + (0, chai_1.expect)(signedSdVp['proof'].type).to.be.equal('BJJSignature2021'); + (0, chai_1.should)().exist(signedSdVp['proof'].created); + (0, chai_1.should)().exist(signedSdVp['proof'].verificationMethod); + (0, chai_1.should)().exist(signedSdVp['proof'].proofPurpose); + (0, chai_1.should)().exist(signedSdVp['proof'].challenge); + (0, chai_1.should)().exist(signedSdVp['proof'].proofValue); + })); + it('should be able to sign a verifiable presentation document', () => __awaiter(void 0, void 0, void 0, function* () { + const presentationBody = { + presentation: unsignedVerifiablePresentation, + holderDid: subjectDid, + verificationMethodId: subjectDidDoc.authentication[0], + privateKeyMultibase: holderPrivateKeyMultibase, + challenge: 'abc', + domain: 'www.xyz.com', + }; + signedVp = yield hsSdk.vp.bjjVp.sign(presentationBody); + signedVp1 = {}; + Object.assign(signedVp1, signedVp); + (0, chai_1.should)().exist(signedVp['@context']); + (0, chai_1.should)().exist(signedVp['type']); + (0, chai_1.expect)(signedVp.type[0]).to.be.equal('VerifiablePresentation'); + (0, chai_1.should)().exist(signedVp['verifiableCredential']); + (0, chai_1.should)().exist(signedVp['id']); + (0, chai_1.should)().exist(signedVp['holder']); + (0, chai_1.should)().exist(signedVp['proof']); + (0, chai_1.expect)(signedVp['proof'].type).to.be.equal('BJJSignature2021'); + (0, chai_1.should)().exist(signedVp['proof'].created); + (0, chai_1.should)().exist(signedVp['proof'].verificationMethod); + (0, chai_1.should)().exist(signedVp['proof'].proofPurpose); + (0, chai_1.should)().exist(signedVp['proof'].challenge); + (0, chai_1.should)().exist(signedVp['proof'].proofValue); + })); + }); + describe('#verify() method to verify signed presentation of credential', () => { + const verifyPresentationBody = { + signedPresentation: signedSdVp, + challenge: 'abc', + domain: 'www.xyz.com', + issuerDid, + holderDid: subjectDid, + issuerVerificationMethodId: '', + holderVerificationMethodId: '', + }; + it('should not be able to verify presentation as either holderDid or holderDidDocSigned is required but passed both', function () { + return __awaiter(this, void 0, void 0, function* () { + const tempverifyPresentationBody = Object.assign({}, verifyPresentationBody); + tempverifyPresentationBody.signedPresentation = signedVp; + tempverifyPresentationBody.holderDid = subjectDid; + tempverifyPresentationBody.holderVerificationMethodId = subjectDidDoc.verificationMethod[0].id; + tempverifyPresentationBody.issuerVerificationMethodId = verificationMethod[0].id; + tempverifyPresentationBody['holderDidDocSigned'] = subjectDidDoc; + return hsSdk.vp.bjjVp.verify(tempverifyPresentationBody).catch(function (err) { + (0, chai_1.expect)(function () { + throw err; + }).to.throw(Error, 'HID-SSI-SDK:: Either holderDid or holderDidDocSigned should be provided'); + }); + }); + }); + it('should not be able to verify presentation as issuerDid is null or empty', function () { + return __awaiter(this, void 0, void 0, function* () { + const tempverifyPresentationBody = Object.assign({}, verifyPresentationBody); + tempverifyPresentationBody.issuerDid = ''; + return hsSdk.vp.bjjVp.verify(tempverifyPresentationBody).catch(function (err) { + (0, chai_1.expect)(function () { + throw err; + }).to.throw(Error, 'HID-SSI-SDK:: params.issuerDid is required for verifying a presentation'); + }); + }); + }); + it('should not be able to verify presentation as challenge is null or empty', function () { + return __awaiter(this, void 0, void 0, function* () { + const tempverifyPresentationBody = Object.assign({}, verifyPresentationBody); + tempverifyPresentationBody.issuerDid = issuerDid; + tempverifyPresentationBody.challenge = ''; + return hsSdk.vp.bjjVp.verify(tempverifyPresentationBody).catch(function (err) { + (0, chai_1.expect)(function () { + throw err; + }).to.throw(Error, 'HID-SSI-SDK:: params.challenge is required for verifying a presentation'); + }); + }); + }); + it('should not be able to verify presentation as holderVerificationMethodId is null or empty', function () { + return __awaiter(this, void 0, void 0, function* () { + const tempverifyPresentationBody = Object.assign({}, verifyPresentationBody); + tempverifyPresentationBody.issuerDid = issuerDid; + tempverifyPresentationBody.challenge = 'abc'; + tempverifyPresentationBody.holderVerificationMethodId = ''; + return hsSdk.vp.bjjVp.verify(tempverifyPresentationBody).catch(function (err) { + (0, chai_1.expect)(function () { + throw err; + }).to.throw(Error, 'HID-SSI-SDK:: params.holderVerificationMethodId is required for verifying a presentation'); + }); + }); + }); + it('should not be able to verify presentation as issuerVerificationMethodId is null or empty', function () { + return __awaiter(this, void 0, void 0, function* () { + const tempverifyPresentationBody = Object.assign({}, verifyPresentationBody); + tempverifyPresentationBody.issuerDid = issuerDid; + tempverifyPresentationBody.challenge = 'abc'; + tempverifyPresentationBody.holderVerificationMethodId = subjectDidDoc.verificationMethod[0].id; + tempverifyPresentationBody.issuerVerificationMethodId = ''; + return hsSdk.vp.bjjVp.verify(tempverifyPresentationBody).catch(function (err) { + (0, chai_1.expect)(function () { + throw err; + }).to.throw(Error, 'HID-SSI-SDK:: params.issuerVerificationMethodId is required for verifying a presentation'); + }); + }); + }); + it('should not be able to verify a sd presentation as challenge is different that used in signing', () => __awaiter(void 0, void 0, void 0, function* () { + const presentationBody = { + signedPresentation: JSON.parse(JSON.stringify(signedSdVp)), + challenge: 'abcdvfgh', + domain: 'www.xyz.com', + issuerDid, + holderDid: subjectDid, + issuerVerificationMethodId: issuerDidDoc.assertionMethod[0], + holderVerificationMethodId: subjectDidDoc.authentication[0], + }; + const verifiedVp = yield hsSdk.vp.bjjVp.verify(presentationBody); + (0, chai_1.should)().exist(verifiedVp['verified']); + (0, chai_1.expect)(verifiedVp.verified).to.be.equal(false); + (0, chai_1.should)().exist(verifiedVp['results']); + (0, chai_1.expect)(verifiedVp.results).to.be.a('array'); + (0, chai_1.expect)(verifiedVp.results[0].verified).to.be.equal(false); + (0, chai_1.expect)(verifiedVp.results[1].credentialResult).to.be.a('array'); + (0, chai_1.expect)(verifiedVp.results[1].credentialResult.length).to.be.greaterThan(0); + (0, chai_1.expect)(verifiedVp.results[1].credentialResult[0].verified).to.be.equal(true); + })); + it('should not be able to verify a sd presentation as domain is different that used in signing', () => __awaiter(void 0, void 0, void 0, function* () { + const presentationBody = { + signedPresentation: JSON.parse(JSON.stringify(signedSdVp)), + challenge: 'abc', + domain: 'www.xyz1.com', + issuerDid, + holderDid: subjectDid, + issuerVerificationMethodId: issuerDidDoc.assertionMethod[0], + holderVerificationMethodId: subjectDidDoc.authentication[0], + }; + const verifiedVp = yield hsSdk.vp.bjjVp.verify(presentationBody); + (0, chai_1.should)().exist(verifiedVp['verified']); + (0, chai_1.expect)(verifiedVp.verified).to.be.equal(false); + (0, chai_1.should)().exist(verifiedVp['results']); + (0, chai_1.expect)(verifiedVp.results).to.be.a('array'); + (0, chai_1.expect)(verifiedVp.results[0].verified).to.be.equal(false); + (0, chai_1.expect)(verifiedVp.results[1].credentialResult).to.be.a('array'); + (0, chai_1.expect)(verifiedVp.results[1].credentialResult.length).to.be.greaterThan(0); + (0, chai_1.expect)(verifiedVp.results[1].credentialResult[0].verified).to.be.equal(true); + })); + it('should be able to verify a sd presentation document', () => __awaiter(void 0, void 0, void 0, function* () { + const presentationBody = { + signedPresentation: signedSdVp, + challenge: 'abc', + domain: 'www.xyz.com', + issuerDid, + holderDid: subjectDid, + issuerVerificationMethodId: issuerDidDoc.assertionMethod[0], + holderVerificationMethodId: subjectDidDoc.authentication[0], + }; + const verifiedVp = yield hsSdk.vp.bjjVp.verify(presentationBody); + (0, chai_1.should)().exist(verifiedVp['verified']); + (0, chai_1.expect)(verifiedVp.verified).to.be.equal(true); + (0, chai_1.should)().exist(verifiedVp['results']); + (0, chai_1.expect)(verifiedVp.results).to.be.a('array'); + (0, chai_1.expect)(verifiedVp.results[1].credentialResult).to.be.a('array'); + (0, chai_1.expect)(verifiedVp.results[1].credentialResult.length).to.be.greaterThan(0); + (0, chai_1.expect)(verifiedVp.results[1].credentialResult[0].verified).to.be.equal(true); + })); + it('should not be able to verify presentation as challenge used at the time of verification is different than challenge used in vp sign and getting presentation verification result false', function () { + return __awaiter(this, void 0, void 0, function* () { + const tempverifyPresentationBody = Object.assign({}, verifyPresentationBody); + tempverifyPresentationBody.signedPresentation = signedVp1; + tempverifyPresentationBody.issuerDid = issuerDid; + tempverifyPresentationBody.holderDid = subjectDid; + tempverifyPresentationBody.challenge = 'abczshdsfhgk'; + tempverifyPresentationBody['domain'] = 'http://xyz.com'; + tempverifyPresentationBody.holderVerificationMethodId = subjectDidDoc.assertionMethod[0]; + tempverifyPresentationBody.issuerVerificationMethodId = issuerDidDoc.assertionMethod[0]; + const verifiedPresentationDetail = yield hsSdk.vp.bjjVp.verify(tempverifyPresentationBody); + (0, chai_1.expect)(verifiedPresentationDetail.verified).to.be.equal(false); + (0, chai_1.expect)(verifiedPresentationDetail.results[0].verified).to.be.equal(false); + }); + }); + it('should not be able to verify presentation as domain used at the time of vp verification is differ than domain used in vp sign and getting presentation verification result false', function () { + return __awaiter(this, void 0, void 0, function* () { + const tempverifyPresentationBody = Object.assign({}, verifyPresentationBody); + tempverifyPresentationBody.signedPresentation = signedVp1; + tempverifyPresentationBody.issuerDid = issuerDid; + tempverifyPresentationBody.holderDid = subjectDid; + tempverifyPresentationBody.challenge = 'abc'; + tempverifyPresentationBody['domain'] = 'http://xyz1.com'; + tempverifyPresentationBody.holderVerificationMethodId = subjectDidDoc.authentication[0]; + tempverifyPresentationBody.issuerVerificationMethodId = issuerDidDoc.assertionMethod[0]; + const verifiedPresentationDetail = yield hsSdk.vp.bjjVp.verify(tempverifyPresentationBody); + (0, chai_1.expect)(verifiedPresentationDetail.verified).to.be.equal(false); + (0, chai_1.expect)(verifiedPresentationDetail.results[0].verified).to.be.equal(false); + }); + }); + it('should be able to verify a presentation document', () => __awaiter(void 0, void 0, void 0, function* () { + const presentationBody = { + signedPresentation: signedVp1, + challenge: 'abc', + domain: 'www.xyz.com', + issuerDid, + holderDid: subjectDid, + issuerVerificationMethodId: issuerDidDoc.assertionMethod[0], + holderVerificationMethodId: subjectDidDoc.authentication[0], + }; + const verifiedVp = yield hsSdk.vp.bjjVp.verify(presentationBody); + (0, chai_1.should)().exist(verifiedVp['verified']); + (0, chai_1.expect)(verifiedVp.verified).to.be.equal(true); + (0, chai_1.should)().exist(verifiedVp['results']); + (0, chai_1.expect)(verifiedVp.results).to.be.a('array'); + (0, chai_1.expect)(verifiedVp.results[1].credentialResult).to.be.a('array'); + (0, chai_1.expect)(verifiedVp.results[1].credentialResult.length).to.be.greaterThan(0); + (0, chai_1.expect)(verifiedVp.results[1].credentialResult[0].verified).to.be.equal(true); + })); + }); +}); diff --git a/build/src/tests/bjj/schema/bjj_schema.spec.d.ts b/build/src/tests/bjj/schema/bjj_schema.spec.d.ts new file mode 100644 index 0000000..5900cdc --- /dev/null +++ b/build/src/tests/bjj/schema/bjj_schema.spec.d.ts @@ -0,0 +1,2 @@ +export {}; +//# sourceMappingURL=bjj_schema.spec.d.ts.map \ No newline at end of file diff --git a/build/src/tests/bjj/schema/bjj_schema.spec.d.ts.map b/build/src/tests/bjj/schema/bjj_schema.spec.d.ts.map new file mode 100644 index 0000000..c2810de --- /dev/null +++ b/build/src/tests/bjj/schema/bjj_schema.spec.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"bjj_schema.spec.d.ts","sourceRoot":"","sources":["../../../../../src/tests/bjj/schema/bjj_schema.spec.ts"],"names":[],"mappings":""} \ No newline at end of file diff --git a/build/src/tests/bjj/schema/bjj_schema.spec.js b/build/src/tests/bjj/schema/bjj_schema.spec.js new file mode 100644 index 0000000..7f7926f --- /dev/null +++ b/build/src/tests/bjj/schema/bjj_schema.spec.js @@ -0,0 +1,547 @@ +"use strict"; +var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { + function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } + return new (P || (P = Promise))(function (resolve, reject) { + function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } + function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } + function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } + step((generator = generator.apply(thisArg, _arguments || [])).next()); + }); +}; +Object.defineProperty(exports, "__esModule", { value: true }); +const index_1 = require("../../../index"); +const chai_1 = require("chai"); +const config_1 = require("../../config"); +let signedSchema2; +let invalidSchemaNamedSignedSchema1; +let invalidSchemaNamedSignedSchema2; +let invalidSchemaNamedSignedSchema3; +let randomProperty; +let privateKeyMultibase; +let publicKeyMultibase; +let offlineSigner; +let hsSdk; +let didDocument; +let verificationMethod; +let didDocId; +let schemaObject; +let signedSchema; +let schemaId; +let schemaObject2; +const schemaBody = { + name: 'TestSchema', + description: 'This is a test schema generation', + author: '', + fields: [{ name: 'name', type: 'string', isRequired: false }, { name: "address", type: "string", isRequired: true }], + additionalProperties: false, +}; +beforeEach(function () { + return __awaiter(this, void 0, void 0, function* () { + offlineSigner = yield (0, config_1.createWallet)(config_1.mnemonic); + const params = { + offlineSigner, + nodeRestEndpoint: config_1.hidNodeEp.rest, + nodeRpcEndpoint: config_1.hidNodeEp.rpc, + namespace: config_1.hidNodeEp.namespace, + }; + hsSdk = new index_1.HypersignSSISdk(params); + yield hsSdk.init(); + }); +}); +describe('#generateKeys() method to generate publicKyeMultibase and privateKeyMultiBase', function () { + it('should return publickeyMultibase and privateKeyMultibase', function () { + return __awaiter(this, void 0, void 0, function* () { + const kp = yield hsSdk.did.bjjDID.generateKeys(); + privateKeyMultibase = kp.privateKeyMultibase; + publicKeyMultibase = kp.publicKeyMultibase; + (0, chai_1.expect)(kp).to.be.a('object'); + (0, chai_1.should)().exist(kp.privateKeyMultibase); + (0, chai_1.should)().exist(kp.publicKeyMultibase); + (0, chai_1.should)().not.exist(kp.id); + }); + }); +}); +describe('DID Operation', () => { + describe('#generate() method to generate new did', function () { + it('should be able to generate a did using babyJubJub', () => __awaiter(this, void 0, void 0, function* () { + didDocument = yield hsSdk.did.bjjDID.generate({ + publicKeyMultibase + }); + didDocId = didDocument.id; + verificationMethod = didDocument.verificationMethod; + (0, chai_1.expect)(didDocument).to.be.a('object'); + (0, chai_1.should)().exist(didDocument['@context']); + (0, chai_1.should)().exist(didDocument['id']); + (0, chai_1.should)().exist(didDocument['controller']); + (0, chai_1.should)().exist(didDocument['verificationMethod']); + (0, chai_1.expect)(didDocument['verificationMethod'] && + didDocument['authentication'] && + didDocument['assertionMethod'] && + didDocument['keyAgreement'] && + didDocument['capabilityInvocation'] && + didDocument['capabilityDelegation'] && + didDocument['service']).to.be.a('array'); + (0, chai_1.expect)(verificationMethod[0].type).to.be.equal('BabyJubJubKey2021'); + (0, chai_1.should)().exist(didDocument['authentication']); + (0, chai_1.should)().exist(didDocument['assertionMethod']); + (0, chai_1.should)().exist(didDocument['keyAgreement']); + (0, chai_1.should)().exist(didDocument['capabilityInvocation']); + (0, chai_1.should)().exist(didDocument['capabilityDelegation']); + (0, chai_1.should)().exist(didDocument['service']); + (0, chai_1.expect)(didDocument['authentication'].length).to.be.greaterThan(0); + (0, chai_1.expect)(didDocument['assertionMethod'].length).to.be.greaterThan(0); + (0, chai_1.expect)(didDocument['capabilityInvocation'].length).to.be.equal(0); + (0, chai_1.expect)(didDocument['capabilityDelegation'].length).to.be.equal(0); + (0, chai_1.expect)(didDocument['keyAgreement'].length).to.be.equal(0); + (0, chai_1.expect)(didDocument['service'].length).to.be.equal(0); + })); + }); + describe('#register() method to register did', function () { + it('should be able to register did generated using BabyJubJubKey', () => __awaiter(this, void 0, void 0, function* () { + const registerDid = yield hsSdk.did.bjjDID.register({ + didDocument: didDocument, + privateKeyMultibase, + verificationMethodId: verificationMethod[0].id + }); + didDocument = registerDid.didDocument; + (0, chai_1.expect)(didDocument).to.be.a('object'); + (0, chai_1.should)().exist(didDocument['@context']); + (0, chai_1.should)().exist(didDocument['id']); + (0, chai_1.should)().exist(didDocument['controller']); + (0, chai_1.should)().exist(didDocument['verificationMethod']); + (0, chai_1.expect)(didDocument['verificationMethod'] && + didDocument['authentication'] && + didDocument['assertionMethod'] && + didDocument['keyAgreement'] && + didDocument['capabilityInvocation'] && + didDocument['capabilityDelegation'] && + didDocument['service']).to.be.a('array'); + (0, chai_1.expect)(verificationMethod[0].type).to.be.equal('BabyJubJubKey2021'); + (0, chai_1.should)().exist(didDocument['authentication']); + (0, chai_1.should)().exist(didDocument['assertionMethod']); + (0, chai_1.should)().exist(didDocument['keyAgreement']); + (0, chai_1.should)().exist(didDocument['capabilityInvocation']); + (0, chai_1.should)().exist(didDocument['capabilityDelegation']); + (0, chai_1.should)().exist(didDocument['service']); + (0, chai_1.expect)(didDocument['authentication'].length).to.be.greaterThan(0); + (0, chai_1.expect)(didDocument['assertionMethod'].length).to.be.greaterThan(0); + (0, chai_1.expect)(didDocument['capabilityInvocation'].length).to.be.equal(0); + (0, chai_1.expect)(didDocument['capabilityDelegation'].length).to.be.equal(0); + (0, chai_1.expect)(didDocument['keyAgreement'].length).to.be.equal(0); + (0, chai_1.expect)(didDocument['service'].length).to.be.equal(0); + (0, chai_1.should)().exist(registerDid.transactionHash); + })); + }); +}); +describe('Schema Operations', () => { + describe('#generate() method to create schema', function () { + it('should not be able to create a new schema as author is not passed', function () { + const tempSchemaBody = Object.assign({}, schemaBody); + return hsSdk.schema.hypersignBjjschema.generate(tempSchemaBody).catch(function (err) { + (0, chai_1.expect)(function () { + throw err; + }).to.throw(Error, 'HID-SSI-SDK:: Error: Author must be passed'); + }); + }); + it('should not be able to create a new schema as schema name is in camelCase and only pascalCase is allowed', function () { + const tempSchemaBody = Object.assign({}, schemaBody); + tempSchemaBody.author = didDocId; + tempSchemaBody['name'] = 'testSchema'; + return hsSdk.schema.hypersignBjjschema.generate(tempSchemaBody).catch(function (err) { + (0, chai_1.expect)(function () { + throw err; + }).to.throw(Error, 'HID-SSI-SDK:: Error: schema name should always be in PascalCase'); + }); + }); + it('should not be able to create a schema as schema name is in snakeCase and only pascalCase is allowed', function () { + const tempSchemaBody = Object.assign({}, schemaBody); + tempSchemaBody.author = didDocId; + tempSchemaBody['name'] = 'testing_schema'; + return hsSdk.schema.hypersignBjjschema.generate(tempSchemaBody).catch(function (err) { + (0, chai_1.expect)(function () { + throw err; + }).to.throw(Error, 'HID-SSI-SDK:: Error: schema name should always be in PascalCase'); + }); + }); + it('should not be able to create a schema as schema name is not in pascalCase', function () { + const tempSchemaBody = Object.assign({}, schemaBody); + tempSchemaBody.author = didDocId; + tempSchemaBody['name'] = 'Test credential Schema'; + return hsSdk.schema.hypersignBjjschema.generate(tempSchemaBody).catch(function (err) { + (0, chai_1.expect)(function () { + throw err; + }).to.throw(Error, 'HID-SSI-SDK:: Error: schema name should always be in PascalCase'); + }); + }); + it("should not be able to create a schema as sub-property 'name' is not present in field property", function () { + const tempSchemaBody = Object.assign({}, schemaBody); + tempSchemaBody.author = didDocId; + tempSchemaBody['fields'] = [{ isRequired: true }]; + return hsSdk.schema.hypersignBjjschema.generate(tempSchemaBody).catch(function (err) { + (0, chai_1.expect)(function () { + throw err; + }).to.throw(Error, "HID-SSI-SDK:: Error: All fields must contains property 'name'"); + }); + }); + it('should be able to generate new schema', function () { + return __awaiter(this, void 0, void 0, function* () { + const tempSchemaBody = Object.assign({}, schemaBody); + tempSchemaBody.author = didDocId; + schemaObject = yield hsSdk.schema.hypersignBjjschema.generate(tempSchemaBody); + schemaId = schemaObject['id']; + (0, chai_1.expect)(schemaObject).to.be.a('object'); + (0, chai_1.should)().exist(schemaObject['type']); + (0, chai_1.should)().exist(schemaObject['modelVersion']); + (0, chai_1.should)().exist(schemaObject['id']); + (0, chai_1.should)().exist(schemaObject['name']); + (0, chai_1.should)().exist(schemaObject['author']); + (0, chai_1.should)().exist(schemaObject['authored']); + (0, chai_1.should)().exist(schemaObject['schema']); + (0, chai_1.expect)(schemaObject.schema).to.be.a('object'); + (0, chai_1.expect)(schemaObject['name']).to.be.equal(tempSchemaBody.name); + (0, chai_1.expect)(schemaObject['author']).to.be.equal(tempSchemaBody.author); + (0, chai_1.expect)(schemaObject['schema'].required).to.be.a('array'); + }); + }); + it('should be able to create a schema with differnt field value', function () { + return __awaiter(this, void 0, void 0, function* () { + const tempSchemaBody = Object.assign({}, schemaBody); + tempSchemaBody.fields.push({ name: 'address', type: 'string', isRequired: false }); + tempSchemaBody.author = didDocId; + schemaObject2 = yield hsSdk.schema.hypersignBjjschema.generate(tempSchemaBody); + (0, chai_1.expect)(schemaObject).to.be.a('object'); + (0, chai_1.should)().exist(schemaObject['type']); + (0, chai_1.should)().exist(schemaObject['modelVersion']); + (0, chai_1.should)().exist(schemaObject['id']); + (0, chai_1.should)().exist(schemaObject['name']); + (0, chai_1.should)().exist(schemaObject['author']); + (0, chai_1.should)().exist(schemaObject['authored']); + (0, chai_1.should)().exist(schemaObject['schema']); + (0, chai_1.expect)(schemaObject.schema).to.be.a('object'); + (0, chai_1.expect)(schemaObject['name']).to.be.equal(tempSchemaBody.name); + (0, chai_1.expect)(schemaObject['author']).to.be.equal(tempSchemaBody.author); + }); + }); + }); + describe('#sign() method to sign a schema', function () { + it('should not be able to sign a new schema as privateKeyMultibase is not passed', function () { + return hsSdk.schema.hypersignBjjschema.sign({ + privateKeyMultibase: "", + schema: schemaObject, + verificationMethodId: didDocument['assertionMethod'][0] + }).catch(function (err) { + (0, chai_1.expect)(function () { + throw err; + }).to.throw(Error, 'HID-SSI-SDK:: Error: params.privateKeyMultibase must be passed'); + }); + }); + it('should not be able to sign a new schema as verificationMethodId is not passed', function () { + return hsSdk.schema.hypersignBjjschema.sign({ + privateKeyMultibase, + schema: schemaObject, + verificationMethodId: "" + }).catch(function (err) { + (0, chai_1.expect)(function () { + throw err; + }).to.throw(Error, 'HID-SSI-SDK:: Error: params.verificationMethodId must be passed'); + }); + }); + it('should not be able to sign a new schema as schema is not passed', function () { + return hsSdk.schema.hypersignBjjschema.sign({ + privateKeyMultibase, + verificationMethodId: didDocument['assertionMethod'][0] + }).catch(function (err) { + (0, chai_1.expect)(function () { + throw err; + }).to.throw(Error, 'HID-SSI-SDK:: Error: Schema must be passed'); + }); + }); + it('should be able to sign newly created schema', () => __awaiter(this, void 0, void 0, function* () { + signedSchema = yield hsSdk.schema.hypersignBjjschema.sign({ + privateKeyMultibase, + schema: schemaObject, + verificationMethodId: didDocument['assertionMethod'][0] + }); + (0, chai_1.expect)(signedSchema).to.be.a('object'); + (0, chai_1.should)().exist(signedSchema.type); + (0, chai_1.should)().exist(signedSchema.modelVersion); + (0, chai_1.should)().exist(signedSchema['id']); + (0, chai_1.should)().exist(signedSchema['name']); + (0, chai_1.should)().exist(signedSchema['author']); + (0, chai_1.should)().exist(signedSchema['authored']); + (0, chai_1.should)().exist(signedSchema['schema']); + (0, chai_1.should)().exist(signedSchema.schema.schema); + (0, chai_1.should)().exist(signedSchema.schema.description); + (0, chai_1.should)().exist(signedSchema.schema.type); + (0, chai_1.should)().exist(signedSchema.schema.properties); + (0, chai_1.should)().exist(signedSchema.schema.required); + (0, chai_1.should)().exist(signedSchema.proof); + (0, chai_1.should)().exist(signedSchema.proof.type); + (0, chai_1.expect)(signedSchema.proof.type).to.be.equal('BJJSignature2021'); + (0, chai_1.should)().exist(signedSchema.proof.created); + (0, chai_1.should)().exist(signedSchema.proof.verificationMethod); + (0, chai_1.should)().exist(signedSchema.proof.proofPurpose); + (0, chai_1.expect)(signedSchema.proof.proofPurpose).to.be.equal('assertionMethod'); + (0, chai_1.should)().exist(signedSchema.proof.proofValue); + })); + it('should be able to sign newly created schema with schema name is in camelCase', function () { + return __awaiter(this, void 0, void 0, function* () { + const tempSchemaBody = JSON.parse(JSON.stringify(schemaObject2)); + tempSchemaBody['name'] = "testSchema"; + invalidSchemaNamedSignedSchema1 = yield hsSdk.schema.hypersignBjjschema.sign({ + privateKeyMultibase: privateKeyMultibase, + schema: tempSchemaBody, + verificationMethodId: didDocument['assertionMethod'][0], + }); + (0, chai_1.expect)(signedSchema).to.be.a('object'); + (0, chai_1.should)().exist(signedSchema.proof); + (0, chai_1.should)().exist(signedSchema.proof.type); + (0, chai_1.should)().exist(signedSchema.proof.verificationMethod); + (0, chai_1.should)().exist(signedSchema.proof.proofPurpose); + (0, chai_1.should)().exist(signedSchema.proof.proofValue); + (0, chai_1.should)().exist(signedSchema.proof.created); + (0, chai_1.should)().exist(signedSchema.type); + (0, chai_1.should)().exist(signedSchema.modelVersion); + (0, chai_1.should)().exist(signedSchema.author); + (0, chai_1.should)().exist(signedSchema['id']); + (0, chai_1.should)().exist(signedSchema['name']); + (0, chai_1.should)().exist(signedSchema['author']); + (0, chai_1.should)().exist(signedSchema['authored']); + (0, chai_1.should)().exist(signedSchema['schema']); + }); + }); + it('should be able to sign newly created schema with schema name is in snakeCase', function () { + return __awaiter(this, void 0, void 0, function* () { + const tempSchemaBody = JSON.parse(JSON.stringify(schemaObject2)); + tempSchemaBody['name'] = "test_schema"; + invalidSchemaNamedSignedSchema2 = yield hsSdk.schema.hypersignBjjschema.sign({ + privateKeyMultibase: privateKeyMultibase, + schema: tempSchemaBody, + verificationMethodId: didDocument['assertionMethod'][0], + }); + (0, chai_1.expect)(signedSchema).to.be.a('object'); + (0, chai_1.should)().exist(signedSchema.proof); + (0, chai_1.should)().exist(signedSchema.proof.type); + (0, chai_1.should)().exist(signedSchema.proof.verificationMethod); + (0, chai_1.should)().exist(signedSchema.proof.proofPurpose); + (0, chai_1.should)().exist(signedSchema.proof.proofValue); + (0, chai_1.should)().exist(signedSchema.proof.created); + (0, chai_1.should)().exist(signedSchema.type); + (0, chai_1.should)().exist(signedSchema.modelVersion); + (0, chai_1.should)().exist(signedSchema.author); + (0, chai_1.should)().exist(signedSchema['id']); + (0, chai_1.should)().exist(signedSchema['name']); + (0, chai_1.should)().exist(signedSchema['author']); + (0, chai_1.should)().exist(signedSchema['authored']); + (0, chai_1.should)().exist(signedSchema['schema']); + }); + }); + it('should be able to sign newly created schema with schema name is in sentanceCase', function () { + return __awaiter(this, void 0, void 0, function* () { + const tempSchemaBody = JSON.parse(JSON.stringify(schemaObject2)); + tempSchemaBody['name'] = "Test Schema"; + invalidSchemaNamedSignedSchema3 = yield hsSdk.schema.hypersignBjjschema.sign({ + privateKeyMultibase: privateKeyMultibase, + schema: tempSchemaBody, + verificationMethodId: didDocument['assertionMethod'][0], + }); + (0, chai_1.expect)(signedSchema).to.be.a('object'); + (0, chai_1.should)().exist(signedSchema.proof); + (0, chai_1.should)().exist(signedSchema.proof.type); + (0, chai_1.should)().exist(signedSchema.proof.verificationMethod); + (0, chai_1.should)().exist(signedSchema.proof.proofPurpose); + (0, chai_1.should)().exist(signedSchema.proof.proofValue); + (0, chai_1.should)().exist(signedSchema.proof.created); + (0, chai_1.should)().exist(signedSchema.type); + (0, chai_1.should)().exist(signedSchema.modelVersion); + (0, chai_1.should)().exist(signedSchema.author); + (0, chai_1.should)().exist(signedSchema['id']); + (0, chai_1.should)().exist(signedSchema['name']); + (0, chai_1.should)().exist(signedSchema['author']); + (0, chai_1.should)().exist(signedSchema['authored']); + (0, chai_1.should)().exist(signedSchema['schema']); + }); + }); + it('should be able to sign newly created schema with invalid sub-property of propert field', function () { + return __awaiter(this, void 0, void 0, function* () { + const tempSchemaBody = JSON.parse(JSON.stringify(schemaObject2)); + const prop = JSON.parse(tempSchemaBody.schema.properties); + randomProperty = "randomProperty"; + prop[`${schemaBody.fields[0].name}`]['randomProperty'] = "xyz"; + tempSchemaBody['schema'].properties = JSON.stringify(prop); + signedSchema2 = yield hsSdk.schema.hypersignBjjschema.sign({ + privateKeyMultibase: privateKeyMultibase, + schema: tempSchemaBody, + verificationMethodId: didDocument['assertionMethod'][0], + }); + (0, chai_1.expect)(signedSchema).to.be.a('object'); + (0, chai_1.should)().exist(signedSchema.proof); + (0, chai_1.should)().exist(signedSchema.proof.type); + (0, chai_1.should)().exist(signedSchema.proof.verificationMethod); + (0, chai_1.should)().exist(signedSchema.proof.proofPurpose); + (0, chai_1.should)().exist(signedSchema.proof.proofValue); + (0, chai_1.should)().exist(signedSchema.proof.created); + (0, chai_1.should)().exist(signedSchema.type); + (0, chai_1.should)().exist(signedSchema.modelVersion); + (0, chai_1.should)().exist(signedSchema.author); + (0, chai_1.should)().exist(signedSchema['id']); + (0, chai_1.should)().exist(signedSchema['name']); + (0, chai_1.should)().exist(signedSchema['author']); + (0, chai_1.should)().exist(signedSchema['authored']); + (0, chai_1.should)().exist(signedSchema['schema']); + }); + }); + }); + describe('#register() method to register a schema', function () { + it('Should not be able to register schema as schema is not passed in params', () => __awaiter(this, void 0, void 0, function* () { + const params = { + schemas: signedSchema + }; + return hsSdk.schema.hypersignBjjschema.register(params).catch(function (err) { + (0, chai_1.expect)(function () { + throw err; + }).to.throw(Error, 'HID-SSI-SDK:: Error: schema must be passed'); + }); + })); + it('Should not be able to register schema as schema object does not have proof field', () => __awaiter(this, void 0, void 0, function* () { + const tempSchemaDetail = Object.assign({}, signedSchema); + delete tempSchemaDetail.proof; + return hsSdk.schema.hypersignBjjschema.register({ schema: tempSchemaDetail }).catch(function (err) { + (0, chai_1.expect)(function () { + throw err; + }).to.throw(Error, 'HID-SSI-SDK:: Error: schema.proof must be passed'); + }); + })); + it('Should not be able to register schema as schema proof does not have "created" field or it is empty ', () => __awaiter(this, void 0, void 0, function* () { + const tempSchemaDetail = JSON.parse(JSON.stringify(Object.assign({}, signedSchema))); + tempSchemaDetail.proof.created = ""; + return hsSdk.schema.hypersignBjjschema.register({ schema: tempSchemaDetail }).catch(function (err) { + (0, chai_1.expect)(function () { + throw err; + }).to.throw(Error, 'HID-SSI-SDK:: Error: schema.proof must Contain created'); + }); + })); + it('Should not be able to register schema as schema proof does not have "proofPurpose" field or it is empty ', () => __awaiter(this, void 0, void 0, function* () { + const tempSchemaDetail = JSON.parse(JSON.stringify(Object.assign({}, signedSchema))); + tempSchemaDetail.proof.proofPurpose = ""; + return hsSdk.schema.hypersignBjjschema.register({ schema: tempSchemaDetail }).catch(function (err) { + (0, chai_1.expect)(function () { + throw err; + }).to.throw(Error, 'HID-SSI-SDK:: Error: schema.proof must Contain proofPurpose'); + }); + })); + it('Should not be able to register schema as schema proof does not have "proofValue" field or it is empty ', () => __awaiter(this, void 0, void 0, function* () { + const tempSchemaDetail = JSON.parse(JSON.stringify(Object.assign({}, signedSchema))); + tempSchemaDetail.proof.proofValue = ""; + return hsSdk.schema.hypersignBjjschema.register({ schema: tempSchemaDetail }).catch(function (err) { + (0, chai_1.expect)(function () { + throw err; + }).to.throw(Error, 'HID-SSI-SDK:: Error: schema.proof must Contain proofValue'); + }); + })); + it('Should not be able to register schema as schema proof does not have "type" field or it is empty ', () => __awaiter(this, void 0, void 0, function* () { + const tempSchemaDetail = JSON.parse(JSON.stringify(Object.assign({}, signedSchema))); + tempSchemaDetail.proof.type = ""; + return hsSdk.schema.hypersignBjjschema.register({ schema: tempSchemaDetail }).catch(function (err) { + (0, chai_1.expect)(function () { + throw err; + }).to.throw(Error, 'HID-SSI-SDK:: Error: schema.proof must Contain type'); + }); + })); + it('Should not be able to register schema as schema proof does not have "verificationMethod" field or it is empty ', () => __awaiter(this, void 0, void 0, function* () { + const tempSchemaDetail = JSON.parse(JSON.stringify(Object.assign({}, signedSchema))); + tempSchemaDetail.proof.verificationMethod = ""; + return hsSdk.schema.hypersignBjjschema.register({ schema: tempSchemaDetail }).catch(function (err) { + (0, chai_1.expect)(function () { + throw err; + }).to.throw(Error, 'HID-SSI-SDK:: Error: schema.proof must Contain verificationMethod'); + }); + })); + it('should be able to register newly created schema', () => __awaiter(this, void 0, void 0, function* () { + const registerdSchema = yield hsSdk.schema.hypersignBjjschema.register({ schema: signedSchema }); + (0, chai_1.should)().exist(registerdSchema.transactionHash); + })); + it('should not be able to register schema on blockchain as its already registered', function () { + return __awaiter(this, void 0, void 0, function* () { + return hsSdk.schema.hypersignBjjschema.register({ + schema: signedSchema, + }).catch(function (err) { + (0, chai_1.expect)(function () { + throw err; + }).to.throw(Error, `failed to execute message; message index: 0: Schema ID: ${schemaId}: schema already exists`); + }); + }); + }); + it('should not be able to register schema as schema name is in camel case which is not valid', function () { + return __awaiter(this, void 0, void 0, function* () { + return hsSdk.schema.hypersignBjjschema.register({ + schema: invalidSchemaNamedSignedSchema1, + }).catch(function (err) { + (0, chai_1.expect)(function () { + throw err; + }).to.throw(Error, `failed to execute message; message index: 0: name must always be in PascalCase: ${invalidSchemaNamedSignedSchema1.name}: invalid credential schema`); + }); + }); + }); + it('should not be able to register schema as schema name is in snake case which is not valid', function () { + return __awaiter(this, void 0, void 0, function* () { + return hsSdk.schema.hypersignBjjschema.register({ + schema: invalidSchemaNamedSignedSchema2, + }).catch(function (err) { + (0, chai_1.expect)(function () { + throw err; + }).to.throw(Error, `failed to execute message; message index: 0: name must always be in PascalCase: ${invalidSchemaNamedSignedSchema2.name}: invalid credential schema`); + }); + }); + }); + it('should not be able to register schema as schema name is in sentance case which is not valid', function () { + return __awaiter(this, void 0, void 0, function* () { + return hsSdk.schema.hypersignBjjschema.register({ + schema: invalidSchemaNamedSignedSchema3, + }).catch(function (err) { + (0, chai_1.expect)(function () { + throw err; + }).to.throw(Error, `failed to execute message; message index: 0: name must always be in PascalCase: ${invalidSchemaNamedSignedSchema3.name}: invalid credential schema`); + }); + }); + }); + it('should not be able to register schema as there is a invalid sub-property in side property field', function () { + return __awaiter(this, void 0, void 0, function* () { + return hsSdk.schema.hypersignBjjschema.register({ + schema: signedSchema2, + }).catch(function (err) { + (0, chai_1.expect)(function () { + throw err; + }).to.throw(Error, `failed to execute message; message index: 0: invalid \`property\` provided: invalid sub-attribute ${randomProperty} of attribute name. Only \`type\` and \`format\` sub-attributes are permitted: invalid credential schema`); + }); + }); + }); + }); + describe('#resolve() method to resolve a schema', function () { + it('Should be able to resolve schema from blockchain', () => __awaiter(this, void 0, void 0, function* () { + const resolvedSchema = yield hsSdk.schema.hypersignBjjschema.resolve({ schemaId }); + (0, chai_1.should)().exist(resolvedSchema.context); + (0, chai_1.should)().exist(resolvedSchema.type); + (0, chai_1.should)().exist(resolvedSchema.modelVersion); + (0, chai_1.should)().exist(resolvedSchema.id); + (0, chai_1.should)().exist(resolvedSchema.name); + (0, chai_1.should)().exist(resolvedSchema.author); + (0, chai_1.should)().exist(resolvedSchema.authored); + (0, chai_1.should)().exist(resolvedSchema.schema); + (0, chai_1.should)().exist(resolvedSchema.schema.schema); + (0, chai_1.should)().exist(resolvedSchema.schema.description); + (0, chai_1.should)().exist(resolvedSchema.schema.type); + (0, chai_1.should)().exist(resolvedSchema.schema.properties); + (0, chai_1.should)().exist(resolvedSchema.schema.required); + (0, chai_1.should)().exist(resolvedSchema.schema.additionalProperties); + (0, chai_1.should)().exist(resolvedSchema.proof); + (0, chai_1.expect)(resolvedSchema.proof.type).to.be.equal('BJJSignature2021'); + (0, chai_1.should)().exist(resolvedSchema.proof.created); + (0, chai_1.should)().exist(resolvedSchema.proof.verificationMethod); + (0, chai_1.should)().exist(resolvedSchema.proof.proofPurpose); + (0, chai_1.should)().exist(resolvedSchema.proof.proofValue); + (0, chai_1.should)().exist(resolvedSchema.proof.clientSpecType); + (0, chai_1.expect)(resolvedSchema.proof.clientSpecType).to.be.equal('CLIENT_SPEC_TYPE_NONE'); + })); + }); +}); diff --git a/build/src/tests/config.d.ts b/build/src/tests/config.d.ts index 7823c85..77e8c99 100644 --- a/build/src/tests/config.d.ts +++ b/build/src/tests/config.d.ts @@ -1,5 +1,7 @@ import { DirectSecp256k1HdWallet } from '@cosmjs/proto-signing'; import { Slip10RawIndex } from '@cosmjs/crypto'; +import Web3 from 'web3'; +import { ProofTypes, VerificationMethodRelationships } from '../../libs/generated/ssi/client/enums'; export declare const mnemonic = "verify sustain lumber boat demise parade special soft bargain scout spoil there addict move badge rebuild horn achieve hollow acquire glide bundle curious present"; export declare const hidNodeEp: { rpc: string; @@ -8,4 +10,16 @@ export declare const hidNodeEp: { }; export declare function makeCosmoshubPath(a: any): Slip10RawIndex[]; export declare const createWallet: (mnemonic: any) => Promise; +export declare const generatePresentationProof: (presentation: any, challenge: any, holderDid: any, authentication: any, verificationMethodId: any, domain?: any) => Promise; +export declare const verifyPresentation: (signedPresentaion: any, challenge: any, holderDid: any, domain?: any) => Promise; +export declare const metamaskProvider = "https://linea-goerli.infura.io/v3/6014efc44d9346bcb69d99d97aa0ad27"; +export declare const generateWeb3Obj: () => Promise; +export declare const signDid: (didDocument: any, clientSpec: any, verificationMethodId: any, account: any) => Promise<{ + '@context': any; + type: ProofTypes; + created: string; + verificationMethod: any; + proofPurpose: VerificationMethodRelationships; +} | undefined>; +export declare const entityApiSecret = "29a393a5d70094e409824359fc5d5.befc6c6f32d622e1c29ca900299a5695251b2407ca7cf6db8e6b2569dc13f937a4b83f4fa78738715d6267d3733e4f139"; //# sourceMappingURL=config.d.ts.map \ No newline at end of file diff --git a/build/src/tests/config.d.ts.map b/build/src/tests/config.d.ts.map index b586557..4ee2f57 100644 --- a/build/src/tests/config.d.ts.map +++ b/build/src/tests/config.d.ts.map @@ -1 +1 @@ -{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../../src/tests/config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,uBAAuB,EAAE,MAAM,uBAAuB,CAAC;AAChE,OAAO,EAAU,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAExD,eAAO,MAAM,QAAQ,uKACiJ,CAAC;AAEvK,eAAO,MAAM,SAAS;;;;CAIrB,CAAC;AAMF,wBAAgB,iBAAiB,CAAC,CAAC,KAAA,oBAQlC;AAED,eAAO,MAAM,YAAY,qDAmBxB,CAAC"} \ No newline at end of file +{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../../src/tests/config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,uBAAuB,EAAE,MAAM,uBAAuB,CAAC;AAChE,OAAO,EAAU,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAMxD,OAAO,IAAI,MAAM,MAAM,CAAC;AAIxB,OAAO,EAAE,UAAU,EAAE,+BAA+B,EAAE,MAAM,uCAAuC,CAAC;AAIpG,eAAO,MAAM,QAAQ,uKACiJ,CAAC;AAEvK,eAAO,MAAM,SAAS;;;;CAIrB,CAAC;AAMF,wBAAgB,iBAAiB,CAAC,CAAC,KAAA,oBAQlC;AAGD,eAAO,MAAM,YAAY,qDAmBxB,CAAC;AAEF,eAAO,MAAM,yBAAyB,mIAqCrC,CAAC;AAEF,eAAO,MAAM,kBAAkB,iJAqB9B,CAAC;AAgBF,eAAO,MAAM,gBAAgB,uEAAuE,CAAC;AAErG,eAAO,MAAM,eAAe,qBAI3B,CAAC;AAEF,eAAO,MAAM,OAAO;;;;;;cAsCnB,CAAC;AAEF,eAAO,MAAM,eAAe,oIACuG,CAAC"} \ No newline at end of file diff --git a/build/src/tests/config.js b/build/src/tests/config.js index 6a4d12d..1e73d49 100644 --- a/build/src/tests/config.js +++ b/build/src/tests/config.js @@ -8,19 +8,33 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge step((generator = generator.apply(thisArg, _arguments || [])).next()); }); }; +var __importDefault = (this && this.__importDefault) || function (mod) { + return (mod && mod.__esModule) ? mod : { "default": mod }; +}; Object.defineProperty(exports, "__esModule", { value: true }); -exports.createWallet = exports.makeCosmoshubPath = exports.hidNodeEp = exports.mnemonic = void 0; +exports.entityApiSecret = exports.signDid = exports.generateWeb3Obj = exports.metamaskProvider = exports.verifyPresentation = exports.generatePresentationProof = exports.createWallet = exports.makeCosmoshubPath = exports.hidNodeEp = exports.mnemonic = void 0; const proto_signing_1 = require("@cosmjs/proto-signing"); const crypto_1 = require("@cosmjs/crypto"); +const ethereumeip712signature2021suite_1 = require("ethereumeip712signature2021suite"); +const jsonld_signatures_1 = require("jsonld-signatures"); +const constants_1 = require("../constants"); +const v1_1 = __importDefault(require("../../libs/w3cache/v1")); +const jcs_1 = require("jcs"); +const web3_1 = __importDefault(require("web3")); +const jsonld_1 = __importDefault(require("jsonld")); +const crypto_2 = __importDefault(require("crypto")); +const enums_1 = require("../../libs/generated/ssi/client/enums"); +const documentLoader = v1_1.default; +let keyPair; exports.mnemonic = 'verify sustain lumber boat demise parade special soft bargain scout spoil there addict move badge rebuild horn achieve hollow acquire glide bundle curious present'; exports.hidNodeEp = { - rpc: 'https://rpc.jagrat.hypersign.id', - rest: 'https://api.jagrat.hypersign.id', + rpc: 'https://rpc.prajna.hypersign.id', + rest: 'https://api.prajna.hypersign.id', namespace: 'testnet', }; // export const hidNodeEp = { -// rpc: 'http://localhost:26657', -// rest: 'http://localhost:1317', +// rpc: 'http://127.0.0.1:26657', +// rest: 'http://127.0.0.1:1317', // namespace: 'testnet', // }; function makeCosmoshubPath(a) { @@ -33,6 +47,7 @@ function makeCosmoshubPath(a) { ]; } exports.makeCosmoshubPath = makeCosmoshubPath; +const phrase = 'flat vessel crawl guess female tray breeze bachelor rare fragile pottery observe'; const createWallet = (mnemonic) => __awaiter(void 0, void 0, void 0, function* () { let options; if (!mnemonic) { @@ -49,4 +64,113 @@ const createWallet = (mnemonic) => __awaiter(void 0, void 0, void 0, function* ( } }); exports.createWallet = createWallet; +const generatePresentationProof = (presentation, challenge, holderDid, authentication, verificationMethodId, domain) => __awaiter(void 0, void 0, void 0, function* () { + const web3 = yield (0, exports.generateWeb3Obj)(); + const EthereumEip712Signature2021obj = new ethereumeip712signature2021suite_1.EthereumEip712Signature2021({}, web3); + keyPair = yield EthereumEip712Signature2021obj.fromPrivateKey('0x149195a4059ac8cafe2d56fc612f613b6b18b9265a73143c9f6d7cfbbed76b7e'); + const vcs = []; + presentation.verifiableCredential.forEach((vc) => { + return vcs.push(jcs_1.JCS.cannonicalize(vc)); + }); + presentation.verifiableCredential = vcs; + const proof = yield EthereumEip712Signature2021obj.createProof({ + document: presentation, + purpose: new jsonld_signatures_1.purposes.AuthenticationProofPurpose({ + challenge, + domain: domain, + controller: { + '@context': constants_1.DID.CONTROLLER_CONTEXT, + id: holderDid, + authentication: authentication, + }, + }), + verificationMethod: verificationMethodId, + date: new Date().toISOString(), + documentLoader, + domain: domain ? { name: domain } : undefined, + }); + presentation.proof = proof; + return presentation; +}); +exports.generatePresentationProof = generatePresentationProof; +// will remove unused functions later +const verifyPresentation = (signedPresentaion, challenge, holderDid, domain) => __awaiter(void 0, void 0, void 0, function* () { + const EthereumEip712Signature2021obj = new ethereumeip712signature2021suite_1.EthereumEip712Signature2021({}); + const proof = signedPresentaion.proof; + delete signedPresentaion.proof; + const verifResult = yield EthereumEip712Signature2021obj.verifyProof({ + proof: proof, + domain: domain ? { name: domain } : undefined, + document: signedPresentaion, + types: 'EthereumEip712Signature2021', + purpose: new jsonld_signatures_1.purposes.AuthenticationProofPurpose({ + challenge, + domain: domain, + controller: { + '@context': constants_1.DID.CONTROLLER_CONTEXT, + id: holderDid, + authentication: [`${holderDid}#key-1`], + }, + }), + documentLoader: v1_1.default, + }); + return verifResult; +}); +exports.verifyPresentation = verifyPresentation; +function _jsonLdNormalize(params) { + return __awaiter(this, void 0, void 0, function* () { + const docToNormalize = params.doc; + const normalizedoc = yield jsonld_1.default.normalize(docToNormalize, { + format: 'application/n-quads', + algorithm: 'URDNA2015', + }); + return normalizedoc; + }); +} +function _concat(arr1, arr2) { + const concatenatedArr = new Uint8Array(arr1.length + arr2.length); + concatenatedArr.set(arr1, 0); + concatenatedArr.set(arr2, arr1.length); + return concatenatedArr; +} +exports.metamaskProvider = 'https://linea-goerli.infura.io/v3/6014efc44d9346bcb69d99d97aa0ad27'; +const generateWeb3Obj = () => __awaiter(void 0, void 0, void 0, function* () { + const provider = new web3_1.default.providers.HttpProvider(exports.metamaskProvider); + const web3 = new web3_1.default(provider); + return web3; +}); +exports.generateWeb3Obj = generateWeb3Obj; +const signDid = (didDocument, clientSpec, verificationMethodId, account) => __awaiter(void 0, void 0, void 0, function* () { + if (clientSpec == 'eth-personalSign') { + const normalizedDidDoc = yield _jsonLdNormalize({ doc: didDocument }); + const normalizedDidDocHash = new Uint8Array(Buffer.from(crypto_2.default.createHash('sha256').update(normalizedDidDoc).digest('hex'), 'hex')); + const proof = { + '@context': didDocument['@context'], + type: enums_1.ProofTypes.EcdsaSecp256k1RecoverySignature2020, + created: new Date(new Date().getTime() - 100000).toISOString().slice(0, -5) + 'Z', + verificationMethod: verificationMethodId, + proofPurpose: enums_1.VerificationMethodRelationships.assertionMethod, + }; + const normalizedProof = yield _jsonLdNormalize({ doc: proof }); + delete proof['@context']; + const normalizedProofhash = new Uint8Array(Buffer.from(crypto_2.default.createHash('sha256').update(normalizedProof).digest('hex'), 'hex')); + const combinedHash = _concat(normalizedProofhash, normalizedDidDocHash); + const didDocJsonDigest = { + didId: didDocument.id, + didDocDigest: Buffer.from(combinedHash).toString('hex'), + }; + const web3 = new web3_1.default(); + const signature = yield web3.eth.personal.sign(JSON.stringify(didDocJsonDigest, (key, value) => { + if (value === '' || (Array.isArray(value) && value.length === 0)) { + return undefined; + } + return value; + }), account.address, account.privateKey); + delete proof['@context']; + proof['proofValue'] = signature; + return proof; + } +}); +exports.signDid = signDid; +exports.entityApiSecret = '29a393a5d70094e409824359fc5d5.befc6c6f32d622e1c29ca900299a5695251b2407ca7cf6db8e6b2569dc13f937a4b83f4fa78738715d6267d3733e4f139'; // wallet address: hid1rh5h603fv9dneqm422uvl4xk3fc77a4uheleq5 diff --git a/build/src/tests/credential/vc.spec.js b/build/src/tests/credential/vc.spec.js index 3539397..839e0d0 100644 --- a/build/src/tests/credential/vc.spec.js +++ b/build/src/tests/credential/vc.spec.js @@ -36,6 +36,14 @@ let credenStatus; let credentialStatusProof2 = {}; let credentialStatus2 = {}; let credentialStatus; +let holderDidDocument; +let holderSignedDidDoc; +let holdersPrivateKeyMultibase; +let credentialDetail2; +let credentialDetail3; +let issuedCredResult; +let issuedCredResult2; +const credentialTransMessage = []; const entityApiSecretKey = '57ed4af5b3f51428250e76a769ce8.d8f70a64e3d060b377c85eb75b60ae25011ecebb63f28a27f72183e5bcba140222f8628f17a72eee4833a9174f5ae8309'; const credentialBody = { schemaId: '', @@ -46,7 +54,7 @@ const credentialBody = { expirationDate: '', }; const schemaBody = { - name: 'testSchema', + name: 'TestSchema', description: 'This is a test schema generation', author: '', fields: [{ name: 'name', type: 'string', isRequired: false }], @@ -120,6 +128,32 @@ describe('DID Opearations', () => { (0, chai_1.should)().exist(didDocument['service']); }); }); + it('should be able to generate didDocument', function () { + return __awaiter(this, void 0, void 0, function* () { + const kp = yield hypersignDID.generateKeys(); + holdersPrivateKeyMultibase = kp.privateKeyMultibase; + holderDidDocument = yield hypersignDID.generate({ publicKeyMultibase: kp.publicKeyMultibase }); + (0, chai_1.expect)(didDocument).to.be.a('object'); + (0, chai_1.should)().exist(didDocument['@context']); + (0, chai_1.should)().exist(didDocument['id']); + (0, chai_1.should)().exist(didDocument['controller']); + (0, chai_1.should)().exist(didDocument['alsoKnownAs']); + (0, chai_1.should)().exist(didDocument['verificationMethod']); + (0, chai_1.expect)(didDocument['verificationMethod'] && + didDocument['authentication'] && + didDocument['assertionMethod'] && + didDocument['keyAgreement'] && + didDocument['capabilityInvocation'] && + didDocument['capabilityDelegation'] && + didDocument['service']).to.be.a('array'); + (0, chai_1.should)().exist(didDocument['authentication']); + (0, chai_1.should)().exist(didDocument['assertionMethod']); + (0, chai_1.should)().exist(didDocument['keyAgreement']); + (0, chai_1.should)().exist(didDocument['capabilityInvocation']); + (0, chai_1.should)().exist(didDocument['capabilityDelegation']); + (0, chai_1.should)().exist(didDocument['service']); + }); + }); }); describe('#sign() this is to sign didDoc', function () { const controller = { @@ -155,11 +189,41 @@ describe('DID Opearations', () => { (0, chai_1.should)().exist(signedDocument['proof']); }); }); + it('should able to sign did document for holder', function () { + return __awaiter(this, void 0, void 0, function* () { + const params = { + privateKeyMultibase: holdersPrivateKeyMultibase, + challenge: challenge, + domain: domain, + did: '', + didDocument: holderDidDocument, + verificationMethodId: holderDidDocument.verificationMethod[0].id, + controller, + }; + holderSignedDidDoc = yield hypersignDID.sign(params); + (0, chai_1.expect)(signedDocument).to.be.a('object'); + (0, chai_1.should)().exist(signedDocument['@context']); + (0, chai_1.should)().exist(signedDocument['id']); + (0, chai_1.expect)(didDocId).to.be.equal(signedDocument['id']); + (0, chai_1.should)().exist(signedDocument['controller']); + (0, chai_1.should)().exist(signedDocument['alsoKnownAs']); + (0, chai_1.should)().exist(signedDocument['verificationMethod']); + (0, chai_1.should)().exist(signedDocument['authentication']); + (0, chai_1.should)().exist(signedDocument['assertionMethod']); + (0, chai_1.should)().exist(signedDocument['keyAgreement']); + (0, chai_1.should)().exist(signedDocument['capabilityInvocation']); + (0, chai_1.should)().exist(signedDocument['capabilityDelegation']); + (0, chai_1.should)().exist(signedDocument['service']); + (0, chai_1.should)().exist(signedDocument['proof']); + }); + }); }); describe('#register() this is to register did on the blockchain', function () { it('should be able to register didDocument in the blockchain', function () { return __awaiter(this, void 0, void 0, function* () { - const result = yield hypersignDID.register({ didDocument, privateKeyMultibase, verificationMethodId }); + const didDoc = didDocument; + delete didDoc.proof; + const result = yield hypersignDID.register({ didDocument: didDoc, privateKeyMultibase, verificationMethodId }); (0, chai_1.should)().exist(result.transactionHash); (0, chai_1.should)().exist(result.didDocument); }); @@ -204,7 +268,6 @@ describe('Schema Opearations', () => { const registeredSchema = yield hypersignSchema.register({ schema: signedSchema, }); - // console.log(registeredSchema) (0, chai_1.expect)(registeredSchema).to.be.a('object'); (0, chai_1.should)().exist(registeredSchema.transactionHash); }); @@ -215,12 +278,12 @@ describe('Schema Opearations', () => { * Test cases related to credential */ describe('Verifiable Credential Opearations', () => { - describe('#getCredential() method to generate a credential', function () { + describe('#generate() method to generate a credential', function () { it('should not be able to generate new credential for a schema as both subjectDid and subjectDidDocSigned is passed', function () { return __awaiter(this, void 0, void 0, function* () { const tempCredentialBody = Object.assign({}, credentialBody); tempCredentialBody.issuerDid = didDocId; - tempCredentialBody.subjectDid = didDocId; + tempCredentialBody.subjectDid = holderDidDocument.id; tempCredentialBody['subjectDidDocSigned'] = signedDocument; return hypersignVC.generate(tempCredentialBody).catch(function (err) { (0, chai_1.expect)(function () { @@ -270,7 +333,7 @@ describe('Verifiable Credential Opearations', () => { const tempCredentialBody = Object.assign({}, credentialBody); tempCredentialBody.schemaId = schemaId; tempCredentialBody.issuerDid = didDocId; - tempCredentialBody['subjectDid'] = didDocId; + tempCredentialBody['subjectDid'] = holderDidDocument.id; return hypersignVC.generate(tempCredentialBody).catch(function (err) { (0, chai_1.expect)(function () { throw err; @@ -318,74 +381,97 @@ describe('Verifiable Credential Opearations', () => { const expirationDate = new Date('12/11/2027'); const tempCredentialBody = Object.assign({}, credentialBody); tempCredentialBody.schemaId = schemaId; - tempCredentialBody.subjectDid = didDocId; + tempCredentialBody.subjectDid = holderDidDocument.id; tempCredentialBody['expirationDate'] = expirationDate.toString(); tempCredentialBody.issuerDid = didDocId; tempCredentialBody.fields = { name: 'varsha' }; credentialDetail = yield hypersignVC.generate(tempCredentialBody); - // console.log('New Credential --------------------------------'); - // console.log(JSON.stringify(credentialDetail, null, 2)); (0, chai_1.expect)(credentialDetail).to.be.a('object'); (0, chai_1.should)().exist(credentialDetail['@context']); (0, chai_1.should)().exist(credentialDetail['id']); credentialId = credentialDetail.id; (0, chai_1.should)().exist(credentialDetail['type']); - (0, chai_1.should)().exist(credentialDetail['expirationDate']); (0, chai_1.should)().exist(credentialDetail['issuanceDate']); (0, chai_1.should)().exist(credentialDetail['issuer']); (0, chai_1.should)().exist(credentialDetail['credentialSubject']); - (0, chai_1.should)().exist(credentialDetail['credentialSchema']); (0, chai_1.should)().exist(credentialDetail['credentialStatus']); - (0, chai_1.expect)(credentialDetail['credentialStatus'].type).to.be.equal('CredentialStatusList2017'); + (0, chai_1.expect)(credentialDetail['credentialStatus'].type).to.be.equal('HypersignCredentialStatus2023'); }); }); it('should be able to generate new credential even without offlinesigner passed to constructor', function () { return __awaiter(this, void 0, void 0, function* () { - const expirationDate = new Date('12/11/2027'); + const expirationDate = new Date('11/11/2027'); const tempCredentialBody = Object.assign({}, credentialBody); tempCredentialBody.schemaId = schemaId; - tempCredentialBody.subjectDid = didDocId; + tempCredentialBody.subjectDid = holderDidDocument.id; tempCredentialBody['expirationDate'] = expirationDate.toString(); tempCredentialBody.issuerDid = didDocId; tempCredentialBody.fields = { name: 'varsha' }; - const hypersignVC1 = new index_1.HypersignVerifiableCredential(); - const credentialDetail = yield hypersignVC1.generate(tempCredentialBody); + const hypersignVC1 = new index_1.HypersignVerifiableCredential({ + nodeRestEndpoint: config_1.hidNodeEp.rest, + nodeRpcEndpoint: config_1.hidNodeEp.rpc, + namespace: config_1.hidNodeEp.namespace, + }); + credentialDetail2 = yield hypersignVC1.generate(tempCredentialBody); (0, chai_1.expect)(credentialDetail).to.be.a('object'); (0, chai_1.should)().exist(credentialDetail['@context']); (0, chai_1.should)().exist(credentialDetail['id']); (0, chai_1.should)().exist(credentialDetail['type']); - (0, chai_1.should)().exist(credentialDetail['expirationDate']); (0, chai_1.should)().exist(credentialDetail['issuanceDate']); (0, chai_1.should)().exist(credentialDetail['issuer']); (0, chai_1.should)().exist(credentialDetail['credentialSubject']); (0, chai_1.should)().exist(credentialDetail['credentialSchema']); (0, chai_1.should)().exist(credentialDetail['credentialStatus']); - (0, chai_1.expect)(credentialDetail['credentialStatus'].type).to.be.equal('CredentialStatusList2017'); + (0, chai_1.expect)(credentialDetail['credentialStatus'].type).to.be.equal('HypersignCredentialStatus2023'); + }); + }); + it('should be able to generate new credential even without offlinesigner passed to constructor to test bulkRegistration', function () { + return __awaiter(this, void 0, void 0, function* () { + const expirationDate = new Date('11/11/2027'); + const tempCredentialBody = Object.assign({}, credentialBody); + tempCredentialBody.schemaId = schemaId; + tempCredentialBody.subjectDid = holderDidDocument.id; + tempCredentialBody['expirationDate'] = expirationDate.toString(); + tempCredentialBody.issuerDid = didDocId; + tempCredentialBody.fields = { name: 'varsha' }; + const hypersignVC1 = new index_1.HypersignVerifiableCredential({ + nodeRestEndpoint: config_1.hidNodeEp.rest, + nodeRpcEndpoint: config_1.hidNodeEp.rpc, + namespace: config_1.hidNodeEp.namespace, + }); + credentialDetail3 = yield hypersignVC1.generate(tempCredentialBody); + (0, chai_1.expect)(credentialDetail).to.be.a('object'); + (0, chai_1.should)().exist(credentialDetail['@context']); + (0, chai_1.should)().exist(credentialDetail['id']); + (0, chai_1.should)().exist(credentialDetail['type']); + (0, chai_1.should)().exist(credentialDetail['issuanceDate']); + (0, chai_1.should)().exist(credentialDetail['issuer']); + (0, chai_1.should)().exist(credentialDetail['credentialSubject']); + (0, chai_1.should)().exist(credentialDetail['credentialSchema']); + (0, chai_1.should)().exist(credentialDetail['credentialStatus']); + (0, chai_1.expect)(credentialDetail['credentialStatus'].type).to.be.equal('HypersignCredentialStatus2023'); }); }); it('should be able to generate new credential for a schema with signed subject DID doc', function () { return __awaiter(this, void 0, void 0, function* () { - const expirationDate = new Date('12/11/2027'); + const expirationDate = new Date('10/11/2027'); const tempCredentialBody = Object.assign({}, credentialBody); tempCredentialBody.schemaId = schemaId; tempCredentialBody['subjectDidDocSigned'] = signedDocument; tempCredentialBody['expirationDate'] = expirationDate.toString(); tempCredentialBody.issuerDid = didDocId; tempCredentialBody.fields = { name: 'varsha' }; - // console.log(tempCredentialBody) const credentialDetail = yield hypersignVC.generate(tempCredentialBody); - // console.log(JSON.stringify(credentialDetail)); (0, chai_1.expect)(credentialDetail).to.be.a('object'); (0, chai_1.should)().exist(credentialDetail['@context']); (0, chai_1.should)().exist(credentialDetail['id']); (0, chai_1.should)().exist(credentialDetail['type']); - (0, chai_1.should)().exist(credentialDetail['expirationDate']); (0, chai_1.should)().exist(credentialDetail['issuanceDate']); (0, chai_1.should)().exist(credentialDetail['issuer']); (0, chai_1.should)().exist(credentialDetail['credentialSubject']); (0, chai_1.should)().exist(credentialDetail['credentialSchema']); (0, chai_1.should)().exist(credentialDetail['credentialStatus']); - (0, chai_1.expect)(credentialDetail['credentialStatus'].type).to.be.equal('CredentialStatusList2017'); + (0, chai_1.expect)(credentialDetail['credentialStatus'].type).to.be.equal('HypersignCredentialStatus2023'); }); }); }); @@ -453,20 +539,16 @@ describe('Verifiable Credential Opearations', () => { tempIssueCredentialBody.issuerDid = didDocId; tempIssueCredentialBody.verificationMethodId = verificationMethodId; tempIssueCredentialBody.privateKeyMultibase = privateKeyMultibase; - // console.log(JSON.stringify(tempIssueCredentialBody, null, 2)); const issuedCredResult = yield hypersignVC.issue(tempIssueCredentialBody); const { signedCredential, credentialStatus, credentialStatusProof, credentialStatusRegistrationResult } = issuedCredResult; signedVC = signedCredential; credenStatus = credentialStatus; credentialId = signedVC.id; - // console.log('Signed Credential --------------------------------'); - // console.log(JSON.stringify(signedVC, null, 2)); credentialStatusId = signedCredential['credentialStatus'].id; (0, chai_1.expect)(signedCredential).to.be.a('object'); (0, chai_1.should)().exist(signedCredential['@context']); (0, chai_1.should)().exist(signedCredential['id']); (0, chai_1.should)().exist(signedCredential['type']); - (0, chai_1.should)().exist(signedCredential['expirationDate']); (0, chai_1.should)().exist(signedCredential['issuanceDate']); (0, chai_1.should)().exist(signedCredential['issuer']); (0, chai_1.should)().exist(signedCredential['credentialSubject']); @@ -475,15 +557,14 @@ describe('Verifiable Credential Opearations', () => { (0, chai_1.should)().exist(signedCredential['proof']); (0, chai_1.expect)(signedCredential['id']).to.be.equal(tempIssueCredentialBody.credential.id); (0, chai_1.expect)(credentialStatus).to.be.a('object'); - (0, chai_1.should)().exist(credentialStatus['claim']); + (0, chai_1.should)().exist(credentialStatus['@context']); + (0, chai_1.should)().exist(credentialStatus['id']); (0, chai_1.should)().exist(credentialStatus['issuer']); (0, chai_1.should)().exist(credentialStatus['issuanceDate']); - (0, chai_1.should)().exist(credentialStatus['expirationDate']); - (0, chai_1.should)().exist(credentialStatus['credentialHash']); + (0, chai_1.should)().exist(credentialStatus['credentialMerkleRootHash']); (0, chai_1.expect)(credentialStatusProof).to.be.a('object'); (0, chai_1.should)().exist(credentialStatusProof['type']); (0, chai_1.should)().exist(credentialStatusProof['created']); - (0, chai_1.should)().exist(credentialStatusProof['updated']); (0, chai_1.should)().exist(credentialStatusProof['verificationMethod']); (0, chai_1.should)().exist(credentialStatusProof['proofPurpose']); (0, chai_1.should)().exist(credentialStatusProof['proofValue']); @@ -499,7 +580,7 @@ describe('Verifiable Credential Opearations', () => { const expirationDate = new Date('12/11/2027'); const tempCredentialBody = Object.assign({}, credentialBody); tempCredentialBody.schemaId = schemaId; - tempCredentialBody['subjectDidDocSigned'] = signedDocument; + tempCredentialBody['subjectDidDocSigned'] = holderSignedDidDoc; tempCredentialBody['expirationDate'] = expirationDate.toString(); tempCredentialBody.issuerDid = didDocId; tempCredentialBody.fields = { name: 'varsha' }; @@ -514,12 +595,40 @@ describe('Verifiable Credential Opearations', () => { const { signedCredential, credentialStatus, credentialStatusProof, credentialStatusRegistrationResult } = issuedCredResult; credentialStatus2 = credentialStatus; credentialStatusProof2 = credentialStatusProof; - // console.log({ - // signedCredential, - // credentialStatusRegistrationResult, - // credentialStatus2, - // credentialStatusProof2, - // }); + (0, chai_1.expect)(signedCredential).to.be.a('object'); + (0, chai_1.expect)(credentialStatus).to.be.a('object'); + (0, chai_1.expect)(credentialStatusProof).to.be.a('object'); + (0, chai_1.should)().not.exist(credentialStatusRegistrationResult); + }); + }); + it('should be able to issue credential without having the credential status registered on chain to test bulkRegistration', function () { + return __awaiter(this, void 0, void 0, function* () { + const tempIssueCredentialBody = Object.assign({}, issueCredentialBody); + tempIssueCredentialBody.credential = credentialDetail2; + tempIssueCredentialBody.issuerDid = didDocId; + tempIssueCredentialBody.verificationMethodId = verificationMethodId; + tempIssueCredentialBody.privateKeyMultibase = privateKeyMultibase; + tempIssueCredentialBody.registerCredential = false; + issuedCredResult = yield hypersignVC.issue(tempIssueCredentialBody); + const { signedCredential, credentialStatus, credentialStatusProof, credentialStatusRegistrationResult } = issuedCredResult; + (0, chai_1.expect)(signedCredential).to.be.a('object'); + (0, chai_1.expect)(credentialStatus).to.be.a('object'); + (0, chai_1.expect)(credentialStatusProof).to.be.a('object'); + (0, chai_1.should)().not.exist(credentialStatusRegistrationResult); + }); + }); + it('should be able to issue credential without having the credential status registered on chain to test bulkRegistration', function () { + return __awaiter(this, void 0, void 0, function* () { + const tempIssueCredentialBody = Object.assign({}, issueCredentialBody); + tempIssueCredentialBody.credential = credentialDetail3; + tempIssueCredentialBody.issuerDid = didDocId; + tempIssueCredentialBody.verificationMethodId = verificationMethodId; + tempIssueCredentialBody.privateKeyMultibase = privateKeyMultibase; + tempIssueCredentialBody.registerCredential = false; + issuedCredResult2 = yield hypersignVC.issue(tempIssueCredentialBody); + const { signedCredential, credentialStatus, credentialStatusProof, credentialStatusRegistrationResult } = issuedCredResult; + // credentialStatus2 = credentialStatus; + // credentialStatusProof2 = credentialStatusProof; (0, chai_1.expect)(signedCredential).to.be.a('object'); (0, chai_1.expect)(credentialStatus).to.be.a('object'); (0, chai_1.expect)(credentialStatusProof).to.be.a('object'); @@ -535,11 +644,7 @@ describe('Verifiable Credential Opearations', () => { issuerDid: didDocId, verificationMethodId, }; - // console.log('Signed vc --------------------------------'); - // console.log(JSON.stringify(params.credential, null, 2)); const verificationResult = yield hypersignVC.verify(params); - // console.log('Credential Verifification result --------------------------------'); - // console.log(JSON.stringify(verificationResult, null, 2)); (0, chai_1.expect)(verificationResult).to.be.a('object'); (0, chai_1.should)().exist(verificationResult.verified); (0, chai_1.expect)(verificationResult.verified).to.be.equal(true); @@ -651,9 +756,7 @@ describe('Verifiable Credential Status Opearations', () => { }); it('should be able to check credential status', function () { return __awaiter(this, void 0, void 0, function* () { - // console.log('Credential ID ' + credentialId); const credentialStatus = yield hypersignVC.checkCredentialStatus({ credentialId: credentialId }); - // console.log(JSON.stringify(credentialStatus, null, 2)); (0, chai_1.expect)(credentialStatus).to.be.a('object'); (0, chai_1.should)().exist(credentialStatus.verified); (0, chai_1.expect)(credentialStatus.verified).to.be.equal(true); @@ -673,12 +776,13 @@ describe('Verifiable Credential Status Opearations', () => { it('should be able to resolve credential', function () { return __awaiter(this, void 0, void 0, function* () { credentialStatus = yield hypersignVC.resolveCredentialStatus({ credentialId }); - // console.log(JSON.stringify(credentialStatus, null, 2)); (0, chai_1.expect)(credentialStatus).to.be.a('object'); + (0, chai_1.should)().exist(credentialStatus.revoked); + (0, chai_1.should)().exist(credentialStatus.suspended); + (0, chai_1.should)().exist(credentialStatus.remarks); (0, chai_1.should)().exist(credentialStatus.issuer); (0, chai_1.should)().exist(credentialStatus.issuanceDate); - (0, chai_1.should)().exist(credentialStatus.expirationDate); - (0, chai_1.should)().exist(credentialStatus.credentialHash); + (0, chai_1.should)().exist(credentialStatus.credentialMerkleRootHash); (0, chai_1.should)().exist(credentialStatus.proof); }); }); @@ -707,8 +811,8 @@ describe('Verifiable Credential Status Opearations', () => { // const tempParams = { ...params }; // tempParams.verificationMethodId = verificationMethodId; // tempParams.privateKeyMultibase = privateKeyMultibase; - // tempParams.issuerDid = credentialStatus; - // tempParams.credentialStatus = {} as ICredentialStatus; + // tempParams.issuerDid = didDocId; + // tempParams.credentialStatus = {} as ICredentialStatus; // return hypersignVC.updateCredentialStatus(tempParams).catch(function (err) { // expect(function () { // throw err; @@ -757,7 +861,55 @@ describe('Verifiable Credential Status Opearations', () => { }); }); }); + it('should not be able to update credential as status passed is invalid', function () { + return __awaiter(this, void 0, void 0, function* () { + const tempParams = Object.assign({}, params); + tempParams.verificationMethodId = verificationMethodId; + tempParams.credentialStatus = credenStatus; + tempParams.privateKeyMultibase = privateKeyMultibase; + tempParams.issuerDid = didDocId; + tempParams.status = 'svgsdvjif'; + return hypersignVC.updateCredentialStatus(tempParams).catch(function (err) { + (0, chai_1.expect)(function () { + throw err; + }).to.throw(Error, `HID-SSI-SDK:: Error: params.status is invalid`); + }); + }); + }); it('should be able to change credential status to suspended', function () { + return __awaiter(this, void 0, void 0, function* () { + const credentialStatus = yield hypersignVC.resolveCredentialStatus({ credentialId }); + const tempParams = Object.assign({}, params); + tempParams['credentialStatus'] = credentialStatus; + tempParams['verificationMethodId'] = verificationMethodId; + tempParams.issuerDid = didDocId; + tempParams.privateKeyMultibase = privateKeyMultibase; + tempParams['status'] = 'SUSPENDED'; + tempParams['statusReason'] = 'Suspending this credential for some time'; + const updatedCredResult = yield hypersignVC.updateCredentialStatus(tempParams); + (0, chai_1.expect)(updatedCredResult).to.be.a('object'); + (0, chai_1.expect)(updatedCredResult.code).to.be.equal(0); + (0, chai_1.expect)(updatedCredResult.transactionHash).to.be.a('string'); + }); + }); + it('should not be able to suspend a suspended credential status', function () { + return __awaiter(this, void 0, void 0, function* () { + const credentialStatus = yield hypersignVC.resolveCredentialStatus({ credentialId }); + const tempParams = Object.assign({}, params); + tempParams['credentialStatus'] = credentialStatus; + tempParams['verificationMethodId'] = verificationMethodId; + tempParams['status'] = 'SUSPENDED'; + tempParams.privateKeyMultibase = privateKeyMultibase; + tempParams.issuerDid = didDocId; + tempParams['statusReason'] = 'Suspending this credential for some time'; + return hypersignVC.updateCredentialStatus(tempParams).catch(function (err) { + (0, chai_1.expect)(function () { + throw err; + }).to.throw(Error, "failed to execute message; message index: 0: incoming Credential Status Document does not have any changes: invalid Credential Status"); + }); + }); + }); + it('should be able to change credential status to Live', function () { return __awaiter(this, void 0, void 0, function* () { const credentialStatus = yield hypersignVC.resolveCredentialStatus({ credentialId }); const params = { @@ -765,16 +917,15 @@ describe('Verifiable Credential Status Opearations', () => { issuerDid: didDocId, verificationMethodId, privateKeyMultibase, - status: 'SUSPENDED', - statusReason: 'Suspending this credential for some time', + status: 'LIVE', + statusReason: 'Setting the status to LIVE', }; const updatedCredResult = yield hypersignVC.updateCredentialStatus(params); - // console.log(updatedCredResult); (0, chai_1.expect)(updatedCredResult).to.be.a('object'); (0, chai_1.expect)(updatedCredResult.code).to.be.equal(0); }); }); - it('should be able to change credential status to Live', function () { + it('should be able to change credential status to Revoked', function () { return __awaiter(this, void 0, void 0, function* () { const credentialStatus = yield hypersignVC.resolveCredentialStatus({ credentialId }); const params = { @@ -782,14 +933,47 @@ describe('Verifiable Credential Status Opearations', () => { issuerDid: didDocId, verificationMethodId, privateKeyMultibase, - status: 'LIVE', - statusReason: 'Setting the status to LIVE', + status: 'REVOKED', + statusReason: 'Revoking the credential', }; const updatedCredResult = yield hypersignVC.updateCredentialStatus(params); (0, chai_1.expect)(updatedCredResult).to.be.a('object'); (0, chai_1.expect)(updatedCredResult.code).to.be.equal(0); }); }); + it('should not be able to revoke a revoked credential status', function () { + return __awaiter(this, void 0, void 0, function* () { + const credentialStatus = yield hypersignVC.resolveCredentialStatus({ credentialId }); + const params = { + credentialStatus, + issuerDid: didDocId, + verificationMethodId, + privateKeyMultibase, + status: 'REVOKED', + statusReason: 'Revoking the credential', + }; + return hypersignVC.updateCredentialStatus(params).catch(function (err) { + (0, chai_1.expect)(function () { + throw err; + }).to.throw(Error, 'failed to execute message; message index: 0: incoming Credential Status Document does not have any changes: invalid Credential Status'); + }); + }); + }); + it('should not be able to change the status of credential as it is revoked', function () { + return __awaiter(this, void 0, void 0, function* () { + const params = { + credentialStatus, + issuerDid: didDocId, + verificationMethodId, + privateKeyMultibase, + status: 'SUSPENDED', + statusReason: 'Suspending this credential for some time', + }; + return hypersignVC.updateCredentialStatus(params).catch(function (err) { + (0, chai_1.expect)(err.message).to.include(`failed to execute message; message index: 0: credential status ${credentialId} could not be updated since it is revoked: invalid Credential Status`); + }); + }); + }); }); describe('#registerCredentialStatus() method to register credential on blockchain', function () { it('should not be able to register credential as credentialStatusProof is not passed', function () { @@ -822,5 +1006,78 @@ describe('Verifiable Credential Status Opearations', () => { (0, chai_1.should)().exist(registerCredDetail.transactionHash); }); }); + it('should not be able to register credential on blockchain as stutus already registerd on chain', function () { + return __awaiter(this, void 0, void 0, function* () { + return hypersignVC.registerCredentialStatus({ + credentialStatus: credentialStatus2, + credentialStatusProof: credentialStatusProof2, + }).catch(function (err) { + (0, chai_1.expect)(function () { + throw err; + }).to.throw('failed to execute message; message index: 0: credential status document already exists'); + }); + }); + }); + }); + describe('#generateRegisterCredentialStatusTxnMessage() method to generate transaction message for credential2', function () { + it('should not be able to generatecredential status TxnMessage as credentialStatus is not passed', function () { + return __awaiter(this, void 0, void 0, function* () { + const credentialStatus = null; + const credentialStatusProof = issuedCredResult.credentialStatusProof; + return hypersignVC.generateRegisterCredentialStatusTxnMessage(credentialStatus, credentialStatusProof).catch(function (err) { + (0, chai_1.expect)(function () { + throw err; + }).to.throw(Error, 'HID-SSI-SDK:: Error: credentialStatus and proof are required to register credential status'); + }); + }); + }); + it('should not be able to generatecredential status TxnMessage as credentialStatusProof is not passed', function () { + return __awaiter(this, void 0, void 0, function* () { + const credentialStatus = issuedCredResult.credentialStatus; + const credentialStatusProof = null; + return hypersignVC.generateRegisterCredentialStatusTxnMessage(credentialStatus, credentialStatusProof).catch(function (err) { + (0, chai_1.expect)(function () { + throw err; + }).to.throw(Error, 'HID-SSI-SDK:: Error: credentialStatus and proof are required to register credential status'); + }); + }); + }); + it('should be able to generate credential status TxnMessage', function () { + return __awaiter(this, void 0, void 0, function* () { + const credentialStatus = issuedCredResult.credentialStatus; + const credentialStatusProof = issuedCredResult.credentialStatusProof; + const credentialStatus2 = issuedCredResult2.credentialStatus; + const credentialStatusProof2 = issuedCredResult2.credentialStatusProof; + const txnMessage1 = yield hypersignVC.generateRegisterCredentialStatusTxnMessage(credentialStatus, credentialStatusProof); + credentialTransMessage.push(txnMessage1); + const txnMessage2 = yield hypersignVC.generateRegisterCredentialStatusTxnMessage(credentialStatus2, credentialStatusProof2); + credentialTransMessage.push(txnMessage2); + (0, chai_1.expect)(txnMessage1).to.be.a('object'); + (0, chai_1.should)().exist(txnMessage1.typeUrl); + (0, chai_1.should)().exist(txnMessage1.value); + (0, chai_1.should)().exist(txnMessage1.value.credentialStatusDocument); + (0, chai_1.should)().exist(txnMessage1.value.credentialStatusProof); + (0, chai_1.should)().exist(txnMessage1.value.txAuthor); + }); + }); + }); + describe('#registerCredentialStatusTxnBulk() method to register credential on blockchain', function () { + it('should not be able to register multiple credential as txnMessage is not passed', function () { + return __awaiter(this, void 0, void 0, function* () { + const txnMessage = []; + return hypersignVC.registerCredentialStatusTxnBulk(txnMessage).catch(function (err) { + (0, chai_1.expect)(function () { + throw err; + }).to.throw(Error, 'HID-SSI-SDK:: Error: txnMessage is required to register credential status'); + }); + }); + }); + it('should be able to register credential on blockchain in a bulk', function () { + return __awaiter(this, void 0, void 0, function* () { + const registerCredDetail = yield hypersignVC.registerCredentialStatusTxnBulk(credentialTransMessage); + (0, chai_1.expect)(registerCredDetail).to.be.a('object'); + (0, chai_1.should)().exist(registerCredDetail.transactionHash); + }); + }); }); }); diff --git a/build/src/tests/credential/vcByEntityApiKey.spec.js b/build/src/tests/credential/vcByEntityApiKey.spec.js index cc7329c..7540529 100644 --- a/build/src/tests/credential/vcByEntityApiKey.spec.js +++ b/build/src/tests/credential/vcByEntityApiKey.spec.js @@ -12,6 +12,7 @@ Object.defineProperty(exports, "__esModule", { value: true }); const chai_1 = require("chai"); const index_1 = require("../../index"); const config_1 = require("../config"); +// import { CredentialProof, CredentialStatus } from '../../../libs/generated/ssi/credential'; let didDocument; let didDocId; let privateKeyMultibase; @@ -38,7 +39,6 @@ const schemaBody = { fields: [{ name: 'name', type: 'string', isRequired: false }], additionalProperties: false, }; -const entityApiSecret = "69b91e007904228e3313e586ba695.bc7705956989e43bbd7060e845c2763a381cbc80f935ac848119b8c2d7d00616346eeb74efe22a0ff140506a0c6157ef6"; beforeEach(function () { return __awaiter(this, void 0, void 0, function* () { offlineSigner = yield (0, config_1.createWallet)(config_1.mnemonic); @@ -264,7 +264,7 @@ describe('Verifiable credential operation', function () { describe('#registerCredentialStatus() method to register credential status on chain', () => { it('Should be able to register credential using entityApiSecretKey', () => __awaiter(this, void 0, void 0, function* () { const hypersignVC = new index_1.HypersignVerifiableCredential({ - entityApiSecretKey: entityApiSecret, + entityApiSecretKey: config_1.entityApiSecret, nodeRestEndpoint: config_1.hidNodeEp.rest, nodeRpcEndpoint: config_1.hidNodeEp.rpc, namespace: config_1.hidNodeEp.namespace, diff --git a/build/src/tests/did/did.spec.js b/build/src/tests/did/did.spec.js index dbadef4..5a46789 100644 --- a/build/src/tests/did/did.spec.js +++ b/build/src/tests/did/did.spec.js @@ -11,8 +11,8 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge Object.defineProperty(exports, "__esModule", { value: true }); const chai_1 = require("chai"); const index_1 = require("../../index"); -const IDID_1 = require("../../did/IDID"); const config_1 = require("../config"); +const enums_1 = require("../../../libs/generated/ssi/client/enums"); let privateKeyMultibase; let publicKeyMultibase; let verificationMethodId; @@ -23,6 +23,7 @@ let versionId; let hypersignDID; let transactionHash; let signedDocument; +let signedDocumentAssertion; const challenge = '1231231231'; const domain = 'www.adbv.com'; let hypersignSSISDK; @@ -269,7 +270,7 @@ describe('DID Test scenarios', () => { it('should not be able to add verificationMethod as params.did is passed but yet not registerd', () => __awaiter(this, void 0, void 0, function* () { const params = { did: 'did:hid:testnet:z8wo3LVRR4JkEguESX6hf4EBc234refrdan5xVD49quCPV7fBHYdY', - type: IDID_1.IKeyType.Ed25519VerificationKey2020, + type: enums_1.VerificationMethodTypes.Ed25519VerificationKey2020, id: 'did:hid:testnet:z8wo3LVRR4JkEguESX6hf4EBc234refrdan5xVD49quCPV7fBHYdY#key-1', publicKeyMultibase: '23fer44374u3rmhvf47ri35ty', }; @@ -357,42 +358,44 @@ describe('DID Test scenarios', () => { }).to.throw(Error, `HID-SSI-SDK:: Error: verificationMethod ${params.id} already exists`); }); })); - it('should be able to add verification method of type X25519KeyAgreementKey2020 in didDocument', () => __awaiter(this, void 0, void 0, function* () { - const params = { - didDocument: didDocument, - type: 'X25519KeyAgreementKey2020', - publicKeyMultibase: '23fer44374u3rmhvf47ri35ty', - }; - const didDoc = JSON.parse(JSON.stringify(didDocument)); - const updatedDidDoc = yield hypersignDID.addVerificationMethod(Object.assign({}, params)); - (0, chai_1.expect)(updatedDidDoc).to.be.a('object'); - (0, chai_1.should)().exist(updatedDidDoc['context']); - (0, chai_1.should)().exist(updatedDidDoc['id']); - (0, chai_1.should)().exist(updatedDidDoc['controller']); - (0, chai_1.should)().exist(updatedDidDoc['alsoKnownAs']); - (0, chai_1.should)().exist(updatedDidDoc['verificationMethod']); - (0, chai_1.expect)(updatedDidDoc['verificationMethod'] && - updatedDidDoc['authentication'] && - updatedDidDoc['assertionMethod'] && - updatedDidDoc['keyAgreement'] && - updatedDidDoc['capabilityInvocation'] && - updatedDidDoc['capabilityDelegation'] && - updatedDidDoc['service']).to.be.a('array'); - (0, chai_1.should)().exist(updatedDidDoc['authentication']); - (0, chai_1.should)().exist(updatedDidDoc['assertionMethod']); - (0, chai_1.expect)(updatedDidDoc.verificationMethod.length).to.be.greaterThan(didDoc.verificationMethod.length); - })); + // it('should be able to add verification method of type X25519KeyAgreementKey2020 in didDocument', async () => { + // const params = { + // didDocument: didDocument, + // type: 'X25519KeyAgreementKey2020', + // publicKeyMultibase: '23fer44374u3rmhvf47ri35ty', + // }; + // const didDoc = JSON.parse(JSON.stringify(didDocument)); + // const updatedDidDoc = await hypersignDID.addVerificationMethod({ ...params }); + // expect(updatedDidDoc).to.be.a('object'); + // should().exist(updatedDidDoc['@context']); + // should().exist(updatedDidDoc['id']); + // should().exist(updatedDidDoc['controller']); + // should().exist(updatedDidDoc['alsoKnownAs']); + // should().exist(updatedDidDoc['verificationMethod']); + // expect( + // updatedDidDoc['verificationMethod'] && + // updatedDidDoc['authentication'] && + // updatedDidDoc['assertionMethod'] && + // updatedDidDoc['keyAgreement'] && + // updatedDidDoc['capabilityInvocation'] && + // updatedDidDoc['capabilityDelegation'] && + // updatedDidDoc['service'] + // ).to.be.a('array'); + // should().exist(updatedDidDoc['authentication']); + // should().exist(updatedDidDoc['assertionMethod']); + // expect(updatedDidDoc.verificationMethod.length).to.be.greaterThan(didDoc.verificationMethod.length); + // }); it('should be able to add verification method in didDocument without offlinesigner', () => __awaiter(this, void 0, void 0, function* () { const hypersignDid = new index_1.HypersignDID({ namespace: 'testnet' }); const didDoc = JSON.parse(JSON.stringify(didDocument)); const params = { didDocument: didDoc, - type: IDID_1.IKeyType.X25519KeyAgreementKey2020, + type: enums_1.VerificationMethodTypes.X25519KeyAgreementKey2020, publicKeyMultibase: '23fer44374u3rmhvf47ri35ty', }; const testDidDoc = yield hypersignDid.addVerificationMethod(params); (0, chai_1.expect)(testDidDoc).to.be.a('object'); - (0, chai_1.should)().exist(testDidDoc['context']); + (0, chai_1.should)().exist(testDidDoc['@context']); (0, chai_1.should)().exist(testDidDoc['id']); (0, chai_1.should)().exist(testDidDoc['controller']); (0, chai_1.should)().exist(testDidDoc['alsoKnownAs']); @@ -417,7 +420,7 @@ describe('DID Test scenarios', () => { const didDoc = JSON.parse(JSON.stringify(didDocToReg)); DIdDOcWithMultiplVM = yield hypersignDID.addVerificationMethod(params); (0, chai_1.expect)(DIdDOcWithMultiplVM).to.be.a('object'); - (0, chai_1.should)().exist(DIdDOcWithMultiplVM['context']); + (0, chai_1.should)().exist(DIdDOcWithMultiplVM['@context']); (0, chai_1.should)().exist(DIdDOcWithMultiplVM['id']); (0, chai_1.should)().exist(DIdDOcWithMultiplVM['controller']); (0, chai_1.should)().exist(DIdDOcWithMultiplVM['alsoKnownAs']); @@ -434,6 +437,59 @@ describe('DID Test scenarios', () => { (0, chai_1.expect)(DIdDOcWithMultiplVM.verificationMethod.length).to.be.greaterThan(didDoc.verificationMethod.length); })); }); + describe('#createSignInfos() to generated sign array', function () { + it('should not able to create sign of did document and throw error as didDocument is not passed or it is empty', function () { + return hypersignDID + .createSignInfos({ didDocument: {}, privateKeyMultibase, verificationMethodId }) + .catch(function (err) { + (0, chai_1.expect)(function () { + throw err; + }).to.throw(Error, 'HID-SSI-SDK:: Error: params.didDocument is required to create signature of a did'); + }); + }); + it('should not be able to create sign of did document as privateKeyMultibase is null or empty', function () { + return hypersignDID + .createSignInfos({ didDocument, privateKeyMultibase: '', verificationMethodId }) + .catch(function (err) { + (0, chai_1.expect)(function () { + throw err; + }).to.throw(Error, 'HID-SSI-SDK:: Error: params.privateKeyMultibase is required to create signature of a did'); + }); + }); + it('should not be able to create sign of did document as verificationMethodId is null or empty', function () { + return hypersignDID + .createSignInfos({ didDocument, privateKeyMultibase, verificationMethodId: '' }) + .catch(function (err) { + (0, chai_1.expect)(function () { + throw err; + }).to.throw(Error, 'HID-SSI-SDK:: Error: params.verificationMethodId is required to create signature of a did'); + }); + }); + it('should not be able to create sign of did document as didDocument is not in Ld-json format', function () { + const didDoc = JSON.parse(JSON.stringify(didDocument)); + didDoc.context = didDoc['@context']; + delete didDoc['@context']; + return hypersignDID + .createSignInfos({ didDocument: didDoc, privateKeyMultibase, verificationMethodId: verificationMethodId }) + .catch(function (err) { + (0, chai_1.expect)(function () { + throw err; + }).to.throw(Error, 'HID-SSI-SDK:: Error: didDocument is not in Ld-json format'); + }); + }); + it('should be able to generate signature array', () => __awaiter(this, void 0, void 0, function* () { + const tempDidDoc = JSON.parse(JSON.stringify(didDocument)); + let signInfo = yield hypersignDID.createSignInfos({ didDocument: tempDidDoc, privateKeyMultibase, verificationMethodId }); + (0, chai_1.expect)(signInfo).to.be.a('array'); + signInfo = signInfo[0]; + (0, chai_1.should)().exist(signInfo.signature); + (0, chai_1.expect)(signInfo.signature).to.be.a("string"); + (0, chai_1.should)().exist(signInfo.verification_method_id); + (0, chai_1.expect)(signInfo.verification_method_id).to.be.a("string"); + (0, chai_1.should)().exist(signInfo.created); + (0, chai_1.expect)(signInfo.created).to.be.a("string"); + })); + }); describe('#register() this is to register did on the blockchain', function () { it('should not able to register did document and throw error as didDocument is not passed or it is empty', function () { return hypersignDID @@ -462,6 +518,19 @@ describe('DID Test scenarios', () => { }).to.throw(Error, 'HID-SSI-SDK:: Error: params.verificationMethodId is required to register a did'); }); }); + it('should not be able to register did document as didDocument is not in Ld-json fromat', function () { + const didDoc = JSON.parse(JSON.stringify(didDocument)); + // const context = didDoc['@context'] + didDoc.context = didDoc['@context']; + delete didDoc['@context']; + return hypersignDID + .register({ didDocument: didDoc, privateKeyMultibase, verificationMethodId: verificationMethodId }) + .catch(function (err) { + (0, chai_1.expect)(function () { + throw err; + }).to.throw(Error, 'HID-SSI-SDK:: Error: didDocument is not in Ld-json format'); + }); + }); it('should not be able to register a did document as neither privateKeyMultibase nor verificationMethodId is passed and signData passed is empty array', () => __awaiter(this, void 0, void 0, function* () { return hypersignDID.register({ didDocument, signData: [] }).catch(function (err) { (0, chai_1.expect)(function () { @@ -537,13 +606,12 @@ describe('DID Test scenarios', () => { // await hypersign.init(); // return hypersign.register({ didDocument, privateKeyMultibase, verificationMethodId }) // .catch(function (err) { - // console.log(err); // expect(function () { // throw err; // }).to.throw(Error, "HID-SSI-SDK:: Error: DIDRpc class is not initialise with offlinesigner"); // }); // }); - it('should be able to register didDocument in the blockchain with two vm one is of type Ed25519VerificationKey2020 and other is of type X25519KeyAgreementKey2020 and register method is called without signData field', function () { + it('should be able to register didDocument without signData field in the blockchain', function () { return __awaiter(this, void 0, void 0, function* () { const result = yield hypersignDID.register({ didDocument, @@ -563,6 +631,20 @@ describe('DID Test scenarios', () => { (0, chai_1.should)().exist(result.transactionHash); }); }); + it('should not be able to register didDocument as didDocument is already registered', function () { + return __awaiter(this, void 0, void 0, function* () { + return yield hypersignDID.register({ + didDocument, + privateKeyMultibase, + verificationMethodId, + }) + .catch(function (err) { + (0, chai_1.expect)(function () { + throw err; + }).to.throw(Error, `failed to execute message; message index: 0: ${didDocId}: didDoc already exists`); + }); + }); + }); it('should be able to register a did Doc of type Ed25519VerificationKey2020 with multiple verification method', () => __awaiter(this, void 0, void 0, function* () { const registerdDidDoc = yield hypersignDID.register({ didDocument: DIdDOcWithMultiplVM, @@ -633,18 +715,31 @@ describe('DID Test scenarios', () => { }); it('should not be able to update did document as versionId passed is incorrect', function () { const updateBody = { didDocument, privateKeyMultibase, verificationMethodId, versionId: '1.0.1' }; - didDocument['alsoKnownAs'].push('Random Data'); + const didDoc = JSON.parse(JSON.stringify(didDocument)); + updateBody['didDocument'] = didDoc; + updateBody['didDocument']['alsoKnownAs'].push('Random Data'); return hypersignDID.update(updateBody).catch(function (err) { (0, chai_1.expect)(function () { throw err; - }).to.throw(Error, `Query failed with (6): rpc error: code = Unknown desc = failed to execute message; message index: 0: Expected ${didDocId} with version ${versionId}. Got version ${updateBody.versionId}: unexpected DID version`); + }).to.throw(Error, `failed to execute message; message index: 0: Expected ${didDocId} with version ${versionId}. Got version ${updateBody.versionId}: unexpected DID version`); + }); + }); + it('should not be able to update did document as there is no change in didDoc', function () { + const updateBody = { didDocument, privateKeyMultibase, verificationMethodId, versionId }; + const didDoc = JSON.parse(JSON.stringify(didDocument)); + updateBody['didDocument'] = didDoc; + return hypersignDID.update(updateBody).catch(function (err) { + (0, chai_1.expect)(function () { + throw err; + }).to.throw(Error, `failed to execute message; message index: 0: incoming DID Document does not have any changes: didDoc is invalid`); }); }); it('should be able to update did document', function () { return __awaiter(this, void 0, void 0, function* () { - didDocument['alsoKnownAs'].push('Some DATA'); + const didDoc = JSON.parse(JSON.stringify(didDocument)); + didDoc['alsoKnownAs'].push('Some DATA'); const result = yield hypersignDID.update({ - didDocument, + didDocument: didDoc, privateKeyMultibase, verificationMethodId, versionId, @@ -663,7 +758,6 @@ describe('DID Test scenarios', () => { (0, chai_1.expect)(result).to.be.a('object'); (0, chai_1.expect)(result.didDocument.id).to.be.equal(didDocId); (0, chai_1.expect)(result.didDocumentMetadata).to.be.a('object'); - (0, chai_1.expect)(result.didDocument.verificationMethod[0].publicKeyMultibase).to.be.not.equal(publicKeyMultibase); versionId = result.didDocumentMetadata.versionId; }); }); @@ -693,7 +787,6 @@ describe('DID Test scenarios', () => { (0, chai_1.expect)(result).to.be.a('object'); (0, chai_1.expect)(result.didDocument.id).to.be.equal(didDocId); (0, chai_1.expect)(result.didDocumentMetadata).to.be.a('object'); - (0, chai_1.expect)(result.didDocument.verificationMethod[0].publicKeyMultibase).to.be.equal(publicKeyMultibase); }); }); }); @@ -725,18 +818,21 @@ describe('DID Test scenarios', () => { }).to.throw(Error, 'HID-SSI-SDK:: Error: params.versionId is required to deactivate a did'); }); }); - it('should not be able to deactivate did document as versionId pased is incorrect', function () { - const deactivateBody = { didDocument, privateKeyMultibase, verificationMethodId, versionId: '1.0.1' }; + it('should not be able to deactivate did document as versionId passed is incorrect', function () { + const didDoc = JSON.parse(JSON.stringify(didDocument)); + const deactivateBody = { didDocument: didDoc, privateKeyMultibase, verificationMethodId, versionId: '1.0.1' }; return hypersignDID.deactivate(deactivateBody).catch(function (err) { (0, chai_1.expect)(function () { throw err; - }).to.throw(Error, `Query failed with (6): rpc error: code = Unknown desc = failed to execute message; message index: 0: Expected ${didDocId} with version ${versionId}. Got version ${deactivateBody.versionId}: unexpected DID version`); + }).to.throw(Error, `failed to execute message; message index: 0: Expected ${didDocId} with version ${versionId}. Got version ${deactivateBody.versionId}: unexpected DID version`); }); }); + // add test case should not be able to deacivate a deactivated did it('should be able to deactivate did document', function () { return __awaiter(this, void 0, void 0, function* () { + const didDocTodeactivate = JSON.parse(JSON.stringify(didDocument)); const result = yield hypersignDID.deactivate({ - didDocument, + didDocument: didDocTodeactivate, privateKeyMultibase, verificationMethodId, versionId, @@ -744,6 +840,21 @@ describe('DID Test scenarios', () => { (0, chai_1.should)().exist(result.transactionHash); }); }); + it('should not be able to deactivate did document as its already deactivated', function () { + return __awaiter(this, void 0, void 0, function* () { + const didDocTodeactivate = JSON.parse(JSON.stringify(didDocument)); + return hypersignDID.deactivate({ + didDocument: didDocTodeactivate, + privateKeyMultibase, + verificationMethodId, + versionId, + }).catch(function (err) { + (0, chai_1.expect)(function () { + throw err; + }).to.throw(Error, `failed to execute message; message index: 0: DID Document ${didDocId} is already deactivated: didDoc is deactivated`); + }); + }); + }); }); describe('#sign() this is to sign didDoc', function () { const publicKey = { @@ -811,24 +922,25 @@ describe('DID Test scenarios', () => { }).to.throw(Error, 'HID-SSI-SDK:: Error: params.domain is required to sign a did'); }); }); - it('should not able to sign did document and throw error as did is not resolved', function () { + it('should not able to sign did document and throw error as verificationMethodId is invalid or wrong', function () { const params = { privateKeyMultibase: privateKeyMultibase, challenge: challenge, domain: domain, - did: didDocId, + did: '', didDocument: didDocument, verificationMethodId: verificationMethodId, publicKey, controller, }; + params.verificationMethodId = ''; return hypersignDID.sign(params).catch(function (err) { (0, chai_1.expect)(function () { throw err; - }).to.throw(Error, `HID-SSI-SDK:: Error: could not resolve did ${params.did}`); + }).to.throw(Error, 'HID-SSI-SDK:: Error: Incorrect verification method id'); }); }); - it('should not able to sign did document and throw error as verificationMethodId is invalid or wrong', function () { + it('should not able to sign did document and throw error as unsupported purpose is passed', function () { const params = { privateKeyMultibase: privateKeyMultibase, challenge: challenge, @@ -838,15 +950,46 @@ describe('DID Test scenarios', () => { verificationMethodId: verificationMethodId, publicKey, controller, + purpose: "random purpose" }; params.verificationMethodId = ''; return hypersignDID.sign(params).catch(function (err) { (0, chai_1.expect)(function () { throw err; - }).to.throw(Error, 'HID-SSI-SDK:: Error: Incorrect verification method id'); + }).to.throw(Error, `HID-SSI-SDK:: Error: unsupported purpose ${params.purpose}`); }); }); - it('should able to sign did document', function () { + it('should able to sign did document for didAuth using assertion purpose', function () { + return __awaiter(this, void 0, void 0, function* () { + const tempDidDoc = JSON.parse(JSON.stringify(didDocument)); + const params = { + privateKeyMultibase: privateKeyMultibase, + challenge: challenge, + domain: domain, + did: '', + didDocument: tempDidDoc, + verificationMethodId: verificationMethodId, + controller, + purpose: 'assertionMethod' + }; + signedDocumentAssertion = yield hypersignDID.sign(params); + (0, chai_1.expect)(signedDocumentAssertion).to.be.a('object'); + (0, chai_1.should)().exist(signedDocumentAssertion['@context']); + (0, chai_1.should)().exist(signedDocumentAssertion['id']); + (0, chai_1.expect)(didDocId).to.be.equal(signedDocumentAssertion['id']); + (0, chai_1.should)().exist(signedDocumentAssertion['controller']); + (0, chai_1.should)().exist(signedDocumentAssertion['alsoKnownAs']); + (0, chai_1.should)().exist(signedDocumentAssertion['verificationMethod']); + (0, chai_1.should)().exist(signedDocumentAssertion['authentication']); + (0, chai_1.should)().exist(signedDocumentAssertion['assertionMethod']); + (0, chai_1.should)().exist(signedDocumentAssertion['keyAgreement']); + (0, chai_1.should)().exist(signedDocumentAssertion['capabilityInvocation']); + (0, chai_1.should)().exist(signedDocumentAssertion['capabilityDelegation']); + (0, chai_1.should)().exist(signedDocumentAssertion['service']); + (0, chai_1.should)().exist(signedDocumentAssertion['proof']); + }); + }); + it('should able to sign did document for didAuth using authentication purpose', function () { return __awaiter(this, void 0, void 0, function* () { const params = { privateKeyMultibase: privateKeyMultibase, @@ -894,7 +1037,16 @@ describe('DID Test scenarios', () => { }).to.throw(Error, 'HID-SSI-SDK:: Error: params.challenge is required to verify a did'); }); }); - it('should return verification result', function () { + it('should not able to verify did document and throw error as unsupported purpose is passed', function () { + return hypersignDID + .verify({ didDocument: signedDocument, verificationMethodId, challenge: '', domain, purpose: "random" }) + .catch(function (err) { + (0, chai_1.expect)(function () { + throw err; + }).to.throw(Error, `HID-SSI-SDK:: Error: unsupported purpose random`); + }); + }); + it('should return verification result for didAuthentication', function () { return __awaiter(this, void 0, void 0, function* () { const result = yield hypersignDID.verify({ didDocument: signedDocument, @@ -910,6 +1062,21 @@ describe('DID Test scenarios', () => { (0, chai_1.expect)(result.verified).to.equal(true); }); }); + it('should return verification result for didAssertion', function () { + return __awaiter(this, void 0, void 0, function* () { + const result = yield hypersignDID.verify({ + didDocument: signedDocumentAssertion, + verificationMethodId, + purpose: "assertionMethod" + }); + (0, chai_1.expect)(result).to.be.a('object'); + (0, chai_1.should)().exist(result); + (0, chai_1.should)().exist(result.verified); + (0, chai_1.should)().exist(result.results); + (0, chai_1.expect)(result.results).to.be.a('array'); + (0, chai_1.expect)(result.verified).to.equal(true); + }); + }); it('should not able to verify did document and throw error as unknown verification method id is passed', function () { const verMethIdMod = verificationMethodId + 'somerandomtext'; return hypersignDID diff --git a/build/src/tests/did/didByEntityApiKey.spec.js b/build/src/tests/did/didByEntityApiKey.spec.js index f86ebf6..5244cc6 100644 --- a/build/src/tests/did/didByEntityApiKey.spec.js +++ b/build/src/tests/did/didByEntityApiKey.spec.js @@ -12,9 +12,6 @@ Object.defineProperty(exports, "__esModule", { value: true }); const chai_1 = require("chai"); const index_1 = require("../../index"); const config_1 = require("../config"); -// const entityApiSecretKey = -// '8fc3d16ce8f040fd2fc4e5ccc1d73.6b6e55d4d54cd90c85bbcc92d9469873e60c0d7878681223e2fe63fca3abafb63390f939a77b3d73bf2eb58a654810b38'; -const entityApiSecret = "69b91e007904228e3313e586ba695.bc7705956989e43bbd7060e845c2763a381cbc80f935ac848119b8c2d7d00616346eeb74efe22a0ff140506a0c6157ef6"; // with local edv let offlineSigner; let hypersignDID; @@ -37,7 +34,7 @@ beforeEach(function () { yield hypersignDID.init(); }); }); -describe("testing hypersignDid initiation", function () { +describe('testing hypersignDid initiation', function () { it('It should throw error as hypersignDid is neither init using offlineSigner nor using entityApiKey', () => __awaiter(this, void 0, void 0, function* () { const params = { nodeRestEndpoint: config_1.hidNodeEp.rest, @@ -105,17 +102,17 @@ describe('DID Test Scenarios using entiAPiSecretKey', () => { describe('#register() to register did on chain', function () { it('should not be able to initialize HypersignDID with entityApiSecretKey as entityApiSecretKey is invalid', () => __awaiter(this, void 0, void 0, function* () { const HypersignDid = new index_1.HypersignDID({ - entityApiSecretKey: "entityApiSecretKey", + entityApiSecretKey: 'entityApiSecretKey', nodeRestEndpoint: config_1.hidNodeEp.rest, nodeRpcEndpoint: config_1.hidNodeEp.rpc, namespace: config_1.hidNodeEp.namespace, }); try { yield HypersignDid.init(); - chai_1.expect.fail("Expected an error but initialization succeeded"); + chai_1.expect.fail('Expected an error but initialization succeeded'); } catch (error) { - (0, chai_1.expect)(error.message).to.equal("HID-SSI-SDK:: access_denied"); + (0, chai_1.expect)(error.message).to.equal('HID-SSI-SDK:: access_denied'); } })); it('should not able to register did document and throw error as didDocument is not passed or it is empty', () => __awaiter(this, void 0, void 0, function* () { @@ -145,7 +142,7 @@ describe('DID Test Scenarios using entiAPiSecretKey', () => { })); it('should be able to registr did using entityApiSecret', () => __awaiter(this, void 0, void 0, function* () { const HypersignDid = new index_1.HypersignDID({ - entityApiSecretKey: entityApiSecret, + entityApiSecretKey: config_1.entityApiSecret, nodeRestEndpoint: config_1.hidNodeEp.rest, nodeRpcEndpoint: config_1.hidNodeEp.rpc, namespace: config_1.hidNodeEp.namespace, @@ -170,10 +167,10 @@ describe('DID Test Scenarios using entiAPiSecretKey', () => { }); it('Should be able to resolve did using entityApiSecret', () => __awaiter(this, void 0, void 0, function* () { const params = { - did: didDocId + did: didDocId, }; const HypersignDid = new index_1.HypersignDID({ - entityApiSecretKey: entityApiSecret, + entityApiSecretKey: config_1.entityApiSecret, nodeRestEndpoint: config_1.hidNodeEp.rest, nodeRpcEndpoint: config_1.hidNodeEp.rpc, namespace: config_1.hidNodeEp.namespace, @@ -216,7 +213,7 @@ describe('DID Test Scenarios using entiAPiSecretKey', () => { }); it('should be able to update did document using entityApiSecret', () => __awaiter(this, void 0, void 0, function* () { const HypersignDid = new index_1.HypersignDID({ - entityApiSecretKey: entityApiSecret, + entityApiSecretKey: config_1.entityApiSecret, nodeRestEndpoint: config_1.hidNodeEp.rest, nodeRpcEndpoint: config_1.hidNodeEp.rpc, namespace: config_1.hidNodeEp.namespace, @@ -229,7 +226,7 @@ describe('DID Test Scenarios using entiAPiSecretKey', () => { verificationMethodId, versionId, }); - (0, chai_1.should)().exist(result.transactionHash); + (0, chai_1.should)().exist(result); })); }); describe('#resolve() did ater updating did document', function () { @@ -250,15 +247,18 @@ describe('DID Test Scenarios using entiAPiSecretKey', () => { describe('#deactivate() this is to deactivate didDocument', function () { it('should not be able to deactivate did document using entityApiSecretKey as privateKeyMultibase is null or empty', () => __awaiter(this, void 0, void 0, function* () { const HypersignDid = new index_1.HypersignDID({ - entityApiSecretKey: entityApiSecret, + entityApiSecretKey: config_1.entityApiSecret, nodeRestEndpoint: config_1.hidNodeEp.rest, nodeRpcEndpoint: config_1.hidNodeEp.rpc, namespace: config_1.hidNodeEp.namespace, }); yield HypersignDid.init(); - return HypersignDid - .deactivate({ didDocument, privateKeyMultibase: '', verificationMethodId, versionId: '1.0' }) - .catch(function (err) { + return HypersignDid.deactivate({ + didDocument, + privateKeyMultibase: '', + verificationMethodId, + versionId: '1.0', + }).catch(function (err) { (0, chai_1.expect)(function () { throw err; }).to.throw(Error, 'HID-SSI-SDK:: Error: params.privateKeyMultibase is required to deactivate a did'); @@ -267,15 +267,18 @@ describe('DID Test Scenarios using entiAPiSecretKey', () => { it('should not be able to deactivate did document as verificationMethodId is null or empty', function () { return __awaiter(this, void 0, void 0, function* () { const HypersignDid = new index_1.HypersignDID({ - entityApiSecretKey: entityApiSecret, + entityApiSecretKey: config_1.entityApiSecret, nodeRestEndpoint: config_1.hidNodeEp.rest, nodeRpcEndpoint: config_1.hidNodeEp.rpc, namespace: config_1.hidNodeEp.namespace, }); yield HypersignDid.init(); - return HypersignDid - .deactivate({ didDocument, privateKeyMultibase, verificationMethodId: '', versionId: '1.0' }) - .catch(function (err) { + return HypersignDid.deactivate({ + didDocument, + privateKeyMultibase, + verificationMethodId: '', + versionId: '1.0', + }).catch(function (err) { (0, chai_1.expect)(function () { throw err; }).to.throw(Error, 'HID-SSI-SDK:: Error: params.verificationMethodId is required to deactivate a did'); @@ -293,7 +296,7 @@ describe('DID Test Scenarios using entiAPiSecretKey', () => { }); it('Should be able to deactivate did document using entityApiSecretKey', () => __awaiter(this, void 0, void 0, function* () { const HypersignDid = new index_1.HypersignDID({ - entityApiSecretKey: entityApiSecret, + entityApiSecretKey: config_1.entityApiSecret, nodeRestEndpoint: config_1.hidNodeEp.rest, nodeRpcEndpoint: config_1.hidNodeEp.rpc, namespace: config_1.hidNodeEp.namespace, @@ -309,10 +312,10 @@ describe('DID Test Scenarios using entiAPiSecretKey', () => { })); it('Should be able to resolve deactivated did and get deactivated as true in didDoc', () => __awaiter(this, void 0, void 0, function* () { const params = { - did: didDocId + did: didDocId, }; const HypersignDid = new index_1.HypersignDID({ - entityApiSecretKey: entityApiSecret, + entityApiSecretKey: config_1.entityApiSecret, nodeRestEndpoint: config_1.hidNodeEp.rest, nodeRpcEndpoint: config_1.hidNodeEp.rpc, namespace: config_1.hidNodeEp.namespace, diff --git a/build/src/tests/did/didByclientSpec.spec.js b/build/src/tests/did/didByclientSpec.spec.js index c47070f..f90ee85 100644 --- a/build/src/tests/did/didByclientSpec.spec.js +++ b/build/src/tests/did/didByclientSpec.spec.js @@ -43,7 +43,7 @@ const ethers_1 = require("ethers"); const config_1 = require("../config"); const bip39 = __importStar(require("bip39")); let hypersignDID; -let MMWalletAddress; +const MMWalletAddress = "0x4457bCb9351c5677f892F9d8Be75493B8F7A7932"; let MMPrivateKey; let MMPublicKey; let offlineSigner; @@ -69,7 +69,7 @@ function generateSignature() { const wallet = yield ethers_1.HDNodeWallet.fromMnemonic(Mnemonics, `m/44'/60'/0'/0/${0}`); const web3 = new web3_1.default(); const account = yield web3.eth.accounts.privateKeyToAccount(wallet.privateKey); - MMWalletAddress = account.address; + // MMWalletAddress = account.address; MMPrivateKey = wallet.privateKey; MMPublicKey = wallet.publicKey; }); @@ -235,12 +235,42 @@ describe('DID Test scenarion for clientSpec', () => { }).to.throw(Error, 'HID-SSI-SDK:: Error: params.web3 is required to sign'); }); })); + it('should not be able to generate signature as verificationMethodId is not passed', () => __awaiter(this, void 0, void 0, function* () { + const web3 = new web3_1.default(metamaskProvider); + const params = { + didDocument: didDocumentByClientspec, + address: MMWalletAddress, + web3, + clientSpec: "eth-personalSign" + }; + return hypersignDID.signByClientSpec(params).catch(function (err) { + (0, chai_1.expect)(function () { + throw err; + }).to.throw(Error, 'HID-SSI-SDK:: Error: params.verificationMethodId is required to sign'); + }); + })); + it('should not be able to generate signature as verificationMethodId passed is invalid or not presnet in didDoc', () => __awaiter(this, void 0, void 0, function* () { + const web3 = new web3_1.default(metamaskProvider); + const params = { + didDocument: didDocumentByClientspec, + address: MMWalletAddress, + web3, + clientSpec: "eth-personalSign", + verificationMethodId: didDocumentByClientspec.id + "e#key-1", + }; + return hypersignDID.signByClientSpec(params).catch(function (err) { + (0, chai_1.expect)(function () { + throw err; + }).to.throw(Error, "HID-SSI_SDK:: Error: invalid verificationMethodId"); + }); + })); it('should not be able to generate signature as clientSpec passed is of type "cosmos-ADR036" but chainId is not passed', () => __awaiter(this, void 0, void 0, function* () { const web3 = new web3_1.default(metamaskProvider); const params = { didDocument: didDocumentByClientspec, address: MMWalletAddress, web3, + verificationMethodId: didDocumentByClientspec.verificationMethod[0].id, clientSpec: "cosmos-ADR036" }; return hypersignDID.signByClientSpec(params).catch(function (err) { @@ -249,18 +279,17 @@ describe('DID Test scenarion for clientSpec', () => { }).to.throw(Error, `HID-SSI-SDK:: Error: params.chainId is required to sign for clientSpec ${params.clientSpec} and keyType EcdsaSecp256k1VerificationKey2019`); }); })); - // it('Should be able to generate signature for didDoc', async()=>{ - // const web3= new Web3(metamaskProvider) - // console.log(web3.eth.personal.sign) - // const params={ - // didDocument:didDocumentByClientspec, - // address:MMWalletAddress, - // clientSpec:"eth-personalSign", - // web3:web3 - // } - // const signedDidDocByClientSpec= await hypersignDID.signByClientSpec(params) - // console.log(signedDidDocByClientSpec) - // // error Cannot read properties of undefined (reading 'eth') + // it('Should be able to generate signature for didDoc', async () => { + // const web3 = new Web3(metamaskProvider) + // const params = { + // didDocument: didDocumentByClientspec, + // address: MMWalletAddress,//"0x4457bCb9351c5677f892F9d8Be75493B8F7A7932", + // clientSpec: "eth-personalSign", + // web3: web3, + // verificationMethodId: didDocumentByClientspec.verificationMethod[0].id, + // } + // const signedDidDocByClientSpec = await hypersignDID.signByClientSpec(params) + // // error Cannot read properties of undefined (reading 'eth') // }) }); describe("#registerByClientSpec() this is to register did generated using clientspec on the blockchain", function () { @@ -664,7 +693,7 @@ describe('DID Test scenarion for clientSpec', () => { var _a; (0, chai_1.expect)(function () { throw err; - }).to.throw(Error, `HID-SSI-SDK:: Error: params.signInfos[${0}].adr036SignerAddress is required to deactivate a did, when clientSpec type is${(_a = params.signInfos[0].clientSpec) === null || _a === void 0 ? void 0 : _a.type} `); + }).to.throw(Error, `HID-SSI-SDK:: Error: params.signInfos[${0}].adr036SignerAddress is required to deactivate a did, when clientSpec type is${(_a = params.signInfos[0].clientSpec) === null || _a === void 0 ? void 0 : _a.type}`); }); })); it('should not be able to deactivate did as versionId is not passed', () => __awaiter(this, void 0, void 0, function* () { diff --git a/build/src/tests/did/did_keyagreement.spec.d.ts b/build/src/tests/did/did_keyagreement.spec.d.ts new file mode 100644 index 0000000..2b7fbb4 --- /dev/null +++ b/build/src/tests/did/did_keyagreement.spec.d.ts @@ -0,0 +1,2 @@ +export {}; +//# sourceMappingURL=did_keyagreement.spec.d.ts.map \ No newline at end of file diff --git a/build/src/tests/did/did_keyagreement.spec.d.ts.map b/build/src/tests/did/did_keyagreement.spec.d.ts.map new file mode 100644 index 0000000..682a172 --- /dev/null +++ b/build/src/tests/did/did_keyagreement.spec.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"did_keyagreement.spec.d.ts","sourceRoot":"","sources":["../../../../src/tests/did/did_keyagreement.spec.ts"],"names":[],"mappings":""} \ No newline at end of file diff --git a/build/src/tests/did/did_keyagreement.spec.js b/build/src/tests/did/did_keyagreement.spec.js new file mode 100644 index 0000000..25f20d0 --- /dev/null +++ b/build/src/tests/did/did_keyagreement.spec.js @@ -0,0 +1,334 @@ +"use strict"; +var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { + function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } + return new (P || (P = Promise))(function (resolve, reject) { + function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } + function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } + function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } + step((generator = generator.apply(thisArg, _arguments || [])).next()); + }); +}; +Object.defineProperty(exports, "__esModule", { value: true }); +const chai_1 = require("chai"); +const index_1 = require("../../index"); +const config_1 = require("../config"); +let privateKeyMultibase; +let publicKeyMultibase; +let verificationMethodId; +let didDocument; +let didDocId; +let offlineSigner; +let versionId; +let hypersignDID; +let transactionHash; +beforeEach(function () { + return __awaiter(this, void 0, void 0, function* () { + offlineSigner = yield (0, config_1.createWallet)(config_1.mnemonic); + const params = { + offlineSigner, + nodeRestEndpoint: config_1.hidNodeEp.rest, + nodeRpcEndpoint: config_1.hidNodeEp.rpc, + namespace: config_1.hidNodeEp.namespace, + }; + hypersignDID = new index_1.HypersignDID(params); + yield hypersignDID.init(); + }); +}); +describe('DID Test scenarios for keyagreement type', () => { + describe('DID Test scenarios for keyType X25519KeyAgreementKey2020', () => { + describe('#generateKeys() method to generate publicKyeMultibase and privateKeyMultiBase', function () { + it('should return publickeyMultibase and privateKeyMultibase', function () { + return __awaiter(this, void 0, void 0, function* () { + const kp = yield hypersignDID.generateKeys(); + privateKeyMultibase = kp.privateKeyMultibase; + publicKeyMultibase = kp.publicKeyMultibase; + (0, chai_1.expect)(kp).to.be.a('object'); + (0, chai_1.should)().exist(kp.privateKeyMultibase); + (0, chai_1.should)().exist(kp.publicKeyMultibase); + (0, chai_1.should)().not.exist(kp.id); + }); + }); + }); + describe('#generate() to generate did', function () { + it('should not be able to generate did document and throw error as publicKeyMultibase passed is null or empty', function () { + return hypersignDID.generate({ publicKeyMultibase: '' }).catch(function (err) { + (0, chai_1.expect)(function () { + throw err; + }).to.throw(Error, 'HID-SSI-SDK:: Error: params.publicKeyMultibase is required to generate new did didoc'); + }); + }); + it('should be able to generate didDocument with ed25519 key', function () { + return __awaiter(this, void 0, void 0, function* () { + didDocument = yield hypersignDID.generate({ publicKeyMultibase }); + didDocId = didDocument['id']; + verificationMethodId = didDocument['verificationMethod'][0].id; + (0, chai_1.expect)(didDocument).to.be.a('object'); + (0, chai_1.should)().exist(didDocument['@context']); + (0, chai_1.should)().exist(didDocument['id']); + (0, chai_1.should)().exist(didDocument['controller']); + (0, chai_1.should)().exist(didDocument['alsoKnownAs']); + (0, chai_1.should)().exist(didDocument['verificationMethod']); + (0, chai_1.expect)(didDocument['verificationMethod'] && + didDocument['authentication'] && + didDocument['assertionMethod'] && + didDocument['keyAgreement'] && + didDocument['capabilityInvocation'] && + didDocument['capabilityDelegation'] && + didDocument['service']).to.be.a('array'); + (0, chai_1.should)().exist(didDocument['authentication']); + (0, chai_1.should)().exist(didDocument['assertionMethod']); + (0, chai_1.should)().exist(didDocument['keyAgreement']); + (0, chai_1.should)().exist(didDocument['capabilityInvocation']); + (0, chai_1.should)().exist(didDocument['capabilityDelegation']); + (0, chai_1.should)().exist(didDocument['service']); + }); + }); + }); + // adding keyagreement type as vm + describe('#addVerificationMethod() to add verificationMethod in didDocument', function () { + it('should be able to add verification method of type X25519KeyAgreementKey2020 in didDocument', () => __awaiter(this, void 0, void 0, function* () { + const params = { + didDocument: didDocument, + type: 'X25519KeyAgreementKey2020', + publicKeyMultibase: '23fer44374u3rmhvf47ri35ty', + }; + const didDoc = JSON.parse(JSON.stringify(didDocument)); + const updatedDidDoc = yield hypersignDID.addVerificationMethod(Object.assign({}, params)); + (0, chai_1.expect)(updatedDidDoc).to.be.a('object'); + (0, chai_1.should)().exist(updatedDidDoc['@context']); + (0, chai_1.should)().exist(updatedDidDoc['id']); + (0, chai_1.should)().exist(updatedDidDoc['controller']); + (0, chai_1.should)().exist(updatedDidDoc['alsoKnownAs']); + (0, chai_1.should)().exist(updatedDidDoc['verificationMethod']); + (0, chai_1.expect)(updatedDidDoc['verificationMethod'] && + updatedDidDoc['authentication'] && + updatedDidDoc['assertionMethod'] && + updatedDidDoc['keyAgreement'] && + updatedDidDoc['capabilityInvocation'] && + updatedDidDoc['capabilityDelegation'] && + updatedDidDoc['service']).to.be.a('array'); + (0, chai_1.should)().exist(updatedDidDoc['authentication']); + (0, chai_1.should)().exist(updatedDidDoc['assertionMethod']); + (0, chai_1.expect)(updatedDidDoc.verificationMethod.length).to.be.greaterThan(didDoc.verificationMethod.length); + })); + }); + describe('#register() this is to register did on the blockchain', function () { + it('should be able to register didDocument in the blockchain with two vm one is of type Ed25519VerificationKey2020 and other is of type X25519KeyAgreementKey2020 and register method is called without signData field', function () { + return __awaiter(this, void 0, void 0, function* () { + const result = yield hypersignDID.register({ + didDocument, + privateKeyMultibase, + verificationMethodId + }); + transactionHash = result.transactionHash; + (0, chai_1.should)().exist(result.transactionHash); + }); + }); + }); + describe('#resolve() this is to resolve didDocument based on didDocId', function () { + it('should be able to resolve did', function () { + return __awaiter(this, void 0, void 0, function* () { + const params = { + did: didDocId, + }; + const result = yield hypersignDID.resolve(params); + (0, chai_1.expect)(result).to.be.a('object'); + (0, chai_1.expect)(result.didDocument.id).to.be.equal(didDocId); + (0, chai_1.expect)(result.didDocumentMetadata).to.be.a('object'); + versionId = result.didDocumentMetadata.versionId; + }); + }); + }); + describe('#update() this is to update didDocument based on didDocId', function () { + it('should be able to update did document with key type X25519KeyAgreementKey2020', function () { + return __awaiter(this, void 0, void 0, function* () { + const didDoc = JSON.parse(JSON.stringify(didDocument)); + didDoc['alsoKnownAs'].push('Some DATA'); + const result = yield hypersignDID.update({ + didDocument: didDoc, + privateKeyMultibase, + verificationMethodId, + versionId, + }); + (0, chai_1.should)().exist(result.transactionHash); + }); + }); + }); + describe('#resolve() did after updating did document', function () { + it('should be able to resolve did', function () { + return __awaiter(this, void 0, void 0, function* () { + const params = { + did: didDocId, + }; + const result = yield hypersignDID.resolve(params); + (0, chai_1.expect)(result).to.be.a('object'); + (0, chai_1.expect)(result.didDocument.id).to.be.equal(didDocId); + (0, chai_1.expect)(result.didDocumentMetadata).to.be.a('object'); + versionId = result.didDocumentMetadata.versionId; + }); + }); + }); + describe('#deactivate() this is to deactivate didDocument based on didDocId', function () { + it('should be able to deactivate did document with key type X25519KeyAgreementKey2020', function () { + return __awaiter(this, void 0, void 0, function* () { + const didDocTodeactivate = JSON.parse(JSON.stringify(didDocument)); + const result = yield hypersignDID.deactivate({ + didDocument: didDocTodeactivate, + privateKeyMultibase, + verificationMethodId, + versionId, + }); + (0, chai_1.should)().exist(result.transactionHash); + }); + }); + }); + }); + describe('DID Test scenarios for keyType X25519KeyAgreementKeyEIP5630', () => { + describe('#generateKeys() method to generate publicKyeMultibase and privateKeyMultiBase', function () { + it('should return publickeyMultibase and privateKeyMultibase', function () { + return __awaiter(this, void 0, void 0, function* () { + const kp = yield hypersignDID.generateKeys(); + privateKeyMultibase = kp.privateKeyMultibase; + publicKeyMultibase = kp.publicKeyMultibase; + (0, chai_1.expect)(kp).to.be.a('object'); + (0, chai_1.should)().exist(kp.privateKeyMultibase); + (0, chai_1.should)().exist(kp.publicKeyMultibase); + (0, chai_1.should)().not.exist(kp.id); + }); + }); + }); + describe('#generate() to generate did', function () { + it('should not be able to generate did document and throw error as publicKeyMultibase passed is null or empty', function () { + return hypersignDID.generate({ publicKeyMultibase: '' }).catch(function (err) { + (0, chai_1.expect)(function () { + throw err; + }).to.throw(Error, 'HID-SSI-SDK:: Error: params.publicKeyMultibase is required to generate new did didoc'); + }); + }); + it('should be able to generate didDocument with ed25519 key', function () { + return __awaiter(this, void 0, void 0, function* () { + didDocument = yield hypersignDID.generate({ publicKeyMultibase }); + didDocId = didDocument['id']; + verificationMethodId = didDocument['verificationMethod'][0].id; + (0, chai_1.expect)(didDocument).to.be.a('object'); + (0, chai_1.should)().exist(didDocument['@context']); + (0, chai_1.should)().exist(didDocument['id']); + (0, chai_1.should)().exist(didDocument['controller']); + (0, chai_1.should)().exist(didDocument['alsoKnownAs']); + (0, chai_1.should)().exist(didDocument['verificationMethod']); + (0, chai_1.expect)(didDocument['verificationMethod'] && + didDocument['authentication'] && + didDocument['assertionMethod'] && + didDocument['keyAgreement'] && + didDocument['capabilityInvocation'] && + didDocument['capabilityDelegation'] && + didDocument['service']).to.be.a('array'); + (0, chai_1.should)().exist(didDocument['authentication']); + (0, chai_1.should)().exist(didDocument['assertionMethod']); + (0, chai_1.should)().exist(didDocument['keyAgreement']); + (0, chai_1.should)().exist(didDocument['capabilityInvocation']); + (0, chai_1.should)().exist(didDocument['capabilityDelegation']); + (0, chai_1.should)().exist(didDocument['service']); + }); + }); + }); + // adding keyagreement type as vm + describe('#addVerificationMethod() to add verificationMethod in didDocument', function () { + it('should be able to add verification method of type X25519KeyAgreementKeyEIP5630 in didDocument', () => __awaiter(this, void 0, void 0, function* () { + const params = { + didDocument: didDocument, + type: 'X25519KeyAgreementKeyEIP5630', + publicKeyMultibase: '23fer44374u3rmhvf47ri35ty1', + }; + const didDoc = JSON.parse(JSON.stringify(didDocument)); + const updatedDidDoc = yield hypersignDID.addVerificationMethod(Object.assign({}, params)); + (0, chai_1.expect)(updatedDidDoc).to.be.a('object'); + (0, chai_1.should)().exist(updatedDidDoc['@context']); + (0, chai_1.should)().exist(updatedDidDoc['id']); + (0, chai_1.should)().exist(updatedDidDoc['controller']); + (0, chai_1.should)().exist(updatedDidDoc['alsoKnownAs']); + (0, chai_1.should)().exist(updatedDidDoc['verificationMethod']); + (0, chai_1.expect)(updatedDidDoc['verificationMethod'] && + updatedDidDoc['authentication'] && + updatedDidDoc['assertionMethod'] && + updatedDidDoc['keyAgreement'] && + updatedDidDoc['capabilityInvocation'] && + updatedDidDoc['capabilityDelegation'] && + updatedDidDoc['service']).to.be.a('array'); + (0, chai_1.should)().exist(updatedDidDoc['authentication']); + (0, chai_1.should)().exist(updatedDidDoc['assertionMethod']); + (0, chai_1.expect)(updatedDidDoc.verificationMethod.length).to.be.greaterThan(didDoc.verificationMethod.length); + })); + }); + describe('#register() this is to register did with keyType Ed25519VerificationKey2020 and X25519KeyAgreementKeyEIP5630 on the blockchain', function () { + it('should be able to register didDocument in the blockchain with two vm one is of type Ed25519VerificationKey2020 and other is of type X25519KeyAgreementKeyEIP5630 and register method is called without signData field', function () { + return __awaiter(this, void 0, void 0, function* () { + const result = yield hypersignDID.register({ + didDocument, + privateKeyMultibase, + verificationMethodId + }); + transactionHash = result.transactionHash; + (0, chai_1.should)().exist(result.transactionHash); + }); + }); + }); + describe('#resolve() this is to resolve didDocument based on didDocId', function () { + it('should be able to resolve did', function () { + return __awaiter(this, void 0, void 0, function* () { + const params = { + did: didDocId, + }; + const result = yield hypersignDID.resolve(params); + (0, chai_1.expect)(result).to.be.a('object'); + (0, chai_1.expect)(result.didDocument.id).to.be.equal(didDocId); + (0, chai_1.expect)(result.didDocumentMetadata).to.be.a('object'); + versionId = result.didDocumentMetadata.versionId; + }); + }); + }); + describe('#update() this is to update didDocument based on didDocId', function () { + it('should be able to update did document with keyType X25519KeyAgreementKeyEIP5630', function () { + return __awaiter(this, void 0, void 0, function* () { + const didDoc = JSON.parse(JSON.stringify(didDocument)); + didDoc['alsoKnownAs'].push('Some DATA'); + const result = yield hypersignDID.update({ + didDocument: didDoc, + privateKeyMultibase, + verificationMethodId, + versionId, + }); + (0, chai_1.should)().exist(result.transactionHash); + }); + }); + }); + describe('#resolve() did after updating did document', function () { + it('should be able to resolve did', function () { + return __awaiter(this, void 0, void 0, function* () { + const params = { + did: didDocId, + }; + const result = yield hypersignDID.resolve(params); + (0, chai_1.expect)(result).to.be.a('object'); + (0, chai_1.expect)(result.didDocument.id).to.be.equal(didDocId); + (0, chai_1.expect)(result.didDocumentMetadata).to.be.a('object'); + versionId = result.didDocumentMetadata.versionId; + }); + }); + }); + describe('#deactivate() this is to deactivate didDocument based on didDocId', function () { + it('should be able to deactivate did document with keytype X25519KeyAgreementKeyEIP5630', function () { + return __awaiter(this, void 0, void 0, function* () { + const didDocTodeactivate = JSON.parse(JSON.stringify(didDocument)); + const result = yield hypersignDID.deactivate({ + didDocument: didDocTodeactivate, + privateKeyMultibase, + verificationMethodId, + versionId, + }); + (0, chai_1.should)().exist(result.transactionHash); + }); + }); + }); + }); +}); diff --git a/build/src/tests/vp.spec.d.ts b/build/src/tests/presentation/vp.spec.d.ts similarity index 100% rename from build/src/tests/vp.spec.d.ts rename to build/src/tests/presentation/vp.spec.d.ts diff --git a/build/src/tests/presentation/vp.spec.d.ts.map b/build/src/tests/presentation/vp.spec.d.ts.map new file mode 100644 index 0000000..83bb71c --- /dev/null +++ b/build/src/tests/presentation/vp.spec.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"vp.spec.d.ts","sourceRoot":"","sources":["../../../../src/tests/presentation/vp.spec.ts"],"names":[],"mappings":""} \ No newline at end of file diff --git a/build/src/tests/vp.spec.js b/build/src/tests/presentation/vp.spec.js similarity index 71% rename from build/src/tests/vp.spec.js rename to build/src/tests/presentation/vp.spec.js index a2ac1e5..83ef537 100644 --- a/build/src/tests/vp.spec.js +++ b/build/src/tests/presentation/vp.spec.js @@ -10,8 +10,10 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge }; Object.defineProperty(exports, "__esModule", { value: true }); const chai_1 = require("chai"); -const index_1 = require("../index"); -const config_1 = require("./config"); +const index_1 = require("../../index"); +const config_1 = require("../config"); +let holdersPrivateKeyMultibase; +let holderDidDocument; let hypersignSSISDK; let privateKeyMultibase; let publicKeyMultibase; @@ -21,7 +23,6 @@ let signedDocument; let verificationMethodId; let didDocument; let schemaObject; -let schemaSignature; const challenge = '1231231231'; const domain = 'www.adbv.com'; let offlineSigner; @@ -38,8 +39,6 @@ let hypersignVP; let unsignedverifiablePresentation; let verifiableCredentialPresentationId; let signedVerifiablePresentation; -let didDocumentByClientspec; -const MMWalletAddress = '0x7967C85D989c41cA245f1Bb54c97D42173B135E0'; const credentialBody = { schemaId: '', subjectDid: '', @@ -48,7 +47,7 @@ const credentialBody = { fields: { name: 'Varsha' }, }; const schemaBody = { - name: 'testSchema', + name: 'TestSchema', description: 'This is a test schema generation', author: '', fields: [{ name: 'name', type: 'string', isRequired: false }], @@ -130,32 +129,32 @@ describe('DID Opearations', () => { (0, chai_1.should)().exist(didDocument['service']); }); }); - it('should be able to generate new did with MMwallet address using client spec', () => __awaiter(this, void 0, void 0, function* () { - const params = { - methodSpecificId: MMWalletAddress, - address: MMWalletAddress, - chainId: '0x1', - clientSpec: 'eth-personalSign', - }; - didDocumentByClientspec = yield hypersignDID.createByClientSpec(params); - (0, chai_1.expect)(didDocumentByClientspec).to.be.a('object'); - (0, chai_1.should)().exist(didDocumentByClientspec['@context']); - (0, chai_1.should)().exist(didDocumentByClientspec['id']); - (0, chai_1.should)().exist(didDocumentByClientspec['controller']); - (0, chai_1.should)().exist(didDocumentByClientspec['alsoKnownAs']); - (0, chai_1.should)().exist(didDocumentByClientspec['verificationMethod']); - (0, chai_1.expect)(didDocumentByClientspec['verificationMethod'] && - didDocumentByClientspec['authentication'] && - didDocumentByClientspec['assertionMethod'] && - didDocumentByClientspec['keyAgreement'] && - didDocumentByClientspec['capabilityInvocation'] && - didDocumentByClientspec['capabilityDelegation']).to.be.a('array'); - (0, chai_1.should)().exist(didDocumentByClientspec['authentication']); - (0, chai_1.should)().exist(didDocumentByClientspec['assertionMethod']); - (0, chai_1.should)().exist(didDocumentByClientspec['keyAgreement']); - (0, chai_1.should)().exist(didDocumentByClientspec['capabilityInvocation']); - (0, chai_1.should)().exist(didDocumentByClientspec['capabilityDelegation']); - })); + it('should be able to generate didDocument for holder', function () { + return __awaiter(this, void 0, void 0, function* () { + const kp = yield hypersignDID.generateKeys(); + holdersPrivateKeyMultibase = kp.privateKeyMultibase; + holderDidDocument = yield hypersignDID.generate({ publicKeyMultibase: kp.publicKeyMultibase }); + (0, chai_1.expect)(didDocument).to.be.a('object'); + (0, chai_1.should)().exist(didDocument['@context']); + (0, chai_1.should)().exist(didDocument['id']); + (0, chai_1.should)().exist(didDocument['controller']); + (0, chai_1.should)().exist(didDocument['alsoKnownAs']); + (0, chai_1.should)().exist(didDocument['verificationMethod']); + (0, chai_1.expect)(didDocument['verificationMethod'] && + didDocument['authentication'] && + didDocument['assertionMethod'] && + didDocument['keyAgreement'] && + didDocument['capabilityInvocation'] && + didDocument['capabilityDelegation'] && + didDocument['service']).to.be.a('array'); + (0, chai_1.should)().exist(didDocument['authentication']); + (0, chai_1.should)().exist(didDocument['assertionMethod']); + (0, chai_1.should)().exist(didDocument['keyAgreement']); + (0, chai_1.should)().exist(didDocument['capabilityInvocation']); + (0, chai_1.should)().exist(didDocument['capabilityDelegation']); + (0, chai_1.should)().exist(didDocument['service']); + }); + }); }); describe('#sign() this is to sign didDoc', function () { const controller = { @@ -165,12 +164,13 @@ describe('DID Opearations', () => { }; it('should able to sign did document', function () { return __awaiter(this, void 0, void 0, function* () { + const didDoc = JSON.parse(JSON.stringify(didDocument)); const params = { privateKeyMultibase: privateKeyMultibase, challenge: challenge, domain: domain, did: '', - didDocument: didDocument, + didDocument: didDoc, verificationMethodId: verificationMethodId, controller, }; @@ -200,11 +200,22 @@ describe('DID Opearations', () => { (0, chai_1.should)().exist(result.didDocument); }); }); + it('should be able to register holder didDocument in the blockchain', function () { + return __awaiter(this, void 0, void 0, function* () { + const result = yield hypersignDID.register({ + didDocument: holderDidDocument, + privateKeyMultibase: holdersPrivateKeyMultibase, + verificationMethodId: holderDidDocument.verificationMethod[0].id, + }); + (0, chai_1.should)().exist(result.transactionHash); + (0, chai_1.should)().exist(result.didDocument); + }); + }); }); }); -/** - * Schema Creation and Registration - */ +// /** +// * Schema Creation and Registration +// */ describe('Schema Opearations', () => { describe('#getSchema() method to create schema', function () { it('should able to create a new schema', function () { @@ -247,17 +258,17 @@ describe('Schema Opearations', () => { }); }); }); -/** - * Test cases related to credential - */ +// /** +// * Test cases related to credential +// */ describe('Verifiable Credential Opearations', () => { - describe('#getCredential() method to generate a credential', function () { + describe('#generate() method to generate a credential', function () { it('should be able to generate new credential for a schema with subject DID', function () { return __awaiter(this, void 0, void 0, function* () { const expirationDate = new Date('12/11/2027'); const tempCredentialBody = Object.assign({}, credentialBody); tempCredentialBody.schemaId = schemaId; - tempCredentialBody.subjectDid = didDocId; + tempCredentialBody.subjectDid = holderDidDocument.id; tempCredentialBody['expirationDate'] = expirationDate; tempCredentialBody.issuerDid = didDocId; tempCredentialBody.fields = { name: 'varsha' }; @@ -275,7 +286,7 @@ describe('Verifiable Credential Opearations', () => { (0, chai_1.should)().exist(credentialDetail['credentialSubject']); (0, chai_1.should)().exist(credentialDetail['credentialSchema']); (0, chai_1.should)().exist(credentialDetail['credentialStatus']); - (0, chai_1.expect)(credentialDetail['credentialStatus'].type).to.be.equal('CredentialStatusList2017'); + (0, chai_1.expect)(credentialDetail['credentialStatus'].type).to.be.equal('HypersignCredentialStatus2023'); }); }); }); @@ -293,8 +304,6 @@ describe('Verifiable Credential Opearations', () => { signedVC = signedCredential; credenStatus = credentialStatus; credentialId = signedVC.id; - // console.log('Signed Credential --------------------------------'); - // console.log(JSON.stringify(signedVC, null, 2)); credentialStatusId = signedCredential['credentialStatus'].id; (0, chai_1.expect)(signedCredential).to.be.a('object'); (0, chai_1.should)().exist(signedCredential['@context']); @@ -307,26 +316,20 @@ describe('Verifiable Credential Opearations', () => { (0, chai_1.should)().exist(signedCredential['credentialSchema']); (0, chai_1.should)().exist(signedCredential['credentialStatus']); (0, chai_1.should)().exist(signedCredential['proof']); - // console.log({ - // signedCredentialId: signedVC ? signedVC['id'] : '', - // credentialId, - // id: tempIssueCredentialBody.credential.id, - // }); (0, chai_1.expect)(signedCredential['id']).to.be.equal(tempIssueCredentialBody.credential.id); (0, chai_1.expect)(credentialStatus).to.be.a('object'); - (0, chai_1.should)().exist(credentialStatus['claim']); (0, chai_1.should)().exist(credentialStatus['issuer']); (0, chai_1.should)().exist(credentialStatus['issuanceDate']); - (0, chai_1.should)().exist(credentialStatus['expirationDate']); - (0, chai_1.should)().exist(credentialStatus['credentialHash']); + (0, chai_1.should)().exist(credentialStatus['remarks']); + (0, chai_1.should)().exist(credentialStatus['credentialMerkleRootHash']); (0, chai_1.expect)(credentialStatusProof).to.be.a('object'); (0, chai_1.should)().exist(credentialStatusProof['type']); (0, chai_1.should)().exist(credentialStatusProof['created']); - (0, chai_1.should)().exist(credentialStatusProof['updated']); (0, chai_1.should)().exist(credentialStatusProof['verificationMethod']); (0, chai_1.should)().exist(credentialStatusProof['proofPurpose']); (0, chai_1.should)().exist(credentialStatusProof['proofValue']); (0, chai_1.expect)(credentialStatusRegistrationResult).to.be.a('object'); + (0, chai_1.should)().exist(credentialStatusRegistrationResult['code']); (0, chai_1.should)().exist(credentialStatusRegistrationResult['height']); (0, chai_1.should)().exist(credentialStatusRegistrationResult['transactionHash']); (0, chai_1.should)().exist(credentialStatusRegistrationResult['gasUsed']); @@ -335,22 +338,20 @@ describe('Verifiable Credential Opearations', () => { }); }); }); -/** - * Test cases related to verifiable presentation - */ +// /** +// * Test cases related to verifiable presentation +// */ describe('Verifiable Presentation Operataions', () => { describe('#generate() method to generate new presentation document', () => { - const presentationBody = { - verifiableCredentials: [credentialDetail], - holderDid: didDocId, - }; - it('should be able to gnerate a new presentation document', () => __awaiter(void 0, void 0, void 0, function* () { + it('should be able to generate a new presentation document', () => __awaiter(void 0, void 0, void 0, function* () { + const presentationBody = { + verifiableCredentials: [credentialDetail], + holderDid: holderDidDocument.id, + }; const tempPresentationBody = Object.assign({}, presentationBody); tempPresentationBody.verifiableCredentials[0] = credentialDetail; - tempPresentationBody.holderDid = didDocId; - // console.log(JSON.stringify(tempPresentationBody, null, 2)); + tempPresentationBody.holderDid = holderDidDocument.id; unsignedverifiablePresentation = yield hypersignVP.generate(tempPresentationBody); - // console.log(JSON.stringify(unsignedverifiablePresentation, null, 2)); (0, chai_1.should)().exist(unsignedverifiablePresentation['@context']); (0, chai_1.should)().exist(unsignedverifiablePresentation['type']); (0, chai_1.expect)(unsignedverifiablePresentation.type[0]).to.be.equal('VerifiablePresentation'); @@ -359,24 +360,23 @@ describe('Verifiable Presentation Operataions', () => { (0, chai_1.should)().exist(unsignedverifiablePresentation['id']); (0, chai_1.should)().exist(unsignedverifiablePresentation['holder']); verifiableCredentialPresentationId = unsignedverifiablePresentation.id; - // expect(unsignedverifiablePresentation['verifiableCredential'][0].id).to.be.equal(credentialId); })); }); describe('#sign() method to sign presentation document', () => { const signPresentationBody = { presentation: unsignedverifiablePresentation, - holderDid: didDocId, - verificationMethodId, - privateKeyMultibase: privateKeyMultibase, + holderDid: '', + verificationMethodId: '', + privateKeyMultibase: '', challenge, }; it('should not be able to sign presentation as either holderDid or holderDidDocSigned is required but passed both', function () { return __awaiter(this, void 0, void 0, function* () { const tempSignPresentationBody = Object.assign({}, signPresentationBody); tempSignPresentationBody.presentation = unsignedverifiablePresentation; - tempSignPresentationBody.holderDid = didDocId; - tempSignPresentationBody.verificationMethodId = verificationMethodId; - tempSignPresentationBody.privateKeyMultibase = privateKeyMultibase; + tempSignPresentationBody.holderDid = holderDidDocument.id; + tempSignPresentationBody.verificationMethodId = holderDidDocument.verificationMethod[0].id; + tempSignPresentationBody.privateKeyMultibase = holdersPrivateKeyMultibase; tempSignPresentationBody['holderDidDocSigned'] = signedDocument; return hypersignVP.sign(tempSignPresentationBody).catch(function (err) { (0, chai_1.expect)(function () { @@ -396,51 +396,56 @@ describe('Verifiable Presentation Operataions', () => { }); }); }); - // it('should not be able to sign presentation as either holderDid or holderDidDocSigned is required but passed both', async function () { - // const tempSignPresentationBody = { ...signPresentationBody }; - // tempSignPresentationBody.privateKeyMultibase = privateKeyMultibase; - // tempSignPresentationBody.presentation = {} as IVerifiablePresentation; - // return hypersignVP.sign(tempSignPresentationBody).catch(function (err) { - // expect(function () { - // throw err; - // }).to.throw(Error, 'HID-SSI-SDK:: params.presentation is required for signinng a presentation'); - // }); - // }); - it('should not be able to sign presentation as challenge is not passed', function () { + it('should not be able to sign presentation as either holderDid or holderDidDocSigned is required but passed both', function () { return __awaiter(this, void 0, void 0, function* () { const tempSignPresentationBody = Object.assign({}, signPresentationBody); tempSignPresentationBody.privateKeyMultibase = privateKeyMultibase; + tempSignPresentationBody.presentation = {}; + tempSignPresentationBody.verificationMethodId = holderDidDocument.verificationMethod[0].id; + tempSignPresentationBody.holderDid = holderDidDocument.id; + return hypersignVP.sign(tempSignPresentationBody).catch(function (err) { + (0, chai_1.expect)(function () { + throw err; + }).to.throw(Error, 'HID-SSI-SDK:: params.presentation is required for signing a presentation'); + }); + }); + }); + it('should not be able to sign presentation as challenge is not passed', function () { + return __awaiter(this, void 0, void 0, function* () { + const tempSignPresentationBody = Object.assign({}, signPresentationBody); + tempSignPresentationBody.privateKeyMultibase = holdersPrivateKeyMultibase; tempSignPresentationBody.presentation = unsignedverifiablePresentation; tempSignPresentationBody.challenge = ''; return hypersignVP.sign(tempSignPresentationBody).catch(function (err) { (0, chai_1.expect)(function () { throw err; - }).to.throw(Error, 'HID-SSI-SDK:: params.challenge is required for signinng a presentation'); + }).to.throw(Error, 'HID-SSI-SDK:: params.challenge is required for signing a presentation'); }); }); }); it('should not be able to sign presentation as verificationMethodId is not passed', function () { return __awaiter(this, void 0, void 0, function* () { const tempSignPresentationBody = Object.assign({}, signPresentationBody); - tempSignPresentationBody.privateKeyMultibase = privateKeyMultibase; + tempSignPresentationBody.privateKeyMultibase = holdersPrivateKeyMultibase; tempSignPresentationBody.presentation = unsignedverifiablePresentation; tempSignPresentationBody.challenge = challenge; tempSignPresentationBody.verificationMethodId = ''; return hypersignVP.sign(tempSignPresentationBody).catch(function (err) { (0, chai_1.expect)(function () { throw err; - }).to.throw(Error, 'HID-SSI-SDK:: params.verificationMethodId is required for signinng a presentation'); + }).to.throw(Error, 'HID-SSI-SDK:: params.verificationMethodId is required for signing a presentation'); }); }); }); it('should be able a sign presentation document', () => __awaiter(void 0, void 0, void 0, function* () { const tempSignPresentationBody = Object.assign({}, signPresentationBody); tempSignPresentationBody.presentation = unsignedverifiablePresentation; - tempSignPresentationBody.holderDid = didDocId; - tempSignPresentationBody.verificationMethodId = verificationMethodId; - tempSignPresentationBody.privateKeyMultibase = privateKeyMultibase; + tempSignPresentationBody.holderDid = holderDidDocument.id; + tempSignPresentationBody.verificationMethodId = holderDidDocument.verificationMethod[0].id; + tempSignPresentationBody.privateKeyMultibase = holdersPrivateKeyMultibase; + tempSignPresentationBody.challenge = "abc"; + tempSignPresentationBody['domain'] = "http://xyz.com"; signedVerifiablePresentation = yield hypersignVP.sign(tempSignPresentationBody); - // console.log(JSON.stringify(signedVerifiablePresentation, null, 2)); (0, chai_1.should)().exist(signedVerifiablePresentation['@context']); (0, chai_1.should)().exist(signedVerifiablePresentation['type']); (0, chai_1.expect)(signedVerifiablePresentation.type[0]).to.be.equal('VerifiablePresentation'); @@ -451,8 +456,8 @@ describe('Verifiable Presentation Operataions', () => { describe('#verify() method to verify a signed presentation document', () => { const verifyPresentationBody = { signedPresentation: signedVerifiablePresentation, - holderDid: didDocId, - holderVerificationMethodId: verificationMethodId, + holderDid: '', + holderVerificationMethodId: '', issuerVerificationMethodId: verificationMethodId, privateKey: privateKeyMultibase, challenge, @@ -462,8 +467,8 @@ describe('Verifiable Presentation Operataions', () => { return __awaiter(this, void 0, void 0, function* () { const tempverifyPresentationBody = Object.assign({}, verifyPresentationBody); tempverifyPresentationBody.signedPresentation = signedVerifiablePresentation; - tempverifyPresentationBody.holderDid = didDocId; - tempverifyPresentationBody.holderVerificationMethodId = verificationMethodId; + tempverifyPresentationBody.holderDid = holderDidDocument.id; + tempverifyPresentationBody.holderVerificationMethodId = holderDidDocument.verificationMethod[0].id; tempverifyPresentationBody.issuerVerificationMethodId = verificationMethodId; tempverifyPresentationBody.privateKey = privateKeyMultibase; tempverifyPresentationBody['holderDidDocSigned'] = signedDocument; @@ -515,7 +520,7 @@ describe('Verifiable Presentation Operataions', () => { const tempverifyPresentationBody = Object.assign({}, verifyPresentationBody); tempverifyPresentationBody.issuerDid = didDocId; tempverifyPresentationBody.challenge = challenge; - tempverifyPresentationBody.holderVerificationMethodId = verificationMethodId; + tempverifyPresentationBody.holderVerificationMethodId = holderDidDocument.verificationMethod[0].id; tempverifyPresentationBody.issuerVerificationMethodId = ''; return hypersignVP.verify(tempverifyPresentationBody).catch(function (err) { (0, chai_1.expect)(function () { @@ -524,25 +529,86 @@ describe('Verifiable Presentation Operataions', () => { }); }); }); - it('should be able a verify sgned presentation document', () => __awaiter(void 0, void 0, void 0, function* () { + it('should not be able to verify presentation as challenge used at the time of verification is different than challenge used in vp sign and getting presentation verification result false', function () { + return __awaiter(this, void 0, void 0, function* () { + const tempverifyPresentationBody = Object.assign({}, verifyPresentationBody); + tempverifyPresentationBody.signedPresentation = signedVerifiablePresentation; + tempverifyPresentationBody.issuerDid = didDocId; + tempverifyPresentationBody.holderDid = holderDidDocument.id; + tempverifyPresentationBody.challenge = "abczshdsfhgk"; + tempverifyPresentationBody['domain'] = "http://xyz.com"; + tempverifyPresentationBody.holderVerificationMethodId = holderDidDocument.verificationMethod[0].id; + tempverifyPresentationBody.issuerVerificationMethodId = verificationMethodId; + const verifiedPresentationDetail = yield hypersignVP.verify(tempverifyPresentationBody); + (0, chai_1.expect)(verifiedPresentationDetail.verified).to.be.equal(false); + (0, chai_1.expect)(verifiedPresentationDetail.presentationResult.verified).to.be.equal(false); + (0, chai_1.expect)(verifiedPresentationDetail.credentialResults[0].verified).to.be.equal(true); + }); + }); + it('should not be able to verify presentation as domain used at the time of vp verification is differ than domain used in vp sign and getting presentation verification result false', function () { + return __awaiter(this, void 0, void 0, function* () { + const tempverifyPresentationBody = Object.assign({}, verifyPresentationBody); + tempverifyPresentationBody.signedPresentation = signedVerifiablePresentation; + tempverifyPresentationBody.issuerDid = didDocId; + tempverifyPresentationBody.holderDid = holderDidDocument.id; + tempverifyPresentationBody.challenge = "abc"; + tempverifyPresentationBody['domain'] = "http://xyz1.com"; + tempverifyPresentationBody.holderVerificationMethodId = holderDidDocument.verificationMethod[0].id; + tempverifyPresentationBody.issuerVerificationMethodId = verificationMethodId; + const verifiedPresentationDetail = yield hypersignVP.verify(tempverifyPresentationBody); + (0, chai_1.expect)(verifiedPresentationDetail.verified).to.be.equal(false); + (0, chai_1.expect)(verifiedPresentationDetail.presentationResult.verified).to.be.equal(false); + (0, chai_1.expect)(verifiedPresentationDetail.credentialResults[0].verified).to.be.equal(true); + }); + }); + it('should be able to verify signed presentation document', () => __awaiter(void 0, void 0, void 0, function* () { const tempverifyPresentationBody = Object.assign({}, verifyPresentationBody); tempverifyPresentationBody.signedPresentation = signedVerifiablePresentation; tempverifyPresentationBody.issuerDid = didDocId; - tempverifyPresentationBody.holderDid = didDocId; - tempverifyPresentationBody.holderVerificationMethodId = verificationMethodId; + tempverifyPresentationBody.holderDid = holderDidDocument.id; + tempverifyPresentationBody.holderVerificationMethodId = holderDidDocument.verificationMethod[0].id; tempverifyPresentationBody.issuerVerificationMethodId = verificationMethodId; - tempverifyPresentationBody.challenge = didDocId; + tempverifyPresentationBody.challenge = "abc"; + tempverifyPresentationBody['domain'] = "http://xyz.com"; const verifiedPresentationDetail = yield hypersignVP.verify(tempverifyPresentationBody); - // console.log(JSON.stringify(verifiedPresentationDetail, null, 2)); (0, chai_1.should)().exist(verifiedPresentationDetail.verified); (0, chai_1.expect)(verifiedPresentationDetail.verified).to.be.equal(true); + (0, chai_1.expect)(verifiedPresentationDetail.presentationResult.verified).to.be.equal(true); (0, chai_1.expect)(verifiedPresentationDetail).to.be.a('object'); - (0, chai_1.should)().exist(verifiedPresentationDetail.results); - (0, chai_1.expect)(verifiedPresentationDetail.results).to.be.a('array'); (0, chai_1.should)().exist(verifiedPresentationDetail.credentialResults); (0, chai_1.expect)(verifiedPresentationDetail.credentialResults).to.be.a('array'); + (0, chai_1.should)().exist(verifiedPresentationDetail.credentialResults[0].results); + (0, chai_1.expect)(verifiedPresentationDetail.credentialResults[0].results).to.be.a('array'); (0, chai_1.expect)(verifiedPresentationDetail.credentialResults[0].verified).to.be.equal(true); (0, chai_1.expect)(verifiedPresentationDetail.credentialResults[0].credentialId).to.be.equal(credentialId); })); + it('should be able a sign and verify a presentation without domain', () => __awaiter(void 0, void 0, void 0, function* () { + const signPresentationBody = { + presentation: unsignedverifiablePresentation, + holderDid: holderDidDocument.id, + verificationMethodId: holderDidDocument.verificationMethod[0].id, + privateKeyMultibase: holdersPrivateKeyMultibase, + challenge: "abcd", + domain: "http://xyz.com" + }; + signedVerifiablePresentation = yield hypersignVP.sign(signPresentationBody); + (0, chai_1.should)().exist(signedVerifiablePresentation['@context']); + (0, chai_1.should)().exist(signedVerifiablePresentation['type']); + (0, chai_1.expect)(signedVerifiablePresentation.type[0]).to.be.equal('VerifiablePresentation'); + (0, chai_1.should)().exist(signedVerifiablePresentation['verifiableCredential']); + (0, chai_1.expect)(signedVerifiablePresentation.id).to.be.equal(verifiableCredentialPresentationId); + const verifyPresentationBody = { + signedPresentation: signedVerifiablePresentation, + holderDid: holderDidDocument.id, + holderVerificationMethodId: holderDidDocument.verificationMethod[0].id, + issuerVerificationMethodId: verificationMethodId, + privateKey: privateKeyMultibase, + challenge: "abcd", + issuerDid: didDocId, + domain: "http://xyz.com" + }; + const verifiedPresentationDetail = yield hypersignVP.verify(verifyPresentationBody); + console.log(verifiedPresentationDetail); + })); }); }); diff --git a/build/src/tests/presentation/vpByClientSpec.spec.d.ts b/build/src/tests/presentation/vpByClientSpec.spec.d.ts new file mode 100644 index 0000000..4ff8b80 --- /dev/null +++ b/build/src/tests/presentation/vpByClientSpec.spec.d.ts @@ -0,0 +1,2 @@ +export {}; +//# sourceMappingURL=vpByClientSpec.spec.d.ts.map \ No newline at end of file diff --git a/build/src/tests/presentation/vpByClientSpec.spec.d.ts.map b/build/src/tests/presentation/vpByClientSpec.spec.d.ts.map new file mode 100644 index 0000000..1640be4 --- /dev/null +++ b/build/src/tests/presentation/vpByClientSpec.spec.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"vpByClientSpec.spec.d.ts","sourceRoot":"","sources":["../../../../src/tests/presentation/vpByClientSpec.spec.ts"],"names":[],"mappings":""} \ No newline at end of file diff --git a/build/src/tests/presentation/vpByClientSpec.spec.js b/build/src/tests/presentation/vpByClientSpec.spec.js new file mode 100644 index 0000000..b349251 --- /dev/null +++ b/build/src/tests/presentation/vpByClientSpec.spec.js @@ -0,0 +1,477 @@ +"use strict"; +var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { + function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } + return new (P || (P = Promise))(function (resolve, reject) { + function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } + function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } + function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } + step((generator = generator.apply(thisArg, _arguments || [])).next()); + }); +}; +var __importDefault = (this && this.__importDefault) || function (mod) { + return (mod && mod.__esModule) ? mod : { "default": mod }; +}; +Object.defineProperty(exports, "__esModule", { value: true }); +const chai_1 = require("chai"); +const index_1 = require("../../index"); +const config_1 = require("../config"); +const web3_1 = __importDefault(require("web3")); +const did_1 = require("../../../libs/generated/ssi/did"); +let holderDidDoc; +let holderVmId; +let hypersignDID; +let hypersignVC; +let offlineSigner; +let privateKeyMultibase; +let publicKeyMultibase; +let issuerDidDocument; +let didDocId; +let issuerVerificationMethodId; +let unsignedverifiablePresentation; +let signedVerifiablePresentation; +let hypersignPresentation; +let signedDocument; +let vpId; +const challenge = '1231231231'; +const domain = 'www.adbv.com'; +let credentialDetail; +let credentialId; +let verificationMethodId; +const holderDid = "did:hid:testnet:0xec437f1b8DCe95e7094D04A38665AB6f2A1D47ec"; +const credentialBody = { + // schemaId: '', + schemaContext: ["https://schema.org"], + type: ["Person"], + subjectDid: '', + issuerDid: '', + fields: { name: 'Varsha' }, +}; +let account; +let mmKeyPair; +let web3; +beforeEach(function () { + return __awaiter(this, void 0, void 0, function* () { + offlineSigner = yield (0, config_1.createWallet)(config_1.mnemonic); + const params = { + offlineSigner, + nodeRestEndpoint: config_1.hidNodeEp.rest, + nodeRpcEndpoint: config_1.hidNodeEp.rpc, + namespace: config_1.hidNodeEp.namespace, + }; + const provider = new web3_1.default.providers.HttpProvider(config_1.metamaskProvider); + web3 = new web3_1.default(provider); + account = web3.eth.accounts.create(); + // account= account.address + hypersignDID = new index_1.HypersignDID(params); + yield hypersignDID.init(); + hypersignVC = new index_1.HypersignVerifiableCredential(params); + yield hypersignVC.init(); + hypersignPresentation = new index_1.HypersignVerifiablePresentation(params); + }); +}); +// Generate public and private key pair +describe('#generateKeys() method to generate publicKyeMultibase and privateKeyMultiBase', function () { + it('should return publickeyMultibase and privateKeyMultibase', function () { + return __awaiter(this, void 0, void 0, function* () { + const kp = yield hypersignDID.generateKeys(); + privateKeyMultibase = kp.privateKeyMultibase; + publicKeyMultibase = kp.publicKeyMultibase; + (0, chai_1.expect)(kp).to.be.a('object'); + (0, chai_1.should)().exist(kp.privateKeyMultibase); + (0, chai_1.should)().exist(kp.publicKeyMultibase); + }); + }); +}); +describe('DID Opearations', () => { + describe('#generate() to generate did', function () { + it('should be able to generate didDocument', function () { + return __awaiter(this, void 0, void 0, function* () { + issuerDidDocument = yield hypersignDID.generate({ publicKeyMultibase }); + didDocId = issuerDidDocument['id']; + issuerVerificationMethodId = issuerDidDocument['verificationMethod'][0].id; + (0, chai_1.expect)(issuerDidDocument).to.be.a('object'); + (0, chai_1.should)().exist(issuerDidDocument['@context']); + (0, chai_1.should)().exist(issuerDidDocument['id']); + (0, chai_1.should)().exist(issuerDidDocument['controller']); + (0, chai_1.should)().exist(issuerDidDocument['alsoKnownAs']); + (0, chai_1.should)().exist(issuerDidDocument['verificationMethod']); + (0, chai_1.expect)(issuerDidDocument['verificationMethod'] && + issuerDidDocument['authentication'] && + issuerDidDocument['assertionMethod'] && + issuerDidDocument['keyAgreement'] && + issuerDidDocument['capabilityInvocation'] && + issuerDidDocument['capabilityDelegation'] && + issuerDidDocument['service']).to.be.a('array'); + (0, chai_1.should)().exist(issuerDidDocument['authentication']); + (0, chai_1.should)().exist(issuerDidDocument['assertionMethod']); + (0, chai_1.should)().exist(issuerDidDocument['keyAgreement']); + (0, chai_1.should)().exist(issuerDidDocument['capabilityInvocation']); + (0, chai_1.should)().exist(issuerDidDocument['capabilityDelegation']); + (0, chai_1.should)().exist(issuerDidDocument['service']); + }); + }); + it('should be able to generated did for holder using metamask', function () { + return __awaiter(this, void 0, void 0, function* () { + holderDidDoc = yield hypersignDID.createByClientSpec({ methodSpecificId: account.address, address: account.address, chainId: '0x1', clientSpec: 'eth-personalSign' }); + holderVmId = holderDidDoc.verificationMethod[0].id; + }); + }); + }); +}); +// describe('#sign() this is to sign didDoc', function () { +// const controller = { +// '@context': '', +// id: '', +// authentication: [], +// }; +// it('should able to sign did document', async function () { +// const didDoc = JSON.parse(JSON.stringify(issuerDidDocument)); +// const params = { +// privateKeyMultibase: privateKeyMultibase as string, +// challenge: challenge as string, +// domain: domain as string, +// did: '', +// didDocument: didDoc as object, +// verificationMethodId: issuerVerificationMethodId as string, +// controller, +// }; +// signedDocument = await hypersignDID.sign(params); +// expect(signedDocument).to.be.a('object'); +// should().exist(signedDocument['@context']); +// should().exist(signedDocument['id']); +// expect(didDocId).to.be.equal(signedDocument['id']); +// should().exist(signedDocument['controller']); +// should().exist(signedDocument['alsoKnownAs']); +// should().exist(signedDocument['verificationMethod']); +// should().exist(signedDocument['authentication']); +// should().exist(signedDocument['assertionMethod']); +// should().exist(signedDocument['keyAgreement']); +// should().exist(signedDocument['capabilityInvocation']); +// should().exist(signedDocument['capabilityDelegation']); +// should().exist(signedDocument['service']); +// should().exist(signedDocument['proof']); +// }); +// }); +describe('#register() this is to register did on the blockchain', function () { + it('should be able to register didDocument for issuer on the blockchain', function () { + return __awaiter(this, void 0, void 0, function* () { + const result = yield hypersignDID.register({ didDocument: issuerDidDocument, privateKeyMultibase, verificationMethodId: issuerVerificationMethodId }); + (0, chai_1.should)().exist(result.transactionHash); + (0, chai_1.should)().exist(result.didDocument); + }); + }); + it('should be able to register didDocument for holder on the blockchain', function () { + return __awaiter(this, void 0, void 0, function* () { + const address = account.address; + const signature = web3.eth.accounts.sign(holderDidDoc, account.privateKey); + const created = new Date(new Date().getTime() - 100000).toISOString().slice(0, -5) + 'Z'; + const signInfo = [{ + verification_method_id: holderVmId, + signature: signature.signature, + created, + clientSpec: { type: 'eth-personalSign' } + }]; + const result = yield hypersignDID.registerByClientSpec({ didDocument: holderDidDoc, signInfos: signInfo }); + (0, chai_1.should)().exist(result.transactionHash); + (0, chai_1.should)().exist(result.didDocument); + // const sign = await signDid(holderDidDoc, "eth-personalSign", holderVmId, account) + // console.log(sign) + }); + }); +}); +// return +// /** +// * Test cases related to credential +// */ +describe('Verifiable Credential Opearations', () => { + describe('#getCredential() method to generate a credential', function () { + it('should be able to generate new credential using schemacontext', function () { + return __awaiter(this, void 0, void 0, function* () { + const expirationDate = new Date('12/11/2027'); + const tempCredentialBody = Object.assign({}, credentialBody); + // tempCredentialBody.schemaId = schemaId; + tempCredentialBody.subjectDid = holderDid; + tempCredentialBody['expirationDate'] = expirationDate; + tempCredentialBody.issuerDid = didDocId; + tempCredentialBody.fields = { name: 'varsha' }; + credentialDetail = yield hypersignVC.generate(tempCredentialBody); + // console.log(JSON.stringify(credentialDetail, null, 2)); + (0, chai_1.expect)(credentialDetail).to.be.a('object'); + (0, chai_1.should)().exist(credentialDetail['@context']); + (0, chai_1.should)().exist(credentialDetail['id']); + credentialId = credentialDetail.id; + (0, chai_1.should)().exist(credentialDetail['type']); + (0, chai_1.should)().exist(credentialDetail['expirationDate']); + (0, chai_1.should)().exist(credentialDetail['issuanceDate']); + (0, chai_1.should)().exist(credentialDetail['issuer']); + (0, chai_1.should)().exist(credentialDetail['credentialSubject']); + // should().exist(credentialDetail['credentialSchema']); + (0, chai_1.should)().exist(credentialDetail['credentialStatus']); + (0, chai_1.expect)(credentialDetail['credentialStatus'].type).to.be.equal('HypersignCredentialStatus2023'); + }); + }); + }); + describe('#issueCredential() method for issuing credential', function () { + it('should be able to issue credential with credential status registered on chain', function () { + return __awaiter(this, void 0, void 0, function* () { + const issuedCredResult = yield hypersignVC.issue({ + credential: credentialDetail, + issuerDid: didDocId, + verificationMethodId: `${didDocId}#key-1`, + privateKeyMultibase: privateKeyMultibase + }); + const { signedCredential, credentialStatus, credentialStatusProof, credentialStatusRegistrationResult } = issuedCredResult; + (0, chai_1.expect)(signedCredential).to.be.a('object'); + (0, chai_1.should)().exist(signedCredential['@context']); + (0, chai_1.should)().exist(signedCredential['id']); + (0, chai_1.should)().exist(signedCredential['type']); + (0, chai_1.should)().exist(signedCredential['expirationDate']); + (0, chai_1.should)().exist(signedCredential['issuanceDate']); + (0, chai_1.should)().exist(signedCredential['issuer']); + (0, chai_1.should)().exist(signedCredential['credentialSubject']); + // should().exist(signedCredential['credentialSchema']); + (0, chai_1.should)().exist(signedCredential['credentialStatus']); + (0, chai_1.should)().exist(signedCredential['proof']); + (0, chai_1.expect)(credentialStatus).to.be.a('object'); + (0, chai_1.should)().exist(credentialStatus['issuer']); + (0, chai_1.should)().exist(credentialStatus['issuanceDate']); + (0, chai_1.should)().exist(credentialStatus['revoked']); + (0, chai_1.should)().exist(credentialStatus['suspended']); + (0, chai_1.should)().exist(credentialStatus['remarks']); + (0, chai_1.should)().exist(credentialStatus['credentialMerkleRootHash']); + (0, chai_1.expect)(credentialStatusProof).to.be.a('object'); + (0, chai_1.should)().exist(credentialStatusProof['type']); + (0, chai_1.should)().exist(credentialStatusProof['created']); + (0, chai_1.should)().exist(credentialStatusProof['verificationMethod']); + (0, chai_1.should)().exist(credentialStatusProof['proofPurpose']); + (0, chai_1.should)().exist(credentialStatusProof['proofValue']); + (0, chai_1.expect)(credentialStatusRegistrationResult).to.be.a('object'); + (0, chai_1.should)().exist(credentialStatusRegistrationResult['code']); + (0, chai_1.should)().exist(credentialStatusRegistrationResult['height']); + (0, chai_1.should)().exist(credentialStatusRegistrationResult['transactionHash']); + (0, chai_1.should)().exist(credentialStatusRegistrationResult['gasUsed']); + (0, chai_1.should)().exist(credentialStatusRegistrationResult['gasWanted']); + }); + }); + }); +}); +// // /** +// // * Test cases related to verifiable presentation +// // */ +describe('Verifiable Presentation Operataions', () => { + describe('#generate() method to generate new presentation document', () => { + it('should be able to gnerate a new presentation document', () => __awaiter(void 0, void 0, void 0, function* () { + const presentationBody = { + verifiableCredentials: [credentialDetail], + holderDid: holderDid, + }; + const tempPresentationBody = Object.assign({}, presentationBody); + tempPresentationBody.verifiableCredentials[0] = credentialDetail; + tempPresentationBody.holderDid = holderDid; + unsignedverifiablePresentation = yield hypersignPresentation.generate(tempPresentationBody); + (0, chai_1.should)().exist(unsignedverifiablePresentation['@context']); + (0, chai_1.should)().exist(unsignedverifiablePresentation['type']); + (0, chai_1.expect)(unsignedverifiablePresentation.type[0]).to.be.equal('VerifiablePresentation'); + (0, chai_1.should)().exist(unsignedverifiablePresentation['verifiableCredential']); + (0, chai_1.expect)(unsignedverifiablePresentation.verifiableCredential).to.be.a('array'); + (0, chai_1.should)().exist(unsignedverifiablePresentation['id']); + (0, chai_1.should)().exist(unsignedverifiablePresentation['holder']); + vpId = unsignedverifiablePresentation.id; + })); + }); + describe('#signByClientSpec() method to sign presentation document', () => { + const signPresentationBody = { + presentation: unsignedverifiablePresentation, + holderDid: "", + verificationMethodId: "", + web3Obj: {}, + challenge, + }; + const web3 = new web3_1.default(); + it('should not be able to sign presentation as holderDid is required but not passed', function () { + return __awaiter(this, void 0, void 0, function* () { + const tempSignPresentationBody = Object.assign({}, signPresentationBody); + tempSignPresentationBody.holderDid = ''; + tempSignPresentationBody.presentation = unsignedverifiablePresentation; + tempSignPresentationBody.verificationMethodId = `${holderDid}#key-1`; + tempSignPresentationBody.web3Obj = web3; + return hypersignPresentation.signByClientSpec(tempSignPresentationBody).catch(function (err) { + (0, chai_1.expect)(function () { + throw err; + }).to.throw(Error, 'HID-SSI-SDK:: params.holderDid is required to sign a presentation'); + }); + }); + }); + it('should not be able to sign presentation as presentation is not passed', function () { + return __awaiter(this, void 0, void 0, function* () { + const tempSignPresentationBody = Object.assign({}, signPresentationBody); + tempSignPresentationBody.presentation = null; + tempSignPresentationBody.challenge = challenge; + tempSignPresentationBody.holderDid = holderDid; + return hypersignPresentation.signByClientSpec(tempSignPresentationBody).catch(function (err) { + (0, chai_1.expect)(function () { + throw err; + }).to.throw(Error, 'HID-SSI-SDK:: params.presentation is required for signing a presentation'); + }); + }); + }); + it('should not be able to sign presentation as challenge is not passed', function () { + return __awaiter(this, void 0, void 0, function* () { + const tempSignPresentationBody = Object.assign({}, signPresentationBody); + tempSignPresentationBody.presentation = unsignedverifiablePresentation; + tempSignPresentationBody.holderDid = holderDid; + tempSignPresentationBody.challenge = ''; + return hypersignPresentation.signByClientSpec(tempSignPresentationBody).catch(function (err) { + (0, chai_1.expect)(function () { + throw err; + }).to.throw(Error, 'HID-SSI-SDK:: params.challenge is required for signing a presentation'); + }); + }); + }); + it('should not be able to sign presentation as verificationMethodId is not passed', function () { + return __awaiter(this, void 0, void 0, function* () { + const tempSignPresentationBody = Object.assign({}, signPresentationBody); + tempSignPresentationBody.holderDid = holderDid; + tempSignPresentationBody.presentation = unsignedverifiablePresentation; + tempSignPresentationBody.challenge = challenge; + tempSignPresentationBody.verificationMethodId = ''; + return hypersignPresentation.signByClientSpec(tempSignPresentationBody).catch(function (err) { + (0, chai_1.expect)(function () { + throw err; + }).to.throw(Error, 'HID-SSI-SDK:: params.verificationMethodId is required for signing a presentation'); + }); + }); + }); + it('should not be able to sign presentation as web3 object is not passed', function () { + return __awaiter(this, void 0, void 0, function* () { + const tempSignPresentationBody = Object.assign({}, signPresentationBody); + tempSignPresentationBody.holderDid = holderDid; + tempSignPresentationBody.presentation = unsignedverifiablePresentation; + tempSignPresentationBody.challenge = challenge; + tempSignPresentationBody.verificationMethodId = issuerVerificationMethodId; + return hypersignPresentation.signByClientSpec(tempSignPresentationBody).catch(function (err) { + (0, chai_1.expect)(function () { + throw err; + }).to.throw(Error, 'HID-SSI-SDK:: Error: params.web3Obj is required to sign a presentation'); + }); + }); + }); + }); + describe('#verify() method to verify a signed presentation document', () => { + const verifyPresentationBody = { + signedPresentation: signedVerifiablePresentation, + challenge, + issuerDid: "", + holderDid: "", + holderDidDocSigned: did_1.DidDocument, + holderVerificationMethodId: "", + issuerVerificationMethodId: verificationMethodId, + web3Obj: {} + }; + it('should not be able to verify presentation as either holderDid or holderDidDocSigned is required but passed both', function () { + return __awaiter(this, void 0, void 0, function* () { + const tempverifyPresentationBody = Object.assign({}, verifyPresentationBody); + tempverifyPresentationBody.signedPresentation = signedVerifiablePresentation; + tempverifyPresentationBody.holderDid = holderDid; + tempverifyPresentationBody.holderVerificationMethodId = `${holderDid}#key-1`; + tempverifyPresentationBody.issuerVerificationMethodId = verificationMethodId; + tempverifyPresentationBody['holderDidDocSigned'] = did_1.DidDocument; + return hypersignPresentation.verifyByClientSpec(tempverifyPresentationBody).catch(function (err) { + (0, chai_1.expect)(function () { + throw err; + }).to.throw(Error, 'HID-SSI-SDK:: Either holderDid or holderDidDocSigned should be provided'); + }); + }); + }); + it('should not be able to verify presentation as issuerDid is null or empty', function () { + return __awaiter(this, void 0, void 0, function* () { + const tempverifyPresentationBody = Object.assign({}, verifyPresentationBody); + tempverifyPresentationBody.issuerDid = ''; + return hypersignPresentation.verifyByClientSpec(tempverifyPresentationBody).catch(function (err) { + (0, chai_1.expect)(function () { + throw err; + }).to.throw(Error, 'HID-SSI-SDK:: params.issuerDid is required for verifying a presentation'); + }); + }); + }); + it('should not be able to verify presentation as challenge is null or empty', function () { + return __awaiter(this, void 0, void 0, function* () { + const tempverifyPresentationBody = Object.assign({}, verifyPresentationBody); + tempverifyPresentationBody.issuerDid = issuerDidDocument.id; + tempverifyPresentationBody.challenge = ''; + return hypersignPresentation.verifyByClientSpec(tempverifyPresentationBody).catch(function (err) { + (0, chai_1.expect)(function () { + throw err; + }).to.throw(Error, 'HID-SSI-SDK:: params.challenge is required for verifying a presentation'); + }); + }); + }); + it('should not be able to verify presentation as holderVerificationMethodId is null or empty', function () { + return __awaiter(this, void 0, void 0, function* () { + const tempverifyPresentationBody = Object.assign({}, verifyPresentationBody); + tempverifyPresentationBody.issuerDid = didDocId; + tempverifyPresentationBody.challenge = challenge; + tempverifyPresentationBody.holderVerificationMethodId = ''; + return hypersignPresentation.verifyByClientSpec(tempverifyPresentationBody).catch(function (err) { + (0, chai_1.expect)(function () { + throw err; + }).to.throw(Error, 'HID-SSI-SDK:: params.holderVerificationMethodId is required for verifying a presentation'); + }); + }); + }); + it('should not be able to verify presentation as issuerVerificationMethodId is null or empty', function () { + return __awaiter(this, void 0, void 0, function* () { + const tempverifyPresentationBody = Object.assign({}, verifyPresentationBody); + tempverifyPresentationBody.issuerDid = didDocId; + tempverifyPresentationBody.challenge = challenge; + tempverifyPresentationBody.holderVerificationMethodId = `${holderDid}#key-1`; + tempverifyPresentationBody.issuerVerificationMethodId = ''; + return hypersignPresentation.verifyByClientSpec(tempverifyPresentationBody).catch(function (err) { + (0, chai_1.expect)(function () { + throw err; + }).to.throw(Error, 'HID-SSI-SDK:: params.issuerVerificationMethodId is required for verifying a presentation'); + }); + }); + }); + it('should not be able to verify presentation as web3Obj is null or empty', function () { + return __awaiter(this, void 0, void 0, function* () { + const web3 = new web3_1.default(); + const tempverifyPresentationBody = Object.assign({}, verifyPresentationBody); + tempverifyPresentationBody.issuerDid = didDocId; + tempverifyPresentationBody.challenge = challenge; + tempverifyPresentationBody.holderVerificationMethodId = `${holderDid}#key-1`; + tempverifyPresentationBody.issuerVerificationMethodId = issuerVerificationMethodId; + tempverifyPresentationBody.web3Obj = {}; + return hypersignPresentation.verifyByClientSpec(tempverifyPresentationBody).catch(function (err) { + (0, chai_1.expect)(function () { + throw err; + }).to.throw(Error, 'HID-SSI-SDK:: Error: params.web3Obj is required to verify a presentation'); + }); + }); + }); + it('should be able a verify signed presentation document', () => __awaiter(void 0, void 0, void 0, function* () { + signedVerifiablePresentation = yield (0, config_1.generatePresentationProof)(unsignedverifiablePresentation, challenge, holderDid, [`${holderDid}#key-1`], `${holderDid}#key-1`); + // const verificationResult = await verifyPresentation(signedVerifiablePresentation, challenge, holderDid) + // console.log(verificationResult) + const web3 = yield (0, config_1.generateWeb3Obj)(); + const tempverifyPresentationBody = Object.assign({}, verifyPresentationBody); + tempverifyPresentationBody.signedPresentation = signedVerifiablePresentation; + tempverifyPresentationBody.issuerDid = issuerDidDocument.id; + tempverifyPresentationBody.holderDid = holderDid; + tempverifyPresentationBody.holderVerificationMethodId = `${holderDid}#key-1`; + tempverifyPresentationBody.issuerVerificationMethodId = issuerVerificationMethodId; + tempverifyPresentationBody.challenge = challenge; + tempverifyPresentationBody.web3Obj = web3; + const verifiedPresentationDetail = yield hypersignPresentation.verifyByClientSpec(tempverifyPresentationBody); + (0, chai_1.should)().exist(verifiedPresentationDetail.verified); + (0, chai_1.expect)(verifiedPresentationDetail.verified).to.be.equal(true); + (0, chai_1.expect)(verifiedPresentationDetail).to.be.a('object'); + (0, chai_1.should)().exist(verifiedPresentationDetail.results); + (0, chai_1.expect)(verifiedPresentationDetail.results).to.be.a('array'); + (0, chai_1.should)().exist(verifiedPresentationDetail.credentialResults); + (0, chai_1.expect)(verifiedPresentationDetail.credentialResults).to.be.a('array'); + (0, chai_1.expect)(verifiedPresentationDetail.credentialResults[0].verified).to.be.equal(true); + (0, chai_1.expect)(verifiedPresentationDetail.credentialResults[0].credentialId).to.be.equal(credentialId); + })); + }); +}); diff --git a/build/src/tests/schema/schema.spec.js b/build/src/tests/schema/schema.spec.js index 474ef3f..1446aa7 100644 --- a/build/src/tests/schema/schema.spec.js +++ b/build/src/tests/schema/schema.spec.js @@ -12,35 +12,37 @@ Object.defineProperty(exports, "__esModule", { value: true }); const chai_1 = require("chai"); const index_1 = require("../../index"); const config_1 = require("../config"); -let hsSdk; +let signedSchema2; +let invalidSchemaNamedSignedSchema1; +let invalidSchemaNamedSignedSchema2; +let invalidSchemaNamedSignedSchema3; let privateKeyMultibase; let publicKeyMultibase; let verificationMethodId; let didDocument; let didDocId; let offlineSigner; -let schemaSignature; let hypersignSchema; let schemaObject; +let schemaObject2; let schemaId; let verificationMethod; +let randomProperty; let hypersignDID; let signedSchema; const signSchema = {}; -signSchema.proof = {}; +signSchema['proof'] = {}; const schemaBody = { - name: 'testSchema', + name: 'TestSchema', description: 'This is a test schema generation', author: '', - fields: [{ name: 'name', type: 'integer', isRequired: false }], + fields: [{ name: 'name', type: 'string', isRequired: true }], additionalProperties: false, }; //add mnemonic of wallet that have balance beforeEach(function () { return __awaiter(this, void 0, void 0, function* () { offlineSigner = yield (0, config_1.createWallet)(config_1.mnemonic); - // hsSdk = new HypersignSSISdk(offlineSigner, hidNodeEp.rpc, hidNodeEp.rest, hidNodeEp.namespace); - // await hsSdk.init(); hypersignSchema = new index_1.HypersignSchema({ // entityApiSecretKey, offlineSigner, @@ -123,7 +125,47 @@ describe('#generate() method to create schema', function () { }).to.throw(Error, 'HID-SSI-SDK:: Error: Author must be passed'); }); }); - it('should able to create a new schema without offlinesigner', function () { + it('should not be able to create a new schema as schema name is in camelCase and only pascalCase is allowed', function () { + const tempSchemaBody = Object.assign({}, schemaBody); + tempSchemaBody.author = didDocId; + tempSchemaBody['name'] = 'testSchema'; + return hypersignSchema.generate(tempSchemaBody).catch(function (err) { + (0, chai_1.expect)(function () { + throw err; + }).to.throw(Error, 'HID-SSI-SDK:: Error: schema name should always be in PascalCase'); + }); + }); + it('should not be able to create a schema as schema name is in snakeCase and only pascalCase is allowed', function () { + const tempSchemaBody = Object.assign({}, schemaBody); + tempSchemaBody.author = didDocId; + tempSchemaBody['name'] = 'testing_schema'; + return hypersignSchema.generate(tempSchemaBody).catch(function (err) { + (0, chai_1.expect)(function () { + throw err; + }).to.throw(Error, 'HID-SSI-SDK:: Error: schema name should always be in PascalCase'); + }); + }); + it('should not be able to create a schema as schema name is not in pascalCase', function () { + const tempSchemaBody = Object.assign({}, schemaBody); + tempSchemaBody.author = didDocId; + tempSchemaBody['name'] = 'Test credential Schema'; + return hypersignSchema.generate(tempSchemaBody).catch(function (err) { + (0, chai_1.expect)(function () { + throw err; + }).to.throw(Error, 'HID-SSI-SDK:: Error: schema name should always be in PascalCase'); + }); + }); + it("should not be able to create a schema as sub-property 'name' is not present in field property", function () { + const tempSchemaBody = Object.assign({}, schemaBody); + tempSchemaBody.author = didDocId; + tempSchemaBody['fields'] = [{ isRequired: true }]; + return hypersignSchema.generate(tempSchemaBody).catch(function (err) { + (0, chai_1.expect)(function () { + throw err; + }).to.throw(Error, "HID-SSI-SDK:: Error: All fields must contains property 'name'"); + }); + }); + it('should be able to create a new schema without offlinesigner', function () { return __awaiter(this, void 0, void 0, function* () { const tempSchemaBody = Object.assign({}, schemaBody); tempSchemaBody.author = didDocId; @@ -142,7 +184,7 @@ describe('#generate() method to create schema', function () { (0, chai_1.expect)(schemaDoc['author']).to.be.equal(tempSchemaBody.author); }); }); - it('should able to create a new schema', function () { + it('should be able to create a new schema', function () { return __awaiter(this, void 0, void 0, function* () { const tempSchemaBody = Object.assign({}, schemaBody); tempSchemaBody.author = didDocId; @@ -161,16 +203,175 @@ describe('#generate() method to create schema', function () { (0, chai_1.expect)(schemaObject['author']).to.be.equal(tempSchemaBody.author); }); }); + it('should be able to create a schema with differnt field value', function () { + return __awaiter(this, void 0, void 0, function* () { + const tempSchemaBody = Object.assign({}, schemaBody); + tempSchemaBody.fields.push({ name: 'address', type: 'string', isRequired: false }); + tempSchemaBody.author = didDocId; + schemaObject2 = yield hypersignSchema.generate(tempSchemaBody); + (0, chai_1.expect)(schemaObject).to.be.a('object'); + (0, chai_1.should)().exist(schemaObject['type']); + (0, chai_1.should)().exist(schemaObject['modelVersion']); + (0, chai_1.should)().exist(schemaObject['id']); + (0, chai_1.should)().exist(schemaObject['name']); + (0, chai_1.should)().exist(schemaObject['author']); + (0, chai_1.should)().exist(schemaObject['authored']); + (0, chai_1.should)().exist(schemaObject['schema']); + (0, chai_1.expect)(schemaObject.schema).to.be.a('object'); + (0, chai_1.expect)(schemaObject['name']).to.be.equal(tempSchemaBody.name); + (0, chai_1.expect)(schemaObject['author']).to.be.equal(tempSchemaBody.author); + }); + }); }); +// dont allow fields other than { name: 'name', type: 'string', isRequired: false } describe('#sign() function to sign schema', function () { + it('should not be able to sign a new schema as privateKeyMultibase is not passed', function () { + return hypersignSchema.sign({ + privateKeyMultibase: "", + schema: schemaObject, + verificationMethodId: didDocument['assertionMethod'][0] + }).catch(function (err) { + (0, chai_1.expect)(function () { + throw err; + }).to.throw(Error, 'HID-SSI-SDK:: Error: params.privateKeyMultibase must be passed'); + }); + }); + it('should not be able to sign a new schema as verificationMethodId is not passed', function () { + return hypersignSchema.sign({ + privateKeyMultibase, + schema: schemaObject, + verificationMethodId: "" + }).catch(function (err) { + (0, chai_1.expect)(function () { + throw err; + }).to.throw(Error, 'HID-SSI-SDK:: Error: params.verificationMethodId must be passed'); + }); + }); + it('should not be able to sign a new schema as schema is not passed', function () { + return hypersignSchema.sign({ + privateKeyMultibase, + verificationMethodId: didDocument['assertionMethod'][0] + }).catch(function (err) { + (0, chai_1.expect)(function () { + throw err; + }).to.throw(Error, 'HID-SSI-SDK:: Error: Schema must be passed'); + }); + }); it('should be able to sign newly created schema', function () { return __awaiter(this, void 0, void 0, function* () { + const tempSchemaBody = JSON.parse(JSON.stringify(schemaObject)); signedSchema = yield hypersignSchema.sign({ privateKeyMultibase: privateKeyMultibase, - schema: schemaObject, + schema: tempSchemaBody, + verificationMethodId: didDocument['assertionMethod'][0], + }); + (0, chai_1.expect)(signedSchema).to.be.a('object'); + (0, chai_1.should)().exist(signedSchema.proof); + (0, chai_1.should)().exist(signedSchema.proof.type); + (0, chai_1.should)().exist(signedSchema.proof.verificationMethod); + (0, chai_1.should)().exist(signedSchema.proof.proofPurpose); + (0, chai_1.should)().exist(signedSchema.proof.proofValue); + (0, chai_1.should)().exist(signedSchema.proof.created); + (0, chai_1.should)().exist(signedSchema.type); + (0, chai_1.should)().exist(signedSchema.modelVersion); + (0, chai_1.should)().exist(signedSchema.author); + (0, chai_1.should)().exist(signedSchema['id']); + (0, chai_1.should)().exist(signedSchema['name']); + (0, chai_1.should)().exist(signedSchema['author']); + (0, chai_1.should)().exist(signedSchema['authored']); + (0, chai_1.should)().exist(signedSchema['schema']); + }); + }); + it('should be able to sign newly created schema with schema name is in camelCase', function () { + return __awaiter(this, void 0, void 0, function* () { + const tempSchemaBody = JSON.parse(JSON.stringify(schemaObject2)); + tempSchemaBody['name'] = "testSchema"; + invalidSchemaNamedSignedSchema1 = yield hypersignSchema.sign({ + privateKeyMultibase: privateKeyMultibase, + schema: tempSchemaBody, + verificationMethodId: didDocument['assertionMethod'][0], + }); + (0, chai_1.expect)(signedSchema).to.be.a('object'); + (0, chai_1.should)().exist(signedSchema.proof); + (0, chai_1.should)().exist(signedSchema.proof.type); + (0, chai_1.should)().exist(signedSchema.proof.verificationMethod); + (0, chai_1.should)().exist(signedSchema.proof.proofPurpose); + (0, chai_1.should)().exist(signedSchema.proof.proofValue); + (0, chai_1.should)().exist(signedSchema.proof.created); + (0, chai_1.should)().exist(signedSchema.type); + (0, chai_1.should)().exist(signedSchema.modelVersion); + (0, chai_1.should)().exist(signedSchema.author); + (0, chai_1.should)().exist(signedSchema['id']); + (0, chai_1.should)().exist(signedSchema['name']); + (0, chai_1.should)().exist(signedSchema['author']); + (0, chai_1.should)().exist(signedSchema['authored']); + (0, chai_1.should)().exist(signedSchema['schema']); + }); + }); + it('should be able to sign newly created schema with schema name is in snakeCase', function () { + return __awaiter(this, void 0, void 0, function* () { + const tempSchemaBody = JSON.parse(JSON.stringify(schemaObject2)); + tempSchemaBody['name'] = "test_schema"; + invalidSchemaNamedSignedSchema2 = yield hypersignSchema.sign({ + privateKeyMultibase: privateKeyMultibase, + schema: tempSchemaBody, + verificationMethodId: didDocument['assertionMethod'][0], + }); + (0, chai_1.expect)(signedSchema).to.be.a('object'); + (0, chai_1.should)().exist(signedSchema.proof); + (0, chai_1.should)().exist(signedSchema.proof.type); + (0, chai_1.should)().exist(signedSchema.proof.verificationMethod); + (0, chai_1.should)().exist(signedSchema.proof.proofPurpose); + (0, chai_1.should)().exist(signedSchema.proof.proofValue); + (0, chai_1.should)().exist(signedSchema.proof.created); + (0, chai_1.should)().exist(signedSchema.type); + (0, chai_1.should)().exist(signedSchema.modelVersion); + (0, chai_1.should)().exist(signedSchema.author); + (0, chai_1.should)().exist(signedSchema['id']); + (0, chai_1.should)().exist(signedSchema['name']); + (0, chai_1.should)().exist(signedSchema['author']); + (0, chai_1.should)().exist(signedSchema['authored']); + (0, chai_1.should)().exist(signedSchema['schema']); + }); + }); + it('should be able to sign newly created schema with schema name is in sentanceCase', function () { + return __awaiter(this, void 0, void 0, function* () { + const tempSchemaBody = JSON.parse(JSON.stringify(schemaObject2)); + tempSchemaBody['name'] = "Test Schema"; + invalidSchemaNamedSignedSchema3 = yield hypersignSchema.sign({ + privateKeyMultibase: privateKeyMultibase, + schema: tempSchemaBody, + verificationMethodId: didDocument['assertionMethod'][0], + }); + (0, chai_1.expect)(signedSchema).to.be.a('object'); + (0, chai_1.should)().exist(signedSchema.proof); + (0, chai_1.should)().exist(signedSchema.proof.type); + (0, chai_1.should)().exist(signedSchema.proof.verificationMethod); + (0, chai_1.should)().exist(signedSchema.proof.proofPurpose); + (0, chai_1.should)().exist(signedSchema.proof.proofValue); + (0, chai_1.should)().exist(signedSchema.proof.created); + (0, chai_1.should)().exist(signedSchema.type); + (0, chai_1.should)().exist(signedSchema.modelVersion); + (0, chai_1.should)().exist(signedSchema.author); + (0, chai_1.should)().exist(signedSchema['id']); + (0, chai_1.should)().exist(signedSchema['name']); + (0, chai_1.should)().exist(signedSchema['author']); + (0, chai_1.should)().exist(signedSchema['authored']); + (0, chai_1.should)().exist(signedSchema['schema']); + }); + }); + it('should be able to sign newly created schema with invalid sub-property of propert field', function () { + return __awaiter(this, void 0, void 0, function* () { + const tempSchemaBody = JSON.parse(JSON.stringify(schemaObject2)); + const prop = JSON.parse(tempSchemaBody.schema.properties); + randomProperty = "randomProperty"; + prop[`${schemaBody.fields[0].name}`]['randomProperty'] = "xyz"; + tempSchemaBody['schema'].properties = JSON.stringify(prop); + signedSchema2 = yield hypersignSchema.sign({ + privateKeyMultibase: privateKeyMultibase, + schema: tempSchemaBody, verificationMethodId: didDocument['assertionMethod'][0], }); - //onsole.log(JSON.stringify(signedSchema, null, 2)) (0, chai_1.expect)(signedSchema).to.be.a('object'); (0, chai_1.should)().exist(signedSchema.proof); (0, chai_1.should)().exist(signedSchema.proof.type); @@ -256,12 +457,68 @@ describe('#register() function to register schema on blockchain', function () { })); it('should be able to register schema on blockchain', function () { return __awaiter(this, void 0, void 0, function* () { + console.log(signedSchema); const registeredSchema = yield hypersignSchema.register({ schema: signedSchema, }); (0, chai_1.should)().exist(registeredSchema.transactionHash); }); }); + it('should not be able to register schema on blockchain as its already registered', function () { + return __awaiter(this, void 0, void 0, function* () { + return hypersignSchema.register({ + schema: signedSchema, + }).catch(function (err) { + (0, chai_1.expect)(function () { + throw err; + }).to.throw(Error, `failed to execute message; message index: 0: Schema ID: ${schemaId}: schema already exists`); + }); + }); + }); + it('should not be able to register schema as schema name is in camel case which is not valid', function () { + return __awaiter(this, void 0, void 0, function* () { + return hypersignSchema.register({ + schema: invalidSchemaNamedSignedSchema1, + }).catch(function (err) { + (0, chai_1.expect)(function () { + throw err; + }).to.throw(Error, `failed to execute message; message index: 0: name must always be in PascalCase: ${invalidSchemaNamedSignedSchema1.name}: invalid credential schema`); + }); + }); + }); + it('should not be able to register schema as schema name is in snake case which is not valid', function () { + return __awaiter(this, void 0, void 0, function* () { + return hypersignSchema.register({ + schema: invalidSchemaNamedSignedSchema2, + }).catch(function (err) { + (0, chai_1.expect)(function () { + throw err; + }).to.throw(Error, `failed to execute message; message index: 0: name must always be in PascalCase: ${invalidSchemaNamedSignedSchema2.name}: invalid credential schema`); + }); + }); + }); + it('should not be able to register schema as schema name is in sentance case which is not valid', function () { + return __awaiter(this, void 0, void 0, function* () { + return hypersignSchema.register({ + schema: invalidSchemaNamedSignedSchema3, + }).catch(function (err) { + (0, chai_1.expect)(function () { + throw err; + }).to.throw(Error, `failed to execute message; message index: 0: name must always be in PascalCase: ${invalidSchemaNamedSignedSchema3.name}: invalid credential schema`); + }); + }); + }); + it('should not be able to register schema as there is a invalid sub-property in side property field', function () { + return __awaiter(this, void 0, void 0, function* () { + return hypersignSchema.register({ + schema: signedSchema2, + }).catch(function (err) { + (0, chai_1.expect)(function () { + throw err; + }).to.throw(Error, `failed to execute message; message index: 0: invalid \`property\` provided: invalid sub-attribute ${randomProperty} of attribute name. Only \`type\` and \`format\` sub-attributes are permitted: invalid credential schema`); + }); + }); + }); }); describe('#resolve() this is to resolve schema', function () { it('should not able to resolve schema and throw error didDocId is not passed', function () { diff --git a/build/src/tests/schema/schemaByEntityApiKey.spec.js b/build/src/tests/schema/schemaByEntityApiKey.spec.js index d53f9bc..3c94315 100644 --- a/build/src/tests/schema/schemaByEntityApiKey.spec.js +++ b/build/src/tests/schema/schemaByEntityApiKey.spec.js @@ -28,9 +28,6 @@ let hypersignDID; let hypersignSchema; let verificationMethod; let schemaDoc; -// const entityApiSecretKey = -// '8fc3d16ce8f040fd2fc4e5ccc1d73.6b6e55d4d54cd90c85bbcc92d9469873e60c0d7878681223e2fe63fca3abafb63390f939a77b3d73bf2eb58a654810b38'; -const entityApiSecret = "69b91e007904228e3313e586ba695.bc7705956989e43bbd7060e845c2763a381cbc80f935ac848119b8c2d7d00616346eeb74efe22a0ff140506a0c6157ef6"; const schemaBody = { name: 'schema for university student registration', description: 'This is a test schema generated for student registration', @@ -276,7 +273,7 @@ describe('Schema test scenario with entityApiSecretKey', () => { })); it('Should be able to register schema using entitApiSecretKey', () => __awaiter(void 0, void 0, void 0, function* () { const hypersignSchema = new schema_1.default({ - entityApiSecretKey: entityApiSecret, + entityApiSecretKey: config_1.entityApiSecret, nodeRestEndpoint: config_1.hidNodeEp.rest, nodeRpcEndpoint: config_1.hidNodeEp.rpc, namespace: config_1.hidNodeEp.namespace, diff --git a/build/src/tests/vp.spec.d.ts.map b/build/src/tests/vp.spec.d.ts.map deleted file mode 100644 index 93a1c37..0000000 --- a/build/src/tests/vp.spec.d.ts.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"vp.spec.d.ts","sourceRoot":"","sources":["../../../src/tests/vp.spec.ts"],"names":[],"mappings":""} \ No newline at end of file diff --git a/build/src/utils.d.ts b/build/src/utils.d.ts index 1d986f4..e69820e 100644 --- a/build/src/utils.d.ts +++ b/build/src/utils.d.ts @@ -1,4 +1,4 @@ -import { Did } from '../libs/generated/ssi/did'; +import { DidDocument as Did } from '../libs/generated/ssi/did'; export default class Utils { static getUUID(): Promise; static checkUrl(url: string): string; @@ -6,22 +6,10 @@ export default class Utils { static _decodeMbKey(header: any, key: any): Uint8Array; static _decodeMbPubKey(header: any, key: any): string; static _bufToMultibase(pubKeyBuf: Uint8Array): string; - static convertedStableLibKeysIntoEd25519verificationkey2020(stableLibKp: { - privKey?: Uint8Array; - publicKey?: string; - }): { - publicKeyMultibase: string; - privateKeyMultibase: string; - }; - static convertEd25519verificationkey2020toStableLibKeysInto(ed255192020VerKeys: { - privKey?: string; - publicKey?: string; - }): { - publicKeyMultibase: string; - privateKeyMultibase: string; - }; static jsonToLdConvertor(json: any): Did; static ldToJsonConvertor(ld: any): {}; static getFee(): string; + static removeEmptyString(obj: object): object; + static fetchFee(methodName: string, baseUrl: any): Promise; } //# sourceMappingURL=utils.d.ts.map \ No newline at end of file diff --git a/build/src/utils.d.ts.map b/build/src/utils.d.ts.map index e0d7f88..fa406db 100644 --- a/build/src/utils.d.ts.map +++ b/build/src/utils.d.ts.map @@ -1 +1 @@ -{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,2BAA2B,CAAC;AAKhD,MAAM,CAAC,OAAO,OAAO,KAAK;WACJ,OAAO,IAAI,OAAO,CAAC,MAAM,CAAC;WAShC,QAAQ,CAAC,GAAG,EAAE,MAAM;IASlC,MAAM,CAAC,YAAY,CAAC,MAAM,KAAA,EAAE,GAAG,KAAA;IAO/B,MAAM,CAAC,YAAY,CAAC,MAAM,KAAA,EAAE,GAAG,KAAA;IAM/B,MAAM,CAAC,eAAe,CAAC,MAAM,KAAA,EAAE,GAAG,KAAA;WAMpB,eAAe,CAAC,SAAS,EAAE,UAAU;WAMrC,oDAAoD,CAAC,WAAW,EAAE;QAC9E,OAAO,CAAC,EAAE,UAAU,CAAC;QACrB,SAAS,CAAC,EAAE,MAAM,CAAC;KACpB,GAAG;QAAE,kBAAkB,EAAE,MAAM,CAAC;QAAC,mBAAmB,EAAE,MAAM,CAAA;KAAE;WAqBjD,oDAAoD,CAAC,kBAAkB,EAAE;QACrF,OAAO,CAAC,EAAE,MAAM,CAAC;QACjB,SAAS,CAAC,EAAE,MAAM,CAAC;KACpB,GAAG;QAAE,kBAAkB,EAAE,MAAM,CAAC;QAAC,mBAAmB,EAAE,MAAM,CAAA;KAAE;WAwBjD,iBAAiB,CAAC,IAAI,EAAE,GAAG;WAY3B,iBAAiB,CAAC,EAAE,EAAE,GAAG;WAazB,MAAM;CAGrB"} \ No newline at end of file +{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,IAAI,GAAG,EAAE,MAAM,2BAA2B,CAAC;AAK/D,MAAM,CAAC,OAAO,OAAO,KAAK;WACJ,OAAO,IAAI,OAAO,CAAC,MAAM,CAAC;WAMhC,QAAQ,CAAC,GAAG,EAAE,MAAM;IASlC,MAAM,CAAC,YAAY,CAAC,MAAM,KAAA,EAAE,GAAG,KAAA;IAO/B,MAAM,CAAC,YAAY,CAAC,MAAM,KAAA,EAAE,GAAG,KAAA;IAM/B,MAAM,CAAC,eAAe,CAAC,MAAM,KAAA,EAAE,GAAG,KAAA;WAMpB,eAAe,CAAC,SAAS,EAAE,UAAU;WAKrC,iBAAiB,CAAC,IAAI,EAAE,GAAG;WAY3B,iBAAiB,CAAC,EAAE,EAAE,GAAG;WAazB,MAAM;WAIN,iBAAiB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM;WAwBhC,QAAQ,CAAC,UAAU,EAAE,MAAM,EAAC,OAAO,KAAA;CAYxD"} \ No newline at end of file diff --git a/build/src/utils.js b/build/src/utils.js index 20a1410..5bcaba0 100644 --- a/build/src/utils.js +++ b/build/src/utils.js @@ -40,10 +40,7 @@ class Utils { return __awaiter(this, void 0, void 0, function* () { const edKeyPair = yield ed25519_verification_key_2020_1.Ed25519VerificationKey2020.generate(); const exportedKp = yield edKeyPair.export({ publicKey: true }); - const { publicKeyMultibase: publicKeyMultibase1 } = this.convertEd25519verificationkey2020toStableLibKeysInto({ - publicKey: exportedKp.publicKeyMultibase, - }); - return publicKeyMultibase1; + return exportedKp.publicKeyMultibase; }); } static checkUrl(url) { @@ -74,35 +71,6 @@ class Utils { static _bufToMultibase(pubKeyBuf) { return 'z' + encode(pubKeyBuf); } - // Converting 45byte public key to 48 by padding header - // Converting 88byte private key to 91 by padding header - static convertedStableLibKeysIntoEd25519verificationkey2020(stableLibKp) { - const result = {}; - if (stableLibKp.publicKey) { - const stableLibPubKeyWithoutZ = stableLibKp.publicKey.substr(1); - const stableLibPubKeyWithoutZDecode = decode(stableLibPubKeyWithoutZ); - result['publicKeyMultibase'] = Utils._encodeMbKey(constants.KEY_HEADERS.MULTICODEC_ED25519_PUB_HEADER, stableLibPubKeyWithoutZDecode); - } - if (stableLibKp.privKey) { - result['privateKeyMultibase'] = Utils._encodeMbKey(constants.KEY_HEADERS.MULTICODEC_ED25519_PRIV_HEADER, stableLibKp.privKey); - } - return result; - } - static convertEd25519verificationkey2020toStableLibKeysInto(ed255192020VerKeys) { - const result = {}; - if (ed255192020VerKeys.publicKey) { - const stableLibPubKeyWithoutZ = ed255192020VerKeys.publicKey.substr(1); - const stableLibPubKeyWithoutZDecode = decode(stableLibPubKeyWithoutZ); - result['publicKeyMultibase'] = Utils._decodeMbPubKey(constants.KEY_HEADERS.MULTICODEC_ED25519_PUB_HEADER, stableLibPubKeyWithoutZDecode); - } - // privateKeyMultibase = z + encode(header+original) - if (ed255192020VerKeys.privKey) { - const stableLibPrivKeyWithoutZ = ed255192020VerKeys.privKey.substr(1); - const stableLibPrivKeyWithoutZDecode = decode(stableLibPrivKeyWithoutZ); - result['privateKeyMultibase'] = Utils._decodeMbKey(constants.KEY_HEADERS.MULTICODEC_ED25519_PRIV_HEADER, stableLibPrivKeyWithoutZDecode); - } - return result; - } static jsonToLdConvertor(json) { const ld = {}; for (const key in json) { @@ -131,5 +99,47 @@ class Utils { static getFee() { return 'auto'; } + static removeEmptyString(obj) { + if (Array.isArray(obj)) { + for (let i = obj.length - 1; i >= 0; i--) { + if (obj[i] === '' || (typeof obj[i] === 'object' && Object.keys(obj[i]).length === 0)) { + obj.splice(i, 1); + } + else if (typeof obj[i] === 'object') { + this.removeEmptyString(obj[i]); + } + } + } + else if (typeof obj === 'object' && obj !== null) { + for (const key in obj) { + if (Object.prototype.hasOwnProperty.call(obj, key)) { + if (obj[key] === '') { + delete obj[key]; + } + else if (Array.isArray(obj[key])) { + this.removeEmptyString(obj[key]); + } + else if (typeof obj[key] === 'object') { + this.removeEmptyString(obj[key]); + } + } + } + } + return obj; + } + static fetchFee(methodName, baseUrl) { + return __awaiter(this, void 0, void 0, function* () { + const url = constants.GAS_FEE_API_URL(baseUrl); + const feeStructure = yield fetch(url); + const fee = yield feeStructure.json(); + if (fee && fee[methodName]) { + const amount = fee[methodName].amount; + return amount; + } + else { + throw new Error(`Fee not found for method: ${methodName}`); + } + }); + } } exports.default = Utils; diff --git a/libs/generated/ssi/client/enums.ts b/libs/generated/ssi/client/enums.ts new file mode 100644 index 0000000..5398451 --- /dev/null +++ b/libs/generated/ssi/client/enums.ts @@ -0,0 +1,213 @@ +/* eslint-disable */ + +export const protobufPackage = "hypersign.ssi.client"; + +/** The messages defined here are meant only meant for TS client. */ + +export enum VerificationMethodRelationships { + authentication = "authentication", + assertionMethod = "assertionMethod", + keyAgreement = "keyAgreement", + capabilityInvocation = "capabilityInvocation", + capabilityDelegation = "capabilityDelegation", +} + +export function verificationMethodRelationshipsFromJSON(object: any): VerificationMethodRelationships { + switch (object) { + case 0: + case "authentication": + return VerificationMethodRelationships.authentication; + case 1: + case "assertionMethod": + return VerificationMethodRelationships.assertionMethod; + case 2: + case "keyAgreement": + return VerificationMethodRelationships.keyAgreement; + case 3: + case "capabilityInvocation": + return VerificationMethodRelationships.capabilityInvocation; + case 4: + case "capabilityDelegation": + return VerificationMethodRelationships.capabilityDelegation; + default: + throw new globalThis.Error("Unrecognized enum value " + object + " for enum VerificationMethodRelationships"); + } +} + +export function verificationMethodRelationshipsToJSON(object: VerificationMethodRelationships): string { + switch (object) { + case VerificationMethodRelationships.authentication: + return "authentication"; + case VerificationMethodRelationships.assertionMethod: + return "assertionMethod"; + case VerificationMethodRelationships.keyAgreement: + return "keyAgreement"; + case VerificationMethodRelationships.capabilityInvocation: + return "capabilityInvocation"; + case VerificationMethodRelationships.capabilityDelegation: + return "capabilityDelegation"; + default: + throw new globalThis.Error("Unrecognized enum value " + object + " for enum VerificationMethodRelationships"); + } +} + +export function verificationMethodRelationshipsToNumber(object: VerificationMethodRelationships): number { + switch (object) { + case VerificationMethodRelationships.authentication: + return 0; + case VerificationMethodRelationships.assertionMethod: + return 1; + case VerificationMethodRelationships.keyAgreement: + return 2; + case VerificationMethodRelationships.capabilityInvocation: + return 3; + case VerificationMethodRelationships.capabilityDelegation: + return 4; + default: + throw new globalThis.Error("Unrecognized enum value " + object + " for enum VerificationMethodRelationships"); + } +} + +export enum VerificationMethodTypes { + Ed25519VerificationKey2020 = "Ed25519VerificationKey2020", + EcdsaSecp256k1VerificationKey2019 = "EcdsaSecp256k1VerificationKey2019", + EcdsaSecp256k1RecoveryMethod2020 = "EcdsaSecp256k1RecoveryMethod2020", + X25519KeyAgreementKey2020 = "X25519KeyAgreementKey2020", + X25519KeyAgreementKeyEIP5630 = "X25519KeyAgreementKeyEIP5630", + Bls12381G2Key2020 = "Bls12381G2Key2020", + BabyJubJubKey2021 = "BabyJubJubKey2021", +} + +export function verificationMethodTypesFromJSON(object: any): VerificationMethodTypes { + switch (object) { + case 0: + case "Ed25519VerificationKey2020": + return VerificationMethodTypes.Ed25519VerificationKey2020; + case 1: + case "EcdsaSecp256k1VerificationKey2019": + return VerificationMethodTypes.EcdsaSecp256k1VerificationKey2019; + case 2: + case "EcdsaSecp256k1RecoveryMethod2020": + return VerificationMethodTypes.EcdsaSecp256k1RecoveryMethod2020; + case 3: + case "X25519KeyAgreementKey2020": + return VerificationMethodTypes.X25519KeyAgreementKey2020; + case 4: + case "X25519KeyAgreementKeyEIP5630": + return VerificationMethodTypes.X25519KeyAgreementKeyEIP5630; + case 5: + case "Bls12381G2Key2020": + return VerificationMethodTypes.Bls12381G2Key2020; + case 6: + case "BabyJubJubKey2021": + return VerificationMethodTypes.BabyJubJubKey2021; + default: + throw new globalThis.Error("Unrecognized enum value " + object + " for enum VerificationMethodTypes"); + } +} + +export function verificationMethodTypesToJSON(object: VerificationMethodTypes): string { + switch (object) { + case VerificationMethodTypes.Ed25519VerificationKey2020: + return "Ed25519VerificationKey2020"; + case VerificationMethodTypes.EcdsaSecp256k1VerificationKey2019: + return "EcdsaSecp256k1VerificationKey2019"; + case VerificationMethodTypes.EcdsaSecp256k1RecoveryMethod2020: + return "EcdsaSecp256k1RecoveryMethod2020"; + case VerificationMethodTypes.X25519KeyAgreementKey2020: + return "X25519KeyAgreementKey2020"; + case VerificationMethodTypes.X25519KeyAgreementKeyEIP5630: + return "X25519KeyAgreementKeyEIP5630"; + case VerificationMethodTypes.Bls12381G2Key2020: + return "Bls12381G2Key2020"; + case VerificationMethodTypes.BabyJubJubKey2021: + return "BabyJubJubKey2021"; + default: + throw new globalThis.Error("Unrecognized enum value " + object + " for enum VerificationMethodTypes"); + } +} + +export function verificationMethodTypesToNumber(object: VerificationMethodTypes): number { + switch (object) { + case VerificationMethodTypes.Ed25519VerificationKey2020: + return 0; + case VerificationMethodTypes.EcdsaSecp256k1VerificationKey2019: + return 1; + case VerificationMethodTypes.EcdsaSecp256k1RecoveryMethod2020: + return 2; + case VerificationMethodTypes.X25519KeyAgreementKey2020: + return 3; + case VerificationMethodTypes.X25519KeyAgreementKeyEIP5630: + return 4; + case VerificationMethodTypes.Bls12381G2Key2020: + return 5; + case VerificationMethodTypes.BabyJubJubKey2021: + return 6; + default: + throw new globalThis.Error("Unrecognized enum value " + object + " for enum VerificationMethodTypes"); + } +} + +export enum ProofTypes { + Ed25519Signature2020 = "Ed25519Signature2020", + EcdsaSecp256k1Signature2019 = "EcdsaSecp256k1Signature2019", + EcdsaSecp256k1RecoverySignature2020 = "EcdsaSecp256k1RecoverySignature2020", + BJJSignature2021 = "BJJSignature2021", + BbsBlsSignature2020 = "BbsBlsSignature2020", +} + +export function proofTypesFromJSON(object: any): ProofTypes { + switch (object) { + case 0: + case "Ed25519Signature2020": + return ProofTypes.Ed25519Signature2020; + case 1: + case "EcdsaSecp256k1Signature2019": + return ProofTypes.EcdsaSecp256k1Signature2019; + case 2: + case "EcdsaSecp256k1RecoverySignature2020": + return ProofTypes.EcdsaSecp256k1RecoverySignature2020; + case 3: + case "BJJSignature2021": + return ProofTypes.BJJSignature2021; + case 4: + case "BbsBlsSignature2020": + return ProofTypes.BbsBlsSignature2020; + default: + throw new globalThis.Error("Unrecognized enum value " + object + " for enum ProofTypes"); + } +} + +export function proofTypesToJSON(object: ProofTypes): string { + switch (object) { + case ProofTypes.Ed25519Signature2020: + return "Ed25519Signature2020"; + case ProofTypes.EcdsaSecp256k1Signature2019: + return "EcdsaSecp256k1Signature2019"; + case ProofTypes.EcdsaSecp256k1RecoverySignature2020: + return "EcdsaSecp256k1RecoverySignature2020"; + case ProofTypes.BJJSignature2021: + return "BJJSignature2021"; + case ProofTypes.BbsBlsSignature2020: + return "BbsBlsSignature2020"; + default: + throw new globalThis.Error("Unrecognized enum value " + object + " for enum ProofTypes"); + } +} + +export function proofTypesToNumber(object: ProofTypes): number { + switch (object) { + case ProofTypes.Ed25519Signature2020: + return 0; + case ProofTypes.EcdsaSecp256k1Signature2019: + return 1; + case ProofTypes.EcdsaSecp256k1RecoverySignature2020: + return 2; + case ProofTypes.BJJSignature2021: + return 3; + case ProofTypes.BbsBlsSignature2020: + return 4; + default: + throw new globalThis.Error("Unrecognized enum value " + object + " for enum ProofTypes"); + } +} diff --git a/libs/generated/ssi/clientSpec.ts b/libs/generated/ssi/clientSpec.ts deleted file mode 100644 index d1397cb..0000000 --- a/libs/generated/ssi/clientSpec.ts +++ /dev/null @@ -1,99 +0,0 @@ -/* eslint-disable */ -import { Writer, Reader } from "protobufjs/minimal"; - -export const protobufPackage = "hypersignprotocol.hidnode.ssi"; - -export interface ClientSpec { - type: string; - adr036SignerAddress: string; -} - -const baseClientSpec: object = { type: "", adr036SignerAddress: "" }; - -export const ClientSpec = { - encode(message: ClientSpec, writer: Writer = Writer.create()): Writer { - if (message.type !== "") { - writer.uint32(10).string(message.type); - } - if (message.adr036SignerAddress !== "") { - writer.uint32(18).string(message.adr036SignerAddress); - } - return writer; - }, - - decode(input: Reader | Uint8Array, length?: number): ClientSpec { - const reader = input instanceof Uint8Array ? new Reader(input) : input; - let end = length === undefined ? reader.len : reader.pos + length; - const message = { ...baseClientSpec } as ClientSpec; - while (reader.pos < end) { - const tag = reader.uint32(); - switch (tag >>> 3) { - case 1: - message.type = reader.string(); - break; - case 2: - message.adr036SignerAddress = reader.string(); - break; - default: - reader.skipType(tag & 7); - break; - } - } - return message; - }, - - fromJSON(object: any): ClientSpec { - const message = { ...baseClientSpec } as ClientSpec; - if (object.type !== undefined && object.type !== null) { - message.type = String(object.type); - } else { - message.type = ""; - } - if ( - object.adr036SignerAddress !== undefined && - object.adr036SignerAddress !== null - ) { - message.adr036SignerAddress = String(object.adr036SignerAddress); - } else { - message.adr036SignerAddress = ""; - } - return message; - }, - - toJSON(message: ClientSpec): unknown { - const obj: any = {}; - message.type !== undefined && (obj.type = message.type); - message.adr036SignerAddress !== undefined && - (obj.adr036SignerAddress = message.adr036SignerAddress); - return obj; - }, - - fromPartial(object: DeepPartial): ClientSpec { - const message = { ...baseClientSpec } as ClientSpec; - if (object.type !== undefined && object.type !== null) { - message.type = object.type; - } else { - message.type = ""; - } - if ( - object.adr036SignerAddress !== undefined && - object.adr036SignerAddress !== null - ) { - message.adr036SignerAddress = object.adr036SignerAddress; - } else { - message.adr036SignerAddress = ""; - } - return message; - }, -}; - -type Builtin = Date | Function | Uint8Array | string | number | undefined; -export type DeepPartial = T extends Builtin - ? T - : T extends Array - ? Array> - : T extends ReadonlyArray - ? ReadonlyArray> - : T extends {} - ? { [K in keyof T]?: DeepPartial } - : Partial; diff --git a/libs/generated/ssi/client_spec.ts b/libs/generated/ssi/client_spec.ts new file mode 100644 index 0000000..ebbc453 --- /dev/null +++ b/libs/generated/ssi/client_spec.ts @@ -0,0 +1,51 @@ +/* eslint-disable */ + +export const protobufPackage = "hypersign.ssi.v1"; + +export enum ClientSpecType { + CLIENT_SPEC_TYPE_NONE = "CLIENT_SPEC_TYPE_NONE", + CLIENT_SPEC_TYPE_COSMOS_ADR036 = "CLIENT_SPEC_TYPE_COSMOS_ADR036", + CLIENT_SPEC_TYPE_ETH_PERSONAL_SIGN = "CLIENT_SPEC_TYPE_ETH_PERSONAL_SIGN", +} + +export function clientSpecTypeFromJSON(object: any): ClientSpecType { + switch (object) { + case 0: + case "CLIENT_SPEC_TYPE_NONE": + return ClientSpecType.CLIENT_SPEC_TYPE_NONE; + case 1: + case "CLIENT_SPEC_TYPE_COSMOS_ADR036": + return ClientSpecType.CLIENT_SPEC_TYPE_COSMOS_ADR036; + case 2: + case "CLIENT_SPEC_TYPE_ETH_PERSONAL_SIGN": + return ClientSpecType.CLIENT_SPEC_TYPE_ETH_PERSONAL_SIGN; + default: + throw new globalThis.Error("Unrecognized enum value " + object + " for enum ClientSpecType"); + } +} + +export function clientSpecTypeToJSON(object: ClientSpecType): string { + switch (object) { + case ClientSpecType.CLIENT_SPEC_TYPE_NONE: + return "CLIENT_SPEC_TYPE_NONE"; + case ClientSpecType.CLIENT_SPEC_TYPE_COSMOS_ADR036: + return "CLIENT_SPEC_TYPE_COSMOS_ADR036"; + case ClientSpecType.CLIENT_SPEC_TYPE_ETH_PERSONAL_SIGN: + return "CLIENT_SPEC_TYPE_ETH_PERSONAL_SIGN"; + default: + throw new globalThis.Error("Unrecognized enum value " + object + " for enum ClientSpecType"); + } +} + +export function clientSpecTypeToNumber(object: ClientSpecType): number { + switch (object) { + case ClientSpecType.CLIENT_SPEC_TYPE_NONE: + return 0; + case ClientSpecType.CLIENT_SPEC_TYPE_COSMOS_ADR036: + return 1; + case ClientSpecType.CLIENT_SPEC_TYPE_ETH_PERSONAL_SIGN: + return 2; + default: + throw new globalThis.Error("Unrecognized enum value " + object + " for enum ClientSpecType"); + } +} diff --git a/libs/generated/ssi/credential.ts b/libs/generated/ssi/credential.ts deleted file mode 100644 index ee85a38..0000000 --- a/libs/generated/ssi/credential.ts +++ /dev/null @@ -1,577 +0,0 @@ -/* eslint-disable */ -import { Writer, Reader } from "protobufjs/minimal"; - -export const protobufPackage = "hypersignprotocol.hidnode.ssi"; - -export interface Claim { - id: string; - currentStatus: string; - statusReason: string; -} - -export interface CredentialStatus { - claim: Claim | undefined; - issuer: string; - issuanceDate: string; - expirationDate: string; - credentialHash: string; -} - -export interface CredentialProof { - type: string; - created: string; - updated: string; - verificationMethod: string; - proofPurpose: string; - proofValue: string; -} - -export interface Credential { - claim: Claim | undefined; - issuer: string; - issuanceDate: string; - expirationDate: string; - credentialHash: string; - proof: CredentialProof | undefined; -} - -const baseClaim: object = { id: "", currentStatus: "", statusReason: "" }; - -export const Claim = { - encode(message: Claim, writer: Writer = Writer.create()): Writer { - if (message.id !== "") { - writer.uint32(10).string(message.id); - } - if (message.currentStatus !== "") { - writer.uint32(18).string(message.currentStatus); - } - if (message.statusReason !== "") { - writer.uint32(26).string(message.statusReason); - } - return writer; - }, - - decode(input: Reader | Uint8Array, length?: number): Claim { - const reader = input instanceof Uint8Array ? new Reader(input) : input; - let end = length === undefined ? reader.len : reader.pos + length; - const message = { ...baseClaim } as Claim; - while (reader.pos < end) { - const tag = reader.uint32(); - switch (tag >>> 3) { - case 1: - message.id = reader.string(); - break; - case 2: - message.currentStatus = reader.string(); - break; - case 3: - message.statusReason = reader.string(); - break; - default: - reader.skipType(tag & 7); - break; - } - } - return message; - }, - - fromJSON(object: any): Claim { - const message = { ...baseClaim } as Claim; - if (object.id !== undefined && object.id !== null) { - message.id = String(object.id); - } else { - message.id = ""; - } - if (object.currentStatus !== undefined && object.currentStatus !== null) { - message.currentStatus = String(object.currentStatus); - } else { - message.currentStatus = ""; - } - if (object.statusReason !== undefined && object.statusReason !== null) { - message.statusReason = String(object.statusReason); - } else { - message.statusReason = ""; - } - return message; - }, - - toJSON(message: Claim): unknown { - const obj: any = {}; - message.id !== undefined && (obj.id = message.id); - message.currentStatus !== undefined && - (obj.currentStatus = message.currentStatus); - message.statusReason !== undefined && - (obj.statusReason = message.statusReason); - return obj; - }, - - fromPartial(object: DeepPartial): Claim { - const message = { ...baseClaim } as Claim; - if (object.id !== undefined && object.id !== null) { - message.id = object.id; - } else { - message.id = ""; - } - if (object.currentStatus !== undefined && object.currentStatus !== null) { - message.currentStatus = object.currentStatus; - } else { - message.currentStatus = ""; - } - if (object.statusReason !== undefined && object.statusReason !== null) { - message.statusReason = object.statusReason; - } else { - message.statusReason = ""; - } - return message; - }, -}; - -const baseCredentialStatus: object = { - issuer: "", - issuanceDate: "", - expirationDate: "", - credentialHash: "", -}; - -export const CredentialStatus = { - encode(message: CredentialStatus, writer: Writer = Writer.create()): Writer { - if (message.claim !== undefined) { - Claim.encode(message.claim, writer.uint32(10).fork()).ldelim(); - } - if (message.issuer !== "") { - writer.uint32(18).string(message.issuer); - } - if (message.issuanceDate !== "") { - writer.uint32(26).string(message.issuanceDate); - } - if (message.expirationDate !== "") { - writer.uint32(34).string(message.expirationDate); - } - if (message.credentialHash !== "") { - writer.uint32(42).string(message.credentialHash); - } - return writer; - }, - - decode(input: Reader | Uint8Array, length?: number): CredentialStatus { - const reader = input instanceof Uint8Array ? new Reader(input) : input; - let end = length === undefined ? reader.len : reader.pos + length; - const message = { ...baseCredentialStatus } as CredentialStatus; - while (reader.pos < end) { - const tag = reader.uint32(); - switch (tag >>> 3) { - case 1: - message.claim = Claim.decode(reader, reader.uint32()); - break; - case 2: - message.issuer = reader.string(); - break; - case 3: - message.issuanceDate = reader.string(); - break; - case 4: - message.expirationDate = reader.string(); - break; - case 5: - message.credentialHash = reader.string(); - break; - default: - reader.skipType(tag & 7); - break; - } - } - return message; - }, - - fromJSON(object: any): CredentialStatus { - const message = { ...baseCredentialStatus } as CredentialStatus; - if (object.claim !== undefined && object.claim !== null) { - message.claim = Claim.fromJSON(object.claim); - } else { - message.claim = undefined; - } - if (object.issuer !== undefined && object.issuer !== null) { - message.issuer = String(object.issuer); - } else { - message.issuer = ""; - } - if (object.issuanceDate !== undefined && object.issuanceDate !== null) { - message.issuanceDate = String(object.issuanceDate); - } else { - message.issuanceDate = ""; - } - if (object.expirationDate !== undefined && object.expirationDate !== null) { - message.expirationDate = String(object.expirationDate); - } else { - message.expirationDate = ""; - } - if (object.credentialHash !== undefined && object.credentialHash !== null) { - message.credentialHash = String(object.credentialHash); - } else { - message.credentialHash = ""; - } - return message; - }, - - toJSON(message: CredentialStatus): unknown { - const obj: any = {}; - message.claim !== undefined && - (obj.claim = message.claim ? Claim.toJSON(message.claim) : undefined); - message.issuer !== undefined && (obj.issuer = message.issuer); - message.issuanceDate !== undefined && - (obj.issuanceDate = message.issuanceDate); - message.expirationDate !== undefined && - (obj.expirationDate = message.expirationDate); - message.credentialHash !== undefined && - (obj.credentialHash = message.credentialHash); - return obj; - }, - - fromPartial(object: DeepPartial): CredentialStatus { - const message = { ...baseCredentialStatus } as CredentialStatus; - if (object.claim !== undefined && object.claim !== null) { - message.claim = Claim.fromPartial(object.claim); - } else { - message.claim = undefined; - } - if (object.issuer !== undefined && object.issuer !== null) { - message.issuer = object.issuer; - } else { - message.issuer = ""; - } - if (object.issuanceDate !== undefined && object.issuanceDate !== null) { - message.issuanceDate = object.issuanceDate; - } else { - message.issuanceDate = ""; - } - if (object.expirationDate !== undefined && object.expirationDate !== null) { - message.expirationDate = object.expirationDate; - } else { - message.expirationDate = ""; - } - if (object.credentialHash !== undefined && object.credentialHash !== null) { - message.credentialHash = object.credentialHash; - } else { - message.credentialHash = ""; - } - return message; - }, -}; - -const baseCredentialProof: object = { - type: "", - created: "", - updated: "", - verificationMethod: "", - proofPurpose: "", - proofValue: "", -}; - -export const CredentialProof = { - encode(message: CredentialProof, writer: Writer = Writer.create()): Writer { - if (message.type !== "") { - writer.uint32(10).string(message.type); - } - if (message.created !== "") { - writer.uint32(18).string(message.created); - } - if (message.updated !== "") { - writer.uint32(26).string(message.updated); - } - if (message.verificationMethod !== "") { - writer.uint32(34).string(message.verificationMethod); - } - if (message.proofPurpose !== "") { - writer.uint32(42).string(message.proofPurpose); - } - if (message.proofValue !== "") { - writer.uint32(50).string(message.proofValue); - } - return writer; - }, - - decode(input: Reader | Uint8Array, length?: number): CredentialProof { - const reader = input instanceof Uint8Array ? new Reader(input) : input; - let end = length === undefined ? reader.len : reader.pos + length; - const message = { ...baseCredentialProof } as CredentialProof; - while (reader.pos < end) { - const tag = reader.uint32(); - switch (tag >>> 3) { - case 1: - message.type = reader.string(); - break; - case 2: - message.created = reader.string(); - break; - case 3: - message.updated = reader.string(); - break; - case 4: - message.verificationMethod = reader.string(); - break; - case 5: - message.proofPurpose = reader.string(); - break; - case 6: - message.proofValue = reader.string(); - break; - default: - reader.skipType(tag & 7); - break; - } - } - return message; - }, - - fromJSON(object: any): CredentialProof { - const message = { ...baseCredentialProof } as CredentialProof; - if (object.type !== undefined && object.type !== null) { - message.type = String(object.type); - } else { - message.type = ""; - } - if (object.created !== undefined && object.created !== null) { - message.created = String(object.created); - } else { - message.created = ""; - } - if (object.updated !== undefined && object.updated !== null) { - message.updated = String(object.updated); - } else { - message.updated = ""; - } - if ( - object.verificationMethod !== undefined && - object.verificationMethod !== null - ) { - message.verificationMethod = String(object.verificationMethod); - } else { - message.verificationMethod = ""; - } - if (object.proofPurpose !== undefined && object.proofPurpose !== null) { - message.proofPurpose = String(object.proofPurpose); - } else { - message.proofPurpose = ""; - } - if (object.proofValue !== undefined && object.proofValue !== null) { - message.proofValue = String(object.proofValue); - } else { - message.proofValue = ""; - } - return message; - }, - - toJSON(message: CredentialProof): unknown { - const obj: any = {}; - message.type !== undefined && (obj.type = message.type); - message.created !== undefined && (obj.created = message.created); - message.updated !== undefined && (obj.updated = message.updated); - message.verificationMethod !== undefined && - (obj.verificationMethod = message.verificationMethod); - message.proofPurpose !== undefined && - (obj.proofPurpose = message.proofPurpose); - message.proofValue !== undefined && (obj.proofValue = message.proofValue); - return obj; - }, - - fromPartial(object: DeepPartial): CredentialProof { - const message = { ...baseCredentialProof } as CredentialProof; - if (object.type !== undefined && object.type !== null) { - message.type = object.type; - } else { - message.type = ""; - } - if (object.created !== undefined && object.created !== null) { - message.created = object.created; - } else { - message.created = ""; - } - if (object.updated !== undefined && object.updated !== null) { - message.updated = object.updated; - } else { - message.updated = ""; - } - if ( - object.verificationMethod !== undefined && - object.verificationMethod !== null - ) { - message.verificationMethod = object.verificationMethod; - } else { - message.verificationMethod = ""; - } - if (object.proofPurpose !== undefined && object.proofPurpose !== null) { - message.proofPurpose = object.proofPurpose; - } else { - message.proofPurpose = ""; - } - if (object.proofValue !== undefined && object.proofValue !== null) { - message.proofValue = object.proofValue; - } else { - message.proofValue = ""; - } - return message; - }, -}; - -const baseCredential: object = { - issuer: "", - issuanceDate: "", - expirationDate: "", - credentialHash: "", -}; - -export const Credential = { - encode(message: Credential, writer: Writer = Writer.create()): Writer { - if (message.claim !== undefined) { - Claim.encode(message.claim, writer.uint32(10).fork()).ldelim(); - } - if (message.issuer !== "") { - writer.uint32(18).string(message.issuer); - } - if (message.issuanceDate !== "") { - writer.uint32(26).string(message.issuanceDate); - } - if (message.expirationDate !== "") { - writer.uint32(34).string(message.expirationDate); - } - if (message.credentialHash !== "") { - writer.uint32(42).string(message.credentialHash); - } - if (message.proof !== undefined) { - CredentialProof.encode(message.proof, writer.uint32(50).fork()).ldelim(); - } - return writer; - }, - - decode(input: Reader | Uint8Array, length?: number): Credential { - const reader = input instanceof Uint8Array ? new Reader(input) : input; - let end = length === undefined ? reader.len : reader.pos + length; - const message = { ...baseCredential } as Credential; - while (reader.pos < end) { - const tag = reader.uint32(); - switch (tag >>> 3) { - case 1: - message.claim = Claim.decode(reader, reader.uint32()); - break; - case 2: - message.issuer = reader.string(); - break; - case 3: - message.issuanceDate = reader.string(); - break; - case 4: - message.expirationDate = reader.string(); - break; - case 5: - message.credentialHash = reader.string(); - break; - case 6: - message.proof = CredentialProof.decode(reader, reader.uint32()); - break; - default: - reader.skipType(tag & 7); - break; - } - } - return message; - }, - - fromJSON(object: any): Credential { - const message = { ...baseCredential } as Credential; - if (object.claim !== undefined && object.claim !== null) { - message.claim = Claim.fromJSON(object.claim); - } else { - message.claim = undefined; - } - if (object.issuer !== undefined && object.issuer !== null) { - message.issuer = String(object.issuer); - } else { - message.issuer = ""; - } - if (object.issuanceDate !== undefined && object.issuanceDate !== null) { - message.issuanceDate = String(object.issuanceDate); - } else { - message.issuanceDate = ""; - } - if (object.expirationDate !== undefined && object.expirationDate !== null) { - message.expirationDate = String(object.expirationDate); - } else { - message.expirationDate = ""; - } - if (object.credentialHash !== undefined && object.credentialHash !== null) { - message.credentialHash = String(object.credentialHash); - } else { - message.credentialHash = ""; - } - if (object.proof !== undefined && object.proof !== null) { - message.proof = CredentialProof.fromJSON(object.proof); - } else { - message.proof = undefined; - } - return message; - }, - - toJSON(message: Credential): unknown { - const obj: any = {}; - message.claim !== undefined && - (obj.claim = message.claim ? Claim.toJSON(message.claim) : undefined); - message.issuer !== undefined && (obj.issuer = message.issuer); - message.issuanceDate !== undefined && - (obj.issuanceDate = message.issuanceDate); - message.expirationDate !== undefined && - (obj.expirationDate = message.expirationDate); - message.credentialHash !== undefined && - (obj.credentialHash = message.credentialHash); - message.proof !== undefined && - (obj.proof = message.proof - ? CredentialProof.toJSON(message.proof) - : undefined); - return obj; - }, - - fromPartial(object: DeepPartial): Credential { - const message = { ...baseCredential } as Credential; - if (object.claim !== undefined && object.claim !== null) { - message.claim = Claim.fromPartial(object.claim); - } else { - message.claim = undefined; - } - if (object.issuer !== undefined && object.issuer !== null) { - message.issuer = object.issuer; - } else { - message.issuer = ""; - } - if (object.issuanceDate !== undefined && object.issuanceDate !== null) { - message.issuanceDate = object.issuanceDate; - } else { - message.issuanceDate = ""; - } - if (object.expirationDate !== undefined && object.expirationDate !== null) { - message.expirationDate = object.expirationDate; - } else { - message.expirationDate = ""; - } - if (object.credentialHash !== undefined && object.credentialHash !== null) { - message.credentialHash = object.credentialHash; - } else { - message.credentialHash = ""; - } - if (object.proof !== undefined && object.proof !== null) { - message.proof = CredentialProof.fromPartial(object.proof); - } else { - message.proof = undefined; - } - return message; - }, -}; - -type Builtin = Date | Function | Uint8Array | string | number | undefined; -export type DeepPartial = T extends Builtin - ? T - : T extends Array - ? Array> - : T extends ReadonlyArray - ? ReadonlyArray> - : T extends {} - ? { [K in keyof T]?: DeepPartial } - : Partial; diff --git a/libs/generated/ssi/credential_schema.ts b/libs/generated/ssi/credential_schema.ts new file mode 100644 index 0000000..eaca5e0 --- /dev/null +++ b/libs/generated/ssi/credential_schema.ts @@ -0,0 +1,446 @@ +/* eslint-disable */ +import _m0 from "protobufjs/minimal"; +import { DocumentProof } from "./proof"; + +export const protobufPackage = "hypersign.ssi.v1"; + +export interface CredentialSchemaDocument { + "@context"?: string[] | undefined; + type?: string | undefined; + modelVersion?: string | undefined; + id?: string | undefined; + name?: string | undefined; + author?: string | undefined; + authored?: string | undefined; + schema?: CredentialSchemaProperty | undefined; +} + +export interface CredentialSchemaProperty { + schema?: string | undefined; + description?: string | undefined; + type?: string | undefined; + properties?: string | undefined; + required?: string[] | undefined; + additionalProperties?: boolean | undefined; +} + +export interface CredentialSchemaState { + credentialSchemaDocument?: CredentialSchemaDocument | undefined; + credentialSchemaProof?: DocumentProof | undefined; +} + +function createBaseCredentialSchemaDocument(): CredentialSchemaDocument { + return {}; +} + +export const CredentialSchemaDocument = { + encode(message: CredentialSchemaDocument, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { + if (message["@context"] !== undefined && message["@context"].length !== 0) { + for (const v of message["@context"]) { + writer.uint32(10).string(v!); + } + } + if (message.type !== undefined && message.type !== "") { + writer.uint32(18).string(message.type); + } + if (message.modelVersion !== undefined && message.modelVersion !== "") { + writer.uint32(26).string(message.modelVersion); + } + if (message.id !== undefined && message.id !== "") { + writer.uint32(34).string(message.id); + } + if (message.name !== undefined && message.name !== "") { + writer.uint32(42).string(message.name); + } + if (message.author !== undefined && message.author !== "") { + writer.uint32(50).string(message.author); + } + if (message.authored !== undefined && message.authored !== "") { + writer.uint32(58).string(message.authored); + } + if (message.schema !== undefined) { + CredentialSchemaProperty.encode(message.schema, writer.uint32(66).fork()).ldelim(); + } + return writer; + }, + + decode(input: _m0.Reader | Uint8Array, length?: number): CredentialSchemaDocument { + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseCredentialSchemaDocument(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + if (tag !== 10) { + break; + } + + if (message["@context"] === undefined) { + message["@context"] = []; + } + message["@context"]!.push(reader.string()); + continue; + case 2: + if (tag !== 18) { + break; + } + + message.type = reader.string(); + continue; + case 3: + if (tag !== 26) { + break; + } + + message.modelVersion = reader.string(); + continue; + case 4: + if (tag !== 34) { + break; + } + + message.id = reader.string(); + continue; + case 5: + if (tag !== 42) { + break; + } + + message.name = reader.string(); + continue; + case 6: + if (tag !== 50) { + break; + } + + message.author = reader.string(); + continue; + case 7: + if (tag !== 58) { + break; + } + + message.authored = reader.string(); + continue; + case 8: + if (tag !== 66) { + break; + } + + message.schema = CredentialSchemaProperty.decode(reader, reader.uint32()); + continue; + } + if ((tag & 7) === 4 || tag === 0) { + break; + } + reader.skipType(tag & 7); + } + return message; + }, + + fromJSON(object: any): CredentialSchemaDocument { + return { + "@context": globalThis.Array.isArray(object?.["@context"]) + ? object["@context"].map((e: any) => globalThis.String(e)) + : undefined, + type: isSet(object.type) ? globalThis.String(object.type) : undefined, + modelVersion: isSet(object.modelVersion) ? globalThis.String(object.modelVersion) : undefined, + id: isSet(object.id) ? globalThis.String(object.id) : undefined, + name: isSet(object.name) ? globalThis.String(object.name) : undefined, + author: isSet(object.author) ? globalThis.String(object.author) : undefined, + authored: isSet(object.authored) ? globalThis.String(object.authored) : undefined, + schema: isSet(object.schema) ? CredentialSchemaProperty.fromJSON(object.schema) : undefined, + }; + }, + + toJSON(message: CredentialSchemaDocument): unknown { + const obj: any = {}; + if (message["@context"]?.length) { + obj["@context"] = message["@context"]; + } + if (message.type !== undefined && message.type !== "") { + obj.type = message.type; + } + if (message.modelVersion !== undefined && message.modelVersion !== "") { + obj.modelVersion = message.modelVersion; + } + if (message.id !== undefined && message.id !== "") { + obj.id = message.id; + } + if (message.name !== undefined && message.name !== "") { + obj.name = message.name; + } + if (message.author !== undefined && message.author !== "") { + obj.author = message.author; + } + if (message.authored !== undefined && message.authored !== "") { + obj.authored = message.authored; + } + if (message.schema !== undefined) { + obj.schema = CredentialSchemaProperty.toJSON(message.schema); + } + return obj; + }, + + create, I>>(base?: I): CredentialSchemaDocument { + return CredentialSchemaDocument.fromPartial(base ?? ({} as any)); + }, + fromPartial, I>>(object: I): CredentialSchemaDocument { + const message = createBaseCredentialSchemaDocument(); + message["@context"] = object["@context"]?.map((e) => e) || undefined; + message.type = object.type ?? undefined; + message.modelVersion = object.modelVersion ?? undefined; + message.id = object.id ?? undefined; + message.name = object.name ?? undefined; + message.author = object.author ?? undefined; + message.authored = object.authored ?? undefined; + message.schema = (object.schema !== undefined && object.schema !== null) + ? CredentialSchemaProperty.fromPartial(object.schema) + : undefined; + return message; + }, +}; + +function createBaseCredentialSchemaProperty(): CredentialSchemaProperty { + return {}; +} + +export const CredentialSchemaProperty = { + encode(message: CredentialSchemaProperty, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { + if (message.schema !== undefined && message.schema !== "") { + writer.uint32(10).string(message.schema); + } + if (message.description !== undefined && message.description !== "") { + writer.uint32(18).string(message.description); + } + if (message.type !== undefined && message.type !== "") { + writer.uint32(26).string(message.type); + } + if (message.properties !== undefined && message.properties !== "") { + writer.uint32(34).string(message.properties); + } + if (message.required !== undefined && message.required.length !== 0) { + for (const v of message.required) { + writer.uint32(42).string(v!); + } + } + if (message.additionalProperties === true) { + writer.uint32(48).bool(message.additionalProperties); + } + return writer; + }, + + decode(input: _m0.Reader | Uint8Array, length?: number): CredentialSchemaProperty { + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseCredentialSchemaProperty(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + if (tag !== 10) { + break; + } + + message.schema = reader.string(); + continue; + case 2: + if (tag !== 18) { + break; + } + + message.description = reader.string(); + continue; + case 3: + if (tag !== 26) { + break; + } + + message.type = reader.string(); + continue; + case 4: + if (tag !== 34) { + break; + } + + message.properties = reader.string(); + continue; + case 5: + if (tag !== 42) { + break; + } + + if (message.required === undefined) { + message.required = []; + } + message.required!.push(reader.string()); + continue; + case 6: + if (tag !== 48) { + break; + } + + message.additionalProperties = reader.bool(); + continue; + } + if ((tag & 7) === 4 || tag === 0) { + break; + } + reader.skipType(tag & 7); + } + return message; + }, + + fromJSON(object: any): CredentialSchemaProperty { + return { + schema: isSet(object.schema) ? globalThis.String(object.schema) : undefined, + description: isSet(object.description) ? globalThis.String(object.description) : undefined, + type: isSet(object.type) ? globalThis.String(object.type) : undefined, + properties: isSet(object.properties) ? globalThis.String(object.properties) : undefined, + required: globalThis.Array.isArray(object?.required) + ? object.required.map((e: any) => globalThis.String(e)) + : undefined, + additionalProperties: isSet(object.additionalProperties) + ? globalThis.Boolean(object.additionalProperties) + : undefined, + }; + }, + + toJSON(message: CredentialSchemaProperty): unknown { + const obj: any = {}; + if (message.schema !== undefined && message.schema !== "") { + obj.schema = message.schema; + } + if (message.description !== undefined && message.description !== "") { + obj.description = message.description; + } + if (message.type !== undefined && message.type !== "") { + obj.type = message.type; + } + if (message.properties !== undefined && message.properties !== "") { + obj.properties = message.properties; + } + if (message.required?.length) { + obj.required = message.required; + } + if (message.additionalProperties === true) { + obj.additionalProperties = message.additionalProperties; + } + return obj; + }, + + create, I>>(base?: I): CredentialSchemaProperty { + return CredentialSchemaProperty.fromPartial(base ?? ({} as any)); + }, + fromPartial, I>>(object: I): CredentialSchemaProperty { + const message = createBaseCredentialSchemaProperty(); + message.schema = object.schema ?? undefined; + message.description = object.description ?? undefined; + message.type = object.type ?? undefined; + message.properties = object.properties ?? undefined; + message.required = object.required?.map((e) => e) || undefined; + message.additionalProperties = object.additionalProperties ?? undefined; + return message; + }, +}; + +function createBaseCredentialSchemaState(): CredentialSchemaState { + return {}; +} + +export const CredentialSchemaState = { + encode(message: CredentialSchemaState, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { + if (message.credentialSchemaDocument !== undefined) { + CredentialSchemaDocument.encode(message.credentialSchemaDocument, writer.uint32(10).fork()).ldelim(); + } + if (message.credentialSchemaProof !== undefined) { + DocumentProof.encode(message.credentialSchemaProof, writer.uint32(18).fork()).ldelim(); + } + return writer; + }, + + decode(input: _m0.Reader | Uint8Array, length?: number): CredentialSchemaState { + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseCredentialSchemaState(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + if (tag !== 10) { + break; + } + + message.credentialSchemaDocument = CredentialSchemaDocument.decode(reader, reader.uint32()); + continue; + case 2: + if (tag !== 18) { + break; + } + + message.credentialSchemaProof = DocumentProof.decode(reader, reader.uint32()); + continue; + } + if ((tag & 7) === 4 || tag === 0) { + break; + } + reader.skipType(tag & 7); + } + return message; + }, + + fromJSON(object: any): CredentialSchemaState { + return { + credentialSchemaDocument: isSet(object.credentialSchemaDocument) + ? CredentialSchemaDocument.fromJSON(object.credentialSchemaDocument) + : undefined, + credentialSchemaProof: isSet(object.credentialSchemaProof) + ? DocumentProof.fromJSON(object.credentialSchemaProof) + : undefined, + }; + }, + + toJSON(message: CredentialSchemaState): unknown { + const obj: any = {}; + if (message.credentialSchemaDocument !== undefined) { + obj.credentialSchemaDocument = CredentialSchemaDocument.toJSON(message.credentialSchemaDocument); + } + if (message.credentialSchemaProof !== undefined) { + obj.credentialSchemaProof = DocumentProof.toJSON(message.credentialSchemaProof); + } + return obj; + }, + + create, I>>(base?: I): CredentialSchemaState { + return CredentialSchemaState.fromPartial(base ?? ({} as any)); + }, + fromPartial, I>>(object: I): CredentialSchemaState { + const message = createBaseCredentialSchemaState(); + message.credentialSchemaDocument = + (object.credentialSchemaDocument !== undefined && object.credentialSchemaDocument !== null) + ? CredentialSchemaDocument.fromPartial(object.credentialSchemaDocument) + : undefined; + message.credentialSchemaProof = + (object.credentialSchemaProof !== undefined && object.credentialSchemaProof !== null) + ? DocumentProof.fromPartial(object.credentialSchemaProof) + : undefined; + return message; + }, +}; + +type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined; + +export type DeepPartial = T extends Builtin ? T + : T extends globalThis.Array ? globalThis.Array> + : T extends ReadonlyArray ? ReadonlyArray> + : T extends {} ? { [K in keyof T]?: DeepPartial } + : Partial; + +type KeysOfUnion = T extends T ? keyof T : never; +export type Exact = P extends Builtin ? P + : P & { [K in keyof P]: Exact } & { [K in Exclude>]: never }; + +function isSet(value: any): boolean { + return value !== null && value !== undefined; +} diff --git a/libs/generated/ssi/credential_status.ts b/libs/generated/ssi/credential_status.ts new file mode 100644 index 0000000..4f2da11 --- /dev/null +++ b/libs/generated/ssi/credential_status.ts @@ -0,0 +1,294 @@ +/* eslint-disable */ +import _m0 from "protobufjs/minimal"; +import { DocumentProof } from "./proof"; + +export const protobufPackage = "hypersign.ssi.v1"; + +export interface CredentialStatusDocument { + "@context"?: string[] | undefined; + id?: string | undefined; + revoked?: boolean | undefined; + suspended?: boolean | undefined; + remarks?: string | undefined; + issuer?: string | undefined; + issuanceDate?: string | undefined; + credentialMerkleRootHash?: string | undefined; +} + +export interface CredentialStatusState { + credentialStatusDocument?: CredentialStatusDocument | undefined; + credentialStatusProof?: DocumentProof | undefined; +} + +function createBaseCredentialStatusDocument(): CredentialStatusDocument { + return {}; +} + +export const CredentialStatusDocument = { + encode(message: CredentialStatusDocument, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { + if (message["@context"] !== undefined && message["@context"].length !== 0) { + for (const v of message["@context"]) { + writer.uint32(10).string(v!); + } + } + if (message.id !== undefined && message.id !== "") { + writer.uint32(18).string(message.id); + } + if (message.revoked === true) { + writer.uint32(24).bool(message.revoked); + } + if (message.suspended === true) { + writer.uint32(32).bool(message.suspended); + } + if (message.remarks !== undefined && message.remarks !== "") { + writer.uint32(42).string(message.remarks); + } + if (message.issuer !== undefined && message.issuer !== "") { + writer.uint32(50).string(message.issuer); + } + if (message.issuanceDate !== undefined && message.issuanceDate !== "") { + writer.uint32(58).string(message.issuanceDate); + } + if (message.credentialMerkleRootHash !== undefined && message.credentialMerkleRootHash !== "") { + writer.uint32(66).string(message.credentialMerkleRootHash); + } + return writer; + }, + + decode(input: _m0.Reader | Uint8Array, length?: number): CredentialStatusDocument { + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseCredentialStatusDocument(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + if (tag !== 10) { + break; + } + + if (message["@context"] === undefined) { + message["@context"] = []; + } + message["@context"]!.push(reader.string()); + continue; + case 2: + if (tag !== 18) { + break; + } + + message.id = reader.string(); + continue; + case 3: + if (tag !== 24) { + break; + } + + message.revoked = reader.bool(); + continue; + case 4: + if (tag !== 32) { + break; + } + + message.suspended = reader.bool(); + continue; + case 5: + if (tag !== 42) { + break; + } + + message.remarks = reader.string(); + continue; + case 6: + if (tag !== 50) { + break; + } + + message.issuer = reader.string(); + continue; + case 7: + if (tag !== 58) { + break; + } + + message.issuanceDate = reader.string(); + continue; + case 8: + if (tag !== 66) { + break; + } + + message.credentialMerkleRootHash = reader.string(); + continue; + } + if ((tag & 7) === 4 || tag === 0) { + break; + } + reader.skipType(tag & 7); + } + return message; + }, + + fromJSON(object: any): CredentialStatusDocument { + return { + "@context": globalThis.Array.isArray(object?.["@context"]) + ? object["@context"].map((e: any) => globalThis.String(e)) + : undefined, + id: isSet(object.id) ? globalThis.String(object.id) : undefined, + revoked: isSet(object.revoked) ? globalThis.Boolean(object.revoked) : undefined, + suspended: isSet(object.suspended) ? globalThis.Boolean(object.suspended) : undefined, + remarks: isSet(object.remarks) ? globalThis.String(object.remarks) : undefined, + issuer: isSet(object.issuer) ? globalThis.String(object.issuer) : undefined, + issuanceDate: isSet(object.issuanceDate) ? globalThis.String(object.issuanceDate) : undefined, + credentialMerkleRootHash: isSet(object.credentialMerkleRootHash) + ? globalThis.String(object.credentialMerkleRootHash) + : undefined, + }; + }, + + toJSON(message: CredentialStatusDocument): unknown { + const obj: any = {}; + if (message["@context"]?.length) { + obj["@context"] = message["@context"]; + } + if (message.id !== undefined && message.id !== "") { + obj.id = message.id; + } + if (message.revoked === true) { + obj.revoked = message.revoked; + } + if (message.suspended === true) { + obj.suspended = message.suspended; + } + if (message.remarks !== undefined && message.remarks !== "") { + obj.remarks = message.remarks; + } + if (message.issuer !== undefined && message.issuer !== "") { + obj.issuer = message.issuer; + } + if (message.issuanceDate !== undefined && message.issuanceDate !== "") { + obj.issuanceDate = message.issuanceDate; + } + if (message.credentialMerkleRootHash !== undefined && message.credentialMerkleRootHash !== "") { + obj.credentialMerkleRootHash = message.credentialMerkleRootHash; + } + return obj; + }, + + create, I>>(base?: I): CredentialStatusDocument { + return CredentialStatusDocument.fromPartial(base ?? ({} as any)); + }, + fromPartial, I>>(object: I): CredentialStatusDocument { + const message = createBaseCredentialStatusDocument(); + message["@context"] = object["@context"]?.map((e) => e) || undefined; + message.id = object.id ?? undefined; + message.revoked = object.revoked ?? undefined; + message.suspended = object.suspended ?? undefined; + message.remarks = object.remarks ?? undefined; + message.issuer = object.issuer ?? undefined; + message.issuanceDate = object.issuanceDate ?? undefined; + message.credentialMerkleRootHash = object.credentialMerkleRootHash ?? undefined; + return message; + }, +}; + +function createBaseCredentialStatusState(): CredentialStatusState { + return {}; +} + +export const CredentialStatusState = { + encode(message: CredentialStatusState, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { + if (message.credentialStatusDocument !== undefined) { + CredentialStatusDocument.encode(message.credentialStatusDocument, writer.uint32(10).fork()).ldelim(); + } + if (message.credentialStatusProof !== undefined) { + DocumentProof.encode(message.credentialStatusProof, writer.uint32(18).fork()).ldelim(); + } + return writer; + }, + + decode(input: _m0.Reader | Uint8Array, length?: number): CredentialStatusState { + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseCredentialStatusState(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + if (tag !== 10) { + break; + } + + message.credentialStatusDocument = CredentialStatusDocument.decode(reader, reader.uint32()); + continue; + case 2: + if (tag !== 18) { + break; + } + + message.credentialStatusProof = DocumentProof.decode(reader, reader.uint32()); + continue; + } + if ((tag & 7) === 4 || tag === 0) { + break; + } + reader.skipType(tag & 7); + } + return message; + }, + + fromJSON(object: any): CredentialStatusState { + return { + credentialStatusDocument: isSet(object.credentialStatusDocument) + ? CredentialStatusDocument.fromJSON(object.credentialStatusDocument) + : undefined, + credentialStatusProof: isSet(object.credentialStatusProof) + ? DocumentProof.fromJSON(object.credentialStatusProof) + : undefined, + }; + }, + + toJSON(message: CredentialStatusState): unknown { + const obj: any = {}; + if (message.credentialStatusDocument !== undefined) { + obj.credentialStatusDocument = CredentialStatusDocument.toJSON(message.credentialStatusDocument); + } + if (message.credentialStatusProof !== undefined) { + obj.credentialStatusProof = DocumentProof.toJSON(message.credentialStatusProof); + } + return obj; + }, + + create, I>>(base?: I): CredentialStatusState { + return CredentialStatusState.fromPartial(base ?? ({} as any)); + }, + fromPartial, I>>(object: I): CredentialStatusState { + const message = createBaseCredentialStatusState(); + message.credentialStatusDocument = + (object.credentialStatusDocument !== undefined && object.credentialStatusDocument !== null) + ? CredentialStatusDocument.fromPartial(object.credentialStatusDocument) + : undefined; + message.credentialStatusProof = + (object.credentialStatusProof !== undefined && object.credentialStatusProof !== null) + ? DocumentProof.fromPartial(object.credentialStatusProof) + : undefined; + return message; + }, +}; + +type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined; + +export type DeepPartial = T extends Builtin ? T + : T extends globalThis.Array ? globalThis.Array> + : T extends ReadonlyArray ? ReadonlyArray> + : T extends {} ? { [K in keyof T]?: DeepPartial } + : Partial; + +type KeysOfUnion = T extends T ? keyof T : never; +export type Exact = P extends Builtin ? P + : P & { [K in keyof P]: Exact } & { [K in Exclude>]: never }; + +function isSet(value: any): boolean { + return value !== null && value !== undefined; +} diff --git a/libs/generated/ssi/did.ts b/libs/generated/ssi/did.ts index 351d582..c817258 100644 --- a/libs/generated/ssi/did.ts +++ b/libs/generated/ssi/did.ts @@ -1,946 +1,739 @@ /* eslint-disable */ -import { ClientSpec } from "./clientSpec"; -import { Writer, Reader } from "protobufjs/minimal"; - -export const protobufPackage = "hypersignprotocol.hidnode.ssi"; - -export interface Did { - context: string[]; - id: string; - controller: string[]; - alsoKnownAs: string[]; - verificationMethod: VerificationMethod[]; - authentication: string[]; - assertionMethod: string[]; - keyAgreement: string[]; - capabilityInvocation: string[]; - capabilityDelegation: string[]; - service: Service[]; +import _m0 from "protobufjs/minimal"; + +export const protobufPackage = "hypersign.ssi.v1"; + +export interface DidDocument { + "@context"?: string[] | undefined; + id?: string | undefined; + controller?: string[] | undefined; + alsoKnownAs?: string[] | undefined; + verificationMethod?: VerificationMethod[] | undefined; + authentication?: string[] | undefined; + assertionMethod?: string[] | undefined; + keyAgreement?: string[] | undefined; + capabilityInvocation?: string[] | undefined; + capabilityDelegation?: string[] | undefined; + service?: Service[] | undefined; } -export interface Metadata { - created: string; - updated: string; - deactivated: boolean; - versionId: string; +export interface DidDocumentMetadata { + created?: string | undefined; + updated?: string | undefined; + deactivated?: boolean | undefined; + versionId?: string | undefined; } export interface VerificationMethod { - id: string; - type: string; - controller: string; + id?: string | undefined; + type?: string | undefined; + controller?: + | string + | undefined; /** If value is provided, `blockchainAccountId` must be empty */ - publicKeyMultibase: string; + publicKeyMultibase?: + | string + | undefined; /** If value is provided, `publicKeyMultibase` must be empty */ - blockchainAccountId: string; + blockchainAccountId?: string | undefined; } export interface Service { - id: string; - type: string; - serviceEndpoint: string; -} - -export interface SignInfo { - verification_method_id: string; - signature: string; - clientSpec: ClientSpec | undefined; + id?: string | undefined; + type?: string | undefined; + serviceEndpoint?: string | undefined; } export interface DidDocumentState { - didDocument: Did | undefined; - didDocumentMetadata: Metadata | undefined; + didDocument?: DidDocument | undefined; + didDocumentMetadata?: DidDocumentMetadata | undefined; } -const baseDid: object = { - context: "", - id: "", - controller: "", - alsoKnownAs: "", - authentication: "", - assertionMethod: "", - keyAgreement: "", - capabilityInvocation: "", - capabilityDelegation: "", -}; +function createBaseDidDocument(): DidDocument { + return {}; +} -export const Did = { - encode(message: Did, writer: Writer = Writer.create()): Writer { - for (const v of message.context) { - writer.uint32(10).string(v!); +export const DidDocument = { + encode(message: DidDocument, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { + if (message["@context"] !== undefined && message["@context"].length !== 0) { + for (const v of message["@context"]) { + writer.uint32(10).string(v!); + } } - if (message.id !== "") { + if (message.id !== undefined && message.id !== "") { writer.uint32(18).string(message.id); } - for (const v of message.controller) { - writer.uint32(26).string(v!); + if (message.controller !== undefined && message.controller.length !== 0) { + for (const v of message.controller) { + writer.uint32(26).string(v!); + } } - for (const v of message.alsoKnownAs) { - writer.uint32(34).string(v!); + if (message.alsoKnownAs !== undefined && message.alsoKnownAs.length !== 0) { + for (const v of message.alsoKnownAs) { + writer.uint32(34).string(v!); + } } - for (const v of message.verificationMethod) { - VerificationMethod.encode(v!, writer.uint32(42).fork()).ldelim(); + if (message.verificationMethod !== undefined && message.verificationMethod.length !== 0) { + for (const v of message.verificationMethod) { + VerificationMethod.encode(v!, writer.uint32(42).fork()).ldelim(); + } } - for (const v of message.authentication) { - writer.uint32(50).string(v!); + if (message.authentication !== undefined && message.authentication.length !== 0) { + for (const v of message.authentication) { + writer.uint32(50).string(v!); + } } - for (const v of message.assertionMethod) { - writer.uint32(58).string(v!); + if (message.assertionMethod !== undefined && message.assertionMethod.length !== 0) { + for (const v of message.assertionMethod) { + writer.uint32(58).string(v!); + } } - for (const v of message.keyAgreement) { - writer.uint32(66).string(v!); + if (message.keyAgreement !== undefined && message.keyAgreement.length !== 0) { + for (const v of message.keyAgreement) { + writer.uint32(66).string(v!); + } } - for (const v of message.capabilityInvocation) { - writer.uint32(74).string(v!); + if (message.capabilityInvocation !== undefined && message.capabilityInvocation.length !== 0) { + for (const v of message.capabilityInvocation) { + writer.uint32(74).string(v!); + } } - for (const v of message.capabilityDelegation) { - writer.uint32(82).string(v!); + if (message.capabilityDelegation !== undefined && message.capabilityDelegation.length !== 0) { + for (const v of message.capabilityDelegation) { + writer.uint32(82).string(v!); + } } - for (const v of message.service) { - Service.encode(v!, writer.uint32(90).fork()).ldelim(); + if (message.service !== undefined && message.service.length !== 0) { + for (const v of message.service) { + Service.encode(v!, writer.uint32(90).fork()).ldelim(); + } } return writer; }, - decode(input: Reader | Uint8Array, length?: number): Did { - const reader = input instanceof Uint8Array ? new Reader(input) : input; + decode(input: _m0.Reader | Uint8Array, length?: number): DidDocument { + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; - const message = { ...baseDid } as Did; - message.context = []; - message.controller = []; - message.alsoKnownAs = []; - message.verificationMethod = []; - message.authentication = []; - message.assertionMethod = []; - message.keyAgreement = []; - message.capabilityInvocation = []; - message.capabilityDelegation = []; - message.service = []; + const message = createBaseDidDocument(); while (reader.pos < end) { const tag = reader.uint32(); switch (tag >>> 3) { case 1: - message.context.push(reader.string()); - break; + if (tag !== 10) { + break; + } + + if (message["@context"] === undefined) { + message["@context"] = []; + } + message["@context"]!.push(reader.string()); + continue; case 2: + if (tag !== 18) { + break; + } + message.id = reader.string(); - break; + continue; case 3: - message.controller.push(reader.string()); - break; + if (tag !== 26) { + break; + } + + if (message.controller === undefined) { + message.controller = []; + } + message.controller!.push(reader.string()); + continue; case 4: - message.alsoKnownAs.push(reader.string()); - break; + if (tag !== 34) { + break; + } + + if (message.alsoKnownAs === undefined) { + message.alsoKnownAs = []; + } + message.alsoKnownAs!.push(reader.string()); + continue; case 5: - message.verificationMethod.push( - VerificationMethod.decode(reader, reader.uint32()) - ); - break; + if (tag !== 42) { + break; + } + + if (message.verificationMethod === undefined) { + message.verificationMethod = []; + } + message.verificationMethod!.push(VerificationMethod.decode(reader, reader.uint32())); + continue; case 6: - message.authentication.push(reader.string()); - break; + if (tag !== 50) { + break; + } + + if (message.authentication === undefined) { + message.authentication = []; + } + message.authentication!.push(reader.string()); + continue; case 7: - message.assertionMethod.push(reader.string()); - break; + if (tag !== 58) { + break; + } + + if (message.assertionMethod === undefined) { + message.assertionMethod = []; + } + message.assertionMethod!.push(reader.string()); + continue; case 8: - message.keyAgreement.push(reader.string()); - break; + if (tag !== 66) { + break; + } + + if (message.keyAgreement === undefined) { + message.keyAgreement = []; + } + message.keyAgreement!.push(reader.string()); + continue; case 9: - message.capabilityInvocation.push(reader.string()); - break; + if (tag !== 74) { + break; + } + + if (message.capabilityInvocation === undefined) { + message.capabilityInvocation = []; + } + message.capabilityInvocation!.push(reader.string()); + continue; case 10: - message.capabilityDelegation.push(reader.string()); - break; + if (tag !== 82) { + break; + } + + if (message.capabilityDelegation === undefined) { + message.capabilityDelegation = []; + } + message.capabilityDelegation!.push(reader.string()); + continue; case 11: - message.service.push(Service.decode(reader, reader.uint32())); - break; - default: - reader.skipType(tag & 7); - break; - } - } - return message; - }, - - fromJSON(object: any): Did { - const message = { ...baseDid } as Did; - message.context = []; - message.controller = []; - message.alsoKnownAs = []; - message.verificationMethod = []; - message.authentication = []; - message.assertionMethod = []; - message.keyAgreement = []; - message.capabilityInvocation = []; - message.capabilityDelegation = []; - message.service = []; - if (object.context !== undefined && object.context !== null) { - for (const e of object.context) { - message.context.push(String(e)); - } - } - if (object.id !== undefined && object.id !== null) { - message.id = String(object.id); - } else { - message.id = ""; - } - if (object.controller !== undefined && object.controller !== null) { - for (const e of object.controller) { - message.controller.push(String(e)); - } - } - if (object.alsoKnownAs !== undefined && object.alsoKnownAs !== null) { - for (const e of object.alsoKnownAs) { - message.alsoKnownAs.push(String(e)); - } - } - if ( - object.verificationMethod !== undefined && - object.verificationMethod !== null - ) { - for (const e of object.verificationMethod) { - message.verificationMethod.push(VerificationMethod.fromJSON(e)); - } - } - if (object.authentication !== undefined && object.authentication !== null) { - for (const e of object.authentication) { - message.authentication.push(String(e)); - } - } - if ( - object.assertionMethod !== undefined && - object.assertionMethod !== null - ) { - for (const e of object.assertionMethod) { - message.assertionMethod.push(String(e)); - } - } - if (object.keyAgreement !== undefined && object.keyAgreement !== null) { - for (const e of object.keyAgreement) { - message.keyAgreement.push(String(e)); - } - } - if ( - object.capabilityInvocation !== undefined && - object.capabilityInvocation !== null - ) { - for (const e of object.capabilityInvocation) { - message.capabilityInvocation.push(String(e)); - } - } - if ( - object.capabilityDelegation !== undefined && - object.capabilityDelegation !== null - ) { - for (const e of object.capabilityDelegation) { - message.capabilityDelegation.push(String(e)); + if (tag !== 90) { + break; + } + + if (message.service === undefined) { + message.service = []; + } + message.service!.push(Service.decode(reader, reader.uint32())); + continue; } - } - if (object.service !== undefined && object.service !== null) { - for (const e of object.service) { - message.service.push(Service.fromJSON(e)); + if ((tag & 7) === 4 || tag === 0) { + break; } + reader.skipType(tag & 7); } return message; }, - toJSON(message: Did): unknown { - const obj: any = {}; - if (message.context) { - obj.context = message.context.map((e) => e); - } else { - obj.context = []; - } - message.id !== undefined && (obj.id = message.id); - if (message.controller) { - obj.controller = message.controller.map((e) => e); - } else { - obj.controller = []; - } - if (message.alsoKnownAs) { - obj.alsoKnownAs = message.alsoKnownAs.map((e) => e); - } else { - obj.alsoKnownAs = []; - } - if (message.verificationMethod) { - obj.verificationMethod = message.verificationMethod.map((e) => - e ? VerificationMethod.toJSON(e) : undefined - ); - } else { - obj.verificationMethod = []; - } - if (message.authentication) { - obj.authentication = message.authentication.map((e) => e); - } else { - obj.authentication = []; - } - if (message.assertionMethod) { - obj.assertionMethod = message.assertionMethod.map((e) => e); - } else { - obj.assertionMethod = []; - } - if (message.keyAgreement) { - obj.keyAgreement = message.keyAgreement.map((e) => e); - } else { - obj.keyAgreement = []; - } - if (message.capabilityInvocation) { - obj.capabilityInvocation = message.capabilityInvocation.map((e) => e); - } else { - obj.capabilityInvocation = []; - } - if (message.capabilityDelegation) { - obj.capabilityDelegation = message.capabilityDelegation.map((e) => e); - } else { - obj.capabilityDelegation = []; - } - if (message.service) { - obj.service = message.service.map((e) => - e ? Service.toJSON(e) : undefined - ); - } else { - obj.service = []; - } - return obj; + fromJSON(object: any): DidDocument { + return { + "@context": globalThis.Array.isArray(object?.["@context"]) + ? object["@context"].map((e: any) => globalThis.String(e)) + : undefined, + id: isSet(object.id) ? globalThis.String(object.id) : undefined, + controller: globalThis.Array.isArray(object?.controller) + ? object.controller.map((e: any) => globalThis.String(e)) + : undefined, + alsoKnownAs: globalThis.Array.isArray(object?.alsoKnownAs) + ? object.alsoKnownAs.map((e: any) => globalThis.String(e)) + : undefined, + verificationMethod: globalThis.Array.isArray(object?.verificationMethod) + ? object.verificationMethod.map((e: any) => VerificationMethod.fromJSON(e)) + : undefined, + authentication: globalThis.Array.isArray(object?.authentication) + ? object.authentication.map((e: any) => globalThis.String(e)) + : undefined, + assertionMethod: globalThis.Array.isArray(object?.assertionMethod) + ? object.assertionMethod.map((e: any) => globalThis.String(e)) + : undefined, + keyAgreement: globalThis.Array.isArray(object?.keyAgreement) + ? object.keyAgreement.map((e: any) => globalThis.String(e)) + : undefined, + capabilityInvocation: globalThis.Array.isArray(object?.capabilityInvocation) + ? object.capabilityInvocation.map((e: any) => globalThis.String(e)) + : undefined, + capabilityDelegation: globalThis.Array.isArray(object?.capabilityDelegation) + ? object.capabilityDelegation.map((e: any) => globalThis.String(e)) + : undefined, + service: globalThis.Array.isArray(object?.service) + ? object.service.map((e: any) => Service.fromJSON(e)) + : undefined, + }; }, - fromPartial(object: DeepPartial): Did { - const message = { ...baseDid } as Did; - message.context = []; - message.controller = []; - message.alsoKnownAs = []; - message.verificationMethod = []; - message.authentication = []; - message.assertionMethod = []; - message.keyAgreement = []; - message.capabilityInvocation = []; - message.capabilityDelegation = []; - message.service = []; - if (object.context !== undefined && object.context !== null) { - for (const e of object.context) { - message.context.push(e); - } + toJSON(message: DidDocument): unknown { + const obj: any = {}; + if (message["@context"]?.length) { + obj["@context"] = message["@context"]; } - if (object.id !== undefined && object.id !== null) { - message.id = object.id; - } else { - message.id = ""; + if (message.id !== undefined && message.id !== "") { + obj.id = message.id; } - if (object.controller !== undefined && object.controller !== null) { - for (const e of object.controller) { - message.controller.push(e); - } + if (message.controller?.length) { + obj.controller = message.controller; } - if (object.alsoKnownAs !== undefined && object.alsoKnownAs !== null) { - for (const e of object.alsoKnownAs) { - message.alsoKnownAs.push(e); - } + if (message.alsoKnownAs?.length) { + obj.alsoKnownAs = message.alsoKnownAs; } - if ( - object.verificationMethod !== undefined && - object.verificationMethod !== null - ) { - for (const e of object.verificationMethod) { - message.verificationMethod.push(VerificationMethod.fromPartial(e)); - } + if (message.verificationMethod?.length) { + obj.verificationMethod = message.verificationMethod.map((e) => VerificationMethod.toJSON(e)); } - if (object.authentication !== undefined && object.authentication !== null) { - for (const e of object.authentication) { - message.authentication.push(e); - } + if (message.authentication?.length) { + obj.authentication = message.authentication; } - if ( - object.assertionMethod !== undefined && - object.assertionMethod !== null - ) { - for (const e of object.assertionMethod) { - message.assertionMethod.push(e); - } + if (message.assertionMethod?.length) { + obj.assertionMethod = message.assertionMethod; } - if (object.keyAgreement !== undefined && object.keyAgreement !== null) { - for (const e of object.keyAgreement) { - message.keyAgreement.push(e); - } + if (message.keyAgreement?.length) { + obj.keyAgreement = message.keyAgreement; } - if ( - object.capabilityInvocation !== undefined && - object.capabilityInvocation !== null - ) { - for (const e of object.capabilityInvocation) { - message.capabilityInvocation.push(e); - } + if (message.capabilityInvocation?.length) { + obj.capabilityInvocation = message.capabilityInvocation; } - if ( - object.capabilityDelegation !== undefined && - object.capabilityDelegation !== null - ) { - for (const e of object.capabilityDelegation) { - message.capabilityDelegation.push(e); - } + if (message.capabilityDelegation?.length) { + obj.capabilityDelegation = message.capabilityDelegation; } - if (object.service !== undefined && object.service !== null) { - for (const e of object.service) { - message.service.push(Service.fromPartial(e)); - } + if (message.service?.length) { + obj.service = message.service.map((e) => Service.toJSON(e)); } + return obj; + }, + + create, I>>(base?: I): DidDocument { + return DidDocument.fromPartial(base ?? ({} as any)); + }, + fromPartial, I>>(object: I): DidDocument { + const message = createBaseDidDocument(); + message["@context"] = object["@context"]?.map((e) => e) || undefined; + message.id = object.id ?? undefined; + message.controller = object.controller?.map((e) => e) || undefined; + message.alsoKnownAs = object.alsoKnownAs?.map((e) => e) || undefined; + message.verificationMethod = object.verificationMethod?.map((e) => VerificationMethod.fromPartial(e)) || undefined; + message.authentication = object.authentication?.map((e) => e) || undefined; + message.assertionMethod = object.assertionMethod?.map((e) => e) || undefined; + message.keyAgreement = object.keyAgreement?.map((e) => e) || undefined; + message.capabilityInvocation = object.capabilityInvocation?.map((e) => e) || undefined; + message.capabilityDelegation = object.capabilityDelegation?.map((e) => e) || undefined; + message.service = object.service?.map((e) => Service.fromPartial(e)) || undefined; return message; }, }; -const baseMetadata: object = { - created: "", - updated: "", - deactivated: false, - versionId: "", -}; +function createBaseDidDocumentMetadata(): DidDocumentMetadata { + return {}; +} -export const Metadata = { - encode(message: Metadata, writer: Writer = Writer.create()): Writer { - if (message.created !== "") { +export const DidDocumentMetadata = { + encode(message: DidDocumentMetadata, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { + if (message.created !== undefined && message.created !== "") { writer.uint32(10).string(message.created); } - if (message.updated !== "") { + if (message.updated !== undefined && message.updated !== "") { writer.uint32(18).string(message.updated); } if (message.deactivated === true) { writer.uint32(24).bool(message.deactivated); } - if (message.versionId !== "") { + if (message.versionId !== undefined && message.versionId !== "") { writer.uint32(34).string(message.versionId); } return writer; }, - decode(input: Reader | Uint8Array, length?: number): Metadata { - const reader = input instanceof Uint8Array ? new Reader(input) : input; + decode(input: _m0.Reader | Uint8Array, length?: number): DidDocumentMetadata { + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; - const message = { ...baseMetadata } as Metadata; + const message = createBaseDidDocumentMetadata(); while (reader.pos < end) { const tag = reader.uint32(); switch (tag >>> 3) { case 1: + if (tag !== 10) { + break; + } + message.created = reader.string(); - break; + continue; case 2: + if (tag !== 18) { + break; + } + message.updated = reader.string(); - break; + continue; case 3: + if (tag !== 24) { + break; + } + message.deactivated = reader.bool(); - break; + continue; case 4: + if (tag !== 34) { + break; + } + message.versionId = reader.string(); - break; - default: - reader.skipType(tag & 7); - break; + continue; + } + if ((tag & 7) === 4 || tag === 0) { + break; } + reader.skipType(tag & 7); } return message; }, - fromJSON(object: any): Metadata { - const message = { ...baseMetadata } as Metadata; - if (object.created !== undefined && object.created !== null) { - message.created = String(object.created); - } else { - message.created = ""; - } - if (object.updated !== undefined && object.updated !== null) { - message.updated = String(object.updated); - } else { - message.updated = ""; - } - if (object.deactivated !== undefined && object.deactivated !== null) { - message.deactivated = Boolean(object.deactivated); - } else { - message.deactivated = false; - } - if (object.versionId !== undefined && object.versionId !== null) { - message.versionId = String(object.versionId); - } else { - message.versionId = ""; - } - return message; + fromJSON(object: any): DidDocumentMetadata { + return { + created: isSet(object.created) ? globalThis.String(object.created) : undefined, + updated: isSet(object.updated) ? globalThis.String(object.updated) : undefined, + deactivated: isSet(object.deactivated) ? globalThis.Boolean(object.deactivated) : undefined, + versionId: isSet(object.versionId) ? globalThis.String(object.versionId) : undefined, + }; }, - toJSON(message: Metadata): unknown { + toJSON(message: DidDocumentMetadata): unknown { const obj: any = {}; - message.created !== undefined && (obj.created = message.created); - message.updated !== undefined && (obj.updated = message.updated); - message.deactivated !== undefined && - (obj.deactivated = message.deactivated); - message.versionId !== undefined && (obj.versionId = message.versionId); - return obj; - }, - - fromPartial(object: DeepPartial): Metadata { - const message = { ...baseMetadata } as Metadata; - if (object.created !== undefined && object.created !== null) { - message.created = object.created; - } else { - message.created = ""; + if (message.created !== undefined && message.created !== "") { + obj.created = message.created; } - if (object.updated !== undefined && object.updated !== null) { - message.updated = object.updated; - } else { - message.updated = ""; + if (message.updated !== undefined && message.updated !== "") { + obj.updated = message.updated; } - if (object.deactivated !== undefined && object.deactivated !== null) { - message.deactivated = object.deactivated; - } else { - message.deactivated = false; + if (message.deactivated === true) { + obj.deactivated = message.deactivated; } - if (object.versionId !== undefined && object.versionId !== null) { - message.versionId = object.versionId; - } else { - message.versionId = ""; + if (message.versionId !== undefined && message.versionId !== "") { + obj.versionId = message.versionId; } + return obj; + }, + + create, I>>(base?: I): DidDocumentMetadata { + return DidDocumentMetadata.fromPartial(base ?? ({} as any)); + }, + fromPartial, I>>(object: I): DidDocumentMetadata { + const message = createBaseDidDocumentMetadata(); + message.created = object.created ?? undefined; + message.updated = object.updated ?? undefined; + message.deactivated = object.deactivated ?? undefined; + message.versionId = object.versionId ?? undefined; return message; }, }; -const baseVerificationMethod: object = { - id: "", - type: "", - controller: "", - publicKeyMultibase: "", - blockchainAccountId: "", -}; +function createBaseVerificationMethod(): VerificationMethod { + return {}; +} export const VerificationMethod = { - encode( - message: VerificationMethod, - writer: Writer = Writer.create() - ): Writer { - if (message.id !== "") { + encode(message: VerificationMethod, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { + if (message.id !== undefined && message.id !== "") { writer.uint32(10).string(message.id); } - if (message.type !== "") { + if (message.type !== undefined && message.type !== "") { writer.uint32(18).string(message.type); } - if (message.controller !== "") { + if (message.controller !== undefined && message.controller !== "") { writer.uint32(26).string(message.controller); } - if (message.publicKeyMultibase !== "") { + if (message.publicKeyMultibase !== undefined && message.publicKeyMultibase !== "") { writer.uint32(34).string(message.publicKeyMultibase); } - if (message.blockchainAccountId !== "") { + if (message.blockchainAccountId !== undefined && message.blockchainAccountId !== "") { writer.uint32(42).string(message.blockchainAccountId); } return writer; }, - decode(input: Reader | Uint8Array, length?: number): VerificationMethod { - const reader = input instanceof Uint8Array ? new Reader(input) : input; + decode(input: _m0.Reader | Uint8Array, length?: number): VerificationMethod { + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; - const message = { ...baseVerificationMethod } as VerificationMethod; + const message = createBaseVerificationMethod(); while (reader.pos < end) { const tag = reader.uint32(); switch (tag >>> 3) { case 1: + if (tag !== 10) { + break; + } + message.id = reader.string(); - break; + continue; case 2: + if (tag !== 18) { + break; + } + message.type = reader.string(); - break; + continue; case 3: + if (tag !== 26) { + break; + } + message.controller = reader.string(); - break; + continue; case 4: + if (tag !== 34) { + break; + } + message.publicKeyMultibase = reader.string(); - break; + continue; case 5: + if (tag !== 42) { + break; + } + message.blockchainAccountId = reader.string(); - break; - default: - reader.skipType(tag & 7); - break; + continue; + } + if ((tag & 7) === 4 || tag === 0) { + break; } + reader.skipType(tag & 7); } return message; }, fromJSON(object: any): VerificationMethod { - const message = { ...baseVerificationMethod } as VerificationMethod; - if (object.id !== undefined && object.id !== null) { - message.id = String(object.id); - } else { - message.id = ""; - } - if (object.type !== undefined && object.type !== null) { - message.type = String(object.type); - } else { - message.type = ""; - } - if (object.controller !== undefined && object.controller !== null) { - message.controller = String(object.controller); - } else { - message.controller = ""; - } - if ( - object.publicKeyMultibase !== undefined && - object.publicKeyMultibase !== null - ) { - message.publicKeyMultibase = String(object.publicKeyMultibase); - } else { - message.publicKeyMultibase = ""; - } - if ( - object.blockchainAccountId !== undefined && - object.blockchainAccountId !== null - ) { - message.blockchainAccountId = String(object.blockchainAccountId); - } else { - message.blockchainAccountId = ""; - } - return message; + return { + id: isSet(object.id) ? globalThis.String(object.id) : undefined, + type: isSet(object.type) ? globalThis.String(object.type) : undefined, + controller: isSet(object.controller) ? globalThis.String(object.controller) : undefined, + publicKeyMultibase: isSet(object.publicKeyMultibase) ? globalThis.String(object.publicKeyMultibase) : undefined, + blockchainAccountId: isSet(object.blockchainAccountId) + ? globalThis.String(object.blockchainAccountId) + : undefined, + }; }, toJSON(message: VerificationMethod): unknown { const obj: any = {}; - message.id !== undefined && (obj.id = message.id); - message.type !== undefined && (obj.type = message.type); - message.controller !== undefined && (obj.controller = message.controller); - message.publicKeyMultibase !== undefined && - (obj.publicKeyMultibase = message.publicKeyMultibase); - message.blockchainAccountId !== undefined && - (obj.blockchainAccountId = message.blockchainAccountId); + if (message.id !== undefined && message.id !== "") { + obj.id = message.id; + } + if (message.type !== undefined && message.type !== "") { + obj.type = message.type; + } + if (message.controller !== undefined && message.controller !== "") { + obj.controller = message.controller; + } + if (message.publicKeyMultibase !== undefined && message.publicKeyMultibase !== "") { + obj.publicKeyMultibase = message.publicKeyMultibase; + } + if (message.blockchainAccountId !== undefined && message.blockchainAccountId !== "") { + obj.blockchainAccountId = message.blockchainAccountId; + } return obj; }, - fromPartial(object: DeepPartial): VerificationMethod { - const message = { ...baseVerificationMethod } as VerificationMethod; - if (object.id !== undefined && object.id !== null) { - message.id = object.id; - } else { - message.id = ""; - } - if (object.type !== undefined && object.type !== null) { - message.type = object.type; - } else { - message.type = ""; - } - if (object.controller !== undefined && object.controller !== null) { - message.controller = object.controller; - } else { - message.controller = ""; - } - if ( - object.publicKeyMultibase !== undefined && - object.publicKeyMultibase !== null - ) { - message.publicKeyMultibase = object.publicKeyMultibase; - } else { - message.publicKeyMultibase = ""; - } - if ( - object.blockchainAccountId !== undefined && - object.blockchainAccountId !== null - ) { - message.blockchainAccountId = object.blockchainAccountId; - } else { - message.blockchainAccountId = ""; - } + create, I>>(base?: I): VerificationMethod { + return VerificationMethod.fromPartial(base ?? ({} as any)); + }, + fromPartial, I>>(object: I): VerificationMethod { + const message = createBaseVerificationMethod(); + message.id = object.id ?? undefined; + message.type = object.type ?? undefined; + message.controller = object.controller ?? undefined; + message.publicKeyMultibase = object.publicKeyMultibase ?? undefined; + message.blockchainAccountId = object.blockchainAccountId ?? undefined; return message; }, }; -const baseService: object = { id: "", type: "", serviceEndpoint: "" }; +function createBaseService(): Service { + return {}; +} export const Service = { - encode(message: Service, writer: Writer = Writer.create()): Writer { - if (message.id !== "") { + encode(message: Service, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { + if (message.id !== undefined && message.id !== "") { writer.uint32(10).string(message.id); } - if (message.type !== "") { + if (message.type !== undefined && message.type !== "") { writer.uint32(18).string(message.type); } - if (message.serviceEndpoint !== "") { + if (message.serviceEndpoint !== undefined && message.serviceEndpoint !== "") { writer.uint32(26).string(message.serviceEndpoint); } return writer; }, - decode(input: Reader | Uint8Array, length?: number): Service { - const reader = input instanceof Uint8Array ? new Reader(input) : input; + decode(input: _m0.Reader | Uint8Array, length?: number): Service { + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; - const message = { ...baseService } as Service; + const message = createBaseService(); while (reader.pos < end) { const tag = reader.uint32(); switch (tag >>> 3) { case 1: + if (tag !== 10) { + break; + } + message.id = reader.string(); - break; + continue; case 2: + if (tag !== 18) { + break; + } + message.type = reader.string(); - break; + continue; case 3: + if (tag !== 26) { + break; + } + message.serviceEndpoint = reader.string(); - break; - default: - reader.skipType(tag & 7); - break; + continue; + } + if ((tag & 7) === 4 || tag === 0) { + break; } + reader.skipType(tag & 7); } return message; }, fromJSON(object: any): Service { - const message = { ...baseService } as Service; - if (object.id !== undefined && object.id !== null) { - message.id = String(object.id); - } else { - message.id = ""; - } - if (object.type !== undefined && object.type !== null) { - message.type = String(object.type); - } else { - message.type = ""; - } - if ( - object.serviceEndpoint !== undefined && - object.serviceEndpoint !== null - ) { - message.serviceEndpoint = String(object.serviceEndpoint); - } else { - message.serviceEndpoint = ""; - } - return message; + return { + id: isSet(object.id) ? globalThis.String(object.id) : undefined, + type: isSet(object.type) ? globalThis.String(object.type) : undefined, + serviceEndpoint: isSet(object.serviceEndpoint) ? globalThis.String(object.serviceEndpoint) : undefined, + }; }, toJSON(message: Service): unknown { const obj: any = {}; - message.id !== undefined && (obj.id = message.id); - message.type !== undefined && (obj.type = message.type); - message.serviceEndpoint !== undefined && - (obj.serviceEndpoint = message.serviceEndpoint); - return obj; - }, - - fromPartial(object: DeepPartial): Service { - const message = { ...baseService } as Service; - if (object.id !== undefined && object.id !== null) { - message.id = object.id; - } else { - message.id = ""; - } - if (object.type !== undefined && object.type !== null) { - message.type = object.type; - } else { - message.type = ""; - } - if ( - object.serviceEndpoint !== undefined && - object.serviceEndpoint !== null - ) { - message.serviceEndpoint = object.serviceEndpoint; - } else { - message.serviceEndpoint = ""; + if (message.id !== undefined && message.id !== "") { + obj.id = message.id; } - return message; - }, -}; - -const baseSignInfo: object = { verification_method_id: "", signature: "" }; - -export const SignInfo = { - encode(message: SignInfo, writer: Writer = Writer.create()): Writer { - if (message.verification_method_id !== "") { - writer.uint32(10).string(message.verification_method_id); - } - if (message.signature !== "") { - writer.uint32(18).string(message.signature); + if (message.type !== undefined && message.type !== "") { + obj.type = message.type; } - if (message.clientSpec !== undefined) { - ClientSpec.encode(message.clientSpec, writer.uint32(26).fork()).ldelim(); + if (message.serviceEndpoint !== undefined && message.serviceEndpoint !== "") { + obj.serviceEndpoint = message.serviceEndpoint; } - return writer; - }, - - decode(input: Reader | Uint8Array, length?: number): SignInfo { - const reader = input instanceof Uint8Array ? new Reader(input) : input; - let end = length === undefined ? reader.len : reader.pos + length; - const message = { ...baseSignInfo } as SignInfo; - while (reader.pos < end) { - const tag = reader.uint32(); - switch (tag >>> 3) { - case 1: - message.verification_method_id = reader.string(); - break; - case 2: - message.signature = reader.string(); - break; - case 3: - message.clientSpec = ClientSpec.decode(reader, reader.uint32()); - break; - default: - reader.skipType(tag & 7); - break; - } - } - return message; - }, - - fromJSON(object: any): SignInfo { - const message = { ...baseSignInfo } as SignInfo; - if ( - object.verification_method_id !== undefined && - object.verification_method_id !== null - ) { - message.verification_method_id = String(object.verification_method_id); - } else { - message.verification_method_id = ""; - } - if (object.signature !== undefined && object.signature !== null) { - message.signature = String(object.signature); - } else { - message.signature = ""; - } - if (object.clientSpec !== undefined && object.clientSpec !== null) { - message.clientSpec = ClientSpec.fromJSON(object.clientSpec); - } else { - message.clientSpec = undefined; - } - return message; - }, - - toJSON(message: SignInfo): unknown { - const obj: any = {}; - message.verification_method_id !== undefined && - (obj.verification_method_id = message.verification_method_id); - message.signature !== undefined && (obj.signature = message.signature); - message.clientSpec !== undefined && - (obj.clientSpec = message.clientSpec - ? ClientSpec.toJSON(message.clientSpec) - : undefined); return obj; }, - fromPartial(object: DeepPartial): SignInfo { - const message = { ...baseSignInfo } as SignInfo; - if ( - object.verification_method_id !== undefined && - object.verification_method_id !== null - ) { - message.verification_method_id = object.verification_method_id; - } else { - message.verification_method_id = ""; - } - if (object.signature !== undefined && object.signature !== null) { - message.signature = object.signature; - } else { - message.signature = ""; - } - if (object.clientSpec !== undefined && object.clientSpec !== null) { - message.clientSpec = ClientSpec.fromPartial(object.clientSpec); - } else { - message.clientSpec = undefined; - } + create, I>>(base?: I): Service { + return Service.fromPartial(base ?? ({} as any)); + }, + fromPartial, I>>(object: I): Service { + const message = createBaseService(); + message.id = object.id ?? undefined; + message.type = object.type ?? undefined; + message.serviceEndpoint = object.serviceEndpoint ?? undefined; return message; }, }; -const baseDidDocumentState: object = {}; +function createBaseDidDocumentState(): DidDocumentState { + return {}; +} export const DidDocumentState = { - encode(message: DidDocumentState, writer: Writer = Writer.create()): Writer { + encode(message: DidDocumentState, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { if (message.didDocument !== undefined) { - Did.encode(message.didDocument, writer.uint32(10).fork()).ldelim(); + DidDocument.encode(message.didDocument, writer.uint32(10).fork()).ldelim(); } if (message.didDocumentMetadata !== undefined) { - Metadata.encode( - message.didDocumentMetadata, - writer.uint32(18).fork() - ).ldelim(); + DidDocumentMetadata.encode(message.didDocumentMetadata, writer.uint32(18).fork()).ldelim(); } return writer; }, - decode(input: Reader | Uint8Array, length?: number): DidDocumentState { - const reader = input instanceof Uint8Array ? new Reader(input) : input; + decode(input: _m0.Reader | Uint8Array, length?: number): DidDocumentState { + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; - const message = { ...baseDidDocumentState } as DidDocumentState; + const message = createBaseDidDocumentState(); while (reader.pos < end) { const tag = reader.uint32(); switch (tag >>> 3) { case 1: - message.didDocument = Did.decode(reader, reader.uint32()); - break; + if (tag !== 10) { + break; + } + + message.didDocument = DidDocument.decode(reader, reader.uint32()); + continue; case 2: - message.didDocumentMetadata = Metadata.decode( - reader, - reader.uint32() - ); - break; - default: - reader.skipType(tag & 7); - break; + if (tag !== 18) { + break; + } + + message.didDocumentMetadata = DidDocumentMetadata.decode(reader, reader.uint32()); + continue; } + if ((tag & 7) === 4 || tag === 0) { + break; + } + reader.skipType(tag & 7); } return message; }, fromJSON(object: any): DidDocumentState { - const message = { ...baseDidDocumentState } as DidDocumentState; - if (object.didDocument !== undefined && object.didDocument !== null) { - message.didDocument = Did.fromJSON(object.didDocument); - } else { - message.didDocument = undefined; - } - if ( - object.didDocumentMetadata !== undefined && - object.didDocumentMetadata !== null - ) { - message.didDocumentMetadata = Metadata.fromJSON( - object.didDocumentMetadata - ); - } else { - message.didDocumentMetadata = undefined; - } - return message; + return { + didDocument: isSet(object.didDocument) ? DidDocument.fromJSON(object.didDocument) : undefined, + didDocumentMetadata: isSet(object.didDocumentMetadata) + ? DidDocumentMetadata.fromJSON(object.didDocumentMetadata) + : undefined, + }; }, toJSON(message: DidDocumentState): unknown { const obj: any = {}; - message.didDocument !== undefined && - (obj.didDocument = message.didDocument - ? Did.toJSON(message.didDocument) - : undefined); - message.didDocumentMetadata !== undefined && - (obj.didDocumentMetadata = message.didDocumentMetadata - ? Metadata.toJSON(message.didDocumentMetadata) - : undefined); + if (message.didDocument !== undefined) { + obj.didDocument = DidDocument.toJSON(message.didDocument); + } + if (message.didDocumentMetadata !== undefined) { + obj.didDocumentMetadata = DidDocumentMetadata.toJSON(message.didDocumentMetadata); + } return obj; }, - fromPartial(object: DeepPartial): DidDocumentState { - const message = { ...baseDidDocumentState } as DidDocumentState; - if (object.didDocument !== undefined && object.didDocument !== null) { - message.didDocument = Did.fromPartial(object.didDocument); - } else { - message.didDocument = undefined; - } - if ( - object.didDocumentMetadata !== undefined && - object.didDocumentMetadata !== null - ) { - message.didDocumentMetadata = Metadata.fromPartial( - object.didDocumentMetadata - ); - } else { - message.didDocumentMetadata = undefined; - } + create, I>>(base?: I): DidDocumentState { + return DidDocumentState.fromPartial(base ?? ({} as any)); + }, + fromPartial, I>>(object: I): DidDocumentState { + const message = createBaseDidDocumentState(); + message.didDocument = (object.didDocument !== undefined && object.didDocument !== null) + ? DidDocument.fromPartial(object.didDocument) + : undefined; + message.didDocumentMetadata = (object.didDocumentMetadata !== undefined && object.didDocumentMetadata !== null) + ? DidDocumentMetadata.fromPartial(object.didDocumentMetadata) + : undefined; return message; }, }; -type Builtin = Date | Function | Uint8Array | string | number | undefined; -export type DeepPartial = T extends Builtin - ? T - : T extends Array - ? Array> - : T extends ReadonlyArray - ? ReadonlyArray> - : T extends {} - ? { [K in keyof T]?: DeepPartial } +type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined; + +export type DeepPartial = T extends Builtin ? T + : T extends globalThis.Array ? globalThis.Array> + : T extends ReadonlyArray ? ReadonlyArray> + : T extends {} ? { [K in keyof T]?: DeepPartial } : Partial; + +type KeysOfUnion = T extends T ? keyof T : never; +export type Exact = P extends Builtin ? P + : P & { [K in keyof P]: Exact } & { [K in Exclude>]: never }; + +function isSet(value: any): boolean { + return value !== null && value !== undefined; +} diff --git a/libs/generated/ssi/genesis.ts b/libs/generated/ssi/genesis.ts new file mode 100644 index 0000000..b3098bd --- /dev/null +++ b/libs/generated/ssi/genesis.ts @@ -0,0 +1,82 @@ +/* eslint-disable */ +import _m0 from "protobufjs/minimal"; + +export const protobufPackage = "hypersign.ssi.v1"; + +/** GenesisState defines the ssi module's genesis state. */ +export interface GenesisState { + chainNamespace?: string | undefined; +} + +function createBaseGenesisState(): GenesisState { + return {}; +} + +export const GenesisState = { + encode(message: GenesisState, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { + if (message.chainNamespace !== undefined && message.chainNamespace !== "") { + writer.uint32(10).string(message.chainNamespace); + } + return writer; + }, + + decode(input: _m0.Reader | Uint8Array, length?: number): GenesisState { + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseGenesisState(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + if (tag !== 10) { + break; + } + + message.chainNamespace = reader.string(); + continue; + } + if ((tag & 7) === 4 || tag === 0) { + break; + } + reader.skipType(tag & 7); + } + return message; + }, + + fromJSON(object: any): GenesisState { + return { chainNamespace: isSet(object.chainNamespace) ? globalThis.String(object.chainNamespace) : undefined }; + }, + + toJSON(message: GenesisState): unknown { + const obj: any = {}; + if (message.chainNamespace !== undefined && message.chainNamespace !== "") { + obj.chainNamespace = message.chainNamespace; + } + return obj; + }, + + create, I>>(base?: I): GenesisState { + return GenesisState.fromPartial(base ?? ({} as any)); + }, + fromPartial, I>>(object: I): GenesisState { + const message = createBaseGenesisState(); + message.chainNamespace = object.chainNamespace ?? undefined; + return message; + }, +}; + +type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined; + +export type DeepPartial = T extends Builtin ? T + : T extends globalThis.Array ? globalThis.Array> + : T extends ReadonlyArray ? ReadonlyArray> + : T extends {} ? { [K in keyof T]?: DeepPartial } + : Partial; + +type KeysOfUnion = T extends T ? keyof T : never; +export type Exact = P extends Builtin ? P + : P & { [K in keyof P]: Exact } & { [K in Exclude>]: never }; + +function isSet(value: any): boolean { + return value !== null && value !== undefined; +} diff --git a/libs/generated/ssi/proof.ts b/libs/generated/ssi/proof.ts new file mode 100644 index 0000000..283a127 --- /dev/null +++ b/libs/generated/ssi/proof.ts @@ -0,0 +1,164 @@ +/* eslint-disable */ +import _m0 from "protobufjs/minimal"; +import { ClientSpecType, clientSpecTypeFromJSON, clientSpecTypeToJSON, clientSpecTypeToNumber } from "./client_spec"; + +export const protobufPackage = "hypersign.ssi.v1"; + +export interface DocumentProof { + type?: string | undefined; + created?: string | undefined; + verificationMethod?: string | undefined; + proofPurpose?: string | undefined; + proofValue?: string | undefined; + clientSpecType?: ClientSpecType | undefined; +} + +function createBaseDocumentProof(): DocumentProof { + return {}; +} + +export const DocumentProof = { + encode(message: DocumentProof, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { + if (message.type !== undefined && message.type !== "") { + writer.uint32(10).string(message.type); + } + if (message.created !== undefined && message.created !== "") { + writer.uint32(18).string(message.created); + } + if (message.verificationMethod !== undefined && message.verificationMethod !== "") { + writer.uint32(26).string(message.verificationMethod); + } + if (message.proofPurpose !== undefined && message.proofPurpose !== "") { + writer.uint32(34).string(message.proofPurpose); + } + if (message.proofValue !== undefined && message.proofValue !== "") { + writer.uint32(42).string(message.proofValue); + } + if (message.clientSpecType !== undefined && message.clientSpecType !== ClientSpecType.CLIENT_SPEC_TYPE_NONE) { + writer.uint32(48).int32(clientSpecTypeToNumber(message.clientSpecType)); + } + return writer; + }, + + decode(input: _m0.Reader | Uint8Array, length?: number): DocumentProof { + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseDocumentProof(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + if (tag !== 10) { + break; + } + + message.type = reader.string(); + continue; + case 2: + if (tag !== 18) { + break; + } + + message.created = reader.string(); + continue; + case 3: + if (tag !== 26) { + break; + } + + message.verificationMethod = reader.string(); + continue; + case 4: + if (tag !== 34) { + break; + } + + message.proofPurpose = reader.string(); + continue; + case 5: + if (tag !== 42) { + break; + } + + message.proofValue = reader.string(); + continue; + case 6: + if (tag !== 48) { + break; + } + + message.clientSpecType = clientSpecTypeFromJSON(reader.int32()); + continue; + } + if ((tag & 7) === 4 || tag === 0) { + break; + } + reader.skipType(tag & 7); + } + return message; + }, + + fromJSON(object: any): DocumentProof { + return { + type: isSet(object.type) ? globalThis.String(object.type) : undefined, + created: isSet(object.created) ? globalThis.String(object.created) : undefined, + verificationMethod: isSet(object.verificationMethod) ? globalThis.String(object.verificationMethod) : undefined, + proofPurpose: isSet(object.proofPurpose) ? globalThis.String(object.proofPurpose) : undefined, + proofValue: isSet(object.proofValue) ? globalThis.String(object.proofValue) : undefined, + clientSpecType: isSet(object.clientSpecType) ? clientSpecTypeFromJSON(object.clientSpecType) : undefined, + }; + }, + + toJSON(message: DocumentProof): unknown { + const obj: any = {}; + if (message.type !== undefined && message.type !== "") { + obj.type = message.type; + } + if (message.created !== undefined && message.created !== "") { + obj.created = message.created; + } + if (message.verificationMethod !== undefined && message.verificationMethod !== "") { + obj.verificationMethod = message.verificationMethod; + } + if (message.proofPurpose !== undefined && message.proofPurpose !== "") { + obj.proofPurpose = message.proofPurpose; + } + if (message.proofValue !== undefined && message.proofValue !== "") { + obj.proofValue = message.proofValue; + } + if (message.clientSpecType !== undefined && message.clientSpecType !== ClientSpecType.CLIENT_SPEC_TYPE_NONE) { + obj.clientSpecType = clientSpecTypeToJSON(message.clientSpecType); + } + return obj; + }, + + create, I>>(base?: I): DocumentProof { + return DocumentProof.fromPartial(base ?? ({} as any)); + }, + fromPartial, I>>(object: I): DocumentProof { + const message = createBaseDocumentProof(); + message.type = object.type ?? undefined; + message.created = object.created ?? undefined; + message.verificationMethod = object.verificationMethod ?? undefined; + message.proofPurpose = object.proofPurpose ?? undefined; + message.proofValue = object.proofValue ?? undefined; + message.clientSpecType = object.clientSpecType ?? undefined; + return message; + }, +}; + +type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined; + +export type DeepPartial = T extends Builtin ? T + : T extends globalThis.Array ? globalThis.Array> + : T extends ReadonlyArray ? ReadonlyArray> + : T extends {} ? { [K in keyof T]?: DeepPartial } + : Partial; + +type KeysOfUnion = T extends T ? keyof T : never; +export type Exact = P extends Builtin ? P + : P & { [K in keyof P]: Exact } & { [K in Exclude>]: never }; + +function isSet(value: any): boolean { + return value !== null && value !== undefined; +} diff --git a/libs/generated/ssi/schema.ts b/libs/generated/ssi/schema.ts deleted file mode 100644 index a8f7ea0..0000000 --- a/libs/generated/ssi/schema.ts +++ /dev/null @@ -1,708 +0,0 @@ -/* eslint-disable */ -import { Writer, Reader } from "protobufjs/minimal"; - -export const protobufPackage = "hypersignprotocol.hidnode.ssi"; - -export interface SchemaDocument { - type: string; - modelVersion: string; - id: string; - name: string; - author: string; - authored: string; - schema: SchemaProperty | undefined; -} - -export interface SchemaProperty { - schema: string; - description: string; - type: string; - properties: string; - required: string[]; - additionalProperties: boolean; -} - -export interface SchemaProof { - type: string; - created: string; - verificationMethod: string; - proofPurpose: string; - proofValue: string; -} - -export interface Schema { - type: string; - modelVersion: string; - id: string; - name: string; - author: string; - authored: string; - schema: SchemaProperty | undefined; - proof: SchemaProof | undefined; -} - -const baseSchemaDocument: object = { - type: "", - modelVersion: "", - id: "", - name: "", - author: "", - authored: "", -}; - -export const SchemaDocument = { - encode(message: SchemaDocument, writer: Writer = Writer.create()): Writer { - if (message.type !== "") { - writer.uint32(10).string(message.type); - } - if (message.modelVersion !== "") { - writer.uint32(18).string(message.modelVersion); - } - if (message.id !== "") { - writer.uint32(26).string(message.id); - } - if (message.name !== "") { - writer.uint32(34).string(message.name); - } - if (message.author !== "") { - writer.uint32(42).string(message.author); - } - if (message.authored !== "") { - writer.uint32(50).string(message.authored); - } - if (message.schema !== undefined) { - SchemaProperty.encode(message.schema, writer.uint32(58).fork()).ldelim(); - } - return writer; - }, - - decode(input: Reader | Uint8Array, length?: number): SchemaDocument { - const reader = input instanceof Uint8Array ? new Reader(input) : input; - let end = length === undefined ? reader.len : reader.pos + length; - const message = { ...baseSchemaDocument } as SchemaDocument; - while (reader.pos < end) { - const tag = reader.uint32(); - switch (tag >>> 3) { - case 1: - message.type = reader.string(); - break; - case 2: - message.modelVersion = reader.string(); - break; - case 3: - message.id = reader.string(); - break; - case 4: - message.name = reader.string(); - break; - case 5: - message.author = reader.string(); - break; - case 6: - message.authored = reader.string(); - break; - case 7: - message.schema = SchemaProperty.decode(reader, reader.uint32()); - break; - default: - reader.skipType(tag & 7); - break; - } - } - return message; - }, - - fromJSON(object: any): SchemaDocument { - const message = { ...baseSchemaDocument } as SchemaDocument; - if (object.type !== undefined && object.type !== null) { - message.type = String(object.type); - } else { - message.type = ""; - } - if (object.modelVersion !== undefined && object.modelVersion !== null) { - message.modelVersion = String(object.modelVersion); - } else { - message.modelVersion = ""; - } - if (object.id !== undefined && object.id !== null) { - message.id = String(object.id); - } else { - message.id = ""; - } - if (object.name !== undefined && object.name !== null) { - message.name = String(object.name); - } else { - message.name = ""; - } - if (object.author !== undefined && object.author !== null) { - message.author = String(object.author); - } else { - message.author = ""; - } - if (object.authored !== undefined && object.authored !== null) { - message.authored = String(object.authored); - } else { - message.authored = ""; - } - if (object.schema !== undefined && object.schema !== null) { - message.schema = SchemaProperty.fromJSON(object.schema); - } else { - message.schema = undefined; - } - return message; - }, - - toJSON(message: SchemaDocument): unknown { - const obj: any = {}; - message.type !== undefined && (obj.type = message.type); - message.modelVersion !== undefined && - (obj.modelVersion = message.modelVersion); - message.id !== undefined && (obj.id = message.id); - message.name !== undefined && (obj.name = message.name); - message.author !== undefined && (obj.author = message.author); - message.authored !== undefined && (obj.authored = message.authored); - message.schema !== undefined && - (obj.schema = message.schema - ? SchemaProperty.toJSON(message.schema) - : undefined); - return obj; - }, - - fromPartial(object: DeepPartial): SchemaDocument { - const message = { ...baseSchemaDocument } as SchemaDocument; - if (object.type !== undefined && object.type !== null) { - message.type = object.type; - } else { - message.type = ""; - } - if (object.modelVersion !== undefined && object.modelVersion !== null) { - message.modelVersion = object.modelVersion; - } else { - message.modelVersion = ""; - } - if (object.id !== undefined && object.id !== null) { - message.id = object.id; - } else { - message.id = ""; - } - if (object.name !== undefined && object.name !== null) { - message.name = object.name; - } else { - message.name = ""; - } - if (object.author !== undefined && object.author !== null) { - message.author = object.author; - } else { - message.author = ""; - } - if (object.authored !== undefined && object.authored !== null) { - message.authored = object.authored; - } else { - message.authored = ""; - } - if (object.schema !== undefined && object.schema !== null) { - message.schema = SchemaProperty.fromPartial(object.schema); - } else { - message.schema = undefined; - } - return message; - }, -}; - -const baseSchemaProperty: object = { - schema: "", - description: "", - type: "", - properties: "", - required: "", - additionalProperties: false, -}; - -export const SchemaProperty = { - encode(message: SchemaProperty, writer: Writer = Writer.create()): Writer { - if (message.schema !== "") { - writer.uint32(10).string(message.schema); - } - if (message.description !== "") { - writer.uint32(18).string(message.description); - } - if (message.type !== "") { - writer.uint32(26).string(message.type); - } - if (message.properties !== "") { - writer.uint32(34).string(message.properties); - } - for (const v of message.required) { - writer.uint32(42).string(v!); - } - if (message.additionalProperties === true) { - writer.uint32(48).bool(message.additionalProperties); - } - return writer; - }, - - decode(input: Reader | Uint8Array, length?: number): SchemaProperty { - const reader = input instanceof Uint8Array ? new Reader(input) : input; - let end = length === undefined ? reader.len : reader.pos + length; - const message = { ...baseSchemaProperty } as SchemaProperty; - message.required = []; - while (reader.pos < end) { - const tag = reader.uint32(); - switch (tag >>> 3) { - case 1: - message.schema = reader.string(); - break; - case 2: - message.description = reader.string(); - break; - case 3: - message.type = reader.string(); - break; - case 4: - message.properties = reader.string(); - break; - case 5: - message.required.push(reader.string()); - break; - case 6: - message.additionalProperties = reader.bool(); - break; - default: - reader.skipType(tag & 7); - break; - } - } - return message; - }, - - fromJSON(object: any): SchemaProperty { - const message = { ...baseSchemaProperty } as SchemaProperty; - message.required = []; - if (object.schema !== undefined && object.schema !== null) { - message.schema = String(object.schema); - } else { - message.schema = ""; - } - if (object.description !== undefined && object.description !== null) { - message.description = String(object.description); - } else { - message.description = ""; - } - if (object.type !== undefined && object.type !== null) { - message.type = String(object.type); - } else { - message.type = ""; - } - if (object.properties !== undefined && object.properties !== null) { - message.properties = String(object.properties); - } else { - message.properties = ""; - } - if (object.required !== undefined && object.required !== null) { - for (const e of object.required) { - message.required.push(String(e)); - } - } - if ( - object.additionalProperties !== undefined && - object.additionalProperties !== null - ) { - message.additionalProperties = Boolean(object.additionalProperties); - } else { - message.additionalProperties = false; - } - return message; - }, - - toJSON(message: SchemaProperty): unknown { - const obj: any = {}; - message.schema !== undefined && (obj.schema = message.schema); - message.description !== undefined && - (obj.description = message.description); - message.type !== undefined && (obj.type = message.type); - message.properties !== undefined && (obj.properties = message.properties); - if (message.required) { - obj.required = message.required.map((e) => e); - } else { - obj.required = []; - } - message.additionalProperties !== undefined && - (obj.additionalProperties = message.additionalProperties); - return obj; - }, - - fromPartial(object: DeepPartial): SchemaProperty { - const message = { ...baseSchemaProperty } as SchemaProperty; - message.required = []; - if (object.schema !== undefined && object.schema !== null) { - message.schema = object.schema; - } else { - message.schema = ""; - } - if (object.description !== undefined && object.description !== null) { - message.description = object.description; - } else { - message.description = ""; - } - if (object.type !== undefined && object.type !== null) { - message.type = object.type; - } else { - message.type = ""; - } - if (object.properties !== undefined && object.properties !== null) { - message.properties = object.properties; - } else { - message.properties = ""; - } - if (object.required !== undefined && object.required !== null) { - for (const e of object.required) { - message.required.push(e); - } - } - if ( - object.additionalProperties !== undefined && - object.additionalProperties !== null - ) { - message.additionalProperties = object.additionalProperties; - } else { - message.additionalProperties = false; - } - return message; - }, -}; - -const baseSchemaProof: object = { - type: "", - created: "", - verificationMethod: "", - proofPurpose: "", - proofValue: "", -}; - -export const SchemaProof = { - encode(message: SchemaProof, writer: Writer = Writer.create()): Writer { - if (message.type !== "") { - writer.uint32(10).string(message.type); - } - if (message.created !== "") { - writer.uint32(18).string(message.created); - } - if (message.verificationMethod !== "") { - writer.uint32(34).string(message.verificationMethod); - } - if (message.proofPurpose !== "") { - writer.uint32(42).string(message.proofPurpose); - } - if (message.proofValue !== "") { - writer.uint32(50).string(message.proofValue); - } - return writer; - }, - - decode(input: Reader | Uint8Array, length?: number): SchemaProof { - const reader = input instanceof Uint8Array ? new Reader(input) : input; - let end = length === undefined ? reader.len : reader.pos + length; - const message = { ...baseSchemaProof } as SchemaProof; - while (reader.pos < end) { - const tag = reader.uint32(); - switch (tag >>> 3) { - case 1: - message.type = reader.string(); - break; - case 2: - message.created = reader.string(); - break; - case 4: - message.verificationMethod = reader.string(); - break; - case 5: - message.proofPurpose = reader.string(); - break; - case 6: - message.proofValue = reader.string(); - break; - default: - reader.skipType(tag & 7); - break; - } - } - return message; - }, - - fromJSON(object: any): SchemaProof { - const message = { ...baseSchemaProof } as SchemaProof; - if (object.type !== undefined && object.type !== null) { - message.type = String(object.type); - } else { - message.type = ""; - } - if (object.created !== undefined && object.created !== null) { - message.created = String(object.created); - } else { - message.created = ""; - } - if ( - object.verificationMethod !== undefined && - object.verificationMethod !== null - ) { - message.verificationMethod = String(object.verificationMethod); - } else { - message.verificationMethod = ""; - } - if (object.proofPurpose !== undefined && object.proofPurpose !== null) { - message.proofPurpose = String(object.proofPurpose); - } else { - message.proofPurpose = ""; - } - if (object.proofValue !== undefined && object.proofValue !== null) { - message.proofValue = String(object.proofValue); - } else { - message.proofValue = ""; - } - return message; - }, - - toJSON(message: SchemaProof): unknown { - const obj: any = {}; - message.type !== undefined && (obj.type = message.type); - message.created !== undefined && (obj.created = message.created); - message.verificationMethod !== undefined && - (obj.verificationMethod = message.verificationMethod); - message.proofPurpose !== undefined && - (obj.proofPurpose = message.proofPurpose); - message.proofValue !== undefined && (obj.proofValue = message.proofValue); - return obj; - }, - - fromPartial(object: DeepPartial): SchemaProof { - const message = { ...baseSchemaProof } as SchemaProof; - if (object.type !== undefined && object.type !== null) { - message.type = object.type; - } else { - message.type = ""; - } - if (object.created !== undefined && object.created !== null) { - message.created = object.created; - } else { - message.created = ""; - } - if ( - object.verificationMethod !== undefined && - object.verificationMethod !== null - ) { - message.verificationMethod = object.verificationMethod; - } else { - message.verificationMethod = ""; - } - if (object.proofPurpose !== undefined && object.proofPurpose !== null) { - message.proofPurpose = object.proofPurpose; - } else { - message.proofPurpose = ""; - } - if (object.proofValue !== undefined && object.proofValue !== null) { - message.proofValue = object.proofValue; - } else { - message.proofValue = ""; - } - return message; - }, -}; - -const baseSchema: object = { - type: "", - modelVersion: "", - id: "", - name: "", - author: "", - authored: "", -}; - -export const Schema = { - encode(message: Schema, writer: Writer = Writer.create()): Writer { - if (message.type !== "") { - writer.uint32(10).string(message.type); - } - if (message.modelVersion !== "") { - writer.uint32(18).string(message.modelVersion); - } - if (message.id !== "") { - writer.uint32(26).string(message.id); - } - if (message.name !== "") { - writer.uint32(34).string(message.name); - } - if (message.author !== "") { - writer.uint32(42).string(message.author); - } - if (message.authored !== "") { - writer.uint32(50).string(message.authored); - } - if (message.schema !== undefined) { - SchemaProperty.encode(message.schema, writer.uint32(58).fork()).ldelim(); - } - if (message.proof !== undefined) { - SchemaProof.encode(message.proof, writer.uint32(66).fork()).ldelim(); - } - return writer; - }, - - decode(input: Reader | Uint8Array, length?: number): Schema { - const reader = input instanceof Uint8Array ? new Reader(input) : input; - let end = length === undefined ? reader.len : reader.pos + length; - const message = { ...baseSchema } as Schema; - while (reader.pos < end) { - const tag = reader.uint32(); - switch (tag >>> 3) { - case 1: - message.type = reader.string(); - break; - case 2: - message.modelVersion = reader.string(); - break; - case 3: - message.id = reader.string(); - break; - case 4: - message.name = reader.string(); - break; - case 5: - message.author = reader.string(); - break; - case 6: - message.authored = reader.string(); - break; - case 7: - message.schema = SchemaProperty.decode(reader, reader.uint32()); - break; - case 8: - message.proof = SchemaProof.decode(reader, reader.uint32()); - break; - default: - reader.skipType(tag & 7); - break; - } - } - return message; - }, - - fromJSON(object: any): Schema { - const message = { ...baseSchema } as Schema; - if (object.type !== undefined && object.type !== null) { - message.type = String(object.type); - } else { - message.type = ""; - } - if (object.modelVersion !== undefined && object.modelVersion !== null) { - message.modelVersion = String(object.modelVersion); - } else { - message.modelVersion = ""; - } - if (object.id !== undefined && object.id !== null) { - message.id = String(object.id); - } else { - message.id = ""; - } - if (object.name !== undefined && object.name !== null) { - message.name = String(object.name); - } else { - message.name = ""; - } - if (object.author !== undefined && object.author !== null) { - message.author = String(object.author); - } else { - message.author = ""; - } - if (object.authored !== undefined && object.authored !== null) { - message.authored = String(object.authored); - } else { - message.authored = ""; - } - if (object.schema !== undefined && object.schema !== null) { - message.schema = SchemaProperty.fromJSON(object.schema); - } else { - message.schema = undefined; - } - if (object.proof !== undefined && object.proof !== null) { - message.proof = SchemaProof.fromJSON(object.proof); - } else { - message.proof = undefined; - } - return message; - }, - - toJSON(message: Schema): unknown { - const obj: any = {}; - message.type !== undefined && (obj.type = message.type); - message.modelVersion !== undefined && - (obj.modelVersion = message.modelVersion); - message.id !== undefined && (obj.id = message.id); - message.name !== undefined && (obj.name = message.name); - message.author !== undefined && (obj.author = message.author); - message.authored !== undefined && (obj.authored = message.authored); - message.schema !== undefined && - (obj.schema = message.schema - ? SchemaProperty.toJSON(message.schema) - : undefined); - message.proof !== undefined && - (obj.proof = message.proof - ? SchemaProof.toJSON(message.proof) - : undefined); - return obj; - }, - - fromPartial(object: DeepPartial): Schema { - const message = { ...baseSchema } as Schema; - if (object.type !== undefined && object.type !== null) { - message.type = object.type; - } else { - message.type = ""; - } - if (object.modelVersion !== undefined && object.modelVersion !== null) { - message.modelVersion = object.modelVersion; - } else { - message.modelVersion = ""; - } - if (object.id !== undefined && object.id !== null) { - message.id = object.id; - } else { - message.id = ""; - } - if (object.name !== undefined && object.name !== null) { - message.name = object.name; - } else { - message.name = ""; - } - if (object.author !== undefined && object.author !== null) { - message.author = object.author; - } else { - message.author = ""; - } - if (object.authored !== undefined && object.authored !== null) { - message.authored = object.authored; - } else { - message.authored = ""; - } - if (object.schema !== undefined && object.schema !== null) { - message.schema = SchemaProperty.fromPartial(object.schema); - } else { - message.schema = undefined; - } - if (object.proof !== undefined && object.proof !== null) { - message.proof = SchemaProof.fromPartial(object.proof); - } else { - message.proof = undefined; - } - return message; - }, -}; - -type Builtin = Date | Function | Uint8Array | string | number | undefined; -export type DeepPartial = T extends Builtin - ? T - : T extends Array - ? Array> - : T extends ReadonlyArray - ? ReadonlyArray> - : T extends {} - ? { [K in keyof T]?: DeepPartial } - : Partial; diff --git a/libs/generated/ssi/tx.ts b/libs/generated/ssi/tx.ts index 1b6436e..489186b 100644 --- a/libs/generated/ssi/tx.ts +++ b/libs/generated/ssi/tx.ts @@ -1,1103 +1,1196 @@ /* eslint-disable */ -import { Reader, util, configure, Writer } from "protobufjs/minimal"; -import * as Long from "long"; -import { Did, SignInfo } from "./did"; -import { SchemaDocument, SchemaProof } from "./schema"; -import { ClientSpec } from "./clientSpec"; -import { CredentialStatus, CredentialProof } from "./credential"; - -export const protobufPackage = "hypersignprotocol.hidnode.ssi"; - -export interface MsgCreateDID { - didDocString: Did | undefined; - signatures: SignInfo[]; - creator: string; +import _m0 from "protobufjs/minimal"; +import { CredentialSchemaDocument } from "./credential_schema"; +import { CredentialStatusDocument } from "./credential_status"; +import { DidDocument } from "./did"; +import { DocumentProof } from "./proof"; + +export const protobufPackage = "hypersign.ssi.v1"; + +export interface MsgRegisterDID { + didDocument?: DidDocument | undefined; + didDocumentProofs?: DocumentProof[] | undefined; + txAuthor?: string | undefined; } -export interface MsgCreateDIDResponse { - id: number; +export interface MsgRegisterDIDResponse { } export interface MsgUpdateDID { - didDocString: Did | undefined; - version_id: string; - signatures: SignInfo[]; - creator: string; + didDocument?: DidDocument | undefined; + didDocumentProofs?: DocumentProof[] | undefined; + versionId?: string | undefined; + txAuthor?: string | undefined; } export interface MsgUpdateDIDResponse { - updateId: string; } -export interface MsgCreateSchema { - creator: string; - schemaDoc: SchemaDocument | undefined; - schemaProof: SchemaProof | undefined; - clientSpec: ClientSpec | undefined; +export interface MsgDeactivateDID { + didDocumentId?: string | undefined; + didDocumentProofs?: DocumentProof[] | undefined; + versionId?: string | undefined; + txAuthor?: string | undefined; } -export interface MsgCreateSchemaResponse { - id: number; +export interface MsgDeactivateDIDResponse { } -export interface MsgDeactivateDID { - creator: string; - didId: string; - version_id: string; - signatures: SignInfo[]; +export interface MsgRegisterCredentialSchema { + credentialSchemaDocument?: CredentialSchemaDocument | undefined; + credentialSchemaProof?: DocumentProof | undefined; + txAuthor?: string | undefined; } -export interface MsgDeactivateDIDResponse { - id: number; +export interface MsgRegisterCredentialSchemaResponse { +} + +export interface MsgUpdateCredentialSchema { + credentialSchemaDocument?: CredentialSchemaDocument | undefined; + credentialSchemaProof?: DocumentProof | undefined; + txAuthor?: string | undefined; +} + +export interface MsgUpdateCredentialSchemaResponse { } export interface MsgRegisterCredentialStatus { - creator: string; - credentialStatus: CredentialStatus | undefined; - proof: CredentialProof | undefined; - clientSpec: ClientSpec | undefined; + credentialStatusDocument?: CredentialStatusDocument | undefined; + credentialStatusProof?: DocumentProof | undefined; + txAuthor?: string | undefined; } export interface MsgRegisterCredentialStatusResponse { - id: number; } -const baseMsgCreateDID: object = { creator: "" }; +export interface MsgUpdateCredentialStatus { + credentialStatusDocument?: CredentialStatusDocument | undefined; + credentialStatusProof?: DocumentProof | undefined; + txAuthor?: string | undefined; +} -export const MsgCreateDID = { - encode(message: MsgCreateDID, writer: Writer = Writer.create()): Writer { - if (message.didDocString !== undefined) { - Did.encode(message.didDocString, writer.uint32(10).fork()).ldelim(); +export interface MsgUpdateCredentialStatusResponse { +} + +function createBaseMsgRegisterDID(): MsgRegisterDID { + return {}; +} + +export const MsgRegisterDID = { + encode(message: MsgRegisterDID, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { + if (message.didDocument !== undefined) { + DidDocument.encode(message.didDocument, writer.uint32(10).fork()).ldelim(); } - for (const v of message.signatures) { - SignInfo.encode(v!, writer.uint32(18).fork()).ldelim(); + if (message.didDocumentProofs !== undefined && message.didDocumentProofs.length !== 0) { + for (const v of message.didDocumentProofs) { + DocumentProof.encode(v!, writer.uint32(18).fork()).ldelim(); + } } - if (message.creator !== "") { - writer.uint32(26).string(message.creator); + if (message.txAuthor !== undefined && message.txAuthor !== "") { + writer.uint32(26).string(message.txAuthor); } return writer; }, - decode(input: Reader | Uint8Array, length?: number): MsgCreateDID { - const reader = input instanceof Uint8Array ? new Reader(input) : input; + decode(input: _m0.Reader | Uint8Array, length?: number): MsgRegisterDID { + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; - const message = { ...baseMsgCreateDID } as MsgCreateDID; - message.signatures = []; + const message = createBaseMsgRegisterDID(); while (reader.pos < end) { const tag = reader.uint32(); switch (tag >>> 3) { case 1: - message.didDocString = Did.decode(reader, reader.uint32()); - break; + if (tag !== 10) { + break; + } + + message.didDocument = DidDocument.decode(reader, reader.uint32()); + continue; case 2: - message.signatures.push(SignInfo.decode(reader, reader.uint32())); - break; + if (tag !== 18) { + break; + } + + if (message.didDocumentProofs === undefined) { + message.didDocumentProofs = []; + } + message.didDocumentProofs!.push(DocumentProof.decode(reader, reader.uint32())); + continue; case 3: - message.creator = reader.string(); - break; - default: - reader.skipType(tag & 7); - break; + if (tag !== 26) { + break; + } + + message.txAuthor = reader.string(); + continue; + } + if ((tag & 7) === 4 || tag === 0) { + break; } + reader.skipType(tag & 7); } return message; }, - fromJSON(object: any): MsgCreateDID { - const message = { ...baseMsgCreateDID } as MsgCreateDID; - message.signatures = []; - if (object.didDocString !== undefined && object.didDocString !== null) { - message.didDocString = Did.fromJSON(object.didDocString); - } else { - message.didDocString = undefined; - } - if (object.signatures !== undefined && object.signatures !== null) { - for (const e of object.signatures) { - message.signatures.push(SignInfo.fromJSON(e)); - } - } - if (object.creator !== undefined && object.creator !== null) { - message.creator = String(object.creator); - } else { - message.creator = ""; - } - return message; + fromJSON(object: any): MsgRegisterDID { + return { + didDocument: isSet(object.didDocument) ? DidDocument.fromJSON(object.didDocument) : undefined, + didDocumentProofs: globalThis.Array.isArray(object?.didDocumentProofs) + ? object.didDocumentProofs.map((e: any) => DocumentProof.fromJSON(e)) + : undefined, + txAuthor: isSet(object.txAuthor) ? globalThis.String(object.txAuthor) : undefined, + }; }, - toJSON(message: MsgCreateDID): unknown { + toJSON(message: MsgRegisterDID): unknown { const obj: any = {}; - message.didDocString !== undefined && - (obj.didDocString = message.didDocString - ? Did.toJSON(message.didDocString) - : undefined); - if (message.signatures) { - obj.signatures = message.signatures.map((e) => - e ? SignInfo.toJSON(e) : undefined - ); - } else { - obj.signatures = []; + if (message.didDocument !== undefined) { + obj.didDocument = DidDocument.toJSON(message.didDocument); + } + if (message.didDocumentProofs?.length) { + obj.didDocumentProofs = message.didDocumentProofs.map((e) => DocumentProof.toJSON(e)); + } + if (message.txAuthor !== undefined && message.txAuthor !== "") { + obj.txAuthor = message.txAuthor; } - message.creator !== undefined && (obj.creator = message.creator); return obj; }, - fromPartial(object: DeepPartial): MsgCreateDID { - const message = { ...baseMsgCreateDID } as MsgCreateDID; - message.signatures = []; - if (object.didDocString !== undefined && object.didDocString !== null) { - message.didDocString = Did.fromPartial(object.didDocString); - } else { - message.didDocString = undefined; - } - if (object.signatures !== undefined && object.signatures !== null) { - for (const e of object.signatures) { - message.signatures.push(SignInfo.fromPartial(e)); - } - } - if (object.creator !== undefined && object.creator !== null) { - message.creator = object.creator; - } else { - message.creator = ""; - } + create, I>>(base?: I): MsgRegisterDID { + return MsgRegisterDID.fromPartial(base ?? ({} as any)); + }, + fromPartial, I>>(object: I): MsgRegisterDID { + const message = createBaseMsgRegisterDID(); + message.didDocument = (object.didDocument !== undefined && object.didDocument !== null) + ? DidDocument.fromPartial(object.didDocument) + : undefined; + message.didDocumentProofs = object.didDocumentProofs?.map((e) => DocumentProof.fromPartial(e)) || undefined; + message.txAuthor = object.txAuthor ?? undefined; return message; }, }; -const baseMsgCreateDIDResponse: object = { id: 0 }; +function createBaseMsgRegisterDIDResponse(): MsgRegisterDIDResponse { + return {}; +} -export const MsgCreateDIDResponse = { - encode( - message: MsgCreateDIDResponse, - writer: Writer = Writer.create() - ): Writer { - if (message.id !== 0) { - writer.uint32(8).uint64(message.id); - } +export const MsgRegisterDIDResponse = { + encode(_: MsgRegisterDIDResponse, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { return writer; }, - decode(input: Reader | Uint8Array, length?: number): MsgCreateDIDResponse { - const reader = input instanceof Uint8Array ? new Reader(input) : input; + decode(input: _m0.Reader | Uint8Array, length?: number): MsgRegisterDIDResponse { + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; - const message = { ...baseMsgCreateDIDResponse } as MsgCreateDIDResponse; + const message = createBaseMsgRegisterDIDResponse(); while (reader.pos < end) { const tag = reader.uint32(); switch (tag >>> 3) { - case 1: - message.id = longToNumber(reader.uint64() as Long); - break; - default: - reader.skipType(tag & 7); - break; } + if ((tag & 7) === 4 || tag === 0) { + break; + } + reader.skipType(tag & 7); } return message; }, - fromJSON(object: any): MsgCreateDIDResponse { - const message = { ...baseMsgCreateDIDResponse } as MsgCreateDIDResponse; - if (object.id !== undefined && object.id !== null) { - message.id = Number(object.id); - } else { - message.id = 0; - } - return message; + fromJSON(_: any): MsgRegisterDIDResponse { + return {}; }, - toJSON(message: MsgCreateDIDResponse): unknown { + toJSON(_: MsgRegisterDIDResponse): unknown { const obj: any = {}; - message.id !== undefined && (obj.id = message.id); return obj; }, - fromPartial(object: DeepPartial): MsgCreateDIDResponse { - const message = { ...baseMsgCreateDIDResponse } as MsgCreateDIDResponse; - if (object.id !== undefined && object.id !== null) { - message.id = object.id; - } else { - message.id = 0; - } + create, I>>(base?: I): MsgRegisterDIDResponse { + return MsgRegisterDIDResponse.fromPartial(base ?? ({} as any)); + }, + fromPartial, I>>(_: I): MsgRegisterDIDResponse { + const message = createBaseMsgRegisterDIDResponse(); return message; }, }; -const baseMsgUpdateDID: object = { version_id: "", creator: "" }; +function createBaseMsgUpdateDID(): MsgUpdateDID { + return {}; +} export const MsgUpdateDID = { - encode(message: MsgUpdateDID, writer: Writer = Writer.create()): Writer { - if (message.didDocString !== undefined) { - Did.encode(message.didDocString, writer.uint32(10).fork()).ldelim(); + encode(message: MsgUpdateDID, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { + if (message.didDocument !== undefined) { + DidDocument.encode(message.didDocument, writer.uint32(10).fork()).ldelim(); } - if (message.version_id !== "") { - writer.uint32(18).string(message.version_id); + if (message.didDocumentProofs !== undefined && message.didDocumentProofs.length !== 0) { + for (const v of message.didDocumentProofs) { + DocumentProof.encode(v!, writer.uint32(18).fork()).ldelim(); + } } - for (const v of message.signatures) { - SignInfo.encode(v!, writer.uint32(26).fork()).ldelim(); + if (message.versionId !== undefined && message.versionId !== "") { + writer.uint32(26).string(message.versionId); } - if (message.creator !== "") { - writer.uint32(34).string(message.creator); + if (message.txAuthor !== undefined && message.txAuthor !== "") { + writer.uint32(34).string(message.txAuthor); } return writer; }, - decode(input: Reader | Uint8Array, length?: number): MsgUpdateDID { - const reader = input instanceof Uint8Array ? new Reader(input) : input; + decode(input: _m0.Reader | Uint8Array, length?: number): MsgUpdateDID { + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; - const message = { ...baseMsgUpdateDID } as MsgUpdateDID; - message.signatures = []; + const message = createBaseMsgUpdateDID(); while (reader.pos < end) { const tag = reader.uint32(); switch (tag >>> 3) { case 1: - message.didDocString = Did.decode(reader, reader.uint32()); - break; + if (tag !== 10) { + break; + } + + message.didDocument = DidDocument.decode(reader, reader.uint32()); + continue; case 2: - message.version_id = reader.string(); - break; + if (tag !== 18) { + break; + } + + if (message.didDocumentProofs === undefined) { + message.didDocumentProofs = []; + } + message.didDocumentProofs!.push(DocumentProof.decode(reader, reader.uint32())); + continue; case 3: - message.signatures.push(SignInfo.decode(reader, reader.uint32())); - break; + if (tag !== 26) { + break; + } + + message.versionId = reader.string(); + continue; case 4: - message.creator = reader.string(); - break; - default: - reader.skipType(tag & 7); - break; + if (tag !== 34) { + break; + } + + message.txAuthor = reader.string(); + continue; + } + if ((tag & 7) === 4 || tag === 0) { + break; } + reader.skipType(tag & 7); } return message; }, fromJSON(object: any): MsgUpdateDID { - const message = { ...baseMsgUpdateDID } as MsgUpdateDID; - message.signatures = []; - if (object.didDocString !== undefined && object.didDocString !== null) { - message.didDocString = Did.fromJSON(object.didDocString); - } else { - message.didDocString = undefined; - } - if (object.version_id !== undefined && object.version_id !== null) { - message.version_id = String(object.version_id); - } else { - message.version_id = ""; - } - if (object.signatures !== undefined && object.signatures !== null) { - for (const e of object.signatures) { - message.signatures.push(SignInfo.fromJSON(e)); - } - } - if (object.creator !== undefined && object.creator !== null) { - message.creator = String(object.creator); - } else { - message.creator = ""; - } - return message; + return { + didDocument: isSet(object.didDocument) ? DidDocument.fromJSON(object.didDocument) : undefined, + didDocumentProofs: globalThis.Array.isArray(object?.didDocumentProofs) + ? object.didDocumentProofs.map((e: any) => DocumentProof.fromJSON(e)) + : undefined, + versionId: isSet(object.versionId) ? globalThis.String(object.versionId) : undefined, + txAuthor: isSet(object.txAuthor) ? globalThis.String(object.txAuthor) : undefined, + }; }, toJSON(message: MsgUpdateDID): unknown { const obj: any = {}; - message.didDocString !== undefined && - (obj.didDocString = message.didDocString - ? Did.toJSON(message.didDocString) - : undefined); - message.version_id !== undefined && (obj.version_id = message.version_id); - if (message.signatures) { - obj.signatures = message.signatures.map((e) => - e ? SignInfo.toJSON(e) : undefined - ); - } else { - obj.signatures = []; + if (message.didDocument !== undefined) { + obj.didDocument = DidDocument.toJSON(message.didDocument); } - message.creator !== undefined && (obj.creator = message.creator); - return obj; - }, - - fromPartial(object: DeepPartial): MsgUpdateDID { - const message = { ...baseMsgUpdateDID } as MsgUpdateDID; - message.signatures = []; - if (object.didDocString !== undefined && object.didDocString !== null) { - message.didDocString = Did.fromPartial(object.didDocString); - } else { - message.didDocString = undefined; - } - if (object.version_id !== undefined && object.version_id !== null) { - message.version_id = object.version_id; - } else { - message.version_id = ""; + if (message.didDocumentProofs?.length) { + obj.didDocumentProofs = message.didDocumentProofs.map((e) => DocumentProof.toJSON(e)); } - if (object.signatures !== undefined && object.signatures !== null) { - for (const e of object.signatures) { - message.signatures.push(SignInfo.fromPartial(e)); - } + if (message.versionId !== undefined && message.versionId !== "") { + obj.versionId = message.versionId; } - if (object.creator !== undefined && object.creator !== null) { - message.creator = object.creator; - } else { - message.creator = ""; + if (message.txAuthor !== undefined && message.txAuthor !== "") { + obj.txAuthor = message.txAuthor; } + return obj; + }, + + create, I>>(base?: I): MsgUpdateDID { + return MsgUpdateDID.fromPartial(base ?? ({} as any)); + }, + fromPartial, I>>(object: I): MsgUpdateDID { + const message = createBaseMsgUpdateDID(); + message.didDocument = (object.didDocument !== undefined && object.didDocument !== null) + ? DidDocument.fromPartial(object.didDocument) + : undefined; + message.didDocumentProofs = object.didDocumentProofs?.map((e) => DocumentProof.fromPartial(e)) || undefined; + message.versionId = object.versionId ?? undefined; + message.txAuthor = object.txAuthor ?? undefined; return message; }, }; -const baseMsgUpdateDIDResponse: object = { updateId: "" }; +function createBaseMsgUpdateDIDResponse(): MsgUpdateDIDResponse { + return {}; +} export const MsgUpdateDIDResponse = { - encode( - message: MsgUpdateDIDResponse, - writer: Writer = Writer.create() - ): Writer { - if (message.updateId !== "") { - writer.uint32(10).string(message.updateId); - } + encode(_: MsgUpdateDIDResponse, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { return writer; }, - decode(input: Reader | Uint8Array, length?: number): MsgUpdateDIDResponse { - const reader = input instanceof Uint8Array ? new Reader(input) : input; + decode(input: _m0.Reader | Uint8Array, length?: number): MsgUpdateDIDResponse { + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; - const message = { ...baseMsgUpdateDIDResponse } as MsgUpdateDIDResponse; + const message = createBaseMsgUpdateDIDResponse(); while (reader.pos < end) { const tag = reader.uint32(); switch (tag >>> 3) { - case 1: - message.updateId = reader.string(); - break; - default: - reader.skipType(tag & 7); - break; } + if ((tag & 7) === 4 || tag === 0) { + break; + } + reader.skipType(tag & 7); } return message; }, - fromJSON(object: any): MsgUpdateDIDResponse { - const message = { ...baseMsgUpdateDIDResponse } as MsgUpdateDIDResponse; - if (object.updateId !== undefined && object.updateId !== null) { - message.updateId = String(object.updateId); - } else { - message.updateId = ""; - } - return message; + fromJSON(_: any): MsgUpdateDIDResponse { + return {}; }, - toJSON(message: MsgUpdateDIDResponse): unknown { + toJSON(_: MsgUpdateDIDResponse): unknown { const obj: any = {}; - message.updateId !== undefined && (obj.updateId = message.updateId); return obj; }, - fromPartial(object: DeepPartial): MsgUpdateDIDResponse { - const message = { ...baseMsgUpdateDIDResponse } as MsgUpdateDIDResponse; - if (object.updateId !== undefined && object.updateId !== null) { - message.updateId = object.updateId; - } else { - message.updateId = ""; - } + create, I>>(base?: I): MsgUpdateDIDResponse { + return MsgUpdateDIDResponse.fromPartial(base ?? ({} as any)); + }, + fromPartial, I>>(_: I): MsgUpdateDIDResponse { + const message = createBaseMsgUpdateDIDResponse(); return message; }, }; -const baseMsgCreateSchema: object = { creator: "" }; +function createBaseMsgDeactivateDID(): MsgDeactivateDID { + return {}; +} -export const MsgCreateSchema = { - encode(message: MsgCreateSchema, writer: Writer = Writer.create()): Writer { - if (message.creator !== "") { - writer.uint32(10).string(message.creator); +export const MsgDeactivateDID = { + encode(message: MsgDeactivateDID, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { + if (message.didDocumentId !== undefined && message.didDocumentId !== "") { + writer.uint32(10).string(message.didDocumentId); } - if (message.schemaDoc !== undefined) { - SchemaDocument.encode( - message.schemaDoc, - writer.uint32(18).fork() - ).ldelim(); + if (message.didDocumentProofs !== undefined && message.didDocumentProofs.length !== 0) { + for (const v of message.didDocumentProofs) { + DocumentProof.encode(v!, writer.uint32(18).fork()).ldelim(); + } } - if (message.schemaProof !== undefined) { - SchemaProof.encode( - message.schemaProof, - writer.uint32(26).fork() - ).ldelim(); + if (message.versionId !== undefined && message.versionId !== "") { + writer.uint32(26).string(message.versionId); } - if (message.clientSpec !== undefined) { - ClientSpec.encode(message.clientSpec, writer.uint32(34).fork()).ldelim(); + if (message.txAuthor !== undefined && message.txAuthor !== "") { + writer.uint32(34).string(message.txAuthor); } return writer; }, - decode(input: Reader | Uint8Array, length?: number): MsgCreateSchema { - const reader = input instanceof Uint8Array ? new Reader(input) : input; + decode(input: _m0.Reader | Uint8Array, length?: number): MsgDeactivateDID { + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; - const message = { ...baseMsgCreateSchema } as MsgCreateSchema; + const message = createBaseMsgDeactivateDID(); while (reader.pos < end) { const tag = reader.uint32(); switch (tag >>> 3) { case 1: - message.creator = reader.string(); - break; + if (tag !== 10) { + break; + } + + message.didDocumentId = reader.string(); + continue; case 2: - message.schemaDoc = SchemaDocument.decode(reader, reader.uint32()); - break; + if (tag !== 18) { + break; + } + + if (message.didDocumentProofs === undefined) { + message.didDocumentProofs = []; + } + message.didDocumentProofs!.push(DocumentProof.decode(reader, reader.uint32())); + continue; case 3: - message.schemaProof = SchemaProof.decode(reader, reader.uint32()); - break; + if (tag !== 26) { + break; + } + + message.versionId = reader.string(); + continue; case 4: - message.clientSpec = ClientSpec.decode(reader, reader.uint32()); - break; - default: - reader.skipType(tag & 7); - break; + if (tag !== 34) { + break; + } + + message.txAuthor = reader.string(); + continue; } + if ((tag & 7) === 4 || tag === 0) { + break; + } + reader.skipType(tag & 7); } return message; }, - fromJSON(object: any): MsgCreateSchema { - const message = { ...baseMsgCreateSchema } as MsgCreateSchema; - if (object.creator !== undefined && object.creator !== null) { - message.creator = String(object.creator); - } else { - message.creator = ""; - } - if (object.schemaDoc !== undefined && object.schemaDoc !== null) { - message.schemaDoc = SchemaDocument.fromJSON(object.schemaDoc); - } else { - message.schemaDoc = undefined; - } - if (object.schemaProof !== undefined && object.schemaProof !== null) { - message.schemaProof = SchemaProof.fromJSON(object.schemaProof); - } else { - message.schemaProof = undefined; - } - if (object.clientSpec !== undefined && object.clientSpec !== null) { - message.clientSpec = ClientSpec.fromJSON(object.clientSpec); - } else { - message.clientSpec = undefined; - } - return message; + fromJSON(object: any): MsgDeactivateDID { + return { + didDocumentId: isSet(object.didDocumentId) ? globalThis.String(object.didDocumentId) : undefined, + didDocumentProofs: globalThis.Array.isArray(object?.didDocumentProofs) + ? object.didDocumentProofs.map((e: any) => DocumentProof.fromJSON(e)) + : undefined, + versionId: isSet(object.versionId) ? globalThis.String(object.versionId) : undefined, + txAuthor: isSet(object.txAuthor) ? globalThis.String(object.txAuthor) : undefined, + }; }, - toJSON(message: MsgCreateSchema): unknown { + toJSON(message: MsgDeactivateDID): unknown { const obj: any = {}; - message.creator !== undefined && (obj.creator = message.creator); - message.schemaDoc !== undefined && - (obj.schemaDoc = message.schemaDoc - ? SchemaDocument.toJSON(message.schemaDoc) - : undefined); - message.schemaProof !== undefined && - (obj.schemaProof = message.schemaProof - ? SchemaProof.toJSON(message.schemaProof) - : undefined); - message.clientSpec !== undefined && - (obj.clientSpec = message.clientSpec - ? ClientSpec.toJSON(message.clientSpec) - : undefined); - return obj; - }, - - fromPartial(object: DeepPartial): MsgCreateSchema { - const message = { ...baseMsgCreateSchema } as MsgCreateSchema; - if (object.creator !== undefined && object.creator !== null) { - message.creator = object.creator; - } else { - message.creator = ""; + if (message.didDocumentId !== undefined && message.didDocumentId !== "") { + obj.didDocumentId = message.didDocumentId; } - if (object.schemaDoc !== undefined && object.schemaDoc !== null) { - message.schemaDoc = SchemaDocument.fromPartial(object.schemaDoc); - } else { - message.schemaDoc = undefined; + if (message.didDocumentProofs?.length) { + obj.didDocumentProofs = message.didDocumentProofs.map((e) => DocumentProof.toJSON(e)); } - if (object.schemaProof !== undefined && object.schemaProof !== null) { - message.schemaProof = SchemaProof.fromPartial(object.schemaProof); - } else { - message.schemaProof = undefined; + if (message.versionId !== undefined && message.versionId !== "") { + obj.versionId = message.versionId; } - if (object.clientSpec !== undefined && object.clientSpec !== null) { - message.clientSpec = ClientSpec.fromPartial(object.clientSpec); - } else { - message.clientSpec = undefined; + if (message.txAuthor !== undefined && message.txAuthor !== "") { + obj.txAuthor = message.txAuthor; } + return obj; + }, + + create, I>>(base?: I): MsgDeactivateDID { + return MsgDeactivateDID.fromPartial(base ?? ({} as any)); + }, + fromPartial, I>>(object: I): MsgDeactivateDID { + const message = createBaseMsgDeactivateDID(); + message.didDocumentId = object.didDocumentId ?? undefined; + message.didDocumentProofs = object.didDocumentProofs?.map((e) => DocumentProof.fromPartial(e)) || undefined; + message.versionId = object.versionId ?? undefined; + message.txAuthor = object.txAuthor ?? undefined; return message; }, }; -const baseMsgCreateSchemaResponse: object = { id: 0 }; +function createBaseMsgDeactivateDIDResponse(): MsgDeactivateDIDResponse { + return {}; +} -export const MsgCreateSchemaResponse = { - encode( - message: MsgCreateSchemaResponse, - writer: Writer = Writer.create() - ): Writer { - if (message.id !== 0) { - writer.uint32(8).uint64(message.id); - } +export const MsgDeactivateDIDResponse = { + encode(_: MsgDeactivateDIDResponse, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { return writer; }, - decode(input: Reader | Uint8Array, length?: number): MsgCreateSchemaResponse { - const reader = input instanceof Uint8Array ? new Reader(input) : input; + decode(input: _m0.Reader | Uint8Array, length?: number): MsgDeactivateDIDResponse { + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; - const message = { - ...baseMsgCreateSchemaResponse, - } as MsgCreateSchemaResponse; + const message = createBaseMsgDeactivateDIDResponse(); while (reader.pos < end) { const tag = reader.uint32(); switch (tag >>> 3) { - case 1: - message.id = longToNumber(reader.uint64() as Long); - break; - default: - reader.skipType(tag & 7); - break; } + if ((tag & 7) === 4 || tag === 0) { + break; + } + reader.skipType(tag & 7); } return message; }, - fromJSON(object: any): MsgCreateSchemaResponse { - const message = { - ...baseMsgCreateSchemaResponse, - } as MsgCreateSchemaResponse; - if (object.id !== undefined && object.id !== null) { - message.id = Number(object.id); - } else { - message.id = 0; - } - return message; + fromJSON(_: any): MsgDeactivateDIDResponse { + return {}; }, - toJSON(message: MsgCreateSchemaResponse): unknown { + toJSON(_: MsgDeactivateDIDResponse): unknown { const obj: any = {}; - message.id !== undefined && (obj.id = message.id); return obj; }, - fromPartial( - object: DeepPartial - ): MsgCreateSchemaResponse { - const message = { - ...baseMsgCreateSchemaResponse, - } as MsgCreateSchemaResponse; - if (object.id !== undefined && object.id !== null) { - message.id = object.id; - } else { - message.id = 0; - } + create, I>>(base?: I): MsgDeactivateDIDResponse { + return MsgDeactivateDIDResponse.fromPartial(base ?? ({} as any)); + }, + fromPartial, I>>(_: I): MsgDeactivateDIDResponse { + const message = createBaseMsgDeactivateDIDResponse(); return message; }, }; -const baseMsgDeactivateDID: object = { creator: "", didId: "", version_id: "" }; +function createBaseMsgRegisterCredentialSchema(): MsgRegisterCredentialSchema { + return {}; +} -export const MsgDeactivateDID = { - encode(message: MsgDeactivateDID, writer: Writer = Writer.create()): Writer { - if (message.creator !== "") { - writer.uint32(10).string(message.creator); - } - if (message.didId !== "") { - writer.uint32(18).string(message.didId); +export const MsgRegisterCredentialSchema = { + encode(message: MsgRegisterCredentialSchema, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { + if (message.credentialSchemaDocument !== undefined) { + CredentialSchemaDocument.encode(message.credentialSchemaDocument, writer.uint32(10).fork()).ldelim(); } - if (message.version_id !== "") { - writer.uint32(26).string(message.version_id); + if (message.credentialSchemaProof !== undefined) { + DocumentProof.encode(message.credentialSchemaProof, writer.uint32(18).fork()).ldelim(); } - for (const v of message.signatures) { - SignInfo.encode(v!, writer.uint32(34).fork()).ldelim(); + if (message.txAuthor !== undefined && message.txAuthor !== "") { + writer.uint32(26).string(message.txAuthor); } return writer; }, - decode(input: Reader | Uint8Array, length?: number): MsgDeactivateDID { - const reader = input instanceof Uint8Array ? new Reader(input) : input; + decode(input: _m0.Reader | Uint8Array, length?: number): MsgRegisterCredentialSchema { + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; - const message = { ...baseMsgDeactivateDID } as MsgDeactivateDID; - message.signatures = []; + const message = createBaseMsgRegisterCredentialSchema(); while (reader.pos < end) { const tag = reader.uint32(); switch (tag >>> 3) { case 1: - message.creator = reader.string(); - break; + if (tag !== 10) { + break; + } + + message.credentialSchemaDocument = CredentialSchemaDocument.decode(reader, reader.uint32()); + continue; case 2: - message.didId = reader.string(); - break; + if (tag !== 18) { + break; + } + + message.credentialSchemaProof = DocumentProof.decode(reader, reader.uint32()); + continue; case 3: - message.version_id = reader.string(); - break; - case 4: - message.signatures.push(SignInfo.decode(reader, reader.uint32())); - break; - default: - reader.skipType(tag & 7); - break; + if (tag !== 26) { + break; + } + + message.txAuthor = reader.string(); + continue; + } + if ((tag & 7) === 4 || tag === 0) { + break; } + reader.skipType(tag & 7); } return message; }, - fromJSON(object: any): MsgDeactivateDID { - const message = { ...baseMsgDeactivateDID } as MsgDeactivateDID; - message.signatures = []; - if (object.creator !== undefined && object.creator !== null) { - message.creator = String(object.creator); - } else { - message.creator = ""; + fromJSON(object: any): MsgRegisterCredentialSchema { + return { + credentialSchemaDocument: isSet(object.credentialSchemaDocument) + ? CredentialSchemaDocument.fromJSON(object.credentialSchemaDocument) + : undefined, + credentialSchemaProof: isSet(object.credentialSchemaProof) + ? DocumentProof.fromJSON(object.credentialSchemaProof) + : undefined, + txAuthor: isSet(object.txAuthor) ? globalThis.String(object.txAuthor) : undefined, + }; + }, + + toJSON(message: MsgRegisterCredentialSchema): unknown { + const obj: any = {}; + if (message.credentialSchemaDocument !== undefined) { + obj.credentialSchemaDocument = CredentialSchemaDocument.toJSON(message.credentialSchemaDocument); } - if (object.didId !== undefined && object.didId !== null) { - message.didId = String(object.didId); - } else { - message.didId = ""; + if (message.credentialSchemaProof !== undefined) { + obj.credentialSchemaProof = DocumentProof.toJSON(message.credentialSchemaProof); } - if (object.version_id !== undefined && object.version_id !== null) { - message.version_id = String(object.version_id); - } else { - message.version_id = ""; + if (message.txAuthor !== undefined && message.txAuthor !== "") { + obj.txAuthor = message.txAuthor; } - if (object.signatures !== undefined && object.signatures !== null) { - for (const e of object.signatures) { - message.signatures.push(SignInfo.fromJSON(e)); + return obj; + }, + + create, I>>(base?: I): MsgRegisterCredentialSchema { + return MsgRegisterCredentialSchema.fromPartial(base ?? ({} as any)); + }, + fromPartial, I>>(object: I): MsgRegisterCredentialSchema { + const message = createBaseMsgRegisterCredentialSchema(); + message.credentialSchemaDocument = + (object.credentialSchemaDocument !== undefined && object.credentialSchemaDocument !== null) + ? CredentialSchemaDocument.fromPartial(object.credentialSchemaDocument) + : undefined; + message.credentialSchemaProof = + (object.credentialSchemaProof !== undefined && object.credentialSchemaProof !== null) + ? DocumentProof.fromPartial(object.credentialSchemaProof) + : undefined; + message.txAuthor = object.txAuthor ?? undefined; + return message; + }, +}; + +function createBaseMsgRegisterCredentialSchemaResponse(): MsgRegisterCredentialSchemaResponse { + return {}; +} + +export const MsgRegisterCredentialSchemaResponse = { + encode(_: MsgRegisterCredentialSchemaResponse, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { + return writer; + }, + + decode(input: _m0.Reader | Uint8Array, length?: number): MsgRegisterCredentialSchemaResponse { + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseMsgRegisterCredentialSchemaResponse(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + } + if ((tag & 7) === 4 || tag === 0) { + break; } + reader.skipType(tag & 7); } return message; }, - toJSON(message: MsgDeactivateDID): unknown { + fromJSON(_: any): MsgRegisterCredentialSchemaResponse { + return {}; + }, + + toJSON(_: MsgRegisterCredentialSchemaResponse): unknown { const obj: any = {}; - message.creator !== undefined && (obj.creator = message.creator); - message.didId !== undefined && (obj.didId = message.didId); - message.version_id !== undefined && (obj.version_id = message.version_id); - if (message.signatures) { - obj.signatures = message.signatures.map((e) => - e ? SignInfo.toJSON(e) : undefined - ); - } else { - obj.signatures = []; - } return obj; }, - fromPartial(object: DeepPartial): MsgDeactivateDID { - const message = { ...baseMsgDeactivateDID } as MsgDeactivateDID; - message.signatures = []; - if (object.creator !== undefined && object.creator !== null) { - message.creator = object.creator; - } else { - message.creator = ""; + create, I>>( + base?: I, + ): MsgRegisterCredentialSchemaResponse { + return MsgRegisterCredentialSchemaResponse.fromPartial(base ?? ({} as any)); + }, + fromPartial, I>>( + _: I, + ): MsgRegisterCredentialSchemaResponse { + const message = createBaseMsgRegisterCredentialSchemaResponse(); + return message; + }, +}; + +function createBaseMsgUpdateCredentialSchema(): MsgUpdateCredentialSchema { + return {}; +} + +export const MsgUpdateCredentialSchema = { + encode(message: MsgUpdateCredentialSchema, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { + if (message.credentialSchemaDocument !== undefined) { + CredentialSchemaDocument.encode(message.credentialSchemaDocument, writer.uint32(10).fork()).ldelim(); } - if (object.didId !== undefined && object.didId !== null) { - message.didId = object.didId; - } else { - message.didId = ""; + if (message.credentialSchemaProof !== undefined) { + DocumentProof.encode(message.credentialSchemaProof, writer.uint32(18).fork()).ldelim(); } - if (object.version_id !== undefined && object.version_id !== null) { - message.version_id = object.version_id; - } else { - message.version_id = ""; + if (message.txAuthor !== undefined && message.txAuthor !== "") { + writer.uint32(26).string(message.txAuthor); } - if (object.signatures !== undefined && object.signatures !== null) { - for (const e of object.signatures) { - message.signatures.push(SignInfo.fromPartial(e)); + return writer; + }, + + decode(input: _m0.Reader | Uint8Array, length?: number): MsgUpdateCredentialSchema { + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseMsgUpdateCredentialSchema(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + if (tag !== 10) { + break; + } + + message.credentialSchemaDocument = CredentialSchemaDocument.decode(reader, reader.uint32()); + continue; + case 2: + if (tag !== 18) { + break; + } + + message.credentialSchemaProof = DocumentProof.decode(reader, reader.uint32()); + continue; + case 3: + if (tag !== 26) { + break; + } + + message.txAuthor = reader.string(); + continue; + } + if ((tag & 7) === 4 || tag === 0) { + break; } + reader.skipType(tag & 7); } return message; }, -}; -const baseMsgDeactivateDIDResponse: object = { id: 0 }; + fromJSON(object: any): MsgUpdateCredentialSchema { + return { + credentialSchemaDocument: isSet(object.credentialSchemaDocument) + ? CredentialSchemaDocument.fromJSON(object.credentialSchemaDocument) + : undefined, + credentialSchemaProof: isSet(object.credentialSchemaProof) + ? DocumentProof.fromJSON(object.credentialSchemaProof) + : undefined, + txAuthor: isSet(object.txAuthor) ? globalThis.String(object.txAuthor) : undefined, + }; + }, -export const MsgDeactivateDIDResponse = { - encode( - message: MsgDeactivateDIDResponse, - writer: Writer = Writer.create() - ): Writer { - if (message.id !== 0) { - writer.uint32(8).uint64(message.id); + toJSON(message: MsgUpdateCredentialSchema): unknown { + const obj: any = {}; + if (message.credentialSchemaDocument !== undefined) { + obj.credentialSchemaDocument = CredentialSchemaDocument.toJSON(message.credentialSchemaDocument); + } + if (message.credentialSchemaProof !== undefined) { + obj.credentialSchemaProof = DocumentProof.toJSON(message.credentialSchemaProof); } + if (message.txAuthor !== undefined && message.txAuthor !== "") { + obj.txAuthor = message.txAuthor; + } + return obj; + }, + + create, I>>(base?: I): MsgUpdateCredentialSchema { + return MsgUpdateCredentialSchema.fromPartial(base ?? ({} as any)); + }, + fromPartial, I>>(object: I): MsgUpdateCredentialSchema { + const message = createBaseMsgUpdateCredentialSchema(); + message.credentialSchemaDocument = + (object.credentialSchemaDocument !== undefined && object.credentialSchemaDocument !== null) + ? CredentialSchemaDocument.fromPartial(object.credentialSchemaDocument) + : undefined; + message.credentialSchemaProof = + (object.credentialSchemaProof !== undefined && object.credentialSchemaProof !== null) + ? DocumentProof.fromPartial(object.credentialSchemaProof) + : undefined; + message.txAuthor = object.txAuthor ?? undefined; + return message; + }, +}; + +function createBaseMsgUpdateCredentialSchemaResponse(): MsgUpdateCredentialSchemaResponse { + return {}; +} + +export const MsgUpdateCredentialSchemaResponse = { + encode(_: MsgUpdateCredentialSchemaResponse, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { return writer; }, - decode( - input: Reader | Uint8Array, - length?: number - ): MsgDeactivateDIDResponse { - const reader = input instanceof Uint8Array ? new Reader(input) : input; + decode(input: _m0.Reader | Uint8Array, length?: number): MsgUpdateCredentialSchemaResponse { + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; - const message = { - ...baseMsgDeactivateDIDResponse, - } as MsgDeactivateDIDResponse; + const message = createBaseMsgUpdateCredentialSchemaResponse(); while (reader.pos < end) { const tag = reader.uint32(); switch (tag >>> 3) { - case 1: - message.id = longToNumber(reader.uint64() as Long); - break; - default: - reader.skipType(tag & 7); - break; } + if ((tag & 7) === 4 || tag === 0) { + break; + } + reader.skipType(tag & 7); } return message; }, - fromJSON(object: any): MsgDeactivateDIDResponse { - const message = { - ...baseMsgDeactivateDIDResponse, - } as MsgDeactivateDIDResponse; - if (object.id !== undefined && object.id !== null) { - message.id = Number(object.id); - } else { - message.id = 0; - } - return message; + fromJSON(_: any): MsgUpdateCredentialSchemaResponse { + return {}; }, - toJSON(message: MsgDeactivateDIDResponse): unknown { + toJSON(_: MsgUpdateCredentialSchemaResponse): unknown { const obj: any = {}; - message.id !== undefined && (obj.id = message.id); return obj; }, - fromPartial( - object: DeepPartial - ): MsgDeactivateDIDResponse { - const message = { - ...baseMsgDeactivateDIDResponse, - } as MsgDeactivateDIDResponse; - if (object.id !== undefined && object.id !== null) { - message.id = object.id; - } else { - message.id = 0; - } + create, I>>( + base?: I, + ): MsgUpdateCredentialSchemaResponse { + return MsgUpdateCredentialSchemaResponse.fromPartial(base ?? ({} as any)); + }, + fromPartial, I>>( + _: I, + ): MsgUpdateCredentialSchemaResponse { + const message = createBaseMsgUpdateCredentialSchemaResponse(); return message; }, }; -const baseMsgRegisterCredentialStatus: object = { creator: "" }; +function createBaseMsgRegisterCredentialStatus(): MsgRegisterCredentialStatus { + return {}; +} export const MsgRegisterCredentialStatus = { - encode( - message: MsgRegisterCredentialStatus, - writer: Writer = Writer.create() - ): Writer { - if (message.creator !== "") { - writer.uint32(10).string(message.creator); - } - if (message.credentialStatus !== undefined) { - CredentialStatus.encode( - message.credentialStatus, - writer.uint32(18).fork() - ).ldelim(); + encode(message: MsgRegisterCredentialStatus, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { + if (message.credentialStatusDocument !== undefined) { + CredentialStatusDocument.encode(message.credentialStatusDocument, writer.uint32(10).fork()).ldelim(); } - if (message.proof !== undefined) { - CredentialProof.encode(message.proof, writer.uint32(26).fork()).ldelim(); + if (message.credentialStatusProof !== undefined) { + DocumentProof.encode(message.credentialStatusProof, writer.uint32(18).fork()).ldelim(); } - if (message.clientSpec !== undefined) { - ClientSpec.encode(message.clientSpec, writer.uint32(34).fork()).ldelim(); + if (message.txAuthor !== undefined && message.txAuthor !== "") { + writer.uint32(26).string(message.txAuthor); } return writer; }, - decode( - input: Reader | Uint8Array, - length?: number - ): MsgRegisterCredentialStatus { - const reader = input instanceof Uint8Array ? new Reader(input) : input; + decode(input: _m0.Reader | Uint8Array, length?: number): MsgRegisterCredentialStatus { + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; - const message = { - ...baseMsgRegisterCredentialStatus, - } as MsgRegisterCredentialStatus; + const message = createBaseMsgRegisterCredentialStatus(); while (reader.pos < end) { const tag = reader.uint32(); switch (tag >>> 3) { case 1: - message.creator = reader.string(); - break; + if (tag !== 10) { + break; + } + + message.credentialStatusDocument = CredentialStatusDocument.decode(reader, reader.uint32()); + continue; case 2: - message.credentialStatus = CredentialStatus.decode( - reader, - reader.uint32() - ); - break; + if (tag !== 18) { + break; + } + + message.credentialStatusProof = DocumentProof.decode(reader, reader.uint32()); + continue; case 3: - message.proof = CredentialProof.decode(reader, reader.uint32()); - break; - case 4: - message.clientSpec = ClientSpec.decode(reader, reader.uint32()); - break; - default: - reader.skipType(tag & 7); - break; + if (tag !== 26) { + break; + } + + message.txAuthor = reader.string(); + continue; } + if ((tag & 7) === 4 || tag === 0) { + break; + } + reader.skipType(tag & 7); } return message; }, fromJSON(object: any): MsgRegisterCredentialStatus { - const message = { - ...baseMsgRegisterCredentialStatus, - } as MsgRegisterCredentialStatus; - if (object.creator !== undefined && object.creator !== null) { - message.creator = String(object.creator); - } else { - message.creator = ""; + return { + credentialStatusDocument: isSet(object.credentialStatusDocument) + ? CredentialStatusDocument.fromJSON(object.credentialStatusDocument) + : undefined, + credentialStatusProof: isSet(object.credentialStatusProof) + ? DocumentProof.fromJSON(object.credentialStatusProof) + : undefined, + txAuthor: isSet(object.txAuthor) ? globalThis.String(object.txAuthor) : undefined, + }; + }, + + toJSON(message: MsgRegisterCredentialStatus): unknown { + const obj: any = {}; + if (message.credentialStatusDocument !== undefined) { + obj.credentialStatusDocument = CredentialStatusDocument.toJSON(message.credentialStatusDocument); } - if ( - object.credentialStatus !== undefined && - object.credentialStatus !== null - ) { - message.credentialStatus = CredentialStatus.fromJSON( - object.credentialStatus - ); - } else { - message.credentialStatus = undefined; + if (message.credentialStatusProof !== undefined) { + obj.credentialStatusProof = DocumentProof.toJSON(message.credentialStatusProof); } - if (object.proof !== undefined && object.proof !== null) { - message.proof = CredentialProof.fromJSON(object.proof); - } else { - message.proof = undefined; + if (message.txAuthor !== undefined && message.txAuthor !== "") { + obj.txAuthor = message.txAuthor; } - if (object.clientSpec !== undefined && object.clientSpec !== null) { - message.clientSpec = ClientSpec.fromJSON(object.clientSpec); - } else { - message.clientSpec = undefined; + return obj; + }, + + create, I>>(base?: I): MsgRegisterCredentialStatus { + return MsgRegisterCredentialStatus.fromPartial(base ?? ({} as any)); + }, + fromPartial, I>>(object: I): MsgRegisterCredentialStatus { + const message = createBaseMsgRegisterCredentialStatus(); + message.credentialStatusDocument = + (object.credentialStatusDocument !== undefined && object.credentialStatusDocument !== null) + ? CredentialStatusDocument.fromPartial(object.credentialStatusDocument) + : undefined; + message.credentialStatusProof = + (object.credentialStatusProof !== undefined && object.credentialStatusProof !== null) + ? DocumentProof.fromPartial(object.credentialStatusProof) + : undefined; + message.txAuthor = object.txAuthor ?? undefined; + return message; + }, +}; + +function createBaseMsgRegisterCredentialStatusResponse(): MsgRegisterCredentialStatusResponse { + return {}; +} + +export const MsgRegisterCredentialStatusResponse = { + encode(_: MsgRegisterCredentialStatusResponse, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { + return writer; + }, + + decode(input: _m0.Reader | Uint8Array, length?: number): MsgRegisterCredentialStatusResponse { + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseMsgRegisterCredentialStatusResponse(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + } + if ((tag & 7) === 4 || tag === 0) { + break; + } + reader.skipType(tag & 7); } return message; }, - toJSON(message: MsgRegisterCredentialStatus): unknown { + fromJSON(_: any): MsgRegisterCredentialStatusResponse { + return {}; + }, + + toJSON(_: MsgRegisterCredentialStatusResponse): unknown { const obj: any = {}; - message.creator !== undefined && (obj.creator = message.creator); - message.credentialStatus !== undefined && - (obj.credentialStatus = message.credentialStatus - ? CredentialStatus.toJSON(message.credentialStatus) - : undefined); - message.proof !== undefined && - (obj.proof = message.proof - ? CredentialProof.toJSON(message.proof) - : undefined); - message.clientSpec !== undefined && - (obj.clientSpec = message.clientSpec - ? ClientSpec.toJSON(message.clientSpec) - : undefined); return obj; }, - fromPartial( - object: DeepPartial - ): MsgRegisterCredentialStatus { - const message = { - ...baseMsgRegisterCredentialStatus, - } as MsgRegisterCredentialStatus; - if (object.creator !== undefined && object.creator !== null) { - message.creator = object.creator; - } else { - message.creator = ""; - } - if ( - object.credentialStatus !== undefined && - object.credentialStatus !== null - ) { - message.credentialStatus = CredentialStatus.fromPartial( - object.credentialStatus - ); - } else { - message.credentialStatus = undefined; - } - if (object.proof !== undefined && object.proof !== null) { - message.proof = CredentialProof.fromPartial(object.proof); - } else { - message.proof = undefined; - } - if (object.clientSpec !== undefined && object.clientSpec !== null) { - message.clientSpec = ClientSpec.fromPartial(object.clientSpec); - } else { - message.clientSpec = undefined; - } + create, I>>( + base?: I, + ): MsgRegisterCredentialStatusResponse { + return MsgRegisterCredentialStatusResponse.fromPartial(base ?? ({} as any)); + }, + fromPartial, I>>( + _: I, + ): MsgRegisterCredentialStatusResponse { + const message = createBaseMsgRegisterCredentialStatusResponse(); return message; }, }; -const baseMsgRegisterCredentialStatusResponse: object = { id: 0 }; +function createBaseMsgUpdateCredentialStatus(): MsgUpdateCredentialStatus { + return {}; +} -export const MsgRegisterCredentialStatusResponse = { - encode( - message: MsgRegisterCredentialStatusResponse, - writer: Writer = Writer.create() - ): Writer { - if (message.id !== 0) { - writer.uint32(8).uint64(message.id); +export const MsgUpdateCredentialStatus = { + encode(message: MsgUpdateCredentialStatus, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { + if (message.credentialStatusDocument !== undefined) { + CredentialStatusDocument.encode(message.credentialStatusDocument, writer.uint32(10).fork()).ldelim(); + } + if (message.credentialStatusProof !== undefined) { + DocumentProof.encode(message.credentialStatusProof, writer.uint32(18).fork()).ldelim(); + } + if (message.txAuthor !== undefined && message.txAuthor !== "") { + writer.uint32(26).string(message.txAuthor); } return writer; }, - decode( - input: Reader | Uint8Array, - length?: number - ): MsgRegisterCredentialStatusResponse { - const reader = input instanceof Uint8Array ? new Reader(input) : input; + decode(input: _m0.Reader | Uint8Array, length?: number): MsgUpdateCredentialStatus { + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; - const message = { - ...baseMsgRegisterCredentialStatusResponse, - } as MsgRegisterCredentialStatusResponse; + const message = createBaseMsgUpdateCredentialStatus(); while (reader.pos < end) { const tag = reader.uint32(); switch (tag >>> 3) { case 1: - message.id = longToNumber(reader.uint64() as Long); - break; - default: - reader.skipType(tag & 7); - break; + if (tag !== 10) { + break; + } + + message.credentialStatusDocument = CredentialStatusDocument.decode(reader, reader.uint32()); + continue; + case 2: + if (tag !== 18) { + break; + } + + message.credentialStatusProof = DocumentProof.decode(reader, reader.uint32()); + continue; + case 3: + if (tag !== 26) { + break; + } + + message.txAuthor = reader.string(); + continue; } + if ((tag & 7) === 4 || tag === 0) { + break; + } + reader.skipType(tag & 7); + } + return message; + }, + + fromJSON(object: any): MsgUpdateCredentialStatus { + return { + credentialStatusDocument: isSet(object.credentialStatusDocument) + ? CredentialStatusDocument.fromJSON(object.credentialStatusDocument) + : undefined, + credentialStatusProof: isSet(object.credentialStatusProof) + ? DocumentProof.fromJSON(object.credentialStatusProof) + : undefined, + txAuthor: isSet(object.txAuthor) ? globalThis.String(object.txAuthor) : undefined, + }; + }, + + toJSON(message: MsgUpdateCredentialStatus): unknown { + const obj: any = {}; + if (message.credentialStatusDocument !== undefined) { + obj.credentialStatusDocument = CredentialStatusDocument.toJSON(message.credentialStatusDocument); + } + if (message.credentialStatusProof !== undefined) { + obj.credentialStatusProof = DocumentProof.toJSON(message.credentialStatusProof); + } + if (message.txAuthor !== undefined && message.txAuthor !== "") { + obj.txAuthor = message.txAuthor; } + return obj; + }, + + create, I>>(base?: I): MsgUpdateCredentialStatus { + return MsgUpdateCredentialStatus.fromPartial(base ?? ({} as any)); + }, + fromPartial, I>>(object: I): MsgUpdateCredentialStatus { + const message = createBaseMsgUpdateCredentialStatus(); + message.credentialStatusDocument = + (object.credentialStatusDocument !== undefined && object.credentialStatusDocument !== null) + ? CredentialStatusDocument.fromPartial(object.credentialStatusDocument) + : undefined; + message.credentialStatusProof = + (object.credentialStatusProof !== undefined && object.credentialStatusProof !== null) + ? DocumentProof.fromPartial(object.credentialStatusProof) + : undefined; + message.txAuthor = object.txAuthor ?? undefined; return message; }, +}; - fromJSON(object: any): MsgRegisterCredentialStatusResponse { - const message = { - ...baseMsgRegisterCredentialStatusResponse, - } as MsgRegisterCredentialStatusResponse; - if (object.id !== undefined && object.id !== null) { - message.id = Number(object.id); - } else { - message.id = 0; +function createBaseMsgUpdateCredentialStatusResponse(): MsgUpdateCredentialStatusResponse { + return {}; +} + +export const MsgUpdateCredentialStatusResponse = { + encode(_: MsgUpdateCredentialStatusResponse, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { + return writer; + }, + + decode(input: _m0.Reader | Uint8Array, length?: number): MsgUpdateCredentialStatusResponse { + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseMsgUpdateCredentialStatusResponse(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + } + if ((tag & 7) === 4 || tag === 0) { + break; + } + reader.skipType(tag & 7); } return message; }, - toJSON(message: MsgRegisterCredentialStatusResponse): unknown { + fromJSON(_: any): MsgUpdateCredentialStatusResponse { + return {}; + }, + + toJSON(_: MsgUpdateCredentialStatusResponse): unknown { const obj: any = {}; - message.id !== undefined && (obj.id = message.id); return obj; }, - fromPartial( - object: DeepPartial - ): MsgRegisterCredentialStatusResponse { - const message = { - ...baseMsgRegisterCredentialStatusResponse, - } as MsgRegisterCredentialStatusResponse; - if (object.id !== undefined && object.id !== null) { - message.id = object.id; - } else { - message.id = 0; - } + create, I>>( + base?: I, + ): MsgUpdateCredentialStatusResponse { + return MsgUpdateCredentialStatusResponse.fromPartial(base ?? ({} as any)); + }, + fromPartial, I>>( + _: I, + ): MsgUpdateCredentialStatusResponse { + const message = createBaseMsgUpdateCredentialStatusResponse(); return message; }, }; -/** Msg defines the Msg service. */ export interface Msg { - CreateDID(request: MsgCreateDID): Promise; + RegisterDID(request: MsgRegisterDID): Promise; UpdateDID(request: MsgUpdateDID): Promise; - CreateSchema(request: MsgCreateSchema): Promise; DeactivateDID(request: MsgDeactivateDID): Promise; - RegisterCredentialStatus( - request: MsgRegisterCredentialStatus - ): Promise; + RegisterCredentialSchema(request: MsgRegisterCredentialSchema): Promise; + UpdateCredentialSchema(request: MsgUpdateCredentialSchema): Promise; + RegisterCredentialStatus(request: MsgRegisterCredentialStatus): Promise; + UpdateCredentialStatus(request: MsgUpdateCredentialStatus): Promise; } +export const MsgServiceName = "hypersign.ssi.v1.Msg"; export class MsgClientImpl implements Msg { private readonly rpc: Rpc; - constructor(rpc: Rpc) { + private readonly service: string; + constructor(rpc: Rpc, opts?: { service?: string }) { + this.service = opts?.service || MsgServiceName; this.rpc = rpc; + this.RegisterDID = this.RegisterDID.bind(this); + this.UpdateDID = this.UpdateDID.bind(this); + this.DeactivateDID = this.DeactivateDID.bind(this); + this.RegisterCredentialSchema = this.RegisterCredentialSchema.bind(this); + this.UpdateCredentialSchema = this.UpdateCredentialSchema.bind(this); + this.RegisterCredentialStatus = this.RegisterCredentialStatus.bind(this); + this.UpdateCredentialStatus = this.UpdateCredentialStatus.bind(this); } - CreateDID(request: MsgCreateDID): Promise { - const data = MsgCreateDID.encode(request).finish(); - const promise = this.rpc.request( - "hypersignprotocol.hidnode.ssi.Msg", - "CreateDID", - data - ); - return promise.then((data) => - MsgCreateDIDResponse.decode(new Reader(data)) - ); + RegisterDID(request: MsgRegisterDID): Promise { + const data = MsgRegisterDID.encode(request).finish(); + const promise = this.rpc.request(this.service, "RegisterDID", data); + return promise.then((data) => MsgRegisterDIDResponse.decode(_m0.Reader.create(data))); } UpdateDID(request: MsgUpdateDID): Promise { const data = MsgUpdateDID.encode(request).finish(); - const promise = this.rpc.request( - "hypersignprotocol.hidnode.ssi.Msg", - "UpdateDID", - data - ); - return promise.then((data) => - MsgUpdateDIDResponse.decode(new Reader(data)) - ); - } - - CreateSchema(request: MsgCreateSchema): Promise { - const data = MsgCreateSchema.encode(request).finish(); - const promise = this.rpc.request( - "hypersignprotocol.hidnode.ssi.Msg", - "CreateSchema", - data - ); - return promise.then((data) => - MsgCreateSchemaResponse.decode(new Reader(data)) - ); + const promise = this.rpc.request(this.service, "UpdateDID", data); + return promise.then((data) => MsgUpdateDIDResponse.decode(_m0.Reader.create(data))); } DeactivateDID(request: MsgDeactivateDID): Promise { const data = MsgDeactivateDID.encode(request).finish(); - const promise = this.rpc.request( - "hypersignprotocol.hidnode.ssi.Msg", - "DeactivateDID", - data - ); - return promise.then((data) => - MsgDeactivateDIDResponse.decode(new Reader(data)) - ); + const promise = this.rpc.request(this.service, "DeactivateDID", data); + return promise.then((data) => MsgDeactivateDIDResponse.decode(_m0.Reader.create(data))); + } + + RegisterCredentialSchema(request: MsgRegisterCredentialSchema): Promise { + const data = MsgRegisterCredentialSchema.encode(request).finish(); + const promise = this.rpc.request(this.service, "RegisterCredentialSchema", data); + return promise.then((data) => MsgRegisterCredentialSchemaResponse.decode(_m0.Reader.create(data))); } - RegisterCredentialStatus( - request: MsgRegisterCredentialStatus - ): Promise { + UpdateCredentialSchema(request: MsgUpdateCredentialSchema): Promise { + const data = MsgUpdateCredentialSchema.encode(request).finish(); + const promise = this.rpc.request(this.service, "UpdateCredentialSchema", data); + return promise.then((data) => MsgUpdateCredentialSchemaResponse.decode(_m0.Reader.create(data))); + } + + RegisterCredentialStatus(request: MsgRegisterCredentialStatus): Promise { const data = MsgRegisterCredentialStatus.encode(request).finish(); - const promise = this.rpc.request( - "hypersignprotocol.hidnode.ssi.Msg", - "RegisterCredentialStatus", - data - ); - return promise.then((data) => - MsgRegisterCredentialStatusResponse.decode(new Reader(data)) - ); + const promise = this.rpc.request(this.service, "RegisterCredentialStatus", data); + return promise.then((data) => MsgRegisterCredentialStatusResponse.decode(_m0.Reader.create(data))); + } + + UpdateCredentialStatus(request: MsgUpdateCredentialStatus): Promise { + const data = MsgUpdateCredentialStatus.encode(request).finish(); + const promise = this.rpc.request(this.service, "UpdateCredentialStatus", data); + return promise.then((data) => MsgUpdateCredentialStatusResponse.decode(_m0.Reader.create(data))); } } interface Rpc { - request( - service: string, - method: string, - data: Uint8Array - ): Promise; + request(service: string, method: string, data: Uint8Array): Promise; } -declare var self: any | undefined; -declare var window: any | undefined; -var globalThis: any = (() => { - if (typeof globalThis !== "undefined") return globalThis; - if (typeof self !== "undefined") return self; - if (typeof window !== "undefined") return window; - if (typeof global !== "undefined") return global; - throw "Unable to locate global object"; -})(); - -type Builtin = Date | Function | Uint8Array | string | number | undefined; -export type DeepPartial = T extends Builtin - ? T - : T extends Array - ? Array> - : T extends ReadonlyArray - ? ReadonlyArray> - : T extends {} - ? { [K in keyof T]?: DeepPartial } +type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined; + +export type DeepPartial = T extends Builtin ? T + : T extends globalThis.Array ? globalThis.Array> + : T extends ReadonlyArray ? ReadonlyArray> + : T extends {} ? { [K in keyof T]?: DeepPartial } : Partial; -function longToNumber(long: Long): number { - if (long.gt(Number.MAX_SAFE_INTEGER)) { - throw new globalThis.Error("Value is larger than Number.MAX_SAFE_INTEGER"); - } - return long.toNumber(); -} +type KeysOfUnion = T extends T ? keyof T : never; +export type Exact = P extends Builtin ? P + : P & { [K in keyof P]: Exact } & { [K in Exclude>]: never }; -// if (util.Long !== Long) { -// util.Long = Long as any; -// configure(); -// } +function isSet(value: any): boolean { + return value !== null && value !== undefined; +} diff --git a/libs/w3cache/v1/X25519KeyAgreementKeyEIP5630.json b/libs/w3cache/v1/X25519KeyAgreementKeyEIP5630.json new file mode 100644 index 0000000..b39bc8e --- /dev/null +++ b/libs/w3cache/v1/X25519KeyAgreementKeyEIP5630.json @@ -0,0 +1,37 @@ +{ + "@context": { + "id": "@id", + "type": "@type", + "@protected": true, + "proof": { + "@id": "https://w3id.org/security#proof", + "@type": "@id", + "@container": "@graph" + }, + "X25519KeyAgreementKeyEIP5630": { + "@id": "https://w3id.org/security#X25519KeyAgreementKeyEIP5630", + "@context": { + "@protected": true, + "id": "@id", + "type": "@type", + "controller": { + "@id": "https://w3id.org/security#controller", + "@type": "@id" + }, + "revoked": { + "@id": "https://w3id.org/security#revoked", + "@type": "http://www.w3.org/2001/XMLSchema#dateTime" + }, + "publicKeyMultibase": { + "@id": "https://w3id.org/security#publicKeyMultibase", + "@type": "https://w3id.org/security#multibase" + }, + "blockchainAccountId":{ + "@id": "https://w3c.github.io/vc-data-integrity/vocab/security/vocabulary.jsonld#blockchainAccountId", + "@type": "https://w3id.org/security#blockchainAccountId" + } + } + } + + } +} \ No newline at end of file diff --git a/libs/w3cache/v1/credentialStatus.json b/libs/w3cache/v1/credentialStatus.json new file mode 100644 index 0000000..fee6048 --- /dev/null +++ b/libs/w3cache/v1/credentialStatus.json @@ -0,0 +1,33 @@ +{ + "@context": { + "@protected": true, + "@version": 1.1, + "hypersign-vocab": "urn:uuid:13fe9318-bb82-4d95-8bf5-8e7fdf8b2026#", + "xsd": "http://www.w3.org/2001/XMLSchema#", + "id": "@id", + "revoked": { + "@id": "hypersign-vocab:revoked", + "@type": "xsd:boolean" + }, + "suspended": { + "@id": "hypersign-vocab:suspended", + "@type": "xsd:boolean" + }, + "remarks": { + "@id": "hypersign-vocab:remarks", + "@type": "xsd:string" + }, + "issuer": { + "@id": "hypersign-vocab:issuer", + "@type": "xsd:string" + }, + "issuanceDate": { + "@id": "hypersign-vocab:issuanceDate", + "@type": "xsd:dateTime" + }, + "credentialMerkleRootHash": { + "@id": "hypersign-vocab:credentialMerkleRootHash", + "@type": "xsd:string" + } + } +} diff --git a/libs/w3cache/v1/credential_schema.json b/libs/w3cache/v1/credential_schema.json new file mode 100644 index 0000000..97409c0 --- /dev/null +++ b/libs/w3cache/v1/credential_schema.json @@ -0,0 +1,47 @@ +{ + "@context": { + "@version": 1.1, + "hypersign-vocab": "urn:uuid:13fe9318-bb82-4d95-8bf5-8e7fdf8b2026#", + "xsd": "http://www.w3.org/2001/XMLSchema#", + "id": "@id", + "type": { + "@id": "hypersign-vocab:type" + }, + "modelVersion": { + "@id": "hypersign-vocab:modelVersion", + "@type": "xsd:string" + }, + "name": { + "@id": "hypersign-vocab:name", + "@type": "xsd:string" + }, + "author": { + "@id": "hypersign-vocab:author", + "@type": "xsd:string" + }, + "authored": { + "@id": "hypersign-vocab:authored", + "@type": "xsd:dateTime" + }, + "schema": { + "@id": "hypersign-vocab:schema", + "@type": "xsd:string" + }, + "additionalProperties": { + "@id": "hypersign-vocab:additionalProperties", + "@type": "xsd:boolean" + }, + "description": { + "@id": "hypersign-vocab:description", + "@type": "xsd:string" + }, + "properties": { + "@id": "hypersign-vocab:properties", + "@type": "xsd:string" + }, + "required": { + "@id": "hypersign-vocab:required", + "@container": "@set" + } + } +} diff --git a/libs/w3cache/v1/credentials.json b/libs/w3cache/v1/credentials.json index 0124a3c..63efae0 100644 --- a/libs/w3cache/v1/credentials.json +++ b/libs/w3cache/v1/credentials.json @@ -2,102 +2,135 @@ "@context": { "@version": 1.1, "@protected": true, - "id": "@id", "type": "@type", - "VerifiableCredential": { "@id": "https://www.w3.org/2018/credentials#VerifiableCredential", "@context": { "@version": 1.1, "@protected": true, - "id": "@id", "type": "@type", - "cred": "https://www.w3.org/2018/credentials#", "sec": "https://w3id.org/security#", "xsd": "http://www.w3.org/2001/XMLSchema#", - "credentialSchema": { "@id": "cred:credentialSchema", "@type": "@id", "@context": { "@version": 1.1, "@protected": true, - "id": "@id", - "type": "@type", - - "cred": "https://www.w3.org/2018/credentials#", - - "JsonSchemaValidator2018": "cred:JsonSchemaValidator2018" + "type": "https://www.w3.org/2018/credentials#JsonSchemaValidator2018" } }, - "credentialStatus": {"@id": "cred:credentialStatus", "@type": "@id"}, - "credentialSubject": {"@id": "cred:credentialSubject", "@type": "@id"}, - "evidence": {"@id": "cred:evidence", "@type": "@id"}, - "expirationDate": {"@id": "cred:expirationDate", "@type": "xsd:dateTime"}, - "holder": {"@id": "cred:holder", "@type": "@id"}, - "issued": {"@id": "cred:issued", "@type": "xsd:dateTime"}, - "issuer": {"@id": "cred:issuer", "@type": "@id"}, - "issuanceDate": {"@id": "cred:issuanceDate", "@type": "xsd:dateTime"}, - "proof": {"@id": "sec:proof", "@type": "@id", "@container": "@graph"}, + "credentialStatus": { + "@id": "cred:credentialStatus", + "@type": "@id" + }, + "credentialSubject": { + "@id": "cred:credentialSubject", + "@type": "@id" + }, + "evidence": { + "@id": "cred:evidence", + "@type": "@id" + }, + "expirationDate": { + "@id": "cred:expirationDate", + "@type": "xsd:dateTime" + }, + "holder": { + "@id": "cred:holder", + "@type": "@id" + }, + "issued": { + "@id": "cred:issued", + "@type": "xsd:dateTime" + }, + "issuer": { + "@id": "cred:issuer", + "@type": "@id" + }, + "issuanceDate": { + "@id": "cred:issuanceDate", + "@type": "xsd:dateTime" + }, + "proof": { + "@id": "sec:proof", + "@type": "@id", + "@container": "@graph" + }, "refreshService": { "@id": "cred:refreshService", "@type": "@id", "@context": { "@version": 1.1, "@protected": true, - "id": "@id", "type": "@type", - "cred": "https://www.w3.org/2018/credentials#", - "ManualRefreshService2018": "cred:ManualRefreshService2018" } }, - "termsOfUse": {"@id": "cred:termsOfUse", "@type": "@id"}, - "validFrom": {"@id": "cred:validFrom", "@type": "xsd:dateTime"}, - "validUntil": {"@id": "cred:validUntil", "@type": "xsd:dateTime"} + "termsOfUse": { + "@id": "cred:termsOfUse", + "@type": "@id" + }, + "validFrom": { + "@id": "cred:validFrom", + "@type": "xsd:dateTime" + }, + "validUntil": { + "@id": "cred:validUntil", + "@type": "xsd:dateTime" + } } }, - "VerifiablePresentation": { "@id": "https://www.w3.org/2018/credentials#VerifiablePresentation", "@context": { "@version": 1.1, "@protected": true, - "id": "@id", "type": "@type", - "cred": "https://www.w3.org/2018/credentials#", "sec": "https://w3id.org/security#", - - "holder": {"@id": "cred:holder", "@type": "@id"}, - "proof": {"@id": "sec:proof", "@type": "@id", "@container": "@graph"}, - "verifiableCredential": {"@id": "cred:verifiableCredential", "@type": "@id", "@container": "@graph"} + "holder": { + "@id": "cred:holder", + "@type": "@id" + }, + "proof": { + "@id": "sec:proof", + "@type": "@id", + "@container": "@graph" + }, + "verifiableCredential": { + "@id": "cred:verifiableCredential", + "@type": "@id", + "@container": "@graph" + } } }, - "EcdsaSecp256k1Signature2019": { "@id": "https://w3id.org/security#EcdsaSecp256k1Signature2019", "@context": { "@version": 1.1, "@protected": true, - "id": "@id", "type": "@type", - "sec": "https://w3id.org/security#", "xsd": "http://www.w3.org/2001/XMLSchema#", - "challenge": "sec:challenge", - "created": {"@id": "http://purl.org/dc/terms/created", "@type": "xsd:dateTime"}, + "created": { + "@id": "http://purl.org/dc/terms/created", + "@type": "xsd:dateTime" + }, "domain": "sec:domain", - "expires": {"@id": "sec:expiration", "@type": "xsd:dateTime"}, + "expires": { + "@id": "sec:expiration", + "@type": "xsd:dateTime" + }, "jws": "sec:jws", "nonce": "sec:nonce", "proofPurpose": { @@ -106,37 +139,47 @@ "@context": { "@version": 1.1, "@protected": true, - "id": "@id", "type": "@type", - "sec": "https://w3id.org/security#", - - "assertionMethod": {"@id": "sec:assertionMethod", "@type": "@id", "@container": "@set"}, - "authentication": {"@id": "sec:authenticationMethod", "@type": "@id", "@container": "@set"} + "assertionMethod": { + "@id": "sec:assertionMethod", + "@type": "@id", + "@container": "@set" + }, + "authentication": { + "@id": "sec:authenticationMethod", + "@type": "@id", + "@container": "@set" + } } }, "proofValue": "sec:proofValue", - "verificationMethod": {"@id": "sec:verificationMethod", "@type": "@id"} + "verificationMethod": { + "@id": "sec:verificationMethod", + "@type": "@id" + } } }, - "EcdsaSecp256r1Signature2019": { "@id": "https://w3id.org/security#EcdsaSecp256r1Signature2019", "@context": { "@version": 1.1, "@protected": true, - "id": "@id", "type": "@type", - "sec": "https://w3id.org/security#", "xsd": "http://www.w3.org/2001/XMLSchema#", - "challenge": "sec:challenge", - "created": {"@id": "http://purl.org/dc/terms/created", "@type": "xsd:dateTime"}, + "created": { + "@id": "http://purl.org/dc/terms/created", + "@type": "xsd:dateTime" + }, "domain": "sec:domain", - "expires": {"@id": "sec:expiration", "@type": "xsd:dateTime"}, + "expires": { + "@id": "sec:expiration", + "@type": "xsd:dateTime" + }, "jws": "sec:jws", "nonce": "sec:nonce", "proofPurpose": { @@ -145,37 +188,47 @@ "@context": { "@version": 1.1, "@protected": true, - "id": "@id", "type": "@type", - "sec": "https://w3id.org/security#", - - "assertionMethod": {"@id": "sec:assertionMethod", "@type": "@id", "@container": "@set"}, - "authentication": {"@id": "sec:authenticationMethod", "@type": "@id", "@container": "@set"} + "assertionMethod": { + "@id": "sec:assertionMethod", + "@type": "@id", + "@container": "@set" + }, + "authentication": { + "@id": "sec:authenticationMethod", + "@type": "@id", + "@container": "@set" + } } }, "proofValue": "sec:proofValue", - "verificationMethod": {"@id": "sec:verificationMethod", "@type": "@id"} + "verificationMethod": { + "@id": "sec:verificationMethod", + "@type": "@id" + } } }, - "Ed25519Signature2018": { "@id": "https://w3id.org/security#Ed25519Signature2018", "@context": { "@version": 1.1, "@protected": true, - "id": "@id", "type": "@type", - "sec": "https://w3id.org/security#", "xsd": "http://www.w3.org/2001/XMLSchema#", - "challenge": "sec:challenge", - "created": {"@id": "http://purl.org/dc/terms/created", "@type": "xsd:dateTime"}, + "created": { + "@id": "http://purl.org/dc/terms/created", + "@type": "xsd:dateTime" + }, "domain": "sec:domain", - "expires": {"@id": "sec:expiration", "@type": "xsd:dateTime"}, + "expires": { + "@id": "sec:expiration", + "@type": "xsd:dateTime" + }, "jws": "sec:jws", "nonce": "sec:nonce", "proofPurpose": { @@ -184,31 +237,43 @@ "@context": { "@version": 1.1, "@protected": true, - "id": "@id", "type": "@type", - "sec": "https://w3id.org/security#", - - "assertionMethod": {"@id": "sec:assertionMethod", "@type": "@id", "@container": "@set"}, - "authentication": {"@id": "sec:authenticationMethod", "@type": "@id", "@container": "@set"} + "assertionMethod": { + "@id": "sec:assertionMethod", + "@type": "@id", + "@container": "@set" + }, + "authentication": { + "@id": "sec:authenticationMethod", + "@type": "@id", + "@container": "@set" + } } }, "proofValue": "sec:proofValue", - "verificationMethod": {"@id": "sec:verificationMethod", "@type": "@id"} + "verificationMethod": { + "@id": "sec:verificationMethod", + "@type": "@id" + } } }, - "RsaSignature2018": { "@id": "https://w3id.org/security#RsaSignature2018", "@context": { "@version": 1.1, "@protected": true, - "challenge": "sec:challenge", - "created": {"@id": "http://purl.org/dc/terms/created", "@type": "xsd:dateTime"}, + "created": { + "@id": "http://purl.org/dc/terms/created", + "@type": "xsd:dateTime" + }, "domain": "sec:domain", - "expires": {"@id": "sec:expiration", "@type": "xsd:dateTime"}, + "expires": { + "@id": "sec:expiration", + "@type": "xsd:dateTime" + }, "jws": "sec:jws", "nonce": "sec:nonce", "proofPurpose": { @@ -217,21 +282,32 @@ "@context": { "@version": 1.1, "@protected": true, - "id": "@id", "type": "@type", - "sec": "https://w3id.org/security#", - - "assertionMethod": {"@id": "sec:assertionMethod", "@type": "@id", "@container": "@set"}, - "authentication": {"@id": "sec:authenticationMethod", "@type": "@id", "@container": "@set"} + "assertionMethod": { + "@id": "sec:assertionMethod", + "@type": "@id", + "@container": "@set" + }, + "authentication": { + "@id": "sec:authenticationMethod", + "@type": "@id", + "@container": "@set" + } } }, "proofValue": "sec:proofValue", - "verificationMethod": {"@id": "sec:verificationMethod", "@type": "@id"} + "verificationMethod": { + "@id": "sec:verificationMethod", + "@type": "@id" + } } }, - - "proof": {"@id": "https://w3id.org/security#proof", "@type": "@id", "@container": "@graph"} + "proof": { + "@id": "https://w3id.org/security#proof", + "@type": "@id", + "@container": "@graph" + } } -} +} \ No newline at end of file diff --git a/libs/w3cache/v1/hypersignCredentialStatus2023.json b/libs/w3cache/v1/hypersignCredentialStatus2023.json new file mode 100644 index 0000000..896514d --- /dev/null +++ b/libs/w3cache/v1/hypersignCredentialStatus2023.json @@ -0,0 +1,14 @@ +{ + "@context": { + "@protected": true, + "hypersign-vocab": "urn:uuid:13fe9318-bb82-4d95-8bf5-8e7fdf8b2026#", + "HypersignCredentialStatus2023": { + "@id": "hypersign-vocab:HypersignCredentialStatus2023", + "@context": { + "@protected": true, + "id": "@id", + "type": "@type" + } + } + } +} diff --git a/libs/w3cache/v1/index.ts b/libs/w3cache/v1/index.ts index a87382f..66cb896 100644 --- a/libs/w3cache/v1/index.ts +++ b/libs/w3cache/v1/index.ts @@ -1,62 +1,216 @@ -import did from './did.json' -import ed25519signature2020 from './ed25519-signature-2020.json' -import securityv2 from './security-v2.json' -import credentials from './credentials.json' +import did from './did.json'; +import ed25519signature2020 from './ed25519-signature-2020.json'; +import securityv2 from './security-v2.json'; +import credentials from './credentials.json'; import jsonld from 'jsonld'; -import dataintegrety from './vc-data-integrety.json' -import ecdsasecp2020 from './lds-ecdsa-secp256k1-recovery2020.json' -import schema_org from './schema_org.json' -import x25519VerificationKey2020 from "./x25519-key-agreement-2020-v1.json" +import dataintegrety from './vc-data-integrety.json'; +import ecdsasecp2020 from './lds-ecdsa-secp256k1-recovery2020.json'; +import schema_org from './schema_org.json'; +import x25519VerificationKey2020 from './x25519-key-agreement-2020-v1.json'; +import X25519KeyAgreementKeyEIP5630 from './X25519KeyAgreementKeyEIP5630.json'; +import credentialStatus from './credentialStatus.json'; +import credentialSchema from './credential_schema.json'; +import hypersigncredentialStatus2023 from './hypersignCredentialStatus2023.json'; // Ref: https://github.com/digitalbazaar/jsonld.js/#custom-document-loader let nodeDocumentLoader; if (typeof window === 'undefined') { - nodeDocumentLoader = jsonld.documentLoaders.node(); -}else{ - nodeDocumentLoader = jsonld.documentLoaders.xhr(); + nodeDocumentLoader = jsonld.documentLoaders.node; +} else { + nodeDocumentLoader = jsonld.documentLoaders.xhr; } -import wellknown from './did-wellknown.json' +import wellknown from './did-wellknown.json'; const CONTEXTS = Object.freeze({ - "https://www.w3.org/ns/did/v1": { - ...did + 'https://www.w3.org/ns/did/v1': { + ...did, + }, + 'https://w3id.org/security/suites/ed25519-2020/v1': { + ...ed25519signature2020, + }, + 'https://w3id.org/security/v2': { + ...securityv2, + }, + 'https://www.w3.org/2018/credentials/v1': { + ...credentials, + }, + 'https://w3c.github.io/vc-data-integrity/vocab/security/vocabulary.jsonld': { + ...dataintegrety, + }, + 'https://w3id.org/security/suites/secp256k1recovery-2020/v2': { + ...ecdsasecp2020, + }, + 'https://schema.org': { + ...schema_org, + }, + 'https://ns.did.ai/suites/x25519-2020/v1': { + ...x25519VerificationKey2020, + }, + 'https://identity.foundation/.well-known/did-configuration/v1': { + ...wellknown, + }, + 'https://raw.githubusercontent.com/hypersign-protocol/hypersign-contexts/main/BabyJubJubKey2021.jsonld': { + '@context': { + id: '@id', + type: '@type', + '@protected': true, + 'hypersign-vocab': 'urn:uuid:13fe9318-bb82-4d95-8bf5-8e7fdf8b2026#', + BabyJubJubKey2021: { + '@id': 'hypersign-vocab:BabyJubJubKey2021', + '@context': { + id: '@id', + type: '@type', + controller: { + '@id': 'https://w3id.org/security#controller', + '@type': '@id', + }, + publicKeyMultibase: { + '@id': 'https://w3id.org/security#publicKeyMultibase', + '@type': 'https://w3id.org/security#multibase', + }, + }, + }, }, - "https://w3id.org/security/suites/ed25519-2020/v1": { - ...ed25519signature2020 + }, + 'https://raw.githubusercontent.com/hypersign-protocol/hypersign-contexts/main/X25519KeyAgreementKeyEIP5630.jsonld': { + ...X25519KeyAgreementKeyEIP5630, + }, + 'https://raw.githubusercontent.com/hypersign-protocol/hypersign-contexts/main/CredentialStatus.jsonld': { + ...credentialStatus, + }, + 'https://raw.githubusercontent.com/hypersign-protocol/hypersign-contexts/main/CredentialSchema.jsonld': { + ...credentialSchema, + }, + 'https://raw.githubusercontent.com/hypersign-protocol/hypersign-contexts/main/HypersignCredentialStatus2023.jsonld': { + ...hypersigncredentialStatus2023, + }, + 'https://raw.githubusercontent.com/hypersign-protocol/hypersign-contexts/main/BJJSignature2021.jsonld': { + '@context': { + '@version': 1.1, + id: '@id', + type: '@type', + proof: { + '@id': 'https://w3id.org/security#proof', + '@type': '@id', + '@container': '@graph', + }, + BJJSignature2021: { + '@id': 'https://w3id.org/security#BJJSignature2021', + '@context': { + '@version': 1.1, + '@protected': true, + id: '@id', + type: '@type', + challenge: 'https://w3id.org/security#challenge', + created: { + '@id': 'http://purl.org/dc/terms/created', + '@type': 'http://www.w3.org/2001/XMLSchema#dateTime', + }, + domain: 'https://w3id.org/security#domain', + proofValue: 'https://w3id.org/security#proofValue', + credentialRoot: 'https://w3id.org/security#credentialRoot', + nonce: 'https://w3id.org/security#nonce', + proofPurpose: { + '@id': 'https://w3id.org/security#proofPurpose', + '@type': '@vocab', + '@context': { + '@version': 1.1, + '@protected': true, + id: '@id', + type: '@type', + assertionMethod: { + '@id': 'https://w3id.org/security#assertionMethod', + '@type': '@id', + '@container': '@set', + }, + authentication: { + '@id': 'https://w3id.org/security#authenticationMethod', + '@type': '@id', + '@container': '@set', + }, + }, + }, + verificationMethod: { + '@id': 'https://w3id.org/security#verificationMethod', + '@type': '@id', + }, + }, + }, + BabyJubJubSignatureProof2021: { + '@id': 'https://w3id.org/security#BabyJubJubSignatureProof2021', + '@context': { + '@version': 1.1, + '@protected': true, + id: '@id', + type: '@type', + challenge: 'https://w3id.org/security#challenge', + created: { + '@id': 'http://purl.org/dc/terms/created', + '@type': 'http://www.w3.org/2001/XMLSchema#dateTime', + }, + domain: 'https://w3id.org/security#domain', + nonce: 'https://w3id.org/security#nonce', + proofPurpose: { + '@id': 'https://w3id.org/security#proofPurpose', + '@type': '@vocab', + '@context': { + '@version': 1.1, + '@protected': true, + id: '@id', + type: '@type', + sec: 'https://w3id.org/security#', + assertionMethod: { + '@id': 'https://w3id.org/security#assertionMethod', + '@type': '@id', + '@container': '@set', + }, + authentication: { + '@id': 'https://w3id.org/security#authenticationMethod', + '@type': '@id', + '@container': '@set', + }, + }, + }, + proofValue: 'https://w3id.org/security#proofValue', + credentialRoot: 'https://w3id.org/security#credentialRoot', + verificationMethod: { + '@id': 'https://w3id.org/security#verificationMethod', + '@type': '@id', + }, + }, + }, }, - "https://w3id.org/security/v2": { - ...securityv2 - }, - "https://www.w3.org/2018/credentials/v1": { - ...credentials - }, - "https://w3c.github.io/vc-data-integrity/vocab/security/vocabulary.jsonld": { - ...dataintegrety - }, - "https://w3id.org/security/suites/secp256k1recovery-2020/v2": { - ...ecdsasecp2020 - }, - "https://schema.org": { - ...schema_org - }, - "https://digitalbazaar.github.io/x25519-key-agreement-2020-context/contexts/x25519-key-agreement-2020-v1.jsonld":{ - ...x25519VerificationKey2020 + }, + + 'https://raw.githubusercontent.com/hypersign-protocol/hypersign-contexts/main/LinkedDomains.jsonld': { + '@context': { + '@protected': true, + id: '@id', + type: '@type', + LinkedDomains: { + '@id': 'https://www.w3.org/ns/did#LinkedDomains', + '@type': '@id', + '@context': { + '@protected': true, + id: '@id', + type: '@type', + serviceEndpoint: { + '@id': 'https://www.w3.org/ns/did#serviceEndpoint', + '@type': '@id', + }, + }, + }, }, - "https://identity.foundation/.well-known/did-configuration/v1": { - ...wellknown - } + }, }); export default async (url, options) => { - if (url in CONTEXTS) { - return { - contextUrl: null, // this is for a context via a link header - document: CONTEXTS[url], // this is the actual document that was loaded - documentUrl: url // this is the actual context URL after redirects - }; - } - // call the default documentLoader - return nodeDocumentLoader(url); + if (url in CONTEXTS) { + return { + contextUrl: null, // this is for a context via a link header + document: CONTEXTS[url], // this is the actual document that was loaded + documentUrl: url, // this is the actual context URL after redirects + }; + } + // call the default documentLoader + return nodeDocumentLoader(url); }; - - - diff --git a/package-lock.json b/package-lock.json index 3909d68..7d85daa 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,28 +1,32 @@ { "name": "hs-ssi-sdk", - "version": "6.2.0", + "version": "7.0.1", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "hs-ssi-sdk", - "version": "6.2.0", + "version": "7.0.1", "license": "ISC", "dependencies": { - "@cosmjs/proto-signing": "^0.27.0", - "@cosmjs/stargate": "^0.27.0", + "@cfworker/json-schema": "github:hypersign-protocol/json-schema", + "@cosmjs/proto-signing": "^0.31.0", + "@cosmjs/stargate": "^0.31.0", "@digitalbazaar/ed25519-signature-2020": "^3.0.0", "@digitalbazaar/ed25519-verification-key-2018": "^3.1.2", "@digitalbazaar/ed25519-verification-key-2020": "^3.3.0", - "@stablelib/ed25519": "^1.0.2", - "axios": "^0.19.0", + "@iden3/js-jsonld-merklization": "^1.0.2", + "@iden3/js-merkletree": "^1.1.2", + "axios": "^1.6.2", + "babyjubjub2021": "^0.1.1", + "babyjubjubsignature2021": "github:hypersign-protocol/BabyJubJubSignature2021Suite", "crypto-ld": "^6.0.0", "ethereumeip712signature2021suite": "github:hypersign-protocol/EthereumEip712Signature2021Suite.git", "jcs": "github:hypersign-protocol/JCS", - "jsonld": "^8.2.0", "jsonld-signatures": "^9.3.1", "jsonwebtoken": "^9.0.1", - "node-fetch": "^2.6.1", + "multiformats": "^9.9.0", + "node-fetch": "^2.7.0", "protobufjs": "^6.11.2", "uuid": "^8.3.0", "vc-js": "https://github.com/hypersign-protocol/vc-js", @@ -48,23 +52,20 @@ }, "node_modules/@aashutoshrathi/word-wrap": { "version": "1.2.6", - "resolved": "https://registry.npmjs.org/@aashutoshrathi/word-wrap/-/word-wrap-1.2.6.tgz", - "integrity": "sha512-1Yjs2SvM8TflER/OD3cOjhWWOZb58A2t7wpE2S9XfBYTiIl+XFhQG2bjy4Pu1I+EAlCNUzRDYDdFwFYUKvXcIA==", "dev": true, + "license": "MIT", "engines": { "node": ">=0.10.0" } }, "node_modules/@adraffy/ens-normalize": { - "version": "1.9.2", - "resolved": "https://registry.npmjs.org/@adraffy/ens-normalize/-/ens-normalize-1.9.2.tgz", - "integrity": "sha512-0h+FrQDqe2Wn+IIGFkTCd4aAwTJ+7834Ek1COohCyV26AXhwQ7WQaz+4F/nLOeVl/3BtWHOHLPsq46V8YB46Eg==" + "version": "1.10.0", + "license": "MIT" }, "node_modules/@ampproject/remapping": { "version": "2.2.1", - "resolved": "https://registry.npmjs.org/@ampproject/remapping/-/remapping-2.2.1.tgz", - "integrity": "sha512-lFMjJTrFL3j7L9yBxwYfCq2k6qqwHyzuUl/XBnif78PWTJYyL/dfowQHWE3sp6U6ZzqWiiIZnpTMO96zhkjwtg==", "dev": true, + "license": "Apache-2.0", "dependencies": { "@jridgewell/gen-mapping": "^0.3.0", "@jridgewell/trace-mapping": "^0.3.9" @@ -75,39 +76,36 @@ }, "node_modules/@babel/code-frame": { "version": "7.12.11", - "resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.12.11.tgz", - "integrity": "sha512-Zt1yodBx1UcyiePMSkWnU4hPqhwq7hGi2nFL1LeA3EUl+q2LQx16MISgJ0+z7dnmgvP9QtIleuETGOiOH1RcIw==", "dev": true, + "license": "MIT", "dependencies": { "@babel/highlight": "^7.10.4" } }, "node_modules/@babel/compat-data": { - "version": "7.22.9", - "resolved": "https://registry.npmjs.org/@babel/compat-data/-/compat-data-7.22.9.tgz", - "integrity": "sha512-5UamI7xkUcJ3i9qVDS+KFDEK8/7oJ55/sJMB1Ge7IEapr7KfdfV/HErR+koZwOfd+SgtFKOKRhRakdg++DcJpQ==", + "version": "7.23.5", "dev": true, + "license": "MIT", "engines": { "node": ">=6.9.0" } }, "node_modules/@babel/core": { - "version": "7.22.15", - "resolved": "https://registry.npmjs.org/@babel/core/-/core-7.22.15.tgz", - "integrity": "sha512-PtZqMmgRrvj8ruoEOIwVA3yoF91O+Hgw9o7DAUTNBA6Mo2jpu31clx9a7Nz/9JznqetTR6zwfC4L3LAjKQXUwA==", + "version": "7.23.6", "dev": true, + "license": "MIT", "dependencies": { "@ampproject/remapping": "^2.2.0", - "@babel/code-frame": "^7.22.13", - "@babel/generator": "^7.22.15", - "@babel/helper-compilation-targets": "^7.22.15", - "@babel/helper-module-transforms": "^7.22.15", - "@babel/helpers": "^7.22.15", - "@babel/parser": "^7.22.15", + "@babel/code-frame": "^7.23.5", + "@babel/generator": "^7.23.6", + "@babel/helper-compilation-targets": "^7.23.6", + "@babel/helper-module-transforms": "^7.23.3", + "@babel/helpers": "^7.23.6", + "@babel/parser": "^7.23.6", "@babel/template": "^7.22.15", - "@babel/traverse": "^7.22.15", - "@babel/types": "^7.22.15", - "convert-source-map": "^1.7.0", + "@babel/traverse": "^7.23.6", + "@babel/types": "^7.23.6", + "convert-source-map": "^2.0.0", "debug": "^4.1.0", "gensync": "^1.0.0-beta.2", "json5": "^2.2.3", @@ -122,12 +120,11 @@ } }, "node_modules/@babel/core/node_modules/@babel/code-frame": { - "version": "7.22.13", - "resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.22.13.tgz", - "integrity": "sha512-XktuhWlJ5g+3TJXc5upd9Ks1HutSArik6jf2eAjYFyIOf4ej3RN+184cZbzDvbPnuTJIUhPKKJE3cIsYTiAT3w==", + "version": "7.23.5", "dev": true, + "license": "MIT", "dependencies": { - "@babel/highlight": "^7.22.13", + "@babel/highlight": "^7.23.4", "chalk": "^2.4.2" }, "engines": { @@ -136,9 +133,8 @@ }, "node_modules/@babel/core/node_modules/ansi-styles": { "version": "3.2.1", - "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-3.2.1.tgz", - "integrity": "sha512-VT0ZI6kZRdTh8YyJw3SMbYm/u+NqfsAxEpWO0Pf9sq8/e94WxxOpPKx9FR1FlyCtOVDNOQ+8ntlqFxiRc+r5qA==", "dev": true, + "license": "MIT", "dependencies": { "color-convert": "^1.9.0" }, @@ -148,9 +144,8 @@ }, "node_modules/@babel/core/node_modules/chalk": { "version": "2.4.2", - "resolved": "https://registry.npmjs.org/chalk/-/chalk-2.4.2.tgz", - "integrity": "sha512-Mti+f9lpJNcwF4tWV8/OrTTtF1gZi+f8FqlyAdouralcFWFQWF2+NgCHShjkCb+IFBLq9buZwE1xckQU4peSuQ==", "dev": true, + "license": "MIT", "dependencies": { "ansi-styles": "^3.2.1", "escape-string-regexp": "^1.0.5", @@ -162,51 +157,50 @@ }, "node_modules/@babel/core/node_modules/color-convert": { "version": "1.9.3", - "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-1.9.3.tgz", - "integrity": "sha512-QfAUtd+vFdAtFQcC8CCyYt1fYWxSqAiK2cSD6zDB8N3cpsEBAvRxp9zOGg6G/SHHJYAT88/az/IuDGALsNVbGg==", "dev": true, + "license": "MIT", "dependencies": { "color-name": "1.1.3" } }, "node_modules/@babel/core/node_modules/color-name": { "version": "1.1.3", - "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.3.tgz", - "integrity": "sha512-72fSenhMw2HZMTVHeCA9KCmpEIbzWiQsjN+BHcBbS9vr1mtt+vJjPdksIBNUmKAW8TFUDPJK5SUU3QhE9NEXDw==", - "dev": true + "dev": true, + "license": "MIT" + }, + "node_modules/@babel/core/node_modules/convert-source-map": { + "version": "2.0.0", + "dev": true, + "license": "MIT" }, "node_modules/@babel/core/node_modules/escape-string-regexp": { "version": "1.0.5", - "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz", - "integrity": "sha512-vbRorB5FUQWvla16U8R/qgaFIya2qGzwDrNmCZuYKrbdSUMG6I1ZCGQRefkRVhuOkIGVne7BQ35DSfo1qvJqFg==", "dev": true, + "license": "MIT", "engines": { "node": ">=0.8.0" } }, "node_modules/@babel/core/node_modules/has-flag": { "version": "3.0.0", - "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-3.0.0.tgz", - "integrity": "sha512-sKJf1+ceQBr4SMkvQnBDNDtf4TXpVhVGateu0t918bl30FnbE2m4vNLX+VWe/dpjlb+HugGYzW7uQXH98HPEYw==", "dev": true, + "license": "MIT", "engines": { "node": ">=4" } }, "node_modules/@babel/core/node_modules/semver": { "version": "6.3.1", - "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.1.tgz", - "integrity": "sha512-BR7VvDCVHO+q2xBEWskxS6DJE1qRnb7DxzUrogb71CWoSficBxYsiAGd+Kl0mmq/MprG9yArRkyrQxTO6XjMzA==", "dev": true, + "license": "ISC", "bin": { "semver": "bin/semver.js" } }, "node_modules/@babel/core/node_modules/supports-color": { "version": "5.5.0", - "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.5.0.tgz", - "integrity": "sha512-QjVjwdXIt408MIiAqCX4oUKsgU2EqAGzs2Ppkm4aQYbjm+ZEWEcW4SfFNTr4uMNZma0ey4f5lgLrkB0aX0QMow==", "dev": true, + "license": "MIT", "dependencies": { "has-flag": "^3.0.0" }, @@ -215,12 +209,11 @@ } }, "node_modules/@babel/generator": { - "version": "7.22.15", - "resolved": "https://registry.npmjs.org/@babel/generator/-/generator-7.22.15.tgz", - "integrity": "sha512-Zu9oWARBqeVOW0dZOjXc3JObrzuqothQ3y/n1kUtrjCoCPLkXUwMvOo/F/TCfoHMbWIFlWwpZtkZVb9ga4U2pA==", + "version": "7.23.6", "dev": true, + "license": "MIT", "dependencies": { - "@babel/types": "^7.22.15", + "@babel/types": "^7.23.6", "@jridgewell/gen-mapping": "^0.3.2", "@jridgewell/trace-mapping": "^0.3.17", "jsesc": "^2.5.1" @@ -230,14 +223,13 @@ } }, "node_modules/@babel/helper-compilation-targets": { - "version": "7.22.15", - "resolved": "https://registry.npmjs.org/@babel/helper-compilation-targets/-/helper-compilation-targets-7.22.15.tgz", - "integrity": "sha512-y6EEzULok0Qvz8yyLkCvVX+02ic+By2UdOhylwUOvOn9dvYc9mKICJuuU1n1XBI02YWsNsnrY1kc6DVbjcXbtw==", + "version": "7.23.6", "dev": true, + "license": "MIT", "dependencies": { - "@babel/compat-data": "^7.22.9", - "@babel/helper-validator-option": "^7.22.15", - "browserslist": "^4.21.9", + "@babel/compat-data": "^7.23.5", + "@babel/helper-validator-option": "^7.23.5", + "browserslist": "^4.22.2", "lru-cache": "^5.1.1", "semver": "^6.3.1" }, @@ -247,30 +239,27 @@ }, "node_modules/@babel/helper-compilation-targets/node_modules/semver": { "version": "6.3.1", - "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.1.tgz", - "integrity": "sha512-BR7VvDCVHO+q2xBEWskxS6DJE1qRnb7DxzUrogb71CWoSficBxYsiAGd+Kl0mmq/MprG9yArRkyrQxTO6XjMzA==", "dev": true, + "license": "ISC", "bin": { "semver": "bin/semver.js" } }, "node_modules/@babel/helper-environment-visitor": { - "version": "7.22.5", - "resolved": "https://registry.npmjs.org/@babel/helper-environment-visitor/-/helper-environment-visitor-7.22.5.tgz", - "integrity": "sha512-XGmhECfVA/5sAt+H+xpSg0mfrHq6FzNr9Oxh7PSEBBRUb/mL7Kz3NICXb194rCqAEdxkhPT1a88teizAFyvk8Q==", + "version": "7.22.20", "dev": true, + "license": "MIT", "engines": { "node": ">=6.9.0" } }, "node_modules/@babel/helper-function-name": { - "version": "7.22.5", - "resolved": "https://registry.npmjs.org/@babel/helper-function-name/-/helper-function-name-7.22.5.tgz", - "integrity": "sha512-wtHSq6jMRE3uF2otvfuD3DIvVhOsSNshQl0Qrd7qC9oQJzHvOL4qQXlQn2916+CXGywIjpGuIkoyZRRxHPiNQQ==", + "version": "7.23.0", "dev": true, + "license": "MIT", "dependencies": { - "@babel/template": "^7.22.5", - "@babel/types": "^7.22.5" + "@babel/template": "^7.22.15", + "@babel/types": "^7.23.0" }, "engines": { "node": ">=6.9.0" @@ -278,9 +267,8 @@ }, "node_modules/@babel/helper-hoist-variables": { "version": "7.22.5", - "resolved": "https://registry.npmjs.org/@babel/helper-hoist-variables/-/helper-hoist-variables-7.22.5.tgz", - "integrity": "sha512-wGjk9QZVzvknA6yKIUURb8zY3grXCcOZt+/7Wcy8O2uctxhplmUPkOdlgoNhmdVee2c92JXbf1xpMtVNbfoxRw==", "dev": true, + "license": "MIT", "dependencies": { "@babel/types": "^7.22.5" }, @@ -290,9 +278,8 @@ }, "node_modules/@babel/helper-module-imports": { "version": "7.22.15", - "resolved": "https://registry.npmjs.org/@babel/helper-module-imports/-/helper-module-imports-7.22.15.tgz", - "integrity": "sha512-0pYVBnDKZO2fnSPCrgM/6WMc7eS20Fbok+0r88fp+YtWVLZrp4CkafFGIp+W0VKw4a22sgebPT99y+FDNMdP4w==", "dev": true, + "license": "MIT", "dependencies": { "@babel/types": "^7.22.15" }, @@ -301,16 +288,15 @@ } }, "node_modules/@babel/helper-module-transforms": { - "version": "7.22.15", - "resolved": "https://registry.npmjs.org/@babel/helper-module-transforms/-/helper-module-transforms-7.22.15.tgz", - "integrity": "sha512-l1UiX4UyHSFsYt17iQ3Se5pQQZZHa22zyIXURmvkmLCD4t/aU+dvNWHatKac/D9Vm9UES7nvIqHs4jZqKviUmQ==", + "version": "7.23.3", "dev": true, + "license": "MIT", "dependencies": { - "@babel/helper-environment-visitor": "^7.22.5", + "@babel/helper-environment-visitor": "^7.22.20", "@babel/helper-module-imports": "^7.22.15", "@babel/helper-simple-access": "^7.22.5", "@babel/helper-split-export-declaration": "^7.22.6", - "@babel/helper-validator-identifier": "^7.22.15" + "@babel/helper-validator-identifier": "^7.22.20" }, "engines": { "node": ">=6.9.0" @@ -321,18 +307,16 @@ }, "node_modules/@babel/helper-plugin-utils": { "version": "7.22.5", - "resolved": "https://registry.npmjs.org/@babel/helper-plugin-utils/-/helper-plugin-utils-7.22.5.tgz", - "integrity": "sha512-uLls06UVKgFG9QD4OeFYLEGteMIAa5kpTPcFL28yuCIIzsf6ZyKZMllKVOCZFhiZ5ptnwX4mtKdWCBE/uT4amg==", "dev": true, + "license": "MIT", "engines": { "node": ">=6.9.0" } }, "node_modules/@babel/helper-simple-access": { "version": "7.22.5", - "resolved": "https://registry.npmjs.org/@babel/helper-simple-access/-/helper-simple-access-7.22.5.tgz", - "integrity": "sha512-n0H99E/K+Bika3++WNL17POvo4rKWZ7lZEp1Q+fStVbUi8nxPQEBOlTmCOxW/0JsS56SKKQ+ojAe2pHKJHN35w==", "dev": true, + "license": "MIT", "dependencies": { "@babel/types": "^7.22.5" }, @@ -342,9 +326,8 @@ }, "node_modules/@babel/helper-split-export-declaration": { "version": "7.22.6", - "resolved": "https://registry.npmjs.org/@babel/helper-split-export-declaration/-/helper-split-export-declaration-7.22.6.tgz", - "integrity": "sha512-AsUnxuLhRYsisFiaJwvp1QF+I3KjD5FOxut14q/GzovUe6orHLesW2C7d754kRm53h5gqrz6sFl6sxc4BVtE/g==", "dev": true, + "license": "MIT", "dependencies": { "@babel/types": "^7.22.5" }, @@ -353,53 +336,48 @@ } }, "node_modules/@babel/helper-string-parser": { - "version": "7.22.5", - "resolved": "https://registry.npmjs.org/@babel/helper-string-parser/-/helper-string-parser-7.22.5.tgz", - "integrity": "sha512-mM4COjgZox8U+JcXQwPijIZLElkgEpO5rsERVDJTc2qfCDfERyob6k5WegS14SX18IIjv+XD+GrqNumY5JRCDw==", + "version": "7.23.4", "dev": true, + "license": "MIT", "engines": { "node": ">=6.9.0" } }, "node_modules/@babel/helper-validator-identifier": { - "version": "7.22.15", - "resolved": "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.22.15.tgz", - "integrity": "sha512-4E/F9IIEi8WR94324mbDUMo074YTheJmd7eZF5vITTeYchqAi6sYXRLHUVsmkdmY4QjfKTcB2jB7dVP3NaBElQ==", + "version": "7.22.20", "dev": true, + "license": "MIT", "engines": { "node": ">=6.9.0" } }, "node_modules/@babel/helper-validator-option": { - "version": "7.22.15", - "resolved": "https://registry.npmjs.org/@babel/helper-validator-option/-/helper-validator-option-7.22.15.tgz", - "integrity": "sha512-bMn7RmyFjY/mdECUbgn9eoSY4vqvacUnS9i9vGAGttgFWesO6B4CYWA7XlpbWgBt71iv/hfbPlynohStqnu5hA==", + "version": "7.23.5", "dev": true, + "license": "MIT", "engines": { "node": ">=6.9.0" } }, "node_modules/@babel/helpers": { - "version": "7.22.15", - "resolved": "https://registry.npmjs.org/@babel/helpers/-/helpers-7.22.15.tgz", - "integrity": "sha512-7pAjK0aSdxOwR+CcYAqgWOGy5dcfvzsTIfFTb2odQqW47MDfv14UaJDY6eng8ylM2EaeKXdxaSWESbkmaQHTmw==", + "version": "7.23.6", "dev": true, + "license": "MIT", "dependencies": { "@babel/template": "^7.22.15", - "@babel/traverse": "^7.22.15", - "@babel/types": "^7.22.15" + "@babel/traverse": "^7.23.6", + "@babel/types": "^7.23.6" }, "engines": { "node": ">=6.9.0" } }, "node_modules/@babel/highlight": { - "version": "7.22.13", - "resolved": "https://registry.npmjs.org/@babel/highlight/-/highlight-7.22.13.tgz", - "integrity": "sha512-C/BaXcnnvBCmHTpz/VGZ8jgtE2aYlW4hxDhseJAWZb7gqGM/qtCK6iZUb0TyKFf7BOUsBH7Q7fkRsDRhg1XklQ==", + "version": "7.23.4", "dev": true, + "license": "MIT", "dependencies": { - "@babel/helper-validator-identifier": "^7.22.5", + "@babel/helper-validator-identifier": "^7.22.20", "chalk": "^2.4.2", "js-tokens": "^4.0.0" }, @@ -409,9 +387,8 @@ }, "node_modules/@babel/highlight/node_modules/ansi-styles": { "version": "3.2.1", - "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-3.2.1.tgz", - "integrity": "sha512-VT0ZI6kZRdTh8YyJw3SMbYm/u+NqfsAxEpWO0Pf9sq8/e94WxxOpPKx9FR1FlyCtOVDNOQ+8ntlqFxiRc+r5qA==", "dev": true, + "license": "MIT", "dependencies": { "color-convert": "^1.9.0" }, @@ -421,9 +398,8 @@ }, "node_modules/@babel/highlight/node_modules/chalk": { "version": "2.4.2", - "resolved": "https://registry.npmjs.org/chalk/-/chalk-2.4.2.tgz", - "integrity": "sha512-Mti+f9lpJNcwF4tWV8/OrTTtF1gZi+f8FqlyAdouralcFWFQWF2+NgCHShjkCb+IFBLq9buZwE1xckQU4peSuQ==", "dev": true, + "license": "MIT", "dependencies": { "ansi-styles": "^3.2.1", "escape-string-regexp": "^1.0.5", @@ -435,42 +411,37 @@ }, "node_modules/@babel/highlight/node_modules/color-convert": { "version": "1.9.3", - "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-1.9.3.tgz", - "integrity": "sha512-QfAUtd+vFdAtFQcC8CCyYt1fYWxSqAiK2cSD6zDB8N3cpsEBAvRxp9zOGg6G/SHHJYAT88/az/IuDGALsNVbGg==", "dev": true, + "license": "MIT", "dependencies": { "color-name": "1.1.3" } }, "node_modules/@babel/highlight/node_modules/color-name": { "version": "1.1.3", - "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.3.tgz", - "integrity": "sha512-72fSenhMw2HZMTVHeCA9KCmpEIbzWiQsjN+BHcBbS9vr1mtt+vJjPdksIBNUmKAW8TFUDPJK5SUU3QhE9NEXDw==", - "dev": true + "dev": true, + "license": "MIT" }, "node_modules/@babel/highlight/node_modules/escape-string-regexp": { "version": "1.0.5", - "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz", - "integrity": "sha512-vbRorB5FUQWvla16U8R/qgaFIya2qGzwDrNmCZuYKrbdSUMG6I1ZCGQRefkRVhuOkIGVne7BQ35DSfo1qvJqFg==", "dev": true, + "license": "MIT", "engines": { "node": ">=0.8.0" } }, "node_modules/@babel/highlight/node_modules/has-flag": { "version": "3.0.0", - "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-3.0.0.tgz", - "integrity": "sha512-sKJf1+ceQBr4SMkvQnBDNDtf4TXpVhVGateu0t918bl30FnbE2m4vNLX+VWe/dpjlb+HugGYzW7uQXH98HPEYw==", "dev": true, + "license": "MIT", "engines": { "node": ">=4" } }, "node_modules/@babel/highlight/node_modules/supports-color": { "version": "5.5.0", - "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.5.0.tgz", - "integrity": "sha512-QjVjwdXIt408MIiAqCX4oUKsgU2EqAGzs2Ppkm4aQYbjm+ZEWEcW4SfFNTr4uMNZma0ey4f5lgLrkB0aX0QMow==", "dev": true, + "license": "MIT", "dependencies": { "has-flag": "^3.0.0" }, @@ -479,10 +450,9 @@ } }, "node_modules/@babel/parser": { - "version": "7.22.16", - "resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.22.16.tgz", - "integrity": "sha512-+gPfKv8UWeKKeJTUxe59+OobVcrYHETCsORl61EmSkmgymguYk/X5bp7GuUIXaFsc6y++v8ZxPsLSSuujqDphA==", + "version": "7.23.6", "dev": true, + "license": "MIT", "bin": { "parser": "bin/babel-parser.js" }, @@ -492,9 +462,8 @@ }, "node_modules/@babel/plugin-syntax-async-generators": { "version": "7.8.4", - "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-async-generators/-/plugin-syntax-async-generators-7.8.4.tgz", - "integrity": "sha512-tycmZxkGfZaxhMRbXlPXuVFpdWlXpir2W4AMhSJgRKzk/eDlIXOhb2LHWoLpDF7TEHylV5zNhykX6KAgHJmTNw==", "dev": true, + "license": "MIT", "dependencies": { "@babel/helper-plugin-utils": "^7.8.0" }, @@ -504,9 +473,8 @@ }, "node_modules/@babel/plugin-syntax-bigint": { "version": "7.8.3", - "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-bigint/-/plugin-syntax-bigint-7.8.3.tgz", - "integrity": "sha512-wnTnFlG+YxQm3vDxpGE57Pj0srRU4sHE/mDkt1qv2YJJSeUAec2ma4WLUnUPeKjyrfntVwe/N6dCXpU+zL3Npg==", "dev": true, + "license": "MIT", "dependencies": { "@babel/helper-plugin-utils": "^7.8.0" }, @@ -516,9 +484,8 @@ }, "node_modules/@babel/plugin-syntax-class-properties": { "version": "7.12.13", - "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-class-properties/-/plugin-syntax-class-properties-7.12.13.tgz", - "integrity": "sha512-fm4idjKla0YahUNgFNLCB0qySdsoPiZP3iQE3rky0mBUtMZ23yDJ9SJdg6dXTSDnulOVqiF3Hgr9nbXvXTQZYA==", "dev": true, + "license": "MIT", "dependencies": { "@babel/helper-plugin-utils": "^7.12.13" }, @@ -528,9 +495,8 @@ }, "node_modules/@babel/plugin-syntax-import-meta": { "version": "7.10.4", - "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-import-meta/-/plugin-syntax-import-meta-7.10.4.tgz", - "integrity": "sha512-Yqfm+XDx0+Prh3VSeEQCPU81yC+JWZ2pDPFSS4ZdpfZhp4MkFMaDC1UqseovEKwSUpnIL7+vK+Clp7bfh0iD7g==", "dev": true, + "license": "MIT", "dependencies": { "@babel/helper-plugin-utils": "^7.10.4" }, @@ -540,9 +506,8 @@ }, "node_modules/@babel/plugin-syntax-json-strings": { "version": "7.8.3", - "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-json-strings/-/plugin-syntax-json-strings-7.8.3.tgz", - "integrity": "sha512-lY6kdGpWHvjoe2vk4WrAapEuBR69EMxZl+RoGRhrFGNYVK8mOPAW8VfbT/ZgrFbXlDNiiaxQnAtgVCZ6jv30EA==", "dev": true, + "license": "MIT", "dependencies": { "@babel/helper-plugin-utils": "^7.8.0" }, @@ -552,9 +517,8 @@ }, "node_modules/@babel/plugin-syntax-logical-assignment-operators": { "version": "7.10.4", - "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-logical-assignment-operators/-/plugin-syntax-logical-assignment-operators-7.10.4.tgz", - "integrity": "sha512-d8waShlpFDinQ5MtvGU9xDAOzKH47+FFoney2baFIoMr952hKOLp1HR7VszoZvOsV/4+RRszNY7D17ba0te0ig==", "dev": true, + "license": "MIT", "dependencies": { "@babel/helper-plugin-utils": "^7.10.4" }, @@ -564,9 +528,8 @@ }, "node_modules/@babel/plugin-syntax-nullish-coalescing-operator": { "version": "7.8.3", - "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-nullish-coalescing-operator/-/plugin-syntax-nullish-coalescing-operator-7.8.3.tgz", - "integrity": "sha512-aSff4zPII1u2QD7y+F8oDsz19ew4IGEJg9SVW+bqwpwtfFleiQDMdzA/R+UlWDzfnHFCxxleFT0PMIrR36XLNQ==", "dev": true, + "license": "MIT", "dependencies": { "@babel/helper-plugin-utils": "^7.8.0" }, @@ -576,9 +539,8 @@ }, "node_modules/@babel/plugin-syntax-numeric-separator": { "version": "7.10.4", - "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-numeric-separator/-/plugin-syntax-numeric-separator-7.10.4.tgz", - "integrity": "sha512-9H6YdfkcK/uOnY/K7/aA2xpzaAgkQn37yzWUMRK7OaPOqOpGS1+n0H5hxT9AUw9EsSjPW8SVyMJwYRtWs3X3ug==", "dev": true, + "license": "MIT", "dependencies": { "@babel/helper-plugin-utils": "^7.10.4" }, @@ -588,9 +550,8 @@ }, "node_modules/@babel/plugin-syntax-object-rest-spread": { "version": "7.8.3", - "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-object-rest-spread/-/plugin-syntax-object-rest-spread-7.8.3.tgz", - "integrity": "sha512-XoqMijGZb9y3y2XskN+P1wUGiVwWZ5JmoDRwx5+3GmEplNyVM2s2Dg8ILFQm8rWM48orGy5YpI5Bl8U1y7ydlA==", "dev": true, + "license": "MIT", "dependencies": { "@babel/helper-plugin-utils": "^7.8.0" }, @@ -600,9 +561,8 @@ }, "node_modules/@babel/plugin-syntax-optional-catch-binding": { "version": "7.8.3", - "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-optional-catch-binding/-/plugin-syntax-optional-catch-binding-7.8.3.tgz", - "integrity": "sha512-6VPD0Pc1lpTqw0aKoeRTMiB+kWhAoT24PA+ksWSBrFtl5SIRVpZlwN3NNPQjehA2E/91FV3RjLWoVTglWcSV3Q==", "dev": true, + "license": "MIT", "dependencies": { "@babel/helper-plugin-utils": "^7.8.0" }, @@ -612,9 +572,8 @@ }, "node_modules/@babel/plugin-syntax-optional-chaining": { "version": "7.8.3", - "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-optional-chaining/-/plugin-syntax-optional-chaining-7.8.3.tgz", - "integrity": "sha512-KoK9ErH1MBlCPxV0VANkXW2/dw4vlbGDrFgz8bmUsBGYkFRcbRwMh6cIJubdPrkxRwuGdtCk0v/wPTKbQgBjkg==", "dev": true, + "license": "MIT", "dependencies": { "@babel/helper-plugin-utils": "^7.8.0" }, @@ -624,9 +583,8 @@ }, "node_modules/@babel/plugin-syntax-top-level-await": { "version": "7.14.5", - "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-top-level-await/-/plugin-syntax-top-level-await-7.14.5.tgz", - "integrity": "sha512-hx++upLv5U1rgYfwe1xBQUhRmU41NEvpUvrp8jkrSCdvGSnM5/qdRMtylJ6PG5OFkBaHkbTAKTnd3/YyESRHFw==", "dev": true, + "license": "MIT", "dependencies": { "@babel/helper-plugin-utils": "^7.14.5" }, @@ -638,10 +596,9 @@ } }, "node_modules/@babel/plugin-syntax-typescript": { - "version": "7.22.5", - "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-typescript/-/plugin-syntax-typescript-7.22.5.tgz", - "integrity": "sha512-1mS2o03i7t1c6VzH6fdQ3OA8tcEIxwG18zIPRp+UY1Ihv6W+XZzBCVxExF9upussPXJ0xE9XRHwMoNs1ep/nRQ==", + "version": "7.23.3", "dev": true, + "license": "MIT", "dependencies": { "@babel/helper-plugin-utils": "^7.22.5" }, @@ -654,9 +611,8 @@ }, "node_modules/@babel/template": { "version": "7.22.15", - "resolved": "https://registry.npmjs.org/@babel/template/-/template-7.22.15.tgz", - "integrity": "sha512-QPErUVm4uyJa60rkI73qneDacvdvzxshT3kksGqlGWYdOTIUOwJ7RDUL8sGqslY1uXWSL6xMFKEXDS3ox2uF0w==", "dev": true, + "license": "MIT", "dependencies": { "@babel/code-frame": "^7.22.13", "@babel/parser": "^7.22.15", @@ -667,12 +623,11 @@ } }, "node_modules/@babel/template/node_modules/@babel/code-frame": { - "version": "7.22.13", - "resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.22.13.tgz", - "integrity": "sha512-XktuhWlJ5g+3TJXc5upd9Ks1HutSArik6jf2eAjYFyIOf4ej3RN+184cZbzDvbPnuTJIUhPKKJE3cIsYTiAT3w==", + "version": "7.23.5", "dev": true, + "license": "MIT", "dependencies": { - "@babel/highlight": "^7.22.13", + "@babel/highlight": "^7.23.4", "chalk": "^2.4.2" }, "engines": { @@ -681,9 +636,8 @@ }, "node_modules/@babel/template/node_modules/ansi-styles": { "version": "3.2.1", - "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-3.2.1.tgz", - "integrity": "sha512-VT0ZI6kZRdTh8YyJw3SMbYm/u+NqfsAxEpWO0Pf9sq8/e94WxxOpPKx9FR1FlyCtOVDNOQ+8ntlqFxiRc+r5qA==", "dev": true, + "license": "MIT", "dependencies": { "color-convert": "^1.9.0" }, @@ -693,9 +647,8 @@ }, "node_modules/@babel/template/node_modules/chalk": { "version": "2.4.2", - "resolved": "https://registry.npmjs.org/chalk/-/chalk-2.4.2.tgz", - "integrity": "sha512-Mti+f9lpJNcwF4tWV8/OrTTtF1gZi+f8FqlyAdouralcFWFQWF2+NgCHShjkCb+IFBLq9buZwE1xckQU4peSuQ==", "dev": true, + "license": "MIT", "dependencies": { "ansi-styles": "^3.2.1", "escape-string-regexp": "^1.0.5", @@ -707,42 +660,37 @@ }, "node_modules/@babel/template/node_modules/color-convert": { "version": "1.9.3", - "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-1.9.3.tgz", - "integrity": "sha512-QfAUtd+vFdAtFQcC8CCyYt1fYWxSqAiK2cSD6zDB8N3cpsEBAvRxp9zOGg6G/SHHJYAT88/az/IuDGALsNVbGg==", "dev": true, + "license": "MIT", "dependencies": { "color-name": "1.1.3" } }, "node_modules/@babel/template/node_modules/color-name": { "version": "1.1.3", - "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.3.tgz", - "integrity": "sha512-72fSenhMw2HZMTVHeCA9KCmpEIbzWiQsjN+BHcBbS9vr1mtt+vJjPdksIBNUmKAW8TFUDPJK5SUU3QhE9NEXDw==", - "dev": true + "dev": true, + "license": "MIT" }, "node_modules/@babel/template/node_modules/escape-string-regexp": { "version": "1.0.5", - "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz", - "integrity": "sha512-vbRorB5FUQWvla16U8R/qgaFIya2qGzwDrNmCZuYKrbdSUMG6I1ZCGQRefkRVhuOkIGVne7BQ35DSfo1qvJqFg==", "dev": true, + "license": "MIT", "engines": { "node": ">=0.8.0" } }, "node_modules/@babel/template/node_modules/has-flag": { "version": "3.0.0", - "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-3.0.0.tgz", - "integrity": "sha512-sKJf1+ceQBr4SMkvQnBDNDtf4TXpVhVGateu0t918bl30FnbE2m4vNLX+VWe/dpjlb+HugGYzW7uQXH98HPEYw==", "dev": true, + "license": "MIT", "engines": { "node": ">=4" } }, "node_modules/@babel/template/node_modules/supports-color": { "version": "5.5.0", - "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.5.0.tgz", - "integrity": "sha512-QjVjwdXIt408MIiAqCX4oUKsgU2EqAGzs2Ppkm4aQYbjm+ZEWEcW4SfFNTr4uMNZma0ey4f5lgLrkB0aX0QMow==", "dev": true, + "license": "MIT", "dependencies": { "has-flag": "^3.0.0" }, @@ -751,20 +699,19 @@ } }, "node_modules/@babel/traverse": { - "version": "7.22.15", - "resolved": "https://registry.npmjs.org/@babel/traverse/-/traverse-7.22.15.tgz", - "integrity": "sha512-DdHPwvJY0sEeN4xJU5uRLmZjgMMDIvMPniLuYzUVXj/GGzysPl0/fwt44JBkyUIzGJPV8QgHMcQdQ34XFuKTYQ==", + "version": "7.23.6", "dev": true, + "license": "MIT", "dependencies": { - "@babel/code-frame": "^7.22.13", - "@babel/generator": "^7.22.15", - "@babel/helper-environment-visitor": "^7.22.5", - "@babel/helper-function-name": "^7.22.5", + "@babel/code-frame": "^7.23.5", + "@babel/generator": "^7.23.6", + "@babel/helper-environment-visitor": "^7.22.20", + "@babel/helper-function-name": "^7.23.0", "@babel/helper-hoist-variables": "^7.22.5", "@babel/helper-split-export-declaration": "^7.22.6", - "@babel/parser": "^7.22.15", - "@babel/types": "^7.22.15", - "debug": "^4.1.0", + "@babel/parser": "^7.23.6", + "@babel/types": "^7.23.6", + "debug": "^4.3.1", "globals": "^11.1.0" }, "engines": { @@ -772,12 +719,11 @@ } }, "node_modules/@babel/traverse/node_modules/@babel/code-frame": { - "version": "7.22.13", - "resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.22.13.tgz", - "integrity": "sha512-XktuhWlJ5g+3TJXc5upd9Ks1HutSArik6jf2eAjYFyIOf4ej3RN+184cZbzDvbPnuTJIUhPKKJE3cIsYTiAT3w==", + "version": "7.23.5", "dev": true, + "license": "MIT", "dependencies": { - "@babel/highlight": "^7.22.13", + "@babel/highlight": "^7.23.4", "chalk": "^2.4.2" }, "engines": { @@ -786,9 +732,8 @@ }, "node_modules/@babel/traverse/node_modules/ansi-styles": { "version": "3.2.1", - "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-3.2.1.tgz", - "integrity": "sha512-VT0ZI6kZRdTh8YyJw3SMbYm/u+NqfsAxEpWO0Pf9sq8/e94WxxOpPKx9FR1FlyCtOVDNOQ+8ntlqFxiRc+r5qA==", "dev": true, + "license": "MIT", "dependencies": { "color-convert": "^1.9.0" }, @@ -798,9 +743,8 @@ }, "node_modules/@babel/traverse/node_modules/chalk": { "version": "2.4.2", - "resolved": "https://registry.npmjs.org/chalk/-/chalk-2.4.2.tgz", - "integrity": "sha512-Mti+f9lpJNcwF4tWV8/OrTTtF1gZi+f8FqlyAdouralcFWFQWF2+NgCHShjkCb+IFBLq9buZwE1xckQU4peSuQ==", "dev": true, + "license": "MIT", "dependencies": { "ansi-styles": "^3.2.1", "escape-string-regexp": "^1.0.5", @@ -812,51 +756,45 @@ }, "node_modules/@babel/traverse/node_modules/color-convert": { "version": "1.9.3", - "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-1.9.3.tgz", - "integrity": "sha512-QfAUtd+vFdAtFQcC8CCyYt1fYWxSqAiK2cSD6zDB8N3cpsEBAvRxp9zOGg6G/SHHJYAT88/az/IuDGALsNVbGg==", "dev": true, + "license": "MIT", "dependencies": { "color-name": "1.1.3" } }, "node_modules/@babel/traverse/node_modules/color-name": { "version": "1.1.3", - "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.3.tgz", - "integrity": "sha512-72fSenhMw2HZMTVHeCA9KCmpEIbzWiQsjN+BHcBbS9vr1mtt+vJjPdksIBNUmKAW8TFUDPJK5SUU3QhE9NEXDw==", - "dev": true + "dev": true, + "license": "MIT" }, "node_modules/@babel/traverse/node_modules/escape-string-regexp": { "version": "1.0.5", - "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz", - "integrity": "sha512-vbRorB5FUQWvla16U8R/qgaFIya2qGzwDrNmCZuYKrbdSUMG6I1ZCGQRefkRVhuOkIGVne7BQ35DSfo1qvJqFg==", "dev": true, + "license": "MIT", "engines": { "node": ">=0.8.0" } }, "node_modules/@babel/traverse/node_modules/globals": { "version": "11.12.0", - "resolved": "https://registry.npmjs.org/globals/-/globals-11.12.0.tgz", - "integrity": "sha512-WOBp/EEGUiIsJSp7wcv/y6MO+lV9UoncWqxuFfm8eBwzWNgyfBd6Gz+IeKQ9jCmyhoH99g15M3T+QaVHFjizVA==", "dev": true, + "license": "MIT", "engines": { "node": ">=4" } }, "node_modules/@babel/traverse/node_modules/has-flag": { "version": "3.0.0", - "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-3.0.0.tgz", - "integrity": "sha512-sKJf1+ceQBr4SMkvQnBDNDtf4TXpVhVGateu0t918bl30FnbE2m4vNLX+VWe/dpjlb+HugGYzW7uQXH98HPEYw==", "dev": true, + "license": "MIT", "engines": { "node": ">=4" } }, "node_modules/@babel/traverse/node_modules/supports-color": { "version": "5.5.0", - "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.5.0.tgz", - "integrity": "sha512-QjVjwdXIt408MIiAqCX4oUKsgU2EqAGzs2Ppkm4aQYbjm+ZEWEcW4SfFNTr4uMNZma0ey4f5lgLrkB0aX0QMow==", "dev": true, + "license": "MIT", "dependencies": { "has-flag": "^3.0.0" }, @@ -865,13 +803,12 @@ } }, "node_modules/@babel/types": { - "version": "7.22.15", - "resolved": "https://registry.npmjs.org/@babel/types/-/types-7.22.15.tgz", - "integrity": "sha512-X+NLXr0N8XXmN5ZsaQdm9U2SSC3UbIYq/doL++sueHOTisgZHoKaQtZxGuV2cUPQHMfjKEfg/g6oy7Hm6SKFtA==", + "version": "7.23.6", "dev": true, + "license": "MIT", "dependencies": { - "@babel/helper-string-parser": "^7.22.5", - "@babel/helper-validator-identifier": "^7.22.15", + "@babel/helper-string-parser": "^7.23.4", + "@babel/helper-validator-identifier": "^7.22.20", "to-fast-properties": "^2.0.0" }, "engines": { @@ -880,51 +817,48 @@ }, "node_modules/@bcoe/v8-coverage": { "version": "0.2.3", - "resolved": "https://registry.npmjs.org/@bcoe/v8-coverage/-/v8-coverage-0.2.3.tgz", - "integrity": "sha512-0hYQ8SB4Db5zvZB4axdMHGwEaQjkZzFjQiN9LVYvIFB2nSUHW9tYpxWriPrWDASIxiaXax83REcLxuSdnGPZtw==", - "dev": true + "dev": true, + "license": "MIT" + }, + "node_modules/@cfworker/json-schema": { + "version": "1.12.7", + "resolved": "git+ssh://git@github.com/hypersign-protocol/json-schema.git#ed4a14c72ce3e761895483dc8d6089cec71e2892", + "license": "MIT" }, "node_modules/@confio/ics23": { "version": "0.6.8", - "resolved": "https://registry.npmjs.org/@confio/ics23/-/ics23-0.6.8.tgz", - "integrity": "sha512-wB6uo+3A50m0sW/EWcU64xpV/8wShZ6bMTa7pF8eYsTrSkQA7oLUIJcs/wb8g4y2Oyq701BaGiO6n/ak5WXO1w==", + "license": "Apache-2.0", "dependencies": { "@noble/hashes": "^1.0.0", "protobufjs": "^6.8.8" } }, "node_modules/@cosmjs/amino": { - "version": "0.27.1", - "resolved": "https://registry.npmjs.org/@cosmjs/amino/-/amino-0.27.1.tgz", - "integrity": "sha512-w56ar/nK9+qlvWDpBPRmD0Blk2wfkkLqRi1COs1x7Ll1LF0AtkIBUjbRKplENLbNovK0T3h+w8bHiFm+GBGQOA==", + "version": "0.31.3", + "license": "Apache-2.0", "dependencies": { - "@cosmjs/crypto": "0.27.1", - "@cosmjs/encoding": "0.27.1", - "@cosmjs/math": "0.27.1", - "@cosmjs/utils": "0.27.1" + "@cosmjs/crypto": "^0.31.3", + "@cosmjs/encoding": "^0.31.3", + "@cosmjs/math": "^0.31.3", + "@cosmjs/utils": "^0.31.3" } }, "node_modules/@cosmjs/crypto": { - "version": "0.27.1", - "resolved": "https://registry.npmjs.org/@cosmjs/crypto/-/crypto-0.27.1.tgz", - "integrity": "sha512-vbcxwSt99tIYJg8Spp00wc3zx72qx+pY3ozGuBN8gAvySnagK9dQ/jHwtWQWdammmdD6oW+75WfIHZ+gNa+Ybg==", - "dependencies": { - "@cosmjs/encoding": "0.27.1", - "@cosmjs/math": "0.27.1", - "@cosmjs/utils": "0.27.1", - "bip39": "^3.0.2", + "version": "0.31.3", + "license": "Apache-2.0", + "dependencies": { + "@cosmjs/encoding": "^0.31.3", + "@cosmjs/math": "^0.31.3", + "@cosmjs/utils": "^0.31.3", + "@noble/hashes": "^1", "bn.js": "^5.2.0", - "elliptic": "^6.5.3", - "js-sha3": "^0.8.0", - "libsodium-wrappers": "^0.7.6", - "ripemd160": "^2.0.2", - "sha.js": "^2.4.11" + "elliptic": "^6.5.4", + "libsodium-wrappers-sumo": "^0.7.11" } }, "node_modules/@cosmjs/encoding": { - "version": "0.27.1", - "resolved": "https://registry.npmjs.org/@cosmjs/encoding/-/encoding-0.27.1.tgz", - "integrity": "sha512-rayLsA0ojHeniaRfWWcqSsrE/T1rl1gl0OXVNtXlPwLJifKBeLEefGbOUiAQaT0wgJ8VNGBazVtAZBpJidfDhw==", + "version": "0.31.3", + "license": "Apache-2.0", "dependencies": { "base64-js": "^1.3.0", "bech32": "^1.1.4", @@ -932,144 +866,79 @@ } }, "node_modules/@cosmjs/json-rpc": { - "version": "0.27.1", - "resolved": "https://registry.npmjs.org/@cosmjs/json-rpc/-/json-rpc-0.27.1.tgz", - "integrity": "sha512-AKvsllGr6oN5kiroatIeIIxRdCFetLd8LCWV04RRNkoJ2OefDNb46VlWEQ+gI3ay5GgfVjB9qAcfvbJyrcEv+A==", + "version": "0.31.3", + "license": "Apache-2.0", "dependencies": { - "@cosmjs/stream": "0.27.1", + "@cosmjs/stream": "^0.31.3", "xstream": "^11.14.0" } }, "node_modules/@cosmjs/math": { - "version": "0.27.1", - "resolved": "https://registry.npmjs.org/@cosmjs/math/-/math-0.27.1.tgz", - "integrity": "sha512-cHWVjmfIjtRc7f80n7x+J5k8pe+vTVTQ0lA82tIxUgqUvgS6rogPP/TmGtTiZ4+NxWxd11DUISY6gVpr18/VNQ==", + "version": "0.31.3", + "license": "Apache-2.0", "dependencies": { "bn.js": "^5.2.0" } }, "node_modules/@cosmjs/proto-signing": { - "version": "0.27.1", - "resolved": "https://registry.npmjs.org/@cosmjs/proto-signing/-/proto-signing-0.27.1.tgz", - "integrity": "sha512-t7/VvQivMdM1KgKWai/9ZCEcGFXJtr9Xo0hGcPLTn9wGkh9tmOsUXINYVMsf5D/jWIm1MDPbGCYfdb9V1Od4hw==", - "dependencies": { - "@cosmjs/amino": "0.27.1", - "@cosmjs/crypto": "0.27.1", - "@cosmjs/math": "0.27.1", - "cosmjs-types": "^0.4.0", - "long": "^4.0.0", - "protobufjs": "~6.10.2" - } - }, - "node_modules/@cosmjs/proto-signing/node_modules/@types/node": { - "version": "13.13.52", - "resolved": "https://registry.npmjs.org/@types/node/-/node-13.13.52.tgz", - "integrity": "sha512-s3nugnZumCC//n4moGGe6tkNMyYEdaDBitVjwPxXmR5lnMG5dHePinH2EdxkG3Rh1ghFHHixAG4NJhpJW1rthQ==" - }, - "node_modules/@cosmjs/proto-signing/node_modules/protobufjs": { - "version": "6.10.3", - "resolved": "https://registry.npmjs.org/protobufjs/-/protobufjs-6.10.3.tgz", - "integrity": "sha512-yvAslS0hNdBhlSKckI4R1l7wunVilX66uvrjzE4MimiAt7/qw1nLpMhZrn/ObuUTM/c3Xnfl01LYMdcSJe6dwg==", - "hasInstallScript": true, + "version": "0.31.3", + "license": "Apache-2.0", "dependencies": { - "@protobufjs/aspromise": "^1.1.2", - "@protobufjs/base64": "^1.1.2", - "@protobufjs/codegen": "^2.0.4", - "@protobufjs/eventemitter": "^1.1.0", - "@protobufjs/fetch": "^1.1.0", - "@protobufjs/float": "^1.0.2", - "@protobufjs/inquire": "^1.1.0", - "@protobufjs/path": "^1.1.2", - "@protobufjs/pool": "^1.1.0", - "@protobufjs/utf8": "^1.1.0", - "@types/long": "^4.0.1", - "@types/node": "^13.7.0", + "@cosmjs/amino": "^0.31.3", + "@cosmjs/crypto": "^0.31.3", + "@cosmjs/encoding": "^0.31.3", + "@cosmjs/math": "^0.31.3", + "@cosmjs/utils": "^0.31.3", + "cosmjs-types": "^0.8.0", "long": "^4.0.0" - }, - "bin": { - "pbjs": "bin/pbjs", - "pbts": "bin/pbts" } }, "node_modules/@cosmjs/socket": { - "version": "0.27.1", - "resolved": "https://registry.npmjs.org/@cosmjs/socket/-/socket-0.27.1.tgz", - "integrity": "sha512-bKCRsaSXh/TA7efxVCogzS2K3cgC40Ge2itFYmTfgpOE+++52FchCblVCsCYwMNDLS497RP4P0GbeC1VEBToMA==", + "version": "0.31.3", + "license": "Apache-2.0", "dependencies": { - "@cosmjs/stream": "0.27.1", + "@cosmjs/stream": "^0.31.3", "isomorphic-ws": "^4.0.1", "ws": "^7", "xstream": "^11.14.0" } }, "node_modules/@cosmjs/stargate": { - "version": "0.27.1", - "resolved": "https://registry.npmjs.org/@cosmjs/stargate/-/stargate-0.27.1.tgz", - "integrity": "sha512-7hAIyNd6NbhQA51w9mPVyMYw515Hpj0o7SXMaqbc7nxs3hkJNMONQ9RakyMm0U/WeCd6ObcSaPEcdkqbfkc+mg==", - "dependencies": { - "@confio/ics23": "^0.6.3", - "@cosmjs/amino": "0.27.1", - "@cosmjs/encoding": "0.27.1", - "@cosmjs/math": "0.27.1", - "@cosmjs/proto-signing": "0.27.1", - "@cosmjs/stream": "0.27.1", - "@cosmjs/tendermint-rpc": "0.27.1", - "@cosmjs/utils": "0.27.1", - "cosmjs-types": "^0.4.0", + "version": "0.31.3", + "license": "Apache-2.0", + "dependencies": { + "@confio/ics23": "^0.6.8", + "@cosmjs/amino": "^0.31.3", + "@cosmjs/encoding": "^0.31.3", + "@cosmjs/math": "^0.31.3", + "@cosmjs/proto-signing": "^0.31.3", + "@cosmjs/stream": "^0.31.3", + "@cosmjs/tendermint-rpc": "^0.31.3", + "@cosmjs/utils": "^0.31.3", + "cosmjs-types": "^0.8.0", "long": "^4.0.0", - "protobufjs": "~6.10.2", + "protobufjs": "~6.11.3", "xstream": "^11.14.0" } }, - "node_modules/@cosmjs/stargate/node_modules/@types/node": { - "version": "13.13.52", - "resolved": "https://registry.npmjs.org/@types/node/-/node-13.13.52.tgz", - "integrity": "sha512-s3nugnZumCC//n4moGGe6tkNMyYEdaDBitVjwPxXmR5lnMG5dHePinH2EdxkG3Rh1ghFHHixAG4NJhpJW1rthQ==" - }, - "node_modules/@cosmjs/stargate/node_modules/protobufjs": { - "version": "6.10.3", - "resolved": "https://registry.npmjs.org/protobufjs/-/protobufjs-6.10.3.tgz", - "integrity": "sha512-yvAslS0hNdBhlSKckI4R1l7wunVilX66uvrjzE4MimiAt7/qw1nLpMhZrn/ObuUTM/c3Xnfl01LYMdcSJe6dwg==", - "hasInstallScript": true, - "dependencies": { - "@protobufjs/aspromise": "^1.1.2", - "@protobufjs/base64": "^1.1.2", - "@protobufjs/codegen": "^2.0.4", - "@protobufjs/eventemitter": "^1.1.0", - "@protobufjs/fetch": "^1.1.0", - "@protobufjs/float": "^1.0.2", - "@protobufjs/inquire": "^1.1.0", - "@protobufjs/path": "^1.1.2", - "@protobufjs/pool": "^1.1.0", - "@protobufjs/utf8": "^1.1.0", - "@types/long": "^4.0.1", - "@types/node": "^13.7.0", - "long": "^4.0.0" - }, - "bin": { - "pbjs": "bin/pbjs", - "pbts": "bin/pbts" - } - }, "node_modules/@cosmjs/stream": { - "version": "0.27.1", - "resolved": "https://registry.npmjs.org/@cosmjs/stream/-/stream-0.27.1.tgz", - "integrity": "sha512-cEyEAVfXEyuUpKYBeEJrOj8Dp/c+M6a0oGJHxvDdhP5gSsaeCPgQXrh7qZFBiUfu3Brmqd+e/bKZm+068l9bBw==", + "version": "0.31.3", + "license": "Apache-2.0", "dependencies": { "xstream": "^11.14.0" } }, "node_modules/@cosmjs/tendermint-rpc": { - "version": "0.27.1", - "resolved": "https://registry.npmjs.org/@cosmjs/tendermint-rpc/-/tendermint-rpc-0.27.1.tgz", - "integrity": "sha512-eN1NyBYIiFutDNleEaTfvIJ3S3KA1gP45UHaLhSETm8KyiaUqg/b0Mj6sp7J3h4BhgwLq2zn/TDtIn0k5luedg==", - "dependencies": { - "@cosmjs/crypto": "0.27.1", - "@cosmjs/encoding": "0.27.1", - "@cosmjs/json-rpc": "0.27.1", - "@cosmjs/math": "0.27.1", - "@cosmjs/socket": "0.27.1", - "@cosmjs/stream": "0.27.1", + "version": "0.31.3", + "license": "Apache-2.0", + "dependencies": { + "@cosmjs/crypto": "^0.31.3", + "@cosmjs/encoding": "^0.31.3", + "@cosmjs/json-rpc": "^0.31.3", + "@cosmjs/math": "^0.31.3", + "@cosmjs/socket": "^0.31.3", + "@cosmjs/stream": "^0.31.3", + "@cosmjs/utils": "^0.31.3", "axios": "^0.21.2", "readonly-date": "^1.0.0", "xstream": "^11.14.0" @@ -1077,41 +946,19 @@ }, "node_modules/@cosmjs/tendermint-rpc/node_modules/axios": { "version": "0.21.4", - "resolved": "https://registry.npmjs.org/axios/-/axios-0.21.4.tgz", - "integrity": "sha512-ut5vewkiu8jjGBdqpM44XxjuCjq9LAKeHVmoVfHVzy8eHgxxq8SbAVQNovDA8mVi05kP0Ea/n/UzcSHcTJQfNg==", + "license": "MIT", "dependencies": { "follow-redirects": "^1.14.0" } }, - "node_modules/@cosmjs/tendermint-rpc/node_modules/follow-redirects": { - "version": "1.15.2", - "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.15.2.tgz", - "integrity": "sha512-VQLG33o04KaQ8uYi2tVNbdrWp1QWxNNea+nmIB4EVM28v0hmP17z7aG1+wAkNzVq4KeXTq3221ye5qTJP91JwA==", - "funding": [ - { - "type": "individual", - "url": "https://github.com/sponsors/RubenVerborgh" - } - ], - "engines": { - "node": ">=4.0" - }, - "peerDependenciesMeta": { - "debug": { - "optional": true - } - } - }, "node_modules/@cosmjs/utils": { - "version": "0.27.1", - "resolved": "https://registry.npmjs.org/@cosmjs/utils/-/utils-0.27.1.tgz", - "integrity": "sha512-VG7QPDiMUzVPxRdJahDV8PXxVdnuAHiIuG56hldV4yPnOz/si/DLNd7VAUUA5923b6jS1Hhev0Hr6AhEkcxBMg==" + "version": "0.31.3", + "license": "Apache-2.0" }, "node_modules/@cspotcode/source-map-support": { "version": "0.8.1", - "resolved": "https://registry.npmjs.org/@cspotcode/source-map-support/-/source-map-support-0.8.1.tgz", - "integrity": "sha512-IchNf6dN4tHoMFIn/7OE8LWZ19Y6q/67Bmf6vnGREv8RSbBVb9LPJxEcnwrcwX6ixSvaiGoomAUvu4YSxXrVgw==", "dev": true, + "license": "MIT", "dependencies": { "@jridgewell/trace-mapping": "0.3.9" }, @@ -1121,9 +968,8 @@ }, "node_modules/@cspotcode/source-map-support/node_modules/@jridgewell/trace-mapping": { "version": "0.3.9", - "resolved": "https://registry.npmjs.org/@jridgewell/trace-mapping/-/trace-mapping-0.3.9.tgz", - "integrity": "sha512-3Belt6tdc8bPgAtbcmdtNJlirVoTmEb5e2gC94PnkwEW9jI6CAHUeoG85tjWP5WquqfavoMtMwiG4P926ZKKuQ==", "dev": true, + "license": "MIT", "dependencies": { "@jridgewell/resolve-uri": "^3.0.3", "@jridgewell/sourcemap-codec": "^1.4.10" @@ -1131,8 +977,7 @@ }, "node_modules/@digitalbazaar/ed25519-signature-2020": { "version": "3.0.0", - "resolved": "https://registry.npmjs.org/@digitalbazaar/ed25519-signature-2020/-/ed25519-signature-2020-3.0.0.tgz", - "integrity": "sha512-Va4mJlklWe7F0LwFwcZmJszeSYkWkxnsYXpmwgqPiJyxhnp0dgOPJxWRWoxsc1809mBgAxxeD+KGnjx6oFYf2Q==", + "license": "BSD-3-Clause", "dependencies": { "@digitalbazaar/ed25519-verification-key-2020": "^3.0.0", "base58-universal": "^1.0.0", @@ -1147,8 +992,7 @@ }, "node_modules/@digitalbazaar/ed25519-verification-key-2018": { "version": "3.2.0", - "resolved": "https://registry.npmjs.org/@digitalbazaar/ed25519-verification-key-2018/-/ed25519-verification-key-2018-3.2.0.tgz", - "integrity": "sha512-j/jTA6SFXpiMofoCnhC4iD6NPBeT9b4/JiC8uM+1sVMb2dqGQjTxv7Ld5oZqLsLf6idvd5V42X3zrezRJ9J8AA==", + "license": "BSD-3-Clause", "dependencies": { "@noble/ed25519": "^1.6.0", "base58-universal": "^1.0.0", @@ -1161,16 +1005,14 @@ }, "node_modules/@digitalbazaar/ed25519-verification-key-2018/node_modules/crypto-ld": { "version": "5.1.0", - "resolved": "https://registry.npmjs.org/crypto-ld/-/crypto-ld-5.1.0.tgz", - "integrity": "sha512-Dy1QoQzj+2K6UlGZ9l34cPp+g/YHOd+r3/DXXQTnnz5btGb0vqDlkZBn+icYmwntEmW0bvGVwFWvcwZSbk1EEQ==", + "license": "BSD-3-Clause", "engines": { "node": ">=8.3.0" } }, "node_modules/@digitalbazaar/ed25519-verification-key-2020": { "version": "3.3.0", - "resolved": "https://registry.npmjs.org/@digitalbazaar/ed25519-verification-key-2020/-/ed25519-verification-key-2020-3.3.0.tgz", - "integrity": "sha512-/euFk/BNnwLIbaWxHW76PW26emuGjaJ8vbTMgdcIcx3TbDE1dsAbmLSzE9122KLT59CLLfOXvl5uA9xa14VRqQ==", + "license": "BSD-3-Clause", "dependencies": { "@noble/ed25519": "^1.6.0", "base58-universal": "^1.0.0", @@ -1184,16 +1026,14 @@ }, "node_modules/@digitalbazaar/ed25519-verification-key-2020/node_modules/crypto-ld": { "version": "5.1.0", - "resolved": "https://registry.npmjs.org/crypto-ld/-/crypto-ld-5.1.0.tgz", - "integrity": "sha512-Dy1QoQzj+2K6UlGZ9l34cPp+g/YHOd+r3/DXXQTnnz5btGb0vqDlkZBn+icYmwntEmW0bvGVwFWvcwZSbk1EEQ==", + "license": "BSD-3-Clause", "engines": { "node": ">=8.3.0" } }, "node_modules/@digitalbazaar/http-client": { "version": "3.4.1", - "resolved": "https://registry.npmjs.org/@digitalbazaar/http-client/-/http-client-3.4.1.tgz", - "integrity": "sha512-Ahk1N+s7urkgj7WvvUND5f8GiWEPfUw0D41hdElaqLgu8wZScI8gdI0q+qWw5N1d35x7GCRH2uk9mi+Uzo9M3g==", + "license": "BSD-3-Clause", "dependencies": { "ky": "^0.33.3", "ky-universal": "^0.11.0", @@ -1205,9 +1045,8 @@ }, "node_modules/@eslint-community/eslint-utils": { "version": "4.4.0", - "resolved": "https://registry.npmjs.org/@eslint-community/eslint-utils/-/eslint-utils-4.4.0.tgz", - "integrity": "sha512-1/sA4dwrzBAyeUoQ6oxahHKmrZvsnLCg4RfxW3ZFGGmQkSNQPFNLV9CUEFQP1x9EYXHTo5p6xdhZM1Ne9p/AfA==", "dev": true, + "license": "MIT", "dependencies": { "eslint-visitor-keys": "^3.3.0" }, @@ -1219,19 +1058,17 @@ } }, "node_modules/@eslint-community/regexpp": { - "version": "4.8.0", - "resolved": "https://registry.npmjs.org/@eslint-community/regexpp/-/regexpp-4.8.0.tgz", - "integrity": "sha512-JylOEEzDiOryeUnFbQz+oViCXS0KsvR1mvHkoMiu5+UiBvy+RYX7tzlIIIEstF/gVa2tj9AQXk3dgnxv6KxhFg==", + "version": "4.10.0", "dev": true, + "license": "MIT", "engines": { "node": "^12.0.0 || ^14.0.0 || >=16.0.0" } }, "node_modules/@eslint/eslintrc": { "version": "0.4.3", - "resolved": "https://registry.npmjs.org/@eslint/eslintrc/-/eslintrc-0.4.3.tgz", - "integrity": "sha512-J6KFFz5QCYUJq3pf0mjEcCJVERbzv71PUIDczuh9JkwGEzced6CO5ADLHB1rbf/+oPBtoPfMYNOpGDzCANlbXw==", "dev": true, + "license": "MIT", "dependencies": { "ajv": "^6.12.4", "debug": "^4.1.1", @@ -1249,26 +1086,23 @@ }, "node_modules/@eslint/eslintrc/node_modules/ignore": { "version": "4.0.6", - "resolved": "https://registry.npmjs.org/ignore/-/ignore-4.0.6.tgz", - "integrity": "sha512-cyFDKrqc/YdcWFniJhzI42+AzS+gNwmUzOSFcRCQYwySuBBBy/KjuxWLZ/FHEH6Moq1NizMOBWyTcv8O4OZIMg==", "dev": true, + "license": "MIT", "engines": { "node": ">= 4" } }, "node_modules/@ethereumjs/common": { - "version": "2.5.0", - "resolved": "https://registry.npmjs.org/@ethereumjs/common/-/common-2.5.0.tgz", - "integrity": "sha512-DEHjW6e38o+JmB/NO3GZBpW4lpaiBpkFgXF6jLcJ6gETBYpEyaA5nTimsWBUJR3Vmtm/didUEbNjajskugZORg==", + "version": "2.6.5", + "license": "MIT", "dependencies": { "crc-32": "^1.2.0", - "ethereumjs-util": "^7.1.1" + "ethereumjs-util": "^7.1.5" } }, "node_modules/@ethereumjs/common/node_modules/ethereumjs-util": { "version": "7.1.5", - "resolved": "https://registry.npmjs.org/ethereumjs-util/-/ethereumjs-util-7.1.5.tgz", - "integrity": "sha512-SDl5kKrQAudFBUe5OJM9Ac6WmMyYmXX/6sTmLZ3ffG2eY6ZIGBes3pEDxNN6V72WyOw4CPD5RomKdsa8DAAwLg==", + "license": "MPL-2.0", "dependencies": { "@types/bn.js": "^5.1.0", "bn.js": "^5.1.2", @@ -1282,8 +1116,7 @@ }, "node_modules/@ethereumjs/rlp": { "version": "4.0.1", - "resolved": "https://registry.npmjs.org/@ethereumjs/rlp/-/rlp-4.0.1.tgz", - "integrity": "sha512-tqsQiBQDQdmPWE1xkkBq4rlSW5QZpLOUJ5RJh2/9fug+q9tnUhuZoVLk7s0scUIKTOzEtR72DFBXI4WiZcMpvw==", + "license": "MPL-2.0", "bin": { "rlp": "bin/rlp" }, @@ -1292,18 +1125,16 @@ } }, "node_modules/@ethereumjs/tx": { - "version": "3.3.2", - "resolved": "https://registry.npmjs.org/@ethereumjs/tx/-/tx-3.3.2.tgz", - "integrity": "sha512-6AaJhwg4ucmwTvw/1qLaZUX5miWrwZ4nLOUsKyb/HtzS3BMw/CasKhdi1ims9mBKeK9sOJCH4qGKOBGyJCeeog==", + "version": "3.5.2", + "license": "MPL-2.0", "dependencies": { - "@ethereumjs/common": "^2.5.0", - "ethereumjs-util": "^7.1.2" + "@ethereumjs/common": "^2.6.4", + "ethereumjs-util": "^7.1.5" } }, "node_modules/@ethereumjs/tx/node_modules/ethereumjs-util": { "version": "7.1.5", - "resolved": "https://registry.npmjs.org/ethereumjs-util/-/ethereumjs-util-7.1.5.tgz", - "integrity": "sha512-SDl5kKrQAudFBUe5OJM9Ac6WmMyYmXX/6sTmLZ3ffG2eY6ZIGBes3pEDxNN6V72WyOw4CPD5RomKdsa8DAAwLg==", + "license": "MPL-2.0", "dependencies": { "@types/bn.js": "^5.1.0", "bn.js": "^5.1.2", @@ -1317,8 +1148,7 @@ }, "node_modules/@ethereumjs/util": { "version": "8.1.0", - "resolved": "https://registry.npmjs.org/@ethereumjs/util/-/util-8.1.0.tgz", - "integrity": "sha512-zQ0IqbdX8FZ9aw11vP+dZkKDkS+kgIvQPHnSAXzP9pLu+Rfu3D3XEeLbicvoXJTYnhZiPmsZUxgdzXwNKxRPbA==", + "license": "MPL-2.0", "dependencies": { "@ethereumjs/rlp": "^4.0.1", "ethereum-cryptography": "^2.0.0", @@ -1328,10 +1158,19 @@ "node": ">=14" } }, + "node_modules/@ethereumjs/util/node_modules/@noble/curves": { + "version": "1.1.0", + "license": "MIT", + "dependencies": { + "@noble/hashes": "1.3.1" + }, + "funding": { + "url": "https://paulmillr.com/funding/" + } + }, "node_modules/@ethereumjs/util/node_modules/@noble/hashes": { "version": "1.3.1", - "resolved": "https://registry.npmjs.org/@noble/hashes/-/hashes-1.3.1.tgz", - "integrity": "sha512-EbqwksQwz9xDRGfDST86whPBgM65E0OH/pCgqW0GBVzO22bNE+NuIbeTb714+IfSjU3aRk47EUvXIb5bTsenKA==", + "license": "MIT", "engines": { "node": ">= 16" }, @@ -1341,8 +1180,7 @@ }, "node_modules/@ethereumjs/util/node_modules/ethereum-cryptography": { "version": "2.1.2", - "resolved": "https://registry.npmjs.org/ethereum-cryptography/-/ethereum-cryptography-2.1.2.tgz", - "integrity": "sha512-Z5Ba0T0ImZ8fqXrJbpHcbpAvIswRte2wGNR/KePnu8GbbvgJ47lMxT/ZZPG6i9Jaht4azPDop4HaM00J0J59ug==", + "license": "MIT", "dependencies": { "@noble/curves": "1.1.0", "@noble/hashes": "1.3.1", @@ -1352,8 +1190,6 @@ }, "node_modules/@ethersproject/abi": { "version": "5.7.0", - "resolved": "https://registry.npmjs.org/@ethersproject/abi/-/abi-5.7.0.tgz", - "integrity": "sha512-351ktp42TiRcYB3H1OP8yajPeAQstMW/yCFokj/AthP9bLHzQFPlOrxOcwYEDkUAICmOHljvN4K39OMTMUa9RA==", "funding": [ { "type": "individual", @@ -1364,6 +1200,7 @@ "url": "https://www.buymeacoffee.com/ricmoo" } ], + "license": "MIT", "dependencies": { "@ethersproject/address": "^5.7.0", "@ethersproject/bignumber": "^5.7.0", @@ -1378,8 +1215,6 @@ }, "node_modules/@ethersproject/abstract-provider": { "version": "5.7.0", - "resolved": "https://registry.npmjs.org/@ethersproject/abstract-provider/-/abstract-provider-5.7.0.tgz", - "integrity": "sha512-R41c9UkchKCpAqStMYUpdunjo3pkEvZC3FAwZn5S5MGbXoMQOHIdHItezTETxAO5bevtMApSyEhn9+CHcDsWBw==", "funding": [ { "type": "individual", @@ -1390,6 +1225,7 @@ "url": "https://www.buymeacoffee.com/ricmoo" } ], + "license": "MIT", "dependencies": { "@ethersproject/bignumber": "^5.7.0", "@ethersproject/bytes": "^5.7.0", @@ -1402,8 +1238,6 @@ }, "node_modules/@ethersproject/abstract-signer": { "version": "5.7.0", - "resolved": "https://registry.npmjs.org/@ethersproject/abstract-signer/-/abstract-signer-5.7.0.tgz", - "integrity": "sha512-a16V8bq1/Cz+TGCkE2OPMTOUDLS3grCpdjoJCYNnVBbdYEMSgKrU0+B90s8b6H+ByYTBZN7a3g76jdIJi7UfKQ==", "funding": [ { "type": "individual", @@ -1414,6 +1248,7 @@ "url": "https://www.buymeacoffee.com/ricmoo" } ], + "license": "MIT", "dependencies": { "@ethersproject/abstract-provider": "^5.7.0", "@ethersproject/bignumber": "^5.7.0", @@ -1424,8 +1259,6 @@ }, "node_modules/@ethersproject/address": { "version": "5.7.0", - "resolved": "https://registry.npmjs.org/@ethersproject/address/-/address-5.7.0.tgz", - "integrity": "sha512-9wYhYt7aghVGo758POM5nqcOMaE168Q6aRLJZwUmiqSrAungkG74gSSeKEIR7ukixesdRZGPgVqme6vmxs1fkA==", "funding": [ { "type": "individual", @@ -1436,6 +1269,7 @@ "url": "https://www.buymeacoffee.com/ricmoo" } ], + "license": "MIT", "dependencies": { "@ethersproject/bignumber": "^5.7.0", "@ethersproject/bytes": "^5.7.0", @@ -1446,8 +1280,6 @@ }, "node_modules/@ethersproject/base64": { "version": "5.7.0", - "resolved": "https://registry.npmjs.org/@ethersproject/base64/-/base64-5.7.0.tgz", - "integrity": "sha512-Dr8tcHt2mEbsZr/mwTPIQAf3Ai0Bks/7gTw9dSqk1mQvhW3XvRlmDJr/4n+wg1JmCl16NZue17CDh8xb/vZ0sQ==", "funding": [ { "type": "individual", @@ -1458,14 +1290,13 @@ "url": "https://www.buymeacoffee.com/ricmoo" } ], + "license": "MIT", "dependencies": { "@ethersproject/bytes": "^5.7.0" } }, "node_modules/@ethersproject/bignumber": { "version": "5.7.0", - "resolved": "https://registry.npmjs.org/@ethersproject/bignumber/-/bignumber-5.7.0.tgz", - "integrity": "sha512-n1CAdIHRWjSucQO3MC1zPSVgV/6dy/fjL9pMrPP9peL+QxEg9wOsVqwD4+818B6LUEtaXzVHQiuivzRoxPxUGw==", "funding": [ { "type": "individual", @@ -1476,6 +1307,7 @@ "url": "https://www.buymeacoffee.com/ricmoo" } ], + "license": "MIT", "dependencies": { "@ethersproject/bytes": "^5.7.0", "@ethersproject/logger": "^5.7.0", @@ -1484,8 +1316,6 @@ }, "node_modules/@ethersproject/bytes": { "version": "5.7.0", - "resolved": "https://registry.npmjs.org/@ethersproject/bytes/-/bytes-5.7.0.tgz", - "integrity": "sha512-nsbxwgFXWh9NyYWo+U8atvmMsSdKJprTcICAkvbBffT75qDocbuggBU0SJiVK2MuTrp0q+xvLkTnGMPK1+uA9A==", "funding": [ { "type": "individual", @@ -1496,14 +1326,13 @@ "url": "https://www.buymeacoffee.com/ricmoo" } ], + "license": "MIT", "dependencies": { "@ethersproject/logger": "^5.7.0" } }, "node_modules/@ethersproject/constants": { "version": "5.7.0", - "resolved": "https://registry.npmjs.org/@ethersproject/constants/-/constants-5.7.0.tgz", - "integrity": "sha512-DHI+y5dBNvkpYUMiRQyxRBYBefZkJfo70VUkUAsRjcPs47muV9evftfZ0PJVCXYbAiCgght0DtcF9srFQmIgWA==", "funding": [ { "type": "individual", @@ -1514,14 +1343,13 @@ "url": "https://www.buymeacoffee.com/ricmoo" } ], + "license": "MIT", "dependencies": { "@ethersproject/bignumber": "^5.7.0" } }, "node_modules/@ethersproject/hash": { "version": "5.7.0", - "resolved": "https://registry.npmjs.org/@ethersproject/hash/-/hash-5.7.0.tgz", - "integrity": "sha512-qX5WrQfnah1EFnO5zJv1v46a8HW0+E5xuBBDTwMFZLuVTx0tbU2kkx15NqdjxecrLGatQN9FGQKpb1FKdHCt+g==", "funding": [ { "type": "individual", @@ -1532,6 +1360,7 @@ "url": "https://www.buymeacoffee.com/ricmoo" } ], + "license": "MIT", "dependencies": { "@ethersproject/abstract-signer": "^5.7.0", "@ethersproject/address": "^5.7.0", @@ -1546,8 +1375,6 @@ }, "node_modules/@ethersproject/keccak256": { "version": "5.7.0", - "resolved": "https://registry.npmjs.org/@ethersproject/keccak256/-/keccak256-5.7.0.tgz", - "integrity": "sha512-2UcPboeL/iW+pSg6vZ6ydF8tCnv3Iu/8tUmLLzWWGzxWKFFqOBQFLo6uLUv6BDrLgCDfN28RJ/wtByx+jZ4KBg==", "funding": [ { "type": "individual", @@ -1558,6 +1385,7 @@ "url": "https://www.buymeacoffee.com/ricmoo" } ], + "license": "MIT", "dependencies": { "@ethersproject/bytes": "^5.7.0", "js-sha3": "0.8.0" @@ -1565,8 +1393,6 @@ }, "node_modules/@ethersproject/logger": { "version": "5.7.0", - "resolved": "https://registry.npmjs.org/@ethersproject/logger/-/logger-5.7.0.tgz", - "integrity": "sha512-0odtFdXu/XHtjQXJYA3u9G0G8btm0ND5Cu8M7i5vhEcE8/HmF4Lbdqanwyv4uQTr2tx6b7fQRmgLrsnpQlmnig==", "funding": [ { "type": "individual", @@ -1576,12 +1402,11 @@ "type": "individual", "url": "https://www.buymeacoffee.com/ricmoo" } - ] + ], + "license": "MIT" }, "node_modules/@ethersproject/networks": { "version": "5.7.1", - "resolved": "https://registry.npmjs.org/@ethersproject/networks/-/networks-5.7.1.tgz", - "integrity": "sha512-n/MufjFYv3yFcUyfhnXotyDlNdFb7onmkSy8aQERi2PjNcnWQ66xXxa3XlS8nCcA8aJKJjIIMNJTC7tu80GwpQ==", "funding": [ { "type": "individual", @@ -1592,14 +1417,13 @@ "url": "https://www.buymeacoffee.com/ricmoo" } ], + "license": "MIT", "dependencies": { "@ethersproject/logger": "^5.7.0" } }, "node_modules/@ethersproject/properties": { "version": "5.7.0", - "resolved": "https://registry.npmjs.org/@ethersproject/properties/-/properties-5.7.0.tgz", - "integrity": "sha512-J87jy8suntrAkIZtecpxEPxY//szqr1mlBaYlQ0r4RCaiD2hjheqF9s1LVE8vVuJCXisjIP+JgtK/Do54ej4Sw==", "funding": [ { "type": "individual", @@ -1610,14 +1434,13 @@ "url": "https://www.buymeacoffee.com/ricmoo" } ], + "license": "MIT", "dependencies": { "@ethersproject/logger": "^5.7.0" } }, "node_modules/@ethersproject/rlp": { "version": "5.7.0", - "resolved": "https://registry.npmjs.org/@ethersproject/rlp/-/rlp-5.7.0.tgz", - "integrity": "sha512-rBxzX2vK8mVF7b0Tol44t5Tb8gomOHkj5guL+HhzQ1yBh/ydjGnpw6at+X6Iw0Kp3OzzzkcKp8N9r0W4kYSs9w==", "funding": [ { "type": "individual", @@ -1628,6 +1451,7 @@ "url": "https://www.buymeacoffee.com/ricmoo" } ], + "license": "MIT", "dependencies": { "@ethersproject/bytes": "^5.7.0", "@ethersproject/logger": "^5.7.0" @@ -1635,8 +1459,6 @@ }, "node_modules/@ethersproject/signing-key": { "version": "5.7.0", - "resolved": "https://registry.npmjs.org/@ethersproject/signing-key/-/signing-key-5.7.0.tgz", - "integrity": "sha512-MZdy2nL3wO0u7gkB4nA/pEf8lu1TlFswPNmy8AiYkfKTdO6eXBJyUdmHO/ehm/htHw9K/qF8ujnTyUAD+Ry54Q==", "funding": [ { "type": "individual", @@ -1647,6 +1469,7 @@ "url": "https://www.buymeacoffee.com/ricmoo" } ], + "license": "MIT", "dependencies": { "@ethersproject/bytes": "^5.7.0", "@ethersproject/logger": "^5.7.0", @@ -1658,8 +1481,6 @@ }, "node_modules/@ethersproject/strings": { "version": "5.7.0", - "resolved": "https://registry.npmjs.org/@ethersproject/strings/-/strings-5.7.0.tgz", - "integrity": "sha512-/9nu+lj0YswRNSH0NXYqrh8775XNyEdUQAuf3f+SmOrnVewcJ5SBNAjF7lpgehKi4abvNNXyf+HX86czCdJ8Mg==", "funding": [ { "type": "individual", @@ -1670,6 +1491,7 @@ "url": "https://www.buymeacoffee.com/ricmoo" } ], + "license": "MIT", "dependencies": { "@ethersproject/bytes": "^5.7.0", "@ethersproject/constants": "^5.7.0", @@ -1678,8 +1500,6 @@ }, "node_modules/@ethersproject/transactions": { "version": "5.7.0", - "resolved": "https://registry.npmjs.org/@ethersproject/transactions/-/transactions-5.7.0.tgz", - "integrity": "sha512-kmcNicCp1lp8qanMTC3RIikGgoJ80ztTyvtsFvCYpSCfkjhD0jZ2LOrnbcuxuToLIUYYf+4XwD1rP+B/erDIhQ==", "funding": [ { "type": "individual", @@ -1690,6 +1510,7 @@ "url": "https://www.buymeacoffee.com/ricmoo" } ], + "license": "MIT", "dependencies": { "@ethersproject/address": "^5.7.0", "@ethersproject/bignumber": "^5.7.0", @@ -1704,8 +1525,6 @@ }, "node_modules/@ethersproject/web": { "version": "5.7.1", - "resolved": "https://registry.npmjs.org/@ethersproject/web/-/web-5.7.1.tgz", - "integrity": "sha512-Gueu8lSvyjBWL4cYsWsjh6MtMwM0+H4HvqFPZfB6dV8ctbP9zFAO73VG1cMWae0FLPCtz0peKPpZY8/ugJJX2w==", "funding": [ { "type": "individual", @@ -1716,6 +1535,7 @@ "url": "https://www.buymeacoffee.com/ricmoo" } ], + "license": "MIT", "dependencies": { "@ethersproject/base64": "^5.7.0", "@ethersproject/bytes": "^5.7.0", @@ -1724,11 +1544,17 @@ "@ethersproject/strings": "^5.7.0" } }, + "node_modules/@fastify/busboy": { + "version": "2.1.0", + "license": "MIT", + "engines": { + "node": ">=14" + } + }, "node_modules/@humanwhocodes/config-array": { "version": "0.5.0", - "resolved": "https://registry.npmjs.org/@humanwhocodes/config-array/-/config-array-0.5.0.tgz", - "integrity": "sha512-FagtKFz74XrTl7y6HCzQpwDfXP0yhxe9lHLD1UZxjvZIcbyRz8zTFF/yYNfSfzU414eDwZ1SrO0Qvtyf+wFMQg==", "dev": true, + "license": "Apache-2.0", "dependencies": { "@humanwhocodes/object-schema": "^1.2.0", "debug": "^4.1.1", @@ -1740,15 +1566,38 @@ }, "node_modules/@humanwhocodes/object-schema": { "version": "1.2.1", - "resolved": "https://registry.npmjs.org/@humanwhocodes/object-schema/-/object-schema-1.2.1.tgz", - "integrity": "sha512-ZnQMnLV4e7hDlUvw8H+U8ASL02SS2Gn6+9Ac3wGGLIe7+je2AeAOxPY+izIPJDfFDb7eDjev0Us8MO1iFRN8hA==", - "dev": true + "dev": true, + "license": "BSD-3-Clause" + }, + "node_modules/@iden3/js-crypto": { + "version": "1.0.3", + "license": "AGPL-3.0" + }, + "node_modules/@iden3/js-jsonld-merklization": { + "version": "1.1.2", + "license": "AGPL-3.0", + "dependencies": { + "@js-temporal/polyfill": "0.4.4", + "jsonld": "8.3.1", + "n3": "1.17.1" + }, + "peerDependencies": { + "@iden3/js-crypto": "1.0.3", + "@iden3/js-merkletree": "1.1.2" + } + }, + "node_modules/@iden3/js-merkletree": { + "version": "1.1.2", + "license": "AGPL-3.0", + "peerDependencies": { + "@iden3/js-crypto": "1.0.3", + "idb-keyval": "^6.2.0" + } }, "node_modules/@istanbuljs/load-nyc-config": { "version": "1.1.0", - "resolved": "https://registry.npmjs.org/@istanbuljs/load-nyc-config/-/load-nyc-config-1.1.0.tgz", - "integrity": "sha512-VjeHSlIzpv/NyD3N0YuHfXOPDIixcA1q2ZV98wsMqcYlPmv2n3Yb2lYP9XMElnaFVXg5A7YLTeLu6V84uQDjmQ==", "dev": true, + "license": "ISC", "dependencies": { "camelcase": "^5.3.1", "find-up": "^4.1.0", @@ -1762,27 +1611,24 @@ }, "node_modules/@istanbuljs/load-nyc-config/node_modules/resolve-from": { "version": "5.0.0", - "resolved": "https://registry.npmjs.org/resolve-from/-/resolve-from-5.0.0.tgz", - "integrity": "sha512-qYg9KP24dD5qka9J47d0aVky0N+b4fTU89LN9iDnjB5waksiC49rvMB0PrUJQGoTmH50XPiqOvAjDfaijGxYZw==", "dev": true, + "license": "MIT", "engines": { "node": ">=8" } }, "node_modules/@istanbuljs/schema": { "version": "0.1.3", - "resolved": "https://registry.npmjs.org/@istanbuljs/schema/-/schema-0.1.3.tgz", - "integrity": "sha512-ZXRY4jNvVgSVQ8DL3LTcakaAtXwTVUxE81hslsyD2AtoXW/wVob10HkOJ1X/pAlcI7D+2YoZKg5do8G/w6RYgA==", "dev": true, + "license": "MIT", "engines": { "node": ">=8" } }, "node_modules/@jest/console": { "version": "28.1.3", - "resolved": "https://registry.npmjs.org/@jest/console/-/console-28.1.3.tgz", - "integrity": "sha512-QPAkP5EwKdK/bxIr6C1I4Vs0rm2nHiANzj/Z5X2JQkrZo6IqvC4ldZ9K95tF0HdidhA8Bo6egxSzUFPYKcEXLw==", "dev": true, + "license": "MIT", "dependencies": { "@jest/types": "^28.1.3", "@types/node": "*", @@ -1797,9 +1643,8 @@ }, "node_modules/@jest/core": { "version": "28.1.3", - "resolved": "https://registry.npmjs.org/@jest/core/-/core-28.1.3.tgz", - "integrity": "sha512-CIKBrlaKOzA7YG19BEqCw3SLIsEwjZkeJzf5bdooVnW4bH5cktqe3JX+G2YV1aK5vP8N9na1IGWFzYaTp6k6NA==", "dev": true, + "license": "MIT", "dependencies": { "@jest/console": "^28.1.3", "@jest/reporters": "^28.1.3", @@ -1845,9 +1690,8 @@ }, "node_modules/@jest/environment": { "version": "28.1.3", - "resolved": "https://registry.npmjs.org/@jest/environment/-/environment-28.1.3.tgz", - "integrity": "sha512-1bf40cMFTEkKyEf585R9Iz1WayDjHoHqvts0XFYEqyKM3cFWDpeMoqKKTAF9LSYQModPUlh8FKptoM2YcMWAXA==", "dev": true, + "license": "MIT", "dependencies": { "@jest/fake-timers": "^28.1.3", "@jest/types": "^28.1.3", @@ -1860,9 +1704,8 @@ }, "node_modules/@jest/expect": { "version": "28.1.3", - "resolved": "https://registry.npmjs.org/@jest/expect/-/expect-28.1.3.tgz", - "integrity": "sha512-lzc8CpUbSoE4dqT0U+g1qODQjBRHPpCPXissXD4mS9+sWQdmmpeJ9zSH1rS1HEkrsMN0fb7nKrJ9giAR1d3wBw==", "dev": true, + "license": "MIT", "dependencies": { "expect": "^28.1.3", "jest-snapshot": "^28.1.3" @@ -1873,9 +1716,8 @@ }, "node_modules/@jest/expect-utils": { "version": "28.1.3", - "resolved": "https://registry.npmjs.org/@jest/expect-utils/-/expect-utils-28.1.3.tgz", - "integrity": "sha512-wvbi9LUrHJLn3NlDW6wF2hvIMtd4JUl2QNVrjq+IBSHirgfrR3o9RnVtxzdEGO2n9JyIWwHnLfby5KzqBGg2YA==", "dev": true, + "license": "MIT", "dependencies": { "jest-get-type": "^28.0.2" }, @@ -1885,9 +1727,8 @@ }, "node_modules/@jest/fake-timers": { "version": "28.1.3", - "resolved": "https://registry.npmjs.org/@jest/fake-timers/-/fake-timers-28.1.3.tgz", - "integrity": "sha512-D/wOkL2POHv52h+ok5Oj/1gOG9HSywdoPtFsRCUmlCILXNn5eIWmcnd3DIiWlJnpGvQtmajqBP95Ei0EimxfLw==", "dev": true, + "license": "MIT", "dependencies": { "@jest/types": "^28.1.3", "@sinonjs/fake-timers": "^9.1.2", @@ -1902,9 +1743,8 @@ }, "node_modules/@jest/globals": { "version": "28.1.3", - "resolved": "https://registry.npmjs.org/@jest/globals/-/globals-28.1.3.tgz", - "integrity": "sha512-XFU4P4phyryCXu1pbcqMO0GSQcYe1IsalYCDzRNyhetyeyxMcIxa11qPNDpVNLeretItNqEmYYQn1UYz/5x1NA==", "dev": true, + "license": "MIT", "dependencies": { "@jest/environment": "^28.1.3", "@jest/expect": "^28.1.3", @@ -1916,9 +1756,8 @@ }, "node_modules/@jest/reporters": { "version": "28.1.3", - "resolved": "https://registry.npmjs.org/@jest/reporters/-/reporters-28.1.3.tgz", - "integrity": "sha512-JuAy7wkxQZVNU/V6g9xKzCGC5LVXx9FDcABKsSXp5MiKPEE2144a/vXTEDoyzjUpZKfVwp08Wqg5A4WfTMAzjg==", "dev": true, + "license": "MIT", "dependencies": { "@bcoe/v8-coverage": "^0.2.3", "@jest/console": "^28.1.3", @@ -1960,9 +1799,8 @@ }, "node_modules/@jest/schemas": { "version": "28.1.3", - "resolved": "https://registry.npmjs.org/@jest/schemas/-/schemas-28.1.3.tgz", - "integrity": "sha512-/l/VWsdt/aBXgjshLWOFyFt3IVdYypu5y2Wn2rOO1un6nkqIn8SLXzgIMYXFyYsRWDyF5EthmKJMIdJvk08grg==", "dev": true, + "license": "MIT", "dependencies": { "@sinclair/typebox": "^0.24.1" }, @@ -1972,9 +1810,8 @@ }, "node_modules/@jest/source-map": { "version": "28.1.2", - "resolved": "https://registry.npmjs.org/@jest/source-map/-/source-map-28.1.2.tgz", - "integrity": "sha512-cV8Lx3BeStJb8ipPHnqVw/IM2VCMWO3crWZzYodSIkxXnRcXJipCdx1JCK0K5MsJJouZQTH73mzf4vgxRaH9ww==", "dev": true, + "license": "MIT", "dependencies": { "@jridgewell/trace-mapping": "^0.3.13", "callsites": "^3.0.0", @@ -1986,9 +1823,8 @@ }, "node_modules/@jest/test-result": { "version": "28.1.3", - "resolved": "https://registry.npmjs.org/@jest/test-result/-/test-result-28.1.3.tgz", - "integrity": "sha512-kZAkxnSE+FqE8YjW8gNuoVkkC9I7S1qmenl8sGcDOLropASP+BkcGKwhXoyqQuGOGeYY0y/ixjrd/iERpEXHNg==", "dev": true, + "license": "MIT", "dependencies": { "@jest/console": "^28.1.3", "@jest/types": "^28.1.3", @@ -2001,9 +1837,8 @@ }, "node_modules/@jest/test-sequencer": { "version": "28.1.3", - "resolved": "https://registry.npmjs.org/@jest/test-sequencer/-/test-sequencer-28.1.3.tgz", - "integrity": "sha512-NIMPEqqa59MWnDi1kvXXpYbqsfQmSJsIbnd85mdVGkiDfQ9WQQTXOLsvISUfonmnBT+w85WEgneCigEEdHDFxw==", "dev": true, + "license": "MIT", "dependencies": { "@jest/test-result": "^28.1.3", "graceful-fs": "^4.2.9", @@ -2016,9 +1851,8 @@ }, "node_modules/@jest/transform": { "version": "28.1.3", - "resolved": "https://registry.npmjs.org/@jest/transform/-/transform-28.1.3.tgz", - "integrity": "sha512-u5dT5di+oFI6hfcLOHGTAfmUxFRrjK+vnaP0kkVow9Md/M7V/MxqQMOz/VV25UZO8pzeA9PjfTpOu6BDuwSPQA==", "dev": true, + "license": "MIT", "dependencies": { "@babel/core": "^7.11.6", "@jest/types": "^28.1.3", @@ -2042,9 +1876,8 @@ }, "node_modules/@jest/types": { "version": "28.1.3", - "resolved": "https://registry.npmjs.org/@jest/types/-/types-28.1.3.tgz", - "integrity": "sha512-RyjiyMUZrKz/c+zlMFO1pm70DcIlST8AeWTkoUdZevew44wcNZQHsEVOiCVtgVnlFFD82FPaXycys58cf2muVQ==", "dev": true, + "license": "MIT", "dependencies": { "@jest/schemas": "^28.1.3", "@types/istanbul-lib-coverage": "^2.0.0", @@ -2059,9 +1892,8 @@ }, "node_modules/@jridgewell/gen-mapping": { "version": "0.3.3", - "resolved": "https://registry.npmjs.org/@jridgewell/gen-mapping/-/gen-mapping-0.3.3.tgz", - "integrity": "sha512-HLhSWOLRi875zjjMG/r+Nv0oCW8umGb0BgEhyX3dDX3egwZtB8PqLnjz3yedt8R5StBrzcg4aBpnh8UA9D1BoQ==", "dev": true, + "license": "MIT", "dependencies": { "@jridgewell/set-array": "^1.0.1", "@jridgewell/sourcemap-codec": "^1.4.10", @@ -2073,53 +1905,62 @@ }, "node_modules/@jridgewell/resolve-uri": { "version": "3.1.1", - "resolved": "https://registry.npmjs.org/@jridgewell/resolve-uri/-/resolve-uri-3.1.1.tgz", - "integrity": "sha512-dSYZh7HhCDtCKm4QakX0xFpsRDqjjtZf/kjI/v3T3Nwt5r8/qz/M19F9ySyOqU94SXBmeG9ttTul+YnR4LOxFA==", "dev": true, + "license": "MIT", "engines": { "node": ">=6.0.0" } }, "node_modules/@jridgewell/set-array": { "version": "1.1.2", - "resolved": "https://registry.npmjs.org/@jridgewell/set-array/-/set-array-1.1.2.tgz", - "integrity": "sha512-xnkseuNADM0gt2bs+BvhO0p78Mk762YnZdsuzFV018NoG1Sj1SCQvpSqa7XUaTam5vAGasABV9qXASMKnFMwMw==", "dev": true, + "license": "MIT", "engines": { "node": ">=6.0.0" } }, "node_modules/@jridgewell/sourcemap-codec": { "version": "1.4.15", - "resolved": "https://registry.npmjs.org/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.4.15.tgz", - "integrity": "sha512-eF2rxCRulEKXHTRiDrDy6erMYWqNw4LPdQ8UQA4huuxaQsVeRPFl2oM8oDGxMFhJUWZf9McpLtJasDDZb/Bpeg==", - "dev": true + "dev": true, + "license": "MIT" }, "node_modules/@jridgewell/trace-mapping": { - "version": "0.3.19", - "resolved": "https://registry.npmjs.org/@jridgewell/trace-mapping/-/trace-mapping-0.3.19.tgz", - "integrity": "sha512-kf37QtfW+Hwx/buWGMPcR60iF9ziHa6r/CZJIHbmcm4+0qrXiVdxegAH0F6yddEVQ7zdkjcGCgCzUu+BcbhQxw==", + "version": "0.3.20", "dev": true, + "license": "MIT", "dependencies": { "@jridgewell/resolve-uri": "^3.1.0", "@jridgewell/sourcemap-codec": "^1.4.14" } }, + "node_modules/@js-temporal/polyfill": { + "version": "0.4.4", + "license": "ISC", + "dependencies": { + "jsbi": "^4.3.0", + "tslib": "^2.4.1" + }, + "engines": { + "node": ">=12" + } + }, + "node_modules/@multiformats/base-x": { + "version": "4.0.1", + "license": "MIT" + }, "node_modules/@noble/curves": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/@noble/curves/-/curves-1.1.0.tgz", - "integrity": "sha512-091oBExgENk/kGj3AZmtBDMpxQPDtxQABR2B9lb1JbVTs6ytdzZNwvhxQ4MWasRNEzlbEH8jCWFCwhF/Obj5AA==", + "version": "1.2.0", + "license": "MIT", "dependencies": { - "@noble/hashes": "1.3.1" + "@noble/hashes": "1.3.2" }, "funding": { "url": "https://paulmillr.com/funding/" } }, "node_modules/@noble/curves/node_modules/@noble/hashes": { - "version": "1.3.1", - "resolved": "https://registry.npmjs.org/@noble/hashes/-/hashes-1.3.1.tgz", - "integrity": "sha512-EbqwksQwz9xDRGfDST86whPBgM65E0OH/pCgqW0GBVzO22bNE+NuIbeTb714+IfSjU3aRk47EUvXIb5bTsenKA==", + "version": "1.3.2", + "license": "MIT", "engines": { "node": ">= 16" }, @@ -2129,19 +1970,17 @@ }, "node_modules/@noble/ed25519": { "version": "1.7.3", - "resolved": "https://registry.npmjs.org/@noble/ed25519/-/ed25519-1.7.3.tgz", - "integrity": "sha512-iR8GBkDt0Q3GyaVcIu7mSsVIqnFbkbRzGLWlvhwunacoLwt4J3swfKhfaM6rN6WY+TBGoYT1GtT1mIh2/jGbRQ==", "funding": [ { "type": "individual", "url": "https://paulmillr.com/funding/" } - ] + ], + "license": "MIT" }, "node_modules/@noble/hashes": { - "version": "1.3.2", - "resolved": "https://registry.npmjs.org/@noble/hashes/-/hashes-1.3.2.tgz", - "integrity": "sha512-MVC8EAQp7MvEcm30KWENFjgR+Mkmf+D189XJTkFIlwohU5hcBbn1ZkKq7KVTi2Hme3PMGF390DaL52beVrIihQ==", + "version": "1.3.3", + "license": "MIT", "engines": { "node": ">= 16" }, @@ -2149,22 +1988,10 @@ "url": "https://paulmillr.com/funding/" } }, - "node_modules/@noble/secp256k1": { - "version": "1.7.1", - "resolved": "https://registry.npmjs.org/@noble/secp256k1/-/secp256k1-1.7.1.tgz", - "integrity": "sha512-hOUk6AyBFmqVrv7k5WAw/LpszxVbj9gGN4JRkIX52fdFAj1UA61KXmZDvqVEm+pOyec3+fIeZB02LYa/pWOArw==", - "funding": [ - { - "type": "individual", - "url": "https://paulmillr.com/funding/" - } - ] - }, "node_modules/@nodelib/fs.scandir": { "version": "2.1.5", - "resolved": "https://registry.npmjs.org/@nodelib/fs.scandir/-/fs.scandir-2.1.5.tgz", - "integrity": "sha512-vq24Bq3ym5HEQm2NKCr3yXDwjc7vTsEThRDnkp2DK9p1uqLR+DHurm/NOTo0KG7HYHU7eppKZj3MyqYuMBf62g==", "dev": true, + "license": "MIT", "dependencies": { "@nodelib/fs.stat": "2.0.5", "run-parallel": "^1.1.9" @@ -2175,18 +2002,16 @@ }, "node_modules/@nodelib/fs.stat": { "version": "2.0.5", - "resolved": "https://registry.npmjs.org/@nodelib/fs.stat/-/fs.stat-2.0.5.tgz", - "integrity": "sha512-RkhPPp2zrqDAQA/2jNhnztcPAlv64XdhIp7a7454A5ovI7Bukxgt7MX7udwAu3zg1DcpPU0rz3VV1SeaqvY4+A==", "dev": true, + "license": "MIT", "engines": { "node": ">= 8" } }, "node_modules/@nodelib/fs.walk": { "version": "1.2.8", - "resolved": "https://registry.npmjs.org/@nodelib/fs.walk/-/fs.walk-1.2.8.tgz", - "integrity": "sha512-oGB+UxlgWcgQkgwo8GcEGwemoTFt3FIO9ababBmaGwXIoBKZ+GTy0pP185beGg7Llih/NSHSV2XAs1lnznocSg==", "dev": true, + "license": "MIT", "dependencies": { "@nodelib/fs.scandir": "2.1.5", "fastq": "^1.6.0" @@ -2197,28 +2022,23 @@ }, "node_modules/@protobufjs/aspromise": { "version": "1.1.2", - "resolved": "https://registry.npmjs.org/@protobufjs/aspromise/-/aspromise-1.1.2.tgz", - "integrity": "sha512-j+gKExEuLmKwvz3OgROXtrJ2UG2x8Ch2YZUxahh+s1F2HZ+wAceUNLkvy6zKCPVRkU++ZWQrdxsUeQXmcg4uoQ==" + "license": "BSD-3-Clause" }, "node_modules/@protobufjs/base64": { "version": "1.1.2", - "resolved": "https://registry.npmjs.org/@protobufjs/base64/-/base64-1.1.2.tgz", - "integrity": "sha512-AZkcAA5vnN/v4PDqKyMR5lx7hZttPDgClv83E//FMNhR2TMcLUhfRUBHCmSl0oi9zMgDDqRUJkSxO3wm85+XLg==" + "license": "BSD-3-Clause" }, "node_modules/@protobufjs/codegen": { "version": "2.0.4", - "resolved": "https://registry.npmjs.org/@protobufjs/codegen/-/codegen-2.0.4.tgz", - "integrity": "sha512-YyFaikqM5sH0ziFZCN3xDC7zeGaB/d0IUb9CATugHWbd1FRFwWwt4ld4OYMPWu5a3Xe01mGAULCdqhMlPl29Jg==" + "license": "BSD-3-Clause" }, "node_modules/@protobufjs/eventemitter": { "version": "1.1.0", - "resolved": "https://registry.npmjs.org/@protobufjs/eventemitter/-/eventemitter-1.1.0.tgz", - "integrity": "sha512-j9ednRT81vYJ9OfVuXG6ERSTdEL1xVsNgqpkxMsbIabzSo3goCjDIveeGv5d03om39ML71RdmrGNjG5SReBP/Q==" + "license": "BSD-3-Clause" }, "node_modules/@protobufjs/fetch": { "version": "1.1.0", - "resolved": "https://registry.npmjs.org/@protobufjs/fetch/-/fetch-1.1.0.tgz", - "integrity": "sha512-lljVXpqXebpsijW71PZaCYeIcE5on1w5DlQy5WH6GLbFryLUrBD4932W/E2BSpfRJWseIL4v/KPgBFxDOIdKpQ==", + "license": "BSD-3-Clause", "dependencies": { "@protobufjs/aspromise": "^1.1.1", "@protobufjs/inquire": "^1.1.0" @@ -2226,41 +2046,34 @@ }, "node_modules/@protobufjs/float": { "version": "1.0.2", - "resolved": "https://registry.npmjs.org/@protobufjs/float/-/float-1.0.2.tgz", - "integrity": "sha512-Ddb+kVXlXst9d+R9PfTIxh1EdNkgoRe5tOX6t01f1lYWOvJnSPDBlG241QLzcyPdoNTsblLUdujGSE4RzrTZGQ==" + "license": "BSD-3-Clause" }, "node_modules/@protobufjs/inquire": { "version": "1.1.0", - "resolved": "https://registry.npmjs.org/@protobufjs/inquire/-/inquire-1.1.0.tgz", - "integrity": "sha512-kdSefcPdruJiFMVSbn801t4vFK7KB/5gd2fYvrxhuJYg8ILrmn9SKSX2tZdV6V+ksulWqS7aXjBcRXl3wHoD9Q==" + "license": "BSD-3-Clause" }, "node_modules/@protobufjs/path": { "version": "1.1.2", - "resolved": "https://registry.npmjs.org/@protobufjs/path/-/path-1.1.2.tgz", - "integrity": "sha512-6JOcJ5Tm08dOHAbdR3GrvP+yUUfkjG5ePsHYczMFLq3ZmMkAD98cDgcT2iA1lJ9NVwFd4tH/iSSoe44YWkltEA==" + "license": "BSD-3-Clause" }, "node_modules/@protobufjs/pool": { "version": "1.1.0", - "resolved": "https://registry.npmjs.org/@protobufjs/pool/-/pool-1.1.0.tgz", - "integrity": "sha512-0kELaGSIDBKvcgS4zkjz1PeddatrjYcmMWOlAuAPwAeccUrPHdUqo/J6LiymHHEiJT5NrF1UVwxY14f+fy4WQw==" + "license": "BSD-3-Clause" }, "node_modules/@protobufjs/utf8": { "version": "1.1.0", - "resolved": "https://registry.npmjs.org/@protobufjs/utf8/-/utf8-1.1.0.tgz", - "integrity": "sha512-Vvn3zZrhQZkkBE8LSuW3em98c0FwgO4nxzv6OdSxPKJIEKY2bGbHn+mhGIPerzI4twdxaP8/0+06HBpwf345Lw==" + "license": "BSD-3-Clause" }, "node_modules/@scure/base": { - "version": "1.1.3", - "resolved": "https://registry.npmjs.org/@scure/base/-/base-1.1.3.tgz", - "integrity": "sha512-/+SgoRjLq7Xlf0CWuLHq2LUZeL/w65kfzAPG5NH9pcmBhs+nunQTn4gvdwgMTIXnt9b2C/1SeL2XiysZEyIC9Q==", + "version": "1.1.5", + "license": "MIT", "funding": { "url": "https://paulmillr.com/funding/" } }, "node_modules/@scure/bip32": { "version": "1.3.1", - "resolved": "https://registry.npmjs.org/@scure/bip32/-/bip32-1.3.1.tgz", - "integrity": "sha512-osvveYtyzdEVbt3OfwwXFr4P2iVBL5u1Q3q4ONBfDY/UpOuXmOlbgwc1xECEboY8wIays8Yt6onaWMUdUbfl0A==", + "license": "MIT", "dependencies": { "@noble/curves": "~1.1.0", "@noble/hashes": "~1.3.1", @@ -2270,10 +2083,29 @@ "url": "https://paulmillr.com/funding/" } }, + "node_modules/@scure/bip32/node_modules/@noble/curves": { + "version": "1.1.0", + "license": "MIT", + "dependencies": { + "@noble/hashes": "1.3.1" + }, + "funding": { + "url": "https://paulmillr.com/funding/" + } + }, + "node_modules/@scure/bip32/node_modules/@noble/hashes": { + "version": "1.3.1", + "license": "MIT", + "engines": { + "node": ">= 16" + }, + "funding": { + "url": "https://paulmillr.com/funding/" + } + }, "node_modules/@scure/bip39": { "version": "1.2.1", - "resolved": "https://registry.npmjs.org/@scure/bip39/-/bip39-1.2.1.tgz", - "integrity": "sha512-Z3/Fsz1yr904dduJD0NpiyRHhRYHdcnyh73FZWiV+/qhWi83wNJ3NWolYqCEN+ZWsUz2TWwajJggcRE9r1zUYg==", + "license": "MIT", "dependencies": { "@noble/hashes": "~1.3.0", "@scure/base": "~1.1.0" @@ -2284,14 +2116,12 @@ }, "node_modules/@sinclair/typebox": { "version": "0.24.51", - "resolved": "https://registry.npmjs.org/@sinclair/typebox/-/typebox-0.24.51.tgz", - "integrity": "sha512-1P1OROm/rdubP5aFDSZQILU0vrLCJ4fvHt6EoqHEM+2D/G5MK3bIaymUKLit8Js9gbns5UyJnkP/TZROLw4tUA==", - "dev": true + "dev": true, + "license": "MIT" }, "node_modules/@sindresorhus/is": { "version": "4.6.0", - "resolved": "https://registry.npmjs.org/@sindresorhus/is/-/is-4.6.0.tgz", - "integrity": "sha512-t09vSN3MdfsyCHoFcTRCH/iUtG7OJ0CsjzB8cjAmKc/va/kIgeDI/TxsigdncE/4be734m0cvIYwNaV4i2XqAw==", + "license": "MIT", "engines": { "node": ">=10" }, @@ -2301,78 +2131,23 @@ }, "node_modules/@sinonjs/commons": { "version": "1.8.6", - "resolved": "https://registry.npmjs.org/@sinonjs/commons/-/commons-1.8.6.tgz", - "integrity": "sha512-Ky+XkAkqPZSm3NLBeUng77EBQl3cmeJhITaGHdYH8kjVB+aun3S4XBRti2zt17mtt0mIUDiNxYeoJm6drVvBJQ==", "dev": true, + "license": "BSD-3-Clause", "dependencies": { "type-detect": "4.0.8" } }, "node_modules/@sinonjs/fake-timers": { "version": "9.1.2", - "resolved": "https://registry.npmjs.org/@sinonjs/fake-timers/-/fake-timers-9.1.2.tgz", - "integrity": "sha512-BPS4ynJW/o92PUR4wgriz2Ud5gpST5vz6GQfMixEDK0Z8ZCUv2M7SkBLykH56T++Xs+8ln9zTGbOvNGIe02/jw==", "dev": true, + "license": "BSD-3-Clause", "dependencies": { "@sinonjs/commons": "^1.7.0" } }, - "node_modules/@stablelib/binary": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/@stablelib/binary/-/binary-1.0.1.tgz", - "integrity": "sha512-ClJWvmL6UBM/wjkvv/7m5VP3GMr9t0osr4yVgLZsLCOz4hGN9gIAFEqnJ0TsSMAN+n840nf2cHZnA5/KFqHC7Q==", - "dependencies": { - "@stablelib/int": "^1.0.1" - } - }, - "node_modules/@stablelib/ed25519": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/@stablelib/ed25519/-/ed25519-1.0.3.tgz", - "integrity": "sha512-puIMWaX9QlRsbhxfDc5i+mNPMY+0TmQEskunY1rZEBPi1acBCVQAhnsk/1Hk50DGPtVsZtAWQg4NHGlVaO9Hqg==", - "dependencies": { - "@stablelib/random": "^1.0.2", - "@stablelib/sha512": "^1.0.1", - "@stablelib/wipe": "^1.0.1" - } - }, - "node_modules/@stablelib/hash": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/@stablelib/hash/-/hash-1.0.1.tgz", - "integrity": "sha512-eTPJc/stDkdtOcrNMZ6mcMK1e6yBbqRBaNW55XA1jU8w/7QdnCF0CmMmOD1m7VSkBR44PWrMHU2l6r8YEQHMgg==" - }, - "node_modules/@stablelib/int": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/@stablelib/int/-/int-1.0.1.tgz", - "integrity": "sha512-byr69X/sDtDiIjIV6m4roLVWnNNlRGzsvxw+agj8CIEazqWGOQp2dTYgQhtyVXV9wpO6WyXRQUzLV/JRNumT2w==" - }, - "node_modules/@stablelib/random": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/@stablelib/random/-/random-1.0.2.tgz", - "integrity": "sha512-rIsE83Xpb7clHPVRlBj8qNe5L8ISQOzjghYQm/dZ7VaM2KHYwMW5adjQjrzTZCchFnNCNhkwtnOBa9HTMJCI8w==", - "dependencies": { - "@stablelib/binary": "^1.0.1", - "@stablelib/wipe": "^1.0.1" - } - }, - "node_modules/@stablelib/sha512": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/@stablelib/sha512/-/sha512-1.0.1.tgz", - "integrity": "sha512-13gl/iawHV9zvDKciLo1fQ8Bgn2Pvf7OV6amaRVKiq3pjQ3UmEpXxWiAfV8tYjUpeZroBxtyrwtdooQT/i3hzw==", - "dependencies": { - "@stablelib/binary": "^1.0.1", - "@stablelib/hash": "^1.0.1", - "@stablelib/wipe": "^1.0.1" - } - }, - "node_modules/@stablelib/wipe": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/@stablelib/wipe/-/wipe-1.0.1.tgz", - "integrity": "sha512-WfqfX/eXGiAd3RJe4VU2snh/ZPwtSjLG4ynQ/vYzvghTh7dHFcI1wl+nrkWG6lGhukOxOsUHfv8dUXr58D0ayg==" - }, "node_modules/@szmarczak/http-timer": { "version": "5.0.1", - "resolved": "https://registry.npmjs.org/@szmarczak/http-timer/-/http-timer-5.0.1.tgz", - "integrity": "sha512-+PmQX0PiAYPMeVYe237LJAYvOMYW1j2rH5YROyS3b4CTVJum34HfRvKvAzozHAQG0TnHNdUfY9nCeUyRAs//cw==", + "license": "MIT", "dependencies": { "defer-to-connect": "^2.0.1" }, @@ -2382,33 +2157,28 @@ }, "node_modules/@tsconfig/node10": { "version": "1.0.9", - "resolved": "https://registry.npmjs.org/@tsconfig/node10/-/node10-1.0.9.tgz", - "integrity": "sha512-jNsYVVxU8v5g43Erja32laIDHXeoNvFEpX33OK4d6hljo3jDhCBDhx5dhCCTMWUojscpAagGiRkBKxpdl9fxqA==", - "dev": true + "dev": true, + "license": "MIT" }, "node_modules/@tsconfig/node12": { "version": "1.0.11", - "resolved": "https://registry.npmjs.org/@tsconfig/node12/-/node12-1.0.11.tgz", - "integrity": "sha512-cqefuRsh12pWyGsIoBKJA9luFu3mRxCA+ORZvA4ktLSzIuCUtWVxGIuXigEwO5/ywWFMZ2QEGKWvkZG1zDMTag==", - "dev": true + "dev": true, + "license": "MIT" }, "node_modules/@tsconfig/node14": { "version": "1.0.3", - "resolved": "https://registry.npmjs.org/@tsconfig/node14/-/node14-1.0.3.tgz", - "integrity": "sha512-ysT8mhdixWK6Hw3i1V2AeRqZ5WfXg1G43mqoYlM2nc6388Fq5jcXyr5mRsqViLx/GJYdoL0bfXD8nmF+Zn/Iow==", - "dev": true + "dev": true, + "license": "MIT" }, "node_modules/@tsconfig/node16": { "version": "1.0.4", - "resolved": "https://registry.npmjs.org/@tsconfig/node16/-/node16-1.0.4.tgz", - "integrity": "sha512-vxhUy4J8lyeyinH7Azl1pdd43GJhZH/tP2weN8TntQblOY+A0XbT8DJk1/oCPuOOyg/Ja757rG0CgHcWC8OfMA==", - "dev": true + "dev": true, + "license": "MIT" }, "node_modules/@types/babel__core": { - "version": "7.20.1", - "resolved": "https://registry.npmjs.org/@types/babel__core/-/babel__core-7.20.1.tgz", - "integrity": "sha512-aACu/U/omhdk15O4Nfb+fHgH/z3QsfQzpnvRZhYhThms83ZnAOZz7zZAWO7mn2yyNQaA4xTO8GLK3uqFU4bYYw==", + "version": "7.20.5", "dev": true, + "license": "MIT", "dependencies": { "@babel/parser": "^7.20.7", "@babel/types": "^7.20.7", @@ -2418,45 +2188,40 @@ } }, "node_modules/@types/babel__generator": { - "version": "7.6.4", - "resolved": "https://registry.npmjs.org/@types/babel__generator/-/babel__generator-7.6.4.tgz", - "integrity": "sha512-tFkciB9j2K755yrTALxD44McOrk+gfpIpvC3sxHjRawj6PfnQxrse4Clq5y/Rq+G3mrBurMax/lG8Qn2t9mSsg==", + "version": "7.6.8", "dev": true, + "license": "MIT", "dependencies": { "@babel/types": "^7.0.0" } }, "node_modules/@types/babel__template": { - "version": "7.4.1", - "resolved": "https://registry.npmjs.org/@types/babel__template/-/babel__template-7.4.1.tgz", - "integrity": "sha512-azBFKemX6kMg5Io+/rdGT0dkGreboUVR0Cdm3fz9QJWpaQGJRQXl7C+6hOTCZcMll7KFyEQpgbYI2lHdsS4U7g==", + "version": "7.4.4", "dev": true, + "license": "MIT", "dependencies": { "@babel/parser": "^7.1.0", "@babel/types": "^7.0.0" } }, "node_modules/@types/babel__traverse": { - "version": "7.20.1", - "resolved": "https://registry.npmjs.org/@types/babel__traverse/-/babel__traverse-7.20.1.tgz", - "integrity": "sha512-MitHFXnhtgwsGZWtT68URpOvLN4EREih1u3QtQiN4VdAxWKRVvGCSvw/Qth0M0Qq3pJpnGOu5JaM/ydK7OGbqg==", + "version": "7.20.4", "dev": true, + "license": "MIT", "dependencies": { "@babel/types": "^7.20.7" } }, "node_modules/@types/bn.js": { - "version": "5.1.1", - "resolved": "https://registry.npmjs.org/@types/bn.js/-/bn.js-5.1.1.tgz", - "integrity": "sha512-qNrYbZqMx0uJAfKnKclPh+dTwK33KfLHYqtyODwd5HnXOjnkhc4qgn3BrK6RWyGZm5+sIFE7Q7Vz6QQtJB7w7g==", + "version": "5.1.5", + "license": "MIT", "dependencies": { "@types/node": "*" } }, "node_modules/@types/cacheable-request": { "version": "6.0.3", - "resolved": "https://registry.npmjs.org/@types/cacheable-request/-/cacheable-request-6.0.3.tgz", - "integrity": "sha512-IQ3EbTzGxIigb1I3qPZc1rWJnH0BmSKv5QYTalEwweFvyBDLSAe24zP0le/hyi7ecGfZVlIVAg4BZqb8WBwKqw==", + "license": "MIT", "dependencies": { "@types/http-cache-semantics": "*", "@types/keyv": "^3.1.4", @@ -2465,141 +2230,121 @@ } }, "node_modules/@types/chai": { - "version": "4.3.6", - "resolved": "https://registry.npmjs.org/@types/chai/-/chai-4.3.6.tgz", - "integrity": "sha512-VOVRLM1mBxIRxydiViqPcKn6MIxZytrbMpd6RJLIWKxUNr3zux8no0Oc7kJx0WAPIitgZ0gkrDS+btlqQpubpw==", - "dev": true + "version": "4.3.11", + "dev": true, + "license": "MIT" }, "node_modules/@types/graceful-fs": { - "version": "4.1.6", - "resolved": "https://registry.npmjs.org/@types/graceful-fs/-/graceful-fs-4.1.6.tgz", - "integrity": "sha512-Sig0SNORX9fdW+bQuTEovKj3uHcUL6LQKbCrrqb1X7J6/ReAbhCXRAhc+SMejhLELFj2QcyuxmUooZ4bt5ReSw==", + "version": "4.1.9", "dev": true, + "license": "MIT", "dependencies": { "@types/node": "*" } }, "node_modules/@types/http-cache-semantics": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/@types/http-cache-semantics/-/http-cache-semantics-4.0.1.tgz", - "integrity": "sha512-SZs7ekbP8CN0txVG2xVRH6EgKmEm31BOxA07vkFaETzZz1xh+cbt8BcI0slpymvwhx5dlFnQG2rTlPVQn+iRPQ==" + "version": "4.0.4", + "license": "MIT" }, "node_modules/@types/istanbul-lib-coverage": { - "version": "2.0.4", - "resolved": "https://registry.npmjs.org/@types/istanbul-lib-coverage/-/istanbul-lib-coverage-2.0.4.tgz", - "integrity": "sha512-z/QT1XN4K4KYuslS23k62yDIDLwLFkzxOuMplDtObz0+y7VqJCaO2o+SPwHCvLFZh7xazvvoor2tA/hPz9ee7g==", - "dev": true + "version": "2.0.6", + "dev": true, + "license": "MIT" }, "node_modules/@types/istanbul-lib-report": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/@types/istanbul-lib-report/-/istanbul-lib-report-3.0.0.tgz", - "integrity": "sha512-plGgXAPfVKFoYfa9NpYDAkseG+g6Jr294RqeqcqDixSbU34MZVJRi/P+7Y8GDpzkEwLaGZZOpKIEmeVZNtKsrg==", + "version": "3.0.3", "dev": true, + "license": "MIT", "dependencies": { "@types/istanbul-lib-coverage": "*" } }, "node_modules/@types/istanbul-reports": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/@types/istanbul-reports/-/istanbul-reports-3.0.1.tgz", - "integrity": "sha512-c3mAZEuK0lvBp8tmuL74XRKn1+y2dcwOUpH7x4WrF6gk1GIgiluDRgMYQtw2OFcBvAJWlt6ASU3tSqxp0Uu0Aw==", + "version": "3.0.4", "dev": true, + "license": "MIT", "dependencies": { "@types/istanbul-lib-report": "*" } }, "node_modules/@types/json-schema": { - "version": "7.0.12", - "resolved": "https://registry.npmjs.org/@types/json-schema/-/json-schema-7.0.12.tgz", - "integrity": "sha512-Hr5Jfhc9eYOQNPYO5WLDq/n4jqijdHNlDXjuAQkkt+mWdQR+XJToOHrsD4cPaMXpn6KO7y2+wM8AZEs8VpBLVA==", - "dev": true + "version": "7.0.15", + "dev": true, + "license": "MIT" }, "node_modules/@types/keyv": { "version": "3.1.4", - "resolved": "https://registry.npmjs.org/@types/keyv/-/keyv-3.1.4.tgz", - "integrity": "sha512-BQ5aZNSCpj7D6K2ksrRCTmKRLEpnPvWDiLPfoGyhZ++8YtiK9d/3DBKPJgry359X/P1PfruyYwvnvwFjuEiEIg==", + "license": "MIT", "dependencies": { "@types/node": "*" } }, "node_modules/@types/long": { "version": "4.0.2", - "resolved": "https://registry.npmjs.org/@types/long/-/long-4.0.2.tgz", - "integrity": "sha512-MqTGEo5bj5t157U6fA/BiDynNkn0YknVdh48CMPkTSpFTVmvao5UQmm7uEF6xBEo7qIMAlY/JSleYaE6VOdpaA==" + "license": "MIT" }, "node_modules/@types/mocha": { - "version": "10.0.1", - "resolved": "https://registry.npmjs.org/@types/mocha/-/mocha-10.0.1.tgz", - "integrity": "sha512-/fvYntiO1GeICvqbQ3doGDIP97vWmvFt83GKguJ6prmQM2iXZfFcq6YE8KteFyRtX2/h5Hf91BYvPodJKFYv5Q==", - "dev": true + "version": "10.0.6", + "dev": true, + "license": "MIT" }, "node_modules/@types/node": { - "version": "14.18.58", - "resolved": "https://registry.npmjs.org/@types/node/-/node-14.18.58.tgz", - "integrity": "sha512-Y8ETZc8afYf6lQ/mVp096phIVsgD/GmDxtm3YaPcc+71jmi/J6zdwbwaUU4JvS56mq6aSfbpkcKhQ5WugrWFPw==" + "version": "14.18.63", + "license": "MIT" }, "node_modules/@types/pbkdf2": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/@types/pbkdf2/-/pbkdf2-3.1.0.tgz", - "integrity": "sha512-Cf63Rv7jCQ0LaL8tNXmEyqTHuIJxRdlS5vMh1mj5voN4+QFhVZnlZruezqpWYDiJ8UTzhP0VmeLXCmBk66YrMQ==", + "version": "3.1.2", + "license": "MIT", "dependencies": { "@types/node": "*" } }, "node_modules/@types/prettier": { "version": "2.7.3", - "resolved": "https://registry.npmjs.org/@types/prettier/-/prettier-2.7.3.tgz", - "integrity": "sha512-+68kP9yzs4LMp7VNh8gdzMSPZFL44MLGqiHWvttYJe+6qnuVr4Ek9wSBQoveqY/r+LwjCcU29kNVkidwim+kYA==", - "dev": true + "dev": true, + "license": "MIT" }, "node_modules/@types/responselike": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/@types/responselike/-/responselike-1.0.0.tgz", - "integrity": "sha512-85Y2BjiufFzaMIlvJDvTTB8Fxl2xfLo4HgmHzVBz08w4wDePCTjYw66PdrolO0kzli3yam/YCgRufyo1DdQVTA==", + "version": "1.0.3", + "license": "MIT", "dependencies": { "@types/node": "*" } }, "node_modules/@types/secp256k1": { - "version": "4.0.3", - "resolved": "https://registry.npmjs.org/@types/secp256k1/-/secp256k1-4.0.3.tgz", - "integrity": "sha512-Da66lEIFeIz9ltsdMZcpQvmrmmoqrfju8pm1BH8WbYjZSwUgCwXLb9C+9XYogwBITnbsSaMdVPb2ekf7TV+03w==", + "version": "4.0.6", + "license": "MIT", "dependencies": { "@types/node": "*" } }, "node_modules/@types/semver": { - "version": "7.5.1", - "resolved": "https://registry.npmjs.org/@types/semver/-/semver-7.5.1.tgz", - "integrity": "sha512-cJRQXpObxfNKkFAZbJl2yjWtJCqELQIdShsogr1d2MilP8dKD9TE/nEKHkJgUNHdGKCQaf9HbIynuV2csLGVLg==", - "dev": true + "version": "7.5.6", + "dev": true, + "license": "MIT" }, "node_modules/@types/stack-utils": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/@types/stack-utils/-/stack-utils-2.0.1.tgz", - "integrity": "sha512-Hl219/BT5fLAaz6NDkSuhzasy49dwQS/DSdu4MdggFB8zcXv7vflBI3xp7FEmkmdDkBUI2bPUNeMttp2knYdxw==", - "dev": true + "version": "2.0.3", + "dev": true, + "license": "MIT" }, "node_modules/@types/yargs": { - "version": "17.0.24", - "resolved": "https://registry.npmjs.org/@types/yargs/-/yargs-17.0.24.tgz", - "integrity": "sha512-6i0aC7jV6QzQB8ne1joVZ0eSFIstHsCrobmOtghM11yGlH0j43FKL2UhWdELkyps0zuf7qVTUVCCR+tgSlyLLw==", + "version": "17.0.32", "dev": true, + "license": "MIT", "dependencies": { "@types/yargs-parser": "*" } }, "node_modules/@types/yargs-parser": { - "version": "21.0.0", - "resolved": "https://registry.npmjs.org/@types/yargs-parser/-/yargs-parser-21.0.0.tgz", - "integrity": "sha512-iO9ZQHkZxHn4mSakYV0vFHAVDyEOIJQrV2uZ06HxEPcx+mt8swXoZHIbaaJ2crJYFfErySgktuTZ3BeLz+XmFA==", - "dev": true + "version": "21.0.3", + "dev": true, + "license": "MIT" }, "node_modules/@typescript-eslint/eslint-plugin": { "version": "5.62.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-5.62.0.tgz", - "integrity": "sha512-TiZzBSJja/LbhNPvk6yc0JrX9XqhQ0hdh6M2svYfsHGejaKFIAGd9MQ+ERIMzLGlN/kZoYIgdxFV0PuljTKXag==", "dev": true, + "license": "MIT", "dependencies": { "@eslint-community/regexpp": "^4.4.0", "@typescript-eslint/scope-manager": "5.62.0", @@ -2631,9 +2376,8 @@ }, "node_modules/@typescript-eslint/parser": { "version": "5.62.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-5.62.0.tgz", - "integrity": "sha512-VlJEV0fOQ7BExOsHYAGrgbEiZoi8D+Bl2+f6V2RrXerRSylnp+ZBHmPvaIa8cz0Ajx7WO7Z5RqfgYg7ED1nRhA==", "dev": true, + "license": "BSD-2-Clause", "dependencies": { "@typescript-eslint/scope-manager": "5.62.0", "@typescript-eslint/types": "5.62.0", @@ -2658,9 +2402,8 @@ }, "node_modules/@typescript-eslint/scope-manager": { "version": "5.62.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-5.62.0.tgz", - "integrity": "sha512-VXuvVvZeQCQb5Zgf4HAxc04q5j+WrNAtNh9OwCsCgpKqESMTu3tF/jhZ3xG6T4NZwWl65Bg8KuS2uEvhSfLl0w==", "dev": true, + "license": "MIT", "dependencies": { "@typescript-eslint/types": "5.62.0", "@typescript-eslint/visitor-keys": "5.62.0" @@ -2675,9 +2418,8 @@ }, "node_modules/@typescript-eslint/type-utils": { "version": "5.62.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/type-utils/-/type-utils-5.62.0.tgz", - "integrity": "sha512-xsSQreu+VnfbqQpW5vnCJdq1Z3Q0U31qiWmRhr98ONQmcp/yhiPJFPq8MXiJVLiksmOKSjIldZzkebzHuCGzew==", "dev": true, + "license": "MIT", "dependencies": { "@typescript-eslint/typescript-estree": "5.62.0", "@typescript-eslint/utils": "5.62.0", @@ -2702,9 +2444,8 @@ }, "node_modules/@typescript-eslint/types": { "version": "5.62.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-5.62.0.tgz", - "integrity": "sha512-87NVngcbVXUahrRTqIK27gD2t5Cu1yuCXxbLcFtCzZGlfyVWWh8mLHkoxzjsB6DDNnvdL+fW8MiwPEJyGJQDgQ==", "dev": true, + "license": "MIT", "engines": { "node": "^12.22.0 || ^14.17.0 || >=16.0.0" }, @@ -2715,9 +2456,8 @@ }, "node_modules/@typescript-eslint/typescript-estree": { "version": "5.62.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-5.62.0.tgz", - "integrity": "sha512-CmcQ6uY7b9y694lKdRB8FEel7JbU/40iSAPomu++SjLMntB+2Leay2LO6i8VnJk58MtE9/nQSFIH6jpyRWyYzA==", "dev": true, + "license": "BSD-2-Clause", "dependencies": { "@typescript-eslint/types": "5.62.0", "@typescript-eslint/visitor-keys": "5.62.0", @@ -2742,9 +2482,8 @@ }, "node_modules/@typescript-eslint/utils": { "version": "5.62.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/utils/-/utils-5.62.0.tgz", - "integrity": "sha512-n8oxjeb5aIbPFEtmQxQYOLI0i9n5ySBEY/ZEHHZqKQSFnxio1rv6dthascc9dLuwrL0RC5mPCxB7vnAVGAYWAQ==", "dev": true, + "license": "MIT", "dependencies": { "@eslint-community/eslint-utils": "^4.2.0", "@types/json-schema": "^7.0.9", @@ -2768,9 +2507,8 @@ }, "node_modules/@typescript-eslint/visitor-keys": { "version": "5.62.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-5.62.0.tgz", - "integrity": "sha512-07ny+LHRzQXepkGg6w0mFY41fVUNBrL2Roj/++7V1txKugfjm/Ci/qSND03r2RhlJhJYMcTn9AhhSSqQp0Ysyw==", "dev": true, + "license": "MIT", "dependencies": { "@typescript-eslint/types": "5.62.0", "eslint-visitor-keys": "^3.3.0" @@ -2785,8 +2523,7 @@ }, "node_modules/abort-controller": { "version": "3.0.0", - "resolved": "https://registry.npmjs.org/abort-controller/-/abort-controller-3.0.0.tgz", - "integrity": "sha512-h8lQ8tacZYnR3vNQTgibj+tODHI5/+l06Au2Pcriv/Gmet0eaj4TwWH41sO9wnHDiQsEj19q0drzdWdeAHtweg==", + "license": "MIT", "dependencies": { "event-target-shim": "^5.0.0" }, @@ -2796,13 +2533,11 @@ }, "node_modules/abortcontroller-polyfill": { "version": "1.7.5", - "resolved": "https://registry.npmjs.org/abortcontroller-polyfill/-/abortcontroller-polyfill-1.7.5.tgz", - "integrity": "sha512-JMJ5soJWP18htbbxJjG7bG6yuI6pRhgJ0scHHTfkUjf6wjP912xZWvM+A4sJK3gqd9E8fcPbDnOefbA9Th/FIQ==" + "license": "MIT" }, "node_modules/accepts": { "version": "1.3.8", - "resolved": "https://registry.npmjs.org/accepts/-/accepts-1.3.8.tgz", - "integrity": "sha512-PYAthTa2m2VKxuvSD3DPC/Gy+U+sOA1LAuT8mkmRuvw+NACSaeXEQ+NHcVF7rONl6qcaxV3Uuemwawk+7+SJLw==", + "license": "MIT", "dependencies": { "mime-types": "~2.1.34", "negotiator": "0.6.3" @@ -2813,9 +2548,8 @@ }, "node_modules/acorn": { "version": "7.4.1", - "resolved": "https://registry.npmjs.org/acorn/-/acorn-7.4.1.tgz", - "integrity": "sha512-nQyp0o1/mNdbTO1PO6kHkwSrmgZ0MT/jCCpNiwbUjGoRN4dlBhqJtoQuCnEOKzgTVwg0ZWiCoQy6SxMebQVh8A==", "dev": true, + "license": "MIT", "bin": { "acorn": "bin/acorn" }, @@ -2825,31 +2559,27 @@ }, "node_modules/acorn-jsx": { "version": "5.3.2", - "resolved": "https://registry.npmjs.org/acorn-jsx/-/acorn-jsx-5.3.2.tgz", - "integrity": "sha512-rq9s+JNhf0IChjtDXxllJ7g41oZk5SlXtp0LHwyA5cejwn7vKmKp4pPri6YEePv2PU65sAsegbXtIinmDFDXgQ==", "dev": true, + "license": "MIT", "peerDependencies": { "acorn": "^6.0.0 || ^7.0.0 || ^8.0.0" } }, "node_modules/acorn-walk": { - "version": "8.2.0", - "resolved": "https://registry.npmjs.org/acorn-walk/-/acorn-walk-8.2.0.tgz", - "integrity": "sha512-k+iyHEuPgSw6SbuDpGQM+06HQUa04DZ3o+F6CSzXMvvI5KMvnaEqXe+YVe555R9nn6GPt404fos4wcgpw12SDA==", + "version": "8.3.1", "dev": true, + "license": "MIT", "engines": { "node": ">=0.4.0" } }, "node_modules/aes-js": { "version": "4.0.0-beta.5", - "resolved": "https://registry.npmjs.org/aes-js/-/aes-js-4.0.0-beta.5.tgz", - "integrity": "sha512-G965FqalsNyrPqgEGON7nIx1e/OVENSgiEIzyC63haUMuvNnwIgIjMs52hlTCKhkBny7A2ORNlfY9Zu+jmGk1Q==" + "license": "MIT" }, "node_modules/ajv": { "version": "6.12.6", - "resolved": "https://registry.npmjs.org/ajv/-/ajv-6.12.6.tgz", - "integrity": "sha512-j3fVLgvTo527anyYyJOGTYJbG+vnnQYvE0m5mmkc1TK+nxAppkCLMIL0aZ4dblVCNoGShhm+kzE4ZUykBoMg4g==", + "license": "MIT", "dependencies": { "fast-deep-equal": "^3.1.1", "fast-json-stable-stringify": "^2.0.0", @@ -2863,18 +2593,16 @@ }, "node_modules/ansi-colors": { "version": "4.1.3", - "resolved": "https://registry.npmjs.org/ansi-colors/-/ansi-colors-4.1.3.tgz", - "integrity": "sha512-/6w/C21Pm1A7aZitlI5Ni/2J6FFQN8i1Cvz3kHABAAbw93v/NlvKdVOqz7CCWz/3iv/JplRSEEZ83XION15ovw==", "dev": true, + "license": "MIT", "engines": { "node": ">=6" } }, "node_modules/ansi-escapes": { "version": "4.3.2", - "resolved": "https://registry.npmjs.org/ansi-escapes/-/ansi-escapes-4.3.2.tgz", - "integrity": "sha512-gKXj5ALrKWQLsYG9jlTRmR/xKluxHV+Z9QEwNIgCfM1/uwPMCuzVVnh5mwTd+OuBZcwSIMbqssNWRm1lE51QaQ==", "dev": true, + "license": "MIT", "dependencies": { "type-fest": "^0.21.3" }, @@ -2887,9 +2615,8 @@ }, "node_modules/ansi-escapes/node_modules/type-fest": { "version": "0.21.3", - "resolved": "https://registry.npmjs.org/type-fest/-/type-fest-0.21.3.tgz", - "integrity": "sha512-t0rzBq87m3fVcduHDUFhKmyyX+9eo6WQjZvf51Ea/M0Q7+T374Jp1aUiyUl0GKxp8M/OETVHSDvmkyPgvX+X2w==", "dev": true, + "license": "(MIT OR CC0-1.0)", "engines": { "node": ">=10" }, @@ -2899,18 +2626,16 @@ }, "node_modules/ansi-regex": { "version": "5.0.1", - "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.1.tgz", - "integrity": "sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ==", "dev": true, + "license": "MIT", "engines": { "node": ">=8" } }, "node_modules/ansi-styles": { "version": "4.3.0", - "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", - "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", "dev": true, + "license": "MIT", "dependencies": { "color-convert": "^2.0.1" }, @@ -2923,9 +2648,8 @@ }, "node_modules/anymatch": { "version": "3.1.3", - "resolved": "https://registry.npmjs.org/anymatch/-/anymatch-3.1.3.tgz", - "integrity": "sha512-KMReFUr0B4t+D+OBkjR3KYqvocp2XaSzO55UcB6mgQMd3KbcE+mWTyvVV7D/zsdEbNnV6acZUutkiHQXvTr1Rw==", "dev": true, + "license": "ISC", "dependencies": { "normalize-path": "^3.0.0", "picomatch": "^2.0.4" @@ -2936,23 +2660,20 @@ }, "node_modules/arg": { "version": "4.1.3", - "resolved": "https://registry.npmjs.org/arg/-/arg-4.1.3.tgz", - "integrity": "sha512-58S9QDqG0Xx27YwPSt9fJxivjYl432YCwfDMfZ+71RAqUrZef7LrKQZ3LHLOwCS4FLNBplP533Zx895SeOCHvA==", - "dev": true + "dev": true, + "license": "MIT" }, "node_modules/argparse": { "version": "1.0.10", - "resolved": "https://registry.npmjs.org/argparse/-/argparse-1.0.10.tgz", - "integrity": "sha512-o5Roy6tNG4SL/FOkCAN6RzjiakZS25RLYFrcMttJqbdd8BWrnA+fGz57iN5Pb06pvBGvl5gQ0B48dJlslXvoTg==", "dev": true, + "license": "MIT", "dependencies": { "sprintf-js": "~1.0.2" } }, "node_modules/array-buffer-byte-length": { "version": "1.0.0", - "resolved": "https://registry.npmjs.org/array-buffer-byte-length/-/array-buffer-byte-length-1.0.0.tgz", - "integrity": "sha512-LPuwb2P+NrQw3XhxGc36+XSvuBPopovXYTR9Ew++Du9Yb/bx5AzBfrIsBoj0EZUifjQU+sHL21sseZ3jerWO/A==", + "license": "MIT", "dependencies": { "call-bind": "^1.0.2", "is-array-buffer": "^3.0.1" @@ -2963,22 +2684,19 @@ }, "node_modules/array-flatten": { "version": "1.1.1", - "resolved": "https://registry.npmjs.org/array-flatten/-/array-flatten-1.1.1.tgz", - "integrity": "sha512-PCVAQswWemu6UdxsDFFX/+gVeYqKAod3D3UVm91jHwynguOwAvYPhx8nNlM++NqRcK6CxxpUafjmhIdKiHibqg==" + "license": "MIT" }, "node_modules/array-union": { "version": "2.1.0", - "resolved": "https://registry.npmjs.org/array-union/-/array-union-2.1.0.tgz", - "integrity": "sha512-HGyxoOTYUyCM6stUe6EJgnd4EoewAI7zMdfqO+kGjnlZmBDz/cR5pf8r/cR4Wq60sL/p0IkcjUEEPwS3GFrIyw==", "dev": true, + "license": "MIT", "engines": { "node": ">=8" } }, "node_modules/arraybuffer.prototype.slice": { "version": "1.0.2", - "resolved": "https://registry.npmjs.org/arraybuffer.prototype.slice/-/arraybuffer.prototype.slice-1.0.2.tgz", - "integrity": "sha512-yMBKppFur/fbHu9/6USUe03bZ4knMYiwFBcyiaXB8Go0qNehwX6inYPzK9U0NeQvGxKthcmHcaR8P5MStSRBAw==", + "license": "MIT", "dependencies": { "array-buffer-byte-length": "^1.0.0", "call-bind": "^1.0.2", @@ -2997,52 +2715,45 @@ }, "node_modules/asn1": { "version": "0.2.6", - "resolved": "https://registry.npmjs.org/asn1/-/asn1-0.2.6.tgz", - "integrity": "sha512-ix/FxPn0MDjeyJ7i/yoHGFt/EX6LyNbxSEhPPXODPL+KB0VPk86UYfL0lMdy+KCnv+fmvIzySwaK5COwqVbWTQ==", + "license": "MIT", "dependencies": { "safer-buffer": "~2.1.0" } }, "node_modules/assert-plus": { "version": "1.0.0", - "resolved": "https://registry.npmjs.org/assert-plus/-/assert-plus-1.0.0.tgz", - "integrity": "sha512-NfJ4UzBCcQGLDlQq7nHxH+tv3kyZ0hHQqF5BO6J7tNJeP5do1llPr8dZ8zHonfhAu0PHAdMkSo+8o0wxg9lZWw==", + "license": "MIT", "engines": { "node": ">=0.8" } }, "node_modules/assertion-error": { "version": "1.1.0", - "resolved": "https://registry.npmjs.org/assertion-error/-/assertion-error-1.1.0.tgz", - "integrity": "sha512-jgsaNduz+ndvGyFt3uSuWqvy4lCnIJiovtouQN5JZHOKCS2QuhEdbcQHFhVksz2N2U9hXJo8odG7ETyWlEeuDw==", "dev": true, + "license": "MIT", "engines": { "node": "*" } }, "node_modules/astral-regex": { "version": "2.0.0", - "resolved": "https://registry.npmjs.org/astral-regex/-/astral-regex-2.0.0.tgz", - "integrity": "sha512-Z7tMw1ytTXt5jqMcOP+OQteU1VuNK9Y02uuJtKQ1Sv69jXQKKg5cibLwGJow8yzZP+eAc18EmLGPal0bp36rvQ==", "dev": true, + "license": "MIT", "engines": { "node": ">=8" } }, "node_modules/async-limiter": { "version": "1.0.1", - "resolved": "https://registry.npmjs.org/async-limiter/-/async-limiter-1.0.1.tgz", - "integrity": "sha512-csOlWGAcRFJaI6m+F2WKdnMKr4HhdhFVBk0H/QbJFMCr+uO2kwohwXQPxw/9OCxp05r5ghVBFSyioixx3gfkNQ==" + "license": "MIT" }, "node_modules/asynckit": { "version": "0.4.0", - "resolved": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz", - "integrity": "sha512-Oei9OH4tRh0YqU3GxhX79dM/mwVgvbZJaSNaRk+bshkj0S5cfHcgYakreBjrHwatXKbz+IoIdYLxrKim2MjW0Q==" + "license": "MIT" }, "node_modules/available-typed-arrays": { "version": "1.0.5", - "resolved": "https://registry.npmjs.org/available-typed-arrays/-/available-typed-arrays-1.0.5.tgz", - "integrity": "sha512-DMD0KiN46eipeziST1LPP/STfDU0sufISXmjSgvVsoU2tqxctQeASejWcfNtxYKqETM1UxQ8sp2OrSBWpHY6sw==", + "license": "MIT", "engines": { "node": ">= 0.4" }, @@ -3052,31 +2763,28 @@ }, "node_modules/aws-sign2": { "version": "0.7.0", - "resolved": "https://registry.npmjs.org/aws-sign2/-/aws-sign2-0.7.0.tgz", - "integrity": "sha512-08kcGqnYf/YmjoRhfxyu+CLxBjUtHLXLXX/vUfx9l2LYzG3c1m61nrpyFUZI6zeS+Li/wWMMidD9KgrqtGq3mA==", + "license": "Apache-2.0", "engines": { "node": "*" } }, "node_modules/aws4": { "version": "1.12.0", - "resolved": "https://registry.npmjs.org/aws4/-/aws4-1.12.0.tgz", - "integrity": "sha512-NmWvPnx0F1SfrQbYwOi7OeaNGokp9XhzNioJ/CSBs8Qa4vxug81mhJEAVZwxXuBmYB5KDRfMq/F3RR0BIU7sWg==" + "license": "MIT" }, "node_modules/axios": { - "version": "0.19.2", - "resolved": "https://registry.npmjs.org/axios/-/axios-0.19.2.tgz", - "integrity": "sha512-fjgm5MvRHLhx+osE2xoekY70AhARk3a6hkN+3Io1jc00jtquGvxYlKlsFUhmUET0V5te6CcZI7lcv2Ym61mjHA==", - "deprecated": "Critical security vulnerability fixed in v0.21.1. For more information, see https://github.com/axios/axios/pull/3410", + "version": "1.6.3", + "license": "MIT", "dependencies": { - "follow-redirects": "1.5.10" + "follow-redirects": "^1.15.0", + "form-data": "^4.0.0", + "proxy-from-env": "^1.1.0" } }, "node_modules/babel-jest": { "version": "28.1.3", - "resolved": "https://registry.npmjs.org/babel-jest/-/babel-jest-28.1.3.tgz", - "integrity": "sha512-epUaPOEWMk3cWX0M/sPvCHHCe9fMFAa/9hXEgKP8nFfNl/jlGkE9ucq9NqkZGXLDduCJYS0UvSlPUwC0S+rH6Q==", "dev": true, + "license": "MIT", "dependencies": { "@jest/transform": "^28.1.3", "@types/babel__core": "^7.1.14", @@ -3095,9 +2803,8 @@ }, "node_modules/babel-plugin-istanbul": { "version": "6.1.1", - "resolved": "https://registry.npmjs.org/babel-plugin-istanbul/-/babel-plugin-istanbul-6.1.1.tgz", - "integrity": "sha512-Y1IQok9821cC9onCx5otgFfRm7Lm+I+wwxOx738M/WLPZ9Q42m4IG5W0FNX8WLL2gYMZo3JkuXIH2DOpWM+qwA==", "dev": true, + "license": "BSD-3-Clause", "dependencies": { "@babel/helper-plugin-utils": "^7.0.0", "@istanbuljs/load-nyc-config": "^1.0.0", @@ -3111,9 +2818,8 @@ }, "node_modules/babel-plugin-jest-hoist": { "version": "28.1.3", - "resolved": "https://registry.npmjs.org/babel-plugin-jest-hoist/-/babel-plugin-jest-hoist-28.1.3.tgz", - "integrity": "sha512-Ys3tUKAmfnkRUpPdpa98eYrAR0nV+sSFUZZEGuQ2EbFd1y4SOLtD5QDNHAq+bb9a+bbXvYQC4b+ID/THIMcU6Q==", "dev": true, + "license": "MIT", "dependencies": { "@babel/template": "^7.3.3", "@babel/types": "^7.3.3", @@ -3126,9 +2832,8 @@ }, "node_modules/babel-preset-current-node-syntax": { "version": "1.0.1", - "resolved": "https://registry.npmjs.org/babel-preset-current-node-syntax/-/babel-preset-current-node-syntax-1.0.1.tgz", - "integrity": "sha512-M7LQ0bxarkxQoN+vz5aJPsLBn77n8QgTFmo8WK0/44auK2xlCXrYcUxHFxgU7qW5Yzw/CjmLRK2uJzaCd7LvqQ==", "dev": true, + "license": "MIT", "dependencies": { "@babel/plugin-syntax-async-generators": "^7.8.4", "@babel/plugin-syntax-bigint": "^7.8.3", @@ -3149,9 +2854,8 @@ }, "node_modules/babel-preset-jest": { "version": "28.1.3", - "resolved": "https://registry.npmjs.org/babel-preset-jest/-/babel-preset-jest-28.1.3.tgz", - "integrity": "sha512-L+fupJvlWAHbQfn74coNX3zf60LXMJsezNvvx8eIh7iOR1luJ1poxYgQk1F8PYtNq/6QODDHCqsSnTFSWC491A==", "dev": true, + "license": "MIT", "dependencies": { "babel-plugin-jest-hoist": "^28.1.3", "babel-preset-current-node-syntax": "^1.0.0" @@ -3163,24 +2867,44 @@ "@babel/core": "^7.0.0" } }, + "node_modules/babyjubjub2021": { + "version": "0.1.1", + "license": "ISC", + "dependencies": { + "@iden3/js-crypto": "^1.0.3", + "@iden3/js-jsonld-merklization": "^1.1.2", + "bip39": "^3.1.0", + "crypto-ld": "^6.0.0", + "multibase": "^4.0.6" + } + }, + "node_modules/babyjubjubsignature2021": { + "version": "1.1.0", + "resolved": "git+ssh://git@github.com/hypersign-protocol/BabyJubJubSignature2021Suite.git#4234728351d3be7a0da07ded7e860909395f0b22", + "license": "ISC", + "dependencies": { + "@iden3/js-crypto": "^1.0.3", + "@iden3/js-jsonld-merklization": "^1.1.2", + "babyjubjub2021": "^0.1.1", + "jsonld-signatures": "^9.3.1", + "multibase": "^4.0.6" + } + }, "node_modules/balanced-match": { "version": "1.0.2", - "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.2.tgz", - "integrity": "sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==", - "dev": true + "dev": true, + "license": "MIT" }, "node_modules/base-x": { "version": "3.0.9", - "resolved": "https://registry.npmjs.org/base-x/-/base-x-3.0.9.tgz", - "integrity": "sha512-H7JU6iBHTal1gp56aKoaa//YUxEaAOUiydvrV/pILqIHXTtqxSkATOnDA2u+jZ/61sD+L/412+7kzXRtWukhpQ==", + "license": "MIT", "dependencies": { "safe-buffer": "^5.0.1" } }, "node_modules/base58-universal": { "version": "1.0.0", - "resolved": "https://registry.npmjs.org/base58-universal/-/base58-universal-1.0.0.tgz", - "integrity": "sha512-v0Ja4jwaQP8gBZPNXpfaXlLht2ed/Gp3AsVUZXtlZgY1qbKS0CjxvYs43U0Gh00zbVc1neMe+q/ULJ7ubVyB+w==", + "license": "BSD-3-Clause", "dependencies": { "esm": "^3.2.25" }, @@ -3190,8 +2914,6 @@ }, "node_modules/base64-js": { "version": "1.5.1", - "resolved": "https://registry.npmjs.org/base64-js/-/base64-js-1.5.1.tgz", - "integrity": "sha512-AKpaYlHn8t4SVbOHCy+b5+KKgvR4vrsD8vbvrbiQJps7fKDTkjkDry6ji0rUJjC0kzbNePLwzxq8iypo41qeWA==", "funding": [ { "type": "github", @@ -3205,20 +2927,19 @@ "type": "consulting", "url": "https://feross.org/support" } - ] + ], + "license": "MIT" }, "node_modules/base64url": { "version": "3.0.1", - "resolved": "https://registry.npmjs.org/base64url/-/base64url-3.0.1.tgz", - "integrity": "sha512-ir1UPr3dkwexU7FdV8qBBbNDRUhMmIekYMFZfi+C/sLNnRESKPl23nB9b2pltqfOQNnGzsDdId90AEtG5tCx4A==", + "license": "MIT", "engines": { "node": ">=6.0.0" } }, "node_modules/base64url-universal": { "version": "1.1.0", - "resolved": "https://registry.npmjs.org/base64url-universal/-/base64url-universal-1.1.0.tgz", - "integrity": "sha512-WyftvZqye29YQ10ZnuiBeEj0lk8SN8xHU9hOznkLc85wS1cLTp6RpzlMrHxMPD9nH7S55gsBqMqgGyz93rqmkA==", + "license": "BSD-3-Clause", "dependencies": { "base64url": "^3.0.0" }, @@ -3228,66 +2949,56 @@ }, "node_modules/bcrypt-pbkdf": { "version": "1.0.2", - "resolved": "https://registry.npmjs.org/bcrypt-pbkdf/-/bcrypt-pbkdf-1.0.2.tgz", - "integrity": "sha512-qeFIXtP4MSoi6NLqO12WfqARWWuCKi2Rn/9hJLEmtB5yTNr9DqFWkJRCf2qShWzPeAMRnOgCrq0sg/KLv5ES9w==", + "license": "BSD-3-Clause", "dependencies": { "tweetnacl": "^0.14.3" } }, "node_modules/bcrypt-pbkdf/node_modules/tweetnacl": { "version": "0.14.5", - "resolved": "https://registry.npmjs.org/tweetnacl/-/tweetnacl-0.14.5.tgz", - "integrity": "sha512-KXXFFdAbFXY4geFIwoyNK+f5Z1b7swfXABfL7HXCmoIWMKU3dmS26672A4EeQtDzLKy7SXmfBu51JolvEKwtGA==" + "license": "Unlicense" }, "node_modules/bech32": { "version": "1.1.4", - "resolved": "https://registry.npmjs.org/bech32/-/bech32-1.1.4.tgz", - "integrity": "sha512-s0IrSOzLlbvX7yp4WBfPITzpAU8sqQcpsmwXDiKwrG4r491vwCO/XpejasRNl0piBMe/DvP4Tz0mIS/X1DPJBQ==" + "license": "MIT" }, "node_modules/bignumber.js": { "version": "9.1.2", - "resolved": "https://registry.npmjs.org/bignumber.js/-/bignumber.js-9.1.2.tgz", - "integrity": "sha512-2/mKyZH9K85bzOEfhXDBFZTGd1CTs+5IHpeFQo9luiBG7hghdC851Pj2WAhb6E3R6b9tZj/XKhbg4fum+Kepug==", + "license": "MIT", "engines": { "node": "*" } }, "node_modules/binary-extensions": { "version": "2.2.0", - "resolved": "https://registry.npmjs.org/binary-extensions/-/binary-extensions-2.2.0.tgz", - "integrity": "sha512-jDctJ/IVQbZoJykoeHbhXpOlNBqGNcwXJKJog42E5HDPUwQTSdjCHdihjj0DlnheQ7blbT6dHOafNAiS8ooQKA==", "dev": true, + "license": "MIT", "engines": { "node": ">=8" } }, "node_modules/bip39": { "version": "3.1.0", - "resolved": "https://registry.npmjs.org/bip39/-/bip39-3.1.0.tgz", - "integrity": "sha512-c9kiwdk45Do5GL0vJMe7tS95VjCii65mYAH7DfWl3uW8AVzXKQVUm64i3hzVybBDMp9r7j9iNxR85+ul8MdN/A==", + "license": "ISC", "dependencies": { "@noble/hashes": "^1.2.0" } }, "node_modules/blakejs": { "version": "1.2.1", - "resolved": "https://registry.npmjs.org/blakejs/-/blakejs-1.2.1.tgz", - "integrity": "sha512-QXUSXI3QVc/gJME0dBpXrag1kbzOqCjCX8/b54ntNyW6sjtoqxqRk3LTmXzaJoh71zMsDCjM+47jS7XiwN/+fQ==" + "license": "MIT" }, "node_modules/bluebird": { "version": "3.7.2", - "resolved": "https://registry.npmjs.org/bluebird/-/bluebird-3.7.2.tgz", - "integrity": "sha512-XpNj6GDQzdfW+r2Wnn7xiSAd7TM3jzkxGXBGTtWKuSXv1xUV+azxAm8jdWZN06QTQk+2N2XB9jRDkvbmQmcRtg==" + "license": "MIT" }, "node_modules/bn.js": { "version": "5.2.1", - "resolved": "https://registry.npmjs.org/bn.js/-/bn.js-5.2.1.tgz", - "integrity": "sha512-eXRvHzWyYPBuB4NBy0cmYQjGitUrtqwbvlzP3G6VFnNRbsZQIxQ10PbKKHt8gZ/HW/D/747aDl+QkDqg3KQLMQ==" + "license": "MIT" }, "node_modules/body-parser": { "version": "1.20.2", - "resolved": "https://registry.npmjs.org/body-parser/-/body-parser-1.20.2.tgz", - "integrity": "sha512-ml9pReCu3M61kGlqoTm2umSXTlRTuGTx0bfYj+uIUKKYycG5NtSbeetV3faSU6R7ajOPw0g/J1PvK4qNy7s5bA==", + "license": "MIT", "dependencies": { "bytes": "3.1.2", "content-type": "~1.0.5", @@ -3309,22 +3020,19 @@ }, "node_modules/body-parser/node_modules/debug": { "version": "2.6.9", - "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", - "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==", + "license": "MIT", "dependencies": { "ms": "2.0.0" } }, "node_modules/body-parser/node_modules/ms": { "version": "2.0.0", - "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", - "integrity": "sha512-Tpp60P6IUJDTuOq/5Z8cdskzJujfwqfOTkrwIwj7IRISpnkJnT6SyJ4PCPnGMoFjC9ddhal5KVIYtAt97ix05A==" + "license": "MIT" }, "node_modules/brace-expansion": { "version": "1.1.11", - "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", - "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", "dev": true, + "license": "MIT", "dependencies": { "balanced-match": "^1.0.0", "concat-map": "0.0.1" @@ -3332,9 +3040,8 @@ }, "node_modules/braces": { "version": "3.0.2", - "resolved": "https://registry.npmjs.org/braces/-/braces-3.0.2.tgz", - "integrity": "sha512-b8um+L1RzM3WDSzvhm6gIz1yfTbBt6YTlcEKAvsmqCZZFw46z626lVj9j1yEPW33H5H+lBQpZMP1k8l+78Ha0A==", "dev": true, + "license": "MIT", "dependencies": { "fill-range": "^7.0.1" }, @@ -3344,19 +3051,16 @@ }, "node_modules/brorand": { "version": "1.1.0", - "resolved": "https://registry.npmjs.org/brorand/-/brorand-1.1.0.tgz", - "integrity": "sha512-cKV8tMCEpQs4hK/ik71d6LrPOnpkpGBR0wzxqr68g2m/LB2GxVYQroAjMJZRVM1Y4BCjCKc3vAamxSzOY2RP+w==" + "license": "MIT" }, "node_modules/browser-stdout": { "version": "1.3.1", - "resolved": "https://registry.npmjs.org/browser-stdout/-/browser-stdout-1.3.1.tgz", - "integrity": "sha512-qhAVI1+Av2X7qelOfAIYwXONood6XlZE/fXaBSmW/T5SzLAmCgzi+eiWE7fUvbHaeNBQH13UftjpXxsfLkMpgw==", - "dev": true + "dev": true, + "license": "ISC" }, "node_modules/browserify-aes": { "version": "1.2.0", - "resolved": "https://registry.npmjs.org/browserify-aes/-/browserify-aes-1.2.0.tgz", - "integrity": "sha512-+7CHXqGuspUn/Sl5aO7Ea0xWGAtETPXNSAjHo48JfLdPWcMng33Xe4znFvQweqc/uzk5zSOI3H52CYnjCfb5hA==", + "license": "MIT", "dependencies": { "buffer-xor": "^1.0.3", "cipher-base": "^1.0.0", @@ -3367,9 +3071,7 @@ } }, "node_modules/browserslist": { - "version": "4.21.10", - "resolved": "https://registry.npmjs.org/browserslist/-/browserslist-4.21.10.tgz", - "integrity": "sha512-bipEBdZfVH5/pwrvqc+Ub0kUPVfGUhlKxbvfD+z1BDnPEO/X98ruXGA1WP5ASpAFKan7Qr6j736IacbZQuAlKQ==", + "version": "4.22.2", "dev": true, "funding": [ { @@ -3385,11 +3087,12 @@ "url": "https://github.com/sponsors/ai" } ], + "license": "MIT", "dependencies": { - "caniuse-lite": "^1.0.30001517", - "electron-to-chromium": "^1.4.477", - "node-releases": "^2.0.13", - "update-browserslist-db": "^1.0.11" + "caniuse-lite": "^1.0.30001565", + "electron-to-chromium": "^1.4.601", + "node-releases": "^2.0.14", + "update-browserslist-db": "^1.0.13" }, "bin": { "browserslist": "cli.js" @@ -3400,9 +3103,8 @@ }, "node_modules/bs-logger": { "version": "0.2.6", - "resolved": "https://registry.npmjs.org/bs-logger/-/bs-logger-0.2.6.tgz", - "integrity": "sha512-pd8DCoxmbgc7hyPKOvxtqNcjYoOsABPQdcCUjGp3d42VR2CX1ORhk2A87oqqu5R1kk+76nsxZupkmyd+MVtCog==", "dev": true, + "license": "MIT", "dependencies": { "fast-json-stable-stringify": "2.x" }, @@ -3412,16 +3114,14 @@ }, "node_modules/bs58": { "version": "4.0.1", - "resolved": "https://registry.npmjs.org/bs58/-/bs58-4.0.1.tgz", - "integrity": "sha512-Ok3Wdf5vOIlBrgCvTq96gBkJw+JUEzdBgyaza5HLtPm7yTHkjRy8+JzNyHF7BHa0bNWOQIp3m5YF0nnFcOIKLw==", + "license": "MIT", "dependencies": { "base-x": "^3.0.2" } }, "node_modules/bs58check": { "version": "2.1.2", - "resolved": "https://registry.npmjs.org/bs58check/-/bs58check-2.1.2.tgz", - "integrity": "sha512-0TS1jicxdU09dwJMNZtVAfzPi6Q6QeN0pM1Fkzrjn+XYHvzMKPU3pHVpva+769iNVSfIYWf7LJ6WR+BuuMf8cA==", + "license": "MIT", "dependencies": { "bs58": "^4.0.0", "create-hash": "^1.1.0", @@ -3430,17 +3130,14 @@ }, "node_modules/bser": { "version": "2.1.1", - "resolved": "https://registry.npmjs.org/bser/-/bser-2.1.1.tgz", - "integrity": "sha512-gQxTNE/GAfIIrmHLUE3oJyp5FO6HRBfhjnw4/wMmA63ZGDJnWBmgY/lyQBpnDUkGmAhbSe39tx2d/iTOAfglwQ==", "dev": true, + "license": "Apache-2.0", "dependencies": { "node-int64": "^0.4.0" } }, "node_modules/buffer": { "version": "5.7.1", - "resolved": "https://registry.npmjs.org/buffer/-/buffer-5.7.1.tgz", - "integrity": "sha512-EHcyIPBQ4BSGlvjB16k5KgAJ27CIsHY/2JBmCRReo48y9rQ3MaUzWX3KVlBa4U7MyX02HdVj0K7C3WaB3ju7FQ==", "funding": [ { "type": "github", @@ -3455,6 +3152,7 @@ "url": "https://feross.org/support" } ], + "license": "MIT", "dependencies": { "base64-js": "^1.3.1", "ieee754": "^1.1.13" @@ -3462,30 +3160,25 @@ }, "node_modules/buffer-equal-constant-time": { "version": "1.0.1", - "resolved": "https://registry.npmjs.org/buffer-equal-constant-time/-/buffer-equal-constant-time-1.0.1.tgz", - "integrity": "sha512-zRpUiDwd/xk6ADqPMATG8vc9VPrkck7T07OIx0gnjmJAnHnTVXNQG3vfvWNuiZIkwu9KrKdA1iJKfsfTVxE6NA==" + "license": "BSD-3-Clause" }, "node_modules/buffer-from": { "version": "1.1.2", - "resolved": "https://registry.npmjs.org/buffer-from/-/buffer-from-1.1.2.tgz", - "integrity": "sha512-E+XQCRwSbaaiChtv6k6Dwgc+bx+Bs6vuKJHHl5kox/BaKbhiXzqQOwK4cO22yElGp2OCmjwVhT3HmxgyPGnJfQ==", - "dev": true + "dev": true, + "license": "MIT" }, "node_modules/buffer-to-arraybuffer": { "version": "0.0.5", - "resolved": "https://registry.npmjs.org/buffer-to-arraybuffer/-/buffer-to-arraybuffer-0.0.5.tgz", - "integrity": "sha512-3dthu5CYiVB1DEJp61FtApNnNndTckcqe4pFcLdvHtrpG+kcyekCJKg4MRiDcFW7A6AODnXB9U4dwQiCW5kzJQ==" + "license": "MIT" }, "node_modules/buffer-xor": { "version": "1.0.3", - "resolved": "https://registry.npmjs.org/buffer-xor/-/buffer-xor-1.0.3.tgz", - "integrity": "sha512-571s0T7nZWK6vB67HI5dyUF7wXiNcfaPPPTl6zYCNApANjIvYJTg7hlud/+cJpdAhS7dVzqMLmfhfHR3rAcOjQ==" + "license": "MIT" }, "node_modules/bufferutil": { - "version": "4.0.7", - "resolved": "https://registry.npmjs.org/bufferutil/-/bufferutil-4.0.7.tgz", - "integrity": "sha512-kukuqc39WOHtdxtw4UScxF/WVnMFVSQVKhtx3AjZJzhd0RGZZldcrfSEbVsWWe6KNH253574cq5F+wpv0G9pJw==", + "version": "4.0.8", "hasInstallScript": true, + "license": "MIT", "dependencies": { "node-gyp-build": "^4.3.0" }, @@ -3493,37 +3186,23 @@ "node": ">=6.14.2" } }, - "node_modules/busboy": { - "version": "1.6.0", - "resolved": "https://registry.npmjs.org/busboy/-/busboy-1.6.0.tgz", - "integrity": "sha512-8SFQbg/0hQ9xy3UNTB0YEnsNBbWfhf7RtnzpL7TkBiTBRfrQ9Fxcnz7VJsleJpyp6rVLvXiuORqjlHi5q+PYuA==", - "dependencies": { - "streamsearch": "^1.1.0" - }, - "engines": { - "node": ">=10.16.0" - } - }, "node_modules/bytes": { "version": "3.1.2", - "resolved": "https://registry.npmjs.org/bytes/-/bytes-3.1.2.tgz", - "integrity": "sha512-/Nf7TyzTx6S3yRJObOAV7956r8cr2+Oj8AC5dt8wSP3BQAoeX58NoHyCU8P8zGkNXStjTSi6fzO6F0pBdcYbEg==", + "license": "MIT", "engines": { "node": ">= 0.8" } }, "node_modules/cacheable-lookup": { "version": "6.1.0", - "resolved": "https://registry.npmjs.org/cacheable-lookup/-/cacheable-lookup-6.1.0.tgz", - "integrity": "sha512-KJ/Dmo1lDDhmW2XDPMo+9oiy/CeqosPguPCrgcVzKyZrL6pM1gU2GmPY/xo6OQPTUaA/c0kwHuywB4E6nmT9ww==", + "license": "MIT", "engines": { "node": ">=10.6.0" } }, "node_modules/cacheable-request": { "version": "7.0.4", - "resolved": "https://registry.npmjs.org/cacheable-request/-/cacheable-request-7.0.4.tgz", - "integrity": "sha512-v+p6ongsrp0yTGbJXjgxPow2+DL93DASP4kXCDKb8/bwRtt9OEF3whggkkDkGNzgcWy2XaF4a8nZglC7uElscg==", + "license": "MIT", "dependencies": { "clone-response": "^1.0.2", "get-stream": "^5.1.0", @@ -3539,8 +3218,7 @@ }, "node_modules/cacheable-request/node_modules/get-stream": { "version": "5.2.0", - "resolved": "https://registry.npmjs.org/get-stream/-/get-stream-5.2.0.tgz", - "integrity": "sha512-nBF+F1rAZVCu/p7rjzgA+Yb4lfYXrpl7a6VmJrU8wF9I1CKvP/QwPNZHnOlwbTkY6dvtFIzFMSyQXbLoTQPRpA==", + "license": "MIT", "dependencies": { "pump": "^3.0.0" }, @@ -3553,19 +3231,18 @@ }, "node_modules/cacheable-request/node_modules/lowercase-keys": { "version": "2.0.0", - "resolved": "https://registry.npmjs.org/lowercase-keys/-/lowercase-keys-2.0.0.tgz", - "integrity": "sha512-tqNXrS78oMOE73NMxK4EMLQsQowWf8jKooH9g7xPavRT706R6bkQJ6DY2Te7QukaZsulxa30wQ7bk0pm4XiHmA==", + "license": "MIT", "engines": { "node": ">=8" } }, "node_modules/call-bind": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/call-bind/-/call-bind-1.0.2.tgz", - "integrity": "sha512-7O+FbCihrB5WGbFYesctwmTKae6rOiIzmz1icreWJ+0aA7LJfuqhEso2T9ncpcFtzMQtzXf2QGGueWJGTYsqrA==", + "version": "1.0.5", + "license": "MIT", "dependencies": { - "function-bind": "^1.1.1", - "get-intrinsic": "^1.0.2" + "function-bind": "^1.1.2", + "get-intrinsic": "^1.2.1", + "set-function-length": "^1.1.1" }, "funding": { "url": "https://github.com/sponsors/ljharb" @@ -3573,26 +3250,22 @@ }, "node_modules/callsites": { "version": "3.1.0", - "resolved": "https://registry.npmjs.org/callsites/-/callsites-3.1.0.tgz", - "integrity": "sha512-P8BjAsXvZS+VIDUI11hHCQEv74YT67YUi5JJFNWIqL235sBmjX4+qx9Muvls5ivyNENctx46xQLQ3aTuE7ssaQ==", "dev": true, + "license": "MIT", "engines": { "node": ">=6" } }, "node_modules/camelcase": { "version": "5.3.1", - "resolved": "https://registry.npmjs.org/camelcase/-/camelcase-5.3.1.tgz", - "integrity": "sha512-L28STB170nwWS63UjtlEOE3dldQApaJXZkOI1uMFfzf3rRuPegHaHesyee+YxQ+W6SvRDQV6UrdOdRiR153wJg==", "dev": true, + "license": "MIT", "engines": { "node": ">=6" } }, "node_modules/caniuse-lite": { - "version": "1.0.30001528", - "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001528.tgz", - "integrity": "sha512-0Db4yyjR9QMNlsxh+kKWzQtkyflkG/snYheSzkjmvdEtEXB1+jt7A2HmSEiO6XIJPIbo92lHNGNySvE5pZcs5Q==", + "version": "1.0.30001571", "dev": true, "funding": [ { @@ -3607,31 +3280,29 @@ "type": "github", "url": "https://github.com/sponsors/ai" } - ] + ], + "license": "CC-BY-4.0" }, "node_modules/canonicalize": { "version": "1.0.8", - "resolved": "https://registry.npmjs.org/canonicalize/-/canonicalize-1.0.8.tgz", - "integrity": "sha512-0CNTVCLZggSh7bc5VkX5WWPWO+cyZbNd07IHIsSXLia/eAq+r836hgk+8BKoEh7949Mda87VUOitx5OddVj64A==" + "license": "Apache-2.0" }, "node_modules/caseless": { "version": "0.12.0", - "resolved": "https://registry.npmjs.org/caseless/-/caseless-0.12.0.tgz", - "integrity": "sha512-4tYFyifaFfGacoiObjJegolkwSU4xQNGbVgUiNYVUxbQ2x2lUsFvY4hVgVzGiIe6WLOPqycWXA40l+PWsxthUw==" + "license": "Apache-2.0" }, "node_modules/chai": { - "version": "4.3.8", - "resolved": "https://registry.npmjs.org/chai/-/chai-4.3.8.tgz", - "integrity": "sha512-vX4YvVVtxlfSZ2VecZgFUTU5qPCYsobVI2O9FmwEXBhDigYGQA6jRXCycIs1yJnnWbZ6/+a2zNIF5DfVCcJBFQ==", + "version": "4.3.10", "dev": true, + "license": "MIT", "dependencies": { "assertion-error": "^1.1.0", - "check-error": "^1.0.2", - "deep-eql": "^4.1.2", - "get-func-name": "^2.0.0", - "loupe": "^2.3.1", + "check-error": "^1.0.3", + "deep-eql": "^4.1.3", + "get-func-name": "^2.0.2", + "loupe": "^2.3.6", "pathval": "^1.1.1", - "type-detect": "^4.0.5" + "type-detect": "^4.0.8" }, "engines": { "node": ">=4" @@ -3639,9 +3310,8 @@ }, "node_modules/chalk": { "version": "4.1.2", - "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz", - "integrity": "sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==", "dev": true, + "license": "MIT", "dependencies": { "ansi-styles": "^4.1.0", "supports-color": "^7.1.0" @@ -3655,26 +3325,25 @@ }, "node_modules/char-regex": { "version": "1.0.2", - "resolved": "https://registry.npmjs.org/char-regex/-/char-regex-1.0.2.tgz", - "integrity": "sha512-kWWXztvZ5SBQV+eRgKFeh8q5sLuZY2+8WUIzlxWVTg+oGwY14qylx1KbKzHd8P6ZYkAg0xyIDU9JMHhyJMZ1jw==", "dev": true, + "license": "MIT", "engines": { "node": ">=10" } }, "node_modules/check-error": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/check-error/-/check-error-1.0.2.tgz", - "integrity": "sha512-BrgHpW9NURQgzoNyjfq0Wu6VFO6D7IZEmJNdtgNqpzGG8RuNFHt2jQxWlAs4HMe119chBnv+34syEZtc6IhLtA==", + "version": "1.0.3", "dev": true, + "license": "MIT", + "dependencies": { + "get-func-name": "^2.0.2" + }, "engines": { "node": "*" } }, "node_modules/chokidar": { "version": "3.5.3", - "resolved": "https://registry.npmjs.org/chokidar/-/chokidar-3.5.3.tgz", - "integrity": "sha512-Dr3sfKRP6oTcjf2JmUmFJfeVMvXBdegxB0iVQ5eb2V10uFJUCAS8OByZdVAyVb8xXNz3GjjTgj9kLWsZTqE6kw==", "dev": true, "funding": [ { @@ -3682,6 +3351,7 @@ "url": "https://paulmillr.com/funding/" } ], + "license": "MIT", "dependencies": { "anymatch": "~3.1.2", "braces": "~3.0.2", @@ -3700,13 +3370,10 @@ }, "node_modules/chownr": { "version": "1.1.4", - "resolved": "https://registry.npmjs.org/chownr/-/chownr-1.1.4.tgz", - "integrity": "sha512-jJ0bqzaylmJtVnNgzTeSOs8DPavpbYgEr/b0YL8/2GO3xJEhInFmhKMUnEJQjZumK7KXGFhUy89PrsJWlakBVg==" + "license": "ISC" }, "node_modules/ci-info": { - "version": "3.8.0", - "resolved": "https://registry.npmjs.org/ci-info/-/ci-info-3.8.0.tgz", - "integrity": "sha512-eXTggHWSooYhq49F2opQhuHWgzucfF2YgODK4e1566GQs5BIfP30B0oenwBJHfWxAs2fyPB1s7Mg949zLf61Yw==", + "version": "3.9.0", "dev": true, "funding": [ { @@ -3714,15 +3381,14 @@ "url": "https://github.com/sponsors/sibiraj-s" } ], + "license": "MIT", "engines": { "node": ">=8" } }, "node_modules/cids": { "version": "0.7.5", - "resolved": "https://registry.npmjs.org/cids/-/cids-0.7.5.tgz", - "integrity": "sha512-zT7mPeghoWAu+ppn8+BS1tQ5qGmbMfB4AregnQjA/qHY3GC1m1ptI9GkWNlgeu38r7CuRdXB47uY2XgAYt6QVA==", - "deprecated": "This module has been superseded by the multiformats module", + "license": "MIT", "dependencies": { "buffer": "^5.5.0", "class-is": "^1.1.0", @@ -3735,11 +3401,17 @@ "npm": ">=3.0.0" } }, + "node_modules/cids/node_modules/multibase": { + "version": "0.6.1", + "license": "MIT", + "dependencies": { + "base-x": "^3.0.8", + "buffer": "^5.5.0" + } + }, "node_modules/cids/node_modules/multicodec": { "version": "1.0.4", - "resolved": "https://registry.npmjs.org/multicodec/-/multicodec-1.0.4.tgz", - "integrity": "sha512-NDd7FeS3QamVtbgfvu5h7fd1IlbaC4EQ0/pgU4zqE2vdHCmBGsUa0TiM8/TdSeG6BMPC92OOCf8F1ocE/Wkrrg==", - "deprecated": "This module has been superseded by the multiformats module", + "license": "MIT", "dependencies": { "buffer": "^5.6.0", "varint": "^5.0.0" @@ -3747,8 +3419,7 @@ }, "node_modules/cipher-base": { "version": "1.0.4", - "resolved": "https://registry.npmjs.org/cipher-base/-/cipher-base-1.0.4.tgz", - "integrity": "sha512-Kkht5ye6ZGmwv40uUDZztayT2ThLQGfnj/T71N/XzeZeo3nf8foyW7zGTsPYkEya3m5f3cAypH+qe7YOrM1U2Q==", + "license": "MIT", "dependencies": { "inherits": "^2.0.1", "safe-buffer": "^5.0.1" @@ -3756,20 +3427,17 @@ }, "node_modules/cjs-module-lexer": { "version": "1.2.3", - "resolved": "https://registry.npmjs.org/cjs-module-lexer/-/cjs-module-lexer-1.2.3.tgz", - "integrity": "sha512-0TNiGstbQmCFwt4akjjBg5pLRTSyj/PkWQ1ZoO2zntmg9yLqSRxwEa4iCfQLGjqhiqBfOJa7W/E8wfGrTDmlZQ==", - "dev": true + "dev": true, + "license": "MIT" }, "node_modules/class-is": { "version": "1.1.0", - "resolved": "https://registry.npmjs.org/class-is/-/class-is-1.1.0.tgz", - "integrity": "sha512-rhjH9AG1fvabIDoGRVH587413LPjTZgmDF9fOFCbFJQV4yuocX1mHxxvXI4g3cGwbVY9wAYIoKlg1N79frJKQw==" + "license": "MIT" }, "node_modules/cliui": { "version": "8.0.1", - "resolved": "https://registry.npmjs.org/cliui/-/cliui-8.0.1.tgz", - "integrity": "sha512-BSeNnyus75C4//NQ9gQt1/csTXyo/8Sb+afLAkzAptFuMsod9HFokGNudZpi/oQV73hnVK+sR+5PVRMd+Dr7YQ==", "dev": true, + "license": "ISC", "dependencies": { "string-width": "^4.2.0", "strip-ansi": "^6.0.1", @@ -3781,8 +3449,7 @@ }, "node_modules/clone-response": { "version": "1.0.3", - "resolved": "https://registry.npmjs.org/clone-response/-/clone-response-1.0.3.tgz", - "integrity": "sha512-ROoL94jJH2dUVML2Y/5PEDNaSHgeOdSDicUyS7izcF63G6sTc/FTjLub4b8Il9S8S0beOfYt0TaA5qvFK+w0wA==", + "license": "MIT", "dependencies": { "mimic-response": "^1.0.0" }, @@ -3792,9 +3459,8 @@ }, "node_modules/co": { "version": "4.6.0", - "resolved": "https://registry.npmjs.org/co/-/co-4.6.0.tgz", - "integrity": "sha512-QVb0dM5HvG+uaxitm8wONl7jltx8dqhfU33DcqtOZcLSVIKSDDLDi7+0LbAKiyI8hD9u42m2YxXSkMGWThaecQ==", "dev": true, + "license": "MIT", "engines": { "iojs": ">= 1.0.0", "node": ">= 0.12.0" @@ -3802,15 +3468,13 @@ }, "node_modules/collect-v8-coverage": { "version": "1.0.2", - "resolved": "https://registry.npmjs.org/collect-v8-coverage/-/collect-v8-coverage-1.0.2.tgz", - "integrity": "sha512-lHl4d5/ONEbLlJvaJNtsF/Lz+WvB07u2ycqTYbdrq7UypDXailES4valYb2eWiJFxZlVmpGekfqoxQhzyFdT4Q==", - "dev": true + "dev": true, + "license": "MIT" }, "node_modules/color-convert": { "version": "2.0.1", - "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", - "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", "dev": true, + "license": "MIT", "dependencies": { "color-name": "~1.1.4" }, @@ -3820,14 +3484,12 @@ }, "node_modules/color-name": { "version": "1.1.4", - "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", - "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", - "dev": true + "dev": true, + "license": "MIT" }, "node_modules/combined-stream": { "version": "1.0.8", - "resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.8.tgz", - "integrity": "sha512-FQN4MRfuJeHf7cBbBMJFXhKSDq+2kAArBlmRBvcvFE5BB1HZKXtSFASDhdlz9zOYwxh8lDdnvmMOe/+5cdoEdg==", + "license": "MIT", "dependencies": { "delayed-stream": "~1.0.0" }, @@ -3837,14 +3499,12 @@ }, "node_modules/concat-map": { "version": "0.0.1", - "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", - "integrity": "sha512-/Srv4dswyQNBfohGpz9o6Yb3Gz3SrUDqBH5rTuhGR7ahtlbYKnVxw2bCFMRljaA7EXHaXZ8wsHdodFvbkhKmqg==", - "dev": true + "dev": true, + "license": "MIT" }, "node_modules/content-disposition": { "version": "0.5.4", - "resolved": "https://registry.npmjs.org/content-disposition/-/content-disposition-0.5.4.tgz", - "integrity": "sha512-FveZTNuGw04cxlAiWbzi6zTAL/lhehaWbTtgluJh4/E95DqMwTmha3KZN1aAWA8cFIhHzMZUvLevkw5Rqk+tSQ==", + "license": "MIT", "dependencies": { "safe-buffer": "5.2.1" }, @@ -3854,8 +3514,7 @@ }, "node_modules/content-hash": { "version": "2.5.2", - "resolved": "https://registry.npmjs.org/content-hash/-/content-hash-2.5.2.tgz", - "integrity": "sha512-FvIQKy0S1JaWV10sMsA7TRx8bpU+pqPkhbsfvOJAdjRXvYxEckAwQWGwtRjiaJfh+E0DvcWUGqcdjwMGFjsSdw==", + "license": "ISC", "dependencies": { "cids": "^0.7.1", "multicodec": "^0.5.5", @@ -3864,40 +3523,34 @@ }, "node_modules/content-type": { "version": "1.0.5", - "resolved": "https://registry.npmjs.org/content-type/-/content-type-1.0.5.tgz", - "integrity": "sha512-nTjqfcBFEipKdXCv4YDQWCfmcLZKm81ldF0pAopTvyrFGVbcR6P/VAAd5G7N+0tTr8QqiU0tFadD6FK4NtJwOA==", + "license": "MIT", "engines": { "node": ">= 0.6" } }, "node_modules/convert-source-map": { "version": "1.9.0", - "resolved": "https://registry.npmjs.org/convert-source-map/-/convert-source-map-1.9.0.tgz", - "integrity": "sha512-ASFBup0Mz1uyiIjANan1jzLQami9z1PoYSZCiiYW2FczPbenXc45FZdBZLzOT+r6+iciuEModtmCti+hjaAk0A==", - "dev": true + "dev": true, + "license": "MIT" }, "node_modules/cookie": { "version": "0.5.0", - "resolved": "https://registry.npmjs.org/cookie/-/cookie-0.5.0.tgz", - "integrity": "sha512-YZ3GUyn/o8gfKJlnlX7g7xq4gyO6OSuhGPKaaGssGB2qgDUS0gPgtTvoyZLTt9Ab6dC4hfc9dV5arkvc/OCmrw==", + "license": "MIT", "engines": { "node": ">= 0.6" } }, "node_modules/cookie-signature": { "version": "1.0.6", - "resolved": "https://registry.npmjs.org/cookie-signature/-/cookie-signature-1.0.6.tgz", - "integrity": "sha512-QADzlaHc8icV8I7vbaJXJwod9HWYp8uCqf1xa4OfNu1T7JVxQIrUgOWtHdNDtPiywmFbiS12VjotIXLrKM3orQ==" + "license": "MIT" }, "node_modules/core-util-is": { "version": "1.0.2", - "resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.2.tgz", - "integrity": "sha512-3lqz5YjWTYnW6dlDa5TLaTCcShfar1e40rmcJVwCBJC6mWlFuj0eCHIElmG1g5kyuJ/GD+8Wn4FFCcz4gJPfaQ==" + "license": "MIT" }, "node_modules/cors": { "version": "2.8.5", - "resolved": "https://registry.npmjs.org/cors/-/cors-2.8.5.tgz", - "integrity": "sha512-KIHbLJqu73RGr/hnbrO9uBeixNGuvSQjul/jdFvS/KFSIH1hWVd1ng7zOHx+YrEfInLG7q4n6GHQ9cDtxv/P6g==", + "license": "MIT", "dependencies": { "object-assign": "^4", "vary": "^1" @@ -3907,9 +3560,8 @@ } }, "node_modules/cosmjs-types": { - "version": "0.4.1", - "resolved": "https://registry.npmjs.org/cosmjs-types/-/cosmjs-types-0.4.1.tgz", - "integrity": "sha512-I7E/cHkIgoJzMNQdFF0YVqPlaTqrqKHrskuSTIqlEyxfB5Lf3WKCajSXVK2yHOfOFfSux/RxEdpMzw/eO4DIog==", + "version": "0.8.0", + "license": "Apache-2.0", "dependencies": { "long": "^4.0.0", "protobufjs": "~6.11.2" @@ -3917,8 +3569,7 @@ }, "node_modules/crc-32": { "version": "1.2.2", - "resolved": "https://registry.npmjs.org/crc-32/-/crc-32-1.2.2.tgz", - "integrity": "sha512-ROmzCKrTnOwybPcJApAA6WBWij23HVfGVNKqqrZpuyZOHqK2CwHSvpGuyt/UNNvaIjEd8X5IFGp4Mh+Ie1IHJQ==", + "license": "Apache-2.0", "bin": { "crc32": "bin/crc32.njs" }, @@ -3928,8 +3579,7 @@ }, "node_modules/create-hash": { "version": "1.2.0", - "resolved": "https://registry.npmjs.org/create-hash/-/create-hash-1.2.0.tgz", - "integrity": "sha512-z00bCGNHDG8mHAkP7CtT1qVu+bFQUPjYq/4Iv3C3kWjTFV10zIjfSoeqXo9Asws8gwSHDGj/hl2u4OGIjapeCg==", + "license": "MIT", "dependencies": { "cipher-base": "^1.0.1", "inherits": "^2.0.1", @@ -3940,8 +3590,7 @@ }, "node_modules/create-hmac": { "version": "1.1.7", - "resolved": "https://registry.npmjs.org/create-hmac/-/create-hmac-1.1.7.tgz", - "integrity": "sha512-MJG9liiZ+ogc4TzUwuvbER1JRdgvUFSB5+VR/g5h82fGaIRWMWddtKBHi7/sVhfjQZ6SehlyhvQYrcYkaUIpLg==", + "license": "MIT", "dependencies": { "cipher-base": "^1.0.3", "create-hash": "^1.1.0", @@ -3953,28 +3602,24 @@ }, "node_modules/create-require": { "version": "1.1.1", - "resolved": "https://registry.npmjs.org/create-require/-/create-require-1.1.1.tgz", - "integrity": "sha512-dcKFX3jn0MpIaXjisoRvexIJVEKzaq7z2rZKxf+MSr9TkdmHmsU4m2lcLojrj/FHl8mk5VxMmYA+ftRkP/3oKQ==", - "dev": true + "dev": true, + "license": "MIT" }, "node_modules/credentials-context": { "version": "2.0.0", - "resolved": "https://registry.npmjs.org/credentials-context/-/credentials-context-2.0.0.tgz", - "integrity": "sha512-/mFKax6FK26KjgV2KW2D4YqKgoJ5DVJpNt87X2Jc9IxT2HBMy7nEIlc+n7pEi+YFFe721XqrvZPd+jbyyBjsvQ==" + "license": "SEE LICENSE IN LICENSE.md" }, "node_modules/cross-fetch": { "version": "4.0.0", - "resolved": "https://registry.npmjs.org/cross-fetch/-/cross-fetch-4.0.0.tgz", - "integrity": "sha512-e4a5N8lVvuLgAWgnCrLr2PP0YyDOTHa9H/Rj54dirp61qXnNq46m82bRhNqIA5VccJtWBvPTFRV3TtvHUKPB1g==", + "license": "MIT", "dependencies": { "node-fetch": "^2.6.12" } }, "node_modules/cross-spawn": { "version": "7.0.3", - "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.3.tgz", - "integrity": "sha512-iRDPJKUPVEND7dHPO8rkbOnPpyDygcDFtWjpeWNCgy8WP2rXcxXL8TskReQl6OrB2G7+UJrags1q15Fudc7G6w==", "dev": true, + "license": "MIT", "dependencies": { "path-key": "^3.1.0", "shebang-command": "^2.0.0", @@ -3986,16 +3631,14 @@ }, "node_modules/crypto-ld": { "version": "6.0.0", - "resolved": "https://registry.npmjs.org/crypto-ld/-/crypto-ld-6.0.0.tgz", - "integrity": "sha512-XWL1LslqggNoaCI/m3I7HcvaSt9b2tYzdrXO+jHLUj9G1BvRfvV7ZTFDVY5nifYuIGAPdAGu7unPxLRustw3VA==", + "license": "BSD-3-Clause", "engines": { "node": ">=8.3.0" } }, "node_modules/d": { "version": "1.0.1", - "resolved": "https://registry.npmjs.org/d/-/d-1.0.1.tgz", - "integrity": "sha512-m62ShEObQ39CfralilEQRjH6oAMtNCV1xJyEx5LpRYUVN+EviphDgUc/F3hnYbADmkiNs67Y+3ylmlG7Lnu+FA==", + "license": "ISC", "dependencies": { "es5-ext": "^0.10.50", "type": "^1.0.1" @@ -4003,8 +3646,7 @@ }, "node_modules/dashdash": { "version": "1.14.1", - "resolved": "https://registry.npmjs.org/dashdash/-/dashdash-1.14.1.tgz", - "integrity": "sha512-jRFi8UDGo6j+odZiEpjazZaWqEal3w/basFjQHQEwVtZJGDpxbH1MeYluwCS8Xq5wmLJooDlMgvVarmWfGM44g==", + "license": "MIT", "dependencies": { "assert-plus": "^1.0.0" }, @@ -4014,17 +3656,15 @@ }, "node_modules/data-uri-to-buffer": { "version": "3.0.1", - "resolved": "https://registry.npmjs.org/data-uri-to-buffer/-/data-uri-to-buffer-3.0.1.tgz", - "integrity": "sha512-WboRycPNsVw3B3TL559F7kuBUM4d8CgMEvk6xEJlOp7OBPjt6G7z8WMWlD2rOFZLk6OYfFIUGsCOWzcQH9K2og==", + "license": "MIT", "engines": { "node": ">= 6" } }, "node_modules/debug": { "version": "4.3.4", - "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.4.tgz", - "integrity": "sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ==", "dev": true, + "license": "MIT", "dependencies": { "ms": "2.1.2" }, @@ -4039,9 +3679,8 @@ }, "node_modules/decamelize": { "version": "4.0.0", - "resolved": "https://registry.npmjs.org/decamelize/-/decamelize-4.0.0.tgz", - "integrity": "sha512-9iE1PgSik9HeIIw2JO94IidnE3eBoQrFJ3w7sFuzSX4DpmZ3v5sZpUiV5Swcf6mQEF+Y0ru8Neo+p+nyh2J+hQ==", "dev": true, + "license": "MIT", "engines": { "node": ">=10" }, @@ -4051,16 +3690,14 @@ }, "node_modules/decode-uri-component": { "version": "0.2.2", - "resolved": "https://registry.npmjs.org/decode-uri-component/-/decode-uri-component-0.2.2.tgz", - "integrity": "sha512-FqUYQ+8o158GyGTrMFJms9qh3CqTKvAqgqsTnkLI8sKu0028orqBhxNMFkFen0zGyg6epACD32pjVk58ngIErQ==", + "license": "MIT", "engines": { "node": ">=0.10" } }, "node_modules/decompress-response": { "version": "6.0.0", - "resolved": "https://registry.npmjs.org/decompress-response/-/decompress-response-6.0.0.tgz", - "integrity": "sha512-aW35yZM6Bb/4oJlZncMH2LCoZtJXTRxES17vE3hoRiowU2kWHaJKFkSBDnDR+cm9J+9QhXmREyIfv0pji9ejCQ==", + "license": "MIT", "dependencies": { "mimic-response": "^3.1.0" }, @@ -4073,8 +3710,7 @@ }, "node_modules/decompress-response/node_modules/mimic-response": { "version": "3.1.0", - "resolved": "https://registry.npmjs.org/mimic-response/-/mimic-response-3.1.0.tgz", - "integrity": "sha512-z0yWI+4FDrrweS8Zmt4Ej5HdJmky15+L2e6Wgn3+iK5fWzb6T3fhNFq2+MeTRb064c6Wr4N/wv0DzQTjNzHNGQ==", + "license": "MIT", "engines": { "node": ">=10" }, @@ -4084,15 +3720,13 @@ }, "node_modules/dedent": { "version": "0.7.0", - "resolved": "https://registry.npmjs.org/dedent/-/dedent-0.7.0.tgz", - "integrity": "sha512-Q6fKUPqnAHAyhiUgFU7BUzLiv0kd8saH9al7tnu5Q/okj6dnupxyTgFIBjVzJATdfIAm9NAsvXNzjaKa+bxVyA==", - "dev": true + "dev": true, + "license": "MIT" }, "node_modules/deep-eql": { "version": "4.1.3", - "resolved": "https://registry.npmjs.org/deep-eql/-/deep-eql-4.1.3.tgz", - "integrity": "sha512-WaEtAOpRA1MQ0eohqZjpGD8zdI0Ovsm8mmFhaDN8dvDZzyoUMcYDnf5Y6iu7HTXxf8JDS23qWa4a+hKCDyOPzw==", "dev": true, + "license": "MIT", "dependencies": { "type-detect": "^4.0.0" }, @@ -4102,32 +3736,41 @@ }, "node_modules/deep-is": { "version": "0.1.4", - "resolved": "https://registry.npmjs.org/deep-is/-/deep-is-0.1.4.tgz", - "integrity": "sha512-oIPzksmTg4/MriiaYGO+okXDT7ztn/w3Eptv/+gSIdMdKsJo0u4CfYNFJPy+4SKMuCqGw2wxnA+URMg3t8a/bQ==", - "dev": true + "dev": true, + "license": "MIT" }, "node_modules/deepmerge": { "version": "4.3.1", - "resolved": "https://registry.npmjs.org/deepmerge/-/deepmerge-4.3.1.tgz", - "integrity": "sha512-3sUqbMEc77XqpdNO7FRyRog+eW3ph+GYCbj+rK+uYyRMuwsVy0rMiVtPn+QJlKFvWP/1PYpapqYn0Me2knFn+A==", "dev": true, + "license": "MIT", "engines": { "node": ">=0.10.0" } }, "node_modules/defer-to-connect": { "version": "2.0.1", - "resolved": "https://registry.npmjs.org/defer-to-connect/-/defer-to-connect-2.0.1.tgz", - "integrity": "sha512-4tvttepXG1VaYGrRibk5EwJd1t4udunSOVMdLSAL6mId1ix438oPwPZMALY41FCijukO1L0twNcGsdzS7dHgDg==", + "license": "MIT", "engines": { "node": ">=10" } }, + "node_modules/define-data-property": { + "version": "1.1.1", + "license": "MIT", + "dependencies": { + "get-intrinsic": "^1.2.1", + "gopd": "^1.0.1", + "has-property-descriptors": "^1.0.0" + }, + "engines": { + "node": ">= 0.4" + } + }, "node_modules/define-properties": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/define-properties/-/define-properties-1.2.0.tgz", - "integrity": "sha512-xvqAVKGfT1+UAvPwKTVw/njhdQ8ZhXK4lI0bCIuCMrp2up9nPnaDftrLtmpTazqd1o+UY4zgzU+avtMbDP+ldA==", + "version": "1.2.1", + "license": "MIT", "dependencies": { + "define-data-property": "^1.0.1", "has-property-descriptors": "^1.0.0", "object-keys": "^1.1.1" }, @@ -4140,24 +3783,21 @@ }, "node_modules/delayed-stream": { "version": "1.0.0", - "resolved": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz", - "integrity": "sha512-ZySD7Nf91aLB0RxL4KGrKHBXl7Eds1DAmEdcoVawXnLD7SDhpNgtuII2aAkg7a7QS41jxPSZ17p4VdGnMHk3MQ==", + "license": "MIT", "engines": { "node": ">=0.4.0" } }, "node_modules/depd": { "version": "2.0.0", - "resolved": "https://registry.npmjs.org/depd/-/depd-2.0.0.tgz", - "integrity": "sha512-g7nH6P6dyDioJogAAGprGpCtVImJhpPk/roCzdb3fIh61/s/nPsfR6onyMwkCAR/OlC3yBC0lESvUoQEAssIrw==", + "license": "MIT", "engines": { "node": ">= 0.8" } }, "node_modules/destroy": { "version": "1.2.0", - "resolved": "https://registry.npmjs.org/destroy/-/destroy-1.2.0.tgz", - "integrity": "sha512-2sJGJTaXIIaR1w4iJSNoN0hnMY7Gpc/n8D4qSCJw8QqFWXf7cuAgnEHxBpweaVcPevC2l3KpjYCx3NypQQgaJg==", + "license": "MIT", "engines": { "node": ">= 0.8", "npm": "1.2.8000 || >= 1.4.16" @@ -4165,36 +3805,32 @@ }, "node_modules/detect-newline": { "version": "3.1.0", - "resolved": "https://registry.npmjs.org/detect-newline/-/detect-newline-3.1.0.tgz", - "integrity": "sha512-TLz+x/vEXm/Y7P7wn1EJFNLxYpUD4TgMosxY6fAVJUnJMbupHBOncxyWUG9OpTaH9EBD7uFI5LfEgmMOc54DsA==", "dev": true, + "license": "MIT", "engines": { "node": ">=8" } }, "node_modules/diff": { "version": "5.0.0", - "resolved": "https://registry.npmjs.org/diff/-/diff-5.0.0.tgz", - "integrity": "sha512-/VTCrvm5Z0JGty/BWHljh+BAiw3IK+2j87NGMu8Nwc/f48WoDAC395uomO9ZD117ZOBaHmkX1oyLvkVM/aIT3w==", "dev": true, + "license": "BSD-3-Clause", "engines": { "node": ">=0.3.1" } }, "node_modules/diff-sequences": { "version": "28.1.1", - "resolved": "https://registry.npmjs.org/diff-sequences/-/diff-sequences-28.1.1.tgz", - "integrity": "sha512-FU0iFaH/E23a+a718l8Qa/19bF9p06kgE0KipMOMadwa3SjnaElKzPaUC0vnibs6/B/9ni97s61mcejk8W1fQw==", "dev": true, + "license": "MIT", "engines": { "node": "^12.13.0 || ^14.15.0 || ^16.10.0 || >=17.0.0" } }, "node_modules/dir-glob": { "version": "3.0.1", - "resolved": "https://registry.npmjs.org/dir-glob/-/dir-glob-3.0.1.tgz", - "integrity": "sha512-WkrWp9GR4KXfKGYzOLmTuGVi1UWFfws377n9cc55/tb6DuqyF6pcQ5AbiHEshaDpY9v6oaSr2XCDidGmMwdzIA==", "dev": true, + "license": "MIT", "dependencies": { "path-type": "^4.0.0" }, @@ -4204,9 +3840,8 @@ }, "node_modules/doctrine": { "version": "3.0.0", - "resolved": "https://registry.npmjs.org/doctrine/-/doctrine-3.0.0.tgz", - "integrity": "sha512-yS+Q5i3hBf7GBkd4KG8a7eBNNWNGLTaEwwYWUijIYM7zrlYDM0BFXHjjPWlWZ1Rg7UaddZeIDmi9jF3HmqiQ2w==", "dev": true, + "license": "Apache-2.0", "dependencies": { "esutils": "^2.0.2" }, @@ -4215,14 +3850,11 @@ } }, "node_modules/dom-walk": { - "version": "0.1.2", - "resolved": "https://registry.npmjs.org/dom-walk/-/dom-walk-0.1.2.tgz", - "integrity": "sha512-6QvTW9mrGeIegrFXdtQi9pk7O/nSK6lSdXW2eqUspN5LWD7UTji2Fqw5V2YLjBpHEoU9Xl/eUWNpDeZvoyOv2w==" + "version": "0.1.2" }, "node_modules/ecc-jsbn": { "version": "0.1.2", - "resolved": "https://registry.npmjs.org/ecc-jsbn/-/ecc-jsbn-0.1.2.tgz", - "integrity": "sha512-eh9O+hwRHNbG4BLTjEl3nw044CkGm5X6LoaCf7LPp7UU8Qrt47JYNi6nPX8xjW97TKGKm1ouctg0QSpZe9qrnw==", + "license": "MIT", "dependencies": { "jsbn": "~0.1.0", "safer-buffer": "^2.1.0" @@ -4230,37 +3862,31 @@ }, "node_modules/ecdsa-sig-formatter": { "version": "1.0.11", - "resolved": "https://registry.npmjs.org/ecdsa-sig-formatter/-/ecdsa-sig-formatter-1.0.11.tgz", - "integrity": "sha512-nagl3RYrbNv6kQkeJIpt6NJZy8twLB/2vtz6yN9Z4vRKHN4/QZJIEbqohALSgwKdnksuY3k5Addp5lg8sVoVcQ==", + "license": "Apache-2.0", "dependencies": { "safe-buffer": "^5.0.1" } }, "node_modules/ed25519-signature-2018-context": { "version": "1.1.0", - "resolved": "https://registry.npmjs.org/ed25519-signature-2018-context/-/ed25519-signature-2018-context-1.1.0.tgz", - "integrity": "sha512-ppDWYMNwwp9bploq0fS4l048vHIq41nWsAbPq6H4mNVx9G/GxW3fwg4Ln0mqctP13MoEpREK7Biz8TbVVdYXqA==" + "license": "BSD-3-Clause" }, "node_modules/ed25519-signature-2020-context": { "version": "1.1.0", - "resolved": "https://registry.npmjs.org/ed25519-signature-2020-context/-/ed25519-signature-2020-context-1.1.0.tgz", - "integrity": "sha512-dBGSmoUIK6h2vadDctrDnhhTO01PR2hJk0mRNEfrRDPCjaIwrfy4J+eziEQ9Q1m8By4f/CSRgKM1h53ydKfdNg==" + "license": "BSD-3-Clause" }, "node_modules/ee-first": { "version": "1.1.1", - "resolved": "https://registry.npmjs.org/ee-first/-/ee-first-1.1.1.tgz", - "integrity": "sha512-WMwm9LhRUo+WUaRN+vRuETqG89IgZphVSNkdFgeb6sS/E4OrDIN7t48CAewSHXc6C8lefD8KKfr5vY61brQlow==" + "license": "MIT" }, "node_modules/electron-to-chromium": { - "version": "1.4.510", - "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.4.510.tgz", - "integrity": "sha512-xPfLIPFcN/WLXBpQ/K4UgE98oUBO5Tia6BD4rkSR0wE7ep/PwBVlgvPJQrIBpmJGVAmUzwPKuDbVt9XV6+uC2g==", - "dev": true + "version": "1.4.616", + "dev": true, + "license": "ISC" }, "node_modules/elliptic": { "version": "6.5.4", - "resolved": "https://registry.npmjs.org/elliptic/-/elliptic-6.5.4.tgz", - "integrity": "sha512-iLhC6ULemrljPZb+QutR5TQGB+pdW6KGD5RSegS+8sorOZT+rdQFbsQFJgvN3eRqNALqJer4oQ16YvJHlU8hzQ==", + "license": "MIT", "dependencies": { "bn.js": "^4.11.9", "brorand": "^1.1.0", @@ -4273,14 +3899,12 @@ }, "node_modules/elliptic/node_modules/bn.js": { "version": "4.12.0", - "resolved": "https://registry.npmjs.org/bn.js/-/bn.js-4.12.0.tgz", - "integrity": "sha512-c98Bf3tPniI+scsdk237ku1Dc3ujXQTSgyiPUDEOe7tRkhrqridvh8klBv0HCEso1OLOYcHuCv/cS6DNxKH+ZA==" + "license": "MIT" }, "node_modules/emittery": { "version": "0.10.2", - "resolved": "https://registry.npmjs.org/emittery/-/emittery-0.10.2.tgz", - "integrity": "sha512-aITqOwnLanpHLNXZJENbOgjUBeHocD+xsSJmNrjovKBW5HbSpW3d1pEls7GFQPUWXiwG9+0P4GtHfEqC/4M0Iw==", "dev": true, + "license": "MIT", "engines": { "node": ">=12" }, @@ -4290,31 +3914,27 @@ }, "node_modules/emoji-regex": { "version": "8.0.0", - "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-8.0.0.tgz", - "integrity": "sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==", - "dev": true + "dev": true, + "license": "MIT" }, "node_modules/encodeurl": { "version": "1.0.2", - "resolved": "https://registry.npmjs.org/encodeurl/-/encodeurl-1.0.2.tgz", - "integrity": "sha512-TPJXq8JqFaVYm2CWmPvnP2Iyo4ZSM7/QKcSmuMLDObfpH5fi7RUGmd/rTDf+rut/saiDiQEeVTNgAmJEdAOx0w==", + "license": "MIT", "engines": { "node": ">= 0.8" } }, "node_modules/end-of-stream": { "version": "1.4.4", - "resolved": "https://registry.npmjs.org/end-of-stream/-/end-of-stream-1.4.4.tgz", - "integrity": "sha512-+uw1inIHVPQoaVuHzRyXd21icM+cnt4CzD5rW+NC1wjOUSTOs+Te7FOv7AhN7vS9x/oIyhLP5PR1H+phQAHu5Q==", + "license": "MIT", "dependencies": { "once": "^1.4.0" } }, "node_modules/enquirer": { "version": "2.4.1", - "resolved": "https://registry.npmjs.org/enquirer/-/enquirer-2.4.1.tgz", - "integrity": "sha512-rRqJg/6gd538VHvR3PSrdRBb/1Vy2YfzHqzvbhGIQpDRKIa4FgV/54b5Q1xYSxOOwKvjXweS26E0Q+nAMwp2pQ==", "dev": true, + "license": "MIT", "dependencies": { "ansi-colors": "^4.1.1", "strip-ansi": "^6.0.1" @@ -4325,33 +3945,31 @@ }, "node_modules/error-ex": { "version": "1.3.2", - "resolved": "https://registry.npmjs.org/error-ex/-/error-ex-1.3.2.tgz", - "integrity": "sha512-7dFHNmqeFSEt2ZBsCriorKnn3Z2pj+fd9kmI6QoWw4//DL+icEBfc0U7qJCisqrTsKTjw4fNFy2pW9OqStD84g==", "dev": true, + "license": "MIT", "dependencies": { "is-arrayish": "^0.2.1" } }, "node_modules/es-abstract": { - "version": "1.22.1", - "resolved": "https://registry.npmjs.org/es-abstract/-/es-abstract-1.22.1.tgz", - "integrity": "sha512-ioRRcXMO6OFyRpyzV3kE1IIBd4WG5/kltnzdxSCqoP8CMGs/Li+M1uF5o7lOkZVFjDs+NLesthnF66Pg/0q0Lw==", + "version": "1.22.3", + "license": "MIT", "dependencies": { "array-buffer-byte-length": "^1.0.0", - "arraybuffer.prototype.slice": "^1.0.1", + "arraybuffer.prototype.slice": "^1.0.2", "available-typed-arrays": "^1.0.5", - "call-bind": "^1.0.2", + "call-bind": "^1.0.5", "es-set-tostringtag": "^2.0.1", "es-to-primitive": "^1.2.1", - "function.prototype.name": "^1.1.5", - "get-intrinsic": "^1.2.1", + "function.prototype.name": "^1.1.6", + "get-intrinsic": "^1.2.2", "get-symbol-description": "^1.0.0", "globalthis": "^1.0.3", "gopd": "^1.0.1", - "has": "^1.0.3", "has-property-descriptors": "^1.0.0", "has-proto": "^1.0.1", "has-symbols": "^1.0.3", + "hasown": "^2.0.0", "internal-slot": "^1.0.5", "is-array-buffer": "^3.0.2", "is-callable": "^1.2.7", @@ -4359,23 +3977,23 @@ "is-regex": "^1.1.4", "is-shared-array-buffer": "^1.0.2", "is-string": "^1.0.7", - "is-typed-array": "^1.1.10", + "is-typed-array": "^1.1.12", "is-weakref": "^1.0.2", - "object-inspect": "^1.12.3", + "object-inspect": "^1.13.1", "object-keys": "^1.1.1", "object.assign": "^4.1.4", - "regexp.prototype.flags": "^1.5.0", - "safe-array-concat": "^1.0.0", + "regexp.prototype.flags": "^1.5.1", + "safe-array-concat": "^1.0.1", "safe-regex-test": "^1.0.0", - "string.prototype.trim": "^1.2.7", - "string.prototype.trimend": "^1.0.6", - "string.prototype.trimstart": "^1.0.6", + "string.prototype.trim": "^1.2.8", + "string.prototype.trimend": "^1.0.7", + "string.prototype.trimstart": "^1.0.7", "typed-array-buffer": "^1.0.0", "typed-array-byte-length": "^1.0.0", "typed-array-byte-offset": "^1.0.0", "typed-array-length": "^1.0.4", "unbox-primitive": "^1.0.2", - "which-typed-array": "^1.1.10" + "which-typed-array": "^1.1.13" }, "engines": { "node": ">= 0.4" @@ -4385,13 +4003,12 @@ } }, "node_modules/es-set-tostringtag": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/es-set-tostringtag/-/es-set-tostringtag-2.0.1.tgz", - "integrity": "sha512-g3OMbtlwY3QewlqAiMLI47KywjWZoEytKr8pf6iTC8uJq5bIAH52Z9pnQ8pVL6whrCto53JZDuUIsifGeLorTg==", + "version": "2.0.2", + "license": "MIT", "dependencies": { - "get-intrinsic": "^1.1.3", - "has": "^1.0.3", - "has-tostringtag": "^1.0.0" + "get-intrinsic": "^1.2.2", + "has-tostringtag": "^1.0.0", + "hasown": "^2.0.0" }, "engines": { "node": ">= 0.4" @@ -4399,8 +4016,7 @@ }, "node_modules/es-to-primitive": { "version": "1.2.1", - "resolved": "https://registry.npmjs.org/es-to-primitive/-/es-to-primitive-1.2.1.tgz", - "integrity": "sha512-QCOllgZJtaUo9miYBcLChTUaHNjJF3PYs1VidD7AwiEj1kYxKeQTctLAezAOH5ZKRH0g2IgPn6KwB4IT8iRpvA==", + "license": "MIT", "dependencies": { "is-callable": "^1.1.4", "is-date-object": "^1.0.1", @@ -4415,9 +4031,8 @@ }, "node_modules/es5-ext": { "version": "0.10.62", - "resolved": "https://registry.npmjs.org/es5-ext/-/es5-ext-0.10.62.tgz", - "integrity": "sha512-BHLqn0klhEpnOKSrzn/Xsz2UIW8j+cGmo9JLzr8BiUapV8hPL9+FliFqjwr9ngW7jWdnxv6eO+/LqyhJVqgrjA==", "hasInstallScript": true, + "license": "ISC", "dependencies": { "es6-iterator": "^2.0.3", "es6-symbol": "^3.1.3", @@ -4429,8 +4044,7 @@ }, "node_modules/es6-iterator": { "version": "2.0.3", - "resolved": "https://registry.npmjs.org/es6-iterator/-/es6-iterator-2.0.3.tgz", - "integrity": "sha512-zw4SRzoUkd+cl+ZoE15A9o1oQd920Bb0iOJMQkQhl3jNc03YqVjAhG7scf9C5KWRU/R13Orf588uCC6525o02g==", + "license": "MIT", "dependencies": { "d": "1", "es5-ext": "^0.10.35", @@ -4439,13 +4053,11 @@ }, "node_modules/es6-promise": { "version": "4.2.8", - "resolved": "https://registry.npmjs.org/es6-promise/-/es6-promise-4.2.8.tgz", - "integrity": "sha512-HJDGx5daxeIvxdBxvG2cb9g4tEvwIk3i8+nhX0yGrYmZUzbkdg8QbDevheDB8gd0//uPj4c1EQua8Q+MViT0/w==" + "license": "MIT" }, "node_modules/es6-symbol": { "version": "3.1.3", - "resolved": "https://registry.npmjs.org/es6-symbol/-/es6-symbol-3.1.3.tgz", - "integrity": "sha512-NJ6Yn3FuDinBaBRWl/q5X/s4koRHBrgKAu+yGI6JCBeiu3qrcbJhwT2GeR/EXVfylRk8dpQVJoLEFhK+Mu31NA==", + "license": "ISC", "dependencies": { "d": "^1.0.1", "ext": "^1.1.2" @@ -4453,23 +4065,20 @@ }, "node_modules/escalade": { "version": "3.1.1", - "resolved": "https://registry.npmjs.org/escalade/-/escalade-3.1.1.tgz", - "integrity": "sha512-k0er2gUkLf8O0zKJiAhmkTnJlTvINGv7ygDNPbeIsX/TJjGJZHuh9B2UxbsaEkmlEo9MfhrSzmhIlhRlI2GXnw==", "dev": true, + "license": "MIT", "engines": { "node": ">=6" } }, "node_modules/escape-html": { "version": "1.0.3", - "resolved": "https://registry.npmjs.org/escape-html/-/escape-html-1.0.3.tgz", - "integrity": "sha512-NiSupZ4OeuGwr68lGIeym/ksIZMJodUGOSCZ/FSnTxcrekbvqrgdUxlJOMpijaKZVjAJrWrGs/6Jy8OMuyj9ow==" + "license": "MIT" }, "node_modules/escape-string-regexp": { "version": "4.0.0", - "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-4.0.0.tgz", - "integrity": "sha512-TtpcNJ3XAzx3Gq8sWRzJaVajRs0uVxA2YAkdb1jm2YkPz4G6egUFAyA3n5vtEIZefPk5Wa4UXbKuS5fKkJWdgA==", "dev": true, + "license": "MIT", "engines": { "node": ">=10" }, @@ -4479,9 +4088,8 @@ }, "node_modules/eslint": { "version": "7.32.0", - "resolved": "https://registry.npmjs.org/eslint/-/eslint-7.32.0.tgz", - "integrity": "sha512-VHZ8gX+EDfz+97jGcgyGCyRia/dPOd6Xh9yPv8Bl1+SoaIwD+a/vlrOmGRUyOYu7MwUhc7CxqeaDZU13S4+EpA==", "dev": true, + "license": "MIT", "dependencies": { "@babel/code-frame": "7.12.11", "@eslint/eslintrc": "^0.4.3", @@ -4536,9 +4144,8 @@ }, "node_modules/eslint-scope": { "version": "5.1.1", - "resolved": "https://registry.npmjs.org/eslint-scope/-/eslint-scope-5.1.1.tgz", - "integrity": "sha512-2NxwbF/hZ0KpepYN0cNbo+FN6XoK7GaHlQhgx/hIZl6Va0bF45RQOOwhLIy8lQDbuCiadSLCBnH2CFYquit5bw==", "dev": true, + "license": "BSD-2-Clause", "dependencies": { "esrecurse": "^4.3.0", "estraverse": "^4.1.1" @@ -4549,9 +4156,8 @@ }, "node_modules/eslint-utils": { "version": "2.1.0", - "resolved": "https://registry.npmjs.org/eslint-utils/-/eslint-utils-2.1.0.tgz", - "integrity": "sha512-w94dQYoauyvlDc43XnGB8lU3Zt713vNChgt4EWwhXAP2XkBvndfxF0AgIqKOOasjPIPzj9JqgwkwbCYD0/V3Zg==", "dev": true, + "license": "MIT", "dependencies": { "eslint-visitor-keys": "^1.1.0" }, @@ -4564,18 +4170,16 @@ }, "node_modules/eslint-utils/node_modules/eslint-visitor-keys": { "version": "1.3.0", - "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-1.3.0.tgz", - "integrity": "sha512-6J72N8UNa462wa/KFODt/PJ3IU60SDpC3QXC1Hjc1BXXpfL2C9R5+AU7jhe0F6GREqVMh4Juu+NY7xn+6dipUQ==", "dev": true, + "license": "Apache-2.0", "engines": { "node": ">=4" } }, "node_modules/eslint-visitor-keys": { "version": "3.4.3", - "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-3.4.3.tgz", - "integrity": "sha512-wpc+LXeiyiisxPlEkUzU6svyS1frIO3Mgxj1fdy7Pm8Ygzguax2N3Fa/D/ag1WqbOprdI+uY6wMUl8/a2G+iag==", "dev": true, + "license": "Apache-2.0", "engines": { "node": "^12.22.0 || ^14.17.0 || >=16.0.0" }, @@ -4585,35 +4189,31 @@ }, "node_modules/eslint/node_modules/eslint-visitor-keys": { "version": "2.1.0", - "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-2.1.0.tgz", - "integrity": "sha512-0rSmRBzXgDzIsD6mGdJgevzgezI534Cer5L/vyMX0kHzT/jiB43jRhd9YUlMGYLQy2zprNmoT8qasCGtY+QaKw==", "dev": true, + "license": "Apache-2.0", "engines": { "node": ">=10" } }, "node_modules/eslint/node_modules/ignore": { "version": "4.0.6", - "resolved": "https://registry.npmjs.org/ignore/-/ignore-4.0.6.tgz", - "integrity": "sha512-cyFDKrqc/YdcWFniJhzI42+AzS+gNwmUzOSFcRCQYwySuBBBy/KjuxWLZ/FHEH6Moq1NizMOBWyTcv8O4OZIMg==", "dev": true, + "license": "MIT", "engines": { "node": ">= 4" } }, "node_modules/esm": { "version": "3.2.25", - "resolved": "https://registry.npmjs.org/esm/-/esm-3.2.25.tgz", - "integrity": "sha512-U1suiZ2oDVWv4zPO56S0NcR5QriEahGtdN2OR6FiOG4WJvcjBVFB0qI4+eKoWFH483PKGuLuu6V8Z4T5g63UVA==", + "license": "MIT", "engines": { "node": ">=6" } }, "node_modules/espree": { "version": "7.3.1", - "resolved": "https://registry.npmjs.org/espree/-/espree-7.3.1.tgz", - "integrity": "sha512-v3JCNCE64umkFpmkFGqzVKsOT0tN1Zr+ueqLZfpV1Ob8e+CEgPWa+OxCoGH3tnhimMKIaBm4m/vaRpJ/krRz2g==", "dev": true, + "license": "BSD-2-Clause", "dependencies": { "acorn": "^7.4.0", "acorn-jsx": "^5.3.1", @@ -4625,18 +4225,16 @@ }, "node_modules/espree/node_modules/eslint-visitor-keys": { "version": "1.3.0", - "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-1.3.0.tgz", - "integrity": "sha512-6J72N8UNa462wa/KFODt/PJ3IU60SDpC3QXC1Hjc1BXXpfL2C9R5+AU7jhe0F6GREqVMh4Juu+NY7xn+6dipUQ==", "dev": true, + "license": "Apache-2.0", "engines": { "node": ">=4" } }, "node_modules/esprima": { "version": "4.0.1", - "resolved": "https://registry.npmjs.org/esprima/-/esprima-4.0.1.tgz", - "integrity": "sha512-eGuFFw7Upda+g4p+QHvnW0RyTX/SVeJBDM/gCtMARO0cLuT2HcEKnTPvhjV6aGeqrCB/sbNop0Kszm0jsaWU4A==", "dev": true, + "license": "BSD-2-Clause", "bin": { "esparse": "bin/esparse.js", "esvalidate": "bin/esvalidate.js" @@ -4647,9 +4245,8 @@ }, "node_modules/esquery": { "version": "1.5.0", - "resolved": "https://registry.npmjs.org/esquery/-/esquery-1.5.0.tgz", - "integrity": "sha512-YQLXUplAwJgCydQ78IMJywZCceoqk1oH01OERdSAJc/7U2AylwjhSCLDEtqwg811idIS/9fIU5GjG73IgjKMVg==", "dev": true, + "license": "BSD-3-Clause", "dependencies": { "estraverse": "^5.1.0" }, @@ -4659,18 +4256,16 @@ }, "node_modules/esquery/node_modules/estraverse": { "version": "5.3.0", - "resolved": "https://registry.npmjs.org/estraverse/-/estraverse-5.3.0.tgz", - "integrity": "sha512-MMdARuVEQziNTeJD8DgMqmhwR11BRQ/cBP+pLtYdSTnf3MIO8fFeiINEbX36ZdNlfU/7A9f3gUw49B3oQsvwBA==", "dev": true, + "license": "BSD-2-Clause", "engines": { "node": ">=4.0" } }, "node_modules/esrecurse": { "version": "4.3.0", - "resolved": "https://registry.npmjs.org/esrecurse/-/esrecurse-4.3.0.tgz", - "integrity": "sha512-KmfKL3b6G+RXvP8N1vr3Tq1kL/oCFgn2NYXEtqP8/L3pKapUA4G8cFVaoF3SU323CD4XypR/ffioHmkti6/Tag==", "dev": true, + "license": "BSD-2-Clause", "dependencies": { "estraverse": "^5.2.0" }, @@ -4680,43 +4275,38 @@ }, "node_modules/esrecurse/node_modules/estraverse": { "version": "5.3.0", - "resolved": "https://registry.npmjs.org/estraverse/-/estraverse-5.3.0.tgz", - "integrity": "sha512-MMdARuVEQziNTeJD8DgMqmhwR11BRQ/cBP+pLtYdSTnf3MIO8fFeiINEbX36ZdNlfU/7A9f3gUw49B3oQsvwBA==", "dev": true, + "license": "BSD-2-Clause", "engines": { "node": ">=4.0" } }, "node_modules/estraverse": { "version": "4.3.0", - "resolved": "https://registry.npmjs.org/estraverse/-/estraverse-4.3.0.tgz", - "integrity": "sha512-39nnKffWz8xN1BU/2c79n9nB9HDzo0niYUqx6xyqUnyoAnQyyWpOTdZEeiCch8BBu515t4wp9ZmgVfVhn9EBpw==", "dev": true, + "license": "BSD-2-Clause", "engines": { "node": ">=4.0" } }, "node_modules/esutils": { "version": "2.0.3", - "resolved": "https://registry.npmjs.org/esutils/-/esutils-2.0.3.tgz", - "integrity": "sha512-kVscqXk4OCp68SZ0dkgEKVi6/8ij300KBWTJq32P/dYeWTSwK41WyTxalN1eRmA5Z9UU/LX9D7FWSmV9SAYx6g==", "dev": true, + "license": "BSD-2-Clause", "engines": { "node": ">=0.10.0" } }, "node_modules/etag": { "version": "1.8.1", - "resolved": "https://registry.npmjs.org/etag/-/etag-1.8.1.tgz", - "integrity": "sha512-aIL5Fx7mawVa300al2BnEE4iNvo1qETxLrPI/o05L7z6go7fCw1J6EQmbK4FmJ2AS7kgVF/KEZWufBfdClMcPg==", + "license": "MIT", "engines": { "node": ">= 0.6" } }, "node_modules/eth-ens-namehash": { "version": "2.0.8", - "resolved": "https://registry.npmjs.org/eth-ens-namehash/-/eth-ens-namehash-2.0.8.tgz", - "integrity": "sha512-VWEI1+KJfz4Km//dadyvBBoBeSQ0MHTXPvr8UIXiLW6IanxvAV+DmlZAijZwAyggqGUfwQBeHf7tc9wzc1piSw==", + "license": "ISC", "dependencies": { "idna-uts46-hx": "^2.3.1", "js-sha3": "^0.5.7" @@ -4724,13 +4314,11 @@ }, "node_modules/eth-ens-namehash/node_modules/js-sha3": { "version": "0.5.7", - "resolved": "https://registry.npmjs.org/js-sha3/-/js-sha3-0.5.7.tgz", - "integrity": "sha512-GII20kjaPX0zJ8wzkTbNDYMY7msuZcTWk8S5UOh6806Jq/wz1J8/bnr8uGU0DAUmYDjj2Mr4X1cW8v/GLYnR+g==" + "license": "MIT" }, "node_modules/eth-lib": { "version": "0.1.29", - "resolved": "https://registry.npmjs.org/eth-lib/-/eth-lib-0.1.29.tgz", - "integrity": "sha512-bfttrr3/7gG4E02HoWTDUcDDslN003OlOoBxk9virpAZQ1ja/jDgwkWB8QfJF7ojuEowrqy+lzp9VcJG7/k5bQ==", + "license": "MIT", "dependencies": { "bn.js": "^4.11.6", "elliptic": "^6.4.0", @@ -4742,18 +4330,15 @@ }, "node_modules/eth-lib/node_modules/bn.js": { "version": "4.12.0", - "resolved": "https://registry.npmjs.org/bn.js/-/bn.js-4.12.0.tgz", - "integrity": "sha512-c98Bf3tPniI+scsdk237ku1Dc3ujXQTSgyiPUDEOe7tRkhrqridvh8klBv0HCEso1OLOYcHuCv/cS6DNxKH+ZA==" + "license": "MIT" }, "node_modules/eth-lib/node_modules/safe-buffer": { "version": "5.1.2", - "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz", - "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==" + "license": "MIT" }, "node_modules/eth-lib/node_modules/ws": { "version": "3.3.3", - "resolved": "https://registry.npmjs.org/ws/-/ws-3.3.3.tgz", - "integrity": "sha512-nnWLa/NwZSt4KQJu51MYlCcSQ5g7INpOrOMt4XV8j4dqTXdmlUmSHQ8/oLC069ckre0fRsgfvsKwbTdtKLCDkA==", + "license": "MIT", "dependencies": { "async-limiter": "~1.0.0", "safe-buffer": "~5.1.0", @@ -4762,9 +4347,7 @@ }, "node_modules/eth-sig-util": { "version": "3.0.1", - "resolved": "https://registry.npmjs.org/eth-sig-util/-/eth-sig-util-3.0.1.tgz", - "integrity": "sha512-0Us50HiGGvZgjtWTyAI/+qTzYPMLy5Q451D0Xy68bxq1QMWdoOddDwGvsqcFT27uohKgalM9z/yxplyt+mY2iQ==", - "deprecated": "Deprecated in favor of '@metamask/eth-sig-util'", + "license": "ISC", "dependencies": { "ethereumjs-abi": "^0.6.8", "ethereumjs-util": "^5.1.1", @@ -4774,16 +4357,14 @@ }, "node_modules/ethereum-bloom-filters": { "version": "1.0.10", - "resolved": "https://registry.npmjs.org/ethereum-bloom-filters/-/ethereum-bloom-filters-1.0.10.tgz", - "integrity": "sha512-rxJ5OFN3RwjQxDcFP2Z5+Q9ho4eIdEmSc2ht0fCu8Se9nbXjZ7/031uXoUYJ87KHCOdVeiUuwSnoS7hmYAGVHA==", + "license": "MIT", "dependencies": { "js-sha3": "^0.8.0" } }, "node_modules/ethereum-cryptography": { "version": "0.1.3", - "resolved": "https://registry.npmjs.org/ethereum-cryptography/-/ethereum-cryptography-0.1.3.tgz", - "integrity": "sha512-w8/4x1SGGzc+tO97TASLja6SLd3fRIK2tLVcV2Gx4IB21hE19atll5Cq9o3d0ZmAYC/8aw0ipieTSiekAea4SQ==", + "license": "MIT", "dependencies": { "@types/pbkdf2": "^3.0.0", "@types/secp256k1": "^4.0.1", @@ -4804,7 +4385,7 @@ }, "node_modules/ethereumeip712signature2021suite": { "version": "0.0.1", - "resolved": "git+ssh://git@github.com/hypersign-protocol/EthereumEip712Signature2021Suite.git#a8805272e6dc0e7e983adcbce8163d6389553e32", + "resolved": "git+ssh://git@github.com/hypersign-protocol/EthereumEip712Signature2021Suite.git#f3c5980d44447572e8de9b6d38f85ff824b6a2b9", "license": "Apache-2.0", "dependencies": { "bip39": "^3.1.0", @@ -4818,8 +4399,7 @@ }, "node_modules/ethereumeip712signature2021suite/node_modules/jsonld": { "version": "3.3.2", - "resolved": "https://registry.npmjs.org/jsonld/-/jsonld-3.3.2.tgz", - "integrity": "sha512-DXqG/fdiG7eJ8FzvSd58bW8DQsulQR/gjLYUz9PxBP/WTTpB2HzjjdxSAx5aBHewJ0RiFAV/QcqGCJjxHvuIzw==", + "license": "BSD-3-Clause", "dependencies": { "canonicalize": "^1.0.1", "lru-cache": "^5.1.1", @@ -4835,8 +4415,7 @@ }, "node_modules/ethereumeip712signature2021suite/node_modules/rdf-canonize": { "version": "2.0.1", - "resolved": "https://registry.npmjs.org/rdf-canonize/-/rdf-canonize-2.0.1.tgz", - "integrity": "sha512-/GVELjrfW8G/wS4QfDZ5Kq68cS1belVNJqZlcwiErerexeBUsgOINCROnP7UumWIBNdeCwTVLE9NVXMnRYK0lA==", + "license": "BSD-3-Clause", "dependencies": { "semver": "^6.3.0", "setimmediate": "^1.0.5" @@ -4847,16 +4426,14 @@ }, "node_modules/ethereumeip712signature2021suite/node_modules/semver": { "version": "6.3.1", - "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.1.tgz", - "integrity": "sha512-BR7VvDCVHO+q2xBEWskxS6DJE1qRnb7DxzUrogb71CWoSficBxYsiAGd+Kl0mmq/MprG9yArRkyrQxTO6XjMzA==", + "license": "ISC", "bin": { "semver": "bin/semver.js" } }, "node_modules/ethereumjs-abi": { "version": "0.6.8", - "resolved": "https://registry.npmjs.org/ethereumjs-abi/-/ethereumjs-abi-0.6.8.tgz", - "integrity": "sha512-Tx0r/iXI6r+lRsdvkFDlut0N08jWMnKRZ6Gkq+Nmw75lZe4e6o3EkSnkaBP5NF6+m5PTGAr9JP43N3LyeoglsA==", + "license": "MIT", "dependencies": { "bn.js": "^4.11.8", "ethereumjs-util": "^6.0.0" @@ -4864,21 +4441,18 @@ }, "node_modules/ethereumjs-abi/node_modules/@types/bn.js": { "version": "4.11.6", - "resolved": "https://registry.npmjs.org/@types/bn.js/-/bn.js-4.11.6.tgz", - "integrity": "sha512-pqr857jrp2kPuO9uRjZ3PwnJTjoQy+fcdxvBTvHm6dkmEL9q+hDD/2j/0ELOBPtPnS8LjCX0gI9nbl8lVkadpg==", + "license": "MIT", "dependencies": { "@types/node": "*" } }, "node_modules/ethereumjs-abi/node_modules/bn.js": { "version": "4.12.0", - "resolved": "https://registry.npmjs.org/bn.js/-/bn.js-4.12.0.tgz", - "integrity": "sha512-c98Bf3tPniI+scsdk237ku1Dc3ujXQTSgyiPUDEOe7tRkhrqridvh8klBv0HCEso1OLOYcHuCv/cS6DNxKH+ZA==" + "license": "MIT" }, "node_modules/ethereumjs-abi/node_modules/ethereumjs-util": { "version": "6.2.1", - "resolved": "https://registry.npmjs.org/ethereumjs-util/-/ethereumjs-util-6.2.1.tgz", - "integrity": "sha512-W2Ktez4L01Vexijrm5EB6w7dg4n/TgpoYU4avuT5T3Vmnw/eCRtiBrJfQYS/DCSvDIOLn2k57GcHdeBcgVxAqw==", + "license": "MPL-2.0", "dependencies": { "@types/bn.js": "^4.11.3", "bn.js": "^4.11.0", @@ -4891,8 +4465,7 @@ }, "node_modules/ethereumjs-util": { "version": "5.2.1", - "resolved": "https://registry.npmjs.org/ethereumjs-util/-/ethereumjs-util-5.2.1.tgz", - "integrity": "sha512-v3kT+7zdyCm1HIqWlLNrHGqHGLpGYIhjeHxQjnDXjLT2FyGJDsd3LWMYUo7pAFRrk86CR3nUJfhC81CCoJNNGQ==", + "license": "MPL-2.0", "dependencies": { "bn.js": "^4.11.0", "create-hash": "^1.1.2", @@ -4905,13 +4478,10 @@ }, "node_modules/ethereumjs-util/node_modules/bn.js": { "version": "4.12.0", - "resolved": "https://registry.npmjs.org/bn.js/-/bn.js-4.12.0.tgz", - "integrity": "sha512-c98Bf3tPniI+scsdk237ku1Dc3ujXQTSgyiPUDEOe7tRkhrqridvh8klBv0HCEso1OLOYcHuCv/cS6DNxKH+ZA==" + "license": "MIT" }, "node_modules/ethers": { - "version": "6.7.1", - "resolved": "https://registry.npmjs.org/ethers/-/ethers-6.7.1.tgz", - "integrity": "sha512-qX5kxIFMfg1i+epfgb0xF4WM7IqapIIu50pOJ17aebkxxa4BacW5jFrQRmCJpDEg2ZK2oNtR5QjrQ1WDBF29dA==", + "version": "6.9.1", "funding": [ { "type": "individual", @@ -4922,10 +4492,11 @@ "url": "https://www.buymeacoffee.com/ricmoo" } ], + "license": "MIT", "dependencies": { - "@adraffy/ens-normalize": "1.9.2", - "@noble/hashes": "1.1.2", - "@noble/secp256k1": "1.7.1", + "@adraffy/ens-normalize": "1.10.0", + "@noble/curves": "1.2.0", + "@noble/hashes": "1.3.2", "@types/node": "18.15.13", "aes-js": "4.0.0-beta.5", "tslib": "2.4.0", @@ -4936,25 +4507,26 @@ } }, "node_modules/ethers/node_modules/@noble/hashes": { - "version": "1.1.2", - "resolved": "https://registry.npmjs.org/@noble/hashes/-/hashes-1.1.2.tgz", - "integrity": "sha512-KYRCASVTv6aeUi1tsF8/vpyR7zpfs3FUzy2Jqm+MU+LmUKhQ0y2FpfwqkCcxSg2ua4GALJd8k2R76WxwZGbQpA==", - "funding": [ - { - "type": "individual", - "url": "https://paulmillr.com/funding/" - } - ] + "version": "1.3.2", + "license": "MIT", + "engines": { + "node": ">= 16" + }, + "funding": { + "url": "https://paulmillr.com/funding/" + } }, "node_modules/ethers/node_modules/@types/node": { "version": "18.15.13", - "resolved": "https://registry.npmjs.org/@types/node/-/node-18.15.13.tgz", - "integrity": "sha512-N+0kuo9KgrUQ1Sn/ifDXsvg0TTleP7rIy4zOBGECxAljqvqfqpTfzx0Q1NUedOixRMBfe2Whhb056a42cWs26Q==" + "license": "MIT" + }, + "node_modules/ethers/node_modules/tslib": { + "version": "2.4.0", + "license": "0BSD" }, "node_modules/ethers/node_modules/ws": { "version": "8.5.0", - "resolved": "https://registry.npmjs.org/ws/-/ws-8.5.0.tgz", - "integrity": "sha512-BWX0SWVgLPzYwF8lTzEy1egjhS4S4OEAHfsO8o65WOVsrnSRGaSiUaa9e0ggGlkMTtBlmOpEXiie9RUcBO86qg==", + "license": "MIT", "engines": { "node": ">=10.0.0" }, @@ -4973,8 +4545,7 @@ }, "node_modules/ethjs-unit": { "version": "0.1.6", - "resolved": "https://registry.npmjs.org/ethjs-unit/-/ethjs-unit-0.1.6.tgz", - "integrity": "sha512-/Sn9Y0oKl0uqQuvgFk/zQgR7aw1g36qX/jzSQ5lSwlO0GigPymk4eGQfeNTD03w1dPOqfz8V77Cy43jH56pagw==", + "license": "MIT", "dependencies": { "bn.js": "4.11.6", "number-to-bn": "1.7.0" @@ -4986,13 +4557,11 @@ }, "node_modules/ethjs-unit/node_modules/bn.js": { "version": "4.11.6", - "resolved": "https://registry.npmjs.org/bn.js/-/bn.js-4.11.6.tgz", - "integrity": "sha512-XWwnNNFCuuSQ0m3r3C4LE3EiORltHd9M05pq6FOlVeiophzRbMo50Sbz1ehl8K3Z+jw9+vmgnXefY1hz8X+2wA==" + "license": "MIT" }, "node_modules/ethjs-util": { "version": "0.1.6", - "resolved": "https://registry.npmjs.org/ethjs-util/-/ethjs-util-0.1.6.tgz", - "integrity": "sha512-CUnVOQq7gSpDHZVVrQW8ExxUETWrnrvXYvYz55wOU8Uj4VCgw56XC2B/fVqQN+f7gmrnRHSLVnFAwsCuNwji8w==", + "license": "MIT", "dependencies": { "is-hex-prefixed": "1.0.0", "strip-hex-prefix": "1.0.0" @@ -5004,21 +4573,25 @@ }, "node_modules/event-target-shim": { "version": "5.0.1", - "resolved": "https://registry.npmjs.org/event-target-shim/-/event-target-shim-5.0.1.tgz", - "integrity": "sha512-i/2XbnSz/uxRCU6+NdVJgKWDTM427+MqYbkQzD321DuCQJUqOuJKIA0IM2+W2xtYHdKOmZ4dR6fExsd4SXL+WQ==", + "license": "MIT", "engines": { "node": ">=6" } }, "node_modules/eventemitter3": { "version": "4.0.4", - "resolved": "https://registry.npmjs.org/eventemitter3/-/eventemitter3-4.0.4.tgz", - "integrity": "sha512-rlaVLnVxtxvoyLsQQFBx53YmXHDxRIzzTLbdfxqi4yocpSjAxXwkU0cScM5JgSKMqEhrZpnvQ2D9gjylR0AimQ==" + "license": "MIT" + }, + "node_modules/events": { + "version": "3.3.0", + "license": "MIT", + "engines": { + "node": ">=0.8.x" + } }, "node_modules/evp_bytestokey": { "version": "1.0.3", - "resolved": "https://registry.npmjs.org/evp_bytestokey/-/evp_bytestokey-1.0.3.tgz", - "integrity": "sha512-/f2Go4TognH/KvCISP7OUsHn85hT9nUkxxA9BEWxFn+Oj9o8ZNLm/40hdlgSLyuOimsrTKLUMEorQexp/aPQeA==", + "license": "MIT", "dependencies": { "md5.js": "^1.3.4", "safe-buffer": "^5.1.1" @@ -5026,9 +4599,8 @@ }, "node_modules/execa": { "version": "5.1.1", - "resolved": "https://registry.npmjs.org/execa/-/execa-5.1.1.tgz", - "integrity": "sha512-8uSpZZocAZRBAPIEINJj3Lo9HyGitllczc27Eh5YYojjMFMn8yHMDMaUHE2Jqfq05D/wucwI4JGURyXt1vchyg==", "dev": true, + "license": "MIT", "dependencies": { "cross-spawn": "^7.0.3", "get-stream": "^6.0.0", @@ -5049,8 +4621,6 @@ }, "node_modules/exit": { "version": "0.1.2", - "resolved": "https://registry.npmjs.org/exit/-/exit-0.1.2.tgz", - "integrity": "sha512-Zk/eNKV2zbjpKzrsQ+n1G6poVbErQxJ0LBOJXaKZ1EViLzH+hrLu9cdXI4zw9dBQJslwBEpbQ2P1oS7nDxs6jQ==", "dev": true, "engines": { "node": ">= 0.8.0" @@ -5058,9 +4628,8 @@ }, "node_modules/expect": { "version": "28.1.3", - "resolved": "https://registry.npmjs.org/expect/-/expect-28.1.3.tgz", - "integrity": "sha512-eEh0xn8HlsuOBxFgIss+2mX85VAS4Qy3OSkjV7rlBWljtA4oWH37glVGyOZSZvErDT/yBywZdPGwCXuTvSG85g==", "dev": true, + "license": "MIT", "dependencies": { "@jest/expect-utils": "^28.1.3", "jest-get-type": "^28.0.2", @@ -5074,8 +4643,7 @@ }, "node_modules/express": { "version": "4.18.2", - "resolved": "https://registry.npmjs.org/express/-/express-4.18.2.tgz", - "integrity": "sha512-5/PsL6iGPdfQ/lKM1UuielYgv3BUoJfz1aUwU9vHZ+J7gyvwdQXFEBIEIaxeGf0GIcreATNyBExtalisDbuMqQ==", + "license": "MIT", "dependencies": { "accepts": "~1.3.8", "array-flatten": "1.1.1", @@ -5115,8 +4683,7 @@ }, "node_modules/express/node_modules/body-parser": { "version": "1.20.1", - "resolved": "https://registry.npmjs.org/body-parser/-/body-parser-1.20.1.tgz", - "integrity": "sha512-jWi7abTbYwajOytWCQc37VulmWiRae5RyTpaCyDcS5/lMdtwSz5lOpDE67srw/HYe35f1z3fDQw+3txg7gNtWw==", + "license": "MIT", "dependencies": { "bytes": "3.1.2", "content-type": "~1.0.4", @@ -5138,21 +4705,18 @@ }, "node_modules/express/node_modules/debug": { "version": "2.6.9", - "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", - "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==", + "license": "MIT", "dependencies": { "ms": "2.0.0" } }, "node_modules/express/node_modules/ms": { "version": "2.0.0", - "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", - "integrity": "sha512-Tpp60P6IUJDTuOq/5Z8cdskzJujfwqfOTkrwIwj7IRISpnkJnT6SyJ4PCPnGMoFjC9ddhal5KVIYtAt97ix05A==" + "license": "MIT" }, "node_modules/express/node_modules/raw-body": { "version": "2.5.1", - "resolved": "https://registry.npmjs.org/raw-body/-/raw-body-2.5.1.tgz", - "integrity": "sha512-qqJBtEyVgS0ZmPGdCFPWJ3FreoqvG4MVQln/kCgF7Olq95IbOp0/BWyMwbdtn4VTvkM8Y7khCQ2Xgk/tcrCXig==", + "license": "MIT", "dependencies": { "bytes": "3.1.2", "http-errors": "2.0.0", @@ -5165,40 +4729,34 @@ }, "node_modules/ext": { "version": "1.7.0", - "resolved": "https://registry.npmjs.org/ext/-/ext-1.7.0.tgz", - "integrity": "sha512-6hxeJYaL110a9b5TEJSj0gojyHQAmA2ch5Os+ySCiA1QGdS697XWY1pzsrSjqA9LDEEgdB/KypIlR59RcLuHYw==", + "license": "ISC", "dependencies": { "type": "^2.7.2" } }, "node_modules/ext/node_modules/type": { "version": "2.7.2", - "resolved": "https://registry.npmjs.org/type/-/type-2.7.2.tgz", - "integrity": "sha512-dzlvlNlt6AXU7EBSfpAscydQ7gXB+pPGsPnfJnZpiNJBDj7IaJzQlBZYGdEi4R9HmPdBv2XmWJ6YUtoTa7lmCw==" + "license": "ISC" }, "node_modules/extend": { "version": "3.0.2", - "resolved": "https://registry.npmjs.org/extend/-/extend-3.0.2.tgz", - "integrity": "sha512-fjquC59cD7CyW6urNXK0FBufkZcoiGG80wTuPujX590cB5Ttln20E2UB4S/WARVqhXffZl2LNgS+gQdPIIim/g==" + "license": "MIT" }, "node_modules/extsprintf": { "version": "1.3.0", - "resolved": "https://registry.npmjs.org/extsprintf/-/extsprintf-1.3.0.tgz", - "integrity": "sha512-11Ndz7Nv+mvAC1j0ktTa7fAb0vLyGGX+rMHNBYQviQDGU0Hw7lhctJANqbPhu9nV9/izT/IntTgZ7Im/9LJs9g==", "engines": [ "node >=0.6.0" - ] + ], + "license": "MIT" }, "node_modules/fast-deep-equal": { "version": "3.1.3", - "resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-3.1.3.tgz", - "integrity": "sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q==" + "license": "MIT" }, "node_modules/fast-glob": { - "version": "3.3.1", - "resolved": "https://registry.npmjs.org/fast-glob/-/fast-glob-3.3.1.tgz", - "integrity": "sha512-kNFPyjhh5cKjrUltxs+wFx+ZkbRaxxmZ+X0ZU31SOsxCEtP9VPgtq2teZw1DebupL5GmDaNQ6yKMMVcM41iqDg==", + "version": "3.3.2", "dev": true, + "license": "MIT", "dependencies": { "@nodelib/fs.stat": "^2.0.2", "@nodelib/fs.walk": "^1.2.3", @@ -5212,37 +4770,32 @@ }, "node_modules/fast-json-stable-stringify": { "version": "2.1.0", - "resolved": "https://registry.npmjs.org/fast-json-stable-stringify/-/fast-json-stable-stringify-2.1.0.tgz", - "integrity": "sha512-lhd/wF+Lk98HZoTCtlVraHtfh5XYijIjalXck7saUtuanSDyLMxnHhSXEDJqHxD7msR8D0uCmqlkwjCV8xvwHw==" + "license": "MIT" }, "node_modules/fast-levenshtein": { "version": "2.0.6", - "resolved": "https://registry.npmjs.org/fast-levenshtein/-/fast-levenshtein-2.0.6.tgz", - "integrity": "sha512-DCXu6Ifhqcks7TZKY3Hxp3y6qphY5SJZmrWMDrKcERSOXWQdMhU9Ig/PYrzyw/ul9jOIyh0N4M0tbC5hodg8dw==", - "dev": true + "dev": true, + "license": "MIT" }, "node_modules/fastq": { - "version": "1.15.0", - "resolved": "https://registry.npmjs.org/fastq/-/fastq-1.15.0.tgz", - "integrity": "sha512-wBrocU2LCXXa+lWBt8RoIRD89Fi8OdABODa/kEnyeyjS5aZO5/GNvI5sEINADqP/h8M29UHTHUb53sUu5Ihqdw==", + "version": "1.16.0", "dev": true, + "license": "ISC", "dependencies": { "reusify": "^1.0.4" } }, "node_modules/fb-watchman": { "version": "2.0.2", - "resolved": "https://registry.npmjs.org/fb-watchman/-/fb-watchman-2.0.2.tgz", - "integrity": "sha512-p5161BqbuCaSnB8jIbzQHOlpgsPmK5rJVDfDKO91Axs5NC1uu3HRQm6wt9cd9/+GtQQIO53JdGXXoyDpTAsgYA==", "dev": true, + "license": "Apache-2.0", "dependencies": { "bser": "2.1.1" } }, "node_modules/fetch-blob": { "version": "2.1.2", - "resolved": "https://registry.npmjs.org/fetch-blob/-/fetch-blob-2.1.2.tgz", - "integrity": "sha512-YKqtUDwqLyfyMnmbw8XD6Q8j9i/HggKtPEI+pZ1+8bvheBu78biSmNaXWusx1TauGqtUUGx/cBb1mKdq2rLYow==", + "license": "MIT", "engines": { "node": "^10.17.0 || >=12.3.0" }, @@ -5254,9 +4807,8 @@ }, "node_modules/file-entry-cache": { "version": "6.0.1", - "resolved": "https://registry.npmjs.org/file-entry-cache/-/file-entry-cache-6.0.1.tgz", - "integrity": "sha512-7Gps/XWymbLk2QLYK4NzpMOrYjMhdIxXuIvy2QBsLE6ljuodKvdkWs/cpyJJ3CVIVpH0Oi1Hvg1ovbMzLdFBBg==", "dev": true, + "license": "MIT", "dependencies": { "flat-cache": "^3.0.4" }, @@ -5266,9 +4818,8 @@ }, "node_modules/fill-range": { "version": "7.0.1", - "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-7.0.1.tgz", - "integrity": "sha512-qOo9F+dMUmC2Lcb4BbVvnKJxTPjCm+RRpe4gDuGrzkL7mEVl/djYSu2OdQ2Pa302N4oqkSg9ir6jaLWJ2USVpQ==", "dev": true, + "license": "MIT", "dependencies": { "to-regex-range": "^5.0.1" }, @@ -5278,8 +4829,7 @@ }, "node_modules/finalhandler": { "version": "1.2.0", - "resolved": "https://registry.npmjs.org/finalhandler/-/finalhandler-1.2.0.tgz", - "integrity": "sha512-5uXcUVftlQMFnWC9qu/svkWv3GTd2PfUhK/3PLkYNAe7FbqJMt3515HaxE6eRL74GdsriiwujiawdaB1BpEISg==", + "license": "MIT", "dependencies": { "debug": "2.6.9", "encodeurl": "~1.0.2", @@ -5295,22 +4845,19 @@ }, "node_modules/finalhandler/node_modules/debug": { "version": "2.6.9", - "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", - "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==", + "license": "MIT", "dependencies": { "ms": "2.0.0" } }, "node_modules/finalhandler/node_modules/ms": { "version": "2.0.0", - "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", - "integrity": "sha512-Tpp60P6IUJDTuOq/5Z8cdskzJujfwqfOTkrwIwj7IRISpnkJnT6SyJ4PCPnGMoFjC9ddhal5KVIYtAt97ix05A==" + "license": "MIT" }, "node_modules/find-up": { "version": "4.1.0", - "resolved": "https://registry.npmjs.org/find-up/-/find-up-4.1.0.tgz", - "integrity": "sha512-PpOwAdQ/YlXQ2vj8a3h8IipDuYRi3wceVQQGYWxNINccq40Anw7BlsEXCMbt1Zt+OLA6Fq9suIpIWD0OsnISlw==", "dev": true, + "license": "MIT", "dependencies": { "locate-path": "^5.0.0", "path-exists": "^4.0.0" @@ -5321,95 +4868,81 @@ }, "node_modules/flat": { "version": "5.0.2", - "resolved": "https://registry.npmjs.org/flat/-/flat-5.0.2.tgz", - "integrity": "sha512-b6suED+5/3rTpUBdG1gupIl8MPFCAMA0QXwmljLhvCUKcUvdE4gWky9zpuGCcXHOsz4J9wPGNWq6OKpmIzz3hQ==", "dev": true, + "license": "BSD-3-Clause", "bin": { "flat": "cli.js" } }, "node_modules/flat-cache": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/flat-cache/-/flat-cache-3.1.0.tgz", - "integrity": "sha512-OHx4Qwrrt0E4jEIcI5/Xb+f+QmJYNj2rrK8wiIdQOIrB9WrrJL8cjZvXdXuBTkkEwEqLycb5BeZDV1o2i9bTew==", + "version": "3.2.0", "dev": true, + "license": "MIT", "dependencies": { - "flatted": "^3.2.7", + "flatted": "^3.2.9", "keyv": "^4.5.3", "rimraf": "^3.0.2" }, "engines": { - "node": ">=12.0.0" + "node": "^10.12.0 || >=12.0.0" } }, "node_modules/flatted": { - "version": "3.2.7", - "resolved": "https://registry.npmjs.org/flatted/-/flatted-3.2.7.tgz", - "integrity": "sha512-5nqDSxl8nn5BSNxyR3n4I6eDmbolI6WT+QqR547RwxQapgjQBmtktdP+HTBb/a/zLsbzERTONyUB5pefh5TtjQ==", - "dev": true + "version": "3.2.9", + "dev": true, + "license": "ISC" }, "node_modules/follow-redirects": { - "version": "1.5.10", - "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.5.10.tgz", - "integrity": "sha512-0V5l4Cizzvqt5D44aTXbFZz+FtyXV1vrDN6qrelxtfYQKW0KO0W2T/hkE8xvGa/540LkZlkaUjO4ailYTFtHVQ==", - "dependencies": { - "debug": "=3.1.0" - }, + "version": "1.15.3", + "funding": [ + { + "type": "individual", + "url": "https://github.com/sponsors/RubenVerborgh" + } + ], + "license": "MIT", "engines": { "node": ">=4.0" + }, + "peerDependenciesMeta": { + "debug": { + "optional": true + } } }, - "node_modules/follow-redirects/node_modules/debug": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/debug/-/debug-3.1.0.tgz", - "integrity": "sha512-OX8XqP7/1a9cqkxYw2yXss15f26NKWBpDXQd0/uK/KPqdQhxbPa994hnzjcE2VqQpDslf55723cKPUOGSmMY3g==", - "dependencies": { - "ms": "2.0.0" - } - }, - "node_modules/follow-redirects/node_modules/ms": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", - "integrity": "sha512-Tpp60P6IUJDTuOq/5Z8cdskzJujfwqfOTkrwIwj7IRISpnkJnT6SyJ4PCPnGMoFjC9ddhal5KVIYtAt97ix05A==" - }, "node_modules/for-each": { "version": "0.3.3", - "resolved": "https://registry.npmjs.org/for-each/-/for-each-0.3.3.tgz", - "integrity": "sha512-jqYfLp7mo9vIyQf8ykW2v7A+2N4QjeCeI5+Dz9XraiO1ign81wjiH7Fb9vSOWvQfNtmSa4H2RoQTrrXivdUZmw==", + "license": "MIT", "dependencies": { "is-callable": "^1.1.3" } }, "node_modules/forever-agent": { "version": "0.6.1", - "resolved": "https://registry.npmjs.org/forever-agent/-/forever-agent-0.6.1.tgz", - "integrity": "sha512-j0KLYPhm6zeac4lz3oJ3o65qvgQCcPubiyotZrXqEaG4hNagNYO8qdlUrX5vwqv9ohqeT/Z3j6+yW067yWWdUw==", + "license": "Apache-2.0", "engines": { "node": "*" } }, "node_modules/form-data": { - "version": "2.3.3", - "resolved": "https://registry.npmjs.org/form-data/-/form-data-2.3.3.tgz", - "integrity": "sha512-1lLKB2Mu3aGP1Q/2eCOx0fNbRMe7XdwktwOruhfqqd0rIJWwN4Dh+E3hrPSlDCXnSR7UtZ1N38rVXm+6+MEhJQ==", + "version": "4.0.0", + "license": "MIT", "dependencies": { "asynckit": "^0.4.0", - "combined-stream": "^1.0.6", + "combined-stream": "^1.0.8", "mime-types": "^2.1.12" }, "engines": { - "node": ">= 0.12" + "node": ">= 6" } }, "node_modules/form-data-encoder": { "version": "1.7.1", - "resolved": "https://registry.npmjs.org/form-data-encoder/-/form-data-encoder-1.7.1.tgz", - "integrity": "sha512-EFRDrsMm/kyqbTQocNvRXMLjc7Es2Vk+IQFx/YW7hkUH1eBl4J1fqiP34l74Yt0pFLCNpc06fkbVk00008mzjg==" + "license": "MIT" }, "node_modules/formdata-polyfill": { "version": "4.0.10", - "resolved": "https://registry.npmjs.org/formdata-polyfill/-/formdata-polyfill-4.0.10.tgz", - "integrity": "sha512-buewHzMvYL29jdeQTVILecSaZKnt/RJWjoZCF5OW60Z67/GmSLBkOFM7qh1PI3zFNtJbaZL5eQu1vLfazOwj4g==", + "license": "MIT", "dependencies": { "fetch-blob": "^3.1.2" }, @@ -5419,8 +4952,6 @@ }, "node_modules/formdata-polyfill/node_modules/fetch-blob": { "version": "3.2.0", - "resolved": "https://registry.npmjs.org/fetch-blob/-/fetch-blob-3.2.0.tgz", - "integrity": "sha512-7yAQpD2UMJzLi1Dqv7qFYnPbaPx7ZfFK6PiIxQ4PfkGPyNyl2Ugx+a/umUonmKqjhM4DnfbMvdX6otXq83soQQ==", "funding": [ { "type": "github", @@ -5431,6 +4962,7 @@ "url": "https://paypal.me/jimmywarting" } ], + "license": "MIT", "dependencies": { "node-domexception": "^1.0.0", "web-streams-polyfill": "^3.0.3" @@ -5441,24 +4973,21 @@ }, "node_modules/forwarded": { "version": "0.2.0", - "resolved": "https://registry.npmjs.org/forwarded/-/forwarded-0.2.0.tgz", - "integrity": "sha512-buRG0fpBtRHSTCOASe6hD258tEubFoRLb4ZNA6NxMVHNw2gOcwHo9wyablzMzOA5z9xA9L1KNjk/Nt6MT9aYow==", + "license": "MIT", "engines": { "node": ">= 0.6" } }, "node_modules/fresh": { "version": "0.5.2", - "resolved": "https://registry.npmjs.org/fresh/-/fresh-0.5.2.tgz", - "integrity": "sha512-zJ2mQYM18rEFOudeV4GShTGIQ7RbzA7ozbU9I/XBpm7kqgMywgmylMwXHxZJmkVoYkna9d2pVXVXPdYTP9ej8Q==", + "license": "MIT", "engines": { "node": ">= 0.6" } }, "node_modules/fs-extra": { "version": "4.0.3", - "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-4.0.3.tgz", - "integrity": "sha512-q6rbdDd1o2mAnQreO7YADIxf/Whx4AHBiRf6d+/cVT8h44ss+lHgxf1FemcqDnQt9X3ct4McHr+JMGlYSsK7Cg==", + "license": "MIT", "dependencies": { "graceful-fs": "^4.1.2", "jsonfile": "^4.0.0", @@ -5467,41 +4996,26 @@ }, "node_modules/fs-minipass": { "version": "1.2.7", - "resolved": "https://registry.npmjs.org/fs-minipass/-/fs-minipass-1.2.7.tgz", - "integrity": "sha512-GWSSJGFy4e9GUeCcbIkED+bgAoFyj7XF1mV8rma3QW4NIqX9Kyx79N/PF61H5udOV3aY1IaMLs6pGbH71nlCTA==", + "license": "ISC", "dependencies": { "minipass": "^2.6.0" } }, "node_modules/fs.realpath": { "version": "1.0.0", - "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", - "integrity": "sha512-OO0pH2lK6a0hZnAdau5ItzHPI6pUlvI7jMVnxUQRtw4owF2wk8lOSabtGDCTP4Ggrg2MbGnWO9X8K1t4+fGMDw==", - "dev": true - }, - "node_modules/fsevents": { - "version": "2.3.3", - "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.3.tgz", - "integrity": "sha512-5xoDfX+fL7faATnagmWPpbFtwh/R77WmMMqqHGS65C3vvB0YHrgF+B1YmZ3441tMj5n63k0212XNoJwzlhffQw==", "dev": true, - "hasInstallScript": true, - "optional": true, - "os": [ - "darwin" - ], - "engines": { - "node": "^8.16.0 || ^10.6.0 || >=11.0.0" - } + "license": "ISC" }, "node_modules/function-bind": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.1.tgz", - "integrity": "sha512-yIovAzMX49sF8Yl58fSCWJ5svSLuaibPxXQJFLmBObTuCr0Mf1KiPopGM9NiFjiYBCbfaa2Fh6breQ6ANVTI0A==" + "version": "1.1.2", + "license": "MIT", + "funding": { + "url": "https://github.com/sponsors/ljharb" + } }, "node_modules/function.prototype.name": { "version": "1.1.6", - "resolved": "https://registry.npmjs.org/function.prototype.name/-/function.prototype.name-1.1.6.tgz", - "integrity": "sha512-Z5kx79swU5P27WEayXM1tBi5Ze/lbIyiNgU3qyXUOf9b2rgXYyF9Dy9Cx+IQv/Lc8WCG6L82zwUPpSS9hGehIg==", + "license": "MIT", "dependencies": { "call-bind": "^1.0.2", "define-properties": "^1.2.0", @@ -5517,54 +5031,48 @@ }, "node_modules/functional-red-black-tree": { "version": "1.0.1", - "resolved": "https://registry.npmjs.org/functional-red-black-tree/-/functional-red-black-tree-1.0.1.tgz", - "integrity": "sha512-dsKNQNdj6xA3T+QlADDA7mOSlX0qiMINjn0cgr+eGHGsbSHzTabcIogz2+p/iqP1Xs6EP/sS2SbqH+brGTbq0g==", - "dev": true + "dev": true, + "license": "MIT" }, "node_modules/functions-have-names": { "version": "1.2.3", - "resolved": "https://registry.npmjs.org/functions-have-names/-/functions-have-names-1.2.3.tgz", - "integrity": "sha512-xckBUXyTIqT97tq2x2AMb+g163b5JFysYk0x4qxNFwbfQkmNZoiRHb6sPzI9/QV33WeuvVYBUIiD4NzNIyqaRQ==", + "license": "MIT", "funding": { "url": "https://github.com/sponsors/ljharb" } }, "node_modules/gensync": { "version": "1.0.0-beta.2", - "resolved": "https://registry.npmjs.org/gensync/-/gensync-1.0.0-beta.2.tgz", - "integrity": "sha512-3hN7NaskYvMDLQY55gnW3NQ+mesEAepTqlg+VEbj7zzqEMBVNhzcGYYeqFo/TlYz6eQiFcp1HcsCZO+nGgS8zg==", "dev": true, + "license": "MIT", "engines": { "node": ">=6.9.0" } }, "node_modules/get-caller-file": { "version": "2.0.5", - "resolved": "https://registry.npmjs.org/get-caller-file/-/get-caller-file-2.0.5.tgz", - "integrity": "sha512-DyFP3BM/3YHTQOCUL/w0OZHR0lpKeGrxotcHWcqNEdnltqFwXVfhEBQ94eIo34AfQpo0rGki4cyIiftY06h2Fg==", "dev": true, + "license": "ISC", "engines": { "node": "6.* || 8.* || >= 10.*" } }, "node_modules/get-func-name": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/get-func-name/-/get-func-name-2.0.0.tgz", - "integrity": "sha512-Hm0ixYtaSZ/V7C8FJrtZIuBBI+iSgL+1Aq82zSu8VQNB4S3Gk8e7Qs3VwBDJAhmRZcFqkl3tQu36g/Foh5I5ig==", + "version": "2.0.2", "dev": true, + "license": "MIT", "engines": { "node": "*" } }, "node_modules/get-intrinsic": { - "version": "1.2.1", - "resolved": "https://registry.npmjs.org/get-intrinsic/-/get-intrinsic-1.2.1.tgz", - "integrity": "sha512-2DcsyfABl+gVHEfCOaTrWgyt+tb6MSEGmKq+kI5HwLbIYgjgmMcV8KQ41uaKz1xxUcn9tJtgFbQUEVcEbd0FYw==", + "version": "1.2.2", + "license": "MIT", "dependencies": { - "function-bind": "^1.1.1", - "has": "^1.0.3", + "function-bind": "^1.1.2", "has-proto": "^1.0.1", - "has-symbols": "^1.0.3" + "has-symbols": "^1.0.3", + "hasown": "^2.0.0" }, "funding": { "url": "https://github.com/sponsors/ljharb" @@ -5572,17 +5080,15 @@ }, "node_modules/get-package-type": { "version": "0.1.0", - "resolved": "https://registry.npmjs.org/get-package-type/-/get-package-type-0.1.0.tgz", - "integrity": "sha512-pjzuKtY64GYfWizNAJ0fr9VqttZkNiK2iS430LtIHzjBEr6bX8Am2zm4sW4Ro5wjWW5cAlRL1qAMTcXbjNAO2Q==", "dev": true, + "license": "MIT", "engines": { "node": ">=8.0.0" } }, "node_modules/get-stream": { "version": "6.0.1", - "resolved": "https://registry.npmjs.org/get-stream/-/get-stream-6.0.1.tgz", - "integrity": "sha512-ts6Wi+2j3jQjqi70w5AlN8DFnkSwC+MqmxEzdEALB2qXZYV3X/b1CTfgPLGJNMeAWxdPfU8FO1ms3NUfaHCPYg==", + "license": "MIT", "engines": { "node": ">=10" }, @@ -5592,8 +5098,7 @@ }, "node_modules/get-symbol-description": { "version": "1.0.0", - "resolved": "https://registry.npmjs.org/get-symbol-description/-/get-symbol-description-1.0.0.tgz", - "integrity": "sha512-2EmdH1YvIQiZpltCNgkuiUnyukzxM/R6NDJX31Ke3BG1Nq5b0S2PhX59UKi9vZpPDQVdqn+1IcaAwnzTT5vCjw==", + "license": "MIT", "dependencies": { "call-bind": "^1.0.2", "get-intrinsic": "^1.1.1" @@ -5607,17 +5112,15 @@ }, "node_modules/getpass": { "version": "0.1.7", - "resolved": "https://registry.npmjs.org/getpass/-/getpass-0.1.7.tgz", - "integrity": "sha512-0fzj9JxOLfJ+XGLhR8ze3unN0KZCgZwiSSDz168VERjK8Wl8kVSdcu2kspd4s4wtAa1y/qrVRiAA0WclVsu0ng==", + "license": "MIT", "dependencies": { "assert-plus": "^1.0.0" } }, "node_modules/glob": { "version": "7.2.3", - "resolved": "https://registry.npmjs.org/glob/-/glob-7.2.3.tgz", - "integrity": "sha512-nFR0zLpU2YCaRxwoCJvL6UvCH2JFyFVIvwTLsIf21AuHlMskA1hhTdk+LlYJtOlYt9v6dvszD2BGRqBL+iQK9Q==", "dev": true, + "license": "ISC", "dependencies": { "fs.realpath": "^1.0.0", "inflight": "^1.0.4", @@ -5635,9 +5138,8 @@ }, "node_modules/glob-parent": { "version": "5.1.2", - "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-5.1.2.tgz", - "integrity": "sha512-AOIgSQCepiJYwP3ARnGx+5VnTu2HBYdzbGP45eLw1vr3zB3vZLeyed1sC9hnbcOc9/SrMyM5RPQrkGz4aS9Zow==", "dev": true, + "license": "ISC", "dependencies": { "is-glob": "^4.0.1" }, @@ -5647,18 +5149,16 @@ }, "node_modules/global": { "version": "4.4.0", - "resolved": "https://registry.npmjs.org/global/-/global-4.4.0.tgz", - "integrity": "sha512-wv/LAoHdRE3BeTGz53FAamhGlPLhlssK45usmGFThIi4XqnBmjKQ16u+RNbP7WvigRZDxUsM0J3gcQ5yicaL0w==", + "license": "MIT", "dependencies": { "min-document": "^2.19.0", "process": "^0.11.10" } }, "node_modules/globals": { - "version": "13.21.0", - "resolved": "https://registry.npmjs.org/globals/-/globals-13.21.0.tgz", - "integrity": "sha512-ybyme3s4yy/t/3s35bewwXKOf7cvzfreG2lH0lZl0JB7I4GxRP2ghxOK/Nb9EkRXdbBXZLfq/p/0W2JUONB/Gg==", + "version": "13.24.0", "dev": true, + "license": "MIT", "dependencies": { "type-fest": "^0.20.2" }, @@ -5671,8 +5171,7 @@ }, "node_modules/globalthis": { "version": "1.0.3", - "resolved": "https://registry.npmjs.org/globalthis/-/globalthis-1.0.3.tgz", - "integrity": "sha512-sFdI5LyBiNTHjRd7cGPWapiHWMOXKyuBNX/cWJ3NfzrZQVa8GI/8cofCl74AOVqq9W5kNmguTIzJ/1s2gyI9wA==", + "license": "MIT", "dependencies": { "define-properties": "^1.1.3" }, @@ -5685,9 +5184,8 @@ }, "node_modules/globby": { "version": "11.1.0", - "resolved": "https://registry.npmjs.org/globby/-/globby-11.1.0.tgz", - "integrity": "sha512-jhIXaOzy1sb8IyocaruWSn1TjmnBVs8Ayhcy83rmxNJ8q2uWKCAj3CnJY+KpGSXCueAPc0i05kVvVKtP1t9S3g==", "dev": true, + "license": "MIT", "dependencies": { "array-union": "^2.1.0", "dir-glob": "^3.0.1", @@ -5705,8 +5203,7 @@ }, "node_modules/gopd": { "version": "1.0.1", - "resolved": "https://registry.npmjs.org/gopd/-/gopd-1.0.1.tgz", - "integrity": "sha512-d65bNlIadxvpb/A2abVdlqKqV563juRnZ1Wtk6s1sIR8uNsXR70xqIzVqxVf1eTqDunwT2MkczEeaezCKTZhwA==", + "license": "MIT", "dependencies": { "get-intrinsic": "^1.1.3" }, @@ -5716,8 +5213,7 @@ }, "node_modules/got": { "version": "12.1.0", - "resolved": "https://registry.npmjs.org/got/-/got-12.1.0.tgz", - "integrity": "sha512-hBv2ty9QN2RdbJJMK3hesmSkFTjVIHyIDDbssCKnSmq62edGgImJWD10Eb1k77TiV1bxloxqcFAVK8+9pkhOig==", + "license": "MIT", "dependencies": { "@sindresorhus/is": "^4.6.0", "@szmarczak/http-timer": "^5.0.1", @@ -5742,28 +5238,23 @@ }, "node_modules/graceful-fs": { "version": "4.2.11", - "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.11.tgz", - "integrity": "sha512-RbJ5/jmFcNNCcDV5o9eTnBLJ/HszWV0P73bc+Ff4nS/rJj+YaS6IGyiOL0VoBYX+l1Wrl3k63h/KrH+nhJ0XvQ==" + "license": "ISC" }, "node_modules/graphemer": { "version": "1.4.0", - "resolved": "https://registry.npmjs.org/graphemer/-/graphemer-1.4.0.tgz", - "integrity": "sha512-EtKwoO6kxCL9WO5xipiHTZlSzBm7WLT627TqC/uVRd0HKmq8NXyebnNYxDoBi7wt8eTWrUrKXCOVaFq9x1kgag==", - "dev": true + "dev": true, + "license": "MIT" }, "node_modules/har-schema": { "version": "2.0.0", - "resolved": "https://registry.npmjs.org/har-schema/-/har-schema-2.0.0.tgz", - "integrity": "sha512-Oqluz6zhGX8cyRaTQlFMPw80bSJVG2x/cFb8ZPhUILGgHka9SsokCCOQgpveePerqidZOrT14ipqfJb7ILcW5Q==", + "license": "ISC", "engines": { "node": ">=4" } }, "node_modules/har-validator": { "version": "5.1.5", - "resolved": "https://registry.npmjs.org/har-validator/-/har-validator-5.1.5.tgz", - "integrity": "sha512-nmT2T0lljbxdQZfspsno9hgrG3Uir6Ks5afism62poxqBM6sDnMEuPmzTq8XN0OEwqKLLdh1jQI3qyE66Nzb3w==", - "deprecated": "this library is no longer supported", + "license": "MIT", "dependencies": { "ajv": "^6.12.3", "har-schema": "^2.0.0" @@ -5772,40 +5263,26 @@ "node": ">=6" } }, - "node_modules/has": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/has/-/has-1.0.3.tgz", - "integrity": "sha512-f2dvO0VU6Oej7RkWJGrehjbzMAjFp5/VKPp5tTpWIV4JHHZK1/BxbFRtf/siA2SWTe09caDmVtYYzWEIbBS4zw==", - "dependencies": { - "function-bind": "^1.1.1" - }, - "engines": { - "node": ">= 0.4.0" - } - }, "node_modules/has-bigints": { "version": "1.0.2", - "resolved": "https://registry.npmjs.org/has-bigints/-/has-bigints-1.0.2.tgz", - "integrity": "sha512-tSvCKtBr9lkF0Ex0aQiP9N+OpV4zi2r/Nee5VkRDbaqv35RLYMzbwQfFSZZH0kR+Rd6302UJZ2p/bJCEoR3VoQ==", + "license": "MIT", "funding": { "url": "https://github.com/sponsors/ljharb" } }, "node_modules/has-flag": { "version": "4.0.0", - "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", - "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", "dev": true, + "license": "MIT", "engines": { "node": ">=8" } }, "node_modules/has-property-descriptors": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/has-property-descriptors/-/has-property-descriptors-1.0.0.tgz", - "integrity": "sha512-62DVLZGoiEBDHQyqG4w9xCuZ7eJEwNmJRWw2VY84Oedb7WFcA27fiEVe8oUQx9hAUJ4ekurquucTGwsyO1XGdQ==", + "version": "1.0.1", + "license": "MIT", "dependencies": { - "get-intrinsic": "^1.1.1" + "get-intrinsic": "^1.2.2" }, "funding": { "url": "https://github.com/sponsors/ljharb" @@ -5813,8 +5290,7 @@ }, "node_modules/has-proto": { "version": "1.0.1", - "resolved": "https://registry.npmjs.org/has-proto/-/has-proto-1.0.1.tgz", - "integrity": "sha512-7qE+iP+O+bgF9clE5+UoBFzE65mlBiVj3tKCrlNQ0Ogwm0BjpT/gK4SlLYDMybDh5I3TCTKnPPa0oMG7JDYrhg==", + "license": "MIT", "engines": { "node": ">= 0.4" }, @@ -5824,8 +5300,7 @@ }, "node_modules/has-symbols": { "version": "1.0.3", - "resolved": "https://registry.npmjs.org/has-symbols/-/has-symbols-1.0.3.tgz", - "integrity": "sha512-l3LCuF6MgDNwTDKkdYGEihYjt5pRPbEg46rtlmnSPlUbgmB8LOIrKJbYYFBSbnPaJexMKtiPO8hmeRjRz2Td+A==", + "license": "MIT", "engines": { "node": ">= 0.4" }, @@ -5835,8 +5310,7 @@ }, "node_modules/has-tostringtag": { "version": "1.0.0", - "resolved": "https://registry.npmjs.org/has-tostringtag/-/has-tostringtag-1.0.0.tgz", - "integrity": "sha512-kFjcSNhnlGV1kyoGk7OXKSawH5JOb/LzUc5w9B02hOTO0dfFRjbHQKvg1d6cf3HbeUmtU9VbbV3qzZ2Teh97WQ==", + "license": "MIT", "dependencies": { "has-symbols": "^1.0.2" }, @@ -5849,8 +5323,7 @@ }, "node_modules/hash-base": { "version": "3.1.0", - "resolved": "https://registry.npmjs.org/hash-base/-/hash-base-3.1.0.tgz", - "integrity": "sha512-1nmYp/rhMDiE7AYkDw+lLwlAzz0AntGIe51F3RfFfEqyQ3feY2eI/NcwC6umIQVOASPMsWJLJScWKSSvzL9IVA==", + "license": "MIT", "dependencies": { "inherits": "^2.0.4", "readable-stream": "^3.6.0", @@ -5862,26 +5335,33 @@ }, "node_modules/hash.js": { "version": "1.1.7", - "resolved": "https://registry.npmjs.org/hash.js/-/hash.js-1.1.7.tgz", - "integrity": "sha512-taOaskGt4z4SOANNseOviYDvjEJinIkRgmp7LbKP2YTTmVxWBl87s/uzK9r+44BclBSp2X7K1hqeNfz9JbBeXA==", + "license": "MIT", "dependencies": { "inherits": "^2.0.3", "minimalistic-assert": "^1.0.1" } }, + "node_modules/hasown": { + "version": "2.0.0", + "license": "MIT", + "dependencies": { + "function-bind": "^1.1.2" + }, + "engines": { + "node": ">= 0.4" + } + }, "node_modules/he": { "version": "1.2.0", - "resolved": "https://registry.npmjs.org/he/-/he-1.2.0.tgz", - "integrity": "sha512-F/1DnUGPopORZi0ni+CvrCgHQ5FyEAHRLSApuYWMmrbSwoN2Mn/7k+Gl38gJnR7yyDZk6WLXwiGod1JOWNDKGw==", "dev": true, + "license": "MIT", "bin": { "he": "bin/he" } }, "node_modules/hmac-drbg": { "version": "1.0.1", - "resolved": "https://registry.npmjs.org/hmac-drbg/-/hmac-drbg-1.0.1.tgz", - "integrity": "sha512-Tti3gMqLdZfhOQY1Mzf/AanLiqh1WTiJgEj26ZuYQ9fbkLomzGchCws4FyrSd4VkpBfiNhaE1On+lOz894jvXg==", + "license": "MIT", "dependencies": { "hash.js": "^1.0.3", "minimalistic-assert": "^1.0.0", @@ -5890,19 +5370,16 @@ }, "node_modules/html-escaper": { "version": "2.0.2", - "resolved": "https://registry.npmjs.org/html-escaper/-/html-escaper-2.0.2.tgz", - "integrity": "sha512-H2iMtd0I4Mt5eYiapRdIDjp+XzelXQ0tFE4JS7YFwFevXXMmOp9myNrUvCg0D6ws8iqkRPBfKHgbwig1SmlLfg==", - "dev": true + "dev": true, + "license": "MIT" }, "node_modules/http-cache-semantics": { "version": "4.1.1", - "resolved": "https://registry.npmjs.org/http-cache-semantics/-/http-cache-semantics-4.1.1.tgz", - "integrity": "sha512-er295DKPVsV82j5kw1Gjt+ADA/XYHsajl82cGNQG2eyoPkvgUhX+nDIyelzhIWbbsXP39EHcI6l5tYs2FYqYXQ==" + "license": "BSD-2-Clause" }, "node_modules/http-errors": { "version": "2.0.0", - "resolved": "https://registry.npmjs.org/http-errors/-/http-errors-2.0.0.tgz", - "integrity": "sha512-FtwrG/euBzaEjYeRqOgly7G0qviiXoJWnvEH2Z1plBdXgbyjv34pHTSb9zoeHMyDy33+DWy5Wt9Wo+TURtOYSQ==", + "license": "MIT", "dependencies": { "depd": "2.0.0", "inherits": "2.0.4", @@ -5916,13 +5393,11 @@ }, "node_modules/http-https": { "version": "1.0.0", - "resolved": "https://registry.npmjs.org/http-https/-/http-https-1.0.0.tgz", - "integrity": "sha512-o0PWwVCSp3O0wS6FvNr6xfBCHgt0m1tvPLFOCc2iFDKTRAXhB7m8klDf7ErowFH8POa6dVdGatKU5I1YYwzUyg==" + "license": "ISC" }, "node_modules/http-signature": { "version": "1.2.0", - "resolved": "https://registry.npmjs.org/http-signature/-/http-signature-1.2.0.tgz", - "integrity": "sha512-CAbnr6Rz4CYQkLYUtSNXxQPUH2gK8f3iWexVlsnMeD+GjlsQ0Xsy1cOX+mN3dtxYomRy21CiOzU8Uhw6OwncEQ==", + "license": "MIT", "dependencies": { "assert-plus": "^1.0.0", "jsprim": "^1.2.2", @@ -5934,9 +5409,8 @@ } }, "node_modules/http2-wrapper": { - "version": "2.2.0", - "resolved": "https://registry.npmjs.org/http2-wrapper/-/http2-wrapper-2.2.0.tgz", - "integrity": "sha512-kZB0wxMo0sh1PehyjJUWRFEd99KC5TLjZ2cULC4f9iqJBAmKQQXEICjxl5iPJRwP40dpeHFqqhm7tYCvODpqpQ==", + "version": "2.2.1", + "license": "MIT", "dependencies": { "quick-lru": "^5.1.1", "resolve-alpn": "^1.2.0" @@ -5947,18 +5421,16 @@ }, "node_modules/human-signals": { "version": "2.1.0", - "resolved": "https://registry.npmjs.org/human-signals/-/human-signals-2.1.0.tgz", - "integrity": "sha512-B4FFZ6q/T2jhhksgkbEW3HBvWIfDW85snkQgawt07S7J5QXTk6BkNV+0yAeZrM5QpMAdYlocGoljn0sJ/WQkFw==", "dev": true, + "license": "Apache-2.0", "engines": { "node": ">=10.17.0" } }, "node_modules/husky": { "version": "7.0.4", - "resolved": "https://registry.npmjs.org/husky/-/husky-7.0.4.tgz", - "integrity": "sha512-vbaCKN2QLtP/vD4yvs6iz6hBEo6wkSzs8HpRah1Z6aGmF2KW5PdYuAd7uX5a+OyBZHBhd+TFLqgjUgytQr4RvQ==", "dev": true, + "license": "MIT", "bin": { "husky": "lib/bin.js" }, @@ -5971,8 +5443,7 @@ }, "node_modules/iconv-lite": { "version": "0.4.24", - "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.4.24.tgz", - "integrity": "sha512-v3MXnZAcvnywkTUEZomIActle7RXXeedOR31wwl7VlyoXO4Qi9arvSenNQWne1TcRwhCL1HwLI21bEqdpj8/rA==", + "license": "MIT", "dependencies": { "safer-buffer": ">= 2.1.2 < 3" }, @@ -5980,10 +5451,14 @@ "node": ">=0.10.0" } }, + "node_modules/idb-keyval": { + "version": "6.2.1", + "license": "Apache-2.0", + "peer": true + }, "node_modules/idna-uts46-hx": { "version": "2.3.1", - "resolved": "https://registry.npmjs.org/idna-uts46-hx/-/idna-uts46-hx-2.3.1.tgz", - "integrity": "sha512-PWoF9Keq6laYdIRwwCdhTPl60xRqAloYNMQLiyUnG42VjT53oW07BXIRM+NK7eQjzXjAk2gUvX9caRxlnF9TAA==", + "license": "MIT", "dependencies": { "punycode": "2.1.0" }, @@ -5993,16 +5468,13 @@ }, "node_modules/idna-uts46-hx/node_modules/punycode": { "version": "2.1.0", - "resolved": "https://registry.npmjs.org/punycode/-/punycode-2.1.0.tgz", - "integrity": "sha512-Yxz2kRwT90aPiWEMHVYnEf4+rhwF1tBmmZ4KepCP+Wkium9JxtWnUm1nqGwpiAHr/tnTSeHqr3wb++jgSkXjhA==", + "license": "MIT", "engines": { "node": ">=6" } }, "node_modules/ieee754": { "version": "1.2.1", - "resolved": "https://registry.npmjs.org/ieee754/-/ieee754-1.2.1.tgz", - "integrity": "sha512-dcyqhDvX1C46lXZcVqCpK+FtMRQVdIMN6/Df5js2zouUsqG7I6sFxitIC+7KYK29KdXOLHdu9zL4sFnoVQnqaA==", "funding": [ { "type": "github", @@ -6016,22 +5488,21 @@ "type": "consulting", "url": "https://feross.org/support" } - ] + ], + "license": "BSD-3-Clause" }, "node_modules/ignore": { - "version": "5.2.4", - "resolved": "https://registry.npmjs.org/ignore/-/ignore-5.2.4.tgz", - "integrity": "sha512-MAb38BcSbH0eHNBxn7ql2NH/kX33OkB3lZ1BNdh7ENeRChHTYsTvWrMubiIAMNS2llXEEgZ1MUOBtXChP3kaFQ==", + "version": "5.3.0", "dev": true, + "license": "MIT", "engines": { "node": ">= 4" } }, "node_modules/import-fresh": { "version": "3.3.0", - "resolved": "https://registry.npmjs.org/import-fresh/-/import-fresh-3.3.0.tgz", - "integrity": "sha512-veYYhQa+D1QBKznvhUHxb8faxlrwUnxseDAbAp457E0wLNio2bOSKnjYDhMj+YiAq61xrMGhQk9iXVk5FzgQMw==", "dev": true, + "license": "MIT", "dependencies": { "parent-module": "^1.0.0", "resolve-from": "^4.0.0" @@ -6045,9 +5516,8 @@ }, "node_modules/import-local": { "version": "3.1.0", - "resolved": "https://registry.npmjs.org/import-local/-/import-local-3.1.0.tgz", - "integrity": "sha512-ASB07uLtnDs1o6EHjKpX34BKYDSqnFerfTOJL2HvMqF70LnxpjkzDB8J44oT9pu4AMPkQwf8jl6szgvNd2tRIg==", "dev": true, + "license": "MIT", "dependencies": { "pkg-dir": "^4.2.0", "resolve-cwd": "^3.0.0" @@ -6064,18 +5534,16 @@ }, "node_modules/imurmurhash": { "version": "0.1.4", - "resolved": "https://registry.npmjs.org/imurmurhash/-/imurmurhash-0.1.4.tgz", - "integrity": "sha512-JmXMZ6wuvDmLiHEml9ykzqO6lwFbof0GG4IkcGaENdCRDDmMVnny7s5HsIgHCbaq0w2MyPhDqkhTUgS2LU2PHA==", "dev": true, + "license": "MIT", "engines": { "node": ">=0.8.19" } }, "node_modules/inflight": { "version": "1.0.6", - "resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz", - "integrity": "sha512-k92I/b08q4wvFscXCLvqfsHCrjrF7yiXsQuIVvVE7N82W3+aqpzuUdBbfhWcy/FZR3/4IgflMgKLOsvPDrGCJA==", "dev": true, + "license": "ISC", "dependencies": { "once": "^1.3.0", "wrappy": "1" @@ -6083,16 +5551,14 @@ }, "node_modules/inherits": { "version": "2.0.4", - "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz", - "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==" + "license": "ISC" }, "node_modules/internal-slot": { - "version": "1.0.5", - "resolved": "https://registry.npmjs.org/internal-slot/-/internal-slot-1.0.5.tgz", - "integrity": "sha512-Y+R5hJrzs52QCG2laLn4udYVnxsfny9CpOhNhUvk/SSSVyF6T27FzRbF0sroPidSu3X8oEAkOn2K804mjpt6UQ==", + "version": "1.0.6", + "license": "MIT", "dependencies": { - "get-intrinsic": "^1.2.0", - "has": "^1.0.3", + "get-intrinsic": "^1.2.2", + "hasown": "^2.0.0", "side-channel": "^1.0.4" }, "engines": { @@ -6101,16 +5567,14 @@ }, "node_modules/ipaddr.js": { "version": "1.9.1", - "resolved": "https://registry.npmjs.org/ipaddr.js/-/ipaddr.js-1.9.1.tgz", - "integrity": "sha512-0KI/607xoxSToH7GjN1FfSbLoU0+btTicjsQSWQlh/hZykN8KpmMf7uYwPW3R+akZ6R/w18ZlXSHBYXiYUPO3g==", + "license": "MIT", "engines": { "node": ">= 0.10" } }, "node_modules/is-arguments": { "version": "1.1.1", - "resolved": "https://registry.npmjs.org/is-arguments/-/is-arguments-1.1.1.tgz", - "integrity": "sha512-8Q7EARjzEnKpt/PCD7e1cgUS0a6X8u5tdSiMqXhojOdoV9TsMsiO+9VLC5vAmO8N7/GmXn7yjR8qnA6bVAEzfA==", + "license": "MIT", "dependencies": { "call-bind": "^1.0.2", "has-tostringtag": "^1.0.0" @@ -6124,8 +5588,7 @@ }, "node_modules/is-array-buffer": { "version": "3.0.2", - "resolved": "https://registry.npmjs.org/is-array-buffer/-/is-array-buffer-3.0.2.tgz", - "integrity": "sha512-y+FyyR/w8vfIRq4eQcM1EYgSTnmHXPqaF+IgzgraytCFq5Xh8lllDVmAZolPJiZttZLeFSINPYMaEJ7/vWUa1w==", + "license": "MIT", "dependencies": { "call-bind": "^1.0.2", "get-intrinsic": "^1.2.0", @@ -6137,14 +5600,12 @@ }, "node_modules/is-arrayish": { "version": "0.2.1", - "resolved": "https://registry.npmjs.org/is-arrayish/-/is-arrayish-0.2.1.tgz", - "integrity": "sha512-zz06S8t0ozoDXMG+ube26zeCTNXcKIPJZJi8hBrF4idCLms4CG9QtK7qBl1boi5ODzFpjswb5JPmHCbMpjaYzg==", - "dev": true + "dev": true, + "license": "MIT" }, "node_modules/is-bigint": { "version": "1.0.4", - "resolved": "https://registry.npmjs.org/is-bigint/-/is-bigint-1.0.4.tgz", - "integrity": "sha512-zB9CruMamjym81i2JZ3UMn54PKGsQzsJeo6xvN3HJJ4CAsQNB6iRutp2To77OfCNuoxspsIhzaPoO1zyCEhFOg==", + "license": "MIT", "dependencies": { "has-bigints": "^1.0.1" }, @@ -6154,9 +5615,8 @@ }, "node_modules/is-binary-path": { "version": "2.1.0", - "resolved": "https://registry.npmjs.org/is-binary-path/-/is-binary-path-2.1.0.tgz", - "integrity": "sha512-ZMERYes6pDydyuGidse7OsHxtbI7WVeUEozgR/g7rd0xUimYNlvZRE/K2MgZTjWy725IfelLeVcEM97mmtRGXw==", "dev": true, + "license": "MIT", "dependencies": { "binary-extensions": "^2.0.0" }, @@ -6166,8 +5626,7 @@ }, "node_modules/is-boolean-object": { "version": "1.1.2", - "resolved": "https://registry.npmjs.org/is-boolean-object/-/is-boolean-object-1.1.2.tgz", - "integrity": "sha512-gDYaKHJmnj4aWxyj6YHyXVpdQawtVLHU5cb+eztPGczf6cjuTdwve5ZIEfgXqH4e57An1D1AKf8CZ3kYrQRqYA==", + "license": "MIT", "dependencies": { "call-bind": "^1.0.2", "has-tostringtag": "^1.0.0" @@ -6181,8 +5640,7 @@ }, "node_modules/is-callable": { "version": "1.2.7", - "resolved": "https://registry.npmjs.org/is-callable/-/is-callable-1.2.7.tgz", - "integrity": "sha512-1BC0BVFhS/p0qtw6enp8e+8OD0UrK0oFLztSjNzhcKA3WDuJxxAPXzPuPtKkjEY9UUoEWlX/8fgKeu2S8i9JTA==", + "license": "MIT", "engines": { "node": ">= 0.4" }, @@ -6191,12 +5649,11 @@ } }, "node_modules/is-core-module": { - "version": "2.13.0", - "resolved": "https://registry.npmjs.org/is-core-module/-/is-core-module-2.13.0.tgz", - "integrity": "sha512-Z7dk6Qo8pOCp3l4tsX2C5ZVas4V+UxwQodwZhLopL91TX8UyyHEXafPcyoeeWuLrwzHcr3igO78wNLwHJHsMCQ==", + "version": "2.13.1", "dev": true, + "license": "MIT", "dependencies": { - "has": "^1.0.3" + "hasown": "^2.0.0" }, "funding": { "url": "https://github.com/sponsors/ljharb" @@ -6204,8 +5661,7 @@ }, "node_modules/is-date-object": { "version": "1.0.5", - "resolved": "https://registry.npmjs.org/is-date-object/-/is-date-object-1.0.5.tgz", - "integrity": "sha512-9YQaSxsAiSwcvS33MBk3wTCVnWK+HhF8VZR2jRxehM16QcVOdHqPn4VPHmRK4lSr38n9JriurInLcP90xsYNfQ==", + "license": "MIT", "dependencies": { "has-tostringtag": "^1.0.0" }, @@ -6218,40 +5674,35 @@ }, "node_modules/is-extglob": { "version": "2.1.1", - "resolved": "https://registry.npmjs.org/is-extglob/-/is-extglob-2.1.1.tgz", - "integrity": "sha512-SbKbANkN603Vi4jEZv49LeVJMn4yGwsbzZworEoyEiutsN3nJYdbO36zfhGJ6QEDpOZIFkDtnq5JRxmvl3jsoQ==", "dev": true, + "license": "MIT", "engines": { "node": ">=0.10.0" } }, "node_modules/is-fullwidth-code-point": { "version": "3.0.0", - "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-3.0.0.tgz", - "integrity": "sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg==", "dev": true, + "license": "MIT", "engines": { "node": ">=8" } }, "node_modules/is-function": { "version": "1.0.2", - "resolved": "https://registry.npmjs.org/is-function/-/is-function-1.0.2.tgz", - "integrity": "sha512-lw7DUp0aWXYg+CBCN+JKkcE0Q2RayZnSvnZBlwgxHBQhqt5pZNVy4Ri7H9GmmXkdu7LUthszM+Tor1u/2iBcpQ==" + "license": "MIT" }, "node_modules/is-generator-fn": { "version": "2.1.0", - "resolved": "https://registry.npmjs.org/is-generator-fn/-/is-generator-fn-2.1.0.tgz", - "integrity": "sha512-cTIB4yPYL/Grw0EaSzASzg6bBy9gqCofvWN8okThAYIxKJZC+udlRAmGbM0XLeniEJSs8uEgHPGuHSe1XsOLSQ==", "dev": true, + "license": "MIT", "engines": { "node": ">=6" } }, "node_modules/is-generator-function": { "version": "1.0.10", - "resolved": "https://registry.npmjs.org/is-generator-function/-/is-generator-function-1.0.10.tgz", - "integrity": "sha512-jsEjy9l3yiXEQ+PsXdmBwEPcOxaXWLspKdplFUVI9vq1iZgIekeC0L167qeu86czQaxed3q/Uzuw0swL0irL8A==", + "license": "MIT", "dependencies": { "has-tostringtag": "^1.0.0" }, @@ -6264,9 +5715,8 @@ }, "node_modules/is-glob": { "version": "4.0.3", - "resolved": "https://registry.npmjs.org/is-glob/-/is-glob-4.0.3.tgz", - "integrity": "sha512-xelSayHH36ZgE7ZWhli7pW34hNbNl8Ojv5KVmkJD4hBdD3th8Tfk9vYasLM+mXWOZhFkgZfxhLSnrwRr4elSSg==", "dev": true, + "license": "MIT", "dependencies": { "is-extglob": "^2.1.1" }, @@ -6276,8 +5726,7 @@ }, "node_modules/is-hex-prefixed": { "version": "1.0.0", - "resolved": "https://registry.npmjs.org/is-hex-prefixed/-/is-hex-prefixed-1.0.0.tgz", - "integrity": "sha512-WvtOiug1VFrE9v1Cydwm+FnXd3+w9GaeVUss5W4v/SLy3UW00vP+6iNF2SdnfiBoLy4bTqVdkftNGTUeOFVsbA==", + "license": "MIT", "engines": { "node": ">=6.5.0", "npm": ">=3" @@ -6285,8 +5734,7 @@ }, "node_modules/is-negative-zero": { "version": "2.0.2", - "resolved": "https://registry.npmjs.org/is-negative-zero/-/is-negative-zero-2.0.2.tgz", - "integrity": "sha512-dqJvarLawXsFbNDeJW7zAz8ItJ9cd28YufuuFzh0G8pNHjJMnY08Dv7sYX2uF5UpQOwieAeOExEYAWWfu7ZZUA==", + "license": "MIT", "engines": { "node": ">= 0.4" }, @@ -6296,17 +5744,15 @@ }, "node_modules/is-number": { "version": "7.0.0", - "resolved": "https://registry.npmjs.org/is-number/-/is-number-7.0.0.tgz", - "integrity": "sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng==", "dev": true, + "license": "MIT", "engines": { "node": ">=0.12.0" } }, "node_modules/is-number-object": { "version": "1.0.7", - "resolved": "https://registry.npmjs.org/is-number-object/-/is-number-object-1.0.7.tgz", - "integrity": "sha512-k1U0IRzLMo7ZlYIfzRu23Oh6MiIFasgpb9X76eqfFZAqwH44UI4KTBvBYIZ1dSL9ZzChTB9ShHfLkR4pdW5krQ==", + "license": "MIT", "dependencies": { "has-tostringtag": "^1.0.0" }, @@ -6319,17 +5765,15 @@ }, "node_modules/is-plain-obj": { "version": "2.1.0", - "resolved": "https://registry.npmjs.org/is-plain-obj/-/is-plain-obj-2.1.0.tgz", - "integrity": "sha512-YWnfyRwxL/+SsrWYfOpUtz5b3YD+nyfkHvjbcanzk8zgyO4ASD67uVMRt8k5bM4lLMDnXfriRhOpemw+NfT1eA==", "dev": true, + "license": "MIT", "engines": { "node": ">=8" } }, "node_modules/is-regex": { "version": "1.1.4", - "resolved": "https://registry.npmjs.org/is-regex/-/is-regex-1.1.4.tgz", - "integrity": "sha512-kvRdxDsxZjhzUX07ZnLydzS1TU/TJlTUHHY4YLL87e37oUA49DfkLqgy+VjFocowy29cKvcSiu+kIv728jTTVg==", + "license": "MIT", "dependencies": { "call-bind": "^1.0.2", "has-tostringtag": "^1.0.0" @@ -6343,8 +5787,7 @@ }, "node_modules/is-shared-array-buffer": { "version": "1.0.2", - "resolved": "https://registry.npmjs.org/is-shared-array-buffer/-/is-shared-array-buffer-1.0.2.tgz", - "integrity": "sha512-sqN2UDu1/0y6uvXyStCOzyhAjCSlHceFoMKJW8W9EU9cvic/QdsZ0kEU93HEy3IUEFZIiH/3w+AH/UQbPHNdhA==", + "license": "MIT", "dependencies": { "call-bind": "^1.0.2" }, @@ -6354,9 +5797,8 @@ }, "node_modules/is-stream": { "version": "2.0.1", - "resolved": "https://registry.npmjs.org/is-stream/-/is-stream-2.0.1.tgz", - "integrity": "sha512-hFoiJiTl63nn+kstHGBtewWSKnQLpyb155KHheA1l39uvtO9nWIop1p3udqPcUd/xbF1VLMO4n7OI6p7RbngDg==", "dev": true, + "license": "MIT", "engines": { "node": ">=8" }, @@ -6366,8 +5808,7 @@ }, "node_modules/is-string": { "version": "1.0.7", - "resolved": "https://registry.npmjs.org/is-string/-/is-string-1.0.7.tgz", - "integrity": "sha512-tE2UXzivje6ofPW7l23cjDOMa09gb7xlAqG6jG5ej6uPV32TlWP3NKPigtaGeHNu9fohccRYvIiZMfOOnOYUtg==", + "license": "MIT", "dependencies": { "has-tostringtag": "^1.0.0" }, @@ -6380,8 +5821,7 @@ }, "node_modules/is-symbol": { "version": "1.0.4", - "resolved": "https://registry.npmjs.org/is-symbol/-/is-symbol-1.0.4.tgz", - "integrity": "sha512-C/CPBqKWnvdcxqIARxyOh4v1UUEOCHpgDa0WYgpKDFMszcrPcffg5uhwSgPCLD2WWxmq6isisz87tzT01tuGhg==", + "license": "MIT", "dependencies": { "has-symbols": "^1.0.2" }, @@ -6394,8 +5834,7 @@ }, "node_modules/is-typed-array": { "version": "1.1.12", - "resolved": "https://registry.npmjs.org/is-typed-array/-/is-typed-array-1.1.12.tgz", - "integrity": "sha512-Z14TF2JNG8Lss5/HMqt0//T9JeHXttXy5pH/DBU4vi98ozO2btxzq9MwYDZYnKwU8nRsz/+GVFVRDq3DkVuSPg==", + "license": "MIT", "dependencies": { "which-typed-array": "^1.1.11" }, @@ -6408,14 +5847,12 @@ }, "node_modules/is-typedarray": { "version": "1.0.0", - "resolved": "https://registry.npmjs.org/is-typedarray/-/is-typedarray-1.0.0.tgz", - "integrity": "sha512-cyA56iCMHAh5CdzjJIa4aohJyeO1YbwLi3Jc35MmRU6poroFjIGZzUzupGiRPOjgHg9TLu43xbpwXk523fMxKA==" + "license": "MIT" }, "node_modules/is-unicode-supported": { "version": "0.1.0", - "resolved": "https://registry.npmjs.org/is-unicode-supported/-/is-unicode-supported-0.1.0.tgz", - "integrity": "sha512-knxG2q4UC3u8stRGyAVJCOdxFmv5DZiRcdlIaAQXAbSfJya+OhopNotLQrstBhququ4ZpuKbDc/8S6mgXgPFPw==", "dev": true, + "license": "MIT", "engines": { "node": ">=10" }, @@ -6425,8 +5862,7 @@ }, "node_modules/is-weakref": { "version": "1.0.2", - "resolved": "https://registry.npmjs.org/is-weakref/-/is-weakref-1.0.2.tgz", - "integrity": "sha512-qctsuLZmIQ0+vSSMfoVvyFe2+GSEvnmZ2ezTup1SBse9+twCCeial6EEi3Nc2KFcf6+qz2FBPnjXsk8xhKSaPQ==", + "license": "MIT", "dependencies": { "call-bind": "^1.0.2" }, @@ -6436,42 +5872,36 @@ }, "node_modules/isarray": { "version": "2.0.5", - "resolved": "https://registry.npmjs.org/isarray/-/isarray-2.0.5.tgz", - "integrity": "sha512-xHjhDr3cNBK0BzdUJSPXZntQUx/mwMS5Rw4A7lPJ90XGAO6ISP/ePDNuo0vhqOZU+UD5JoodwCAAoZQd3FeAKw==" + "license": "MIT" }, "node_modules/isexe": { "version": "2.0.0", - "resolved": "https://registry.npmjs.org/isexe/-/isexe-2.0.0.tgz", - "integrity": "sha512-RHxMLp9lnKHGHRng9QFhRCMbYAcVpn69smSGcq3f36xjgVVWThj4qqLbTLlq7Ssj8B+fIQ1EuCEGI2lKsyQeIw==", - "dev": true + "dev": true, + "license": "ISC" }, "node_modules/isomorphic-ws": { "version": "4.0.1", - "resolved": "https://registry.npmjs.org/isomorphic-ws/-/isomorphic-ws-4.0.1.tgz", - "integrity": "sha512-BhBvN2MBpWTaSHdWRb/bwdZJ1WaehQ2L1KngkCkfLUGF0mAWAT1sQUQacEmQ0jXkFw/czDXPNQSL5u2/Krsz1w==", + "license": "MIT", "peerDependencies": { "ws": "*" } }, "node_modules/isstream": { "version": "0.1.2", - "resolved": "https://registry.npmjs.org/isstream/-/isstream-0.1.2.tgz", - "integrity": "sha512-Yljz7ffyPbrLpLngrMtZ7NduUgVvi6wG9RJ9IUcyCd59YQ911PBJphODUcbOVbqYfxe1wuYf/LJ8PauMRwsM/g==" + "license": "MIT" }, "node_modules/istanbul-lib-coverage": { - "version": "3.2.0", - "resolved": "https://registry.npmjs.org/istanbul-lib-coverage/-/istanbul-lib-coverage-3.2.0.tgz", - "integrity": "sha512-eOeJ5BHCmHYvQK7xt9GkdHuzuCGS1Y6g9Gvnx3Ym33fz/HpLRYxiS0wHNr+m/MBC8B647Xt608vCDEvhl9c6Mw==", + "version": "3.2.2", "dev": true, + "license": "BSD-3-Clause", "engines": { "node": ">=8" } }, "node_modules/istanbul-lib-instrument": { "version": "5.2.1", - "resolved": "https://registry.npmjs.org/istanbul-lib-instrument/-/istanbul-lib-instrument-5.2.1.tgz", - "integrity": "sha512-pzqtp31nLv/XFOzXGuvhCb8qhjmTVo5vjVk19XE4CRlSWz0KoeJ3bw9XsA7nOp9YBf4qHjwBxkDzKcME/J29Yg==", "dev": true, + "license": "BSD-3-Clause", "dependencies": { "@babel/core": "^7.12.3", "@babel/parser": "^7.14.7", @@ -6485,18 +5915,16 @@ }, "node_modules/istanbul-lib-instrument/node_modules/semver": { "version": "6.3.1", - "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.1.tgz", - "integrity": "sha512-BR7VvDCVHO+q2xBEWskxS6DJE1qRnb7DxzUrogb71CWoSficBxYsiAGd+Kl0mmq/MprG9yArRkyrQxTO6XjMzA==", "dev": true, + "license": "ISC", "bin": { "semver": "bin/semver.js" } }, "node_modules/istanbul-lib-report": { "version": "3.0.1", - "resolved": "https://registry.npmjs.org/istanbul-lib-report/-/istanbul-lib-report-3.0.1.tgz", - "integrity": "sha512-GCfE1mtsHGOELCU8e/Z7YWzpmybrx/+dSTfLrvY8qRmaY6zXTKWn6WQIjaAFw069icm6GVMNkgu0NzI4iPZUNw==", "dev": true, + "license": "BSD-3-Clause", "dependencies": { "istanbul-lib-coverage": "^3.0.0", "make-dir": "^4.0.0", @@ -6508,9 +5936,8 @@ }, "node_modules/istanbul-lib-source-maps": { "version": "4.0.1", - "resolved": "https://registry.npmjs.org/istanbul-lib-source-maps/-/istanbul-lib-source-maps-4.0.1.tgz", - "integrity": "sha512-n3s8EwkdFIJCG3BPKBYvskgXGoy88ARzvegkitk60NxRdwltLOTaH7CUiMRXvwYorl0Q712iEjcWB+fK/MrWVw==", "dev": true, + "license": "BSD-3-Clause", "dependencies": { "debug": "^4.1.1", "istanbul-lib-coverage": "^3.0.0", @@ -6522,9 +5949,8 @@ }, "node_modules/istanbul-reports": { "version": "3.1.6", - "resolved": "https://registry.npmjs.org/istanbul-reports/-/istanbul-reports-3.1.6.tgz", - "integrity": "sha512-TLgnMkKg3iTDsQ9PbPTdpfAK2DzjF9mqUG7RMgcQl8oFjad8ob4laGxv5XV5U9MAfx8D6tSJiUyuAwzLicaxlg==", "dev": true, + "license": "BSD-3-Clause", "dependencies": { "html-escaper": "^2.0.0", "istanbul-lib-report": "^3.0.0" @@ -6540,9 +5966,8 @@ }, "node_modules/jest": { "version": "28.1.3", - "resolved": "https://registry.npmjs.org/jest/-/jest-28.1.3.tgz", - "integrity": "sha512-N4GT5on8UkZgH0O5LUavMRV1EDEhNTL0KEfRmDIeZHSV7p2XgLoY9t9VDUgL6o+yfdgYHVxuz81G8oB9VG5uyA==", "dev": true, + "license": "MIT", "dependencies": { "@jest/core": "^28.1.3", "@jest/types": "^28.1.3", @@ -6566,9 +5991,8 @@ }, "node_modules/jest-changed-files": { "version": "28.1.3", - "resolved": "https://registry.npmjs.org/jest-changed-files/-/jest-changed-files-28.1.3.tgz", - "integrity": "sha512-esaOfUWJXk2nfZt9SPyC8gA1kNfdKLkQWyzsMlqq8msYSlNKfmZxfRgZn4Cd4MGVUF+7v6dBs0d5TOAKa7iIiA==", "dev": true, + "license": "MIT", "dependencies": { "execa": "^5.0.0", "p-limit": "^3.1.0" @@ -6579,9 +6003,8 @@ }, "node_modules/jest-circus": { "version": "28.1.3", - "resolved": "https://registry.npmjs.org/jest-circus/-/jest-circus-28.1.3.tgz", - "integrity": "sha512-cZ+eS5zc79MBwt+IhQhiEp0OeBddpc1n8MBo1nMB8A7oPMKEO+Sre+wHaLJexQUj9Ya/8NOBY0RESUgYjB6fow==", "dev": true, + "license": "MIT", "dependencies": { "@jest/environment": "^28.1.3", "@jest/expect": "^28.1.3", @@ -6609,9 +6032,8 @@ }, "node_modules/jest-cli": { "version": "28.1.3", - "resolved": "https://registry.npmjs.org/jest-cli/-/jest-cli-28.1.3.tgz", - "integrity": "sha512-roY3kvrv57Azn1yPgdTebPAXvdR2xfezaKKYzVxZ6It/5NCxzJym6tUI5P1zkdWhfUYkxEI9uZWcQdaFLo8mJQ==", "dev": true, + "license": "MIT", "dependencies": { "@jest/core": "^28.1.3", "@jest/test-result": "^28.1.3", @@ -6643,9 +6065,8 @@ }, "node_modules/jest-config": { "version": "28.1.3", - "resolved": "https://registry.npmjs.org/jest-config/-/jest-config-28.1.3.tgz", - "integrity": "sha512-MG3INjByJ0J4AsNBm7T3hsuxKQqFIiRo/AUqb1q9LRKI5UU6Aar9JHbr9Ivn1TVwfUD9KirRoM/T6u8XlcQPHQ==", "dev": true, + "license": "MIT", "dependencies": { "@babel/core": "^7.11.6", "@jest/test-sequencer": "^28.1.3", @@ -6688,9 +6109,8 @@ }, "node_modules/jest-diff": { "version": "28.1.3", - "resolved": "https://registry.npmjs.org/jest-diff/-/jest-diff-28.1.3.tgz", - "integrity": "sha512-8RqP1B/OXzjjTWkqMX67iqgwBVJRgCyKD3L9nq+6ZqJMdvjE8RgHktqZ6jNrkdMT+dJuYNI3rhQpxaz7drJHfw==", "dev": true, + "license": "MIT", "dependencies": { "chalk": "^4.0.0", "diff-sequences": "^28.1.1", @@ -6703,9 +6123,8 @@ }, "node_modules/jest-docblock": { "version": "28.1.1", - "resolved": "https://registry.npmjs.org/jest-docblock/-/jest-docblock-28.1.1.tgz", - "integrity": "sha512-3wayBVNiOYx0cwAbl9rwm5kKFP8yHH3d/fkEaL02NPTkDojPtheGB7HZSFY4wzX+DxyrvhXz0KSCVksmCknCuA==", "dev": true, + "license": "MIT", "dependencies": { "detect-newline": "^3.0.0" }, @@ -6715,9 +6134,8 @@ }, "node_modules/jest-each": { "version": "28.1.3", - "resolved": "https://registry.npmjs.org/jest-each/-/jest-each-28.1.3.tgz", - "integrity": "sha512-arT1z4sg2yABU5uogObVPvSlSMQlDA48owx07BDPAiasW0yYpYHYOo4HHLz9q0BVzDVU4hILFjzJw0So9aCL/g==", "dev": true, + "license": "MIT", "dependencies": { "@jest/types": "^28.1.3", "chalk": "^4.0.0", @@ -6731,9 +6149,8 @@ }, "node_modules/jest-environment-node": { "version": "28.1.3", - "resolved": "https://registry.npmjs.org/jest-environment-node/-/jest-environment-node-28.1.3.tgz", - "integrity": "sha512-ugP6XOhEpjAEhGYvp5Xj989ns5cB1K6ZdjBYuS30umT4CQEETaxSiPcZ/E1kFktX4GkrcM4qu07IIlDYX1gp+A==", "dev": true, + "license": "MIT", "dependencies": { "@jest/environment": "^28.1.3", "@jest/fake-timers": "^28.1.3", @@ -6748,18 +6165,16 @@ }, "node_modules/jest-get-type": { "version": "28.0.2", - "resolved": "https://registry.npmjs.org/jest-get-type/-/jest-get-type-28.0.2.tgz", - "integrity": "sha512-ioj2w9/DxSYHfOm5lJKCdcAmPJzQXmbM/Url3rhlghrPvT3tt+7a/+oXc9azkKmLvoiXjtV83bEWqi+vs5nlPA==", "dev": true, + "license": "MIT", "engines": { "node": "^12.13.0 || ^14.15.0 || ^16.10.0 || >=17.0.0" } }, "node_modules/jest-haste-map": { "version": "28.1.3", - "resolved": "https://registry.npmjs.org/jest-haste-map/-/jest-haste-map-28.1.3.tgz", - "integrity": "sha512-3S+RQWDXccXDKSWnkHa/dPwt+2qwA8CJzR61w3FoYCvoo3Pn8tvGcysmMF0Bj0EX5RYvAI2EIvC57OmotfdtKA==", "dev": true, + "license": "MIT", "dependencies": { "@jest/types": "^28.1.3", "@types/graceful-fs": "^4.1.3", @@ -6782,9 +6197,8 @@ }, "node_modules/jest-leak-detector": { "version": "28.1.3", - "resolved": "https://registry.npmjs.org/jest-leak-detector/-/jest-leak-detector-28.1.3.tgz", - "integrity": "sha512-WFVJhnQsiKtDEo5lG2mM0v40QWnBM+zMdHHyJs8AWZ7J0QZJS59MsyKeJHWhpBZBH32S48FOVvGyOFT1h0DlqA==", "dev": true, + "license": "MIT", "dependencies": { "jest-get-type": "^28.0.2", "pretty-format": "^28.1.3" @@ -6795,9 +6209,8 @@ }, "node_modules/jest-matcher-utils": { "version": "28.1.3", - "resolved": "https://registry.npmjs.org/jest-matcher-utils/-/jest-matcher-utils-28.1.3.tgz", - "integrity": "sha512-kQeJ7qHemKfbzKoGjHHrRKH6atgxMk8Enkk2iPQ3XwO6oE/KYD8lMYOziCkeSB9G4adPM4nR1DE8Tf5JeWH6Bw==", "dev": true, + "license": "MIT", "dependencies": { "chalk": "^4.0.0", "jest-diff": "^28.1.3", @@ -6810,9 +6223,8 @@ }, "node_modules/jest-message-util": { "version": "28.1.3", - "resolved": "https://registry.npmjs.org/jest-message-util/-/jest-message-util-28.1.3.tgz", - "integrity": "sha512-PFdn9Iewbt575zKPf1286Ht9EPoJmYT7P0kY+RibeYZ2XtOr53pDLEFoTWXbd1h4JiGiWpTBC84fc8xMXQMb7g==", "dev": true, + "license": "MIT", "dependencies": { "@babel/code-frame": "^7.12.13", "@jest/types": "^28.1.3", @@ -6829,12 +6241,11 @@ } }, "node_modules/jest-message-util/node_modules/@babel/code-frame": { - "version": "7.22.13", - "resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.22.13.tgz", - "integrity": "sha512-XktuhWlJ5g+3TJXc5upd9Ks1HutSArik6jf2eAjYFyIOf4ej3RN+184cZbzDvbPnuTJIUhPKKJE3cIsYTiAT3w==", + "version": "7.23.5", "dev": true, + "license": "MIT", "dependencies": { - "@babel/highlight": "^7.22.13", + "@babel/highlight": "^7.23.4", "chalk": "^2.4.2" }, "engines": { @@ -6843,9 +6254,8 @@ }, "node_modules/jest-message-util/node_modules/@babel/code-frame/node_modules/chalk": { "version": "2.4.2", - "resolved": "https://registry.npmjs.org/chalk/-/chalk-2.4.2.tgz", - "integrity": "sha512-Mti+f9lpJNcwF4tWV8/OrTTtF1gZi+f8FqlyAdouralcFWFQWF2+NgCHShjkCb+IFBLq9buZwE1xckQU4peSuQ==", "dev": true, + "license": "MIT", "dependencies": { "ansi-styles": "^3.2.1", "escape-string-regexp": "^1.0.5", @@ -6857,9 +6267,8 @@ }, "node_modules/jest-message-util/node_modules/ansi-styles": { "version": "3.2.1", - "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-3.2.1.tgz", - "integrity": "sha512-VT0ZI6kZRdTh8YyJw3SMbYm/u+NqfsAxEpWO0Pf9sq8/e94WxxOpPKx9FR1FlyCtOVDNOQ+8ntlqFxiRc+r5qA==", "dev": true, + "license": "MIT", "dependencies": { "color-convert": "^1.9.0" }, @@ -6869,42 +6278,37 @@ }, "node_modules/jest-message-util/node_modules/color-convert": { "version": "1.9.3", - "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-1.9.3.tgz", - "integrity": "sha512-QfAUtd+vFdAtFQcC8CCyYt1fYWxSqAiK2cSD6zDB8N3cpsEBAvRxp9zOGg6G/SHHJYAT88/az/IuDGALsNVbGg==", "dev": true, + "license": "MIT", "dependencies": { "color-name": "1.1.3" } }, "node_modules/jest-message-util/node_modules/color-name": { "version": "1.1.3", - "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.3.tgz", - "integrity": "sha512-72fSenhMw2HZMTVHeCA9KCmpEIbzWiQsjN+BHcBbS9vr1mtt+vJjPdksIBNUmKAW8TFUDPJK5SUU3QhE9NEXDw==", - "dev": true + "dev": true, + "license": "MIT" }, "node_modules/jest-message-util/node_modules/escape-string-regexp": { "version": "1.0.5", - "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz", - "integrity": "sha512-vbRorB5FUQWvla16U8R/qgaFIya2qGzwDrNmCZuYKrbdSUMG6I1ZCGQRefkRVhuOkIGVne7BQ35DSfo1qvJqFg==", "dev": true, + "license": "MIT", "engines": { "node": ">=0.8.0" } }, "node_modules/jest-message-util/node_modules/has-flag": { "version": "3.0.0", - "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-3.0.0.tgz", - "integrity": "sha512-sKJf1+ceQBr4SMkvQnBDNDtf4TXpVhVGateu0t918bl30FnbE2m4vNLX+VWe/dpjlb+HugGYzW7uQXH98HPEYw==", "dev": true, + "license": "MIT", "engines": { "node": ">=4" } }, "node_modules/jest-message-util/node_modules/supports-color": { "version": "5.5.0", - "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.5.0.tgz", - "integrity": "sha512-QjVjwdXIt408MIiAqCX4oUKsgU2EqAGzs2Ppkm4aQYbjm+ZEWEcW4SfFNTr4uMNZma0ey4f5lgLrkB0aX0QMow==", "dev": true, + "license": "MIT", "dependencies": { "has-flag": "^3.0.0" }, @@ -6914,9 +6318,8 @@ }, "node_modules/jest-mock": { "version": "28.1.3", - "resolved": "https://registry.npmjs.org/jest-mock/-/jest-mock-28.1.3.tgz", - "integrity": "sha512-o3J2jr6dMMWYVH4Lh/NKmDXdosrsJgi4AviS8oXLujcjpCMBb1FMsblDnOXKZKfSiHLxYub1eS0IHuRXsio9eA==", "dev": true, + "license": "MIT", "dependencies": { "@jest/types": "^28.1.3", "@types/node": "*" @@ -6927,9 +6330,8 @@ }, "node_modules/jest-pnp-resolver": { "version": "1.2.3", - "resolved": "https://registry.npmjs.org/jest-pnp-resolver/-/jest-pnp-resolver-1.2.3.tgz", - "integrity": "sha512-+3NpwQEnRoIBtx4fyhblQDPgJI0H1IEIkX7ShLUjPGA7TtUTvI1oiKi3SR4oBR0hQhQR80l4WAe5RrXBwWMA8w==", "dev": true, + "license": "MIT", "engines": { "node": ">=6" }, @@ -6944,18 +6346,16 @@ }, "node_modules/jest-regex-util": { "version": "28.0.2", - "resolved": "https://registry.npmjs.org/jest-regex-util/-/jest-regex-util-28.0.2.tgz", - "integrity": "sha512-4s0IgyNIy0y9FK+cjoVYoxamT7Zeo7MhzqRGx7YDYmaQn1wucY9rotiGkBzzcMXTtjrCAP/f7f+E0F7+fxPNdw==", "dev": true, + "license": "MIT", "engines": { "node": "^12.13.0 || ^14.15.0 || ^16.10.0 || >=17.0.0" } }, "node_modules/jest-resolve": { "version": "28.1.3", - "resolved": "https://registry.npmjs.org/jest-resolve/-/jest-resolve-28.1.3.tgz", - "integrity": "sha512-Z1W3tTjE6QaNI90qo/BJpfnvpxtaFTFw5CDgwpyE/Kz8U/06N1Hjf4ia9quUhCh39qIGWF1ZuxFiBiJQwSEYKQ==", "dev": true, + "license": "MIT", "dependencies": { "chalk": "^4.0.0", "graceful-fs": "^4.2.9", @@ -6973,9 +6373,8 @@ }, "node_modules/jest-resolve-dependencies": { "version": "28.1.3", - "resolved": "https://registry.npmjs.org/jest-resolve-dependencies/-/jest-resolve-dependencies-28.1.3.tgz", - "integrity": "sha512-qa0QO2Q0XzQoNPouMbCc7Bvtsem8eQgVPNkwn9LnS+R2n8DaVDPL/U1gngC0LTl1RYXJU0uJa2BMC2DbTfFrHA==", "dev": true, + "license": "MIT", "dependencies": { "jest-regex-util": "^28.0.2", "jest-snapshot": "^28.1.3" @@ -6986,9 +6385,8 @@ }, "node_modules/jest-runner": { "version": "28.1.3", - "resolved": "https://registry.npmjs.org/jest-runner/-/jest-runner-28.1.3.tgz", - "integrity": "sha512-GkMw4D/0USd62OVO0oEgjn23TM+YJa2U2Wu5zz9xsQB1MxWKDOlrnykPxnMsN0tnJllfLPinHTka61u0QhaxBA==", "dev": true, + "license": "MIT", "dependencies": { "@jest/console": "^28.1.3", "@jest/environment": "^28.1.3", @@ -7018,9 +6416,8 @@ }, "node_modules/jest-runtime": { "version": "28.1.3", - "resolved": "https://registry.npmjs.org/jest-runtime/-/jest-runtime-28.1.3.tgz", - "integrity": "sha512-NU+881ScBQQLc1JHG5eJGU7Ui3kLKrmwCPPtYsJtBykixrM2OhVQlpMmFWJjMyDfdkGgBMNjXCGB/ebzsgNGQw==", "dev": true, + "license": "MIT", "dependencies": { "@jest/environment": "^28.1.3", "@jest/fake-timers": "^28.1.3", @@ -7051,9 +6448,8 @@ }, "node_modules/jest-snapshot": { "version": "28.1.3", - "resolved": "https://registry.npmjs.org/jest-snapshot/-/jest-snapshot-28.1.3.tgz", - "integrity": "sha512-4lzMgtiNlc3DU/8lZfmqxN3AYD6GGLbl+72rdBpXvcV+whX7mDrREzkPdp2RnmfIiWBg1YbuFSkXduF2JcafJg==", "dev": true, + "license": "MIT", "dependencies": { "@babel/core": "^7.11.6", "@babel/generator": "^7.7.2", @@ -7085,9 +6481,8 @@ }, "node_modules/jest-util": { "version": "28.1.3", - "resolved": "https://registry.npmjs.org/jest-util/-/jest-util-28.1.3.tgz", - "integrity": "sha512-XdqfpHwpcSRko/C35uLYFM2emRAltIIKZiJ9eAmhjsj0CqZMa0p1ib0R5fWIqGhn1a103DebTbpqIaP1qCQ6tQ==", "dev": true, + "license": "MIT", "dependencies": { "@jest/types": "^28.1.3", "@types/node": "*", @@ -7102,9 +6497,8 @@ }, "node_modules/jest-validate": { "version": "28.1.3", - "resolved": "https://registry.npmjs.org/jest-validate/-/jest-validate-28.1.3.tgz", - "integrity": "sha512-SZbOGBWEsaTxBGCOpsRWlXlvNkvTkY0XxRfh7zYmvd8uL5Qzyg0CHAXiXKROflh801quA6+/DsT4ODDthOC/OA==", "dev": true, + "license": "MIT", "dependencies": { "@jest/types": "^28.1.3", "camelcase": "^6.2.0", @@ -7119,9 +6513,8 @@ }, "node_modules/jest-validate/node_modules/camelcase": { "version": "6.3.0", - "resolved": "https://registry.npmjs.org/camelcase/-/camelcase-6.3.0.tgz", - "integrity": "sha512-Gmy6FhYlCY7uOElZUSbxo2UCDH8owEk996gkbrpsgGtrJLM3J7jGxl9Ic7Qwwj4ivOE5AWZWRMecDdF7hqGjFA==", "dev": true, + "license": "MIT", "engines": { "node": ">=10" }, @@ -7131,9 +6524,8 @@ }, "node_modules/jest-watcher": { "version": "28.1.3", - "resolved": "https://registry.npmjs.org/jest-watcher/-/jest-watcher-28.1.3.tgz", - "integrity": "sha512-t4qcqj9hze+jviFPUN3YAtAEeFnr/azITXQEMARf5cMwKY2SMBRnCQTXLixTl20OR6mLh9KLMrgVJgJISym+1g==", "dev": true, + "license": "MIT", "dependencies": { "@jest/test-result": "^28.1.3", "@jest/types": "^28.1.3", @@ -7150,9 +6542,8 @@ }, "node_modules/jest-worker": { "version": "28.1.3", - "resolved": "https://registry.npmjs.org/jest-worker/-/jest-worker-28.1.3.tgz", - "integrity": "sha512-CqRA220YV/6jCo8VWvAt1KKx6eek1VIHMPeLEbpcfSfkEeWyBNppynM/o6q+Wmw+sOhos2ml34wZbSX3G13//g==", "dev": true, + "license": "MIT", "dependencies": { "@types/node": "*", "merge-stream": "^2.0.0", @@ -7164,9 +6555,8 @@ }, "node_modules/jest-worker/node_modules/supports-color": { "version": "8.1.1", - "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-8.1.1.tgz", - "integrity": "sha512-MpUEN2OodtUzxvKQl72cUF7RQ5EiHsGvSsVG0ia9c5RbWGL2CI4C7EpPS8UTBIplnlzZiNuV56w+FuNxy3ty2Q==", "dev": true, + "license": "MIT", "dependencies": { "has-flag": "^4.0.0" }, @@ -7179,20 +6569,17 @@ }, "node_modules/js-sha3": { "version": "0.8.0", - "resolved": "https://registry.npmjs.org/js-sha3/-/js-sha3-0.8.0.tgz", - "integrity": "sha512-gF1cRrHhIzNfToc802P800N8PpXS+evLLXfsVpowqmAFR9uwbi89WvXg2QspOmXL8QL86J4T1EpFu+yUkwJY3Q==" + "license": "MIT" }, "node_modules/js-tokens": { "version": "4.0.0", - "resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-4.0.0.tgz", - "integrity": "sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ==", - "dev": true + "dev": true, + "license": "MIT" }, "node_modules/js-yaml": { "version": "3.14.1", - "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-3.14.1.tgz", - "integrity": "sha512-okMH7OXXJ7YrN9Ok3/SXrnu4iX9yOk+25nqX4imS2npuvTYDmo/QEZoqwZkYaIDk3jVvBOTOIEgEhaLOynBS9g==", "dev": true, + "license": "MIT", "dependencies": { "argparse": "^1.0.7", "esprima": "^4.0.0" @@ -7201,16 +6588,18 @@ "js-yaml": "bin/js-yaml.js" } }, + "node_modules/jsbi": { + "version": "4.3.0", + "license": "Apache-2.0" + }, "node_modules/jsbn": { "version": "0.1.1", - "resolved": "https://registry.npmjs.org/jsbn/-/jsbn-0.1.1.tgz", - "integrity": "sha512-UVU9dibq2JcFWxQPA6KCqj5O42VOmAY3zQUfEKxU0KpTGXwNoCjkX1e13eHNvw/xPynt6pU0rZ1htjWTNTSXsg==" + "license": "MIT" }, "node_modules/jsesc": { "version": "2.5.2", - "resolved": "https://registry.npmjs.org/jsesc/-/jsesc-2.5.2.tgz", - "integrity": "sha512-OYu7XEzjkCQ3C5Ps3QIZsQfNpqoJyZZA99wd9aWd05NCtC5pWOkShK2mkL6HXQR6/Cy2lbNdPlZBpuQHXE63gA==", "dev": true, + "license": "MIT", "bin": { "jsesc": "bin/jsesc" }, @@ -7220,41 +6609,34 @@ }, "node_modules/json-buffer": { "version": "3.0.1", - "resolved": "https://registry.npmjs.org/json-buffer/-/json-buffer-3.0.1.tgz", - "integrity": "sha512-4bV5BfR2mqfQTJm+V5tPPdf+ZpuhiIvTuAB5g8kcrXOZpTT/QwwVRWBywX1ozr6lEuPdbHxwaJlm9G6mI2sfSQ==" + "license": "MIT" }, "node_modules/json-parse-even-better-errors": { "version": "2.3.1", - "resolved": "https://registry.npmjs.org/json-parse-even-better-errors/-/json-parse-even-better-errors-2.3.1.tgz", - "integrity": "sha512-xyFwyhro/JEof6Ghe2iz2NcXoj2sloNsWr/XsERDK/oiPCfaNhl5ONfp+jQdAZRQQ0IJWNzH9zIZF7li91kh2w==", - "dev": true + "dev": true, + "license": "MIT" }, "node_modules/json-schema": { "version": "0.4.0", - "resolved": "https://registry.npmjs.org/json-schema/-/json-schema-0.4.0.tgz", - "integrity": "sha512-es94M3nTIfsEPisRafak+HDLfHXnKBhV3vU5eqPcS3flIWqcxJWgXHXiey3YrpaNsanY5ei1VoYEbOzijuq9BA==" + "license": "(AFL-2.1 OR BSD-3-Clause)" }, "node_modules/json-schema-traverse": { "version": "0.4.1", - "resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-0.4.1.tgz", - "integrity": "sha512-xbbCH5dCYU5T8LcEhhuh7HJ88HXuW3qsI3Y0zOZFKfZEHcpWiHU/Jxzk629Brsab/mMiHQti9wMP+845RPe3Vg==" + "license": "MIT" }, "node_modules/json-stable-stringify-without-jsonify": { "version": "1.0.1", - "resolved": "https://registry.npmjs.org/json-stable-stringify-without-jsonify/-/json-stable-stringify-without-jsonify-1.0.1.tgz", - "integrity": "sha512-Bdboy+l7tA3OGW6FjyFHWkP5LuByj1Tk33Ljyq0axyzdk9//JSi2u3fP1QSmd1KNwq6VOKYGlAu87CisVir6Pw==", - "dev": true + "dev": true, + "license": "MIT" }, "node_modules/json-stringify-safe": { "version": "5.0.1", - "resolved": "https://registry.npmjs.org/json-stringify-safe/-/json-stringify-safe-5.0.1.tgz", - "integrity": "sha512-ZClg6AaYvamvYEE82d3Iyd3vSSIjQ+odgjaTzRuO3s7toCdFKczob2i0zCh7JE8kWn17yvAWhUVxvqGwUalsRA==" + "license": "ISC" }, "node_modules/json5": { "version": "2.2.3", - "resolved": "https://registry.npmjs.org/json5/-/json5-2.2.3.tgz", - "integrity": "sha512-XmOWe7eyHYH14cLdVPoyg+GOH3rYX++KpzrylJwSW98t3Nk+U8XOl8FWKOgwtzdb8lXGf6zYwDUzeHMWfxasyg==", "dev": true, + "license": "MIT", "bin": { "json5": "lib/cli.js" }, @@ -7264,16 +6646,14 @@ }, "node_modules/jsonfile": { "version": "4.0.0", - "resolved": "https://registry.npmjs.org/jsonfile/-/jsonfile-4.0.0.tgz", - "integrity": "sha512-m6F1R3z8jjlf2imQHS2Qez5sjKWQzbuuhuJ/FKYFRZvPE3PuHcSMVZzfsLhGVOkfd20obL5SWEBew5ShlquNxg==", + "license": "MIT", "optionalDependencies": { "graceful-fs": "^4.1.6" } }, "node_modules/jsonld": { "version": "8.3.1", - "resolved": "https://registry.npmjs.org/jsonld/-/jsonld-8.3.1.tgz", - "integrity": "sha512-tYfKpWL56meSJCHS91Ph0+EUThHZOZ8bKuboME4998SF+Kkukp2PhCPdRCvA7tsGUKr9FvSoyIRqJPuImBcBuA==", + "license": "BSD-3-Clause", "dependencies": { "@digitalbazaar/http-client": "^3.4.1", "canonicalize": "^1.0.1", @@ -7286,8 +6666,7 @@ }, "node_modules/jsonld-signatures": { "version": "9.3.1", - "resolved": "https://registry.npmjs.org/jsonld-signatures/-/jsonld-signatures-9.3.1.tgz", - "integrity": "sha512-OasKERvvbfbuItVFrb0pOHiclHPvT98IAorayZnEj48/E0Vz3rTPLzC14rDi1CEXjiiTGeNadLzTLdomdeZEAQ==", + "license": "BSD-3-Clause", "dependencies": { "jsonld": "^5.0.0", "security-context": "^4.0.0", @@ -7299,8 +6678,7 @@ }, "node_modules/jsonld-signatures/node_modules/@digitalbazaar/http-client": { "version": "1.2.0", - "resolved": "https://registry.npmjs.org/@digitalbazaar/http-client/-/http-client-1.2.0.tgz", - "integrity": "sha512-W9KQQ5pUJcaR0I4c2HPJC0a7kRbZApIorZgPnEDwMBgj16iQzutGLrCXYaZOmxqVLVNqqlQ4aUJh+HBQZy4W6Q==", + "license": "BSD-3-Clause", "dependencies": { "esm": "^3.2.22", "ky": "^0.25.1", @@ -7312,8 +6690,7 @@ }, "node_modules/jsonld-signatures/node_modules/jsonld": { "version": "5.2.0", - "resolved": "https://registry.npmjs.org/jsonld/-/jsonld-5.2.0.tgz", - "integrity": "sha512-JymgT6Xzk5CHEmHuEyvoTNviEPxv6ihLWSPu1gFdtjSAyM6cFqNrv02yS/SIur3BBIkCf0HjizRc24d8/FfQKw==", + "license": "BSD-3-Clause", "dependencies": { "@digitalbazaar/http-client": "^1.1.0", "canonicalize": "^1.0.1", @@ -7326,8 +6703,7 @@ }, "node_modules/jsonld-signatures/node_modules/ky": { "version": "0.25.1", - "resolved": "https://registry.npmjs.org/ky/-/ky-0.25.1.tgz", - "integrity": "sha512-PjpCEWlIU7VpiMVrTwssahkYXX1by6NCT0fhTUX34F3DTinARlgMpriuroolugFPcMgpPWrOW4mTb984Qm1RXA==", + "license": "MIT", "engines": { "node": ">=10" }, @@ -7337,8 +6713,7 @@ }, "node_modules/jsonld-signatures/node_modules/ky-universal": { "version": "0.8.2", - "resolved": "https://registry.npmjs.org/ky-universal/-/ky-universal-0.8.2.tgz", - "integrity": "sha512-xe0JaOH9QeYxdyGLnzUOVGK4Z6FGvDVzcXFTdrYA1f33MZdEa45sUDaMBy98xQMcsd2XIBrTXRrRYnegcSdgVQ==", + "license": "MIT", "dependencies": { "abort-controller": "^3.0.0", "node-fetch": "3.0.0-beta.9" @@ -7361,8 +6736,7 @@ }, "node_modules/jsonld-signatures/node_modules/lru-cache": { "version": "6.0.0", - "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-6.0.0.tgz", - "integrity": "sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA==", + "license": "ISC", "dependencies": { "yallist": "^4.0.0" }, @@ -7372,8 +6746,7 @@ }, "node_modules/jsonld-signatures/node_modules/node-fetch": { "version": "3.0.0-beta.9", - "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-3.0.0-beta.9.tgz", - "integrity": "sha512-RdbZCEynH2tH46+tj0ua9caUHVWrd/RHnRfvly2EVdqGmI3ndS1Vn/xjm5KuGejDt2RNDQsVRLPNd2QPwcewVg==", + "license": "MIT", "dependencies": { "data-uri-to-buffer": "^3.0.1", "fetch-blob": "^2.1.1" @@ -7388,13 +6761,11 @@ }, "node_modules/jsonld-signatures/node_modules/yallist": { "version": "4.0.0", - "resolved": "https://registry.npmjs.org/yallist/-/yallist-4.0.0.tgz", - "integrity": "sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==" + "license": "ISC" }, "node_modules/jsonld/node_modules/lru-cache": { "version": "6.0.0", - "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-6.0.0.tgz", - "integrity": "sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA==", + "license": "ISC", "dependencies": { "yallist": "^4.0.0" }, @@ -7404,13 +6775,11 @@ }, "node_modules/jsonld/node_modules/yallist": { "version": "4.0.0", - "resolved": "https://registry.npmjs.org/yallist/-/yallist-4.0.0.tgz", - "integrity": "sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==" + "license": "ISC" }, "node_modules/jsonwebtoken": { "version": "9.0.2", - "resolved": "https://registry.npmjs.org/jsonwebtoken/-/jsonwebtoken-9.0.2.tgz", - "integrity": "sha512-PRp66vJ865SSqOlgqS8hujT5U4AOgMfhrwYIuIhfKaoSCZcirrmASQr8CX7cUg+RMih+hgznrjp99o+W4pJLHQ==", + "license": "MIT", "dependencies": { "jws": "^3.2.2", "lodash.includes": "^4.3.0", @@ -7430,8 +6799,7 @@ }, "node_modules/jsprim": { "version": "1.4.2", - "resolved": "https://registry.npmjs.org/jsprim/-/jsprim-1.4.2.tgz", - "integrity": "sha512-P2bSOMAc/ciLz6DzgjVlGJP9+BrJWu5UDGK70C2iweC5QBIeFf0ZXRvGjEj2uYgrY2MkAAhsSWHDWlFtEroZWw==", + "license": "MIT", "dependencies": { "assert-plus": "1.0.0", "extsprintf": "1.3.0", @@ -7444,8 +6812,7 @@ }, "node_modules/jwa": { "version": "1.4.1", - "resolved": "https://registry.npmjs.org/jwa/-/jwa-1.4.1.tgz", - "integrity": "sha512-qiLX/xhEEFKUAJ6FiBMbes3w9ATzyk5W7Hvzpa/SLYdxNtng+gcurvrI7TbACjIXlsJyr05/S1oUhZrc63evQA==", + "license": "MIT", "dependencies": { "buffer-equal-constant-time": "1.0.1", "ecdsa-sig-formatter": "1.0.11", @@ -7454,18 +6821,16 @@ }, "node_modules/jws": { "version": "3.2.2", - "resolved": "https://registry.npmjs.org/jws/-/jws-3.2.2.tgz", - "integrity": "sha512-YHlZCB6lMTllWDtSPHz/ZXTsi8S00usEV6v1tjq8tOUZzw7DpSDWVXjXDre6ed1w/pd495ODpHZYSdkRTsa0HA==", + "license": "MIT", "dependencies": { "jwa": "^1.4.1", "safe-buffer": "^5.0.1" } }, "node_modules/keccak": { - "version": "3.0.3", - "resolved": "https://registry.npmjs.org/keccak/-/keccak-3.0.3.tgz", - "integrity": "sha512-JZrLIAJWuZxKbCilMpNz5Vj7Vtb4scDG3dMXLOsbzBmQGyjwE61BbW7bJkfKKCShXiQZt3T6sBgALRtmd+nZaQ==", + "version": "3.0.4", "hasInstallScript": true, + "license": "MIT", "dependencies": { "node-addon-api": "^2.0.0", "node-gyp-build": "^4.2.0", @@ -7476,26 +6841,23 @@ } }, "node_modules/keyv": { - "version": "4.5.3", - "resolved": "https://registry.npmjs.org/keyv/-/keyv-4.5.3.tgz", - "integrity": "sha512-QCiSav9WaX1PgETJ+SpNnx2PRRapJ/oRSXM4VO5OGYGSjrxbKPVFVhB3l2OCbLCk329N8qyAtsJjSjvVBWzEug==", + "version": "4.5.4", + "license": "MIT", "dependencies": { "json-buffer": "3.0.1" } }, "node_modules/kleur": { "version": "3.0.3", - "resolved": "https://registry.npmjs.org/kleur/-/kleur-3.0.3.tgz", - "integrity": "sha512-eTIzlVOSUR+JxdDFepEYcBMtZ9Qqdef+rnzWdRZuMbOywu5tO2w2N7rqjoANZ5k9vywhL6Br1VRjUIgTQx4E8w==", "dev": true, + "license": "MIT", "engines": { "node": ">=6" } }, "node_modules/ky": { "version": "0.33.3", - "resolved": "https://registry.npmjs.org/ky/-/ky-0.33.3.tgz", - "integrity": "sha512-CasD9OCEQSFIam2U8efFK81Yeg8vNMTBUqtMOHlrcWQHqUX3HeCl9Dr31u4toV7emlH8Mymk5+9p0lL6mKb/Xw==", + "license": "MIT", "engines": { "node": ">=14.16" }, @@ -7505,8 +6867,7 @@ }, "node_modules/ky-universal": { "version": "0.11.0", - "resolved": "https://registry.npmjs.org/ky-universal/-/ky-universal-0.11.0.tgz", - "integrity": "sha512-65KyweaWvk+uKKkCrfAf+xqN2/epw1IJDtlyCPxYffFCMR8u1sp2U65NtWpnozYfZxQ6IUzIlvUcw+hQ82U2Xw==", + "license": "MIT", "dependencies": { "abort-controller": "^3.0.0", "node-fetch": "^3.2.10" @@ -7529,16 +6890,13 @@ }, "node_modules/ky-universal/node_modules/data-uri-to-buffer": { "version": "4.0.1", - "resolved": "https://registry.npmjs.org/data-uri-to-buffer/-/data-uri-to-buffer-4.0.1.tgz", - "integrity": "sha512-0R9ikRb668HB7QDxT1vkpuUBtqc53YyAwMwGeUFKRojY/NWKvdZ+9UYtRfGmhqNbRkTSVpMbmyhXipFFv2cb/A==", + "license": "MIT", "engines": { "node": ">= 12" } }, "node_modules/ky-universal/node_modules/fetch-blob": { "version": "3.2.0", - "resolved": "https://registry.npmjs.org/fetch-blob/-/fetch-blob-3.2.0.tgz", - "integrity": "sha512-7yAQpD2UMJzLi1Dqv7qFYnPbaPx7ZfFK6PiIxQ4PfkGPyNyl2Ugx+a/umUonmKqjhM4DnfbMvdX6otXq83soQQ==", "funding": [ { "type": "github", @@ -7549,6 +6907,7 @@ "url": "https://paypal.me/jimmywarting" } ], + "license": "MIT", "dependencies": { "node-domexception": "^1.0.0", "web-streams-polyfill": "^3.0.3" @@ -7559,8 +6918,7 @@ }, "node_modules/ky-universal/node_modules/node-fetch": { "version": "3.3.2", - "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-3.3.2.tgz", - "integrity": "sha512-dRB78srN/l6gqWulah9SrxeYnxeddIG30+GOqK/9OlLVyLg3HPnr6SqOWTWOXKRwC2eGYCkZ59NNuSgvSrpgOA==", + "license": "MIT", "dependencies": { "data-uri-to-buffer": "^4.0.0", "fetch-blob": "^3.1.4", @@ -7576,18 +6934,16 @@ }, "node_modules/leven": { "version": "3.1.0", - "resolved": "https://registry.npmjs.org/leven/-/leven-3.1.0.tgz", - "integrity": "sha512-qsda+H8jTaUaN/x5vzW2rzc+8Rw4TAQ/4KjB46IwK5VH+IlVeeeje/EoZRpiXvIqjFgK84QffqPztGI3VBLG1A==", "dev": true, + "license": "MIT", "engines": { "node": ">=6" } }, "node_modules/levn": { "version": "0.4.1", - "resolved": "https://registry.npmjs.org/levn/-/levn-0.4.1.tgz", - "integrity": "sha512-+bT2uH4E5LGE7h/n3evcS/sQlJXCpIp6ym8OWJ5eV6+67Dsql/LaaT7qJBAt2rzfoa/5QBGBhxDix1dMt2kQKQ==", "dev": true, + "license": "MIT", "dependencies": { "prelude-ls": "^1.2.1", "type-check": "~0.4.0" @@ -7596,30 +6952,26 @@ "node": ">= 0.8.0" } }, - "node_modules/libsodium": { - "version": "0.7.11", - "resolved": "https://registry.npmjs.org/libsodium/-/libsodium-0.7.11.tgz", - "integrity": "sha512-WPfJ7sS53I2s4iM58QxY3Inb83/6mjlYgcmZs7DJsvDlnmVUwNinBCi5vBT43P6bHRy01O4zsMU2CoVR6xJ40A==" + "node_modules/libsodium-sumo": { + "version": "0.7.13", + "license": "ISC" }, - "node_modules/libsodium-wrappers": { - "version": "0.7.11", - "resolved": "https://registry.npmjs.org/libsodium-wrappers/-/libsodium-wrappers-0.7.11.tgz", - "integrity": "sha512-SrcLtXj7BM19vUKtQuyQKiQCRJPgbpauzl3s0rSwD+60wtHqSUuqcoawlMDheCJga85nKOQwxNYQxf/CKAvs6Q==", + "node_modules/libsodium-wrappers-sumo": { + "version": "0.7.13", + "license": "ISC", "dependencies": { - "libsodium": "^0.7.11" + "libsodium-sumo": "^0.7.13" } }, "node_modules/lines-and-columns": { "version": "1.2.4", - "resolved": "https://registry.npmjs.org/lines-and-columns/-/lines-and-columns-1.2.4.tgz", - "integrity": "sha512-7ylylesZQ/PV29jhEDl3Ufjo6ZX7gCqJr5F7PKrqc93v7fzSymt1BpwEU8nAUXs8qzzvqhbjhK5QZg6Mt/HkBg==", - "dev": true + "dev": true, + "license": "MIT" }, "node_modules/locate-path": { "version": "5.0.0", - "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-5.0.0.tgz", - "integrity": "sha512-t7hw9pI+WvuwNJXwk5zVHpyhIqzg2qTlklJOf0mVxGSbe3Fp2VieZcduNYjaLDoy6p9uGpQEGWG87WpMKlNq8g==", "dev": true, + "license": "MIT", "dependencies": { "p-locate": "^4.1.0" }, @@ -7629,62 +6981,51 @@ }, "node_modules/lodash.includes": { "version": "4.3.0", - "resolved": "https://registry.npmjs.org/lodash.includes/-/lodash.includes-4.3.0.tgz", - "integrity": "sha512-W3Bx6mdkRTGtlJISOvVD/lbqjTlPPUDTMnlXZFnVwi9NKJ6tiAk6LVdlhZMm17VZisqhKcgzpO5Wz91PCt5b0w==" + "license": "MIT" }, "node_modules/lodash.isboolean": { "version": "3.0.3", - "resolved": "https://registry.npmjs.org/lodash.isboolean/-/lodash.isboolean-3.0.3.tgz", - "integrity": "sha512-Bz5mupy2SVbPHURB98VAcw+aHh4vRV5IPNhILUCsOzRmsTmSQ17jIuqopAentWoehktxGd9e/hbIXq980/1QJg==" + "license": "MIT" }, "node_modules/lodash.isinteger": { "version": "4.0.4", - "resolved": "https://registry.npmjs.org/lodash.isinteger/-/lodash.isinteger-4.0.4.tgz", - "integrity": "sha512-DBwtEWN2caHQ9/imiNeEA5ys1JoRtRfY3d7V9wkqtbycnAmTvRRmbHKDV4a0EYc678/dia0jrte4tjYwVBaZUA==" + "license": "MIT" }, "node_modules/lodash.isnumber": { "version": "3.0.3", - "resolved": "https://registry.npmjs.org/lodash.isnumber/-/lodash.isnumber-3.0.3.tgz", - "integrity": "sha512-QYqzpfwO3/CWf3XP+Z+tkQsfaLL/EnUlXWVkIk5FUPc4sBdTehEqZONuyRt2P67PXAk+NXmTBcc97zw9t1FQrw==" + "license": "MIT" }, "node_modules/lodash.isplainobject": { "version": "4.0.6", - "resolved": "https://registry.npmjs.org/lodash.isplainobject/-/lodash.isplainobject-4.0.6.tgz", - "integrity": "sha512-oSXzaWypCMHkPC3NvBEaPHf0KsA5mvPrOPgQWDsbg8n7orZ290M0BmC/jgRZ4vcJ6DTAhjrsSYgdsW/F+MFOBA==" + "license": "MIT" }, "node_modules/lodash.isstring": { "version": "4.0.1", - "resolved": "https://registry.npmjs.org/lodash.isstring/-/lodash.isstring-4.0.1.tgz", - "integrity": "sha512-0wJxfxH1wgO3GrbuP+dTTk7op+6L41QCXbGINEmD+ny/G/eCqGzxyCsh7159S+mgDDcoarnBw6PC1PS5+wUGgw==" + "license": "MIT" }, "node_modules/lodash.memoize": { "version": "4.1.2", - "resolved": "https://registry.npmjs.org/lodash.memoize/-/lodash.memoize-4.1.2.tgz", - "integrity": "sha512-t7j+NzmgnQzTAYXcsHYLgimltOV1MXHtlOWf6GjL9Kj8GK5FInw5JotxvbOs+IvV1/Dzo04/fCGfLVs7aXb4Ag==", - "dev": true + "dev": true, + "license": "MIT" }, "node_modules/lodash.merge": { "version": "4.6.2", - "resolved": "https://registry.npmjs.org/lodash.merge/-/lodash.merge-4.6.2.tgz", - "integrity": "sha512-0KpjqXRVvrYyCsX1swR/XTK0va6VQkQM6MNo7PqW77ByjAhoARA8EfrP1N4+KlKj8YS0ZUCtRT/YUuhyYDujIQ==", - "dev": true + "dev": true, + "license": "MIT" }, "node_modules/lodash.once": { "version": "4.1.1", - "resolved": "https://registry.npmjs.org/lodash.once/-/lodash.once-4.1.1.tgz", - "integrity": "sha512-Sb487aTOCr9drQVL8pIxOzVhafOjZN9UU54hiN8PU3uAiSV7lx1yYNpbNmex2PK6dSJoNTSJUUswT651yww3Mg==" + "license": "MIT" }, "node_modules/lodash.truncate": { "version": "4.4.2", - "resolved": "https://registry.npmjs.org/lodash.truncate/-/lodash.truncate-4.4.2.tgz", - "integrity": "sha512-jttmRe7bRse52OsWIMDLaXxWqRAmtIUccAQ3garviCqJjafXOfNMO0yMfNpdD6zbGaTU0P5Nz7e7gAT6cKmJRw==", - "dev": true + "dev": true, + "license": "MIT" }, "node_modules/log-symbols": { "version": "4.1.0", - "resolved": "https://registry.npmjs.org/log-symbols/-/log-symbols-4.1.0.tgz", - "integrity": "sha512-8XPvpAA8uyhfteu8pIvQxpJZ7SYYdpUivZpGy6sFsBuKRY/7rQGavedeB8aK+Zkyq6upMFVL/9AW6vOYzfRyLg==", "dev": true, + "license": "MIT", "dependencies": { "chalk": "^4.1.0", "is-unicode-supported": "^0.1.0" @@ -7698,22 +7039,19 @@ }, "node_modules/long": { "version": "4.0.0", - "resolved": "https://registry.npmjs.org/long/-/long-4.0.0.tgz", - "integrity": "sha512-XsP+KhQif4bjX1kbuSiySJFNAehNxgLb6hPRGJ9QsUr8ajHkuXGdrHmFUTUUXhDwVX2R5bY4JNZEwbUiMhV+MA==" + "license": "Apache-2.0" }, "node_modules/loupe": { - "version": "2.3.6", - "resolved": "https://registry.npmjs.org/loupe/-/loupe-2.3.6.tgz", - "integrity": "sha512-RaPMZKiMy8/JruncMU5Bt6na1eftNoo++R4Y+N2FrxkDVTrGvcyzFTsaGif4QTeKESheMGegbhw6iUAq+5A8zA==", + "version": "2.3.7", "dev": true, + "license": "MIT", "dependencies": { - "get-func-name": "^2.0.0" + "get-func-name": "^2.0.1" } }, "node_modules/lowercase-keys": { "version": "3.0.0", - "resolved": "https://registry.npmjs.org/lowercase-keys/-/lowercase-keys-3.0.0.tgz", - "integrity": "sha512-ozCC6gdQ+glXOQsveKD0YsDy8DSQFjDTz4zyzEHNV5+JP5D62LmfDZ6o1cycFx9ouG940M5dE8C8CTewdj2YWQ==", + "license": "MIT", "engines": { "node": "^12.20.0 || ^14.13.1 || >=16.0.0" }, @@ -7723,17 +7061,15 @@ }, "node_modules/lru-cache": { "version": "5.1.1", - "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-5.1.1.tgz", - "integrity": "sha512-KpNARQA3Iwv+jTA0utUVVbrh+Jlrr1Fv0e56GGzAFOXN7dk/FviaDW8LHmK52DlcH4WP2n6gI8vN1aesBFgo9w==", + "license": "ISC", "dependencies": { "yallist": "^3.0.2" } }, "node_modules/make-dir": { "version": "4.0.0", - "resolved": "https://registry.npmjs.org/make-dir/-/make-dir-4.0.0.tgz", - "integrity": "sha512-hXdUTZYIVOt1Ex//jAQi+wTZZpUpwBj/0QsOzqegb3rGMMeJiSEu5xLHnYfBrRV4RH2+OCSOO95Is/7x1WJ4bw==", "dev": true, + "license": "MIT", "dependencies": { "semver": "^7.5.3" }, @@ -7746,23 +7082,20 @@ }, "node_modules/make-error": { "version": "1.3.6", - "resolved": "https://registry.npmjs.org/make-error/-/make-error-1.3.6.tgz", - "integrity": "sha512-s8UhlNe7vPKomQhC1qFelMokr/Sc3AgNbso3n74mVPA5LTZwkB9NlXf4XPamLxJE8h0gh73rM94xvwRT2CVInw==", - "dev": true + "dev": true, + "license": "ISC" }, "node_modules/makeerror": { "version": "1.0.12", - "resolved": "https://registry.npmjs.org/makeerror/-/makeerror-1.0.12.tgz", - "integrity": "sha512-JmqCvUhmt43madlpFzG4BQzG2Z3m6tvQDNKdClZnO3VbIudJYmxsT0FNJMeiB2+JTSlTQTSbU8QdesVmwJcmLg==", "dev": true, + "license": "BSD-3-Clause", "dependencies": { "tmpl": "1.0.5" } }, "node_modules/md5.js": { "version": "1.3.5", - "resolved": "https://registry.npmjs.org/md5.js/-/md5.js-1.3.5.tgz", - "integrity": "sha512-xitP+WxNPcTTOgnTJcrhM0xvdPepipPSf3I8EIpGKeFLjt3PlJLIDG3u8EX53ZIubkb+5U2+3rELYpEhHhzdkg==", + "license": "MIT", "dependencies": { "hash-base": "^3.0.0", "inherits": "^2.0.1", @@ -7771,50 +7104,43 @@ }, "node_modules/media-typer": { "version": "0.3.0", - "resolved": "https://registry.npmjs.org/media-typer/-/media-typer-0.3.0.tgz", - "integrity": "sha512-dq+qelQ9akHpcOl/gUVRTxVIOkAJ1wR3QAvb4RsVjS8oVoFjDGTc679wJYmUmknUF5HwMLOgb5O+a3KxfWapPQ==", + "license": "MIT", "engines": { "node": ">= 0.6" } }, "node_modules/merge-descriptors": { "version": "1.0.1", - "resolved": "https://registry.npmjs.org/merge-descriptors/-/merge-descriptors-1.0.1.tgz", - "integrity": "sha512-cCi6g3/Zr1iqQi6ySbseM1Xvooa98N0w31jzUYrXPX2xqObmFGHJ0tQ5u74H3mVh7wLouTseZyYIq39g8cNp1w==" + "license": "MIT" }, "node_modules/merge-stream": { "version": "2.0.0", - "resolved": "https://registry.npmjs.org/merge-stream/-/merge-stream-2.0.0.tgz", - "integrity": "sha512-abv/qOcuPfk3URPfDzmZU1LKmuw8kT+0nIHvKrKgFrwifol/doWcdA4ZqsWQ8ENrFKkd67Mfpo/LovbIUsbt3w==", - "dev": true + "dev": true, + "license": "MIT" }, "node_modules/merge2": { "version": "1.4.1", - "resolved": "https://registry.npmjs.org/merge2/-/merge2-1.4.1.tgz", - "integrity": "sha512-8q7VEgMJW4J8tcfVPy8g09NcQwZdbwFEqhe/WZkoIzjn/3TGDwtOCYtXGxA3O8tPzpczCCDgv+P2P5y00ZJOOg==", "dev": true, + "license": "MIT", "engines": { "node": ">= 8" } }, "node_modules/methods": { "version": "1.1.2", - "resolved": "https://registry.npmjs.org/methods/-/methods-1.1.2.tgz", - "integrity": "sha512-iclAHeNqNm68zFtnZ0e+1L2yUIdvzNoauKU4WBA3VvH/vPFieF7qfRlwUZU+DA9P9bPXIS90ulxoUoCH23sV2w==", + "license": "MIT", "engines": { "node": ">= 0.6" } }, "node_modules/micro-ftch": { "version": "0.3.1", - "resolved": "https://registry.npmjs.org/micro-ftch/-/micro-ftch-0.3.1.tgz", - "integrity": "sha512-/0LLxhzP0tfiR5hcQebtudP56gUurs2CLkGarnCiB/OqEyUFQ6U3paQi/tgLv0hBJYt2rnr9MNpxz4fiiugstg==" + "license": "MIT" }, "node_modules/micromatch": { "version": "4.0.5", - "resolved": "https://registry.npmjs.org/micromatch/-/micromatch-4.0.5.tgz", - "integrity": "sha512-DMy+ERcEW2q8Z2Po+WNXuw3c5YaUSFjAO5GsJqfEl7UjvtIuFKO6ZrKvcItdy98dwFI2N1tg3zNIdKaQT+aNdA==", "dev": true, + "license": "MIT", "dependencies": { "braces": "^3.0.2", "picomatch": "^2.3.1" @@ -7825,8 +7151,7 @@ }, "node_modules/mime": { "version": "1.6.0", - "resolved": "https://registry.npmjs.org/mime/-/mime-1.6.0.tgz", - "integrity": "sha512-x0Vn8spI+wuJ1O6S7gnbaQg8Pxh4NNHb7KSINmEWKiPE4RKOplvijn+NkmYmmRgP68mc70j2EbeTFRsrswaQeg==", + "license": "MIT", "bin": { "mime": "cli.js" }, @@ -7836,16 +7161,14 @@ }, "node_modules/mime-db": { "version": "1.52.0", - "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.52.0.tgz", - "integrity": "sha512-sPU4uV7dYlvtWJxwwxHD0PuihVNiE7TyAbQ5SWxDCB9mUYvOgroQOwYQQOKPJ8CIbE+1ETVlOoK1UC2nU3gYvg==", + "license": "MIT", "engines": { "node": ">= 0.6" } }, "node_modules/mime-types": { "version": "2.1.35", - "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.35.tgz", - "integrity": "sha512-ZDY+bPm5zTTF+YpCrAU9nK0UgICYPT0QtT1NZWFv4s++TNkcgVaT0g6+4R2uI4MjQjzysHB1zxuWL50hzaeXiw==", + "license": "MIT", "dependencies": { "mime-db": "1.52.0" }, @@ -7855,44 +7178,37 @@ }, "node_modules/mimic-fn": { "version": "2.1.0", - "resolved": "https://registry.npmjs.org/mimic-fn/-/mimic-fn-2.1.0.tgz", - "integrity": "sha512-OqbOk5oEQeAZ8WXWydlu9HJjz9WVdEIvamMCcXmuqUYjTknH/sqsWvhQ3vgwKFRR1HpjvNBKQ37nbJgYzGqGcg==", "dev": true, + "license": "MIT", "engines": { "node": ">=6" } }, "node_modules/mimic-response": { "version": "1.0.1", - "resolved": "https://registry.npmjs.org/mimic-response/-/mimic-response-1.0.1.tgz", - "integrity": "sha512-j5EctnkH7amfV/q5Hgmoal1g2QHFJRraOtmx0JpIqkxhBhI/lJSl1nMpQ45hVarwNETOoWEimndZ4QK0RHxuxQ==", + "license": "MIT", "engines": { "node": ">=4" } }, "node_modules/min-document": { "version": "2.19.0", - "resolved": "https://registry.npmjs.org/min-document/-/min-document-2.19.0.tgz", - "integrity": "sha512-9Wy1B3m3f66bPPmU5hdA4DR4PB2OfDU/+GS3yAB7IQozE3tqXaVv2zOjgla7MEGSRv95+ILmOuvhLkOK6wJtCQ==", "dependencies": { "dom-walk": "^0.1.0" } }, "node_modules/minimalistic-assert": { "version": "1.0.1", - "resolved": "https://registry.npmjs.org/minimalistic-assert/-/minimalistic-assert-1.0.1.tgz", - "integrity": "sha512-UtJcAD4yEaGtjPezWuO9wC4nwUnVH/8/Im3yEHQP4b67cXlD/Qr9hdITCU1xDbSEXg2XKNaP8jsReV7vQd00/A==" + "license": "ISC" }, "node_modules/minimalistic-crypto-utils": { "version": "1.0.1", - "resolved": "https://registry.npmjs.org/minimalistic-crypto-utils/-/minimalistic-crypto-utils-1.0.1.tgz", - "integrity": "sha512-JIYlbt6g8i5jKfJ3xz7rF0LXmv2TkDxBLUkiBeZ7bAx4GnnNMr8xFpGnOxn6GhTEHx3SjRrZEoU+j04prX1ktg==" + "license": "MIT" }, "node_modules/minimatch": { "version": "3.1.2", - "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.2.tgz", - "integrity": "sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==", "dev": true, + "license": "ISC", "dependencies": { "brace-expansion": "^1.1.7" }, @@ -7902,16 +7218,14 @@ }, "node_modules/minimist": { "version": "1.2.8", - "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.8.tgz", - "integrity": "sha512-2yyAR8qBkN3YuheJanUpWC5U3bb5osDywNB8RzDVlDwDHbocAJveqqj1u8+SVD7jkWT4yvsHCpWqqWqAxb0zCA==", + "license": "MIT", "funding": { "url": "https://github.com/sponsors/ljharb" } }, "node_modules/minipass": { "version": "2.9.0", - "resolved": "https://registry.npmjs.org/minipass/-/minipass-2.9.0.tgz", - "integrity": "sha512-wxfUjg9WebH+CUDX/CdbRlh5SmfZiy/hpkxaRI16Y9W56Pa75sWgd/rvFilSgrauD9NyFymP/+JFV3KwzIsJeg==", + "license": "ISC", "dependencies": { "safe-buffer": "^5.1.2", "yallist": "^3.0.0" @@ -7919,16 +7233,14 @@ }, "node_modules/minizlib": { "version": "1.3.3", - "resolved": "https://registry.npmjs.org/minizlib/-/minizlib-1.3.3.tgz", - "integrity": "sha512-6ZYMOEnmVsdCeTJVE0W9ZD+pVnE8h9Hma/iOwwRDsdQoePpoX56/8B6z3P9VNwppJuBKNRuFDRNRqRWexT9G9Q==", + "license": "MIT", "dependencies": { "minipass": "^2.9.0" } }, "node_modules/mkdirp": { "version": "3.0.1", - "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-3.0.1.tgz", - "integrity": "sha512-+NsyUUAZDmo6YVHzL/stxSu3t9YS1iljliy3BSDrXJ/dkn1KYdmtZODGGjLcc9XLgVVpH4KshHB8XmZgMhaBXg==", + "license": "MIT", "bin": { "mkdirp": "dist/cjs/src/bin.js" }, @@ -7941,9 +7253,7 @@ }, "node_modules/mkdirp-promise": { "version": "5.0.1", - "resolved": "https://registry.npmjs.org/mkdirp-promise/-/mkdirp-promise-5.0.1.tgz", - "integrity": "sha512-Hepn5kb1lJPtVW84RFT40YG1OddBNTOVUZR2bzQUHc+Z03en8/3uX0+060JDhcEzyO08HmipsN9DcnFMxhIL9w==", - "deprecated": "This package is broken and no longer maintained. 'mkdirp' itself supports promises now, please switch to that.", + "license": "ISC", "dependencies": { "mkdirp": "*" }, @@ -7953,9 +7263,8 @@ }, "node_modules/mocha": { "version": "10.2.0", - "resolved": "https://registry.npmjs.org/mocha/-/mocha-10.2.0.tgz", - "integrity": "sha512-IDY7fl/BecMwFHzoqF2sg/SHHANeBoMMXFlS9r0OXKDssYE1M5O43wUY/9BVPeIvfH2zmEbBfseqN9gBQZzXkg==", "dev": true, + "license": "MIT", "dependencies": { "ansi-colors": "4.1.1", "browser-stdout": "1.3.1", @@ -7993,24 +7302,21 @@ }, "node_modules/mocha/node_modules/ansi-colors": { "version": "4.1.1", - "resolved": "https://registry.npmjs.org/ansi-colors/-/ansi-colors-4.1.1.tgz", - "integrity": "sha512-JoX0apGbHaUJBNl6yF+p6JAFYZ666/hhCGKN5t9QFjbJQKUU/g8MNbFDbvfrgKXvI1QpZplPOnwIo99lX/AAmA==", "dev": true, + "license": "MIT", "engines": { "node": ">=6" } }, "node_modules/mocha/node_modules/argparse": { "version": "2.0.1", - "resolved": "https://registry.npmjs.org/argparse/-/argparse-2.0.1.tgz", - "integrity": "sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q==", - "dev": true + "dev": true, + "license": "Python-2.0" }, "node_modules/mocha/node_modules/cliui": { "version": "7.0.4", - "resolved": "https://registry.npmjs.org/cliui/-/cliui-7.0.4.tgz", - "integrity": "sha512-OcRE68cOsVMXp1Yvonl/fzkQOyjLSu/8bhPDfQt0e0/Eb283TKP20Fs2MqoPsr9SwA595rRCA+QMzYc9nBP+JQ==", "dev": true, + "license": "ISC", "dependencies": { "string-width": "^4.2.0", "strip-ansi": "^6.0.0", @@ -8019,9 +7325,8 @@ }, "node_modules/mocha/node_modules/find-up": { "version": "5.0.0", - "resolved": "https://registry.npmjs.org/find-up/-/find-up-5.0.0.tgz", - "integrity": "sha512-78/PXT1wlLLDgTzDs7sjq9hzz0vXD+zn+7wypEe4fXQxCmdmqfGsEPQxmiCSQI3ajFV91bVSsvNtrJRiW6nGng==", "dev": true, + "license": "MIT", "dependencies": { "locate-path": "^6.0.0", "path-exists": "^4.0.0" @@ -8035,9 +7340,8 @@ }, "node_modules/mocha/node_modules/glob": { "version": "7.2.0", - "resolved": "https://registry.npmjs.org/glob/-/glob-7.2.0.tgz", - "integrity": "sha512-lmLf6gtyrPq8tTjSmrO94wBeQbFR3HbLHbuyD69wuyQkImp2hWqMGB47OX65FBkPffO641IP9jWa1z4ivqG26Q==", "dev": true, + "license": "ISC", "dependencies": { "fs.realpath": "^1.0.0", "inflight": "^1.0.4", @@ -8055,9 +7359,8 @@ }, "node_modules/mocha/node_modules/glob/node_modules/minimatch": { "version": "3.1.2", - "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.2.tgz", - "integrity": "sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==", "dev": true, + "license": "ISC", "dependencies": { "brace-expansion": "^1.1.7" }, @@ -8067,9 +7370,8 @@ }, "node_modules/mocha/node_modules/js-yaml": { "version": "4.1.0", - "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-4.1.0.tgz", - "integrity": "sha512-wpxZs9NoxZaJESJGIZTyDEaYpl0FKSA+FB9aJiyemKhMwkxQg63h4T1KJgUGHpTqPDNRcmmYLugrRjJlBtWvRA==", "dev": true, + "license": "MIT", "dependencies": { "argparse": "^2.0.1" }, @@ -8079,9 +7381,8 @@ }, "node_modules/mocha/node_modules/locate-path": { "version": "6.0.0", - "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-6.0.0.tgz", - "integrity": "sha512-iPZK6eYjbxRu3uB4/WZ3EsEIMJFMqAoopl3R+zuq0UjcAm/MO6KCweDgPfP3elTztoKP3KtnVHxTn2NHBSDVUw==", "dev": true, + "license": "MIT", "dependencies": { "p-locate": "^5.0.0" }, @@ -8094,9 +7395,8 @@ }, "node_modules/mocha/node_modules/minimatch": { "version": "5.0.1", - "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-5.0.1.tgz", - "integrity": "sha512-nLDxIFRyhDblz3qMuq+SoRZED4+miJ/G+tdDrjkkkRnjAsBexeGpgjLEQ0blJy7rHhR2b93rhQY4SvyWu9v03g==", "dev": true, + "license": "ISC", "dependencies": { "brace-expansion": "^2.0.1" }, @@ -8106,24 +7406,21 @@ }, "node_modules/mocha/node_modules/minimatch/node_modules/brace-expansion": { "version": "2.0.1", - "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-2.0.1.tgz", - "integrity": "sha512-XnAIvQ8eM+kC6aULx6wuQiwVsnzsi9d3WxzV3FpWTGA19F621kwdbsAcFKXgKUHZWsy+mY6iL1sHTxWEFCytDA==", "dev": true, + "license": "MIT", "dependencies": { "balanced-match": "^1.0.0" } }, "node_modules/mocha/node_modules/ms": { "version": "2.1.3", - "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz", - "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==", - "dev": true + "dev": true, + "license": "MIT" }, "node_modules/mocha/node_modules/p-locate": { "version": "5.0.0", - "resolved": "https://registry.npmjs.org/p-locate/-/p-locate-5.0.0.tgz", - "integrity": "sha512-LaNjtRWUBY++zB5nE/NwcaoMylSPk+S+ZHNB1TzdbMJMny6dynpAGt7X/tl/QYq3TIeE6nxHppbo2LGymrG5Pw==", "dev": true, + "license": "MIT", "dependencies": { "p-limit": "^3.0.2" }, @@ -8136,9 +7433,8 @@ }, "node_modules/mocha/node_modules/supports-color": { "version": "8.1.1", - "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-8.1.1.tgz", - "integrity": "sha512-MpUEN2OodtUzxvKQl72cUF7RQ5EiHsGvSsVG0ia9c5RbWGL2CI4C7EpPS8UTBIplnlzZiNuV56w+FuNxy3ty2Q==", "dev": true, + "license": "MIT", "dependencies": { "has-flag": "^4.0.0" }, @@ -8151,9 +7447,8 @@ }, "node_modules/mocha/node_modules/yargs": { "version": "16.2.0", - "resolved": "https://registry.npmjs.org/yargs/-/yargs-16.2.0.tgz", - "integrity": "sha512-D1mvvtDG0L5ft/jGWkLpG1+m0eQxOfaBvTNELraWj22wSVUMWxZUvYgJYcKh6jGGIkJFhH4IZPQhR4TKpc8mBw==", "dev": true, + "license": "MIT", "dependencies": { "cliui": "^7.0.2", "escalade": "^3.1.1", @@ -8169,37 +7464,37 @@ }, "node_modules/mock-fs": { "version": "4.14.0", - "resolved": "https://registry.npmjs.org/mock-fs/-/mock-fs-4.14.0.tgz", - "integrity": "sha512-qYvlv/exQ4+svI3UOvPUpLDF0OMX5euvUH0Ny4N5QyRyhNdgAgUrVH3iUINSzEPLvx0kbo/Bp28GJKIqvE7URw==" + "license": "MIT" }, "node_modules/ms": { "version": "2.1.2", - "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", - "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==" + "license": "MIT" }, "node_modules/multibase": { - "version": "0.6.1", - "resolved": "https://registry.npmjs.org/multibase/-/multibase-0.6.1.tgz", - "integrity": "sha512-pFfAwyTjbbQgNc3G7D48JkJxWtoJoBMaR4xQUOuB8RnCgRqaYmWNFeJTTvrJ2w51bjLq2zTby6Rqj9TQ9elSUw==", - "deprecated": "This module has been superseded by the multiformats module", + "version": "4.0.6", + "license": "MIT", "dependencies": { - "base-x": "^3.0.8", - "buffer": "^5.5.0" + "@multiformats/base-x": "^4.0.1" + }, + "engines": { + "node": ">=12.0.0", + "npm": ">=6.0.0" } }, "node_modules/multicodec": { "version": "0.5.7", - "resolved": "https://registry.npmjs.org/multicodec/-/multicodec-0.5.7.tgz", - "integrity": "sha512-PscoRxm3f+88fAtELwUnZxGDkduE2HD9Q6GHUOywQLjOGT/HAdhjLDYNZ1e7VR0s0TP0EwZ16LNUTFpoBGivOA==", - "deprecated": "This module has been superseded by the multiformats module", + "license": "MIT", "dependencies": { "varint": "^5.0.0" } }, + "node_modules/multiformats": { + "version": "9.9.0", + "license": "(Apache-2.0 AND MIT)" + }, "node_modules/multihashes": { "version": "0.4.21", - "resolved": "https://registry.npmjs.org/multihashes/-/multihashes-0.4.21.tgz", - "integrity": "sha512-uVSvmeCWf36pU2nB4/1kzYZjsXD9vofZKpgudqkceYY5g2aZZXJ5r9lxuzoRLl1OAp28XljXsEJ/X/85ZsKmKw==", + "license": "MIT", "dependencies": { "buffer": "^5.5.0", "multibase": "^0.7.0", @@ -8208,24 +7503,67 @@ }, "node_modules/multihashes/node_modules/multibase": { "version": "0.7.0", - "resolved": "https://registry.npmjs.org/multibase/-/multibase-0.7.0.tgz", - "integrity": "sha512-TW8q03O0f6PNFTQDvh3xxH03c8CjGaaYrjkl9UQPG6rz53TQzzxJVCIWVjzcbN/Q5Y53Zd0IBQBMVktVgNx4Fg==", - "deprecated": "This module has been superseded by the multiformats module", + "license": "MIT", "dependencies": { "base-x": "^3.0.8", "buffer": "^5.5.0" } }, + "node_modules/n3": { + "version": "1.17.1", + "license": "MIT", + "dependencies": { + "queue-microtask": "^1.1.2", + "readable-stream": "^4.0.0" + }, + "engines": { + "node": ">=12.0" + } + }, + "node_modules/n3/node_modules/buffer": { + "version": "6.0.3", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/feross" + }, + { + "type": "patreon", + "url": "https://www.patreon.com/feross" + }, + { + "type": "consulting", + "url": "https://feross.org/support" + } + ], + "license": "MIT", + "dependencies": { + "base64-js": "^1.3.1", + "ieee754": "^1.2.1" + } + }, + "node_modules/n3/node_modules/readable-stream": { + "version": "4.5.1", + "license": "MIT", + "dependencies": { + "abort-controller": "^3.0.0", + "buffer": "^6.0.3", + "events": "^3.3.0", + "process": "^0.11.10", + "string_decoder": "^1.3.0" + }, + "engines": { + "node": "^12.22.0 || ^14.17.0 || >=16.0.0" + } + }, "node_modules/nano-json-stream-parser": { "version": "0.1.2", - "resolved": "https://registry.npmjs.org/nano-json-stream-parser/-/nano-json-stream-parser-0.1.2.tgz", - "integrity": "sha512-9MqxMH/BSJC7dnLsEMPyfN5Dvoo49IsPFYMcHw3Bcfc2kN0lpHRBSzlMSVx4HGyJ7s9B31CyBTVehWJoQ8Ctew==" + "license": "MIT" }, "node_modules/nanoid": { "version": "3.3.3", - "resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.3.3.tgz", - "integrity": "sha512-p1sjXuopFs0xg+fPASzQ28agW1oHD7xDsd9Xkf3T15H3c/cifrFHVwrh74PdoklAPi+i7MdRsE47vm2r6JoB+w==", "dev": true, + "license": "MIT", "bin": { "nanoid": "bin/nanoid.cjs" }, @@ -8235,38 +7573,31 @@ }, "node_modules/natural-compare": { "version": "1.4.0", - "resolved": "https://registry.npmjs.org/natural-compare/-/natural-compare-1.4.0.tgz", - "integrity": "sha512-OWND8ei3VtNC9h7V60qff3SVobHr996CTwgxubgyQYEpg290h9J0buyECNNJexkFm5sOajh5G116RYA1c8ZMSw==", - "dev": true + "dev": true, + "license": "MIT" }, "node_modules/natural-compare-lite": { "version": "1.4.0", - "resolved": "https://registry.npmjs.org/natural-compare-lite/-/natural-compare-lite-1.4.0.tgz", - "integrity": "sha512-Tj+HTDSJJKaZnfiuw+iaF9skdPpTo2GtEly5JHnWV/hfv2Qj/9RKsGISQtLh2ox3l5EAGw487hnBee0sIJ6v2g==", - "dev": true + "dev": true, + "license": "MIT" }, "node_modules/negotiator": { "version": "0.6.3", - "resolved": "https://registry.npmjs.org/negotiator/-/negotiator-0.6.3.tgz", - "integrity": "sha512-+EUsqGPLsM+j/zdChZjsnX51g4XrHFOIXwfnCVPGlQk/k5giakcKsuxCObBRu6DSm9opw/O6slWbJdghQM4bBg==", + "license": "MIT", "engines": { "node": ">= 0.6" } }, "node_modules/next-tick": { "version": "1.1.0", - "resolved": "https://registry.npmjs.org/next-tick/-/next-tick-1.1.0.tgz", - "integrity": "sha512-CXdUiJembsNjuToQvxayPZF9Vqht7hewsvy2sOWafLvi2awflj9mOC6bHIg50orX8IJvWKY9wYQ/zB2kogPslQ==" + "license": "ISC" }, "node_modules/node-addon-api": { "version": "2.0.2", - "resolved": "https://registry.npmjs.org/node-addon-api/-/node-addon-api-2.0.2.tgz", - "integrity": "sha512-Ntyt4AIXyaLIuMHF6IOoTakB3K+RWxwtsHNRxllEoA6vPwP9o4866g6YWDLUdnucilZhmkxiHwHr11gAENw+QA==" + "license": "MIT" }, "node_modules/node-domexception": { "version": "1.0.0", - "resolved": "https://registry.npmjs.org/node-domexception/-/node-domexception-1.0.0.tgz", - "integrity": "sha512-/jKZoMpw0F8GRwl4/eLROPA3cfcXtLApP0QzLmUT/HuPCZWyB7IY9ZrMeKw2O/nFIqPQB3PVM9aYm0F312AXDQ==", "funding": [ { "type": "github", @@ -8277,6 +7608,7 @@ "url": "https://paypal.me/jimmywarting" } ], + "license": "MIT", "engines": { "node": ">=10.5.0" } @@ -8285,6 +7617,7 @@ "version": "2.7.0", "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.7.0.tgz", "integrity": "sha512-c4FRfUm/dbcWZ7U+1Wq0AwCyFL+3nt2bEw05wfxSz+DWpWsitgmSgYmy2dQdWyKC1694ELPqMs/YzUSNozLt8A==", + "license": "MIT", "dependencies": { "whatwg-url": "^5.0.0" }, @@ -8301,9 +7634,8 @@ } }, "node_modules/node-gyp-build": { - "version": "4.6.1", - "resolved": "https://registry.npmjs.org/node-gyp-build/-/node-gyp-build-4.6.1.tgz", - "integrity": "sha512-24vnklJmyRS8ViBNI8KbtK/r/DmXQMRiOMXTNz2nrTnAYUwjmEEbnnpB/+kt+yWRv73bPsSPRFddrcIbAxSiMQ==", + "version": "4.7.1", + "license": "MIT", "bin": { "node-gyp-build": "bin.js", "node-gyp-build-optional": "optional.js", @@ -8312,29 +7644,25 @@ }, "node_modules/node-int64": { "version": "0.4.0", - "resolved": "https://registry.npmjs.org/node-int64/-/node-int64-0.4.0.tgz", - "integrity": "sha512-O5lz91xSOeoXP6DulyHfllpq+Eg00MWitZIbtPfoSEvqIHdl5gfcY6hYzDWnj0qD5tz52PI08u9qUvSVeUBeHw==", - "dev": true + "dev": true, + "license": "MIT" }, "node_modules/node-releases": { - "version": "2.0.13", - "resolved": "https://registry.npmjs.org/node-releases/-/node-releases-2.0.13.tgz", - "integrity": "sha512-uYr7J37ae/ORWdZeQ1xxMJe3NtdmqMC/JZK+geofDrkLUApKRHPd18/TxtBOJ4A0/+uUIliorNrfYV6s1b02eQ==", - "dev": true + "version": "2.0.14", + "dev": true, + "license": "MIT" }, "node_modules/normalize-path": { "version": "3.0.0", - "resolved": "https://registry.npmjs.org/normalize-path/-/normalize-path-3.0.0.tgz", - "integrity": "sha512-6eZs5Ls3WtCisHWp9S2GUy8dqkpGi4BVSz3GaqiE6ezub0512ESztXUwUB6C6IKbQkY2Pnb/mD4WYojCRwcwLA==", "dev": true, + "license": "MIT", "engines": { "node": ">=0.10.0" } }, "node_modules/normalize-url": { "version": "6.1.0", - "resolved": "https://registry.npmjs.org/normalize-url/-/normalize-url-6.1.0.tgz", - "integrity": "sha512-DlL+XwOy3NxAQ8xuC0okPgK46iuVNAK01YN7RueYBqqFeGsBjV9XmCAzAdgt+667bCl5kPh9EqKKDwnaPG1I7A==", + "license": "MIT", "engines": { "node": ">=10" }, @@ -8344,9 +7672,8 @@ }, "node_modules/npm-run-path": { "version": "4.0.1", - "resolved": "https://registry.npmjs.org/npm-run-path/-/npm-run-path-4.0.1.tgz", - "integrity": "sha512-S48WzZW777zhNIrn7gxOlISNAqi9ZC/uQFnRdbeIHhZhCA6UqpkOT8T1G7BvfdgP4Er8gF4sUbaS0i7QvIfCWw==", "dev": true, + "license": "MIT", "dependencies": { "path-key": "^3.0.0" }, @@ -8356,8 +7683,7 @@ }, "node_modules/number-to-bn": { "version": "1.7.0", - "resolved": "https://registry.npmjs.org/number-to-bn/-/number-to-bn-1.7.0.tgz", - "integrity": "sha512-wsJ9gfSz1/s4ZsJN01lyonwuxA1tml6X1yBDnfpMglypcBRFZZkus26EdPSlqS5GJfYddVZa22p3VNb3z5m5Ig==", + "license": "MIT", "dependencies": { "bn.js": "4.11.6", "strip-hex-prefix": "1.0.0" @@ -8369,48 +7695,42 @@ }, "node_modules/number-to-bn/node_modules/bn.js": { "version": "4.11.6", - "resolved": "https://registry.npmjs.org/bn.js/-/bn.js-4.11.6.tgz", - "integrity": "sha512-XWwnNNFCuuSQ0m3r3C4LE3EiORltHd9M05pq6FOlVeiophzRbMo50Sbz1ehl8K3Z+jw9+vmgnXefY1hz8X+2wA==" + "license": "MIT" }, "node_modules/oauth-sign": { "version": "0.9.0", - "resolved": "https://registry.npmjs.org/oauth-sign/-/oauth-sign-0.9.0.tgz", - "integrity": "sha512-fexhUFFPTGV8ybAtSIGbV6gOkSv8UtRbDBnAyLQw4QPKkgNlsH2ByPGtMUqdWkos6YCRmAqViwgZrJc/mRDzZQ==", + "license": "Apache-2.0", "engines": { "node": "*" } }, "node_modules/object-assign": { "version": "4.1.1", - "resolved": "https://registry.npmjs.org/object-assign/-/object-assign-4.1.1.tgz", - "integrity": "sha512-rJgTQnkUnH1sFw8yT6VSU3zD3sWmu6sZhIseY8VX+GRu3P6F7Fu+JNDoXfklElbLJSnc3FUQHVe4cU5hj+BcUg==", + "license": "MIT", "engines": { "node": ">=0.10.0" } }, "node_modules/object-inspect": { - "version": "1.12.3", - "resolved": "https://registry.npmjs.org/object-inspect/-/object-inspect-1.12.3.tgz", - "integrity": "sha512-geUvdk7c+eizMNUDkRpW1wJwgfOiOeHbxBR/hLXK1aT6zmVSO0jsQcs7fj6MGw89jC/cjGfLcNOrtMYtGqm81g==", + "version": "1.13.1", + "license": "MIT", "funding": { "url": "https://github.com/sponsors/ljharb" } }, "node_modules/object-keys": { "version": "1.1.1", - "resolved": "https://registry.npmjs.org/object-keys/-/object-keys-1.1.1.tgz", - "integrity": "sha512-NuAESUOUMrlIXOfHKzD6bpPu3tYt3xvjNdRIQ+FeT0lNb4K8WR70CaDxhuNguS2XG+GjkyMwOzsN5ZktImfhLA==", + "license": "MIT", "engines": { "node": ">= 0.4" } }, "node_modules/object.assign": { - "version": "4.1.4", - "resolved": "https://registry.npmjs.org/object.assign/-/object.assign-4.1.4.tgz", - "integrity": "sha512-1mxKf0e58bvyjSCtKYY4sRe9itRk3PJpquJOjeIkz885CczcI4IvJJDLPS72oowuSh+pBxUFROpX+TU++hxhZQ==", + "version": "4.1.5", + "license": "MIT", "dependencies": { - "call-bind": "^1.0.2", - "define-properties": "^1.1.4", + "call-bind": "^1.0.5", + "define-properties": "^1.2.1", "has-symbols": "^1.0.3", "object-keys": "^1.1.1" }, @@ -8423,8 +7743,7 @@ }, "node_modules/object.fromentries": { "version": "2.0.7", - "resolved": "https://registry.npmjs.org/object.fromentries/-/object.fromentries-2.0.7.tgz", - "integrity": "sha512-UPbPHML6sL8PI/mOqPwsH4G6iyXcCGzLin8KvEPenOZN5lpCNBZZQ+V62vdjB1mQHrmqGQt5/OJzemUA+KJmEA==", + "license": "MIT", "dependencies": { "call-bind": "^1.0.2", "define-properties": "^1.2.0", @@ -8439,16 +7758,14 @@ }, "node_modules/oboe": { "version": "2.1.5", - "resolved": "https://registry.npmjs.org/oboe/-/oboe-2.1.5.tgz", - "integrity": "sha512-zRFWiF+FoicxEs3jNI/WYUrVEgA7DeET/InK0XQuudGHRg8iIob3cNPrJTKaz4004uaA9Pbe+Dwa8iluhjLZWA==", + "license": "BSD", "dependencies": { "http-https": "^1.0.0" } }, "node_modules/on-finished": { "version": "2.4.1", - "resolved": "https://registry.npmjs.org/on-finished/-/on-finished-2.4.1.tgz", - "integrity": "sha512-oVlzkg3ENAhCk2zdv7IJwd/QUD4z2RxRwpkcGY8psCVcCYZNq4wYnVWALHM+brtuJjePWiYF/ClmuDr8Ch5+kg==", + "license": "MIT", "dependencies": { "ee-first": "1.1.1" }, @@ -8458,17 +7775,15 @@ }, "node_modules/once": { "version": "1.4.0", - "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", - "integrity": "sha512-lNaJgI+2Q5URQBkccEKHTQOPaXdUxnZZElQTZY0MFUAuaEqe1E+Nyvgdz/aIyNi6Z9MzO5dv1H8n58/GELp3+w==", + "license": "ISC", "dependencies": { "wrappy": "1" } }, "node_modules/onetime": { "version": "5.1.2", - "resolved": "https://registry.npmjs.org/onetime/-/onetime-5.1.2.tgz", - "integrity": "sha512-kbpaSSGJTWdAY5KPVeMOKXSrPtr8C8C7wodJbcsd51jRnmD+GZu8Y0VoU6Dm5Z4vWr0Ig/1NKuWRKf7j5aaYSg==", "dev": true, + "license": "MIT", "dependencies": { "mimic-fn": "^2.1.0" }, @@ -8481,9 +7796,8 @@ }, "node_modules/optionator": { "version": "0.9.3", - "resolved": "https://registry.npmjs.org/optionator/-/optionator-0.9.3.tgz", - "integrity": "sha512-JjCoypp+jKn1ttEFExxhetCKeJt9zhAgAve5FXHixTvFDW/5aEktX9bufBKLRRMdU7bNtpLfcGu94B3cdEJgjg==", "dev": true, + "license": "MIT", "dependencies": { "@aashutoshrathi/word-wrap": "^1.2.3", "deep-is": "^0.1.3", @@ -8498,17 +7812,15 @@ }, "node_modules/p-cancelable": { "version": "3.0.0", - "resolved": "https://registry.npmjs.org/p-cancelable/-/p-cancelable-3.0.0.tgz", - "integrity": "sha512-mlVgR3PGuzlo0MmTdk4cXqXWlwQDLnONTAg6sm62XkMJEiRxN3GL3SffkYvqwonbkJBcrI7Uvv5Zh9yjvn2iUw==", + "license": "MIT", "engines": { "node": ">=12.20" } }, "node_modules/p-limit": { "version": "3.1.0", - "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-3.1.0.tgz", - "integrity": "sha512-TYOanM3wGwNGsZN2cVTYPArw454xnXj5qmWF1bEoAc4+cU/ol7GVh7odevjp1FNHduHc3KZMcFduxU5Xc6uJRQ==", "dev": true, + "license": "MIT", "dependencies": { "yocto-queue": "^0.1.0" }, @@ -8521,9 +7833,8 @@ }, "node_modules/p-locate": { "version": "4.1.0", - "resolved": "https://registry.npmjs.org/p-locate/-/p-locate-4.1.0.tgz", - "integrity": "sha512-R79ZZ/0wAxKGu3oYMlz8jy/kbhsNrS7SKZ7PxEHBgJ5+F2mtFW2fK2cOtBh1cHYkQsbzFV7I+EoRKe6Yt0oK7A==", "dev": true, + "license": "MIT", "dependencies": { "p-limit": "^2.2.0" }, @@ -8533,9 +7844,8 @@ }, "node_modules/p-locate/node_modules/p-limit": { "version": "2.3.0", - "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-2.3.0.tgz", - "integrity": "sha512-//88mFWSJx8lxCzwdAABTJL2MyWB12+eIY7MDL2SqLmAkeKU9qxRvWuSyTjm3FUmpBEMuFfckAIqEaVGUDxb6w==", "dev": true, + "license": "MIT", "dependencies": { "p-try": "^2.0.0" }, @@ -8548,18 +7858,16 @@ }, "node_modules/p-try": { "version": "2.2.0", - "resolved": "https://registry.npmjs.org/p-try/-/p-try-2.2.0.tgz", - "integrity": "sha512-R4nPAVTAU0B9D35/Gk3uJf/7XYbQcyohSKdvAxIRSNghFl4e71hVoGnBNQz9cWaXxO2I10KTC+3jMdvvoKw6dQ==", "dev": true, + "license": "MIT", "engines": { "node": ">=6" } }, "node_modules/parent-module": { "version": "1.0.1", - "resolved": "https://registry.npmjs.org/parent-module/-/parent-module-1.0.1.tgz", - "integrity": "sha512-GQ2EWRpQV8/o+Aw8YqtfZZPfNRWZYkbidE9k5rpl/hC3vtHHBfGm2Ifi6qWV+coDGkrUKZAxE3Lot5kcsRlh+g==", "dev": true, + "license": "MIT", "dependencies": { "callsites": "^3.0.0" }, @@ -8569,14 +7877,12 @@ }, "node_modules/parse-headers": { "version": "2.0.5", - "resolved": "https://registry.npmjs.org/parse-headers/-/parse-headers-2.0.5.tgz", - "integrity": "sha512-ft3iAoLOB/MlwbNXgzy43SWGP6sQki2jQvAyBg/zDFAgr9bfNWZIUj42Kw2eJIl8kEi4PbgE6U1Zau/HwI75HA==" + "license": "MIT" }, "node_modules/parse-json": { "version": "5.2.0", - "resolved": "https://registry.npmjs.org/parse-json/-/parse-json-5.2.0.tgz", - "integrity": "sha512-ayCKvm/phCGxOkYRSCM82iDwct8/EonSEgCSxWxD7ve6jHggsFl4fZVQBPRNgQoKiuV/odhFrGzQXZwbifC8Rg==", "dev": true, + "license": "MIT", "dependencies": { "@babel/code-frame": "^7.0.0", "error-ex": "^1.3.1", @@ -8592,72 +7898,63 @@ }, "node_modules/parseurl": { "version": "1.3.3", - "resolved": "https://registry.npmjs.org/parseurl/-/parseurl-1.3.3.tgz", - "integrity": "sha512-CiyeOxFT/JZyN5m0z9PfXw4SCBJ6Sygz1Dpl0wqjlhDEGGBP1GnsUVEL0p63hoG1fcj3fHynXi9NYO4nWOL+qQ==", + "license": "MIT", "engines": { "node": ">= 0.8" } }, "node_modules/path-exists": { "version": "4.0.0", - "resolved": "https://registry.npmjs.org/path-exists/-/path-exists-4.0.0.tgz", - "integrity": "sha512-ak9Qy5Q7jYb2Wwcey5Fpvg2KoAc/ZIhLSLOSBmRmygPsGwkVVt0fZa0qrtMz+m6tJTAHfZQ8FnmB4MG4LWy7/w==", "dev": true, + "license": "MIT", "engines": { "node": ">=8" } }, "node_modules/path-is-absolute": { "version": "1.0.1", - "resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz", - "integrity": "sha512-AVbw3UJ2e9bq64vSaS9Am0fje1Pa8pbGqTTsmXfaIiMpnr5DlDhfJOuLj9Sf95ZPVDAUerDfEk88MPmPe7UCQg==", "dev": true, + "license": "MIT", "engines": { "node": ">=0.10.0" } }, "node_modules/path-key": { "version": "3.1.1", - "resolved": "https://registry.npmjs.org/path-key/-/path-key-3.1.1.tgz", - "integrity": "sha512-ojmeN0qd+y0jszEtoY48r0Peq5dwMEkIlCOu6Q5f41lfkswXuKtYrhgoTpLnyIcHm24Uhqx+5Tqm2InSwLhE6Q==", "dev": true, + "license": "MIT", "engines": { "node": ">=8" } }, "node_modules/path-parse": { "version": "1.0.7", - "resolved": "https://registry.npmjs.org/path-parse/-/path-parse-1.0.7.tgz", - "integrity": "sha512-LDJzPVEEEPR+y48z93A0Ed0yXb8pAByGWo/k5YYdYgpY2/2EsOsksJrq7lOHxryrVOn1ejG6oAp8ahvOIQD8sw==", - "dev": true + "dev": true, + "license": "MIT" }, "node_modules/path-to-regexp": { "version": "0.1.7", - "resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-0.1.7.tgz", - "integrity": "sha512-5DFkuoqlv1uYQKxy8omFBeJPQcdoE07Kv2sferDCrAq1ohOU+MSDswDIbnx3YAM60qIOnYa53wBhXW0EbMonrQ==" + "license": "MIT" }, "node_modules/path-type": { "version": "4.0.0", - "resolved": "https://registry.npmjs.org/path-type/-/path-type-4.0.0.tgz", - "integrity": "sha512-gDKb8aZMDeD/tZWs9P6+q0J9Mwkdl6xMV8TjnGP3qJVJ06bdMgkbBlLU8IdfOsIsFz2BW1rNVT3XuNEl8zPAvw==", "dev": true, + "license": "MIT", "engines": { "node": ">=8" } }, "node_modules/pathval": { "version": "1.1.1", - "resolved": "https://registry.npmjs.org/pathval/-/pathval-1.1.1.tgz", - "integrity": "sha512-Dp6zGqpTdETdR63lehJYPeIOqpiNBNtc7BpWSLrOje7UaIsE5aY92r/AunQA7rsXvet3lrJ3JnZX29UPTKXyKQ==", "dev": true, + "license": "MIT", "engines": { "node": "*" } }, "node_modules/pbkdf2": { "version": "3.1.2", - "resolved": "https://registry.npmjs.org/pbkdf2/-/pbkdf2-3.1.2.tgz", - "integrity": "sha512-iuh7L6jA7JEGu2WxDwtQP1ddOpaJNC4KlDEFfdQajSGgGPNi4OyDc2R7QnbY2bR9QjBVGwgvTdNJZoE7RaxUMA==", + "license": "MIT", "dependencies": { "create-hash": "^1.1.2", "create-hmac": "^1.1.4", @@ -8671,20 +7968,17 @@ }, "node_modules/performance-now": { "version": "2.1.0", - "resolved": "https://registry.npmjs.org/performance-now/-/performance-now-2.1.0.tgz", - "integrity": "sha512-7EAHlyLHI56VEIdK57uwHdHKIaAGbnXPiw0yWbarQZOKaKpvUIgW0jWRVLiatnM+XXlSwsanIBH/hzGMJulMow==" + "license": "MIT" }, "node_modules/picocolors": { "version": "1.0.0", - "resolved": "https://registry.npmjs.org/picocolors/-/picocolors-1.0.0.tgz", - "integrity": "sha512-1fygroTLlHu66zi26VoTDv8yRgm0Fccecssto+MhsZ0D/DGW2sm8E8AjW7NU5VVTRt5GxbeZ5qBuJr+HyLYkjQ==", - "dev": true + "dev": true, + "license": "ISC" }, "node_modules/picomatch": { "version": "2.3.1", - "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.3.1.tgz", - "integrity": "sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA==", "dev": true, + "license": "MIT", "engines": { "node": ">=8.6" }, @@ -8694,18 +7988,16 @@ }, "node_modules/pirates": { "version": "4.0.6", - "resolved": "https://registry.npmjs.org/pirates/-/pirates-4.0.6.tgz", - "integrity": "sha512-saLsH7WeYYPiD25LDuLRRY/i+6HaPYr6G1OUlN39otzkSTxKnubR9RTxS3/Kk50s1g2JTgFwWQDQyplC5/SHZg==", "dev": true, + "license": "MIT", "engines": { "node": ">= 6" } }, "node_modules/pkg-dir": { "version": "4.2.0", - "resolved": "https://registry.npmjs.org/pkg-dir/-/pkg-dir-4.2.0.tgz", - "integrity": "sha512-HRDzbaKjC+AOWVXxAU/x54COGeIv9eb+6CkDSQoNTt4XyWoIJvuPsXizxu/Fr23EiekbtZwmh1IcIG/l/a10GQ==", "dev": true, + "license": "MIT", "dependencies": { "find-up": "^4.0.0" }, @@ -8715,18 +8007,16 @@ }, "node_modules/prelude-ls": { "version": "1.2.1", - "resolved": "https://registry.npmjs.org/prelude-ls/-/prelude-ls-1.2.1.tgz", - "integrity": "sha512-vkcDPrRZo1QZLbn5RLGPpg/WmIQ65qoWWhcGKf/b5eplkkarX0m9z8ppCat4mlOqUsWpyNuYgO3VRyrYHSzX5g==", "dev": true, + "license": "MIT", "engines": { "node": ">= 0.8.0" } }, "node_modules/prettier": { "version": "2.8.8", - "resolved": "https://registry.npmjs.org/prettier/-/prettier-2.8.8.tgz", - "integrity": "sha512-tdN8qQGvNjw4CHbY+XXk0JgCXn9QiF21a55rBe5LJAU+kDyC4WQn4+awm2Xfk2lQMk5fKup9XgzTZtGkjBdP9Q==", "dev": true, + "license": "MIT", "bin": { "prettier": "bin-prettier.js" }, @@ -8739,9 +8029,8 @@ }, "node_modules/pretty-format": { "version": "28.1.3", - "resolved": "https://registry.npmjs.org/pretty-format/-/pretty-format-28.1.3.tgz", - "integrity": "sha512-8gFb/To0OmxHR9+ZTb14Df2vNxdGCX8g1xWGUTqUw5TiZvcQf5sHKObd5UcPyLLyowNwDAMTF3XWOG1B6mxl1Q==", "dev": true, + "license": "MIT", "dependencies": { "@jest/schemas": "^28.1.3", "ansi-regex": "^5.0.1", @@ -8754,9 +8043,8 @@ }, "node_modules/pretty-format/node_modules/ansi-styles": { "version": "5.2.0", - "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-5.2.0.tgz", - "integrity": "sha512-Cxwpt2SfTzTtXcfOlzGEee8O+c+MmUgGrNiBcXnuWxuFJHe6a5Hz7qwhwe5OgaSYI0IJvkLqWX1ASG+cJOkEiA==", "dev": true, + "license": "MIT", "engines": { "node": ">=10" }, @@ -8766,26 +8054,23 @@ }, "node_modules/process": { "version": "0.11.10", - "resolved": "https://registry.npmjs.org/process/-/process-0.11.10.tgz", - "integrity": "sha512-cdGef/drWFoydD1JsMzuFf8100nZl+GT+yacc2bEced5f9Rjk4z+WtFUTBu9PhOi9j/jfmBPu0mMEY4wIdAF8A==", + "license": "MIT", "engines": { "node": ">= 0.6.0" } }, "node_modules/progress": { "version": "2.0.3", - "resolved": "https://registry.npmjs.org/progress/-/progress-2.0.3.tgz", - "integrity": "sha512-7PiHtLll5LdnKIMw100I+8xJXR5gW2QwWYkT6iJva0bXitZKa/XMrSbdmg3r2Xnaidz9Qumd0VPaMrZlF9V9sA==", "dev": true, + "license": "MIT", "engines": { "node": ">=0.4.0" } }, "node_modules/prompts": { "version": "2.4.2", - "resolved": "https://registry.npmjs.org/prompts/-/prompts-2.4.2.tgz", - "integrity": "sha512-NxNv/kLguCA7p3jE8oL2aEBsrJWgAakBpgmgK6lpPWV+WuOmY6r2/zbAVnP+T8bQlA0nzHXSJSJW0Hq7ylaD2Q==", "dev": true, + "license": "MIT", "dependencies": { "kleur": "^3.0.3", "sisteransi": "^1.0.5" @@ -8796,9 +8081,8 @@ }, "node_modules/protobufjs": { "version": "6.11.4", - "resolved": "https://registry.npmjs.org/protobufjs/-/protobufjs-6.11.4.tgz", - "integrity": "sha512-5kQWPaJHi1WoCpjTGszzQ32PG2F4+wRY6BmAT4Vfw56Q2FZ4YZzK20xUYQH4YkfehY1e6QSICrJquM6xXZNcrw==", "hasInstallScript": true, + "license": "BSD-3-Clause", "dependencies": { "@protobufjs/aspromise": "^1.1.2", "@protobufjs/base64": "^1.1.2", @@ -8821,8 +8105,7 @@ }, "node_modules/proxy-addr": { "version": "2.0.7", - "resolved": "https://registry.npmjs.org/proxy-addr/-/proxy-addr-2.0.7.tgz", - "integrity": "sha512-llQsMLSUDUPT44jdrU/O37qlnifitDP+ZwrmmZcoSKyLKvtZxpyV0n2/bD/N4tBAAZ/gJEdZU7KMraoK1+XYAg==", + "license": "MIT", "dependencies": { "forwarded": "0.2.0", "ipaddr.js": "1.9.1" @@ -8831,32 +8114,32 @@ "node": ">= 0.10" } }, + "node_modules/proxy-from-env": { + "version": "1.1.0", + "license": "MIT" + }, "node_modules/psl": { "version": "1.9.0", - "resolved": "https://registry.npmjs.org/psl/-/psl-1.9.0.tgz", - "integrity": "sha512-E/ZsdU4HLs/68gYzgGTkMicWTLPdAftJLfJFlLUAAKZGkStNU72sZjT66SnMDVOfOWY/YAoiD7Jxa9iHvngcag==" + "license": "MIT" }, "node_modules/pump": { "version": "3.0.0", - "resolved": "https://registry.npmjs.org/pump/-/pump-3.0.0.tgz", - "integrity": "sha512-LwZy+p3SFs1Pytd/jYct4wpv49HiYCqd9Rlc5ZVdk0V+8Yzv6jR5Blk3TRmPL1ft69TxP0IMZGJ+WPFU2BFhww==", + "license": "MIT", "dependencies": { "end-of-stream": "^1.1.0", "once": "^1.3.1" } }, "node_modules/punycode": { - "version": "2.3.0", - "resolved": "https://registry.npmjs.org/punycode/-/punycode-2.3.0.tgz", - "integrity": "sha512-rRV+zQD8tVFys26lAGR9WUuS4iUAngJScM+ZRSKtvl5tKeZ2t5bvdNFdNHBW9FWR4guGHlgmsZ1G7BSm2wTbuA==", + "version": "2.3.1", + "license": "MIT", "engines": { "node": ">=6" } }, "node_modules/qs": { "version": "6.11.0", - "resolved": "https://registry.npmjs.org/qs/-/qs-6.11.0.tgz", - "integrity": "sha512-MvjoMCJwEarSbUYk5O+nmoSzSutSsTwF85zcHPQ9OrlFoZOYIjaqBAJIqIXjptyD5vThxGq52Xu/MaJzRkIk4Q==", + "license": "BSD-3-Clause", "dependencies": { "side-channel": "^1.0.4" }, @@ -8869,8 +8152,7 @@ }, "node_modules/query-string": { "version": "5.1.1", - "resolved": "https://registry.npmjs.org/query-string/-/query-string-5.1.1.tgz", - "integrity": "sha512-gjWOsm2SoGlgLEdAGt7a6slVOk9mGiXmPFMqrEhLQ68rhQuBnpfs3+EmlvqKyxnCo9/PPlF+9MtY02S1aFg+Jw==", + "license": "MIT", "dependencies": { "decode-uri-component": "^0.2.0", "object-assign": "^4.1.0", @@ -8882,9 +8164,6 @@ }, "node_modules/queue-microtask": { "version": "1.2.3", - "resolved": "https://registry.npmjs.org/queue-microtask/-/queue-microtask-1.2.3.tgz", - "integrity": "sha512-NuaNSa6flKT5JaSYQzJok04JzTL1CA6aGhv5rfLW3PgqA+M2ChpZQnAC8h8i4ZFkBS8X5RqkDBHA7r4hej3K9A==", - "dev": true, "funding": [ { "type": "github", @@ -8898,12 +8177,12 @@ "type": "consulting", "url": "https://feross.org/support" } - ] + ], + "license": "MIT" }, "node_modules/quick-lru": { "version": "5.1.1", - "resolved": "https://registry.npmjs.org/quick-lru/-/quick-lru-5.1.1.tgz", - "integrity": "sha512-WuyALRjWPDGtt/wzJiadO5AXY+8hZ80hVpe6MyivgraREW751X3SbhRvG3eLKOYN+8VEvqLcf3wdnt44Z4S4SA==", + "license": "MIT", "engines": { "node": ">=10" }, @@ -8913,24 +8192,21 @@ }, "node_modules/randombytes": { "version": "2.1.0", - "resolved": "https://registry.npmjs.org/randombytes/-/randombytes-2.1.0.tgz", - "integrity": "sha512-vYl3iOX+4CKUWuxGi9Ukhie6fsqXqS9FE2Zaic4tNFD2N2QQaXOMFbuKK4QmDHC0JO6B1Zp41J0LpT0oR68amQ==", + "license": "MIT", "dependencies": { "safe-buffer": "^5.1.0" } }, "node_modules/range-parser": { "version": "1.2.1", - "resolved": "https://registry.npmjs.org/range-parser/-/range-parser-1.2.1.tgz", - "integrity": "sha512-Hrgsx+orqoygnmhFbKaHE6c296J+HTAQXoxEF6gNupROmmGJRoyzfG3ccAveqCBrwr/2yxQ5BVd/GTl5agOwSg==", + "license": "MIT", "engines": { "node": ">= 0.6" } }, "node_modules/raw-body": { "version": "2.5.2", - "resolved": "https://registry.npmjs.org/raw-body/-/raw-body-2.5.2.tgz", - "integrity": "sha512-8zGqypfENjCIqGhgXToC8aB2r7YrBX+AQAfIPs/Mlk+BtPTztOvTS01NRW/3Eh60J+a48lt8qsCzirQ6loCVfA==", + "license": "MIT", "dependencies": { "bytes": "3.1.2", "http-errors": "2.0.0", @@ -8943,8 +8219,7 @@ }, "node_modules/rdf-canonize": { "version": "3.4.0", - "resolved": "https://registry.npmjs.org/rdf-canonize/-/rdf-canonize-3.4.0.tgz", - "integrity": "sha512-fUeWjrkOO0t1rg7B2fdyDTvngj+9RlUyL92vOdiB7c0FPguWVsniIMjEtHH+meLBO9rzkUlUzBVXgWrjI8P9LA==", + "license": "BSD-3-Clause", "dependencies": { "setimmediate": "^1.0.5" }, @@ -8954,14 +8229,12 @@ }, "node_modules/react-is": { "version": "18.2.0", - "resolved": "https://registry.npmjs.org/react-is/-/react-is-18.2.0.tgz", - "integrity": "sha512-xWGDIW6x921xtzPkhiULtthJHoJvBbF3q26fzloPCK0hsvxtPVelvftw3zjbHWSkR2km9Z+4uxbDDK/6Zw9B8w==", - "dev": true + "dev": true, + "license": "MIT" }, "node_modules/readable-stream": { "version": "3.6.2", - "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-3.6.2.tgz", - "integrity": "sha512-9u/sniCrY3D5WdsERHzHE4G2YCXqoG5FTHUiCC4SIbr6XcLZBY05ya9EKjYek9O5xOAwjGq+1JdGBAS7Q9ScoA==", + "license": "MIT", "dependencies": { "inherits": "^2.0.3", "string_decoder": "^1.1.1", @@ -8973,9 +8246,8 @@ }, "node_modules/readdirp": { "version": "3.6.0", - "resolved": "https://registry.npmjs.org/readdirp/-/readdirp-3.6.0.tgz", - "integrity": "sha512-hOS089on8RduqdbhvQ5Z37A0ESjsqz6qnRcffsMU3495FuTdqSm+7bhJ29JvIOsBDEEnan5DPu9t3To9VRlMzA==", "dev": true, + "license": "MIT", "dependencies": { "picomatch": "^2.2.1" }, @@ -8985,17 +8257,15 @@ }, "node_modules/readonly-date": { "version": "1.0.0", - "resolved": "https://registry.npmjs.org/readonly-date/-/readonly-date-1.0.0.tgz", - "integrity": "sha512-tMKIV7hlk0h4mO3JTmmVuIlJVXjKk3Sep9Bf5OH0O+758ruuVkUy2J9SttDLm91IEX/WHlXPSpxMGjPj4beMIQ==" + "license": "Apache-2.0" }, "node_modules/regexp.prototype.flags": { - "version": "1.5.0", - "resolved": "https://registry.npmjs.org/regexp.prototype.flags/-/regexp.prototype.flags-1.5.0.tgz", - "integrity": "sha512-0SutC3pNudRKgquxGoRGIz946MZVHqbNfPjBdxeOhBrdgDKlRoXmYLQN9xRbrR09ZXWeGAdPuif7egofn6v5LA==", + "version": "1.5.1", + "license": "MIT", "dependencies": { "call-bind": "^1.0.2", "define-properties": "^1.2.0", - "functions-have-names": "^1.2.3" + "set-function-name": "^2.0.0" }, "engines": { "node": ">= 0.4" @@ -9006,9 +8276,8 @@ }, "node_modules/regexpp": { "version": "3.2.0", - "resolved": "https://registry.npmjs.org/regexpp/-/regexpp-3.2.0.tgz", - "integrity": "sha512-pq2bWo9mVD43nbts2wGv17XLiNLya+GklZ8kaDLV2Z08gDCsGpnKn9BFMepvWuHCbyVvY7J5o5+BVvoQbmlJLg==", "dev": true, + "license": "MIT", "engines": { "node": ">=8" }, @@ -9018,9 +8287,7 @@ }, "node_modules/request": { "version": "2.88.2", - "resolved": "https://registry.npmjs.org/request/-/request-2.88.2.tgz", - "integrity": "sha512-MsvtOrfG9ZcrOwAW+Qi+F6HbD0CWXEh9ou77uOb7FM2WPhwT7smM833PzanhJLsgXjN89Ir6V2PczXNnMpwKhw==", - "deprecated": "request has been deprecated, see https://github.com/request/request/issues/3142", + "license": "Apache-2.0", "dependencies": { "aws-sign2": "~0.7.0", "aws4": "^1.8.0", @@ -9047,46 +8314,52 @@ "node": ">= 6" } }, + "node_modules/request/node_modules/form-data": { + "version": "2.3.3", + "license": "MIT", + "dependencies": { + "asynckit": "^0.4.0", + "combined-stream": "^1.0.6", + "mime-types": "^2.1.12" + }, + "engines": { + "node": ">= 0.12" + } + }, "node_modules/request/node_modules/qs": { "version": "6.5.3", - "resolved": "https://registry.npmjs.org/qs/-/qs-6.5.3.tgz", - "integrity": "sha512-qxXIEh4pCGfHICj1mAJQ2/2XVZkjCDTcEgfoSQxc/fYivUZxTkk7L3bDBJSoNrEzXI17oUO5Dp07ktqE5KzczA==", + "license": "BSD-3-Clause", "engines": { "node": ">=0.6" } }, "node_modules/request/node_modules/uuid": { "version": "3.4.0", - "resolved": "https://registry.npmjs.org/uuid/-/uuid-3.4.0.tgz", - "integrity": "sha512-HjSDRw6gZE5JMggctHBcjVak08+KEVhSIiDzFnT9S9aegmp85S/bReBVTb4QTFaRNptJ9kuYaNhnbNEOkbKb/A==", - "deprecated": "Please upgrade to version 7 or higher. Older versions may use Math.random() in certain circumstances, which is known to be problematic. See https://v8.dev/blog/math-random for details.", + "license": "MIT", "bin": { "uuid": "bin/uuid" } }, "node_modules/require-directory": { "version": "2.1.1", - "resolved": "https://registry.npmjs.org/require-directory/-/require-directory-2.1.1.tgz", - "integrity": "sha512-fGxEI7+wsG9xrvdjsrlmL22OMTTiHRwAMroiEeMgq8gzoLC/PQr7RsRDSTLUg/bZAZtF+TVIkHc6/4RIKrui+Q==", "dev": true, + "license": "MIT", "engines": { "node": ">=0.10.0" } }, "node_modules/require-from-string": { "version": "2.0.2", - "resolved": "https://registry.npmjs.org/require-from-string/-/require-from-string-2.0.2.tgz", - "integrity": "sha512-Xf0nWe6RseziFMu+Ap9biiUbmplq6S9/p+7w7YXP/JBHhrUDDUhwa+vANyubuqfZWTveU//DYVGsDG7RKL/vEw==", "dev": true, + "license": "MIT", "engines": { "node": ">=0.10.0" } }, "node_modules/resolve": { - "version": "1.22.4", - "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.22.4.tgz", - "integrity": "sha512-PXNdCiPqDqeUou+w1C2eTQbNfxKSuMxqTCuvlmmMsk1NWHL5fRrhY6Pl0qEYYc6+QqGClco1Qj8XnjPego4wfg==", + "version": "1.22.8", "dev": true, + "license": "MIT", "dependencies": { "is-core-module": "^2.13.0", "path-parse": "^1.0.7", @@ -9101,14 +8374,12 @@ }, "node_modules/resolve-alpn": { "version": "1.2.1", - "resolved": "https://registry.npmjs.org/resolve-alpn/-/resolve-alpn-1.2.1.tgz", - "integrity": "sha512-0a1F4l73/ZFZOakJnQ3FvkJ2+gSTQWz/r2KE5OdDY0TxPm5h4GkqkWWfM47T7HsbnOtcJVEF4epCVy6u7Q3K+g==" + "license": "MIT" }, "node_modules/resolve-cwd": { "version": "3.0.0", - "resolved": "https://registry.npmjs.org/resolve-cwd/-/resolve-cwd-3.0.0.tgz", - "integrity": "sha512-OrZaX2Mb+rJCpH/6CpSqt9xFVpN++x01XnN2ie9g6P5/3xelLAkXWVADpdz1IHD/KFfEXyE6V0U01OQ3UO2rEg==", "dev": true, + "license": "MIT", "dependencies": { "resolve-from": "^5.0.0" }, @@ -9118,35 +8389,31 @@ }, "node_modules/resolve-cwd/node_modules/resolve-from": { "version": "5.0.0", - "resolved": "https://registry.npmjs.org/resolve-from/-/resolve-from-5.0.0.tgz", - "integrity": "sha512-qYg9KP24dD5qka9J47d0aVky0N+b4fTU89LN9iDnjB5waksiC49rvMB0PrUJQGoTmH50XPiqOvAjDfaijGxYZw==", "dev": true, + "license": "MIT", "engines": { "node": ">=8" } }, "node_modules/resolve-from": { "version": "4.0.0", - "resolved": "https://registry.npmjs.org/resolve-from/-/resolve-from-4.0.0.tgz", - "integrity": "sha512-pb/MYmXstAkysRFx8piNI1tGFNQIFA3vkE3Gq4EuA1dF6gHp/+vgZqsCGJapvy8N3Q+4o7FwvquPJcnZ7RYy4g==", "dev": true, + "license": "MIT", "engines": { "node": ">=4" } }, "node_modules/resolve.exports": { "version": "1.1.1", - "resolved": "https://registry.npmjs.org/resolve.exports/-/resolve.exports-1.1.1.tgz", - "integrity": "sha512-/NtpHNDN7jWhAaQ9BvBUYZ6YTXsRBgfqWFWP7BZBaoMJO/I3G5OFzvTuWNlZC3aPjins1F+TNrLKsGbH4rfsRQ==", "dev": true, + "license": "MIT", "engines": { "node": ">=10" } }, "node_modules/responselike": { "version": "2.0.1", - "resolved": "https://registry.npmjs.org/responselike/-/responselike-2.0.1.tgz", - "integrity": "sha512-4gl03wn3hj1HP3yzgdI7d3lCkF95F21Pz4BPGvKHinyQzALR5CapwC8yIi0Rh58DEMQ/SguC03wFj2k0M/mHhw==", + "license": "MIT", "dependencies": { "lowercase-keys": "^2.0.0" }, @@ -9156,17 +8423,15 @@ }, "node_modules/responselike/node_modules/lowercase-keys": { "version": "2.0.0", - "resolved": "https://registry.npmjs.org/lowercase-keys/-/lowercase-keys-2.0.0.tgz", - "integrity": "sha512-tqNXrS78oMOE73NMxK4EMLQsQowWf8jKooH9g7xPavRT706R6bkQJ6DY2Te7QukaZsulxa30wQ7bk0pm4XiHmA==", + "license": "MIT", "engines": { "node": ">=8" } }, "node_modules/reusify": { "version": "1.0.4", - "resolved": "https://registry.npmjs.org/reusify/-/reusify-1.0.4.tgz", - "integrity": "sha512-U9nH88a3fc/ekCF1l0/UP1IosiuIjyTh7hBvXVMHYgVcfGvt897Xguj2UOLDeI5BG2m7/uwyaLVT6fbtCwTyzw==", "dev": true, + "license": "MIT", "engines": { "iojs": ">=1.0.0", "node": ">=0.10.0" @@ -9174,9 +8439,8 @@ }, "node_modules/rimraf": { "version": "3.0.2", - "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-3.0.2.tgz", - "integrity": "sha512-JZkJMZkAGFFPP2YqXZXPbMlMBgsxzE8ILs4lMIX/2o0L9UBw9O/Y3o6wFw/i9YLapcUJWwqbi3kdxIPdC62TIA==", "dev": true, + "license": "ISC", "dependencies": { "glob": "^7.1.3" }, @@ -9189,8 +8453,7 @@ }, "node_modules/ripemd160": { "version": "2.0.2", - "resolved": "https://registry.npmjs.org/ripemd160/-/ripemd160-2.0.2.tgz", - "integrity": "sha512-ii4iagi25WusVoiC4B4lq7pbXfAp3D9v5CwfkY33vffw2+pkDjY1D8GaN7spsxvCSx8dkPqOZCEZyfxcmJG2IA==", + "license": "MIT", "dependencies": { "hash-base": "^3.0.0", "inherits": "^2.0.1" @@ -9198,8 +8461,7 @@ }, "node_modules/rlp": { "version": "2.2.7", - "resolved": "https://registry.npmjs.org/rlp/-/rlp-2.2.7.tgz", - "integrity": "sha512-d5gdPmgQ0Z+AklL2NVXr/IoSjNZFfTVvQWzL/AM2AOcSzYP2xjlb0AC8YyCLc41MSNf6P6QVtjgPdmVtzb+4lQ==", + "license": "MPL-2.0", "dependencies": { "bn.js": "^5.2.0" }, @@ -9209,8 +8471,6 @@ }, "node_modules/run-parallel": { "version": "1.2.0", - "resolved": "https://registry.npmjs.org/run-parallel/-/run-parallel-1.2.0.tgz", - "integrity": "sha512-5l4VyZR86LZ/lDxZTR6jqL8AFE2S0IFLMP26AbjsLVADxHdhB/c0GUsH+y39UfCi3dzz8OlQuPmnaJOMoDHQBA==", "dev": true, "funding": [ { @@ -9226,14 +8486,14 @@ "url": "https://feross.org/support" } ], + "license": "MIT", "dependencies": { "queue-microtask": "^1.2.2" } }, "node_modules/safe-array-concat": { "version": "1.0.1", - "resolved": "https://registry.npmjs.org/safe-array-concat/-/safe-array-concat-1.0.1.tgz", - "integrity": "sha512-6XbUAseYE2KtOuGueyeobCySj9L4+66Tn6KQMOPQJrAJEowYKW/YR/MGJZl7FdydUdaFu4LYyDZjxf4/Nmo23Q==", + "license": "MIT", "dependencies": { "call-bind": "^1.0.2", "get-intrinsic": "^1.2.1", @@ -9249,8 +8509,6 @@ }, "node_modules/safe-buffer": { "version": "5.2.1", - "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.1.tgz", - "integrity": "sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ==", "funding": [ { "type": "github", @@ -9264,12 +8522,12 @@ "type": "consulting", "url": "https://feross.org/support" } - ] + ], + "license": "MIT" }, "node_modules/safe-regex-test": { "version": "1.0.0", - "resolved": "https://registry.npmjs.org/safe-regex-test/-/safe-regex-test-1.0.0.tgz", - "integrity": "sha512-JBUUzyOgEwXQY1NuPtvcj/qcBDbDmEvWufhlnXZIm75DEHp+afM1r1ujJpJsV/gSM4t59tpDyPi1sd6ZaPFfsA==", + "license": "MIT", "dependencies": { "call-bind": "^1.0.2", "get-intrinsic": "^1.1.3", @@ -9281,19 +8539,16 @@ }, "node_modules/safer-buffer": { "version": "2.1.2", - "resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz", - "integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==" + "license": "MIT" }, "node_modules/scrypt-js": { "version": "3.0.1", - "resolved": "https://registry.npmjs.org/scrypt-js/-/scrypt-js-3.0.1.tgz", - "integrity": "sha512-cdwTTnqPu0Hyvf5in5asVdZocVDTNRmR7XEcJuIzMjJeSHybHl7vpB66AzwTaIg6CLSbtjcxc8fqcySfnTkccA==" + "license": "MIT" }, "node_modules/secp256k1": { "version": "4.0.3", - "resolved": "https://registry.npmjs.org/secp256k1/-/secp256k1-4.0.3.tgz", - "integrity": "sha512-NLZVf+ROMxwtEj3Xa562qgv2BK5e2WNmXPiOdVIPLgs6lyTzMvBq0aWTYMI5XCP9jZMVKOcqZLw/Wc4vDkuxhA==", "hasInstallScript": true, + "license": "MIT", "dependencies": { "elliptic": "^6.5.4", "node-addon-api": "^2.0.0", @@ -9304,14 +8559,11 @@ } }, "node_modules/security-context": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/security-context/-/security-context-4.0.0.tgz", - "integrity": "sha512-yiDCS7tpKQl6p4NG57BdKLTSNLFfj5HosBIzXBl4jZf/qorJzSzbEUIdLhN+vVYgyLlvjixY8DPPTgqI8zvNCA==" + "version": "4.0.0" }, "node_modules/semver": { "version": "7.5.4", - "resolved": "https://registry.npmjs.org/semver/-/semver-7.5.4.tgz", - "integrity": "sha512-1bCSESV6Pv+i21Hvpxp3Dx+pSD8lIPt8uVjRrxAUt/nbswYc+tK6Y2btiULjd4+fnq15PX+nqQDC7Oft7WkwcA==", + "license": "ISC", "dependencies": { "lru-cache": "^6.0.0" }, @@ -9324,8 +8576,7 @@ }, "node_modules/semver/node_modules/lru-cache": { "version": "6.0.0", - "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-6.0.0.tgz", - "integrity": "sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA==", + "license": "ISC", "dependencies": { "yallist": "^4.0.0" }, @@ -9335,13 +8586,11 @@ }, "node_modules/semver/node_modules/yallist": { "version": "4.0.0", - "resolved": "https://registry.npmjs.org/yallist/-/yallist-4.0.0.tgz", - "integrity": "sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==" + "license": "ISC" }, "node_modules/send": { "version": "0.18.0", - "resolved": "https://registry.npmjs.org/send/-/send-0.18.0.tgz", - "integrity": "sha512-qqWzuOjSFOuqPjFe4NOsMLafToQQwBSOEpS+FwEt3A2V3vKubTquT3vmLTQpFgMXp8AlFWFuP1qKaJZOtPpVXg==", + "license": "MIT", "dependencies": { "debug": "2.6.9", "depd": "2.0.0", @@ -9363,26 +8612,22 @@ }, "node_modules/send/node_modules/debug": { "version": "2.6.9", - "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", - "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==", + "license": "MIT", "dependencies": { "ms": "2.0.0" } }, "node_modules/send/node_modules/debug/node_modules/ms": { "version": "2.0.0", - "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", - "integrity": "sha512-Tpp60P6IUJDTuOq/5Z8cdskzJujfwqfOTkrwIwj7IRISpnkJnT6SyJ4PCPnGMoFjC9ddhal5KVIYtAt97ix05A==" + "license": "MIT" }, "node_modules/send/node_modules/ms": { "version": "2.1.3", - "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz", - "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==" + "license": "MIT" }, "node_modules/serialize-error": { "version": "8.1.0", - "resolved": "https://registry.npmjs.org/serialize-error/-/serialize-error-8.1.0.tgz", - "integrity": "sha512-3NnuWfM6vBYoy5gZFvHiYsVbafvI9vZv/+jlIigFn4oP4zjNPK3LhcY0xSCgeb1a5L8jO71Mit9LlNoi2UfDDQ==", + "license": "MIT", "dependencies": { "type-fest": "^0.20.2" }, @@ -9395,17 +8640,15 @@ }, "node_modules/serialize-javascript": { "version": "6.0.0", - "resolved": "https://registry.npmjs.org/serialize-javascript/-/serialize-javascript-6.0.0.tgz", - "integrity": "sha512-Qr3TosvguFt8ePWqsvRfrKyQXIiW+nGbYpy8XK24NQHE83caxWt+mIymTT19DGFbNWNLfEwsrkSmN64lVWB9ag==", "dev": true, + "license": "BSD-3-Clause", "dependencies": { "randombytes": "^2.1.0" } }, "node_modules/serve-static": { "version": "1.15.0", - "resolved": "https://registry.npmjs.org/serve-static/-/serve-static-1.15.0.tgz", - "integrity": "sha512-XGuRDNjXUijsUL0vl6nSD7cwURuzEgglbOaFuZM9g3kwDXOWVTck0jLzjPzGD+TazWbboZYu52/9/XPdUgne9g==", + "license": "MIT", "dependencies": { "encodeurl": "~1.0.2", "escape-html": "~1.0.3", @@ -9418,8 +8661,7 @@ }, "node_modules/servify": { "version": "0.1.12", - "resolved": "https://registry.npmjs.org/servify/-/servify-0.1.12.tgz", - "integrity": "sha512-/xE6GvsKKqyo1BAY+KxOWXcLpPsUUyji7Qg3bVD7hh1eRze5bR1uYiuDA/k3Gof1s9BTzQZEJK8sNcNGFIzeWw==", + "license": "MIT", "dependencies": { "body-parser": "^1.16.0", "cors": "^2.8.1", @@ -9431,20 +8673,42 @@ "node": ">=6" } }, + "node_modules/set-function-length": { + "version": "1.1.1", + "license": "MIT", + "dependencies": { + "define-data-property": "^1.1.1", + "get-intrinsic": "^1.2.1", + "gopd": "^1.0.1", + "has-property-descriptors": "^1.0.0" + }, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/set-function-name": { + "version": "2.0.1", + "license": "MIT", + "dependencies": { + "define-data-property": "^1.0.1", + "functions-have-names": "^1.2.3", + "has-property-descriptors": "^1.0.0" + }, + "engines": { + "node": ">= 0.4" + } + }, "node_modules/setimmediate": { "version": "1.0.5", - "resolved": "https://registry.npmjs.org/setimmediate/-/setimmediate-1.0.5.tgz", - "integrity": "sha512-MATJdZp8sLqDl/68LfQmbP8zKPLQNV6BIZoIgrscFDQ+RsvK/BxeDQOgyxKKoh0y/8h3BqVFnCqQ/gd+reiIXA==" + "license": "MIT" }, "node_modules/setprototypeof": { "version": "1.2.0", - "resolved": "https://registry.npmjs.org/setprototypeof/-/setprototypeof-1.2.0.tgz", - "integrity": "sha512-E5LDX7Wrp85Kil5bhZv46j8jOeboKq5JMmYM3gVGdGH8xFpPWXUMsNrlODCrkoxMEeNi/XZIwuRvY4XNwYMJpw==" + "license": "ISC" }, "node_modules/sha.js": { "version": "2.4.11", - "resolved": "https://registry.npmjs.org/sha.js/-/sha.js-2.4.11.tgz", - "integrity": "sha512-QMEp5B7cftE7APOjk5Y6xgrbWu+WkLVQwk8JNjZ8nKRciZaByEW6MubieAiToS7+dwvrjGhH8jRXz3MVd0AYqQ==", + "license": "(MIT AND BSD-3-Clause)", "dependencies": { "inherits": "^2.0.1", "safe-buffer": "^5.0.1" @@ -9455,9 +8719,8 @@ }, "node_modules/shebang-command": { "version": "2.0.0", - "resolved": "https://registry.npmjs.org/shebang-command/-/shebang-command-2.0.0.tgz", - "integrity": "sha512-kHxr2zZpYtdmrN1qDjrrX/Z1rR1kG8Dx+gkpK1G4eXmvXswmcE1hTWBWYUzlraYw1/yZp6YuDY77YtvbN0dmDA==", "dev": true, + "license": "MIT", "dependencies": { "shebang-regex": "^3.0.0" }, @@ -9467,17 +8730,15 @@ }, "node_modules/shebang-regex": { "version": "3.0.0", - "resolved": "https://registry.npmjs.org/shebang-regex/-/shebang-regex-3.0.0.tgz", - "integrity": "sha512-7++dFhtcx3353uBaq8DDR4NuxBetBzC7ZQOhmTQInHEd6bSrXdiEyzCvG07Z44UYdLShWUyXt5M/yhz8ekcb1A==", "dev": true, + "license": "MIT", "engines": { "node": ">=8" } }, "node_modules/side-channel": { "version": "1.0.4", - "resolved": "https://registry.npmjs.org/side-channel/-/side-channel-1.0.4.tgz", - "integrity": "sha512-q5XPytqFEIKHkGdiMIrY10mvLRvnQh42/+GoBlFW3b2LXLE2xxJpZFdm94we0BaoV3RwJyGqg5wS7epxTv0Zvw==", + "license": "MIT", "dependencies": { "call-bind": "^1.0.0", "get-intrinsic": "^1.0.2", @@ -9489,14 +8750,11 @@ }, "node_modules/signal-exit": { "version": "3.0.7", - "resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-3.0.7.tgz", - "integrity": "sha512-wnD2ZE+l+SPC/uoS0vXeE9L1+0wuaMqKlfz9AMUo38JsyLSBWSFcHR1Rri62LZc12vLr1gb3jl7iwQhgwpAbGQ==", - "dev": true + "dev": true, + "license": "ISC" }, "node_modules/simple-concat": { "version": "1.0.1", - "resolved": "https://registry.npmjs.org/simple-concat/-/simple-concat-1.0.1.tgz", - "integrity": "sha512-cSFtAPtRhljv69IK0hTVZQ+OfE9nePi/rtJmw5UjHeVyVroEqJXP1sFztKUy1qU+xvz3u/sfYJLa947b7nAN2Q==", "funding": [ { "type": "github", @@ -9510,12 +8768,12 @@ "type": "consulting", "url": "https://feross.org/support" } - ] + ], + "license": "MIT" }, "node_modules/simple-get": { "version": "2.8.2", - "resolved": "https://registry.npmjs.org/simple-get/-/simple-get-2.8.2.tgz", - "integrity": "sha512-Ijd/rV5o+mSBBs4F/x9oDPtTx9Zb6X9brmnXvMW4J7IR15ngi9q5xxqWBKU744jTZiaXtxaPL7uHG6vtN8kUkw==", + "license": "MIT", "dependencies": { "decompress-response": "^3.3.0", "once": "^1.3.1", @@ -9524,8 +8782,7 @@ }, "node_modules/simple-get/node_modules/decompress-response": { "version": "3.3.0", - "resolved": "https://registry.npmjs.org/decompress-response/-/decompress-response-3.3.0.tgz", - "integrity": "sha512-BzRPQuY1ip+qDonAOz42gRm/pg9F768C+npV/4JOsxRC2sq+Rlk+Q4ZCAsOhnIaMrgarILY+RMUIvMmmX1qAEA==", + "license": "MIT", "dependencies": { "mimic-response": "^1.0.0" }, @@ -9535,24 +8792,21 @@ }, "node_modules/sisteransi": { "version": "1.0.5", - "resolved": "https://registry.npmjs.org/sisteransi/-/sisteransi-1.0.5.tgz", - "integrity": "sha512-bLGGlR1QxBcynn2d5YmDX4MGjlZvy2MRBDRNHLJ8VI6l6+9FUiyTFNJ0IveOSP0bcXgVDPRcfGqA0pjaqUpfVg==", - "dev": true + "dev": true, + "license": "MIT" }, "node_modules/slash": { "version": "3.0.0", - "resolved": "https://registry.npmjs.org/slash/-/slash-3.0.0.tgz", - "integrity": "sha512-g9Q1haeby36OSStwb4ntCGGGaKsaVSjQ68fBxoQcutl5fS1vuY18H3wSt3jFyFtrkx+Kz0V1G85A4MyAdDMi2Q==", "dev": true, + "license": "MIT", "engines": { "node": ">=8" } }, "node_modules/slice-ansi": { "version": "4.0.0", - "resolved": "https://registry.npmjs.org/slice-ansi/-/slice-ansi-4.0.0.tgz", - "integrity": "sha512-qMCMfhY040cVHT43K9BFygqYbUPFZKHOg7K73mtTWJRb8pyP3fzf4Ixd5SzdEJQ6MRUg/WBnOLxghZtKKurENQ==", "dev": true, + "license": "MIT", "dependencies": { "ansi-styles": "^4.0.0", "astral-regex": "^2.0.0", @@ -9567,18 +8821,16 @@ }, "node_modules/source-map": { "version": "0.6.1", - "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz", - "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==", "dev": true, + "license": "BSD-3-Clause", "engines": { "node": ">=0.10.0" } }, "node_modules/source-map-support": { "version": "0.5.13", - "resolved": "https://registry.npmjs.org/source-map-support/-/source-map-support-0.5.13.tgz", - "integrity": "sha512-SHSKFHadjVA5oR4PPqhtAVdcBWwRYVd6g6cAXnIbRiIwc2EhPrTuKUBdSLvlEKyIP3GCf89fltvcZiP9MMFA1w==", "dev": true, + "license": "MIT", "dependencies": { "buffer-from": "^1.0.0", "source-map": "^0.6.0" @@ -9586,14 +8838,12 @@ }, "node_modules/sprintf-js": { "version": "1.0.3", - "resolved": "https://registry.npmjs.org/sprintf-js/-/sprintf-js-1.0.3.tgz", - "integrity": "sha512-D9cPgkvLlV3t3IzL0D0YLvGA9Ahk4PcvVwUbN0dSGr1aP0Nrt4AEnTUbuGvquEC0mA64Gqt1fzirlRs5ibXx8g==", - "dev": true + "dev": true, + "license": "BSD-3-Clause" }, "node_modules/sshpk": { - "version": "1.17.0", - "resolved": "https://registry.npmjs.org/sshpk/-/sshpk-1.17.0.tgz", - "integrity": "sha512-/9HIEs1ZXGhSPE8X6Ccm7Nam1z8KcoCqPdI7ecm1N33EzAetWahvQWVqLZtaZQ+IDKX4IyA2o0gBzqIMkAagHQ==", + "version": "1.18.0", + "license": "MIT", "dependencies": { "asn1": "~0.2.3", "assert-plus": "^1.0.0", @@ -9616,14 +8866,12 @@ }, "node_modules/sshpk/node_modules/tweetnacl": { "version": "0.14.5", - "resolved": "https://registry.npmjs.org/tweetnacl/-/tweetnacl-0.14.5.tgz", - "integrity": "sha512-KXXFFdAbFXY4geFIwoyNK+f5Z1b7swfXABfL7HXCmoIWMKU3dmS26672A4EeQtDzLKy7SXmfBu51JolvEKwtGA==" + "license": "Unlicense" }, "node_modules/stack-utils": { "version": "2.0.6", - "resolved": "https://registry.npmjs.org/stack-utils/-/stack-utils-2.0.6.tgz", - "integrity": "sha512-XlkWvfIm6RmsWtNJx+uqtKLS8eqFbxUg0ZzLXqY0caEy9l7hruX8IpiDnjsLavoBgqCCR71TqWO8MaXYheJ3RQ==", "dev": true, + "license": "MIT", "dependencies": { "escape-string-regexp": "^2.0.0" }, @@ -9633,50 +8881,37 @@ }, "node_modules/stack-utils/node_modules/escape-string-regexp": { "version": "2.0.0", - "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-2.0.0.tgz", - "integrity": "sha512-UpzcLCXolUWcNu5HtVMHYdXJjArjsF9C0aNnquZYY4uW/Vu0miy5YoWvbV345HauVvcAUnpRuhMMcqTcGOY2+w==", "dev": true, + "license": "MIT", "engines": { "node": ">=8" } }, "node_modules/statuses": { "version": "2.0.1", - "resolved": "https://registry.npmjs.org/statuses/-/statuses-2.0.1.tgz", - "integrity": "sha512-RwNA9Z/7PrK06rYLIzFMlaF+l73iwpzsqRIFgbMLbTcLD6cOao82TaWefPXQvB2fOC4AjuYSEndS7N/mTCbkdQ==", + "license": "MIT", "engines": { "node": ">= 0.8" } }, - "node_modules/streamsearch": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/streamsearch/-/streamsearch-1.1.0.tgz", - "integrity": "sha512-Mcc5wHehp9aXz1ax6bZUyY5afg9u2rv5cqQI3mRrYkGC8rW2hM02jWuwjtL++LS5qinSyhj2QfLyNsuc+VsExg==", - "engines": { - "node": ">=10.0.0" - } - }, "node_modules/strict-uri-encode": { "version": "1.1.0", - "resolved": "https://registry.npmjs.org/strict-uri-encode/-/strict-uri-encode-1.1.0.tgz", - "integrity": "sha512-R3f198pcvnB+5IpnBlRkphuE9n46WyVl8I39W/ZUTZLz4nqSP/oLYUrcnJrw462Ds8he4YKMov2efsTIw1BDGQ==", + "license": "MIT", "engines": { "node": ">=0.10.0" } }, "node_modules/string_decoder": { "version": "1.3.0", - "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.3.0.tgz", - "integrity": "sha512-hkRX8U1WjJFd8LsDJ2yQ/wWWxaopEsABU1XfkM8A+j0+85JAGppt16cr1Whg6KIbb4okU6Mql6BOj+uup/wKeA==", + "license": "MIT", "dependencies": { "safe-buffer": "~5.2.0" } }, "node_modules/string-length": { "version": "4.0.2", - "resolved": "https://registry.npmjs.org/string-length/-/string-length-4.0.2.tgz", - "integrity": "sha512-+l6rNN5fYHNhZZy41RXsYptCjA2Igmq4EG7kZAYFQI1E1VTXarr6ZPXBg6eq7Y6eK4FEhY6AJlyuFIb/v/S0VQ==", "dev": true, + "license": "MIT", "dependencies": { "char-regex": "^1.0.2", "strip-ansi": "^6.0.0" @@ -9687,9 +8922,8 @@ }, "node_modules/string-width": { "version": "4.2.3", - "resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.3.tgz", - "integrity": "sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==", "dev": true, + "license": "MIT", "dependencies": { "emoji-regex": "^8.0.0", "is-fullwidth-code-point": "^3.0.0", @@ -9700,13 +8934,12 @@ } }, "node_modules/string.prototype.trim": { - "version": "1.2.7", - "resolved": "https://registry.npmjs.org/string.prototype.trim/-/string.prototype.trim-1.2.7.tgz", - "integrity": "sha512-p6TmeT1T3411M8Cgg9wBTMRtY2q9+PNy9EV1i2lIXUN/btt763oIfxwN3RR8VU6wHX8j/1CFy0L+YuThm6bgOg==", + "version": "1.2.8", + "license": "MIT", "dependencies": { "call-bind": "^1.0.2", - "define-properties": "^1.1.4", - "es-abstract": "^1.20.4" + "define-properties": "^1.2.0", + "es-abstract": "^1.22.1" }, "engines": { "node": ">= 0.4" @@ -9716,13 +8949,12 @@ } }, "node_modules/string.prototype.trimend": { - "version": "1.0.6", - "resolved": "https://registry.npmjs.org/string.prototype.trimend/-/string.prototype.trimend-1.0.6.tgz", - "integrity": "sha512-JySq+4mrPf9EsDBEDYMOb/lM7XQLulwg5R/m1r0PXEFqrV0qHvl58sdTilSXtKOflCsK2E8jxf+GKC0T07RWwQ==", + "version": "1.0.7", + "license": "MIT", "dependencies": { "call-bind": "^1.0.2", - "define-properties": "^1.1.4", - "es-abstract": "^1.20.4" + "define-properties": "^1.2.0", + "es-abstract": "^1.22.1" }, "funding": { "url": "https://github.com/sponsors/ljharb" @@ -9730,8 +8962,7 @@ }, "node_modules/string.prototype.trimstart": { "version": "1.0.7", - "resolved": "https://registry.npmjs.org/string.prototype.trimstart/-/string.prototype.trimstart-1.0.7.tgz", - "integrity": "sha512-NGhtDFu3jCEm7B4Fy0DpLewdJQOZcQ0rGbwQ/+stjnrp2i+rlKeCvos9hOIeCmqwratM47OBxY7uFZzjxHXmrg==", + "license": "MIT", "dependencies": { "call-bind": "^1.0.2", "define-properties": "^1.2.0", @@ -9743,9 +8974,8 @@ }, "node_modules/strip-ansi": { "version": "6.0.1", - "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.1.tgz", - "integrity": "sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==", "dev": true, + "license": "MIT", "dependencies": { "ansi-regex": "^5.0.1" }, @@ -9755,26 +8985,23 @@ }, "node_modules/strip-bom": { "version": "4.0.0", - "resolved": "https://registry.npmjs.org/strip-bom/-/strip-bom-4.0.0.tgz", - "integrity": "sha512-3xurFv5tEgii33Zi8Jtp55wEIILR9eh34FAW00PZf+JnSsTmV/ioewSgQl97JHvgjoRGwPShsWm+IdrxB35d0w==", "dev": true, + "license": "MIT", "engines": { "node": ">=8" } }, "node_modules/strip-final-newline": { "version": "2.0.0", - "resolved": "https://registry.npmjs.org/strip-final-newline/-/strip-final-newline-2.0.0.tgz", - "integrity": "sha512-BrpvfNAE3dcvq7ll3xVumzjKjZQ5tI1sEUIKr3Uoks0XUl45St3FlatVqef9prk4jRDzhW6WZg+3bk93y6pLjA==", "dev": true, + "license": "MIT", "engines": { "node": ">=6" } }, "node_modules/strip-hex-prefix": { "version": "1.0.0", - "resolved": "https://registry.npmjs.org/strip-hex-prefix/-/strip-hex-prefix-1.0.0.tgz", - "integrity": "sha512-q8d4ue7JGEiVcypji1bALTos+0pWtyGlivAWyPuTkHzuTCJqrK9sWxYQZUq6Nq3cuyv3bm734IhHvHtGGURU6A==", + "license": "MIT", "dependencies": { "is-hex-prefixed": "1.0.0" }, @@ -9785,9 +9012,8 @@ }, "node_modules/strip-json-comments": { "version": "3.1.1", - "resolved": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-3.1.1.tgz", - "integrity": "sha512-6fPc+R4ihwqP6N/aIv2f1gMH8lOVtWQHoqC4yK6oSDVVocumAsfCqjkXnqiYMhmMwS/mEHLp7Vehlt3ql6lEig==", "dev": true, + "license": "MIT", "engines": { "node": ">=8" }, @@ -9797,9 +9023,8 @@ }, "node_modules/supports-color": { "version": "7.2.0", - "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", - "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==", "dev": true, + "license": "MIT", "dependencies": { "has-flag": "^4.0.0" }, @@ -9809,9 +9034,8 @@ }, "node_modules/supports-hyperlinks": { "version": "2.3.0", - "resolved": "https://registry.npmjs.org/supports-hyperlinks/-/supports-hyperlinks-2.3.0.tgz", - "integrity": "sha512-RpsAZlpWcDwOPQA22aCH4J0t7L8JmAvsCxfOSEwm7cQs3LshN36QaTkwd70DnBOXDWGssw2eUoc8CaRWT0XunA==", "dev": true, + "license": "MIT", "dependencies": { "has-flag": "^4.0.0", "supports-color": "^7.0.0" @@ -9822,9 +9046,8 @@ }, "node_modules/supports-preserve-symlinks-flag": { "version": "1.0.0", - "resolved": "https://registry.npmjs.org/supports-preserve-symlinks-flag/-/supports-preserve-symlinks-flag-1.0.0.tgz", - "integrity": "sha512-ot0WnXS9fgdkgIcePe6RHNk1WA8+muPa6cSjeR3V8K27q9BB1rTE3R1p7Hv0z1ZyAc8s6Vvv8DIyWf681MAt0w==", "dev": true, + "license": "MIT", "engines": { "node": ">= 0.4" }, @@ -9834,8 +9057,7 @@ }, "node_modules/swarm-js": { "version": "0.1.42", - "resolved": "https://registry.npmjs.org/swarm-js/-/swarm-js-0.1.42.tgz", - "integrity": "sha512-BV7c/dVlA3R6ya1lMlSSNPLYrntt0LUq4YMgy3iwpCIc6rZnS5W2wUoctarZ5pXlpKtxDDf9hNziEkcfrxdhqQ==", + "license": "MIT", "dependencies": { "bluebird": "^3.5.0", "buffer": "^5.0.5", @@ -9852,8 +9074,7 @@ }, "node_modules/swarm-js/node_modules/@szmarczak/http-timer": { "version": "4.0.6", - "resolved": "https://registry.npmjs.org/@szmarczak/http-timer/-/http-timer-4.0.6.tgz", - "integrity": "sha512-4BAffykYOgO+5nzBWYwE3W90sBgLJoUPRWWcL8wlyiM8IB8ipJz3UMJ9KXQd1RKQXpKp8Tutn80HZtWsu2u76w==", + "license": "MIT", "dependencies": { "defer-to-connect": "^2.0.0" }, @@ -9863,16 +9084,14 @@ }, "node_modules/swarm-js/node_modules/cacheable-lookup": { "version": "5.0.4", - "resolved": "https://registry.npmjs.org/cacheable-lookup/-/cacheable-lookup-5.0.4.tgz", - "integrity": "sha512-2/kNscPhpcxrOigMZzbiWF7dz8ilhb/nIHU3EyZiXWXpeq/au8qJ8VhdftMkty3n7Gj6HIGalQG8oiBNB3AJgA==", + "license": "MIT", "engines": { "node": ">=10.6.0" } }, "node_modules/swarm-js/node_modules/got": { "version": "11.8.6", - "resolved": "https://registry.npmjs.org/got/-/got-11.8.6.tgz", - "integrity": "sha512-6tfZ91bOr7bOXnK7PRDCGBLa1H4U080YHNaAQ2KsMGlLEzRbk44nsZF2E1IeRc3vtJHPVbKCYgdFbaGO2ljd8g==", + "license": "MIT", "dependencies": { "@sindresorhus/is": "^4.0.0", "@szmarczak/http-timer": "^4.0.5", @@ -9895,8 +9114,7 @@ }, "node_modules/swarm-js/node_modules/http2-wrapper": { "version": "1.0.3", - "resolved": "https://registry.npmjs.org/http2-wrapper/-/http2-wrapper-1.0.3.tgz", - "integrity": "sha512-V+23sDMr12Wnz7iTcDeJr3O6AIxlnvT/bmaAAAP/Xda35C90p9599p0F1eHR/N1KILWSoWVAiOMFjBBXaXSMxg==", + "license": "MIT", "dependencies": { "quick-lru": "^5.1.1", "resolve-alpn": "^1.0.0" @@ -9907,33 +9125,29 @@ }, "node_modules/swarm-js/node_modules/lowercase-keys": { "version": "2.0.0", - "resolved": "https://registry.npmjs.org/lowercase-keys/-/lowercase-keys-2.0.0.tgz", - "integrity": "sha512-tqNXrS78oMOE73NMxK4EMLQsQowWf8jKooH9g7xPavRT706R6bkQJ6DY2Te7QukaZsulxa30wQ7bk0pm4XiHmA==", + "license": "MIT", "engines": { "node": ">=8" } }, "node_modules/swarm-js/node_modules/p-cancelable": { "version": "2.1.1", - "resolved": "https://registry.npmjs.org/p-cancelable/-/p-cancelable-2.1.1.tgz", - "integrity": "sha512-BZOr3nRQHOntUjTrH8+Lh54smKHoHyur8We1V8DSMVrl5A2malOOwuJRnKRDjSnkoeBh4at6BwEnb5I7Jl31wg==", + "license": "MIT", "engines": { "node": ">=8" } }, "node_modules/symbol-observable": { "version": "2.0.3", - "resolved": "https://registry.npmjs.org/symbol-observable/-/symbol-observable-2.0.3.tgz", - "integrity": "sha512-sQV7phh2WCYAn81oAkakC5qjq2Ml0g8ozqz03wOGnx9dDlG1de6yrF+0RAzSJD8fPUow3PTSMf2SAbOGxb93BA==", + "license": "MIT", "engines": { "node": ">=0.10" } }, "node_modules/table": { "version": "6.8.1", - "resolved": "https://registry.npmjs.org/table/-/table-6.8.1.tgz", - "integrity": "sha512-Y4X9zqrCftUhMeH2EptSSERdVKt/nEdijTOacGD/97EKjhQ/Qs8RTlEGABSJNNN8lac9kheH+af7yAkEWlgneA==", "dev": true, + "license": "BSD-3-Clause", "dependencies": { "ajv": "^8.0.1", "lodash.truncate": "^4.4.2", @@ -9947,9 +9161,8 @@ }, "node_modules/table/node_modules/ajv": { "version": "8.12.0", - "resolved": "https://registry.npmjs.org/ajv/-/ajv-8.12.0.tgz", - "integrity": "sha512-sRu1kpcO9yLtYxBKvqfTeh9KzZEwO3STyX1HT+4CaDzC6HpTGYhIhPIzj9XuKU7KYDwnaeh5hcOwjy1QuJzBPA==", "dev": true, + "license": "MIT", "dependencies": { "fast-deep-equal": "^3.1.1", "json-schema-traverse": "^1.0.0", @@ -9963,14 +9176,12 @@ }, "node_modules/table/node_modules/json-schema-traverse": { "version": "1.0.0", - "resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-1.0.0.tgz", - "integrity": "sha512-NM8/P9n3XjXhIZn1lLhkFaACTOURQXjWhV4BA/RnOv8xvgqtqpAX9IO4mRQxSx1Rlo4tqzeqb0sOlruaOy3dug==", - "dev": true + "dev": true, + "license": "MIT" }, "node_modules/tar": { "version": "4.4.19", - "resolved": "https://registry.npmjs.org/tar/-/tar-4.4.19.tgz", - "integrity": "sha512-a20gEsvHnWe0ygBY8JbxoM4w3SJdhc7ZAuxkLqh+nvNQN2IOt0B5lLgM490X5Hl8FF0dl0tOf2ewFYAlIFgzVA==", + "license": "ISC", "dependencies": { "chownr": "^1.1.4", "fs-minipass": "^1.2.7", @@ -9986,8 +9197,7 @@ }, "node_modules/tar/node_modules/mkdirp": { "version": "0.5.6", - "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.6.tgz", - "integrity": "sha512-FP+p8RB8OWpF3YZBCrP5gtADmtXApB5AMLn+vdyA+PyxCjrCs00mjyUozssO33cwDeT3wNGdLxJ5M//YqtHAJw==", + "license": "MIT", "dependencies": { "minimist": "^1.2.6" }, @@ -9997,9 +9207,8 @@ }, "node_modules/terminal-link": { "version": "2.1.1", - "resolved": "https://registry.npmjs.org/terminal-link/-/terminal-link-2.1.1.tgz", - "integrity": "sha512-un0FmiRUQNr5PJqy9kP7c40F5BOfpGlYTrxonDChEZB7pzZxRNp/bt+ymiy9/npwXya9KH99nJ/GXFIiUkYGFQ==", "dev": true, + "license": "MIT", "dependencies": { "ansi-escapes": "^4.2.1", "supports-hyperlinks": "^2.0.0" @@ -10013,9 +9222,8 @@ }, "node_modules/test-exclude": { "version": "6.0.0", - "resolved": "https://registry.npmjs.org/test-exclude/-/test-exclude-6.0.0.tgz", - "integrity": "sha512-cAGWPIyOHU6zlmg88jwm7VRyXnMN7iV68OGAbYDk/Mh/xC/pzVPlQtY6ngoIH/5/tciuhGfvESU8GrHrcxD56w==", "dev": true, + "license": "ISC", "dependencies": { "@istanbuljs/schema": "^0.1.2", "glob": "^7.1.4", @@ -10027,38 +9235,33 @@ }, "node_modules/text-table": { "version": "0.2.0", - "resolved": "https://registry.npmjs.org/text-table/-/text-table-0.2.0.tgz", - "integrity": "sha512-N+8UisAXDGk8PFXP4HAzVR9nbfmVJ3zYLAWiTIoqC5v5isinhr+r5uaO8+7r3BMfuNIufIsA7RdpVgacC2cSpw==", - "dev": true + "dev": true, + "license": "MIT" }, "node_modules/timed-out": { "version": "4.0.1", - "resolved": "https://registry.npmjs.org/timed-out/-/timed-out-4.0.1.tgz", - "integrity": "sha512-G7r3AhovYtr5YKOWQkta8RKAPb+J9IsO4uVmzjl8AZwfhs8UcUwTiD6gcJYSgOtzyjvQKrKYn41syHbUWMkafA==", + "license": "MIT", "engines": { "node": ">=0.10.0" } }, "node_modules/tmpl": { "version": "1.0.5", - "resolved": "https://registry.npmjs.org/tmpl/-/tmpl-1.0.5.tgz", - "integrity": "sha512-3f0uOEAQwIqGuWW2MVzYg8fV/QNnc/IpuJNG837rLuczAaLVHslWHZQj4IGiEl5Hs3kkbhwL9Ab7Hrsmuj+Smw==", - "dev": true + "dev": true, + "license": "BSD-3-Clause" }, "node_modules/to-fast-properties": { "version": "2.0.0", - "resolved": "https://registry.npmjs.org/to-fast-properties/-/to-fast-properties-2.0.0.tgz", - "integrity": "sha512-/OaKK0xYrs3DmxRYqL/yDc+FxFUVYhDlXMhRmv3z915w2HF1tnN1omB354j8VUGO/hbRzyD6Y3sA7v7GS/ceog==", "dev": true, + "license": "MIT", "engines": { "node": ">=4" } }, "node_modules/to-regex-range": { "version": "5.0.1", - "resolved": "https://registry.npmjs.org/to-regex-range/-/to-regex-range-5.0.1.tgz", - "integrity": "sha512-65P7iz6X5yEr1cwcgvQxbbIw7Uk3gOy5dIdtZ4rDveLqhrdJP+Li/Hx6tyK0NEb+2GCyneCMJiGqrADCSNk8sQ==", "dev": true, + "license": "MIT", "dependencies": { "is-number": "^7.0.0" }, @@ -10068,16 +9271,14 @@ }, "node_modules/toidentifier": { "version": "1.0.1", - "resolved": "https://registry.npmjs.org/toidentifier/-/toidentifier-1.0.1.tgz", - "integrity": "sha512-o5sSPKEkg/DIQNmH43V0/uerLrpzVedkUh8tGNvaeXpfpuwjKenlSox/2O/BTlZUtEe+JG7s5YhEz608PlAHRA==", + "license": "MIT", "engines": { "node": ">=0.6" } }, "node_modules/tough-cookie": { "version": "2.5.0", - "resolved": "https://registry.npmjs.org/tough-cookie/-/tough-cookie-2.5.0.tgz", - "integrity": "sha512-nlLsUzgm1kfLXSXfRZMc1KLAugd4hqJHDTvc2hDIwS3mZAfMEuMbc03SujMF+GEcpaX/qboeycw6iO8JwVv2+g==", + "license": "BSD-3-Clause", "dependencies": { "psl": "^1.1.28", "punycode": "^2.1.1" @@ -10088,14 +9289,12 @@ }, "node_modules/tr46": { "version": "0.0.3", - "resolved": "https://registry.npmjs.org/tr46/-/tr46-0.0.3.tgz", - "integrity": "sha512-N3WMsuqV66lT30CrXNbEjx4GEwlow3v6rr4mCcv6prnfwhS01rkgyFdjPNBYd9br7LpXV1+Emh01fHnq2Gdgrw==" + "license": "MIT" }, "node_modules/ts-jest": { "version": "28.0.8", - "resolved": "https://registry.npmjs.org/ts-jest/-/ts-jest-28.0.8.tgz", - "integrity": "sha512-5FaG0lXmRPzApix8oFG8RKjAz4ehtm8yMKOTy5HX3fY6W8kmvOrmcY0hKDElW52FJov+clhUbrKAqofnj4mXTg==", "dev": true, + "license": "MIT", "dependencies": { "bs-logger": "0.x", "fast-json-stable-stringify": "2.x", @@ -10136,18 +9335,16 @@ }, "node_modules/ts-jest/node_modules/yargs-parser": { "version": "21.1.1", - "resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-21.1.1.tgz", - "integrity": "sha512-tVpsJW7DdjecAiFpbIB1e3qxIQsE6NoPc5/eTdrbbIC4h0LVsWhnoa3g+m2HclBIujHzsxZ4VJVA+GUuc2/LBw==", "dev": true, + "license": "ISC", "engines": { "node": ">=12" } }, "node_modules/ts-node": { - "version": "10.9.1", - "resolved": "https://registry.npmjs.org/ts-node/-/ts-node-10.9.1.tgz", - "integrity": "sha512-NtVysVPkxxrwFGUUxGYhfux8k78pQB3JqYBXlLRZgdGUqTO5wU/UyHop5p70iEbGhB7q5KmiZiU0Y3KlJrScEw==", + "version": "10.9.2", "dev": true, + "license": "MIT", "dependencies": { "@cspotcode/source-map-support": "^0.8.0", "@tsconfig/node10": "^1.0.7", @@ -10187,10 +9384,9 @@ } }, "node_modules/ts-node/node_modules/acorn": { - "version": "8.10.0", - "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.10.0.tgz", - "integrity": "sha512-F0SAmZ8iUtS//m8DmCTA0jlh6TDKkHQyK6xc6V4KDTyZKA9dnvX9/3sRTVQrWm79glUAZbnmmNcdYwUIHWVybw==", + "version": "8.11.2", "dev": true, + "license": "MIT", "bin": { "acorn": "bin/acorn" }, @@ -10200,23 +9396,20 @@ }, "node_modules/ts-node/node_modules/diff": { "version": "4.0.2", - "resolved": "https://registry.npmjs.org/diff/-/diff-4.0.2.tgz", - "integrity": "sha512-58lmxKSA4BNyLz+HHMUzlOEpg09FV+ev6ZMe3vJihgdxzgcwZ8VoEEPmALCZG9LmqfVoNMMKpttIYTVG6uDY7A==", "dev": true, + "license": "BSD-3-Clause", "engines": { "node": ">=0.3.1" } }, "node_modules/tslib": { - "version": "2.4.0", - "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.4.0.tgz", - "integrity": "sha512-d6xOpEDfsi2CZVlPQzGeux8XMwLT9hssAsaPYExaQMuYskwb+x1x7J371tWlbBdWHroy99KnVB6qIkUbs5X3UQ==" + "version": "2.6.2", + "license": "0BSD" }, "node_modules/tsutils": { "version": "3.21.0", - "resolved": "https://registry.npmjs.org/tsutils/-/tsutils-3.21.0.tgz", - "integrity": "sha512-mHKK3iUXL+3UF6xL5k0PEhKRUBKPBCv/+RkEOpjRWxxx27KKRBmmA60A9pgOUvMi8GKhRMPEmjBRPzs2W7O1OA==", "dev": true, + "license": "MIT", "dependencies": { "tslib": "^1.8.1" }, @@ -10229,14 +9422,12 @@ }, "node_modules/tsutils/node_modules/tslib": { "version": "1.14.1", - "resolved": "https://registry.npmjs.org/tslib/-/tslib-1.14.1.tgz", - "integrity": "sha512-Xni35NKzjgMrwevysHTCArtLDpPvye8zV/0E4EyYn43P7/7qvQwPh9BGkHewbMulVntbigmcT7rdX3BNo9wRJg==", - "dev": true + "dev": true, + "license": "0BSD" }, "node_modules/tunnel-agent": { "version": "0.6.0", - "resolved": "https://registry.npmjs.org/tunnel-agent/-/tunnel-agent-0.6.0.tgz", - "integrity": "sha512-McnNiV1l8RYeY8tBgEpuodCC1mLUdbSN+CYBL7kJsJNInOP8UjDDEwdk6Mw60vdLLrr5NHKZhMAOSrR2NZuQ+w==", + "license": "Apache-2.0", "dependencies": { "safe-buffer": "^5.0.1" }, @@ -10246,24 +9437,20 @@ }, "node_modules/tweetnacl": { "version": "1.0.3", - "resolved": "https://registry.npmjs.org/tweetnacl/-/tweetnacl-1.0.3.tgz", - "integrity": "sha512-6rt+RN7aOi1nGMyC4Xa5DdYiukl2UWCbcJft7YhxReBGQD7OAM8Pbxw6YMo4r2diNEA8FEmu32YOn9rhaiE5yw==" + "license": "Unlicense" }, "node_modules/tweetnacl-util": { "version": "0.15.1", - "resolved": "https://registry.npmjs.org/tweetnacl-util/-/tweetnacl-util-0.15.1.tgz", - "integrity": "sha512-RKJBIj8lySrShN4w6i/BonWp2Z/uxwC3h4y7xsRrpP59ZboCd0GpEVsOnMDYLMmKBpYhb5TgHzZXy7wTfYFBRw==" + "license": "Unlicense" }, "node_modules/type": { "version": "1.2.0", - "resolved": "https://registry.npmjs.org/type/-/type-1.2.0.tgz", - "integrity": "sha512-+5nt5AAniqsCnu2cEQQdpzCAh33kVx8n0VoFidKpB1dVVLAN/F+bgVOqOJqOnEnrhp222clB5p3vUlD+1QAnfg==" + "license": "ISC" }, "node_modules/type-check": { "version": "0.4.0", - "resolved": "https://registry.npmjs.org/type-check/-/type-check-0.4.0.tgz", - "integrity": "sha512-XleUoc9uwGXqjWwXaUTZAmzMcFZ5858QA2vvx1Ur5xIcixXIP+8LnFDgRplU30us6teqdlskFfu+ae4K79Ooew==", "dev": true, + "license": "MIT", "dependencies": { "prelude-ls": "^1.2.1" }, @@ -10273,17 +9460,15 @@ }, "node_modules/type-detect": { "version": "4.0.8", - "resolved": "https://registry.npmjs.org/type-detect/-/type-detect-4.0.8.tgz", - "integrity": "sha512-0fr/mIH1dlO+x7TlcMy+bIDqKPsw/70tVyeHW787goQjhmqaZe10uwLujubK9q9Lg6Fiho1KUKDYz0Z7k7g5/g==", "dev": true, + "license": "MIT", "engines": { "node": ">=4" } }, "node_modules/type-fest": { "version": "0.20.2", - "resolved": "https://registry.npmjs.org/type-fest/-/type-fest-0.20.2.tgz", - "integrity": "sha512-Ne+eE4r0/iWnpAxD852z3A+N0Bt5RN//NjJwRd2VFHEmrywxf5vsZlh4R6lixl6B+wz/8d+maTSAkN1FIkI3LQ==", + "license": "(MIT OR CC0-1.0)", "engines": { "node": ">=10" }, @@ -10293,8 +9478,7 @@ }, "node_modules/type-is": { "version": "1.6.18", - "resolved": "https://registry.npmjs.org/type-is/-/type-is-1.6.18.tgz", - "integrity": "sha512-TkRKr9sUTxEH8MdfuCSP7VizJyzRNMjj2J2do2Jr3Kym598JVdEksuzPQCnlFPW4ky9Q+iA+ma9BGm06XQBy8g==", + "license": "MIT", "dependencies": { "media-typer": "0.3.0", "mime-types": "~2.1.24" @@ -10305,8 +9489,7 @@ }, "node_modules/typed-array-buffer": { "version": "1.0.0", - "resolved": "https://registry.npmjs.org/typed-array-buffer/-/typed-array-buffer-1.0.0.tgz", - "integrity": "sha512-Y8KTSIglk9OZEr8zywiIHG/kmQ7KWyjseXs1CbSo8vC42w7hg2HgYTxSWwP0+is7bWDc1H+Fo026CpHFwm8tkw==", + "license": "MIT", "dependencies": { "call-bind": "^1.0.2", "get-intrinsic": "^1.2.1", @@ -10318,8 +9501,7 @@ }, "node_modules/typed-array-byte-length": { "version": "1.0.0", - "resolved": "https://registry.npmjs.org/typed-array-byte-length/-/typed-array-byte-length-1.0.0.tgz", - "integrity": "sha512-Or/+kvLxNpeQ9DtSydonMxCx+9ZXOswtwJn17SNLvhptaXYDJvkFFP5zbfU/uLmvnBJlI4yrnXRxpdWH/M5tNA==", + "license": "MIT", "dependencies": { "call-bind": "^1.0.2", "for-each": "^0.3.3", @@ -10335,8 +9517,7 @@ }, "node_modules/typed-array-byte-offset": { "version": "1.0.0", - "resolved": "https://registry.npmjs.org/typed-array-byte-offset/-/typed-array-byte-offset-1.0.0.tgz", - "integrity": "sha512-RD97prjEt9EL8YgAgpOkf3O4IF9lhJFr9g0htQkm0rchFp/Vx7LW5Q8fSXXub7BXAODyUQohRMyOc3faCPd0hg==", + "license": "MIT", "dependencies": { "available-typed-arrays": "^1.0.5", "call-bind": "^1.0.2", @@ -10353,8 +9534,7 @@ }, "node_modules/typed-array-length": { "version": "1.0.4", - "resolved": "https://registry.npmjs.org/typed-array-length/-/typed-array-length-1.0.4.tgz", - "integrity": "sha512-KjZypGq+I/H7HI5HlOoGHkWUUGq+Q0TPhQurLbyrVrvnKTBgzLhIJ7j6J/XTQOi0d1RjyZ0wdas8bKs2p0x3Ng==", + "license": "MIT", "dependencies": { "call-bind": "^1.0.2", "for-each": "^0.3.3", @@ -10366,17 +9546,15 @@ }, "node_modules/typedarray-to-buffer": { "version": "3.1.5", - "resolved": "https://registry.npmjs.org/typedarray-to-buffer/-/typedarray-to-buffer-3.1.5.tgz", - "integrity": "sha512-zdu8XMNEDepKKR+XYOXAVPtWui0ly0NtohUscw+UmaHiAWT8hrV1rr//H6V+0DvJ3OQ19S979M0laLfX8rm82Q==", + "license": "MIT", "dependencies": { "is-typedarray": "^1.0.0" } }, "node_modules/typescript": { "version": "4.9.5", - "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.9.5.tgz", - "integrity": "sha512-1FXk9E2Hm+QzZQ7z+McJiHL4NW1F2EzMu9Nq9i3zAaGqibafqYwCVU6WyWAuyQRRzOlxou8xZSyXLEN8oKj24g==", "dev": true, + "license": "Apache-2.0", "bin": { "tsc": "bin/tsc", "tsserver": "bin/tsserver" @@ -10387,13 +9565,11 @@ }, "node_modules/ultron": { "version": "1.1.1", - "resolved": "https://registry.npmjs.org/ultron/-/ultron-1.1.1.tgz", - "integrity": "sha512-UIEXBNeYmKptWH6z8ZnqTeS8fV74zG0/eRU9VGkpzz+LIJNs8W/zM/L+7ctCkRrgbNnnR0xxw4bKOr0cW0N0Og==" + "license": "MIT" }, "node_modules/unbox-primitive": { "version": "1.0.2", - "resolved": "https://registry.npmjs.org/unbox-primitive/-/unbox-primitive-1.0.2.tgz", - "integrity": "sha512-61pPlCD9h51VoreyJ0BReideM3MDKMKnh6+V9L08331ipq6Q8OFXZYiqP6n/tbHx4s5I9uRhcye6BrbkizkBDw==", + "license": "MIT", "dependencies": { "call-bind": "^1.0.2", "has-bigints": "^1.0.2", @@ -10405,11 +9581,10 @@ } }, "node_modules/undici": { - "version": "5.23.0", - "resolved": "https://registry.npmjs.org/undici/-/undici-5.23.0.tgz", - "integrity": "sha512-1D7w+fvRsqlQ9GscLBwcAJinqcZGHUKjbOmXdlE/v8BvEGXjeWAax+341q44EuTcHXXnfyKNbKRq4Lg7OzhMmg==", + "version": "5.28.2", + "license": "MIT", "dependencies": { - "busboy": "^1.6.0" + "@fastify/busboy": "^2.0.0" }, "engines": { "node": ">=14.0" @@ -10417,24 +9592,20 @@ }, "node_modules/universalify": { "version": "0.1.2", - "resolved": "https://registry.npmjs.org/universalify/-/universalify-0.1.2.tgz", - "integrity": "sha512-rBJeI5CXAlmy1pV+617WB9J63U6XcazHHF2f2dbJix4XzpUF0RS3Zbj0FGIOCAva5P/d/GBOYaACQ1w+0azUkg==", + "license": "MIT", "engines": { "node": ">= 4.0.0" } }, "node_modules/unpipe": { "version": "1.0.0", - "resolved": "https://registry.npmjs.org/unpipe/-/unpipe-1.0.0.tgz", - "integrity": "sha512-pjy2bYhSsufwWlKwPc+l3cN7+wuJlK6uz0YdJEOlQDbl6jo/YlPi4mb8agUkVC8BF7V8NuzeyPNqRksA3hztKQ==", + "license": "MIT", "engines": { "node": ">= 0.8" } }, "node_modules/update-browserslist-db": { - "version": "1.0.11", - "resolved": "https://registry.npmjs.org/update-browserslist-db/-/update-browserslist-db-1.0.11.tgz", - "integrity": "sha512-dCwEFf0/oT85M1fHBg4F0jtLwJrutGoHSQXCh7u4o2t1drG+c0a9Flnqww6XUKSfQMPpJBRjU8d4RXB09qtvaA==", + "version": "1.0.13", "dev": true, "funding": [ { @@ -10450,6 +9621,7 @@ "url": "https://github.com/sponsors/ai" } ], + "license": "MIT", "dependencies": { "escalade": "^3.1.1", "picocolors": "^1.0.0" @@ -10463,22 +9635,19 @@ }, "node_modules/uri-js": { "version": "4.4.1", - "resolved": "https://registry.npmjs.org/uri-js/-/uri-js-4.4.1.tgz", - "integrity": "sha512-7rKUyy33Q1yc98pQ1DAmLtwX109F7TIfWlW1Ydo8Wl1ii1SeHieeh0HHfPeL2fMXK6z0s8ecKs9frCuLJvndBg==", + "license": "BSD-2-Clause", "dependencies": { "punycode": "^2.1.0" } }, "node_modules/url-set-query": { "version": "1.0.0", - "resolved": "https://registry.npmjs.org/url-set-query/-/url-set-query-1.0.0.tgz", - "integrity": "sha512-3AChu4NiXquPfeckE5R5cGdiHCMWJx1dwCWOmWIL4KHAziJNOFIYJlpGFeKDvwLPHovZRCxK3cYlwzqI9Vp+Gg==" + "license": "MIT" }, "node_modules/utf-8-validate": { "version": "5.0.10", - "resolved": "https://registry.npmjs.org/utf-8-validate/-/utf-8-validate-5.0.10.tgz", - "integrity": "sha512-Z6czzLq4u8fPOyx7TU6X3dvUZVvoJmxSQ+IcrlmagKhilxlhZgxPK6C5Jqbkw1IDUmFTM+cz9QDnnLTwDz/2gQ==", "hasInstallScript": true, + "license": "MIT", "dependencies": { "node-gyp-build": "^4.3.0" }, @@ -10488,13 +9657,11 @@ }, "node_modules/utf8": { "version": "3.0.0", - "resolved": "https://registry.npmjs.org/utf8/-/utf8-3.0.0.tgz", - "integrity": "sha512-E8VjFIQ/TyQgp+TZfS6l8yp/xWppSAHzidGiRrqe4bK4XP9pTRyKFgGJpO3SN7zdX4DeomTrwaseCHovfpFcqQ==" + "license": "MIT" }, "node_modules/util": { "version": "0.12.5", - "resolved": "https://registry.npmjs.org/util/-/util-0.12.5.tgz", - "integrity": "sha512-kZf/K6hEIrWHI6XqOFUiiMa+79wE/D8Q+NCNAWclkyg3b4d2k7s0QGepNjiABc+aR3N1PAyHL7p6UcLY6LmrnA==", + "license": "MIT", "dependencies": { "inherits": "^2.0.3", "is-arguments": "^1.0.4", @@ -10505,60 +9672,57 @@ }, "node_modules/util-deprecate": { "version": "1.0.2", - "resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz", - "integrity": "sha512-EPD5q1uXyFxJpCrLnCc1nHnq3gOa6DZBocAIiI2TaSCA7VCJ1UJDMagCzIkXNsUYfD1daK//LTEQ8xiIbrHtcw==" + "license": "MIT" }, "node_modules/utils-merge": { "version": "1.0.1", - "resolved": "https://registry.npmjs.org/utils-merge/-/utils-merge-1.0.1.tgz", - "integrity": "sha512-pMZTvIkT1d+TFGvDOqodOclx0QWkkgi6Tdoa8gC8ffGAAqz9pzPTZWAybbsHHoED/ztMtkv/VoYTYyShUn81hA==", + "license": "MIT", "engines": { "node": ">= 0.4.0" } }, "node_modules/uuid": { "version": "8.3.2", - "resolved": "https://registry.npmjs.org/uuid/-/uuid-8.3.2.tgz", - "integrity": "sha512-+NYs2QeMWy+GWFOEm9xnn6HCDp0l7QBD7ml8zLUmJ+93Q5NF0NocErnwkTkXVFNiX3/fpC6afS8Dhb/gz7R7eg==", + "license": "MIT", "bin": { "uuid": "dist/bin/uuid" } }, "node_modules/v8-compile-cache": { "version": "2.4.0", - "resolved": "https://registry.npmjs.org/v8-compile-cache/-/v8-compile-cache-2.4.0.tgz", - "integrity": "sha512-ocyWc3bAHBB/guyqJQVI5o4BZkPhznPYUG2ea80Gond/BgNWpap8TOmLSeeQG7bnh2KMISxskdADG59j7zruhw==", - "dev": true + "dev": true, + "license": "MIT" }, "node_modules/v8-compile-cache-lib": { "version": "3.0.1", - "resolved": "https://registry.npmjs.org/v8-compile-cache-lib/-/v8-compile-cache-lib-3.0.1.tgz", - "integrity": "sha512-wa7YjyUGfNZngI/vtK0UHAN+lgDCxBPCylVXGp0zu59Fz5aiGtNXaq3DhIov063MorB+VfufLh3JlF2KdTK3xg==", - "dev": true + "dev": true, + "license": "MIT" }, "node_modules/v8-to-istanbul": { - "version": "9.1.0", - "resolved": "https://registry.npmjs.org/v8-to-istanbul/-/v8-to-istanbul-9.1.0.tgz", - "integrity": "sha512-6z3GW9x8G1gd+JIIgQQQxXuiJtCXeAjp6RaPEPLv62mH3iPHPxV6W3robxtCzNErRo6ZwTmzWhsbNvjyEBKzKA==", + "version": "9.2.0", "dev": true, + "license": "ISC", "dependencies": { "@jridgewell/trace-mapping": "^0.3.12", "@types/istanbul-lib-coverage": "^2.0.1", - "convert-source-map": "^1.6.0" + "convert-source-map": "^2.0.0" }, "engines": { "node": ">=10.12.0" } }, + "node_modules/v8-to-istanbul/node_modules/convert-source-map": { + "version": "2.0.0", + "dev": true, + "license": "MIT" + }, "node_modules/varint": { "version": "5.0.2", - "resolved": "https://registry.npmjs.org/varint/-/varint-5.0.2.tgz", - "integrity": "sha512-lKxKYG6H03yCZUpAGOPOsMcGxd1RHCu1iKvEHYDPmTyq2HueGhD73ssNBqqQWfvYs04G9iUFRvmAVLW20Jw6ow==" + "license": "MIT" }, "node_modules/vary": { "version": "1.1.2", - "resolved": "https://registry.npmjs.org/vary/-/vary-1.1.2.tgz", - "integrity": "sha512-BNGbWLfd0eUPabhkXUVm0j8uuvREyTh5ovRa/dyow/BqAbZJyC+5fU+IzQOzmAKzYqYRAISoRhdQr3eIZ/PXqg==", + "license": "MIT", "engines": { "node": ">= 0.8" } @@ -10579,8 +9743,7 @@ }, "node_modules/vc-js/node_modules/@digitalbazaar/http-client": { "version": "1.2.0", - "resolved": "https://registry.npmjs.org/@digitalbazaar/http-client/-/http-client-1.2.0.tgz", - "integrity": "sha512-W9KQQ5pUJcaR0I4c2HPJC0a7kRbZApIorZgPnEDwMBgj16iQzutGLrCXYaZOmxqVLVNqqlQ4aUJh+HBQZy4W6Q==", + "license": "BSD-3-Clause", "dependencies": { "esm": "^3.2.22", "ky": "^0.25.1", @@ -10592,8 +9755,7 @@ }, "node_modules/vc-js/node_modules/jsonld": { "version": "5.2.0", - "resolved": "https://registry.npmjs.org/jsonld/-/jsonld-5.2.0.tgz", - "integrity": "sha512-JymgT6Xzk5CHEmHuEyvoTNviEPxv6ihLWSPu1gFdtjSAyM6cFqNrv02yS/SIur3BBIkCf0HjizRc24d8/FfQKw==", + "license": "BSD-3-Clause", "dependencies": { "@digitalbazaar/http-client": "^1.1.0", "canonicalize": "^1.0.1", @@ -10606,8 +9768,7 @@ }, "node_modules/vc-js/node_modules/ky": { "version": "0.25.1", - "resolved": "https://registry.npmjs.org/ky/-/ky-0.25.1.tgz", - "integrity": "sha512-PjpCEWlIU7VpiMVrTwssahkYXX1by6NCT0fhTUX34F3DTinARlgMpriuroolugFPcMgpPWrOW4mTb984Qm1RXA==", + "license": "MIT", "engines": { "node": ">=10" }, @@ -10617,8 +9778,7 @@ }, "node_modules/vc-js/node_modules/ky-universal": { "version": "0.8.2", - "resolved": "https://registry.npmjs.org/ky-universal/-/ky-universal-0.8.2.tgz", - "integrity": "sha512-xe0JaOH9QeYxdyGLnzUOVGK4Z6FGvDVzcXFTdrYA1f33MZdEa45sUDaMBy98xQMcsd2XIBrTXRrRYnegcSdgVQ==", + "license": "MIT", "dependencies": { "abort-controller": "^3.0.0", "node-fetch": "3.0.0-beta.9" @@ -10641,8 +9801,7 @@ }, "node_modules/vc-js/node_modules/lru-cache": { "version": "6.0.0", - "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-6.0.0.tgz", - "integrity": "sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA==", + "license": "ISC", "dependencies": { "yallist": "^4.0.0" }, @@ -10652,8 +9811,7 @@ }, "node_modules/vc-js/node_modules/node-fetch": { "version": "3.0.0-beta.9", - "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-3.0.0-beta.9.tgz", - "integrity": "sha512-RdbZCEynH2tH46+tj0ua9caUHVWrd/RHnRfvly2EVdqGmI3ndS1Vn/xjm5KuGejDt2RNDQsVRLPNd2QPwcewVg==", + "license": "MIT", "dependencies": { "data-uri-to-buffer": "^3.0.1", "fetch-blob": "^2.1.1" @@ -10668,16 +9826,14 @@ }, "node_modules/vc-js/node_modules/yallist": { "version": "4.0.0", - "resolved": "https://registry.npmjs.org/yallist/-/yallist-4.0.0.tgz", - "integrity": "sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==" + "license": "ISC" }, "node_modules/verror": { "version": "1.10.0", - "resolved": "https://registry.npmjs.org/verror/-/verror-1.10.0.tgz", - "integrity": "sha512-ZZKSmDAEFOijERBLkmYfJ+vmk3w+7hOLYDNkRCuRuMJGEmqYNCNLyBBFwWKVMhfwaEF3WOd0Zlw86U/WC/+nYw==", "engines": [ "node >=0.6.0" ], + "license": "MIT", "dependencies": { "assert-plus": "^1.0.0", "core-util-is": "1.0.2", @@ -10686,44 +9842,40 @@ }, "node_modules/walker": { "version": "1.0.8", - "resolved": "https://registry.npmjs.org/walker/-/walker-1.0.8.tgz", - "integrity": "sha512-ts/8E8l5b7kY0vlWLewOkDXMmPdLcVV4GmOQLyxuSswIJsweeFZtAsMF7k1Nszz+TYBQrlYRmzOnr398y1JemQ==", "dev": true, + "license": "Apache-2.0", "dependencies": { "makeerror": "1.0.12" } }, "node_modules/web-streams-polyfill": { "version": "3.2.1", - "resolved": "https://registry.npmjs.org/web-streams-polyfill/-/web-streams-polyfill-3.2.1.tgz", - "integrity": "sha512-e0MO3wdXWKrLbL0DgGnUV7WHVuw9OUvL4hjgnPkIeEvESk74gAITi5G606JtZPp39cd8HA9VQzCIvA49LpPN5Q==", + "license": "MIT", "engines": { "node": ">= 8" } }, "node_modules/web3": { - "version": "1.10.2", - "resolved": "https://registry.npmjs.org/web3/-/web3-1.10.2.tgz", - "integrity": "sha512-DAtZ3a3ruPziE80uZ3Ob0YDZxt6Vk2un/F5BcBrxO70owJ9Z1Y2+loZmbh1MoAmoLGjA/SUSHeUtid3fYmBaog==", + "version": "1.10.3", "hasInstallScript": true, + "license": "LGPL-3.0", "dependencies": { - "web3-bzz": "1.10.2", - "web3-core": "1.10.2", - "web3-eth": "1.10.2", - "web3-eth-personal": "1.10.2", - "web3-net": "1.10.2", - "web3-shh": "1.10.2", - "web3-utils": "1.10.2" + "web3-bzz": "1.10.3", + "web3-core": "1.10.3", + "web3-eth": "1.10.3", + "web3-eth-personal": "1.10.3", + "web3-net": "1.10.3", + "web3-shh": "1.10.3", + "web3-utils": "1.10.3" }, "engines": { "node": ">=8.0.0" } }, "node_modules/web3-bzz": { - "version": "1.10.2", - "resolved": "https://registry.npmjs.org/web3-bzz/-/web3-bzz-1.10.2.tgz", - "integrity": "sha512-vLOfDCj6198Qc7esDrCKeFA/M3ZLbowsaHQ0hIL4NmIHoq7lU8aSRTa5AI+JBh8cKN1gVryJsuW2ZCc5bM4I4Q==", + "version": "1.10.3", "hasInstallScript": true, + "license": "LGPL-3.0", "dependencies": { "@types/node": "^12.12.6", "got": "12.1.0", @@ -10735,57 +9887,52 @@ }, "node_modules/web3-bzz/node_modules/@types/node": { "version": "12.20.55", - "resolved": "https://registry.npmjs.org/@types/node/-/node-12.20.55.tgz", - "integrity": "sha512-J8xLz7q2OFulZ2cyGTLE1TbbZcjpno7FaN6zdJNrgAdrJ+DZzh/uFR6YrTb4C+nXakvud8Q4+rbhoIWlYQbUFQ==" + "license": "MIT" }, "node_modules/web3-core": { - "version": "1.10.2", - "resolved": "https://registry.npmjs.org/web3-core/-/web3-core-1.10.2.tgz", - "integrity": "sha512-qTn2UmtE8tvwMRsC5pXVdHxrQ4uZ6jiLgF5DRUVtdi7dPUmX18Dp9uxKfIfhGcA011EAn8P6+X7r3pvi2YRxBw==", + "version": "1.10.3", + "license": "LGPL-3.0", "dependencies": { "@types/bn.js": "^5.1.1", "@types/node": "^12.12.6", "bignumber.js": "^9.0.0", - "web3-core-helpers": "1.10.2", - "web3-core-method": "1.10.2", - "web3-core-requestmanager": "1.10.2", - "web3-utils": "1.10.2" + "web3-core-helpers": "1.10.3", + "web3-core-method": "1.10.3", + "web3-core-requestmanager": "1.10.3", + "web3-utils": "1.10.3" }, "engines": { "node": ">=8.0.0" } }, "node_modules/web3-core-helpers": { - "version": "1.10.2", - "resolved": "https://registry.npmjs.org/web3-core-helpers/-/web3-core-helpers-1.10.2.tgz", - "integrity": "sha512-1JfaNtox6/ZYJHNoI+QVc2ObgwEPeGF+YdxHZQ7aF5605BmlwM1Bk3A8xv6mg64jIRvEq1xX6k9oG6x7p1WgXQ==", + "version": "1.10.3", + "license": "LGPL-3.0", "dependencies": { - "web3-eth-iban": "1.10.2", - "web3-utils": "1.10.2" + "web3-eth-iban": "1.10.3", + "web3-utils": "1.10.3" }, "engines": { "node": ">=8.0.0" } }, "node_modules/web3-core-method": { - "version": "1.10.2", - "resolved": "https://registry.npmjs.org/web3-core-method/-/web3-core-method-1.10.2.tgz", - "integrity": "sha512-gG6ES+LOuo01MJHML4gnEt702M8lcPGMYZoX8UjZzmEebGrPYOY9XccpCrsFgCeKgQzM12SVnlwwpMod1+lcLg==", + "version": "1.10.3", + "license": "LGPL-3.0", "dependencies": { "@ethersproject/transactions": "^5.6.2", - "web3-core-helpers": "1.10.2", - "web3-core-promievent": "1.10.2", - "web3-core-subscriptions": "1.10.2", - "web3-utils": "1.10.2" + "web3-core-helpers": "1.10.3", + "web3-core-promievent": "1.10.3", + "web3-core-subscriptions": "1.10.3", + "web3-utils": "1.10.3" }, "engines": { "node": ">=8.0.0" } }, "node_modules/web3-core-promievent": { - "version": "1.10.2", - "resolved": "https://registry.npmjs.org/web3-core-promievent/-/web3-core-promievent-1.10.2.tgz", - "integrity": "sha512-Qkkb1dCDOU8dZeORkcwJBQRAX+mdsjx8LqFBB+P4W9QgwMqyJ6LXda+y1XgyeEVeKEmY1RCeTq9Y94q1v62Sfw==", + "version": "1.10.3", + "license": "LGPL-3.0", "dependencies": { "eventemitter3": "4.0.4" }, @@ -10794,27 +9941,25 @@ } }, "node_modules/web3-core-requestmanager": { - "version": "1.10.2", - "resolved": "https://registry.npmjs.org/web3-core-requestmanager/-/web3-core-requestmanager-1.10.2.tgz", - "integrity": "sha512-nlLeNJUu6fR+ZbJr2k9Du/nN3VWwB4AJPY4r6nxUODAmykgJq57T21cLP/BEk6mbiFQYGE9TrrPhh4qWxQEtAw==", + "version": "1.10.3", + "license": "LGPL-3.0", "dependencies": { "util": "^0.12.5", - "web3-core-helpers": "1.10.2", - "web3-providers-http": "1.10.2", - "web3-providers-ipc": "1.10.2", - "web3-providers-ws": "1.10.2" + "web3-core-helpers": "1.10.3", + "web3-providers-http": "1.10.3", + "web3-providers-ipc": "1.10.3", + "web3-providers-ws": "1.10.3" }, "engines": { "node": ">=8.0.0" } }, "node_modules/web3-core-subscriptions": { - "version": "1.10.2", - "resolved": "https://registry.npmjs.org/web3-core-subscriptions/-/web3-core-subscriptions-1.10.2.tgz", - "integrity": "sha512-MiWcKjz4tco793EPPPLc/YOJmYUV3zAfxeQH/UVTfBejMfnNvmfwKa2SBKfPIvKQHz/xI5bV2TF15uvJEucU7w==", + "version": "1.10.3", + "license": "LGPL-3.0", "dependencies": { "eventemitter3": "4.0.4", - "web3-core-helpers": "1.10.2" + "web3-core-helpers": "1.10.3" }, "engines": { "node": ">=8.0.0" @@ -10822,58 +9967,54 @@ }, "node_modules/web3-core/node_modules/@types/node": { "version": "12.20.55", - "resolved": "https://registry.npmjs.org/@types/node/-/node-12.20.55.tgz", - "integrity": "sha512-J8xLz7q2OFulZ2cyGTLE1TbbZcjpno7FaN6zdJNrgAdrJ+DZzh/uFR6YrTb4C+nXakvud8Q4+rbhoIWlYQbUFQ==" + "license": "MIT" }, "node_modules/web3-eth": { - "version": "1.10.2", - "resolved": "https://registry.npmjs.org/web3-eth/-/web3-eth-1.10.2.tgz", - "integrity": "sha512-s38rhrntyhGShmXC4R/aQtfkpcmev9c7iZwgb9CDIBFo7K8nrEJvqIOyajeZTxnDIiGzTJmrHxiKSadii5qTRg==", - "dependencies": { - "web3-core": "1.10.2", - "web3-core-helpers": "1.10.2", - "web3-core-method": "1.10.2", - "web3-core-subscriptions": "1.10.2", - "web3-eth-abi": "1.10.2", - "web3-eth-accounts": "1.10.2", - "web3-eth-contract": "1.10.2", - "web3-eth-ens": "1.10.2", - "web3-eth-iban": "1.10.2", - "web3-eth-personal": "1.10.2", - "web3-net": "1.10.2", - "web3-utils": "1.10.2" + "version": "1.10.3", + "license": "LGPL-3.0", + "dependencies": { + "web3-core": "1.10.3", + "web3-core-helpers": "1.10.3", + "web3-core-method": "1.10.3", + "web3-core-subscriptions": "1.10.3", + "web3-eth-abi": "1.10.3", + "web3-eth-accounts": "1.10.3", + "web3-eth-contract": "1.10.3", + "web3-eth-ens": "1.10.3", + "web3-eth-iban": "1.10.3", + "web3-eth-personal": "1.10.3", + "web3-net": "1.10.3", + "web3-utils": "1.10.3" }, "engines": { "node": ">=8.0.0" } }, "node_modules/web3-eth-abi": { - "version": "1.10.2", - "resolved": "https://registry.npmjs.org/web3-eth-abi/-/web3-eth-abi-1.10.2.tgz", - "integrity": "sha512-pY4fQUio7W7ZRSLf+vsYkaxJqaT/jHcALZjIxy+uBQaYAJ3t6zpQqMZkJB3Dw7HUODRJ1yI0NPEFGTnkYf/17A==", + "version": "1.10.3", + "license": "LGPL-3.0", "dependencies": { "@ethersproject/abi": "^5.6.3", - "web3-utils": "1.10.2" + "web3-utils": "1.10.3" }, "engines": { "node": ">=8.0.0" } }, "node_modules/web3-eth-accounts": { - "version": "1.10.2", - "resolved": "https://registry.npmjs.org/web3-eth-accounts/-/web3-eth-accounts-1.10.2.tgz", - "integrity": "sha512-6/HhCBYAXN/f553/SyxS9gY62NbLgpD1zJpENcvRTDpJN3Znvli1cmpl5Q3ZIUJkvHnG//48EWfWh0cbb3fbKQ==", + "version": "1.10.3", + "license": "LGPL-3.0", "dependencies": { - "@ethereumjs/common": "2.5.0", - "@ethereumjs/tx": "3.3.2", + "@ethereumjs/common": "2.6.5", + "@ethereumjs/tx": "3.5.2", "@ethereumjs/util": "^8.1.0", "eth-lib": "0.2.8", "scrypt-js": "^3.0.1", "uuid": "^9.0.0", - "web3-core": "1.10.2", - "web3-core-helpers": "1.10.2", - "web3-core-method": "1.10.2", - "web3-utils": "1.10.2" + "web3-core": "1.10.3", + "web3-core-helpers": "1.10.3", + "web3-core-method": "1.10.3", + "web3-utils": "1.10.3" }, "engines": { "node": ">=8.0.0" @@ -10881,13 +10022,11 @@ }, "node_modules/web3-eth-accounts/node_modules/bn.js": { "version": "4.12.0", - "resolved": "https://registry.npmjs.org/bn.js/-/bn.js-4.12.0.tgz", - "integrity": "sha512-c98Bf3tPniI+scsdk237ku1Dc3ujXQTSgyiPUDEOe7tRkhrqridvh8klBv0HCEso1OLOYcHuCv/cS6DNxKH+ZA==" + "license": "MIT" }, "node_modules/web3-eth-accounts/node_modules/eth-lib": { "version": "0.2.8", - "resolved": "https://registry.npmjs.org/eth-lib/-/eth-lib-0.2.8.tgz", - "integrity": "sha512-ArJ7x1WcWOlSpzdoTBX8vkwlkSQ85CjjifSZtV4co64vWxSV8geWfPI9x4SVYu3DSxnX4yWFVTtGL+j9DUFLNw==", + "license": "MIT", "dependencies": { "bn.js": "^4.11.6", "elliptic": "^6.4.0", @@ -10895,72 +10034,71 @@ } }, "node_modules/web3-eth-accounts/node_modules/uuid": { - "version": "9.0.0", - "resolved": "https://registry.npmjs.org/uuid/-/uuid-9.0.0.tgz", - "integrity": "sha512-MXcSTerfPa4uqyzStbRoTgt5XIe3x5+42+q1sDuy3R5MDk66URdLMOZe5aPX/SQd+kuYAh0FdP/pO28IkQyTeg==", + "version": "9.0.1", + "funding": [ + "https://github.com/sponsors/broofa", + "https://github.com/sponsors/ctavan" + ], + "license": "MIT", "bin": { "uuid": "dist/bin/uuid" } }, "node_modules/web3-eth-contract": { - "version": "1.10.2", - "resolved": "https://registry.npmjs.org/web3-eth-contract/-/web3-eth-contract-1.10.2.tgz", - "integrity": "sha512-CZLKPQRmupP/+OZ5A/CBwWWkBiz5B/foOpARz0upMh1yjb0dEud4YzRW2gJaeNu0eGxDLsWVaXhUimJVGYprQw==", + "version": "1.10.3", + "license": "LGPL-3.0", "dependencies": { "@types/bn.js": "^5.1.1", - "web3-core": "1.10.2", - "web3-core-helpers": "1.10.2", - "web3-core-method": "1.10.2", - "web3-core-promievent": "1.10.2", - "web3-core-subscriptions": "1.10.2", - "web3-eth-abi": "1.10.2", - "web3-utils": "1.10.2" + "web3-core": "1.10.3", + "web3-core-helpers": "1.10.3", + "web3-core-method": "1.10.3", + "web3-core-promievent": "1.10.3", + "web3-core-subscriptions": "1.10.3", + "web3-eth-abi": "1.10.3", + "web3-utils": "1.10.3" }, "engines": { "node": ">=8.0.0" } }, "node_modules/web3-eth-ens": { - "version": "1.10.2", - "resolved": "https://registry.npmjs.org/web3-eth-ens/-/web3-eth-ens-1.10.2.tgz", - "integrity": "sha512-kTQ42UdNHy4BQJHgWe97bHNMkc3zCMBKKY7t636XOMxdI/lkRdIjdE5nQzt97VjQvSVasgIWYKRAtd8aRaiZiQ==", + "version": "1.10.3", + "license": "LGPL-3.0", "dependencies": { "content-hash": "^2.5.2", "eth-ens-namehash": "2.0.8", - "web3-core": "1.10.2", - "web3-core-helpers": "1.10.2", - "web3-core-promievent": "1.10.2", - "web3-eth-abi": "1.10.2", - "web3-eth-contract": "1.10.2", - "web3-utils": "1.10.2" + "web3-core": "1.10.3", + "web3-core-helpers": "1.10.3", + "web3-core-promievent": "1.10.3", + "web3-eth-abi": "1.10.3", + "web3-eth-contract": "1.10.3", + "web3-utils": "1.10.3" }, "engines": { "node": ">=8.0.0" } }, "node_modules/web3-eth-iban": { - "version": "1.10.2", - "resolved": "https://registry.npmjs.org/web3-eth-iban/-/web3-eth-iban-1.10.2.tgz", - "integrity": "sha512-y8+Ii2XXdyHQMFNL2NWpBnXe+TVJ4ryvPlzNhObRRnIo4O4nLIXS010olLDMayozDzoUlmzCmBZJYc9Eev1g7A==", + "version": "1.10.3", + "license": "LGPL-3.0", "dependencies": { "bn.js": "^5.2.1", - "web3-utils": "1.10.2" + "web3-utils": "1.10.3" }, "engines": { "node": ">=8.0.0" } }, "node_modules/web3-eth-personal": { - "version": "1.10.2", - "resolved": "https://registry.npmjs.org/web3-eth-personal/-/web3-eth-personal-1.10.2.tgz", - "integrity": "sha512-+vEbJsPUJc5J683y0c2aN645vXC+gPVlFVCQu4IjPvXzJrAtUfz26+IZ6AUOth4fDJPT0f1uSLS5W2yrUdw9BQ==", + "version": "1.10.3", + "license": "LGPL-3.0", "dependencies": { "@types/node": "^12.12.6", - "web3-core": "1.10.2", - "web3-core-helpers": "1.10.2", - "web3-core-method": "1.10.2", - "web3-net": "1.10.2", - "web3-utils": "1.10.2" + "web3-core": "1.10.3", + "web3-core-helpers": "1.10.3", + "web3-core-method": "1.10.3", + "web3-net": "1.10.3", + "web3-utils": "1.10.3" }, "engines": { "node": ">=8.0.0" @@ -10968,55 +10106,50 @@ }, "node_modules/web3-eth-personal/node_modules/@types/node": { "version": "12.20.55", - "resolved": "https://registry.npmjs.org/@types/node/-/node-12.20.55.tgz", - "integrity": "sha512-J8xLz7q2OFulZ2cyGTLE1TbbZcjpno7FaN6zdJNrgAdrJ+DZzh/uFR6YrTb4C+nXakvud8Q4+rbhoIWlYQbUFQ==" + "license": "MIT" }, "node_modules/web3-net": { - "version": "1.10.2", - "resolved": "https://registry.npmjs.org/web3-net/-/web3-net-1.10.2.tgz", - "integrity": "sha512-w9i1t2z7dItagfskhaCKwpp6W3ylUR88gs68u820y5f8yfK5EbPmHc6c2lD8X9ZrTnmDoeOpIRCN/RFPtZCp+g==", + "version": "1.10.3", + "license": "LGPL-3.0", "dependencies": { - "web3-core": "1.10.2", - "web3-core-method": "1.10.2", - "web3-utils": "1.10.2" + "web3-core": "1.10.3", + "web3-core-method": "1.10.3", + "web3-utils": "1.10.3" }, "engines": { "node": ">=8.0.0" } }, "node_modules/web3-providers-http": { - "version": "1.10.2", - "resolved": "https://registry.npmjs.org/web3-providers-http/-/web3-providers-http-1.10.2.tgz", - "integrity": "sha512-G8abKtpkyKGpRVKvfjIF3I4O/epHP7mxXWN8mNMQLkQj1cjMFiZBZ13f+qI77lNJN7QOf6+LtNdKrhsTGU72TA==", + "version": "1.10.3", + "license": "LGPL-3.0", "dependencies": { "abortcontroller-polyfill": "^1.7.5", "cross-fetch": "^4.0.0", "es6-promise": "^4.2.8", - "web3-core-helpers": "1.10.2" + "web3-core-helpers": "1.10.3" }, "engines": { "node": ">=8.0.0" } }, "node_modules/web3-providers-ipc": { - "version": "1.10.2", - "resolved": "https://registry.npmjs.org/web3-providers-ipc/-/web3-providers-ipc-1.10.2.tgz", - "integrity": "sha512-lWbn6c+SgvhLymU8u4Ea/WOVC0Gqs7OJUvauejWz+iLycxeF0xFNyXnHVAi42ZJDPVI3vnfZotafoxcNNL7Sug==", + "version": "1.10.3", + "license": "LGPL-3.0", "dependencies": { "oboe": "2.1.5", - "web3-core-helpers": "1.10.2" + "web3-core-helpers": "1.10.3" }, "engines": { "node": ">=8.0.0" } }, "node_modules/web3-providers-ws": { - "version": "1.10.2", - "resolved": "https://registry.npmjs.org/web3-providers-ws/-/web3-providers-ws-1.10.2.tgz", - "integrity": "sha512-3nYSiP6grI5GvpkSoehctSywfCTodU21VY8bUtXyFHK/IVfDooNtMpd5lVIMvXVAlaxwwrCfjebokaJtKH2Iag==", + "version": "1.10.3", + "license": "LGPL-3.0", "dependencies": { "eventemitter3": "4.0.4", - "web3-core-helpers": "1.10.2", + "web3-core-helpers": "1.10.3", "websocket": "^1.0.32" }, "engines": { @@ -11024,24 +10157,22 @@ } }, "node_modules/web3-shh": { - "version": "1.10.2", - "resolved": "https://registry.npmjs.org/web3-shh/-/web3-shh-1.10.2.tgz", - "integrity": "sha512-UP0Kc3pHv9uULFu0+LOVfPwKBSJ6B+sJ5KflF7NyBk6TvNRxlpF3hUhuaVDCjjB/dDUR6T0EQeg25FA2uzJbag==", + "version": "1.10.3", "hasInstallScript": true, + "license": "LGPL-3.0", "dependencies": { - "web3-core": "1.10.2", - "web3-core-method": "1.10.2", - "web3-core-subscriptions": "1.10.2", - "web3-net": "1.10.2" + "web3-core": "1.10.3", + "web3-core-method": "1.10.3", + "web3-core-subscriptions": "1.10.3", + "web3-net": "1.10.3" }, "engines": { "node": ">=8.0.0" } }, "node_modules/web3-utils": { - "version": "1.10.2", - "resolved": "https://registry.npmjs.org/web3-utils/-/web3-utils-1.10.2.tgz", - "integrity": "sha512-TdApdzdse5YR+5GCX/b/vQnhhbj1KSAtfrDtRW7YS0kcWp1gkJsN62gw6GzCaNTeXookB7UrLtmDUuMv65qgow==", + "version": "1.10.3", + "license": "LGPL-3.0", "dependencies": { "@ethereumjs/util": "^8.1.0", "bn.js": "^5.2.1", @@ -11056,10 +10187,19 @@ "node": ">=8.0.0" } }, + "node_modules/web3-utils/node_modules/@noble/curves": { + "version": "1.1.0", + "license": "MIT", + "dependencies": { + "@noble/hashes": "1.3.1" + }, + "funding": { + "url": "https://paulmillr.com/funding/" + } + }, "node_modules/web3-utils/node_modules/@noble/hashes": { "version": "1.3.1", - "resolved": "https://registry.npmjs.org/@noble/hashes/-/hashes-1.3.1.tgz", - "integrity": "sha512-EbqwksQwz9xDRGfDST86whPBgM65E0OH/pCgqW0GBVzO22bNE+NuIbeTb714+IfSjU3aRk47EUvXIb5bTsenKA==", + "license": "MIT", "engines": { "node": ">= 16" }, @@ -11069,8 +10209,7 @@ }, "node_modules/web3-utils/node_modules/ethereum-cryptography": { "version": "2.1.2", - "resolved": "https://registry.npmjs.org/ethereum-cryptography/-/ethereum-cryptography-2.1.2.tgz", - "integrity": "sha512-Z5Ba0T0ImZ8fqXrJbpHcbpAvIswRte2wGNR/KePnu8GbbvgJ47lMxT/ZZPG6i9Jaht4azPDop4HaM00J0J59ug==", + "license": "MIT", "dependencies": { "@noble/curves": "1.1.0", "@noble/hashes": "1.3.1", @@ -11080,13 +10219,11 @@ }, "node_modules/webidl-conversions": { "version": "3.0.1", - "resolved": "https://registry.npmjs.org/webidl-conversions/-/webidl-conversions-3.0.1.tgz", - "integrity": "sha512-2JAn3z8AR6rjK8Sm8orRC0h/bcl/DqL7tRPdGZ4I1CjdF+EaMLmYxBHyXuKL849eucPFhvBoxMsflfOb8kxaeQ==" + "license": "BSD-2-Clause" }, "node_modules/websocket": { "version": "1.0.34", - "resolved": "https://registry.npmjs.org/websocket/-/websocket-1.0.34.tgz", - "integrity": "sha512-PRDso2sGwF6kM75QykIesBijKSVceR6jL2G8NGYyq2XrItNC2P5/qL5XeR056GhA+Ly7JMFvJb9I312mJfmqnQ==", + "license": "Apache-2.0", "dependencies": { "bufferutil": "^4.0.1", "debug": "^2.2.0", @@ -11101,21 +10238,18 @@ }, "node_modules/websocket/node_modules/debug": { "version": "2.6.9", - "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", - "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==", + "license": "MIT", "dependencies": { "ms": "2.0.0" } }, "node_modules/websocket/node_modules/ms": { "version": "2.0.0", - "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", - "integrity": "sha512-Tpp60P6IUJDTuOq/5Z8cdskzJujfwqfOTkrwIwj7IRISpnkJnT6SyJ4PCPnGMoFjC9ddhal5KVIYtAt97ix05A==" + "license": "MIT" }, "node_modules/whatwg-url": { "version": "5.0.0", - "resolved": "https://registry.npmjs.org/whatwg-url/-/whatwg-url-5.0.0.tgz", - "integrity": "sha512-saE57nupxk6v3HY35+jzBwYa0rKSy0XR8JSxZPwgLr7ys0IBzhGviA1/TUGJLmSVqs8pb9AnvICXEuOHLprYTw==", + "license": "MIT", "dependencies": { "tr46": "~0.0.3", "webidl-conversions": "^3.0.0" @@ -11123,9 +10257,8 @@ }, "node_modules/which": { "version": "2.0.2", - "resolved": "https://registry.npmjs.org/which/-/which-2.0.2.tgz", - "integrity": "sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA==", "dev": true, + "license": "ISC", "dependencies": { "isexe": "^2.0.0" }, @@ -11138,8 +10271,7 @@ }, "node_modules/which-boxed-primitive": { "version": "1.0.2", - "resolved": "https://registry.npmjs.org/which-boxed-primitive/-/which-boxed-primitive-1.0.2.tgz", - "integrity": "sha512-bwZdv0AKLpplFY2KZRX6TvyuN7ojjr7lwkg6ml0roIy9YeuSr7JS372qlNW18UQYzgYK9ziGcerWqZOmEn9VNg==", + "license": "MIT", "dependencies": { "is-bigint": "^1.0.1", "is-boolean-object": "^1.1.0", @@ -11152,12 +10284,11 @@ } }, "node_modules/which-typed-array": { - "version": "1.1.11", - "resolved": "https://registry.npmjs.org/which-typed-array/-/which-typed-array-1.1.11.tgz", - "integrity": "sha512-qe9UWWpkeG5yzZ0tNYxDmd7vo58HDBc39mZ0xWWpolAGADdFOzkfamWLDxkOWcvHQKVmdTyQdLD4NOfjLWTKew==", + "version": "1.1.13", + "license": "MIT", "dependencies": { "available-typed-arrays": "^1.0.5", - "call-bind": "^1.0.2", + "call-bind": "^1.0.4", "for-each": "^0.3.3", "gopd": "^1.0.1", "has-tostringtag": "^1.0.0" @@ -11171,15 +10302,13 @@ }, "node_modules/workerpool": { "version": "6.2.1", - "resolved": "https://registry.npmjs.org/workerpool/-/workerpool-6.2.1.tgz", - "integrity": "sha512-ILEIE97kDZvF9Wb9f6h5aXK4swSlKGUcOEGiIYb2OOu/IrDU9iwj0fD//SsA6E5ibwJxpEvhullJY4Sl4GcpAw==", - "dev": true + "dev": true, + "license": "Apache-2.0" }, "node_modules/wrap-ansi": { "version": "7.0.0", - "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-7.0.0.tgz", - "integrity": "sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q==", "dev": true, + "license": "MIT", "dependencies": { "ansi-styles": "^4.0.0", "string-width": "^4.1.0", @@ -11194,14 +10323,12 @@ }, "node_modules/wrappy": { "version": "1.0.2", - "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", - "integrity": "sha512-l4Sp/DRseor9wL6EvV2+TuQn63dMkPjZ/sp9XkghTEbV9KlPS1xUsZ3u7/IQO4wxtcFB4bgpQPRcR3QCvezPcQ==" + "license": "ISC" }, "node_modules/write-file-atomic": { "version": "4.0.2", - "resolved": "https://registry.npmjs.org/write-file-atomic/-/write-file-atomic-4.0.2.tgz", - "integrity": "sha512-7KxauUdBmSdWnmpaGFg+ppNjKF8uNLry8LyzjauQDOVONfFLNKrKvQOxZ/VuTIcS/gge/YNahf5RIIQWTSarlg==", "dev": true, + "license": "ISC", "dependencies": { "imurmurhash": "^0.1.4", "signal-exit": "^3.0.7" @@ -11212,8 +10339,7 @@ }, "node_modules/ws": { "version": "7.5.9", - "resolved": "https://registry.npmjs.org/ws/-/ws-7.5.9.tgz", - "integrity": "sha512-F+P9Jil7UiSKSkppIiD94dN07AwvFixvLIj1Og1Rl9GGMuNipJnV9JzjD6XuqmAeiswGvUmNLjr5cFuXwNS77Q==", + "license": "MIT", "engines": { "node": ">=8.3.0" }, @@ -11232,8 +10358,7 @@ }, "node_modules/xhr": { "version": "2.6.0", - "resolved": "https://registry.npmjs.org/xhr/-/xhr-2.6.0.tgz", - "integrity": "sha512-/eCGLb5rxjx5e3mF1A7s+pLlR6CGyqWN91fv1JgER5mVWg1MZmlhBvy9kjcsOdRk8RrIujotWyJamfyrp+WIcA==", + "license": "MIT", "dependencies": { "global": "~4.4.0", "is-function": "^1.0.1", @@ -11243,8 +10368,7 @@ }, "node_modules/xhr-request": { "version": "1.1.0", - "resolved": "https://registry.npmjs.org/xhr-request/-/xhr-request-1.1.0.tgz", - "integrity": "sha512-Y7qzEaR3FDtL3fP30k9wO/e+FBnBByZeybKOhASsGP30NIkRAAkKD/sCnLvgEfAIEC1rcmK7YG8f4oEnIrrWzA==", + "license": "MIT", "dependencies": { "buffer-to-arraybuffer": "^0.0.5", "object-assign": "^4.1.1", @@ -11257,25 +10381,20 @@ }, "node_modules/xhr-request-promise": { "version": "0.1.3", - "resolved": "https://registry.npmjs.org/xhr-request-promise/-/xhr-request-promise-0.1.3.tgz", - "integrity": "sha512-YUBytBsuwgitWtdRzXDDkWAXzhdGB8bYm0sSzMPZT7Z2MBjMSTHFsyCT1yCRATY+XC69DUrQraRAEgcoCRaIPg==", + "license": "MIT", "dependencies": { "xhr-request": "^1.1.0" } }, "node_modules/xmldom": { "version": "0.1.19", - "resolved": "https://registry.npmjs.org/xmldom/-/xmldom-0.1.19.tgz", - "integrity": "sha512-pDyxjQSFQgNHkU+yjvoF+GXVGJU7e9EnOg/KcGMDihBIKjTsOeDYaECwC/O9bsUWKY+Sd9izfE43JXC46EOHKA==", - "deprecated": "Deprecated due to CVE-2021-21366 resolved in 0.5.0", "engines": { "node": ">=0.1" } }, "node_modules/xstream": { "version": "11.14.0", - "resolved": "https://registry.npmjs.org/xstream/-/xstream-11.14.0.tgz", - "integrity": "sha512-1bLb+kKKtKPbgTK6i/BaoAn03g47PpFstlbe1BA+y3pNS/LfvcaghS5BFf9+EE1J+KwSQsEpfJvFN5GqFtiNmw==", + "license": "MIT", "dependencies": { "globalthis": "^1.0.1", "symbol-observable": "^2.0.3" @@ -11283,39 +10402,34 @@ }, "node_modules/xtend": { "version": "4.0.2", - "resolved": "https://registry.npmjs.org/xtend/-/xtend-4.0.2.tgz", - "integrity": "sha512-LKYU1iAXJXUgAXn9URjiu+MWhyUXHsvfp7mcuYm9dSUKK0/CjtrUwFAxD82/mCWbtLsGjFIad0wIsod4zrTAEQ==", + "license": "MIT", "engines": { "node": ">=0.4" } }, "node_modules/y18n": { "version": "5.0.8", - "resolved": "https://registry.npmjs.org/y18n/-/y18n-5.0.8.tgz", - "integrity": "sha512-0pfFzegeDWJHJIAmTLRP2DwHjdF5s7jo9tuztdQxAhINCdvS+3nGINqPd00AphqJR/0LhANUS6/+7SCb98YOfA==", "dev": true, + "license": "ISC", "engines": { "node": ">=10" } }, "node_modules/yaeti": { "version": "0.0.6", - "resolved": "https://registry.npmjs.org/yaeti/-/yaeti-0.0.6.tgz", - "integrity": "sha512-MvQa//+KcZCUkBTIC9blM+CU9J2GzuTytsOUwf2lidtvkx/6gnEp1QvJv34t9vdjhFmha/mUiNDbN0D0mJWdug==", + "license": "MIT", "engines": { "node": ">=0.10.32" } }, "node_modules/yallist": { "version": "3.1.1", - "resolved": "https://registry.npmjs.org/yallist/-/yallist-3.1.1.tgz", - "integrity": "sha512-a4UGQaWPH59mOXUYnAG2ewncQS4i4F43Tv3JoAM+s2VDAmS9NsK8GpDMLrCHPksFT7h3K6TOoUNn2pb7RoXx4g==" + "license": "ISC" }, "node_modules/yargs": { "version": "17.7.2", - "resolved": "https://registry.npmjs.org/yargs/-/yargs-17.7.2.tgz", - "integrity": "sha512-7dSzzRQ++CKnNI/krKnYRV7JKKPUXMEh61soaHKg9mrWEhzFWhFnxPxGl+69cD1Ou63C13NUPCnmIcrvqCuM6w==", "dev": true, + "license": "MIT", "dependencies": { "cliui": "^8.0.1", "escalade": "^3.1.1", @@ -11331,18 +10445,16 @@ }, "node_modules/yargs-parser": { "version": "20.2.4", - "resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-20.2.4.tgz", - "integrity": "sha512-WOkpgNhPTlE73h4VFAFsOnomJVaovO8VqLDzy5saChRBFQFBoMYirowyW+Q9HB4HFF4Z7VZTiG3iSzJJA29yRA==", "dev": true, + "license": "ISC", "engines": { "node": ">=10" } }, "node_modules/yargs-unparser": { "version": "2.0.0", - "resolved": "https://registry.npmjs.org/yargs-unparser/-/yargs-unparser-2.0.0.tgz", - "integrity": "sha512-7pRTIA9Qc1caZ0bZ6RYRGbHJthJWuakf+WmHK0rVeLkNrrGhfoabBNdue6kdINI6r4if7ocq9aD/n7xwKOdzOA==", "dev": true, + "license": "MIT", "dependencies": { "camelcase": "^6.0.0", "decamelize": "^4.0.0", @@ -11355,9 +10467,8 @@ }, "node_modules/yargs-unparser/node_modules/camelcase": { "version": "6.3.0", - "resolved": "https://registry.npmjs.org/camelcase/-/camelcase-6.3.0.tgz", - "integrity": "sha512-Gmy6FhYlCY7uOElZUSbxo2UCDH8owEk996gkbrpsgGtrJLM3J7jGxl9Ic7Qwwj4ivOE5AWZWRMecDdF7hqGjFA==", "dev": true, + "license": "MIT", "engines": { "node": ">=10" }, @@ -11367,27 +10478,24 @@ }, "node_modules/yargs/node_modules/yargs-parser": { "version": "21.1.1", - "resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-21.1.1.tgz", - "integrity": "sha512-tVpsJW7DdjecAiFpbIB1e3qxIQsE6NoPc5/eTdrbbIC4h0LVsWhnoa3g+m2HclBIujHzsxZ4VJVA+GUuc2/LBw==", "dev": true, + "license": "ISC", "engines": { "node": ">=12" } }, "node_modules/yn": { "version": "3.1.1", - "resolved": "https://registry.npmjs.org/yn/-/yn-3.1.1.tgz", - "integrity": "sha512-Ux4ygGWsu2c7isFWe8Yu1YluJmqVhxqK2cLXNQA5AcC3QfbGNpM7fu0Y8b/z16pXLnFxZYvWhd3fhBY9DLmC6Q==", "dev": true, + "license": "MIT", "engines": { "node": ">=6" } }, "node_modules/yocto-queue": { "version": "0.1.0", - "resolved": "https://registry.npmjs.org/yocto-queue/-/yocto-queue-0.1.0.tgz", - "integrity": "sha512-rVksvsnNCdJ/ohGc6xgPwyN8eheCxsiLM8mxuE/t/mOVqJewPuO1miLpTHQiRgTKCLexL4MeAFVagts7HmNZ2Q==", "dev": true, + "license": "MIT", "engines": { "node": ">=10" }, diff --git a/package.json b/package.json index 19472cf..4064cc6 100644 --- a/package.json +++ b/package.json @@ -1,19 +1,26 @@ { "name": "hs-ssi-sdk", - "version": "6.2.0", + "version": "7.0.1", "description": "sdk is an implementation of proposed DID by W3C", "main": "build/src/index.js", "scripts": { "test": "npm run test-did && npm run test-schema && npm run test-credential && npm run test-presentation", + "test-bjj": "npm run test-did-bjj && npm run test-schema-bjj && npm run test-credential-bjj && npm run test-presentation-bjj", "test-did": "env TS_NODE_COMPILER_OPTIONS='{\"module\": \"commonjs\" }' mocha -r ts-node/register 'src/tests/did/did.spec.ts' --exit --timeout 40000", + "test-did-keyagreement": "env TS_NODE_COMPILER_OPTIONS='{\"module\": \"commonjs\" }' mocha -r ts-node/register 'src/tests/did/did_keyagreement.spec.ts' --exit --timeout 40000", "test-didByApiKey": "env TS_NODE_COMPILER_OPTIONS='{\"module\": \"commonjs\" }' mocha -r ts-node/register 'src/tests/did/didByEntityApiKey.spec.ts' --exit --timeout 400000", "test-didByClientSpec": "env TS_NODE_COMPILER_OPTIONS='{\"module\": \"commonjs\" }' mocha -r ts-node/register 'src/tests/did/didByclientSpec.spec.ts' --exit --timeout 400000", "test-schema": "env TS_NODE_COMPILER_OPTIONS='{\"module\": \"commonjs\" }' mocha -r ts-node/register 'src/tests/schema/schema.spec.ts' --exit --timeout 400000", "test-schemaByApiKey": "env TS_NODE_COMPILER_OPTIONS='{\"module\": \"commonjs\" }' mocha -r ts-node/register 'src/tests/schema/schemaByEntityApiKey.spec.ts' --exit --timeout 400000", "test-credential": "env TS_NODE_COMPILER_OPTIONS='{\"module\": \"commonjs\" }' mocha -r ts-node/register 'src/tests/credential/vc.spec.ts' --exit --timeout 400000", "test-credentialByApiKey": "env TS_NODE_COMPILER_OPTIONS='{\"module\": \"commonjs\" }' mocha -r ts-node/register 'src/tests/credential/vcByEntityApiKey.spec.ts' --exit --timeout 400000", - "test-presentation": "env TS_NODE_COMPILER_OPTIONS='{\"module\": \"commonjs\" }' mocha -r ts-node/register 'src/tests/vp.spec.ts' --exit --timeout 400000", - "test-signdid": "env TS_NODE_COMPILER_OPTIONS='{\"module\": \"commonjs\" }' mocha -r ts-node/register 'src/tests/didSign.spec.ts' --exit --timeout 400000", + "test-presentation": "env TS_NODE_COMPILER_OPTIONS='{\"module\": \"commonjs\" }' mocha -r ts-node/register 'src/tests/presentation/vp.spec.ts' --exit --timeout 400000", + "test-presentationByClientSpec": "env TS_NODE_COMPILER_OPTIONS='{\"module\": \"commonjs\" }' mocha -r ts-node/register 'src/tests/presentation/vpByClientSpec.spec.ts' --exit --timeout 400000", + "test-did-bjj": "env TS_NODE_COMPILER_OPTIONS='{\"module\": \"commonjs\" }' mocha -r ts-node/register 'src/tests/bjj/did/bjj_did.spec.ts' --exit --timeout 400000", + "test-schema-bjj": "env TS_NODE_COMPILER_OPTIONS='{\"module\": \"commonjs\" }' mocha -r ts-node/register 'src/tests/bjj/schema/bjj_schema.spec.ts' --exit --timeout 400000", + "test-credential-bjj": "env TS_NODE_COMPILER_OPTIONS='{\"module\": \"commonjs\" }' mocha -r ts-node/register 'src/tests/bjj/credential/bjj_credential.spec.ts' --exit --timeout 400000", + "test-presentation-bjj": "env TS_NODE_COMPILER_OPTIONS='{\"module\": \"commonjs\" }' mocha -r ts-node/register 'src/tests/bjj/presentation/bjj_vp.spec.ts' --exit --timeout 400000", + "test-bjjScenario": "env TS_NODE_COMPILER_OPTIONS='{\"module\": \"commonjs\" }' mocha -r ts-node/register 'src/tests/bjj/bjjTestScenario.spec.ts' --exit --timeout 400000", "start": "node build/index.js", "build": "npm run lint:fix && npm run prettier && rimraf build && tsc -p .", "prettier": "prettier --config .prettierrc.json --write src/**/*.ts", @@ -25,20 +32,24 @@ "author": "Hypersign Team", "license": "ISC", "dependencies": { - "@cosmjs/proto-signing": "^0.27.0", - "@cosmjs/stargate": "^0.27.0", + "@cfworker/json-schema": "github:hypersign-protocol/json-schema", + "@cosmjs/proto-signing": "^0.31.0", + "@cosmjs/stargate": "^0.31.0", "@digitalbazaar/ed25519-signature-2020": "^3.0.0", "@digitalbazaar/ed25519-verification-key-2018": "^3.1.2", "@digitalbazaar/ed25519-verification-key-2020": "^3.3.0", - "@stablelib/ed25519": "^1.0.2", - "axios": "^0.19.0", + "@iden3/js-jsonld-merklization": "^1.0.2", + "@iden3/js-merkletree": "^1.1.2", + "axios": "^1.6.2", + "babyjubjub2021": "^0.1.1", + "babyjubjubsignature2021": "github:hypersign-protocol/BabyJubJubSignature2021Suite", "crypto-ld": "^6.0.0", "ethereumeip712signature2021suite": "github:hypersign-protocol/EthereumEip712Signature2021Suite.git", "jcs": "github:hypersign-protocol/JCS", - "jsonld": "^8.2.0", "jsonld-signatures": "^9.3.1", "jsonwebtoken": "^9.0.1", - "node-fetch": "^2.6.1", + "multiformats": "^9.9.0", + "node-fetch": "^2.7.0", "protobufjs": "^6.11.2", "uuid": "^8.3.0", "vc-js": "https://github.com/hypersign-protocol/vc-js", diff --git a/src/constants.ts b/src/constants.ts index 9e1f9a0..146abfe 100644 --- a/src/constants.ts +++ b/src/constants.ts @@ -1,4 +1,9 @@ 'use strict'; +import { + ProofTypes, + VerificationMethodRelationships, + VerificationMethodTypes, +} from '../libs/generated/ssi/client/enums'; export const compactProof = false; export const HYPERSIGN_TESTNET_RPC = 'https://rpc.jagrat.hypersign.id'; @@ -7,62 +12,60 @@ export const HYPERSIGN_TESTNET_REST = 'https://api.jagrat.hypersign.id'; export const HYPERSIGN_MAINNET_RPC = 'http://localhost:26657'; export const HYPERSIGN_MAINNET_REST = 'http://localhost:1317'; -export const HID_COSMOS_MODULE = '/hypersignprotocol.hidnode.ssi'; +export const HID_COSMOS_MODULE = '/hypersign.ssi.v1'; export const HYPERSIGN_NETWORK_DID_PATH = 'hypersign-protocol/hidnode/ssi/did'; export const HYPERSIGN_NETWORK_SCHEMA_PATH = 'hypersign-protocol/hidnode/ssi/schema'; export const HYPERSIGN_NETWORK_CREDENTIALSTATUS_PATH = 'hypersign-protocol/hidnode/ssi/credential'; export const HYPERSIGN_NETWORK_BANK_BALANCE_PATH = '/bank/balances/'; export enum HIDRpcEnums { - MsgCreateDID = 'MsgCreateDID', + MsgRegisterDID = 'MsgRegisterDID', MsgUpdateDID = 'MsgUpdateDID', MsgDeactivateDID = 'MsgDeactivateDID', - MsgCreateSchema = 'MsgCreateSchema', + MsgRegisterCredentialSchema = 'MsgRegisterCredentialSchema', MsgRegisterCredentialStatus = 'MsgRegisterCredentialStatus', + MsgUpdateCredentialStatus = 'MsgUpdateCredentialStatus', } Object.freeze(HIDRpcEnums); export enum CredentialStatusEnums { - - LIVE = "Live", - REVOKED="Revoked", - SUSPENDED="Suspended" + LIVE = 'Live', + REVOKED = 'Revoked', + SUSPENDED = 'Suspended', } export enum CredentialStatusReasonEnums { - LIVE = "Credential is live", - REVOKED="Credential is revoked", - SUSPENDED="Credential is suspended" + LIVE = 'Credential is live', + REVOKED = 'Credential is revoked', + SUSPENDED = 'Credential is suspended', } - - - export const DID_Ed25519VerificationKey2020 = { CONTROLLER_CONTEXT: 'https://w3id.org/security/v2', SCHEME: 'did', METHOD: 'hid', NAMESPACE: 'testnet', // this is not used DID_BASE_CONTEXT: 'https://www.w3.org/ns/did/v1', - DID_KEYAGREEMENT_CONTEXT:"https://digitalbazaar.github.io/x25519-key-agreement-2020-context/contexts/x25519-key-agreement-2020-v1.jsonld", + DID_KEYAGREEMENT_CONTEXT: 'https://ns.did.ai/suites/x25519-2020/v1', + DID_Ed25519_CONTEXT_2020: 'https://w3id.org/security/suites/ed25519-2020/v1', VERIFICATION_METHOD_TYPE: 'Ed25519VerificationKey2020', BLOCKCHAINACCOUNTID_CONTEXT: 'https://w3c.github.io/vc-data-integrity/vocab/security/vocabulary.jsonld', - + SIGNATURE_TYPE: ProofTypes.Ed25519Signature2020, }; - export const DID_EcdsaSecp256k1RecoveryMethod2020 = { CONTROLLER_CONTEXT: 'https://w3id.org/security/v2', SCHEME: 'did', METHOD: 'hid', NAMESPACE: 'testnet', // this is not used DID_BASE_CONTEXT: 'https://www.w3.org/ns/did/v1', - DID_KEYAGREEMENT_CONTEXT:"https://github.com/hypersign-protocol/hid-ssi-js-sdk/blob/develop/libs/w3cache/v1/X25519KeyAgreementKeyEIP5630.json", + DID_KEYAGREEMENT_CONTEXT: + 'https://raw.githubusercontent.com/hypersign-protocol/hypersign-contexts/main/X25519KeyAgreementKeyEIP5630.jsonld', BLOCKCHAINACCOUNTID_CONTEXT: 'https://w3c.github.io/vc-data-integrity/vocab/security/vocabulary.jsonld', - VERIFICATION_METHOD_TYPE: 'EcdsaSecp256k1RecoveryMethod2020', + SECP256K12020_RECOVERY_CONTEXT: 'https://ns.did.ai/suites/secp256k1-2020/v1', + VERIFICATION_METHOD_TYPE: VerificationMethodTypes.EcdsaSecp256k1RecoveryMethod2020, + SIGNATURE_TYPE: ProofTypes.EcdsaSecp256k1RecoverySignature2020, }; - - export const DID_EcdsaSecp256k1VerificationKey2019 = { CONTROLLER_CONTEXT: 'https://w3id.org/security/v2', SCHEME: 'did', @@ -70,47 +73,65 @@ export const DID_EcdsaSecp256k1VerificationKey2019 = { NAMESPACE: 'testnet', // this is not used DID_BASE_CONTEXT: 'https://www.w3.org/ns/did/v1', BLOCKCHAINACCOUNTID_CONTEXT: 'https://w3c.github.io/vc-data-integrity/vocab/security/vocabulary.jsonld', - VERIFICATION_METHOD_TYPE: 'EcdsaSecp256k1VerificationKey2019', + SECP256K12020_VERIFICATION_CONTEXT: 'https://ns.did.ai/suites/secp256k1-2019/v1', + VERIFICATION_METHOD_TYPE: VerificationMethodTypes.EcdsaSecp256k1VerificationKey2019, + SIGNATURE_TYPE: ProofTypes.EcdsaSecp256k1Signature2019, }; +export const DID_BabyJubJubKey2021 = { + CONTROLLER_CONTEXT: 'https://w3id.org/security/v2', + SCHEME: 'did', + METHOD: 'hid', + NAMESPACE: 'testnet', // this is not used + DID_BASE_CONTEXT: 'https://www.w3.org/ns/did/v1', + DID_KEYAGREEMENT_CONTEXT: 'https://ns.did.ai/suites/x25519-2020/v1', + DID_BABYJUBJUBKEY2021: + 'https://raw.githubusercontent.com/hypersign-protocol/hypersign-contexts/main/BabyJubJubKey2021.jsonld', + BABYJUBJUBSIGNATURE: + 'https://raw.githubusercontent.com/hypersign-protocol/hypersign-contexts/main/BJJSignature2021.jsonld', + VERIFICATION_METHOD_TYPE: 'BabyJubJubKey2021', + BLOCKCHAINACCOUNTID_CONTEXT: 'https://w3c.github.io/vc-data-integrity/vocab/security/vocabulary.jsonld', + + SIGNATURE_TYPE: ProofTypes.BJJSignature2021, +}; -export enum CAIP_10_PREFIX{ - "eip155"="eip155", +export enum CAIP_10_PREFIX { + 'eip155' = 'eip155', } - export const DID = { CONTROLLER_CONTEXT: 'https://w3id.org/security/v2', SCHEME: 'did', METHOD: 'hid', NAMESPACE: 'testnet', // this is not used DID_BASE_CONTEXT: 'https://www.w3.org/ns/did/v1', - VERIFICATION_METHOD_TYPE: 'Ed25519VerificationKey2020', + VERIFICATION_METHOD_TYPE: VerificationMethodTypes.Ed25519VerificationKey2020, BLOCKCHAINACCOUNTID_CONTEXT: 'https://w3c.github.io/vc-data-integrity/vocab/security/vocabulary.jsonld', - }; Object.freeze(DID); export const VC = { - - SCHEME: "vc", - METHOD: "hid", - NAMESPACE:"testnet", - PREFIX: "vc:" + DID.METHOD + ":" + DID.NAMESPACE + ":", - CREDENTAIL_SCHEMA_VALIDATOR_TYPE: "JsonSchemaValidator2018", - CREDENTAIL_STATUS_TYPE: "CredentialStatusList2017", - CREDENTAIL_BASE_CONTEXT: "https://www.w3.org/2018/credentials/v1", - CREDENTAIL_SECURITY_CONTEXT_V2: "https://w3id.org/security/v2", - CREDENTAIL_SECURITY_SUITE: "https://w3id.org/security/suites/ed25519-2020/v1", - CREDENTAIL_ECDSA_SECURITY_SUITE: "https://w3id.org/security/suites/secp256k1recovery-2020/v2", - PROOF_PURPOSE: "assertion", - VERIFICATION_METHOD_TYPE: "Ed25519Signature2020", - CRED_STATUS_TYPES: CredentialStatusEnums , - - CRED_STATUS_REASON_TYPES: CredentialStatusReasonEnums -} -Object.freeze(VC) + SCHEME: 'vc', + METHOD: 'hid', + NAMESPACE: 'testnet', + PREFIX: 'vc:' + DID.METHOD + ':' + DID.NAMESPACE + ':', + CREDENTAIL_SCHEMA_VALIDATOR_TYPE: 'JsonSchemaValidator2018', + CREDENTAIL_STATUS_TYPE: 'HypersignCredentialStatus2023', + CREDENTIAL_STATUS_CONTEXT: + 'https://raw.githubusercontent.com/hypersign-protocol/hypersign-contexts/main/CredentialStatus.jsonld', + CONTEXT_HypersignCredentialStatus2023: + 'https://raw.githubusercontent.com/hypersign-protocol/hypersign-contexts/main/HypersignCredentialStatus2023.jsonld', + CREDENTAIL_BASE_CONTEXT: 'https://www.w3.org/2018/credentials/v1', + CREDENTAIL_SECURITY_CONTEXT_V2: 'https://w3id.org/security/v2', + CREDENTIAIL_SECURITY_SUITE: 'https://w3id.org/security/suites/ed25519-2020/v1', + CREDENTAIL_ECDSA_SECURITY_SUITE: 'https://w3id.org/security/suites/secp256k1recovery-2020/v2', + PROOF_PURPOSE: VerificationMethodRelationships.assertionMethod, + VERIFICATION_METHOD_TYPE: ProofTypes.Ed25519Signature2020, + CRED_STATUS_TYPES: CredentialStatusEnums, + CRED_STATUS_REASON_TYPES: CredentialStatusReasonEnums, +}; +Object.freeze(VC); export const VP = { PREFIX: 'vp:', @@ -126,8 +147,10 @@ export const SCHEMA = { NAMESPACE: 'testnet', SCHEMA_JSON: 'http://json-schema.org/draft-07/schema', SCHEMA_TYPE: 'https://w3c-ccg.github.io/vc-json-schemas/v1/schema/1.0/schema.json', - SIGNATURE_TYPE: "Ed25519Signature2020", - PROOF_PURPOSE: "assertion", + SIGNATURE_TYPE: ProofTypes.Ed25519Signature2020, + PROOF_PURPOSE: VerificationMethodRelationships.assertionMethod, + SCHEMA_CONTEXT: + 'https://raw.githubusercontent.com/hypersign-protocol/hypersign-contexts/main/CredentialSchema.jsonld', }; Object.freeze(SCHEMA); @@ -142,3 +165,17 @@ export const HID_DECIMAL = 6; export const HID_DNOMINATION = 'uhid'; export const HID_MIN_GAS = '200000'; export const HID_MIN_FEE = '5000'; + + + +export const GAS_FEE_API_URL = (baseUrl)=> { return `${baseUrl}/hypersign-protocol/hidnode/ssi/fixedfee`} +export const GAS_FEE_METHODS = { + Register_Did: "register_did_fee", + Update_Did: "update_did_fee", + Deactivate_Did: "deactivate_did_fee", + Register_Cred_Schema: "register_credential_schema_fee", + Update_Cred_Schema: "update_credential_schema_fee", + Register_Cred_Status: "register_credential_status_fee", + Update_Cred_Status: "update_credential_status_fee" + +} \ No newline at end of file diff --git a/src/credential/ICredential.ts b/src/credential/ICredential.ts index 08832fd..e69be92 100644 --- a/src/credential/ICredential.ts +++ b/src/credential/ICredential.ts @@ -5,7 +5,12 @@ */ import { TypedDataField } from '@ethersproject/abstract-signer'; -import { CredentialStatus, CredentialProof, Credential } from '../../libs/generated/ssi/credential'; +import { + CredentialStatusDocument as CredentialStatus, + CredentialStatusState as Credential, +} from '../../libs/generated/ssi/credential_status'; +import { DocumentProof as CredentialProof } from '../../libs/generated/ssi/proof'; + import { DeliverTxResponse } from '@cosmjs/stargate'; // interface ICredStatus { @@ -94,12 +99,16 @@ export interface ICredentialMethods { privateKeyMultibase: string; status: string; statusReason?: string; - }): Promise; + }): Promise; - resolveCredentialStatus(params: { credentialId: string }): Promise; + resolveCredentialStatus(params: { credentialId: string }): Promise; checkCredentialStatus(params: { credentialId: string }): Promise<{ verified: boolean }>; } +export interface IResolveCredential extends CredentialStatus { + proof: CredentialProof; +} + export interface ICredentialRPC { credentialRestEP: string; registerCredentialStatus(credentialStatus: CredentialStatus, proof: CredentialProof): Promise; diff --git a/src/credential/bjjvc.ts b/src/credential/bjjvc.ts new file mode 100644 index 0000000..649e78a --- /dev/null +++ b/src/credential/bjjvc.ts @@ -0,0 +1,894 @@ +/** + * Copyright (c) 2023, Hypermine Pvt. Ltd. + * All rights reserved. + * Author: Hypermine Core Team + */ +import jssig from 'jsonld-signatures'; +import { purposes } from 'jsonld-signatures'; +import Utils from '../utils'; +import HypersignSchema from '../schema/schema'; +import { CredentialSchemaProperty as SchemaProperty } from '../../libs/generated/ssi/credential_schema'; +import HypersignDID from '../did/did'; +import { DidDocument as Did, DidDocument, VerificationMethod } from '../../libs/generated/ssi/did'; + +import * as jsonSchemaValidator from '@cfworker/json-schema'; + +import jsonSigs from 'jsonld-signatures'; +const { AssertionProofPurpose } = jsonSigs.purposes; +import { CredentialRPC } from './credRPC'; +import { + ICredentialMethods, + IVerifiableCredential, + ICredentialStatus, + ISchema, + ICredentialProof, + IResolveCredential, +} from './ICredential'; +import { VC, DID, CredentialStatusEnums } from '../constants'; +import { + CredentialStatusDocument as CredentialStatus, + CredentialStatusDocument, + CredentialStatusState, +} from '../../libs/generated/ssi/credential_status'; +import { DocumentProof as CredentialProof } from '../../libs/generated/ssi/proof'; +import { DeliverTxResponse } from '@cosmjs/stargate'; +import { OfflineSigner } from '@cosmjs/proto-signing'; +import customLoader from '../../libs/w3cache/v1'; + +import { extendContextLoader } from 'jsonld-signatures'; +import { ICredentialService } from '../ssiApi/services/credential/ICredentialApi'; +import CredentialApiService from '../ssiApi/services/credential/credential.service'; +import { IResolveSchema } from '../schema/ISchema'; +import * as constant from '../constants'; +import { BabyJubJubKeys2021 } from 'babyjubjub2021'; +import { BabyJubJubSignature2021Suite, deriveProof } from 'babyjubjubsignature2021'; +const { Merklizer } = require('@iden3/js-jsonld-merklization'); +const documentLoader = extendContextLoader(customLoader); +export default class HypersignBJJVerifiableCredential implements ICredentialMethods, IVerifiableCredential { + public '@context': Array; + public id: string; + public type: Array; + public issuer: string; + public issuanceDate: string; + public expirationDate: string; + public credentialSubject: object; + public credentialSchema: ISchema; + public proof: ICredentialProof; + public credentialStatus: ICredentialStatus; + private credStatusRPC: CredentialRPC | null; + private credentialApiService: ICredentialService | null; + private namespace: string; + private hsSchema: HypersignSchema; + private hsDid: HypersignDID; + public documentL: any; + constructor( + params: { + namespace?: string; + offlineSigner?: OfflineSigner; + nodeRpcEndpoint?: string; + nodeRestEndpoint?: string; + entityApiSecretKey?: string; + } = {} + ) { + const { namespace, offlineSigner, nodeRpcEndpoint, nodeRestEndpoint, entityApiSecretKey } = params; + this.documentL = documentLoader; + this.namespace = namespace && namespace != '' ? namespace : ''; + const nodeRPCEp = nodeRpcEndpoint ? nodeRpcEndpoint : 'MAIN'; + const nodeRestEp = nodeRestEndpoint ? nodeRestEndpoint : ''; + const offlineConstuctorParams = { offlineSigner, nodeRpcEndpoint: nodeRPCEp, nodeRestEndpoint: nodeRestEp }; + this.credStatusRPC = new CredentialRPC(offlineConstuctorParams); + this.hsDid = new HypersignDID(offlineConstuctorParams); + this.hsSchema = new HypersignSchema(offlineConstuctorParams); + if (entityApiSecretKey && entityApiSecretKey != '') { + this.credentialApiService = new CredentialApiService(entityApiSecretKey); + this.credStatusRPC = null; + } else { + this.credentialApiService = null; + } + + this['@context'] = []; + this.id = ''; + this.type = []; + this.issuer = ''; + this.issuanceDate = ''; + this.expirationDate = ''; + this.credentialSubject = {}; + this.credentialSchema = { + id: '', + type: VC.CREDENTAIL_SCHEMA_VALIDATOR_TYPE, + }; + this.credentialStatus = { + id: '', + type: VC.CREDENTAIL_STATUS_TYPE, + }; + this.proof = {} as ICredentialProof; + } + private async _jsonLdSign(params: { + credentialStatus: CredentialStatus; + privateKeyMultibase: string; + verificationMethodId: string; + publicKeyMultibase: string; + }) { + const { credentialStatus, privateKeyMultibase, verificationMethodId } = params; + const keyPair = await BabyJubJubKeys2021.fromKeys({ + options: { id: verificationMethodId, controller: verificationMethodId }, + privateKeyMultibase: privateKeyMultibase, + publicKeyMultibase: params.publicKeyMultibase, + }); + const suite = new BabyJubJubSignature2021Suite({ key: keyPair, verificationMethod: verificationMethodId }); + + const signedCredStatus = await jsonSigs.sign(credentialStatus, { + suite, + purpose: new AssertionProofPurpose(), + documentLoader: customLoader, + }); + return signedCredStatus.proof; + } + + private _dateNow(date?: string): string { + if (date) { + return new Date(date).toISOString().slice(0, -5) + 'Z'; + } else { + return new Date(new Date().getTime() - 100000).toISOString().slice(0, -5) + 'Z'; + } + } + + private async _getId(): Promise { + const uuid = await Utils.getUUID(); + let id; + if (this.namespace && this.namespace != '') { + id = `${VC.SCHEME}:${VC.METHOD}:${this.namespace}:${uuid}`; + } else { + id = `${VC.SCHEME}:${VC.METHOD}:${uuid}`; + } + return id; + } + + private async _toTitleCase(status: string) { + return status.charAt(0).toUpperCase() + status.slice(1).toLowerCase(); + } + /** + * Initialise the offlinesigner to interact with Hypersign blockchain + */ + public async init() { + if (!this.credStatusRPC && !this.credentialApiService) { + throw new Error( + 'HID-SSI-SDK:: Error: HypersignVerifiableCredential class is not instantiated with Offlinesigner or have not been initilized with entityApiSecretKey' + ); + } + if (this.credStatusRPC) { + await this.credStatusRPC.init(); + } + if (this.credentialApiService) { + await this.credentialApiService.auth(); + } + } + + /** + * Generates a new credential document + * @params + * - params.schemaId : Hypersign schema id + * - params.subjectDid : DID of the subject, if not provided, will be taken from subjectDidDocSigned + * - params.schemaContext : + * - params.type : + * - params.issuerDid : DID of the issuer + * - params.expirationDate : Date of the expiration for this credential + * - params.fields : Schema fields values for this credential + * @returns {Promise} Result a credential document + */ + public async generate(params: { + schemaId?: string; + subjectDid?: string; + subjectDidDocSigned?: JSON; + schemaContext?: Array; + type?: Array; + issuerDid: string; + expirationDate: string; + fields: object; + }): Promise { + let schemaDoc: IResolveSchema = {} as IResolveSchema; + if (params.subjectDid && params.subjectDidDocSigned) { + throw new Error('HID-SSI-SDK:: Error: Both subjectDid and subjectDidDoc cannot be passed'); + } + + if (!this.credStatusRPC) { + throw new Error( + 'HID-SSI-SDK:: Error: HypersignVerifiableCredential class is not instantiated with Offlinesigner or have not been initilized' + ); + } + + const issuerDid = params.issuerDid; + const subjectDid = params.subjectDid; + let resolvedsubjectDidDoc; + // const { didDocument: issuerDidDoc } = await this.hsDid.resolve({ did: issuerDid }); + if (params.subjectDid) { + // resolvedsubjectDidDoc = await this.hsDid.resolve({ did: params.subjectDid }); + } else if (params.subjectDidDocSigned) { + resolvedsubjectDidDoc = {}; + resolvedsubjectDidDoc.didDocument = params.subjectDidDocSigned; + } else { + throw new Error('HID-SSI-SDK:: Error: Could not resolve the subjectDid or subjectDidDoc'); + } + // const { didDocument: subjectDidDoc } = resolvedsubjectDidDoc; + // if (!issuerDidDoc) { + // throw new Error('HID-SSI-SDK:: Error: Could not fetch issuer did doc, issuer did = ' + issuerDid); + // } + + // if (!subjectDidDoc) { + // throw new Error('HID-SSI-SDK:: Error: Could not fetch subject did doc, subject did = ' + subjectDid); + // } + + if (params && params.schemaContext && params.type) { + try { + const context = Array(); + context.push(VC.CREDENTAIL_BASE_CONTEXT); + context.push(constant.DID_BabyJubJubKey2021.BABYJUBJUBSIGNATURE); + + params.schemaContext.forEach((x) => { + context.push(x); + }); + + const issuerDid = params.issuerDid; + const subjectDid = params.subjectDid; + const expirationDate = params.expirationDate; + const credentialSubject = params.fields; + + const vc: IVerifiableCredential = {} as IVerifiableCredential; + vc['@context'] = context; + + vc.id = await this._getId(); + vc.type = []; + vc.type.push('VerifiableCredential'); + params.type.forEach((x) => { + vc.type.push(x); + }); + + vc.issuer = issuerDid; + vc.issuanceDate = this._dateNow(new Date(new Date().getTime() - 100000).toISOString()); + vc.expirationDate = this._dateNow(expirationDate); + vc.credentialSubject = credentialSubject; + vc.credentialSubject['id'] = subjectDid; //subjectDid && subjectDid != undefined ? subjectDid : subjectDidDoc.id; + + // TODO: confusion here is, what would be the status of this credential at the time of its creation? + // If this properpty is present , then checkStatus() must be passed at the time of verification of the credential + // Ref: https://github.com/digitalbazaar/vc-js/blob/7e14ef27bc688194635077d243d9025c0020448b/test/10-verify.spec.js#L188 + vc.credentialStatus = { + id: this.credStatusRPC.credentialRestEP + '/' + vc.id, // TODO: Will add credentialStatus path when issueing this crdential + type: this.credentialStatus.type, + } as ICredentialStatus; + + return vc; + } catch (error) { + throw new Error('HID-SSI-SDK:: Error: Could not create credential, error = ' + error); + } + } else if (!params.schemaId) { + throw new Error('HID-SSI-SDK:: Error: schemaId is required when schemaContext and type not passed'); + } + + try { + schemaDoc = await this.hsSchema.resolve({ schemaId: params.schemaId }); + } catch (e) { + throw new Error('HID-SSI-SDK:: Error: Could not resolve the schema from schemaId = ' + params.schemaId); + } + // TODO: do proper check for date and time + //if(params.expirationDate < new Date()) throw new Error("Expiration date can not be lesser than current date") + + const vc: IVerifiableCredential = {} as IVerifiableCredential; + + // const schemaInternal = schemaDoc.schema as SchemaProperty; + // const schemaProperties = JSON.parse(schemaInternal.properties as string); + // const schemaName = schemaDoc.name as string; + // context + // vc['@context'] = this._getCredentialContext(params.schemaId, schemaProperties, schemaName); + vc['@context'] = [ + VC.CREDENTAIL_BASE_CONTEXT, + constant.DID_BabyJubJubKey2021.DID_BABYJUBJUBKEY2021, + constant.DID_BabyJubJubKey2021.BABYJUBJUBSIGNATURE, + ]; + vc['@context'].push(VC.CONTEXT_HypersignCredentialStatus2023); + const JsonSchema = this.hsSchema.vcJsonSchema(schemaDoc); + vc['@context'].push((JsonSchema as any).$metadata.jsonLdContext); + + /// TODO: need to implement this properly + vc.id = await this._getId(); + + // Type + vc.type = []; + vc.type.push('VerifiableCredential'); + vc.type.push(schemaDoc.name as string); + + vc.expirationDate = this._dateNow(params.expirationDate); + vc.issuanceDate = this._dateNow(); // TODO: need to remove this. + + vc.issuer = issuerDid; + vc.credentialSubject = {}; + // ToDo: Implement Schema validation (JSON Schema Validator) + + const validator = new jsonSchemaValidator.Validator(JsonSchema as any, '2020-12', true); + + const result = validator.validate({ + credentialSubject: { ...params.fields }, + }); + + if (!result.valid) { + throw result.errors; + } + + // vc.credentialSubject = { + // ...this._getCredentialSubject(schemaDoc.schema as SchemaProperty, params.fields), + // }; + + vc.credentialSubject = params.fields; + vc.credentialSubject['id'] = subjectDid; // subjectDid && subjectDid != undefined ? subjectDid : subjectDidDoc.id; + vc.credentialSchema = { + id: schemaDoc.id as string, + type: this.credentialSchema.type, + }; + + // TODO: confusion here is, what would be the status of this credential at the time of its creation? + // If this properpty is present , then checkStatus() must be passed at the time of verification of the credential + // Ref: https://github.com/digitalbazaar/vc-js/blob/7e14ef27bc688194635077d243d9025c0020448b/test/10-verify.spec.js#L188 + vc.credentialStatus = { + id: this.credStatusRPC.credentialRestEP + '/' + vc.id, // TODO: Will add credentialStatus path when issueing this crdential + type: this.credentialStatus.type, + } as ICredentialStatus; + return vc; + } + + /** + * Generates signed credentials document and registers its status on Hypersign blockchain + * @params + * - params.credential : Hypersign credentail document + * - params.privateKeyMultibase : P + * - params.issuerDid : DID of the issuer + * - params.verificationMethodId : Verifcation Method of Issuer + * @returns {Promise<{ + * signedCredential: IVerifiableCredential; + * credentialStatus: CredentialStatus; + * credentialStatusProof: CredentialProof; + * credentialStatusRegistrationResult?: DeliverTxResponse; + * }>} + */ + public async issue(params: { + credential: IVerifiableCredential; + issuerDid: string; + verificationMethodId: string; // vermethod of issuer for assestion + privateKeyMultibase: string; + registerCredential?: boolean; + issuerDidDoc?: JSON; + }): Promise<{ + signedCredential: IVerifiableCredential; + credentialStatus: CredentialStatus; + credentialStatusProof: CredentialProof; + credentialStatusRegistrationResult?: DeliverTxResponse; + }> { + if (!params.verificationMethodId) { + throw new Error('HID-SSI-SDK:: Error: params.verificationMethodId is required to issue credential'); + } + + if (!params.credential) { + throw new Error('HID-SSI-SDK:: Error: params.credential is required to issue credential'); + } + + if (!params.privateKeyMultibase) { + throw new Error('HID-SSI-SDK:: Error: params.privateKeyMultibase is required to issue credential'); + } + + if (!params.issuerDid) { + throw new Error('HID-SSI-SDK:: Error: params.issuerDid is required to issue credential'); + } + + if (!this.credStatusRPC) { + throw new Error( + 'HID-SSI-SDK:: Error: HypersignVerifiableCredential class is not instantiated with Offlinesigner or have not been initilized' + ); + } + + if (params.registerCredential == undefined) { + params.registerCredential = true; + } + + // const { didDocument: signerDidDoc } = await this.hsDid.resolve({ did: params.issuerDid }); + + let signerDidDoc; + if (params.issuerDidDoc) { + console.log('Got issuerDID doc so no need to resolve'); + signerDidDoc = params.issuerDidDoc; + } else { + console.log('Did not get issuerDID doc, need to resolve'); + signerDidDoc = (await this.hsDid.resolve({ did: params.issuerDid })).didDocument; + } + + if (signerDidDoc === null || signerDidDoc === undefined) + throw new Error('HID-SSI-SDK:: Error: Could not resolve issuerDid = ' + params.issuerDid); + + const publicKeyId = params.verificationMethodId; + const publicKeyVerMethod: VerificationMethod = signerDidDoc['verificationMethod'].find( + (x) => x.id == publicKeyId + ) as VerificationMethod; + + if (!publicKeyVerMethod) { + throw new Error( + 'HID-SSI-SDK:: Error: Could not find verification method for id = ' + params.verificationMethodId + ); + } + const keyPair = await BabyJubJubKeys2021.fromKeys({ + privateKeyMultibase: params.privateKeyMultibase, + publicKeyMultibase: publicKeyVerMethod.publicKeyMultibase as string, + options: { + id: publicKeyVerMethod.id, + controller: publicKeyVerMethod.controller, + }, + }); + + const suite = new BabyJubJubSignature2021Suite({ + verificationMethod: publicKeyId, + key: keyPair, + }); + + /// Before we issue the credential the credential status has to be added + /// for that we will call RegisterCredentialStatus RPC + // Let us generate credentialHash first + + // generating hash using merkelroot hash + + const merkelizerObj = await Merklizer.merklizeJSONLD(JSON.stringify(params.credential), { + documentLoader, + }); + + let credentialHash = await merkelizerObj.mt.root(); + credentialHash = Buffer.from(credentialHash.bytes).toString('hex'); + + const credentialStatus: CredentialStatus = { + '@context': [constant.VC.CREDENTIAL_STATUS_CONTEXT, constant.DID_BabyJubJubKey2021.BABYJUBJUBSIGNATURE], + id: params.credential.id, + issuer: params.credential.issuer, + issuanceDate: params.credential.issuanceDate, + remarks: 'Credential is active', + credentialMerkleRootHash: credentialHash, + }; + + const credProof = await this._jsonLdSign({ + credentialStatus, + privateKeyMultibase: params.privateKeyMultibase, + verificationMethodId: params.verificationMethodId, + publicKeyMultibase: publicKeyVerMethod.publicKeyMultibase as string, + }); + + let issuerDID; + if (params.issuerDidDoc) { + console.log('Got issuerDID doc so no need to resolve'); + issuerDID = params.issuerDidDoc; + } else { + console.log('Did not get issuerDID doc, need to resolve'); + issuerDID = (await this.hsDid.resolve({ did: params.credential.issuer })).didDocument; + } + + if (issuerDID === null || issuerDID === undefined) + throw new Error('Could not resolve issuerDid = ' + params.credential.issuer); + const credIssuerDidDoc: Did = issuerDID as Did; + const credIssuerController = credIssuerDidDoc.controller as string[]; + if (!credIssuerController.includes(params.issuerDid)) { + throw new Error(params.issuerDid + ' is not a controller of ' + params.credential.issuer); + } + + /// RegisterCRedeRPC + const signedVC = await jssig.sign(params.credential, { + purpose: new purposes.AssertionProofPurpose({ + controller: { + '@context': ['https://www.w3.org/ns/did/v1'], + id: issuerDID.id, + assertionMethod: issuerDID.assertionMethod, + }, + }), + suite, + documentLoader, + }); + let credentialStatusRegistrationResult: DeliverTxResponse; + if (params.registerCredential) { + credentialStatusRegistrationResult = await this.credStatusRPC.registerCredentialStatus( + credentialStatus, + credProof + ); + + if (!credentialStatusRegistrationResult || credentialStatusRegistrationResult.code != 0) { + throw new Error( + 'HID-SSI-SDK:: Error while issuing the credential error = ' + credentialStatusRegistrationResult.rawLog + ); + } + return { + signedCredential: signedVC, + credentialStatus, + credentialStatusProof: credProof, + credentialStatusRegistrationResult, + }; + } + + return { signedCredential: signedVC, credentialStatus, credentialStatusProof: credProof }; + } + + // Ref: https://github.com/digitalbazaar/vc-js/blob/44ca660f62ad3569f338eaaaecb11a7b09949bd2/lib/vc.js#L251 + /** + * Verfies signed/issued credential + * @params + * - params.credential : Signed Hypersign credentail document of type IVerifiableCredential + * - params.issuerDid : DID of the issuer + * - params.verificationMethodId : Verifcation Method of Issuer + * @returns {Promise} + */ + public async verify(params: { + credential: IVerifiableCredential; + issuerDid?: string; + issuerDidDocument?: Did; + verificationMethodId: string; + }): Promise { + if (!params.credential) { + throw new Error('HID-SSI-SDK:: params.credential is required to verify credential'); + } + + if (!params.credential.proof) { + throw new Error('HID-SSI-SDK:: params.credential.proof is required to verify credential'); + } + + if (!params.verificationMethodId) { + throw new Error('HID-SSI-SDK:: Error: params.verificationMethodId is required to verify credential'); + } + + // if (!params.issuerDid) { + // throw new Error('HID-SSI-SDK:: Error: params.issuerDid is required to verify credential'); + // } + + if (!params.issuerDid && !params.issuerDidDocument) { + throw new Error( + 'HID-SSI-SDK:: Error: params.issuerDid or params.issuerDidDocument is required to verify credential' + ); + } + + let issuerDID; + if (params.issuerDid) { + const { didDocument } = await this.hsDid.resolve({ did: params.issuerDid }); + issuerDID = didDocument; + } else { + issuerDID = params.issuerDidDocument; + } + + const issuerDidDoc: Did = issuerDID as Did; + const publicKeyId = params.verificationMethodId; + const publicKeyVerMethod: VerificationMethod = (issuerDidDoc.verificationMethod as VerificationMethod[]).find( + (x) => x.id == publicKeyId + ) as VerificationMethod; + + const keyPair = await BabyJubJubKeys2021.fromKeys({ + publicKeyMultibase: publicKeyVerMethod.publicKeyMultibase as string, + options: { + id: publicKeyVerMethod.id, + controller: publicKeyVerMethod.controller, + }, + }); + const suite = new BabyJubJubSignature2021Suite({ + verificationMethod: publicKeyId, + key: keyPair, + }); + + /* eslint-disable */ + const thats = this; + /* eslint-enable */ + + const result = await jssig.verify(params.credential, { + purpose: new purposes.AssertionProofPurpose({ + controller: { + '@context': ['https://www.w3.org/ns/did/v1'], + id: issuerDID.id, + assertionMethod: issuerDID.assertionMethod, + }, + }), + suite, + documentLoader, + }); + + const statusCheck = await thats.checkCredentialStatus({ credentialId: params.credential.id }); + result.statusResult = statusCheck; + + return result; + } + + /** + * Resolves credential status from Hypersign Blokchain + * @params + * - params.credentialId : Verifiable credential id + * @returns {Promise} + */ + public async resolveCredentialStatus(params: { credentialId: string }): Promise { + if (!params || !params.credentialId) + throw new Error('HID-SSI-SDK:: Error: params.credentialId is required to resolve credential status'); + let credentialStatus = {} as CredentialStatusState; + if (!this.credStatusRPC) { + throw new Error( + 'HID-SSI-SDK:: Error: HypersignVerifiableCred is not instantiated with Offlinesigner or not initialized' + ); + } + credentialStatus = await this.credStatusRPC.resolveCredentialStatus(params.credentialId); + const response = { + ...(credentialStatus.credentialStatusDocument as CredentialStatusDocument), + proof: credentialStatus.credentialStatusProof as CredentialProof, + }; + return response; + } + + /** + * Update credential status in blockchain Hypersign Blokchain + * @params + * - params.credentialStatus : Status of the credential of type CredentialStatus + * - params.issuerDid : DID of the issuer + * - params.verificationMethodId : verificationMethodId + * - params.privateKeyMultibase : privateKey of the issuer + * - params.status : Status LIVE/REVOKE/SUSPENDED + * - params.statusReason : Reason for the status change + * @returns {Promise} + */ + public async updateCredentialStatus(params: { + credentialStatus: CredentialStatus; + issuerDid: string; + verificationMethodId: string; // vermethod of issuer for assestion + privateKeyMultibase: string; + status: string; + statusReason?: string; + }): Promise { + if (!params.verificationMethodId) { + throw new Error('HID-SSI-SDK:: Error: params.verificationMethodId is required to update credential status'); + } + + if (!params.credentialStatus) { + throw new Error('HID-SSI-SDK:: Error: params.credentialStatus is required to update credential status'); + } + + if (!params.privateKeyMultibase) { + throw new Error('HID-SSI-SDK:: Error: params.privateKeyMultibase is required to update credential status'); + } + + if (!params.issuerDid) { + throw new Error('HID-SSI-SDK:: Error: params.issuerDid is required to update credential status'); + } + if (!params.status) { + throw new Error('HID-SSI-SDK:: Error: params.status is required to update credential status'); + } + if (!this.credStatusRPC) { + throw new Error( + 'HID-SSI-SDK:: Error: HypersignVerifiableCredential class is not instantiated with Offlinesigner or have not been initilized' + ); + } + + const { didDocument: signerDidDoc } = await this.hsDid.resolve({ did: params.issuerDid }); + if (!signerDidDoc) throw new Error('Could not resolve issuerDid = ' + params.issuerDid); + + // TODO: take verification method from params + const publicKeyId = params.verificationMethodId; // TODO: bad idea - should not hardcode it. + const publicKeyVerMethod: VerificationMethod = signerDidDoc['verificationMethod'].find( + (x) => x.id == publicKeyId + ) as VerificationMethod; + + /// Before we issue the credential the credential status has to be added + /// for that we will call RegisterCredentialStatus RPC + // Let us generate credentialHash first + const status = await this._toTitleCase(params.status); + if (!Object.values(CredentialStatusEnums).includes(status as CredentialStatusEnums)) { + throw new Error(`HID-SSI-SDK:: Error: params.status is invalid`); + } + const claim = params.credentialStatus; + const credentialStatus: CredentialStatus = { + '@context': [constant.VC.CREDENTIAL_STATUS_CONTEXT, constant.DID_BabyJubJubKey2021.BABYJUBJUBSIGNATURE], + id: claim.id, + remarks: params.statusReason ?? VC.CRED_STATUS_REASON_TYPES[params.status], + issuer: params.credentialStatus.issuer, + issuanceDate: params.credentialStatus.issuanceDate, + credentialMerkleRootHash: params.credentialStatus.credentialMerkleRootHash, + }; + if (status === VC.CRED_STATUS_TYPES.REVOKED) { + credentialStatus['revoked'] = true; + } else if (status === VC.CRED_STATUS_TYPES.SUSPENDED) { + credentialStatus['suspended'] = true; + } + + const proofValue = await this._jsonLdSign({ + credentialStatus, + privateKeyMultibase: params.privateKeyMultibase, + verificationMethodId: params.verificationMethodId, + publicKeyMultibase: publicKeyVerMethod.publicKeyMultibase as string, + }); + const { didDocument: issuerDID } = await this.hsDid.resolve({ did: params.credentialStatus.issuer as string }); + const issuerDidDoc: Did = issuerDID as Did; + const issuerDidDocController = issuerDidDoc.controller as string[]; + const verificationMethodController = params.verificationMethodId.split('#')[0]; + + if (!issuerDidDocController.includes(verificationMethodController)) { + throw new Error('HID-SSI-SDK:: Error: params.verificationMethodId does not belong to issuerDid'); + } + + const { didDocument: controllerDidDoc } = await this.hsDid.resolve({ did: verificationMethodController }); + if (!controllerDidDoc) + throw new Error('HID-SSI-SDK:: Error: params.verificationMethodId does not belong to issuerDid'); + + /// UpdateCredRPC + const resp: DeliverTxResponse = await this.credStatusRPC.updateCredentialStatus(credentialStatus, proofValue); + + if (!resp || resp.code != 0) { + throw new Error('HID-SSI-SDK:: Error while revoking the credential error = ' + resp.rawLog); + } + + return resp; + } + + /** + * Check status of credential on Hypersign Chain + * @param + * - params.credentialId : Credential Id + * @returns {Promise<{ verified: boolean }>} + */ + + public async checkCredentialStatus(params: { credentialId: string }): Promise<{ verified: boolean }> { + if (!params || !params.credentialId) + throw new Error('HID-SSI-SDK:: Error: params.credentialId is required to resolve credential status'); + + const { credentialId } = params; + let credentialStatus = {} as CredentialStatusState; + if (!this.credStatusRPC) { + throw new Error('HID-SSI-SDK:: Error: HypersignVerifiableCred is not instantiated with Offlinesigner'); + } + credentialStatus = await this.credStatusRPC.resolveCredentialStatus(credentialId); + if (!credentialStatus) { + throw new Error('HID-SSI-SDK:: Error: while checking credential status of credentialID ' + credentialId); + } + // const claim: Claim = credentialStatus.claim as Claim; + const { remarks: statusReason } = credentialStatus.credentialStatusDocument as CredentialStatus; + let currentStatus; + /// TODO: probably we should also verify the credential HASH by recalculating the hash of the crdential and + // matching with credentialHash property. + // const { credentialHash } = credentialStatus; + if (!credentialStatus.credentialStatusDocument?.revoked && !credentialStatus.credentialStatusDocument?.suspended) { + currentStatus = VC.CRED_STATUS_TYPES.LIVE; + } + if (currentStatus != VC.CRED_STATUS_TYPES.LIVE) { + console.log('WARN: Credential status is not LIVE, currentStatus ' + currentStatus); + console.log('WARN: Status reason is ' + statusReason); + return { verified: false }; + } + + return { verified: true }; + } + + /** + * Register credential status on Hypersign Chain + * @param + * - params.credentialStatus : Credential status + * - params.credentialStatusProof : Status proof of the credential + * @returns {Promise<{ transactionHash: string }>} + */ + public async registerCredentialStatus(params: { + credentialStatus: CredentialStatus; + credentialStatusProof: CredentialProof; + }): Promise<{ transactionHash: string }> { + const { credentialStatus, credentialStatusProof } = params; + if (!credentialStatus || !credentialStatusProof) + throw new Error( + 'HID-SSI-SDK:: Error: credentialStatus and credentialStatusProof are required to register credential status' + ); + + if (!this.credStatusRPC && !this.credentialApiService) { + throw new Error( + 'HID-SSI-SDK:: Error: HypersignVerifiableCredential class is not instantiated with Offlinesigner or have not been initilized with entityApiSecret' + ); + } + + let resp = {} as { transactionHash: string }; + if (this.credStatusRPC) { + const result: DeliverTxResponse = await this.credStatusRPC.registerCredentialStatus( + credentialStatus, + credentialStatusProof + ); + if (!result || result.code != 0) { + throw new Error('HID-SSI-SDK:: Error while issuing the credential error = ' + result.rawLog); + } + resp.transactionHash = result.transactionHash; + } else if (this.credentialApiService) { + resp = await this.credentialApiService.registerCredentialStatus({ + credentialStatus, + credentialStatusProof, + namespace: this.namespace, + }); + } + return resp; + } + + /** + * Generate transaction message + * @param + * - params.credentialStatus : Credential status + * - params.credentialStatusProof : Status proof of the credential + * @returns {Promise<{typeUrl: string, value: MsgRegisterCredentialStatus}>} + */ + public async generateRegisterCredentialStatusTxnMessage(credentialStatus: CredentialStatus, proof: CredentialProof) { + if (!credentialStatus || !proof) + throw new Error('HID-SSI-SDK:: Error: credentialStatus and proof are required to register credential status'); + + if (!this.credStatusRPC) { + throw new Error( + 'HID-SSI-SDK:: Error: HypersignVerifiableCredential class is not instantiated with Offlinesigner or have not been initilized' + ); + } + const txnMessage = await this.credStatusRPC.generateCredentialStatusTxnMessage(credentialStatus, proof); + + return txnMessage; + } + /** + * Register multiple credential status + * @param + * - params.txnMessage : Array of transaction message + * @returns {Promise} + */ + + public async registerCredentialStatusTxnBulk(txnMessage: []) { + if (!txnMessage || txnMessage.length <= 0) + throw new Error('HID-SSI-SDK:: Error: txnMessage is required to register credential status'); + + if (!this.credStatusRPC) { + throw new Error( + 'HID-SSI-SDK:: Error: HypersignVerifiableCredential class is not instantiated with Offlinesigner or have not been initilized' + ); + } + + const resp: DeliverTxResponse = await this.credStatusRPC.registerCredentialStatusBulk(txnMessage); + if (!resp || resp.code != 0) { + throw new Error('HID-SSI-SDK:: Error while issuing the credential error = ' + resp.rawLog); + } + return resp; + } + + public async generateSeletiveDisclosure(param: { + verifiableCredential: IVerifiableCredential; + frame: object; + verificationMethodId: string; + issuerDid: string; + }) { + if (!param.verifiableCredential) { + throw new Error('HID-SSI-SDK:: verifiableCredential is required'); + } + + if (!param.frame) { + throw new Error('HID-SSI-SDK:: frame is required'); + } + if (!param.verificationMethodId) { + throw new Error('HID-SSI-SDK:: verificationMethodId is required'); + } + + if (!param.issuerDid) { + throw new Error('HID-SSI-SDK:: issuerDid is required'); + } + + param.frame['@context'] = param.verifiableCredential['@context']; + const { didDocument: signerDidDoc } = await this.hsDid.resolve({ did: param.issuerDid }); + const credIssuerDidDoc: Did = signerDidDoc as Did; + const vm = credIssuerDidDoc.verificationMethod?.find((vm) => vm.id == param.verificationMethodId); + const suite = BabyJubJubKeys2021.fromKeys({ + publicKeyMultibase: vm?.publicKeyMultibase as string, + options: { + id: param.verificationMethodId, + controller: param.issuerDid, + }, + }); + + const verifyCredential = await this.verify({ + credential: param.verifiableCredential, + issuerDid: param.issuerDid, + verificationMethodId: param.verificationMethodId, + }); + + if (!verifyCredential.verified == true) { + throw new Error('proofDocument cannot be verified'); + } + + return await deriveProof(param.verifiableCredential, param.frame, { + suite, + documentLoader, + }); + } +} diff --git a/src/credential/credRPC.ts b/src/credential/credRPC.ts index 4990f27..f597eb9 100644 --- a/src/credential/credRPC.ts +++ b/src/credential/credRPC.ts @@ -10,12 +10,19 @@ import { SigningStargateClient, DeliverTxResponse } from '@cosmjs/stargate'; import axios from 'axios'; import { HIDClient } from '../hid/client'; import { ICredentialRPC } from './ICredential'; -import { CredentialStatus, CredentialProof, Credential } from '../../libs/generated/ssi/credential'; +import { + CredentialStatusDocument as CredentialStatus, + CredentialStatusState as Credential, +} from '../../libs/generated/ssi/credential_status'; +import { DocumentProof as CredentialProof } from '../../libs/generated/ssi/proof'; import { OfflineSigner } from '@cosmjs/proto-signing'; +import Utils from '../utils'; +import * as constants from '../constants'; export class CredentialRPC implements ICredentialRPC { public credentialRestEP: string; private hidClient: any; + private nodeRestEp: string; constructor({ offlineSigner, @@ -31,6 +38,7 @@ export class CredentialRPC implements ICredentialRPC { } else { this.hidClient = null; } + this.nodeRestEp = nodeRestEndpoint; this.credentialRestEP = (HIDClient.hidNodeRestEndpoint ? HIDClient.hidNodeRestEndpoint : nodeRestEndpoint) + HYPERSIGN_NETWORK_CREDENTIALSTATUS_PATH; @@ -64,19 +72,30 @@ export class CredentialRPC implements ICredentialRPC { const txMessage = { typeUrl, // Same as above value: generatedProto[HIDRpcEnums.MsgRegisterCredentialStatus].fromPartial({ - credentialStatus, - proof, - creator: HIDClient.getHidWalletAddress(), + credentialStatusDocument: credentialStatus, + credentialStatusProof: proof, + txAuthor: HIDClient.getHidWalletAddress(), }), }; - - const fee = 'auto'; + const amount = await Utils.fetchFee(constants.GAS_FEE_METHODS.Register_Cred_Status, this.nodeRestEp); + const fee = { + amount: [ + { + denom: 'uhid', + amount: amount, + }, + ], + gas: '200000', + }; const hidClient: SigningStargateClient = HIDClient.getHidClient(); const txResult: DeliverTxResponse = await hidClient.signAndBroadcast( HIDClient.getHidWalletAddress(), [txMessage], fee ); + if (txResult.code !== 0) { + throw new Error(`${txResult.rawLog}`); + } return txResult; } @@ -94,12 +113,11 @@ export class CredentialRPC implements ICredentialRPC { const txMessage = { typeUrl, // Same as above value: generatedProto[HIDRpcEnums.MsgRegisterCredentialStatus].fromPartial({ - credentialStatus, - proof, - creator: HIDClient.getHidWalletAddress(), + credentialStatusDocument: credentialStatus, + credentialStatusProof: proof, + txAuthor: HIDClient.getHidWalletAddress(), }), }; - return txMessage; } @@ -107,14 +125,28 @@ export class CredentialRPC implements ICredentialRPC { if (!this.hidClient) { throw new Error('HID-SSI-SDK:: Error: CredentialRPC class is not initialise with offlinesigner'); } - - const fee = 'auto'; + const txLenght = txMessages.length; + const amount = ( + txLenght * parseInt(await Utils.fetchFee(constants.GAS_FEE_METHODS.Register_Cred_Status, this.nodeRestEp)) + ).toString(); + const fee = { + amount: [ + { + denom: 'uhid', + amount: amount, + }, + ], + gas: '200000', + }; const hidClient: SigningStargateClient = HIDClient.getHidClient(); const txResult: DeliverTxResponse = await hidClient.signAndBroadcast( HIDClient.getHidWalletAddress(), txMessages, fee ); + if (txResult.code !== 0) { + throw new Error(`${txResult.rawLog}`); + } return txResult; } @@ -127,8 +159,8 @@ export class CredentialRPC implements ICredentialRPC { if (!response.data) { throw new Error('Could not resolve credential status of credentialId ' + credentialId); } - const credStatus: Credential = response.data.credStatus; - if (!credStatus || !credStatus.claim || !credStatus.proof) { + const credStatus: Credential = response.data.credentialStatus; + if (!credStatus || !credStatus.credentialStatusDocument || !credStatus.credentialStatusProof) { throw new Error('No credential status found. Probably invalid credentialId'); } return credStatus; @@ -141,10 +173,54 @@ export class CredentialRPC implements ICredentialRPC { credentialHash: '', proof: null, } as any as Credential; - if (!credStatus || !credStatus.claim || !credStatus.proof) { + if (!credStatus || !credStatus.credentialStatusDocument || !credStatus.credentialStatusProof) { throw new Error('No credential status found. Probably invalid credentialId'); } return credStatus; } } + async updateCredentialStatus(credentialStatus: CredentialStatus, proof: CredentialProof): Promise { + if (!credentialStatus) { + throw new Error('CredentialStatus must be passed as a param while registerting credential status'); + } + + if (!proof) { + throw new Error('Proof must be passed as a param while registering crdential status'); + } + + if (!this.hidClient) { + throw new Error('HID-SSI-SDK:: Error: CredentialRPC class is not initialise with offlinesigner'); + } + + const typeUrl = `${HID_COSMOS_MODULE}.${HIDRpcEnums.MsgUpdateCredentialStatus}`; + + const txMessage = { + typeUrl, + value: generatedProto[HIDRpcEnums.MsgUpdateCredentialStatus].fromPartial({ + credentialStatusDocument: credentialStatus, + credentialStatusProof: proof, + txAuthor: HIDClient.getHidWalletAddress(), + }), + }; + const amount = await Utils.fetchFee(constants.GAS_FEE_METHODS.Update_Cred_Status, this.nodeRestEp); + const fee = { + amount: [ + { + denom: 'uhid', + amount: amount, + }, + ], + gas: '200000', + }; + const hidClient: SigningStargateClient = HIDClient.getHidClient(); + const txResult: DeliverTxResponse = await hidClient.signAndBroadcast( + HIDClient.getHidWalletAddress(), + [txMessage], + fee + ); + if (txResult.code !== 0) { + throw new Error(`${txResult.rawLog}`); + } + return txResult; + } } diff --git a/src/credential/vc.ts b/src/credential/vc.ts index 4de5e31..63f57e8 100644 --- a/src/credential/vc.ts +++ b/src/credential/vc.ts @@ -3,30 +3,50 @@ * All rights reserved. * Author: Hypermine Core Team */ +import jssig from 'jsonld-signatures'; import { purposes } from 'jsonld-signatures'; -import vc from 'vc-js'; import Utils from '../utils'; import HypersignSchema from '../schema/schema'; -import { Schema, SchemaProperty } from '../../libs/generated/ssi/schema'; +import { CredentialSchemaProperty as SchemaProperty } from '../../libs/generated/ssi/credential_schema'; import HypersignDID from '../did/did'; -import { Did, VerificationMethod } from '../../libs/generated/ssi/did'; +import { DidDocument as Did, VerificationMethod } from '../../libs/generated/ssi/did'; + +import * as jsonSchemaValidator from '@cfworker/json-schema'; + import { Ed25519VerificationKey2020 } from '@digitalbazaar/ed25519-verification-key-2020'; + import { Ed25519Signature2020 } from '@digitalbazaar/ed25519-signature-2020'; -const ed25519 = require('@stablelib/ed25519'); +import jsonSigs from 'jsonld-signatures'; +const { AssertionProofPurpose } = jsonSigs.purposes; import { CredentialRPC } from './credRPC'; -import { ICredentialMethods, IVerifiableCredential, ICredentialStatus, ISchema, ICredentialProof } from './ICredential'; -import { VC, DID } from '../constants'; -import { CredentialStatus, CredentialProof, Credential, Claim } from '../../libs/generated/ssi/credential'; +import { + ICredentialMethods, + IVerifiableCredential, + ICredentialStatus, + ISchema, + ICredentialProof, + IResolveCredential, +} from './ICredential'; +import { VC, DID, CredentialStatusEnums } from '../constants'; +import { + CredentialStatusDocument as CredentialStatus, + CredentialStatusDocument, + CredentialStatusState, +} from '../../libs/generated/ssi/credential_status'; +import { DocumentProof as CredentialProof } from '../../libs/generated/ssi/proof'; import { DeliverTxResponse } from '@cosmjs/stargate'; import { OfflineSigner } from '@cosmjs/proto-signing'; -import crypto from 'crypto'; import customLoader from '../../libs/w3cache/v1'; import { EthereumEip712Signature2021 } from 'ethereumeip712signature2021suite'; import { IClientSpec } from '../did/IDID'; import { extendContextLoader } from 'jsonld-signatures'; import { ICredentialService } from '../ssiApi/services/credential/ICredentialApi'; import CredentialApiService from '../ssiApi/services/credential/credential.service'; - +import { IResolveSchema } from '../schema/ISchema'; +import * as constant from '../constants'; +import HypersignBJJVerifiableCredential from './bjjvc'; +import Web3 from 'web3'; +const { Merklizer } = require('@iden3/js-jsonld-merklization'); const documentLoader = extendContextLoader(customLoader); export default class HypersignVerifiableCredential implements ICredentialMethods, IVerifiableCredential { @@ -45,6 +65,7 @@ export default class HypersignVerifiableCredential implements ICredentialMethods private namespace: string; private hsSchema: HypersignSchema; private hsDid: HypersignDID; + public bjjVC: HypersignBJJVerifiableCredential; constructor( params: { @@ -87,20 +108,28 @@ export default class HypersignVerifiableCredential implements ICredentialMethods type: VC.CREDENTAIL_STATUS_TYPE, }; this.proof = {} as ICredentialProof; - } - private async _sign(params: { message: string; privateKeyMultibase: string }): Promise { - const { privateKeyMultibase: privateKeyMultibaseConverted } = - Utils.convertEd25519verificationkey2020toStableLibKeysInto({ - privKey: params.privateKeyMultibase, - }); - - // TODO: do proper checck of paramaters - const credentialStatus: CredentialStatus = JSON.parse(params.message); - const credentialBytes = (await CredentialStatus.encode(credentialStatus)).finish(); - // const messageBytes = Buffer.from(params.message); - const signed = ed25519.sign(privateKeyMultibaseConverted, credentialBytes); - return Buffer.from(signed).toString('base64'); + this.bjjVC = new HypersignBJJVerifiableCredential(params); + } + private async _jsonLdSign(params: { + credentialStatus: CredentialStatus; + privateKeyMultibase: string; + verificationMethodId: string; + publicKeyMultibase: string; + }) { + const { credentialStatus, privateKeyMultibase, verificationMethodId } = params; + const keyPair = await Ed25519VerificationKey2020.from({ + id: verificationMethodId, + privateKeyMultibase: privateKeyMultibase, + publicKeyMultibase: params.publicKeyMultibase, + }); + const suite = new Ed25519Signature2020({ key: keyPair }); + const signedCredStatus = await jsonSigs.sign(credentialStatus, { + suite, + purpose: new AssertionProofPurpose(), + documentLoader: customLoader, + }); + return signedCredStatus.proof; } private _dateNow(date?: string): string { @@ -111,14 +140,9 @@ export default class HypersignVerifiableCredential implements ICredentialMethods } } - private _sha256Hash(message: string): string { - const sha256 = crypto.createHash('sha256'); - return sha256.update(message).digest('hex'); - } - private async _getId(): Promise { const uuid = await Utils.getUUID(); - let id; + let id: string | PromiseLike; if (this.namespace && this.namespace != '') { id = `${VC.SCHEME}:${VC.METHOD}:${this.namespace}:${uuid}`; } else { @@ -153,7 +177,7 @@ export default class HypersignVerifiableCredential implements ICredentialMethods } // Check all required propes - const requiredPros: Array = Object.values(schemaProperty.required); + const requiredPros: Array = Object.values(schemaProperty.required as string[]); if (!this._checkIfAllRequiredPropsAreSent(sentPropes, requiredPros)) throw new Error(`${JSON.stringify(requiredPros)} are required properties`); @@ -168,33 +192,39 @@ export default class HypersignVerifiableCredential implements ICredentialMethods // // TODO: https://www.w3.org/TR/vc-data-model/#data-schemas // TODO: handle schemaUrl variable properly later. - private _getCredentialContext = (schemaId: string, schemaProperties: object) => { - const context: any = []; - - let schemaUrl; - if (this.hsSchema && this.hsSchema.schemaRpc) { - schemaUrl = `${this.hsSchema.schemaRpc.schemaRestEp}/${schemaId}:`; - } else { - throw new Error('Error: HypersigSchema object may not be initialized'); - } - - context.push(VC.CREDENTAIL_BASE_CONTEXT); - //context.push(VC.CREDENTAIL_SECURITY_SUITE); - - context.push({ - hs: schemaUrl, - }); - - const props: Array = Object.keys(schemaProperties); - props.forEach((x) => { - const obj = {}; - obj[x] = `hs:${x}`; - context.push(obj); - }); - - return context; - }; - + // private _getCredentialContext = (schemaId: string, schemaProperties: object, schemaName: string) => { + // const context: any = []; + + // let schemaUrl; + // if (this.hsSchema && this.hsSchema.schemaRpc) { + // schemaUrl = `${this.hsSchema.schemaRpc.schemaRestEp}/${schemaId}:`; + // } else { + // throw new Error('Error: HypersigSchema object may not be initialized'); + // } + + // context.push(VC.CREDENTAIL_BASE_CONTEXT); + // // context.push(VC.CREDENTAIL_SECURITY_SUITE); + + // context.push({ + // hs: schemaUrl, + // }); + // context.push({ + // [schemaName]: `hs:${schemaName}`, + // }); + // const props: Array = Object.keys(schemaProperties); + // props.forEach((x) => { + // const obj = {}; + // obj[x] = `hs:${x}`; + // context.push(obj); + // }); + // context.push(VC.CONTEXT_HypersignCredentialStatus2023); + + // return context; + // }; + + private async _toTitleCase(status: string) { + return status.charAt(0).toUpperCase() + status.slice(1).toLowerCase(); + } /** * Initialise the offlinesigner to interact with Hypersign blockchain */ @@ -234,7 +264,7 @@ export default class HypersignVerifiableCredential implements ICredentialMethods expirationDate: string; fields: object; }): Promise { - let schemaDoc: Schema = {} as Schema; + let schemaDoc: IResolveSchema = {} as IResolveSchema; if (params.subjectDid && params.subjectDidDocSigned) { throw new Error('HID-SSI-SDK:: Error: Both subjectDid and subjectDidDoc cannot be passed'); } @@ -249,7 +279,6 @@ export default class HypersignVerifiableCredential implements ICredentialMethods const subjectDid = params.subjectDid; let resolvedsubjectDidDoc; const { didDocument: issuerDidDoc } = await this.hsDid.resolve({ did: issuerDid }); - // if (params.subjectDid) { resolvedsubjectDidDoc = await this.hsDid.resolve({ did: params.subjectDid }); } else if (params.subjectDidDocSigned) { @@ -321,10 +350,15 @@ export default class HypersignVerifiableCredential implements ICredentialMethods const vc: IVerifiableCredential = {} as IVerifiableCredential; - const schemaInternal = schemaDoc.schema as SchemaProperty; - const schemaProperties = JSON.parse(schemaInternal.properties); + // const schemaInternal = schemaDoc.schema as SchemaProperty; + // const schemaProperties = JSON.parse(schemaInternal.properties as string); + // const schemaName = schemaDoc.name as string; // context - vc['@context'] = this._getCredentialContext(params.schemaId, schemaProperties); + // vc['@context'] = this._getCredentialContext(params.schemaId, schemaProperties, schemaName); + vc['@context'] = [VC.CREDENTAIL_BASE_CONTEXT]; + vc['@context'].push(VC.CONTEXT_HypersignCredentialStatus2023); + const JsonSchema = this.hsSchema.vcJsonSchema(schemaDoc); + vc['@context'].push((JsonSchema as any).$metadata.jsonLdContext); /// TODO: need to implement this properly vc.id = await this._getId(); @@ -332,19 +366,33 @@ export default class HypersignVerifiableCredential implements ICredentialMethods // Type vc.type = []; vc.type.push('VerifiableCredential'); - vc.type.push(schemaDoc.name); + vc.type.push(schemaDoc.name as string); vc.expirationDate = this._dateNow(params.expirationDate); vc.issuanceDate = this._dateNow(); // TODO: need to remove this. vc.issuer = issuerDid; vc.credentialSubject = {}; - vc.credentialSubject = { - ...this._getCredentialSubject(schemaDoc.schema as SchemaProperty, params.fields), - }; + // ToDo: Implement Schema validation (JSON Schema Validator) + + const validator = new jsonSchemaValidator.Validator(JsonSchema as any, '2020-12', true); + + const result = validator.validate({ + credentialSubject: { ...params.fields }, + }); + + if (!result.valid) { + throw result.errors; + } + + // vc.credentialSubject = { + // ...this._getCredentialSubject(schemaDoc.schema as SchemaProperty, params.fields), + // }; + + vc.credentialSubject = params.fields; vc.credentialSubject['id'] = subjectDid && subjectDid != undefined ? subjectDid : subjectDidDoc.id; vc.credentialSchema = { - id: schemaDoc.id, + id: schemaDoc.id as string, type: this.credentialSchema.type, }; @@ -355,7 +403,6 @@ export default class HypersignVerifiableCredential implements ICredentialMethods id: this.credStatusRPC.credentialRestEP + '/' + vc.id, // TODO: Will add credentialStatus path when issueing this crdential type: this.credentialStatus.type, } as ICredentialStatus; - return vc; } @@ -415,8 +462,7 @@ export default class HypersignVerifiableCredential implements ICredentialMethods if (signerDidDoc === null || signerDidDoc === undefined) throw new Error('HID-SSI-SDK:: Error: Could not resolve issuerDid = ' + params.issuerDid); - // TODO: take verification method from params - const publicKeyId = params.verificationMethodId; // TODO: bad idea - should not hardcode it. + const publicKeyId = params.verificationMethodId; const publicKeyVerMethod: VerificationMethod = signerDidDoc['verificationMethod'].find( (x) => x.id == publicKeyId ) as VerificationMethod; @@ -426,13 +472,6 @@ export default class HypersignVerifiableCredential implements ICredentialMethods 'HID-SSI-SDK:: Error: Could not find verification method for id = ' + params.verificationMethodId ); } - - const convertedKeyPair = Utils.convertedStableLibKeysIntoEd25519verificationkey2020({ - publicKey: publicKeyVerMethod.publicKeyMultibase, - }); - - publicKeyVerMethod['publicKeyMultibase'] = convertedKeyPair.publicKeyMultibase; - const keyPair = await Ed25519VerificationKey2020.from({ privateKeyMultibase: params.privateKeyMultibase, ...publicKeyVerMethod, @@ -446,63 +485,59 @@ export default class HypersignVerifiableCredential implements ICredentialMethods /// Before we issue the credential the credential status has to be added /// for that we will call RegisterCredentialStatus RPC // Let us generate credentialHash first - const credentialHash = this._sha256Hash(JSON.stringify(params.credential)); + + // generating hash using merkelroot hash + + const merkelizerObj = await Merklizer.merklizeJSONLD(JSON.stringify(params.credential), { + documentLoader, + }); + let credentialHash = await merkelizerObj.mt.root(); + credentialHash = Buffer.from(credentialHash.bytes).toString('hex'); const credentialStatus: CredentialStatus = { - claim: { - id: params.credential.id, - currentStatus: VC.CRED_STATUS_TYPES.LIVE, - statusReason: 'Credential is active', - }, + '@context': [ + constant.VC.CREDENTIAL_STATUS_CONTEXT, + constant.DID_Ed25519VerificationKey2020.DID_Ed25519_CONTEXT_2020, + ], + id: params.credential.id, issuer: params.credential.issuer, issuanceDate: params.credential.issuanceDate, - expirationDate: params.credential.expirationDate, - credentialHash, + remarks: 'Credential is active', + credentialMerkleRootHash: credentialHash, }; - - const proofValue = await this._sign({ - message: JSON.stringify(credentialStatus), + const credProof = await this._jsonLdSign({ + credentialStatus, privateKeyMultibase: params.privateKeyMultibase, + verificationMethodId: params.verificationMethodId, + publicKeyMultibase: publicKeyVerMethod.publicKeyMultibase as string, }); - - // check params.issuer is a controller of params.credential.issuer - const { didDocument: issuerDID } = await this.hsDid.resolve({ did: params.credential.issuer }); if (issuerDID === null || issuerDID === undefined) throw new Error('Could not resolve issuerDid = ' + params.credential.issuer); const credIssuerDidDoc: Did = issuerDID as Did; - const credIssuerController = credIssuerDidDoc.controller; + const credIssuerController = credIssuerDidDoc.controller as string[]; if (!credIssuerController.includes(params.issuerDid)) { throw new Error(params.issuerDid + ' is not a controller of ' + params.credential.issuer); } - // const issuerDidDoc: Did = issuerDID as Did; - // const issuerPublicKeyId = params.verificationMethodId; - // const issuerPublicKeyVerMethod: VerificationMethod = issuerDidDoc.verificationMethod.find( - // (x) => x.id == issuerPublicKeyId - // ) as VerificationMethod; - - const issuerPublicKeyVerMethod: VerificationMethod = publicKeyVerMethod; - - const proof: CredentialProof = { - type: VC.VERIFICATION_METHOD_TYPE, - created: this._dateNow(), - updated: this._dateNow(), - verificationMethod: issuerPublicKeyVerMethod.id, - proofValue, - proofPurpose: VC.PROOF_PURPOSE, - }; - /// RegisterCRedeRPC - const signedVC = await vc.issue({ - credential: params.credential, + const signedVC = await jssig.sign(params.credential, { + purpose: new purposes.AssertionProofPurpose({ + controller: { + '@context': ['https://www.w3.org/ns/did/v1'], + id: issuerDID.id, + assertionMethod: issuerDID.assertionMethod, + }, + }), suite, documentLoader, }); - let credentialStatusRegistrationResult: DeliverTxResponse; if (params.registerCredential) { - credentialStatusRegistrationResult = await this.credStatusRPC.registerCredentialStatus(credentialStatus, proof); + credentialStatusRegistrationResult = await this.credStatusRPC.registerCredentialStatus( + credentialStatus, + credProof + ); if (!credentialStatusRegistrationResult || credentialStatusRegistrationResult.code != 0) { throw new Error( @@ -513,12 +548,12 @@ export default class HypersignVerifiableCredential implements ICredentialMethods return { signedCredential: signedVC, credentialStatus, - credentialStatusProof: proof, + credentialStatusProof: credProof, credentialStatusRegistrationResult, }; } - return { signedCredential: signedVC, credentialStatus, credentialStatusProof: proof }; + return { signedCredential: signedVC, credentialStatus, credentialStatusProof: credProof }; } // Ref: https://github.com/digitalbazaar/vc-js/blob/44ca660f62ad3569f338eaaaecb11a7b09949bd2/lib/vc.js#L251 @@ -554,17 +589,10 @@ export default class HypersignVerifiableCredential implements ICredentialMethods const { didDocument: issuerDID } = await this.hsDid.resolve({ did: params.issuerDid }); const issuerDidDoc: Did = issuerDID as Did; const publicKeyId = params.verificationMethodId; - const publicKeyVerMethod: VerificationMethod = issuerDidDoc.verificationMethod.find( + const publicKeyVerMethod: VerificationMethod = (issuerDidDoc.verificationMethod as VerificationMethod[]).find( (x) => x.id == publicKeyId ) as VerificationMethod; - // TODO: Get rid of this hack later. - // Convert 45 byte publick key into 48 - const { publicKeyMultibase } = Utils.convertedStableLibKeysIntoEd25519verificationkey2020({ - publicKey: publicKeyVerMethod.publicKeyMultibase, - }); - publicKeyVerMethod.publicKeyMultibase = publicKeyMultibase; - const assertionController = { '@context': DID.CONTROLLER_CONTEXT, id: issuerDidDoc.id, @@ -583,16 +611,21 @@ export default class HypersignVerifiableCredential implements ICredentialMethods /* eslint-disable */ const that = this; /* eslint-enable */ - const result = await vc.verifyCredential({ - credential: params.credential, - controller: assertionController, + const result = await jssig.verify(params.credential, { + purpose: new purposes.AssertionProofPurpose({ + controller: { + '@context': ['https://www.w3.org/ns/did/v1'], + id: issuerDID.id, + assertionMethod: issuerDID.assertionMethod, + }, + }), suite, documentLoader, - checkStatus: async function (options) { - return await that.checkCredentialStatus({ credentialId: options.credential.id }); - }, }); + const statusCheck = await that.checkCredentialStatus({ credentialId: params.credential.id }); + result.statusResult = statusCheck; + return result; } @@ -600,19 +633,23 @@ export default class HypersignVerifiableCredential implements ICredentialMethods * Resolves credential status from Hypersign Blokchain * @params * - params.credentialId : Verifiable credential id - * @returns {Promise} + * @returns {Promise} */ - public async resolveCredentialStatus(params: { credentialId: string }): Promise { + public async resolveCredentialStatus(params: { credentialId: string }): Promise { if (!params || !params.credentialId) throw new Error('HID-SSI-SDK:: Error: params.credentialId is required to resolve credential status'); - let credentialStatus = {} as CredentialStatus; + let credentialStatus = {} as CredentialStatusState; if (!this.credStatusRPC) { throw new Error( 'HID-SSI-SDK:: Error: HypersignVerifiableCred is not instantiated with Offlinesigner or not initialized' ); } credentialStatus = await this.credStatusRPC.resolveCredentialStatus(params.credentialId); - return credentialStatus; + const response = { + ...(credentialStatus.credentialStatusDocument as CredentialStatusDocument), + proof: credentialStatus.credentialStatusProof as CredentialProof, + }; + return response; } /** @@ -633,7 +670,11 @@ export default class HypersignVerifiableCredential implements ICredentialMethods privateKeyMultibase: string; status: string; statusReason?: string; - }): Promise { + readonly?: boolean; + }): Promise { + if (!params.readonly) { + params.readonly = false; + } if (!params.verificationMethodId) { throw new Error('HID-SSI-SDK:: Error: params.verificationMethodId is required to update credential status'); } @@ -652,7 +693,6 @@ export default class HypersignVerifiableCredential implements ICredentialMethods if (!params.status) { throw new Error('HID-SSI-SDK:: Error: params.status is required to update credential status'); } - if (!this.credStatusRPC) { throw new Error( 'HID-SSI-SDK:: Error: HypersignVerifiableCredential class is not instantiated with Offlinesigner or have not been initilized' @@ -668,12 +708,6 @@ export default class HypersignVerifiableCredential implements ICredentialMethods (x) => x.id == publicKeyId ) as VerificationMethod; - const convertedKeyPair = Utils.convertedStableLibKeysIntoEd25519verificationkey2020({ - publicKey: publicKeyVerMethod.publicKeyMultibase, - }); - - publicKeyVerMethod['publicKeyMultibase'] = convertedKeyPair.publicKeyMultibase; - const keyPair = await Ed25519VerificationKey2020.from({ privateKeyMultibase: params.privateKeyMultibase, ...publicKeyVerMethod, @@ -687,28 +721,37 @@ export default class HypersignVerifiableCredential implements ICredentialMethods /// Before we issue the credential the credential status has to be added /// for that we will call RegisterCredentialStatus RPC // Let us generate credentialHash first - params.status = params.status.toUpperCase(); - const claim: Claim = params.credentialStatus.claim as Claim; + const status = await this._toTitleCase(params.status); + if (!Object.values(CredentialStatusEnums).includes(status as CredentialStatusEnums)) { + throw new Error(`HID-SSI-SDK:: Error: params.status is invalid`); + } + const claim = params.credentialStatus; const credentialStatus: CredentialStatus = { - claim: { - id: claim.id, - currentStatus: VC.CRED_STATUS_TYPES[params.status], - statusReason: params.statusReason ? params.statusReason : VC.CRED_STATUS_REASON_TYPES[params.status], - }, + '@context': [ + constant.VC.CREDENTIAL_STATUS_CONTEXT, + constant.DID_Ed25519VerificationKey2020.DID_Ed25519_CONTEXT_2020, + ], + id: claim.id, + remarks: params.statusReason ?? VC.CRED_STATUS_REASON_TYPES[params.status], issuer: params.credentialStatus.issuer, issuanceDate: params.credentialStatus.issuanceDate, - expirationDate: params.credentialStatus.expirationDate, - credentialHash: params.credentialStatus.credentialHash, + credentialMerkleRootHash: params.credentialStatus.credentialMerkleRootHash, }; + if (status === VC.CRED_STATUS_TYPES.REVOKED) { + credentialStatus['revoked'] = true; + } else if (status === VC.CRED_STATUS_TYPES.SUSPENDED) { + credentialStatus['suspended'] = true; + } - const proofValue = await this._sign({ - message: JSON.stringify(credentialStatus), + const proofValue = await this._jsonLdSign({ + credentialStatus, privateKeyMultibase: params.privateKeyMultibase, + verificationMethodId: params.verificationMethodId, + publicKeyMultibase: publicKeyVerMethod.publicKeyMultibase as string, }); - - const { didDocument: issuerDID } = await this.hsDid.resolve({ did: params.credentialStatus.issuer }); + const { didDocument: issuerDID } = await this.hsDid.resolve({ did: params.credentialStatus.issuer as string }); const issuerDidDoc: Did = issuerDID as Did; - const issuerDidDocController = issuerDidDoc.controller; + const issuerDidDocController = issuerDidDoc.controller as string[]; const verificationMethodController = params.verificationMethodId.split('#')[0]; if (!issuerDidDocController.includes(verificationMethodController)) { @@ -718,25 +761,15 @@ export default class HypersignVerifiableCredential implements ICredentialMethods const { didDocument: controllerDidDoc } = await this.hsDid.resolve({ did: verificationMethodController }); if (!controllerDidDoc) throw new Error('HID-SSI-SDK:: Error: params.verificationMethodId does not belong to issuerDid'); - const didDocofController = controllerDidDoc as Did; - - const issuerPublicKeyId = params.verificationMethodId; - const issuerPublicKeyVerMethod: VerificationMethod = didDocofController.verificationMethod.find( - (x) => x.id == issuerPublicKeyId - ) as VerificationMethod; - - const proof: CredentialProof = { - type: VC.VERIFICATION_METHOD_TYPE, - created: params.credentialStatus.issuanceDate, - updated: this._dateNow(), - verificationMethod: issuerPublicKeyVerMethod.id, - proofValue, - proofPurpose: VC.PROOF_PURPOSE, - }; + if (params.readonly == true) { + return { + credentialStatus, + proofValue, + }; + } - /// RegisterCRedeRPC - // We use the same RPC (i.e. MsgRegisterCredentialStatus) for register and update of credential status on blockchain - const resp: DeliverTxResponse = await this.credStatusRPC.registerCredentialStatus(credentialStatus, proof); + /// UpdateCredRPC + const resp: DeliverTxResponse = await this.credStatusRPC.updateCredentialStatus(credentialStatus, proofValue); if (!resp || resp.code != 0) { throw new Error('HID-SSI-SDK:: Error while revoking the credential error = ' + resp.rawLog); @@ -757,7 +790,7 @@ export default class HypersignVerifiableCredential implements ICredentialMethods throw new Error('HID-SSI-SDK:: Error: params.credentialId is required to resolve credential status'); const { credentialId } = params; - let credentialStatus = {} as CredentialStatus; + let credentialStatus = {} as CredentialStatusState; if (!this.credStatusRPC) { throw new Error('HID-SSI-SDK:: Error: HypersignVerifiableCred is not instantiated with Offlinesigner'); } @@ -765,12 +798,15 @@ export default class HypersignVerifiableCredential implements ICredentialMethods if (!credentialStatus) { throw new Error('HID-SSI-SDK:: Error: while checking credential status of credentialID ' + credentialId); } - const claim: Claim = credentialStatus.claim as Claim; - const { currentStatus, statusReason } = claim; - + // const claim: Claim = credentialStatus.claim as Claim; + const { remarks: statusReason } = credentialStatus.credentialStatusDocument as CredentialStatus; + let currentStatus; /// TODO: probably we should also verify the credential HASH by recalculating the hash of the crdential and // matching with credentialHash property. // const { credentialHash } = credentialStatus; + if (!credentialStatus.credentialStatusDocument?.revoked && !credentialStatus.credentialStatusDocument?.suspended) { + currentStatus = VC.CRED_STATUS_TYPES.LIVE; + } if (currentStatus != VC.CRED_STATUS_TYPES.LIVE) { console.log('WARN: Credential status is not LIVE, currentStatus ' + currentStatus); console.log('WARN: Status reason is ' + statusReason); @@ -851,7 +887,8 @@ export default class HypersignVerifiableCredential implements ICredentialMethods */ public async registerCredentialStatusTxnBulk(txnMessage: []) { - if (!txnMessage) throw new Error('HID-SSI-SDK:: Error: txnMessage is required to register credential status'); + if (!txnMessage || txnMessage.length <= 0) + throw new Error('HID-SSI-SDK:: Error: txnMessage is required to register credential status'); if (!this.credStatusRPC) { throw new Error( @@ -885,7 +922,8 @@ export default class HypersignVerifiableCredential implements ICredentialMethods issuerDid: string; verificationMethodId: string; type?: string; - web3Obj; + web3Obj?: Web3 | undefined; + privateKey?: string; registerCredential?: boolean; domain?: string; clientSpec?: IClientSpec; @@ -904,8 +942,8 @@ export default class HypersignVerifiableCredential implements ICredentialMethods 'HID-SSI-SDK:: Error: HypersignVerifiableCredential class is not instantiated with Offlinesigner or have not been initilized' ); } - if (!params.web3Obj) { - throw new Error('HID-SSI-SDK:: Error: prams.web3Obj should be passed'); + if (!params.web3Obj && !params.privateKey) { + throw new Error('HID-SSI-SDK:: Error: prams.web3Obj or prams.privateKey should be passed'); } if (params.type == undefined) { params.type = 'Document'; @@ -926,11 +964,23 @@ export default class HypersignVerifiableCredential implements ICredentialMethods 'HID-SSI-SDK:: Error: Could not find verification method for id = ' + params.verificationMethodId ); } - const EthereumEip712Signature2021obj = new EthereumEip712Signature2021({}, params.web3Obj); + let EthereumEip712Signature2021obj: EthereumEip712Signature2021; + if (params.privateKey) { + EthereumEip712Signature2021obj = new EthereumEip712Signature2021({}); + await EthereumEip712Signature2021obj.fromPrivateKey(params.privateKey); + } else { + EthereumEip712Signature2021obj = new EthereumEip712Signature2021({}, params.web3Obj); + } const proof = await EthereumEip712Signature2021obj.createProof({ document: params.credential, - purpose: new purposes.AssertionProofPurpose(), + purpose: new purposes.AssertionProofPurpose({ + controller: { + '@context': ['https://w3id.org/security/v2'], + id: signerDidDoc.id, + assertionMethod: [params.verificationMethodId], + }, + }), verificationMethod: params.verificationMethodId, primaryType: params.type, date: new Date().toISOString(), @@ -944,7 +994,7 @@ export default class HypersignVerifiableCredential implements ICredentialMethods if (issuerDID === null || issuerDID === undefined) throw new Error('Could not resolve issuerDid = ' + params.credential.issuer); const credIssuerDidDoc: Did = issuerDID as Did; - const credIssuerController = credIssuerDidDoc.controller; + const credIssuerController = credIssuerDidDoc.controller as string[]; if (!credIssuerController.includes(params.issuerDid)) { throw new Error(params.issuerDid + ' is not a controller of ' + params.credential.issuer); } @@ -972,7 +1022,6 @@ export default class HypersignVerifiableCredential implements ICredentialMethods credential: IVerifiableCredential; issuerDid: string; verificationMethodId: string; - web3Obj; }): Promise { if (!params.credential) { throw new Error('HID-SSI-SDK:: params.credential is required to verify credential'); @@ -990,20 +1039,23 @@ export default class HypersignVerifiableCredential implements ICredentialMethods throw new Error('HID-SSI-SDK:: Error: params.issuerDid is required to verify credential'); } - if (!params.web3Obj) { - throw new Error('HID-SSI-SDK:: Error: prams.web3Obj should be passed'); - } const { didDocument } = await this.hsDid.resolve({ did: params.issuerDid }); if (didDocument === null || didDocument === undefined) throw new Error('HID-SSI-SDK:: Error: Could not resolve issuerDid = ' + params.issuerDid); - const EthereumEip712Signature2021obj = new EthereumEip712Signature2021({}, params.web3Obj); + const EthereumEip712Signature2021obj = new EthereumEip712Signature2021({}); const { proof } = params.credential; const verificationResult = await EthereumEip712Signature2021obj.verifyProof({ proof: proof, document: params.credential, types: proof.eip712.types, domain: proof.eip712.domain, - purpose: new purposes.AssertionProofPurpose(), + purpose: new purposes.AssertionProofPurpose({ + controller: { + '@context': ['https://w3id.org/security/v2'], + id: didDocument.id, + assertionMethod: [params.verificationMethodId], + }, + }), documentLoader, }); return verificationResult; diff --git a/src/did/IDID.ts b/src/did/IDID.ts index 68d6b93..290ef59 100644 --- a/src/did/IDID.ts +++ b/src/did/IDID.ts @@ -4,9 +4,20 @@ * Author: Hypermine Core Team */ -import { Did as IDidProto, Metadata, VerificationMethod, Service, Did, SignInfo } from '../../libs/generated/ssi/did'; -import { ClientSpec } from '../../libs/generated/ssi/clientSpec'; +import { + DidDocument as IDidProto, + DidDocumentMetadata as Metadata, + VerificationMethod, + Service, + DidDocument, +} from '../../libs/generated/ssi/did'; +import { DocumentProof as SignInfo } from '../../libs/generated/ssi/proof'; import Web3 from 'web3'; +import { + ProofTypes, + VerificationMethodRelationships, + VerificationMethodTypes, +} from '../../libs/generated/ssi/client/enums'; export interface IPublicKey { '@context': string; @@ -15,42 +26,31 @@ export interface IPublicKey { publicKeyBase58: string; } -export enum IVerificationRelationships { - authentication = 'authentication', - assertionMethod = 'assertionMethod', - keyAgreement = 'keyAgreement', - capabilityInvocation = 'capabilityInvocation', - capabilityDelegation = 'capabilityDelegation', -} - -export enum IKeyType { - Ed25519VerificationKey2020 = 'Ed25519VerificationKey2020', - EcdsaSecp256k1VerificationKey2019 = 'EcdsaSecp256k1VerificationKey2019', - EcdsaSecp256k1RecoveryMethod2020 = 'EcdsaSecp256k1RecoveryMethod2020', - X25519KeyAgreementKey2020 = 'X25519KeyAgreementKey2020', - X25519KeyAgreementKeyEIP5630 = 'X25519KeyAgreementKeyEIP5630', -} - export enum IClientSpec { 'eth-personalSign' = 'eth-personalSign', 'cosmos-ADR036' = 'cosmos-ADR036', } - -export interface ExtendedClientSpec extends ClientSpec { +export enum SupportedPurpose { + 'assertionMethod' = 'assertionMethod', + 'authentication' = 'authentication', +} +export interface ExtendedClientSpec { type: IClientSpec; - adr036SignerAddress: string; + adr036SignerAddress?: string; } - export interface ISignInfo { verification_method_id: string; signature: string; clientSpec?: ExtendedClientSpec | undefined; + created: string; + type?: ProofTypes; } export interface IController { '@context': string; id: string; - authentication: Array; + authentication?: Array; + assertionMethod?: Array; } export interface IParams { @@ -91,24 +91,24 @@ export interface IDID { generate(params: { methodSpecificId?: string; publicKeyMultibase: string; - verificationRelationships: IVerificationRelationships[]; - }): Promise; + verificationRelationships: VerificationMethodRelationships[]; + }): Promise; register(params: { - didDocument: Did; + didDocument: DidDocument; privateKeyMultibase?: string; verificationMethodId?: string; signData?: ISignData[]; - }): Promise<{ didDocument: Did; transactionHash: string }>; + }): Promise<{ didDocument: DidDocument; transactionHash: string }>; - resolve(params: { did: string; ed25519verificationkey2020?: boolean }): Promise; + resolve(params: { did: string }): Promise; update(params: { - didDocument: Did; + didDocument: DidDocument; privateKeyMultibase: string; verificationMethodId: string; versionId: string; - }): Promise<{ transactionHash: string }>; + }): Promise<{ transactionHash: string } | { didDocument; signInfos; versionId }>; deactivate(params: { didDocument: object; @@ -119,7 +119,7 @@ export interface IDID { // didAuth sign(params: { - didDocument: Did; + didDocument: DidDocument; privateKeyMultibase: string; challenge: string; domain: string; @@ -128,7 +128,7 @@ export interface IDID { }): Promise; verify(params: { - didDocument: Did; + didDocument: DidDocument; verificationMethodId: string; challenge: string; domain?: string; @@ -136,13 +136,13 @@ export interface IDID { addVerificationMethod(params: { did?: string; - didDocument?: Did; - type: IKeyType; + didDocument?: DidDocument; + type: VerificationMethodTypes; id?: string; controller?: string; publicKeyMultibase?: string; blockchainAccountId?: string; - }): Promise; + }): Promise; createByClientSpec(params: { methodSpecificId: string; @@ -150,40 +150,46 @@ export interface IDID { address: string; chainId: string; clientSpec: IClientSpec; - verificationRelationships?: IVerificationRelationships[]; - }): Promise; + verificationRelationships?: VerificationMethodRelationships[]; + }): Promise; registerByClientSpec(params: { - didDocument: Did; // Ld document + didDocument: DidDocument; // Ld document signInfos: SignInfo[]; - }): Promise<{ didDocument: Did; transactionHash: string }>; + }): Promise<{ didDocument: DidDocument; transactionHash: string }>; updateByClientSpec(params: { - didDocument: Did; + didDocument: DidDocument; versionId: string; signInfos: SignInfo[]; }): Promise<{ transactionHash: string }>; deactivateByClientSpec(params: { - didDocument: Did; + didDocument: DidDocument; signInfos: SignInfo[]; versionId: string; }): Promise<{ transactionHash: string }>; signAndRegisterByClientSpec(params: { - didDocument: Did; + didDocument: DidDocument; address: string; verificationMethodId: string; web3: Web3 | any; clientSpec: IClientSpec; chainId?: string; // only for [cosmos-ADR036] - }): Promise<{ didDocument: Did; transactionHash: string }>; + }): Promise<{ didDocument: DidDocument; transactionHash: string }>; signByClientSpec(params: { - didDocument: Did; + didDocument: DidDocument; clientSpec: IClientSpec; address: string; web3: Web3 | any; - chainId?: string; // only for [cosmos-ADR036] - }): Promise<{ didDocument: Did; signature: string }>; + chainId?: string; // only for [cosmos-ADR036], + verificationMethodId; + }): Promise; + createSignInfos(params: { + didDocument: DidDocument; + privateKeyMultibase: string; + verificationMethodId: string; + }): Promise>; } export interface IDIDResolve { @@ -232,5 +238,5 @@ export interface IDidDocument { export interface ISignData { verificationMethodId: string; privateKeyMultibase: string; - type: IKeyType; + type: VerificationMethodTypes; } diff --git a/src/did/bjjdid.ts b/src/did/bjjdid.ts new file mode 100644 index 0000000..a9919f4 --- /dev/null +++ b/src/did/bjjdid.ts @@ -0,0 +1,920 @@ +/** + * Copyright (c) 2023, Hypermine Pvt. Ltd. + * All rights reserved. + * Author: Hypermine Core Team + */ +import * as constant from '../constants'; +import jsonSigs from 'jsonld-signatures'; +const { AssertionProofPurpose } = jsonSigs.purposes; +import { DIDRpc } from './didRPC'; +import Utils from '../utils'; +import { BabyJubJubKeys2021 } from 'babyjubjub2021'; +import { BabyJubJubSignature2021Suite } from 'babyjubjubsignature2021'; +import { DidDocument as Did, VerificationMethod, Service } from '../../libs/generated/ssi/did'; +import { DocumentProof, DocumentProof as SignInfo } from '../../libs/generated/ssi/proof'; +import Web3 from 'web3'; +import DidApiService from '../ssiApi/services/did/did.service'; +import { IDidApiService } from '../ssiApi/services/did/IDIDApi'; +import jsonld from 'jsonld'; +import { IDID, IDid, IDIDResolve, IDIDRpc, ISignedDIDDocument, IClientSpec, ISignData, ISignInfo } from './IDID'; +import { VerificationMethodRelationships, VerificationMethodTypes } from '../../libs/generated/ssi/client/enums'; +import { OfflineSigner } from '@cosmjs/proto-signing'; +import customLoader from '../../libs/w3cache/v1'; +import { DeliverTxResponse } from './IDID'; + +const documentLoader = jsonSigs.extendContextLoader(customLoader); +class DIDDocument implements Did { + '@context': string[]; + id: string; + controller: string[]; + alsoKnownAs?: string[]; + verificationMethod?: VerificationMethod[]; + authentication: string[] | any; + assertionMethod: string[] | any; + keyAgreement: string[] | any; + capabilityInvocation: string[] | any; + capabilityDelegation: string[] | any; + service: Service[]; + constructor( + publicKey: string, + blockchainAccountId: string, + id: string, + keyType: VerificationMethodTypes, + verificationRelationships?: VerificationMethodRelationships[] + ) { + let vm; + switch (keyType) { + case VerificationMethodTypes.Ed25519VerificationKey2020: { + this['@context'] = [ + constant['DID_' + keyType].DID_BASE_CONTEXT, + constant['DID_' + keyType].DID_BABYJUBJUBKEY2021, + ]; + this.id = id; + this.controller = [this.id]; + this.alsoKnownAs = [this.id]; + vm = { + id: this.id + '#key-1', + type: constant['DID_' + keyType].VERIFICATION_METHOD_TYPE, + controller: this.id, + publicKeyMultibase: publicKey, + }; + + const verificationMethod: VerificationMethod = vm; + this.verificationMethod = [verificationMethod]; + this.authentication = []; + this.assertionMethod = []; + this.keyAgreement = []; + this.capabilityInvocation = []; + this.capabilityDelegation = []; + verificationRelationships?.forEach((value) => { + const vmId = verificationMethod.id as string; + this[value] = [vmId]; + }); + + // TODO: we should take services object in consntructor + this.service = []; + + break; + } + case VerificationMethodTypes.EcdsaSecp256k1RecoveryMethod2020: { + this['@context'] = [ + constant['DID_' + keyType].DID_BASE_CONTEXT, + constant['DID_' + keyType].SECP256K12020_RECOVERY_CONTEXT, + ]; + this.id = id; + this.controller = [this.id]; + this.alsoKnownAs = [this.id]; + vm = { + id: this.id + '#key-1', + type: constant['DID_' + keyType].VERIFICATION_METHOD_TYPE, + controller: this.id, + blockchainAccountId: blockchainAccountId, + }; + const verificationMethod: VerificationMethod = vm; + this.verificationMethod = [verificationMethod]; + this.authentication = []; + this.assertionMethod = []; + this.keyAgreement = []; + this.capabilityInvocation = []; + this.capabilityDelegation = []; + verificationRelationships?.forEach((value) => { + const vmId = verificationMethod.id as string; + this[value] = [vmId]; + }); + // TODO: we should take services object in consntructor + this.service = []; + + break; + } + case VerificationMethodTypes.EcdsaSecp256k1VerificationKey2019: { + this['@context'] = [ + constant['DID_' + keyType].DID_BASE_CONTEXT, + constant['DID_' + keyType].SECP256K12020_VERIFICATION_CONTEXT, + ]; + this.id = id; + this.controller = [this.id]; + this.alsoKnownAs = [this.id]; + vm = { + id: this.id + '#key-1', + type: constant['DID_' + keyType].VERIFICATION_METHOD_TYPE, + controller: this.id, + publicKeyMultibase: publicKey, + blockchainAccountId: blockchainAccountId, + }; + const verificationMethod: VerificationMethod = vm; + this.verificationMethod = [verificationMethod]; + this.authentication = []; + this.assertionMethod = []; + this.keyAgreement = []; + this.capabilityInvocation = []; + this.capabilityDelegation = []; + + verificationRelationships?.forEach((value) => { + const vmId = verificationMethod.id as string; + this[value] = [vmId]; + }); + // TODO: we should take services object in consntructor + this.service = []; + + break; + } + case VerificationMethodTypes.BabyJubJubKey2021: { + this['@context'] = [ + constant['DID_' + keyType].DID_BASE_CONTEXT, + constant['DID_' + keyType].DID_BABYJUBJUBKEY2021, + constant['DID_' + keyType].BABYJUBJUBSIGNATURE, + ]; + this.id = id; + this.controller = [this.id]; + vm = { + id: this.id + '#key-1', + type: constant['DID_' + keyType].VERIFICATION_METHOD_TYPE, + controller: this.id, + publicKeyMultibase: publicKey, + }; + + const verificationMethod: VerificationMethod = vm; + this.verificationMethod = [verificationMethod]; + // eslint-disable-next-line @typescript-eslint/no-this-alias + this.authentication = [vm.id]; + this.assertionMethod = [vm.id]; + this.keyAgreement = []; + this.capabilityInvocation = []; + this.capabilityDelegation = []; + verificationRelationships?.forEach((value) => { + const vmId = verificationMethod.id as string; + this[value] = [vmId]; + }); + + // TODO: we should take services object in consntructor + this.service = []; + + break; + } + default: + throw new Error('Invalid'); + } + } +} + +/** Class representing HypersignDID */ +export default class HypersignBJJDID implements IDID { + private didrpc: IDIDRpc | null; + private didAPIService: IDidApiService | null; + public namespace: string; + + /** + * Creates instance of HypersignDID class + * @constructor + * @params + * - params.namespace : namespace of did id, Default 'did:hid' + * - params.offlineSigner : signer of type OfflineSigner + * - params.nodeRpcEndpoint : RPC endpoint of the Hypersign blockchain, Default 'TEST' + * - params.nodeRestEndpoint : REST endpoint of the Hypersign blockchain + */ + constructor( + params: { + namespace?: string; + offlineSigner?: OfflineSigner; + nodeRpcEndpoint?: string; + nodeRestEndpoint?: string; + entityApiSecretKey?: string; + } = {} + ) { + const { offlineSigner, namespace, nodeRpcEndpoint, nodeRestEndpoint, entityApiSecretKey } = params; + const nodeRPCEp = nodeRpcEndpoint ? nodeRpcEndpoint : 'MAIN'; + const nodeRestEp = nodeRestEndpoint ? nodeRestEndpoint : ''; + + const rpcConstructorParams = { + offlineSigner, + nodeRpcEndpoint: nodeRPCEp, + nodeRestEndpoint: nodeRestEp, + }; + this.didrpc = new DIDRpc(rpcConstructorParams); + if (entityApiSecretKey && entityApiSecretKey != '') { + this.didAPIService = new DidApiService(entityApiSecretKey); + this.didrpc = null; + } else { + this.didAPIService = null; + } + this.namespace = namespace ? namespace : ''; + } + sign(params: { + didDocument: Did; + privateKeyMultibase: string; + challenge: string; + domain: string; + did: string; + verificationMethodId: string; + }): Promise { + throw new Error('Method not implemented.'); + } + verify(params: { + didDocument: Did; + verificationMethodId: string; + challenge: string; + domain?: string | undefined; + }): Promise { + throw new Error('Method not implemented.'); + } + addVerificationMethod(params: { + did?: string | undefined; + didDocument?: Did | undefined; + type: VerificationMethodTypes; // TODO: we should take services object in consntructor + // TODO: we should take services object in consntructor + id?: string | undefined; + controller?: string | undefined; + publicKeyMultibase?: string | undefined; + blockchainAccountId?: string | undefined; + }): Promise { + throw new Error('Method not implemented.'); + } + createByClientSpec(params: { + methodSpecificId: string; + publicKey?: string | undefined; + address: string; + chainId: string; + clientSpec: IClientSpec; + verificationRelationships?: VerificationMethodRelationships[] | undefined; + }): Promise { + throw new Error('Method not implemented.'); + } + registerByClientSpec(params: { + didDocument: Did; + signInfos: DocumentProof[]; + }): Promise<{ didDocument: Did; transactionHash: string }> { + throw new Error('Method not implemented.'); + } + updateByClientSpec(params: { + didDocument: Did; + versionId: string; + signInfos: DocumentProof[]; + }): Promise<{ transactionHash: string }> { + throw new Error('Method not implemented.'); + } + deactivateByClientSpec(params: { + didDocument: Did; + signInfos: DocumentProof[]; + versionId: string; + }): Promise<{ transactionHash: string }> { + throw new Error('Method not implemented.'); + } + signAndRegisterByClientSpec(params: { + didDocument: Did; + address: string; + verificationMethodId: string; + web3: any; + clientSpec: IClientSpec; + chainId?: string | undefined; + }): Promise<{ didDocument: Did; transactionHash: string }> { + throw new Error('Method not implemented.'); + } + signByClientSpec(params: { + didDocument: Did; + clientSpec: IClientSpec; + address: string; + web3: any; + chainId?: string | undefined; + verificationMethodId: any; + }): Promise { + throw new Error('Method not implemented.'); + } + + private _getDateTime(): string { + return new Date(new Date().getTime() - 100000).toISOString().slice(0, -5) + 'Z'; + } + + private async _jsonLdSign(params: { + didDocument: Did; + privateKeyMultibase: string; + verificationMethodId: string; + }): Promise { + const { didDocument, privateKeyMultibase, verificationMethodId } = params; + const publicKeyId = verificationMethodId + 'assertionMethod'; + const pubKey = (didDocument.assertionMethod as any)?.find((item) => item.id === publicKeyId); + const publicKeyMultibase1 = pubKey?.publicKeyMultibase; + const keyPair = BabyJubJubKeys2021.fromKeys({ + options: { + id: publicKeyId, + controller: publicKeyId, + }, + privateKeyMultibase: privateKeyMultibase, + publicKeyMultibase: publicKeyMultibase1 as string, + }); + const suite = new BabyJubJubSignature2021Suite({ key: keyPair }); + const signedDidDocument = (await jsonSigs.sign(didDocument, { + suite, + purpose: new AssertionProofPurpose(), + documentLoader, + })) as ISignedDIDDocument; + return signedDidDocument.proof; + } + + private _getId = (methodSpecificId: string) => { + if (methodSpecificId && methodSpecificId.length < 32) { + throw new Error('HID-SSI-SDK:: Error: methodSpecificId should be of minimum size 32'); + } + let did = ''; + did = + this.namespace && this.namespace != '' + ? `${constant.DID.SCHEME}:${constant.DID.METHOD}:${this.namespace}:${methodSpecificId}` + : `${constant.DID.SCHEME}:${constant.DID.METHOD}:${methodSpecificId}`; + return did; + }; + + private _filterVerificationRelationships( + verificationRelationships: VerificationMethodRelationships[] + ): VerificationMethodRelationships[] { + let vR: VerificationMethodRelationships[] = [ + VerificationMethodRelationships.assertionMethod, + VerificationMethodRelationships.authentication, + ]; + if (verificationRelationships && verificationRelationships.length > 0) { + const set1 = new Set(vR); + const set2 = new Set(verificationRelationships); + vR = Array.from(set1).filter((value) => set2.has(value)); + } + + return vR; + } + + /** + * Creates a new DID Document from wallet address + * @params + * - params.blockChainAccountId : + * - params.methodSpecificId : methodSpecificId (min 32 bit alhanumeric) else it will generate new random methodSpecificId or may be walletaddress + * @returns {Promise} DidDocument object + */ + private _getBlockChainAccountID(chainId: string, address: string) { + try { + const web3 = new Web3(); + const inDecimelChainId = web3.utils.hexToNumber(chainId); + const blockChainAccountId = constant.CAIP_10_PREFIX.eip155 + ':' + inDecimelChainId + ':' + address; + return blockChainAccountId; + } catch (error) { + throw new Error('HID-SSI-SDK:: Error: unsupported chain Id'); + } + } + + public async init() { + if (!this.didrpc && !this.didAPIService) { + throw new Error( + 'HID-SSI-SDK:: Error: HypersignDID class is not instantiated with Offlinesigner or have not been initilized with entityApiSecretKey' + ); + } + if (this.didrpc) { + await this.didrpc.init(); + } + if (this.didAPIService) { + await this.didAPIService.auth(); + } + } + + /** + * Generate a new key pair of type Ed25519VerificationKey2020 + * @params params.seed - Optional, Seed to generate the key pair, if not passed, random seed will be taken + * @params params.controller - Optional, controller field + * @returns {Promise} The key pair of type Ed25519 + */ + public async generateKeys(params: { + mnemonic?: string; + controller?: string; + }): Promise<{ privateKeyMultibase: string; publicKeyMultibase: string }> { + let edKeyPair; + if (params && params.mnemonic && params.controller) { + edKeyPair = await BabyJubJubKeys2021.from(params.mnemonic, { + id: params.controller, + }); + } else if (params && params.controller) { + edKeyPair = await BabyJubJubKeys2021.generate({ id: params.controller }); + } else if (params && params.mnemonic) { + edKeyPair = await BabyJubJubKeys2021.from(params.mnemonic); + } else { + edKeyPair = await BabyJubJubKeys2021.generate(); + } + return { + ...edKeyPair, + }; + } + + /** + * Generates a new DID Document + * @params + * - params.publicKeyMultibase : public key + * - params.methodSpecificId : Optional methodSpecificId (min 32 bit alhanumeric) else it will generate new random methodSpecificId + * - params.verificationRelationships: Optional, verification relationships where you want to add your verificaiton method ids + * @returns {Promise} DidDocument object + */ + public async generate(params: { + methodSpecificId?: string; + publicKeyMultibase: string; + verificationRelationships?: VerificationMethodRelationships[]; + }): Promise { + let verificationRelationships: VerificationMethodRelationships[] = []; + if (params.verificationRelationships && params.verificationRelationships.length > 0) { + if (params.verificationRelationships.includes(VerificationMethodRelationships.keyAgreement)) { + throw new Error('HID-SSI-SDK:: Error: keyAgreement is not allowed in verificationRelationships'); + } + verificationRelationships = this._filterVerificationRelationships(params.verificationRelationships); + } else { + verificationRelationships = this._filterVerificationRelationships([]); + } + if (!params.publicKeyMultibase) { + throw new Error('HID-SSI-SDK:: Error: params.publicKeyMultibase is required to generate new did didoc'); + } + const publicKeyMultibase1 = params.publicKeyMultibase; + const methodSpecificId = publicKeyMultibase1; + let didId; + if (params.methodSpecificId) { + didId = this._getId(params.methodSpecificId); + } else { + didId = this._getId(methodSpecificId); + } + + const newDid = new DIDDocument( + publicKeyMultibase1, + '', + didId, + VerificationMethodTypes.BabyJubJubKey2021, + verificationRelationships + ) as IDid; + return Utils.jsonToLdConvertor({ ...newDid }); + } + + private prepareDidDocument(did: Did) { + const did1 = {} as any; + Object.assign(did1, did); + delete did1.alsoKnownAs; + // TODO FIx + did1.assertionMethod = []; + did1.authentication = []; + did1.capabilityDelegation = []; + did1.capabilityInvocation = []; + did1.keyAgreement = []; + if (did.assertionMethod) { + did.assertionMethod.forEach((x) => { + const vm = did.verificationMethod?.find((vm) => vm.id === x); + if (vm) { + did1.assertionMethod.push({ + id: vm.id + 'assertionMethod', + type: vm.type, + publicKeyMultibase: vm.publicKeyMultibase, + }); + } + }); + } + + if (did.authentication) { + did.authentication.forEach((x) => { + const vm = did.verificationMethod?.find((vm) => vm.id === x); + if (vm) { + did1.authentication.push({ + id: vm.id + 'authentication', + type: vm.type, + publicKeyMultibase: vm.publicKeyMultibase, + }); + } + }); + } + + if (did.capabilityDelegation) { + did.capabilityDelegation.forEach((x) => { + const vm = did.verificationMethod?.find((vm) => vm.id === x); + if (vm) { + did1.capabilityDelegation.push({ + id: vm.id + 'capabilityDelegation', + type: vm.type, + publicKeyMultibase: vm.publicKeyMultibase, + }); + } + }); + } + + if (did.capabilityInvocation) { + did.capabilityInvocation.forEach((x) => { + const vm = did.verificationMethod?.find((vm) => vm.id === x); + if (vm) { + did1.capabilityInvocation.push({ + id: vm.id + 'capabilityInvocation', + type: vm.type, + publicKeyMultibase: vm.publicKeyMultibase, + }); + } + }); + } + + if (did.keyAgreement) { + did.keyAgreement.forEach((x) => { + const vm = did.verificationMethod?.find((vm) => vm.id === x); + if (vm) { + did1.keyAgreement.push({ + id: vm.id + 'keyAgreement', + type: vm.type, + publicKeyMultibase: vm.publicKeyMultibase, + }); + } + }); + } + + delete did1.verificationMethod; + return did1; + } + /** + * Register a new DID and Document in Hypersign blockchain - an onchain activity + * @params + * - params.didDocument : LD did document + * - params.privateKeyMultibase : Private Key to sign the doc + * - params.verificationMethodId : VerificationMethodId of the document + * @returns {Promise} Result of the registration + */ + public async register(params: { + didDocument: Did; // Ld document + privateKeyMultibase?: string; + verificationMethodId: string; + signData?: ISignData[]; + }): Promise<{ didDocument: Did; transactionHash: string }> { + //ToDO check if did exists + const response = {} as { didDocument: Did; transactionHash: string }; + + // TODO: this method MUST also accept signature/proof + + if (!params.didDocument || Object.keys(params.didDocument).length === 0) { + throw new Error('HID-SSI-SDK:: Error: params.didDocString is required to register a did'); + } + if (!this.didrpc && !this.didAPIService) { + throw new Error( + 'HID-SSI-SDK:: Error: HypersignDID class is not instantiated with "Offlinesigner" or have not been initilized with "EntityAPISecreKey"' + ); + } + let { didDocument } = params; + const didDoc: Did = didDocument as Did; + const signInfos: Array = []; + if (!params.signData) { + if (!params.privateKeyMultibase) { + throw new Error('HID-SSI-SDK:: Error: params.privateKeyMultibase is required to register a did'); + } + if (!params.verificationMethodId) { + throw new Error('HID-SSI-SDK:: Error: params.verificationMethodId is required to register a did'); + } + const { privateKeyMultibase, verificationMethodId } = params; + let signature; + let createdAt; + if (!didDocument['@context']) { + throw new Error('HID-SSI-SDK:: Error: didDocument is not in Ld-json format'); + } else { + didDocument = Utils.removeEmptyString(didDocument); + const prepareDidDocument = this.prepareDidDocument(didDocument); + const proof = await this._jsonLdSign({ + didDocument: prepareDidDocument, + privateKeyMultibase, + verificationMethodId, + }); + signature = proof.proofValue; + createdAt = proof.created; + } + + signInfos.push({ + type: constant['DID_BabyJubJubKey2021'].SIGNATURE_TYPE, + created: createdAt ?? this._getDateTime(), + verificationMethod: verificationMethodId, + proofPurpose: VerificationMethodRelationships.assertionMethod, + proofValue: signature, + }); + } else { + if (params.signData.length < 1) { + throw new Error('HID-SSI-SDK:: Error: params.signInfos must be a non empty array'); + } + for (const i in params.signData) { + if (!params.signData[i].verificationMethodId) { + throw new Error( + `HID-SSI-SDK:: Error: params.signData[${i}].verificationMethodId is required to register a did` + ); + } + if (!params.signData[i].privateKeyMultibase) { + throw new Error( + `HID-SSI-SDK:: Error: params.signData[${i}].privateKeyMultibase is required to register a did` + ); + } + if (!params.signData[i].type) { + throw new Error(`HID-SSI-SDK:: Error: params.signData[${i}].type is required to register a did`); + } + const { type, privateKeyMultibase, verificationMethodId } = params.signData[i]; + let createdAt; + if ( + type !== VerificationMethodTypes.X25519KeyAgreementKey2020 && + type !== VerificationMethodTypes.X25519KeyAgreementKeyEIP5630 + ) { + let signature: string; + if (!didDocument['@context']) { + throw new Error('HID-SSI-SDK:: Error: didDocument is not in Ld-json format'); + } else { + didDocument = Utils.removeEmptyString(didDocument); + const prepareDidDocument = this.prepareDidDocument(didDocument); + const proof: SignInfo = await this._jsonLdSign({ + didDocument: prepareDidDocument, + privateKeyMultibase, + verificationMethodId, + }); + signature = proof.proofValue as string; + createdAt = proof.created; + } + signInfos.push({ + type: constant['DID_BabyJubJubKey2021'].SIGNATURE_TYPE, + created: createdAt ?? this._getDateTime(), + verificationMethod: verificationMethodId, + proofPurpose: VerificationMethodRelationships.assertionMethod, + proofValue: signature, + }); + delete didDocument['proof']; + } + } + } + + if (this.didrpc) { + const result: DeliverTxResponse = await this.didrpc.registerDID(didDoc, signInfos); + if (result.code !== 0) { + throw new Error(result.rawLog); + } + + response.didDocument = params.didDocument; + response.transactionHash = result.transactionHash; + } else if (this.didAPIService) { + const newSignInfos = signInfos as Array; + const result: { didDocument: Did; transactionHash: string } = await this.didAPIService.registerDid({ + didDocument, + signInfos: newSignInfos, + }); + response.didDocument = didDocument; + response.transactionHash = result.transactionHash; + } + return response; + } + /** + * Generate signature + * @params + * - params.didDocument : LD did document + * - params.privateKeyMultibase : Private Key to sign the doc + * - params.verificationMethodId : VerificationMethodId of the document + * @returns {Promise} Generate Array + */ + public async createSignInfos(params: { + didDocument: Did; // Ld document + privateKeyMultibase: string; + verificationMethodId: string; + }): Promise> { + if (!params.didDocument || Object.keys(params.didDocument).length === 0) { + throw new Error('HID-SSI-SDK:: Error: params.didDocument is required to create signature of a did'); + } + if (!params.privateKeyMultibase) { + throw new Error('HID-SSI-SDK:: Error: params.privateKeyMultibase is required to create signature of a did'); + } + if (!params.verificationMethodId) { + throw new Error('HID-SSI-SDK:: Error: params.verificationMethodId is required to create signature of a did'); + } + let { didDocument } = params; + const signInfos: Array = []; + const { privateKeyMultibase, verificationMethodId } = params; + let signature; + let createdAt; + let type; + if (!didDocument['@context']) { + throw new Error('HID-SSI-SDK:: Error: didDocument is not in Ld-json format'); + } else { + didDocument = this.prepareDidDocument(didDocument); + + didDocument = Utils.removeEmptyString(didDocument); + const proof = await this._jsonLdSign({ + didDocument, + privateKeyMultibase, + verificationMethodId, + }); + signature = proof.proofValue; + createdAt = proof.created; + type = proof.type; + } + signInfos.push({ + type, + signature, + verification_method_id: verificationMethodId, + created: createdAt, + clientSpec: undefined, + }); + return signInfos; + } + + /** + * Resolves a DID into DIDDocument from Hypersign blockchain - an onchain activity + * @params + * - params.did : DID + * @returns {Promise} didDocument and didDocumentMetadata + */ + public async resolve(params: { did: string }): Promise { + let result = {} as IDIDResolve; + if (!params.did) { + throw new Error('HID-SSI-SDK:: Error: params.did is required to resolve a did'); + } + if (this.didrpc) { + result = await this.didrpc.resolveDID(params.did); + } else if (this.didAPIService) { + result = await this.didAPIService.resolveDid({ did: params.did }); + } + return { + didDocument: Utils.jsonToLdConvertor(result.didDocument), + didDocumentMetadata: result.didDocumentMetadata, + } as IDIDResolve; + } + + /** + * Update a DIDDocument in Hypersign blockchain - an onchain activity + * @params + * - params.didDocument : LD did document + * - params.privateKeyMultibase : Private Key to sign the doc + * - params.verificationMethodId : VerificationMethodId of the document + * - params.versionId : Version of the document + * @returns {Promise<{ transactionHash: string }>} Result of the update operation + */ + public async update(params: { + didDocument: Did; + privateKeyMultibase: string; + verificationMethodId: string; + versionId: string; + readonly?: boolean; + otherSignInfo?: Array; + }): Promise<{ transactionHash: string } | { didDocument; signInfos; versionId }> { + const response = {} as { transactionHash: string }; + if (!params.didDocument) { + throw new Error('HID-SSI-SDK:: Error: params.didDocument is required to update a did'); + } + if (!params.privateKeyMultibase) { + throw new Error('HID-SSI-SDK:: Error: params.privateKeyMultibase is required to update a did'); + } + + if (!params.verificationMethodId) { + throw new Error('HID-SSI-SDK:: Error: params.verificationMethodId is required to update a did'); + } + if (!params.versionId) { + throw new Error('HID-SSI-SDK:: Error: params.versionId is required to update a did'); + } + + if (!this.didrpc && !this.didAPIService) { + throw new Error( + 'HID-SSI-SDK:: Error: HypersignDID class is not instantiated with "Offlinesigner" or have not been initilized with "EntityAPISecreKey"' + ); + } + const { didDocument, privateKeyMultibase, verificationMethodId, versionId } = params; + const prepareDidDocument = this.prepareDidDocument(didDocument); + const proof = await this._jsonLdSign({ + didDocument: prepareDidDocument, + privateKeyMultibase, + verificationMethodId, + }); + let signInfos: Array = [ + { + type: constant['DID_BabyJubJubKey2021'].SIGNATURE_TYPE, + created: proof.created ?? this._getDateTime(), + verificationMethod: verificationMethodId, + proofPurpose: VerificationMethodRelationships.assertionMethod, + proofValue: proof.proofValue, + }, + ]; + if (params.otherSignInfo) { + signInfos = [...signInfos, ...params.otherSignInfo]; + } + if (params.readonly === true) { + return { + didDocument, + signInfos, + versionId, + }; + } + if (this.didrpc) { + const result: DeliverTxResponse = await this.didrpc.updateDID(didDocument, signInfos, versionId); + response.transactionHash = result.transactionHash; + } else if (this.didAPIService) { + const newSignInfos = signInfos as Array; + const result = await this.didAPIService.updateDid({ + didDocument: didDocument as Did, + signInfos: newSignInfos, + deactivate: false, + }); + response.transactionHash = result.transactionHash; + } + return response; + } + + /** + * Deactivate a DIDDocument in Hypersign blockchain - an onchain activity + * @params + * - params.didDocument : LD did document + * - params.privateKeyMultibase : Private Key to sign the doc + * - params.verificationMethodId : VerificationMethodId of the document + * - params.versionId : Version of the document + * @returns {Promise} Result of the deactivatee operation + */ + public async deactivate(params: { + didDocument: Did; + privateKeyMultibase: string; + verificationMethodId: string; + versionId: string; + }): Promise<{ transactionHash: string }> { + const response = {} as { transactionHash: string }; + if (!params.didDocument) { + throw new Error('HID-SSI-SDK:: Error: params.didDocument is required to deactivate a did'); + } + if (!params.privateKeyMultibase) { + throw new Error('HID-SSI-SDK:: Error: params.privateKeyMultibase is required to deactivate a did'); + } + + if (!params.verificationMethodId) { + throw new Error('HID-SSI-SDK:: Error: params.verificationMethodId is required to deactivate a did'); + } + if (!params.versionId) { + throw new Error('HID-SSI-SDK:: Error: params.versionId is required to deactivate a did'); + } + + if (!this.didrpc && !this.didAPIService) { + throw new Error( + 'HID-SSI-SDK:: Error: HypersignDID class is not instantiated with "Offlinesigner" or have not been initilized with "EntityAPISecreKey"' + ); + } + + const { didDocument, privateKeyMultibase, verificationMethodId, versionId } = params; + const prepareDidDocument = this.prepareDidDocument(didDocument); + const proof = await this._jsonLdSign({ + didDocument: prepareDidDocument, + privateKeyMultibase, + verificationMethodId, + }); + const signInfos: Array = [ + { + type: constant['DID_BabyJubJubKey2021'].SIGNATURE_TYPE, + created: proof.created ?? this._getDateTime(), + verificationMethod: verificationMethodId, + proofPurpose: VerificationMethodRelationships.assertionMethod, + proofValue: proof.proofValue, + }, + ]; + if (this.didrpc) { + const result: DeliverTxResponse = await this.didrpc.deactivateDID(didDocument.id as string, signInfos, versionId); + response.transactionHash = result.transactionHash; + } else if (this.didAPIService) { + const newSignInfos = signInfos as Array; + const result: { transactionHash: string } = await this.didAPIService.updateDid({ + didDocument: didDocument as Did, + signInfos: newSignInfos, + deactivate: true, + }); + response.transactionHash = result.transactionHash; + } + return response; + } + + /** + * Signs a DIDDocument + * @params + * - params.didDocument : Did document to be signed + * - params.privateKeyMultibase : private key in multibase format (base58 digitalbazar format) + * - params.challenge : challenge is a random string generated by the client + * - params.did : did of the user + * - params.domain : domain is the domain of the DID Document that is being authenticated + * - params.verificationMethodId : verificationMethodId of the DID + * @returns {Promise} Signed DID Document + */ + + private _isValidMultibaseBase58String = (str) => { + const multibaseBase58Regex = /^z([1-9A-HJ-NP-Za-km-z]+)$/; + return multibaseBase58Regex.test(str); + }; + // using in API + /** + * Create DIDDocument using metamask or kepler + * @param + * - params.methodSpecificId : methodSpecificId (min 32 bit alhanumeric) else it will generate new random methodSpecificId or may be walletaddress + * - params.publicKey : Optional, Used for cosmos-ADR036 + * - params.address : Checksum address from web3 wallet + * - params.chainId : Chain Id + * - params.clientSpec : ClientSpec either it is eth-personalSign or cosmos-ADR036\ + * - params.verificationRelationships : Optional, verification relationships where you want to add your verificaiton method ids + * @returns {Promise} DidDocument object + */ +} diff --git a/src/did/did.ts b/src/did/did.ts index d1c7520..8a0d774 100644 --- a/src/did/did.ts +++ b/src/did/did.ts @@ -5,39 +5,43 @@ */ import * as constant from '../constants'; import jsonSigs from 'jsonld-signatures'; -const { AuthenticationProofPurpose } = jsonSigs.purposes; +const { AuthenticationProofPurpose, AssertionProofPurpose } = jsonSigs.purposes; import { DIDRpc } from './didRPC'; import Utils from '../utils'; -const ed25519 = require('@stablelib/ed25519'); -import { Did, VerificationMethod, Service, SignInfo } from '../../libs/generated/ssi/did'; +import { DidDocument as Did, VerificationMethod, Service, DidDocument } from '../../libs/generated/ssi/did'; +import { DocumentProof, DocumentProof as SignInfo } from '../../libs/generated/ssi/proof'; import { Ed25519VerificationKey2020 } from '@digitalbazaar/ed25519-verification-key-2020'; import { Ed25519Signature2020 } from '@digitalbazaar/ed25519-signature-2020'; import Web3 from 'web3'; import DidApiService from '../ssiApi/services/did/did.service'; -import { IDidApiService, IRegister } from '../ssiApi/services/did/IDIDApi'; - +import { IDidApiService } from '../ssiApi/services/did/IDIDApi'; +import jsonld from 'jsonld'; +import crypto from 'crypto'; import { - IParams, IDID, IDid, IDIDResolve, IDIDRpc, IController, - IDidDocument, ISignedDIDDocument, - IKeyType, IClientSpec, - IVerificationRelationships, ISignData, ISignInfo, + SupportedPurpose, } from './IDID'; - +import { + ProofTypes, + VerificationMethodRelationships, + VerificationMethodTypes, +} from '../../libs/generated/ssi/client/enums'; import { OfflineSigner } from '@cosmjs/proto-signing'; import customLoader from '../../libs/w3cache/v1'; import { DeliverTxResponse } from '../did/IDID'; - +import { ClientSpecType } from '../../libs/generated/ssi/client_spec'; +import HypersignBJJDId from './bjjdid'; +const documentLoader = jsonSigs.extendContextLoader(customLoader); class DIDDocument implements Did { - context: string[]; + '@context': string[]; id: string; controller: string[]; alsoKnownAs: string[]; @@ -52,13 +56,13 @@ class DIDDocument implements Did { publicKey: string, blockchainAccountId: string, id: string, - keyType: IKeyType, - verificationRelationships?: IVerificationRelationships[] + keyType: VerificationMethodTypes, + verificationRelationships?: VerificationMethodRelationships[] ) { let vm; switch (keyType) { - case IKeyType.Ed25519VerificationKey2020: { - this.context = [constant['DID_' + keyType].DID_BASE_CONTEXT]; + case VerificationMethodTypes.Ed25519VerificationKey2020: { + this['@context'] = [constant['DID_' + keyType].DID_BASE_CONTEXT, constant.VC.CREDENTIAIL_SECURITY_SUITE]; this.id = id; this.controller = [this.id]; this.alsoKnownAs = [this.id]; @@ -67,7 +71,6 @@ class DIDDocument implements Did { type: constant['DID_' + keyType].VERIFICATION_METHOD_TYPE, controller: this.id, publicKeyMultibase: publicKey, - blockchainAccountId: '', }; const verificationMethod: VerificationMethod = vm; @@ -78,7 +81,8 @@ class DIDDocument implements Did { this.capabilityInvocation = []; this.capabilityDelegation = []; verificationRelationships?.forEach((value) => { - this[value] = [verificationMethod.id]; + const vmId = verificationMethod.id as string; + this[value] = [vmId]; }); // TODO: we should take services object in consntructor @@ -86,8 +90,11 @@ class DIDDocument implements Did { break; } - case IKeyType.EcdsaSecp256k1RecoveryMethod2020: { - this.context = [constant['DID_' + keyType].DID_BASE_CONTEXT]; + case VerificationMethodTypes.EcdsaSecp256k1RecoveryMethod2020: { + this['@context'] = [ + constant['DID_' + keyType].DID_BASE_CONTEXT, + constant['DID_' + keyType].SECP256K12020_RECOVERY_CONTEXT, + ]; this.id = id; this.controller = [this.id]; this.alsoKnownAs = [this.id]; @@ -105,18 +112,22 @@ class DIDDocument implements Did { this.capabilityInvocation = []; this.capabilityDelegation = []; verificationRelationships?.forEach((value) => { - this[value] = [verificationMethod.id]; + const vmId = verificationMethod.id as string; + this[value] = [vmId]; }); // TODO: we should take services object in consntructor this.service = []; break; } - case IKeyType.EcdsaSecp256k1VerificationKey2019: { - this.context = [constant['DID_' + keyType].DID_BASE_CONTEXT]; + case VerificationMethodTypes.EcdsaSecp256k1VerificationKey2019: { + this['@context'] = [ + constant['DID_' + keyType].DID_BASE_CONTEXT, + constant['DID_' + keyType].SECP256K12020_VERIFICATION_CONTEXT, + ]; this.id = id; this.controller = [this.id]; - this.alsoKnownAs = []; + this.alsoKnownAs = [this.id]; vm = { id: this.id + '#key-1', type: constant['DID_' + keyType].VERIFICATION_METHOD_TYPE, @@ -132,7 +143,8 @@ class DIDDocument implements Did { this.capabilityInvocation = []; this.capabilityDelegation = []; verificationRelationships?.forEach((value) => { - this[value] = [verificationMethod.id]; + const vmId = verificationMethod.id as string; + this[value] = [vmId]; }); // TODO: we should take services object in consntructor this.service = []; @@ -150,6 +162,7 @@ export default class HypersignDID implements IDID { private didrpc: IDIDRpc | null; private didAPIService: IDidApiService | null; public namespace: string; + public bjjDID: HypersignBJJDId; /** * Creates instance of HypersignDID class @@ -186,22 +199,51 @@ export default class HypersignDID implements IDID { this.didAPIService = null; } this.namespace = namespace ? namespace : ''; + + this.bjjDID = new HypersignBJJDId(params); } - private async _sign(params: { didDocString: string; privateKeyMultibase: string }): Promise { - const { privateKeyMultibase: privateKeyMultibaseConverted } = - Utils.convertEd25519verificationkey2020toStableLibKeysInto({ - privKey: params.privateKeyMultibase, - }); + private _getDateTime(): string { + return new Date(new Date().getTime() - 100000).toISOString().slice(0, -5) + 'Z'; + } - const { didDocString } = params; - // TODO: do proper checck of paramaters - const did: Did = JSON.parse(didDocString); - const didBytes = (await Did.encode(did)).finish(); - const signed = ed25519.sign(privateKeyMultibaseConverted, didBytes); - return Buffer.from(signed).toString('base64'); + private async _jsonLdSign(params: { + didDocument: Did; + privateKeyMultibase: string; + verificationMethodId: string; + }): Promise { + const { didDocument, privateKeyMultibase, verificationMethodId } = params; + const publicKeyId = verificationMethodId; + const pubKey = didDocument.verificationMethod?.find((item) => item.id === publicKeyId); + const publicKeyMultibase1 = pubKey?.publicKeyMultibase; + const keyPair = await Ed25519VerificationKey2020.from({ + id: publicKeyId, + privateKeyMultibase: privateKeyMultibase, + publicKeyMultibase: publicKeyMultibase1, + }); + const suite = new Ed25519Signature2020({ key: keyPair }); + const signedDidDocument = (await jsonSigs.sign(didDocument, { + suite, + purpose: new AssertionProofPurpose(), + documentLoader, + })) as ISignedDIDDocument; + return signedDidDocument; } + private async _jsonLdNormalize(params: { doc }) { + const docToNormalize = params.doc; + const normalizedoc = await jsonld.normalize(docToNormalize, { + format: 'application/n-quads', + algorithm: 'URDNA2015', + }); + return normalizedoc; + } + private _concat(arr1, arr2) { + const concatenatedArr = new Uint8Array(arr1.length + arr2.length); + concatenatedArr.set(arr1, 0); + concatenatedArr.set(arr2, arr1.length); + return concatenatedArr; + } private _getId = (methodSpecificId: string) => { if (methodSpecificId && methodSpecificId.length < 32) { throw new Error('HID-SSI-SDK:: Error: methodSpecificId should be of minimum size 32'); @@ -215,13 +257,13 @@ export default class HypersignDID implements IDID { }; private _filterVerificationRelationships( - verificationRelationships: IVerificationRelationships[] - ): IVerificationRelationships[] { - let vR: IVerificationRelationships[] = [ - IVerificationRelationships.assertionMethod, - IVerificationRelationships.authentication, - IVerificationRelationships.capabilityDelegation, - IVerificationRelationships.capabilityInvocation, + verificationRelationships: VerificationMethodRelationships[] + ): VerificationMethodRelationships[] { + let vR: VerificationMethodRelationships[] = [ + VerificationMethodRelationships.assertionMethod, + VerificationMethodRelationships.authentication, + VerificationMethodRelationships.capabilityDelegation, + VerificationMethodRelationships.capabilityInvocation, ]; if (verificationRelationships && verificationRelationships.length > 0) { const set1 = new Set(vR); @@ -303,11 +345,11 @@ export default class HypersignDID implements IDID { public async generate(params: { methodSpecificId?: string; publicKeyMultibase: string; - verificationRelationships?: IVerificationRelationships[]; + verificationRelationships?: VerificationMethodRelationships[]; }): Promise { - let verificationRelationships: IVerificationRelationships[] = []; + let verificationRelationships: VerificationMethodRelationships[] = []; if (params.verificationRelationships && params.verificationRelationships.length > 0) { - if (params.verificationRelationships.includes(IVerificationRelationships.keyAgreement)) { + if (params.verificationRelationships.includes(VerificationMethodRelationships.keyAgreement)) { throw new Error('HID-SSI-SDK:: Error: keyAgreement is not allowed in verificationRelationships'); } verificationRelationships = this._filterVerificationRelationships(params.verificationRelationships); @@ -317,10 +359,7 @@ export default class HypersignDID implements IDID { if (!params.publicKeyMultibase) { throw new Error('HID-SSI-SDK:: Error: params.publicKeyMultibase is required to generate new did didoc'); } - const { publicKeyMultibase: publicKeyMultibase1 } = Utils.convertEd25519verificationkey2020toStableLibKeysInto({ - publicKey: params.publicKeyMultibase, - }); - + const publicKeyMultibase1 = params.publicKeyMultibase; const methodSpecificId = publicKeyMultibase1; let didId; if (params.methodSpecificId) { @@ -333,7 +372,7 @@ export default class HypersignDID implements IDID { publicKeyMultibase1, '', didId, - IKeyType.Ed25519VerificationKey2020, + VerificationMethodTypes.Ed25519VerificationKey2020, verificationRelationships ) as IDid; return Utils.jsonToLdConvertor({ ...newDid }); @@ -363,9 +402,8 @@ export default class HypersignDID implements IDID { 'HID-SSI-SDK:: Error: HypersignDID class is not instantiated with "Offlinesigner" or have not been initilized with "EntityAPISecreKey"' ); } - const { didDocument } = params; - const didDocStringJson = Utils.ldToJsonConvertor(didDocument); - const didDoc: Did = didDocStringJson as Did; + let { didDocument } = params; + const didDoc: Did = didDocument as Did; const signInfos: Array = []; if (!params.signData) { if (!params.privateKeyMultibase) { @@ -375,14 +413,27 @@ export default class HypersignDID implements IDID { throw new Error('HID-SSI-SDK:: Error: params.verificationMethodId is required to register a did'); } const { privateKeyMultibase, verificationMethodId } = params; - const signature: string = await this._sign({ - didDocString: JSON.stringify(didDocStringJson), - privateKeyMultibase, - }); + let signature; + let createdAt; + if (!didDocument['@context']) { + throw new Error('HID-SSI-SDK:: Error: didDocument is not in Ld-json format'); + } else { + didDocument = Utils.removeEmptyString(didDocument); + const signedDidDoc = await this._jsonLdSign({ + didDocument: didDocument, + privateKeyMultibase, + verificationMethodId, + }); + const { proof } = signedDidDoc; + signature = proof.proofValue; + createdAt = proof.created; + } signInfos.push({ - signature, - verification_method_id: verificationMethodId, - clientSpec: undefined, + type: constant['DID_Ed25519VerificationKey2020'].SIGNATURE_TYPE, + created: createdAt ?? this._getDateTime(), + verificationMethod: verificationMethodId, + proofPurpose: VerificationMethodRelationships.assertionMethod, + proofValue: signature, }); } else { if (params.signData.length < 1) { @@ -403,16 +454,33 @@ export default class HypersignDID implements IDID { throw new Error(`HID-SSI-SDK:: Error: params.signData[${i}].type is required to register a did`); } const { type, privateKeyMultibase, verificationMethodId } = params.signData[i]; - if (type !== IKeyType.X25519KeyAgreementKey2020 && type !== IKeyType.X25519KeyAgreementKeyEIP5630) { - const signature: string = await this._sign({ - didDocString: JSON.stringify(didDocStringJson), - privateKeyMultibase, - }); + let createdAt; + if ( + type !== VerificationMethodTypes.X25519KeyAgreementKey2020 && + type !== VerificationMethodTypes.X25519KeyAgreementKeyEIP5630 + ) { + let signature: string; + if (!didDocument['@context']) { + throw new Error('HID-SSI-SDK:: Error: didDocument is not in Ld-json format'); + } else { + didDocument = Utils.removeEmptyString(didDocument); + const signedDidDoc = await this._jsonLdSign({ + didDocument: didDocument, + privateKeyMultibase, + verificationMethodId, + }); + const { proof } = signedDidDoc; + signature = proof.proofValue as string; + createdAt = proof.created; + } signInfos.push({ - signature, - verification_method_id: verificationMethodId, - clientSpec: undefined, + type: constant['DID_Ed25519VerificationKey2020'].SIGNATURE_TYPE, + created: createdAt ?? this._getDateTime(), + verificationMethod: verificationMethodId, + proofPurpose: VerificationMethodRelationships.assertionMethod, + proofValue: signature, }); + delete didDocument['proof']; } } } @@ -432,24 +500,54 @@ export default class HypersignDID implements IDID { return response; } + /** + * Generate signature + * @params + * - params.didDocument : LD did document + * - params.privateKeyMultibase : Private Key to sign the doc + * - params.verificationMethodId : VerificationMethodId of the document + * @returns {Promise} Generate Array + */ public async createSignInfos(params: { didDocument: Did; // Ld document privateKeyMultibase: string; verificationMethodId: string; - }): Promise> { - const { didDocument } = params; - const didDocStringJson = Utils.ldToJsonConvertor(didDocument); - const didDoc: Did = didDocStringJson as Did; - const signInfos: Array = []; + }): Promise> { + if (!params.didDocument || Object.keys(params.didDocument).length === 0) { + throw new Error('HID-SSI-SDK:: Error: params.didDocument is required to create signature of a did'); + } + if (!params.privateKeyMultibase) { + throw new Error('HID-SSI-SDK:: Error: params.privateKeyMultibase is required to create signature of a did'); + } + if (!params.verificationMethodId) { + throw new Error('HID-SSI-SDK:: Error: params.verificationMethodId is required to create signature of a did'); + } + let { didDocument } = params; + const signInfos: Array = []; const { privateKeyMultibase, verificationMethodId } = params; - const signature: string = await this._sign({ - didDocString: JSON.stringify(didDocStringJson), - privateKeyMultibase, - }); + let signature; + let createdAt; + let type; + if (!didDocument['@context']) { + throw new Error('HID-SSI-SDK:: Error: didDocument is not in Ld-json format'); + } else { + didDocument = Utils.removeEmptyString(didDocument); + const signedDidDocument = await this._jsonLdSign({ + didDocument, + privateKeyMultibase, + verificationMethodId, + }); + const { proof } = signedDidDocument; + signature = proof.proofValue; + createdAt = proof.created; + type = proof.type; + } signInfos.push({ signature, verification_method_id: verificationMethodId, + created: createdAt, clientSpec: undefined, + type, }); return signInfos; } @@ -458,32 +556,20 @@ export default class HypersignDID implements IDID { * Resolves a DID into DIDDocument from Hypersign blockchain - an onchain activity * @params * - params.did : DID - * - params.ed25519verificationkey2020 : *Optional* True/False * @returns {Promise} didDocument and didDocumentMetadata */ - public async resolve(params: { did: string; ed25519verificationkey2020?: boolean }): Promise { + public async resolve(params: { did: string }): Promise { let result = {} as IDIDResolve; if (!params.did) { throw new Error('HID-SSI-SDK:: Error: params.did is required to resolve a did'); } + if (this.didrpc) { result = await this.didrpc.resolveDID(params.did); - if (params.ed25519verificationkey2020) { - const didDoc: IDidDocument = result.didDocument as IDidDocument; - const verificationMethods = didDoc.verificationMethod; - verificationMethods.forEach((verificationMethod) => { - if (verificationMethod.type === constant.DID.VERIFICATION_METHOD_TYPE) { - const ed25519PublicKey = Utils.convertedStableLibKeysIntoEd25519verificationkey2020({ - publicKey: verificationMethod.publicKeyMultibase, - }); - verificationMethod.publicKeyMultibase = ed25519PublicKey.publicKeyMultibase; - } - }); - didDoc.verificationMethod = verificationMethods; - } } else if (this.didAPIService) { result = await this.didAPIService.resolveDid({ did: params.did }); } + return { didDocument: Utils.jsonToLdConvertor(result.didDocument), didDocumentMetadata: result.didDocumentMetadata, @@ -504,9 +590,13 @@ export default class HypersignDID implements IDID { privateKeyMultibase: string; verificationMethodId: string; versionId: string; - }): Promise<{ transactionHash: string }> { + readonly?: boolean; + otherSignInfo?: Array; + }): Promise<{ transactionHash: string } | { didDocument; signInfos; versionId }> { + if (!params.readonly) { + params.readonly = false; + } const response = {} as { transactionHash: string }; - if (!params.didDocument) { throw new Error('HID-SSI-SDK:: Error: params.didDocument is required to update a did'); } @@ -527,24 +617,39 @@ export default class HypersignDID implements IDID { ); } - const { didDocument, privateKeyMultibase, verificationMethodId, versionId } = params; - const didDocStringJson = Utils.ldToJsonConvertor(didDocument); - const signature = await this._sign({ didDocString: JSON.stringify(didDocStringJson), privateKeyMultibase }); - const didDoc: Did = didDocStringJson as Did; - const signInfos: Array = [ + const { didDocument, privateKeyMultibase, verificationMethodId, versionId, otherSignInfo } = params; + const signedDidDocument = await this._jsonLdSign({ + didDocument, + privateKeyMultibase, + verificationMethodId, + }); + const { proof } = signedDidDocument; + let signInfos: Array = [ { - signature, - verification_method_id: verificationMethodId, - clientSpec: undefined, + type: constant['DID_Ed25519VerificationKey2020'].SIGNATURE_TYPE, + created: proof.created ?? this._getDateTime(), + verificationMethod: verificationMethodId, + proofPurpose: VerificationMethodRelationships.assertionMethod, + proofValue: proof.proofValue, }, ]; + if (otherSignInfo) { + signInfos = [...signInfos, ...otherSignInfo]; + } + if (params.readonly === true) { + return { + didDocument, + signInfos, + versionId, + }; + } if (this.didrpc) { - const result: DeliverTxResponse = await this.didrpc.updateDID(didDoc, signInfos, versionId); + const result: DeliverTxResponse = await this.didrpc.updateDID(didDocument, signInfos, versionId); response.transactionHash = result.transactionHash; } else if (this.didAPIService) { const newSignInfos = signInfos as Array; const result = await this.didAPIService.updateDid({ - didDocument: didDoc as Did, + didDocument: didDocument as Did, signInfos: newSignInfos, deactivate: false, }); @@ -569,7 +674,6 @@ export default class HypersignDID implements IDID { versionId: string; }): Promise<{ transactionHash: string }> { const response = {} as { transactionHash: string }; - if (!params.didDocument) { throw new Error('HID-SSI-SDK:: Error: params.didDocument is required to deactivate a did'); } @@ -591,18 +695,24 @@ export default class HypersignDID implements IDID { } const { didDocument, privateKeyMultibase, verificationMethodId, versionId } = params; - const didDocStringJson = Utils.ldToJsonConvertor(didDocument); - const signature = await this._sign({ didDocString: JSON.stringify(didDocStringJson), privateKeyMultibase }); - const didDoc: Did = didDocStringJson as Did; + + const signedDidDocument = await this._jsonLdSign({ + didDocument, + privateKeyMultibase, + verificationMethodId, + }); + const { proof } = signedDidDocument; const signInfos: Array = [ { - signature, - verification_method_id: verificationMethodId, - clientSpec: undefined, + type: constant['DID_Ed25519VerificationKey2020'].SIGNATURE_TYPE, + created: proof.created ?? this._getDateTime(), + verificationMethod: verificationMethodId, + proofPurpose: VerificationMethodRelationships.assertionMethod, + proofValue: proof.proofValue, }, ]; if (this.didrpc) { - const result: DeliverTxResponse = await this.didrpc.deactivateDID(didDoc.id, signInfos, versionId); + const result: DeliverTxResponse = await this.didrpc.deactivateDID(didDocument.id as string, signInfos, versionId); response.transactionHash = result.transactionHash; } else if (this.didAPIService) { const newSignInfos = signInfos as Array; @@ -625,75 +735,88 @@ export default class HypersignDID implements IDID { * - params.did : did of the user * - params.domain : domain is the domain of the DID Document that is being authenticated * - params.verificationMethodId : verificationMethodId of the DID + * - params.purpose : purpose of Auth (authentication or assertionMethod) * @returns {Promise} Signed DID Document */ public async sign(params: { - didDocument: Did; + didDocument?: Did; privateKeyMultibase: string; challenge: string; domain: string; - did: string; + did?: string; verificationMethodId: string; + purpose?: SupportedPurpose; }): Promise { const { privateKeyMultibase, challenge, domain, did, didDocument, verificationMethodId } = params; let resolveddoc; if (!privateKeyMultibase) { throw new Error('HID-SSI-SDK:: Error: params.privateKey is required to sign a did'); } - if (!challenge) { - throw new Error('HID-SSI-SDK:: Error: params.challenge is required to sign a did'); - } - if (!domain) { - throw new Error('HID-SSI-SDK:: Error: params.domain is required to sign a did'); - } - + const didAuthType = params.purpose ?? 'authentication'; try { // if did is prvovided then resolve the did doc from the blockchain or else use the did doc provided in the params object to sign the did doc with the proof if (did && this.didrpc) { resolveddoc = await this.didrpc.resolveDID(did); } else if (didDocument) { resolveddoc = {}; - resolveddoc.didDocument = didDocument; + resolveddoc.didDocument = Utils.removeEmptyString(didDocument) as Did; } else { throw new Error('HID-SSI-SDK:: Error: params.did or params.didDocument is required to sign a did'); } } catch (error) { throw new Error(`HID-SSI-SDK:: Error: could not resolve did ${did}`); } + let signedDidDocument; + if (didAuthType === 'authentication') { + if (!challenge) { + throw new Error('HID-SSI-SDK:: Error: params.challenge is required to sign a did'); + } + if (!domain) { + throw new Error('HID-SSI-SDK:: Error: params.domain is required to sign a did'); + } + const publicKeyId = verificationMethodId; + const pubkey = resolveddoc.didDocument.verificationMethod.find((item) => item.id === publicKeyId); + if (!pubkey) { + throw new Error('HID-SSI-SDK:: Error: Incorrect verification method id'); + } - const publicKeyId = verificationMethodId; - const pubkey = resolveddoc.didDocument.verificationMethod.find((item) => item.id === publicKeyId); - if (!pubkey) { - throw new Error('HID-SSI-SDK:: Error: Incorrect verification method id'); - } - const { publicKeyMultibase: publicKeyMultibase1 } = Utils.convertedStableLibKeysIntoEd25519verificationkey2020({ - publicKey: pubkey.publicKeyMultibase, - }); - - const keyPair = await Ed25519VerificationKey2020.from({ - id: publicKeyId, - privateKeyMultibase, - publicKeyMultibase: publicKeyMultibase1, - }); - - const suite = new Ed25519Signature2020({ - verificationMethod: publicKeyId, - key: keyPair, - }); - const didDocumentLd = Utils.jsonToLdConvertor(resolveddoc.didDocument); - didDocumentLd['@context'].push(constant.VC.CREDENTAIL_SECURITY_SUITE); - // didDocumentLd['@context'].push(constant.VC.CREDENTAIL_ECDSA_SECURITY_SUITE) + const publicKeyMultibase1 = pubkey.publicKeyMultibase; + const keyPair = await Ed25519VerificationKey2020.from({ + id: publicKeyId, + privateKeyMultibase, + publicKeyMultibase: publicKeyMultibase1, + }); - const signedDidDocument = (await jsonSigs.sign(didDocumentLd, { - suite, - purpose: new AuthenticationProofPurpose({ - challenge, - domain, - }), - documentLoader: customLoader, - compactProof: constant.compactProof, - })) as ISignedDIDDocument; + const suite = new Ed25519Signature2020({ + verificationMethod: publicKeyId, + key: keyPair, + }); + const didDocumentLd = resolveddoc.didDocument; + const controller = { + '@context': constant.DID.CONTROLLER_CONTEXT, + id: publicKeyId, + authentication: didDocumentLd.authentication as string[], + }; + signedDidDocument = (await jsonSigs.sign(didDocumentLd, { + suite, + purpose: new AuthenticationProofPurpose({ + controller, + challenge, + domain, + }), + documentLoader, + compactProof: constant.compactProof, + })) as ISignedDIDDocument; + } else if (didAuthType === 'assertionMethod') { + signedDidDocument = await this._jsonLdSign({ + didDocument: resolveddoc.didDocument, + privateKeyMultibase, + verificationMethodId, + }); + } else { + throw new Error(`HID-SSI-SDK:: Error: unsupported purpose ${params.purpose}`); + } return signedDidDocument; } @@ -702,16 +825,18 @@ export default class HypersignDID implements IDID { * @params * - params.didDocument : Signed DID Document * - params.privateKey : private key in multibase format (base58 digitalbazar format) - * - params.challenge : challenge is a random string generated by the client + * - params.challenge : challenge is a random string generated by the client required for authentication purpose * - params.did : did of the user * - params.domain : domain is the domain of the DID Document that is being authenticated + * - params.purpose : purpose of Auth (authentication or assertion) * @returns Promise<{ verificationResult }> Verification Result */ public async verify(params: { didDocument: Did; verificationMethodId: string; - challenge: string; + challenge?: string; domain?: string; + purpose?: SupportedPurpose; }): Promise { const { didDocument, verificationMethodId, challenge, domain } = params; if (!didDocument) { @@ -725,14 +850,10 @@ export default class HypersignDID implements IDID { if (!verificationMethodId) { throw new Error('HID-SSI-SDK:: Error: params.verificationMethodId is required to verify a did'); } - - if (!challenge) { - throw new Error('HID-SSI-SDK:: Error: params.challenge is required to verify a did'); - } - - const didDoc = didDocument as Did; + const didAuthType = params.purpose ?? 'authentication'; + const didDoc = Utils.removeEmptyString(didDocument) as Did; const publicKeyId = verificationMethodId; - const pubkey = didDoc.verificationMethod.find((item) => item.id === publicKeyId); + const pubkey = didDoc.verificationMethod?.find((item) => item.id === publicKeyId); if (!pubkey) { throw new Error( @@ -741,38 +862,48 @@ export default class HypersignDID implements IDID { ' in did document' ); } - - const { publicKeyMultibase: publicKeyMultibase1 } = Utils.convertedStableLibKeysIntoEd25519verificationkey2020({ - publicKey: pubkey.publicKeyMultibase, - }); - + const publicKeyMultibase1 = pubkey.publicKeyMultibase; const keyPair = await Ed25519VerificationKey2020.from({ id: publicKeyId, - publicKeyMultibase: publicKeyMultibase1, }); - const suite = new Ed25519Signature2020({ key: keyPair, }); suite.date = new Date(new Date().getTime() - 100000).toISOString(); - - const controller: IController = { - '@context': constant.DID.CONTROLLER_CONTEXT, - id: publicKeyId, - authentication: didDoc.authentication, - }; - - const purpose = new AuthenticationProofPurpose({ - controller, - challenge, - domain, - }); + let controller: IController; + let purpose; + if (didAuthType === 'authentication') { + if (!challenge) { + throw new Error('HID-SSI-SDK:: Error: params.challenge is required to verify a did'); + } + controller = { + '@context': constant.DID.CONTROLLER_CONTEXT, + id: publicKeyId, + authentication: didDoc.authentication as string[], + }; + purpose = new AuthenticationProofPurpose({ + controller, + challenge, + domain, + }); + } else if (didAuthType === 'assertionMethod') { + controller = { + '@context': constant.DID.CONTROLLER_CONTEXT, + id: publicKeyId, + assertionMethod: didDoc.assertionMethod as string[], + }; + purpose = new AssertionProofPurpose({ + controller, + }); + } else { + throw new Error(`HID-SSI-SDK:: Error: unsupported purpose ${params.purpose}`); + } const result = await jsonSigs.verify(didDoc, { suite, purpose: purpose, - documentLoader: customLoader, + documentLoader, compactProof: constant.compactProof, }); return result; @@ -799,7 +930,7 @@ export default class HypersignDID implements IDID { address: string; chainId: string; clientSpec: IClientSpec; - verificationRelationships?: IVerificationRelationships[]; + verificationRelationships?: VerificationMethodRelationships[]; }): Promise { if (this['window'] === 'undefined') { console.log('HID-SSI-SDK:: Warning: Running in non browser mode'); @@ -822,9 +953,9 @@ export default class HypersignDID implements IDID { throw new Error('HID-SSI-SDK:: Error: params.clientSpec is invalid'); } let didDoc; - let verificationRelationships: IVerificationRelationships[] = []; + let verificationRelationships: VerificationMethodRelationships[] = []; if (params.verificationRelationships && params.verificationRelationships.length > 0) { - if (params.verificationRelationships.includes(IVerificationRelationships.keyAgreement)) { + if (params.verificationRelationships.includes(VerificationMethodRelationships.keyAgreement)) { throw new Error('HID-SSI-SDK:: Error: keyAgreement is not allowed in verificationRelationships'); } verificationRelationships = this._filterVerificationRelationships(params.verificationRelationships); @@ -841,10 +972,10 @@ export default class HypersignDID implements IDID { '', blockChainAccountId, didId, - IKeyType.EcdsaSecp256k1RecoveryMethod2020, + VerificationMethodTypes.EcdsaSecp256k1RecoveryMethod2020, verificationRelationships ); - didDoc = Utils.jsonToLdConvertor({ ...newDid }); + didDoc = { ...newDid }; delete didDoc.service; break; } @@ -852,13 +983,13 @@ export default class HypersignDID implements IDID { if (!params.publicKey) { throw new Error( 'HID-SSI-SDK:: Error: params.publicKey is required to create didoc for ' + - IKeyType.EcdsaSecp256k1VerificationKey2019 + VerificationMethodTypes.EcdsaSecp256k1VerificationKey2019 ); } if (!this._isValidMultibaseBase58String(params.publicKey)) { throw new Error( 'HID-SSI-SDK:: Error: params.publicKey mustbe multibase encoded base58 string for ' + - IKeyType.EcdsaSecp256k1VerificationKey2019 + VerificationMethodTypes.EcdsaSecp256k1VerificationKey2019 ); } @@ -869,9 +1000,10 @@ export default class HypersignDID implements IDID { multibasePublicKey, blockChainAccountId, didId, - IKeyType.EcdsaSecp256k1VerificationKey2019 + VerificationMethodTypes.EcdsaSecp256k1VerificationKey2019, + verificationRelationships ); - didDoc = Utils.jsonToLdConvertor({ ...newDid }); + didDoc = { ...newDid }; break; } @@ -882,6 +1014,13 @@ export default class HypersignDID implements IDID { return didDoc; } + // public generateKeyPairBabyJubJub() { + // return; + // } + // public async createDIDbyBabyJubJub() { + // return; + // } + // using in API /** * Register did on chain generated using wallet @@ -893,7 +1032,7 @@ export default class HypersignDID implements IDID { public async registerByClientSpec(params: { didDocument: Did; // Ld document - signInfos: SignInfo[]; + signInfos: ISignInfo[]; // type should be documentProof type. will change it later }): Promise<{ didDocument: Did; transactionHash: string }> { const response = {} as { didDocument: Did; transactionHash: string }; if (!params.didDocument || Object.keys(params.didDocument).length === 0) { @@ -919,36 +1058,57 @@ export default class HypersignDID implements IDID { throw new Error('HID-SSI-SDK:: Error: params.signInfos must be a non empty array'); } for (const i in params.signInfos) { - if (!params.signInfos[i].verification_method_id) { + if (!params.signInfos[i]['verification_method_id']) { throw new Error( `HID-SSI-SDK:: Error: params.signInfos[${i}].verification_method_id is required to register a did` ); } - const clientSpec = params.signInfos[i].clientSpec; + const clientSpec = params.signInfos[i]['clientSpec']; if (clientSpec && clientSpec.type && !(clientSpec.type in IClientSpec)) { throw new Error(`HID-SSI-SDK:: Error: params.signInfos[${0}].clientSpec is invalid`); } - if (params.signInfos[i].clientSpec?.type === IClientSpec['cosmos-ADR036']) { - if ( - params.signInfos[i].clientSpec?.adr036SignerAddress === '' || - params.signInfos[i].clientSpec?.adr036SignerAddress === undefined - ) { + if (clientSpec === undefined) { + if (!params.signInfos[i].type) { throw new Error( - `HID-SSI-SDK:: Error: params.signInfos[${i}].adr036SignerAddress is required to register a did, when clientSpec type is${params.signInfos[i].clientSpec?.type} ` + `HID-SSI-SDK:: Error: params.signInfos[${i}].type is required to register a did if clientSpec is not passed or undefined` ); } } - if (!params.signInfos[i].signature) { + if (!params.signInfos[i]['signature']) { throw new Error(`HID-SSI-SDK:: Error: params.signInfos[${i}].signature is required to register a did`); } } - const didDocStringJson = Utils.ldToJsonConvertor(params.didDocument); - const didDoc: Did = didDocStringJson as Did; + const didDoc: Did = params.didDocument as Did; const { signInfos } = params; if (this.didrpc) { - const result: DeliverTxResponse = await this.didrpc.registerDID(didDoc, signInfos); + const proofs: DocumentProof[] = []; + signInfos.forEach((sign) => { + let type; + let clientSpec; + if (sign.clientSpec?.type === IClientSpec['eth-personalSign']) { + type = constant['DID_EcdsaSecp256k1RecoveryMethod2020'].SIGNATURE_TYPE; + clientSpec = ClientSpecType.CLIENT_SPEC_TYPE_ETH_PERSONAL_SIGN; + } else if (sign['clientSpec']?.type === IClientSpec['cosmos-ADR036']) { + type = constant['DID_EcdsaSecp256k1VerificationKey2019'].SIGNATURE_TYPE; + clientSpec = ClientSpecType.CLIENT_SPEC_TYPE_COSMOS_ADR036; + } else if (sign['clientSpec'] === undefined) { + type = sign.type; + } else { + throw new Error('Invalid clientSpec type'); + } + const proof = { + type, + created: sign['created'], + verificationMethod: sign['verification_method_id'], + proofPurpose: VerificationMethodRelationships.assertionMethod, + proofValue: sign['signature'], + clientSpecType: clientSpec, + }; + proofs.push(proof); + }); + const result: DeliverTxResponse = await this.didrpc.registerDID(didDoc, proofs); response.didDocument = didDoc; response.transactionHash = result.transactionHash; } else if (this.didAPIService) { @@ -975,7 +1135,7 @@ export default class HypersignDID implements IDID { public async updateByClientSpec(params: { didDocument: Did; versionId: string; - signInfos: SignInfo[]; + signInfos: ISignInfo[]; }): Promise<{ transactionHash: string }> { const response = {} as { transactionHash: string }; if (!this.didrpc && !this.didAPIService) { @@ -994,29 +1154,18 @@ export default class HypersignDID implements IDID { throw new Error('HID-SSI-SDK:: Error: params.signInfos must be a non empty array'); } for (const i in params.signInfos) { - if (!params.signInfos[i].verification_method_id) { + if (!params.signInfos[i]['verification_method_id']) { throw new Error( `HID-SSI-SDK:: Error: params.signInfos[${i}].verification_method_id is required to register a did` ); } - const clientSpec = params.signInfos[i].clientSpec; + const clientSpec = params.signInfos[i]['clientSpec']; if (clientSpec && clientSpec.type && !(clientSpec.type in IClientSpec)) { throw new Error(`HID-SSI-SDK:: Error: params.signInfos[${0}].clientSpec is invalid`); } - if (params.signInfos[i].clientSpec?.type === IClientSpec['cosmos-ADR036']) { - if ( - params.signInfos[i].clientSpec?.adr036SignerAddress === '' || - params.signInfos[i].clientSpec?.adr036SignerAddress === undefined - ) { - throw new Error( - `HID-SSI-SDK:: Error: params.signInfos[${i}].adr036SignerAddress is required to register a did, when clientSpec type is${params.signInfos[i].clientSpec?.type} ` - ); - } - } - - if (!params.signInfos[i].signature) { + if (!params.signInfos[i]['signature']) { throw new Error(`HID-SSI-SDK:: Error: params.signInfos[${i}].signature is required to register a did`); } } @@ -1026,7 +1175,30 @@ export default class HypersignDID implements IDID { const { didDocument, signInfos, versionId } = params; if (this.didrpc) { - const result: DeliverTxResponse = await this.didrpc.updateDID(didDocument as Did, signInfos, versionId); + const proofs: DocumentProof[] = []; + signInfos.forEach((sign) => { + let type; + let clientSpec; + if (sign['clientSpec']?.type === IClientSpec['eth-personalSign']) { + type = constant['DID_EcdsaSecp256k1RecoveryMethod2020'].SIGNATURE_TYPE; + clientSpec = ClientSpecType.CLIENT_SPEC_TYPE_ETH_PERSONAL_SIGN; + } else if (sign['clientSpec']?.type === IClientSpec['cosmos-ADR036']) { + type = constant['DID_EcdsaSecp256k1VerificationKey2019'].SIGNATURE_TYPE; + clientSpec = ClientSpecType.CLIENT_SPEC_TYPE_COSMOS_ADR036; + } else { + throw new Error('Invalid clientSpec type'); + } + const proof = { + type, + created: sign['created'], + verificationMethod: sign['verification_method_id'], + proofPurpose: VerificationMethodRelationships.assertionMethod, + proofValue: sign['signature'], + clientSpecType: clientSpec, + }; + proofs.push(proof); + }); + const result: DeliverTxResponse = await this.didrpc.updateDID(didDocument as Did, proofs, versionId); response.transactionHash = result.transactionHash; } else if (this.didAPIService) { const newSignInfos = signInfos as Array; @@ -1051,7 +1223,7 @@ export default class HypersignDID implements IDID { */ public async deactivateByClientSpec(params: { didDocument: Did; - signInfos: SignInfo[]; + signInfos: ISignInfo[]; versionId: string; }): Promise<{ transactionHash: string }> { const response = {} as { transactionHash: string }; @@ -1072,28 +1244,18 @@ export default class HypersignDID implements IDID { } for (const i in params.signInfos) { - if (!params.signInfos[i].verification_method_id) { + if (!params.signInfos[i]['verification_method_id']) { throw new Error( `HID-SSI-SDK:: Error: params.signInfos[${i}].verification_method_id is required to deactivate a did` ); } - const clientSpec = params.signInfos[i].clientSpec; + const clientSpec = params.signInfos[i]['clientSpec']; if (clientSpec && clientSpec.type && !(clientSpec.type in IClientSpec)) { throw new Error(`HID-SSI-SDK:: Error: params.signInfos[${0}].clientSpec is invalid`); } - if (params.signInfos[i].clientSpec?.type === IClientSpec['cosmos-ADR036']) { - if ( - params.signInfos[i].clientSpec?.adr036SignerAddress === '' || - params.signInfos[i].clientSpec?.adr036SignerAddress === undefined - ) { - throw new Error( - `HID-SSI-SDK:: Error: params.signInfos[${i}].adr036SignerAddress is required to deactivate a did, when clientSpec type is${params.signInfos[i].clientSpec?.type} ` - ); - } - } - if (!params.signInfos[i].signature) { + if (!params.signInfos[i]['signature']) { throw new Error(`HID-SSI-SDK:: Error: params.signInfos[${i}].signature is required to deactivate a did`); } } @@ -1104,7 +1266,30 @@ export default class HypersignDID implements IDID { const { didDocument, signInfos, versionId } = params; const didDoc: Did = didDocument as Did; if (this.didrpc) { - const result: DeliverTxResponse = await this.didrpc.deactivateDID(didDoc.id, signInfos, versionId); + const proofs: DocumentProof[] = []; + signInfos.forEach((sign) => { + let type; + let clientSpec; + if (sign['clientSpec']?.type === IClientSpec['eth-personalSign']) { + type = constant['DID_EcdsaSecp256k1RecoveryMethod2020'].SIGNATURE_TYPE; + clientSpec = ClientSpecType.CLIENT_SPEC_TYPE_ETH_PERSONAL_SIGN; + } else if (sign['clientSpec']?.type === IClientSpec['cosmos-ADR036']) { + type = constant['DID_EcdsaSecp256k1VerificationKey2019'].SIGNATURE_TYPE; + clientSpec = ClientSpecType.CLIENT_SPEC_TYPE_COSMOS_ADR036; + } else { + throw new Error('Invalid clientSpec type'); + } + const proof = { + type, + created: sign['created'], + verificationMethod: sign['verification_method_id'], + proofPurpose: VerificationMethodRelationships.assertionMethod, + proofValue: sign['signature'], + clientSpecType: clientSpec, + }; + proofs.push(proof); + }); + const result: DeliverTxResponse = await this.didrpc.deactivateDID(didDoc.id as string, proofs, versionId); response.transactionHash = result.transactionHash; } else if (this.didAPIService) { const newSignInfos = signInfos as Array; @@ -1162,28 +1347,30 @@ export default class HypersignDID implements IDID { throw new Error('HID-SSI-SDK:: Error: params.address is required to sign a did'); } - const { didDocument, signature } = await this.signByClientSpec({ + const signedDidDoc = await this.signByClientSpec({ didDocument: params.didDocument, clientSpec: params.clientSpec, address: params.address, web3: params.web3, chainId: params.chainId, + verificationMethodId: params.verificationMethodId, }); - - const signInfos: Array = [ + const signInfos = [ { - signature, + signature: signedDidDoc.proof.proofValue, verification_method_id: params.verificationMethodId, + created: signedDidDoc.proof.created, clientSpec: { - type: params.clientSpec, - adr036SignerAddress: params.clientSpec === IClientSpec['cosmos-ADR036'] ? params.address : '', + type: + params.clientSpec === IClientSpec['cosmos-ADR036'] + ? IClientSpec['cosmos-ADR036'] + : IClientSpec['eth-personalSign'], }, }, ]; return await this.registerByClientSpec({ - didDocument, + didDocument: params.didDocument, signInfos, - // only for [cosmos-ADR036] }); } /** @@ -1194,21 +1381,26 @@ export default class HypersignDID implements IDID { * - params.address : Checksum address from web3 wallet * - params.web3 : web3 object * - params.chainId : Optional, chainId - * @returns {Promise<{ didDocument: Did; signature: string }>} + * - params.verificationMethodId : verificationMEthodId for generating signature + * @returns {Promise} */ public async signByClientSpec(params: { didDocument: Did; clientSpec: IClientSpec; address: string; web3: Web3 | any; + verificationMethodId: string; chainId?: string; // only for [cosmos-ADR036] - }): Promise<{ didDocument: Did; signature: string }> { + }): Promise { if (this['window'] === 'undefined') { throw new Error('HID-SSI-SDK:: Error: Running in non browser mode'); } if (!params.didDocument) { throw Error('HID-SSI-SDK:: Error: params.didDocument is required to sign'); } + if (params.didDocument['proof']) { + throw new Error('HID-SSI-SDK:: Error: params.didDocument should not contain proof in it'); + } if (!params.address) { throw new Error('HID-SSI-SDK:: Error: params.address is required to sign a did'); @@ -1222,14 +1414,45 @@ export default class HypersignDID implements IDID { if (!params.web3) { throw new Error('HID-SSI-SDK:: Error: params.web3 is required to sign'); } + if (!params.verificationMethodId) { + throw new Error('HID-SSI-SDK:: Error: params.verificationMethodId is required to sign'); + } + const vmId = params.didDocument.verificationMethod?.find((x) => x.id == params.verificationMethodId); + if (!vmId || vmId == undefined) { + throw new Error(`HID-SSI_SDK:: Error: invalid verificationMethodId`); + } + const didDoc: Did = Utils.removeEmptyString(params.didDocument) as Did; switch (params.clientSpec) { case IClientSpec['eth-personalSign']: { - const didDocStringJson = Utils.ldToJsonConvertor(params.didDocument); + // normalize didDoc with JSON LD + const normalizedDidDoc = await this._jsonLdNormalize({ doc: didDoc }); + const normalizedDidDocHash = new Uint8Array( + Buffer.from(crypto.createHash('sha256').update(normalizedDidDoc).digest('hex'), 'hex') + ); - const didDoc: Did = didDocStringJson as Did; + // construct proof + const proof = { + '@context': didDoc['@context'], + type: ProofTypes.EcdsaSecp256k1RecoverySignature2020, + created: this._getDateTime(), + verificationMethod: params.verificationMethodId, //didDoc?.verificationMethod && (didDoc.verificationMethod[0]?.id as string), // which vmId to use in case of multiple vms or we should pass vmId also in sign function + proofPurpose: VerificationMethodRelationships.assertionMethod, + }; + + // normalize proof with JSON LD + const normalizedProof = await this._jsonLdNormalize({ doc: proof }); + delete proof['@context']; + const normalizedProofHash = new Uint8Array( + Buffer.from(crypto.createHash('sha256').update(normalizedProof).digest('hex'), 'hex') + ); + const combinedHash = await this._concat(normalizedProofHash, normalizedDidDocHash); + const didDocJsonDigest = { + didId: didDoc.id, + didDocDigest: Buffer.from(combinedHash).toString('hex'), + }; const signature = await params.web3.eth.personal.sign( - JSON.stringify(didDoc, (key, value) => { + JSON.stringify(didDocJsonDigest, (key, value) => { if (value === '' || (Array.isArray(value) && value.length === 0)) { return undefined; } @@ -1237,7 +1460,10 @@ export default class HypersignDID implements IDID { }), params.address ); - return { didDocument: didDoc, signature }; + proof['proofValue'] = signature; + proof['clientSpecType'] = ClientSpecType.CLIENT_SPEC_TYPE_ETH_PERSONAL_SIGN; + didDoc['proof'] = proof; + return didDoc as ISignedDIDDocument; } case IClientSpec['cosmos-ADR036']: { if (!params.chainId) { @@ -1245,18 +1471,37 @@ export default class HypersignDID implements IDID { 'HID-SSI-SDK:: Error: params.chainId is required to sign for clientSpec ' + IClientSpec['cosmos-ADR036'] + ' and keyType ' + - IKeyType.EcdsaSecp256k1VerificationKey2019 + VerificationMethodTypes.EcdsaSecp256k1VerificationKey2019 ); } - const didDocStringJson = Utils.ldToJsonConvertor(params.didDocument); - const didDoc: Did = didDocStringJson as Did; - const didDocBytes = (await Did.encode(didDoc)).finish(); + const normalizedDidDoc = await this._jsonLdNormalize({ doc: didDoc }); + const normalizedDidDochash = new Uint8Array( + Buffer.from(crypto.createHash('sha256').update(normalizedDidDoc).digest('hex'), 'hex') + ); + + // construct proof + const proof = { + '@context': didDoc['@context'], + type: ProofTypes.EcdsaSecp256k1Signature2019, + created: this._getDateTime(), + verificationMethod: params.verificationMethodId, // which vmId to use in case of multiple vms or we should pass vmId also in sign function + proofPurpose: VerificationMethodRelationships.assertionMethod, + }; + const normalizedProof = await this._jsonLdNormalize({ doc: proof }); + delete proof['@context']; + const normalizedProofHash = new Uint8Array( + Buffer.from(crypto.createHash('sha256').update(normalizedProof).digest('hex'), 'hex') + ); + const combinedHash = await this._concat(normalizedProofHash, normalizedDidDochash); const signRespObj = await params.web3.requestMethod('signArbitrary', [ params.chainId, params.address, - didDocBytes, + combinedHash, ]); - return { didDocument: didDoc, signature: signRespObj['signature'] }; + proof['proofValue'] = signRespObj['signature']; + proof['clientSpecType'] = ClientSpecType.CLIENT_SPEC_TYPE_COSMOS_ADR036; + didDoc['proof'] = proof; + return didDoc as ISignedDIDDocument; } default: @@ -1281,7 +1526,7 @@ export default class HypersignDID implements IDID { public async addVerificationMethod(params: { did?: string; didDocument?: Did; - type: IKeyType; + type: VerificationMethodTypes; id?: string; // verificationMethodId controller?: string; publicKeyMultibase?: string; @@ -1296,7 +1541,7 @@ export default class HypersignDID implements IDID { throw new Error('HID-SSI-SDK:: Error: params.type is required to addVerificationMethod'); } const { type } = params; - if (!(type in IKeyType)) { + if (!(type in VerificationMethodTypes)) { throw new Error('HID-SSI-SDK:: Error: params.type is invalid'); } try { @@ -1322,16 +1567,16 @@ export default class HypersignDID implements IDID { throw new Error(`HID-SSI-SDK:: Error: could not resolve did ${params.did}`); } if ( - type === IKeyType.EcdsaSecp256k1RecoveryMethod2020 && + type === VerificationMethodTypes.EcdsaSecp256k1RecoveryMethod2020 && (!params.blockchainAccountId || params.blockchainAccountId.trim() === '') ) { throw new Error(`HID-SSI-SDK:: Error: params.blockchainAccountId is required for keyType ${params.type}`); } - if (type === IKeyType.EcdsaSecp256k1RecoveryMethod2020 && (!params.id || params.id.trim() === '')) { + if (type === VerificationMethodTypes.EcdsaSecp256k1RecoveryMethod2020 && (!params.id || params.id.trim() === '')) { throw new Error(`HID-SSI-SDK:: Error: params.id is required for keyType ${params.type}`); } if ( - type === IKeyType.EcdsaSecp256k1VerificationKey2019 && + type === VerificationMethodTypes.EcdsaSecp256k1VerificationKey2019 && (!params.blockchainAccountId || params.blockchainAccountId.trim() === '' || !params.publicKeyMultibase || @@ -1343,16 +1588,15 @@ export default class HypersignDID implements IDID { } if ( - (type === IKeyType.Ed25519VerificationKey2020 || - type === IKeyType.X25519KeyAgreementKey2020 || - type === IKeyType.X25519KeyAgreementKeyEIP5630) && + (type === VerificationMethodTypes.Ed25519VerificationKey2020 || + type === VerificationMethodTypes.X25519KeyAgreementKey2020 || + type === VerificationMethodTypes.X25519KeyAgreementKeyEIP5630) && !params.publicKeyMultibase ) { throw new Error('HID-SSI-SDK:: Error: params.publicKeyMultibase is required to addVerificationMethod'); } const verificationMethod = {} as VerificationMethod; - let { didDocument } = resolvedDidDoc; - didDocument = Utils.ldToJsonConvertor(didDocument); + const { didDocument } = resolvedDidDoc; if (params.id) { const checkIfVmIdExists = didDocument.verificationMethod.some((vm) => vm.id === params.id); @@ -1365,21 +1609,19 @@ export default class HypersignDID implements IDID { verificationMethod['id'] = params?.id ?? `${didDocument.id}#key-${VMLength + 1}`; verificationMethod['type'] = type; verificationMethod['controller'] = didDocument.id; - if (type !== IKeyType.EcdsaSecp256k1RecoveryMethod2020) { - if (type === IKeyType.Ed25519VerificationKey2020) { - const { publicKeyMultibase: publicKeyMultibase1 } = Utils.convertEd25519verificationkey2020toStableLibKeysInto({ - publicKey: params.publicKeyMultibase, - }); - verificationMethod['publicKeyMultibase'] = publicKeyMultibase1; - } else { - verificationMethod['publicKeyMultibase'] = params?.publicKeyMultibase ?? ''; - } + if (type !== VerificationMethodTypes.EcdsaSecp256k1RecoveryMethod2020) { + verificationMethod['publicKeyMultibase'] = params?.publicKeyMultibase ?? ''; + } + if (type !== VerificationMethodTypes.Ed25519VerificationKey2020) { + verificationMethod['blockchainAccountId'] = params?.blockchainAccountId ?? ''; + } + if (type == VerificationMethodTypes.BabyJubJubKey2021) { + delete verificationMethod['blockchainAccountId']; } - verificationMethod['blockchainAccountId'] = params?.blockchainAccountId ?? ''; didDocument.verificationMethod.push(verificationMethod); if ( - verificationMethod['type'] === IKeyType.X25519KeyAgreementKey2020 || - verificationMethod['type'] === IKeyType.X25519KeyAgreementKeyEIP5630 + verificationMethod['type'] === VerificationMethodTypes.X25519KeyAgreementKey2020 || + verificationMethod['type'] === VerificationMethodTypes.X25519KeyAgreementKeyEIP5630 ) { didDocument.keyAgreement.push(verificationMethod['id']); } else { @@ -1388,16 +1630,28 @@ export default class HypersignDID implements IDID { didDocument.capabilityDelegation.push(verificationMethod['id']); didDocument.capabilityInvocation.push(verificationMethod['id']); } - if (verificationMethod['type'] === IKeyType.X25519KeyAgreementKey2020) { - const newContext = constant['DID_' + IKeyType.Ed25519VerificationKey2020].DID_KEYAGREEMENT_CONTEXT; - if (!didDocument['context'].includes(newContext)) { - didDocument['context'].push(newContext); + if (verificationMethod['type'] === VerificationMethodTypes.X25519KeyAgreementKey2020) { + const newContext = constant['DID_' + VerificationMethodTypes.Ed25519VerificationKey2020].DID_KEYAGREEMENT_CONTEXT; + if (!didDocument['@context'].includes(newContext)) { + didDocument['@context'].push(newContext); + } + } + if (verificationMethod['type'] === VerificationMethodTypes.X25519KeyAgreementKeyEIP5630) { + const newContext = + constant['DID_' + VerificationMethodTypes.EcdsaSecp256k1RecoveryMethod2020].DID_KEYAGREEMENT_CONTEXT; + if (!didDocument['@context'].includes(newContext)) { + didDocument['@context'].push(newContext); } } - if (verificationMethod['type'] === IKeyType.X25519KeyAgreementKeyEIP5630) { - const newContext = constant['DID_' + IKeyType.EcdsaSecp256k1RecoveryMethod2020].DID_KEYAGREEMENT_CONTEXT; - if (!didDocument['context'].includes(newContext)) { - didDocument['context'].push(newContext); + if (verificationMethod['type'] === VerificationMethodTypes.BabyJubJubKey2021) { + const newContext = constant['DID_' + VerificationMethodTypes.BabyJubJubKey2021].DID_BABYJUBJUBKEY2021; + if (!didDocument['@context'].includes(newContext)) { + didDocument['@context'].push(newContext); + } + const newContext1 = constant['DID_' + VerificationMethodTypes.BabyJubJubKey2021].BABYJUBJUBSIGNATURE; + + if (!didDocument['@context'].includes(newContext1)) { + didDocument['@context'].push(newContext1); } } return didDocument; diff --git a/src/did/didRPC.ts b/src/did/didRPC.ts index 469ba67..3840933 100644 --- a/src/did/didRPC.ts +++ b/src/did/didRPC.ts @@ -6,17 +6,20 @@ import { HIDRpcEnums, HID_COSMOS_MODULE, HYPERSIGN_NETWORK_DID_PATH } from '../constants'; import * as generatedProto from '../../libs/generated/ssi/tx'; -import { Did as IDidProto, SignInfo } from '../../libs/generated/ssi/did'; +import { DidDocument as IDidProto } from '../../libs/generated/ssi/did'; +import { DocumentProof as SignInfo } from '../../libs/generated/ssi/proof'; import { SigningStargateClient } from '@cosmjs/stargate'; import axios from 'axios'; import { HIDClient } from '../hid/client'; -import { IClientSpec, IDIDResolve, IDIDRpc, IKeyType, DeliverTxResponse } from './IDID'; +import { IDIDResolve, IDIDRpc, DeliverTxResponse } from './IDID'; import { OfflineSigner } from '@cosmjs/proto-signing'; - +import Utils from '../utils'; +import * as constants from '../constants'; export class DIDRpc implements IDIDRpc { private didRestEp: string; private hidClient: HIDClient | null; + private nodeRestEp: string; constructor({ offlineSigner, nodeRpcEndpoint, @@ -31,10 +34,19 @@ export class DIDRpc implements IDIDRpc { } else { this.hidClient = null; } + this.nodeRestEp = nodeRestEndpoint; this.didRestEp = (HIDClient.hidNodeRestEndpoint ? HIDClient.hidNodeRestEndpoint : nodeRestEndpoint) + HYPERSIGN_NETWORK_DID_PATH; } + private getSigningStargateClient() { + const client = HIDClient.getHidClient(); + if (!client) { + throw new Error('HID-SSI-SDK:: Error: DIDRpc class is not initialise with offlinesigner'); + } + return client; + } + async init() { if (!this.hidClient) { throw new Error('HID-SSI-SDK:: Error: DIDRpc class is not initialise with offlinesigner'); @@ -46,24 +58,39 @@ export class DIDRpc implements IDIDRpc { if (!this.hidClient) { throw new Error('HID-SSI-SDK:: Error: DIDRpc class is not initialise with offlinesigner'); } - - const typeUrl = `${HID_COSMOS_MODULE}.${HIDRpcEnums.MsgCreateDID}`; + delete didDoc['proof']; + const typeUrl = `${HID_COSMOS_MODULE}.${HIDRpcEnums.MsgRegisterDID}`; const txMessage = { typeUrl, // Same as above - value: generatedProto[HIDRpcEnums.MsgCreateDID].fromPartial({ - didDocString: didDoc, - signatures: signInfos, - creator: HIDClient.getHidWalletAddress(), + value: generatedProto[HIDRpcEnums.MsgRegisterDID].fromPartial({ + didDocument: didDoc, + didDocumentProofs: signInfos, + txAuthor: HIDClient.getHidWalletAddress(), }), }; - const fee = 'auto'; + + const amount = await Utils.fetchFee(constants.GAS_FEE_METHODS.Register_Did, this.nodeRestEp); + const fee = { + amount: [ + { + denom: 'uhid', + amount, + }, + ], + gas: '200000', + }; const hidClient: SigningStargateClient = HIDClient.getHidClient(); + const txResult = await hidClient.signAndBroadcast(HIDClient.getHidWalletAddress(), [txMessage], fee); + if (txResult.code !== 0) { + throw new Error(`${txResult.rawLog}`); + } return txResult; } async updateDID(didDoc: IDidProto, signInfos: SignInfo[], versionId: string): Promise { + delete didDoc['proof']; if (!this.hidClient) { throw new Error('HID-SSI-SDK:: Error: DIDRpc class is not initialise with offlinesigner'); } @@ -73,18 +100,28 @@ export class DIDRpc implements IDIDRpc { const txMessage = { typeUrl, // Same as above value: generatedProto[HIDRpcEnums.MsgUpdateDID].fromPartial({ - didDocString: didDoc, - signatures: signInfos, - creator: HIDClient.getHidWalletAddress(), - version_id: versionId, + didDocument: didDoc, + didDocumentProofs: signInfos, + txAuthor: HIDClient.getHidWalletAddress(), + versionId: versionId, }), }; + const amount = await Utils.fetchFee(constants.GAS_FEE_METHODS.Update_Did, this.nodeRestEp); + const fee = { + amount: [ + { + denom: 'uhid', + amount, + }, + ], + gas: '200000', + }; - // TODO: need to find a way to make it dynamic - const fee = 'auto'; - - const hidClient: SigningStargateClient = HIDClient.getHidClient(); + const hidClient: SigningStargateClient = this.getSigningStargateClient(); const txResult = await hidClient.signAndBroadcast(HIDClient.getHidWalletAddress(), [txMessage], fee); + if (txResult.code !== 0) { + throw new Error(`${txResult.rawLog}`); + } return txResult; } @@ -98,22 +135,32 @@ export class DIDRpc implements IDIDRpc { const txMessage = { typeUrl, // Same as above value: generatedProto[HIDRpcEnums.MsgDeactivateDID].fromPartial({ - didId: did, - signatures: signInfos, - creator: HIDClient.getHidWalletAddress(), - version_id: versionId, + didDocumentId: did, + didDocumentProofs: signInfos, + txAuthor: HIDClient.getHidWalletAddress(), + versionId: versionId, }), }; - - // TODO: need to find a way to make it dynamic - const fee = 'auto'; + const amount = await Utils.fetchFee(constants.GAS_FEE_METHODS.Deactivate_Did, this.nodeRestEp); + const fee = { + amount: [ + { + denom: 'uhid', + amount, + }, + ], + gas: '200000', + }; const hidClient: SigningStargateClient = HIDClient.getHidClient(); + const txResult = await hidClient.signAndBroadcast(HIDClient.getHidWalletAddress(), [txMessage], fee); + if (txResult.code !== 0) { + throw new Error(`${txResult.rawLog}`); + } return txResult; } async resolveDID(did: string): Promise { - did = did + ':'; // TODO: we need to sort this out ... need to remove later const get_didUrl = `${this.didRestEp}/${did}`; let response; try { diff --git a/src/index.ts b/src/index.ts index 3401c29..4024040 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,13 +1,17 @@ import HypersignDID from './did/did'; +import HyperSignBJJDID from './did/bjjdid'; import HypersignVerifiableCredential from './credential/vc'; import HypersignVerifiablePresentation from './presentation/vp'; import HypersignSchema from './schema/schema'; import { OfflineSigner } from '@cosmjs/proto-signing'; -import { IClientSpec, IKeyType, ISignInfo, IVerificationRelationships } from './did/IDID'; -import { Did } from '../libs/generated/ssi/did'; +import { IClientSpec, ISignInfo, SupportedPurpose } from './did/IDID'; +import { VerificationMethodTypes as IKeyType } from '../libs/generated/ssi/client/enums'; +import { VerificationMethodRelationships as IVerificationRelationships } from '../libs/generated/ssi/client/enums'; +import { DidDocument as Did } from '../libs/generated/ssi/did'; import { IVerifiableCredential } from './credential/ICredential'; -import { Schema } from '../libs/generated/ssi/schema'; +import { CredentialSchemaDocument as Schema } from '../libs/generated/ssi/credential_schema'; import { IVerifiablePresentation } from './presentation/IPresentation'; +import HypersignBJJVerifiableCredential from './credential/bjjvc'; class HypersignSSISdk { did: HypersignDID; @@ -41,15 +45,20 @@ class HypersignSSISdk { }; this.did = new HypersignDID(constructorParams); + this.did.bjjDID = new HyperSignBJJDID(constructorParams); this.schema = new HypersignSchema(constructorParams); this.vc = new HypersignVerifiableCredential(constructorParams); + this.vc.bjjVC = new HypersignBJJVerifiableCredential(constructorParams); this.vp = new HypersignVerifiablePresentation(constructorParams); } async init() { await this.did.init(); + await this.did.bjjDID.init(); await this.schema.init(); + await this.schema.hypersignBjjschema.init(); await this.vc.init(); + await this.vc.bjjVC.init(); } } @@ -60,6 +69,7 @@ export { HypersignVerifiableCredential, HypersignVerifiablePresentation, IVerificationRelationships, + HypersignBJJVerifiableCredential, IKeyType, ISignInfo, IClientSpec, @@ -67,4 +77,5 @@ export { IVerifiableCredential, IVerifiablePresentation, Schema, + SupportedPurpose, }; diff --git a/src/presentation/IPresentation.ts b/src/presentation/IPresentation.ts index 7ffe58b..8c0eef3 100644 --- a/src/presentation/IPresentation.ts +++ b/src/presentation/IPresentation.ts @@ -22,7 +22,7 @@ import { IVerifiableCredential } from '../credential/ICredential'; export interface IVerifiablePresentation { id: string; type: Array; - verifiableCredential: Array | Array; + verifiableCredential: Array; holder: string; proof: object; } @@ -36,6 +36,7 @@ export interface IPresentationMethods { privateKeyMultibase: string; challenge: string; verificationMethodId: string; + domain?: string; }): Promise; verify(params: { diff --git a/src/presentation/bjjVp.ts b/src/presentation/bjjVp.ts new file mode 100644 index 0000000..05133d5 --- /dev/null +++ b/src/presentation/bjjVp.ts @@ -0,0 +1,372 @@ +/** + * Copyright (c) 2023, Hypermine Pvt. Ltd. + * All rights reserved. + * Author: Hypermine Core Team + */ + +import vc from 'vc-js'; +import jsonSigs from 'jsonld-signatures'; +import HypersignDID from '../did/did'; +import { DidDocument as Did, VerificationMethod } from '../../libs/generated/ssi/did'; + +import Utils from '../utils'; +import HypersignVerifiableCredential from '../credential/vc'; +import { IVerifiableCredential } from '../credential/ICredential'; +const { AuthenticationProofPurpose, AssertionProofPurpose } = jsonSigs.purposes; +import { VP, DID } from '../constants'; +import { IPresentationMethods, IVerifiablePresentation } from './IPresentation'; +import customLoader from '../../libs/w3cache/v1'; +import { BabyJubJubKeys2021 } from 'babyjubjub2021'; +import { BabyJubJubSignature2021Suite, BabyJubJubSignatureProof2021 } from 'babyjubjubsignature2021'; + +const documentLoader = jsonSigs.extendContextLoader(customLoader); + +export default class HyperSignBJJVP implements IPresentationMethods, IVerifiablePresentation { + private hsDid: HypersignDID; + private vc: HypersignVerifiableCredential; + id: string; + type: Array; + verifiableCredential: Array; + holder: string; + proof: object; + namespace: string; + constructor( + params: { + namespace?: string; + nodeRpcEndpoint?: string; + nodeRestEndpoint?: string; + } = {} + ) { + const { namespace, nodeRpcEndpoint, nodeRestEndpoint } = params; + + this.namespace = namespace && namespace != '' ? namespace : ''; + const nodeRPCEp = nodeRpcEndpoint ? nodeRpcEndpoint : 'MAIN'; + const nodeRestEp = nodeRestEndpoint ? nodeRestEndpoint : ''; + const offlineConstuctorParams = { nodeRpcEndpoint: nodeRPCEp, nodeRestEndpoint: nodeRestEp }; + + this.vc = new HypersignVerifiableCredential(offlineConstuctorParams); + this.hsDid = new HypersignDID(offlineConstuctorParams); + + this.id = ''; + this.type = []; + this.verifiableCredential = []; + this.holder = ''; + this.proof = {}; + } + signByClientSpec(params: { + presentation: IVerifiablePresentation; + holderDid?: string | undefined; + verificationMethodId: string; + web3Obj: any; + domain?: string | undefined; + challenge?: string | undefined; + }): Promise { + throw new Error('Method not implemented.'); + } + verifyByClientSpec(params: { + signedPresentation: IVerifiablePresentation; + challenge?: string | undefined; + domain?: string | undefined; + issuerDid: string; + holderDid?: string | undefined; + holderDidDocSigned?: JSON | undefined; + holderVerificationMethodId: string; + issuerVerificationMethodId: string; + web3Obj: any; + }): Promise<{ verified: boolean; credentialResults: any; presentationResult: any; error: any }> { + throw new Error('Method not implemented.'); + } + + private async _getId(): Promise { + const uuid = await Utils.getUUID(); + let id; + if (this.namespace && this.namespace != '') { + id = `${VP.SCHEME}:${VP.METHOD}:${this.namespace}:${uuid}`; + } else { + id = `${VP.SCHEME}:${VP.METHOD}:${uuid}`; + } + return id; + } + + /** + * Generates a new presentation document + * @params + * - params.verifiableCredentials: Array of Verifiable Credentials + * - params.holderDid : DID of the subject + * @returns {Promise} + */ + async generate(params: { verifiableCredentials: Array; holderDid: string }): Promise { + const id = await this._getId(); + const presentation = vc.createPresentation({ + verifiableCredential: params.verifiableCredentials, + id: id, + holder: params.holderDid, + }); + return presentation; + } + + /** + * Signs a new presentation document + * @params + * - params.presentation : Array of Verifiable Credentials + * - params.holderDid : *Optional* DID of the subject + * - params.holderDidDocSigned : *Optional* DID Doc of the subject + * - params.verificationMethodId : verificationMethodId of holder + * - params.privateKeyMultibase : Private key associated with the verification method + * - params.challenge : Any random challenge + * - params.domain : Domain url + * @returns {Promise} + */ + async sign(params: { + presentation: IVerifiablePresentation; + holderDid?: string; + holderDidDocSigned?: JSON; + verificationMethodId: string; + privateKeyMultibase: string; + challenge: string; + domain?: string; + }): Promise { + if (params.holderDid && params.holderDidDocSigned) { + throw new Error('HID-SSI-SDK:: Either holderDid or holderDidDocSigned should be provided'); + } + if (!params.privateKeyMultibase) { + throw new Error('HID-SSI-SDK:: params.privateKeyMultibase is required for signing a presentation'); + } + + if (!params.presentation) { + throw new Error('HID-SSI-SDK:: params.presentation is required for signing a presentation'); + } + + if (!params.challenge) { + throw new Error('HID-SSI-SDK:: params.challenge is required for signing a presentation'); + } + + if (!params.verificationMethodId) { + throw new Error('HID-SSI-SDK:: params.verificationMethodId is required for signing a presentation'); + } + + if (!this.hsDid) { + throw new Error( + 'HID-SSI-SDK:: Error: HypersignVerifiableCredential class is not instantiated with Offlinesigner or have not been initilized' + ); + } + + let resolvedDidDoc; + if (params.holderDid) { + resolvedDidDoc = await this.hsDid.resolve({ did: params.holderDid }); + } else if (params.holderDidDocSigned) { + resolvedDidDoc = {}; + resolvedDidDoc.didDocument = params.holderDidDocSigned; + } else { + throw new Error( + 'HID-SSI-SDK:: params.holderDid or params.holderDidDocSigned is required for signing a presentation' + ); + } + const { didDocument: signerDidDoc } = resolvedDidDoc; + + // TODO: take verification method from params + const publicKeyId = params.verificationMethodId; // TODO: bad idea - should not hardcode it. + const publicKeyVerMethod: VerificationMethod = signerDidDoc['verificationMethod'].find( + (x) => x.id == publicKeyId + ) as VerificationMethod; + + const keyPair = await BabyJubJubKeys2021.fromKeys({ + privateKeyMultibase: params.privateKeyMultibase, + publicKeyMultibase: publicKeyVerMethod.publicKeyMultibase as string, + options: { + id: publicKeyVerMethod.id, + controller: publicKeyVerMethod.controller, + }, + }); + + const suite = new BabyJubJubSignature2021Suite({ + verificationMethod: publicKeyId, + key: keyPair, + }); + params.presentation['@context'].push( + 'https://raw.githubusercontent.com/hypersign-protocol/hypersign-contexts/main/BJJSignature2021.jsonld' + ); + const signedVP = await jsonSigs.sign(params.presentation, { + suite, + purpose: new AuthenticationProofPurpose({ + controller: { + '@context': ['https://www.w3.org/2018/credentials/v1'], + id: publicKeyId, + authentication: [publicKeyId], + }, + domain: params.domain, + challenge: params.challenge, + }), + + documentLoader, + }); + + return signedVP; + } + + // https://github.com/digitalbazaar/vc-js/blob/44ca660f62ad3569f338eaaaecb11a7b09949bd2/lib/vc.js#L392 + /** + * Verifies signed presentation document + * @params + * - params.signedPresentation : Signed presentation document + * - params.holderDid : DID of the subject + * - params.holderDidDocSigned : DIDdocument of the subject + * - params.holderVerificationMethodId : verificationMethodId of holder + * - params.issuerDid : DID of the issuer + * - params.issuerVerificationMethodId : verificationMethodId of issuer + * - params.domain : Optional domain + * - params.challenge : Random challenge + * @returns {Promise} + */ + async verify(params: { + signedPresentation: IVerifiablePresentation; + challenge: string; + domain?: string; + issuerDid: string; + holderDid?: string; + holderDidDocSigned?: JSON; + holderVerificationMethodId: string; // verificationMethodId of holder for authentication + issuerVerificationMethodId: string; // verificationMethodId of issuer for assertion + }): Promise { + /* eslint-disable */ + const that = this; + if (params.holderDid && params.holderDidDocSigned) { + throw new Error('HID-SSI-SDK:: Either holderDid or holderDidDocSigned should be provided'); + } + + if (!params.issuerDid) { + throw new Error('HID-SSI-SDK:: params.issuerDid is required for verifying a presentation'); + } + + if (!params.challenge) { + throw new Error('HID-SSI-SDK:: params.challenge is required for verifying a presentation'); + } + + if (!params.holderVerificationMethodId) { + throw new Error('HID-SSI-SDK:: params.holderVerificationMethodId is required for verifying a presentation'); + } + + if (!params.issuerVerificationMethodId) { + throw new Error('HID-SSI-SDK:: params.issuerVerificationMethodId is required for verifying a presentation'); + } + + if (!this.vc || !this.hsDid) { + throw new Error( + 'HID-SSI-SDK:: Error: HypersignVerifiableCredential class is not instantiated with Offlinesigner or have not been initilized' + ); + } + + if (!params.signedPresentation.proof) { + throw new Error('HID-SSI-SDK:: params.signedPresentation must be signed'); + } + + ///--------------------------------------- + /// Holder + let resolvedDidDoc; + if (params.holderDid) { + resolvedDidDoc = await this.hsDid.resolve({ did: params.holderDid }); + } else if (params.holderDidDocSigned) { + resolvedDidDoc = {}; + resolvedDidDoc.didDocument = params.holderDidDocSigned; + } else { + throw new Error('Either holderDid or holderDidDocSigned should be provided'); + } + const credentialResult = Array(); + + const verifiableCredential = params.signedPresentation.verifiableCredential; + for (let i = 0; i < verifiableCredential.length; i++) { + if (verifiableCredential[i].proof?.type === 'BabyJubJubSignatureProof2021') { + const res = await this.hsDid.resolve({ did: verifiableCredential[i].issuer }); + const didDocument = res.didDocument; + const vm = didDocument.verificationMethod.find((x) => x.id == params.issuerVerificationMethodId); + const credentailRes = await this.verifyProof(verifiableCredential[i], { + suite: new BabyJubJubSignatureProof2021({ + key: await BabyJubJubKeys2021.fromKeys({ + publicKeyMultibase: vm?.publicKeyMultibase as string, + options: { + id: vm?.id, + controller: vm?.controller, + }, + }), + }), + }); + credentialResult.push(credentailRes); + } else { + const credentailRes = await that.vc.bjjVC.verify({ + credential: verifiableCredential[i], + issuerDid: verifiableCredential[i].issuer, + verificationMethodId: verifiableCredential[i].proof?.verificationMethod as string, + }); + credentialResult.push(credentailRes); + } + } + + const { didDocument: holderDID } = resolvedDidDoc; + + const holderDidDoc: Did = holderDID as Did; + const holderPublicKeyId = params.holderVerificationMethodId; + + const holderPublicKeyVerMethod: VerificationMethod = (holderDidDoc.verificationMethod as VerificationMethod[]).find( + (x) => x.id == holderPublicKeyId + ) as VerificationMethod; + + const holderController = { + '@context': DID.CONTROLLER_CONTEXT, + id: holderDidDoc.id, + authentication: holderDidDoc.authentication, + }; + + // TODO: need to use domainname. + const presentationPurpose = new AuthenticationProofPurpose({ + controller: holderController, + domain: params.domain, + challenge: params.challenge, + }); + + const keyPair = await BabyJubJubKeys2021.fromKeys({ + publicKeyMultibase: holderPublicKeyVerMethod.publicKeyMultibase as string, + options: { + id: holderPublicKeyVerMethod.id, + controller: holderPublicKeyVerMethod.controller, + }, + }); + + const vpSuite_holder = new BabyJubJubSignature2021Suite({ + verificationMethod: holderPublicKeyId, + key: keyPair, + }); + + /* eslint-enable */ + const result = await jsonSigs.verify(params.signedPresentation, { + purpose: presentationPurpose, + suite: vpSuite_holder, + documentLoader, + // checkStatus: async function (options) { + // return await that.vc.checkCredentialStatus({ credentialId: options.credential.id }); + // }, + }); + result.results.push({ credentialResult }); + return result; + } + + async verifyProof( + derivedProofs, + params: { + suite: BabyJubJubSignatureProof2021; + } + ) { + const id = derivedProofs.proof.verificationMethod; + const result = await jsonSigs.verify(derivedProofs, { + suite: params.suite, + purpose: new AssertionProofPurpose({ + controller: { + '@context': ['https://www.w3.org/ns/did/v1'], + id, + assertionMethod: [id], + }, + }), + documentLoader, + }); + return result; + } +} diff --git a/src/presentation/vp.ts b/src/presentation/vp.ts index f47fbd3..31c4775 100644 --- a/src/presentation/vp.ts +++ b/src/presentation/vp.ts @@ -8,7 +8,7 @@ import { JCS } from 'jcs'; import vc from 'vc-js'; import jsonSigs from 'jsonld-signatures'; import HypersignDID from '../did/did'; -import { Did, VerificationMethod } from '../../libs/generated/ssi/did'; +import { DidDocument as Did, VerificationMethod } from '../../libs/generated/ssi/did'; import { Ed25519Signature2020 } from '@digitalbazaar/ed25519-signature-2020'; import { Ed25519VerificationKey2020 } from '@digitalbazaar/ed25519-verification-key-2020'; import Utils from '../utils'; @@ -20,12 +20,14 @@ import { IPresentationMethods, IVerifiablePresentation } from './IPresentation'; import customLoader from '../../libs/w3cache/v1'; import { purposes } from 'jsonld-signatures'; import { EthereumEip712Signature2021 } from 'ethereumeip712signature2021suite'; +import HyperSignBJJVP from './bjjVp'; -const documentLoader = customLoader; +const documentLoader = jsonSigs.extendContextLoader(customLoader); export default class HypersignVerifiablePresentation implements IPresentationMethods, IVerifiablePresentation { private hsDid: HypersignDID | null; private vc: HypersignVerifiableCredential; + public bjjVp: HyperSignBJJVP; id: string; type: Array; verifiableCredential: Array; @@ -53,6 +55,7 @@ export default class HypersignVerifiablePresentation implements IPresentationMet this.verifiableCredential = []; this.holder = ''; this.proof = {}; + this.bjjVp = new HyperSignBJJVP(params); } private async _getId(): Promise { @@ -92,6 +95,7 @@ export default class HypersignVerifiablePresentation implements IPresentationMet * - params.verificationMethodId : verificationMethodId of holder * - params.privateKeyMultibase : Private key associated with the verification method * - params.challenge : Any random challenge + * - params.domain : Domain url * @returns {Promise} */ async sign(params: { @@ -101,6 +105,7 @@ export default class HypersignVerifiablePresentation implements IPresentationMet verificationMethodId: string; privateKeyMultibase: string; challenge: string; + domain?: string; }): Promise { if (params.holderDid && params.holderDidDocSigned) { throw new Error('HID-SSI-SDK:: Either holderDid or holderDidDocSigned should be provided'); @@ -110,15 +115,15 @@ export default class HypersignVerifiablePresentation implements IPresentationMet } if (!params.presentation) { - throw new Error('HID-SSI-SDK:: params.presentation is required for signinng a presentation'); + throw new Error('HID-SSI-SDK:: params.presentation is required for signing a presentation'); } if (!params.challenge) { - throw new Error('HID-SSI-SDK:: params.challenge is required for signinng a presentation'); + throw new Error('HID-SSI-SDK:: params.challenge is required for signing a presentation'); } if (!params.verificationMethodId) { - throw new Error('HID-SSI-SDK:: params.verificationMethodId is required for signinng a presentation'); + throw new Error('HID-SSI-SDK:: params.verificationMethodId is required for signing a presentation'); } if (!this.hsDid) { @@ -135,7 +140,7 @@ export default class HypersignVerifiablePresentation implements IPresentationMet resolvedDidDoc.didDocument = params.holderDidDocSigned; } else { throw new Error( - 'HID-SSI-SDK:: params.holderDid or params.holderDidDocSigned is required for signinng a presentation' + 'HID-SSI-SDK:: params.holderDid or params.holderDidDocSigned is required for signing a presentation' ); } const { didDocument: signerDidDoc } = resolvedDidDoc; @@ -146,12 +151,6 @@ export default class HypersignVerifiablePresentation implements IPresentationMet (x) => x.id == publicKeyId ) as VerificationMethod; - const convertedKeyPair = Utils.convertedStableLibKeysIntoEd25519verificationkey2020({ - publicKey: publicKeyVerMethod.publicKeyMultibase, - }); - - publicKeyVerMethod['publicKeyMultibase'] = convertedKeyPair.publicKeyMultibase; - const keyPair = await Ed25519VerificationKey2020.from({ privateKeyMultibase: params.privateKeyMultibase, ...publicKeyVerMethod, @@ -167,6 +166,7 @@ export default class HypersignVerifiablePresentation implements IPresentationMet suite, challenge: params.challenge, documentLoader, + domain: params.domain, }); return signedVP; @@ -237,24 +237,15 @@ export default class HypersignVerifiablePresentation implements IPresentationMet } else { throw new Error('Either holderDid or holderDidDocSigned should be provided'); } - const { didDocument: holderDID } = resolvedDidDoc; const holderDidDoc: Did = holderDID as Did; const holderPublicKeyId = params.holderVerificationMethodId; - const holderPublicKeyVerMethod: VerificationMethod = holderDidDoc.verificationMethod.find( + const holderPublicKeyVerMethod: VerificationMethod = (holderDidDoc.verificationMethod as VerificationMethod[]).find( (x) => x.id == holderPublicKeyId ) as VerificationMethod; - // Connvert the 45 byte pub key of holder into 48 byte - const { publicKeyMultibase: holderPublicKeyMultibase } = Utils.convertedStableLibKeysIntoEd25519verificationkey2020( - { - publicKey: holderPublicKeyVerMethod.publicKeyMultibase, - } - ); - holderPublicKeyVerMethod.publicKeyMultibase = holderPublicKeyMultibase; - const holderController = { '@context': DID.CONTROLLER_CONTEXT, id: holderDidDoc.id, @@ -265,6 +256,7 @@ export default class HypersignVerifiablePresentation implements IPresentationMet const presentationPurpose = new AuthenticationProofPurpose({ controller: holderController, challenge: params.challenge, + domain: params.domain, }); const keyPair = await Ed25519VerificationKey2020.from({ @@ -280,12 +272,12 @@ export default class HypersignVerifiablePresentation implements IPresentationMet ///--------------------------------------- /// Issuer const { didDocument: issuerDID } = await this.hsDid.resolve({ did: params.issuerDid }); - if (issuerDID === null || issuerDID === undefined) { - throw new Error('Issuer DID is not registered'); + if (issuerDID === null || issuerDID === undefined || Object.keys(issuerDID).length === 0) { + throw new Error(`Issuer DID ${issuerDID} is invalid or not registered on the blockchain`); } const issuerDidDoc: Did = issuerDID as Did; - const issuerDidDocController = issuerDidDoc.controller; + const issuerDidDocController = issuerDidDoc.controller as string[]; const issuerDidDocControllerVerificationMethod = params.issuerVerificationMethodId.split('#')[0]; if (!issuerDidDocController.includes(issuerDidDocControllerVerificationMethod)) { @@ -294,7 +286,7 @@ export default class HypersignVerifiablePresentation implements IPresentationMet const issuerPublicKeyId = params.issuerVerificationMethodId; - let issuerPublicKeyVerMethod: VerificationMethod = issuerDidDoc.verificationMethod.find( + let issuerPublicKeyVerMethod: VerificationMethod = (issuerDidDoc.verificationMethod as VerificationMethod[]).find( (x) => x.id == issuerPublicKeyId ) as VerificationMethod; @@ -303,17 +295,10 @@ export default class HypersignVerifiablePresentation implements IPresentationMet did: issuerDidDocControllerVerificationMethod, }); const controllerDidDoc: Did = controllerDidDocT as Did; - issuerPublicKeyVerMethod = controllerDidDoc.verificationMethod.find( + issuerPublicKeyVerMethod = (controllerDidDoc.verificationMethod as VerificationMethod[]).find( (x) => x.id == issuerPublicKeyId ) as VerificationMethod; } - // Connvert the 45 byte pub key of issuer into 48 byte - const { publicKeyMultibase: issuerPublicKeyMultibase } = Utils.convertedStableLibKeysIntoEd25519verificationkey2020( - { - publicKey: issuerPublicKeyVerMethod.publicKeyMultibase, - } - ); - issuerPublicKeyVerMethod.publicKeyMultibase = issuerPublicKeyMultibase; const issuerController = { '@context': DID.CONTROLLER_CONTEXT, @@ -344,7 +329,7 @@ export default class HypersignVerifiablePresentation implements IPresentationMet purpose, suite: [vpSuite_holder, vcSuite_issuer], documentLoader, - unsignedPresentation: true, + unsignedPresentation: false, checkStatus: async function (options) { return await that.vc.checkCredentialStatus({ credentialId: options.credential.id }); }, @@ -370,23 +355,25 @@ export default class HypersignVerifiablePresentation implements IPresentationMet verificationMethodId: string; web3Obj; domain?: string; - challenge?: string; + challenge: string; }): Promise { if (!params.holderDid) { - throw new Error('HID-SSI-SDK:: Either holderDid or holderDidDocSigned should be provided'); + throw new Error('HID-SSI-SDK:: params.holderDid is required to sign a presentation'); } if (!params.presentation) { - throw new Error('HID-SSI-SDK:: params.presentation is required for signinng a presentation'); + throw new Error('HID-SSI-SDK:: params.presentation is required for signing a presentation'); } if (!params.challenge) { - throw new Error('HID-SSI-SDK:: params.challenge is required for signinng a presentation'); + throw new Error('HID-SSI-SDK:: params.challenge is required for signing a presentation'); } if (!params.verificationMethodId) { - throw new Error('HID-SSI-SDK:: params.verificationMethodId is required for signinng a presentation'); + throw new Error('HID-SSI-SDK:: params.verificationMethodId is required for signing a presentation'); + } + if (!params.web3Obj || Object.keys(params.web3Obj).length === 0) { + throw new Error('HID-SSI-SDK:: Error: params.web3Obj is required to sign a presentation'); } - if (!this.hsDid) { throw new Error( 'HID-SSI-SDK:: Error: HypersignVerifiableCredential class is not instantiated with Offlinesigner or have not been initilized' @@ -402,8 +389,8 @@ export default class HypersignVerifiablePresentation implements IPresentationMet params.presentation.verifiableCredential.forEach((vc) => { return vcs.push(JCS.cannonicalize(vc)); }); - params.presentation.verifiableCredential = Array(); - params.presentation.verifiableCredential = vcs; + // params.presentation.verifiableCredential = Array(); + // params.presentation.verifiableCredential = vcs; const EthereumEip712Signature2021obj = new EthereumEip712Signature2021({}, params.web3Obj); const proof = await EthereumEip712Signature2021obj.createProof({ document: params.presentation, @@ -502,18 +489,10 @@ export default class HypersignVerifiablePresentation implements IPresentationMet const publicKeyId = params.issuerVerificationMethodId; const issuerDidDoc: Did = issuerDID as Did; - const publicKeyVerMethod: VerificationMethod = issuerDidDoc.verificationMethod.find( + const publicKeyVerMethod: VerificationMethod = (issuerDidDoc.verificationMethod as VerificationMethod[]).find( (x) => x.id == publicKeyId ) as VerificationMethod; - // TODO: Get rid of this hack later. - // Convert 45 byte publick key into 48 - const { publicKeyMultibase } = Utils.convertedStableLibKeysIntoEd25519verificationkey2020({ - publicKey: publicKeyVerMethod.publicKeyMultibase, - }); - - publicKeyVerMethod.publicKeyMultibase = publicKeyMultibase; - const assertionController = { '@context': ['DID.CONTROLLER_CONTEXT'], id: issuerDidDoc.id, diff --git a/src/schema/ISchema.ts b/src/schema/ISchema.ts index b5cff0e..99ec8ef 100644 --- a/src/schema/ISchema.ts +++ b/src/schema/ISchema.ts @@ -4,7 +4,11 @@ * Author: Hypermine Core Team */ -import { Schema as ISchemaProto, Schema, SchemaDocument } from '../../libs/generated/ssi/schema'; +import { + CredentialSchemaState as Schema, + CredentialSchemaDocument as SchemaDocument, +} from '../../libs/generated/ssi/credential_schema'; +import { DocumentProof } from '../../libs/generated/ssi/proof'; export interface ISchemaFields { type: string; format?: string; @@ -21,9 +25,17 @@ export interface ISchemaMethods { additionalProperties: boolean; }): Promise; - sign(params: { privateKeyMultibase: string; schema: SchemaDocument; verificationMethodId: string }): Promise; + sign(params: { + privateKeyMultibase: string; + schema: SchemaDocument; + verificationMethodId: string; + }): Promise; - register(params: { schema: Schema }): Promise<{ transactionHash: string }>; + register(params: { schema: IResolveSchema }): Promise<{ transactionHash: string }>; - resolve(params: { schemaId: string }): Promise; + resolve(params: { schemaId: string }): Promise; +} + +export interface IResolveSchema extends SchemaDocument { + proof?: DocumentProof; } diff --git a/src/schema/bjjSchema.ts b/src/schema/bjjSchema.ts new file mode 100644 index 0000000..6f89838 --- /dev/null +++ b/src/schema/bjjSchema.ts @@ -0,0 +1,408 @@ +/** + * Copyright (c) 2023, Hypermine Pvt. Ltd. + * All rights reserved. + * Author: Hypermine Core Team + */ + +import { + CredentialSchemaDocument, + CredentialSchemaState as Schema, + CredentialSchemaDocument as SchemaDocument, + CredentialSchemaProperty as SchemaProperty, +} from '../../libs/generated/ssi/credential_schema'; +import { DocumentProof, DocumentProof as SchemaProof } from '../../libs/generated/ssi/proof'; +import { SchemaRpc } from './schemaRPC'; +import * as constants from '../constants'; +import jsonSigs from 'jsonld-signatures'; +const { AssertionProofPurpose } = jsonSigs.purposes; +import { ISchemaFields, ISchemaMethods, IResolveSchema } from './ISchema'; +import Utils from '../utils'; +import { OfflineSigner } from '@cosmjs/proto-signing'; +import { DeliverTxResponse } from '@cosmjs/stargate'; +import { extendContextLoader } from 'jsonld-signatures'; +import SchemaApiService from '../ssiApi/services/schema/schema.service'; +import customLoader from '../../libs/w3cache/v1'; +const documentLoader = extendContextLoader(customLoader); +import HypersignDID from '../did/did'; +import { VerificationMethod } from '../../libs/generated/ssi/did'; +import { BabyJubJubKeys2021 } from 'babyjubjub2021'; +import { BabyJubJubSignature2021Suite } from 'babyjubjubsignature2021'; + +export default class HypersignBJJSchema implements ISchemaMethods { + '@context': Array; + type: string; + modelVersion: string; + id: string; + name: string; + author: string; + authored: string; + schema: SchemaProperty; + schemaRpc: SchemaRpc | null; + namespace: string; + private schemaApiService: SchemaApiService | null; + private hsDid: HypersignDID; + constructor( + params: { + namespace?: string; + offlineSigner?: OfflineSigner; + nodeRpcEndpoint?: string; + nodeRestEndpoint?: string; + entityApiSecretKey?: string; + } = {} + ) { + const { namespace, offlineSigner, nodeRpcEndpoint, nodeRestEndpoint, entityApiSecretKey } = params; + const nodeRPCEp = nodeRpcEndpoint ? nodeRpcEndpoint : 'MAIN'; + const nodeRestEp = nodeRestEndpoint ? nodeRestEndpoint : ''; + this.schemaRpc = new SchemaRpc({ offlineSigner, nodeRpcEndpoint: nodeRPCEp, nodeRestEndpoint: nodeRestEp }); + this.hsDid = new HypersignDID({ offlineSigner, nodeRpcEndpoint: nodeRPCEp, nodeRestEndpoint: nodeRestEp }); + if (entityApiSecretKey && entityApiSecretKey != '') { + this.schemaApiService = new SchemaApiService(entityApiSecretKey); + this.schemaRpc = null; + } else { + this.schemaApiService = null; + } + this['@context'] = [constants.SCHEMA.SCHEMA_CONTEXT, constants.DID_BabyJubJubKey2021.BABYJUBJUBSIGNATURE]; + this.namespace = namespace && namespace != '' ? namespace : ''; + (this.type = constants.SCHEMA.SCHEMA_TYPE), + (this.modelVersion = '1.0'), + (this.id = ''), + (this.name = ''), + (this.author = ''), + (this.authored = ''); + this.schema = { + schema: '', + description: '', + type: '', + properties: '', + required: [], + additionalProperties: false, + }; + } + + // Ref: + private async _getSchemaId(): Promise { + const b = await Utils.getUUID(); + // ID Structure -> sch:::: + let id; + if (this.namespace && this.namespace != '') { + id = `${constants.SCHEMA.SCHEME}:${constants.SCHEMA.METHOD}:${this.namespace}:${b}:${this.modelVersion}`; + } else { + id = `${constants.SCHEMA.SCHEME}:${constants.SCHEMA.METHOD}:${b}:${this.modelVersion}`; + } + return id; + } + + private _getDateTime(): string { + return new Date(new Date().getTime() - 100000).toISOString().slice(0, -5) + 'Z'; + } + + private isPascalCase(inputString: string): boolean { + const pattern = /^[A-Z][a-zA-Z0-9]*$/; + return pattern.test(inputString); + } + + private async _jsonLdSign(params: { + schema: CredentialSchemaDocument; + privateKeyMultibase: string; + verificationMethodId: string; + publicKeyMultibase: string; + }) { + const { schema, privateKeyMultibase, verificationMethodId } = params; + const keyPair = await BabyJubJubKeys2021.fromKeys({ + options: { + controller: verificationMethodId, + id: verificationMethodId, + }, + privateKeyMultibase: privateKeyMultibase, + publicKeyMultibase: params.publicKeyMultibase, + }); + const suite = new BabyJubJubSignature2021Suite({ key: keyPair }); + + const signedSchema = await jsonSigs.sign(schema, { + suite, + purpose: new AssertionProofPurpose(), + documentLoader, + }); + return signedSchema.proof; + } + + /** + * Initialise the offlinesigner to interact with Hypersign blockchain + */ + public async init() { + if (!this.schemaRpc && !this.schemaApiService) { + throw new Error( + 'HID-SSI-SDK:: Error: HypersignVerifiableCredential class is not instantiated with Offlinesigner or have not been initilized with entityApiSecretKey' + ); + } + if (this.schemaRpc) { + await this.schemaRpc.init(); + } + if (this.schemaApiService) { + await this.schemaApiService.auth(); + } + } + + /** + * Generates a new schema doc without proof + * @params + * - params.name : Name of the schema + * - params.description : Optional - Description of the schema + * - params.author : DID of the author + * - params.fields : Schema fields of type ISchemaFields + * - params.additionalProperties : If additionalProperties can be added, boolean + * @returns {Promise} SchemaDocument object + */ + public async generate(params: { + name: string; + description?: string; + author: string; + fields?: Array; + additionalProperties: boolean; + }): Promise { + if (!params.author) throw new Error('HID-SSI-SDK:: Error: Author must be passed'); + if (!this.isPascalCase(params.name)) + throw new Error('HID-SSI-SDK:: Error: schema name should always be in PascalCase'); + this['@context'] = [constants.SCHEMA.SCHEMA_CONTEXT, constants.DID_BabyJubJubKey2021.BABYJUBJUBSIGNATURE]; + this.id = await this._getSchemaId(); + this.name = params.name; + this.author = params.author; + this.authored = this._getDateTime(); + this.schema = { + schema: constants.SCHEMA.SCHEMA_JSON, + description: params.description ? params.description : '', + type: 'https://schema.org/object', + properties: '', + required: [], + additionalProperties: params.additionalProperties, + }; + + const t = {}; + if (params.fields && params.fields.length > 0) { + params.fields.forEach((prop) => { + if (!prop.name) throw new Error("HID-SSI-SDK:: Error: All fields must contains property 'name'"); + const schemaPropsObj: { + propName: string; + val: { type: string; format?: string }; + } = {} as { propName: string; val: { type: string; format?: string } }; + schemaPropsObj.propName = prop.name; + schemaPropsObj.val = {} as { type: string; format?: string }; + schemaPropsObj.val.type = prop?.type ?? 'string'; + if (prop.format) schemaPropsObj.val.format = prop.format; + t[schemaPropsObj.propName] = schemaPropsObj.val; + if (prop.isRequired) { + (this.schema.required as string[]).push(prop.name); + } + }); + + this.schema.properties = JSON.stringify(t); + } + if (!this.schema.additionalProperties) { + delete this.schema.additionalProperties; + } + if (this.schema.required?.length == 0) { + delete this.schema.required; + } + return { + '@context': this['@context'], + type: this.type, + modelVersion: this.modelVersion, + id: this.id, + name: this.name, + author: this.author, + authored: this.authored, + schema: this.schema, + }; + } + + /** + * Signs a schema document and attaches proof + * @params + * - params.schema : The schema document without proof + * - params.privateKeyMultibase : Private Key to sign the doc + * - params.verificationMethodId : VerificationMethodId of the document + * @returns {Promise} Schema with proof + */ + public async sign(params: { + privateKeyMultibase: string; + schema: SchemaDocument; + verificationMethodId: string; + }): Promise { + if (!params.privateKeyMultibase) throw new Error('HID-SSI-SDK:: Error: params.privateKeyMultibase must be passed'); + if (!params.verificationMethodId) + throw new Error('HID-SSI-SDK:: Error: params.verificationMethodId must be passed'); + if (!params.schema) throw new Error('HID-SSI-SDK:: Error: Schema must be passed'); + const { schema, privateKeyMultibase, verificationMethodId } = params; + const schemaDoc: SchemaDocument = params.schema; + const { didDocument } = await this.hsDid.resolve({ did: schema.author as string }); + if (!didDocument) { + throw new Error('HID-SSI-SDK:: Error: can not resolve the author'); + } + const verificationMethod: VerificationMethod = didDocument['verificationMethod'].find( + (x) => x.id == verificationMethodId + ) as VerificationMethod; + if (!verificationMethod) { + throw new Error('HID-SSI-SDK:: Error: verificationMethod not matched'); + } + const proof = await this._jsonLdSign({ + schema, + privateKeyMultibase, + verificationMethodId, + publicKeyMultibase: verificationMethod.publicKeyMultibase as string, + }); + + schemaDoc['proof'] = {} as SchemaProof; + const schemaToReturn: IResolveSchema = schemaDoc as IResolveSchema; + if (proof) { + schemaToReturn['proof'] = { ...schemaToReturn['proof'], ...proof }; + } + + return schemaToReturn; + } + + /** + * Register a schema Document in Hypersign blockchain - an onchain activity + * @params + * - params.schema : The schema document with schemaProof + * @returns {Promise} Result of the registration + */ + public async register(params: { schema: IResolveSchema }): Promise<{ transactionHash: string }> { + if (!params.schema) throw new Error('HID-SSI-SDK:: Error: schema must be passed'); + if (!params.schema['proof']) throw new Error('HID-SSI-SDK:: Error: schema.proof must be passed'); + if (!params.schema['proof'].created) throw new Error('HID-SSI-SDK:: Error: schema.proof must Contain created'); + if (!params.schema['proof'].proofPurpose) + throw new Error('HID-SSI-SDK:: Error: schema.proof must Contain proofPurpose'); + if (!params.schema['proof'].proofValue) + throw new Error('HID-SSI-SDK:: Error: schema.proof must Contain proofValue'); + if (!params.schema['proof'].type) throw new Error('HID-SSI-SDK:: Error: schema.proof must Contain type'); + if (!params.schema['proof'].verificationMethod) + throw new Error('HID-SSI-SDK:: Error: schema.proof must Contain verificationMethod'); + + if (!this.schemaRpc && !this.schemaApiService) { + throw new Error( + 'HID-SSI-SDK:: Error: HypersignSchema class is not instantiated with Offlinesigner or have not been initilized with entityApiSecret' + ); + } + const response = {} as { transactionHash: string }; + const schemaDoc = params.schema; + const proof = schemaDoc['proof'] as DocumentProof; + if (this.schemaRpc) { + const result: DeliverTxResponse = await this.schemaRpc.registerSchema(schemaDoc as SchemaDocument, proof); + response.transactionHash = result.transactionHash; + } else if (this.schemaApiService) { + const result: { transactionHash: string } = await this.schemaApiService.registerSchema({ + schemaDocument: params.schema, + schemaProof: params.schema['proof'], + }); + response.transactionHash = result.transactionHash; + } + return response; + } + + /** + * Resolves a schema document with schemId from Hypersign blockchain - an onchain activity + * @params + * - params.schemaId : Id of the schema document + * @returns {Promise} Returns schema document + */ + public async resolve(params: { schemaId: string }): Promise { + if (!params.schemaId) throw new Error('HID-SSI-SDK:: Error: SchemaId must be passed'); + + if (!this.schemaRpc) { + throw new Error( + 'HID-SSI-SDK:: Error: HypersignSchema class is not instantiated with Offlinesigner or have not been initilized' + ); + } + const schemaArr: Array = await this.schemaRpc.resolveSchema(params.schemaId); + + if (!schemaArr || schemaArr.length < 0) { + throw new Error('HID-SSI-SDK:: Error: No schema found, id = ' + params.schemaId); + } + const schemaT = schemaArr[0] as Schema; + + const schema = { + credentialSchemaDocument: (schemaArr[0] as any).schema ? schemaArr[0] : schemaT.credentialSchemaDocument, + credentialSchemaProof: (schemaArr[0] as any).proof ? (schemaArr[0] as any).proof : schemaT.credentialSchemaProof, + } as Schema; + + const response: IResolveSchema = { + ...schema.credentialSchemaDocument, + proof: schema.credentialSchemaProof as SchemaProof, + }; + + // Competable Schema with https://www.w3.org/TR/vc-json-schema/#jsonschema currently not used + + return response; + } + + public vcJsonSchema(schemaResolved: IResolveSchema) { + const schemaWrapper = schemaResolved; + const properties = JSON.parse(schemaResolved.schema?.properties as string); + const ld = {}; + const schemaProp = {}; + Object.entries(properties).forEach((elm) => { + ld[elm[0]] = { + '@id': 'https://hypersign-schema.org/' + elm[0], + // eslint-disable-next-line @typescript-eslint/ban-ts-comment + // @ts-ignore + '@type': 'xsd:' + elm[1].type, + }; + + schemaProp[elm[0]] = { + description: `Enter value for ${elm[0]}`, + title: `${elm[0]}`, + // eslint-disable-next-line @typescript-eslint/ban-ts-comment + // @ts-ignore + type: elm[1].type, + }; + }); + + const jsonLdcontext = { + '@protected': true, + '@version': 1.1, + id: '@id', + type: '@type', + // eslint-disable-next-line @typescript-eslint/ban-ts-comment + // @ts-ignore + [schemaWrapper.name]: { + '@context': { + '@propagate': true, + '@protected': true, + xsd: 'http://www.w3.org/2001/XMLSchema#', + ...ld, + }, + '@id': 'https://hypersign-schema.org', + }, + }; + + const schemaDoc = { + $schema: 'https://json-schema.org/draft/2020-12/schema', + description: schemaWrapper.schema?.description, + properties: { + credentialSubject: { + description: 'Stores the data of the credential', + title: 'Credential subject', + properties: { + id: { + description: 'Stores the DID of the subject that owns the credential', + title: 'Credential subject ID', + format: 'uri', + type: 'string', + }, + ...schemaProp, + }, + required: schemaWrapper.schema?.required, + type: 'object', + }, + }, + type: 'object', + required: ['credentialSubject'], + }; + schemaDoc['$metadata'] = { + type: schemaWrapper.name, + version: 1.0, + jsonLdContext: { '@context': { ...jsonLdcontext } }, + }; + return schemaDoc; + } +} diff --git a/src/schema/schema.ts b/src/schema/schema.ts index 8eca4f5..e74fadf 100644 --- a/src/schema/schema.ts +++ b/src/schema/schema.ts @@ -4,17 +4,33 @@ * Author: Hypermine Core Team */ -import { Schema, SchemaDocument, SchemaProof, SchemaProperty } from '../../libs/generated/ssi/schema'; +import { + CredentialSchemaDocument, + CredentialSchemaState as Schema, + CredentialSchemaDocument as SchemaDocument, + CredentialSchemaProperty as SchemaProperty, +} from '../../libs/generated/ssi/credential_schema'; +import { DocumentProof, DocumentProof as SchemaProof } from '../../libs/generated/ssi/proof'; import { SchemaRpc } from './schemaRPC'; import * as constants from '../constants'; -import { ISchemaFields, ISchemaMethods } from './ISchema'; +import jsonSigs from 'jsonld-signatures'; +const { AssertionProofPurpose } = jsonSigs.purposes; +import { ISchemaFields, ISchemaMethods, IResolveSchema } from './ISchema'; import Utils from '../utils'; import { OfflineSigner } from '@cosmjs/proto-signing'; import { DeliverTxResponse } from '@cosmjs/stargate'; +import { extendContextLoader } from 'jsonld-signatures'; +import { Ed25519Signature2020 } from '@digitalbazaar/ed25519-signature-2020'; import SchemaApiService from '../ssiApi/services/schema/schema.service'; -const ed25519 = require('@stablelib/ed25519'); +import customLoader from '../../libs/w3cache/v1'; +const documentLoader = extendContextLoader(customLoader); +import { Ed25519VerificationKey2020 } from '@digitalbazaar/ed25519-verification-key-2020'; +import HypersignDID from '../did/did'; +import { VerificationMethod } from '../../libs/generated/ssi/did'; +import HypersignBJJSchema from './bjjSchema'; export default class HyperSignSchema implements ISchemaMethods { + '@context': Array; type: string; modelVersion: string; id: string; @@ -25,6 +41,8 @@ export default class HyperSignSchema implements ISchemaMethods { schemaRpc: SchemaRpc | null; namespace: string; private schemaApiService: SchemaApiService | null; + private hsDid: HypersignDID; + public hypersignBjjschema: HypersignBJJSchema; constructor( params: { namespace?: string; @@ -38,12 +56,14 @@ export default class HyperSignSchema implements ISchemaMethods { const nodeRPCEp = nodeRpcEndpoint ? nodeRpcEndpoint : 'MAIN'; const nodeRestEp = nodeRestEndpoint ? nodeRestEndpoint : ''; this.schemaRpc = new SchemaRpc({ offlineSigner, nodeRpcEndpoint: nodeRPCEp, nodeRestEndpoint: nodeRestEp }); + this.hsDid = new HypersignDID({ offlineSigner, nodeRpcEndpoint: nodeRPCEp, nodeRestEndpoint: nodeRestEp }); if (entityApiSecretKey && entityApiSecretKey != '') { this.schemaApiService = new SchemaApiService(entityApiSecretKey); this.schemaRpc = null; } else { this.schemaApiService = null; } + this['@context'] = [constants.SCHEMA.SCHEMA_CONTEXT]; this.namespace = namespace && namespace != '' ? namespace : ''; (this.type = constants.SCHEMA.SCHEMA_TYPE), (this.modelVersion = '1.0'), @@ -59,6 +79,7 @@ export default class HyperSignSchema implements ISchemaMethods { required: [], additionalProperties: false, }; + this.hypersignBjjschema = new HypersignBJJSchema(params); } // Ref: @@ -78,6 +99,31 @@ export default class HyperSignSchema implements ISchemaMethods { return new Date(new Date().getTime() - 100000).toISOString().slice(0, -5) + 'Z'; } + private isPascalCase(inputString: string): boolean { + const pattern = /^[A-Z][a-zA-Z0-9]*$/; + return pattern.test(inputString); + } + private async _jsonLdSign(params: { + schema: CredentialSchemaDocument; + privateKeyMultibase: string; + verificationMethodId: string; + publicKeyMultibase: string; + }) { + const { schema, privateKeyMultibase, verificationMethodId } = params; + const keyPair = await Ed25519VerificationKey2020.from({ + id: verificationMethodId, + privateKeyMultibase: privateKeyMultibase, + publicKeyMultibase: params.publicKeyMultibase, + }); + const suite = new Ed25519Signature2020({ key: keyPair }); + const signedSchema = await jsonSigs.sign(schema, { + suite, + purpose: new AssertionProofPurpose(), + documentLoader, + }); + return signedSchema.proof; + } + /** * Initialise the offlinesigner to interact with Hypersign blockchain */ @@ -113,7 +159,9 @@ export default class HyperSignSchema implements ISchemaMethods { additionalProperties: boolean; }): Promise { if (!params.author) throw new Error('HID-SSI-SDK:: Error: Author must be passed'); - + if (!this.isPascalCase(params.name)) + throw new Error('HID-SSI-SDK:: Error: schema name should always be in PascalCase'); + this['@context'] = [constants.SCHEMA.SCHEMA_CONTEXT]; this.id = await this._getSchemaId(); this.name = params.name; this.author = params.author; @@ -121,7 +169,7 @@ export default class HyperSignSchema implements ISchemaMethods { this.schema = { schema: constants.SCHEMA.SCHEMA_JSON, description: params.description ? params.description : '', - type: 'object', + type: 'https://schema.org/object', properties: '', required: [], additionalProperties: params.additionalProperties, @@ -130,27 +178,34 @@ export default class HyperSignSchema implements ISchemaMethods { const t = {}; if (params.fields && params.fields.length > 0) { params.fields.forEach((prop) => { + if (!prop.name) throw new Error("HID-SSI-SDK:: Error: All fields must contains property 'name'"); const schemaPropsObj: { propName: string; val: { type: string; format?: string }; } = {} as { propName: string; val: { type: string; format?: string } }; schemaPropsObj.propName = prop.name; schemaPropsObj.val = {} as { type: string; format?: string }; - schemaPropsObj.val.type = prop.type; + schemaPropsObj.val.type = prop?.type ?? 'string'; if (prop.format) schemaPropsObj.val.format = prop.format; t[schemaPropsObj.propName] = schemaPropsObj.val; if (prop.isRequired) { - this.schema.required.push(prop.name); + (this.schema.required as string[]).push(prop.name); } }); this.schema.properties = JSON.stringify(t); } - + if (!this.schema.additionalProperties) { + delete this.schema.additionalProperties; + } + if (this.schema.required?.length == 0) { + delete this.schema.required; + } return { + '@context': this['@context'], type: this.type, modelVersion: this.modelVersion, id: this.id, @@ -167,37 +222,43 @@ export default class HyperSignSchema implements ISchemaMethods { * - params.schema : The schema document without proof * - params.privateKeyMultibase : Private Key to sign the doc * - params.verificationMethodId : VerificationMethodId of the document - * @returns {Promise} Schema with proof + * @returns {Promise} Schema with proof */ public async sign(params: { privateKeyMultibase: string; schema: SchemaDocument; verificationMethodId: string; - }): Promise { + }): Promise { if (!params.privateKeyMultibase) throw new Error('HID-SSI-SDK:: Error: params.privateKeyMultibase must be passed'); if (!params.verificationMethodId) throw new Error('HID-SSI-SDK:: Error: params.verificationMethodId must be passed'); if (!params.schema) throw new Error('HID-SSI-SDK:: Error: Schema must be passed'); + const { schema, privateKeyMultibase, verificationMethodId } = params; + const schemaDoc: SchemaDocument = params.schema; + const { didDocument } = await this.hsDid.resolve({ did: schema.author as string }); + if (!didDocument) { + throw new Error('HID-SSI-SDK:: Error: can not resolve the author'); + } + const verificationMethod: VerificationMethod = didDocument['verificationMethod'].find( + (x) => x.id == verificationMethodId + ) as VerificationMethod; + if (!verificationMethod) { + throw new Error('HID-SSI-SDK:: Error: verificationMethod not matched'); + } + const proof = await this._jsonLdSign({ + schema, + privateKeyMultibase, + verificationMethodId, + publicKeyMultibase: verificationMethod.publicKeyMultibase as string, + }); - const { privateKeyMultibase: privateKeyMultibaseConverted } = - Utils.convertEd25519verificationkey2020toStableLibKeysInto({ - privKey: params.privateKeyMultibase, - }); - - const schemaDoc = params.schema as Schema; - const dataBytes = (await Schema.encode(schemaDoc)).finish(); - const signed = ed25519.sign(privateKeyMultibaseConverted, dataBytes); + schemaDoc['proof'] = {} as SchemaProof; + const schemaToReturn: IResolveSchema = schemaDoc as IResolveSchema; + if (proof) { + schemaToReturn['proof'] = { ...schemaToReturn['proof'], ...proof }; + } - const proof: SchemaProof = { - type: constants.SCHEMA.SIGNATURE_TYPE, - created: this._getDateTime(), - verificationMethod: params.verificationMethodId, - proofPurpose: constants.SCHEMA.PROOF_PURPOSE, - proofValue: Buffer.from(signed).toString('base64'), - }; - schemaDoc.proof = {} as SchemaProof; - Object.assign(schemaDoc.proof, { ...proof }); - return schemaDoc; + return schemaToReturn; } /** @@ -206,15 +267,16 @@ export default class HyperSignSchema implements ISchemaMethods { * - params.schema : The schema document with schemaProof * @returns {Promise} Result of the registration */ - public async register(params: { schema: Schema }): Promise<{ transactionHash: string }> { + public async register(params: { schema: IResolveSchema }): Promise<{ transactionHash: string }> { if (!params.schema) throw new Error('HID-SSI-SDK:: Error: schema must be passed'); - if (!params.schema.proof) throw new Error('HID-SSI-SDK:: Error: schema.proof must be passed'); - if (!params.schema.proof.created) throw new Error('HID-SSI-SDK:: Error: schema.proof must Contain created'); - if (!params.schema.proof.proofPurpose) + if (!params.schema['proof']) throw new Error('HID-SSI-SDK:: Error: schema.proof must be passed'); + if (!params.schema['proof'].created) throw new Error('HID-SSI-SDK:: Error: schema.proof must Contain created'); + if (!params.schema['proof'].proofPurpose) throw new Error('HID-SSI-SDK:: Error: schema.proof must Contain proofPurpose'); - if (!params.schema.proof.proofValue) throw new Error('HID-SSI-SDK:: Error: schema.proof must Contain proofValue'); - if (!params.schema.proof.type) throw new Error('HID-SSI-SDK:: Error: schema.proof must Contain type'); - if (!params.schema.proof.verificationMethod) + if (!params.schema['proof'].proofValue) + throw new Error('HID-SSI-SDK:: Error: schema.proof must Contain proofValue'); + if (!params.schema['proof'].type) throw new Error('HID-SSI-SDK:: Error: schema.proof must Contain type'); + if (!params.schema['proof'].verificationMethod) throw new Error('HID-SSI-SDK:: Error: schema.proof must Contain verificationMethod'); if (!this.schemaRpc && !this.schemaApiService) { @@ -223,13 +285,15 @@ export default class HyperSignSchema implements ISchemaMethods { ); } const response = {} as { transactionHash: string }; + const schemaDoc = params.schema; + const proof = schemaDoc['proof'] as DocumentProof; if (this.schemaRpc) { - const result: DeliverTxResponse = await this.schemaRpc.createSchema(params.schema, params.schema.proof); + const result: DeliverTxResponse = await this.schemaRpc.registerSchema(schemaDoc as SchemaDocument, proof); response.transactionHash = result.transactionHash; } else if (this.schemaApiService) { const result: { transactionHash: string } = await this.schemaApiService.registerSchema({ schemaDocument: params.schema, - schemaProof: params.schema.proof, + schemaProof: params.schema['proof'], }); response.transactionHash = result.transactionHash; } @@ -240,9 +304,9 @@ export default class HyperSignSchema implements ISchemaMethods { * Resolves a schema document with schemId from Hypersign blockchain - an onchain activity * @params * - params.schemaId : Id of the schema document - * @returns {Promise} Returns schema document + * @returns {Promise} Returns schema document */ - public async resolve(params: { schemaId: string }): Promise { + public async resolve(params: { schemaId: string }): Promise { if (!params.schemaId) throw new Error('HID-SSI-SDK:: Error: SchemaId must be passed'); if (!this.schemaRpc) { @@ -251,10 +315,95 @@ export default class HyperSignSchema implements ISchemaMethods { ); } const schemaArr: Array = await this.schemaRpc.resolveSchema(params.schemaId); + if (!schemaArr || schemaArr.length < 0) { throw new Error('HID-SSI-SDK:: Error: No schema found, id = ' + params.schemaId); } - const schema = schemaArr[0] as Schema; - return schema; + const schemaT = schemaArr[0] as Schema; + + const schema = { + credentialSchemaDocument: (schemaArr[0] as any).schema ? schemaArr[0] : schemaT.credentialSchemaDocument, + credentialSchemaProof: (schemaArr[0] as any).proof ? (schemaArr[0] as any).proof : schemaT.credentialSchemaProof, + } as Schema; + + const response: IResolveSchema = { + ...schema.credentialSchemaDocument, + proof: schema.credentialSchemaProof as SchemaProof, + }; + + // Competable Schema with https://www.w3.org/TR/vc-json-schema/#jsonschema currently not used + + return response; + } + + public vcJsonSchema(schemaResolved: IResolveSchema) { + const schemaWrapper = schemaResolved; + const properties = JSON.parse(schemaResolved.schema?.properties as string); + const ld = {}; + const schemaProp = {}; + Object.entries(properties).forEach((elm) => { + ld[elm[0]] = { + '@id': 'https://hypersign-schema.org/' + elm[0], + // eslint-disable-next-line @typescript-eslint/ban-ts-comment + // @ts-ignore + '@type': 'xsd:' + elm[1].type, + }; + + schemaProp[elm[0]] = { + description: `Enter value for ${elm[0]}`, + title: `${elm[0]}`, + // eslint-disable-next-line @typescript-eslint/ban-ts-comment + // @ts-ignore + type: elm[1].type, + }; + }); + + const jsonLdcontext = { + '@protected': true, + '@version': 1.1, + id: '@id', + type: '@type', + // eslint-disable-next-line @typescript-eslint/ban-ts-comment + // @ts-ignore + [schemaWrapper.name]: { + '@context': { + '@propagate': true, + '@protected': true, + xsd: 'http://www.w3.org/2001/XMLSchema#', + ...ld, + }, + '@id': 'https://hypersign-schema.org', + }, + }; + + const schemaDoc = { + $schema: 'https://json-schema.org/draft/2020-12/schema', + description: schemaWrapper.schema?.description, + properties: { + credentialSubject: { + description: 'Stores the data of the credential', + title: 'Credential subject', + properties: { + id: { + description: 'Stores the DID of the subject that owns the credential', + title: 'Credential subject ID', + format: 'uri', + type: 'string', + }, + ...schemaProp, + }, + required: schemaWrapper.schema?.required, + type: 'object', + }, + }, + type: 'object', + required: ['credentialSubject'], + }; + schemaDoc['$metadata'] = { + type: schemaWrapper.name, + version: 1.0, + jsonLdContext: { '@context': { ...jsonLdcontext } }, + }; + return schemaDoc; } } diff --git a/src/schema/schemaRPC.ts b/src/schema/schemaRPC.ts index abb4033..1767223 100644 --- a/src/schema/schemaRPC.ts +++ b/src/schema/schemaRPC.ts @@ -9,17 +9,22 @@ import * as generatedProto from '../../libs/generated/ssi/tx'; import { OfflineSigner } from '@cosmjs/proto-signing'; import axios from 'axios'; import { HIDClient } from '../hid/client'; -import { Schema, SchemaProof } from '../../libs/generated/ssi/schema'; +import { CredentialSchemaDocument, CredentialSchemaState as Schema } from '../../libs/generated/ssi/credential_schema'; +import { DocumentProof as SchemaProof } from '../../libs/generated/ssi/proof'; import { DeliverTxResponse, SigningStargateClient } from '@cosmjs/stargate'; +import { CredentialSchemaDocument as SchemaDocument } from '../../libs/generated/ssi/credential_schema'; +import Utils from '../utils'; +import * as constants from '../constants'; export interface ISchemaRPC { - createSchema(schema: Schema, proof: SchemaProof): Promise; + registerSchema(schema: SchemaDocument, proof: SchemaProof): Promise; resolveSchema(schemaId: string): Promise; } export class SchemaRpc implements ISchemaRPC { public schemaRestEp: string; private hidClient: any; + private nodeRestEp: string; constructor({ offlineSigner, @@ -35,6 +40,8 @@ export class SchemaRpc implements ISchemaRPC { } else { this.hidClient = null; } + + this.nodeRestEp = nodeRestEndpoint; this.schemaRestEp = HIDClient.hidNodeRestEndpoint + HYPERSIGN_NETWORK_SCHEMA_PATH; } @@ -45,33 +52,48 @@ export class SchemaRpc implements ISchemaRPC { await this.hidClient.init(); } - async createSchema(schema: Schema, proof: SchemaProof): Promise { + async registerSchema(schema: CredentialSchemaDocument, proof: SchemaProof): Promise { if (!this.hidClient) { throw new Error('HID-SSI-SDK:: Error: SchemaRpc class is not initialise with offlinesigner'); } - - const typeUrl = `${HID_COSMOS_MODULE}.${HIDRpcEnums.MsgCreateSchema}`; - + const typeUrl = `${HID_COSMOS_MODULE}.${HIDRpcEnums.MsgRegisterCredentialSchema}`; const txMessage = { typeUrl, // Same as above - value: generatedProto[HIDRpcEnums.MsgCreateSchema].fromJSON({ - schemaDoc: schema, - schemaProof: proof, - creator: HIDClient.getHidWalletAddress(), + value: generatedProto[HIDRpcEnums.MsgRegisterCredentialSchema].fromPartial({ + credentialSchemaDocument: schema, + credentialSchemaProof: proof, + txAuthor: HIDClient.getHidWalletAddress(), }), }; - - // TODO: need to find a way to make it dynamic - const fee = 'auto'; + const amount = await Utils.fetchFee(constants.GAS_FEE_METHODS.Register_Cred_Schema, this.nodeRestEp); + const fee = { + amount: [ + { + denom: 'uhid', + amount, + }, + ], + gas: '200000', + }; const hidClient: SigningStargateClient = HIDClient.getHidClient(); const txResult = await hidClient.signAndBroadcast(HIDClient.getHidWalletAddress(), [txMessage], fee); + if (txResult.code !== 0) { + throw new Error(`${txResult.rawLog}`); + } return txResult; } async resolveSchema(schemaId: string): Promise> { const getSchemaUrl = `${this.schemaRestEp}/${schemaId}:`; const response = await axios.get(getSchemaUrl); - const { schema } = response.data; - return schema; + + const { credentialSchemas } = response.data; + + if (credentialSchemas === undefined) { + const { schema } = response.data; + + return schema; + } + return credentialSchemas; } } diff --git a/src/ssiApi/api-constant.ts b/src/ssiApi/api-constant.ts index b51ab21..8a1717f 100644 --- a/src/ssiApi/api-constant.ts +++ b/src/ssiApi/api-constant.ts @@ -1,7 +1,7 @@ export const APIENDPOINT = { - STUDIO_API_BASE_URL: 'http://localhost:3001/api/v1', + // STUDIO_API_BASE_URL: 'http://localhost:3001/api/v1', - // STUDIO_API_BASE_URL: 'https://api.entity.hypersign.id/api/v1', + STUDIO_API_BASE_URL: 'https://api.entity.hypersign.id/api/v1', STUDIO_API_ORIGIN: 'https://entity.hypersign.id', AUTH: '/app/oauth', DID: { diff --git a/src/ssiApi/services/credential/ICredentialApi.ts b/src/ssiApi/services/credential/ICredentialApi.ts index fd67c4d..7b1aa28 100644 --- a/src/ssiApi/services/credential/ICredentialApi.ts +++ b/src/ssiApi/services/credential/ICredentialApi.ts @@ -1,6 +1,6 @@ import { DeliverTxResponse } from "@cosmjs/stargate"; -import { CredentialProof, CredentialStatus } from "../../../../libs/generated/ssi/credential"; - +import { CredentialStatusDocument as CredentialStatus } from "../../../../libs/generated/ssi/credential_status"; +import { DocumentProof as CredentialProof } from "../../../../libs/generated/ssi/proof"; export interface IRegisterCredStatus { credentialStatus: CredentialStatus; credentialStatusProof: CredentialProof; diff --git a/src/ssiApi/services/did/IDIDApi.ts b/src/ssiApi/services/did/IDIDApi.ts index c392c59..3634756 100644 --- a/src/ssiApi/services/did/IDIDApi.ts +++ b/src/ssiApi/services/did/IDIDApi.ts @@ -1,11 +1,11 @@ -import { Did } from "../../../../libs/generated/ssi/did"; -import { IClientSpec, IDIDResolve, IKeyType, IVerificationRelationships } from "../../../did/IDID"; -import { ISignInfo } from '../../../did/IDID'; +import { DidDocument as Did } from "../../../../libs/generated/ssi/did"; +import { IDIDResolve, ISignInfo } from "../../../did/IDID"; +import { VerificationMethodTypes, VerificationMethodRelationships as IVerificationRelationships } from "../../../../libs/generated/ssi/client/enums"; export interface IGenerateDid{ namespace:string; methodSpecificId?:string; options?:{ - keyType:IKeyType, + keyType: VerificationMethodTypes, chainId:string, publicKey:string, walletAddress:string, diff --git a/src/ssiApi/services/did/did.service.ts b/src/ssiApi/services/did/did.service.ts index 8fc3097..840a724 100644 --- a/src/ssiApi/services/did/did.service.ts +++ b/src/ssiApi/services/did/did.service.ts @@ -1,4 +1,4 @@ -import { Did, SignInfo } from '../../../../libs/generated/ssi/did'; +import { DidDocument as Did } from '../../../../libs/generated/ssi/did'; import { IClientSpec, IDIDResolve } from '../../../did/IDID'; import { APIENDPOINT } from '../../api-constant'; import { IAuth, IValidateAccesstokenResp } from '../../apiAuth/IAuth'; @@ -90,24 +90,6 @@ export default class DidApiService implements IDidApiService { `HID-SSI-SDK:: Error: params.signInfos[${i}].verification_method_id is required to register a did` ); } - // if (!params.signInfos[i].clientSpec) { - // throw new Error(`HID-SSI-SDK:: Error: params.signInfos[${i}].clientSpec is required to register a did`); - // } - - // if (params.signInfos[i].clientSpec && !(params.signInfos[i].clientSpec.type in IClientSpec)) { - // throw new Error('HID-SSI-SDK:: Error: params.clientSpec is invalid'); - // } - if (params.signInfos[i].clientSpec?.type === IClientSpec['cosmos-ADR036']) { - if ( - params.signInfos[i].clientSpec?.adr036SignerAddress === '' || - params.signInfos[i].clientSpec?.adr036SignerAddress === undefined - ) { - throw new Error( - `HID-SSI-SDK:: Error: params.signInfos[${i}].adr036SignerAddress is required to register a did, when clientSpec type is${params.signInfos[i].clientSpec?.type} ` - ); - } - } - if (!params.signInfos[i].signature) { throw new Error(`HID-SSI-SDK:: Error: params.signInfos[${i}].signature is required to register a did`); } @@ -178,7 +160,6 @@ export default class DidApiService implements IDidApiService { */ public async updateDid(params: IUpdate): Promise<{ transactionHash: string }> { - console.log('did services') if (!params.didDocument || Object.keys(params.didDocument).length === 0) { throw new Error('HID-SSI-SDK:: Error: params.didDocument is required to update a did'); } @@ -197,16 +178,6 @@ export default class DidApiService implements IDidApiService { `HID-SSI-SDK:: Error: params.signInfos[${i}].verification_method_id is required to update a did` ); } - if (params.signInfos[i].clientSpec?.type === IClientSpec['cosmos-ADR036']) { - if ( - params.signInfos[i].clientSpec?.adr036SignerAddress === '' || - params.signInfos[i].clientSpec?.adr036SignerAddress === undefined - ) { - throw new Error( - `HID-SSI-SDK:: Error: params.signInfos[${i}].adr036SignerAddress is required to update a did, when clientSpec type is${params.signInfos[i].clientSpec?.type} ` - ); - } - } if (!params.signInfos[i].signature) { throw new Error(`HID-SSI-SDK:: Error: params.signInfos[${i}].signature is required to register a did`); diff --git a/src/ssiApi/services/schema/ISchemaApi.ts b/src/ssiApi/services/schema/ISchemaApi.ts index bb2461e..f4b3722 100644 --- a/src/ssiApi/services/schema/ISchemaApi.ts +++ b/src/ssiApi/services/schema/ISchemaApi.ts @@ -1,6 +1,7 @@ import { DeliverTxResponse } from "@cosmjs/stargate"; -import { SchemaDocument, SchemaProof } from "../../../../libs/generated/ssi/schema"; +import { CredentialSchemaDocument as SchemaDocument } from "../../../../libs/generated/ssi/credential_schema"; +import { DocumentProof as SchemaProof } from '../../../../libs/generated/ssi/proof' export interface IRegisterSchema { schemaDocument: SchemaDocument, schemaProof: SchemaProof diff --git a/src/tests/bjj/bjjTestScenario.spec.ts b/src/tests/bjj/bjjTestScenario.spec.ts new file mode 100644 index 0000000..37d8e6f --- /dev/null +++ b/src/tests/bjj/bjjTestScenario.spec.ts @@ -0,0 +1,471 @@ +import { HypersignSSISdk } from '../../index'; +import { expect, should } from 'chai'; +import { createWallet, mnemonic, hidNodeEp } from '../config'; +import { VerificationMethodTypes } from '../../../libs/generated/ssi/client/enums'; +let offlineSigner; +let hsSdk; +let privateKeyMultibase; +let publicKeyMultibase; +let didDocument; +let didDocId; +let subjectDid +let verificationMethodId; +let bjjPubKey; +let bjjPrivKey; +let schemaObject; +let signedSchema +let schemaId; +let credentialDetail; +let signedVC; +let unsignedverifiablePresentation; +let issuerDidDoc +let issuerDid +let holderDidDoc +let holderDid +let signedVerifiablePresentation; +let challenge; +let credenStatus; +let credentialStatusId +let credentialId; +let verifiableCredentialPresentationId; +let IssuerKp +let holderKp +const schemaBody = { + name: 'TestSchema', + description: 'This is a test schema generation', + author: '', + fields: [{ name: 'name', type: 'string', isRequired: true }] as any, + additionalProperties: false, +} +const credentialBody = { + schemaId: '', + subjectDid: '', + type: [], + issuerDid: '', + fields: { name: 'Varsha' }, + expirationDate: '', +}; +const issueCredentialBody = { + credential: credentialDetail, + issuerDid: didDocId, + verificationMethodId, + privateKeyMultibase: privateKeyMultibase, + registerCredential: true, +}; + +beforeEach(async function () { + offlineSigner = await createWallet(mnemonic); + const params = { + offlineSigner, + nodeRestEndpoint: hidNodeEp.rest, + nodeRpcEndpoint: hidNodeEp.rpc, + namespace: hidNodeEp.namespace, + }; + hsSdk = new HypersignSSISdk(params); + await hsSdk.init(); +}); +describe('DID Test scenarios', () => { + describe('#generateKeys() method to generate publicKyeMultibase and privateKeyMultiBase', function () { + it('should return publickeyMultibase and privateKeyMultibase', async function () { + const kp = await hsSdk.did.generateKeys(); + privateKeyMultibase = kp.privateKeyMultibase; + publicKeyMultibase = kp.publicKeyMultibase; + const bjjKp = await hsSdk.did.bjjDID.generateKeys(); + bjjPubKey = bjjKp.publicKeyMultibase; + bjjPrivKey = bjjKp.privateKeyMultibase; + }); + }); + describe('Bjj test scenario', function () { + it('Should be able to generate and register a DID using the Ed25519 key type, and update it by adding a Baby JubJub (BJJ) verification method (VM)', async function () { + didDocument = await hsSdk.did.generate({ publicKeyMultibase }); + didDocId = didDocument['id']; + verificationMethodId = didDocument['verificationMethod'][0].id; + await hsSdk.did.register({ + didDocument, + privateKeyMultibase, + verificationMethodId, + }); + const didDocWithBjjVM = await hsSdk.did.addVerificationMethod({ + didDocument, + type: VerificationMethodTypes.BabyJubJubKey2021, + publicKeyMultibase: bjjPubKey, + }); + const resolvedDid = await hsSdk.did.resolve({ did: didDocId }); + delete didDocWithBjjVM.alsoKnownAs; + const bjjSign = await hsSdk.did.bjjDID.update({ + didDocument: didDocWithBjjVM, + privateKeyMultibase: bjjPrivKey, + verificationMethodId: didDocWithBjjVM.verificationMethod[1].id, + versionId: resolvedDid.didDocumentMetadata.versionId, + readonly: true, + }); + await hsSdk.did.update({ + didDocument: didDocWithBjjVM, + privateKeyMultibase, + verificationMethodId: verificationMethodId,// need to check this + versionId: resolvedDid.didDocumentMetadata.versionId, + otherSignInfo: bjjSign.signInfos, + }); + const resolvedBjjDid = await hsSdk.did.resolve({ did: didDocId }) + // console.log(resolvedBjjDid) + }); + + it('Should be able to generate and register a DID using the Bjj key type, and update it by adding a Ed255 verification method (VM)', async function () { + const holderDidDocument = await hsSdk.did.bjjDID.generate({ publicKeyMultibase: bjjPubKey }); + subjectDid = holderDidDocument['id']; + const verificationMethodId = holderDidDocument['verificationMethod'][0].id; + await hsSdk.did.bjjDID.register({ + didDocument: holderDidDocument, + privateKeyMultibase: bjjPrivKey, + verificationMethodId, + }); + const didDocWithEdd255VM = await hsSdk.did.addVerificationMethod({ + didDocument: holderDidDocument, + type: VerificationMethodTypes.Ed25519VerificationKey2020, + publicKeyMultibase, + }); + const resolvedDid = await hsSdk.did.resolve({ did: subjectDid }); + delete didDocWithEdd255VM.alsoKnownAs; + const ed255Sign = await hsSdk.did.update({ + didDocument: didDocWithEdd255VM, + privateKeyMultibase: privateKeyMultibase, + verificationMethodId: didDocWithEdd255VM.verificationMethod[1].id, + versionId: resolvedDid.didDocumentMetadata.versionId, + readonly: true, + }); + delete didDocWithEdd255VM.proof + await hsSdk.did.bjjDID.update({ + didDocument: didDocWithEdd255VM, + privateKeyMultibase: bjjPrivKey, + verificationMethodId: verificationMethodId, + versionId: resolvedDid.didDocumentMetadata.versionId, + otherSignInfo: ed255Sign.signInfos, + }); + const resolvedBjjDid = await hsSdk.did.resolve({ did: subjectDid }) + // console.log(resolvedBjjDid.didDocument.verificationMethod, 'resolvedBjjDid'); + }); + + }); + + describe('Register did with two vm together', function () { + it('Should be able to generate a DID BJJ and register it by adding Ed255 VM', async function () { + const ed25519Kp = await hsSdk.did.generateKeys(); + IssuerKp = await hsSdk.did.bjjDID.generateKeys(); + issuerDidDoc = await hsSdk.did.bjjDID.generate({ publicKeyMultibase: IssuerKp.publicKeyMultibase }); + issuerDid = issuerDidDoc['id'] + const verificationMethodId = issuerDidDoc['verificationMethod'][0].id; + const didDocWithEdd255VM = await hsSdk.did.addVerificationMethod({ + didDocument: issuerDidDoc, + type: VerificationMethodTypes.Ed25519VerificationKey2020, + publicKeyMultibase: ed25519Kp.publicKeyMultibase, + }); + delete didDocWithEdd255VM.alsoKnownAs; + let ed255Sign = await hsSdk.did.createSignInfos({ + didDocument: didDocWithEdd255VM, + privateKeyMultibase: ed25519Kp.privateKeyMultibase, + verificationMethodId: didDocWithEdd255VM.verificationMethod[1].id, + }); + ed255Sign = ed255Sign[0] + delete didDocWithEdd255VM.proof + let bjjSign = await hsSdk.did.bjjDID.createSignInfos({ + didDocument: didDocWithEdd255VM, + privateKeyMultibase: IssuerKp.privateKeyMultibase, + verificationMethodId: verificationMethodId, + }); + bjjSign = bjjSign[0] + + const registeredDid = await hsSdk.did.registerByClientSpec({ + didDocument: didDocWithEdd255VM, + signInfos: [ + + { + type: bjjSign.type, + verification_method_id: bjjSign.verification_method_id, + signature: bjjSign.signature, + created: bjjSign.created + }, + { + type: ed255Sign.type, + verification_method_id: ed255Sign.verification_method_id, + signature: ed255Sign.signature, + created: ed255Sign.created + }, + ] + }) + //console.log(registeredDid) + }); + + it('Should be able to generate a Ed255 Did and register it by adding Bjj VM', async function () { + const ed25519Kp = await hsSdk.did.generateKeys(); + holderKp = await hsSdk.did.bjjDID.generateKeys(); + holderDidDoc = await hsSdk.did.generate({ publicKeyMultibase: ed25519Kp.publicKeyMultibase }); + holderDid = holderDidDoc['id'] + const verificationMethodId = holderDidDoc['verificationMethod'][0].id; + const didDocWithBJJVM = await hsSdk.did.addVerificationMethod({ + didDocument: holderDidDoc, + type: VerificationMethodTypes.BabyJubJubKey2021, + publicKeyMultibase: holderKp.publicKeyMultibase, + }); + delete didDocWithBJJVM.alsoKnownAs; + let bjjSign = await hsSdk.did.bjjDID.createSignInfos({ + didDocument: didDocWithBJJVM, + privateKeyMultibase: holderKp.privateKeyMultibase, + verificationMethodId: didDocWithBJJVM.verificationMethod[1].id, + }); + bjjSign = bjjSign[0] + let ed255Sign = await hsSdk.did.createSignInfos({ + didDocument: didDocWithBJJVM, + privateKeyMultibase: ed25519Kp.privateKeyMultibase, + verificationMethodId, + }); + ed255Sign = ed255Sign[0] + const registeredDid = await hsSdk.did.registerByClientSpec({ + didDocument: didDocWithBJJVM, + signInfos: [ + { + type: 'Ed25519Signature2020', + verification_method_id: verificationMethodId, + signature: ed255Sign.signature, + created: ed255Sign.created + }, + { + type: 'BJJSignature2021', + verification_method_id: bjjSign.verification_method_id, + signature: bjjSign.signature, + created: bjjSign.created + }, + ] + }) + // console.log(registeredDid) + }); + }); + +}); + +describe('#generate() method to create schema', function () { + it('should be able to create a new schema', async function () { + const tempSchemaBody = { ...schemaBody }; + tempSchemaBody.author = issuerDid; + schemaObject = await hsSdk.schema.hypersignBjjschema.generate(tempSchemaBody); + schemaId = schemaObject['id']; + expect(schemaObject).to.be.a('object'); + should().exist(schemaObject['type']); + should().exist(schemaObject['modelVersion']); + should().exist(schemaObject['id']); + should().exist(schemaObject['name']); + should().exist(schemaObject['author']); + should().exist(schemaObject['authored']); + should().exist(schemaObject['schema']); + expect(schemaObject.schema).to.be.a('object'); + expect(schemaObject['name']).to.be.equal(tempSchemaBody.name); + expect(schemaObject['author']).to.be.equal(tempSchemaBody.author); + }); + +}); + +describe('#sign() function to sign schema', function () { + it('should be able to sign newly created schema', async function () { + const tempSchemaBody = JSON.parse(JSON.stringify(schemaObject)) + signedSchema = await hsSdk.schema.hypersignBjjschema.sign({ + privateKeyMultibase: IssuerKp.privateKeyMultibase, + schema: tempSchemaBody, + verificationMethodId: issuerDidDoc.verificationMethod[0].id, + }); + expect(signedSchema).to.be.a('object'); + should().exist(signedSchema.proof); + should().exist(signedSchema.proof.type); + should().exist(signedSchema.proof.verificationMethod); + should().exist(signedSchema.proof.proofPurpose); + should().exist(signedSchema.proof.proofValue); + should().exist(signedSchema.proof.created); + should().exist(signedSchema.type); + should().exist(signedSchema.modelVersion); + should().exist(signedSchema.author); + should().exist(signedSchema['id']); + should().exist(signedSchema['name']); + should().exist(signedSchema['author']); + should().exist(signedSchema['authored']); + should().exist(signedSchema['schema']); + }); +}); + +describe('#register() function to register schema on blockchain', function () { + it('should be able to register schema on blockchain', async function () { + const registeredSchema = await hsSdk.schema.hypersignBjjschema.register({ + schema: signedSchema, + }); + should().exist(registeredSchema.transactionHash); + }); +}); + +describe('Verifiable Credential Opearations', () => { + describe('#generate() method to generate a credential', function () { + it('should be able to generate new credential for a schema with subject DID', async function () { + const expirationDate = new Date('12/11/2027'); + const tempCredentialBody = { ...credentialBody }; + tempCredentialBody.schemaId = schemaId; + tempCredentialBody.subjectDid = holderDid; + tempCredentialBody['expirationDate'] = expirationDate.toString(); + tempCredentialBody.issuerDid = issuerDid; + tempCredentialBody.fields = { name: 'varsha' }; + credentialDetail = await hsSdk.vc.bjjVC.generate(tempCredentialBody); + expect(credentialDetail).to.be.a('object'); + should().exist(credentialDetail['@context']); + should().exist(credentialDetail['id']); + credentialId = credentialDetail.id; + should().exist(credentialDetail['type']); + should().exist(credentialDetail['issuanceDate']); + should().exist(credentialDetail['issuer']); + should().exist(credentialDetail['credentialSubject']); + should().exist(credentialDetail['credentialStatus']); + expect(credentialDetail['credentialStatus'].type).to.be.equal('HypersignCredentialStatus2023'); + }); + + }); + + describe('#issueCredential() method for issuing credential', function () { + + it('should be able to issue credential with credential status registered on chain', async function () { + const tempIssueCredentialBody = { ...issueCredentialBody }; + tempIssueCredentialBody.credential = credentialDetail; + tempIssueCredentialBody.issuerDid = issuerDid; + tempIssueCredentialBody.verificationMethodId = issuerDidDoc.verificationMethod[0].id; + tempIssueCredentialBody.privateKeyMultibase = IssuerKp.privateKeyMultibase; + const issuedCredResult = await hsSdk.vc.bjjVC.issue(tempIssueCredentialBody); + const { signedCredential, credentialStatus, credentialStatusProof, credentialStatusRegistrationResult } = + issuedCredResult; + + signedVC = signedCredential; + credenStatus = credentialStatus; + credentialId = signedVC.id; + credentialStatusId = signedCredential['credentialStatus'].id; + expect(signedCredential).to.be.a('object'); + should().exist(signedCredential['@context']); + should().exist(signedCredential['id']); + should().exist(signedCredential['type']); + should().exist(signedCredential['issuanceDate']); + should().exist(signedCredential['issuer']); + should().exist(signedCredential['credentialSubject']); + should().exist(signedCredential['credentialSchema']); + should().exist(signedCredential['credentialStatus']); + should().exist(signedCredential['proof']); + expect(signedCredential['id']).to.be.equal(tempIssueCredentialBody.credential.id); + expect(credentialStatus).to.be.a('object'); + should().exist(credentialStatus['@context']); + should().exist(credentialStatus['id']); + should().exist(credentialStatus['issuer']); + should().exist(credentialStatus['issuanceDate']); + should().exist(credentialStatus['credentialMerkleRootHash']); + expect(credentialStatusProof).to.be.a('object'); + should().exist(credentialStatusProof['type']); + should().exist(credentialStatusProof['created']); + should().exist(credentialStatusProof['verificationMethod']); + should().exist(credentialStatusProof['proofPurpose']); + should().exist(credentialStatusProof['proofValue']); + expect(credentialStatusRegistrationResult).to.be.a('object'); + should().exist(credentialStatusRegistrationResult['height']); + should().exist(credentialStatusRegistrationResult['transactionHash']); + should().exist(credentialStatusRegistrationResult['gasUsed']); + should().exist(credentialStatusRegistrationResult['gasWanted']); + }); + + }); + describe('#verifyCredential() method to verify a credential', function () { + it('should be able to verify credential', async function () { + const params = { + credential: signedVC, + issuerDid: issuerDid, + verificationMethodId: issuerDidDoc.verificationMethod[0].id, + }; + const verificationResult = await hsSdk.vc.bjjVC.verify(params); + expect(verificationResult).to.be.a('object'); + should().exist(verificationResult.verified); + expect(verificationResult.verified).to.be.equal(true); + should().exist(verificationResult.results); + expect(verificationResult.results).to.be.a('array'); + should().exist(verificationResult.statusResult); + expect(verificationResult.statusResult.verified).to.be.equal(true); + }); + }); +}); +describe('Verifiable Presentation Operataions', () => { + describe('#generate() method to generate new presentation document', () => { + it('should be able to generate a new presentation document', async () => { + const presentationBody = { + verifiableCredentials: [credentialDetail], + holderDid: holderDid, + }; + const tempPresentationBody = { ...presentationBody }; + tempPresentationBody.verifiableCredentials[0] = credentialDetail; + tempPresentationBody.holderDid = holderDid; + unsignedverifiablePresentation = await hsSdk.vp.bjjVp.generate(tempPresentationBody); + should().exist(unsignedverifiablePresentation['@context']); + should().exist(unsignedverifiablePresentation['type']); + expect(unsignedverifiablePresentation.type[0]).to.be.equal('VerifiablePresentation'); + should().exist(unsignedverifiablePresentation['verifiableCredential']); + expect(unsignedverifiablePresentation.verifiableCredential).to.be.a('array'); + should().exist(unsignedverifiablePresentation['id']); + should().exist(unsignedverifiablePresentation['holder']); + verifiableCredentialPresentationId = unsignedverifiablePresentation.id; + }); + }); + + describe('#sign() method to sign presentation document', () => { + const signPresentationBody = { + presentation: unsignedverifiablePresentation, + holderDid: '', + verificationMethodId: '', + privateKeyMultibase: '', + challenge, + }; + + it('should be able a sign presentation document', async () => { + const tempSignPresentationBody = { ...signPresentationBody }; + tempSignPresentationBody.presentation = unsignedverifiablePresentation; + tempSignPresentationBody.holderDid = holderDid; + tempSignPresentationBody.verificationMethodId = holderDidDoc.verificationMethod[1].id; + tempSignPresentationBody.privateKeyMultibase = holderKp.privateKeyMultibase; + tempSignPresentationBody.challenge = "abc"; + tempSignPresentationBody['domain'] = "http://xyz.com"; + signedVerifiablePresentation = await hsSdk.vp.bjjVp.sign(tempSignPresentationBody); + should().exist(signedVerifiablePresentation['@context']); + should().exist(signedVerifiablePresentation['type']); + expect(signedVerifiablePresentation.type[0]).to.be.equal('VerifiablePresentation'); + should().exist(signedVerifiablePresentation['verifiableCredential']); + expect(signedVerifiablePresentation.id).to.be.equal(verifiableCredentialPresentationId); + }); + + }); + describe('#verify() method to verify a signed presentation document', () => { + const verifyPresentationBody = { + signedPresentation: signedVerifiablePresentation, + holderDid: '', + holderVerificationMethodId: '', + issuerVerificationMethodId: verificationMethodId, + privateKey: privateKeyMultibase, + challenge, + issuerDid: didDocId, + }; + + it('should be able to verify signed presentation document', async () => { + const tempverifyPresentationBody = { ...verifyPresentationBody }; + tempverifyPresentationBody.signedPresentation = signedVerifiablePresentation; + tempverifyPresentationBody.issuerDid = issuerDid; + tempverifyPresentationBody.holderDid = holderDid; + tempverifyPresentationBody.holderVerificationMethodId = holderDidDoc.verificationMethod[1].id; + tempverifyPresentationBody.issuerVerificationMethodId = issuerDidDoc.verificationMethod[0].id; + tempverifyPresentationBody.challenge = "abc"; + tempverifyPresentationBody['domain'] = "http://xyz.com" + const verifiedPresentationDetail = await hsSdk.vp.bjjVp.verify(tempverifyPresentationBody); + should().exist(verifiedPresentationDetail['verified']); + expect(verifiedPresentationDetail.verified).to.be.equal(true); + should().exist(verifiedPresentationDetail['results']); + expect(verifiedPresentationDetail.results).to.be.a('array'); + expect(verifiedPresentationDetail.results[1].credentialResult).to.be.a('array'); + expect(verifiedPresentationDetail.results[1].credentialResult.length).to.be.greaterThan(0); + expect(verifiedPresentationDetail.results[1].credentialResult[0].verified).to.be.equal(true); + }); + + }); + +}) diff --git a/src/tests/bjj/credential/bjj_credential.spec.ts b/src/tests/bjj/credential/bjj_credential.spec.ts new file mode 100644 index 0000000..2b06bff --- /dev/null +++ b/src/tests/bjj/credential/bjj_credential.spec.ts @@ -0,0 +1,1129 @@ +import { HypersignSSISdk } from '../../../index'; +import { expect, should } from 'chai'; +import { createWallet, mnemonic, hidNodeEp } from '../../config'; +let issuerPrivateKeyMultibase; +let issuerPublicKeyMultibase; +let holderPrivateKeyMultibase; +let holderPublicKeyMultibase; +let offlineSigner; +let hsSdk; +let credentialDetail3; +let issuedCredResult2; +let issuedCredResult; +let credentialStatusId; +const credentialTransMessage = [] as any; +let credentialDetail2; +let credenStatus; +let verificationMethod; +let schemaObject; +let signedSchema; +let schemaId; +let subjectDid; +let issuerDid; +let issuerDidDoc; +let subjectDidDoc; +let credentialDetail; +let credentialId; +let signedVC; +let selectiveDisclosure; +let credentialStatus2; +let credentialStatusProof2; +let signedVC1; +const issueCredentialBody = { + credential: credentialDetail, + issuerDid, + verificationMethodId: '', + privateKeyMultibase: issuerPrivateKeyMultibase, + registerCredential: true, +}; +const schemaBody = { + name: 'TestSchema', + description: 'This is a test schema generation', + author: '', + fields: [ + { name: 'name', type: 'string', isRequired: false }, + { name: 'address', type: 'string', isRequired: true }, + ], + additionalProperties: false, +}; +const credentialBody = { + schemaId: '', + subjectDid: '', + type: [], + issuerDid: '', + fields: { name: 'Varsha', address: 'Random address' }, + expirationDate: '', +}; +beforeEach(async function () { + offlineSigner = await createWallet(mnemonic); + const params = { + offlineSigner, + nodeRestEndpoint: hidNodeEp.rest, + nodeRpcEndpoint: hidNodeEp.rpc, + namespace: hidNodeEp.namespace, + }; + hsSdk = new HypersignSSISdk(params); + await hsSdk.init(); +}); + +describe('#generateKeys() method to generate publicKyeMultibase and privateKeyMultiBase', function () { + it('should return publickeyMultibase and privateKeyMultibase', async function () { + const kp = await hsSdk.did.bjjDID.generateKeys(); + issuerPrivateKeyMultibase = kp.privateKeyMultibase; + issuerPublicKeyMultibase = kp.publicKeyMultibase; + expect(kp).to.be.a('object'); + should().exist(kp.privateKeyMultibase); + should().exist(kp.publicKeyMultibase); + should().not.exist(kp.id); + }); +}); +describe('DID Operation', () => { + describe('#generate() method to generate new did', function () { + it('should be able to generate a issuer did using babyJubJub', async () => { + issuerDidDoc = await hsSdk.did.bjjDID.generate({ + publicKeyMultibase: issuerPublicKeyMultibase, + }); + issuerDid = issuerDidDoc.id; + verificationMethod = issuerDidDoc.verificationMethod; + expect(issuerDidDoc).to.be.a('object'); + should().exist(issuerDidDoc['@context']); + should().exist(issuerDidDoc['id']); + should().exist(issuerDidDoc['controller']); + should().exist(issuerDidDoc['verificationMethod']); + expect( + issuerDidDoc['verificationMethod'] && + issuerDidDoc['authentication'] && + issuerDidDoc['assertionMethod'] && + issuerDidDoc['keyAgreement'] && + issuerDidDoc['capabilityInvocation'] && + issuerDidDoc['capabilityDelegation'] && + issuerDidDoc['service'] + ).to.be.a('array'); + expect(verificationMethod[0].type).to.be.equal('BabyJubJubKey2021'); + should().exist(issuerDidDoc['authentication']); + should().exist(issuerDidDoc['assertionMethod']); + should().exist(issuerDidDoc['keyAgreement']); + should().exist(issuerDidDoc['capabilityInvocation']); + should().exist(issuerDidDoc['capabilityDelegation']); + should().exist(issuerDidDoc['service']); + expect(issuerDidDoc['authentication'].length).to.be.greaterThan(0); + expect(issuerDidDoc['assertionMethod'].length).to.be.greaterThan(0); + expect(issuerDidDoc['capabilityInvocation'].length).to.be.equal(0); + expect(issuerDidDoc['capabilityDelegation'].length).to.be.equal(0); + expect(issuerDidDoc['keyAgreement'].length).to.be.equal(0); + expect(issuerDidDoc['service'].length).to.be.equal(0); + }); + it('should be able to genrate a did for holder', async () => { + const kp = await hsSdk.did.bjjDID.generateKeys(); + holderPrivateKeyMultibase = kp.privateKeyMultibase; + holderPublicKeyMultibase = kp.publicKeyMultibase; + subjectDidDoc = await hsSdk.did.bjjDID.generate({ + publicKeyMultibase: holderPublicKeyMultibase, + }); + subjectDid = subjectDidDoc.id; + }); + }); + describe('#register() method to register did', function () { + it('should be able to register did generated using BabyJubJubKey', async () => { + const registerDid = await hsSdk.did.bjjDID.register({ + didDocument: issuerDidDoc, + privateKeyMultibase: issuerPrivateKeyMultibase, + verificationMethodId: verificationMethod[0].id, + }); + issuerDidDoc = registerDid.didDocument; + expect(issuerDidDoc).to.be.a('object'); + should().exist(issuerDidDoc['@context']); + should().exist(issuerDidDoc['id']); + should().exist(issuerDidDoc['controller']); + should().exist(issuerDidDoc['verificationMethod']); + expect( + issuerDidDoc['verificationMethod'] && + issuerDidDoc['authentication'] && + issuerDidDoc['assertionMethod'] && + issuerDidDoc['keyAgreement'] && + issuerDidDoc['capabilityInvocation'] && + issuerDidDoc['capabilityDelegation'] && + issuerDidDoc['service'] + ).to.be.a('array'); + expect(verificationMethod[0].type).to.be.equal('BabyJubJubKey2021'); + should().exist(issuerDidDoc['authentication']); + should().exist(issuerDidDoc['assertionMethod']); + should().exist(issuerDidDoc['keyAgreement']); + should().exist(issuerDidDoc['capabilityInvocation']); + should().exist(issuerDidDoc['capabilityDelegation']); + should().exist(issuerDidDoc['service']); + expect(issuerDidDoc['authentication'].length).to.be.greaterThan(0); + expect(issuerDidDoc['assertionMethod'].length).to.be.greaterThan(0); + expect(issuerDidDoc['capabilityInvocation'].length).to.be.equal(0); + expect(issuerDidDoc['capabilityDelegation'].length).to.be.equal(0); + expect(issuerDidDoc['keyAgreement'].length).to.be.equal(0); + expect(issuerDidDoc['service'].length).to.be.equal(0); + should().exist(registerDid.transactionHash); + }); + it('should be able to register did for holder', async () => { + const registerDid = await hsSdk.did.bjjDID.register({ + didDocument: subjectDidDoc, + privateKeyMultibase: holderPrivateKeyMultibase, + verificationMethodId: subjectDidDoc.verificationMethod[0].id, + }); + subjectDidDoc = registerDid.didDocument; + }); + }); +}); + +describe('Schema Operations', () => { + describe('#generate() method to create schema', function () { + it('should be able to generate new schema', async function () { + const tempSchemaBody = { ...schemaBody }; + tempSchemaBody.author = issuerDid; + schemaObject = await hsSdk.schema.hypersignBjjschema.generate(tempSchemaBody); + schemaId = schemaObject['id']; + expect(schemaObject).to.be.a('object'); + should().exist(schemaObject['type']); + should().exist(schemaObject['modelVersion']); + should().exist(schemaObject['id']); + should().exist(schemaObject['name']); + should().exist(schemaObject['author']); + should().exist(schemaObject['authored']); + should().exist(schemaObject['schema']); + expect(schemaObject.schema).to.be.a('object'); + expect(schemaObject['name']).to.be.equal(tempSchemaBody.name); + expect(schemaObject['author']).to.be.equal(tempSchemaBody.author); + expect(schemaObject['schema'].required).to.be.a('array'); + }); + }); + + describe('#sign() method to sign a schema', function () { + it('should be able to sign newly created schema', async () => { + signedSchema = await await hsSdk.schema.hypersignBjjschema.sign({ + privateKeyMultibase: issuerPrivateKeyMultibase, + schema: schemaObject, + verificationMethodId: issuerDidDoc['assertionMethod'][0], + }); + expect(signedSchema).to.be.a('object'); + should().exist(signedSchema.type); + should().exist(signedSchema.modelVersion); + should().exist(signedSchema['id']); + should().exist(signedSchema['name']); + should().exist(signedSchema['author']); + should().exist(signedSchema['authored']); + should().exist(signedSchema['schema']); + should().exist(signedSchema.schema.schema); + should().exist(signedSchema.schema.description); + should().exist(signedSchema.schema.type); + should().exist(signedSchema.schema.properties); + should().exist(signedSchema.schema.required); + should().exist(signedSchema.proof); + should().exist(signedSchema.proof.type); + expect(signedSchema.proof.type).to.be.equal('BJJSignature2021'); + should().exist(signedSchema.proof.created); + should().exist(signedSchema.proof.verificationMethod); + should().exist(signedSchema.proof.proofPurpose); + expect(signedSchema.proof.proofPurpose).to.be.equal('assertionMethod'); + should().exist(signedSchema.proof.proofValue); + }); + }); + + describe('#register() method to register a schema', function () { + it('should be able to register newly created schema', async () => { + const registerdSchema = await hsSdk.schema.hypersignBjjschema.register({ schema: signedSchema }); + should().exist(registerdSchema.transactionHash); + }); + }); + + describe('#resolve() method to resolve a schema', function () { + it('Should be able to resolve schema from blockchain', async () => { + const resolvedSchema = await hsSdk.schema.hypersignBjjschema.resolve({ schemaId }); + should().exist(resolvedSchema.context); + should().exist(resolvedSchema.type); + should().exist(resolvedSchema.modelVersion); + should().exist(resolvedSchema.id); + should().exist(resolvedSchema.name); + should().exist(resolvedSchema.author); + should().exist(resolvedSchema.authored); + should().exist(resolvedSchema.schema); + should().exist(resolvedSchema.schema.schema); + should().exist(resolvedSchema.schema.description); + should().exist(resolvedSchema.schema.type); + should().exist(resolvedSchema.schema.properties); + should().exist(resolvedSchema.schema.required); + should().exist(resolvedSchema.schema.additionalProperties); + should().exist(resolvedSchema.proof); + should().exist(resolvedSchema.proof.type); + should().exist(resolvedSchema.proof.created); + should().exist(resolvedSchema.proof.verificationMethod); + should().exist(resolvedSchema.proof.proofPurpose); + should().exist(resolvedSchema.proof.proofValue); + should().exist(resolvedSchema.proof.clientSpecType); + expect(resolvedSchema.proof.clientSpecType).to.be.equal('CLIENT_SPEC_TYPE_NONE'); + }); + }); +}); + +describe('Credential Operation', () => { + describe('#generate() method to generate a credential', function () { + it('should not be able to generate new credential for a schema as both subjectDid and subjectDidDocSigned is passed', async function () { + const tempCredentialBody = { ...credentialBody }; + tempCredentialBody.issuerDid = issuerDid; + tempCredentialBody.subjectDid = subjectDid; + tempCredentialBody['subjectDidDocSigned'] = subjectDidDoc; + return hsSdk.vc.bjjVC.generate(tempCredentialBody).catch(function (err) { + expect(function () { + throw err; + }).to.throw(Error, 'HID-SSI-SDK:: Error: Both subjectDid and subjectDidDoc cannot be passed'); + }); + }); + it('should not be able to generate new credential for a schema as not able to resolve subjectDid or subjectDidDoc as neither subjectDid nor subjectDidDocSigned is passed', async function () { + const tempCredentialBody = { ...credentialBody }; + tempCredentialBody.issuerDid = issuerDid; + return hsSdk.vc.bjjVC.generate(tempCredentialBody).catch(function (err) { + expect(function () { + throw err; + }).to.throw(Error, 'HID-SSI-SDK:: Error: Could not resolve the subjectDid or subjectDidDoc'); + }); + }); + it('should not be able to generate new credential for a schema as nether schemaId nor schema Context is passed', async function () { + const tempCredentialBody = { ...credentialBody }; + tempCredentialBody.issuerDid = issuerDid; + tempCredentialBody['subjectDidDocSigned'] = subjectDidDoc; + return hsSdk.vc.bjjVC.generate(tempCredentialBody).catch(function (err) { + expect(function () { + throw err; + }).to.throw(Error, 'schemaId is required when schemaContext and type not passed'); + }); + }); + it('should not be able to generate new credential for a schema as wrong issuer did is passed', async function () { + const tempCredentialBody = { ...credentialBody }; + tempCredentialBody.schemaId = schemaId; + tempCredentialBody.issuerDid = issuerDid + 'xyz'; + tempCredentialBody['subjectDidDocSigned'] = subjectDidDoc; + return hsSdk.vc.bjjVC.generate(tempCredentialBody).catch(function (err) { + expect(function () { + throw err; + }).to.throw( + Error, + `HID-SSI-SDK:: Error: Could not fetch issuer did doc, issuer did = ${tempCredentialBody.issuerDid}` + ); + }); + }); + it('should not be able to generate new credential for a schema as not able to get subject did doc based on subjectDid passed', async function () { + const tempCredentialBody = { ...credentialBody }; + tempCredentialBody.schemaId = schemaId; + tempCredentialBody.issuerDid = issuerDid; + tempCredentialBody['subjectDid'] = subjectDid; + return hsSdk.vc.bjjVC.generate(tempCredentialBody).catch(function (err) { + expect(function () { + throw err; + }).to.throw( + Error, + `HID-SSI-SDK:: Error: Could not fetch subject did doc, subject did ${tempCredentialBody.subjectDid}` + ); + }); + }); + it('should not be able to generate new credential for a schema as expiration date is passed in wrong format', async function () { + const todaysDate = new Date(); + const tempExpirationDate = todaysDate.setDate(todaysDate.getDate() + 2); + const expirationDate = tempExpirationDate.toString(); + const tempCredentialBody = { ...credentialBody }; + tempCredentialBody.schemaId = schemaId; + tempCredentialBody['subjectDidDocSigned'] = subjectDidDoc; + tempCredentialBody['expirationDate'] = expirationDate.toString(); + tempCredentialBody.issuerDid = issuerDid; + return hsSdk.vc.bjjVC.generate(tempCredentialBody).catch(function (err) { + expect(function () { + throw err; + }).to.throw(Error, 'Invalid time value'); + }); + }); + it('should not be able to generate new credential for a schema as additional properties in schema is set to false but sending additional properties in field value at the time of generating credential', async function () { + const expirationDate = new Date('12/11/2027'); + const tempCredentialBody = { ...credentialBody }; + tempCredentialBody.schemaId = schemaId; + tempCredentialBody['subjectDidDocSigned'] = subjectDidDoc; + tempCredentialBody['expirationDate'] = expirationDate.toString(); + tempCredentialBody.issuerDid = issuerDid; + tempCredentialBody.fields['type'] = 'string'; + tempCredentialBody.fields['value'] = 'Varsha'; + tempCredentialBody.fields['name'] = 'name'; + return hsSdk.vc.bjjVC.generate(tempCredentialBody).catch(function (err) { + expect(function () { + throw err; + }).to.throw( + Error, + `Only ["${schemaBody.fields[0].name}"] attributes are possible. additionalProperties is false in the schema` + ); + }); + }); + it('should be able to generate a credential', async () => { + const expirationDate = new Date('12/11/2027'); + const tempCredentialBody = { ...credentialBody }; + tempCredentialBody.schemaId = schemaId; + tempCredentialBody.subjectDid = subjectDid; + tempCredentialBody['expirationDate'] = expirationDate.toString(); + tempCredentialBody.issuerDid = issuerDid; + tempCredentialBody.fields = { name: 'varsha', address: 'random address' }; + credentialDetail = await hsSdk.vc.bjjVC.generate(tempCredentialBody); + expect(credentialDetail).to.be.a('object'); + should().exist(credentialDetail['@context']); + should().exist(credentialDetail['id']); + credentialId = credentialDetail.id; + should().exist(credentialDetail['type']); + should().exist(credentialDetail['issuanceDate']); + should().exist(credentialDetail['issuer']); + should().exist(credentialDetail['credentialSubject']); + should().exist(credentialDetail['credentialStatus']); + expect(credentialDetail['credentialStatus'].type).to.be.equal('HypersignCredentialStatus2023'); + }); + it('should be able to generate new credential for testing bulk registration', async function () { + const expirationDate = new Date('11/11/2027'); + const tempCredentialBody = { ...credentialBody }; + tempCredentialBody.schemaId = schemaId; + tempCredentialBody.subjectDid = subjectDid; + tempCredentialBody['expirationDate'] = expirationDate.toString(); + tempCredentialBody.issuerDid = issuerDid; + tempCredentialBody['fields'] = { name: 'varsha', address: 'random address' }; + credentialDetail2 = await hsSdk.vc.bjjVC.generate(tempCredentialBody); + expect(credentialDetail).to.be.a('object'); + should().exist(credentialDetail['@context']); + should().exist(credentialDetail['id']); + should().exist(credentialDetail['type']); + should().exist(credentialDetail['issuanceDate']); + should().exist(credentialDetail['issuer']); + should().exist(credentialDetail['credentialSubject']); + should().exist(credentialDetail['credentialSchema']); + should().exist(credentialDetail['credentialStatus']); + expect(credentialDetail['credentialStatus'].type).to.be.equal('HypersignCredentialStatus2023'); + }); + it('should be able to generate new credential even without offlinesigner passed to constructor to test bulkRegistration', async function () { + const expirationDate = new Date('11/11/2027'); + const tempCredentialBody = { ...credentialBody }; + tempCredentialBody.schemaId = schemaId; + tempCredentialBody.subjectDid = subjectDid; + tempCredentialBody['expirationDate'] = expirationDate.toString(); + tempCredentialBody.issuerDid = issuerDid; + tempCredentialBody.fields = { name: 'varsha', address: 'random address' }; + credentialDetail3 = await await hsSdk.vc.bjjVC.generate(tempCredentialBody); + expect(credentialDetail).to.be.a('object'); + should().exist(credentialDetail['@context']); + should().exist(credentialDetail['id']); + should().exist(credentialDetail['type']); + should().exist(credentialDetail['issuanceDate']); + should().exist(credentialDetail['issuer']); + should().exist(credentialDetail['credentialSubject']); + should().exist(credentialDetail['credentialSchema']); + should().exist(credentialDetail['credentialStatus']); + expect(credentialDetail['credentialStatus'].type).to.be.equal('HypersignCredentialStatus2023'); + }); + }); + describe('#issueCredential() method for issuing credential', function () { + it('should not be able to issueCredential as verificationMethodId is null or empty', async function () { + const tempIssueCredentialBody = { ...issueCredentialBody }; + tempIssueCredentialBody.credential = credentialDetail; + tempIssueCredentialBody.issuerDid = issuerDid; + tempIssueCredentialBody.verificationMethodId = ''; + tempIssueCredentialBody.privateKeyMultibase = issuerPrivateKeyMultibase; + return await hsSdk.vc.bjjVC.issue(tempIssueCredentialBody).catch(function (err) { + expect(function () { + throw err; + }).to.throw(Error, 'HID-SSI-SDK:: Error: params.verificationMethodId is required to issue credential'); + }); + }); + it('should not be able to issueCredential as credentialObject is null or undefined', async function () { + const tempIssueCredentialBody = { ...issueCredentialBody }; + tempIssueCredentialBody.credential = undefined; + tempIssueCredentialBody.issuerDid = issuerDid; + tempIssueCredentialBody.verificationMethodId = verificationMethod[0].id; + tempIssueCredentialBody.privateKeyMultibase = issuerPrivateKeyMultibase; + return await hsSdk.vc.bjjVC.issue(tempIssueCredentialBody).catch(function (err) { + expect(function () { + throw err; + }).to.throw(Error, 'HID-SSI-SDK:: Error: params.credential is required to issue credential'); + }); + }); + it('should not be able to issueCredential as privateKey is null or empty', async function () { + const tempIssueCredentialBody = { ...issueCredentialBody }; + tempIssueCredentialBody.credential = credentialDetail; + tempIssueCredentialBody.issuerDid = issuerDid; + tempIssueCredentialBody.verificationMethodId = verificationMethod[0].id; + tempIssueCredentialBody.privateKeyMultibase = ''; + return await hsSdk.vc.bjjVC.issue(tempIssueCredentialBody).catch(function (err) { + expect(function () { + throw err; + }).to.throw(Error, 'HID-SSI-SDK:: Error: params.privateKeyMultibase is required to issue credential'); + }); + }); + it('should not be able to issueCredential as issuerDid is null or empty', async function () { + const tempIssueCredentialBody = { ...issueCredentialBody }; + tempIssueCredentialBody.credential = credentialDetail; + tempIssueCredentialBody.issuerDid = ''; + tempIssueCredentialBody.verificationMethodId = verificationMethod[0].id; + tempIssueCredentialBody.privateKeyMultibase = issuerPrivateKeyMultibase; + return await hsSdk.vc.bjjVC.issue(tempIssueCredentialBody).catch(function (err) { + expect(function () { + throw err; + }).to.throw(Error, 'HID-SSI-SDK:: Error: params.issuerDid is required to issue credential'); + }); + }); + it('should be able to issue credential with credential status registered on chain', async function () { + const tempIssueCredentialBody = { ...issueCredentialBody }; + tempIssueCredentialBody.credential = credentialDetail; + tempIssueCredentialBody.issuerDid = issuerDid; + tempIssueCredentialBody.verificationMethodId = verificationMethod[0].id; + tempIssueCredentialBody.privateKeyMultibase = issuerPrivateKeyMultibase; + + const issuedCredResult = await hsSdk.vc.bjjVC.issue(tempIssueCredentialBody); + const { signedCredential, credentialStatus, credentialStatusProof, credentialStatusRegistrationResult } = + issuedCredResult; + signedVC = {}; + Object.assign(signedVC, signedCredential); + signedVC1 = signedCredential; + credenStatus = credentialStatus; + credentialId = signedVC.id; + credentialStatusId = signedCredential['credentialStatus'].id; + expect(signedCredential).to.be.a('object'); + should().exist(signedCredential['@context']); + should().exist(signedCredential['id']); + should().exist(signedCredential['type']); + should().exist(signedCredential['issuanceDate']); + should().exist(signedCredential['issuer']); + should().exist(signedCredential['credentialSubject']); + should().exist(signedCredential['credentialSchema']); + should().exist(signedCredential['credentialStatus']); + should().exist(signedCredential['proof']); + expect(signedCredential['id']).to.be.equal(tempIssueCredentialBody.credential.id); + expect(credentialStatus).to.be.a('object'); + should().exist(credentialStatus['@context']); + should().exist(credentialStatus['id']); + should().exist(credentialStatus['issuer']); + should().exist(credentialStatus['issuanceDate']); + should().exist(credentialStatus['credentialMerkleRootHash']); + should().exist(credentialStatus['proof']); + should().exist(credentialStatus['proof'].type); + expect(credentialStatus['proof'].type).to.be.equal('BJJSignature2021'); + expect(credentialStatusProof).to.be.a('object'); + should().exist(credentialStatusProof['type']); + expect(credentialStatusProof['type']).to.be.equal('BJJSignature2021'); + should().exist(credentialStatusProof['created']); + should().exist(credentialStatusProof['verificationMethod']); + should().exist(credentialStatusProof['proofPurpose']); + should().exist(credentialStatusProof['proofValue']); + expect(credentialStatusRegistrationResult).to.be.a('object'); + should().exist(credentialStatusRegistrationResult['height']); + should().exist(credentialStatusRegistrationResult['transactionHash']); + should().exist(credentialStatusRegistrationResult['gasUsed']); + should().exist(credentialStatusRegistrationResult['gasWanted']); + }); + + it('should be able to issue credential without having the credential status registered on chain', async function () { + const expirationDate = new Date('12/11/2027'); + const tempCredentialBody = { ...credentialBody }; + tempCredentialBody.schemaId = schemaId; + // tempCredentialBody['subjectDidDocSigned'] = holderSignedDidDoc; + tempCredentialBody['expirationDate'] = expirationDate.toString(); + tempCredentialBody.issuerDid = issuerDid; + tempCredentialBody.subjectDid = subjectDid; + tempCredentialBody.fields = { name: 'varsha', address: 'random address' }; + const credentialDetail = await hsSdk.vc.bjjVC.generate(tempCredentialBody); + const tempIssueCredentialBody = { ...issueCredentialBody }; + tempIssueCredentialBody.credential = credentialDetail; + tempIssueCredentialBody.issuerDid = issuerDid; + tempIssueCredentialBody.verificationMethodId = verificationMethod[0].id; + tempIssueCredentialBody.privateKeyMultibase = issuerPrivateKeyMultibase; + tempIssueCredentialBody.registerCredential = false; + const issuedCredResult = await hsSdk.vc.bjjVC.issue(tempIssueCredentialBody); + const { signedCredential, credentialStatus, credentialStatusProof, credentialStatusRegistrationResult } = + issuedCredResult; + credentialStatus2 = credentialStatus; + credentialStatusProof2 = credentialStatusProof; + expect(signedCredential).to.be.a('object'); + expect(credentialStatus).to.be.a('object'); + expect(credentialStatusProof).to.be.a('object'); + should().not.exist(credentialStatusRegistrationResult); + }); + + it('should be able to issue credential without having the credential status registered on chain to test bulkRegistration', async function () { + const tempIssueCredentialBody = { ...issueCredentialBody }; + tempIssueCredentialBody.credential = credentialDetail2; + tempIssueCredentialBody.issuerDid = issuerDid; + tempIssueCredentialBody.verificationMethodId = verificationMethod[0].id; + tempIssueCredentialBody.privateKeyMultibase = issuerPrivateKeyMultibase; + tempIssueCredentialBody.registerCredential = false; + issuedCredResult = await hsSdk.vc.bjjVC.issue(tempIssueCredentialBody); + const { signedCredential, credentialStatus, credentialStatusProof, credentialStatusRegistrationResult } = + issuedCredResult; + expect(signedCredential).to.be.a('object'); + expect(credentialStatus).to.be.a('object'); + expect(credentialStatusProof).to.be.a('object'); + should().not.exist(credentialStatusRegistrationResult); + }); + it('should be able to issue credential without having the credential status registered on chain to test bulkRegistration', async function () { + const tempIssueCredentialBody = { ...issueCredentialBody }; + tempIssueCredentialBody.credential = credentialDetail3; + tempIssueCredentialBody.issuerDid = issuerDid; + tempIssueCredentialBody.verificationMethodId = verificationMethod[0].id; + tempIssueCredentialBody.privateKeyMultibase = issuerPrivateKeyMultibase; + tempIssueCredentialBody.registerCredential = false; + issuedCredResult2 = await hsSdk.vc.bjjVC.issue(tempIssueCredentialBody); + const { signedCredential, credentialStatus, credentialStatusProof, credentialStatusRegistrationResult } = + issuedCredResult; + expect(signedCredential).to.be.a('object'); + expect(credentialStatus).to.be.a('object'); + expect(credentialStatusProof).to.be.a('object'); + should().not.exist(credentialStatusRegistrationResult); + }); + }); + describe('#generateSeletiveDisclosure() method for genertaaing sd', function () { + const presentationBody = { + verifiableCredential: signedVC1, + verificationMethodId: '', + issuerDid, + }; + it('should not be able to generate a sd presentation document as verfiableCredential is not passed or null', async function () { + const tempPresentationBody = { ...presentationBody }; + tempPresentationBody.verifiableCredential = null; + return hsSdk.vc.bjjVC.generateSeletiveDisclosure(tempPresentationBody).catch(function (err) { + expect(function () { + throw err; + }).to.throw(Error, 'HID-SSI-SDK:: verifiableCredential is required'); + }); + }); + + it('should not be able to generate a sd presentation document as frame is not passed or null', async function () { + const tempPresentationBody = { ...presentationBody }; + tempPresentationBody.verifiableCredential = signedVC; + tempPresentationBody['frame'] = null; + + return hsSdk.vc.bjjVC.generateSeletiveDisclosure(tempPresentationBody).catch(function (err) { + expect(function () { + throw err; + }).to.throw(Error, 'HID-SSI-SDK:: frame is required'); + }); + }); + it('should not be able to generate a sd presentation document as verificationMethodId is not passed', async function () { + const tempPresentationBody = { ...presentationBody }; + tempPresentationBody.verifiableCredential = signedVC; + const revelDocument = { + type: ['VerifiableCredential', 'TestSchema'], + expirationDate: {}, + issuanceDate: {}, + issuer: {}, + credentialSubject: { + '@explicit': true, + id: {}, + }, + }; + tempPresentationBody['frame'] = revelDocument; + return hsSdk.vc.bjjVC.generateSeletiveDisclosure(tempPresentationBody).catch(function (err) { + expect(function () { + throw err; + }).to.throw(Error, 'HID-SSI-SDK:: verificationMethodId is required'); + }); + }); + it('should not be able to generate a sd presentation document as issuerDid is not passed', async function () { + const tempPresentationBody = { ...presentationBody }; + tempPresentationBody.verifiableCredential = signedVC; + const revelDocument = { + type: ['VerifiableCredential', 'TestSchema'], + expirationDate: {}, + issuanceDate: {}, + issuer: {}, + credentialSubject: { + '@explicit': true, + id: {}, + }, + }; + tempPresentationBody['frame'] = revelDocument; + tempPresentationBody.verificationMethodId = verificationMethod[0].id; + tempPresentationBody.issuerDid = ''; + + return hsSdk.vc.bjjVC.generateSeletiveDisclosure(tempPresentationBody).catch(function (err) { + expect(function () { + throw err; + }).to.throw(Error, 'HID-SSI-SDK:: issuerDid is required'); + }); + }); + it('should be able to generate a sd document', async () => { + const presentationBody = { + verifiableCredential: {}, + frame: {}, + verificationMethodId: verificationMethod[0].id, + issuerDid, + }; + const revelDocument = { + type: ['VerifiableCredential', 'TestSchema'], + expirationDate: {}, + issuanceDate: {}, + issuer: {}, + credentialSubject: { + '@explicit': true, + id: {}, + }, + }; + const tempPresentationBody = { ...presentationBody }; + tempPresentationBody.verifiableCredential = signedVC1; + tempPresentationBody.frame = revelDocument; + tempPresentationBody.issuerDid = issuerDid; + tempPresentationBody.verificationMethodId = verificationMethod[0].id; + selectiveDisclosure = await hsSdk.vc.bjjVC.generateSeletiveDisclosure(tempPresentationBody); + should().exist(selectiveDisclosure['@context']); + should().exist(selectiveDisclosure['id']); + expect(selectiveDisclosure['id']).to.be.equal(credentialId); + should().exist(selectiveDisclosure['type']); + should().exist(selectiveDisclosure['credentialSchema']); + should().exist(selectiveDisclosure['credentialStatus']); + should().exist(selectiveDisclosure['credentialSubject']); + expect(selectiveDisclosure['credentialSubject']).to.be.equal(subjectDid); + should().exist(selectiveDisclosure['expirationDate']); + should().exist(selectiveDisclosure['issuanceDate']); + should().exist(selectiveDisclosure['issuer']); + expect(selectiveDisclosure['issuer']).to.be.equal(issuerDid); + should().exist(selectiveDisclosure['proof']); + should().exist(selectiveDisclosure['proof'].type); + expect(selectiveDisclosure['proof'].type).to.be.equal('BabyJubJubSignatureProof2021'); + should().exist(selectiveDisclosure['proof'].created); + should().exist(selectiveDisclosure['proof'].verificationMethod); + should().exist(selectiveDisclosure['proof'].proofPurpose); + should().exist(selectiveDisclosure['proof'].credentialRoot); + should().exist(selectiveDisclosure['proof'].proofValue); + }); + }); + describe('#verify() method for verifying credential', function () { + it('should be able to verify credential', async function () { + const params = { + credential: signedVC1, + issuerDid, + verificationMethodId: verificationMethod[0].id, + }; + + const verificationResult = await hsSdk.vc.bjjVC.verify(params); + + expect(verificationResult).to.be.a('object'); + should().exist(verificationResult.verified); + expect(verificationResult.verified).to.be.equal(true); + should().exist(verificationResult.results); + expect(verificationResult.results).to.be.a('array'); + should().exist(verificationResult.statusResult); + expect(verificationResult.statusResult.verified).to.be.equal(true); + }); + + it('should not be able to verify credential as verificationMethodId is null or empty', async function () { + const params = { + credential: signedVC, + issuerDid, + verificationMethodId: verificationMethod[0].id, + }; + params.verificationMethodId = ''; + return hsSdk.vc.bjjVC.verify(params).catch(function (err) { + expect(function () { + throw err; + }).to.throw(Error, 'HID-SSI-SDK:: Error: params.verificationMethodId is required to verify credential'); + }); + }); + + it('should not be able to verify credential as issuerDid is null or empty', async function () { + const params = { + credential: signedVC, + issuerDid, + verificationMethodId: verificationMethod[0].id, + }; + params.issuerDid = ''; + return hsSdk.vc.bjjVC.verify(params).catch(function (err) { + expect(function () { + throw err; + }).to.throw( + Error, + 'HID-SSI-SDK:: Error: params.issuerDid or params.issuerDidDocument is required to verify credential' + ); + }); + }); + + it('should not be able to verify credential as proof is null or undefined', async function () { + const params = { + credential: signedVC, + issuerDid, + verificationMethodId: verificationMethod[0].id, + }; + + if (params.credential) { + params.credential.proof = undefined; + } + + return hsSdk.vc.bjjVC.verify(params).catch(function (err) { + expect(function () { + throw err; + }).to.throw(Error, 'HID-SSI-SDK:: params.credential.proof is required to verify credential'); + }); + }); + + it('should not be able to verify credential as credential is null or undefined', async function () { + const params = { + credential: signedVC, + issuerDid, + verificationMethodId: verificationMethod[0].id, + }; + params.credential = null; + return hsSdk.vc.bjjVC.verify(params).catch(function (err) { + expect(function () { + throw err; + }).to.throw(Error, 'HID-SSI-SDK:: params.credential is required to verify credential'); + }); + }); + }); +}); + +describe('Verifiable Credential Status Opearations', () => { + describe('#checkCredentialStatus() method to check status of the credential', function () { + it('should not be able to check credential as credentialId is null or empty', async function () { + return hsSdk.vc.bjjVC.checkCredentialStatus().catch(function (err) { + expect(function () { + throw err; + }).to.throw(Error, 'HID-SSI-SDK:: Error: params.credentialId is required to resolve credential status'); + }); + }); + + it('should not be able to check credential as credentialId is invalid', async function () { + return hsSdk.vc.bjjVC.checkCredentialStatus({ credentialId: credentialId + 'x' }).catch(function (err) { + expect(function () { + throw err; + }).to.throw(Error, 'No credential status found. Probably invalid credentialId'); + }); + }); + it('should be able to check credential status', async function () { + const credentialStatus = await hsSdk.vc.bjjVC.checkCredentialStatus({ credentialId: credentialId }); + expect(credentialStatus).to.be.a('object'); + should().exist(credentialStatus.verified); + expect(credentialStatus.verified).to.be.equal(true); + }); + }); + describe('#resolveCredentialStatus() method to resolve status of the credential from blockchain', function () { + it('should not be able to resolve credential as credentialId is not passed', async function () { + return hsSdk.vc.bjjVC.resolveCredentialStatus({ credentialId: '' }).catch(function (err) { + expect(function () { + throw err; + }).to.throw(Error, 'HID-SSI-SDK:: Error: params.credentialId is required to resolve credential status'); + }); + }); + it('should be able to check credential status', async function () { + const credentialStatus = await hsSdk.vc.bjjVC.resolveCredentialStatus({ credentialId: credentialId }); + expect(credentialStatus).to.be.a('object'); + should().exist(credentialStatus.revoked); + should().exist(credentialStatus.suspended); + should().exist(credentialStatus.remarks); + should().exist(credentialStatus.issuer); + should().exist(credentialStatus.issuanceDate); + should().exist(credentialStatus.credentialMerkleRootHash); + should().exist(credentialStatus.proof); + }); + }); + describe('#updateCredentialStatus this method is to change credential status to revoked or suspended', function () { + it('should not be able to update credential as verificationMethodId is not passed', async function () { + const tempParams = { + credentialStatus: credenStatus, + issuerDid, + verificationMethodId: '', + privateKeyMultibase: issuerPrivateKeyMultibase, + status: 'SUSPENDED', + statusReason: 'Suspending this credential for some time', + }; + tempParams.verificationMethodId = ''; + return hsSdk.vc.bjjVC.updateCredentialStatus(tempParams).catch(function (err) { + expect(function () { + throw err; + }).to.throw(Error, 'HID-SSI-SDK:: Error: params.verificationMethodId is required to update credential status'); + }); + }); + it('should not be able to update credential as privateKey is not passed', async function () { + const tempParams = { + credentialStatus: credenStatus, + issuerDid, + verificationMethodId: verificationMethod[0].id, + privateKeyMultibase: '', + status: 'SUSPENDED', + statusReason: 'Suspending this credential for some time', + }; + tempParams.verificationMethodId = verificationMethod[0].id; + tempParams.credentialStatus = credenStatus; + tempParams.privateKeyMultibase = ''; + + return hsSdk.vc.bjjVC.updateCredentialStatus(tempParams).catch(function (err) { + expect(function () { + throw err; + }).to.throw(Error, 'HID-SSI-SDK:: Error: params.privateKeyMultibase is required to update credential status'); + }); + }); + it('should not be able to update credential as issuerDid is not passed', async function () { + const tempParams = { + credentialStatus: credenStatus, + issuerDid: '', + verificationMethodId: verificationMethod[0].id, + privateKeyMultibase: issuerPrivateKeyMultibase, + status: 'SUSPENDED', + statusReason: 'Suspending this credential for some time', + }; + tempParams.verificationMethodId = verificationMethod[0].id; + tempParams.credentialStatus = credenStatus; + tempParams.privateKeyMultibase = issuerPrivateKeyMultibase; + tempParams.issuerDid = ''; + return hsSdk.vc.bjjVC.updateCredentialStatus(tempParams).catch(function (err) { + expect(function () { + throw err; + }).to.throw(Error, 'HID-SSI-SDK:: Error: params.issuerDid is required to update credential status'); + }); + }); + it('should not be able to update credential as status is not passed', async function () { + const tempParams = { + credentialStatus: credenStatus, + issuerDid, + verificationMethodId: verificationMethod[0].id, + privateKeyMultibase: issuerPrivateKeyMultibase, + status: '', + statusReason: 'Suspending this credential for some time', + }; + tempParams.verificationMethodId = verificationMethod[0].id; + tempParams.credentialStatus = credenStatus; + tempParams.privateKeyMultibase = issuerPrivateKeyMultibase; + tempParams.issuerDid = issuerDid; + tempParams.status = ''; + return hsSdk.vc.bjjVC.updateCredentialStatus(tempParams).catch(function (err) { + expect(function () { + throw err; + }).to.throw(Error, 'HID-SSI-SDK:: Error: params.status is required to update credential status'); + }); + }); + it('should not be able to update credential as status passed is invalid', async function () { + const tempParams = { + credentialStatus: credenStatus, + issuerDid, + verificationMethodId: verificationMethod[0].id, + privateKeyMultibase: issuerPrivateKeyMultibase, + status: 'svgsdvjif', + statusReason: 'Suspending this credential for some time', + }; + tempParams.verificationMethodId = verificationMethod[0].id; + tempParams.credentialStatus = credenStatus; + tempParams.privateKeyMultibase = issuerPrivateKeyMultibase; + tempParams.issuerDid = issuerDid; + tempParams.status = 'svgsdvjif'; + return hsSdk.vc.bjjVC.updateCredentialStatus(tempParams).catch(function (err) { + expect(function () { + throw err; + }).to.throw(Error, `HID-SSI-SDK:: Error: params.status is invalid`); + }); + }); + it('should be able to change credential status to suspended', async function () { + const credentialStatus = await hsSdk.vc.bjjVC.resolveCredentialStatus({ credentialId }); + const params = { + credentialStatus, + issuerDid, + verificationMethodId: verificationMethod[0].id, + privateKeyMultibase: issuerPrivateKeyMultibase, + status: 'SUSPENDED', + statusReason: 'Suspending this credential for some time', + }; + const updatedCredResult = await hsSdk.vc.bjjVC.updateCredentialStatus(params); + expect(updatedCredResult).to.be.a('object'); + expect(updatedCredResult.code).to.be.equal(0); + expect(updatedCredResult.transactionHash).to.be.a('string'); + }); + it('should not be able to suspend a suspended credential status', async function () { + const credentialStatus = await hsSdk.vc.bjjVC.resolveCredentialStatus({ credentialId }); + const params = { + credentialStatus: credentialStatus, + issuerDid, + verificationMethodId: verificationMethod[0].id, + privateKeyMultibase: issuerPrivateKeyMultibase, + status: 'SUSPENDED', + statusReason: 'Suspending this credential for some time', + }; + return hsSdk.vc.bjjVC.updateCredentialStatus(params).catch(function (err) { + expect(function () { + throw err; + }).to.throw( + Error, + 'failed to execute message; message index: 0: incoming Credential Status Document does not have any changes: invalid Credential Status' + ); + }); + }); + it('should be able to change credential status to Live', async function () { + const credentialStatus = await hsSdk.vc.bjjVC.resolveCredentialStatus({ credentialId }); + const params = { + credentialStatus, + issuerDid, + verificationMethodId: verificationMethod[0].id, + privateKeyMultibase: issuerPrivateKeyMultibase, + status: 'LIVE', + statusReason: 'Setting the status to LIVE', + }; + const updatedCredResult = await hsSdk.vc.bjjVC.updateCredentialStatus(params); + expect(updatedCredResult).to.be.a('object'); + expect(updatedCredResult.code).to.be.equal(0); + expect(updatedCredResult.transactionHash).to.be.a('string'); + }); + it('should be able to change credential status to Revoke', async function () { + const credentialStatus = await hsSdk.vc.bjjVC.resolveCredentialStatus({ credentialId }); + const params = { + credentialStatus, + issuerDid, + verificationMethodId: verificationMethod[0].id, + privateKeyMultibase: issuerPrivateKeyMultibase, + status: 'REVOKED', + statusReason: 'Revoking the credential', + }; + const updatedCredResult = await hsSdk.vc.bjjVC.updateCredentialStatus(params); + expect(updatedCredResult).to.be.a('object'); + expect(updatedCredResult.code).to.be.equal(0); + expect(updatedCredResult.transactionHash).to.be.a('string'); + }); + it('should not be able to revoke a revoked credential status', async function () { + const credentialStatus = await hsSdk.vc.bjjVC.resolveCredentialStatus({ credentialId }); + const params = { + credentialStatus, + issuerDid, + verificationMethodId: verificationMethod[0].id, + privateKeyMultibase: issuerPrivateKeyMultibase, + status: 'REVOKED', + statusReason: 'Revoking the credential', + }; + return hsSdk.vc.bjjVC.updateCredentialStatus(params).catch(function (err) { + expect(function () { + throw err; + }).to.throw( + Error, + 'failed to execute message; message index: 0: incoming Credential Status Document does not have any changes: invalid Credential Status' + ); + }); + }); + it('should not be able to change the status of credential as it is revoked', async function () { + const credentialStatus = await hsSdk.vc.bjjVC.resolveCredentialStatus({ credentialId }); + const params = { + credentialStatus, + issuerDid, + verificationMethodId: verificationMethod[0].id, + privateKeyMultibase: issuerPrivateKeyMultibase, + status: 'SUSPENDED', + statusReason: 'Suspending this credential for some time', + }; + + return hsSdk.vc.bjjVC.updateCredentialStatus(params).catch(function (err) { + expect(err.message).to.include( + `failed to execute message; message index: 0: credential status ${credentialId} could not be updated since it is revoked: invalid Credential Status` + ); + }); + }); + }); + describe('#registerCredentialStatus() method to register credential on blockchain', function () { + it('should not be able to register credential as credentialStatusProof is not passed', async function () { + return hsSdk.vc.bjjVC.registerCredentialStatus({ credentialStatus: credentialStatus2 }).catch(function (err) { + expect(function () { + throw err; + }).to.throw( + Error, + 'HID-SSI-SDK:: Error: credentialStatus and credentialStatusProof are required to register credential status' + ); + }); + }); + it('should not be able to register credential as credentialStatus is not passed', async function () { + return hsSdk.vc.bjjVC + .registerCredentialStatus({ credentialStatusProof: credentialStatusProof2 }) + .catch(function (err) { + expect(function () { + throw err; + }).to.throw( + Error, + 'HID-SSI-SDK:: Error: credentialStatus and credentialStatusProof are required to register credential status' + ); + }); + }); + it('should be able to register credential on blockchain', async function () { + const registerCredDetail = await hsSdk.vc.bjjVC.registerCredentialStatus({ + credentialStatus: credentialStatus2, + credentialStatusProof: credentialStatusProof2, + }); + expect(registerCredDetail).to.be.a('object'); + should().exist(registerCredDetail.transactionHash); + }); + it('should not be able to register credential on blockchain as stutus already registerd on chain', async function () { + return hsSdk.vc.bjjVC + .registerCredentialStatus({ + credentialStatus: credentialStatus2, + credentialStatusProof: credentialStatusProof2, + }) + .catch(function (err) { + expect(function () { + throw err; + }).to.throw('failed to execute message; message index: 0: credential status document already exists'); + }); + }); + }); + + describe('#generateRegisterCredentialStatusTxnMessage() method to generate transaction message for credential2', function () { + it('should not be able to generatecredential status TxnMessage as credentialStatus is not passed', async function () { + const credentialStatus = null; + const credentialStatusProof = issuedCredResult.credentialStatusProof; + return hsSdk.vc.bjjVC + .generateRegisterCredentialStatusTxnMessage(credentialStatus, credentialStatusProof) + .catch(function (err) { + expect(function () { + throw err; + }).to.throw( + Error, + 'HID-SSI-SDK:: Error: credentialStatus and proof are required to register credential status' + ); + }); + }); + it('should not be able to generatecredential status TxnMessage as credentialStatusProof is not passed', async function () { + const credentialStatus = issuedCredResult.credentialStatus; + const credentialStatusProof = null; + return hsSdk.vc.bjjVC + .generateRegisterCredentialStatusTxnMessage(credentialStatus, credentialStatusProof) + .catch(function (err) { + expect(function () { + throw err; + }).to.throw( + Error, + 'HID-SSI-SDK:: Error: credentialStatus and proof are required to register credential status' + ); + }); + }); + it('should be able to generate credential status TxnMessage', async function () { + const credentialStatus = issuedCredResult.credentialStatus; + const credentialStatusProof = issuedCredResult.credentialStatusProof; + const credentialStatus2 = issuedCredResult2.credentialStatus; + const credentialStatusProof2 = issuedCredResult2.credentialStatusProof; + const txnMessage1 = await hsSdk.vc.bjjVC.generateRegisterCredentialStatusTxnMessage( + credentialStatus, + credentialStatusProof + ); + credentialTransMessage.push(txnMessage1); + const txnMessage2 = await hsSdk.vc.bjjVC.generateRegisterCredentialStatusTxnMessage( + credentialStatus2, + credentialStatusProof2 + ); + credentialTransMessage.push(txnMessage2); + expect(txnMessage1).to.be.a('object'); + should().exist(txnMessage1.typeUrl); + should().exist(txnMessage1.value); + should().exist(txnMessage1.value.credentialStatusDocument); + should().exist(txnMessage1.value.credentialStatusProof); + should().exist(txnMessage1.value.txAuthor); + }); + }); + + describe('#registerCredentialStatusTxnBulk() method to register credential on blockchain', function () { + it('should not be able to register multiple credential as txnMessage is not passed', async function () { + const txnMessage = []; + return hsSdk.vc.bjjVC.registerCredentialStatusTxnBulk(txnMessage).catch(function (err) { + expect(function () { + throw err; + }).to.throw(Error, 'HID-SSI-SDK:: Error: txnMessage is required to register credential status'); + }); + }); + it('should be able to register credential on blockchain in a bulk', async function () { + const registerCredDetail = await hsSdk.vc.bjjVC.registerCredentialStatusTxnBulk(credentialTransMessage); + expect(registerCredDetail).to.be.a('object'); + should().exist(registerCredDetail.transactionHash); + }); + }); +}); + +// add testcase for sd diff --git a/src/tests/bjj/did/bjj_did.spec.ts b/src/tests/bjj/did/bjj_did.spec.ts new file mode 100644 index 0000000..5f99be8 --- /dev/null +++ b/src/tests/bjj/did/bjj_did.spec.ts @@ -0,0 +1,520 @@ + +import { HypersignSSISdk } from '../../../index'; +import { expect, should } from 'chai'; +import { createWallet, mnemonic, hidNodeEp } from '../../config' +let privateKeyMultibase; +let publicKeyMultibase; +let offlineSigner +let hsSdk +let didDocument; +let verificationMethod; +let didDocId; +let versionId; +beforeEach(async function () { + offlineSigner = await createWallet(mnemonic); + const params = { + offlineSigner, + nodeRestEndpoint: hidNodeEp.rest, + nodeRpcEndpoint: hidNodeEp.rpc, + namespace: hidNodeEp.namespace, + }; + hsSdk = new HypersignSSISdk(params); + await hsSdk.init(); +}); +describe('DID Test scenarios for BabyJubJub key', () => { + //remove seed while creating did so that wallet can generate different did every time + describe('#generateKeys() method to generate publicKyeMultibase and privateKeyMultiBase', function () { + it('should return publickeyMultibase and privateKeyMultibase', async function () { + const kp = await hsSdk.did.bjjDID.generateKeys(); + privateKeyMultibase = kp.privateKeyMultibase; + publicKeyMultibase = kp.publicKeyMultibase; + expect(kp).to.be.a('object'); + should().exist(kp.privateKeyMultibase); + should().exist(kp.publicKeyMultibase); + should().not.exist(kp.id); + }); + + + }); + + describe('#generate() method to generate new did', function () { + it('should not be able to generate did document and throw error as publicKeyMultibase passed is null or empty', function () { + return hsSdk.did.bjjDID.generate({ publicKeyMultibase: '' }).catch(function (err) { + expect(function () { + throw err; + }).to.throw(Error, 'HID-SSI-SDK:: Error: params.publicKeyMultibase is required to generate new did didoc'); + }); + }); + it('should be able to generate a did using babyJubJub', async () => { + didDocument = await hsSdk.did.bjjDID.generate({ + publicKeyMultibase + }) + didDocId = didDocument.id + verificationMethod = didDocument.verificationMethod + expect(didDocument).to.be.a('object'); + should().exist(didDocument['@context']); + should().exist(didDocument['id']); + should().exist(didDocument['controller']); + should().exist(didDocument['verificationMethod']); + expect( + didDocument['verificationMethod'] && + didDocument['authentication'] && + didDocument['assertionMethod'] && + didDocument['keyAgreement'] && + didDocument['capabilityInvocation'] && + didDocument['capabilityDelegation'] && + didDocument['service'] + ).to.be.a('array'); + expect(verificationMethod[0].type).to.be.equal('BabyJubJubKey2021') + should().exist(didDocument['authentication']); + should().exist(didDocument['assertionMethod']); + should().exist(didDocument['keyAgreement']); + should().exist(didDocument['capabilityInvocation']); + should().exist(didDocument['capabilityDelegation']); + should().exist(didDocument['service']); + expect(didDocument['authentication'].length).to.be.greaterThan(0) + expect(didDocument['assertionMethod'].length).to.be.greaterThan(0) + expect(didDocument['capabilityInvocation'].length).to.be.equal(0) + expect(didDocument['capabilityDelegation'].length).to.be.equal(0) + expect(didDocument['keyAgreement'].length).to.be.equal(0) + expect(didDocument['service'].length).to.be.equal(0) + + }) + it('should be able to generate a did using babyJubJub with passed verification relationships', async () => { + const didDocument = await hsSdk.did.bjjDID.generate({ + publicKeyMultibase, + verificationRelationships: ['authentication', 'assertionMethod'], + }) + expect(didDocument).to.be.a('object'); + should().exist(didDocument['@context']); + should().exist(didDocument['id']); + should().exist(didDocument['controller']); + should().exist(didDocument['verificationMethod']); + expect( + didDocument['verificationMethod'] && + didDocument['authentication'] && + didDocument['assertionMethod'] && + didDocument['keyAgreement'] && + didDocument['capabilityInvocation'] && + didDocument['capabilityDelegation'] && + didDocument['service'] + ).to.be.a('array'); + expect(verificationMethod[0].type).to.be.equal('BabyJubJubKey2021') + should().exist(didDocument['authentication']); + should().exist(didDocument['assertionMethod']); + should().exist(didDocument['keyAgreement']); + should().exist(didDocument['capabilityInvocation']); + should().exist(didDocument['capabilityDelegation']); + should().exist(didDocument['service']); + expect(didDocument['authentication'].length).to.be.greaterThan(0) + expect(didDocument['assertionMethod'].length).to.be.greaterThan(0) + expect(didDocument['capabilityInvocation'].length).to.be.equal(0) + expect(didDocument['capabilityDelegation'].length).to.be.equal(0) + expect(didDocument['keyAgreement'].length).to.be.equal(0) + expect(didDocument['service'].length).to.be.equal(0) + + }) + }) + + describe('#register() method to register did', function () { + it('should not able to register did document and throw error as didDocument is not passed or it is empty', function () { + return hsSdk.did.bjjDID + .register({ didDocument: {}, privateKeyMultibase, verificationMethodId: verificationMethod[0].id }) + .catch(function (err) { + expect(function () { + throw err; + }).to.throw(Error, 'HID-SSI-SDK:: Error: params.didDocString is required to register a did'); + }); + }); + it('should not be able to register did document as privateKeyMultibase is null or empty', function () { + return hsSdk.did.bjjDID + .register({ didDocument, privateKeyMultibase: '', verificationMethodId: verificationMethod[0].id }) + .catch(function (err) { + expect(function () { + throw err; + }).to.throw(Error, 'HID-SSI-SDK:: Error: params.privateKeyMultibase is required to register a did'); + }); + }); + it('should not be able to register did document as verificationMethodId is null or empty', function () { + return hsSdk.did.bjjDID + .register({ didDocument, privateKeyMultibase, verificationMethodId: '' }) + .catch(function (err) { + expect(function () { + throw err; + }).to.throw(Error, 'HID-SSI-SDK:: Error: params.verificationMethodId is required to register a did'); + }); + }); + it('should not be able to register did document as didDocument is not in Ld-json fromat', function () { + const didDoc = JSON.parse(JSON.stringify(didDocument)) + didDoc.context = didDoc['@context'] + delete didDoc['@context'] + return hsSdk.did.bjjDID + .register({ didDocument: didDoc, privateKeyMultibase, verificationMethodId: verificationMethod[0].id }) + .catch(function (err) { + expect(function () { + throw err; + }).to.throw(Error, 'HID-SSI-SDK:: Error: didDocument is not in Ld-json format'); + }); + }); + it('should not be able to register a did document as neither privateKeyMultibase nor verificationMethodId is passed and signData passed is empty array', async () => { + return hsSdk.did.bjjDID.register({ didDocument, signData: [] }).catch(function (err) { + expect(function () { + throw err; + }).to.throw(Error, 'HID-SSI-SDK:: Error: params.signInfos must be a non empty array'); + }); + }); + it('should not be able to register a did document as verificationMethodId is not passed inside signData', async () => { + return hsSdk.did.bjjDID.register({ didDocument, signData: [{ privateKeyMultibase: privateKeyMultibase }] }).catch(function (err) { + expect(function () { + throw err; + }).to.throw( + Error, + 'HID-SSI-SDK:: Error: params.signData[0].verificationMethodId is required to register a did' + ); + }); + }); + it('should not be able to register a did document as verificationMethodId is not passed inside signData', async () => { + return hsSdk.did.bjjDID.register({ didDocument, signData: [{ privateKeyMultibase: privateKeyMultibase }] }).catch(function (err) { + expect(function () { + throw err; + }).to.throw( + Error, + 'HID-SSI-SDK:: Error: params.signData[0].verificationMethodId is required to register a did' + ); + }); + }); + it('should not be able to register a did document as privateKeyMultibase is not passed inside signData', async () => { + return hsSdk.did.bjjDID + .register({ + didDocument, + signData: [ + { + verificationMethodId: verificationMethod[0].id, + }, + ], + }) + .catch(function (err) { + expect(function () { + throw err; + }).to.throw( + Error, + 'HID-SSI-SDK:: Error: params.signData[0].privateKeyMultibase is required to register a did' + ); + }); + }); + it('should not be able to register a did document as type is not passed inside signData', async () => { + return hsSdk.did.bjjDID + .register({ + didDocument, + signData: [ + { + verificationMethodId: verificationMethod[0].id, + privateKeyMultibase: privateKeyMultibase, + }, + ], + }) + .catch(function (err) { + expect(function () { + throw err; + }).to.throw(Error, 'HID-SSI-SDK:: Error: params.signData[0].type is required to register a did'); + }); + }); + it('should be able to register did generated using BabyJubJubKey', async () => { + const registerDid = await hsSdk.did.bjjDID.register({ + didDocument: didDocument, + privateKeyMultibase, + verificationMethodId: verificationMethod[0].id + }) + didDocument = registerDid.didDocument + expect(didDocument).to.be.a('object'); + should().exist(didDocument['@context']); + should().exist(didDocument['id']); + should().exist(didDocument['controller']); + should().exist(didDocument['verificationMethod']); + expect( + didDocument['verificationMethod'] && + didDocument['authentication'] && + didDocument['assertionMethod'] && + didDocument['keyAgreement'] && + didDocument['capabilityInvocation'] && + didDocument['capabilityDelegation'] && + didDocument['service'] + ).to.be.a('array'); + expect(verificationMethod[0].type).to.be.equal('BabyJubJubKey2021') + should().exist(didDocument['authentication']); + should().exist(didDocument['assertionMethod']); + should().exist(didDocument['keyAgreement']); + should().exist(didDocument['capabilityInvocation']); + should().exist(didDocument['capabilityDelegation']); + should().exist(didDocument['service']); + expect(didDocument['authentication'].length).to.be.greaterThan(0) + expect(didDocument['assertionMethod'].length).to.be.greaterThan(0) + expect(didDocument['capabilityInvocation'].length).to.be.equal(0) + expect(didDocument['capabilityDelegation'].length).to.be.equal(0) + expect(didDocument['keyAgreement'].length).to.be.equal(0) + expect(didDocument['service'].length).to.be.equal(0) + should().exist(registerDid.transactionHash); + }) + it('should not be able to register didDocument as didDocument is already registered', async function () { + return await hsSdk.did.bjjDID.register({ + didDocument, + privateKeyMultibase, + verificationMethodId: verificationMethod[0].id, + }).catch(function (err) { + expect(function () { + throw err; + }).to.throw( + Error, + `failed to execute message; message index: 0: ${didDocId}: didDoc already exists` + ); + }); + }); + }) + + describe('#resolve() method to resolve did', function () { + it('should not able to resolve did document and throw error as didDocId is not passed', function () { + return hsSdk.did.bjjDID.resolve({ params: { did: '' } }).catch(function (err) { + expect(function () { + throw err; + }).to.throw(Error, 'HID-SSI-SDK:: Error: params.did is required to resolve a did'); + }); + }); + it('should be able to resolve did', async () => { + const resolvedDid = await hsSdk.did.bjjDID.resolve({ + did: didDocId + }) + versionId = resolvedDid.didDocumentMetadata.versionId + didDocument = resolvedDid.didDocument + const didDocumentmetaData = resolvedDid.didDocumentMetadata + expect(didDocument).to.be.a('object'); + should().exist(didDocument['@context']); + should().exist(didDocument['id']); + should().exist(didDocument['controller']); + should().exist(didDocument['verificationMethod']); + expect( + didDocument['verificationMethod'] && + didDocument['authentication'] && + didDocument['assertionMethod'] && + didDocument['keyAgreement'] && + didDocument['capabilityInvocation'] && + didDocument['capabilityDelegation'] && + didDocument['service'] + ).to.be.a('array'); + expect(verificationMethod[0].type).to.be.equal('BabyJubJubKey2021') + should().exist(didDocument['authentication']); + should().exist(didDocument['assertionMethod']); + should().exist(didDocument['keyAgreement']); + should().exist(didDocument['capabilityInvocation']); + should().exist(didDocument['capabilityDelegation']); + should().exist(didDocument['service']); + expect(didDocument['authentication'].length).to.be.greaterThan(0) + expect(didDocument['assertionMethod'].length).to.be.greaterThan(0) + expect(didDocument['capabilityInvocation'].length).to.be.equal(0) + expect(didDocument['capabilityDelegation'].length).to.be.equal(0) + expect(didDocument['keyAgreement'].length).to.be.equal(0) + expect(didDocument['service'].length).to.be.equal(0) + expect(didDocumentmetaData).to.be.a('object') + should().exist(didDocumentmetaData.created) + should().exist(didDocumentmetaData.updated) + should().exist(didDocumentmetaData.deactivated) + should().exist(didDocumentmetaData.versionId) + expect(didDocumentmetaData.created).to.be.equal(didDocumentmetaData.updated) + }) + + }) + + describe('#update() method to update a did', function () { + it('should not be able to update did document as privateKeyMultibase is null or empty', function () { + return hsSdk.did.bjjDID + .update({ didDocument, privateKeyMultibase: '', verificationMethodId: verificationMethod[0].id, versionId: '1.0' }) + .catch(function (err) { + expect(function () { + throw err; + }).to.throw(Error, 'HID-SSI-SDK:: Error: params.privateKeyMultibase is required to update a did'); + }); + }); + it('should not be able to update did document as verificationMethodId is null or empty', function () { + return hsSdk.did.bjjDID + .update({ didDocument, privateKeyMultibase, verificationMethodId: '', versionId: '1.0' }) + .catch(function (err) { + expect(function () { + throw err; + }).to.throw(Error, 'HID-SSI-SDK:: Error: params.verificationMethodId is required to update a did'); + }); + }); + it('should not be able to update did document as versionId is null or empty', function () { + return hsSdk.did.bjjDID + .update({ didDocument, privateKeyMultibase, verificationMethodId: verificationMethod[0].id, versionId: '' }) + .catch(function (err) { + expect(function () { + throw err; + }).to.throw(Error, 'HID-SSI-SDK:: Error: params.versionId is required to update a did'); + }); + }); + it('should not be able to update did document as versionId passed is incorrect', function () { + const updateBody = { didDocument, privateKeyMultibase, verificationMethodId: verificationMethod[0].id, versionId: '1.0.1' }; + const didDoc = JSON.parse(JSON.stringify(didDocument)) + updateBody['didDocument'] = didDoc + updateBody['didDocument']['authentication'] = []; + return hsSdk.did.bjjDID.update(updateBody).catch(function (err) { + expect(function () { + throw err; + }).to.throw( + Error, + `failed to execute message; message index: 0: Expected ${didDocId} with version ${versionId}. Got version ${updateBody.versionId}: unexpected DID version` + ); + }); + }); + it('should not be able to update did document as there is no change in didDocument', function () { + const updateBody = { didDocument, privateKeyMultibase, verificationMethodId: verificationMethod[0].id, versionId: '1.0.1' }; + const didDoc = JSON.parse(JSON.stringify(didDocument)) + updateBody['didDocument'] = didDoc + return hsSdk.did.bjjDID.update(updateBody).catch(function (err) { + expect(function () { + throw err; + }).to.throw( + Error, + "failed to execute message; message index: 0: incoming DID Document does not have any changes: didDoc is invalid" + ); + }); + }); + it('should be able to update did generated using BabyJubJubKey', async () => { + const newDidDoc = JSON.parse(JSON.stringify(didDocument)) + newDidDoc['authentication'] = [] + const updatedDid = await hsSdk.did.bjjDID.update({ + didDocument: newDidDoc, + privateKeyMultibase, + verificationMethodId: verificationMethod[0].id, + versionId + }) + should().exist(updatedDid.transactionHash); + }) + }) + + describe('#resolve() method to resolve did', function () { + it('should be able to resolve did after updation', async () => { + const resolvedDid = await hsSdk.did.bjjDID.resolve({ + did: didDocId + }) + versionId = resolvedDid.didDocumentMetadata.versionId + didDocument = resolvedDid.didDocument + const didDocumentmetaData = resolvedDid.didDocumentMetadata + expect(didDocument).to.be.a('object'); + should().exist(didDocument['@context']); + should().exist(didDocument['id']); + should().exist(didDocument['controller']); + should().exist(didDocument['verificationMethod']); + expect( + didDocument['verificationMethod'] && + didDocument['authentication'] && + didDocument['assertionMethod'] && + didDocument['keyAgreement'] && + didDocument['capabilityInvocation'] && + didDocument['capabilityDelegation'] && + didDocument['service'] + ).to.be.a('array'); + expect(verificationMethod[0].type).to.be.equal('BabyJubJubKey2021') + should().exist(didDocument['authentication']); + should().exist(didDocument['assertionMethod']); + should().exist(didDocument['keyAgreement']); + should().exist(didDocument['capabilityInvocation']); + should().exist(didDocument['capabilityDelegation']); + should().exist(didDocument['service']); + // expect(didDocument['authentication'].length).to.be.greaterThan(0) + expect(didDocument['assertionMethod'].length).to.be.greaterThan(0) + expect(didDocument['capabilityInvocation'].length).to.be.equal(0) + expect(didDocument['capabilityDelegation'].length).to.be.equal(0) + expect(didDocument['keyAgreement'].length).to.be.equal(0) + expect(didDocument['service'].length).to.be.equal(0) + expect(didDocumentmetaData).to.be.a('object') + should().exist(didDocumentmetaData.created) + should().exist(didDocumentmetaData.updated) + should().exist(didDocumentmetaData.deactivated) + should().exist(didDocumentmetaData.versionId) + const date1 = new Date(didDocumentmetaData.updated); + const date2 = new Date(didDocumentmetaData.created); + expect(date1).to.be.greaterThan(date2) + }) + }) + describe('#deactivate() method to deactivate a did document', function () { + it('should not be able to deactivate did document as privateKeyMultibase is null or empty', function () { + return hsSdk.did.bjjDID + .deactivate({ didDocument, privateKeyMultibase: '', verificationMethodId: verificationMethod[0].id, versionId: '1.0' }) + .catch(function (err) { + expect(function () { + throw err; + }).to.throw(Error, 'HID-SSI-SDK:: Error: params.privateKeyMultibase is required to deactivate a did'); + }); + }); + it('should not be able to deactivate did document as verificationMethodId is null or empty', function () { + return hsSdk.did.bjjDID + .deactivate({ didDocument, privateKeyMultibase, verificationMethodId: '', versionId: '1.0' }) + .catch(function (err) { + expect(function () { + throw err; + }).to.throw(Error, 'HID-SSI-SDK:: Error: params.verificationMethodId is required to deactivate a did'); + }); + }); + it('should not be able to deactivate did document as versionId is null or empty', function () { + return hsSdk.did.bjjDID + .deactivate({ didDocument, privateKeyMultibase, verificationMethodId: verificationMethod[0].id, versionId: '' }) + .catch(function (err) { + expect(function () { + throw err; + }).to.throw(Error, 'HID-SSI-SDK:: Error: params.versionId is required to deactivate a did'); + }); + }); + it('should not be able to deactivate did document as versionId passed is incorrect', function () { + const didDoc = JSON.parse(JSON.stringify(didDocument)) + const deactivateBody = { didDocument: didDoc, privateKeyMultibase, verificationMethodId: verificationMethod[0].id, versionId: '1.0.1' }; + return hsSdk.did.bjjDID.deactivate(deactivateBody).catch(function (err) { + expect(function () { + throw err; + }).to.throw( + Error, + `failed to execute message; message index: 0: Expected ${didDocId} with version ${versionId}. Got version 1.0.1: unexpected DID version` + ); + }); + }); + it('should be able to deactivate did generated using BabyJubJubKey', async () => { + const updatedDid = await hsSdk.did.bjjDID.deactivate({ + didDocument: didDocument, + privateKeyMultibase, + verificationMethodId: verificationMethod[0].id, + versionId + }) + should().exist(updatedDid.transactionHash); + }) + it('should not be able to deactivate did document as its already deactivated', async function () { + const didDocTodeactivate = JSON.parse(JSON.stringify(didDocument)) + return hsSdk.did.bjjDID.deactivate({ + didDocument: didDocTodeactivate, + privateKeyMultibase, + verificationMethodId: verificationMethod[0].id, + versionId, + }).catch(function (err) { + expect(function () { + throw err; + }).to.throw(Error, `failed to execute message; message index: 0: DID Document ${didDocId} is already deactivated: didDoc is deactivated`) + }) + }); + it('should be able to resolve did after deactivation and deactivated should be true', async () => { + const resolvedDid = await hsSdk.did.bjjDID.resolve({ + did: didDocId + }) + versionId = resolvedDid.didDocumentMetadata.versionId + didDocument = resolvedDid.didDocument + const didDocumentmetaData = resolvedDid.didDocumentMetadata + expect(didDocument).to.be.a('object'); + expect(didDocumentmetaData).to.be.a('object') + should().exist(didDocumentmetaData.created) + should().exist(didDocumentmetaData.updated) + should().exist(didDocumentmetaData.deactivated) + expect(didDocumentmetaData.deactivated).to.be.equal(true) + should().exist(didDocumentmetaData.versionId) + const date1 = new Date(didDocumentmetaData.updated); + const date2 = new Date(didDocumentmetaData.created); + expect(date1).to.be.greaterThan(date2) + }) + }) +}) \ No newline at end of file diff --git a/src/tests/bjj/presentation/bjj_vp.spec.ts b/src/tests/bjj/presentation/bjj_vp.spec.ts new file mode 100644 index 0000000..f3ad5a4 --- /dev/null +++ b/src/tests/bjj/presentation/bjj_vp.spec.ts @@ -0,0 +1,718 @@ +import { HypersignSSISdk } from '../../../index'; +import { expect, should } from 'chai'; +import { createWallet, mnemonic, hidNodeEp } from '../../config'; +let issuerPrivateKeyMultibase; +let issuerPublicKeyMultibase; +let holderPrivateKeyMultibase; +let holderPublicKeyMultibase; +let offlineSigner; +let hsSdk; +let credentialStatusId; +let credenStatus; +let verificationMethod; +let schemaObject; +let signedSchema; +let schemaId; +let subjectDid; +let signedVC1; +let issuerDid; +let issuerDidDoc; +let subjectDidDoc; +let credentialDetail; +let credentialId; +let signedVp1; +let signedVC; +let unsignedSdVerifiablePresentation; +let unsignedVerifiablePresentation; + +let signedVp; +let signedSdVp; +let selectiveDisclosure; +const issueCredentialBody = { + credential: credentialDetail, + issuerDid, + verificationMethodId: '', + privateKeyMultibase: issuerPrivateKeyMultibase, + registerCredential: true, +}; +const schemaBody = { + name: 'TestSchema', + description: 'This is a test schema generation', + author: '', + fields: [ + { name: 'name', type: 'string', isRequired: false }, + { name: 'address', type: 'string', isRequired: true }, + ], + additionalProperties: false, +}; +const credentialBody = { + schemaId: '', + subjectDid: '', + type: [], + issuerDid: '', + fields: { name: 'Varsha', address: 'Random address' }, + expirationDate: '', +}; +beforeEach(async function () { + offlineSigner = await createWallet(mnemonic); + const params = { + offlineSigner, + nodeRestEndpoint: hidNodeEp.rest, + nodeRpcEndpoint: hidNodeEp.rpc, + namespace: hidNodeEp.namespace, + }; + hsSdk = new HypersignSSISdk(params); + await hsSdk.init(); +}); + +describe('#generateKeys() method to generate publicKyeMultibase and privateKeyMultiBase', function () { + it('should return publickeyMultibase and privateKeyMultibase', async function () { + const kp = await hsSdk.did.bjjDID.generateKeys(); + issuerPrivateKeyMultibase = kp.privateKeyMultibase; + issuerPublicKeyMultibase = kp.publicKeyMultibase; + expect(kp).to.be.a('object'); + should().exist(kp.privateKeyMultibase); + should().exist(kp.publicKeyMultibase); + should().not.exist(kp.id); + }); +}); +/** + * DID creation and registration + */ +describe('DID Operation', () => { + describe('#generate() method to generate new did', function () { + it('should be able to generate a issuer did using babyJubJub', async () => { + issuerDidDoc = await hsSdk.did.bjjDID.generate({ + publicKeyMultibase: issuerPublicKeyMultibase, + }); + issuerDid = issuerDidDoc.id; + verificationMethod = issuerDidDoc.verificationMethod; + expect(issuerDidDoc).to.be.a('object'); + should().exist(issuerDidDoc['@context']); + should().exist(issuerDidDoc['id']); + should().exist(issuerDidDoc['controller']); + should().exist(issuerDidDoc['verificationMethod']); + expect( + issuerDidDoc['verificationMethod'] && + issuerDidDoc['authentication'] && + issuerDidDoc['assertionMethod'] && + issuerDidDoc['keyAgreement'] && + issuerDidDoc['capabilityInvocation'] && + issuerDidDoc['capabilityDelegation'] && + issuerDidDoc['service'] + ).to.be.a('array'); + expect(verificationMethod[0].type).to.be.equal('BabyJubJubKey2021'); + should().exist(issuerDidDoc['authentication']); + should().exist(issuerDidDoc['assertionMethod']); + should().exist(issuerDidDoc['keyAgreement']); + should().exist(issuerDidDoc['capabilityInvocation']); + should().exist(issuerDidDoc['capabilityDelegation']); + should().exist(issuerDidDoc['service']); + expect(issuerDidDoc['authentication'].length).to.be.greaterThan(0); + expect(issuerDidDoc['assertionMethod'].length).to.be.greaterThan(0); + expect(issuerDidDoc['capabilityInvocation'].length).to.be.equal(0); + expect(issuerDidDoc['capabilityDelegation'].length).to.be.equal(0); + expect(issuerDidDoc['keyAgreement'].length).to.be.equal(0); + expect(issuerDidDoc['service'].length).to.be.equal(0); + }); + it('should be able to genrate a did for holder', async () => { + const kp = await hsSdk.did.bjjDID.generateKeys(); + holderPrivateKeyMultibase = kp.privateKeyMultibase; + holderPublicKeyMultibase = kp.publicKeyMultibase; + subjectDidDoc = await hsSdk.did.bjjDID.generate({ + publicKeyMultibase: holderPublicKeyMultibase, + }); + subjectDid = subjectDidDoc.id; + }); + }); + describe('#register() method to register did', function () { + it('should be able to register did generated using BabyJubJubKey', async () => { + const registerDid = await hsSdk.did.bjjDID.register({ + didDocument: issuerDidDoc, + privateKeyMultibase: issuerPrivateKeyMultibase, + verificationMethodId: verificationMethod[0].id, + }); + issuerDidDoc = registerDid.didDocument; + expect(issuerDidDoc).to.be.a('object'); + should().exist(issuerDidDoc['@context']); + should().exist(issuerDidDoc['id']); + should().exist(issuerDidDoc['controller']); + should().exist(issuerDidDoc['verificationMethod']); + expect( + issuerDidDoc['verificationMethod'] && + issuerDidDoc['authentication'] && + issuerDidDoc['assertionMethod'] && + issuerDidDoc['keyAgreement'] && + issuerDidDoc['capabilityInvocation'] && + issuerDidDoc['capabilityDelegation'] && + issuerDidDoc['service'] + ).to.be.a('array'); + expect(verificationMethod[0].type).to.be.equal('BabyJubJubKey2021'); + should().exist(issuerDidDoc['authentication']); + should().exist(issuerDidDoc['assertionMethod']); + should().exist(issuerDidDoc['keyAgreement']); + should().exist(issuerDidDoc['capabilityInvocation']); + should().exist(issuerDidDoc['capabilityDelegation']); + should().exist(issuerDidDoc['service']); + expect(issuerDidDoc['authentication'].length).to.be.greaterThan(0); + expect(issuerDidDoc['assertionMethod'].length).to.be.greaterThan(0); + expect(issuerDidDoc['capabilityInvocation'].length).to.be.equal(0); + expect(issuerDidDoc['capabilityDelegation'].length).to.be.equal(0); + expect(issuerDidDoc['keyAgreement'].length).to.be.equal(0); + expect(issuerDidDoc['service'].length).to.be.equal(0); + should().exist(registerDid.transactionHash); + }); + it('should be able to register did for holder', async () => { + const registerDid = await hsSdk.did.bjjDID.register({ + didDocument: subjectDidDoc, + privateKeyMultibase: holderPrivateKeyMultibase, + verificationMethodId: subjectDidDoc.verificationMethod[0].id, + }); + subjectDidDoc = registerDid.didDocument; + }); + }); +}); +// /** +// * Schema Creation and Registration +// */ +describe('Schema Operations', () => { + describe('#generate() method to create schema', function () { + it('should be able to generate new schema', async function () { + const tempSchemaBody = { ...schemaBody }; + tempSchemaBody.author = issuerDid; + schemaObject = await hsSdk.schema.hypersignBjjschema.generate(tempSchemaBody); + schemaId = schemaObject['id']; + expect(schemaObject).to.be.a('object'); + should().exist(schemaObject['type']); + should().exist(schemaObject['modelVersion']); + should().exist(schemaObject['id']); + should().exist(schemaObject['name']); + should().exist(schemaObject['author']); + should().exist(schemaObject['authored']); + should().exist(schemaObject['schema']); + expect(schemaObject.schema).to.be.a('object'); + expect(schemaObject['name']).to.be.equal(tempSchemaBody.name); + expect(schemaObject['author']).to.be.equal(tempSchemaBody.author); + expect(schemaObject['schema'].required).to.be.a('array'); + }); + }); + + describe('#sign() method to sign a schema', function () { + it('should be able to sign newly created schema', async () => { + signedSchema = await await hsSdk.schema.hypersignBjjschema.sign({ + privateKeyMultibase: issuerPrivateKeyMultibase, + schema: schemaObject, + verificationMethodId: issuerDidDoc['assertionMethod'][0], + }); + expect(signedSchema).to.be.a('object'); + should().exist(signedSchema.type); + should().exist(signedSchema.modelVersion); + should().exist(signedSchema['id']); + should().exist(signedSchema['name']); + should().exist(signedSchema['author']); + should().exist(signedSchema['authored']); + should().exist(signedSchema['schema']); + should().exist(signedSchema.schema.schema); + should().exist(signedSchema.schema.description); + should().exist(signedSchema.schema.type); + should().exist(signedSchema.schema.properties); + should().exist(signedSchema.schema.required); + should().exist(signedSchema.proof); + should().exist(signedSchema.proof.type); + expect(signedSchema.proof.type).to.be.equal('BJJSignature2021'); + should().exist(signedSchema.proof.created); + should().exist(signedSchema.proof.verificationMethod); + should().exist(signedSchema.proof.proofPurpose); + expect(signedSchema.proof.proofPurpose).to.be.equal('assertionMethod'); + should().exist(signedSchema.proof.proofValue); + }); + }); + + describe('#register() method to register a schema', function () { + it('should be able to register newly created schema', async () => { + const registerdSchema = await hsSdk.schema.hypersignBjjschema.register({ schema: signedSchema }); + should().exist(registerdSchema.transactionHash); + }); + }); + + describe('#resolve() method to resolve a schema', function () { + it('Should be able to resolve schema from blockchain', async () => { + const resolvedSchema = await hsSdk.schema.hypersignBjjschema.resolve({ schemaId }); + should().exist(resolvedSchema.context); + should().exist(resolvedSchema.type); + should().exist(resolvedSchema.modelVersion); + should().exist(resolvedSchema.id); + should().exist(resolvedSchema.name); + should().exist(resolvedSchema.author); + should().exist(resolvedSchema.authored); + should().exist(resolvedSchema.schema); + should().exist(resolvedSchema.schema.schema); + should().exist(resolvedSchema.schema.description); + should().exist(resolvedSchema.schema.type); + should().exist(resolvedSchema.schema.properties); + should().exist(resolvedSchema.schema.required); + should().exist(resolvedSchema.schema.additionalProperties); + should().exist(resolvedSchema.proof); + should().exist(resolvedSchema.proof.type); + should().exist(resolvedSchema.proof.created); + should().exist(resolvedSchema.proof.verificationMethod); + should().exist(resolvedSchema.proof.proofPurpose); + should().exist(resolvedSchema.proof.proofValue); + should().exist(resolvedSchema.proof.clientSpecType); + expect(resolvedSchema.proof.clientSpecType).to.be.equal('CLIENT_SPEC_TYPE_NONE'); + }); + }); +}); +// /** +// * Test cases related to credential +// */ +describe('Credential Operation', () => { + describe('#generate() method to generate a credential', function () { + it('should be able to generate a credential', async () => { + const expirationDate = new Date('12/11/2027'); + const tempCredentialBody = { ...credentialBody }; + tempCredentialBody.schemaId = schemaId; + tempCredentialBody.subjectDid = subjectDid; + tempCredentialBody['expirationDate'] = expirationDate.toString(); + tempCredentialBody.issuerDid = issuerDid; + tempCredentialBody.fields = { name: 'varsha', address: 'random address' }; + credentialDetail = await hsSdk.vc.bjjVC.generate(tempCredentialBody); + + expect(credentialDetail).to.be.a('object'); + should().exist(credentialDetail['@context']); + should().exist(credentialDetail['id']); + credentialId = credentialDetail.id; + should().exist(credentialDetail['type']); + should().exist(credentialDetail['issuanceDate']); + should().exist(credentialDetail['issuer']); + should().exist(credentialDetail['credentialSubject']); + should().exist(credentialDetail['credentialStatus']); + expect(credentialDetail['credentialStatus'].type).to.be.equal('HypersignCredentialStatus2023'); + }); + }); + + describe('#issueCredential() method for issuing credential', function () { + it('should be able to issue credential with credential status registered on chain', async function () { + const tempIssueCredentialBody = { ...issueCredentialBody }; + tempIssueCredentialBody.credential = credentialDetail; + tempIssueCredentialBody.issuerDid = issuerDid; + tempIssueCredentialBody.verificationMethodId = verificationMethod[0].id; + tempIssueCredentialBody.privateKeyMultibase = issuerPrivateKeyMultibase; + const issuedCredResult = await hsSdk.vc.bjjVC.issue(tempIssueCredentialBody); + + const { signedCredential, credentialStatus, credentialStatusProof, credentialStatusRegistrationResult } = + issuedCredResult; + + signedVC1 = {}; + Object.assign(signedVC1, signedCredential); + signedVC = signedCredential; + credenStatus = credentialStatus; + credentialId = signedVC.id; + credentialStatusId = signedCredential['credentialStatus'].id; + expect(signedCredential).to.be.a('object'); + should().exist(signedCredential['@context']); + should().exist(signedCredential['id']); + should().exist(signedCredential['type']); + should().exist(signedCredential['issuanceDate']); + should().exist(signedCredential['issuer']); + should().exist(signedCredential['credentialSubject']); + should().exist(signedCredential['credentialSchema']); + should().exist(signedCredential['credentialStatus']); + should().exist(signedCredential['proof']); + expect(signedCredential['id']).to.be.equal(tempIssueCredentialBody.credential.id); + expect(credentialStatus).to.be.a('object'); + should().exist(credentialStatus['@context']); + should().exist(credentialStatus['id']); + should().exist(credentialStatus['issuer']); + should().exist(credentialStatus['issuanceDate']); + should().exist(credentialStatus['credentialMerkleRootHash']); + should().exist(credentialStatus['proof']); + should().exist(credentialStatus['proof'].type); + expect(credentialStatus['proof'].type).to.be.equal('BJJSignature2021'); + expect(credentialStatusProof).to.be.a('object'); + should().exist(credentialStatusProof['type']); + expect(credentialStatusProof['type']).to.be.equal('BJJSignature2021'); + should().exist(credentialStatusProof['created']); + should().exist(credentialStatusProof['verificationMethod']); + should().exist(credentialStatusProof['proofPurpose']); + should().exist(credentialStatusProof['proofValue']); + expect(credentialStatusRegistrationResult).to.be.a('object'); + should().exist(credentialStatusRegistrationResult['height']); + should().exist(credentialStatusRegistrationResult['transactionHash']); + should().exist(credentialStatusRegistrationResult['gasUsed']); + should().exist(credentialStatusRegistrationResult['gasWanted']); + }); + }); + + describe('#generateSeletiveDisclosure() method for genertaing sd', function () { + const presentationBody = { + verifiableCredential: signedVC1, + frame: {}, + verificationMethodId: '', + issuerDid, + }; + it('should be able to generate a sd document', async () => { + const revelDocument = { + type: ['VerifiableCredential', 'TestSchema'], + expirationDate: {}, + issuanceDate: {}, + issuer: {}, + credentialSubject: { + '@explicit': true, + id: {}, + }, + }; + const tempPresentationBody = { ...presentationBody }; + tempPresentationBody.verifiableCredential = signedVC1; + tempPresentationBody.frame = revelDocument; + tempPresentationBody.issuerDid = issuerDid; + tempPresentationBody.verificationMethodId = verificationMethod[0].id; + selectiveDisclosure = await hsSdk.vc.bjjVC.generateSeletiveDisclosure(tempPresentationBody); + + should().exist(selectiveDisclosure['@context']); + should().exist(selectiveDisclosure['id']); + expect(selectiveDisclosure['id']).to.be.equal(credentialId); + should().exist(selectiveDisclosure['type']); + should().exist(selectiveDisclosure['credentialSchema']); + should().exist(selectiveDisclosure['credentialStatus']); + should().exist(selectiveDisclosure['credentialSubject']); + expect(selectiveDisclosure['credentialSubject']).to.be.equal(subjectDid); + should().exist(selectiveDisclosure['expirationDate']); + should().exist(selectiveDisclosure['issuanceDate']); + should().exist(selectiveDisclosure['issuer']); + expect(selectiveDisclosure['issuer']).to.be.equal(issuerDid); + should().exist(selectiveDisclosure['proof']); + should().exist(selectiveDisclosure['proof'].type); + expect(selectiveDisclosure['proof'].type).to.be.equal('BabyJubJubSignatureProof2021'); + should().exist(selectiveDisclosure['proof'].created); + should().exist(selectiveDisclosure['proof'].verificationMethod); + should().exist(selectiveDisclosure['proof'].proofPurpose); + should().exist(selectiveDisclosure['proof'].credentialRoot); + should().exist(selectiveDisclosure['proof'].proofValue); + }); + }); +}); + +// /** +// * Test cases related to verifiable presentation +// */ +describe('Verifiable Presentation Operataions', () => { + describe('#generate() method to generate new presentation document', () => { + it('should be able to generate a new presentation for sd document', async () => { + const presentationBody = { + verifiableCredentials: [selectiveDisclosure], + holderDid: subjectDid, + }; + + const tempPresentationBody = { ...presentationBody }; + tempPresentationBody.holderDid = subjectDid; + unsignedSdVerifiablePresentation = await hsSdk.vp.bjjVp.generate(tempPresentationBody); + should().exist(unsignedSdVerifiablePresentation['@context']); + should().exist(unsignedSdVerifiablePresentation['type']); + expect(unsignedSdVerifiablePresentation.type[0]).to.be.equal('VerifiablePresentation'); + should().exist(unsignedSdVerifiablePresentation['verifiableCredential']); + expect(unsignedSdVerifiablePresentation.verifiableCredential).to.be.a('array'); + should().exist(unsignedSdVerifiablePresentation['id']); + should().exist(unsignedSdVerifiablePresentation['holder']); + }); + + it('should be able to generate a presentation for credential document', async () => { + const presentationBody = { + verifiableCredentials: [signedVC1], + holderDid: subjectDid, + }; + const tempPresentationBody = { ...presentationBody }; + tempPresentationBody.holderDid = subjectDid; + unsignedVerifiablePresentation = await hsSdk.vp.bjjVp.generate(tempPresentationBody); + should().exist(unsignedVerifiablePresentation['@context']); + should().exist(unsignedVerifiablePresentation['type']); + expect(unsignedVerifiablePresentation.type[0]).to.be.equal('VerifiablePresentation'); + should().exist(unsignedVerifiablePresentation['verifiableCredential']); + expect(unsignedVerifiablePresentation.verifiableCredential).to.be.a('array'); + should().exist(unsignedVerifiablePresentation['id']); + should().exist(unsignedVerifiablePresentation['holder']); + }); + }); + + describe('#sign() method to sign presentation of credential', () => { + const signPresentaionBody = { + presentation: unsignedVerifiablePresentation, + holderDid: subjectDid, + verificationMethodId: '', + privateKeyMultibase: holderPrivateKeyMultibase, + challenge: 'abc', + domain: 'www.xyz.com', + }; + it('should not be able to sign a presentation as both holderDidDoc as well did is passed', async () => { + const tempSignPresentaionBody = { ...signPresentaionBody }; + tempSignPresentaionBody['holderDid'] = subjectDid; + tempSignPresentaionBody['holderDidDocSigned'] = subjectDidDoc; + return hsSdk.vp.bjjVp.sign(tempSignPresentaionBody).catch(function (err) { + expect(function () { + throw err; + }).to.throw(Error, 'HID-SSI-SDK:: Either holderDid or holderDidDocSigned should be provided'); + }); + }); + it('should not be able to sign a presentation as privateKeyMultibase is not passed', async () => { + const tempSignPresentaionBody = { ...signPresentaionBody }; + tempSignPresentaionBody['holderDid'] = subjectDid; + tempSignPresentaionBody['privateKeyMultibase'] = ''; + + return hsSdk.vp.bjjVp.sign(tempSignPresentaionBody).catch(function (err) { + expect(function () { + throw err; + }).to.throw(Error, 'HID-SSI-SDK:: params.privateKeyMultibase is required for signing a presentation'); + }); + }); + it('should not be able to sign a presentation as presentation is not passed', async () => { + const tempSignPresentaionBody = { ...signPresentaionBody }; + tempSignPresentaionBody['holderDid'] = subjectDid; + tempSignPresentaionBody['privateKeyMultibase'] = holderPrivateKeyMultibase; + tempSignPresentaionBody['presentation'] = null; + + return hsSdk.vp.bjjVp.sign(tempSignPresentaionBody).catch(function (err) { + expect(function () { + throw err; + }).to.throw(Error, 'HID-SSI-SDK:: params.presentation is required for signing a presentation'); + }); + }); + it('should not be able to sign a presentation as verificationMethodId is not passed', async () => { + const tempSignPresentaionBody = { ...signPresentaionBody }; + tempSignPresentaionBody['holderDid'] = subjectDid; + tempSignPresentaionBody['privateKeyMultibase'] = holderPrivateKeyMultibase; + tempSignPresentaionBody['presentation'] = unsignedVerifiablePresentation; + tempSignPresentaionBody['challenge'] = 'abc'; + + return hsSdk.vp.bjjVp.sign(tempSignPresentaionBody).catch(function (err) { + expect(function () { + throw err; + }).to.throw(Error, 'HID-SSI-SDK:: params.verificationMethodId is required for signing a presentation'); + }); + }); + it('should be able to sign a selective discloser presentation document', async () => { + const presentationBody = { + presentation: unsignedSdVerifiablePresentation, + holderDid: subjectDid, + verificationMethodId: subjectDidDoc.authentication[0], + privateKeyMultibase: holderPrivateKeyMultibase, + challenge: 'abc', + domain: 'www.xyz.com', + }; + signedSdVp = await hsSdk.vp.bjjVp.sign(presentationBody); + should().exist(signedSdVp['@context']); + should().exist(signedSdVp['type']); + expect(signedSdVp.type[0]).to.be.equal('VerifiablePresentation'); + should().exist(signedSdVp['verifiableCredential']); + should().exist(signedSdVp['id']); + should().exist(signedSdVp['holder']); + should().exist(signedSdVp['proof']); + expect(signedSdVp['proof'].type).to.be.equal('BJJSignature2021'); + should().exist(signedSdVp['proof'].created); + should().exist(signedSdVp['proof'].verificationMethod); + should().exist(signedSdVp['proof'].proofPurpose); + should().exist(signedSdVp['proof'].challenge); + should().exist(signedSdVp['proof'].proofValue); + }); + it('should be able to sign a verifiable presentation document', async () => { + const presentationBody = { + presentation: unsignedVerifiablePresentation, + holderDid: subjectDid, + verificationMethodId: subjectDidDoc.authentication[0], + privateKeyMultibase: holderPrivateKeyMultibase, + challenge: 'abc', + domain: 'www.xyz.com', + }; + signedVp = await hsSdk.vp.bjjVp.sign(presentationBody); + + signedVp1 = {}; + Object.assign(signedVp1, signedVp); + + should().exist(signedVp['@context']); + should().exist(signedVp['type']); + expect(signedVp.type[0]).to.be.equal('VerifiablePresentation'); + should().exist(signedVp['verifiableCredential']); + should().exist(signedVp['id']); + should().exist(signedVp['holder']); + should().exist(signedVp['proof']); + expect(signedVp['proof'].type).to.be.equal('BJJSignature2021'); + should().exist(signedVp['proof'].created); + should().exist(signedVp['proof'].verificationMethod); + should().exist(signedVp['proof'].proofPurpose); + should().exist(signedVp['proof'].challenge); + should().exist(signedVp['proof'].proofValue); + }); + }); + describe('#verify() method to verify signed presentation of credential', () => { + const verifyPresentationBody = { + signedPresentation: signedSdVp, + challenge: 'abc', + domain: 'www.xyz.com', + issuerDid, + holderDid: subjectDid, + issuerVerificationMethodId: '', + holderVerificationMethodId: '', + }; + it('should not be able to verify presentation as either holderDid or holderDidDocSigned is required but passed both', async function () { + const tempverifyPresentationBody = { ...verifyPresentationBody }; + tempverifyPresentationBody.signedPresentation = signedVp; + tempverifyPresentationBody.holderDid = subjectDid; + tempverifyPresentationBody.holderVerificationMethodId = subjectDidDoc.verificationMethod[0].id; + tempverifyPresentationBody.issuerVerificationMethodId = verificationMethod[0].id; + tempverifyPresentationBody['holderDidDocSigned'] = subjectDidDoc; + return hsSdk.vp.bjjVp.verify(tempverifyPresentationBody).catch(function (err) { + expect(function () { + throw err; + }).to.throw(Error, 'HID-SSI-SDK:: Either holderDid or holderDidDocSigned should be provided'); + }); + }); + it('should not be able to verify presentation as issuerDid is null or empty', async function () { + const tempverifyPresentationBody = { ...verifyPresentationBody }; + tempverifyPresentationBody.issuerDid = ''; + return hsSdk.vp.bjjVp.verify(tempverifyPresentationBody).catch(function (err) { + expect(function () { + throw err; + }).to.throw(Error, 'HID-SSI-SDK:: params.issuerDid is required for verifying a presentation'); + }); + }); + it('should not be able to verify presentation as challenge is null or empty', async function () { + const tempverifyPresentationBody = { ...verifyPresentationBody }; + tempverifyPresentationBody.issuerDid = issuerDid; + tempverifyPresentationBody.challenge = ''; + + return hsSdk.vp.bjjVp.verify(tempverifyPresentationBody).catch(function (err) { + expect(function () { + throw err; + }).to.throw(Error, 'HID-SSI-SDK:: params.challenge is required for verifying a presentation'); + }); + }); + it('should not be able to verify presentation as holderVerificationMethodId is null or empty', async function () { + const tempverifyPresentationBody = { ...verifyPresentationBody }; + tempverifyPresentationBody.issuerDid = issuerDid; + tempverifyPresentationBody.challenge = 'abc'; + tempverifyPresentationBody.holderVerificationMethodId = ''; + + return hsSdk.vp.bjjVp.verify(tempverifyPresentationBody).catch(function (err) { + expect(function () { + throw err; + }).to.throw(Error, 'HID-SSI-SDK:: params.holderVerificationMethodId is required for verifying a presentation'); + }); + }); + it('should not be able to verify presentation as issuerVerificationMethodId is null or empty', async function () { + const tempverifyPresentationBody = { ...verifyPresentationBody }; + tempverifyPresentationBody.issuerDid = issuerDid; + tempverifyPresentationBody.challenge = 'abc'; + tempverifyPresentationBody.holderVerificationMethodId = subjectDidDoc.verificationMethod[0].id; + tempverifyPresentationBody.issuerVerificationMethodId = ''; + return hsSdk.vp.bjjVp.verify(tempverifyPresentationBody).catch(function (err) { + expect(function () { + throw err; + }).to.throw(Error, 'HID-SSI-SDK:: params.issuerVerificationMethodId is required for verifying a presentation'); + }); + }); + it('should not be able to verify a sd presentation as challenge is different that used in signing', async () => { + const presentationBody = { + signedPresentation: JSON.parse(JSON.stringify(signedSdVp)), + challenge: 'abcdvfgh', + domain: 'www.xyz.com', + issuerDid, + holderDid: subjectDid, + issuerVerificationMethodId: issuerDidDoc.assertionMethod[0], + holderVerificationMethodId: subjectDidDoc.authentication[0], + }; + const verifiedVp = await hsSdk.vp.bjjVp.verify(presentationBody); + should().exist(verifiedVp['verified']); + expect(verifiedVp.verified).to.be.equal(false); + should().exist(verifiedVp['results']); + expect(verifiedVp.results).to.be.a('array'); + expect(verifiedVp.results[0].verified).to.be.equal(false); + expect(verifiedVp.results[1].credentialResult).to.be.a('array'); + expect(verifiedVp.results[1].credentialResult.length).to.be.greaterThan(0); + expect(verifiedVp.results[1].credentialResult[0].verified).to.be.equal(true); + }); + it('should not be able to verify a sd presentation as domain is different that used in signing', async () => { + const presentationBody = { + signedPresentation: JSON.parse(JSON.stringify(signedSdVp)), + challenge: 'abc', + domain: 'www.xyz1.com', + issuerDid, + holderDid: subjectDid, + issuerVerificationMethodId: issuerDidDoc.assertionMethod[0], + holderVerificationMethodId: subjectDidDoc.authentication[0], + }; + const verifiedVp = await hsSdk.vp.bjjVp.verify(presentationBody); + should().exist(verifiedVp['verified']); + expect(verifiedVp.verified).to.be.equal(false); + should().exist(verifiedVp['results']); + expect(verifiedVp.results).to.be.a('array'); + expect(verifiedVp.results[0].verified).to.be.equal(false); + expect(verifiedVp.results[1].credentialResult).to.be.a('array'); + expect(verifiedVp.results[1].credentialResult.length).to.be.greaterThan(0); + expect(verifiedVp.results[1].credentialResult[0].verified).to.be.equal(true); + }); + it('should be able to verify a sd presentation document', async () => { + const presentationBody = { + signedPresentation: signedSdVp, + challenge: 'abc', + domain: 'www.xyz.com', + issuerDid, + holderDid: subjectDid, + issuerVerificationMethodId: issuerDidDoc.assertionMethod[0], + holderVerificationMethodId: subjectDidDoc.authentication[0], + }; + const verifiedVp = await hsSdk.vp.bjjVp.verify(presentationBody); + should().exist(verifiedVp['verified']); + expect(verifiedVp.verified).to.be.equal(true); + should().exist(verifiedVp['results']); + expect(verifiedVp.results).to.be.a('array'); + expect(verifiedVp.results[1].credentialResult).to.be.a('array'); + expect(verifiedVp.results[1].credentialResult.length).to.be.greaterThan(0); + expect(verifiedVp.results[1].credentialResult[0].verified).to.be.equal(true); + }); + it('should not be able to verify presentation as challenge used at the time of verification is different than challenge used in vp sign and getting presentation verification result false', async function () { + const tempverifyPresentationBody = { ...verifyPresentationBody }; + tempverifyPresentationBody.signedPresentation = signedVp1; + tempverifyPresentationBody.issuerDid = issuerDid; + tempverifyPresentationBody.holderDid = subjectDid; + tempverifyPresentationBody.challenge = 'abczshdsfhgk'; + tempverifyPresentationBody['domain'] = 'http://xyz.com'; + tempverifyPresentationBody.holderVerificationMethodId = subjectDidDoc.assertionMethod[0]; + tempverifyPresentationBody.issuerVerificationMethodId = issuerDidDoc.assertionMethod[0]; + const verifiedPresentationDetail = await hsSdk.vp.bjjVp.verify(tempverifyPresentationBody); + expect(verifiedPresentationDetail.verified).to.be.equal(false); + expect(verifiedPresentationDetail.results[0].verified).to.be.equal(false); + }); + it('should not be able to verify presentation as domain used at the time of vp verification is differ than domain used in vp sign and getting presentation verification result false', async function () { + const tempverifyPresentationBody = { ...verifyPresentationBody }; + tempverifyPresentationBody.signedPresentation = signedVp1; + tempverifyPresentationBody.issuerDid = issuerDid; + tempverifyPresentationBody.holderDid = subjectDid; + tempverifyPresentationBody.challenge = 'abc'; + tempverifyPresentationBody['domain'] = 'http://xyz1.com'; + tempverifyPresentationBody.holderVerificationMethodId = subjectDidDoc.authentication[0]; + tempverifyPresentationBody.issuerVerificationMethodId = issuerDidDoc.assertionMethod[0]; + const verifiedPresentationDetail = await hsSdk.vp.bjjVp.verify(tempverifyPresentationBody); + expect(verifiedPresentationDetail.verified).to.be.equal(false); + expect(verifiedPresentationDetail.results[0].verified).to.be.equal(false); + }); + it('should be able to verify a presentation document', async () => { + const presentationBody = { + signedPresentation: signedVp1, + challenge: 'abc', + domain: 'www.xyz.com', + issuerDid, + holderDid: subjectDid, + issuerVerificationMethodId: issuerDidDoc.assertionMethod[0], + holderVerificationMethodId: subjectDidDoc.authentication[0], + }; + const verifiedVp = await hsSdk.vp.bjjVp.verify(presentationBody); + + should().exist(verifiedVp['verified']); + expect(verifiedVp.verified).to.be.equal(true); + should().exist(verifiedVp['results']); + expect(verifiedVp.results).to.be.a('array'); + expect(verifiedVp.results[1].credentialResult).to.be.a('array'); + expect(verifiedVp.results[1].credentialResult.length).to.be.greaterThan(0); + expect(verifiedVp.results[1].credentialResult[0].verified).to.be.equal(true); + }); + }); +}); diff --git a/src/tests/bjj/schema/bjj_schema.spec.ts b/src/tests/bjj/schema/bjj_schema.spec.ts new file mode 100644 index 0000000..dc03f61 --- /dev/null +++ b/src/tests/bjj/schema/bjj_schema.spec.ts @@ -0,0 +1,522 @@ + +import { HypersignSSISdk } from '../../../index'; +import { expect, should } from 'chai'; +import { createWallet, mnemonic, hidNodeEp } from '../../config' + +let signedSchema2; +let invalidSchemaNamedSignedSchema1 +let invalidSchemaNamedSignedSchema2 +let invalidSchemaNamedSignedSchema3 +let randomProperty + +let privateKeyMultibase; +let publicKeyMultibase; +let offlineSigner +let hsSdk +let didDocument; +let verificationMethod; +let didDocId; +let schemaObject; +let signedSchema; +let schemaId +let schemaObject2 +const schemaBody = { + name: 'TestSchema', + description: 'This is a test schema generation', + author: '', + fields: [{ name: 'name', type: 'string', isRequired: false }, { name: "address", type: "string", isRequired: true }] as any, + additionalProperties: false, +}; +beforeEach(async function () { + offlineSigner = await createWallet(mnemonic); + const params = { + offlineSigner, + nodeRestEndpoint: hidNodeEp.rest, + nodeRpcEndpoint: hidNodeEp.rpc, + namespace: hidNodeEp.namespace, + }; + hsSdk = new HypersignSSISdk(params); + await hsSdk.init(); +}); + +describe('#generateKeys() method to generate publicKyeMultibase and privateKeyMultiBase', function () { + it('should return publickeyMultibase and privateKeyMultibase', async function () { + const kp = await hsSdk.did.bjjDID.generateKeys(); + privateKeyMultibase = kp.privateKeyMultibase; + publicKeyMultibase = kp.publicKeyMultibase; + expect(kp).to.be.a('object'); + should().exist(kp.privateKeyMultibase); + should().exist(kp.publicKeyMultibase); + should().not.exist(kp.id); + }); +}); +describe('DID Operation', () => { + describe('#generate() method to generate new did', function () { + it('should be able to generate a did using babyJubJub', async () => { + didDocument = await hsSdk.did.bjjDID.generate({ + publicKeyMultibase + }) + didDocId = didDocument.id + verificationMethod = didDocument.verificationMethod + expect(didDocument).to.be.a('object'); + should().exist(didDocument['@context']); + should().exist(didDocument['id']); + should().exist(didDocument['controller']); + should().exist(didDocument['verificationMethod']); + expect( + didDocument['verificationMethod'] && + didDocument['authentication'] && + didDocument['assertionMethod'] && + didDocument['keyAgreement'] && + didDocument['capabilityInvocation'] && + didDocument['capabilityDelegation'] && + didDocument['service'] + ).to.be.a('array'); + expect(verificationMethod[0].type).to.be.equal('BabyJubJubKey2021') + should().exist(didDocument['authentication']); + should().exist(didDocument['assertionMethod']); + should().exist(didDocument['keyAgreement']); + should().exist(didDocument['capabilityInvocation']); + should().exist(didDocument['capabilityDelegation']); + should().exist(didDocument['service']); + expect(didDocument['authentication'].length).to.be.greaterThan(0) + expect(didDocument['assertionMethod'].length).to.be.greaterThan(0) + expect(didDocument['capabilityInvocation'].length).to.be.equal(0) + expect(didDocument['capabilityDelegation'].length).to.be.equal(0) + expect(didDocument['keyAgreement'].length).to.be.equal(0) + expect(didDocument['service'].length).to.be.equal(0) + + }) + }) + describe('#register() method to register did', function () { + it('should be able to register did generated using BabyJubJubKey', async () => { + const registerDid = await hsSdk.did.bjjDID.register({ + didDocument: didDocument, + privateKeyMultibase, + verificationMethodId: verificationMethod[0].id + }) + didDocument = registerDid.didDocument + expect(didDocument).to.be.a('object'); + should().exist(didDocument['@context']); + should().exist(didDocument['id']); + should().exist(didDocument['controller']); + should().exist(didDocument['verificationMethod']); + expect( + didDocument['verificationMethod'] && + didDocument['authentication'] && + didDocument['assertionMethod'] && + didDocument['keyAgreement'] && + didDocument['capabilityInvocation'] && + didDocument['capabilityDelegation'] && + didDocument['service'] + ).to.be.a('array'); + expect(verificationMethod[0].type).to.be.equal('BabyJubJubKey2021') + should().exist(didDocument['authentication']); + should().exist(didDocument['assertionMethod']); + should().exist(didDocument['keyAgreement']); + should().exist(didDocument['capabilityInvocation']); + should().exist(didDocument['capabilityDelegation']); + should().exist(didDocument['service']); + expect(didDocument['authentication'].length).to.be.greaterThan(0) + expect(didDocument['assertionMethod'].length).to.be.greaterThan(0) + expect(didDocument['capabilityInvocation'].length).to.be.equal(0) + expect(didDocument['capabilityDelegation'].length).to.be.equal(0) + expect(didDocument['keyAgreement'].length).to.be.equal(0) + expect(didDocument['service'].length).to.be.equal(0) + should().exist(registerDid.transactionHash); + }) + }) +}) + +describe('Schema Operations', () => { + describe('#generate() method to create schema', function () { + it('should not be able to create a new schema as author is not passed', function () { + const tempSchemaBody = { ...schemaBody }; + return hsSdk.schema.hypersignBjjschema.generate(tempSchemaBody).catch(function (err) { + expect(function () { + throw err; + }).to.throw(Error, 'HID-SSI-SDK:: Error: Author must be passed'); + }); + }); + it('should not be able to create a new schema as schema name is in camelCase and only pascalCase is allowed', function () { + const tempSchemaBody = { ...schemaBody }; + tempSchemaBody.author = didDocId; + tempSchemaBody['name'] = 'testSchema' + + return hsSdk.schema.hypersignBjjschema.generate(tempSchemaBody).catch(function (err) { + expect(function () { + throw err; + }).to.throw(Error, 'HID-SSI-SDK:: Error: schema name should always be in PascalCase'); + }); + }); + + it('should not be able to create a schema as schema name is in snakeCase and only pascalCase is allowed', function () { + const tempSchemaBody = { ...schemaBody }; + tempSchemaBody.author = didDocId; + tempSchemaBody['name'] = 'testing_schema' + return hsSdk.schema.hypersignBjjschema.generate(tempSchemaBody).catch(function (err) { + expect(function () { + throw err; + }).to.throw(Error, 'HID-SSI-SDK:: Error: schema name should always be in PascalCase'); + }); + }); + it('should not be able to create a schema as schema name is not in pascalCase', function () { + const tempSchemaBody = { ...schemaBody }; + tempSchemaBody.author = didDocId; + tempSchemaBody['name'] = 'Test credential Schema' + return hsSdk.schema.hypersignBjjschema.generate(tempSchemaBody).catch(function (err) { + expect(function () { + throw err; + }).to.throw(Error, 'HID-SSI-SDK:: Error: schema name should always be in PascalCase'); + }); + }); + it("should not be able to create a schema as sub-property 'name' is not present in field property", function () { + const tempSchemaBody = { ...schemaBody }; + tempSchemaBody.author = didDocId; + tempSchemaBody['fields'] = [{ isRequired: true }] + return hsSdk.schema.hypersignBjjschema.generate(tempSchemaBody).catch(function (err) { + expect(function () { + throw err; + }).to.throw(Error, "HID-SSI-SDK:: Error: All fields must contains property 'name'"); + }); + }); + it('should be able to generate new schema', async function () { + const tempSchemaBody = { ...schemaBody } + tempSchemaBody.author = didDocId + schemaObject = await hsSdk.schema.hypersignBjjschema.generate(tempSchemaBody) + schemaId = schemaObject['id'] + expect(schemaObject).to.be.a('object') + should().exist(schemaObject['type']); + should().exist(schemaObject['modelVersion']); + should().exist(schemaObject['id']); + should().exist(schemaObject['name']); + should().exist(schemaObject['author']); + should().exist(schemaObject['authored']); + should().exist(schemaObject['schema']); + expect(schemaObject.schema).to.be.a('object'); + expect(schemaObject['name']).to.be.equal(tempSchemaBody.name); + expect(schemaObject['author']).to.be.equal(tempSchemaBody.author); + expect(schemaObject['schema'].required).to.be.a('array') + }) + it('should be able to create a schema with differnt field value', async function () { + const tempSchemaBody = { ...schemaBody }; + tempSchemaBody.fields.push({ name: 'address', type: 'string', isRequired: false }) + tempSchemaBody.author = didDocId; + schemaObject2 = await hsSdk.schema.hypersignBjjschema.generate(tempSchemaBody); + expect(schemaObject).to.be.a('object'); + should().exist(schemaObject['type']); + should().exist(schemaObject['modelVersion']); + should().exist(schemaObject['id']); + should().exist(schemaObject['name']); + should().exist(schemaObject['author']); + should().exist(schemaObject['authored']); + should().exist(schemaObject['schema']); + expect(schemaObject.schema).to.be.a('object'); + expect(schemaObject['name']).to.be.equal(tempSchemaBody.name); + expect(schemaObject['author']).to.be.equal(tempSchemaBody.author); + }); + }) + describe('#sign() method to sign a schema', function () { + it('should not be able to sign a new schema as privateKeyMultibase is not passed', function () { + return hsSdk.schema.hypersignBjjschema.sign({ + privateKeyMultibase: "", + schema: schemaObject, + verificationMethodId: didDocument['assertionMethod'][0] + }).catch(function (err) { + expect(function () { + throw err; + }).to.throw(Error, 'HID-SSI-SDK:: Error: params.privateKeyMultibase must be passed'); + }); + }); + it('should not be able to sign a new schema as verificationMethodId is not passed', function () { + return hsSdk.schema.hypersignBjjschema.sign({ + privateKeyMultibase, + schema: schemaObject, + verificationMethodId: "" + }).catch(function (err) { + expect(function () { + throw err; + }).to.throw(Error, 'HID-SSI-SDK:: Error: params.verificationMethodId must be passed'); + }); + }); + it('should not be able to sign a new schema as schema is not passed', function () { + return hsSdk.schema.hypersignBjjschema.sign({ + privateKeyMultibase, + verificationMethodId: didDocument['assertionMethod'][0] + }).catch(function (err) { + expect(function () { + throw err; + }).to.throw(Error, 'HID-SSI-SDK:: Error: Schema must be passed'); + }); + }); + it('should be able to sign newly created schema', async () => { + signedSchema = await hsSdk.schema.hypersignBjjschema.sign({ + privateKeyMultibase, + schema: schemaObject, + verificationMethodId: didDocument['assertionMethod'][0] + }) + expect(signedSchema).to.be.a('object'); + should().exist(signedSchema.type); + should().exist(signedSchema.modelVersion); + should().exist(signedSchema['id']); + should().exist(signedSchema['name']); + should().exist(signedSchema['author']); + should().exist(signedSchema['authored']); + should().exist(signedSchema['schema']); + should().exist(signedSchema.schema.schema); + should().exist(signedSchema.schema.description); + should().exist(signedSchema.schema.type); + should().exist(signedSchema.schema.properties); + should().exist(signedSchema.schema.required); + should().exist(signedSchema.proof); + should().exist(signedSchema.proof.type); + expect(signedSchema.proof.type).to.be.equal('BJJSignature2021') + should().exist(signedSchema.proof.created); + should().exist(signedSchema.proof.verificationMethod); + should().exist(signedSchema.proof.proofPurpose); + expect(signedSchema.proof.proofPurpose).to.be.equal('assertionMethod') + should().exist(signedSchema.proof.proofValue); + }) + it('should be able to sign newly created schema with schema name is in camelCase', async function () { + const tempSchemaBody = JSON.parse(JSON.stringify(schemaObject2)) + tempSchemaBody['name'] = "testSchema" + invalidSchemaNamedSignedSchema1 = await hsSdk.schema.hypersignBjjschema.sign({ + privateKeyMultibase: privateKeyMultibase, + schema: tempSchemaBody, + verificationMethodId: didDocument['assertionMethod'][0], + }); + expect(signedSchema).to.be.a('object'); + should().exist(signedSchema.proof); + should().exist(signedSchema.proof.type); + should().exist(signedSchema.proof.verificationMethod); + should().exist(signedSchema.proof.proofPurpose); + should().exist(signedSchema.proof.proofValue); + should().exist(signedSchema.proof.created); + should().exist(signedSchema.type); + should().exist(signedSchema.modelVersion); + should().exist(signedSchema.author); + should().exist(signedSchema['id']); + should().exist(signedSchema['name']); + should().exist(signedSchema['author']); + should().exist(signedSchema['authored']); + should().exist(signedSchema['schema']); + }); + it('should be able to sign newly created schema with schema name is in snakeCase', async function () { + const tempSchemaBody = JSON.parse(JSON.stringify(schemaObject2)) + tempSchemaBody['name'] = "test_schema" + invalidSchemaNamedSignedSchema2 = await hsSdk.schema.hypersignBjjschema.sign({ + privateKeyMultibase: privateKeyMultibase, + schema: tempSchemaBody, + verificationMethodId: didDocument['assertionMethod'][0], + }); + expect(signedSchema).to.be.a('object'); + should().exist(signedSchema.proof); + should().exist(signedSchema.proof.type); + should().exist(signedSchema.proof.verificationMethod); + should().exist(signedSchema.proof.proofPurpose); + should().exist(signedSchema.proof.proofValue); + should().exist(signedSchema.proof.created); + should().exist(signedSchema.type); + should().exist(signedSchema.modelVersion); + should().exist(signedSchema.author); + should().exist(signedSchema['id']); + should().exist(signedSchema['name']); + should().exist(signedSchema['author']); + should().exist(signedSchema['authored']); + should().exist(signedSchema['schema']); + }); + it('should be able to sign newly created schema with schema name is in sentanceCase', async function () { + const tempSchemaBody = JSON.parse(JSON.stringify(schemaObject2)) + tempSchemaBody['name'] = "Test Schema" + invalidSchemaNamedSignedSchema3 = await hsSdk.schema.hypersignBjjschema.sign({ + privateKeyMultibase: privateKeyMultibase, + schema: tempSchemaBody, + verificationMethodId: didDocument['assertionMethod'][0], + }); + expect(signedSchema).to.be.a('object'); + should().exist(signedSchema.proof); + should().exist(signedSchema.proof.type); + should().exist(signedSchema.proof.verificationMethod); + should().exist(signedSchema.proof.proofPurpose); + should().exist(signedSchema.proof.proofValue); + should().exist(signedSchema.proof.created); + should().exist(signedSchema.type); + should().exist(signedSchema.modelVersion); + should().exist(signedSchema.author); + should().exist(signedSchema['id']); + should().exist(signedSchema['name']); + should().exist(signedSchema['author']); + should().exist(signedSchema['authored']); + should().exist(signedSchema['schema']); + }); + it('should be able to sign newly created schema with invalid sub-property of propert field', async function () { + const tempSchemaBody = JSON.parse(JSON.stringify(schemaObject2)) + const prop = JSON.parse(tempSchemaBody.schema.properties) + randomProperty = "randomProperty" + prop[`${schemaBody.fields[0].name}`]['randomProperty'] = "xyz" + tempSchemaBody['schema'].properties = JSON.stringify(prop) + signedSchema2 = await hsSdk.schema.hypersignBjjschema.sign({ + privateKeyMultibase: privateKeyMultibase, + schema: tempSchemaBody, + verificationMethodId: didDocument['assertionMethod'][0], + }); + expect(signedSchema).to.be.a('object'); + should().exist(signedSchema.proof); + should().exist(signedSchema.proof.type); + should().exist(signedSchema.proof.verificationMethod); + should().exist(signedSchema.proof.proofPurpose); + should().exist(signedSchema.proof.proofValue); + should().exist(signedSchema.proof.created); + should().exist(signedSchema.type); + should().exist(signedSchema.modelVersion); + should().exist(signedSchema.author); + should().exist(signedSchema['id']); + should().exist(signedSchema['name']); + should().exist(signedSchema['author']); + should().exist(signedSchema['authored']); + should().exist(signedSchema['schema']); + }); + }) + describe('#register() method to register a schema', function () { + it('Should not be able to register schema as schema is not passed in params', async () => { + const params = { + schemas: signedSchema + } + return hsSdk.schema.hypersignBjjschema.register(params).catch(function (err) { + expect(function () { + throw err + }).to.throw(Error, 'HID-SSI-SDK:: Error: schema must be passed') + }) + }) + it('Should not be able to register schema as schema object does not have proof field', async () => { + const tempSchemaDetail = { ...signedSchema } + delete tempSchemaDetail.proof + return hsSdk.schema.hypersignBjjschema.register({ schema: tempSchemaDetail }).catch(function (err) { + expect(function () { + throw err + }).to.throw(Error, 'HID-SSI-SDK:: Error: schema.proof must be passed') + }) + }) + it('Should not be able to register schema as schema proof does not have "created" field or it is empty ', async () => { + const tempSchemaDetail = JSON.parse(JSON.stringify({ ...signedSchema })) + tempSchemaDetail.proof.created = "" + return hsSdk.schema.hypersignBjjschema.register({ schema: tempSchemaDetail }).catch(function (err) { + expect(function () { + throw err + }).to.throw(Error, 'HID-SSI-SDK:: Error: schema.proof must Contain created') + }) + }) + it('Should not be able to register schema as schema proof does not have "proofPurpose" field or it is empty ', async () => { + const tempSchemaDetail = JSON.parse(JSON.stringify({ ...signedSchema })) + tempSchemaDetail.proof.proofPurpose = "" + return hsSdk.schema.hypersignBjjschema.register({ schema: tempSchemaDetail }).catch(function (err) { + expect(function () { + throw err + }).to.throw(Error, 'HID-SSI-SDK:: Error: schema.proof must Contain proofPurpose') + }) + }) + it('Should not be able to register schema as schema proof does not have "proofValue" field or it is empty ', async () => { + const tempSchemaDetail = JSON.parse(JSON.stringify({ ...signedSchema })) + tempSchemaDetail.proof.proofValue = "" + return hsSdk.schema.hypersignBjjschema.register({ schema: tempSchemaDetail }).catch(function (err) { + expect(function () { + throw err + }).to.throw(Error, 'HID-SSI-SDK:: Error: schema.proof must Contain proofValue') + }) + }) + it('Should not be able to register schema as schema proof does not have "type" field or it is empty ', async () => { + const tempSchemaDetail = JSON.parse(JSON.stringify({ ...signedSchema })) + tempSchemaDetail.proof.type = "" + return hsSdk.schema.hypersignBjjschema.register({ schema: tempSchemaDetail }).catch(function (err) { + expect(function () { + throw err + }).to.throw(Error, 'HID-SSI-SDK:: Error: schema.proof must Contain type') + }) + }) + it('Should not be able to register schema as schema proof does not have "verificationMethod" field or it is empty ', async () => { + const tempSchemaDetail = JSON.parse(JSON.stringify({ ...signedSchema })) + tempSchemaDetail.proof.verificationMethod = "" + return hsSdk.schema.hypersignBjjschema.register({ schema: tempSchemaDetail }).catch(function (err) { + expect(function () { + throw err + }).to.throw(Error, 'HID-SSI-SDK:: Error: schema.proof must Contain verificationMethod') + }) + }) + it('should be able to register newly created schema', async () => { + const registerdSchema = await hsSdk.schema.hypersignBjjschema.register({ schema: signedSchema }) + should().exist(registerdSchema.transactionHash); + }) + it('should not be able to register schema on blockchain as its already registered', async function () { + return hsSdk.schema.hypersignBjjschema.register({ + schema: signedSchema, + }).catch(function (err) { + expect(function () { + throw err + }).to.throw(Error, `failed to execute message; message index: 0: Schema ID: ${schemaId}: schema already exists`) + }) + }); + it('should not be able to register schema as schema name is in camel case which is not valid', async function () { + return hsSdk.schema.hypersignBjjschema.register({ + schema: invalidSchemaNamedSignedSchema1, + }).catch(function (err) { + expect(function () { + throw err; + }).to.throw(Error, `failed to execute message; message index: 0: name must always be in PascalCase: ${invalidSchemaNamedSignedSchema1.name}: invalid credential schema`) + }) + }); + it('should not be able to register schema as schema name is in snake case which is not valid', async function () { + return hsSdk.schema.hypersignBjjschema.register({ + schema: invalidSchemaNamedSignedSchema2, + }).catch(function (err) { + expect(function () { + throw err; + }).to.throw(Error, `failed to execute message; message index: 0: name must always be in PascalCase: ${invalidSchemaNamedSignedSchema2.name}: invalid credential schema`) + }) + }); + it('should not be able to register schema as schema name is in sentance case which is not valid', async function () { + return hsSdk.schema.hypersignBjjschema.register({ + schema: invalidSchemaNamedSignedSchema3, + }).catch(function (err) { + expect(function () { + throw err; + }).to.throw(Error, `failed to execute message; message index: 0: name must always be in PascalCase: ${invalidSchemaNamedSignedSchema3.name}: invalid credential schema`) + }) + }); + it('should not be able to register schema as there is a invalid sub-property in side property field', async function () { + return hsSdk.schema.hypersignBjjschema.register({ + schema: signedSchema2, + }).catch(function (err) { + expect(function () { + throw err; + }).to.throw(Error, `failed to execute message; message index: 0: invalid \`property\` provided: invalid sub-attribute ${randomProperty} of attribute name. Only \`type\` and \`format\` sub-attributes are permitted: invalid credential schema`) + }) + }); + }) + describe('#resolve() method to resolve a schema', function () { + it('Should be able to resolve schema from blockchain', async () => { + const resolvedSchema = await hsSdk.schema.hypersignBjjschema.resolve({ schemaId }) + should().exist(resolvedSchema.context) + should().exist(resolvedSchema.type) + should().exist(resolvedSchema.modelVersion) + should().exist(resolvedSchema.id) + should().exist(resolvedSchema.name) + should().exist(resolvedSchema.author) + should().exist(resolvedSchema.authored) + should().exist(resolvedSchema.schema) + should().exist(resolvedSchema.schema.schema) + should().exist(resolvedSchema.schema.description) + should().exist(resolvedSchema.schema.type) + should().exist(resolvedSchema.schema.properties) + should().exist(resolvedSchema.schema.required) + should().exist(resolvedSchema.schema.additionalProperties) + should().exist(resolvedSchema.proof) + expect(resolvedSchema.proof.type).to.be.equal('BJJSignature2021') + should().exist(resolvedSchema.proof.created) + should().exist(resolvedSchema.proof.verificationMethod) + should().exist(resolvedSchema.proof.proofPurpose) + should().exist(resolvedSchema.proof.proofValue) + should().exist(resolvedSchema.proof.clientSpecType) + expect(resolvedSchema.proof.clientSpecType).to.be.equal('CLIENT_SPEC_TYPE_NONE') + }) + }) +}) \ No newline at end of file diff --git a/src/tests/config.ts b/src/tests/config.ts index c707caa..76b24e0 100644 --- a/src/tests/config.ts +++ b/src/tests/config.ts @@ -1,17 +1,29 @@ import { DirectSecp256k1HdWallet } from '@cosmjs/proto-signing'; import { HdPath, Slip10RawIndex } from '@cosmjs/crypto'; +import { EthereumEip712Signature2021 } from 'ethereumeip712signature2021suite'; +import { purposes } from 'jsonld-signatures'; +import { DID } from '../constants'; +import customLoader from '../../libs/w3cache/v1'; +import { JCS } from 'jcs'; +import Web3 from 'web3'; +import jsonld from 'jsonld'; +import crypto from 'crypto'; +import { ProofTypes, VerificationMethodRelationships } from '../../libs/generated/ssi/client/enums'; +const documentLoader = customLoader; + +let keyPair; export const mnemonic = 'verify sustain lumber boat demise parade special soft bargain scout spoil there addict move badge rebuild horn achieve hollow acquire glide bundle curious present'; export const hidNodeEp = { - rpc: 'https://rpc.jagrat.hypersign.id', - rest: 'https://api.jagrat.hypersign.id', + rpc: 'https://rpc.prajna.hypersign.id', + rest: 'https://api.prajna.hypersign.id', namespace: 'testnet', }; // export const hidNodeEp = { -// rpc: 'http://localhost:26657', -// rest: 'http://localhost:1317', +// rpc: 'http://127.0.0.1:26657', +// rest: 'http://127.0.0.1:1317', // namespace: 'testnet', // }; export function makeCosmoshubPath(a) { @@ -23,6 +35,7 @@ export function makeCosmoshubPath(a) { Slip10RawIndex.normal(a), ]; } +const phrase = 'flat vessel crawl guess female tray breeze bachelor rare fragile pottery observe'; export const createWallet = async (mnemonic) => { let options; @@ -45,4 +58,130 @@ export const createWallet = async (mnemonic) => { } }; +export const generatePresentationProof = async ( + presentation, + challenge, + holderDid, + authentication, + verificationMethodId, + domain? +) => { + const web3 = await generateWeb3Obj(); + const EthereumEip712Signature2021obj = new EthereumEip712Signature2021({}, web3); + + keyPair = await EthereumEip712Signature2021obj.fromPrivateKey( + '0x149195a4059ac8cafe2d56fc612f613b6b18b9265a73143c9f6d7cfbbed76b7e' + ); + const vcs: Array = []; + presentation.verifiableCredential.forEach((vc) => { + return vcs.push(JCS.cannonicalize(vc)); + }); + presentation.verifiableCredential = vcs; + const proof = await EthereumEip712Signature2021obj.createProof({ + document: presentation, + purpose: new purposes.AuthenticationProofPurpose({ + challenge, + domain: domain, + controller: { + '@context': DID.CONTROLLER_CONTEXT, + id: holderDid, + authentication: authentication, + }, + }), + verificationMethod: verificationMethodId, + date: new Date().toISOString(), + documentLoader, + domain: domain ? { name: domain } : undefined, + }); + presentation.proof = proof; + return presentation; +}; +// will remove unused functions later +export const verifyPresentation = async (signedPresentaion, challenge, holderDid, domain?) => { + const EthereumEip712Signature2021obj = new EthereumEip712Signature2021({}); + const proof = signedPresentaion.proof; + delete signedPresentaion.proof; + const verifResult = await EthereumEip712Signature2021obj.verifyProof({ + proof: proof, + domain: domain ? { name: domain } : undefined, + document: signedPresentaion, + types: 'EthereumEip712Signature2021', + purpose: new purposes.AuthenticationProofPurpose({ + challenge, + domain: domain, + controller: { + '@context': DID.CONTROLLER_CONTEXT, + id: holderDid, + authentication: [`${holderDid}#key-1`], + }, + }), + documentLoader: customLoader, + }); + return verifResult; +}; +async function _jsonLdNormalize(params: { doc }) { + const docToNormalize = params.doc; + const normalizedoc = await jsonld.normalize(docToNormalize, { + format: 'application/n-quads', + algorithm: 'URDNA2015', + }); + + return normalizedoc; +} +function _concat(arr1, arr2) { + const concatenatedArr = new Uint8Array(arr1.length + arr2.length); + concatenatedArr.set(arr1, 0); + concatenatedArr.set(arr2, arr1.length); + return concatenatedArr; +} +export const metamaskProvider = 'https://linea-goerli.infura.io/v3/6014efc44d9346bcb69d99d97aa0ad27'; + +export const generateWeb3Obj = async () => { + const provider = new Web3.providers.HttpProvider(metamaskProvider); + const web3 = new Web3(provider); + return web3; +}; + +export const signDid = async (didDocument, clientSpec, verificationMethodId, account) => { + if (clientSpec == 'eth-personalSign') { + const normalizedDidDoc = await _jsonLdNormalize({ doc: didDocument }); + const normalizedDidDocHash = new Uint8Array( + Buffer.from(crypto.createHash('sha256').update(normalizedDidDoc).digest('hex'), 'hex') + ); + const proof = { + '@context': didDocument['@context'], + type: ProofTypes.EcdsaSecp256k1RecoverySignature2020, + created: new Date(new Date().getTime() - 100000).toISOString().slice(0, -5) + 'Z', + verificationMethod: verificationMethodId, //didDoc?.verificationMethod && (didDoc.verificationMethod[0]?.id as string), // which vmId to use in case of multiple vms or we should pass vmId also in sign function + proofPurpose: VerificationMethodRelationships.assertionMethod, + }; + const normalizedProof = await _jsonLdNormalize({ doc: proof }); + delete proof['@context']; + const normalizedProofhash = new Uint8Array( + Buffer.from(crypto.createHash('sha256').update(normalizedProof).digest('hex'), 'hex') + ); + const combinedHash = _concat(normalizedProofhash, normalizedDidDocHash); + const didDocJsonDigest = { + didId: didDocument.id, + didDocDigest: Buffer.from(combinedHash).toString('hex'), + }; + const web3 = new Web3(); + const signature = await web3.eth.personal.sign( + JSON.stringify(didDocJsonDigest, (key, value) => { + if (value === '' || (Array.isArray(value) && value.length === 0)) { + return undefined; + } + return value; + }), + account.address, + account.privateKey + ); + delete proof['@context']; + proof['proofValue'] = signature; + return proof; + } +}; + +export const entityApiSecret = + '29a393a5d70094e409824359fc5d5.befc6c6f32d622e1c29ca900299a5695251b2407ca7cf6db8e6b2569dc13f937a4b83f4fa78738715d6267d3733e4f139'; // wallet address: hid1rh5h603fv9dneqm422uvl4xk3fc77a4uheleq5 diff --git a/src/tests/credential/vc.spec.ts b/src/tests/credential/vc.spec.ts index ca55414..e64f9b2 100644 --- a/src/tests/credential/vc.spec.ts +++ b/src/tests/credential/vc.spec.ts @@ -2,8 +2,8 @@ import { expect, should } from 'chai'; import { HypersignDID, HypersignSchema, HypersignVerifiableCredential } from '../../index'; import { createWallet, mnemonic, hidNodeEp } from '../config'; import { ICredentialStatus, IVerifiableCredential } from '../../credential/ICredential'; -import { CredentialProof, CredentialStatus } from '../../../libs/generated/ssi/credential'; - +import { CredentialStatusDocument as CredentialStatus } from '../../../libs/generated/ssi/credential_status'; +import { DocumentProof as CredentialProof } from '../../../libs/generated/ssi/proof'; let privateKeyMultibase; let publicKeyMultibase; let didDocId; @@ -28,6 +28,15 @@ let credenStatus: ICredentialStatus; let credentialStatusProof2 = {}; let credentialStatus2 = {}; let credentialStatus; +let holderDidDocument; +let holderSignedDidDoc; +let holdersPrivateKeyMultibase; +let credentialDetail2; +let credentialDetail3; +let issuedCredResult +let issuedCredResult2 +const credentialTransMessage = [] as any + const entityApiSecretKey = '57ed4af5b3f51428250e76a769ce8.d8f70a64e3d060b377c85eb75b60ae25011ecebb63f28a27f72183e5bcba140222f8628f17a72eee4833a9174f5ae8309'; const credentialBody = { @@ -39,7 +48,7 @@ const credentialBody = { expirationDate: '', }; const schemaBody = { - name: 'testSchema', + name: 'TestSchema', description: 'This is a test schema generation', author: '', fields: [{ name: 'name', type: 'string', isRequired: false }], @@ -102,12 +111,39 @@ describe('DID Opearations', () => { should().exist(didDocument['verificationMethod']); expect( didDocument['verificationMethod'] && - didDocument['authentication'] && - didDocument['assertionMethod'] && - didDocument['keyAgreement'] && - didDocument['capabilityInvocation'] && - didDocument['capabilityDelegation'] && - didDocument['service'] + didDocument['authentication'] && + didDocument['assertionMethod'] && + didDocument['keyAgreement'] && + didDocument['capabilityInvocation'] && + didDocument['capabilityDelegation'] && + didDocument['service'] + ).to.be.a('array'); + should().exist(didDocument['authentication']); + should().exist(didDocument['assertionMethod']); + should().exist(didDocument['keyAgreement']); + should().exist(didDocument['capabilityInvocation']); + should().exist(didDocument['capabilityDelegation']); + should().exist(didDocument['service']); + }); + it('should be able to generate didDocument', async function () { + const kp = await hypersignDID.generateKeys(); + holdersPrivateKeyMultibase = kp.privateKeyMultibase; + holderDidDocument = await hypersignDID.generate({ publicKeyMultibase: kp.publicKeyMultibase }); + expect(didDocument).to.be.a('object'); + should().exist(didDocument['@context']); + should().exist(didDocument['id']); + should().exist(didDocument['controller']); + should().exist(didDocument['alsoKnownAs']); + + should().exist(didDocument['verificationMethod']); + expect( + didDocument['verificationMethod'] && + didDocument['authentication'] && + didDocument['assertionMethod'] && + didDocument['keyAgreement'] && + didDocument['capabilityInvocation'] && + didDocument['capabilityDelegation'] && + didDocument['service'] ).to.be.a('array'); should().exist(didDocument['authentication']); should().exist(didDocument['assertionMethod']); @@ -150,11 +186,39 @@ describe('DID Opearations', () => { should().exist(signedDocument['service']); should().exist(signedDocument['proof']); }); + it('should able to sign did document for holder', async function () { + const params = { + privateKeyMultibase: holdersPrivateKeyMultibase as string, + challenge: challenge as string, + domain: domain as string, + did: '', + didDocument: holderDidDocument as object, + verificationMethodId: holderDidDocument.verificationMethod[0].id as string, + controller, + }; + holderSignedDidDoc = await hypersignDID.sign(params); + expect(signedDocument).to.be.a('object'); + should().exist(signedDocument['@context']); + should().exist(signedDocument['id']); + expect(didDocId).to.be.equal(signedDocument['id']); + should().exist(signedDocument['controller']); + should().exist(signedDocument['alsoKnownAs']); + should().exist(signedDocument['verificationMethod']); + should().exist(signedDocument['authentication']); + should().exist(signedDocument['assertionMethod']); + should().exist(signedDocument['keyAgreement']); + should().exist(signedDocument['capabilityInvocation']); + should().exist(signedDocument['capabilityDelegation']); + should().exist(signedDocument['service']); + should().exist(signedDocument['proof']); + }); }); describe('#register() this is to register did on the blockchain', function () { it('should be able to register didDocument in the blockchain', async function () { - const result = await hypersignDID.register({ didDocument, privateKeyMultibase, verificationMethodId }); + const didDoc = didDocument; + delete didDoc.proof; + const result = await hypersignDID.register({ didDocument: didDoc, privateKeyMultibase, verificationMethodId }); should().exist(result.transactionHash); should().exist(result.didDocument); }); @@ -195,7 +259,6 @@ describe('Schema Opearations', () => { const registeredSchema = await hypersignSchema.register({ schema: signedSchema, }); - // console.log(registeredSchema) expect(registeredSchema).to.be.a('object'); should().exist(registeredSchema.transactionHash); }); @@ -206,11 +269,11 @@ describe('Schema Opearations', () => { * Test cases related to credential */ describe('Verifiable Credential Opearations', () => { - describe('#getCredential() method to generate a credential', function () { + describe('#generate() method to generate a credential', function () { it('should not be able to generate new credential for a schema as both subjectDid and subjectDidDocSigned is passed', async function () { const tempCredentialBody = { ...credentialBody }; tempCredentialBody.issuerDid = didDocId; - tempCredentialBody.subjectDid = didDocId; + tempCredentialBody.subjectDid = holderDidDocument.id; tempCredentialBody['subjectDidDocSigned'] = signedDocument; return hypersignVC.generate(tempCredentialBody).catch(function (err) { expect(function () { @@ -255,7 +318,7 @@ describe('Verifiable Credential Opearations', () => { const tempCredentialBody = { ...credentialBody }; tempCredentialBody.schemaId = schemaId; tempCredentialBody.issuerDid = didDocId; - tempCredentialBody['subjectDid'] = didDocId; + tempCredentialBody['subjectDid'] = holderDidDocument.id; return hypersignVC.generate(tempCredentialBody).catch(function (err) { expect(function () { throw err; @@ -299,82 +362,100 @@ describe('Verifiable Credential Opearations', () => { ); }); }); - it('should be able to generate new credential for a schema with subject DID', async function () { const expirationDate = new Date('12/11/2027'); const tempCredentialBody = { ...credentialBody }; tempCredentialBody.schemaId = schemaId; - tempCredentialBody.subjectDid = didDocId; + tempCredentialBody.subjectDid = holderDidDocument.id; tempCredentialBody['expirationDate'] = expirationDate.toString(); tempCredentialBody.issuerDid = didDocId; tempCredentialBody.fields = { name: 'varsha' }; credentialDetail = await hypersignVC.generate(tempCredentialBody); - // console.log('New Credential --------------------------------'); - // console.log(JSON.stringify(credentialDetail, null, 2)); - expect(credentialDetail).to.be.a('object'); should().exist(credentialDetail['@context']); should().exist(credentialDetail['id']); credentialId = credentialDetail.id; should().exist(credentialDetail['type']); - should().exist(credentialDetail['expirationDate']); should().exist(credentialDetail['issuanceDate']); should().exist(credentialDetail['issuer']); should().exist(credentialDetail['credentialSubject']); - should().exist(credentialDetail['credentialSchema']); should().exist(credentialDetail['credentialStatus']); - expect(credentialDetail['credentialStatus'].type).to.be.equal('CredentialStatusList2017'); + expect(credentialDetail['credentialStatus'].type).to.be.equal('HypersignCredentialStatus2023'); }); - it('should be able to generate new credential even without offlinesigner passed to constructor', async function () { - const expirationDate = new Date('12/11/2027'); + const expirationDate = new Date('11/11/2027'); const tempCredentialBody = { ...credentialBody }; tempCredentialBody.schemaId = schemaId; - tempCredentialBody.subjectDid = didDocId; + tempCredentialBody.subjectDid = holderDidDocument.id; tempCredentialBody['expirationDate'] = expirationDate.toString(); tempCredentialBody.issuerDid = didDocId; tempCredentialBody.fields = { name: 'varsha' }; - const hypersignVC1 = new HypersignVerifiableCredential(); - const credentialDetail = await hypersignVC1.generate(tempCredentialBody); + const hypersignVC1 = new HypersignVerifiableCredential({ + nodeRestEndpoint: hidNodeEp.rest, + nodeRpcEndpoint: hidNodeEp.rpc, + namespace: hidNodeEp.namespace, + }); + credentialDetail2 = await hypersignVC1.generate(tempCredentialBody); expect(credentialDetail).to.be.a('object'); should().exist(credentialDetail['@context']); should().exist(credentialDetail['id']); should().exist(credentialDetail['type']); - should().exist(credentialDetail['expirationDate']); should().exist(credentialDetail['issuanceDate']); should().exist(credentialDetail['issuer']); should().exist(credentialDetail['credentialSubject']); should().exist(credentialDetail['credentialSchema']); should().exist(credentialDetail['credentialStatus']); - expect(credentialDetail['credentialStatus'].type).to.be.equal('CredentialStatusList2017'); + expect(credentialDetail['credentialStatus'].type).to.be.equal('HypersignCredentialStatus2023'); }); + it('should be able to generate new credential even without offlinesigner passed to constructor to test bulkRegistration', async function () { + const expirationDate = new Date('11/11/2027'); + const tempCredentialBody = { ...credentialBody }; + tempCredentialBody.schemaId = schemaId; + tempCredentialBody.subjectDid = holderDidDocument.id; + tempCredentialBody['expirationDate'] = expirationDate.toString(); + tempCredentialBody.issuerDid = didDocId; + tempCredentialBody.fields = { name: 'varsha' }; + + const hypersignVC1 = new HypersignVerifiableCredential({ + nodeRestEndpoint: hidNodeEp.rest, + nodeRpcEndpoint: hidNodeEp.rpc, + namespace: hidNodeEp.namespace, + }); + credentialDetail3 = await hypersignVC1.generate(tempCredentialBody); + expect(credentialDetail).to.be.a('object'); + should().exist(credentialDetail['@context']); + should().exist(credentialDetail['id']); + should().exist(credentialDetail['type']); + should().exist(credentialDetail['issuanceDate']); + should().exist(credentialDetail['issuer']); + should().exist(credentialDetail['credentialSubject']); + should().exist(credentialDetail['credentialSchema']); + should().exist(credentialDetail['credentialStatus']); + expect(credentialDetail['credentialStatus'].type).to.be.equal('HypersignCredentialStatus2023'); + }); it('should be able to generate new credential for a schema with signed subject DID doc', async function () { - const expirationDate = new Date('12/11/2027'); + const expirationDate = new Date('10/11/2027'); const tempCredentialBody = { ...credentialBody }; tempCredentialBody.schemaId = schemaId; tempCredentialBody['subjectDidDocSigned'] = signedDocument; tempCredentialBody['expirationDate'] = expirationDate.toString(); tempCredentialBody.issuerDid = didDocId; tempCredentialBody.fields = { name: 'varsha' }; - - // console.log(tempCredentialBody) const credentialDetail = await hypersignVC.generate(tempCredentialBody); - // console.log(JSON.stringify(credentialDetail)); expect(credentialDetail).to.be.a('object'); should().exist(credentialDetail['@context']); should().exist(credentialDetail['id']); should().exist(credentialDetail['type']); - should().exist(credentialDetail['expirationDate']); should().exist(credentialDetail['issuanceDate']); should().exist(credentialDetail['issuer']); should().exist(credentialDetail['credentialSubject']); should().exist(credentialDetail['credentialSchema']); should().exist(credentialDetail['credentialStatus']); - expect(credentialDetail['credentialStatus'].type).to.be.equal('CredentialStatusList2017'); + expect(credentialDetail['credentialStatus'].type).to.be.equal('HypersignCredentialStatus2023'); }); }); @@ -427,14 +508,12 @@ describe('Verifiable Credential Opearations', () => { }).to.throw(Error, 'HID-SSI-SDK:: Error: params.issuerDid is required to issue credential'); }); }); - it('should be able to issue credential with credential status registered on chain', async function () { const tempIssueCredentialBody = { ...issueCredentialBody }; tempIssueCredentialBody.credential = credentialDetail; tempIssueCredentialBody.issuerDid = didDocId; tempIssueCredentialBody.verificationMethodId = verificationMethodId; tempIssueCredentialBody.privateKeyMultibase = privateKeyMultibase; - // console.log(JSON.stringify(tempIssueCredentialBody, null, 2)); const issuedCredResult = await hypersignVC.issue(tempIssueCredentialBody); const { signedCredential, credentialStatus, credentialStatusProof, credentialStatusRegistrationResult } = @@ -444,16 +523,12 @@ describe('Verifiable Credential Opearations', () => { credenStatus = credentialStatus; credentialId = signedVC.id; - // console.log('Signed Credential --------------------------------'); - // console.log(JSON.stringify(signedVC, null, 2)); - credentialStatusId = signedCredential['credentialStatus'].id; expect(signedCredential).to.be.a('object'); should().exist(signedCredential['@context']); should().exist(signedCredential['id']); should().exist(signedCredential['type']); - should().exist(signedCredential['expirationDate']); should().exist(signedCredential['issuanceDate']); should().exist(signedCredential['issuer']); should().exist(signedCredential['credentialSubject']); @@ -464,16 +539,15 @@ describe('Verifiable Credential Opearations', () => { expect(signedCredential['id']).to.be.equal(tempIssueCredentialBody.credential.id); expect(credentialStatus).to.be.a('object'); - should().exist(credentialStatus['claim']); + should().exist(credentialStatus['@context']); + should().exist(credentialStatus['id']); should().exist(credentialStatus['issuer']); should().exist(credentialStatus['issuanceDate']); - should().exist(credentialStatus['expirationDate']); - should().exist(credentialStatus['credentialHash']); + should().exist(credentialStatus['credentialMerkleRootHash']); expect(credentialStatusProof).to.be.a('object'); should().exist(credentialStatusProof['type']); should().exist(credentialStatusProof['created']); - should().exist(credentialStatusProof['updated']); should().exist(credentialStatusProof['verificationMethod']); should().exist(credentialStatusProof['proofPurpose']); should().exist(credentialStatusProof['proofValue']); @@ -484,40 +558,58 @@ describe('Verifiable Credential Opearations', () => { should().exist(credentialStatusRegistrationResult['gasUsed']); should().exist(credentialStatusRegistrationResult['gasWanted']); }); - it('should be able to issue credential without having the credential status registered on chain', async function () { const expirationDate = new Date('12/11/2027'); const tempCredentialBody = { ...credentialBody }; tempCredentialBody.schemaId = schemaId; - tempCredentialBody['subjectDidDocSigned'] = signedDocument; + tempCredentialBody['subjectDidDocSigned'] = holderSignedDidDoc; tempCredentialBody['expirationDate'] = expirationDate.toString(); tempCredentialBody.issuerDid = didDocId; tempCredentialBody.fields = { name: 'varsha' }; const credentialDetail = await hypersignVC.generate(tempCredentialBody); - const tempIssueCredentialBody = { ...issueCredentialBody }; - tempIssueCredentialBody.credential = credentialDetail; tempIssueCredentialBody.issuerDid = didDocId; tempIssueCredentialBody.verificationMethodId = verificationMethodId; tempIssueCredentialBody.privateKeyMultibase = privateKeyMultibase; tempIssueCredentialBody.registerCredential = false; - const issuedCredResult = await hypersignVC.issue(tempIssueCredentialBody); - const { signedCredential, credentialStatus, credentialStatusProof, credentialStatusRegistrationResult } = issuedCredResult; - credentialStatus2 = credentialStatus; credentialStatusProof2 = credentialStatusProof; - - // console.log({ - // signedCredential, - // credentialStatusRegistrationResult, - // credentialStatus2, - // credentialStatusProof2, - // }); - + expect(signedCredential).to.be.a('object'); + expect(credentialStatus).to.be.a('object'); + expect(credentialStatusProof).to.be.a('object'); + should().not.exist(credentialStatusRegistrationResult); + }); + it('should be able to issue credential without having the credential status registered on chain to test bulkRegistration', async function () { + const tempIssueCredentialBody = { ...issueCredentialBody }; + tempIssueCredentialBody.credential = credentialDetail2; + tempIssueCredentialBody.issuerDid = didDocId; + tempIssueCredentialBody.verificationMethodId = verificationMethodId; + tempIssueCredentialBody.privateKeyMultibase = privateKeyMultibase; + tempIssueCredentialBody.registerCredential = false; + issuedCredResult = await hypersignVC.issue(tempIssueCredentialBody); + const { signedCredential, credentialStatus, credentialStatusProof, credentialStatusRegistrationResult } = + issuedCredResult; + expect(signedCredential).to.be.a('object'); + expect(credentialStatus).to.be.a('object'); + expect(credentialStatusProof).to.be.a('object'); + should().not.exist(credentialStatusRegistrationResult); + }); + it('should be able to issue credential without having the credential status registered on chain to test bulkRegistration', async function () { + const tempIssueCredentialBody = { ...issueCredentialBody }; + tempIssueCredentialBody.credential = credentialDetail3; + tempIssueCredentialBody.issuerDid = didDocId; + tempIssueCredentialBody.verificationMethodId = verificationMethodId; + tempIssueCredentialBody.privateKeyMultibase = privateKeyMultibase; + tempIssueCredentialBody.registerCredential = false; + issuedCredResult2 = await hypersignVC.issue(tempIssueCredentialBody); + const { signedCredential, credentialStatus, credentialStatusProof, credentialStatusRegistrationResult } = + issuedCredResult; + // credentialStatus2 = credentialStatus; + // credentialStatusProof2 = credentialStatusProof; expect(signedCredential).to.be.a('object'); expect(credentialStatus).to.be.a('object'); expect(credentialStatusProof).to.be.a('object'); @@ -531,12 +623,7 @@ describe('Verifiable Credential Opearations', () => { issuerDid: didDocId, verificationMethodId, }; - - // console.log('Signed vc --------------------------------'); - // console.log(JSON.stringify(params.credential, null, 2)); const verificationResult = await hypersignVC.verify(params); - // console.log('Credential Verifification result --------------------------------'); - // console.log(JSON.stringify(verificationResult, null, 2)); expect(verificationResult).to.be.a('object'); should().exist(verificationResult.verified); expect(verificationResult.verified).to.be.equal(true); @@ -646,15 +733,12 @@ describe('Verifiable Credential Status Opearations', () => { }); it('should be able to check credential status', async function () { - // console.log('Credential ID ' + credentialId); const credentialStatus = await hypersignVC.checkCredentialStatus({ credentialId: credentialId }); - // console.log(JSON.stringify(credentialStatus, null, 2)); expect(credentialStatus).to.be.a('object'); should().exist(credentialStatus.verified); expect(credentialStatus.verified).to.be.equal(true); }); }); - describe('#resolveCredentialStatus this is to resolve credential status', function () { it('should not be able to resolve credential as credentialId is not passed', async function () { return hypersignVC.resolveCredentialStatus({ credentialId: '' }).catch(function (err) { @@ -665,12 +749,13 @@ describe('Verifiable Credential Status Opearations', () => { }); it('should be able to resolve credential', async function () { credentialStatus = await hypersignVC.resolveCredentialStatus({ credentialId }); - // console.log(JSON.stringify(credentialStatus, null, 2)); expect(credentialStatus).to.be.a('object'); + should().exist(credentialStatus.revoked); + should().exist(credentialStatus.suspended); + should().exist(credentialStatus.remarks); should().exist(credentialStatus.issuer); should().exist(credentialStatus.issuanceDate); - should().exist(credentialStatus.expirationDate); - should().exist(credentialStatus.credentialHash); + should().exist(credentialStatus.credentialMerkleRootHash); should().exist(credentialStatus.proof); }); }); @@ -697,8 +782,8 @@ describe('Verifiable Credential Status Opearations', () => { // const tempParams = { ...params }; // tempParams.verificationMethodId = verificationMethodId; // tempParams.privateKeyMultibase = privateKeyMultibase; - // tempParams.issuerDid = credentialStatus; - // tempParams.credentialStatus = {} as ICredentialStatus; + // tempParams.issuerDid = didDocId; + // tempParams.credentialStatus = {} as ICredentialStatus; // return hypersignVC.updateCredentialStatus(tempParams).catch(function (err) { // expect(function () { // throw err; @@ -742,36 +827,110 @@ describe('Verifiable Credential Status Opearations', () => { }).to.throw(Error, 'HID-SSI-SDK:: Error: params.status is required to update credential status'); }); }); + it('should not be able to update credential as status passed is invalid', async function () { + const tempParams = { ...params }; + tempParams.verificationMethodId = verificationMethodId; + tempParams.credentialStatus = credenStatus; + tempParams.privateKeyMultibase = privateKeyMultibase; + tempParams.issuerDid = didDocId; + tempParams.status = 'svgsdvjif'; + return hypersignVC.updateCredentialStatus(tempParams).catch(function (err) { + expect(function () { + throw err; + }).to.throw(Error, `HID-SSI-SDK:: Error: params.status is invalid`); + }); + }); it('should be able to change credential status to suspended', async function () { + const credentialStatus = await hypersignVC.resolveCredentialStatus({ credentialId }); + const tempParams = { ...params } + tempParams['credentialStatus'] = credentialStatus + tempParams['verificationMethodId'] = verificationMethodId + tempParams.issuerDid = didDocId; + tempParams.privateKeyMultibase = privateKeyMultibase; + tempParams['status'] = 'SUSPENDED' + tempParams['statusReason'] = 'Suspending this credential for some time' + const updatedCredResult = await hypersignVC.updateCredentialStatus(tempParams); + expect(updatedCredResult).to.be.a('object'); + expect(updatedCredResult.code).to.be.equal(0); + expect(updatedCredResult.transactionHash).to.be.a('string'); + }); + it('should not be able to suspend a suspended credential status', async function () { + const credentialStatus = await hypersignVC.resolveCredentialStatus({ credentialId }); + const tempParams = { ...params } + tempParams['credentialStatus'] = credentialStatus + tempParams['verificationMethodId'] = verificationMethodId + tempParams['status'] = 'SUSPENDED' + tempParams.privateKeyMultibase = privateKeyMultibase; + tempParams.issuerDid = didDocId; + tempParams['statusReason'] = 'Suspending this credential for some time' + return hypersignVC.updateCredentialStatus(tempParams).catch(function (err) { + expect(function () { + throw err + }).to.throw(Error, "failed to execute message; message index: 0: incoming Credential Status Document does not have any changes: invalid Credential Status") + }); + + }); + it('should be able to change credential status to Live', async function () { const credentialStatus = await hypersignVC.resolveCredentialStatus({ credentialId }); const params = { credentialStatus, issuerDid: didDocId, verificationMethodId, privateKeyMultibase, - status: 'SUSPENDED', - statusReason: 'Suspending this credential for some time', + status: 'LIVE', + statusReason: 'Setting the status to LIVE', }; const updatedCredResult = await hypersignVC.updateCredentialStatus(params); - // console.log(updatedCredResult); expect(updatedCredResult).to.be.a('object'); expect(updatedCredResult.code).to.be.equal(0); }); - - it('should be able to change credential status to Live', async function () { + it('should be able to change credential status to Revoked', async function () { const credentialStatus = await hypersignVC.resolveCredentialStatus({ credentialId }); const params = { credentialStatus, issuerDid: didDocId, verificationMethodId, privateKeyMultibase, - status: 'LIVE', - statusReason: 'Setting the status to LIVE', + status: 'REVOKED', + statusReason: 'Revoking the credential', }; const updatedCredResult = await hypersignVC.updateCredentialStatus(params); expect(updatedCredResult).to.be.a('object'); expect(updatedCredResult.code).to.be.equal(0); }); + it('should not be able to revoke a revoked credential status', async function () { + const credentialStatus = await hypersignVC.resolveCredentialStatus({ credentialId }); + const params = { + credentialStatus, + issuerDid: didDocId, + verificationMethodId, + privateKeyMultibase, + status: 'REVOKED', + statusReason: 'Revoking the credential', + }; + return hypersignVC.updateCredentialStatus(params).catch(function (err) { + expect(function () { + throw err + }).to.throw(Error, 'failed to execute message; message index: 0: incoming Credential Status Document does not have any changes: invalid Credential Status') + }) + + }); + it('should not be able to change the status of credential as it is revoked', async function () { + const params = { + credentialStatus, + issuerDid: didDocId, + verificationMethodId, + privateKeyMultibase, + status: 'SUSPENDED', + statusReason: 'Suspending this credential for some time', + }; + + return hypersignVC.updateCredentialStatus(params).catch(function (err) { + expect(err.message).to.include( + `failed to execute message; message index: 0: credential status ${credentialId} could not be updated since it is revoked: invalid Credential Status` + ); + }); + }); }); describe('#registerCredentialStatus() method to register credential on blockchain', function () { @@ -806,5 +965,80 @@ describe('Verifiable Credential Status Opearations', () => { expect(registerCredDetail).to.be.a('object'); should().exist(registerCredDetail.transactionHash); }); + it('should not be able to register credential on blockchain as stutus already registerd on chain', async function () { + return hypersignVC.registerCredentialStatus({ + credentialStatus: credentialStatus2 as CredentialStatus, + credentialStatusProof: credentialStatusProof2 as CredentialProof, + }).catch(function (err) { + expect(function () { + throw err + + }).to.throw('failed to execute message; message index: 0: credential status document already exists') + }) + }); + }); + + + describe('#generateRegisterCredentialStatusTxnMessage() method to generate transaction message for credential2', function () { + it('should not be able to generatecredential status TxnMessage as credentialStatus is not passed', async function () { + const credentialStatus = null + const credentialStatusProof = issuedCredResult.credentialStatusProof + return hypersignVC.generateRegisterCredentialStatusTxnMessage(credentialStatus, credentialStatusProof).catch(function (err) { + expect(function () { + throw err; + }).to.throw( + Error, + 'HID-SSI-SDK:: Error: credentialStatus and proof are required to register credential status' + ); + }); + }); + it('should not be able to generatecredential status TxnMessage as credentialStatusProof is not passed', async function () { + const credentialStatus = issuedCredResult.credentialStatus + const credentialStatusProof = null + return hypersignVC.generateRegisterCredentialStatusTxnMessage(credentialStatus, credentialStatusProof).catch(function (err) { + expect(function () { + throw err; + }).to.throw( + Error, + 'HID-SSI-SDK:: Error: credentialStatus and proof are required to register credential status' + ); + }); + }); + it('should be able to generate credential status TxnMessage', async function () { + const credentialStatus = issuedCredResult.credentialStatus + const credentialStatusProof = issuedCredResult.credentialStatusProof + const credentialStatus2 = issuedCredResult2.credentialStatus + const credentialStatusProof2 = issuedCredResult2.credentialStatusProof + const txnMessage1 = await hypersignVC.generateRegisterCredentialStatusTxnMessage(credentialStatus, credentialStatusProof) + credentialTransMessage.push(txnMessage1) + const txnMessage2 = await hypersignVC.generateRegisterCredentialStatusTxnMessage(credentialStatus2, credentialStatusProof2) + credentialTransMessage.push(txnMessage2) + expect(txnMessage1).to.be.a('object') + should().exist(txnMessage1.typeUrl) + should().exist(txnMessage1.value) + should().exist(txnMessage1.value.credentialStatusDocument) + should().exist(txnMessage1.value.credentialStatusProof) + should().exist(txnMessage1.value.txAuthor) + }); + }) + + + describe('#registerCredentialStatusTxnBulk() method to register credential on blockchain', function () { + it('should not be able to register multiple credential as txnMessage is not passed', async function () { + const txnMessage = [] + return hypersignVC.registerCredentialStatusTxnBulk(txnMessage).catch(function (err) { + expect(function () { + throw err; + }).to.throw( + Error, + 'HID-SSI-SDK:: Error: txnMessage is required to register credential status' + ); + }); + }); + it('should be able to register credential on blockchain in a bulk', async function () { + const registerCredDetail = await hypersignVC.registerCredentialStatusTxnBulk(credentialTransMessage); + expect(registerCredDetail).to.be.a('object'); + should().exist(registerCredDetail.transactionHash); + }); }); }); diff --git a/src/tests/credential/vcByEntityApiKey.spec.ts b/src/tests/credential/vcByEntityApiKey.spec.ts index ebbb903..7379823 100644 --- a/src/tests/credential/vcByEntityApiKey.spec.ts +++ b/src/tests/credential/vcByEntityApiKey.spec.ts @@ -1,8 +1,8 @@ import { expect, should } from 'chai'; import { HypersignDID, HypersignSchema, HypersignVerifiableCredential } from '../../index'; -import { createWallet, mnemonic, hidNodeEp } from '../config'; +import { createWallet, mnemonic, hidNodeEp, entityApiSecret } from '../config'; import { ICredentialStatus, IVerifiableCredential } from '../../credential/ICredential'; -import { CredentialProof, CredentialStatus } from '../../../libs/generated/ssi/credential'; +// import { CredentialProof, CredentialStatus } from '../../../libs/generated/ssi/credential'; let didDocument; let didDocId; let privateKeyMultibase; @@ -29,8 +29,6 @@ const schemaBody = { fields: [{ name: 'name', type: 'string', isRequired: false }], additionalProperties: false, }; -const entityApiSecret = - "69b91e007904228e3313e586ba695.bc7705956989e43bbd7060e845c2763a381cbc80f935ac848119b8c2d7d00616346eeb74efe22a0ff140506a0c6157ef6" beforeEach(async function () { offlineSigner = await createWallet(mnemonic); const constructorParams = { diff --git a/src/tests/did/did.spec.ts b/src/tests/did/did.spec.ts index 1a07041..4f76137 100644 --- a/src/tests/did/did.spec.ts +++ b/src/tests/did/did.spec.ts @@ -1,8 +1,9 @@ import { expect, should } from 'chai'; import { HypersignDID, HypersignSSISdk } from '../../index'; -import { IPublicKey, IController, IDID, IKeyType } from '../../did/IDID'; +import { IPublicKey, IController } from '../../did/IDID'; import { createWallet, mnemonic, hidNodeEp } from '../config'; +import { VerificationMethodTypes } from '../../../libs/generated/ssi/client/enums'; let privateKeyMultibase; let publicKeyMultibase; let verificationMethodId; @@ -13,6 +14,7 @@ let versionId; let hypersignDID; let transactionHash; let signedDocument; +let signedDocumentAssertion const challenge = '1231231231'; const domain = 'www.adbv.com'; let hypersignSSISDK; @@ -272,7 +274,7 @@ describe('DID Test scenarios', () => { it('should not be able to add verificationMethod as params.did is passed but yet not registerd', async () => { const params = { did: 'did:hid:testnet:z8wo3LVRR4JkEguESX6hf4EBc234refrdan5xVD49quCPV7fBHYdY', - type: IKeyType.Ed25519VerificationKey2020, + type: VerificationMethodTypes.Ed25519VerificationKey2020, id: 'did:hid:testnet:z8wo3LVRR4JkEguESX6hf4EBc234refrdan5xVD49quCPV7fBHYdY#key-1', publicKeyMultibase: '23fer44374u3rmhvf47ri35ty', }; @@ -375,46 +377,45 @@ describe('DID Test scenarios', () => { }); }); - it('should be able to add verification method of type X25519KeyAgreementKey2020 in didDocument', async () => { - const params = { - didDocument: didDocument, - type: 'X25519KeyAgreementKey2020', - publicKeyMultibase: '23fer44374u3rmhvf47ri35ty', - }; - const didDoc = JSON.parse(JSON.stringify(didDocument)); - - const updatedDidDoc = await hypersignDID.addVerificationMethod({ ...params }); - expect(updatedDidDoc).to.be.a('object'); - should().exist(updatedDidDoc['context']); - should().exist(updatedDidDoc['id']); - should().exist(updatedDidDoc['controller']); - should().exist(updatedDidDoc['alsoKnownAs']); - should().exist(updatedDidDoc['verificationMethod']); - expect( - updatedDidDoc['verificationMethod'] && - updatedDidDoc['authentication'] && - updatedDidDoc['assertionMethod'] && - updatedDidDoc['keyAgreement'] && - updatedDidDoc['capabilityInvocation'] && - updatedDidDoc['capabilityDelegation'] && - updatedDidDoc['service'] - ).to.be.a('array'); - should().exist(updatedDidDoc['authentication']); - should().exist(updatedDidDoc['assertionMethod']); - expect(updatedDidDoc.verificationMethod.length).to.be.greaterThan(didDoc.verificationMethod.length); - }); + // it('should be able to add verification method of type X25519KeyAgreementKey2020 in didDocument', async () => { + // const params = { + // didDocument: didDocument, + // type: 'X25519KeyAgreementKey2020', + // publicKeyMultibase: '23fer44374u3rmhvf47ri35ty', + // }; + // const didDoc = JSON.parse(JSON.stringify(didDocument)); + // const updatedDidDoc = await hypersignDID.addVerificationMethod({ ...params }); + // expect(updatedDidDoc).to.be.a('object'); + // should().exist(updatedDidDoc['@context']); + // should().exist(updatedDidDoc['id']); + // should().exist(updatedDidDoc['controller']); + // should().exist(updatedDidDoc['alsoKnownAs']); + // should().exist(updatedDidDoc['verificationMethod']); + // expect( + // updatedDidDoc['verificationMethod'] && + // updatedDidDoc['authentication'] && + // updatedDidDoc['assertionMethod'] && + // updatedDidDoc['keyAgreement'] && + // updatedDidDoc['capabilityInvocation'] && + // updatedDidDoc['capabilityDelegation'] && + // updatedDidDoc['service'] + // ).to.be.a('array'); + // should().exist(updatedDidDoc['authentication']); + // should().exist(updatedDidDoc['assertionMethod']); + // expect(updatedDidDoc.verificationMethod.length).to.be.greaterThan(didDoc.verificationMethod.length); + // }); it('should be able to add verification method in didDocument without offlinesigner', async () => { const hypersignDid = new HypersignDID({ namespace: 'testnet' }); const didDoc = JSON.parse(JSON.stringify(didDocument)); const params = { didDocument: didDoc, - type: IKeyType.X25519KeyAgreementKey2020, + type: VerificationMethodTypes.X25519KeyAgreementKey2020, publicKeyMultibase: '23fer44374u3rmhvf47ri35ty', }; const testDidDoc = await hypersignDid.addVerificationMethod(params); expect(testDidDoc).to.be.a('object'); - should().exist(testDidDoc['context']); + should().exist(testDidDoc['@context']); should().exist(testDidDoc['id']); should().exist(testDidDoc['controller']); should().exist(testDidDoc['alsoKnownAs']); @@ -442,7 +443,7 @@ describe('DID Test scenarios', () => { DIdDOcWithMultiplVM = await hypersignDID.addVerificationMethod(params); expect(DIdDOcWithMultiplVM).to.be.a('object'); - should().exist(DIdDOcWithMultiplVM['context']); + should().exist(DIdDOcWithMultiplVM['@context']); should().exist(DIdDOcWithMultiplVM['id']); should().exist(DIdDOcWithMultiplVM['controller']); should().exist(DIdDOcWithMultiplVM['alsoKnownAs']); @@ -461,6 +462,59 @@ describe('DID Test scenarios', () => { expect(DIdDOcWithMultiplVM.verificationMethod.length).to.be.greaterThan(didDoc.verificationMethod.length); }); }); + describe('#createSignInfos() to generated sign array', function () { + it('should not able to create sign of did document and throw error as didDocument is not passed or it is empty', function () { + return hypersignDID + .createSignInfos({ didDocument: {}, privateKeyMultibase, verificationMethodId }) + .catch(function (err) { + expect(function () { + throw err; + }).to.throw(Error, 'HID-SSI-SDK:: Error: params.didDocument is required to create signature of a did'); + }); + }); + it('should not be able to create sign of did document as privateKeyMultibase is null or empty', function () { + return hypersignDID + .createSignInfos({ didDocument, privateKeyMultibase: '', verificationMethodId }) + .catch(function (err) { + expect(function () { + throw err; + }).to.throw(Error, 'HID-SSI-SDK:: Error: params.privateKeyMultibase is required to create signature of a did'); + }); + }); + it('should not be able to create sign of did document as verificationMethodId is null or empty', function () { + return hypersignDID + .createSignInfos({ didDocument, privateKeyMultibase, verificationMethodId: '' }) + .catch(function (err) { + expect(function () { + throw err; + }).to.throw(Error, 'HID-SSI-SDK:: Error: params.verificationMethodId is required to create signature of a did'); + }); + }); + it('should not be able to create sign of did document as didDocument is not in Ld-json format', function () { + const didDoc = JSON.parse(JSON.stringify(didDocument)) + didDoc.context = didDoc['@context'] + delete didDoc['@context'] + return hypersignDID + .createSignInfos({ didDocument: didDoc, privateKeyMultibase, verificationMethodId: verificationMethodId }) + .catch(function (err) { + expect(function () { + throw err; + }).to.throw(Error, 'HID-SSI-SDK:: Error: didDocument is not in Ld-json format'); + }); + }); + it('should be able to generate signature array', async () => { + const tempDidDoc = JSON.parse(JSON.stringify(didDocument)) + let signInfo = await hypersignDID.createSignInfos({ didDocument: tempDidDoc, privateKeyMultibase, verificationMethodId }) + expect(signInfo).to.be.a('array') + signInfo = signInfo[0] + should().exist(signInfo.signature); + expect(signInfo.signature).to.be.a("string") + should().exist(signInfo.verification_method_id); + expect(signInfo.verification_method_id).to.be.a("string") + should().exist(signInfo.created); + expect(signInfo.created).to.be.a("string") + }) + }); describe('#register() this is to register did on the blockchain', function () { it('should not able to register did document and throw error as didDocument is not passed or it is empty', function () { return hypersignDID @@ -489,6 +543,19 @@ describe('DID Test scenarios', () => { }).to.throw(Error, 'HID-SSI-SDK:: Error: params.verificationMethodId is required to register a did'); }); }); + it('should not be able to register did document as didDocument is not in Ld-json fromat', function () { + const didDoc = JSON.parse(JSON.stringify(didDocument)) + // const context = didDoc['@context'] + didDoc.context = didDoc['@context'] + delete didDoc['@context'] + return hypersignDID + .register({ didDocument: didDoc, privateKeyMultibase, verificationMethodId: verificationMethodId }) + .catch(function (err) { + expect(function () { + throw err; + }).to.throw(Error, 'HID-SSI-SDK:: Error: didDocument is not in Ld-json format'); + }); + }); it('should not be able to register a did document as neither privateKeyMultibase nor verificationMethodId is passed and signData passed is empty array', async () => { return hypersignDID.register({ didDocument, signData: [] }).catch(function (err) { expect(function () { @@ -506,6 +573,7 @@ describe('DID Test scenarios', () => { ); }); }); + it('should not be able to register a did document as privateKeyMultibase is not passed inside signData', async () => { return hypersignDID .register({ @@ -573,13 +641,13 @@ describe('DID Test scenarios', () => { // await hypersign.init(); // return hypersign.register({ didDocument, privateKeyMultibase, verificationMethodId }) // .catch(function (err) { - // console.log(err); // expect(function () { // throw err; // }).to.throw(Error, "HID-SSI-SDK:: Error: DIDRpc class is not initialise with offlinesigner"); // }); // }); - it('should be able to register didDocument in the blockchain with two vm one is of type Ed25519VerificationKey2020 and other is of type X25519KeyAgreementKey2020 and register method is called without signData field', async function () { + + it('should be able to register didDocument without signData field in the blockchain', async function () { const result = await hypersignDID.register({ didDocument, privateKeyMultibase, @@ -597,6 +665,21 @@ describe('DID Test scenarios', () => { transactionHash = result.transactionHash; should().exist(result.transactionHash); }); + it('should not be able to register didDocument as didDocument is already registered', async function () { + return await hypersignDID.register({ + didDocument, + privateKeyMultibase, + verificationMethodId, + }) + .catch(function (err) { + expect(function () { + throw err; + }).to.throw( + Error, + `failed to execute message; message index: 0: ${didDocId}: didDoc already exists` + ); + }); + }); it('should be able to register a did Doc of type Ed25519VerificationKey2020 with multiple verification method', async () => { const registerdDidDoc = await hypersignDID.register({ didDocument: DIdDOcWithMultiplVM, @@ -665,20 +748,36 @@ describe('DID Test scenarios', () => { }); it('should not be able to update did document as versionId passed is incorrect', function () { const updateBody = { didDocument, privateKeyMultibase, verificationMethodId, versionId: '1.0.1' }; - didDocument['alsoKnownAs'].push('Random Data'); + const didDoc = JSON.parse(JSON.stringify(didDocument)) + updateBody['didDocument'] = didDoc + updateBody['didDocument']['alsoKnownAs'].push('Random Data'); + return hypersignDID.update(updateBody).catch(function (err) { + expect(function () { + throw err; + }).to.throw( + Error, + `failed to execute message; message index: 0: Expected ${didDocId} with version ${versionId}. Got version ${updateBody.versionId}: unexpected DID version` + ); + }); + }); + it('should not be able to update did document as there is no change in didDoc', function () { + const updateBody = { didDocument, privateKeyMultibase, verificationMethodId, versionId }; + const didDoc = JSON.parse(JSON.stringify(didDocument)) + updateBody['didDocument'] = didDoc return hypersignDID.update(updateBody).catch(function (err) { expect(function () { throw err; }).to.throw( Error, - `Query failed with (6): rpc error: code = Unknown desc = failed to execute message; message index: 0: Expected ${didDocId} with version ${versionId}. Got version ${updateBody.versionId}: unexpected DID version` + `failed to execute message; message index: 0: incoming DID Document does not have any changes: didDoc is invalid` ); }); }); it('should be able to update did document', async function () { - didDocument['alsoKnownAs'].push('Some DATA'); + const didDoc = JSON.parse(JSON.stringify(didDocument)) + didDoc['alsoKnownAs'].push('Some DATA') const result = await hypersignDID.update({ - didDocument, + didDocument: didDoc, privateKeyMultibase, verificationMethodId, versionId, @@ -695,7 +794,6 @@ describe('DID Test scenarios', () => { expect(result).to.be.a('object'); expect(result.didDocument.id).to.be.equal(didDocId); expect(result.didDocumentMetadata).to.be.a('object'); - expect(result.didDocument.verificationMethod[0].publicKeyMultibase).to.be.not.equal(publicKeyMultibase); versionId = result.didDocumentMetadata.versionId; }); // should we able to get same publicKeyMultibase as generated in the begining in didDoc @@ -714,7 +812,6 @@ describe('DID Test scenarios', () => { it('should be able to resolve DID even without offline signer passed to the constructor; making resolve RPC offchain activity', async function () { const hypersignDID = new HypersignDID(); - const params = { did: didDocId, ed25519verificationkey2020: true, @@ -724,7 +821,6 @@ describe('DID Test scenarios', () => { expect(result).to.be.a('object'); expect(result.didDocument.id).to.be.equal(didDocId); expect(result.didDocumentMetadata).to.be.a('object'); - expect(result.didDocument.verificationMethod[0].publicKeyMultibase).to.be.equal(publicKeyMultibase); }); }); describe('#deactivate() this is to deactivate didDocument based on didDocId', function () { @@ -755,26 +851,42 @@ describe('DID Test scenarios', () => { }).to.throw(Error, 'HID-SSI-SDK:: Error: params.versionId is required to deactivate a did'); }); }); - it('should not be able to deactivate did document as versionId pased is incorrect', function () { - const deactivateBody = { didDocument, privateKeyMultibase, verificationMethodId, versionId: '1.0.1' }; + it('should not be able to deactivate did document as versionId passed is incorrect', function () { + const didDoc = JSON.parse(JSON.stringify(didDocument)) + const deactivateBody = { didDocument: didDoc, privateKeyMultibase, verificationMethodId, versionId: '1.0.1' }; return hypersignDID.deactivate(deactivateBody).catch(function (err) { expect(function () { throw err; }).to.throw( Error, - `Query failed with (6): rpc error: code = Unknown desc = failed to execute message; message index: 0: Expected ${didDocId} with version ${versionId}. Got version ${deactivateBody.versionId}: unexpected DID version` + `failed to execute message; message index: 0: Expected ${didDocId} with version ${versionId}. Got version ${deactivateBody.versionId}: unexpected DID version` ); }); }); + // add test case should not be able to deacivate a deactivated did it('should be able to deactivate did document', async function () { + const didDocTodeactivate = JSON.parse(JSON.stringify(didDocument)) const result = await hypersignDID.deactivate({ - didDocument, + didDocument: didDocTodeactivate, privateKeyMultibase, verificationMethodId, versionId, }); should().exist(result.transactionHash); }); + it('should not be able to deactivate did document as its already deactivated', async function () { + const didDocTodeactivate = JSON.parse(JSON.stringify(didDocument)) + return hypersignDID.deactivate({ + didDocument: didDocTodeactivate, + privateKeyMultibase, + verificationMethodId, + versionId, + }).catch(function (err) { + expect(function () { + throw err; + }).to.throw(Error, `failed to execute message; message index: 0: DID Document ${didDocId} is already deactivated: didDoc is deactivated`) + }) + }); }); describe('#sign() this is to sign didDoc', function () { @@ -844,24 +956,25 @@ describe('DID Test scenarios', () => { }).to.throw(Error, 'HID-SSI-SDK:: Error: params.domain is required to sign a did'); }); }); - it('should not able to sign did document and throw error as did is not resolved', function () { + it('should not able to sign did document and throw error as verificationMethodId is invalid or wrong', function () { const params = { privateKeyMultibase: privateKeyMultibase as string, challenge: challenge as string, domain: domain as string, - did: didDocId as string, + did: '', didDocument: didDocument as object, verificationMethodId: verificationMethodId as string, publicKey, controller, }; + params.verificationMethodId = ''; return hypersignDID.sign(params).catch(function (err) { expect(function () { throw err; - }).to.throw(Error, `HID-SSI-SDK:: Error: could not resolve did ${params.did}`); + }).to.throw(Error, 'HID-SSI-SDK:: Error: Incorrect verification method id'); }); }); - it('should not able to sign did document and throw error as verificationMethodId is invalid or wrong', function () { + it('should not able to sign did document and throw error as unsupported purpose is passed', function () { const params = { privateKeyMultibase: privateKeyMultibase as string, challenge: challenge as string, @@ -871,16 +984,45 @@ describe('DID Test scenarios', () => { verificationMethodId: verificationMethodId as string, publicKey, controller, + purpose: "random purpose" }; params.verificationMethodId = ''; return hypersignDID.sign(params).catch(function (err) { expect(function () { throw err; - }).to.throw(Error, 'HID-SSI-SDK:: Error: Incorrect verification method id'); + }).to.throw(Error, `HID-SSI-SDK:: Error: unsupported purpose ${params.purpose}`); }); }); - it('should able to sign did document', async function () { + it('should able to sign did document for didAuth using assertion purpose', async function () { + const tempDidDoc = JSON.parse(JSON.stringify(didDocument)) + const params = { + privateKeyMultibase: privateKeyMultibase as string, + challenge: challenge as string, + domain: domain as string, + did: '', // This is taken as empty as didDoc is yet not register on blockchain and won't able to resolve based on did + didDocument: tempDidDoc as object, + verificationMethodId: verificationMethodId as string, + controller, + purpose: 'assertionMethod' + }; + signedDocumentAssertion = await hypersignDID.sign(params); + expect(signedDocumentAssertion).to.be.a('object'); + should().exist(signedDocumentAssertion['@context']); + should().exist(signedDocumentAssertion['id']); + expect(didDocId).to.be.equal(signedDocumentAssertion['id']); + should().exist(signedDocumentAssertion['controller']); + should().exist(signedDocumentAssertion['alsoKnownAs']); + should().exist(signedDocumentAssertion['verificationMethod']); + should().exist(signedDocumentAssertion['authentication']); + should().exist(signedDocumentAssertion['assertionMethod']); + should().exist(signedDocumentAssertion['keyAgreement']); + should().exist(signedDocumentAssertion['capabilityInvocation']); + should().exist(signedDocumentAssertion['capabilityDelegation']); + should().exist(signedDocumentAssertion['service']); + should().exist(signedDocumentAssertion['proof']); + }); + it('should able to sign did document for didAuth using authentication purpose', async function () { const params = { privateKeyMultibase: privateKeyMultibase as string, challenge: challenge as string, @@ -926,8 +1068,16 @@ describe('DID Test scenarios', () => { }).to.throw(Error, 'HID-SSI-SDK:: Error: params.challenge is required to verify a did'); }); }); - - it('should return verification result', async function () { + it('should not able to verify did document and throw error as unsupported purpose is passed', function () { + return hypersignDID + .verify({ didDocument: signedDocument, verificationMethodId, challenge: '', domain, purpose: "random" }) + .catch(function (err) { + expect(function () { + throw err; + }).to.throw(Error, `HID-SSI-SDK:: Error: unsupported purpose random`); + }); + }); + it('should return verification result for didAuthentication', async function () { const result = await hypersignDID.verify({ didDocument: signedDocument, verificationMethodId, @@ -941,6 +1091,19 @@ describe('DID Test scenarios', () => { expect(result.results).to.be.a('array'); expect(result.verified).to.equal(true); }); + it('should return verification result for didAssertion', async function () { + const result = await hypersignDID.verify({ + didDocument: signedDocumentAssertion, + verificationMethodId, + purpose: "assertionMethod" + }); + expect(result).to.be.a('object'); + should().exist(result); + should().exist(result.verified); + should().exist(result.results); + expect(result.results).to.be.a('array'); + expect(result.verified).to.equal(true); + }); it('should not able to verify did document and throw error as unknown verification method id is passed', function () { const verMethIdMod = verificationMethodId + 'somerandomtext'; diff --git a/src/tests/did/didByEntityApiKey.spec.ts b/src/tests/did/didByEntityApiKey.spec.ts index 47c5169..d79e273 100644 --- a/src/tests/did/didByEntityApiKey.spec.ts +++ b/src/tests/did/didByEntityApiKey.spec.ts @@ -1,10 +1,7 @@ import { expect, should } from 'chai'; import { HypersignDID } from '../../index'; -import { createWallet, mnemonic, hidNodeEp } from '../config'; -// const entityApiSecretKey = -// '8fc3d16ce8f040fd2fc4e5ccc1d73.6b6e55d4d54cd90c85bbcc92d9469873e60c0d7878681223e2fe63fca3abafb63390f939a77b3d73bf2eb58a654810b38'; -const entityApiSecret = - "69b91e007904228e3313e586ba695.bc7705956989e43bbd7060e845c2763a381cbc80f935ac848119b8c2d7d00616346eeb74efe22a0ff140506a0c6157ef6" +import { createWallet, mnemonic, hidNodeEp, entityApiSecret } from '../config'; + // with local edv let offlineSigner; let hypersignDID; @@ -13,307 +10,308 @@ let publicKeyMultibase; let didDocument; let didDocId; let versionId; -let verificationMethodId +let verificationMethodId; beforeEach(async function () { - offlineSigner = await createWallet(mnemonic); + offlineSigner = await createWallet(mnemonic); + + const params = { + offlineSigner, + nodeRestEndpoint: hidNodeEp.rest, + nodeRpcEndpoint: hidNodeEp.rpc, + namespace: hidNodeEp.namespace, + }; + hypersignDID = new HypersignDID(params); + await hypersignDID.init(); +}); +describe('testing hypersignDid initiation', function () { + it('It should throw error as hypersignDid is neither init using offlineSigner nor using entityApiKey', async () => { const params = { - offlineSigner, - nodeRestEndpoint: hidNodeEp.rest, - nodeRpcEndpoint: hidNodeEp.rpc, - namespace: hidNodeEp.namespace, + nodeRestEndpoint: hidNodeEp.rest, + nodeRpcEndpoint: hidNodeEp.rpc, + namespace: hidNodeEp.namespace, }; - hypersignDID = new HypersignDID(params); - await hypersignDID.init(); + const hypersigndid = new HypersignDID(params); + return await hypersigndid.init().catch(function (err) { + expect(function () { + throw err; + }).to.throw(Error, 'HID-SSI-SDK:: Error: DIDRpc class is not initialise with offlinesigner'); + }); + }); }); - -describe("testing hypersignDid initiation", function () { - it('It should throw error as hypersignDid is neither init using offlineSigner nor using entityApiKey', async () => { - const params = { - nodeRestEndpoint: hidNodeEp.rest, - nodeRpcEndpoint: hidNodeEp.rpc, - namespace: hidNodeEp.namespace, - }; - const hypersigndid = new HypersignDID(params); - return await hypersigndid.init().catch(function (err) { - expect(function () { - throw err - }).to.throw(Error, 'HID-SSI-SDK:: Error: DIDRpc class is not initialise with offlinesigner') - }) - - }) -}) describe('DID Test Scenarios using entiAPiSecretKey', () => { - describe('#generateKeys() method to generate publicKyeMultibase and privateKeyMultiBase', function () { - it('should return publickeyMultibase and privateKeyMultibase', async function () { - const kp = await hypersignDID.generateKeys(); - privateKeyMultibase = kp.privateKeyMultibase; - publicKeyMultibase = kp.publicKeyMultibase; - expect(kp).to.be.a('object'); - should().exist(kp.privateKeyMultibase); - should().exist(kp.publicKeyMultibase); - should().not.exist(kp.id); - }); - }) - describe('#generate() to generate did', function () { - it('should not be able to generate did document and throw error as publicKeyMultibase passed is null or empty', function () { - return hypersignDID.generate({ publicKeyMultibase: '' }).catch(function (err) { - expect(function () { - throw err; - }).to.throw(Error, 'HID-SSI-SDK:: Error: params.publicKeyMultibase is required to generate new did didoc'); - }); - - }); - it('should be able to generate didDocument', async function () { - didDocument = await hypersignDID.generate({ publicKeyMultibase }); - didDocId = didDocument['id']; - verificationMethodId = didDocument['verificationMethod'][0].id; - expect(didDocument).to.be.a('object'); - should().exist(didDocument['@context']); - should().exist(didDocument['id']); - should().exist(didDocument['controller']); - should().exist(didDocument['alsoKnownAs']); - should().exist(didDocument['verificationMethod']); - expect( - didDocument['verificationMethod'] && - didDocument['authentication'] && - didDocument['assertionMethod'] && - didDocument['keyAgreement'] && - didDocument['capabilityInvocation'] && - didDocument['capabilityDelegation'] && - didDocument['service'] - ).to.be.a('array'); - expect(didDocument['keyAgreement'].length).to.be.equal(0) - should().exist(didDocument['authentication']); - should().exist(didDocument['assertionMethod']); - should().exist(didDocument['keyAgreement']); - should().exist(didDocument['capabilityInvocation']); - should().exist(didDocument['capabilityDelegation']); - should().exist(didDocument['service']); - }); - }) + describe('#generateKeys() method to generate publicKyeMultibase and privateKeyMultiBase', function () { + it('should return publickeyMultibase and privateKeyMultibase', async function () { + const kp = await hypersignDID.generateKeys(); + privateKeyMultibase = kp.privateKeyMultibase; + publicKeyMultibase = kp.publicKeyMultibase; + expect(kp).to.be.a('object'); + should().exist(kp.privateKeyMultibase); + should().exist(kp.publicKeyMultibase); + should().not.exist(kp.id); + }); + }); + describe('#generate() to generate did', function () { + it('should not be able to generate did document and throw error as publicKeyMultibase passed is null or empty', function () { + return hypersignDID.generate({ publicKeyMultibase: '' }).catch(function (err) { + expect(function () { + throw err; + }).to.throw(Error, 'HID-SSI-SDK:: Error: params.publicKeyMultibase is required to generate new did didoc'); + }); + }); + it('should be able to generate didDocument', async function () { + didDocument = await hypersignDID.generate({ publicKeyMultibase }); + didDocId = didDocument['id']; + verificationMethodId = didDocument['verificationMethod'][0].id; + expect(didDocument).to.be.a('object'); + should().exist(didDocument['@context']); + should().exist(didDocument['id']); + should().exist(didDocument['controller']); + should().exist(didDocument['alsoKnownAs']); + should().exist(didDocument['verificationMethod']); + expect( + didDocument['verificationMethod'] && + didDocument['authentication'] && + didDocument['assertionMethod'] && + didDocument['keyAgreement'] && + didDocument['capabilityInvocation'] && + didDocument['capabilityDelegation'] && + didDocument['service'] + ).to.be.a('array'); + expect(didDocument['keyAgreement'].length).to.be.equal(0); + should().exist(didDocument['authentication']); + should().exist(didDocument['assertionMethod']); + should().exist(didDocument['keyAgreement']); + should().exist(didDocument['capabilityInvocation']); + should().exist(didDocument['capabilityDelegation']); + should().exist(didDocument['service']); + }); + }); - describe('#register() to register did on chain', function () { - it('should not be able to initialize HypersignDID with entityApiSecretKey as entityApiSecretKey is invalid', async () => { - const HypersignDid = new HypersignDID({ - entityApiSecretKey: "entityApiSecretKey", - nodeRestEndpoint: hidNodeEp.rest, - nodeRpcEndpoint: hidNodeEp.rpc, - namespace: hidNodeEp.namespace, - }) - try { - await HypersignDid.init(); - expect.fail("Expected an error but initialization succeeded"); - } catch (error: any) { - expect(error.message).to.equal("HID-SSI-SDK:: access_denied"); - } - - }); - it('should not able to register did document and throw error as didDocument is not passed or it is empty', async () => { - return hypersignDID - .register({ didDocument: {}, privateKeyMultibase, verificationMethodId }) - .catch(function (err) { - expect(function () { - throw err; - }).to.throw(Error, 'HID-SSI-SDK:: Error: params.didDocString is required to register a did'); - }); - }); - it('should not be able to register did document as privateKeyMultibase is null or empty', function () { - return hypersignDID - .register({ didDocument, privateKeyMultibase: '', verificationMethodId }) - .catch(function (err) { - expect(function () { - throw err; - }).to.throw(Error, 'HID-SSI-SDK:: Error: params.privateKeyMultibase is required to register a did'); - }); - }); - it('should not be able to register a did document as neither privateKeyMultibase nor verificationMethodId is passed and signData passed is empty array', async () => { - return hypersignDID.register({ didDocument, signData: [] }).catch(function (err) { - expect(function () { - throw err; - }).to.throw(Error, 'HID-SSI-SDK:: Error: params.signInfos must be a non empty array'); - }); + describe('#register() to register did on chain', function () { + it('should not be able to initialize HypersignDID with entityApiSecretKey as entityApiSecretKey is invalid', async () => { + const HypersignDid = new HypersignDID({ + entityApiSecretKey: 'entityApiSecretKey', + nodeRestEndpoint: hidNodeEp.rest, + nodeRpcEndpoint: hidNodeEp.rpc, + namespace: hidNodeEp.namespace, + }); + try { + await HypersignDid.init(); + expect.fail('Expected an error but initialization succeeded'); + } catch (error: any) { + expect(error.message).to.equal('HID-SSI-SDK:: access_denied'); + } + }); + it('should not able to register did document and throw error as didDocument is not passed or it is empty', async () => { + return hypersignDID + .register({ didDocument: {}, privateKeyMultibase, verificationMethodId }) + .catch(function (err) { + expect(function () { + throw err; + }).to.throw(Error, 'HID-SSI-SDK:: Error: params.didDocString is required to register a did'); }); - it('should be able to registr did using entityApiSecret', async () => { - const HypersignDid = new HypersignDID({ - entityApiSecretKey: entityApiSecret, - nodeRestEndpoint: hidNodeEp.rest, - nodeRpcEndpoint: hidNodeEp.rpc, - namespace: hidNodeEp.namespace, - }) - await HypersignDid.init() - const registerdDid = await hypersignDID.register({ - didDocument, - privateKeyMultibase, - verificationMethodId, - }) - should().exist(registerdDid.didDocument); - should().exist(registerdDid.transactionHash); - - }) - }) - describe('#resolve() to resove did using ', function () { - it('should not able to resolve did document and throw error didDocId is not passed', function () { - return hypersignDID.resolve({ params: { did: '' } }).catch(function (err) { - expect(function () { - throw err; - }).to.throw(Error, 'HID-SSI-SDK:: Error: params.did is required to resolve a did'); - }); + }); + it('should not be able to register did document as privateKeyMultibase is null or empty', function () { + return hypersignDID + .register({ didDocument, privateKeyMultibase: '', verificationMethodId }) + .catch(function (err) { + expect(function () { + throw err; + }).to.throw(Error, 'HID-SSI-SDK:: Error: params.privateKeyMultibase is required to register a did'); }); - it('Should be able to resolve did using entityApiSecret', async () => { - const params = { - did: didDocId - } - const HypersignDid = new HypersignDID({ - entityApiSecretKey: entityApiSecret, - nodeRestEndpoint: hidNodeEp.rest, - nodeRpcEndpoint: hidNodeEp.rpc, - namespace: hidNodeEp.namespace, - }) - await HypersignDid.init() - const result = await HypersignDid.resolve(params) - expect(result).to.be.a('object'); - expect(result.didDocument.id).to.be.equal(didDocId); - expect(result.didDocumentMetadata).to.be.a('object'); - versionId = result.didDocumentMetadata.versionId; - }) - }) + }); + it('should not be able to register a did document as neither privateKeyMultibase nor verificationMethodId is passed and signData passed is empty array', async () => { + return hypersignDID.register({ didDocument, signData: [] }).catch(function (err) { + expect(function () { + throw err; + }).to.throw(Error, 'HID-SSI-SDK:: Error: params.signInfos must be a non empty array'); + }); + }); + it('should be able to registr did using entityApiSecret', async () => { + const HypersignDid = new HypersignDID({ + entityApiSecretKey: entityApiSecret, + nodeRestEndpoint: hidNodeEp.rest, + nodeRpcEndpoint: hidNodeEp.rpc, + namespace: hidNodeEp.namespace, + }); + await HypersignDid.init(); + const registerdDid = await hypersignDID.register({ + didDocument, + privateKeyMultibase, + verificationMethodId, + }); + should().exist(registerdDid.didDocument); + should().exist(registerdDid.transactionHash); + }); + }); + describe('#resolve() to resove did using ', function () { + it('should not able to resolve did document and throw error didDocId is not passed', function () { + return hypersignDID.resolve({ params: { did: '' } }).catch(function (err) { + expect(function () { + throw err; + }).to.throw(Error, 'HID-SSI-SDK:: Error: params.did is required to resolve a did'); + }); + }); + it('Should be able to resolve did using entityApiSecret', async () => { + const params = { + did: didDocId, + }; + const HypersignDid = new HypersignDID({ + entityApiSecretKey: entityApiSecret, + nodeRestEndpoint: hidNodeEp.rest, + nodeRpcEndpoint: hidNodeEp.rpc, + namespace: hidNodeEp.namespace, + }); + await HypersignDid.init(); + const result = await HypersignDid.resolve(params); + expect(result).to.be.a('object'); + expect(result.didDocument.id).to.be.equal(didDocId); + expect(result.didDocumentMetadata).to.be.a('object'); + versionId = result.didDocumentMetadata.versionId; + }); + }); - describe('#update() this is to update didDocument', function () { - it('should not be able to update did document using entityApiKey as privateKeyMultibase is null or empty', function () { - return hypersignDID - .update({ didDocument, privateKeyMultibase: '', verificationMethodId, versionId: '1.0' }) - .catch(function (err) { - expect(function () { - throw err; - }).to.throw(Error, 'HID-SSI-SDK:: Error: params.privateKeyMultibase is required to update a did'); - }); + describe('#update() this is to update didDocument', function () { + it('should not be able to update did document using entityApiKey as privateKeyMultibase is null or empty', function () { + return hypersignDID + .update({ didDocument, privateKeyMultibase: '', verificationMethodId, versionId: '1.0' }) + .catch(function (err) { + expect(function () { + throw err; + }).to.throw(Error, 'HID-SSI-SDK:: Error: params.privateKeyMultibase is required to update a did'); }); - it('should not be able to update did document using entityApiKey as verificationMethodId is null or empty', function () { - return hypersignDID - .update({ didDocument, privateKeyMultibase, verificationMethodId: '', versionId: '1.0' }) - .catch(function (err) { - expect(function () { - throw err; - }).to.throw(Error, 'HID-SSI-SDK:: Error: params.verificationMethodId is required to update a did'); - }); + }); + it('should not be able to update did document using entityApiKey as verificationMethodId is null or empty', function () { + return hypersignDID + .update({ didDocument, privateKeyMultibase, verificationMethodId: '', versionId: '1.0' }) + .catch(function (err) { + expect(function () { + throw err; + }).to.throw(Error, 'HID-SSI-SDK:: Error: params.verificationMethodId is required to update a did'); }); - it('should not be able to update did document using entityApiKey as versionId is null or empty', function () { - return hypersignDID - .update({ didDocument, privateKeyMultibase, verificationMethodId, versionId: '' }) - .catch(function (err) { - expect(function () { - throw err; - }).to.throw(Error, 'HID-SSI-SDK:: Error: params.versionId is required to update a did'); - }); + }); + it('should not be able to update did document using entityApiKey as versionId is null or empty', function () { + return hypersignDID + .update({ didDocument, privateKeyMultibase, verificationMethodId, versionId: '' }) + .catch(function (err) { + expect(function () { + throw err; + }).to.throw(Error, 'HID-SSI-SDK:: Error: params.versionId is required to update a did'); }); - it('should be able to update did document using entityApiSecret', async () => { - const HypersignDid = new HypersignDID({ - entityApiSecretKey: entityApiSecret, - nodeRestEndpoint: hidNodeEp.rest, - nodeRpcEndpoint: hidNodeEp.rpc, - namespace: hidNodeEp.namespace, - }) - await HypersignDid.init() - didDocument['alsoKnownAs'].push('Varsha'); - - const result = await HypersignDid.update({ - didDocument, - privateKeyMultibase, - verificationMethodId, - versionId, - }) - should().exist(result.transactionHash); + }); + it('should be able to update did document using entityApiSecret', async () => { + const HypersignDid = new HypersignDID({ + entityApiSecretKey: entityApiSecret, + nodeRestEndpoint: hidNodeEp.rest, + nodeRpcEndpoint: hidNodeEp.rpc, + namespace: hidNodeEp.namespace, + }); + await HypersignDid.init(); + didDocument['alsoKnownAs'].push('Varsha'); - }) - }) - describe('#resolve() did ater updating did document', function () { - it('Should be able to resolve did', async function () { - const params = { - did: didDocId, - }; - const result = await hypersignDID.resolve(params); - expect(result).to.be.a('object'); - expect(result.didDocument.id).to.be.equal(didDocId); - expect(result.didDocumentMetadata).to.be.a('object'); - expect(result.didDocument.verificationMethod[0].publicKeyMultibase).to.be.not.equal(publicKeyMultibase); - versionId = result.didDocumentMetadata.versionId; - }) - }) + const result = await HypersignDid.update({ + didDocument, + privateKeyMultibase, + verificationMethodId, + versionId, + }); + should().exist(result); + }); + }); + describe('#resolve() did ater updating did document', function () { + it('Should be able to resolve did', async function () { + const params = { + did: didDocId, + }; + const result = await hypersignDID.resolve(params); + expect(result).to.be.a('object'); + expect(result.didDocument.id).to.be.equal(didDocId); + expect(result.didDocumentMetadata).to.be.a('object'); + expect(result.didDocument.verificationMethod[0].publicKeyMultibase).to.be.not.equal(publicKeyMultibase); + versionId = result.didDocumentMetadata.versionId; + }); + }); - describe('#deactivate() this is to deactivate didDocument', function () { - it('should not be able to deactivate did document using entityApiSecretKey as privateKeyMultibase is null or empty', async () => { - const HypersignDid = new HypersignDID({ - entityApiSecretKey: entityApiSecret, - nodeRestEndpoint: hidNodeEp.rest, - nodeRpcEndpoint: hidNodeEp.rpc, - namespace: hidNodeEp.namespace, - }) - await HypersignDid.init() - return HypersignDid - .deactivate({ didDocument, privateKeyMultibase: '', verificationMethodId, versionId: '1.0' }) - .catch(function (err) { - expect(function () { - throw err; - }).to.throw(Error, 'HID-SSI-SDK:: Error: params.privateKeyMultibase is required to deactivate a did'); - }); - }); - it('should not be able to deactivate did document as verificationMethodId is null or empty', async function () { - const HypersignDid = new HypersignDID({ - entityApiSecretKey: entityApiSecret, - nodeRestEndpoint: hidNodeEp.rest, - nodeRpcEndpoint: hidNodeEp.rpc, - namespace: hidNodeEp.namespace, - }) - await HypersignDid.init() - return HypersignDid - .deactivate({ didDocument, privateKeyMultibase, verificationMethodId: '', versionId: '1.0' }) - .catch(function (err) { - expect(function () { - throw err; - }).to.throw(Error, 'HID-SSI-SDK:: Error: params.verificationMethodId is required to deactivate a did'); - }); - }); - it('should not be able to deactivate did document as versionId is null or empty', function () { - return hypersignDID - .deactivate({ didDocument, privateKeyMultibase, verificationMethodId, versionId: '' }) - .catch(function (err) { - expect(function () { - throw err; - }).to.throw(Error, 'HID-SSI-SDK:: Error: params.versionId is required to deactivate a did'); - }); + describe('#deactivate() this is to deactivate didDocument', function () { + it('should not be able to deactivate did document using entityApiSecretKey as privateKeyMultibase is null or empty', async () => { + const HypersignDid = new HypersignDID({ + entityApiSecretKey: entityApiSecret, + nodeRestEndpoint: hidNodeEp.rest, + nodeRpcEndpoint: hidNodeEp.rpc, + namespace: hidNodeEp.namespace, + }); + await HypersignDid.init(); + return HypersignDid.deactivate({ + didDocument, + privateKeyMultibase: '', + verificationMethodId, + versionId: '1.0', + }).catch(function (err) { + expect(function () { + throw err; + }).to.throw(Error, 'HID-SSI-SDK:: Error: params.privateKeyMultibase is required to deactivate a did'); + }); + }); + it('should not be able to deactivate did document as verificationMethodId is null or empty', async function () { + const HypersignDid = new HypersignDID({ + entityApiSecretKey: entityApiSecret, + nodeRestEndpoint: hidNodeEp.rest, + nodeRpcEndpoint: hidNodeEp.rpc, + namespace: hidNodeEp.namespace, + }); + await HypersignDid.init(); + return HypersignDid.deactivate({ + didDocument, + privateKeyMultibase, + verificationMethodId: '', + versionId: '1.0', + }).catch(function (err) { + expect(function () { + throw err; + }).to.throw(Error, 'HID-SSI-SDK:: Error: params.verificationMethodId is required to deactivate a did'); + }); + }); + it('should not be able to deactivate did document as versionId is null or empty', function () { + return hypersignDID + .deactivate({ didDocument, privateKeyMultibase, verificationMethodId, versionId: '' }) + .catch(function (err) { + expect(function () { + throw err; + }).to.throw(Error, 'HID-SSI-SDK:: Error: params.versionId is required to deactivate a did'); }); - it('Should be able to deactivate did document using entityApiSecretKey', async () => { - const HypersignDid = new HypersignDID({ - entityApiSecretKey: entityApiSecret, - nodeRestEndpoint: hidNodeEp.rest, - nodeRpcEndpoint: hidNodeEp.rpc, - namespace: hidNodeEp.namespace, - }) - await HypersignDid.init() - const result = await HypersignDid.deactivate({ - didDocument, - privateKeyMultibase, - verificationMethodId, - versionId, - }); - should().exist(result.transactionHash); - }) - it('Should be able to resolve deactivated did and get deactivated as true in didDoc', async () => { - const params = { - did: didDocId - } - const HypersignDid = new HypersignDID({ - entityApiSecretKey: entityApiSecret, - nodeRestEndpoint: hidNodeEp.rest, - nodeRpcEndpoint: hidNodeEp.rpc, - namespace: hidNodeEp.namespace, - }) - await HypersignDid.init() - const result = await HypersignDid.resolve(params) - should().exist(result.didDocument); - should().exist(result.didDocumentMetadata); - expect(result.didDocumentMetadata.deactivated).to.equal(true) - }) - }) -}) \ No newline at end of file + }); + it('Should be able to deactivate did document using entityApiSecretKey', async () => { + const HypersignDid = new HypersignDID({ + entityApiSecretKey: entityApiSecret, + nodeRestEndpoint: hidNodeEp.rest, + nodeRpcEndpoint: hidNodeEp.rpc, + namespace: hidNodeEp.namespace, + }); + await HypersignDid.init(); + const result = await HypersignDid.deactivate({ + didDocument, + privateKeyMultibase, + verificationMethodId, + versionId, + }); + should().exist(result.transactionHash); + }); + it('Should be able to resolve deactivated did and get deactivated as true in didDoc', async () => { + const params = { + did: didDocId, + }; + const HypersignDid = new HypersignDID({ + entityApiSecretKey: entityApiSecret, + nodeRestEndpoint: hidNodeEp.rest, + nodeRpcEndpoint: hidNodeEp.rpc, + namespace: hidNodeEp.namespace, + }); + await HypersignDid.init(); + const result = await HypersignDid.resolve(params); + should().exist(result.didDocument); + should().exist(result.didDocumentMetadata); + expect(result.didDocumentMetadata.deactivated).to.equal(true); + }); + }); +}); diff --git a/src/tests/did/didByclientSpec.spec.ts b/src/tests/did/didByclientSpec.spec.ts index c3c9dbc..6dbaa87 100644 --- a/src/tests/did/didByclientSpec.spec.ts +++ b/src/tests/did/didByclientSpec.spec.ts @@ -7,7 +7,7 @@ import { createWallet, mnemonic, hidNodeEp } from '../config'; import * as bip39 from 'bip39'; let hypersignDID; -let MMWalletAddress; +const MMWalletAddress = "0x4457bCb9351c5677f892F9d8Be75493B8F7A7932"; let MMPrivateKey; let MMPublicKey; let offlineSigner; @@ -31,14 +31,12 @@ async function generateSignature() { const wallet = await HDNodeWallet.fromMnemonic(Mnemonics, `m/44'/60'/0'/0/${0}`); const web3 = new Web3(); const account = await web3.eth.accounts.privateKeyToAccount(wallet.privateKey); - MMWalletAddress = account.address; + // MMWalletAddress = account.address; MMPrivateKey = wallet.privateKey; MMPublicKey = wallet.publicKey; } describe('DID Test scenarion for clientSpec', () => { - describe('#createByClientSpec() this is to generate did using clientSpec', function () { - const param = { methodSpecificId: "xyz", address: "xyz", @@ -214,38 +212,69 @@ describe('DID Test scenarion for clientSpec', () => { }).to.throw(Error, 'HID-SSI-SDK:: Error: params.web3 is required to sign') }) }) - it('should not be able to generate signature as clientSpec passed is of type "cosmos-ADR036" but chainId is not passed', async () => { + it('should not be able to generate signature as verificationMethodId is not passed', async () => { const web3 = new Web3(metamaskProvider) const params = { didDocument: didDocumentByClientspec, address: MMWalletAddress, web3, - clientSpec: "cosmos-ADR036" + clientSpec: "eth-personalSign" } + return hypersignDID.signByClientSpec(params).catch(function (err) { + expect(function () { + throw err; + }).to.throw(Error, 'HID-SSI-SDK:: Error: params.verificationMethodId is required to sign') + }) + }) + it('should not be able to generate signature as verificationMethodId passed is invalid or not presnet in didDoc', async () => { + const web3 = new Web3(metamaskProvider) + const params = { + didDocument: didDocumentByClientspec, + address: MMWalletAddress, + web3, + clientSpec: "eth-personalSign", + verificationMethodId: didDocumentByClientspec.id + "e#key-1", + + } + return hypersignDID.signByClientSpec(params).catch(function (err) { + expect(function () { + throw err; + }).to.throw(Error, "HID-SSI_SDK:: Error: invalid verificationMethodId") + }) + }) + + it('should not be able to generate signature as clientSpec passed is of type "cosmos-ADR036" but chainId is not passed', async () => { + const web3 = new Web3(metamaskProvider) + const params = { + didDocument: didDocumentByClientspec, + address: MMWalletAddress, + web3, + verificationMethodId: didDocumentByClientspec.verificationMethod[0].id, + clientSpec: "cosmos-ADR036" + } return hypersignDID.signByClientSpec(params).catch(function (err) { expect(function () { throw err; }).to.throw(Error, `HID-SSI-SDK:: Error: params.chainId is required to sign for clientSpec ${params.clientSpec} and keyType EcdsaSecp256k1VerificationKey2019`) }) }) - // it('Should be able to generate signature for didDoc', async()=>{ - // const web3= new Web3(metamaskProvider) - // console.log(web3.eth.personal.sign) - // const params={ - // didDocument:didDocumentByClientspec, - // address:MMWalletAddress, - // clientSpec:"eth-personalSign", - // web3:web3 - // } - // const signedDidDocByClientSpec= await hypersignDID.signByClientSpec(params) - // console.log(signedDidDocByClientSpec) + // it('Should be able to generate signature for didDoc', async () => { + // const web3 = new Web3(metamaskProvider) + // const params = { + // didDocument: didDocumentByClientspec, + // address: MMWalletAddress,//"0x4457bCb9351c5677f892F9d8Be75493B8F7A7932", + // clientSpec: "eth-personalSign", + // web3: web3, + // verificationMethodId: didDocumentByClientspec.verificationMethod[0].id, - // // error Cannot read properties of undefined (reading 'eth') + // } + // const signedDidDocByClientSpec = await hypersignDID.signByClientSpec(params) + + // // error Cannot read properties of undefined (reading 'eth') // }) }) - describe("#registerByClientSpec() this is to register did generated using clientspec on the blockchain", function () { const signInfo = [{ verification_method_id: "", @@ -662,7 +691,7 @@ describe('DID Test scenarion for clientSpec', () => { expect(function () { throw err; }).to.throw(Error, - `HID-SSI-SDK:: Error: params.signInfos[${0}].adr036SignerAddress is required to deactivate a did, when clientSpec type is${params.signInfos[0].clientSpec?.type} ` + `HID-SSI-SDK:: Error: params.signInfos[${0}].adr036SignerAddress is required to deactivate a did, when clientSpec type is${params.signInfos[0].clientSpec?.type}` ) }) }) diff --git a/src/tests/did/did_keyagreement.spec.ts b/src/tests/did/did_keyagreement.spec.ts new file mode 100644 index 0000000..56710df --- /dev/null +++ b/src/tests/did/did_keyagreement.spec.ts @@ -0,0 +1,314 @@ +import { expect, should } from 'chai'; +import { HypersignDID } from '../../index'; + +import { createWallet, mnemonic, hidNodeEp } from '../config'; +let privateKeyMultibase; +let publicKeyMultibase; +let verificationMethodId; +let didDocument; +let didDocId; +let offlineSigner; +let versionId; +let hypersignDID; +let transactionHash +beforeEach(async function () { + offlineSigner = await createWallet(mnemonic); + const params = { + offlineSigner, + nodeRestEndpoint: hidNodeEp.rest, + nodeRpcEndpoint: hidNodeEp.rpc, + namespace: hidNodeEp.namespace, + }; + hypersignDID = new HypersignDID(params); + await hypersignDID.init(); +}) +describe('DID Test scenarios for keyagreement type', () => { + describe('DID Test scenarios for keyType X25519KeyAgreementKey2020', () => { + + describe('#generateKeys() method to generate publicKyeMultibase and privateKeyMultiBase', function () { + it('should return publickeyMultibase and privateKeyMultibase', async function () { + const kp = await hypersignDID.generateKeys(); + privateKeyMultibase = kp.privateKeyMultibase; + publicKeyMultibase = kp.publicKeyMultibase; + expect(kp).to.be.a('object'); + should().exist(kp.privateKeyMultibase); + should().exist(kp.publicKeyMultibase); + should().not.exist(kp.id); + }); + }); + + + describe('#generate() to generate did', function () { + it('should not be able to generate did document and throw error as publicKeyMultibase passed is null or empty', function () { + return hypersignDID.generate({ publicKeyMultibase: '' }).catch(function (err) { + expect(function () { + throw err; + }).to.throw(Error, 'HID-SSI-SDK:: Error: params.publicKeyMultibase is required to generate new did didoc'); + }); + }); + + it('should be able to generate didDocument with ed25519 key', async function () { + didDocument = await hypersignDID.generate({ publicKeyMultibase }); + didDocId = didDocument['id']; + verificationMethodId = didDocument['verificationMethod'][0].id; + expect(didDocument).to.be.a('object'); + should().exist(didDocument['@context']); + should().exist(didDocument['id']); + should().exist(didDocument['controller']); + should().exist(didDocument['alsoKnownAs']); + should().exist(didDocument['verificationMethod']); + expect( + didDocument['verificationMethod'] && + didDocument['authentication'] && + didDocument['assertionMethod'] && + didDocument['keyAgreement'] && + didDocument['capabilityInvocation'] && + didDocument['capabilityDelegation'] && + didDocument['service'] + ).to.be.a('array'); + should().exist(didDocument['authentication']); + should().exist(didDocument['assertionMethod']); + should().exist(didDocument['keyAgreement']); + should().exist(didDocument['capabilityInvocation']); + should().exist(didDocument['capabilityDelegation']); + should().exist(didDocument['service']); + }); + + }); + // adding keyagreement type as vm + describe('#addVerificationMethod() to add verificationMethod in didDocument', function () { + it('should be able to add verification method of type X25519KeyAgreementKey2020 in didDocument', async () => { + const params = { + didDocument: didDocument, + type: 'X25519KeyAgreementKey2020', + publicKeyMultibase: '23fer44374u3rmhvf47ri35ty', + }; + const didDoc = JSON.parse(JSON.stringify(didDocument)); + const updatedDidDoc = await hypersignDID.addVerificationMethod({ ...params }); + expect(updatedDidDoc).to.be.a('object'); + should().exist(updatedDidDoc['@context']); + should().exist(updatedDidDoc['id']); + should().exist(updatedDidDoc['controller']); + should().exist(updatedDidDoc['alsoKnownAs']); + should().exist(updatedDidDoc['verificationMethod']); + expect( + updatedDidDoc['verificationMethod'] && + updatedDidDoc['authentication'] && + updatedDidDoc['assertionMethod'] && + updatedDidDoc['keyAgreement'] && + updatedDidDoc['capabilityInvocation'] && + updatedDidDoc['capabilityDelegation'] && + updatedDidDoc['service'] + ).to.be.a('array'); + should().exist(updatedDidDoc['authentication']); + should().exist(updatedDidDoc['assertionMethod']); + expect(updatedDidDoc.verificationMethod.length).to.be.greaterThan(didDoc.verificationMethod.length); + }); + }); + describe('#register() this is to register did on the blockchain', function () { + it('should be able to register didDocument in the blockchain with two vm one is of type Ed25519VerificationKey2020 and other is of type X25519KeyAgreementKey2020 and register method is called without signData field', async function () { + const result = await hypersignDID.register({ + didDocument, + privateKeyMultibase, + verificationMethodId + }); + transactionHash = result.transactionHash; + should().exist(result.transactionHash); + }); + }); + describe('#resolve() this is to resolve didDocument based on didDocId', function () { + it('should be able to resolve did', async function () { + const params = { + did: didDocId, + }; + const result = await hypersignDID.resolve(params); + expect(result).to.be.a('object'); + expect(result.didDocument.id).to.be.equal(didDocId); + expect(result.didDocumentMetadata).to.be.a('object'); + versionId = result.didDocumentMetadata.versionId; + }); + }); + describe('#update() this is to update didDocument based on didDocId', function () { + it('should be able to update did document with key type X25519KeyAgreementKey2020', async function () { + const didDoc = JSON.parse(JSON.stringify(didDocument)) + didDoc['alsoKnownAs'].push('Some DATA'); + const result = await hypersignDID.update({ + didDocument: didDoc, + privateKeyMultibase, + verificationMethodId, + versionId, + }); + should().exist(result.transactionHash); + }); + }); + describe('#resolve() did after updating did document', function () { + it('should be able to resolve did', async function () { + const params = { + did: didDocId, + }; + const result = await hypersignDID.resolve(params); + expect(result).to.be.a('object'); + expect(result.didDocument.id).to.be.equal(didDocId); + expect(result.didDocumentMetadata).to.be.a('object'); + versionId = result.didDocumentMetadata.versionId; + }); + + }); + + describe('#deactivate() this is to deactivate didDocument based on didDocId', function () { + it('should be able to deactivate did document with key type X25519KeyAgreementKey2020', async function () { + const didDocTodeactivate = JSON.parse(JSON.stringify(didDocument)) + const result = await hypersignDID.deactivate({ + didDocument: didDocTodeactivate, + privateKeyMultibase, + verificationMethodId, + versionId, + }); + should().exist(result.transactionHash); + }); + }); + }) + describe('DID Test scenarios for keyType X25519KeyAgreementKeyEIP5630', () => { + describe('#generateKeys() method to generate publicKyeMultibase and privateKeyMultiBase', function () { + it('should return publickeyMultibase and privateKeyMultibase', async function () { + const kp = await hypersignDID.generateKeys(); + privateKeyMultibase = kp.privateKeyMultibase; + publicKeyMultibase = kp.publicKeyMultibase; + expect(kp).to.be.a('object'); + should().exist(kp.privateKeyMultibase); + should().exist(kp.publicKeyMultibase); + should().not.exist(kp.id); + }); + }); + + + describe('#generate() to generate did', function () { + it('should not be able to generate did document and throw error as publicKeyMultibase passed is null or empty', function () { + return hypersignDID.generate({ publicKeyMultibase: '' }).catch(function (err) { + expect(function () { + throw err; + }).to.throw(Error, 'HID-SSI-SDK:: Error: params.publicKeyMultibase is required to generate new did didoc'); + }); + }); + it('should be able to generate didDocument with ed25519 key', async function () { + didDocument = await hypersignDID.generate({ publicKeyMultibase }); + didDocId = didDocument['id']; + verificationMethodId = didDocument['verificationMethod'][0].id; + expect(didDocument).to.be.a('object'); + should().exist(didDocument['@context']); + should().exist(didDocument['id']); + should().exist(didDocument['controller']); + should().exist(didDocument['alsoKnownAs']); + should().exist(didDocument['verificationMethod']); + expect( + didDocument['verificationMethod'] && + didDocument['authentication'] && + didDocument['assertionMethod'] && + didDocument['keyAgreement'] && + didDocument['capabilityInvocation'] && + didDocument['capabilityDelegation'] && + didDocument['service'] + ).to.be.a('array'); + should().exist(didDocument['authentication']); + should().exist(didDocument['assertionMethod']); + should().exist(didDocument['keyAgreement']); + should().exist(didDocument['capabilityInvocation']); + should().exist(didDocument['capabilityDelegation']); + should().exist(didDocument['service']); + }); + + }); + // adding keyagreement type as vm + describe('#addVerificationMethod() to add verificationMethod in didDocument', function () { + it('should be able to add verification method of type X25519KeyAgreementKeyEIP5630 in didDocument', async () => { + const params = { + didDocument: didDocument, + type: 'X25519KeyAgreementKeyEIP5630', + publicKeyMultibase: '23fer44374u3rmhvf47ri35ty1', + }; + const didDoc = JSON.parse(JSON.stringify(didDocument)); + const updatedDidDoc = await hypersignDID.addVerificationMethod({ ...params }); + expect(updatedDidDoc).to.be.a('object'); + should().exist(updatedDidDoc['@context']); + should().exist(updatedDidDoc['id']); + should().exist(updatedDidDoc['controller']); + should().exist(updatedDidDoc['alsoKnownAs']); + should().exist(updatedDidDoc['verificationMethod']); + expect( + updatedDidDoc['verificationMethod'] && + updatedDidDoc['authentication'] && + updatedDidDoc['assertionMethod'] && + updatedDidDoc['keyAgreement'] && + updatedDidDoc['capabilityInvocation'] && + updatedDidDoc['capabilityDelegation'] && + updatedDidDoc['service'] + ).to.be.a('array'); + should().exist(updatedDidDoc['authentication']); + should().exist(updatedDidDoc['assertionMethod']); + expect(updatedDidDoc.verificationMethod.length).to.be.greaterThan(didDoc.verificationMethod.length); + }); + }); + describe('#register() this is to register did with keyType Ed25519VerificationKey2020 and X25519KeyAgreementKeyEIP5630 on the blockchain', function () { + it('should be able to register didDocument in the blockchain with two vm one is of type Ed25519VerificationKey2020 and other is of type X25519KeyAgreementKeyEIP5630 and register method is called without signData field', async function () { + const result = await hypersignDID.register({ + didDocument, + privateKeyMultibase, + verificationMethodId + }); + transactionHash = result.transactionHash; + should().exist(result.transactionHash); + }); + }); + describe('#resolve() this is to resolve didDocument based on didDocId', function () { + it('should be able to resolve did', async function () { + const params = { + did: didDocId, + }; + const result = await hypersignDID.resolve(params); + expect(result).to.be.a('object'); + expect(result.didDocument.id).to.be.equal(didDocId); + expect(result.didDocumentMetadata).to.be.a('object'); + versionId = result.didDocumentMetadata.versionId; + }); + }); + describe('#update() this is to update didDocument based on didDocId', function () { + it('should be able to update did document with keyType X25519KeyAgreementKeyEIP5630', async function () { + const didDoc = JSON.parse(JSON.stringify(didDocument)) + didDoc['alsoKnownAs'].push('Some DATA'); + const result = await hypersignDID.update({ + didDocument: didDoc, + privateKeyMultibase, + verificationMethodId, + versionId, + }); + should().exist(result.transactionHash); + }); + }); + describe('#resolve() did after updating did document', function () { + it('should be able to resolve did', async function () { + const params = { + did: didDocId, + }; + const result = await hypersignDID.resolve(params); + expect(result).to.be.a('object'); + expect(result.didDocument.id).to.be.equal(didDocId); + expect(result.didDocumentMetadata).to.be.a('object'); + versionId = result.didDocumentMetadata.versionId; + }); + + }); + + describe('#deactivate() this is to deactivate didDocument based on didDocId', function () { + it('should be able to deactivate did document with keytype X25519KeyAgreementKeyEIP5630', async function () { + const didDocTodeactivate = JSON.parse(JSON.stringify(didDocument)) + const result = await hypersignDID.deactivate({ + didDocument: didDocTodeactivate, + privateKeyMultibase, + verificationMethodId, + versionId, + }); + should().exist(result.transactionHash); + }); + }); + }) +}) \ No newline at end of file diff --git a/src/tests/vp.spec.ts b/src/tests/presentation/vp.spec.ts similarity index 68% rename from src/tests/vp.spec.ts rename to src/tests/presentation/vp.spec.ts index 0dc480d..7ca78b7 100644 --- a/src/tests/vp.spec.ts +++ b/src/tests/presentation/vp.spec.ts @@ -1,15 +1,10 @@ import { expect, should } from 'chai'; -import { - HypersignDID, - HypersignSchema, - HypersignVerifiableCredential, - HypersignVerifiablePresentation, - HypersignSSISdk, -} from '../index'; -import { createWallet, mnemonic, hidNodeEp } from './config'; -import { IVerifiablePresentation } from '../presentation/IPresentation'; -import { ICredentialStatus, IVerifiableCredential } from '../credential/ICredential'; - +import { HypersignSchema, HypersignVerifiableCredential, HypersignSSISdk } from '../../index'; +import { createWallet, mnemonic, hidNodeEp } from '../config'; +import { IVerifiablePresentation } from '../../presentation/IPresentation'; +import { ICredentialStatus, IVerifiableCredential } from '../../credential/ICredential'; +let holdersPrivateKeyMultibase; +let holderDidDocument; let hypersignSSISDK; let privateKeyMultibase; let publicKeyMultibase; @@ -19,7 +14,6 @@ let signedDocument; let verificationMethodId; let didDocument; let schemaObject; -let schemaSignature; const challenge = '1231231231'; const domain = 'www.adbv.com'; let offlineSigner; @@ -36,9 +30,6 @@ let hypersignVP; let unsignedverifiablePresentation: IVerifiablePresentation; let verifiableCredentialPresentationId; let signedVerifiablePresentation: IVerifiablePresentation; -let didDocumentByClientspec; -const MMWalletAddress = '0x7967C85D989c41cA245f1Bb54c97D42173B135E0'; - const credentialBody = { schemaId: '', subjectDid: '', @@ -47,7 +38,7 @@ const credentialBody = { fields: { name: 'Varsha' }, }; const schemaBody = { - name: 'testSchema', + name: 'TestSchema', description: 'This is a test schema generation', author: '', fields: [{ name: 'name', type: 'string', isRequired: false }], @@ -136,36 +127,35 @@ describe('DID Opearations', () => { should().exist(didDocument['capabilityDelegation']); should().exist(didDocument['service']); }); - it('should be able to generate new did with MMwallet address using client spec', async () => { - const params = { - methodSpecificId: MMWalletAddress, - address: MMWalletAddress, - chainId: '0x1', - clientSpec: 'eth-personalSign', - }; - didDocumentByClientspec = await hypersignDID.createByClientSpec(params); - expect(didDocumentByClientspec).to.be.a('object'); - should().exist(didDocumentByClientspec['@context']); - should().exist(didDocumentByClientspec['id']); - should().exist(didDocumentByClientspec['controller']); - should().exist(didDocumentByClientspec['alsoKnownAs']); - should().exist(didDocumentByClientspec['verificationMethod']); + + it('should be able to generate didDocument for holder', async function () { + const kp = await hypersignDID.generateKeys(); + holdersPrivateKeyMultibase = kp.privateKeyMultibase; + holderDidDocument = await hypersignDID.generate({ publicKeyMultibase: kp.publicKeyMultibase }); + expect(didDocument).to.be.a('object'); + should().exist(didDocument['@context']); + should().exist(didDocument['id']); + should().exist(didDocument['controller']); + should().exist(didDocument['alsoKnownAs']); + + should().exist(didDocument['verificationMethod']); expect( - didDocumentByClientspec['verificationMethod'] && - didDocumentByClientspec['authentication'] && - didDocumentByClientspec['assertionMethod'] && - didDocumentByClientspec['keyAgreement'] && - didDocumentByClientspec['capabilityInvocation'] && - didDocumentByClientspec['capabilityDelegation'] + didDocument['verificationMethod'] && + didDocument['authentication'] && + didDocument['assertionMethod'] && + didDocument['keyAgreement'] && + didDocument['capabilityInvocation'] && + didDocument['capabilityDelegation'] && + didDocument['service'] ).to.be.a('array'); - should().exist(didDocumentByClientspec['authentication']); - should().exist(didDocumentByClientspec['assertionMethod']); - should().exist(didDocumentByClientspec['keyAgreement']); - should().exist(didDocumentByClientspec['capabilityInvocation']); - should().exist(didDocumentByClientspec['capabilityDelegation']); + should().exist(didDocument['authentication']); + should().exist(didDocument['assertionMethod']); + should().exist(didDocument['keyAgreement']); + should().exist(didDocument['capabilityInvocation']); + should().exist(didDocument['capabilityDelegation']); + should().exist(didDocument['service']); }); }); - describe('#sign() this is to sign didDoc', function () { const controller = { '@context': '', @@ -173,12 +163,13 @@ describe('DID Opearations', () => { authentication: [], }; it('should able to sign did document', async function () { + const didDoc = JSON.parse(JSON.stringify(didDocument)); const params = { privateKeyMultibase: privateKeyMultibase as string, challenge: challenge as string, domain: domain as string, did: '', - didDocument: didDocument as object, + didDocument: didDoc as object, verificationMethodId: verificationMethodId as string, controller, }; @@ -199,18 +190,26 @@ describe('DID Opearations', () => { should().exist(signedDocument['proof']); }); }); - describe('#register() this is to register did on the blockchain', function () { it('should be able to register didDocument in the blockchain', async function () { const result = await hypersignDID.register({ didDocument, privateKeyMultibase, verificationMethodId }); should().exist(result.transactionHash); should().exist(result.didDocument); }); + it('should be able to register holder didDocument in the blockchain', async function () { + const result = await hypersignDID.register({ + didDocument: holderDidDocument, + privateKeyMultibase: holdersPrivateKeyMultibase, + verificationMethodId: holderDidDocument.verificationMethod[0].id, + }); + should().exist(result.transactionHash); + should().exist(result.didDocument); + }); }); }); -/** - * Schema Creation and Registration - */ +// /** +// * Schema Creation and Registration +// */ describe('Schema Opearations', () => { describe('#getSchema() method to create schema', function () { it('should able to create a new schema', async function () { @@ -250,16 +249,16 @@ describe('Schema Opearations', () => { }); }); -/** - * Test cases related to credential - */ +// /** +// * Test cases related to credential +// */ describe('Verifiable Credential Opearations', () => { - describe('#getCredential() method to generate a credential', function () { + describe('#generate() method to generate a credential', function () { it('should be able to generate new credential for a schema with subject DID', async function () { const expirationDate = new Date('12/11/2027'); const tempCredentialBody = { ...credentialBody }; tempCredentialBody.schemaId = schemaId; - tempCredentialBody.subjectDid = didDocId; + tempCredentialBody.subjectDid = holderDidDocument.id; tempCredentialBody['expirationDate'] = expirationDate; tempCredentialBody.issuerDid = didDocId; tempCredentialBody.fields = { name: 'varsha' }; @@ -279,10 +278,9 @@ describe('Verifiable Credential Opearations', () => { should().exist(credentialDetail['credentialSubject']); should().exist(credentialDetail['credentialSchema']); should().exist(credentialDetail['credentialStatus']); - expect(credentialDetail['credentialStatus'].type).to.be.equal('CredentialStatusList2017'); + expect(credentialDetail['credentialStatus'].type).to.be.equal('HypersignCredentialStatus2023'); }); }); - describe('#issueCredential() method for issuing credential', function () { it('should be able to issue credential with credential status registered on chain', async function () { const tempIssueCredentialBody = { ...issueCredentialBody }; @@ -292,17 +290,12 @@ describe('Verifiable Credential Opearations', () => { tempIssueCredentialBody.privateKeyMultibase = privateKeyMultibase; //console.log(JSON.stringify(tempIssueCredentialBody, null, 2)); const issuedCredResult = await hypersignVC.issue(tempIssueCredentialBody); - const { signedCredential, credentialStatus, credentialStatusProof, credentialStatusRegistrationResult } = issuedCredResult; signedVC = signedCredential; credenStatus = credentialStatus; credentialId = signedVC.id; - - // console.log('Signed Credential --------------------------------'); - // console.log(JSON.stringify(signedVC, null, 2)); - credentialStatusId = signedCredential['credentialStatus'].id; expect(signedCredential).to.be.a('object'); @@ -316,29 +309,20 @@ describe('Verifiable Credential Opearations', () => { should().exist(signedCredential['credentialSchema']); should().exist(signedCredential['credentialStatus']); should().exist(signedCredential['proof']); - // console.log({ - // signedCredentialId: signedVC ? signedVC['id'] : '', - // credentialId, - // id: tempIssueCredentialBody.credential.id, - // }); expect(signedCredential['id']).to.be.equal(tempIssueCredentialBody.credential.id); - expect(credentialStatus).to.be.a('object'); - should().exist(credentialStatus['claim']); should().exist(credentialStatus['issuer']); should().exist(credentialStatus['issuanceDate']); - should().exist(credentialStatus['expirationDate']); - should().exist(credentialStatus['credentialHash']); - + should().exist(credentialStatus['remarks']); + should().exist(credentialStatus['credentialMerkleRootHash']); expect(credentialStatusProof).to.be.a('object'); should().exist(credentialStatusProof['type']); should().exist(credentialStatusProof['created']); - should().exist(credentialStatusProof['updated']); should().exist(credentialStatusProof['verificationMethod']); should().exist(credentialStatusProof['proofPurpose']); should().exist(credentialStatusProof['proofValue']); - expect(credentialStatusRegistrationResult).to.be.a('object'); + should().exist(credentialStatusRegistrationResult['code']); should().exist(credentialStatusRegistrationResult['height']); should().exist(credentialStatusRegistrationResult['transactionHash']); should().exist(credentialStatusRegistrationResult['gasUsed']); @@ -347,26 +331,21 @@ describe('Verifiable Credential Opearations', () => { }); }); -/** - * Test cases related to verifiable presentation - */ +// /** +// * Test cases related to verifiable presentation +// */ describe('Verifiable Presentation Operataions', () => { describe('#generate() method to generate new presentation document', () => { - const presentationBody = { - verifiableCredentials: [credentialDetail], - holderDid: didDocId, - }; - - it('should be able to gnerate a new presentation document', async () => { + it('should be able to generate a new presentation document', async () => { + const presentationBody = { + verifiableCredentials: [credentialDetail], + holderDid: holderDidDocument.id, + }; const tempPresentationBody = { ...presentationBody }; tempPresentationBody.verifiableCredentials[0] = credentialDetail; - tempPresentationBody.holderDid = didDocId; - - // console.log(JSON.stringify(tempPresentationBody, null, 2)); - + tempPresentationBody.holderDid = holderDidDocument.id; unsignedverifiablePresentation = await hypersignVP.generate(tempPresentationBody); - // console.log(JSON.stringify(unsignedverifiablePresentation, null, 2)); should().exist(unsignedverifiablePresentation['@context']); should().exist(unsignedverifiablePresentation['type']); expect(unsignedverifiablePresentation.type[0]).to.be.equal('VerifiablePresentation'); @@ -375,24 +354,23 @@ describe('Verifiable Presentation Operataions', () => { should().exist(unsignedverifiablePresentation['id']); should().exist(unsignedverifiablePresentation['holder']); verifiableCredentialPresentationId = unsignedverifiablePresentation.id; - // expect(unsignedverifiablePresentation['verifiableCredential'][0].id).to.be.equal(credentialId); }); }); describe('#sign() method to sign presentation document', () => { const signPresentationBody = { presentation: unsignedverifiablePresentation, - holderDid: didDocId, - verificationMethodId, - privateKeyMultibase: privateKeyMultibase, + holderDid: '', + verificationMethodId: '', + privateKeyMultibase: '', challenge, }; it('should not be able to sign presentation as either holderDid or holderDidDocSigned is required but passed both', async function () { const tempSignPresentationBody = { ...signPresentationBody }; tempSignPresentationBody.presentation = unsignedverifiablePresentation; - tempSignPresentationBody.holderDid = didDocId; - tempSignPresentationBody.verificationMethodId = verificationMethodId; - tempSignPresentationBody.privateKeyMultibase = privateKeyMultibase; + tempSignPresentationBody.holderDid = holderDidDocument.id; + tempSignPresentationBody.verificationMethodId = holderDidDocument.verificationMethod[0].id; + tempSignPresentationBody.privateKeyMultibase = holdersPrivateKeyMultibase; tempSignPresentationBody['holderDidDocSigned'] = signedDocument; return hypersignVP.sign(tempSignPresentationBody).catch(function (err) { expect(function () { @@ -409,51 +387,52 @@ describe('Verifiable Presentation Operataions', () => { }).to.throw(Error, 'HID-SSI-SDK:: params.privateKeyMultibase is required for signing a presentation'); }); }); - // it('should not be able to sign presentation as either holderDid or holderDidDocSigned is required but passed both', async function () { - // const tempSignPresentationBody = { ...signPresentationBody }; - // tempSignPresentationBody.privateKeyMultibase = privateKeyMultibase; - // tempSignPresentationBody.presentation = {} as IVerifiablePresentation; + it('should not be able to sign presentation as either holderDid or holderDidDocSigned is required but passed both', async function () { + const tempSignPresentationBody = { ...signPresentationBody }; + tempSignPresentationBody.privateKeyMultibase = privateKeyMultibase; + tempSignPresentationBody.presentation = {} as IVerifiablePresentation; + tempSignPresentationBody.verificationMethodId = holderDidDocument.verificationMethod[0].id; + tempSignPresentationBody.holderDid = holderDidDocument.id; - // return hypersignVP.sign(tempSignPresentationBody).catch(function (err) { - // expect(function () { - // throw err; - // }).to.throw(Error, 'HID-SSI-SDK:: params.presentation is required for signinng a presentation'); - // }); - // }); + return hypersignVP.sign(tempSignPresentationBody).catch(function (err) { + expect(function () { + throw err; + }).to.throw(Error, 'HID-SSI-SDK:: params.presentation is required for signing a presentation'); + }); + }); it('should not be able to sign presentation as challenge is not passed', async function () { const tempSignPresentationBody = { ...signPresentationBody }; - tempSignPresentationBody.privateKeyMultibase = privateKeyMultibase; + tempSignPresentationBody.privateKeyMultibase = holdersPrivateKeyMultibase; tempSignPresentationBody.presentation = unsignedverifiablePresentation; tempSignPresentationBody.challenge = ''; return hypersignVP.sign(tempSignPresentationBody).catch(function (err) { expect(function () { throw err; - }).to.throw(Error, 'HID-SSI-SDK:: params.challenge is required for signinng a presentation'); + }).to.throw(Error, 'HID-SSI-SDK:: params.challenge is required for signing a presentation'); }); }); it('should not be able to sign presentation as verificationMethodId is not passed', async function () { const tempSignPresentationBody = { ...signPresentationBody }; - tempSignPresentationBody.privateKeyMultibase = privateKeyMultibase; + tempSignPresentationBody.privateKeyMultibase = holdersPrivateKeyMultibase; tempSignPresentationBody.presentation = unsignedverifiablePresentation; tempSignPresentationBody.challenge = challenge; tempSignPresentationBody.verificationMethodId = ''; return hypersignVP.sign(tempSignPresentationBody).catch(function (err) { expect(function () { throw err; - }).to.throw(Error, 'HID-SSI-SDK:: params.verificationMethodId is required for signinng a presentation'); + }).to.throw(Error, 'HID-SSI-SDK:: params.verificationMethodId is required for signing a presentation'); }); }); it('should be able a sign presentation document', async () => { const tempSignPresentationBody = { ...signPresentationBody }; tempSignPresentationBody.presentation = unsignedverifiablePresentation; - tempSignPresentationBody.holderDid = didDocId; - tempSignPresentationBody.verificationMethodId = verificationMethodId; - tempSignPresentationBody.privateKeyMultibase = privateKeyMultibase; + tempSignPresentationBody.holderDid = holderDidDocument.id; + tempSignPresentationBody.verificationMethodId = holderDidDocument.verificationMethod[0].id; + tempSignPresentationBody.privateKeyMultibase = holdersPrivateKeyMultibase; + tempSignPresentationBody.challenge = "abc"; + tempSignPresentationBody['domain'] = "http://xyz.com"; signedVerifiablePresentation = await hypersignVP.sign(tempSignPresentationBody); - - // console.log(JSON.stringify(signedVerifiablePresentation, null, 2)); - should().exist(signedVerifiablePresentation['@context']); should().exist(signedVerifiablePresentation['type']); expect(signedVerifiablePresentation.type[0]).to.be.equal('VerifiablePresentation'); @@ -461,12 +440,11 @@ describe('Verifiable Presentation Operataions', () => { expect(signedVerifiablePresentation.id).to.be.equal(verifiableCredentialPresentationId); }); }); - describe('#verify() method to verify a signed presentation document', () => { const verifyPresentationBody = { signedPresentation: signedVerifiablePresentation, - holderDid: didDocId, - holderVerificationMethodId: verificationMethodId, + holderDid: '', + holderVerificationMethodId: '', issuerVerificationMethodId: verificationMethodId, privateKey: privateKeyMultibase, challenge, @@ -476,8 +454,8 @@ describe('Verifiable Presentation Operataions', () => { it('should not be able to verify presentation as either holderDid or holderDidDocSigned is required but passed both', async function () { const tempverifyPresentationBody = { ...verifyPresentationBody }; tempverifyPresentationBody.signedPresentation = signedVerifiablePresentation; - tempverifyPresentationBody.holderDid = didDocId; - tempverifyPresentationBody.holderVerificationMethodId = verificationMethodId; + tempverifyPresentationBody.holderDid = holderDidDocument.id; + tempverifyPresentationBody.holderVerificationMethodId = holderDidDocument.verificationMethod[0].id; tempverifyPresentationBody.issuerVerificationMethodId = verificationMethodId; tempverifyPresentationBody.privateKey = privateKeyMultibase; tempverifyPresentationBody['holderDidDocSigned'] = signedDocument; @@ -523,7 +501,7 @@ describe('Verifiable Presentation Operataions', () => { const tempverifyPresentationBody = { ...verifyPresentationBody }; tempverifyPresentationBody.issuerDid = didDocId; tempverifyPresentationBody.challenge = challenge; - tempverifyPresentationBody.holderVerificationMethodId = verificationMethodId; + tempverifyPresentationBody.holderVerificationMethodId = holderDidDocument.verificationMethod[0].id; tempverifyPresentationBody.issuerVerificationMethodId = ''; return hypersignVP.verify(tempverifyPresentationBody).catch(function (err) { @@ -532,28 +510,84 @@ describe('Verifiable Presentation Operataions', () => { }).to.throw(Error, 'HID-SSI-SDK:: params.issuerVerificationMethodId is required for verifying a presentation'); }); }); - - it('should be able a verify sgned presentation document', async () => { + it('should not be able to verify presentation as challenge used at the time of verification is different than challenge used in vp sign and getting presentation verification result false', async function () { const tempverifyPresentationBody = { ...verifyPresentationBody }; tempverifyPresentationBody.signedPresentation = signedVerifiablePresentation; tempverifyPresentationBody.issuerDid = didDocId; - tempverifyPresentationBody.holderDid = didDocId; - tempverifyPresentationBody.holderVerificationMethodId = verificationMethodId; + tempverifyPresentationBody.holderDid = holderDidDocument.id; + tempverifyPresentationBody.challenge = "abczshdsfhgk"; + tempverifyPresentationBody['domain'] = "http://xyz.com" + tempverifyPresentationBody.holderVerificationMethodId = holderDidDocument.verificationMethod[0].id; tempverifyPresentationBody.issuerVerificationMethodId = verificationMethodId; - tempverifyPresentationBody.challenge = didDocId; - const verifiedPresentationDetail = await hypersignVP.verify(tempverifyPresentationBody); - // console.log(JSON.stringify(verifiedPresentationDetail, null, 2)); - + expect(verifiedPresentationDetail.verified).to.be.equal(false); + expect(verifiedPresentationDetail.presentationResult.verified).to.be.equal(false); + expect(verifiedPresentationDetail.credentialResults[0].verified).to.be.equal(true); + }); + it('should not be able to verify presentation as domain used at the time of vp verification is differ than domain used in vp sign and getting presentation verification result false', async function () { + const tempverifyPresentationBody = { ...verifyPresentationBody }; + tempverifyPresentationBody.signedPresentation = signedVerifiablePresentation; + tempverifyPresentationBody.issuerDid = didDocId; + tempverifyPresentationBody.holderDid = holderDidDocument.id; + tempverifyPresentationBody.challenge = "abc"; + tempverifyPresentationBody['domain'] = "http://xyz1.com"; + tempverifyPresentationBody.holderVerificationMethodId = holderDidDocument.verificationMethod[0].id; + tempverifyPresentationBody.issuerVerificationMethodId = verificationMethodId; + const verifiedPresentationDetail = await hypersignVP.verify(tempverifyPresentationBody); + expect(verifiedPresentationDetail.verified).to.be.equal(false); + expect(verifiedPresentationDetail.presentationResult.verified).to.be.equal(false); + expect(verifiedPresentationDetail.credentialResults[0].verified).to.be.equal(true); + }); + it('should be able to verify signed presentation document', async () => { + const tempverifyPresentationBody = { ...verifyPresentationBody }; + tempverifyPresentationBody.signedPresentation = signedVerifiablePresentation; + tempverifyPresentationBody.issuerDid = didDocId; + tempverifyPresentationBody.holderDid = holderDidDocument.id; + tempverifyPresentationBody.holderVerificationMethodId = holderDidDocument.verificationMethod[0].id; + tempverifyPresentationBody.issuerVerificationMethodId = verificationMethodId; + tempverifyPresentationBody.challenge = "abc"; + tempverifyPresentationBody['domain'] = "http://xyz.com" + const verifiedPresentationDetail = await hypersignVP.verify(tempverifyPresentationBody); should().exist(verifiedPresentationDetail.verified); expect(verifiedPresentationDetail.verified).to.be.equal(true); + expect(verifiedPresentationDetail.presentationResult.verified).to.be.equal(true); + expect(verifiedPresentationDetail).to.be.a('object'); - should().exist(verifiedPresentationDetail.results); - expect(verifiedPresentationDetail.results).to.be.a('array'); should().exist(verifiedPresentationDetail.credentialResults); expect(verifiedPresentationDetail.credentialResults).to.be.a('array'); + should().exist(verifiedPresentationDetail.credentialResults[0].results); + expect(verifiedPresentationDetail.credentialResults[0].results).to.be.a('array'); expect(verifiedPresentationDetail.credentialResults[0].verified).to.be.equal(true); expect(verifiedPresentationDetail.credentialResults[0].credentialId).to.be.equal(credentialId); }); + + it('should be able a sign and verify a presentation without domain', async () => { + const signPresentationBody = { + presentation: unsignedverifiablePresentation, + holderDid: holderDidDocument.id, + verificationMethodId: holderDidDocument.verificationMethod[0].id, + privateKeyMultibase: holdersPrivateKeyMultibase, + challenge: "abcd", + domain: "http://xyz.com" + }; + signedVerifiablePresentation = await hypersignVP.sign(signPresentationBody); + should().exist(signedVerifiablePresentation['@context']); + should().exist(signedVerifiablePresentation['type']); + expect(signedVerifiablePresentation.type[0]).to.be.equal('VerifiablePresentation'); + should().exist(signedVerifiablePresentation['verifiableCredential']); + expect(signedVerifiablePresentation.id).to.be.equal(verifiableCredentialPresentationId); + const verifyPresentationBody = { + signedPresentation: signedVerifiablePresentation, + holderDid: holderDidDocument.id, + holderVerificationMethodId: holderDidDocument.verificationMethod[0].id, + issuerVerificationMethodId: verificationMethodId, + privateKey: privateKeyMultibase, + challenge: "abcd", + issuerDid: didDocId, + domain: "http://xyz.com" + }; + const verifiedPresentationDetail = await hypersignVP.verify(verifyPresentationBody); + console.log(verifiedPresentationDetail) + }); }); }); diff --git a/src/tests/presentation/vpByClientSpec.spec.ts b/src/tests/presentation/vpByClientSpec.spec.ts new file mode 100644 index 0000000..8238038 --- /dev/null +++ b/src/tests/presentation/vpByClientSpec.spec.ts @@ -0,0 +1,454 @@ +import { expect, should } from 'chai'; +import { HypersignDID, HypersignVerifiableCredential, HypersignVerifiablePresentation } from '../../index'; +import { createWallet, mnemonic, hidNodeEp, generatePresentationProof, verifyPresentation, generateWeb3Obj, metamaskProvider, signDid } from '../config'; +import Web3 from 'web3'; +import { DidDocument } from '../../../libs/generated/ssi/did'; +let holderDidDoc +let holderVmId +let hypersignDID; +let hypersignVC; +let offlineSigner; +let privateKeyMultibase; +let publicKeyMultibase; +let issuerDidDocument; +let didDocId; +let issuerVerificationMethodId; +let unsignedverifiablePresentation +let signedVerifiablePresentation +let hypersignPresentation; +let signedDocument; +let vpId; +const challenge = '1231231231'; +const domain = 'www.adbv.com'; +let credentialDetail; +let credentialId; +let verificationMethodId +const holderDid = "did:hid:testnet:0xec437f1b8DCe95e7094D04A38665AB6f2A1D47ec" +const credentialBody = { + // schemaId: '', + schemaContext: ["https://schema.org"], + type: ["Person"], + subjectDid: '', + issuerDid: '', + fields: { name: 'Varsha' }, +}; +let account +let mmKeyPair +let web3 +beforeEach(async function () { + offlineSigner = await createWallet(mnemonic) + const params = { + offlineSigner, + nodeRestEndpoint: hidNodeEp.rest, + nodeRpcEndpoint: hidNodeEp.rpc, + namespace: hidNodeEp.namespace, + } + const provider = new Web3.providers.HttpProvider(metamaskProvider) + web3 = new Web3(provider) + account = web3.eth.accounts.create() + // account= account.address + hypersignDID = new HypersignDID(params); + await hypersignDID.init(); + + + hypersignVC = new HypersignVerifiableCredential(params); + await hypersignVC.init(); + hypersignPresentation = new HypersignVerifiablePresentation(params); +}); + +// Generate public and private key pair +describe('#generateKeys() method to generate publicKyeMultibase and privateKeyMultiBase', function () { + it('should return publickeyMultibase and privateKeyMultibase', async function () { + const kp = await hypersignDID.generateKeys(); + privateKeyMultibase = kp.privateKeyMultibase; + publicKeyMultibase = kp.publicKeyMultibase; + expect(kp).to.be.a('object'); + should().exist(kp.privateKeyMultibase); + should().exist(kp.publicKeyMultibase); + }); +}); + +describe('DID Opearations', () => { + describe('#generate() to generate did', function () { + it('should be able to generate didDocument', async function () { + issuerDidDocument = await hypersignDID.generate({ publicKeyMultibase }); + didDocId = issuerDidDocument['id']; + issuerVerificationMethodId = issuerDidDocument['verificationMethod'][0].id; + expect(issuerDidDocument).to.be.a('object'); + should().exist(issuerDidDocument['@context']); + should().exist(issuerDidDocument['id']); + should().exist(issuerDidDocument['controller']); + should().exist(issuerDidDocument['alsoKnownAs']); + + should().exist(issuerDidDocument['verificationMethod']); + expect( + issuerDidDocument['verificationMethod'] && + issuerDidDocument['authentication'] && + issuerDidDocument['assertionMethod'] && + issuerDidDocument['keyAgreement'] && + issuerDidDocument['capabilityInvocation'] && + issuerDidDocument['capabilityDelegation'] && + issuerDidDocument['service'] + ).to.be.a('array'); + should().exist(issuerDidDocument['authentication']); + should().exist(issuerDidDocument['assertionMethod']); + should().exist(issuerDidDocument['keyAgreement']); + should().exist(issuerDidDocument['capabilityInvocation']); + should().exist(issuerDidDocument['capabilityDelegation']); + should().exist(issuerDidDocument['service']); + }); + it('should be able to generated did for holder using metamask', async function () { + holderDidDoc = await hypersignDID.createByClientSpec({ methodSpecificId: account.address, address: account.address, chainId: '0x1', clientSpec: 'eth-personalSign' }); + holderVmId = holderDidDoc.verificationMethod[0].id + }) + }); +}) +// describe('#sign() this is to sign didDoc', function () { +// const controller = { +// '@context': '', +// id: '', +// authentication: [], +// }; +// it('should able to sign did document', async function () { +// const didDoc = JSON.parse(JSON.stringify(issuerDidDocument)); +// const params = { +// privateKeyMultibase: privateKeyMultibase as string, +// challenge: challenge as string, +// domain: domain as string, +// did: '', +// didDocument: didDoc as object, +// verificationMethodId: issuerVerificationMethodId as string, +// controller, +// }; +// signedDocument = await hypersignDID.sign(params); +// expect(signedDocument).to.be.a('object'); +// should().exist(signedDocument['@context']); +// should().exist(signedDocument['id']); +// expect(didDocId).to.be.equal(signedDocument['id']); +// should().exist(signedDocument['controller']); +// should().exist(signedDocument['alsoKnownAs']); +// should().exist(signedDocument['verificationMethod']); +// should().exist(signedDocument['authentication']); +// should().exist(signedDocument['assertionMethod']); +// should().exist(signedDocument['keyAgreement']); +// should().exist(signedDocument['capabilityInvocation']); +// should().exist(signedDocument['capabilityDelegation']); +// should().exist(signedDocument['service']); +// should().exist(signedDocument['proof']); +// }); +// }); +describe('#register() this is to register did on the blockchain', function () { + it('should be able to register didDocument for issuer on the blockchain', async function () { + const result = await hypersignDID.register({ didDocument: issuerDidDocument, privateKeyMultibase, verificationMethodId: issuerVerificationMethodId }); + should().exist(result.transactionHash); + should().exist(result.didDocument); + }); + it('should be able to register didDocument for holder on the blockchain', async function () { + + const address = account.address + + const signature = web3.eth.accounts.sign(holderDidDoc, account.privateKey) + const created = new Date(new Date().getTime() - 100000).toISOString().slice(0, -5) + 'Z' + const signInfo = [{ + verification_method_id: holderVmId, + signature: signature.signature, + created, + clientSpec: { type: 'eth-personalSign' } + }] + const result = await hypersignDID.registerByClientSpec({ didDocument: holderDidDoc, signInfos: signInfo }); + should().exist(result.transactionHash); + should().exist(result.didDocument); + // const sign = await signDid(holderDidDoc, "eth-personalSign", holderVmId, account) + // console.log(sign) + }); + +}); +// return +// /** +// * Test cases related to credential +// */ +describe('Verifiable Credential Opearations', () => { + describe('#getCredential() method to generate a credential', function () { + it('should be able to generate new credential using schemacontext', async function () { + const expirationDate = new Date('12/11/2027'); + const tempCredentialBody = { ...credentialBody }; + // tempCredentialBody.schemaId = schemaId; + tempCredentialBody.subjectDid = holderDid; + tempCredentialBody['expirationDate'] = expirationDate; + tempCredentialBody.issuerDid = didDocId; + tempCredentialBody.fields = { name: 'varsha' }; + + credentialDetail = await hypersignVC.generate(tempCredentialBody); + // console.log(JSON.stringify(credentialDetail, null, 2)); + + expect(credentialDetail).to.be.a('object'); + should().exist(credentialDetail['@context']); + should().exist(credentialDetail['id']); + credentialId = credentialDetail.id; + should().exist(credentialDetail['type']); + should().exist(credentialDetail['expirationDate']); + should().exist(credentialDetail['issuanceDate']); + should().exist(credentialDetail['issuer']); + should().exist(credentialDetail['credentialSubject']); + // should().exist(credentialDetail['credentialSchema']); + should().exist(credentialDetail['credentialStatus']); + expect(credentialDetail['credentialStatus'].type).to.be.equal('HypersignCredentialStatus2023'); + }); + }); + describe('#issueCredential() method for issuing credential', function () { + it('should be able to issue credential with credential status registered on chain', async function () { + const issuedCredResult = await hypersignVC.issue({ + credential: credentialDetail, + issuerDid: didDocId, + verificationMethodId: `${didDocId}#key-1`, + privateKeyMultibase: privateKeyMultibase + }); + const { signedCredential, credentialStatus, credentialStatusProof, credentialStatusRegistrationResult } = + issuedCredResult; + expect(signedCredential).to.be.a('object'); + should().exist(signedCredential['@context']); + should().exist(signedCredential['id']); + should().exist(signedCredential['type']); + should().exist(signedCredential['expirationDate']); + should().exist(signedCredential['issuanceDate']); + should().exist(signedCredential['issuer']); + should().exist(signedCredential['credentialSubject']); + // should().exist(signedCredential['credentialSchema']); + should().exist(signedCredential['credentialStatus']); + should().exist(signedCredential['proof']); + expect(credentialStatus).to.be.a('object'); + should().exist(credentialStatus['issuer']); + should().exist(credentialStatus['issuanceDate']); + should().exist(credentialStatus['revoked']); + should().exist(credentialStatus['suspended']); + should().exist(credentialStatus['remarks']); + should().exist(credentialStatus['credentialMerkleRootHash']); + expect(credentialStatusProof).to.be.a('object'); + should().exist(credentialStatusProof['type']); + should().exist(credentialStatusProof['created']); + should().exist(credentialStatusProof['verificationMethod']); + should().exist(credentialStatusProof['proofPurpose']); + should().exist(credentialStatusProof['proofValue']); + + expect(credentialStatusRegistrationResult).to.be.a('object'); + should().exist(credentialStatusRegistrationResult['code']); + should().exist(credentialStatusRegistrationResult['height']); + should().exist(credentialStatusRegistrationResult['transactionHash']); + should().exist(credentialStatusRegistrationResult['gasUsed']); + should().exist(credentialStatusRegistrationResult['gasWanted']); + }); + }); +}); + + +// // /** +// // * Test cases related to verifiable presentation +// // */ + +describe('Verifiable Presentation Operataions', () => { + describe('#generate() method to generate new presentation document', () => { + it('should be able to gnerate a new presentation document', async () => { + const presentationBody = { + verifiableCredentials: [credentialDetail], + holderDid: holderDid, + }; + const tempPresentationBody = { ...presentationBody }; + tempPresentationBody.verifiableCredentials[0] = credentialDetail; + tempPresentationBody.holderDid = holderDid; + unsignedverifiablePresentation = await hypersignPresentation.generate(tempPresentationBody); + should().exist(unsignedverifiablePresentation['@context']); + should().exist(unsignedverifiablePresentation['type']); + expect(unsignedverifiablePresentation.type[0]).to.be.equal('VerifiablePresentation'); + should().exist(unsignedverifiablePresentation['verifiableCredential']); + expect(unsignedverifiablePresentation.verifiableCredential).to.be.a('array'); + should().exist(unsignedverifiablePresentation['id']); + should().exist(unsignedverifiablePresentation['holder']); + vpId = unsignedverifiablePresentation.id; + }); + }); + describe('#signByClientSpec() method to sign presentation document', () => { + const signPresentationBody = { + presentation: unsignedverifiablePresentation, + holderDid: "", + verificationMethodId: "", + web3Obj: {}, + challenge, + }; + const web3 = new Web3() + it('should not be able to sign presentation as holderDid is required but not passed', async function () { + const tempSignPresentationBody = { ...signPresentationBody }; + tempSignPresentationBody.holderDid = ''; + tempSignPresentationBody.presentation = unsignedverifiablePresentation; + tempSignPresentationBody.verificationMethodId = `${holderDid}#key-1`; + tempSignPresentationBody.web3Obj = web3 + return hypersignPresentation.signByClientSpec(tempSignPresentationBody).catch(function (err) { + expect(function () { + throw err; + }).to.throw(Error, 'HID-SSI-SDK:: params.holderDid is required to sign a presentation'); + }); + }); + it('should not be able to sign presentation as presentation is not passed', async function () { + const tempSignPresentationBody = { ...signPresentationBody }; + tempSignPresentationBody.presentation = null; + tempSignPresentationBody.challenge = challenge + tempSignPresentationBody.holderDid = holderDid + + return hypersignPresentation.signByClientSpec(tempSignPresentationBody).catch(function (err) { + expect(function () { + throw err; + }).to.throw(Error, 'HID-SSI-SDK:: params.presentation is required for signing a presentation'); + }); + }); + it('should not be able to sign presentation as challenge is not passed', async function () { + const tempSignPresentationBody = { ...signPresentationBody }; + tempSignPresentationBody.presentation = unsignedverifiablePresentation; + tempSignPresentationBody.holderDid = holderDid + tempSignPresentationBody.challenge = ''; + return hypersignPresentation.signByClientSpec(tempSignPresentationBody).catch(function (err) { + expect(function () { + throw err; + }).to.throw(Error, 'HID-SSI-SDK:: params.challenge is required for signing a presentation'); + }); + }); + it('should not be able to sign presentation as verificationMethodId is not passed', async function () { + const tempSignPresentationBody = { ...signPresentationBody }; + tempSignPresentationBody.holderDid = holderDid + tempSignPresentationBody.presentation = unsignedverifiablePresentation; + tempSignPresentationBody.challenge = challenge; + tempSignPresentationBody.verificationMethodId = ''; + return hypersignPresentation.signByClientSpec(tempSignPresentationBody).catch(function (err) { + expect(function () { + throw err; + }).to.throw(Error, 'HID-SSI-SDK:: params.verificationMethodId is required for signing a presentation'); + }); + }); + it('should not be able to sign presentation as web3 object is not passed', async function () { + const tempSignPresentationBody = { ...signPresentationBody }; + tempSignPresentationBody.holderDid = holderDid + tempSignPresentationBody.presentation = unsignedverifiablePresentation; + tempSignPresentationBody.challenge = challenge; + tempSignPresentationBody.verificationMethodId = issuerVerificationMethodId; + return hypersignPresentation.signByClientSpec(tempSignPresentationBody).catch(function (err) { + expect(function () { + throw err; + }).to.throw(Error, 'HID-SSI-SDK:: Error: params.web3Obj is required to sign a presentation'); + }); + }); + }); + + + describe('#verify() method to verify a signed presentation document', () => { + const verifyPresentationBody = { + signedPresentation: signedVerifiablePresentation, + challenge, + issuerDid: "", + holderDid: "", + holderDidDocSigned: DidDocument, + holderVerificationMethodId: "", + issuerVerificationMethodId: verificationMethodId, + web3Obj: {} + }; + + it('should not be able to verify presentation as either holderDid or holderDidDocSigned is required but passed both', async function () { + const tempverifyPresentationBody = { ...verifyPresentationBody }; + tempverifyPresentationBody.signedPresentation = signedVerifiablePresentation; + tempverifyPresentationBody.holderDid = holderDid; + tempverifyPresentationBody.holderVerificationMethodId = `${holderDid}#key-1`; + tempverifyPresentationBody.issuerVerificationMethodId = verificationMethodId; + tempverifyPresentationBody['holderDidDocSigned'] = DidDocument; + return hypersignPresentation.verifyByClientSpec(tempverifyPresentationBody).catch(function (err) { + expect(function () { + throw err; + }).to.throw(Error, 'HID-SSI-SDK:: Either holderDid or holderDidDocSigned should be provided'); + }); + }); + it('should not be able to verify presentation as issuerDid is null or empty', async function () { + const tempverifyPresentationBody = { ...verifyPresentationBody }; + tempverifyPresentationBody.issuerDid = ''; + return hypersignPresentation.verifyByClientSpec(tempverifyPresentationBody).catch(function (err) { + expect(function () { + throw err; + }).to.throw(Error, 'HID-SSI-SDK:: params.issuerDid is required for verifying a presentation'); + }); + }); + + it('should not be able to verify presentation as challenge is null or empty', async function () { + const tempverifyPresentationBody = { ...verifyPresentationBody }; + tempverifyPresentationBody.issuerDid = issuerDidDocument.id; + tempverifyPresentationBody.challenge = ''; + + return hypersignPresentation.verifyByClientSpec(tempverifyPresentationBody).catch(function (err) { + expect(function () { + throw err; + }).to.throw(Error, 'HID-SSI-SDK:: params.challenge is required for verifying a presentation'); + }); + }); + + it('should not be able to verify presentation as holderVerificationMethodId is null or empty', async function () { + const tempverifyPresentationBody = { ...verifyPresentationBody }; + tempverifyPresentationBody.issuerDid = didDocId; + tempverifyPresentationBody.challenge = challenge; + tempverifyPresentationBody.holderVerificationMethodId = ''; + + return hypersignPresentation.verifyByClientSpec(tempverifyPresentationBody).catch(function (err) { + expect(function () { + throw err; + }).to.throw(Error, 'HID-SSI-SDK:: params.holderVerificationMethodId is required for verifying a presentation'); + }); + }); + + it('should not be able to verify presentation as issuerVerificationMethodId is null or empty', async function () { + const tempverifyPresentationBody = { ...verifyPresentationBody }; + tempverifyPresentationBody.issuerDid = didDocId; + tempverifyPresentationBody.challenge = challenge; + tempverifyPresentationBody.holderVerificationMethodId = `${holderDid}#key-1`; + tempverifyPresentationBody.issuerVerificationMethodId = ''; + + return hypersignPresentation.verifyByClientSpec(tempverifyPresentationBody).catch(function (err) { + expect(function () { + throw err; + }).to.throw(Error, 'HID-SSI-SDK:: params.issuerVerificationMethodId is required for verifying a presentation'); + }); + }); + it('should not be able to verify presentation as web3Obj is null or empty', async function () { + const web3 = new Web3() + const tempverifyPresentationBody = { ...verifyPresentationBody }; + tempverifyPresentationBody.issuerDid = didDocId; + tempverifyPresentationBody.challenge = challenge; + tempverifyPresentationBody.holderVerificationMethodId = `${holderDid}#key-1`; + tempverifyPresentationBody.issuerVerificationMethodId = issuerVerificationMethodId; + tempverifyPresentationBody.web3Obj = {} + return hypersignPresentation.verifyByClientSpec(tempverifyPresentationBody).catch(function (err) { + expect(function () { + throw err; + }).to.throw(Error, 'HID-SSI-SDK:: Error: params.web3Obj is required to verify a presentation'); + }); + }); + + it('should be able a verify signed presentation document', async () => { + signedVerifiablePresentation = await generatePresentationProof(unsignedverifiablePresentation, challenge, holderDid, [`${holderDid}#key-1`], `${holderDid}#key-1`) + // const verificationResult = await verifyPresentation(signedVerifiablePresentation, challenge, holderDid) + // console.log(verificationResult) + const web3 = await generateWeb3Obj() + const tempverifyPresentationBody = { ...verifyPresentationBody }; + tempverifyPresentationBody.signedPresentation = signedVerifiablePresentation; + tempverifyPresentationBody.issuerDid = issuerDidDocument.id; + tempverifyPresentationBody.holderDid = holderDid; + tempverifyPresentationBody.holderVerificationMethodId = `${holderDid}#key-1`; + tempverifyPresentationBody.issuerVerificationMethodId = issuerVerificationMethodId; + tempverifyPresentationBody.challenge = challenge; + tempverifyPresentationBody.web3Obj = web3; + const verifiedPresentationDetail = await hypersignPresentation.verifyByClientSpec(tempverifyPresentationBody); + should().exist(verifiedPresentationDetail.verified); + expect(verifiedPresentationDetail.verified).to.be.equal(true); + expect(verifiedPresentationDetail).to.be.a('object'); + should().exist(verifiedPresentationDetail.results); + expect(verifiedPresentationDetail.results).to.be.a('array'); + should().exist(verifiedPresentationDetail.credentialResults); + expect(verifiedPresentationDetail.credentialResults).to.be.a('array'); + expect(verifiedPresentationDetail.credentialResults[0].verified).to.be.equal(true); + expect(verifiedPresentationDetail.credentialResults[0].credentialId).to.be.equal(credentialId); + }); + }); +}); + diff --git a/src/tests/schema/schema.spec.ts b/src/tests/schema/schema.spec.ts index f5a91ce..9f0b0a0 100644 --- a/src/tests/schema/schema.spec.ts +++ b/src/tests/schema/schema.spec.ts @@ -1,29 +1,35 @@ import { expect, should } from 'chai'; -import { HypersignSSISdk, HypersignDID, HypersignSchema } from '../../index'; +import { HypersignDID, HypersignSchema } from '../../index'; import { createWallet, mnemonic, hidNodeEp } from '../config'; -import { Schema, SchemaProof, SchemaDocument } from '../../../libs/generated/ssi/schema'; +import { CredentialSchemaState as Schema } from '../../../libs/generated/ssi/credential_schema'; +import { DocumentProof as SchemaProof } from '../../../libs/generated/ssi/proof'; + +let signedSchema2; +let invalidSchemaNamedSignedSchema1 +let invalidSchemaNamedSignedSchema2 +let invalidSchemaNamedSignedSchema3 -let hsSdk; let privateKeyMultibase; let publicKeyMultibase; let verificationMethodId; let didDocument; let didDocId; let offlineSigner; -let schemaSignature; let hypersignSchema; let schemaObject; +let schemaObject2 let schemaId; let verificationMethod; +let randomProperty let hypersignDID; let signedSchema; const signSchema = {} as Schema; -signSchema.proof = {} as SchemaProof; +signSchema['proof'] = {} as SchemaProof; const schemaBody = { - name: 'testSchema', + name: 'TestSchema', description: 'This is a test schema generation', author: '', - fields: [{ name: 'name', type: 'integer', isRequired: false }], + fields: [{ name: 'name', type: 'string', isRequired: true }] as any, additionalProperties: false, }; @@ -31,8 +37,6 @@ const schemaBody = { beforeEach(async function () { offlineSigner = await createWallet(mnemonic); - // hsSdk = new HypersignSSISdk(offlineSigner, hidNodeEp.rpc, hidNodeEp.rest, hidNodeEp.namespace); - // await hsSdk.init(); hypersignSchema = new HypersignSchema({ // entityApiSecretKey, @@ -117,7 +121,49 @@ describe('#generate() method to create schema', function () { }); }); - it('should able to create a new schema without offlinesigner', async function () { + it('should not be able to create a new schema as schema name is in camelCase and only pascalCase is allowed', function () { + const tempSchemaBody = { ...schemaBody }; + tempSchemaBody.author = didDocId; + tempSchemaBody['name'] = 'testSchema' + return hypersignSchema.generate(tempSchemaBody).catch(function (err) { + expect(function () { + throw err; + }).to.throw(Error, 'HID-SSI-SDK:: Error: schema name should always be in PascalCase'); + }); + }); + + it('should not be able to create a schema as schema name is in snakeCase and only pascalCase is allowed', function () { + const tempSchemaBody = { ...schemaBody }; + tempSchemaBody.author = didDocId; + tempSchemaBody['name'] = 'testing_schema' + return hypersignSchema.generate(tempSchemaBody).catch(function (err) { + expect(function () { + throw err; + }).to.throw(Error, 'HID-SSI-SDK:: Error: schema name should always be in PascalCase'); + }); + }); + it('should not be able to create a schema as schema name is not in pascalCase', function () { + const tempSchemaBody = { ...schemaBody }; + tempSchemaBody.author = didDocId; + tempSchemaBody['name'] = 'Test credential Schema' + return hypersignSchema.generate(tempSchemaBody).catch(function (err) { + expect(function () { + throw err; + }).to.throw(Error, 'HID-SSI-SDK:: Error: schema name should always be in PascalCase'); + }); + }); + it("should not be able to create a schema as sub-property 'name' is not present in field property", function () { + const tempSchemaBody = { ...schemaBody }; + tempSchemaBody.author = didDocId; + tempSchemaBody['fields'] = [{ isRequired: true }] + return hypersignSchema.generate(tempSchemaBody).catch(function (err) { + expect(function () { + throw err; + }).to.throw(Error, "HID-SSI-SDK:: Error: All fields must contains property 'name'"); + }); + }); + + it('should be able to create a new schema without offlinesigner', async function () { const tempSchemaBody = { ...schemaBody }; tempSchemaBody.author = didDocId; const hypersignSchema = new HypersignSchema() @@ -134,7 +180,7 @@ describe('#generate() method to create schema', function () { expect(schemaDoc['name']).to.be.equal(tempSchemaBody.name); expect(schemaDoc['author']).to.be.equal(tempSchemaBody.author); }); - it('should able to create a new schema', async function () { + it('should be able to create a new schema', async function () { const tempSchemaBody = { ...schemaBody }; tempSchemaBody.author = didDocId; schemaObject = await hypersignSchema.generate(tempSchemaBody); @@ -151,16 +197,164 @@ describe('#generate() method to create schema', function () { expect(schemaObject['name']).to.be.equal(tempSchemaBody.name); expect(schemaObject['author']).to.be.equal(tempSchemaBody.author); }); + it('should be able to create a schema with differnt field value', async function () { + const tempSchemaBody = { ...schemaBody }; + tempSchemaBody.fields.push({ name: 'address', type: 'string', isRequired: false }) + tempSchemaBody.author = didDocId; + schemaObject2 = await hypersignSchema.generate(tempSchemaBody); + expect(schemaObject).to.be.a('object'); + should().exist(schemaObject['type']); + should().exist(schemaObject['modelVersion']); + should().exist(schemaObject['id']); + should().exist(schemaObject['name']); + should().exist(schemaObject['author']); + should().exist(schemaObject['authored']); + should().exist(schemaObject['schema']); + expect(schemaObject.schema).to.be.a('object'); + expect(schemaObject['name']).to.be.equal(tempSchemaBody.name); + expect(schemaObject['author']).to.be.equal(tempSchemaBody.author); + }); }); - +// dont allow fields other than { name: 'name', type: 'string', isRequired: false } describe('#sign() function to sign schema', function () { + it('should not be able to sign a new schema as privateKeyMultibase is not passed', function () { + return hypersignSchema.sign({ + privateKeyMultibase: "", + schema: schemaObject, + verificationMethodId: didDocument['assertionMethod'][0] + }).catch(function (err) { + expect(function () { + throw err; + }).to.throw(Error, 'HID-SSI-SDK:: Error: params.privateKeyMultibase must be passed'); + }); + }); + it('should not be able to sign a new schema as verificationMethodId is not passed', function () { + return hypersignSchema.sign({ + privateKeyMultibase, + schema: schemaObject, + verificationMethodId: "" + }).catch(function (err) { + expect(function () { + throw err; + }).to.throw(Error, 'HID-SSI-SDK:: Error: params.verificationMethodId must be passed'); + }); + }); + it('should not be able to sign a new schema as schema is not passed', function () { + return hypersignSchema.sign({ + privateKeyMultibase, + verificationMethodId: didDocument['assertionMethod'][0] + }).catch(function (err) { + expect(function () { + throw err; + }).to.throw(Error, 'HID-SSI-SDK:: Error: Schema must be passed'); + }); + }); it('should be able to sign newly created schema', async function () { + const tempSchemaBody = JSON.parse(JSON.stringify(schemaObject)) signedSchema = await hypersignSchema.sign({ privateKeyMultibase: privateKeyMultibase, - schema: schemaObject, + schema: tempSchemaBody, + verificationMethodId: didDocument['assertionMethod'][0], + }); + expect(signedSchema).to.be.a('object'); + should().exist(signedSchema.proof); + should().exist(signedSchema.proof.type); + should().exist(signedSchema.proof.verificationMethod); + should().exist(signedSchema.proof.proofPurpose); + should().exist(signedSchema.proof.proofValue); + should().exist(signedSchema.proof.created); + should().exist(signedSchema.type); + should().exist(signedSchema.modelVersion); + should().exist(signedSchema.author); + should().exist(signedSchema['id']); + should().exist(signedSchema['name']); + should().exist(signedSchema['author']); + should().exist(signedSchema['authored']); + should().exist(signedSchema['schema']); + }); + it('should be able to sign newly created schema with schema name is in camelCase', async function () { + const tempSchemaBody = JSON.parse(JSON.stringify(schemaObject2)) + tempSchemaBody['name'] = "testSchema" + invalidSchemaNamedSignedSchema1 = await hypersignSchema.sign({ + privateKeyMultibase: privateKeyMultibase, + schema: tempSchemaBody, + verificationMethodId: didDocument['assertionMethod'][0], + }); + expect(signedSchema).to.be.a('object'); + should().exist(signedSchema.proof); + should().exist(signedSchema.proof.type); + should().exist(signedSchema.proof.verificationMethod); + should().exist(signedSchema.proof.proofPurpose); + should().exist(signedSchema.proof.proofValue); + should().exist(signedSchema.proof.created); + should().exist(signedSchema.type); + should().exist(signedSchema.modelVersion); + should().exist(signedSchema.author); + should().exist(signedSchema['id']); + should().exist(signedSchema['name']); + should().exist(signedSchema['author']); + should().exist(signedSchema['authored']); + should().exist(signedSchema['schema']); + }); + it('should be able to sign newly created schema with schema name is in snakeCase', async function () { + const tempSchemaBody = JSON.parse(JSON.stringify(schemaObject2)) + tempSchemaBody['name'] = "test_schema" + invalidSchemaNamedSignedSchema2 = await hypersignSchema.sign({ + privateKeyMultibase: privateKeyMultibase, + schema: tempSchemaBody, + verificationMethodId: didDocument['assertionMethod'][0], + }); + expect(signedSchema).to.be.a('object'); + should().exist(signedSchema.proof); + should().exist(signedSchema.proof.type); + should().exist(signedSchema.proof.verificationMethod); + should().exist(signedSchema.proof.proofPurpose); + should().exist(signedSchema.proof.proofValue); + should().exist(signedSchema.proof.created); + should().exist(signedSchema.type); + should().exist(signedSchema.modelVersion); + should().exist(signedSchema.author); + should().exist(signedSchema['id']); + should().exist(signedSchema['name']); + should().exist(signedSchema['author']); + should().exist(signedSchema['authored']); + should().exist(signedSchema['schema']); + }); + it('should be able to sign newly created schema with schema name is in sentanceCase', async function () { + const tempSchemaBody = JSON.parse(JSON.stringify(schemaObject2)) + tempSchemaBody['name'] = "Test Schema" + invalidSchemaNamedSignedSchema3 = await hypersignSchema.sign({ + privateKeyMultibase: privateKeyMultibase, + schema: tempSchemaBody, + verificationMethodId: didDocument['assertionMethod'][0], + }); + expect(signedSchema).to.be.a('object'); + should().exist(signedSchema.proof); + should().exist(signedSchema.proof.type); + should().exist(signedSchema.proof.verificationMethod); + should().exist(signedSchema.proof.proofPurpose); + should().exist(signedSchema.proof.proofValue); + should().exist(signedSchema.proof.created); + should().exist(signedSchema.type); + should().exist(signedSchema.modelVersion); + should().exist(signedSchema.author); + should().exist(signedSchema['id']); + should().exist(signedSchema['name']); + should().exist(signedSchema['author']); + should().exist(signedSchema['authored']); + should().exist(signedSchema['schema']); + }); + it('should be able to sign newly created schema with invalid sub-property of propert field', async function () { + const tempSchemaBody = JSON.parse(JSON.stringify(schemaObject2)) + const prop = JSON.parse(tempSchemaBody.schema.properties) + randomProperty = "randomProperty" + prop[`${schemaBody.fields[0].name}`]['randomProperty'] = "xyz" + tempSchemaBody['schema'].properties = JSON.stringify(prop) + signedSchema2 = await hypersignSchema.sign({ + privateKeyMultibase: privateKeyMultibase, + schema: tempSchemaBody, verificationMethodId: didDocument['assertionMethod'][0], }); - //onsole.log(JSON.stringify(signedSchema, null, 2)) expect(signedSchema).to.be.a('object'); should().exist(signedSchema.proof); should().exist(signedSchema.proof.type); @@ -245,13 +439,61 @@ describe('#register() function to register schema on blockchain', function () { }) }) it('should be able to register schema on blockchain', async function () { + console.log(signedSchema); + const registeredSchema = await hypersignSchema.register({ schema: signedSchema, }); should().exist(registeredSchema.transactionHash); }); -}); + it('should not be able to register schema on blockchain as its already registered', async function () { + return hypersignSchema.register({ + schema: signedSchema, + }).catch(function (err) { + expect(function () { + throw err + }).to.throw(Error, `failed to execute message; message index: 0: Schema ID: ${schemaId}: schema already exists`) + }) + }); + it('should not be able to register schema as schema name is in camel case which is not valid', async function () { + return hypersignSchema.register({ + schema: invalidSchemaNamedSignedSchema1, + }).catch(function (err) { + expect(function () { + throw err; + }).to.throw(Error, `failed to execute message; message index: 0: name must always be in PascalCase: ${invalidSchemaNamedSignedSchema1.name}: invalid credential schema`) + }) + }); + + it('should not be able to register schema as schema name is in snake case which is not valid', async function () { + return hypersignSchema.register({ + schema: invalidSchemaNamedSignedSchema2, + }).catch(function (err) { + expect(function () { + throw err; + }).to.throw(Error, `failed to execute message; message index: 0: name must always be in PascalCase: ${invalidSchemaNamedSignedSchema2.name}: invalid credential schema`) + }) + }); + it('should not be able to register schema as schema name is in sentance case which is not valid', async function () { + return hypersignSchema.register({ + schema: invalidSchemaNamedSignedSchema3, + }).catch(function (err) { + expect(function () { + throw err; + }).to.throw(Error, `failed to execute message; message index: 0: name must always be in PascalCase: ${invalidSchemaNamedSignedSchema3.name}: invalid credential schema`) + }) + }); + it('should not be able to register schema as there is a invalid sub-property in side property field', async function () { + return hypersignSchema.register({ + schema: signedSchema2, + }).catch(function (err) { + expect(function () { + throw err; + }).to.throw(Error, `failed to execute message; message index: 0: invalid \`property\` provided: invalid sub-attribute ${randomProperty} of attribute name. Only \`type\` and \`format\` sub-attributes are permitted: invalid credential schema`) + }) + }); +}); describe('#resolve() this is to resolve schema', function () { it('should not able to resolve schema and throw error didDocId is not passed', function () { return hypersignSchema.resolve({ params: { schemaId: '' } }).catch(function (err) { diff --git a/src/tests/schema/schemaByEntityApiKey.spec.ts b/src/tests/schema/schemaByEntityApiKey.spec.ts index 6bc21ef..e3fe640 100644 --- a/src/tests/schema/schemaByEntityApiKey.spec.ts +++ b/src/tests/schema/schemaByEntityApiKey.spec.ts @@ -1,7 +1,6 @@ import { expect, should } from 'chai'; import { HypersignSchema, HypersignDID } from '../../index'; -import { createWallet, mnemonic, hidNodeEp } from '../config' -import { Schema, SchemaProof, SchemaDocument } from '../../../libs/generated/ssi/schema'; +import { createWallet, mnemonic, hidNodeEp, entityApiSecret } from '../config' import HyperSignSchema from '../../schema/schema'; let signedSchema @@ -16,10 +15,6 @@ let hypersignDID; let hypersignSchema; let verificationMethod; let schemaDoc; -// const entityApiSecretKey = -// '8fc3d16ce8f040fd2fc4e5ccc1d73.6b6e55d4d54cd90c85bbcc92d9469873e60c0d7878681223e2fe63fca3abafb63390f939a77b3d73bf2eb58a654810b38'; -const entityApiSecret = - "69b91e007904228e3313e586ba695.bc7705956989e43bbd7060e845c2763a381cbc80f935ac848119b8c2d7d00616346eeb74efe22a0ff140506a0c6157ef6" const schemaBody = { name: 'schema for university student registration', description: 'This is a test schema generated for student registration', diff --git a/src/utils.ts b/src/utils.ts index 1614bd2..232b03d 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -1,4 +1,4 @@ -import { Did } from '../libs/generated/ssi/did'; +import { DidDocument as Did } from '../libs/generated/ssi/did'; import * as constants from './constants'; const { encode, decode } = require('base58-universal'); import { Ed25519VerificationKey2020 } from '@digitalbazaar/ed25519-verification-key-2020'; @@ -7,10 +7,7 @@ export default class Utils { public static async getUUID(): Promise { const edKeyPair = await Ed25519VerificationKey2020.generate(); const exportedKp = await edKeyPair.export({ publicKey: true }); - const { publicKeyMultibase: publicKeyMultibase1 } = this.convertEd25519verificationkey2020toStableLibKeysInto({ - publicKey: exportedKp.publicKeyMultibase, - }); - return publicKeyMultibase1; + return exportedKp.publicKeyMultibase; } public static checkUrl(url: string) { @@ -45,58 +42,6 @@ export default class Utils { return 'z' + encode(pubKeyBuf); } - // Converting 45byte public key to 48 by padding header - // Converting 88byte private key to 91 by padding header - public static convertedStableLibKeysIntoEd25519verificationkey2020(stableLibKp: { - privKey?: Uint8Array; - publicKey?: string; - }): { publicKeyMultibase: string; privateKeyMultibase: string } { - const result = {} as { publicKeyMultibase: string; privateKeyMultibase: string }; - if (stableLibKp.publicKey) { - const stableLibPubKeyWithoutZ = stableLibKp.publicKey.substr(1); - const stableLibPubKeyWithoutZDecode = decode(stableLibPubKeyWithoutZ); - result['publicKeyMultibase'] = Utils._encodeMbKey( - constants.KEY_HEADERS.MULTICODEC_ED25519_PUB_HEADER, - stableLibPubKeyWithoutZDecode - ); - } - - if (stableLibKp.privKey) { - result['privateKeyMultibase'] = Utils._encodeMbKey( - constants.KEY_HEADERS.MULTICODEC_ED25519_PRIV_HEADER, - stableLibKp.privKey - ); - } - - return result; - } - - public static convertEd25519verificationkey2020toStableLibKeysInto(ed255192020VerKeys: { - privKey?: string; - publicKey?: string; - }): { publicKeyMultibase: string; privateKeyMultibase: string } { - const result = {} as { publicKeyMultibase: string; privateKeyMultibase: any }; - if (ed255192020VerKeys.publicKey) { - const stableLibPubKeyWithoutZ = ed255192020VerKeys.publicKey.substr(1); - const stableLibPubKeyWithoutZDecode = decode(stableLibPubKeyWithoutZ); - result['publicKeyMultibase'] = Utils._decodeMbPubKey( - constants.KEY_HEADERS.MULTICODEC_ED25519_PUB_HEADER, - stableLibPubKeyWithoutZDecode - ); - } - - // privateKeyMultibase = z + encode(header+original) - if (ed255192020VerKeys.privKey) { - const stableLibPrivKeyWithoutZ = ed255192020VerKeys.privKey.substr(1); - const stableLibPrivKeyWithoutZDecode = decode(stableLibPrivKeyWithoutZ); - result['privateKeyMultibase'] = Utils._decodeMbKey( - constants.KEY_HEADERS.MULTICODEC_ED25519_PRIV_HEADER, - stableLibPrivKeyWithoutZDecode - ); - } - - return result; - } public static jsonToLdConvertor(json: any) { const ld = {} as Did; @@ -126,4 +71,41 @@ export default class Utils { public static getFee() { return 'auto'; } + + public static removeEmptyString(obj: object): object { + if (Array.isArray(obj)) { + for (let i = obj.length - 1; i >= 0; i--) { + if (obj[i] === '' || (typeof obj[i] === 'object' && Object.keys(obj[i]).length === 0)) { + obj.splice(i, 1); + } else if (typeof obj[i] === 'object') { + this.removeEmptyString(obj[i]) + } + } + } else if (typeof obj === 'object' && obj !== null) { + for (const key in obj) { + if (Object.prototype.hasOwnProperty.call(obj, key)) { + if (obj[key] === '') { + delete obj[key] + } else if (Array.isArray(obj[key])) { + this.removeEmptyString(obj[key]); + } else if (typeof obj[key] === 'object') { + this.removeEmptyString(obj[key]) + } + } + } + } + return obj + } + public static async fetchFee(methodName: string,baseUrl) { + const url = constants.GAS_FEE_API_URL(baseUrl); + + const feeStructure = await fetch(url) + const fee = await feeStructure.json() + if (fee && fee[methodName]) { + const amount = fee[methodName].amount; + return amount; + } else { + throw new Error(`Fee not found for method: ${methodName}`); + } + } } diff --git a/test/config.js b/test/config.js deleted file mode 100644 index 0e3f48a..0000000 --- a/test/config.js +++ /dev/null @@ -1,76 +0,0 @@ -const { DirectSecp256k1HdWallet } = require("@cosmjs/proto-signing"); -const { HdPath, Slip10RawIndex } = require('@cosmjs/crypto') -const fs = require('fs') - -// const mnemonic = "retreat seek south invite fall eager engage endorse inquiry sample salad evidence express actor hidden fence anchor crowd two now convince convince park bag" -const mnemonic = "napkin delay purchase easily camp mimic share wait stereo reflect allow soccer believe exhibit laptop upset tired talent transfer talk surface solution omit crack" - -function makeCosmoshubPath(a) { - return [ - Slip10RawIndex.hardened(44), - Slip10RawIndex.hardened(118), - Slip10RawIndex.hardened(0), - Slip10RawIndex.normal(0), - Slip10RawIndex.normal(a), - - ]; -} -const createWallet = async (mnemonic) => { - if (!mnemonic) { - return await DirectSecp256k1HdWallet.generate(24, options = { - prefix: "hid", - hdPaths: [makeCosmoshubPath(0)], - }); - } else { - return await DirectSecp256k1HdWallet.fromMnemonic(mnemonic, options = { - prefix: "hid", - hdPaths: [makeCosmoshubPath(0)], - }); - } -} - -const writeDataInFile = (fileName, data) => { - return fs.writeFile(fileName, data, (error) => { - if (error) { - throw new Error(error) - } - console.log('Successfully written into file ', fileName); - }) -} - -const readDateFromFile = (fileName) => { - return new Promise((resolve, reject) => { - return fs.readFile(fileName, (err, data) => { - if (err) { - reject(err) - } - resolve(JSON.parse(data)) - }); - }) -} - -const ifFileExists = (fileName) => { - return fs.existsSync(fileName) -} - -const props = { - "name": "", - "email": "", - "phoneNumber": "" -} - - const hidNodeEp = { - rpc: 'https://rpc.jagrat.hypersign.id', - rest: 'https://api.jagrat.hypersign.id', - namespace: 'testnet', - }; - -module.exports = { - props, - writeDataInFile, - readDateFromFile, - ifFileExists, - createWallet, - mnemonic, - hidNodeEp -} \ No newline at end of file diff --git a/test/mock/After-revoke-vc.json b/test/mock/After-revoke-vc.json deleted file mode 100644 index 473ba0d..0000000 --- a/test/mock/After-revoke-vc.json +++ /dev/null @@ -1 +0,0 @@ -{"code":0,"height":376147,"rawLog":"[{\"events\":[{\"type\":\"message\",\"attributes\":[{\"key\":\"action\",\"value\":\"/hypersignprotocol.hidnode.ssi.MsgRegisterCredentialStatus\"}]}]}]","transactionHash":"2A7E1EB752A0C9A15C22A6097D067D8EFB1240C68A4D1DAA80A53D56394F1BEB","gasUsed":96461,"gasWanted":111407} \ No newline at end of file diff --git a/test/mock/Before-revoke-vc.json b/test/mock/Before-revoke-vc.json deleted file mode 100644 index 3febdc9..0000000 --- a/test/mock/Before-revoke-vc.json +++ /dev/null @@ -1 +0,0 @@ -{"@context":["https://www.w3.org/2018/credentials/v1",{"hs":"https://jagrat.hypersign.id/rest/hypersign-protocol/hidnode/ssi/schema/sch:hid:testnet:zH4mkwSskyfseVvyxXVHvP3oU6WSjN2888c5fjQLGy68A:1.1:"},{"email":"hs:email"},{"name":"hs:name"},{"modelname":"hs:modelname"},{"rollno":"hs:rollno"},"https://w3id.org/security/suites/ed25519-2020/v1"],"id":"vc:hid:testnet:z22ugRqouwWdc8bewooqqwqZY5fkrgrdywcYhHWiZMTkr","type":["VerifiableCredential","Email Schema Test"],"expirationDate":"2027-12-10T18:30:00Z","issuanceDate":"2022-10-25T11:20:37Z","issuer":"did:hid:testnet:zBsgb2aLJfMZArfXwjejSX8gMVz1k5zhf5bEn3WACz2wG","credentialSubject":{"email":"vishwas@anand.com","name":"Vishwas Anand Bhushan","modelname":"abcd","id":"did:hid:testnet:zBsgb2aLJfMZArfXwjejSX8gMVz1k5zhf5bEn3WACz2wG"},"credentialSchema":{"id":"sch:hid:testnet:zH4mkwSskyfseVvyxXVHvP3oU6WSjN2888c5fjQLGy68A:1.1","type":"JsonSchemaValidator2018"},"credentialStatus":{"id":"https://jagrat.hypersign.id/rest/hypersign-protocol/hidnode/ssi/credential/vc:hid:testnet:z22ugRqouwWdc8bewooqqwqZY5fkrgrdywcYhHWiZMTkr","type":"CredentialStatusList2017"},"proof":{"type":"Ed25519Signature2020","created":"2022-10-25T11:22:27Z","verificationMethod":"did:hid:testnet:zBsgb2aLJfMZArfXwjejSX8gMVz1k5zhf5bEn3WACz2wG#key-1","proofPurpose":"assertionMethod","proofValue":"z66eV2iJuf6DqX6L9xxq79NUywK3jwUNRj48yPCpzuviFCgAv55sYMCqyw4RJ4vcoDYG7e7i5UFuy5e1BbSRwUMe3"}} \ No newline at end of file diff --git a/test/mock/private/did.json b/test/mock/private/did.json deleted file mode 100644 index b8c0294..0000000 --- a/test/mock/private/did.json +++ /dev/null @@ -1 +0,0 @@ -{"@context":["https://www.w3.org/ns/did/v1"],"id":"did:hid:testnet:z44r9SLdy8nzuh9T1Q4tjH9ShagoPcpUZ8LpgBvUkrZAH","controller":["did:hid:testnet:z44r9SLdy8nzuh9T1Q4tjH9ShagoPcpUZ8LpgBvUkrZAH"],"alsoKnownAs":["did:hid:testnet:z44r9SLdy8nzuh9T1Q4tjH9ShagoPcpUZ8LpgBvUkrZAH"],"verificationMethod":[{"id":"did:hid:testnet:z44r9SLdy8nzuh9T1Q4tjH9ShagoPcpUZ8LpgBvUkrZAH#key-1","type":"Ed25519VerificationKey2020","controller":"did:hid:testnet:z44r9SLdy8nzuh9T1Q4tjH9ShagoPcpUZ8LpgBvUkrZAH","publicKeyMultibase":"z44r9SLdy8nzuh9T1Q4tjH9ShagoPcpUZ8LpgBvUkrZAH"}],"authentication":["did:hid:testnet:z44r9SLdy8nzuh9T1Q4tjH9ShagoPcpUZ8LpgBvUkrZAH#key-1"],"assertionMethod":["did:hid:testnet:z44r9SLdy8nzuh9T1Q4tjH9ShagoPcpUZ8LpgBvUkrZAH#key-1"],"keyAgreement":["did:hid:testnet:z44r9SLdy8nzuh9T1Q4tjH9ShagoPcpUZ8LpgBvUkrZAH#key-1"],"capabilityInvocation":["did:hid:testnet:z44r9SLdy8nzuh9T1Q4tjH9ShagoPcpUZ8LpgBvUkrZAH#key-1"],"capabilityDelegation":["did:hid:testnet:z44r9SLdy8nzuh9T1Q4tjH9ShagoPcpUZ8LpgBvUkrZAH#key-1"],"service":[]} \ No newline at end of file diff --git a/test/mock/private/keys.json b/test/mock/private/keys.json deleted file mode 100644 index 67b17a6..0000000 --- a/test/mock/private/keys.json +++ /dev/null @@ -1 +0,0 @@ -{"privateKeyMultibase":"zrv58sbG19TndtraJhAcqTnoye9ZUrA7pSdCojLS4esG922AnaegUrmxjoJ7s8vWY75pSyiqhhXRiqZ2niumTSKoP3P","publicKeyMultibase":"z6MkhX7C2atQULVNoeHi5dra8EzhQG5F2hiupMjc2CSmmmwf"} \ No newline at end of file diff --git a/test/mock/private/signed-did.json b/test/mock/private/signed-did.json deleted file mode 100644 index f4ab235..0000000 --- a/test/mock/private/signed-did.json +++ /dev/null @@ -1 +0,0 @@ -{"@context":["https://www.w3.org/ns/did/v1","https://w3id.org/security/suites/ed25519-2020/v1"],"id":"did:hid:testnet:z44r9SLdy8nzuh9T1Q4tjH9ShagoPcpUZ8LpgBvUkrZAH","controller":["did:hid:testnet:z44r9SLdy8nzuh9T1Q4tjH9ShagoPcpUZ8LpgBvUkrZAH"],"alsoKnownAs":["did:hid:testnet:z44r9SLdy8nzuh9T1Q4tjH9ShagoPcpUZ8LpgBvUkrZAH"],"verificationMethod":[{"id":"did:hid:testnet:z44r9SLdy8nzuh9T1Q4tjH9ShagoPcpUZ8LpgBvUkrZAH#key-1","type":"Ed25519VerificationKey2020","controller":"did:hid:testnet:z44r9SLdy8nzuh9T1Q4tjH9ShagoPcpUZ8LpgBvUkrZAH","publicKeyMultibase":"z44r9SLdy8nzuh9T1Q4tjH9ShagoPcpUZ8LpgBvUkrZAH"}],"authentication":["did:hid:testnet:z44r9SLdy8nzuh9T1Q4tjH9ShagoPcpUZ8LpgBvUkrZAH#key-1"],"assertionMethod":["did:hid:testnet:z44r9SLdy8nzuh9T1Q4tjH9ShagoPcpUZ8LpgBvUkrZAH#key-1"],"keyAgreement":["did:hid:testnet:z44r9SLdy8nzuh9T1Q4tjH9ShagoPcpUZ8LpgBvUkrZAH#key-1"],"capabilityInvocation":["did:hid:testnet:z44r9SLdy8nzuh9T1Q4tjH9ShagoPcpUZ8LpgBvUkrZAH#key-1"],"capabilityDelegation":["did:hid:testnet:z44r9SLdy8nzuh9T1Q4tjH9ShagoPcpUZ8LpgBvUkrZAH#key-1"],"service":[],"proof":{"type":"Ed25519Signature2020","created":"2022-12-19T09:06:04Z","verificationMethod":"did:hid:testnet:z44r9SLdy8nzuh9T1Q4tjH9ShagoPcpUZ8LpgBvUkrZAH#key-1","proofPurpose":"authentication","challenge":"1231231231","domain":"www.adbv.com","proofValue":"zG6u68Qfhp7sehTuhZeqXDk58TygWZrZnrfcgpDNt3hjRNJFiSGBxxay4C5wtbbhGC6fqufKCoesgeWyuxZZEUZr"}} \ No newline at end of file diff --git a/test/mock/public/did.json b/test/mock/public/did.json deleted file mode 100644 index 84a92fc..0000000 --- a/test/mock/public/did.json +++ /dev/null @@ -1 +0,0 @@ -{"@context":["https://www.w3.org/ns/did/v1","https://w3id.org/security/suites/ed25519-2020/v1"],"id":"did:hid:testnet:z9vP8jZ3ZCNWtCVqoW7jjs6q4KgkULh3iunPLnc8my9cB","controller":["did:hid:testnet:z9vP8jZ3ZCNWtCVqoW7jjs6q4KgkULh3iunPLnc8my9cB"],"alsoKnownAs":["did:hid:testnet:z9vP8jZ3ZCNWtCVqoW7jjs6q4KgkULh3iunPLnc8my9cB"],"verificationMethod":[{"id":"did:hid:testnet:z9vP8jZ3ZCNWtCVqoW7jjs6q4KgkULh3iunPLnc8my9cB#key-1","type":"Ed25519VerificationKey2020","controller":"did:hid:testnet:z9vP8jZ3ZCNWtCVqoW7jjs6q4KgkULh3iunPLnc8my9cB","publicKeyMultibase":"z9vP8jZ3ZCNWtCVqoW7jjs6q4KgkULh3iunPLnc8my9cB"}],"authentication":["did:hid:testnet:z9vP8jZ3ZCNWtCVqoW7jjs6q4KgkULh3iunPLnc8my9cB#key-1"],"assertionMethod":["did:hid:testnet:z9vP8jZ3ZCNWtCVqoW7jjs6q4KgkULh3iunPLnc8my9cB#key-1"],"keyAgreement":["did:hid:testnet:z9vP8jZ3ZCNWtCVqoW7jjs6q4KgkULh3iunPLnc8my9cB#key-1"],"capabilityInvocation":["did:hid:testnet:z9vP8jZ3ZCNWtCVqoW7jjs6q4KgkULh3iunPLnc8my9cB#key-1"],"capabilityDelegation":["did:hid:testnet:z9vP8jZ3ZCNWtCVqoW7jjs6q4KgkULh3iunPLnc8my9cB#key-1"],"service":[{"id":"did:hid:testnet:z9vP8jZ3ZCNWtCVqoW7jjs6q4KgkULh3iunPLnc8my9cB#vcs","type":"LinkedDomains","serviceEndpoint":"https://example.com/vc"}]} \ No newline at end of file diff --git a/test/mock/public/keys.json b/test/mock/public/keys.json deleted file mode 100644 index c15d78a..0000000 --- a/test/mock/public/keys.json +++ /dev/null @@ -1 +0,0 @@ -{"privateKeyMultibase":"zrv3MeAyjUGfyNDmHsDtSqDoRX3AzfxYd4E7TKKtqwjUx5DLGWka1yF3atjNeTQRTy2PBDRgrdPfzYc9kJR7hoDTT9q","publicKeyMultibase":"z6MkoNeBKoHzXv1MJzgWBghaiCP49G2KkaJ5boJGct6ntNPZ"} \ No newline at end of file diff --git a/test/mock/public/schema.json b/test/mock/public/schema.json deleted file mode 100644 index a8b79b2..0000000 --- a/test/mock/public/schema.json +++ /dev/null @@ -1 +0,0 @@ -{"type":"https://w3c-ccg.github.io/vc-json-schemas/v1/schema/1.0/schema.json","modelVersion":"1.0","id":"sch:hid:testnet:zFJ8qPmgAUw6udxzeuFQqwAmCtZZk39HGLottMSs9ztHv:1.1","name":"Email Schema Test","author":"did:hid:testnet:z9vP8jZ3ZCNWtCVqoW7jjs6q4KgkULh3iunPLnc8my9cB","authored":"2022-12-19T09:06:20Z","schema":{"schema":"http://json-schema.org/draft-07/schema","description":"This is email credential test","type":"object","properties":"{\"email\":{\"type\":\"string\",\"format\":\"email\"},\"name\":{\"type\":\"string\"},\"modelname\":{\"type\":\"string\"},\"rollno\":{\"type\":\"string\"}}","required":["email","name"],"additionalProperties":false},"proof":{"type":"Ed25519Signature2020","created":"2022-12-19T09:06:20Z","verificationMethod":"did:hid:testnet:z9vP8jZ3ZCNWtCVqoW7jjs6q4KgkULh3iunPLnc8my9cB#key-1","proofPurpose":"assertion","proofValue":"xrC0u6YIBY1xdMJDTz0jtPJei+2PJfH1DB3nWpdcJDFz58lC+ISy4MQLTD/Hbsax0e3dfVX56PTmOmJEfj1/CA=="}} \ No newline at end of file diff --git a/test/mock/public/signed-did.json b/test/mock/public/signed-did.json deleted file mode 100644 index feaa120..0000000 --- a/test/mock/public/signed-did.json +++ /dev/null @@ -1 +0,0 @@ -{"@context":["https://www.w3.org/ns/did/v1","https://w3id.org/security/suites/ed25519-2020/v1"],"id":"did:hid:testnet:z9vP8jZ3ZCNWtCVqoW7jjs6q4KgkULh3iunPLnc8my9cB","controller":["did:hid:testnet:z9vP8jZ3ZCNWtCVqoW7jjs6q4KgkULh3iunPLnc8my9cB"],"alsoKnownAs":["did:hid:testnet:z9vP8jZ3ZCNWtCVqoW7jjs6q4KgkULh3iunPLnc8my9cB"],"verificationMethod":[{"id":"did:hid:testnet:z9vP8jZ3ZCNWtCVqoW7jjs6q4KgkULh3iunPLnc8my9cB#key-1","type":"Ed25519VerificationKey2020","controller":"did:hid:testnet:z9vP8jZ3ZCNWtCVqoW7jjs6q4KgkULh3iunPLnc8my9cB","publicKeyMultibase":"z9vP8jZ3ZCNWtCVqoW7jjs6q4KgkULh3iunPLnc8my9cB"}],"authentication":["did:hid:testnet:z9vP8jZ3ZCNWtCVqoW7jjs6q4KgkULh3iunPLnc8my9cB#key-1"],"assertionMethod":["did:hid:testnet:z9vP8jZ3ZCNWtCVqoW7jjs6q4KgkULh3iunPLnc8my9cB#key-1"],"keyAgreement":["did:hid:testnet:z9vP8jZ3ZCNWtCVqoW7jjs6q4KgkULh3iunPLnc8my9cB#key-1"],"capabilityInvocation":["did:hid:testnet:z9vP8jZ3ZCNWtCVqoW7jjs6q4KgkULh3iunPLnc8my9cB#key-1"],"capabilityDelegation":["did:hid:testnet:z9vP8jZ3ZCNWtCVqoW7jjs6q4KgkULh3iunPLnc8my9cB#key-1"],"service":[],"proof":{"type":"Ed25519Signature2020","created":"2022-12-19T09:07:27Z","verificationMethod":"did:hid:testnet:z9vP8jZ3ZCNWtCVqoW7jjs6q4KgkULh3iunPLnc8my9cB#key-1","proofPurpose":"authentication","challenge":"1231231231","domain":"www.adbv.com","proofValue":"zSX8YhJPMDVMb7qNG4NuSxPya4zgm7o6bAskV291bEkbQucLXFPTRzVKF9ytBKqFCE3mmXgcUL8jfKXLsXAx8UMB"}} \ No newline at end of file diff --git a/test/mock/vc-with-schema-org.json b/test/mock/vc-with-schema-org.json deleted file mode 100644 index ff3ff85..0000000 --- a/test/mock/vc-with-schema-org.json +++ /dev/null @@ -1,154 +0,0 @@ -{ - "@context": [ - "https://www.w3.org/2018/credentials/v1", - "https://schema.org", - "https://w3id.org/security/suites/ed25519-2020/v1" - ], - "id": "vc:hid:testnet:zAgQW7Z8mv3Q6ApQKo933s7rmdNDZpsDfdPSpr5VjuxgV", - "type": [ - "VerifiableCredential", - "Patient" - ], - "issuer": "did:hid:testnet:z9DdjzeSywdNRmjL3kFj6LSWJcbED652swFi2GX2hs3sm", - "issuanceDate": "2022-12-19T09:04:59Z", - "expirationDate": "2027-12-10T18:30:00Z", - "credentialSubject": { - "address": { - "@type": "PostalAddress", - "addressLocality": "Seattle", - "addressRegion": "WA", - "postalCode": "98052", - "streetAddress": "20341 Whitworth Institute 405 N. Whitworth" - }, - "email": "mailto:jane-doe@xyz.edu", - "image": "janedoe.jpg", - "jobTitle": "Professor", - "name": "Jane Doe", - "telephone": "(425) 123-4567", - "url": "http://www.janedoe.com", - "id": "did:hid:testnet:z9DdjzeSywdNRmjL3kFj6LSWJcbED652swFi2GX2hs3sm", - "diagonsis": { - "alternateName": "angina pectoris", - "associatedAnatomy": { - "@type": "AnatomicalStructure", - "name": "heart" - }, - "cause": [ - { - "@type": "MedicalCause", - "name": "atherosclerosis" - }, - { - "@type": "MedicalCause", - "name": "spasms of the epicardial artery" - } - ], - "code": { - "@type": "MedicalCode", - "code": "413", - "codingSystem": "ICD-9" - }, - "differentialDiagnosis": { - "@type": "DDxElement", - "diagnosis": { - "@type": "MedicalCondition", - "name": "heart attack" - }, - "distinguishingSign": [ - { - "@type": "MedicalSymptom", - "name": "chest pain lasting at least 10 minutes at rest" - }, - { - "@type": "MedicalSymptom", - "name": "repeated episodes of chest pain at rest lasting 5 or more minutes" - }, - { - "@type": "MedicalSymptom", - "name": "an accelerating pattern of chest discomfort (episodes that are more frequent, severe, longer in duration, and precipitated by minimal exertion)" - } - ] - }, - "name": "Stable angina", - "possibleTreatment": [ - { - "@type": "Drug", - "name": "aspirin" - }, - { - "@type": "DrugClass", - "name": "beta blockers" - }, - { - "@type": "DrugClass", - "name": "ACE inhibitors" - }, - { - "@type": "Drug", - "name": "nitroglycerine" - } - ], - "riskFactor": [ - { - "@type": "MedicalRiskFactor", - "name": "Age" - }, - { - "@type": "MedicalRiskFactor", - "name": "Gender" - }, - { - "@type": "MedicalRiskFactor", - "name": "Systolic blood pressure" - }, - { - "@type": "MedicalRiskFactor", - "name": "Smoking" - }, - { - "@type": "MedicalRiskFactor", - "name": "Total cholesterol and/or cholesterol:HDL ratio" - }, - { - "@type": "MedicalRiskFactor", - "name": "Coronary artery disease" - } - ], - "secondaryPrevention": [ - { - "@type": "LifestyleModification", - "name": "stopping smoking" - }, - { - "@type": "LifestyleModification", - "name": "weight management" - }, - { - "@type": "LifestyleModification", - "name": "increased physical activity" - } - ], - "signOrSymptom": [ - { - "@type": "MedicalSymptom", - "name": "chest discomfort" - }, - { - "@type": "MedicalSymptom", - "name": "feeling of tightness, heaviness, or pain in the chest" - } - ] - } - }, - "credentialStatus": { - "id": "https://jagrat.hypersign.id/rest/hypersign-protocol/hidnode/ssi/credential/vc:hid:testnet:zAgQW7Z8mv3Q6ApQKo933s7rmdNDZpsDfdPSpr5VjuxgV", - "type": "CredentialStatusList2017" - }, - "proof": { - "type": "Ed25519Signature2020", - "created": "2022-12-19T09:06:39Z", - "verificationMethod": "did:hid:testnet:z9DdjzeSywdNRmjL3kFj6LSWJcbED652swFi2GX2hs3sm#key-1", - "proofPurpose": "assertionMethod", - "proofValue": "z2W72PFro69fU9zjjjB21RpSVokTHYNpTe1czr98RXzyWpzRAvFuK9kHwUm14kfkYjMPt5Pyw9xmbwRt3xEoCS3Ma" - } -} \ No newline at end of file diff --git a/test/mock/vc.json b/test/mock/vc.json deleted file mode 100644 index aa527ca..0000000 --- a/test/mock/vc.json +++ /dev/null @@ -1 +0,0 @@ -{"@context":["https://www.w3.org/2018/credentials/v1",{"hs":"https://jagrat.hypersign.id/rest/hypersign-protocol/hidnode/ssi/schema/sch:hid:testnet:zFJ8qPmgAUw6udxzeuFQqwAmCtZZk39HGLottMSs9ztHv:1.1:"},{"email":"hs:email"},{"name":"hs:name"},{"modelname":"hs:modelname"},{"rollno":"hs:rollno"},"https://w3id.org/security/suites/ed25519-2020/v1"],"id":"vc:hid:testnet:z2iMa5hEXkfT4yvHbg6Krw5GrVUSpvuDqbcaELSqfu6mk","type":["VerifiableCredential","Email Schema Test"],"expirationDate":"2027-12-10T18:30:00Z","issuanceDate":"2022-12-19T09:07:02Z","issuer":"did:hid:testnet:z9vP8jZ3ZCNWtCVqoW7jjs6q4KgkULh3iunPLnc8my9cB","credentialSubject":{"email":"vishwas@anand.com","name":"Vishwas Anand Bhushan","modelname":"abcd","id":"did:hid:testnet:z44r9SLdy8nzuh9T1Q4tjH9ShagoPcpUZ8LpgBvUkrZAH"},"credentialSchema":{"id":"sch:hid:testnet:zFJ8qPmgAUw6udxzeuFQqwAmCtZZk39HGLottMSs9ztHv:1.1","type":"JsonSchemaValidator2018"},"credentialStatus":{"id":"https://jagrat.hypersign.id/rest/hypersign-protocol/hidnode/ssi/credential/vc:hid:testnet:z2iMa5hEXkfT4yvHbg6Krw5GrVUSpvuDqbcaELSqfu6mk","type":"CredentialStatusList2017"},"proof":{"type":"Ed25519Signature2020","created":"2022-12-19T09:08:42Z","verificationMethod":"did:hid:testnet:z9vP8jZ3ZCNWtCVqoW7jjs6q4KgkULh3iunPLnc8my9cB#key-1","proofPurpose":"assertionMethod","proofValue":"zt7iYmyHRYDnw3PrZkdtyiunwtCAYh25jZB87QtLV3DB89wshAfCRGquE7DGsprfGuUCUq4sGQpv67WpCEUs2aRE"}} \ No newline at end of file diff --git a/test/mock/vp-with-multi-vc.json b/test/mock/vp-with-multi-vc.json deleted file mode 100644 index dd776bc..0000000 --- a/test/mock/vp-with-multi-vc.json +++ /dev/null @@ -1 +0,0 @@ -{"@context":["https://www.w3.org/2018/credentials/v1","https://w3id.org/security/suites/ed25519-2020/v1"],"type":["VerifiablePresentation"],"verifiableCredential":[{"@context":["https://www.w3.org/2018/credentials/v1","https://schema.org","https://w3id.org/security/suites/ed25519-2020/v1"],"id":"vc:hid:testnet:zAgQW7Z8mv3Q6ApQKo933s7rmdNDZpsDfdPSpr5VjuxgV","type":["VerifiableCredential","Patient"],"issuer":"did:hid:testnet:z9DdjzeSywdNRmjL3kFj6LSWJcbED652swFi2GX2hs3sm","issuanceDate":"2022-12-19T09:04:59Z","expirationDate":"2027-12-10T18:30:00Z","credentialSubject":{"address":{"@type":"PostalAddress","addressLocality":"Seattle","addressRegion":"WA","postalCode":"98052","streetAddress":"20341 Whitworth Institute 405 N. Whitworth"},"email":"mailto:jane-doe@xyz.edu","image":"janedoe.jpg","jobTitle":"Professor","name":"Jane Doe","telephone":"(425) 123-4567","url":"http://www.janedoe.com","id":"did:hid:testnet:z9DdjzeSywdNRmjL3kFj6LSWJcbED652swFi2GX2hs3sm","diagonsis":{"alternateName":"angina pectoris","associatedAnatomy":{"@type":"AnatomicalStructure","name":"heart"},"cause":[{"@type":"MedicalCause","name":"atherosclerosis"},{"@type":"MedicalCause","name":"spasms of the epicardial artery"}],"code":{"@type":"MedicalCode","code":"413","codingSystem":"ICD-9"},"differentialDiagnosis":{"@type":"DDxElement","diagnosis":{"@type":"MedicalCondition","name":"heart attack"},"distinguishingSign":[{"@type":"MedicalSymptom","name":"chest pain lasting at least 10 minutes at rest"},{"@type":"MedicalSymptom","name":"repeated episodes of chest pain at rest lasting 5 or more minutes"},{"@type":"MedicalSymptom","name":"an accelerating pattern of chest discomfort (episodes that are more frequent, severe, longer in duration, and precipitated by minimal exertion)"}]},"name":"Stable angina","possibleTreatment":[{"@type":"Drug","name":"aspirin"},{"@type":"DrugClass","name":"beta blockers"},{"@type":"DrugClass","name":"ACE inhibitors"},{"@type":"Drug","name":"nitroglycerine"}],"riskFactor":[{"@type":"MedicalRiskFactor","name":"Age"},{"@type":"MedicalRiskFactor","name":"Gender"},{"@type":"MedicalRiskFactor","name":"Systolic blood pressure"},{"@type":"MedicalRiskFactor","name":"Smoking"},{"@type":"MedicalRiskFactor","name":"Total cholesterol and/or cholesterol:HDL ratio"},{"@type":"MedicalRiskFactor","name":"Coronary artery disease"}],"secondaryPrevention":[{"@type":"LifestyleModification","name":"stopping smoking"},{"@type":"LifestyleModification","name":"weight management"},{"@type":"LifestyleModification","name":"increased physical activity"}],"signOrSymptom":[{"@type":"MedicalSymptom","name":"chest discomfort"},{"@type":"MedicalSymptom","name":"feeling of tightness, heaviness, or pain in the chest"}]}},"credentialStatus":{"id":"https://jagrat.hypersign.id/rest/hypersign-protocol/hidnode/ssi/credential/vc:hid:testnet:zAgQW7Z8mv3Q6ApQKo933s7rmdNDZpsDfdPSpr5VjuxgV","type":"CredentialStatusList2017"},"proof":{"type":"Ed25519Signature2020","created":"2022-12-19T09:06:39Z","verificationMethod":"did:hid:testnet:z9DdjzeSywdNRmjL3kFj6LSWJcbED652swFi2GX2hs3sm#key-1","proofPurpose":"assertionMethod","proofValue":"z2W72PFro69fU9zjjjB21RpSVokTHYNpTe1czr98RXzyWpzRAvFuK9kHwUm14kfkYjMPt5Pyw9xmbwRt3xEoCS3Ma"}},{"@context":["https://www.w3.org/2018/credentials/v1",{"hs":"https://jagrat.hypersign.id/rest/hypersign-protocol/hidnode/ssi/schema/sch:hid:testnet:z6Hf1qxZVjWALgaVuicTzyZ1rokJy5dJukffzZcEiB6KE:1.1:"},{"email":"hs:email"},{"name":"hs:name"},{"modelname":"hs:modelname"},{"rollno":"hs:rollno"},"https://w3id.org/security/suites/ed25519-2020/v1"],"id":"vc:hid:testnet:z4WAhwbZdnynhaJcBfaFZRycpcwwXyh8VMDqRhwHnBvCt","type":["VerifiableCredential","Email Schema Test"],"expirationDate":"2027-12-10T18:30:00Z","issuanceDate":"2022-12-19T09:04:42Z","issuer":"did:hid:testnet:z9DdjzeSywdNRmjL3kFj6LSWJcbED652swFi2GX2hs3sm","credentialSubject":{"email":"vishwas@anand.com","name":"Vishwas Anand Bhushan","modelname":"abcd","id":"did:hid:testnet:z44r9SLdy8nzuh9T1Q4tjH9ShagoPcpUZ8LpgBvUkrZAH"},"credentialSchema":{"id":"sch:hid:testnet:z6Hf1qxZVjWALgaVuicTzyZ1rokJy5dJukffzZcEiB6KE:1.1","type":"JsonSchemaValidator2018"},"credentialStatus":{"id":"https://jagrat.hypersign.id/rest/hypersign-protocol/hidnode/ssi/credential/vc:hid:testnet:z4WAhwbZdnynhaJcBfaFZRycpcwwXyh8VMDqRhwHnBvCt","type":"CredentialStatusList2017"},"proof":{"type":"Ed25519Signature2020","created":"2022-12-19T09:06:22Z","verificationMethod":"did:hid:testnet:z9DdjzeSywdNRmjL3kFj6LSWJcbED652swFi2GX2hs3sm#key-1","proofPurpose":"assertionMethod","proofValue":"z2rxCqMYCasKsMaBY5o51p8Jy6UpSueeiuDJcq2nA64nmVFX15r6Vci41GT6TrM9GdLy6vvKKx4ovrSdwkEDuYonD"}}],"id":"vp:hid:testnet:zAF64WdQCno2BCBH6h41xcTB4jQRtk8NyP1SpJQegPpnG","holder":"did:hid:testnet:z9DdjzeSywdNRmjL3kFj6LSWJcbED652swFi2GX2hs3sm","proof":{"type":"Ed25519Signature2020","created":"2022-12-19T09:06:52Z","verificationMethod":"did:hid:testnet:z9DdjzeSywdNRmjL3kFj6LSWJcbED652swFi2GX2hs3sm#key-1","proofPurpose":"authentication","challenge":"123","proofValue":"z55N5AL3DK3RKwSqJvmeKawJtoAPedx9Kx9veLNasDAXJtQS8bJ1RdRdnPkXYQvXDPPdVxXWCHRZXgB6ez8ntqc1K"}} \ No newline at end of file diff --git a/test/mock/vp.json b/test/mock/vp.json deleted file mode 100644 index fc051e7..0000000 --- a/test/mock/vp.json +++ /dev/null @@ -1 +0,0 @@ -{"@context":["https://www.w3.org/2018/credentials/v1","https://w3id.org/security/suites/ed25519-2020/v1"],"type":["VerifiablePresentation"],"verifiableCredential":[{"@context":["https://www.w3.org/2018/credentials/v1",{"hs":"https://jagrat.hypersign.id/rest/hypersign-protocol/hidnode/ssi/schema/sch:hid:testnet:zFJ8qPmgAUw6udxzeuFQqwAmCtZZk39HGLottMSs9ztHv:1.1:"},{"email":"hs:email"},{"name":"hs:name"},{"modelname":"hs:modelname"},{"rollno":"hs:rollno"},"https://w3id.org/security/suites/ed25519-2020/v1"],"id":"vc:hid:testnet:z2iMa5hEXkfT4yvHbg6Krw5GrVUSpvuDqbcaELSqfu6mk","type":["VerifiableCredential","Email Schema Test"],"expirationDate":"2027-12-10T18:30:00Z","issuanceDate":"2022-12-19T09:07:02Z","issuer":"did:hid:testnet:z9vP8jZ3ZCNWtCVqoW7jjs6q4KgkULh3iunPLnc8my9cB","credentialSubject":{"email":"vishwas@anand.com","name":"Vishwas Anand Bhushan","modelname":"abcd","id":"did:hid:testnet:z44r9SLdy8nzuh9T1Q4tjH9ShagoPcpUZ8LpgBvUkrZAH"},"credentialSchema":{"id":"sch:hid:testnet:zFJ8qPmgAUw6udxzeuFQqwAmCtZZk39HGLottMSs9ztHv:1.1","type":"JsonSchemaValidator2018"},"credentialStatus":{"id":"https://jagrat.hypersign.id/rest/hypersign-protocol/hidnode/ssi/credential/vc:hid:testnet:z2iMa5hEXkfT4yvHbg6Krw5GrVUSpvuDqbcaELSqfu6mk","type":"CredentialStatusList2017"},"proof":{"type":"Ed25519Signature2020","created":"2022-12-19T09:08:42Z","verificationMethod":"did:hid:testnet:z9vP8jZ3ZCNWtCVqoW7jjs6q4KgkULh3iunPLnc8my9cB#key-1","proofPurpose":"assertionMethod","proofValue":"zt7iYmyHRYDnw3PrZkdtyiunwtCAYh25jZB87QtLV3DB89wshAfCRGquE7DGsprfGuUCUq4sGQpv67WpCEUs2aRE"}}],"id":"vp:hid:testnet:zD78ha3B78auEgmrg9zk8aMyWirzaHbNx71WPibZwBKCP","holder":"did:hid:testnet:z44r9SLdy8nzuh9T1Q4tjH9ShagoPcpUZ8LpgBvUkrZAH","proof":{"type":"Ed25519Signature2020","created":"2022-12-19T09:08:50Z","verificationMethod":"did:hid:testnet:z44r9SLdy8nzuh9T1Q4tjH9ShagoPcpUZ8LpgBvUkrZAH#key-1","proofPurpose":"authentication","challenge":"12312301231231jnj12n3123123s","proofValue":"zeRRMSQ9QTcqf4PuPWsKvYwmdugcjhXc3bgzHyE3CakuYPVf92YDCx48incrMgYf3rJNhiSmWKAfU5Wt3dQUpazC"}} \ No newline at end of file diff --git a/test/ssi/credentials/test1.js b/test/ssi/credentials/test1.js deleted file mode 100644 index 3e8039a..0000000 --- a/test/ssi/credentials/test1.js +++ /dev/null @@ -1,110 +0,0 @@ -/** - * - Testing create, sign, verify VC using custom schema - * - Testing create, sign, verify VP - * - Testing of private and public did - */ - -const HypersignSsiSDK = require('../../../build/src') -const { createWallet, mnemonic, hidNodeEp, writeDataInFile } = require('../../config') -const issuerDidDoc = require('../../mock/public/did.json') -const { id: schemaId } = require('../../mock/public/schema.json') -const { privateKeyMultibase } = require('../../mock/public/keys.json') - -const holderSignedDIDDoc = require('../../mock/private/signed-did.json') - - -let hsSdk; -let unsignedVc; -let signedVC; -let unsignedVp; -let signedVP; -const challenge = "12312301231231jnj12n3123123s" -const subjectDid = holderSignedDIDDoc.id -console.log(subjectDid) -const issuerDid = issuerDidDoc.id; -const privateKey = privateKeyMultibase; - -createWallet(mnemonic) - .then((offlineSigner) => { - hsSdk = new HypersignSsiSDK(offlineSigner, hidNodeEp.rpc, hidNodeEp.rest, hidNodeEp.namespace); - return hsSdk.init(); - }) - .then(() => { - const fields = { - email: "vishwas@anand.com", - name: "Vishwas Anand Bhushan", - modelname: "abcd" - }; - const expirationDate = new Date('12/11/2027'); - console.log('================Genenrate Verifiable Credential================') - return hsSdk.vc.getCredential({ - schemaId, - subjectDidDocSigned: holderSignedDIDDoc, - issuerDid, - expirationDate, - fields - }) - }) - .then((vc) => { - console.log(JSON.stringify(vc, null, 2)) - unsignedVc = vc; - console.log('================Issue Verifiable Credential================') - return hsSdk.vc.issueCredential({ - credential: vc, - issuerDid, - privateKey, - verificationMethodId:issuerDidDoc.assertionMethod[0] - }) - }) - .then((svc) => { - writeDataInFile('../../mock/vc.json', JSON.stringify(svc)) - console.log(JSON.stringify(svc, null, 2)) - signedVC = svc; - console.log('================Verify Verifiable Credential================') - return hsSdk.vc.verifyCredential({ credential: svc, issuerDid ,verificationMethodId:issuerDidDoc.assertionMethod[0]}) - }) - .then((result) => { - console.log(result) - }) - - - .then(() => { - console.log('================Generate Verifiable Presenatation Unsigned VC: ================') - return hsSdk.vp.getPresentation({ - verifiableCredentials: [unsignedVc], - holderDid: subjectDid - }) - }) - .then(vp => { - console.log(JSON.stringify(vp, null, 2)) - unsignedVp = vp; - console.log('================Sign Verifiable Presenatation================') - return hsSdk.vp.signPresentation({ - presentation: unsignedVp, - holderDidDocSigned: holderSignedDIDDoc, - privateKey, - challenge, - verificationMethodId:holderSignedDIDDoc.assertionMethod[0] - }) - }) - .then(svp => { - console.log(JSON.stringify(svp, null, 2)) - writeDataInFile('../../mock/vp.json', JSON.stringify(svp)) - signedVP = svp; - console.log('================Verify Verifiable Presenatation================') - return hsSdk.vp.verifyPresentation({ - signedPresentation: signedVP, - challenge, - domain: "https://localhos:20202", - issuerDid, - holderDidDocSigned: holderSignedDIDDoc, - holderVerificationMethodId:holderSignedDIDDoc.authentication[0], - issuerVerificationMethodId:issuerDidDoc.assertionMethod[0] - }) - }) - .then(result => { - console.log(result) - }) - .catch((e) => { - console.error(e) - }) \ No newline at end of file diff --git a/test/ssi/credentials/test2.js b/test/ssi/credentials/test2.js deleted file mode 100644 index 3a2de96..0000000 --- a/test/ssi/credentials/test2.js +++ /dev/null @@ -1,224 +0,0 @@ -/** - * - Testing schema which are not registered in Hypersign Network - * - Supporting Multiple Credentials while creating presentation - */ - -const {HypersignVerifiableCredential} = require("../../../build/src") -const { createWallet, mnemonic, hidNodeEp, writeDataInFile } = require("../../config") -const { privateKeyMultibase } = require('../../mock/public/keys.json') -const issuerDidDoc = require('../../mock/public/did.json') -const otherVc = require('../../mock/vc.json'); -const path = require('path'); - - -async function test2() { - const issuerDid = issuerDidDoc.id; - const subjectDid = issuerDidDoc.id;; - - const offlineSigner = await createWallet(mnemonic); - const hsSdk = new HypersignVerifiableCredential({ - offlineSigner, nodeRpcEndpoint:'https://rpc.jagrat.hypersign.id', nodeRestEndpoint:'https://api.jagrat.hypersign.id', namespace: 'testnet' - }); - await hsSdk.init() - - const expirationDate = new Date('12/11/2027'); - const context = [ "https://schema.org"] // proving schemas which are not registered in hypersign - - - const fields = { - "address": { - "@type": "PostalAddress", - "addressLocality": "Seattle", - "addressRegion": "WA", - "postalCode": "98052", - "streetAddress": "20341 Whitworth Institute 405 N. Whitworth" - }, - "email": "mailto:jane-doe@xyz.edu", - "image": "janedoe.jpg", - "jobTitle": "Professor", - "name": "Jane Doe", - "telephone": "(425) 123-4567", - "url": "http://www.janedoe.com", - "id": "did:hid:devnet:zHByfNVfzzLD15nkpdpwYLkvkkPdGgdppznXUxTJ1Ws8v", - "diagonsis": { - "alternateName": "angina pectoris", - "associatedAnatomy": { - "@type": "AnatomicalStructure", - "name": "heart" - }, - "cause": [ - { - "@type": "MedicalCause", - "name": "atherosclerosis" - }, - { - "@type": "MedicalCause", - "name": "spasms of the epicardial artery" - } - ], - "code": { - "@type": "MedicalCode", - "code": "413", - "codingSystem": "ICD-9" - }, - "differentialDiagnosis": { - "@type": "DDxElement", - "diagnosis": { - "@type": "MedicalCondition", - "name": "heart attack" - }, - "distinguishingSign": [ - { - "@type": "MedicalSymptom", - "name": "chest pain lasting at least 10 minutes at rest" - }, - { - "@type": "MedicalSymptom", - "name": "repeated episodes of chest pain at rest lasting 5 or more minutes" - }, - { - "@type": "MedicalSymptom", - "name": "an accelerating pattern of chest discomfort (episodes that are more frequent, severe, longer in duration, and precipitated by minimal exertion)" - } - ] - }, - "name": "Stable angina", - "possibleTreatment": [ - { - "@type": "Drug", - "name": "aspirin" - }, - { - "@type": "DrugClass", - "name": "beta blockers" - }, - { - "@type": "DrugClass", - "name": "ACE inhibitors" - }, - { - "@type": "Drug", - "name": "nitroglycerine" - } - ], - "riskFactor": [ - { - "@type": "MedicalRiskFactor", - "name": "Age" - }, - { - "@type": "MedicalRiskFactor", - "name": "Gender" - }, - { - "@type": "MedicalRiskFactor", - "name": "Systolic blood pressure" - }, - { - "@type": "MedicalRiskFactor", - "name": "Smoking" - }, - { - "@type": "MedicalRiskFactor", - "name": "Total cholesterol and/or cholesterol:HDL ratio" - }, - { - "@type": "MedicalRiskFactor", - "name": "Coronary artery disease" - } - ], - "secondaryPrevention": [ - { - "@type": "LifestyleModification", - "name": "stopping smoking" - }, - { - "@type": "LifestyleModification", - "name": "weight management" - }, - { - "@type": "LifestyleModification", - "name": "increased physical activity" - } - ], - "signOrSymptom": [ - { - "@type": "MedicalSymptom", - "name": "chest discomfort" - }, - { - "@type": "MedicalSymptom", - "name": "feeling of tightness, heaviness, or pain in the chest" - } - ] - }, - - - } - - console.log('Genenrate VC ==========') - const creadential=await hsSdk.generate({ - schemaContext: context, - type: ['Patient'], - subjectDid, - issuerDid, - fields, - expirationDate - }) - - console.log(JSON.stringify(creadential, null, 2)); - - console.log('Issue VC ==========') - const issueCread=await hsSdk.issue({ - credential: creadential, - issuerDid, - verificationMethodId:issuerDidDoc.assertionMethod[0] , - privateKeyMultibase: privateKeyMultibase - }) - const filePath = path.join(__dirname, '../../mock/vc-with-schema-org.json') - console.log(filePath); - writeDataInFile(filePath, JSON.stringify(issueCread)) - console.log(JSON.stringify(issueCread, null, 2)); - - console.log('Verify VC ==========') - const verifiableCreadStatus = await hsSdk.verify({ credential: issueCread.signedCredential, - issuerDid,verificationMethodId:issueCread.signedCredential.proof.verificationMethod }) - console.log(verifiableCreadStatus); - - console.log('Generate VP ==========') - const unsignedVp = await hsSdk.vp.getPresentation({ - verifiableCredentials: [ issueCread, otherVc ], // adding two credentials to check if both credentials can be verified - holderDid: subjectDid, - }) - console.log(unsignedVp); - - console.log('Sign VP ==========') - const SignedPresentation = await hsSdk.vp.signPresentation({ - presentation: unsignedVp, - holderDid: subjectDid, - privateKey: privateKeyMultibase, - challenge: '123', - domain: 'example.com', - verificationMethodId: issuerDidDoc.assertionMethod[0] - }) - - console.log(JSON.stringify(SignedPresentation, null, 2)); - const vpfilePath = path.join(__dirname, '../../mock/vp-with-multi-vc.json') - writeDataInFile(vpfilePath, JSON.stringify(SignedPresentation)) - console.log('Verify VP ==========') - const verify = await hsSdk.vp.verifyPresentation({ - signedPresentation: SignedPresentation, - challenge: '123', - domain: 'example.com', - issuerDid, - holderDid: subjectDid, - holderVerificationMethodId: issuerDidDoc.authentication[0], - issuerVerificationMethodId: issuerDidDoc.assertionMethod[0] - }) - console.log(verify); -} - - -test2() - - diff --git a/test/ssi/credentials/updateCredStatus.js b/test/ssi/credentials/updateCredStatus.js deleted file mode 100644 index ba598bb..0000000 --- a/test/ssi/credentials/updateCredStatus.js +++ /dev/null @@ -1,96 +0,0 @@ -/** - * - Testing create, sign, verify VC using custom schema - * - Testing create, sign, verify VP - * - Testing of private and public did - */ - -const HypersignSsiSDK = require('../../../build/src') -const { createWallet, mnemonic, hidNodeEp, writeDataInFile } = require('../../config') -const issuerDidDoc = require('../../mock/public/did.json') -const { id: schemaId } = require('../../mock/public/schema.json') -const { privateKeyMultibase } = require('../../mock/public/keys.json') - -const holderSignedDIDDoc = require('../../mock/private/signed-did.json') -const { default: Axios } = require('axios') - - -let hsSdk; -let unsignedVc; -let signedVC; -let unsignedVp; -let signedVP; -const challenge = "12312301231231jnj12n3123123s" -const subjectDid = holderSignedDIDDoc.id -console.log(subjectDid) -const issuerDid = issuerDidDoc.id; -const privateKey = privateKeyMultibase; - -createWallet(mnemonic) - .then((offlineSigner) => { - hsSdk = new HypersignSsiSDK(offlineSigner, hidNodeEp.rpc, hidNodeEp.rest, hidNodeEp.namespace); - return hsSdk.init(); - }) - .then(() => { - const fields = { - email: "vishwas@anand.com", - name: "Vishwas Anand Bhushan", - modelname: "abcd" - }; - const expirationDate = new Date('12/11/2027'); - console.log('================Genenrate Verifiable Credential================') - return hsSdk.vc.getCredential({ - schemaId, - subjectDidDocSigned: holderSignedDIDDoc, - issuerDid, - expirationDate, - fields - }) - }) - .then((vc) => { - console.log(JSON.stringify(vc, null, 2)) - unsignedVc = vc; - console.log('================Issue Verifiable Credential================') - return hsSdk.vc.issueCredential({ - credential: vc, - issuerDid, - privateKey, - verificationMethodId: issuerDidDoc.assertionMethod[0] - }) - }) - .then((svc) => { - writeDataInFile('../../mock/Before-revoke-vc.json', JSON.stringify(svc)) - console.log(JSON.stringify(svc, null, 2)) - signedVC = svc; - console.log('================Verify Verifiable Credential================') - return hsSdk.vc.verifyCredential({ credential: svc, issuerDid, verificationMethodId: issuerDidDoc.assertionMethod[0] }) - }) - .then((result) => { - console.log(result) - }) - - .then(async () => { - console.log('================Revoke Verifiable Credential================') - const credentialStatus = await Axios.get(signedVC.credentialStatus.id) - const {credStatus}= credentialStatus.data - return hsSdk.vc.updateCredentialStatus({ - credStatus, - issuerDid, - privateKey, - verificationMethodId: issuerDidDoc.assertionMethod[0], - status: 'SUSPENDED', - statusReason: 'I am the issuer i can do whatever' - }) - }) - .then((result) => { - console.log(JSON.stringify(result, null, 2)) - writeDataInFile('../../mock/After-revoke-vc.json', JSON.stringify(result)) - - console.log('================Verify Verifiable Credential================') - return hsSdk.vc.verifyCredential({ credential: signedVC, issuerDid, verificationMethodId: issuerDidDoc.assertionMethod[0] }) - - - }).then((result) => { - console.log("===================Verification after revocation ====================") - - console.log(result) - }) diff --git a/test/ssi/did.js b/test/ssi/did.js deleted file mode 100644 index 12b8d20..0000000 --- a/test/ssi/did.js +++ /dev/null @@ -1,104 +0,0 @@ -const { createWallet, writeDataInFile, mnemonic, hidNodeEp } = require('../config') -const HypersignSsiSDK = require('../../build/src') -const {Bip39}=require('@cosmjs/crypto') -let hsSdk = null; -let didDocString; -let versionId; -let verificationMethodId; -let didDoc; -let privateKeyMultibase; -let offlineSigner; -const challenge = "1231231231"; -const domain = "www.adbv.com"; -createWallet(mnemonic) - .then(async(offlineSigner11) => { - offlineSigner=offlineSigner11 - console.log("offlineSigner", offlineSigner); - const accounts = await offlineSigner.getAccounts(); - console.log(accounts) - hsSdk = new HypersignSsiSDK(offlineSigner, hidNodeEp.rpc, hidNodeEp.rest, hidNodeEp.namespace); - return hsSdk.init(); - }) - .then(async() => { - console.log("===============GENERATE DID-KEYS=======================") - // const param = "blade sting surge cube valid scr"; // 32 bytes - const seed=Bip39.decode(mnemonic) - const kp = await hsSdk.did.generateKeys(); - console.log("kp", kp); - writeDataInFile('../mock/public/keys.json', JSON.stringify(kp)) - privateKeyMultibase = kp.privateKeyMultibase - const publicKeyMultibase = kp.publicKeyMultibase - console.log(kp) - console.log("===============GENERATE DID&DIDDoc=======================") - return hsSdk.did.generate({ publicKeyMultibase}); - - }) - .then((res) => { - console.log(res) - didDocString = JSON.stringify(res); - writeDataInFile('../mock/public/did.json',didDocString) - didDoc = res; - verificationMethodId = didDoc['verificationMethod'][0].id - console.log("===============SIGN DID=======================") - return hsSdk.did.signDid({ privateKey: privateKeyMultibase, challenge, domain, doc: didDoc, verificationMethodId }); - }) - .then((signedDidDoc) => { - const { signedDidDocument } = signedDidDoc; - console.log(signedDidDocument) - writeDataInFile('../mock/public/signed-did.json',JSON.stringify(signedDidDocument)) - console.log("===============VERIFY DID=======================") - return hsSdk.did.verify({ doc : signedDidDocument, verificationMethodId, challenge, domain }) - }) - .then((result) => { - console.log(result.verificationResult) - }) - .then(() => { - verificationMethodId = didDoc['verificationMethod'][0].id - console.log("===============REGISTER DID=======================") - return hsSdk.did.register({ didDocument: didDoc , privateKeyMultibase, verificationMethodId }) - }) - .then((resTx) => { - console.log(resTx) - console.log("===============RESOLVE DID=======================") - return hsSdk.did.resolve({ did: didDoc["id"],ed25519verificationkey2020:true }) - }) - .then(res => { - console.log(JSON.stringify(res, null, 2)) - const { didDocumentMetadata } = res; - versionId = didDocumentMetadata.versionId; - - /// updating some data - didDoc.service.push({ - "id": didDoc.id + "#vcs", - "type": "LinkedDomains", - "serviceEndpoint": "https://example.com/vc" - }) - - console.log("===============DID Update=======================") - return hsSdk.did.update({ didDocument: didDoc, privateKeyMultibase, verificationMethodId, versionId }) - }) - .then((resTx) => { - console.log(resTx) - console.log("===============RESOLVE DID=======================") - return hsSdk.did.resolve({ did: didDoc["id"] }) - }) - .then(res => { - console.log(res) - console.log("===============DID Deactivate=======================") - const { didDocumentMetadata, didDocument } = res; - didDocString = JSON.stringify(didDocument) - writeDataInFile('../mock/public/did.json', didDocString) - versionId = didDocumentMetadata.versionId; - return ""// hsSdk.did.deactivate({ didDocument: didDoc, privateKeyMultibase, verificationMethodId, versionId }) - }) - .then((resTx) => { - console.log(resTx) - console.log("===============RESOLVE DID=======================") - return hsSdk.did.resolve({ did: didDoc["id"] }) - }) - .then(res => { - console.log(res) - }) - .catch((e) => { - console.error(e) - }) \ No newline at end of file diff --git a/test/ssi/private-did.js b/test/ssi/private-did.js deleted file mode 100644 index 036acd9..0000000 --- a/test/ssi/private-did.js +++ /dev/null @@ -1,57 +0,0 @@ -const { createWallet, writeDataInFile, mnemonic, hidNodeEp } = require('../config') -const HypersignSsiSDK = require('../../build/src') -const {Bip39}=require('@cosmjs/crypto') -let hsSdk = null; -let didDocString; -let versionId; -let verificationMethodId; -let didDoc; -let privateKeyMultibase; -let offlineSigner; -const challenge = "1231231231"; -const domain = "www.adbv.com"; -createWallet(mnemonic) - .then(async(offlineSigner11) => { - offlineSigner=offlineSigner11 - console.log("offlineSigner", offlineSigner); - const accounts = await offlineSigner.getAccounts(); - console.log(accounts) - hsSdk = new HypersignSsiSDK(offlineSigner, hidNodeEp.rpc, hidNodeEp.rest, hidNodeEp.namespace); - return hsSdk.init(); - }) - .then(async() => { - console.log("===============GENERATE DID-KEYS=======================") - // const param = "blade sting surge cube valid scr"; // 32 bytes - const seed=Bip39.decode("three image merge verb tenant divert modify million hotel decade hurt alien loop illegal day judge beyond anxiety term there improve mad gossip shallow") - const kp = await hsSdk.did.generateKeys({seed}); - console.log("kp", kp); - writeDataInFile('../mock/private/keys.json', JSON.stringify(kp)) - privateKeyMultibase = kp.privateKeyMultibase - const publicKeyMultibase = kp.publicKeyMultibase - console.log(kp) - console.log("===============GENERATE DID&DIDDoc=======================") - return hsSdk.did.generate({ publicKeyMultibase }); - - }) - .then((res) => { - console.log(res) - didDocString = JSON.stringify(res); - writeDataInFile('../mock/private/did.json',didDocString) - didDoc = res; - verificationMethodId = didDoc['verificationMethod'][0].id - console.log("===============SIGN DID=======================") - return hsSdk.did.signDid({ privateKey: privateKeyMultibase, challenge, domain, doc: didDoc, verificationMethodId }); - }) - .then((signedDidDoc) => { - const { signedDidDocument } = signedDidDoc; - console.log(signedDidDocument) - writeDataInFile('../mock/private/signed-did.json',JSON.stringify(signedDidDocument)) - console.log("===============VERIFY DID=======================") - return hsSdk.did.verify({ doc : signedDidDocument, verificationMethodId, challenge, domain }) - }) - .then((result) => { - console.log(result.verificationResult) - }) - .catch((e) => { - console.error(e) - }) \ No newline at end of file diff --git a/test/ssi/schema.js b/test/ssi/schema.js deleted file mode 100644 index 9420260..0000000 --- a/test/ssi/schema.js +++ /dev/null @@ -1,116 +0,0 @@ -const { props, writeDataInFile, createWallet, mnemonic, hidNodeEp } = require('../config') -const HypersignSsiSDK = require('../../build/src') -const { privateKeyMultibase } = require('../mock/public/keys.json') -const { verificationMethod, id, assertionMethod } = require('../mock/public/did.json') - - -console.log({ - verificationMethod, - id, - privateKeyMultibase -}) -if (!privateKeyMultibase || !verificationMethod || !id) { - throw new Error('Please run did test case before proceeding') -} - -const author = id; -let hsSdk; -let schema; -let proof = { - "type": "Ed25519Signature2020", - "created": "", - "verificationMethod": assertionMethod[0], - "proofValue": "", - "proofPurpose": "assertion" -} -createWallet(mnemonic) - .then((offlineSigner) => { - hsSdk = new HypersignSsiSDK(offlineSigner, hidNodeEp.rpc, hidNodeEp.rest, hidNodeEp.namespace); - return hsSdk.init(); - }) - .then(() => { - console.log("======Generate Schema=====") - const schemaOptions = { - name: "Email Schema Test", - author, - schemaProperty: { - properties: [{ - name: "email", - type: "string", - format: "email", - isRequired: true - }, - { - name: "name", - type: "string", - isRequired: true - }, - { - name: "modelname", - type: "string", - isRequired: false - } - ], - }, - - } - return hsSdk.schema.getSchema({ - name: schemaOptions.name, - description: "This is email credential test", - author: schemaOptions.author, - additionalProperties: false, - fields: schemaOptions.schemaProperty.properties, - }) - }) - .then((schemaLocal) => { - schema = schemaLocal - console.log(schema) - console.log("========Sign Schema=======") - const privKey = privateKeyMultibase - return hsSdk.schema.signSchema({ privateKey: privKey, schema }) - }) - .then(signature => { - console.log("Signature: ", signature) - console.log("=========Register Schema========") - proof.proofValue = signature - proof.created = schema.authored - console.log(schema, proof); - return hsSdk.schema.registerSchema({ schema, proof }) - }).then(res => { - console.log("=========Resolve Schema========") - console.log(res) - return hsSdk.schema.resolve({ schemaId: schema.id }) - }).then(res => { - writeDataInFile('../mock/public/schema.json', JSON.stringify(res)) - console.log(JSON.stringify(res, null, 2)) - }) - - .then(() => { - console.log("=========Edit Schema========") - - const properties=JSON.parse(schema.schema.properties) - properties.rollno={type:"string"} - schema.schema.properties=JSON.stringify(properties) - let schemaId=schema.id - schemaId=schemaId.replace("1.0","1.1") - schema.id=schemaId - - console.log("========Sign Schema=======") - const privKey = privateKeyMultibase - return hsSdk.schema.signSchema({ privateKey: privKey, schema }) - }) - .then(signature => { - console.log("Signature: ", signature) - console.log("=========Register Schema========") - proof.proofValue = signature - proof.created = schema.authored - console.log(schema, proof); - return hsSdk.schema.registerSchema({ schema, proof }) - }).then(res => { - console.log("=========Resolve Schema========") - console.log(res) - return hsSdk.schema.resolve({ schemaId: schema.id }) - }).then(res => { - writeDataInFile('../mock/public/schema.json', JSON.stringify(res)) - console.log(JSON.stringify(res, null, 2)) - }) \ No newline at end of file diff --git a/tsconfig.json b/tsconfig.json index 4ffd8de..c819580 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -21,7 +21,7 @@ // "importHelpers": true, /* Import emit helpers from 'tslib'. */ // "downlevelIteration": true, /* Provide full support for iterables in 'for-of', spread, and destructuring when targeting 'ES5' or 'ES3'. */ // "isolatedModules": true, /* Transpile each file as a separate module (similar to 'ts.transpileModule'). */ - + "skipLibCheck":true, /* Strict Type-Checking Options */ "strict": true /* Enable all strict type-checking options. */, "noImplicitAny": false /* Raise error on expressions and declarations with an implied 'any' type. */, @@ -63,5 +63,5 @@ /* Advanced Options */ "forceConsistentCasingInFileNames": true /* Disallow inconsistently-cased references to the same file. */ - } + }, }