@0xpolygonid/js-sdk 1.7.0 → 1.7.1

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.
Files changed (31) hide show
  1. package/dist/browser/esm/index.js +102 -6
  2. package/dist/browser/esm/index.js.map +1 -1
  3. package/dist/browser/umd/index.js +103 -7
  4. package/dist/browser/umd/index.js.map +1 -1
  5. package/dist/node/cjs/circuits/comparer.js +20 -2
  6. package/dist/node/cjs/circuits/linked-multi-query.js +1 -1
  7. package/dist/node/cjs/credentials/credential-wallet.js +1 -0
  8. package/dist/node/cjs/iden3comm/constants.js +2 -0
  9. package/dist/node/cjs/iden3comm/handlers/fetch.js +2 -2
  10. package/dist/node/cjs/iden3comm/handlers/index.js +1 -0
  11. package/dist/node/cjs/iden3comm/handlers/refresh.js +76 -0
  12. package/dist/node/cjs/verifiable/constants.js +10 -1
  13. package/dist/node/esm/circuits/comparer.js +20 -2
  14. package/dist/node/esm/circuits/linked-multi-query.js +1 -1
  15. package/dist/node/esm/credentials/credential-wallet.js +1 -0
  16. package/dist/node/esm/iden3comm/constants.js +2 -0
  17. package/dist/node/esm/iden3comm/handlers/fetch.js +2 -2
  18. package/dist/node/esm/iden3comm/handlers/index.js +1 -0
  19. package/dist/node/esm/iden3comm/handlers/refresh.js +72 -0
  20. package/dist/node/esm/verifiable/constants.js +9 -0
  21. package/dist/types/credentials/credential-wallet.d.ts +5 -1
  22. package/dist/types/iden3comm/constants.d.ts +1 -0
  23. package/dist/types/iden3comm/handlers/fetch.d.ts +2 -2
  24. package/dist/types/iden3comm/handlers/index.d.ts +1 -0
  25. package/dist/types/iden3comm/handlers/refresh.d.ts +56 -0
  26. package/dist/types/iden3comm/types/packer.d.ts +2 -1
  27. package/dist/types/iden3comm/types/protocol/credentials.d.ts +15 -0
  28. package/dist/types/verifiable/constants.d.ts +8 -0
  29. package/dist/types/verifiable/credential.d.ts +2 -1
  30. package/dist/types/verifiable/proof.d.ts +10 -1
  31. package/package.json +1 -1
@@ -57,8 +57,26 @@ exports.availableTypesOperators = new Map([
57
57
  [XSDNS.Integer, allOperations],
58
58
  [XSDNS.NonNegativeInteger, allOperations],
59
59
  [XSDNS.PositiveInteger, allOperations],
60
- [XSDNS.Double, [exports.QueryOperators.$eq, exports.QueryOperators.$ne, exports.QueryOperators.$in, exports.QueryOperators.$nin, exports.QueryOperators.$sd]],
61
- [XSDNS.String, [exports.QueryOperators.$eq, exports.QueryOperators.$ne, exports.QueryOperators.$in, exports.QueryOperators.$nin, exports.QueryOperators.$sd]],
60
+ [
61
+ XSDNS.Double,
62
+ [
63
+ exports.QueryOperators.$eq,
64
+ exports.QueryOperators.$ne,
65
+ exports.QueryOperators.$in,
66
+ exports.QueryOperators.$nin,
67
+ exports.QueryOperators.$sd
68
+ ]
69
+ ],
70
+ [
71
+ XSDNS.String,
72
+ [
73
+ exports.QueryOperators.$eq,
74
+ exports.QueryOperators.$ne,
75
+ exports.QueryOperators.$in,
76
+ exports.QueryOperators.$nin,
77
+ exports.QueryOperators.$sd
78
+ ]
79
+ ],
62
80
  [XSDNS.DateTime, allOperations]
63
81
  ]);
