@devtion/actions 0.0.0-4088679 → 0.0.0-477457c
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 +2 -2
- package/dist/index.mjs +376 -268
- package/dist/index.node.js +376 -266
- package/dist/types/src/helpers/authentication.d.ts.map +1 -1
- 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.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/functions.d.ts +2 -1
- package/dist/types/src/helpers/functions.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/services.d.ts.map +1 -1
- package/dist/types/src/helpers/storage.d.ts +5 -2
- package/dist/types/src/helpers/storage.d.ts.map +1 -1
- package/dist/types/src/helpers/utils.d.ts +33 -21
- 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 -4
- package/dist/types/src/types/index.d.ts.map +1 -1
- package/dist/types/test/data/generators.d.ts +32 -0
- package/dist/types/test/data/generators.d.ts.map +1 -0
- package/dist/types/test/data/samples.d.ts +40 -0
- package/dist/types/test/data/samples.d.ts.map +1 -0
- package/dist/types/test/utils/authentication.d.ts +72 -0
- package/dist/types/test/utils/authentication.d.ts.map +1 -0
- package/dist/types/test/utils/configs.d.ts +52 -0
- package/dist/types/test/utils/configs.d.ts.map +1 -0
- package/dist/types/test/utils/index.d.ts +4 -0
- package/dist/types/test/utils/index.d.ts.map +1 -0
- package/dist/types/test/utils/storage.d.ts +126 -0
- package/dist/types/test/utils/storage.d.ts.map +1 -0
- package/package.json +7 -8
- package/src/helpers/constants.ts +39 -31
- package/src/helpers/contracts.ts +3 -3
- package/src/helpers/crypto.ts +5 -1
- package/src/helpers/database.ts +13 -0
- package/src/helpers/functions.ts +1 -1
- package/src/helpers/security.ts +11 -8
- package/src/helpers/services.ts +3 -3
- package/src/helpers/storage.ts +15 -3
- package/src/helpers/utils.ts +335 -263
- package/src/helpers/verification.ts +6 -6
- package/src/helpers/vm.ts +28 -7
- package/src/index.ts +5 -3
- package/src/types/index.ts +32 -8
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { UserCredential } from "firebase/auth";
|
|
2
|
+
import { FirebaseApp } from "firebase/app";
|
|
3
|
+
import { Auth } from "firebase-admin/auth";
|
|
4
|
+
import { UserDocumentReferenceAndData } from "../../src/types/index";
|
|
5
|
+
/**
|
|
6
|
+
* Sleeps the function execution for given millis.
|
|
7
|
+
* @dev to be used in combination with loggers when writing data into files.
|
|
8
|
+
* @param ms <number> - sleep amount in milliseconds
|
|
9
|
+
* @returns <Promise<any>>
|
|
10
|
+
*/
|
|
11
|
+
export declare const sleep: (ms: any) => Promise<unknown>;
|
|
12
|
+
/**
|
|
13
|
+
* Return a pseudo random string of numeric values of specified length.
|
|
14
|
+
* @param length <string> - the number of values.
|
|
15
|
+
* @returns <string> - a pseudo random string of numeric values.
|
|
16
|
+
*/
|
|
17
|
+
export declare const generatePseudoRandomStringOfNumbers: (length: number) => string;
|
|
18
|
+
/**
|
|
19
|
+
* Create a new Firebase user account with specified email and password.
|
|
20
|
+
* @notice On successful creation of the user account, this user will also be signed in to your application.
|
|
21
|
+
* @dev The pw MUST not be the one used for login with the email on Google or other email providers. The pw is only valid for authentication with Firebase.
|
|
22
|
+
* @param userApp <FirebaseApp> - the initialized instance of the Firebase app.
|
|
23
|
+
* @param email <string> - the personal user email.
|
|
24
|
+
* @param pw <string> - a password to be associated with the user personal email here in Firebase.
|
|
25
|
+
* @returns <Promise<UserCredential>>
|
|
26
|
+
*/
|
|
27
|
+
export declare const createNewFirebaseUserWithEmailAndPw: (userApp: FirebaseApp, email: string, pw: string) => Promise<UserCredential>;
|
|
28
|
+
/**
|
|
29
|
+
* Return the verification code needed to complete the access with Github.
|
|
30
|
+
* @param gmailUserEmail <string> - the GMail email address.
|
|
31
|
+
* @param gmailClientId <string> - the GMail client identifier.
|
|
32
|
+
* @param gmailClientSecret <string> - the GMail client secret.
|
|
33
|
+
* @param gmailRedirectUrl <string> - the GMail redirect url.
|
|
34
|
+
* @param gmailRefreshToken <string> - the GMail refresh token.
|
|
35
|
+
* @dev You should have the GMail APIs for OAuth2.0 must be enabled and configured properly in order to get correct results.
|
|
36
|
+
* @returns <Promise<string>> - return the 6 digits verification code needed to complete the access with Github.
|
|
37
|
+
* @todo this method will not be used for testing right now. See PR #286 and #289 for info.
|
|
38
|
+
*/
|
|
39
|
+
export declare const getLastGithubVerificationCode: (gmailUserEmail: string, gmailClientId: string, gmailClientSecret: string, gmailRedirectUrl: string, gmailRefreshToken: string) => Promise<string>;
|
|
40
|
+
/**
|
|
41
|
+
* Test function to set custom claims of a user.
|
|
42
|
+
* @param adminAuth <Auth> - the admin auth instance.
|
|
43
|
+
* @param userId <string> - the uid of the user to add the privileges to.
|
|
44
|
+
* @param claims <{ [key: string]: boolean }> - the claims to set.
|
|
45
|
+
* @returns
|
|
46
|
+
*/
|
|
47
|
+
export declare const setCustomClaims: (adminAuth: Auth, userId: string, claims: {
|
|
48
|
+
[key: string]: boolean;
|
|
49
|
+
}) => Promise<void>;
|
|
50
|
+
/**
|
|
51
|
+
* Test function to create a new user
|
|
52
|
+
* @param userApp <FirebaseApp> - the Firebase user Application instance.
|
|
53
|
+
* @param email <string> - the email of the user.
|
|
54
|
+
* @param password <string> - the password of the user.
|
|
55
|
+
* @param isUserCoordinator <boolean> - whether the user is a coordinator or not.
|
|
56
|
+
* @param adminAuth <Auth> - the admin auth instance.
|
|
57
|
+
*/
|
|
58
|
+
export declare const createMockUser: (userApp: FirebaseApp, email: string, password: string, isUserCoordinator?: boolean, adminAuth?: Auth) => Promise<string>;
|
|
59
|
+
/**
|
|
60
|
+
* Generate a list of random passwords.
|
|
61
|
+
* @param numberOfUsers <number> - the number of users to generate passwords for.
|
|
62
|
+
* @returns <string[]> - the list of passwords.
|
|
63
|
+
*/
|
|
64
|
+
export declare const generateUserPasswords: (numberOfUsers: number) => string[];
|
|
65
|
+
/**
|
|
66
|
+
* Clean up the db and app by removing users created for testing.
|
|
67
|
+
* @param adminAuth <Auth> - the admin auth instance.
|
|
68
|
+
* @param adminFirestore <Firestore> - the admin firestore instance.
|
|
69
|
+
* @param uids <string[]> - the list of uids to delete.
|
|
70
|
+
*/
|
|
71
|
+
export declare const cleanUpMockUsers: (adminAuth: Auth, adminFirestore: FirebaseFirestore.Firestore, users: UserDocumentReferenceAndData[]) => Promise<void>;
|
|
72
|
+
//# sourceMappingURL=authentication.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"authentication.d.ts","sourceRoot":"","sources":["../../../../test/utils/authentication.ts"],"names":[],"mappings":"AACA,OAAO,EAA2C,cAAc,EAAE,MAAM,eAAe,CAAA;AACvF,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAA;AAC1C,OAAO,EAAE,IAAI,EAAE,MAAM,qBAAqB,CAAA;AAE1C,OAAO,EAAE,4BAA4B,EAAE,MAAM,uBAAuB,CAAA;AAEpE;;;;;GAKG;AACH,eAAO,MAAM,KAAK,GAAI,IAAI,GAAG,qBAAsD,CAAA;AAEnF;;;;GAIG;AACH,eAAO,MAAM,mCAAmC,GAAI,QAAQ,MAAM,KAAG,MAAwC,CAAA;AAE7G;;;;;;;;GAQG;AACH,eAAO,MAAM,mCAAmC,GAC5C,SAAS,WAAW,EACpB,OAAO,MAAM,EACb,IAAI,MAAM,KACX,OAAO,CAAC,cAAc,CAAgE,CAAA;AAEzF;;;;;;;;;;GAUG;AACH,eAAO,MAAM,6BAA6B,GACtC,gBAAgB,MAAM,EACtB,eAAe,MAAM,EACrB,mBAAmB,MAAM,EACzB,kBAAkB,MAAM,EACxB,mBAAmB,MAAM,KAC1B,OAAO,CAAC,MAAM,CA+BhB,CAAA;AAED;;;;;;GAMG;AACH,eAAO,MAAM,eAAe,GACxB,WAAW,IAAI,EACf,QAAQ,MAAM,EACd,QAAQ;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAA;CAAE,KACnC,OAAO,CAAC,IAAI,CAAkD,CAAA;AAEjE;;;;;;;GAOG;AACH,eAAO,MAAM,cAAc,GACvB,SAAS,WAAW,EACpB,OAAO,MAAM,EACb,UAAU,MAAM,EAChB,oBAAmB,OAAc,EACjC,YAAY,IAAI,KACjB,OAAO,CAAC,MAAM,CAiBhB,CAAA;AAED;;;;GAIG;AACH,eAAO,MAAM,qBAAqB,GAAI,eAAe,MAAM,KAAG,MAAM,EAOnE,CAAA;AAED;;;;;GAKG;AACH,eAAO,MAAM,gBAAgB,GACzB,WAAW,IAAI,EACf,gBAAgB,iBAAiB,CAAC,SAAS,EAC3C,OAAO,4BAA4B,EAAE,KACtC,OAAO,CAAC,IAAI,CAKd,CAAA"}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import admin from "firebase-admin";
|
|
2
|
+
import { FirebaseApp } from "firebase/app";
|
|
3
|
+
import { Firestore } from "firebase/firestore";
|
|
4
|
+
import { Functions } from "firebase/functions";
|
|
5
|
+
import { TestingEnvironment } from "../../src/types/enums";
|
|
6
|
+
export declare const envType: TestingEnvironment;
|
|
7
|
+
/**
|
|
8
|
+
* Initialize and return the Admin SDK app and services.
|
|
9
|
+
* @returns <App, Firestore, Auth, SecurityRules> - the instance of the initialized admin app and services.
|
|
10
|
+
*/
|
|
11
|
+
export declare const initializeAdminServices: () => {
|
|
12
|
+
adminApp: admin.app.App;
|
|
13
|
+
adminFirestore: admin.firestore.Firestore;
|
|
14
|
+
adminAuth: admin.auth.Auth;
|
|
15
|
+
adminSecurityRules: admin.securityRules.SecurityRules;
|
|
16
|
+
};
|
|
17
|
+
/**
|
|
18
|
+
* Initialize and return the Firebase app and services.
|
|
19
|
+
* @returns <App, Firestore, Functions> - the instance of the initialized Firebase app and services.
|
|
20
|
+
*/
|
|
21
|
+
export declare const initializeUserServices: () => {
|
|
22
|
+
userApp: FirebaseApp;
|
|
23
|
+
userFirestore: Firestore;
|
|
24
|
+
userFunctions: Functions;
|
|
25
|
+
};
|
|
26
|
+
/**
|
|
27
|
+
* Get necessary information for correctly config the storage module.
|
|
28
|
+
* @returns <number, string, number> - the necessary information for configuring storage module (AWS S3).
|
|
29
|
+
*/
|
|
30
|
+
export declare const getStorageConfiguration: () => {
|
|
31
|
+
streamChunkSizeInMb: number;
|
|
32
|
+
ceremonyBucketPostfix: string;
|
|
33
|
+
presignedUrlExpirationInSeconds: number;
|
|
34
|
+
};
|
|
35
|
+
/**
|
|
36
|
+
* Get necessary information for correctly config the authentication module.
|
|
37
|
+
* @returns <string> - the necessary information for dealing with the authentication.
|
|
38
|
+
*/
|
|
39
|
+
export declare const getAuthenticationConfiguration: () => {
|
|
40
|
+
githubClientId: string;
|
|
41
|
+
userEmail: string;
|
|
42
|
+
githubUserPw: string;
|
|
43
|
+
gmailClientId: string;
|
|
44
|
+
gmailClientSecret: string;
|
|
45
|
+
gmailRedirectUrl: string;
|
|
46
|
+
gmailRefreshToken: string;
|
|
47
|
+
};
|
|
48
|
+
/**
|
|
49
|
+
* Delete all initialized apps using the Admin SDK.
|
|
50
|
+
*/
|
|
51
|
+
export declare const deleteAdminApp: () => Promise<void>;
|
|
52
|
+
//# sourceMappingURL=configs.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"configs.d.ts","sourceRoot":"","sources":["../../../../test/utils/configs.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,gBAAgB,CAAA;AAElC,OAAO,EAAE,WAAW,EAAyB,MAAM,cAAc,CAAA;AACjE,OAAO,EAA4B,SAAS,EAAgB,MAAM,oBAAoB,CAAA;AACtF,OAAO,EAA4B,SAAS,EAAgB,MAAM,oBAAoB,CAAA;AAEtF,OAAO,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAA;AAW1D,eAAO,MAAM,OAAO,oBAAmG,CAAA;AAEvH;;;GAGG;AACH,eAAO,MAAM,uBAAuB,QAAO;IACvC,QAAQ,EAAE,KAAK,CAAC,GAAG,CAAC,GAAG,CAAA;IACvB,cAAc,EAAE,KAAK,CAAC,SAAS,CAAC,SAAS,CAAA;IACzC,SAAS,EAAE,KAAK,CAAC,IAAI,CAAC,IAAI,CAAA;IAC1B,kBAAkB,EAAE,KAAK,CAAC,aAAa,CAAC,aAAa,CAAA;CAkBxD,CAAA;AAED;;;GAGG;AACH,eAAO,MAAM,sBAAsB,QAAO;IACtC,OAAO,EAAE,WAAW,CAAA;IACpB,aAAa,EAAE,SAAS,CAAA;IACxB,aAAa,EAAE,SAAS,CAAA;CA6B3B,CAAA;AAED;;;GAGG;AACH,eAAO,MAAM,uBAAuB,QAAO;IACvC,mBAAmB,EAAE,MAAM,CAAA;IAC3B,qBAAqB,EAAE,MAAM,CAAA;IAC7B,+BAA+B,EAAE,MAAM,CAAA;CAKzC,CAAA;AAEF;;;GAGG;AACH,eAAO,MAAM,8BAA8B,QAAO;IAC9C,cAAc,EAAE,MAAM,CAAA;IACtB,SAAS,EAAE,MAAM,CAAA;IACjB,YAAY,EAAE,MAAM,CAAA;IACpB,aAAa,EAAE,MAAM,CAAA;IACrB,iBAAiB,EAAE,MAAM,CAAA;IACzB,gBAAgB,EAAE,MAAM,CAAA;IACxB,iBAAiB,EAAE,MAAM,CAAA;CAS3B,CAAA;AAEF;;GAEG;AACH,eAAO,MAAM,cAAc,qBAE1B,CAAA"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export { envType, initializeAdminServices, initializeUserServices, getStorageConfiguration, getAuthenticationConfiguration, deleteAdminApp } from "./configs";
|
|
2
|
+
export { createMockCeremony, cleanUpRecursively, cleanUpMockCeremony, createMockContribution, createMockTimedOutContribution, cleanUpMockParticipant, cleanUpMockTimeout, createMockParticipant, cleanUpMockContribution, deleteBucket, deleteObjectFromS3, getContributionLocalFilePath, getPotLocalFilePath, getZkeyLocalFilePath, mockCeremoniesCleanup, uploadFileToS3, getTranscriptLocalFilePath, storeMockDoneParticipant } from "./storage";
|
|
3
|
+
export { createMockUser, cleanUpMockUsers, createNewFirebaseUserWithEmailAndPw, generateUserPasswords, setCustomClaims, sleep, generatePseudoRandomStringOfNumbers } from "./authentication";
|
|
4
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../test/utils/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACH,OAAO,EACP,uBAAuB,EACvB,sBAAsB,EACtB,uBAAuB,EACvB,8BAA8B,EAC9B,cAAc,EACjB,MAAM,WAAW,CAAA;AAClB,OAAO,EACH,kBAAkB,EAClB,kBAAkB,EAClB,mBAAmB,EACnB,sBAAsB,EACtB,8BAA8B,EAC9B,sBAAsB,EACtB,kBAAkB,EAClB,qBAAqB,EACrB,uBAAuB,EACvB,YAAY,EACZ,kBAAkB,EAClB,4BAA4B,EAC5B,mBAAmB,EACnB,oBAAoB,EACpB,qBAAqB,EACrB,cAAc,EACd,0BAA0B,EAC1B,wBAAwB,EAC3B,MAAM,WAAW,CAAA;AAClB,OAAO,EACH,cAAc,EACd,gBAAgB,EAChB,mCAAmC,EACnC,qBAAqB,EACrB,eAAe,EACf,KAAK,EACL,mCAAmC,EACtC,MAAM,kBAAkB,CAAA"}
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
import { CeremonyDocumentReferenceAndData, CircuitDocumentReferenceAndData, ParticipantDocumentReferenceAndData } from "../../src/types/index";
|
|
2
|
+
/**
|
|
3
|
+
* Create a new S3 Client object
|
|
4
|
+
* @returns <S3Client | boolean> an S3 client if the credentials are set, false otherwise
|
|
5
|
+
*/
|
|
6
|
+
export declare const getS3Client: () => any;
|
|
7
|
+
/**
|
|
8
|
+
* Deletes an object from S3 (test function only)
|
|
9
|
+
* @param bucketName <string> the name of the bucket to delete the object from
|
|
10
|
+
* @param objectKey <string> the key of the object to delete
|
|
11
|
+
* @returns <boolean> true if the object was deleted, false otherwise
|
|
12
|
+
*/
|
|
13
|
+
export declare const deleteObjectFromS3: (bucketName: string, objectKey: string) => Promise<boolean>;
|
|
14
|
+
/**
|
|
15
|
+
* Deletes a bucket from s3 (test function only)
|
|
16
|
+
* @param bucketName <string> the name of the bucket to delete
|
|
17
|
+
* @returns boolean true if the bucket was deleted, false otherwise
|
|
18
|
+
*/
|
|
19
|
+
export declare const deleteBucket: (bucketName: string) => Promise<boolean>;
|
|
20
|
+
/**
|
|
21
|
+
* Uploads a file to S3 (test function only)
|
|
22
|
+
* @param bucketName <string> the name of the bucket to upload the file to
|
|
23
|
+
* @param objectKey <string> the key of the object to upload
|
|
24
|
+
* @param path <string> the path of the file to upload
|
|
25
|
+
*/
|
|
26
|
+
export declare const uploadFileToS3: (bucketName: string, objectKey: string, path: string) => Promise<void>;
|
|
27
|
+
/**
|
|
28
|
+
* Creates mock data on Firestore (test function only)
|
|
29
|
+
* @param adminFirestore <FirebaseFirestore.Firestore> the admin firestore instance
|
|
30
|
+
* @param ceremonyData <CeremonyDocumentReferenceAndData> the ceremony data
|
|
31
|
+
* @param circuitData <CircuitDocumentReferenceAndData> the circuit data
|
|
32
|
+
*/
|
|
33
|
+
export declare const createMockCeremony: (adminFirestore: FirebaseFirestore.Firestore, ceremonyData: CeremonyDocumentReferenceAndData, circuitData: CircuitDocumentReferenceAndData) => Promise<void>;
|
|
34
|
+
/**
|
|
35
|
+
* Cleans up mock data on Firestore (test function only)
|
|
36
|
+
* @param adminFirestore <FirebaseFirestore.Firestore> the admin firestore instance
|
|
37
|
+
* @param ceremonyId <string> the ceremony id
|
|
38
|
+
* @param circuitId <string> the circuit id
|
|
39
|
+
*/
|
|
40
|
+
export declare const cleanUpMockCeremony: (adminFirestore: FirebaseFirestore.Firestore, ceremonyId: string, circuitId: string) => Promise<void>;
|
|
41
|
+
/**
|
|
42
|
+
* Recursively clean up all documents of a ceremony given its id
|
|
43
|
+
* @param adminFirestore <FirebaseFirestore.Firestore> the admin firestore instance
|
|
44
|
+
* @param ceremonyId <string> the ceremony id
|
|
45
|
+
*/
|
|
46
|
+
export declare const cleanUpRecursively: (adminFirestore: FirebaseFirestore.Firestore, ceremonyId: string) => Promise<void>;
|
|
47
|
+
/**
|
|
48
|
+
* Clean up all mock ceremonies on Firestore (test function only)
|
|
49
|
+
* @param adminFirestore <FirebaseFirestore.Firestore> the admin firestore instance
|
|
50
|
+
*/
|
|
51
|
+
export declare const mockCeremoniesCleanup: (adminFirestore: FirebaseFirestore.Firestore) => Promise<void>;
|
|
52
|
+
/**
|
|
53
|
+
* Creates a mock contribution on Firestore (test function only)
|
|
54
|
+
* @param adminFirestore <FirebaseFirestore.Firestore> the admin firestore instance
|
|
55
|
+
* @param contributorId <string> the contributor id
|
|
56
|
+
* @param ceremonyId <string> the ceremony id
|
|
57
|
+
* @param circuitId <string> the circuit id
|
|
58
|
+
*/
|
|
59
|
+
export declare const createMockContribution: (adminFirestore: FirebaseFirestore.Firestore, ceremonyId: string, circuitId: string, contribution: any, contributionId: string) => Promise<void>;
|
|
60
|
+
/**
|
|
61
|
+
* Delete a mock contribution (test function only)
|
|
62
|
+
* @param adminFirestore <FirebaseFirestore.Firestore> the admin firestore instance
|
|
63
|
+
* @param contributorId <string> the contributor id
|
|
64
|
+
* @param ceremonyId <string> the ceremony id
|
|
65
|
+
* @param circuitId <string> the circuit id
|
|
66
|
+
*/
|
|
67
|
+
export declare const cleanUpMockContribution: (adminFirestore: FirebaseFirestore.Firestore, ceremonyId: string, circuitId: string, contributionId: string) => Promise<void>;
|
|
68
|
+
/**
|
|
69
|
+
* Store a participant on Firestore (test function only)
|
|
70
|
+
* @param adminFirestore <FirebaseFirestore.Firestore> the admin firestore instance
|
|
71
|
+
* @param ceremonyId <string> the ceremony id
|
|
72
|
+
*/
|
|
73
|
+
export declare const createMockParticipant: (adminFirestore: FirebaseFirestore.Firestore, ceremonyId: string, participantId: string, participantData: ParticipantDocumentReferenceAndData) => Promise<void>;
|
|
74
|
+
/**
|
|
75
|
+
* Store a participant on Firestore with contribution Done (test function only)
|
|
76
|
+
* @param adminFirestore <FirebaseFirestore.Firestore> the admin firestore instance
|
|
77
|
+
* @param ceremonyId <string> the ceremony id
|
|
78
|
+
* @param participantUID <string> the participant uid
|
|
79
|
+
*/
|
|
80
|
+
export declare const storeMockDoneParticipant: (adminFirestore: FirebaseFirestore.Firestore, ceremonyId: string, participantUID: string) => Promise<void>;
|
|
81
|
+
/**
|
|
82
|
+
* Clean up the mock participant at step 1 from Firestore (test function only)
|
|
83
|
+
* @param adminFirestore <FirebaseFirestore.Firestore> the admin firestore instance
|
|
84
|
+
* @param ceremonyId <string> the ceremony id
|
|
85
|
+
*/
|
|
86
|
+
export declare const cleanUpMockParticipant: (adminFirestore: FirebaseFirestore.Firestore, ceremonyId: string, participantId: string) => Promise<void>;
|
|
87
|
+
/**
|
|
88
|
+
* Creates a mock timed out contribution on Firestore (test function only)
|
|
89
|
+
* @param adminFirestore <FirebaseFirestore.Firestore> the admin firestore instance
|
|
90
|
+
* @param contributorId <string> the contributor id
|
|
91
|
+
* @param ceremonyId <string> the ceremony id
|
|
92
|
+
* @param circuitId <string> the circuit id
|
|
93
|
+
*/
|
|
94
|
+
export declare const createMockTimedOutContribution: (adminFirestore: FirebaseFirestore.Firestore, contributorId: string, ceremonyId: string) => Promise<void>;
|
|
95
|
+
/**
|
|
96
|
+
* Clean up a mock timeout (test function only)
|
|
97
|
+
* @param adminFirestore <FirebaseFirestore.Firestore> the admin firestore instance
|
|
98
|
+
* @param contributorId <string> the contributor id
|
|
99
|
+
* @param ceremonyId <string> the ceremony id
|
|
100
|
+
*/
|
|
101
|
+
export declare const cleanUpMockTimeout: (adminFirestore: FirebaseFirestore.Firestore, contributorId: string, ceremonyId: string) => Promise<void>;
|
|
102
|
+
/**
|
|
103
|
+
* Get the complete PoT file path.
|
|
104
|
+
* @param completeFilename <string> - the complete filename of the file (name.ext).
|
|
105
|
+
* @returns <string> - the complete PoT path to the file.
|
|
106
|
+
*/
|
|
107
|
+
export declare const getPotLocalFilePath: (completeFilename: string) => string;
|
|
108
|
+
/**
|
|
109
|
+
* Get the complete zKey file path.
|
|
110
|
+
* @param completeFilename <string> - the complete filename of the file (name.ext).
|
|
111
|
+
* @returns <string> - the complete zKey path to the file.
|
|
112
|
+
*/
|
|
113
|
+
export declare const getZkeyLocalFilePath: (completeFilename: string) => string;
|
|
114
|
+
/**
|
|
115
|
+
* Get the complete contribution file path.
|
|
116
|
+
* @param completeFilename <string> - the complete filename of the file (name.ext).
|
|
117
|
+
* @returns <string> - the complete contribution path to the file.
|
|
118
|
+
*/
|
|
119
|
+
export declare const getContributionLocalFilePath: (completeFilename: string) => string;
|
|
120
|
+
/**
|
|
121
|
+
* Get the transcript file path.
|
|
122
|
+
* @param completeFilename <string> - the complete filename of the file (name.ext).
|
|
123
|
+
* @returns <string> - the the transcript path to the file.
|
|
124
|
+
*/
|
|
125
|
+
export declare const getTranscriptLocalFilePath: (completeFilename: string) => string;
|
|
126
|
+
//# sourceMappingURL=storage.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"storage.d.ts","sourceRoot":"","sources":["../../../../test/utils/storage.ts"],"names":[],"mappings":"AAEA,OAAO,EACH,gCAAgC,EAChC,+BAA+B,EAC/B,mCAAmC,EACtC,MAAM,uBAAuB,CAAA;AAY9B;;;GAGG;AACH,eAAO,MAAM,WAAW,QAAO,GAmB9B,CAAA;AAED;;;;;GAKG;AACH,eAAO,MAAM,kBAAkB,GAAU,YAAY,MAAM,EAAE,WAAW,MAAM,qBAmB7E,CAAA;AAED;;;;GAIG;AACH,eAAO,MAAM,YAAY,GAAU,YAAY,MAAM,KAAG,OAAO,CAAC,OAAO,CAiBtE,CAAA;AAED;;;;;GAKG;AACH,eAAO,MAAM,cAAc,GAAU,YAAY,MAAM,EAAE,WAAW,MAAM,EAAE,MAAM,MAAM,kBAevF,CAAA;AAED;;;;;GAKG;AACH,eAAO,MAAM,kBAAkB,GAC3B,gBAAgB,iBAAiB,CAAC,SAAS,EAC3C,cAAc,gCAAgC,EAC9C,aAAa,+BAA+B,kBAgB/C,CAAA;AAED;;;;;GAKG;AACH,eAAO,MAAM,mBAAmB,GAC5B,gBAAgB,iBAAiB,CAAC,SAAS,EAC3C,YAAY,MAAM,EAClB,WAAW,MAAM,kBAIpB,CAAA;AAED;;;;GAIG;AACH,eAAO,MAAM,kBAAkB,GAAU,gBAAgB,iBAAiB,CAAC,SAAS,EAAE,YAAY,MAAM,kBAIvG,CAAA;AAED;;;GAGG;AACH,eAAO,MAAM,qBAAqB,GAAU,gBAAgB,iBAAiB,CAAC,SAAS,kBAYtF,CAAA;AAED;;;;;;GAMG;AACH,eAAO,MAAM,sBAAsB,GAC/B,gBAAgB,iBAAiB,CAAC,SAAS,EAC3C,YAAY,MAAM,EAClB,WAAW,MAAM,EACjB,cAAc,GAAG,EACjB,gBAAgB,MAAM,kBAQzB,CAAA;AAED;;;;;;GAMG;AACH,eAAO,MAAM,uBAAuB,GAChC,gBAAgB,iBAAiB,CAAC,SAAS,EAC3C,YAAY,MAAM,EAClB,WAAW,MAAM,EACjB,gBAAgB,MAAM,kBAGzB,CAAA;AAED;;;;GAIG;AACH,eAAO,MAAM,qBAAqB,GAC9B,gBAAgB,iBAAiB,CAAC,SAAS,EAC3C,YAAY,MAAM,EAClB,eAAe,MAAM,EACrB,iBAAiB,mCAAmC,kBAQvD,CAAA;AAED;;;;;GAKG;AACH,eAAO,MAAM,wBAAwB,GACjC,gBAAgB,iBAAiB,CAAC,SAAS,EAC3C,YAAY,MAAM,EAClB,gBAAgB,MAAM,kBA2BzB,CAAA;AAED;;;;GAIG;AACH,eAAO,MAAM,sBAAsB,GAC/B,gBAAgB,iBAAiB,CAAC,SAAS,EAC3C,YAAY,MAAM,EAClB,eAAe,MAAM,kBAGxB,CAAA;AAED;;;;;;GAMG;AACH,eAAO,MAAM,8BAA8B,GACvC,gBAAgB,iBAAiB,CAAC,SAAS,EAC3C,eAAe,MAAM,EACrB,YAAY,MAAM,kBAoBrB,CAAA;AAED;;;;;GAKG;AACH,eAAO,MAAM,kBAAkB,GAC3B,gBAAgB,iBAAiB,CAAC,SAAS,EAC3C,eAAe,MAAM,EACrB,YAAY,MAAM,kBAIrB,CAAA;AAWD;;;;GAIG;AACH,eAAO,MAAM,mBAAmB,GAAI,kBAAkB,MAAM,KAAG,MAAqD,CAAA;AAEpH;;;;GAIG;AACH,eAAO,MAAM,oBAAoB,GAAI,kBAAkB,MAAM,KAAG,MAAuD,CAAA;AAEvH;;;;GAIG;AACH,eAAO,MAAM,4BAA4B,GAAI,kBAAkB,MAAM,KAAG,MACf,CAAA;AAEzD;;;;GAIG;AACH,eAAO,MAAM,0BAA0B,GAAI,kBAAkB,MAAM,KAAG,MACH,CAAA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@devtion/actions",
|
|
3
|
-
"version": "0.0.0-
|
|
3
|
+
"version": "0.0.0-477457c",
|
|
4
4
|
"description": "A set of actions and helpers for CLI commands",
|
|
5
5
|
"repository": "git@github.com:privacy-scaling-explorations/p0tion.git",
|
|
6
6
|
"homepage": "https://github.com/privacy-scaling-explorations/p0tion",
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
"main": "dist/index.node.js",
|
|
15
15
|
"types": "dist/types/src/index.d.ts",
|
|
16
16
|
"engines": {
|
|
17
|
-
"node": ">=
|
|
17
|
+
"node": ">=20.0.0"
|
|
18
18
|
},
|
|
19
19
|
"files": [
|
|
20
20
|
"dist/",
|
|
@@ -31,8 +31,8 @@
|
|
|
31
31
|
"circom"
|
|
32
32
|
],
|
|
33
33
|
"scripts": {
|
|
34
|
-
"build": "rimraf dist && rollup -c rollup.config.ts --configPlugin typescript",
|
|
35
|
-
"build:watch": "rollup -c rollup.config.ts -w --configPlugin typescript",
|
|
34
|
+
"build": "rimraf dist && rollup -c rollup.config.ts --configPlugin typescript --bundleConfigAsCjs",
|
|
35
|
+
"build:watch": "rollup -c rollup.config.ts -w --configPlugin typescript --bundleConfigAsCjs",
|
|
36
36
|
"pre:publish": "yarn build",
|
|
37
37
|
"compile:contracts": "hardhat compile",
|
|
38
38
|
"test:contracts": "GOOGLE_APPLICATION_CREDENTIALS=\"../backend/serviceAccountKey.json\" && NODE_ENV=prod && TS_NODE_FILES=true hardhat test test/unit/contract.test.ts",
|
|
@@ -51,19 +51,19 @@
|
|
|
51
51
|
"chai-as-promised": "^7.1.1",
|
|
52
52
|
"dotenv": "^16.0.3",
|
|
53
53
|
"ethers": "^5.7.2",
|
|
54
|
-
"ffjavascript": "^0.2.57",
|
|
55
54
|
"firebase": "^9.21.0",
|
|
56
55
|
"firebase-admin": "^11.8.0",
|
|
57
56
|
"googleapis": "^118.0.0",
|
|
58
57
|
"rimraf": "^5.0.0",
|
|
59
58
|
"rollup": "^3.21.6",
|
|
60
|
-
"snarkjs": "
|
|
59
|
+
"snarkjs": "0.7.3",
|
|
61
60
|
"solc": "^0.8.19"
|
|
62
61
|
},
|
|
63
62
|
"devDependencies": {
|
|
64
63
|
"@ethersproject/providers": "^5.7.2",
|
|
65
64
|
"@nomicfoundation/hardhat-chai-matchers": "^1.0.6",
|
|
66
65
|
"@nomiclabs/hardhat-ethers": "^2.2.3",
|
|
66
|
+
"@rollup/plugin-typescript": "^11.1.6",
|
|
67
67
|
"@typechain/ethers-v5": "^10.2.1",
|
|
68
68
|
"@typechain/hardhat": "^6.1.6",
|
|
69
69
|
"@types/mocha": "^10.0.1",
|
|
@@ -71,7 +71,6 @@
|
|
|
71
71
|
"hardhat": "^2.14.0",
|
|
72
72
|
"rollup-plugin-auto-external": "^2.0.0",
|
|
73
73
|
"rollup-plugin-cleanup": "^3.2.1",
|
|
74
|
-
"rollup-plugin-typescript2": "^0.34.1",
|
|
75
74
|
"ts-node": "^10.9.1",
|
|
76
75
|
"typescript": "^5.0.4",
|
|
77
76
|
"winston": "^3.8.2"
|
|
@@ -79,5 +78,5 @@
|
|
|
79
78
|
"publishConfig": {
|
|
80
79
|
"access": "public"
|
|
81
80
|
},
|
|
82
|
-
"gitHead": "
|
|
81
|
+
"gitHead": "a160aad10b1d03b9d4307a44aa00d13405767d90"
|
|
83
82
|
}
|
package/src/helpers/constants.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
// Main part for the
|
|
2
|
-
export const potFileDownloadMainUrl = `https://
|
|
3
|
-
// Main part for the
|
|
4
|
-
export const potFilenameTemplate = `
|
|
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 = /Contribution.+Hash.+\s+.+\s+.+\s+.+\s+.+\s*/
|
|
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://
|
|
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://
|
|
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://
|
|
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://
|
|
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://
|
|
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://
|
|
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://
|
|
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://
|
|
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://
|
|
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://
|
|
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://
|
|
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://
|
|
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://
|
|
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://
|
|
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://
|
|
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://
|
|
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://
|
|
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://
|
|
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://
|
|
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://
|
|
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://
|
|
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://
|
|
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://
|
|
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://
|
|
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://
|
|
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://
|
|
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://
|
|
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
|
|
|
@@ -314,5 +320,7 @@ export const commonTerms = {
|
|
|
314
320
|
finalizeCeremony: "finalizeCeremony",
|
|
315
321
|
downloadCircuitArtifacts: "downloadCircuitArtifacts",
|
|
316
322
|
transferObject: "transferObject",
|
|
323
|
+
bandadaValidateProof: "bandadaValidateProof",
|
|
324
|
+
checkNonceOfSIWEAddress: "checkNonceOfSIWEAddress"
|
|
317
325
|
}
|
|
318
326
|
}
|
package/src/helpers/contracts.ts
CHANGED
|
@@ -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 =
|
|
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(
|
|
48
|
+
formattedCircuitInput.push(p256(unstringifyBigInts(cInput)))
|
|
49
49
|
}
|
|
50
50
|
// construct calldata
|
|
51
51
|
const calldata = {
|
package/src/helpers/crypto.ts
CHANGED
|
@@ -24,7 +24,11 @@ export const blake512FromPath = async (path: fs.PathLike): Promise<string> => {
|
|
|
24
24
|
|
|
25
25
|
const hash: string = await new Promise((resolve) => {
|
|
26
26
|
fs.createReadStream(path)
|
|
27
|
-
.on("data", (chunk: Buffer) => {
|
|
27
|
+
.on("data", (chunk: string | Buffer) => {
|
|
28
|
+
if (typeof chunk === "string") {
|
|
29
|
+
chunk = Buffer.from(chunk)
|
|
30
|
+
}
|
|
31
|
+
|
|
28
32
|
blake.blake2bUpdate(context, chunk)
|
|
29
33
|
})
|
|
30
34
|
.on("end", () => {
|
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/functions.ts
CHANGED
package/src/helpers/security.ts
CHANGED
|
@@ -16,14 +16,15 @@ const getGitHubStats = async (user: string): Promise<any> => {
|
|
|
16
16
|
|
|
17
17
|
const jsonData: any = await response.json()
|
|
18
18
|
|
|
19
|
-
const data
|
|
19
|
+
const data = {
|
|
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
|
-
return data
|
|
27
|
+
return data
|
|
27
28
|
}
|
|
28
29
|
|
|
29
30
|
/**
|
|
@@ -38,27 +39,29 @@ 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,
|
|
57
60
|
avatarUrl: ""
|
|
58
61
|
}
|
|
59
|
-
|
|
62
|
+
|
|
60
63
|
return {
|
|
61
64
|
reputable: true,
|
|
62
|
-
avatarUrl
|
|
65
|
+
avatarUrl
|
|
63
66
|
}
|
|
64
67
|
}
|