fix: commit vendored @kuns/zitadel-auth dist (was excluded by dist/ gitignore)
This commit is contained in:
36
vendor/zitadel-auth/dist/angular.js
vendored
Normal file
36
vendor/zitadel-auth/dist/angular.js
vendored
Normal file
@@ -0,0 +1,36 @@
|
||||
import {
|
||||
ZitadelAuth
|
||||
} from "./chunk-NFH7JLJM.js";
|
||||
|
||||
// src/adapters/angular.ts
|
||||
var AUTH_INSTANCE_KEY = "__kuns_zitadel_auth__";
|
||||
function provideZitadelAuth(config) {
|
||||
const auth = new ZitadelAuth(config);
|
||||
globalThis[AUTH_INSTANCE_KEY] = auth;
|
||||
return {
|
||||
provide: "KUNS_ZITADEL_AUTH",
|
||||
useValue: auth
|
||||
};
|
||||
}
|
||||
function getAuthInstance() {
|
||||
const auth = globalThis[AUTH_INSTANCE_KEY];
|
||||
if (!auth) throw new Error("Call provideZitadelAuth() before using zitadelGuard()");
|
||||
return auth;
|
||||
}
|
||||
function zitadelGuard() {
|
||||
let initPromise = null;
|
||||
return async () => {
|
||||
const auth = getAuthInstance();
|
||||
if (!initPromise) {
|
||||
initPromise = auth.init();
|
||||
}
|
||||
await initPromise;
|
||||
if (auth.isAuthenticated) return true;
|
||||
auth.login();
|
||||
return false;
|
||||
};
|
||||
}
|
||||
export {
|
||||
provideZitadelAuth,
|
||||
zitadelGuard
|
||||
};
|
||||
Reference in New Issue
Block a user