fix(core): update

This commit is contained in:
Philipp Kunz 2020-02-19 16:58:46 +00:00
parent e0614b5956
commit bc4cae3333
4 changed files with 9 additions and 16 deletions

6
package-lock.json generated
View File

@ -933,9 +933,9 @@
"dev": true "dev": true
}, },
"js-base64": { "js-base64": {
"version": "2.5.1", "version": "2.5.2",
"resolved": "https://verdaccio.lossless.one/js-base64/-/js-base64-2.5.1.tgz", "resolved": "https://verdaccio.lossless.one/js-base64/-/js-base64-2.5.2.tgz",
"integrity": "sha512-M7kLczedRMYX4L8Mdh4MzyAMM9O5osx+4FcOQuTvr3A9F2D9S5JXheN0ewNbrvK2UatkTRhL5ejGmGSjNMiZuw==" "integrity": "sha512-Vg8czh0Q7sFBSUMWWArX/miJeBWYBPpdU/3M/DKSaekLMqrqVPaedp+5mZhie/r0lgrcaYBfwXatEew6gwgiQQ=="
}, },
"js-tokens": { "js-tokens": {
"version": "4.0.0", "version": "4.0.0",

View File

@ -1,3 +1,2 @@
required: required:
- CF_EMAIL
- CF_KEY - CF_KEY

View File

@ -11,10 +11,7 @@ const randomPrefix = Math.floor(Math.random() * 2000);
let testCloudflareAccount: cloudflare.CloudflareAccount; let testCloudflareAccount: cloudflare.CloudflareAccount;
tap.test('should create a valid instance of CloudflareAccount', async () => { tap.test('should create a valid instance of CloudflareAccount', async () => {
testCloudflareAccount = new cloudflare.CloudflareAccount({ testCloudflareAccount = new cloudflare.CloudflareAccount(testQenv.getEnvVarOnDemand('CF_KEY'));
email: testQenv.getEnvVarOnDemand('CF_EMAIL'),
key: testQenv.getEnvVarOnDemand('CF_KEY')
});
}); });
tap.test('.listZones() -> should display an entire account', async tools => { tap.test('.listZones() -> should display an entire account', async tools => {

View File

@ -6,8 +6,7 @@ import { WorkerManager } from './cloudflare.classes.workermanager';
import { ZoneManager } from './cloudflare.classes.zonemanager'; import { ZoneManager } from './cloudflare.classes.zonemanager';
export class CloudflareAccount { export class CloudflareAccount {
private authEmail: string; private authToken: string;
private authKey: string;
private accountIdentifier: string; private accountIdentifier: string;
public workerManager = new WorkerManager(this); public workerManager = new WorkerManager(this);
@ -17,9 +16,8 @@ export class CloudflareAccount {
* constructor sets auth information on the CloudflareAccountInstance * constructor sets auth information on the CloudflareAccountInstance
* @param optionsArg * @param optionsArg
*/ */
constructor(optionsArg: { email: string; key: string }) { constructor(authTokenArg: string) {
this.authEmail = optionsArg.email; this.authToken = authTokenArg
this.authKey = optionsArg.key;
} }
/** /**
@ -192,8 +190,7 @@ export class CloudflareAccount {
method: methodArg, method: methodArg,
headers: { headers: {
'Content-Type': 'application/json', 'Content-Type': 'application/json',
'X-Auth-Email': this.authEmail, 'Authorization': `Bearer ${this.authToken}`,
'X-Auth-Key': this.authKey,
'Content-Length': Buffer.byteLength(JSON.stringify(dataArg)), 'Content-Length': Buffer.byteLength(JSON.stringify(dataArg)),
...requestHeadersArg ...requestHeadersArg
}, },
@ -237,6 +234,6 @@ export class CloudflareAccount {
} }
private authCheck() { private authCheck() {
return this.authEmail && this.authKey; // check if auth is available return !!this.authToken; // check if auth is available
} }
} }