@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
|
@@ -58425,6 +58425,7 @@ var PolygonIdSdk = (function (exports) {
|
|
|
58425
58425
|
}
|
|
58426
58426
|
|
|
58427
58427
|
const IDEN3_PROTOCOL = 'https://iden3-communication.io/';
|
|
58428
|
+
const DIDCOMM_PROTOCOL = 'https://didcomm.org/';
|
|
58428
58429
|
/**
|
|
58429
58430
|
* Constants for Iden3 protocol
|
|
58430
58431
|
*/
|
|
@@ -58468,7 +58469,11 @@ var PolygonIdSdk = (function (exports) {
|
|
|
58468
58469
|
// PaymentRequestMessageType is type for payment-request message
|
|
58469
58470
|
PAYMENT_REQUEST_MESSAGE_TYPE: `${IDEN3_PROTOCOL}credentials/0.1/payment-request`,
|
|
58470
58471
|
// PaymentMessageType is type for payment message
|
|
58471
|
-
PAYMENT_MESSAGE_TYPE: `${IDEN3_PROTOCOL}credentials/0.1/payment
|
|
58472
|
+
PAYMENT_MESSAGE_TYPE: `${IDEN3_PROTOCOL}credentials/0.1/payment`,
|
|
58473
|
+
// DiscoveryProtocolQueriesMessageType is type for didcomm discovery protocol queries
|
|
58474
|
+
DISCOVERY_PROTOCOL_QUERIES_MESSAGE_TYPE: `${DIDCOMM_PROTOCOL}discover-features/2.0/queries`,
|
|
58475
|
+
// DiscoveryProtocolDiscloseMessageType is type for didcomm discovery protocol disclose
|
|
58476
|
+
DISCOVERY_PROTOCOL_DISCLOSE_MESSAGE_TYPE: `${DIDCOMM_PROTOCOL}discover-features/2.0/disclose`
|
|
58472
58477
|
});
|
|
58473
58478
|
/**
|
|
58474
58479
|
* Media types for iden3 comm communication protocol
|
|
@@ -80355,6 +80360,18 @@ var PolygonIdSdk = (function (exports) {
|
|
|
80355
80360
|
constructor() {
|
|
80356
80361
|
this.packers = new Map();
|
|
80357
80362
|
}
|
|
80363
|
+
/** {@inheritDoc IPackageManager.getSupportedProfiles} */
|
|
80364
|
+
getSupportedProfiles() {
|
|
80365
|
+
const acceptProfiles = [];
|
|
80366
|
+
const mediaTypes = this.getSupportedMediaTypes();
|
|
80367
|
+
for (const mediaType of mediaTypes) {
|
|
80368
|
+
const p = this.packers.get(mediaType);
|
|
80369
|
+
if (p) {
|
|
80370
|
+
acceptProfiles.push(...p.getSupportedProfiles());
|
|
80371
|
+
}
|
|
80372
|
+
}
|
|
80373
|
+
return [...new Set(acceptProfiles)];
|
|
80374
|
+
}
|
|
80358
80375
|
/** {@inheritDoc IPackageManager.isProfileSupported} */
|
|
80359
80376
|
isProfileSupported(mediaType, profile) {
|
|
80360
80377
|
const p = this.packers.get(mediaType);
|
|
@@ -80668,6 +80685,9 @@ var PolygonIdSdk = (function (exports) {
|
|
|
80668
80685
|
this.provingParamsMap = provingParamsMap;
|
|
80669
80686
|
this.verificationParamsMap = verificationParamsMap;
|
|
80670
80687
|
this._opts = _opts;
|
|
80688
|
+
this.supportedProtocolVersions = [ProtocolVersion.V1];
|
|
80689
|
+
this.supportedAlgorithms = [AcceptJwzAlgorithms.Groth16];
|
|
80690
|
+
this.supportedCircuitIds = [AcceptAuthCircuits.AuthV2];
|
|
80671
80691
|
}
|
|
80672
80692
|
/**
|
|
80673
80693
|
* Packs a basic message using the specified parameters.
|
|
@@ -80729,28 +80749,23 @@ var PolygonIdSdk = (function (exports) {
|
|
|
80729
80749
|
}
|
|
80730
80750
|
/** {@inheritDoc IPacker.getSupportedProfiles} */
|
|
80731
80751
|
getSupportedProfiles() {
|
|
80732
|
-
return
|
|
80733
|
-
`env=${this.mediaType()}&alg=${this.getSupportedAlgorithms().join(',')}&circuitIds=${this.getSupportedCircuitIds().join(',')}`
|
|
80734
|
-
];
|
|
80752
|
+
return this.supportedProtocolVersions.map((v) => `${v};env=${this.mediaType()};alg=${this.supportedAlgorithms.join(',')};circuitIds=${this.supportedCircuitIds.join(',')}`);
|
|
80735
80753
|
}
|
|
80736
80754
|
/** {@inheritDoc IPacker.isProfileSupported} */
|
|
80737
80755
|
isProfileSupported(profile) {
|
|
80738
|
-
const { env, circuits, alg } = parseAcceptProfile(profile);
|
|
80756
|
+
const { protocolVersion, env, circuits, alg } = parseAcceptProfile(profile);
|
|
80757
|
+
if (!this.supportedProtocolVersions.includes(protocolVersion)) {
|
|
80758
|
+
return false;
|
|
80759
|
+
}
|
|
80739
80760
|
if (env !== this.mediaType()) {
|
|
80740
80761
|
return false;
|
|
80741
80762
|
}
|
|
80742
|
-
const supportedCircuitIds = this.
|
|
80763
|
+
const supportedCircuitIds = this.supportedCircuitIds;
|
|
80743
80764
|
const circuitIdSupported = !circuits?.length || circuits.some((c) => supportedCircuitIds.includes(c));
|
|
80744
|
-
const supportedAlgArr = this.
|
|
80765
|
+
const supportedAlgArr = this.supportedAlgorithms;
|
|
80745
80766
|
const algSupported = !alg?.length || alg.some((a) => supportedAlgArr.includes(a));
|
|
80746
80767
|
return algSupported && circuitIdSupported;
|
|
80747
80768
|
}
|
|
80748
|
-
getSupportedAlgorithms() {
|
|
80749
|
-
return [AcceptJwzAlgorithms.Groth16];
|
|
80750
|
-
}
|
|
80751
|
-
getSupportedCircuitIds() {
|
|
80752
|
-
return [AcceptAuthCircuits.AuthV2];
|
|
80753
|
-
}
|
|
80754
80769
|
}
|
|
80755
80770
|
const verifySender = async (token, msg) => {
|
|
80756
80771
|
switch (token.circuitId) {
|
|
@@ -80784,6 +80799,9 @@ var PolygonIdSdk = (function (exports) {
|
|
|
80784
80799
|
* @implements implements IPacker interface
|
|
80785
80800
|
*/
|
|
80786
80801
|
class PlainPacker {
|
|
80802
|
+
constructor() {
|
|
80803
|
+
this.supportedProtocolVersions = [ProtocolVersion.V1];
|
|
80804
|
+
}
|
|
80787
80805
|
/**
|
|
80788
80806
|
* Packs a basic message using the specified parameters.
|
|
80789
80807
|
*
|
|
@@ -80827,11 +80845,14 @@ var PolygonIdSdk = (function (exports) {
|
|
|
80827
80845
|
}
|
|
80828
80846
|
/** {@inheritDoc IPacker.getSupportedProfiles} */
|
|
80829
80847
|
getSupportedProfiles() {
|
|
80830
|
-
return
|
|
80848
|
+
return this.supportedProtocolVersions.map((v) => `${v};env=${this.mediaType()}`);
|
|
80831
80849
|
}
|
|
80832
80850
|
/** {@inheritDoc IPacker.isProfileSupported} */
|
|
80833
80851
|
isProfileSupported(profile) {
|
|
80834
|
-
const { env, circuits, alg } = parseAcceptProfile(profile);
|
|
80852
|
+
const { protocolVersion, env, circuits, alg } = parseAcceptProfile(profile);
|
|
80853
|
+
if (!this.supportedProtocolVersions.includes(protocolVersion)) {
|
|
80854
|
+
return false;
|
|
80855
|
+
}
|
|
80835
80856
|
if (env !== this.mediaType()) {
|
|
80836
80857
|
return false;
|
|
80837
80858
|
}
|
|
@@ -80863,6 +80884,8 @@ var PolygonIdSdk = (function (exports) {
|
|
|
80863
80884
|
constructor(_kms, _documentResolver) {
|
|
80864
80885
|
this._kms = _kms;
|
|
80865
80886
|
this._documentResolver = _documentResolver;
|
|
80887
|
+
this.supportedAlgorithms = [AcceptJwsAlgorithms.ES256K, AcceptJwsAlgorithms.ES256KR];
|
|
80888
|
+
this.supportedProtocolVersions = [ProtocolVersion.V1];
|
|
80866
80889
|
}
|
|
80867
80890
|
/**
|
|
80868
80891
|
* Packs the given payload and returns a promise that resolves to the packed data.
|
|
@@ -80925,24 +80948,23 @@ var PolygonIdSdk = (function (exports) {
|
|
|
80925
80948
|
}
|
|
80926
80949
|
/** {@inheritDoc IPacker.getSupportedProfiles} */
|
|
80927
80950
|
getSupportedProfiles() {
|
|
80928
|
-
return
|
|
80951
|
+
return this.supportedProtocolVersions.map((v) => `${v};env=${this.mediaType()};alg=${this.supportedAlgorithms.join(',')}`);
|
|
80929
80952
|
}
|
|
80930
80953
|
/** {@inheritDoc IPacker.isProfileSupported} */
|
|
80931
80954
|
isProfileSupported(profile) {
|
|
80932
|
-
const { env, circuits, alg } = parseAcceptProfile(profile);
|
|
80955
|
+
const { protocolVersion, env, circuits, alg } = parseAcceptProfile(profile);
|
|
80956
|
+
if (!this.supportedProtocolVersions.includes(protocolVersion)) {
|
|
80957
|
+
return false;
|
|
80958
|
+
}
|
|
80933
80959
|
if (env !== this.mediaType()) {
|
|
80934
80960
|
return false;
|
|
80935
80961
|
}
|
|
80936
80962
|
if (circuits) {
|
|
80937
80963
|
throw new Error(`Circuits are not supported for ${env} media type`);
|
|
80938
80964
|
}
|
|
80939
|
-
const
|
|
80940
|
-
const algSupported = !alg?.length || alg.some((a) => supportedAlgArr.includes(a));
|
|
80965
|
+
const algSupported = !alg?.length || alg.some((a) => this.supportedAlgorithms.includes(a));
|
|
80941
80966
|
return algSupported;
|
|
80942
80967
|
}
|
|
80943
|
-
getSupportedAlgorithms() {
|
|
80944
|
-
return [AcceptJwsAlgorithms.ES256K, AcceptJwsAlgorithms.ES256KR];
|
|
80945
|
-
}
|
|
80946
80968
|
async resolveDidDoc(from) {
|
|
80947
80969
|
let didDocument;
|
|
80948
80970
|
try {
|
|
@@ -81018,6 +81040,20 @@ var PolygonIdSdk = (function (exports) {
|
|
|
81018
81040
|
CredentialOfferStatus["Rejected"] = "rejected";
|
|
81019
81041
|
})(exports.CredentialOfferStatus || (exports.CredentialOfferStatus = {}));
|
|
81020
81042
|
|
|
81043
|
+
/** @beta DiscoverFeatureQueryType is enum for query type fields */
|
|
81044
|
+
exports.DiscoverFeatureQueryType = void 0;
|
|
81045
|
+
(function (DiscoverFeatureQueryType) {
|
|
81046
|
+
DiscoverFeatureQueryType["FeatureType"] = "feature-type";
|
|
81047
|
+
})(exports.DiscoverFeatureQueryType || (exports.DiscoverFeatureQueryType = {}));
|
|
81048
|
+
/** @beta DiscoveryProtocolFeatureType is enum for supported feature-types */
|
|
81049
|
+
exports.DiscoveryProtocolFeatureType = void 0;
|
|
81050
|
+
(function (DiscoveryProtocolFeatureType) {
|
|
81051
|
+
DiscoveryProtocolFeatureType["Accept"] = "accept";
|
|
81052
|
+
DiscoveryProtocolFeatureType["Protocol"] = "protocol";
|
|
81053
|
+
DiscoveryProtocolFeatureType["GoalCode"] = "goal-code";
|
|
81054
|
+
DiscoveryProtocolFeatureType["Header"] = "header";
|
|
81055
|
+
})(exports.DiscoveryProtocolFeatureType || (exports.DiscoveryProtocolFeatureType = {}));
|
|
81056
|
+
|
|
81021
81057
|
/**
|
|
81022
81058
|
* Groups the ZeroKnowledgeProofRequest objects based on their groupId.
|
|
81023
81059
|
* Returns a Map where the key is the groupId and the value is an object containing the query and linkNonce.
|
|
@@ -81463,32 +81499,24 @@ var PolygonIdSdk = (function (exports) {
|
|
|
81463
81499
|
}
|
|
81464
81500
|
getSupportedMediaTypeByProfile(ctx, responseType, profile) {
|
|
81465
81501
|
let mediaType;
|
|
81466
|
-
if (profile?.length) {
|
|
81467
|
-
|
|
81468
|
-
|
|
81469
|
-
|
|
81470
|
-
|
|
81471
|
-
|
|
81472
|
-
|
|
81473
|
-
|
|
81474
|
-
(responseTypeVersion < 1 || responseTypeVersion >= 2))) {
|
|
81475
|
-
continue;
|
|
81476
|
-
}
|
|
81477
|
-
// 2. check packer support
|
|
81478
|
-
if (this._packerMgr.isProfileSupported(env, acceptProfile)) {
|
|
81479
|
-
supportedMediaTypes.push(env);
|
|
81480
|
-
}
|
|
81481
|
-
}
|
|
81482
|
-
if (!supportedMediaTypes.length) {
|
|
81483
|
-
throw new Error('no packer with profile which meets `accept` header requirements');
|
|
81484
|
-
}
|
|
81485
|
-
mediaType = supportedMediaTypes[0];
|
|
81486
|
-
if (ctx.mediaType && supportedMediaTypes.includes(ctx.mediaType)) {
|
|
81487
|
-
mediaType = ctx.mediaType;
|
|
81502
|
+
if (!profile?.length) {
|
|
81503
|
+
return ctx.mediaType || MediaType.ZKPMessage;
|
|
81504
|
+
}
|
|
81505
|
+
const supportedMediaTypes = [];
|
|
81506
|
+
for (const acceptProfile of profile) {
|
|
81507
|
+
const { env } = parseAcceptProfile(acceptProfile);
|
|
81508
|
+
if (this._packerMgr.isProfileSupported(env, acceptProfile)) {
|
|
81509
|
+
supportedMediaTypes.push(env);
|
|
81488
81510
|
}
|
|
81489
81511
|
}
|
|
81490
|
-
|
|
81491
|
-
|
|
81512
|
+
if (!supportedMediaTypes.length) {
|
|
81513
|
+
throw new Error('no packer with profile which meets `accept` header requirements');
|
|
81514
|
+
}
|
|
81515
|
+
mediaType = supportedMediaTypes.includes(MediaType.ZKPMessage)
|
|
81516
|
+
? MediaType.ZKPMessage
|
|
81517
|
+
: supportedMediaTypes[0];
|
|
81518
|
+
if (ctx.mediaType && supportedMediaTypes.includes(ctx.mediaType)) {
|
|
81519
|
+
mediaType = ctx.mediaType;
|
|
81492
81520
|
}
|
|
81493
81521
|
return mediaType;
|
|
81494
81522
|
}
|
|
@@ -82695,6 +82723,170 @@ var PolygonIdSdk = (function (exports) {
|
|
|
82695
82723
|
}
|
|
82696
82724
|
}
|
|
82697
82725
|
|
|
82726
|
+
/**
|
|
82727
|
+
* @beta
|
|
82728
|
+
* createDiscoveryFeatureQueryMessage is a function to create didcomm protocol discovery-feature query message
|
|
82729
|
+
* @param opts - discovery-feature query options
|
|
82730
|
+
* @returns `DiscoverFeatureQueriesMessage`
|
|
82731
|
+
*/
|
|
82732
|
+
function createDiscoveryFeatureQueryMessage(queries, opts) {
|
|
82733
|
+
const uuidv4 = v4();
|
|
82734
|
+
return {
|
|
82735
|
+
id: uuidv4,
|
|
82736
|
+
thid: uuidv4,
|
|
82737
|
+
typ: MediaType.PlainMessage,
|
|
82738
|
+
type: PROTOCOL_MESSAGE_TYPE.DISCOVERY_PROTOCOL_QUERIES_MESSAGE_TYPE,
|
|
82739
|
+
body: {
|
|
82740
|
+
queries
|
|
82741
|
+
},
|
|
82742
|
+
from: opts?.from,
|
|
82743
|
+
to: opts?.to,
|
|
82744
|
+
created_time: b$4(new Date()),
|
|
82745
|
+
expires_time: opts?.expires_time
|
|
82746
|
+
};
|
|
82747
|
+
}
|
|
82748
|
+
/**
|
|
82749
|
+
* @beta
|
|
82750
|
+
* createDiscoveryFeatureDiscloseMessage is a function to create didcomm protocol discovery-feature disclose message
|
|
82751
|
+
* @param {DiscoverFeatureDisclosure[]} disclosures - array of disclosures
|
|
82752
|
+
* @param opts - basic message options
|
|
82753
|
+
* @returns `DiscoverFeatureQueriesMessage`
|
|
82754
|
+
*/
|
|
82755
|
+
function createDiscoveryFeatureDiscloseMessage(disclosures, opts) {
|
|
82756
|
+
const uuidv4 = v4();
|
|
82757
|
+
return {
|
|
82758
|
+
id: uuidv4,
|
|
82759
|
+
typ: MediaType.PlainMessage,
|
|
82760
|
+
thid: uuidv4,
|
|
82761
|
+
type: PROTOCOL_MESSAGE_TYPE.DISCOVERY_PROTOCOL_DISCLOSE_MESSAGE_TYPE,
|
|
82762
|
+
body: {
|
|
82763
|
+
disclosures
|
|
82764
|
+
},
|
|
82765
|
+
from: opts?.from,
|
|
82766
|
+
to: opts?.to,
|
|
82767
|
+
created_time: b$4(new Date()),
|
|
82768
|
+
expires_time: opts?.expires_time
|
|
82769
|
+
};
|
|
82770
|
+
}
|
|
82771
|
+
/**
|
|
82772
|
+
*
|
|
82773
|
+
* Handler for discovery protocol
|
|
82774
|
+
*
|
|
82775
|
+
* @public
|
|
82776
|
+
* @beta
|
|
82777
|
+
* @class DiscoveryProtocolHandler
|
|
82778
|
+
* @implements implements DiscoveryProtocolHandler interface
|
|
82779
|
+
*/
|
|
82780
|
+
class DiscoveryProtocolHandler extends AbstractMessageHandler {
|
|
82781
|
+
/**
|
|
82782
|
+
* Creates an instance of DiscoveryProtocolHandler.
|
|
82783
|
+
* @param {DiscoveryProtocolOptions} _options - discovery protocol options
|
|
82784
|
+
*/
|
|
82785
|
+
constructor(_options) {
|
|
82786
|
+
super();
|
|
82787
|
+
this._options = _options;
|
|
82788
|
+
const headers = [
|
|
82789
|
+
'id',
|
|
82790
|
+
'typ',
|
|
82791
|
+
'type',
|
|
82792
|
+
'thid',
|
|
82793
|
+
'body',
|
|
82794
|
+
'from',
|
|
82795
|
+
'to',
|
|
82796
|
+
'created_time',
|
|
82797
|
+
'expires_time'
|
|
82798
|
+
];
|
|
82799
|
+
if (!_options.headers) {
|
|
82800
|
+
_options.headers = headers;
|
|
82801
|
+
}
|
|
82802
|
+
}
|
|
82803
|
+
/**
|
|
82804
|
+
* @inheritdoc IProtocolMessageHandler#handle
|
|
82805
|
+
*/
|
|
82806
|
+
async handle(message, context) {
|
|
82807
|
+
switch (message.type) {
|
|
82808
|
+
case PROTOCOL_MESSAGE_TYPE.DISCOVERY_PROTOCOL_QUERIES_MESSAGE_TYPE:
|
|
82809
|
+
return await this.handleDiscoveryQuery(message, context);
|
|
82810
|
+
default:
|
|
82811
|
+
return super.handle(message, context);
|
|
82812
|
+
}
|
|
82813
|
+
}
|
|
82814
|
+
/**
|
|
82815
|
+
* @inheritdoc IDiscoveryProtocolHandler#handleDiscoveryQuery
|
|
82816
|
+
*/
|
|
82817
|
+
async handleDiscoveryQuery(message, opts) {
|
|
82818
|
+
if (!opts?.allowExpiredMessages) {
|
|
82819
|
+
verifyExpiresTime(message);
|
|
82820
|
+
}
|
|
82821
|
+
const disclosures = [];
|
|
82822
|
+
for (const query of message.body.queries) {
|
|
82823
|
+
disclosures.push(...this.handleQuery(query));
|
|
82824
|
+
}
|
|
82825
|
+
return Promise.resolve(createDiscoveryFeatureDiscloseMessage(disclosures, {
|
|
82826
|
+
to: message.from,
|
|
82827
|
+
from: message.to,
|
|
82828
|
+
expires_time: opts?.disclosureExpiresDate
|
|
82829
|
+
? b$4(opts.disclosureExpiresDate)
|
|
82830
|
+
: undefined
|
|
82831
|
+
}));
|
|
82832
|
+
}
|
|
82833
|
+
handleQuery(query) {
|
|
82834
|
+
let result = [];
|
|
82835
|
+
switch (query[exports.DiscoverFeatureQueryType.FeatureType]) {
|
|
82836
|
+
case exports.DiscoveryProtocolFeatureType.Accept:
|
|
82837
|
+
result = this.handleAcceptQuery();
|
|
82838
|
+
break;
|
|
82839
|
+
case exports.DiscoveryProtocolFeatureType.Protocol:
|
|
82840
|
+
result = this.handleProtocolQuery();
|
|
82841
|
+
break;
|
|
82842
|
+
case exports.DiscoveryProtocolFeatureType.GoalCode:
|
|
82843
|
+
result = this.handleGoalCodeQuery();
|
|
82844
|
+
break;
|
|
82845
|
+
case exports.DiscoveryProtocolFeatureType.Header:
|
|
82846
|
+
result = this.handleHeaderQuery();
|
|
82847
|
+
break;
|
|
82848
|
+
}
|
|
82849
|
+
return this.handleMatch(result, query.match);
|
|
82850
|
+
}
|
|
82851
|
+
handleAcceptQuery() {
|
|
82852
|
+
const acceptProfiles = this._options.packageManager.getSupportedProfiles();
|
|
82853
|
+
return acceptProfiles.map((profile) => ({
|
|
82854
|
+
[exports.DiscoverFeatureQueryType.FeatureType]: exports.DiscoveryProtocolFeatureType.Accept,
|
|
82855
|
+
id: profile
|
|
82856
|
+
}));
|
|
82857
|
+
}
|
|
82858
|
+
handleProtocolQuery() {
|
|
82859
|
+
return (this._options.protocols?.map((protocol) => ({
|
|
82860
|
+
[exports.DiscoverFeatureQueryType.FeatureType]: exports.DiscoveryProtocolFeatureType.Protocol,
|
|
82861
|
+
id: protocol
|
|
82862
|
+
})) ?? []);
|
|
82863
|
+
}
|
|
82864
|
+
handleGoalCodeQuery() {
|
|
82865
|
+
return (this._options.goalCodes?.map((goalCode) => ({
|
|
82866
|
+
[exports.DiscoverFeatureQueryType.FeatureType]: exports.DiscoveryProtocolFeatureType.GoalCode,
|
|
82867
|
+
id: goalCode
|
|
82868
|
+
})) ?? []);
|
|
82869
|
+
}
|
|
82870
|
+
handleHeaderQuery() {
|
|
82871
|
+
return (this._options.headers?.map((header) => ({
|
|
82872
|
+
[exports.DiscoverFeatureQueryType.FeatureType]: exports.DiscoveryProtocolFeatureType.Header,
|
|
82873
|
+
id: header
|
|
82874
|
+
})) ?? []);
|
|
82875
|
+
}
|
|
82876
|
+
handleMatch(disclosures, match) {
|
|
82877
|
+
if (!match || match === '*') {
|
|
82878
|
+
return disclosures;
|
|
82879
|
+
}
|
|
82880
|
+
const regExp = this.wildcardToRegExp(match);
|
|
82881
|
+
return disclosures.filter((disclosure) => regExp.test(disclosure.id));
|
|
82882
|
+
}
|
|
82883
|
+
wildcardToRegExp(match) {
|
|
82884
|
+
// Escape special regex characters, then replace `*` with `.*`
|
|
82885
|
+
const regexPattern = match.replace(/[.+^${}()|[\]\\]/g, '\\$&').replace(/\*/g, '.*');
|
|
82886
|
+
return new RegExp(`^${regexPattern}$`);
|
|
82887
|
+
}
|
|
82888
|
+
}
|
|
82889
|
+
|
|
82698
82890
|
const allOperations = Object.values(QueryOperators);
|
|
82699
82891
|
const v2Operations = [
|
|
82700
82892
|
exports.Operators.NOOP,
|
|
@@ -84770,6 +84962,7 @@ var PolygonIdSdk = (function (exports) {
|
|
|
84770
84962
|
exports.DataPrepareHandlerFunc = DataPrepareHandlerFunc;
|
|
84771
84963
|
exports.DidDocumentCredentialStatusResolver = DidDocumentCredentialStatusResolver;
|
|
84772
84964
|
exports.DidResolverStateReadonlyStorage = DidResolverStateReadonlyStorage;
|
|
84965
|
+
exports.DiscoveryProtocolHandler = DiscoveryProtocolHandler;
|
|
84773
84966
|
exports.Ed25519Provider = Ed25519Provider;
|
|
84774
84967
|
exports.ErrorEmptyAuthClaimNonRevProof = ErrorEmptyAuthClaimNonRevProof;
|
|
84775
84968
|
exports.ErrorEmptyAuthClaimProof = ErrorEmptyAuthClaimProof;
|
|
@@ -84869,6 +85062,8 @@ var PolygonIdSdk = (function (exports) {
|
|
|
84869
85062
|
exports.core = index$1;
|
|
84870
85063
|
exports.createAuthorizationRequest = createAuthorizationRequest;
|
|
84871
85064
|
exports.createAuthorizationRequestWithMessage = createAuthorizationRequestWithMessage;
|
|
85065
|
+
exports.createDiscoveryFeatureDiscloseMessage = createDiscoveryFeatureDiscloseMessage;
|
|
85066
|
+
exports.createDiscoveryFeatureQueryMessage = createDiscoveryFeatureQueryMessage;
|
|
84872
85067
|
exports.createPayment = createPayment;
|
|
84873
85068
|
exports.createPaymentRequest = createPaymentRequest;
|
|
84874
85069
|
exports.createProposal = createProposal;
|