@devtion/actions 0.0.0-8bb9489 → 0.0.0-9239207

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 (34) hide show
  1. package/dist/index.mjs +322 -262
  2. package/dist/index.node.js +323 -261
  3. package/dist/types/src/helpers/constants.d.ts +5 -2
  4. package/dist/types/src/helpers/constants.d.ts.map +1 -1
  5. package/dist/types/src/helpers/contracts.d.ts.map +1 -1
  6. package/dist/types/src/helpers/crypto.d.ts +1 -0
  7. package/dist/types/src/helpers/crypto.d.ts.map +1 -1
  8. package/dist/types/src/helpers/database.d.ts +8 -0
  9. package/dist/types/src/helpers/database.d.ts.map +1 -1
  10. package/dist/types/src/helpers/security.d.ts +1 -1
  11. package/dist/types/src/helpers/security.d.ts.map +1 -1
  12. package/dist/types/src/helpers/storage.d.ts +1 -1
  13. package/dist/types/src/helpers/storage.d.ts.map +1 -1
  14. package/dist/types/src/helpers/utils.d.ts +34 -20
  15. package/dist/types/src/helpers/utils.d.ts.map +1 -1
  16. package/dist/types/src/helpers/verification.d.ts +3 -2
  17. package/dist/types/src/helpers/verification.d.ts.map +1 -1
  18. package/dist/types/src/helpers/vm.d.ts.map +1 -1
  19. package/dist/types/src/index.d.ts +2 -2
  20. package/dist/types/src/index.d.ts.map +1 -1
  21. package/dist/types/src/types/index.d.ts +9 -3
  22. package/dist/types/src/types/index.d.ts.map +1 -1
  23. package/package.json +3 -4
  24. package/src/helpers/constants.ts +40 -32
  25. package/src/helpers/contracts.ts +3 -3
  26. package/src/helpers/database.ts +13 -0
  27. package/src/helpers/security.ts +8 -5
  28. package/src/helpers/services.ts +2 -2
  29. package/src/helpers/storage.ts +3 -3
  30. package/src/helpers/utils.ts +299 -254
  31. package/src/helpers/verification.ts +6 -6
  32. package/src/helpers/vm.ts +9 -4
  33. package/src/index.ts +3 -1
  34. package/src/types/index.ts +23 -3
@@ -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
+ }
@@ -20,7 +20,8 @@ const getGitHubStats = async (user: string): Promise<any> => {
20
20
  following: jsonData.following,
21
21
  followers: jsonData.followers,
22
22
  publicRepos: jsonData.public_repos,
23
- avatarUrl: jsonData.avatar_url
23
+ avatarUrl: jsonData.avatar_url,
24
+ age: jsonData.created_at
24
25
  }
25
26
 
26
27
  return data
@@ -38,19 +39,21 @@ export const githubReputation = async (
38
39
  userLogin: string,
39
40
  minimumAmountOfFollowing: number,
40
41
  minimumAmountOfFollowers: number,
41
- minimumAmountOfPublicRepos: number
42
+ minimumAmountOfPublicRepos: number,
43
+ minimumAge: number
42
44
  ): Promise<any> => {
43
45
  if (!process.env.GITHUB_ACCESS_TOKEN)
44
46
  throw new Error(
45
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."
46
48
  )
47
49
 
48
- const { following, followers, publicRepos, avatarUrl } = await getGitHubStats(userLogin)
50
+ const { following, followers, publicRepos, avatarUrl, age } = await getGitHubStats(userLogin)
49
51
 
50
52
  if (
51
53
  following < minimumAmountOfFollowing ||
52
54
  publicRepos < minimumAmountOfPublicRepos ||
53
- followers < minimumAmountOfFollowers
55
+ followers < minimumAmountOfFollowers ||
56
+ new Date(age) > new Date(Date.now() - minimumAge)
54
57
  )
55
58
  return {
56
59
  reputable: false,
@@ -59,6 +62,6 @@ export const githubReputation = async (
59
62
 
60
63
  return {
61
64
  reputable: true,
62
- avatarUrl: avatarUrl
65
+ avatarUrl
63
66
  }
64
67
  }
@@ -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 {
@@ -13,7 +14,6 @@ import {
13
14
  temporaryStoreCurrentContributionMultiPartUploadId,
14
15
  temporaryStoreCurrentContributionUploadedChunkData
15
16
  } from "./functions"
16
- import { GenericBar } from "cli-progress"
17
17
 
18
18
  /**
19
19
  * Return the bucket name based on ceremony prefix.
@@ -169,7 +169,7 @@ export const multiPartUpload = async (
169
169
  configStreamChunkSize: number,
170
170
  ceremonyId?: string,
171
171
  temporaryDataToResumeMultiPartUpload?: TemporaryParticipantContributionData,
172
- logger?: GenericBar
172
+ logger?: GenericBar
173
173
  ) => {
174
174
  // The unique identifier of the multi-part upload.
175
175
  let multiPartUploadId: string = ""
@@ -210,7 +210,7 @@ export const multiPartUpload = async (
210
210
  cloudFunctions,
211
211
  ceremonyId,
212
212
  alreadyUploadedChunks,
213
- logger
213
+ logger
214
214
  )
215
215
 
216
216
  // Step (3).