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
|
# builds
|
||||||
dist/
|
dist/
|
||||||
dist_web/
|
dist_*/
|
||||||
dist_serve/
|
|
||||||
dist_ts_web/
|
|
||||||
|
|
||||||
# custom
|
# custom
|
@ -24,13 +24,14 @@ mirror:
|
|||||||
- docker
|
- docker
|
||||||
- notpriv
|
- notpriv
|
||||||
|
|
||||||
snyk:
|
audit:
|
||||||
image: registry.gitlab.com/hosttoday/ht-docker-node:snyk
|
image: registry.gitlab.com/hosttoday/ht-docker-node:npmci
|
||||||
stage: security
|
stage: security
|
||||||
script:
|
script:
|
||||||
- npmci npm prepare
|
- npmci npm prepare
|
||||||
- npmci command npm install --ignore-scripts
|
- 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:
|
tags:
|
||||||
- lossless
|
- lossless
|
||||||
- docker
|
- docker
|
||||||
|
8
.vscode/settings.json
vendored
8
.vscode/settings.json
vendored
@ -11,7 +11,13 @@
|
|||||||
},
|
},
|
||||||
"gitzone": {
|
"gitzone": {
|
||||||
"type": "object",
|
"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",
|
"version": "1.0.25",
|
||||||
"private": false,
|
"private": false,
|
||||||
"description": "an api abstraction package for mailgun",
|
"description": "an api abstraction package for mailgun",
|
||||||
"main": "dist/index.js",
|
"main": "dist_ts/index.js",
|
||||||
"typings": "dist/index.d.ts",
|
"typings": "dist_ts/index.d.ts",
|
||||||
"author": "Lossless GmbH",
|
"author": "Lossless GmbH",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"test": "(tstest test/)",
|
"test": "(tstest test/)",
|
||||||
"build": "(tsbuild)",
|
"build": "(tsbuild --web)",
|
||||||
"format": "(gitzone format)"
|
"format": "(gitzone format)"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
@ -31,7 +31,8 @@
|
|||||||
"ts/**/*",
|
"ts/**/*",
|
||||||
"ts_web/**/*",
|
"ts_web/**/*",
|
||||||
"dist/**/*",
|
"dist/**/*",
|
||||||
"dist_web/**/*",
|
"dist_*/**/*",
|
||||||
|
"dist_ts/**/*",
|
||||||
"dist_ts_web/**/*",
|
"dist_ts_web/**/*",
|
||||||
"assets/**/*",
|
"assets/**/*",
|
||||||
"cli.js",
|
"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/)
|
* [docs (typedoc)](https://mojoio.gitlab.io/mailgun/)
|
||||||
|
|
||||||
## Status for master
|
## 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)
|
Status Category | Status Badge
|
||||||
[![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)
|
GitLab Pipelines | [![pipeline status](https://gitlab.com/mojoio/mailgun/badges/master/pipeline.svg)](https://lossless.cloud)
|
||||||
[![TypeScript](https://img.shields.io/badge/TypeScript->=%203.x-blue.svg)](https://nodejs.org/dist/latest-v10.x/docs/api/)
|
GitLab Pipline Test Coverage | [![coverage report](https://gitlab.com/mojoio/mailgun/badges/master/coverage.svg)](https://lossless.cloud)
|
||||||
[![node](https://img.shields.io/badge/node->=%2010.x.x-blue.svg)](https://nodejs.org/dist/latest-v10.x/docs/api/)
|
npm | [![npm downloads per month](https://badgen.net/npm/dy/@mojoio/mailgun)](https://lossless.cloud)
|
||||||
[![JavaScript Style Guide](https://img.shields.io/badge/code%20style-prettier-ff69b4.svg)](https://prettier.io/)
|
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
|
## 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.
|
For further information read the linked docs at the top of this readme.
|
||||||
|
|
||||||
> MIT licensed | **©** [Lossless GmbH](https://lossless.gmbh)
|
> MIT licensed | **©** [Lossless GmbH](https://lossless.gmbh)
|
||||||
|
@ -7,7 +7,6 @@ const testQenv = new Qenv('./', './.nogit');
|
|||||||
import * as mailgun from '../ts/index';
|
import * as mailgun from '../ts/index';
|
||||||
import { IMailgunMessage } from '../ts/index';
|
import { IMailgunMessage } from '../ts/index';
|
||||||
|
|
||||||
|
|
||||||
let testMailgunAccount: mailgun.MailgunAccount;
|
let testMailgunAccount: mailgun.MailgunAccount;
|
||||||
let testSmartmail: smartmail.Smartmail<IMailgunMessage>;
|
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 () => {
|
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) {
|
if (result) {
|
||||||
result.options.subject = 'hi there. This is a testmail with attachment';
|
result.options.subject = 'hi there. This is a testmail with attachment';
|
||||||
result.options.from = 'noreply@mail.lossless.com';
|
result.options.from = 'noreply@mail.lossless.com';
|
||||||
|
@ -6,7 +6,7 @@ export interface IMailgunNotification {
|
|||||||
'Received-Spf': string;
|
'Received-Spf': string;
|
||||||
From: string;
|
From: string;
|
||||||
'Return-Path': string;
|
'Return-Path': string;
|
||||||
'Arc-Seal': string[],
|
'Arc-Seal': string[];
|
||||||
'Delivered-To': string;
|
'Delivered-To': string;
|
||||||
'X-Google-Dkim-Signature': string;
|
'X-Google-Dkim-Signature': string;
|
||||||
To: string;
|
To: string;
|
||||||
@ -43,5 +43,5 @@ export interface IMailgunNotification {
|
|||||||
'stripped-signature': string;
|
'stripped-signature': string;
|
||||||
|
|
||||||
// Lossless specific
|
// 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) {
|
public async getRequest(routeArg: string, binaryArg: boolean = false) {
|
||||||
let requestUrl = routeArg;
|
let requestUrl = routeArg;
|
||||||
const needsBaseUrlPrefix = !routeArg.startsWith('https://');
|
const needsBaseUrlPrefix = !routeArg.startsWith('https://');
|
||||||
needsBaseUrlPrefix ? requestUrl = `${this.baseUrl}${routeArg}` : null;
|
needsBaseUrlPrefix ? (requestUrl = `${this.baseUrl}${routeArg}`) : null;
|
||||||
console.log(requestUrl);
|
console.log(requestUrl);
|
||||||
const requestOptions: plugins.smartrequest.ISmartRequestOptions = {
|
const requestOptions: plugins.smartrequest.ISmartRequestOptions = {
|
||||||
method: 'GET',
|
method: 'GET',
|
||||||
headers: {
|
headers: {
|
||||||
Authorization: `Basic ${plugins.smartstring.base64.encode(
|
Authorization: `Basic ${plugins.smartstring.base64.encode(`api:${this.apiToken}`)}`,
|
||||||
`api:${this.apiToken}`
|
|
||||||
)}`,
|
|
||||||
'Content-Type': 'application/json'
|
'Content-Type': 'application/json'
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@ -38,9 +36,7 @@ export class MailgunAccount {
|
|||||||
requestUrl,
|
requestUrl,
|
||||||
{
|
{
|
||||||
headers: {
|
headers: {
|
||||||
Authorization: `Basic ${plugins.smartstring.base64.encode(
|
Authorization: `Basic ${plugins.smartstring.base64.encode(`api:${this.apiToken}`)}`
|
||||||
`api:${this.apiToken}`
|
|
||||||
)}`
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
formFields
|
formFields
|
||||||
@ -51,7 +47,11 @@ export class MailgunAccount {
|
|||||||
/**
|
/**
|
||||||
* sends a SmartMail
|
* 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 domain = smartmailArg.options.from.split('@')[1].replace('>', '');
|
||||||
const formFields: plugins.smartrequest.IFormField[] = [
|
const formFields: plugins.smartrequest.IFormField[] = [
|
||||||
{
|
{
|
||||||
@ -105,7 +105,7 @@ export class MailgunAccount {
|
|||||||
const responseBody: interfaces.IMailgunMessage = response.body;
|
const responseBody: interfaces.IMailgunMessage = response.body;
|
||||||
const smartmail = new plugins.smartmail.Smartmail<interfaces.IMailgunMessage>({
|
const smartmail = new plugins.smartmail.Smartmail<interfaces.IMailgunMessage>({
|
||||||
from: responseBody.From,
|
from: responseBody.From,
|
||||||
body: responseBody["body-html"],
|
body: responseBody['body-html'],
|
||||||
subject: responseBody.Subject,
|
subject: responseBody.Subject,
|
||||||
creationObjectRef: responseBody
|
creationObjectRef: responseBody
|
||||||
});
|
});
|
||||||
@ -115,11 +115,13 @@ export class MailgunAccount {
|
|||||||
for (const attachmentInfo of responseBody.attachments) {
|
for (const attachmentInfo of responseBody.attachments) {
|
||||||
const attachmentName = attachmentInfo.name;
|
const attachmentName = attachmentInfo.name;
|
||||||
const attachmentContents = await this.getRequest(attachmentInfo.url, true);
|
const attachmentContents = await this.getRequest(attachmentInfo.url, true);
|
||||||
smartmail.addAttachment(new plugins.smartfile.Smartfile({
|
smartmail.addAttachment(
|
||||||
path: `./${attachmentName}`,
|
new plugins.smartfile.Smartfile({
|
||||||
base: `./${attachmentName}`,
|
path: `./${attachmentName}`,
|
||||||
contentBuffer: attachmentContents.body
|
base: `./${attachmentName}`,
|
||||||
}));
|
contentBuffer: attachmentContents.body
|
||||||
|
})
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user