@devtion/devcli 0.0.0-dev → 0.0.0-e312890

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 (43) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +3 -1
  3. package/dist/.env +54 -39
  4. package/dist/index.js +553 -121
  5. package/dist/public/mini-semaphore.wasm +0 -0
  6. package/dist/public/mini-semaphore.zkey +0 -0
  7. package/dist/types/commands/authBandada.d.ts +2 -0
  8. package/dist/types/commands/authSIWE.d.ts +7 -0
  9. package/dist/types/commands/ceremony/index.d.ts +3 -0
  10. package/dist/types/commands/ceremony/listParticipants.d.ts +2 -0
  11. package/dist/types/commands/contribute.d.ts +1 -1
  12. package/dist/types/commands/finalize.d.ts +4 -3
  13. package/dist/types/commands/index.d.ts +2 -0
  14. package/dist/types/commands/observe.d.ts +1 -1
  15. package/dist/types/commands/setup.d.ts +4 -4
  16. package/dist/types/lib/bandada.d.ts +6 -0
  17. package/dist/types/lib/files.d.ts +1 -0
  18. package/dist/types/lib/localConfigs.d.ts +38 -0
  19. package/dist/types/lib/prompts.d.ts +7 -7
  20. package/dist/types/lib/utils.d.ts +3 -2
  21. package/dist/types/types/index.d.ts +69 -0
  22. package/package.json +106 -97
  23. package/src/commands/auth.ts +24 -8
  24. package/src/commands/authBandada.ts +120 -0
  25. package/src/commands/authSIWE.ts +185 -0
  26. package/src/commands/ceremony/index.ts +20 -0
  27. package/src/commands/ceremony/listParticipants.ts +56 -0
  28. package/src/commands/contribute.ts +56 -29
  29. package/src/commands/finalize.ts +27 -14
  30. package/src/commands/index.ts +3 -1
  31. package/src/commands/listCeremonies.ts +2 -3
  32. package/src/commands/logout.ts +3 -1
  33. package/src/commands/observe.ts +8 -4
  34. package/src/commands/setup.ts +59 -48
  35. package/src/commands/validate.ts +2 -3
  36. package/src/index.ts +35 -13
  37. package/src/lib/bandada.ts +51 -0
  38. package/src/lib/errors.ts +2 -2
  39. package/src/lib/localConfigs.ts +55 -1
  40. package/src/lib/prompts.ts +23 -26
  41. package/src/lib/services.ts +39 -16
  42. package/src/lib/utils.ts +53 -15
  43. package/src/types/index.ts +75 -0
Binary file
Binary file
@@ -0,0 +1,2 @@
1
+ declare const authBandada: () => Promise<never>;
2
+ export default authBandada;
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Auth command using Sign In With Ethereum
3
+ * @notice The auth command allows a user to make the association of their Ethereum account with the CLI by leveraging SIWE as an authentication mechanism.
4
+ * @dev Under the hood, the command handles a manual Device Flow following the guidelines in the SIWE documentation.
5
+ */
6
+ declare const authSIWE: () => Promise<void>;
7
+ export default authSIWE;
@@ -0,0 +1,3 @@
1
+ import { Command } from "commander";
2
+ declare const setCeremonyCommands: (program: Command) => Command;
3
+ export default setCeremonyCommands;
@@ -0,0 +1,2 @@
1
+ declare const listParticipants: () => Promise<never>;
2
+ export default listParticipants;
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import { Contribution, ContributionValidity, FirebaseDocumentInfo } from "@p0tion/actions";
2
+ import { Contribution, ContributionValidity, FirebaseDocumentInfo } from "@devtion/actions";
3
3
  import { DocumentSnapshot, DocumentData, Firestore } from "firebase/firestore";
4
4
  import { Functions } from "firebase/functions";
5
5
  /**
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import { FirebaseDocumentInfo } from "@p0tion/actions";
2
+ import { FirebaseDocumentInfo } from "@devtion/actions";
3
3
  import { Functions } from "firebase/functions";
4
4
  import { Firestore } from "firebase/firestore";
5
5
  /**
@@ -36,8 +36,9 @@ export declare const handleVerifierSmartContract: (cloudFunctions: Functions, bu
36
36
  * @param participant <FirebaseDocumentInfo> - the Firestore document of the participant (coordinator).
37
37
  * @param beacon <string> - the value used to compute the final contribution while finalizing the ceremony.
38
38
  * @param coordinatorIdentifier <string> - the identifier of the coordinator.
39
+ * @param circuitsLength <number> - the number of circuits in the ceremony.
39
40
  */
