@devtion/devcli 0.0.0-9614e0c → 0.0.0-9843891
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 +1 -1
- package/dist/.env +17 -3
- package/dist/index.js +543 -101
- package/dist/public/mini-semaphore.wasm +0 -0
- package/dist/public/mini-semaphore.zkey +0 -0
- package/dist/types/commands/authBandada.d.ts +2 -0
- package/dist/types/commands/authSIWE.d.ts +7 -0
- package/dist/types/commands/ceremony/index.d.ts +3 -0
- package/dist/types/commands/ceremony/listParticipants.d.ts +2 -0
- package/dist/types/commands/finalize.d.ts +3 -2
- package/dist/types/commands/index.d.ts +2 -0
- package/dist/types/commands/setup.d.ts +1 -1
- package/dist/types/lib/bandada.d.ts +6 -0
- package/dist/types/lib/files.d.ts +1 -0
- package/dist/types/lib/localConfigs.d.ts +38 -0
- package/dist/types/lib/prompts.d.ts +6 -6
- package/dist/types/lib/utils.d.ts +2 -1
- package/dist/types/types/index.d.ts +69 -0
- package/package.json +10 -3
- package/src/commands/auth.ts +25 -9
- package/src/commands/authBandada.ts +120 -0
- package/src/commands/authSIWE.ts +185 -0
- package/src/commands/ceremony/index.ts +20 -0
- package/src/commands/ceremony/listParticipants.ts +56 -0
- package/src/commands/contribute.ts +55 -28
- package/src/commands/finalize.ts +26 -13
- package/src/commands/index.ts +3 -1
- package/src/commands/listCeremonies.ts +1 -2
- package/src/commands/logout.ts +3 -1
- package/src/commands/observe.ts +7 -3
- package/src/commands/setup.ts +59 -27
- package/src/commands/validate.ts +1 -2
- package/src/index.ts +35 -13
- package/src/lib/bandada.ts +51 -0
- package/src/lib/errors.ts +1 -1
- package/src/lib/localConfigs.ts +54 -0
- package/src/lib/prompts.ts +22 -25
- package/src/lib/services.ts +38 -15
- package/src/lib/utils.ts +44 -9
- package/src/types/index.ts +75 -0
package/src/lib/utils.ts
CHANGED
|
@@ -155,7 +155,9 @@ export const getPublicAttestationGist = async (
|
|
|
155
155
|
* @returns <string> - the third-party provider handle of the user.
|
|
156
156
|
*/
|
|
157
157
|
export const getUserHandleFromProviderUserId = (providerUserId: string): string => {
|
|
158
|
-
if (providerUserId.indexOf("-") === -1)
|
|
158
|
+
if (providerUserId.indexOf("-") === -1) {
|
|
159
|
+
return providerUserId
|
|
160
|
+
}
|
|
159
161
|
|
|
160
162
|
return providerUserId.split("-")[0]
|
|
161
163
|
}
|
|
@@ -311,8 +313,22 @@ export const generateCustomUrlToTweetAboutParticipation = (
|
|
|
311
313
|
isFinalizing: boolean
|
|
312
314
|
) =>
|
|
313
315
|
isFinalizing
|
|
314
|
-
? `https://twitter.com/intent/tweet?text=I%20have%20finalized%20the%20${ceremonyName}
|
|
315
|
-
|
|
316
|
+
? `https://twitter.com/intent/tweet?text=I%20have%20finalized%20the%20${ceremonyName}${
|
|
317
|
+
ceremonyName.toLowerCase().includes("trusted") ||
|
|
318
|
+
ceremonyName.toLowerCase().includes("setup") ||
|
|
319
|
+
ceremonyName.toLowerCase().includes("phase2") ||
|
|
320
|
+
ceremonyName.toLowerCase().includes("ceremony")
|
|
321
|
+
? "!"
|
|
322
|
+
: "%20Phase%202%20Trusted%20Setup%20ceremony!"
|
|
323
|
+
}%20You%20can%20view%20my%20final%20attestation%20here:%20${gistUrl}%20#Ethereum%20#ZKP%20#PSE`
|
|
324
|
+
: `https://twitter.com/intent/tweet?text=I%20contributed%20to%20the%20${ceremonyName}${
|
|
325
|
+
ceremonyName.toLowerCase().includes("trusted") ||
|
|
326
|
+
ceremonyName.toLowerCase().includes("setup") ||
|
|
327
|
+
ceremonyName.toLowerCase().includes("phase2") ||
|
|
328
|
+
ceremonyName.toLowerCase().includes("ceremony")
|
|
329
|
+
? "!"
|
|
330
|
+
: "%20Phase%202%20Trusted%20Setup%20ceremony!"
|
|
331
|
+
}%20You%20can%20view%20the%20steps%20to%20contribute%20here:%20https://ceremony.pse.dev%20You%20can%20view%20my%20attestation%20here:%20${gistUrl}%20#Ethereum%20#ZKP`
|
|
316
332
|
|
|
317
333
|
/**
|
|
318
334
|
* Return a custom progress bar.
|
|
@@ -521,6 +537,7 @@ export const getLatestUpdatesFromParticipant = async (
|
|
|
521
537
|
* @param entropyOrBeaconHash <string> - the entropy or beacon hash (only when finalizing) for the contribution.
|
|
522
538
|
* @param contributorOrCoordinatorIdentifier <string> - the identifier of the contributor or coordinator (only when finalizing).
|
|
523
539
|
* @param isFinalizing <boolean> - flag to discriminate between ceremony finalization (true) and contribution (false).
|
|
540
|
+
* @param circuitsLength <number> - the total number of circuits in the ceremony.
|
|
524
541
|
*/
|
|
525
542
|
export const handleStartOrResumeContribution = async (
|
|
526
543
|
cloudFunctions: Functions,
|
|
@@ -530,7 +547,8 @@ export const handleStartOrResumeContribution = async (
|
|
|
530
547
|
participant: FirebaseDocumentInfo,
|
|
531
548
|
entropyOrBeaconHash: any,
|
|
532
549
|
contributorOrCoordinatorIdentifier: string,
|
|
533
|
-
isFinalizing: boolean
|
|
550
|
+
isFinalizing: boolean,
|
|
551
|
+
circuitsLength: number
|
|
534
552
|
): Promise<void> => {
|
|
535
553
|
// Extract data.
|
|
536
554
|
const { prefix: ceremonyPrefix } = ceremony.data
|
|
@@ -538,7 +556,9 @@ export const handleStartOrResumeContribution = async (
|
|
|
538
556
|
const { completedContributions } = waitingQueue // = current progress.
|
|
539
557
|
|
|
540
558
|
console.log(
|
|
541
|
-
`${theme.text.bold(
|
|
559
|
+
`${theme.text.bold(
|
|
560
|
+
`\n- Circuit # ${theme.colors.magenta(`${sequencePosition}/${circuitsLength}`)}`
|
|
561
|
+
)} (Contribution Steps)`
|
|
542
562
|
)
|
|
543
563
|
|
|
544
564
|
// Get most up-to-date data from the participant document.
|
|
@@ -607,6 +627,8 @@ export const handleStartOrResumeContribution = async (
|
|
|
607
627
|
`${theme.symbols.success} Contribution ${theme.text.bold(`#${lastZkeyIndex}`)} correctly downloaded`
|
|
608
628
|
)
|
|
609
629
|
|
|
630
|
+
await sleep(3000)
|
|
631
|
+
|
|
610
632
|
// Advance to next contribution step (COMPUTING) if not finalizing.
|
|
611
633
|
if (!isFinalizing) {
|
|
612
634
|
spinner.text = `Preparing for contribution computation...`
|
|
@@ -650,6 +672,8 @@ export const handleStartOrResumeContribution = async (
|
|
|
650
672
|
// Format contribution hash.
|
|
651
673
|
const contributionHash = matchContributionHash?.at(0)?.replace("\n\t\t", "")!
|
|
652
674
|
|
|
675
|
+
await sleep(500)
|
|
676
|
+
|
|
653
677
|
// Make request to cloud functions to permanently store the information.
|
|
654
678
|
await permanentlyStoreCurrentContributionTimeAndHash(
|
|
655
679
|
cloudFunctions,
|
|
@@ -675,6 +699,9 @@ export const handleStartOrResumeContribution = async (
|
|
|
675
699
|
)}`
|
|
676
700
|
)
|
|
677
701
|
|
|
702
|
+
// ensure the previous step is completed
|
|
703
|
+
await sleep(5000)
|
|
704
|
+
|
|
678
705
|
// Advance to next contribution step (UPLOADING) if not finalizing.
|
|
679
706
|
if (!isFinalizing) {
|
|
680
707
|
spinner.text = `Preparing for uploading the contribution...`
|
|
@@ -696,10 +723,12 @@ export const handleStartOrResumeContribution = async (
|
|
|
696
723
|
!isFinalizing ? theme.text.bold(`#${nextZkeyIndex}`) : ""
|
|
697
724
|
} to storage.\n${
|
|
698
725
|
theme.symbols.warning
|
|
699
|
-
} This step may take a while based on circuit size and your
|
|
726
|
+
} This step may take a while based on circuit size and your internet speed. Everything's fine, just be patient.`
|
|
700
727
|
spinner.start()
|
|
701
728
|
|
|
702
|
-
|
|
729
|
+
const progressBar = customProgressBar(ProgressBarType.UPLOAD, `your contribution`)
|
|
730
|
+
|
|
731
|
+
if (!isFinalizing) {
|
|
703
732
|
await multiPartUpload(
|
|
704
733
|
cloudFunctions,
|
|
705
734
|
bucketName,
|
|
@@ -707,9 +736,12 @@ export const handleStartOrResumeContribution = async (
|
|
|
707
736
|
nextZkeyLocalFilePath,
|
|
708
737
|
Number(process.env.CONFIG_STREAM_CHUNK_SIZE_IN_MB),
|
|
709
738
|
ceremony.id,
|
|
710
|
-
participantData.tempContributionData
|
|
739
|
+
participantData.tempContributionData,
|
|
740
|
+
progressBar
|
|
711
741
|
)
|
|
712
|
-
|
|
742
|
+
|
|
743
|
+
progressBar.stop()
|
|
744
|
+
} else
|
|
713
745
|
await multiPartUpload(
|
|
714
746
|
cloudFunctions,
|
|
715
747
|
bucketName,
|
|
@@ -718,6 +750,9 @@ export const handleStartOrResumeContribution = async (
|
|
|
718
750
|
Number(process.env.CONFIG_STREAM_CHUNK_SIZE_IN_MB)
|
|
719
751
|
)
|
|
720
752
|
|
|
753
|
+
// small sleep to ensure the previous step is completed
|
|
754
|
+
await sleep(5000)
|
|
755
|
+
|
|
721
756
|
spinner.succeed(
|
|
722
757
|
`${
|
|
723
758
|
isFinalizing ? `Contribution` : `Contribution ${theme.text.bold(`#${nextZkeyIndex}`)}`
|
package/src/types/index.ts
CHANGED
|
@@ -68,3 +68,78 @@ export type GithubGistFile = {
|
|
|
68
68
|
raw_url: string
|
|
69
69
|
size: number
|
|
70
70
|
}
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* Define the return object of the function that verifies the Bandada membership and proof.
|
|
74
|
+
* @typedef {Object} VerifiedBandadaResponse
|
|
75
|
+
* @property {boolean} valid - true if the proof is valid and the user is a member of the group; otherwise false.
|
|
76
|
+
* @property {string} message - a message describing the result of the verification.
|
|
77
|
+
* @property {string} token - the custom access token.
|
|
78
|
+
*/
|
|
79
|
+
export type VerifiedBandadaResponse = {
|
|
80
|
+
valid: boolean
|
|
81
|
+
message: string
|
|
82
|
+
token: string
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* Define the return object of the device code uri request.
|
|
87
|
+
* @typedef {Object} OAuthDeviceCodeResponse
|
|
88
|
+
* @property {string} device_code - the device code.
|
|
89
|
+
* @property {string} user_code - the user code.
|
|
90
|
+
* @property {string} verification_uri - the verification uri.
|
|
91
|
+
* @property {number} expires_in - the expiration time in seconds.
|
|
92
|
+
* @property {number} interval - the interval time in seconds.
|
|
93
|
+
* @property {string} verification_uri_complete - the complete verification uri.
|
|
94
|
+
* @property {string} error - in case there was an error, show the code
|
|
95
|
+
* @property {string} error_description - error details.
|
|
96
|
+
* @property {string} error_uri - error uri.
|
|
97
|
+
*/
|
|
98
|
+
export type OAuthDeviceCodeResponse = {
|
|
99
|
+
device_code: string
|
|
100
|
+
user_code: string
|
|
101
|
+
verification_uri: string
|
|
102
|
+
expires_in: number
|
|
103
|
+
interval: number
|
|
104
|
+
verification_uri_complete: string
|
|
105
|
+
// error response should contain
|
|
106
|
+
error?: string
|
|
107
|
+
error_description?: string
|
|
108
|
+
error_uri?: string
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
/**
|
|
112
|
+
* Define the return object of the polling endpoint
|
|
113
|
+
* @typedef {Object} OAuthTokenResponse
|
|
114
|
+
* @property {string} access_token - the resulting device flow token
|
|
115
|
+
* @property {string} token_type - token type
|
|
116
|
+
* @property {number} expires_in - when does the token expires
|
|
117
|
+
* @property {string} scope - the scope requested by the initial device flow endpoint
|
|
118
|
+
* @property {string} refresh_token - refresh token
|
|
119
|
+
* @property {string} id_token - id token
|
|
120
|
+
* @property {string} error - in case there was an error, show the code
|
|
121
|
+
* @property {string} error_description - error details
|
|
122
|
+
*/
|
|
123
|
+
export type OAuthTokenResponse = {
|
|
124
|
+
access_token: string
|
|
125
|
+
token_type: string
|
|
126
|
+
expires_in: number
|
|
127
|
+
scope: string
|
|
128
|
+
refresh_token: string
|
|
129
|
+
id_token: string
|
|
130
|
+
// error response should contain
|
|
131
|
+
error?: string
|
|
132
|
+
error_description?: string
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
/**
|
|
136
|
+
* @typedef {Object} CheckNonceOfSIWEAddressResponse
|
|
137
|
+
* @property {boolean} valid - if the checking was valid or not
|
|
138
|
+
* @property {string} message - more information about the validity
|
|
139
|
+
* @property {string} token - token to sign into Firebase
|
|
140
|
+
*/
|
|
141
|
+
export type CheckNonceOfSIWEAddressResponse = {
|
|
142
|
+
valid: boolean
|
|
143
|
+
message: string
|
|
144
|
+
token: string
|
|
145
|
+
}
|