UNPKG

@cognigy/rest-api-client

Version:

Cognigy REST-Client

51 lines 2.09 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.microsoftTokenStatusNode = void 0; /* Custom modules */ const createNodeDescriptor_1 = require("../../../createNodeDescriptor"); const design_1 = require("../utils/design"); /** * Node name: 'teamsPermissions' * * Purpose: * divide the flow into granted and not granted requests */ exports.microsoftTokenStatusNode = (0, createNodeDescriptor_1.createNodeDescriptor)({ type: "microsoftTokenStatus", defaultLabel: "Token Status", summary: "UI__NODE_EDITOR__MICROSOFT__TOKEN_STATUS__SUMMARY", appearance: { showIcon: true, color: design_1.nodeColor, }, fields: [], sections: [], tags: ["microsoft"], dependencies: { children: ["microsoftTokenGranted", "microsoftTokenNotGranted"] }, function: async ({ cognigy, childConfigs }) => { const { api, input } = cognigy; const tokenGrantedChild = childConfigs === null || childConfigs === void 0 ? void 0 : childConfigs.find((child) => child.type === "microsoftTokenGranted"); const tokenNotGrantedChild = childConfigs === null || childConfigs === void 0 ? void 0 : childConfigs.find((child) => child.type === "microsoftTokenNotGranted"); /** Permissions not requested */ if (!input.data.microsoftSsoPermissionRequest) { api.setNextNode(tokenNotGrantedChild.id); /** Permissions granted and token valid */ } else if (input.data.microsoftSsoPermissionRequest === "completed" && input.data.microsoftSsoToken !== null) { api.setNextNode(tokenGrantedChild.id); /** Token expired or Logged out */ } else if (input.data.microsoftSsoPermissionRequest === "completed" && input.data.microsoftSsoToken === null) { api.setNextNode(tokenNotGrantedChild.id); /** Permissions not yet accepted or declined */ } else { api.setNextNode(tokenNotGrantedChild.id); } }, }); //# sourceMappingURL=index.js.map