64
82
  /**
@@ -28,7 +28,7 @@ class LinkedMultiQueryInputs extends common_1.BaseConfig {
28
28
  if (!this.query[i]) {
29
29
  enabled.push(0);
30
30
  claimPathNotExists.push(0);
31
- claimPathMtp.push([]);
31
+ claimPathMtp.push(new Array(this.getMTLevelsClaim()).fill('0'));
32
32
  claimPathMtpNoAux.push('0');
33
33
  claimPathMtpAuxHi.push('0');
34
34
  claimPathMtpAuxHv.push('0');
@@ -76,6 +76,7 @@ class CredentialWallet {
76
76
  cr['@context'] = context;
77
77
  cr.type = credentialType;
78
78
  cr.expirationDate = expirationDate ? new Date(expirationDate * 1000).toISOString() : undefined;
79
+ cr.refreshService = request.refreshService;
79
80
  cr.issuanceDate = new Date().toISOString();
80
81
  cr.credentialSubject = credentialSubject;
81
82
  cr.issuer = issuer.string();
@@ -18,6 +18,8 @@ exports.PROTOCOL_MESSAGE_TYPE = Object.freeze({
18
18
  CREDENTIAL_OFFER_MESSAGE_TYPE: IDEN3_PROTOCOL + 'credentials/1.0/offer',
19
19
  // CredentialIssuanceResponseMessageType is type for message with a credential issuance
20
20
  CREDENTIAL_ISSUANCE_RESPONSE_MESSAGE_TYPE: IDEN3_PROTOCOL + 'credentials/1.0/issuance-response',
21
+ // CredentialRefreshMessageType is type for message with a credential issuance
22
+ CREDENTIAL_REFRESH_MESSAGE_TYPE: IDEN3_PROTOCOL + 'credentials/1.0/refresh',
21
23
  // DeviceRegistrationRequestMessageType defines device registration request type of the communication protocol
22
24
  DEVICE_REGISTRATION_REQUEST_MESSAGE_TYPE: IDEN3_PROTOCOL + 'devices/1.0/registration',
23
25
  // MessageFetMessageFetchRequestMessageType defines message fetch request type of the communication protocol.
@@ -42,7 +42,7 @@ const js_iden3_core_1 = require("@iden3/js-iden3-core");
42
42
  */
