From 35d96f54c8a26cfeee18c33ec572c25c44de1315 Mon Sep 17 00:00:00 2001 From: mike12345567 Date: Tue, 16 Nov 2021 10:30:37 +0000 Subject: [PATCH] Adding specific error cases to all app ID checking functions - three cases, is dev/prod, isn't and no app/ID provided. --- packages/auth/src/db/utils.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/packages/auth/src/db/utils.js b/packages/auth/src/db/utils.js index 11ce51fae9..14e80df735 100644 --- a/packages/auth/src/db/utils.js +++ b/packages/auth/src/db/utils.js @@ -8,6 +8,8 @@ const fetch = require("node-fetch") const { getCouch } = require("./index") const { getAppMetadata } = require("../cache/appMetadata") +const NO_APP_ERROR = "No app provided" + const UNICODE_MAX = "\ufff0" exports.ViewNames = { @@ -46,16 +48,22 @@ function getDocParams(docType, docId = null, otherProps = {}) { } exports.isDevAppID = appId => { + if (!appId) { + throw NO_APP_ERROR + } return appId.startsWith(exports.APP_DEV_PREFIX) } exports.isProdAppID = appId => { + if (!appId) { + throw NO_APP_ERROR + } return appId.startsWith(exports.APP_PREFIX) && !exports.isDevAppID(appId) } function isDevApp(app) { if (!app) { - return false + throw NO_APP_ERROR } return exports.isDevAppID(app.appId) }