Compare commits

..

4 Commits

Author SHA1 Message Date
9d8c14d187 5.0.7 2021-01-22 20:45:36 +00:00
5a0b12f6aa fix(core): update 2021-01-22 20:45:35 +00:00
387f00078f 5.0.6 2020-06-10 05:34:48 +00:00
fe2f45e3a9 fix(core): update 2020-06-10 05:34:47 +00:00
10 changed files with 8269 additions and 1632 deletions

4
.gitignore vendored
View File

@ -15,8 +15,6 @@ node_modules/
# builds # builds
dist/ dist/
dist_web/ dist_*/
dist_serve/
dist_ts_web/
# custom # custom

View File

@ -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

9818
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -1,6 +1,6 @@
{ {
"name": "@mojoio/cloudflare", "name": "@mojoio/cloudflare",
"version": "5.0.5", "version": "5.0.7",
"private": false, "private": false,
"description": "easy cloudflare management", "description": "easy cloudflare management",
"main": "dist_ts/index.js", "main": "dist_ts/index.js",
@ -24,28 +24,29 @@
}, },
"homepage": "https://gitlab.com/pushrocks/cflare#readme", "homepage": "https://gitlab.com/pushrocks/cflare#readme",
"dependencies": { "dependencies": {
"@pushrocks/smartdelay": "^2.0.9", "@pushrocks/smartdelay": "^2.0.10",
"@pushrocks/smartlog": "^2.0.28", "@pushrocks/smartlog": "^2.0.39",
"@pushrocks/smartpromise": "^3.0.6", "@pushrocks/smartpromise": "^3.1.3",
"@pushrocks/smartrequest": "^1.1.47", "@pushrocks/smartrequest": "^1.1.51",
"@pushrocks/smartstring": "^3.0.18", "@pushrocks/smartstring": "^3.0.24",
"@tsclass/tsclass": "^3.0.17" "@tsclass/tsclass": "^3.0.29"
}, },
"devDependencies": { "devDependencies": {
"@gitzone/tsbuild": "^2.1.24", "@gitzone/tsbuild": "^2.1.25",
"@gitzone/tsrun": "^1.2.12", "@gitzone/tsrun": "^1.2.12",
"@gitzone/tstest": "^1.0.33", "@gitzone/tstest": "^1.0.52",
"@pushrocks/qenv": "^4.0.10", "@pushrocks/qenv": "^4.0.10",
"@pushrocks/tapbundle": "^3.2.1", "@pushrocks/tapbundle": "^3.2.9",
"@types/node": "^14.0.13", "@types/node": "^14.14.22",
"tslint": "^6.1.2", "tslint": "^6.1.3",
"tslint-config-prettier": "^1.18.0" "tslint-config-prettier": "^1.18.0"
}, },
"files": [ "files": [
"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",

View File

@ -8,13 +8,20 @@ easy cloudflare management
* [docs (typedoc)](https://mojoio.gitlab.io/cloudflare/) * [docs (typedoc)](https://mojoio.gitlab.io/cloudflare/)
## Status for master ## Status for master
[![pipeline status](https://gitlab.com/mojoio/cloudflare/badges/master/pipeline.svg)](https://gitlab.com/mojoio/cloudflare/commits/master)
[![coverage report](https://gitlab.com/mojoio/cloudflare/badges/master/coverage.svg)](https://gitlab.com/mojoio/cloudflare/commits/master) Status Category | Status Badge
[![npm downloads per month](https://img.shields.io/npm/dm/@mojoio/cloudflare.svg)](https://www.npmjs.com/package/@mojoio/cloudflare) -- | --
[![Known Vulnerabilities](https://snyk.io/test/npm/@mojoio/cloudflare/badge.svg)](https://snyk.io/test/npm/@mojoio/cloudflare) GitLab Pipelines | [![pipeline status](https://gitlab.com/mojoio/cloudflare/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/cloudflare/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/cloudflare)](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/cloudflare)](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/cloudflare)](https://lossless.cloud)
PackagePhobia (package size on registry) | [![PackagePhobia](https://badgen.net/packagephobia/publish/@mojoio/cloudflare)](https://lossless.cloud)
BundlePhobia (total size when bundled) | [![BundlePhobia](https://badgen.net/bundlephobia/minzip/@mojoio/cloudflare)](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

View File

@ -47,10 +47,7 @@ export class CloudflareAccount {
if (filteredResponse.length >= 1) { if (filteredResponse.length >= 1) {
return filteredResponse[0].id; return filteredResponse[0].id;
} else { } else {
logger.log( logger.log('error', `the domain ${domainName} does not appear to be in this account!`);
'error',
`the domain ${domainName} does not appear to be in this account!`
);
throw new Error(`the domain ${domainName} does not appear to be in this account!`); throw new Error(`the domain ${domainName} does not appear to be in this account!`);
} }
}, },
@ -76,14 +73,16 @@ export class CloudflareAccount {
createRecord: async ( createRecord: async (
domainNameArg: string, domainNameArg: string,
typeArg: plugins.tsclass.network.TDnsRecordType, typeArg: plugins.tsclass.network.TDnsRecordType,
contentArg: string contentArg: string,
ttlArg = 1
): Promise<any> => { ): Promise<any> => {
const domain = new plugins.smartstring.Domain(domainNameArg); const domain = new plugins.smartstring.Domain(domainNameArg);
const domainIdArg = await this.convenience.getZoneId(domain.zoneName); const domainIdArg = await this.convenience.getZoneId(domain.zoneName);
const dataObject = { const dataObject = {
name: domain.fullName, name: domain.fullName,
type: typeArg, type: typeArg,
content: contentArg content: contentArg,
ttl: ttlArg
}; };
const response = await this.request( const response = await this.request(
'POST', 'POST',
@ -176,7 +175,7 @@ export class CloudflareAccount {
// acme convenience functions // acme convenience functions
acmeSetDnsChallenge: async (dnsChallenge: plugins.tsclass.network.IDnsChallenge) => { acmeSetDnsChallenge: async (dnsChallenge: plugins.tsclass.network.IDnsChallenge) => {
await this.convenience.cleanRecord(dnsChallenge.hostName, 'TXT'); await this.convenience.cleanRecord(dnsChallenge.hostName, 'TXT');
await this.convenience.createRecord(dnsChallenge.hostName, 'TXT', dnsChallenge.challenge); await this.convenience.createRecord(dnsChallenge.hostName, 'TXT', dnsChallenge.challenge, 2);
}, },
acmeRemoveDnsChallenge: async (dnsChallenge: plugins.tsclass.network.IDnsChallenge) => { acmeRemoveDnsChallenge: async (dnsChallenge: plugins.tsclass.network.IDnsChallenge) => {
await this.convenience.removeRecord(dnsChallenge.hostName, 'TXT'); await this.convenience.removeRecord(dnsChallenge.hostName, 'TXT');

View File

@ -1,5 +1,3 @@
import * as plugins from './cloudflare.plugins'; import * as plugins from './cloudflare.plugins';
export class CloudflareRecord { export class CloudflareRecord {}
}

View File

@ -47,5 +47,4 @@ export class CloudflareZone implements interfaces.ICflareZone {
paused: boolean; paused: boolean;
type: string; type: string;
checked_on: string; checked_on: string;
} }

View File

@ -14,14 +14,14 @@ export class ZoneManager {
public async getZones(zoneName: string) { public async getZones(zoneName: string) {
let requestRoute = `/zones?per_page=50`; let requestRoute = `/zones?per_page=50`;
// may be optionally filtered by domain name // may be optionally filtered by domain name
if (zoneName) { if (zoneName) {
requestRoute = `${requestRoute}&name=${zoneName}`; requestRoute = `${requestRoute}&name=${zoneName}`;
} }
const response: any = await this.cfAccount.request('GET', requestRoute); const response: any = await this.cfAccount.request('GET', requestRoute);
const apiObjects: interfaces.ICflareZone[] = response.result; const apiObjects: interfaces.ICflareZone[] = response.result;
const cloudflareZoneArray = []; const cloudflareZoneArray = [];
for (const apiObject of apiObjects) { for (const apiObject of apiObjects) {
cloudflareZoneArray.push(CloudflareZone.createFromApiObject(apiObject)); cloudflareZoneArray.push(CloudflareZone.createFromApiObject(apiObject));

View File

@ -1,3 +1,3 @@
import * as plugins from './cloudflare.plugins'; import * as plugins from './cloudflare.plugins';
export const logger = new plugins.smartlog.ConsoleLog(); export const logger = new plugins.smartlog.ConsoleLog();