authula 0.5.3 → 0.6.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- import { C as AfterFetchHook, E as FetchRequestOptions, S as verificationTypeSchema, T as FetchContext, _ as VerificationType, a as SignOutResponse, b as userSchema, c as FetchOptions, d as CookieProvider, f as CookieStore, g as Verification, h as User, i as SignOutRequest, l as Plugin, m as Session, n as createClient, o as AuthulaClientConfig, p as Account, r as GetMeResponse, s as AuthulaClientOptions, t as ClientWithPlugins, u as AuthulaClient, v as accountSchema, w as BeforeFetchHook, x as verificationSchema, y as sessionSchema } from "./sdk-7eSlhCrf.js";
2
- export { Account, AfterFetchHook, AuthulaClient, AuthulaClientConfig, AuthulaClientOptions, BeforeFetchHook, type ClientWithPlugins, CookieProvider, CookieStore, FetchContext, FetchOptions, FetchRequestOptions, GetMeResponse, Plugin, Session, SignOutRequest, SignOutResponse, User, Verification, VerificationType, accountSchema, createClient, sessionSchema, userSchema, verificationSchema, verificationTypeSchema };
1
+ import { $ as SignUpRequestMetadata, $n as AddOrganizationTeamMemberRequest, $t as DisableResponse, A as UpdateUserResponse, An as CreateAccountResponse, At as MagicLinkSignInRequest, B as UpdateOrganizationRequestMetadata, Bn as BanUserResponse, Bt as UserPermissionInfo, C as UsersPage, Cn as CreateOrganizationTeamRequestMetadata, Ct as OrganizationInvitationStatus, D as UpsertUserStateRequest, Dn as CreateApiKeyResponse, Dt as OauthAuthorizeParams, E as UpsertUserStateResponse, En as CreateOrganizationInvitationRequest, Et as OauthCallbackParams, F as UpdatePermissionResponse, Fn as ChangePasswordRequest, Ft as ListOrganizationMembersParams, G as UpdateAccountResponse, Gn as ApiKey, Gt as GetMeResponse, H as UpdateApiKeyResponse, Hn as AuthorizeResponse, Ht as GetUserByIDResponse, I as UpdatePermissionRequest, In as ChangeEmailResponse, It as ListApiKeysParams, J as StopImpersonationResponse, Jn as AdminUserSession, Jt as GetApiKeyResponse, K as UpdateAccountRequest, Kn as ApiKeyMetadata, Kt as GetImpersonationByIDResponse, L as UpdateOrganizationTeamRequest, Ln as CallbackResponse, Lt as Jwk, M as UpdateUserRequestMetadata, Mn as CheckUserPermissionsResponse, Mt as MagicLinkExchangeRequest, N as UpdateRoleResponse, Nn as CheckUserPermissionsRequest, Nt as ListUsersParams, O as UpsertSessionStateResponse, On as CreateApiKeyRequest, Ot as MagicLinkVerifyResponse, P as UpdateRoleRequest, Pn as ChangePasswordResponse, Pt as ListOrganizationTeamMembersParams, Q as SignUpRequest, Qn as AddRolePermissionRequest, Qt as EnableResponse, R as UpdateOrganizationTeamRequestMetadata, Rn as User, Rt as GetUserStateResponse, S as VerifyApiKeyRequest, Sn as CreateOrganizationTeamRequest, St as OrganizationInvitation, T as UserAccountsResponse, Tn as CreateOrganizationRequestMetadata, Tt as OrganizationMetadata, U as UpdateApiKeyRequest, Un as AssignUserRoleResponse, Ut as GetTOTPURIResponse, V as UpdateOrganizationMemberRequest, Vn as BanUserRequest, Vt as PermissionGrantSource, W as UpdateApiKeyRequestMetadata, Wn as AssignUserRoleRequest, Wt as GetSessionStateResponse, X as StartImpersonationRequest, Xn as AdminSessionState, Xt as GetAccountByIDResponse, Y as StartImpersonationResponse, Yn as Session, Yt as GetAllApiKeysResponse, Z as SignUpResponse, Zn as AddRolePermissionResponse, Zt as GenerateBackupCodesResponse, _ as VerifyTOTPRequest, _n as Role, _t as RefreshTokenRequest, a as AuthulaClientConfig, an as DeleteOrganizationTeamResponse, at as RoleDetails, b as VerifyBackupCodeRequest, bn as Permission, bt as OrganizationTeamMetadata, c as CookieStore, cn as DeleteOrganizationMemberResponse, ct as RequestPasswordResetRequest, d as AuthulaClient, dn as CreateUserStateRequest, dt as ReplaceUserRolesRequest, en as DeleteUserStateResponse, er as AddOrganizationMemberRequest, et as SignOutResponse, f as AfterFetchHook, fn as CreateUserResponse, ft as ReplaceRolePermissionsRequest, g as VerifyTOTPResponse, gn as CreateRoleResponse, gt as RefreshTokenResponse, h as WellKnownJWKSResponse, hn as CreateSessionStateRequest, ht as RemoveRolePermissionResponse, in as DeletePermissionResponse, it as SendEmailVerificationRequest, j as UpdateUserRequest, jn as CreateAccountRequest, jt as MagicLinkExchangeResponse, k as UpsertSessionStateRequest, kn as CreateApiKeyRequestMetadata, kt as MagicLinkSignInResponse, l as FetchOptions, ln as DeleteApiKeyResponse, lt as RequestEmailChangeRequest, m as FetchContext, mn as CreateUserRequestMetadata, mt as RemoveUserRoleResponse, n as createClient, nn as DeleteSessionStateResponse, nr as AcceptOrganizationInvitationQuery, nt as SignInResponse, o as AuthulaClientOptions, on as DeleteOrganizationTeamMemberResponse, ot as RevokeSessionResponse, p as BeforeFetchHook, pn as CreateUserRequest, pt as ReplaceRolePermissionResponse, q as UnbanUserResponse, qn as AdminUserState, qt as Impersonation, r as ApiError, rn as DeleteRoleResponse, rr as AcceptOrganizationInvitationParams, rt as SignInRequest, s as CookieAttributes, sn as DeleteOrganizationResponse, st as RevokeSessionRequest, t as ClientWithPlugins, tn as DeleteUserResponse, tr as Account, tt as SignOutRequest, u as Plugin, un as DeleteAccountResponse, ut as ReplaceUserRolesResponse, v as VerifyMagicLinkParams, vn as CreateRoleRequest, vt as OrganizationTeamMember, w as UserRoleInfo, wn as CreateOrganizationRequest, wt as Organization, x as VerifyApiKeyResponse, xn as CreatePermissionRequest, xt as OrganizationMember, y as VerifyBackupCodeResponse, yn as CreatePermissionResponse, yt as OrganizationTeam, z as UpdateOrganizationRequest, zn as UserMetadata, zt as GetUserPermissionsResponse } from "./index-DHUQcsNV.js";
2
+ export { AcceptOrganizationInvitationParams, AcceptOrganizationInvitationQuery, Account, AddOrganizationMemberRequest, AddOrganizationTeamMemberRequest, AddRolePermissionRequest, AddRolePermissionResponse, AdminSessionState, AdminUserSession, AdminUserState, AfterFetchHook, ApiError, ApiKey, ApiKeyMetadata, AssignUserRoleRequest, AssignUserRoleResponse, AuthorizeResponse, AuthulaClient, AuthulaClientConfig, AuthulaClientOptions, BanUserRequest, BanUserResponse, BeforeFetchHook, CallbackResponse, ChangeEmailResponse, ChangePasswordRequest, ChangePasswordResponse, CheckUserPermissionsRequest, CheckUserPermissionsResponse, type ClientWithPlugins, CookieAttributes, CookieStore, CreateAccountRequest, CreateAccountResponse, CreateApiKeyRequest, CreateApiKeyRequestMetadata, CreateApiKeyResponse, CreateOrganizationInvitationRequest, CreateOrganizationRequest, CreateOrganizationRequestMetadata, CreateOrganizationTeamRequest, CreateOrganizationTeamRequestMetadata, CreatePermissionRequest, CreatePermissionResponse, CreateRoleRequest, CreateRoleResponse, CreateSessionStateRequest, CreateUserRequest, CreateUserRequestMetadata, CreateUserResponse, CreateUserStateRequest, DeleteAccountResponse, DeleteApiKeyResponse, DeleteOrganizationMemberResponse, DeleteOrganizationResponse, DeleteOrganizationTeamMemberResponse, DeleteOrganizationTeamResponse, DeletePermissionResponse, DeleteRoleResponse, DeleteSessionStateResponse, DeleteUserResponse, DeleteUserStateResponse, DisableResponse, EnableResponse, FetchContext, FetchOptions, GenerateBackupCodesResponse, GetAccountByIDResponse, GetAllApiKeysResponse, GetApiKeyResponse, GetImpersonationByIDResponse, GetMeResponse, GetSessionStateResponse, GetTOTPURIResponse, GetUserByIDResponse, GetUserPermissionsResponse, GetUserStateResponse, Impersonation, Jwk, ListApiKeysParams, ListOrganizationMembersParams, ListOrganizationTeamMembersParams, ListUsersParams, MagicLinkExchangeRequest, MagicLinkExchangeResponse, MagicLinkSignInRequest, MagicLinkSignInResponse, MagicLinkVerifyResponse, OauthAuthorizeParams, OauthCallbackParams, Organization, OrganizationInvitation, OrganizationInvitationStatus, OrganizationMember, OrganizationMetadata, OrganizationTeam, OrganizationTeamMember, OrganizationTeamMetadata, Permission, PermissionGrantSource, Plugin, RefreshTokenRequest, RefreshTokenResponse, RemoveRolePermissionResponse, RemoveUserRoleResponse, ReplaceRolePermissionResponse, ReplaceRolePermissionsRequest, ReplaceUserRolesRequest, ReplaceUserRolesResponse, RequestEmailChangeRequest, RequestPasswordResetRequest, RevokeSessionRequest, RevokeSessionResponse, Role, RoleDetails, SendEmailVerificationRequest, Session, SignInRequest, SignInResponse, SignOutRequest, SignOutResponse, SignUpRequest, SignUpRequestMetadata, SignUpResponse, StartImpersonationRequest, StartImpersonationResponse, StopImpersonationResponse, UnbanUserResponse, UpdateAccountRequest, UpdateAccountResponse, UpdateApiKeyRequest, UpdateApiKeyRequestMetadata, UpdateApiKeyResponse, UpdateOrganizationMemberRequest, UpdateOrganizationRequest, UpdateOrganizationRequestMetadata, UpdateOrganizationTeamRequest, UpdateOrganizationTeamRequestMetadata, UpdatePermissionRequest, UpdatePermissionResponse, UpdateRoleRequest, UpdateRoleResponse, UpdateUserRequest, UpdateUserRequestMetadata, UpdateUserResponse, UpsertSessionStateRequest, UpsertSessionStateResponse, UpsertUserStateRequest, UpsertUserStateResponse, User, UserAccountsResponse, UserMetadata, UserPermissionInfo, UserRoleInfo, UsersPage, VerifyApiKeyRequest, VerifyApiKeyResponse, VerifyBackupCodeRequest, VerifyBackupCodeResponse, VerifyMagicLinkParams, VerifyTOTPRequest, VerifyTOTPResponse, WellKnownJWKSResponse, createClient };
package/dist/index.js CHANGED
@@ -1,6 +1,15 @@
1
- import { a as verificationSchema, i as userSchema, n as accountSchema, o as verificationTypeSchema, r as sessionSchema, t as wrappedFetch } from "./fetch-BnZpQ0Yq.js";
2
- import { toSnakeCaseKeys } from "es-toolkit";
1
+ import { t as ApiError } from "./custom-fetch-ZBY99AZW.js";
3
2
 
