@devtion/actions 0.0.0-5d170d3 → 0.0.0-5fad82d

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 (36) hide show
  1. package/README.md +1 -1
  2. package/dist/index.mjs +368 -329
  3. package/dist/index.node.js +369 -328
  4. package/dist/types/src/helpers/constants.d.ts +11 -2
  5. package/dist/types/src/helpers/constants.d.ts.map +1 -1
  6. package/dist/types/src/helpers/contracts.d.ts.map +1 -1
  7. package/dist/types/src/helpers/crypto.d.ts +1 -0
  8. package/dist/types/src/helpers/crypto.d.ts.map +1 -1
  9. package/dist/types/src/helpers/database.d.ts +8 -0
  10. package/dist/types/src/helpers/database.d.ts.map +1 -1
  11. package/dist/types/src/helpers/security.d.ts +2 -2
  12. package/dist/types/src/helpers/security.d.ts.map +1 -1
  13. package/dist/types/src/helpers/storage.d.ts +5 -2
  14. package/dist/types/src/helpers/storage.d.ts.map +1 -1
  15. package/dist/types/src/helpers/utils.d.ts +34 -20
  16. package/dist/types/src/helpers/utils.d.ts.map +1 -1
  17. package/dist/types/src/helpers/verification.d.ts +3 -2
  18. package/dist/types/src/helpers/verification.d.ts.map +1 -1
  19. package/dist/types/src/helpers/vm.d.ts.map +1 -1
  20. package/dist/types/src/index.d.ts +2 -2
  21. package/dist/types/src/index.d.ts.map +1 -1
  22. package/dist/types/src/types/index.d.ts +9 -3
  23. package/dist/types/src/types/index.d.ts.map +1 -1
  24. package/package.json +3 -8
  25. package/src/helpers/constants.ts +45 -31
  26. package/src/helpers/contracts.ts +3 -3
  27. package/src/helpers/database.ts +13 -0
  28. package/src/helpers/functions.ts +1 -1
  29. package/src/helpers/security.ts +33 -52
  30. package/src/helpers/services.ts +3 -3
  31. package/src/helpers/storage.ts +15 -3
  32. package/src/helpers/utils.ts +316 -277
  33. package/src/helpers/verification.ts +6 -6
  34. package/src/helpers/vm.ts +14 -7
  35. package/src/index.ts +5 -3
  36. package/src/types/index.ts +32 -8
@@ -1,7 +1,7 @@
1
- // Main part for the Hermez Phase 1 Trusted Setup URLs to download PoT files.
2
- export const potFileDownloadMainUrl = `https://hermez.s3-eu-west-1.amazonaws.com/`
3
- // Main part for the Hermez Phase 1 Trusted Setup PoT files to be downloaded.
4
- export const potFilenameTemplate = `powersOfTau28_hez_final_`
1
+ // Main part for the PPoT Phase 1 Trusted Setup URLs to download PoT files.
2
+ export const potFileDownloadMainUrl = `https://pse-trusted-setup-ppot.s3.eu-central-1.amazonaws.com/pot28_0080/`
3
+ // Main part for the PPoT Phase 1 Trusted Setup PoT files to be downloaded.
4
+ export const potFilenameTemplate = `ppot_0080_`
5
5
  // The genesis zKey index.
6
6
  export const genesisZkeyIndex = `00000`
7
7
  // The number of exponential iterations to be executed by SnarkJS when finalizing the ceremony.
@@ -18,6 +18,8 @@ export const verifierSmartContractAcronym = "verifier"
18
18
  export const ec2InstanceTag = "p0tionec2instance"
19
19
  // The name of the VM startup script file.
20
20
  export const vmBootstrapScriptFilename = "bootstrap.sh"
21
+ // Match hash output by snarkjs in transcript log
22
+ export const contribHashRegex = new RegExp("Contribution.+Hash.+\n\t\t.+\n\t\t.+\n.+\n\t\t.+\r?\n")
21
23
 
22
24
  /**
23
25
  * Define the supported VM configuration types.
@@ -77,112 +79,116 @@ export const vmConfigurationTypes = {
77
79
  */
