@0xpolygonid/js-sdk 1.25.1 → 1.26.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/browser/esm/index.js +239 -47
- package/dist/browser/esm/index.js.map +1 -1
- package/dist/browser/umd/index.js +241 -46
- package/dist/browser/umd/index.js.map +1 -1
- package/dist/node/cjs/iden3comm/constants.js +6 -1
- package/dist/node/cjs/iden3comm/handlers/auth.js +16 -24
- package/dist/node/cjs/iden3comm/handlers/discovery-protocol.js +198 -0
- package/dist/node/cjs/iden3comm/handlers/index.js +1 -0
- package/dist/node/cjs/iden3comm/packageManager.js +12 -0
- package/dist/node/cjs/iden3comm/packers/jws.js +8 -7
- package/dist/node/cjs/iden3comm/packers/plain.js +8 -2
- package/dist/node/cjs/iden3comm/packers/zkp.js +10 -12
- package/dist/node/cjs/iden3comm/types/index.js +1 -0
- package/dist/node/cjs/iden3comm/types/protocol/discovery-protocol.js +16 -0
- package/dist/node/esm/iden3comm/constants.js +6 -1
- package/dist/node/esm/iden3comm/handlers/auth.js +17 -25
- package/dist/node/esm/iden3comm/handlers/discovery-protocol.js +169 -0
- package/dist/node/esm/iden3comm/handlers/index.js +1 -0
- package/dist/node/esm/iden3comm/packageManager.js +12 -0
- package/dist/node/esm/iden3comm/packers/jws.js +9 -8
- package/dist/node/esm/iden3comm/packers/plain.js +9 -3
- package/dist/node/esm/iden3comm/packers/zkp.js +11 -13
- package/dist/node/esm/iden3comm/types/index.js +1 -0
- package/dist/node/esm/iden3comm/types/protocol/discovery-protocol.js +13 -0
- package/dist/types/iden3comm/constants.d.ts +2 -0
- package/dist/types/iden3comm/handlers/discovery-protocol.d.ts +100 -0
- package/dist/types/iden3comm/handlers/index.d.ts +1 -0
- package/dist/types/iden3comm/packageManager.d.ts +2 -0
- package/dist/types/iden3comm/packers/jws.d.ts +2 -1
- package/dist/types/iden3comm/packers/plain.d.ts +1 -0
- package/dist/types/iden3comm/packers/zkp.d.ts +3 -2
- package/dist/types/iden3comm/types/index.d.ts +1 -0
- package/dist/types/iden3comm/types/packageManager.d.ts +6 -0
- package/dist/types/iden3comm/types/protocol/discovery-protocol.d.ts +41 -0
- package/package.json +1 -1
|
@@ -58286,6 +58286,7 @@ class CredentialStatusResolverRegistry {
|
|
|
58286
58286
|
}
|
|
58287
58287
|
|
|
58288
58288
|
const IDEN3_PROTOCOL = 'https://iden3-communication.io/';
|
|
58289
|
+
const DIDCOMM_PROTOCOL = 'https://didcomm.org/';
|
|
58289
58290
|
/**
|
|
58290
58291
|
* Constants for Iden3 protocol
|
|
58291
58292
|
*/
|
|
@@ -58329,7 +58330,11 @@ const PROTOCOL_MESSAGE_TYPE = Object.freeze({
|
|
|
58329
58330
|
// PaymentRequestMessageType is type for payment-request message
|
|
58330
58331
|
PAYMENT_REQUEST_MESSAGE_TYPE: `${IDEN3_PROTOCOL}credentials/0.1/payment-request`,
|
|
58331
58332
|
// PaymentMessageType is type for payment message
|
|
58332
|
-
PAYMENT_MESSAGE_TYPE: `${IDEN3_PROTOCOL}credentials/0.1/payment
|
|
58333
|
+
PAYMENT_MESSAGE_TYPE: `${IDEN3_PROTOCOL}credentials/0.1/payment`,
|
|
58334
|
+
// DiscoveryProtocolQueriesMessageType is type for didcomm discovery protocol queries
|
|
58335
|
+
DISCOVERY_PROTOCOL_QUERIES_MESSAGE_TYPE: `${DIDCOMM_PROTOCOL}discover-features/2.0/queries`,
|
|
58336
|
+
// DiscoveryProtocolDiscloseMessageType is type for didcomm discovery protocol disclose
|
|
58337
|
+
DISCOVERY_PROTOCOL_DISCLOSE_MESSAGE_TYPE: `${DIDCOMM_PROTOCOL}discover-features/2.0/disclose`
|
|
58333
58338
|
});
|
|
58334
58339
|
/**
|
|
58335
58340
|
* Media types for iden3 comm communication protocol
|
|
@@ -59473,6 +59478,18 @@ class PackageManager {
|
|
|
59473
59478
|
constructor() {
|
|
59474
59479
|
this.packers = new Map();
|
|
59475
59480
|
}
|
|
59481
|
+
/** {@inheritDoc IPackageManager.getSupportedProfiles} */
|
|
59482
|
+
getSupportedProfiles() {
|
|
59483
|
+
const acceptProfiles = [];
|
|
59484
|
+
const mediaTypes = this.getSupportedMediaTypes();
|
|
59485
|
+
for (const mediaType of mediaTypes) {
|
|
59486
|
+
const p = this.packers.get(mediaType);
|
|
59487
|
+
if (p) {
|
|
59488
|
+
acceptProfiles.push(...p.getSupportedProfiles());
|
|
59489
|
+
}
|
|
59490
|
+
}
|
|
59491
|
+
return [...new Set(acceptProfiles)];
|
|
59492
|
+
}
|
|
59476
59493
|
/** {@inheritDoc IPackageManager.isProfileSupported} */
|
|
59477
59494
|
isProfileSupported(mediaType, profile) {
|
|
59478
59495
|
const p = this.packers.get(mediaType);
|
|
@@ -59786,6 +59803,9 @@ class ZKPPacker {
|
|
|
59786
59803
|
this.provingParamsMap = provingParamsMap;
|
|
59787
59804
|
this.verificationParamsMap = verificationParamsMap;
|
|
59788
59805
|
this._opts = _opts;
|
|
59806
|
+
this.supportedProtocolVersions = [ProtocolVersion.V1];
|
|
59807
|
+
this.supportedAlgorithms = [AcceptJwzAlgorithms.Groth16];
|
|
59808
|
+
this.supportedCircuitIds = [AcceptAuthCircuits.AuthV2];
|
|
59789
59809
|
}
|
|
59790
59810
|
/**
|
|
59791
59811
|
* Packs a basic message using the specified parameters.
|
|
@@ -59847,28 +59867,23 @@ class ZKPPacker {
|
|
|
59847
59867
|
}
|
|
59848
59868
|
/** {@inheritDoc IPacker.getSupportedProfiles} */
|
|
59849
59869
|
getSupportedProfiles() {
|
|
59850
|
-
return
|
|
59851
|
-
`env=${this.mediaType()}&alg=${this.getSupportedAlgorithms().join(',')}&circuitIds=${this.getSupportedCircuitIds().join(',')}`
|
|
59852
|
-
];
|
|
59870
|
+
return this.supportedProtocolVersions.map((v) => `${v};env=${this.mediaType()};alg=${this.supportedAlgorithms.join(',')};circuitIds=${this.supportedCircuitIds.join(',')}`);
|
|
59853
59871
|
}
|
|
59854
59872
|
/** {@inheritDoc IPacker.isProfileSupported} */
|
|
59855
59873
|
isProfileSupported(profile) {
|
|
59856
|
-
const { env, circuits, alg } = parseAcceptProfile(profile);
|
|
59874
|
+
const { protocolVersion, env, circuits, alg } = parseAcceptProfile(profile);
|
|
59875
|
+
if (!this.supportedProtocolVersions.includes(protocolVersion)) {
|
|
59876
|
+
return false;
|
|
59877
|
+
}
|
|
59857
59878
|
if (env !== this.mediaType()) {
|
|
59858
59879
|
return false;
|
|
59859
59880
|
}
|
|
59860
|
-
const supportedCircuitIds = this.
|
|
59881
|
+
const supportedCircuitIds = this.supportedCircuitIds;
|
|
59861
59882
|
const circuitIdSupported = !circuits?.length || circuits.some((c) => supportedCircuitIds.includes(c));
|
|
59862
|
-
const supportedAlgArr = this.
|
|
59883
|
+
const supportedAlgArr = this.supportedAlgorithms;
|
|
59863
59884
|
const algSupported = !alg?.length || alg.some((a) => supportedAlgArr.includes(a));
|
|
59864
59885
|
return algSupported && circuitIdSupported;
|
|
59865
59886
|
}
|
|
59866
|
-
getSupportedAlgorithms() {
|
|
59867
|
-
return [AcceptJwzAlgorithms.Groth16];
|
|
59868
|
-
}
|
|
59869
|
-
getSupportedCircuitIds() {
|
|
59870
|
-
return [AcceptAuthCircuits.AuthV2];
|
|
59871
|
-
}
|
|
59872
59887
|
}
|
|
59873
59888
|
const verifySender = async (token, msg) => {
|
|
59874
59889
|
switch (token.circuitId) {
|
|
@@ -59902,6 +59917,9 @@ const verifySender = async (token, msg) => {
|
|
|
59902
59917
|
* @implements implements IPacker interface
|
|
59903
59918
|
*/
|
|
59904
59919
|
class PlainPacker {
|
|
59920
|
+
constructor() {
|
|
59921
|
+
this.supportedProtocolVersions = [ProtocolVersion.V1];
|
|
59922
|
+
}
|
|
59905
59923
|
/**
|
|
59906
59924
|
* Packs a basic message using the specified parameters.
|
|
59907
59925
|
*
|
|
@@ -59945,11 +59963,14 @@ class PlainPacker {
|
|
|
59945
59963
|
}
|
|
59946
59964
|
/** {@inheritDoc IPacker.getSupportedProfiles} */
|
|
59947
59965
|
getSupportedProfiles() {
|
|
59948
|
-
return
|
|
59966
|
+
return this.supportedProtocolVersions.map((v) => `${v};env=${this.mediaType()}`);
|
|
59949
59967
|
}
|
|
59950
59968
|
/** {@inheritDoc IPacker.isProfileSupported} */
|
|
59951
59969
|
isProfileSupported(profile) {
|
|
59952
|
-
const { env, circuits, alg } = parseAcceptProfile(profile);
|
|
59970
|
+
const { protocolVersion, env, circuits, alg } = parseAcceptProfile(profile);
|
|
59971
|
+
if (!this.supportedProtocolVersions.includes(protocolVersion)) {
|
|
59972
|
+
return false;
|
|
59973
|
+
}
|
|
59953
59974
|
if (env !== this.mediaType()) {
|
|
59954
59975
|
return false;
|
|
59955
59976
|
}
|
|
@@ -59981,6 +60002,8 @@ class JWSPacker {
|
|
|
59981
60002
|
constructor(_kms, _documentResolver) {
|
|
59982
60003
|
this._kms = _kms;
|
|
59983
60004
|
this._documentResolver = _documentResolver;
|
|
60005
|
+
this.supportedAlgorithms = [AcceptJwsAlgorithms.ES256K, AcceptJwsAlgorithms.ES256KR];
|
|
60006
|
+
this.supportedProtocolVersions = [ProtocolVersion.V1];
|
|
59984
60007
|
}
|
|
59985
60008
|
/**
|
|
59986
60009
|
* Packs the given payload and returns a promise that resolves to the packed data.
|
|
@@ -60043,24 +60066,23 @@ class JWSPacker {
|
|
|
60043
60066
|
}
|
|
60044
60067
|
/** {@inheritDoc IPacker.getSupportedProfiles} */
|
|
60045
60068
|
getSupportedProfiles() {
|
|
60046
|
-
return
|
|
60069
|
+
return this.supportedProtocolVersions.map((v) => `${v};env=${this.mediaType()};alg=${this.supportedAlgorithms.join(',')}`);
|
|
60047
60070
|
}
|
|
60048
60071
|
/** {@inheritDoc IPacker.isProfileSupported} */
|
|
60049
60072
|
isProfileSupported(profile) {
|
|
60050
|
-
const { env, circuits, alg } = parseAcceptProfile(profile);
|
|
60073
|
+
const { protocolVersion, env, circuits, alg } = parseAcceptProfile(profile);
|
|
60074
|
+
if (!this.supportedProtocolVersions.includes(protocolVersion)) {
|
|
60075
|
+
return false;
|
|
60076
|
+
}
|
|
60051
60077
|
if (env !== this.mediaType()) {
|
|
60052
60078
|
return false;
|
|
60053
60079
|
}
|
|
60054
60080
|
if (circuits) {
|
|
60055
60081
|
throw new Error(`Circuits are not supported for ${env} media type`);
|
|
60056
60082
|
}
|
|
60057
|
-
const
|
|
60058
|
-
const algSupported = !alg?.length || alg.some((a) => supportedAlgArr.includes(a));
|
|
60083
|
+
const algSupported = !alg?.length || alg.some((a) => this.supportedAlgorithms.includes(a));
|
|
60059
60084
|
return algSupported;
|
|
60060
60085
|
}
|
|
60061
|
-
getSupportedAlgorithms() {
|
|
60062
|
-
return [AcceptJwsAlgorithms.ES256K, AcceptJwsAlgorithms.ES256KR];
|
|
60063
|
-
}
|
|
60064
60086
|
async resolveDidDoc(from) {
|
|
60065
60087
|
let didDocument;
|
|
60066
60088
|
try {
|
|
@@ -60136,6 +60158,20 @@ var CredentialOfferStatus;
|
|
|
60136
60158
|
CredentialOfferStatus["Rejected"] = "rejected";
|
|
60137
60159
|
})(CredentialOfferStatus || (CredentialOfferStatus = {}));
|
|
60138
60160
|
|
|
60161
|
+
/** @beta DiscoverFeatureQueryType is enum for query type fields */
|
|
60162
|
+
var DiscoverFeatureQueryType;
|
|
60163
|
+
(function (DiscoverFeatureQueryType) {
|
|
60164
|
+
DiscoverFeatureQueryType["FeatureType"] = "feature-type";
|
|
60165
|
+
})(DiscoverFeatureQueryType || (DiscoverFeatureQueryType = {}));
|
|
60166
|
+
/** @beta DiscoveryProtocolFeatureType is enum for supported feature-types */
|
|
60167
|
+
var DiscoveryProtocolFeatureType;
|
|
60168
|
+
(function (DiscoveryProtocolFeatureType) {
|
|
60169
|
+
DiscoveryProtocolFeatureType["Accept"] = "accept";
|
|
60170
|
+
DiscoveryProtocolFeatureType["Protocol"] = "protocol";
|
|
60171
|
+
DiscoveryProtocolFeatureType["GoalCode"] = "goal-code";
|
|
60172
|
+
DiscoveryProtocolFeatureType["Header"] = "header";
|
|
60173
|
+
})(DiscoveryProtocolFeatureType || (DiscoveryProtocolFeatureType = {}));
|
|
60174
|
+
|
|
60139
60175
|
/**
|
|
60140
60176
|
* Groups the ZeroKnowledgeProofRequest objects based on their groupId.
|
|
60141
60177
|
* Returns a Map where the key is the groupId and the value is an object containing the query and linkNonce.
|
|
@@ -60581,32 +60617,24 @@ class AuthHandler extends AbstractMessageHandler {
|
|
|
60581
60617
|
}
|
|
60582
60618
|
getSupportedMediaTypeByProfile(ctx, responseType, profile) {
|
|
60583
60619
|
let mediaType;
|
|
60584
|
-
if (profile?.length) {
|
|
60585
|
-
|
|
60586
|
-
|
|
60587
|
-
|
|
60588
|
-
|
|
60589
|
-
|
|
60590
|
-
|
|
60591
|
-
|
|
60592
|
-
(responseTypeVersion < 1 || responseTypeVersion >= 2))) {
|
|
60593
|
-
continue;
|
|
60594
|
-
}
|
|
60595
|
-
// 2. check packer support
|
|
60596
|
-
if (this._packerMgr.isProfileSupported(env, acceptProfile)) {
|
|
60597
|
-
supportedMediaTypes.push(env);
|
|
60598
|
-
}
|
|
60599
|
-
}
|
|
60600
|
-
if (!supportedMediaTypes.length) {
|
|
60601
|
-
throw new Error('no packer with profile which meets `accept` header requirements');
|
|
60602
|
-
}
|
|
60603
|
-
mediaType = supportedMediaTypes[0];
|
|
60604
|
-
if (ctx.mediaType && supportedMediaTypes.includes(ctx.mediaType)) {
|
|
60605
|
-
mediaType = ctx.mediaType;
|
|
60620
|
+
if (!profile?.length) {
|
|
60621
|
+
return ctx.mediaType || MediaType.ZKPMessage;
|
|
60622
|
+
}
|
|
60623
|
+
const supportedMediaTypes = [];
|
|
60624
|
+
for (const acceptProfile of profile) {
|
|
60625
|
+
const { env } = parseAcceptProfile(acceptProfile);
|
|
60626
|
+
if (this._packerMgr.isProfileSupported(env, acceptProfile)) {
|
|
60627
|
+
supportedMediaTypes.push(env);
|
|
60606
60628
|
}
|
|
60607
60629
|
}
|
|
60608
|
-
|
|
60609
|
-
|
|
60630
|
+
if (!supportedMediaTypes.length) {
|
|
60631
|
+
throw new Error('no packer with profile which meets `accept` header requirements');
|
|
60632
|
+
}
|
|
60633
|
+
mediaType = supportedMediaTypes.includes(MediaType.ZKPMessage)
|
|
60634
|
+
? MediaType.ZKPMessage
|
|
60635
|
+
: supportedMediaTypes[0];
|
|
60636
|
+
if (ctx.mediaType && supportedMediaTypes.includes(ctx.mediaType)) {
|
|
60637
|
+
mediaType = ctx.mediaType;
|
|
60610
60638
|
}
|
|
60611
60639
|
return mediaType;
|
|
60612
60640
|
}
|
|
@@ -61813,6 +61841,170 @@ class PaymentHandler extends AbstractMessageHandler {
|
|
|
61813
61841
|
}
|
|
61814
61842
|
}
|
|
61815
61843
|
|
|
61844
|
+
/**
|
|
61845
|
+
* @beta
|
|
61846
|
+
* createDiscoveryFeatureQueryMessage is a function to create didcomm protocol discovery-feature query message
|
|
61847
|
+
* @param opts - discovery-feature query options
|
|
61848
|
+
* @returns `DiscoverFeatureQueriesMessage`
|
|
61849
|
+
*/
|
|
61850
|
+
function createDiscoveryFeatureQueryMessage(queries, opts) {
|
|
61851
|
+
const uuidv4 = v4();
|
|
61852
|
+
return {
|
|
61853
|
+
id: uuidv4,
|
|
61854
|
+
thid: uuidv4,
|
|
61855
|
+
typ: MediaType.PlainMessage,
|
|
61856
|
+
type: PROTOCOL_MESSAGE_TYPE.DISCOVERY_PROTOCOL_QUERIES_MESSAGE_TYPE,
|
|
61857
|
+
body: {
|
|
61858
|
+
queries
|
|
61859
|
+
},
|
|
61860
|
+
from: opts?.from,
|
|
61861
|
+
to: opts?.to,
|
|
61862
|
+
created_time: getUnixTimestamp(new Date()),
|
|
61863
|
+
expires_time: opts?.expires_time
|
|
61864
|
+
};
|
|
61865
|
+
}
|
|
61866
|
+
/**
|
|
61867
|
+
* @beta
|
|
61868
|
+
* createDiscoveryFeatureDiscloseMessage is a function to create didcomm protocol discovery-feature disclose message
|
|
61869
|
+
* @param {DiscoverFeatureDisclosure[]} disclosures - array of disclosures
|
|
61870
|
+
* @param opts - basic message options
|
|
61871
|
+
* @returns `DiscoverFeatureQueriesMessage`
|
|
61872
|
+
*/
|
|
61873
|
+
function createDiscoveryFeatureDiscloseMessage(disclosures, opts) {
|
|
61874
|
+
const uuidv4 = v4();
|
|
61875
|
+
return {
|
|
61876
|
+
id: uuidv4,
|
|
61877
|
+
typ: MediaType.PlainMessage,
|
|
61878
|
+
thid: uuidv4,
|
|
61879
|
+
type: PROTOCOL_MESSAGE_TYPE.DISCOVERY_PROTOCOL_DISCLOSE_MESSAGE_TYPE,
|
|
61880
|
+
body: {
|
|
61881
|
+
disclosures
|
|
61882
|
+
},
|
|
61883
|
+
from: opts?.from,
|
|
61884
|
+
to: opts?.to,
|
|
61885
|
+
created_time: getUnixTimestamp(new Date()),
|
|
61886
|
+
expires_time: opts?.expires_time
|
|
61887
|
+
};
|
|
61888
|
+
}
|
|
61889
|
+
/**
|
|
61890
|
+
*
|
|
61891
|
+
* Handler for discovery protocol
|
|
61892
|
+
*
|
|
61893
|
+
* @public
|
|
61894
|
+
* @beta
|
|
61895
|
+
* @class DiscoveryProtocolHandler
|
|
61896
|
+
* @implements implements DiscoveryProtocolHandler interface
|
|
61897
|
+
*/
|
|
61898
|
+
class DiscoveryProtocolHandler extends AbstractMessageHandler {
|
|
61899
|
+
/**
|
|
61900
|
+
* Creates an instance of DiscoveryProtocolHandler.
|
|
61901
|
+
* @param {DiscoveryProtocolOptions} _options - discovery protocol options
|
|
61902
|
+
*/
|
|
61903
|
+
constructor(_options) {
|
|
61904
|
+
super();
|
|
61905
|
+
this._options = _options;
|
|
61906
|
+
const headers = [
|
|
61907
|
+
'id',
|
|
61908
|
+
'typ',
|
|
61909
|
+
'type',
|
|
61910
|
+
'thid',
|
|
61911
|
+
'body',
|
|
61912
|
+
'from',
|
|
61913
|
+
'to',
|
|
61914
|
+
'created_time',
|
|
61915
|
+
'expires_time'
|
|
61916
|
+
];
|
|
61917
|
+
if (!_options.headers) {
|
|
61918
|
+
_options.headers = headers;
|
|
61919
|
+
}
|
|
61920
|
+
}
|
|
61921
|
+
/**
|
|
61922
|
+
* @inheritdoc IProtocolMessageHandler#handle
|
|
61923
|
+
*/
|
|
61924
|
+
async handle(message, context) {
|
|
61925
|
+
switch (message.type) {
|
|
61926
|
+
case PROTOCOL_MESSAGE_TYPE.DISCOVERY_PROTOCOL_QUERIES_MESSAGE_TYPE:
|
|
61927
|
+
return await this.handleDiscoveryQuery(message, context);
|
|
61928
|
+
default:
|
|
61929
|
+
return super.handle(message, context);
|
|
61930
|
+
}
|
|
61931
|
+
}
|
|
61932
|
+
/**
|
|
61933
|
+
* @inheritdoc IDiscoveryProtocolHandler#handleDiscoveryQuery
|
|
61934
|
+
*/
|
|
61935
|
+
async handleDiscoveryQuery(message, opts) {
|
|
61936
|
+
if (!opts?.allowExpiredMessages) {
|
|
61937
|
+
verifyExpiresTime(message);
|
|
61938
|
+
}
|
|
61939
|
+
const disclosures = [];
|
|
61940
|
+
for (const query of message.body.queries) {
|
|
61941
|
+
disclosures.push(...this.handleQuery(query));
|
|
61942
|
+
}
|
|
61943
|
+
return Promise.resolve(createDiscoveryFeatureDiscloseMessage(disclosures, {
|
|
61944
|
+
to: message.from,
|
|
61945
|
+
from: message.to,
|
|
61946
|
+
expires_time: opts?.disclosureExpiresDate
|
|
61947
|
+
? getUnixTimestamp(opts.disclosureExpiresDate)
|
|
61948
|
+
: undefined
|
|
61949
|
+
}));
|
|
61950
|
+
}
|
|
61951
|
+
handleQuery(query) {
|
|
61952
|
+
let result = [];
|
|
61953
|
+
switch (query[DiscoverFeatureQueryType.FeatureType]) {
|
|
61954
|
+
case DiscoveryProtocolFeatureType.Accept:
|
|
61955
|
+
result = this.handleAcceptQuery();
|
|
61956
|
+
break;
|
|
61957
|
+
case DiscoveryProtocolFeatureType.Protocol:
|
|
61958
|
+
result = this.handleProtocolQuery();
|
|
61959
|
+
break;
|
|
61960
|
+
case DiscoveryProtocolFeatureType.GoalCode:
|
|
61961
|
+
result = this.handleGoalCodeQuery();
|
|
61962
|
+
break;
|
|
61963
|
+
case DiscoveryProtocolFeatureType.Header:
|
|
61964
|
+
result = this.handleHeaderQuery();
|
|
61965
|
+
break;
|
|
61966
|
+
}
|
|
61967
|
+
return this.handleMatch(result, query.match);
|
|
61968
|
+
}
|
|
61969
|
+
handleAcceptQuery() {
|
|
61970
|
+
const acceptProfiles = this._options.packageManager.getSupportedProfiles();
|
|
61971
|
+
return acceptProfiles.map((profile) => ({
|
|
61972
|
+
[DiscoverFeatureQueryType.FeatureType]: DiscoveryProtocolFeatureType.Accept,
|
|
61973
|
+
id: profile
|
|
61974
|
+
}));
|
|
61975
|
+
}
|
|
61976
|
+
handleProtocolQuery() {
|
|
61977
|
+
return (this._options.protocols?.map((protocol) => ({
|
|
61978
|
+
[DiscoverFeatureQueryType.FeatureType]: DiscoveryProtocolFeatureType.Protocol,
|
|
61979
|
+
id: protocol
|
|
61980
|
+
})) ?? []);
|
|
61981
|
+
}
|
|
61982
|
+
handleGoalCodeQuery() {
|
|
61983
|
+
return (this._options.goalCodes?.map((goalCode) => ({
|
|
61984
|
+
[DiscoverFeatureQueryType.FeatureType]: DiscoveryProtocolFeatureType.GoalCode,
|
|
61985
|
+
id: goalCode
|
|
61986
|
+
})) ?? []);
|
|
61987
|
+
}
|
|
61988
|
+
handleHeaderQuery() {
|
|
61989
|
+
return (this._options.headers?.map((header) => ({
|
|
61990
|
+
[DiscoverFeatureQueryType.FeatureType]: DiscoveryProtocolFeatureType.Header,
|
|
61991
|
+
id: header
|
|
61992
|
+
})) ?? []);
|
|
61993
|
+
}
|
|
61994
|
+
handleMatch(disclosures, match) {
|
|
61995
|
+
if (!match || match === '*') {
|
|
61996
|
+
return disclosures;
|
|
61997
|
+
}
|
|
61998
|
+
const regExp = this.wildcardToRegExp(match);
|
|
61999
|
+
return disclosures.filter((disclosure) => regExp.test(disclosure.id));
|
|
62000
|
+
}
|
|
62001
|
+
wildcardToRegExp(match) {
|
|
62002
|
+
// Escape special regex characters, then replace `*` with `.*`
|
|
62003
|
+
const regexPattern = match.replace(/[.+^${}()|[\]\\]/g, '\\$&').replace(/\*/g, '.*');
|
|
62004
|
+
return new RegExp(`^${regexPattern}$`);
|
|
62005
|
+
}
|
|
62006
|
+
}
|
|
62007
|
+
|
|
61816
62008
|
const allOperations = Object.values(QueryOperators);
|
|
61817
62009
|
const v2Operations = [
|
|
61818
62010
|
Operators.NOOP,
|
|
@@ -63853,5 +64045,5 @@ class IdentityWallet {
|
|
|
63853
64045
|
}
|
|
63854
64046
|
}
|
|
63855
64047
|
|
|
63856
|
-
export { AbstractMessageHandler, AbstractPrivateKeyStore, AgentResolver, AtomicQueryMTPV2Inputs, AtomicQueryMTPV2OnChainInputs, AtomicQueryMTPV2OnChainPubSignals, AtomicQueryMTPV2PubSignals, AtomicQuerySigV2Inputs, AtomicQuerySigV2OnChainCircuitInputs, AtomicQuerySigV2OnChainInputs, AtomicQuerySigV2OnChainPubSignals, AtomicQuerySigV2PubSignals, AtomicQueryV3Inputs, AtomicQueryV3OnChainInputs, AtomicQueryV3OnChainPubSignals, AtomicQueryV3PubSignals, AuthHandler, AuthV2Inputs, AuthV2PubSignals, BJJSignatureProof2021, BaseConfig, BjjProvider, BrowserDataSource, CircuitClaim, CircuitError, CircuitId, CircuitStorage, ContractRequestHandler, CredentialOfferStatus, CredentialProposalHandler, CredentialStatusPublisherRegistry, CredentialStatusResolverRegistry, CredentialStatusType, CredentialStorage, CredentialWallet, DIDDocumentJSONSchema, DIDDocumentSignature, DataPrepareHandlerFunc, DidDocumentCredentialStatusResolver, DidResolverStateReadonlyStorage, DisplayMethodType, Ed25519Provider, ErrorEmptyAuthClaimNonRevProof, ErrorEmptyAuthClaimProof, ErrorEmptyChallengeSignature, ErrorEmptyClaimNonRevProof, ErrorEmptyClaimProof, ErrorEmptyClaimSignature, ErrorEmptyIssuerAuthClaimNonRevProof, ErrorEmptyIssuerAuthClaimProof, ErrorUserStateInRelayClaimProof, EthStateStorage, FSCircuitStorage, FetchHandler, FilterQuery, FunctionSignatures, Iden3OnchainSmtCredentialStatusPublisher, Iden3SmtRhsCredentialStatusPublisher, Iden3SparseMerkleTreeProof, IdentityStorage, IdentityWallet, InMemoryDataSource, InMemoryMerkleTreeStorage, InMemoryPrivateKeyStore, IndexedDBDataSource, IndexedDBPrivateKeyStore, InputGenerator, IssuerResolver, JSON_SCHEMA_VALIDATORS_REGISTRY, JWSPacker, JsonSchemaValidator, KMS, KmsKeyType, LDParser, LinkedMultiQueryInputs, LinkedMultiQueryPubSignals, LocalStoragePrivateKeyStore, MerkleTreeIndexedDBStorage, MerkleTreeLocalStorage, MerkleTreeType, MerklizedRootPosition, MessageBus, MessageHandler, NativeProver, OnChainResolver, OnChainRevocationStorage, OnChainZKPVerifier, OnchainIssuer, Operators, constants as PROTOCOL_CONSTANTS, PackageManager, Parser, PaymentFeatures, PaymentHandler, PaymentRequestDataType, PaymentType, PlainPacker, ProofNode, ProofPurpose, ProofService, ProofType, PubSignalsVerifier, Query, QueryOperators, RHSResolver, RefreshHandler, RefreshServiceType, RevocationStatusHandler, SDK_EVENTS, Scalar, SearchError, Sec256k1Provider, StandardJSONCredentialsQueryFilter, StateTransitionInputs, StateTransitionPubSignals, SubjectPosition, SupportedCurrencies, SupportedPaymentProofType, TransactionService, ValueProof, Vector, VerifiableConstants, VerificationHandlerFunc, W3CCredential, XSDNS, ZKPPacker, availableTypesOperators, base58ToBytes$1 as base58ToBytes, base64ToBytes$1 as base64ToBytes, base64UrlToBytes, bigIntArrayToStringArray, bigIntCompare, buildAccept, buildDIDFromEthPubKey, buildFieldPath, buildTreeState, buildVerifierId, byteDecoder, byteEncoder, bytesToBase58$1 as bytesToBase58, bytesToBase64, bytesToBase64url$1 as bytesToBase64url, bytesToHex$3 as bytesToHex, cacheLoader, calculateCoreSchemaHash, calculateQueryHashV2, calculateQueryHashV3, checkCircuitOperator, checkCircuitQueriesLength, checkDataInField, checkQueryRequest, circuitValidator, comparatorOptions, createAuthorizationRequest, createAuthorizationRequestWithMessage, createPayment, createPaymentRequest, createProposal, createProposalRequest, createSchemaHash, createVerifiablePresentation, credentialSubjectKey, dataFillsSlot, decodeBase64url$1 as decodeBase64url, defaultEthConnectionConfig, defaultMTLevels, defaultMTLevelsClaim, defaultMTLevelsOnChain, defaultValueArraySize, defineMerklizedRootPosition, encodeBase64url, existenceToInt, extractProof, extractPublicKeyBytes, factoryComparer, fieldToByteArray, fieldValueFromVerifiablePresentation, fillCoreClaimSlot, fillSlot, findCredentialType, findValue, generateProfileDID, getERC20Decimals, getFieldSlotIndex, getKMSIdByAuthCredential, getNodeAuxValue, getNodesRepresentation, getOperatorNameByValue, getPermitSignature, getProperties, getSerializationAttrFromContext, getSerializationAttrFromParsedContext, getUserDIDFromCredential, hexToBytes$3 as hexToBytes, isEthereumIdentity, isGenesisState, isGenesisStateId, isIssuerGenesis, isValidOperation, keyPath, mergeObjects, parseAcceptProfile, parseCoreClaimSlots, parseCredentialSubject, parseQueriesMetadata, parseQueryMetadata, parseSerializationAttr, prepareCircuitArrayValues, prepareSiblingsStr, processZeroKnowledgeProofRequests, pushHashesToRHS, resolveDIDDocumentAuth, resolveDidDocument, resolvePath, resolveVerificationMethods, strMTHex, stringByPath, subjectPositionIndex, swapEndianness, toClaimNonRevStatus, toGISTProof, toRevocationStatus, transformQueryValueToBigInts, userStateError, validateDIDDocumentAuth, validateDisclosureNativeSDSupport, validateDisclosureV2Circuit, validateEmptyCredentialSubjectNoopNativeSupport, validateEmptyCredentialSubjectV2Circuit, validateOperators, validateTreeState, verifyEIP712TypedData, verifyExpiresTime, verifyFieldValueInclusionNativeExistsSupport, verifyFieldValueInclusionV2, witnessBuilder };
|
|
64048
|
+
export { AbstractMessageHandler, AbstractPrivateKeyStore, AgentResolver, AtomicQueryMTPV2Inputs, AtomicQueryMTPV2OnChainInputs, AtomicQueryMTPV2OnChainPubSignals, AtomicQueryMTPV2PubSignals, AtomicQuerySigV2Inputs, AtomicQuerySigV2OnChainCircuitInputs, AtomicQuerySigV2OnChainInputs, AtomicQuerySigV2OnChainPubSignals, AtomicQuerySigV2PubSignals, AtomicQueryV3Inputs, AtomicQueryV3OnChainInputs, AtomicQueryV3OnChainPubSignals, AtomicQueryV3PubSignals, AuthHandler, AuthV2Inputs, AuthV2PubSignals, BJJSignatureProof2021, BaseConfig, BjjProvider, BrowserDataSource, CircuitClaim, CircuitError, CircuitId, CircuitStorage, ContractRequestHandler, CredentialOfferStatus, CredentialProposalHandler, CredentialStatusPublisherRegistry, CredentialStatusResolverRegistry, CredentialStatusType, CredentialStorage, CredentialWallet, DIDDocumentJSONSchema, DIDDocumentSignature, DataPrepareHandlerFunc, DidDocumentCredentialStatusResolver, DidResolverStateReadonlyStorage, DiscoverFeatureQueryType, DiscoveryProtocolFeatureType, DiscoveryProtocolHandler, DisplayMethodType, Ed25519Provider, ErrorEmptyAuthClaimNonRevProof, ErrorEmptyAuthClaimProof, ErrorEmptyChallengeSignature, ErrorEmptyClaimNonRevProof, ErrorEmptyClaimProof, ErrorEmptyClaimSignature, ErrorEmptyIssuerAuthClaimNonRevProof, ErrorEmptyIssuerAuthClaimProof, ErrorUserStateInRelayClaimProof, EthStateStorage, FSCircuitStorage, FetchHandler, FilterQuery, FunctionSignatures, Iden3OnchainSmtCredentialStatusPublisher, Iden3SmtRhsCredentialStatusPublisher, Iden3SparseMerkleTreeProof, IdentityStorage, IdentityWallet, InMemoryDataSource, InMemoryMerkleTreeStorage, InMemoryPrivateKeyStore, IndexedDBDataSource, IndexedDBPrivateKeyStore, InputGenerator, IssuerResolver, JSON_SCHEMA_VALIDATORS_REGISTRY, JWSPacker, JsonSchemaValidator, KMS, KmsKeyType, LDParser, LinkedMultiQueryInputs, LinkedMultiQueryPubSignals, LocalStoragePrivateKeyStore, MerkleTreeIndexedDBStorage, MerkleTreeLocalStorage, MerkleTreeType, MerklizedRootPosition, MessageBus, MessageHandler, NativeProver, OnChainResolver, OnChainRevocationStorage, OnChainZKPVerifier, OnchainIssuer, Operators, constants as PROTOCOL_CONSTANTS, PackageManager, Parser, PaymentFeatures, PaymentHandler, PaymentRequestDataType, PaymentType, PlainPacker, ProofNode, ProofPurpose, ProofService, ProofType, PubSignalsVerifier, Query, QueryOperators, RHSResolver, RefreshHandler, RefreshServiceType, RevocationStatusHandler, SDK_EVENTS, Scalar, SearchError, Sec256k1Provider, StandardJSONCredentialsQueryFilter, StateTransitionInputs, StateTransitionPubSignals, SubjectPosition, SupportedCurrencies, SupportedPaymentProofType, TransactionService, ValueProof, Vector, VerifiableConstants, VerificationHandlerFunc, W3CCredential, XSDNS, ZKPPacker, availableTypesOperators, base58ToBytes$1 as base58ToBytes, base64ToBytes$1 as base64ToBytes, base64UrlToBytes, bigIntArrayToStringArray, bigIntCompare, buildAccept, buildDIDFromEthPubKey, buildFieldPath, buildTreeState, buildVerifierId, byteDecoder, byteEncoder, bytesToBase58$1 as bytesToBase58, bytesToBase64, bytesToBase64url$1 as bytesToBase64url, bytesToHex$3 as bytesToHex, cacheLoader, calculateCoreSchemaHash, calculateQueryHashV2, calculateQueryHashV3, checkCircuitOperator, checkCircuitQueriesLength, checkDataInField, checkQueryRequest, circuitValidator, comparatorOptions, createAuthorizationRequest, createAuthorizationRequestWithMessage, createDiscoveryFeatureDiscloseMessage, createDiscoveryFeatureQueryMessage, createPayment, createPaymentRequest, createProposal, createProposalRequest, createSchemaHash, createVerifiablePresentation, credentialSubjectKey, dataFillsSlot, decodeBase64url$1 as decodeBase64url, defaultEthConnectionConfig, defaultMTLevels, defaultMTLevelsClaim, defaultMTLevelsOnChain, defaultValueArraySize, defineMerklizedRootPosition, encodeBase64url, existenceToInt, extractProof, extractPublicKeyBytes, factoryComparer, fieldToByteArray, fieldValueFromVerifiablePresentation, fillCoreClaimSlot, fillSlot, findCredentialType, findValue, generateProfileDID, getERC20Decimals, getFieldSlotIndex, getKMSIdByAuthCredential, getNodeAuxValue, getNodesRepresentation, getOperatorNameByValue, getPermitSignature, getProperties, getSerializationAttrFromContext, getSerializationAttrFromParsedContext, getUserDIDFromCredential, hexToBytes$3 as hexToBytes, isEthereumIdentity, isGenesisState, isGenesisStateId, isIssuerGenesis, isValidOperation, keyPath, mergeObjects, parseAcceptProfile, parseCoreClaimSlots, parseCredentialSubject, parseQueriesMetadata, parseQueryMetadata, parseSerializationAttr, prepareCircuitArrayValues, prepareSiblingsStr, processZeroKnowledgeProofRequests, pushHashesToRHS, resolveDIDDocumentAuth, resolveDidDocument, resolvePath, resolveVerificationMethods, strMTHex, stringByPath, subjectPositionIndex, swapEndianness, toClaimNonRevStatus, toGISTProof, toRevocationStatus, transformQueryValueToBigInts, userStateError, validateDIDDocumentAuth, validateDisclosureNativeSDSupport, validateDisclosureV2Circuit, validateEmptyCredentialSubjectNoopNativeSupport, validateEmptyCredentialSubjectV2Circuit, validateOperators, validateTreeState, verifyEIP712TypedData, verifyExpiresTime, verifyFieldValueInclusionNativeExistsSupport, verifyFieldValueInclusionV2, witnessBuilder };
|
|
63857
64049
|
//# sourceMappingURL=index.js.map
|