@zk-email/sdk 0.0.86 → 0.0.88
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/README.md +30 -6
- package/dist/ccip-Blve6Z7V.js +2 -0
- package/dist/ccip-Blve6Z7V.js.map +1 -0
- package/dist/ccip-CqWwM5V5.mjs +147 -0
- package/dist/ccip-CqWwM5V5.mjs.map +1 -0
- package/dist/index-76VwpgoI.js +41 -0
- package/dist/index-76VwpgoI.js.map +1 -0
- package/dist/index-BBAkhu6Z.mjs +13594 -0
- package/dist/index-BBAkhu6Z.mjs.map +1 -0
- package/dist/types/auth.d.ts +3 -0
- package/dist/types/blueprint.d.ts +132 -0
- package/dist/types/blueprintValidation.d.ts +82 -0
- package/dist/types/chain/index.d.ts +2 -0
- package/dist/types/index.d.ts +24 -0
- package/dist/types/localProverWorkerString.d.ts +1 -0
- package/dist/types/proof.d.ts +52 -0
- package/dist/types/prover.d.ts +39 -0
- package/dist/types/relayerUtils.d.ts +14 -0
- package/dist/types/types/auth.d.ts +16 -0
- package/dist/types/types/blueprint.d.ts +155 -0
- package/dist/types/types/index.d.ts +6 -0
- package/dist/types/types/proof.d.ts +63 -0
- package/dist/types/types/prover.d.ts +8 -0
- package/dist/types/types/sdk.d.ts +5 -0
- package/dist/types/types/utils.d.ts +8 -0
- package/dist/types/user.d.ts +5 -0
- package/dist/types/utils.d.ts +7 -0
- package/dist/zk-email-sdk.cjs.js +2 -0
- package/dist/zk-email-sdk.cjs.js.map +1 -0
- package/dist/zk-email-sdk.es.js +18 -0
- package/dist/zk-email-sdk.es.js.map +1 -0
- package/package.json +25 -11
- package/dist/index.d.mts +0 -557
- package/dist/index.d.ts +0 -557
- package/dist/index.js +0 -7
- package/dist/index.js.map +0 -1
- package/dist/index.mjs +0 -7
- package/dist/index.mjs.map +0 -1
@@ -0,0 +1,132 @@
|
|
1
|
+
import { Prover } from "./prover";
|
2
|
+
import { BlueprintProps, ChunkedZkeyUrl, DownloadUrls, ListBlueprintsOptions, Status } from "./types/blueprint";
|
3
|
+
import { Auth } from "./types/auth";
|
4
|
+
import { Proof } from "./proof";
|
5
|
+
import { blueprintFormSchema } from "./blueprintValidation";
|
6
|
+
import { ProverOptions } from "./types";
|
7
|
+
/**
|
8
|
+
* Represents a Regex Blueprint including the decomposed regex access to the circuit.
|
9
|
+
*/
|
10
|
+
export declare class Blueprint {
|
11
|
+
props: BlueprintProps;
|
12
|
+
auth?: Auth;
|
13
|
+
baseUrl: string;
|
14
|
+
stars: number;
|
15
|
+
static readonly formSchema: typeof blueprintFormSchema;
|
16
|
+
private lastCheckedStatus;
|
17
|
+
constructor(props: BlueprintProps, baseUrl: string, auth?: Auth);
|
18
|
+
addAuth(auth: Auth): void;
|
19
|
+
/**
|
20
|
+
* Fetches an existing RegexBlueprint from the database.
|
21
|
+
* @param {string} id - Id of the RegexBlueprint.
|
22
|
+
* @returns A promise that resolves to a new instance of RegexBlueprint.
|
23
|
+
*/
|
24
|
+
static getBlueprintById(id: string, baseUrl: string, auth?: Auth): Promise<Blueprint>;
|
25
|
+
/**
|
26
|
+
* Fetches an existing RegexBlueprint by slug from the database.
|
27
|
+
* @param slug - Slug of the blueprint. Must include version, e.g. "slug:v1"
|
28
|
+
* @param version - Version of the slug.
|
29
|
+
* @returns A promise that resolves to a new instance of RegexBlueprint.
|
30
|
+
*/
|
31
|
+
static getBlueprintBySlug(slug: string, baseUrl: string, auth?: Auth): Promise<Blueprint>;
|
32
|
+
private static responseToBlueprintProps;
|
33
|
+
private static blueprintPropsToRequest;
|
34
|
+
/**
|
35
|
+
* Submits a new RegexBlueprint to the registry as draft.
|
36
|
+
* This does not compile the circuits yet and you will still be able to make changes.
|
37
|
+
* @returns A promise. Once it resolves, `getId` can be called.
|
38
|
+
*/
|
39
|
+
submitDraft(): Promise<void>;
|
40
|
+
/**
|
41
|
+
* Submits a new version of the RegexBlueprint to the registry as draft.
|
42
|
+
* This does not compile the circuits yet and you will still be able to make changes.
|
43
|
+
* @param newProps - The updated blueprint props.
|
44
|
+
* @returns A promise. Once it resolves, the current Blueprint will be replaced with the new one.
|
45
|
+
*/
|
46
|
+
submitNewVersionDraft(newProps: BlueprintProps): Promise<void>;
|
47
|
+
/**
|
48
|
+
* Submits a new version of the blueprint. This will save the new blueprint version
|
49
|
+
* and start the compilation.
|
50
|
+
* This will also overwrite the current Blueprint with its new version, even if the last
|
51
|
+
* version was not compiled yet.
|
52
|
+
* @param newProps - The updated blueprint props.
|
53
|
+
*/
|
54
|
+
submitNewVersion(newProps: BlueprintProps): Promise<void>;
|
55
|
+
/**
|
56
|
+
* Lists blueblueprints, only including the latest version per unique slug.
|
57
|
+
* @param options - Options to filter the blueprints by.
|
58
|
+
* @returns A promise. Once it resolves, `getId` can be called.
|
59
|
+
*/
|
60
|
+
static listBlueprints(baseUrl: string, options?: ListBlueprintsOptions, auth?: Auth): Promise<Blueprint[]>;
|
61
|
+
/**
|
62
|
+
* Submits a blueprint. This will save the blueprint if it didn't exist before
|
63
|
+
* and start the compilation.
|
64
|
+
*/
|
65
|
+
submit(): Promise<void>;
|
66
|
+
private _checkStatus;
|
67
|
+
/**
|
68
|
+
* Checks the status of blueprint.
|
69
|
+
* checkStatus can be used in a while(await checkStatus()) loop, since it will wait a fixed
|
70
|
+
* amount of time the second time you call it.
|
71
|
+
* @returns A promise with the Status.
|
72
|
+
*/
|
73
|
+
checkStatus(): Promise<Status>;
|
74
|
+
/**
|
75
|
+
* Get the id of the blueprint.
|
76
|
+
* @returns The id of the blueprint. If it was not saved yet, return null.
|
77
|
+
*/
|
78
|
+
getId(): string | null;
|
79
|
+
/**
|
80
|
+
* Returns a download link for the ZKeys of the blueprint.
|
81
|
+
* @returns The the url to download the ZKeys.
|
82
|
+
*/
|
83
|
+
getZKeyDownloadLink(): Promise<DownloadUrls>;
|
84
|
+
/**
|
85
|
+
* Directly starts a download of the ZKeys in the browser.
|
86
|
+
* Must be called within a user action, like a button click.
|
87
|
+
*/
|
88
|
+
startZKeyDownload(): Promise<void>;
|
89
|
+
/**
|
90
|
+
* Creates an instance of Prover with which you can create proofs.
|
91
|
+
* @returns An instance of Prover.
|
92
|
+
*/
|
93
|
+
createProver(options?: ProverOptions): Prover;
|
94
|
+
/**
|
95
|
+
* Verifies a proof on chain.
|
96
|
+
* @param proof - The generated proof you want to verify.
|
97
|
+
* @returns A true if the verification was successfull, false if it failed.
|
98
|
+
*/
|
99
|
+
verifyProofOnChain(proof: Proof): Promise<boolean>;
|
100
|
+
/**
|
101
|
+
* Returns a deep cloned version of the Blueprints props.
|
102
|
+
* This can be used to update properties and then to use them with createNewVersion.
|
103
|
+
* @param proof - The generated proof you want to verify.
|
104
|
+
* @returns A true if the verification was successfull, false if it failed.
|
105
|
+
*/
|
106
|
+
getClonedProps(): BlueprintProps;
|
107
|
+
/**
|
108
|
+
* Returns true if the blueprint can be updated. A blueprint can be updated if the circuits
|
109
|
+
* haven't beed compiled yet, i.e. the status is not Done. The blueprint also must be saved
|
110
|
+
* already before it can be updated.
|
111
|
+
* @returns true if it can be updated
|
112
|
+
*/
|
113
|
+
canUpdate(): boolean;
|
114
|
+
/**
|
115
|
+
* Updates an existing blueprint that is not compiled yet.
|
116
|
+
* @param newProps - The props the blueprint should be updated to.
|
117
|
+
* @returns a promise.
|
118
|
+
*/
|
119
|
+
update(newProps: BlueprintProps): Promise<void>;
|
120
|
+
listAllVersions(): Promise<Blueprint[]>;
|
121
|
+
addStar(): Promise<number>;
|
122
|
+
removeStar(): Promise<number>;
|
123
|
+
getStars(): Promise<number>;
|
124
|
+
cancelCompilation(): Promise<void>;
|
125
|
+
delete(): Promise<void>;
|
126
|
+
getChunkedZkeyDownloadLinks(): Promise<ChunkedZkeyUrl[]>;
|
127
|
+
getWasmFileDownloadLink(): Promise<string>;
|
128
|
+
getVkeyFileDownloadLink(): Promise<string>;
|
129
|
+
getVkey(): Promise<string>;
|
130
|
+
getNumOfRemoteProofs(): Promise<number>;
|
131
|
+
}
|
132
|
+
export * from "./types/blueprint";
|
@@ -0,0 +1,82 @@
|
|
1
|
+
import { z } from "zod";
|
2
|
+
export declare const blueprintFormSchema: z.ZodObject<{
|
3
|
+
title: z.ZodString;
|
4
|
+
circuitName: z.ZodString;
|
5
|
+
description: z.ZodString;
|
6
|
+
emailQuery: z.ZodString;
|
7
|
+
ignoreBodyHashCheck: z.ZodBoolean;
|
8
|
+
shaPrecomputeSelector: z.ZodOptional<z.ZodEffects<z.ZodString, string, string>>;
|
9
|
+
senderDomain: z.ZodEffects<z.ZodString, string, string>;
|
10
|
+
emailBodyMaxLength: z.ZodEffects<z.ZodNumber, number, number>;
|
11
|
+
emailHeaderMaxLength: z.ZodDefault<z.ZodEffects<z.ZodNumber, number, number>>;
|
12
|
+
decomposedRegexes: z.ZodArray<z.ZodObject<{
|
13
|
+
name: z.ZodEffects<z.ZodString, string, string>;
|
14
|
+
maxLength: z.ZodDefault<z.ZodNumber>;
|
15
|
+
location: z.ZodString;
|
16
|
+
parts: z.ZodUnion<[z.ZodOptional<z.ZodEffects<z.ZodString, any[], string>>, z.ZodArray<z.ZodAny, "many">]>;
|
17
|
+
}, "strip", z.ZodTypeAny, {
|
18
|
+
name: string;
|
19
|
+
maxLength: number;
|
20
|
+
location: string;
|
21
|
+
parts?: any[] | undefined;
|
22
|
+
}, {
|
23
|
+
name: string;
|
24
|
+
location: string;
|
25
|
+
maxLength?: number | undefined;
|
26
|
+
parts?: string | any[] | undefined;
|
27
|
+
}>, "many">;
|
28
|
+
externalInputs: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
29
|
+
name: z.ZodString;
|
30
|
+
maxLength: z.ZodDefault<z.ZodNumber>;
|
31
|
+
}, "strip", z.ZodTypeAny, {
|
32
|
+
name: string;
|
33
|
+
maxLength: number;
|
34
|
+
}, {
|
35
|
+
name: string;
|
36
|
+
maxLength?: number | undefined;
|
37
|
+
}>, "many">>;
|
38
|
+
}, "strip", z.ZodTypeAny, {
|
39
|
+
description: string;
|
40
|
+
title: string;
|
41
|
+
circuitName: string;
|
42
|
+
emailQuery: string;
|
43
|
+
ignoreBodyHashCheck: boolean;
|
44
|
+
senderDomain: string;
|
45
|
+
emailBodyMaxLength: number;
|
46
|
+
emailHeaderMaxLength: number;
|
47
|
+
decomposedRegexes: {
|
48
|
+
name: string;
|
49
|
+
maxLength: number;
|
50
|
+
location: string;
|
51
|
+
parts?: any[] | undefined;
|
52
|
+
}[];
|
53
|
+
shaPrecomputeSelector?: string | undefined;
|
54
|
+
externalInputs?: {
|
55
|
+
name: string;
|
56
|
+
maxLength: number;
|
57
|
+
}[] | undefined;
|
58
|
+
}, {
|
59
|
+
description: string;
|
60
|
+
title: string;
|
61
|
+
circuitName: string;
|
62
|
+
emailQuery: string;
|
63
|
+
ignoreBodyHashCheck: boolean;
|
64
|
+
senderDomain: string;
|
65
|
+
emailBodyMaxLength: number;
|
66
|
+
decomposedRegexes: {
|
67
|
+
name: string;
|
68
|
+
location: string;
|
69
|
+
maxLength?: number | undefined;
|
70
|
+
parts?: string | any[] | undefined;
|
71
|
+
}[];
|
72
|
+
shaPrecomputeSelector?: string | undefined;
|
73
|
+
emailHeaderMaxLength?: number | undefined;
|
74
|
+
externalInputs?: {
|
75
|
+
name: string;
|
76
|
+
maxLength?: number | undefined;
|
77
|
+
}[] | undefined;
|
78
|
+
}>;
|
79
|
+
export type ValidationErrors = {
|
80
|
+
[K in keyof z.infer<typeof blueprintFormSchema>]?: string;
|
81
|
+
};
|
82
|
+
export { ZodError } from "zod";
|
@@ -0,0 +1,24 @@
|
|
1
|
+
import { Blueprint, BlueprintProps, ListBlueprintsOptions } from "./blueprint";
|
2
|
+
import { Proof } from "./proof";
|
3
|
+
import { SdkOptions } from "./types/sdk";
|
4
|
+
export * from "./types/blueprint";
|
5
|
+
export { Blueprint } from "./blueprint";
|
6
|
+
export * from "./types/proof";
|
7
|
+
export { Proof } from "./proof";
|
8
|
+
export * from "./types/prover";
|
9
|
+
export type { Auth } from "./types/auth";
|
10
|
+
export type { ParsedEmail } from "./types/utils";
|
11
|
+
export type { ValidationErrors } from "./blueprintValidation";
|
12
|
+
export { startJsonFileDownload, getDKIMSelector } from "./utils";
|
13
|
+
export { testDecomposedRegex, parseEmail, generateProofInputs, testBlueprint, } from "./relayerUtils";
|
14
|
+
export { getLoginWithGithubUrl } from "./auth";
|
15
|
+
export { ZodError } from "./blueprintValidation";
|
16
|
+
declare const _default: (sdkOptions?: SdkOptions) => {
|
17
|
+
createBlueprint(props: BlueprintProps): Blueprint;
|
18
|
+
getBlueprint(slug: string): Promise<Blueprint>;
|
19
|
+
getBlueprintById(id: string): Promise<Blueprint>;
|
20
|
+
listBlueprints(options?: ListBlueprintsOptions): Promise<Blueprint[]>;
|
21
|
+
getProof(id: string): Promise<Proof>;
|
22
|
+
getStarredBlueprints(): Promise<string[]>;
|
23
|
+
};
|
24
|
+
export default _default;
|