"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
/*---------------------------------------------------------------------------------------------
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
* See LICENSE.md in the project root for license terms and full copyright notice.
*--------------------------------------------------------------------------------------------*/
const fs = require("fs");
const path = require("path");
// Sets up certa to allow a method on the frontend to get an access token
require("@itwin/oidc-signin-tool/lib/cjs/certa/certaBackend");
const SideChannels_1 = require("../common/SideChannels");
/** Loads the provided `.env` file into process.env */
function loadEnv(envFile) {
    if (!fs.existsSync(envFile))
        return;
    const dotenv = require("dotenv"); // eslint-disable-line @typescript-eslint/no-var-requires
    const dotenvExpand = require("dotenv-expand"); // eslint-disable-line @typescript-eslint/no-var-requires
    const envResult = dotenv.config({ path: envFile });
    if (envResult.error) {
        throw envResult.error;
    }
    dotenvExpand(envResult);
}
module.exports = (async () => {
    loadEnv(path.join(__dirname, "..", "..", ".env"));
    (0, SideChannels_1.exposeBackendCallbacks)();
})();
//# sourceMappingURL=BackendInit.js.map