From bc4cae333303b16aa962456354ecf3b5b7541041 Mon Sep 17 00:00:00 2001 From: Phil Kunz Date: Wed, 19 Feb 2020 16:58:46 +0000 Subject: [PATCH] fix(core): update --- package-lock.json | 6 +++--- qenv.yml | 1 - test/test.ts | 5 +---- ts/cloudflare.classes.account.ts | 13 +++++-------- 4 files changed, 9 insertions(+), 16 deletions(-) diff --git a/package-lock.json b/package-lock.json index 8249e47..a82a1c7 100644 --- a/package-lock.json +++ b/package-lock.json @@ -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", diff --git a/qenv.yml b/qenv.yml index d42e153..1e2966d 100644 --- a/qenv.yml +++ b/qenv.yml @@ -1,3 +1,2 @@ required: - - CF_EMAIL - CF_KEY \ No newline at end of file diff --git a/test/test.ts b/test/test.ts index eb1f7a0..0d05ab1 100644 --- a/test/test.ts +++ b/test/test.ts @@ -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 => { diff --git a/ts/cloudflare.classes.account.ts b/ts/cloudflare.classes.account.ts index 0534067..25a3ff5 100644 --- a/ts/cloudflare.classes.account.ts +++ b/ts/cloudflare.classes.account.ts @@ -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 } /** @@ -192,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 }, @@ -237,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 } }