78
80
  export const powersOfTauFiles = [
79
81
  {
80
- ref: "https://hermez.s3-eu-west-1.amazonaws.com/powersOfTau28_hez_final_01.ptau",
82
+ ref: "https://pse-trusted-setup-ppot.s3.eu-central-1.amazonaws.com/pot28_0080/ppot_0080_01.ptau",
81
83
  size: 0.000084
82
84
  },
83
85
  {
84
- ref: "https://hermez.s3-eu-west-1.amazonaws.com/powersOfTau28_hez_final_02.ptau",
86
+ ref: "https://pse-trusted-setup-ppot.s3.eu-central-1.amazonaws.com/pot28_0080/ppot_0080_02.ptau",
85
87
  size: 0.000086
86
88
  },
87
89
  {
88
- ref: "https://hermez.s3-eu-west-1.amazonaws.com/powersOfTau28_hez_final_03.ptau",
90
+ ref: "https://pse-trusted-setup-ppot.s3.eu-central-1.amazonaws.com/pot28_0080/ppot_0080_03.ptau",
89
91
  size: 0.000091
90
92
  },
91
93
  {
92
- ref: "https://hermez.s3-eu-west-1.amazonaws.com/powersOfTau28_hez_final_04.ptau",
94
+ ref: "https://pse-trusted-setup-ppot.s3.eu-central-1.amazonaws.com/pot28_0080/ppot_0080_04.ptau",
93
95
  size: 0.0001
94
96
  },
95
97
  {
96
- ref: "https://hermez.s3-eu-west-1.amazonaws.com/powersOfTau28_hez_final_05.ptau",
98
+ ref: "https://pse-trusted-setup-ppot.s3.eu-central-1.amazonaws.com/pot28_0080/ppot_0080_05.ptau",
97
99
  size: 0.000117
98
100
  },
99
101
  {
100
- ref: "https://hermez.s3-eu-west-1.amazonaws.com/powersOfTau28_hez_final_06.ptau",
102
+ ref: "https://pse-trusted-setup-ppot.s3.eu-central-1.amazonaws.com/pot28_0080/ppot_0080_06.ptau",
101
103
  size: 0.000153
102
104
  },
103
105
  {
104
- ref: "https://hermez.s3-eu-west-1.amazonaws.com/powersOfTau28_hez_final_07.ptau",
106
+ ref: "https://pse-trusted-setup-ppot.s3.eu-central-1.amazonaws.com/pot28_0080/ppot_0080_07.ptau",
105
107
  size: 0.000225
106
108
  },
107
109
  {
108
- ref: "https://hermez.s3-eu-west-1.amazonaws.com/powersOfTau28_hez_final_08.ptau",
110
+ ref: "https://pse-trusted-setup-ppot.s3.eu-central-1.amazonaws.com/pot28_0080/ppot_0080_08.ptau",
109
111
  size: 0.0004
110
112
  },
111
113
  {
112
- ref: "https://hermez.s3-eu-west-1.amazonaws.com/powersOfTau28_hez_final_09.ptau",
114
+ ref: "https://pse-trusted-setup-ppot.s3.eu-central-1.amazonaws.com/pot28_0080/ppot_0080_09.ptau",
113
115
  size: 0.000658
114
116
  },
115
117
  {
116
- ref: "https://hermez.s3-eu-west-1.amazonaws.com/powersOfTau28_hez_final_10.ptau",
118
+ ref: "https://pse-trusted-setup-ppot.s3.eu-central-1.amazonaws.com/pot28_0080/ppot_0080_10.ptau",
117
119
  size: 0.0013
118
120
  },
119
121
  {
120
- ref: "https://hermez.s3-eu-west-1.amazonaws.com/powersOfTau28_hez_final_11.ptau",
122
+ ref: "https://pse-trusted-setup-ppot.s3.eu-central-1.amazonaws.com/pot28_0080/ppot_0080_11.ptau",
121
123
  size: 0.0023
122
124
  },
123
125
  {
124
- ref: "https://hermez.s3-eu-west-1.amazonaws.com/powersOfTau28_hez_final_12.ptau",
126
+ ref: "https://pse-trusted-setup-ppot.s3.eu-central-1.amazonaws.com/pot28_0080/ppot_0080_12.ptau",
125
127
  size: 0.0046
126
128
  },
127
129
  {
128
- ref: "https://hermez.s3-eu-west-1.amazonaws.com/powersOfTau28_hez_final_13.ptau",
130
+ ref: "https://pse-trusted-setup-ppot.s3.eu-central-1.amazonaws.com/pot28_0080/ppot_0080_13.ptau",
129
131
  size: 0.0091
130
132
  },
131
133
  {
132
- ref: "https://hermez.s3-eu-west-1.amazonaws.com/powersOfTau28_hez_final_14.ptau",
134
+ ref: "https://pse-trusted-setup-ppot.s3.eu-central-1.amazonaws.com/pot28_0080/ppot_0080_14.ptau",
133
135
  size: 0.0181
134
136
  },
135
137
  {
136
- ref: "https://hermez.s3-eu-west-1.amazonaws.com/powersOfTau28_hez_final_15.ptau",
138
+ ref: "https://pse-trusted-setup-ppot.s3.eu-central-1.amazonaws.com/pot28_0080/ppot_0080_15.ptau",
137
139
  size: 0.0361
138
140
  },
139
141
  {
140
- ref: "https://hermez.s3-eu-west-1.amazonaws.com/powersOfTau28_hez_final_16.ptau",
142
+ ref: "https://pse-trusted-setup-ppot.s3.eu-central-1.amazonaws.com/pot28_0080/ppot_0080_16.ptau",
141
143
  size: 0.0721
142
144
  },
143
145
  {
144
- ref: "https://hermez.s3-eu-west-1.amazonaws.com/powersOfTau28_hez_final_17.ptau",
146
+ ref: "https://pse-trusted-setup-ppot.s3.eu-central-1.amazonaws.com/pot28_0080/ppot_0080_17.ptau",
145
147
  size: 0.144
146
148
  },
147
149
  {
148
- ref: "https://hermez.s3-eu-west-1.amazonaws.com/powersOfTau28_hez_final_18.ptau",
150
+ ref: "https://pse-trusted-setup-ppot.s3.eu-central-1.amazonaws.com/pot28_0080/ppot_0080_18.ptau",
149
151
  size: 0.288
150
152
  },
151
153
  {
152
- ref: "https://hermez.s3-eu-west-1.amazonaws.com/powersOfTau28_hez_final_19.ptau",
154
+ ref: "https://pse-trusted-setup-ppot.s3.eu-central-1.amazonaws.com/pot28_0080/ppot_0080_19.ptau",
153
155
  size: 0.576
154
156
  },
155
157
  {
156
- ref: "https://hermez.s3-eu-west-1.amazonaws.com/powersOfTau28_hez_final_20.ptau",
158
+ ref: "https://pse-trusted-setup-ppot.s3.eu-central-1.amazonaws.com/pot28_0080/ppot_0080_20.ptau",
157
159
  size: 1.1
158
160
  },
159
161
  {
160
- ref: "https://hermez.s3-eu-west-1.amazonaws.com/powersOfTau28_hez_final_21.ptau",
162
+ ref: "https://pse-trusted-setup-ppot.s3.eu-central-1.amazonaws.com/pot28_0080/ppot_0080_21.ptau",
161
163
  size: 2.3
162
164
  },
163
165
  {
164
- ref: "https://hermez.s3-eu-west-1.amazonaws.com/powersOfTau28_hez_final_22.ptau",
166
+ ref: "https://pse-trusted-setup-ppot.s3.eu-central-1.amazonaws.com/pot28_0080/ppot_0080_22.ptau",
165
167
  size: 4.5
166
168
  },
167
169
  {
168
- ref: "https://hermez.s3-eu-west-1.amazonaws.com/powersOfTau28_hez_final_23.ptau",
170
+ ref: "https://pse-trusted-setup-ppot.s3.eu-central-1.amazonaws.com/pot28_0080/ppot_0080_23.ptau",
169
171
  size: 9.0
170
172
  },
171
173
  {
172
- ref: "https://hermez.s3-eu-west-1.amazonaws.com/powersOfTau28_hez_final_24.ptau",
174
+ ref: "https://pse-trusted-setup-ppot.s3.eu-central-1.amazonaws.com/pot28_0080/ppot_0080_24.ptau",
173
175
  size: 18.0
174
176
  },
175
177
  {
176
- ref: "https://hermez.s3-eu-west-1.amazonaws.com/powersOfTau28_hez_final_25.ptau",
178
+ ref: "https://pse-trusted-setup-ppot.s3.eu-central-1.amazonaws.com/pot28_0080/ppot_0080_25.ptau",
177
179
  size: 36.0
178
180
  },
179
181
  {
180
- ref: "https://hermez.s3-eu-west-1.amazonaws.com/powersOfTau28_hez_final_26.ptau",
182
+ ref: "https://pse-trusted-setup-ppot.s3.eu-central-1.amazonaws.com/pot28_0080/ppot_0080_26.ptau",
181
183
  size: 72.0
182
184
  },
183
185
  {
184
- ref: "https://hermez.s3-eu-west-1.amazonaws.com/powersOfTau28_hez_final_27.ptau",
186
+ ref: "https://pse-trusted-setup-ppot.s3.eu-central-1.amazonaws.com/pot28_0080/ppot_0080_27.ptau",
185
187
  size: 144.0
188
+ },
189
+ {
190
+ ref: "https://pse-trusted-setup-ppot.s3.eu-central-1.amazonaws.com/pot28_0080/ppot_0080_final.ptau",
191
+ size: 288.0
186
192
  }
187
193
  ]
