@gatwech/core 0.0.11 → 1.0.0-beta.19

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.
Files changed (134) hide show
  1. package/dist/api/index.d.mts +2 -2
  2. package/dist/context/index.d.mts +2 -2
  3. package/dist/db/adapter/index.d.mts +2 -2
  4. package/dist/db/index.d.mts +2 -2
  5. package/dist/env/index.d.mts +1 -1
  6. package/dist/env/index.mjs +1 -1
  7. package/dist/{env-JMSMESs1.mjs → env-ubiqEEZm.mjs} +10 -9
  8. package/dist/error/index.mjs +2 -2
  9. package/dist/{error-41YsFQ8b.mjs → error-DKIIiFmH.mjs} +1 -1
  10. package/dist/{index-DLP-K0uY.d.mts → index-CNtOUpmF.d.mts} +4 -3
  11. package/dist/index-Df0KhQRf.d.mts +3002 -0
  12. package/dist/index.d.mts +3 -3
  13. package/dist/oauth2/index.d.mts +2 -2
  14. package/dist/social-providers/index.d.mts +3 -3
  15. package/dist/social-providers/index.mjs +73 -2414
  16. package/dist/src/api/index.d.ts +119 -0
  17. package/dist/src/async_hooks/index.d.ts +6 -0
  18. package/dist/src/context/endpoint-context.d.ts +14 -0
  19. package/dist/src/context/index.d.ts +3 -0
  20. package/dist/src/context/request-state.d.ts +13 -0
  21. package/dist/src/context/transaction.d.ts +11 -0
  22. package/dist/src/db/adapter/index.d.ts +401 -0
  23. package/{src/db/index.ts → dist/src/db/index.d.ts} +2 -18
  24. package/dist/src/db/plugin.d.ts +10 -0
  25. package/dist/src/db/schema/account.d.ts +22 -0
  26. package/dist/src/db/schema/rate-limit.d.ts +10 -0
  27. package/dist/src/db/schema/session.d.ts +17 -0
  28. package/dist/src/db/schema/shared.d.ts +6 -0
  29. package/dist/src/db/schema/user.d.ts +16 -0
  30. package/{src/db/schema/verification.ts → dist/src/db/schema/verification.d.ts} +8 -8
  31. package/dist/src/db/type.d.ts +159 -0
  32. package/dist/src/env/color-depth.d.ts +1 -0
  33. package/dist/src/env/env-impl.d.ts +29 -0
  34. package/dist/src/env/index.d.ts +3 -0
  35. package/dist/src/env/logger.d.ts +52 -0
  36. package/dist/src/error/codes.d.ts +27 -0
  37. package/dist/src/error/index.d.ts +4 -0
  38. package/dist/src/oauth2/client-credentials-token.d.ts +21 -0
  39. package/dist/src/oauth2/create-authorization-url.d.ts +21 -0
  40. package/dist/src/oauth2/index.d.ts +6 -0
  41. package/dist/src/oauth2/oauth-provider.d.ts +178 -0
  42. package/dist/src/oauth2/refresh-access-token.d.ts +20 -0
  43. package/dist/src/oauth2/utils.d.ts +3 -0
  44. package/dist/src/oauth2/validate-authorization-code.d.ts +28 -0
  45. package/dist/src/social-providers/github.d.ts +89 -0
  46. package/dist/src/social-providers/google.d.ts +82 -0
  47. package/dist/src/social-providers/index.d.ts +93 -0
  48. package/dist/src/types/context.d.ts +177 -0
  49. package/dist/src/types/cookie.d.ts +15 -0
  50. package/dist/src/types/helper.d.ts +9 -0
  51. package/dist/src/types/index.d.ts +7 -0
  52. package/dist/src/types/init-options.d.ts +1140 -0
  53. package/dist/src/types/plugin-client.d.ts +88 -0
  54. package/dist/src/types/plugin.d.ts +120 -0
  55. package/dist/src/utils/error-codes.d.ts +9 -0
  56. package/dist/utils/index.mjs +1 -1
  57. package/package.json +11 -5
  58. package/.turbo/turbo-build.log +0 -42
  59. package/dist/index-DjrJweYn.d.mts +0 -7312
  60. package/src/api/index.ts +0 -57
  61. package/src/async_hooks/index.ts +0 -35
  62. package/src/context/endpoint-context.ts +0 -48
  63. package/src/context/index.ts +0 -21
  64. package/src/context/request-state.test.ts +0 -346
  65. package/src/context/request-state.ts +0 -75
  66. package/src/context/transaction.ts +0 -72
  67. package/src/db/adapter/index.ts +0 -466
  68. package/src/db/plugin.ts +0 -11
  69. package/src/db/schema/account.ts +0 -34
  70. package/src/db/schema/rate-limit.ts +0 -21
  71. package/src/db/schema/session.ts +0 -17
  72. package/src/db/schema/shared.ts +0 -7
  73. package/src/db/schema/user.ts +0 -16
  74. package/src/db/type.ts +0 -180
  75. package/src/env/color-depth.ts +0 -172
  76. package/src/env/env-impl.ts +0 -124
  77. package/src/env/index.ts +0 -23
  78. package/src/env/logger.test.ts +0 -33
  79. package/src/env/logger.ts +0 -145
  80. package/src/error/codes.ts +0 -31
  81. package/src/error/index.ts +0 -11
  82. package/src/oauth2/client-credentials-token.ts +0 -102
  83. package/src/oauth2/create-authorization-url.ts +0 -85
  84. package/src/oauth2/index.ts +0 -21
  85. package/src/oauth2/oauth-provider.ts +0 -211
  86. package/src/oauth2/refresh-access-token.ts +0 -124
  87. package/src/oauth2/utils.ts +0 -36
  88. package/src/oauth2/validate-authorization-code.ts +0 -154
  89. package/src/social-providers/apple.ts +0 -213
  90. package/src/social-providers/atlassian.ts +0 -132
  91. package/src/social-providers/cognito.ts +0 -269
  92. package/src/social-providers/discord.ts +0 -169
  93. package/src/social-providers/dropbox.ts +0 -112
  94. package/src/social-providers/facebook.ts +0 -204
  95. package/src/social-providers/figma.ts +0 -115
  96. package/src/social-providers/github.ts +0 -154
  97. package/src/social-providers/gitlab.ts +0 -152
  98. package/src/social-providers/google.ts +0 -171
  99. package/src/social-providers/huggingface.ts +0 -118
  100. package/src/social-providers/index.ts +0 -124
  101. package/src/social-providers/kakao.ts +0 -178
  102. package/src/social-providers/kick.ts +0 -92
  103. package/src/social-providers/line.ts +0 -169
  104. package/src/social-providers/linear.ts +0 -120
  105. package/src/social-providers/linkedin.ts +0 -110
  106. package/src/social-providers/microsoft-entra-id.ts +0 -245
  107. package/src/social-providers/naver.ts +0 -112
  108. package/src/social-providers/notion.ts +0 -108
  109. package/src/social-providers/paybin.ts +0 -122
  110. package/src/social-providers/paypal.ts +0 -263
  111. package/src/social-providers/polar.ts +0 -107
  112. package/src/social-providers/reddit.ts +0 -122
  113. package/src/social-providers/roblox.ts +0 -110
  114. package/src/social-providers/salesforce.ts +0 -159
  115. package/src/social-providers/slack.ts +0 -111
  116. package/src/social-providers/spotify.ts +0 -93
  117. package/src/social-providers/tiktok.ts +0 -210
  118. package/src/social-providers/twitch.ts +0 -111
  119. package/src/social-providers/twitter.ts +0 -198
  120. package/src/social-providers/vk.ts +0 -126
  121. package/src/social-providers/zoom.ts +0 -217
  122. package/src/types/context.ts +0 -269
  123. package/src/types/cookie.ts +0 -7
  124. package/src/types/helper.ts +0 -6
  125. package/src/types/index.ts +0 -21
  126. package/src/types/init-options.ts +0 -1346
  127. package/src/types/plugin-client.ts +0 -100
  128. package/src/types/plugin.ts +0 -158
  129. package/src/utils/error-codes.ts +0 -51
  130. package/tsconfig.json +0 -7
  131. package/tsdown.config.ts +0 -20
  132. /package/{src/index.ts → dist/src/index.d.ts} +0 -0
  133. /package/{src/utils/index.ts → dist/src/utils/index.d.ts} +0 -0
  134. /package/dist/{utils-BFQCAfNW.mjs → utils-CTOwq_Nj.mjs} +0 -0
