@0xpolygonid/js-sdk 1.15.0 → 1.15.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.
@@ -1,2 +1,10 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.CredentialOfferStatus = void 0;
4
+ /** CredentialOfferStatus is list of possible statuses for credential offer message */
5
+ var CredentialOfferStatus;
6
+ (function (CredentialOfferStatus) {
7
+ CredentialOfferStatus["Pending"] = "pending";
8
+ CredentialOfferStatus["Completed"] = "completed";
9
+ CredentialOfferStatus["Rejected"] = "rejected";
10
+ })(CredentialOfferStatus = exports.CredentialOfferStatus || (exports.CredentialOfferStatus = {}));
@@ -390,7 +390,7 @@ class IdentityWallet {
390
390
  req.revocationOpts.nonce =
391
391
  typeof req.revocationOpts.nonce === 'number'
392
392
  ? req.revocationOpts.nonce
393
- : Math.round(Math.random() * 10000);
393
+ : new DataView((0, js_crypto_1.getRandomBytes)(16).buffer).getUint32(0, false);
394
394
  req.subjectPosition = req.subjectPosition ?? verifiable_1.SubjectPosition.Index;
395
395
  try {
396
396
  credential = this._credentialWallet.createCredential(issuerDID, req, jsonSchema);
@@ -226,9 +226,6 @@ class ProofService {
226
226
  const gistRoot = authV2PubSignals.GISTRoot.bigInt();
227
227
  const userId = authV2PubSignals.userID.bigInt();
228
228
  const globalStateInfo = await this._stateStorage.getGISTRootInfo(gistRoot, userId);
229
- if (globalStateInfo.createdAtTimestamp === 0n) {
230
- throw new Error(`gist state doesn't exists in contract`);
231
- }
232
229
  if (globalStateInfo.root !== gistRoot) {
233
230
  throw new Error(`gist info contains invalid state`);
234
231
  }
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.SupportedCurrencies = exports.PaymentType = exports.PaymentRequestDataType = exports.PaymentRequestType = exports.RefreshServiceType = exports.SubjectPosition = exports.MerklizedRootPosition = exports.ProofPurpose = exports.CredentialStatusType = exports.ProofType = exports.VerifiableConstants = void 0;
3
+ exports.DisplayMethodType = exports.SupportedCurrencies = exports.PaymentType = exports.PaymentRequestDataType = exports.PaymentRequestType = 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: {
@@ -149,3 +149,12 @@ var SupportedCurrencies;
149
149
  (function (SupportedCurrencies) {
150
150
  SupportedCurrencies["ETH"] = "ETH";
151
151
  })(SupportedCurrencies = exports.SupportedCurrencies || (exports.SupportedCurrencies = {}));
152
+ /**
153
+ * DisplayMethodType type for display method
154
+ *
155
+ * @enum {string}
156
+ */
157
+ var DisplayMethodType;
158
+ (function (DisplayMethodType) {
159
+ DisplayMethodType["Iden3BasicDisplayMethodV1"] = "Iden3BasicDisplayMethodV1";
160
+ })(DisplayMethodType = exports.DisplayMethodType || (exports.DisplayMethodType = {}));
@@ -1 +1,7 @@
1
- export {};
1
+ /** CredentialOfferStatus is list of possible statuses for credential offer message */
2
+ export var CredentialOfferStatus;
3
+ (function (CredentialOfferStatus) {
4
+ CredentialOfferStatus["Pending"] = "pending";
5
+ CredentialOfferStatus["Completed"] = "completed";
6
+ CredentialOfferStatus["Rejected"] = "rejected";
7
+ })(CredentialOfferStatus || (CredentialOfferStatus = {}));
@@ -364,7 +364,7 @@ export class IdentityWallet {
364
364
  req.revocationOpts.nonce =
365
365
  typeof req.revocationOpts.nonce === 'number'
366
366
  ? req.revocationOpts.nonce
367
- : Math.round(Math.random() * 10000);
367
+ : new DataView(getRandomBytes(16).buffer).getUint32(0, false);
368
368
  req.subjectPosition = req.subjectPosition ?? SubjectPosition.Index;
369
369
  try {
370
370
  credential = this._credentialWallet.createCredential(issuerDID, req, jsonSchema);
@@ -223,9 +223,6 @@ export class ProofService {
223
223
  const gistRoot = authV2PubSignals.GISTRoot.bigInt();
224
224
  const userId = authV2PubSignals.userID.bigInt();
225
225
  const globalStateInfo = await this._stateStorage.getGISTRootInfo(gistRoot, userId);
226
- if (globalStateInfo.createdAtTimestamp === 0n) {
227
- throw new Error(`gist state doesn't exists in contract`);
228
- }
229
226
  if (globalStateInfo.root !== gistRoot) {
230
227
  throw new Error(`gist info contains invalid state`);
231
228
  }
@@ -146,3 +146,12 @@ export var SupportedCurrencies;
146
146
  (function (SupportedCurrencies) {
147
147
  SupportedCurrencies["ETH"] = "ETH";
148
148
  })(SupportedCurrencies || (SupportedCurrencies = {}));
149
+ /**
150
+ * DisplayMethodType type for display method
151
+ *
152
+ * @enum {string}
153
+ */
154
+ export var DisplayMethodType;
155
+ (function (DisplayMethodType) {
156
+ DisplayMethodType["Iden3BasicDisplayMethodV1"] = "Iden3BasicDisplayMethodV1";
157
+ })(DisplayMethodType || (DisplayMethodType = {}));
@@ -1,6 +1,5 @@
1
1
  import { ZKProof } from '@iden3/js-jwz';
2
2
  import { BasicMessage, JSONObject } from '../packer';
3
- import { DID } from '@iden3/js-iden3-core';
4
3
  /** AuthorizationResponseMessage is struct the represents iden3message authorization response */
5
4
  export type AuthorizationResponseMessage = BasicMessage & {
6
5
  body: AuthorizationMessageResponseBody;
@@ -34,7 +33,6 @@ export type ZeroKnowledgeProofRequest = {
34
33
  query: JSONObject;
35
34
  params?: {
36
35
  nullifierSessionId?: string | number;
37
- verifierDid?: DID;
38
36
  };
39
37
  };
40
38
  /** ZeroKnowledgeProofResponse represents structure of zkp response */
@@ -29,10 +29,17 @@ export type CredentialsOnchainOfferMessageBody = {
29
29
  credentials: CredentialOffer[];
30
30
  transaction_data: ContractInvokeTransactionData;
31
31
  };
32
+ /** CredentialOfferStatus is list of possible statuses for credential offer message */
33
+ export declare enum CredentialOfferStatus {
34
+ Pending = "pending",
35
+ Completed = "completed",
36
+ Rejected = "rejected"
37
+ }
32
38
  /** CredentialOffer is structure to fetch credential */
33
39
  export type CredentialOffer = {
34
40
  id: string;
35
41
  description: string;
42
+ status?: CredentialOfferStatus;
36
43
  };
37
44
  /** CredentialIssuanceMessage represent Iden3message for credential issuance */
38
45
  export type CredentialIssuanceMessage = Required<BasicMessage> & {
@@ -117,3 +117,11 @@ export declare enum PaymentType {
117
117
  export declare enum SupportedCurrencies {
118
118
  ETH = "ETH"
119
119
  }
120
+ /**
121
+ * DisplayMethodType type for display method
122
+ *
123
+ * @enum {string}
124
+ */
125
+ export declare enum DisplayMethodType {
126
+ Iden3BasicDisplayMethodV1 = "Iden3BasicDisplayMethodV1"
127
+ }
@@ -1,4 +1,4 @@
1
- import { BJJSignatureProof2021, Iden3SparseMerkleTreeProof, CredentialStatus, RefreshService } from './proof';
1
+ import { BJJSignatureProof2021, Iden3SparseMerkleTreeProof, CredentialStatus, RefreshService, DisplayMethod } from './proof';
2
2
  import { Claim } from '@iden3/js-iden3-core';
3
3
  import { Proof } from '@iden3/js-merkletree';
4
4
  import { Merklizer, Options } from '@iden3/js-jsonld-merklization';
@@ -18,6 +18,7 @@ export declare class W3CCredential {
18
18
  type: string[];
19
19
  expirationDate?: string;
20
20
  refreshService?: RefreshService;
21
+ displayMethod?: DisplayMethod;
21
22
  issuanceDate?: string;
22
23
  credentialSubject: {
23
24
  [key: string]: object | string | number | boolean;
@@ -1,5 +1,5 @@
1
1
  import { Hash, Proof } from '@iden3/js-merkletree';
2
- import { ProofType, CredentialStatusType, RefreshServiceType } from './constants';
2
+ import { ProofType, CredentialStatusType, RefreshServiceType, DisplayMethodType } 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';
@@ -201,3 +201,12 @@ export interface RefreshService {
201
201
  id: string;
202
202
  type: RefreshServiceType | string;
203
203
  }
204
+ /**
205
+ * DisplayMethod contains type and id
206
+ * @public
207
+ * @interface DisplayMethod
208
+ */
209
+ export interface DisplayMethod {
210
+ id: string;
211
+ type: DisplayMethodType | string;
212
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@0xpolygonid/js-sdk",
3
- "version": "1.15.0",
3
+ "version": "1.15.3",
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",
@@ -87,9 +87,9 @@
87
87
  },
88
88
  "peerDependencies": {
89
89
  "@iden3/js-crypto": "1.1.0",
90
- "@iden3/js-iden3-core": "1.3.1",
91
- "@iden3/js-jsonld-merklization": "1.2.0",
92
- "@iden3/js-jwz": "1.5.0",
90
+ "@iden3/js-iden3-core": "1.3.2",
91
+ "@iden3/js-jsonld-merklization": "1.3.1",
92
+ "@iden3/js-jwz": "1.5.1",
93
93
  "@iden3/js-merkletree": "1.2.0",
94
94
  "ffjavascript": "0.3.0",
95
95
  "rfc4648": "1.5.3",