188
194
 
@@ -217,6 +223,12 @@ export const commonTerms = {
217
223
  verificationStartedAt: "verificationStartedAt"
218
224
  }
219
225
  },
226
+ avatars: {
227
+ name: "avatars",
228
+ fields: {
229
+ avatarUrl: "avatarUrl"
230
+ }
231
+ },
220
232
  ceremonies: {
221
233
  name: "ceremonies",
222
234
  fields: {
@@ -308,5 +320,7 @@ export const commonTerms = {
308
320
  finalizeCeremony: "finalizeCeremony",
309
321
  downloadCircuitArtifacts: "downloadCircuitArtifacts",
310
322
  transferObject: "transferObject",
323
+ bandadaValidateProof: "bandadaValidateProof",
324
+ checkNonceOfSIWEAddress: "checkNonceOfSIWEAddress"
311
325
  }
312
326
  }
@@ -1,5 +1,4 @@
1
1
  import { Contract, ContractFactory, Signer } from "ethers"
2
- import { utils as ffUtils } from "ffjavascript"
3
2
  import { Firestore, where } from "firebase/firestore"
4
3
  import { Functions } from "firebase/functions"
5
4
  import fs from "fs"
@@ -16,6 +15,7 @@ import {
16
15
  import { compareHashes } from "./crypto"
17
16
  import { commonTerms, finalContributionIndex, verificationKeyAcronym, verifierSmartContractAcronym } from "./constants"
18
17
  import { fromQueryToFirebaseDocumentInfo, queryCollection } from "./database"
18
+ import { unstringifyBigInts } from "./utils"
19
19
 
20
20
  /**
21
21
  * Formats part of a GROTH16 SNARK proof
@@ -41,11 +41,11 @@ export const p256 = (proofPart: any) => {
41
41
  */
42
42
  export const formatSolidityCalldata = (circuitInput: string[], _proof: any): any => {
43
43
  try {
44
- const proof = ffUtils.unstringifyBigInts(_proof)
44
+ const proof = unstringifyBigInts(_proof) as any
45
45
  // format the public inputs to the circuit
46
46
  const formattedCircuitInput = []
47
47
  for (const cInput of circuitInput) {
48
- formattedCircuitInput.push(p256(ffUtils.unstringifyBigInts(cInput)))
48
+ formattedCircuitInput.push(p256(unstringifyBigInts(cInput)))
49
49
  }
50
50
  // construct calldata
51
51
  const calldata = {
@@ -219,3 +219,16 @@ export const getClosedCeremonies = async (firestoreDatabase: Firestore): Promise
219
219
 
220
220
  return fromQueryToFirebaseDocumentInfo(closedCeremoniesQuerySnap.docs)
221
221
  }
222
+
223
+ /**
224
+ * Query all ceremonies
225
+ * @notice get all ceremonies from the database.
226
+ * @dev this is a helper for the CLI ceremony methods.
227
+ * @param firestoreDatabase <Firestore> - the Firestore service instance associated to the current Firebase application.
228
+ * @returns <Promise<Array<FirebaseDocumentInfo>>> - the list of all ceremonies.
229
+ */
230
+ export const getAllCeremonies = async (firestoreDatabase: Firestore): Promise<Array<FirebaseDocumentInfo>> => {
231
+ const ceremoniesQuerySnap = await queryCollection(firestoreDatabase, commonTerms.collections.ceremonies.name, [])
232
+
233
+ return fromQueryToFirebaseDocumentInfo(ceremoniesQuerySnap.docs)
234
+ }
@@ -435,4 +435,4 @@ export const finalizeCeremony = async (functions: Functions, ceremonyId: string)
435
435
  await cf({
436
436
  ceremonyId
437
437
  })
438
- }
438
+ }
@@ -1,57 +1,30 @@
1
1
  import fetch from "@adobe/node-fetch-retry"
2
2
  /**
3
- * This function will return the number of public repos of a user
4
- * @param user <string> The username of the user
5
- * @returns <number> The number of public repos
3
+ * This function queries the GitHub API to fetch users statistics
4
+ * @param user {string} the user uid
5
+ * @returns {any} the stats from the GitHub API
6
6
  */
7
- const getNumberOfPublicReposGitHub = async (user: string): Promise<number> => {
8
- const response = await fetch(`https://api.github.com/user/${user}/repos`, {
7
+ const getGitHubStats = async (user: string): Promise<any> => {
8
+ const response = await fetch(`https://api.github.com/user/${user}`, {
9
9
  method: "GET",
10
10
  headers: {
11
11
  Authorization: `token ${process.env.GITHUB_ACCESS_TOKEN!}`
12
12
  }
13
13
  })
14
14
  if (response.status !== 200)
15
- throw new Error("It was not possible to retrieve the number of public repositories. Please try again.")
16
- const jsonData: any = await response.json()
17
- return jsonData.length
18
- }
19
- /**
20
- * This function will return the number of followers of a user
21
- * @param user <string> The username of the user
22
- * @returns <number> The number of followers
23
- */
24
- const getNumberOfFollowersGitHub = async (user: string): Promise<number> => {
25
- const response = await fetch(`https://api.github.com/user/${user}/followers`, {
26
- method: "GET",
27
- headers: {
28
- Authorization: `token ${process.env.GITHUB_ACCESS_TOKEN!}`
29
- }
30
- })
31
- if (response.status !== 200)
32
- throw new Error("It was not possible to retrieve the number of followers. Please try again.")
33
- const jsonData: any = await response.json()
34
- return jsonData.length
35
- }
36
- /**
37
- * This function will return the number of following of a user
38
- * @param user <string> The username of the user
39
- * @returns <number> The number of following users
40
- */
41
- const getNumberOfFollowingGitHub = async (user: string): Promise<number> => {
42
- const response = await fetch(`https://api.github.com/user/${user}/following`, {
43
- method: "GET",
44
- headers: {
45
- Authorization: `token ${process.env.GITHUB_ACCESS_TOKEN!}`
46
- }
47
- })
48
-
49
- if (response.status !== 200)
50
- throw new Error("It was not possible to retrieve the number of following. Please try again.")
15
+ throw new Error("It was not possible to retrieve the user's statistic. Please try again.")
51
16
 
52
17
  const jsonData: any = await response.json()
53
18
 
54
- return jsonData.length
19
+ const data = {
20
+ following: jsonData.following,
21
+ followers: jsonData.followers,
22
+ publicRepos: jsonData.public_repos,
23
+ avatarUrl: jsonData.avatar_url,
24
+ age: jsonData.created_at
25
+ }
26
+
27
+ return data
55
28
  }
56
29
 
57
30
  /**
@@ -60,27 +33,35 @@ const getNumberOfFollowingGitHub = async (user: string): Promise<number> => {
60
33
  * @param minimumAmountOfFollowing <number> The minimum amount of following the user should have
61
34
  * @param minimumAmountOfFollowers <number> The minimum amount of followers the user should have
62
35
  * @param minimumAmountOfPublicRepos <number> The minimum amount of public repos the user should have
63
- * @returns <boolean> True if the user is reputable enough, false otherwise
36
+ * @returns <any> Return the avatar URL of the user if the user is reputable, false otherwise
64
37
  */
65
38
  export const githubReputation = async (
66
39
  userLogin: string,
67
40
  minimumAmountOfFollowing: number,
68
41
  minimumAmountOfFollowers: number,
69
- minimumAmountOfPublicRepos: number
70
- ): Promise<boolean> => {
42
+ minimumAmountOfPublicRepos: number,
43
+ minimumAge: number
44
+ ): Promise<any> => {
71
45
  if (!process.env.GITHUB_ACCESS_TOKEN)
72
46
  throw new Error(
73
47
  "The GitHub access token is missing. Please insert a valid token to be used for anti-sybil checks on user registation, and then try again."
74
48
  )
75
- const following = await getNumberOfFollowingGitHub(userLogin)
76
- const repos = await getNumberOfPublicReposGitHub(userLogin)
77
- const followers = await getNumberOfFollowersGitHub(userLogin)
49
+
50
+ const { following, followers, publicRepos, avatarUrl, age } = await getGitHubStats(userLogin)
78
51
 
79
52
  if (
80
53
  following < minimumAmountOfFollowing ||
81
- repos < minimumAmountOfPublicRepos ||
82
- followers < minimumAmountOfFollowers
54
+ publicRepos < minimumAmountOfPublicRepos ||
55
+ followers < minimumAmountOfFollowers ||
56
+ new Date(age) > new Date(Date.now() - minimumAge)
83
57
  )
84
- return false
85
- return true
58
+ return {
59
+ reputable: false,
60
+ avatarUrl: ""
61
+ }
62
+
63
+ return {
64
+ reputable: true,
65
+ avatarUrl
66
+ }
86
67
  }
@@ -22,7 +22,7 @@ export const getFirestoreDatabase = (app: FirebaseApp): Firestore => getFirestor
22
22
  * @param app <FirebaseApp> - the Firebase application.
23
23
  * @returns <Functions> - the Cloud Functions associated to the application.
24
24
  */
25
- export const getFirebaseFunctions = (app: FirebaseApp): Functions => getFunctions(app, 'europe-west1')
25
+ export const getFirebaseFunctions = (app: FirebaseApp): Functions => getFunctions(app, "europe-west1")
26
26
 
27
27
  /**
28
28
  * Retrieve the configuration variables for the AWS services (S3, EC2).
@@ -33,7 +33,7 @@ export const getAWSVariables = (): AWSVariables => {
33
33
  !process.env.AWS_ACCESS_KEY_ID ||
34
34
  !process.env.AWS_SECRET_ACCESS_KEY ||
35
35
  !process.env.AWS_REGION ||
36
- !process.env.AWS_ROLE_ARN ||
36
+ !process.env.AWS_INSTANCE_PROFILE_ARN ||
37
37
  !process.env.AWS_AMI_ID
38
38
  )
39
39
  throw new Error(
@@ -44,7 +44,7 @@ export const getAWSVariables = (): AWSVariables => {
44
44
  accessKeyId: process.env.AWS_ACCESS_KEY_ID!,
45
45
  secretAccessKey: process.env.AWS_SECRET_ACCESS_KEY!,
46
46
  region: process.env.AWS_REGION || "us-east-1",
47
- roleArn: process.env.AWS_ROLE_ARN!,
47
+ instanceProfileArn: process.env.AWS_INSTANCE_PROFILE_ARN!,
48
48
  amiId: process.env.AWS_AMI_ID!
49
49
  }
50
50
  }
@@ -3,6 +3,7 @@ import mime from "mime-types"
3
3
  import fs, { createWriteStream } from "fs"
4
4
  import fetch from "@adobe/node-fetch-retry"
5
5
  import https from "https"
6
+ import { GenericBar } from "cli-progress"
6
7
  import { ETagWithPartNumber, ChunkWithUrl, TemporaryParticipantContributionData } from "../types/index"
7
8
  import { commonTerms } from "./constants"
8
9
  import {
@@ -80,6 +81,7 @@ export const getChunksAndPreSignedUrls = async (
80
81
  * @param cloudFunctions <Functions> - the Firebase Cloud Functions service instance.
81
82
  * @param ceremonyId <string> - the unique identifier of the ceremony.
82
83
  * @param alreadyUploadedChunks Array<ETagWithPartNumber> - the temporary information about the already uploaded chunks.
84
+ * @param logger <GenericBar> - an optional logger to show progress.
83
85
  * @returns <Promise<Array<ETagWithPartNumber>>> - the completed (uploaded) chunks information.
84
86
  */
85
87
  export const uploadParts = async (
@@ -87,11 +89,15 @@ export const uploadParts = async (
87
89
  contentType: string | false,
88
90
  cloudFunctions?: Functions,
89
91
  ceremonyId?: string,
90
- alreadyUploadedChunks?: Array<ETagWithPartNumber>
92
+ alreadyUploadedChunks?: Array<ETagWithPartNumber>,
93
+ logger?: GenericBar
91
94
  ): Promise<Array<ETagWithPartNumber>> => {
92
95
  // Keep track of uploaded chunks.
93
96
  const uploadedChunks: Array<ETagWithPartNumber> = alreadyUploadedChunks || []
94
97
 
98
+ // if we were passed a logger, start it
99
+ if (logger) logger.start(chunksWithUrls.length, 0)
100
+
95
101
  // Loop through remaining chunks.
96
102
  for (let i = alreadyUploadedChunks ? alreadyUploadedChunks.length : 0; i < chunksWithUrls.length; i += 1) {
97
103
  // Consume the pre-signed url to upload the chunk.
@@ -128,6 +134,9 @@ export const uploadParts = async (
128
134
  // nb. this must be done only when contributing (not finalizing).
129
135
  if (!!ceremonyId && !!cloudFunctions)
130
136
  await temporaryStoreCurrentContributionUploadedChunkData(cloudFunctions, ceremonyId, chunk)
137
+
138
+ // increment the count on the logger
139
+ if (logger) logger.increment()
131
140
  }
132
141
 
133
142
  return uploadedChunks
@@ -150,6 +159,7 @@ export const uploadParts = async (
150
159
  * @param configStreamChunkSize <number> - size of each chunk into which the artifact is going to be splitted (nb. will be converted in MB).
151
160
  * @param [ceremonyId] <string> - the unique identifier of the ceremony (used as a double-edge sword - as identifier and as a check if current contributor is the coordinator finalizing the ceremony).
152
161
  * @param [temporaryDataToResumeMultiPartUpload] <TemporaryParticipantContributionData> - the temporary information necessary to resume an already started multi-part upload.
162
+ * @param logger <GenericBar> - an optional logger to show progress.
153
163
  */
154
164
  export const multiPartUpload = async (
155
165
  cloudFunctions: Functions,
@@ -158,7 +168,8 @@ export const multiPartUpload = async (
158
168
  localFilePath: string,
159
169
  configStreamChunkSize: number,
160
170
  ceremonyId?: string,
161
- temporaryDataToResumeMultiPartUpload?: TemporaryParticipantContributionData
171
+ temporaryDataToResumeMultiPartUpload?: TemporaryParticipantContributionData,
172
+ logger?: GenericBar
162
173
  ) => {
163
174
  // The unique identifier of the multi-part upload.
164
175
  let multiPartUploadId: string = ""
@@ -198,7 +209,8 @@ export const multiPartUpload = async (
198
209
  mime.lookup(localFilePath), // content-type.
199
210
  cloudFunctions,
200
211
  ceremonyId,
201
- alreadyUploadedChunks
212
+ alreadyUploadedChunks,
213
+ logger
202
214
  )
203
215
 
204
216
  // Step (3).