@devtion/backend 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.
- package/README.md +28 -2
- package/dist/src/functions/index.js +432 -192
- package/dist/src/functions/index.mjs +432 -194
- package/dist/types/functions/bandada.d.ts +4 -0
- package/dist/types/functions/bandada.d.ts.map +1 -0
- package/dist/types/functions/ceremony.d.ts.map +1 -1
- package/dist/types/functions/circuit.d.ts.map +1 -1
- package/dist/types/functions/index.d.ts +2 -0
- package/dist/types/functions/index.d.ts.map +1 -1
- package/dist/types/functions/siwe.d.ts +4 -0
- package/dist/types/functions/siwe.d.ts.map +1 -0
- package/dist/types/functions/storage.d.ts.map +1 -1
- package/dist/types/functions/timeout.d.ts.map +1 -1
- package/dist/types/functions/user.d.ts.map +1 -1
- package/dist/types/lib/errors.d.ts +2 -1
- package/dist/types/lib/errors.d.ts.map +1 -1
- package/dist/types/lib/services.d.ts +7 -0
- package/dist/types/lib/services.d.ts.map +1 -1
- package/dist/types/lib/utils.d.ts +1 -1
- package/dist/types/lib/utils.d.ts.map +1 -1
- package/dist/types/types/index.d.ts +57 -1
- package/dist/types/types/index.d.ts.map +1 -1
- package/package.json +5 -4
- package/src/functions/bandada.ts +155 -0
- package/src/functions/ceremony.ts +13 -8
- package/src/functions/circuit.ts +140 -188
- package/src/functions/index.ts +2 -0
- package/src/functions/participant.ts +16 -16
- package/src/functions/siwe.ts +77 -0
- package/src/functions/storage.ts +12 -9
- package/src/functions/timeout.ts +9 -7
- package/src/functions/user.ts +37 -12
- package/src/lib/errors.ts +6 -1
- package/src/lib/services.ts +36 -0
- package/src/lib/utils.ts +11 -9
- package/src/types/declarations.d.ts +1 -0
- package/src/types/index.ts +61 -1
package/src/functions/storage.ts
CHANGED
|
@@ -20,7 +20,7 @@ import {
|
|
|
20
20
|
ParticipantContributionStep,
|
|
21
21
|
formatZkeyIndex,
|
|
22
22
|
getZkeyStorageFilePath
|
|
23
|
-
} from "@
|
|
23
|
+
} from "@devtion/actions"
|
|
24
24
|
import { getCeremonyCircuits, getDocumentById } from "../lib/utils"
|
|
25
25
|
import { COMMON_ERRORS, logAndThrowError, makeError, printLog, SPECIFIC_ERRORS } from "../lib/errors"
|
|
26
26
|
import { LogLevel } from "../types/enums"
|
|
@@ -134,7 +134,7 @@ const checkIfBucketIsDedicatedToCeremony = async (bucketName: string) => {
|
|
|
134
134
|
export const createBucket = functions
|
|
135
135
|
.region("europe-west1")
|
|
136
136
|
.runWith({
|
|
137
|
-
memory: "
|
|
137
|
+
memory: "1GB"
|
|
138
138
|
})
|
|
139
139
|
.https.onCall(async (data: CreateBucketData, context: functions.https.CallableContext) => {
|
|
140
140
|
// Check if the user has the coordinator claim.
|
|
@@ -193,8 +193,10 @@ export const createBucket = functions
|
|
|
193
193
|
CORSConfiguration: {
|
|
194
194
|
CORSRules: [
|
|
195
195
|
{
|
|
196
|
-
AllowedMethods: ["GET"],
|
|
197
|
-
AllowedOrigins: ["*"]
|
|
196
|
+
AllowedMethods: ["GET", "PUT"],
|
|
197
|
+
AllowedOrigins: ["*"],
|
|
198
|
+
ExposeHeaders: ["ETag", "Content-Length"],
|
|
199
|
+
AllowedHeaders: ["*"]
|
|
198
200
|
}
|
|
199
201
|
]
|
|
200
202
|
}
|
|
@@ -236,7 +238,7 @@ export const createBucket = functions
|
|
|
236
238
|
export const checkIfObjectExist = functions
|
|
237
239
|
.region("europe-west1")
|
|
238
240
|
.runWith({
|
|
239
|
-
memory: "
|
|
241
|
+
memory: "1GB"
|
|
240
242
|
})
|
|
241
243
|
.https.onCall(async (data: BucketAndObjectKeyData, context: functions.https.CallableContext): Promise<boolean> => {
|
|
242
244
|
// Check if the user has the coordinator claim.
|
|
@@ -292,7 +294,7 @@ export const checkIfObjectExist = functions
|
|
|
292
294
|
export const generateGetObjectPreSignedUrl = functions
|
|
293
295
|
.region("europe-west1")
|
|
294
296
|
.runWith({
|
|
295
|
-
memory: "
|
|
297
|
+
memory: "1GB"
|
|
296
298
|
})
|
|
297
299
|
.https.onCall(async (data: BucketAndObjectKeyData, context: functions.https.CallableContext): Promise<any> => {
|
|
298
300
|
if (!context.auth) logAndThrowError(COMMON_ERRORS.CM_NOT_AUTHENTICATED)
|
|
@@ -339,7 +341,7 @@ export const generateGetObjectPreSignedUrl = functions
|
|
|
339
341
|
export const startMultiPartUpload = functions
|
|
340
342
|
.region("europe-west1")
|
|
341
343
|
.runWith({
|
|
342
|
-
memory: "
|
|
344
|
+
memory: "2GB"
|
|
343
345
|
})
|
|
344
346
|
.https.onCall(async (data: StartMultiPartUploadData, context: functions.https.CallableContext): Promise<any> => {
|
|
345
347
|
if (!context.auth || (!context.auth.token.participant && !context.auth.token.coordinator))
|
|
@@ -407,7 +409,8 @@ export const startMultiPartUpload = functions
|
|
|
407
409
|
export const generatePreSignedUrlsParts = functions
|
|
408
410
|
.region("europe-west1")
|
|
409
411
|
.runWith({
|
|
410
|
-
memory: "
|
|
412
|
+
memory: "1GB",
|
|
413
|
+
timeoutSeconds: 300
|
|
411
414
|
})
|
|
412
415
|
.https.onCall(
|
|
413
416
|
async (
|
|
@@ -484,7 +487,7 @@ export const generatePreSignedUrlsParts = functions
|
|
|
484
487
|
export const completeMultiPartUpload = functions
|
|
485
488
|
.region("europe-west1")
|
|
486
489
|
.runWith({
|
|
487
|
-
memory: "
|
|
490
|
+
memory: "2GB"
|
|
488
491
|
})
|
|
489
492
|
.https.onCall(async (data: CompleteMultiPartUploadData, context: functions.https.CallableContext): Promise<any> => {
|
|
490
493
|
if (!context.auth || (!context.auth.token.participant && !context.auth.token.coordinator))
|
package/src/functions/timeout.ts
CHANGED
|
@@ -9,7 +9,7 @@ import {
|
|
|
9
9
|
ParticipantStatus,
|
|
10
10
|
getTimeoutsCollectionPath,
|
|
11
11
|
commonTerms
|
|
12
|
-
} from "@
|
|
12
|
+
} from "@devtion/actions"
|
|
13
13
|
import {
|
|
14
14
|
getCeremonyCircuits,
|
|
15
15
|
getCurrentServerTimestampInMillis,
|
|
@@ -42,7 +42,7 @@ dotenv.config()
|
|
|
42
42
|
export const checkAndRemoveBlockingContributor = functions
|
|
43
43
|
.region("europe-west1")
|
|
44
44
|
.runWith({
|
|
45
|
-
memory: "
|
|
45
|
+
memory: "1GB"
|
|
46
46
|
})
|
|
47
47
|
.pubsub.schedule("every 1 minutes")
|
|
48
48
|
.onRun(async () => {
|
|
@@ -64,7 +64,7 @@ export const checkAndRemoveBlockingContributor = functions
|
|
|
64
64
|
const circuits = await getCeremonyCircuits(ceremony.id)
|
|
65
65
|
|
|
66
66
|
// Extract ceremony data.
|
|
67
|
-
const { timeoutMechanismType, penalty } = ceremony.data()!
|
|
67
|
+
const { timeoutType: timeoutMechanismType, penalty } = ceremony.data()!
|
|
68
68
|
|
|
69
69
|
for (const circuit of circuits) {
|
|
70
70
|
if (!circuit.data())
|
|
@@ -144,7 +144,8 @@ export const checkAndRemoveBlockingContributor = functions
|
|
|
144
144
|
timeoutExpirationDateInMsForBlockingContributor < currentServerTimestamp &&
|
|
145
145
|
(contributionStep === ParticipantContributionStep.DOWNLOADING ||
|
|
146
146
|
contributionStep === ParticipantContributionStep.COMPUTING ||
|
|
147
|
-
contributionStep === ParticipantContributionStep.UPLOADING
|
|
147
|
+
contributionStep === ParticipantContributionStep.UPLOADING ||
|
|
148
|
+
contributionStep === ParticipantContributionStep.COMPLETED)
|
|
148
149
|
)
|
|
149
150
|
timeoutType = TimeoutType.BLOCKING_CONTRIBUTION
|
|
150
151
|
|
|
@@ -174,7 +175,7 @@ export const checkAndRemoveBlockingContributor = functions
|
|
|
174
175
|
const batch = firestore.batch()
|
|
175
176
|
|
|
176
177
|
// Remove current contributor from waiting queue.
|
|
177
|
-
contributors.shift(
|
|
178
|
+
contributors.shift()
|
|
178
179
|
|
|
179
180
|
// Check if someone else is ready to start the contribution.
|
|
180
181
|
if (contributors.length > 0) {
|
|
@@ -253,7 +254,7 @@ export const checkAndRemoveBlockingContributor = functions
|
|
|
253
254
|
export const resumeContributionAfterTimeoutExpiration = functions
|
|
254
255
|
.region("europe-west1")
|
|
255
256
|
.runWith({
|
|
256
|
-
memory: "
|
|
257
|
+
memory: "1GB"
|
|
257
258
|
})
|
|
258
259
|
.https.onCall(async (data: { ceremonyId: string }, context: functions.https.CallableContext): Promise<void> => {
|
|
259
260
|
if (!context.auth || (!context.auth.token.participant && !context.auth.token.coordinator))
|
|
@@ -281,7 +282,8 @@ export const resumeContributionAfterTimeoutExpiration = functions
|
|
|
281
282
|
if (status === ParticipantStatus.EXHUMED)
|
|
282
283
|
await participantDoc.ref.update({
|
|
283
284
|
status: ParticipantStatus.READY,
|
|
284
|
-
lastUpdated: getCurrentServerTimestampInMillis()
|
|
285
|
+
lastUpdated: getCurrentServerTimestampInMillis(),
|
|
286
|
+
tempContributionData: {}
|
|
285
287
|
})
|
|
286
288
|
else logAndThrowError(SPECIFIC_ERRORS.SE_CONTRIBUTE_CANNOT_PROGRESS_TO_NEXT_CIRCUIT)
|
|
287
289
|
|
package/src/functions/user.ts
CHANGED
|
@@ -2,7 +2,7 @@ import * as functions from "firebase-functions"
|
|
|
2
2
|
import { UserRecord } from "firebase-functions/v1/auth"
|
|
3
3
|
import admin from "firebase-admin"
|
|
4
4
|
import dotenv from "dotenv"
|
|
5
|
-
import { commonTerms, githubReputation } from "@
|
|
5
|
+
import { commonTerms, githubReputation } from "@devtion/actions"
|
|
6
6
|
import { encode } from "html-entities"
|
|
7
7
|
import { getGitHubVariables, getCurrentServerTimestampInMillis } from "../lib/utils"
|
|
8
8
|
import { logAndThrowError, makeError, printLog, SPECIFIC_ERRORS } from "../lib/errors"
|
|
@@ -18,7 +18,7 @@ dotenv.config()
|
|
|
18
18
|
export const registerAuthUser = functions
|
|
19
19
|
.region("europe-west1")
|
|
20
20
|
.runWith({
|
|
21
|
-
memory: "
|
|
21
|
+
memory: "1GB"
|
|
22
22
|
})
|
|
23
23
|
.auth.user()
|
|
24
24
|
.onCreate(async (user: UserRecord) => {
|
|
@@ -40,8 +40,12 @@ export const registerAuthUser = functions
|
|
|
40
40
|
const { uid } = user
|
|
41
41
|
// Reference to a document using uid.
|
|
42
42
|
const userRef = firestore.collection(commonTerms.collections.users.name).doc(uid)
|
|
43
|
-
// html encode the display name
|
|
44
|
-
const encodedDisplayName =
|
|
43
|
+
// html encode the display name (or put the ID if the name is not displayed)
|
|
44
|
+
const encodedDisplayName =
|
|
45
|
+
user.displayName === "Null" || user.displayName === null ? user.uid : encode(displayName)
|
|
46
|
+
|
|
47
|
+
// store the avatar URL of a contributor
|
|
48
|
+
let avatarUrl: string = ""
|
|
45
49
|
// we only do reputation check if the user is not a coordinator
|
|
46
50
|
if (
|
|
47
51
|
!(
|
|
@@ -51,18 +55,19 @@ export const registerAuthUser = functions
|
|
|
51
55
|
) {
|
|
52
56
|
const auth = admin.auth()
|
|
53
57
|
// if provider == github.com let's use our functions to check the user's reputation
|
|
54
|
-
if (user.providerData[0].providerId === "github.com") {
|
|
58
|
+
if (user.providerData.length > 0 && user.providerData[0].providerId === "github.com") {
|
|
55
59
|
const vars = getGitHubVariables()
|
|
56
60
|
|
|
57
61
|
// this return true or false
|
|
58
62
|
try {
|
|
59
|
-
const
|
|
63
|
+
const { reputable, avatarUrl: avatarURL } = await githubReputation(
|
|
60
64
|
user.providerData[0].uid,
|
|
61
65
|
vars.minimumFollowing,
|
|
62
66
|
vars.minimumFollowers,
|
|
63
|
-
vars.minimumPublicRepos
|
|
67
|
+
vars.minimumPublicRepos,
|
|
68
|
+
vars.minimumAge
|
|
64
69
|
)
|
|
65
|
-
if (!
|
|
70
|
+
if (!reputable) {
|
|
66
71
|
// Delete user
|
|
67
72
|
await auth.deleteUser(user.uid)
|
|
68
73
|
// Throw error
|
|
@@ -70,11 +75,22 @@ export const registerAuthUser = functions
|
|
|
70
75
|
makeError(
|
|
71
76
|
"permission-denied",
|
|
72
77
|
"The user is not allowed to sign up because their Github reputation is not high enough.",
|
|
73
|
-
`The user ${
|
|
78
|
+
`The user ${
|
|
79
|
+
user.displayName === "Null" || user.displayName === null
|
|
80
|
+
? user.uid
|
|
81
|
+
: user.displayName
|
|
82
|
+
} is not allowed to sign up because their Github reputation is not high enough. Please contact the administrator if you think this is a mistake.`
|
|
74
83
|
)
|
|
75
84
|
)
|
|
76
85
|
}
|
|
77
|
-
|
|
86
|
+
// store locally
|
|
87
|
+
avatarUrl = avatarURL
|
|
88
|
+
printLog(
|
|
89
|
+
`Github reputation check passed for user ${
|
|
90
|
+
user.displayName === "Null" || user.displayName === null ? user.uid : user.displayName
|
|
91
|
+
}`,
|
|
92
|
+
LogLevel.DEBUG
|
|
93
|
+
)
|
|
78
94
|
} catch (error: any) {
|
|
79
95
|
// Delete user
|
|
80
96
|
await auth.deleteUser(user.uid)
|
|
@@ -89,19 +105,28 @@ export const registerAuthUser = functions
|
|
|
89
105
|
}
|
|
90
106
|
}
|
|
91
107
|
// Set document (nb. we refer to providerData[0] because we use Github OAuth provider only).
|
|
108
|
+
// In future releases we might want to loop through the providerData array as we support
|
|
109
|
+
// more providers.
|
|
92
110
|
await userRef.set({
|
|
93
111
|
name: encodedDisplayName,
|
|
94
112
|
encodedDisplayName,
|
|
95
113
|
// Metadata.
|
|
96
114
|
creationTime,
|
|
97
|
-
lastSignInTime,
|
|
115
|
+
lastSignInTime: lastSignInTime || creationTime,
|
|
98
116
|
// Optional.
|
|
99
117
|
email: email || "",
|
|
100
118
|
emailVerified: emailVerified || false,
|
|
101
119
|
photoURL: photoURL || "",
|
|
102
120
|
lastUpdated: getCurrentServerTimestampInMillis()
|
|
103
121
|
})
|
|
122
|
+
|
|
123
|
+
// we want to create a new collection for the users to store the avatars
|
|
124
|
+
const avatarRef = firestore.collection(commonTerms.collections.avatars.name).doc(uid)
|
|
125
|
+
await avatarRef.set({
|
|
126
|
+
avatarUrl: avatarUrl || ""
|
|
127
|
+
})
|
|
104
128
|
printLog(`Authenticated user document with identifier ${uid} has been correctly stored`, LogLevel.DEBUG)
|
|
129
|
+
printLog(`Authenticated user avatar with identifier ${uid} has been correctly stored`, LogLevel.DEBUG)
|
|
105
130
|
})
|
|
106
131
|
/**
|
|
107
132
|
* Set custom claims for role-based access control on the newly created user.
|
|
@@ -111,7 +136,7 @@ export const registerAuthUser = functions
|
|
|
111
136
|
export const processSignUpWithCustomClaims = functions
|
|
112
137
|
.region("europe-west1")
|
|
113
138
|
.runWith({
|
|
114
|
-
memory: "
|
|
139
|
+
memory: "1GB"
|
|
115
140
|
})
|
|
116
141
|
.auth.user()
|
|
117
142
|
.onCreate(async (user: UserRecord) => {
|
package/src/lib/errors.ts
CHANGED
|
@@ -7,7 +7,7 @@ import { LogLevel } from "../types/enums"
|
|
|
7
7
|
* @notice the set of Firebase Functions status codes. The codes are the same at the
|
|
8
8
|
* ones exposed by {@link https://github.com/grpc/grpc/blob/master/doc/statuscodes.md | gRPC}.
|
|
9
9
|
* @param errorCode <FunctionsErrorCode> - the set of possible error codes.
|
|
10
|
-
* @param message <string> - the error
|
|
10
|
+
* @param message <string> - the error message.
|
|
11
11
|
* @param [details] <string> - the details of the error (optional).
|
|
12
12
|
* @returns <HttpsError>
|
|
13
13
|
*/
|
|
@@ -184,6 +184,11 @@ export const SPECIFIC_ERRORS = {
|
|
|
184
184
|
"unavailable",
|
|
185
185
|
"VM command execution has been delayed since there were no available instance at the moment",
|
|
186
186
|
"Please, contact the coordinator if this error persists."
|
|
187
|
+
),
|
|
188
|
+
SE_VM_UNKNOWN_COMMAND_STATUS: makeError(
|
|
189
|
+
"unavailable",
|
|
190
|
+
"VM command execution has failed due to an unknown status code",
|
|
191
|
+
"Please, contact the coordinator if this error persists."
|
|
187
192
|
)
|
|
188
193
|
}
|
|
189
194
|
|
package/src/lib/services.ts
CHANGED
|
@@ -1,6 +1,11 @@
|
|
|
1
|
+
import dotenv from "dotenv"
|
|
2
|
+
import ethers from "ethers"
|
|
1
3
|
import { S3Client } from "@aws-sdk/client-s3"
|
|
2
4
|
import { COMMON_ERRORS, logAndThrowError } from "./errors"
|
|
3
5
|
|
|
6
|
+
dotenv.config()
|
|
7
|
+
let provider: ethers.providers.Provider
|
|
8
|
+
|
|
4
9
|
/**
|
|
5
10
|
* Return a configured and connected instance of the AWS S3 client.
|
|
6
11
|
* @dev this method check and utilize the environment variables to configure the connection
|
|
@@ -26,3 +31,34 @@ export const getS3Client = async (): Promise<S3Client> => {
|
|
|
26
31
|
region: process.env.AWS_REGION!
|
|
27
32
|
})
|
|
28
33
|
}
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Returns a Prvider, connected via a configured JSON URL or else
|
|
37
|
+
* the ethers.js default provider, using configured API keys.
|
|
38
|
+
* @returns <ethers.providers.Provider> An Eth node provider
|
|
39
|
+
*/
|
|
40
|
+
export const setEthProvider = (): ethers.providers.Provider => {
|
|
41
|
+
if (provider) return provider
|
|
42
|
+
console.log(`setting new provider`)
|
|
43
|
+
|
|
44
|
+
// Use JSON URL if defined
|
|
45
|
+
// if ((hardhat as any).ethers) {
|
|
46
|
+
// console.log(`using hardhat.ethers provider`)
|
|
47
|
+
// provider = (hardhat as any).ethers.provider
|
|
48
|
+
// } else
|
|
49
|
+
if (process.env.ETH_PROVIDER_JSON_URL) {
|
|
50
|
+
console.log(`JSON URL provider at ${process.env.ETH_PROVIDER_JSON_URL}`)
|
|
51
|
+
provider = new ethers.providers.JsonRpcProvider({
|
|
52
|
+
url: process.env.ETH_PROVIDER_JSON_URL,
|
|
53
|
+
skipFetchSetup: true
|
|
54
|
+
})
|
|
55
|
+
} else {
|
|
56
|
+
// Otherwise, connect the default provider with ALchemy, Infura, or both
|
|
57
|
+
provider = ethers.providers.getDefaultProvider("homestead", {
|
|
58
|
+
alchemy: process.env.ETH_PROVIDER_ALCHEMY_API_KEY!,
|
|
59
|
+
infura: process.env.ETH_PROVIDER_INFURA_API_KEY!
|
|
60
|
+
})
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
return provider
|
|
64
|
+
}
|
package/src/lib/utils.ts
CHANGED
|
@@ -10,7 +10,7 @@ import admin from "firebase-admin"
|
|
|
10
10
|
import dotenv from "dotenv"
|
|
11
11
|
import { DeleteObjectCommand, GetObjectCommand, PutObjectCommand } from "@aws-sdk/client-s3"
|
|
12
12
|
import { getSignedUrl } from "@aws-sdk/s3-request-presigner"
|
|
13
|
-
import { createWriteStream
|
|
13
|
+
import { createWriteStream } from "node:fs"
|
|
14
14
|
import { pipeline } from "node:stream"
|
|
15
15
|
import { promisify } from "node:util"
|
|
16
16
|
import { readFileSync } from "fs"
|
|
@@ -25,7 +25,7 @@ import {
|
|
|
25
25
|
CeremonyState,
|
|
26
26
|
finalContributionIndex,
|
|
27
27
|
CircuitDocument
|
|
28
|
-
} from "@
|
|
28
|
+
} from "@devtion/actions"
|
|
29
29
|
import fetch from "@adobe/node-fetch-retry"
|
|
30
30
|
import path from "path"
|
|
31
31
|
import os from "os"
|
|
@@ -166,7 +166,7 @@ export const getCircuitDocumentByPosition = async (
|
|
|
166
166
|
// Query for all ceremony circuits.
|
|
167
167
|
const circuits = await getCeremonyCircuits(ceremonyId)
|
|
168
168
|
|
|
169
|
-
// Apply a filter using the sequence
|
|
169
|
+
// Apply a filter using the sequence position.
|
|
170
170
|
const matchedCircuits = circuits.filter(
|
|
171
171
|
(circuit: DocumentData) => circuit.data().sequencePosition === sequencePosition
|
|
172
172
|
)
|
|
@@ -217,7 +217,7 @@ export const downloadArtifactFromS3Bucket = async (bucketName: string, objectKey
|
|
|
217
217
|
const streamPipeline = promisify(pipeline)
|
|
218
218
|
await streamPipeline(response.body, writeStream)
|
|
219
219
|
|
|
220
|
-
writeStream.on(
|
|
220
|
+
writeStream.on("finish", () => {
|
|
221
221
|
writeStream.end()
|
|
222
222
|
})
|
|
223
223
|
}
|
|
@@ -305,7 +305,7 @@ export const deleteObject = async (bucketName: string, objectKey: string) => {
|
|
|
305
305
|
|
|
306
306
|
// Prepare command.
|
|
307
307
|
const command = new DeleteObjectCommand({ Bucket: bucketName, Key: objectKey })
|
|
308
|
-
|
|
308
|
+
|
|
309
309
|
// Execute command.
|
|
310
310
|
const data = await client.send(command)
|
|
311
311
|
|
|
@@ -385,14 +385,16 @@ export const getGitHubVariables = (): any => {
|
|
|
385
385
|
if (
|
|
386
386
|
!process.env.GITHUB_MINIMUM_FOLLOWERS ||
|
|
387
387
|
!process.env.GITHUB_MINIMUM_FOLLOWING ||
|
|
388
|
-
!process.env.GITHUB_MINIMUM_PUBLIC_REPOS
|
|
388
|
+
!process.env.GITHUB_MINIMUM_PUBLIC_REPOS ||
|
|
389
|
+
!process.env.GITHUB_MINIMUM_AGE
|
|
389
390
|
)
|
|
390
391
|
logAndThrowError(COMMON_ERRORS.CM_WRONG_CONFIGURATION)
|
|
391
392
|
|
|
392
393
|
return {
|
|
393
394
|
minimumFollowers: Number(process.env.GITHUB_MINIMUM_FOLLOWERS),
|
|
394
395
|
minimumFollowing: Number(process.env.GITHUB_MINIMUM_FOLLOWING),
|
|
395
|
-
minimumPublicRepos: Number(process.env.GITHUB_MINIMUM_PUBLIC_REPOS)
|
|
396
|
+
minimumPublicRepos: Number(process.env.GITHUB_MINIMUM_PUBLIC_REPOS),
|
|
397
|
+
minimumAge: Number(process.env.GITHUB_MINIMUM_AGE)
|
|
396
398
|
}
|
|
397
399
|
}
|
|
398
400
|
|
|
@@ -404,7 +406,7 @@ export const getAWSVariables = (): any => {
|
|
|
404
406
|
if (
|
|
405
407
|
!process.env.AWS_ACCESS_KEY_ID ||
|
|
406
408
|
!process.env.AWS_SECRET_ACCESS_KEY ||
|
|
407
|
-
!process.env.
|
|
409
|
+
!process.env.AWS_INSTANCE_PROFILE_ARN ||
|
|
408
410
|
!process.env.AWS_AMI_ID ||
|
|
409
411
|
!process.env.AWS_SNS_TOPIC_ARN
|
|
410
412
|
)
|
|
@@ -414,7 +416,7 @@ export const getAWSVariables = (): any => {
|
|
|
414
416
|
accessKeyId: process.env.AWS_ACCESS_KEY_ID!,
|
|
415
417
|
secretAccessKey: process.env.AWS_SECRET_ACCESS_KEY!,
|
|
416
418
|
region: process.env.AWS_REGION || "eu-central-1",
|
|
417
|
-
|
|
419
|
+
instanceProfileArn: process.env.AWS_INSTANCE_PROFILE_ARN!,
|
|
418
420
|
amiId: process.env.AWS_AMI_ID!,
|
|
419
421
|
snsTopic: process.env.AWS_SNS_TOPIC_ARN!
|
|
420
422
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
declare module "@bandada/api-sdk"
|
package/src/types/index.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { CeremonyInputData, CircuitDocument, ETagWithPartNumber } from "@
|
|
1
|
+
import { CeremonyInputData, CircuitDocument, ETagWithPartNumber } from "@devtion/actions"
|
|
2
|
+
import type { Groth16Proof, PublicSignals } from "snarkjs"
|
|
2
3
|
|
|
3
4
|
/**
|
|
4
5
|
* Group all the necessary data needed for running the `setupCeremony` cloud function.
|
|
@@ -138,3 +139,62 @@ export type FinalizeCircuitData = {
|
|
|
138
139
|
bucketName: string
|
|
139
140
|
beacon: string
|
|
140
141
|
}
|
|
142
|
+
|
|
143
|
+
/**
|
|
144
|
+
* Group all the necessary data needed for running the `bandadaValidateProof` cloud function.
|
|
145
|
+
* @typedef {Object} BandadaValidateProof
|
|
146
|
+
* @property {string} merkleTreeRoot - the merkle tree root of the group.
|
|
147
|
+
* @property {string} nullifierHash - the nullifier hash of the member.
|
|
148
|
+
* @property {string} externalNullifier - the external nullifier of the member.
|
|
149
|
+
* @property {PackedProof} proof - the packed proof generated on the client.
|
|
150
|
+
*/
|
|
151
|
+
export type BandadaValidateProof = {
|
|
152
|
+
proof: Groth16Proof
|
|
153
|
+
publicSignals: PublicSignals
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
/**
|
|
157
|
+
* Define the return object of the function that verifies the Bandada membership and proof.
|
|
158
|
+
* @typedef {Object} VerifiedBandadaResponse
|
|
159
|
+
* @property {boolean} valid - true if the proof is valid and the user is a member of the group; otherwise false.
|
|
160
|
+
* @property {string} message - a message describing the result of the verification.
|
|
161
|
+
* @property {string} token - the custom access token.
|
|
162
|
+
*/
|
|
163
|
+
export type VerifiedBandadaResponse = {
|
|
164
|
+
valid: boolean
|
|
165
|
+
message: string
|
|
166
|
+
token: string
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
/**
|
|
170
|
+
* Define the check nonce object for the cloud function
|
|
171
|
+
* @typedef {Object} CheckNonceOfSIWEAddressRequest
|
|
172
|
+
* @property {string} auth0Token - token from the device flow authentication
|
|
173
|
+
*/
|
|
174
|
+
export type CheckNonceOfSIWEAddressRequest = {
|
|
175
|
+
auth0Token: string
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
/**
|
|
179
|
+
* Define the check nonce response object of the cloud function
|
|
180
|
+
* @typedef {Object} CheckNonceOfSIWEAddressResponse
|
|
181
|
+
* @property {boolean} valid - if the checking result was valid or not
|
|
182
|
+
* @property {string} message - informative message
|
|
183
|
+
* @property {string} token - token to sign in
|
|
184
|
+
*/
|
|
185
|
+
export type CheckNonceOfSIWEAddressResponse = {
|
|
186
|
+
valid: boolean
|
|
187
|
+
message?: string
|
|
188
|
+
token?: string
|
|
189
|
+
}
|
|
190
|
+
/**
|
|
191
|
+
* Define the response from auth0 /userinfo endpoint
|
|
192
|
+
*
|
|
193
|
+
*/
|
|
194
|
+
export type Auth0UserInfo = {
|
|
195
|
+
sub: string
|
|
196
|
+
nickname: string
|
|
197
|
+
name: string
|
|
198
|
+
picture: string
|
|
199
|
+
updated_at: string
|
|
200
|
+
}
|