@aws-amplify/amplify-category-predictions
Version:
amplify-cli predictions plugin
40 lines • 1.72 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.enableGuestAuth = void 0;
const os = require('os');
const { AmplifyError } = require('@aws-amplify/amplify-cli-core');
async function enableGuestAuth(context, resourceName, allowUnauthenticatedIdentities) {
const identifyRequirements = { authSelections: 'identityPoolAndUserPool', allowUnauthenticatedIdentities };
const checkResult = await context.amplify.invokePluginMethod(context, 'auth', undefined, 'checkRequirements', [
identifyRequirements,
context,
'predictions',
resourceName,
]);
if (checkResult.authImported === true && checkResult.errors && checkResult.errors.length > 0) {
throw new AmplifyError('ConfigurationError', {
message: 'The imported auth config is not compatible with the specified predictions config',
details: checkResult.errors.join(os.EOL),
resolution: 'Manually configure the imported auth resource according to the details above',
});
}
if (checkResult.errors && checkResult.errors.length > 0) {
context.print.warning(checkResult.errors.join(os.EOL));
}
if (!checkResult.authEnabled || !checkResult.requirementsMet) {
try {
await context.amplify.invokePluginMethod(context, 'auth', undefined, 'externalAuthEnable', [
context,
'predictions',
resourceName,
identifyRequirements,
]);
}
catch (error) {
context.print.error(error);
throw error;
}
}
}
exports.enableGuestAuth = enableGuestAuth;
//# sourceMappingURL=enable-guest-auth.js.map