@0xpolygonid/js-sdk 1.40.2 → 1.40.3

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.
@@ -69,7 +69,10 @@ export interface ICredentialProposalHandler {
69
69
  }>;
70
70
  }
71
71
  /** @beta ProposalRequestHandlerOptions represents proposal-request handler options */
72
- export type ProposalRequestHandlerOptions = BasicHandlerOptions;
72
+ export type ProposalRequestHandlerOptions = BasicHandlerOptions & {
73
+ /** When true, bypasses wallet credential search and always creates a new proposal */
74
+ forceCredentialReissue?: boolean;
75
+ };
73
76
  /** @beta ProposalHandlerOptions represents proposal handler options */
74
77
  export type ProposalHandlerOptions = BasicHandlerOptions & {
75
78
  proposalRequest?: ProposalRequestMessage;
@@ -1 +1 @@
1
- {"version":3,"file":"credential-proposal.d.ts","sourceRoot":"","sources":["../../../../src/iden3comm/handlers/credential-proposal.ts"],"names":[],"mappings":"AACA,OAAO,EACL,UAAU,EACV,YAAY,EAGZ,WAAW,EACX,eAAe,EAChB,MAAM,UAAU,CAAC;AAElB,OAAO,EAAE,GAAG,EAAoB,MAAM,sBAAsB,CAAC;AAE7D,OAAO,EACL,QAAQ,EACR,sBAAsB,EACtB,eAAe,EACf,yBAAyB,EAC1B,MAAM,oCAAoC,CAAC;AAC5C,OAAO,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAGjD,OAAO,EACL,sBAAsB,EACtB,mBAAmB,EACnB,uBAAuB,EAExB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,mBAAmB,EAA+C,MAAM,UAAU,CAAC;AAE5F,wFAAwF;AACxF,MAAM,MAAM,8BAA8B,GAAG;IAC3C,WAAW,EAAE,yBAAyB,EAAE,CAAC;IACzC,OAAO,CAAC,EAAE,WAAW,CAAC;IACtB,YAAY,CAAC,EAAE,IAAI,CAAC;IACpB,WAAW,CAAC,EAAE,UAAU,EAAE,CAAC;CAC5B,CAAC;AAEF,yEAAyE;AACzE,MAAM,MA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ACvB,YAAY,EAAE,mBAAmB,CAAC;CACnC,CAAC;AAEF;;;;;;GAMG;AACH,qBAAa,yBACX,SAAQ,sBACR,YAAW,0BAA0B,EAAE,uBAAuB;IAW5D,OAAO,CAAC,QAAQ,CAAC,UAAU;IAC3B,OAAO,CAAC,QAAQ,CAAC,eAAe;IAChC,OAAO,CAAC,QAAQ,CAAC,OAAO;IAX1B;;;;;;OAMG;gBAGgB,UAAU,EAAE,eAAe,EAC3B,eAAe,EAAE,eAAe,EAChC,OAAO,EAAE,+BAA+B;IAK9C,MAAM,CACjB,OAAO,EAAE,YAAY,EACrB,OAAO,EAAE,6BAA6B,GACrC,OAAO,CAAC,YAAY,GAAG,IAAI,CAAC;IAY/B;;OAEG;IACG,oBAAoB,CAAC,OAAO,EAAE,UAAU,GAAG,OAAO,CAAC,sBAAsB,CAAC;YASlE,4BAA4B;IAgG1C;;OAEG;IACG,qBAAqB,CACzB,OAAO,EAAE,UAAU,EAEnB,IAAI,CAAC,EAAE,6BAA6B,GACnC,OAAO,CAAC,UAAU,CAAC;IAwBtB;;OAEG;IACG,cAAc,CAAC,QAAQ,EAAE,eAAe,EAAE,IAAI,CAAC,EAAE,sBAAsB;;;CAW9E"}
1
+ {"version":3,"file":"credential-proposal.d.ts","sourceRoot":"","sources":["../../../../src/iden3comm/handlers/credential-proposal.ts"],"names":[],"mappings":"AACA,OAAO,EACL,UAAU,EACV,YAAY,EAGZ,WAAW,EACX,eAAe,EAChB,MAAM,UAAU,CAAC;AAElB,OAAO,EAAE,GAAG,EAAoB,MAAM,sBAAsB,CAAC;AAE7D,OAAO,EACL,QAAQ,EACR,sBAAsB,EACtB,eAAe,EACf,yBAAyB,EAC1B,MAAM,oCAAoC,CAAC;AAC5C,OAAO,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAGjD,OAAO,EACL,sBAAsB,EACtB,mBAAmB,EACnB,uBAAuB,EAExB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,mBAAmB,EAA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sB,GAAG,mBAAmB,GAAG;IACzD,eAAe,CAAC,EAAE,sBAAsB,CAAC;CAC1C,CAAC;AAEF,0FAA0F;AAC1F,MAAM,MAAM,+BAA+B,GAAG;IAC5C,QAAQ,EAAE,MAAM,CAAC;IACjB,kBAAkB,EAAE,CAClB,OAAO,EAAE,MAAM,EACf,IAAI,EAAE,MAAM,EACZ,IAAI,CAAC,EAAE;QAAE,GAAG,CAAC,EAAE,YAAY,CAAA;KAAE,KAC1B,OAAO,CAAC,QAAQ,CAAC,CAAC;IACvB,YAAY,EAAE,mBAAmB,CAAC;CACnC,CAAC;AAEF;;;;;;GAMG;AACH,qBAAa,yBACX,SAAQ,sBACR,YAAW,0BAA0B,EAAE,uBAAuB;IAW5D,OAAO,CAAC,QAAQ,CAAC,UAAU;IAC3B,OAAO,CAAC,QAAQ,CAAC,eAAe;IAChC,OAAO,CAAC,QAAQ,CAAC,OAAO;IAX1B;;;;;;OAMG;gBAGgB,UAAU,EAAE,eAAe,EAC3B,eAAe,EAAE,eAAe,EAChC,OAAO,EAAE,+BAA+B;IAK9C,MAAM,CACjB,OAAO,EAAE,YAAY,EACrB,OAAO,EAAE,6BAA6B,GACrC,OAAO,CAAC,YAAY,GAAG,IAAI,CAAC;IAY/B;;OAEG;IACG,oBAAoB,CAAC,OAAO,EAAE,UAAU,GAAG,OAAO,CAAC,sBAAsB,CAAC;YASlE,4BAA4B;IAkG1C;;OAEG;IACG,qBAAqB,CACzB,OAAO,EAAE,UAAU,EAEnB,IAAI,CAAC,EAAE,6BAA6B,GACnC,OAAO,CAAC,UAAU,CAAC;IAwBtB;;OAEG;IACG,cAAc,CAAC,QAAQ,EAAE,eAAe,EAAE,IAAI,CAAC,EAAE,sBAAsB;;;CAW9E"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@0xpolygonid/js-sdk",
3
- "version": "1.40.2",
3
+ "version": "1.40.3",
4
4
  "description": "SDK to work with Polygon ID",
5
5
  "source": "./src/index.ts",
6
6
  "exports": {
@@ -148,7 +148,10 @@ export interface ICredentialProposalHandler {
148
148
  }
149
149
 
150
150
  /** @beta ProposalRequestHandlerOptions represents proposal-request handler options */
151
- export type ProposalRequestHandlerOptions = BasicHandlerOptions;
151
+ export type ProposalRequestHandlerOptions = BasicHandlerOptions & {
152
+ /** When true, bypasses wallet credential search and always creates a new proposal */
153
+ forceCredentialReissue?: boolean;
154
+ };
152
155
 
153
156
  /** @beta ProposalHandlerOptions represents proposal handler options */
154
157
  export type ProposalHandlerOptions = BasicHandlerOptions & {
@@ -246,50 +249,52 @@ export class CredentialProposalHandler
246
249
  // check if there is credentials in the wallet
247
250
  let credsFromWallet: W3CCredential[] = [];
248
251
 
249
- try {
250
- credsFromWallet = await this._identityWallet.credentialWallet.findByQuery({
251
- credentialSubject: {
252
- id: {
253
- $eq: proposalRequest.from
254
- }
255
- },
256
- type: cred.type,
257
- context: cred.context,
258
- allowedIssuers: [proposalRequest.to]
259
- });
260
- } catch (e) {
261
- if ((e as Error).message !== 'no credential satisfied query') {
262
- throw e;
263
- }
264
- }
265
-
266
- if (credsFromWallet.length) {
267
- const guid = uuid.v4();
268
- if (!credOfferMessage) {
269
- credOfferMessage = {
270
- id: guid,
271
- typ: this._params.packerParams.mediaType,
272
- type: PROTOCOL_MESSAGE_TYPE.CREDENTIAL_OFFER_MESSAGE_TYPE,
273
- thid: proposalRequest.thid ?? guid,
274
- body: {
275
- url: this._params.agentUrl,
276
- credentials: []
252
+ if (!ctx?.forceCredentialReissue) {
253
+ try {
254
+ credsFromWallet = await this._identityWallet.credentialWallet.findByQuery({
255
+ credentialSubject: {
256
+ id: {
257
+ $eq: proposalRequest.from
258
+ }
277
259
  },
278
- from: proposalRequest.to,
279
- to: proposalRequest.from
280
- };
260
+ type: cred.type,
261
+ context: cred.context,
262
+ allowedIssuers: [proposalRequest.to]
263
+ });
264
+ } catch (e) {
265
+ if ((e as Error).message !== 'no credential satisfied query') {
266
+ throw e;
267
+ }
281
268
  }
282
269
 
283
- credOfferMessage.body.credentials.push(
284
- ...credsFromWallet.map<CredentialOffer>((c) => ({
285
- id: c.id,
286
- description: ''
287
- }))
288
- );
289
- continue;
270
+ if (credsFromWallet.length) {
271
+ const guid = uuid.v4();
272
+ if (!credOfferMessage) {
273
+ credOfferMessage = {
274
+ id: guid,
275
+ typ: this._params.packerParams.mediaType,
276
+ type: PROTOCOL_MESSAGE_TYPE.CREDENTIAL_OFFER_MESSAGE_TYPE,
277
+ thid: proposalRequest.thid ?? guid,
278
+ body: {
279
+ url: this._params.agentUrl,
280
+ credentials: []
281
+ },
282
+ from: proposalRequest.to,
283
+ to: proposalRequest.from
284
+ };
285
+ }
286
+
287
+ credOfferMessage.body.credentials.push(
288
+ ...credsFromWallet.map<CredentialOffer>((c) => ({
289
+ id: c.id,
290
+ description: ''
291
+ }))
292
+ );
293
+ continue;
294
+ }
290
295
  }
291
296
 
292
- // credential not found in the wallet, prepare proposal protocol message
297
+ // credential not found in the wallet or credential reissue is forced, prepare proposal protocol message
293
298
  const proposal = await this._params.proposalResolverFn(cred.context, cred.type, {
294
299
  msg: proposalRequest
295
300
  });