fix(core): update
This commit is contained in:
parent
29a7472b3c
commit
5d4b0eff68
4
.gitignore
vendored
4
.gitignore
vendored
@ -15,8 +15,6 @@ node_modules/
|
||||
|
||||
# builds
|
||||
dist/
|
||||
dist_web/
|
||||
dist_serve/
|
||||
dist_ts_web/
|
||||
dist_*/
|
||||
|
||||
# custom
|
@ -24,13 +24,14 @@ mirror:
|
||||
- docker
|
||||
- notpriv
|
||||
|
||||
snyk:
|
||||
image: registry.gitlab.com/hosttoday/ht-docker-node:snyk
|
||||
audit:
|
||||
image: registry.gitlab.com/hosttoday/ht-docker-node:npmci
|
||||
stage: security
|
||||
script:
|
||||
- npmci npm prepare
|
||||
- npmci command npm install --ignore-scripts
|
||||
- npmci command snyk test
|
||||
- npmci command npm config set registry https://registry.npmjs.org
|
||||
- npmci command npm audit --audit-level=high
|
||||
tags:
|
||||
- lossless
|
||||
- docker
|
||||
|
8
.vscode/settings.json
vendored
8
.vscode/settings.json
vendored
@ -11,7 +11,13 @@
|
||||
},
|
||||
"gitzone": {
|
||||
"type": "object",
|
||||
"description": "settings for gitzone"
|
||||
"description": "settings for gitzone",
|
||||
"properties": {
|
||||
"projectType": {
|
||||
"type": "string",
|
||||
"enum": ["website", "element", "service", "npm"]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -3,13 +3,13 @@
|
||||
"version": "1.0.25",
|
||||
"private": false,
|
||||
"description": "an api abstraction package for mailgun",
|
||||
"main": "dist/index.js",
|
||||
"typings": "dist/index.d.ts",
|
||||
"main": "dist_ts/index.js",
|
||||
"typings": "dist_ts/index.d.ts",
|
||||
"author": "Lossless GmbH",
|
||||
"license": "MIT",
|
||||
"scripts": {
|
||||
"test": "(tstest test/)",
|
||||
"build": "(tsbuild)",
|
||||
"build": "(tsbuild --web)",
|
||||
"format": "(gitzone format)"
|
||||
},
|
||||
"devDependencies": {
|
||||
@ -31,7 +31,8 @@
|
||||
"ts/**/*",
|
||||
"ts_web/**/*",
|
||||
"dist/**/*",
|
||||
"dist_web/**/*",
|
||||
"dist_*/**/*",
|
||||
"dist_ts/**/*",
|
||||
"dist_ts_web/**/*",
|
||||
"assets/**/*",
|
||||
"cli.js",
|
||||
|
27
readme.md
27
readme.md
@ -8,16 +8,29 @@ an api abstraction package for mailgun
|
||||
* [docs (typedoc)](https://mojoio.gitlab.io/mailgun/)
|
||||
|
||||
## Status for master
|
||||
[![build status](https://gitlab.com/mojoio/mailgun/badges/master/build.svg)](https://gitlab.com/mojoio/mailgun/commits/master)
|
||||
[![coverage report](https://gitlab.com/mojoio/mailgun/badges/master/coverage.svg)](https://gitlab.com/mojoio/mailgun/commits/master)
|
||||
[![npm downloads per month](https://img.shields.io/npm/dm/@mojoio/mailgun.svg)](https://www.npmjs.com/package/@mojoio/mailgun)
|
||||
[![Known Vulnerabilities](https://snyk.io/test/npm/@mojoio/mailgun/badge.svg)](https://snyk.io/test/npm/@mojoio/mailgun)
|
||||
[![TypeScript](https://img.shields.io/badge/TypeScript->=%203.x-blue.svg)](https://nodejs.org/dist/latest-v10.x/docs/api/)
|
||||
[![node](https://img.shields.io/badge/node->=%2010.x.x-blue.svg)](https://nodejs.org/dist/latest-v10.x/docs/api/)
|
||||
[![JavaScript Style Guide](https://img.shields.io/badge/code%20style-prettier-ff69b4.svg)](https://prettier.io/)
|
||||
|
||||
Status Category | Status Badge
|
||||
-- | --
|
||||
GitLab Pipelines | [![pipeline status](https://gitlab.com/mojoio/mailgun/badges/master/pipeline.svg)](https://lossless.cloud)
|
||||
GitLab Pipline Test Coverage | [![coverage report](https://gitlab.com/mojoio/mailgun/badges/master/coverage.svg)](https://lossless.cloud)
|
||||
npm | [![npm downloads per month](https://badgen.net/npm/dy/@mojoio/mailgun)](https://lossless.cloud)
|
||||
Snyk | [![Known Vulnerabilities](https://badgen.net/snyk/mojoio/mailgun)](https://lossless.cloud)
|
||||
TypeScript Support | [![TypeScript](https://badgen.net/badge/TypeScript/>=%203.x/blue?icon=typescript)](https://lossless.cloud)
|
||||
node Support | [![node](https://img.shields.io/badge/node->=%2010.x.x-blue.svg)](https://nodejs.org/dist/latest-v10.x/docs/api/)
|
||||
Code Style | [![Code Style](https://badgen.net/badge/style/prettier/purple)](https://lossless.cloud)
|
||||
PackagePhobia (total standalone install weight) | [![PackagePhobia](https://badgen.net/packagephobia/install/@mojoio/mailgun)](https://lossless.cloud)
|
||||
PackagePhobia (package size on registry) | [![PackagePhobia](https://badgen.net/packagephobia/publish/@mojoio/mailgun)](https://lossless.cloud)
|
||||
BundlePhobia (total size when bundled) | [![BundlePhobia](https://badgen.net/bundlephobia/minzip/@mojoio/mailgun)](https://lossless.cloud)
|
||||
Platform support | [![Supports Windows 10](https://badgen.net/badge/supports%20Windows%2010/yes/green?icon=windows)](https://lossless.cloud) [![Supports Mac OS X](https://badgen.net/badge/supports%20Mac%20OS%20X/yes/green?icon=apple)](https://lossless.cloud)
|
||||
|
||||
## Usage
|
||||
|
||||
Use TypeScript for best in class intellisense.
|
||||
|
||||
## Contribution
|
||||
|
||||
We are always happy for code contributions. If you are not the code contributing type that is ok. Still, maintaining Open Source repositories takes considerable time and thought. If you like the quality of what we do and our modules are useful to you we would appreciate a little monthly contribution: You can [contribute one time](https://lossless.link/contribute-onetime) or [contribute monthly](https://lossless.link/contribute). :)
|
||||
|
||||
For further information read the linked docs at the top of this readme.
|
||||
|
||||
> MIT licensed | **©** [Lossless GmbH](https://lossless.gmbh)
|
||||
|
@ -7,7 +7,6 @@ const testQenv = new Qenv('./', './.nogit');
|
||||
import * as mailgun from '../ts/index';
|
||||
import { IMailgunMessage } from '../ts/index';
|
||||
|
||||
|
||||
let testMailgunAccount: mailgun.MailgunAccount;
|
||||
let testSmartmail: smartmail.Smartmail<IMailgunMessage>;
|
||||
|
||||
@ -30,7 +29,9 @@ tap.test('should send a smartmail', async () => {
|
||||
});
|
||||
|
||||
tap.test('should retrieve a mail using a retrieval url', async () => {
|
||||
const result = await testMailgunAccount.retrieveSmartMailFromMessageUrl('https://sw.api.mailgun.net/v3/domains/mail.lossless.one/messages/AgMFnnnAKC8xp_dDa79LyoxhloxtaVmnRA==');
|
||||
const result = await testMailgunAccount.retrieveSmartMailFromMessageUrl(
|
||||
'https://sw.api.mailgun.net/v3/domains/mail.lossless.one/messages/AgMFnnnAKC8xp_dDa79LyoxhloxtaVmnRA=='
|
||||
);
|
||||
if (result) {
|
||||
result.options.subject = 'hi there. This is a testmail with attachment';
|
||||
result.options.from = 'noreply@mail.lossless.com';
|
||||
|
@ -6,7 +6,7 @@ export interface IMailgunNotification {
|
||||
'Received-Spf': string;
|
||||
From: string;
|
||||
'Return-Path': string;
|
||||
'Arc-Seal': string[],
|
||||
'Arc-Seal': string[];
|
||||
'Delivered-To': string;
|
||||
'X-Google-Dkim-Signature': string;
|
||||
To: string;
|
||||
@ -43,5 +43,5 @@ export interface IMailgunNotification {
|
||||
'stripped-signature': string;
|
||||
|
||||
// Lossless specific
|
||||
"X-Lossless-Auth": string;
|
||||
'X-Lossless-Auth': string;
|
||||
}
|
@ -12,14 +12,12 @@ export class MailgunAccount {
|
||||
public async getRequest(routeArg: string, binaryArg: boolean = false) {
|
||||
let requestUrl = routeArg;
|
||||
const needsBaseUrlPrefix = !routeArg.startsWith('https://');
|
||||
needsBaseUrlPrefix ? requestUrl = `${this.baseUrl}${routeArg}` : null;
|
||||
needsBaseUrlPrefix ? (requestUrl = `${this.baseUrl}${routeArg}`) : null;
|
||||
console.log(requestUrl);
|
||||
const requestOptions: plugins.smartrequest.ISmartRequestOptions = {
|
||||
method: 'GET',
|
||||
headers: {
|
||||
Authorization: `Basic ${plugins.smartstring.base64.encode(
|
||||
`api:${this.apiToken}`
|
||||
)}`,
|
||||
Authorization: `Basic ${plugins.smartstring.base64.encode(`api:${this.apiToken}`)}`,
|
||||
'Content-Type': 'application/json'
|
||||
}
|
||||
};
|
||||
@ -38,9 +36,7 @@ export class MailgunAccount {
|
||||
requestUrl,
|
||||
{
|
||||
headers: {
|
||||
Authorization: `Basic ${plugins.smartstring.base64.encode(
|
||||
`api:${this.apiToken}`
|
||||
)}`
|
||||
Authorization: `Basic ${plugins.smartstring.base64.encode(`api:${this.apiToken}`)}`
|
||||
}
|
||||
},
|
||||
formFields
|
||||
@ -51,7 +47,11 @@ export class MailgunAccount {
|
||||
/**
|
||||
* sends a SmartMail
|
||||
*/
|
||||
public async sendSmartMail(smartmailArg: plugins.smartmail.Smartmail<interfaces.IMailgunMessage>, toArg: string, dataArg = {}) {
|
||||
public async sendSmartMail(
|
||||
smartmailArg: plugins.smartmail.Smartmail<interfaces.IMailgunMessage>,
|
||||
toArg: string,
|
||||
dataArg = {}
|
||||
) {
|
||||
const domain = smartmailArg.options.from.split('@')[1].replace('>', '');
|
||||
const formFields: plugins.smartrequest.IFormField[] = [
|
||||
{
|
||||
@ -105,7 +105,7 @@ export class MailgunAccount {
|
||||
const responseBody: interfaces.IMailgunMessage = response.body;
|
||||
const smartmail = new plugins.smartmail.Smartmail<interfaces.IMailgunMessage>({
|
||||
from: responseBody.From,
|
||||
body: responseBody["body-html"],
|
||||
body: responseBody['body-html'],
|
||||
subject: responseBody.Subject,
|
||||
creationObjectRef: responseBody
|
||||
});
|
||||
@ -115,11 +115,13 @@ export class MailgunAccount {
|
||||
for (const attachmentInfo of responseBody.attachments) {
|
||||
const attachmentName = attachmentInfo.name;
|
||||
const attachmentContents = await this.getRequest(attachmentInfo.url, true);
|
||||
smartmail.addAttachment(new plugins.smartfile.Smartfile({
|
||||
path: `./${attachmentName}`,
|
||||
base: `./${attachmentName}`,
|
||||
contentBuffer: attachmentContents.body
|
||||
}));
|
||||
smartmail.addAttachment(
|
||||
new plugins.smartfile.Smartfile({
|
||||
path: `./${attachmentName}`,
|
||||
base: `./${attachmentName}`,
|
||||
contentBuffer: attachmentContents.body
|
||||
})
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user