@zk-email/sdk 0.0.86 → 0.0.87

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 (38) hide show
  1. package/README.md +30 -6
  2. package/dist/ccip-CkoSjJUg.mjs +147 -0
  3. package/dist/ccip-CkoSjJUg.mjs.map +1 -0
  4. package/dist/ccip-w_MIWPz4.js +2 -0
  5. package/dist/ccip-w_MIWPz4.js.map +1 -0
  6. package/dist/index-BgOHM3Bb.mjs +13594 -0
  7. package/dist/index-BgOHM3Bb.mjs.map +1 -0
  8. package/dist/index-DQibsX5L.js +41 -0
  9. package/dist/index-DQibsX5L.js.map +1 -0
  10. package/dist/types/auth.d.ts +3 -0
  11. package/dist/types/blueprint.d.ts +132 -0
  12. package/dist/types/blueprintValidation.d.ts +82 -0
  13. package/dist/types/chain/index.d.ts +2 -0
  14. package/dist/types/index.d.ts +24 -0
  15. package/dist/types/localProverWorkerString.d.ts +1 -0
  16. package/dist/types/proof.d.ts +52 -0
  17. package/dist/types/prover.d.ts +39 -0
  18. package/dist/types/relayerUtils.d.ts +14 -0
  19. package/dist/types/types/auth.d.ts +16 -0
  20. package/dist/types/types/blueprint.d.ts +155 -0
  21. package/dist/types/types/index.d.ts +6 -0
  22. package/dist/types/types/proof.d.ts +63 -0
  23. package/dist/types/types/prover.d.ts +8 -0
  24. package/dist/types/types/sdk.d.ts +5 -0
  25. package/dist/types/types/utils.d.ts +8 -0
  26. package/dist/types/user.d.ts +5 -0
  27. package/dist/types/utils.d.ts +7 -0
  28. package/dist/zk-email-sdk.cjs.js +2 -0
  29. package/dist/zk-email-sdk.cjs.js.map +1 -0
  30. package/dist/zk-email-sdk.es.js +18 -0
  31. package/dist/zk-email-sdk.es.js.map +1 -0
  32. package/package.json +25 -11
  33. package/dist/index.d.mts +0 -557
  34. package/dist/index.d.ts +0 -557
  35. package/dist/index.js +0 -7
  36. package/dist/index.js.map +0 -1
  37. package/dist/index.mjs +0 -7
  38. package/dist/index.mjs.map +0 -1
