@stevenkellner/team-conduct-api 2.0.7 → 2.0.8
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.
|
@@ -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
|
|
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(
|
|
36
|
+
export declare function checkAuthentication(userAuthId: string | null, teamId: Team.Id, roles: ExpectedUserRoles): Promise<User.Id>;
|
|
37
37
|
export {};
|
|
@@ -30,17 +30,17 @@ 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
|
|
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(
|
|
41
|
-
if (
|
|
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(
|
|
43
|
+
const userAuthenticationId = await Firestore_1.Firestore.shared.userAuthentication(userAuthId).snapshot();
|
|
44
44
|
if (!userAuthenticationId.exists)
|
|
45
45
|
throw new firebase_function_1.FunctionsError('permission-denied', 'User authentication does not exist');
|
|
46
46
|
const userId = types_1.User.Id.builder.build(userAuthenticationId.data);
|
package/package.json
CHANGED
|
@@ -50,18 +50,18 @@ 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
|
|
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(
|
|
61
|
-
if (
|
|
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(
|
|
64
|
+
const userAuthenticationId = await Firestore.shared.userAuthentication(userAuthId).snapshot();
|
|
65
65
|
if (!userAuthenticationId.exists)
|
|
66
66
|
throw new FunctionsError('permission-denied', 'User authentication does not exist');
|
|
67
67
|
const userId = User.Id.builder.build(userAuthenticationId.data);
|