@dereekb/firebase-server 9.7.6 → 9.8.0
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/CHANGELOG.md +13 -0
- package/package.json +7 -7
- package/src/lib/auth/auth.service.d.ts +99 -5
- package/src/lib/auth/auth.service.js +154 -1
- package/src/lib/auth/auth.service.js.map +1 -1
- package/src/lib/auth/auth.util.d.ts +8 -0
- package/src/lib/auth/auth.util.js +27 -0
- package/src/lib/auth/auth.util.js.map +1 -0
- package/src/lib/auth/index.d.ts +1 -0
- package/src/lib/auth/index.js +1 -0
- package/src/lib/auth/index.js.map +1 -1
- package/test/CHANGELOG.md +8 -0
- package/test/package.json +10 -10
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,19 @@
|
|
|
2
2
|
|
|
3
3
|
This file was generated using [@jscutlery/semver](https://github.com/jscutlery/semver).
|
|
4
4
|
|
|
5
|
+
# [9.8.0](https://github.com/dereekb/dbx-components/compare/v9.7.7-dev...v9.8.0) (2022-09-15)
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
### Features
|
|
9
|
+
|
|
10
|
+
* added FirebaseServerNewUserService ([10d64dc](https://github.com/dereekb/dbx-components/commit/10d64dc137e533a62d7449709a93056741a840e4))
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
## [9.7.7](https://github.com/dereekb/dbx-components/compare/v9.7.6-dev...v9.7.7) (2022-09-12)
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
|
|
5
18
|
## [9.7.6](https://github.com/dereekb/dbx-components/compare/v9.7.5-dev...v9.7.6) (2022-09-12)
|
|
6
19
|
|
|
7
20
|
|
package/package.json
CHANGED
|
@@ -1,25 +1,25 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dereekb/firebase-server",
|
|
3
|
-
"version": "9.
|
|
3
|
+
"version": "9.8.0",
|
|
4
4
|
"devDependencies": {
|
|
5
5
|
"firebase-functions-test": "2.0.2"
|
|
6
6
|
},
|
|
7
7
|
"peerDependencies": {
|
|
8
8
|
"jsonwebtoken": "^8.0.0",
|
|
9
|
-
"@dereekb/firebase": "9.
|
|
9
|
+
"@dereekb/firebase": "9.8.0",
|
|
10
10
|
"rxjs": "^7.5.0",
|
|
11
11
|
"firebase": "^9.9.2",
|
|
12
|
-
"@dereekb/util": "9.
|
|
12
|
+
"@dereekb/util": "9.8.0",
|
|
13
13
|
"lodash.isequal": "^4.5.0",
|
|
14
14
|
"make-error": "^1.3.0",
|
|
15
15
|
"ts-essentials": "^9.1.2",
|
|
16
16
|
"extra-set": "^2.2.11",
|
|
17
|
-
"@dereekb/rxjs": "9.
|
|
17
|
+
"@dereekb/rxjs": "9.8.0",
|
|
18
18
|
"ms": "^3.0.0-canary.1",
|
|
19
|
-
"@dereekb/model": "9.
|
|
19
|
+
"@dereekb/model": "9.8.0",
|
|
20
20
|
"class-transformer": "^0.5.1",
|
|
21
21
|
"class-validator": "^0.13.2",
|
|
22
|
-
"@dereekb/date": "9.
|
|
22
|
+
"@dereekb/date": "9.8.0",
|
|
23
23
|
"date-fns": "^2.29.0",
|
|
24
24
|
"date-fns-tz": "^1.3.0",
|
|
25
25
|
"rrule": "git+https://git@github.com/dereekb/rrule#2b13b1ea881059ba2ecfec380e12ef244ef54570",
|
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
"@nestjs/common": "^9.0.0",
|
|
31
31
|
"@nestjs/core": "^9.0.0",
|
|
32
32
|
"@nestjs/platform-express": "^9.0.0",
|
|
33
|
-
"@dereekb/nestjs": "9.
|
|
33
|
+
"@dereekb/nestjs": "9.8.0",
|
|
34
34
|
"@nestjs/config": "^2.0.1",
|
|
35
35
|
"tslib": "^2.0.0"
|
|
36
36
|
},
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as functions from 'firebase-functions';
|
|
2
2
|
import * as admin from 'firebase-admin';
|
|
3
3
|
import { FirebaseAuthContextInfo, FirebaseAuthUserId } from '@dereekb/firebase';
|
|
4
|
-
import { AuthClaims, AuthRoleSet, ArrayOrValue, AuthRole, AuthClaimsUpdate, AuthClaimsObject, Maybe } from '@dereekb/util';
|
|
4
|
+
import { ISO8601DateString, Milliseconds, AuthClaims, AuthRoleSet, ArrayOrValue, AuthRole, AuthClaimsUpdate, AuthClaimsObject, Maybe, EmailAddress, E164PhoneNumber, PasswordString } from '@dereekb/util';
|
|
5
5
|
import { CallableContextWithAuthData } from '../function/context';
|
|
6
6
|
import { AuthDataRef } from './auth.context';
|
|
7
7
|
export interface FirebaseServerAuthUserIdentifierContext {
|
|
@@ -11,6 +11,10 @@ export interface FirebaseServerAuthUserIdentifierContext {
|
|
|
11
11
|
readonly uid: FirebaseAuthUserId;
|
|
12
12
|
}
|
|
13
13
|
export interface FirebaseServerAuthUserContext extends FirebaseServerAuthUserIdentifierContext {
|
|
14
|
+
/**
|
|
15
|
+
* Returns true if the user exists.
|
|
16
|
+
*/
|
|
17
|
+
exists(): Promise<boolean>;
|
|
14
18
|
/**
|
|
15
19
|
* Loads the record of the user.
|
|
16
20
|
*/
|
|
@@ -48,13 +52,13 @@ export interface FirebaseServerAuthUserContext extends FirebaseServerAuthUserIde
|
|
|
48
52
|
*
|
|
49
53
|
* @param claims
|
|
50
54
|
*/
|
|
51
|
-
updateClaims(claims: AuthClaimsUpdate): Promise<void>;
|
|
55
|
+
updateClaims<T extends AuthClaimsObject = AuthClaimsObject>(claims: AuthClaimsUpdate<T>): Promise<void>;
|
|
52
56
|
/**
|
|
53
57
|
* Sets the claims for a user. All previous claims are cleared.
|
|
54
58
|
*
|
|
55
59
|
* @param claims
|
|
56
60
|
*/
|
|
57
|
-
setClaims(claims: AuthClaimsUpdate): Promise<void>;
|
|
61
|
+
setClaims<T extends AuthClaimsObject = AuthClaimsObject>(claims: AuthClaimsUpdate<T>): Promise<void>;
|
|
58
62
|
/**
|
|
59
63
|
* Clears all claims for the user.
|
|
60
64
|
*
|
|
@@ -67,6 +71,7 @@ export declare abstract class AbstractFirebaseServerAuthUserContext<S extends Fi
|
|
|
67
71
|
readonly uid: FirebaseAuthUserId;
|
|
68
72
|
private readonly _loadRecord;
|
|
69
73
|
constructor(service: S, uid: FirebaseAuthUserId);
|
|
74
|
+
exists(): Promise<boolean>;
|
|
70
75
|
loadRecord(): Promise<admin.auth.UserRecord>;
|
|
71
76
|
loadRoles(): Promise<AuthRoleSet>;
|
|
72
77
|
addRoles(roles: ArrayOrValue<AuthRole>): Promise<void>;
|
|
@@ -78,9 +83,9 @@ export declare abstract class AbstractFirebaseServerAuthUserContext<S extends Fi
|
|
|
78
83
|
[x: symbol]: null;
|
|
79
84
|
}>;
|
|
80
85
|
loadClaims<T extends AuthClaimsObject = AuthClaimsObject>(): Promise<AuthClaims<T>>;
|
|
81
|
-
updateClaims(claims: AuthClaimsUpdate): Promise<void>;
|
|
86
|
+
updateClaims<T extends AuthClaimsObject = AuthClaimsObject>(claims: AuthClaimsUpdate<T>): Promise<void>;
|
|
82
87
|
clearClaims(): Promise<void>;
|
|
83
|
-
setClaims(claims: AuthClaimsUpdate | null): Promise<void>;
|
|
88
|
+
setClaims<T extends AuthClaimsObject = AuthClaimsObject>(claims: AuthClaimsUpdate<T> | null): Promise<void>;
|
|
84
89
|
}
|
|
85
90
|
export interface FirebaseServerAuthContext<U extends FirebaseServerAuthUserContext = FirebaseServerAuthUserContext> extends FirebaseServerAuthUserIdentifierContext {
|
|
86
91
|
/**
|
|
@@ -128,6 +133,90 @@ export declare abstract class AbstractFirebaseServerAuthContext<C extends Fireba
|
|
|
128
133
|
get claims(): AuthClaims;
|
|
129
134
|
get uid(): string;
|
|
130
135
|
}
|
|
136
|
+
export declare const FIREBASE_SERVER_AUTH_CLAIMS_SETUP_PASSWORD_KEY = "setupPassword";
|
|
137
|
+
export declare const FIREBASE_SERVER_AUTH_CLAIMS_SETUP_LAST_COM_DATE_KEY = "setupCommunicationAt";
|
|
138
|
+
/**
|
|
139
|
+
* Password used for completing setup.
|
|
140
|
+
*/
|
|
141
|
+
export declare type FirebaseServerAuthSetupPassword = PasswordString;
|
|
142
|
+
export interface FirebaseServerAuthNewUserClaims extends AuthClaimsObject {
|
|
143
|
+
/**
|
|
144
|
+
* Setup password time
|
|
145
|
+
*/
|
|
146
|
+
setupPassword: FirebaseServerAuthSetupPassword;
|
|
147
|
+
/**
|
|
148
|
+
* Last setup communication time.
|
|
149
|
+
*/
|
|
150
|
+
setupCommunicationAt: ISO8601DateString;
|
|
151
|
+
}
|
|
152
|
+
export interface FirebaseServerAuthInitializeNewUser {
|
|
153
|
+
/**
|
|
154
|
+
* Specific user identifier to use.
|
|
155
|
+
*/
|
|
156
|
+
readonly uid?: FirebaseAuthUserId;
|
|
157
|
+
/**
|
|
158
|
+
* Email for the new user, if applicable.
|
|
159
|
+
*/
|
|
160
|
+
readonly email?: EmailAddress;
|
|
161
|
+
/**
|
|
162
|
+
* Phone for the new user, if applicable.
|
|
163
|
+
*/
|
|
164
|
+
readonly phone?: E164PhoneNumber;
|
|
165
|
+
/**
|
|
166
|
+
* Password to set on the user if not created yet.
|
|
167
|
+
*
|
|
168
|
+
* This is a setup password and should not be the user's permenant/final password.
|
|
169
|
+
*/
|
|
170
|
+
readonly setupPassword?: FirebaseServerAuthSetupPassword;
|
|
171
|
+
/**
|
|
172
|
+
* Whether or not to send a setup email. Is true by default.
|
|
173
|
+
*/
|
|
174
|
+
readonly sendSetupContent?: boolean;
|
|
175
|
+
}
|
|
176
|
+
export interface FirebaseServerAuthCreateNewUserResult {
|
|
177
|
+
readonly user: admin.auth.UserRecord;
|
|
178
|
+
readonly password: FirebaseServerAuthSetupPassword;
|
|
179
|
+
}
|
|
180
|
+
export interface FirebaseServerAuthNewUserSetupDetails<U extends FirebaseServerAuthUserContext = FirebaseServerAuthUserContext> {
|
|
181
|
+
readonly userContext: U;
|
|
182
|
+
readonly claims: FirebaseServerAuthNewUserClaims;
|
|
183
|
+
}
|
|
184
|
+
export interface FirebaseServerNewUserService {
|
|
185
|
+
initializeNewUser(input: FirebaseServerAuthInitializeNewUser): Promise<admin.auth.UserRecord>;
|
|
186
|
+
sendSetupContent(uid: FirebaseAuthUserId): Promise<boolean>;
|
|
187
|
+
markUserSetupAsComplete(uid: FirebaseAuthUserId): Promise<boolean>;
|
|
188
|
+
}
|
|
189
|
+
export declare const DEFAULT_FIREBASE_PASSWORD_NUMBER_GENERATOR: import("@dereekb/util").RandomNumberFactory;
|
|
190
|
+
export declare const DEFAULT_SETUP_COM_THROTTLE_TIME: number;
|
|
191
|
+
export declare abstract class AbstractFirebaseServerNewUserService<U extends FirebaseServerAuthUserContext = FirebaseServerAuthUserContext, C extends FirebaseServerAuthContext = FirebaseServerAuthContext> implements FirebaseServerNewUserService {
|
|
192
|
+
readonly authService: FirebaseServerAuthService<U, C>;
|
|
193
|
+
protected setupThrottleTime: Milliseconds;
|
|
194
|
+
constructor(authService: FirebaseServerAuthService<U, C>);
|
|
195
|
+
initializeNewUser(input: FirebaseServerAuthInitializeNewUser): Promise<admin.auth.UserRecord>;
|
|
196
|
+
/**
|
|
197
|
+
* Sends the setup content to the user. Returns true if content was sent or was already recently sent.
|
|
198
|
+
*
|
|
199
|
+
* @param uid
|
|
200
|
+
*/
|
|
201
|
+
sendSetupContent(uid: FirebaseAuthUserId): Promise<boolean>;
|
|
202
|
+
loadSetupDetails(uid: FirebaseAuthUserId): Promise<Maybe<FirebaseServerAuthNewUserSetupDetails<U>>>;
|
|
203
|
+
protected updateSetupContentSentTime(details: FirebaseServerAuthNewUserSetupDetails<U>): Promise<void>;
|
|
204
|
+
/**
|
|
205
|
+
* Update a user's claims to clear any setup-related content.
|
|
206
|
+
*
|
|
207
|
+
* Returns true if a user was updated.
|
|
208
|
+
*
|
|
209
|
+
* @param uid
|
|
210
|
+
*/
|
|
211
|
+
markUserSetupAsComplete(uid: FirebaseAuthUserId): Promise<boolean>;
|
|
212
|
+
protected createNewUser(input: FirebaseServerAuthInitializeNewUser): Promise<FirebaseServerAuthCreateNewUserResult>;
|
|
213
|
+
protected generateRandomSetupPassword(): FirebaseServerAuthSetupPassword;
|
|
214
|
+
protected abstract sendSetupContentToUser(user: Maybe<FirebaseServerAuthNewUserSetupDetails<U>>): Promise<void>;
|
|
215
|
+
protected updateClaimsToClearUser(userContext: U): Promise<void>;
|
|
216
|
+
}
|
|
217
|
+
export declare class NoSetupContentFirebaseServerNewUserService<U extends FirebaseServerAuthUserContext = FirebaseServerAuthUserContext> extends AbstractFirebaseServerNewUserService<U> {
|
|
218
|
+
protected sendSetupContentToUser(user: Maybe<FirebaseServerAuthNewUserSetupDetails<U>>): Promise<void>;
|
|
219
|
+
}
|
|
131
220
|
/**
|
|
132
221
|
* Reference to a FirebaseServerAuthService
|
|
133
222
|
*/
|
|
@@ -199,6 +288,10 @@ export declare abstract class FirebaseServerAuthService<U extends FirebaseServer
|
|
|
199
288
|
* @param context
|
|
200
289
|
*/
|
|
201
290
|
abstract authContextInfo(context: AuthDataRef): Maybe<FirebaseAuthContextInfo>;
|
|
291
|
+
/**
|
|
292
|
+
* Returns the new user service to create a new user programmatically.
|
|
293
|
+
*/
|
|
294
|
+
abstract newUser(): FirebaseServerNewUserService;
|
|
202
295
|
}
|
|
203
296
|
/**
|
|
204
297
|
* Abstract FirebaseServerAuthService implementation.
|
|
@@ -215,5 +308,6 @@ export declare abstract class AbstractFirebaseServerAuthService<U extends Fireba
|
|
|
215
308
|
hasSignedTosInRoles(roles: AuthRoleSet): boolean;
|
|
216
309
|
abstract readRoles(claims: AuthClaims): AuthRoleSet;
|
|
217
310
|
abstract claimsForRoles(roles: AuthRoleSet): AuthClaimsUpdate;
|
|
311
|
+
newUser(): FirebaseServerNewUserService;
|
|
218
312
|
authContextInfo(context: AuthDataRef): Maybe<FirebaseAuthContextInfo>;
|
|
219
313
|
}
|
|
@@ -1,16 +1,23 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.AbstractFirebaseServerAuthService = exports.FirebaseServerAuthService = exports.AbstractFirebaseServerAuthContext = exports.AbstractFirebaseServerAuthUserContext = void 0;
|
|
3
|
+
exports.AbstractFirebaseServerAuthService = exports.FirebaseServerAuthService = exports.NoSetupContentFirebaseServerNewUserService = exports.AbstractFirebaseServerNewUserService = exports.DEFAULT_SETUP_COM_THROTTLE_TIME = exports.DEFAULT_FIREBASE_PASSWORD_NUMBER_GENERATOR = exports.FIREBASE_SERVER_AUTH_CLAIMS_SETUP_LAST_COM_DATE_KEY = exports.FIREBASE_SERVER_AUTH_CLAIMS_SETUP_PASSWORD_KEY = exports.AbstractFirebaseServerAuthContext = exports.AbstractFirebaseServerAuthUserContext = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
const util_1 = require("@dereekb/util");
|
|
6
6
|
const context_1 = require("../function/context");
|
|
7
7
|
const auth_context_1 = require("./auth.context");
|
|
8
|
+
const date_1 = require("@dereekb/date");
|
|
9
|
+
const auth_util_1 = require("./auth.util");
|
|
8
10
|
class AbstractFirebaseServerAuthUserContext {
|
|
9
11
|
constructor(service, uid) {
|
|
10
12
|
this.service = service;
|
|
11
13
|
this.uid = uid;
|
|
12
14
|
this._loadRecord = (0, util_1.cachedGetter)(() => this.service.auth.getUser(this.uid));
|
|
13
15
|
}
|
|
16
|
+
exists() {
|
|
17
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
18
|
+
return (0, auth_util_1.getAuthUserOrUndefined)(this._loadRecord()).then((x) => Boolean(x));
|
|
19
|
+
});
|
|
20
|
+
}
|
|
14
21
|
loadRecord() {
|
|
15
22
|
return this._loadRecord();
|
|
16
23
|
}
|
|
@@ -109,6 +116,149 @@ class AbstractFirebaseServerAuthContext {
|
|
|
109
116
|
}
|
|
110
117
|
}
|
|
111
118
|
exports.AbstractFirebaseServerAuthContext = AbstractFirebaseServerAuthContext;
|
|
119
|
+
// MARK: New Account Initialization
|
|
120
|
+
exports.FIREBASE_SERVER_AUTH_CLAIMS_SETUP_PASSWORD_KEY = 'setupPassword';
|
|
121
|
+
exports.FIREBASE_SERVER_AUTH_CLAIMS_SETUP_LAST_COM_DATE_KEY = 'setupCommunicationAt';
|
|
122
|
+
exports.DEFAULT_FIREBASE_PASSWORD_NUMBER_GENERATOR = (0, util_1.randomNumberFactory)({ min: 100000, max: 1000000 - 1 });
|
|
123
|
+
exports.DEFAULT_SETUP_COM_THROTTLE_TIME = (0, date_1.hoursToMs)(1);
|
|
124
|
+
class AbstractFirebaseServerNewUserService {
|
|
125
|
+
constructor(authService) {
|
|
126
|
+
this.authService = authService;
|
|
127
|
+
this.setupThrottleTime = exports.DEFAULT_SETUP_COM_THROTTLE_TIME;
|
|
128
|
+
}
|
|
129
|
+
initializeNewUser(input) {
|
|
130
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
131
|
+
const { uid, email, phone, sendSetupContent: sendSetupEmail } = input;
|
|
132
|
+
let userRecordPromise;
|
|
133
|
+
if (uid) {
|
|
134
|
+
userRecordPromise = this.authService.auth.getUser(uid);
|
|
135
|
+
}
|
|
136
|
+
else if (email) {
|
|
137
|
+
userRecordPromise = this.authService.auth.getUserByEmail(email);
|
|
138
|
+
}
|
|
139
|
+
else if (phone) {
|
|
140
|
+
userRecordPromise = this.authService.auth.getUserByPhoneNumber(phone);
|
|
141
|
+
}
|
|
142
|
+
else {
|
|
143
|
+
throw new Error('email or phone is required to initialize a new user.');
|
|
144
|
+
}
|
|
145
|
+
let userRecord = yield (0, auth_util_1.getAuthUserOrUndefined)(userRecordPromise);
|
|
146
|
+
if (!userRecord) {
|
|
147
|
+
const createResult = yield this.createNewUser(input);
|
|
148
|
+
// add the setup password to the user's credentials
|
|
149
|
+
const userContext = this.authService.userContext(createResult.user.uid);
|
|
150
|
+
yield userContext.updateClaims({
|
|
151
|
+
[exports.FIREBASE_SERVER_AUTH_CLAIMS_SETUP_PASSWORD_KEY]: createResult.password
|
|
152
|
+
});
|
|
153
|
+
if (sendSetupEmail !== false) {
|
|
154
|
+
yield this.sendSetupContent(createResult.user.uid);
|
|
155
|
+
}
|
|
156
|
+
// return the new record
|
|
157
|
+
userRecord = yield userContext.loadRecord();
|
|
158
|
+
}
|
|
159
|
+
return userRecord;
|
|
160
|
+
});
|
|
161
|
+
}
|
|
162
|
+
/**
|
|
163
|
+
* Sends the setup content to the user. Returns true if content was sent or was already recently sent.
|
|
164
|
+
*
|
|
165
|
+
* @param uid
|
|
166
|
+
*/
|
|
167
|
+
sendSetupContent(uid) {
|
|
168
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
169
|
+
const setupDetails = yield this.loadSetupDetails(uid);
|
|
170
|
+
if (setupDetails) {
|
|
171
|
+
const { setupCommunicationAt } = setupDetails.claims;
|
|
172
|
+
if (!setupCommunicationAt || (0, date_1.timeHasExpired)(new Date(setupCommunicationAt), this.setupThrottleTime)) {
|
|
173
|
+
yield this.sendSetupContentToUser(setupDetails);
|
|
174
|
+
yield this.updateSetupContentSentTime(setupDetails);
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
return false;
|
|
178
|
+
});
|
|
179
|
+
}
|
|
180
|
+
loadSetupDetails(uid) {
|
|
181
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
182
|
+
const userContext = this.authService.userContext(uid);
|
|
183
|
+
const userExists = yield userContext.exists();
|
|
184
|
+
let details;
|
|
185
|
+
if (userExists) {
|
|
186
|
+
const { setupPassword, setupCommunicationAt } = yield userContext.loadClaims();
|
|
187
|
+
if (setupPassword) {
|
|
188
|
+
details = {
|
|
189
|
+
userContext,
|
|
190
|
+
claims: {
|
|
191
|
+
setupPassword,
|
|
192
|
+
setupCommunicationAt
|
|
193
|
+
}
|
|
194
|
+
};
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
return details;
|
|
198
|
+
});
|
|
199
|
+
}
|
|
200
|
+
updateSetupContentSentTime(details) {
|
|
201
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
202
|
+
yield details.userContext.updateClaims({
|
|
203
|
+
setupCommunicationAt: (0, date_1.toISODateString)(new Date())
|
|
204
|
+
});
|
|
205
|
+
});
|
|
206
|
+
}
|
|
207
|
+
/**
|
|
208
|
+
* Update a user's claims to clear any setup-related content.
|
|
209
|
+
*
|
|
210
|
+
* Returns true if a user was updated.
|
|
211
|
+
*
|
|
212
|
+
* @param uid
|
|
213
|
+
*/
|
|
214
|
+
markUserSetupAsComplete(uid) {
|
|
215
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
216
|
+
const userContext = this.authService.userContext(uid);
|
|
217
|
+
const userExists = yield userContext.exists();
|
|
218
|
+
if (userExists) {
|
|
219
|
+
yield this.updateClaimsToClearUser(userContext);
|
|
220
|
+
}
|
|
221
|
+
return userExists;
|
|
222
|
+
});
|
|
223
|
+
}
|
|
224
|
+
createNewUser(input) {
|
|
225
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
226
|
+
const { uid, email, phone: phoneNumber, setupPassword: inputPassword } = input;
|
|
227
|
+
const password = inputPassword !== null && inputPassword !== void 0 ? inputPassword : this.generateRandomSetupPassword();
|
|
228
|
+
const user = yield this.authService.auth.createUser({
|
|
229
|
+
uid,
|
|
230
|
+
email,
|
|
231
|
+
phoneNumber,
|
|
232
|
+
password
|
|
233
|
+
});
|
|
234
|
+
return {
|
|
235
|
+
user,
|
|
236
|
+
password
|
|
237
|
+
};
|
|
238
|
+
});
|
|
239
|
+
}
|
|
240
|
+
generateRandomSetupPassword() {
|
|
241
|
+
const x = (0, exports.DEFAULT_FIREBASE_PASSWORD_NUMBER_GENERATOR)();
|
|
242
|
+
return `${x}`;
|
|
243
|
+
}
|
|
244
|
+
updateClaimsToClearUser(userContext) {
|
|
245
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
246
|
+
yield userContext.updateClaims({
|
|
247
|
+
[exports.FIREBASE_SERVER_AUTH_CLAIMS_SETUP_PASSWORD_KEY]: null,
|
|
248
|
+
[exports.FIREBASE_SERVER_AUTH_CLAIMS_SETUP_LAST_COM_DATE_KEY]: null
|
|
249
|
+
});
|
|
250
|
+
});
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
exports.AbstractFirebaseServerNewUserService = AbstractFirebaseServerNewUserService;
|
|
254
|
+
class NoSetupContentFirebaseServerNewUserService extends AbstractFirebaseServerNewUserService {
|
|
255
|
+
sendSetupContentToUser(user) {
|
|
256
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
257
|
+
// send nothing.
|
|
258
|
+
});
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
exports.NoSetupContentFirebaseServerNewUserService = NoSetupContentFirebaseServerNewUserService;
|
|
112
262
|
/**
|
|
113
263
|
* FirebaseServer auth service that provides accessors to auth-related components.
|
|
114
264
|
*/
|
|
@@ -138,6 +288,9 @@ class AbstractFirebaseServerAuthService {
|
|
|
138
288
|
hasSignedTosInRoles(roles) {
|
|
139
289
|
return roles.has(util_1.AUTH_TOS_SIGNED_ROLE);
|
|
140
290
|
}
|
|
291
|
+
newUser() {
|
|
292
|
+
return new NoSetupContentFirebaseServerNewUserService(this);
|
|
293
|
+
}
|
|
141
294
|
authContextInfo(context) {
|
|
142
295
|
const { auth } = context;
|
|
143
296
|
let result;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"auth.service.js","sourceRoot":"","sources":["../../../../../../packages/firebase-server/src/lib/auth/auth.service.ts"],"names":[],"mappings":";;;;AAGA,
|
|
1
|
+
{"version":3,"file":"auth.service.js","sourceRoot":"","sources":["../../../../../../packages/firebase-server/src/lib/auth/auth.service.ts"],"names":[],"mappings":";;;;AAGA,wCAAuY;AACvY,iDAA+F;AAC/F,iDAAkF;AAClF,wCAAuF;AACvF,2CAAqD;AA2ErD,MAAsB,qCAAqC;IAGzD,YAAqB,OAAU,EAAW,GAAuB;QAA5C,YAAO,GAAP,OAAO,CAAG;QAAW,QAAG,GAAH,GAAG,CAAoB;QAFhD,gBAAW,GAAG,IAAA,mBAAY,EA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YACR,MAAM,MAAM,GAAG,IAAA,mBAAY,EAAC,GAAG,EAAE,CAAC,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,KAA8B,CAAC,CAAC,CAAC;YACvF,MAAM,SAAS,GAAG,GAAkD,EAAE,CAAC,IAAI,CAAC,KAAiC,CAAC;YAE9G,MAAM,GAAG;gBACP,GAAG,EAAE,IAAI,CAAC,GAAG;gBACb,OAAO,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,cAAc,CAAC,MAAM,EAAE,CAAC;gBAC5C,SAAS;gBACT,YAAY,EAAE,MAAM;gBACpB,KAAK,EAAE,IAAA,kDAAmC,EAAC,IAAI,CAAC,KAAK,CAAC;aACvD,CAAC;SACH;QAED,OAAO,MAAM,CAAC;IAChB,CAAC;CACF;AAvDD,8EAuDC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { Maybe } from '@dereekb/util';
|
|
2
|
+
import * as admin from 'firebase-admin';
|
|
3
|
+
/**
|
|
4
|
+
* Awaits the load result from the input promise. If it encounters a FIREBASE_AUTH_USER_NOT_FOUND_ERROR, then returns undefined. Throws the error otherwise.
|
|
5
|
+
* @param promise
|
|
6
|
+
* @returns
|
|
7
|
+
*/
|
|
8
|
+
export declare function getAuthUserOrUndefined(promise: Promise<admin.auth.UserRecord>): Promise<Maybe<admin.auth.UserRecord>>;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getAuthUserOrUndefined = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const firebase_1 = require("@dereekb/firebase");
|
|
6
|
+
/**
|
|
7
|
+
* Awaits the load result from the input promise. If it encounters a FIREBASE_AUTH_USER_NOT_FOUND_ERROR, then returns undefined. Throws the error otherwise.
|
|
8
|
+
* @param promise
|
|
9
|
+
* @returns
|
|
10
|
+
*/
|
|
11
|
+
function getAuthUserOrUndefined(promise) {
|
|
12
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
13
|
+
try {
|
|
14
|
+
return yield promise;
|
|
15
|
+
}
|
|
16
|
+
catch (error) {
|
|
17
|
+
if ((error === null || error === void 0 ? void 0 : error.code) === firebase_1.FIREBASE_AUTH_USER_NOT_FOUND_ERROR) {
|
|
18
|
+
return undefined;
|
|
19
|
+
}
|
|
20
|
+
else {
|
|
21
|
+
throw error;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
exports.getAuthUserOrUndefined = getAuthUserOrUndefined;
|
|
27
|
+
//# sourceMappingURL=auth.util.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"auth.util.js","sourceRoot":"","sources":["../../../../../../packages/firebase-server/src/lib/auth/auth.util.ts"],"names":[],"mappings":";;;;AAAA,gDAA0F;AAI1F;;;;GAIG;AACH,SAAsB,sBAAsB,CAAC,OAAuC;;QAClF,IAAI;YACF,OAAO,MAAM,OAAO,CAAC;SACtB;QAAC,OAAO,KAAc,EAAE;YACvB,IAAI,CAAC,KAA2B,aAA3B,KAAK,uBAAL,KAAK,CAAwB,IAAI,MAAK,6CAAkC,EAAE;gBAC7E,OAAO,SAAS,CAAC;aAClB;iBAAM;gBACL,MAAM,KAAK,CAAC;aACb;SACF;IACH,CAAC;CAAA;AAVD,wDAUC"}
|
package/src/lib/auth/index.d.ts
CHANGED
package/src/lib/auth/index.js
CHANGED
|
@@ -3,4 +3,5 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
const tslib_1 = require("tslib");
|
|
4
4
|
tslib_1.__exportStar(require("./auth.service"), exports);
|
|
5
5
|
tslib_1.__exportStar(require("./auth.context"), exports);
|
|
6
|
+
tslib_1.__exportStar(require("./auth.util"), exports);
|
|
6
7
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../packages/firebase-server/src/lib/auth/index.ts"],"names":[],"mappings":";;;AAAA,yDAA+B;AAC/B,yDAA+B"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../packages/firebase-server/src/lib/auth/index.ts"],"names":[],"mappings":";;;AAAA,yDAA+B;AAC/B,yDAA+B;AAC/B,sDAA4B"}
|
package/test/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,14 @@
|
|
|
2
2
|
|
|
3
3
|
This file was generated using [@jscutlery/semver](https://github.com/jscutlery/semver).
|
|
4
4
|
|
|
5
|
+
# [9.8.0](https://github.com/dereekb/dbx-components/compare/v9.7.7-dev...v9.8.0) (2022-09-15)
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
## [9.7.7](https://github.com/dereekb/dbx-components/compare/v9.7.6-dev...v9.7.7) (2022-09-12)
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
5
13
|
## [9.7.6](https://github.com/dereekb/dbx-components/compare/v9.7.5-dev...v9.7.6) (2022-09-12)
|
|
6
14
|
|
|
7
15
|
|
package/test/package.json
CHANGED
|
@@ -1,40 +1,40 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dereekb/firebase-server/test",
|
|
3
|
-
"version": "9.
|
|
3
|
+
"version": "9.8.0",
|
|
4
4
|
"type": "commonjs",
|
|
5
5
|
"main": "./src/index.js",
|
|
6
6
|
"typings": "./src/index.d.ts",
|
|
7
7
|
"dependencies": {},
|
|
8
8
|
"peerDependencies": {
|
|
9
|
-
"@dereekb/firebase": "9.
|
|
9
|
+
"@dereekb/firebase": "9.8.0",
|
|
10
10
|
"rxjs": "^7.5.0",
|
|
11
11
|
"firebase": "^9.9.2",
|
|
12
|
-
"@dereekb/util": "9.
|
|
12
|
+
"@dereekb/util": "9.8.0",
|
|
13
13
|
"lodash.isequal": "^4.5.0",
|
|
14
14
|
"make-error": "^1.3.0",
|
|
15
15
|
"ts-essentials": "^9.1.2",
|
|
16
16
|
"extra-set": "^2.2.11",
|
|
17
|
-
"@dereekb/rxjs": "9.
|
|
17
|
+
"@dereekb/rxjs": "9.8.0",
|
|
18
18
|
"ms": "^3.0.0-canary.1",
|
|
19
|
-
"@dereekb/model": "9.
|
|
19
|
+
"@dereekb/model": "9.8.0",
|
|
20
20
|
"class-transformer": "^0.5.1",
|
|
21
21
|
"class-validator": "^0.13.2",
|
|
22
|
-
"@dereekb/date": "9.
|
|
22
|
+
"@dereekb/date": "9.8.0",
|
|
23
23
|
"date-fns": "^2.29.0",
|
|
24
24
|
"date-fns-tz": "^1.3.0",
|
|
25
25
|
"rrule": "git+https://git@github.com/dereekb/rrule#2b13b1ea881059ba2ecfec380e12ef244ef54570",
|
|
26
26
|
"@vvo/tzdb": "^6.56.0",
|
|
27
|
-
"@dereekb/util/test": "9.
|
|
27
|
+
"@dereekb/util/test": "9.8.0",
|
|
28
28
|
"firebase-admin": "^11.0.0",
|
|
29
29
|
"jsonwebtoken": "^8.0.0",
|
|
30
30
|
"firebase-functions": "^3.22.0",
|
|
31
31
|
"@nestjs/common": "^9.0.0",
|
|
32
32
|
"@google-cloud/firestore": "^5.0.2",
|
|
33
|
-
"@dereekb/firebase/test": "9.
|
|
34
|
-
"@dereekb/firebase-server": "9.
|
|
33
|
+
"@dereekb/firebase/test": "9.8.0",
|
|
34
|
+
"@dereekb/firebase-server": "9.8.0",
|
|
35
35
|
"@nestjs/core": "^9.0.0",
|
|
36
36
|
"@nestjs/platform-express": "^9.0.0",
|
|
37
|
-
"@dereekb/nestjs": "9.
|
|
37
|
+
"@dereekb/nestjs": "9.8.0",
|
|
38
38
|
"@nestjs/config": "^2.0.1",
|
|
39
39
|
"tslib": "^2.0.0"
|
|
40
40
|
}
|