40
- export declare const handleCircuitFinalization: (cloudFunctions: Functions, firestoreDatabase: Firestore, ceremony: FirebaseDocumentInfo, circuit: FirebaseDocumentInfo, participant: FirebaseDocumentInfo, beacon: string, coordinatorIdentifier: string) => Promise<void>;
41
+ export declare const handleCircuitFinalization: (cloudFunctions: Functions, firestoreDatabase: Firestore, ceremony: FirebaseDocumentInfo, circuit: FirebaseDocumentInfo, participant: FirebaseDocumentInfo, beacon: string, coordinatorIdentifier: string, circuitsLength: number) => Promise<void>;
41
42
  /**
42
43
  * Finalize command.
43
44
  * @notice The finalize command allows a coordinator to finalize a Trusted Setup Phase 2 ceremony by providing the final beacon,
@@ -47,5 +48,5 @@ export declare const handleCircuitFinalization: (cloudFunctions: Functions, fire
47
48
  * @dev For proper execution, the command requires the coordinator to be authenticated with a GitHub account (run auth command first) in order to
48
49
  * handle sybil-resistance and connect to GitHub APIs to publish the gist containing the final public attestation.
49
50
  */
50
- declare const finalize: () => Promise<void>;
51
+ declare const finalize: (opt: any) => Promise<void>;
51
52
  export default finalize;
@@ -1,5 +1,7 @@
1
1
  export { default as setup } from "./setup.js";
2
2
  export { default as auth } from "./auth.js";
3
+ export { default as authBandada } from "./authBandada.js";
4
+ export { default as authSIWE } from "./authSIWE.js";
3
5
  export { default as contribute } from "./contribute.js";
4
6
  export { default as observe } from "./observe.js";
5
7
  export { default as finalize } from "./finalize.js";
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import { FirebaseDocumentInfo } from "@p0tion/actions";
2
+ import { FirebaseDocumentInfo } from "@devtion/actions";
3
3
  import { Firestore } from "firebase/firestore";
4
4
  /**
5
5
  * Clean cursor lines from current position back to root (default: zero).
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env node
2
2
  import { Functions } from "firebase/functions";
3
- import { CeremonyTimeoutType, CircomCompilerData, CircuitInputData, CeremonyInputData, CircuitDocument } from "@p0tion/actions";
3
+ import { CeremonyTimeoutType, CircomCompilerData, CircuitInputData, CeremonyInputData, CircuitDocument } from "@devtion/actions";
4
4
  /**
5
5
  * Handle whatever is needed to obtain the input data for a circuit that the coordinator would like to add to the ceremony.
6
6
  * @param choosenCircuitFilename <string> - the name of the circuit to add.
@@ -27,7 +27,7 @@ export declare const handleAdditionOfCircuitsToCeremony: (r1csOptions: Array<str
27
27
  export declare const displayCeremonySummary: (ceremonyInputData: CeremonyInputData, circuits: Array<CircuitDocument>) => void;
28
28
  /**
29
29
  * Check if the smallest Powers of Tau has already been downloaded/stored in the correspondent local path
30
- * @dev we are downloading the Powers of Tau file from Hermez Cryptography Phase 1 Trusted Setup.
30
+ * @dev we are downloading the Powers of Tau file from Perpetual Powers of Tau Phase 1 Trusted Setup.
31
31
  * @param powers <string> - the smallest amount of powers needed for the given circuit (should be in a 'XY' stringified form).
32
32
  * @param ptauCompleteFilename <string> - the complete file name of the powers of tau file to be downloaded.
33
33
  * @returns <Promise<void>>
@@ -39,7 +39,7 @@ export declare const checkAndDownloadSmallestPowersOfTau: (powers: string, ptauC
39
39
  * number of powers greater than or equal to the powers needed by the zKey), the coordinator will be asked
40
40
  * to provide a number of powers manually, ranging from the smallest possible to the largest.
41
41
  * @param neededPowers <number> - the smallest amount of powers needed by the zKey.
42
- * @returns Promise<string, string> - the information about the choosen Powers of Tau file for the pre-computed zKey
42
+ * @returns Promise<string, string> - the information about the chosen Powers of Tau file for the pre-computed zKey
43
43
  * along with related powers.
44
44
  */
