@brightnkhoma/auth 1.0.7 → 1.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.
@@ -1 +1 @@
1
- {"version":3,"file":"signIn.d.ts","sourceRoot":"","sources":["../../../src/authentication/aggregates/signIn.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAC;AACvC,OAAO,EAAC,OAAO,EAAC,QAAQ,EAAC,MAAM,SAAS,CAAA;AAExC,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAIrD,qBAAa,MAAO,SAAQ,UAAU;IACtB,OAAO,CAAC,QAAQ,CAAC,KAAK;IAAlC,YAA6B,KAAK,EAAG,MAAM,EAE1C;IACD,SAAS,WAMR;IACK,iBAAiB,mBAYtB;IACK,OAAO,mBAEZ;IAGD,MAAM,CAAC,QAAQ,UACY,OAAO,OAAQ,QAAQ,mBAcjD;IACD,MAAM,CAAC,EAAE,UACkB,OAAO,OAAQ,QAAQ,mBAUjD;CACJ"}
1
+ {"version":3,"file":"signIn.d.ts","sourceRoot":"","sources":["../../../src/authentication/aggregates/signIn.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAC;AACvC,OAAO,EAAC,OAAO,EAAC,QAAQ,EAAC,MAAM,SAAS,CAAA;AAExC,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAKrD,qBAAa,MAAO,SAAQ,UAAU;IACtB,OAAO,CAAC,QAAQ,CAAC,KAAK;IAAlC,YAA6B,KAAK,EAAG,MAAM,EAE1C;IACD,SAAS,WAMR;IACK,iBAAiB,mBAwCtB;IACK,OAAO,mBAEZ;IAGD,MAAM,CAAC,QAAQ,UACY,OAAO,OAAQ,QAAQ,mBAcjD;IACD,MAAM,CAAC,EAAE,UACkB,OAAO,OAAQ,QAAQ,mBAUjD;CACJ"}
package/dist/index.js CHANGED
@@ -4032,6 +4032,24 @@ var SignIn = class _SignIn extends UserDomain {
4032
4032
  async verifyUserIdToken() {
4033
4033
  const res = await auth.verifyIdToken(this.token);
4034
4034
  const uid = res.uid;
4035
+ const exists = await this.userDomain.exists(uid);
4036
+ if (!exists) {
4037
+ const { uid: uid2, email } = res;
4038
+ const name = res.name?.trim() || res.userName?.trim() || res.username?.trim() || [res.firstName, res.lastName].filter((part) => typeof part === "string" && part.trim().length > 0).map((part) => part.trim()).join(" ") || void 0;
4039
+ if (!name || !uid2 || !email) throw new Error("User not recognized");
4040
+ const user2 = {
4041
+ email,
4042
+ name,
4043
+ avatar: res?.picture,
4044
+ phoneNumber: res?.phone_number,
4045
+ id: uid2,
4046
+ dateCreated: "",
4047
+ dateUpdated: "",
4048
+ tags: [],
4049
+ createdBy: ""
4050
+ };
4051
+ await this.userDomain.add(user2);
4052
+ }
4035
4053
  await this.userDomain.set(uid);
4036
4054
  const user = this.userDomain.get();
4037
4055
  const secret = this.getSecret();
package/dist/index.mjs CHANGED
@@ -4021,6 +4021,24 @@ var SignIn = class _SignIn extends UserDomain {
4021
4021
  async verifyUserIdToken() {
4022
4022
  const res = await auth.verifyIdToken(this.token);
4023
4023
  const uid = res.uid;
4024
+ const exists = await this.userDomain.exists(uid);
4025
+ if (!exists) {
4026
+ const { uid: uid2, email } = res;
4027
+ const name = res.name?.trim() || res.userName?.trim() || res.username?.trim() || [res.firstName, res.lastName].filter((part) => typeof part === "string" && part.trim().length > 0).map((part) => part.trim()).join(" ") || void 0;
4028
+ if (!name || !uid2 || !email) throw new Error("User not recognized");
4029
+ const user2 = {
4030
+ email,
4031
+ name,
4032
+ avatar: res?.picture,
4033
+ phoneNumber: res?.phone_number,
4034
+ id: uid2,
4035
+ dateCreated: "",
4036
+ dateUpdated: "",
4037
+ tags: [],
4038
+ createdBy: ""
4039
+ };
4040
+ await this.userDomain.add(user2);
4041
+ }
4024
4042
  await this.userDomain.set(uid);
4025
4043
  const user = this.userDomain.get();
4026
4044
  const secret = this.getSecret();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@brightnkhoma/auth",
3
- "version": "1.0.7",
3
+ "version": "1.0.8",
4
4
  "description": "A module that automates CRUD functionality and routing and helps you follow DDD(Domain Driven Design) with ease using firebase, express and typescript",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.mjs",