diff --git a/dist/api/ApiPrimitive.d.ts b/dist/api/ApiPrimitive.d.ts index 803d340..0ec967d 100644 --- a/dist/api/ApiPrimitive.d.ts +++ b/dist/api/ApiPrimitive.d.ts @@ -3,7 +3,8 @@ import { IdentityDefinition } from "../identity/IdentityDefinition"; import { OfferForMaking } from "../offers/OfferForMaking"; import { ListedOffer } from "../offers/OfferList"; import { RawTransaction } from "../transaction/RawTransaction"; -export declare type ApiPrimitive = string | number | boolean | null | OfferForMaking | ApiPrimitiveJson | ListedOffer | Array | IdentityDefinition | BlockInfo | RawTransaction; +import { SignDataArgs } from "./classes/SignData/SignDataRequest"; +export declare type ApiPrimitive = string | number | boolean | null | OfferForMaking | ApiPrimitiveJson | ListedOffer | Array | IdentityDefinition | BlockInfo | RawTransaction | SignDataArgs; export declare type ApiPrimitiveJson = { [key: string]: ApiPrimitive | undefined; }; diff --git a/dist/api/classes/SignData/SignDataRequest.d.ts b/dist/api/classes/SignData/SignDataRequest.d.ts new file mode 100644 index 0000000..d0f83ca --- /dev/null +++ b/dist/api/classes/SignData/SignDataRequest.d.ts @@ -0,0 +1,31 @@ +import { ApiRequest } from "../../ApiRequest"; +import { ApiPrimitiveJson, RequestParams } from "../../ApiPrimitive"; +import { DataDescriptorInfo } from "../../../utils/types/DataDescriptor"; +import { SignDataParameters } from "../../../utils/types/SignData"; +export declare type SignDataArgs = { + address?: string; + filename?: string; + message?: string; + messagehex?: string; + messsagebase64?: string; + datahash?: string; + vdxfdata?: string; + mmrdata?: Array; + mmrsalt?: Array; + mmrhashtype?: string; + priormmr?: Array; + vdxfkeys?: Array; + vdxfkeynames?: Array; + boundhahses?: Array; + hashtype?: string; + signature?: string; + encrypttoaddress?: string; + createmmr?: boolean; +}; +export declare class SignDataRequest extends ApiRequest { + data: SignDataArgs; + constructor(chain: string, signableItems: SignDataArgs); + getParams(): RequestParams; + static fromJson(object: ApiPrimitiveJson): SignDataRequest; + toJson(): ApiPrimitiveJson; +} diff --git a/dist/api/classes/SignData/SignDataRequest.js b/dist/api/classes/SignData/SignDataRequest.js new file mode 100644 index 0000000..cee3cd8 --- /dev/null +++ b/dist/api/classes/SignData/SignDataRequest.js @@ -0,0 +1,25 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.SignDataRequest = void 0; +const ApiRequest_1 = require("../../ApiRequest"); +const cmds_1 = require("../../../constants/cmds"); +class SignDataRequest extends ApiRequest_1.ApiRequest { + constructor(chain, signableItems) { + super(chain, cmds_1.SIGN_DATA); + this.data = signableItems; + } + getParams() { + const params = [this.data]; + return params.filter((x) => x != null); + } + static fromJson(object) { + return new SignDataRequest(object.chain, object.data); + } + toJson() { + return { + chain: this.chain, + data: this.data, + }; + } +} +exports.SignDataRequest = SignDataRequest; diff --git a/dist/api/classes/SignData/SignDataResponse.d.ts b/dist/api/classes/SignData/SignDataResponse.d.ts new file mode 100644 index 0000000..df9019c --- /dev/null +++ b/dist/api/classes/SignData/SignDataResponse.d.ts @@ -0,0 +1,23 @@ +import { ApiResponse } from "../../ApiResponse"; +import { SignatureDataInfo } from "../../../utils/types/Signature"; +import { MmrDescriptorParameters } from "../../../utils/types/MmrDescriptor"; +import { DataDescriptorInfo } from "../../../utils/types/DataDescriptor"; +export declare class SignDataResponse extends ApiResponse { + result: { + mmrdescriptor_encrypted?: MmrDescriptorParameters; + mmrdescriptor?: MmrDescriptorParameters; + signature?: string; + signaturedata_encrypted?: DataDescriptorInfo; + signaturedata_ssk?: string; + signaturedata?: SignatureDataInfo; + system?: string; + systemid?: string; + hashtype?: string; + mmrhashtype?: string; + hash?: string; + identity?: string; + canonicalname?: string; + address?: string; + signatureheight?: number; + }; +} diff --git a/dist/api/classes/SignData/SignDataResponse.js b/dist/api/classes/SignData/SignDataResponse.js new file mode 100644 index 0000000..fe83e95 --- /dev/null +++ b/dist/api/classes/SignData/SignDataResponse.js @@ -0,0 +1,7 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.SignDataResponse = void 0; +const ApiResponse_1 = require("../../ApiResponse"); +class SignDataResponse extends ApiResponse_1.ApiResponse { +} +exports.SignDataResponse = SignDataResponse; diff --git a/dist/api/classes/index.d.ts b/dist/api/classes/index.d.ts index 4419a1f..31b7f1a 100644 --- a/dist/api/classes/index.d.ts +++ b/dist/api/classes/index.d.ts @@ -25,6 +25,8 @@ import { SendRawTransactionRequest } from './SendRawTransaction/SendRawTransacti import { SendRawTransactionResponse } from './SendRawTransaction/SendRawTransactionResponse'; import { SignMessageRequest } from './SignMessage/SignMessageRequest'; import { SignMessageResponse } from './SignMessage/SignMessageResponse'; +import { SignDataRequest } from './SignData/SignDataRequest'; +import { SignDataResponse } from './SignData/SignDataResponse'; import { VerifyMessageRequest } from './VerifyMessage/VerifyMessageRequest'; import { VerifyMessageResponse } from './VerifyMessage/VerifyMessageResponse'; import { GetAddressMempoolResponse } from './GetAddressMempool/GetAddressMempoolResponse'; @@ -41,6 +43,6 @@ import { EstimateConversionRequest } from './EstimateConversion/EstimateConversi import { EstimateConversionResponse } from './EstimateConversion/EstimateConversionResponse'; import { ZGetOperationStatusRequest } from './ZGetOperationStatus/ZGetOperationStatusRequest'; import { ZGetOperationStatusResponse } from './ZGetOperationStatus/ZGetOperationStatusResponse'; -export { GetAddressBalanceRequest, GetAddressBalanceResponse, GetAddressDeltasRequest, GetAddressDeltasResponse, GetAddressMempoolRequest, GetAddressMempoolResponse, GetAddressUtxosRequest, GetAddressUtxosResponse, GetBlockRequest, GetBlockResponse, GetVdxfIdRequest, GetVdxfIdResponse, GetIdentityRequest, GetIdentityContentRequest, GetIdentityResponse, GetCurrencyRequest, GetCurrencyResponse, GetOffersRequest, GetOffersResponse, GetRawTransactionRequest, GetRawTransactionResponse, MakeOfferRequest, MakeOfferResponse, SendRawTransactionRequest, SendRawTransactionResponse, GetInfoRequest, GetInfoResponse, VerifyMessageRequest, VerifyMessageResponse, SignMessageRequest, SignMessageResponse, SendCurrencyRequest, SendCurrencyResponse, FundRawTransactionRequest, FundRawTransactionResponse, GetCurrencyConvertersRequest, GetCurrencyConvertersResponse, ListCurrenciesRequest, ListCurrenciesResponse, EstimateConversionRequest, EstimateConversionResponse, ZGetOperationStatusRequest, ZGetOperationStatusResponse }; -export declare type RpcRequest = typeof MakeOfferRequest | typeof GetOffersRequest | typeof GetAddressBalanceRequest | typeof GetAddressDeltasRequest | typeof GetAddressMempoolRequest | typeof GetAddressUtxosRequest | typeof GetBlockRequest | typeof GetVdxfIdRequest | typeof GetInfoRequest | typeof GetIdentityRequest | typeof GetIdentityContentRequest | typeof GetCurrencyRequest | typeof SendRawTransactionRequest | typeof GetRawTransactionRequest | typeof VerifyMessageRequest | typeof SignMessageRequest | typeof SendCurrencyRequest | typeof FundRawTransactionRequest | typeof GetCurrencyConvertersRequest | typeof ListCurrenciesRequest | typeof EstimateConversionRequest | typeof ZGetOperationStatusRequest; -export declare type RpcResponse = typeof MakeOfferResponse | typeof GetOffersResponse | typeof GetAddressBalanceResponse | typeof GetAddressDeltasResponse | typeof GetAddressMempoolResponse | typeof GetAddressUtxosResponse | typeof GetBlockResponse | typeof GetVdxfIdResponse | typeof GetInfoResponse | typeof GetIdentityResponse | typeof GetCurrencyResponse | typeof SendRawTransactionResponse | typeof GetRawTransactionResponse | typeof VerifyMessageResponse | typeof SignMessageResponse | typeof SendCurrencyResponse | typeof FundRawTransactionResponse | typeof GetCurrencyConvertersResponse | typeof ListCurrenciesResponse | typeof EstimateConversionResponse | typeof ZGetOperationStatusResponse; +export { GetAddressBalanceRequest, GetAddressBalanceResponse, GetAddressDeltasRequest, GetAddressDeltasResponse, GetAddressMempoolRequest, GetAddressMempoolResponse, GetAddressUtxosRequest, GetAddressUtxosResponse, GetBlockRequest, GetBlockResponse, GetVdxfIdRequest, GetVdxfIdResponse, GetIdentityRequest, GetIdentityContentRequest, GetIdentityResponse, GetCurrencyRequest, GetCurrencyResponse, GetOffersRequest, GetOffersResponse, GetRawTransactionRequest, GetRawTransactionResponse, MakeOfferRequest, MakeOfferResponse, SendRawTransactionRequest, SendRawTransactionResponse, GetInfoRequest, GetInfoResponse, VerifyMessageRequest, VerifyMessageResponse, SignMessageRequest, SignMessageResponse, SignDataRequest, SignDataResponse, SendCurrencyRequest, SendCurrencyResponse, FundRawTransactionRequest, FundRawTransactionResponse, GetCurrencyConvertersRequest, GetCurrencyConvertersResponse, ListCurrenciesRequest, ListCurrenciesResponse, EstimateConversionRequest, EstimateConversionResponse, ZGetOperationStatusRequest, ZGetOperationStatusResponse }; +export declare type RpcRequest = typeof MakeOfferRequest | typeof GetOffersRequest | typeof GetAddressBalanceRequest | typeof GetAddressDeltasRequest | typeof GetAddressMempoolRequest | typeof GetAddressUtxosRequest | typeof GetBlockRequest | typeof GetVdxfIdRequest | typeof GetInfoRequest | typeof GetIdentityRequest | typeof GetIdentityContentRequest | typeof GetCurrencyRequest | typeof SendRawTransactionRequest | typeof GetRawTransactionRequest | typeof VerifyMessageRequest | typeof SignMessageRequest | typeof SignDataRequest | typeof SendCurrencyRequest | typeof FundRawTransactionRequest | typeof GetCurrencyConvertersRequest | typeof ListCurrenciesRequest | typeof EstimateConversionRequest | typeof ZGetOperationStatusRequest; +export declare type RpcResponse = typeof MakeOfferResponse | typeof GetOffersResponse | typeof GetAddressBalanceResponse | typeof GetAddressDeltasResponse | typeof GetAddressMempoolResponse | typeof GetAddressUtxosResponse | typeof GetBlockResponse | typeof GetVdxfIdResponse | typeof GetInfoResponse | typeof GetIdentityResponse | typeof GetCurrencyResponse | typeof SendRawTransactionResponse | typeof GetRawTransactionResponse | typeof VerifyMessageResponse | typeof SignMessageResponse | typeof SignDataResponse | typeof SendCurrencyResponse | typeof FundRawTransactionResponse | typeof GetCurrencyConvertersResponse | typeof ListCurrenciesResponse | typeof EstimateConversionResponse | typeof ZGetOperationStatusResponse; diff --git a/dist/api/classes/index.js b/dist/api/classes/index.js index b4e330b..f63b412 100644 --- a/dist/api/classes/index.js +++ b/dist/api/classes/index.js @@ -1,6 +1,6 @@ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); -exports.ZGetOperationStatusResponse = exports.ZGetOperationStatusRequest = exports.EstimateConversionResponse = exports.EstimateConversionRequest = exports.ListCurrenciesResponse = exports.ListCurrenciesRequest = exports.GetCurrencyConvertersResponse = exports.GetCurrencyConvertersRequest = exports.FundRawTransactionResponse = exports.FundRawTransactionRequest = exports.SendCurrencyResponse = exports.SendCurrencyRequest = exports.SignMessageResponse = exports.SignMessageRequest = exports.VerifyMessageResponse = exports.VerifyMessageRequest = exports.GetInfoResponse = exports.GetInfoRequest = exports.SendRawTransactionResponse = exports.SendRawTransactionRequest = exports.MakeOfferResponse = exports.MakeOfferRequest = exports.GetRawTransactionResponse = exports.GetRawTransactionRequest = exports.GetOffersResponse = exports.GetOffersRequest = exports.GetCurrencyResponse = exports.GetCurrencyRequest = exports.GetIdentityResponse = exports.GetIdentityContentRequest = exports.GetIdentityRequest = exports.GetVdxfIdResponse = exports.GetVdxfIdRequest = exports.GetBlockResponse = exports.GetBlockRequest = exports.GetAddressUtxosResponse = exports.GetAddressUtxosRequest = exports.GetAddressMempoolResponse = exports.GetAddressMempoolRequest = exports.GetAddressDeltasResponse = exports.GetAddressDeltasRequest = exports.GetAddressBalanceResponse = exports.GetAddressBalanceRequest = void 0; +exports.ZGetOperationStatusResponse = exports.ZGetOperationStatusRequest = exports.EstimateConversionResponse = exports.EstimateConversionRequest = exports.ListCurrenciesResponse = exports.ListCurrenciesRequest = exports.GetCurrencyConvertersResponse = exports.GetCurrencyConvertersRequest = exports.FundRawTransactionResponse = exports.FundRawTransactionRequest = exports.SendCurrencyResponse = exports.SendCurrencyRequest = exports.SignDataResponse = exports.SignDataRequest = exports.SignMessageResponse = exports.SignMessageRequest = exports.VerifyMessageResponse = exports.VerifyMessageRequest = exports.GetInfoResponse = exports.GetInfoRequest = exports.SendRawTransactionResponse = exports.SendRawTransactionRequest = exports.MakeOfferResponse = exports.MakeOfferRequest = exports.GetRawTransactionResponse = exports.GetRawTransactionRequest = exports.GetOffersResponse = exports.GetOffersRequest = exports.GetCurrencyResponse = exports.GetCurrencyRequest = exports.GetIdentityResponse = exports.GetIdentityContentRequest = exports.GetIdentityRequest = exports.GetVdxfIdResponse = exports.GetVdxfIdRequest = exports.GetBlockResponse = exports.GetBlockRequest = exports.GetAddressUtxosResponse = exports.GetAddressUtxosRequest = exports.GetAddressMempoolResponse = exports.GetAddressMempoolRequest = exports.GetAddressDeltasResponse = exports.GetAddressDeltasRequest = exports.GetAddressBalanceResponse = exports.GetAddressBalanceRequest = void 0; const GetAddressBalanceRequest_1 = require("./GetAddressBalance/GetAddressBalanceRequest"); Object.defineProperty(exports, "GetAddressBalanceRequest", { enumerable: true, get: function () { return GetAddressBalanceRequest_1.GetAddressBalanceRequest; } }); const GetAddressBalanceResponse_1 = require("./GetAddressBalance/GetAddressBalanceResponse"); @@ -55,6 +55,10 @@ const SignMessageRequest_1 = require("./SignMessage/SignMessageRequest"); Object.defineProperty(exports, "SignMessageRequest", { enumerable: true, get: function () { return SignMessageRequest_1.SignMessageRequest; } }); const SignMessageResponse_1 = require("./SignMessage/SignMessageResponse"); Object.defineProperty(exports, "SignMessageResponse", { enumerable: true, get: function () { return SignMessageResponse_1.SignMessageResponse; } }); +const SignDataRequest_1 = require("./SignData/SignDataRequest"); +Object.defineProperty(exports, "SignDataRequest", { enumerable: true, get: function () { return SignDataRequest_1.SignDataRequest; } }); +const SignDataResponse_1 = require("./SignData/SignDataResponse"); +Object.defineProperty(exports, "SignDataResponse", { enumerable: true, get: function () { return SignDataResponse_1.SignDataResponse; } }); const VerifyMessageRequest_1 = require("./VerifyMessage/VerifyMessageRequest"); Object.defineProperty(exports, "VerifyMessageRequest", { enumerable: true, get: function () { return VerifyMessageRequest_1.VerifyMessageRequest; } }); const VerifyMessageResponse_1 = require("./VerifyMessage/VerifyMessageResponse"); diff --git a/dist/constants/cmds.d.ts b/dist/constants/cmds.d.ts index 7eaccc9..0206b69 100644 --- a/dist/constants/cmds.d.ts +++ b/dist/constants/cmds.d.ts @@ -13,6 +13,7 @@ export declare const GET_ADDRESS_MEMPOOL = "getaddressmempool"; export declare const SEND_RAW_TRANSACTION = "sendrawtransaction"; export declare const GET_ADDRESS_UTXOS = "getaddressutxos"; export declare const SIGN_MESSAGE = "signmessage"; +export declare const SIGN_DATA = "signdata"; export declare const VERIFY_MESSAGE = "verifymessage"; export declare const FUND_RAW_TRANSACTION = "fundrawtransaction"; export declare const SEND_CURRENCY = "sendcurrency"; diff --git a/dist/constants/cmds.js b/dist/constants/cmds.js index 6193bf7..4fd7e0f 100644 --- a/dist/constants/cmds.js +++ b/dist/constants/cmds.js @@ -1,6 +1,6 @@ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); -exports.Z_GET_OPERATION_STATUS = exports.ESTIMATE_CONVERSION = exports.LIST_CURRENCIES = exports.GET_CURRENCY_CONVERTERS = exports.SEND_CURRENCY = exports.FUND_RAW_TRANSACTION = exports.VERIFY_MESSAGE = exports.SIGN_MESSAGE = exports.GET_ADDRESS_UTXOS = exports.SEND_RAW_TRANSACTION = exports.GET_ADDRESS_MEMPOOL = exports.GET_ADDRESS_DELTAS = exports.GET_RAW_TRANSACTION = exports.GET_VDXF_ID = exports.GET_BLOCK = exports.GET_INFO = exports.GET_ADDRESS_BALANCE = exports.GET_CURRENCY = exports.GET_IDENTITY_CONTENT = exports.GET_IDENTITY = exports.GET_OFFERS = exports.MAKE_OFFER = void 0; +exports.Z_GET_OPERATION_STATUS = exports.ESTIMATE_CONVERSION = exports.LIST_CURRENCIES = exports.GET_CURRENCY_CONVERTERS = exports.SEND_CURRENCY = exports.FUND_RAW_TRANSACTION = exports.VERIFY_MESSAGE = exports.SIGN_DATA = exports.SIGN_MESSAGE = exports.GET_ADDRESS_UTXOS = exports.SEND_RAW_TRANSACTION = exports.GET_ADDRESS_MEMPOOL = exports.GET_ADDRESS_DELTAS = exports.GET_RAW_TRANSACTION = exports.GET_VDXF_ID = exports.GET_BLOCK = exports.GET_INFO = exports.GET_ADDRESS_BALANCE = exports.GET_CURRENCY = exports.GET_IDENTITY_CONTENT = exports.GET_IDENTITY = exports.GET_OFFERS = exports.MAKE_OFFER = void 0; exports.MAKE_OFFER = 'makeoffer'; exports.GET_OFFERS = 'getoffers'; exports.GET_IDENTITY = 'getidentity'; @@ -16,6 +16,7 @@ exports.GET_ADDRESS_MEMPOOL = 'getaddressmempool'; exports.SEND_RAW_TRANSACTION = 'sendrawtransaction'; exports.GET_ADDRESS_UTXOS = 'getaddressutxos'; exports.SIGN_MESSAGE = 'signmessage'; +exports.SIGN_DATA = 'signdata'; exports.VERIFY_MESSAGE = 'verifymessage'; exports.FUND_RAW_TRANSACTION = 'fundrawtransaction'; exports.SEND_CURRENCY = 'sendcurrency'; diff --git a/dist/constants/vdxf.d.ts b/dist/constants/vdxf.d.ts index b9ae15e..a6b14af 100644 --- a/dist/constants/vdxf.d.ts +++ b/dist/constants/vdxf.d.ts @@ -2,6 +2,7 @@ /// export declare const VDXF_OBJECT_DEFAULT_VERSION: import("bn.js"); export declare const HASH160_BYTE_LENGTH = 20; +export declare const HASH256_BYTE_LENGTH = 32; export declare const I_ADDR_VERSION = 102; export declare const R_ADDR_VERSION = 60; export declare const VERUS_DATA_SIGNATURE_PREFIX: Buffer; diff --git a/dist/constants/vdxf.js b/dist/constants/vdxf.js index 5db3955..2ffea88 100644 --- a/dist/constants/vdxf.js +++ b/dist/constants/vdxf.js @@ -1,10 +1,11 @@ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); -exports.VERUS_DATA_SIGNATURE_PREFIX = exports.R_ADDR_VERSION = exports.I_ADDR_VERSION = exports.HASH160_BYTE_LENGTH = exports.VDXF_OBJECT_DEFAULT_VERSION = void 0; +exports.VERUS_DATA_SIGNATURE_PREFIX = exports.R_ADDR_VERSION = exports.I_ADDR_VERSION = exports.HASH256_BYTE_LENGTH = exports.HASH160_BYTE_LENGTH = exports.VDXF_OBJECT_DEFAULT_VERSION = void 0; const bn_js_1 = require("bn.js"); const bufferutils_1 = require("../utils/bufferutils"); exports.VDXF_OBJECT_DEFAULT_VERSION = new bn_js_1.BN(1, 10); exports.HASH160_BYTE_LENGTH = 20; +exports.HASH256_BYTE_LENGTH = 32; exports.I_ADDR_VERSION = 102; exports.R_ADDR_VERSION = 60; const VERUS_DATA_SIGNATURE_PREFIX_STRING = "Verus signed data:\n"; diff --git a/dist/index.d.ts b/dist/index.d.ts index c3e1d5e..ae4f47f 100644 --- a/dist/index.d.ts +++ b/dist/index.d.ts @@ -11,6 +11,7 @@ export * from './utils/varuint'; export * from './utils/ops'; export * from './utils/evals'; export * from './utils/script'; +export * from './utils/cccustom'; export * from './pbaas/index'; export * from './identity/IdentityDefinition'; export * from './currency/CurrencyDefinition'; diff --git a/dist/index.js b/dist/index.js index 1c8797b..eeef48b 100644 --- a/dist/index.js +++ b/dist/index.js @@ -28,6 +28,7 @@ __exportStar(require("./utils/varuint"), exports); __exportStar(require("./utils/ops"), exports); __exportStar(require("./utils/evals"), exports); __exportStar(require("./utils/script"), exports); +__exportStar(require("./utils/cccustom"), exports); __exportStar(require("./pbaas/index"), exports); __exportStar(require("./identity/IdentityDefinition"), exports); __exportStar(require("./currency/CurrencyDefinition"), exports); diff --git a/dist/pbaas/ContentMultiMap.d.ts b/dist/pbaas/ContentMultiMap.d.ts index 621afb1..fc85620 100644 --- a/dist/pbaas/ContentMultiMap.d.ts +++ b/dist/pbaas/ContentMultiMap.d.ts @@ -17,7 +17,7 @@ export declare class ContentMultiMap implements SerializableEntity { }); getByteLength(): number; toBuffer(): Buffer; - fromBuffer(buffer: Buffer, offset?: number, keylists?: Array | null>): number; + fromBuffer(buffer: Buffer, offset?: number, parseVdxfObjects?: boolean): number; static fromJson(obj: { [key: string]: ContentMultiMapJsonValue; }): ContentMultiMap; diff --git a/dist/pbaas/ContentMultiMap.js b/dist/pbaas/ContentMultiMap.js index ea17dae..1402fee 100644 --- a/dist/pbaas/ContentMultiMap.js +++ b/dist/pbaas/ContentMultiMap.js @@ -79,19 +79,18 @@ class ContentMultiMap { } return writer.buffer; } - fromBuffer(buffer, offset = 0, keylists = []) { + fromBuffer(buffer, offset = 0, parseVdxfObjects = false) { const reader = new BufferReader(buffer, offset); - const contentMultiMapSize = reader.readVarInt(); + const contentMultiMapSize = reader.readCompactSize(); this.kv_content = new Map(); - for (var i = 0; i < contentMultiMapSize.toNumber(); i++) { - const keylist = i < keylists.length ? keylists[i] : null; + for (var i = 0; i < contentMultiMapSize; i++) { const contentMapKey = (0, address_1.toBase58Check)(reader.readSlice(20), vdxf_1.I_ADDR_VERSION); const vector = []; const count = reader.readCompactSize(); for (let j = 0; j < count; j++) { - if (keylist) { + if (parseVdxfObjects) { const unival = new VdxfUniValue_1.VdxfUniValue(); - unival.fromBuffer(reader.readVarSlice(), 0, keylist); + unival.fromBuffer(reader.readVarSlice(), 0); vector.push(unival); } else diff --git a/dist/pbaas/ContentMultiMapRemove.d.ts b/dist/pbaas/ContentMultiMapRemove.d.ts new file mode 100644 index 0000000..6da36cc --- /dev/null +++ b/dist/pbaas/ContentMultiMapRemove.d.ts @@ -0,0 +1,38 @@ +/// +/// +import { BigNumber } from '../utils/types/BigNumber'; +import { SerializableEntity } from '../utils/types/SerializableEntity'; +export interface ContentMultiMapRemoveJson { + version: number; + action: number; + entrykey: string; + valuehash: string; +} +export declare class ContentMultiMapRemove implements SerializableEntity { + version: BigNumber; + action: BigNumber; + entry_key: string; + value_hash: Buffer; + static VERSION_INVALID: import("bn.js"); + static VERSION_FIRST: import("bn.js"); + static VERSION_LAST: import("bn.js"); + static VERSION_CURRENT: import("bn.js"); + static ACTION_FIRST: import("bn.js"); + static ACTION_REMOVE_ONE_KEYVALUE: import("bn.js"); + static ACTION_REMOVE_ALL_KEYVALUE: import("bn.js"); + static ACTION_REMOVE_ALL_KEY: import("bn.js"); + static ACTION_CLEAR_MAP: import("bn.js"); + static ACTION_LAST: import("bn.js"); + constructor(data?: { + version?: BigNumber; + action?: BigNumber; + entry_key?: string; + value_hash?: Buffer; + }); + getByteLength(): number; + toBuffer(): Buffer; + fromBuffer(buffer: Buffer, offset?: number): number; + static fromJson(data: ContentMultiMapRemoveJson): ContentMultiMapRemove; + toJson(): ContentMultiMapRemoveJson; + isValid(): boolean; +} diff --git a/dist/pbaas/ContentMultiMapRemove.js b/dist/pbaas/ContentMultiMapRemove.js new file mode 100644 index 0000000..7e04b6d --- /dev/null +++ b/dist/pbaas/ContentMultiMapRemove.js @@ -0,0 +1,88 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.ContentMultiMapRemove = void 0; +const address_1 = require("../utils/address"); +const bufferutils_1 = require("../utils/bufferutils"); +const bn_js_1 = require("bn.js"); +const vdxf_1 = require("../constants/vdxf"); +const { BufferReader, BufferWriter } = bufferutils_1.default; +class ContentMultiMapRemove { + constructor(data) { + this.version = (data === null || data === void 0 ? void 0 : data.version) || new bn_js_1.BN(1, 10); + this.action = (data === null || data === void 0 ? void 0 : data.action) || new bn_js_1.BN(0, 10); + this.entry_key = (data === null || data === void 0 ? void 0 : data.entry_key) || ""; + this.value_hash = (data === null || data === void 0 ? void 0 : data.value_hash) || Buffer.alloc(0); + } + getByteLength() { + let byteLength = 0; + byteLength += 4; // version uint32 + byteLength += 4; // action uint32 + if (this.action != ContentMultiMapRemove.ACTION_CLEAR_MAP) { + byteLength += 20; + if (this.action != ContentMultiMapRemove.ACTION_REMOVE_ALL_KEY) { + byteLength += 32; + } + } + return byteLength; + } + toBuffer() { + const bufferWriter = new BufferWriter(Buffer.alloc(this.getByteLength())); + bufferWriter.writeUInt32(this.version.toNumber()); + bufferWriter.writeUInt32(this.action.toNumber()); + if (this.action != ContentMultiMapRemove.ACTION_CLEAR_MAP) { + bufferWriter.writeSlice((0, address_1.fromBase58Check)(this.entry_key).hash); + if (this.action != ContentMultiMapRemove.ACTION_REMOVE_ALL_KEY) { + bufferWriter.writeSlice(this.value_hash); + } + } + return bufferWriter.buffer; + } + fromBuffer(buffer, offset = 0) { + const reader = new BufferReader(buffer, offset); + this.version = new bn_js_1.BN(reader.readUInt32()); + this.action = new bn_js_1.BN(reader.readUInt32()); + if (this.action != ContentMultiMapRemove.ACTION_CLEAR_MAP) { + this.entry_key = (0, address_1.toBase58Check)(reader.readSlice(20), vdxf_1.I_ADDR_VERSION); + if (this.action != ContentMultiMapRemove.ACTION_REMOVE_ALL_KEY) { + this.value_hash = reader.readSlice(32); + } + } + return reader.offset; + } + static fromJson(data) { + return new ContentMultiMapRemove({ + version: new bn_js_1.BN(data.version), + action: new bn_js_1.BN(data.action), + entry_key: data.entrykey, + value_hash: Buffer.from(data.valuehash, 'hex') + }); + } + toJson() { + return { + version: this.version.toNumber(), + action: this.action.toNumber(), + entrykey: this.entry_key, + valuehash: this.value_hash.toString('hex') + }; + } + isValid() { + if (this.version.gte(ContentMultiMapRemove.VERSION_FIRST) && + this.version.lte(ContentMultiMapRemove.VERSION_LAST)) { + return (this.action.eq(ContentMultiMapRemove.ACTION_CLEAR_MAP) || + (this.entry_key && (this.entry_key.length > 0) && + (this.action.eq(ContentMultiMapRemove.ACTION_REMOVE_ALL_KEY) || this.value_hash.length > 0))); + } + return false; + } +} +exports.ContentMultiMapRemove = ContentMultiMapRemove; +ContentMultiMapRemove.VERSION_INVALID = new bn_js_1.BN(0); +ContentMultiMapRemove.VERSION_FIRST = new bn_js_1.BN(1); +ContentMultiMapRemove.VERSION_LAST = new bn_js_1.BN(1); +ContentMultiMapRemove.VERSION_CURRENT = new bn_js_1.BN(1); +ContentMultiMapRemove.ACTION_FIRST = new bn_js_1.BN(1); +ContentMultiMapRemove.ACTION_REMOVE_ONE_KEYVALUE = new bn_js_1.BN(1); +ContentMultiMapRemove.ACTION_REMOVE_ALL_KEYVALUE = new bn_js_1.BN(2); +ContentMultiMapRemove.ACTION_REMOVE_ALL_KEY = new bn_js_1.BN(3); +ContentMultiMapRemove.ACTION_CLEAR_MAP = new bn_js_1.BN(4); +ContentMultiMapRemove.ACTION_LAST = new bn_js_1.BN(4); diff --git a/dist/pbaas/CrossChainDataRef.d.ts b/dist/pbaas/CrossChainDataRef.d.ts new file mode 100644 index 0000000..e0eac02 --- /dev/null +++ b/dist/pbaas/CrossChainDataRef.d.ts @@ -0,0 +1,40 @@ +/// +import { SerializableEntity } from '../utils/types/SerializableEntity'; +import { PBaaSEvidenceRef, PBaaSEvidenceRefJson } from './PBaaSEvidenceRef'; +import { IdentityMultimapRef, IdentityMultimapRefJson } from './IdentityMultimapRef'; +import { URLRef, URLRefJson } from './URLRef'; +export declare type CrossChainDataRefJson = (PBaaSEvidenceRefJson & { + type: number; +}) | (IdentityMultimapRefJson & { + type: number; +}) | (URLRefJson & { + type: number; +}); +export declare class CrossChainDataRef implements SerializableEntity { + ref: PBaaSEvidenceRef | IdentityMultimapRef | URLRef; + static TYPE_CROSSCHAIN_DATAREF: number; + static TYPE_IDENTITY_DATAREF: number; + static TYPE_URL_REF: number; + constructor(data?: PBaaSEvidenceRef | IdentityMultimapRef | URLRef | any); + which(): number; + getByteLength(): number; + toBuffer(): Buffer; + fromBuffer(buffer: Buffer, offset?: number): number; + isValid(): boolean; + toJson(): { + type: number; + } | { + type: number; + version: number; + flags: number; + output: any; + objectnum: number; + subobject: number; + systemid: string; + } | { + type: number; + version: string; + url: string; + }; + static fromJson(data: CrossChainDataRefJson): CrossChainDataRef; +} diff --git a/dist/pbaas/CrossChainDataRef.js b/dist/pbaas/CrossChainDataRef.js new file mode 100644 index 0000000..455b096 --- /dev/null +++ b/dist/pbaas/CrossChainDataRef.js @@ -0,0 +1,82 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.CrossChainDataRef = void 0; +const bufferutils_1 = require("../utils/bufferutils"); +const PBaaSEvidenceRef_1 = require("./PBaaSEvidenceRef"); +const IdentityMultimapRef_1 = require("./IdentityMultimapRef"); +const URLRef_1 = require("./URLRef"); +const { BufferReader, BufferWriter } = bufferutils_1.default; +class CrossChainDataRef { + constructor(data) { + this.ref = data || null; + } + which() { + if (this.ref instanceof PBaaSEvidenceRef_1.PBaaSEvidenceRef) { + return CrossChainDataRef.TYPE_CROSSCHAIN_DATAREF; + } + else if (this.ref instanceof IdentityMultimapRef_1.IdentityMultimapRef) { + return CrossChainDataRef.TYPE_IDENTITY_DATAREF; + } + else if (this.ref instanceof URLRef_1.URLRef) { + return CrossChainDataRef.TYPE_URL_REF; + } + } + getByteLength() { + let byteLength = 1; //type uint8 + byteLength += this.ref.getByteLength(); + return byteLength; + } + toBuffer() { + const bufferWriter = new BufferWriter(Buffer.alloc(this.getByteLength())); + bufferWriter.writeUInt8(this.which()); + bufferWriter.writeSlice(this.ref.toBuffer()); + return bufferWriter.buffer; + } + fromBuffer(buffer, offset = 0) { + const reader = new BufferReader(buffer, offset); + const type = reader.readUInt8(); + if (type == CrossChainDataRef.TYPE_CROSSCHAIN_DATAREF) { + this.ref = new PBaaSEvidenceRef_1.PBaaSEvidenceRef(); + } + else if (type == CrossChainDataRef.TYPE_IDENTITY_DATAREF) { + this.ref = new IdentityMultimapRef_1.IdentityMultimapRef(); + } + else if (type == CrossChainDataRef.TYPE_URL_REF) { + this.ref = new URLRef_1.URLRef(); + } + offset = this.ref.fromBuffer(buffer, reader.offset); + return offset; + } + isValid() { + switch (this.which()) { + case CrossChainDataRef.TYPE_CROSSCHAIN_DATAREF: + return this.ref.isValid(); + case CrossChainDataRef.TYPE_IDENTITY_DATAREF: + return this.ref.isValid(); + case CrossChainDataRef.TYPE_URL_REF: + return this.ref.isValid(); + default: + return false; + } + } + toJson() { + return Object.assign(Object.assign({}, this.ref.toJson()), { type: this.which() }); + } + static fromJson(data) { + if (data.type == CrossChainDataRef.TYPE_CROSSCHAIN_DATAREF) { + return new CrossChainDataRef(PBaaSEvidenceRef_1.PBaaSEvidenceRef.fromJson(data)); + } + else if (data.type == CrossChainDataRef.TYPE_IDENTITY_DATAREF) { + return new CrossChainDataRef(IdentityMultimapRef_1.IdentityMultimapRef.fromJson(data)); + } + else if (data.type == CrossChainDataRef.TYPE_URL_REF) { + return new CrossChainDataRef(URLRef_1.URLRef.fromJson(data)); + } + else + throw new Error("Invalid CrossChainDataRef type"); + } +} +exports.CrossChainDataRef = CrossChainDataRef; +CrossChainDataRef.TYPE_CROSSCHAIN_DATAREF = 0; +CrossChainDataRef.TYPE_IDENTITY_DATAREF = 1; +CrossChainDataRef.TYPE_URL_REF = 2; diff --git a/dist/pbaas/CurrencyValueMap.d.ts b/dist/pbaas/CurrencyValueMap.d.ts index b38ab9c..155d500 100644 --- a/dist/pbaas/CurrencyValueMap.d.ts +++ b/dist/pbaas/CurrencyValueMap.d.ts @@ -13,4 +13,11 @@ export declare class CurrencyValueMap implements SerializableEntity { getByteLength(): number; toBuffer(): Buffer; fromBuffer(buffer: Buffer, offset?: number): number; + isValid(): boolean; + toJson(): { + [key: string]: string; + }; + static fromJson(data: { + [key: string]: string; + }, multivalue?: boolean): CurrencyValueMap; } diff --git a/dist/pbaas/CurrencyValueMap.js b/dist/pbaas/CurrencyValueMap.js index 350e1ca..3f55080 100644 --- a/dist/pbaas/CurrencyValueMap.js +++ b/dist/pbaas/CurrencyValueMap.js @@ -59,5 +59,27 @@ class CurrencyValueMap { } return reader.offset; } + isValid() { + for (let [key, value] of this.value_map) { + if (!key || (typeof (key) == 'string' && key.length == 0)) { + return false; + } + } + return true; + } + toJson() { + const value_map = {}; + for (let [key, value] of this.value_map) { + value_map[key] = value.toString(); + } + return value_map; + } + static fromJson(data, multivalue = false) { + const value_map = new Map(); + for (let key in data) { + value_map.set(key, new bn_js_1.BN(data[key])); + } + return new CurrencyValueMap({ value_map, multivalue }); + } } exports.CurrencyValueMap = CurrencyValueMap; diff --git a/dist/pbaas/DataDescriptor.d.ts b/dist/pbaas/DataDescriptor.d.ts new file mode 100644 index 0000000..8f02d48 --- /dev/null +++ b/dist/pbaas/DataDescriptor.d.ts @@ -0,0 +1,94 @@ +/// +/// +import { BigNumber } from '../utils/types/BigNumber'; +import { BufferDataVdxfObject } from '../vdxf/index'; +import { SerializableEntity } from '../utils/types/SerializableEntity'; +export interface DataDescriptorJson { + version: number; + flags?: number; + objectdata?: string | { + ['message']: string; + } | object; + label?: string; + mimetype?: string; + salt?: string; + epk?: string; + ivk?: string; + ssk?: string; +} +export declare class DataDescriptor implements SerializableEntity { + static VERSION_INVALID: import("bn.js"); + static VERSION_FIRST: import("bn.js"); + static FIRST_VERSION: import("bn.js"); + static LAST_VERSION: import("bn.js"); + static DEFAULT_VERSION: import("bn.js"); + static FLAG_ENCRYPTED_DATA: import("bn.js"); + static FLAG_SALT_PRESENT: import("bn.js"); + static FLAG_ENCRYPTION_PUBLIC_KEY_PRESENT: import("bn.js"); + static FLAG_INCOMING_VIEWING_KEY_PRESENT: import("bn.js"); + static FLAG_SYMMETRIC_ENCRYPTION_KEY_PRESENT: import("bn.js"); + static FLAG_LABEL_PRESENT: import("bn.js"); + static FLAG_MIME_TYPE_PRESENT: import("bn.js"); + static FLAG_MASK: import("bn.js"); + version: BigNumber; + flags: BigNumber; + objectdata: Buffer; + label: string; + mimeType: string; + salt: Buffer; + epk: Buffer; + ivk: Buffer; + ssk: Buffer; + constructor(data?: { + version?: BigNumber; + flags?: BigNumber; + objectdata?: Buffer; + label?: string; + mimeType?: string; + salt?: Buffer; + epk?: Buffer; + ivk?: Buffer; + ssk?: Buffer; + }); + static fromJson(data: any): DataDescriptor; + DecodeHashVector(): Array; + getByteLength(): number; + toBuffer(): Buffer; + fromBuffer(buffer: Buffer, offset?: number): number; + HasEncryptedData(): boolean; + HasSalt(): boolean; + HasEPK(): boolean; + HasMIME(): boolean; + HasIVK(): boolean; + HasSSK(): boolean; + HasLabel(): boolean; + CalcFlags(): BigNumber; + SetFlags(): void; + isValid(): boolean; + toJson(): DataDescriptorJson; +} +export declare class VDXFDataDescriptor extends BufferDataVdxfObject { + dataDescriptor: DataDescriptor; + constructor(dataDescriptor?: DataDescriptor, vdxfkey?: string, version?: BigNumber); + static fromDataVdxfObject(data: BufferDataVdxfObject): VDXFDataDescriptor; + dataByteLength(): number; + toDataBuffer(): Buffer; + fromDataBuffer(buffer: Buffer, offset?: number): number; + HasEncryptedData(): boolean; + HasLabel(): boolean; + HasSalt(): boolean; + HasEPK(): boolean; + HasIVK(): boolean; + HasSSK(): boolean; + CalcFlags(): BigNumber; + SetFlags(): void; +} +export declare enum EHashTypes { + HASH_INVALID = 0, + HASH_BLAKE2BMMR = 1, + HASH_BLAKE2BMMR2 = 2, + HASH_KECCAK = 3, + HASH_SHA256D = 4, + HASH_SHA256 = 5, + HASH_LASTTYPE = 5 +} diff --git a/dist/pbaas/DataDescriptor.js b/dist/pbaas/DataDescriptor.js new file mode 100644 index 0000000..2eb9e49 --- /dev/null +++ b/dist/pbaas/DataDescriptor.js @@ -0,0 +1,330 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.EHashTypes = exports.VDXFDataDescriptor = exports.DataDescriptor = void 0; +const bn_js_1 = require("bn.js"); +const varint_1 = require("../utils/varint"); +const varuint_1 = require("../utils/varuint"); +const bufferutils_1 = require("../utils/bufferutils"); +const { BufferReader, BufferWriter } = bufferutils_1.default; +const _1 = require("."); +const index_1 = require("../vdxf/index"); +const VDXF_Data = require("../vdxf/vdxfdatakeys"); +class DataDescriptor { + constructor(data) { + this.flags = new bn_js_1.BN(0); + this.version = DataDescriptor.DEFAULT_VERSION; + if (data != null) { + if (data.flags != null) + this.flags = data.flags; + if (data.version != null) + this.version = data.version; + if (data.objectdata != null) + this.objectdata = data.objectdata; + if (data.label != null) + this.label = data.label; + if (data.mimeType != null) + this.mimeType = data.mimeType; + if (data.salt != null) + this.salt = data.salt; + if (data.epk != null) + this.epk = data.epk; + if (data.ivk != null) + this.ivk = data.ivk; + if (data.ssk != null) + this.ssk = data.ssk; + if (this.label && this.label.length > 64) { + this.label = this.label.slice(0, 64); + } + if (this.mimeType && this.mimeType.length > 128) { + this.mimeType = this.mimeType.slice(0, 128); + } + this.SetFlags(); + } + } + static fromJson(data) { + const newDataDescriptor = new DataDescriptor(); + if (data != null) { + if (data.flags != null) + newDataDescriptor.flags = new bn_js_1.BN(data.flags); + if (data.version != null) + newDataDescriptor.version = new bn_js_1.BN(data.version); + if (data.objectdata != null) + newDataDescriptor.objectdata = _1.VdxfUniValue.fromJson(data.objectdata).toBuffer(); + if (data.label != null) + newDataDescriptor.label = data.label; + if (data.mimetype != null) + newDataDescriptor.mimeType = data.mimetype; + if (data.salt != null) + newDataDescriptor.salt = Buffer.from(data.salt, 'hex'); + if (data.epk != null) + newDataDescriptor.epk = Buffer.from(data.epk, 'hex'); + if (data.ivk != null) + newDataDescriptor.ivk = Buffer.from(data.ivk, 'hex'); + if (data.ssk != null) + newDataDescriptor.ssk = Buffer.from(data.ssk, 'hex'); + if (newDataDescriptor.label && newDataDescriptor.label.length > 64) { + newDataDescriptor.label = newDataDescriptor.label.slice(0, 64); + } + if (newDataDescriptor.mimeType && newDataDescriptor.mimeType.length > 128) { + newDataDescriptor.mimeType = newDataDescriptor.mimeType.slice(0, 128); + } + } + ; + newDataDescriptor.SetFlags(); + return newDataDescriptor; + } + DecodeHashVector() { + const vdxfData = new index_1.BufferDataVdxfObject(); + vdxfData.fromBuffer(this.objectdata); + const hashes = []; + if (vdxfData.vdxfkey == VDXF_Data.VectorUint256Key.vdxfid) { + const reader = new BufferReader(Buffer.from(vdxfData.data, 'hex')); + const count = reader.readVarInt(); + for (let i = 0; i < count.toNumber(); i++) { + hashes.push(reader.readSlice(32)); + } + } + return hashes; + } + getByteLength() { + let length = 0; + length += varint_1.default.encodingLength(this.version); + length += varint_1.default.encodingLength(this.flags); + length += varuint_1.default.encodingLength(this.objectdata.length); + length += this.objectdata.length; + if (this.HasLabel()) { + if (this.label.length > 64) { + throw new Error("Label too long"); + } + length += varuint_1.default.encodingLength(this.label.length); + length += this.label.length; + } + if (this.HasMIME()) { + if (this.mimeType.length > 128) { + throw new Error("MIME type too long"); + } + length += varuint_1.default.encodingLength(this.mimeType.length); + length += this.mimeType.length; + } + if (this.HasSalt()) { + length += varuint_1.default.encodingLength(this.salt.length); + length += this.salt.length; + } + if (this.HasEPK()) { + length += varuint_1.default.encodingLength(this.epk.length); + length += this.epk.length; + } + if (this.HasIVK()) { + length += varuint_1.default.encodingLength(this.ivk.length); + length += this.ivk.length; + } + if (this.HasSSK()) { + length += varuint_1.default.encodingLength(this.ssk.length); + length += this.ssk.length; + } + return length; + } + toBuffer() { + const writer = new BufferWriter(Buffer.alloc(this.getByteLength())); + writer.writeVarInt(this.version); + writer.writeVarInt(this.flags); + writer.writeVarSlice(this.objectdata); + if (this.HasLabel()) { + writer.writeVarSlice(Buffer.from(this.label)); + } + if (this.HasMIME()) { + writer.writeVarSlice(Buffer.from(this.mimeType)); + } + if (this.HasSalt()) { + writer.writeVarSlice(this.salt); + } + if (this.HasEPK()) { + writer.writeVarSlice(this.epk); + } + if (this.HasIVK()) { + writer.writeVarSlice(this.ivk); + } + if (this.HasSSK()) { + writer.writeVarSlice(this.ssk); + } + return writer.buffer; + } + fromBuffer(buffer, offset = 0) { + const reader = new BufferReader(buffer, offset); + this.version = reader.readVarInt(); + this.flags = reader.readVarInt(); + this.objectdata = reader.readVarSlice(); + if (this.HasLabel()) { + this.label = reader.readVarSlice().toString(); + } + if (this.HasMIME()) { + this.mimeType = reader.readVarSlice().toString(); + } + if (this.HasSalt()) { + this.salt = reader.readVarSlice(); + } + if (this.HasEPK()) { + this.epk = reader.readVarSlice(); + } + if (this.HasIVK()) { + this.ivk = reader.readVarSlice(); + } + if (this.HasSSK()) { + this.ssk = reader.readVarSlice(); + } + return reader.offset; + } + HasEncryptedData() { + return this.flags.and(DataDescriptor.FLAG_ENCRYPTED_DATA).gt(new bn_js_1.BN(0)); + } + HasSalt() { + return this.flags.and(DataDescriptor.FLAG_SALT_PRESENT).gt(new bn_js_1.BN(0)); + } + HasEPK() { + return this.flags.and(DataDescriptor.FLAG_ENCRYPTION_PUBLIC_KEY_PRESENT).gt(new bn_js_1.BN(0)); + } + HasMIME() { + return this.flags.and(DataDescriptor.FLAG_MIME_TYPE_PRESENT).gt(new bn_js_1.BN(0)); + } + HasIVK() { + return this.flags.and(DataDescriptor.FLAG_INCOMING_VIEWING_KEY_PRESENT).gt(new bn_js_1.BN(0)); + } + HasSSK() { + return this.flags.and(DataDescriptor.FLAG_SYMMETRIC_ENCRYPTION_KEY_PRESENT).gt(new bn_js_1.BN(0)); + } + HasLabel() { + return this.flags.and(DataDescriptor.FLAG_LABEL_PRESENT).gt(new bn_js_1.BN(0)); + } + CalcFlags() { + return this.flags.and(DataDescriptor.FLAG_ENCRYPTED_DATA).add(this.label ? DataDescriptor.FLAG_LABEL_PRESENT : new bn_js_1.BN(0)).add(this.mimeType ? DataDescriptor.FLAG_MIME_TYPE_PRESENT : new bn_js_1.BN(0)).add(this.salt ? DataDescriptor.FLAG_SALT_PRESENT : new bn_js_1.BN(0)).add(this.epk ? DataDescriptor.FLAG_ENCRYPTION_PUBLIC_KEY_PRESENT : new bn_js_1.BN(0)).add(this.ivk ? DataDescriptor.FLAG_INCOMING_VIEWING_KEY_PRESENT : new bn_js_1.BN(0)).add(this.ssk ? DataDescriptor.FLAG_SYMMETRIC_ENCRYPTION_KEY_PRESENT : new bn_js_1.BN(0)); + } + SetFlags() { + this.flags = this.CalcFlags(); + } + isValid() { + return !!(this.version.gte(DataDescriptor.FIRST_VERSION) && this.version.lte(DataDescriptor.LAST_VERSION) && this.flags.and(DataDescriptor.FLAG_MASK.notn(DataDescriptor.FLAG_MASK.bitLength()))); + } + toJson() { + const retval = { + version: this.version.toNumber(), + flags: this.flags.toNumber() + }; + let isText = false; + if (this.mimeType) { + retval['mimetype'] = this.mimeType; + if (this.mimeType.startsWith("text/")) + isText = true; + } + let processedObject = new _1.VdxfUniValue(); + processedObject.fromBuffer(this.objectdata); + if (isText && ((processedObject.values.get("") === "string") || Buffer.isBuffer(processedObject.values.get("")))) { + const objectDataUni = { message: '' }; + if (processedObject.values.get("") === "string") { + objectDataUni.message = processedObject.values.get(""); + } + else { + objectDataUni.message = processedObject.values.get("").toString('utf-8'); + } + retval['objectdata'] = objectDataUni; + } + else { + retval['objectdata'] = processedObject.toJson(); + } + if (this.label) + retval['label'] = this.label; + if (this.salt) + retval['salt'] = this.salt.toString('hex'); + if (this.epk) + retval['epk'] = this.epk.toString('hex'); + if (this.ivk) + retval['ivk'] = this.ivk.toString('hex'); + if (this.ssk) + retval['ssk'] = this.ssk.toString('hex'); + return retval; + } +} +exports.DataDescriptor = DataDescriptor; +DataDescriptor.VERSION_INVALID = new bn_js_1.BN(0); +DataDescriptor.VERSION_FIRST = new bn_js_1.BN(1); +DataDescriptor.FIRST_VERSION = new bn_js_1.BN(1); +DataDescriptor.LAST_VERSION = new bn_js_1.BN(1); +DataDescriptor.DEFAULT_VERSION = new bn_js_1.BN(1); +DataDescriptor.FLAG_ENCRYPTED_DATA = new bn_js_1.BN(1); +DataDescriptor.FLAG_SALT_PRESENT = new bn_js_1.BN(2); +DataDescriptor.FLAG_ENCRYPTION_PUBLIC_KEY_PRESENT = new bn_js_1.BN(4); +DataDescriptor.FLAG_INCOMING_VIEWING_KEY_PRESENT = new bn_js_1.BN(8); +DataDescriptor.FLAG_SYMMETRIC_ENCRYPTION_KEY_PRESENT = new bn_js_1.BN(0x10); +DataDescriptor.FLAG_LABEL_PRESENT = new bn_js_1.BN(0x20); +DataDescriptor.FLAG_MIME_TYPE_PRESENT = new bn_js_1.BN(0x40); +DataDescriptor.FLAG_MASK = (DataDescriptor.FLAG_ENCRYPTED_DATA.add(DataDescriptor.FLAG_SALT_PRESENT).add(DataDescriptor.FLAG_ENCRYPTION_PUBLIC_KEY_PRESENT).add(DataDescriptor.FLAG_INCOMING_VIEWING_KEY_PRESENT).add(DataDescriptor.FLAG_SYMMETRIC_ENCRYPTION_KEY_PRESENT).add(DataDescriptor.FLAG_LABEL_PRESENT).add(DataDescriptor.FLAG_MIME_TYPE_PRESENT)); +; +class VDXFDataDescriptor extends index_1.BufferDataVdxfObject { + constructor(dataDescriptor, vdxfkey = "", version = new bn_js_1.BN(1)) { + super("", vdxfkey); + this.version = version; + if (dataDescriptor) { + this.dataDescriptor = dataDescriptor; + } + } + static fromDataVdxfObject(data) { + const retval = new VDXFDataDescriptor(); + retval.version = data.version; + retval.data = data.data; + retval.fromBuffer(Buffer.from(retval.data, 'hex')); + delete retval.data; + return retval; + } + dataByteLength() { + let length = 0; + length += this.dataDescriptor.getByteLength(); + return length; + } + toDataBuffer() { + return this.dataDescriptor.toBuffer(); + } + fromDataBuffer(buffer, offset) { + const reader = new bufferutils_1.default.BufferReader(buffer, offset); + this.data = reader.readVarSlice().toString('hex'); + this.dataDescriptor = new DataDescriptor(); + this.dataDescriptor.fromBuffer(Buffer.from(this.data, 'hex'), reader.offset); + delete this.data; + return reader.offset; + } + HasEncryptedData() { + return this.dataDescriptor.HasEncryptedData(); + } + HasLabel() { + return this.dataDescriptor.HasLabel(); + } + HasSalt() { + return this.dataDescriptor.HasSalt(); + } + HasEPK() { + return this.dataDescriptor.HasEPK(); + } + HasIVK() { + return this.dataDescriptor.HasIVK(); + } + HasSSK() { + return this.dataDescriptor.HasSSK(); + } + CalcFlags() { + return this.dataDescriptor.CalcFlags(); + } + SetFlags() { + return this.dataDescriptor.SetFlags(); + } +} +exports.VDXFDataDescriptor = VDXFDataDescriptor; +; +var EHashTypes; +(function (EHashTypes) { + EHashTypes[EHashTypes["HASH_INVALID"] = 0] = "HASH_INVALID"; + EHashTypes[EHashTypes["HASH_BLAKE2BMMR"] = 1] = "HASH_BLAKE2BMMR"; + EHashTypes[EHashTypes["HASH_BLAKE2BMMR2"] = 2] = "HASH_BLAKE2BMMR2"; + EHashTypes[EHashTypes["HASH_KECCAK"] = 3] = "HASH_KECCAK"; + EHashTypes[EHashTypes["HASH_SHA256D"] = 4] = "HASH_SHA256D"; + EHashTypes[EHashTypes["HASH_SHA256"] = 5] = "HASH_SHA256"; + EHashTypes[EHashTypes["HASH_LASTTYPE"] = 5] = "HASH_LASTTYPE"; +})(EHashTypes = exports.EHashTypes || (exports.EHashTypes = {})); +; diff --git a/dist/pbaas/Identity.d.ts b/dist/pbaas/Identity.d.ts index fb3e3c5..da52ae4 100644 --- a/dist/pbaas/Identity.d.ts +++ b/dist/pbaas/Identity.d.ts @@ -68,8 +68,9 @@ export declare class Identity extends Principal implements SerializableEntity { unlock_after?: BigNumber; }); getByteLength(): number; + clearContentMultiMap(): void; toBuffer(): Buffer; - fromBuffer(buffer: Buffer, offset?: number, multimapKeylists?: Array | null>): number; + fromBuffer(buffer: Buffer, offset?: number, parseVdxfObjects?: boolean): number; toJson(): VerusCLIVerusIDJson; getIdentityAddress(): string; isRevoked(): boolean; diff --git a/dist/pbaas/Identity.js b/dist/pbaas/Identity.js index 4d20c59..67957b5 100644 --- a/dist/pbaas/Identity.js +++ b/dist/pbaas/Identity.js @@ -85,6 +85,9 @@ class Identity extends Principal_1.Principal { } return length; } + clearContentMultiMap() { + this.content_multimap = new ContentMultiMap_1.ContentMultiMap({ kv_content: new Map() }); + } toBuffer() { const writer = new BufferWriter(Buffer.alloc(this.getByteLength())); writer.writeSlice(super.toBuffer()); @@ -124,7 +127,7 @@ class Identity extends Principal_1.Principal { } return writer.buffer; } - fromBuffer(buffer, offset = 0, multimapKeylists = []) { + fromBuffer(buffer, offset = 0, parseVdxfObjects = false) { const reader = new BufferReader(buffer, offset); reader.offset = super.fromBuffer(reader.buffer, reader.offset); const _parent = new IdentityID_1.IdentityID(); @@ -134,7 +137,7 @@ class Identity extends Principal_1.Principal { //contentmultimap if (this.version.gte(exports.IDENTITY_VERSION_PBAAS)) { const multimap = new ContentMultiMap_1.ContentMultiMap(); - reader.offset = multimap.fromBuffer(reader.buffer, reader.offset, multimapKeylists); + reader.offset = multimap.fromBuffer(reader.buffer, reader.offset, parseVdxfObjects); this.content_multimap = multimap; } // contentmap diff --git a/dist/pbaas/IdentityMultimapRef.d.ts b/dist/pbaas/IdentityMultimapRef.d.ts new file mode 100644 index 0000000..39921f7 --- /dev/null +++ b/dist/pbaas/IdentityMultimapRef.d.ts @@ -0,0 +1,39 @@ +/// +/// +import { BigNumber } from '../utils/types/BigNumber'; +import { SerializableEntity } from '../utils/types/SerializableEntity'; +export interface IdentityMultimapRefJson { + version: number; + flags: number; + vdxfkey: string; + startheight: number; + endheight: number; + datahash: string; + systemid: string; +} +export declare class IdentityMultimapRef implements SerializableEntity { + version: BigNumber; + flags: BigNumber; + id_ID: string; + key: string; + height_start: BigNumber; + height_end: BigNumber; + data_hash: Buffer; + system_id: string; + static FLAG_NO_DELETION: import("bn.js"); + static FLAG_HAS_DATAHASH: import("bn.js"); + static FLAG_HAS_SYSTEM: import("bn.js"); + static FIRST_VERSION: import("bn.js"); + static LAST_VERSION: import("bn.js"); + static CURRENT_VERSION: import("bn.js"); + constructor(data?: any); + setFlags(): void; + getByteLength(): number; + toBuffer(): Buffer; + fromBuffer(buffer: Buffer, offset?: number): number; + isValid(): boolean; + hasDataHash(): boolean; + hasSystemID(): boolean; + toJson(): void; + static fromJson(data: IdentityMultimapRefJson): IdentityMultimapRef; +} diff --git a/dist/pbaas/IdentityMultimapRef.js b/dist/pbaas/IdentityMultimapRef.js new file mode 100644 index 0000000..98b0f49 --- /dev/null +++ b/dist/pbaas/IdentityMultimapRef.js @@ -0,0 +1,126 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.IdentityMultimapRef = void 0; +const varint_1 = require("../utils/varint"); +const address_1 = require("../utils/address"); +const bufferutils_1 = require("../utils/bufferutils"); +const bn_js_1 = require("bn.js"); +const vdxf_1 = require("../constants/vdxf"); +const { BufferReader, BufferWriter } = bufferutils_1.default; +class IdentityMultimapRef { + constructor(data) { + if (data) { + this.version = data.version || IdentityMultimapRef.CURRENT_VERSION; + this.flags = data.flags || new bn_js_1.BN(0); + this.id_ID = data.id_ID || ""; + this.key = data.key || ""; + this.height_start = data.height_start || new bn_js_1.BN(0); + this.height_end = data.height_end || new bn_js_1.BN(0); + this.data_hash = data.data_hash || Buffer.alloc(0); + this.system_id = data.system_id || ""; + } + } + setFlags() { + this.flags = this.flags.and(IdentityMultimapRef.FLAG_NO_DELETION); + if (this.data_hash && this.data_hash.length > 0) { + this.flags = this.flags.or(IdentityMultimapRef.FLAG_HAS_DATAHASH); + } + if (this.system_id && this.system_id.length > 0) { + this.flags = this.flags.or(IdentityMultimapRef.FLAG_HAS_SYSTEM); + } + } + getByteLength() { + let byteLength = 0; + this.setFlags(); + byteLength += varint_1.default.encodingLength(this.version); + byteLength += varint_1.default.encodingLength(this.flags); + byteLength += 20; // id_ID uint160 + byteLength += 20; // key uint160 + byteLength += varint_1.default.encodingLength(this.height_start); // height_start uint32 + byteLength += varint_1.default.encodingLength(this.height_end); // height_end uint32 + byteLength += 32; // data_hash uint25 + if (this.flags.and(IdentityMultimapRef.FLAG_HAS_DATAHASH).gt(new bn_js_1.BN(0))) { + byteLength += 32; + } + if (this.flags.and(IdentityMultimapRef.FLAG_HAS_SYSTEM).gt(new bn_js_1.BN(0))) { + byteLength += 20; + } + return byteLength; + } + toBuffer() { + const bufferWriter = new BufferWriter(Buffer.alloc(this.getByteLength())); + bufferWriter.writeVarInt(this.version); + bufferWriter.writeVarInt(this.flags); + bufferWriter.writeSlice((0, address_1.fromBase58Check)(this.id_ID).hash); + bufferWriter.writeSlice((0, address_1.fromBase58Check)(this.key).hash); + bufferWriter.writeVarInt(this.height_start); + bufferWriter.writeVarInt(this.height_end); + if (this.flags.and(IdentityMultimapRef.FLAG_HAS_DATAHASH).gt(new bn_js_1.BN(0))) { + bufferWriter.writeSlice(this.data_hash); + } + if (this.flags.and(IdentityMultimapRef.FLAG_HAS_SYSTEM).gt(new bn_js_1.BN(0))) { + bufferWriter.writeSlice((0, address_1.fromBase58Check)(this.system_id).hash); + } + return bufferWriter.buffer; + } + fromBuffer(buffer, offset = 0) { + const reader = new BufferReader(buffer, offset); + this.version = reader.readVarInt(); + this.flags = reader.readVarInt(); + this.id_ID = (0, address_1.toBase58Check)(reader.readSlice(20), vdxf_1.I_ADDR_VERSION); + this.key = (0, address_1.toBase58Check)(reader.readSlice(20), vdxf_1.I_ADDR_VERSION); + this.height_start = reader.readVarInt(); + this.height_end = reader.readVarInt(); + if (this.flags.and(IdentityMultimapRef.FLAG_HAS_DATAHASH).gt(new bn_js_1.BN(0))) { + this.data_hash = reader.readSlice(32); + } + if (this.flags.and(IdentityMultimapRef.FLAG_HAS_SYSTEM).gt(new bn_js_1.BN(0))) { + this.system_id = (0, address_1.toBase58Check)(reader.readSlice(20), vdxf_1.I_ADDR_VERSION); + } + return reader.offset; + } + isValid() { + return this.version.gte(IdentityMultimapRef.FIRST_VERSION) && + this.version.lte(IdentityMultimapRef.LAST_VERSION) && + (this.flags.and(IdentityMultimapRef.FLAG_HAS_DATAHASH.add(IdentityMultimapRef.FLAG_HAS_SYSTEM).notn(16))).eq(new bn_js_1.BN(0)) && + !(!this.id_ID || this.id_ID.length === 0) && !(!this.key || this.key.length === 0); + } + hasDataHash() { + return this.flags.and(IdentityMultimapRef.FLAG_HAS_DATAHASH).gt(new bn_js_1.BN(0)); + } + hasSystemID() { + return this.flags.and(IdentityMultimapRef.FLAG_HAS_SYSTEM).gt(new bn_js_1.BN(0)); + } + toJson() { + let retval; + retval.version = this.version.toString(10); + retval.flags = this.flags.toString(10); + retval.vdxfkey = this.key; + if (this.hasDataHash()) { + retval.datahash = this.data_hash.toString('hex'); + } + if (this.hasSystemID()) { + retval.systemid = this.system_id; + } + retval.startheight = this.height_start.toString(10); + retval.endheight = this.height_end.toString(10); + } + static fromJson(data) { + return new IdentityMultimapRef({ + version: new bn_js_1.BN(data.version), + flags: new bn_js_1.BN(data.flags), + key: data.vdxfkey, + height_start: new bn_js_1.BN(data.startheight), + height_end: new bn_js_1.BN(data.endheight), + data_hash: Buffer.from(data.datahash, 'hex'), + system_id: data.systemid + }); + } +} +exports.IdentityMultimapRef = IdentityMultimapRef; +IdentityMultimapRef.FLAG_NO_DELETION = new bn_js_1.BN(1); +IdentityMultimapRef.FLAG_HAS_DATAHASH = new bn_js_1.BN(2); +IdentityMultimapRef.FLAG_HAS_SYSTEM = new bn_js_1.BN(4); +IdentityMultimapRef.FIRST_VERSION = new bn_js_1.BN(1); +IdentityMultimapRef.LAST_VERSION = new bn_js_1.BN(1); +IdentityMultimapRef.CURRENT_VERSION = new bn_js_1.BN(1); diff --git a/dist/pbaas/MMR.d.ts b/dist/pbaas/MMR.d.ts new file mode 100644 index 0000000..762fece --- /dev/null +++ b/dist/pbaas/MMR.d.ts @@ -0,0 +1,71 @@ +/// +export declare class MMRLayer { + private vSize; + private nodes; + constructor(); + size(): number; + getIndex(idx: number): NODE_TYPE; + push_back(node: NODE_TYPE): void; + clear(): void; +} +export declare class MMRNode { + hash: Buffer; + constructor(Hash?: Buffer); + digest(input: any): any; + hashObj(obj: Buffer, onbjR?: Buffer): Buffer; + createParentNode(nRight: MMRNode): MMRNode; + getProofHash(opposite: MMRNode): Array; + getLeafHash(): Array; + getExtraHashCount(): number; +} +export declare class MerkleMountainRange { + layer0: MMRLayer; + vSize: number; + upperNodes: Array>; + _leafLength: number; + constructor(); + getbyteLength(): number; + toBuffer(): Buffer; + fromBuffer(bufferIn: Buffer): MerkleMountainRange; + add(leaf: MMRNode): number; + size(): number; + height(): number; + getNode(Height: any, Index: any): MMRNode; +} +export declare class MMRBranch { + branchType?: number; + nIndex?: number; + nSize?: number; + branch?: Array; + constructor(branchType?: number, nIndex?: number, nSize?: number, branch?: Array); + dataByteLength(): number; + toBuffer(): Buffer; + fromBuffer(buffer: Buffer, offset?: number): number; + digest(input: any): any; + safeCheck(hash: Buffer): Buffer; +} +export declare class MMRProof { + proofSequence: Array; + setProof(proof: MMRBranch): void; + dataByteLength(): number; + toBuffer(): Buffer; + fromDataBuffer(buffer: Buffer, offset?: number): number; +} +export declare class MerkleMountainView { + mmr: MerkleMountainRange; + sizes: Array; + peaks: Array; + peakMerkle: Array>; + constructor(mountainRange: MerkleMountainRange, viewSize?: number); + size(): number; + calcPeaks(force?: boolean): void; + resize(newSize: number): number; + maxsize(): number; + getPeaks(): Array; + getRoot(): Buffer; + getRootNode(): MMRNode; + getHash(index: number): Buffer; + getBranchType(): number; + getProof(retProof: MMRProof, pos: number): boolean; + getProofBits(pos: number, mmvSize: number): void; +} diff --git a/dist/pbaas/MMR.js b/dist/pbaas/MMR.js new file mode 100644 index 0000000..21212ab --- /dev/null +++ b/dist/pbaas/MMR.js @@ -0,0 +1,460 @@ +"use strict"; +// Licence MIT +// Adapted to Verus Blake2b MMR. +Object.defineProperty(exports, "__esModule", { value: true }); +exports.MerkleMountainView = exports.MMRProof = exports.MMRBranch = exports.MerkleMountainRange = exports.MMRNode = exports.MMRLayer = void 0; +var blake2b = require('blake2b'); +const bn_js_1 = require("bn.js"); +const varuint_1 = require("../utils/varuint"); +const bufferutils_1 = require("../utils/bufferutils"); +const mmr_1 = require("../utils/mmr"); +const { BufferReader, BufferWriter } = bufferutils_1.default; +const BRANCH_MMRBLAKE_NODE = 2; +class MMRLayer { + constructor() { this.vSize = 0; } + size() { + return this.vSize; + } + getIndex(idx) { + if (idx < this.vSize) { + return this.nodes[idx]; + } + else { + throw new Error("CChunkedLayer [] index out of range"); + } + } + push_back(node) { + this.vSize++; + if (!this.nodes) { + this.nodes = new Array(); + } + this.nodes.push(node); + } + clear() { + this.nodes = null; + this.vSize = 0; + } +} +exports.MMRLayer = MMRLayer; +; +class MMRNode { + constructor(Hash) { + if (Hash) { + this.hash = Hash; + } + } + digest(input) { + var out = Buffer.allocUnsafe(32); + return blake2b(out.length, null, null, Buffer.from("VerusDefaultHash")).update(input).digest(out); + } + hashObj(obj, onbjR) { + if (!onbjR) + return this.digest(obj); + else + return this.digest(Buffer.concat([obj, onbjR])); + } + // add a right to this left and create a parent node + createParentNode(nRight) { + return new MMRNode(this.digest(Buffer.concat([this.hash, nRight.hash]))); + } + getProofHash(opposite) { + return [this.hash]; + } + // leaf nodes that track additional data, such as block power, may need a hash added to the path + // at the very beginning + getLeafHash() { return []; } + getExtraHashCount() { + // how many extra proof hashes per layer are added with this node + return 0; + } +} +exports.MMRNode = MMRNode; +; +//template , typename LAYER0_TYPE=LAYER_TYPE> +class MerkleMountainRange { + constructor() { + this.layer0 = new MMRLayer(); + this.vSize = 0; + this.upperNodes = new Array(); + this._leafLength = 0; + } + getbyteLength() { + return 1; + } + toBuffer() { + return Buffer.from([]); + } + fromBuffer(bufferIn) { + return new MerkleMountainRange(); + } + add(leaf) { + this.layer0.push_back(leaf); + let height = 0; + let layerSize; + for (layerSize = this.layer0.size(); height <= this.upperNodes.length && layerSize > 1; height++) { + let newSizeAbove = layerSize >> 1; + // expand vector of vectors if we are adding a new layer + if (height == this.upperNodes.length) { + this.upperNodes.push(new MMRLayer()); + } + let curSizeAbove = this.upperNodes[height].size(); + // if we need to add an element to the vector above us, do it + if (!(layerSize & 1) && newSizeAbove > curSizeAbove) { + let idx = layerSize - 2; + if (height > 0) { + this.upperNodes[height].push_back(this.upperNodes[height - 1].getIndex(idx).createParentNode(this.upperNodes[height - 1].getIndex(idx + 1))); + } + else { + this.upperNodes[height].push_back(this.layer0.getIndex(idx).createParentNode(this.layer0.getIndex(idx + 1))); + } + } + layerSize = newSizeAbove; + } + // return new index + return this.layer0.size() - 1; + } + size() { + return this.layer0.size(); + } + height() { + return this.layer0.size() > 0 ? this.upperNodes.length + 1 : 0; + } + getNode(Height, Index) { + let layers = this.height(); + if (Height < layers) { + if (Height) { + if (Index < this.upperNodes[Height - 1].size()) { + return this.upperNodes[Height - 1].getIndex(Index); + } + } + else { + if (Index < this.layer0.size()) { + return this.layer0.getIndex(Index); + } + } + } + return null; + } +} +exports.MerkleMountainRange = MerkleMountainRange; +class MMRBranch { + constructor(branchType = BRANCH_MMRBLAKE_NODE, nIndex = 0, nSize = 0, branch = new Array()) { + this.branchType = branchType; + this.nIndex = nIndex; + this.nSize = nSize; + this.branch = branch; + } + dataByteLength() { + let length = 0; + length += varuint_1.default.encodingLength(this.branchType); + length += varuint_1.default.encodingLength(this.nIndex); + length += varuint_1.default.encodingLength(this.nSize); + length += varuint_1.default.encodingLength(this.branch.length); + for (let i = 0; i < this.branch.length; i++) { + length += this.branch[i].length; + } + return length; + } + toBuffer() { + const bufferWriter = new BufferWriter(Buffer.alloc(this.dataByteLength())); + bufferWriter.writeCompactSize(this.branchType); + bufferWriter.writeCompactSize(this.nIndex); + bufferWriter.writeCompactSize(this.nSize); + bufferWriter.writeCompactSize(this.branch.length); + for (let i = 0; i < this.branch.length; i++) { + bufferWriter.writeSlice(this.branch[i]); + } + return bufferWriter.buffer; + } + fromBuffer(buffer, offset) { + const reader = new bufferutils_1.default.BufferReader(buffer, offset); + this.branchType = reader.readCompactSize(); + this.nIndex = reader.readCompactSize(); + this.nSize = reader.readCompactSize(); + let branchLength = reader.readCompactSize(); + this.branch = new Array(); + for (let i = 0; i < branchLength; i++) { + this.branch.push(reader.readSlice(32)); + } + return reader.offset; + } + digest(input) { + var out = Buffer.allocUnsafe(32); + return blake2b(out.length, null, null, Buffer.from("VerusDefaultHash")).update(input).digest(out); + } + safeCheck(hash) { + let index = (0, mmr_1.GetMMRProofIndex)(this.nIndex, this.nSize, 0); + let joined = Buffer.allocUnsafe(64); + let hashInProgress = hash; + for (let i = 0; i < this.branch.length; i++) { + if (index.and(new bn_js_1.BN(1)).gt(new bn_js_1.BN(0))) { + if (this.branch[i] === hashInProgress) + throw new Error("Value can be equal to node but never on the right"); + joined = Buffer.concat([this.branch[i], hashInProgress]); + } + else { + joined = Buffer.concat([hashInProgress, this.branch[i]]); + } + hashInProgress = this.digest(joined); + index = index.shrn(1); + } + return hashInProgress; + } +} +exports.MMRBranch = MMRBranch; +class MMRProof { + setProof(proof) { + if (!this.proofSequence) { + this.proofSequence = new Array(); + } + this.proofSequence.push(proof); + } + dataByteLength() { + let length = 0; + length += varuint_1.default.encodingLength(this.proofSequence.length); + for (let i = 0; i < this.proofSequence.length; i++) { + length += this.proofSequence[i].dataByteLength(); + } + return length; + } + toBuffer() { + const bufferWriter = new BufferWriter(Buffer.alloc(this.dataByteLength())); + bufferWriter.writeCompactSize(this.proofSequence.length); + for (let i = 0; i < this.proofSequence.length; i++) { + bufferWriter.writeSlice(this.proofSequence[i].toBuffer()); + } + return bufferWriter.buffer; + } + fromDataBuffer(buffer, offset) { + const reader = new bufferutils_1.default.BufferReader(buffer, offset); + let proofSequenceLength = reader.readCompactSize(); + this.proofSequence = new Array(); + for (let i = 0; i < proofSequenceLength; i++) { + let proof = new MMRBranch(); + reader.offset = proof.fromBuffer(reader.buffer, reader.offset); + this.setProof(proof); + } + return reader.offset; + } +} +exports.MMRProof = MMRProof; +//template , typename LAYER0_TYPE=LAYER_TYPE, typename HASHALGOWRITER=CBLAKE2bWriter> +class MerkleMountainView { + constructor(mountainRange, viewSize = 0) { + this.mmr = mountainRange; + let maxSize = this.mmr.size(); + if (viewSize > maxSize || viewSize == 0) { + viewSize = maxSize; + } + this.sizes = new Array(); + this.sizes.push(viewSize); + for (viewSize >>= 1; viewSize; viewSize >>= 1) { + this.sizes.push(viewSize); + } + this.peakMerkle = new Array(); + this.peaks = new Array(); + } + // how many elements are stored in this view + size() { + // zero if empty or the size of the zeroeth layer + return this.sizes.length == 0 ? 0 : this.sizes[0]; + } + calcPeaks(force = false) { + // if we don't yet have calculated peaks, calculate them + if (force || (this.peaks.length == 0 && this.size() != 0)) { + // reset the peak merkle tree, in case this is forced + this.peaks = new Array; + this.peakMerkle = new Array; + for (let ht = 0; ht < this.sizes.length; ht++) { + // if we're at the top or the layer above us is smaller than 1/2 the size of this layer, rounded up, we are a peak + if (ht == (this.sizes.length - 1) || this.sizes[ht + 1] < ((this.sizes[ht] + 1) >> 1)) { + this.peaks.splice(0, 0, this.mmr.getNode(ht, this.sizes[ht] - 1)); + } + } + } + } + resize(newSize) { + if (newSize != this.size()) { + this.sizes = new Array; + this.peaks = new Array; + this.peakMerkle = new Array; + let maxSize = this.mmr.size(); + if (newSize > maxSize) { + newSize = maxSize; + } + this.sizes.push(newSize); + newSize >>= 1; + while (newSize) { + this.sizes.push(newSize); + newSize >>= 1; + } + } + return this.size(); + } + maxsize() { + return this.mmr.size() - 1; + } + getPeaks() { + this.calcPeaks(); + return this.peaks; + } + getRoot() { + let rootHash = Buffer.allocUnsafe(32); + if (this.size() > 0 && this.peakMerkle.length == 0) { + // get peaks and hash to a root + this.calcPeaks(); + let layerNum = 0, layerSize = this.peaks.length; + // with an odd number of elements below, the edge passes through + for (let passThrough = !!(layerSize & 1); layerNum == 0 || layerSize > 1; passThrough = !!(layerSize & 1), layerNum++) { + this.peakMerkle.push(Array()); + let i; + let layerIndex = layerNum ? layerNum - 1 : 0; // layerNum is base 1 + for (i = 0; i < (layerSize >> 1); i++) { + if (layerNum > 0) { + this.peakMerkle[this.peakMerkle.length - 1].push(this.peakMerkle[layerIndex][i << 1].createParentNode(this.peakMerkle[layerIndex][(i << 1) + 1])); + } + else { + this.peakMerkle[this.peakMerkle.length - 1].push(this.peaks[i << 1].createParentNode(this.peaks[(i << 1) + 1])); + } + } + if (passThrough) { + if (layerNum > 0) { + // pass the end of the prior layer through + this.peakMerkle[this.peakMerkle.length - 1].push(this.peakMerkle[layerIndex][this.peakMerkle[layerIndex].length - 1]); + } + else { + this.peakMerkle[this.peakMerkle.length].push(this.peaks[this.peaks.length - 1]); + } + } + // each entry in the next layer should be either combined two of the prior layer, or a duplicate of the prior layer's end + layerSize = this.peakMerkle[this.peakMerkle.length - 1].length; + } + rootHash = this.peakMerkle[this.peakMerkle.length - 1][0].hash; + } + else if (this.peakMerkle.length > 0) { + rootHash = this.peakMerkle[this.peakMerkle.length - 1][0].hash; + } + return rootHash; + } + getRootNode() { + // ensure merkle tree is calculated + let root = this.getRoot(); + if (root.length > 0) { + return this.peakMerkle[this.peakMerkle.length - 1][0]; + } + else { + return null; + } + } + // return hash of the element at "index" + getHash(index) { + if (index < this.size()) { + return this.mmr.layer0[index].hash; + } + else { + return Buffer.allocUnsafe(32); + } + } + getBranchType() { + return BRANCH_MMRBLAKE_NODE; + } + // return a proof of the element at "pos" + getProof(retProof, pos) { + // find a path from the indicated position to the root in the current view + let retBranch = new MMRBranch(); + if (pos < this.size()) { + // just make sure the peakMerkle tree is calculated + this.getRoot(); + // if we have leaf information, add it + let toAdd = this.mmr.layer0.getIndex(pos).getLeafHash(); + if (toAdd.length > 0) { + retBranch.branch.splice(retBranch.branch.length, 0, toAdd[0]); + } + let p = pos; + for (let l = 0; l < this.sizes.length; l++) { + if ((p & 1) === 1) { + let proofHashes = this.mmr.getNode(l, p - 1).hash; + retBranch.branch = retBranch.branch.concat(proofHashes); + p >>= 1; + } + else { + // make sure there is one after us to hash with or we are a peak and should be hashed with the rest of the peaks + if (this.sizes[l] > (p + 1)) { + let proofHashes = this.mmr.getNode(l, p + 1).hash; + retBranch.branch = retBranch.branch.concat(proofHashes); + p >>= 1; + } + else { + /* for (auto &oneNode : peaks) + { + printf("peaknode: "); + for (auto oneHash : oneNode.getProofHash(oneNode)) + { + printf("%s:", oneHash.GetHex().c_str()); + } + printf("\n"); + } */ + // we are at a peak, the alternate peak to us, or the next thing we should be hashed with, if there is one, is next on our path + let peakHash = this.mmr.getNode(l, p).hash; + // linear search to find out which peak we are in the base of the peakMerkle + for (p = 0; p < this.peaks.length; p++) { + if (this.peaks[p].hash == peakHash) { + break; + } + } + // p is the position in the merkle tree of peaks + if (p > this.peaks.length) + throw new Error("peak not found"); + // move up to the top, which is always a peak of size 1 + let layerNum, layerSize; + for (layerNum = 0, layerSize = this.peaks.length; layerNum == 0 || layerSize > 1; layerSize = this.peakMerkle[layerNum++].length) { + let layerIndex = layerNum ? layerNum - 1 : 0; // layerNum is base 1 + // we are an odd member on the end (even index) and will not hash with the next layer above, we will propagate to its end + if ((p < layerSize - 1) || (p & 1)) { + if (p & 1) { + // hash with the one before us + if (layerNum > 0) { + let proofHashes = this.peakMerkle[layerIndex][p - 1].hash; + retBranch.branch = retBranch.branch.concat(proofHashes); + } + else { + let proofHashes = this.peaks[p - 1].hash; + retBranch.branch = retBranch.branch.concat(proofHashes); + } + } + else { + // hash with the one in front of us + if (layerNum > 0) { + let proofHashes = this.peakMerkle[layerIndex][p + 1].hash; + retBranch.branch = retBranch.branch.concat(proofHashes); + } + else { + let proofHashes = this.peaks[p + 1].hash; + retBranch.branch = retBranch.branch.concat(proofHashes); + } + } + } + p >>= 1; + } + // finished + break; + } + } + } + retBranch.branchType = this.getBranchType(); + retBranch.nSize = this.size(); + retBranch.nIndex = pos; + retProof.setProof(retBranch); + return true; + } + return false; + } + // return a vector of the bits, either 1 or 0 in each byte, to represent both the size + // of the proof by the size of the vector, and the expected bit in each position for the given + // position in a Merkle Mountain View of the specified size + getProofBits(pos, mmvSize) { + //NOTE: Not implmented. + } + ; +} +exports.MerkleMountainView = MerkleMountainView; diff --git a/dist/pbaas/MMRDescriptor.d.ts b/dist/pbaas/MMRDescriptor.d.ts new file mode 100644 index 0000000..2b1a99d --- /dev/null +++ b/dist/pbaas/MMRDescriptor.d.ts @@ -0,0 +1,41 @@ +/// +/// +import { BigNumber } from '../utils/types/BigNumber'; +import { DataDescriptor, DataDescriptorJson } from './DataDescriptor'; +import { EHashTypes } from './DataDescriptor'; +import { SerializableEntity } from '../utils/types/SerializableEntity'; +export interface MMRDescriptorJson { + version: number; + objecthashtype?: number; + mmrhashtype?: number; + mmrroot?: DataDescriptorJson; + mmrhashes?: DataDescriptorJson; + datadescriptors?: DataDescriptorJson[]; +} +export declare class MMRDescriptor implements SerializableEntity { + static VERSION_INVALID: import("bn.js"); + static FIRST_VERSION: import("bn.js"); + static LAST_VERSION: import("bn.js"); + static DEFAULT_VERSION: import("bn.js"); + version: BigNumber; + objectHashType: EHashTypes; + mmrHashType: EHashTypes; + mmrRoot: DataDescriptor; + mmrHashes: DataDescriptor; + dataDescriptors: DataDescriptor[]; + constructor(data?: { + version?: BigNumber; + objectHashType?: EHashTypes; + mmrHashType?: EHashTypes; + mmrRoot?: DataDescriptor; + mmrHashes?: DataDescriptor; + dataDescriptors?: DataDescriptor[]; + }); + static fromJson(data: MMRDescriptorJson): MMRDescriptor; + getByteLength(): number; + toBuffer(): Buffer; + fromBuffer(buffer: Buffer, offset?: number): number; + hasData(): boolean; + isValid(): boolean; + toJson(): MMRDescriptorJson; +} diff --git a/dist/pbaas/MMRDescriptor.js b/dist/pbaas/MMRDescriptor.js new file mode 100644 index 0000000..a0f0188 --- /dev/null +++ b/dist/pbaas/MMRDescriptor.js @@ -0,0 +1,120 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.MMRDescriptor = void 0; +const bn_js_1 = require("bn.js"); +const varint_1 = require("../utils/varint"); +const varuint_1 = require("../utils/varuint"); +const bufferutils_1 = require("../utils/bufferutils"); +const { BufferReader, BufferWriter } = bufferutils_1.default; +const DataDescriptor_1 = require("./DataDescriptor"); +class MMRDescriptor { + constructor(data) { + if (data) { + if (data.version) + this.version = data.version; + if (data.objectHashType) + this.objectHashType = data.objectHashType; + if (data.mmrHashType) + this.mmrHashType = data.mmrHashType; + if (data.mmrRoot) + this.mmrRoot = data.mmrRoot; + if (data.mmrHashes) + this.mmrHashes = data.mmrHashes; + if (data.dataDescriptors) + this.dataDescriptors = data.dataDescriptors; + } + else { + this.version = MMRDescriptor.DEFAULT_VERSION; + } + } + static fromJson(data) { + const newMMRDescriptor = new MMRDescriptor(); + if (data) { + if (data.version) + newMMRDescriptor.version = new bn_js_1.BN(data.version); + if (data.objecthashtype) + newMMRDescriptor.objectHashType = data.objecthashtype; + if (data.mmrhashtype) + newMMRDescriptor.mmrHashType = data.mmrhashtype; + if (data.mmrroot) + newMMRDescriptor.mmrRoot = DataDescriptor_1.DataDescriptor.fromJson(data.mmrroot); + if (data.mmrhashes) + newMMRDescriptor.mmrHashes = DataDescriptor_1.DataDescriptor.fromJson(data.mmrhashes); + if (data.datadescriptors) { + newMMRDescriptor.dataDescriptors = []; + data.datadescriptors.forEach((data) => { + newMMRDescriptor.dataDescriptors.push(DataDescriptor_1.DataDescriptor.fromJson(data)); + }); + } + ; + } + return newMMRDescriptor; + } + getByteLength() { + let length = 0; + length += varint_1.default.encodingLength(this.version); + length += varint_1.default.encodingLength(new bn_js_1.BN(this.objectHashType)); + length += varint_1.default.encodingLength(new bn_js_1.BN(this.mmrHashType)); + length += this.mmrRoot.getByteLength(); + length += this.mmrHashes.getByteLength(); + length += varuint_1.default.encodingLength(this.dataDescriptors.length); + this.dataDescriptors.forEach((dataDescriptor) => { + length += dataDescriptor.getByteLength(); + }); + return length; + } + toBuffer() { + const writer = new BufferWriter(Buffer.alloc(this.getByteLength())); + writer.writeVarInt(this.version); + writer.writeVarInt(new bn_js_1.BN(this.objectHashType)); + writer.writeVarInt(new bn_js_1.BN(this.mmrHashType)); + writer.writeSlice(this.mmrRoot.toBuffer()); + writer.writeSlice(this.mmrHashes.toBuffer()); + writer.writeCompactSize(this.dataDescriptors.length); + this.dataDescriptors.forEach((dataDescriptor) => { + writer.writeSlice(dataDescriptor.toBuffer()); + }); + return writer.buffer; + } + fromBuffer(buffer, offset) { + const reader = new BufferReader(buffer, offset); + this.version = reader.readVarInt(); + this.objectHashType = reader.readVarInt().toNumber(); + this.mmrHashType = reader.readVarInt().toNumber(); + this.mmrRoot = new DataDescriptor_1.DataDescriptor(); + reader.offset = this.mmrRoot.fromBuffer(reader.buffer, reader.offset); + this.mmrHashes = new DataDescriptor_1.DataDescriptor(); + reader.offset = this.mmrHashes.fromBuffer(reader.buffer, reader.offset); + const dataDescriptorsLength = reader.readCompactSize(); + this.dataDescriptors = []; + for (let i = 0; i < dataDescriptorsLength; i++) { + const dataDescriptor = new DataDescriptor_1.DataDescriptor(); + reader.offset = dataDescriptor.fromBuffer(reader.buffer, reader.offset); + this.dataDescriptors.push(dataDescriptor); + } + return reader.offset; + } + hasData() { + return !!(this.mmrHashes.objectdata && this.dataDescriptors); + } + isValid() { + return this.version >= MMRDescriptor.FIRST_VERSION && this.version <= MMRDescriptor.LAST_VERSION; + } + toJson() { + const retval = { + version: this.version.toNumber(), + objecthashtype: this.objectHashType.valueOf(), + mmrhashtype: this.mmrHashType, + mmrroot: this.mmrRoot.toJson(), + mmrhashes: this.mmrHashes.toJson(), + datadescriptors: this.dataDescriptors.map((dataDescriptor) => dataDescriptor.toJson()) + }; + return retval; + } +} +exports.MMRDescriptor = MMRDescriptor; +MMRDescriptor.VERSION_INVALID = new bn_js_1.BN(0); +MMRDescriptor.FIRST_VERSION = new bn_js_1.BN(1); +MMRDescriptor.LAST_VERSION = new bn_js_1.BN(1); +MMRDescriptor.DEFAULT_VERSION = new bn_js_1.BN(1); +; diff --git a/dist/pbaas/PBaaSEvidenceRef.d.ts b/dist/pbaas/PBaaSEvidenceRef.d.ts new file mode 100644 index 0000000..8961c7a --- /dev/null +++ b/dist/pbaas/PBaaSEvidenceRef.d.ts @@ -0,0 +1,40 @@ +/// +/// +import { BigNumber } from '../utils/types/BigNumber'; +import { SerializableEntity } from '../utils/types/SerializableEntity'; +import { UTXORef } from './UTXORef'; +export interface PBaaSEvidenceRefJson { + version: number; + flags: number; + output: any; + objectnum: number; + subobject: number; + systemid: string; +} +export declare class PBaaSEvidenceRef implements SerializableEntity { + version: BigNumber; + flags: BigNumber; + output: UTXORef; + object_num: BigNumber; + sub_object: BigNumber; + system_id: string; + static FLAG_ISEVIDENCE: import("bn.js"); + static FLAG_HAS_SYSTEM: import("bn.js"); + static FIRST_VERSION: import("bn.js"); + static LAST_VERSION: import("bn.js"); + constructor(data?: { + version?: BigNumber; + flags?: BigNumber; + output?: UTXORef; + object_num?: BigNumber; + sub_object?: BigNumber; + system_id?: string; + }); + setFlags(): void; + getByteLength(): number; + toBuffer(): Buffer; + fromBuffer(buffer: Buffer, offset?: number): number; + isValid(): boolean; + toJson(): PBaaSEvidenceRefJson; + static fromJson(json: PBaaSEvidenceRefJson): PBaaSEvidenceRef; +} diff --git a/dist/pbaas/PBaaSEvidenceRef.js b/dist/pbaas/PBaaSEvidenceRef.js new file mode 100644 index 0000000..ac727f2 --- /dev/null +++ b/dist/pbaas/PBaaSEvidenceRef.js @@ -0,0 +1,98 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.PBaaSEvidenceRef = void 0; +const varint_1 = require("../utils/varint"); +const address_1 = require("../utils/address"); +const bufferutils_1 = require("../utils/bufferutils"); +const bn_js_1 = require("bn.js"); +const vdxf_1 = require("../constants/vdxf"); +const UTXORef_1 = require("./UTXORef"); +const IdentityMultimapRef_1 = require("./IdentityMultimapRef"); +const { BufferReader, BufferWriter } = bufferutils_1.default; +class PBaaSEvidenceRef { + constructor(data) { + if (data) { + this.version = data.version || new bn_js_1.BN(1, 10); + this.flags = data.flags || new bn_js_1.BN(0); + this.output = data.output || new UTXORef_1.UTXORef(); + this.object_num = data.object_num || new bn_js_1.BN(0); + this.sub_object = data.sub_object || new bn_js_1.BN(0); + this.system_id = data.system_id || ""; + } + } + setFlags() { + this.flags = this.flags.and(PBaaSEvidenceRef.FLAG_ISEVIDENCE); + if (this.system_id && this.system_id.length > 0) { + this.flags = this.flags.or(PBaaSEvidenceRef.FLAG_HAS_SYSTEM); + } + } + getByteLength() { + let byteLength = 0; + this.setFlags(); + byteLength += varint_1.default.encodingLength(this.version); + byteLength += varint_1.default.encodingLength(this.flags); + byteLength += this.output.getByteLength(); + byteLength += varint_1.default.encodingLength(this.object_num); + byteLength += varint_1.default.encodingLength(this.sub_object); + if (this.flags.and(PBaaSEvidenceRef.FLAG_HAS_SYSTEM).gt(new bn_js_1.BN(0))) { + byteLength += 20; + } + return byteLength; + } + toBuffer() { + const bufferWriter = new BufferWriter(Buffer.alloc(this.getByteLength())); + bufferWriter.writeVarInt(this.version); + bufferWriter.writeVarInt(this.flags); + bufferWriter.writeSlice(this.output.toBuffer()); + bufferWriter.writeVarInt(this.object_num); + bufferWriter.writeVarInt(this.sub_object); + if (this.flags.and(PBaaSEvidenceRef.FLAG_HAS_SYSTEM).gt(new bn_js_1.BN(0))) { + bufferWriter.writeSlice((0, address_1.fromBase58Check)(this.system_id).hash); + } + return bufferWriter.buffer; + } + fromBuffer(buffer, offset = 0) { + const reader = new BufferReader(buffer, offset); + this.version = reader.readVarInt(); + this.flags = reader.readVarInt(); + this.output = new UTXORef_1.UTXORef(); + offset = this.output.fromBuffer(reader.buffer, reader.offset); + this.object_num = reader.readVarInt(); + this.sub_object = reader.readVarInt(); + if (this.flags.and(IdentityMultimapRef_1.IdentityMultimapRef.FLAG_HAS_DATAHASH).gt(new bn_js_1.BN(0))) { + this.system_id = (0, address_1.toBase58Check)(reader.readSlice(20), vdxf_1.I_ADDR_VERSION); + } + return reader.offset; + } + isValid() { + return this.output.isValid() && this.version.gte(PBaaSEvidenceRef.FIRST_VERSION) && + this.version.lte(PBaaSEvidenceRef.LAST_VERSION) && + (this.flags.and(PBaaSEvidenceRef.FLAG_ISEVIDENCE).gt(new bn_js_1.BN(0))); + } + toJson() { + let retval = { + version: this.version.toNumber(), + flags: this.flags.toNumber(), + output: this.output.toJson(), + objectnum: this.object_num.toNumber(), + subobject: this.sub_object.toNumber(), + systemid: this.system_id || "" + }; + return retval; + } + static fromJson(json) { + return new PBaaSEvidenceRef({ + version: new bn_js_1.BN(json.version), + flags: new bn_js_1.BN(json.flags), + output: UTXORef_1.UTXORef.fromJson(json.output), + object_num: new bn_js_1.BN(json.objectnum), + sub_object: new bn_js_1.BN(json.subobject), + system_id: json.systemid + }); + } +} +exports.PBaaSEvidenceRef = PBaaSEvidenceRef; +PBaaSEvidenceRef.FLAG_ISEVIDENCE = new bn_js_1.BN(1); +PBaaSEvidenceRef.FLAG_HAS_SYSTEM = new bn_js_1.BN(2); +PBaaSEvidenceRef.FIRST_VERSION = new bn_js_1.BN(1); +PBaaSEvidenceRef.LAST_VERSION = new bn_js_1.BN(1); diff --git a/dist/pbaas/Rating.d.ts b/dist/pbaas/Rating.d.ts new file mode 100644 index 0000000..cf550b3 --- /dev/null +++ b/dist/pbaas/Rating.d.ts @@ -0,0 +1,42 @@ +/// +/// +import { BigNumber } from '../utils/types/BigNumber'; +import { SerializableEntity } from '../utils/types/SerializableEntity'; +export interface RatingJson { + version: number; + trustlevel: number; + ratingsmap: { + [key: string]: string; + }; +} +export declare class Rating implements SerializableEntity { + static VERSION_INVALID: import("bn.js"); + static VERSION_FIRST: import("bn.js"); + static VERSION_LAST: import("bn.js"); + static VERSION_CURRENT: import("bn.js"); + static TRUST_UNKNOWN: import("bn.js"); + static TRUST_BLOCKED: import("bn.js"); + static TRUST_APPROVED: import("bn.js"); + static TRUST_FIRST: import("bn.js"); + static TRUST_LAST: import("bn.js"); + version: BigNumber; + trust_level: BigNumber; + ratings: Map; + constructor(data?: { + version?: BigNumber; + trust_level?: BigNumber; + ratings?: Map; + }); + getByteLength(): number; + toBuffer(): Buffer; + fromBuffer(buffer: Buffer, offset?: number): number; + isValid(): boolean; + toJson(): { + version: string; + trust_level: string; + ratings: { + [key: string]: string; + }; + }; + static fromJson(json: RatingJson): Rating; +} diff --git a/dist/pbaas/Rating.js b/dist/pbaas/Rating.js new file mode 100644 index 0000000..dfab329 --- /dev/null +++ b/dist/pbaas/Rating.js @@ -0,0 +1,89 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.Rating = void 0; +const varuint_1 = require("../utils/varuint"); +const address_1 = require("../utils/address"); +const bufferutils_1 = require("../utils/bufferutils"); +const bn_js_1 = require("bn.js"); +const vdxf_1 = require("../constants/vdxf"); +const { BufferReader, BufferWriter } = bufferutils_1.default; +class Rating { + constructor(data = {}) { + this.version = data.version || new bn_js_1.BN(1, 10); + this.trust_level = data.trust_level || new bn_js_1.BN(0, 10); + this.ratings = new Map(data.ratings || []); + } + getByteLength() { + let byteLength = 0; + byteLength += 4; // version uint32 + byteLength += 1; // trust_level uint8 + byteLength += varuint_1.default.encodingLength(this.ratings.size); + for (const [key, value] of this.ratings) { + byteLength += 20; + byteLength += varuint_1.default.encodingLength(value.length); + byteLength += value.length; + } + return byteLength; + } + toBuffer() { + const bufferWriter = new BufferWriter(Buffer.alloc(this.getByteLength())); + bufferWriter.writeUInt32(this.version.toNumber()); + bufferWriter.writeUInt8(this.trust_level.toNumber()); + bufferWriter.writeCompactSize(this.ratings.size); + for (const [key, value] of this.ratings) { + const { hash } = (0, address_1.fromBase58Check)(key); + bufferWriter.writeSlice(hash); + bufferWriter.writeVarSlice(value); + } + return bufferWriter.buffer; + } + fromBuffer(buffer, offset = 0) { + const reader = new BufferReader(buffer, offset); + this.version = new bn_js_1.BN(reader.readUInt32()); + this.trust_level = new bn_js_1.BN(reader.readUInt8()); + const count = reader.readCompactSize(); + for (let i = 0; i < count; i++) { + const hash = reader.readSlice(20); + const value = reader.readVarSlice(); + const base58Key = (0, address_1.toBase58Check)(hash, vdxf_1.I_ADDR_VERSION); + this.ratings.set(base58Key, value); + } + return reader.offset; + } + isValid() { + return this.version.gte(Rating.VERSION_FIRST) && this.version.lte(Rating.VERSION_LAST) && + this.trust_level.gte(Rating.TRUST_FIRST) && this.trust_level.lte(Rating.TRUST_LAST); + } + toJson() { + const ratings = {}; + this.ratings.forEach((value, key) => { + ratings[key] = value.toString('hex'); + }); + return { + version: this.version.toString(), + trust_level: this.trust_level.toString(), + ratings: ratings + }; + } + static fromJson(json) { + const ratings = new Map(); + for (const key in json.ratingsmap) { + ratings.set(key, Buffer.from(json.ratingsmap[key], 'hex')); + } + return new Rating({ + version: new bn_js_1.BN(json.version), + trust_level: new bn_js_1.BN(json.trustlevel), + ratings: ratings + }); + } +} +exports.Rating = Rating; +Rating.VERSION_INVALID = new bn_js_1.BN(0, 10); +Rating.VERSION_FIRST = new bn_js_1.BN(1, 10); +Rating.VERSION_LAST = new bn_js_1.BN(1, 10); +Rating.VERSION_CURRENT = new bn_js_1.BN(1, 10); +Rating.TRUST_UNKNOWN = new bn_js_1.BN(0, 10); // unknown and can be included in exploration +Rating.TRUST_BLOCKED = new bn_js_1.BN(1, 10); // suspected or known to be untrustworthy and should not be interacted with +Rating.TRUST_APPROVED = new bn_js_1.BN(2, 10); // explicitly believed to be trustworthy enough to interact with +Rating.TRUST_FIRST = new bn_js_1.BN(0, 10); +Rating.TRUST_LAST = new bn_js_1.BN(2, 10); diff --git a/dist/pbaas/SaltedData.d.ts b/dist/pbaas/SaltedData.d.ts new file mode 100644 index 0000000..8182888 --- /dev/null +++ b/dist/pbaas/SaltedData.d.ts @@ -0,0 +1,17 @@ +/// +/// +import { VDXFData } from '../vdxf/index'; +export declare class SaltedData extends VDXFData { + salt: Buffer; + static VERSION_INVALID: import("bn.js"); + static FIRST_VERSION: import("bn.js"); + static LAST_VERSION: import("bn.js"); + static DEFAULT_VERSION: import("bn.js"); + constructor(data?: Buffer, salt?: Buffer); + static fromJson(data: any): SaltedData; + getByteLength(): number; + toBuffer(): Buffer; + fromBuffer(buffer: Buffer, offset?: number): number; + toJson(): any; + getHash(hw: (data: Buffer) => Buffer): Buffer; +} diff --git a/dist/pbaas/SaltedData.js b/dist/pbaas/SaltedData.js new file mode 100644 index 0000000..cc68520 --- /dev/null +++ b/dist/pbaas/SaltedData.js @@ -0,0 +1,82 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.SaltedData = void 0; +const varint_1 = require("../utils/varint"); +const varuint_1 = require("../utils/varuint"); +const address_1 = require("../utils/address"); +const bufferutils_1 = require("../utils/bufferutils"); +const bn_js_1 = require("bn.js"); +const vdxf_1 = require("../constants/vdxf"); +const index_1 = require("../vdxf/index"); +const { BufferReader, BufferWriter } = bufferutils_1.default; +const createHash = require("create-hash"); +const vdxfdatakeys_1 = require("../vdxf/vdxfdatakeys"); +class SaltedData extends index_1.VDXFData { + constructor(data, salt = Buffer.alloc(0)) { + super(data); + if (salt.length != 0) { + this.salt = salt; + } + this.vdxfkey = vdxfdatakeys_1.SaltedDataKey.vdxfid; + this.version = SaltedData.DEFAULT_VERSION; + } + static fromJson(data) { + const saltedData = new SaltedData(); + if (data) { + if (data.version) { + saltedData.version = new bn_js_1.BN(data.version); + } + else { + saltedData.version = SaltedData.DEFAULT_VERSION; + } + if (data.salt) + saltedData.salt = Buffer.from(data.salt, 'hex'); + if (data.data) + saltedData.data = Buffer.from(data.data, 'hex'); + if (data.key) + saltedData.vdxfkey = data.key; + } + return saltedData; + } + getByteLength() { + let byteLength = 0; + byteLength += 20; //key + byteLength += varint_1.default.encodingLength(this.version); + byteLength += varuint_1.default.encodingLength(this.data.length + this.salt.length); + byteLength += this.data.length + this.salt.length; + return byteLength; + } + toBuffer() { + const bufferWriter = new BufferWriter(Buffer.alloc(this.getByteLength())); + bufferWriter.writeSlice((0, address_1.fromBase58Check)(this.vdxfkey).hash); + bufferWriter.writeVarInt(this.version); + bufferWriter.writeVarSlice(Buffer.concat([this.data, this.salt])); + return bufferWriter.buffer; + } + fromBuffer(buffer, offset = 0) { + const reader = new BufferReader(buffer, offset); + this.vdxfkey = (0, address_1.toBase58Check)(reader.readSlice(20), vdxf_1.I_ADDR_VERSION); + this.version = reader.readVarInt(); + this.data = reader.readVarSlice(); + this.salt = this.data.slice(this.data.length - 32); + this.data = this.data.slice(0, this.data.length - 32); + return reader.offset; + } + toJson() { + return { + version: this.version.toString(), + key: this.vdxfkey, + data: this.data.toString('hex'), + salt: this.salt.toString('hex') + }; + } + getHash(hw) { + const hash = hw(Buffer.concat([this.data, this.salt])); + return hash; + } +} +exports.SaltedData = SaltedData; +SaltedData.VERSION_INVALID = new bn_js_1.BN(0); +SaltedData.FIRST_VERSION = new bn_js_1.BN(1); +SaltedData.LAST_VERSION = new bn_js_1.BN(1); +SaltedData.DEFAULT_VERSION = new bn_js_1.BN(1); diff --git a/dist/pbaas/SignatureData.d.ts b/dist/pbaas/SignatureData.d.ts new file mode 100644 index 0000000..7165093 --- /dev/null +++ b/dist/pbaas/SignatureData.d.ts @@ -0,0 +1,61 @@ +/// +/// +import { BigNumber } from '../utils/types/BigNumber'; +import { SerializableEntity } from '../utils/types/SerializableEntity'; +export interface SignatureJsonDataInterface { + version: number; + systemid: string; + hashtype: number; + signaturehash: string; + identityid: string; + signaturetype: number; + vdxfkeys: Array; + vdxfkeynames: Array; + boundhashes: Array; + signature: string; +} +export declare class SignatureData implements SerializableEntity { + version: BigNumber; + system_ID: string; + hash_type: BigNumber; + signature_hash: Buffer; + identity_ID: string; + sig_type: BigNumber; + vdxf_keys: Array; + vdxf_key_names: Array; + bound_hashes: Array; + signature_as_vch: Buffer; + static VERSION_INVALID: import("bn.js"); + static FIRST_VERSION: import("bn.js"); + static LAST_VERSION: import("bn.js"); + static DEFAULT_VERSION: import("bn.js"); + static TYPE_VERUSID_DEFAULT: import("bn.js"); + constructor(data?: { + version?: BigNumber; + system_ID?: string; + hash_type?: BigNumber; + signature_hash?: Buffer; + identity_ID?: string; + sig_type?: BigNumber; + vdxf_keys?: Array; + vdxf_key_names?: Array; + bound_hashes?: Array; + signature_as_vch?: Buffer; + }); + static fromJson(data: SignatureJsonDataInterface | any): SignatureData; + static getSignatureHashType(input: Buffer): number; + getByteLength(): number; + toBuffer(): Buffer; + fromBuffer(buffer: Buffer, offset?: number): number; + isValid(): boolean; + toJson(): { + version: string; + systemid: string; + hashtype: string; + }; + getIdentityHash(sigObject: { + version: number; + hash_type: number; + height: number; + }): any; +} diff --git a/dist/pbaas/SignatureData.js b/dist/pbaas/SignatureData.js new file mode 100644 index 0000000..db90a8d --- /dev/null +++ b/dist/pbaas/SignatureData.js @@ -0,0 +1,192 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.SignatureData = void 0; +const varint_1 = require("../utils/varint"); +const varuint_1 = require("../utils/varuint"); +const address_1 = require("../utils/address"); +const bufferutils_1 = require("../utils/bufferutils"); +const bn_js_1 = require("bn.js"); +const vdxf_1 = require("../constants/vdxf"); +const DataDescriptor_1 = require("./DataDescriptor"); +const { BufferReader, BufferWriter } = bufferutils_1.default; +const createHash = require("create-hash"); +const vdxf_2 = require("../constants/vdxf"); +class SignatureData { + constructor(data) { + if (data) { + this.version = data.version || new bn_js_1.BN(1, 10); + this.system_ID = data.system_ID || ""; + this.hash_type = data.hash_type || new bn_js_1.BN(0); + this.signature_hash = data.signature_hash || Buffer.alloc(0); + this.identity_ID = data.identity_ID || ""; + this.sig_type = data.sig_type || new bn_js_1.BN(0); + this.vdxf_keys = data.vdxf_keys || []; + this.vdxf_key_names = data.vdxf_key_names || []; + this.bound_hashes = data.bound_hashes || []; + this.signature_as_vch = data.signature_as_vch || Buffer.alloc(0); + } + } + static fromJson(data) { + var _a; + const signatureData = new SignatureData(); + if (data) { + signatureData.version = new bn_js_1.BN(data.version); + signatureData.system_ID = data.systemid; + signatureData.hash_type = new bn_js_1.BN(data.hashtype); + signatureData.identity_ID = data.identityid; + signatureData.sig_type = new bn_js_1.BN(data.signaturetype); + if (signatureData.hash_type == new bn_js_1.BN(DataDescriptor_1.EHashTypes.HASH_SHA256)) { + signatureData.signature_hash = Buffer.from(data.signaturehash, 'hex'); + } + else { + signatureData.signature_hash = Buffer.from(data.signaturehash, 'hex').reverse(); + } + signatureData.signature_as_vch = Buffer.from(data.signature, 'base64'); + signatureData.vdxf_keys = data.vdxfkeys || []; + signatureData.vdxf_key_names = data.vdxfkeynames || []; + signatureData.bound_hashes = ((_a = data.boundhashes) === null || _a === void 0 ? void 0 : _a.map((hash) => Buffer.from(hash, 'hex'))) || []; + } + return signatureData; + } + static getSignatureHashType(input) { + var bufferReader = new bufferutils_1.default.BufferReader(input, 0); + let version = bufferReader.readUInt8(); + if (version === 2) + return bufferReader.readUInt8(); + else + return DataDescriptor_1.EHashTypes.HASH_SHA256; + } + getByteLength() { + let byteLength = 0; + byteLength += varint_1.default.encodingLength(this.version); + byteLength += 20; // system_ID uint160 + byteLength += varint_1.default.encodingLength(this.hash_type); + byteLength += varuint_1.default.encodingLength(this.signature_hash.length); + byteLength += this.signature_hash.length; + byteLength += 20; // identity_ID uint160 + byteLength += varint_1.default.encodingLength(this.sig_type); + byteLength += varuint_1.default.encodingLength(this.vdxf_keys.length); + byteLength += this.vdxf_keys.length * 20; + byteLength += varuint_1.default.encodingLength(this.vdxf_key_names.length); + for (const keyName of this.vdxf_key_names) { + byteLength += varuint_1.default.encodingLength(Buffer.from(keyName, 'utf8').length); + byteLength += Buffer.from(keyName, 'utf8').length; + } + byteLength += varuint_1.default.encodingLength(this.bound_hashes.length); + byteLength += this.bound_hashes.length * 32; + byteLength += varuint_1.default.encodingLength(this.signature_as_vch.length); + byteLength += this.signature_as_vch.length; + return byteLength; + } + toBuffer() { + const bufferWriter = new BufferWriter(Buffer.alloc(this.getByteLength())); + bufferWriter.writeVarInt(this.version); + bufferWriter.writeSlice((0, address_1.fromBase58Check)(this.system_ID).hash); + bufferWriter.writeVarInt(this.hash_type); + bufferWriter.writeVarSlice(this.signature_hash); + bufferWriter.writeSlice((0, address_1.fromBase58Check)(this.identity_ID).hash); + bufferWriter.writeVarInt(this.sig_type); + bufferWriter.writeCompactSize(this.vdxf_keys.length); + for (const key of this.vdxf_keys) { + bufferWriter.writeSlice((0, address_1.fromBase58Check)(key).hash); + } + bufferWriter.writeCompactSize(this.vdxf_key_names.length); + for (const keyName of this.vdxf_key_names) { + bufferWriter.writeVarSlice(Buffer.from(keyName, 'utf8')); + } + bufferWriter.writeCompactSize(this.bound_hashes.length); + for (const boundHash of this.bound_hashes) { + bufferWriter.writeSlice(boundHash); + } + bufferWriter.writeVarSlice(this.signature_as_vch); + return bufferWriter.buffer; + } + fromBuffer(buffer, offset = 0) { + const reader = new BufferReader(buffer, offset); + this.version = reader.readVarInt(); + this.system_ID = (0, address_1.toBase58Check)(reader.readSlice(20), vdxf_1.I_ADDR_VERSION); + this.hash_type = reader.readVarInt(); + this.signature_hash = reader.readVarSlice(); + this.identity_ID = (0, address_1.toBase58Check)(reader.readSlice(20), vdxf_1.I_ADDR_VERSION); + this.sig_type = reader.readVarInt(); + const vdxfKeysLength = reader.readCompactSize(); + this.vdxf_keys = []; + for (let i = 0; i < vdxfKeysLength; i++) { + this.vdxf_keys.push((0, address_1.toBase58Check)(reader.readSlice(20), vdxf_1.I_ADDR_VERSION)); + } + const vdxfKeyNamesLength = reader.readCompactSize(); + this.vdxf_key_names = []; + for (let i = 0; i < vdxfKeyNamesLength; i++) { + this.vdxf_key_names.push(reader.readVarSlice().toString('utf8')); + } + const boundHashesLength = reader.readCompactSize(); + this.bound_hashes = []; + for (let i = 0; i < boundHashesLength; i++) { + this.bound_hashes.push(reader.readSlice(32)); + } + this.signature_as_vch = reader.readVarSlice(); + return reader.offset; + } + isValid() { + return !!(this.version.gte(SignatureData.FIRST_VERSION) && + this.version.lte(SignatureData.LAST_VERSION) && + this.system_ID); + } + toJson() { + const returnObj = { + version: this.version.toString(), + systemid: this.system_ID, + hashtype: this.hash_type.toString() + }; + if (this.hash_type == new bn_js_1.BN(DataDescriptor_1.EHashTypes.HASH_SHA256)) { + returnObj['signaturehash'] = this.signature_hash.reverse().toString('hex'); + } + else { + returnObj['signaturehash'] = this.signature_hash.toString('hex'); + } + returnObj['identityid'] = this.identity_ID; + returnObj['signaturetype'] = this.sig_type.toString(); + returnObj['signature'] = this.signature_as_vch.toString('base64'); + if (this.vdxf_keys) { + returnObj['vdxfkeys'] = this.vdxf_keys; + } + if (this.vdxf_key_names) { + returnObj['vdxfkeynames'] = this.vdxf_key_names; + } + if (this.bound_hashes) { + returnObj['boundhashes'] = this.bound_hashes.map((hash) => hash.toString('hex')); + } + return returnObj; + } + getIdentityHash(sigObject) { + var heightBuffer = Buffer.allocUnsafe(4); + heightBuffer.writeUInt32LE(sigObject.height); + if (sigObject.hash_type != Number(DataDescriptor_1.EHashTypes.HASH_SHA256)) { + throw new Error("Invalid signature type for identity hash"); + } + if (sigObject.version == 1) { + return createHash("sha256") + .update(vdxf_2.VERUS_DATA_SIGNATURE_PREFIX) + .update((0, address_1.fromBase58Check)(this.system_ID).hash) + .update(heightBuffer) + .update((0, address_1.fromBase58Check)(this.identity_ID).hash) + .update(this.signature_hash) + .digest(); + } + else { + return createHash("sha256") + .update((0, address_1.fromBase58Check)(this.system_ID).hash) + .update(heightBuffer) + .update((0, address_1.fromBase58Check)(this.identity_ID).hash) + .update(vdxf_2.VERUS_DATA_SIGNATURE_PREFIX) + .update(this.signature_hash) + .digest(); + } + } +} +exports.SignatureData = SignatureData; +SignatureData.VERSION_INVALID = new bn_js_1.BN(0); +SignatureData.FIRST_VERSION = new bn_js_1.BN(1); +SignatureData.LAST_VERSION = new bn_js_1.BN(1); +SignatureData.DEFAULT_VERSION = new bn_js_1.BN(1); +SignatureData.TYPE_VERUSID_DEFAULT = new bn_js_1.BN(1); diff --git a/dist/pbaas/TransferDestination.d.ts b/dist/pbaas/TransferDestination.d.ts index 7088e03..ca9f848 100644 --- a/dist/pbaas/TransferDestination.d.ts +++ b/dist/pbaas/TransferDestination.d.ts @@ -53,4 +53,6 @@ export declare class TransferDestination implements SerializableEntity { fromBuffer(buffer: Buffer, offset?: number): number; static fromJson(data: TransferDestinationJson): TransferDestination; toJson(): TransferDestinationJson; + isValid(): boolean; + getAuxDest(destNum: any): TransferDestination; } diff --git a/dist/pbaas/TransferDestination.js b/dist/pbaas/TransferDestination.js index 08765b1..7ce4f86 100644 --- a/dist/pbaas/TransferDestination.js +++ b/dist/pbaas/TransferDestination.js @@ -23,6 +23,7 @@ exports.LAST_VALID_TYPE_NO_FLAGS = exports.DEST_RAW; exports.FLAG_DEST_AUX = new bn_js_1.BN(64, 10); exports.FLAG_DEST_GATEWAY = new bn_js_1.BN(128, 10); exports.FLAG_MASK = exports.FLAG_DEST_AUX.add(exports.FLAG_DEST_GATEWAY); +const UINT160_BYTE_SIZE = 20; class TransferDestination { constructor(data) { this.type = exports.DEST_INVALID; @@ -89,9 +90,9 @@ class TransferDestination { length += (0, address_1.fromBase58Check)(this.gateway_code).hash.length; // gateway_code } else { - length += 20; + length += UINT160_BYTE_SIZE; } - length += 8; // fees + length += 8; // fees int64 } if (this.hasAuxDests()) { length += varuint_1.default.encodingLength(this.aux_dests.length); // aux dests compact size @@ -113,7 +114,7 @@ class TransferDestination { writer.writeSlice((0, address_1.fromBase58Check)(this.gateway_code).hash); } else { - writer.writeSlice(Buffer.alloc(20)); + writer.writeSlice(Buffer.alloc(UINT160_BYTE_SIZE)); } writer.writeInt64(this.fees); } @@ -162,5 +163,41 @@ class TransferDestination { aux_dests: this.aux_dests.map(x => x.toJson()) }; } + isValid() { + // verify aux dests + let valid = (((this.type.and(exports.FLAG_DEST_AUX).gt(new bn_js_1.BN(0))) && this.aux_dests.length > 0) || (!(this.type.and(exports.FLAG_DEST_AUX).gt(new bn_js_1.BN(0))) && !(this.aux_dests.length > 0))); + if (valid && this.aux_dests && this.aux_dests.length > 0) { + for (let i = 0; i < this.aux_dests.length; i++) { + if (!this.getAuxDest(i).isValid()) { + valid = false; + break; + } + } + } + return !!(valid && + !this.typeNoFlags().eq(exports.DEST_INVALID) && + this.typeNoFlags().lte(exports.LAST_VALID_TYPE_NO_FLAGS) && + (((this.type.and(exports.FLAG_DEST_GATEWAY).eq(new bn_js_1.BN(0))) && (this.gateway_id == null)) || this.gateway_id != null)); + } + getAuxDest(destNum) { + const retVal = this.aux_dests[destNum]; + if (destNum >= 0 && destNum < this.aux_dests.length) { + if (retVal.type.and(exports.FLAG_DEST_AUX).gt(new bn_js_1.BN(0)) || retVal.aux_dests.length > 0) { + retVal.type = exports.DEST_INVALID; + } + // no gateways or flags, only simple destinations work + switch (retVal.type) { + case exports.DEST_ID: + case exports.DEST_PK: + case exports.DEST_PKH: + case exports.DEST_ETH: + case exports.DEST_SH: + break; + default: + retVal.type = exports.DEST_INVALID; + } + } + return retVal; + } } exports.TransferDestination = TransferDestination; diff --git a/dist/pbaas/URLRef.d.ts b/dist/pbaas/URLRef.d.ts new file mode 100644 index 0000000..6db5302 --- /dev/null +++ b/dist/pbaas/URLRef.d.ts @@ -0,0 +1,27 @@ +/// +/// +import { BigNumber } from '../utils/types/BigNumber'; +import { SerializableEntity } from '../utils/types/SerializableEntity'; +export interface URLRefJson { + version: string; + url: string; +} +export declare class URLRef implements SerializableEntity { + static FIRST_VERSION: import("bn.js"); + static LAST_VERSION: import("bn.js"); + version: BigNumber; + url: string; + constructor(data?: { + version?: BigNumber; + url?: string; + }); + getByteLength(): number; + toBuffer(): Buffer; + fromBuffer(buffer: Buffer, offset?: number): number; + isValid(): boolean; + toJson(): { + version: string; + url: string; + }; + static fromJson(data: URLRefJson): URLRef; +} diff --git a/dist/pbaas/URLRef.js b/dist/pbaas/URLRef.js new file mode 100644 index 0000000..bf2d5bc --- /dev/null +++ b/dist/pbaas/URLRef.js @@ -0,0 +1,57 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.URLRef = void 0; +const varint_1 = require("../utils/varint"); +const varuint_1 = require("../utils/varuint"); +const bufferutils_1 = require("../utils/bufferutils"); +const bn_js_1 = require("bn.js"); +const { BufferReader, BufferWriter } = bufferutils_1.default; +class URLRef { + constructor(data) { + if (data) { + this.version = data.version || new bn_js_1.BN(1, 10); + this.url = data.url || ""; + } + } + getByteLength() { + let byteLength = 0; + byteLength += varint_1.default.encodingLength(this.version); + byteLength += varuint_1.default.encodingLength(Buffer.from(this.url, 'utf8').length); + byteLength += Buffer.from(this.url, 'utf8').length; + if (byteLength > 4096) + throw new Error("URLRef exceeds maximum length of 4096 bytes"); + return byteLength; + } + toBuffer() { + const bufferWriter = new BufferWriter(Buffer.alloc(this.getByteLength())); + bufferWriter.writeVarInt(this.version); + bufferWriter.writeVarSlice(Buffer.from(this.url, 'utf8')); + return bufferWriter.buffer; + } + fromBuffer(buffer, offset = 0) { + const reader = new BufferReader(buffer, offset); + this.version = reader.readVarInt(); + this.url = reader.readVarSlice().toString('utf8'); + return reader.offset; + } + isValid() { + return this.version.gte(URLRef.FIRST_VERSION) && + this.version.lte(URLRef.LAST_VERSION) && + !(!this.url || this.url.length === 0); + } + toJson() { + return { + version: this.version.toString(10), + url: this.url + }; + } + static fromJson(data) { + return new URLRef({ + version: new bn_js_1.BN(data.version, 10), + url: data.url + }); + } +} +exports.URLRef = URLRef; +URLRef.FIRST_VERSION = new bn_js_1.BN(1); +URLRef.LAST_VERSION = new bn_js_1.BN(1); diff --git a/dist/pbaas/UTXORef.d.ts b/dist/pbaas/UTXORef.d.ts new file mode 100644 index 0000000..38f1d18 --- /dev/null +++ b/dist/pbaas/UTXORef.d.ts @@ -0,0 +1,23 @@ +/// +import { BigNumber } from '../utils/types/BigNumber'; +import { SerializableEntity } from '../utils/types/SerializableEntity'; +export declare class UTXORef implements SerializableEntity { + hash: Buffer; + n: BigNumber; + constructor(data?: { + hash?: Buffer; + n?: BigNumber; + }); + getByteLength(): number; + toBuffer(): Buffer; + fromBuffer(buffer: Buffer, offset?: number): number; + isValid(): boolean; + toJson(): { + hash: string; + n: number; + }; + static fromJson(data: { + hash: string; + n: string; + }): UTXORef; +} diff --git a/dist/pbaas/UTXORef.js b/dist/pbaas/UTXORef.js new file mode 100644 index 0000000..07727ad --- /dev/null +++ b/dist/pbaas/UTXORef.js @@ -0,0 +1,46 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.UTXORef = void 0; +const bufferutils_1 = require("../utils/bufferutils"); +const bn_js_1 = require("bn.js"); +const { BufferReader, BufferWriter } = bufferutils_1.default; +class UTXORef { + constructor(data) { + this.hash = data.hash || Buffer.alloc(0); + this.n = data.n || new bn_js_1.BN(0); + } + getByteLength() { + let byteLength = 0; + byteLength += 32; // hash uint256 + byteLength += 4; // n uint32 + return byteLength; + } + toBuffer() { + const bufferWriter = new BufferWriter(Buffer.alloc(this.getByteLength())); + bufferWriter.writeSlice(this.hash); + bufferWriter.writeUInt32(this.n.toNumber()); + return bufferWriter.buffer; + } + fromBuffer(buffer, offset = 0) { + const reader = new BufferReader(buffer, offset); + this.hash = reader.readSlice(32); + this.n = new bn_js_1.BN(reader.readUInt32()); + return reader.offset; + } + isValid() { + return this.n.lt(new bn_js_1.BN(0xffffffff)); + } + toJson() { + return { + hash: this.hash.toString('hex'), + n: this.n.toNumber() + }; + } + static fromJson(data) { + return new UTXORef({ + hash: Buffer.from(data.hash, 'hex'), + n: new bn_js_1.BN(data.n, 10) + }); + } +} +exports.UTXORef = UTXORef; diff --git a/dist/pbaas/VdxfUniValue.d.ts b/dist/pbaas/VdxfUniValue.d.ts index d1a9698..d5ad578 100644 --- a/dist/pbaas/VdxfUniValue.d.ts +++ b/dist/pbaas/VdxfUniValue.d.ts @@ -2,12 +2,24 @@ /// import { BigNumber } from '../utils/types/BigNumber'; import { SerializableEntity } from '../utils/types/SerializableEntity'; +import { CurrencyValueMap } from './CurrencyValueMap'; +import { Rating, RatingJson } from './Rating'; +import { TransferDestination, TransferDestinationJson } from './TransferDestination'; +import { ContentMultiMapRemove, ContentMultiMapRemoveJson } from './ContentMultiMapRemove'; +import { CrossChainDataRef, CrossChainDataRefJson } from './CrossChainDataRef'; +import { SignatureData, SignatureJsonDataInterface } from './SignatureData'; +import { DataDescriptor, DataDescriptorJson } from './DataDescriptor'; +import { MMRDescriptor, MMRDescriptorJson } from './MMRDescriptor'; export declare const VDXF_UNI_VALUE_VERSION_INVALID: import("bn.js"); export declare const VDXF_UNI_VALUE_VERSION_CURRENT: import("bn.js"); -export declare type VdxfUniType = string | Buffer; -export declare type VdxfUniValueJson = { - [key: string]: string; -}; +export declare type VdxfUniType = string | Buffer | BigNumber | CurrencyValueMap | Rating | TransferDestination | ContentMultiMapRemove | CrossChainDataRef | SignatureData | DataDescriptor | MMRDescriptor; +export interface VdxfUniValueJson { + [key: string]: string | number | RatingJson | TransferDestinationJson | ContentMultiMapRemoveJson | CrossChainDataRefJson | SignatureJsonDataInterface | DataDescriptorJson | MMRDescriptorJson; + serializedHex?: string; + serializedBase64?: string; + message?: string; +} +export declare type JsonSerializableObject = CurrencyValueMap | Rating | TransferDestination | ContentMultiMapRemove | CrossChainDataRef | SignatureData | DataDescriptor | MMRDescriptor; export declare class VdxfUniValue implements SerializableEntity { values: Map; version: BigNumber; @@ -17,7 +29,7 @@ export declare class VdxfUniValue implements SerializableEntity { }); getByteLength(): number; toBuffer(): Buffer; - fromBuffer(buffer: Buffer, offset?: number, keylist?: Array): number; + fromBuffer(buffer: Buffer, offset?: number): number; static fromJson(obj: VdxfUniValueJson): VdxfUniValue; toJson(): VdxfUniValueJson; } diff --git a/dist/pbaas/VdxfUniValue.js b/dist/pbaas/VdxfUniValue.js index d0c677c..afce1f1 100644 --- a/dist/pbaas/VdxfUniValue.js +++ b/dist/pbaas/VdxfUniValue.js @@ -6,11 +6,21 @@ const bufferutils_1 = require("../utils/bufferutils"); const address_1 = require("../utils/address"); const vdxf_1 = require("../constants/vdxf"); const bn_js_1 = require("bn.js"); -const vdxf_2 = require("../vdxf"); const varint_1 = require("../utils/varint"); +const string_1 = require("../utils/string"); +const CurrencyValueMap_1 = require("./CurrencyValueMap"); +const Rating_1 = require("./Rating"); +const TransferDestination_1 = require("./TransferDestination"); +const ContentMultiMapRemove_1 = require("./ContentMultiMapRemove"); +const CrossChainDataRef_1 = require("./CrossChainDataRef"); +const SignatureData_1 = require("./SignatureData"); +const DataDescriptor_1 = require("./DataDescriptor"); +const MMRDescriptor_1 = require("./MMRDescriptor"); +const VDXF_Data = require("../vdxf/vdxfdatakeys"); exports.VDXF_UNI_VALUE_VERSION_INVALID = new bn_js_1.BN(0, 10); exports.VDXF_UNI_VALUE_VERSION_CURRENT = new bn_js_1.BN(1, 10); const { BufferWriter, BufferReader } = bufferutils_1.default; +; // This UniValue class was adapted from C++ code for encoding JSON objects into bytes. It is not serialization and // therefore doesn't have a fromBuffer function, as you can't reliably decode it, only encode. class VdxfUniValue { @@ -26,18 +36,104 @@ class VdxfUniValue { let length = 0; for (const key of this.values.keys()) { const value = this.values.get(key); + // if we just have serialized data + if (key === "") { + length += Buffer.from(value, "hex").length; + continue; + } + if (key == VDXF_Data.DataByteKey.vdxfid) { + length += 1; + continue; + } + else if ((key == VDXF_Data.DataUint16Key.vdxfid) || (key == VDXF_Data.DataInt16Key.vdxfid)) { + length += 2; + continue; + } + else if ((key == VDXF_Data.DataInt32Key.vdxfid) || (key == VDXF_Data.DataUint32Key.vdxfid)) { + length += 4; + continue; + } + else if (key == VDXF_Data.DataInt64Key.vdxfid) { + length += 8; + continue; + } + else if (key == VDXF_Data.DataUint160Key.vdxfid) { + length += vdxf_1.HASH160_BYTE_LENGTH; + continue; + } + else if (key == VDXF_Data.DataUint256Key.vdxfid) { + length += vdxf_1.HASH256_BYTE_LENGTH; + continue; + } length += vdxf_1.HASH160_BYTE_LENGTH; - length += varint_1.default.encodingLength(this.version); - if (key == vdxf_2.DATA_TYPE_STRING.vdxfid) { - const valueString = value; - const valBuf = Buffer.from(valueString, 'utf8'); - //NOTE 3 is from ss type + ver + vdxfidver - length += varint_1.default.encodingLength(new bn_js_1.BN(valBuf.length + 3)); + if (key == VDXF_Data.DataStringKey.vdxfid) { + const valBuf = Buffer.from(value, "utf-8"); + length += varint_1.default.encodingLength(new bn_js_1.BN(1)); + // NOTE: 3 is from ss type + ver + vdxfIdVersion + length += varuint_1.default.encodingLength(valBuf.length + 3); length += varuint_1.default.encodingLength(valBuf.length); length += valBuf.length; } - else - throw new Error("Invalid or unrecognized vdxf key for object type"); + else if (key == VDXF_Data.DataByteVectorKey.vdxfid) { + const valBuf = Buffer.from(value, "hex"); + length += varint_1.default.encodingLength(new bn_js_1.BN(1)); + length += varuint_1.default.encodingLength(valBuf.length + 3); + length += varuint_1.default.encodingLength(valBuf.length); + length += valBuf.length; + } + else if (key == VDXF_Data.DataCurrencyMapKey.vdxfid) { + const destinations = Object.keys(value); + const values = Object.values(value); + const oneCurMap = new CurrencyValueMap_1.CurrencyValueMap({ value_map: new Map(destinations.map((key, index) => [key, new bn_js_1.BN(values[index])])), multivalue: true }); + length += varint_1.default.encodingLength(new bn_js_1.BN(1)); + length += varuint_1.default.encodingLength(oneCurMap.getByteLength()); + length += oneCurMap.getByteLength(); + } + else if (key == VDXF_Data.DataRatingsKey.vdxfid) { + const oneRatingMap = new Rating_1.Rating(value); + length += varint_1.default.encodingLength(oneRatingMap.version); + length += varuint_1.default.encodingLength(oneRatingMap.getByteLength() + 3); + length += oneRatingMap.getByteLength(); + } + else if (key == VDXF_Data.DataTransferDestinationKey.vdxfid) { + const transferDest = new TransferDestination_1.TransferDestination(value); + length += varint_1.default.encodingLength(transferDest.typeNoFlags()); + length += varuint_1.default.encodingLength(transferDest.getByteLength() + 3); + length += transferDest.getByteLength(); + } + else if (key == VDXF_Data.ContentMultiMapRemoveKey.vdxfid) { + const transferDest = new ContentMultiMapRemove_1.ContentMultiMapRemove(value); + length += varint_1.default.encodingLength(transferDest.version); + length += varuint_1.default.encodingLength(transferDest.getByteLength() + 3); + length += transferDest.getByteLength(); + } + else if (key == VDXF_Data.CrossChainDataRefKey.vdxfid) { + const transferDest = new CrossChainDataRef_1.CrossChainDataRef(value); + length += varint_1.default.encodingLength(vdxf_1.VDXF_OBJECT_DEFAULT_VERSION); + length += varuint_1.default.encodingLength(transferDest.getByteLength() + 3); + length += transferDest.getByteLength(); + } + else if (key == VDXF_Data.DataDescriptorKey.vdxfid) { + const descr = new DataDescriptor_1.DataDescriptor(value); + length += varint_1.default.encodingLength(descr.version); + length += varuint_1.default.encodingLength(descr.getByteLength() + 3); + length += descr.getByteLength(); + } + else if (key == VDXF_Data.MMRDescriptorKey.vdxfid) { + const descr = new MMRDescriptor_1.MMRDescriptor(value); + length += varint_1.default.encodingLength(descr.version); + length += varuint_1.default.encodingLength(descr.getByteLength() + 3); + length += descr.getByteLength(); + } + else if (key == VDXF_Data.SignatureDataKey.vdxfid) { + const sigData = new SignatureData_1.SignatureData(value); + length += varint_1.default.encodingLength(sigData.version); + length += varuint_1.default.encodingLength(sigData.getByteLength() + 3); + length += sigData.getByteLength(); + } + else { + throw new Error("contentmap invalid or unrecognized vdxfkey for object type: " + key); + } } return length; } @@ -45,62 +141,428 @@ class VdxfUniValue { const writer = new BufferWriter(Buffer.alloc(this.getByteLength())); for (const key of this.values.keys()) { const value = this.values.get(key); - writer.writeSlice((0, address_1.fromBase58Check)(key).hash); - writer.writeVarInt(this.version); - if (key == vdxf_2.DATA_TYPE_STRING.vdxfid) { - const valueString = value; - const valBuf = Buffer.from(valueString, 'utf8'); - //NOTE 3 is from ss type + ver + vdxfidver - writer.writeVarInt(new bn_js_1.BN(valBuf.length + 3)); + if (key === "") { + writer.writeSlice(value); + continue; + } + if (key == VDXF_Data.DataByteKey.vdxfid) { + const oneByte = Buffer.from(value, "hex"); + if (oneByte.length != 1) { + throw new Error("contentmap: byte data must be exactly one byte"); + } + writer.writeSlice(oneByte); + } + else if (key == VDXF_Data.DataInt16Key.vdxfid) { + const oneShort = Buffer.alloc(2); + oneShort.writeInt16LE(value.toNumber()); + writer.writeSlice(oneShort); + } + else if (key == VDXF_Data.DataUint16Key.vdxfid) { + const oneUShort = Buffer.alloc(2); + oneUShort.writeUInt16LE(value.toNumber()); + writer.writeSlice(oneUShort); + } + else if (key == VDXF_Data.DataInt32Key.vdxfid) { + const oneInt = Buffer.alloc(4); + oneInt.writeInt32LE(value.toNumber()); + writer.writeSlice(oneInt); + } + else if (key == VDXF_Data.DataUint32Key.vdxfid) { + const oneUInt = Buffer.alloc(4); + oneUInt.writeUInt32LE(value.toNumber()); + writer.writeSlice(oneUInt); + } + else if (key == VDXF_Data.DataInt64Key.vdxfid) { + const oneInt64 = Buffer.alloc(8); + oneInt64.writeBigInt64LE(BigInt(value.toString())); + writer.writeSlice(oneInt64); + } + else if (key == VDXF_Data.DataUint160Key.vdxfid) { + const oneKey = (0, address_1.fromBase58Check)(value).hash; + writer.writeSlice(oneKey); + } + else if (key == VDXF_Data.DataUint256Key.vdxfid) { + const oneHash = Buffer.from(value, "hex"); + if (oneHash.length != vdxf_1.HASH256_BYTE_LENGTH) { + throw new Error("contentmap: hash data must be exactly 32 bytes"); + } + writer.writeVarSlice(oneHash.reverse()); + } + else if (key == VDXF_Data.DataStringKey.vdxfid) { + const valBuf = Buffer.from(value, "utf-8"); + writer.writeSlice((0, address_1.fromBase58Check)(key).hash); + writer.writeVarInt(new bn_js_1.BN(1)); + writer.writeCompactSize(valBuf.length + 3); writer.writeVarSlice(valBuf); } - else - throw new Error("Invalid or unrecognized vdxf key for object type"); + else if (key == VDXF_Data.DataByteVectorKey.vdxfid) { + const encodedLength = varuint_1.default.encodingLength(Buffer.from(value, "hex").length); + writer.writeSlice((0, address_1.fromBase58Check)(key).hash); + writer.writeVarInt(new bn_js_1.BN(1)); + writer.writeCompactSize(encodedLength + Buffer.from(value, "hex").length); + writer.writeVarSlice(Buffer.from(value, "hex")); + } + else if (key == VDXF_Data.DataCurrencyMapKey.vdxfid) { + const destinations = Object.keys(value); + const values = Object.values(value); + const oneCurMap = new CurrencyValueMap_1.CurrencyValueMap({ value_map: new Map(destinations.map((key, index) => [key, new bn_js_1.BN(values[index])])), multivalue: true }); + writer.writeSlice((0, address_1.fromBase58Check)(key).hash); + writer.writeVarInt(new bn_js_1.BN(1)); + writer.writeCompactSize(oneCurMap.getByteLength()); + writer.writeSlice(oneCurMap.toBuffer()); + } + else if (key == VDXF_Data.DataRatingsKey.vdxfid) { + const oneRatingMap = new Rating_1.Rating(value); + writer.writeSlice((0, address_1.fromBase58Check)(key).hash); + writer.writeVarInt(oneRatingMap.version); + writer.writeCompactSize(oneRatingMap.getByteLength()); + writer.writeSlice(oneRatingMap.toBuffer()); + } + else if (key == VDXF_Data.DataTransferDestinationKey.vdxfid) { + const transferDest = new TransferDestination_1.TransferDestination(value); + const writer = new BufferWriter(Buffer.alloc(length)); + writer.writeSlice((0, address_1.fromBase58Check)(key).hash); + writer.writeVarInt(transferDest.typeNoFlags()); + writer.writeCompactSize(transferDest.getByteLength()); + writer.writeSlice(transferDest.toBuffer()); + } + else if (key == VDXF_Data.ContentMultiMapRemoveKey.vdxfid) { + const transferDest = new ContentMultiMapRemove_1.ContentMultiMapRemove(value); + writer.writeSlice((0, address_1.fromBase58Check)(key).hash); + writer.writeVarInt(transferDest.version); + writer.writeCompactSize(transferDest.getByteLength()); + writer.writeSlice(transferDest.toBuffer()); + } + else if (key == VDXF_Data.CrossChainDataRefKey.vdxfid) { + const transferDest = new CrossChainDataRef_1.CrossChainDataRef(value); + writer.writeSlice((0, address_1.fromBase58Check)(key).hash); + writer.writeVarInt(vdxf_1.VDXF_OBJECT_DEFAULT_VERSION); + writer.writeCompactSize(transferDest.getByteLength()); + writer.writeSlice(transferDest.toBuffer()); + } + else if (key == VDXF_Data.DataDescriptorKey.vdxfid) { + const descr = new DataDescriptor_1.DataDescriptor(value); + writer.writeSlice((0, address_1.fromBase58Check)(key).hash); + writer.writeVarInt(descr.version); + writer.writeCompactSize(descr.getByteLength()); + writer.writeSlice(descr.toBuffer()); + } + else if (key == VDXF_Data.MMRDescriptorKey.vdxfid) { + const descr = new MMRDescriptor_1.MMRDescriptor(value); + writer.writeSlice((0, address_1.fromBase58Check)(key).hash); + writer.writeVarInt(descr.version); + writer.writeCompactSize(descr.getByteLength()); + writer.writeSlice(descr.toBuffer()); + } + else if (key == VDXF_Data.SignatureDataKey.vdxfid) { + const sigData = new SignatureData_1.SignatureData(value); + writer.writeSlice((0, address_1.fromBase58Check)(key).hash); + writer.writeVarInt(sigData.version); + writer.writeCompactSize(sigData.getByteLength()); + writer.writeSlice(sigData.toBuffer()); + } + else { + throw new Error("contentmap invalid or unrecognized vdxfkey for object type: " + key); + } } return writer.buffer; } - fromBuffer(buffer, offset = 0, keylist = []) { + fromBuffer(buffer, offset = 0) { const reader = new BufferReader(buffer, offset); - let lastPrereadOffset = reader.offset; - function readNextKey() { - lastPrereadOffset = reader.offset; + this.values = new Map(); + let bytesLeft = reader.buffer.length - reader.offset; + while (bytesLeft > vdxf_1.HASH160_BYTE_LENGTH) // size of uint160 + { + let pSuccess = { value: false }; + let objectUni; + const initialOffset = reader.offset; try { - return (0, address_1.toBase58Check)(reader.readSlice(20), vdxf_1.I_ADDR_VERSION); + let checkVal; + let version = new bn_js_1.BN(0); + let objSize = 0; + checkVal = (0, address_1.toBase58Check)(reader.readSlice(vdxf_1.HASH160_BYTE_LENGTH), vdxf_1.I_ADDR_VERSION); + if (checkVal == VDXF_Data.DataCurrencyMapKey.vdxfid) { + const oneCurrencyMap = new CurrencyValueMap_1.CurrencyValueMap({ multivalue: true }); + version = reader.readVarInt(); + objSize = reader.readCompactSize(); + reader.offset = oneCurrencyMap.fromBuffer(reader.buffer, reader.offset); + if (oneCurrencyMap.isValid()) { + objectUni = { key: checkVal, value: oneCurrencyMap }; + } + } + else if (checkVal == VDXF_Data.DataRatingsKey.vdxfid) { + const oneRatingObj = new Rating_1.Rating(); + version = reader.readVarInt(); + objSize = reader.readCompactSize(); + reader.offset = oneRatingObj.fromBuffer(reader.buffer, reader.offset); + if (oneRatingObj.isValid()) { + objectUni = { key: checkVal, value: oneRatingObj }; + } + } + else if (checkVal == VDXF_Data.DataTransferDestinationKey.vdxfid) { + const oneTransferDest = new TransferDestination_1.TransferDestination(); + version = reader.readVarInt(); + objSize = reader.readCompactSize(); + reader.offset = oneTransferDest.fromBuffer(reader.buffer, reader.offset); + if (oneTransferDest.isValid()) { + objectUni = { key: checkVal, value: oneTransferDest }; + } + } + else if (checkVal == VDXF_Data.ContentMultiMapRemoveKey.vdxfid) { + const contentMap = new ContentMultiMapRemove_1.ContentMultiMapRemove(); + version = reader.readVarInt(); + objSize = reader.readCompactSize(); + reader.offset = contentMap.fromBuffer(reader.buffer, reader.offset); + if (contentMap.isValid()) { + objectUni = { key: checkVal, value: contentMap }; + } + } + else if (checkVal == VDXF_Data.DataStringKey.vdxfid) { + let stringVal; + version = reader.readVarInt(); + objSize = reader.readCompactSize(); + stringVal = reader.readVarSlice().toString('utf8'); + objectUni = { key: checkVal, value: stringVal }; + } + else if (checkVal == VDXF_Data.DataByteVectorKey.vdxfid) { + let vecVal; + version = reader.readVarInt(); + objSize = reader.readCompactSize(); + vecVal = reader.readVarSlice(); + objectUni = { key: checkVal, value: vecVal.toString('hex') }; + } + else if (checkVal == VDXF_Data.CrossChainDataRefKey.vdxfid) { + const dataRef = new CrossChainDataRef_1.CrossChainDataRef(); + version = reader.readVarInt(); + objSize = reader.readCompactSize(); + reader.offset = dataRef.fromBuffer(reader.buffer, reader.offset); + if (dataRef.isValid()) { + objectUni = { key: checkVal, value: dataRef }; + } + } + else if (checkVal == VDXF_Data.DataDescriptorKey.vdxfid) { + const dataDescriptor = new DataDescriptor_1.DataDescriptor(); + version = reader.readVarInt(); + objSize = reader.readCompactSize(); + reader.offset = dataDescriptor.fromBuffer(reader.buffer, reader.offset); + if (dataDescriptor.isValid()) { + objectUni = { key: checkVal, value: dataDescriptor }; + } + } + else if (checkVal == VDXF_Data.MMRDescriptorKey.vdxfid) { + const mmrDescriptor = new MMRDescriptor_1.MMRDescriptor(); + version = reader.readVarInt(); + objSize = reader.readCompactSize(); + reader.offset = mmrDescriptor.fromBuffer(reader.buffer, reader.offset); + if (mmrDescriptor.isValid()) { + objectUni = { key: checkVal, value: mmrDescriptor }; + } + } + else if (checkVal == VDXF_Data.SignatureDataKey.vdxfid) { + const sigData = new SignatureData_1.SignatureData(); + version = reader.readVarInt(); + objSize = reader.readCompactSize(); + reader.offset = sigData.fromBuffer(reader.buffer, reader.offset); + if (sigData.isValid()) { + objectUni = { key: checkVal, value: sigData }; + } + } + // if we have an object that we recognized, encode it + if (objectUni && objectUni.key && objectUni.value) { + if (pSuccess != null) { + pSuccess.value = true; + } + } + else { + if (pSuccess != null) { + pSuccess.value = false; + } + } } catch (e) { - return null; + if (pSuccess != null) { + pSuccess.value = false; + } } - } - this.values = new Map(); - for (const key of keylist) { - const dataTypeKey = readNextKey(); - this.version = reader.readVarInt(); - if (this.version.gt(exports.VDXF_UNI_VALUE_VERSION_CURRENT)) - throw new Error("Unknown VDXFUniValue version"); - if (dataTypeKey == vdxf_2.DATA_TYPE_STRING.vdxfid) { - reader.readVarInt(); - const slice = reader.readVarSlice(); - this.values.set(dataTypeKey, slice.toString('utf8')); + bytesLeft = reader.buffer.length - reader.offset; + if ((pSuccess === null || pSuccess === void 0 ? void 0 : pSuccess.value) && (pSuccess === null || pSuccess === void 0 ? void 0 : pSuccess.value)) { + this.values.set(objectUni.key, objectUni.value); } else { - throw new Error("Invalid or unrecognized vdxf key for object type"); + // add the remaining data as a hex string + reader.offset = initialOffset; + this.values.set("", reader.readSlice(reader.buffer.length - reader.offset)); + bytesLeft = 0; + break; } } + if (bytesLeft && bytesLeft <= vdxf_1.HASH160_BYTE_LENGTH) { + this.values.set("", reader.readSlice(bytesLeft)); + } return reader.offset; } static fromJson(obj) { const map = new Map(); - for (const key in obj) { - map.set(key, obj[key]); + if (typeof (obj) != 'object') { + if (typeof (obj) != 'string') + throw new Error('Not JSON string as expected'); + if ((0, string_1.isHexString)(obj)) { + map.set("", Buffer.from(obj, "hex")); + return new VdxfUniValue({ + values: map + }); + } + map.set("", Buffer.from(obj, "utf-8")); + return new VdxfUniValue({ + values: map + }); + } + if (obj.serializedHex) { + if (!(0, string_1.isHexString)(obj.serializedHex)) { + throw new Error("contentmap: If the \"serializedhex\" key is present, it's data must be only valid hex and complete"); + } + map.set("", Buffer.from(obj.serializedHex, "hex")); + return new VdxfUniValue({ + values: map + }); + } + if (obj.serializedBase64) { + try { + map.set("", Buffer.from(obj.serializedBase64, "base64")); + return new VdxfUniValue({ + values: map + }); + } + catch (e) { + throw new Error("contentmap: If the \"serializedBase64\" key is present, it's data must be only valid base64 and complete"); + } + } + if (obj.message) { + map.set("", Buffer.from(obj.message, "utf-8")); + return new VdxfUniValue({ + values: map + }); + } + // this should be an object with "vdxfkey" as the key and {object} as the json object to serialize + const oneValKeys = Object.keys(obj); + const oneValValues = Object.values(obj); + for (let k = 0; k < oneValKeys.length; k++) { + const objTypeKey = oneValKeys[k]; + if (objTypeKey == VDXF_Data.DataByteKey.vdxfid) { + const oneByte = Buffer.from(oneValValues[k], "hex"); + if (oneByte.length != 1) { + throw new Error("contentmap: byte data must be exactly one byte"); + } + map.set(objTypeKey, oneByte); + } + else if (objTypeKey == VDXF_Data.DataInt16Key.vdxfid) { + const oneShort = Buffer.alloc(2); + oneShort.writeInt16LE(oneValValues[k]); + map.set(objTypeKey, oneShort); + } + else if (objTypeKey == VDXF_Data.DataUint16Key.vdxfid) { + const oneUShort = Buffer.alloc(2); + oneUShort.writeUInt16LE(oneValValues[k]); + map.set(objTypeKey, oneUShort); + } + else if (objTypeKey == VDXF_Data.DataInt32Key.vdxfid) { + const oneInt = Buffer.alloc(4); + oneInt.writeInt32LE(oneValValues[k]); + map.set(objTypeKey, oneInt); + } + else if (objTypeKey == VDXF_Data.DataUint32Key.vdxfid) { + const oneUInt = Buffer.alloc(4); + oneUInt.writeUInt32LE(oneValValues[k]); + map.set(objTypeKey, oneUInt); + } + else if (objTypeKey == VDXF_Data.DataInt64Key.vdxfid) { + const oneInt64 = Buffer.alloc(8); + oneInt64.writeIntLE(oneValValues[k], 0, 8); + map.set(objTypeKey, oneInt64); + } + else if (objTypeKey == VDXF_Data.DataUint160Key.vdxfid) { + (0, address_1.fromBase58Check)(oneValValues[k]).hash; + map.set(objTypeKey, oneValValues[k]); + } + else if (objTypeKey == VDXF_Data.DataUint256Key.vdxfid) { + const oneHash = Buffer.from(oneValValues[k], "hex"); + if (oneHash.length != vdxf_1.HASH256_BYTE_LENGTH) { + throw new Error("contentmap: hash data must be exactly 32 bytes"); + } + map.set(objTypeKey, oneHash); + } + else if (objTypeKey == VDXF_Data.DataStringKey.vdxfid) { + map.set(objTypeKey, oneValValues[k]); + } + else if (objTypeKey == VDXF_Data.DataByteVectorKey.vdxfid) { + if (!(0, string_1.isHexString)(oneValValues[k])) { + throw new Error("contentmap: bytevector data must be valid hex"); + } + map.set(objTypeKey, Buffer.from(oneValValues[k], "hex")); + } + else if (objTypeKey == VDXF_Data.DataCurrencyMapKey.vdxfid) { + const destinations = Object.keys(oneValValues[k]); + const values = Object.values(oneValValues[k]); + const oneCurMap = new CurrencyValueMap_1.CurrencyValueMap({ value_map: new Map(destinations.map((key, index) => [key, new bn_js_1.BN(values[index])])), multivalue: true }); + map.set(objTypeKey, oneCurMap); + } + else if (objTypeKey == VDXF_Data.DataRatingsKey.vdxfid) { + const oneRatingMap = Rating_1.Rating.fromJson(oneValValues[k]); + map.set(objTypeKey, oneRatingMap); + } + else if (objTypeKey == VDXF_Data.DataTransferDestinationKey.vdxfid) { + const transferDest = TransferDestination_1.TransferDestination.fromJson(oneValValues[k]); + map.set(objTypeKey, transferDest); + } + else if (objTypeKey == VDXF_Data.ContentMultiMapRemoveKey.vdxfid) { + const content = ContentMultiMapRemove_1.ContentMultiMapRemove.fromJson(oneValValues[k]); + map.set(objTypeKey, content); + } + else if (objTypeKey == VDXF_Data.CrossChainDataRefKey.vdxfid) { + const crossChainRefKey = CrossChainDataRef_1.CrossChainDataRef.fromJson(oneValValues[k]); + map.set(objTypeKey, crossChainRefKey); + } + else if (objTypeKey == VDXF_Data.DataDescriptorKey.vdxfid) { + const descriptor = DataDescriptor_1.DataDescriptor.fromJson(oneValValues[k]); + map.set(objTypeKey, descriptor); + } + else if (objTypeKey == VDXF_Data.MMRDescriptorKey.vdxfid) { + const mmrDescriptor = MMRDescriptor_1.MMRDescriptor.fromJson(oneValValues[k]); + map.set(objTypeKey, mmrDescriptor); + } + else if (objTypeKey == VDXF_Data.SignatureDataKey.vdxfid) { + const sigData = SignatureData_1.SignatureData.fromJson(oneValValues[k]); + map.set(objTypeKey, sigData); + } + else { + throw new Error("Unkknow vdxfkey: " + oneValValues[k]); + } } return new VdxfUniValue({ values: map }); } toJson() { - const ret = {}; + let ret = {}; for (const key of this.values.keys()) { - ret[key] = this.values.get(key); + if (key === "") { + ret[key] = this.values.get(key).toString('hex'); + } + else if (typeof (this.values.get(key)) == 'string') { + ret[key] = this.values.get(key); + } + else if (Buffer.isBuffer(this.values.get(key))) { + ret[key] = this.values.get(key).toString('hex'); + } + else if (this.values.get(key) instanceof bn_js_1.BN) { + ret[key] = this.values.get(key).toString(10); + } + else { + ret[key] = this.values.get(key).toJson(); + } + } + if (ret && ret[""] && Object.keys(ret).length == 1) { + ret = ret[""]; } return ret; } diff --git a/dist/pbaas/transaction/IdentityScript.d.ts b/dist/pbaas/transaction/IdentityScript.d.ts index ddeff07..b7ffb10 100644 --- a/dist/pbaas/transaction/IdentityScript.d.ts +++ b/dist/pbaas/transaction/IdentityScript.d.ts @@ -5,5 +5,5 @@ import { SmartTransactionScript } from "./SmartTransactionScript"; export declare class IdentityScript extends SmartTransactionScript implements SerializableEntity { constructor(master?: OptCCParams, params?: OptCCParams); static fromIdentity(identity: Identity): IdentityScript; - getIdentity(multimapKeylists?: Array | null>): Identity; + getIdentity(parseVdxfObjects?: boolean): Identity; } diff --git a/dist/pbaas/transaction/IdentityScript.js b/dist/pbaas/transaction/IdentityScript.js index e9da65d..89288fa 100644 --- a/dist/pbaas/transaction/IdentityScript.js +++ b/dist/pbaas/transaction/IdentityScript.js @@ -8,6 +8,8 @@ const SmartTransactionScript_1 = require("./SmartTransactionScript"); const evals_1 = require("../../utils/evals"); const TxDestination_1 = require("../TxDestination"); const IdentityID_1 = require("../IdentityID"); +const cccustom_1 = require("../../utils/cccustom"); +const KeyID_1 = require("../KeyID"); class IdentityScript extends SmartTransactionScript_1.SmartTransactionScript { constructor(master, params) { super(master, params); @@ -17,16 +19,27 @@ class IdentityScript extends SmartTransactionScript_1.SmartTransactionScript { throw new Error("Cannot generate script for outdated identity version"); } const identityAddress = identity.getIdentityAddress(); + const destinationsMaster = identity.isRevoked() ? [ + new TxDestination_1.TxDestination(IdentityID_1.IdentityID.fromAddress(identityAddress)), + new TxDestination_1.TxDestination(identity.recovery_authority) + ] : [ + new TxDestination_1.TxDestination(IdentityID_1.IdentityID.fromAddress(identityAddress)), + new TxDestination_1.TxDestination(identity.revocation_authority), + new TxDestination_1.TxDestination(identity.recovery_authority) + ]; + const destinationsRecovery = [ + new TxDestination_1.TxDestination(identity.recovery_authority) + ]; + if (identity.hasTokenizedIdControl()) { + const addrDestination = new TxDestination_1.TxDestination(KeyID_1.KeyID.fromAddress(cccustom_1.IDENTITY_RECOVER_ADDR)); + destinationsRecovery.push(addrDestination); + } const master = new OptCCParams_1.OptCCParams({ version: Identity_1.Identity.VERSION_CURRENT, eval_code: new bn_js_1.BN(evals_1.EVALS.EVAL_NONE), m: new bn_js_1.BN(1), - n: new bn_js_1.BN(3), - destinations: [ - new TxDestination_1.TxDestination(IdentityID_1.IdentityID.fromAddress(identityAddress)), - new TxDestination_1.TxDestination(identity.revocation_authority), - new TxDestination_1.TxDestination(identity.recovery_authority) - ], + n: new bn_js_1.BN(destinationsMaster.length), + destinations: destinationsMaster, vdata: [] }); const params = new OptCCParams_1.OptCCParams({ @@ -37,7 +50,17 @@ class IdentityScript extends SmartTransactionScript_1.SmartTransactionScript { destinations: [ new TxDestination_1.TxDestination(IdentityID_1.IdentityID.fromAddress(identityAddress)) ], - vdata: [ + vdata: identity.isRevoked() ? [ + identity.toBuffer(), + new OptCCParams_1.OptCCParams({ + version: Identity_1.Identity.VERSION_CURRENT, + eval_code: new bn_js_1.BN(evals_1.EVALS.EVAL_IDENTITY_RECOVER), + m: new bn_js_1.BN(1), + n: new bn_js_1.BN(destinationsRecovery.length), + destinations: destinationsRecovery, + vdata: [] + }).toChunk() + ] : [ identity.toBuffer(), new OptCCParams_1.OptCCParams({ version: Identity_1.Identity.VERSION_CURRENT, @@ -53,19 +76,17 @@ class IdentityScript extends SmartTransactionScript_1.SmartTransactionScript { version: Identity_1.Identity.VERSION_CURRENT, eval_code: new bn_js_1.BN(evals_1.EVALS.EVAL_IDENTITY_RECOVER), m: new bn_js_1.BN(1), - n: new bn_js_1.BN(1), - destinations: [ - new TxDestination_1.TxDestination(identity.recovery_authority) - ], + n: new bn_js_1.BN(destinationsRecovery.length), + destinations: destinationsRecovery, vdata: [] }).toChunk() ] }); return new IdentityScript(master, params); } - getIdentity(multimapKeylists) { + getIdentity(parseVdxfObjects = false) { const identity = new Identity_1.Identity(); - identity.fromBuffer(this.params.getParamObject(), 0, multimapKeylists); + identity.fromBuffer(this.params.getParamObject(), 0, parseVdxfObjects); return identity; } } diff --git a/dist/utils/IdentityData.d.ts b/dist/utils/IdentityData.d.ts new file mode 100644 index 0000000..b99b85f --- /dev/null +++ b/dist/utils/IdentityData.d.ts @@ -0,0 +1,6 @@ +export declare const getFriendlyNameForVdxfKey: (vdxfkey: string, locale?: string) => any; +export declare const IdentityVdxfidMap: { + [x: string]: { + EN: string; + }; +}; diff --git a/dist/utils/IdentityData.js b/dist/utils/IdentityData.js new file mode 100644 index 0000000..7e637ca --- /dev/null +++ b/dist/utils/IdentityData.js @@ -0,0 +1,163 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.IdentityVdxfidMap = exports.getFriendlyNameForVdxfKey = void 0; +const identitykeys = require("../vdxf/identitydatakeys"); +const keylist = require("../vdxf/keys"); +const IMPLEMENTED_LOCALES = ['EN']; +const getFriendlyNameForVdxfKey = (vdxfkey, locale = 'EN') => { + if (!IMPLEMENTED_LOCALES.includes(locale)) { + throw new Error(locale + " is not implemented"); + } + if (vdxfkey in exports.IdentityVdxfidMap[locale]) { + return exports.IdentityVdxfidMap[vdxfkey][locale]; + } + else { + throw new Error("Unknown VDXF key"); + } +}; +exports.getFriendlyNameForVdxfKey = getFriendlyNameForVdxfKey; +exports.IdentityVdxfidMap = { + [identitykeys.IDENTITY_FIRSTNAME.vdxfid]: { EN: "First Name" }, + [identitykeys.IDENTITY_LASTNAME.vdxfid]: { EN: "Last Name" }, + [identitykeys.IDENTITY_NATIONALITY.vdxfid]: { EN: "Nationality" }, + [identitykeys.IDENTITY_ATTESTOR.vdxfid]: { EN: "Attestor ID" }, + [identitykeys.IDENTITY_ATTESTATION_RECIPIENT.vdxfid]: { EN: "Attestation Recipient" }, + [identitykeys.IDENTITY_PHONENUMBER.vdxfid]: { EN: "Phone Number" }, + [identitykeys.IDENTITY_DATEOFBIRTH.vdxfid]: { EN: "Date of Birth" }, + [identitykeys.IDENTITY_OVER18.vdxfid]: { EN: "Over 18" }, + [identitykeys.IDENTITY_OVER21.vdxfid]: { EN: "Over 21" }, + [identitykeys.IDENTITY_OVER25.vdxfid]: { EN: "Over 25" }, + [identitykeys.IDENTITY_EMAIL.vdxfid]: { EN: "Email Address" }, + [identitykeys.IDENTITY_HOMEADDRESS.vdxfid]: { EN: "Home address" }, + [identitykeys.IDENTITY_HOMEADDRESS_STREET1.vdxfid]: { EN: "Street 1" }, + [identitykeys.IDENTITY_HOMEADDRESS_STREET2.vdxfid]: { EN: "Street 2" }, + [identitykeys.IDENTITY_HOMEADDRESS_CITY.vdxfid]: { EN: "City" }, + [identitykeys.IDENTITY_HOMEADDRESS_REGION.vdxfid]: { EN: "Region" }, + [identitykeys.IDENTITY_HOMEADDRESS_POSTCODE.vdxfid]: { EN: "Post Code" }, + [identitykeys.IDENTITY_HOMEADDRESS_COUNTRY.vdxfid]: { EN: "Country" }, + [identitykeys.IDENTITY_IDNUMBER_VALUE.vdxfid]: { EN: "ID Number" }, + [identitykeys.IDENTITY_IDNUMBER_TYPE.vdxfid]: { EN: "ID Type" }, + [identitykeys.IDENTITY_VERIFICATION_STATUS.vdxfid]: { EN: "Verification Status" }, + [identitykeys.IDENTITY_VERIFICATION_APPROVALS_ACCEPTEDTOS.vdxfid]: { EN: "Accepted Terms and Conditions" }, + [identitykeys.IDENTITY_VERIFICATION_APPROVALS_VERIFIEDSMS.vdxfid]: { EN: "SMS Verified" }, + [identitykeys.IDENTITY_VERIFICATION_APPROVALS_KYCCHECKED.vdxfid]: { EN: "KYC Checked ok" }, + [identitykeys.IDENTITY_VERIFICATION_APPROVALS_DOCUMENTSVERIFIED.vdxfid]: { EN: "Documents Verified" }, + [identitykeys.IDENTITY_VERIFICATION_APPROVALS_SELFIECHECKED.vdxfid]: { EN: "Selfie Checked" }, + [identitykeys.IDENTITY_VERIFICATION_APPROVALS_WATCHLISTOK.vdxfid]: { EN: "Watchlist ok" }, + [identitykeys.IDENTITY_VERIFICATION_APPROVALS_RISKCHECKOK.vdxfid]: { EN: "Riskcheck ok" }, + [identitykeys.IDENTITY_DRIVINGLICENCE.vdxfid]: { EN: "Driving Licence" }, + [identitykeys.IDENTITY_DRIVINGLICENCE_ORIGINALFRONT.vdxfid]: { EN: "Driving Licence Front" }, + [identitykeys.IDENTITY_DRIVINGLICENCE_ORIGINALBACK.vdxfid]: { EN: "Driving Licence Back" }, + [identitykeys.IDENTITY_DRIVINGLICENCE_CROPPEDFRONT.vdxfid]: { EN: "Driving Licence Front" }, + [identitykeys.IDENTITY_DRIVINGLICENCE_CROPPEDBACK.vdxfid]: { EN: "Driving Licence Back" }, + [identitykeys.IDENTITY_DRIVINGLICENCE_FACE.vdxfid]: { EN: "Driving Licence Face" }, + [identitykeys.IDENTITY_DRIVINGLICENCE_IDNUMBER.vdxfid]: { EN: "Driving Licence Number" }, + [identitykeys.IDENTITY_DRIVINGLICENCE_CATEGORY.vdxfid]: { EN: "Driving Licence Catagory" }, + [identitykeys.IDENTITY_DRIVINGLICENCE_EXPIRATIONDATE.vdxfid]: { EN: "Driving Licence expiry date" }, + [identitykeys.IDENTITY_DRIVINGLICENCE_ISSUINGCOUNTRY.vdxfid]: { EN: "Driving Licence issuing country" }, + [identitykeys.IDENTITY_DRIVINGLICENCE_ISSUINGREGION.vdxfid]: { EN: "Driving Licence issuing region" }, + [identitykeys.IDENTITY_DRIVINGLICENCE_DATEOFBIRTH.vdxfid]: { EN: "Driving Licence Date of Birth" }, + [identitykeys.IDENTITY_DRIVINGLICENCE_ADDRESS_STREET1.vdxfid]: { EN: "Driving Licence Street 1" }, + [identitykeys.IDENTITY_DRIVINGLICENCE_ADDRESS_CITY.vdxfid]: { EN: "Driving Licence City" }, + [identitykeys.IDENTITY_DRIVINGLICENCE_ADDRESS_REGION.vdxfid]: { EN: "Driving Licence Region" }, + [identitykeys.IDENTITY_DRIVINGLICENCE_ADDRESS_POSTCODE.vdxfid]: { EN: "Driving Licence ZIP/Post Code" }, + [identitykeys.IDENTITY_DRIVINGLICENCE_ADDRESS_COUNTRY.vdxfid]: { EN: "Driving Licence Country" }, + [identitykeys.IDENTITY_SELFIECHECK_IMAGE.vdxfid]: { EN: "Selfie Check image" }, + [identitykeys.IDENTITY_SELFIECHECK_VIDEO.vdxfid]: { EN: "Selfie Check video" }, + [identitykeys.IDENTITY_VERIFICATION_APPROVALS_RISKCHECKOK.vdxfid]: { EN: "Risk Check Ok" }, + [identitykeys.IDENTITY_EMAIL_ISDELIVERABLE.vdxfid]: { EN: "Email address is deliverable" }, + [identitykeys.IDENTITY_EMAIL_BREACHCOUNT.vdxfid]: { EN: "Email breach count" }, + [identitykeys.IDENTITY_EMAIL_FIRSTBREACHEDAT.vdxfid]: { EN: "Email first breach date" }, + [identitykeys.IDENTITY_EMAIL_LASTBREACHEDAT.vdxfid]: { EN: "Email last breach date" }, + [identitykeys.IDENTITY_EMAIL_DOMAIN_REGISTEREDAT.vdxfid]: { EN: "Email domain registered at" }, + [identitykeys.IDENTITY_EMAIL_DOMAIN_FREEPROVIDER.vdxfid]: { EN: "Email is free provider" }, + [identitykeys.IDENTITY_EMAIL_DOMAIN_CUSTOM.vdxfid]: { EN: "Email Domain is custom" }, + [identitykeys.IDENTITY_EMAIL_DOMAIN_DISPOSABLE.vdxfid]: { EN: "Email Domain Disposable" }, + [identitykeys.IDENTITY_EMAIL_DOMAIN_TOPLEVEL_SUSPICIOUS.vdxfid]: { EN: "Email top level Domain Suspicious" }, + [identitykeys.IDENTITY_IDCARD.vdxfid]: { EN: "ID Card" }, + [identitykeys.IDENTITY_IDCARD_ORIGINALFRONT.vdxfid]: { EN: "ID Card Front" }, + [identitykeys.IDENTITY_IDCARD_ORIGINALBACK.vdxfid]: { EN: "ID Card Back" }, + [identitykeys.IDENTITY_IDCARD_CROPPEDFRONT.vdxfid]: { EN: "ID Card Front" }, + [identitykeys.IDENTITY_IDCARD_CROPPEDBACK.vdxfid]: { EN: "ID Card Back" }, + [identitykeys.IDENTITY_IDCARD_FACE.vdxfid]: { EN: "ID Card Face" }, + [identitykeys.IDENTITY_IDCARD_IDNUMBER.vdxfid]: { EN: "ID Card ID Number" }, + [identitykeys.IDENTITY_IDCARD_CATEGORY.vdxfid]: { EN: "ID Card Category" }, + [identitykeys.IDENTITY_IDCARD_EXPIRATIONDATE.vdxfid]: { EN: "ID Card Expiry date" }, + [identitykeys.IDENTITY_IDCARD_ISSUINGREGION.vdxfid]: { EN: "ID Card Issuing Region" }, + [identitykeys.IDENTITY_IDCARD_DATEOFBIRTH.vdxfid]: { EN: "ID Card Date of Birth" }, + [identitykeys.IDENTITY_IDCARD_ADDRESS_STREET1.vdxfid]: { EN: "ID Card Street 1" }, + [identitykeys.IDENTITY_IDCARD_ADDRESS_CITY.vdxfid]: { EN: "ID Card City" }, + [identitykeys.IDENTITY_IDCARD_ADDRESS_REGION.vdxfid]: { EN: "ID Card Region" }, + [identitykeys.IDENTITY_IDCARD_ADDRESS_POSTCODE.vdxfid]: { EN: "ID Card Zip/Post Code" }, + [identitykeys.IDENTITY_IDCARD_ADDRESS_COUNTRY.vdxfid]: { EN: "ID Card Country" }, + [identitykeys.IDENTITY_PASSPORT.vdxfid]: { EN: "Passport" }, + [identitykeys.IDENTITY_PASSPORT_ORIGINALFRONT.vdxfid]: { EN: "Passport front" }, + [identitykeys.IDENTITY_PASSPORT_ORIGINALBACK.vdxfid]: { EN: "Passport back" }, + [identitykeys.IDENTITY_PASSPORT_CROPPEDFRONT.vdxfid]: { EN: "Passport front" }, + [identitykeys.IDENTITY_PASSPORT_CROPPEDBACK.vdxfid]: { EN: "Passport back" }, + [identitykeys.IDENTITY_PASSPORT_FACE.vdxfid]: { EN: "Passport face" }, + [identitykeys.IDENTITY_PASSPORT_IDNUMBER.vdxfid]: { EN: "Passport ID Number" }, + [identitykeys.IDENTITY_PASSPORT_CATEGORY.vdxfid]: { EN: "Passport Category" }, + [identitykeys.IDENTITY_PASSPORT_EXPIRATIONDATE.vdxfid]: { EN: "Passport expiry date" }, + [identitykeys.IDENTITY_PASSPORT_DATEOFBIRTH.vdxfid]: { EN: "Passport date of birth" }, + [identitykeys.IDENTITY_PASSPORT_ADDRESS_STREET1.vdxfid]: { EN: "Passport street 1" }, + [identitykeys.IDENTITY_PASSPORT_ADDRESS_CITY.vdxfid]: { EN: "Passport city" }, + [identitykeys.IDENTITY_PASSPORT_ADDRESS_REGION.vdxfid]: { EN: "Passport region" }, + [identitykeys.IDENTITY_PASSPORT_ADDRESS_POSTCODE.vdxfid]: { EN: "Passport zip/post code" }, + [identitykeys.IDENTITY_PASSPORT_ADDRESS_COUNTRY.vdxfid]: { EN: "Passport country" }, + [identitykeys.IDENTITY_RESIDENCEPERMIT.vdxfid]: { EN: "Residence Permit" }, + [identitykeys.IDENTITY_RESIDENCEPERMIT_ORIGINALFRONT.vdxfid]: { EN: "Residence Permit front" }, + [identitykeys.IDENTITY_RESIDENCEPERMIT_ORIGINALBACK.vdxfid]: { EN: "Residence Permit back" }, + [identitykeys.IDENTITY_RESIDENCEPERMIT_CROPPEDFRONT.vdxfid]: { EN: "Residence Permit front" }, + [identitykeys.IDENTITY_RESIDENCEPERMIT_CROPPEDBACK.vdxfid]: { EN: "Residence Permit back" }, + [identitykeys.IDENTITY_RESIDENCEPERMIT_FACE.vdxfid]: { EN: "Residence Permit face" }, + [identitykeys.IDENTITY_RESIDENCEPERMIT_IDNUMBER.vdxfid]: { EN: "Residence Permit ID Number" }, + [identitykeys.IDENTITY_RESIDENCEPERMIT_CATEGORY.vdxfid]: { EN: "Residence Permit category" }, + [identitykeys.IDENTITY_RESIDENCEPERMIT_EXPIRATIONDATE.vdxfid]: { EN: "Residence Permit expiry date" }, + [identitykeys.IDENTITY_RESIDENCEPERMIT_ISSUINGREGION.vdxfid]: { EN: "Residence Permit issuing region" }, + [identitykeys.IDENTITY_RESIDENCEPERMIT_DATEOFBIRTH.vdxfid]: { EN: "Residence Permit date of birth" }, + [identitykeys.IDENTITY_RESIDENCEPERMIT_ADDRESS.vdxfid]: { EN: "Residence Permit Address" }, + [identitykeys.IDENTITY_RESIDENCEPERMIT_ADDRESS_STREET1.vdxfid]: { EN: "Residence Permit Street 1" }, + [identitykeys.IDENTITY_RESIDENCEPERMIT_ADDRESS_CITY.vdxfid]: { EN: "Residence Permit City" }, + [identitykeys.IDENTITY_RESIDENCEPERMIT_ADDRESS_REGION.vdxfid]: { EN: "Residence Permit Region" }, + [identitykeys.IDENTITY_RESIDENCEPERMIT_ADDRESS_POSTCODE.vdxfid]: { EN: "Residence Permit Zip/Post code" }, + [identitykeys.IDENTITY_RESIDENCEPERMIT_ADDRESS_COUNTRY.vdxfid]: { EN: "Residence Permit Country" }, + [identitykeys.IDENTITY_RESIDENTCARD.vdxfid]: { EN: "Resident Card" }, + [identitykeys.IDENTITY_RESIDENTCARD_ORIGINALFRONT.vdxfid]: { EN: "Resident Card Front" }, + [identitykeys.IDENTITY_RESIDENTCARD_ORIGINALBACK.vdxfid]: { EN: "Resident Card Back" }, + [identitykeys.IDENTITY_RESIDENTCARD_CROPPEDFRONT.vdxfid]: { EN: "Resident Card Front" }, + [identitykeys.IDENTITY_RESIDENTCARD_CROPPEDBACK.vdxfid]: { EN: "Resident Card Back" }, + [identitykeys.IDENTITY_RESIDENTCARD_FACE.vdxfid]: { EN: "Resident Card Face" }, + [identitykeys.IDENTITY_RESIDENTCARD_IDNUMBER.vdxfid]: { EN: "Resident Card ID Number" }, + [identitykeys.IDENTITY_RESIDENTCARD_CATEGORY.vdxfid]: { EN: "Resident Card Category" }, + [identitykeys.IDENTITY_RESIDENTCARD_EXPIRATIONDATE.vdxfid]: { EN: "Resident Card Expiry Date" }, + [identitykeys.IDENTITY_RESIDENTCARD_ISSUINGREGION.vdxfid]: { EN: "Resident Card Issuing Region" }, + [identitykeys.IDENTITY_RESIDENTCARD_DATEOFBIRTH.vdxfid]: { EN: "Resident Card date of birth" }, + [identitykeys.IDENTITY_RESIDENTCARD_ADDRESS_STREET1.vdxfid]: { EN: "Resident Card Street 1" }, + [identitykeys.IDENTITY_RESIDENTCARD_ADDRESS_CITY.vdxfid]: { EN: "Resident Card City" }, + [identitykeys.IDENTITY_RESIDENTCARD_ADDRESS_REGION.vdxfid]: { EN: "Resident Card Region" }, + [identitykeys.IDENTITY_RESIDENTCARD_ADDRESS_POSTCODE.vdxfid]: { EN: "Resident Card Zip/Post Code" }, + [identitykeys.IDENTITY_RESIDENTCARD_ADDRESS_COUNTRY.vdxfid]: { EN: "Resident Card Country" }, + [identitykeys.IDENTITY_VISA.vdxfid]: { EN: "Visa" }, + [identitykeys.IDENTITY_VISA_ORIGINALFRONT.vdxfid]: { EN: "Visa front" }, + [identitykeys.IDENTITY_VISA_ORIGINALBACK.vdxfid]: { EN: "Visa back" }, + [identitykeys.IDENTITY_VISA_CROPPEDFRONT.vdxfid]: { EN: "Visa front" }, + [identitykeys.IDENTITY_VISA_CROPPEDBACK.vdxfid]: { EN: "Visa back" }, + [identitykeys.IDENTITY_VISA_FACE.vdxfid]: { EN: "Visa face" }, + [identitykeys.IDENTITY_VISA_IDNUMBER.vdxfid]: { EN: "Visa ID Number" }, + [identitykeys.IDENTITY_VISA_CATEGORY.vdxfid]: { EN: "Visa Category" }, + [identitykeys.IDENTITY_VISA_EXPIRATIONDATE.vdxfid]: { EN: "Visa expiry date" }, + [identitykeys.IDENTITY_VISA_ISSUINGREGION.vdxfid]: { EN: "Visa issuing region" }, + [identitykeys.IDENTITY_VISA_DATEOFBIRTH.vdxfid]: { EN: "Visa date of birth" }, + [identitykeys.IDENTITY_VISA_ADDRESS_STREET1.vdxfid]: { EN: "Visa Street 1" }, + [identitykeys.IDENTITY_VISA_ADDRESS_CITY.vdxfid]: { EN: "Visa City" }, + [identitykeys.IDENTITY_VISA_ADDRESS_REGION.vdxfid]: { EN: "Visa Region" }, + [identitykeys.IDENTITY_VISA_ADDRESS_POSTCODE.vdxfid]: { EN: "Visa Zip/Post Code" }, + [identitykeys.IDENTITY_VISA_ADDRESS_COUNTRY.vdxfid]: { EN: "Visa Country" }, + [keylist.ATTESTATION_PROVISION_TYPE.vdxfid]: { EN: "Attestation Type" }, + [keylist.ATTESTATION_PROVISION_URL.vdxfid]: { EN: "Attestation URL" }, + [keylist.ATTESTATION_VIEW_RESPONSE.vdxfid]: { EN: "Attestation View Response" }, + [keylist.ATTESTATION_VIEW_REQUEST.vdxfid]: { EN: "Attestation View Response" }, + [keylist.PROFILE_DATA_VIEW_REQUEST.vdxfid]: { EN: "Profile Data View Request" }, + [keylist.IDENTITY_SIGNDATA_REQUEST.vdxfid]: { EN: "Identity Sign Data Request" } +}; diff --git a/dist/utils/cccustom.d.ts b/dist/utils/cccustom.d.ts new file mode 100644 index 0000000..e5bbe42 --- /dev/null +++ b/dist/utils/cccustom.d.ts @@ -0,0 +1,20 @@ +export declare const STAKE_GUARD_ADDR = "RCG8KwJNDVwpUBcdoa6AoHqHVJsA1uMYMR"; +export declare const PBAAS_DEFINITION_ADDR = "RP7id3CzCnwvzNUZesYJM6ekvsxpEzMqB1"; +export declare const NOTARY_EVIDENCE_ADDR = "RQWMeecjGFF3ZAVeSimRbyG9iMDUHPY5Ny"; +export declare const EARNED_NOTARIZATION_ADDR = "RMYbaxFsCT1xfMmwLCCYAVf2DsxcDTtBmx"; +export declare const ACCEPTED_NOTARIZATION_ADDR = "RDTq9qn1Lthv7fvsdbWz36mGp8HK9XaruZ"; +export declare const FINALIZE_NOTARIZATION_ADDR = "RRbKYitLH9EhQCvCo4bPZqJx3TWxASadxE"; +export declare const RESERVE_OUTPUT_ADDR = "RMXeZGxxRuABFkT4uLSCeuJHLegBNGZq8D"; +export declare const ADVANCED_NAME_RESERVATION_ADDR = "REuGNkgunnw1J4Zx6Y9UCp8YHVZqYATe9D"; +export declare const RESERVE_TRANSFER_ADDR = "RTqQe58LSj2yr5CrwYFwcsAQ1edQwmrkUU"; +export declare const RESERVE_DEPOSIT_ADDR = "RFw9AVfgNKcHe2Vp2eyzHrX65aFD9Ky8df"; +export declare const CROSS_CHAIN_EXPORT_ADDR = "RGkrs7SndcpsV61oKK2jYdMiU8PgkLU2qP"; +export declare const CROSS_CHAIN_IMPORT_ADDR = "RKLN7wFhbrJFkPG8XkKteErAe5CjqoddTm"; +export declare const CURRENCY_STATE_ADDR = "REU1HKkmdwdxKMpfD3QoxeERYd9tfMN6n9"; +export declare const IDENTITY_PRIMARY_ADDR = "RS545EBdK5AzPTaGHNUg78wFuuAzBb74FB"; +export declare const IDENTITY_REVOKE_ADDR = "RG6My2zwh9hBFSgUhZ5UmmUtxBap57aU4N"; +export declare const IDENTITY_RECOVER_ADDR = "RRw9rJMPwdNqC1wgXn5vryJwMDyBgpXjYT"; +export declare const IDENTITY_COMMITMENT_ADDR = "RCySaThHfVBcHZgjJGoBw3un4vcsRJNPYw"; +export declare const IDENTITY_RESERVATION_ADDR = "RDbzJU8rEv4CkMABNUnKQoKDTfnikSm9fM"; +export declare const FINALIZE_EXPORT_ADDR = "REL7oLNeaeoQB1XauiHfcvjKMZC52Uj5xF"; +export declare const FEE_POOL_ADDR = "RQ55dLQ7uGnLx8scXfkaFV6QS6qVBGyxAG"; diff --git a/dist/utils/cccustom.js b/dist/utils/cccustom.js new file mode 100644 index 0000000..1acb4d5 --- /dev/null +++ b/dist/utils/cccustom.js @@ -0,0 +1,23 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.FEE_POOL_ADDR = exports.FINALIZE_EXPORT_ADDR = exports.IDENTITY_RESERVATION_ADDR = exports.IDENTITY_COMMITMENT_ADDR = exports.IDENTITY_RECOVER_ADDR = exports.IDENTITY_REVOKE_ADDR = exports.IDENTITY_PRIMARY_ADDR = exports.CURRENCY_STATE_ADDR = exports.CROSS_CHAIN_IMPORT_ADDR = exports.CROSS_CHAIN_EXPORT_ADDR = exports.RESERVE_DEPOSIT_ADDR = exports.RESERVE_TRANSFER_ADDR = exports.ADVANCED_NAME_RESERVATION_ADDR = exports.RESERVE_OUTPUT_ADDR = exports.FINALIZE_NOTARIZATION_ADDR = exports.ACCEPTED_NOTARIZATION_ADDR = exports.EARNED_NOTARIZATION_ADDR = exports.NOTARY_EVIDENCE_ADDR = exports.PBAAS_DEFINITION_ADDR = exports.STAKE_GUARD_ADDR = void 0; +exports.STAKE_GUARD_ADDR = "RCG8KwJNDVwpUBcdoa6AoHqHVJsA1uMYMR"; +exports.PBAAS_DEFINITION_ADDR = "RP7id3CzCnwvzNUZesYJM6ekvsxpEzMqB1"; +exports.NOTARY_EVIDENCE_ADDR = "RQWMeecjGFF3ZAVeSimRbyG9iMDUHPY5Ny"; +exports.EARNED_NOTARIZATION_ADDR = "RMYbaxFsCT1xfMmwLCCYAVf2DsxcDTtBmx"; +exports.ACCEPTED_NOTARIZATION_ADDR = "RDTq9qn1Lthv7fvsdbWz36mGp8HK9XaruZ"; +exports.FINALIZE_NOTARIZATION_ADDR = "RRbKYitLH9EhQCvCo4bPZqJx3TWxASadxE"; +exports.RESERVE_OUTPUT_ADDR = "RMXeZGxxRuABFkT4uLSCeuJHLegBNGZq8D"; +exports.ADVANCED_NAME_RESERVATION_ADDR = "REuGNkgunnw1J4Zx6Y9UCp8YHVZqYATe9D"; +exports.RESERVE_TRANSFER_ADDR = "RTqQe58LSj2yr5CrwYFwcsAQ1edQwmrkUU"; +exports.RESERVE_DEPOSIT_ADDR = "RFw9AVfgNKcHe2Vp2eyzHrX65aFD9Ky8df"; +exports.CROSS_CHAIN_EXPORT_ADDR = "RGkrs7SndcpsV61oKK2jYdMiU8PgkLU2qP"; +exports.CROSS_CHAIN_IMPORT_ADDR = "RKLN7wFhbrJFkPG8XkKteErAe5CjqoddTm"; +exports.CURRENCY_STATE_ADDR = "REU1HKkmdwdxKMpfD3QoxeERYd9tfMN6n9"; +exports.IDENTITY_PRIMARY_ADDR = "RS545EBdK5AzPTaGHNUg78wFuuAzBb74FB"; +exports.IDENTITY_REVOKE_ADDR = "RG6My2zwh9hBFSgUhZ5UmmUtxBap57aU4N"; +exports.IDENTITY_RECOVER_ADDR = "RRw9rJMPwdNqC1wgXn5vryJwMDyBgpXjYT"; +exports.IDENTITY_COMMITMENT_ADDR = "RCySaThHfVBcHZgjJGoBw3un4vcsRJNPYw"; +exports.IDENTITY_RESERVATION_ADDR = "RDbzJU8rEv4CkMABNUnKQoKDTfnikSm9fM"; +exports.FINALIZE_EXPORT_ADDR = "REL7oLNeaeoQB1XauiHfcvjKMZC52Uj5xF"; +exports.FEE_POOL_ADDR = "RQ55dLQ7uGnLx8scXfkaFV6QS6qVBGyxAG"; diff --git a/dist/utils/mmr.d.ts b/dist/utils/mmr.d.ts new file mode 100644 index 0000000..4bf5e50 --- /dev/null +++ b/dist/utils/mmr.d.ts @@ -0,0 +1,2 @@ +import { BN } from 'bn.js'; +export declare const GetMMRProofIndex: (pos: number, mmvSize: number, extraHashes: number) => InstanceType; diff --git a/dist/utils/mmr.js b/dist/utils/mmr.js new file mode 100644 index 0000000..8cbc00e --- /dev/null +++ b/dist/utils/mmr.js @@ -0,0 +1,87 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.GetMMRProofIndex = void 0; +const bn_js_1 = require("bn.js"); +const GetMMRProofIndex = (pos, mmvSize, extraHashes) => { + let index = new bn_js_1.BN(0); + let layerSizes = []; + let merkleSizes = []; + let peakIndexes = []; + let bitPos = 0; + //start at the beginning + //create a simulation of a mmr based on size + if (!(pos > 0 && pos < mmvSize)) + return new bn_js_1.BN(0); + //create an array of all the sizes + while (mmvSize) { + layerSizes.push(mmvSize); + mmvSize = mmvSize >> 1; + } + for (let height = 0; height < layerSizes.length; height++) { + if (height == layerSizes.length - 1 || layerSizes[height] & 1) { + peakIndexes.push(height); + } + } + //array flip peak indexes + peakIndexes.reverse(); + let layerNum = 0; + let layerSize = peakIndexes.length; + for (let passThrough = (layerSize & 1); layerNum == 0 || layerSize > 1; passThrough = (layerSize & 1), layerNum++) { + layerSize = (layerSize >> 1) + passThrough; + if (layerSize) { + merkleSizes.push(layerSize); + } + } + //flip the merklesizes + for (let i = 0; i < extraHashes; i++) { + bitPos++; + } + let p = pos; + for (let l = 0; l < layerSizes.length; l++) { + if (p & 1) { + index = index.or(new bn_js_1.BN(1).shln(bitPos++)); + p >>= 1; + for (let i = 0; i < extraHashes; i++) { + bitPos++; + } + } + else { + if (layerSizes[l] > (p + 1)) { + bitPos++; + p >>= 1; + for (let i = 0; i < extraHashes; i++) { + bitPos++; + } + } + else { + for (p = 0; p < peakIndexes.length; p++) { + if (peakIndexes[p] == l) { + break; + } + } + for (let layerNum = -1, layerSize = peakIndexes.length; layerNum == -1 || layerSize > 1; layerSize = merkleSizes[++layerNum]) { + if (p < (layerSize - 1) || (p & 1)) { + if (p & 1) { + // hash with the one before us + index = index.or(new bn_js_1.BN(1).shln(bitPos++)); + for (let i = 0; i < extraHashes; i++) { + bitPos++; + } + } + else { + // hash with the one in front of us + bitPos++; + for (let i = 0; i < extraHashes; i++) { + bitPos++; + } + } + } + p >>= 1; + } + break; + } + } + } + return index; +}; +exports.GetMMRProofIndex = GetMMRProofIndex; diff --git a/dist/utils/types/DataDescriptor.d.ts b/dist/utils/types/DataDescriptor.d.ts new file mode 100644 index 0000000..6679e4a --- /dev/null +++ b/dist/utils/types/DataDescriptor.d.ts @@ -0,0 +1,11 @@ +export declare type DataDescriptorInfo = { + version?: number; + flags?: number; + objectdata?: string; + label?: string; + mimeType?: string; + salt?: string; + epk?: string; + ivk?: string; + ssk?: string; +}; diff --git a/dist/utils/types/DataDescriptor.js b/dist/utils/types/DataDescriptor.js new file mode 100644 index 0000000..c8ad2e5 --- /dev/null +++ b/dist/utils/types/DataDescriptor.js @@ -0,0 +1,2 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); diff --git a/dist/utils/types/MmrDescriptor.d.ts b/dist/utils/types/MmrDescriptor.d.ts new file mode 100644 index 0000000..e5a14de --- /dev/null +++ b/dist/utils/types/MmrDescriptor.d.ts @@ -0,0 +1,9 @@ +import { DataDescriptorInfo } from './DataDescriptor'; +export declare type MmrDescriptorParameters = { + version?: number; + objecthashtype?: number; + mmrhashtype?: number; + mmrroot?: DataDescriptorInfo; + mmrhashes?: DataDescriptorInfo; + datadescriptors?: DataDescriptorInfo[]; +}; diff --git a/dist/utils/types/MmrDescriptor.js b/dist/utils/types/MmrDescriptor.js new file mode 100644 index 0000000..c8ad2e5 --- /dev/null +++ b/dist/utils/types/MmrDescriptor.js @@ -0,0 +1,2 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); diff --git a/dist/utils/types/SignData.d.ts b/dist/utils/types/SignData.d.ts new file mode 100644 index 0000000..dd0cbb5 --- /dev/null +++ b/dist/utils/types/SignData.d.ts @@ -0,0 +1,8 @@ +export declare type SignDataParameters = { + filename?: string; + message?: string; + messagehex?: string; + messsagebase64?: string; + datahash?: string; + vdxfdata?: string; +}; diff --git a/dist/utils/types/SignData.js b/dist/utils/types/SignData.js new file mode 100644 index 0000000..c8ad2e5 --- /dev/null +++ b/dist/utils/types/SignData.js @@ -0,0 +1,2 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); diff --git a/dist/utils/types/Signature.d.ts b/dist/utils/types/Signature.d.ts new file mode 100644 index 0000000..0f57ddd --- /dev/null +++ b/dist/utils/types/Signature.d.ts @@ -0,0 +1,9 @@ +export declare type SignatureDataInfo = { + version: number; + systemid: string; + hashtype: number; + signaturehash: string; + identityid: string; + signaturetype: number; + signature: string; +}; diff --git a/dist/utils/types/Signature.js b/dist/utils/types/Signature.js new file mode 100644 index 0000000..c8ad2e5 --- /dev/null +++ b/dist/utils/types/Signature.js @@ -0,0 +1,2 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); diff --git a/dist/vdxf/classes/Attestation.d.ts b/dist/vdxf/classes/Attestation.d.ts new file mode 100644 index 0000000..b9b44e3 --- /dev/null +++ b/dist/vdxf/classes/Attestation.d.ts @@ -0,0 +1,38 @@ +/// +import { BufferDataVdxfObject } from '../index'; +import { SerializableEntity } from '../../utils/types/SerializableEntity'; +export declare class Attestation extends BufferDataVdxfObject { + getAttestationData(): { + [key: string]: AttestationViewRequest; + }; +} +export declare class AttestationViewRequest implements SerializableEntity { + attestation_id: string; + accepted_attestors: Array; + attestation_keys: Array; + attestor_filters: Array; + constructor(data?: { + attestation_id?: string; + accepted_attestors?: Array; + attestation_keys?: Array; + attestor_filters?: Array; + }); + getByteLength(): number; + toBuffer(): Buffer; + fromBuffer(buffer: Buffer, offset?: number): number; +} +export declare class AttestationProvisioningData implements SerializableEntity { + attestation_id: string; + accepted_attestors: Array; + attestation_keys: Array; + attestor_filters: Array; + constructor(data?: { + attestation_id?: string; + accepted_attestors?: Array; + attestation_keys?: Array; + attestor_filters?: Array; + }); + getByteLength(): number; + toBuffer(): Buffer; + fromBuffer(buffer: Buffer, offset?: number): number; +} diff --git a/dist/vdxf/classes/Attestation.js b/dist/vdxf/classes/Attestation.js new file mode 100644 index 0000000..608690d --- /dev/null +++ b/dist/vdxf/classes/Attestation.js @@ -0,0 +1,146 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.AttestationProvisioningData = exports.AttestationViewRequest = exports.Attestation = void 0; +const bufferutils_1 = require("../../utils/bufferutils"); +const address_1 = require("../../utils/address"); +const vdxf_1 = require("../../constants/vdxf"); +const DataDescriptor_1 = require("../../pbaas/DataDescriptor"); +const __1 = require("../"); +const varuint_1 = require("../../utils/varuint"); +const index_1 = require("../index"); +const { BufferReader, BufferWriter } = bufferutils_1.default; +class Attestation extends index_1.BufferDataVdxfObject { + getAttestationData() { + const reader = new BufferReader(Buffer.from(this.data, 'hex')); + const returnedData = {}; + while (reader.buffer.length > reader.offset) { + let vdxfkey = (0, address_1.toBase58Check)(reader.readSlice(20), vdxf_1.I_ADDR_VERSION); + switch (vdxfkey) { + case __1.ATTESTATION_VIEW_REQUEST.vdxfid: + returnedData[vdxfkey] = new AttestationViewRequest(); + reader.offset = returnedData[vdxfkey].fromBuffer(reader.buffer, reader.offset); + break; + case __1.ATTESTATION_PROVISION_TYPE.vdxfid: + let dataDescriptorItemsCount = reader.readCompactSize(); + let dataDescriptors = []; + for (let i = 0; i < dataDescriptorItemsCount; i++) { + let dataDescriptor = new DataDescriptor_1.DataDescriptor(); + reader.offset = dataDescriptor.fromBuffer(reader.buffer, reader.offset); + dataDescriptors.push(dataDescriptor); + } + returnedData[vdxfkey] = dataDescriptors; + break; + default: + throw new Error("Unsupported Attestation Data Type"); + } + } + return returnedData; + } +} +exports.Attestation = Attestation; +class AttestationViewRequest { + constructor(data) { + this.attestation_id = data.attestation_id || ""; + this.accepted_attestors = data.accepted_attestors || []; + this.attestation_keys = data.attestation_keys || []; + this.attestor_filters = data.attestor_filters || []; + } + getByteLength() { + let length = 0; // attestation_id + length += varuint_1.default.encodingLength(this.accepted_attestors.length); + length += this.accepted_attestors.length * 20; // accepted_attestors + length += varuint_1.default.encodingLength(this.attestation_keys.length); + length += this.attestation_keys.length * 20; // attestation_keys + length += varuint_1.default.encodingLength(this.attestor_filters.length); + length += this.attestor_filters.length * 20; // attestor_filters + return length; + } + toBuffer() { + const bufferWriter = new BufferWriter(Buffer.alloc(this.getByteLength())); + bufferWriter.writeSlice((0, address_1.fromBase58Check)(this.attestation_id).hash); + bufferWriter.writeCompactSize(this.accepted_attestors.length); + for (let i = 0; i < this.accepted_attestors.length; i++) { + bufferWriter.writeSlice((0, address_1.fromBase58Check)(this.accepted_attestors[i]).hash); + } + bufferWriter.writeCompactSize(this.attestation_keys.length); + for (let i = 0; i < this.attestation_keys.length; i++) { + bufferWriter.writeSlice((0, address_1.fromBase58Check)(this.attestation_keys[i]).hash); + } + bufferWriter.writeCompactSize(this.attestor_filters.length); + for (let i = 0; i < this.attestor_filters.length; i++) { + bufferWriter.writeSlice((0, address_1.fromBase58Check)(this.attestor_filters[i]).hash); + } + return bufferWriter.buffer; + } + fromBuffer(buffer, offset = 0) { + const reader = new BufferReader(buffer, offset); + this.attestation_id = (0, address_1.toBase58Check)(reader.readSlice(20), vdxf_1.I_ADDR_VERSION); + let attestorCount = reader.readCompactSize(); + for (let i = 0; i < attestorCount; i++) { + this.accepted_attestors.push((0, address_1.toBase58Check)(reader.readSlice(20), vdxf_1.I_ADDR_VERSION)); + } + let attestationKeyCount = reader.readCompactSize(); + for (let i = 0; i < attestationKeyCount; i++) { + this.attestation_keys.push((0, address_1.toBase58Check)(reader.readSlice(20), vdxf_1.I_ADDR_VERSION)); + } + let attestorFilterCount = reader.readCompactSize(); + for (let i = 0; i < attestorFilterCount; i++) { + this.attestor_filters.push((0, address_1.toBase58Check)(reader.readSlice(20), vdxf_1.I_ADDR_VERSION)); + } + return reader.offset; + } +} +exports.AttestationViewRequest = AttestationViewRequest; +class AttestationProvisioningData { + constructor(data) { + this.attestation_id = data.attestation_id || ""; + this.accepted_attestors = data.accepted_attestors || []; + this.attestation_keys = data.attestation_keys || []; + this.attestor_filters = data.attestor_filters || []; + } + getByteLength() { + let length = 0; // attestation_id + length += varuint_1.default.encodingLength(this.accepted_attestors.length); + length += this.accepted_attestors.length * 20; // accepted_attestors + length += varuint_1.default.encodingLength(this.attestation_keys.length); + length += this.attestation_keys.length * 20; // attestation_keys + length += varuint_1.default.encodingLength(this.attestor_filters.length); + length += this.attestor_filters.length * 20; // attestor_filters + return length; + } + toBuffer() { + const bufferWriter = new BufferWriter(Buffer.alloc(this.getByteLength())); + bufferWriter.writeSlice((0, address_1.fromBase58Check)(this.attestation_id).hash); + bufferWriter.writeCompactSize(this.accepted_attestors.length); + for (let i = 0; i < this.accepted_attestors.length; i++) { + bufferWriter.writeSlice((0, address_1.fromBase58Check)(this.accepted_attestors[i]).hash); + } + bufferWriter.writeCompactSize(this.attestation_keys.length); + for (let i = 0; i < this.attestation_keys.length; i++) { + bufferWriter.writeSlice((0, address_1.fromBase58Check)(this.attestation_keys[i]).hash); + } + bufferWriter.writeCompactSize(this.attestor_filters.length); + for (let i = 0; i < this.attestor_filters.length; i++) { + bufferWriter.writeSlice((0, address_1.fromBase58Check)(this.attestor_filters[i]).hash); + } + return bufferWriter.buffer; + } + fromBuffer(buffer, offset = 0) { + const reader = new BufferReader(buffer, offset); + this.attestation_id = (0, address_1.toBase58Check)(reader.readSlice(20), vdxf_1.I_ADDR_VERSION); + let attestorCount = reader.readCompactSize(); + for (let i = 0; i < attestorCount; i++) { + this.accepted_attestors.push((0, address_1.toBase58Check)(reader.readSlice(20), vdxf_1.I_ADDR_VERSION)); + } + let attestationKeyCount = reader.readCompactSize(); + for (let i = 0; i < attestationKeyCount; i++) { + this.attestation_keys.push((0, address_1.toBase58Check)(reader.readSlice(20), vdxf_1.I_ADDR_VERSION)); + } + let attestorFilterCount = reader.readCompactSize(); + for (let i = 0; i < attestorFilterCount; i++) { + this.attestor_filters.push((0, address_1.toBase58Check)(reader.readSlice(20), vdxf_1.I_ADDR_VERSION)); + } + return reader.offset; + } +} +exports.AttestationProvisioningData = AttestationProvisioningData; diff --git a/dist/vdxf/classes/Challenge.d.ts b/dist/vdxf/classes/Challenge.d.ts index 324e4c3..56202d6 100644 --- a/dist/vdxf/classes/Challenge.d.ts +++ b/dist/vdxf/classes/Challenge.d.ts @@ -1,6 +1,8 @@ /// import { Utf8DataVdxfObject, VDXFObject, Utf8OrBase58Object } from "../"; import { Context } from "./Context"; +import { Hash160 } from "./Hash160"; +import { Attestation } from "./Attestation"; export declare class RedirectUri extends VDXFObject { uri: string; constructor(uri?: string, vdxfkey?: string); @@ -18,15 +20,10 @@ export declare class Subject extends Utf8OrBase58Object { export declare class ProvisioningInfo extends Utf8OrBase58Object { constructor(data?: string, vdxfkey?: string); } -export declare class RequestedPermission extends Utf8DataVdxfObject { - constructor(vdxfkey?: string); -} export declare class Audience extends Utf8DataVdxfObject { } export declare class AltAuthFactor extends Utf8DataVdxfObject { } -export declare class Attestation extends Utf8DataVdxfObject { -} export interface ChallengeInterface { challenge_id: string; requested_access?: Array | null; @@ -45,7 +42,7 @@ export interface ChallengeInterface { export declare class Challenge extends VDXFObject implements ChallengeInterface { challenge_id: string; requested_access?: Array | null; - requested_access_audience?: Array | null; + requested_access_audience?: Array | null; subject?: Array; provisioning_info?: Array; alt_auth_factors?: Array | null; @@ -64,7 +61,7 @@ export declare class Challenge extends VDXFObject implements ChallengeInterface vdxfkey: string; challenge_id: string; requested_access: RequestedPermission[]; - requested_access_audience: RequestedPermission[]; + requested_access_audience: Audience[]; subject: Subject[]; provisioning_info: ProvisioningInfo[]; alt_auth_factors: AltAuthFactor[]; @@ -80,3 +77,10 @@ export declare class Challenge extends VDXFObject implements ChallengeInterface skip: boolean; }; } +export declare class RequestedPermission extends VDXFObject { + data: Array; + constructor(vdxfkey?: string, data?: Array | Array); + dataByteLength(): number; + toDataBuffer(): Buffer; + fromDataBuffer(buffer: Buffer, offset?: number): number; +} diff --git a/dist/vdxf/classes/Challenge.js b/dist/vdxf/classes/Challenge.js index 5b6dae5..d91e246 100644 --- a/dist/vdxf/classes/Challenge.js +++ b/dist/vdxf/classes/Challenge.js @@ -1,11 +1,13 @@ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); -exports.Challenge = exports.Attestation = exports.AltAuthFactor = exports.Audience = exports.RequestedPermission = exports.ProvisioningInfo = exports.Subject = exports.RedirectUri = void 0; +exports.RequestedPermission = exports.Challenge = exports.AltAuthFactor = exports.Audience = exports.ProvisioningInfo = exports.Subject = exports.RedirectUri = void 0; const __1 = require("../"); const bufferutils_1 = require("../../utils/bufferutils"); const varuint_1 = require("../../utils/varuint"); const Context_1 = require("./Context"); const Hash160_1 = require("./Hash160"); +const Attestation_1 = require("./Attestation"); +const address_1 = require("../../utils/address"); class RedirectUri extends __1.VDXFObject { constructor(uri = "", vdxfkey = "") { super(vdxfkey); @@ -50,28 +52,17 @@ class ProvisioningInfo extends __1.Utf8OrBase58Object { } } exports.ProvisioningInfo = ProvisioningInfo; -class RequestedPermission extends __1.Utf8DataVdxfObject { - constructor(vdxfkey = "") { - super("", vdxfkey); - } -} -exports.RequestedPermission = RequestedPermission; class Audience extends __1.Utf8DataVdxfObject { } exports.Audience = Audience; class AltAuthFactor extends __1.Utf8DataVdxfObject { } exports.AltAuthFactor = AltAuthFactor; -class Attestation extends __1.Utf8DataVdxfObject { -} -exports.Attestation = Attestation; class Challenge extends __1.VDXFObject { constructor(challenge = { challenge_id: "", created_at: 0 }, vdxfkey = __1.LOGIN_CONSENT_CHALLENGE_VDXF_KEY.vdxfid) { super(vdxfkey); this.challenge_id = challenge.challenge_id; - this.requested_access = challenge.requested_access - ? challenge.requested_access.map((x) => new RequestedPermission(x.vdxfkey)) - : challenge.requested_access; + this.requested_access = challenge.requested_access ? challenge.requested_access.map((x) => new RequestedPermission(x.vdxfkey, x.data)) : challenge.requested_access; this.requested_access_audience = challenge.requested_access_audience; this.subject = challenge.subject ? challenge.subject.map((x) => new Subject(x.data, x.vdxfkey)) @@ -109,7 +100,7 @@ class Challenge extends __1.VDXFObject { const _subject = this.subject ? this.subject : []; const _provisioning_info = this.provisioning_info ? this.provisioning_info : []; const _alt_auth_factors = []; - const _attestations = []; + const _attestations = this.attestations ? this.attestations : []; const _redirect_uris = this.redirect_uris ? this.redirect_uris : []; const _context = this.context ? this.context : new Context_1.Context({}); length += _challenge_id.byteLength(); @@ -127,6 +118,7 @@ class Challenge extends __1.VDXFObject { length += _provisioning_info.reduce((sum, current) => sum + current.byteLength(), 0); length += varuint_1.default.encodingLength(_alt_auth_factors.length); length += varuint_1.default.encodingLength(_attestations.length); + length += _attestations.reduce((sum, current) => sum + current.byteLength(), 0); length += varuint_1.default.encodingLength(_redirect_uris.length); length += _redirect_uris.reduce((sum, current) => sum + current.byteLength(), 0); } @@ -151,7 +143,7 @@ class Challenge extends __1.VDXFObject { const _subject = this.subject ? this.subject : []; const _provisioning_info = this.provisioning_info ? this.provisioning_info : []; const _alt_auth_factors = []; - const _attestations = []; + const _attestations = this.attestations ? this.attestations : []; const _redirect_uris = this.redirect_uris ? this.redirect_uris : []; const _context = this.context ? this.context : new Context_1.Context({}); writer.writeSlice(_challenge_id.toBuffer()); @@ -223,8 +215,10 @@ class Challenge extends __1.VDXFObject { } this.attestations = []; const attestationsLength = reader.readCompactSize(); - if (attestationsLength > 0) { - throw new Error("Attestations currently unsupported"); + for (let i = 0; i < attestationsLength; i++) { + const _att = new Attestation_1.Attestation(); + reader.offset = _att.fromBuffer(reader.buffer, reader.offset); + this.attestations.push(_att); } this.redirect_uris = []; const urisLength = reader.readCompactSize(); @@ -262,3 +256,47 @@ class Challenge extends __1.VDXFObject { } } exports.Challenge = Challenge; +class RequestedPermission extends __1.VDXFObject { + constructor(vdxfkey, data) { + super(vdxfkey); + if (data && data.length > 0) { + if (data[0] instanceof Hash160_1.Hash160) { + this.data = data; + } + else { + this.data = data.map((x) => new Hash160_1.Hash160((0, address_1.fromBase58Check)(x).hash)); + } + } + else { + this.data = []; + } + } + dataByteLength() { + let length = 0; + length += varuint_1.default.encodingLength(this.data.length); + for (let i = 0; i < this.data.length; i++) { + length += 20; + } + return length; + } + toDataBuffer() { + const buffer = Buffer.alloc(this.dataByteLength()); + const writer = new bufferutils_1.default.BufferWriter(buffer); + writer.writeCompactSize(this.data.length); + for (let i = 0; i < this.data.length; i++) { + writer.writeSlice(this.data[i].toBuffer()); + } + return writer.buffer; + } + fromDataBuffer(buffer, offset) { + const reader = new bufferutils_1.default.BufferReader(buffer, offset); + const contextLength = reader.readCompactSize(); + const numKeys = reader.readCompactSize(); + this.data = []; + for (let i = 0; i < numKeys; i++) { + this.data.push(new Hash160_1.Hash160(reader.readSlice(20))); + } + return reader.offset; + } +} +exports.RequestedPermission = RequestedPermission; diff --git a/dist/vdxf/classes/Decision.d.ts b/dist/vdxf/classes/Decision.d.ts index 83313c0..0f5309f 100644 --- a/dist/vdxf/classes/Decision.d.ts +++ b/dist/vdxf/classes/Decision.d.ts @@ -1,6 +1,6 @@ /// import { VDXFObject } from ".."; -import { Attestation } from "./Challenge"; +import { Attestation } from "./Attestation"; import { Context } from "./Context"; import { Request, RequestInterface } from "./Request"; export interface DecisionInterface { @@ -18,7 +18,7 @@ export declare class Decision extends VDXFObject { request: Request; created_at: number; skipped?: boolean; - attestations: Array; + attestations: Array; salt?: string; constructor(decision?: DecisionInterface, vdxfkey?: string); dataByteLength(): number; @@ -43,7 +43,7 @@ export declare class Decision extends VDXFObject { vdxfkey: string; challenge_id: string; requested_access: import("./Challenge").RequestedPermission[]; - requested_access_audience: import("./Challenge").RequestedPermission[]; + requested_access_audience: import("./Challenge").Audience[]; subject: import("./Challenge").Subject[]; provisioning_info: import("./Challenge").ProvisioningInfo[]; alt_auth_factors: import("./Challenge").AltAuthFactor[]; diff --git a/dist/vdxf/classes/Decision.js b/dist/vdxf/classes/Decision.js index 188e0b0..083e028 100644 --- a/dist/vdxf/classes/Decision.js +++ b/dist/vdxf/classes/Decision.js @@ -4,6 +4,7 @@ exports.Decision = void 0; const __1 = require(".."); const bufferutils_1 = require("../../utils/bufferutils"); const varuint_1 = require("../../utils/varuint"); +const Attestation_1 = require("./Attestation"); const Context_1 = require("./Context"); const Hash160_1 = require("./Hash160"); const Request_1 = require("./Request"); @@ -30,13 +31,14 @@ class Decision extends __1.VDXFObject { : Hash160_1.Hash160.getEmpty(); const _request = this.request ? this.request : new Request_1.Request(); const _context = this.context ? this.context : new Context_1.Context(); - const _attestations = []; + const _attestations = this.attestations ? this.attestations : []; length += _challenge_id.byteLength(); length += 8; // created_at length += _salt.byteLength(); if (this.vdxfkey === __1.LOGIN_CONSENT_DECISION_VDXF_KEY.vdxfid) { length += 1; // skipped length += varuint_1.default.encodingLength(_attestations.length); + length += _attestations.reduce((sum, current) => sum + current.byteLength(), 0); } length += _request.byteLength(); length += _context.byteLength(); @@ -52,7 +54,7 @@ class Decision extends __1.VDXFObject { : Hash160_1.Hash160.getEmpty(); const _request = this.request ? this.request : new Request_1.Request(); const _context = this.context ? this.context : new Context_1.Context(); - const _attestations = []; + const _attestations = this.attestations ? this.attestations : []; writer.writeSlice(_decision_id.toBuffer()); writer.writeUInt64(_created_at); writer.writeSlice(_salt.toBuffer()); @@ -82,8 +84,10 @@ class Decision extends __1.VDXFObject { this.skipped = reader.readUInt8() === 1 ? true : false; this.attestations = []; const attestationsLength = reader.readCompactSize(); - if (attestationsLength > 0) { - throw new Error("Attestations currently unsupported"); + for (let i = 0; i < attestationsLength; i++) { + const _att = new Attestation_1.Attestation(); + reader.offset = _att.fromBuffer(reader.buffer, reader.offset); + this.attestations.push(_att); } } const _context = new Context_1.Context(); diff --git a/dist/vdxf/classes/PersonalProfile.d.ts b/dist/vdxf/classes/PersonalProfile.d.ts new file mode 100644 index 0000000..6b99a84 --- /dev/null +++ b/dist/vdxf/classes/PersonalProfile.d.ts @@ -0,0 +1,7 @@ +import { VDXFObject } from ".."; +export declare class DataCategory extends VDXFObject { + data: Array; + category: string; + details: string; + constructor(vdxfid?: string, data?: Array, category?: string, details?: string); +} diff --git a/dist/vdxf/classes/PersonalProfile.js b/dist/vdxf/classes/PersonalProfile.js new file mode 100644 index 0000000..1deec6a --- /dev/null +++ b/dist/vdxf/classes/PersonalProfile.js @@ -0,0 +1,13 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.DataCategory = void 0; +const __1 = require(".."); +class DataCategory extends __1.VDXFObject { + constructor(vdxfid = "", data, category, details) { + super(vdxfid); + this.data = data || []; + this.category = category || ""; + this.details = details || ""; + } +} +exports.DataCategory = DataCategory; diff --git a/dist/vdxf/classes/Request.d.ts b/dist/vdxf/classes/Request.d.ts index 235325f..b070c21 100644 --- a/dist/vdxf/classes/Request.d.ts +++ b/dist/vdxf/classes/Request.d.ts @@ -23,12 +23,12 @@ export declare class Request extends VDXFObject { vdxfkey: string; challenge_id: string; requested_access: import("./Challenge").RequestedPermission[]; - requested_access_audience: import("./Challenge").RequestedPermission[]; + requested_access_audience: import("./Challenge").Audience[]; subject: import("./Challenge").Subject[]; provisioning_info: import("./Challenge").ProvisioningInfo[]; alt_auth_factors: import("./Challenge").AltAuthFactor[]; session_id: string; - attestations: import("./Challenge").Attestation[]; + attestations: import("./Attestation").Attestation[]; redirect_uris: { uri: string; vdxfkey: string; diff --git a/dist/vdxf/classes/Response.d.ts b/dist/vdxf/classes/Response.d.ts index c6f059f..e672aa7 100644 --- a/dist/vdxf/classes/Response.d.ts +++ b/dist/vdxf/classes/Response.d.ts @@ -41,12 +41,12 @@ export declare class Response extends VDXFObject { vdxfkey: string; challenge_id: string; requested_access: import("./Challenge").RequestedPermission[]; - requested_access_audience: import("./Challenge").RequestedPermission[]; + requested_access_audience: import("./Challenge").Audience[]; subject: import("./Challenge").Subject[]; provisioning_info: import("./Challenge").ProvisioningInfo[]; alt_auth_factors: import("./Challenge").AltAuthFactor[]; session_id: string; - attestations: import("./Challenge").Attestation[]; + attestations: import("./Attestation").Attestation[]; redirect_uris: { uri: string; vdxfkey: string; diff --git a/dist/vdxf/classes/SaltedData.d.ts b/dist/vdxf/classes/SaltedData.d.ts new file mode 100644 index 0000000..01bd8c5 --- /dev/null +++ b/dist/vdxf/classes/SaltedData.d.ts @@ -0,0 +1,17 @@ +/// +/// +import { VDXFData } from '../../'; +export declare class SaltedData extends VDXFData { + salt: Buffer; + static VERSION_INVALID: import("bn.js"); + static FIRST_VERSION: import("bn.js"); + static LAST_VERSION: import("bn.js"); + static DEFAULT_VERSION: import("bn.js"); + constructor(data?: Buffer, salt?: Buffer); + static fromJson(data: any): SaltedData; + getByteLength(): number; + toBuffer(): Buffer; + fromBuffer(buffer: Buffer, offset?: number): number; + toJson(): any; + getHash(hw: (data: Buffer) => Buffer): Buffer; +} diff --git a/dist/vdxf/classes/SaltedData.js b/dist/vdxf/classes/SaltedData.js new file mode 100644 index 0000000..7a2d015 --- /dev/null +++ b/dist/vdxf/classes/SaltedData.js @@ -0,0 +1,81 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.SaltedData = void 0; +const varint_1 = require("../../utils/varint"); +const varuint_1 = require("../../utils/varuint"); +const address_1 = require("../../utils/address"); +const bufferutils_1 = require("../../utils/bufferutils"); +const bn_js_1 = require("bn.js"); +const vdxf_1 = require("../../constants/vdxf"); +const __1 = require("../../"); +const { BufferReader, BufferWriter } = bufferutils_1.default; +const createHash = require("create-hash"); +const vdxfdatakeys_1 = require("../vdxfdatakeys"); +class SaltedData extends __1.VDXFData { + constructor(data, salt = Buffer.alloc(0)) { + super(data); + if (salt.length != 0) { + this.salt = salt; + } + this.vdxfkey = vdxfdatakeys_1.SaltedDataKey.vdxfid; + } + static fromJson(data) { + const saltedData = new SaltedData(); + if (data) { + if (data.version) { + saltedData.version = new bn_js_1.BN(data.version); + } + else { + saltedData.version = SaltedData.DEFAULT_VERSION; + } + if (data.salt) + saltedData.salt = Buffer.from(data.salt, 'hex'); + if (data.data) + saltedData.data = Buffer.from(data.data, 'hex'); + if (data.key) + saltedData.vdxfkey = data.key; + } + return saltedData; + } + getByteLength() { + let byteLength = 0; + byteLength += 20; //key + byteLength += varint_1.default.encodingLength(this.version); + byteLength += varuint_1.default.encodingLength(this.data.length + this.salt.length); + byteLength += this.data.length + this.salt.length; + return byteLength; + } + toBuffer() { + const bufferWriter = new BufferWriter(Buffer.alloc(this.getByteLength())); + bufferWriter.writeSlice((0, address_1.fromBase58Check)(this.vdxfkey).hash); + bufferWriter.writeVarInt(this.version); + bufferWriter.writeVarSlice(Buffer.concat([this.data, this.salt])); + return bufferWriter.buffer; + } + fromBuffer(buffer, offset = 0) { + const reader = new BufferReader(buffer, offset); + this.vdxfkey = (0, address_1.toBase58Check)(reader.readSlice(20), vdxf_1.I_ADDR_VERSION); + this.version = reader.readVarInt(); + this.data = reader.readVarSlice(); + this.salt = this.data.slice(this.data.length - 32); + this.data = this.data.slice(0, this.data.length - 32); + return reader.offset; + } + toJson() { + return { + version: this.version.toString(), + key: this.vdxfkey, + data: this.data.toString('hex'), + salt: this.salt.toString('hex') + }; + } + getHash(hw) { + const hash = hw(Buffer.concat([this.data, this.salt])); + return hash; + } +} +exports.SaltedData = SaltedData; +SaltedData.VERSION_INVALID = new bn_js_1.BN(0); +SaltedData.FIRST_VERSION = new bn_js_1.BN(1); +SaltedData.LAST_VERSION = new bn_js_1.BN(1); +SaltedData.DEFAULT_VERSION = new bn_js_1.BN(1); diff --git a/dist/vdxf/classes/index.d.ts b/dist/vdxf/classes/index.d.ts index 14025e0..f523463 100644 --- a/dist/vdxf/classes/index.d.ts +++ b/dist/vdxf/classes/index.d.ts @@ -21,6 +21,8 @@ export { ProvisioningResponseInterface as LoginConsentProvisioningResponseInterf export { ProvisioningDecisionInterface as LoginConsentProvisioningDecisionInterface } from "./provisioning/ProvisioningDecision"; export { ProvisioningResultInterface as LoginConsentProvisioningResultInterface } from "./provisioning/ProvisioningResult"; export { Hash160 } from './Hash160'; -export { RedirectUri, Subject, ProvisioningInfo, RequestedPermission, Audience, AltAuthFactor, Attestation, } from "./Challenge"; +export { RedirectUri, Subject, ProvisioningInfo, RequestedPermission, Audience, AltAuthFactor, } from "./Challenge"; +export { Attestation } from './Attestation'; export { ProvisioningTxid } from './provisioning/ProvisioningResult'; export { Context } from './Context'; +export { DataCategory } from './PersonalProfile'; diff --git a/dist/vdxf/classes/index.js b/dist/vdxf/classes/index.js index 2a9305b..39790ba 100644 --- a/dist/vdxf/classes/index.js +++ b/dist/vdxf/classes/index.js @@ -1,6 +1,6 @@ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); -exports.Context = exports.ProvisioningTxid = exports.Attestation = exports.AltAuthFactor = exports.Audience = exports.RequestedPermission = exports.ProvisioningInfo = exports.Subject = exports.RedirectUri = exports.Hash160 = exports.LoginConsentProvisioningResult = exports.LoginConsentProvisioningDecision = exports.LoginConsentProvisioningResponse = exports.LoginConsentProvisioningChallenge = exports.LoginConsentProvisioningRequest = exports.VerusPayInvoice = exports.VerusPayInvoiceDetails = exports.SignedSessionObjectData = exports.SignedSessionObject = exports.LoginConsentResponse = exports.LoginConsentRequest = exports.LoginConsentDecision = exports.LoginConsentChallenge = void 0; +exports.DataCategory = exports.Context = exports.ProvisioningTxid = exports.Attestation = exports.AltAuthFactor = exports.Audience = exports.RequestedPermission = exports.ProvisioningInfo = exports.Subject = exports.RedirectUri = exports.Hash160 = exports.LoginConsentProvisioningResult = exports.LoginConsentProvisioningDecision = exports.LoginConsentProvisioningResponse = exports.LoginConsentProvisioningChallenge = exports.LoginConsentProvisioningRequest = exports.VerusPayInvoice = exports.VerusPayInvoiceDetails = exports.SignedSessionObjectData = exports.SignedSessionObject = exports.LoginConsentResponse = exports.LoginConsentRequest = exports.LoginConsentDecision = exports.LoginConsentChallenge = void 0; var Challenge_1 = require("./Challenge"); Object.defineProperty(exports, "LoginConsentChallenge", { enumerable: true, get: function () { return Challenge_1.Challenge; } }); var Decision_1 = require("./Decision"); @@ -36,8 +36,11 @@ Object.defineProperty(exports, "ProvisioningInfo", { enumerable: true, get: func Object.defineProperty(exports, "RequestedPermission", { enumerable: true, get: function () { return Challenge_2.RequestedPermission; } }); Object.defineProperty(exports, "Audience", { enumerable: true, get: function () { return Challenge_2.Audience; } }); Object.defineProperty(exports, "AltAuthFactor", { enumerable: true, get: function () { return Challenge_2.AltAuthFactor; } }); -Object.defineProperty(exports, "Attestation", { enumerable: true, get: function () { return Challenge_2.Attestation; } }); +var Attestation_1 = require("./Attestation"); +Object.defineProperty(exports, "Attestation", { enumerable: true, get: function () { return Attestation_1.Attestation; } }); var ProvisioningResult_2 = require("./provisioning/ProvisioningResult"); Object.defineProperty(exports, "ProvisioningTxid", { enumerable: true, get: function () { return ProvisioningResult_2.ProvisioningTxid; } }); var Context_1 = require("./Context"); Object.defineProperty(exports, "Context", { enumerable: true, get: function () { return Context_1.Context; } }); +var PersonalProfile_1 = require("./PersonalProfile"); +Object.defineProperty(exports, "DataCategory", { enumerable: true, get: function () { return PersonalProfile_1.DataCategory; } }); diff --git a/dist/vdxf/identitydatakeys.d.ts b/dist/vdxf/identitydatakeys.d.ts new file mode 100644 index 0000000..7c9f451 --- /dev/null +++ b/dist/vdxf/identitydatakeys.d.ts @@ -0,0 +1,184 @@ +import { VDXFKeyInterface } from "./keys"; +export declare const IDENTITY_ACCOUNT_ID: VDXFKeyInterface; +export declare const IDENTITY_ACCOUNT_USERID: VDXFKeyInterface; +export declare const IDENTITY_ACCOUNT_CREATEDAT: VDXFKeyInterface; +export declare const IDENTITY_ACCOUNT_COMPLETEDAT: VDXFKeyInterface; +export declare const IDENTITY_ACCOUNT_PREVIOUSATTEMPTID: VDXFKeyInterface; +export declare const IDENTITY_ACCOUNT_SHAREABLEURL: VDXFKeyInterface; +export declare const IDENTITY_ACCOUNT_TEMPLATEID: VDXFKeyInterface; +export declare const IDENTITY_ACCOUNT_TEMPLATEVERSION: VDXFKeyInterface; +export declare const IDENTITY_ACCOUNT_STATUS: VDXFKeyInterface; +export declare const IDENTITY_PHONENUMBER: VDXFKeyInterface; +export declare const IDENTITY_DATEOFBIRTH: VDXFKeyInterface; +export declare const IDENTITY_OVER18: VDXFKeyInterface; +export declare const IDENTITY_OVER21: VDXFKeyInterface; +export declare const IDENTITY_OVER25: VDXFKeyInterface; +export declare const IDENTITY_ACCOUNT_REQUESTING_IPADDRESS: VDXFKeyInterface; +export declare const IDENTITY_EMAIL: VDXFKeyInterface; +export declare const IDENTITY_NATIONALITY: VDXFKeyInterface; +export declare const IDENTITY_FIRSTNAME: VDXFKeyInterface; +export declare const IDENTITY_MIDDLENAME: VDXFKeyInterface; +export declare const IDENTITY_LASTNAME: VDXFKeyInterface; +export declare const IDENTITY_GENDER: VDXFKeyInterface; +export declare const IDENTITY_HEIGHT: VDXFKeyInterface; +export declare const IDENTITY_EYECOLOR: VDXFKeyInterface; +export declare const IDENTITY_ETHNICITY: VDXFKeyInterface; +export declare const IDENTITY_WEIGHT: VDXFKeyInterface; +export declare const IDENTITY_HOMEADDRESS: VDXFKeyInterface; +export declare const IDENTITY_HOMEADDRESS_STREET1: VDXFKeyInterface; +export declare const IDENTITY_HOMEADDRESS_STREET2: VDXFKeyInterface; +export declare const IDENTITY_HOMEADDRESS_CITY: VDXFKeyInterface; +export declare const IDENTITY_HOMEADDRESS_REGION: VDXFKeyInterface; +export declare const IDENTITY_HOMEADDRESS_POSTCODE: VDXFKeyInterface; +export declare const IDENTITY_HOMEADDRESS_COUNTRY: VDXFKeyInterface; +export declare const IDENTITY_IDNUMBER_VALUE: VDXFKeyInterface; +export declare const IDENTITY_IDNUMBER_TYPE: VDXFKeyInterface; +export declare const IDENTITY_VERIFICATION_STATUS: VDXFKeyInterface; +export declare const IDENTITY_VERIFICATION_APPROVALS: VDXFKeyInterface; +export declare const IDENTITY_VERIFICATION_APPROVALS_ACCEPTEDTOS: VDXFKeyInterface; +export declare const IDENTITY_VERIFICATION_APPROVALS_VERIFIEDSMS: VDXFKeyInterface; +export declare const IDENTITY_VERIFICATION_APPROVALS_KYCCHECKED: VDXFKeyInterface; +export declare const IDENTITY_VERIFICATION_APPROVALS_DOCUMENTSVERIFIED: VDXFKeyInterface; +export declare const IDENTITY_VERIFICATION_APPROVALS_SELFIECHECKED: VDXFKeyInterface; +export declare const IDENTITY_VERIFICATION_APPROVALS_WATCHLISTOK: VDXFKeyInterface; +export declare const IDENTITY_VERIFICATION_APPROVALS_RISKCHECKOK: VDXFKeyInterface; +export declare const IDENTITY_VERIFICATION_APPROVALS_STATUS: VDXFKeyInterface; +export declare const IDENTITY_DRIVINGLICENCE: VDXFKeyInterface; +export declare const IDENTITY_DRIVINGLICENCE_ORIGINALFRONT: VDXFKeyInterface; +export declare const IDENTITY_DRIVINGLICENCE_ORIGINALBACK: VDXFKeyInterface; +export declare const IDENTITY_DRIVINGLICENCE_CROPPEDFRONT: VDXFKeyInterface; +export declare const IDENTITY_DRIVINGLICENCE_CROPPEDBACK: VDXFKeyInterface; +export declare const IDENTITY_DRIVINGLICENCE_FACE: VDXFKeyInterface; +export declare const IDENTITY_DRIVINGLICENCE_IDNUMBER: VDXFKeyInterface; +export declare const IDENTITY_DRIVINGLICENCE_CATEGORY: VDXFKeyInterface; +export declare const IDENTITY_DRIVINGLICENCE_EXPIRATIONDATE: VDXFKeyInterface; +export declare const IDENTITY_DRIVINGLICENCE_ISSUINGCOUNTRY: VDXFKeyInterface; +export declare const IDENTITY_DRIVINGLICENCE_ISSUINGREGION: VDXFKeyInterface; +export declare const IDENTITY_DRIVINGLICENCE_DATEOFBIRTH: VDXFKeyInterface; +export declare const IDENTITY_DRIVINGLICENCE_ADDRESS_STREET1: VDXFKeyInterface; +export declare const IDENTITY_DRIVINGLICENCE_ADDRESS_CITY: VDXFKeyInterface; +export declare const IDENTITY_DRIVINGLICENCE_ADDRESS_REGION: VDXFKeyInterface; +export declare const IDENTITY_DRIVINGLICENCE_ADDRESS_POSTCODE: VDXFKeyInterface; +export declare const IDENTITY_DRIVINGLICENCE_ADDRESS_COUNTRY: VDXFKeyInterface; +export declare const IDENTITY_SELFIECHECK_IMAGE: VDXFKeyInterface; +export declare const IDENTITY_SELFIECHECK_VIDEO: VDXFKeyInterface; +export declare const IDENTITY_EMAIL_ISDELIVERABLE: VDXFKeyInterface; +export declare const IDENTITY_EMAIL_BREACHCOUNT: VDXFKeyInterface; +export declare const IDENTITY_EMAIL_FIRSTBREACHEDAT: VDXFKeyInterface; +export declare const IDENTITY_EMAIL_LASTBREACHEDAT: VDXFKeyInterface; +export declare const IDENTITY_EMAIL_DOMAIN_REGISTEREDAT: VDXFKeyInterface; +export declare const IDENTITY_EMAIL_DOMAIN_FREEPROVIDER: VDXFKeyInterface; +export declare const IDENTITY_EMAIL_DOMAIN_CUSTOM: VDXFKeyInterface; +export declare const IDENTITY_EMAIL_DOMAIN_DISPOSABLE: VDXFKeyInterface; +export declare const IDENTITY_EMAIL_DOMAIN_TOPLEVEL_SUSPICIOUS: VDXFKeyInterface; +export declare const IDENTITY_PASSPORT: VDXFKeyInterface; +export declare const IDENTITY_PASSPORT_ORIGINALFRONT: VDXFKeyInterface; +export declare const IDENTITY_PASSPORT_ORIGINALBACK: VDXFKeyInterface; +export declare const IDENTITY_PASSPORT_CROPPEDFRONT: VDXFKeyInterface; +export declare const IDENTITY_PASSPORT_CROPPEDBACK: VDXFKeyInterface; +export declare const IDENTITY_PASSPORT_FACE: VDXFKeyInterface; +export declare const IDENTITY_PASSPORT_IDNUMBER: VDXFKeyInterface; +export declare const IDENTITY_PASSPORT_CATEGORY: VDXFKeyInterface; +export declare const IDENTITY_PASSPORT_EXPIRATIONDATE: VDXFKeyInterface; +export declare const IDENTITY_PASSPORT_ISSUINGCOUNTRY: VDXFKeyInterface; +export declare const IDENTITY_PASSPORT_ISSUINGREGION: VDXFKeyInterface; +export declare const IDENTITY_PASSPORT_DATEOFBIRTH: VDXFKeyInterface; +export declare const IDENTITY_PASSPORT_ADDRESS_STREET1: VDXFKeyInterface; +export declare const IDENTITY_PASSPORT_ADDRESS_CITY: VDXFKeyInterface; +export declare const IDENTITY_PASSPORT_ADDRESS_REGION: VDXFKeyInterface; +export declare const IDENTITY_PASSPORT_ADDRESS_POSTCODE: VDXFKeyInterface; +export declare const IDENTITY_PASSPORT_ADDRESS_COUNTRY: VDXFKeyInterface; +export declare const IDENTITY_RESIDENCEPERMIT: VDXFKeyInterface; +export declare const IDENTITY_RESIDENCEPERMIT_ORIGINALFRONT: VDXFKeyInterface; +export declare const IDENTITY_RESIDENCEPERMIT_ORIGINALBACK: VDXFKeyInterface; +export declare const IDENTITY_RESIDENCEPERMIT_CROPPEDFRONT: VDXFKeyInterface; +export declare const IDENTITY_RESIDENCEPERMIT_CROPPEDBACK: VDXFKeyInterface; +export declare const IDENTITY_RESIDENCEPERMIT_FACE: VDXFKeyInterface; +export declare const IDENTITY_RESIDENCEPERMIT_IDNUMBER: VDXFKeyInterface; +export declare const IDENTITY_RESIDENCEPERMIT_CATEGORY: VDXFKeyInterface; +export declare const IDENTITY_RESIDENCEPERMIT_EXPIRATIONDATE: VDXFKeyInterface; +export declare const IDENTITY_RESIDENCEPERMIT_ISSUINGCOUNTRY: VDXFKeyInterface; +export declare const IDENTITY_RESIDENCEPERMIT_ISSUINGREGION: VDXFKeyInterface; +export declare const IDENTITY_RESIDENCEPERMIT_DATEOFBIRTH: VDXFKeyInterface; +export declare const IDENTITY_RESIDENCEPERMIT_ADDRESS: VDXFKeyInterface; +export declare const IDENTITY_RESIDENCEPERMIT_ADDRESS_STREET1: VDXFKeyInterface; +export declare const IDENTITY_RESIDENCEPERMIT_ADDRESS_CITY: VDXFKeyInterface; +export declare const IDENTITY_RESIDENCEPERMIT_ADDRESS_REGION: VDXFKeyInterface; +export declare const IDENTITY_RESIDENCEPERMIT_ADDRESS_POSTCODE: VDXFKeyInterface; +export declare const IDENTITY_RESIDENCEPERMIT_ADDRESS_COUNTRY: VDXFKeyInterface; +export declare const IDENTITY_RESIDENTCARD: VDXFKeyInterface; +export declare const IDENTITY_RESIDENTCARD_ORIGINALFRONT: VDXFKeyInterface; +export declare const IDENTITY_RESIDENTCARD_ORIGINALBACK: VDXFKeyInterface; +export declare const IDENTITY_RESIDENTCARD_CROPPEDFRONT: VDXFKeyInterface; +export declare const IDENTITY_RESIDENTCARD_CROPPEDBACK: VDXFKeyInterface; +export declare const IDENTITY_RESIDENTCARD_FACE: VDXFKeyInterface; +export declare const IDENTITY_RESIDENTCARD_IDNUMBER: VDXFKeyInterface; +export declare const IDENTITY_RESIDENTCARD_CATEGORY: VDXFKeyInterface; +export declare const IDENTITY_RESIDENTCARD_EXPIRATIONDATE: VDXFKeyInterface; +export declare const IDENTITY_RESIDENTCARD_ISSUINGCOUNTRY: VDXFKeyInterface; +export declare const IDENTITY_RESIDENTCARD_ISSUINGREGION: VDXFKeyInterface; +export declare const IDENTITY_RESIDENTCARD_DATEOFBIRTH: VDXFKeyInterface; +export declare const IDENTITY_RESIDENTCARD_ADDRESS_STREET1: VDXFKeyInterface; +export declare const IDENTITY_RESIDENTCARD_ADDRESS_CITY: VDXFKeyInterface; +export declare const IDENTITY_RESIDENTCARD_ADDRESS_REGION: VDXFKeyInterface; +export declare const IDENTITY_RESIDENTCARD_ADDRESS_POSTCODE: VDXFKeyInterface; +export declare const IDENTITY_RESIDENTCARD_ADDRESS_COUNTRY: VDXFKeyInterface; +export declare const IDENTITY_IDCARD: VDXFKeyInterface; +export declare const IDENTITY_IDCARD_ORIGINALFRONT: VDXFKeyInterface; +export declare const IDENTITY_IDCARD_ORIGINALBACK: VDXFKeyInterface; +export declare const IDENTITY_IDCARD_CROPPEDFRONT: VDXFKeyInterface; +export declare const IDENTITY_IDCARD_CROPPEDBACK: VDXFKeyInterface; +export declare const IDENTITY_IDCARD_FACE: VDXFKeyInterface; +export declare const IDENTITY_IDCARD_IDNUMBER: VDXFKeyInterface; +export declare const IDENTITY_IDCARD_CATEGORY: VDXFKeyInterface; +export declare const IDENTITY_IDCARD_EXPIRATIONDATE: VDXFKeyInterface; +export declare const IDENTITY_IDCARD_ISSUINGCOUNTRY: VDXFKeyInterface; +export declare const IDENTITY_IDCARD_ISSUINGREGION: VDXFKeyInterface; +export declare const IDENTITY_IDCARD_DATEOFBIRTH: VDXFKeyInterface; +export declare const IDENTITY_IDCARD_ADDRESS_STREET1: VDXFKeyInterface; +export declare const IDENTITY_IDCARD_ADDRESS_CITY: VDXFKeyInterface; +export declare const IDENTITY_IDCARD_ADDRESS_REGION: VDXFKeyInterface; +export declare const IDENTITY_IDCARD_ADDRESS_POSTCODE: VDXFKeyInterface; +export declare const IDENTITY_IDCARD_ADDRESS_COUNTRY: VDXFKeyInterface; +export declare const IDENTITY_VISA: VDXFKeyInterface; +export declare const IDENTITY_VISA_ORIGINALFRONT: VDXFKeyInterface; +export declare const IDENTITY_VISA_ORIGINALBACK: VDXFKeyInterface; +export declare const IDENTITY_VISA_CROPPEDFRONT: VDXFKeyInterface; +export declare const IDENTITY_VISA_CROPPEDBACK: VDXFKeyInterface; +export declare const IDENTITY_VISA_FACE: VDXFKeyInterface; +export declare const IDENTITY_VISA_IDNUMBER: VDXFKeyInterface; +export declare const IDENTITY_VISA_CATEGORY: VDXFKeyInterface; +export declare const IDENTITY_VISA_EXPIRATIONDATE: VDXFKeyInterface; +export declare const IDENTITY_VISA_ISSUINGCOUNTRY: VDXFKeyInterface; +export declare const IDENTITY_VISA_ISSUINGREGION: VDXFKeyInterface; +export declare const IDENTITY_VISA_DATEOFBIRTH: VDXFKeyInterface; +export declare const IDENTITY_VISA_ADDRESS_STREET1: VDXFKeyInterface; +export declare const IDENTITY_VISA_ADDRESS_CITY: VDXFKeyInterface; +export declare const IDENTITY_VISA_ADDRESS_REGION: VDXFKeyInterface; +export declare const IDENTITY_VISA_ADDRESS_POSTCODE: VDXFKeyInterface; +export declare const IDENTITY_VISA_ADDRESS_COUNTRY: VDXFKeyInterface; +export declare const IDENTITY_PERSONALDETAILS: VDXFKeyInterface; +export declare const IDENTITY_CONTACTDETAILS: VDXFKeyInterface; +export declare const IDENTITY_LOCATION: VDXFKeyInterface; +export declare const IDENTITY_BANKINGDETAILS: VDXFKeyInterface; +export declare const IDENTITY_DOCUMENTS: VDXFKeyInterface; +export declare const IDENTITY_BANKACCOUNT: VDXFKeyInterface; +export declare const IDENTITY_BANKINGDETAILS_CURRENCY: VDXFKeyInterface; +export declare const IDENTITY_BANKINGDETAILS_COUNTRY: VDXFKeyInterface; +export declare const IDENTITY_BANKINGDETAILS_STREET1: VDXFKeyInterface; +export declare const IDENTITY_BANKINGDETAILS_STREET2: VDXFKeyInterface; +export declare const IDENTITY_BANKINGDETAILS_CITY: VDXFKeyInterface; +export declare const IDENTITY_BANKINGDETAILS_REGION: VDXFKeyInterface; +export declare const IDENTITY_BANKINGDETAILS_POSTALCODE: VDXFKeyInterface; +export declare const IDENTITY_BANKINGDETAILS_TAXNUMBER: VDXFKeyInterface; +export declare const IDENTITY_BANKINGDETAILS_TAXCOUNTRY: VDXFKeyInterface; +export declare const IDENTITY_BANKINGDETAILS_FIRSTNAME: VDXFKeyInterface; +export declare const IDENTITY_BANKINGDETAILS_LASTNAME: VDXFKeyInterface; +export declare const IDENTITY_BANKINGDETAILS_PHONENUMBER: VDXFKeyInterface; +export declare const IDENTITY_BANKINGDETAILS_NUMBER: VDXFKeyInterface; +export declare const IDENTITY_BANKINGDETAILS_TYPE: VDXFKeyInterface; +export declare const IDENTITY_BANKINGDETAILS_SORTCODE: VDXFKeyInterface; +export declare const IDENTITY_DOCUMENTS_PASSPORT: VDXFKeyInterface; +export declare const IDENTITY_RESIDENCECARD: VDXFKeyInterface; +export declare const IDENTITY_ATTESTOR: VDXFKeyInterface; +export declare const IDENTITY_ATTESTATION_RECIPIENT: VDXFKeyInterface; diff --git a/dist/vdxf/identitydatakeys.js b/dist/vdxf/identitydatakeys.js new file mode 100644 index 0000000..5039ee4 --- /dev/null +++ b/dist/vdxf/identitydatakeys.js @@ -0,0 +1,1653 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.IDENTITY_DRIVINGLICENCE_FACE = exports.IDENTITY_DRIVINGLICENCE_CROPPEDBACK = exports.IDENTITY_DRIVINGLICENCE_CROPPEDFRONT = exports.IDENTITY_DRIVINGLICENCE_ORIGINALBACK = exports.IDENTITY_DRIVINGLICENCE_ORIGINALFRONT = exports.IDENTITY_DRIVINGLICENCE = exports.IDENTITY_VERIFICATION_APPROVALS_STATUS = exports.IDENTITY_VERIFICATION_APPROVALS_RISKCHECKOK = exports.IDENTITY_VERIFICATION_APPROVALS_WATCHLISTOK = exports.IDENTITY_VERIFICATION_APPROVALS_SELFIECHECKED = exports.IDENTITY_VERIFICATION_APPROVALS_DOCUMENTSVERIFIED = exports.IDENTITY_VERIFICATION_APPROVALS_KYCCHECKED = exports.IDENTITY_VERIFICATION_APPROVALS_VERIFIEDSMS = exports.IDENTITY_VERIFICATION_APPROVALS_ACCEPTEDTOS = exports.IDENTITY_VERIFICATION_APPROVALS = exports.IDENTITY_VERIFICATION_STATUS = exports.IDENTITY_IDNUMBER_TYPE = exports.IDENTITY_IDNUMBER_VALUE = exports.IDENTITY_HOMEADDRESS_COUNTRY = exports.IDENTITY_HOMEADDRESS_POSTCODE = exports.IDENTITY_HOMEADDRESS_REGION = exports.IDENTITY_HOMEADDRESS_CITY = exports.IDENTITY_HOMEADDRESS_STREET2 = exports.IDENTITY_HOMEADDRESS_STREET1 = exports.IDENTITY_HOMEADDRESS = exports.IDENTITY_WEIGHT = exports.IDENTITY_ETHNICITY = exports.IDENTITY_EYECOLOR = exports.IDENTITY_HEIGHT = exports.IDENTITY_GENDER = exports.IDENTITY_LASTNAME = exports.IDENTITY_MIDDLENAME = exports.IDENTITY_FIRSTNAME = exports.IDENTITY_NATIONALITY = exports.IDENTITY_EMAIL = exports.IDENTITY_ACCOUNT_REQUESTING_IPADDRESS = exports.IDENTITY_OVER25 = exports.IDENTITY_OVER21 = exports.IDENTITY_OVER18 = exports.IDENTITY_DATEOFBIRTH = exports.IDENTITY_PHONENUMBER = exports.IDENTITY_ACCOUNT_STATUS = exports.IDENTITY_ACCOUNT_TEMPLATEVERSION = exports.IDENTITY_ACCOUNT_TEMPLATEID = exports.IDENTITY_ACCOUNT_SHAREABLEURL = exports.IDENTITY_ACCOUNT_PREVIOUSATTEMPTID = exports.IDENTITY_ACCOUNT_COMPLETEDAT = exports.IDENTITY_ACCOUNT_CREATEDAT = exports.IDENTITY_ACCOUNT_USERID = exports.IDENTITY_ACCOUNT_ID = void 0; +exports.IDENTITY_RESIDENCEPERMIT_ISSUINGREGION = exports.IDENTITY_RESIDENCEPERMIT_ISSUINGCOUNTRY = exports.IDENTITY_RESIDENCEPERMIT_EXPIRATIONDATE = exports.IDENTITY_RESIDENCEPERMIT_CATEGORY = exports.IDENTITY_RESIDENCEPERMIT_IDNUMBER = exports.IDENTITY_RESIDENCEPERMIT_FACE = exports.IDENTITY_RESIDENCEPERMIT_CROPPEDBACK = exports.IDENTITY_RESIDENCEPERMIT_CROPPEDFRONT = exports.IDENTITY_RESIDENCEPERMIT_ORIGINALBACK = exports.IDENTITY_RESIDENCEPERMIT_ORIGINALFRONT = exports.IDENTITY_RESIDENCEPERMIT = exports.IDENTITY_PASSPORT_ADDRESS_COUNTRY = exports.IDENTITY_PASSPORT_ADDRESS_POSTCODE = exports.IDENTITY_PASSPORT_ADDRESS_REGION = exports.IDENTITY_PASSPORT_ADDRESS_CITY = exports.IDENTITY_PASSPORT_ADDRESS_STREET1 = exports.IDENTITY_PASSPORT_DATEOFBIRTH = exports.IDENTITY_PASSPORT_ISSUINGREGION = exports.IDENTITY_PASSPORT_ISSUINGCOUNTRY = exports.IDENTITY_PASSPORT_EXPIRATIONDATE = exports.IDENTITY_PASSPORT_CATEGORY = exports.IDENTITY_PASSPORT_IDNUMBER = exports.IDENTITY_PASSPORT_FACE = exports.IDENTITY_PASSPORT_CROPPEDBACK = exports.IDENTITY_PASSPORT_CROPPEDFRONT = exports.IDENTITY_PASSPORT_ORIGINALBACK = exports.IDENTITY_PASSPORT_ORIGINALFRONT = exports.IDENTITY_PASSPORT = exports.IDENTITY_EMAIL_DOMAIN_TOPLEVEL_SUSPICIOUS = exports.IDENTITY_EMAIL_DOMAIN_DISPOSABLE = exports.IDENTITY_EMAIL_DOMAIN_CUSTOM = exports.IDENTITY_EMAIL_DOMAIN_FREEPROVIDER = exports.IDENTITY_EMAIL_DOMAIN_REGISTEREDAT = exports.IDENTITY_EMAIL_LASTBREACHEDAT = exports.IDENTITY_EMAIL_FIRSTBREACHEDAT = exports.IDENTITY_EMAIL_BREACHCOUNT = exports.IDENTITY_EMAIL_ISDELIVERABLE = exports.IDENTITY_SELFIECHECK_VIDEO = exports.IDENTITY_SELFIECHECK_IMAGE = exports.IDENTITY_DRIVINGLICENCE_ADDRESS_COUNTRY = exports.IDENTITY_DRIVINGLICENCE_ADDRESS_POSTCODE = exports.IDENTITY_DRIVINGLICENCE_ADDRESS_REGION = exports.IDENTITY_DRIVINGLICENCE_ADDRESS_CITY = exports.IDENTITY_DRIVINGLICENCE_ADDRESS_STREET1 = exports.IDENTITY_DRIVINGLICENCE_DATEOFBIRTH = exports.IDENTITY_DRIVINGLICENCE_ISSUINGREGION = exports.IDENTITY_DRIVINGLICENCE_ISSUINGCOUNTRY = exports.IDENTITY_DRIVINGLICENCE_EXPIRATIONDATE = exports.IDENTITY_DRIVINGLICENCE_CATEGORY = exports.IDENTITY_DRIVINGLICENCE_IDNUMBER = void 0; +exports.IDENTITY_VISA_EXPIRATIONDATE = exports.IDENTITY_VISA_CATEGORY = exports.IDENTITY_VISA_IDNUMBER = exports.IDENTITY_VISA_FACE = exports.IDENTITY_VISA_CROPPEDBACK = exports.IDENTITY_VISA_CROPPEDFRONT = exports.IDENTITY_VISA_ORIGINALBACK = exports.IDENTITY_VISA_ORIGINALFRONT = exports.IDENTITY_VISA = exports.IDENTITY_IDCARD_ADDRESS_COUNTRY = exports.IDENTITY_IDCARD_ADDRESS_POSTCODE = exports.IDENTITY_IDCARD_ADDRESS_REGION = exports.IDENTITY_IDCARD_ADDRESS_CITY = exports.IDENTITY_IDCARD_ADDRESS_STREET1 = exports.IDENTITY_IDCARD_DATEOFBIRTH = exports.IDENTITY_IDCARD_ISSUINGREGION = exports.IDENTITY_IDCARD_ISSUINGCOUNTRY = exports.IDENTITY_IDCARD_EXPIRATIONDATE = exports.IDENTITY_IDCARD_CATEGORY = exports.IDENTITY_IDCARD_IDNUMBER = exports.IDENTITY_IDCARD_FACE = exports.IDENTITY_IDCARD_CROPPEDBACK = exports.IDENTITY_IDCARD_CROPPEDFRONT = exports.IDENTITY_IDCARD_ORIGINALBACK = exports.IDENTITY_IDCARD_ORIGINALFRONT = exports.IDENTITY_IDCARD = exports.IDENTITY_RESIDENTCARD_ADDRESS_COUNTRY = exports.IDENTITY_RESIDENTCARD_ADDRESS_POSTCODE = exports.IDENTITY_RESIDENTCARD_ADDRESS_REGION = exports.IDENTITY_RESIDENTCARD_ADDRESS_CITY = exports.IDENTITY_RESIDENTCARD_ADDRESS_STREET1 = exports.IDENTITY_RESIDENTCARD_DATEOFBIRTH = exports.IDENTITY_RESIDENTCARD_ISSUINGREGION = exports.IDENTITY_RESIDENTCARD_ISSUINGCOUNTRY = exports.IDENTITY_RESIDENTCARD_EXPIRATIONDATE = exports.IDENTITY_RESIDENTCARD_CATEGORY = exports.IDENTITY_RESIDENTCARD_IDNUMBER = exports.IDENTITY_RESIDENTCARD_FACE = exports.IDENTITY_RESIDENTCARD_CROPPEDBACK = exports.IDENTITY_RESIDENTCARD_CROPPEDFRONT = exports.IDENTITY_RESIDENTCARD_ORIGINALBACK = exports.IDENTITY_RESIDENTCARD_ORIGINALFRONT = exports.IDENTITY_RESIDENTCARD = exports.IDENTITY_RESIDENCEPERMIT_ADDRESS_COUNTRY = exports.IDENTITY_RESIDENCEPERMIT_ADDRESS_POSTCODE = exports.IDENTITY_RESIDENCEPERMIT_ADDRESS_REGION = exports.IDENTITY_RESIDENCEPERMIT_ADDRESS_CITY = exports.IDENTITY_RESIDENCEPERMIT_ADDRESS_STREET1 = exports.IDENTITY_RESIDENCEPERMIT_ADDRESS = exports.IDENTITY_RESIDENCEPERMIT_DATEOFBIRTH = void 0; +exports.IDENTITY_ATTESTATION_RECIPIENT = exports.IDENTITY_ATTESTOR = exports.IDENTITY_RESIDENCECARD = exports.IDENTITY_DOCUMENTS_PASSPORT = exports.IDENTITY_BANKINGDETAILS_SORTCODE = exports.IDENTITY_BANKINGDETAILS_TYPE = exports.IDENTITY_BANKINGDETAILS_NUMBER = exports.IDENTITY_BANKINGDETAILS_PHONENUMBER = exports.IDENTITY_BANKINGDETAILS_LASTNAME = exports.IDENTITY_BANKINGDETAILS_FIRSTNAME = exports.IDENTITY_BANKINGDETAILS_TAXCOUNTRY = exports.IDENTITY_BANKINGDETAILS_TAXNUMBER = exports.IDENTITY_BANKINGDETAILS_POSTALCODE = exports.IDENTITY_BANKINGDETAILS_REGION = exports.IDENTITY_BANKINGDETAILS_CITY = exports.IDENTITY_BANKINGDETAILS_STREET2 = exports.IDENTITY_BANKINGDETAILS_STREET1 = exports.IDENTITY_BANKINGDETAILS_COUNTRY = exports.IDENTITY_BANKINGDETAILS_CURRENCY = exports.IDENTITY_BANKACCOUNT = exports.IDENTITY_DOCUMENTS = exports.IDENTITY_BANKINGDETAILS = exports.IDENTITY_LOCATION = exports.IDENTITY_CONTACTDETAILS = exports.IDENTITY_PERSONALDETAILS = exports.IDENTITY_VISA_ADDRESS_COUNTRY = exports.IDENTITY_VISA_ADDRESS_POSTCODE = exports.IDENTITY_VISA_ADDRESS_REGION = exports.IDENTITY_VISA_ADDRESS_CITY = exports.IDENTITY_VISA_ADDRESS_STREET1 = exports.IDENTITY_VISA_DATEOFBIRTH = exports.IDENTITY_VISA_ISSUINGREGION = exports.IDENTITY_VISA_ISSUINGCOUNTRY = void 0; +exports.IDENTITY_ACCOUNT_ID = { + "vdxfid": "i5Xgd7Aqds922eE8FDBUsKHSgiig39AnfS", + "indexid": "xAMo5ubvVBMgep7A6tqdqhoyiNjgq3j1ci", + "hash160result": "4c5e79bf46593fe959cb1918422eaa8fc82b8916", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::identity.account.id" + } +}; +exports.IDENTITY_ACCOUNT_USERID = { + "vdxfid": "iNKVUvr5GzdCHgybMauK11DdZZUyWE3pe3", + "indexid": "xT9bwjHA8JqrurrdDGZTyPkAbDVzR53C2o", + "hash160result": "93b62bfd8c861ac7a5aa3d3d9f618ccd8c04b5ce", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::identity.account.userid" + } +}; +exports.IDENTITY_ACCOUNT_CREATEDAT = { + "vdxfid": "i42uTbJmVBcPacY3Ak1g95LBg5rBBntQby", + "indexid": "x8s1vPjrLVq4CnR52Rfq7TrihjsBzxAEic", + "hash160result": "c40b12b14582c976e67a2e5992b0fdf67fb21f06", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::identity.account.createdat" + } +}; +exports.IDENTITY_ACCOUNT_COMPLETEDAT = { + "vdxfid": "iRJTZj7osY5EYA7pd7K3UcJVAApkvodDjZ", + "indexid": "xW8a2XYtirHuAKzrUnyCSzq2BpqmpCnnHQ", + "hash160result": "c568b6e1f734f5dc9b754e5932ebdb63f2606bef", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::identity.account.completedat" + } +}; +exports.IDENTITY_ACCOUNT_PREVIOUSATTEMPTID = { + "vdxfid": "iGU6RCWyjU1sscCPLN77XhTESJ21JCTNxF", + "indexid": "xMJCszx4anEYVn5RC3mGW5ymTx32EBfaqs", + "hash160result": "50c2b12bb483802d14beae3c6b7454c6ecc0848e", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::identity.account.previousattemptid" + } +}; +exports.IDENTITY_ACCOUNT_SHAREABLEURL = { + "vdxfid": "i92YkV3FVGZfp5Ep3j1sfQUgqUS37M9v82", + "indexid": "xDrfDHULLanLSF7quQg2do1Ds8T3yGCRw3", + "hash160result": "52e9f990e5e89cc1088acd29a2fda0ef140ae73c", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::identity.account.shareableurl" + } +}; +exports.IDENTITY_ACCOUNT_TEMPLATEID = { + "vdxfid": "iL5diuVsHAG5DLVeyc8XYdEXR6fFro5G7s", + "indexid": "xQukBhvx8UUjqWNgqHngX1m4SkgGhnybh1", + "hash160result": "37ef653fe6685fca132d77834384702f6cd225b6", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::identity.account.templateid" + } +}; +exports.IDENTITY_ACCOUNT_TEMPLATEVERSION = { + "vdxfid": "i7eBZNzKrgFov6c2Sx2QecyEmPq2Mc4BGe", + "indexid": "xCUJ2BRQhzUUYGV4JdgZd1Vmo3r39BsUym", + "hash160result": "e6e490ce8bfde333ab0374880ea0efbb9c12b42d", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::identity.account.templateversion" + } +}; +exports.IDENTITY_ACCOUNT_STATUS = { + "vdxfid": "iJf3EbihEtdEpJjbQ6PgUaL3GxDgZRzSWk", + "indexid": "xPV9hQ9n6CquSUcdFn3qSxraJcEhVfWa72", + "hash160result": "d6fc5578c2fbed3251f3aa250c73b58386ec86a6", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::identity.account.status" + } +}; +exports.IDENTITY_PHONENUMBER = { + "vdxfid": "iAQY8o4HwupzcJAw9aBtFwgrvWZGQStkge", + "indexid": "xFEebbVNoE3fEU3y1Fr3ELDPxAaHE7V2kN", + "hash160result": "32bc2c7919f626c39679630ee4d6d6d07bcd074c", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::identity.phonenumber" + } +}; +exports.IDENTITY_DATEOFBIRTH = { + "vdxfid": "iSZsa7C4esogN3W6fBngUHR6GvSmt7We4j", + "indexid": "xXPz2ud9WC2LzDP8WsSqSfwdJaTnqpHdND", + "hash160result": "ab74371e952a27f615b079d3c084b38b98c84dfd", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::identity.dateofbirth" + } +}; +exports.IDENTITY_OVER18 = { + "vdxfid": "iHPD8vB7jhtbuqPkUqzheqcZdfAfHUFVzM", + "indexid": "xNDKbicCb27GY1GnLXerdE96fKBg9tLUDT", + "hash160result": "28139ce1eae370e76f749066f778466597689098", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::identity.over18" + } +}; +exports.IDENTITY_OVER21 = { + "vdxfid": "iAXYYrZaipc4DAmAKXUFYZxavsf6uBJqaj", + "indexid": "xFMf1ezfa8piqLeCBD8QWxV7xXg7mxMc1Z", + "hash160result": "7a1fee70ace1c048c0a93c120a8a4c5f890f5b4d", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::identity.over21" + } +}; +exports.IDENTITY_OVER25 = { + "vdxfid": "iDuForPTZFeFBAgDX1HyrP3d6of7wzrRaS", + "indexid": "xJjNGepYQZruoLZFNgx8pmaA8Tg8qSfnzM", + "hash160result": "2a1e6fa6913ea3659dcaf1c5bc20a96e399d5e72", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::identity.over25" + } +}; +exports.IDENTITY_ACCOUNT_REQUESTING_IPADDRESS = { + "vdxfid": "i4uE1EvnDbq9WGhF5UbBr6fbxNLsgk1eZ3", + "indexid": "x9jLU3Ms4v3p8SaGwAFLpVC8z2MtYJTVwp", + "hash160result": "05a3aa58192812972a2c4e4184af7bb5fbf9a30f", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::identity.account.requesting.ipaddress" + } +}; +exports.IDENTITY_EMAIL = { + "vdxfid": "iJ4pq4DCymfbu8SAuXyNhasLeSHFNKPr23", + "indexid": "xNtwHreHq5tGXJKCmDdXfyPsg6JGHUY6X1", + "hash160result": "15a8095b6298bbff5147060d9a6363a9df6c0ea0", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::identity.email" + } +}; +exports.IDENTITY_NATIONALITY = { + "vdxfid": "iEUYNTkw6kFhZWto7vyTpQqtdRL7eoKZY2", + "indexid": "xKJeqGC1x4UNBgmpycdcnoNRf5M8btexbt", + "hash160result": "db935713b90281d6aefe5e7b33e5b660962aaa78", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::identity.nationality" + } +}; +exports.IDENTITY_FIRSTNAME = { + "vdxfid": "iLB8SG7ErJtTYcG1f4w9RLuMJPpAsjFkiL", + "indexid": "xR1Eu4YKhd78An93WkbJPjRtL3qBprmMno", + "hash160result": "0bab76359b70b37c858399c2a3776939c5de2fb7", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::identity.firstname" + } +}; +exports.IDENTITY_MIDDLENAME = { + "vdxfid": "iHG6ALRUPyRcgJMsPqBmvUCZxe4PrMfgej", + "indexid": "xN6Cd8rZFHeHJUEuFWqvtrj6zJ5QjX94j5", + "hash160result": "b98bd82034ec86ae5538313c9f5501c086ac3797", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::identity.middlename" + } +}; +exports.IDENTITY_LASTNAME = { + "vdxfid": "iKRmfy4xgjWQyPdXYie6dJezRXF4aKdbHB", + "indexid": "xQFt8mW3Y3j5bZWZQQJFbhBXTBG5S4vdaZ", + "hash160result": "6b597e0c05d1430566b7b17a59da683fb4a6fcae", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::identity.lastname" + } +}; +exports.IDENTITY_GENDER = { + "vdxfid": "iShgSBdiYDQnVwgNcDnSbNYHGU6CTwBDb1", + "indexid": "xXXntz4oPXdT87ZQTuSbZm4pJ87DGEgHpG", + "hash160result": "3baee594e927d47b641c7cf3927ab3229dd0c7fe", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::identity.gender" + } +}; +exports.IDENTITY_HEIGHT = { + "vdxfid": "iLmLmsFMTUm4dd2iMuMe4xaMC8VSZN9soP", + "indexid": "xRbTEfgSJnyjFnukDb1o3M6tDnWTSUiii7", + "hash160result": "e80652253fa52b95cd9ea5ff43d51642ea4fa8bd", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::identity.height" + } +}; +exports.IDENTITY_EYECOLOR = { + "vdxfid": "iRo2XT8tcMtLTpuPJ6V5WxbnVWa2CrcdsJ", + "indexid": "xWd8zFZyTg715znR9n9EVM8KXAb328xGbZ", + "hash160result": "c60fdfcc04173f273aa92a3b1844964b368ad2f4", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::identity.eyecolor" + } +}; +exports.IDENTITY_ETHNICITY = { + "vdxfid": "i9jHPJokwnLoCQ83P6jqezCcEZUD1g34B9", + "indexid": "xEZPr7Eqo6ZTpa15EnPzdNj9GDVDsfToki", + "hash160result": "0476d568a9cf949bc8b6d84dc73e38cf85449b44", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::identity.ethnicity" + } +}; +exports.IDENTITY_WEIGHT = { + "vdxfid": "iMzGK44r6SNkzi3N3AmcZBtuysPvgYiRiT", + "indexid": "xSpNmrVvwkbRcsvPtrRmXaRT1XQwXFe2Ut", + "hash160result": "8abe0e94cb1ff345f1351720acc8eefed91e12cb", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::identity.weight" + } +}; +exports.IDENTITY_HOMEADDRESS = { + "vdxfid": "i9A1fD5sVwFFXzEmCJWSRDqN94PXp9oNaS", + "indexid": "xDz881WxMFTvAA7o3zAbPcMuAiQYiT4Vnc", + "hash160result": "072a3abed3a353e001288074d9426285e569503e", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::identity.homeaddress" + } +}; +exports.IDENTITY_HOMEADDRESS_STREET1 = { + "vdxfid": "i5BJAwQbrP4Bht8gUpoqSrovuBwfRc6jiv", + "indexid": "xA1QdjqghhGrL41iLWTzRFLTvqxgNsVzXY", + "hash160result": "ff22b196e64c9388daab76a57bcaea50491cae12", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::identity.homeaddress.street1" + } +}; +exports.IDENTITY_HOMEADDRESS_STREET2 = { + "vdxfid": "iMx71C14hrBoWD3yyhYChmhJEw4Kqw1zj4", + "indexid": "xSnDTzS9ZAQU8Nw1qPCMgADqGb5Lgqb4zw", + "hash160result": "efdda473a6a9e98cd91b02d36bfeb5dec784a9ca", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::identity.homeaddress.street2" + } +}; +exports.IDENTITY_HOMEADDRESS_CITY = { + "vdxfid": "i75ZpW5T6wgQEMVxyvqHT9ZaV4fjsQ7kws", + "indexid": "xBugHJWXxFu4rXNzqcVSRY67WigkoCUEUQ", + "hash160result": "fcae40d5d327f13dc0e0c1e80f3db212a4ed8827", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::identity.homeaddress.city" + } +}; +exports.IDENTITY_HOMEADDRESS_REGION = { + "vdxfid": "iRkYck3JowdFWmrM6VUAS8Wtpmxds2fLXS", + "indexid": "xWaf5YUPfFqv8wjNxB8KQX3RrRyenbioh5", + "hash160result": "fa06b90a547658a3efc3cd1797d6b3cd30695af4", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::identity.homeaddress.region" + } +}; +exports.IDENTITY_HOMEADDRESS_POSTCODE = { + "vdxfid": "iAL2FRG8PVi18fN8MatjXhV1YkuZr7PM4T", + "indexid": "xFA8iDhDEovfkqFADGYtW61YaQvahtrhJA", + "hash160result": "b4f4c3a08fdcf32209482fa3d8c7b01201312d4b", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::identity.homeaddress.postcode" + } +}; +exports.IDENTITY_HOMEADDRESS_COUNTRY = { + "vdxfid": "iABYGvas6uUDk9ejCkfCVLvE9PPJXgyCKX", + "indexid": "xF1ejj1wxDgtNKXm4SKMTjSmB3QKL8LhQG", + "hash160result": "bafb2cb6d5cc86478622feb8a00097d71d839249", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::identity.homeaddress.country" + } +}; +exports.IDENTITY_IDNUMBER_VALUE = { + "vdxfid": "iQrnvbCNWMaG6PjTmeXzrcuAXKsMzmNJWA", + "indexid": "xVguPPdTMfnviZcVdLC9q1RhYytNuZ3ToS", + "hash160result": "72cf52b2f6b4f68173c933fb046e892870b990ea", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::identity.idnumber.value" + } +}; +exports.IDENTITY_IDNUMBER_TYPE = { + "vdxfid": "iSSZX5yUdQh7zLf1gUewH5rVfbXtSq2c4s", + "indexid": "xXGfytQZUiuncWY3YAK6FUP2hFYuQ4yYwW", + "hash160result": "2807f356d687b4c6208ce0379b31043c7fcdebfb", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::identity.idnumber.type" + } +}; +exports.IDENTITY_VERIFICATION_STATUS = { + "vdxfid": "i8MhqW3ejupmV1M5UyhyhG13dkS8A7g7zg", + "indexid": "xDBpJJUjbE3S7BE7LfN8feXafQT92YQZPm", + "hash160result": "47f2864de74ffe01ccb7eeabf0f2d848e3668e35", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::identity.verification.status" + } +}; +exports.IDENTITY_VERIFICATION_APPROVALS = { + "vdxfid": "iBMkZtqC9yqVrFL4GfYtXckFpYAhRkE2mj", + "indexid": "xGBs2hGH1J4AURD68MD3W1GnrCBiJ3nRgG", + "hash160result": "a98801de1ba5ff5e571dbdde50519483140f7956", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::identity.verification.approvals" + } +}; +exports.IDENTITY_VERIFICATION_APPROVALS_ACCEPTEDTOS = { + "vdxfid": "iH32QkXBKyWEJD6kh9HJ4KMfeiWfPWoHEh", + "indexid": "xMs8sYxGBHitvNynYpwT2htCgNXgHt6VAW", + "hash160result": "bbe4c09ae069561d3c14b04e3b7b96c98622bf94", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::identity.verification.approvals.acceptedtos" + } +}; +exports.IDENTITY_VERIFICATION_APPROVALS_VERIFIEDSMS = { + "vdxfid": "iPgyMDFQ9QMNrqc3ckEBEubDNwLnvubUdW", + "indexid": "xUX5p1gUzia3V1V5URtLDJ7kQbMosPsVj8", + "hash160result": "72853b66aa158531e1f15b9ff075199a1224bddd", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::identity.verification.approvals.verifiedsms" + } +}; +exports.IDENTITY_VERIFICATION_APPROVALS_KYCCHECKED = { + "vdxfid": "iRnbiA4dAPbeuB6KQN2donBHP9mKUHHFZf", + "indexid": "xWciAxVi1hpKXLyMG3gnnAhpQonLQapWPv", + "hash160result": "c6114ffec250b746bde117903b930d9a34d3bdf4", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::identity.verification.approvals.kycchecked" + } +}; +exports.IDENTITY_VERIFICATION_APPROVALS_DOCUMENTSVERIFIED = { + "vdxfid": "iBjML9DHV67MBQyMEHVTSoJPhU8DNeWRTE", + "indexid": "xGZTnweNLQL1oarP5y9cRBpvj89EGt5VSm", + "hash160result": "0a93883010769ff783be5ced074ecfa50dd08e5a", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::identity.verification.approvals.documentsverified" + } +}; +exports.IDENTITY_VERIFICATION_APPROVALS_SELFIECHECKED = { + "vdxfid": "iKgeFKoy6WMx9MoEjig5vHoXbyxVFBPWDN", + "indexid": "xQWki8F3wpacmXgGbQLEtgL4ddyWC8UZLv", + "hash160result": "6a044306ef77ce9896ffcd26ee40174651b1ccb1", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::identity.verification.approvals.selfiechecked" + } +}; +exports.IDENTITY_VERIFICATION_APPROVALS_WATCHLISTOK = { + "vdxfid": "iFDB1qKYSrWMRaMCWX6hNGE8HVXB1cNtJu", + "indexid": "xL3HUdkdJAj23kEENCkrLekfK9YBymnLrX", + "hash160result": "e691a2d2af30df6ee21f0eb805a98e11d539ba80", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::identity.verification.approvals.watchlistok" + } +}; +exports.IDENTITY_VERIFICATION_APPROVALS_RISKCHECKOK = { + "vdxfid": "i9dva492S7vQphjLiK2UaS7JikZKs5TQsB", + "indexid": "xEU32ra7HS95SscNZzgdYpdqkQaLjnzcyC", + "hash160result": "6ffdbee07124450d29698724573bd6ab07d09743", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::identity.verification.approvals.riskcheckok" + } +}; +exports.IDENTITY_VERIFICATION_APPROVALS_STATUS = { + "vdxfid": "iKhGUcTH4ZQ7uiy933m8f1GbwSLcwJW8ev", + "indexid": "xQXNwQtMuscnXtrAtjRHdPo8y6MdomjAXM", + "hash160result": "00612f17d9cedc346fcd139c0c5b56e666efeab1", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::identity.verification.approvals.status" + } +}; +exports.IDENTITY_DRIVINGLICENCE = { + "vdxfid": "iMYQw33ryywcNyQDjFjiVvFm2kAwG85poV", + "indexid": "xSNXPqUwqJAH19HFawPsUJnJ4QBxCATPNx", + "hash160result": "e2857ddcc4f3301c354a00d1376558a75e802ec6", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::identity.drivinglicence" + } +}; +exports.IDENTITY_DRIVINGLICENCE_ORIGINALFRONT = { + "vdxfid": "i3fq6ET2dL8CxC3BJzdYTpUsjEsQaKP7bX", + "indexid": "x8VwZ2t7UeLsaMvDAgHhSD1QkttRPYndPW", + "hash160result": "26bab54e1f760b1abb888229a38a5179cc502302", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::identity.drivinglicence.originalfront" + } +}; +exports.IDENTITY_DRIVINGLICENCE_ORIGINALBACK = { + "vdxfid": "i7LTNZvJmm5LjAwMWuryb52yKt7txaV5FW", + "indexid": "xCAZqNMPd5J1MLpPNbX8ZTZWMY8unxdAfs", + "hash160result": "c7b3e9a70908fafc8de3e81f6ac2e0c131c9592a", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::identity.drivinglicence.originalback" + } +}; +exports.IDENTITY_DRIVINGLICENCE_CROPPEDFRONT = { + "vdxfid": "i8KsL3JJgbJyuqEyEbu5KZkDBFvHscLoM6", + "indexid": "xD9ynqjPXuXeY1816HZEHxGkCuwJoHBx54", + "hash160result": "7b28226a4f3eaae379cddbc84d037cfe587e3535", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::identity.drivinglicence.croppedfront" + } +}; +exports.IDENTITY_DRIVINGLICENCE_CROPPEDBACK = { + "vdxfid": "iRwumhx12vtT8CkspBLmKQY8WZywurxVXo", + "indexid": "xWn2EWP5tF77kNdufrzvHo4fYDzxhjXyZz", + "hash160result": "0b6edf21bfe119173b3fffab6118d79a39a580f6", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::identity.drivinglicence.croppedback" + } +}; +exports.IDENTITY_DRIVINGLICENCE_FACE = { + "vdxfid": "i5i7U4EAbgPzhCRebtbmoZt6pTyqGqP8jj", + "indexid": "xAYDvrfFSzcfKNJgTaFvmxQdr7zr6oGgFh", + "hash160result": "1f47647bf3e71f0c1c2638c99e6a42e6bf118218", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::identity.drivinglicence.face" + } +}; +exports.IDENTITY_DRIVINGLICENCE_IDNUMBER = { + "vdxfid": "iBCA8b4zS5ygVgTFqxabke7BBFs92dhcXQ", + "indexid": "xG2GbPW5HQCM7rLHheEkj2diCut9vgFhM2", + "hash160result": "fcf0571278bd1afce6d93f0a99f41437bb91a854", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::identity.drivinglicence.idnumber" + } +}; +exports.IDENTITY_DRIVINGLICENCE_CATEGORY = { + "vdxfid": "i5Cm95DZa6FPP66bA6aFfoYL2jaojetHMp", + "indexid": "xA2sbseeRQU41Fyd1nEQeC4s4Pbpf63xB4", + "hash160result": "3b91fccdf59d99b21e442441b89abb31bf09f512", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::identity.drivinglicence.category" + } +}; +exports.IDENTITY_DRIVINGLICENCE_EXPIRATIONDATE = { + "vdxfid": "iJvGpPoP1uUkUqn9bAchLyfaGWyy8JGQoX", + "indexid": "xPkPHCETsDhR71fBSrGrKNC7JAzz17RsLk", + "hash160result": "96aee63b3c6094a4d9edbc04b63a8e45688068a9", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::identity.drivinglicence.expirationdate" + } +}; +exports.IDENTITY_DRIVINGLICENCE_ISSUINGCOUNTRY = { + "vdxfid": "iBsNEqysX64cQAjiRHHL1msd7LxroGM6Mb", + "indexid": "xGhUheQxNQHH2LckGxwUzAQA8zysfnKDSU", + "hash160result": "f2f24dd2383538493d21ff0aca77c7cd1fe6125c", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::identity.drivinglicence.issuingcountry" + } +}; +exports.IDENTITY_DRIVINGLICENCE_ISSUINGREGION = { + "vdxfid": "i6gZSDYpK9inexaeFQDSk9GuAmew1ymMFo", + "indexid": "xBWfu1yuATwTH8Tg75sbiXoSCRfwsxQzeR", + "hash160result": "67f4fd5c49250912aecf1eb8ab17f29d590a2f23", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::identity.drivinglicence.issuingregion" + } +}; +exports.IDENTITY_DRIVINGLICENCE_DATEOFBIRTH = { + "vdxfid": "iChWUsL1NQwDqcwXbFGxHiCegfquGPyadv", + "indexid": "xHXcwfm6Dj9tTnpZSvw7G6jBiKrvBUhwaw", + "hash160result": "3c7bd13bcdb54368e7590a9f2da5b201b7be2d65", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::identity.drivinglicence.dateofbirth" + } +}; +exports.IDENTITY_DRIVINGLICENCE_ADDRESS_STREET1 = { + "vdxfid": "i9xaEvSQ537wuYgcVPRgG3zop9bVzeDTBw", + "indexid": "xEnghisUvMLcXiZeM55qESXLqocWsv6zmJ", + "hash160result": "48dd1caf84c1a49209ca44064846dc4ad0be1e47", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::identity.drivinglicence.address.street1" + } +}; +exports.IDENTITY_DRIVINGLICENCE_ADDRESS_CITY = { + "vdxfid": "i6XMEh3jrxzdyoVYoNWhRSncR9oWSnmikd", + "indexid": "xBMThVUpiHDJbyNaf4ArPqK9SopXGndEyv", + "hash160result": "c1f3612774870d1f12320bff317e7790211d7121", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::identity.drivinglicence.address.city" + } +}; +exports.IDENTITY_DRIVINGLICENCE_ADDRESS_REGION = { + "vdxfid": "i7sPBSqerD23RAqfN167aYePjfC8LL34UA", + "indexid": "xChVeFGjhXEi3LihDgkGYwAvmKD9CsNunu", + "hash160result": "991d24c053cb59a816e161fe3af2f40a7f2e3330", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::identity.drivinglicence.address.region" + } +}; +exports.IDENTITY_DRIVINGLICENCE_ADDRESS_POSTCODE = { + "vdxfid": "i9eHAmpeA3tmpsVeG5EkHuVfALFrmpzLqM", + "indexid": "xEUPdaFj1N7ST3Ng7ktuGJ2CBzGsZbja5V", + "hash160result": "f5905bbdf2eb60b24ccf6851716cc0efe801a943", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::identity.drivinglicence.address.postcode" + } +}; +exports.IDENTITY_DRIVINGLICENCE_ADDRESS_COUNTRY = { + "vdxfid": "i3xAMYBKLVdK89kuheXhTjuJTAxozmypj3", + "indexid": "x8nGpLcQBoqykKdwZLBrS8RqUpypqVUEV5", + "hash160result": "459844e00df4387514f31f182a88f7e13b0d3a05", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::identity.drivinglicence.address.country" + } +}; +exports.IDENTITY_SELFIECHECK_IMAGE = { + "vdxfid": "iC22PxGqY7Mx3YT9kNrW1d11JNyGL56N8e", + "indexid": "xGr8rkhvPRacfiLBc4Wez1XYL2zHDDbJgD", + "hash160result": "c52d0023cce8c847a5097b6898f867651914b65d", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::identity.selfiecheck.image" + } +}; +exports.IDENTITY_SELFIECHECK_VIDEO = { + "vdxfid": "iLfnRYzcdQXR6am8rZk7xNtTUbLZo5NLG6", + "indexid": "xRVttMRhUik5ikeAiFQGvmQzWFMajwrVzX", + "hash160result": "ac0674f6d656d434e0b5b310daaaed554c3a9bbc", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::identity.selfiecheck.video" + } +}; +exports.IDENTITY_EMAIL_ISDELIVERABLE = { + "vdxfid": "iN5Tdse8NSwuW6A4ZavHbHoDyD8aVjn1Ky", + "indexid": "xSua6g5DDmAa8G36RGaSZgKkzs9bSnFbCX", + "hash160result": "8194ee01a0bc66dca2af9ba7c3bba4a24da70dcc", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::identity.email.isdeliverable" + } +}; +exports.IDENTITY_EMAIL_BREACHCOUNT = { + "vdxfid": "iDy1YKGhzVjAiMiuAvFDqxQbmLRhLEjwPo", + "indexid": "xJo817hnqowqLXbw2buNpLw8nzSiAygHhx", + "hash160result": "8144d2d8cafd733bb03847166be8493d275e1473", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::identity.email.breachcount" + } +}; +exports.IDENTITY_EMAIL_FIRSTBREACHEDAT = { + "vdxfid": "i3eSGR4wrLk5djHsnT18dDHrJBFSBBxVST", + "indexid": "x8UYjDW2hexkFuAue8fHbbpPKqGT4mjAzH", + "hash160result": "df796054181f57d3b61d655d604d42d6c6d8df01", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::identity.email.firstbreachedat" + } +}; +exports.IDENTITY_EMAIL_LASTBREACHEDAT = { + "vdxfid": "iCuZWBzmxCoFcRFjXYFgC6g4jT7kzxvhew", + "indexid": "xHjfxzRroX1vEb8mPDuqAVCbm78ms8Hkhd", + "hash160result": "d1b421db4c835cfa67b491342c31f89283427567", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::identity.email.lastbreachedat" + } +}; +exports.IDENTITY_EMAIL_DOMAIN_REGISTEREDAT = { + "vdxfid": "iGxV4SBRZMk5qWrQEKgUS4RoqzpDmyBEpC", + "indexid": "xMnbXEcWQfxkTgjS61LdQSxLseqEcTADNA", + "hash160result": "e195ef220f8e71bfa7bef160291ecaa0164de393", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::identity.email.domain.registeredat" + } +}; +exports.IDENTITY_EMAIL_DOMAIN_FREEPROVIDER = { + "vdxfid": "iLUfvKcg92CYo3BvCuRf5o844d44kGLhJL", + "indexid": "xRJnP83kzLRDRD4x4b5p4Beb6H55fetTy7", + "hash160result": "0b0f213c88a1b0df6cd01721955b1d0c103981ba", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::identity.email.domain.freeprovider" + } +}; +exports.IDENTITY_EMAIL_DOMAIN_CUSTOM = { + "vdxfid": "i4FSBFpQ6Ccjiy2g61GrxhBppv1jDDh6on", + "indexid": "x95Ye4FUwWqQM8uhwgw1w5iMra2k7F1Lfz", + "hash160result": "bea1175185aeaf256aa7f04795b2c8d0c8547e08", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::identity.email.domain.custom" + } +}; +exports.IDENTITY_EMAIL_DOMAIN_DISPOSABLE = { + "vdxfid": "i52PJxRyjKAEkmQFd2oGYgZV3pcsQUcD1T", + "indexid": "x9rVmks4adNuNwHHUiTRX5625UdtJPBQ1w", + "hash160result": "3adf98cb5cc90a074a52a651c50f67f5f0a7fe10", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::identity.email.domain.disposable" + } +}; +exports.IDENTITY_EMAIL_DOMAIN_TOPLEVEL_SUSPICIOUS = { + "vdxfid": "iCtAZWinafiyf4tmvPxFkKNn5KxayXTPSV", + "indexid": "xHiH2K9sRyweHEmon5cQihuK6yybre797b", + "hash160result": "85477eb8148562614c396ca64fc7563637b13167", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::identity.email.domain.toplevel.suspicious" + } +}; +exports.IDENTITY_PASSPORT = { + "vdxfid": "iKgbqmZ4Ks9SPNQGj5PZ5TgXomYG4CtaXv", + "indexid": "xQWiJZz9BBN71YHJam3i3rD4qRZH1sbLHD", + "hash160result": "775f52820102c994e30a29b1828b064421afcab1", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::identity.passport" + } +}; +exports.IDENTITY_PASSPORT_ORIGINALFRONT = { + "vdxfid": "iCwT1mHdci9wooC6Q8mtx8QssXzwiL4hxp", + "indexid": "xHmZUZiiU2NcRy58FpS3vWwQuC1xdM48mW", + "hash160result": "25023e23a25ba4daa7ac0a9c96180f5e90acd067", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::identity.passport.originalfront" + } +}; +exports.IDENTITY_PASSPORT_ORIGINALBACK = { + "vdxfid": "iDXKJaroNRKr9GZfLFvH7LttJQaXqGoSrc", + "indexid": "xJMRmPHtDjYWmSShBwaS5jRRL4bYmTdC9J", + "hash160result": "21734b0f37ec51dd77bdab8c10065cf67b61386e", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::identity.passport.originalback" + } +}; +exports.IDENTITY_PASSPORT_CROPPEDFRONT = { + "vdxfid": "i4cr6CxCYDHUDjc6UoMsDVAZoNep6Meuyi", + "indexid": "x9SxZ1PHPXW8quV8LV22Bsh6q2fpxtJ6Zd", + "hash160result": "274c241806d31576a57a074cc2f6b4c624078b0c", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::identity.passport.croppedfront" + } +}; +exports.IDENTITY_PASSPORT_CROPPEDBACK = { + "vdxfid": "i6wA2ttX7vcxBXmrdmGEa44NZEFBZWoRYa", + "indexid": "xBmGVhKbyEqcohetVSvPYSauatGCUYDMs2", + "hash160result": "f56f1db46ddebc99f3c8954fc8bf1d26a9bef125", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::identity.passport.croppedback" + } +}; +exports.IDENTITY_PASSPORT_FACE = { + "vdxfid": "iLCbvnyU4V3XeMz18CXAG5MCtjb2FjpcZX", + "indexid": "xR2iPbQYuoGCGXs2ytBKETsjvPc35DNZDm", + "hash160result": "26f7dc9d524f84a21c8a9e3f2dc5149f3a3c77b7", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::identity.passport.face" + } +}; +exports.IDENTITY_PASSPORT_IDNUMBER = { + "vdxfid": "iDYih1jmCA1oexyxZ1PQFL5ewyciqoQ2rw", + "indexid": "xJNq9pAr3UEUH8rzQh3ZDicByddjgKM4vN", + "hash160result": "c8a25af227fc07e260119b370da0eae2a9517c6e", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::identity.passport.idnumber" + } +}; +exports.IDENTITY_PASSPORT_CATEGORY = { + "vdxfid": "iMtpUJYWZmnnSJyJcshHRdWJZMhZVZZifT", + "indexid": "xSivw6ybR61T4UrLUZMSQ22qb1iaQux7BU", + "hash160result": "84a9f125285d7e93a1e676ed48e3fbe459780aca", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::identity.passport.category" + } +}; +exports.IDENTITY_PASSPORT_EXPIRATIONDATE = { + "vdxfid": "i98TaZ3wTh3qRw2ufeunVY2MD5eKwoamGE", + "indexid": "xDxa3MV2K1GW46uwXLZwTvYtEjfLspcYEK", + "hash160result": "07727b480c654d59cb611ed01715e254eb37053e", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::identity.passport.expirationdate" + } +}; +exports.IDENTITY_PASSPORT_ISSUINGCOUNTRY = { + "vdxfid": "iRHGM2GEYeRUuHKSG1wENVA16bdyVRxchn", + "indexid": "xW7NophKPxe9XTCU7hbPLsgY8FezLKmJHi", + "hash160result": "4798dee337b16fc22d26748fb0803738f99831ef", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::identity.passport.issuingcountry" + } +}; +exports.IDENTITY_PASSPORT_ISSUINGREGION = { + "vdxfid": "i6Ay9VdcZjGrJur5SNyhBDZWzxGmo7qUmW", + "indexid": "xB15cJ4hR3VWw5j7J4dr9c642cHnbq2nm9", + "hash160result": "f3d9b605096f4c816de7d72c597fee07e75a961d", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::identity.passport.issuingregion" + } +}; +exports.IDENTITY_PASSPORT_DATEOFBIRTH = { + "vdxfid": "iAjG8DwYfKxt9affJy6CUBDDFK5jaeHRLJ", + "indexid": "xFZNb2NdWeBYmkYhAekMSZjkGy6kWqAqyd", + "hash160result": "73eb23619d178f495a24b41aaf6aac107357924f", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::identity.passport.dateofbirth" + } +}; +exports.IDENTITY_PASSPORT_ADDRESS_STREET1 = { + "vdxfid": "i7HPJNB16V5pws8xSq4a8pHF29Mcg6sUyy", + "indexid": "xC7VmAc5woJVa31zJWij7Con3oNdXuBysY", + "hash160result": "c28625c4dfc12d3cdd85f8c7272e87a57523c529", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::identity.passport.address.street1" + } +}; +exports.IDENTITY_PASSPORT_ADDRESS_CITY = { + "vdxfid": "iFSLsk21VvWSWLg9a4XFTB3kEN8bLnTB7c", + "indexid": "xLGTLYT6MEj78WZBRkBQRZaHG29cBfjnYu", + "hash160result": "c06884e75232e86de75c6ccbd5605a3352dd3783", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::identity.passport.address.city" + } +}; +exports.IDENTITY_PASSPORT_ADDRESS_REGION = { + "vdxfid": "iFNoUQhExFEYTgrqgy7x22Q6URM7ek9L3J", + "indexid": "xLCuwD8KoZTD5rjsYen6zQvdW5N8Z4oGqf", + "hash160result": "7b7baa6d0d788f434536aa472c57d9de40678c82", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::identity.passport.address.region" + } +}; +exports.IDENTITY_PASSPORT_ADDRESS_POSTCODE = { + "vdxfid": "iS4SakGdB4ek1Q1QAitXUwFEk1RVyi3rLY", + "indexid": "xWtZ3Yhi2NsQdZtS2QYgTKmmmfSWrxdFKY", + "hash160result": "4457551bc48db37393f5ec3ec3d0cf6766dcbcf7", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::identity.passport.address.postcode" + } +}; +exports.IDENTITY_PASSPORT_ADDRESS_COUNTRY = { + "vdxfid": "iB9w9GgcJdGTt3ZuM2pm5qpDBA3UaJdcvj", + "indexid": "xFz3c57h9wV8WDSwCiUv4ELkCp4VNyPHLr", + "hash160result": "dd93bcbecc805e5b1606efafa1ecab6b33e53c54", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::identity.passport.address.country" + } +}; +exports.IDENTITY_RESIDENCEPERMIT = { + "vdxfid": "i8WZetqKFn98rHRZGvAvPuzPyrJeyUMjfb", + "indexid": "xDLg7hGQ76MoUTJb8bq5NJWw1WKftQg9VL", + "hash160result": "712ef00d9937eb4ade0fd3e627c2df1d99503b37", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::identity.residencepermit" + } +}; +exports.IDENTITY_RESIDENCEPERMIT_ORIGINALFRONT = { + "vdxfid": "iC5NrmPgKckxBjKv7v9HjUMytm4jRtEBgZ", + "indexid": "xGuVKZpmAvycouCwyboShrtWvR5kNYzWoH", + "hash160result": "639ed2ef9da2f5e75fe63e1ccf83d1b54e68585e", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::identity.residencepermit.originalfront" + } +}; +exports.IDENTITY_RESIDENCEPERMIT_ORIGINALBACK = { + "vdxfid": "iLTPvrZi8HNALuVmYeAWnSnLdZ5GsAAUcx", + "indexid": "xRHWPeznybapy5NoQKpfkqJsfD6HmQW5eW", + "hash160result": "94d200a22dbdfa7ba47d1970c21eacb65f7543ba", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::identity.residencepermit.originalback" + } +}; +exports.IDENTITY_RESIDENCEPERMIT_CROPPEDFRONT = { + "vdxfid": "i6T3rairykWA5vVEtQqptjp5RBRhTCmsBS", + "indexid": "xBHAKP9wq4ipi6NGk6Vys8LcSqSiKAMKZU", + "hash160result": "14136815f288a4b6426c7f4ab6b28221dcf0a020", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::identity.residencepermit.croppedfront" + } +}; +exports.IDENTITY_RESIDENCEPERMIT_CROPPEDBACK = { + "vdxfid": "iHssgpjB2gsusjjLH36N3KqUQqz7JPXumA", + "indexid": "xNhz9dAFt16aVucN8ikX1iN1SW18D7SNDP", + "hash160result": "ce3cae77f2010009817f1e01de52ce8a493cfc9d", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::identity.residencepermit.croppedback" + } +}; +exports.IDENTITY_RESIDENCEPERMIT_FACE = { + "vdxfid": "iNVvVYKcKuredXKvctn5uQxp3kNXoJrwNb", + "indexid": "xTL2xLkhBE5KFhCxUaSEsoVM5QPYfELeHf", + "hash160result": "4dd17db50d569a63cc892d78850ac9de1d0eaed0", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::identity.residencepermit.face" + } +}; +exports.IDENTITY_RESIDENCEPERMIT_IDNUMBER = { + "vdxfid": "iMxygBvDFftAnmUCjVLh21etV5v4wt9zdk", + "indexid": "xSo68zMJ6z6qQwMEbAzqzQBRWjw5u6Tm63", + "hash160result": "ab544471e583d6a11245bb971e3ee1ef5ed1d3ca", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::identity.residencepermit.idnumber" + } +}; +exports.IDENTITY_RESIDENCEPERMIT_CATEGORY = { + "vdxfid": "iGbMb21an69VE6iTH2iRtRFKCEUZPJHTwU", + "indexid": "xMRU3pSfdQN9rGbV8iNaromrDtVaCufAXu", + "hash160result": "ae9031bab1ee600e10aa16ec1d4c13def953e48f", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::identity.residencepermit.category" + } +}; +exports.IDENTITY_RESIDENCEPERMIT_EXPIRATIONDATE = { + "vdxfid": "iJ48ALemxyMV6DYzeuRMe8Fn78iMZdjSXZ", + "indexid": "xNtEd95rpHa9iPS2Wb5WcWnK8njNXD9HEH", + "hash160result": "d3083b08621d6ff5dc3f7f9cace34f944d7aec9f", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::identity.residencepermit.expirationdate" + } +}; +exports.IDENTITY_RESIDENCEPERMIT_ISSUINGCOUNTRY = { + "vdxfid": "i7UhTp4gruQwtkC1bi4RxE4wUAsro6n9Ym", + "indexid": "xCJovcVmiDdcWv53TPiavcbUVptsgMKzdL", + "hash160result": "75e37dc8957c8c6765c60962804d446b2de0e82b", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::identity.residencepermit.issuingcountry" + } +}; +exports.IDENTITY_RESIDENCEPERMIT_ISSUINGREGION = { + "vdxfid": "iERBNWk2tyaGJ2w8P1kM88Mdj5WA9qFzbv", + "indexid": "xKFHqKB7kHnvvCpAEhQW6WtAkjXAymjqXM", + "hash160result": "788165581de37b5473c2f127d387f3d7a8630778", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::identity.residencepermit.issuingregion" + } +}; +exports.IDENTITY_RESIDENCEPERMIT_DATEOFBIRTH = { + "vdxfid": "iM62dN7LSHWDuetPi6qAewG6bzYwFrcqBN", + "indexid": "xRv96AYRHbitXpmRZnVKdKnddeZxAivvFE", + "hash160result": "e2533190e4822ab51c5b2029039fbb0d431131c1", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::identity.residencepermit.dateofbirth" + } +}; +exports.IDENTITY_RESIDENCEPERMIT_ADDRESS = { + "vdxfid": "iCA8P2rVs5DjtzQpXEnPJcG4KBs79C9EpL", + "indexid": "xGzEqqHaiPSQXAHrNvSYGznbLqt83gLGV5", + "hash160result": "2c7264a72e1d7937da951620039e48a0c8663e5f", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::identity.residencepermit.address" + } +}; +exports.IDENTITY_RESIDENCEPERMIT_ADDRESS_STREET1 = { + "vdxfid": "iMuY2CbmQpCFzodGBtqxogmTb5dYfNbCJa", + "indexid": "xSjeV12rG8QvcyWJ3aW7n5HzcjeZaxtGwr", + "hash160result": "444cbb0dc6f471ecb2261dc7d6731cd97e272dca", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::identity.residencepermit.address.street1" + } +}; +exports.IDENTITY_RESIDENCEPERMIT_ADDRESS_CITY = { + "vdxfid": "iRckJ1VkfYazfVHWJuA9iXTth83ZYp8znz", + "indexid": "xWSrkovqWrofHfAYAapJguzRin4aPEqHJK", + "hash160result": "73e22f5d24515103052ab165736a0198a7d4e0f2", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::identity.residencepermit.address.city" + } +}; +exports.IDENTITY_RESIDENCEPERMIT_ADDRESS_REGION = { + "vdxfid": "iBpH337NTJSLjSxbBWuu2wBLu12k4JVGk4", + "indexid": "xGePVqYTJcf1Mcqd3Ca41Khsvf3kyxtNXH", + "hash160result": "2f7b3040cf60259ee4bf6dfc93a4de42ab4e7d5b", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::identity.residencepermit.address.region" + } +}; +exports.IDENTITY_RESIDENCEPERMIT_ADDRESS_POSTCODE = { + "vdxfid": "iGKi47jtg6CumKYSUBj57drgLNGzhJY3Gj", + "indexid": "xM9pWvAyXQRaPVRUKsPE62PDN2J1Zp4d6b", + "hash160result": "db85ea63848a6ad2c3a0e82bb29e215c00c2ee8c", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::identity.residencepermit.address.postcode" + } +}; +exports.IDENTITY_RESIDENCEPERMIT_ADDRESS_COUNTRY = { + "vdxfid": "i8KD9CUn7Su4YT44WhbD8HYA1K425cFCqM", + "indexid": "xD9Kbzurxm7jAcw6NPFN6g4h2y531jRanx", + "hash160result": "75970ae74cd40419dc78ecef7be22c5ee09d1535", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::identity.residencepermit.address.country" + } +}; +exports.IDENTITY_RESIDENTCARD = { + "vdxfid": "iKkJFFtbxRMJutjoruW47Mc1sCfdGYQrC9", + "indexid": "xQaQi4KgojZyY4cqibAD5k8Ytrge9jwt3u", + "hash160result": "2b737a5733b91d305dcf07d9e75797740da97db2", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::identity.residentcard" + } +}; +exports.IDENTITY_RESIDENTCARD_ORIGINALFRONT = { + "vdxfid": "iNMJhZ3wie5U2SRF7WSFTpjJo6B6RSTR4t", + "indexid": "xTBRAMV2ZxJ8ecJGyC6QSDFqpkC7KTFMbW", + "hash160result": "e440d2d8bab46633691a12e7bed0ea785bd90ccf", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::identity.residentcard.originalfront" + } +}; +exports.IDENTITY_RESIDENTCARD_ORIGINALBACK = { + "vdxfid": "i4pAk8J5ec2wn55VattFRr7PyN4J2L13HJ", + "indexid": "x9eHCvjAVvFcQExXSaYQQEdw125Jz84d8u", + "hash160result": "9fa70ca8b49eab8c3e704f78f0e0ae1bc52caf0e", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::identity.residentcard.originalback" + } +}; +exports.IDENTITY_RESIDENTCARD_CROPPEDFRONT = { + "vdxfid": "iLnx7NDcAWtb9uWicdgSaiwco56TywMh5w", + "indexid": "xRd4aAeh1q7Fn5PkUKLbZ7U9pj7UvU8v2V", + "hash160result": "fa7347c3517552a028890dacaf889a6ead39f6bd", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::identity.residentcard.croppedfront" + } +}; +exports.IDENTITY_RESIDENTCARD_CROPPEDBACK = { + "vdxfid": "i8WjL22L4UeaCDKZuj8R4Uub6zurTPdaLv", + "indexid": "xDLqnpTQunsEpPCbmQna2sS88evsLJL51v", + "hash160result": "b5134fe72682aa4f0dc645ceb73421dc07644337", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::identity.residentcard.croppedback" + } +}; +exports.IDENTITY_RESIDENTCARD_FACE = { + "vdxfid": "i6dGShbLY2ppZnXSyfvdtdGFkCxBQd2r9Y", + "indexid": "xBTNuW2RPM3VBxQUqMans1nnmryCFH4rRD", + "hash160result": "25a41b37f64414a2477c5c0d1a139d64ce9b8f22", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::identity.residentcard.face" + } +}; +exports.IDENTITY_RESIDENTCARD_IDNUMBER = { + "vdxfid": "iKFkbwDcQRXjapZcZAXsaMXjgER9CZbwZx", + "indexid": "xQ5s4jehFjkQCzSeQrC2Yk4GhtSA2GbM4B", + "hash160result": "e30d9a01765325e02ca22f60335d4bdb499917ad", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::identity.residentcard.idnumber" + } +}; +exports.IDENTITY_RESIDENTCARD_CATEGORY = { + "vdxfid": "i46Fgc8ev9zAkjikjHWreqSXkMRpFr5Lsi", + "indexid": "x8vN9QZjmUCqNubnayB1dDy4n1SqAqg4vn", + "hash160result": "c0039a4929d081eec1d1f5ca3040e19bded3c106", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::identity.residentcard.category" + } +}; +exports.IDENTITY_RESIDENTCARD_EXPIRATIONDATE = { + "vdxfid": "iBA1oFvDABKqbu9i61AEGy1m5fFHdCWkpy", + "indexid": "xFz8G4MJ1VYWE52jwgpPFMYJ7KGJUd6Y4b", + "hash160result": "0866dd99514f509c9ad4584b3f570515f4c74054", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::identity.residentcard.expirationdate" + } +}; +exports.IDENTITY_RESIDENTCARD_ISSUINGCOUNTRY = { + "vdxfid": "iHBgD199BSEQWREtiW8dP259DX4qg6KjkM", + "indexid": "xN1nfoaE2kT58b7vaBnnMQbgFB5rWuKCtd", + "hash160result": "ef88ffb14a8b66dacc690351fa9c3d35a8036296", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::identity.residentcard.issuingcountry" + } +}; +exports.IDENTITY_RESIDENTCARD_ISSUINGREGION = { + "vdxfid": "i6jygVNjzZUFEXVgtzWxXpBYf5rwjXF92J", + "indexid": "xBa69HopqsgurhNikgB7WCi5gjsxbi12z3", + "hash160result": "dc31e031328cfe3697527e046a52cc372687d423", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::identity.residentcard.issuingregion" + } +}; +exports.IDENTITY_RESIDENTCARD_DATEOFBIRTH = { + "vdxfid": "iQfYTwmTxXzxxyFh6XbY2PQVLVwswRoJL1", + "indexid": "xVVevkCYorDdb98ixDFgzmw2N9xtnBn6M2", + "hash160result": "73e0e5f4af76255bc2a3583ad9a7b1d0241470e8", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::identity.residentcard.dateofbirth" + } +}; +exports.IDENTITY_RESIDENTCARD_ADDRESS_STREET1 = { + "vdxfid": "iJ67qMPN6tyrLXBhbJpKKBZYpkcBzZD8S4", + "indexid": "xNvEJ9pSxDCWxh4jSzUUHa65rQdCviMqur", + "hash160result": "8540d9cb71ca32f4c03caf26a4cffa4d51094da0", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::identity.residentcard.address.street1" + } +}; +exports.IDENTITY_RESIDENTCARD_ADDRESS_CITY = { + "vdxfid": "iLCQ2n5tKHzKcVBv8of1eYmdWEdEY5vTUN", + "indexid": "xR2WVaWyAcCzEf4wzVKAcwJAXteFUoFSux", + "hash160result": "7990100969a22f4b4ba35613b3994219e74d6db7", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::identity.residentcard.address.city" + } +}; +exports.IDENTITY_RESIDENTCARD_ADDRESS_REGION = { + "vdxfid": "iPWcAQ6zbC9rKaaWAgrpoHmKs5G5SQCprF", + "indexid": "xULidCY5SWNWwkTY2NWymgHrtjH6QfP6JL", + "hash160result": "ff3f1523bfb1fe501ef10f0036c9f059b64bc7db", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::identity.residentcard.address.region" + } +}; +exports.IDENTITY_RESIDENTCARD_ADDRESS_POSTCODE = { + "vdxfid": "iG1QGYyp4SkiP7b9ngPwkTGC3DxVG3hB16", + "indexid": "xLqWjMQtukyP1HUBeN46iqnj4syW4eat4U", + "hash160result": "f345aa72196b006e2200bd08ed0ea165806c7889", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::identity.residentcard.address.postcode" + } +}; +exports.IDENTITY_RESIDENTCARD_ADDRESS_COUNTRY = { + "vdxfid": "i4wzngZfZb2QBnjr2TjtoMoMF9roSqQkho", + "indexid": "x9n7FUzkQuF4oxcst9Q3mkKtGospNqDjEQ", + "hash160result": "dd2a94da0a94115ed04de616b7d0ea1b19312a10", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::identity.residentcard.address.country" + } +}; +exports.IDENTITY_IDCARD = { + "vdxfid": "iK7FrcxNvsej84qZjYR73iGgEV96sGKwTU", + "indexid": "xPwNKRPTnBsPkEibbE5G26oDG9A7j4JSm7", + "hash160result": "4f2b2c852e4cfa5a640988af78c4d02243467cab", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::identity.idcard" + } +}; +exports.IDENTITY_IDCARD_ORIGINALFRONT = { + "vdxfid": "iCnLNq42DxhuK84Nes4UGjFFUuNsGGpuBZ", + "indexid": "xHcSqdV75GvZwHwQWYidF7mnWZPtATN7Ky", + "hash160result": "9f5f63641e6e935628d7602e92814311ea631766", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::identity.idcard.originalfront" + } +}; +exports.IDENTITY_IDCARD_ORIGINALBACK = { + "vdxfid": "iJyfvwrUeTRiGxiYw6oJZ3uALsuBt7QTyy", + "indexid": "xPonPkHZVmeNu8bannTTXSRhNXvCpAD3MB", + "hash160result": "df3a44e11ad54673eff910c1320d9f50100b0daa", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::identity.idcard.originalback" + } +}; +exports.IDENTITY_IDCARD_CROPPEDFRONT = { + "vdxfid": "iFDp8jWwybweGStGQnYxwhbi8eiucZ29sr", + "indexid": "xL3vbXx2pvAJtcmJGUD7v68FAJjvZmrsga", + "hash160result": "b10845ae9b29f3ed25f33f091398fd0a1536d980", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::identity.idcard.croppedfront" + } +}; +exports.IDENTITY_IDCARD_CROPPEDBACK = { + "vdxfid": "i8GpXrygUPpQYVwcoZ7JVRB1xB46xZsMuG", + "indexid": "xD6vzfQmKi35AfpefEmTTohYyq57sdLVxr", + "hash160result": "84c05d2d84ab69db2834df22602f34445ae9a134", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::identity.idcard.croppedback" + } +}; +exports.IDENTITY_IDCARD_FACE = { + "vdxfid": "i8sfiwALhk4FtSaWSnBWYwKnWN3G7m3jyU", + "indexid": "xDhnBjbRZ4GvWcTYJTqfXKrKY24GxBC5cg", + "hash160result": "4afc5fda25a15a4627b8426f40594ff2e11d393b", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::identity.idcard.face" + } +}; +exports.IDENTITY_IDCARD_IDNUMBER = { + "vdxfid": "iBEJB1xD1mpR4kYQbYieW3hNFpe5QmQ6qA", + "indexid": "xG4QdpPHs635gvRSTENoUSDuHUf6JB2izs", + "hash160result": "0af18c033e6ad395bdfb5fbdbf5144d63c1d1055", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::identity.idcard.idnumber" + } +}; +exports.IDENTITY_IDCARD_CATEGORY = { + "vdxfid": "i4HCpvV1NJd4Ka8atCtDkXs4XLAkrmtKib", + "indexid": "x97KHiv6Dcqiwk1cjtYNivPbYzBmg48ama", + "hash160result": "68b49fa5bf2ed00672c881c15167fee2c304d408", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::identity.idcard.category" + } +}; +exports.IDENTITY_IDCARD_EXPIRATIONDATE = { + "vdxfid": "iNTbsfTmeAm7KUFehtCq3RH1JgbUdTJwCt", + "indexid": "xTHiLTtrVUymwe8gZZrz1ooYLLcVZC5A4n", + "hash160result": "f4b807e32848d5a40815e2aa19cb219c64ae3dd0", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::identity.idcard.expirationdate" + } +}; +exports.IDENTITY_IDCARD_ISSUINGCOUNTRY = { + "vdxfid": "iJ5qVRWTHerkVreE9UrSfKyphD3XB9s8FA", + "indexid": "xNuwxDwY8y5R82XG1AWbdiWMis4Y3BXDg7", + "hash160result": "2cc5492966de5135e638de253b497cccb8643fa0", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::identity.idcard.issuingcountry" + } +}; +exports.IDENTITY_IDCARD_ISSUINGREGION = { + "vdxfid": "i8dHTbZ62Bth8NwkxasnKFpvX4EZYuBun4", + "indexid": "xDTPvPzAsW7MkYpnpGXwHeMTYiFaMyp6FD", + "hash160result": "f42f7b71bb43c590b9063755754bf2d534b58038", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::identity.idcard.issuingregion" + } +}; +exports.IDENTITY_IDCARD_DATEOFBIRTH = { + "vdxfid": "iGcwhC6znG63pb6jqsRnrtDjXV4aXXsub2", + "indexid": "xMT49zY5daJiSkymhZ5wqGkGZ95bMGYJ9r", + "hash160result": "4d0c72c3369a0ac64711e58ae1b10785f1363190", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::identity.idcard.dateofbirth" + } +}; +exports.IDENTITY_IDCARD_ADDRESS_STREET1 = { + "vdxfid": "i6jMXjNE9qioZ2dFricFnEBEQEWK5Kg3PS", + "indexid": "xBZTzXoK19wUBCWHiQGQkchmRtXKugcKWw", + "hash160result": "2cee0d13a2fdeaac83d052ad27610da8bf59b623", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::identity.idcard.address.street1" + } +}; +exports.IDENTITY_IDCARD_ADDRESS_CITY = { + "vdxfid": "i3viAeqayk3KDk5tQpYcz6gFs1ayW5vBma", + "indexid": "x8kpdTGfq4FyquxvGWCmxVCntfbzM8iAVb", + "hash160result": "a10bfcd1cfd12d466a276339072d2f2a7ec6f304", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::identity.idcard.address.city" + } +}; +exports.IDENTITY_IDCARD_ADDRESS_REGION = { + "vdxfid": "iEHvf3XCFacMihTQPVXxNeo6hBCqggDFie", + "indexid": "xK837qxH6tq2LsLSFBC7M3KdiqDrYBNMK7", + "hash160result": "55af249b3ceb591709c693017e5b7b1cb131a876", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::identity.idcard.address.region" + } +}; +exports.IDENTITY_IDCARD_ADDRESS_POSTCODE = { + "vdxfid": "i3yAnt6zdceYxbCBnLwxn2tNdM4BnPkzhT", + "indexid": "x8oHFgY5UvsDam5De2c7kRQuf15ChzdWFA", + "hash160result": "acd086baf0863cff86fc56ec0fbb16dd18d56a05", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::identity.idcard.address.postcode" + } +}; +exports.IDENTITY_IDCARD_ADDRESS_COUNTRY = { + "vdxfid": "iA6KVD2C4QJAyKfCS3XfQV8AxmpR9R3XG5", + "indexid": "xEvRx1TGuiWqbVYEHjBpNsehzRqS2fp4qg", + "hash160result": "bab14b514d91d7daa39175c90e29a956dec19548", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::identity.idcard.address.country" + } +}; +exports.IDENTITY_VISA = { + "vdxfid": "iDCwZf84AhbJkm4zKZP7Le8h8ukJS9FySA", + "indexid": "xJ342TZ921oyNvx2BF3GK2fEAZmKGeUQUd", + "hash160result": "57faa6b546ac92c71022178b8c5e9fbae9bebe6a", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::identity.visa" + } +}; +exports.IDENTITY_VISA_ORIGINALFRONT = { + "vdxfid": "iGAgzyLDVs5vYFLRgXVnkQpDRKy9Zh1TiV", + "indexid": "xLzoTmmJMBJbARDTYD9wioLkSyzARsVQWr", + "hash160result": "755da3361216260b786ba78fbe68800557223a8b", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::identity.visa.originalfront" + } +}; +exports.IDENTITY_VISA_ORIGINALBACK = { + "vdxfid": "i3becgcmf85RiY2PAxsp3fbuGKG8Qc73t1", + "indexid": "x8Rm5V3rWSJ6LhuR2eXy248SHyH9Jjue4S", + "hash160result": "e71909c77e2e0361764d22b81f4f53085fe85801", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::identity.visa.originalback" + } +}; +exports.IDENTITY_VISA_CROPPEDFRONT = { + "vdxfid": "iAapfFQMAQy7USdjRwqzAZ2nWhRMSiQMmV", + "indexid": "xFQw83qS1jBn6cWmHdW98wZKYMSNHsb2wy", + "hash160result": "56ed30f8daf83e3b09eee57517be45b6b8c1f94d", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::identity.visa.croppedfront" + } +}; +exports.IDENTITY_VISA_CROPPEDBACK = { + "vdxfid": "i3quMdmv3vAQDBA6nzM8fTiFtqJrw7tcnf", + "indexid": "x8g1pSCzuEP4qM38eg1HdrEnvVKsoXBZ7R", + "hash160result": "1d8106821498549cebc0af6f8d120b9933090b04", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::identity.visa.croppedback" + } +}; +exports.IDENTITY_VISA_FACE = { + "vdxfid": "iAqxnB58655ZcRLAUm2Utib2rguRXT9wZM", + "indexid": "xFg5EyWCwPJEEbDCLSgds77ZtLvSRpw2k9", + "hash160result": "59564e826c8342a2b721708f6a83c9761dc6d650", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::identity.visa.face" + } +}; +exports.IDENTITY_VISA_IDNUMBER = { + "vdxfid": "iQ5LfUtuggDyqbePUB9iWLgxYj7tvDm2VE", + "indexid": "xUuT8HKzXzSeTmXRKrosUjDVaP8upm7rqg", + "hash160result": "77ae761bf6bf7922ff8e47b53bd88107be15f8e1", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::identity.visa.idnumber" + } +}; +exports.IDENTITY_VISA_CATEGORY = { + "vdxfid": "iH4nhrNsZKK6bEkgLDu17fBPR5dnVgitiQ", + "indexid": "xMtuAeoxQdXmDQdiBuZA63hvSjeoT3wsnv", + "hash160result": "8052162609b4da20bb5932ead5b6deedbb861495", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::identity.visa.category" + } +}; +exports.IDENTITY_VISA_EXPIRATIONDATE = { + "vdxfid": "iNW2k7p7hVK2GCc7m1k4mihqh8jd94Dmnh", + "indexid": "xTL9CvFCYoXgtNV9chQDk7ENinkdzPUodD", + "hash160result": "5eaa0aef6ed6d27ee4909bc6ce8619c60346b3d0", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::identity.visa.expirationdate" + } +}; +exports.IDENTITY_VISA_ISSUINGCOUNTRY = { + "vdxfid": "i5vDfPKMfCRPXVRhfumjWPEvBFhNMVjtGK", + "indexid": "xAkL8BkSWWe49fJjXbRtUmmTCuiPJGBZ2c", + "hash160result": "ebf49255193b4ffbb3a0487106a4df98833bcc1a", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::identity.visa.issuingcountry" + } +}; +exports.IDENTITY_VISA_ISSUINGREGION = { + "vdxfid": "iPRc9Ns6LadQNYU7DqSNyx7LW8W9dPKDjC", + "indexid": "xUFicBJBBtr4ziM95X6XxLdsXnXAYQ1XFN", + "hash160result": "a1217c6e44b1f47faf9d59378206009d8433d5da", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::identity.visa.issuingregion" + } +}; +exports.IDENTITY_VISA_DATEOFBIRTH = { + "vdxfid": "i55bTsxLkCTmE6VvppvG8doYnmxuHhec65", + "indexid": "x9uhvgPRbWgRrGNxgWaR72L5pRyvA4vVWm", + "hash160result": "ed824bbfd195e63d6d5151a07eda49eba60c9a11", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::identity.visa.dateofbirth" + } +}; +exports.IDENTITY_VISA_ADDRESS_STREET1 = { + "vdxfid": "iMzWxFVzJHbQm5YWv9c1eujvrUrPHAGVAc", + "indexid": "xSpdR3w59bp5PFRYmqGAdJGTt8sQ8o4mpu", + "hash160result": "05992eb838a4f562b6b7e0ff84bb05cdac571ecb", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::identity.visa.address.street1" + } +}; +exports.IDENTITY_VISA_ADDRESS_CITY = { + "vdxfid": "i8YXgZ7doRhidT5phX6qyRnttV6hZiyWTm", + "indexid": "xDNe9MYiejvPFcxrZCkzwpKRv97iS3TQjA", + "hash160result": "04959daab853c797bbbcb9c5ead7376e4a809a37", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::identity.visa.address.city" + } +}; +exports.IDENTITY_VISA_ADDRESS_REGION = { + "vdxfid": "i6YkTDEi1M1mzuTyzww8hNoksJFpev17Fu", + "indexid": "xBNrv1fnrfESd5M1rdbHfmLHtxGqUoeALR", + "hash160result": "3a47a53e8717444b5d31e8618049daa8cde8b421", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::identity.visa.address.region" + } +}; +exports.IDENTITY_VISA_ADDRESS_POSTCODE = { + "vdxfid": "iBJDLHSLB4cHvaeXazFp25Be3V9yRWmcoK", + "indexid": "xG8Ko5sR2NpxYkXZSfuxzTiB59AzMUATiw", + "hash160result": "dd0d87e3163157402aa16d2017a3ea06d6bccd55", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::identity.visa.address.postcode" + } +}; +exports.IDENTITY_VISA_ADDRESS_COUNTRY = { + "vdxfid": "iQ9Z1PZMMp49rtDuGQSjfEZn3xACfxLAYa", + "indexid": "xUyfUBzSD8GpV46w866tdd6K5cBDbMPuNo", + "hash160result": "c45655a6924c0b377e9182869dc780df690dc4e2", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::identity.visa.address.country" + } +}; +exports.IDENTITY_PERSONALDETAILS = { + "vdxfid": "i8SSgM1z7XVoCtoP9CCsMms3zCndaNjtCe", + "indexid": "xDGZ99T4xqiTq4gQzss2LAPb1roeUyLwkU", + "hash160result": "a8fbe89451c1d0a77b336ccf6b0fb7601dd47336", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::identity.personaldetails" + } +}; +exports.IDENTITY_CONTACTDETAILS = { + "vdxfid": "iRLT8V9NN178CvZQusJSHuyuFC2fD2QmE3", + "indexid": "xWAZbHaTDKKnq6SSmYxbGJWSGr3g1GRDYH", + "hash160result": "b9185ad980909708754a484bf11edc9febd8cbef", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::identity.contactdetails" + } +}; +exports.IDENTITY_LOCATION = { + "vdxfid": "iGmiLZ7J6GjxjZ4rkSMsDzyyvWtmMBjnbo", + "indexid": "xMbpoMYNwaxdMiwtc822CPWWxAunLDE1BS", + "hash160result": "15ea60d9ddde976095b0c79ceecef7b034cfd991", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::identity.location" + } +}; +exports.IDENTITY_BANKINGDETAILS = { + "vdxfid": "i8DUrZJJRjNQMJNeJ3Ti6pbpKPJ55LECyJ", + "indexid": "xD3bKMjPH3b4yUFg9j7s5D8MM3K612HEir", + "hash160result": "a7e5de6ac208f110d0509cffeb916b8dd03c0034", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::identity.bankingdetails" + } +}; +exports.IDENTITY_DOCUMENTS = { + "vdxfid": "iCm3ERZoUw2ze1P11QyRUtvhKYovCWFXbT", + "indexid": "xHb9hDztLFFfGBG2s6daTHTEMCpw3tcbVJ", + "hash160result": "ee9f8d5ba7366983cf9b9d3e5e8ac50898a9d865", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::identity.documents" + } +}; +exports.IDENTITY_BANKACCOUNT = { + "vdxfid": "iN4AgB4KEN1C3TfZnYDFUhxn37PdcrZvxT", + "indexid": "xStH8yVQ5gDrfdYbeDsQT6VK4mQeYDjcFm", + "hash160result": "122bf0739d7d1def003656a63c443efb6c14cfcb", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::identity.bankaccount" + } +}; +exports.IDENTITY_BANKINGDETAILS_CURRENCY = { + "vdxfid": "i5k8pb9FHf5VZJKki6him1WMBkpyhe56BY", + "indexid": "xAaFHPaL8yJABUCnZnMsjQ2tDQqzfUkZRm", + "hash160result": "cc655f9f104ad6c25cc65407121fa7ac1208e418", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::identity.bankingdetails.currency" + } +}; +exports.IDENTITY_BANKINGDETAILS_COUNTRY = { + "vdxfid": "iHYqZF4Asa4erZR9kJ5G5nWRNGWdiS8vBh", + "indexid": "xNNx23VFitHKUjJBbyjR4B2xPvXebL5g4h", + "hash160result": "cf7870c11608bf6e58890fbfc18ffe0db98d629a", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::identity.bankingdetails.country" + } +}; +exports.IDENTITY_BANKINGDETAILS_STREET1 = { + "vdxfid": "iRhANjQk2G3aFXiaGtG68kZjdYr2iVXQJJ", + "indexid": "xWXGqXqpsaGEshbc8ZvF796GfCs3bDhrgC", + "hash160result": "bd420c73e6bba2e48542cddf188c23b8c098b6f3", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::identity.bankingdetails.street1" + } +}; +exports.IDENTITY_BANKINGDETAILS_STREET2 = { + "vdxfid": "iFWtcLUKAECLrREJr6mxtHM9xPUocxmTSY", + "indexid": "xLM158uQ1YR1Ub7LhnS7rfsgz3VpTpBcCu", + "hash160result": "7f1a53da2e265bab3230d9eec1ed0f36d7041484", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::identity.bankingdetails.street2" + } +}; +exports.IDENTITY_BANKINGDETAILS_CITY = { + "vdxfid": "iQxBEB8sXNez25HJCzvnTWtWqXUkEVAuo8", + "indexid": "xVnHgyZxNgseeFAL4gawRuR3sBVm7nyQqt", + "hash160result": "5878bb5b9371344acb1b679316e0e087046c95eb", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::identity.bankingdetails.city" + } +}; +exports.IDENTITY_BANKINGDETAILS_REGION = { + "vdxfid": "i4HJ5yrzBFEwjiYgzptMcrBsCeBjPYQJFX", + "indexid": "x97QYnJ52ZTcMtRirWYWbEiQEJCkKnxArM", + "hash160result": "7bf3a5ee05846c54bd19032e6ee9069cbc68d808", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::identity.bankingdetails.region" + } +}; +exports.IDENTITY_BANKINGDETAILS_POSTALCODE = { + "vdxfid": "iFVaE922Bzrro6rb87d9En2t2AAGx7EivG", + "indexid": "xLKggwT73K5XRGjcyoHJDAZR3pBHqz4Utt", + "hash160result": "ebd93a0f4fb8db6fb0cb8d397c45b41a0142d483", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::identity.bankingdetails.postalcode" + } +}; +exports.IDENTITY_BANKINGDETAILS_TAXNUMBER = { + "vdxfid": "i6Gbi3EkYrbREumkLmHUedbzrisXkRzwKY", + "indexid": "xB6iAqfqQAp5s5enCSwdd28XtNtYcHgrDb", + "hash160result": "bcc691f5d53f99e196b291ea2a00a9805ff4a61e", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::identity.bankingdetails.taxnumber" + } +}; +exports.IDENTITY_BANKINGDETAILS_TAXCOUNTRY = { + "vdxfid": "iMJzAfPjqvWJdYyoWTX79cSjd51HbVc7wC", + "indexid": "xS96dTpphEiyFirqN9BG7zyGej2JTACDB1", + "hash160result": "e19f920e684c7d906dd8c85d72a5d5f0cd6ba4c3", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::identity.bankingdetails.taxcountry" + } +}; +exports.IDENTITY_BANKINGDETAILS_FIRSTNAME = { + "vdxfid": "iGAomW7jtsy7zRaoMFU48KvrHahHwdjzi7", + "indexid": "xLzvEJYpkCBncbTqCw8D6iTPKEiJpW3beK", + "hash160result": "d33bd09ba3184bf0e3fa00ad62e92a7a99c83f8b", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::identity.bankingdetails.firstname" + } +}; +exports.IDENTITY_BANKINGDETAILS_LASTNAME = { + "vdxfid": "iMrvbLJnZawGsdFshtrHM3QKa4pDPbRk3L", + "indexid": "xSh348jsQu9wVo8uZaWSKRvrbiqED1eny3", + "hash160result": "4a0d68f2cafc3cbe827a91fd5038c65878bfaec9", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::identity.bankingdetails.lastname" + } +}; +exports.IDENTITY_BANKINGDETAILS_PHONENUMBER = { + "vdxfid": "i9jKPi8ubg5fx3BBmZdiyobJxNgzcmV9et", + "indexid": "xEZRrWZzSzJLaD4DdFHsxC7qz2i1YejHqk", + "hash160result": "b092c8f73031298d26b919f4b398fa9b66f19c44", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::identity.bankingdetails.phonenumber" + } +}; +exports.IDENTITY_BANKINGDETAILS_NUMBER = { + "vdxfid": "iKGaF7fZ6yAvwJyxcmpuas2Hn9PZPF99yf", + "indexid": "xQ6ghv6dxHPbZUrzUTV4ZFYpooQaFZG1aa", + "hash160result": "fcceea7c24223218bc9313e8176daea6155e3fad", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::identity.bankingdetails.number" + } +}; +exports.IDENTITY_BANKINGDETAILS_TYPE = { + "vdxfid": "iNkzXo7BBcUvCBH8somKyFtAFsR3mmmYuG", + "indexid": "xTb6zbYG2vhapMAAjVRUweQhHXS4csH9eB", + "hash160result": "26dcd354b4b2bd8b939af29fc5ea57a082aa87d3", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::identity.bankingdetails.type" + } +}; +exports.IDENTITY_BANKINGDETAILS_SORTCODE = { + "vdxfid": "i8v2y1beTivG8Nyi6Td3VFTc2ExFQJT8pC", + "indexid": "xDk9Rp2jK38vkYrjx9HCTdz93tyGLCaa3E", + "hash160result": "27df54160c8a8a962dd455004c8afac060aeab3b", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::identity.bankingdetails.sortcode" + } +}; +exports.IDENTITY_DOCUMENTS_PASSPORT = { + "vdxfid": "iJHkDyp8dPnNdrh7P9fzow4gTshpbznkSK", + "indexid": "xP7rgnFDUi13G2a9EqL9nKbDVXiqVHVtyg", + "hash160result": "456f1956c77f7ff59d98dd57030d7ed22afd7fa2", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::identity.documents.passport" + } +}; +exports.IDENTITY_RESIDENCECARD = { + "vdxfid": "iQerHJHjqVT32hU1ZUyVYKQEkavs4xFtHo", + "indexid": "xVUxk6ipgofhesM3RAdeWhvmnEwsywApa2", + "hash160result": "0b2227f2bb574fe3cbcc683eecfc4d3bff884ee8", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::identity.residencecard" + } +}; +exports.IDENTITY_ATTESTOR = { + "vdxfid": "iFNc5DG22Btm69wBDDXatvSPLxzJq53QBa", + "indexid": "xLCiY1h6sW7RiKpD4uBjsJxvNd1Kiej8tW", + "hash160result": "e5d18dab811f87643c1e7a63627172331be38282", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::identity.attestor" + } +}; +exports.IDENTITY_ATTESTATION_RECIPIENT = { + "vdxfid": "iAkd3VBhYQ3MK6PUCtfhXrLVNbqSghxxpn", + "indexid": "xFajWHcnPiG1wGGW4aKrWEs2QFrTbwP7wd", + "hash160result": "71b7cbbfc8be868f6d9f6c481c420b002438d44f", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::identity.attestation.recipient" + } +}; diff --git a/dist/vdxf/index.d.ts b/dist/vdxf/index.d.ts index 5e8c173..f385f35 100644 --- a/dist/vdxf/index.d.ts +++ b/dist/vdxf/index.d.ts @@ -4,6 +4,9 @@ import { VDXFKeyInterface } from './keys'; import { BigNumber } from "../utils/types/BigNumber"; export * from './keys'; export * from './scopes'; +export * from './keymap'; +export * from './identitydatakeys'; +export * from './vdxfdatakeys'; export interface VDXFObjectInterface { vdxfkey: string; toString: () => string; @@ -55,6 +58,17 @@ export declare class BufferDataVdxfObject extends VDXFObject { vdxfkey: string; }; } +export declare class VDXFData extends VDXFObject { + data: Buffer; + constructor(data?: Buffer, vdxfkey?: string); + dataByteLength(): number; + toDataBuffer(): Buffer; + fromDataBuffer(buffer: Buffer, offset?: number): number; + toJson(): { + data: string; + vdxfkey: string; + }; +} export declare class Utf8DataVdxfObject extends BufferDataVdxfObject { constructor(data?: string, vdxfkey?: string); } diff --git a/dist/vdxf/index.js b/dist/vdxf/index.js index d2f91ef..30d632c 100644 --- a/dist/vdxf/index.js +++ b/dist/vdxf/index.js @@ -14,7 +14,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) { for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p); }; Object.defineProperty(exports, "__esModule", { value: true }); -exports.VerusIDSignature = exports.Utf8OrBase58Object = exports.HexDataVdxfObject = exports.Utf8DataVdxfObject = exports.BufferDataVdxfObject = exports.VDXFObject = void 0; +exports.VerusIDSignature = exports.Utf8OrBase58Object = exports.HexDataVdxfObject = exports.Utf8DataVdxfObject = exports.VDXFData = exports.BufferDataVdxfObject = exports.VDXFObject = void 0; const base64url_1 = require("base64url"); const createHash = require("create-hash"); const vdxf_1 = require("../constants/vdxf"); @@ -27,6 +27,9 @@ const keys_1 = require("./keys"); const bn_js_1 = require("bn.js"); __exportStar(require("./keys"), exports); __exportStar(require("./scopes"), exports); +__exportStar(require("./keymap"), exports); +__exportStar(require("./identitydatakeys"), exports); +__exportStar(require("./vdxfdatakeys"), exports); class VDXFObject { constructor(key = "", serializekey = true) { this.serializekey = true; @@ -86,9 +89,7 @@ class VDXFObject { writer.writeSlice(key.hash); } writer.writeVarInt(new bn_js_1.BN(this.version, 10)); - if (dataLength) { - writer.writeVarSlice(this.toDataBuffer()); - } + writer.writeVarSlice(this.toDataBuffer()); return writer.buffer; } toSha256() { @@ -122,6 +123,30 @@ class BufferDataVdxfObject extends VDXFObject { } } exports.BufferDataVdxfObject = BufferDataVdxfObject; +class VDXFData extends VDXFObject { + constructor(data = Buffer.from(""), vdxfkey = "") { + super(vdxfkey); + this.data = data; + } + dataByteLength() { + return this.data.length; + } + toDataBuffer() { + return this.data; + } + fromDataBuffer(buffer, offset) { + const reader = new bufferutils_1.default.BufferReader(buffer, offset); + this.data = reader.readVarSlice(); + return reader.offset; + } + toJson() { + return { + data: this.data.toString("hex"), + vdxfkey: this.vdxfkey, + }; + } +} +exports.VDXFData = VDXFData; class Utf8DataVdxfObject extends BufferDataVdxfObject { constructor(data = "", vdxfkey = "") { super(data, vdxfkey, "utf-8"); diff --git a/dist/vdxf/keymap.d.ts b/dist/vdxf/keymap.d.ts new file mode 100644 index 0000000..fcbcb5f --- /dev/null +++ b/dist/vdxf/keymap.d.ts @@ -0,0 +1,12 @@ +import * as keylist from './keys'; +export declare const keymap: { + [key: string]: keylist.VDXFKeyInterface; +}; +export declare const attestationDataKeys: { + [key: string]: keylist.VDXFKeyInterface; +}; +export declare const IdentityVdxfidMap: { + [x: string]: { + EN: string; + }; +}; diff --git a/dist/vdxf/keymap.js b/dist/vdxf/keymap.js new file mode 100644 index 0000000..d9f9d9d --- /dev/null +++ b/dist/vdxf/keymap.js @@ -0,0 +1,10 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.IdentityVdxfidMap = exports.attestationDataKeys = exports.keymap = void 0; +const keylist = require("./keys"); +const attestationData = require("../utils/IdentityData"); +exports.keymap = Object.keys(keylist) + .reduce((obj, item) => { obj[keylist[item].vdxfid] = keylist[item]; return obj; }, {}); +exports.attestationDataKeys = Object.keys(attestationData) + .reduce((obj, item) => { obj[attestationData[item].vdxfid] = attestationData[item]; return obj; }, {}); +exports.IdentityVdxfidMap = attestationData.IdentityVdxfidMap; diff --git a/dist/vdxf/keys.d.ts b/dist/vdxf/keys.d.ts index b31d32a..704d0c6 100644 --- a/dist/vdxf/keys.d.ts +++ b/dist/vdxf/keys.d.ts @@ -5,6 +5,10 @@ export interface VDXFKeyInterface { name: string; namespace: string; }; + bounddata?: { + vdxfkey: string; + }; + indexid?: string; } export declare const VERUSPAY_INVOICE_VDXF_KEY: VDXFKeyInterface; export declare const IDENTITY_AUTH_SIG_VDXF_KEY: VDXFKeyInterface; @@ -16,6 +20,8 @@ export declare const LOGIN_CONSENT_DECISION_VDXF_KEY: VDXFKeyInterface; export declare const WALLET_VDXF_KEY: VDXFKeyInterface; export declare const LOGIN_CONSENT_REDIRECT_VDXF_KEY: VDXFKeyInterface; export declare const LOGIN_CONSENT_WEBHOOK_VDXF_KEY: VDXFKeyInterface; +export declare const LOGIN_CONSENT_ATTESTATION_WEBHOOK_VDXF_KEY: VDXFKeyInterface; +export declare const LOGIN_CONSENT_PERSONALINFO_WEBHOOK_VDXF_KEY: VDXFKeyInterface; export declare const LOGIN_CONSENT_CONTEXT_VDXF_KEY: VDXFKeyInterface; export declare const LOGIN_CONSENT_ID_PROVISIONING_WEBHOOK_VDXF_KEY: VDXFKeyInterface; export declare const ID_ADDRESS_VDXF_KEY: VDXFKeyInterface; @@ -42,4 +48,18 @@ export declare const LOGIN_CONSENT_PROVISIONING_ERROR_KEY_TRANSFER_FAILED: VDXFK export declare const SIGNED_SESSION_OBJECT_DATA: VDXFKeyInterface; export declare const SIGNED_SESSION_OBJECT: VDXFKeyInterface; export declare const CURRENCY_ADDRESS: VDXFKeyInterface; +export declare const ATTESTATION_PROVISION_URL: VDXFKeyInterface; +export declare const ATTESTATION_PROVISION_TYPE: VDXFKeyInterface; +export declare const ATTESTATION_PROVISION_OBJECT: VDXFKeyInterface; +export declare const ATTESTATION_VIEW_REQUEST: VDXFKeyInterface; +export declare const ATTESTATION_VIEW_RESPONSE: VDXFKeyInterface; +export declare const ATTESTATION_ID: VDXFKeyInterface; +export declare const ATTESTATION_NAME: VDXFKeyInterface; +export declare const ATTESTATION_TYPE: VDXFKeyInterface; +export declare const ATTESTATION_VIEW_REQUEST_KEY: VDXFKeyInterface; +export declare const ATTESTATION_VIEW_REQUEST_NAME: VDXFKeyInterface; +export declare const ATTESTATION_VIEW_REQUEST_ATTESTOR: VDXFKeyInterface; +export declare const ATTESTATION_VIEW_REQUEST_ID: VDXFKeyInterface; +export declare const PROFILE_DATA_VIEW_REQUEST: VDXFKeyInterface; +export declare const IDENTITY_SIGNDATA_REQUEST: VDXFKeyInterface; export declare const DATA_TYPE_STRING: VDXFKeyInterface; diff --git a/dist/vdxf/keys.js b/dist/vdxf/keys.js index bef9483..25c3a5a 100644 --- a/dist/vdxf/keys.js +++ b/dist/vdxf/keys.js @@ -1,6 +1,7 @@ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); -exports.DATA_TYPE_STRING = exports.CURRENCY_ADDRESS = exports.SIGNED_SESSION_OBJECT = exports.SIGNED_SESSION_OBJECT_DATA = exports.LOGIN_CONSENT_PROVISIONING_ERROR_KEY_TRANSFER_FAILED = exports.LOGIN_CONSENT_PROVISIONING_ERROR_KEY_CREATION_FAILED = exports.LOGIN_CONSENT_PROVISIONING_ERROR_KEY_COMMIT_FAILED = exports.LOGIN_CONSENT_PROVISIONING_ERROR_KEY_UNKNOWN = exports.LOGIN_CONSENT_PROVISIONING_ERROR_KEY_NAMETAKEN = exports.LOGIN_CONSENT_PROVISIONING_RESULT_STATE_FAILED = exports.LOGIN_CONSENT_PROVISIONING_RESULT_STATE_COMPLETE = exports.LOGIN_CONSENT_PROVISIONING_RESULT_STATE_PENDINGAPPROVAL = exports.LOGIN_CONSENT_PROVISIONING_RESULT_STATE_PENDINGREQUIREDINFO = exports.IDENTITY_UPDATE_TXID = exports.IDENTITY_REGISTRATION_TXID = exports.IDENTITY_NAME_COMMITMENT_TXID = exports.LOGIN_CONSENT_PROVISIONING_RESULT_VDXF_KEY = exports.LOGIN_CONSENT_PROVISIONING_RESPONSE_VDXF_KEY = exports.LOGIN_CONSENT_PROVISIONING_DECISION_VDXF_KEY = exports.LOGIN_CONSENT_PROVISIONING_CHALLENGE_VDXF_KEY = exports.LOGIN_CONSENT_PROVISIONING_REQUEST_VDXF_KEY = exports.ID_PARENT_VDXF_KEY = exports.ID_FULLYQUALIFIEDNAME_VDXF_KEY = exports.ID_SYSTEMID_VDXF_KEY = exports.ID_ADDRESS_VDXF_KEY = exports.LOGIN_CONSENT_ID_PROVISIONING_WEBHOOK_VDXF_KEY = exports.LOGIN_CONSENT_CONTEXT_VDXF_KEY = exports.LOGIN_CONSENT_WEBHOOK_VDXF_KEY = exports.LOGIN_CONSENT_REDIRECT_VDXF_KEY = exports.WALLET_VDXF_KEY = exports.LOGIN_CONSENT_DECISION_VDXF_KEY = exports.LOGIN_CONSENT_CHALLENGE_VDXF_KEY = exports.LOGIN_CONSENT_RESPONSE_VDXF_KEY = exports.LOGIN_CONSENT_REQUEST_VDXF_KEY = exports.LOGIN_CONSENT_RESPONSE_SIG_VDXF_KEY = exports.IDENTITY_AUTH_SIG_VDXF_KEY = exports.VERUSPAY_INVOICE_VDXF_KEY = void 0; +exports.ATTESTATION_VIEW_REQUEST_ID = exports.ATTESTATION_VIEW_REQUEST_ATTESTOR = exports.ATTESTATION_VIEW_REQUEST_NAME = exports.ATTESTATION_VIEW_REQUEST_KEY = exports.ATTESTATION_TYPE = exports.ATTESTATION_NAME = exports.ATTESTATION_ID = exports.ATTESTATION_VIEW_RESPONSE = exports.ATTESTATION_VIEW_REQUEST = exports.ATTESTATION_PROVISION_OBJECT = exports.ATTESTATION_PROVISION_TYPE = exports.ATTESTATION_PROVISION_URL = exports.CURRENCY_ADDRESS = exports.SIGNED_SESSION_OBJECT = exports.SIGNED_SESSION_OBJECT_DATA = exports.LOGIN_CONSENT_PROVISIONING_ERROR_KEY_TRANSFER_FAILED = exports.LOGIN_CONSENT_PROVISIONING_ERROR_KEY_CREATION_FAILED = exports.LOGIN_CONSENT_PROVISIONING_ERROR_KEY_COMMIT_FAILED = exports.LOGIN_CONSENT_PROVISIONING_ERROR_KEY_UNKNOWN = exports.LOGIN_CONSENT_PROVISIONING_ERROR_KEY_NAMETAKEN = exports.LOGIN_CONSENT_PROVISIONING_RESULT_STATE_FAILED = exports.LOGIN_CONSENT_PROVISIONING_RESULT_STATE_COMPLETE = exports.LOGIN_CONSENT_PROVISIONING_RESULT_STATE_PENDINGAPPROVAL = exports.LOGIN_CONSENT_PROVISIONING_RESULT_STATE_PENDINGREQUIREDINFO = exports.IDENTITY_UPDATE_TXID = exports.IDENTITY_REGISTRATION_TXID = exports.IDENTITY_NAME_COMMITMENT_TXID = exports.LOGIN_CONSENT_PROVISIONING_RESULT_VDXF_KEY = exports.LOGIN_CONSENT_PROVISIONING_RESPONSE_VDXF_KEY = exports.LOGIN_CONSENT_PROVISIONING_DECISION_VDXF_KEY = exports.LOGIN_CONSENT_PROVISIONING_CHALLENGE_VDXF_KEY = exports.LOGIN_CONSENT_PROVISIONING_REQUEST_VDXF_KEY = exports.ID_PARENT_VDXF_KEY = exports.ID_FULLYQUALIFIEDNAME_VDXF_KEY = exports.ID_SYSTEMID_VDXF_KEY = exports.ID_ADDRESS_VDXF_KEY = exports.LOGIN_CONSENT_ID_PROVISIONING_WEBHOOK_VDXF_KEY = exports.LOGIN_CONSENT_CONTEXT_VDXF_KEY = exports.LOGIN_CONSENT_PERSONALINFO_WEBHOOK_VDXF_KEY = exports.LOGIN_CONSENT_ATTESTATION_WEBHOOK_VDXF_KEY = exports.LOGIN_CONSENT_WEBHOOK_VDXF_KEY = exports.LOGIN_CONSENT_REDIRECT_VDXF_KEY = exports.WALLET_VDXF_KEY = exports.LOGIN_CONSENT_DECISION_VDXF_KEY = exports.LOGIN_CONSENT_CHALLENGE_VDXF_KEY = exports.LOGIN_CONSENT_RESPONSE_VDXF_KEY = exports.LOGIN_CONSENT_REQUEST_VDXF_KEY = exports.LOGIN_CONSENT_RESPONSE_SIG_VDXF_KEY = exports.IDENTITY_AUTH_SIG_VDXF_KEY = exports.VERUSPAY_INVOICE_VDXF_KEY = void 0; +exports.DATA_TYPE_STRING = exports.IDENTITY_SIGNDATA_REQUEST = exports.PROFILE_DATA_VIEW_REQUEST = void 0; exports.VERUSPAY_INVOICE_VDXF_KEY = { hash160result: "628efc28c2e2d40050e1a9de7a93e7ddf2aa0076", qualifiedname: { @@ -81,6 +82,23 @@ exports.LOGIN_CONSENT_WEBHOOK_VDXF_KEY = { name: "vrsc::identity.authentication.loginconsent.webhook", }, }; +exports.LOGIN_CONSENT_ATTESTATION_WEBHOOK_VDXF_KEY = { + vdxfid: "iEiQe3C68gKvAevZWAx6MLmoSR64hVqfMb", + hash160result: "6759ec3006891e89422e59fb613ab2653389497b", + qualifiedname: { + namespace: "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + name: "vrsc::identity.attestation.webhook", + }, +}; +exports.LOGIN_CONSENT_PERSONALINFO_WEBHOOK_VDXF_KEY = { + vdxfid: "i8RW9fcZHh1oaAqR2fWWLCB99mfNW6Q2mQ", + indexid: "xDFccU3e91EUCLiStMAfJahgBRgPHfYq74", + hash160result: "fe40712687cd6f9f288e535ced75b653624f4636", + qualifiedname: { + namespace: "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + name: "vrsc::identity.identitydata.webhook" + } +}; exports.LOGIN_CONSENT_CONTEXT_VDXF_KEY = { vdxfid: "iBMochrKPSQfua5yZYWyd6p4QnREakqU44", hash160result: "3b605d4ace1e19dd0bddb2eef63171b1879a7b56", @@ -289,6 +307,129 @@ exports.CURRENCY_ADDRESS = { "name": "vrsc::currency.address" } }; +exports.ATTESTATION_PROVISION_URL = { + "vdxfid": "iD9J9aQ6vsRYvqZbBs9QpKmCcgUynee7mT", + "indexid": "xHyQcNqBnBeDZ1Sd3YoZniHjeLVzgLK5ka", + "hash160result": "e1059d2a03500749f86ed9c49137b86de6430e6a", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::attestation.provision.url" + } +}; +exports.ATTESTATION_PROVISION_TYPE = { + "vdxfid": "i7VGPAp3q2h4U4njZ556b9eG3Jts2gmzHn", + "indexid": "xCKNqyF8gLuj6EfmQkjFZYAo4xuswrB6X9", + "hash160result": "5f922c9d09e0160b7c3bc5f31588dfc11b5b042c", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::attestation.provision.type" + } +}; +exports.ATTESTATION_PROVISION_OBJECT = { + "vdxfid": "iA4mSmR35HNwXogTtdGasrmxHzX9zFfDqM", + "indexid": "xEtsuZr7vbbc9yZVkJvjrFJVKeYArDTHtu", + "hash160result": "568af36801cfae2e1290ecef7a60c7ae0c984a48", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::attestation.provision.object" + } +}; +exports.ATTESTATION_VIEW_REQUEST = { + "vdxfid": "i5R9p3V1sxZ9p1NDV7nPkz1wvmQTUvuByY", + "hash160result": "872923256c56f6bda8256c5bb6a4c98d85f44c15", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::attestation.view.request" + } +}; +exports.ATTESTATION_VIEW_RESPONSE = { + "vdxfid": "i5R9p3V1sxZ9p1NDV7nPkz1wvmQTUvuByY", + "hash160result": "872923256c56f6bda8256c5bb6a4c98d85f44c15", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::attestation.view.response" + } +}; +exports.ATTESTATION_ID = { + "vdxfid": "i87ZC3B5EFiKtLW9fCUkw9yoMVmh2i2bZ3", + "hash160result": "f540229f88da9e3a9f40f99ce5a22afe765ce132", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::attestation.id" + } +}; +exports.ATTESTATION_NAME = { + "vdxfid": "iEEjVkvM9Niz4u2WCr6QQzx1zpVSvDFub1", + "hash160result": "8a00bdd77505b345ed85d7292459b61457a10d76", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::attestation.name" + } +}; +exports.ATTESTATION_TYPE = { + "vdxfid": "iAJUD5mgT6MHz8ymF49XUtBDRS7uvYqNWZ", + "indexid": "xF8aftCmJQZxcJro6jogTGhkT68vqfCDCm", + "hash160result": "e56544849c038b7cfadb0a1074ac51df9207e24a", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::attestation.type" + } +}; +exports.ATTESTATION_VIEW_REQUEST_KEY = { + "vdxfid": "i8iRyLrnapw29BTaHYtu7C3wWPtbjKvEJp", + "indexid": "xDYYS9HsS99gmMLc9EZ45aaUY3ucaC7FDD", + "hash160result": "fa51ed48a3b250818d2fb1efcdf6275fd2e47939", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::attestation.view.request.key" + } +}; +exports.ATTESTATION_VIEW_REQUEST_NAME = { + "vdxfid": "i6psJBVkM3yivumyxuhmAwmMYixiFRD9LT", + "indexid": "xBeykyvqCNCPZ5f1pbMv9LHtaNyjDs5X2m", + "hash160result": "8bb63c962ccec2eced99eb15f958b2d03247c124", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::attestation.view.request.name" + } +}; +exports.ATTESTATION_VIEW_REQUEST_ATTESTOR = { + "vdxfid": "iHuiKHNSLJd6xeUCN8etjnTcGgzhDp9Zug", + "indexid": "xNjpn5oXBcqmapMEDpK3iAz9JM1i7g8cDX", + "hash160result": "1bdced61a4c500114659b9f15759eea89c3e559e", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::attestation.view.request.attestor" + } +}; +exports.ATTESTATION_VIEW_REQUEST_ID = { + "vdxfid": "iSoJNm8wz9Jtv69YvReNyRSzBr8KJSXTym", + "indexid": "xXdQqZa2qTXZYG2an7JXwoyXDW9L9NjTYS", + "hash160result": "70cbf4f61e3d585bcaac692fa9443a9890e5d7ff", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::attestation.view.request.id" + } +}; +exports.PROFILE_DATA_VIEW_REQUEST = { + "vdxfid": "iEocxePWah2zp5Hn4ujeoQpc4UVYeJeQ2g", + "indexid": "xKdjRSpbS1FfSFAovbPomoM968WZVsmW1E", + "hash160result": "b1778ef367dbf00e7b9ad15eea2ef17490e6457c", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::profile.data.view.request" + } +}; +exports.IDENTITY_SIGNDATA_REQUEST = { + "vdxfid": "i8pWCPRLoGD9MgL7HM13xo5Bhr9TsXjGxs", + "indexid": "xDecfBrReaRoyrD992fCwBbijWAUi4yjUN", + "hash160result": "0785689a95a2a08dd2e0efd60b71237e97ea9f3a", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::identity.signdata.request" + } +}; +// DATA TYPES exports.DATA_TYPE_STRING = { "vdxfid": "iK7a5JNJnbeuYWVHCDRpJosj3irGJ5Qa8c", "hash160result": "e5c061641228a399169211e666de18448b7b8bab", diff --git a/dist/vdxf/scopes.d.ts b/dist/vdxf/scopes.d.ts index fa45b71..0c3ccd4 100644 --- a/dist/vdxf/scopes.d.ts +++ b/dist/vdxf/scopes.d.ts @@ -1,3 +1,6 @@ import { VDXFKeyInterface } from "./keys"; export declare const IDENTITY_VIEW: VDXFKeyInterface; export declare const IDENTITY_AGREEMENT: VDXFKeyInterface; +export declare const ATTESTATION_READ_REQUEST: VDXFKeyInterface; +export declare const PROFILE_DATA_READ_REQUEST: VDXFKeyInterface; +export declare const ATTESTATION_RECEIVE_REQUEST: VDXFKeyInterface; diff --git a/dist/vdxf/scopes.js b/dist/vdxf/scopes.js index 59a75f3..e2f1baa 100644 --- a/dist/vdxf/scopes.js +++ b/dist/vdxf/scopes.js @@ -1,6 +1,6 @@ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); -exports.IDENTITY_AGREEMENT = exports.IDENTITY_VIEW = void 0; +exports.ATTESTATION_RECEIVE_REQUEST = exports.PROFILE_DATA_READ_REQUEST = exports.ATTESTATION_READ_REQUEST = exports.IDENTITY_AGREEMENT = exports.IDENTITY_VIEW = void 0; exports.IDENTITY_VIEW = { vdxfid: "iLUrA89mDKnwxZcMiPadfNB9TLp58A2TKU", hash160result: "aeab47faa1b2bde2633a63b8284770a8e5c489ba", @@ -17,3 +17,29 @@ exports.IDENTITY_AGREEMENT = { name: "vrsc::identity.authentication.permission.agree" } }; +exports.ATTESTATION_READ_REQUEST = { + vdxfid: "iNqLaiDJjcADGCvXcQZnPqwTqMXzQbDCFu", + hash160result: "fbd8fe825062b19a9bd26dc51b6f768828115ad4", + qualifiedname: { + namespace: "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + name: "vrsc::identity.attestation.read" + } +}; +exports.PROFILE_DATA_READ_REQUEST = { + vdxfid: "iFYznrRxyHaoJZ91cFDSYGT4szETf4RLRV", + indexid: "xLP7Fes3pboTvj23TvsbWeybueFUatbQQh", + hash160result: "d3f2168aad438c6c6eab8f3384458cbebf027a84", + qualifiedname: { + namespace: "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + name: "vrsc::profile.data.view" + } +}; +exports.ATTESTATION_RECEIVE_REQUEST = { + "vdxfid": "iQxHMa4cGQRMEVFchV7fah2JDqxjcgMAZK", + "indexid": "xVnPpNVh7ie1rf8eZAmpZ5YqFVykaYqC8E", + "hash160result": "b9af87a7313fff9976f29bc6abaffc1674899aeb", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::identity.attestation.receive" + } +}; diff --git a/dist/vdxf/vdxfdatakeys.d.ts b/dist/vdxf/vdxfdatakeys.d.ts new file mode 100644 index 0000000..2103be3 --- /dev/null +++ b/dist/vdxf/vdxfdatakeys.d.ts @@ -0,0 +1,69 @@ +import { VDXFKeyInterface } from "./keys"; +export declare const DataByteKeyName = "vrsc::data.type.byte"; +export declare const DataByteKey: VDXFKeyInterface; +export declare const DataInt16KeyName = "vrsc::data.type.int16"; +export declare const DataInt16Key: VDXFKeyInterface; +export declare const DataUint16KeyName = "vrsc::data.type.uint16"; +export declare const DataUint16Key: VDXFKeyInterface; +export declare const DataInt32KeyName = "vrsc::data.type.int32"; +export declare const DataInt32Key: VDXFKeyInterface; +export declare const DataUint32KeyName = "vrsc::data.type.uint32"; +export declare const DataUint32Key: VDXFKeyInterface; +export declare const DataInt64KeyName = "vrsc::data.type.int64"; +export declare const DataInt64Key: VDXFKeyInterface; +export declare const DataUint64KeyName = "vrsc::data.type.uint64"; +export declare const DataUint64Key: VDXFKeyInterface; +export declare const DataUint160KeyName = "vrsc::data.type.uint160"; +export declare const DataUint160Key: VDXFKeyInterface; +export declare const DataUint256KeyName = "vrsc::data.type.uint256"; +export declare const DataUint256Key: VDXFKeyInterface; +export declare const DataStringKeyName = "vrsc::data.type.string"; +export declare const DataStringKey: VDXFKeyInterface; +export declare const DataVectorKeyName = "vrsc::data.type.vector"; +export declare const DataVectorKey: VDXFKeyInterface; +export declare const DataByteVectorKeyName = "vrsc::data.type.bytevector"; +export declare const DataByteVectorKey: VDXFKeyInterface; +export declare const DataInt32VectorKeyName = "vrsc::data.type.int32vector"; +export declare const DataInt32VectorKey: VDXFKeyInterface; +export declare const DataInt64VectorKeyName = "vrsc::data.type.int64vector"; +export declare const DataInt64VectorKey: VDXFKeyInterface; +export declare const DataCurrencyMapKeyName = "vrsc::data.type.object.currencymap"; +export declare const DataCurrencyMapKey: VDXFKeyInterface; +export declare const DataRatingsKeyName = "vrsc::data.type.object.ratings"; +export declare const DataRatingsKey: VDXFKeyInterface; +export declare const DataURLKeyName = "vrsc::data.type.object.url"; +export declare const DataURLKey: VDXFKeyInterface; +export declare const DataTransferDestinationKeyName = "vrsc::data.type.object.transferdestination"; +export declare const DataTransferDestinationKey: VDXFKeyInterface; +export declare const UTXORefKeyName = "vrsc::data.type.object.utxoref"; +export declare const UTXORefKey: VDXFKeyInterface; +export declare const CrossChainDataRefKeyName = "vrsc::data.type.object.crosschaindataref"; +export declare const CrossChainDataRefKey: VDXFKeyInterface; +export declare const EncryptionDescriptorKeyName = "vrsc::data.type.encryptiondescriptor"; +export declare const EncryptionDescriptorKey: VDXFKeyInterface; +export declare const SaltedDataKeyName = "vrsc::data.type.salteddata"; +export declare const SaltedDataKey: VDXFKeyInterface; +export declare const DataDescriptorKeyName = "vrsc::data.type.object.datadescriptor"; +export declare const DataDescriptorKey: VDXFKeyInterface; +export declare const SignatureDataKeyName = "vrsc::data.signaturedata"; +export declare const SignatureDataKey: VDXFKeyInterface; +export declare const VectorUint256KeyName = "vrsc::data.mmrhashes"; +export declare const VectorUint256Key: VDXFKeyInterface; +export declare const MMRLinksKeyName = "vrsc::data.mmrlinks"; +export declare const MMRLinksKey: VDXFKeyInterface; +export declare const MMRDescriptorKeyName = "vrsc::data.mmrdescriptor"; +export declare const MMRDescriptorKey: VDXFKeyInterface; +export declare const TypeDefinitionKeyName = "vrsc::data.type.typedefinition"; +export declare const TypeDefinitionKey: VDXFKeyInterface; +export declare const MultiMapKeyName = "vrsc::identity.multimapkey"; +export declare const MultiMapKey: VDXFKeyInterface; +export declare const ContentMultiMapRemoveKeyName = "vrsc::identity.multimapremove"; +export declare const ContentMultiMapRemoveKey: VDXFKeyInterface; +export declare const ProfileMediaKeyName = "vrsc::identity.profile.media"; +export declare const ProfileMediaKey: VDXFKeyInterface; +export declare const ZMemoMessageKeyName = "vrsc::system.zmemo.message"; +export declare const ZMemoMessageKey: VDXFKeyInterface; +export declare const ZMemoSignatureKeyName = "vrsc::system.zmemo.signature"; +export declare const ZMemoSignatureKey: VDXFKeyInterface; +export declare const CurrencyStartNotarizationKeyName = "vrsc::system.currency.startnotarization"; +export declare const CurrencyStartNotarizationKey: VDXFKeyInterface; diff --git a/dist/vdxf/vdxfdatakeys.js b/dist/vdxf/vdxfdatakeys.js new file mode 100644 index 0000000..d70e41f --- /dev/null +++ b/dist/vdxf/vdxfdatakeys.js @@ -0,0 +1,347 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.VectorUint256Key = exports.VectorUint256KeyName = exports.SignatureDataKey = exports.SignatureDataKeyName = exports.DataDescriptorKey = exports.DataDescriptorKeyName = exports.SaltedDataKey = exports.SaltedDataKeyName = exports.EncryptionDescriptorKey = exports.EncryptionDescriptorKeyName = exports.CrossChainDataRefKey = exports.CrossChainDataRefKeyName = exports.UTXORefKey = exports.UTXORefKeyName = exports.DataTransferDestinationKey = exports.DataTransferDestinationKeyName = exports.DataURLKey = exports.DataURLKeyName = exports.DataRatingsKey = exports.DataRatingsKeyName = exports.DataCurrencyMapKey = exports.DataCurrencyMapKeyName = exports.DataInt64VectorKey = exports.DataInt64VectorKeyName = exports.DataInt32VectorKey = exports.DataInt32VectorKeyName = exports.DataByteVectorKey = exports.DataByteVectorKeyName = exports.DataVectorKey = exports.DataVectorKeyName = exports.DataStringKey = exports.DataStringKeyName = exports.DataUint256Key = exports.DataUint256KeyName = exports.DataUint160Key = exports.DataUint160KeyName = exports.DataUint64Key = exports.DataUint64KeyName = exports.DataInt64Key = exports.DataInt64KeyName = exports.DataUint32Key = exports.DataUint32KeyName = exports.DataInt32Key = exports.DataInt32KeyName = exports.DataUint16Key = exports.DataUint16KeyName = exports.DataInt16Key = exports.DataInt16KeyName = exports.DataByteKey = exports.DataByteKeyName = void 0; +exports.CurrencyStartNotarizationKey = exports.CurrencyStartNotarizationKeyName = exports.ZMemoSignatureKey = exports.ZMemoSignatureKeyName = exports.ZMemoMessageKey = exports.ZMemoMessageKeyName = exports.ProfileMediaKey = exports.ProfileMediaKeyName = exports.ContentMultiMapRemoveKey = exports.ContentMultiMapRemoveKeyName = exports.MultiMapKey = exports.MultiMapKeyName = exports.TypeDefinitionKey = exports.TypeDefinitionKeyName = exports.MMRDescriptorKey = exports.MMRDescriptorKeyName = exports.MMRLinksKey = exports.MMRLinksKeyName = void 0; +exports.DataByteKeyName = "vrsc::data.type.byte"; +exports.DataByteKey = { + "vdxfid": "iBXUHbh4iacbeZnzDRxishvBSrYk2S2k7t", + "indexid": "xGMakQ89ZtqGGjg257csr6SiUWZksGmjWp", + "hash160result": "2e97a8bba443773812341e1d761530d3bba04f58", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::data.type.byte" + } +}; +exports.DataInt16KeyName = "vrsc::data.type.int16"; +exports.DataInt16Key = { + "vdxfid": "iDtTv3wf1Vk3M2Y46RjLPKtttx5hydwtY1", + "indexid": "xJiaNrNjroxhyCR5x7PVMiRRvc6ipg6N9g", + "hash160result": "ee334ebd432db0b24cc2702eda61c28ff44d3872", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::data.type.int16" + } +}; +exports.DataUint16KeyName = "vrsc::data.type.uint16"; +exports.DataUint16Key = { + "vdxfid": "iHn7urT2yVfS7pQn6WGAmCVWh4HBLV24n3", + "indexid": "xNcENet7pot6jzHoxBvKjb23iiJCGpekDk", + "hash160result": "5cfc322d2a216145f7b82714115e7953269de59c", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::data.type.uint16" + } +}; +exports.DataInt32KeyName = "vrsc::data.type.int32"; +exports.DataInt32Key = { + "vdxfid": "iHpLPprRDv3H5H3ZMaJ9nyHFzkG9xJWZDb", + "indexid": "xNeSrdHW5EFwhSvbDFxJmMoo2QHAtoEaEM", + "hash160result": "3e9ba478b23b13232f28d21051d907ce8fdd509d", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::data.type.int32" + } +}; +exports.DataUint32KeyName = "vrsc::data.type.uint32"; +exports.DataUint32Key = { + "vdxfid": "iKSj5zhd6cSsLudaGhtfmisRNgEM7SPFWY", + "indexid": "xQGqYo8hwvfXy5Wc8PYpk7PxQLFMwfP7Fp", + "hash160result": "f279818aeb4fe768956b350d1fc7216ca0e82aaf", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::data.type.uint32" + } +}; +exports.DataInt64KeyName = "vrsc::data.type.int64"; +exports.DataInt64Key = { + "vdxfid": "iKB3TGi9Dg5HZ4nQAgLQAgp3tuXBaRKHpC", + "indexid": "xQ19v59E4zHxBEfS2MzZ95LavZYCTTeuyg", + "hash160result": "ab3705f8a7fae59786ef897b014df85fcd9533ac", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::data.type.int64" + } +}; +exports.DataUint64KeyName = "vrsc::data.type.uint64"; +exports.DataUint64Key = { + "vdxfid": "iPamkQf38AeGQ8z4zSsZL7t9kXMeUkYLJL", + "indexid": "xUQtDD67yUrw2Js6r8XiJWQgnBNfNeeoUq", + "hash160result": "bb2ae9ed3e9f400def0724937fbf65f23ef690dc", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::data.type.uint64" + } +}; +exports.DataUint160KeyName = "vrsc::data.type.uint160"; +exports.DataUint160Key = { + "vdxfid": "iAAwdbLyKYL39nJ1eQHaHtb75krg4mV1Lq", + "indexid": "xF146Pn4ArYhmxB3W5wjGH7e7Qsgx9bkpj", + "hash160result": "d97d2295d4c73f6f6f0697c8086bd822d6977549", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::data.type.uint160" + } +}; +exports.DataUint256KeyName = "vrsc::data.type.uint256"; +exports.DataUint256Key = { + "vdxfid": "i8k7g7z6grtGYrNZmZr5TQ872aHssXuuua", + "indexid": "xDaE8vRBYB6wB2FbdFWERnee4EJtjbCtMM", + "hash160result": "939b27bea698d180237c40b2194025acc673cb39", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::data.type.uint256" + } +}; +exports.DataStringKeyName = "vrsc::data.type.string"; +exports.DataStringKey = { + "vdxfid": "iK7a5JNJnbeuYWVHCDRpJosj3irGJ5Qa8c", + "indexid": "xPwgY6oPdusaAgNK3u5yHCQG5NsHEcBpi5", + "hash160result": "e5c061641228a399169211e666de18448b7b8bab", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::data.type.string" + } +}; +// this is a key for a typed vector, which will have the object type key following the vector key +exports.DataVectorKeyName = "vrsc::data.type.vector"; +exports.DataVectorKey = { + "vdxfid": "iAEShwk1xjdGhaUSz3Maa2XR32o3vRuHq7", + "indexid": "xF4ZAkB6p3qwKkMUqj1jYR3x4gp4mGz657", + "hash160result": "503875b0dc301189a98927d3ece56c5f921c1f4a", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::data.type.vector" + } +}; +exports.DataByteVectorKeyName = "vrsc::data.type.bytevector"; +exports.DataByteVectorKey = { + "vdxfid": "iKMhRLX1JHQihVZx2t2pAWW2uzmK6AzwW3", + "indexid": "xQBot8x69bdPKfSytZgy8u2ZwenKzVjR4X", + "hash160result": "cc3ae6466006629f5105f71325bb2a19107037ae", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::data.type.bytevector" + } +}; +exports.DataInt32VectorKeyName = "vrsc::data.type.int32vector"; +exports.DataInt32VectorKey = { + "vdxfid": "iJZt2fcUv1iivbfC3tuPuefabcTppQEoVq", + "indexid": "xPPzVU3ZmKwPYmYDuaZYt3C7dGUqk939N7", + "hash160result": "c0847f3025c408059b5a8f6a9e414a8ed8288da5", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::data.type.int32vector" + } +}; +exports.DataInt64VectorKeyName = "vrsc::data.type.int64vector"; +exports.DataInt64VectorKey = { + "vdxfid": "i4qtYkFS9iNyu2AkqwoSn1xyCdfH9PUvak", + "indexid": "x9g11YgX12beXC3nhdTbkQVWEHgJ2jqfz1", + "hash160result": "c6219ea13884987453692cb14c72d5f6a47c020f", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::data.type.int64vector" + } +}; +exports.DataCurrencyMapKeyName = "vrsc::data.type.object.currencymap"; +exports.DataCurrencyMapKey = { + "vdxfid": "iMrGhzkZq5fpWWSa1RambRySFPb7CuvKuX", + "indexid": "xSgPAoBegPtV8gKbs7EvZpVyH3c858ZUvL", + "hash160result": "25db70c2fcae2571f89201181bec04587e1f8fc9", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::data.type.object.currencymap" + } +}; +exports.DataRatingsKeyName = "vrsc::data.type.object.ratings"; +exports.DataRatingsKey = { + "vdxfid": "iHJComZUXXGniLkDhjYprWYEN8qvQGDoam", + "indexid": "xN8KGZzZNqVTLWdFZRCypu4mPnrwHFKbCK", + "hash160result": "32cad57ff1dc5db4b5ba573ce01bc9c89b0d9e97", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::data.type.object.ratings" + } +}; +exports.DataURLKeyName = "vrsc::data.type.object.url"; +exports.DataURLKey = { + "vdxfid": "iJ7xdhJTJAvJubNnSJFXyA3jujzqGxjLuZ", + "indexid": "xNx56VjY9V8yXmFpHyugwYaGwQ1rCt6J9W", + "hash160result": "7748bfaf53dd2ff63ed5f73a41174c360f30a6a0", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::data.type.object.url" + } +}; +exports.DataTransferDestinationKeyName = "vrsc::data.type.object.transferdestination"; +exports.DataTransferDestinationKey = { + "vdxfid": "i91L6zwZQrkbNVMB1AZ1Z671qybexRmeVK", + "indexid": "xDqSZoNeGAyFzfECrrDAXUdYsdcfs3Zuku", + "hash160result": "92f38773849383146037b16a48ea350c1c11ac3c", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::data.type.object.transferdestination" + } +}; +exports.UTXORefKeyName = "vrsc::data.type.object.utxoref"; +exports.UTXORefKey = { + "vdxfid": "iNcKvh7mazaXptzHf85q6EtpFYFE7asKC1", + "indexid": "xTSSPVYrSJoCT4sKWojz4dRMHCGF3h9tM4", + "hash160result": "013e760f7451c289672993ea391ae643c21ce4d1", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::data.type.object.utxoref" + } +}; +exports.CrossChainDataRefKeyName = "vrsc::data.type.object.crosschaindataref"; +exports.CrossChainDataRefKey = { + "vdxfid": "iP3euVSzNcXUrLNHnQnR9G6q8jeYuGSxgw", + "indexid": "xTsmNHt5Dvk9UWFKe6Sa7edNAPfZmJVgLc", + "hash160result": "4d33e0aee0f648c7871b2661d1221b57c05aaed6", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::data.type.object.crosschaindataref" + } +}; +exports.EncryptionDescriptorKeyName = "vrsc::data.type.encryptiondescriptor"; +exports.EncryptionDescriptorKey = { + "vdxfid": "iHEEK8ipj58BeKZNWuaaR2tDR5RK2kmf9A", + "indexid": "xN4Lmw9uaPLrGVSQNbEjPRQkSjSKxsHUQu", + "hash160result": "8d021acc1b68335bd7d37b28ff773c138ea5dd96", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::data.type.encryptiondescriptor" + } +}; +exports.SaltedDataKeyName = "vrsc::data.type.salteddata"; +exports.SaltedDataKey = { + "vdxfid": "i92U1nLuLJkC44FZZ4Lq9zk4qW3HrWAWNo", + "indexid": "xDraUamzBcxrgE8bQjzz8PGbsA4JiFskTD", + "hash160result": "9e13510e01d0d03a7bc90d7a2ef32824f515e33c", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::data.type.salteddata" + } +}; +exports.DataDescriptorKeyName = "vrsc::data.type.object.datadescriptor"; +exports.DataDescriptorKey = { + "vdxfid": "i4GC1YGEVD21afWudGoFJVdnfjJ5XWnCQv", + "indexid": "x96JULhKLXEgCqPwUxTQGtAKhPK6Qh1iaW", + "hash160result": "4d4f12424ded2033a526a4e2a8835fc5b2eba208", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::data.type.object.datadescriptor" + } +}; +exports.SignatureDataKeyName = "vrsc::data.signaturedata"; +exports.SignatureDataKey = { + "vdxfid": "i7PcVF9wwPtQ6p6jDtCVpohX65pTZuP2ah", + "indexid": "xCDix3b2ni74iyym5ZreoCE47jqUTBFRAb", + "hash160result": "b48b359e9a00042cec64f7f66ac717d388a4f22a", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::data.signaturedata" + } +}; +exports.VectorUint256KeyName = "vrsc::data.mmrhashes"; +exports.VectorUint256Key = { + "vdxfid": "i9UgJ2WxGw95PKdoCXjpfnBShtP5gi9fxS", + "indexid": "xEJnkpx38FMk1VWq4DPyeAhyjYQ6X5Gsti", + "hash160result": "8c1afd59e904f6d2702699963abccbc6d326d841", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::data.mmrhashes" + } +}; +exports.MMRLinksKeyName = "vrsc::data.mmrlinks"; +exports.MMRLinksKey = { + "vdxfid": "iPQsnA1R8UjHNddZKZ3FxsuKQ5WzKqSC7w", + "indexid": "xUEzExSVynwwzoWbBEhQwGRrRjY1Bc2MYc", + "hash160result": "f535a4e9ac0f94eda01695d16489a4a102d6b1da", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::data.mmrlinks" + } +}; +exports.MMRDescriptorKeyName = "vrsc::data.mmrdescriptor"; +exports.MMRDescriptorKey = { + "vdxfid": "i9dVDb4LgfMYrZD1JBNP2uaso4bNAkT4Jr", + "indexid": "xETbgPVRXyaDUj639s2Y1J7QpicP4DvZMt", + "hash160result": "97273a4c02d6be002f8d69c3979616732ba68243", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::data.mmrdescriptor" + } +}; +exports.TypeDefinitionKeyName = "vrsc::data.type.typedefinition"; +exports.TypeDefinitionKey = { + "vdxfid": "iL5MPPHWXQEY3p2Q1UsmGDvXsgPiqd1W1S", + "indexid": "xQuTrBibNiTCfyuRsAXvEcT4uLQjhxrpyL", + "hash160result": "ae8d805d9650c0512a6b6ec33e963386542f18b6", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::data.type.typedefinition" + } +}; +exports.MultiMapKeyName = "vrsc::identity.multimapkey"; +exports.MultiMapKey = { + "vdxfid": "i3mbggp3NBR77C5JeFQJTpAxmgMidayLLE", + "indexid": "x8bi9VF8DVdmjMxLVw4TSChVoLNjUyapgs", + "hash160result": "6920bb81b420bc95e29a10ed677379b1e39e3a03", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::identity.multimapkey" + } +}; +exports.ContentMultiMapRemoveKeyName = "vrsc::identity.multimapremove"; +exports.ContentMultiMapRemoveKey = { + "vdxfid": "i5Zkx5Z7tEfh42xtKfwbJ5LgEWE9rEgpFY", + "indexid": "xAPsQszCjYtMgCqvBMbkGTsDGAFAmrN33A", + "hash160result": "d393b986e4f82db7bec82d97b186882d739ded16", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::identity.multimapremove" + } +}; +// for any ID, this key indexes content that applies to representing the profile of +// that ID. there may be many mime-type instances of a particular piece of profile media +exports.ProfileMediaKeyName = "vrsc::identity.profile.media"; +exports.ProfileMediaKey = { + "vdxfid": "iEYsp2njSt1M4EVYi9uuAPBU2wpKmThkkr", + "indexid": "xKNzGqDpJCE1gQNaZqa48mi14bqLaG669g", + "hash160result": "e95b2ee1abb130a93900ddaef2d8e528010f7c79", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::identity.profile.media" + } +}; +exports.ZMemoMessageKeyName = "vrsc::system.zmemo.message"; +exports.ZMemoMessageKey = { + "vdxfid": "iNHg1n828PUxktkYeNxC6sdVmuKTipn3L3", + "indexid": "xT7nUaZ6yhhdP4daW4cM5GA2oZLUaNVaBD", + "hash160result": "4a8f418203621f10d1a61701be8dbbbb38fa5cce", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::system.zmemo.message" + } +}; +exports.ZMemoSignatureKeyName = "vrsc::system.zmemo.signature"; +exports.ZMemoSignatureKey = { + "vdxfid": "i7mrLLjUfGYuHJwnsxFvd282hsdn4staJG", + "indexid": "xCbxo9AZWamZuUppjdv5bQeZjXeo1vbaCc", + "hash160result": "7b47c8cd90c4c3ddc542f37ca77473b7325a272f", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::system.zmemo.signature" + } +}; +exports.CurrencyStartNotarizationKeyName = "vrsc::system.currency.startnotarization"; +exports.CurrencyStartNotarizationKey = { + "vdxfid": "iRvxVcGLaCXcDiAfnQ5FfeBCo2AiBibAft", + "indexid": "xWm4xQhRRWkGqt3he5jQe2hjpgBj5C7Tj3", + "hash160result": "b537201ca6465976bea7bdb03119644a858052f6", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::system.currency.startnotarization" + } +}; diff --git a/package.json b/package.json index 6c52f9d..72e5a45 100644 --- a/package.json +++ b/package.json @@ -21,6 +21,7 @@ "license": "MIT", "dependencies": { "base64url": "3.0.1", + "blake2b": "https://github.com/VerusCoin/blake2b", "bn.js": "5.2.1", "bs58check": "2.0.0", "create-hash": "1.2.0", diff --git a/src/__tests__/attestation/attestation.test.ts b/src/__tests__/attestation/attestation.test.ts new file mode 100644 index 0000000..c7f730a --- /dev/null +++ b/src/__tests__/attestation/attestation.test.ts @@ -0,0 +1,186 @@ +import { + LOGIN_CONSENT_ATTESTATION_WEBHOOK_VDXF_KEY, + PROFILE_DATA_VIEW_REQUEST, + LOGIN_CONSENT_PERSONALINFO_WEBHOOK_VDXF_KEY, + IDENTITY_VIEW, + LOGIN_CONSENT_REDIRECT_VDXF_KEY, + IDENTITY_PERSONALDETAILS, + IDENTITY_CONTACTDETAILS, + IDENTITY_LOCATION, + IDENTITY_BANKINGDETAILS, + IDENTITY_DOCUMENTS, + ATTESTATION_PROVISION_TYPE, + ATTESTATION_PROVISION_OBJECT +} from "../../vdxf"; + +import { Attestation, LoginConsentRequest } from "../../vdxf/classes"; +import { RedirectUri, RequestedPermission } from "../../vdxf/classes/Challenge"; +import { Context } from "../../vdxf/classes/Context"; +import { Subject } from "../../vdxf/classes/Challenge"; +import { DataDescriptor } from "../../pbaas/DataDescriptor"; +import { toBase58Check, fromBase58Check } from '../../utils/address'; + +describe('Serializes and deserializes attestation request', () => { + + test("request profile information to Create an Attestation", async () => { + + const profileInfoRequest = new LoginConsentRequest({ + system_id: "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + signing_id: "iB5PRXMHLYcNtM8dfLB6KwfJrHU2mKDYuU", + signature: { + signature: + "AYG2IQABQSAN1fp6A9NIVbxvKuOVLLU+0I+G3oQGbRtS6u4Eampfb217Cdf5FCMScQhV9kMxtjI9GWzpchmjuiTB2tctk6qT", + }, + challenge: { + challenge_id: "iMqzCkWdebC19xbjkLfVdDkkGP9Ni1oxoN", + requested_access: [ + new RequestedPermission(IDENTITY_VIEW.vdxfid), + new RequestedPermission(PROFILE_DATA_VIEW_REQUEST.vdxfid, [IDENTITY_PERSONALDETAILS.vdxfid, IDENTITY_CONTACTDETAILS.vdxfid, IDENTITY_LOCATION.vdxfid, IDENTITY_BANKINGDETAILS.vdxfid, IDENTITY_DOCUMENTS.vdxfid]), + new RequestedPermission(LOGIN_CONSENT_PERSONALINFO_WEBHOOK_VDXF_KEY.vdxfid), + new RequestedPermission(LOGIN_CONSENT_REDIRECT_VDXF_KEY.vdxfid), + ], + redirect_uris: [new RedirectUri( + "https://example.com/sendpersonaldata", + LOGIN_CONSENT_PERSONALINFO_WEBHOOK_VDXF_KEY.vdxfid) + ], + subject: [], + provisioning_info: [], // + created_at: Number((Date.now() / 1000).toFixed(0)), + } + }); + + const serializedRequest = profileInfoRequest.toBuffer().toString('hex'); // Serialize the request to a hex string + const newProfileInfoRequest = new LoginConsentRequest(); + + newProfileInfoRequest.fromBuffer(Buffer.from(serializedRequest, 'hex')); // Deserialize the request from the hex string + expect(serializedRequest).toStrictEqual(newProfileInfoRequest.toBuffer().toString('hex')) // Compare the original serialized request to the new serialized request + }); + + test("send attestation to a user", async () => { + const req = new LoginConsentRequest({ + system_id: "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + signing_id: "iB5PRXMHLYcNtM8dfLB6KwfJrHU2mKDYuU", + signature: { + signature: + "AYG2IQABQSAN1fp6A9NIVbxvKuOVLLU+0I+G3oQGbRtS6u4Eampfb217Cdf5FCMScQhV9kMxtjI9GWzpchmjuiTB2tctk6qT", + }, + challenge: { + challenge_id: "iKNufKJdLX3Xg8qFru9AuLBvivAEJ88PW4", + requested_access: [new RequestedPermission(IDENTITY_VIEW.vdxfid)], + session_id: "iRQZGW36o3RcVR1xyVT1qWdAKdxp3wUyrh", + redirect_uris: [ + new RedirectUri( + "https://www.verus.io", + LOGIN_CONSENT_ATTESTATION_WEBHOOK_VDXF_KEY.vdxfid + ), + ], + created_at: 1664382484, + salt: "i6NawEzHMocZnU4h8pPkGpHApvsrHjxwXE", + context: new Context({ + ["i4KyLCxWZXeSkw15dF95CUKytEK3HU7em9"]: "test", + }), + }, + }); + + const serializedRequest = req.toBuffer().toString('hex'); // Serialize the request to a hex string + const newProfileInfoRequest = new LoginConsentRequest(); + + newProfileInfoRequest.fromBuffer(Buffer.from(serializedRequest, 'hex')); // Deserialize the request from the hex string + expect(serializedRequest).toStrictEqual(newProfileInfoRequest.toBuffer().toString('hex')) // Compare the original serialized request to the new serialized request + + }); + + test('attestation provision serialize and deserialize', async () => { + + const attestationDataDescriptor = DataDescriptor.fromJson({ + version: 1, + "flags": 2, + "objectdata": { + "i4GC1YGEVD21afWudGoFJVdnfjJ5XWnCQv": { + "version": 1, + "flags": 96, + "mimetype": "text/plain", + "objectdata": { + "message": "John" + }, + "label": "i4GqsotHGa4czCdtg2d8FVHKfJFzVyBPrM" + } + }, + "salt": "4f66603f256d3f757b6dc3ea44802d4041d2a1901e06005028fd60b85a5878a2" + }); + + const attestationitem = Buffer.concat([fromBase58Check(ATTESTATION_PROVISION_TYPE.vdxfid).hash, + Buffer.from([0x01]), + attestationDataDescriptor.toBuffer()]); + + const attestationObject = new Attestation(attestationitem.toString('hex'), ATTESTATION_PROVISION_OBJECT.vdxfid); + + const req = new LoginConsentRequest({ + system_id: "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + signing_id: "iB5PRXMHLYcNtM8dfLB6KwfJrHU2mKDYuU", + signature: { + signature: + "AYG2IQABQSAN1fp6A9NIVbxvKuOVLLU+0I+G3oQGbRtS6u4Eampfb217Cdf5FCMScQhV9kMxtjI9GWzpchmjuiTB2tctk6qT", + }, + challenge: { + challenge_id: "iKNufKJdLX3Xg8qFru9AuLBvivAEJ88PW4", + requested_access: [new RequestedPermission(IDENTITY_VIEW.vdxfid)], + session_id: "iRQZGW36o3RcVR1xyVT1qWdAKdxp3wUyrh", + redirect_uris: [ + new RedirectUri( + "https://www.verus.io", + LOGIN_CONSENT_REDIRECT_VDXF_KEY.vdxfid + ), + ], + created_at: 1664382484, + salt: "i6NawEzHMocZnU4h8pPkGpHApvsrHjxwXE", + context: new Context({ + ["i4KyLCxWZXeSkw15dF95CUKytEK3HU7em9"]: "test", + }), + attestations: [attestationObject] + }, + }); + + const serializedRequest = req.toBuffer().toString('hex'); // Serialize the request to a hex string + const attestationProvisionRequest = new LoginConsentRequest(); + + attestationProvisionRequest.fromBuffer(Buffer.from(serializedRequest, 'hex')); // Deserialize the request from the hex string + expect(serializedRequest).toStrictEqual(attestationProvisionRequest.toBuffer().toString('hex')) // Compare the original serialized request to the new serialized request + + }); + + test("request profile information to Create an Attestation", async () => { + + const profileInfoRequest = new LoginConsentRequest({ + system_id: "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + signing_id: "iB5PRXMHLYcNtM8dfLB6KwfJrHU2mKDYuU", + signature: { + signature: + "AYG2IQABQSAN1fp6A9NIVbxvKuOVLLU+0I+G3oQGbRtS6u4Eampfb217Cdf5FCMScQhV9kMxtjI9GWzpchmjuiTB2tctk6qT", + }, + challenge: { + challenge_id: "iMqzCkWdebC19xbjkLfVdDkkGP9Ni1oxoN", + requested_access: [ + new RequestedPermission(IDENTITY_VIEW.vdxfid, [IDENTITY_PERSONALDETAILS.vdxfid, IDENTITY_CONTACTDETAILS.vdxfid, IDENTITY_LOCATION.vdxfid, IDENTITY_BANKINGDETAILS.vdxfid, IDENTITY_DOCUMENTS.vdxfid]), + new RequestedPermission(PROFILE_DATA_VIEW_REQUEST.vdxfid), // change to array + new RequestedPermission(LOGIN_CONSENT_PERSONALINFO_WEBHOOK_VDXF_KEY.vdxfid), + new RequestedPermission(LOGIN_CONSENT_REDIRECT_VDXF_KEY.vdxfid), + ], + redirect_uris: [new RedirectUri( + "https://example.com/sendpersonaldata", + LOGIN_CONSENT_PERSONALINFO_WEBHOOK_VDXF_KEY.vdxfid) + ], + subject: [], + provisioning_info: [], // + created_at: Number((Date.now() / 1000).toFixed(0)), + } + }); + + const serializedRequest = profileInfoRequest.toBuffer().toString('hex'); // Serialize the request to a hex string + const newProfileInfoRequest = new LoginConsentRequest(); + + newProfileInfoRequest.fromBuffer(Buffer.from(serializedRequest, 'hex')); // Deserialize the request from the hex string + expect(serializedRequest).toStrictEqual(newProfileInfoRequest.toBuffer().toString('hex')) // Compare the original serialized request to the new serialized request + }); + +}); diff --git a/src/__tests__/attestation/personalInfo.test.ts b/src/__tests__/attestation/personalInfo.test.ts new file mode 100644 index 0000000..6d71fac --- /dev/null +++ b/src/__tests__/attestation/personalInfo.test.ts @@ -0,0 +1,226 @@ +import { DataDescriptor } from "../../pbaas/DataDescriptor"; +import { MMRDescriptor, MMRDescriptorJson } from "../../pbaas/MMRDescriptor"; +import { SignatureData } from "../../pbaas/SignatureData"; + +describe('Create a personal info request', () => { + test('serialize datadescriptor with nested datadescriptor', async () => { + + const personalDataCategory = DataDescriptor.fromJson({ + version: 1, + "flags": 2, + "objectdata": { + "i4GC1YGEVD21afWudGoFJVdnfjJ5XWnCQv": { + "version": 1, + "flags": 96, + "mimetype": "text/plain", + "objectdata": { + "message": "John" + }, + "label": "i4GqsotHGa4czCdtg2d8FVHKfJFzVyBPrM" + } + }, + "salt": "4f66603f256d3f757b6dc3ea44802d4041d2a1901e06005028fd60b85a5878a2" + }); + + const initialDescriptor = personalDataCategory.toBuffer().toString('hex'); + const newDescriptor = new DataDescriptor(); + + newDescriptor.fromBuffer(Buffer.from(initialDescriptor, 'hex')); + + expect(initialDescriptor).toStrictEqual(newDescriptor.toBuffer().toString('hex')); + + }); + + test('serialize and deserialize a mmrdescriptor', async () => { + + const mmrdescriptor: MMRDescriptorJson = { + "version": 1, + "objecthashtype": 5, + "mmrhashtype": 1, + "mmrroot": { + "version": 1, + "flags": 0, + "objectdata": "30395e0868b1953477e14bb5c16349622239a94115a4d1f02b72b6ecf8b1c79c" + }, + "mmrhashes": { + "version": 1, + "flags": 0, + "objectdata": "41d826d3c6cbbc3a96992670d2f604e959fd1a8c014102f1eac8f180bee7fb256b801b219e20612fbc9f5e99da111a8364d1197ff3e3fbef8259770f618dacee9489e8cd2cd5dd77d36ede6c42cebdabd85a5b5e8af60b" + }, + "datadescriptors": [ + { + "version": 1, + "flags": 2, + "objectdata": { + "i4GC1YGEVD21afWudGoFJVdnfjJ5XWnCQv": { + "version": 1, + "flags": 96, + "mimetype": "text/plain", + "objectdata": { + "message": "Chris" + }, + "label": "i4GqsotHGa4czCdtg2d8FVHKfJFzVyBPrM" + } + }, + "salt": "4f66603f256d3f757b6dc3ea44802d4041d2a1901e06005028fd60b85a5878a2" + }, + { + "version": 1, + "flags": 2, + "objectdata": { + "i4GC1YGEVD21afWudGoFJVdnfjJ5XWnCQv": { + "version": 1, + "flags": 96, + "mimetype": "text/plain", + "objectdata": { + "message": "Monkins" + }, + "label": "iHybTrNB1kXRrjsCtJXd6fvBKxepqMpS5Z" + } + }, + "salt": "62fae0c46b2ad1177749e25fd6d48ccb40213d3cc72e4b2b0dc533039cbe8314" + } + ] + } + + const mmrdescriptorBuffer = MMRDescriptor.fromJson(mmrdescriptor); + const initialDescriptor = mmrdescriptorBuffer.toBuffer().toString('hex'); + const newDescriptor = new MMRDescriptor(); + + newDescriptor.fromBuffer(Buffer.from(initialDescriptor, 'hex')); + + expect(initialDescriptor).toStrictEqual(newDescriptor.toBuffer().toString('hex')); + + }); + + test('serialize and deserialize a mmrdescriptor', async () => { + + const mmrdescriptor = { + "version": 1, + "objecthashtype": 5, + "mmrhashtype": 1, + "mmrroot": { + "version": 1, + "flags": 0, + "objectdata": "30395e0868b1953477e14bb5c16349622239a94115a4d1f02b72b6ecf8b1c79c" + }, + "mmrhashes": { + "version": 1, + "flags": 0, + "objectdata": "41d826d3c6cbbc3a96992670d2f604e959fd1a8c014102f1eac8f180bee7fb256b801b219e20612fbc9f5e99da111a8364d1197ff3e3fbef8259770f618dacee9489e8cd2cd5dd77d36ede6c42cebdabd85a5b5e8af60b" + }, + "datadescriptors": [ + { + "version": 1, + "flags": 2, + "objectdata": { + "i4GC1YGEVD21afWudGoFJVdnfjJ5XWnCQv": { + "version": 1, + "flags": 96, + "mimetype": "text/plain", + "objectdata": { + "message": "Chris" + }, + "label": "i4GqsotHGa4czCdtg2d8FVHKfJFzVyBPrM" + } + }, + "salt": "4f66603f256d3f757b6dc3ea44802d4041d2a1901e06005028fd60b85a5878a2" + }, + { + "version": 1, + "flags": 2, + "objectdata": { + "i4GC1YGEVD21afWudGoFJVdnfjJ5XWnCQv": { + "version": 1, + "flags": 96, + "mimetype": "text/plain", + "objectdata": { + "message": "Monkins" + }, + "label": "iHybTrNB1kXRrjsCtJXd6fvBKxepqMpS5Z" + } + }, + "salt": "62fae0c46b2ad1177749e25fd6d48ccb40213d3cc72e4b2b0dc533039cbe8314" + } + ] + } + + const mmrdescriptorBuffer = MMRDescriptor.fromJson(mmrdescriptor); + const initialDescriptor = mmrdescriptorBuffer.toBuffer().toString('hex'); + const newDescriptor = new MMRDescriptor(); + + newDescriptor.fromBuffer(Buffer.from(initialDescriptor, 'hex')); + + expect(initialDescriptor).toStrictEqual(newDescriptor.toBuffer().toString('hex')); + + }); + + test('serialize and deserialize an encrypted mmrdescriptor', async () => { + + const encryptedmmrdescriptor = { + "version": 1, + "objecthashtype": 5, + "mmrhashtype": 1, + "mmrroot": { + "version": 1, + "flags": 5, + "objectdata": "dec21b940a475989ac9220081ec3816a0026921594462841d2155a3d8462bdd8ada9f02cb7b795a01b842dce0a3c5bfe83e57fd46f34b19a67ee716a1e771264db1b7831cd2341a515", + "epk": "bdea4d6f2a88a954bed38de4ed6e7f6ff7d483fc799f1428be2ccfe6f27c87c9" + }, + "mmrhashes": { + "version": 1, + "flags": 5, + "objectdata": "8ad904b879fc67d7f0ceee8accd593549af8225d03772153465c666bb552eff607883d3d07f154a5515e167d9952feb7e3c121033e18ae855cdad782bc7ccbeb8e4737e9fdfcad31dc066695014e8aec572d4de728b8a1dedd740891ee848f85cc5eb16959761d89feafd78ac1e93494d08ea50311fa424c436bdb24b47ff369", + "epk": "7939e04d89b5713ad3a809ba4cedb4b320df8f380a8b5999e24ce4465fe43b18" + }, + "datadescriptors": [ + { + "version": 1, + "flags": 5, + "objectdata": "0e953a1bb2c81f2c101d9439736e9f614e1c289621dedfd4a0ff8455a36473c8023f4c8a35bdc546e8e48e17030cb7bc418ef248705f0873f3a1ce5674b800030294cace9b26d8d5cf06ac5a7a379be8c2a1d3e6643249312cfa83fbfe9f882a8f5cde0ddb4b940a53e5d4e69bacffa571b6e8eca218ee9d02b751c71426e8433aeabe6cf79e54495510626b5c43c690c47ca8770835", + "epk": "c7f2304a170a54dbb97951a93f7444cf689d487e46172f2f5e54923aefe8865e" + }, + { + "version": 1, + "flags": 5, + "objectdata": "05615e1c62f2a0b5311ec1d4e78d7709f3e29ac52e98a87c4222796ee532f457d0f68a4759464d0d7ea72c90177752d7ee179cfcb25d42ff4d19755650443c1f26490d80db903d28423fb38bd32f19f855f50e52b1e53529da16da8755cfc9857a4a4af1bc4327caa691633a79ef718bcf4547abf5d4cc1f26f5f6919711fc99f6de8e351726d828b534aa090bdcdc5987b117fe0c0b2e06", + "epk": "cf066d1ca66ea90a7a3de353e4a7db6fd4f88c7ae2eb47bcef9a78a0c8be6010" + } + ] + } + + const mmrdescriptorBuffer = MMRDescriptor.fromJson(encryptedmmrdescriptor); + const initialDescriptor = mmrdescriptorBuffer.toBuffer().toString('hex'); + const newDescriptor = new MMRDescriptor(); + + newDescriptor.fromBuffer(Buffer.from(initialDescriptor, 'hex')); + + expect(initialDescriptor).toStrictEqual(newDescriptor.toBuffer().toString('hex')); + + }); + + test('serialize and deserialize signaturedata', async () => { + + const signaturedata = { + "version": 1, + "systemid": "iJhCezBExJHvtyH3fGhNnt2NhU4Ztkf2yq", + "hashtype": 1, + "signaturehash": "dfd3e3d82783360dfc675a09e6a226fd43119ef4e8d7cf553af96ea5883b51da", + "identityid": "iKjrTCwoPFRk44fAi2nYNbPG16ZUQjv1NB", + "signaturetype": 1, + "signature": "AgXOCgAAAUEfCiSukK9tg46cYOpHmxzKjNquWDyNc8H58+uLSOYmqlUcNUxWB8j3nzT1RHKeJGygdAwrUj5iZ/A9H3+qYV9H9g==" + } + + const mmrdescriptorBuffer = SignatureData.fromJson(signaturedata); + const initialDescriptor = mmrdescriptorBuffer.toBuffer().toString('hex'); + const newDescriptor = new SignatureData(); + + newDescriptor.fromBuffer(Buffer.from(initialDescriptor, 'hex')); + + expect(initialDescriptor).toStrictEqual(newDescriptor.toBuffer().toString('hex')); + + }); + + + +}); diff --git a/src/__tests__/pbaas/contentMultiMapRemove.test.ts b/src/__tests__/pbaas/contentMultiMapRemove.test.ts new file mode 100644 index 0000000..ecfb030 --- /dev/null +++ b/src/__tests__/pbaas/contentMultiMapRemove.test.ts @@ -0,0 +1,27 @@ +import { ContentMultiMapRemove } from "../../pbaas/ContentMultiMapRemove"; +import { DATA_TYPE_STRING } from "../../vdxf"; +import { VDXF_UNI_VALUE_VERSION_CURRENT, VdxfUniValue } from "../../pbaas/VdxfUniValue"; +import { BN } from 'bn.js'; + +describe('Serializes and deserializes ContentMultiMapRemove', () => { + + function testContentMultiMapRemove() { + const c = new ContentMultiMapRemove({ + version: new BN(1), + action: ContentMultiMapRemove.ACTION_REMOVE_ONE_KEYVALUE, + entry_key: "iPsFBfFoCcxtuZNzE8yxPQhXVn4dmytf8j", + value_hash: Buffer.alloc(32).fill("h") + }); + + const cFromBuf = new ContentMultiMapRemove(); + + cFromBuf.fromBuffer(c.toBuffer()); + + expect(cFromBuf.toBuffer().toString('hex')).toBe(c.toBuffer().toString('hex')); + expect(ContentMultiMapRemove.fromJson(c.toJson()).toBuffer().toString("hex")).toBe(cFromBuf.toBuffer().toString('hex')); + } + + test('test CMMR with vdxfunivalue content', () => { + testContentMultiMapRemove(); + }); +}); \ No newline at end of file diff --git a/src/__tests__/pbaas/crossChainDataRef.test.ts b/src/__tests__/pbaas/crossChainDataRef.test.ts new file mode 100644 index 0000000..dfc31b3 --- /dev/null +++ b/src/__tests__/pbaas/crossChainDataRef.test.ts @@ -0,0 +1,29 @@ +import { CrossChainDataRef, CrossChainDataRefJson } from "../../pbaas/CrossChainDataRef"; +import { URLRef, URLRefJson } from '../../pbaas/URLRef'; +import { DATA_TYPE_STRING } from "../../vdxf"; +import { VDXF_UNI_VALUE_VERSION_CURRENT, VdxfUniValue } from "../../pbaas/VdxfUniValue"; +import { BN } from 'bn.js'; + +describe('Serializes and deserializes CrossChainDataRef', () => { + + function testCrossChainDataRef() { + + const url = new URLRef({ + version: new BN(1), + url: "https://verus.io" + }); + + const c = new CrossChainDataRef(url); + + const cFromBuf = new CrossChainDataRef(); + + cFromBuf.fromBuffer(c.toBuffer()); + + expect(cFromBuf.toBuffer().toString('hex')).toBe(c.toBuffer().toString('hex')); + expect(CrossChainDataRef.fromJson(c.toJson() as CrossChainDataRefJson).toBuffer().toString("hex")).toBe(cFromBuf.toBuffer().toString('hex')); + } + + test('test CCDR with vdxfunivalue content', () => { + testCrossChainDataRef(); + }); + }); \ No newline at end of file diff --git a/src/__tests__/pbaas/currencyValueMap.test.ts b/src/__tests__/pbaas/currencyValueMap.test.ts new file mode 100644 index 0000000..348b680 --- /dev/null +++ b/src/__tests__/pbaas/currencyValueMap.test.ts @@ -0,0 +1,31 @@ +import { CurrencyValueMap } from '../../pbaas/CurrencyValueMap'; +import { URLRef, URLRefJson } from '../../pbaas/URLRef'; +import { DATA_TYPE_STRING } from "../../vdxf"; +import { VDXF_UNI_VALUE_VERSION_CURRENT, VdxfUniValue } from "../../pbaas/VdxfUniValue"; +import { BN } from 'bn.js'; +import { BigNumber } from '../../utils/types/BigNumber'; + +describe('Serializes and deserializes CurrencyValueMap', () => { + + function testCurrencyValueMap() { + + const valueMap = new Map(); + + valueMap.set("i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", new BN(100000)); + + const c = new CurrencyValueMap({ + value_map: valueMap, + }); + + const cFromBuf = new CurrencyValueMap(); + + cFromBuf.fromBuffer(c.toBuffer()); + + expect(cFromBuf.toBuffer().toString('hex')).toBe(c.toBuffer().toString('hex')); + expect(CurrencyValueMap.fromJson(c.toJson()).toBuffer().toString("hex")).toBe(cFromBuf.toBuffer().toString('hex')); + } + + test('test CurrencyValueMap with vdxfunivalue content', () => { + testCurrencyValueMap(); + }); +}); \ No newline at end of file diff --git a/src/__tests__/pbaas/dataDescriptor.test.ts b/src/__tests__/pbaas/dataDescriptor.test.ts new file mode 100644 index 0000000..6e0f9d5 --- /dev/null +++ b/src/__tests__/pbaas/dataDescriptor.test.ts @@ -0,0 +1,207 @@ +import { DataDescriptor, } from "../../pbaas/DataDescriptor"; +import { PBaaSEvidenceRef } from "../../pbaas/PBaaSEvidenceRef"; +import { UTXORef } from "../../pbaas/UTXORef"; +import { URLRef } from "../../pbaas/URLRef"; +import { IdentityMultimapRef } from "../../pbaas/IdentityMultimapRef"; +import { CrossChainDataRef } from "../../pbaas/CrossChainDataRef"; +import { VdxfUniValue } from "../../pbaas/VdxfUniValue"; +import { SignatureData } from "../../pbaas/SignatureData"; +import { TransferDestination, DEST_ID } from "../../pbaas/TransferDestination"; +import * as VDXF_Data from '../../vdxf/vdxfdatakeys'; +import { toBase58Check, fromBase58Check } from '../../utils/address'; +import { BN } from "bn.js"; + +describe('Serializes and deserializes dataDescriptors', () => { + + test('Nested datadescriptor with dataDescriptor in it', async () => { + + const nestedDescriptor = DataDescriptor.fromJson({ + version: 1, + "flags": 2, + "objectdata": { + "i4GC1YGEVD21afWudGoFJVdnfjJ5XWnCQv": { + "version": 1, + "flags": 96, + "mimetype": "text/plain", + "objectdata": { + "message": "Something 1" + }, + "label": "label 1" + } + }, + "salt": "4f66603f256d3f757b6dc3ea44802d4041d2a1901e06005028fd60b85a5878a2" + }); + + const serializedDesc = nestedDescriptor.toBuffer().toString('hex'); // Serialize the request to a hex string + const newDescriptor = new DataDescriptor(); + + newDescriptor.fromBuffer(Buffer.from(serializedDesc, 'hex')); // Deserialize the request from the hex string + expect(serializedDesc).toStrictEqual(newDescriptor.toBuffer().toString('hex')) // Compare the original serialized request to the new serialized request + + }); + + test('Datadescriptor with CrossChainDataRef', async () => { + + const evid = new PBaaSEvidenceRef(); + + evid.version = new BN(1); + evid.flags = new BN(1); //type IS_EVIDENCE = 1 + evid.output = new UTXORef({ hash: Buffer.from('30395e0868b1953477e14bb5c16349622239a94115a4d1f02b72b6ecf8b1c79c', 'hex'), n: new BN(0) }); + evid.object_num = new BN(0); + evid.sub_object = new BN(0); + evid.system_id = "i5v3h9FWVdRFbNHU7DfcpGykQjRaHtMqu7"; + + const crossChainRef = new CrossChainDataRef(evid); + const dataKeyMap = new Map(); + dataKeyMap.set(VDXF_Data.CrossChainDataRefKey.vdxfid, crossChainRef); + const crossChainVector = new VdxfUniValue({ values: dataKeyMap }); + + const nestedDescriptor = DataDescriptor.fromJson({ + version: 1, + "flags": 2, //FLAG_SALT_PRESENT = 2 + "objectdata": crossChainVector.toBuffer().toString('hex'), + "salt": "4f66603f256d3f757b6dc3ea44802d4041d2a1901e06005028fd60b85a5878a2" + }); + + const serializedDesc = nestedDescriptor.toBuffer().toString('hex'); // Serialize the request to a hex string + const newDescriptor = new DataDescriptor(); + + newDescriptor.fromBuffer(Buffer.from(serializedDesc, 'hex')); // Deserialize the request from the hex string + expect(serializedDesc).toStrictEqual(newDescriptor.toBuffer().toString('hex')) // Compare the original serialized request to the new serialized request + expect(newDescriptor.objectdata) + }); + test('Datadescriptor with TransferDestination', async () => { + + const destid = "iCtawpxUiCc2sEupt7Z4u8SDAncGZpgSKm"; + + const txDest = new TransferDestination({ + type: DEST_ID, + destination_bytes: fromBase58Check(destid).hash + }); + + const destinationKeyMap = new Map(); + destinationKeyMap.set(VDXF_Data.CrossChainDataRefKey.vdxfid, txDest); + + const txDestVector = new VdxfUniValue({ values: destinationKeyMap }); + + const nestedDescriptor = DataDescriptor.fromJson({ + version: 1, + "flags": 2, //FLAG_SALT_PRESENT = 2 + "objectdata": txDestVector.toBuffer().toString('hex'), + "salt": "4f66603f256d3f757b6dc3ea44802d4041d2a1901e06005028fd60b85a5878a2" + }); + + const serializedDesc = nestedDescriptor.toBuffer().toString('hex'); // Serialize the request to a hex string + const newDescriptor = new DataDescriptor(); + + newDescriptor.fromBuffer(Buffer.from(serializedDesc, 'hex')); // Deserialize the request from the hex string + expect(serializedDesc).toStrictEqual(newDescriptor.toBuffer().toString('hex')) // Compare the original serialized request to the new serialized request + }); + test('Datadescriptor with SignatureData', async () => { + + const sigData = SignatureData.fromJson({ + "version": 1, + "systemid": "iJhCezBExJHvtyH3fGhNnt2NhU4Ztkf2yq", + "hashtype": 1, + "signaturehash": "dfd3e3d82783360dfc675a09e6a226fd43119ef4e8d7cf553af96ea5883b51da", + "identityid": "iKjrTCwoPFRk44fAi2nYNbPG16ZUQjv1NB", + "signaturetype": 1, + "signature": "AgXOCgAAAUEfCiSukK9tg46cYOpHmxzKjNquWDyNc8H58+uLSOYmqlUcNUxWB8j3nzT1RHKeJGygdAwrUj5iZ/A9H3+qYV9H9g==" + }); + + const sigDataMap = new Map(); + sigDataMap.set(VDXF_Data.CrossChainDataRefKey.vdxfid, sigData); + + const sigUniValue = new VdxfUniValue({ values: sigDataMap }); + + const nestedDescriptor = DataDescriptor.fromJson({ + version: 1, + "flags": 2, //FLAG_SALT_PRESENT = 2 + "objectdata": sigUniValue.toBuffer().toString('hex'), + "salt": "4f66603f256d3f757b6dc3ea44802d4041d2a1901e06005028fd60b85a5878a2" + }); + + const serializedDesc = nestedDescriptor.toBuffer().toString('hex'); // Serialize the request to a hex string + const newDescriptor = new DataDescriptor(); + + newDescriptor.fromBuffer(Buffer.from(serializedDesc, 'hex')); // Deserialize the request from the hex string + expect(serializedDesc).toStrictEqual(newDescriptor.toBuffer().toString('hex')) // Compare the original serialized request to the new serialized request + }); + + test('deserialize and desserialize mmrhashes', async () => { + + const mmrhashes = DataDescriptor.fromJson({ + "version": 1, + "flags": 0, + "objectdata": "41d826d3c6cbbc3a96992670d2f604e959fd1a8c014102c78ee8fa7c01db81cbf60181fc9baa101aa8c07d40c324d771145699168d3b18867a587f139173cf8b961d581fe15bbf15f5d02813a615e54c050d2b6b1cd4ee" + }) + + const initialDescriptor = mmrhashes.toBuffer().toString('hex'); + const newDescriptor = new DataDescriptor(); + + newDescriptor.fromBuffer(Buffer.from(initialDescriptor, 'hex')); + + expect(initialDescriptor).toStrictEqual(newDescriptor.toBuffer().toString('hex')); + + // test to see if the hashed object is the correct size + const hashes = mmrhashes.DecodeHashVector(); + expect(typeof hashes).toStrictEqual('object') + expect(hashes.length).toStrictEqual(2); + expect(hashes[0].length).toStrictEqual(32); + expect(hashes[1].length).toStrictEqual(32); + + }); + test('Datadescriptor with URLRef', async () => { + + const urlRef = new URLRef({ version: new BN(1), url: "https://verus.io" }); + + const urlRefMap = new Map(); + urlRefMap.set(VDXF_Data.CrossChainDataRefKey.vdxfid, urlRef); + + const urlRefUniValue = new VdxfUniValue({ values: urlRefMap }); + + const nestedDescriptor = DataDescriptor.fromJson({ + version: 1, + "flags": 2, //FLAG_SALT_PRESENT = 2 + "objectdata": urlRefUniValue.toBuffer().toString('hex'), + "salt": "4f66603f256d3f757b6dc3ea44802d4041d2a1901e06005028fd60b85a5878a2" + }); + + const serializedDesc = nestedDescriptor.toBuffer().toString('hex'); // Serialize the request to a hex string + const newDescriptor = new DataDescriptor(); + + newDescriptor.fromBuffer(Buffer.from(serializedDesc, 'hex')); // Deserialize the request from the hex string + expect(serializedDesc).toStrictEqual(newDescriptor.toBuffer().toString('hex')) // Compare the original serialized request to the new serialized request + }); + test('Datadescriptor with IdentityMultimapRef', async () => { + + const idMultimap = new IdentityMultimapRef({ + version: new BN(1), + flags: new BN(0), + id_ID: "iJhCezBExJHvtyH3fGhNnt2NhU4Ztkf2yq", + key: "i4GC1YGEVD21afWudGoFJVdnfjJ5XWnCQv", + height_start: new BN(0), + height_end: new BN(0), + data_hash: Buffer.alloc(0), + system_id: "iJhCezBExJHvtyH3fGhNnt2NhU4Ztkf2yq" + }); + + const idMultimapMap = new Map(); + idMultimapMap.set(VDXF_Data.CrossChainDataRefKey.vdxfid, idMultimap); + + const idMultimapUniValue = new VdxfUniValue({ values: idMultimapMap }); + + const nestedDescriptor = DataDescriptor.fromJson({ + version: 1, + "flags": 2, //FLAG_SALT_PRESENT = 2 + "objectdata": idMultimapUniValue.toBuffer().toString('hex'), + "salt": "4f66603f256d3f757b6dc3ea44802d4041d2a1901e06005028fd60b85a5878a2" + }); + + const serializedDesc = nestedDescriptor.toBuffer().toString('hex'); // Serialize the request to a hex string + const newDescriptor = new DataDescriptor(); + + newDescriptor.fromBuffer(Buffer.from(serializedDesc, 'hex')); // Deserialize the request from the hex string + expect(serializedDesc).toStrictEqual(newDescriptor.toBuffer().toString('hex')) // Compare the original serialized request to the new serialized request + }); +}); diff --git a/src/__tests__/pbaas/identity.test.ts b/src/__tests__/pbaas/identity.test.ts index 09ef963..b647270 100644 --- a/src/__tests__/pbaas/identity.test.ts +++ b/src/__tests__/pbaas/identity.test.ts @@ -132,35 +132,29 @@ describe('Serializes and deserializes identity properly', () => { }) test('deserialize a daemon generated VerusID with a contentmultimap without private addr', async () => { - const serializedIdentity = "0300000000000000011472aa70e6a4c0d0ff07541c5fbe4f08cacd89d35b01000000a6ef9ea235635e328124ff3429db9f9e91b64e2d0543687269730250d65f0c3aea3fd55eadf3b6f31f123fe8f9dbe001fdda02ab8b7b8b4418de66e611921699a328126461c0e5018443fdc0027b226172746973744e616d65223a20226976616e40222c2022616c62756d4e616d65223a202274657374416c62756d222c202267656e7265223a2022726f636b222c202275726c223a202268747470733a2f2f2f6a756b65626f78222c20226e6574776f726b4964223a2022726f6f6d66756c222c20227369676e6174757265223a20224167586d4567414141554567774c45516a534f4d44477651394f715859433654706d766c536a2b6c596731374d57336161494d3538634539756657376746344a7966364d2f6e4a4a564d3377466f64496d344972622f545565466a654b43616e35673d3d222c2022747261636b73223a205b7b227265736f757263654964223a20223139343564633964717472673231222c20226e616d65223a20225c75303431325c75303433655c75303433665c75303433625c7530343536205c75303431325c75303435365c75303433345c75303433655c75303433665c75303433625c75303434665c75303434315c75303433655c75303433325c7530343330202d205c75303431325c75303433355c75303434315c75303433645c75303433302028436f766572206279204772616e646d615c7320536d757a6929222c20226475726174696f6e223a203234302e3433327d5d2c2022616c62756d436f766572223a207b227265736f757263654964223a20223931647370387471367273713176227d2c20226172746973744c6f676f223a207b227265736f757263654964223a202272326630366267747a6872386276227d2c2022736c65657665446f63756d656e74223a207b227265736f757263654964223a202235706336307773713335337a736d227d2c2022636f70696573536f6c64223a20302c202272656c6561736554696d657374616d70223a202231363832353539323132222c20227072696365223a207b2256414c55223a20312c202255534443223a203230307d7d652741687b7ab1473754858d7b8b10886945eaf801fddc02ab8b7b8b4418de66e611921699a328126461c0e5018445fdc2027b22616c62756d436f766572223a207b227265736f757263654964223a20223931647370387471367273713176227d2c2022616c62756d4e616d65223a202274657374416c62756d3131222c20226172746973744c6f676f223a207b227265736f757263654964223a202272326630366267747a6872386276227d2c20226172746973744e616d65223a20226976616e40222c202267656e7265223a2022726f636b222c20226e6574776f726b4964223a2022726f6f6d66756c222c20227369676e6174757265223a20224167586d4567414141554567774c45516a534f4d44477651394f715859433654706d766c536a2b6c596731374d57336161494d3538634539756657376746344a7966364d2f6e4a4a564d3377466f64496d344972622f545565466a654b43616e35673d3d222c2022736c65657665446f63756d656e74223a207b227265736f757263654964223a202235706336307773713335337a736d227d2c2022747261636b73223a205b7b226475726174696f6e223a203234302e3433322c20226e616d65223a20225c75303431325c75303433655c75303433665c75303433625c7530343536205c75303431325c75303435365c75303433345c75303433655c75303433665c75303433625c75303434665c75303434315c75303433655c75303433325c7530343330202d205c75303431325c75303433355c75303434315c75303433645c75303433302028436f766572206279204772616e646d615c7320536d757a6929222c20227265736f757263654964223a20223139343564633964717472673231227d5d2c202275726c223a202268747470733a2f2f2f6a756b65626f78222c2022636f70696573536f6c64223a20302c202272656c6561736554696d657374616d70223a202231363832353336313730222c20227072696365223a207b2256414c55223a20312c202255534443223a203230307d7d00dfae84e93ab133b739076354e9fbb2de42887212dfae84e93ab133b739076354e9fbb2de4288721200a6ef9ea235635e328124ff3429db9f9e91b64e2d00000000"; + const serializedIdentity = "0300000000000000021455f51a22c79018a00ced41e758560f5df7d4d35d143e3c1a4f0dc6852eff0b312bec2e4dd382d2939701000000a6ef9ea235635e328124ff3429db9f9e91b64e2d076d6f6e6b696e7301797c0f0128e5d8f2aedd0039a930b1abe12e5be90102040d00f478f668655e60f6b49e2424053166ba2cf24139f478f668655e60f6b49e2424053166ba2cf2413900a6ef9ea235635e328124ff3429db9f9e91b64e2d00000000"; const identity_frombuf = new Identity(); - identity_frombuf.fromBuffer(Buffer.from(serializedIdentity, 'hex'), 0, [[DATA_TYPE_STRING.vdxfid], [DATA_TYPE_STRING.vdxfid]]); + identity_frombuf.fromBuffer(Buffer.from(serializedIdentity, 'hex'), 0, true); expect(identity_frombuf.toBuffer().toString('hex')).toBe(serializedIdentity); const identity_tobuf = new Identity({ version: IDENTITY_VERSION_PBAAS, primary_addresses: [ - KeyID.fromAddress("RKjVHqM4VF2pCfVcwGzKH7CxvfMUE4H6o8") + KeyID.fromAddress("RH7h8p9LN2Yb48SkxzNQ29c1Ltfju8Cd5i"), + KeyID.fromAddress("RExFyRVftxbW8w9e5Xkcixu3YtYjE2kCKX") ], min_sigs: new BN(1), - name: "Chris", + name: "monkins", parent: IdentityID.fromAddress("iJhCezBExJHvtyH3fGhNnt2NhU4Ztkf2yq"), system_id: IdentityID.fromAddress("iJhCezBExJHvtyH3fGhNnt2NhU4Ztkf2yq"), content_multimap: ContentMultiMap.fromJson({ - "iAqxJCbv2veLLHGdantvrzJRupyh3dkT6B": [ - { - "iK7a5JNJnbeuYWVHCDRpJosj3irGJ5Qa8c": "{\"artistName\": \"ivan@\", \"albumName\": \"testAlbum\", \"genre\": \"rock\", \"url\": \"https:///jukebox\", \"networkId\": \"roomful\", \"signature\": \"AgXmEgAAAUEgwLEQjSOMDGvQ9OqXYC6TpmvlSj+lYg17MW3aaIM58cE9ufW7gF4Jyf6M/nJJVM3wFodIm4Irb/TUeFjeKCan5g==\", \"tracks\": [{\"resourceId\": \"1945dc9dqtrg21\", \"name\": \"\\u0412\\u043e\\u043f\\u043b\\u0456 \\u0412\\u0456\\u0434\\u043e\\u043f\\u043b\\u044f\\u0441\\u043e\\u0432\\u0430 - \\u0412\\u0435\\u0441\\u043d\\u0430 (Cover by Grandma\\s Smuzi)\", \"duration\": 240.432}], \"albumCover\": {\"resourceId\": \"91dsp8tq6rsq1v\"}, \"artistLogo\": {\"resourceId\": \"r2f06bgtzhr8bv\"}, \"sleeveDocument\": {\"resourceId\": \"5pc60wsq353zsm\"}, \"copiesSold\": 0, \"releaseTimestamp\": \"1682559212\", \"price\": {\"VALU\": 1, \"USDC\": 200}}" - } - ], - "iChNhyJiQSZ3HumofCBhuASjgupq1m1NgP": [ - { - "iK7a5JNJnbeuYWVHCDRpJosj3irGJ5Qa8c": "{\"albumCover\": {\"resourceId\": \"91dsp8tq6rsq1v\"}, \"albumName\": \"testAlbum11\", \"artistLogo\": {\"resourceId\": \"r2f06bgtzhr8bv\"}, \"artistName\": \"ivan@\", \"genre\": \"rock\", \"networkId\": \"roomful\", \"signature\": \"AgXmEgAAAUEgwLEQjSOMDGvQ9OqXYC6TpmvlSj+lYg17MW3aaIM58cE9ufW7gF4Jyf6M/nJJVM3wFodIm4Irb/TUeFjeKCan5g==\", \"sleeveDocument\": {\"resourceId\": \"5pc60wsq353zsm\"}, \"tracks\": [{\"duration\": 240.432, \"name\": \"\\u0412\\u043e\\u043f\\u043b\\u0456 \\u0412\\u0456\\u0434\\u043e\\u043f\\u043b\\u044f\\u0441\\u043e\\u0432\\u0430 - \\u0412\\u0435\\u0441\\u043d\\u0430 (Cover by Grandma\\s Smuzi)\", \"resourceId\": \"1945dc9dqtrg21\"}], \"url\": \"https:///jukebox\", \"copiesSold\": 0, \"releaseTimestamp\": \"1682536170\", \"price\": {\"VALU\": 1, \"USDC\": 200}}" - } + "iEYsp2njSt1M4EVYi9uuAPBU2wpKmThkkr": [ + "040d" ] }), - revocation_authority: IdentityID.fromAddress("iPsFBfFoCcxtuZNzE8yxPQhXVn4dmytf8j"), - recovery_authority: IdentityID.fromAddress("iPsFBfFoCcxtuZNzE8yxPQhXVn4dmytf8j"), + revocation_authority: IdentityID.fromAddress("iRmBDWNs2WahXDAvS2TEsJyJwwHXhwcs7w"), + recovery_authority: IdentityID.fromAddress("iRmBDWNs2WahXDAvS2TEsJyJwwHXhwcs7w"), unlock_after: new BN(0) }) @@ -168,7 +162,7 @@ describe('Serializes and deserializes identity properly', () => { }); test('deserialize a daemon generated VerusID with a contentmultimap with private addr', async () => { - const serializedIdentity = "03000000000000000114437d73cd0d5b0993b5ada74f7efc1528dc1cbeb201000000a6ef9ea235635e328124ff3429db9f9e91b64e2d0474657374000039a34181d4d91a55d7bd8100580e5eca59265ca439a34181d4d91a55d7bd8100580e5eca59265ca401842ea69656125c777ef462b64990072ff02d1a0199fa5a40a313d4b6a4e77da85a610286f8df1b142fef80a6ef9ea235635e328124ff3429db9f9e91b64e2d00000000"; + const serializedIdentity = "0300000000000000021455f51a22c79018a00ced41e758560f5df7d4d35d143e3c1a4f0dc6852eff0b312bec2e4dd382d2939701000000a6ef9ea235635e328124ff3429db9f9e91b64e2d076d6f6e6b696e7301797c0f0128e5d8f2aedd0039a930b1abe12e5be90102040d00f478f668655e60f6b49e2424053166ba2cf24139f478f668655e60f6b49e2424053166ba2cf2413900a6ef9ea235635e328124ff3429db9f9e91b64e2d00000000"; const identity_frombuf = new Identity(); identity_frombuf.fromBuffer(Buffer.from(serializedIdentity, 'hex')); @@ -180,31 +174,24 @@ describe('Serializes and deserializes identity properly', () => { const identityJson = { "contentmap": {}, "contentmultimap": { - "iAqxJCbv2veLLHGdantvrzJRupyh3dkT6B": [ - { - "iK7a5JNJnbeuYWVHCDRpJosj3irGJ5Qa8c": "{\"artistName\": \"ivan@\", \"albumName\": \"testAlbum\", \"genre\": \"rock\", \"url\": \"https:///jukebox\", \"networkId\": \"roomful\", \"signature\": \"AgXmEgAAAUEgwLEQjSOMDGvQ9OqXYC6TpmvlSj+lYg17MW3aaIM58cE9ufW7gF4Jyf6M/nJJVM3wFodIm4Irb/TUeFjeKCan5g==\", \"tracks\": [{\"resourceId\": \"1945dc9dqtrg21\", \"name\": \"\В\о\п\л\і \В\і\д\о\п\л\я\с\о\в\а - \В\е\с\н\а (Cover by Grandma\\s Smuzi)\", \"duration\": 240.432}], \"albumCover\": {\"resourceId\": \"91dsp8tq6rsq1v\"}, \"artistLogo\": {\"resourceId\": \"r2f06bgtzhr8bv\"}, \"sleeveDocument\": {\"resourceId\": \"5pc60wsq353zsm\"}, \"copiesSold\": 0, \"releaseTimestamp\": \"1682559212\", \"price\": {\"VALU\": 1, \"USDC\": 200}}" - } - ], - "iChNhyJiQSZ3HumofCBhuASjgupq1m1NgP": [ - { - "iK7a5JNJnbeuYWVHCDRpJosj3irGJ5Qa8c": "{\"albumCover\": {\"resourceId\": \"91dsp8tq6rsq1v\"}, \"albumName\": \"testAlbum11\", \"artistLogo\": {\"resourceId\": \"r2f06bgtzhr8bv\"}, \"artistName\": \"ivan@\", \"genre\": \"rock\", \"networkId\": \"roomful\", \"signature\": \"AgXmEgAAAUEgwLEQjSOMDGvQ9OqXYC6TpmvlSj+lYg17MW3aaIM58cE9ufW7gF4Jyf6M/nJJVM3wFodIm4Irb/TUeFjeKCan5g==\", \"sleeveDocument\": {\"resourceId\": \"5pc60wsq353zsm\"}, \"tracks\": [{\"duration\": 240.432, \"name\": \"\В\о\п\л\і \В\і\д\о\п\л\я\с\о\в\а - \В\е\с\н\а (Cover by Grandma\\s Smuzi)\", \"resourceId\": \"1945dc9dqtrg21\"}], \"url\": \"https:///jukebox\", \"copiesSold\": 0, \"releaseTimestamp\": \"1682536170\", \"price\": {\"VALU\": 1, \"USDC\": 200}}" - } + "iEYsp2njSt1M4EVYi9uuAPBU2wpKmThkkr": [ + "040d" ] }, "flags": 0, - "identityaddress": "iPsFBfFoCcxtuZNzE8yxPQhXVn4dmytf8j", + "identityaddress": "iRmBDWNs2WahXDAvS2TEsJyJwwHXhwcs7w", "minimumsignatures": 1, - "name": "Chris", + "name": "monkins", "parent": "iJhCezBExJHvtyH3fGhNnt2NhU4Ztkf2yq", "primaryaddresses": [ - "RKjVHqM4VF2pCfVcwGzKH7CxvfMUE4H6o8" + "RH7h8p9LN2Yb48SkxzNQ29c1Ltfju8Cd5i", + "RExFyRVftxbW8w9e5Xkcixu3YtYjE2kCKX" ], - "recoveryauthority": "iPsFBfFoCcxtuZNzE8yxPQhXVn4dmytf8j", - "revocationauthority": "iPsFBfFoCcxtuZNzE8yxPQhXVn4dmytf8j", + "recoveryauthority": "iRmBDWNs2WahXDAvS2TEsJyJwwHXhwcs7w", + "revocationauthority": "iRmBDWNs2WahXDAvS2TEsJyJwwHXhwcs7w", "systemid": "iJhCezBExJHvtyH3fGhNnt2NhU4Ztkf2yq", "timelock": 0, - "version": 3, - "privateaddress": "zs1wczplx4kegw32h8g0f7xwl57p5tvnprwdmnzmdnsw50chcl26f7tws92wk2ap03ykaq6jyyztfa" + "version": 3 }; const identity_frombuf = Identity.fromJson(identityJson); @@ -394,4 +381,32 @@ describe('Serializes and deserializes identity properly', () => { expect(() => identity_frombuf.upgradeVersion(Identity.VERSION_VERUSID)).toThrowError(); expect(() => identity_frombuf.upgradeVersion(new BN(10))).toThrowError(); }); + test('clear ID contentmultimap', async () => { + const identityJson = { + "flags": 0, + "identityaddress": "iPsFBfFoCcxtuZNzE8yxPQhXVn4dmytf8j", + "minimumsignatures": 1, + "name": "Chris", + "parent": "iJhCezBExJHvtyH3fGhNnt2NhU4Ztkf2yq", + "primaryaddresses": [ + "RKjVHqM4VF2pCfVcwGzKH7CxvfMUE4H6o8" + ], + "recoveryauthority": "iPsFBfFoCcxtuZNzE8yxPQhXVn4dmytf8j", + "revocationauthority": "iPsFBfFoCcxtuZNzE8yxPQhXVn4dmytf8j", + "timelock": 0, + "version": Identity.VERSION_VERUSID.toNumber(), + "privateaddress": "zs1wczplx4kegw32h8g0f7xwl57p5tvnprwdmnzmdnsw50chcl26f7tws92wk2ap03ykaq6jyyztfa" + }; + + const identity_frombuf = Identity.fromJson(identityJson); + + identity_frombuf.clearContentMultiMap(); + + const identity_buf = identity_frombuf.toBuffer(); + + const identity_to_json = new Identity(); + identity_to_json.fromBuffer(identity_buf); + + expect(identity_frombuf.content_multimap.kv_content.size).toBe(0); + }); }); \ No newline at end of file diff --git a/src/__tests__/pbaas/mmrdescriptor.test.ts b/src/__tests__/pbaas/mmrdescriptor.test.ts new file mode 100644 index 0000000..d3ac17f --- /dev/null +++ b/src/__tests__/pbaas/mmrdescriptor.test.ts @@ -0,0 +1,186 @@ +import { DataDescriptor } from "../../pbaas/DataDescriptor"; +import { MMRDescriptor, MMRDescriptorJson } from "../../pbaas/MMRDescriptor"; +import { SignatureData } from "../../pbaas/SignatureData"; + +describe('Create a personal info request', () => { + test('serialize and deserialize a mmrdescriptor', async () => { + + const mmrdescriptor = { + "version": 1, + "objecthashtype": 5, + "mmrhashtype": 1, + "mmrroot": { + "version": 1, + "flags": 5, + "objectdata": "b00ad8606acbf5234700daa308a2c64c1f9466c11d47255a60f8ccf9c74ba82b994a03b9b0331bc6f1bf25bbc8b4453a130d65b6a9dc21f7589967e88e51d930682469b03873c54e77", + "epk": "d89d4a9333fe85519a447b886b6c6c8aabee6fb144e9742b76b745dbdfd83c9a" + }, + "mmrhashes": { + "version": 1, + "flags": 5, + "objectdata": "8207c6db9c149dcaff5f502baf891642e67e7e303c0ba8130f2bff76d8247929bc7ce55fdf66bac03ea808006dc5e71aa12deaff355985c7770ee7a534d9cea2bfc10851ed5c91467083ffb1f746161f5d567b4be5c98d72300e1762697d5f62067d819ac0b35ac2c712c6e8e04cefaecaf759f38f4fa3ff4d3fc4d1dccbb6b8", + "epk": "230df92c25958999741329ed3dafc7825900807cbf6b02becc236ce573158a4f" + }, + "datadescriptors": [ + { + "version": 1, + "flags": 5, + "objectdata": "97c0b93faab9462670a5a13da88d9ca796db968ae9c9f1b88df67c564b73cb63f752248402844522efaa62e5b42ce816d0a9f44ca14efaf6f7fe47d916e77b54266c5cac39c6771e899ebda093c566d33bbf60b4a598ea45bf2f5fb1f0cd782baaf092a880a799e0771144a9e9422eec107e43d23ba9386bb46dde09", + "epk": "d7a908ddf6f4d6261d25c62ca086bb3f570b07d74a59256feed13d64d6fbadd2" + }, + { + "version": 1, + "flags": 5, + "objectdata": "d1ce7cab498d9a87bbf3c8d5f255cf209e87adf01f407751959f2d49f23056597a51240e90d5f758adc92e819f77f698fe754c9ea350c213dbcbffdaeb6d9a55bbaf705af9a375c855e7a8ca486bc65b1bd24c35e13f437a7490ecaffeff0323e7508a6cc4e36c5414b4cd7d3125ffabfa3fe85a56e4f6e539925b", + "epk": "822d2b817613d5eb5daf4893afc57289d0081f8fe225c77e1e4839aa0822b9a5" + } + ] + } + + const mmrdescriptorBuffer = MMRDescriptor.fromJson(mmrdescriptor); + const initialDescriptor = mmrdescriptorBuffer.toBuffer().toString('hex'); + const newDescriptor = new MMRDescriptor(); + + newDescriptor.fromBuffer(Buffer.from(initialDescriptor, 'hex')); + + expect(initialDescriptor).toStrictEqual(newDescriptor.toBuffer().toString('hex')); + expect(mmrdescriptor).toStrictEqual(newDescriptor.toJson()); + + }); + + test('serialize and deserialize an encrypted mmrdescriptor', async () => { + + const serializedDatadescriptor = "010501010549b00ad8606acbf5234700daa308a2c64c1f9466c11d47255a60f8ccf9c74ba82b994a03b9b0331bc6f1bf25bbc8b4453a130d65b6a9dc21f7589967e88e51d930682469b03873c54e7720d89d4a9333fe85519a447b886b6c6c8aabee6fb144e9742b76b745dbdfd83c9a0105808207c6db9c149dcaff5f502baf891642e67e7e303c0ba8130f2bff76d8247929bc7ce55fdf66bac03ea808006dc5e71aa12deaff355985c7770ee7a534d9cea2bfc10851ed5c91467083ffb1f746161f5d567b4be5c98d72300e1762697d5f62067d819ac0b35ac2c712c6e8e04cefaecaf759f38f4fa3ff4d3fc4d1dccbb6b820230df92c25958999741329ed3dafc7825900807cbf6b02becc236ce573158a4f0201057c97c0b93faab9462670a5a13da88d9ca796db968ae9c9f1b88df67c564b73cb63f752248402844522efaa62e5b42ce816d0a9f44ca14efaf6f7fe47d916e77b54266c5cac39c6771e899ebda093c566d33bbf60b4a598ea45bf2f5fb1f0cd782baaf092a880a799e0771144a9e9422eec107e43d23ba9386bb46dde0920d7a908ddf6f4d6261d25c62ca086bb3f570b07d74a59256feed13d64d6fbadd201057bd1ce7cab498d9a87bbf3c8d5f255cf209e87adf01f407751959f2d49f23056597a51240e90d5f758adc92e819f77f698fe754c9ea350c213dbcbffdaeb6d9a55bbaf705af9a375c855e7a8ca486bc65b1bd24c35e13f437a7490ecaffeff0323e7508a6cc4e36c5414b4cd7d3125ffabfa3fe85a56e4f6e539925b20822d2b817613d5eb5daf4893afc57289d0081f8fe225c77e1e4839aa0822b9a5" + const mmrdescriptor = { + "version": 1, + "objecthashtype": 5, + "mmrhashtype": 1, + "mmrroot": { + "version": 1, + "flags": 5, + "objectdata": "b00ad8606acbf5234700daa308a2c64c1f9466c11d47255a60f8ccf9c74ba82b994a03b9b0331bc6f1bf25bbc8b4453a130d65b6a9dc21f7589967e88e51d930682469b03873c54e77", + "epk": "d89d4a9333fe85519a447b886b6c6c8aabee6fb144e9742b76b745dbdfd83c9a" + }, + "mmrhashes": { + "version": 1, + "flags": 5, + "objectdata": "8207c6db9c149dcaff5f502baf891642e67e7e303c0ba8130f2bff76d8247929bc7ce55fdf66bac03ea808006dc5e71aa12deaff355985c7770ee7a534d9cea2bfc10851ed5c91467083ffb1f746161f5d567b4be5c98d72300e1762697d5f62067d819ac0b35ac2c712c6e8e04cefaecaf759f38f4fa3ff4d3fc4d1dccbb6b8", + "epk": "230df92c25958999741329ed3dafc7825900807cbf6b02becc236ce573158a4f" + }, + "datadescriptors": [ + { + "version": 1, + "flags": 5, + "objectdata": "97c0b93faab9462670a5a13da88d9ca796db968ae9c9f1b88df67c564b73cb63f752248402844522efaa62e5b42ce816d0a9f44ca14efaf6f7fe47d916e77b54266c5cac39c6771e899ebda093c566d33bbf60b4a598ea45bf2f5fb1f0cd782baaf092a880a799e0771144a9e9422eec107e43d23ba9386bb46dde09", + "epk": "d7a908ddf6f4d6261d25c62ca086bb3f570b07d74a59256feed13d64d6fbadd2" + }, + { + "version": 1, + "flags": 5, + "objectdata": "d1ce7cab498d9a87bbf3c8d5f255cf209e87adf01f407751959f2d49f23056597a51240e90d5f758adc92e819f77f698fe754c9ea350c213dbcbffdaeb6d9a55bbaf705af9a375c855e7a8ca486bc65b1bd24c35e13f437a7490ecaffeff0323e7508a6cc4e36c5414b4cd7d3125ffabfa3fe85a56e4f6e539925b", + "epk": "822d2b817613d5eb5daf4893afc57289d0081f8fe225c77e1e4839aa0822b9a5" + } + ] + } + const mmrdescriptorFromSerialized = new MMRDescriptor(); + const mmrdescriptorFromJson = MMRDescriptor.fromJson(mmrdescriptor); + + mmrdescriptorFromSerialized.fromBuffer(Buffer.from(serializedDatadescriptor, "hex")); + + const initialDescriptor = mmrdescriptorFromSerialized.toBuffer().toString('hex'); + const newDescriptor = mmrdescriptorFromJson.toBuffer().toString('hex'); + + expect(initialDescriptor).toStrictEqual(newDescriptor); + expect(mmrdescriptorFromJson.toJson()).toStrictEqual(mmrdescriptorFromSerialized.toJson()); + + + }); + + test('serialize and deserialize an encrypted mmrdescriptor', async () => { + + const mmrdescriptor = { + "version": 1, + "objecthashtype": 5, + "mmrhashtype": 1, + "mmrroot": { + "version": 1, + "flags": 5, + "objectdata": "b00ad8606acbf5234700daa308a2c64c1f9466c11d47255a60f8ccf9c74ba82b994a03b9b0331bc6f1bf25bbc8b4453a130d65b6a9dc21f7589967e88e51d930682469b03873c54e77", + "epk": "d89d4a9333fe85519a447b886b6c6c8aabee6fb144e9742b76b745dbdfd83c9a" + }, + "mmrhashes": { + "version": 1, + "flags": 5, + "objectdata": "8207c6db9c149dcaff5f502baf891642e67e7e303c0ba8130f2bff76d8247929bc7ce55fdf66bac03ea808006dc5e71aa12deaff355985c7770ee7a534d9cea2bfc10851ed5c91467083ffb1f746161f5d567b4be5c98d72300e1762697d5f62067d819ac0b35ac2c712c6e8e04cefaecaf759f38f4fa3ff4d3fc4d1dccbb6b8", + "epk": "230df92c25958999741329ed3dafc7825900807cbf6b02becc236ce573158a4f" + }, + "datadescriptors": [ + { + "version": 1, + "flags": 5, + "objectdata": "97c0b93faab9462670a5a13da88d9ca796db968ae9c9f1b88df67c564b73cb63f752248402844522efaa62e5b42ce816d0a9f44ca14efaf6f7fe47d916e77b54266c5cac39c6771e899ebda093c566d33bbf60b4a598ea45bf2f5fb1f0cd782baaf092a880a799e0771144a9e9422eec107e43d23ba9386bb46dde09", + "epk": "d7a908ddf6f4d6261d25c62ca086bb3f570b07d74a59256feed13d64d6fbadd2" + }, + { + "version": 1, + "flags": 5, + "objectdata": "d1ce7cab498d9a87bbf3c8d5f255cf209e87adf01f407751959f2d49f23056597a51240e90d5f758adc92e819f77f698fe754c9ea350c213dbcbffdaeb6d9a55bbaf705af9a375c855e7a8ca486bc65b1bd24c35e13f437a7490ecaffeff0323e7508a6cc4e36c5414b4cd7d3125ffabfa3fe85a56e4f6e539925b", + "epk": "822d2b817613d5eb5daf4893afc57289d0081f8fe225c77e1e4839aa0822b9a5" + } + ] + } + + const mmrdescriptorBuffer = MMRDescriptor.fromJson(mmrdescriptor); + const initialDescriptor = mmrdescriptorBuffer.toBuffer().toString('hex'); + const newDescriptor = new MMRDescriptor(); + + newDescriptor.fromBuffer(Buffer.from(initialDescriptor, 'hex')); + + expect(initialDescriptor).toStrictEqual(newDescriptor.toBuffer().toString('hex')); + expect(mmrdescriptor).toStrictEqual(newDescriptor.toJson()); + + }); + + test('serialize and deserialize an encrypted mmrdescriptor', async () => { + + const encryptedmmrdescriptor = { + "version": 1, + "objecthashtype": 5, + "mmrhashtype": 1, + "mmrroot": { + "version": 1, + "flags": 5, + "objectdata": "dec21b940a475989ac9220081ec3816a0026921594462841d2155a3d8462bdd8ada9f02cb7b795a01b842dce0a3c5bfe83e57fd46f34b19a67ee716a1e771264db1b7831cd2341a515", + "epk": "bdea4d6f2a88a954bed38de4ed6e7f6ff7d483fc799f1428be2ccfe6f27c87c9" + }, + "mmrhashes": { + "version": 1, + "flags": 5, + "objectdata": "8ad904b879fc67d7f0ceee8accd593549af8225d03772153465c666bb552eff607883d3d07f154a5515e167d9952feb7e3c121033e18ae855cdad782bc7ccbeb8e4737e9fdfcad31dc066695014e8aec572d4de728b8a1dedd740891ee848f85cc5eb16959761d89feafd78ac1e93494d08ea50311fa424c436bdb24b47ff369", + "epk": "7939e04d89b5713ad3a809ba4cedb4b320df8f380a8b5999e24ce4465fe43b18" + }, + "datadescriptors": [ + { + "version": 1, + "flags": 5, + "objectdata": "0e953a1bb2c81f2c101d9439736e9f614e1c289621dedfd4a0ff8455a36473c8023f4c8a35bdc546e8e48e17030cb7bc418ef248705f0873f3a1ce5674b800030294cace9b26d8d5cf06ac5a7a379be8c2a1d3e6643249312cfa83fbfe9f882a8f5cde0ddb4b940a53e5d4e69bacffa571b6e8eca218ee9d02b751c71426e8433aeabe6cf79e54495510626b5c43c690c47ca8770835", + "epk": "c7f2304a170a54dbb97951a93f7444cf689d487e46172f2f5e54923aefe8865e" + }, + { + "version": 1, + "flags": 5, + "objectdata": "05615e1c62f2a0b5311ec1d4e78d7709f3e29ac52e98a87c4222796ee532f457d0f68a4759464d0d7ea72c90177752d7ee179cfcb25d42ff4d19755650443c1f26490d80db903d28423fb38bd32f19f855f50e52b1e53529da16da8755cfc9857a4a4af1bc4327caa691633a79ef718bcf4547abf5d4cc1f26f5f6919711fc99f6de8e351726d828b534aa090bdcdc5987b117fe0c0b2e06", + "epk": "cf066d1ca66ea90a7a3de353e4a7db6fd4f88c7ae2eb47bcef9a78a0c8be6010" + } + ] + } + const mmrdescriptorBuffer = MMRDescriptor.fromJson(encryptedmmrdescriptor); + const initialDescriptor = mmrdescriptorBuffer.toBuffer().toString('hex'); + const newDescriptor = new MMRDescriptor(); + + newDescriptor.fromBuffer(Buffer.from(initialDescriptor, 'hex')); + + expect(initialDescriptor).toStrictEqual(newDescriptor.toBuffer().toString('hex')); + + }); +}); \ No newline at end of file diff --git a/src/__tests__/pbaas/rating.test.ts b/src/__tests__/pbaas/rating.test.ts new file mode 100644 index 0000000..4761185 --- /dev/null +++ b/src/__tests__/pbaas/rating.test.ts @@ -0,0 +1,25 @@ +import { BN } from "bn.js"; +import { PRINCIPAL_DEFAULT_FLAGS, PRINCIPAL_VERSION_CURRENT, Principal } from "../../pbaas/Principal"; +import { Rating } from "../../pbaas/Rating"; +import { fromBase58Check } from "../../utils/address"; +import { KeyID } from "../../pbaas/KeyID"; + +describe('Serializes and deserializes Rating', () => { + test('(de)serialize Rating', () => { + + const ratings = new Map(); + + ratings.set("i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", Buffer.from("aa", "hex")); + + const r = new Rating({ + version: Rating.VERSION_CURRENT, + trust_level: Rating.TRUST_APPROVED, + ratings + }); + const rFromBuf = new Rating(); + + rFromBuf.fromBuffer(r.toBuffer()) + + expect(rFromBuf.toBuffer().toString('hex')).toBe(r.toBuffer().toString('hex')) + }); + }); \ No newline at end of file diff --git a/src/__tests__/pbaas/saltedData.test.ts b/src/__tests__/pbaas/saltedData.test.ts new file mode 100644 index 0000000..c743a19 --- /dev/null +++ b/src/__tests__/pbaas/saltedData.test.ts @@ -0,0 +1,22 @@ +import { BN } from "bn.js"; +import { PRINCIPAL_DEFAULT_FLAGS, PRINCIPAL_VERSION_CURRENT, Principal } from "../../pbaas/Principal"; +import { Rating } from "../../pbaas/Rating"; +import { fromBase58Check } from "../../utils/address"; +import { SaltedData } from "../../pbaas/SaltedData"; + +describe('Serializes and deserializes SaltedData', () => { + + test('(de)serialize SaltedData', () => { + + const data = Buffer.from("0101010101010101010101010101010101010101010101010101010101010101", "hex"); + const salt = Buffer.from("0202020202020202020202020202020202020202020202020202020202020202", "hex"); + + const s = new SaltedData(data, salt); + + const sFromBuf = new SaltedData(); + + sFromBuf.fromBuffer(s.toBuffer()) + + expect(sFromBuf.toBuffer().toString('hex')).toBe(s.toBuffer().toString('hex')) + }); +}); diff --git a/src/__tests__/pbaas/signatureData.test.ts b/src/__tests__/pbaas/signatureData.test.ts new file mode 100644 index 0000000..56289dc --- /dev/null +++ b/src/__tests__/pbaas/signatureData.test.ts @@ -0,0 +1,24 @@ +import { SignatureData } from "../../pbaas/SignatureData"; + +describe('Serializes and deserializes SignatureData', () => { + test('(de)serialize SignatureData', () => { + + const data = { + "version": 1, + "systemid": "iJhCezBExJHvtyH3fGhNnt2NhU4Ztkf2yq", + "hashtype": 1, + "signaturehash": "dfd3e3d82783360dfc675a09e6a226fd43119ef4e8d7cf553af96ea5883b51da", + "identityid": "iKjrTCwoPFRk44fAi2nYNbPG16ZUQjv1NB", + "signaturetype": 1, + "signature": "AgXOCgAAAUEfCiSukK9tg46cYOpHmxzKjNquWDyNc8H58+uLSOYmqlUcNUxWB8j3nzT1RHKeJGygdAwrUj5iZ/A9H3+qYV9H9g==" + } + + const s = SignatureData.fromJson(data); + + const sFromBuf = new SignatureData(); + + sFromBuf.fromBuffer(s.toBuffer()) + + expect(sFromBuf.toBuffer().toString('hex')).toBe(s.toBuffer().toString('hex')) + }); + }); diff --git a/src/__tests__/pbaas/transaction/identityscript.test.ts b/src/__tests__/pbaas/transaction/identityscript.test.ts index 99c008c..2f45a8c 100644 --- a/src/__tests__/pbaas/transaction/identityscript.test.ts +++ b/src/__tests__/pbaas/transaction/identityscript.test.ts @@ -1,10 +1,11 @@ -import { Identity } from "../../../pbaas/Identity"; +import { Identity, IDENTITY_FLAG_TOKENIZED_CONTROL } from "../../../pbaas/Identity"; +import { OptCCParams } from "../../../pbaas/OptCCParams"; import { IdentityScript } from "../../../pbaas/transaction/IdentityScript"; +import { IDENTITY_RECOVER_ADDR } from "../../../utils/cccustom"; describe('Serializes and deserializes SmartTransactionScripts', () => { test('(de)serialize a basic identity registration outscript (v1) from daemon', () => { const scriptString = "46040300010314a484f66e98c3d787b2ff8854d3ceeb5b61446978150476a348fd730beb2694f54a7114dbf14aa699f9fa150476a348fd730beb2694f54a7114dbf14aa699f9facc4ce304030e0101150476a348fd730beb2694f54a7114dbf14aa699f9fa4c8e010000000000000001143cdad2d09cbc6e164804af104b1f3f56f0d10d78010000001af5b8015c64d39ab44c60ead8317f9f5a9b6c4c0161000076a348fd730beb2694f54a7114dbf14aa699f9fa76a348fd730beb2694f54a7114dbf14aa699f9fa016931943a1979b5e0308a4da1cb62688e6d6433e4501d2c5a474987deee3137144a48978919d7e6a47670501b04030f0101150476a348fd730beb2694f54a7114dbf14aa699f9fa1b0403100101150476a348fd730beb2694f54a7114dbf14aa699f9fa75"; - const script = new IdentityScript(); script.fromBuffer(Buffer.from(scriptString, 'hex')); @@ -16,7 +17,7 @@ describe('Serializes and deserializes SmartTransactionScripts', () => { minimumsignatures: 1, name: 'a', parent: 'i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV', - primaryaddresses: [ 'REpxm9bCLMiHRNVPA9unPBWixie7uHFA5C' ], + primaryaddresses: ['REpxm9bCLMiHRNVPA9unPBWixie7uHFA5C'], privateaddress: 'zs1dycegwse0x67qvy2fksukcng3ekkgvly2qwjckj8fxraam33xu2y5jyh3yva0e4ywec9quedcud', recoveryauthority: 'iEHpmxiynXmwZKNgMm7BpXWP3EqCJt663q', revocationauthority: 'iEHpmxiynXmwZKNgMm7BpXWP3EqCJt663q', @@ -27,6 +28,71 @@ describe('Serializes and deserializes SmartTransactionScripts', () => { }); expect(() => IdentityScript.fromIdentity(script.getIdentity())).toThrowError() }); + test('(de)serialize a basic identity registration outscript for a revoked ID', () => { + const idjson = { + "contentmap": { + "53f36cc8554d2a9b1c86e92e77965607e242a513": "6332bd51fca724077577f93ec7eb185a45bd881268e2d9488c9ef087293e5cc4" + }, + "contentmultimap": {}, + "flags": 0, + "identityaddress": "i8byHmWFAeFMajYdgrXiQ9qZ1Y9FqxJUx1", + "minimumsignatures": 1, + "name": "VerusPay", + "parent": "iJhCezBExJHvtyH3fGhNnt2NhU4Ztkf2yq", + "primaryaddresses": [ + "RSunNQqKnSwpNBRd6kcenScuQEFUWgL3bZ" + ], + "privateaddress": "zs1wczplx4kegw32h8g0f7xwl57p5tvnprwdmnzmdnsw50chcl26f7tws92wk2ap03ykaq6jyyztfa", + "recoveryauthority": "i9ps1xDcr7eM66Fko6aTkeuvvBPZFLEXRN", + "revocationauthority": "i98Mnj1YugaRzoURXt4aRhdqQDu7rML9J5", + "systemid": "iJhCezBExJHvtyH3fGhNnt2NhU4Ztkf2yq", + "timelock": 0, + "version": 3 + } + + const identity = Identity.fromJson(idjson); + identity.revoke(); + + const idscript = IdentityScript.fromIdentity(identity); + + expect(idscript.masterOptCC.destinations.length).toBe(2); + expect(idscript.masterOptCC.destinations[1].toAddress()).toBe("i9ps1xDcr7eM66Fko6aTkeuvvBPZFLEXRN"); + expect(idscript.paramsOptCC.vdata.length).toBe(2); + }); + + test('(de)serialize a basic identity registration outscript for a revoked ID with tokenized ID control', () => { + const idjson = { + "contentmap": { + "53f36cc8554d2a9b1c86e92e77965607e242a513": "6332bd51fca724077577f93ec7eb185a45bd881268e2d9488c9ef087293e5cc4" + }, + "contentmultimap": {}, + "flags": 0, + "identityaddress": "i8byHmWFAeFMajYdgrXiQ9qZ1Y9FqxJUx1", + "minimumsignatures": 1, + "name": "VerusPay", + "parent": "iJhCezBExJHvtyH3fGhNnt2NhU4Ztkf2yq", + "primaryaddresses": [ + "RSunNQqKnSwpNBRd6kcenScuQEFUWgL3bZ" + ], + "privateaddress": "zs1wczplx4kegw32h8g0f7xwl57p5tvnprwdmnzmdnsw50chcl26f7tws92wk2ap03ykaq6jyyztfa", + "recoveryauthority": "i9ps1xDcr7eM66Fko6aTkeuvvBPZFLEXRN", + "revocationauthority": "i98Mnj1YugaRzoURXt4aRhdqQDu7rML9J5", + "systemid": "iJhCezBExJHvtyH3fGhNnt2NhU4Ztkf2yq", + "timelock": 0, + "version": 3 + } + + const identity = Identity.fromJson(idjson); + identity.flags = identity.flags.xor(IDENTITY_FLAG_TOKENIZED_CONTROL); + + const idscript = IdentityScript.fromIdentity(identity); + + expect(idscript.masterOptCC.destinations.length).toBe(3); + expect(OptCCParams.fromChunk(idscript.paramsOptCC.vdata[2]).destinations[1].toAddress()).toBe(IDENTITY_RECOVER_ADDR); + expect(OptCCParams.fromChunk(idscript.paramsOptCC.vdata[2]).n.toNumber()).toBe(2); + expect(idscript.paramsOptCC.vdata.length).toBe(3); + }); + test('(de)serialize a basic identity registration outscript (v3) from daemon with contentmap', () => { const scriptString = "470403000103150438411ff17100e15b6df8dd72fecbe4fa4964dfea15043e006293b9e3341262eed040048d3a2260367f47150445a96c0179cbb19221c0e8625a2ed691d762fd37cc4d360104030e0101150438411ff17100e15b6df8dd72fecbe4fa4964dfea4ce103000000000000000114c165bce63e47698278f859ee75c35c78eb23e8df01000000a6ef9ea235635e328124ff3429db9f9e91b64e2d085665727573506179000113a542e2075696772ee9861c9b2a4d55c86cf353c45c3e2987f09e8c48d9e2681288bd455a18ebc73ef977750724a7fc51bd32633e006293b9e3341262eed040048d3a2260367f4745a96c0179cbb19221c0e8625a2ed691d762fd370176041f9ab6ca1d155ce87a7c677e9e0d16c9846e6ee62db670751f8be3ead27cb740aa7595d0be24b741a9a6ef9ea235635e328124ff3429db9f9e91b64e2d000000001b04030f010115043e006293b9e3341262eed040048d3a2260367f471b0403100101150445a96c0179cbb19221c0e8625a2ed691d762fd3775"; @@ -62,7 +128,7 @@ describe('Serializes and deserializes SmartTransactionScripts', () => { }); test('(de)serialize a basic identity registration outscript (v3) from daemon with contentmultimap', () => { - const scriptString = "4704030001031504dfae84e93ab133b739076354e9fbb2de428872121504dfae84e93ab133b739076354e9fbb2de428872121504dfae84e93ab133b739076354e9fbb2de42887212cc4dbb0604030e01011504dfae84e93ab133b739076354e9fbb2de428872124d65060300000000000000011472aa70e6a4c0d0ff07541c5fbe4f08cacd89d35b01000000a6ef9ea235635e328124ff3429db9f9e91b64e2d0543687269730250d65f0c3aea3fd55eadf3b6f31f123fe8f9dbe001fdda02ab8b7b8b4418de66e611921699a328126461c0e5018443fdc0027b226172746973744e616d65223a20226976616e40222c2022616c62756d4e616d65223a202274657374416c62756d222c202267656e7265223a2022726f636b222c202275726c223a202268747470733a2f2f2f6a756b65626f78222c20226e6574776f726b4964223a2022726f6f6d66756c222c20227369676e6174757265223a20224167586d4567414141554567774c45516a534f4d44477651394f715859433654706d766c536a2b6c596731374d57336161494d3538634539756657376746344a7966364d2f6e4a4a564d3377466f64496d344972622f545565466a654b43616e35673d3d222c2022747261636b73223a205b7b227265736f757263654964223a20223139343564633964717472673231222c20226e616d65223a20225c75303431325c75303433655c75303433665c75303433625c7530343536205c75303431325c75303435365c75303433345c75303433655c75303433665c75303433625c75303434665c75303434315c75303433655c75303433325c7530343330202d205c75303431325c75303433355c75303434315c75303433645c75303433302028436f766572206279204772616e646d615c7320536d757a6929222c20226475726174696f6e223a203234302e3433327d5d2c2022616c62756d436f766572223a207b227265736f757263654964223a20223931647370387471367273713176227d2c20226172746973744c6f676f223a207b227265736f757263654964223a202272326630366267747a6872386276227d2c2022736c65657665446f63756d656e74223a207b227265736f757263654964223a202235706336307773713335337a736d227d2c2022636f70696573536f6c64223a20302c202272656c6561736554696d657374616d70223a202231363832353539323132222c20227072696365223a207b2256414c55223a20312c202255534443223a203230307d7d652741687b7ab1473754858d7b8b10886945eaf801fddc02ab8b7b8b4418de66e611921699a328126461c0e5018445fdc2027b22616c62756d436f766572223a207b227265736f757263654964223a20223931647370387471367273713176227d2c2022616c62756d4e616d65223a202274657374416c62756d3131222c20226172746973744c6f676f223a207b227265736f757263654964223a202272326630366267747a6872386276227d2c20226172746973744e616d65223a20226976616e40222c202267656e7265223a2022726f636b222c20226e6574776f726b4964223a2022726f6f6d66756c222c20227369676e6174757265223a20224167586d4567414141554567774c45516a534f4d44477651394f715859433654706d766c536a2b6c596731374d57336161494d3538634539756657376746344a7966364d2f6e4a4a564d3377466f64496d344972622f545565466a654b43616e35673d3d222c2022736c65657665446f63756d656e74223a207b227265736f757263654964223a202235706336307773713335337a736d227d2c2022747261636b73223a205b7b226475726174696f6e223a203234302e3433322c20226e616d65223a20225c75303431325c75303433655c75303433665c75303433625c7530343536205c75303431325c75303435365c75303433345c75303433655c75303433665c75303433625c75303434665c75303434315c75303433655c75303433325c7530343330202d205c75303431325c75303433355c75303434315c75303433645c75303433302028436f766572206279204772616e646d615c7320536d757a6929222c20227265736f757263654964223a20223139343564633964717472673231227d5d2c202275726c223a202268747470733a2f2f2f6a756b65626f78222c2022636f70696573536f6c64223a20302c202272656c6561736554696d657374616d70223a202231363832353336313730222c20227072696365223a207b2256414c55223a20312c202255534443223a203230307d7d00dfae84e93ab133b739076354e9fbb2de42887212dfae84e93ab133b739076354e9fbb2de4288721200a6ef9ea235635e328124ff3429db9f9e91b64e2d000000001b04030f01011504dfae84e93ab133b739076354e9fbb2de428872121b04031001011504dfae84e93ab133b739076354e9fbb2de4288721275"; + const scriptString = "4704030001031504f478f668655e60f6b49e2424053166ba2cf241391504f478f668655e60f6b49e2424053166ba2cf241391504f478f668655e60f6b49e2424053166ba2cf24139cc4d030104030e01011504f478f668655e60f6b49e2424053166ba2cf241394cae0300000000000000021455f51a22c79018a00ced41e758560f5df7d4d35d143e3c1a4f0dc6852eff0b312bec2e4dd382d2939701000000a6ef9ea235635e328124ff3429db9f9e91b64e2d076d6f6e6b696e7301797c0f0128e5d8f2aedd0039a930b1abe12e5be90102040d00f478f668655e60f6b49e2424053166ba2cf24139f478f668655e60f6b49e2424053166ba2cf2413900a6ef9ea235635e328124ff3429db9f9e91b64e2d000000001b04030f01011504f478f668655e60f6b49e2424053166ba2cf241391b04031001011504f478f668655e60f6b49e2424053166ba2cf2413975"; const script = new IdentityScript(); script.fromBuffer(Buffer.from(scriptString, 'hex')); @@ -71,33 +137,26 @@ describe('Serializes and deserializes SmartTransactionScripts', () => { "version": 3, "flags": 0, "primaryaddresses": [ - "RKjVHqM4VF2pCfVcwGzKH7CxvfMUE4H6o8" + "RH7h8p9LN2Yb48SkxzNQ29c1Ltfju8Cd5i", + "RExFyRVftxbW8w9e5Xkcixu3YtYjE2kCKX" ], "minimumsignatures": 1, - "name": "Chris", - "identityaddress": "iPsFBfFoCcxtuZNzE8yxPQhXVn4dmytf8j", + "name": "monkins", + "identityaddress": "iRmBDWNs2WahXDAvS2TEsJyJwwHXhwcs7w", "parent": "iJhCezBExJHvtyH3fGhNnt2NhU4Ztkf2yq", "systemid": "iJhCezBExJHvtyH3fGhNnt2NhU4Ztkf2yq", - "contentmap": { - }, + "contentmap": {}, "contentmultimap": { - "iAqxJCbv2veLLHGdantvrzJRupyh3dkT6B": [ - { - "iK7a5JNJnbeuYWVHCDRpJosj3irGJ5Qa8c": "{\"artistName\": \"ivan@\", \"albumName\": \"testAlbum\", \"genre\": \"rock\", \"url\": \"https:///jukebox\", \"networkId\": \"roomful\", \"signature\": \"AgXmEgAAAUEgwLEQjSOMDGvQ9OqXYC6TpmvlSj+lYg17MW3aaIM58cE9ufW7gF4Jyf6M/nJJVM3wFodIm4Irb/TUeFjeKCan5g==\", \"tracks\": [{\"resourceId\": \"1945dc9dqtrg21\", \"name\": \"\\u0412\\u043e\\u043f\\u043b\\u0456 \\u0412\\u0456\\u0434\\u043e\\u043f\\u043b\\u044f\\u0441\\u043e\\u0432\\u0430 - \\u0412\\u0435\\u0441\\u043d\\u0430 (Cover by Grandma\\s Smuzi)\", \"duration\": 240.432}], \"albumCover\": {\"resourceId\": \"91dsp8tq6rsq1v\"}, \"artistLogo\": {\"resourceId\": \"r2f06bgtzhr8bv\"}, \"sleeveDocument\": {\"resourceId\": \"5pc60wsq353zsm\"}, \"copiesSold\": 0, \"releaseTimestamp\": \"1682559212\", \"price\": {\"VALU\": 1, \"USDC\": 200}}" - } - ], - "iChNhyJiQSZ3HumofCBhuASjgupq1m1NgP": [ - { - "iK7a5JNJnbeuYWVHCDRpJosj3irGJ5Qa8c": "{\"albumCover\": {\"resourceId\": \"91dsp8tq6rsq1v\"}, \"albumName\": \"testAlbum11\", \"artistLogo\": {\"resourceId\": \"r2f06bgtzhr8bv\"}, \"artistName\": \"ivan@\", \"genre\": \"rock\", \"networkId\": \"roomful\", \"signature\": \"AgXmEgAAAUEgwLEQjSOMDGvQ9OqXYC6TpmvlSj+lYg17MW3aaIM58cE9ufW7gF4Jyf6M/nJJVM3wFodIm4Irb/TUeFjeKCan5g==\", \"sleeveDocument\": {\"resourceId\": \"5pc60wsq353zsm\"}, \"tracks\": [{\"duration\": 240.432, \"name\": \"\\u0412\\u043e\\u043f\\u043b\\u0456 \\u0412\\u0456\\u0434\\u043e\\u043f\\u043b\\u044f\\u0441\\u043e\\u0432\\u0430 - \\u0412\\u0435\\u0441\\u043d\\u0430 (Cover by Grandma\\s Smuzi)\", \"resourceId\": \"1945dc9dqtrg21\"}], \"url\": \"https:///jukebox\", \"copiesSold\": 0, \"releaseTimestamp\": \"1682536170\", \"price\": {\"VALU\": 1, \"USDC\": 200}}" - } + "iEYsp2njSt1M4EVYi9uuAPBU2wpKmThkkr": [ + "040d" ] }, - "revocationauthority": "iPsFBfFoCcxtuZNzE8yxPQhXVn4dmytf8j", - "recoveryauthority": "iPsFBfFoCcxtuZNzE8yxPQhXVn4dmytf8j", + "revocationauthority": "iRmBDWNs2WahXDAvS2TEsJyJwwHXhwcs7w", + "recoveryauthority": "iRmBDWNs2WahXDAvS2TEsJyJwwHXhwcs7w", "timelock": 0 } - const scriptId = script.getIdentity([["iK7a5JNJnbeuYWVHCDRpJosj3irGJ5Qa8c"], ["iK7a5JNJnbeuYWVHCDRpJosj3irGJ5Qa8c"]]); + const scriptId = script.getIdentity(false); const scriptJson = scriptId.toJson(); expect(script.toBuffer().toString('hex')).toBe(scriptString); diff --git a/src/__tests__/pbaas/vdxfunivalue.test.ts b/src/__tests__/pbaas/vdxfunivalue.test.ts index a0bd374..62b85ba 100644 --- a/src/__tests__/pbaas/vdxfunivalue.test.ts +++ b/src/__tests__/pbaas/vdxfunivalue.test.ts @@ -4,6 +4,13 @@ import { KeyID } from "../../pbaas/KeyID"; import { fromBase58Check } from "../../utils/address"; import { VDXF_UNI_VALUE_VERSION_CURRENT, VdxfUniValue } from "../../pbaas/VdxfUniValue"; import { DATA_TYPE_STRING, VERUSPAY_INVOICE_VDXF_KEY } from "../../vdxf"; +import { Rating } from "../../pbaas/Rating"; +import { CurrencyValueMap } from "../../pbaas"; +import { CrossChainDataRef, CrossChainDataRefJson } from "../../pbaas/CrossChainDataRef"; +import { SaltedData } from "../../pbaas/SaltedData"; +import { SignatureData } from "../../pbaas/SignatureData"; +import { MMRDescriptor } from "../../pbaas/MMRDescriptor"; +import { URLRef, URLRefJson } from "../../pbaas/URLRef"; describe('Encodes and decodes VdxfUniValue', () => { test('encode/decode VdxfUniValue with string data', () => { @@ -17,7 +24,7 @@ describe('Encodes and decodes VdxfUniValue', () => { const vFromBuf = new VdxfUniValue(); - vFromBuf.fromBuffer(v.toBuffer(), 0, [DATA_TYPE_STRING.vdxfid]); + vFromBuf.fromBuffer(v.toBuffer(), 0); expect(vFromBuf.toBuffer().toString('hex')).toBe(v.toBuffer().toString('hex')); expect(VdxfUniValue.fromJson(v.toJson()).toBuffer().toString('hex')).toBe(vFromBuf.toBuffer().toString('hex')); @@ -34,6 +41,119 @@ describe('Encodes and decodes VdxfUniValue', () => { const vFromBuf = new VdxfUniValue(); - expect(() => vFromBuf.fromBuffer(v.toBuffer(), 0, [VERUSPAY_INVOICE_VDXF_KEY.vdxfid])).toThrowError(); + expect(() => vFromBuf.fromBuffer(v.toBuffer(), 0)).toThrowError(); }); + + // This test uses serialized data from the daemon adter putting in the Rating object into a contentmultimap. + const multiMapwithRating = "979e0d9bc8c91be03c57bab5b45ddcf17fd5ca32011c0100000002011af5b8015c64d39ab44c60ead8317f9f5a9b6c4c0101" + + test('fail to encode/decode VdxfUniValue with unknown data', () => { + + const ratingMap = {"version":1, "trustlevel":2, "ratingsmap":{"i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV":"01"}} + + const jsonRating = Rating.fromJson(ratingMap); + + const v = new VdxfUniValue(); + v.fromBuffer(Buffer.from(multiMapwithRating, 'hex')); + + const extractedRating = v.values.get('iHJComZUXXGniLkDhjYprWYEN8qvQGDoam') as Rating; + + expect(jsonRating.toBuffer().toString('hex')).toBe(extractedRating.toBuffer().toString('hex')); + }); + + const multimapwithCurrencymap = "c98f1f7e5804ec1b180192f87125aefcc270db25011d011af5b8015c64d39ab44c60ead8317f9f5a9b6c4c00a0724e1809000000f478f668655" + + const multimapwithcrosschaindataref = "d6ae5ac0571b22d161261b87c748f6e0aee0334d011302011068747470733a2f2f76657275732e696f" + + const multimapwithsignaturedata = "2af2a488d317c76af6f764ec2c04009a9e358bb4019901a6ef9ea235635e328124ff3429db9f9e91b64e2d0120b793323968ea80de4df1fb78963cfb8b604b524f6a7c9069293085e076f44d5df478f668655e60f6b49e2424053166ba2cf2413901000000490205d65f00000141205e483e50265341623cd9a089baf4b913f969b5377d588044c09b7d239870d7f7205a4a4581f440db7d01049ebdfe95f5de7a6b07113f9c7f79dc6fd3da69f245" + + const multimapwithmmrdescriptor = "4382a62b73169697c3698d2f00bed6024c3a279701fd5402010501010549b00ad8606acbf5234700daa308a2c64c1f9466c11d47255a60f8ccf9c74ba82b994a03b9b0331bc6f1bf25bbc8b4453a130d65b6a9dc21f7589967e88e51d930682469b03873c54e7720d89d4a9333fe85519a447b886b6c6c8aabee6fb144e9742b76b745dbdfd83c9a0105808207c6db9c149dcaff5f502baf891642e67e7e303c0ba8130f2bff76d8247929bc7ce55fdf66bac03ea808006dc5e71aa12deaff355985c7770ee7a534d9cea2bfc10851ed5c91467083ffb1f746161f5d567b4be5c98d72300e1762697d5f62067d819ac0b35ac2c712c6e8e04cefaecaf759f38f4fa3ff4d3fc4d1dccbb6b820230df92c25958999741329ed3dafc7825900807cbf6b02becc236ce573158a4f0201057c97c0b93faab9462670a5a13da88d9ca796db968ae9c9f1b88df67c564b73cb63f752248402844522efaa62e5b42ce816d0a9f44ca14efaf6f7fe47d916e77b54266c5cac39c6771e899ebda093c566d33bbf60b4a598ea45bf2f5fb1f0cd782baaf092a880a799e0771144a9e9422eec107e43d23ba9386bb46dde0920d7a908ddf6f4d6261d25c62ca086bb3f570b07d74a59256feed13d64d6fbadd201057bd1ce7cab498d9a87bbf3c8d5f255cf209e87adf01f407751959f2d49f23056597a51240e90d5f758adc92e819f77f698fe754c9ea350c213dbcbffdaeb6d9a55bbaf705af9a375c855e7a8ca486bc65b1bd24c35e13f437a7490ecaffeff0323e7508a6cc4e36c5414b4cd7d3125ffabfa3fe85a56e4f6e539925b20822d2b817613d5eb5daf4893afc57289d0081f8fe225c77e1e4839aa0822b9a5" + + test('deserialize currency map from vdxfuniValue', () => { + const v = new VdxfUniValue(); + v.fromBuffer(Buffer.from(multimapwithCurrencymap, 'hex')); + + const currencyMap = v.values.get('iMrGhzkZq5fpWWSa1RambRySFPb7CuvKuX') as CurrencyValueMap; + + const jsonCurrencyMap = {"i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV":"10000000000000"}; + const currencyMapFromJson = CurrencyValueMap.fromJson(jsonCurrencyMap, true); + + expect(currencyMap.toBuffer().toString('hex')).toBe(currencyMapFromJson.toBuffer().toString('hex')); + }); + + test('deserialize crosschain data ref from vdxfuniValue', () => { + const v = new VdxfUniValue(); + v.fromBuffer(Buffer.from(multimapwithcrosschaindataref, 'hex')); + + const crossChainDataRef = v.values.get('iP3euVSzNcXUrLNHnQnR9G6q8jeYuGSxgw') as CrossChainDataRef; + + const jsonCrossChainDataRef = {"version":"1", "url":"https://verus.io"}; + + const crossChainDataRefFromJson = new CrossChainDataRef(URLRef.fromJson(jsonCrossChainDataRef)); + + expect(crossChainDataRef.toBuffer().toString('hex')).toBe(crossChainDataRefFromJson.toBuffer().toString('hex')); + }); + + test('deserialize signature data from vdxfuniValue', () => { + const v = new VdxfUniValue(); + v.fromBuffer(Buffer.from(multimapwithsignaturedata, 'hex')); + + const signatureData = v.values.get('i7PcVF9wwPtQ6p6jDtCVpohX65pTZuP2ah') as SignatureData; + + const jsonSignatureData = { + "version": 1, + "systemid": "iJhCezBExJHvtyH3fGhNnt2NhU4Ztkf2yq", + "hashtype": 1, + "signaturehash": "5d4df476e085302969907c6a4f524b608bfb3c9678fbf14dde80ea68393293b7", + "identityid": "iRmBDWNs2WahXDAvS2TEsJyJwwHXhwcs7w", + "signaturetype": 1, + "signature": "AgXWXwAAAUEgXkg+UCZTQWI82aCJuvS5E/lptTd9WIBEwJt9I5hw1/cgWkpFgfRA230BBJ69/pX13nprBxE/nH953G/T2mnyRQ==" + } + const signatureDataFromJson = SignatureData.fromJson(jsonSignatureData); + + expect(signatureData.toBuffer().toString('hex')).toBe(signatureDataFromJson.toBuffer().toString('hex')); + }); + + test('deserialize mmr descriptor from vdxfuniValue', () => { + const v = new VdxfUniValue(); + v.fromBuffer(Buffer.from(multimapwithmmrdescriptor, 'hex')); + + const mmrDescriptor = v.values.get('i9dVDb4LgfMYrZD1JBNP2uaso4bNAkT4Jr') as MMRDescriptor; + + const jsonMMRDescriptor ={ + "version": 1, + "objecthashtype": 5, + "mmrhashtype": 1, + "mmrroot": { + "version": 1, + "flags": 5, + "objectdata": "b00ad8606acbf5234700daa308a2c64c1f9466c11d47255a60f8ccf9c74ba82b994a03b9b0331bc6f1bf25bbc8b4453a130d65b6a9dc21f7589967e88e51d930682469b03873c54e77", + "epk": "d89d4a9333fe85519a447b886b6c6c8aabee6fb144e9742b76b745dbdfd83c9a" + }, + "mmrhashes": { + "version": 1, + "flags": 5, + "objectdata": "8207c6db9c149dcaff5f502baf891642e67e7e303c0ba8130f2bff76d8247929bc7ce55fdf66bac03ea808006dc5e71aa12deaff355985c7770ee7a534d9cea2bfc10851ed5c91467083ffb1f746161f5d567b4be5c98d72300e1762697d5f62067d819ac0b35ac2c712c6e8e04cefaecaf759f38f4fa3ff4d3fc4d1dccbb6b8", + "epk": "230df92c25958999741329ed3dafc7825900807cbf6b02becc236ce573158a4f" + }, + "datadescriptors": [ + { + "version": 1, + "flags": 5, + "objectdata": "97c0b93faab9462670a5a13da88d9ca796db968ae9c9f1b88df67c564b73cb63f752248402844522efaa62e5b42ce816d0a9f44ca14efaf6f7fe47d916e77b54266c5cac39c6771e899ebda093c566d33bbf60b4a598ea45bf2f5fb1f0cd782baaf092a880a799e0771144a9e9422eec107e43d23ba9386bb46dde09", + "epk": "d7a908ddf6f4d6261d25c62ca086bb3f570b07d74a59256feed13d64d6fbadd2" + }, + { + "version": 1, + "flags": 5, + "objectdata": "d1ce7cab498d9a87bbf3c8d5f255cf209e87adf01f407751959f2d49f23056597a51240e90d5f758adc92e819f77f698fe754c9ea350c213dbcbffdaeb6d9a55bbaf705af9a375c855e7a8ca486bc65b1bd24c35e13f437a7490ecaffeff0323e7508a6cc4e36c5414b4cd7d3125ffabfa3fe85a56e4f6e539925b", + "epk": "822d2b817613d5eb5daf4893afc57289d0081f8fe225c77e1e4839aa0822b9a5" + } + ] + } + const mmrDescriptorFromJson = MMRDescriptor.fromJson(jsonMMRDescriptor); + + expect(mmrDescriptor.toBuffer().toString('hex')).toBe(mmrDescriptorFromJson.toBuffer().toString('hex')); + }); + }); \ No newline at end of file diff --git a/src/api/ApiPrimitive.ts b/src/api/ApiPrimitive.ts index 85faf50..b9e1144 100644 --- a/src/api/ApiPrimitive.ts +++ b/src/api/ApiPrimitive.ts @@ -3,6 +3,7 @@ import { IdentityDefinition } from "../identity/IdentityDefinition"; import { OfferForMaking } from "../offers/OfferForMaking"; import { ListedOffer } from "../offers/OfferList"; import { RawTransaction } from "../transaction/RawTransaction"; +import { SignDataArgs } from "./classes/SignData/SignDataRequest"; export type ApiPrimitive = | string @@ -15,7 +16,8 @@ export type ApiPrimitive = | Array | IdentityDefinition | BlockInfo - | RawTransaction; + | RawTransaction + | SignDataArgs; export type ApiPrimitiveJson = { [key: string]: ApiPrimitive | undefined }; diff --git a/src/api/classes/SignData/SignDataRequest.ts b/src/api/classes/SignData/SignDataRequest.ts new file mode 100644 index 0000000..2001812 --- /dev/null +++ b/src/api/classes/SignData/SignDataRequest.ts @@ -0,0 +1,55 @@ +import { ApiRequest } from "../../ApiRequest"; +import { ApiPrimitiveJson, RequestParams } from "../../ApiPrimitive"; +import { SIGN_DATA } from "../../../constants/cmds"; +import { DataDescriptorInfo } from "../../../utils/types/DataDescriptor"; +import { SignDataParameters } from "../../../utils/types/SignData"; + +export type SignDataArgs = { + address?: string; + filename?: string; + message?: string; + messagehex?: string; + messsagebase64?: string; + datahash?: string; + vdxfdata?: string; + mmrdata?: Array; + mmrsalt?: Array; + mmrhashtype?: string; + priormmr?: Array; + vdxfkeys?: Array; + vdxfkeynames?: Array; + boundhahses?: Array; + hashtype?: string; + signature?: string; + encrypttoaddress?: string; + createmmr?: boolean; +} + +export class SignDataRequest extends ApiRequest { + data: SignDataArgs; + + constructor(chain: string, signableItems: SignDataArgs) { + super(chain, SIGN_DATA); + this.data = signableItems; + } + + getParams(): RequestParams { + const params = [this.data]; + + return params.filter((x) => x != null); + } + + static fromJson(object: ApiPrimitiveJson): SignDataRequest { + return new SignDataRequest( + object.chain as string, + object.data as SignDataArgs + ); + } + + toJson(): ApiPrimitiveJson { + return { + chain: this.chain, + data: this.data, + }; + } +} \ No newline at end of file diff --git a/src/api/classes/SignData/SignDataResponse.ts b/src/api/classes/SignData/SignDataResponse.ts new file mode 100644 index 0000000..2e7b15f --- /dev/null +++ b/src/api/classes/SignData/SignDataResponse.ts @@ -0,0 +1,24 @@ +import { ApiResponse } from "../../ApiResponse"; +import { SignatureDataInfo } from "../../../utils/types/Signature"; +import { MmrDescriptorParameters } from "../../../utils/types/MmrDescriptor"; +import { DataDescriptorInfo } from "../../../utils/types/DataDescriptor"; + +export class SignDataResponse extends ApiResponse { + result: { + mmrdescriptor_encrypted?: MmrDescriptorParameters; + mmrdescriptor?: MmrDescriptorParameters; + signature?: string; + signaturedata_encrypted?: DataDescriptorInfo; + signaturedata_ssk?: string; + signaturedata?: SignatureDataInfo; + system?: string; + systemid?: string; + hashtype?: string; + mmrhashtype?: string; + hash?: string; + identity?: string; + canonicalname?: string; + address?: string; + signatureheight?: number; + }; +} \ No newline at end of file diff --git a/src/api/classes/index.ts b/src/api/classes/index.ts index ccc14b8..6882c4c 100644 --- a/src/api/classes/index.ts +++ b/src/api/classes/index.ts @@ -25,6 +25,8 @@ import { SendRawTransactionRequest } from './SendRawTransaction/SendRawTransacti import { SendRawTransactionResponse } from './SendRawTransaction/SendRawTransactionResponse' import { SignMessageRequest } from './SignMessage/SignMessageRequest' import { SignMessageResponse } from './SignMessage/SignMessageResponse' +import { SignDataRequest } from './SignData/SignDataRequest' +import { SignDataResponse } from './SignData/SignDataResponse' import { VerifyMessageRequest } from './VerifyMessage/VerifyMessageRequest' import { VerifyMessageResponse } from './VerifyMessage/VerifyMessageResponse' import { GetAddressMempoolResponse } from './GetAddressMempool/GetAddressMempoolResponse' @@ -74,6 +76,8 @@ export { VerifyMessageResponse, SignMessageRequest, SignMessageResponse, + SignDataRequest, + SignDataResponse, SendCurrencyRequest, SendCurrencyResponse, FundRawTransactionRequest, @@ -105,6 +109,7 @@ export type RpcRequest = | typeof GetRawTransactionRequest | typeof VerifyMessageRequest | typeof SignMessageRequest + | typeof SignDataRequest | typeof SendCurrencyRequest | typeof FundRawTransactionRequest | typeof GetCurrencyConvertersRequest @@ -128,6 +133,7 @@ export type RpcResponse = | typeof GetRawTransactionResponse | typeof VerifyMessageResponse | typeof SignMessageResponse + | typeof SignDataResponse | typeof SendCurrencyResponse | typeof FundRawTransactionResponse | typeof GetCurrencyConvertersResponse diff --git a/src/constants/cmds.ts b/src/constants/cmds.ts index f663498..e12da39 100644 --- a/src/constants/cmds.ts +++ b/src/constants/cmds.ts @@ -13,6 +13,7 @@ export const GET_ADDRESS_MEMPOOL = 'getaddressmempool' export const SEND_RAW_TRANSACTION = 'sendrawtransaction' export const GET_ADDRESS_UTXOS = 'getaddressutxos' export const SIGN_MESSAGE = 'signmessage' +export const SIGN_DATA = 'signdata' export const VERIFY_MESSAGE = 'verifymessage' export const FUND_RAW_TRANSACTION = 'fundrawtransaction' export const SEND_CURRENCY = 'sendcurrency' diff --git a/src/constants/vdxf.ts b/src/constants/vdxf.ts index 3f88638..423cf19 100644 --- a/src/constants/vdxf.ts +++ b/src/constants/vdxf.ts @@ -3,6 +3,7 @@ import bufferutils from "../utils/bufferutils"; export const VDXF_OBJECT_DEFAULT_VERSION = new BN(1, 10) export const HASH160_BYTE_LENGTH = 20 +export const HASH256_BYTE_LENGTH = 32 export const I_ADDR_VERSION = 102 export const R_ADDR_VERSION = 60 diff --git a/src/index.ts b/src/index.ts index bd12e9b..4b73ae4 100644 --- a/src/index.ts +++ b/src/index.ts @@ -13,6 +13,7 @@ export * from './utils/varuint' export * from './utils/ops' export * from './utils/evals' export * from './utils/script' +export * from './utils/cccustom' export * from './pbaas/index' diff --git a/src/pbaas/ContentMultiMap.ts b/src/pbaas/ContentMultiMap.ts index 786bcac..b5368eb 100644 --- a/src/pbaas/ContentMultiMap.ts +++ b/src/pbaas/ContentMultiMap.ts @@ -97,24 +97,23 @@ export class ContentMultiMap implements SerializableEntity { return writer.buffer } - fromBuffer(buffer: Buffer, offset: number = 0, keylists: Array | null> = []) { + fromBuffer(buffer: Buffer, offset: number = 0, parseVdxfObjects: boolean = false) { const reader = new BufferReader(buffer, offset); - const contentMultiMapSize = reader.readVarInt(); + const contentMultiMapSize = reader.readCompactSize(); this.kv_content = new Map(); - for (var i = 0; i < contentMultiMapSize.toNumber(); i++) { - const keylist = i < keylists.length ? keylists[i] : null; - + for (var i = 0; i < contentMultiMapSize; i++) { + const contentMapKey = toBase58Check(reader.readSlice(20), I_ADDR_VERSION); const vector: Array = []; const count = reader.readCompactSize(); for (let j = 0; j < count; j++) { - if (keylist) { + if (parseVdxfObjects) { const unival = new VdxfUniValue(); - unival.fromBuffer(reader.readVarSlice(), 0, keylist); + unival.fromBuffer(reader.readVarSlice(), 0); vector.push(unival); } else vector.push(reader.readVarSlice()); diff --git a/src/pbaas/ContentMultiMapRemove.ts b/src/pbaas/ContentMultiMapRemove.ts new file mode 100644 index 0000000..5860f3b --- /dev/null +++ b/src/pbaas/ContentMultiMapRemove.ts @@ -0,0 +1,116 @@ +import varint from '../utils/varint' +import varuint from '../utils/varuint' +import { fromBase58Check, toBase58Check } from "../utils/address"; +import bufferutils from '../utils/bufferutils' +import { BN } from 'bn.js'; +import { BigNumber } from '../utils/types/BigNumber'; +import { I_ADDR_VERSION } from '../constants/vdxf'; +import { SerializableEntity } from '../utils/types/SerializableEntity'; +const { BufferReader, BufferWriter } = bufferutils + +export interface ContentMultiMapRemoveJson { + version: number; + action: number; + entrykey: string; + valuehash: string; +} + +export class ContentMultiMapRemove implements SerializableEntity { + version: BigNumber; + action: BigNumber; + entry_key: string; + value_hash: Buffer; + + static VERSION_INVALID = new BN(0); + static VERSION_FIRST = new BN(1); + static VERSION_LAST = new BN(1); + static VERSION_CURRENT = new BN(1); + static ACTION_FIRST = new BN(1); + static ACTION_REMOVE_ONE_KEYVALUE = new BN(1); + static ACTION_REMOVE_ALL_KEYVALUE = new BN(2); + static ACTION_REMOVE_ALL_KEY = new BN(3); + static ACTION_CLEAR_MAP = new BN(4); + static ACTION_LAST = new BN(4); + + constructor(data?: { version?: BigNumber, action?: BigNumber, entry_key?: string, value_hash?: Buffer }) { + this.version = data?.version || new BN(1, 10); + this.action = data?.action || new BN(0, 10); + this.entry_key = data?.entry_key || ""; + this.value_hash = data?.value_hash || Buffer.alloc(0); + } + + getByteLength() { + let byteLength = 0; + + byteLength += 4; // version uint32 + byteLength += 4; // action uint32 + if (this.action != ContentMultiMapRemove.ACTION_CLEAR_MAP) { + byteLength += 20 + if (this.action != ContentMultiMapRemove.ACTION_REMOVE_ALL_KEY) { + byteLength += 32 + } + } + return byteLength + } + + toBuffer() { + const bufferWriter = new BufferWriter(Buffer.alloc(this.getByteLength())) + + bufferWriter.writeUInt32(this.version.toNumber()); + bufferWriter.writeUInt32(this.action.toNumber()); + + if (this.action != ContentMultiMapRemove.ACTION_CLEAR_MAP) { + bufferWriter.writeSlice(fromBase58Check(this.entry_key).hash); + if (this.action != ContentMultiMapRemove.ACTION_REMOVE_ALL_KEY) { + bufferWriter.writeSlice(this.value_hash); + } + } + + return bufferWriter.buffer + } + + fromBuffer(buffer: Buffer, offset: number = 0) { + const reader = new BufferReader(buffer, offset); + + this.version = new BN(reader.readUInt32()); + this.action = new BN(reader.readUInt32()); + + if (this.action != ContentMultiMapRemove.ACTION_CLEAR_MAP) { + this.entry_key = toBase58Check(reader.readSlice(20), I_ADDR_VERSION) + if (this.action != ContentMultiMapRemove.ACTION_REMOVE_ALL_KEY) { + this.value_hash = reader.readSlice(32) + } + } + return reader.offset; + } + + static fromJson(data: ContentMultiMapRemoveJson): ContentMultiMapRemove { + return new ContentMultiMapRemove({ + version: new BN(data.version), + action: new BN(data.action), + entry_key: data.entrykey, + value_hash: Buffer.from(data.valuehash, 'hex') + }) + } + + toJson(): ContentMultiMapRemoveJson { + return { + version: this.version.toNumber(), + action: this.action.toNumber(), + entrykey: this.entry_key, + valuehash: this.value_hash.toString('hex') + } + } + + isValid() { + + if (this.version.gte(ContentMultiMapRemove.VERSION_FIRST) && + this.version.lte(ContentMultiMapRemove.VERSION_LAST)) { + return (this.action.eq(ContentMultiMapRemove.ACTION_CLEAR_MAP) || + (this.entry_key && (this.entry_key.length > 0) && + (this.action.eq(ContentMultiMapRemove.ACTION_REMOVE_ALL_KEY) || this.value_hash.length > 0) + )); + } + return false; + } +} \ No newline at end of file diff --git a/src/pbaas/CrossChainDataRef.ts b/src/pbaas/CrossChainDataRef.ts new file mode 100644 index 0000000..2c2bcee --- /dev/null +++ b/src/pbaas/CrossChainDataRef.ts @@ -0,0 +1,99 @@ +import varint from '../utils/varint' +import varuint from '../utils/varuint' +import { fromBase58Check, toBase58Check } from "../utils/address"; +import bufferutils from '../utils/bufferutils' +import { BN } from 'bn.js'; +import { BigNumber } from '../utils/types/BigNumber'; +import { I_ADDR_VERSION } from '../constants/vdxf'; +import { SerializableEntity } from '../utils/types/SerializableEntity'; +import { PBaaSEvidenceRef, PBaaSEvidenceRefJson } from './PBaaSEvidenceRef'; +import { IdentityMultimapRef, IdentityMultimapRefJson } from './IdentityMultimapRef'; +import { URLRef, URLRefJson } from './URLRef'; + +const { BufferReader, BufferWriter } = bufferutils + +export type CrossChainDataRefJson = + (PBaaSEvidenceRefJson & { type: number }) + | (IdentityMultimapRefJson & { type: number }) + | (URLRefJson & { type: number }); + +export class CrossChainDataRef implements SerializableEntity { + ref: PBaaSEvidenceRef | IdentityMultimapRef | URLRef; + + static TYPE_CROSSCHAIN_DATAREF = 0; + static TYPE_IDENTITY_DATAREF = 1; + static TYPE_URL_REF = 2; + + constructor(data?: PBaaSEvidenceRef | IdentityMultimapRef | URLRef | any) { + this.ref = data || null; + } + + which(): number { + if (this.ref instanceof PBaaSEvidenceRef) { + return CrossChainDataRef.TYPE_CROSSCHAIN_DATAREF; + } else if (this.ref instanceof IdentityMultimapRef) { + return CrossChainDataRef.TYPE_IDENTITY_DATAREF; + } else if (this.ref instanceof URLRef) { + return CrossChainDataRef.TYPE_URL_REF; + } + } + + getByteLength() { + let byteLength = 1; //type uint8 + byteLength += this.ref.getByteLength(); + return byteLength + } + + toBuffer() { + const bufferWriter = new BufferWriter(Buffer.alloc(this.getByteLength())) + bufferWriter.writeUInt8(this.which()); + bufferWriter.writeSlice(this.ref.toBuffer()); + return bufferWriter.buffer + } + + fromBuffer(buffer: Buffer, offset: number = 0) { + const reader = new BufferReader(buffer, offset); + + const type = reader.readUInt8(); + + if (type == CrossChainDataRef.TYPE_CROSSCHAIN_DATAREF) { + this.ref = new PBaaSEvidenceRef(); + } else if (type == CrossChainDataRef.TYPE_IDENTITY_DATAREF) { + this.ref = new IdentityMultimapRef(); + } else if (type == CrossChainDataRef.TYPE_URL_REF) { + this.ref = new URLRef(); + } + + offset = this.ref.fromBuffer(buffer, reader.offset); + return offset; + } + + isValid(): boolean { + + switch (this.which()) { + case CrossChainDataRef.TYPE_CROSSCHAIN_DATAREF: + return this.ref.isValid(); + case CrossChainDataRef.TYPE_IDENTITY_DATAREF: + return this.ref.isValid(); + case CrossChainDataRef.TYPE_URL_REF: + return this.ref.isValid(); + default: + return false; + } + } + + toJson() { + return {...this.ref.toJson(), type: this.which()}; + } + + static fromJson(data: CrossChainDataRefJson) { + if (data.type == CrossChainDataRef.TYPE_CROSSCHAIN_DATAREF) { + return new CrossChainDataRef(PBaaSEvidenceRef.fromJson(data as PBaaSEvidenceRefJson)); + } else if (data.type == CrossChainDataRef.TYPE_IDENTITY_DATAREF) { + return new CrossChainDataRef(IdentityMultimapRef.fromJson(data as IdentityMultimapRefJson)); + } else if (data.type == CrossChainDataRef.TYPE_URL_REF) { + return new CrossChainDataRef(URLRef.fromJson(data as URLRefJson)); + } + else throw new Error("Invalid CrossChainDataRef type"); + } +} \ No newline at end of file diff --git a/src/pbaas/CurrencyValueMap.ts b/src/pbaas/CurrencyValueMap.ts index 2e50331..db60357 100644 --- a/src/pbaas/CurrencyValueMap.ts +++ b/src/pbaas/CurrencyValueMap.ts @@ -76,4 +76,37 @@ export class CurrencyValueMap implements SerializableEntity { return reader.offset; } + + isValid():boolean + { + for (let [key, value] of this.value_map) + { + if (!key || (typeof(key) == 'string' && key.length == 0)) + { + return false; + } + } + return true; + } + + toJson() { + const value_map: {[key: string]: string} = {}; + + for (let [key, value] of this.value_map) { + value_map[key] = value.toString() + } + + return value_map; + + } + + static fromJson(data: {[key: string]: string}, multivalue: boolean = false): CurrencyValueMap { + const value_map = new Map(); + + for (let key in data) { + value_map.set(key, new BN(data[key])) + } + + return new CurrencyValueMap({ value_map, multivalue }) + } } \ No newline at end of file diff --git a/src/pbaas/DataDescriptor.ts b/src/pbaas/DataDescriptor.ts new file mode 100644 index 0000000..3dae895 --- /dev/null +++ b/src/pbaas/DataDescriptor.ts @@ -0,0 +1,432 @@ +import { BigNumber } from '../utils/types/BigNumber'; +import { BN } from 'bn.js'; +import varint from '../utils/varint' +import varuint from '../utils/varuint' +import bufferutils from '../utils/bufferutils' +const { BufferReader, BufferWriter } = bufferutils +import { VdxfUniValue } from '.'; +import { BufferDataVdxfObject } from '../vdxf/index'; +import * as VDXF_Data from '../vdxf/vdxfdatakeys'; +import { SerializableEntity } from '../utils/types/SerializableEntity'; + +export interface DataDescriptorJson { + version: number; + flags?: number; + objectdata?: string | {['message']: string} | object; + label?: string; + mimetype?: string; + salt?: string; + epk?: string; + ivk?: string; + ssk?: string; +} +export class DataDescriptor implements SerializableEntity { + + static VERSION_INVALID = new BN(0); + static VERSION_FIRST = new BN(1); + static FIRST_VERSION = new BN(1); + static LAST_VERSION = new BN(1); + static DEFAULT_VERSION = new BN(1); + + static FLAG_ENCRYPTED_DATA = new BN(1); + static FLAG_SALT_PRESENT = new BN(2); + static FLAG_ENCRYPTION_PUBLIC_KEY_PRESENT = new BN(4); + static FLAG_INCOMING_VIEWING_KEY_PRESENT = new BN(8); + static FLAG_SYMMETRIC_ENCRYPTION_KEY_PRESENT = new BN(0x10); + static FLAG_LABEL_PRESENT = new BN(0x20); + static FLAG_MIME_TYPE_PRESENT = new BN(0x40); + static FLAG_MASK = (DataDescriptor.FLAG_ENCRYPTED_DATA.add( + DataDescriptor.FLAG_SALT_PRESENT).add( + DataDescriptor.FLAG_ENCRYPTION_PUBLIC_KEY_PRESENT).add( + DataDescriptor.FLAG_INCOMING_VIEWING_KEY_PRESENT).add( + DataDescriptor.FLAG_SYMMETRIC_ENCRYPTION_KEY_PRESENT).add( + DataDescriptor.FLAG_LABEL_PRESENT).add( + DataDescriptor.FLAG_MIME_TYPE_PRESENT)); + + version: BigNumber; + flags: BigNumber; // Flags indicating what items are present in the object + objectdata: Buffer; // either direct data or serialized UTXORef +offset, length, and/or other type of info for different links + label: string; // label associated with this data + mimeType: string; // optional mime type + salt: Buffer; // encryption public key, data only present if encrypted or data referenced by unencrypted link is encrypted + epk: Buffer; // encryption public key, data only present if encrypted or data referenced by unencrypted link is encrypted + ivk: Buffer; // incoming viewing key, optional and contains data only if full viewing key is published at this encryption level + ssk: Buffer; // specific symmetric key, optional and only to decrypt this linked sub-object + + constructor(data?: { + version?: BigNumber, + flags?: BigNumber, + objectdata?: Buffer, + label?: string, + mimeType?: string, + salt?: Buffer, + epk?: Buffer, + ivk?: Buffer, + ssk?: Buffer + }) { + this.flags = new BN(0); + this.version = DataDescriptor.DEFAULT_VERSION; + + if (data != null) { + if (data.flags != null) this.flags = data.flags + if (data.version != null) this.version = data.version + if (data.objectdata != null) this.objectdata = data.objectdata + if (data.label != null) this.label = data.label; + if (data.mimeType != null) this.mimeType = data.mimeType; + if (data.salt != null) this.salt = data.salt; + + if (data.epk != null) this.epk = data.epk; + if (data.ivk != null) this.ivk = data.ivk; + if (data.ssk != null) this.ssk = data.ssk; + + if (this.label && this.label.length > 64) { + this.label = this.label.slice(0, 64); + } + if (this.mimeType && this.mimeType.length > 128) { + this.mimeType = this.mimeType.slice(0, 128); + } + + this.SetFlags(); + + } + } + + static fromJson(data: any): DataDescriptor { + + const newDataDescriptor = new DataDescriptor(); + + if (data != null) { + if (data.flags != null) newDataDescriptor.flags = new BN(data.flags) + if (data.version != null) newDataDescriptor.version = new BN(data.version) + if (data.objectdata != null) newDataDescriptor.objectdata = VdxfUniValue.fromJson(data.objectdata).toBuffer(); + if (data.label != null) newDataDescriptor.label = data.label; + if (data.mimetype != null) newDataDescriptor.mimeType = data.mimetype; + if (data.salt != null) newDataDescriptor.salt = Buffer.from(data.salt, 'hex'); + if (data.epk != null) newDataDescriptor.epk = Buffer.from(data.epk, 'hex'); + if (data.ivk != null) newDataDescriptor.ivk = Buffer.from(data.ivk, 'hex'); + if (data.ssk != null) newDataDescriptor.ssk = Buffer.from(data.ssk, 'hex'); + + if (newDataDescriptor.label && newDataDescriptor.label.length > 64) { + newDataDescriptor.label = newDataDescriptor.label.slice(0, 64); + } + if (newDataDescriptor.mimeType && newDataDescriptor.mimeType.length > 128) { + newDataDescriptor.mimeType = newDataDescriptor.mimeType.slice(0, 128); + } + }; + + newDataDescriptor.SetFlags(); + + return newDataDescriptor; + + } + + DecodeHashVector(): Array { + + const vdxfData = new BufferDataVdxfObject(); + vdxfData.fromBuffer(this.objectdata); + const hashes = []; + + if (vdxfData.vdxfkey == VDXF_Data.VectorUint256Key.vdxfid) { + const reader = new BufferReader(Buffer.from(vdxfData.data, 'hex')); + const count = reader.readVarInt(); + for (let i = 0; i < count.toNumber(); i++) { + hashes.push(reader.readSlice(32)); + } + } + return hashes; + + } + + getByteLength(): number { + + let length = 0; + + length += varint.encodingLength(this.version); + length += varint.encodingLength(this.flags); + length += varuint.encodingLength(this.objectdata.length); + length += this.objectdata.length; + + if (this.HasLabel()) { + if (this.label.length > 64) { + throw new Error("Label too long"); + } + length += varuint.encodingLength(this.label.length); + length += this.label.length; + } + + if (this.HasMIME()) { + if (this.mimeType.length > 128) { + throw new Error("MIME type too long"); + } + length += varuint.encodingLength(this.mimeType.length); + length += this.mimeType.length; + } + + if (this.HasSalt()) { + length += varuint.encodingLength(this.salt.length); + length += this.salt.length; + } + + if (this.HasEPK()) { + length += varuint.encodingLength(this.epk.length); + length += this.epk.length; + } + + if (this.HasIVK()) { + length += varuint.encodingLength(this.ivk.length); + length += this.ivk.length; + } + + if (this.HasSSK()) { + length += varuint.encodingLength(this.ssk.length); + length += this.ssk.length; + } + return length; + } + + toBuffer(): Buffer { + const writer = new BufferWriter(Buffer.alloc(this.getByteLength())); + + writer.writeVarInt(this.version); + writer.writeVarInt(this.flags); + writer.writeVarSlice(this.objectdata); + + if (this.HasLabel()) { + writer.writeVarSlice(Buffer.from(this.label)); + } + + if (this.HasMIME()) { + writer.writeVarSlice(Buffer.from(this.mimeType)); + } + + if (this.HasSalt()) { + writer.writeVarSlice(this.salt); + } + + if (this.HasEPK()) { + writer.writeVarSlice(this.epk); + } + + if (this.HasIVK()) { + writer.writeVarSlice(this.ivk); + } + + if (this.HasSSK()) { + writer.writeVarSlice(this.ssk); + } + + return writer.buffer; + } + + fromBuffer(buffer: Buffer, offset: number = 0): number { + const reader = new BufferReader(buffer, offset); + this.version = reader.readVarInt(); + this.flags = reader.readVarInt(); + this.objectdata = reader.readVarSlice(); + + if (this.HasLabel()) { + this.label = reader.readVarSlice().toString(); + } + + if (this.HasMIME()) { + this.mimeType = reader.readVarSlice().toString(); + } + + if (this.HasSalt()) { + this.salt = reader.readVarSlice(); + } + + if (this.HasEPK()) { + this.epk = reader.readVarSlice(); + } + + if (this.HasIVK()) { + this.ivk = reader.readVarSlice(); + } + + if (this.HasSSK()) { + this.ssk = reader.readVarSlice(); + } + return reader.offset; + + } + + HasEncryptedData(): boolean { + return this.flags.and(DataDescriptor.FLAG_ENCRYPTED_DATA).gt(new BN(0)); + } + + HasSalt(): boolean { + return this.flags.and(DataDescriptor.FLAG_SALT_PRESENT).gt(new BN(0)); + } + + HasEPK(): boolean { + return this.flags.and(DataDescriptor.FLAG_ENCRYPTION_PUBLIC_KEY_PRESENT).gt(new BN(0)); + } + + HasMIME(): boolean { + return this.flags.and(DataDescriptor.FLAG_MIME_TYPE_PRESENT).gt(new BN(0)); + } + + HasIVK(): boolean { + return this.flags.and(DataDescriptor.FLAG_INCOMING_VIEWING_KEY_PRESENT).gt(new BN(0)); + } + + HasSSK(): boolean { + return this.flags.and(DataDescriptor.FLAG_SYMMETRIC_ENCRYPTION_KEY_PRESENT).gt(new BN(0)); + } + + HasLabel(): boolean { + return this.flags.and(DataDescriptor.FLAG_LABEL_PRESENT).gt(new BN(0)); + } + + CalcFlags(): BigNumber { + return this.flags.and(DataDescriptor.FLAG_ENCRYPTED_DATA).add + (this.label ? DataDescriptor.FLAG_LABEL_PRESENT : new BN(0)).add + (this.mimeType ? DataDescriptor.FLAG_MIME_TYPE_PRESENT : new BN(0)).add + (this.salt ? DataDescriptor.FLAG_SALT_PRESENT : new BN(0)).add + (this.epk ? DataDescriptor.FLAG_ENCRYPTION_PUBLIC_KEY_PRESENT : new BN(0)).add + (this.ivk ? DataDescriptor.FLAG_INCOMING_VIEWING_KEY_PRESENT : new BN(0)).add + (this.ssk ? DataDescriptor.FLAG_SYMMETRIC_ENCRYPTION_KEY_PRESENT : new BN(0)); + } + + SetFlags() { + this.flags = this.CalcFlags(); + } + + isValid(): boolean { + return !!(this.version.gte(DataDescriptor.FIRST_VERSION) && this.version.lte(DataDescriptor.LAST_VERSION) && this.flags.and(DataDescriptor.FLAG_MASK.notn(DataDescriptor.FLAG_MASK.bitLength()))); + } + + toJson():DataDescriptorJson { + + const retval: DataDescriptorJson = { + version: this.version.toNumber(), + flags: this.flags.toNumber() + }; + + let isText = false; + if (this.mimeType) { + retval['mimetype'] = this.mimeType; + if (this.mimeType.startsWith("text/")) isText = true; + } + + let processedObject = new VdxfUniValue(); + + processedObject.fromBuffer(this.objectdata) + + if (isText && ((processedObject.values.get("") === "string") || Buffer.isBuffer(processedObject.values.get("")))) { + const objectDataUni = { message: ''}; + if(processedObject.values.get("") === "string") { + objectDataUni.message = processedObject.values.get("") as string; + } else { + objectDataUni.message = (processedObject.values.get("") as Buffer).toString('utf-8'); + } + retval['objectdata'] = objectDataUni; + + } else { + retval['objectdata'] = processedObject.toJson(); + } + + if (this.label) retval['label'] = this.label; + if (this.salt) retval['salt'] = this.salt.toString('hex'); + if (this.epk) retval['epk'] = this.epk.toString('hex'); + if (this.ivk) retval['ivk'] = this.ivk.toString('hex'); + if (this.ssk) retval['ssk'] = this.ssk.toString('hex'); + + return retval; + } +}; + +export class VDXFDataDescriptor extends BufferDataVdxfObject { + dataDescriptor: DataDescriptor; + + constructor(dataDescriptor?: DataDescriptor, + vdxfkey: string = "", + version: BigNumber = new BN(1)) { + super("", vdxfkey); + this.version = version; + if (dataDescriptor) { + this.dataDescriptor = dataDescriptor; + } + } + + static fromDataVdxfObject(data: BufferDataVdxfObject): VDXFDataDescriptor { + + const retval = new VDXFDataDescriptor(); + retval.version = data.version; + retval.data = data.data; + retval.fromBuffer(Buffer.from(retval.data, 'hex')); + delete retval.data; + return retval; + + } + dataByteLength(): number { + + let length = 0; + + length += this.dataDescriptor.getByteLength(); + + return length; + } + + toDataBuffer(): Buffer { + + return this.dataDescriptor.toBuffer(); + } + + fromDataBuffer(buffer: Buffer, offset?: number): number { + const reader = new bufferutils.BufferReader(buffer, offset); + + this.data = reader.readVarSlice().toString('hex'); + + this.dataDescriptor = new DataDescriptor(); + this.dataDescriptor.fromBuffer(Buffer.from(this.data, 'hex'), reader.offset); + delete this.data; + + return reader.offset; + } + + HasEncryptedData(): boolean { + return this.dataDescriptor.HasEncryptedData(); + } + + HasLabel(): boolean { + return this.dataDescriptor.HasLabel(); + } + + HasSalt(): boolean { + return this.dataDescriptor.HasSalt(); + } + + HasEPK(): boolean { + return this.dataDescriptor.HasEPK(); + } + + HasIVK(): boolean { + return this.dataDescriptor.HasIVK(); + } + + HasSSK(): boolean { + return this.dataDescriptor.HasSSK(); + } + + CalcFlags(): BigNumber { + return this.dataDescriptor.CalcFlags(); + } + + SetFlags() { + return this.dataDescriptor.SetFlags(); + } + +}; + +export enum EHashTypes { + HASH_INVALID = 0, + HASH_BLAKE2BMMR = 1, + HASH_BLAKE2BMMR2 = 2, + HASH_KECCAK = 3, + HASH_SHA256D = 4, + HASH_SHA256 = 5, + HASH_LASTTYPE = 5 +}; + diff --git a/src/pbaas/Identity.ts b/src/pbaas/Identity.ts index f880784..2ba705a 100644 --- a/src/pbaas/Identity.ts +++ b/src/pbaas/Identity.ts @@ -144,6 +144,10 @@ export class Identity extends Principal implements SerializableEntity { return length; } + clearContentMultiMap() { + this.content_multimap = new ContentMultiMap({ kv_content: new Map() }); + } + toBuffer() { const writer = new BufferWriter(Buffer.alloc(this.getByteLength())); @@ -197,7 +201,7 @@ export class Identity extends Principal implements SerializableEntity { return writer.buffer } - fromBuffer(buffer: Buffer, offset: number = 0, multimapKeylists: Array | null> = []) { + fromBuffer(buffer: Buffer, offset: number = 0, parseVdxfObjects: boolean = false) { const reader = new BufferReader(buffer, offset); reader.offset = super.fromBuffer(reader.buffer, reader.offset); @@ -215,7 +219,7 @@ export class Identity extends Principal implements SerializableEntity { if (this.version.gte(IDENTITY_VERSION_PBAAS)) { const multimap = new ContentMultiMap(); - reader.offset = multimap.fromBuffer(reader.buffer, reader.offset, multimapKeylists); + reader.offset = multimap.fromBuffer(reader.buffer, reader.offset, parseVdxfObjects); this.content_multimap = multimap; } diff --git a/src/pbaas/IdentityMultimapRef.ts b/src/pbaas/IdentityMultimapRef.ts new file mode 100644 index 0000000..41b9539 --- /dev/null +++ b/src/pbaas/IdentityMultimapRef.ts @@ -0,0 +1,168 @@ +import varint from '../utils/varint' +import varuint from '../utils/varuint' +import { fromBase58Check, toBase58Check } from "../utils/address"; +import bufferutils from '../utils/bufferutils' +import { BN } from 'bn.js'; +import { BigNumber } from '../utils/types/BigNumber'; +import { I_ADDR_VERSION } from '../constants/vdxf'; +import { SerializableEntity } from '../utils/types/SerializableEntity'; + +const { BufferReader, BufferWriter } = bufferutils + +export interface IdentityMultimapRefJson { + version: number; + flags: number; + vdxfkey: string; + startheight: number; + endheight: number; + datahash: string; + systemid: string; +} +export class IdentityMultimapRef implements SerializableEntity { + version: BigNumber; + flags: BigNumber; + id_ID: string; + key: string; + height_start: BigNumber; + height_end: BigNumber; + data_hash: Buffer; + system_id: string; + + static FLAG_NO_DELETION = new BN(1) + static FLAG_HAS_DATAHASH = new BN(2) + static FLAG_HAS_SYSTEM = new BN(4) + static FIRST_VERSION = new BN(1) + static LAST_VERSION = new BN(1) + static CURRENT_VERSION = new BN(1) + + constructor(data?) { + + if (data) { + this.version = data.version || IdentityMultimapRef.CURRENT_VERSION; + this.flags = data.flags || new BN(0); + this.id_ID = data.id_ID || ""; + this.key = data.key || ""; + this.height_start = data.height_start || new BN(0); + this.height_end = data.height_end || new BN(0); + this.data_hash = data.data_hash || Buffer.alloc(0); + this.system_id = data.system_id || ""; + } + } + + setFlags() { + this.flags = this.flags.and(IdentityMultimapRef.FLAG_NO_DELETION); + if (this.data_hash && this.data_hash.length > 0) { + this.flags = this.flags.or(IdentityMultimapRef.FLAG_HAS_DATAHASH); + } + if (this.system_id && this.system_id.length > 0) { + this.flags = this.flags.or(IdentityMultimapRef.FLAG_HAS_SYSTEM); + } + } + + getByteLength() { + let byteLength = 0; + this.setFlags(); + + byteLength += varint.encodingLength(this.version); + byteLength += varint.encodingLength(this.flags); + byteLength += 20; // id_ID uint160 + byteLength += 20; // key uint160 + byteLength += varint.encodingLength(this.height_start); // height_start uint32 + byteLength += varint.encodingLength(this.height_end); // height_end uint32 + byteLength += 32; // data_hash uint25 + + if (this.flags.and(IdentityMultimapRef.FLAG_HAS_DATAHASH).gt(new BN(0))) { + byteLength += 32; + } + + if (this.flags.and(IdentityMultimapRef.FLAG_HAS_SYSTEM).gt(new BN(0))) { + byteLength += 20 + } + return byteLength + } + + toBuffer() { + const bufferWriter = new BufferWriter(Buffer.alloc(this.getByteLength())) + + bufferWriter.writeVarInt(this.version); + bufferWriter.writeVarInt(this.flags); + bufferWriter.writeSlice(fromBase58Check(this.id_ID).hash); + bufferWriter.writeSlice(fromBase58Check(this.key).hash); + bufferWriter.writeVarInt(this.height_start); + bufferWriter.writeVarInt(this.height_end); + + if (this.flags.and(IdentityMultimapRef.FLAG_HAS_DATAHASH).gt(new BN(0))) { + bufferWriter.writeSlice(this.data_hash); + } + if (this.flags.and(IdentityMultimapRef.FLAG_HAS_SYSTEM).gt(new BN(0))) { + bufferWriter.writeSlice(fromBase58Check(this.system_id).hash); + } + + return bufferWriter.buffer + } + + fromBuffer(buffer: Buffer, offset: number = 0) { + const reader = new BufferReader(buffer, offset); + + this.version = reader.readVarInt(); + this.flags = reader.readVarInt(); + this.id_ID = toBase58Check(reader.readSlice(20), I_ADDR_VERSION); + this.key = toBase58Check(reader.readSlice(20), I_ADDR_VERSION); + this.height_start = reader.readVarInt(); + this.height_end = reader.readVarInt(); + + if (this.flags.and(IdentityMultimapRef.FLAG_HAS_DATAHASH).gt(new BN(0))) { + this.data_hash = reader.readSlice(32); + } + + if (this.flags.and(IdentityMultimapRef.FLAG_HAS_SYSTEM).gt(new BN(0))) { + this.system_id = toBase58Check(reader.readSlice(20), I_ADDR_VERSION); + } + return reader.offset; + } + + isValid(): boolean { + return this.version.gte(IdentityMultimapRef.FIRST_VERSION) && + this.version.lte(IdentityMultimapRef.LAST_VERSION) && + (this.flags.and(IdentityMultimapRef.FLAG_HAS_DATAHASH.add(IdentityMultimapRef.FLAG_HAS_SYSTEM).notn(16))).eq(new BN(0)) && + !(!this.id_ID || this.id_ID.length === 0) && !(!this.key || this.key.length === 0); + } + + hasDataHash() { + return this.flags.and(IdentityMultimapRef.FLAG_HAS_DATAHASH).gt(new BN(0)); + } + + hasSystemID() { + return this.flags.and(IdentityMultimapRef.FLAG_HAS_SYSTEM).gt(new BN(0)); + } + + toJson() { + + let retval; + + retval.version = this.version.toString(10); + retval.flags = this.flags.toString(10); + retval.vdxfkey = this.key; + if (this.hasDataHash()) { + retval.datahash = this.data_hash.toString('hex'); + } + + if (this.hasSystemID()) { + retval.systemid = this.system_id; + } + retval.startheight = this.height_start.toString(10); + retval.endheight = this.height_end.toString(10); + } + + static fromJson(data: IdentityMultimapRefJson): IdentityMultimapRef { + return new IdentityMultimapRef({ + version: new BN(data.version), + flags: new BN(data.flags), + key: data.vdxfkey, + height_start: new BN(data.startheight), + height_end: new BN(data.endheight), + data_hash: Buffer.from(data.datahash, 'hex'), + system_id: data.systemid + }) + } +} \ No newline at end of file diff --git a/src/pbaas/MMR.ts b/src/pbaas/MMR.ts new file mode 100644 index 0000000..4532883 --- /dev/null +++ b/src/pbaas/MMR.ts @@ -0,0 +1,581 @@ +// Licence MIT +// Adapted to Verus Blake2b MMR. + +var blake2b = require('blake2b') + +import { BN } from 'bn.js'; +import { VDXFObject } from "../vdxf"; +import varuint from '../utils/varuint' +import bufferutils from '../utils/bufferutils' +import { GetMMRProofIndex } from '../utils/mmr'; + +const { BufferReader, BufferWriter } = bufferutils; +const BRANCH_MMRBLAKE_NODE = 2 + +export class MMRLayer { + + private vSize: number; + private nodes: Array; + + constructor() { this.vSize = 0; } + + size(): number { + return this.vSize; + } + + getIndex(idx: number): NODE_TYPE { + if (idx < this.vSize) { + return this.nodes[idx]; + } + else { + throw new Error("CChunkedLayer [] index out of range"); + } + } + + push_back(node: NODE_TYPE) { + this.vSize++; + if (!this.nodes) { + this.nodes = new Array(); + } + this.nodes.push(node); + } + + clear() { + this.nodes = null; + this.vSize = 0; + } + +}; + +export class MMRNode { + hash: Buffer; + + constructor(Hash?: Buffer) { + if (Hash) { + this.hash = Hash; + } + } + + digest(input) { + var out = Buffer.allocUnsafe(32); + return blake2b(out.length, null, null, Buffer.from("VerusDefaultHash")).update(input).digest(out); + } + + hashObj(obj: Buffer, onbjR?: Buffer): Buffer { + if (!onbjR) return this.digest(obj); + else return this.digest(Buffer.concat([obj, onbjR])); + } + + // add a right to this left and create a parent node + createParentNode(nRight: MMRNode): MMRNode { + return new MMRNode(this.digest(Buffer.concat([this.hash, nRight.hash]))); + } + + getProofHash(opposite: MMRNode): Array { + return [this.hash]; + } + + // leaf nodes that track additional data, such as block power, may need a hash added to the path + // at the very beginning + getLeafHash(): Array { return []; } + + getExtraHashCount() { + // how many extra proof hashes per layer are added with this node + return 0; + } +}; + + + +//template , typename LAYER0_TYPE=LAYER_TYPE> +export class MerkleMountainRange { + layer0: MMRLayer; + vSize: number; + upperNodes: Array>; + _leafLength: number; + + constructor() { + this.layer0 = new MMRLayer(); + this.vSize = 0; + this.upperNodes = new Array>(); + this._leafLength = 0; + } + + getbyteLength(): number { + return 1; + } + + toBuffer(): Buffer { + return Buffer.from([]); + } + + fromBuffer(bufferIn: Buffer): MerkleMountainRange { + return new MerkleMountainRange(); + } + + add(leaf: MMRNode): number { + this.layer0.push_back(leaf); + + let height = 0; + let layerSize: number; + for (layerSize = this.layer0.size(); height <= this.upperNodes.length && layerSize > 1; height++) { + let newSizeAbove = layerSize >> 1; + + // expand vector of vectors if we are adding a new layer + if (height == this.upperNodes.length) { + this.upperNodes.push(new MMRLayer()); + } + + let curSizeAbove = this.upperNodes[height].size(); + + // if we need to add an element to the vector above us, do it + + if (!(layerSize & 1) && newSizeAbove > curSizeAbove) { + let idx = layerSize - 2; + if (height > 0) { + + this.upperNodes[height].push_back(this.upperNodes[height - 1].getIndex(idx).createParentNode(this.upperNodes[height - 1].getIndex(idx + 1))); + } + else { + this.upperNodes[height].push_back(this.layer0.getIndex(idx).createParentNode(this.layer0.getIndex(idx + 1))); + + } + } + layerSize = newSizeAbove; + } + // return new index + return this.layer0.size() - 1; + } + size() { + return this.layer0.size(); + } + + height() { + return this.layer0.size() > 0 ? this.upperNodes.length + 1 : 0; + } + + getNode(Height, Index): MMRNode { + let layers = this.height(); + if (Height < layers) { + if (Height) { + if (Index < this.upperNodes[Height - 1].size()) { + return this.upperNodes[Height - 1].getIndex(Index); + } + } + else { + if (Index < this.layer0.size()) { + return this.layer0.getIndex(Index); + } + } + } + return null; + } + +} + +export class MMRBranch { + branchType?: number; + nIndex?: number; + nSize?: number; + branch?: Array; + + constructor(branchType: number = BRANCH_MMRBLAKE_NODE, nIndex: number = 0, nSize: number = 0, branch: Array = new Array()) { + this.branchType = branchType; + this.nIndex = nIndex; + this.nSize = nSize; + this.branch = branch; + } + + dataByteLength(): number { + + let length = 0; + + length += varuint.encodingLength(this.branchType); + length += varuint.encodingLength(this.nIndex); + length += varuint.encodingLength(this.nSize); + length += varuint.encodingLength(this.branch.length); + + for (let i = 0; i < this.branch.length; i++) { + length += this.branch[i].length; + } + + return length; + + } + + toBuffer(): Buffer { + + const bufferWriter = new BufferWriter(Buffer.alloc(this.dataByteLength())); + + bufferWriter.writeCompactSize(this.branchType); + bufferWriter.writeCompactSize(this.nIndex); + bufferWriter.writeCompactSize(this.nSize); + bufferWriter.writeCompactSize(this.branch.length); + + for (let i = 0; i < this.branch.length; i++) { + bufferWriter.writeSlice(this.branch[i]); + + } + + return bufferWriter.buffer; + + } + + fromBuffer(buffer: Buffer, offset?: number): number { + + const reader = new bufferutils.BufferReader(buffer, offset); + + this.branchType = reader.readCompactSize(); + this.nIndex = reader.readCompactSize(); + this.nSize = reader.readCompactSize(); + + let branchLength = reader.readCompactSize(); + + this.branch = new Array(); + + for (let i = 0; i < branchLength; i++) { + this.branch.push(reader.readSlice(32)); + } + + return reader.offset; + } + + digest(input) { + var out = Buffer.allocUnsafe(32); + return blake2b(out.length, null, null, Buffer.from("VerusDefaultHash")).update(input).digest(out); + } + + safeCheck(hash: Buffer) { + + let index = GetMMRProofIndex(this.nIndex, this.nSize, 0); + + let joined = Buffer.allocUnsafe(64); + let hashInProgress = hash; + + for (let i = 0; i < this.branch.length; i++) { + + if (index.and(new BN(1)).gt(new BN(0))) { + if (this.branch[i] === hashInProgress) throw new Error("Value can be equal to node but never on the right"); + joined = Buffer.concat([this.branch[i], hashInProgress]); + } else { + joined = Buffer.concat([hashInProgress, this.branch[i]]); + } + hashInProgress = this.digest(joined); + + index = index.shrn(1); + } + + return hashInProgress; + } +} + +export class MMRProof { + proofSequence: Array; + + setProof(proof: MMRBranch) { + if (!this.proofSequence) { + this.proofSequence = new Array(); + } + this.proofSequence.push(proof); + } + + dataByteLength(): number { + + let length = 0; + + length += varuint.encodingLength(this.proofSequence.length); + + for (let i = 0; i < this.proofSequence.length; i++) { + length += this.proofSequence[i].dataByteLength(); + } + + return length; + } + + toBuffer(): Buffer { + + const bufferWriter = new BufferWriter(Buffer.alloc(this.dataByteLength())); + + bufferWriter.writeCompactSize(this.proofSequence.length); + + for (let i = 0; i < this.proofSequence.length; i++) { + bufferWriter.writeSlice(this.proofSequence[i].toBuffer()); + + } + + return bufferWriter.buffer; + } + + fromDataBuffer(buffer: Buffer, offset?: number): number { + + const reader = new bufferutils.BufferReader(buffer, offset); + + let proofSequenceLength = reader.readCompactSize(); + + this.proofSequence = new Array(); + + for (let i = 0; i < proofSequenceLength; i++) { + let proof = new MMRBranch(); + reader.offset = proof.fromBuffer(reader.buffer, reader.offset); + this.setProof(proof); + } + + return reader.offset; + } + +} + +//template , typename LAYER0_TYPE=LAYER_TYPE, typename HASHALGOWRITER=CBLAKE2bWriter> +export class MerkleMountainView { + mmr: MerkleMountainRange; // the underlying mountain range, which provides the hash vectors + sizes: Array; // sizes that we will use as proxies for the size of each vector at each height + peaks: Array; // peaks + peakMerkle: Array>; // cached layers for the peak merkle if needed + + constructor(mountainRange: MerkleMountainRange, viewSize: number = 0) { + this.mmr = mountainRange; + let maxSize = this.mmr.size(); + if (viewSize > maxSize || viewSize == 0) { + viewSize = maxSize; + } + this.sizes = new Array(); + this.sizes.push(viewSize); + + for (viewSize >>= 1; viewSize; viewSize >>= 1) { + this.sizes.push(viewSize); + } + this.peakMerkle = new Array>(); + this.peaks = new Array(); + } + + + + // how many elements are stored in this view + size(): number { + // zero if empty or the size of the zeroeth layer + return this.sizes.length == 0 ? 0 : this.sizes[0]; + } + + calcPeaks(force = false) { + // if we don't yet have calculated peaks, calculate them + if (force || (this.peaks.length == 0 && this.size() != 0)) { + // reset the peak merkle tree, in case this is forced + this.peaks = new Array; + this.peakMerkle = new Array>; + for (let ht = 0; ht < this.sizes.length; ht++) { + // if we're at the top or the layer above us is smaller than 1/2 the size of this layer, rounded up, we are a peak + if (ht == (this.sizes.length - 1) || this.sizes[ht + 1] < ((this.sizes[ht] + 1) >> 1)) { + this.peaks.splice(0, 0, this.mmr.getNode(ht, this.sizes[ht] - 1)); + } + } + } + } + + resize(newSize: number): number { + if (newSize != this.size()) { + + this.sizes = new Array; + this.peaks = new Array; + this.peakMerkle = new Array>; + + let maxSize = this.mmr.size(); + if (newSize > maxSize) { + newSize = maxSize; + } + this.sizes.push(newSize); + newSize >>= 1; + + while (newSize) { + this.sizes.push(newSize); + newSize >>= 1; + } + } + return this.size(); + } + + maxsize(): number { + return this.mmr.size() - 1; + } + + getPeaks(): Array { + this.calcPeaks(); + return this.peaks; + } + + getRoot(): Buffer { + let rootHash = Buffer.allocUnsafe(32); + + if (this.size() > 0 && this.peakMerkle.length == 0) { + // get peaks and hash to a root + this.calcPeaks(); + + let layerNum: number = 0, layerSize = this.peaks.length; + // with an odd number of elements below, the edge passes through + for (let passThrough: boolean = !!(layerSize & 1); layerNum == 0 || layerSize > 1; passThrough = !!(layerSize & 1), layerNum++) { + this.peakMerkle.push(Array()); + + let i; + let layerIndex = layerNum ? layerNum - 1 : 0; // layerNum is base 1 + + for (i = 0; i < (layerSize >> 1); i++) { + if (layerNum > 0) { + this.peakMerkle[this.peakMerkle.length - 1].push(this.peakMerkle[layerIndex][i << 1].createParentNode(this.peakMerkle[layerIndex][(i << 1) + 1])); + } + else { + this.peakMerkle[this.peakMerkle.length - 1].push(this.peaks[i << 1].createParentNode(this.peaks[(i << 1) + 1])); + } + } + if (passThrough) { + if (layerNum > 0) { + // pass the end of the prior layer through + this.peakMerkle[this.peakMerkle.length - 1].push(this.peakMerkle[layerIndex][this.peakMerkle[layerIndex].length - 1]); + } + else { + this.peakMerkle[this.peakMerkle.length].push(this.peaks[this.peaks.length - 1]); + } + } + // each entry in the next layer should be either combined two of the prior layer, or a duplicate of the prior layer's end + layerSize = this.peakMerkle[this.peakMerkle.length - 1].length; + } + rootHash = this.peakMerkle[this.peakMerkle.length - 1][0].hash; + } + else if (this.peakMerkle.length > 0) { + rootHash = this.peakMerkle[this.peakMerkle.length - 1][0].hash; + } + return rootHash; + } + + getRootNode(): MMRNode { + // ensure merkle tree is calculated + let root = this.getRoot(); + if (root.length > 0) { + return this.peakMerkle[this.peakMerkle.length - 1][0]; + } + else { + return null; + } + } + + // return hash of the element at "index" + getHash(index: number): Buffer { + if (index < this.size()) { + return this.mmr.layer0[index].hash; + } + else { + return Buffer.allocUnsafe(32); + } + } + + getBranchType(): number { + + return BRANCH_MMRBLAKE_NODE; + } + + // return a proof of the element at "pos" + getProof(retProof: MMRProof, pos: number): boolean { + // find a path from the indicated position to the root in the current view + let retBranch = new MMRBranch(); + + if (pos < this.size()) { + // just make sure the peakMerkle tree is calculated + this.getRoot(); + + // if we have leaf information, add it + let toAdd: Array = this.mmr.layer0.getIndex(pos).getLeafHash(); + if (toAdd.length > 0) { + retBranch.branch.splice(retBranch.branch.length, 0, toAdd[0]); + } + + let p = pos; + for (let l = 0; l < this.sizes.length; l++) { + if ((p & 1) === 1) { + let proofHashes = this.mmr.getNode(l, p - 1).hash; + retBranch.branch = retBranch.branch.concat(proofHashes); + p >>= 1; + } + else { + // make sure there is one after us to hash with or we are a peak and should be hashed with the rest of the peaks + if (this.sizes[l] > (p + 1)) { + let proofHashes = this.mmr.getNode(l, p + 1).hash; + retBranch.branch = retBranch.branch.concat(proofHashes); + p >>= 1; + } + else { + /* for (auto &oneNode : peaks) + { + printf("peaknode: "); + for (auto oneHash : oneNode.getProofHash(oneNode)) + { + printf("%s:", oneHash.GetHex().c_str()); + } + printf("\n"); + } */ + + // we are at a peak, the alternate peak to us, or the next thing we should be hashed with, if there is one, is next on our path + let peakHash = this.mmr.getNode(l, p).hash; + + // linear search to find out which peak we are in the base of the peakMerkle + for (p = 0; p < this.peaks.length; p++) { + if (this.peaks[p].hash == peakHash) { + break; + } + } + + // p is the position in the merkle tree of peaks + if (p > this.peaks.length) throw new Error("peak not found"); + + // move up to the top, which is always a peak of size 1 + let layerNum: number, layerSize: number; + for (layerNum = 0, layerSize = this.peaks.length; layerNum == 0 || layerSize > 1; layerSize = this.peakMerkle[layerNum++].length) { + let layerIndex = layerNum ? layerNum - 1 : 0; // layerNum is base 1 + + // we are an odd member on the end (even index) and will not hash with the next layer above, we will propagate to its end + if ((p < layerSize - 1) || (p & 1)) { + if (p & 1) { + // hash with the one before us + if (layerNum > 0) { + let proofHashes = this.peakMerkle[layerIndex][p - 1].hash; + retBranch.branch = retBranch.branch.concat(proofHashes); + } + else { + let proofHashes = this.peaks[p - 1].hash; + retBranch.branch = retBranch.branch.concat(proofHashes); + } + } + else { + // hash with the one in front of us + if (layerNum > 0) { + let proofHashes = this.peakMerkle[layerIndex][p + 1].hash; + retBranch.branch = retBranch.branch.concat(proofHashes); + } + else { + let proofHashes = this.peaks[p + 1].hash; + retBranch.branch = retBranch.branch.concat(proofHashes); + } + } + } + p >>= 1; + } + + // finished + break; + } + } + } + retBranch.branchType = this.getBranchType(); + retBranch.nSize = this.size(); + retBranch.nIndex = pos; + retProof.setProof(retBranch); + return true; + } + return false; + } + + // return a vector of the bits, either 1 or 0 in each byte, to represent both the size + // of the proof by the size of the vector, and the expected bit in each position for the given + // position in a Merkle Mountain View of the specified size + getProofBits(pos: number, mmvSize: number) { + //NOTE: Not implmented. + }; +} + diff --git a/src/pbaas/MMRDescriptor.ts b/src/pbaas/MMRDescriptor.ts new file mode 100644 index 0000000..a000bd1 --- /dev/null +++ b/src/pbaas/MMRDescriptor.ts @@ -0,0 +1,154 @@ +import { BigNumber } from '../utils/types/BigNumber'; +import { BN } from 'bn.js'; +import varint from '../utils/varint' +import varuint from '../utils/varuint' +import bufferutils from '../utils/bufferutils' +const { BufferReader, BufferWriter } = bufferutils +import { DataDescriptor, DataDescriptorJson } from './DataDescriptor'; +import { EHashTypes } from './DataDescriptor'; +import { VdxfUniValue } from '.'; +import { BufferDataVdxfObject } from '../vdxf/index'; +import * as VDXF_Data from '../vdxf/vdxfdatakeys'; +import { SerializableEntity } from '../utils/types/SerializableEntity'; + +export interface MMRDescriptorJson { + version: number; + objecthashtype?: number; + mmrhashtype?: number; + mmrroot?: DataDescriptorJson; + mmrhashes?: DataDescriptorJson; + datadescriptors?: DataDescriptorJson[]; +} + +export class MMRDescriptor implements SerializableEntity { + static VERSION_INVALID = new BN(0); + static FIRST_VERSION = new BN(1); + static LAST_VERSION = new BN(1); + static DEFAULT_VERSION = new BN(1); + + version: BigNumber; + objectHashType: EHashTypes; + mmrHashType: EHashTypes; + mmrRoot: DataDescriptor; + mmrHashes: DataDescriptor; + dataDescriptors: DataDescriptor[]; + + constructor(data?: { + version?: BigNumber, + objectHashType?: EHashTypes, + mmrHashType?: EHashTypes, + mmrRoot?: DataDescriptor, + mmrHashes?: DataDescriptor, + dataDescriptors?: DataDescriptor[] + }) { + + if (data) { + if (data.version) this.version = data.version; + if (data.objectHashType) this.objectHashType = data.objectHashType; + if (data.mmrHashType) this.mmrHashType = data.mmrHashType; + if (data.mmrRoot) this.mmrRoot = data.mmrRoot; + if (data.mmrHashes) this.mmrHashes = data.mmrHashes; + if (data.dataDescriptors) this.dataDescriptors = data.dataDescriptors; + + } else { + this.version = MMRDescriptor.DEFAULT_VERSION; + } + } + + static fromJson(data: MMRDescriptorJson): MMRDescriptor { + + const newMMRDescriptor = new MMRDescriptor(); + + if (data) { + if (data.version) newMMRDescriptor.version = new BN(data.version); + if (data.objecthashtype) newMMRDescriptor.objectHashType = data.objecthashtype; + if (data.mmrhashtype) newMMRDescriptor.mmrHashType = data.mmrhashtype; + if (data.mmrroot) newMMRDescriptor.mmrRoot = DataDescriptor.fromJson(data.mmrroot); + if (data.mmrhashes) newMMRDescriptor.mmrHashes = DataDescriptor.fromJson(data.mmrhashes); + if (data.datadescriptors) { + newMMRDescriptor.dataDescriptors = []; + + data.datadescriptors.forEach((data) => { + newMMRDescriptor.dataDescriptors.push(DataDescriptor.fromJson(data)); + }); + + }; + } + return newMMRDescriptor; + } + + getByteLength(): number { + let length = 0; + + length += varint.encodingLength(this.version); + length += varint.encodingLength(new BN(this.objectHashType)); + length += varint.encodingLength(new BN(this.mmrHashType)); + length += this.mmrRoot.getByteLength(); + length += this.mmrHashes.getByteLength(); + length += varuint.encodingLength(this.dataDescriptors.length); + this.dataDescriptors.forEach((dataDescriptor) => { + length += dataDescriptor.getByteLength(); + }); + + return length; + } + + toBuffer(): Buffer { + + const writer = new BufferWriter(Buffer.alloc(this.getByteLength())); + + writer.writeVarInt(this.version); + writer.writeVarInt(new BN(this.objectHashType)); + writer.writeVarInt(new BN(this.mmrHashType)); + writer.writeSlice(this.mmrRoot.toBuffer()); + writer.writeSlice(this.mmrHashes.toBuffer()); + writer.writeCompactSize(this.dataDescriptors.length); + + this.dataDescriptors.forEach((dataDescriptor) => { + writer.writeSlice(dataDescriptor.toBuffer()); + }); + return writer.buffer; + } + + fromBuffer(buffer: Buffer, offset?: number): number { + const reader = new BufferReader(buffer, offset); + this.version = reader.readVarInt(); + this.objectHashType = reader.readVarInt().toNumber(); + this.mmrHashType = reader.readVarInt().toNumber(); + this.mmrRoot = new DataDescriptor(); + reader.offset = this.mmrRoot.fromBuffer(reader.buffer, reader.offset); + this.mmrHashes = new DataDescriptor(); + reader.offset = this.mmrHashes.fromBuffer(reader.buffer, reader.offset); + const dataDescriptorsLength = reader.readCompactSize(); + this.dataDescriptors = []; + for (let i = 0; i < dataDescriptorsLength; i++) { + const dataDescriptor = new DataDescriptor(); + reader.offset = dataDescriptor.fromBuffer(reader.buffer, reader.offset); + this.dataDescriptors.push(dataDescriptor); + } + return reader.offset; + } + + hasData(): boolean { + return !!(this.mmrHashes.objectdata && this.dataDescriptors); + } + + isValid(): boolean { + return this.version >= MMRDescriptor.FIRST_VERSION && this.version <= MMRDescriptor.LAST_VERSION; + } + + toJson():MMRDescriptorJson { + + const retval = { + version: this.version.toNumber(), + objecthashtype: this.objectHashType.valueOf(), + mmrhashtype: this.mmrHashType, + mmrroot: this.mmrRoot.toJson(), + mmrhashes: this.mmrHashes.toJson(), + datadescriptors: this.dataDescriptors.map((dataDescriptor) => dataDescriptor.toJson()) + }; + + return retval; + } +}; + diff --git a/src/pbaas/PBaaSEvidenceRef.ts b/src/pbaas/PBaaSEvidenceRef.ts new file mode 100644 index 0000000..c68f979 --- /dev/null +++ b/src/pbaas/PBaaSEvidenceRef.ts @@ -0,0 +1,136 @@ +import varint from '../utils/varint' +import varuint from '../utils/varuint' +import { fromBase58Check, toBase58Check } from "../utils/address"; +import bufferutils from '../utils/bufferutils' +import { BN } from 'bn.js'; +import { BigNumber } from '../utils/types/BigNumber'; +import { I_ADDR_VERSION } from '../constants/vdxf'; +import { SerializableEntity } from '../utils/types/SerializableEntity'; +import { UTXORef } from './UTXORef'; +import { IdentityMultimapRef } from './IdentityMultimapRef'; + +const { BufferReader, BufferWriter } = bufferutils + +export interface PBaaSEvidenceRefJson { + version: number; + flags: number; + output: any; + objectnum: number; + subobject: number; + systemid: string; +} + +export class PBaaSEvidenceRef implements SerializableEntity { + version: BigNumber; + flags: BigNumber; + output: UTXORef; + object_num: BigNumber; + sub_object: BigNumber; + system_id: string; + + static FLAG_ISEVIDENCE = new BN(1) + static FLAG_HAS_SYSTEM = new BN(2) + static FIRST_VERSION = new BN(1) + static LAST_VERSION = new BN(1) + + constructor(data?: { version?: BigNumber, flags?: BigNumber, output?: UTXORef, object_num?: BigNumber, sub_object?: BigNumber, system_id?: string }) { + + if (data) { + this.version = data.version || new BN(1, 10); + this.flags = data.flags || new BN(0); + this.output = data.output || new UTXORef(); + this.object_num = data.object_num || new BN(0); + this.sub_object = data.sub_object || new BN(0); + this.system_id = data.system_id || ""; + } + } + + setFlags() { + this.flags = this.flags.and(PBaaSEvidenceRef.FLAG_ISEVIDENCE); + if (this.system_id && this.system_id.length > 0) { + this.flags = this.flags.or(PBaaSEvidenceRef.FLAG_HAS_SYSTEM); + } + + } + + getByteLength() { + let byteLength = 0; + this.setFlags(); + + byteLength += varint.encodingLength(this.version); + byteLength += varint.encodingLength(this.flags); + byteLength += this.output.getByteLength(); + byteLength += varint.encodingLength(this.object_num); + byteLength += varint.encodingLength(this.sub_object); + + if (this.flags.and(PBaaSEvidenceRef.FLAG_HAS_SYSTEM).gt(new BN(0))) { + byteLength += 20; + } + + return byteLength + } + + toBuffer() { + const bufferWriter = new BufferWriter(Buffer.alloc(this.getByteLength())) + + bufferWriter.writeVarInt(this.version); + bufferWriter.writeVarInt(this.flags); + bufferWriter.writeSlice(this.output.toBuffer()); + bufferWriter.writeVarInt(this.object_num); + bufferWriter.writeVarInt(this.sub_object); + + if (this.flags.and(PBaaSEvidenceRef.FLAG_HAS_SYSTEM).gt(new BN(0))) { + bufferWriter.writeSlice(fromBase58Check(this.system_id).hash); + } + + return bufferWriter.buffer + } + + fromBuffer(buffer: Buffer, offset: number = 0) { + const reader = new BufferReader(buffer, offset); + + this.version = reader.readVarInt(); + this.flags = reader.readVarInt(); + this.output = new UTXORef(); + offset = this.output.fromBuffer(reader.buffer, reader.offset); + this.object_num = reader.readVarInt(); + this.sub_object = reader.readVarInt(); + + if (this.flags.and(IdentityMultimapRef.FLAG_HAS_DATAHASH).gt(new BN(0))) { + this.system_id = toBase58Check(reader.readSlice(20), I_ADDR_VERSION); + } + + return reader.offset; + } + + isValid(): boolean { + return this.output.isValid() && this.version.gte(PBaaSEvidenceRef.FIRST_VERSION) && + this.version.lte(PBaaSEvidenceRef.LAST_VERSION) && + (this.flags.and(PBaaSEvidenceRef.FLAG_ISEVIDENCE).gt(new BN(0))); + } + + toJson(): PBaaSEvidenceRefJson { + + let retval: PBaaSEvidenceRefJson = { + version: this.version.toNumber(), + flags: this.flags.toNumber(), + output: this.output.toJson(), + objectnum: this.object_num.toNumber(), + subobject: this.sub_object.toNumber(), + systemid: this.system_id || "" + } + + return retval; + } + + static fromJson(json: PBaaSEvidenceRefJson): PBaaSEvidenceRef { + return new PBaaSEvidenceRef({ + version: new BN(json.version), + flags: new BN(json.flags), + output: UTXORef.fromJson(json.output), + object_num: new BN(json.objectnum), + sub_object: new BN(json.subobject), + system_id: json.systemid + }); + } +} \ No newline at end of file diff --git a/src/pbaas/Rating.ts b/src/pbaas/Rating.ts new file mode 100644 index 0000000..be0a868 --- /dev/null +++ b/src/pbaas/Rating.ts @@ -0,0 +1,127 @@ +import varuint from '../utils/varuint' +import { fromBase58Check, toBase58Check } from "../utils/address"; +import bufferutils from '../utils/bufferutils' +import { BN } from 'bn.js'; +import { BigNumber } from '../utils/types/BigNumber'; +import { I_ADDR_VERSION } from '../constants/vdxf'; +import { SerializableEntity } from '../utils/types/SerializableEntity'; +const { BufferReader, BufferWriter } = bufferutils + +export interface RatingJson { + version: number; + trustlevel: number; + ratingsmap: {[key: string]: string}; +} +export class Rating implements SerializableEntity { + + static VERSION_INVALID = new BN(0, 10) + static VERSION_FIRST = new BN(1, 10) + static VERSION_LAST = new BN(1, 10) + static VERSION_CURRENT = new BN(1, 10) + + static TRUST_UNKNOWN = new BN(0, 10) // unknown and can be included in exploration + static TRUST_BLOCKED = new BN(1, 10) // suspected or known to be untrustworthy and should not be interacted with + static TRUST_APPROVED = new BN(2, 10) // explicitly believed to be trustworthy enough to interact with + static TRUST_FIRST = new BN(0, 10) + static TRUST_LAST = new BN(2, 10) + + version: BigNumber; + trust_level: BigNumber; + ratings: Map; + + constructor(data: { version?: BigNumber, trust_level?: BigNumber, ratings?: Map } = {}) { + this.version = data.version || new BN(1, 10); + this.trust_level = data.trust_level || new BN(0, 10); + this.ratings = new Map(data.ratings || []); + } + + getByteLength() { + let byteLength = 0; + + byteLength += 4; // version uint32 + byteLength += 1; // trust_level uint8 + byteLength += varuint.encodingLength(this.ratings.size); + + for (const [key, value] of this.ratings) { + byteLength += 20 + byteLength += varuint.encodingLength(value.length) + byteLength += value.length + + } + + return byteLength + } + + toBuffer() { + const bufferWriter = new BufferWriter(Buffer.alloc(this.getByteLength())) + + bufferWriter.writeUInt32(this.version.toNumber()); + bufferWriter.writeUInt8(this.trust_level.toNumber()); + bufferWriter.writeCompactSize(this.ratings.size); + + for (const [key, value] of this.ratings) { + const { hash } = fromBase58Check(key); + + bufferWriter.writeSlice(hash); + bufferWriter.writeVarSlice(value); + } + + return bufferWriter.buffer + } + + fromBuffer(buffer: Buffer, offset: number = 0) { + const reader = new BufferReader(buffer, offset); + + this.version = new BN(reader.readUInt32()); + this.trust_level = new BN(reader.readUInt8()); + + const count = reader.readCompactSize(); + + for (let i = 0; i < count; i++) { + const hash = reader.readSlice(20) + const value = reader.readVarSlice() + + const base58Key = toBase58Check(hash, I_ADDR_VERSION) + + this.ratings.set(base58Key, value) + } + + return reader.offset; + } + + isValid() { + return this.version.gte(Rating.VERSION_FIRST) && this.version.lte(Rating.VERSION_LAST) && + this.trust_level.gte(Rating.TRUST_FIRST) && this.trust_level.lte(Rating.TRUST_LAST); + } + toJson() { + + const ratings: { [key: string]: string } = {}; + + this.ratings.forEach((value, key) => { + ratings[key] = value.toString('hex'); + }); + + return { + version: this.version.toString(), + trust_level: this.trust_level.toString(), + ratings: ratings + } + } + + static fromJson(json: RatingJson) { + + const ratings = new Map(); + + for (const key in json.ratingsmap) { + ratings.set(key, Buffer.from(json.ratingsmap[key], 'hex')); + } + + return new Rating({ + version: new BN(json.version), + trust_level: new BN(json.trustlevel), + ratings: ratings + }) + } + + //TODO: implment ratings values +} \ No newline at end of file diff --git a/src/pbaas/SaltedData.ts b/src/pbaas/SaltedData.ts new file mode 100644 index 0000000..e064631 --- /dev/null +++ b/src/pbaas/SaltedData.ts @@ -0,0 +1,102 @@ +import varint from '../utils/varint' +import varuint from '../utils/varuint' +import { fromBase58Check, toBase58Check } from "../utils/address"; +import bufferutils from '../utils/bufferutils' +import { BN } from 'bn.js'; +import { BigNumber } from '../utils/types/BigNumber'; +import { I_ADDR_VERSION } from '../constants/vdxf'; +import { VDXFData } from '../vdxf/index'; +const { BufferReader, BufferWriter } = bufferutils +const createHash = require("create-hash"); +import { VERUS_DATA_SIGNATURE_PREFIX } from "../constants/vdxf"; +import { SaltedDataKey } from '../vdxf/vdxfdatakeys'; + +export class SaltedData extends VDXFData { + + salt: Buffer; + + static VERSION_INVALID = new BN(0); + static FIRST_VERSION = new BN(1); + static LAST_VERSION = new BN(1); + static DEFAULT_VERSION = new BN(1); + + + constructor(data?: Buffer, salt: Buffer = Buffer.alloc(0)) { + super(data); + if (salt.length != 0) { + this.salt = salt; + } + this.vdxfkey = SaltedDataKey.vdxfid; + this.version = SaltedData.DEFAULT_VERSION; + + } + + static fromJson(data: any) { + + const saltedData = new SaltedData(); + + if (data) { + if (data.version) { + saltedData.version = new BN(data.version); + } else { + saltedData.version = SaltedData.DEFAULT_VERSION; + } + if (data.salt) saltedData.salt = Buffer.from(data.salt, 'hex'); + if (data.data) saltedData.data = Buffer.from(data.data, 'hex'); + if (data.key) saltedData.vdxfkey = data.key; + } + + return saltedData; + } + getByteLength() { + let byteLength = 0; + + byteLength += 20; //key + byteLength += varint.encodingLength(this.version); + byteLength += varuint.encodingLength(this.data.length + this.salt.length); + byteLength += this.data.length + this.salt.length; + + return byteLength + } + + toBuffer() { + const bufferWriter = new BufferWriter(Buffer.alloc(this.getByteLength())) + + bufferWriter.writeSlice(fromBase58Check(this.vdxfkey).hash); + bufferWriter.writeVarInt(this.version); + bufferWriter.writeVarSlice(Buffer.concat([this.data, this.salt])); + + return bufferWriter.buffer + } + + fromBuffer(buffer: Buffer, offset: number = 0) { + const reader = new BufferReader(buffer, offset); + + this.vdxfkey = toBase58Check(reader.readSlice(20), I_ADDR_VERSION); + this.version = reader.readVarInt(); + this.data = reader.readVarSlice(); + + this.salt = this.data.slice(this.data.length - 32); + this.data = this.data.slice(0, this.data.length - 32); + + return reader.offset; + } + + toJson(): any { + + return { + version: this.version.toString(), + key: this.vdxfkey, + data: this.data.toString('hex'), + salt: this.salt.toString('hex') + } + } + + getHash(hw: (data: Buffer) => Buffer ):Buffer { + + const hash = hw(Buffer.concat([this.data, this.salt])); + + return hash; + + } +} \ No newline at end of file diff --git a/src/pbaas/SignatureData.ts b/src/pbaas/SignatureData.ts new file mode 100644 index 0000000..00601df --- /dev/null +++ b/src/pbaas/SignatureData.ts @@ -0,0 +1,255 @@ +import varint from '../utils/varint' +import varuint from '../utils/varuint' +import { fromBase58Check, toBase58Check } from "../utils/address"; +import bufferutils from '../utils/bufferutils' +import { BN } from 'bn.js'; +import { BigNumber } from '../utils/types/BigNumber'; +import { I_ADDR_VERSION } from '../constants/vdxf'; +import { SerializableEntity } from '../utils/types/SerializableEntity'; +import { EHashTypes } from './DataDescriptor'; +const { BufferReader, BufferWriter } = bufferutils +const createHash = require("create-hash"); +import { VERUS_DATA_SIGNATURE_PREFIX } from "../constants/vdxf"; + +export interface SignatureJsonDataInterface { + version: number; + systemid: string; + hashtype: number; + signaturehash: string; + identityid: string; + signaturetype: number; + vdxfkeys: Array; + vdxfkeynames: Array; + boundhashes: Array; + signature: string; +} + +export class SignatureData implements SerializableEntity { + version: BigNumber; + system_ID: string; + hash_type: BigNumber; + signature_hash: Buffer; + identity_ID: string; + sig_type: BigNumber; + vdxf_keys: Array; + vdxf_key_names: Array; + bound_hashes: Array; + signature_as_vch: Buffer; + + static VERSION_INVALID = new BN(0); + static FIRST_VERSION = new BN(1); + static LAST_VERSION = new BN(1); + static DEFAULT_VERSION = new BN(1); + static TYPE_VERUSID_DEFAULT = new BN(1); + + constructor(data?: { version?: BigNumber, system_ID?: string, hash_type?: BigNumber, signature_hash?: Buffer, + identity_ID?: string, sig_type?: BigNumber, vdxf_keys?: Array, vdxf_key_names?: Array, + bound_hashes?: Array, signature_as_vch?: Buffer }) { + + if (data) { + this.version = data.version || new BN(1, 10); + this.system_ID = data.system_ID || ""; + this.hash_type = data.hash_type || new BN(0); + this.signature_hash = data.signature_hash || Buffer.alloc(0); + this.identity_ID = data.identity_ID || ""; + this.sig_type = data.sig_type || new BN(0); + this.vdxf_keys = data.vdxf_keys || []; + this.vdxf_key_names = data.vdxf_key_names || []; + this.bound_hashes = data.bound_hashes || []; + this.signature_as_vch = data.signature_as_vch || Buffer.alloc(0); + } + } + + static fromJson(data: SignatureJsonDataInterface | any) { + + const signatureData = new SignatureData(); + + if (data) { + signatureData.version = new BN(data.version); + signatureData.system_ID = data.systemid; + signatureData.hash_type = new BN(data.hashtype); + signatureData.identity_ID = data.identityid; + signatureData.sig_type = new BN(data.signaturetype); + + if (signatureData.hash_type == new BN(EHashTypes.HASH_SHA256)) { + signatureData.signature_hash = Buffer.from(data.signaturehash, 'hex'); + } else { + signatureData.signature_hash = Buffer.from(data.signaturehash, 'hex').reverse(); + } + + signatureData.signature_as_vch = Buffer.from(data.signature, 'base64'); + signatureData.vdxf_keys = data.vdxfkeys || []; + signatureData.vdxf_key_names = data.vdxfkeynames || []; + signatureData.bound_hashes = data.boundhashes?.map((hash) => Buffer.from(hash, 'hex')) || []; + + } + + return signatureData; + } + + static getSignatureHashType(input: Buffer) { + + var bufferReader = new bufferutils.BufferReader(input, 0); + let version = bufferReader.readUInt8(); + if (version === 2) + return bufferReader.readUInt8(); + else + return EHashTypes.HASH_SHA256; + } + + getByteLength() { + let byteLength = 0; + + byteLength += varint.encodingLength(this.version); + byteLength += 20; // system_ID uint160 + byteLength += varint.encodingLength(this.hash_type); + byteLength += varuint.encodingLength(this.signature_hash.length); + byteLength += this.signature_hash.length; + byteLength += 20; // identity_ID uint160 + byteLength += varint.encodingLength(this.sig_type); + byteLength += varuint.encodingLength(this.vdxf_keys.length); + byteLength += this.vdxf_keys.length * 20; + byteLength += varuint.encodingLength(this.vdxf_key_names.length); + + for (const keyName of this.vdxf_key_names) { + byteLength += varuint.encodingLength(Buffer.from(keyName, 'utf8').length); + byteLength += Buffer.from(keyName, 'utf8').length; + } + + byteLength += varuint.encodingLength(this.bound_hashes.length); + byteLength += this.bound_hashes.length * 32; + byteLength += varuint.encodingLength(this.signature_as_vch.length); + byteLength += this.signature_as_vch.length; + + return byteLength + } + + toBuffer() { + const bufferWriter = new BufferWriter(Buffer.alloc(this.getByteLength())) + + bufferWriter.writeVarInt(this.version); + bufferWriter.writeSlice(fromBase58Check(this.system_ID).hash); + bufferWriter.writeVarInt(this.hash_type); + bufferWriter.writeVarSlice(this.signature_hash); + bufferWriter.writeSlice(fromBase58Check(this.identity_ID).hash); + bufferWriter.writeVarInt(this.sig_type); + bufferWriter.writeCompactSize(this.vdxf_keys.length); + + for (const key of this.vdxf_keys) { + bufferWriter.writeSlice(fromBase58Check(key).hash); + } + + bufferWriter.writeCompactSize(this.vdxf_key_names.length); + for (const keyName of this.vdxf_key_names) { + bufferWriter.writeVarSlice(Buffer.from(keyName, 'utf8')); + } + bufferWriter.writeCompactSize(this.bound_hashes.length); + for (const boundHash of this.bound_hashes) { + bufferWriter.writeSlice(boundHash); + } + bufferWriter.writeVarSlice(this.signature_as_vch); + + return bufferWriter.buffer + } + + fromBuffer(buffer: Buffer, offset: number = 0) { + const reader = new BufferReader(buffer, offset); + + this.version = reader.readVarInt(); + this.system_ID = toBase58Check(reader.readSlice(20), I_ADDR_VERSION); + this.hash_type = reader.readVarInt(); + this.signature_hash = reader.readVarSlice(); + this.identity_ID = toBase58Check(reader.readSlice(20), I_ADDR_VERSION); + this.sig_type = reader.readVarInt(); + const vdxfKeysLength = reader.readCompactSize(); + this.vdxf_keys = []; + + for (let i = 0; i < vdxfKeysLength; i++) { + this.vdxf_keys.push(toBase58Check(reader.readSlice(20), I_ADDR_VERSION)); + } + + const vdxfKeyNamesLength = reader.readCompactSize(); + this.vdxf_key_names = []; + + for (let i = 0; i < vdxfKeyNamesLength; i++) { + this.vdxf_key_names.push(reader.readVarSlice().toString('utf8')); + } + + const boundHashesLength = reader.readCompactSize(); + this.bound_hashes = []; + + for (let i = 0; i < boundHashesLength; i++) { + this.bound_hashes.push(reader.readSlice(32)); + } + + this.signature_as_vch = reader.readVarSlice(); + + return reader.offset; + } + + isValid() { + return !!(this.version.gte(SignatureData.FIRST_VERSION) && + this.version.lte(SignatureData.LAST_VERSION) && + this.system_ID); + } + + toJson() { + + const returnObj = { + version: this.version.toString(), + systemid: this.system_ID, + hashtype: this.hash_type.toString() + } + + if (this.hash_type == new BN(EHashTypes.HASH_SHA256)) { + returnObj['signaturehash'] = this.signature_hash.reverse().toString('hex'); + } else { + returnObj['signaturehash'] = this.signature_hash.toString('hex'); + } + + returnObj['identityid'] = this.identity_ID; + returnObj['signaturetype'] = this.sig_type.toString(); + returnObj['signature'] = this.signature_as_vch.toString('base64'); + + if (this.vdxf_keys) { + returnObj['vdxfkeys'] = this.vdxf_keys; + } + + if (this.vdxf_key_names) { + returnObj['vdxfkeynames'] = this.vdxf_key_names; + } + + if (this.bound_hashes) { + returnObj['boundhashes'] = this.bound_hashes.map((hash) => hash.toString('hex')); + } + + return returnObj + } + + getIdentityHash(sigObject: { version: number, hash_type: number, height: number }) { + var heightBuffer = Buffer.allocUnsafe(4) + heightBuffer.writeUInt32LE(sigObject.height); + + if (sigObject.hash_type != Number(EHashTypes.HASH_SHA256)) { + throw new Error("Invalid signature type for identity hash"); + } + + if (sigObject.version == 1) { + return createHash("sha256") + .update(VERUS_DATA_SIGNATURE_PREFIX) + .update(fromBase58Check(this.system_ID).hash) + .update(heightBuffer) + .update(fromBase58Check(this.identity_ID).hash) + .update(this.signature_hash) + .digest(); + } else { + return createHash("sha256") + .update(fromBase58Check(this.system_ID).hash) + .update(heightBuffer) + .update(fromBase58Check(this.identity_ID).hash) + .update(VERUS_DATA_SIGNATURE_PREFIX) + .update(this.signature_hash) + .digest(); + } + } +} \ No newline at end of file diff --git a/src/pbaas/TransferDestination.ts b/src/pbaas/TransferDestination.ts index 6ec6155..6e5731d 100644 --- a/src/pbaas/TransferDestination.ts +++ b/src/pbaas/TransferDestination.ts @@ -24,6 +24,8 @@ export const FLAG_DEST_AUX = new BN(64, 10) export const FLAG_DEST_GATEWAY = new BN(128, 10) export const FLAG_MASK = FLAG_DEST_AUX.add(FLAG_DEST_GATEWAY) +const UINT160_BYTE_SIZE = 20; + export type TransferDestinationJson = { type: string; destination_bytes: string; @@ -107,9 +109,9 @@ export class TransferDestination implements SerializableEntity { if (this.gateway_code) { length += fromBase58Check(this.gateway_code).hash.length; // gateway_code } else { - length += 20 + length += UINT160_BYTE_SIZE } - length += 8 // fees + length += 8 // fees int64 } if (this.hasAuxDests()) { @@ -137,7 +139,7 @@ export class TransferDestination implements SerializableEntity { if (this.gateway_code) { writer.writeSlice(fromBase58Check(this.gateway_code).hash); } else { - writer.writeSlice(Buffer.alloc(20)); + writer.writeSlice(Buffer.alloc(UINT160_BYTE_SIZE)); } writer.writeInt64(this.fees); } @@ -197,4 +199,50 @@ export class TransferDestination implements SerializableEntity { aux_dests: this.aux_dests.map(x => x.toJson()) } } + + isValid(): boolean + { + // verify aux dests + let valid = (((this.type.and(FLAG_DEST_AUX).gt(new BN(0))) && this.aux_dests.length > 0) || (!(this.type.and(FLAG_DEST_AUX).gt(new BN(0))) && !(this.aux_dests.length > 0))); + if (valid && this.aux_dests && this.aux_dests.length > 0) + { + for (let i = 0; i < this.aux_dests.length; i++) + { + if (!this.getAuxDest(i).isValid()) + { + valid = false; + break; + } + } + } + return !!(valid && + !this.typeNoFlags().eq(DEST_INVALID) && + this.typeNoFlags().lte(LAST_VALID_TYPE_NO_FLAGS) && + (((this.type.and(FLAG_DEST_GATEWAY).eq(new BN(0))) && (this.gateway_id == null)) || this.gateway_id != null)); + } + + getAuxDest(destNum) + { + const retVal = this.aux_dests[destNum]; + if (destNum >= 0 && destNum < this.aux_dests.length) + { + if (retVal.type.and(FLAG_DEST_AUX).gt(new BN(0)) || retVal.aux_dests.length > 0) + { + retVal.type = DEST_INVALID; + } + // no gateways or flags, only simple destinations work + switch (retVal.type) + { + case DEST_ID: + case DEST_PK: + case DEST_PKH: + case DEST_ETH: + case DEST_SH: + break; + default: + retVal.type = DEST_INVALID; + } + } + return retVal; +} } diff --git a/src/pbaas/URLRef.ts b/src/pbaas/URLRef.ts new file mode 100644 index 0000000..7ddf82d --- /dev/null +++ b/src/pbaas/URLRef.ts @@ -0,0 +1,80 @@ +import varint from '../utils/varint' +import varuint from '../utils/varuint' +import { fromBase58Check, toBase58Check } from "../utils/address"; +import bufferutils from '../utils/bufferutils' +import { BN } from 'bn.js'; +import { BigNumber } from '../utils/types/BigNumber'; +import { I_ADDR_VERSION } from '../constants/vdxf'; +import { SerializableEntity } from '../utils/types/SerializableEntity'; + +const { BufferReader, BufferWriter } = bufferutils + +export interface URLRefJson { + version: string; + url: string; +} + +export class URLRef implements SerializableEntity { + + static FIRST_VERSION = new BN(1); + static LAST_VERSION = new BN(1); + + version: BigNumber; + url: string; + constructor(data?: { version?: BigNumber, url?: string }) { + + if (data) { + this.version = data.version || new BN(1, 10); + this.url = data.url || ""; + } + } + + getByteLength() { + let byteLength = 0; + + byteLength += varint.encodingLength(this.version); + byteLength += varuint.encodingLength(Buffer.from(this.url, 'utf8').length); + byteLength += Buffer.from(this.url, 'utf8').length; + if (byteLength > 4096) + throw new Error("URLRef exceeds maximum length of 4096 bytes") + return byteLength + } + + toBuffer() { + const bufferWriter = new BufferWriter(Buffer.alloc(this.getByteLength())) + + bufferWriter.writeVarInt(this.version); + bufferWriter.writeVarSlice(Buffer.from(this.url, 'utf8')); + + return bufferWriter.buffer + } + + fromBuffer(buffer: Buffer, offset: number = 0) { + const reader = new BufferReader(buffer, offset); + + this.version = reader.readVarInt(); + this.url = reader.readVarSlice().toString('utf8'); + + return reader.offset; + } + + isValid(): boolean { + return this.version.gte(URLRef.FIRST_VERSION) && + this.version.lte(URLRef.LAST_VERSION) && + !(!this.url || this.url.length === 0); + } + + toJson() { + return { + version: this.version.toString(10), + url: this.url + } + } + + static fromJson(data: URLRefJson): URLRef { + return new URLRef({ + version: new BN(data.version, 10), + url: data.url + }); + } +} \ No newline at end of file diff --git a/src/pbaas/UTXORef.ts b/src/pbaas/UTXORef.ts new file mode 100644 index 0000000..61ae98c --- /dev/null +++ b/src/pbaas/UTXORef.ts @@ -0,0 +1,65 @@ +import varint from '../utils/varint' +import varuint from '../utils/varuint' +import { fromBase58Check, toBase58Check } from "../utils/address"; +import bufferutils from '../utils/bufferutils' +import { BN } from 'bn.js'; +import { BigNumber } from '../utils/types/BigNumber'; +import { I_ADDR_VERSION } from '../constants/vdxf'; +import { SerializableEntity } from '../utils/types/SerializableEntity'; + +const { BufferReader, BufferWriter } = bufferutils + +export class UTXORef implements SerializableEntity { + hash: Buffer; + n: BigNumber; + + constructor(data?: { hash?: Buffer, n?: BigNumber }) { + this.hash = data.hash || Buffer.alloc(0); + this.n = data.n || new BN(0); + } + + getByteLength() { + let byteLength = 0; + + byteLength += 32; // hash uint256 + byteLength += 4; // n uint32 + + return byteLength + } + + toBuffer() { + const bufferWriter = new BufferWriter(Buffer.alloc(this.getByteLength())) + + bufferWriter.writeSlice(this.hash); + bufferWriter.writeUInt32(this.n.toNumber()); + + return bufferWriter.buffer + } + + fromBuffer(buffer: Buffer, offset: number = 0) { + const reader = new BufferReader(buffer, offset); + + this.hash = reader.readSlice(32); + this.n = new BN(reader.readUInt32()); + + return reader.offset; + } + + isValid(): boolean { + return this.n.lt(new BN(0xffffffff)); + } + + toJson() { + return { + hash: this.hash.toString('hex'), + n: this.n.toNumber() + } + } + + static fromJson(data: { hash: string, n: string }): UTXORef { + return new UTXORef({ + hash: Buffer.from(data.hash, 'hex'), + n: new BN(data.n, 10) + }); + } +} \ No newline at end of file diff --git a/src/pbaas/VdxfUniValue.ts b/src/pbaas/VdxfUniValue.ts index 8fc1019..26a142f 100644 --- a/src/pbaas/VdxfUniValue.ts +++ b/src/pbaas/VdxfUniValue.ts @@ -2,11 +2,20 @@ import varuint from '../utils/varuint' import bufferutils from '../utils/bufferutils' import { BigNumber } from '../utils/types/BigNumber'; import { fromBase58Check, toBase58Check } from '../utils/address'; -import { HASH160_BYTE_LENGTH, I_ADDR_VERSION } from '../constants/vdxf'; +import { HASH160_BYTE_LENGTH, HASH256_BYTE_LENGTH, I_ADDR_VERSION, VDXF_OBJECT_DEFAULT_VERSION } from '../constants/vdxf'; import { BN } from 'bn.js'; -import { DATA_TYPE_STRING } from '../vdxf'; import { SerializableEntity } from '../utils/types/SerializableEntity'; import varint from '../utils/varint'; +import { isHexString } from '../utils/string'; +import { CurrencyValueMap } from './CurrencyValueMap'; +import { Rating, RatingJson } from './Rating'; +import { TransferDestination, TransferDestinationJson } from './TransferDestination'; +import { ContentMultiMapRemove, ContentMultiMapRemoveJson } from './ContentMultiMapRemove'; +import { CrossChainDataRef, CrossChainDataRefJson } from './CrossChainDataRef'; +import { SignatureData, SignatureJsonDataInterface } from './SignatureData'; +import { DataDescriptor, DataDescriptorJson } from './DataDescriptor'; +import { MMRDescriptor, MMRDescriptorJson } from './MMRDescriptor'; +import * as VDXF_Data from '../vdxf/vdxfdatakeys'; export const VDXF_UNI_VALUE_VERSION_INVALID = new BN(0, 10); export const VDXF_UNI_VALUE_VERSION_CURRENT = new BN(1, 10); @@ -14,9 +23,21 @@ export const VDXF_UNI_VALUE_VERSION_CURRENT = new BN(1, 10); const { BufferWriter, BufferReader } = bufferutils // TODO: Add other type definitions -export type VdxfUniType = string | Buffer; -export type VdxfUniValueJson = { [key: string]: string }; - +export type VdxfUniType = string | Buffer | BigNumber | CurrencyValueMap | Rating | + TransferDestination | ContentMultiMapRemove | CrossChainDataRef | SignatureData | + DataDescriptor | MMRDescriptor; + +export interface VdxfUniValueJson { + [key: string]: string | number | RatingJson | TransferDestinationJson | + ContentMultiMapRemoveJson | CrossChainDataRefJson | SignatureJsonDataInterface | DataDescriptorJson | MMRDescriptorJson; + serializedHex?: string; + serializedBase64?: string; + message?: string; +}; + +export type JsonSerializableObject = CurrencyValueMap | Rating | + TransferDestination | ContentMultiMapRemove | CrossChainDataRef | SignatureData | + DataDescriptor | MMRDescriptor; // This UniValue class was adapted from C++ code for encoding JSON objects into bytes. It is not serialization and // therefore doesn't have a fromBuffer function, as you can't reliably decode it, only encode. export class VdxfUniValue implements SerializableEntity { @@ -34,101 +55,614 @@ export class VdxfUniValue implements SerializableEntity { for (const key of this.values.keys()) { const value = this.values.get(key); - length += HASH160_BYTE_LENGTH; - length += varint.encodingLength(this.version); - if (key == DATA_TYPE_STRING.vdxfid) { - const valueString = (value as string); - const valBuf = Buffer.from(valueString, 'utf8'); + // if we just have serialized data + if (key === "") { + length += Buffer.from(value as string, "hex").length; + continue; + } - //NOTE 3 is from ss type + ver + vdxfidver - length += varint.encodingLength(new BN(valBuf.length + 3)); + if (key == VDXF_Data.DataByteKey.vdxfid) { + length += 1; + continue; + } + else if ((key == VDXF_Data.DataUint16Key.vdxfid) || (key == VDXF_Data.DataInt16Key.vdxfid)) { + length += 2; + continue; + } + else if ((key == VDXF_Data.DataInt32Key.vdxfid) || (key == VDXF_Data.DataUint32Key.vdxfid)) { + length += 4; + continue; + } + else if (key == VDXF_Data.DataInt64Key.vdxfid) { + length += 8; + continue; + } + else if (key == VDXF_Data.DataUint160Key.vdxfid) { + length += HASH160_BYTE_LENGTH; + continue; + } + else if (key == VDXF_Data.DataUint256Key.vdxfid) { + length += HASH256_BYTE_LENGTH; + continue; + } + length += HASH160_BYTE_LENGTH; + + if (key == VDXF_Data.DataStringKey.vdxfid) { + const valBuf = Buffer.from(value as string, "utf-8"); + length += varint.encodingLength(new BN(1)); + // NOTE: 3 is from ss type + ver + vdxfIdVersion + length += varuint.encodingLength(valBuf.length + 3); length += varuint.encodingLength(valBuf.length); length += valBuf.length; - } else throw new Error("Invalid or unrecognized vdxf key for object type") - } + } + else if (key == VDXF_Data.DataByteVectorKey.vdxfid) { + const valBuf = Buffer.from(value as string, "hex"); + length += varint.encodingLength(new BN(1)); + length += varuint.encodingLength(valBuf.length + 3); + length += varuint.encodingLength(valBuf.length) + length += valBuf.length; + } + else if (key == VDXF_Data.DataCurrencyMapKey.vdxfid) { + + const destinations = Object.keys(value); + const values = Object.values(value); + const oneCurMap = new CurrencyValueMap({ value_map: new Map(destinations.map((key, index) => [key, new BN(values[index])])), multivalue: true }); + length += varint.encodingLength(new BN(1)); + length += varuint.encodingLength(oneCurMap.getByteLength()); + length += oneCurMap.getByteLength(); + } + else if (key == VDXF_Data.DataRatingsKey.vdxfid) { + + const oneRatingMap = new Rating(value as Rating); + + length += varint.encodingLength(oneRatingMap.version); + length += varuint.encodingLength(oneRatingMap.getByteLength() + 3); + length += oneRatingMap.getByteLength(); + } + else if (key == VDXF_Data.DataTransferDestinationKey.vdxfid) { + + const transferDest = new TransferDestination(value as TransferDestination); + + length += varint.encodingLength(transferDest.typeNoFlags()); + length += varuint.encodingLength(transferDest.getByteLength() + 3); + length += transferDest.getByteLength(); + } + else if (key == VDXF_Data.ContentMultiMapRemoveKey.vdxfid) { + + const transferDest = new ContentMultiMapRemove(value as ContentMultiMapRemove); + + length += varint.encodingLength(transferDest.version); + length += varuint.encodingLength(transferDest.getByteLength() + 3); + length += transferDest.getByteLength(); + } + else if (key == VDXF_Data.CrossChainDataRefKey.vdxfid) { + + const transferDest = new CrossChainDataRef(value); + + length += varint.encodingLength(VDXF_OBJECT_DEFAULT_VERSION); + length += varuint.encodingLength(transferDest.getByteLength() + 3); + length += transferDest.getByteLength(); + } + else if (key == VDXF_Data.DataDescriptorKey.vdxfid) { + + const descr = new DataDescriptor(value as DataDescriptor); + + length += varint.encodingLength(descr.version); + length += varuint.encodingLength(descr.getByteLength() + 3); + length += descr.getByteLength(); + } + else if (key == VDXF_Data.MMRDescriptorKey.vdxfid) { + + const descr = new MMRDescriptor(value as MMRDescriptor); + + length += varint.encodingLength(descr.version); + length += varuint.encodingLength(descr.getByteLength() + 3); + length += descr.getByteLength(); + } + else if (key == VDXF_Data.SignatureDataKey.vdxfid) { + + const sigData = new SignatureData(value as SignatureData); + + length += varint.encodingLength(sigData.version); + length += varuint.encodingLength(sigData.getByteLength() + 3); + length += sigData.getByteLength(); + } else { + throw new Error("contentmap invalid or unrecognized vdxfkey for object type: " + key); + } + } return length; } - toBuffer() { + toBuffer(): Buffer { const writer = new BufferWriter(Buffer.alloc(this.getByteLength())); - for (const key of this.values.keys()) { + for (const key of this.values.keys()) { const value = this.values.get(key); - writer.writeSlice(fromBase58Check(key).hash) - writer.writeVarInt(this.version); + if (key === "") { + writer.writeSlice(value as Buffer); + continue; + } - if (key == DATA_TYPE_STRING.vdxfid) { - const valueString = value as string; - const valBuf = Buffer.from(valueString, 'utf8'); + if (key == VDXF_Data.DataByteKey.vdxfid) { + const oneByte = Buffer.from(value as string, "hex"); + if (oneByte.length != 1) { + throw new Error("contentmap: byte data must be exactly one byte"); + } + writer.writeSlice(oneByte); + } + else if (key == VDXF_Data.DataInt16Key.vdxfid) { + const oneShort = Buffer.alloc(2); + oneShort.writeInt16LE((value as BigNumber).toNumber()); + writer.writeSlice(oneShort); + } + else if (key == VDXF_Data.DataUint16Key.vdxfid) { + const oneUShort = Buffer.alloc(2); + oneUShort.writeUInt16LE((value as BigNumber).toNumber()); + writer.writeSlice(oneUShort); + } + else if (key == VDXF_Data.DataInt32Key.vdxfid) { + const oneInt = Buffer.alloc(4); + oneInt.writeInt32LE((value as BigNumber).toNumber()); + writer.writeSlice(oneInt); + } + else if (key == VDXF_Data.DataUint32Key.vdxfid) { + const oneUInt = Buffer.alloc(4); + oneUInt.writeUInt32LE((value as BigNumber).toNumber()); + writer.writeSlice(oneUInt); + } + else if (key == VDXF_Data.DataInt64Key.vdxfid) { + const oneInt64 = Buffer.alloc(8); + oneInt64.writeBigInt64LE(BigInt((value as BigNumber).toString())); + writer.writeSlice(oneInt64); + } + else if (key == VDXF_Data.DataUint160Key.vdxfid) { + const oneKey = fromBase58Check(value as string).hash; + writer.writeSlice(oneKey); + } + else if (key == VDXF_Data.DataUint256Key.vdxfid) { + const oneHash = Buffer.from(value as string, "hex"); + if (oneHash.length != HASH256_BYTE_LENGTH) { + throw new Error("contentmap: hash data must be exactly 32 bytes"); + } + writer.writeVarSlice(oneHash.reverse()); + } + else if (key == VDXF_Data.DataStringKey.vdxfid) { - //NOTE 3 is from ss type + ver + vdxfidver - writer.writeVarInt(new BN(valBuf.length + 3)); + const valBuf = Buffer.from(value as string, "utf-8"); + writer.writeSlice(fromBase58Check(key).hash); + writer.writeVarInt(new BN(1)); + writer.writeCompactSize(valBuf.length + 3); writer.writeVarSlice(valBuf); - } else throw new Error("Invalid or unrecognized vdxf key for object type") - } + } + else if (key == VDXF_Data.DataByteVectorKey.vdxfid) { - return writer.buffer; - } + const encodedLength = varuint.encodingLength(Buffer.from(value as string, "hex").length) - fromBuffer(buffer: Buffer, offset: number = 0, keylist: Array = []): number { - const reader = new BufferReader(buffer, offset); - let lastPrereadOffset = reader.offset; + writer.writeSlice(fromBase58Check(key).hash); + writer.writeVarInt(new BN(1)); + writer.writeCompactSize(encodedLength + Buffer.from(value as string, "hex").length); + writer.writeVarSlice(Buffer.from(value as string, "hex")); + } + else if (key == VDXF_Data.DataCurrencyMapKey.vdxfid) { - function readNextKey() { - lastPrereadOffset = reader.offset; + const destinations = Object.keys(value); + const values = Object.values(value); + const oneCurMap = new CurrencyValueMap({ value_map: new Map(destinations.map((key, index) => [key, new BN(values[index])])), multivalue: true }); - try { - return toBase58Check(reader.readSlice(20), I_ADDR_VERSION); - } catch(e) { - return null; + writer.writeSlice(fromBase58Check(key).hash); + writer.writeVarInt(new BN(1)); + writer.writeCompactSize(oneCurMap.getByteLength()); + writer.writeSlice(oneCurMap.toBuffer()); } - } + else if (key == VDXF_Data.DataRatingsKey.vdxfid) { - this.values = new Map(); + const oneRatingMap = new Rating(value as Rating); + + writer.writeSlice(fromBase58Check(key).hash); + writer.writeVarInt(oneRatingMap.version); + writer.writeCompactSize(oneRatingMap.getByteLength()); + writer.writeSlice(oneRatingMap.toBuffer()); + } + else if (key == VDXF_Data.DataTransferDestinationKey.vdxfid) { + + const transferDest = new TransferDestination(value as TransferDestination); + const writer = new BufferWriter(Buffer.alloc(length)); + + writer.writeSlice(fromBase58Check(key).hash); + writer.writeVarInt(transferDest.typeNoFlags()); + writer.writeCompactSize(transferDest.getByteLength()); + writer.writeSlice(transferDest.toBuffer()); + } + else if (key == VDXF_Data.ContentMultiMapRemoveKey.vdxfid) { + + const transferDest = new ContentMultiMapRemove(value as ContentMultiMapRemove); + + writer.writeSlice(fromBase58Check(key).hash); + writer.writeVarInt(transferDest.version); + writer.writeCompactSize(transferDest.getByteLength()); + writer.writeSlice(transferDest.toBuffer()); + } + else if (key == VDXF_Data.CrossChainDataRefKey.vdxfid) { - for (const key of keylist) { - const dataTypeKey = readNextKey(); - this.version = reader.readVarInt(); + const transferDest = new CrossChainDataRef(value as CrossChainDataRef); - if (this.version.gt(VDXF_UNI_VALUE_VERSION_CURRENT)) throw new Error("Unknown VDXFUniValue version"); + writer.writeSlice(fromBase58Check(key).hash); + writer.writeVarInt(VDXF_OBJECT_DEFAULT_VERSION); + writer.writeCompactSize(transferDest.getByteLength()); + writer.writeSlice(transferDest.toBuffer()); + } + else if (key == VDXF_Data.DataDescriptorKey.vdxfid) { - if (dataTypeKey == DATA_TYPE_STRING.vdxfid) { - reader.readVarInt(); + const descr = new DataDescriptor(value as DataDescriptor); - const slice = reader.readVarSlice(); + writer.writeSlice(fromBase58Check(key).hash); + writer.writeVarInt(descr.version); + writer.writeCompactSize(descr.getByteLength()); + writer.writeSlice(descr.toBuffer()); + } + else if (key == VDXF_Data.MMRDescriptorKey.vdxfid) { - this.values.set(dataTypeKey, slice.toString('utf8')); + const descr = new MMRDescriptor(value as MMRDescriptor); + + writer.writeSlice(fromBase58Check(key).hash); + writer.writeVarInt(descr.version); + writer.writeCompactSize(descr.getByteLength()); + writer.writeSlice(descr.toBuffer()); + } + else if (key == VDXF_Data.SignatureDataKey.vdxfid) { + + const sigData = new SignatureData(value as SignatureData); + + writer.writeSlice(fromBase58Check(key).hash); + writer.writeVarInt(sigData.version); + writer.writeCompactSize(sigData.getByteLength()); + writer.writeSlice(sigData.toBuffer()); } else { - throw new Error("Invalid or unrecognized vdxf key for object type") + throw new Error("contentmap invalid or unrecognized vdxfkey for object type: " + key); } + } + return writer.buffer; + } + + fromBuffer(buffer: Buffer, offset: number = 0): number { + const reader = new BufferReader(buffer, offset); + + this.values = new Map(); + + let bytesLeft = reader.buffer.length - reader.offset; + + while (bytesLeft > HASH160_BYTE_LENGTH) // size of uint160 + { + let pSuccess = { value: false }; + let objectUni: { key: string, value: VdxfUniType }; + const initialOffset = reader.offset; + + try { + let checkVal: string; + let version = new BN(0); + let objSize = 0; + checkVal = toBase58Check(reader.readSlice(HASH160_BYTE_LENGTH), I_ADDR_VERSION); + + if (checkVal == VDXF_Data.DataCurrencyMapKey.vdxfid) { + const oneCurrencyMap = new CurrencyValueMap({multivalue:true}); + version = reader.readVarInt(); + objSize = reader.readCompactSize(); + reader.offset = oneCurrencyMap.fromBuffer(reader.buffer, reader.offset); + if (oneCurrencyMap.isValid()) { + objectUni = { key: checkVal, value: oneCurrencyMap }; + } + } + else if (checkVal == VDXF_Data.DataRatingsKey.vdxfid) { + const oneRatingObj = new Rating(); + version = reader.readVarInt(); + objSize = reader.readCompactSize(); + reader.offset = oneRatingObj.fromBuffer(reader.buffer, reader.offset); + if (oneRatingObj.isValid()) { + objectUni = { key: checkVal, value: oneRatingObj }; + } + } + else if (checkVal == VDXF_Data.DataTransferDestinationKey.vdxfid) { + const oneTransferDest = new TransferDestination(); + version = reader.readVarInt(); + objSize = reader.readCompactSize(); + reader.offset = oneTransferDest.fromBuffer(reader.buffer, reader.offset); + if (oneTransferDest.isValid()) { + objectUni = { key: checkVal, value: oneTransferDest }; + } + } + else if (checkVal == VDXF_Data.ContentMultiMapRemoveKey.vdxfid) { + const contentMap = new ContentMultiMapRemove(); + version = reader.readVarInt(); + objSize = reader.readCompactSize(); + reader.offset = contentMap.fromBuffer(reader.buffer, reader.offset); + if (contentMap.isValid()) { + objectUni = { key: checkVal, value: contentMap }; + } + } + else if (checkVal == VDXF_Data.DataStringKey.vdxfid) { + let stringVal: string; + version = reader.readVarInt(); + objSize = reader.readCompactSize(); + stringVal = reader.readVarSlice().toString('utf8'); + objectUni = { key: checkVal, value: stringVal }; + } + else if (checkVal == VDXF_Data.DataByteVectorKey.vdxfid) { + let vecVal: Buffer; + version = reader.readVarInt(); + objSize = reader.readCompactSize(); + vecVal = reader.readVarSlice(); + objectUni = { key: checkVal, value: vecVal.toString('hex') }; + } + else if (checkVal == VDXF_Data.CrossChainDataRefKey.vdxfid) { + const dataRef = new CrossChainDataRef(); + version = reader.readVarInt(); + objSize = reader.readCompactSize(); + reader.offset = dataRef.fromBuffer(reader.buffer, reader.offset); + if (dataRef.isValid()) { + objectUni = { key: checkVal, value: dataRef }; + } + } + else if (checkVal == VDXF_Data.DataDescriptorKey.vdxfid) { + const dataDescriptor = new DataDescriptor(); + version = reader.readVarInt(); + objSize = reader.readCompactSize(); + reader.offset = dataDescriptor.fromBuffer(reader.buffer, reader.offset); + if (dataDescriptor.isValid()) { + objectUni = { key: checkVal, value: dataDescriptor }; + } + } + else if (checkVal == VDXF_Data.MMRDescriptorKey.vdxfid) { + const mmrDescriptor = new MMRDescriptor(); + version = reader.readVarInt(); + objSize = reader.readCompactSize(); + reader.offset = mmrDescriptor.fromBuffer(reader.buffer, reader.offset); + if (mmrDescriptor.isValid()) { + objectUni = { key: checkVal, value: mmrDescriptor }; + } + } + else if (checkVal == VDXF_Data.SignatureDataKey.vdxfid) { + const sigData = new SignatureData(); + version = reader.readVarInt(); + objSize = reader.readCompactSize(); + reader.offset = sigData.fromBuffer(reader.buffer, reader.offset); + if (sigData.isValid()) { + objectUni = { key: checkVal, value: sigData }; + } + } + + // if we have an object that we recognized, encode it + if (objectUni && objectUni.key && objectUni.value) { + if (pSuccess != null) { + pSuccess.value = true; + } + } + else { + if (pSuccess != null) { + pSuccess.value = false; + } + } + } + catch (e) { + if (pSuccess != null) { + pSuccess.value = false; + } + } + + bytesLeft = reader.buffer.length - reader.offset; + + if (pSuccess?.value && pSuccess?.value) { + this.values.set(objectUni.key, objectUni.value); + } + else { + // add the remaining data as a hex string + reader.offset = initialOffset; + this.values.set("", reader.readSlice(reader.buffer.length - reader.offset)); + bytesLeft = 0; + break; + } + } + if (bytesLeft && bytesLeft <= HASH160_BYTE_LENGTH) { + this.values.set("", reader.readSlice(bytesLeft)); + } return reader.offset; } static fromJson(obj: VdxfUniValueJson) { - const map = new Map() + const map = new Map(); + + if (typeof (obj) != 'object') { + if (typeof (obj) != 'string') throw new Error('Not JSON string as expected'); + if (isHexString(obj)) { + map.set("", Buffer.from(obj, "hex")) + return new VdxfUniValue({ + values: map + }); + } + map.set("", Buffer.from(obj, "utf-8")) + return new VdxfUniValue({ + values: map + }); + } - for (const key in obj) { - map.set(key, obj[key]); + if (obj.serializedHex) { + if (!isHexString(obj.serializedHex)) { + throw new Error("contentmap: If the \"serializedhex\" key is present, it's data must be only valid hex and complete"); + } + map.set("", Buffer.from(obj.serializedHex, "hex")) + return new VdxfUniValue({ + values: map + }); + } + + if (obj.serializedBase64) { + try { + map.set("", Buffer.from(obj.serializedBase64, "base64")) + return new VdxfUniValue({ + values: map + }); + } catch (e) { + throw new Error("contentmap: If the \"serializedBase64\" key is present, it's data must be only valid base64 and complete"); + } } + if (obj.message) { + map.set("", Buffer.from(obj.message, "utf-8")) + return new VdxfUniValue({ + values: map + }); + } + + // this should be an object with "vdxfkey" as the key and {object} as the json object to serialize + const oneValKeys = Object.keys(obj); + const oneValValues = Object.values(obj); + + for (let k = 0; k < oneValKeys.length; k++) { + const objTypeKey = oneValKeys[k]; + if (objTypeKey == VDXF_Data.DataByteKey.vdxfid) { + + const oneByte = Buffer.from(oneValValues[k] as string, "hex"); + if (oneByte.length != 1) { + throw new Error("contentmap: byte data must be exactly one byte"); + } + map.set(objTypeKey, oneByte); + } + else if (objTypeKey == VDXF_Data.DataInt16Key.vdxfid) { + const oneShort = Buffer.alloc(2); + oneShort.writeInt16LE(oneValValues[k] as number); + map.set(objTypeKey, oneShort); + } + else if (objTypeKey == VDXF_Data.DataUint16Key.vdxfid) { + const oneUShort = Buffer.alloc(2); + oneUShort.writeUInt16LE(oneValValues[k] as number); + map.set(objTypeKey, oneUShort); + } + else if (objTypeKey == VDXF_Data.DataInt32Key.vdxfid) { + const oneInt = Buffer.alloc(4); + oneInt.writeInt32LE(oneValValues[k] as number); + map.set(objTypeKey, oneInt); + + } + else if (objTypeKey == VDXF_Data.DataUint32Key.vdxfid) { + const oneUInt = Buffer.alloc(4); + oneUInt.writeUInt32LE(oneValValues[k] as number); + map.set(objTypeKey, oneUInt); + } + else if (objTypeKey == VDXF_Data.DataInt64Key.vdxfid) { + const oneInt64 = Buffer.alloc(8); + oneInt64.writeIntLE(oneValValues[k] as number, 0, 8); + map.set(objTypeKey, oneInt64); + } + else if (objTypeKey == VDXF_Data.DataUint160Key.vdxfid) { + fromBase58Check(oneValValues[k] as string).hash; + map.set(objTypeKey, oneValValues[k]); + } + else if (objTypeKey == VDXF_Data.DataUint256Key.vdxfid) { + const oneHash = Buffer.from(oneValValues[k] as string, "hex"); + if (oneHash.length != HASH256_BYTE_LENGTH) { + throw new Error("contentmap: hash data must be exactly 32 bytes"); + } + map.set(objTypeKey, oneHash); + } + else if (objTypeKey == VDXF_Data.DataStringKey.vdxfid) { + map.set(objTypeKey, oneValValues[k]); + } + else if (objTypeKey == VDXF_Data.DataByteVectorKey.vdxfid) { + + if (!isHexString(oneValValues[k] as string)) { + throw new Error("contentmap: bytevector data must be valid hex"); + } + + map.set(objTypeKey, Buffer.from(oneValValues[k] as string, "hex")); + + } + else if (objTypeKey == VDXF_Data.DataCurrencyMapKey.vdxfid) { + + const destinations = Object.keys(oneValValues[k]); + const values = Object.values(oneValValues[k]); + + const oneCurMap = new CurrencyValueMap({ value_map: new Map(destinations.map((key, index) => [key, new BN(values[index])])), multivalue: true }); + map.set(objTypeKey, oneCurMap); + + } + else if (objTypeKey == VDXF_Data.DataRatingsKey.vdxfid) { + + const oneRatingMap = Rating.fromJson(oneValValues[k] as RatingJson); + map.set(objTypeKey, oneRatingMap); + + } + else if (objTypeKey == VDXF_Data.DataTransferDestinationKey.vdxfid) { + + const transferDest = TransferDestination.fromJson(oneValValues[k] as TransferDestinationJson); + map.set(objTypeKey, transferDest); + + } + else if (objTypeKey == VDXF_Data.ContentMultiMapRemoveKey.vdxfid) { + + const content = ContentMultiMapRemove.fromJson(oneValValues[k] as ContentMultiMapRemoveJson); + map.set(objTypeKey, content); + + } + else if (objTypeKey == VDXF_Data.CrossChainDataRefKey.vdxfid) { + + const crossChainRefKey = CrossChainDataRef.fromJson(oneValValues[k] as CrossChainDataRefJson); + map.set(objTypeKey, crossChainRefKey); + + } + else if (objTypeKey == VDXF_Data.DataDescriptorKey.vdxfid) { + + const descriptor = DataDescriptor.fromJson(oneValValues[k]); + map.set(objTypeKey, descriptor); + + } + else if (objTypeKey == VDXF_Data.MMRDescriptorKey.vdxfid) { + + const mmrDescriptor = MMRDescriptor.fromJson(oneValValues[k] as MMRDescriptorJson); + map.set(objTypeKey, mmrDescriptor); + + } + else if (objTypeKey == VDXF_Data.SignatureDataKey.vdxfid) { + + const sigData = SignatureData.fromJson(oneValValues[k]); + map.set(objTypeKey, sigData); + + } + else { + throw new Error("Unkknow vdxfkey: " + oneValValues[k]); + } + } return new VdxfUniValue({ values: map }) } toJson(): VdxfUniValueJson { - const ret = {}; + let ret = {}; for (const key of this.values.keys()) { - ret[key] = this.values.get(key) as string; + if (key === "") { + ret[key] = (this.values.get(key) as Buffer).toString('hex'); + } else if (typeof (this.values.get(key)) == 'string') { + ret[key] = this.values.get(key) as string; + } else if (Buffer.isBuffer(this.values.get(key))) { + ret[key] = (this.values.get(key) as Buffer).toString('hex'); + } else if (this.values.get(key) instanceof BN) { + ret[key] = (this.values.get(key) as BigNumber).toString(10); + } else { + ret[key] = (this.values.get(key) as JsonSerializableObject).toJson(); + } + } + + if (ret && ret[""] && Object.keys(ret).length == 1) { + ret = ret[""]; } return ret; } + } \ No newline at end of file diff --git a/src/pbaas/transaction/IdentityScript.ts b/src/pbaas/transaction/IdentityScript.ts index 146f521..f31ed64 100644 --- a/src/pbaas/transaction/IdentityScript.ts +++ b/src/pbaas/transaction/IdentityScript.ts @@ -6,6 +6,8 @@ import { SmartTransactionScript } from "./SmartTransactionScript"; import { EVALS } from "../../utils/evals"; import { TxDestination } from "../TxDestination"; import { IdentityID } from "../IdentityID"; +import { IDENTITY_RECOVER_ADDR } from "../../utils/cccustom"; +import { KeyID } from "../KeyID"; export class IdentityScript extends SmartTransactionScript implements SerializableEntity { constructor(master?: OptCCParams, params?: OptCCParams) { @@ -19,16 +21,30 @@ export class IdentityScript extends SmartTransactionScript implements Serializab const identityAddress = identity.getIdentityAddress(); + const destinationsMaster = identity.isRevoked() ? [ + new TxDestination(IdentityID.fromAddress(identityAddress)), + new TxDestination(identity.recovery_authority) + ] : [ + new TxDestination(IdentityID.fromAddress(identityAddress)), + new TxDestination(identity.revocation_authority), + new TxDestination(identity.recovery_authority) + ]; + + const destinationsRecovery = [ + new TxDestination(identity.recovery_authority) + ] + + if (identity.hasTokenizedIdControl()) { + const addrDestination = new TxDestination(KeyID.fromAddress(IDENTITY_RECOVER_ADDR)); + destinationsRecovery.push(addrDestination); + } + const master = new OptCCParams({ version: Identity.VERSION_CURRENT, eval_code: new BN(EVALS.EVAL_NONE), m: new BN(1), - n: new BN(3), - destinations: [ - new TxDestination(IdentityID.fromAddress(identityAddress)), - new TxDestination(identity.revocation_authority), - new TxDestination(identity.recovery_authority) - ], + n: new BN(destinationsMaster.length), + destinations: destinationsMaster, vdata: [] }) @@ -40,7 +56,17 @@ export class IdentityScript extends SmartTransactionScript implements Serializab destinations: [ new TxDestination(IdentityID.fromAddress(identityAddress)) ], - vdata: [ + vdata: identity.isRevoked() ? [ + identity.toBuffer(), + new OptCCParams({ + version: Identity.VERSION_CURRENT, + eval_code: new BN(EVALS.EVAL_IDENTITY_RECOVER), + m: new BN(1), + n: new BN(destinationsRecovery.length), + destinations: destinationsRecovery, + vdata: [] + }).toChunk() + ] : [ identity.toBuffer(), new OptCCParams({ version: Identity.VERSION_CURRENT, @@ -56,10 +82,8 @@ export class IdentityScript extends SmartTransactionScript implements Serializab version: Identity.VERSION_CURRENT, eval_code: new BN(EVALS.EVAL_IDENTITY_RECOVER), m: new BN(1), - n: new BN(1), - destinations: [ - new TxDestination(identity.recovery_authority) - ], + n: new BN(destinationsRecovery.length), + destinations: destinationsRecovery, vdata: [] }).toChunk() ] @@ -68,9 +92,9 @@ export class IdentityScript extends SmartTransactionScript implements Serializab return new IdentityScript(master, params); } - getIdentity(multimapKeylists?: Array | null>): Identity { + getIdentity(parseVdxfObjects: boolean = false): Identity { const identity = new Identity(); - identity.fromBuffer(this.params.getParamObject()!, 0, multimapKeylists); + identity.fromBuffer(this.params.getParamObject()!, 0, parseVdxfObjects); return identity; } diff --git a/src/utils/IdentityData.ts b/src/utils/IdentityData.ts new file mode 100644 index 0000000..9c8d2b5 --- /dev/null +++ b/src/utils/IdentityData.ts @@ -0,0 +1,167 @@ + +import * as identitykeys from '../vdxf/identitydatakeys'; +import * as keylist from '../vdxf/keys'; + +const IMPLEMENTED_LOCALES = ['EN']; + +export const getFriendlyNameForVdxfKey = (vdxfkey: string, locale = 'EN') => { + + if (!IMPLEMENTED_LOCALES.includes(locale)) { + throw new Error(locale + " is not implemented"); + } + + if (vdxfkey in IdentityVdxfidMap[locale]) { + + return IdentityVdxfidMap[vdxfkey][locale]; + + } else { + throw new Error("Unknown VDXF key"); + } +} + +export const IdentityVdxfidMap = { + [identitykeys.IDENTITY_FIRSTNAME.vdxfid]: { EN: "First Name"}, + [identitykeys.IDENTITY_LASTNAME.vdxfid]: { EN: "Last Name"}, + [identitykeys.IDENTITY_NATIONALITY.vdxfid]: { EN: "Nationality"}, + [identitykeys.IDENTITY_ATTESTOR.vdxfid]: { EN: "Attestor ID"}, + [identitykeys.IDENTITY_ATTESTATION_RECIPIENT.vdxfid]: { EN: "Attestation Recipient"}, + [identitykeys.IDENTITY_PHONENUMBER.vdxfid]: { EN: "Phone Number"}, + [identitykeys.IDENTITY_DATEOFBIRTH.vdxfid]: { EN: "Date of Birth"}, + [identitykeys.IDENTITY_OVER18.vdxfid]: { EN: "Over 18"}, + [identitykeys.IDENTITY_OVER21.vdxfid]: { EN: "Over 21"}, + [identitykeys.IDENTITY_OVER25.vdxfid]: { EN: "Over 25"}, + [identitykeys.IDENTITY_EMAIL.vdxfid]: { EN: "Email Address"}, + [identitykeys.IDENTITY_HOMEADDRESS.vdxfid]: { EN: "Home address"}, + [identitykeys.IDENTITY_HOMEADDRESS_STREET1.vdxfid]: { EN: "Street 1"}, + [identitykeys.IDENTITY_HOMEADDRESS_STREET2.vdxfid]: { EN: "Street 2"}, + [identitykeys.IDENTITY_HOMEADDRESS_CITY.vdxfid]: { EN: "City"}, + [identitykeys.IDENTITY_HOMEADDRESS_REGION.vdxfid]: { EN: "Region"}, + [identitykeys.IDENTITY_HOMEADDRESS_POSTCODE.vdxfid]: { EN: "Post Code"}, + [identitykeys.IDENTITY_HOMEADDRESS_COUNTRY.vdxfid]: { EN: "Country"}, + [identitykeys.IDENTITY_IDNUMBER_VALUE.vdxfid]: { EN: "ID Number"}, + [identitykeys.IDENTITY_IDNUMBER_TYPE.vdxfid]: { EN: "ID Type"}, + [identitykeys.IDENTITY_VERIFICATION_STATUS.vdxfid]: { EN: "Verification Status"}, + [identitykeys.IDENTITY_VERIFICATION_APPROVALS_ACCEPTEDTOS.vdxfid]: { EN: "Accepted Terms and Conditions"}, + [identitykeys.IDENTITY_VERIFICATION_APPROVALS_VERIFIEDSMS.vdxfid]: { EN: "SMS Verified"}, + [identitykeys.IDENTITY_VERIFICATION_APPROVALS_KYCCHECKED.vdxfid]: { EN: "KYC Checked ok"}, + [identitykeys.IDENTITY_VERIFICATION_APPROVALS_DOCUMENTSVERIFIED.vdxfid]: { EN: "Documents Verified"}, + [identitykeys.IDENTITY_VERIFICATION_APPROVALS_SELFIECHECKED.vdxfid]: { EN: "Selfie Checked"}, + [identitykeys.IDENTITY_VERIFICATION_APPROVALS_WATCHLISTOK.vdxfid]: { EN: "Watchlist ok"}, + [identitykeys.IDENTITY_VERIFICATION_APPROVALS_RISKCHECKOK.vdxfid]: { EN: "Riskcheck ok"}, + [identitykeys.IDENTITY_DRIVINGLICENCE.vdxfid]: { EN: "Driving Licence"}, + [identitykeys.IDENTITY_DRIVINGLICENCE_ORIGINALFRONT.vdxfid]: { EN: "Driving Licence Front"}, + [identitykeys.IDENTITY_DRIVINGLICENCE_ORIGINALBACK.vdxfid]: { EN: "Driving Licence Back"}, + [identitykeys.IDENTITY_DRIVINGLICENCE_CROPPEDFRONT.vdxfid]: { EN: "Driving Licence Front"}, + [identitykeys.IDENTITY_DRIVINGLICENCE_CROPPEDBACK.vdxfid]: { EN: "Driving Licence Back"}, + [identitykeys.IDENTITY_DRIVINGLICENCE_FACE.vdxfid]: { EN: "Driving Licence Face"}, + [identitykeys.IDENTITY_DRIVINGLICENCE_IDNUMBER.vdxfid]: { EN: "Driving Licence Number"}, + [identitykeys.IDENTITY_DRIVINGLICENCE_CATEGORY.vdxfid]: { EN: "Driving Licence Catagory"}, + [identitykeys.IDENTITY_DRIVINGLICENCE_EXPIRATIONDATE.vdxfid]: { EN: "Driving Licence expiry date"}, + [identitykeys.IDENTITY_DRIVINGLICENCE_ISSUINGCOUNTRY.vdxfid]: { EN: "Driving Licence issuing country"}, + [identitykeys.IDENTITY_DRIVINGLICENCE_ISSUINGREGION.vdxfid]: { EN: "Driving Licence issuing region"}, + [identitykeys.IDENTITY_DRIVINGLICENCE_DATEOFBIRTH.vdxfid]: { EN: "Driving Licence Date of Birth"}, + [identitykeys.IDENTITY_DRIVINGLICENCE_ADDRESS_STREET1.vdxfid]: { EN: "Driving Licence Street 1"}, + [identitykeys.IDENTITY_DRIVINGLICENCE_ADDRESS_CITY.vdxfid]: { EN: "Driving Licence City"}, + [identitykeys.IDENTITY_DRIVINGLICENCE_ADDRESS_REGION.vdxfid]: { EN: "Driving Licence Region"}, + [identitykeys.IDENTITY_DRIVINGLICENCE_ADDRESS_POSTCODE.vdxfid]: { EN: "Driving Licence ZIP/Post Code"}, + [identitykeys.IDENTITY_DRIVINGLICENCE_ADDRESS_COUNTRY.vdxfid]: { EN: "Driving Licence Country"}, + [identitykeys.IDENTITY_SELFIECHECK_IMAGE.vdxfid]: { EN: "Selfie Check image"}, + [identitykeys.IDENTITY_SELFIECHECK_VIDEO.vdxfid]: { EN: "Selfie Check video"}, + [identitykeys.IDENTITY_VERIFICATION_APPROVALS_RISKCHECKOK.vdxfid]: { EN: "Risk Check Ok"}, + [identitykeys.IDENTITY_EMAIL_ISDELIVERABLE.vdxfid]: { EN: "Email address is deliverable"}, + [identitykeys.IDENTITY_EMAIL_BREACHCOUNT.vdxfid]: { EN: "Email breach count"}, + [identitykeys.IDENTITY_EMAIL_FIRSTBREACHEDAT.vdxfid]: { EN: "Email first breach date"}, + [identitykeys.IDENTITY_EMAIL_LASTBREACHEDAT.vdxfid]: { EN: "Email last breach date"}, + [identitykeys.IDENTITY_EMAIL_DOMAIN_REGISTEREDAT.vdxfid]: { EN: "Email domain registered at"}, + [identitykeys.IDENTITY_EMAIL_DOMAIN_FREEPROVIDER.vdxfid]: { EN: "Email is free provider"}, + [identitykeys.IDENTITY_EMAIL_DOMAIN_CUSTOM.vdxfid]: { EN: "Email Domain is custom"}, + [identitykeys.IDENTITY_EMAIL_DOMAIN_DISPOSABLE.vdxfid]: { EN: "Email Domain Disposable"}, + [identitykeys.IDENTITY_EMAIL_DOMAIN_TOPLEVEL_SUSPICIOUS.vdxfid]: { EN: "Email top level Domain Suspicious"}, + [identitykeys.IDENTITY_IDCARD.vdxfid]: { EN: "ID Card"}, + [identitykeys.IDENTITY_IDCARD_ORIGINALFRONT.vdxfid]: { EN: "ID Card Front"}, + [identitykeys.IDENTITY_IDCARD_ORIGINALBACK.vdxfid]: { EN: "ID Card Back"}, + [identitykeys.IDENTITY_IDCARD_CROPPEDFRONT.vdxfid]: { EN: "ID Card Front"}, + [identitykeys.IDENTITY_IDCARD_CROPPEDBACK.vdxfid]: { EN: "ID Card Back"}, + [identitykeys.IDENTITY_IDCARD_FACE.vdxfid]: { EN: "ID Card Face"}, + [identitykeys.IDENTITY_IDCARD_IDNUMBER.vdxfid]: { EN: "ID Card ID Number"}, + [identitykeys.IDENTITY_IDCARD_CATEGORY.vdxfid]: { EN: "ID Card Category"}, + [identitykeys.IDENTITY_IDCARD_EXPIRATIONDATE.vdxfid]: { EN: "ID Card Expiry date"}, + [identitykeys.IDENTITY_IDCARD_ISSUINGREGION.vdxfid]: { EN: "ID Card Issuing Region"}, + [identitykeys.IDENTITY_IDCARD_DATEOFBIRTH.vdxfid]: { EN: "ID Card Date of Birth"}, + [identitykeys.IDENTITY_IDCARD_ADDRESS_STREET1.vdxfid]: { EN: "ID Card Street 1"}, + [identitykeys.IDENTITY_IDCARD_ADDRESS_CITY.vdxfid]: { EN: "ID Card City"}, + [identitykeys.IDENTITY_IDCARD_ADDRESS_REGION.vdxfid]: { EN: "ID Card Region"}, + [identitykeys.IDENTITY_IDCARD_ADDRESS_POSTCODE.vdxfid]: { EN: "ID Card Zip/Post Code"}, + [identitykeys.IDENTITY_IDCARD_ADDRESS_COUNTRY.vdxfid]: { EN: "ID Card Country"}, + [identitykeys.IDENTITY_PASSPORT.vdxfid]: { EN: "Passport"}, + [identitykeys.IDENTITY_PASSPORT_ORIGINALFRONT.vdxfid]: { EN: "Passport front"}, + [identitykeys.IDENTITY_PASSPORT_ORIGINALBACK.vdxfid]: { EN: "Passport back"}, + [identitykeys.IDENTITY_PASSPORT_CROPPEDFRONT.vdxfid]: { EN: "Passport front"}, + [identitykeys.IDENTITY_PASSPORT_CROPPEDBACK.vdxfid]: { EN: "Passport back"}, + [identitykeys.IDENTITY_PASSPORT_FACE.vdxfid]: { EN: "Passport face"}, + [identitykeys.IDENTITY_PASSPORT_IDNUMBER.vdxfid]: { EN: "Passport ID Number"}, + [identitykeys.IDENTITY_PASSPORT_CATEGORY.vdxfid]: { EN: "Passport Category"}, + [identitykeys.IDENTITY_PASSPORT_EXPIRATIONDATE.vdxfid]: { EN: "Passport expiry date"}, + [identitykeys.IDENTITY_PASSPORT_DATEOFBIRTH.vdxfid]: { EN: "Passport date of birth"}, + [identitykeys.IDENTITY_PASSPORT_ADDRESS_STREET1.vdxfid]: { EN: "Passport street 1"}, + [identitykeys.IDENTITY_PASSPORT_ADDRESS_CITY.vdxfid]: { EN: "Passport city"}, + [identitykeys.IDENTITY_PASSPORT_ADDRESS_REGION.vdxfid]: { EN: "Passport region"}, + [identitykeys.IDENTITY_PASSPORT_ADDRESS_POSTCODE.vdxfid]: { EN: "Passport zip/post code"}, + [identitykeys.IDENTITY_PASSPORT_ADDRESS_COUNTRY.vdxfid]: { EN: "Passport country"}, + [identitykeys.IDENTITY_RESIDENCEPERMIT.vdxfid]: { EN: "Residence Permit"}, + [identitykeys.IDENTITY_RESIDENCEPERMIT_ORIGINALFRONT.vdxfid]: { EN: "Residence Permit front"}, + [identitykeys.IDENTITY_RESIDENCEPERMIT_ORIGINALBACK.vdxfid]: { EN: "Residence Permit back"}, + [identitykeys.IDENTITY_RESIDENCEPERMIT_CROPPEDFRONT.vdxfid]: { EN: "Residence Permit front"}, + [identitykeys.IDENTITY_RESIDENCEPERMIT_CROPPEDBACK.vdxfid]: { EN: "Residence Permit back"}, + [identitykeys.IDENTITY_RESIDENCEPERMIT_FACE.vdxfid]: { EN: "Residence Permit face"}, + [identitykeys.IDENTITY_RESIDENCEPERMIT_IDNUMBER.vdxfid]: { EN: "Residence Permit ID Number"}, + [identitykeys.IDENTITY_RESIDENCEPERMIT_CATEGORY.vdxfid]: { EN: "Residence Permit category"}, + [identitykeys.IDENTITY_RESIDENCEPERMIT_EXPIRATIONDATE.vdxfid]: { EN: "Residence Permit expiry date"}, + [identitykeys.IDENTITY_RESIDENCEPERMIT_ISSUINGREGION.vdxfid]: { EN: "Residence Permit issuing region"}, + [identitykeys.IDENTITY_RESIDENCEPERMIT_DATEOFBIRTH.vdxfid]: { EN: "Residence Permit date of birth"}, + [identitykeys.IDENTITY_RESIDENCEPERMIT_ADDRESS.vdxfid]: { EN: "Residence Permit Address"}, + [identitykeys.IDENTITY_RESIDENCEPERMIT_ADDRESS_STREET1.vdxfid]: { EN: "Residence Permit Street 1"}, + [identitykeys.IDENTITY_RESIDENCEPERMIT_ADDRESS_CITY.vdxfid]: { EN: "Residence Permit City"}, + [identitykeys.IDENTITY_RESIDENCEPERMIT_ADDRESS_REGION.vdxfid]: { EN: "Residence Permit Region"}, + [identitykeys.IDENTITY_RESIDENCEPERMIT_ADDRESS_POSTCODE.vdxfid]: { EN: "Residence Permit Zip/Post code"}, + [identitykeys.IDENTITY_RESIDENCEPERMIT_ADDRESS_COUNTRY.vdxfid]: { EN: "Residence Permit Country"}, + [identitykeys.IDENTITY_RESIDENTCARD.vdxfid]: { EN: "Resident Card"}, + [identitykeys.IDENTITY_RESIDENTCARD_ORIGINALFRONT.vdxfid]: { EN: "Resident Card Front"}, + [identitykeys.IDENTITY_RESIDENTCARD_ORIGINALBACK.vdxfid]: { EN: "Resident Card Back"}, + [identitykeys.IDENTITY_RESIDENTCARD_CROPPEDFRONT.vdxfid]: { EN: "Resident Card Front"}, + [identitykeys.IDENTITY_RESIDENTCARD_CROPPEDBACK.vdxfid]: { EN: "Resident Card Back"}, + [identitykeys.IDENTITY_RESIDENTCARD_FACE.vdxfid]: { EN: "Resident Card Face"}, + [identitykeys.IDENTITY_RESIDENTCARD_IDNUMBER.vdxfid]: { EN: "Resident Card ID Number"}, + [identitykeys.IDENTITY_RESIDENTCARD_CATEGORY.vdxfid]: { EN: "Resident Card Category"}, + [identitykeys.IDENTITY_RESIDENTCARD_EXPIRATIONDATE.vdxfid]: { EN: "Resident Card Expiry Date"}, + [identitykeys.IDENTITY_RESIDENTCARD_ISSUINGREGION.vdxfid]: { EN: "Resident Card Issuing Region"}, + [identitykeys.IDENTITY_RESIDENTCARD_DATEOFBIRTH.vdxfid]: { EN: "Resident Card date of birth"}, + [identitykeys.IDENTITY_RESIDENTCARD_ADDRESS_STREET1.vdxfid]: { EN: "Resident Card Street 1"}, + [identitykeys.IDENTITY_RESIDENTCARD_ADDRESS_CITY.vdxfid]: { EN: "Resident Card City"}, + [identitykeys.IDENTITY_RESIDENTCARD_ADDRESS_REGION.vdxfid]: { EN: "Resident Card Region"}, + [identitykeys.IDENTITY_RESIDENTCARD_ADDRESS_POSTCODE.vdxfid]: { EN: "Resident Card Zip/Post Code"}, + [identitykeys.IDENTITY_RESIDENTCARD_ADDRESS_COUNTRY.vdxfid]: { EN: "Resident Card Country"}, + [identitykeys.IDENTITY_VISA.vdxfid]: { EN: "Visa"}, + [identitykeys.IDENTITY_VISA_ORIGINALFRONT.vdxfid]: { EN: "Visa front"}, + [identitykeys.IDENTITY_VISA_ORIGINALBACK.vdxfid]: { EN: "Visa back"}, + [identitykeys.IDENTITY_VISA_CROPPEDFRONT.vdxfid]: { EN: "Visa front"}, + [identitykeys.IDENTITY_VISA_CROPPEDBACK.vdxfid]: { EN: "Visa back"}, + [identitykeys.IDENTITY_VISA_FACE.vdxfid]: { EN: "Visa face"}, + [identitykeys.IDENTITY_VISA_IDNUMBER.vdxfid]: { EN: "Visa ID Number"}, + [identitykeys.IDENTITY_VISA_CATEGORY.vdxfid]: { EN: "Visa Category"}, + [identitykeys.IDENTITY_VISA_EXPIRATIONDATE.vdxfid]: { EN: "Visa expiry date"}, + [identitykeys.IDENTITY_VISA_ISSUINGREGION.vdxfid]: { EN: "Visa issuing region"}, + [identitykeys.IDENTITY_VISA_DATEOFBIRTH.vdxfid]: { EN: "Visa date of birth"}, + [identitykeys.IDENTITY_VISA_ADDRESS_STREET1.vdxfid]: { EN: "Visa Street 1"}, + [identitykeys.IDENTITY_VISA_ADDRESS_CITY.vdxfid]: { EN: "Visa City"}, + [identitykeys.IDENTITY_VISA_ADDRESS_REGION.vdxfid]: { EN: "Visa Region"}, + [identitykeys.IDENTITY_VISA_ADDRESS_POSTCODE.vdxfid]: { EN: "Visa Zip/Post Code"}, + [identitykeys.IDENTITY_VISA_ADDRESS_COUNTRY.vdxfid]: { EN: "Visa Country"}, + [keylist.ATTESTATION_PROVISION_TYPE.vdxfid]: { EN: "Attestation Type"}, + [keylist.ATTESTATION_PROVISION_URL.vdxfid]: { EN: "Attestation URL"}, + [keylist.ATTESTATION_VIEW_RESPONSE.vdxfid]: { EN: "Attestation View Response"}, + [keylist.ATTESTATION_VIEW_REQUEST.vdxfid]: { EN: "Attestation View Response"}, + [keylist.PROFILE_DATA_VIEW_REQUEST.vdxfid]: { EN: "Profile Data View Request"}, + [keylist.IDENTITY_SIGNDATA_REQUEST.vdxfid]: { EN: "Identity Sign Data Request"} +}; + diff --git a/src/utils/cccustom.ts b/src/utils/cccustom.ts new file mode 100644 index 0000000..d822f1f --- /dev/null +++ b/src/utils/cccustom.ts @@ -0,0 +1,20 @@ +export const STAKE_GUARD_ADDR = "RCG8KwJNDVwpUBcdoa6AoHqHVJsA1uMYMR"; +export const PBAAS_DEFINITION_ADDR = "RP7id3CzCnwvzNUZesYJM6ekvsxpEzMqB1"; +export const NOTARY_EVIDENCE_ADDR = "RQWMeecjGFF3ZAVeSimRbyG9iMDUHPY5Ny"; +export const EARNED_NOTARIZATION_ADDR = "RMYbaxFsCT1xfMmwLCCYAVf2DsxcDTtBmx"; +export const ACCEPTED_NOTARIZATION_ADDR = "RDTq9qn1Lthv7fvsdbWz36mGp8HK9XaruZ"; +export const FINALIZE_NOTARIZATION_ADDR = "RRbKYitLH9EhQCvCo4bPZqJx3TWxASadxE"; +export const RESERVE_OUTPUT_ADDR = "RMXeZGxxRuABFkT4uLSCeuJHLegBNGZq8D"; +export const ADVANCED_NAME_RESERVATION_ADDR = "REuGNkgunnw1J4Zx6Y9UCp8YHVZqYATe9D"; +export const RESERVE_TRANSFER_ADDR = "RTqQe58LSj2yr5CrwYFwcsAQ1edQwmrkUU"; +export const RESERVE_DEPOSIT_ADDR = "RFw9AVfgNKcHe2Vp2eyzHrX65aFD9Ky8df"; +export const CROSS_CHAIN_EXPORT_ADDR = "RGkrs7SndcpsV61oKK2jYdMiU8PgkLU2qP"; +export const CROSS_CHAIN_IMPORT_ADDR = "RKLN7wFhbrJFkPG8XkKteErAe5CjqoddTm"; +export const CURRENCY_STATE_ADDR = "REU1HKkmdwdxKMpfD3QoxeERYd9tfMN6n9"; +export const IDENTITY_PRIMARY_ADDR = "RS545EBdK5AzPTaGHNUg78wFuuAzBb74FB"; +export const IDENTITY_REVOKE_ADDR = "RG6My2zwh9hBFSgUhZ5UmmUtxBap57aU4N"; +export const IDENTITY_RECOVER_ADDR = "RRw9rJMPwdNqC1wgXn5vryJwMDyBgpXjYT"; +export const IDENTITY_COMMITMENT_ADDR = "RCySaThHfVBcHZgjJGoBw3un4vcsRJNPYw"; +export const IDENTITY_RESERVATION_ADDR = "RDbzJU8rEv4CkMABNUnKQoKDTfnikSm9fM"; +export const FINALIZE_EXPORT_ADDR = "REL7oLNeaeoQB1XauiHfcvjKMZC52Uj5xF"; +export const FEE_POOL_ADDR = "RQ55dLQ7uGnLx8scXfkaFV6QS6qVBGyxAG"; \ No newline at end of file diff --git a/src/utils/mmr.ts b/src/utils/mmr.ts new file mode 100644 index 0000000..e69abfb --- /dev/null +++ b/src/utils/mmr.ts @@ -0,0 +1,105 @@ +import { BN } from 'bn.js'; + +export const GetMMRProofIndex = (pos: number, mmvSize: number, extraHashes: number): InstanceType => { + let index = new BN(0); + let layerSizes = []; + let merkleSizes = []; + let peakIndexes = []; + let bitPos = 0; + + //start at the beginning + //create a simulation of a mmr based on size + if (!(pos > 0 && pos < mmvSize)) return new BN(0); + + //create an array of all the sizes + while (mmvSize) { + layerSizes.push(mmvSize); + mmvSize = mmvSize >> 1 + } + + for (let height = 0; height < layerSizes.length; height++) { + if (height == layerSizes.length - 1 || layerSizes[height] & 1) { + peakIndexes.push(height); + } + } + + //array flip peak indexes + peakIndexes.reverse(); + + let layerNum = 0; + let layerSize = peakIndexes.length; + + for (let passThrough = (layerSize & 1); layerNum == 0 || layerSize > 1; passThrough = (layerSize & 1), layerNum++) { + layerSize = (layerSize >> 1) + passThrough; + if (layerSize) { + merkleSizes.push(layerSize); + } + } + //flip the merklesizes + + for (let i = 0; i < extraHashes; i++) { + bitPos++; + } + + let p = pos; + for (let l = 0; l < layerSizes.length; l++) { + if (p & 1) { + index = index.or(new BN(1).shln(bitPos++)); + + p >>= 1; + + for (let i = 0; i < extraHashes; i++) { + bitPos++; + } + + } else { + if (layerSizes[l] > (p + 1)) { + + bitPos++; + p >>= 1; + for (let i = 0; i < extraHashes; i++) { + bitPos++; + } + } else { + + for (p = 0; p < peakIndexes.length; p++) { + + if (peakIndexes[p] == l) { + break; + } + } + + for (let layerNum = -1, layerSize = peakIndexes.length; layerNum == -1 || layerSize > 1; layerSize = merkleSizes[++layerNum]) { + + if (p < (layerSize - 1) || (p & 1)) { + + + if (p & 1) { + // hash with the one before us + index = index.or(new BN(1).shln(bitPos++)); + + for (let i = 0; i < extraHashes; i++) { + bitPos++; + } + } else { + // hash with the one in front of us + bitPos++; + + for (let i = 0; i < extraHashes; i++) { + bitPos++; + } + } + } + p >>= 1; + } + + break; + } + + } + } + return index; + } + + + \ No newline at end of file diff --git a/src/utils/types/DataDescriptor.ts b/src/utils/types/DataDescriptor.ts new file mode 100644 index 0000000..2e71cff --- /dev/null +++ b/src/utils/types/DataDescriptor.ts @@ -0,0 +1,12 @@ + +export type DataDescriptorInfo = { + version?: number, + flags?: number, + objectdata?: string, + label?: string, + mimeType?: string, + salt?: string, + epk?: string, + ivk?: string, + ssk?: string +} diff --git a/src/utils/types/MmrDescriptor.ts b/src/utils/types/MmrDescriptor.ts new file mode 100644 index 0000000..72ba1cb --- /dev/null +++ b/src/utils/types/MmrDescriptor.ts @@ -0,0 +1,10 @@ +import { DataDescriptorInfo } from './DataDescriptor'; + +export type MmrDescriptorParameters = { + version?: number; + objecthashtype?: number; + mmrhashtype?: number; + mmrroot?: DataDescriptorInfo; + mmrhashes?: DataDescriptorInfo; + datadescriptors?: DataDescriptorInfo[]; +} diff --git a/src/utils/types/SignData.ts b/src/utils/types/SignData.ts new file mode 100644 index 0000000..a3870aa --- /dev/null +++ b/src/utils/types/SignData.ts @@ -0,0 +1,8 @@ +export type SignDataParameters = { + filename?: string; + message?: string; + messagehex?: string; + messsagebase64?: string; + datahash?: string; + vdxfdata?: string; +} \ No newline at end of file diff --git a/src/utils/types/Signature.ts b/src/utils/types/Signature.ts new file mode 100644 index 0000000..9e4ba5c --- /dev/null +++ b/src/utils/types/Signature.ts @@ -0,0 +1,9 @@ +export type SignatureDataInfo = { + version: number; + systemid: string; + hashtype: number; + signaturehash: string; + identityid: string; + signaturetype: number; + signature: string; +} \ No newline at end of file diff --git a/src/vdxf/classes/Attestation.ts b/src/vdxf/classes/Attestation.ts new file mode 100644 index 0000000..d638a4b --- /dev/null +++ b/src/vdxf/classes/Attestation.ts @@ -0,0 +1,212 @@ +import bufferutils from '../../utils/bufferutils' +import { toBase58Check, fromBase58Check } from '../../utils/address'; +import { I_ADDR_VERSION } from '../../constants/vdxf'; +import { DataDescriptor } from '../../pbaas/DataDescriptor'; +import { ATTESTATION_VIEW_REQUEST, ATTESTATION_PROVISION_TYPE } from '../'; +import varuint from '../../utils/varuint'; +import { BufferDataVdxfObject } from '../index'; +import { Serializable } from 'child_process'; +import { SerializableEntity } from '../../utils/types/SerializableEntity'; +const { BufferReader, BufferWriter } = bufferutils; + +export class Attestation extends BufferDataVdxfObject { + + getAttestationData(): { [key: string]: AttestationViewRequest } { + + const reader = new BufferReader(Buffer.from(this.data, 'hex')); + + const returnedData = {}; + + while (reader.buffer.length > reader.offset) { + + let vdxfkey = toBase58Check(reader.readSlice(20), I_ADDR_VERSION); + + switch (vdxfkey) { + case ATTESTATION_VIEW_REQUEST.vdxfid: + returnedData[vdxfkey] = new AttestationViewRequest(); + reader.offset = returnedData[vdxfkey].fromBuffer(reader.buffer, reader.offset); + break; + case ATTESTATION_PROVISION_TYPE.vdxfid: + + let dataDescriptorItemsCount = reader.readCompactSize(); + + let dataDescriptors = []; + + for (let i = 0; i < dataDescriptorItemsCount; i++) { + let dataDescriptor = new DataDescriptor(); + reader.offset = dataDescriptor.fromBuffer(reader.buffer, reader.offset); + dataDescriptors.push(dataDescriptor); + } + returnedData[vdxfkey] = dataDescriptors; + break; + default: + throw new Error("Unsupported Attestation Data Type"); + } + + } + + return returnedData; + } +} + +export class AttestationViewRequest implements SerializableEntity { + attestation_id: string; + accepted_attestors: Array; + attestation_keys: Array; + attestor_filters: Array; + + constructor(data?: { attestation_id?: string, accepted_attestors?: Array, attestation_keys?: Array, attestor_filters?: Array }) { + this.attestation_id = data.attestation_id || ""; + this.accepted_attestors = data.accepted_attestors || []; + this.attestation_keys = data.attestation_keys || []; + this.attestor_filters = data.attestor_filters || []; + } + + getByteLength() { + + let length = 0; // attestation_id + length += varuint.encodingLength(this.accepted_attestors.length); + length += this.accepted_attestors.length * 20; // accepted_attestors + length += varuint.encodingLength(this.attestation_keys.length); + length += this.attestation_keys.length * 20; // attestation_keys + length += varuint.encodingLength(this.attestor_filters.length); + length += this.attestor_filters.length * 20; // attestor_filters + + return length + } + + toBuffer() { + const bufferWriter = new BufferWriter(Buffer.alloc(this.getByteLength())) + + bufferWriter.writeSlice(fromBase58Check(this.attestation_id).hash); + + bufferWriter.writeCompactSize(this.accepted_attestors.length); + + for (let i = 0; i < this.accepted_attestors.length; i++) { + bufferWriter.writeSlice(fromBase58Check(this.accepted_attestors[i]).hash); + } + + bufferWriter.writeCompactSize(this.attestation_keys.length); + + for (let i = 0; i < this.attestation_keys.length; i++) { + bufferWriter.writeSlice(fromBase58Check(this.attestation_keys[i]).hash); + } + + bufferWriter.writeCompactSize(this.attestor_filters.length); + + for (let i = 0; i < this.attestor_filters.length; i++) { + bufferWriter.writeSlice(fromBase58Check(this.attestor_filters[i]).hash); + } + + return bufferWriter.buffer + } + + fromBuffer(buffer: Buffer, offset: number = 0) { + const reader = new BufferReader(buffer, offset); + + + this.attestation_id = toBase58Check(reader.readSlice(20), I_ADDR_VERSION); + + let attestorCount = reader.readCompactSize(); + + for (let i = 0; i < attestorCount; i++) { + this.accepted_attestors.push(toBase58Check(reader.readSlice(20), I_ADDR_VERSION)); + } + + let attestationKeyCount = reader.readCompactSize(); + + for (let i = 0; i < attestationKeyCount; i++) { + this.attestation_keys.push(toBase58Check(reader.readSlice(20), I_ADDR_VERSION)); + } + + let attestorFilterCount = reader.readCompactSize(); + + for (let i = 0; i < attestorFilterCount; i++) { + this.attestor_filters.push(toBase58Check(reader.readSlice(20), I_ADDR_VERSION)); + } + + return reader.offset; + } + +} + +export class AttestationProvisioningData implements SerializableEntity { + attestation_id: string; + accepted_attestors: Array; + attestation_keys: Array; + attestor_filters: Array; + + constructor(data?: { attestation_id?: string, accepted_attestors?: Array, attestation_keys?: Array, attestor_filters?: Array }) { + this.attestation_id = data.attestation_id || ""; + this.accepted_attestors = data.accepted_attestors || []; + this.attestation_keys = data.attestation_keys || []; + this.attestor_filters = data.attestor_filters || []; + } + + getByteLength() { + + let length = 0; // attestation_id + length += varuint.encodingLength(this.accepted_attestors.length); + length += this.accepted_attestors.length * 20; // accepted_attestors + length += varuint.encodingLength(this.attestation_keys.length); + length += this.attestation_keys.length * 20; // attestation_keys + length += varuint.encodingLength(this.attestor_filters.length); + length += this.attestor_filters.length * 20; // attestor_filters + + return length + } + + toBuffer() { + const bufferWriter = new BufferWriter(Buffer.alloc(this.getByteLength())) + + bufferWriter.writeSlice(fromBase58Check(this.attestation_id).hash); + + bufferWriter.writeCompactSize(this.accepted_attestors.length); + + for (let i = 0; i < this.accepted_attestors.length; i++) { + bufferWriter.writeSlice(fromBase58Check(this.accepted_attestors[i]).hash); + } + + bufferWriter.writeCompactSize(this.attestation_keys.length); + + for (let i = 0; i < this.attestation_keys.length; i++) { + bufferWriter.writeSlice(fromBase58Check(this.attestation_keys[i]).hash); + } + + bufferWriter.writeCompactSize(this.attestor_filters.length); + + for (let i = 0; i < this.attestor_filters.length; i++) { + bufferWriter.writeSlice(fromBase58Check(this.attestor_filters[i]).hash); + } + + return bufferWriter.buffer + } + + fromBuffer(buffer: Buffer, offset: number = 0) { + const reader = new BufferReader(buffer, offset); + + + this.attestation_id = toBase58Check(reader.readSlice(20), I_ADDR_VERSION); + + let attestorCount = reader.readCompactSize(); + + for (let i = 0; i < attestorCount; i++) { + this.accepted_attestors.push(toBase58Check(reader.readSlice(20), I_ADDR_VERSION)); + } + + let attestationKeyCount = reader.readCompactSize(); + + for (let i = 0; i < attestationKeyCount; i++) { + this.attestation_keys.push(toBase58Check(reader.readSlice(20), I_ADDR_VERSION)); + } + + let attestorFilterCount = reader.readCompactSize(); + + for (let i = 0; i < attestorFilterCount; i++) { + this.attestor_filters.push(toBase58Check(reader.readSlice(20), I_ADDR_VERSION)); + } + + return reader.offset; + } + +} \ No newline at end of file diff --git a/src/vdxf/classes/Challenge.ts b/src/vdxf/classes/Challenge.ts index 0b9df44..44157b6 100644 --- a/src/vdxf/classes/Challenge.ts +++ b/src/vdxf/classes/Challenge.ts @@ -5,12 +5,17 @@ import { ID_SYSTEMID_VDXF_KEY, Utf8DataVdxfObject, VDXFObject, - Utf8OrBase58Object, + Utf8OrBase58Object } from "../"; import bufferutils from "../../utils/bufferutils"; import varuint from "../../utils/varuint"; import { Context } from "./Context"; import { Hash160 } from "./Hash160"; +import { Attestation } from "./Attestation"; +import { fromBase58Check, toBase58Check } from '../../utils/address'; +import { HASH160_BYTE_LENGTH, I_ADDR_VERSION } from '../../constants/vdxf'; +import { BufferDataVdxfObject, VDXFData } from '../index' + export class RedirectUri extends VDXFObject { uri: string; @@ -65,17 +70,9 @@ export class ProvisioningInfo extends Utf8OrBase58Object { } } -export class RequestedPermission extends Utf8DataVdxfObject { - constructor(vdxfkey: string = "") { - super("", vdxfkey); - } -} - -export class Audience extends Utf8DataVdxfObject {} +export class Audience extends Utf8DataVdxfObject { } -export class AltAuthFactor extends Utf8DataVdxfObject {} - -export class Attestation extends Utf8DataVdxfObject {} +export class AltAuthFactor extends Utf8DataVdxfObject { } export interface ChallengeInterface { // Challenge specific VDXF key @@ -124,7 +121,7 @@ export interface ChallengeInterface { export class Challenge extends VDXFObject implements ChallengeInterface { challenge_id: string; requested_access?: Array | null; - requested_access_audience?: Array | null; + requested_access_audience?: Array | null; subject?: Array; provisioning_info?: Array; alt_auth_factors?: Array | null; @@ -143,9 +140,7 @@ export class Challenge extends VDXFObject implements ChallengeInterface { super(vdxfkey); this.challenge_id = challenge.challenge_id; - this.requested_access = challenge.requested_access - ? challenge.requested_access.map((x) => new RequestedPermission(x.vdxfkey)) - : challenge.requested_access; + this.requested_access = challenge.requested_access ? challenge.requested_access.map((x) => new RequestedPermission(x.vdxfkey, x.data)) : challenge.requested_access; this.requested_access_audience = challenge.requested_access_audience; this.subject = challenge.subject ? challenge.subject.map((x) => new Subject(x.data, x.vdxfkey)) @@ -185,7 +180,7 @@ export class Challenge extends VDXFObject implements ChallengeInterface { const _subject = this.subject ? this.subject : []; const _provisioning_info = this.provisioning_info ? this.provisioning_info : []; const _alt_auth_factors = []; - const _attestations = []; + const _attestations = this.attestations ? this.attestations : []; const _redirect_uris = this.redirect_uris ? this.redirect_uris : []; const _context = this.context ? this.context : new Context({}); @@ -223,6 +218,10 @@ export class Challenge extends VDXFObject implements ChallengeInterface { length += varuint.encodingLength(_alt_auth_factors.length); length += varuint.encodingLength(_attestations.length); + length += _attestations.reduce( + (sum, current) => sum + current.byteLength(), + 0 + ); length += varuint.encodingLength(_redirect_uris.length); length += _redirect_uris.reduce( @@ -255,7 +254,7 @@ export class Challenge extends VDXFObject implements ChallengeInterface { const _subject = this.subject ? this.subject : []; const _provisioning_info = this.provisioning_info ? this.provisioning_info : []; const _alt_auth_factors = []; - const _attestations = []; + const _attestations = this.attestations ? this.attestations : []; const _redirect_uris = this.redirect_uris ? this.redirect_uris : []; const _context = this.context ? this.context : new Context({}); @@ -326,6 +325,7 @@ export class Challenge extends VDXFObject implements ChallengeInterface { const requestedAccessLength = reader.readCompactSize(); for (let i = 0; i < requestedAccessLength; i++) { + const _perm = new RequestedPermission(); reader.offset = _perm.fromBuffer(reader.buffer, reader.offset); this.requested_access.push(_perm); @@ -366,8 +366,10 @@ export class Challenge extends VDXFObject implements ChallengeInterface { this.attestations = []; const attestationsLength = reader.readCompactSize(); - if (attestationsLength > 0) { - throw new Error("Attestations currently unsupported"); + for (let i = 0; i < attestationsLength; i++) { + const _att = new Attestation(); + reader.offset = _att.fromBuffer(reader.buffer, reader.offset); + this.attestations.push(_att); } this.redirect_uris = []; @@ -412,3 +414,64 @@ export class Challenge extends VDXFObject implements ChallengeInterface { }; } } + +export class RequestedPermission extends VDXFObject { + + data: Array; + + constructor(vdxfkey?: string, data?: Array | Array) { + super(vdxfkey); + + if (data && data.length > 0) { + if (data[0] instanceof Hash160) { + this.data = data as Array; + } else { + this.data = data.map((x) => new Hash160(fromBase58Check(x).hash)); + } + } else { + this.data = []; + } + } + + dataByteLength(): number { + + let length = 0; + + length += varuint.encodingLength(this.data.length); + + for (let i = 0; i < this.data.length; i++) { + length += 20; + } + + return length; + } + + toDataBuffer(): Buffer { + const buffer = Buffer.alloc(this.dataByteLength()); + const writer = new bufferutils.BufferWriter(buffer); + + writer.writeCompactSize(this.data.length); + + for (let i = 0; i < this.data.length; i++) { + writer.writeSlice(this.data[i].toBuffer()); + } + + return writer.buffer; + } + + + fromDataBuffer(buffer: Buffer, offset?: number): number { + const reader = new bufferutils.BufferReader(buffer, offset); + const contextLength = reader.readCompactSize(); + const numKeys = reader.readCompactSize(); + + this.data = []; + + for (let i = 0; i < numKeys; i++) { + this.data.push(new Hash160(reader.readSlice(20))); + } + + return reader.offset; + } + +} \ No newline at end of file diff --git a/src/vdxf/classes/Decision.ts b/src/vdxf/classes/Decision.ts index ccd6a3b..534aa25 100644 --- a/src/vdxf/classes/Decision.ts +++ b/src/vdxf/classes/Decision.ts @@ -1,7 +1,7 @@ import { LOGIN_CONSENT_DECISION_VDXF_KEY, VDXFObject } from ".."; import bufferutils from "../../utils/bufferutils"; import varuint from "../../utils/varuint"; -import { Attestation } from "./Challenge"; +import { Attestation } from "./Attestation"; import { Context } from "./Context"; import { Hash160 } from "./Hash160"; import { Request, RequestInterface } from "./Request"; @@ -35,7 +35,7 @@ export class Decision extends VDXFObject { request: Request; created_at: number; skipped?: boolean; - attestations: Array; + attestations: Array; salt?: string; constructor( @@ -66,7 +66,7 @@ export class Decision extends VDXFObject { : Hash160.getEmpty(); const _request = this.request ? this.request : new Request(); const _context = this.context ? this.context : new Context(); - const _attestations = []; + const _attestations = this.attestations ? this.attestations : []; length += _challenge_id.byteLength(); @@ -78,6 +78,10 @@ export class Decision extends VDXFObject { length += 1; // skipped length += varuint.encodingLength(_attestations.length); + length += _attestations.reduce( + (sum, current) => sum + current.byteLength(), + 0 + ); } length += _request.byteLength(); @@ -98,7 +102,7 @@ export class Decision extends VDXFObject { : Hash160.getEmpty(); const _request = this.request ? this.request : new Request(); const _context = this.context ? this.context : new Context(); - const _attestations = []; + const _attestations = this.attestations ? this.attestations : []; writer.writeSlice(_decision_id.toBuffer()); @@ -150,9 +154,11 @@ export class Decision extends VDXFObject { this.attestations = []; const attestationsLength = reader.readCompactSize(); - if (attestationsLength > 0) { - throw new Error("Attestations currently unsupported"); - } + for (let i = 0; i < attestationsLength; i++) { + const _att = new Attestation(); + reader.offset = _att.fromBuffer(reader.buffer, reader.offset); + this.attestations.push(_att); + } } const _context = new Context(); diff --git a/src/vdxf/classes/PersonalProfile.ts b/src/vdxf/classes/PersonalProfile.ts new file mode 100644 index 0000000..68ee78c --- /dev/null +++ b/src/vdxf/classes/PersonalProfile.ts @@ -0,0 +1,13 @@ +import { VDXFObject } from ".."; + +export class DataCategory extends VDXFObject { + data: Array; + category: string; + details: string; + constructor(vdxfid: string = "", data?: Array, category?: string, details?: string) { + super(vdxfid); + this.data = data || []; + this.category = category || ""; + this.details = details || ""; + } +} \ No newline at end of file diff --git a/src/vdxf/classes/SaltedData.ts b/src/vdxf/classes/SaltedData.ts new file mode 100644 index 0000000..ff60484 --- /dev/null +++ b/src/vdxf/classes/SaltedData.ts @@ -0,0 +1,102 @@ +import varint from '../../utils/varint' +import varuint from '../../utils/varuint' +import { fromBase58Check, toBase58Check } from "../../utils/address"; +import bufferutils from '../../utils/bufferutils' +import { BN } from 'bn.js'; +import { BigNumber } from '../../utils/types/BigNumber'; +import { I_ADDR_VERSION } from '../../constants/vdxf'; +import { VDXFData } from '../../'; +import { EHashTypes } from '../../pbaas/DataDescriptor'; +const { BufferReader, BufferWriter } = bufferutils +const createHash = require("create-hash"); +import { VERUS_DATA_SIGNATURE_PREFIX } from "../../constants/vdxf"; +import { SaltedDataKey } from '../vdxfdatakeys'; + +export class SaltedData extends VDXFData { + + salt: Buffer; + + static VERSION_INVALID = new BN(0); + static FIRST_VERSION = new BN(1); + static LAST_VERSION = new BN(1); + static DEFAULT_VERSION = new BN(1); + + + constructor(data?: Buffer, salt: Buffer = Buffer.alloc(0)) { + super(data); + if (salt.length != 0) { + this.salt = salt; + } + this.vdxfkey = SaltedDataKey.vdxfid; + + } + + static fromJson(data: any) { + + const saltedData = new SaltedData(); + + if (data) { + if (data.version) { + saltedData.version = new BN(data.version); + } else { + saltedData.version = SaltedData.DEFAULT_VERSION; + } + if (data.salt) saltedData.salt = Buffer.from(data.salt, 'hex'); + if (data.data) saltedData.data = Buffer.from(data.data, 'hex'); + if (data.key) saltedData.vdxfkey = data.key; + } + + return saltedData; + } + getByteLength() { + let byteLength = 0; + + byteLength += 20; //key + byteLength += varint.encodingLength(this.version); + byteLength += varuint.encodingLength(this.data.length + this.salt.length); + byteLength += this.data.length + this.salt.length; + + return byteLength + } + + toBuffer() { + const bufferWriter = new BufferWriter(Buffer.alloc(this.getByteLength())) + + bufferWriter.writeSlice(fromBase58Check(this.vdxfkey).hash); + bufferWriter.writeVarInt(this.version); + bufferWriter.writeVarSlice(Buffer.concat([this.data, this.salt])); + + return bufferWriter.buffer + } + + fromBuffer(buffer: Buffer, offset: number = 0) { + const reader = new BufferReader(buffer, offset); + + this.vdxfkey = toBase58Check(reader.readSlice(20), I_ADDR_VERSION); + this.version = reader.readVarInt(); + this.data = reader.readVarSlice(); + + this.salt = this.data.slice(this.data.length - 32); + this.data = this.data.slice(0, this.data.length - 32); + + return reader.offset; + } + + toJson(): any { + + return { + version: this.version.toString(), + key: this.vdxfkey, + data: this.data.toString('hex'), + salt: this.salt.toString('hex') + } + } + + getHash(hw: (data: Buffer) => Buffer ):Buffer { + + const hash = hw(Buffer.concat([this.data, this.salt])); + + return hash; + + } +} \ No newline at end of file diff --git a/src/vdxf/classes/index.ts b/src/vdxf/classes/index.ts index 2c7f682..2508229 100644 --- a/src/vdxf/classes/index.ts +++ b/src/vdxf/classes/index.ts @@ -32,9 +32,10 @@ export { RequestedPermission, Audience, AltAuthFactor, - Attestation, } from "./Challenge"; +export {Attestation} from './Attestation' export { ProvisioningTxid } from './provisioning/ProvisioningResult' -export { Context } from './Context' \ No newline at end of file +export { Context } from './Context' +export { DataCategory } from './PersonalProfile' \ No newline at end of file diff --git a/src/vdxf/identitydatakeys.ts b/src/vdxf/identitydatakeys.ts new file mode 100644 index 0000000..17868ab --- /dev/null +++ b/src/vdxf/identitydatakeys.ts @@ -0,0 +1,1832 @@ +import { VDXFKeyInterface } from "./keys" + +export const IDENTITY_ACCOUNT_ID: VDXFKeyInterface = { + "vdxfid": "i5Xgd7Aqds922eE8FDBUsKHSgiig39AnfS", + "indexid": "xAMo5ubvVBMgep7A6tqdqhoyiNjgq3j1ci", + "hash160result": "4c5e79bf46593fe959cb1918422eaa8fc82b8916", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::identity.account.id" + } +} + +export const IDENTITY_ACCOUNT_USERID: VDXFKeyInterface = { + "vdxfid": "iNKVUvr5GzdCHgybMauK11DdZZUyWE3pe3", + "indexid": "xT9bwjHA8JqrurrdDGZTyPkAbDVzR53C2o", + "hash160result": "93b62bfd8c861ac7a5aa3d3d9f618ccd8c04b5ce", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::identity.account.userid" + } +} + +export const IDENTITY_ACCOUNT_CREATEDAT: VDXFKeyInterface = { + "vdxfid": "i42uTbJmVBcPacY3Ak1g95LBg5rBBntQby", + "indexid": "x8s1vPjrLVq4CnR52Rfq7TrihjsBzxAEic", + "hash160result": "c40b12b14582c976e67a2e5992b0fdf67fb21f06", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::identity.account.createdat" + } +} + +export const IDENTITY_ACCOUNT_COMPLETEDAT: VDXFKeyInterface = { + "vdxfid": "iRJTZj7osY5EYA7pd7K3UcJVAApkvodDjZ", + "indexid": "xW8a2XYtirHuAKzrUnyCSzq2BpqmpCnnHQ", + "hash160result": "c568b6e1f734f5dc9b754e5932ebdb63f2606bef", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::identity.account.completedat" + } +} + +export const IDENTITY_ACCOUNT_PREVIOUSATTEMPTID: VDXFKeyInterface = { + "vdxfid": "iGU6RCWyjU1sscCPLN77XhTESJ21JCTNxF", + "indexid": "xMJCszx4anEYVn5RC3mGW5ymTx32EBfaqs", + "hash160result": "50c2b12bb483802d14beae3c6b7454c6ecc0848e", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::identity.account.previousattemptid" + } +} + +export const IDENTITY_ACCOUNT_SHAREABLEURL: VDXFKeyInterface = { + "vdxfid": "i92YkV3FVGZfp5Ep3j1sfQUgqUS37M9v82", + "indexid": "xDrfDHULLanLSF7quQg2do1Ds8T3yGCRw3", + "hash160result": "52e9f990e5e89cc1088acd29a2fda0ef140ae73c", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::identity.account.shareableurl" + } +} + +export const IDENTITY_ACCOUNT_TEMPLATEID: VDXFKeyInterface = { + "vdxfid": "iL5diuVsHAG5DLVeyc8XYdEXR6fFro5G7s", + "indexid": "xQukBhvx8UUjqWNgqHngX1m4SkgGhnybh1", + "hash160result": "37ef653fe6685fca132d77834384702f6cd225b6", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::identity.account.templateid" + } +} + +export const IDENTITY_ACCOUNT_TEMPLATEVERSION: VDXFKeyInterface = { + "vdxfid": "i7eBZNzKrgFov6c2Sx2QecyEmPq2Mc4BGe", + "indexid": "xCUJ2BRQhzUUYGV4JdgZd1Vmo3r39BsUym", + "hash160result": "e6e490ce8bfde333ab0374880ea0efbb9c12b42d", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::identity.account.templateversion" + } +} + +export const IDENTITY_ACCOUNT_STATUS: VDXFKeyInterface = { + "vdxfid": "iJf3EbihEtdEpJjbQ6PgUaL3GxDgZRzSWk", + "indexid": "xPV9hQ9n6CquSUcdFn3qSxraJcEhVfWa72", + "hash160result": "d6fc5578c2fbed3251f3aa250c73b58386ec86a6", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::identity.account.status" + } +} + +export const IDENTITY_PHONENUMBER: VDXFKeyInterface = { + "vdxfid": "iAQY8o4HwupzcJAw9aBtFwgrvWZGQStkge", + "indexid": "xFEebbVNoE3fEU3y1Fr3ELDPxAaHE7V2kN", + "hash160result": "32bc2c7919f626c39679630ee4d6d6d07bcd074c", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::identity.phonenumber" + } +} + +export const IDENTITY_DATEOFBIRTH: VDXFKeyInterface = { + "vdxfid": "iSZsa7C4esogN3W6fBngUHR6GvSmt7We4j", + "indexid": "xXPz2ud9WC2LzDP8WsSqSfwdJaTnqpHdND", + "hash160result": "ab74371e952a27f615b079d3c084b38b98c84dfd", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::identity.dateofbirth" + } +} + +export const IDENTITY_OVER18: VDXFKeyInterface = { + "vdxfid": "iHPD8vB7jhtbuqPkUqzheqcZdfAfHUFVzM", + "indexid": "xNDKbicCb27GY1GnLXerdE96fKBg9tLUDT", + "hash160result": "28139ce1eae370e76f749066f778466597689098", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::identity.over18" + } +} + +export const IDENTITY_OVER21: VDXFKeyInterface = { + "vdxfid": "iAXYYrZaipc4DAmAKXUFYZxavsf6uBJqaj", + "indexid": "xFMf1ezfa8piqLeCBD8QWxV7xXg7mxMc1Z", + "hash160result": "7a1fee70ace1c048c0a93c120a8a4c5f890f5b4d", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::identity.over21" + } +} + +export const IDENTITY_OVER25: VDXFKeyInterface = { + "vdxfid": "iDuForPTZFeFBAgDX1HyrP3d6of7wzrRaS", + "indexid": "xJjNGepYQZruoLZFNgx8pmaA8Tg8qSfnzM", + "hash160result": "2a1e6fa6913ea3659dcaf1c5bc20a96e399d5e72", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::identity.over25" + } +} + +export const IDENTITY_ACCOUNT_REQUESTING_IPADDRESS: VDXFKeyInterface = { + "vdxfid": "i4uE1EvnDbq9WGhF5UbBr6fbxNLsgk1eZ3", + "indexid": "x9jLU3Ms4v3p8SaGwAFLpVC8z2MtYJTVwp", + "hash160result": "05a3aa58192812972a2c4e4184af7bb5fbf9a30f", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::identity.account.requesting.ipaddress" + } +} + +export const IDENTITY_EMAIL: VDXFKeyInterface = { + "vdxfid": "iJ4pq4DCymfbu8SAuXyNhasLeSHFNKPr23", + "indexid": "xNtwHreHq5tGXJKCmDdXfyPsg6JGHUY6X1", + "hash160result": "15a8095b6298bbff5147060d9a6363a9df6c0ea0", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::identity.email" + } +} + +export const IDENTITY_NATIONALITY: VDXFKeyInterface = { + "vdxfid": "iEUYNTkw6kFhZWto7vyTpQqtdRL7eoKZY2", + "indexid": "xKJeqGC1x4UNBgmpycdcnoNRf5M8btexbt", + "hash160result": "db935713b90281d6aefe5e7b33e5b660962aaa78", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::identity.nationality" + } +} + +export const IDENTITY_FIRSTNAME: VDXFKeyInterface = { + "vdxfid": "iLB8SG7ErJtTYcG1f4w9RLuMJPpAsjFkiL", + "indexid": "xR1Eu4YKhd78An93WkbJPjRtL3qBprmMno", + "hash160result": "0bab76359b70b37c858399c2a3776939c5de2fb7", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::identity.firstname" + } +} + +export const IDENTITY_MIDDLENAME: VDXFKeyInterface = { + "vdxfid": "iHG6ALRUPyRcgJMsPqBmvUCZxe4PrMfgej", + "indexid": "xN6Cd8rZFHeHJUEuFWqvtrj6zJ5QjX94j5", + "hash160result": "b98bd82034ec86ae5538313c9f5501c086ac3797", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::identity.middlename" + } +} + +export const IDENTITY_LASTNAME: VDXFKeyInterface = { + "vdxfid": "iKRmfy4xgjWQyPdXYie6dJezRXF4aKdbHB", + "indexid": "xQFt8mW3Y3j5bZWZQQJFbhBXTBG5S4vdaZ", + "hash160result": "6b597e0c05d1430566b7b17a59da683fb4a6fcae", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::identity.lastname" + } +} + +export const IDENTITY_GENDER: VDXFKeyInterface = { + "vdxfid": "iShgSBdiYDQnVwgNcDnSbNYHGU6CTwBDb1", + "indexid": "xXXntz4oPXdT87ZQTuSbZm4pJ87DGEgHpG", + "hash160result": "3baee594e927d47b641c7cf3927ab3229dd0c7fe", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::identity.gender" + } +} + +export const IDENTITY_HEIGHT: VDXFKeyInterface = { + "vdxfid": "iLmLmsFMTUm4dd2iMuMe4xaMC8VSZN9soP", + "indexid": "xRbTEfgSJnyjFnukDb1o3M6tDnWTSUiii7", + "hash160result": "e80652253fa52b95cd9ea5ff43d51642ea4fa8bd", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::identity.height" + } +} + +export const IDENTITY_EYECOLOR: VDXFKeyInterface = { + "vdxfid": "iRo2XT8tcMtLTpuPJ6V5WxbnVWa2CrcdsJ", + "indexid": "xWd8zFZyTg715znR9n9EVM8KXAb328xGbZ", + "hash160result": "c60fdfcc04173f273aa92a3b1844964b368ad2f4", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::identity.eyecolor" + } +} + +export const IDENTITY_ETHNICITY: VDXFKeyInterface = { + "vdxfid": "i9jHPJokwnLoCQ83P6jqezCcEZUD1g34B9", + "indexid": "xEZPr7Eqo6ZTpa15EnPzdNj9GDVDsfToki", + "hash160result": "0476d568a9cf949bc8b6d84dc73e38cf85449b44", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::identity.ethnicity" + } +} + +export const IDENTITY_WEIGHT: VDXFKeyInterface = { + "vdxfid": "iMzGK44r6SNkzi3N3AmcZBtuysPvgYiRiT", + "indexid": "xSpNmrVvwkbRcsvPtrRmXaRT1XQwXFe2Ut", + "hash160result": "8abe0e94cb1ff345f1351720acc8eefed91e12cb", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::identity.weight" + } +} + +export const IDENTITY_HOMEADDRESS: VDXFKeyInterface = { + "vdxfid": "i9A1fD5sVwFFXzEmCJWSRDqN94PXp9oNaS", + "indexid": "xDz881WxMFTvAA7o3zAbPcMuAiQYiT4Vnc", + "hash160result": "072a3abed3a353e001288074d9426285e569503e", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::identity.homeaddress" + } +} + +export const IDENTITY_HOMEADDRESS_STREET1: VDXFKeyInterface = { + "vdxfid": "i5BJAwQbrP4Bht8gUpoqSrovuBwfRc6jiv", + "indexid": "xA1QdjqghhGrL41iLWTzRFLTvqxgNsVzXY", + "hash160result": "ff22b196e64c9388daab76a57bcaea50491cae12", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::identity.homeaddress.street1" + } +} + +export const IDENTITY_HOMEADDRESS_STREET2: VDXFKeyInterface = { + "vdxfid": "iMx71C14hrBoWD3yyhYChmhJEw4Kqw1zj4", + "indexid": "xSnDTzS9ZAQU8Nw1qPCMgADqGb5Lgqb4zw", + "hash160result": "efdda473a6a9e98cd91b02d36bfeb5dec784a9ca", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::identity.homeaddress.street2" + } +} + +export const IDENTITY_HOMEADDRESS_CITY: VDXFKeyInterface = { + "vdxfid": "i75ZpW5T6wgQEMVxyvqHT9ZaV4fjsQ7kws", + "indexid": "xBugHJWXxFu4rXNzqcVSRY67WigkoCUEUQ", + "hash160result": "fcae40d5d327f13dc0e0c1e80f3db212a4ed8827", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::identity.homeaddress.city" + } +} + +export const IDENTITY_HOMEADDRESS_REGION: VDXFKeyInterface = { + "vdxfid": "iRkYck3JowdFWmrM6VUAS8Wtpmxds2fLXS", + "indexid": "xWaf5YUPfFqv8wjNxB8KQX3RrRyenbioh5", + "hash160result": "fa06b90a547658a3efc3cd1797d6b3cd30695af4", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::identity.homeaddress.region" + } +} + +export const IDENTITY_HOMEADDRESS_POSTCODE: VDXFKeyInterface = { + "vdxfid": "iAL2FRG8PVi18fN8MatjXhV1YkuZr7PM4T", + "indexid": "xFA8iDhDEovfkqFADGYtW61YaQvahtrhJA", + "hash160result": "b4f4c3a08fdcf32209482fa3d8c7b01201312d4b", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::identity.homeaddress.postcode" + } +} + +export const IDENTITY_HOMEADDRESS_COUNTRY: VDXFKeyInterface = { + "vdxfid": "iABYGvas6uUDk9ejCkfCVLvE9PPJXgyCKX", + "indexid": "xF1ejj1wxDgtNKXm4SKMTjSmB3QKL8LhQG", + "hash160result": "bafb2cb6d5cc86478622feb8a00097d71d839249", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::identity.homeaddress.country" + } +} + +export const IDENTITY_IDNUMBER_VALUE: VDXFKeyInterface = { + "vdxfid": "iQrnvbCNWMaG6PjTmeXzrcuAXKsMzmNJWA", + "indexid": "xVguPPdTMfnviZcVdLC9q1RhYytNuZ3ToS", + "hash160result": "72cf52b2f6b4f68173c933fb046e892870b990ea", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::identity.idnumber.value" + } +} + +export const IDENTITY_IDNUMBER_TYPE: VDXFKeyInterface = { + "vdxfid": "iSSZX5yUdQh7zLf1gUewH5rVfbXtSq2c4s", + "indexid": "xXGfytQZUiuncWY3YAK6FUP2hFYuQ4yYwW", + "hash160result": "2807f356d687b4c6208ce0379b31043c7fcdebfb", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::identity.idnumber.type" + } +} + +export const IDENTITY_VERIFICATION_STATUS: VDXFKeyInterface = { + "vdxfid": "i8MhqW3ejupmV1M5UyhyhG13dkS8A7g7zg", + "indexid": "xDBpJJUjbE3S7BE7LfN8feXafQT92YQZPm", + "hash160result": "47f2864de74ffe01ccb7eeabf0f2d848e3668e35", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::identity.verification.status" + } +} + +export const IDENTITY_VERIFICATION_APPROVALS: VDXFKeyInterface = { + "vdxfid": "iBMkZtqC9yqVrFL4GfYtXckFpYAhRkE2mj", + "indexid": "xGBs2hGH1J4AURD68MD3W1GnrCBiJ3nRgG", + "hash160result": "a98801de1ba5ff5e571dbdde50519483140f7956", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::identity.verification.approvals" + } +} + +export const IDENTITY_VERIFICATION_APPROVALS_ACCEPTEDTOS: VDXFKeyInterface = { + "vdxfid": "iH32QkXBKyWEJD6kh9HJ4KMfeiWfPWoHEh", + "indexid": "xMs8sYxGBHitvNynYpwT2htCgNXgHt6VAW", + "hash160result": "bbe4c09ae069561d3c14b04e3b7b96c98622bf94", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::identity.verification.approvals.acceptedtos" + } +} + +export const IDENTITY_VERIFICATION_APPROVALS_VERIFIEDSMS: VDXFKeyInterface = { + "vdxfid": "iPgyMDFQ9QMNrqc3ckEBEubDNwLnvubUdW", + "indexid": "xUX5p1gUzia3V1V5URtLDJ7kQbMosPsVj8", + "hash160result": "72853b66aa158531e1f15b9ff075199a1224bddd", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::identity.verification.approvals.verifiedsms" + } +} + +export const IDENTITY_VERIFICATION_APPROVALS_KYCCHECKED: VDXFKeyInterface = { + "vdxfid": "iRnbiA4dAPbeuB6KQN2donBHP9mKUHHFZf", + "indexid": "xWciAxVi1hpKXLyMG3gnnAhpQonLQapWPv", + "hash160result": "c6114ffec250b746bde117903b930d9a34d3bdf4", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::identity.verification.approvals.kycchecked" + } +} + +export const IDENTITY_VERIFICATION_APPROVALS_DOCUMENTSVERIFIED: VDXFKeyInterface = { + "vdxfid": "iBjML9DHV67MBQyMEHVTSoJPhU8DNeWRTE", + "indexid": "xGZTnweNLQL1oarP5y9cRBpvj89EGt5VSm", + "hash160result": "0a93883010769ff783be5ced074ecfa50dd08e5a", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::identity.verification.approvals.documentsverified" + } +} + +export const IDENTITY_VERIFICATION_APPROVALS_SELFIECHECKED: VDXFKeyInterface = { + "vdxfid": "iKgeFKoy6WMx9MoEjig5vHoXbyxVFBPWDN", + "indexid": "xQWki8F3wpacmXgGbQLEtgL4ddyWC8UZLv", + "hash160result": "6a044306ef77ce9896ffcd26ee40174651b1ccb1", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::identity.verification.approvals.selfiechecked" + } +} + +export const IDENTITY_VERIFICATION_APPROVALS_WATCHLISTOK: VDXFKeyInterface = { + "vdxfid": "iFDB1qKYSrWMRaMCWX6hNGE8HVXB1cNtJu", + "indexid": "xL3HUdkdJAj23kEENCkrLekfK9YBymnLrX", + "hash160result": "e691a2d2af30df6ee21f0eb805a98e11d539ba80", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::identity.verification.approvals.watchlistok" + } +} + +export const IDENTITY_VERIFICATION_APPROVALS_RISKCHECKOK: VDXFKeyInterface = { + "vdxfid": "i9dva492S7vQphjLiK2UaS7JikZKs5TQsB", + "indexid": "xEU32ra7HS95SscNZzgdYpdqkQaLjnzcyC", + "hash160result": "6ffdbee07124450d29698724573bd6ab07d09743", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::identity.verification.approvals.riskcheckok" + } +} + +export const IDENTITY_VERIFICATION_APPROVALS_STATUS: VDXFKeyInterface = { + "vdxfid": "iKhGUcTH4ZQ7uiy933m8f1GbwSLcwJW8ev", + "indexid": "xQXNwQtMuscnXtrAtjRHdPo8y6MdomjAXM", + "hash160result": "00612f17d9cedc346fcd139c0c5b56e666efeab1", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::identity.verification.approvals.status" + } +} + +export const IDENTITY_DRIVINGLICENCE: VDXFKeyInterface = { + "vdxfid": "iMYQw33ryywcNyQDjFjiVvFm2kAwG85poV", + "indexid": "xSNXPqUwqJAH19HFawPsUJnJ4QBxCATPNx", + "hash160result": "e2857ddcc4f3301c354a00d1376558a75e802ec6", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::identity.drivinglicence" + } +} + +export const IDENTITY_DRIVINGLICENCE_ORIGINALFRONT: VDXFKeyInterface = { + "vdxfid": "i3fq6ET2dL8CxC3BJzdYTpUsjEsQaKP7bX", + "indexid": "x8VwZ2t7UeLsaMvDAgHhSD1QkttRPYndPW", + "hash160result": "26bab54e1f760b1abb888229a38a5179cc502302", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::identity.drivinglicence.originalfront" + } +} + +export const IDENTITY_DRIVINGLICENCE_ORIGINALBACK: VDXFKeyInterface = { + "vdxfid": "i7LTNZvJmm5LjAwMWuryb52yKt7txaV5FW", + "indexid": "xCAZqNMPd5J1MLpPNbX8ZTZWMY8unxdAfs", + "hash160result": "c7b3e9a70908fafc8de3e81f6ac2e0c131c9592a", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::identity.drivinglicence.originalback" + } +} + +export const IDENTITY_DRIVINGLICENCE_CROPPEDFRONT: VDXFKeyInterface = { + "vdxfid": "i8KsL3JJgbJyuqEyEbu5KZkDBFvHscLoM6", + "indexid": "xD9ynqjPXuXeY1816HZEHxGkCuwJoHBx54", + "hash160result": "7b28226a4f3eaae379cddbc84d037cfe587e3535", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::identity.drivinglicence.croppedfront" + } +} + +export const IDENTITY_DRIVINGLICENCE_CROPPEDBACK: VDXFKeyInterface = { + "vdxfid": "iRwumhx12vtT8CkspBLmKQY8WZywurxVXo", + "indexid": "xWn2EWP5tF77kNdufrzvHo4fYDzxhjXyZz", + "hash160result": "0b6edf21bfe119173b3fffab6118d79a39a580f6", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::identity.drivinglicence.croppedback" + } +} + +export const IDENTITY_DRIVINGLICENCE_FACE: VDXFKeyInterface = { + "vdxfid": "i5i7U4EAbgPzhCRebtbmoZt6pTyqGqP8jj", + "indexid": "xAYDvrfFSzcfKNJgTaFvmxQdr7zr6oGgFh", + "hash160result": "1f47647bf3e71f0c1c2638c99e6a42e6bf118218", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::identity.drivinglicence.face" + } +} + +export const IDENTITY_DRIVINGLICENCE_IDNUMBER: VDXFKeyInterface = { + "vdxfid": "iBCA8b4zS5ygVgTFqxabke7BBFs92dhcXQ", + "indexid": "xG2GbPW5HQCM7rLHheEkj2diCut9vgFhM2", + "hash160result": "fcf0571278bd1afce6d93f0a99f41437bb91a854", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::identity.drivinglicence.idnumber" + } +} + +export const IDENTITY_DRIVINGLICENCE_CATEGORY: VDXFKeyInterface = { + "vdxfid": "i5Cm95DZa6FPP66bA6aFfoYL2jaojetHMp", + "indexid": "xA2sbseeRQU41Fyd1nEQeC4s4Pbpf63xB4", + "hash160result": "3b91fccdf59d99b21e442441b89abb31bf09f512", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::identity.drivinglicence.category" + } +} + +export const IDENTITY_DRIVINGLICENCE_EXPIRATIONDATE: VDXFKeyInterface = { + "vdxfid": "iJvGpPoP1uUkUqn9bAchLyfaGWyy8JGQoX", + "indexid": "xPkPHCETsDhR71fBSrGrKNC7JAzz17RsLk", + "hash160result": "96aee63b3c6094a4d9edbc04b63a8e45688068a9", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::identity.drivinglicence.expirationdate" + } +} + +export const IDENTITY_DRIVINGLICENCE_ISSUINGCOUNTRY: VDXFKeyInterface = { + "vdxfid": "iBsNEqysX64cQAjiRHHL1msd7LxroGM6Mb", + "indexid": "xGhUheQxNQHH2LckGxwUzAQA8zysfnKDSU", + "hash160result": "f2f24dd2383538493d21ff0aca77c7cd1fe6125c", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::identity.drivinglicence.issuingcountry" + } +} + +export const IDENTITY_DRIVINGLICENCE_ISSUINGREGION: VDXFKeyInterface = { + "vdxfid": "i6gZSDYpK9inexaeFQDSk9GuAmew1ymMFo", + "indexid": "xBWfu1yuATwTH8Tg75sbiXoSCRfwsxQzeR", + "hash160result": "67f4fd5c49250912aecf1eb8ab17f29d590a2f23", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::identity.drivinglicence.issuingregion" + } +} + +export const IDENTITY_DRIVINGLICENCE_DATEOFBIRTH: VDXFKeyInterface = { + "vdxfid": "iChWUsL1NQwDqcwXbFGxHiCegfquGPyadv", + "indexid": "xHXcwfm6Dj9tTnpZSvw7G6jBiKrvBUhwaw", + "hash160result": "3c7bd13bcdb54368e7590a9f2da5b201b7be2d65", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::identity.drivinglicence.dateofbirth" + } +} + +export const IDENTITY_DRIVINGLICENCE_ADDRESS_STREET1: VDXFKeyInterface = { + "vdxfid": "i9xaEvSQ537wuYgcVPRgG3zop9bVzeDTBw", + "indexid": "xEnghisUvMLcXiZeM55qESXLqocWsv6zmJ", + "hash160result": "48dd1caf84c1a49209ca44064846dc4ad0be1e47", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::identity.drivinglicence.address.street1" + } +} + +export const IDENTITY_DRIVINGLICENCE_ADDRESS_CITY: VDXFKeyInterface = { + "vdxfid": "i6XMEh3jrxzdyoVYoNWhRSncR9oWSnmikd", + "indexid": "xBMThVUpiHDJbyNaf4ArPqK9SopXGndEyv", + "hash160result": "c1f3612774870d1f12320bff317e7790211d7121", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::identity.drivinglicence.address.city" + } +} + +export const IDENTITY_DRIVINGLICENCE_ADDRESS_REGION: VDXFKeyInterface = { + "vdxfid": "i7sPBSqerD23RAqfN167aYePjfC8LL34UA", + "indexid": "xChVeFGjhXEi3LihDgkGYwAvmKD9CsNunu", + "hash160result": "991d24c053cb59a816e161fe3af2f40a7f2e3330", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::identity.drivinglicence.address.region" + } +} + +export const IDENTITY_DRIVINGLICENCE_ADDRESS_POSTCODE: VDXFKeyInterface = { + "vdxfid": "i9eHAmpeA3tmpsVeG5EkHuVfALFrmpzLqM", + "indexid": "xEUPdaFj1N7ST3Ng7ktuGJ2CBzGsZbja5V", + "hash160result": "f5905bbdf2eb60b24ccf6851716cc0efe801a943", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::identity.drivinglicence.address.postcode" + } +} + +export const IDENTITY_DRIVINGLICENCE_ADDRESS_COUNTRY: VDXFKeyInterface = { + "vdxfid": "i3xAMYBKLVdK89kuheXhTjuJTAxozmypj3", + "indexid": "x8nGpLcQBoqykKdwZLBrS8RqUpypqVUEV5", + "hash160result": "459844e00df4387514f31f182a88f7e13b0d3a05", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::identity.drivinglicence.address.country" + } +} + +export const IDENTITY_SELFIECHECK_IMAGE: VDXFKeyInterface = { + "vdxfid": "iC22PxGqY7Mx3YT9kNrW1d11JNyGL56N8e", + "indexid": "xGr8rkhvPRacfiLBc4Wez1XYL2zHDDbJgD", + "hash160result": "c52d0023cce8c847a5097b6898f867651914b65d", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::identity.selfiecheck.image" + } +} + +export const IDENTITY_SELFIECHECK_VIDEO: VDXFKeyInterface = { + "vdxfid": "iLfnRYzcdQXR6am8rZk7xNtTUbLZo5NLG6", + "indexid": "xRVttMRhUik5ikeAiFQGvmQzWFMajwrVzX", + "hash160result": "ac0674f6d656d434e0b5b310daaaed554c3a9bbc", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::identity.selfiecheck.video" + } +} + +export const IDENTITY_EMAIL_ISDELIVERABLE: VDXFKeyInterface = { + "vdxfid": "iN5Tdse8NSwuW6A4ZavHbHoDyD8aVjn1Ky", + "indexid": "xSua6g5DDmAa8G36RGaSZgKkzs9bSnFbCX", + "hash160result": "8194ee01a0bc66dca2af9ba7c3bba4a24da70dcc", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::identity.email.isdeliverable" + } +} + +export const IDENTITY_EMAIL_BREACHCOUNT: VDXFKeyInterface = { + "vdxfid": "iDy1YKGhzVjAiMiuAvFDqxQbmLRhLEjwPo", + "indexid": "xJo817hnqowqLXbw2buNpLw8nzSiAygHhx", + "hash160result": "8144d2d8cafd733bb03847166be8493d275e1473", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::identity.email.breachcount" + } +} + +export const IDENTITY_EMAIL_FIRSTBREACHEDAT: VDXFKeyInterface = { + "vdxfid": "i3eSGR4wrLk5djHsnT18dDHrJBFSBBxVST", + "indexid": "x8UYjDW2hexkFuAue8fHbbpPKqGT4mjAzH", + "hash160result": "df796054181f57d3b61d655d604d42d6c6d8df01", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::identity.email.firstbreachedat" + } +} + +export const IDENTITY_EMAIL_LASTBREACHEDAT: VDXFKeyInterface = { + "vdxfid": "iCuZWBzmxCoFcRFjXYFgC6g4jT7kzxvhew", + "indexid": "xHjfxzRroX1vEb8mPDuqAVCbm78ms8Hkhd", + "hash160result": "d1b421db4c835cfa67b491342c31f89283427567", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::identity.email.lastbreachedat" + } +} + +export const IDENTITY_EMAIL_DOMAIN_REGISTEREDAT: VDXFKeyInterface = { + "vdxfid": "iGxV4SBRZMk5qWrQEKgUS4RoqzpDmyBEpC", + "indexid": "xMnbXEcWQfxkTgjS61LdQSxLseqEcTADNA", + "hash160result": "e195ef220f8e71bfa7bef160291ecaa0164de393", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::identity.email.domain.registeredat" + } +} + +export const IDENTITY_EMAIL_DOMAIN_FREEPROVIDER: VDXFKeyInterface = { + "vdxfid": "iLUfvKcg92CYo3BvCuRf5o844d44kGLhJL", + "indexid": "xRJnP83kzLRDRD4x4b5p4Beb6H55fetTy7", + "hash160result": "0b0f213c88a1b0df6cd01721955b1d0c103981ba", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::identity.email.domain.freeprovider" + } +} + +export const IDENTITY_EMAIL_DOMAIN_CUSTOM: VDXFKeyInterface = { + "vdxfid": "i4FSBFpQ6Ccjiy2g61GrxhBppv1jDDh6on", + "indexid": "x95Ye4FUwWqQM8uhwgw1w5iMra2k7F1Lfz", + "hash160result": "bea1175185aeaf256aa7f04795b2c8d0c8547e08", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::identity.email.domain.custom" + } +} + +export const IDENTITY_EMAIL_DOMAIN_DISPOSABLE: VDXFKeyInterface = { + "vdxfid": "i52PJxRyjKAEkmQFd2oGYgZV3pcsQUcD1T", + "indexid": "x9rVmks4adNuNwHHUiTRX5625UdtJPBQ1w", + "hash160result": "3adf98cb5cc90a074a52a651c50f67f5f0a7fe10", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::identity.email.domain.disposable" + } +} + +export const IDENTITY_EMAIL_DOMAIN_TOPLEVEL_SUSPICIOUS: VDXFKeyInterface = { + "vdxfid": "iCtAZWinafiyf4tmvPxFkKNn5KxayXTPSV", + "indexid": "xHiH2K9sRyweHEmon5cQihuK6yybre797b", + "hash160result": "85477eb8148562614c396ca64fc7563637b13167", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::identity.email.domain.toplevel.suspicious" + } +} + +export const IDENTITY_PASSPORT: VDXFKeyInterface = { + "vdxfid": "iKgbqmZ4Ks9SPNQGj5PZ5TgXomYG4CtaXv", + "indexid": "xQWiJZz9BBN71YHJam3i3rD4qRZH1sbLHD", + "hash160result": "775f52820102c994e30a29b1828b064421afcab1", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::identity.passport" + } +} + +export const IDENTITY_PASSPORT_ORIGINALFRONT: VDXFKeyInterface = { + "vdxfid": "iCwT1mHdci9wooC6Q8mtx8QssXzwiL4hxp", + "indexid": "xHmZUZiiU2NcRy58FpS3vWwQuC1xdM48mW", + "hash160result": "25023e23a25ba4daa7ac0a9c96180f5e90acd067", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::identity.passport.originalfront" + } +} + +export const IDENTITY_PASSPORT_ORIGINALBACK: VDXFKeyInterface = { + "vdxfid": "iDXKJaroNRKr9GZfLFvH7LttJQaXqGoSrc", + "indexid": "xJMRmPHtDjYWmSShBwaS5jRRL4bYmTdC9J", + "hash160result": "21734b0f37ec51dd77bdab8c10065cf67b61386e", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::identity.passport.originalback" + } +} + +export const IDENTITY_PASSPORT_CROPPEDFRONT: VDXFKeyInterface = { + "vdxfid": "i4cr6CxCYDHUDjc6UoMsDVAZoNep6Meuyi", + "indexid": "x9SxZ1PHPXW8quV8LV22Bsh6q2fpxtJ6Zd", + "hash160result": "274c241806d31576a57a074cc2f6b4c624078b0c", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::identity.passport.croppedfront" + } +} + +export const IDENTITY_PASSPORT_CROPPEDBACK: VDXFKeyInterface = { + "vdxfid": "i6wA2ttX7vcxBXmrdmGEa44NZEFBZWoRYa", + "indexid": "xBmGVhKbyEqcohetVSvPYSauatGCUYDMs2", + "hash160result": "f56f1db46ddebc99f3c8954fc8bf1d26a9bef125", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::identity.passport.croppedback" + } +} + +export const IDENTITY_PASSPORT_FACE: VDXFKeyInterface = { + "vdxfid": "iLCbvnyU4V3XeMz18CXAG5MCtjb2FjpcZX", + "indexid": "xR2iPbQYuoGCGXs2ytBKETsjvPc35DNZDm", + "hash160result": "26f7dc9d524f84a21c8a9e3f2dc5149f3a3c77b7", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::identity.passport.face" + } +} + +export const IDENTITY_PASSPORT_IDNUMBER: VDXFKeyInterface = { + "vdxfid": "iDYih1jmCA1oexyxZ1PQFL5ewyciqoQ2rw", + "indexid": "xJNq9pAr3UEUH8rzQh3ZDicByddjgKM4vN", + "hash160result": "c8a25af227fc07e260119b370da0eae2a9517c6e", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::identity.passport.idnumber" + } +} + +export const IDENTITY_PASSPORT_CATEGORY: VDXFKeyInterface = { + "vdxfid": "iMtpUJYWZmnnSJyJcshHRdWJZMhZVZZifT", + "indexid": "xSivw6ybR61T4UrLUZMSQ22qb1iaQux7BU", + "hash160result": "84a9f125285d7e93a1e676ed48e3fbe459780aca", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::identity.passport.category" + } +} + +export const IDENTITY_PASSPORT_EXPIRATIONDATE: VDXFKeyInterface = { + "vdxfid": "i98TaZ3wTh3qRw2ufeunVY2MD5eKwoamGE", + "indexid": "xDxa3MV2K1GW46uwXLZwTvYtEjfLspcYEK", + "hash160result": "07727b480c654d59cb611ed01715e254eb37053e", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::identity.passport.expirationdate" + } +} + +export const IDENTITY_PASSPORT_ISSUINGCOUNTRY: VDXFKeyInterface = { + "vdxfid": "iRHGM2GEYeRUuHKSG1wENVA16bdyVRxchn", + "indexid": "xW7NophKPxe9XTCU7hbPLsgY8FezLKmJHi", + "hash160result": "4798dee337b16fc22d26748fb0803738f99831ef", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::identity.passport.issuingcountry" + } +} + +export const IDENTITY_PASSPORT_ISSUINGREGION: VDXFKeyInterface = { + "vdxfid": "i6Ay9VdcZjGrJur5SNyhBDZWzxGmo7qUmW", + "indexid": "xB15cJ4hR3VWw5j7J4dr9c642cHnbq2nm9", + "hash160result": "f3d9b605096f4c816de7d72c597fee07e75a961d", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::identity.passport.issuingregion" + } +} + +export const IDENTITY_PASSPORT_DATEOFBIRTH: VDXFKeyInterface = { + "vdxfid": "iAjG8DwYfKxt9affJy6CUBDDFK5jaeHRLJ", + "indexid": "xFZNb2NdWeBYmkYhAekMSZjkGy6kWqAqyd", + "hash160result": "73eb23619d178f495a24b41aaf6aac107357924f", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::identity.passport.dateofbirth" + } +} + +export const IDENTITY_PASSPORT_ADDRESS_STREET1: VDXFKeyInterface = { + "vdxfid": "i7HPJNB16V5pws8xSq4a8pHF29Mcg6sUyy", + "indexid": "xC7VmAc5woJVa31zJWij7Con3oNdXuBysY", + "hash160result": "c28625c4dfc12d3cdd85f8c7272e87a57523c529", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::identity.passport.address.street1" + } +} + +export const IDENTITY_PASSPORT_ADDRESS_CITY: VDXFKeyInterface = { + "vdxfid": "iFSLsk21VvWSWLg9a4XFTB3kEN8bLnTB7c", + "indexid": "xLGTLYT6MEj78WZBRkBQRZaHG29cBfjnYu", + "hash160result": "c06884e75232e86de75c6ccbd5605a3352dd3783", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::identity.passport.address.city" + } +} + +export const IDENTITY_PASSPORT_ADDRESS_REGION: VDXFKeyInterface = { + "vdxfid": "iFNoUQhExFEYTgrqgy7x22Q6URM7ek9L3J", + "indexid": "xLCuwD8KoZTD5rjsYen6zQvdW5N8Z4oGqf", + "hash160result": "7b7baa6d0d788f434536aa472c57d9de40678c82", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::identity.passport.address.region" + } +} + +export const IDENTITY_PASSPORT_ADDRESS_POSTCODE: VDXFKeyInterface = { + "vdxfid": "iS4SakGdB4ek1Q1QAitXUwFEk1RVyi3rLY", + "indexid": "xWtZ3Yhi2NsQdZtS2QYgTKmmmfSWrxdFKY", + "hash160result": "4457551bc48db37393f5ec3ec3d0cf6766dcbcf7", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::identity.passport.address.postcode" + } +} + +export const IDENTITY_PASSPORT_ADDRESS_COUNTRY: VDXFKeyInterface = { + "vdxfid": "iB9w9GgcJdGTt3ZuM2pm5qpDBA3UaJdcvj", + "indexid": "xFz3c57h9wV8WDSwCiUv4ELkCp4VNyPHLr", + "hash160result": "dd93bcbecc805e5b1606efafa1ecab6b33e53c54", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::identity.passport.address.country" + } +} + +export const IDENTITY_RESIDENCEPERMIT: VDXFKeyInterface = { + "vdxfid": "i8WZetqKFn98rHRZGvAvPuzPyrJeyUMjfb", + "indexid": "xDLg7hGQ76MoUTJb8bq5NJWw1WKftQg9VL", + "hash160result": "712ef00d9937eb4ade0fd3e627c2df1d99503b37", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::identity.residencepermit" + } +} + +export const IDENTITY_RESIDENCEPERMIT_ORIGINALFRONT: VDXFKeyInterface = { + "vdxfid": "iC5NrmPgKckxBjKv7v9HjUMytm4jRtEBgZ", + "indexid": "xGuVKZpmAvycouCwyboShrtWvR5kNYzWoH", + "hash160result": "639ed2ef9da2f5e75fe63e1ccf83d1b54e68585e", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::identity.residencepermit.originalfront" + } +} + +export const IDENTITY_RESIDENCEPERMIT_ORIGINALBACK: VDXFKeyInterface = { + "vdxfid": "iLTPvrZi8HNALuVmYeAWnSnLdZ5GsAAUcx", + "indexid": "xRHWPeznybapy5NoQKpfkqJsfD6HmQW5eW", + "hash160result": "94d200a22dbdfa7ba47d1970c21eacb65f7543ba", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::identity.residencepermit.originalback" + } +} + +export const IDENTITY_RESIDENCEPERMIT_CROPPEDFRONT: VDXFKeyInterface = { + "vdxfid": "i6T3rairykWA5vVEtQqptjp5RBRhTCmsBS", + "indexid": "xBHAKP9wq4ipi6NGk6Vys8LcSqSiKAMKZU", + "hash160result": "14136815f288a4b6426c7f4ab6b28221dcf0a020", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::identity.residencepermit.croppedfront" + } +} + +export const IDENTITY_RESIDENCEPERMIT_CROPPEDBACK: VDXFKeyInterface = { + "vdxfid": "iHssgpjB2gsusjjLH36N3KqUQqz7JPXumA", + "indexid": "xNhz9dAFt16aVucN8ikX1iN1SW18D7SNDP", + "hash160result": "ce3cae77f2010009817f1e01de52ce8a493cfc9d", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::identity.residencepermit.croppedback" + } +} + +export const IDENTITY_RESIDENCEPERMIT_FACE: VDXFKeyInterface = { + "vdxfid": "iNVvVYKcKuredXKvctn5uQxp3kNXoJrwNb", + "indexid": "xTL2xLkhBE5KFhCxUaSEsoVM5QPYfELeHf", + "hash160result": "4dd17db50d569a63cc892d78850ac9de1d0eaed0", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::identity.residencepermit.face" + } +} + +export const IDENTITY_RESIDENCEPERMIT_IDNUMBER: VDXFKeyInterface = { + "vdxfid": "iMxygBvDFftAnmUCjVLh21etV5v4wt9zdk", + "indexid": "xSo68zMJ6z6qQwMEbAzqzQBRWjw5u6Tm63", + "hash160result": "ab544471e583d6a11245bb971e3ee1ef5ed1d3ca", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::identity.residencepermit.idnumber" + } +} + +export const IDENTITY_RESIDENCEPERMIT_CATEGORY: VDXFKeyInterface = { + "vdxfid": "iGbMb21an69VE6iTH2iRtRFKCEUZPJHTwU", + "indexid": "xMRU3pSfdQN9rGbV8iNaromrDtVaCufAXu", + "hash160result": "ae9031bab1ee600e10aa16ec1d4c13def953e48f", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::identity.residencepermit.category" + } +} + +export const IDENTITY_RESIDENCEPERMIT_EXPIRATIONDATE: VDXFKeyInterface = { + "vdxfid": "iJ48ALemxyMV6DYzeuRMe8Fn78iMZdjSXZ", + "indexid": "xNtEd95rpHa9iPS2Wb5WcWnK8njNXD9HEH", + "hash160result": "d3083b08621d6ff5dc3f7f9cace34f944d7aec9f", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::identity.residencepermit.expirationdate" + } +} + +export const IDENTITY_RESIDENCEPERMIT_ISSUINGCOUNTRY: VDXFKeyInterface = { + "vdxfid": "i7UhTp4gruQwtkC1bi4RxE4wUAsro6n9Ym", + "indexid": "xCJovcVmiDdcWv53TPiavcbUVptsgMKzdL", + "hash160result": "75e37dc8957c8c6765c60962804d446b2de0e82b", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::identity.residencepermit.issuingcountry" + } +} + +export const IDENTITY_RESIDENCEPERMIT_ISSUINGREGION: VDXFKeyInterface = { + "vdxfid": "iERBNWk2tyaGJ2w8P1kM88Mdj5WA9qFzbv", + "indexid": "xKFHqKB7kHnvvCpAEhQW6WtAkjXAymjqXM", + "hash160result": "788165581de37b5473c2f127d387f3d7a8630778", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::identity.residencepermit.issuingregion" + } +} + +export const IDENTITY_RESIDENCEPERMIT_DATEOFBIRTH: VDXFKeyInterface = { + "vdxfid": "iM62dN7LSHWDuetPi6qAewG6bzYwFrcqBN", + "indexid": "xRv96AYRHbitXpmRZnVKdKnddeZxAivvFE", + "hash160result": "e2533190e4822ab51c5b2029039fbb0d431131c1", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::identity.residencepermit.dateofbirth" + } +} + +export const IDENTITY_RESIDENCEPERMIT_ADDRESS: VDXFKeyInterface = { + "vdxfid": "iCA8P2rVs5DjtzQpXEnPJcG4KBs79C9EpL", + "indexid": "xGzEqqHaiPSQXAHrNvSYGznbLqt83gLGV5", + "hash160result": "2c7264a72e1d7937da951620039e48a0c8663e5f", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::identity.residencepermit.address" + } +} + +export const IDENTITY_RESIDENCEPERMIT_ADDRESS_STREET1: VDXFKeyInterface = { + "vdxfid": "iMuY2CbmQpCFzodGBtqxogmTb5dYfNbCJa", + "indexid": "xSjeV12rG8QvcyWJ3aW7n5HzcjeZaxtGwr", + "hash160result": "444cbb0dc6f471ecb2261dc7d6731cd97e272dca", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::identity.residencepermit.address.street1" + } +} + +export const IDENTITY_RESIDENCEPERMIT_ADDRESS_CITY: VDXFKeyInterface = { + "vdxfid": "iRckJ1VkfYazfVHWJuA9iXTth83ZYp8znz", + "indexid": "xWSrkovqWrofHfAYAapJguzRin4aPEqHJK", + "hash160result": "73e22f5d24515103052ab165736a0198a7d4e0f2", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::identity.residencepermit.address.city" + } +} + +export const IDENTITY_RESIDENCEPERMIT_ADDRESS_REGION: VDXFKeyInterface = { + "vdxfid": "iBpH337NTJSLjSxbBWuu2wBLu12k4JVGk4", + "indexid": "xGePVqYTJcf1Mcqd3Ca41Khsvf3kyxtNXH", + "hash160result": "2f7b3040cf60259ee4bf6dfc93a4de42ab4e7d5b", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::identity.residencepermit.address.region" + } +} + +export const IDENTITY_RESIDENCEPERMIT_ADDRESS_POSTCODE: VDXFKeyInterface = { + "vdxfid": "iGKi47jtg6CumKYSUBj57drgLNGzhJY3Gj", + "indexid": "xM9pWvAyXQRaPVRUKsPE62PDN2J1Zp4d6b", + "hash160result": "db85ea63848a6ad2c3a0e82bb29e215c00c2ee8c", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::identity.residencepermit.address.postcode" + } +} + +export const IDENTITY_RESIDENCEPERMIT_ADDRESS_COUNTRY: VDXFKeyInterface = { + "vdxfid": "i8KD9CUn7Su4YT44WhbD8HYA1K425cFCqM", + "indexid": "xD9Kbzurxm7jAcw6NPFN6g4h2y531jRanx", + "hash160result": "75970ae74cd40419dc78ecef7be22c5ee09d1535", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::identity.residencepermit.address.country" + } +} + +export const IDENTITY_RESIDENTCARD: VDXFKeyInterface = { + "vdxfid": "iKkJFFtbxRMJutjoruW47Mc1sCfdGYQrC9", + "indexid": "xQaQi4KgojZyY4cqibAD5k8Ytrge9jwt3u", + "hash160result": "2b737a5733b91d305dcf07d9e75797740da97db2", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::identity.residentcard" + } +} + +export const IDENTITY_RESIDENTCARD_ORIGINALFRONT: VDXFKeyInterface = { + "vdxfid": "iNMJhZ3wie5U2SRF7WSFTpjJo6B6RSTR4t", + "indexid": "xTBRAMV2ZxJ8ecJGyC6QSDFqpkC7KTFMbW", + "hash160result": "e440d2d8bab46633691a12e7bed0ea785bd90ccf", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::identity.residentcard.originalfront" + } +} + +export const IDENTITY_RESIDENTCARD_ORIGINALBACK: VDXFKeyInterface = { + "vdxfid": "i4pAk8J5ec2wn55VattFRr7PyN4J2L13HJ", + "indexid": "x9eHCvjAVvFcQExXSaYQQEdw125Jz84d8u", + "hash160result": "9fa70ca8b49eab8c3e704f78f0e0ae1bc52caf0e", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::identity.residentcard.originalback" + } +} + +export const IDENTITY_RESIDENTCARD_CROPPEDFRONT: VDXFKeyInterface = { + "vdxfid": "iLnx7NDcAWtb9uWicdgSaiwco56TywMh5w", + "indexid": "xRd4aAeh1q7Fn5PkUKLbZ7U9pj7UvU8v2V", + "hash160result": "fa7347c3517552a028890dacaf889a6ead39f6bd", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::identity.residentcard.croppedfront" + } +} + +export const IDENTITY_RESIDENTCARD_CROPPEDBACK: VDXFKeyInterface = { + "vdxfid": "i8WjL22L4UeaCDKZuj8R4Uub6zurTPdaLv", + "indexid": "xDLqnpTQunsEpPCbmQna2sS88evsLJL51v", + "hash160result": "b5134fe72682aa4f0dc645ceb73421dc07644337", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::identity.residentcard.croppedback" + } +} + +export const IDENTITY_RESIDENTCARD_FACE: VDXFKeyInterface = { + "vdxfid": "i6dGShbLY2ppZnXSyfvdtdGFkCxBQd2r9Y", + "indexid": "xBTNuW2RPM3VBxQUqMans1nnmryCFH4rRD", + "hash160result": "25a41b37f64414a2477c5c0d1a139d64ce9b8f22", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::identity.residentcard.face" + } +} + +export const IDENTITY_RESIDENTCARD_IDNUMBER: VDXFKeyInterface = { + "vdxfid": "iKFkbwDcQRXjapZcZAXsaMXjgER9CZbwZx", + "indexid": "xQ5s4jehFjkQCzSeQrC2Yk4GhtSA2GbM4B", + "hash160result": "e30d9a01765325e02ca22f60335d4bdb499917ad", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::identity.residentcard.idnumber" + } +} + +export const IDENTITY_RESIDENTCARD_CATEGORY: VDXFKeyInterface = { + "vdxfid": "i46Fgc8ev9zAkjikjHWreqSXkMRpFr5Lsi", + "indexid": "x8vN9QZjmUCqNubnayB1dDy4n1SqAqg4vn", + "hash160result": "c0039a4929d081eec1d1f5ca3040e19bded3c106", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::identity.residentcard.category" + } +} + +export const IDENTITY_RESIDENTCARD_EXPIRATIONDATE: VDXFKeyInterface = { + "vdxfid": "iBA1oFvDABKqbu9i61AEGy1m5fFHdCWkpy", + "indexid": "xFz8G4MJ1VYWE52jwgpPFMYJ7KGJUd6Y4b", + "hash160result": "0866dd99514f509c9ad4584b3f570515f4c74054", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::identity.residentcard.expirationdate" + } +} + +export const IDENTITY_RESIDENTCARD_ISSUINGCOUNTRY: VDXFKeyInterface = { + "vdxfid": "iHBgD199BSEQWREtiW8dP259DX4qg6KjkM", + "indexid": "xN1nfoaE2kT58b7vaBnnMQbgFB5rWuKCtd", + "hash160result": "ef88ffb14a8b66dacc690351fa9c3d35a8036296", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::identity.residentcard.issuingcountry" + } +} + +export const IDENTITY_RESIDENTCARD_ISSUINGREGION: VDXFKeyInterface = { + "vdxfid": "i6jygVNjzZUFEXVgtzWxXpBYf5rwjXF92J", + "indexid": "xBa69HopqsgurhNikgB7WCi5gjsxbi12z3", + "hash160result": "dc31e031328cfe3697527e046a52cc372687d423", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::identity.residentcard.issuingregion" + } +} + +export const IDENTITY_RESIDENTCARD_DATEOFBIRTH: VDXFKeyInterface = { + "vdxfid": "iQfYTwmTxXzxxyFh6XbY2PQVLVwswRoJL1", + "indexid": "xVVevkCYorDdb98ixDFgzmw2N9xtnBn6M2", + "hash160result": "73e0e5f4af76255bc2a3583ad9a7b1d0241470e8", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::identity.residentcard.dateofbirth" + } +} + +export const IDENTITY_RESIDENTCARD_ADDRESS_STREET1: VDXFKeyInterface = { + "vdxfid": "iJ67qMPN6tyrLXBhbJpKKBZYpkcBzZD8S4", + "indexid": "xNvEJ9pSxDCWxh4jSzUUHa65rQdCviMqur", + "hash160result": "8540d9cb71ca32f4c03caf26a4cffa4d51094da0", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::identity.residentcard.address.street1" + } +} + +export const IDENTITY_RESIDENTCARD_ADDRESS_CITY: VDXFKeyInterface = { + "vdxfid": "iLCQ2n5tKHzKcVBv8of1eYmdWEdEY5vTUN", + "indexid": "xR2WVaWyAcCzEf4wzVKAcwJAXteFUoFSux", + "hash160result": "7990100969a22f4b4ba35613b3994219e74d6db7", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::identity.residentcard.address.city" + } +} + +export const IDENTITY_RESIDENTCARD_ADDRESS_REGION: VDXFKeyInterface = { + "vdxfid": "iPWcAQ6zbC9rKaaWAgrpoHmKs5G5SQCprF", + "indexid": "xULidCY5SWNWwkTY2NWymgHrtjH6QfP6JL", + "hash160result": "ff3f1523bfb1fe501ef10f0036c9f059b64bc7db", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::identity.residentcard.address.region" + } +} + +export const IDENTITY_RESIDENTCARD_ADDRESS_POSTCODE: VDXFKeyInterface = { + "vdxfid": "iG1QGYyp4SkiP7b9ngPwkTGC3DxVG3hB16", + "indexid": "xLqWjMQtukyP1HUBeN46iqnj4syW4eat4U", + "hash160result": "f345aa72196b006e2200bd08ed0ea165806c7889", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::identity.residentcard.address.postcode" + } +} + +export const IDENTITY_RESIDENTCARD_ADDRESS_COUNTRY: VDXFKeyInterface = { + "vdxfid": "i4wzngZfZb2QBnjr2TjtoMoMF9roSqQkho", + "indexid": "x9n7FUzkQuF4oxcst9Q3mkKtGospNqDjEQ", + "hash160result": "dd2a94da0a94115ed04de616b7d0ea1b19312a10", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::identity.residentcard.address.country" + } +} + +export const IDENTITY_IDCARD: VDXFKeyInterface = { + "vdxfid": "iK7FrcxNvsej84qZjYR73iGgEV96sGKwTU", + "indexid": "xPwNKRPTnBsPkEibbE5G26oDG9A7j4JSm7", + "hash160result": "4f2b2c852e4cfa5a640988af78c4d02243467cab", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::identity.idcard" + } +} + +export const IDENTITY_IDCARD_ORIGINALFRONT: VDXFKeyInterface = { + "vdxfid": "iCnLNq42DxhuK84Nes4UGjFFUuNsGGpuBZ", + "indexid": "xHcSqdV75GvZwHwQWYidF7mnWZPtATN7Ky", + "hash160result": "9f5f63641e6e935628d7602e92814311ea631766", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::identity.idcard.originalfront" + } +} + +export const IDENTITY_IDCARD_ORIGINALBACK: VDXFKeyInterface = { + "vdxfid": "iJyfvwrUeTRiGxiYw6oJZ3uALsuBt7QTyy", + "indexid": "xPonPkHZVmeNu8bannTTXSRhNXvCpAD3MB", + "hash160result": "df3a44e11ad54673eff910c1320d9f50100b0daa", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::identity.idcard.originalback" + } +} + +export const IDENTITY_IDCARD_CROPPEDFRONT: VDXFKeyInterface = { + "vdxfid": "iFDp8jWwybweGStGQnYxwhbi8eiucZ29sr", + "indexid": "xL3vbXx2pvAJtcmJGUD7v68FAJjvZmrsga", + "hash160result": "b10845ae9b29f3ed25f33f091398fd0a1536d980", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::identity.idcard.croppedfront" + } +} + +export const IDENTITY_IDCARD_CROPPEDBACK: VDXFKeyInterface = { + "vdxfid": "i8GpXrygUPpQYVwcoZ7JVRB1xB46xZsMuG", + "indexid": "xD6vzfQmKi35AfpefEmTTohYyq57sdLVxr", + "hash160result": "84c05d2d84ab69db2834df22602f34445ae9a134", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::identity.idcard.croppedback" + } +} + +export const IDENTITY_IDCARD_FACE: VDXFKeyInterface = { + "vdxfid": "i8sfiwALhk4FtSaWSnBWYwKnWN3G7m3jyU", + "indexid": "xDhnBjbRZ4GvWcTYJTqfXKrKY24GxBC5cg", + "hash160result": "4afc5fda25a15a4627b8426f40594ff2e11d393b", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::identity.idcard.face" + } +} + +export const IDENTITY_IDCARD_IDNUMBER: VDXFKeyInterface = { + "vdxfid": "iBEJB1xD1mpR4kYQbYieW3hNFpe5QmQ6qA", + "indexid": "xG4QdpPHs635gvRSTENoUSDuHUf6JB2izs", + "hash160result": "0af18c033e6ad395bdfb5fbdbf5144d63c1d1055", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::identity.idcard.idnumber" + } +} + +export const IDENTITY_IDCARD_CATEGORY: VDXFKeyInterface = { + "vdxfid": "i4HCpvV1NJd4Ka8atCtDkXs4XLAkrmtKib", + "indexid": "x97KHiv6Dcqiwk1cjtYNivPbYzBmg48ama", + "hash160result": "68b49fa5bf2ed00672c881c15167fee2c304d408", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::identity.idcard.category" + } +} + +export const IDENTITY_IDCARD_EXPIRATIONDATE: VDXFKeyInterface = { + "vdxfid": "iNTbsfTmeAm7KUFehtCq3RH1JgbUdTJwCt", + "indexid": "xTHiLTtrVUymwe8gZZrz1ooYLLcVZC5A4n", + "hash160result": "f4b807e32848d5a40815e2aa19cb219c64ae3dd0", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::identity.idcard.expirationdate" + } +} + +export const IDENTITY_IDCARD_ISSUINGCOUNTRY: VDXFKeyInterface = { + "vdxfid": "iJ5qVRWTHerkVreE9UrSfKyphD3XB9s8FA", + "indexid": "xNuwxDwY8y5R82XG1AWbdiWMis4Y3BXDg7", + "hash160result": "2cc5492966de5135e638de253b497cccb8643fa0", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::identity.idcard.issuingcountry" + } +} + +export const IDENTITY_IDCARD_ISSUINGREGION: VDXFKeyInterface = { + "vdxfid": "i8dHTbZ62Bth8NwkxasnKFpvX4EZYuBun4", + "indexid": "xDTPvPzAsW7MkYpnpGXwHeMTYiFaMyp6FD", + "hash160result": "f42f7b71bb43c590b9063755754bf2d534b58038", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::identity.idcard.issuingregion" + } +} + +export const IDENTITY_IDCARD_DATEOFBIRTH: VDXFKeyInterface = { + "vdxfid": "iGcwhC6znG63pb6jqsRnrtDjXV4aXXsub2", + "indexid": "xMT49zY5daJiSkymhZ5wqGkGZ95bMGYJ9r", + "hash160result": "4d0c72c3369a0ac64711e58ae1b10785f1363190", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::identity.idcard.dateofbirth" + } +} + +export const IDENTITY_IDCARD_ADDRESS_STREET1: VDXFKeyInterface = { + "vdxfid": "i6jMXjNE9qioZ2dFricFnEBEQEWK5Kg3PS", + "indexid": "xBZTzXoK19wUBCWHiQGQkchmRtXKugcKWw", + "hash160result": "2cee0d13a2fdeaac83d052ad27610da8bf59b623", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::identity.idcard.address.street1" + } +} + +export const IDENTITY_IDCARD_ADDRESS_CITY: VDXFKeyInterface = { + "vdxfid": "i3viAeqayk3KDk5tQpYcz6gFs1ayW5vBma", + "indexid": "x8kpdTGfq4FyquxvGWCmxVCntfbzM8iAVb", + "hash160result": "a10bfcd1cfd12d466a276339072d2f2a7ec6f304", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::identity.idcard.address.city" + } +} + +export const IDENTITY_IDCARD_ADDRESS_REGION: VDXFKeyInterface = { + "vdxfid": "iEHvf3XCFacMihTQPVXxNeo6hBCqggDFie", + "indexid": "xK837qxH6tq2LsLSFBC7M3KdiqDrYBNMK7", + "hash160result": "55af249b3ceb591709c693017e5b7b1cb131a876", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::identity.idcard.address.region" + } +} + +export const IDENTITY_IDCARD_ADDRESS_POSTCODE: VDXFKeyInterface = { + "vdxfid": "i3yAnt6zdceYxbCBnLwxn2tNdM4BnPkzhT", + "indexid": "x8oHFgY5UvsDam5De2c7kRQuf15ChzdWFA", + "hash160result": "acd086baf0863cff86fc56ec0fbb16dd18d56a05", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::identity.idcard.address.postcode" + } +} + +export const IDENTITY_IDCARD_ADDRESS_COUNTRY: VDXFKeyInterface = { + "vdxfid": "iA6KVD2C4QJAyKfCS3XfQV8AxmpR9R3XG5", + "indexid": "xEvRx1TGuiWqbVYEHjBpNsehzRqS2fp4qg", + "hash160result": "bab14b514d91d7daa39175c90e29a956dec19548", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::identity.idcard.address.country" + } +} + +export const IDENTITY_VISA: VDXFKeyInterface = { + "vdxfid": "iDCwZf84AhbJkm4zKZP7Le8h8ukJS9FySA", + "indexid": "xJ342TZ921oyNvx2BF3GK2fEAZmKGeUQUd", + "hash160result": "57faa6b546ac92c71022178b8c5e9fbae9bebe6a", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::identity.visa" + } +} + +export const IDENTITY_VISA_ORIGINALFRONT: VDXFKeyInterface = { + "vdxfid": "iGAgzyLDVs5vYFLRgXVnkQpDRKy9Zh1TiV", + "indexid": "xLzoTmmJMBJbARDTYD9wioLkSyzARsVQWr", + "hash160result": "755da3361216260b786ba78fbe68800557223a8b", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::identity.visa.originalfront" + } +} + +export const IDENTITY_VISA_ORIGINALBACK: VDXFKeyInterface = { + "vdxfid": "i3becgcmf85RiY2PAxsp3fbuGKG8Qc73t1", + "indexid": "x8Rm5V3rWSJ6LhuR2eXy248SHyH9Jjue4S", + "hash160result": "e71909c77e2e0361764d22b81f4f53085fe85801", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::identity.visa.originalback" + } +} + +export const IDENTITY_VISA_CROPPEDFRONT: VDXFKeyInterface = { + "vdxfid": "iAapfFQMAQy7USdjRwqzAZ2nWhRMSiQMmV", + "indexid": "xFQw83qS1jBn6cWmHdW98wZKYMSNHsb2wy", + "hash160result": "56ed30f8daf83e3b09eee57517be45b6b8c1f94d", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::identity.visa.croppedfront" + } +} + +export const IDENTITY_VISA_CROPPEDBACK: VDXFKeyInterface = { + "vdxfid": "i3quMdmv3vAQDBA6nzM8fTiFtqJrw7tcnf", + "indexid": "x8g1pSCzuEP4qM38eg1HdrEnvVKsoXBZ7R", + "hash160result": "1d8106821498549cebc0af6f8d120b9933090b04", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::identity.visa.croppedback" + } +} + +export const IDENTITY_VISA_FACE: VDXFKeyInterface = { + "vdxfid": "iAqxnB58655ZcRLAUm2Utib2rguRXT9wZM", + "indexid": "xFg5EyWCwPJEEbDCLSgds77ZtLvSRpw2k9", + "hash160result": "59564e826c8342a2b721708f6a83c9761dc6d650", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::identity.visa.face" + } +} + +export const IDENTITY_VISA_IDNUMBER: VDXFKeyInterface = { + "vdxfid": "iQ5LfUtuggDyqbePUB9iWLgxYj7tvDm2VE", + "indexid": "xUuT8HKzXzSeTmXRKrosUjDVaP8upm7rqg", + "hash160result": "77ae761bf6bf7922ff8e47b53bd88107be15f8e1", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::identity.visa.idnumber" + } +} + +export const IDENTITY_VISA_CATEGORY: VDXFKeyInterface = { + "vdxfid": "iH4nhrNsZKK6bEkgLDu17fBPR5dnVgitiQ", + "indexid": "xMtuAeoxQdXmDQdiBuZA63hvSjeoT3wsnv", + "hash160result": "8052162609b4da20bb5932ead5b6deedbb861495", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::identity.visa.category" + } +} + +export const IDENTITY_VISA_EXPIRATIONDATE: VDXFKeyInterface = { + "vdxfid": "iNW2k7p7hVK2GCc7m1k4mihqh8jd94Dmnh", + "indexid": "xTL9CvFCYoXgtNV9chQDk7ENinkdzPUodD", + "hash160result": "5eaa0aef6ed6d27ee4909bc6ce8619c60346b3d0", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::identity.visa.expirationdate" + } +} + +export const IDENTITY_VISA_ISSUINGCOUNTRY: VDXFKeyInterface = { + "vdxfid": "i5vDfPKMfCRPXVRhfumjWPEvBFhNMVjtGK", + "indexid": "xAkL8BkSWWe49fJjXbRtUmmTCuiPJGBZ2c", + "hash160result": "ebf49255193b4ffbb3a0487106a4df98833bcc1a", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::identity.visa.issuingcountry" + } +} + +export const IDENTITY_VISA_ISSUINGREGION: VDXFKeyInterface = { + "vdxfid": "iPRc9Ns6LadQNYU7DqSNyx7LW8W9dPKDjC", + "indexid": "xUFicBJBBtr4ziM95X6XxLdsXnXAYQ1XFN", + "hash160result": "a1217c6e44b1f47faf9d59378206009d8433d5da", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::identity.visa.issuingregion" + } +} + +export const IDENTITY_VISA_DATEOFBIRTH: VDXFKeyInterface = { + "vdxfid": "i55bTsxLkCTmE6VvppvG8doYnmxuHhec65", + "indexid": "x9uhvgPRbWgRrGNxgWaR72L5pRyvA4vVWm", + "hash160result": "ed824bbfd195e63d6d5151a07eda49eba60c9a11", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::identity.visa.dateofbirth" + } +} + +export const IDENTITY_VISA_ADDRESS_STREET1: VDXFKeyInterface = { + "vdxfid": "iMzWxFVzJHbQm5YWv9c1eujvrUrPHAGVAc", + "indexid": "xSpdR3w59bp5PFRYmqGAdJGTt8sQ8o4mpu", + "hash160result": "05992eb838a4f562b6b7e0ff84bb05cdac571ecb", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::identity.visa.address.street1" + } +} + +export const IDENTITY_VISA_ADDRESS_CITY: VDXFKeyInterface = { + "vdxfid": "i8YXgZ7doRhidT5phX6qyRnttV6hZiyWTm", + "indexid": "xDNe9MYiejvPFcxrZCkzwpKRv97iS3TQjA", + "hash160result": "04959daab853c797bbbcb9c5ead7376e4a809a37", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::identity.visa.address.city" + } +} + +export const IDENTITY_VISA_ADDRESS_REGION: VDXFKeyInterface = { + "vdxfid": "i6YkTDEi1M1mzuTyzww8hNoksJFpev17Fu", + "indexid": "xBNrv1fnrfESd5M1rdbHfmLHtxGqUoeALR", + "hash160result": "3a47a53e8717444b5d31e8618049daa8cde8b421", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::identity.visa.address.region" + } +} + +export const IDENTITY_VISA_ADDRESS_POSTCODE: VDXFKeyInterface = { + "vdxfid": "iBJDLHSLB4cHvaeXazFp25Be3V9yRWmcoK", + "indexid": "xG8Ko5sR2NpxYkXZSfuxzTiB59AzMUATiw", + "hash160result": "dd0d87e3163157402aa16d2017a3ea06d6bccd55", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::identity.visa.address.postcode" + } +} + +export const IDENTITY_VISA_ADDRESS_COUNTRY: VDXFKeyInterface = { + "vdxfid": "iQ9Z1PZMMp49rtDuGQSjfEZn3xACfxLAYa", + "indexid": "xUyfUBzSD8GpV46w866tdd6K5cBDbMPuNo", + "hash160result": "c45655a6924c0b377e9182869dc780df690dc4e2", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::identity.visa.address.country" + } +} + +export const IDENTITY_PERSONALDETAILS: VDXFKeyInterface = { + "vdxfid": "i8SSgM1z7XVoCtoP9CCsMms3zCndaNjtCe", + "indexid": "xDGZ99T4xqiTq4gQzss2LAPb1roeUyLwkU", + "hash160result": "a8fbe89451c1d0a77b336ccf6b0fb7601dd47336", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::identity.personaldetails" + } +} + +export const IDENTITY_CONTACTDETAILS: VDXFKeyInterface = { + "vdxfid": "iRLT8V9NN178CvZQusJSHuyuFC2fD2QmE3", + "indexid": "xWAZbHaTDKKnq6SSmYxbGJWSGr3g1GRDYH", + "hash160result": "b9185ad980909708754a484bf11edc9febd8cbef", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::identity.contactdetails" + } +} + +export const IDENTITY_LOCATION: VDXFKeyInterface = { + "vdxfid": "iGmiLZ7J6GjxjZ4rkSMsDzyyvWtmMBjnbo", + "indexid": "xMbpoMYNwaxdMiwtc822CPWWxAunLDE1BS", + "hash160result": "15ea60d9ddde976095b0c79ceecef7b034cfd991", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::identity.location" + } +} + +export const IDENTITY_BANKINGDETAILS: VDXFKeyInterface = { + "vdxfid": "i8DUrZJJRjNQMJNeJ3Ti6pbpKPJ55LECyJ", + "indexid": "xD3bKMjPH3b4yUFg9j7s5D8MM3K612HEir", + "hash160result": "a7e5de6ac208f110d0509cffeb916b8dd03c0034", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::identity.bankingdetails" + } +} + +export const IDENTITY_DOCUMENTS: VDXFKeyInterface = { + "vdxfid": "iCm3ERZoUw2ze1P11QyRUtvhKYovCWFXbT", + "indexid": "xHb9hDztLFFfGBG2s6daTHTEMCpw3tcbVJ", + "hash160result": "ee9f8d5ba7366983cf9b9d3e5e8ac50898a9d865", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::identity.documents" + } +} + +export const IDENTITY_BANKACCOUNT: VDXFKeyInterface = { + "vdxfid": "iN4AgB4KEN1C3TfZnYDFUhxn37PdcrZvxT", + "indexid": "xStH8yVQ5gDrfdYbeDsQT6VK4mQeYDjcFm", + "hash160result": "122bf0739d7d1def003656a63c443efb6c14cfcb", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::identity.bankaccount" + } +} + +export const IDENTITY_BANKINGDETAILS_CURRENCY: VDXFKeyInterface = { + "vdxfid": "i5k8pb9FHf5VZJKki6him1WMBkpyhe56BY", + "indexid": "xAaFHPaL8yJABUCnZnMsjQ2tDQqzfUkZRm", + "hash160result": "cc655f9f104ad6c25cc65407121fa7ac1208e418", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::identity.bankingdetails.currency" + } +} + +export const IDENTITY_BANKINGDETAILS_COUNTRY: VDXFKeyInterface = { + "vdxfid": "iHYqZF4Asa4erZR9kJ5G5nWRNGWdiS8vBh", + "indexid": "xNNx23VFitHKUjJBbyjR4B2xPvXebL5g4h", + "hash160result": "cf7870c11608bf6e58890fbfc18ffe0db98d629a", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::identity.bankingdetails.country" + } +} + +export const IDENTITY_BANKINGDETAILS_STREET1: VDXFKeyInterface = { + "vdxfid": "iRhANjQk2G3aFXiaGtG68kZjdYr2iVXQJJ", + "indexid": "xWXGqXqpsaGEshbc8ZvF796GfCs3bDhrgC", + "hash160result": "bd420c73e6bba2e48542cddf188c23b8c098b6f3", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::identity.bankingdetails.street1" + } +} + +export const IDENTITY_BANKINGDETAILS_STREET2: VDXFKeyInterface = { + "vdxfid": "iFWtcLUKAECLrREJr6mxtHM9xPUocxmTSY", + "indexid": "xLM158uQ1YR1Ub7LhnS7rfsgz3VpTpBcCu", + "hash160result": "7f1a53da2e265bab3230d9eec1ed0f36d7041484", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::identity.bankingdetails.street2" + } +} + +export const IDENTITY_BANKINGDETAILS_CITY: VDXFKeyInterface = { + "vdxfid": "iQxBEB8sXNez25HJCzvnTWtWqXUkEVAuo8", + "indexid": "xVnHgyZxNgseeFAL4gawRuR3sBVm7nyQqt", + "hash160result": "5878bb5b9371344acb1b679316e0e087046c95eb", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::identity.bankingdetails.city" + } +} + +export const IDENTITY_BANKINGDETAILS_REGION: VDXFKeyInterface = { + "vdxfid": "i4HJ5yrzBFEwjiYgzptMcrBsCeBjPYQJFX", + "indexid": "x97QYnJ52ZTcMtRirWYWbEiQEJCkKnxArM", + "hash160result": "7bf3a5ee05846c54bd19032e6ee9069cbc68d808", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::identity.bankingdetails.region" + } +} + +export const IDENTITY_BANKINGDETAILS_POSTALCODE: VDXFKeyInterface = { + "vdxfid": "iFVaE922Bzrro6rb87d9En2t2AAGx7EivG", + "indexid": "xLKggwT73K5XRGjcyoHJDAZR3pBHqz4Utt", + "hash160result": "ebd93a0f4fb8db6fb0cb8d397c45b41a0142d483", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::identity.bankingdetails.postalcode" + } +} + +export const IDENTITY_BANKINGDETAILS_TAXNUMBER: VDXFKeyInterface = { + "vdxfid": "i6Gbi3EkYrbREumkLmHUedbzrisXkRzwKY", + "indexid": "xB6iAqfqQAp5s5enCSwdd28XtNtYcHgrDb", + "hash160result": "bcc691f5d53f99e196b291ea2a00a9805ff4a61e", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::identity.bankingdetails.taxnumber" + } +} + +export const IDENTITY_BANKINGDETAILS_TAXCOUNTRY: VDXFKeyInterface = { + "vdxfid": "iMJzAfPjqvWJdYyoWTX79cSjd51HbVc7wC", + "indexid": "xS96dTpphEiyFirqN9BG7zyGej2JTACDB1", + "hash160result": "e19f920e684c7d906dd8c85d72a5d5f0cd6ba4c3", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::identity.bankingdetails.taxcountry" + } +} + +export const IDENTITY_BANKINGDETAILS_FIRSTNAME: VDXFKeyInterface = { + "vdxfid": "iGAomW7jtsy7zRaoMFU48KvrHahHwdjzi7", + "indexid": "xLzvEJYpkCBncbTqCw8D6iTPKEiJpW3beK", + "hash160result": "d33bd09ba3184bf0e3fa00ad62e92a7a99c83f8b", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::identity.bankingdetails.firstname" + } +} + +export const IDENTITY_BANKINGDETAILS_LASTNAME: VDXFKeyInterface = { + "vdxfid": "iMrvbLJnZawGsdFshtrHM3QKa4pDPbRk3L", + "indexid": "xSh348jsQu9wVo8uZaWSKRvrbiqED1eny3", + "hash160result": "4a0d68f2cafc3cbe827a91fd5038c65878bfaec9", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::identity.bankingdetails.lastname" + } +} + +export const IDENTITY_BANKINGDETAILS_PHONENUMBER: VDXFKeyInterface = { + "vdxfid": "i9jKPi8ubg5fx3BBmZdiyobJxNgzcmV9et", + "indexid": "xEZRrWZzSzJLaD4DdFHsxC7qz2i1YejHqk", + "hash160result": "b092c8f73031298d26b919f4b398fa9b66f19c44", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::identity.bankingdetails.phonenumber" + } +} + +export const IDENTITY_BANKINGDETAILS_NUMBER: VDXFKeyInterface = { + "vdxfid": "iKGaF7fZ6yAvwJyxcmpuas2Hn9PZPF99yf", + "indexid": "xQ6ghv6dxHPbZUrzUTV4ZFYpooQaFZG1aa", + "hash160result": "fcceea7c24223218bc9313e8176daea6155e3fad", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::identity.bankingdetails.number" + } +} + +export const IDENTITY_BANKINGDETAILS_TYPE: VDXFKeyInterface = { + "vdxfid": "iNkzXo7BBcUvCBH8somKyFtAFsR3mmmYuG", + "indexid": "xTb6zbYG2vhapMAAjVRUweQhHXS4csH9eB", + "hash160result": "26dcd354b4b2bd8b939af29fc5ea57a082aa87d3", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::identity.bankingdetails.type" + } +} + +export const IDENTITY_BANKINGDETAILS_SORTCODE: VDXFKeyInterface = { + "vdxfid": "i8v2y1beTivG8Nyi6Td3VFTc2ExFQJT8pC", + "indexid": "xDk9Rp2jK38vkYrjx9HCTdz93tyGLCaa3E", + "hash160result": "27df54160c8a8a962dd455004c8afac060aeab3b", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::identity.bankingdetails.sortcode" + } +} + +export const IDENTITY_DOCUMENTS_PASSPORT: VDXFKeyInterface = { + "vdxfid": "iJHkDyp8dPnNdrh7P9fzow4gTshpbznkSK", + "indexid": "xP7rgnFDUi13G2a9EqL9nKbDVXiqVHVtyg", + "hash160result": "456f1956c77f7ff59d98dd57030d7ed22afd7fa2", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::identity.documents.passport" + } +} + +export const IDENTITY_RESIDENCECARD: VDXFKeyInterface = { + "vdxfid": "iQerHJHjqVT32hU1ZUyVYKQEkavs4xFtHo", + "indexid": "xVUxk6ipgofhesM3RAdeWhvmnEwsywApa2", + "hash160result": "0b2227f2bb574fe3cbcc683eecfc4d3bff884ee8", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::identity.residencecard" + } +} + +export const IDENTITY_ATTESTOR: VDXFKeyInterface = { + "vdxfid": "iFNc5DG22Btm69wBDDXatvSPLxzJq53QBa", + "indexid": "xLCiY1h6sW7RiKpD4uBjsJxvNd1Kiej8tW", + "hash160result": "e5d18dab811f87643c1e7a63627172331be38282", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::identity.attestor" + } +} + +export const IDENTITY_ATTESTATION_RECIPIENT: VDXFKeyInterface = { + "vdxfid": "iAkd3VBhYQ3MK6PUCtfhXrLVNbqSghxxpn", + "indexid": "xFajWHcnPiG1wGGW4aKrWEs2QFrTbwP7wd", + "hash160result": "71b7cbbfc8be868f6d9f6c481c420b002438d44f", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::identity.attestation.recipient" + } +} + diff --git a/src/vdxf/index.ts b/src/vdxf/index.ts index 807837f..92953fe 100644 --- a/src/vdxf/index.ts +++ b/src/vdxf/index.ts @@ -11,7 +11,9 @@ import { BN } from "bn.js"; import { BigNumber } from "../utils/types/BigNumber"; export * from './keys' export * from './scopes' - +export * from './keymap' +export * from './identitydatakeys' +export * from './vdxfdatakeys' export interface VDXFObjectInterface { vdxfkey: string; toString: () => string; @@ -65,7 +67,7 @@ export class VDXFObject implements VDXFObjectInterface { toDataBuffer() { return Buffer.alloc(0); } - + fromDataBuffer(buffer: Buffer, offset: number = 0) { return offset; } @@ -115,10 +117,8 @@ export class VDXFObject implements VDXFObjectInterface { } writer.writeVarInt(new BN(this.version, 10)); - - if (dataLength) { - writer.writeVarSlice(this.toDataBuffer()); - } + + writer.writeVarSlice(this.toDataBuffer()); return writer.buffer; } @@ -167,6 +167,42 @@ export class BufferDataVdxfObject extends VDXFObject { } } +export class VDXFData extends VDXFObject { + data: Buffer + + constructor( + data: Buffer = Buffer.from(""), + vdxfkey: string = "" + ) { + super(vdxfkey); + this.data = data; + } + + dataByteLength(): number { + return this.data.length; + } + + toDataBuffer(): Buffer { + return this.data; + } + + fromDataBuffer(buffer: Buffer, offset?: number): number { + const reader = new bufferutils.BufferReader(buffer, offset); + + this.data = reader.readVarSlice(); + + return reader.offset; + } + + toJson() { + return { + data: this.data.toString("hex"), + vdxfkey: this.vdxfkey, + }; + } + + } + export class Utf8DataVdxfObject extends BufferDataVdxfObject { constructor(data: string = "", vdxfkey: string = "") { super(data, vdxfkey, "utf-8"); @@ -226,7 +262,7 @@ export class Utf8OrBase58Object extends VDXFObject { } else { this.data = reader.readVarSlice().toString('utf-8') } - + return reader.offset } @@ -281,4 +317,4 @@ export class VerusIDSignature extends VDXFObject { serializekey: this.serializekey }; } -} \ No newline at end of file +} diff --git a/src/vdxf/keymap.ts b/src/vdxf/keymap.ts new file mode 100644 index 0000000..c18d618 --- /dev/null +++ b/src/vdxf/keymap.ts @@ -0,0 +1,13 @@ +import * as keylist from './keys'; +import * as attestationData from '../utils/IdentityData'; +import { VDXFKeyInterface } from './keys'; + +export const keymap = Object.keys(keylist) + .reduce((obj: { [key: string]: VDXFKeyInterface }, item) => + { obj[keylist[item].vdxfid] = keylist[item]; return obj }, {}); + +export const attestationDataKeys = Object.keys(attestationData) + .reduce((obj: { [key: string]: VDXFKeyInterface }, item) => + { obj[attestationData[item].vdxfid] = attestationData[item]; return obj }, {}); + +export const IdentityVdxfidMap = attestationData.IdentityVdxfidMap; \ No newline at end of file diff --git a/src/vdxf/keys.ts b/src/vdxf/keys.ts index 2dbcaab..adb7918 100644 --- a/src/vdxf/keys.ts +++ b/src/vdxf/keys.ts @@ -5,6 +5,10 @@ export interface VDXFKeyInterface { name: string; namespace: string; }; + bounddata?: { + vdxfkey: string; + } + indexid?: string; } export const VERUSPAY_INVOICE_VDXF_KEY: VDXFKeyInterface = { @@ -97,6 +101,25 @@ export const LOGIN_CONSENT_WEBHOOK_VDXF_KEY: VDXFKeyInterface = { }, }; +export const LOGIN_CONSENT_ATTESTATION_WEBHOOK_VDXF_KEY: VDXFKeyInterface = { + vdxfid: "iEiQe3C68gKvAevZWAx6MLmoSR64hVqfMb", + hash160result: "6759ec3006891e89422e59fb613ab2653389497b", + qualifiedname: { + namespace: "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + name: "vrsc::identity.attestation.webhook", + }, +}; + +export const LOGIN_CONSENT_PERSONALINFO_WEBHOOK_VDXF_KEY: VDXFKeyInterface ={ + vdxfid: "i8RW9fcZHh1oaAqR2fWWLCB99mfNW6Q2mQ", + indexid: "xDFccU3e91EUCLiStMAfJahgBRgPHfYq74", + hash160result: "fe40712687cd6f9f288e535ced75b653624f4636", + qualifiedname: { + namespace: "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + name: "vrsc::identity.identitydata.webhook" + } +} + export const LOGIN_CONSENT_CONTEXT_VDXF_KEY: VDXFKeyInterface = { vdxfid: "iBMochrKPSQfua5yZYWyd6p4QnREakqU44", hash160result: "3b605d4ace1e19dd0bddb2eef63171b1879a7b56", @@ -332,14 +355,152 @@ export const SIGNED_SESSION_OBJECT: VDXFKeyInterface = { }; export const CURRENCY_ADDRESS: VDXFKeyInterface = { - "vdxfid":"iBy2s9cQL9RadMVPjog6bbSV5ityBxTuNR", - "hash160result":"4fb4c86b8ce18e596e28f62bc9a78f43d738255d", + "vdxfid": "iBy2s9cQL9RadMVPjog6bbSV5ityBxTuNR", + "hash160result": "4fb4c86b8ce18e596e28f62bc9a78f43d738255d", "qualifiedname": { - "namespace":"i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", - "name":"vrsc::currency.address" + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::currency.address" } } +export const ATTESTATION_PROVISION_URL: VDXFKeyInterface = { + "vdxfid": "iD9J9aQ6vsRYvqZbBs9QpKmCcgUynee7mT", + "indexid": "xHyQcNqBnBeDZ1Sd3YoZniHjeLVzgLK5ka", + "hash160result": "e1059d2a03500749f86ed9c49137b86de6430e6a", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::attestation.provision.url" + } +}; + +export const ATTESTATION_PROVISION_TYPE: VDXFKeyInterface = { + "vdxfid": "i7VGPAp3q2h4U4njZ556b9eG3Jts2gmzHn", + "indexid": "xCKNqyF8gLuj6EfmQkjFZYAo4xuswrB6X9", + "hash160result": "5f922c9d09e0160b7c3bc5f31588dfc11b5b042c", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::attestation.provision.type" + } +}; + +export const ATTESTATION_PROVISION_OBJECT: VDXFKeyInterface = { + "vdxfid": "iA4mSmR35HNwXogTtdGasrmxHzX9zFfDqM", + "indexid": "xEtsuZr7vbbc9yZVkJvjrFJVKeYArDTHtu", + "hash160result": "568af36801cfae2e1290ecef7a60c7ae0c984a48", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::attestation.provision.object" + } +} + + +export const ATTESTATION_VIEW_REQUEST: VDXFKeyInterface = { + "vdxfid": "i5R9p3V1sxZ9p1NDV7nPkz1wvmQTUvuByY", + "hash160result": "872923256c56f6bda8256c5bb6a4c98d85f44c15", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::attestation.view.request" + } +}; + +export const ATTESTATION_VIEW_RESPONSE: VDXFKeyInterface = { + "vdxfid": "i5R9p3V1sxZ9p1NDV7nPkz1wvmQTUvuByY", + "hash160result": "872923256c56f6bda8256c5bb6a4c98d85f44c15", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::attestation.view.response" + } +}; + +export const ATTESTATION_ID: VDXFKeyInterface = { + "vdxfid": "i87ZC3B5EFiKtLW9fCUkw9yoMVmh2i2bZ3", + "hash160result": "f540229f88da9e3a9f40f99ce5a22afe765ce132", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::attestation.id" + } +}; + +export const ATTESTATION_NAME: VDXFKeyInterface = { + "vdxfid": "iEEjVkvM9Niz4u2WCr6QQzx1zpVSvDFub1", + "hash160result": "8a00bdd77505b345ed85d7292459b61457a10d76", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::attestation.name" + } +}; + +export const ATTESTATION_TYPE: VDXFKeyInterface = { + "vdxfid": "iAJUD5mgT6MHz8ymF49XUtBDRS7uvYqNWZ", + "indexid": "xF8aftCmJQZxcJro6jogTGhkT68vqfCDCm", + "hash160result": "e56544849c038b7cfadb0a1074ac51df9207e24a", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::attestation.type" + } +}; + +export const ATTESTATION_VIEW_REQUEST_KEY: VDXFKeyInterface = { + "vdxfid": "i8iRyLrnapw29BTaHYtu7C3wWPtbjKvEJp", + "indexid": "xDYYS9HsS99gmMLc9EZ45aaUY3ucaC7FDD", + "hash160result": "fa51ed48a3b250818d2fb1efcdf6275fd2e47939", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::attestation.view.request.key" + } +}; + +export const ATTESTATION_VIEW_REQUEST_NAME: VDXFKeyInterface = { + "vdxfid": "i6psJBVkM3yivumyxuhmAwmMYixiFRD9LT", + "indexid": "xBeykyvqCNCPZ5f1pbMv9LHtaNyjDs5X2m", + "hash160result": "8bb63c962ccec2eced99eb15f958b2d03247c124", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::attestation.view.request.name" + } +}; + +export const ATTESTATION_VIEW_REQUEST_ATTESTOR: VDXFKeyInterface = { + "vdxfid": "iHuiKHNSLJd6xeUCN8etjnTcGgzhDp9Zug", + "indexid": "xNjpn5oXBcqmapMEDpK3iAz9JM1i7g8cDX", + "hash160result": "1bdced61a4c500114659b9f15759eea89c3e559e", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::attestation.view.request.attestor" + } +}; + +export const ATTESTATION_VIEW_REQUEST_ID: VDXFKeyInterface = { + "vdxfid": "iSoJNm8wz9Jtv69YvReNyRSzBr8KJSXTym", + "indexid": "xXdQqZa2qTXZYG2an7JXwoyXDW9L9NjTYS", + "hash160result": "70cbf4f61e3d585bcaac692fa9443a9890e5d7ff", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::attestation.view.request.id" + } +}; + +export const PROFILE_DATA_VIEW_REQUEST: VDXFKeyInterface = { + "vdxfid": "iEocxePWah2zp5Hn4ujeoQpc4UVYeJeQ2g", + "indexid": "xKdjRSpbS1FfSFAovbPomoM968WZVsmW1E", + "hash160result": "b1778ef367dbf00e7b9ad15eea2ef17490e6457c", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::profile.data.view.request" + } +} + +export const IDENTITY_SIGNDATA_REQUEST: VDXFKeyInterface = { + "vdxfid": "i8pWCPRLoGD9MgL7HM13xo5Bhr9TsXjGxs", + "indexid": "xDecfBrReaRoyrD992fCwBbijWAUi4yjUN", + "hash160result": "0785689a95a2a08dd2e0efd60b71237e97ea9f3a", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::identity.signdata.request" + } +} + +// DATA TYPES export const DATA_TYPE_STRING: VDXFKeyInterface = { "vdxfid": "iK7a5JNJnbeuYWVHCDRpJosj3irGJ5Qa8c", @@ -348,4 +509,5 @@ export const DATA_TYPE_STRING: VDXFKeyInterface = "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", "name": "vrsc::data.type.string" }, -}; \ No newline at end of file +}; + diff --git a/src/vdxf/scopes.ts b/src/vdxf/scopes.ts index 49a8335..13fd1dd 100644 --- a/src/vdxf/scopes.ts +++ b/src/vdxf/scopes.ts @@ -16,4 +16,34 @@ export const IDENTITY_AGREEMENT: VDXFKeyInterface = { namespace: "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", name: "vrsc::identity.authentication.permission.agree" } -}; \ No newline at end of file +}; + +export const ATTESTATION_READ_REQUEST: VDXFKeyInterface = { + vdxfid: "iNqLaiDJjcADGCvXcQZnPqwTqMXzQbDCFu", + hash160result: "fbd8fe825062b19a9bd26dc51b6f768828115ad4", + qualifiedname: { + namespace: "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + name: "vrsc::identity.attestation.read" + } +}; + +export const PROFILE_DATA_READ_REQUEST: VDXFKeyInterface = { + vdxfid: "iFYznrRxyHaoJZ91cFDSYGT4szETf4RLRV", + indexid: "xLP7Fes3pboTvj23TvsbWeybueFUatbQQh", + hash160result: "d3f2168aad438c6c6eab8f3384458cbebf027a84", + qualifiedname: { + namespace: "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + name: "vrsc::profile.data.view" + } +} + +export const ATTESTATION_RECEIVE_REQUEST: VDXFKeyInterface = +{ + "vdxfid": "iQxHMa4cGQRMEVFchV7fah2JDqxjcgMAZK", + "indexid": "xVnPpNVh7ie1rf8eZAmpZ5YqFVykaYqC8E", + "hash160result": "b9af87a7313fff9976f29bc6abaffc1674899aeb", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::identity.attestation.receive" + } +} diff --git a/src/vdxf/vdxfdatakeys.ts b/src/vdxf/vdxfdatakeys.ts new file mode 100644 index 0000000..f73ca5a --- /dev/null +++ b/src/vdxf/vdxfdatakeys.ts @@ -0,0 +1,438 @@ +import { VDXFKeyInterface } from "./keys" + +export const DataByteKeyName = "vrsc::data.type.byte"; +export const DataByteKey: VDXFKeyInterface = { + "vdxfid": "iBXUHbh4iacbeZnzDRxishvBSrYk2S2k7t", + "indexid": "xGMakQ89ZtqGGjg257csr6SiUWZksGmjWp", + "hash160result": "2e97a8bba443773812341e1d761530d3bba04f58", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::data.type.byte" + } +} +export const DataInt16KeyName = "vrsc::data.type.int16"; +export const DataInt16Key: VDXFKeyInterface = { + "vdxfid": "iDtTv3wf1Vk3M2Y46RjLPKtttx5hydwtY1", + "indexid": "xJiaNrNjroxhyCR5x7PVMiRRvc6ipg6N9g", + "hash160result": "ee334ebd432db0b24cc2702eda61c28ff44d3872", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::data.type.int16" + } +} +export const DataUint16KeyName = "vrsc::data.type.uint16"; +export const DataUint16Key: VDXFKeyInterface = { + + "vdxfid": "iHn7urT2yVfS7pQn6WGAmCVWh4HBLV24n3", + "indexid": "xNcENet7pot6jzHoxBvKjb23iiJCGpekDk", + "hash160result": "5cfc322d2a216145f7b82714115e7953269de59c", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::data.type.uint16" + } +} + +export const DataInt32KeyName = "vrsc::data.type.int32"; +export const DataInt32Key: VDXFKeyInterface = { + + "vdxfid": "iHpLPprRDv3H5H3ZMaJ9nyHFzkG9xJWZDb", + "indexid": "xNeSrdHW5EFwhSvbDFxJmMoo2QHAtoEaEM", + "hash160result": "3e9ba478b23b13232f28d21051d907ce8fdd509d", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::data.type.int32" + } +} + +export const DataUint32KeyName = "vrsc::data.type.uint32"; + +export const DataUint32Key: VDXFKeyInterface = { + + "vdxfid": "iKSj5zhd6cSsLudaGhtfmisRNgEM7SPFWY", + "indexid": "xQGqYo8hwvfXy5Wc8PYpk7PxQLFMwfP7Fp", + "hash160result": "f279818aeb4fe768956b350d1fc7216ca0e82aaf", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::data.type.uint32" + } +} + +export const DataInt64KeyName = "vrsc::data.type.int64"; + +export const DataInt64Key: VDXFKeyInterface = { + + "vdxfid": "iKB3TGi9Dg5HZ4nQAgLQAgp3tuXBaRKHpC", + "indexid": "xQ19v59E4zHxBEfS2MzZ95LavZYCTTeuyg", + "hash160result": "ab3705f8a7fae59786ef897b014df85fcd9533ac", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::data.type.int64" + } +} + +export const DataUint64KeyName = "vrsc::data.type.uint64"; + +export const DataUint64Key: VDXFKeyInterface = { + + "vdxfid": "iPamkQf38AeGQ8z4zSsZL7t9kXMeUkYLJL", + "indexid": "xUQtDD67yUrw2Js6r8XiJWQgnBNfNeeoUq", + "hash160result": "bb2ae9ed3e9f400def0724937fbf65f23ef690dc", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::data.type.uint64" + } +} + +export const DataUint160KeyName = "vrsc::data.type.uint160"; + +export const DataUint160Key: VDXFKeyInterface = { + + "vdxfid": "iAAwdbLyKYL39nJ1eQHaHtb75krg4mV1Lq", + "indexid": "xF146Pn4ArYhmxB3W5wjGH7e7Qsgx9bkpj", + "hash160result": "d97d2295d4c73f6f6f0697c8086bd822d6977549", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::data.type.uint160" + } +} + +export const DataUint256KeyName = "vrsc::data.type.uint256"; + +export const DataUint256Key: VDXFKeyInterface = { + + "vdxfid": "i8k7g7z6grtGYrNZmZr5TQ872aHssXuuua", + "indexid": "xDaE8vRBYB6wB2FbdFWERnee4EJtjbCtMM", + "hash160result": "939b27bea698d180237c40b2194025acc673cb39", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::data.type.uint256" + } +} + +export const DataStringKeyName = "vrsc::data.type.string"; + +export const DataStringKey: VDXFKeyInterface = { + + "vdxfid": "iK7a5JNJnbeuYWVHCDRpJosj3irGJ5Qa8c", + "indexid": "xPwgY6oPdusaAgNK3u5yHCQG5NsHEcBpi5", + "hash160result": "e5c061641228a399169211e666de18448b7b8bab", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::data.type.string" + } +} + +// this is a key for a typed vector, which will have the object type key following the vector key +export const DataVectorKeyName = "vrsc::data.type.vector"; +export const DataVectorKey: VDXFKeyInterface = { + + "vdxfid": "iAEShwk1xjdGhaUSz3Maa2XR32o3vRuHq7", + "indexid": "xF4ZAkB6p3qwKkMUqj1jYR3x4gp4mGz657", + "hash160result": "503875b0dc301189a98927d3ece56c5f921c1f4a", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::data.type.vector" + } +} + +export const DataByteVectorKeyName = "vrsc::data.type.bytevector"; + +export const DataByteVectorKey: VDXFKeyInterface = { + + "vdxfid": "iKMhRLX1JHQihVZx2t2pAWW2uzmK6AzwW3", + "indexid": "xQBot8x69bdPKfSytZgy8u2ZwenKzVjR4X", + "hash160result": "cc3ae6466006629f5105f71325bb2a19107037ae", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::data.type.bytevector" + } +} + +export const DataInt32VectorKeyName = "vrsc::data.type.int32vector"; + +export const DataInt32VectorKey: VDXFKeyInterface = { + + "vdxfid": "iJZt2fcUv1iivbfC3tuPuefabcTppQEoVq", + "indexid": "xPPzVU3ZmKwPYmYDuaZYt3C7dGUqk939N7", + "hash160result": "c0847f3025c408059b5a8f6a9e414a8ed8288da5", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::data.type.int32vector" + } +} + +export const DataInt64VectorKeyName = "vrsc::data.type.int64vector"; + +export const DataInt64VectorKey: VDXFKeyInterface = { + + "vdxfid": "i4qtYkFS9iNyu2AkqwoSn1xyCdfH9PUvak", + "indexid": "x9g11YgX12beXC3nhdTbkQVWEHgJ2jqfz1", + "hash160result": "c6219ea13884987453692cb14c72d5f6a47c020f", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::data.type.int64vector" + } +} + +export const DataCurrencyMapKeyName = "vrsc::data.type.object.currencymap"; + +export const DataCurrencyMapKey: VDXFKeyInterface = { + + "vdxfid": "iMrGhzkZq5fpWWSa1RambRySFPb7CuvKuX", + "indexid": "xSgPAoBegPtV8gKbs7EvZpVyH3c858ZUvL", + "hash160result": "25db70c2fcae2571f89201181bec04587e1f8fc9", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::data.type.object.currencymap" + } +} + +export const DataRatingsKeyName = "vrsc::data.type.object.ratings"; + +export const DataRatingsKey: VDXFKeyInterface = { + + "vdxfid": "iHJComZUXXGniLkDhjYprWYEN8qvQGDoam", + "indexid": "xN8KGZzZNqVTLWdFZRCypu4mPnrwHFKbCK", + "hash160result": "32cad57ff1dc5db4b5ba573ce01bc9c89b0d9e97", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::data.type.object.ratings" + } +} + +export const DataURLKeyName = "vrsc::data.type.object.url"; + +export const DataURLKey: VDXFKeyInterface = { + + "vdxfid": "iJ7xdhJTJAvJubNnSJFXyA3jujzqGxjLuZ", + "indexid": "xNx56VjY9V8yXmFpHyugwYaGwQ1rCt6J9W", + "hash160result": "7748bfaf53dd2ff63ed5f73a41174c360f30a6a0", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::data.type.object.url" + } +} + +export const DataTransferDestinationKeyName = "vrsc::data.type.object.transferdestination"; + +export const DataTransferDestinationKey: VDXFKeyInterface = { + + "vdxfid": "i91L6zwZQrkbNVMB1AZ1Z671qybexRmeVK", + "indexid": "xDqSZoNeGAyFzfECrrDAXUdYsdcfs3Zuku", + "hash160result": "92f38773849383146037b16a48ea350c1c11ac3c", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::data.type.object.transferdestination" + } +} + +export const UTXORefKeyName = "vrsc::data.type.object.utxoref"; + +export const UTXORefKey: VDXFKeyInterface = { + + "vdxfid": "iNcKvh7mazaXptzHf85q6EtpFYFE7asKC1", + "indexid": "xTSSPVYrSJoCT4sKWojz4dRMHCGF3h9tM4", + "hash160result": "013e760f7451c289672993ea391ae643c21ce4d1", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::data.type.object.utxoref" + } +} + +export const CrossChainDataRefKeyName = "vrsc::data.type.object.crosschaindataref"; + +export const CrossChainDataRefKey: VDXFKeyInterface = { + + "vdxfid": "iP3euVSzNcXUrLNHnQnR9G6q8jeYuGSxgw", + "indexid": "xTsmNHt5Dvk9UWFKe6Sa7edNAPfZmJVgLc", + "hash160result": "4d33e0aee0f648c7871b2661d1221b57c05aaed6", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::data.type.object.crosschaindataref" + } +} + +export const EncryptionDescriptorKeyName = "vrsc::data.type.encryptiondescriptor"; + +export const EncryptionDescriptorKey: VDXFKeyInterface = { + + "vdxfid": "iHEEK8ipj58BeKZNWuaaR2tDR5RK2kmf9A", + "indexid": "xN4Lmw9uaPLrGVSQNbEjPRQkSjSKxsHUQu", + "hash160result": "8d021acc1b68335bd7d37b28ff773c138ea5dd96", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::data.type.encryptiondescriptor" + } +} + +export const SaltedDataKeyName = "vrsc::data.type.salteddata"; + +export const SaltedDataKey: VDXFKeyInterface = { + + "vdxfid": "i92U1nLuLJkC44FZZ4Lq9zk4qW3HrWAWNo", + "indexid": "xDraUamzBcxrgE8bQjzz8PGbsA4JiFskTD", + "hash160result": "9e13510e01d0d03a7bc90d7a2ef32824f515e33c", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::data.type.salteddata" + } +} + +export const DataDescriptorKeyName = "vrsc::data.type.object.datadescriptor"; + +export const DataDescriptorKey: VDXFKeyInterface = { + + "vdxfid": "i4GC1YGEVD21afWudGoFJVdnfjJ5XWnCQv", + "indexid": "x96JULhKLXEgCqPwUxTQGtAKhPK6Qh1iaW", + "hash160result": "4d4f12424ded2033a526a4e2a8835fc5b2eba208", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::data.type.object.datadescriptor" + } +} + +export const SignatureDataKeyName = "vrsc::data.signaturedata"; + +export const SignatureDataKey: VDXFKeyInterface = { + + "vdxfid": "i7PcVF9wwPtQ6p6jDtCVpohX65pTZuP2ah", + "indexid": "xCDix3b2ni74iyym5ZreoCE47jqUTBFRAb", + "hash160result": "b48b359e9a00042cec64f7f66ac717d388a4f22a", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::data.signaturedata" + } +} + +export const VectorUint256KeyName = "vrsc::data.mmrhashes"; + +export const VectorUint256Key: VDXFKeyInterface = { + + "vdxfid": "i9UgJ2WxGw95PKdoCXjpfnBShtP5gi9fxS", + "indexid": "xEJnkpx38FMk1VWq4DPyeAhyjYQ6X5Gsti", + "hash160result": "8c1afd59e904f6d2702699963abccbc6d326d841", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::data.mmrhashes" + } +} + +export const MMRLinksKeyName = "vrsc::data.mmrlinks"; + +export const MMRLinksKey: VDXFKeyInterface = { + + "vdxfid": "iPQsnA1R8UjHNddZKZ3FxsuKQ5WzKqSC7w", + "indexid": "xUEzExSVynwwzoWbBEhQwGRrRjY1Bc2MYc", + "hash160result": "f535a4e9ac0f94eda01695d16489a4a102d6b1da", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::data.mmrlinks" + } +} + +export const MMRDescriptorKeyName = "vrsc::data.mmrdescriptor"; + +export const MMRDescriptorKey: VDXFKeyInterface = { + + "vdxfid": "i9dVDb4LgfMYrZD1JBNP2uaso4bNAkT4Jr", + "indexid": "xETbgPVRXyaDUj639s2Y1J7QpicP4DvZMt", + "hash160result": "97273a4c02d6be002f8d69c3979616732ba68243", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::data.mmrdescriptor" + } +} + +export const TypeDefinitionKeyName = "vrsc::data.type.typedefinition"; + +export const TypeDefinitionKey: VDXFKeyInterface = { + + "vdxfid": "iL5MPPHWXQEY3p2Q1UsmGDvXsgPiqd1W1S", + "indexid": "xQuTrBibNiTCfyuRsAXvEcT4uLQjhxrpyL", + "hash160result": "ae8d805d9650c0512a6b6ec33e963386542f18b6", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::data.type.typedefinition" + } +} + +export const MultiMapKeyName = "vrsc::identity.multimapkey"; + +export const MultiMapKey: VDXFKeyInterface = { + + "vdxfid": "i3mbggp3NBR77C5JeFQJTpAxmgMidayLLE", + "indexid": "x8bi9VF8DVdmjMxLVw4TSChVoLNjUyapgs", + "hash160result": "6920bb81b420bc95e29a10ed677379b1e39e3a03", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::identity.multimapkey" + } +} + +export const ContentMultiMapRemoveKeyName = "vrsc::identity.multimapremove"; + +export const ContentMultiMapRemoveKey: VDXFKeyInterface = { + + "vdxfid": "i5Zkx5Z7tEfh42xtKfwbJ5LgEWE9rEgpFY", + "indexid": "xAPsQszCjYtMgCqvBMbkGTsDGAFAmrN33A", + "hash160result": "d393b986e4f82db7bec82d97b186882d739ded16", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::identity.multimapremove" + } +} + + +// for any ID, this key indexes content that applies to representing the profile of +// that ID. there may be many mime-type instances of a particular piece of profile media +export const ProfileMediaKeyName = "vrsc::identity.profile.media"; + +export const ProfileMediaKey: VDXFKeyInterface = { + + "vdxfid": "iEYsp2njSt1M4EVYi9uuAPBU2wpKmThkkr", + "indexid": "xKNzGqDpJCE1gQNaZqa48mi14bqLaG669g", + "hash160result": "e95b2ee1abb130a93900ddaef2d8e528010f7c79", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::identity.profile.media" + } +} + +export const ZMemoMessageKeyName = "vrsc::system.zmemo.message"; + +export const ZMemoMessageKey: VDXFKeyInterface = { + + "vdxfid": "iNHg1n828PUxktkYeNxC6sdVmuKTipn3L3", + "indexid": "xT7nUaZ6yhhdP4daW4cM5GA2oZLUaNVaBD", + "hash160result": "4a8f418203621f10d1a61701be8dbbbb38fa5cce", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::system.zmemo.message" + } +} + +export const ZMemoSignatureKeyName = "vrsc::system.zmemo.signature"; + +export const ZMemoSignatureKey: VDXFKeyInterface = { + + "vdxfid": "i7mrLLjUfGYuHJwnsxFvd282hsdn4staJG", + "indexid": "xCbxo9AZWamZuUppjdv5bQeZjXeo1vbaCc", + "hash160result": "7b47c8cd90c4c3ddc542f37ca77473b7325a272f", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::system.zmemo.signature" + } +} + +export const CurrencyStartNotarizationKeyName = "vrsc::system.currency.startnotarization"; + +export const CurrencyStartNotarizationKey: VDXFKeyInterface = { + + "vdxfid": "iRvxVcGLaCXcDiAfnQ5FfeBCo2AiBibAft", + "indexid": "xWm4xQhRRWkGqt3he5jQe2hjpgBj5C7Tj3", + "hash160result": "b537201ca6465976bea7bdb03119644a858052f6", + "qualifiedname": { + "namespace": "i5w5MuNik5NtLcYmNzcvaoixooEebB6MGV", + "name": "vrsc::system.currency.startnotarization" + } +} diff --git a/yarn.lock b/yarn.lock index de3e14c..2784c1e 100644 --- a/yarn.lock +++ b/yarn.lock @@ -935,6 +935,11 @@ array-union@^2.1.0: resolved "https://registry.yarnpkg.com/array-union/-/array-union-2.1.0.tgz#b798420adbeb1de828d84acd8a2e23d3efe85e8d" integrity sha512-HGyxoOTYUyCM6stUe6EJgnd4EoewAI7zMdfqO+kGjnlZmBDz/cR5pf8r/cR4Wq60sL/p0IkcjUEEPwS3GFrIyw== +b4a@^1.0.1: + version "1.6.4" + resolved "https://registry.yarnpkg.com/b4a/-/b4a-1.6.4.tgz#ef1c1422cae5ce6535ec191baeed7567443f36c9" + integrity sha512-fpWrvyVHEKyeEvbKZTVOeZF3VSKKWtJxFIxX/jaVPf+cLbGUSitjb49pHLqPV2BUNNZ0LcoeEGfE/YCpyDYHIw== + babel-jest@^28.1.3: version "28.1.3" resolved "https://registry.yarnpkg.com/babel-jest/-/babel-jest-28.1.3.tgz#c1187258197c099072156a0a121c11ee1e3917d5" @@ -1017,6 +1022,21 @@ bech32@2.0.0: resolved "https://registry.yarnpkg.com/bech32/-/bech32-2.0.0.tgz#078d3686535075c8c79709f054b1b226a133b355" integrity sha512-LcknSilhIGatDAsY1ak2I8VtGaHNhgMSYVxFrGLXv+xLHytaKZKcaUJJUE7qmBr7h33o5YQwP55pMI0xmkpJwg== +blake2b-wasm@^2.4.0: + version "2.4.0" + resolved "https://registry.yarnpkg.com/blake2b-wasm/-/blake2b-wasm-2.4.0.tgz#9115649111edbbd87eb24ce7c04b427e4e2be5be" + integrity sha512-S1kwmW2ZhZFFFOghcx73+ZajEfKBqhP82JMssxtLVMxlaPea1p9uoLiUZ5WYyHn0KddwbLc+0vh4wR0KBNoT5w== + dependencies: + b4a "^1.0.1" + nanoassert "^2.0.0" + +"blake2b@https://github.com/VerusCoin/blake2b": + version "2.1.4" + resolved "https://github.com/VerusCoin/blake2b#578dc12b7b68a3ce76d1e1add1402b28a5890a6b" + dependencies: + blake2b-wasm "^2.4.0" + nanoassert "^2.0.0" + bn.js@5.2.1: version "5.2.1" resolved "https://registry.yarnpkg.com/bn.js/-/bn.js-5.2.1.tgz#0bc527a6a0d18d0aa8d5b0538ce4a77dccfa7b70" @@ -2308,6 +2328,11 @@ ms@2.1.2: resolved "https://registry.yarnpkg.com/ms/-/ms-2.1.2.tgz#d09d1f357b443f493382a8eb3ccd183872ae6009" integrity sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w== +nanoassert@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/nanoassert/-/nanoassert-2.0.0.tgz#a05f86de6c7a51618038a620f88878ed1e490c09" + integrity sha512-7vO7n28+aYO4J+8w96AzhmU8G+Y/xpPDJz/se19ICsqj/momRbb9mh9ZUtkoJ5X3nTnPdhEJyc0qnM6yAsHBaA== + natural-compare@^1.4.0: version "1.4.0" resolved "https://registry.yarnpkg.com/natural-compare/-/natural-compare-1.4.0.tgz#4abebfeed7541f2c27acfb29bdbbd15c8d5ba4f7"