UNPKG

@adonisjs/ally

Version:

Social authentication provider for AdonisJS

34 lines (33 loc) 861 B
// src/ally_manager.ts import { RuntimeException } from "@poppinss/utils"; var AllyManager = class { constructor(config, ctx) { this.config = config; this.#ctx = ctx; } #ctx; #driversCache = /* @__PURE__ */ new Map(); /** * Returns the driver instance of a social provider */ use(provider) { if (this.#driversCache.has(provider)) { return this.#driversCache.get(provider); } const driver = this.config[provider]; if (!driver) { throw new RuntimeException( `Unknown ally provider "${String( provider )}". Make sure it is registered inside the config/ally.ts file` ); } const driverInstance = driver(this.#ctx); this.#driversCache.set(provider, driverInstance); return driverInstance; } }; export { AllyManager }; //# sourceMappingURL=chunk-NZT2DLWM.js.map