@zkpassport/sdk 0.14.2 → 0.15.0-alpha.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.
- package/dist/cjs/index.cjs +2 -2
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/cjs/index.d.cts +57 -11
- package/dist/esm/index.d.ts +57 -11
- package/dist/esm/index.js +2 -2
- package/dist/esm/index.js.map +1 -1
- package/package.json +2 -2
package/dist/cjs/index.d.cts
CHANGED
|
@@ -40,6 +40,23 @@ type SolidityVerifierParameters = {
|
|
|
40
40
|
committedInputs: string;
|
|
41
41
|
serviceConfig: SolidityServiceConfig;
|
|
42
42
|
};
|
|
43
|
+
type Policy = {
|
|
44
|
+
id: string;
|
|
45
|
+
version: number;
|
|
46
|
+
name: string;
|
|
47
|
+
purpose: string;
|
|
48
|
+
projectId: string | null;
|
|
49
|
+
query: Query;
|
|
50
|
+
};
|
|
51
|
+
type DashboardConfig = {
|
|
52
|
+
project: {
|
|
53
|
+
name: string;
|
|
54
|
+
domain: string;
|
|
55
|
+
logoUrl: string | null;
|
|
56
|
+
allowedOrigins: string[];
|
|
57
|
+
};
|
|
58
|
+
policies: Policy[];
|
|
59
|
+
};
|
|
43
60
|
type QueryBuilderResult = {
|
|
44
61
|
/**
|
|
45
62
|
* The URL of the request.
|
|
@@ -56,6 +73,10 @@ type QueryBuilderResult = {
|
|
|
56
73
|
* The id of the request.
|
|
57
74
|
*/
|
|
58
75
|
requestId: string;
|
|
76
|
+
/**
|
|
77
|
+
* The id of the policy used to build the request, if one was provided.
|
|
78
|
+
*/
|
|
79
|
+
policy?: string;
|
|
59
80
|
/**
|
|
60
81
|
* Called when the user has scanned the QR code or clicked the link to the request.
|
|
61
82
|
*
|
|
@@ -92,6 +113,8 @@ type QueryBuilderResult = {
|
|
|
92
113
|
verified: boolean;
|
|
93
114
|
result: QueryResult;
|
|
94
115
|
queryResultErrors?: Partial<QueryResultErrors>;
|
|
116
|
+
proofs: ProofResult[];
|
|
117
|
+
sdkInstance: ZKPassport;
|
|
95
118
|
}) => void) => void;
|
|
96
119
|
/**
|
|
97
120
|
* Called when the user has rejected the request.
|
|
@@ -203,6 +226,13 @@ type QueryBuilder<T extends "online" | "offline" = "online"> = {
|
|
|
203
226
|
* Best for lower security requirements that requires fast verification such as age verification.
|
|
204
227
|
*/
|
|
205
228
|
facematch: (mode?: FacematchMode) => QueryBuilder;
|
|
229
|
+
/**
|
|
230
|
+
* Applies an immutable policy fetched from the dashboard. The policy's query,
|
|
231
|
+
* purpose and scope are locked; combining with builder methods or calling
|
|
232
|
+
* twice throws.
|
|
233
|
+
* @param id The policy id (e.g. `'pol_xyz'`).
|
|
234
|
+
*/
|
|
235
|
+
policy: (id: string) => QueryBuilder<T>;
|
|
206
236
|
/**
|
|
207
237
|
* Builds the request.
|
|
208
238
|
*
|
|
@@ -215,15 +245,22 @@ type QueryBuilder<T extends "online" | "offline" = "online"> = {
|
|
|
215
245
|
|
|
216
246
|
declare class ZKPassport {
|
|
217
247
|
private domain;
|
|
248
|
+
private domainProvided;
|
|
249
|
+
private disableProofStorage;
|
|
218
250
|
private topicToConfig;
|
|
219
251
|
private topicToLocalConfig;
|
|
220
252
|
private topicToPublicKey;
|
|
221
253
|
private topicToBridge;
|
|
222
254
|
private topicToRequestReceived;
|
|
223
255
|
private topicToService;
|
|
256
|
+
private topicToCallerPurpose;
|
|
224
257
|
private topicToProofs;
|
|
225
258
|
private topicToFailedProofCount;
|
|
226
259
|
private topicToResults;
|
|
260
|
+
private topicToPolicy;
|
|
261
|
+
private dashboardConfig;
|
|
262
|
+
private dashboardConfigPromise;
|
|
263
|
+
private dashboardConfigError;
|
|
227
264
|
private onRequestReceivedCallbacks;
|
|
228
265
|
private onGeneratingProofCallbacks;
|
|
229
266
|
private onBridgeConnectCallbacks;
|
|
@@ -232,7 +269,9 @@ declare class ZKPassport {
|
|
|
232
269
|
private onRejectCallbacks;
|
|
233
270
|
private onErrorCallbacks;
|
|
234
271
|
private normalizeDomain;
|
|
235
|
-
constructor(_domain?: string
|
|
272
|
+
constructor(_domain?: string, options?: {
|
|
273
|
+
disableProofStorage?: boolean;
|
|
274
|
+
});
|
|
236
275
|
private handleResult;
|
|
237
276
|
/**
|
|
238
277
|
* @notice Handle an encrypted message.
|
|
@@ -240,22 +279,29 @@ declare class ZKPassport {
|
|
|
240
279
|
* @param outerRequest The outer request.
|
|
241
280
|
*/
|
|
242
281
|
private handleEncryptedMessage;
|
|
282
|
+
private assertNotPolicyLocked;
|
|
243
283
|
private getZkPassportRequest;
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
* @
|
|
284
|
+
private getDashboardConfig;
|
|
285
|
+
private fetchDashboardConfig;
|
|
286
|
+
private findPolicy;
|
|
287
|
+
private assertCanApplyPolicy;
|
|
288
|
+
/**
|
|
289
|
+
* @notice Create a new request. To apply a policy, chain `.policy('<id>')` on
|
|
290
|
+
* the returned builder; a policy locks the query and scope.
|
|
291
|
+
* @param name Your service name. Defaults to the dashboard branding, then the domain.
|
|
292
|
+
* @param logo Your service logo. Defaults to the dashboard branding.
|
|
293
|
+
* @param purpose Explanation shown to the user. Defaults to the policy's purpose (if any), then a generic message.
|
|
294
|
+
* @param scope Use-case scope (drives the nullifier). Defaults to the domain. Locked by `.policy()` (to `<id>:<version>`).
|
|
250
295
|
* @param projectID The project ID of your service
|
|
251
296
|
* @param validity How many seconds ago the proof checking the expiry date of the ID should have been generated
|
|
297
|
+
* @param mode The proof mode (e.g. "fast" / "compressed").
|
|
252
298
|
* @param devMode Whether to enable dev mode. This will allow you to verify mock proofs (i.e. from ZKR)
|
|
253
299
|
* @returns The query builder object.
|
|
254
300
|
*/
|
|
255
301
|
request({ name, logo, purpose, scope, projectID, mode, validity, devMode, uniqueIdentifierType, oprfKeyId, topicOverride, keyPairOverride, cloudProverUrl, bridgeUrl, }: {
|
|
256
|
-
name
|
|
257
|
-
logo
|
|
258
|
-
purpose
|
|
302
|
+
name?: string;
|
|
303
|
+
logo?: string;
|
|
304
|
+
purpose?: string;
|
|
259
305
|
scope?: string;
|
|
260
306
|
mode?: ProofMode;
|
|
261
307
|
projectID?: string;
|
|
@@ -351,4 +397,4 @@ declare class ZKPassport {
|
|
|
351
397
|
clearAllRequests(): void;
|
|
352
398
|
}
|
|
353
399
|
|
|
354
|
-
export { type OfflineQueryBuilderResult, type QueryBuilder, type QueryBuilderResult, type QueryResultError, type QueryResultErrors, type SolidityProofVerificationData, type SolidityServiceConfig, type SolidityVerifierParameters, ZKPassport };
|
|
400
|
+
export { type DashboardConfig, type OfflineQueryBuilderResult, type Policy, type QueryBuilder, type QueryBuilderResult, type QueryResultError, type QueryResultErrors, type SolidityProofVerificationData, type SolidityServiceConfig, type SolidityVerifierParameters, ZKPassport };
|
package/dist/esm/index.d.ts
CHANGED
|
@@ -40,6 +40,23 @@ type SolidityVerifierParameters = {
|
|
|
40
40
|
committedInputs: string;
|
|
41
41
|
serviceConfig: SolidityServiceConfig;
|
|
42
42
|
};
|
|
43
|
+
type Policy = {
|
|
44
|
+
id: string;
|
|
45
|
+
version: number;
|
|
46
|
+
name: string;
|
|
47
|
+
purpose: string;
|
|
48
|
+
projectId: string | null;
|
|
49
|
+
query: Query;
|
|
50
|
+
};
|
|
51
|
+
type DashboardConfig = {
|
|
52
|
+
project: {
|
|
53
|
+
name: string;
|
|
54
|
+
domain: string;
|
|
55
|
+
logoUrl: string | null;
|
|
56
|
+
allowedOrigins: string[];
|
|
57
|
+
};
|
|
58
|
+
policies: Policy[];
|
|
59
|
+
};
|
|
43
60
|
type QueryBuilderResult = {
|
|
44
61
|
/**
|
|
45
62
|
* The URL of the request.
|
|
@@ -56,6 +73,10 @@ type QueryBuilderResult = {
|
|
|
56
73
|
* The id of the request.
|
|
57
74
|
*/
|
|
58
75
|
requestId: string;
|
|
76
|
+
/**
|
|
77
|
+
* The id of the policy used to build the request, if one was provided.
|
|
78
|
+
*/
|
|
79
|
+
policy?: string;
|
|
59
80
|
/**
|
|
60
81
|
* Called when the user has scanned the QR code or clicked the link to the request.
|
|
61
82
|
*
|
|
@@ -92,6 +113,8 @@ type QueryBuilderResult = {
|
|
|
92
113
|
verified: boolean;
|
|
93
114
|
result: QueryResult;
|
|
94
115
|
queryResultErrors?: Partial<QueryResultErrors>;
|
|
116
|
+
proofs: ProofResult[];
|
|
117
|
+
sdkInstance: ZKPassport;
|
|
95
118
|
}) => void) => void;
|
|
96
119
|
/**
|
|
97
120
|
* Called when the user has rejected the request.
|
|
@@ -203,6 +226,13 @@ type QueryBuilder<T extends "online" | "offline" = "online"> = {
|
|
|
203
226
|
* Best for lower security requirements that requires fast verification such as age verification.
|
|
204
227
|
*/
|
|
205
228
|
facematch: (mode?: FacematchMode) => QueryBuilder;
|
|
229
|
+
/**
|
|
230
|
+
* Applies an immutable policy fetched from the dashboard. The policy's query,
|
|
231
|
+
* purpose and scope are locked; combining with builder methods or calling
|
|
232
|
+
* twice throws.
|
|
233
|
+
* @param id The policy id (e.g. `'pol_xyz'`).
|
|
234
|
+
*/
|
|
235
|
+
policy: (id: string) => QueryBuilder<T>;
|
|
206
236
|
/**
|
|
207
237
|
* Builds the request.
|
|
208
238
|
*
|
|
@@ -215,15 +245,22 @@ type QueryBuilder<T extends "online" | "offline" = "online"> = {
|
|
|
215
245
|
|
|
216
246
|
declare class ZKPassport {
|
|
217
247
|
private domain;
|
|
248
|
+
private domainProvided;
|
|
249
|
+
private disableProofStorage;
|
|
218
250
|
private topicToConfig;
|
|
219
251
|
private topicToLocalConfig;
|
|
220
252
|
private topicToPublicKey;
|
|
221
253
|
private topicToBridge;
|
|
222
254
|
private topicToRequestReceived;
|
|
223
255
|
private topicToService;
|
|
256
|
+
private topicToCallerPurpose;
|
|
224
257
|
private topicToProofs;
|
|
225
258
|
private topicToFailedProofCount;
|
|
226
259
|
private topicToResults;
|
|
260
|
+
private topicToPolicy;
|
|
261
|
+
private dashboardConfig;
|
|
262
|
+
private dashboardConfigPromise;
|
|
263
|
+
private dashboardConfigError;
|
|
227
264
|
private onRequestReceivedCallbacks;
|
|
228
265
|
private onGeneratingProofCallbacks;
|
|
229
266
|
private onBridgeConnectCallbacks;
|
|
@@ -232,7 +269,9 @@ declare class ZKPassport {
|
|
|
232
269
|
private onRejectCallbacks;
|
|
233
270
|
private onErrorCallbacks;
|
|
234
271
|
private normalizeDomain;
|
|
235
|
-
constructor(_domain?: string
|
|
272
|
+
constructor(_domain?: string, options?: {
|
|
273
|
+
disableProofStorage?: boolean;
|
|
274
|
+
});
|
|
236
275
|
private handleResult;
|
|
237
276
|
/**
|
|
238
277
|
* @notice Handle an encrypted message.
|
|
@@ -240,22 +279,29 @@ declare class ZKPassport {
|
|
|
240
279
|
* @param outerRequest The outer request.
|
|
241
280
|
*/
|
|
242
281
|
private handleEncryptedMessage;
|
|
282
|
+
private assertNotPolicyLocked;
|
|
243
283
|
private getZkPassportRequest;
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
* @
|
|
284
|
+
private getDashboardConfig;
|
|
285
|
+
private fetchDashboardConfig;
|
|
286
|
+
private findPolicy;
|
|
287
|
+
private assertCanApplyPolicy;
|
|
288
|
+
/**
|
|
289
|
+
* @notice Create a new request. To apply a policy, chain `.policy('<id>')` on
|
|
290
|
+
* the returned builder; a policy locks the query and scope.
|
|
291
|
+
* @param name Your service name. Defaults to the dashboard branding, then the domain.
|
|
292
|
+
* @param logo Your service logo. Defaults to the dashboard branding.
|
|
293
|
+
* @param purpose Explanation shown to the user. Defaults to the policy's purpose (if any), then a generic message.
|
|
294
|
+
* @param scope Use-case scope (drives the nullifier). Defaults to the domain. Locked by `.policy()` (to `<id>:<version>`).
|
|
250
295
|
* @param projectID The project ID of your service
|
|
251
296
|
* @param validity How many seconds ago the proof checking the expiry date of the ID should have been generated
|
|
297
|
+
* @param mode The proof mode (e.g. "fast" / "compressed").
|
|
252
298
|
* @param devMode Whether to enable dev mode. This will allow you to verify mock proofs (i.e. from ZKR)
|
|
253
299
|
* @returns The query builder object.
|
|
254
300
|
*/
|
|
255
301
|
request({ name, logo, purpose, scope, projectID, mode, validity, devMode, uniqueIdentifierType, oprfKeyId, topicOverride, keyPairOverride, cloudProverUrl, bridgeUrl, }: {
|
|
256
|
-
name
|
|
257
|
-
logo
|
|
258
|
-
purpose
|
|
302
|
+
name?: string;
|
|
303
|
+
logo?: string;
|
|
304
|
+
purpose?: string;
|
|
259
305
|
scope?: string;
|
|
260
306
|
mode?: ProofMode;
|
|
261
307
|
projectID?: string;
|
|
@@ -351,4 +397,4 @@ declare class ZKPassport {
|
|
|
351
397
|
clearAllRequests(): void;
|
|
352
398
|
}
|
|
353
399
|
|
|
354
|
-
export { type OfflineQueryBuilderResult, type QueryBuilder, type QueryBuilderResult, type QueryResultError, type QueryResultErrors, type SolidityProofVerificationData, type SolidityServiceConfig, type SolidityVerifierParameters, ZKPassport };
|
|
400
|
+
export { type DashboardConfig, type OfflineQueryBuilderResult, type Policy, type QueryBuilder, type QueryBuilderResult, type QueryResultError, type QueryResultErrors, type SolidityProofVerificationData, type SolidityServiceConfig, type SolidityVerifierParameters, ZKPassport };
|