3
+ //#region src/gen/models/organization-invitation-status.ts
4
+ const OrganizationInvitationStatus = {
5
+ pending: "pending",
6
+ accepted: "accepted",
7
+ rejected: "rejected",
8
+ revoked: "revoked",
9
+ expired: "expired"
10
+ };
11
+
12
+ //#endregion
4
13
  //#region src/client.ts
5
14
  var AuthulaClient = class {
6
15
  config;
@@ -8,13 +17,10 @@ var AuthulaClient = class {
8
17
  beforeFetchHooks = [];
9
18
  afterFetchHooks = [];
10
19
  constructor(options) {
11
- this.plugins = options.plugins;
20
+ this.plugins = options.plugins || [];
12
21
  const { plugins, ...rest } = options;
13
22
  this.config = rest;
14
- for (const plugin of this.plugins) {
15
- if ("attachCookies" in plugin && this.config.cookies) plugin.attachCookies(this.config.cookies);
16
- this[plugin.id] = plugin.init(this);
17
- }
23
+ for (const plugin of this.plugins) this[plugin.id] = plugin.init(this);
18
24
  }
19
25
  registerBeforeFetch(hook) {
20
26
  this.beforeFetchHooks.push(hook);
@@ -28,15 +34,6 @@ var AuthulaClient = class {
28
34
  async runAfterFetch(ctx, res) {
29
35
  for (const hook of this.afterFetchHooks) if (await hook(ctx, res) === "retry") return "retry";
30
36
  }
31
- async getMe() {
32
- return wrappedFetch(this, "/me", { method: "GET" });
33
- }
34
- async signOut(data) {
35
- return wrappedFetch(this, "/sign-out", {
36
- method: "POST",
37
- body: toSnakeCaseKeys(data)
38
- });
39
- }
40
37
  getPlugin(id) {
41
38
  return this.plugins.find((plugin) => plugin.id === id);
42
39
  }
@@ -49,5 +46,5 @@ function createClient(options) {
49
46
  }
50
47
 
51
48
  //#endregion
52
- export { AuthulaClient, accountSchema, createClient, sessionSchema, userSchema, verificationSchema, verificationTypeSchema };
49
+ export { ApiError, AuthulaClient, OrganizationInvitationStatus, createClient };
53
50
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":[],"sources":["../src/client.ts","../src/sdk.ts"],"sourcesContent":["import { toSnakeCaseKeys } from \"es-toolkit\";\n\nimport { wrappedFetch } from \"./fetch\";\nimport type {\n FetchContext,\n AuthulaClientConfig,\n AuthulaClientOptions,\n SignOutRequest,\n SignOutResponse,\n Plugin,\n BeforeFetchHook,\n AfterFetchHook,\n} from \"./types\";\n\nexport class AuthulaClient {\n public readonly config: AuthulaClientConfig;\n private readonly plugins: Array<Plugin>;\n private readonly beforeFetchHooks: BeforeFetchHook[] = [];\n private readonly afterFetchHooks: AfterFetchHook[] = [];\n\n constructor(options: AuthulaClientOptions) {\n this.plugins = options.plugins;\n\n const { plugins, ...rest } = options;\n this.config = rest;\n\n for (const plugin of this.plugins) {\n if (\"attachCookies\" in plugin && this.config.cookies) {\n (plugin as any).attachCookies(this.config.cookies);\n }\n (this as any)[plugin.id] = plugin.init(this);\n }\n }\n\n public registerBeforeFetch(hook: BeforeFetchHook): void {\n this.beforeFetchHooks.push(hook);\n }\n\n public registerAfterFetch(hook: AfterFetchHook): void {\n this.afterFetchHooks.push(hook);\n }\n\n public async runBeforeFetch(ctx: FetchContext): Promise<void> {\n for (const hook of this.beforeFetchHooks) {\n await hook(ctx);\n }\n }\n\n public async runAfterFetch(ctx: FetchContext, res: Response) {\n for (const hook of this.afterFetchHooks) {\n const result = await hook(ctx, res);\n if (result === \"retry\") {\n return \"retry\";\n }\n }\n }\n\n public async getMe<T = unknown>(): Promise<T> {\n return wrappedFetch<T>(this, \"/me\", {\n method: \"GET\",\n });\n }\n\n public async signOut(data: SignOutRequest): Promise<SignOutResponse> {\n return wrappedFetch<SignOutResponse>(this, \"/sign-out\", {\n method: \"POST\",\n body: toSnakeCaseKeys(data),\n });\n }\n\n public getPlugin<T extends Plugin>(id: string): T | undefined {\n return this.plugins.find((plugin) => plugin.id === id) as T | undefined;\n }\n}\n","import { AuthulaClient } from \"./client\";\nimport type { AuthulaClientOptions, Plugin } from \"./types\";\n\n// Helper to extract plugin methods\nexport type InferPluginMethods<P> = P extends { init: (client: any) => infer M }\n ? M\n : never;\n\nexport type ClientWithPlugins<T extends readonly Plugin[]> = AuthulaClient & {\n [P in T[number] as P[\"id\"]]: InferPluginMethods<P>;\n};\n\nexport function createClient<const T extends readonly Plugin[]>(\n options: Omit<AuthulaClientOptions, \"plugins\"> & { plugins: T },\n): ClientWithPlugins<T> {\n return new AuthulaClient(options as any) as ClientWithPlugins<T>;\n}\n"],"mappings":";;;;AAcA,IAAa,gBAAb,MAA2B;CACzB,AAAgB;CAChB,AAAiB;CACjB,AAAiB,mBAAsC,CAAC;CACxD,AAAiB,kBAAoC,CAAC;CAEtD,YAAY,SAA+B;EACzC,KAAK,UAAU,QAAQ;EAEvB,MAAM,EAAE,SAAS,GAAG,SAAS;EAC7B,KAAK,SAAS;EAEd,KAAK,MAAM,UAAU,KAAK,SAAS;GACjC,IAAI,mBAAmB,UAAU,KAAK,OAAO,SAC3C,AAAC,OAAe,cAAc,KAAK,OAAO,OAAO;GAEnD,AAAC,KAAa,OAAO,MAAM,OAAO,KAAK,IAAI;EAC7C;CACF;CAEA,AAAO,oBAAoB,MAA6B;EACtD,KAAK,iBAAiB,KAAK,IAAI;CACjC;CAEA,AAAO,mBAAmB,MAA4B;EACpD,KAAK,gBAAgB,KAAK,IAAI;CAChC;CAEA,MAAa,eAAe,KAAkC;EAC5D,KAAK,MAAM,QAAQ,KAAK,kBACtB,MAAM,KAAK,GAAG;CAElB;CAEA,MAAa,cAAc,KAAmB,KAAe;EAC3D,KAAK,MAAM,QAAQ,KAAK,iBAEtB,IAAI,MADiB,KAAK,KAAK,GAAG,MACnB,SACb,OAAO;CAGb;CAEA,MAAa,QAAiC;EAC5C,OAAO,aAAgB,MAAM,OAAO,EAClC,QAAQ,MACV,CAAC;CACH;CAEA,MAAa,QAAQ,MAAgD;EACnE,OAAO,aAA8B,MAAM,aAAa;GACtD,QAAQ;GACR,MAAM,gBAAgB,IAAI;EAC5B,CAAC;CACH;CAEA,AAAO,UAA4B,IAA2B;EAC5D,OAAO,KAAK,QAAQ,MAAM,WAAW,OAAO,OAAO,EAAE;CACvD;AACF;;;;AC7DA,SAAgB,aACd,SACsB;CACtB,OAAO,IAAI,cAAc,OAAc;AACzC"}
1
+ {"version":3,"file":"index.js","names":[],"sources":["../src/gen/models/organization-invitation-status.ts","../src/client.ts","../src/sdk.ts"],"sourcesContent":["/**\n * Generated by orval v8.20.0 🍺\n * Do not edit manually.\n * Authula API\n * Authula API - An open-source authentication solution that scales with you.\n * OpenAPI spec version: 0.1.0\n */\n\n/**\n * The type of the invitation status\n */\nexport type OrganizationInvitationStatus =\n\t(typeof OrganizationInvitationStatus)[keyof typeof OrganizationInvitationStatus];\n\nexport const OrganizationInvitationStatus = {\n\tpending: \"pending\",\n\taccepted: \"accepted\",\n\trejected: \"rejected\",\n\trevoked: \"revoked\",\n\texpired: \"expired\",\n} as const;\n","import type {\n FetchContext,\n AuthulaClientConfig,\n AuthulaClientOptions,\n Plugin,\n BeforeFetchHook,\n AfterFetchHook,\n} from \"./types\";\n\nexport class AuthulaClient {\n public readonly config: AuthulaClientConfig;\n private readonly plugins: Array<Plugin>;\n private readonly beforeFetchHooks: BeforeFetchHook[] = [];\n private readonly afterFetchHooks: AfterFetchHook[] = [];\n\n constructor(options: AuthulaClientOptions) {\n this.plugins = options.plugins || [];\n\n const { plugins, ...rest } = options;\n this.config = rest;\n\n for (const plugin of this.plugins) {\n (this as any)[plugin.id] = plugin.init(this);\n }\n }\n\n public registerBeforeFetch(hook: BeforeFetchHook): void {\n this.beforeFetchHooks.push(hook);\n }\n\n public registerAfterFetch(hook: AfterFetchHook): void {\n this.afterFetchHooks.push(hook);\n }\n\n public async runBeforeFetch(ctx: FetchContext): Promise<void> {\n for (const hook of this.beforeFetchHooks) {\n await hook(ctx);\n }\n }\n\n public async runAfterFetch(ctx: FetchContext, res: Response) {\n for (const hook of this.afterFetchHooks) {\n const result = await hook(ctx, res);\n if (result === \"retry\") {\n return \"retry\";\n }\n }\n }\n\n public getPlugin<T extends Plugin>(id: string): T | undefined {\n return this.plugins.find((plugin) => plugin.id === id) as T | undefined;\n }\n}\n","import { AuthulaClient } from \"./client\";\nimport type { AuthulaClientOptions, Plugin } from \"./types\";\n\n// Helper to extract plugin methods\nexport type InferPluginMethods<P> = P extends { init: (client: any) => infer M }\n ? M\n : never;\n\nexport type ClientWithPlugins<T extends readonly Plugin[]> = AuthulaClient & {\n [P in T[number] as P[\"id\"]]: InferPluginMethods<P>;\n};\n\nexport function createClient<const T extends readonly Plugin[]>(\n options: Omit<AuthulaClientOptions, \"plugins\"> & { plugins: T },\n): ClientWithPlugins<T> {\n return new AuthulaClient(options as any) as ClientWithPlugins<T>;\n}\n"],"mappings":";;;AAcA,MAAa,+BAA+B;CAC3C,SAAS;CACT,UAAU;CACV,UAAU;CACV,SAAS;CACT,SAAS;AACV;;;;ACXA,IAAa,gBAAb,MAA2B;CACzB,AAAgB;CAChB,AAAiB;CACjB,AAAiB,mBAAsC,CAAC;CACxD,AAAiB,kBAAoC,CAAC;CAEtD,YAAY,SAA+B;EACzC,KAAK,UAAU,QAAQ,WAAW,CAAC;EAEnC,MAAM,EAAE,SAAS,GAAG,SAAS;EAC7B,KAAK,SAAS;EAEd,KAAK,MAAM,UAAU,KAAK,SACxB,AAAC,KAAa,OAAO,MAAM,OAAO,KAAK,IAAI;CAE/C;CAEA,AAAO,oBAAoB,MAA6B;EACtD,KAAK,iBAAiB,KAAK,IAAI;CACjC;CAEA,AAAO,mBAAmB,MAA4B;EACpD,KAAK,gBAAgB,KAAK,IAAI;CAChC;CAEA,MAAa,eAAe,KAAkC;EAC5D,KAAK,MAAM,QAAQ,KAAK,kBACtB,MAAM,KAAK,GAAG;CAElB;CAEA,MAAa,cAAc,KAAmB,KAAe;EAC3D,KAAK,MAAM,QAAQ,KAAK,iBAEtB,IAAI,MADiB,KAAK,KAAK,GAAG,MACnB,SACb,OAAO;CAGb;CAEA,AAAO,UAA4B,IAA2B;EAC5D,OAAO,KAAK,QAAQ,MAAM,WAAW,OAAO,OAAO,EAAE;CACvD;AACF;;;;ACxCA,SAAgB,aACd,SACsB;CACtB,OAAO,IAAI,cAAc,OAAc;AACzC"}