@devtion/devcli 1.0.5-alpha.0
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 +118 -0
- package/dist/index.js +3206 -0
- package/dist/types/commands/auth.d.ts +25 -0
- package/dist/types/commands/clean.d.ts +6 -0
- package/dist/types/commands/contribute.d.ts +139 -0
- package/dist/types/commands/finalize.d.ts +51 -0
- package/dist/types/commands/index.d.ts +9 -0
- package/dist/types/commands/listCeremonies.d.ts +5 -0
- package/dist/types/commands/logout.d.ts +6 -0
- package/dist/types/commands/observe.d.ts +22 -0
- package/dist/types/commands/setup.d.ts +86 -0
- package/dist/types/commands/validate.d.ts +8 -0
- package/dist/types/index.d.ts +2 -0
- package/dist/types/lib/errors.d.ts +60 -0
- package/dist/types/lib/files.d.ts +64 -0
- package/dist/types/lib/localConfigs.d.ts +110 -0
- package/dist/types/lib/prompts.d.ts +104 -0
- package/dist/types/lib/services.d.ts +31 -0
- package/dist/types/lib/theme.d.ts +42 -0
- package/dist/types/lib/utils.d.ts +158 -0
- package/dist/types/types/index.d.ts +65 -0
- package/package.json +99 -0
- package/src/commands/auth.ts +194 -0
- package/src/commands/clean.ts +49 -0
- package/src/commands/contribute.ts +1090 -0
- package/src/commands/finalize.ts +382 -0
- package/src/commands/index.ts +9 -0
- package/src/commands/listCeremonies.ts +32 -0
- package/src/commands/logout.ts +67 -0
- package/src/commands/observe.ts +193 -0
- package/src/commands/setup.ts +901 -0
- package/src/commands/validate.ts +29 -0
- package/src/index.ts +66 -0
- package/src/lib/errors.ts +77 -0
- package/src/lib/files.ts +102 -0
- package/src/lib/localConfigs.ts +186 -0
- package/src/lib/prompts.ts +748 -0
- package/src/lib/services.ts +191 -0
- package/src/lib/theme.ts +45 -0
- package/src/lib/utils.ts +778 -0
- package/src/types/conf.d.ts +16 -0
- package/src/types/index.ts +70 -0
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
import { Answers } from "prompts";
|
|
2
|
+
import { Firestore } from "firebase/firestore";
|
|
3
|
+
import { CeremonyInputData, FirebaseDocumentInfo, CircomCompilerData, CircuitInputData, CeremonyTimeoutType, DiskTypeForVM } from "@p0tion/actions";
|
|
4
|
+
/**
|
|
5
|
+
* Ask a binary (yes/no or true/false) customizable question.
|
|
6
|
+
* @param question <string> - the question to be answered.
|
|
7
|
+
* @param active <string> - the active option (default yes).
|
|
8
|
+
* @param inactive <string> - the inactive option (default no).
|
|
9
|
+
* @returns <Promise<Answers<string>>>
|
|
10
|
+
*/
|
|
11
|
+
export declare const askForConfirmation: (question: string, active?: string, inactive?: string) => Promise<Answers<string>>;
|
|
12
|
+
/**
|
|
13
|
+
* Prompt a series of questios to gather input data for the ceremony setup.
|
|
14
|
+
* @param firestore <Firestore> - the instance of the Firestore database.
|
|
15
|
+
* @returns <Promise<CeremonyInputData>> - the necessary information for the ceremony provided by the coordinator.
|
|
16
|
+
*/
|
|
17
|
+
export declare const promptCeremonyInputData: (firestore: Firestore) => Promise<CeremonyInputData>;
|
|
18
|
+
/**
|
|
19
|
+
* Prompt a series of questios to gather input about the Circom compiler.
|
|
20
|
+
* @returns <Promise<CircomCompilerData>> - the necessary information for the Circom compiler used for the circuits.
|
|
21
|
+
*/
|
|
22
|
+
export declare const promptCircomCompiler: () => Promise<CircomCompilerData>;
|
|
23
|
+
/**
|
|
24
|
+
* Shows a list of circuits for a single option selection.
|
|
25
|
+
* @dev the circuit names are derived from local R1CS files.
|
|
26
|
+
* @param options <Array<string>> - an array of circuits names.
|
|
27
|
+
* @returns Promise<string> - the name of the choosen circuit.
|
|
28
|
+
*/
|
|
29
|
+
export declare const promptCircuitSelector: (options: Array<string>) => Promise<string>;
|
|
30
|
+
/**
|
|
31
|
+
* Shows a list of standard EC2 VM instance types for a single option selection.
|
|
32
|
+
* @notice the suggested VM configuration type is calculated based on circuit constraint size.
|
|
33
|
+
* @param constraintSize <number> - the amount of circuit constraints
|
|
34
|
+
* @returns Promise<string> - the name of the choosen VM type.
|
|
35
|
+
*/
|
|
36
|
+
export declare const promptVMTypeSelector: (constraintSize: any) => Promise<string>;
|
|
37
|
+
/**
|
|
38
|
+
* Shows a list of disk types for selected VM.
|
|
39
|
+
* @returns Promise<DiskTypeForVM> - the selected disk type.
|
|
40
|
+
*/
|
|
41
|
+
export declare const promptVMDiskTypeSelector: () => Promise<DiskTypeForVM>;
|
|
42
|
+
/**
|
|
43
|
+
* Show a series of questions about the circuits.
|
|
44
|
+
* @param constraintSize <number> - the amount of circuit constraints.
|
|
45
|
+
* @param timeoutMechanismType <CeremonyTimeoutType> - the choosen timeout mechanism type for the ceremony.
|
|
46
|
+
* @param needPromptCircomCompiler <boolean> - a boolean value indicating if the questions related to the Circom compiler version and commit hash must be asked.
|
|
47
|
+
* @param enforceVM <boolean> - a boolean value indicating if the contribution verification could be supported by VM-only approach or not.
|
|
48
|
+
* @returns Promise<Array<Circuit>> - circuit info prompted by the coordinator.
|
|
49
|
+
*/
|
|
50
|
+
export declare const promptCircuitInputData: (constraintSize: number, timeoutMechanismType: CeremonyTimeoutType, sameCircomCompiler: boolean, enforceVM: boolean) => Promise<CircuitInputData>;
|
|
51
|
+
/**
|
|
52
|
+
* Prompt for asking if the same circom compiler version has been used for all circuits of the ceremony.
|
|
53
|
+
* @returns <Promise<boolean>>
|
|
54
|
+
*/
|
|
55
|
+
export declare const promptSameCircomCompiler: () => Promise<boolean>;
|
|
56
|
+
/**
|
|
57
|
+
* Prompt for asking if the coordinator wanna use a pre-computed zKey for the given circuit.
|
|
58
|
+
* @returns <Promise<boolean>>
|
|
59
|
+
*/
|
|
60
|
+
export declare const promptPreComputedZkey: () => Promise<boolean>;
|
|
61
|
+
/**
|
|
62
|
+
* Prompt for asking if the coordinator wants to add a new circuit to the ceremony.
|
|
63
|
+
* @returns <Promise<boolean>>
|
|
64
|
+
*/
|
|
65
|
+
export declare const promptCircuitAddition: () => Promise<boolean>;
|
|
66
|
+
/**
|
|
67
|
+
* Shows a list of pre-computed zKeys for a single option selection.
|
|
68
|
+
* @dev the names are derived from local zKeys files.
|
|
69
|
+
* @param options <Array<string>> - an array of pre-computed zKeys names.
|
|
70
|
+
* @returns Promise<string> - the name of the choosen pre-computed zKey.
|
|
71
|
+
*/
|
|
72
|
+
export declare const promptPreComputedZkeySelector: (options: Array<string>) => Promise<string>;
|
|
73
|
+
/**
|
|
74
|
+
* Prompt asking to the coordinator to choose the desired PoT file for the zKey for the circuit.
|
|
75
|
+
* @param suggestedSmallestNeededPowers <number> - the minimal number of powers necessary for circuit zKey generation.
|
|
76
|
+
* @returns Promise<number> - the selected amount of powers.
|
|
77
|
+
*/
|
|
78
|
+
export declare const promptNeededPowersForCircuit: (suggestedSmallestNeededPowers: number) => Promise<number>;
|
|
79
|
+
/**
|
|
80
|
+
* Shows a list of PoT files for a single option selection.
|
|
81
|
+
* @dev the names are derived from local PoT files.
|
|
82
|
+
* @param options <Array<string>> - an array of PoT file names.
|
|
83
|
+
* @returns Promise<string> - the name of the choosen PoT.
|
|
84
|
+
*/
|
|
85
|
+
export declare const promptPotSelector: (options: Array<string>) => Promise<string>;
|
|
86
|
+
/**
|
|
87
|
+
* Prompt for asking about ceremony selection.
|
|
88
|
+
* @dev this method is used to show a list of ceremonies to be selected for both the computation of a contribution and the finalization of a ceremony.
|
|
89
|
+
* @param ceremoniesDocuments <Array<FirebaseDocumentInfo>> - the list of ceremonies Firestore documents.
|
|
90
|
+
* @param isFinalizing <boolean> - true when the coordinator must select a ceremony for finalization; otherwise false (participant selects a ceremony for contribution).
|
|
91
|
+
* @returns Promise<FirebaseDocumentInfo> - the Firestore document of the selected ceremony.
|
|
92
|
+
*/
|
|
93
|
+
export declare const promptForCeremonySelection: (ceremoniesDocuments: Array<FirebaseDocumentInfo>, isFinalizing: boolean) => Promise<FirebaseDocumentInfo>;
|
|
94
|
+
/**
|
|
95
|
+
* Prompt the participant to type the entropy or the coordinator to type the beacon.
|
|
96
|
+
* @param isEntropy <boolean> - true when prompting for typing entropy; otherwise false.
|
|
97
|
+
* @returns <Promise<string>> - the entropy or beacon value.
|
|
98
|
+
*/
|
|
99
|
+
export declare const promptToTypeEntropyOrBeacon: (isEntropy?: boolean) => Promise<string>;
|
|
100
|
+
/**
|
|
101
|
+
* Prompt for entropy generation or insertion.
|
|
102
|
+
* @return <Promise<string>> - the entropy.
|
|
103
|
+
*/
|
|
104
|
+
export declare const promptForEntropy: () => Promise<string>;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { FirebaseApp } from "firebase/app";
|
|
2
|
+
import { OAuthCredential } from "firebase/auth";
|
|
3
|
+
import { AuthUser } from "../types/index.js";
|
|
4
|
+
/**
|
|
5
|
+
* Bootstrap services and configs is needed for a new command execution and related services.
|
|
6
|
+
* @returns <Promise<FirebaseServices>>
|
|
7
|
+
*/
|
|
8
|
+
export declare const bootstrapCommandExecutionAndServices: () => Promise<any>;
|
|
9
|
+
/**
|
|
10
|
+
* Execute the sign in to Firebase using OAuth credentials.
|
|
11
|
+
* @dev wrapper method to handle custom errors.
|
|
12
|
+
* @param firebaseApp <FirebaseApp> - the configured instance of the Firebase App in use.
|
|
13
|
+
* @param credentials <OAuthCredential> - the OAuth credential generated from token exchange.
|
|
14
|
+
* @returns <Promise<void>>
|
|
15
|
+
*/
|
|
16
|
+
export declare const signInToFirebase: (firebaseApp: FirebaseApp, credentials: OAuthCredential) => Promise<void>;
|
|
17
|
+
/**
|
|
18
|
+
* Ensure that the callee is an authenticated user.
|
|
19
|
+
* @notice The token will be passed as parameter.
|
|
20
|
+
* @dev This method can be used within GitHub actions or other CI/CD pipelines.
|
|
21
|
+
* @param firebaseApp <FirebaseApp> - the configured instance of the Firebase App in use.
|
|
22
|
+
* @param token <string> - the token to be used for authentication.
|
|
23
|
+
* @returns <Promise<AuthUser>> - a custom object containing info about the authenticated user, the token and github handle.
|
|
24
|
+
*/
|
|
25
|
+
export declare const authWithToken: (firebaseApp: FirebaseApp, token: string) => Promise<AuthUser>;
|
|
26
|
+
/**
|
|
27
|
+
* Ensure that the callee is an authenticated user.
|
|
28
|
+
* @dev This method MUST be executed before each command to avoid authentication errors when interacting with the command.
|
|
29
|
+
* @returns <Promise<AuthUser>> - a custom object containing info about the authenticated user, the token and github handle.
|
|
30
|
+
*/
|
|
31
|
+
export declare const checkAuth: (firebaseApp: FirebaseApp) => Promise<AuthUser>;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Custom theme object.
|
|
3
|
+
*/
|
|
4
|
+
declare const _default: {
|
|
5
|
+
colors: {
|
|
6
|
+
yellow: import("chalk").ChalkInstance;
|
|
7
|
+
magenta: import("chalk").ChalkInstance;
|
|
8
|
+
red: import("chalk").ChalkInstance;
|
|
9
|
+
green: import("chalk").ChalkInstance;
|
|
10
|
+
};
|
|
11
|
+
text: {
|
|
12
|
+
underlined: import("chalk").ChalkInstance;
|
|
13
|
+
bold: import("chalk").ChalkInstance;
|
|
14
|
+
italic: import("chalk").ChalkInstance;
|
|
15
|
+
};
|
|
16
|
+
symbols: {
|
|
17
|
+
success: string;
|
|
18
|
+
warning: string;
|
|
19
|
+
error: string;
|
|
20
|
+
info: string;
|
|
21
|
+
};
|
|
22
|
+
emojis: {
|
|
23
|
+
tada: string;
|
|
24
|
+
key: string;
|
|
25
|
+
broom: string;
|
|
26
|
+
pointDown: string;
|
|
27
|
+
eyes: string;
|
|
28
|
+
wave: string;
|
|
29
|
+
clipboard: string;
|
|
30
|
+
fire: string;
|
|
31
|
+
clock: string;
|
|
32
|
+
dizzy: string;
|
|
33
|
+
rocket: string;
|
|
34
|
+
oldKey: string;
|
|
35
|
+
pray: string;
|
|
36
|
+
moon: string;
|
|
37
|
+
upsideDown: string;
|
|
38
|
+
arrowUp: string;
|
|
39
|
+
arrowDown: string;
|
|
40
|
+
};
|
|
41
|
+
};
|
|
42
|
+
export default _default;
|
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
import { FirebaseDocumentInfo } from "@p0tion/actions";
|
|
2
|
+
import { OAuthCredential } from "firebase/auth";
|
|
3
|
+
import { DocumentData, Firestore } from "firebase/firestore";
|
|
4
|
+
import { Functions } from "firebase/functions";
|
|
5
|
+
import { Ora } from "ora";
|
|
6
|
+
import { Logger } from "winston";
|
|
7
|
+
import { GithubGistFile, Timing } from "../types/index.js";
|
|
8
|
+
/**
|
|
9
|
+
* Exchange the Github token for OAuth credential.
|
|
10
|
+
* @param githubToken <string> - the Github token generated through the Device Flow process.
|
|
11
|
+
* @returns <OAuthCredential>
|
|
12
|
+
*/
|
|
13
|
+
export declare const exchangeGithubTokenForCredentials: (githubToken: string) => OAuthCredential;
|
|
14
|
+
/**
|
|
15
|
+
* Get the information associated to the account from which the token has been generated to
|
|
16
|
+
* create a custom unique identifier for the user.
|
|
17
|
+
* @notice the unique identifier has the following form 'handle-identifier'.
|
|
18
|
+
* @param githubToken <string> - the Github token.
|
|
19
|
+
* @returns <Promise<any>> - the Github (provider) unique identifier associated to the user.
|
|
20
|
+
*/
|
|
21
|
+
export declare const getGithubProviderUserId: (githubToken: string) => Promise<any>;
|
|
22
|
+
/**
|
|
23
|
+
* Get the gists associated to the authenticated user account.
|
|
24
|
+
* @param githubToken <string> - the Github token.
|
|
25
|
+
* @param params <Object<number,number>> - the necessary parameters for the request.
|
|
26
|
+
* @returns <Promise<any>> - the Github gists associated with the authenticated user account.
|
|
27
|
+
*/
|
|
28
|
+
export declare const getGithubAuthenticatedUserGists: (githubToken: string, params: {
|
|
29
|
+
perPage: number;
|
|
30
|
+
page: number;
|
|
31
|
+
}) => Promise<any>;
|
|
32
|
+
/**
|
|
33
|
+
* Check whether or not the user has published the gist.
|
|
34
|
+
* @dev gather all the user's gists and check if there is a match with the expected public attestation.
|
|
35
|
+
* @param githubToken <string> - the Github token.
|
|
36
|
+
* @param publicAttestationFilename <string> - the public attestation filename.
|
|
37
|
+
* @returns <Promise<GithubGistFile | undefined>> - return the public attestation gist if and only if has been published.
|
|
38
|
+
*/
|
|
39
|
+
export declare const getPublicAttestationGist: (githubToken: string, publicAttestationFilename: string) => Promise<GithubGistFile | undefined>;
|
|
40
|
+
/**
|
|
41
|
+
* Return the Github handle from the provider user id.
|
|
42
|
+
* @notice the provider user identifier must have the following structure 'handle-id'.
|
|
43
|
+
* @param providerUserId <string> - the unique provider user identifier.
|
|
44
|
+
* @returns <string> - the third-party provider handle of the user.
|
|
45
|
+
*/
|
|
46
|
+
export declare const getUserHandleFromProviderUserId: (providerUserId: string) => string;
|
|
47
|
+
/**
|
|
48
|
+
* Return a custom spinner.
|
|
49
|
+
* @param text <string> - the text that should be displayed as spinner status.
|
|
50
|
+
* @param spinnerLogo <any> - the logo.
|
|
51
|
+
* @returns <Ora> - a new Ora custom spinner.
|
|
52
|
+
*/
|
|
53
|
+
export declare const customSpinner: (text: string, spinnerLogo: any) => Ora;
|
|
54
|
+
/**
|
|
55
|
+
* Custom sleeper.
|
|
56
|
+
* @dev to be used in combination with loggers and for workarounds where listeners cannot help.
|
|
57
|
+
* @param ms <number> - sleep amount in milliseconds
|
|
58
|
+
* @returns <Promise<any>>
|
|
59
|
+
*/
|
|
60
|
+
export declare const sleep: (ms: number) => Promise<any>;
|
|
61
|
+
/**
|
|
62
|
+
* Simple loader for task simulation.
|
|
63
|
+
* @param loadingText <string> - spinner text while loading.
|
|
64
|
+
* @param spinnerLogo <any> - spinner logo.
|
|
65
|
+
* @param durationInMs <number> - spinner loading duration in ms.
|
|
66
|
+
* @returns <Promise<void>>.
|
|
67
|
+
*/
|
|
68
|
+
export declare const simpleLoader: (loadingText: string, spinnerLogo: any, durationInMs: number) => Promise<void>;
|
|
69
|
+
/**
|
|
70
|
+
* Check and return the free aggregated disk space (in KB) for participant machine.
|
|
71
|
+
* @dev this method use the node-disk-info method to retrieve the information about
|
|
72
|
+
* disk availability for all visible disks.
|
|
73
|
+
* nb. no other type of data or operation is performed by this methods.
|
|
74
|
+
* @returns <number> - the free aggregated disk space in kB for the participant machine.
|
|
75
|
+
*/
|
|
76
|
+
export declare const estimateParticipantFreeGlobalDiskSpace: () => number;
|
|
77
|
+
/**
|
|
78
|
+
* Get seconds, minutes, hours and days from milliseconds.
|
|
79
|
+
* @param millis <number> - the amount of milliseconds.
|
|
80
|
+
* @returns <Timing> - a custom object containing the amount of seconds, minutes, hours and days in the provided millis.
|
|
81
|
+
*/
|
|
82
|
+
export declare const getSecondsMinutesHoursFromMillis: (millis: number) => Timing;
|
|
83
|
+
/**
|
|
84
|
+
* Convert milliseconds to seconds.
|
|
85
|
+
* @param millis <number>
|
|
86
|
+
* @returns <number>
|
|
87
|
+
*/
|
|
88
|
+
export declare const convertMillisToSeconds: (millis: number) => number;
|
|
89
|
+
/**
|
|
90
|
+
* Gracefully terminate the command execution
|
|
91
|
+
* @params ghUsername <string> - the Github username of the user.
|
|
92
|
+
*/
|
|
93
|
+
export declare const terminate: (ghUsername: string) => Promise<never>;
|
|
94
|
+
/**
|
|
95
|
+
* Publish public attestation using Github Gist.
|
|
96
|
+
* @dev the contributor must have agreed to provide 'gist' access during the execution of the 'auth' command.
|
|
97
|
+
* @param accessToken <string> - the contributor access token.
|
|
98
|
+
* @param publicAttestation <string> - the public attestation.
|
|
99
|
+
* @param ceremonyTitle <string> - the ceremony title.
|
|
100
|
+
* @param ceremonyPrefix <string> - the ceremony prefix.
|
|
101
|
+
* @returns <Promise<string>> - the url where the gist has been published.
|
|
102
|
+
*/
|
|
103
|
+
export declare const publishGist: (token: string, content: string, ceremonyTitle: string, ceremonyPrefix: string) => Promise<string>;
|
|
104
|
+
/**
|
|
105
|
+
* Generate a custom url that when clicked allows you to compose a tweet ready to be shared.
|
|
106
|
+
* @param ceremonyName <string> - the name of the ceremony.
|
|
107
|
+
* @param gistUrl <string> - the url of the gist where the public attestation has been shared.
|
|
108
|
+
* @param isFinalizing <boolean> - flag to discriminate between ceremony finalization (true) and contribution (false).
|
|
109
|
+
* @returns <string> - the ready to share tweet url.
|
|
110
|
+
*/
|
|
111
|
+
export declare const generateCustomUrlToTweetAboutParticipation: (ceremonyName: string, gistUrl: string, isFinalizing: boolean) => string;
|
|
112
|
+
/**
|
|
113
|
+
* Download an artifact from the ceremony bucket.
|
|
114
|
+
* @dev this method request a pre-signed url to make a GET request to download the artifact.
|
|
115
|
+
* @param cloudFunctions <Functions> - the instance of the Firebase cloud functions for the application.
|
|
116
|
+
* @param bucketName <string> - the name of the ceremony artifacts bucket (AWS S3).
|
|
117
|
+
* @param storagePath <string> - the storage path that locates the artifact to be downloaded in the bucket.
|
|
118
|
+
* @param localPath <string> - the local path where the artifact will be downloaded.
|
|
119
|
+
*/
|
|
120
|
+
export declare const downloadCeremonyArtifact: (cloudFunctions: Functions, bucketName: string, storagePath: string, localPath: string) => Promise<void>;
|
|
121
|
+
/**
|
|
122
|
+
*
|
|
123
|
+
* @param lastZkeyLocalFilePath <string> - the local path of the last contribution.
|
|
124
|
+
* @param nextZkeyLocalFilePath <string> - the local path where the next contribution is going to be stored.
|
|
125
|
+
* @param entropyOrBeacon <string> - the entropy or beacon (only when finalizing) for the contribution.
|
|
126
|
+
* @param contributorOrCoordinatorIdentifier <string> - the identifier of the contributor or coordinator (only when finalizing).
|
|
127
|
+
* @param averageComputingTime <number> - the current average contribution computation time.
|
|
128
|
+
* @param transcriptLogger <Logger> - the custom file logger to generate the contribution transcript.
|
|
129
|
+
* @param isFinalizing <boolean> - flag to discriminate between ceremony finalization (true) and contribution (false).
|
|
130
|
+
* @returns <Promise<number>> - the amount of time spent contributing.
|
|
131
|
+
*/
|
|
132
|
+
export declare const handleContributionComputation: (lastZkeyLocalFilePath: string, nextZkeyLocalFilePath: string, entropyOrBeacon: string, contributorOrCoordinatorIdentifier: string, averageComputingTime: number, transcriptLogger: Logger, isFinalizing: boolean) => Promise<number>;
|
|
133
|
+
/**
|
|
134
|
+
* Return the most up-to-date data about the participant document for the given ceremony.
|
|
135
|
+
* @param firestoreDatabase <Firestore> - the Firestore service instance associated to the current Firebase application.
|
|
136
|
+
* @param ceremonyId <string> - the unique identifier of the ceremony.
|
|
137
|
+
* @param participantId <string> - the unique identifier of the participant.
|
|
138
|
+
* @returns <Promise<DocumentData>> - the most up-to-date participant data.
|
|
139
|
+
*/
|
|
140
|
+
export declare const getLatestUpdatesFromParticipant: (firestoreDatabase: Firestore, ceremonyId: string, participantId: string) => Promise<DocumentData>;
|
|
141
|
+
/**
|
|
142
|
+
* Start or resume a contribution from the last participant contribution step.
|
|
143
|
+
* @notice this method goes through each contribution stage following this order:
|
|
144
|
+
* 1) Downloads the last contribution from previous contributor.
|
|
145
|
+
* 2) Computes the new contribution.
|
|
146
|
+
* 3) Uploads the new contribution.
|
|
147
|
+
* 4) Requests the verification of the new contribution to the coordinator's backend and waits for the result.
|
|
148
|
+
* @param cloudFunctions <Functions> - the instance of the Firebase cloud functions for the application.
|
|
149
|
+
* @param firestoreDatabase <Firestore> - the Firestore service instance associated to the current Firebase application.
|
|
150
|
+
* @param ceremony <FirebaseDocumentInfo> - the Firestore document of the ceremony.
|
|
151
|
+
* @param circuit <FirebaseDocumentInfo> - the Firestore document of the ceremony circuit.
|
|
152
|
+
* @param participant <FirebaseDocumentInfo> - the Firestore document of the participant (contributor or coordinator).
|
|
153
|
+
* @param participantContributionStep <ParticipantContributionStep> - the contribution step of the participant (from where to start/resume contribution).
|
|
154
|
+
* @param entropyOrBeaconHash <string> - the entropy or beacon hash (only when finalizing) for the contribution.
|
|
155
|
+
* @param contributorOrCoordinatorIdentifier <string> - the identifier of the contributor or coordinator (only when finalizing).
|
|
156
|
+
* @param isFinalizing <boolean> - flag to discriminate between ceremony finalization (true) and contribution (false).
|
|
157
|
+
*/
|
|
158
|
+
export declare const handleStartOrResumeContribution: (cloudFunctions: Functions, firestoreDatabase: Firestore, ceremony: FirebaseDocumentInfo, circuit: FirebaseDocumentInfo, participant: FirebaseDocumentInfo, entropyOrBeaconHash: any, contributorOrCoordinatorIdentifier: string, isFinalizing: boolean) => Promise<void>;
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { User as FirebaseAuthUser } from "firebase/auth";
|
|
2
|
+
/**
|
|
3
|
+
* Different custom progress bar types.
|
|
4
|
+
* @enum {string}
|
|
5
|
+
*/
|
|
6
|
+
export declare enum ProgressBarType {
|
|
7
|
+
DOWNLOAD = "DOWNLOAD",
|
|
8
|
+
UPLOAD = "UPLOAD"
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Define the current authenticated user in the Firebase app.
|
|
12
|
+
* @typedef {Object} AuthUser
|
|
13
|
+
* @property {FirebaseAuthUser} user - the instance of the Firebase authenticated user.
|
|
14
|
+
* @property {string} token - the access token.
|
|
15
|
+
* @property {string} providerUserId - the unique identifier of the user tied to its account from a third party provider (e.g., Github).
|
|
16
|
+
*/
|
|
17
|
+
export type AuthUser = {
|
|
18
|
+
user: FirebaseAuthUser;
|
|
19
|
+
token: string;
|
|
20
|
+
providerUserId: string;
|
|
21
|
+
};
|
|
22
|
+
/**
|
|
23
|
+
* Define a custom object for time management tasks.
|
|
24
|
+
* @typedef {Object} Timing
|
|
25
|
+
* @property {number} seconds
|
|
26
|
+
* @property {number} minutes
|
|
27
|
+
* @property {number} hours
|
|
28
|
+
* @property {number} days
|
|
29
|
+
*/
|
|
30
|
+
export type Timing = {
|
|
31
|
+
seconds: number;
|
|
32
|
+
minutes: number;
|
|
33
|
+
hours: number;
|
|
34
|
+
days: number;
|
|
35
|
+
};
|
|
36
|
+
/**
|
|
37
|
+
* Define a custom object containing contribution verification data.
|
|
38
|
+
* @typedef {Object} VerifyContributionComputation
|
|
39
|
+
* @property {boolean} valid - true if the contribution is valid; otherwise false.
|
|
40
|
+
* @property {number} verificationComputationTime - the time spent for completing the verification task only.
|
|
41
|
+
* @property {number} verifyCloudFunctionTime - the time spent for the execution of the verify contribution cloud function.
|
|
42
|
+
* @property {number} fullContributionTime - the time spent while contributing (from download to upload).
|
|
43
|
+
*/
|
|
44
|
+
export type VerifyContributionComputation = {
|
|
45
|
+
valid: boolean;
|
|
46
|
+
verificationComputationTime: number;
|
|
47
|
+
verifyCloudFunctionTime: number;
|
|
48
|
+
fullContributionTime: number;
|
|
49
|
+
};
|
|
50
|
+
/**
|
|
51
|
+
* Define a custom object containing a Github Gist file data.
|
|
52
|
+
* @typedef {Object} GithubGistFile
|
|
53
|
+
* @property {string} filename - the name of the file.
|
|
54
|
+
* @property {string} type - the type of the content of the file (e.g., text/plain).
|
|
55
|
+
* @property {string} language - the type of file (e.g, Text, Markdown).
|
|
56
|
+
* @property {string} raw_url - the url to file content.
|
|
57
|
+
* @property {number} size - the size of the file (in bytes).
|
|
58
|
+
*/
|
|
59
|
+
export type GithubGistFile = {
|
|
60
|
+
filename: string;
|
|
61
|
+
type: string;
|
|
62
|
+
language: string;
|
|
63
|
+
raw_url: string;
|
|
64
|
+
size: number;
|
|
65
|
+
};
|
package/package.json
ADDED
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@devtion/devcli",
|
|
3
|
+
"type": "module",
|
|
4
|
+
"version": "1.0.5-alpha.0",
|
|
5
|
+
"description": "All-in-one interactive command-line for interfacing with zkSNARK Phase 2 Trusted Setup ceremonies",
|
|
6
|
+
"repository": "git@github.com:privacy-scaling-explorations/p0tion.git",
|
|
7
|
+
"homepage": "https://github.com/privacy-scaling-explorations/p0tion",
|
|
8
|
+
"bugs": "https://github.com/privacy-scaling-explorations/p0tion/issues",
|
|
9
|
+
"license": "MIT",
|
|
10
|
+
"bin": "dist/index.js",
|
|
11
|
+
"main": "dist/index.js",
|
|
12
|
+
"types": "dist/types/index.d.ts",
|
|
13
|
+
"engines": {
|
|
14
|
+
"node": ">=16.14.0"
|
|
15
|
+
},
|
|
16
|
+
"files": [
|
|
17
|
+
"dist/",
|
|
18
|
+
"src/",
|
|
19
|
+
"types/",
|
|
20
|
+
"README.md"
|
|
21
|
+
],
|
|
22
|
+
"keywords": [
|
|
23
|
+
"typescript",
|
|
24
|
+
"zero-knowledge",
|
|
25
|
+
"zk-snarks",
|
|
26
|
+
"phase-2",
|
|
27
|
+
"trusted-setup",
|
|
28
|
+
"ceremony",
|
|
29
|
+
"snarkjs",
|
|
30
|
+
"circom"
|
|
31
|
+
],
|
|
32
|
+
"scripts": {
|
|
33
|
+
"build": "rimraf dist && rollup -c rollup.config.ts --configPlugin typescript",
|
|
34
|
+
"build:watch": "rollup -c rollup.config.ts -w --configPlugin typescript",
|
|
35
|
+
"start": "ts-node --esm ./src/index.ts",
|
|
36
|
+
"auth": "yarn start auth",
|
|
37
|
+
"contribute": "yarn start contribute",
|
|
38
|
+
"clean": "yarn start clean",
|
|
39
|
+
"list": "yarn start list",
|
|
40
|
+
"logout": "yarn start logout",
|
|
41
|
+
"validate": "yarn start validate",
|
|
42
|
+
"coordinate:setup": "yarn start coordinate setup",
|
|
43
|
+
"coordinate:observe": "yarn start coordinate observe",
|
|
44
|
+
"coordinate:finalize": "yarn start coordinate finalize",
|
|
45
|
+
"docs": "typedoc src/**/*.ts --out ../../docs/phase2cli"
|
|
46
|
+
},
|
|
47
|
+
"devDependencies": {
|
|
48
|
+
"@types/clear": "^0.1.2",
|
|
49
|
+
"@types/cli-progress": "^3.11.0",
|
|
50
|
+
"@types/figlet": "^1.5.6",
|
|
51
|
+
"@types/mime-types": "^2.1.1",
|
|
52
|
+
"@types/node-emoji": "^1.8.2",
|
|
53
|
+
"@types/node-fetch": "^2.6.3",
|
|
54
|
+
"@types/ora": "^3.2.0",
|
|
55
|
+
"@types/prompts": "^2.4.4",
|
|
56
|
+
"@types/rollup-plugin-auto-external": "^2.0.2",
|
|
57
|
+
"@types/winston": "^2.4.4",
|
|
58
|
+
"rollup-plugin-auto-external": "^2.0.0",
|
|
59
|
+
"rollup-plugin-cleanup": "^3.2.1",
|
|
60
|
+
"rollup-plugin-typescript2": "^0.34.1",
|
|
61
|
+
"solc": "^0.8.19",
|
|
62
|
+
"ts-node": "^10.9.1",
|
|
63
|
+
"typescript": "^5.0.4"
|
|
64
|
+
},
|
|
65
|
+
"dependencies": {
|
|
66
|
+
"@adobe/node-fetch-retry": "^2.2.0",
|
|
67
|
+
"@octokit/auth-oauth-app": "^5.0.5",
|
|
68
|
+
"@octokit/auth-oauth-device": "^4.0.4",
|
|
69
|
+
"@octokit/request": "^6.2.3",
|
|
70
|
+
"@p0tion/actions": "^1.0.5",
|
|
71
|
+
"blakejs": "^1.2.1",
|
|
72
|
+
"boxen": "^7.1.0",
|
|
73
|
+
"chalk": "^5.2.0",
|
|
74
|
+
"clear": "^0.1.0",
|
|
75
|
+
"cli-progress": "^3.12.0",
|
|
76
|
+
"clipboardy": "^3.0.0",
|
|
77
|
+
"commander": "^10.0.1",
|
|
78
|
+
"conf": "^11.0.1",
|
|
79
|
+
"dotenv": "^16.0.3",
|
|
80
|
+
"figlet": "^1.6.0",
|
|
81
|
+
"firebase": "^9.21.0",
|
|
82
|
+
"log-symbols": "^5.1.0",
|
|
83
|
+
"mime-types": "^2.1.35",
|
|
84
|
+
"node-disk-info": "^1.3.0",
|
|
85
|
+
"node-emoji": "^1.11.0",
|
|
86
|
+
"node-fetch": "^3.3.1",
|
|
87
|
+
"open": "^9.1.0",
|
|
88
|
+
"ora": "^6.3.0",
|
|
89
|
+
"prompts": "^2.4.2",
|
|
90
|
+
"rimraf": "^5.0.0",
|
|
91
|
+
"rollup": "^3.21.6",
|
|
92
|
+
"snarkjs": "^0.6.11",
|
|
93
|
+
"timer-node": "^5.0.7",
|
|
94
|
+
"winston": "^3.8.2"
|
|
95
|
+
},
|
|
96
|
+
"publishConfig": {
|
|
97
|
+
"access": "public"
|
|
98
|
+
}
|
|
99
|
+
}
|