UNPKG

@aws-amplify/auth

Version:
33 lines (31 loc) 1.24 kB
'use strict'; // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. // SPDX-License-Identifier: Apache-2.0 Object.defineProperty(exports, "__esModule", { value: true }); exports.getRegionFromIdentityPoolId = exports.getRegion = void 0; const AuthError_1 = require("../../../../../errors/AuthError"); function getRegion(userPoolId) { const region = userPoolId?.split('_')[0]; if (!userPoolId || userPoolId.indexOf('_') < 0 || !region || typeof region !== 'string') throw new AuthError_1.AuthError({ name: 'InvalidUserPoolId', message: 'Invalid user pool id provided.', }); return region; } exports.getRegion = getRegion; function getRegionFromIdentityPoolId(identityPoolId) { if (!identityPoolId || !identityPoolId.includes(':')) { throw new AuthError_1.AuthError({ name: 'InvalidIdentityPoolIdException', message: 'Invalid identity pool id provided.', recoverySuggestion: 'Make sure a valid identityPoolId is given in the config.', }); } return identityPoolId.split(':')[0]; } exports.getRegionFromIdentityPoolId = getRegionFromIdentityPoolId; //# sourceMappingURL=utils.js.map