pangea-server 3.3.140 → 3.3.142

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.
@@ -3,5 +3,8 @@ type File = {
3
3
  mimetype: string;
4
4
  };
5
5
  type Part = string | File;
6
- export declare function generateIaText(content: string | Part[]): Promise<string | undefined>;
6
+ export declare abstract class Gemini {
7
+ static GenerateText(content: string | Part[]): Promise<string | undefined>;
8
+ private static __GetAi;
9
+ }
7
10
  export {};
@@ -1,20 +1,27 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.generateIaText = generateIaText;
3
+ exports.Gemini = void 0;
4
4
  // helpers
5
5
  const helpers_1 = require("../helpers");
6
- async function generateIaText(content) {
7
- const { GoogleGenAI } = await import('@google/genai');
8
- const ai = new GoogleGenAI({ apiKey: (0, helpers_1.getEnvStr)('GEMINI_API_KEY') });
9
- const contents = typeof content === 'string'
10
- ? content
11
- : await Promise.all(content.map(async (part) => {
12
- if (typeof part === 'string')
13
- return { text: part };
14
- const blob = new Blob([new Uint8Array(part.buffer)], { type: part.mimetype });
15
- const uploadedFile = await ai.files.upload({ file: blob });
16
- return { fileData: { fileUri: uploadedFile.uri, mimeType: part.mimetype } };
17
- }));
18
- const response = await ai.models.generateContent({ model: 'gemini-2.5-flash-lite', contents });
19
- return response.text;
6
+ const MODEL = 'gemini-2.5-flash-lite';
7
+ class Gemini {
8
+ static async GenerateText(content) {
9
+ const ai = await this.__GetAi();
10
+ const contents = typeof content === 'string'
11
+ ? content
12
+ : await Promise.all(content.map(async (part) => {
13
+ if (typeof part === 'string')
14
+ return { text: part };
15
+ const blob = new Blob([new Uint8Array(part.buffer)], { type: part.mimetype });
16
+ const uploadedFile = await ai.files.upload({ file: blob });
17
+ return { fileData: { fileUri: uploadedFile.uri, mimeType: part.mimetype } };
18
+ }));
19
+ const response = await ai.models.generateContent({ model: MODEL, contents });
20
+ return response.text;
21
+ }
22
+ static async __GetAi() {
23
+ const { GoogleGenAI } = await import('@google/genai');
24
+ return new GoogleGenAI({ apiKey: (0, helpers_1.getEnvStr)('GEMINI_API_KEY') });
25
+ }
20
26
  }
27
+ exports.Gemini = Gemini;
@@ -10,16 +10,16 @@ const env_helpers_1 = require("./env.helpers");
10
10
  const COST = 12;
11
11
  class Pass {
12
12
  static Hash(password) {
13
- return bcrypt_1.default.hash(withPepper(password), COST);
13
+ return bcrypt_1.default.hash(sign(password), COST);
14
14
  }
15
15
  static async Compare(password, hash) {
16
- if (await bcrypt_1.default.compare(withPepper(password), hash))
16
+ if (await bcrypt_1.default.compare(sign(password), hash))
17
17
  return true;
18
18
  return bcrypt_1.default.compare(password, hash);
19
19
  }
20
20
  }
21
21
  exports.Pass = Pass;
22
22
  // internal functions
23
- function withPepper(password) {
24
- return crypto_1.default.createHmac('sha256', (0, env_helpers_1.getEnvStr)('PASSWORD_PEPPER')).update(password).digest('hex');
23
+ function sign(password) {
24
+ return crypto_1.default.createHmac('sha256', (0, env_helpers_1.getEnvStr)('PASSWORD_SECRET')).update(password).digest('hex');
25
25
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "pangea-server",
3
3
  "description": "",
4
- "version": "3.3.140",
4
+ "version": "3.3.142",
5
5
  "files": [
6
6
  "dist"
7
7
  ],