43
43
  class FetchHandler {
44
44
  /**
45
- * Creates an instance of AuthHandler.
45
+ * Creates an instance of FetchHandler.
46
46
  * @param {IPackageManager} _packerMgr - package manager to unpack message envelope
47
47
  */
48
48
  constructor(_packerMgr) {
@@ -55,7 +55,7 @@ class FetchHandler {
55
55
  * offer: Uint8Array; offer - raw offer message
56
56
  * opts
57
57
  * }) options how to fetch credential
58
- * @returns `Promise<W3CCredential>`
58
+ * @returns `Promise<W3CCredential[]>`
59
59
  */
60
60
  async handleCredentialOffer(offer, opts) {
61
61
  if (!opts) {
@@ -17,3 +17,4 @@ Object.defineProperty(exports, "__esModule", { value: true });
17
17
  __exportStar(require("./auth"), exports);
18
18
  __exportStar(require("./fetch"), exports);
19
19
  __exportStar(require("./contract-request"), exports);
20
+ __exportStar(require("./refresh"), exports);
@@ -0,0 +1,76 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.RefreshHandler = void 0;
4
+ const constants_1 = require("../constants");
5
+ const constants_2 = require("../constants");
6
+ const verifiable_1 = require("../../verifiable");
7
+ const utils_1 = require("../../utils");
8
+ const js_jwz_1 = require("@iden3/js-jwz");
9
+ const js_iden3_core_1 = require("@iden3/js-iden3-core");
10
+ const circuits_1 = require("../../circuits");
11
+ const crypto_1 = require("crypto");
12
+ /**
13
+ *
14
+ * Allows to refresh credential from refresh service and return refreshed credential
15
+ *
16
+ * @public
17
+
18
+ * @class RefreshHandler
19
+ * @implements implements RefreshHandler interface
20
+ */
21
+ class RefreshHandler {
22
+ /**
23
+ * Creates an instance of RefreshHandler.
24
+ * @param {RefreshHandlerOptions} _options - refresh handler options
25
+ */
26
+ constructor(_options) {
27
+ this._options = _options;
28
+ }
29
+ async refreshCredential(credential, opts) {
30
+ if (!credential.refreshService) {
31
+ throw new Error('refreshService not specified for W3CCredential');
32
+ }
33
+ if (credential.refreshService.type !== verifiable_1.RefreshServiceType.Iden3RefreshService2023) {
34
+ throw new Error(`refresh service type ${credential.refreshService.type} is not supported`);
35
+ }
36
+ const otherIdentifier = credential.credentialSubject.id;
37
+ if (!otherIdentifier) {
38
+ throw new Error('self credentials do not support refresh');
39
+ }
40
+ const senderDID = js_iden3_core_1.DID.parse(otherIdentifier);
41
+ const zkpParams = {
42
+ senderDID,
43
+ provingMethodAlg: new js_jwz_1.ProvingMethodAlg(js_jwz_1.proving.provingMethodGroth16AuthV2Instance.methodAlg.alg, circuits_1.CircuitId.AuthV2)
44
+ };
45
+ const refreshMsg = {
46
+ id: (0, crypto_1.randomUUID)(),
47
+ typ: constants_1.MediaType.ZKPMessage,
48
+ type: constants_2.PROTOCOL_MESSAGE_TYPE.CREDENTIAL_REFRESH_MESSAGE_TYPE,
49
+ thid: (0, crypto_1.randomUUID)(),
50
+ body: {
51
+ id: otherIdentifier,
52
+ reason: opts?.reason ?? 'credential is expired'
53
+ },
54
+ from: otherIdentifier,
55
+ to: credential.issuer
56
+ };
57
+ const msgBytes = utils_1.byteEncoder.encode(JSON.stringify(refreshMsg));
58
+ const jwzToken = await this._options.packageManager.pack(constants_1.MediaType.ZKPMessage, msgBytes, zkpParams);
59
+ const resp = await fetch(credential.refreshService.id, {
60
+ method: 'post',
61
+ headers: {
62
+ 'Content-Type': 'application/json'
63
+ },
64
+ body: jwzToken
65
+ });
66
+ if (resp.status !== 200) {
67
+ throw new Error(`could not refresh W3C credential, return status ${resp.status}`);
68
+ }
69
+ const respBody = await resp.json();
70
+ if (!respBody.body?.credential) {
71
+ throw new Error('no credential in CredentialIssuanceMessage response');
72
+ }
73
+ return verifiable_1.W3CCredential.fromJSON(respBody.body.credential);
74
+ }
75
+ }
76
+ exports.RefreshHandler = RefreshHandler;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.SubjectPosition = exports.MerklizedRootPosition = exports.ProofPurpose = exports.CredentialStatusType = exports.ProofType = exports.VerifiableConstants = void 0;
3
+ exports.RefreshServiceType = exports.SubjectPosition = exports.MerklizedRootPosition = exports.ProofPurpose = exports.CredentialStatusType = exports.ProofType = exports.VerifiableConstants = void 0;
4
4
  /** Verifiable constants */
5
5
  exports.VerifiableConstants = Object.freeze({
6
6
  ERRORS: {
@@ -103,3 +103,12 @@ var SubjectPosition;
103
103
  // Value save subject in value part of claim.
104
104
  SubjectPosition["Value"] = "value";
105
105
  })(SubjectPosition = exports.SubjectPosition || (exports.SubjectPosition = {}));
106
+ /**
107
+ * RefreshServiceType type for refreshService
108
+ *
109
+ * @enum {string}
110
+ */
111
+ var RefreshServiceType;
112
+ (function (RefreshServiceType) {
113
+ RefreshServiceType["Iden3RefreshService2023"] = "Iden3RefreshService2023";
114
+ })(RefreshServiceType = exports.RefreshServiceType || (exports.RefreshServiceType = {}));
@@ -54,8 +54,26 @@ export const availableTypesOperators = new Map([
54
54
  [XSDNS.Integer, allOperations],
55
55
  [XSDNS.NonNegativeInteger, allOperations],
56
56
  [XSDNS.PositiveInteger, allOperations],
57
- [XSDNS.Double, [QueryOperators.$eq, QueryOperators.$ne, QueryOperators.$in, QueryOperators.$nin, QueryOperators.$sd]],
58
- [XSDNS.String, [QueryOperators.$eq, QueryOperators.$ne, QueryOperators.$in, QueryOperators.$nin, QueryOperators.$sd]],
57
+ [
58
+ XSDNS.Double,
59
+ [
60
+ QueryOperators.$eq,
61
+ QueryOperators.$ne,
62
+ QueryOperators.$in,
63
+ QueryOperators.$nin,
64
+ QueryOperators.$sd
65
+ ]
66
+ ],
67
+ [
68
+ XSDNS.String,
69
+ [
70
+ QueryOperators.$eq,
71
+ QueryOperators.$ne,
72
+ QueryOperators.$in,
73
+ QueryOperators.$nin,
74
+ QueryOperators.$sd
75
+ ]
76
+ ],
59
77
  [XSDNS.DateTime, allOperations]
60
78
  ]);
61
79
  /**
@@ -25,7 +25,7 @@ export class LinkedMultiQueryInputs extends BaseConfig {
25
25
  if (!this.query[i]) {
26
26
  enabled.push(0);
27
27
  claimPathNotExists.push(0);
28
- claimPathMtp.push([]);
28
+ claimPathMtp.push(new Array(this.getMTLevelsClaim()).fill('0'));
29
29
  claimPathMtpNoAux.push('0');
30
30
  claimPathMtpAuxHi.push('0');
31
31
  claimPathMtpAuxHv.push('0');
@@ -50,6 +50,7 @@ export class CredentialWallet {
50
50
  cr['@context'] = context;
51
51
  cr.type = credentialType;
52
52
  cr.expirationDate = expirationDate ? new Date(expirationDate * 1000).toISOString() : undefined;
53
+ cr.refreshService = request.refreshService;
53
54
  cr.issuanceDate = new Date().toISOString();
54
55
  cr.credentialSubject = credentialSubject;
55
56
  cr.issuer = issuer.string();
@@ -15,6 +15,8 @@ export const PROTOCOL_MESSAGE_TYPE = Object.freeze({
15
15
  CREDENTIAL_OFFER_MESSAGE_TYPE: IDEN3_PROTOCOL + 'credentials/1.0/offer',
16
16
  // CredentialIssuanceResponseMessageType is type for message with a credential issuance
17
17
  CREDENTIAL_ISSUANCE_RESPONSE_MESSAGE_TYPE: IDEN3_PROTOCOL + 'credentials/1.0/issuance-response',
18
+ // CredentialRefreshMessageType is type for message with a credential issuance
19
+ CREDENTIAL_REFRESH_MESSAGE_TYPE: IDEN3_PROTOCOL + 'credentials/1.0/refresh',
18
20
  // DeviceRegistrationRequestMessageType defines device registration request type of the communication protocol
19
21
  DEVICE_REGISTRATION_REQUEST_MESSAGE_TYPE: IDEN3_PROTOCOL + 'devices/1.0/registration',
20
22
  // MessageFetMessageFetchRequestMessageType defines message fetch request type of the communication protocol.
@@ -16,7 +16,7 @@ import { DID } from '@iden3/js-iden3-core';
16
16
  */
17
17
  export class FetchHandler {
18
18
  /**
19
- * Creates an instance of AuthHandler.
19
+ * Creates an instance of FetchHandler.
20
20
  * @param {IPackageManager} _packerMgr - package manager to unpack message envelope
21
21
  */
22
22
  constructor(_packerMgr) {
@@ -29,7 +29,7 @@ export class FetchHandler {
29
29
  * offer: Uint8Array; offer - raw offer message
30
30
  * opts
31
31
  * }) options how to fetch credential
32
- * @returns `Promise<W3CCredential>`
32
+ * @returns `Promise<W3CCredential[]>`
33
33
  */
34
34
  async handleCredentialOffer(offer, opts) {
35
35
  if (!opts) {
@@ -1,3 +1,4 @@
1
1
  export * from './auth';
2
2
  export * from './fetch';
3
3
  export * from './contract-request';
4
+ export * from './refresh';
@@ -0,0 +1,72 @@
1
+ import { MediaType } from '../constants';
2
+ import { PROTOCOL_MESSAGE_TYPE } from '../constants';
3
+ import { RefreshServiceType, W3CCredential } from '../../verifiable';
4
+ import { byteEncoder } from '../../utils';
5
+ import { proving, ProvingMethodAlg } from '@iden3/js-jwz';
6
+ import { DID } from '@iden3/js-iden3-core';
7
+ import { CircuitId } from '../../circuits';
8
+ import { randomUUID } from 'crypto';
9
+ /**
10
+ *
11
+ * Allows to refresh credential from refresh service and return refreshed credential
12
+ *
13
+ * @public
14
+
15
+ * @class RefreshHandler
16
+ * @implements implements RefreshHandler interface
17
+ */
18
+ export class RefreshHandler {
19
+ /**
20
+ * Creates an instance of RefreshHandler.
21
+ * @param {RefreshHandlerOptions} _options - refresh handler options
22
+ */
23
+ constructor(_options) {
24
+ this._options = _options;
25
+ }
26
+ async refreshCredential(credential, opts) {
27
+ if (!credential.refreshService) {
28
+ throw new Error('refreshService not specified for W3CCredential');
29
+ }
30
+ if (credential.refreshService.type !== RefreshServiceType.Iden3RefreshService2023) {
31
+ throw new Error(`refresh service type ${credential.refreshService.type} is not supported`);
32
+ }
33
+ const otherIdentifier = credential.credentialSubject.id;
34
+ if (!otherIdentifier) {
35
+ throw new Error('self credentials do not support refresh');
36
+ }
37
+ const senderDID = DID.parse(otherIdentifier);
38
+ const zkpParams = {
39
+ senderDID,
40
+ provingMethodAlg: new ProvingMethodAlg(proving.provingMethodGroth16AuthV2Instance.methodAlg.alg, CircuitId.AuthV2)
41
+ };
42
+ const refreshMsg = {
43
+ id: randomUUID(),
44
+ typ: MediaType.ZKPMessage,
45
+ type: PROTOCOL_MESSAGE_TYPE.CREDENTIAL_REFRESH_MESSAGE_TYPE,
46
+ thid: randomUUID(),
47
+ body: {
48
+ id: otherIdentifier,
49
+ reason: opts?.reason ?? 'credential is expired'
50
+ },
51
+ from: otherIdentifier,
52
+ to: credential.issuer
53
+ };
54
+ const msgBytes = byteEncoder.encode(JSON.stringify(refreshMsg));
55
+ const jwzToken = await this._options.packageManager.pack(MediaType.ZKPMessage, msgBytes, zkpParams);
56
+ const resp = await fetch(credential.refreshService.id, {
57
+ method: 'post',
58
+ headers: {
59
+ 'Content-Type': 'application/json'
60
+ },
61
+ body: jwzToken
62
+ });
63
+ if (resp.status !== 200) {
64
+ throw new Error(`could not refresh W3C credential, return status ${resp.status}`);
65
+ }
66
+ const respBody = await resp.json();
67
+ if (!respBody.body?.credential) {
68
+ throw new Error('no credential in CredentialIssuanceMessage response');
69
+ }
70
+ return W3CCredential.fromJSON(respBody.body.credential);
71
+ }
72
+ }
@@ -100,3 +100,12 @@ export var SubjectPosition;
100
100
  // Value save subject in value part of claim.
101
101
  SubjectPosition["Value"] = "value";
102
102
  })(SubjectPosition || (SubjectPosition = {}));
103
+ /**
104
+ * RefreshServiceType type for refreshService
105
+ *
106
+ * @enum {string}
107
+ */
108
+ export var RefreshServiceType;
109
+ (function (RefreshServiceType) {
110
+ RefreshServiceType["Iden3RefreshService2023"] = "Iden3RefreshService2023";
111
+ })(RefreshServiceType || (RefreshServiceType = {}));
@@ -1,6 +1,6 @@
1
1
  import { DID } from '@iden3/js-iden3-core';
2
2
  import { IDataStorage } from '../storage/interfaces';
3
- import { W3CCredential, ProofQuery, SubjectPosition, MerklizedRootPosition, CredentialStatus, RevocationStatus, CredentialStatusType } from './../verifiable';
3
+ import { W3CCredential, ProofQuery, SubjectPosition, MerklizedRootPosition, CredentialStatus, RevocationStatus, CredentialStatusType, RefreshService } from './../verifiable';
4
4
  import { JSONSchema } from '../schema-processor';
5
5
  import { CredentialStatusResolverRegistry } from './status/resolver';
6
6
  import { CredentialStatusResolveOptions } from './status/resolver';
@@ -29,6 +29,10 @@ export interface CredentialRequest {
29
29
  * expiration time
30
30
  */
31
31
  expiration?: number;
32
+ /**
33
+ * refreshService
34
+ */
35
+ refreshService?: RefreshService;
32
36
  /**
33
37
  * claim version
34
38
  */
@@ -8,6 +8,7 @@ export declare const PROTOCOL_MESSAGE_TYPE: Readonly<{
8
8
  CREDENTIAL_FETCH_REQUEST_MESSAGE_TYPE: string;
9
9
  CREDENTIAL_OFFER_MESSAGE_TYPE: string;
10
10
  CREDENTIAL_ISSUANCE_RESPONSE_MESSAGE_TYPE: string;
11
+ CREDENTIAL_REFRESH_MESSAGE_TYPE: string;
11
12
  DEVICE_REGISTRATION_REQUEST_MESSAGE_TYPE: string;
12
13
  MESSAGE_FETCH_REQUEST_MESSAGE_TYPE: string;
13
14
  PROOF_GENERATION_REQUEST_MESSAGE_TYPE: string;
@@ -47,7 +47,7 @@ export interface IFetchHandler {
47
47
  export declare class FetchHandler implements IFetchHandler {
48
48
  private readonly _packerMgr;
49
49
  /**
50
- * Creates an instance of AuthHandler.
50
+ * Creates an instance of FetchHandler.
51
51
  * @param {IPackageManager} _packerMgr - package manager to unpack message envelope
52
52
  */
53
53
  constructor(_packerMgr: IPackageManager);
@@ -58,7 +58,7 @@ export declare class FetchHandler implements IFetchHandler {
58
58
  * offer: Uint8Array; offer - raw offer message
59
59
  * opts
60
60
  * }) options how to fetch credential
61
- * @returns `Promise<W3CCredential>`
61
+ * @returns `Promise<W3CCredential[]>`
62
62
  */
63
63
  handleCredentialOffer(offer: Uint8Array, opts?: FetchHandlerOptions): Promise<W3CCredential[]>;
64
64
  }
@@ -1,3 +1,4 @@
1
1
  export * from './auth';
2
2
  export * from './fetch';
3
3
  export * from './contract-request';
4
+ export * from './refresh';
@@ -0,0 +1,56 @@
1
+ import { IPackageManager } from '../types';
2
+ import { W3CCredential } from '../../verifiable';
3
+ import { ICredentialWallet } from '../../credentials';
4
+ /**
5
+ * RefreshHandlerOptions contains options for RefreshHandler
6
+ * @public
7
+ * @interface RefreshHandlerOptions
8
+ */
9
+ export interface RefreshHandlerOptions {
10
+ packageManager: IPackageManager;
11
+ credentialWallet?: ICredentialWallet;
12
+ }
13
+ /**
14
+ *
15
+ * RefreshOptions contains options for refreshCredential call
16
+ *
17
+ * @public
18
+ * @interface RefreshOptions
19
+ */
20
+ export interface RefreshOptions {
21
+ reason?: string;
22
+ }
23
+ /**
24
+ * Interface to work with credential refresh handler
25
+ *
26
+ * @public
27
+ * @interface IRefreshHandler
28
+ */
29
+ export interface IRefreshHandler {
30
+ /**
31
+ * refresh credential
32
+ *
33
+ * @param {W3CCredential} credential - credential to refresh
34
+ * @param {RefreshOptions} opts - options
35
+ * @returns {Promise<W3CCredential>}
36
+ */
37
+ refreshCredential(credential: W3CCredential, opts?: RefreshOptions): Promise<W3CCredential>;
38
+ }
39
+ /**
40
+ *
41
+ * Allows to refresh credential from refresh service and return refreshed credential
42
+ *
43
+ * @public
44
+
45
+ * @class RefreshHandler
46
+ * @implements implements RefreshHandler interface
47
+ */
48
+ export declare class RefreshHandler implements IRefreshHandler {
49
+ private readonly _options;
50
+ /**
51
+ * Creates an instance of RefreshHandler.
52
+ * @param {RefreshHandlerOptions} _options - refresh handler options
53
+ */
54
+ constructor(_options: RefreshHandlerOptions);
55
+ refreshCredential(credential: W3CCredential, opts?: RefreshOptions): Promise<W3CCredential>;
56
+ }
@@ -39,7 +39,8 @@ export type PackerParams = {
39
39
  */
40
40
  export type ZKPPackerParams = PackerParams & {
41
41
  senderDID: DID;
42
- profileNonce: number;
42
+ /** @deprecated */
43
+ profileNonce?: number;
43
44
  provingMethodAlg: ProvingMethodAlg;
44
45
  };
45
46
  /**
@@ -71,3 +71,18 @@ export type Schema = {
71
71
  url: string;
72
72
  type: string;
73
73
  };
74
+ /** CredentialRefreshMessage represent Iden3message for credential refresh request */
75
+ export type CredentialRefreshMessage = {
76
+ id: string;
77
+ typ?: MediaType;
78
+ type: ProtocolMessage;
79
+ thid?: string;
80
+ body?: CredentialRefreshMessageBody;
81
+ from?: string;
82
+ to?: string;
83
+ };
84
+ /** CredentialRefreshMessageBody is msg body for refresh request */
85
+ export type CredentialRefreshMessageBody = {
86
+ id: string;
87
+ reason: string;
88
+ };
@@ -76,3 +76,11 @@ export declare enum SubjectPosition {
76
76
  Index = "index",
77
77
  Value = "value"
78
78
  }
79
+ /**
80
+ * RefreshServiceType type for refreshService
81
+ *
82
+ * @enum {string}
83
+ */
84
+ export declare enum RefreshServiceType {
85
+ Iden3RefreshService2023 = "Iden3RefreshService2023"
86
+ }
@@ -1,4 +1,4 @@
1
- import { BJJSignatureProof2021, Iden3SparseMerkleTreeProof, CredentialStatus } from './proof';
1
+ import { BJJSignatureProof2021, Iden3SparseMerkleTreeProof, CredentialStatus, RefreshService } from './proof';
2
2
  import { Claim } from '@iden3/js-iden3-core';
3
3
  import { ProofType } from './constants';
4
4
  import { Proof } from '@iden3/js-merkletree';
@@ -16,6 +16,7 @@ export declare class W3CCredential {
16
16
  '@context': string[];
17
17
  type: string[];
18
18
  expirationDate?: string;
19
+ refreshService?: RefreshService;
19
20
  issuanceDate?: string;
20
21
  credentialSubject: {
21
22
  [key: string]: object | string | number | boolean;
@@ -1,5 +1,5 @@
1
1
  import { Hash, Proof } from '@iden3/js-merkletree';
2
- import { ProofType, CredentialStatusType } from './constants';
2
+ import { ProofType, CredentialStatusType, RefreshServiceType } from './constants';
3
3
  import { TreeState } from '../circuits';
4
4
  import { Signature } from '@iden3/js-crypto';
5
5
  import { Claim, DID } from '@iden3/js-iden3-core';
@@ -184,3 +184,12 @@ export interface CredentialStatus {
184
184
  revocationNonce?: number;
185
185
  statusIssuer?: CredentialStatus;
186
186
  }
187
+ /**
188
+ * RefreshService contains type and id
189
+ * @public
190
+ * @interface RefreshService
191
+ */
192
+ export interface RefreshService {
193
+ id: string;
194
+ type: RefreshServiceType | string;
195
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@0xpolygonid/js-sdk",
3
- "version": "1.7.0",
3
+ "version": "1.7.1",
4
4
  "description": "SDK to work with Polygon ID",
5
5
  "main": "dist/node/cjs/index.js",
6
6
  "module": "dist/node/esm/index.js",