akeyless-client-commons 1.0.48 → 1.0.50

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,6 +1,6 @@
1
1
  import { FirebaseApp } from 'firebase/app';
2
2
  import { FirebaseStorage } from 'firebase/storage';
3
- import { Auth, GoogleAuthProvider, UserCredential } from 'firebase/auth';
3
+ import { Auth, GoogleAuthProvider, User } from 'firebase/auth';
4
4
  import { AppCheck } from 'firebase/app-check';
5
5
  import { WhereFilterOp, Unsubscribe, Firestore, Timestamp, DocumentSnapshot, DocumentData, CollectionReference } from 'firebase/firestore';
6
6
  import { TObject, CountryOptions, NxUser, Client } from 'akeyless-types-commons';
@@ -47,7 +47,7 @@ declare const storage: FirebaseStorage;
47
47
  declare const app: FirebaseApp;
48
48
  declare const appCheck: AppCheck;
49
49
  declare const googleLoginProvider: GoogleAuthProvider;
50
- declare const useLoginWithGoogle: () => () => Promise<UserCredential>;
50
+ declare const useLoginWithGoogle: () => () => Promise<User>;
51
51
  interface Collections {
52
52
  [key: string]: CollectionReference<DocumentData>;
53
53
  clients: CollectionReference<DocumentData>;
@@ -135,11 +135,12 @@ declare const propsAreEqual: (prevProps: any, nextProps: any) => boolean;
135
135
  declare const getUserCountryByIp: () => Promise<CountryOptions>;
136
136
  declare const parsePermissions: (object: NxUser | Client) => TObject<TObject<boolean>>;
137
137
  interface InitializeUserPermissionsProps {
138
- phoneNumber: string;
138
+ phoneNumber?: string;
139
+ email?: string;
139
140
  firstTimeArray: string[];
140
141
  getUpdatePermissions: (permissions: TObject<TObject<boolean>>) => void;
141
142
  }
142
- declare const initializeUserPermissions: ({ phoneNumber, firstTimeArray, getUpdatePermissions }: InitializeUserPermissionsProps) => Promise<{
143
+ declare const initializeUserPermissions: ({ phoneNumber, email, firstTimeArray, getUpdatePermissions }: InitializeUserPermissionsProps) => Promise<{
143
144
  unsubscribe: () => void;
144
145
  permissions: TObject<TObject<boolean>>;
145
146
  }>;
@@ -1,6 +1,6 @@
1
1
  import { FirebaseApp } from 'firebase/app';
2
2
  import { FirebaseStorage } from 'firebase/storage';
3
- import { Auth, GoogleAuthProvider, UserCredential } from 'firebase/auth';
3
+ import { Auth, GoogleAuthProvider, User } from 'firebase/auth';
4
4
  import { AppCheck } from 'firebase/app-check';
5
5
  import { WhereFilterOp, Unsubscribe, Firestore, Timestamp, DocumentSnapshot, DocumentData, CollectionReference } from 'firebase/firestore';
6
6
  import { TObject, CountryOptions, NxUser, Client } from 'akeyless-types-commons';
@@ -47,7 +47,7 @@ declare const storage: FirebaseStorage;
47
47
  declare const app: FirebaseApp;
48
48
  declare const appCheck: AppCheck;
49
49
  declare const googleLoginProvider: GoogleAuthProvider;
50
- declare const useLoginWithGoogle: () => () => Promise<UserCredential>;
50
+ declare const useLoginWithGoogle: () => () => Promise<User>;
51
51
  interface Collections {
52
52
  [key: string]: CollectionReference<DocumentData>;
53
53
  clients: CollectionReference<DocumentData>;
@@ -135,11 +135,12 @@ declare const propsAreEqual: (prevProps: any, nextProps: any) => boolean;
135
135
  declare const getUserCountryByIp: () => Promise<CountryOptions>;
136
136
  declare const parsePermissions: (object: NxUser | Client) => TObject<TObject<boolean>>;
137
137
  interface InitializeUserPermissionsProps {
138
- phoneNumber: string;
138
+ phoneNumber?: string;
139
+ email?: string;
139
140
  firstTimeArray: string[];
140
141
  getUpdatePermissions: (permissions: TObject<TObject<boolean>>) => void;
141
142
  }
142
- declare const initializeUserPermissions: ({ phoneNumber, firstTimeArray, getUpdatePermissions }: InitializeUserPermissionsProps) => Promise<{
143
+ declare const initializeUserPermissions: ({ phoneNumber, email, firstTimeArray, getUpdatePermissions }: InitializeUserPermissionsProps) => Promise<{
143
144
  unsubscribe: () => void;
144
145
  permissions: TObject<TObject<boolean>>;
145
146
  }>;
@@ -585,7 +585,7 @@ var initApp = function() {
585
585
  var _initApp = initApp(), db = _initApp.db, auth = _initApp.auth, storage = _initApp.storage, app = _initApp.app, appCheck = _initApp.appCheck, googleLoginProvider = _initApp.googleLoginProvider;
586
586
  var useLoginWithGoogle = function() {
587
587
  var signInWithGoogle = (0, import_react.useCallback)(/*#__PURE__*/ _async_to_generator(function() {
588
- var result;
588
+ var result, user;
589
589
  return _ts_generator(this, function(_state) {
590
590
  switch(_state.label){
591
591
  case 0:
@@ -595,9 +595,10 @@ var useLoginWithGoogle = function() {
595
595
  ];
596
596
  case 1:
597
597
  result = _state.sent();
598
+ user = result.user;
598
599
  return [
599
600
  2,
600
- result
601
+ user
601
602
  ];
602
603
  }
603
604
  });
@@ -1497,11 +1498,11 @@ var parsePermissions = function(object) {
1497
1498
  };
1498
1499
  var initializeUserPermissions = /*#__PURE__*/ function() {
1499
1500
  var _ref = _async_to_generator(function(param) {
1500
- var phoneNumber, firstTimeArray, getUpdatePermissions, unsubscribe, permissions, _snapshot, promise, unsubscribeSnapshot, error;
1501
+ var phoneNumber, email, firstTimeArray, getUpdatePermissions, unsubscribe, permissions, queryConditions, _snapshot, promise, unsubscribeSnapshot, error;
1501
1502
  return _ts_generator(this, function(_state) {
1502
1503
  switch(_state.label){
1503
1504
  case 0:
1504
- phoneNumber = param.phoneNumber, firstTimeArray = param.firstTimeArray, getUpdatePermissions = param.getUpdatePermissions;
1505
+ phoneNumber = param.phoneNumber, email = param.email, firstTimeArray = param.firstTimeArray, getUpdatePermissions = param.getUpdatePermissions;
1505
1506
  unsubscribe = null;
1506
1507
  permissions = {};
1507
1508
  _state.label = 1;
@@ -1512,18 +1513,23 @@ var initializeUserPermissions = /*#__PURE__*/ function() {
1512
1513
  ,
1513
1514
  4
1514
1515
  ]);
1516
+ queryConditions = [
1517
+ phoneNumber ? {
1518
+ field_name: "phone_number",
1519
+ operator: "in",
1520
+ value: [
1521
+ phoneNumber,
1522
+ local_israel_phone_format(phoneNumber)
1523
+ ]
1524
+ } : {
1525
+ field_name: "email",
1526
+ operator: "==",
1527
+ value: email
1528
+ }
1529
+ ];
1515
1530
  _snapshot = snapshot({
1516
1531
  collectionName: "nx-users",
1517
- conditions: [
1518
- {
1519
- field_name: "phone_number",
1520
- operator: "in",
1521
- value: [
1522
- phoneNumber,
1523
- local_israel_phone_format(phoneNumber)
1524
- ]
1525
- }
1526
- ],
1532
+ conditions: queryConditions,
1527
1533
  onFirstTime: function(docs) {
1528
1534
  if (!docs.length) {
1529
1535
  throw new Error("User not found");
@@ -285,7 +285,7 @@ var initApp = function() {
285
285
  var _initApp = initApp(), db = _initApp.db, auth = _initApp.auth, storage = _initApp.storage, app = _initApp.app, appCheck = _initApp.appCheck, googleLoginProvider = _initApp.googleLoginProvider;
286
286
  var useLoginWithGoogle = function() {
287
287
  var signInWithGoogle = useCallback(/*#__PURE__*/ _async_to_generator(function() {
288
- var result;
288
+ var result, user;
289
289
  return _ts_generator(this, function(_state) {
290
290
  switch(_state.label){
291
291
  case 0:
@@ -295,9 +295,10 @@ var useLoginWithGoogle = function() {
295
295
  ];
296
296
  case 1:
297
297
  result = _state.sent();
298
+ user = result.user;
298
299
  return [
299
300
  2,
300
- result
301
+ user
301
302
  ];
302
303
  }
303
304
  });
@@ -1196,11 +1197,11 @@ var parsePermissions = function(object) {
1196
1197
  };
1197
1198
  var initializeUserPermissions = /*#__PURE__*/ function() {
1198
1199
  var _ref = _async_to_generator(function(param) {
1199
- var phoneNumber, firstTimeArray, getUpdatePermissions, unsubscribe, permissions, _snapshot, promise, unsubscribeSnapshot, error;
1200
+ var phoneNumber, email, firstTimeArray, getUpdatePermissions, unsubscribe, permissions, queryConditions, _snapshot, promise, unsubscribeSnapshot, error;
1200
1201
  return _ts_generator(this, function(_state) {
1201
1202
  switch(_state.label){
1202
1203
  case 0:
1203
- phoneNumber = param.phoneNumber, firstTimeArray = param.firstTimeArray, getUpdatePermissions = param.getUpdatePermissions;
1204
+ phoneNumber = param.phoneNumber, email = param.email, firstTimeArray = param.firstTimeArray, getUpdatePermissions = param.getUpdatePermissions;
1204
1205
  unsubscribe = null;
1205
1206
  permissions = {};
1206
1207
  _state.label = 1;
@@ -1211,18 +1212,23 @@ var initializeUserPermissions = /*#__PURE__*/ function() {
1211
1212
  ,
1212
1213
  4
1213
1214
  ]);
1215
+ queryConditions = [
1216
+ phoneNumber ? {
1217
+ field_name: "phone_number",
1218
+ operator: "in",
1219
+ value: [
1220
+ phoneNumber,
1221
+ local_israel_phone_format(phoneNumber)
1222
+ ]
1223
+ } : {
1224
+ field_name: "email",
1225
+ operator: "==",
1226
+ value: email
1227
+ }
1228
+ ];
1214
1229
  _snapshot = snapshot({
1215
1230
  collectionName: "nx-users",
1216
- conditions: [
1217
- {
1218
- field_name: "phone_number",
1219
- operator: "in",
1220
- value: [
1221
- phoneNumber,
1222
- local_israel_phone_format(phoneNumber)
1223
- ]
1224
- }
1225
- ],
1231
+ conditions: queryConditions,
1226
1232
  onFirstTime: function(docs) {
1227
1233
  if (!docs.length) {
1228
1234
  throw new Error("User not found");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "akeyless-client-commons",
3
- "version": "1.0.48",
3
+ "version": "1.0.50",
4
4
  "scripts": {
5
5
  "build": "tsup",
6
6
  "deploy": "npm run build && npm version patch --no-git-tag-version && npm publish",