package/dist/index.d.ts DELETED
@@ -1,557 +0,0 @@
1
- import { z } from 'zod';
2
- export { ZodError } from 'zod';
3
-
4
- type BlueprintProps = {
5
- id?: string;
6
- title: string;
7
- description?: string;
8
- slug?: string;
9
- tags?: string[];
10
- emailQuery?: string;
11
- circuitName: string;
12
- ignoreBodyHashCheck?: boolean;
13
- shaPrecomputeSelector?: string;
14
- emailBodyMaxLength?: number;
15
- emailHeaderMaxLength?: number;
16
- removeSoftLinebreaks?: boolean;
17
- githubUsername?: string;
18
- senderDomain?: string;
19
- enableHeaderMasking?: boolean;
20
- enableBodyMasking?: boolean;
21
- zkFramework?: ZkFramework;
22
- isPublic?: boolean;
23
- createdAt?: Date;
24
- updatedAt?: Date;
25
- externalInputs?: ExternalInput[];
26
- decomposedRegexes: DecomposedRegex[];
27
- status?: Status;
28
- verifierContract?: VerifierContract;
29
- version?: number;
30
- };
31
- type DecomposedRegex = {
32
- parts: DecomposedRegexPart[];
33
- name: string;
34
- maxLength: number;
35
- location: "body" | "header";
36
- };
37
- type DecomposedRegexPart = {
38
- isPublic: boolean;
39
- regexDef: string;
40
- };
41
- type DecomposedRegexJson = {
42
- parts: DecomposedRegexPartJson[];
43
- name: string;
44
- max_length: number;
45
- location: "body" | "header";
46
- };
47
- type DecomposedRegexPartJson = {
48
- is_public: boolean;
49
- regex_def: string;
50
- };
51
- type ExternalInput = {
52
- name: string;
53
- maxLength: number;
54
- };
55
- declare enum ZkFramework {
56
- Circom = "circom"
57
- }
58
- declare enum Status {
59
- None = 0,
60
- Draft = 1,
61
- InProgress = 2,
62
- Done = 3,
63
- Failed = 4
64
- }
65
- type VerifierContract = {
66
- address?: string;
67
- chain: number;
68
- };
69
- type BlueprintRequest = {
70
- id?: string;
71
- title: string;
72
- description?: string;
73
- slug?: string;
74
- tags?: string[];
75
- email_query?: string;
76
- circuit_name?: string;
77
- ignore_body_hash_check?: boolean;
78
- sha_precompute_selector?: string;
79
- email_body_max_length?: number;
80
- email_header_max_length?: number;
81
- remove_soft_linebreaks?: boolean;
82
- github_username?: string;
83
- sender_domain?: string;
84
- enable_header_masking?: boolean;
85
- enable_body_masking?: boolean;
86
- zk_framework?: string;
87
- is_public?: boolean;
88
- external_inputs?: ExternalInputResponse[];
89
- decomposed_regexes: DecomposedRegexResponse[];
90
- status?: string;
91
- verifier_contract_address?: string;
92
- verifier_contract_chain?: number;
93
- version?: number;
94
- };
95
- type BlueprintResponse = {
96
- id: string;
97
- title: string;
98
- description: string;
99
- slug: string;
100
- tags: string[];
101
- email_query: string;
102
- circuit_name: string;
103
- ignore_body_hash_check: boolean;
104
- sha_precompute_selector: string;
105
- email_body_max_length: number;
106
- email_header_max_length?: number;
107
- remove_soft_linebreaks?: boolean;
108
- github_username?: string;
109
- sender_domain: string;
110
- enable_header_masking?: boolean;
111
- enable_body_masking?: boolean;
112
- zk_framework: string;
113
- is_public: boolean;
114
- created_at: ServerDate;
115
- updated_at: ServerDate;
116
- external_inputs: ExternalInputResponse[];
117
- decomposed_regexes: DecomposedRegexResponse[];
118
- status: number;
119
- verifier_contract_address: string;
120
- verifier_contract_chain: number;
121
- version: number;
122
- };
123
- type ServerDate = {
124
- seconds: number;
125
- nanos: number;
126
- };
127
- type ExternalInputResponse = {
128
- name: string;
129
- max_length: number;
130
- };
131
- type DecomposedRegexResponse = {
132
- parts: DecomposedRegexPartResponse[];
133
- name: string;
134
- max_length: number;
135
- location: "body" | "header";
136
- };
137
- type DecomposedRegexPartResponse = {
138
- is_public: boolean;
139
- regex_def: string;
140
- };
141
- type ListBlueprintsOptions = {
142
- skip?: number;
143
- limit?: number;
144
- sort?: -1 | 1;
145
- status?: Status[];
146
- isPublic?: boolean;
147
- search?: string;
148
- };
149
- type ListBlueprintsOptionsRequest = {
150
- skip?: number;
151
- limit?: number;
152
- sort?: -1 | 1;
153
- status?: Status[];
154
- is_public?: boolean;
155
- search?: string;
156
- };
157
- type DownloadUrls = Record<string, string>;
158
-
159
- declare enum ProofStatus {
160
- None = 0,
161
- InProgress = 1,
162
- Done = 2,
163
- Failed = 3
164
- }
165
- type ProofProps = {
166
- id: string;
167
- blueprintId: string;
168
- input: string;
169
- proofData?: string;
170
- publicData?: string;
171
- publicOutputs?: string[];
172
- externalInputs?: string;
173
- status?: ProofStatus;
174
- startedAt?: Date;
175
- provedAt?: Date;
176
- };
177
- type ProofResponse = {
178
- id: string;
179
- blueprint_id: string;
180
- input: string;
181
- proof?: string;
182
- public?: string;
183
- external_inputs?: string;
184
- public_outputs?: string[];
185
- started_at: ServerDate;
186
- proved_at?: ServerDate;
187
- status: number;
188
- };
189
- type ProofRequest = {
190
- blueprint_id: string;
191
- input: any;
192
- external_inputs: any;
193
- };
194
- type GenerateProofInputsParams = {
195
- emailHeaderMaxLength: number;
196
- emailBodyMaxLength: number;
197
- ignoreBodyHashCheck: boolean;
198
- removeSoftLinebreaks: boolean;
199
- shaPrecomputeSelector?: string;
200
- };
201
- type GenerateProofInputsParamsInternal = {
202
- maxHeaderLength: number;
203
- maxBodyLength: number;
204
- ignoreBodyHashCheck: boolean;
205
- removeSoftLinesBreaks: boolean;
206
- shaPrecomputeSelector?: string;
207
- };
208
- type ProofData = {
209
- pi_a: [string, string, string];
210
- pi_b: [[string, string], [string, string], [string, string]];
211
- pi_c: [string, string, string];
212
- protocol: string;
213
- };
214
-
215
- /**
216
- * A generated proof. You get get proof data and verify proofs on chain.
217
- */
218
- declare class Proof {
219
- blueprint: Blueprint;
220
- props: ProofProps;
221
- private lastCheckedStatus;
222
- constructor(blueprint: Blueprint, props: ProofProps);
223
- getId(): string;
224
- /**
225
- * Returns a download link for the files of the proof.
226
- * @returns The the url to download a zip of the proof files.
227
- */
228
- getProofDataDownloadLink(): Promise<string>;
229
- startFilesDownload(): Promise<void>;
230
- /**
231
- * Checks the status of proof.
232
- * checkStatus can be used in a while(await checkStatus()) loop, since it will wait a fixed
233
- * amount of time before the second time you call it.
234
- * @returns A promise with the Status.
235
- */
236
- checkStatus(): Promise<ProofStatus>;
237
- waitForCompletion(): Promise<ProofStatus>;
238
- /**
239
- * Verifies the proof on chain using the verifier contract defined in the blueprint.
240
- * Will throw an error if it cannot verify the proof. If the function call succeeds,
241
- * the proof was validated.
242
- */
243
- verifyOnChain(): Promise<void>;
244
- /**
245
- * Generates call data for the proof that can be used to verify the proof on chain.
246
- */
247
- createCallData(): Promise<(bigint[] | bigint[][])[]>;
248
- /**
249
- * Fetches an existing Proof from the database.
250
- * @param id - Id of the Proof.
251
- * @returns A promise that resolves to a new instance of Proof.
252
- */
253
- static getProofById(id: string, baseUrl: string): Promise<Proof>;
254
- static responseToProofProps(response: ProofResponse): ProofProps;
255
- /**
256
- * @returns The public data and proof data.
257
- */
258
- getProofData(): {
259
- proofData: string;
260
- publicData: string;
261
- publicOutputs: string[];
262
- externalInputs: string;
263
- };
264
- }
265
-
266
- type ProverOptions = {
267
- isLocal: boolean;
268
- };
269
- type ExternalInputInput = {
270
- name: string;
271
- value: string;
272
- maxLength: number;
273
- };
274
-
275
- /**
276
- * Represents a Prover generated from a blueprint that can generate Proofs
277
- */
278
- declare class Prover {
279
- options: ProverOptions;
280
- blueprint: Blueprint;
281
- constructor(blueprint: Blueprint, options?: ProverOptions);
282
- /**
283
- * Generates a proof for a given email.
284
- * @param eml - Email to prove agains the blueprint of this Prover.
285
- * @returns A promise that resolves to a new instance of Proof. The Proof will have the status
286
- * Done or Failed.
287
- */
288
- generateProof(eml: string, externalInputs?: ExternalInputInput[]): Promise<Proof>;
289
- /**
290
- * Starts proving for a given email.
291
- * @param eml - Email to prove agains the blueprint of this Prover.
292
- * @returns A promise that resolves to a new instance of Proof. The Proof will have the status
293
- * InProgress.
294
- */
295
- generateProofRequest(eml: string, externalInputs?: ExternalInputInput[]): Promise<Proof>;
296
- }
297
-
298
- /**
299
- * Interface for authentication for creating and updating blueprints
300
- */
301
- type Auth = {
302
- /**
303
- * Retrieves the authentication token
304
- * e.g. from a req for next.js or the localstorage for frontend
305
- * @returns Promise that resolves to the token string or null if no token exists
306
- */
307
- getToken: () => Promise<string | null>;
308
- /**
309
- * Callback triggered when the authentication token expires
310
- * @returns Promise that resolves when expired token is handled
311
- */
312
- onTokenExpired: () => Promise<void>;
313
- };
314
-
315
- declare const blueprintFormSchema: z.ZodObject<{
316
- title: z.ZodString;
317
- circuitName: z.ZodString;
318
- description: z.ZodString;
319
- emailQuery: z.ZodString;
320
- ignoreBodyHashCheck: z.ZodBoolean;
321
- shaPrecomputeSelector: z.ZodOptional<z.ZodEffects<z.ZodString, string, string>>;
322
- senderDomain: z.ZodEffects<z.ZodString, string, string>;
323
- emailBodyMaxLength: z.ZodEffects<z.ZodNumber, number, number>;
324
- emailHeaderMaxLength: z.ZodDefault<z.ZodEffects<z.ZodNumber, number, number>>;
325
- decomposedRegexes: z.ZodArray<z.ZodObject<{
326
- name: z.ZodEffects<z.ZodString, string, string>;
327
- maxLength: z.ZodDefault<z.ZodNumber>;
328
- location: z.ZodString;
329
- parts: z.ZodUnion<[z.ZodOptional<z.ZodEffects<z.ZodString, any[], string>>, z.ZodArray<z.ZodAny, "many">]>;
330
- }, "strip", z.ZodTypeAny, {
331
- name: string;
332
- maxLength: number;
333
- location: string;
334
- parts?: any[] | undefined;
335
- }, {
336
- name: string;
337
- location: string;
338
- maxLength?: number | undefined;
339
- parts?: string | any[] | undefined;
340
- }>, "many">;
341
- externalInputs: z.ZodOptional<z.ZodArray<z.ZodObject<{
342
- name: z.ZodString;
343
- maxLength: z.ZodDefault<z.ZodNumber>;
344
- }, "strip", z.ZodTypeAny, {
345
- name: string;
346
- maxLength: number;
347
- }, {
348
- name: string;
349
- maxLength?: number | undefined;
350
- }>, "many">>;
351
- }, "strip", z.ZodTypeAny, {
352
- description: string;
353
- title: string;
354
- circuitName: string;
355
- emailQuery: string;
356
- ignoreBodyHashCheck: boolean;
357
- senderDomain: string;
358
- emailBodyMaxLength: number;
359
- emailHeaderMaxLength: number;
360
- decomposedRegexes: {
361
- name: string;
362
- maxLength: number;
363
- location: string;
364
- parts?: any[] | undefined;
365
- }[];
366
- shaPrecomputeSelector?: string | undefined;
367
- externalInputs?: {
368
- name: string;
369
- maxLength: number;
370
- }[] | undefined;
371
- }, {
372
- description: string;
373
- title: string;
374
- circuitName: string;
375
- emailQuery: string;
376
- ignoreBodyHashCheck: boolean;
377
- senderDomain: string;
378
- emailBodyMaxLength: number;
379
- decomposedRegexes: {
380
- name: string;
381
- location: string;
382
- maxLength?: number | undefined;
383
- parts?: string | any[] | undefined;
384
- }[];
385
- shaPrecomputeSelector?: string | undefined;
386
- emailHeaderMaxLength?: number | undefined;
387
- externalInputs?: {
388
- name: string;
389
- maxLength?: number | undefined;
390
- }[] | undefined;
391
- }>;
392
- type ValidationErrors = {
393
- [K in keyof z.infer<typeof blueprintFormSchema>]?: string;
394
- };
395
-
396
- /**
397
- * Represents a Regex Blueprint including the decomposed regex access to the circuit.
398
- */
399
- declare class Blueprint {
400
- props: BlueprintProps;
401
- auth?: Auth;
402
- baseUrl: string;
403
- stars: number;
404
- static readonly formSchema: typeof blueprintFormSchema;
405
- private lastCheckedStatus;
406
- constructor(props: BlueprintProps, baseUrl: string, auth?: Auth);
407
- addAuth(auth: Auth): void;
408
- /**
409
- * Fetches an existing RegexBlueprint from the database.
410
- * @param {string} id - Id of the RegexBlueprint.
411
- * @returns A promise that resolves to a new instance of RegexBlueprint.
412
- */
413
- static getBlueprintById(id: string, baseUrl: string, auth?: Auth): Promise<Blueprint>;
414
- /**
415
- * Fetches an existing RegexBlueprint by slug from the database.
416
- * @param slug - Slug of the blueprint. Must include version, e.g. "slug:v1"
417
- * @param version - Version of the slug.
418
- * @returns A promise that resolves to a new instance of RegexBlueprint.
419
- */
420
- static getBlueprintBySlug(slug: string, baseUrl: string, auth?: Auth): Promise<Blueprint>;
421
- private static responseToBlueprintProps;
422
- private static blueprintPropsToRequest;
423
- /**
424
- * Submits a new RegexBlueprint to the registry as draft.
425
- * This does not compile the circuits yet and you will still be able to make changes.
426
- * @returns A promise. Once it resolves, `getId` can be called.
427
- */
428
- submitDraft(): Promise<void>;
429
- /**
430
- * Submits a new version of the RegexBlueprint to the registry as draft.
431
- * This does not compile the circuits yet and you will still be able to make changes.
432
- * @param newProps - The updated blueprint props.
433
- * @returns A promise. Once it resolves, the current Blueprint will be replaced with the new one.
434
- */
435
- submitNewVersionDraft(newProps: BlueprintProps): Promise<void>;
436
- /**
437
- * Submits a new version of the blueprint. This will save the new blueprint version
438
- * and start the compilation.
439
- * This will also overwrite the current Blueprint with its new version, even if the last
440
- * version was not compiled yet.
441
- * @param newProps - The updated blueprint props.
442
- */
443
- submitNewVersion(newProps: BlueprintProps): Promise<void>;
444
- /**
445
- * Lists blueblueprints, only including the latest version per unique slug.
446
- * @param options - Options to filter the blueprints by.
447
- * @returns A promise. Once it resolves, `getId` can be called.
448
- */
449
- static listBlueprints(baseUrl: string, options?: ListBlueprintsOptions, auth?: Auth, fetchStars?: boolean): Promise<Blueprint[]>;
450
- /**
451
- * Submits a blueprint. This will save the blueprint if it didn't exist before
452
- * and start the compilation.
453
- */
454
- submit(): Promise<void>;
455
- private _checkStatus;
456
- /**
457
- * Checks the status of blueprint.
458
- * checkStatus can be used in a while(await checkStatus()) loop, since it will wait a fixed
459
- * amount of time the second time you call it.
460
- * @returns A promise with the Status.
461
- */
462
- checkStatus(): Promise<Status>;
463
- /**
464
- * Get the id of the blueprint.
465
- * @returns The id of the blueprint. If it was not saved yet, return null.
466
- */
467
- getId(): string | null;
468
- /**
469
- * Returns a download link for the ZKeys of the blueprint.
470
- * @returns The the url to download the ZKeys.
471
- */
472
- getZKeyDownloadLink(): Promise<DownloadUrls>;
473
- /**
474
- * Directly starts a download of the ZKeys in the browser.
475
- * Must be called within a user action, like a button click.
476
- */
477
- startZKeyDownload(): Promise<void>;
478
- /**
479
- * Creates an instance of Prover with which you can create proofs.
480
- * @returns An instance of Prover.
481
- */
482
- createProver(): Prover;
483
- /**
484
- * Verifies a proof on chain.
485
- * @param proof - The generated proof you want to verify.
486
- * @returns A true if the verification was successfull, false if it failed.
487
- */
488
- verifyProofOnChain(proof: Proof): Promise<boolean>;
489
- /**
490
- * Returns a deep cloned version of the Blueprints props.
491
- * This can be used to update properties and then to use them with createNewVersion.
492
- * @param proof - The generated proof you want to verify.
493
- * @returns A true if the verification was successfull, false if it failed.
494
- */
495
- getClonedProps(): BlueprintProps;
496
- /**
497
- * Returns true if the blueprint can be updated. A blueprint can be updated if the circuits
498
- * haven't beed compiled yet, i.e. the status is not Done. The blueprint also must be saved
499
- * already before it can be updated.
500
- * @returns true if it can be updated
501
- */
502
- canUpdate(): boolean;
503
- /**
504
- * Updates an existing blueprint that is not compiled yet.
505
- * @param newProps - The props the blueprint should be updated to.
506
- * @returns a promise.
507
- */
508
- update(newProps: BlueprintProps): Promise<void>;
509
- listAllVersions(): Promise<Blueprint[]>;
510
- addStar(): Promise<number>;
511
- removeStar(): Promise<number>;
512
- getStars(): Promise<number>;
513
- cancelCompilation(): Promise<void>;
514
- delete(): Promise<void>;
515
- }
516
-
517
- type SdkOptions = {
518
- auth?: Auth;
519
- baseUrl?: string;
520
- };
521
-
522
- type ParsedEmail = {
523
- canonicalizedHeader: string;
524
- canonicalizedBody: string;
525
- signature: number[];
526
- publicKey: any[];
527
- cleanedBody: string;
528
- headers: Map<string, string[]>;
529
- };
530
-
531
- declare function startJsonFileDownload(json: string, name?: string): void;
532
- declare function getDKIMSelector(emlContent: string): string | null;
533
-
534
- declare function parseEmail(eml: string): Promise<ParsedEmail>;
535
- declare function testBlueprint(eml: string, blueprint: BlueprintProps, revealPrivate?: boolean): Promise<string[][]>;
536
- declare function testDecomposedRegex(body: string, header: string, decomposedRegex: DecomposedRegex | DecomposedRegexJson, revealPrivate?: boolean): Promise<string[]>;
537
- declare function generateProofInputs(eml: string, decomposedRegexes: DecomposedRegex[], externalInputs: ExternalInputInput[], params: GenerateProofInputsParams): Promise<string>;
538
- declare function getMaxEmailBodyLength(emlContent: string, shaPrecomputeSelector: string): Promise<number>;
539
- declare function extractEMLDetails(emlContent: string): Promise<{
540
- senderDomain: string | null;
541
- headerLength: number;
542
- emailQuery: string;
543
- emailBodyMaxLength: number;
544
- }>;
545
-
546
- declare function getLoginWithGithubUrl(callbackUrl: string, githubClientId?: string): string;
547
-
548
- declare const _default: (sdkOptions?: SdkOptions) => {
549
- createBlueprint(props: BlueprintProps): Blueprint;
550
- getBlueprint(slug: string): Promise<Blueprint>;
551
- getBlueprintById(id: string): Promise<Blueprint>;
552
- listBlueprints(options?: ListBlueprintsOptions): Promise<Blueprint[]>;
553
- getProof(id: string): Promise<Proof>;
554
- getStarredBlueprints(): Promise<string[]>;
555
- };
556
-
557
- export { type Auth, Blueprint, type BlueprintProps, type BlueprintRequest, type BlueprintResponse, type DecomposedRegex, type DecomposedRegexJson, type DecomposedRegexPart, type DecomposedRegexPartJson, type DecomposedRegexPartResponse, type DecomposedRegexResponse, type DownloadUrls, type ExternalInput, type ExternalInputInput, type ExternalInputResponse, type GenerateProofInputsParams, type GenerateProofInputsParamsInternal, type ListBlueprintsOptions, type ListBlueprintsOptionsRequest, type ParsedEmail, Proof, type ProofData, type ProofProps, type ProofRequest, type ProofResponse, ProofStatus, type ProverOptions, type ServerDate, Status, type ValidationErrors, type VerifierContract, ZkFramework, _default as default, extractEMLDetails, generateProofInputs, getDKIMSelector, getLoginWithGithubUrl, getMaxEmailBodyLength, parseEmail, startJsonFileDownload, testBlueprint, testDecomposedRegex };
package/dist/index.js DELETED
@@ -1,7 +0,0 @@
1
- 'use strict';Object.defineProperty(exports,'__esModule',{value:true});var viem=require('viem'),chains=require('viem/chains'),relayerUtils=require('@zk-email/relayer-utils'),zod=require('zod');function O(n){return [{type:"function",name:"verify",inputs:[{name:"a",type:"uint256[2]",internalType:"uint256[2]"},{name:"b",type:"uint256[2][2]",internalType:"uint256[2][2]"},{name:"c",type:"uint256[2]",internalType:"uint256[2]"},{name:"signals",type:`uint256[${n}]`,internalType:`uint256[${n}]`}],outputs:[],stateMutability:"view"}]}async function b(n){if(!n.blueprint.props.verifierContract?.chain||!n.blueprint.props.verifierContract?.address)throw new Error("No verifier contract deployed for the blueprint of this proof");if(!n.props.proofData||!n.props.publicOutputs)throw new Error("No proof data generated yet");let e=viem.createPublicClient({chain:chains.base,transport:viem.http("https://sepolia.base.org")}),t=n.props.proofData,o=[[BigInt(t.pi_a[0]),BigInt(t.pi_a[1])],[[BigInt(t.pi_b[0][1]),BigInt(t.pi_b[0][0])],[BigInt(t.pi_b[1][1]),BigInt(t.pi_b[1][0])]],[BigInt(t.pi_c[0]),BigInt(t.pi_c[1])],n.props.publicOutputs.map(r=>BigInt(r))];console.log("Call data to verify: ",o),console.log("contract address: ",n.blueprint.props.verifierContract.address);try{await e.readContract({address:n.blueprint.props.verifierContract.address,abi:O(n.props.publicOutputs.length),functionName:"verify",args:o});}catch(r){throw console.error("Error verifying proof on chain:",r),r}}var B=(r=>(r[r.None=0]="None",r[r.InProgress=1]="InProgress",r[r.Done=2]="Done",r[r.Failed=3]="Failed",r))(B||{});var H="Ov23li0KABFCUsxBEQkn";function q(n,e=H){let t=encodeURIComponent(n);return `https://github.com/login/oauth/authorize?client_id=${e}&scope=user:email&state=${t}`}async function f(n){try{let e=await n.getToken();if(e||(await n.onTokenExpired(),e=await n.getToken()),!e)throw new Error("Failed to get new token");return `Bearer ${e}`}catch(e){throw console.error("Failed to get token from auth"),e}}var y="pk_live_51NXwT8cHf0vYAjQK9LzB3pM6R8gWx2F";async function m(n,e,t){let o=null;if(t)try{o=await f(t);}catch(r){console.error("Could not get token from auth",r);}try{let r={method:"POST",headers:{"Content-Type":"application/json","x-api-key":y,...o?{Authorization:o}:{}}};e&&(r.body=JSON.stringify(e));let s=await fetch(n,r),i=await s.json();if(!s.ok)throw new Error(`HTTP error! status: ${s.status}, message: ${i}`);return i}catch(r){throw console.error("POST Error:",r),r}}async function k(n,e,t){let o=null;if(t)try{o=await f(t);}catch(r){console.warn("Could not get token from auth",r);}try{let r={method:"PATCH",headers:{"Content-Type":"application/json","x-api-key":y,...o?{Authorization:o}:{}}};e&&(r.body=JSON.stringify(e));let s=await fetch(n,r),i=await s.json();if(!s.ok)throw new Error(`HTTP error! status: ${s.status}, message: ${i}`);return i}catch(r){throw console.error("PATCH Error:",r),r}}async function c(n,e,t){let o=null;if(t)try{o=await f(t);}catch(r){console.warn("Could not get token from auth",r);}try{let r=n;if(e){let i=new URLSearchParams;Object.entries(e).forEach(([a,u])=>{u&&i.append(a,String(u));}),i.size>0&&(r+=`?${i.toString()}`);}let s=await fetch(r,{method:"GET",headers:{"Content-Type":"application/json","x-api-key":y,...o?{Authorization:o}:{}}});if(!s.ok)throw new Error(`HTTP error! status: ${s.status}`);return await s.json()}catch(r){throw console.error("GET Error:",r),r}}async function w(n,e,t){let o=null;if(t)try{o=await f(t);}catch(r){console.error("Could not get token from auth",r);}try{let r={method:"DELETE",headers:{"Content-Type":"application/json","x-api-key":y,...o?{Authorization:o}:{}}};e&&(r.body=JSON.stringify(e));let s=await fetch(n,r),i=await s.json();if(!s.ok)throw new Error(`HTTP error! status: ${s.status}, message: ${i}`);return i}catch(r){throw console.error("DELETE Error:",r),r}}function N(n,e="data"){if(!window&&!document)throw Error("startFilesDownload can only be used in a browser");let t=new Blob([n],{type:"application/json"}),o=URL.createObjectURL(t),r=document.createElement("a");r.href=o,r.download=`${e}.json`,document.body.appendChild(r),r.click(),document.body.removeChild(r),URL.revokeObjectURL(o);}function j(n){let e=[],t=n.split(`
2
- `);for(let o of t){if(o.trim()==="")break;o.startsWith(" ")||o.startsWith(" ")?e[e.length-1]+=o.trim():e.push(o);}for(let o of e)if(o.includes("DKIM-Signature")){let r=o.match(/s=([^;]+)/);if(r&&r[1])return r[1].trim()}return null}var g=class n{blueprint;props;lastCheckedStatus=null;constructor(e,t){if(!(e instanceof d))throw new Error("Invalid blueprint: must be an instance of Blueprint class");if(this.blueprint=e,!t?.id)throw new Error("A proof must have an id");this.props={status:1,...t};}getId(){return this.props.id}async getProofDataDownloadLink(){if(this.props.status!==2)throw new Error("The proving is not done yet.");let e;try{e=await c(`${this.blueprint.baseUrl}/proof/files/${this.props.id}`);}catch(t){throw console.error("Failed calling GET on /proof/files/:id in getProofDataDownloadLink: ",t),t}return e.url}async startFilesDownload(){if(!window&&!document)throw Error("startFilesDownload can only be used in a browser");let e;try{e=await this.getProofDataDownloadLink();}catch(o){throw console.error("Failed to start download of ZKeys: ",o),o}let t=document.createElement("a");t.href=e,t.download="proof_files.zip",document.body.appendChild(t),t.click(),document.body.removeChild(t);}async checkStatus(){if(this.props.status===2)return this.props.status;if(!this.lastCheckedStatus)this.lastCheckedStatus=new Date;else {let o=new Date().getTime()-this.lastCheckedStatus.getTime();o<500&&await new Promise(r=>setTimeout(r,500-o));}let e;try{e=await c(`${this.blueprint.baseUrl}/proof/status/${this.props.id}`);}catch(t){throw console.error("Failed calling GET /blueprint/status in getStatus(): ",t),t}if([1,2].includes(this.props.status)&&this.props.status!==e.status){let t=await n.getProofById(this.props.id,this.blueprint.baseUrl);return this.props=t.props,this.props.status}return this.props.status=e.status,e.status}async waitForCompletion(){for(;await this.checkStatus()===1;);return this.props.status}async verifyOnChain(){await b(this);}async createCallData(){if(!this.props.proofData||!this.props.publicOutputs)throw new Error("No proof data generated yet");let e=this.props.proofData;return [[BigInt(e.pi_a[0]),BigInt(e.pi_a[1])],[[BigInt(e.pi_b[0][1]),BigInt(e.pi_b[0][0])],[BigInt(e.pi_b[1][1]),BigInt(e.pi_b[1][0])]],[BigInt(e.pi_c[0]),BigInt(e.pi_c[1])],this.props.publicOutputs.map(t=>BigInt(t))]}static async getProofById(e,t){let o;try{o=await c(`${t}/proof/${e}`);}catch(i){throw console.error("Failed calling /proof/:id in getProofById: ",i),i}let r=this.responseToProofProps(o),s=await d.getBlueprintById(o.blueprint_id,t);return new n(s,r)}static responseToProofProps(e){return {id:e.id,blueprintId:e.blueprint_id,status:e.status,input:e.input,proofData:e.proof,publicData:e.public,publicOutputs:e.public_outputs,externalInputs:e.external_inputs,startedAt:new Date(e.started_at.seconds*1e3),provedAt:e.proved_at?new Date(e.proved_at.seconds*1e3):void 0}}getProofData(){if(this.props.status!==2)throw new Error("Cannot get proof data, proof is not Done");return {proofData:this.props.proofData,publicData:this.props.publicData,publicOutputs:this.props.publicOutputs,externalInputs:this.props.externalInputs}}};var v,P=new Promise(n=>{v=n;});relayerUtils.init().then(()=>{v(null);}).catch(n=>{console.log("Failed to initialize wasm for relayer-utils: ",n);});async function x(n){try{return await P,await relayerUtils.parseEmail(n)}catch(e){throw console.error("Failed to parse email: ",e),e}}async function V(n,e,t=!1){let o=await x(n);if(e.emailBodyMaxLength===void 0&&!e.ignoreBodyHashCheck||e.emailHeaderMaxLength===void 0)throw new Error("emailBodyMaxLength and emailHeaderMaxLength must be provided");let r=o.cleanedBody;if(e.shaPrecomputeSelector){let a=r.split(e.shaPrecomputeSelector)[1];if(!a)throw new Error(`Precompute selector was not found in email, selector: ${e.shaPrecomputeSelector}`);r=a;}let s=o.canonicalizedHeader;return await K(s,r,e),await Promise.all(e.decomposedRegexes.map(a=>L(r,s,a,t)))}async function K(n,e,t){await P;let o=new TextEncoder,r=o.encode(n);if((await relayerUtils.sha256Pad(r,t.emailHeaderMaxLength)).get("messageLength")>t.emailHeaderMaxLength)throw new Error(`emailHeaderMaxLength of ${t.emailHeaderMaxLength} was exceeded`);if(!t.ignoreBodyHashCheck){let i=o.encode(e),a=(e.length+63+65)/64*64,u=Math.max(a,t.emailBodyMaxLength);if((await relayerUtils.sha256Pad(i,u)).get("messageLength")>t.emailBodyMaxLength)throw new Error(`emailBodyMaxLength of ${t.emailBodyMaxLength} was exceeded`)}}async function L(n,e,t,o=!1){let r={parts:t.parts.map(p=>({is_public:"isPublic"in p?p.isPublic:p.is_public,regex_def:"regexDef"in p?p.regexDef:p.regex_def}))},s;if(t.location==="body")s=n;else if(t.location==="header")s=e;else throw Error(`Unsupported location ${t.location}`);let i="maxLength"in t?t.maxLength:t.max_length;await P;let a=relayerUtils.extractSubstr(s,r,!1);if(a[0].length>i)throw new Error(`Max length of extracted result was exceeded for decomposed regex ${t.name}`);return o?relayerUtils.extractSubstr(s,r,o):a}async function D(n,e,t,o){try{let r={maxHeaderLength:o.emailHeaderMaxLength,maxBodyLength:o.emailBodyMaxLength,ignoreBodyHashCheck:o.ignoreBodyHashCheck,removeSoftLinesBreaks:o.removeSoftLinebreaks,shaPrecomputeSelector:o.shaPrecomputeSelector};await P;let s=e.map(a=>({...a,parts:a.parts.map(u=>({is_public:u.isPublic||!!u.is_public,regex_def:u.regexDef||!!u.regex_def}))})),i=await relayerUtils.generateCircuitInputsWithDecomposedRegexesAndExternalInputs(n,s,t,r);return JSON.stringify(Object.fromEntries(i))}catch(r){throw console.error("Failed to generate inputs for proof"),r}}async function Z(n,e){let o=(await x(n)).cleanedBody,r=o.indexOf(e);return r===-1?o.length:o.length-r-e.length}async function W(n){let e={},t=n.split(`
3
- `),o=!0,r=[];for(let h of t)o&&(h.trim()===""?o=!1:r.push(h));r.map(h=>h.startsWith(" ")||h.startsWith(" ")?h.trim():`
4
- ${h.trim()}`).join("").split(`
5
- `).forEach(h=>{let[E,...A]=h.split(":");E&&(e[E.trim()]=A.join(":").trim());});let i=e["Return-Path"]?.match(/@([^\s>]+)/)?.[1]?.split(".").slice(-2).join(".")||null,a=`from:${i}`,u=await x(n);console.log(u.canonicalizedBody,"parsedEmail");let p=u.cleanedBody.length,$=u.canonicalizedHeader.length;return {senderDomain:i,headerLength:$,emailQuery:a,emailBodyMaxLength:p}}var _=class{options;blueprint;constructor(e,t){if(t?.isLocal===!0)throw new Error("Local proving is not supported yet");if(!(e instanceof d))throw new Error("Invalid blueprint: must be an instance of Blueprint class");this.blueprint=e,this.options={isLocal:!1,...t||{}};}async generateProof(e,t=[]){let o=await this.generateProofRequest(e,t);for(;![2,3].includes(await o.checkStatus()););return o}async generateProofRequest(e,t=[]){let o=this.blueprint.getId();if(!o)throw new Error("Blueprint of Proover must be initialized in order to create a Proof");if(this.blueprint.props.externalInputs?.length&&!t.length)throw new Error(`The ${this.blueprint.props.slug} blueprint requires external inputs: ${this.blueprint.props.externalInputs}`);let r;try{let a={emailHeaderMaxLength:this.blueprint.props.emailHeaderMaxLength||256,emailBodyMaxLength:this.blueprint.props.emailBodyMaxLength||2560,ignoreBodyHashCheck:this.blueprint.props.ignoreBodyHashCheck||!1,removeSoftLinebreaks:this.blueprint.props.removeSoftLinebreaks||!0,shaPrecomputeSelector:this.blueprint.props.shaPrecomputeSelector};console.log("generating proof inputs"),r=await D(e,this.blueprint.props.decomposedRegexes,t,a);}catch(a){throw console.error("Failed to generate inputs for proof"),a}console.log("got proof input");let s;try{let a={blueprint_id:o,input:JSON.parse(r),external_inputs:t.reduce((u,p)=>({...u,[p.name]:p.value}),{})};s=await m(`${this.blueprint.baseUrl}/proof`,a);}catch(a){throw console.error("Failed calling POST on /proof/ in generateProofRequest: ",a),a}let i=g.responseToProofProps(s);return new g(this.blueprint,i)}};var Q=(e=>(e.Circom="circom",e))(Q||{}),S=(s=>(s[s.None=0]="None",s[s.Draft=1]="Draft",s[s.InProgress=2]="InProgress",s[s.Done=3]="Done",s[s.Failed=4]="Failed",s))(S||{});var T=zod.z.object({title:zod.z.string().min(1,{message:"Title must be at least 1 characters."}),circuitName:zod.z.string().min(1).regex(/^[a-zA-Z_][a-zA-Z0-9_]*$/,"Invalid name, must start with a letter, digit, or underscore, and can only contain letters, digits or underscores."),description:zod.z.string().min(1),emailQuery:zod.z.string(),ignoreBodyHashCheck:zod.z.boolean(),shaPrecomputeSelector:zod.z.string().transform(n=>n.replace(/(?<!\\)"/g,'\\"')).optional(),senderDomain:zod.z.string().refine(n=>!n.includes("@"),{message:"Sender domain should not contain '@' symbol, only the domain"}),emailBodyMaxLength:zod.z.coerce.number().transform((n,e)=>(n%64!==0&&e.addIssue({code:"custom",message:"Must be a multiple of 64"}),n>1e4&&e.addIssue({code:"custom",message:"Must be less than or equal to 10000"}),n)),emailHeaderMaxLength:zod.z.coerce.number().transform((n,e)=>(n%64!==0&&e.addIssue({code:"custom",message:"Must be a multiple of 64"}),n)).default(1024),decomposedRegexes:zod.z.array(zod.z.object({name:zod.z.string().min(1).transform((n,e)=>n.includes(" ")?(e.addIssue({code:"custom",message:"Warning: Name contains spaces or dashes. They will be replaced with underscores."}),n.replace(/[ -]/g,"_")):n),maxLength:zod.z.coerce.number().positive().default(64),location:zod.z.string().regex(/(body)|(header)/),parts:zod.z.string().transform((n,e)=>{if(!n.includes("isPublic"))return e.addIssue({code:"custom",message:'Each parts config must include at least one "isPublic" field, and at least one thats true and one thats false. Please add it for now until we fix this requirement.'}),zod.z.NEVER;let t;try{t=JSON.parse(n);}catch{return e.addIssue({code:"custom",message:"Invalid JSON"}),zod.z.NEVER}if(!Array.isArray(t))return e.addIssue({code:"custom",message:"Parts must be an array"}),zod.z.NEVER;for(let o=0;o<t.length;o++){let r=t[o];if(typeof r!="object"||r===null)return e.addIssue({code:"custom",message:`Part ${o} must be an object`}),zod.z.NEVER;if(!("isPublic"in r)||typeof r.isPublic!="boolean")return e.addIssue({code:"custom",message:`Part ${o} must have a boolean 'isPublic' field`}),zod.z.NEVER;if(!("regexDef"in r)||typeof r.regexDef!="string")return e.addIssue({code:"custom",message:`Part ${o} must have a string 'regexDef' field`}),zod.z.NEVER}try{return Y(t),t}catch(o){return e.addIssue({code:"custom",message:o.message}),zod.z.NEVER}}).optional().or(zod.z.array(zod.z.any()))})),externalInputs:zod.z.array(zod.z.object({name:zod.z.string().min(1),maxLength:zod.z.coerce.number().positive().default(64)})).optional()});function Y(n){let e="";for(let t of n){if(t.isPublic||(e=e+t.regexDef),!t.isPublic&&!t.regexDef)throw new Error("Part has to have a nonempty regex with isPublic = false");break}if(!e)throw new Error("Part has to have a regex with isPublic = false in order to find it later");return JSON.stringify(e)}var d=class n{props;auth;baseUrl;stars=0;static formSchema=T;lastCheckedStatus=null;constructor(e,t,o){this.props={ignoreBodyHashCheck:!1,enableHeaderMasking:!1,enableBodyMasking:!1,isPublic:!0,status:1,...e},this.baseUrl=t,this.auth=o;}addAuth(e){this.auth=e;}static async getBlueprintById(e,t,o){let r;try{r=await c(`${t}/blueprint/${e}`);}catch(a){throw console.error("Failed calling /blueprint/:id in getBlueprintById: ",a),a}let s=this.responseToBlueprintProps(r);return new n(s,t,o)}static async getBlueprintBySlug(e,t,o){let r=e.split("@");if(!r||!(r.length>1))throw new Error("You must provide the blueprint version, e.g. 'user/slug@v1");let s=r.pop().replace("v","");if(e=encodeURIComponent(r.join("")),!s)throw new Error("You must provide the blueprint version, e.g. 'user/slug@v1");let i;try{let p=`${t}/blueprint/by-slug/${e}/${s}`;i=await c(p);}catch(p){throw console.error("Failed calling /blueprint/by-slug/:slug/:id in getBlueprintById: ",p),p}let a=this.responseToBlueprintProps(i);return new n(a,t,o)}static responseToBlueprintProps(e){return {id:e.id,title:e.title,description:e.description,slug:e.slug,tags:e.tags,emailQuery:e.email_query,circuitName:e.circuit_name,ignoreBodyHashCheck:e.ignore_body_hash_check,shaPrecomputeSelector:e.sha_precompute_selector,emailBodyMaxLength:e.email_body_max_length,emailHeaderMaxLength:e.email_header_max_length,removeSoftLinebreaks:e.remove_soft_linebreaks,githubUsername:e.github_username,senderDomain:e.sender_domain,enableHeaderMasking:e.enable_header_masking,enableBodyMasking:e.enable_body_masking,zkFramework:e.zk_framework,isPublic:e.is_public,createdAt:new Date(e.created_at.seconds*1e3),updatedAt:new Date(e.updated_at.seconds*1e3),externalInputs:e.external_inputs?.map(o=>({name:o.name,maxLength:o.max_length})),decomposedRegexes:e.decomposed_regexes?.map(o=>({parts:o.parts.map(r=>({isPublic:r.is_public,regexDef:r.regex_def})),name:o.name,maxLength:o.max_length,location:o.location})),status:e.status,verifierContract:{address:e.verifier_contract_address,chain:e.verifier_contract_chain},version:e.version}}static blueprintPropsToRequest(e){return {id:e.id,title:e.title,description:e.description,slug:e.slug,tags:e.tags,email_query:e.emailQuery,circuit_name:e.circuitName,ignore_body_hash_check:e.ignoreBodyHashCheck,sha_precompute_selector:e.shaPrecomputeSelector,email_body_max_length:e.emailBodyMaxLength,email_header_max_length:e.emailHeaderMaxLength,remove_soft_linebreaks:e.removeSoftLinebreaks,github_username:e.githubUsername,sender_domain:e.senderDomain,enable_header_masking:e.enableHeaderMasking,enable_body_masking:e.enableBodyMasking,zk_framework:e.zkFramework,is_public:e.isPublic,external_inputs:e.externalInputs?.map(o=>({name:o.name,max_length:o.maxLength})),decomposed_regexes:e.decomposedRegexes?.map(o=>({parts:o.parts.map(r=>({is_public:r.isPublic||r.is_public,regex_def:r.regexDef||r.regex_def})),name:o.name,max_length:o.maxLength,location:o.location})),verifier_contract_address:e.verifierContract?.address,verifier_contract_chain:e.verifierContract?.chain}}async submitDraft(){if(!this.auth)throw new Error("auth is required, add it with Blueprint.addAuth(auth)");if(this.props.id)throw new Error("Blueprint was already saved");let e=n.blueprintPropsToRequest(this.props),t;try{t=await m(`${this.baseUrl}/blueprint`,e,this.auth);}catch(o){throw console.error("Failed calling POST on /blueprint/ in submitDraft: ",o),o}this.props=n.responseToBlueprintProps(t);}async submitNewVersionDraft(e){if(!this.auth)throw new Error("auth is required, add it with Blueprint.addAuth(auth)");let t=n.blueprintPropsToRequest(e),o;try{o=await m(`${this.baseUrl}/blueprint`,t,this.auth);}catch(r){throw console.error("Failed calling POST on /blueprint/ in submitNewVersionDraft: ",r),r}this.props=n.responseToBlueprintProps(o);}async submitNewVersion(e){if(!this.auth)throw new Error("auth is required, add it with Blueprint.addAuth(auth)");await this.submitNewVersionDraft(e);try{await m(`${this.baseUrl}/blueprint/compile/${this.props.id}`,null,this.auth);}catch(t){throw console.error("Failed calling POST on /blueprint/compile in submit: ",t),t}}static async listBlueprints(e,t,o,r=!0){let s={skip:t?.skip,limit:t?.limit,sort:t?.sort,status:t?.status,is_public:t?.isPublic,search:t?.search},i;try{i=await c(`${e}/blueprint`,s,o);}catch(u){throw console.error("Failed calling GET on /blueprint/ in listBlueprints: ",u),u}if(!i.blueprints)return [];let a=i.blueprints.map(u=>{let p=n.responseToBlueprintProps(u);return new n(p,e,o)});return r&&await Promise.all(a.map(u=>u.getStars())),a}async submit(){if(!this.auth)throw new Error("auth is required, add it with Blueprint.addAuth(auth)");if(!this.props.id)try{await this.submitDraft();}catch(t){throw console.error("Failed to create blueprint: ",t),t}let e=await this._checkStatus();if(3===e)throw new Error("The circuits are already compiled.");if(2===e)throw new Error("The circuits already being compiled, please wait.");try{await m(`${this.baseUrl}/blueprint/compile/${this.props.id}`,null,this.auth);}catch(t){throw console.error("Failed calling POST on /blueprint/compile in submit: ",t),t}}async _checkStatus(){let e;try{e=await c(`${this.baseUrl}/blueprint/status/${this.props.id}`);}catch(t){throw console.error("Failed calling GET /blueprint/status in getStatus(): ",t),t}return this.props.status=e.status,e.status}async checkStatus(){if(!this.props.id)return this.props.status;if([4,3].includes(this.props.status))return this.props.status;if(!this.lastCheckedStatus)this.lastCheckedStatus=new Date;else {let o=new Date().getTime()-this.lastCheckedStatus.getTime();o<500&&await new Promise(r=>setTimeout(r,500-o));}return await this._checkStatus()}getId(){return this.props.id||null}async getZKeyDownloadLink(){if(this.props.status!==3)throw new Error("The circuits are not compiled yet, nothing to download.");let e;try{e=await c(`${this.baseUrl}/blueprint/zkey/${this.props.id}`);}catch(t){throw console.error("Failed calling GET on /blueprint/zkey/:id in getZKeyDownloadLink: ",t),t}return e.urls}async startZKeyDownload(){if(!window&&!document)throw Error("startZKeyDownload can only be used in a browser");let e;try{e=await this.getZKeyDownloadLink();}catch(t){throw console.error("Failed to start download of ZKeys: ",t),t}for(let[t,o]of Object.entries(e)){let r=document.createElement("a");r.href=o,r.download=t,document.body.appendChild(r),r.click(),document.body.removeChild(r);}}createProver(){return new _(this)}async verifyProofOnChain(e){try{await b(e);}catch(t){return console.error("Failed to verify proof on chain: ",t),!1}return !0}getClonedProps(){let e=JSON.parse(JSON.stringify(this.props));return e.createdAt&&(e.createdAt=new Date(e.createdAt)),e.updatedAt&&(e.updatedAt=new Date(e.updatedAt)),e}canUpdate(){return !!(this.props.id&&![3,2].includes(this.props.status))}async update(e){if(!this.auth)throw new Error("auth is required, add it with Blueprint.addAuth(auth)");if(!this.canUpdate())throw new Error("Blueprint already compied, cannot update");let t=n.blueprintPropsToRequest(e),o;try{o=await k(`${this.baseUrl}/blueprint/${this.props.id}`,t,this.auth);}catch(r){throw console.error("Failed calling POST on /blueprint/ in submitDraft: ",r),r}this.props=n.responseToBlueprintProps(o);}async listAllVersions(){if(!this.props.id)throw new Error("Blueprint was not saved yet");let e;try{e=await c(`${this.baseUrl}/blueprint/versions/${encodeURIComponent(this.props.slug)}`);}catch(t){throw console.error("Failed calling GET on /blueprint/versions/:slug in listAllVersions: ",t),t}return e.blueprints.map(t=>{let o=n.responseToBlueprintProps(t);return new n(o,this.baseUrl,this.auth)})}async addStar(){if(!this.auth)throw new Error("Auth is required. Please login to star a blueprint.");try{return await m(`${this.baseUrl}/blueprint/${encodeURIComponent(this.props.slug)}/stars`,null,this.auth),await this.getStars()}catch(e){throw console.error("Failed calling POST on /blueprint/${slug}/stars in addStar: ",e),e}}async removeStar(){if(!this.auth)throw new Error("Auth is required. Please login to star a blueprint.");try{return await w(`${this.baseUrl}/blueprint/${encodeURIComponent(this.props.slug)}/stars`,null,this.auth),await this.getStars()}catch(e){throw console.error("Failed calling DELETE on /blueprint/${id}/stars in addStar: ",e),e}}async getStars(){try{let{stars:e}=await c(`${this.baseUrl}/blueprint/${encodeURIComponent(this.props.slug)}/stars`);return this.stars=e||0,e||0}catch(e){throw console.error("Failed calling POST on /blueprint/${id}/stars in addStar: ",e),e}}async cancelCompilation(){if(this.props.status!==2)throw new Error("Can only cancel compilation of a blueprint that is in progress");try{await w(`${this.baseUrl}/blueprint/cancel/${this.props.id}`,null,this.auth);}catch(e){throw console.error("Failed calling DELETE on /blueprint/cancel/${id} in cancelCompilation: ",e),e}}async delete(){try{await w(`${this.baseUrl}/blueprint/${this.props.id}`,null,this.auth);}catch(e){throw console.error("Failed calling DELETE on /blueprint/${id} in cancelCompilation: ",e),e}}};async function C(n,e){let{slugs:t}=await c(`${n}/blueprint/starred`,null,e);return t}var Xe=n=>{let e=n?.baseUrl||"https://conductor.zk.email";return {createBlueprint(t){if(!n&&!n.auth)throw new Error("You need to specify options.auth to use createBlueprint");return new d(t,e,n.auth)},async getBlueprint(t){return d.getBlueprintBySlug(t,e,n?.auth)},async getBlueprintById(t){return d.getBlueprintById(t,e,n?.auth)},async listBlueprints(t){return d.listBlueprints(e,t,n?.auth)},async getProof(t){return g.getProofById(t,e)},async getStarredBlueprints(){if(!n&&!n.auth)throw new Error("You need to specify options.auth to use getStarredBlueprints");return C(e,n.auth)}}};
6
- Object.defineProperty(exports,"ZodError",{enumerable:true,get:function(){return zod.ZodError}});exports.Blueprint=d;exports.Proof=g;exports.ProofStatus=B;exports.Status=S;exports.ZkFramework=Q;exports.default=Xe;exports.extractEMLDetails=W;exports.generateProofInputs=D;exports.getDKIMSelector=j;exports.getLoginWithGithubUrl=q;exports.getMaxEmailBodyLength=Z;exports.parseEmail=x;exports.startJsonFileDownload=N;exports.testBlueprint=V;exports.testDecomposedRegex=L;//# sourceMappingURL=index.js.map
7
- //# sourceMappingURL=index.js.map