@devtion/backend 0.0.0-7e983e3

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 (42) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +151 -0
  3. package/dist/src/functions/index.js +2644 -0
  4. package/dist/src/functions/index.mjs +2596 -0
  5. package/dist/types/functions/ceremony.d.ts +33 -0
  6. package/dist/types/functions/ceremony.d.ts.map +1 -0
  7. package/dist/types/functions/circuit.d.ts +63 -0
  8. package/dist/types/functions/circuit.d.ts.map +1 -0
  9. package/dist/types/functions/index.d.ts +7 -0
  10. package/dist/types/functions/index.d.ts.map +1 -0
  11. package/dist/types/functions/participant.d.ts +58 -0
  12. package/dist/types/functions/participant.d.ts.map +1 -0
  13. package/dist/types/functions/storage.d.ts +37 -0
  14. package/dist/types/functions/storage.d.ts.map +1 -0
  15. package/dist/types/functions/timeout.d.ts +26 -0
  16. package/dist/types/functions/timeout.d.ts.map +1 -0
  17. package/dist/types/functions/user.d.ts +15 -0
  18. package/dist/types/functions/user.d.ts.map +1 -0
  19. package/dist/types/lib/errors.d.ts +75 -0
  20. package/dist/types/lib/errors.d.ts.map +1 -0
  21. package/dist/types/lib/services.d.ts +9 -0
  22. package/dist/types/lib/services.d.ts.map +1 -0
  23. package/dist/types/lib/utils.d.ts +141 -0
  24. package/dist/types/lib/utils.d.ts.map +1 -0
  25. package/dist/types/types/enums.d.ts +13 -0
  26. package/dist/types/types/enums.d.ts.map +1 -0
  27. package/dist/types/types/index.d.ts +130 -0
  28. package/dist/types/types/index.d.ts.map +1 -0
  29. package/package.json +89 -0
  30. package/src/functions/ceremony.ts +333 -0
  31. package/src/functions/circuit.ts +1092 -0
  32. package/src/functions/index.ts +36 -0
  33. package/src/functions/participant.ts +526 -0
  34. package/src/functions/storage.ts +548 -0
  35. package/src/functions/timeout.ts +294 -0
  36. package/src/functions/user.ts +142 -0
  37. package/src/lib/errors.ts +237 -0
  38. package/src/lib/services.ts +28 -0
  39. package/src/lib/utils.ts +472 -0
  40. package/src/types/enums.ts +12 -0
  41. package/src/types/index.ts +140 -0
  42. package/test/index.test.ts +62 -0
@@ -0,0 +1,62 @@
1
+ import chai from "chai"
2
+ import chaiAsPromised from "chai-as-promised"
3
+ import admin from "firebase-admin"
4
+ import firebaseFncTest from "firebase-functions-test"
5
+ // Import the exported function definitions from our functions/index.js file
6
+ import { registerAuthUser } from "../src/functions/index"
7
+
8
+ // Config chai.
9
+ chai.use(chaiAsPromised)
10
+ const { assert } = chai
11
+
12
+ // Initialize the firebase-functions-test SDK using environment variables.
13
+ // These variables are automatically set by firebase emulators:exec
14
+ //
15
+ // This configuration will be used to initialize the Firebase Admin SDK, so
16
+ // when we use the Admin SDK in the tests below we can be confident it will
17
+ // communicate with the emulators, not production.
18
+
19
+ // TODO: make clear is running in production.
20
+ const test = firebaseFncTest({
21
+ databaseURL: process.env.FIREBASE_FIRESTORE_DATABASE_URL,
22
+ storageBucket: process.env.FIREBASE_STORAGE_BUCKET
23
+ })
24
+
25
+ describe("CF Unit Tests", () => {
26
+ // Sample data.
27
+ const userId = "0000000000000000000000000001"
28
+
29
+ afterAll(async () => {
30
+ // Remove user record.
31
+ await admin.firestore().collection("users").doc(userId).delete()
32
+
33
+ test.cleanup()
34
+ })
35
+
36
+ it.skip("should call an authorized CF and interact with Firestore", async () => {
37
+ const wrapped = test.wrap(registerAuthUser)
38
+
39
+ // Make a fake user to pass to the function
40
+ const displayName = "UserA"
41
+ const email = `user-${userId}@example.com`
42
+ const photoURL = `https://www...."`
43
+
44
+ const user = test.auth.makeUserRecord({
45
+ uid: userId,
46
+ displayName,
47
+ email,
48
+ photoURL
49
+ })
50
+
51
+ // Call the function
52
+ await wrapped(user)
53
+
54
+ // Check the data was written to the Firestore emulator
55
+ const snap = await admin.firestore().collection("users").doc(userId).get()
56
+ const data = snap.data()
57
+
58
+ assert.propertyVal(data, "name", displayName)
59
+ assert.propertyVal(data, "email", email)
60
+ assert.propertyVal(data, "photoURL", photoURL)
61
+ })
62
+ })