@@ -1,100 +0,0 @@
1
- import type {
2
- BetterFetch,
3
- BetterFetchOption,
4
- BetterFetchPlugin,
5
- } from "@better-fetch/fetch";
6
- import type { Atom, WritableAtom } from "nanostores";
7
- import type { LiteralString } from "./helper";
8
- import type { PayvoAuthOptions } from "./init-options";
9
- import type { PayvoAuthPlugin } from "./plugin";
10
-
11
- export interface ClientStore {
12
- notify: (signal: string) => void;
13
- listen: (signal: string, listener: () => void) => void;
14
- atoms: Record<string, WritableAtom<any>>;
15
- }
16
-
17
- export type ClientAtomListener = {
18
- matcher: (path: string) => boolean;
19
- signal: "$sessionSignal" | Omit<string, "$sessionSignal">;
20
- };
21
-
22
- export interface RevalidateOptions {
23
- /**
24
- * A time interval (in seconds) after which the session will be re-fetched.
25
- * If set to `0` (default), the session is not polled.
26
- *
27
- * This helps prevent session expiry during idle periods by periodically
28
- * refreshing the session.
29
- *
30
- * @default 0
31
- */
32
- refetchInterval?: number | undefined;
33
- /**
34
- * Automatically refetch the session when the user switches back to the window/tab.
35
- * This option activates this behavior if set to `true` (default).
36
- *
37
- * Prevents expired sessions when users switch tabs and come back later.
38
- *
39
- * @default true
40
- */
41
- refetchOnWindowFocus?: boolean | undefined;
42
- /**
43
- * Set to `false` to stop polling when the device has no internet access
44
- * (determined by `navigator.onLine`).
45
- *
46
- * @default false
47
- * @see https://developer.mozilla.org/en-US/docs/Web/API/NavigatorOnLine/onLine
48
- */
49
- refetchWhenOffline?: boolean | undefined;
50
- }
51
-
52
- export interface PayvoAuthClientOptions {
53
- fetchOptions?: BetterFetchOption | undefined;
54
- plugins?: PayvoAuthClientPlugin[] | undefined;
55
- baseURL?: string | undefined;
56
- basePath?: string | undefined;
57
- disableDefaultFetchPlugins?: boolean | undefined;
58
- $InferAuth?: PayvoAuthOptions | undefined;
59
- sessionOptions?: RevalidateOptions | undefined;
60
- }
61
-
62
- export interface PayvoAuthClientPlugin {
63
- id: LiteralString;
64
- /**
65
- * only used for type inference. don't pass the
66
- * actual plugin
67
- */
68
- $InferServerPlugin?: PayvoAuthPlugin | undefined;
69
- /**
70
- * Custom actions
71
- */
72
- getActions?: (
73
- $fetch: BetterFetch,
74
- $store: ClientStore,
75
- /**
76
- * payvo-auth client options
77
- */
78
- options: PayvoAuthClientOptions | undefined
79
- ) => Record<string, any>;
80
- /**
81
- * State atoms that'll be resolved by each framework
82
- * auth store.
83
- */
84
- getAtoms?: (($fetch: BetterFetch) => Record<string, Atom<any>>) | undefined;
85
- /**
86
- * specify path methods for server plugin inferred
87
- * endpoints to force a specific method.
88
- */
89
- pathMethods?: Record<string, "POST" | "GET"> | undefined;
90
- /**
91
- * Better fetch plugins
92
- */
93
- fetchPlugins?: BetterFetchPlugin[] | undefined;
94
- /**
95
- * a list of recaller based on a matcher function.
96
- * The signal name needs to match a signal in this
97
- * plugin or any plugin the user might have added.
98
- */
99
- atomListeners?: ClientAtomListener[] | undefined;
100
- }
@@ -1,158 +0,0 @@
1
- import type {
2
- Endpoint,
3
- EndpointContext,
4
- InputContext,
5
- Middleware,
6
- } from "better-call";
7
- import type { Migration } from "kysely";
8
- import type { AuthMiddleware } from "../api";
9
- import type { PayvoAuthPluginDBSchema } from "../db";
10
- import type { AuthContext } from "./context";
11
- import type { LiteralString } from "./helper";
12
- import type { PayvoAuthOptions } from "./init-options";
13
-
14
- type Awaitable<T> = T | Promise<T>;
15
- type DeepPartial<T> = T extends Function
16
- ? T
17
- : T extends object
18
- ? { [K in keyof T]?: DeepPartial<T[K]> }
19
- : T;
20
-
21
- export type HookEndpointContext = Partial<
22
- EndpointContext<string, any> & Omit<InputContext<string, any>, "method">
23
- > & {
24
- path: string;
25
- context: AuthContext & {
26
- returned?: unknown | undefined;
27
- responseHeaders?: Headers | undefined;
28
- };
29
- headers?: Headers | undefined;
30
- };
31
-
32
- export type PayvoAuthPlugin = {
33
- id: LiteralString;
34
- /**
35
- * The init function is called when the plugin is initialized.
36
- * You can return a new context or modify the existing context.
37
- */
38
- init?:
39
- | ((ctx: AuthContext) =>
40
- | Awaitable<{
41
- context?: DeepPartial<Omit<AuthContext, "options">>;
42
- options?: Partial<PayvoAuthOptions>;
43
- }>
44
- | void
45
- | Promise<void>)
46
- | undefined;
47
- endpoints?:
48
- | {
49
- [key: string]: Endpoint;
50
- }
51
- | undefined;
52
- middlewares?:
53
- | {
54
- path: string;
55
- middleware: Middleware;
56
- }[]
57
- | undefined;
58
- onRequest?:
59
- | ((
60
- request: Request,
61
- ctx: AuthContext
62
- ) => Promise<
63
- | {
64
- response: Response;
65
- }
66
- | {
67
- request: Request;
68
- }
69
- | void
70
- >)
71
- | undefined;
72
- onResponse?:
73
- | ((
74
- response: Response,
75
- ctx: AuthContext
76
- ) => Promise<{
77
- response: Response;
78
- } | void>)
79
- | undefined;
80
- hooks?:
81
- | {
82
- before?: {
83
- matcher: (context: HookEndpointContext) => boolean;
84
- handler: AuthMiddleware;
85
- }[];
86
- after?: {
87
- matcher: (context: HookEndpointContext) => boolean;
88
- handler: AuthMiddleware;
89
- }[];
90
- }
91
- | undefined;
92
- /**
93
- * Schema the plugin needs
94
- *
95
- * This will also be used to migrate the database. If the fields are dynamic from the plugins
96
- * configuration each time the configuration is changed a new migration will be created.
97
- *
98
- * NOTE: If you want to create migrations manually using
99
- * migrations option or any other way you
100
- * can disable migration per table basis.
101
- *
102
- * @example
103
- * ```ts
104
- * schema: {
105
- * user: {
106
- * fields: {
107
- * email: {
108
- * type: "string",
109
- * },
110
- * emailVerified: {
111
- * type: "boolean",
112
- * defaultValue: false,
113
- * },
114
- * },
115
- * }
116
- * } as AuthPluginSchema
117
- * ```
118
- */
119
- schema?: PayvoAuthPluginDBSchema | undefined;
120
- /**
121
- * The migrations of the plugin. If you define schema that will automatically create
122
- * migrations for you.
123
- *
124
- * ⚠️ Only uses this if you dont't want to use the schema option and you disabled migrations for
125
- * the tables.
126
- */
127
- migrations?: Record<string, Migration> | undefined;
128
- /**
129
- * The options of the plugin
130
- */
131
- options?: Record<string, any> | undefined;
132
- /**
133
- * types to be inferred
134
- */
135
- $Infer?: Record<string, any> | undefined;
136
- /**
137
- * The rate limit rules to apply to specific paths.
138
- */
139
- rateLimit?:
140
- | {
141
- window: number;
142
- max: number;
143
- pathMatcher: (path: string) => boolean;
144
- }[]
145
- | undefined;
146
- /**
147
- * The error codes returned by the plugin
148
- */
149
- $ERROR_CODES?: Record<string, string> | undefined;
150
- /**
151
- * All database operations that are performed by the plugin
152
- *
153
- * This will override the default database operations
154
- */
155
- adapter?: {
156
- [key: string]: (...args: any[]) => Promise<any> | any;
157
- };
158
- };
@@ -1,51 +0,0 @@
1
- type UpperLetter =
2
- | "A"
3
- | "B"
4
- | "C"
5
- | "D"
6
- | "E"
7
- | "F"
8
- | "G"
9
- | "H"
10
- | "I"
11
- | "J"
12
- | "K"
13
- | "L"
14
- | "M"
15
- | "N"
16
- | "O"
17
- | "P"
18
- | "Q"
19
- | "R"
20
- | "S"
21
- | "T"
22
- | "U"
23
- | "V"
24
- | "W"
25
- | "X"
26
- | "Y"
27
- | "Z";
28
- type SpecialCharacter = "_";
29
-
30
- type IsValidUpperSnakeCase<S extends string> = S extends `${infer F}${infer R}`
31
- ? F extends UpperLetter | SpecialCharacter
32
- ? IsValidUpperSnakeCase<R>
33
- : false
34
- : true;
35
-
36
- type InvalidKeyError<K extends string> =
37
- `Invalid error code key: "${K}" - must only contain uppercase letters (A-Z) and underscores (_)`;
38
-
39
- type ValidateErrorCodes<T> = {
40
- [K in keyof T]: K extends string
41
- ? IsValidUpperSnakeCase<K> extends false
42
- ? InvalidKeyError<K>
43
- : T[K]
44
- : T[K];
45
- };
46
-
47
- export function defineErrorCodes<const T extends Record<string, string>>(
48
- codes: ValidateErrorCodes<T>,
49
- ): T {
50
- return codes as T;
51
- }
package/tsconfig.json DELETED
@@ -1,7 +0,0 @@
1
- {
2
- "extends": "../../tsconfig.base.json",
3
- "compilerOptions": {
4
- "lib": ["esnext", "dom", "dom.iterable"],
5
- "types": ["node"]
6
- }
7
- }
package/tsdown.config.ts DELETED
@@ -1,20 +0,0 @@
1
- import { defineConfig } from "tsdown";
2
-
3
- export default defineConfig({
4
- dts: { build: true, incremental: true },
5
- format: ["esm"],
6
- entry: [
7
- "./src/index.ts",
8
- "./src/db/index.ts",
9
- "./src/db/adapter/index.ts",
10
- "./src/async_hooks/index.ts",
11
- "./src/context/index.ts",
12
- "./src/env/index.ts",
13
- "./src/oauth2/index.ts",
14
- "./src/api/index.ts",
15
- "./src/social-providers/index.ts",
16
- "./src/utils/index.ts",
17
- "./src/error/index.ts",
18
- ],
19
- clean: true,
20
- });
File without changes
File without changes