alepha
Version:
Easy-to-use modern TypeScript framework for building many kind of applications.
58 lines (57 loc) • 2.05 kB
JavaScript
import { $module, z } from "alepha";
import { userAccountInfoSchema } from "alepha/security";
import { apiRegistryResponseSchema } from "alepha/server/links";
//#region ../../src/server/auth/constants/routes.ts
const alephaServerAuthRoutes = {
login: "/oauth/login",
callback: "/oauth/callback",
logout: "/oauth/logout",
token: "/_auth/token",
refresh: "/_auth/refresh",
userinfo: "/_auth/userinfo"
};
//#endregion
//#region ../../src/server/auth/schemas/authenticationProviderSchema.ts
const authenticationProviderSchema = z.object({
name: z.text({ description: "Name of the authentication provider." }),
type: z.enum([
"OAUTH2",
"OIDC",
"CREDENTIALS"
]).describe("Type of the authentication provider.")
}).meta({ title: "AuthenticationProvider" });
//#endregion
//#region ../../src/server/auth/schemas/tokensSchema.ts
const tokensSchema = z.object({
provider: z.text(),
access_token: z.text({ size: "rich" }),
issued_at: z.number(),
expires_in: z.number().optional(),
refresh_token: z.text({ size: "rich" }).optional(),
refresh_token_expires_in: z.number().optional(),
refresh_expires_in: z.number().describe("Alias of `refresh_token_expires_in` for compatibility with some providers.").optional(),
id_token: z.text({ size: "rich" }).optional(),
scope: z.text().optional()
});
//#endregion
//#region ../../src/server/auth/schemas/tokenResponseSchema.ts
const tokenResponseSchema = tokensSchema.extend({
user: userAccountInfoSchema,
api: apiRegistryResponseSchema
});
//#endregion
//#region ../../src/server/auth/schemas/userinfoResponseSchema.ts
const userinfoResponseSchema = z.object({
user: userAccountInfoSchema.optional(),
api: apiRegistryResponseSchema
});
//#endregion
//#region ../../src/server/auth/index.browser.ts
const AlephaServerAuth = $module({
name: "alepha.server.auth",
primitives: [],
services: []
});
//#endregion
export { AlephaServerAuth, alephaServerAuthRoutes, authenticationProviderSchema, tokenResponseSchema, tokensSchema, userinfoResponseSchema };
//# sourceMappingURL=index.browser.js.map