checkout-sdk-node
Advanced tools
Comparing version 1.0.30 to 1.0.31
@@ -18,2 +18,6 @@ "use strict"; | ||
if (key.startsWith('Bearer')) { | ||
key = key.replace('Bearer', '').trim(); | ||
} | ||
return _config.MBC_LIVE_SECRET_KEY_REGEX.test(key) || _config.NAS_LIVE_SECRET_KEY_REGEX.test(key) ? _config.LIVE_BASE_URL : _config.SANDBOX_BASE_URL; | ||
@@ -24,3 +28,9 @@ }; | ||
// Unless specified, check environment variables for the key | ||
return !key ? process.env.CKO_SECRET_KEY || '' : key; | ||
let authKey = !key ? process.env.CKO_SECRET_KEY || '' : key; // In case of NAS static keys, append the Bearer prefix | ||
if (_config.NAS_LIVE_SECRET_KEY_REGEX.test(authKey) || _config.NAS_SANDBOX_SECRET_KEY_REGEX.test(authKey)) { | ||
authKey = authKey.startsWith('Bearer') || authKey.startsWith('bearer') ? authKey : `Bearer ${authKey}`; | ||
} | ||
return authKey; | ||
}; | ||
@@ -27,0 +37,0 @@ |
@@ -6,3 +6,3 @@ "use strict"; | ||
}); | ||
exports.CURRENCIES = exports.PAYMENT_TYPES = exports.SOURCE_ID_REGEX = exports.CARD_TOKEN_REGEX = exports.NAS_LIVE_SECRET_KEY_REGEX = exports.MBC_LIVE_SECRET_KEY_REGEX = exports.DEFAULT_TIMEOUT = exports.API_VERSION_HEADER = exports.REQUEST_ID_HEADER = exports.LIVE_BASE_URL = exports.SANDBOX_BASE_URL = void 0; | ||
exports.CURRENCIES = exports.PAYMENT_TYPES = exports.SOURCE_ID_REGEX = exports.CARD_TOKEN_REGEX = exports.NAS_SANDBOX_SECRET_KEY_REGEX = exports.NAS_LIVE_SECRET_KEY_REGEX = exports.MBC_LIVE_SECRET_KEY_REGEX = exports.DEFAULT_TIMEOUT = exports.API_VERSION_HEADER = exports.REQUEST_ID_HEADER = exports.LIVE_BASE_URL = exports.SANDBOX_BASE_URL = void 0; | ||
const SANDBOX_BASE_URL = 'https://api.sandbox.checkout.com'; | ||
@@ -22,2 +22,4 @@ exports.SANDBOX_BASE_URL = SANDBOX_BASE_URL; | ||
exports.NAS_LIVE_SECRET_KEY_REGEX = NAS_LIVE_SECRET_KEY_REGEX; | ||
const NAS_SANDBOX_SECRET_KEY_REGEX = /^sk_sbox_?(\w{27})$/; | ||
exports.NAS_SANDBOX_SECRET_KEY_REGEX = NAS_SANDBOX_SECRET_KEY_REGEX; | ||
const CARD_TOKEN_REGEX = /^(tok)_(\w{26})$/; | ||
@@ -24,0 +26,0 @@ exports.CARD_TOKEN_REGEX = CARD_TOKEN_REGEX; |
{ | ||
"name": "checkout-sdk-node", | ||
"version": "1.0.30", | ||
"version": "1.0.31", | ||
"description": "", | ||
@@ -5,0 +5,0 @@ "main": "./dist/index.js", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
298896
3610