How to use the @authx/authx function in @authx/authx

To help you get started, we’ve selected a few @authx/authx examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github the-control-group / authx / src / server.ts View on Github external
// Create a Koa app.
    const app = new Koa();
    app.proxy = true;

    // Build the interface middleware.
    const interfaceMiddleware = await createAuthXInterface("authx", [
      "@authx/strategy-email/interface",
      "@authx/strategy-password/interface",
      "@authx/strategy-openid/interface"
    ]);

    // Add the AuthX user interface.
    app.use(interfaceMiddleware);

    // Create a new instanciate of AuthX.
    const authx = new AuthX({
      realm: "authx",
      base: `http://localhost${
        process.env.PORT ? `:${process.env.PORT}` : ""
      }/`,
      codeValidityDuration: 60,
      jwtValidityDuration: 5 * 60,
      privateKey:
        process.env.KEYPRIVATE ??
        `-----BEGIN RSA PRIVATE KEY-----
MIICXAIBAAKBgQCfb+nyTPFCntEXbrFPU5DeE0gC4jXRcSFWDfCRgeqeQWqIW9De
MmCj13k0z6fQCiG3FATYosS64wAs+OiyGtu9q/JyUEVIBMF0upDJMA53AFFx+0Fb
/i76JFPTY7SxzvioIFeKRwY8evIRWQWYO95Os6gKBac/x5qiUn5fh2xM+wIDAQAB
AoGAeOPGo24r0LPTHs1TrC5Uvc4o3+bdn70D5dgT/IBhgTVgrZvQt2nDVPfgc2aw
e1HzVnnbYteoC3xrea4R4lnzGpgcvLYyJ+LEAeRNT66u12EHnCjl8OM5Ods79RO2
pSaGBiAlntq9E86DBJ9ma9lL9NXiokCx4h1ph9rqr6T+DMECQQD7zM56evJj8JyV
kyu7m3PGpepqgMtO4LjHlkU9ZP2HRfrq+bl4yWps1TyCTPzaRujXW+hHJBPsTYar