Compare commits
8 Commits
Author | SHA1 | Date | |
---|---|---|---|
8997ded81d | |||
f177d8e9ab | |||
808a9cc856 | |||
be1c8d1164 | |||
2ecb2f3aa0 | |||
01dcdebda5 | |||
2adcc249de | |||
543e696bfc |
28
package.json
28
package.json
@ -1,6 +1,7 @@
|
||||
{
|
||||
"name": "@serve.zone/platformservice",
|
||||
"version": "1.0.3",
|
||||
"private": true,
|
||||
"version": "1.0.7",
|
||||
"description": "contains the platformservice container with mail, sms, letter, ai services.",
|
||||
"main": "dist_ts/index.js",
|
||||
"typings": "dist_ts/index.d.ts",
|
||||
@ -9,20 +10,24 @@
|
||||
"license": "MIT",
|
||||
"scripts": {
|
||||
"test": "(tstest test/)",
|
||||
"start": "(node --max_old_space_size=100 ./cli.js)",
|
||||
"start": "(node --max_old_space_size=250 ./cli.js)",
|
||||
"startTs": "(node cli.ts.js)",
|
||||
"build": "(tsbuild --web --allowimplicitany)"
|
||||
"localPublish": ""
|
||||
},
|
||||
"devDependencies": {
|
||||
"@git.zone/tsbuild": "^2.1.17",
|
||||
"@git.zone/tsrun": "^1.2.8",
|
||||
"@git.zone/tstest": "^1.0.28",
|
||||
"@git.zone/tstest": "^1.0.88",
|
||||
"@git.zone/tswatch": "^2.0.1",
|
||||
"@push.rocks/tapbundle": "^5.0.3"
|
||||
"@push.rocks/tapbundle": "^5.0.17"
|
||||
},
|
||||
"dependencies": {
|
||||
"@api.global/typedrequest": "^3.0.4",
|
||||
"@api.global/typedserver": "^3.0.20",
|
||||
"@anthropic-ai/sdk": "^0.18.0",
|
||||
"@api.global/typedrequest": "^3.0.19",
|
||||
"@api.global/typedserver": "^3.0.27",
|
||||
"@api.global/typedsocket": "^3.0.0",
|
||||
"@apiclient.xyz/cloudflare": "^6.0.3",
|
||||
"@apiclient.xyz/letterxpress": "^1.0.17",
|
||||
"@push.rocks/projectinfo": "^5.0.1",
|
||||
"@push.rocks/qenv": "^6.0.5",
|
||||
"@push.rocks/smartdata": "^5.0.7",
|
||||
@ -30,8 +35,15 @@
|
||||
"@push.rocks/smartlog": "^3.0.3",
|
||||
"@push.rocks/smartmail": "^1.0.24",
|
||||
"@push.rocks/smartpath": "^5.0.5",
|
||||
"@push.rocks/smartpromise": "^4.0.3",
|
||||
"@push.rocks/smartrequest": "^2.0.21",
|
||||
"@push.rocks/smartrx": "^3.0.7",
|
||||
"@push.rocks/smartstate": "^2.0.0",
|
||||
"@serve.zone/interfaces": "^1.0.34"
|
||||
"@serve.zone/interfaces": "^1.0.47",
|
||||
"@tsclass/tsclass": "^4.0.52",
|
||||
"mailauth": "^4.6.5",
|
||||
"mailparser": "^3.6.9",
|
||||
"openai": "^4.29.1",
|
||||
"uuid": "^9.0.1"
|
||||
}
|
||||
}
|
||||
|
3933
pnpm-lock.yaml
generated
3933
pnpm-lock.yaml
generated
File diff suppressed because it is too large
Load Diff
5
test/test.ts
Normal file
5
test/test.ts
Normal file
@ -0,0 +1,5 @@
|
||||
import { tap, expect } from '@push.rocks/tapbundle';
|
||||
|
||||
tap.test('should create a platform service', async () => {});
|
||||
|
||||
tap.start();
|
@ -3,6 +3,6 @@
|
||||
*/
|
||||
export const commitinfo = {
|
||||
name: '@serve.zone/platformservice',
|
||||
version: '1.0.3',
|
||||
version: '1.0.7',
|
||||
description: 'contains the platformservice container with mail, sms, letter, ai services.'
|
||||
}
|
||||
|
50
ts/aibridge/aibridge.classes.aibridge.ts
Normal file
50
ts/aibridge/aibridge.classes.aibridge.ts
Normal file
@ -0,0 +1,50 @@
|
||||
import * as plugins from './aibridge.plugins.js';
|
||||
import * as paths from './aibridge.paths.js';
|
||||
import { AiBridgeDb } from './aibridge.classes.aibridgedb.js';
|
||||
import { OpenAiBridge } from './aibridge.classes.openaibridge.js';
|
||||
|
||||
export class AiBridge {
|
||||
public projectinfo: plugins.projectinfo.ProjectInfo;
|
||||
public serverInstance: plugins.loleServiceserver.ServiceServer;
|
||||
public serviceQenv = new plugins.qenv.Qenv('./', './.nogit');
|
||||
public aibridgeDb: AiBridgeDb;
|
||||
|
||||
public openAiBridge: OpenAiBridge;
|
||||
|
||||
public typedrouter = new plugins.typedrequest.TypedRouter();
|
||||
|
||||
public async start() {
|
||||
this.aibridgeDb = new AiBridgeDb(this);
|
||||
await this.aibridgeDb.start();
|
||||
this.projectinfo = new plugins.projectinfo.ProjectInfo(paths.packageDir);
|
||||
this.openAiBridge = new OpenAiBridge(this);
|
||||
await this.openAiBridge.start();
|
||||
|
||||
// server
|
||||
this.serverInstance = new plugins.loleServiceserver.ServiceServer({
|
||||
serviceDomain: 'aibridge.lossless.one',
|
||||
serviceName: 'aibridge',
|
||||
serviceVersion: this.projectinfo.npm.version,
|
||||
addCustomRoutes: async (serverArg) => {
|
||||
// any custom route configs go here
|
||||
},
|
||||
});
|
||||
|
||||
// lets implemenet the actual typedrequest functions
|
||||
this.typedrouter.addTypedHandler<plugins.lointAiBridge.requests.IReq_Chat>(new plugins.typedrequest.TypedHandler('chat', async reqArg => {
|
||||
const resultChat = await this.openAiBridge.chat(reqArg.chat.systemMessage, reqArg.chat.messages[reqArg.chat.messages.length - 1].content, reqArg.chat.messages);
|
||||
return {
|
||||
chat: reqArg.chat,
|
||||
latestMessage: resultChat.message.content,
|
||||
}
|
||||
}))
|
||||
|
||||
await this.serverInstance.start();
|
||||
this.serverInstance.typedServer.typedrouter.addTypedRouter(this.typedrouter);
|
||||
}
|
||||
|
||||
public async stop() {
|
||||
await this.serverInstance.stop();
|
||||
await this.aibridgeDb.stop();
|
||||
}
|
||||
}
|
25
ts/aibridge/aibridge.classes.aibridgedb.ts
Normal file
25
ts/aibridge/aibridge.classes.aibridgedb.ts
Normal file
@ -0,0 +1,25 @@
|
||||
import * as plugins from './aibridge.plugins.js';
|
||||
import { AiBridge } from './aibridge.classes.aibridge.js';
|
||||
|
||||
export class AiBridgeDb {
|
||||
public smartdataDb: plugins.smartdata.SmartdataDb;
|
||||
public aibridgeRef: AiBridge;
|
||||
|
||||
constructor(aibridgeRefArg: AiBridge) {
|
||||
this.aibridgeRef = aibridgeRefArg;
|
||||
}
|
||||
|
||||
public async start() {
|
||||
this.smartdataDb = new plugins.smartdata.SmartdataDb({
|
||||
mongoDbUser: await this.aibridgeRef.serviceQenv.getEnvVarOnDemand('MONGO_DB_USER'),
|
||||
mongoDbName: await this.aibridgeRef.serviceQenv.getEnvVarOnDemand('MONGO_DB_NAME'),
|
||||
mongoDbPass: await this.aibridgeRef.serviceQenv.getEnvVarOnDemand('MONGO_DB_PASS'),
|
||||
mongoDbUrl: await this.aibridgeRef.serviceQenv.getEnvVarOnDemand('MONGO_DB_URL'),
|
||||
});
|
||||
await this.smartdataDb.init();
|
||||
}
|
||||
|
||||
public async stop() {
|
||||
await this.smartdataDb.close();
|
||||
}
|
||||
}
|
58
ts/aibridge/aibridge.classes.openaibridge.ts
Normal file
58
ts/aibridge/aibridge.classes.openaibridge.ts
Normal file
@ -0,0 +1,58 @@
|
||||
import { AiBridge } from './aibridge.classes.aibridge.js';
|
||||
import * as plugins from './aibridge.plugins.js';
|
||||
import * as paths from './aibridge.paths.js';
|
||||
|
||||
export class OpenAiBridge {
|
||||
public aiBridgeRef: AiBridge;
|
||||
public openAiApiClient: plugins.openai.default;
|
||||
constructor(aiBridgeRefArg: AiBridge) {
|
||||
this.aiBridgeRef = aiBridgeRefArg;
|
||||
}
|
||||
|
||||
public async start() {
|
||||
const openAiToken = await this.aiBridgeRef.serviceQenv.getEnvVarOnDemand('OPENAI_TOKEN');
|
||||
this.openAiApiClient = new plugins.openai.default({
|
||||
apiKey: openAiToken,
|
||||
dangerouslyAllowBrowser: true,
|
||||
});
|
||||
}
|
||||
|
||||
public async stop() {}
|
||||
|
||||
public async chat(
|
||||
systemMessage: string,
|
||||
userMessage: string,
|
||||
messageHistory: {
|
||||
role: 'assistant' | 'user';
|
||||
content: string;
|
||||
}[]
|
||||
) {
|
||||
const result = await this.openAiApiClient.chat.completions.create({
|
||||
model: 'gpt-3.5-turbo-16k-0613',
|
||||
messages: [
|
||||
{ role: 'system', content: systemMessage },
|
||||
...messageHistory,
|
||||
{ role: 'user', content: userMessage },
|
||||
],
|
||||
});
|
||||
return {
|
||||
message: result.choices[0].message,
|
||||
};
|
||||
}
|
||||
|
||||
public async audio(messageArg: string) {
|
||||
const done = plugins.smartpromise.defer();
|
||||
const result = await this.openAiApiClient.audio.speech.create({
|
||||
model: 'tts-1-hd',
|
||||
input: messageArg,
|
||||
voice: 'nova',
|
||||
response_format: 'mp3',
|
||||
speed: 1,
|
||||
});
|
||||
const stream = result.body.pipe(plugins.smartfile.fsStream.createWriteStream(plugins.path.join(paths.nogitDir, 'output.mp3')));
|
||||
stream.on('finish', () => {
|
||||
done.resolve();
|
||||
});
|
||||
return done.promise;
|
||||
}
|
||||
}
|
16
ts/aibridge/aibridge.paths.ts
Normal file
16
ts/aibridge/aibridge.paths.ts
Normal file
@ -0,0 +1,16 @@
|
||||
import * as plugins from './aibridge.plugins.js';
|
||||
|
||||
export const packageDir = plugins.path.join(
|
||||
plugins.smartpath.get.dirnameFromImportMetaUrl(import.meta.url),
|
||||
'../'
|
||||
);
|
||||
|
||||
export const assetsDir = plugins.path.join(
|
||||
packageDir,
|
||||
'./assets/'
|
||||
);
|
||||
|
||||
export const nogitDir = plugins.path.join(
|
||||
packageDir,
|
||||
'./.nogit/'
|
||||
);
|
32
ts/aibridge/aibridge.plugins.ts
Normal file
32
ts/aibridge/aibridge.plugins.ts
Normal file
@ -0,0 +1,32 @@
|
||||
// node native
|
||||
import * as path from 'path';
|
||||
|
||||
export { path };
|
||||
|
||||
// @losslessone_private scope
|
||||
import * as loleServiceserver from '@losslessone_private/lole-serviceserver';
|
||||
import * as lointAiBridge from '@losslessone_private/loint-aibridge';
|
||||
|
||||
export { loleServiceserver, lointAiBridge };
|
||||
|
||||
// apiglobal scope
|
||||
import * as typedrequest from '@api.global/typedrequest';
|
||||
|
||||
export {
|
||||
typedrequest,
|
||||
}
|
||||
|
||||
// pushrocks scope
|
||||
import * as projectinfo from '@push.rocks/projectinfo';
|
||||
import * as qenv from '@push.rocks/qenv';
|
||||
import * as smartdata from '@push.rocks/smartdata';
|
||||
import * as smartfile from '@push.rocks/smartfile';
|
||||
import * as smartpath from '@push.rocks/smartpath';
|
||||
import * as smartpromise from '@push.rocks/smartpromise';
|
||||
|
||||
export { projectinfo, qenv, smartdata, smartfile, smartpath, smartpromise };
|
||||
|
||||
// thirdparty scope
|
||||
import * as antrophic from '@anthropic-ai/sdk';
|
||||
import * as openai from 'openai';
|
||||
export { antrophic as anthropic, openai };
|
17
ts/aibridge/index.ts
Normal file
17
ts/aibridge/index.ts
Normal file
@ -0,0 +1,17 @@
|
||||
import { AiBridge } from './aibridge.classes.aibridge.js';
|
||||
|
||||
export {
|
||||
AiBridge,
|
||||
}
|
||||
|
||||
let aibridgeInstance: AiBridge;
|
||||
export const runCli = async () => {
|
||||
aibridgeInstance = new AiBridge();
|
||||
await aibridgeInstance.start();
|
||||
};
|
||||
|
||||
export const stop = async () => {
|
||||
if (aibridgeInstance) {
|
||||
await aibridgeInstance.stop();
|
||||
}
|
||||
};
|
@ -1,6 +1,10 @@
|
||||
import * as plugins from './plugins.js';
|
||||
import * as paths from './paths.js';
|
||||
import { PlatformServiceDb } from './classes.platformservicedb.js'
|
||||
import { EmailService } from './email/email.classes.emailservice.js';
|
||||
import { SmsService } from './sms/smsservice.js';
|
||||
import { LetterService } from './letter/classes.letterservice.js';
|
||||
import { MtaService } from './mta/mta.classes.mta.js';
|
||||
|
||||
export class SzPlatformService {
|
||||
public projectinfo: plugins.projectinfo.ProjectInfo;
|
||||
@ -10,9 +14,28 @@ export class SzPlatformService {
|
||||
public typedserver: plugins.typedserver.TypedServer;
|
||||
public typedrouter = new plugins.typedrequest.TypedRouter();
|
||||
|
||||
// SubServices
|
||||
public emailService: EmailService;
|
||||
public letterService: LetterService;
|
||||
public mtaService: MtaService;
|
||||
public smsService: SmsService;
|
||||
|
||||
public async start() {
|
||||
this.platformserviceDb = new PlatformServiceDb(this);
|
||||
this.projectinfo = new plugins.projectinfo.ProjectInfo(paths.packageDir);
|
||||
|
||||
// lets start the sub services
|
||||
this.emailService = new EmailService(this);
|
||||
this.letterService = new LetterService(this, {
|
||||
letterxpressUser: await this.serviceQenv.getEnvVarOnDemand('LETTER_API_USER'),
|
||||
letterxpressToken: await this.serviceQenv.getEnvVarOnDemand('LETTER_API_TOKEN')
|
||||
});
|
||||
this.mtaService = new MtaService(this);
|
||||
this.smsService = new SmsService(this, {
|
||||
apiGatewayApiToken: await this.serviceQenv.getEnvVarOnDemand('SMS_API_TOKEN'),
|
||||
});
|
||||
|
||||
// lets start the server finally
|
||||
this.typedserver = new plugins.typedserver.TypedServer({
|
||||
cors: true,
|
||||
});
|
||||
|
@ -6,6 +6,11 @@ import { ApiManager } from './email.classes.apimanager.js';
|
||||
import { logger } from '../logger.js';
|
||||
import type { SzPlatformService } from '../classes.platformservice.js';
|
||||
|
||||
|
||||
export interface IEmailConstructorOptions {
|
||||
mailgunApiKey: string;
|
||||
}
|
||||
|
||||
export class EmailService {
|
||||
public platformServiceRef: SzPlatformService;
|
||||
|
||||
|
41
ts/letter/classes.letterservice.ts
Normal file
41
ts/letter/classes.letterservice.ts
Normal file
@ -0,0 +1,41 @@
|
||||
import type { SzPlatformService } from '../classes.platformservice.js';
|
||||
import * as plugins from '../plugins.js';
|
||||
|
||||
export interface ILetterConstructorOptions {
|
||||
letterxpressUser: string;
|
||||
letterxpressToken: string;
|
||||
}
|
||||
|
||||
export class LetterService {
|
||||
public platformServiceRef: SzPlatformService;
|
||||
public options: ILetterConstructorOptions;
|
||||
public letterxpressAccount: plugins.letterxpress.LetterXpressAccount;
|
||||
public typedrouter = new plugins.typedrequest.TypedRouter();
|
||||
|
||||
constructor(platformServiceRefArg: SzPlatformService, optionsArg: ILetterConstructorOptions) {
|
||||
this.platformServiceRef = platformServiceRefArg;
|
||||
this.options = optionsArg;
|
||||
this.platformServiceRef.typedrouter.addTypedRouter(this.typedrouter);
|
||||
|
||||
this.typedrouter.addTypedHandler<
|
||||
plugins.servezoneInterfaces.platformservice.letter.IRequest_SendLetter
|
||||
>(new plugins.typedrequest.TypedHandler('sendLetter', async dataArg => {
|
||||
if(dataArg.needsCover) {
|
||||
|
||||
}
|
||||
return {
|
||||
processId: '',
|
||||
}
|
||||
}));
|
||||
}
|
||||
|
||||
public async start() {
|
||||
this.letterxpressAccount = new plugins.letterxpress.LetterXpressAccount({
|
||||
username: this.options.letterxpressUser,
|
||||
apiKey: this.options.letterxpressToken,
|
||||
});
|
||||
await this.letterxpressAccount.start();
|
||||
}
|
||||
|
||||
public async stop() {}
|
||||
}
|
0
ts/letter/index.ts
Normal file
0
ts/letter/index.ts
Normal file
@ -1,4 +1,4 @@
|
||||
import * as plugins from './plugins.js';
|
||||
import * as plugins from '../plugins.js';
|
||||
|
||||
export class ApiManager {
|
||||
public typedrouter = new plugins.typedrequest.TypedRouter();
|
||||
|
@ -1,8 +1,8 @@
|
||||
import * as plugins from './plugins.js';
|
||||
import * as paths from './paths.js';
|
||||
import * as plugins from '../plugins.js';
|
||||
import * as paths from '../paths.js';
|
||||
|
||||
import { Email } from './mta.classes.email.js';
|
||||
import type { MTA } from './mta.classes.mta.js';
|
||||
import type { MtaService } from './mta.classes.mta.js';
|
||||
|
||||
const readFile = plugins.util.promisify(plugins.fs.readFile);
|
||||
const writeFile = plugins.util.promisify(plugins.fs.writeFile);
|
||||
@ -16,7 +16,7 @@ export interface IKeyPaths {
|
||||
export class DKIMCreator {
|
||||
private keysDir: string;
|
||||
|
||||
constructor(metaRef: MTA, keysDir = paths.keysDir) {
|
||||
constructor(metaRef: MtaService, keysDir = paths.keysDir) {
|
||||
this.keysDir = keysDir;
|
||||
}
|
||||
|
||||
|
@ -1,10 +1,10 @@
|
||||
import * as plugins from './plugins.js';
|
||||
import { MTA } from './mta.classes.mta.js';
|
||||
import * as plugins from '../plugins.js';
|
||||
import { MtaService } from './mta.classes.mta.js';
|
||||
|
||||
class DKIMVerifier {
|
||||
public mtaRef: MTA;
|
||||
public mtaRef: MtaService;
|
||||
|
||||
constructor(mtaRefArg: MTA) {
|
||||
constructor(mtaRefArg: MtaService) {
|
||||
this.mtaRef = mtaRefArg;
|
||||
}
|
||||
|
||||
|
@ -1,10 +1,10 @@
|
||||
import type { MTA } from './mta.classes.mta.js';
|
||||
import * as plugins from './plugins.js';
|
||||
import type { MtaService } from './mta.classes.mta.js';
|
||||
import * as plugins from '../plugins.js';
|
||||
|
||||
export class DNSManager {
|
||||
public mtaRef: MTA;
|
||||
public mtaRef: MtaService;
|
||||
|
||||
constructor(mtaRefArg: MTA) {
|
||||
constructor(mtaRefArg: MtaService) {
|
||||
this.mtaRef = mtaRefArg;
|
||||
}
|
||||
}
|
@ -1,16 +1,16 @@
|
||||
import * as plugins from './plugins.js';
|
||||
import * as paths from './paths.js';
|
||||
import * as plugins from '../plugins.js';
|
||||
import * as paths from '../paths.js';
|
||||
import { Email } from './mta.classes.email.js';
|
||||
import { EmailSignJob } from './mta.classes.emailsignjob.js';
|
||||
import type { MTA } from './mta.classes.mta.js';
|
||||
import type { MtaService } from './mta.classes.mta.js';
|
||||
|
||||
export class EmailSendJob {
|
||||
mtaRef: MTA;
|
||||
mtaRef: MtaService;
|
||||
private email: Email;
|
||||
private socket: plugins.net.Socket | plugins.tls.TLSSocket = null;
|
||||
private mxRecord: string = null;
|
||||
|
||||
constructor(mtaRef: MTA, emailArg: Email) {
|
||||
constructor(mtaRef: MtaService, emailArg: Email) {
|
||||
this.email = emailArg;
|
||||
this.mtaRef = mtaRef;
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
import * as plugins from './plugins.js';
|
||||
import type { MTA } from './mta.classes.mta.js';
|
||||
import * as plugins from '../plugins.js';
|
||||
import type { MtaService } from './mta.classes.mta.js';
|
||||
|
||||
interface Headers {
|
||||
[key: string]: string;
|
||||
@ -13,10 +13,10 @@ interface IEmailSignJobOptions {
|
||||
}
|
||||
|
||||
export class EmailSignJob {
|
||||
mtaRef: MTA;
|
||||
mtaRef: MtaService;
|
||||
jobOptions: IEmailSignJobOptions;
|
||||
|
||||
constructor(mtaRefArg: MTA, options: IEmailSignJobOptions) {
|
||||
constructor(mtaRefArg: MtaService, options: IEmailSignJobOptions) {
|
||||
this.mtaRef = mtaRefArg;
|
||||
this.jobOptions = options;
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
import * as plugins from './plugins.js';
|
||||
import * as plugins from '../plugins.js';
|
||||
|
||||
import { Email } from './mta.classes.email.js';
|
||||
import { EmailSendJob } from './mta.classes.emailsendjob.js';
|
||||
@ -6,14 +6,17 @@ import { DKIMCreator } from './mta.classes.dkimcreator.js';
|
||||
import { DKIMVerifier } from './mta.classes.dkimverifier.js';
|
||||
import { SMTPServer } from './mta.classes.smtpserver.js';
|
||||
import { DNSManager } from './mta.classes.dnsmanager.js';
|
||||
import type { SzPlatformService } from '../classes.platformservice.js';
|
||||
|
||||
export class MTA {
|
||||
export class MtaService {
|
||||
public platformServiceRef: SzPlatformService;
|
||||
public server: SMTPServer;
|
||||
public dkimCreator: DKIMCreator;
|
||||
public dkimVerifier: DKIMVerifier;
|
||||
public dnsManager: DNSManager;
|
||||
|
||||
constructor() {
|
||||
constructor(platformServiceRefArg: SzPlatformService) {
|
||||
this.platformServiceRef = platformServiceRefArg;
|
||||
this.dkimCreator = new DKIMCreator(this);
|
||||
this.dkimVerifier = new DKIMVerifier(this);
|
||||
this.dnsManager = new DNSManager(this);
|
||||
|
@ -1,7 +1,7 @@
|
||||
import * as plugins from './plugins.js';
|
||||
import * as paths from './paths.js';
|
||||
import * as plugins from '../plugins.js';
|
||||
import * as paths from '../paths.js';
|
||||
import { Email } from './mta.classes.email.js';
|
||||
import type { MTA } from './mta.classes.mta.js';
|
||||
import type { MtaService } from './mta.classes.mta.js';
|
||||
|
||||
export interface ISmtpServerOptions {
|
||||
port: number;
|
||||
@ -10,12 +10,12 @@ export interface ISmtpServerOptions {
|
||||
}
|
||||
|
||||
export class SMTPServer {
|
||||
public mtaRef: MTA;
|
||||
public mtaRef: MtaService;
|
||||
private smtpServerOptions: ISmtpServerOptions;
|
||||
private server: plugins.net.Server;
|
||||
private emailBufferStringMap: Map<plugins.net.Socket, string>;
|
||||
|
||||
constructor(mtaRefArg: MTA, optionsArg: ISmtpServerOptions) {
|
||||
constructor(mtaRefArg: MtaService, optionsArg: ISmtpServerOptions) {
|
||||
console.log('SMTPServer instance is being created...');
|
||||
|
||||
this.mtaRef = mtaRefArg;
|
||||
|
@ -1,12 +0,0 @@
|
||||
import * as plugins from './plugins.js';
|
||||
|
||||
export const cwd = plugins.path.join(
|
||||
plugins.smartpath.get.dirnameFromImportMetaUrl(import.meta.url),
|
||||
'../'
|
||||
);
|
||||
export const assetsDir = plugins.path.join(cwd, './assets');
|
||||
export const keysDir = plugins.path.join(assetsDir, './keys');
|
||||
export const dnsRecordsDir = plugins.path.join(assetsDir, './dns-records');
|
||||
export const sentEmailsDir = plugins.path.join(assetsDir, './sent-emails');
|
||||
export const receivedEmailsDir = plugins.path.join(assetsDir, './received-emails');
|
||||
plugins.smartfile.fs.ensureDirSync(keysDir);
|
@ -1,67 +0,0 @@
|
||||
// node native
|
||||
import * as dns from 'dns';
|
||||
import * as fs from 'fs';
|
||||
import * as crypto from 'crypto';
|
||||
import * as net from 'net';
|
||||
import * as path from 'path';
|
||||
import * as tls from 'tls';
|
||||
import * as util from 'util';
|
||||
|
||||
export {
|
||||
dns,
|
||||
fs,
|
||||
crypto,
|
||||
net,
|
||||
path,
|
||||
tls,
|
||||
util,
|
||||
}
|
||||
|
||||
// @apiclient.xyz/cloudflare
|
||||
import * as cloudflare from '@apiclient.xyz/cloudflare';
|
||||
|
||||
export {
|
||||
cloudflare,
|
||||
}
|
||||
|
||||
// @apiglobal scope
|
||||
import * as typedrequest from '@apiglobal/typedrequest';
|
||||
import * as typedsocket from '@apiglobal/typedsocket';
|
||||
|
||||
export {
|
||||
typedrequest,
|
||||
typedsocket,
|
||||
}
|
||||
|
||||
// pushrocks scope
|
||||
import * as smartfile from '@pushrocks/smartfile';
|
||||
import * as smartpath from '@pushrocks/smartpath';
|
||||
import * as smartpromise from '@pushrocks/smartpromise';
|
||||
import * as smartrx from '@pushrocks/smartrx';
|
||||
|
||||
export {
|
||||
smartfile,
|
||||
smartpath,
|
||||
smartpromise,
|
||||
smartrx,
|
||||
}
|
||||
|
||||
// tsclass scope
|
||||
import * as tsclass from '@tsclass/tsclass';
|
||||
|
||||
export {
|
||||
tsclass,
|
||||
}
|
||||
|
||||
// third party
|
||||
import * as mailauth from 'mailauth';
|
||||
import { dkimSign } from 'mailauth/lib/dkim/sign.js';
|
||||
import mailparser from 'mailparser';
|
||||
import * as uuid from 'uuid';
|
||||
|
||||
export {
|
||||
mailauth,
|
||||
dkimSign,
|
||||
mailparser,
|
||||
uuid,
|
||||
}
|
@ -4,3 +4,9 @@ export const packageDir = plugins.path.join(
|
||||
plugins.smartpath.get.dirnameFromImportMetaUrl(import.meta.url),
|
||||
'../'
|
||||
);
|
||||
export const assetsDir = plugins.path.join(packageDir, './assets');
|
||||
export const keysDir = plugins.path.join(assetsDir, './keys');
|
||||
export const dnsRecordsDir = plugins.path.join(assetsDir, './dns-records');
|
||||
export const sentEmailsDir = plugins.path.join(assetsDir, './sent-emails');
|
||||
export const receivedEmailsDir = plugins.path.join(assetsDir, './received-emails');
|
||||
plugins.smartfile.fs.ensureDirSync(keysDir);
|
@ -1,8 +1,20 @@
|
||||
// node native
|
||||
import * as dns from 'dns';
|
||||
import * as fs from 'fs';
|
||||
import * as crypto from 'crypto';
|
||||
import * as net from 'net';
|
||||
import * as path from 'path';
|
||||
import * as tls from 'tls';
|
||||
import * as util from 'util';
|
||||
|
||||
export {
|
||||
path
|
||||
dns,
|
||||
fs,
|
||||
crypto,
|
||||
net,
|
||||
path,
|
||||
tls,
|
||||
util,
|
||||
}
|
||||
|
||||
// @serve.zone scope
|
||||
@ -15,10 +27,12 @@ export {
|
||||
// @api.global scope
|
||||
import * as typedrequest from '@api.global/typedrequest';
|
||||
import * as typedserver from '@api.global/typedserver';
|
||||
import * as typedsocket from '@api.global/typedsocket';
|
||||
|
||||
export {
|
||||
typedrequest,
|
||||
typedserver,
|
||||
typedsocket,
|
||||
}
|
||||
|
||||
// @push.rocks scope
|
||||
@ -29,6 +43,35 @@ import * as smartfile from '@push.rocks/smartfile';
|
||||
import * as smartlog from '@push.rocks/smartlog';
|
||||
import * as smartmail from '@push.rocks/smartmail';
|
||||
import * as smartpath from '@push.rocks/smartpath';
|
||||
import * as smartpromise from '@push.rocks/smartpromise';
|
||||
import * as smartrequest from '@push.rocks/smartrequest';
|
||||
import * as smartrx from '@push.rocks/smartrx';
|
||||
|
||||
export { projectinfo, qenv, smartdata, smartfile, smartlog, smartmail, smartpath, smartrequest };
|
||||
export { projectinfo, qenv, smartdata, smartfile, smartlog, smartmail, smartpath, smartpromise, smartrequest, smartrx };
|
||||
|
||||
// apiclient.xyz scope
|
||||
import * as letterxpress from '@apiclient.xyz/letterxpress';
|
||||
|
||||
export {
|
||||
letterxpress,
|
||||
}
|
||||
|
||||
// tsclass scope
|
||||
import * as tsclass from '@tsclass/tsclass';
|
||||
|
||||
export {
|
||||
tsclass,
|
||||
}
|
||||
|
||||
// third party
|
||||
import * as mailauth from 'mailauth';
|
||||
import { dkimSign } from 'mailauth/lib/dkim/sign.js';
|
||||
import mailparser from 'mailparser';
|
||||
import * as uuid from 'uuid';
|
||||
|
||||
export {
|
||||
mailauth,
|
||||
dkimSign,
|
||||
mailparser,
|
||||
uuid,
|
||||
}
|
||||
|
@ -4,7 +4,7 @@ import { logger } from '../logger.js';
|
||||
import type { SzPlatformService } from '../classes.platformservice.js';
|
||||
|
||||
export interface ISmsConstructorOptions {
|
||||
apiToken: string;
|
||||
apiGatewayApiToken: string;
|
||||
}
|
||||
|
||||
export class SmsService {
|
||||
@ -63,7 +63,7 @@ export class SmsService {
|
||||
method: 'POST',
|
||||
requestBody: JSON.stringify(payload),
|
||||
headers: {
|
||||
Authorization: `Basic ${Buffer.from(`${this.options.apiToken}:`).toString('base64')}`,
|
||||
Authorization: `Basic ${Buffer.from(`${this.options.apiGatewayApiToken}:`).toString('base64')}`,
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
});
|
||||
|
Reference in New Issue
Block a user