@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.
- package/dist/index.mjs +322 -262
- package/dist/index.node.js +323 -261
- package/dist/types/src/helpers/constants.d.ts +5 -2
- package/dist/types/src/helpers/constants.d.ts.map +1 -1
- package/dist/types/src/helpers/contracts.d.ts.map +1 -1
- package/dist/types/src/helpers/crypto.d.ts +1 -0
- package/dist/types/src/helpers/crypto.d.ts.map +1 -1
- package/dist/types/src/helpers/database.d.ts +8 -0
- package/dist/types/src/helpers/database.d.ts.map +1 -1
- package/dist/types/src/helpers/security.d.ts +1 -1
- package/dist/types/src/helpers/security.d.ts.map +1 -1
- package/dist/types/src/helpers/storage.d.ts +1 -1
- package/dist/types/src/helpers/storage.d.ts.map +1 -1
- package/dist/types/src/helpers/utils.d.ts +34 -20
- package/dist/types/src/helpers/utils.d.ts.map +1 -1
- package/dist/types/src/helpers/verification.d.ts +3 -2
- package/dist/types/src/helpers/verification.d.ts.map +1 -1
- package/dist/types/src/helpers/vm.d.ts.map +1 -1
- package/dist/types/src/index.d.ts +2 -2
- package/dist/types/src/index.d.ts.map +1 -1
- package/dist/types/src/types/index.d.ts +9 -3
- package/dist/types/src/types/index.d.ts.map +1 -1
- package/package.json +3 -4
- package/src/helpers/constants.ts +40 -32
- package/src/helpers/contracts.ts +3 -3
- package/src/helpers/database.ts +13 -0
- package/src/helpers/security.ts +8 -5
- package/src/helpers/services.ts +2 -2
- package/src/helpers/storage.ts +3 -3
- package/src/helpers/utils.ts +299 -254
- package/src/helpers/verification.ts +6 -6
- package/src/helpers/vm.ts +9 -4
- package/src/index.ts +3 -1
- package/src/types/index.ts +23 -3
package/src/helpers/database.ts
CHANGED
|
@@ -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
|
+
}
|
package/src/helpers/security.ts
CHANGED
|
@@ -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
|
|
65
|
+
avatarUrl
|
|
63
66
|
}
|
|
64
67
|
}
|
package/src/helpers/services.ts
CHANGED
|
@@ -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.
|
|
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
|
-
|
|
47
|
+
instanceProfileArn: process.env.AWS_INSTANCE_PROFILE_ARN!,
|
|
48
48
|
amiId: process.env.AWS_AMI_ID!
|
|
49
49
|
}
|
|
50
50
|
}
|
package/src/helpers/storage.ts
CHANGED
|
@@ -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).
|