Compare commits
8 Commits
Author | SHA1 | Date | |
---|---|---|---|
a746577945 | |||
bc4cae3333 | |||
e0614b5956 | |||
f568949085 | |||
bee256416f | |||
afa2679501 | |||
7838642fd5 | |||
7a992badf4 |
20
package-lock.json
generated
20
package-lock.json
generated
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@mojoio/cloudflare",
|
||||
"version": "4.0.1",
|
||||
"version": "4.0.5",
|
||||
"lockfileVersion": 1,
|
||||
"requires": true,
|
||||
"dependencies": {
|
||||
@ -348,9 +348,9 @@
|
||||
}
|
||||
},
|
||||
"@tsclass/tsclass": {
|
||||
"version": "3.0.4",
|
||||
"resolved": "https://verdaccio.lossless.one/@tsclass%2ftsclass/-/tsclass-3.0.4.tgz",
|
||||
"integrity": "sha512-q9PnwBFDTTlwKp6jYn/tL6zhqWvwaKyGsf81xI8xcV6IhjmFo3hk0iM4L3ydw7iTwqR+WmhYaWO5WdMy3/KA+w==",
|
||||
"version": "3.0.7",
|
||||
"resolved": "https://verdaccio.lossless.one/@tsclass%2ftsclass/-/tsclass-3.0.7.tgz",
|
||||
"integrity": "sha512-3s3pU0xrQsMpsvxby0eUgz6z3DpJTaRghLpoFSJ+uJMzi7n0QhwuEiydLbp1CgVvDnIByvQcN8LvU9q3tOswSA==",
|
||||
"requires": {
|
||||
"@pushrocks/tapbundle": "^3.0.13"
|
||||
}
|
||||
@ -429,9 +429,9 @@
|
||||
"dev": true
|
||||
},
|
||||
"@types/node": {
|
||||
"version": "13.7.0",
|
||||
"resolved": "https://verdaccio.lossless.one/@types%2fnode/-/node-13.7.0.tgz",
|
||||
"integrity": "sha512-GnZbirvmqZUzMgkFn70c74OQpTTUcCzlhQliTzYjQMqg+hVKcDnxdL19Ne3UdYzdMA/+W3eb646FWn/ZaT1NfQ=="
|
||||
"version": "13.7.2",
|
||||
"resolved": "https://verdaccio.lossless.one/@types%2fnode/-/node-13.7.2.tgz",
|
||||
"integrity": "sha512-uvilvAQbdJvnSBFcKJ2td4016urcGvsiR+N4dHGU87ml8O2Vl6l+ErOi9w0kXSPiwJ1AYlIW+0pDXDWWMOiWbw=="
|
||||
},
|
||||
"@types/shortid": {
|
||||
"version": "0.0.29",
|
||||
@ -933,9 +933,9 @@
|
||||
"dev": true
|
||||
},
|
||||
"js-base64": {
|
||||
"version": "2.5.1",
|
||||
"resolved": "https://verdaccio.lossless.one/js-base64/-/js-base64-2.5.1.tgz",
|
||||
"integrity": "sha512-M7kLczedRMYX4L8Mdh4MzyAMM9O5osx+4FcOQuTvr3A9F2D9S5JXheN0ewNbrvK2UatkTRhL5ejGmGSjNMiZuw=="
|
||||
"version": "2.5.2",
|
||||
"resolved": "https://verdaccio.lossless.one/js-base64/-/js-base64-2.5.2.tgz",
|
||||
"integrity": "sha512-Vg8czh0Q7sFBSUMWWArX/miJeBWYBPpdU/3M/DKSaekLMqrqVPaedp+5mZhie/r0lgrcaYBfwXatEew6gwgiQQ=="
|
||||
},
|
||||
"js-tokens": {
|
||||
"version": "4.0.0",
|
||||
|
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@mojoio/cloudflare",
|
||||
"version": "4.0.1",
|
||||
"version": "4.0.5",
|
||||
"private": false,
|
||||
"description": "easy cloudflare management",
|
||||
"main": "dist/index.js",
|
||||
@ -29,7 +29,7 @@
|
||||
"@pushrocks/smartpromise": "^3.0.6",
|
||||
"@pushrocks/smartrequest": "^1.1.47",
|
||||
"@pushrocks/smartstring": "^3.0.18",
|
||||
"@tsclass/tsclass": "^3.0.4"
|
||||
"@tsclass/tsclass": "^3.0.7"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@gitzone/tsbuild": "^2.1.17",
|
||||
@ -37,7 +37,7 @@
|
||||
"@gitzone/tstest": "^1.0.28",
|
||||
"@pushrocks/qenv": "^4.0.6",
|
||||
"@pushrocks/tapbundle": "^3.2.0",
|
||||
"@types/node": "^13.7.0",
|
||||
"@types/node": "^13.7.2",
|
||||
"tslint": "^6.0.0",
|
||||
"tslint-config-prettier": "^1.18.0"
|
||||
},
|
||||
|
@ -11,10 +11,7 @@ const randomPrefix = Math.floor(Math.random() * 2000);
|
||||
let testCloudflareAccount: cloudflare.CloudflareAccount;
|
||||
|
||||
tap.test('should create a valid instance of CloudflareAccount', async () => {
|
||||
testCloudflareAccount = new cloudflare.CloudflareAccount({
|
||||
email: testQenv.getEnvVarOnDemand('CF_EMAIL'),
|
||||
key: testQenv.getEnvVarOnDemand('CF_KEY')
|
||||
});
|
||||
testCloudflareAccount = new cloudflare.CloudflareAccount(testQenv.getEnvVarOnDemand('CF_KEY'));
|
||||
});
|
||||
|
||||
tap.test('.listZones() -> should display an entire account', async tools => {
|
||||
|
@ -6,8 +6,7 @@ import { WorkerManager } from './cloudflare.classes.workermanager';
|
||||
import { ZoneManager } from './cloudflare.classes.zonemanager';
|
||||
|
||||
export class CloudflareAccount {
|
||||
private authEmail: string;
|
||||
private authKey: string;
|
||||
private authToken: string;
|
||||
private accountIdentifier: string;
|
||||
|
||||
public workerManager = new WorkerManager(this);
|
||||
@ -17,9 +16,8 @@ export class CloudflareAccount {
|
||||
* constructor sets auth information on the CloudflareAccountInstance
|
||||
* @param optionsArg
|
||||
*/
|
||||
constructor(optionsArg: { email: string; key: string }) {
|
||||
this.authEmail = optionsArg.email;
|
||||
this.authKey = optionsArg.key;
|
||||
constructor(authTokenArg: string) {
|
||||
this.authToken = authTokenArg
|
||||
}
|
||||
|
||||
/**
|
||||
@ -63,7 +61,7 @@ export class CloudflareAccount {
|
||||
*/
|
||||
getRecord: async (
|
||||
domainNameArg: string,
|
||||
typeArg: plugins.tsclass.network.TDnsRecord
|
||||
typeArg: plugins.tsclass.network.TDnsRecordType
|
||||
): Promise<interfaces.ICflareRecord> => {
|
||||
const domain = new plugins.smartstring.Domain(domainNameArg);
|
||||
const recordArrayArg = await this.convenience.listRecords(domain.zoneName);
|
||||
@ -77,7 +75,7 @@ export class CloudflareAccount {
|
||||
*/
|
||||
createRecord: async (
|
||||
domainNameArg: string,
|
||||
typeArg: plugins.tsclass.network.TDnsRecord,
|
||||
typeArg: plugins.tsclass.network.TDnsRecordType,
|
||||
contentArg: string
|
||||
): Promise<any> => {
|
||||
const domain = new plugins.smartstring.Domain(domainNameArg);
|
||||
@ -101,7 +99,7 @@ export class CloudflareAccount {
|
||||
*/
|
||||
removeRecord: async (
|
||||
domainNameArg: string,
|
||||
typeArg: plugins.tsclass.network.TDnsRecord
|
||||
typeArg: plugins.tsclass.network.TDnsRecordType
|
||||
): Promise<any> => {
|
||||
const domain = new plugins.smartstring.Domain(domainNameArg);
|
||||
const cflareRecord = await this.convenience.getRecord(domain.fullName, typeArg);
|
||||
@ -115,13 +113,16 @@ export class CloudflareAccount {
|
||||
/**
|
||||
* cleanrecord allows the cleaning of any previous records to avoid unwanted sideeffects
|
||||
*/
|
||||
cleanRecord: async (domainNameArg: string, typeArg: plugins.tsclass.network.TDnsRecordType) => {
|
||||
console.log(`cleaning record for ${domainNameArg}`);
|
||||
},
|
||||
/**
|
||||
* updates a record
|
||||
* @param domainNameArg
|
||||
* @param typeArg
|
||||
* @param valueArg
|
||||
*/
|
||||
updateRecord: async (domainNameArg: string, typeArg: string, valueArg) => {
|
||||
updateRecord: async (domainNameArg: string, typeArg: plugins.tsclass.network.TDnsRecordType, valueArg) => {
|
||||
// TODO: implement
|
||||
const domain = new plugins.smartstring.Domain(domainNameArg);
|
||||
},
|
||||
@ -170,7 +171,7 @@ export class CloudflareAccount {
|
||||
},
|
||||
// acme convenience functions
|
||||
acmeSetDnsChallenge: async (dnsChallenge: plugins.tsclass.network.IDnsChallenge) => {
|
||||
await this.convenience.removeRecord(dnsChallenge.hostName, 'TXT');
|
||||
await this.convenience.cleanRecord(dnsChallenge.hostName, 'TXT');
|
||||
await this.convenience.createRecord(dnsChallenge.hostName, 'TXT', dnsChallenge.challenge);
|
||||
},
|
||||
acmeRemoveDnsChallenge: async (dnsChallenge: plugins.tsclass.network.IDnsChallenge) => {
|
||||
@ -189,8 +190,7 @@ export class CloudflareAccount {
|
||||
method: methodArg,
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
'X-Auth-Email': this.authEmail,
|
||||
'X-Auth-Key': this.authKey,
|
||||
'Authorization': `Bearer ${this.authToken}`,
|
||||
'Content-Length': Buffer.byteLength(JSON.stringify(dataArg)),
|
||||
...requestHeadersArg
|
||||
},
|
||||
@ -234,6 +234,6 @@ export class CloudflareAccount {
|
||||
}
|
||||
|
||||
private authCheck() {
|
||||
return this.authEmail && this.authKey; // check if auth is available
|
||||
return !!this.authToken; // check if auth is available
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user