45
45
  export declare const handlePreComputedZkeyPowersOfTauSelection: (neededPowers: number) => Promise<{
@@ -76,7 +76,7 @@ export declare const handleCircuitArtifactUploadToStorage: (firebaseFunctions: F
76
76
  * @notice The setup command allows the coordinator of the ceremony to prepare the next ceremony by interacting with the CLI.
77
77
  * @dev For proper execution, the command must be run in a folder containing the R1CS files related to the circuits
78
78
  * for which the coordinator wants to create the ceremony. The command will download the necessary Tau powers
79
- * from Hermez's ceremony Phase 1 Reliable Setup Ceremony.
79
+ * from PPoT ceremony Phase 1 Setup Ceremony.
80
80
  * @param cmd? <any> - the path to the ceremony setup file.
81
81
  */
82
82
  declare const setup: (cmd: {
@@ -0,0 +1,6 @@
1
+ import { GroupResponse } from "@bandada/api-sdk";
2
+ import { Identity } from "@semaphore-protocol/identity";
3
+ export declare const getGroup: (groupId: string) => Promise<GroupResponse | null>;
4
+ export declare const getMembersOfGroup: (groupId: string) => Promise<string[] | null>;
5
+ export declare const addMemberToGroup: (groupId: string, dashboardUrl: string, identity: Identity) => Promise<void>;
6
+ export declare const isGroupMember: (groupId: string, identity: Identity) => Promise<boolean>;
@@ -1,4 +1,5 @@
1
1
  /// <reference types="node" />
2
+ /// <reference types="node" />
2
3
  import { Dirent, Stats } from "fs";
3
4
  /**
4
5
  * Check a directory path.
@@ -35,6 +35,44 @@ export declare const setLocalAccessToken: (token: string) => void;
35
35
  * Delete the stored access token.
36
36
  */
37
37
  export declare const deleteLocalAccessToken: () => void;
38
+ /**
39
+ * Return the Bandada identity, if present.
40
+ * @returns <string | undefined> - the Bandada identity if present, otherwise undefined.
41
+ */
42
+ export declare const getLocalBandadaIdentity: () => string | unknown;
43
+ /**
44
+ * Check if the Bandada identity exists in the local storage.
45
+ * @returns <boolean>
46
+ */
47
+ export declare const checkLocalBandadaIdentity: () => boolean;
48
+ /**
49
+ * Set the Bandada identity.
50
+ * @param identity <string> - the Bandada identity to be stored.
51
+ */
52
+ export declare const setLocalBandadaIdentity: (identity: string) => void;
53
+ /**
54
+ * Delete the stored Bandada identity.
55
+ */
56
+ export declare const deleteLocalBandadaIdentity: () => void;
57
+ /**
58
+ * Return the authentication method, if present.
59
+ * @returns <string | undefined> - the authentication method if present, otherwise undefined.
60
+ */
61
+ export declare const getLocalAuthMethod: () => string | unknown;
62
+ /**
63
+ * Check if the authentication method exists in the local storage.
64
+ * @returns <boolean>
65
+ */
66
+ export declare const checkLocalAuthMethod: () => boolean;
67
+ /**
68
+ * Set the authentication method.
69
+ * @param method <string> - the authentication method to be stored.
70
+ */
71
+ export declare const setLocalAuthMethod: (method: string) => void;
72
+ /**
73
+ * Delete the stored authentication method.
74
+ */
75
+ export declare const deleteLocalAuthMethod: () => void;
38
76
  /**
39
77
  * Get the complete local file path.
40
78
  * @param cwd <string> - the current working directory path.
@@ -1,6 +1,6 @@
1
1
  import { Answers } from "prompts";
2
2
  import { Firestore } from "firebase/firestore";
3
- import { CeremonyInputData, FirebaseDocumentInfo, CircomCompilerData, CircuitInputData, CeremonyTimeoutType, DiskTypeForVM } from "@p0tion/actions";
3
+ import { CeremonyInputData, FirebaseDocumentInfo, CircomCompilerData, CircuitInputData, CeremonyTimeoutType, DiskTypeForVM } from "@devtion/actions";
4
4
  /**
5
5
  * Ask a binary (yes/no or true/false) customizable question.
6
6
  * @param question <string> - the question to be answered.
@@ -24,14 +24,14 @@ export declare const promptCircomCompiler: () => Promise<CircomCompilerData>;
24
24
  * Shows a list of circuits for a single option selection.
25
25
  * @dev the circuit names are derived from local R1CS files.
26
26
  * @param options <Array<string>> - an array of circuits names.
27
- * @returns Promise<string> - the name of the choosen circuit.
27
+ * @returns Promise<string> - the name of the chosen circuit.
28
28
  */
29
29
  export declare const promptCircuitSelector: (options: Array<string>) => Promise<string>;
30
30
  /**
31
31
  * Shows a list of standard EC2 VM instance types for a single option selection.
32
32
  * @notice the suggested VM configuration type is calculated based on circuit constraint size.
33
33
  * @param constraintSize <number> - the amount of circuit constraints
34
- * @returns Promise<string> - the name of the choosen VM type.
34
+ * @returns Promise<string> - the name of the chosen VM type.
35
35
  */
36
36
  export declare const promptVMTypeSelector: (constraintSize: any) => Promise<string>;
37
37
  /**
@@ -42,7 +42,7 @@ export declare const promptVMDiskTypeSelector: () => Promise<DiskTypeForVM>;
42
42
  /**
43
43
  * Show a series of questions about the circuits.
44
44
  * @param constraintSize <number> - the amount of circuit constraints.
45
- * @param timeoutMechanismType <CeremonyTimeoutType> - the choosen timeout mechanism type for the ceremony.
45
+ * @param timeoutMechanismType <CeremonyTimeoutType> - the chosen timeout mechanism type for the ceremony.
46
46
  * @param needPromptCircomCompiler <boolean> - a boolean value indicating if the questions related to the Circom compiler version and commit hash must be asked.
47
47
  * @param enforceVM <boolean> - a boolean value indicating if the contribution verification could be supported by VM-only approach or not.
48
48
  * @returns Promise<Array<Circuit>> - circuit info prompted by the coordinator.
@@ -67,7 +67,7 @@ export declare const promptCircuitAddition: () => Promise<boolean>;
67
67
  * Shows a list of pre-computed zKeys for a single option selection.
68
68
  * @dev the names are derived from local zKeys files.
69
69
  * @param options <Array<string>> - an array of pre-computed zKeys names.
70
- * @returns Promise<string> - the name of the choosen pre-computed zKey.
70
+ * @returns Promise<string> - the name of the chosen pre-computed zKey.
71
71
  */
72
72
  export declare const promptPreComputedZkeySelector: (options: Array<string>) => Promise<string>;
73
73
  /**
@@ -80,7 +80,7 @@ export declare const promptNeededPowersForCircuit: (suggestedSmallestNeededPower
80
80
  * Shows a list of PoT files for a single option selection.
81
81
  * @dev the names are derived from local PoT files.
82
82
  * @param options <Array<string>> - an array of PoT file names.
83
- * @returns Promise<string> - the name of the choosen PoT.
83
+ * @returns Promise<string> - the name of the chosen PoT.
84
84
  */
85
85
  export declare const promptPotSelector: (options: Array<string>) => Promise<string>;
86
86
  /**
@@ -90,7 +90,7 @@ export declare const promptPotSelector: (options: Array<string>) => Promise<stri
90
90
  * @param isFinalizing <boolean> - true when the coordinator must select a ceremony for finalization; otherwise false (participant selects a ceremony for contribution).
91
91
  * @returns Promise<FirebaseDocumentInfo> - the Firestore document of the selected ceremony.
92
92
  */
93
- export declare const promptForCeremonySelection: (ceremoniesDocuments: Array<FirebaseDocumentInfo>, isFinalizing: boolean) => Promise<FirebaseDocumentInfo>;
93
+ export declare const promptForCeremonySelection: (ceremoniesDocuments: Array<FirebaseDocumentInfo>, isFinalizing: boolean, messageToDisplay?: string) => Promise<FirebaseDocumentInfo>;
94
94
  /**
95
95
  * Prompt the participant to type the entropy or the coordinator to type the beacon.
96
96
  * @param isEntropy <boolean> - true when prompting for typing entropy; otherwise false.
@@ -1,4 +1,4 @@
1
- import { FirebaseDocumentInfo } from "@p0tion/actions";
1
+ import { FirebaseDocumentInfo } from "@devtion/actions";
2
2
  import { OAuthCredential } from "firebase/auth";
3
3
  import { DocumentData, Firestore } from "firebase/firestore";
4
4
  import { Functions } from "firebase/functions";
@@ -154,5 +154,6 @@ export declare const getLatestUpdatesFromParticipant: (firestoreDatabase: Firest
154
154
  * @param entropyOrBeaconHash <string> - the entropy or beacon hash (only when finalizing) for the contribution.
155
155
  * @param contributorOrCoordinatorIdentifier <string> - the identifier of the contributor or coordinator (only when finalizing).
156
156
  * @param isFinalizing <boolean> - flag to discriminate between ceremony finalization (true) and contribution (false).
157
+ * @param circuitsLength <number> - the total number of circuits in the ceremony.
157
158
  */
158
- export declare const handleStartOrResumeContribution: (cloudFunctions: Functions, firestoreDatabase: Firestore, ceremony: FirebaseDocumentInfo, circuit: FirebaseDocumentInfo, participant: FirebaseDocumentInfo, entropyOrBeaconHash: any, contributorOrCoordinatorIdentifier: string, isFinalizing: boolean) => Promise<void>;
159
+ export declare const handleStartOrResumeContribution: (cloudFunctions: Functions, firestoreDatabase: Firestore, ceremony: FirebaseDocumentInfo, circuit: FirebaseDocumentInfo, participant: FirebaseDocumentInfo, entropyOrBeaconHash: any, contributorOrCoordinatorIdentifier: string, isFinalizing: boolean, circuitsLength: number) => Promise<void>;
@@ -63,3 +63,72 @@ export type GithubGistFile = {
63
63
  raw_url: string;
64
64
  size: number;
65
65
  };
66
+ /**
67
+ * Define the return object of the function that verifies the Bandada membership and proof.
68
+ * @typedef {Object} VerifiedBandadaResponse
69
+ * @property {boolean} valid - true if the proof is valid and the user is a member of the group; otherwise false.
70
+ * @property {string} message - a message describing the result of the verification.
71
+ * @property {string} token - the custom access token.
72
+ */
73
+ export type VerifiedBandadaResponse = {
74
+ valid: boolean;
75
+ message: string;
76
+ token: string;
77
+ };
78
+ /**
79
+ * Define the return object of the device code uri request.
80
+ * @typedef {Object} OAuthDeviceCodeResponse
81
+ * @property {string} device_code - the device code.
82
+ * @property {string} user_code - the user code.
83
+ * @property {string} verification_uri - the verification uri.
84
+ * @property {number} expires_in - the expiration time in seconds.
85
+ * @property {number} interval - the interval time in seconds.
86
+ * @property {string} verification_uri_complete - the complete verification uri.
87
+ * @property {string} error - in case there was an error, show the code
88
+ * @property {string} error_description - error details.
89
+ * @property {string} error_uri - error uri.
90
+ */
91
+ export type OAuthDeviceCodeResponse = {
92
+ device_code: string;
93
+ user_code: string;
94
+ verification_uri: string;
95
+ expires_in: number;
96
+ interval: number;
97
+ verification_uri_complete: string;
98
+ error?: string;
99
+ error_description?: string;
100
+ error_uri?: string;
101
+ };
102
+ /**
103
+ * Define the return object of the polling endpoint
104
+ * @typedef {Object} OAuthTokenResponse
105
+ * @property {string} access_token - the resulting device flow token
106
+ * @property {string} token_type - token type
107
+ * @property {number} expires_in - when does the token expires
108
+ * @property {string} scope - the scope requested by the initial device flow endpoint
109
+ * @property {string} refresh_token - refresh token
110
+ * @property {string} id_token - id token
111
+ * @property {string} error - in case there was an error, show the code
112
+ * @property {string} error_description - error details
113
+ */
114
+ export type OAuthTokenResponse = {
115
+ access_token: string;
116
+ token_type: string;
117
+ expires_in: number;
118
+ scope: string;
119
+ refresh_token: string;
120
+ id_token: string;
121
+ error?: string;
122
+ error_description?: string;
123
+ };
124
+ /**
125
+ * @typedef {Object} CheckNonceOfSIWEAddressResponse
126
+ * @property {boolean} valid - if the checking was valid or not
127
+ * @property {string} message - more information about the validity
128
+ * @property {string} token - token to sign into Firebase
129
+ */
130
+ export type CheckNonceOfSIWEAddressResponse = {
131
+ valid: boolean;
132
+ message: string;
133
+ token: string;
134
+ };
package/package.json CHANGED
@@ -1,99 +1,108 @@
1
1
  {
2
- "name": "@devtion/devcli",
3
- "type": "module",
4
- "version": "0.0.0-dev",
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
- }
2
+ "name": "@devtion/devcli",
3
+ "type": "module",
4
+ "version": "0.0.0-e312890",
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
+ "auth:siwe": "yarn start auth-siwe",
38
+ "auth:bandada": "yarn start auth-bandada",
39
+ "contribute": "yarn start contribute",
40
+ "clean": "yarn start clean",
41
+ "list": "yarn start list",
42
+ "logout": "yarn start logout",
43
+ "validate": "yarn start validate",
44
+ "ceremony:participants": "yarn start ceremony participants",
45
+ "coordinate:setup": "yarn start coordinate setup",
46
+ "coordinate:observe": "yarn start coordinate observe",
47
+ "coordinate:finalize": "yarn start coordinate finalize",
48
+ "docs": "typedoc src/**/*.ts --out ../../docs/phase2cli"
49
+ },
50
+ "devDependencies": {
51
+ "@types/clear": "^0.1.2",
52
+ "@types/cli-progress": "^3.11.0",
53
+ "@types/figlet": "^1.5.6",
54
+ "@types/mime-types": "^2.1.1",
55
+ "@types/node-emoji": "^1.8.2",
56
+ "@types/node-fetch": "^2.6.3",
57
+ "@types/ora": "^3.2.0",
58
+ "@types/prompts": "^2.4.4",
59
+ "@types/rollup-plugin-auto-external": "^2.0.2",
60
+ "@types/winston": "^2.4.4",
61
+ "rollup-plugin-auto-external": "^2.0.0",
62
+ "rollup-plugin-cleanup": "^3.2.1",
63
+ "rollup-plugin-copy": "^3.5.0",
64
+ "rollup-plugin-typescript2": "^0.34.1",
65
+ "solc": "^0.8.19",
66
+ "ts-node": "^10.9.1",
67
+ "typescript": "^5.0.4"
68
+ },
69
+ "dependencies": {
70
+ "@adobe/node-fetch-retry": "^2.2.0",
71
+ "@aws-sdk/client-s3": "^3.329.0",
72
+ "@bandada/api-sdk": "^1.0.0-beta.1",
73
+ "@devtion/actions": "latest",
74
+ "@octokit/auth-oauth-app": "^5.0.5",
75
+ "@octokit/auth-oauth-device": "^4.0.4",
76
+ "@octokit/request": "^6.2.3",
77
+ "@semaphore-protocol/identity": "^3.15.1",
78
+ "blakejs": "^1.2.1",
79
+ "boxen": "^7.1.0",
80
+ "chalk": "^5.2.0",
81
+ "clear": "^0.1.0",
82
+ "cli-progress": "^3.12.0",
83
+ "clipboardy": "^3.0.0",
84
+ "commander": "^10.0.1",
85
+ "conf": "^11.0.1",
86
+ "dotenv": "^16.0.3",
87
+ "ethers": "^6.9.0",
88
+ "figlet": "^1.6.0",
89
+ "firebase": "^9.21.0",
90
+ "log-symbols": "^5.1.0",
91
+ "mime-types": "^2.1.35",
92
+ "node-disk-info": "^1.3.0",
93
+ "node-emoji": "^1.11.0",
94
+ "node-fetch": "^3.3.1",
95
+ "open": "^9.1.0",
96
+ "ora": "^6.3.0",
97
+ "prompts": "^2.4.2",
98
+ "rimraf": "^5.0.0",
99
+ "rollup": "^3.21.6",
100
+ "snarkjs": "0.7.3",
101
+ "timer-node": "^5.0.7",
102
+ "winston": "^3.8.2"
103
+ },
104
+ "publishConfig": {
105
+ "access": "public"
106
+ },
107
+ "gitHead": "523f29a0c484496e734ccd908c7bcd428ed90618"
99
108
  }
@@ -8,7 +8,12 @@ import figlet from "figlet"
8
8
  import { fileURLToPath } from "url"
9
9
  import { dirname } from "path"
10
10
  import { GENERIC_ERRORS, showError } from "../lib/errors.js"
11
- import { checkLocalAccessToken, getLocalAccessToken, setLocalAccessToken } from "../lib/localConfigs.js"
11
+ import {
12
+ checkLocalAccessToken,
13
+ getLocalAccessToken,
14
+ setLocalAccessToken,
15
+ setLocalAuthMethod
16
+ } from "../lib/localConfigs.js"
12
17
  import { bootstrapCommandExecutionAndServices, signInToFirebase } from "../lib/services.js"
13
18
  import theme from "../lib/theme.js"
14
19
  import {
@@ -63,8 +68,13 @@ export const expirationCountdownForGithubOAuth = (expirationInSeconds: number) =
63
68
  */
64
69
  export const onVerification = async (verification: Verification): Promise<void> => {
65
70
  // Copy code to clipboard.
66
- clipboard.writeSync(verification.user_code)
67
- clipboard.readSync()
71
+ let noClipboard = false
72
+ try {
73
+ clipboard.writeSync(verification.user_code)
74
+ clipboard.readSync()
75
+ } catch (error) {
76
+ noClipboard = true
77
+ }
68
78
 
69
79
  // Display data.
70
80
  console.log(
@@ -73,12 +83,13 @@ export const onVerification = async (verification: Verification): Promise<void>
73
83
  )} on this device to generate a new token and authenticate\n`
74
84
  )
75
85
 
76
- console.log(theme.colors.magenta(figlet.textSync(verification.user_code, { font: "ANSI Shadow" })), '\n')
86
+ console.log(theme.colors.magenta(figlet.textSync("Code is Below", { font: "ANSI Shadow" })), "\n")
77
87
 
88
+ const message = !noClipboard ? `has been copied to your clipboard (${theme.emojis.clipboard})` : ``
78
89
  console.log(
79
- `${theme.symbols.info} Your auth code: ${theme.text.bold(verification.user_code)} has been copied to your clipboard (${theme.emojis.clipboard} ${
90
+ `${theme.symbols.info} Your auth code: ${theme.text.bold(verification.user_code)} ${message} ${
80
91
  theme.symbols.success
81
- })\n`
92
+ }\n`
82
93
  )
83
94
 
84
95
  const spinner = customSpinner(`Redirecting to Github...`, `clock`)
@@ -86,8 +97,12 @@ export const onVerification = async (verification: Verification): Promise<void>
86
97
 
87
98
  await sleep(10000) // ~10s to make users able to read the CLI.
88
99
 
89
- // Automatically open the page (# Step 2).
90
- await open(verification.verification_uri)
100
+ try {
101
+ // Automatically open the page (# Step 2).
102
+ await open(verification.verification_uri)
103
+ } catch (error: any) {
104
+ console.log(`${theme.symbols.info} Please authenticate via GitHub at ${verification.verification_uri}`)
105
+ }
91
106
 
92
107
  spinner.stop()
93
108
 
@@ -161,6 +176,7 @@ const auth = async () => {
161
176
  const newToken = await executeGithubDeviceFlow(String(process.env.AUTH_GITHUB_CLIENT_ID))
162
177
 
163
178
  // Store the new access token.
179
+ setLocalAuthMethod("github")
164
180
  setLocalAccessToken(newToken)
165
181
  } else spinner.succeed(`Local authentication token found\n`)
166
182