@zkpassport/sdk 0.8.7 → 0.9.0-beta.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.
@@ -1,195 +1,9 @@
1
- import { IDCredential, ProofResult, QueryResult, IDCredentialValue, NumericalIDCredential, DisclosableIDCredential, BoundData, SanctionsCountries, SanctionsLists, FacematchMode, ProofMode, SupportedChain } from '@zkpassport/utils';
1
+ import { QueryBuilder, QueryResultErrors, SolidityVerifierParameters } from './types.cjs';
2
+ export { QueryBuilderResult, QueryResultError } from './types.cjs';
3
+ import { ProofMode, ProofResult, QueryResult, NullifierType, SupportedChain } from '@zkpassport/utils';
2
4
  export * from '@zkpassport/utils';
3
5
  export { ASEAN_COUNTRIES, EEA_COUNTRIES, EU_COUNTRIES, MERCOSUR_COUNTRIES, SANCTIONED_COUNTRIES, SCHENGEN_COUNTRIES } from '@zkpassport/utils';
4
6
 
5
- type QueryResultError<T> = {
6
- expected?: T;
7
- received?: T;
8
- message: string;
9
- };
10
- type QueryResultErrors = {
11
- [key in IDCredential | "sig_check_dsc" | "sig_check_id_data" | "data_check_integrity" | "outer" | "disclose" | "bind" | "facematch" | "sanctions"]: {
12
- disclose?: QueryResultError<string | number | Date>;
13
- gte?: QueryResultError<number | Date>;
14
- lte?: QueryResultError<number | Date>;
15
- lt?: QueryResultError<number | Date>;
16
- range?: QueryResultError<[number | Date, number | Date]>;
17
- in?: QueryResultError<string[]>;
18
- out?: QueryResultError<string[]>;
19
- eq?: QueryResultError<string | number | Date>;
20
- commitment?: QueryResultError<string>;
21
- date?: QueryResultError<string>;
22
- certificate?: QueryResultError<string>;
23
- scope?: QueryResultError<string>;
24
- };
25
- };
26
- type SolidityVerifierParameters = {
27
- vkeyHash: string;
28
- proof: string;
29
- publicInputs: string[];
30
- committedInputs: string;
31
- committedInputCounts: number[];
32
- validityPeriodInSeconds: number;
33
- domain: string;
34
- scope: string;
35
- devMode: boolean;
36
- };
37
-
38
- type QueryBuilderResult = {
39
- /**
40
- * The URL of the request.
41
- *
42
- * You can either encode the URL in a QR code or let the user click the link
43
- * to this URL on your website if they're visiting your website on their phone.
44
- */
45
- url: string;
46
- /**
47
- * The id of the request.
48
- */
49
- requestId: string;
50
- /**
51
- * Called when the user has scanned the QR code or clicked the link to the request.
52
- *
53
- * This means the user is currently viewing the request popup with your website information
54
- * and the information requested from them.
55
- */
56
- onRequestReceived: (callback: () => void) => void;
57
- /**
58
- * Called when the user has accepted the request and
59
- * started to generate the proof on their phone.
60
- */
61
- onGeneratingProof: (callback: () => void) => void;
62
- /**
63
- * Called when the SDK successfully connects to the bridge with the mobile app.
64
- */
65
- onBridgeConnect: (callback: () => void) => void;
66
- /**
67
- * Called when the user has generated a proof.
68
- *
69
- * There is a minimum of 4 proofs, but there can be more depending
70
- * on the type of information requested from the user.
71
- */
72
- onProofGenerated: (callback: (proof: ProofResult) => void) => void;
73
- /**
74
- * Called when the user has sent the query result.
75
- *
76
- * The response contains the unique identifier associated to the user,
77
- * your domain name and chosen scope, along with the query result and whether
78
- * the proofs were successfully verified.
79
- */
80
- onResult: (callback: (response: {
81
- uniqueIdentifier: string | undefined;
82
- verified: boolean;
83
- result: QueryResult;
84
- queryResultErrors?: Partial<QueryResultErrors>;
85
- }) => void) => void;
86
- /**
87
- * Called when the user has rejected the request.
88
- */
89
- onReject: (callback: () => void) => void;
90
- /**
91
- * Called when an error occurs, such as one of the requirements not being met
92
- * or a proof failing to be generated.
93
- */
94
- onError: (callback: (error: string) => void) => void;
95
- /**
96
- * @returns true if the bridge with the mobile app is connected
97
- */
98
- isBridgeConnected: () => boolean;
99
- /**
100
- * Get if the user has scanned the QR code or the link to this request
101
- * @returns true if the request has been received by the user on their phone
102
- */
103
- requestReceived: () => boolean;
104
- };
105
- type QueryBuilder = {
106
- /**
107
- * Requires this attribute to be equal to the provided value.
108
- * @param key The attribute to compare.
109
- * @param value The value of the attribute you require.
110
- */
111
- eq: <T extends IDCredential>(key: T, value: IDCredentialValue<T>) => QueryBuilder;
112
- /**
113
- * Requires this attribute to be greater than or equal to the provided value.
114
- * @param key The attribute to compare.
115
- * @param value The value of the attribute you require.
116
- */
117
- gte: <T extends NumericalIDCredential>(key: T, value: IDCredentialValue<T>) => QueryBuilder;
118
- /**
119
- * Requires this attribute to be greater than the provided value.
120
- * @param key The attribute to compare.
121
- * @param value The value of the attribute you require.
122
- */
123
- gt: <T extends NumericalIDCredential>(key: T, value: IDCredentialValue<T>) => QueryBuilder;
124
- /**
125
- * Requires this attribute to be less than or equal to the provided value.
126
- * @param key The attribute to compare.
127
- * @param value The value of the attribute you require.
128
- */
129
- lte: <T extends NumericalIDCredential>(key: T, value: IDCredentialValue<T>) => QueryBuilder;
130
- /**
131
- * Requires this attribute to be less than the provided value.
132
- * @param key The attribute to compare.
133
- * @param value The value of the attribute you require.
134
- */
135
- lt: <T extends NumericalIDCredential>(key: T, value: IDCredentialValue<T>) => QueryBuilder;
136
- /**
137
- * Requires this attribute to be included in the provided range.
138
- * @param key The attribute to compare.
139
- * @param start The start of the range.
140
- * @param end The end of the range.
141
- */
142
- range: <T extends NumericalIDCredential>(key: T, start: IDCredentialValue<T>, end: IDCredentialValue<T>) => QueryBuilder;
143
- /**
144
- * Requires this attribute to be included in the provided list.
145
- * @param key The attribute to compare.
146
- * @param value The list of values to check inclusion against.
147
- */
148
- in: <T extends "nationality" | "issuing_country">(key: T, value: IDCredentialValue<T>[]) => QueryBuilder;
149
- /**
150
- * Requires this attribute to be excluded from the provided list.
151
- * @param key The attribute to compare.
152
- * @param value The list of values to check exclusion against.
153
- */
154
- out: <T extends "nationality" | "issuing_country">(key: T, value: IDCredentialValue<T>[]) => QueryBuilder;
155
- /**
156
- * Requires this attribute to be disclosed.
157
- * @param key The attribute to disclose.
158
- */
159
- disclose: (key: DisclosableIDCredential) => QueryBuilder;
160
- /**
161
- * Binds a value to the request.
162
- * @param key The key of the value to bind.
163
- * @param value The value to bind the request to.
164
- */
165
- bind: (key: keyof BoundData, value: BoundData[keyof BoundData]) => QueryBuilder;
166
- /**
167
- * Requires that the ID holder is not part of any of the specified sanction lists.
168
- * @param countries The country or list of countries whose sanction lists to check against. Defaults to "all".
169
- * e.g. "US", ["US", "GB", "CH", "EU"], "all"
170
- * @param lists The specific lists from a given country to check against. Defaults to "all".
171
- * e.g. ["OFAC_SDN"], "all"
172
- */
173
- sanctions: (countries?: SanctionsCountries, lists?: SanctionsLists) => QueryBuilder;
174
- /**
175
- * This feature is not available yet in the public release of the app.
176
- * Requires that the ID holder's face matches the photo on the ID.
177
- * @param mode The mode to use for the face match. Defaults to "regular".
178
- * @param mode "strict" - The user will have to go through an extensive liveness check to prevent spoofing making it more secure.
179
- * Best for high security requirements such as KYC.
180
- * @param mode "regular" - The user will only have to go through a basic liveness check to prevent spoofing, making it faster for the user.
181
- * Best for lower security requirements that requires fast verification such as age verification.
182
- */
183
- facematch: (mode?: FacematchMode) => QueryBuilder;
184
- /**
185
- * Builds the request.
186
- *
187
- * This will return the URL of the request, which you can either encode in a QR code
188
- * or provide as a link to the user if they're visiting your website on their phone.
189
- * It also returns all the callbacks you can use to handle the user's response.
190
- */
191
- done: () => QueryBuilderResult;
192
- };
193
7
  declare class ZKPassport {
194
8
  private domain;
195
9
  private topicToConfig;
@@ -226,16 +40,18 @@ declare class ZKPassport {
226
40
  * @param logo The logo of your service
227
41
  * @param purpose To explain what you want to do with the user's data
228
42
  * @param scope Scope this request to a specific use case
43
+ * @param projectID The project ID of your service
229
44
  * @param validity How many seconds ago the proof checking the expiry date of the ID should have been generated
230
45
  * @param devMode Whether to enable dev mode. This will allow you to verify mock proofs (i.e. from ZKR)
231
46
  * @returns The query builder object.
232
47
  */
233
- request({ name, logo, purpose, scope, mode, validity, devMode, topicOverride, keyPairOverride, cloudProverUrl, bridgeUrl, }: {
48
+ request({ name, logo, purpose, scope, projectID, mode, validity, devMode, topicOverride, keyPairOverride, cloudProverUrl, bridgeUrl, }: {
234
49
  name: string;
235
50
  logo: string;
236
51
  purpose: string;
237
52
  scope?: string;
238
53
  mode?: ProofMode;
54
+ projectID?: string;
239
55
  validity?: number;
240
56
  devMode?: boolean;
241
57
  topicOverride?: string;
@@ -246,20 +62,6 @@ declare class ZKPassport {
246
62
  cloudProverUrl?: string;
247
63
  bridgeUrl?: string;
248
64
  }): Promise<QueryBuilder>;
249
- private checkDiscloseBytesPublicInputs;
250
- private checkAgePublicInputs;
251
- private checkBirthdatePublicInputs;
252
- private checkExpiryDatePublicInputs;
253
- private checkNationalityExclusionPublicInputs;
254
- private checkIssuingCountryExclusionPublicInputs;
255
- private checkNationalityInclusionPublicInputs;
256
- private checkIssuingCountryInclusionPublicInputs;
257
- private checkScopeFromDisclosureProof;
258
- private checkCertificateRegistryRoot;
259
- private checkCircuitRegistryRoot;
260
- private checkBindPublicInputs;
261
- private checkSanctionsExclusionPublicInputs;
262
- private checkPublicInputs;
263
65
  /**
264
66
  * @notice Verify the proofs received from the mobile app.
265
67
  * @param proofs The proofs to verify.
@@ -281,6 +83,7 @@ declare class ZKPassport {
281
83
  writingDirectory?: string;
282
84
  }): Promise<{
283
85
  uniqueIdentifier: string | undefined;
86
+ uniqueIdentifierType: NullifierType | undefined;
284
87
  verified: boolean;
285
88
  queryResultErrors?: Partial<QueryResultErrors>;
286
89
  }>;
@@ -327,4 +130,4 @@ declare class ZKPassport {
327
130
  clearAllRequests(): void;
328
131
  }
329
132
 
330
- export { type QueryBuilder, type QueryBuilderResult, type QueryResultError, type QueryResultErrors, type SolidityVerifierParameters, ZKPassport };
133
+ export { QueryBuilder, QueryResultErrors, SolidityVerifierParameters, ZKPassport };