@aws-amplify/amplify-category-auth
Version:
amplify-cli authentication plugin
28 lines • 1.71 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.updateAppClientWithGeneratedSecret = void 0;
const amplify_cli_core_1 = require("@aws-amplify/amplify-cli-core");
const getAuthResourceName_1 = require("../../../utils/getAuthResourceName");
const get_app_client_secret_sdk_1 = require("./get-app-client-secret-sdk");
const project_has_auth_1 = require("./project-has-auth");
const updateAppClientWithGeneratedSecret = async (context) => {
var _a, _b;
if ((0, project_has_auth_1.projectHasAuth)()) {
const { imported } = context.amplify.getImportedAuthProperties(context);
if (!imported) {
const authResourceName = await (0, getAuthResourceName_1.getAuthResourceName)(context);
const authMetaOutput = (_b = (_a = amplify_cli_core_1.stateManager.getMeta()) === null || _a === void 0 ? void 0 : _a.auth[authResourceName]) === null || _b === void 0 ? void 0 : _b.output;
const clientId = authMetaOutput.AppClientID;
const userpoolId = authMetaOutput.UserPoolId;
if (clientId && userpoolId) {
const appClientSecret = await (0, get_app_client_secret_sdk_1.getAppClientSecret)(context, userpoolId, clientId);
if (appClientSecret) {
authMetaOutput.AppClientSecret = appClientSecret;
await context.amplify.updateamplifyMetaAfterResourceUpdate(amplify_cli_core_1.AmplifyCategories.AUTH, authResourceName, 'output', authMetaOutput);
}
}
}
}
};
exports.updateAppClientWithGeneratedSecret = updateAppClientWithGeneratedSecret;
//# sourceMappingURL=generate-cognito-app-client-secret.js.map