diff --git a/src/blob/BlobEnvironment.ts b/src/blob/BlobEnvironment.ts index 19978e592..79ccda23b 100644 --- a/src/blob/BlobEnvironment.ts +++ b/src/blob/BlobEnvironment.ts @@ -132,7 +132,14 @@ export default class BlobEnvironment implements IBlobEnvironment { } public oauth(): string | undefined { - return this.flags.oauth; + if (this.flags.oauth !== undefined) { + if (this.flags.oauth !== "basic") { + throw RangeError( + `Must provide a valid value for parameter --oauth, only 'basic' is supported.` + ); + } + return this.flags.oauth; + } } public disableProductStyleUrl(): boolean { diff --git a/src/common/ConfigurationBase.ts b/src/common/ConfigurationBase.ts index be3f0928b..fcd7dab87 100644 --- a/src/common/ConfigurationBase.ts +++ b/src/common/ConfigurationBase.ts @@ -91,7 +91,7 @@ export default abstract class ConfigurationBase { } public getOAuthLevel(): undefined | OAuthLevel { - if (this.oauth) { + if (this.oauth && typeof this.oauth === "string") { if (this.oauth.toLowerCase() === "basic") { return OAuthLevel.BASIC; } diff --git a/src/common/Environment.ts b/src/common/Environment.ts index e42c4fddb..53709785e 100644 --- a/src/common/Environment.ts +++ b/src/common/Environment.ts @@ -201,7 +201,14 @@ export default class Environment implements IEnvironment { } public oauth(): string | undefined { - return this.flags.oauth; + if (this.flags.oauth !== undefined) { + if (this.flags.oauth !== "basic") { + throw RangeError( + `Must provide a valid value for parameter --oauth, only 'basic' is supported.` + ); + } + return this.flags.oauth; + } } public inMemoryPersistence(): boolean { diff --git a/src/queue/QueueEnvironment.ts b/src/queue/QueueEnvironment.ts index b0228e013..d1c352a78 100644 --- a/src/queue/QueueEnvironment.ts +++ b/src/queue/QueueEnvironment.ts @@ -116,7 +116,14 @@ export default class QueueEnvironment implements IQueueEnvironment { } public oauth(): string | undefined { - return this.flags.oauth; + if (this.flags.oauth !== undefined) { + if (this.flags.oauth !== "basic") { + throw RangeError( + `Must provide a valid value for parameter --oauth, only 'basic' is supported.` + ); + } + return this.flags.oauth; + } } public disableProductStyleUrl(): boolean { diff --git a/src/table/TableEnvironment.ts b/src/table/TableEnvironment.ts index 86007cd85..f9de0f9ef 100644 --- a/src/table/TableEnvironment.ts +++ b/src/table/TableEnvironment.ts @@ -153,7 +153,14 @@ export default class TableEnvironment implements ITableEnvironment { } public oauth(): string | undefined { - return this.flags.oauth; + if (this.flags.oauth !== undefined) { + if (this.flags.oauth !== "basic") { + throw RangeError( + `Must provide a valid value for parameter --oauth, only 'basic' is supported.` + ); + } + return this.flags.oauth; + } } public cert(): string | undefined {