@xuda.io/ai_module 1.1.4771 → 1.1.4773

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.
Files changed (2) hide show
  1. package/index.mjs +32 -0
  2. package/package.json +3 -2
package/index.mjs CHANGED
@@ -16,6 +16,7 @@ import { mdToPdf } from 'md-to-pdf';
16
16
  import _ from 'lodash';
17
17
 
18
18
  import { NodeVM, VMScript } from 'vm2';
19
+ import admin from 'firebase-admin';
19
20
 
20
21
  puppeteer.use(StealthPlugin());
21
22
  import process from 'process';
@@ -28,6 +29,11 @@ global._conf = (
28
29
  })
29
30
  ).default;
30
31
 
32
+ const _defaultAppConfig = {
33
+ credential: admin.credential.cert(_conf.firebase_serviceAccount),
34
+ };
35
+ admin.initializeApp(_defaultAppConfig);
36
+
31
37
  const module_path = path.join(process.env.XUDA_HOME, 'cpi') + (!_conf.is_debug ? '/node_modules/@xuda.io' : '');
32
38
  const runtime_modules_path = path.join(process.env.XUDA_HOME, 'dist', 'runtime', 'js', 'modules');
33
39
 
@@ -6986,6 +6992,32 @@ export const get_profile_picture = async function (uid, account_type = 'business
6986
6992
  break;
6987
6993
  }
6988
6994
 
6995
+ const getUserPhotoByEmail = async function (email) {
6996
+ try {
6997
+ const auth = admin.auth();
6998
+ const userRecord = await auth.getUserByEmail(email);
6999
+
7000
+ // photoURL is the profile picture URL (or null if not set)
7001
+ const photoURL = userRecord.photoURL;
7002
+ // console.log(`User found: ${JSON.stringify(userRecord)}`);
7003
+
7004
+ // console.log(`User found: ${userRecord.uid}`);
7005
+ // console.log(`Display name: ${userRecord.displayName || 'None'}`);
7006
+ // console.log(`Email verified: ${userRecord.emailVerified}`);
7007
+ // console.log(`Profile picture URL: ${photoURL || 'No photo set'}`);
7008
+
7009
+ return photoURL;
7010
+ } catch (error) {
7011
+ if (error.code === 'auth/user-not-found') {
7012
+ console.log(`No user found with email: ${email}`);
7013
+ return null;
7014
+ }
7015
+
7016
+ console.error('Error fetching user:', error);
7017
+ // throw error;
7018
+ }
7019
+ };
7020
+
6989
7021
  const get_url = async function () {
6990
7022
  const ret = await submit_chat_gpt_prompt({
6991
7023
  uid,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xuda.io/ai_module",
3
- "version": "1.1.4771",
3
+ "version": "1.1.4773",
4
4
  "description": "Xuda AI Module",
5
5
  "main": "index.mjs",
6
6
  "type": "module",
@@ -21,7 +21,8 @@
21
21
  "puppeteer-extra-plugin-stealth": "^2.11.2",
22
22
  "youtube-dl-exec": "^2.1.3",
23
23
  "md-to-pdf": "^5.2.5",
24
- "vm2": "^3.10.0"
24
+ "vm2": "^3.10.0",
25
+ "firebase-admin": "^9.6.0"
25
26
  },
26
27
  "devDependencies": {},
27
28
  "scripts": {