[
    {
        "id": "sd_LL0Qw7OQupjj1oCg",
        "type": "tab",
        "createdDate": "2019-12-04T10:42:13.097Z",
        "label": "ids",
        "disabled": false,
        "info": "",
        "generateNext": false,
        "serviceName": "ids"
    },
    {
        "id": "sd_JyV10OwQxjGQ3QbQ",
        "type": "HttpIn",
        "z": "sd_LL0Qw7OQupjj1oCg",
        "viewType": "server",
        "nodeType": "start",
        "name": "Login API",
        "path": "/login",
        "uploadpath": "",
        "summary": "",
        "description": "",
        "method": "get",
        "sequenceId": "",
        "consumes": "",
        "produces": "",
        "filetype": "path",
        "acceptFileUpload": false,
        "httpOptions": {
            "/login": {
                "get": {
                    "summary": "",
                    "description": "",
                    "consumes": [],
                    "produces": [],
                    "parameters": [],
                    "responses": {}
                }
            }
        },
        "uploadFileOptions": {},
        "editableListData": {
            "responses": [],
            "params": [],
            "produces": [],
            "consumes": []
        },
        "inputs": 0,
        "outputs": 1,
        "category": "HTTP",
        "x": 92,
        "y": 286.953125,
        "wires": [["sd_5rzcMLv3bP73qPEr"]],
        "generateNext": false,
        "serviceName": "ids",
        "functionName": "sd_JyV10OwQxjGQ3QbQ"
    },
    {
        "id": "sd_hduvL50t0cIWul1p",
        "type": "Script",
        "z": "sd_LL0Qw7OQupjj1oCg",
        "viewType": "common",
        "nodeType": "flow",
        "name": "Create session details",
        "script": "bh.local.reqParams = {\n    state : crypto.randomBytes(16).toString('hex'),\n    nonce : crypto.randomBytes(16).toString('hex'),\n    isMobile : bh.input.query.isMobile,\n    redirectTo : bh.input.query.redirectTo\n};",
        "functionName": "sd_hduvL50t0cIWul1p",
        "category": "Function",
        "x": 618,
        "y": 168.21875,
        "wires": [["sd_EaPmKD9xXVAKX78y"]],
        "generateNext": false,
        "generated": false,
        "serviceName": "ids"
    },
    {
        "id": "sd_EaPmKD9xXVAKX78y",
        "type": "Session",
        "z": "sd_LL0Qw7OQupjj1oCg",
        "viewType": "server",
        "nodeType": "flow",
        "name": "",
        "operationType": "update",
        "data": "",
        "resultMapping": "",
        "dataMapping": "bh.local.reqParams",
        "functionName": "sd_EaPmKD9xXVAKX78y",
        "category": "HTTP",
        "__ssdTypeInputs__": {
            "resultMapping": {
                "type": "bh.input",
                "value": ""
            },
            "dataMapping": {
                "type": "bh.local",
                "value": "reqParams"
            }
        },
        "x": 763,
        "y": 410,
        "wires": [["sd_UJyvwmiovNAK11KS"]],
        "generateNext": false,
        "generated": false,
        "serviceName": "ids"
    },
    {
        "id": "sd_7x6jFEe5Iwamz1i4",
        "type": "Script",
        "z": "sd_LL0Qw7OQupjj1oCg",
        "viewType": "common",
        "nodeType": "flow",
        "name": "Calculate IDS login redirect URL",
        "script": "const authorizationRequest = Object.assign({\n    redirect_uri: url.resolve(bh.web.req.href, '/api/login/cb'),\n    scope: 'openid profile email address phone user',\n    state: bh.local.reqParams.state,\n    nonce: bh.local.reqParams.nonce,\n    response_type: bh.input.client.response_types[0],\n}, bh.input.authParams);\n\nbh.local.redirectHeaders = {\n    location: bh.input.client.authorizationUrl(authorizationRequest)\n};\n",
        "functionName": "sd_7x6jFEe5Iwamz1i4",
        "category": "Function",
        "x": 1194,
        "y": 160,
        "wires": [["sd_UNms52aoqvpcipBl"]],
        "generateNext": false,
        "generated": false,
        "serviceName": "ids"
    },
    {
        "id": "sd_UJyvwmiovNAK11KS",
        "type": "CallService",
        "z": "sd_LL0Qw7OQupjj1oCg",
        "viewType": "common",
        "nodeType": "flow",
        "name": "Get IDS client instance",
        "outputs": 1,
        "noerr": 0,
        "service": {
            "serviceId": "sd_kPuz7ywkyl31TXFZ",
            "serviceName": "idsutil",
            "id": "sd_kPuz7ywkyl31TXFZ",
            "label": "idsutil"
        },
        "flow": {
            "flowId": "sd_y6e702ys1ms4W6fk",
            "flowName": "getIDSClientInstance"
        },
        "inputVariables": [
            {
                "key": "clientInstance",
                "map": true,
                "valueType": "bh.input",
                "value": ""
            }
        ],
        "outputMapping": [
            {
                "mapVarType": "input",
                "key": "clientInstance",
                "valueType": "bh.input",
                "value": "client",
                "mapVarName": "clientInstance",
                "localVar": "bh.input.client"
            }
        ],
        "callService": "./idsutil",
        "startName": "getIDSClientInstance",
        "inputParams": [null],
        "accept_bh": false,
        "functionName": "sd_UJyvwmiovNAK11KS",
        "category": "General",
        "x": 903.8125,
        "y": 173.984375,
        "wires": [["sd_uoTtkYEh4hcNyLyS"]],
        "generateNext": false,
        "generated": false,
        "serviceName": "ids"
    },
    {
        "id": "sd_UNms52aoqvpcipBl",
        "type": "HttpOut",
        "z": "sd_LL0Qw7OQupjj1oCg",
        "viewType": "server",
        "nodeType": "flow",
        "name": "Redirect to IDS",
        "headers": {
            "type": "bh.local",
            "value": "redirectHeaders",
            "ssd_typedInputField": true
        },
        "responseBody": {
            "type": "literal",
            "value": "'redirecting'",
            "ssd_typedInputField": true
        },
        "httpcode": {
            "type": "num",
            "value": "302",
            "ssd_typedInputField": true
        },
        "responseType": "obj",
        "responseMapping": {
            "status": 302,
            "obj": "'redirecting'",
            "send": "'redirecting'"
        },
        "cookies": [],
        "inputs": 1,
        "outputs": 0,
        "editableListData": {
            "headers": []
        },
        "cookiesList": {},
        "switchStates": {
            "headers": "Value",
            "cookies": "Map"
        },
        "functionName": "sd_UNms52aoqvpcipBl",
        "category": "HTTP",
        "x": 1343,
        "y": 408,
        "wires": [],
        "generateNext": false,
        "generated": false,
        "serviceName": "ids"
    },
    {
        "id": "sd_WxcIAWis3tf0iKAQ",
        "type": "Switch",
        "z": "sd_LL0Qw7OQupjj1oCg",
        "viewType": "common",
        "nodeType": "flow",
        "name": "Check if client is registered",
        "property": "idsConfigured",
        "propertyType": "bh.local",
        "propertyGv": "bh.local.idsConfigured",
        "rules": [
            {
                "t": "true"
            },
            {
                "t": "else"
            }
        ],
        "checkall": "false",
        "repair": false,
        "outputs": 2,
        "functionName": "sd_WxcIAWis3tf0iKAQ",
        "category": "Function",
        "x": 388,
        "y": 286,
        "wires": [["sd_hduvL50t0cIWul1p"], ["sd_clS4YZYVcemdE8ln"]],
        "generateNext": false,
        "generated": false,
        "serviceName": "ids"
    },
    {
        "id": "sd_5rzcMLv3bP73qPEr",
        "type": "Script",
        "z": "sd_LL0Qw7OQupjj1oCg",
        "viewType": "common",
        "nodeType": "flow",
        "name": "Assert IDS config",
        "script": "bh.local.idsConfigured = false;\nif (settings.default.hasOwnProperty('ids') && settings.default['ids'].hasOwnProperty('client_id') &&\n    settings.default['ids'].hasOwnProperty('client_secret')) {\n    bh.local.idsConfigured = true;\n}",
        "functionName": "sd_5rzcMLv3bP73qPEr",
        "category": "Function",
        "x": 234,
        "y": 287,
        "wires": [["sd_WxcIAWis3tf0iKAQ"]],
        "generateNext": false,
        "generated": false,
        "serviceName": "ids"
    },
    {
        "id": "sd_8vT7OfRGs69i3Maw",
        "type": "HttpOut",
        "z": "sd_LL0Qw7OQupjj1oCg",
        "viewType": "server",
        "nodeType": "flow",
        "name": "Send client not registered response",
        "headers": {},
        "responseBody": {
            "type": "literal",
            "value": "bh.local.res.message",
            "ssd_typedInputField": true
        },
        "httpcode": {
            "type": "num",
            "value": "404",
            "ssd_typedInputField": true
        },
        "responseType": "obj",
        "responseMapping": {
            "status": 404,
            "obj": "bh.local.res.message",
            "send": "bh.local.res.message"
        },
        "cookies": [],
        "inputs": 1,
        "outputs": 0,
        "editableListData": {
            "headers": []
        },
        "cookiesList": {},
        "switchStates": {
            "headers": "Map",
            "cookies": "Map"
        },
        "functionName": "sd_8vT7OfRGs69i3Maw",
        "category": "HTTP",
        "x": 1341,
        "y": 286,
        "wires": [],
        "generateNext": false,
        "generated": false
    },
    {
        "id": "sd_clS4YZYVcemdE8ln",
        "type": "Script",
        "z": "sd_LL0Qw7OQupjj1oCg",
        "viewType": "common",
        "nodeType": "flow",
        "name": "Client not registered object",
        "script": "bh.local.res = {\n    message: 'IDS client not registered. Register on the Neutrinos Stuido and try again'\n}",
        "functionName": "sd_clS4YZYVcemdE8ln",
        "category": "Function",
        "x": 617,
        "y": 291,
        "wires": [["sd_8vT7OfRGs69i3Maw"]],
        "generateNext": false,
        "generated": false
    },
    {
        "id": "sd_Uj2pthPaj29bX9nM",
        "type": "MiddlewareStart",
        "z": "sd_LL0Qw7OQupjj1oCg",
        "viewType": "server",
        "nodeType": "start",
        "name": "hrefstart",
        "inputs": 0,
        "outputs": 1,
        "category": "HTTP",
        "x": 517,
        "y": 691.796875,
        "wires": [["sd_a0fqJviEstKrFNRo"]],
        "generateNext": false,
        "serviceName": "ids",
        "functionName": "sd_Uj2pthPaj29bX9nM"
    },
    {
        "id": "sd_mj9UIokDh2Z4u3Fh",
        "type": "MiddlewareEnd",
        "z": "sd_LL0Qw7OQupjj1oCg",
        "viewType": "server",
        "nodeType": "flow",
        "name": "Href end",
        "headers": {},
        "responseBody": {
            "type": "literal",
            "value": "'end'",
            "ssd_typedInputField": true
        },
        "httpcode": {
            "type": "num",
            "value": "200",
            "ssd_typedInputField": true
        },
        "responseType": "next",
        "responseMapping": {
            "status": 200,
            "next": "'end'"
        },
        "cookies": [],
        "inputs": 1,
        "outputs": 0,
        "editableListData": {
            "headers": []
        },
        "cookiesList": {},
        "switchStates": {
            "headers": "Map",
            "cookies": "Map"
        },
        "functionName": "sd_mj9UIokDh2Z4u3Fh",
        "category": "HTTP",
        "x": 819.890625,
        "y": 692.796875,
        "wires": [],
        "generateNext": false,
        "generated": false
    },
    {
        "id": "sd_a0fqJviEstKrFNRo",
        "type": "Script",
        "z": "sd_LL0Qw7OQupjj1oCg",
        "viewType": "common",
        "nodeType": "flow",
        "name": "Calculate href",
        "script": "const protocol = bh.input.headers['x-forwarded-proto'] || bh.web.req.protocol;\nconst href = protocol + \"://\" + bh.web.req.get('Host') + bh.web.req.originalUrl;\nbh.web.req.href = href;",
        "functionName": "sd_a0fqJviEstKrFNRo",
        "category": "Function",
        "x": 665,
        "y": 692.78125,
        "wires": [["sd_mj9UIokDh2Z4u3Fh"]],
        "generateNext": false,
        "generated": false
    },
    {
        "id": "sd_uoTtkYEh4hcNyLyS",
        "type": "CallService",
        "z": "sd_LL0Qw7OQupjj1oCg",
        "viewType": "common",
        "nodeType": "flow",
        "name": "Get Scope and consent values",
        "outputs": 1,
        "noerr": 0,
        "service": {
            "serviceId": "sd_kPuz7ywkyl31TXFZ",
            "serviceName": "idsutil",
            "id": "sd_kPuz7ywkyl31TXFZ",
            "label": "idsutil"
        },
        "flow": {
            "flowId": "sd_XmR3hnHRWMoc5IZn",
            "flowName": "Get Authorization Params"
        },
        "inputVariables": [
            {
                "key": "authParams",
                "map": false,
                "value": ""
            }
        ],
        "outputMapping": [
            {
                "mapVarType": "input",
                "key": "authParams",
                "valueType": "bh.input",
                "value": "authParams",
                "mapVarName": "authParams",
                "localVar": "bh.input.authParams"
            }
        ],
        "callService": "./idsutil",
        "startName": "getAuthorizationParams",
        "inputParams": [""],
        "accept_bh": false,
        "functionName": "sd_uoTtkYEh4hcNyLyS",
        "category": "General",
        "x": 1051,
        "y": 415.78125,
        "wires": [["sd_7x6jFEe5Iwamz1i4"]],
        "generateNext": false,
        "generated": false
    },
    {
        "id": "sd_sYwN9nvthgPObVqG",
        "type": "HttpIn",
        "z": "sd_LL0Qw7OQupjj1oCg",
        "viewType": "server",
        "nodeType": "start",
        "name": "Login Callback API",
        "path": "/login/cb",
        "uploadpath": "",
        "summary": "",
        "description": "",
        "method": "get",
        "sequenceId": "",
        "consumes": "",
        "produces": "",
        "filetype": "path",
        "acceptFileUpload": false,
        "httpOptions": {
            "/login/cb": {
                "get": {
                    "summary": "",
                    "description": "",
                    "consumes": [],
                    "produces": [],
                    "parameters": [],
                    "responses": {}
                }
            }
        },
        "uploadFileOptions": {},
        "editableListData": {
            "responses": [],
            "params": [],
            "produces": [],
            "consumes": []
        },
        "inputs": 0,
        "outputs": 1,
        "category": "HTTP",
        "x": 88.890625,
        "y": 1038.796875,
        "wires": [["sd_uZHWmXjW8WYRZXIf"]],
        "generateNext": false,
        "serviceName": "ids",
        "functionName": "sd_sYwN9nvthgPObVqG"
    },
    {
        "id": "sd_lL3nIWah2nxanEDS",
        "type": "CallService",
        "z": "sd_LL0Qw7OQupjj1oCg",
        "viewType": "common",
        "nodeType": "flow",
        "name": "Get IDS client instance",
        "outputs": 1,
        "noerr": 0,
        "service": {
            "serviceId": "sd_kPuz7ywkyl31TXFZ",
            "serviceName": "idsutil",
            "id": "sd_kPuz7ywkyl31TXFZ",
            "label": "idsutil"
        },
        "flow": {
            "flowId": "sd_y6e702ys1ms4W6fk",
            "flowName": "getIDSClientInstance"
        },
        "inputVariables": [
            {
                "key": "clientInstance",
                "map": true,
                "valueType": "bh.input",
                "value": ""
            }
        ],
        "outputMapping": [
            {
                "mapVarType": "input",
                "key": "clientInstance",
                "valueType": "bh.input",
                "value": "client",
                "mapVarName": "clientInstance",
                "localVar": "bh.input.client"
            }
        ],
        "callService": "./idsutil",
        "startName": "getIDSClientInstance",
        "inputParams": [null],
        "accept_bh": false,
        "functionName": "sd_lL3nIWah2nxanEDS",
        "category": "General",
        "x": 453,
        "y": 1036.8125,
        "wires": [["sd_3764ticnEFVkvZcd"]],
        "generateNext": false,
        "generated": false
    },
    {
        "id": "sd_3764ticnEFVkvZcd",
        "type": "Script",
        "z": "sd_LL0Qw7OQupjj1oCg",
        "viewType": "common",
        "nodeType": "flow",
        "name": "Get userinfo and tokens ",
        "script": "const params = bh.input.client.callbackParams(bh.web.req);\nlet tokenset = await bh.input.client.callback(url.resolve(bh.web.req.href, 'cb'), params, {\n    'nonce': bh.input.sessionParams.data.nonce,\n    'state': bh.input.sessionParams.data.state\n});\n\nbh.local.redirectTo = bh.input.sessionParams.data.redirectTo\n\nbh.local.userDetails = {\n    tokenset: Object.assign({}, tokenset),\n    userInfo: await bh.input.client.userinfo(tokenset['access_token'])\n}\nbh.local.userDetails['tokenset']['claims'] = Object.assign({}, tokenset.claims());",
        "functionName": "sd_3764ticnEFVkvZcd",
        "category": "Function",
        "x": 616,
        "y": 1036.78125,
        "wires": [["sd_XnBTeBuoyovhC5zo"]],
        "generateNext": false,
        "generated": false
    },
    {
        "id": "sd_uZHWmXjW8WYRZXIf",
        "type": "Session",
        "z": "sd_LL0Qw7OQupjj1oCg",
        "viewType": "server",
        "nodeType": "flow",
        "name": "",
        "operationType": "get",
        "data": "",
        "resultMapping": "bh.input.sessionParams",
        "dataMapping": "",
        "functionName": "sd_uZHWmXjW8WYRZXIf",
        "category": "HTTP",
        "__ssdTypeInputs__": {
            "resultMapping": {
                "type": "bh.input",
                "value": "sessionParams"
            },
            "dataMapping": {
                "type": "bh.input",
                "value": ""
            }
        },
        "x": 262,
        "y": 1038.796875,
        "wires": [["sd_lL3nIWah2nxanEDS"]],
        "generateNext": false,
        "generated": false
    },
    {
        "id": "sd_H8vgSkS1NiXun692",
        "type": "Switch",
        "z": "sd_LL0Qw7OQupjj1oCg",
        "viewType": "common",
        "nodeType": "flow",
        "name": "Send response based on device type",
        "property": "sessionParams.data.isMobile",
        "propertyType": "bh.input",
        "propertyGv": "bh.input.sessionParams.data.isMobile",
        "rules": [
            {
                "t": "se",
                "v": "true",
                "vt": "str",
                "gv": "\"true\""
            },
            {
                "t": "else"
            }
        ],
        "checkall": "false",
        "repair": false,
        "outputs": 2,
        "functionName": "sd_H8vgSkS1NiXun692",
        "category": "Function",
        "x": 1001,
        "y": 1035.78125,
        "wires": [["sd_f3mOR8t14JTCibs0"], ["sd_SzVqnno2FgJWAPWy"]],
        "generateNext": false,
        "generated": false
    },
    {
        "id": "sd_f3mOR8t14JTCibs0",
        "type": "Script",
        "z": "sd_LL0Qw7OQupjj1oCg",
        "viewType": "common",
        "nodeType": "flow",
        "name": "Mobile html response",
        "script": "bh.local.htmlResponse = `\n <html>\n   <script>\n      let _timer;\n      _timer = setInterval(() => {\n                  if(window.webkit) {\n                      window.webkit.messageHandlers.cordova_iab.postMessage(JSON.stringify({'auth': 'success'}));\n                      clearInterval(_timer);\n                  }\n              }, 250);\n      \n   </script>\n</html>`;",
        "functionName": "sd_f3mOR8t14JTCibs0",
        "category": "Function",
        "x": 1229.390643119812,
        "y": 891.2812614440918,
        "wires": [["sd_oYXYnTyWR0Oxo49J"]],
        "generateNext": false,
        "generated": false
    },
    {
        "id": "sd_SzVqnno2FgJWAPWy",
        "type": "Script",
        "z": "sd_LL0Qw7OQupjj1oCg",
        "viewType": "common",
        "nodeType": "flow",
        "name": "Add location in headers obj",
        "script": "bh.local.redirectHeaders = {\n    location: bh.local.redirectTo\n}",
        "functionName": "sd_SzVqnno2FgJWAPWy",
        "category": "Function",
        "x": 1218.890640258789,
        "y": 1152.5312690734863,
        "wires": [["sd_BloPB3T0UTMyD68d"]],
        "generateNext": false,
        "generated": false
    },
    {
        "id": "sd_oYXYnTyWR0Oxo49J",
        "type": "HttpOut",
        "z": "sd_LL0Qw7OQupjj1oCg",
        "viewType": "server",
        "nodeType": "flow",
        "name": "Html response to close in app browser",
        "headers": {
            "Content-Security-Policy": "script-src 'sha256-wcX+PzUovy0uNFqMGCbbbzuT5v4aAxU9obFNyt6BHAQ='"
        },
        "responseBody": {
            "type": "bh.local",
            "value": "htmlResponse",
            "ssd_typedInputField": true
        },
        "httpcode": {
            "type": "num",
            "value": "200",
            "ssd_typedInputField": true
        },
        "responseType": "txt",
        "responseMapping": {
            "status": 200,
            "txt": "bh.local.htmlResponse",
            "send": "bh.local.htmlResponse"
        },
        "cookies": [],
        "inputs": 1,
        "outputs": 0,
        "editableListData": {
            "headers": [
                {
                    "key": "Content-Security-Policy",
                    "value": "script-src 'sha256-wcX+PzUovy0uNFqMGCbbbzuT5v4aAxU9obFNyt6BHAQ='",
                    "rowId": "sd_VZ8YSISw5G2Kbppv",
                    "valid": true
                }
            ]
        },
        "cookiesList": {},
        "switchStates": {
            "headers": "Map",
            "cookies": "Map"
        },
        "functionName": "sd_oYXYnTyWR0Oxo49J",
        "category": "HTTP",
        "x": 1488.500020980835,
        "y": 1141.781265258789,
        "wires": [],
        "generateNext": false,
        "generated": false
    },
    {
        "id": "sd_BloPB3T0UTMyD68d",
        "type": "HttpOut",
        "z": "sd_LL0Qw7OQupjj1oCg",
        "viewType": "server",
        "nodeType": "flow",
        "name": "Redirect back to app",
        "headers": {
            "type": "bh.local",
            "value": "redirectHeaders",
            "ssd_typedInputField": true
        },
        "responseBody": {
            "type": "literal",
            "value": "'Redirecting'",
            "ssd_typedInputField": true
        },
        "httpcode": {
            "type": "num",
            "value": "302",
            "ssd_typedInputField": true
        },
        "responseType": "txt",
        "responseMapping": {
            "status": 302,
            "txt": "'Redirecting'",
            "send": "'Redirecting'"
        },
        "cookies": [],
        "inputs": 1,
        "outputs": 0,
        "editableListData": {
            "headers": []
        },
        "cookiesList": {},
        "switchStates": {
            "headers": "Value",
            "cookies": "Map"
        },
        "functionName": "sd_BloPB3T0UTMyD68d",
        "category": "HTTP",
        "x": 1483.000020980835,
        "y": 903.2812633514404,
        "wires": [],
        "generateNext": false,
        "generated": false
    },
    {
        "id": "sd_XnBTeBuoyovhC5zo",
        "type": "Session",
        "z": "sd_LL0Qw7OQupjj1oCg",
        "viewType": "server",
        "nodeType": "flow",
        "name": "",
        "operationType": "update",
        "data": "",
        "resultMapping": "",
        "dataMapping": "bh.local.userDetails",
        "functionName": "sd_XnBTeBuoyovhC5zo",
        "category": "HTTP",
        "__ssdTypeInputs__": {
            "resultMapping": {
                "type": "bh.input",
                "value": ""
            },
            "dataMapping": {
                "type": "bh.local",
                "value": "userDetails"
            }
        },
        "x": 792,
        "y": 1036.78125,
        "wires": [["sd_H8vgSkS1NiXun692"]],
        "generateNext": false,
        "generated": false
    },
    {
        "id": "sd_Iormzc7ipO7zZx9L",
        "type": "HttpIn",
        "z": "sd_LL0Qw7OQupjj1oCg",
        "viewType": "server",
        "nodeType": "start",
        "name": "Get userinfo",
        "path": "/user/info",
        "uploadpath": "",
        "summary": "",
        "description": "",
        "method": "get",
        "sequenceId": "IDSAuthroizedAPIs",
        "consumes": "",
        "produces": "",
        "filetype": "path",
        "acceptFileUpload": false,
        "httpOptions": {
            "/user/info": {
                "get": {
                    "summary": "",
                    "description": "",
                    "consumes": [],
                    "produces": [],
                    "parameters": [],
                    "responses": {}
                }
            }
        },
        "uploadFileOptions": {},
        "editableListData": {
            "responses": [],
            "params": [],
            "produces": [],
            "consumes": []
        },
        "inputs": 0,
        "outputs": 1,
        "category": "HTTP",
        "x": 455.8125057220459,
        "y": 2060.734405517578,
        "wires": [["sd_lXdTLg16a0axTGLE"]],
        "generateNext": false,
        "serviceName": "ids",
        "functionName": "sd_Iormzc7ipO7zZx9L"
    },
    {
        "id": "sd_lXdTLg16a0axTGLE",
        "type": "Session",
        "z": "sd_LL0Qw7OQupjj1oCg",
        "viewType": "server",
        "nodeType": "flow",
        "name": "",
        "operationType": "get",
        "data": "",
        "resultMapping": "bh.local.session",
        "dataMapping": "",
        "functionName": "sd_lXdTLg16a0axTGLE",
        "category": "HTTP",
        "__ssdTypeInputs__": {
            "resultMapping": {
                "type": "bh.local",
                "value": "session"
            },
            "dataMapping": {
                "type": "bh.input",
                "value": ""
            }
        },
        "x": 653.0000057220459,
        "y": 2060.781280517578,
        "wires": [["sd_LAzDe0ocOu4iJXDh"]],
        "generateNext": false,
        "generated": false
    },
    {
        "id": "sd_LAzDe0ocOu4iJXDh",
        "type": "HttpOut",
        "z": "sd_LL0Qw7OQupjj1oCg",
        "viewType": "server",
        "nodeType": "flow",
        "name": "",
        "headers": {},
        "responseBody": {
            "type": "bh.local",
            "value": "session.data.userInfo",
            "ssd_typedInputField": true
        },
        "httpcode": {
            "type": "num",
            "value": "200",
            "ssd_typedInputField": true
        },
        "responseType": "obj",
        "responseMapping": {
            "status": 200,
            "obj": "bh.local.session.data.userInfo",
            "send": "bh.local.session.data.userInfo"
        },
        "cookies": [],
        "inputs": 1,
        "outputs": 0,
        "editableListData": {
            "headers": []
        },
        "cookiesList": {},
        "switchStates": {
            "headers": "Map",
            "cookies": "Map"
        },
        "functionName": "sd_LAzDe0ocOu4iJXDh",
        "category": "HTTP",
        "x": 819.0000057220459,
        "y": 2060.781280517578,
        "wires": [],
        "generateNext": false,
        "generated": false
    },
    {
        "id": "sd_0J6ArKjigLVxgH9O",
        "type": "Catch",
        "z": "sd_LL0Qw7OQupjj1oCg",
        "viewType": "common",
        "nodeType": "start",
        "name": "",
        "selectedNodes": [
            "sd_uoTtkYEh4hcNyLyS",
            "sd_sYwN9nvthgPObVqG",
            "sd_lL3nIWah2nxanEDS",
            "sd_3764ticnEFVkvZcd",
            "sd_uZHWmXjW8WYRZXIf",
            "sd_H8vgSkS1NiXun692",
            "sd_f3mOR8t14JTCibs0",
            "sd_SzVqnno2FgJWAPWy",
            "sd_oYXYnTyWR0Oxo49J",
            "sd_BloPB3T0UTMyD68d"
        ],
        "selectCatchType": "selectednodes",
        "masternodeList": "",
        "ignoreList": "",
        "functionName": "sd_0J6ArKjigLVxgH9O",
        "category": "General",
        "x": 98.89062976837158,
        "y": 1233.0000343322754,
        "wires": [["sd_rVbGg4nJXC4p7Sjb"]],
        "generateNext": false,
        "serviceName": "ids"
    },
    {
        "id": "sd_rVbGg4nJXC4p7Sjb",
        "type": "Script",
        "z": "sd_LL0Qw7OQupjj1oCg",
        "viewType": "common",
        "nodeType": "flow",
        "name": "Redirect back to login",
        "script": "bh.web.res.redirect('/api/login')",
        "functionName": "sd_rVbGg4nJXC4p7Sjb",
        "category": "Function",
        "x": 262.50000381469727,
        "y": 1231.0312690734863,
        "wires": [[]],
        "generateNext": false,
        "generated": false
    },
    {
        "id": "sd_8yZNyl7WYJzmoURQ",
        "type": "HttpIn",
        "z": "sd_LL0Qw7OQupjj1oCg",
        "viewType": "server",
        "nodeType": "start",
        "name": "Logout API",
        "path": "/logout",
        "uploadpath": "",
        "summary": "",
        "description": "",
        "method": "get",
        "sequenceId": "",
        "consumes": "",
        "produces": "",
        "filetype": "path",
        "acceptFileUpload": false,
        "httpOptions": {
            "/logout": {
                "get": {
                    "summary": "",
                    "description": "",
                    "consumes": [],
                    "produces": [],
                    "parameters": [],
                    "responses": {}
                }
            }
        },
        "uploadFileOptions": {},
        "editableListData": {
            "responses": [],
            "params": [],
            "produces": [],
            "consumes": []
        },
        "inputs": 0,
        "outputs": 1,
        "category": "HTTP",
        "x": 79.890625,
        "y": 1679.796875,
        "wires": [["sd_8ukNc4HiEsaYgvLP"]],
        "generateNext": false,
        "serviceName": "ids",
        "functionName": "sd_8yZNyl7WYJzmoURQ"
    },
    {
        "id": "sd_8ukNc4HiEsaYgvLP",
        "type": "Session",
        "z": "sd_LL0Qw7OQupjj1oCg",
        "viewType": "server",
        "nodeType": "flow",
        "name": "",
        "operationType": "get",
        "data": "",
        "resultMapping": "bh.local.sessionData",
        "dataMapping": "",
        "functionName": "sd_8ukNc4HiEsaYgvLP",
        "category": "HTTP",
        "__ssdTypeInputs__": {
            "resultMapping": {
                "type": "bh.local",
                "value": "sessionData"
            },
            "dataMapping": {
                "type": "bh.input",
                "value": ""
            }
        },
        "x": 249,
        "y": 1679.78125,
        "wires": [["sd_XUDQCAR3doGVqKTy"]],
        "generateNext": false,
        "generated": false
    },
    {
        "id": "sd_XUDQCAR3doGVqKTy",
        "type": "Script",
        "z": "sd_LL0Qw7OQupjj1oCg",
        "viewType": "common",
        "nodeType": "flow",
        "name": "",
        "script": "\nbh.local.sessionExists = false;\nif (bh.local.sessionData && bh.local.sessionData.data && bh.local.sessionData.data.tokenset) {\n    bh.local.sessionData['data']['redirectTo'] = bh.input.query['redirectTo'];\n    bh.local.sessionData['data']['isMobile'] = bh.input.query['isMobile'];\n    bh.local.sessionExists = true;\n} else {\n    delete bh.local.sessionData['redirectTo'];\n}",
        "functionName": "sd_XUDQCAR3doGVqKTy",
        "category": "Function",
        "x": 413,
        "y": 1678.78125,
        "wires": [["sd_V3Rl3xa9rdsIfUXy"]],
        "generateNext": false,
        "generated": false
    },
    {
        "id": "sd_lYdM3ikXDspFiOeN",
        "type": "Switch",
        "z": "sd_LL0Qw7OQupjj1oCg",
        "viewType": "common",
        "nodeType": "flow",
        "name": "Session exists ",
        "property": "sessionExists",
        "propertyType": "bh.local",
        "propertyGv": "bh.local.sessionExists",
        "rules": [
            {
                "t": "true"
            },
            {
                "t": "else"
            }
        ],
        "checkall": "true",
        "repair": false,
        "outputs": 2,
        "functionName": "sd_lYdM3ikXDspFiOeN",
        "category": "Function",
        "x": 885,
        "y": 1680,
        "wires": [["sd_BP0pgU94Ls6CpW2E"], ["sd_gx3zzUSbXIrJhxR9"]],
        "generateNext": false,
        "generated": false
    },
    {
        "id": "sd_BP0pgU94Ls6CpW2E",
        "type": "Script",
        "z": "sd_LL0Qw7OQupjj1oCg",
        "viewType": "common",
        "nodeType": "flow",
        "name": "",
        "script": "await Promise.all([\n    bh.local.sessionData.data.tokenset.access_token ? bh.input.client.revoke(bh.local.sessionData.data.tokenset.access_token, 'access_token') : undefined,\n    bh.local.sessionData.data.tokenset.refresh_token ? bh.input.client.revoke(bh.local.sessionData.data.tokenset.refresh_token, 'refresh_token') : undefined,\n]);\n\nbh.local.res = {\n        'idsURL': url.format(Object.assign(url.parse(bh.input.client.issuer.end_session_endpoint), {\n            search: null,\n            query: {\n                id_token_hint: bh.local.sessionData.data.tokenset.id_token,\n                post_logout_redirect_uri: url.resolve(bh.web.req.href, '/api/logout/cb'),\n                client_id: settings.default['ids']['client_id']\n            },\n        })),\n        'sessionExists': true,\n}\n\n// Remove user info and tokenset before login redirect\nbh.local.sessionData.data.tokenset = null;\nbh.local.sessionData.data.userInfo = null;",
        "functionName": "sd_BP0pgU94Ls6CpW2E",
        "category": "Function",
        "x": 1045,
        "y": 1560,
        "wires": [["sd_dCWCI7Lqpk6tk1KJ"]],
        "generateNext": false,
        "generated": false
    },
    {
        "id": "sd_V3Rl3xa9rdsIfUXy",
        "type": "CallService",
        "z": "sd_LL0Qw7OQupjj1oCg",
        "viewType": "common",
        "nodeType": "flow",
        "name": "Get IDS client instance",
        "outputs": 1,
        "noerr": 0,
        "service": {
            "serviceId": "sd_kPuz7ywkyl31TXFZ",
            "serviceName": "idsutil",
            "id": "sd_kPuz7ywkyl31TXFZ",
            "label": "idsutil"
        },
        "flow": {
            "flowId": "sd_y6e702ys1ms4W6fk",
            "flowName": "getIDSClientInstance"
        },
        "inputVariables": [
            {
                "key": "clientInstance",
                "map": true,
                "valueType": "bh.input",
                "value": ""
            }
        ],
        "outputMapping": [
            {
                "mapVarType": "input",
                "key": "clientInstance",
                "valueType": "bh.input",
                "value": "client",
                "mapVarName": "clientInstance",
                "localVar": "bh.input.client"
            }
        ],
        "callService": "./idsutil",
        "startName": "getIDSClientInstance",
        "inputParams": [null],
        "accept_bh": false,
        "functionName": "sd_V3Rl3xa9rdsIfUXy",
        "category": "General",
        "x": 645,
        "y": 1680,
        "wires": [["sd_lYdM3ikXDspFiOeN"]],
        "generateNext": false,
        "generated": false
    },
    {
        "id": "sd_6N4yg3CYvATKRQSL",
        "type": "HttpOut",
        "z": "sd_LL0Qw7OQupjj1oCg",
        "viewType": "server",
        "nodeType": "flow",
        "name": "Send IDS logout Url",
        "headers": {},
        "responseBody": {
            "type": "bh.local",
            "value": "res",
            "ssd_typedInputField": true
        },
        "httpcode": {
            "type": "num",
            "value": "200",
            "ssd_typedInputField": true
        },
        "responseType": "obj",
        "responseMapping": {
            "status": 200,
            "obj": "bh.local.res",
            "send": "bh.local.res"
        },
        "cookies": [],
        "inputs": 1,
        "outputs": 0,
        "editableListData": {
            "headers": []
        },
        "cookiesList": {},
        "switchStates": {
            "headers": "Map",
            "cookies": "Map"
        },
        "functionName": "sd_6N4yg3CYvATKRQSL",
        "category": "HTTP",
        "x": 1345,
        "y": 1680,
        "wires": [],
        "generateNext": false,
        "generated": false
    },
    {
        "id": "sd_gx3zzUSbXIrJhxR9",
        "type": "Script",
        "z": "sd_LL0Qw7OQupjj1oCg",
        "viewType": "common",
        "nodeType": "flow",
        "name": "",
        "script": "bh.local.res = {\n        'sessionExists': false,\n}",
        "functionName": "sd_gx3zzUSbXIrJhxR9",
        "category": "Function",
        "x": 1113.250015258789,
        "y": 1790.5312767028809,
        "wires": [["sd_6N4yg3CYvATKRQSL"]],
        "generateNext": false,
        "generated": false
    },
    {
        "id": "sd_ApNmHhyLWr3iz1Hz",
        "type": "HttpIn",
        "z": "sd_LL0Qw7OQupjj1oCg",
        "viewType": "server",
        "nodeType": "start",
        "name": "Logout Callback API",
        "path": "/logout/cb",
        "uploadpath": "",
        "summary": "",
        "description": "",
        "method": "get",
        "sequenceId": "",
        "consumes": "",
        "produces": "",
        "filetype": "path",
        "acceptFileUpload": false,
        "httpOptions": {
            "/logout/cb": {
                "get": {
                    "summary": "",
                    "description": "",
                    "consumes": [],
                    "produces": [],
                    "parameters": [],
                    "responses": {}
                }
            }
        },
        "uploadFileOptions": {},
        "editableListData": {
            "responses": [],
            "params": [],
            "produces": [],
            "consumes": []
        },
        "inputs": 0,
        "outputs": 1,
        "category": "HTTP",
        "x": 200,
        "y": 2500,
        "wires": [["sd_u7cXzwO3ORGKWuMc"]],
        "generateNext": false,
        "serviceName": "ids",
        "functionName": "sd_ApNmHhyLWr3iz1Hz"
    },
    {
        "id": "sd_u7cXzwO3ORGKWuMc",
        "type": "Script",
        "z": "sd_LL0Qw7OQupjj1oCg",
        "viewType": "common",
        "nodeType": "flow",
        "name": "",
        "script": "bh.local.isPasswordResetCallback = !!bh.input.query.password_reset_username",
        "functionName": "sd_u7cXzwO3ORGKWuMc",
        "category": "Function",
        "x": 280,
        "y": 2350,
        "wires": [["sd_ZfEDa2KHXBwDQTDv"]],
        "generateNext": false,
        "generated": false,
        "serviceName": "ids"
    },
    {
        "id": "sd_ZfEDa2KHXBwDQTDv",
        "type": "Switch",
        "z": "sd_LL0Qw7OQupjj1oCg",
        "viewType": "common",
        "nodeType": "flow",
        "name": "",
        "property": "isPasswordResetCallback",
        "propertyType": "bh.local",
        "propertyGv": "bh.local.isPasswordResetCallback",
        "rules": [
            {
                "t": "true"
            },
            {
                "t": "false"
            }
        ],
        "checkall": "false",
        "repair": false,
        "outputs": 2,
        "functionName": "sd_ZfEDa2KHXBwDQTDv",
        "category": "Function",
        "x": 350,
        "y": 2500,
        "wires": [["sd_DpCh23r0SHkJUbOL"], ["sd_ipcZAJB1peq7pMgO"]],
        "generateNext": false,
        "generated": false
    },
    {
        "id": "sd_DpCh23r0SHkJUbOL",
        "type": "Script",
        "z": "sd_LL0Qw7OQupjj1oCg",
        "viewType": "common",
        "nodeType": "flow",
        "name": "",
        "script": "const sessionStore = bh.web.req.sessionStore;\nconst res = new Promise((res, rej) => {\n    sessionStore.all((err, sessions) => {\n        const promises = Object.keys(sessions).map(sid => {\n            return new Promise((resolve, reject) => {\n                sessionStore.get(sid, (err, session) => {\n                    if (session?.data?.userInfo?.username === bh.input.query.password_reset_username) {\n                        log.debug(`[LCB] username matched::${session.data.userInfo.username}`)\n                        sessionStore.destroy(sid, (err, d) => {\n                            resolve(d)\n                        })\n                    } else {\n                        resolve(undefined)\n                    }\n                })\n            })\n        })\n        Promise.all(promises).then((d) => res(d))\n    })\n});\n\nconst rr = await res;",
        "functionName": "sd_DpCh23r0SHkJUbOL",
        "category": "Function",
        "x": 430,
        "y": 2350,
        "wires": [["sd_BloPB3T0UTMyD56t"]],
        "generateNext": false,
        "generated": false,
        "serviceName": "ids"
    },
    {
        "id": "sd_BloPB3T0UTMyD56t",
        "type": "HttpOut",
        "z": "sd_LL0Qw7OQupjj1oCg",
        "viewType": "server",
        "nodeType": "flow",
        "name": "",
        "headers": {},
        "responseBody": {
            "type": "literal",
            "value": "{ message: \"destroyed\" }",
            "ssd_typedInputField": true
        },
        "httpcode": {
            "type": "num",
            "value": "200",
            "ssd_typedInputField": true
        },
        "responseType": "obj",
        "responseMapping": {
            "status": {
                "type": "num",
                "value": 200,
                "ssd_typedInputField": true
            },
            "obj": {
                "type": "literal",
                "value": "{ message: \"destroyed\" }",
                "ssd_typedInputField": true
            },
            "send": {
                "type": "literal",
                "value": "{ message: \"destroyed\" }",
                "ssd_typedInputField": true
            }
        },
        "cookies": [],
        "inputs": 1,
        "outputs": 0,
        "editableListData": {
            "headers": [],
            "produces": [],
            "responses": []
        },
        "cookiesList": {},
        "switchStates": {
            "headers": "Map",
            "cookies": "Map"
        },
        "functionName": "sd_BloPB3T0UTMyD56t",
        "category": "HTTP",
        "x": 580,
        "y": 2350,
        "wires": [],
        "generateNext": false,
        "generated": false
    },
    {
        "id": "sd_ipcZAJB1peq7pMgO",
        "type": "Session",
        "z": "sd_LL0Qw7OQupjj1oCg",
        "viewType": "server",
        "nodeType": "flow",
        "name": "",
        "operationType": "get",
        "data": "",
        "resultMapping": "bh.local.sessionData",
        "dataMapping": "",
        "functionName": "sd_ipcZAJB1peq7pMgO",
        "category": "HTTP",
        "__ssdTypeInputs__": {
            "resultMapping": {
                "type": "bh.local",
                "value": "sessionData"
            },
            "dataMapping": {
                "type": "bh.input",
                "value": ""
            }
        },
        "x": 500,
        "y": 2500,
        "wires": [["sd_aAIo3KKtWen3hsFi"]],
        "generateNext": false,
        "generated": false
    },
    {
        "id": "sd_XHChavZleDW7Jxby",
        "type": "Switch",
        "z": "sd_LL0Qw7OQupjj1oCg",
        "viewType": "common",
        "nodeType": "flow",
        "name": "Check platform type",
        "property": "sessionData.data.isMobile",
        "propertyType": "bh.local",
        "propertyGv": "bh.local.sessionData.data.isMobile",
        "rules": [
            {
                "t": "se",
                "v": "true",
                "vt": "str",
                "gv": "\"true\""
            },
            {
                "t": "else"
            }
        ],
        "checkall": "false",
        "repair": false,
        "outputs": 2,
        "functionName": "sd_XHChavZleDW7Jxby",
        "category": "Function",
        "x": 800,
        "y": 2500,
        "wires": [["sd_5yeSZ93Z4cR0vbUw"], ["sd_WWKNpDYnA4Ra6SsO"]],
        "generateNext": false,
        "generated": false
    },
    {
        "id": "sd_5yeSZ93Z4cR0vbUw",
        "type": "Script",
        "z": "sd_LL0Qw7OQupjj1oCg",
        "viewType": "common",
        "nodeType": "flow",
        "name": "",
        "script": "bh.local.res = \n`<html>\n   <script>\n      var _timer;\n      _timer = setInterval(() => {\n                  if(window.webkit) {\n                      window.webkit.messageHandlers.cordova_iab.postMessage(JSON.stringify({'auth': 'success'}));\n                      clearInterval(_timer);\n                  }\n              }, 250);\n      \n   </script>\n</html>`;",
        "functionName": "sd_5yeSZ93Z4cR0vbUw",
        "category": "Function",
        "x": 1000,
        "y": 2350,
        "wires": [["sd_p640NOwGyI3f7ibT"]],
        "generateNext": false,
        "generated": false
    },
    {
        "id": "sd_p640NOwGyI3f7ibT",
        "type": "HttpOut",
        "z": "sd_LL0Qw7OQupjj1oCg",
        "viewType": "server",
        "nodeType": "flow",
        "name": "Send html response",
        "headers": {
            "Content-Security-Policy": "script 'sha256-j4HHWBMKh2PoLEAu017BWktgUmmL7VVMjnHuNWUHGOg='"
        },
        "responseBody": {
            "type": "bh.local",
            "value": "res",
            "ssd_typedInputField": true
        },
        "httpcode": {
            "type": "num",
            "value": "200",
            "ssd_typedInputField": true
        },
        "responseType": "obj",
        "responseMapping": {
            "status": 200,
            "obj": "bh.local.res",
            "send": "bh.local.res"
        },
        "cookies": [],
        "inputs": 1,
        "outputs": 0,
        "editableListData": {
            "headers": [
                {
                    "key": "Content-Security-Policy",
                    "value": "script 'sha256-j4HHWBMKh2PoLEAu017BWktgUmmL7VVMjnHuNWUHGOg='",
                    "rowId": "sd_1rEodKaPhq3Yygas",
                    "valid": true
                }
            ]
        },
        "cookiesList": {},
        "switchStates": {
            "headers": "Map",
            "cookies": "Map"
        },
        "functionName": "sd_p640NOwGyI3f7ibT",
        "category": "HTTP",
        "x": 1150,
        "y": 2350,
        "wires": [],
        "generateNext": false,
        "generated": false
    },
    {
        "id": "sd_WWKNpDYnA4Ra6SsO",
        "type": "Script",
        "z": "sd_LL0Qw7OQupjj1oCg",
        "viewType": "common",
        "nodeType": "flow",
        "name": "",
        "script": "bh.local.redirectHeaders = {\n    location: bh.local.sessionData.data.redirectTo\n}",
        "functionName": "sd_WWKNpDYnA4Ra6SsO",
        "category": "Function",
        "x": 1000,
        "y": 2650,
        "wires": [["sd_F5WsdUL0X0aWyABD"]],
        "generateNext": false,
        "generated": false
    },
    {
        "id": "sd_F5WsdUL0X0aWyABD",
        "type": "HttpOut",
        "z": "sd_LL0Qw7OQupjj1oCg",
        "viewType": "server",
        "nodeType": "flow",
        "name": "Redirect back to app",
        "headers": {
            "type": "bh.local",
            "value": "redirectHeaders",
            "ssd_typedInputField": true
        },
        "responseBody": {
            "type": "literal",
            "value": "'redirecting'",
            "ssd_typedInputField": true
        },
        "httpcode": {
            "type": "num",
            "value": "302",
            "ssd_typedInputField": true
        },
        "responseType": "txt",
        "responseMapping": {
            "status": 302,
            "txt": "'redirecting'",
            "send": "'redirecting'"
        },
        "cookies": [],
        "inputs": 1,
        "outputs": 0,
        "editableListData": {
            "headers": []
        },
        "cookiesList": {},
        "switchStates": {
            "headers": "Value",
            "cookies": "Map"
        },
        "functionName": "sd_F5WsdUL0X0aWyABD",
        "category": "HTTP",
        "x": 1150,
        "y": 2650,
        "wires": [],
        "generateNext": false,
        "generated": false
    },
    {
        "id": "sd_aAIo3KKtWen3hsFi",
        "type": "Session",
        "z": "sd_LL0Qw7OQupjj1oCg",
        "viewType": "server",
        "nodeType": "flow",
        "name": "",
        "operationType": "destroy",
        "data": "",
        "resultMapping": "",
        "dataMapping": "",
        "functionName": "sd_aAIo3KKtWen3hsFi",
        "category": "HTTP",
        "__ssdTypeInputs__": {
            "resultMapping": {
                "type": "bh.input",
                "value": ""
            },
            "dataMapping": {
                "type": "bh.input",
                "value": ""
            }
        },
        "x": 650,
        "y": 2500,
        "wires": [["sd_XHChavZleDW7Jxby"]],
        "generateNext": false,
        "generated": false
    },
    {
        "id": "sd_WYOSQar5lScQ9aQt",
        "type": "MiddlewareStart",
        "z": "sd_LL0Qw7OQupjj1oCg",
        "viewType": "server",
        "nodeType": "start",
        "name": "Authorize",
        "inputs": 0,
        "outputs": 1,
        "category": "HTTP",
        "x": 80.8125,
        "y": 3182.71875,
        "wires": [["sd_6s9nHq2FPOYxs8r5"]],
        "generateNext": false,
        "serviceName": "ids",
        "functionName": "sd_WYOSQar5lScQ9aQt"
    },
    {
        "id": "sd_lsuoR9YzatS5Ghex",
        "type": "Session",
        "z": "sd_LL0Qw7OQupjj1oCg",
        "viewType": "server",
        "nodeType": "flow",
        "name": "",
        "operationType": "get",
        "data": "",
        "resultMapping": "bh.local.sessionData",
        "dataMapping": "",
        "functionName": "sd_lsuoR9YzatS5Ghex",
        "category": "HTTP",
        "__ssdTypeInputs__": {
            "resultMapping": {
                "type": "bh.local",
                "value": "sessionData"
            },
            "dataMapping": {
                "type": "bh.input",
                "value": ""
            }
        },
        "x": 386,
        "y": 3178.78125,
        "wires": [["sd_YPUZx4Kxzbuen1m9"]],
        "generateNext": false,
        "generated": false
    },
    {
        "id": "sd_N7ZtV6uWv9eEAm8H",
        "type": "Switch",
        "z": "sd_LL0Qw7OQupjj1oCg",
        "viewType": "common",
        "nodeType": "flow",
        "name": "Check if session exists",
        "property": "sessionExists",
        "propertyType": "bh.local",
        "propertyGv": "bh.local.sessionExists",
        "rules": [
            {
                "t": "true"
            },
            {
                "t": "else"
            }
        ],
        "checkall": "true",
        "repair": false,
        "outputs": 2,
        "functionName": "sd_N7ZtV6uWv9eEAm8H",
        "category": "Function",
        "x": 679,
        "y": 3173.78125,
        "wires": [["sd_2sOXcAyr9ppOGa0r"], ["sd_MUgsjs7skXGjmwdt"]],
        "generateNext": false,
        "generated": false
    },
    {
        "id": "sd_MUgsjs7skXGjmwdt",
        "type": "Switch",
        "z": "sd_LL0Qw7OQupjj1oCg",
        "viewType": "common",
        "nodeType": "flow",
        "name": "Check if it is the user info API.",
        "property": "path",
        "propertyType": "bh.input",
        "propertyGv": "bh.input.path",
        "rules": [
            {
                "t": "cont",
                "v": "/user/info",
                "vt": "str",
                "gv": "\"/user/info\""
            },
            {
                "t": "else"
            }
        ],
        "checkall": "false",
        "repair": false,
        "outputs": 2,
        "functionName": "sd_MUgsjs7skXGjmwdt",
        "category": "Function",
        "x": 641,
        "y": 3388.78125,
        "wires": [["sd_ZP2AQ25IWIKG0zuf"], ["sd_cCEl3Vi9lybEThqs"]],
        "generateNext": false,
        "generated": false
    },
    {
        "id": "sd_f9GapX8nqzhxgnZU",
        "type": "HttpOut",
        "z": "sd_LL0Qw7OQupjj1oCg",
        "viewType": "server",
        "nodeType": "flow",
        "name": "Send the session not present response",
        "headers": {},
        "responseBody": {
            "type": "bh.local",
            "value": "res",
            "ssd_typedInputField": true
        },
        "httpcode": {
            "type": "num",
            "value": "403",
            "ssd_typedInputField": true
        },
        "responseType": "obj",
        "responseMapping": {
            "status": 403,
            "obj": "bh.local.res",
            "send": "bh.local.res"
        },
        "cookies": [],
        "inputs": 1,
        "outputs": 0,
        "editableListData": {
            "headers": []
        },
        "cookiesList": {},
        "switchStates": {
            "headers": "Map",
            "cookies": "Map"
        },
        "functionName": "sd_f9GapX8nqzhxgnZU",
        "category": "HTTP",
        "x": 1205,
        "y": 3366.78125,
        "wires": [],
        "generateNext": false,
        "generated": false
    },
    {
        "id": "sd_ZP2AQ25IWIKG0zuf",
        "type": "Script",
        "z": "sd_LL0Qw7OQupjj1oCg",
        "viewType": "common",
        "nodeType": "flow",
        "name": "",
        "script": "bh.local.res = { message: 'Session expired' };",
        "functionName": "sd_ZP2AQ25IWIKG0zuf",
        "category": "Function",
        "x": 892.890625,
        "y": 3386.78125,
        "wires": [["sd_f9GapX8nqzhxgnZU"]],
        "generateNext": false,
        "generated": false
    },
    {
        "id": "sd_cCEl3Vi9lybEThqs",
        "type": "Script",
        "z": "sd_LL0Qw7OQupjj1oCg",
        "viewType": "common",
        "nodeType": "flow",
        "name": "",
        "script": "bh.local.res = { code: 'NO_SESSION', message: 'Session not present' };",
        "functionName": "sd_cCEl3Vi9lybEThqs",
        "category": "Function",
        "x": 885,
        "y": 3522.8125,
        "wires": [["sd_f9GapX8nqzhxgnZU"]],
        "generateNext": false,
        "generated": false
    },
    {
        "id": "sd_8IEjB9g3iUX2FjGC",
        "type": "Switch",
        "z": "sd_LL0Qw7OQupjj1oCg",
        "viewType": "common",
        "nodeType": "flow",
        "name": "Token exists after refresh",
        "property": "newSession",
        "propertyType": "bh.local",
        "propertyGv": "bh.local.newSession",
        "rules": [
            {
                "t": "false"
            },
            {
                "t": "else"
            }
        ],
        "checkall": "false",
        "repair": false,
        "outputs": 2,
        "functionName": "sd_8IEjB9g3iUX2FjGC",
        "category": "Function",
        "x": 846,
        "y": 2953.78125,
        "wires": [["sd_x6x5o7j7sXOWmVY5"], ["sd_ziui7wyh9UGALZkz"]],
        "generateNext": false,
        "generated": false
    },
    {
        "id": "sd_yZH7JMvqCYeKumw7",
        "type": "MiddlewareEnd",
        "z": "sd_LL0Qw7OQupjj1oCg",
        "viewType": "server",
        "nodeType": "flow",
        "name": "Authorize end",
        "headers": {},
        "responseBody": {
            "type": "literal",
            "value": "'end'",
            "ssd_typedInputField": true
        },
        "httpcode": {
            "type": "num",
            "value": "200",
            "ssd_typedInputField": true
        },
        "responseType": "next",
        "responseMapping": {
            "status": 200,
            "next": "'end'"
        },
        "cookies": [],
        "inputs": 1,
        "outputs": 0,
        "editableListData": {
            "headers": []
        },
        "cookiesList": {},
        "switchStates": {
            "headers": "Map",
            "cookies": "Map"
        },
        "functionName": "sd_yZH7JMvqCYeKumw7",
        "category": "HTTP",
        "x": 1484,
        "y": 2956.703125,
        "wires": [],
        "generateNext": false,
        "generated": false
    },
    {
        "id": "sd_DMQIIU5XlH5LL4jt",
        "type": "Script",
        "z": "sd_LL0Qw7OQupjj1oCg",
        "viewType": "common",
        "nodeType": "flow",
        "name": "",
        "script": "bh.local.res = { code: 'TOKEN_EXPIRED', message: 'Token invalid or access revoked' };",
        "functionName": "sd_DMQIIU5XlH5LL4jt",
        "category": "Function",
        "x": 884,
        "y": 3259.78125,
        "wires": [["sd_f9GapX8nqzhxgnZU"]],
        "generateNext": false,
        "generated": false
    },
    {
        "id": "sd_2sOXcAyr9ppOGa0r",
        "type": "CallService",
        "z": "sd_LL0Qw7OQupjj1oCg",
        "viewType": "common",
        "nodeType": "flow",
        "name": "Call handleTokenExpiry",
        "outputs": 1,
        "noerr": 0,
        "service": {
            "serviceId": "sd_kPuz7ywkyl31TXFZ",
            "serviceName": "idsutil",
            "id": "sd_kPuz7ywkyl31TXFZ",
            "label": "idsutil"
        },
        "flow": {
            "flowId": "sd_GiWFwz39d0bmyEtE",
            "flowName": "handleTokenExpiry"
        },
        "inputVariables": [
            {
                "key": "existingSession",
                "map": true,
                "valueType": "bh.local",
                "value": "sessionData"
            },
            {
                "key": "newSession",
                "map": true,
                "valueType": "bh.input",
                "value": ""
            }
        ],
        "outputMapping": [
            {
                "mapVarType": "input",
                "key": "newSession",
                "valueType": "bh.local",
                "value": "newSession",
                "mapVarName": "newSession",
                "localVar": "bh.local.newSession"
            }
        ],
        "callService": "./idsutil",
        "startName": "handleTokenExpiry",
        "inputParams": ["bh.local.sessionData", null],
        "accept_bh": false,
        "functionName": "sd_2sOXcAyr9ppOGa0r",
        "category": "General",
        "x": 631,
        "y": 2951.78125,
        "wires": [["sd_8IEjB9g3iUX2FjGC"]],
        "generateNext": false,
        "generated": false
    },
    {
        "id": "sd_6s9nHq2FPOYxs8r5",
        "type": "Script",
        "z": "sd_LL0Qw7OQupjj1oCg",
        "viewType": "common",
        "nodeType": "flow",
        "name": "",
        "script": "bh.local = {\n    \n}",
        "functionName": "sd_6s9nHq2FPOYxs8r5",
        "category": "Function",
        "x": 227.890625,
        "y": 3180.78125,
        "wires": [["sd_lsuoR9YzatS5Ghex"]],
        "generateNext": false,
        "generated": false
    },
    {
        "id": "sd_YPUZx4Kxzbuen1m9",
        "type": "Script",
        "z": "sd_LL0Qw7OQupjj1oCg",
        "viewType": "common",
        "nodeType": "flow",
        "name": "",
        "script": "bh.local.sessionExists = false;\n\nif (bh.local.sessionData && bh.local.sessionData.data && bh.local.sessionData.data.tokenset &&\n    bh.local.sessionData.data.tokenset.access_token && bh.local.sessionData.data.tokenset.refresh_token) {\n    bh.local.sessionExists = true;\n}",
        "functionName": "sd_YPUZx4Kxzbuen1m9",
        "category": "Function",
        "x": 550,
        "y": 3178.78125,
        "wires": [["sd_N7ZtV6uWv9eEAm8H"]],
        "generateNext": false,
        "generated": false
    },
    {
        "id": "sd_x6x5o7j7sXOWmVY5",
        "type": "Session",
        "z": "sd_LL0Qw7OQupjj1oCg",
        "viewType": "server",
        "nodeType": "flow",
        "name": "",
        "operationType": "destroy",
        "data": "",
        "resultMapping": "",
        "dataMapping": "",
        "functionName": "sd_x6x5o7j7sXOWmVY5",
        "category": "HTTP",
        "__ssdTypeInputs__": {
            "resultMapping": {
                "type": "bh.input",
                "value": ""
            },
            "dataMapping": {
                "type": "bh.input",
                "value": ""
            }
        },
        "x": 887,
        "y": 3093.78125,
        "wires": [["sd_DMQIIU5XlH5LL4jt"]],
        "generateNext": false,
        "generated": false
    },
    {
        "id": "sd_ziui7wyh9UGALZkz",
        "type": "Switch",
        "z": "sd_LL0Qw7OQupjj1oCg",
        "viewType": "common",
        "nodeType": "flow",
        "name": "Update session if token rotated",
        "property": "newSession.rotated",
        "propertyType": "bh.local",
        "propertyGv": "bh.local.newSession.rotated",
        "rules": [
            {
                "t": "true"
            },
            {
                "t": "else"
            }
        ],
        "checkall": "false",
        "repair": false,
        "outputs": 2,
        "functionName": "sd_ziui7wyh9UGALZkz",
        "category": "Function",
        "x": 1051,
        "y": 2956.78125,
        "wires": [["sd_btzbBWy8jr3mf5uJ"], ["sd_yZH7JMvqCYeKumw7"]],
        "generateNext": false,
        "generated": false
    },
    {
        "id": "sd_qVSRzRWs3GLxsfjd",
        "type": "Session",
        "z": "sd_LL0Qw7OQupjj1oCg",
        "viewType": "server",
        "nodeType": "flow",
        "name": "",
        "operationType": "update",
        "data": "",
        "resultMapping": "bh.local.newSession",
        "dataMapping": "bh.local.newSession",
        "functionName": "sd_qVSRzRWs3GLxsfjd",
        "category": "HTTP",
        "__ssdTypeInputs__": {
            "resultMapping": {
                "type": "bh.local",
                "value": "newSession"
            },
            "dataMapping": {
                "type": "bh.local",
                "value": "newSession"
            }
        },
        "x": 1331,
        "y": 2827.78125,
        "wires": [["sd_yZH7JMvqCYeKumw7"]],
        "generateNext": false,
        "generated": false
    },
    {
        "id": "sd_btzbBWy8jr3mf5uJ",
        "type": "Script",
        "z": "sd_LL0Qw7OQupjj1oCg",
        "viewType": "common",
        "nodeType": "flow",
        "name": "",
        "script": "delete bh.local.newSession.rotated;",
        "functionName": "sd_btzbBWy8jr3mf5uJ",
        "category": "Function",
        "x": 1192,
        "y": 2827.78125,
        "wires": [["sd_qVSRzRWs3GLxsfjd"]],
        "generateNext": false,
        "generated": false
    },
    {
        "id": "sd_BtrPILsd85c4A4hE",
        "type": "Comments",
        "z": "sd_LL0Qw7OQupjj1oCg",
        "viewType": "common",
        "nodeType": "flow",
        "name": "Idenity Server Login API",
        "comments": "<p>API used to authenticate users.</p>",
        "category": "General",
        "x": 685,
        "y": 58.78125,
        "wires": [],
        "generateNext": false
    },
    {
        "id": "sd_DDrHgzeCLiTaL9pE",
        "type": "Comments",
        "z": "sd_LL0Qw7OQupjj1oCg",
        "viewType": "common",
        "nodeType": "flow",
        "name": "Flow to add href to bh of the Origin",
        "comments": "",
        "category": "General",
        "x": 664,
        "y": 590.78125,
        "wires": [],
        "generateNext": false
    },
    {
        "id": "sd_EsTCxgDr0tP8B9Ea",
        "type": "Comments",
        "z": "sd_LL0Qw7OQupjj1oCg",
        "viewType": "common",
        "nodeType": "flow",
        "name": "Login Callback API",
        "comments": "<p>After authentication, this is the API called by IDS to get Access token and user info</p>",
        "category": "General",
        "x": 685,
        "y": 897.2265625,
        "wires": [],
        "generateNext": false
    },
    {
        "id": "sd_1eWHsLKTshaNz7lc",
        "type": "Comments",
        "z": "sd_LL0Qw7OQupjj1oCg",
        "viewType": "common",
        "nodeType": "flow",
        "name": "IDS Logout API",
        "comments": "<p>API to redirect the user to IDS Logout page</p>",
        "category": "General",
        "x": 720.0000114440918,
        "y": 1527.226583480835,
        "wires": [],
        "generateNext": false
    },
    {
        "id": "sd_sNzLeLUVuINPPFz0",
        "type": "Comments",
        "z": "sd_LL0Qw7OQupjj1oCg",
        "viewType": "common",
        "nodeType": "flow",
        "name": "Fetch user info",
        "comments": "The API called by neutrinos-oauth-client module internally to fetch user info.",
        "category": "General",
        "x": 651.2500095367432,
        "y": 1947.2265892028809,
        "wires": [],
        "generateNext": false
    },
    {
        "id": "sd_e8QmIb07qgmMPMO4",
        "type": "Comments",
        "z": "sd_LL0Qw7OQupjj1oCg",
        "viewType": "common",
        "nodeType": "flow",
        "name": "Redirect the user back to Login",
        "comments": "<p>Redirect back to /login if the flow cannot fetch user info or access token.</p>",
        "category": "General",
        "x": 177.50000381469727,
        "y": 1310.9765815734863,
        "wires": [],
        "generateNext": false
    },
    {
        "id": "sd_UqSrGgrOtZs2wrGV",
        "type": "Comments",
        "z": "sd_LL0Qw7OQupjj1oCg",
        "viewType": "common",
        "nodeType": "flow",
        "name": "Check Authorization",
        "comments": "Use this middleware flow for all authorized APIs.",
        "category": "General",
        "x": 813.75,
        "y": 2805.9765625,
        "wires": [],
        "generateNext": false
    },
    {
        "id": "sd_INYLRaRlMyf2A33l",
        "type": "Comments",
        "z": "sd_LL0Qw7OQupjj1oCg",
        "viewType": "common",
        "nodeType": "flow",
        "name": "Logout Callback API",
        "comments": "<p>The API redirected by IDS to destroy the user session.</p>",
        "category": "General",
        "x": 581.25,
        "y": 2238.4765625,
        "wires": [],
        "generateNext": false
    },
    {
        "id": "sd_AS2Y4jK92Ac9YV7s",
        "type": "Catch",
        "z": "sd_LL0Qw7OQupjj1oCg",
        "viewType": "common",
        "nodeType": "start",
        "name": "Catch HandleTokenExpiry",
        "selectedNodes": ["sd_2sOXcAyr9ppOGa0r"],
        "selectCatchType": "selectednodes",
        "masternodeList": "",
        "ignoreList": "",
        "functionName": "sd_AS2Y4jK92Ac9YV7s",
        "category": "General",
        "x": 765,
        "y": 3260,
        "wires": [["sd_DMQIIU5XlH5LL4jt"]],
        "generateNext": false,
        "serviceName": "ids"
    },
    {
        "id": "sd_dCWCI7Lqpk6tk1KJ",
        "type": "Session",
        "z": "sd_LL0Qw7OQupjj1oCg",
        "viewType": "server",
        "nodeType": "flow",
        "name": "",
        "operationType": "update",
        "data": "",
        "resultMapping": "bh.local.session",
        "dataMapping": "bh.local.sessionData.data",
        "functionName": "sd_dCWCI7Lqpk6tk1KJ",
        "category": "HTTP",
        "__ssdTypeInputs__": {
            "resultMapping": {
                "type": "bh.local",
                "value": "session",
                "constant": false
            },
            "dataMapping": {
                "type": "bh.local",
                "value": "sessionData.data",
                "constant": false
            }
        },
        "x": 1205,
        "y": 1560,
        "wires": [["sd_6N4yg3CYvATKRQSL"]],
        "generateNext": false,
        "generated": false
    }
]
