@stevenkellner/team-conduct-api 2.0.7 → 2.0.9

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.
@@ -94,7 +94,7 @@ class Firestore {
94
94
  }
95
95
  userAuthentication(id) {
96
96
  return this.base
97
- .collection('userAuthentications')
97
+ .collection('userAuthIds')
98
98
  .document(id);
99
99
  }
100
100
  /**
@@ -15,7 +15,7 @@ import { Fine, FineTemplate, Invitation, Person, Team, User } from '../types';
15
15
  * throughout the application.
16
16
  */
17
17
  export type FirestoreScheme = FirestoreDocument<never, {
18
- userAuthentications: FirestoreCollection<{
18
+ userAuthIds: FirestoreCollection<{
19
19
  [UserAuthId in string]: FirestoreDocument<User.Id>;
20
20
  }>;
21
21
  users: FirestoreCollection<{
@@ -26,12 +26,12 @@ type ExpectedUserRoles = UserRole | ExpectedUserRoles[] | {
26
26
  * 5. Ensures the person is signed in (has signInProperties)
27
27
  * 6. Verifies the person has the required roles
28
28
  *
29
- * @param rawUserId - The raw user ID string from authentication context (null if not authenticated)
29
+ * @param userAuthId - The raw user authentication ID string from authentication context (null if not authenticated)
30
30
  * @param teamId - The ID of the team to check membership and roles for
31
31
  * @param roles - The expected role requirements (supports AND/OR logic via ExpectedUserRoles)
32
32
  * @returns The validated User.Id if all checks pass
33
33
  * @throws {FunctionsError} 'unauthenticated' - If rawUserId is null
34
34
  * @throws {FunctionsError} 'permission-denied' - If any validation check fails
35
35
  */
36
- export declare function checkAuthentication(rawUserId: string | null, teamId: Team.Id, roles: ExpectedUserRoles): Promise<User.Id>;
36
+ export declare function checkAuthentication(userAuthId: string | null, teamId: Team.Id, roles: ExpectedUserRoles): Promise<User.Id>;
37
37
  export {};
@@ -30,20 +30,20 @@ function hasUserRoles(userRoles, expectedRoles) {
30
30
  * 5. Ensures the person is signed in (has signInProperties)
31
31
  * 6. Verifies the person has the required roles
32
32
  *
33
- * @param rawUserId - The raw user ID string from authentication context (null if not authenticated)
33
+ * @param userAuthId - The raw user authentication ID string from authentication context (null if not authenticated)
34
34
  * @param teamId - The ID of the team to check membership and roles for
35
35
  * @param roles - The expected role requirements (supports AND/OR logic via ExpectedUserRoles)
36
36
  * @returns The validated User.Id if all checks pass
37
37
  * @throws {FunctionsError} 'unauthenticated' - If rawUserId is null
38
38
  * @throws {FunctionsError} 'permission-denied' - If any validation check fails
39
39
  */
40
- async function checkAuthentication(rawUserId, teamId, roles) {
41
- if (rawUserId === null)
40
+ async function checkAuthentication(userAuthId, teamId, roles) {
41
+ if (userAuthId === null)
42
42
  throw new firebase_function_1.FunctionsError('unauthenticated', 'User is not authenticated');
43
- const userAuthenticationId = await Firestore_1.Firestore.shared.userAuthentication(rawUserId).snapshot();
44
- if (!userAuthenticationId.exists)
43
+ const userAuthSnapshot = await Firestore_1.Firestore.shared.userAuthentication(userAuthId).snapshot();
44
+ if (!userAuthSnapshot.exists)
45
45
  throw new firebase_function_1.FunctionsError('permission-denied', 'User authentication does not exist');
46
- const userId = types_1.User.Id.builder.build(userAuthenticationId.data);
46
+ const userId = types_1.User.Id.builder.build(userAuthSnapshot.data);
47
47
  const userSnapshot = await Firestore_1.Firestore.shared.user(userId).snapshot();
48
48
  if (!userSnapshot.exists)
49
49
  throw new firebase_function_1.FunctionsError('permission-denied', 'User does not exist');
@@ -19,7 +19,7 @@ const firebase_utils_1 = require("./firebase-utils");
19
19
  });
20
20
  (0, mocha_1.it)('should throw "permission-denied" if user authentication does not exist', async () => {
21
21
  (0, firebase_utils_1.configureFirebase)({
22
- userAuthentications: firebase_utils_1.Collection.docs({
22
+ userAuthIds: firebase_utils_1.Collection.docs({
23
23
  [userAuthId]: firebase_utils_1.Document.empty()
24
24
  })
25
25
  });
@@ -29,7 +29,7 @@ const firebase_utils_1 = require("./firebase-utils");
29
29
  });
30
30
  (0, mocha_1.it)('should throw "permission-denied" if user does not exist', async () => {
31
31
  (0, firebase_utils_1.configureFirebase)({
32
- userAuthentications: firebase_utils_1.Collection.docs({
32
+ userAuthIds: firebase_utils_1.Collection.docs({
33
33
  [userAuthId]: firebase_utils_1.Document.data(userId.value)
34
34
  }),
35
35
  users: firebase_utils_1.Collection.docs({
@@ -43,7 +43,7 @@ const firebase_utils_1 = require("./firebase-utils");
43
43
  (0, mocha_1.it)('should throw "permission-denied" if user is not a member of the team', async () => {
44
44
  const emptyTeams = new typescript_common_functionality_1.Dictionary(index_1.Team.Id.builder);
45
45
  (0, firebase_utils_1.configureFirebase)({
46
- userAuthentications: firebase_utils_1.Collection.docs({
46
+ userAuthIds: firebase_utils_1.Collection.docs({
47
47
  [userAuthId]: firebase_utils_1.Document.data(userId.value)
48
48
  }),
49
49
  users: firebase_utils_1.Collection.docs({
@@ -62,7 +62,7 @@ const firebase_utils_1 = require("./firebase-utils");
62
62
  personId: personId.guidString
63
63
  }));
64
64
  (0, firebase_utils_1.configureFirebase)({
65
- userAuthentications: firebase_utils_1.Collection.docs({
65
+ userAuthIds: firebase_utils_1.Collection.docs({
66
66
  [userAuthId]: firebase_utils_1.Document.data(userId.value)
67
67
  }),
68
68
  users: firebase_utils_1.Collection.docs({
@@ -88,7 +88,7 @@ const firebase_utils_1 = require("./firebase-utils");
88
88
  personId: personId.guidString
89
89
  }));
90
90
  (0, firebase_utils_1.configureFirebase)({
91
- userAuthentications: firebase_utils_1.Collection.docs({
91
+ userAuthIds: firebase_utils_1.Collection.docs({
92
92
  [userAuthId]: firebase_utils_1.Document.data(userId.value)
93
93
  }),
94
94
  users: firebase_utils_1.Collection.docs({
@@ -116,7 +116,7 @@ const firebase_utils_1 = require("./firebase-utils");
116
116
  personId: personId.guidString
117
117
  }));
118
118
  (0, firebase_utils_1.configureFirebase)({
119
- userAuthentications: firebase_utils_1.Collection.docs({
119
+ userAuthIds: firebase_utils_1.Collection.docs({
120
120
  [userAuthId]: firebase_utils_1.Document.data(userId.value)
121
121
  }),
122
122
  users: firebase_utils_1.Collection.docs({
@@ -142,7 +142,7 @@ const firebase_utils_1 = require("./firebase-utils");
142
142
  personId: personId.guidString
143
143
  }));
144
144
  (0, firebase_utils_1.configureFirebase)({
145
- userAuthentications: firebase_utils_1.Collection.docs({
145
+ userAuthIds: firebase_utils_1.Collection.docs({
146
146
  [userAuthId]: firebase_utils_1.Document.data(userId.value)
147
147
  }),
148
148
  users: firebase_utils_1.Collection.docs({
@@ -167,7 +167,7 @@ const firebase_utils_1 = require("./firebase-utils");
167
167
  personId: personId.guidString
168
168
  }));
169
169
  (0, firebase_utils_1.configureFirebase)({
170
- userAuthentications: firebase_utils_1.Collection.docs({
170
+ userAuthIds: firebase_utils_1.Collection.docs({
171
171
  [userAuthId]: firebase_utils_1.Document.data(userId.value)
172
172
  }),
173
173
  users: firebase_utils_1.Collection.docs({
@@ -193,7 +193,7 @@ const firebase_utils_1 = require("./firebase-utils");
193
193
  personId: personId.guidString
194
194
  }));
195
195
  (0, firebase_utils_1.configureFirebase)({
196
- userAuthentications: firebase_utils_1.Collection.docs({
196
+ userAuthIds: firebase_utils_1.Collection.docs({
197
197
  [userAuthId]: firebase_utils_1.Document.data(userId.value)
198
198
  }),
199
199
  users: firebase_utils_1.Collection.docs({
@@ -218,7 +218,7 @@ const firebase_utils_1 = require("./firebase-utils");
218
218
  personId: personId.guidString
219
219
  }));
220
220
  (0, firebase_utils_1.configureFirebase)({
221
- userAuthentications: firebase_utils_1.Collection.docs({
221
+ userAuthIds: firebase_utils_1.Collection.docs({
222
222
  [userAuthId]: firebase_utils_1.Document.data(userId.value)
223
223
  }),
224
224
  users: firebase_utils_1.Collection.docs({
@@ -243,7 +243,7 @@ const firebase_utils_1 = require("./firebase-utils");
243
243
  personId: personId.guidString
244
244
  }));
245
245
  (0, firebase_utils_1.configureFirebase)({
246
- userAuthentications: firebase_utils_1.Collection.docs({
246
+ userAuthIds: firebase_utils_1.Collection.docs({
247
247
  [userAuthId]: firebase_utils_1.Document.data(userId.value)
248
248
  }),
249
249
  users: firebase_utils_1.Collection.docs({
@@ -269,7 +269,7 @@ const firebase_utils_1 = require("./firebase-utils");
269
269
  personId: personId.guidString
270
270
  }));
271
271
  (0, firebase_utils_1.configureFirebase)({
272
- userAuthentications: firebase_utils_1.Collection.docs({
272
+ userAuthIds: firebase_utils_1.Collection.docs({
273
273
  [userAuthId]: firebase_utils_1.Document.data(userId.value)
274
274
  }),
275
275
  users: firebase_utils_1.Collection.docs({
@@ -297,7 +297,7 @@ const firebase_utils_1 = require("./firebase-utils");
297
297
  personId: personId.guidString
298
298
  }));
299
299
  (0, firebase_utils_1.configureFirebase)({
300
- userAuthentications: firebase_utils_1.Collection.docs({
300
+ userAuthIds: firebase_utils_1.Collection.docs({
301
301
  [userAuthId]: firebase_utils_1.Document.data(userId.value)
302
302
  }),
303
303
  users: firebase_utils_1.Collection.docs({
@@ -328,7 +328,7 @@ const firebase_utils_1 = require("./firebase-utils");
328
328
  personId: personId.guidString
329
329
  }));
330
330
  (0, firebase_utils_1.configureFirebase)({
331
- userAuthentications: firebase_utils_1.Collection.docs({
331
+ userAuthIds: firebase_utils_1.Collection.docs({
332
332
  [userAuthId]: firebase_utils_1.Document.data(userId.value)
333
333
  }),
334
334
  users: firebase_utils_1.Collection.docs({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stevenkellner/team-conduct-api",
3
- "version": "2.0.7",
3
+ "version": "2.0.9",
4
4
  "description": "Firebase API for Team Conduct",
5
5
  "license": "MIT",
6
6
  "author": "Steven Kellner",
@@ -101,7 +101,7 @@ export class Firestore {
101
101
 
102
102
  public userAuthentication(id: string): FirestoreDocument<User.Id> {
103
103
  return this.base
104
- .collection('userAuthentications')
104
+ .collection('userAuthIds')
105
105
  .document(id);
106
106
  }
107
107
 
@@ -16,7 +16,7 @@ import { Fine, FineTemplate, Invitation, Person, Team, User } from '../types';
16
16
  * throughout the application.
17
17
  */
18
18
  export type FirestoreScheme = FirestoreDocument<never, {
19
- userAuthentications: FirestoreCollection<{
19
+ userAuthIds: FirestoreCollection<{
20
20
  [UserAuthId in string]: FirestoreDocument<User.Id>
21
21
  }>,
22
22
  users: FirestoreCollection<{
@@ -50,21 +50,21 @@ function hasUserRoles(userRoles: UserRole[], expectedRoles: ExpectedUserRoles):
50
50
  * 5. Ensures the person is signed in (has signInProperties)
51
51
  * 6. Verifies the person has the required roles
52
52
  *
53
- * @param rawUserId - The raw user ID string from authentication context (null if not authenticated)
53
+ * @param userAuthId - The raw user authentication ID string from authentication context (null if not authenticated)
54
54
  * @param teamId - The ID of the team to check membership and roles for
55
55
  * @param roles - The expected role requirements (supports AND/OR logic via ExpectedUserRoles)
56
56
  * @returns The validated User.Id if all checks pass
57
57
  * @throws {FunctionsError} 'unauthenticated' - If rawUserId is null
58
58
  * @throws {FunctionsError} 'permission-denied' - If any validation check fails
59
59
  */
60
- export async function checkAuthentication(rawUserId: string | null, teamId: Team.Id, roles: ExpectedUserRoles): Promise<User.Id> {
61
- if (rawUserId === null)
60
+ export async function checkAuthentication(userAuthId: string | null, teamId: Team.Id, roles: ExpectedUserRoles): Promise<User.Id> {
61
+ if (userAuthId === null)
62
62
  throw new FunctionsError('unauthenticated', 'User is not authenticated');
63
63
 
64
- const userAuthenticationId = await Firestore.shared.userAuthentication(rawUserId).snapshot();
65
- if (!userAuthenticationId.exists)
64
+ const userAuthSnapshot = await Firestore.shared.userAuthentication(userAuthId).snapshot();
65
+ if (!userAuthSnapshot.exists)
66
66
  throw new FunctionsError('permission-denied', 'User authentication does not exist');
67
- const userId = User.Id.builder.build(userAuthenticationId.data);
67
+ const userId = User.Id.builder.build(userAuthSnapshot.data);
68
68
 
69
69
  const userSnapshot = await Firestore.shared.user(userId).snapshot();
70
70
  if (!userSnapshot.exists)