@banata-auth/convex 0.1.0
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/LICENSE +21 -0
- package/README.md +104 -0
- package/dist/auth-config.d.ts +22 -0
- package/dist/auth-config.d.ts.map +1 -0
- package/dist/auth-config.js +3 -0
- package/dist/auth-config.js.map +1 -0
- package/dist/auth.d.ts +462 -0
- package/dist/auth.d.ts.map +1 -0
- package/dist/component/adapter.d.ts +21 -0
- package/dist/component/adapter.d.ts.map +1 -0
- package/dist/component/adapter.js +3 -0
- package/dist/component/adapter.js.map +1 -0
- package/dist/component/schema.d.ts +1026 -0
- package/dist/component/schema.d.ts.map +1 -0
- package/dist/hooks.d.ts +25 -0
- package/dist/hooks.d.ts.map +1 -0
- package/dist/http.d.ts +41 -0
- package/dist/http.d.ts.map +1 -0
- package/dist/http.js +62 -0
- package/dist/http.js.map +1 -0
- package/dist/index.d.ts +9 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +9516 -0
- package/dist/index.js.map +1 -0
- package/dist/node.d.ts +389 -0
- package/dist/node.d.ts.map +1 -0
- package/dist/node.js +9559 -0
- package/dist/node.js.map +1 -0
- package/dist/plugins/audit.d.ts +106 -0
- package/dist/plugins/audit.d.ts.map +1 -0
- package/dist/plugins/config.d.ts +83 -0
- package/dist/plugins/config.d.ts.map +1 -0
- package/dist/plugins/domains.d.ts +3 -0
- package/dist/plugins/domains.d.ts.map +1 -0
- package/dist/plugins/email-sender.d.ts +75 -0
- package/dist/plugins/email-sender.d.ts.map +1 -0
- package/dist/plugins/email-templates.d.ts +108 -0
- package/dist/plugins/email-templates.d.ts.map +1 -0
- package/dist/plugins/email.d.ts +82 -0
- package/dist/plugins/email.d.ts.map +1 -0
- package/dist/plugins/enterprise.d.ts +3 -0
- package/dist/plugins/enterprise.d.ts.map +1 -0
- package/dist/plugins/events.d.ts +40 -0
- package/dist/plugins/events.d.ts.map +1 -0
- package/dist/plugins/index.d.ts +18 -0
- package/dist/plugins/index.d.ts.map +1 -0
- package/dist/plugins/index.js +9192 -0
- package/dist/plugins/index.js.map +1 -0
- package/dist/plugins/organization-rbac.d.ts +3 -0
- package/dist/plugins/organization-rbac.d.ts.map +1 -0
- package/dist/plugins/portal.d.ts +34 -0
- package/dist/plugins/portal.d.ts.map +1 -0
- package/dist/plugins/projects.d.ts +16 -0
- package/dist/plugins/projects.d.ts.map +1 -0
- package/dist/plugins/protection.d.ts +127 -0
- package/dist/plugins/protection.d.ts.map +1 -0
- package/dist/plugins/types.d.ts +508 -0
- package/dist/plugins/types.d.ts.map +1 -0
- package/dist/plugins/user-management.d.ts +8 -0
- package/dist/plugins/user-management.d.ts.map +1 -0
- package/dist/plugins/vault.d.ts +68 -0
- package/dist/plugins/vault.d.ts.map +1 -0
- package/dist/plugins/webhook.d.ts +65 -0
- package/dist/plugins/webhook.d.ts.map +1 -0
- package/dist/triggers.d.ts +158 -0
- package/dist/triggers.d.ts.map +1 -0
- package/dist/triggers.js +36 -0
- package/dist/triggers.js.map +1 -0
- package/package.json +102 -0
- package/src/component/adapter.ts +21 -0
- package/src/component/convex.config.ts +15 -0
- package/src/component/schema.ts +916 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Banata Auth Contributors
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
# @banata-auth/convex
|
|
2
|
+
|
|
3
|
+
Convex backend integration for Banata Auth -- auth factory, plugins, triggers, and database schema.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install @banata-auth/convex
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Quick start
|
|
12
|
+
|
|
13
|
+
### 1. Define your schema
|
|
14
|
+
|
|
15
|
+
```ts
|
|
16
|
+
// convex/banataAuth/schema.ts
|
|
17
|
+
export { default } from "@banata-auth/convex/schema";
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
### 2. Create the auth component and instance
|
|
21
|
+
|
|
22
|
+
```ts
|
|
23
|
+
// convex/banataAuth/auth.ts
|
|
24
|
+
import {
|
|
25
|
+
createBanataAuth,
|
|
26
|
+
createBanataAuthComponent,
|
|
27
|
+
createBanataAuthOptions,
|
|
28
|
+
type BanataAuthConfig,
|
|
29
|
+
} from "@banata-auth/convex";
|
|
30
|
+
import type { GenericCtx } from "@convex-dev/better-auth/utils";
|
|
31
|
+
import { components } from "../_generated/api";
|
|
32
|
+
import type { DataModel } from "../_generated/dataModel";
|
|
33
|
+
import authConfig from "../auth.config";
|
|
34
|
+
import schema from "./schema";
|
|
35
|
+
|
|
36
|
+
export const authComponent = createBanataAuthComponent(components.banataAuth, schema);
|
|
37
|
+
|
|
38
|
+
function getConfig(): BanataAuthConfig {
|
|
39
|
+
return {
|
|
40
|
+
appName: "My App",
|
|
41
|
+
siteUrl: process.env.SITE_URL!,
|
|
42
|
+
secret: process.env.BETTER_AUTH_SECRET!,
|
|
43
|
+
authMethods: {
|
|
44
|
+
emailPassword: true,
|
|
45
|
+
organization: true,
|
|
46
|
+
},
|
|
47
|
+
email: {
|
|
48
|
+
sendVerificationEmail: async ({ email, url }) => { /* ... */ },
|
|
49
|
+
sendResetPassword: async ({ email, url }) => { /* ... */ },
|
|
50
|
+
},
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
export const createAuthOptions = (ctx: GenericCtx<DataModel>) =>
|
|
55
|
+
createBanataAuthOptions(ctx, {
|
|
56
|
+
authComponent,
|
|
57
|
+
authConfig,
|
|
58
|
+
config: getConfig(),
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
export const createAuth = (ctx: GenericCtx<DataModel>) =>
|
|
62
|
+
createBanataAuth(ctx, {
|
|
63
|
+
authComponent,
|
|
64
|
+
authConfig,
|
|
65
|
+
config: getConfig(),
|
|
66
|
+
});
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
### 3. Register HTTP routes
|
|
70
|
+
|
|
71
|
+
```ts
|
|
72
|
+
// convex/http.ts
|
|
73
|
+
import { httpRouter } from "convex/server";
|
|
74
|
+
import { authComponent, createAuth } from "./banataAuth/auth";
|
|
75
|
+
|
|
76
|
+
const http = httpRouter();
|
|
77
|
+
authComponent.registerRoutes(http, createAuth);
|
|
78
|
+
export default http;
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
### 4. Register triggers (optional)
|
|
82
|
+
|
|
83
|
+
```ts
|
|
84
|
+
import { defineBanataAuthTriggers } from "@banata-auth/convex";
|
|
85
|
+
|
|
86
|
+
export const triggers = defineBanataAuthTriggers({
|
|
87
|
+
onUserCreated: async (ctx, user) => {
|
|
88
|
+
console.log("New user:", user.email);
|
|
89
|
+
},
|
|
90
|
+
});
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
## Features
|
|
94
|
+
|
|
95
|
+
- Better Auth factory with sensible defaults
|
|
96
|
+
- Dashboard config, audit log, and webhook plugins
|
|
97
|
+
- Email template plugin with block-based editor support, template CRUD, and HTML rendering
|
|
98
|
+
- Lifecycle trigger system for user/session/org events
|
|
99
|
+
- Pre-built Convex schema for all auth tables (35 tables)
|
|
100
|
+
- Multi-tenant project isolation with `projectId` scoping
|
|
101
|
+
|
|
102
|
+
## License
|
|
103
|
+
|
|
104
|
+
MIT
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Convex auth configuration provider for JWT validation.
|
|
3
|
+
*
|
|
4
|
+
* This tells Convex how to validate JWTs issued by Better Auth
|
|
5
|
+
* using the JWKS endpoint exposed by the component.
|
|
6
|
+
*
|
|
7
|
+
* Usage in consumer's convex/auth.config.ts:
|
|
8
|
+
*
|
|
9
|
+
* ```ts
|
|
10
|
+
* import { getAuthConfigProvider } from "@banata-auth/convex/auth-config";
|
|
11
|
+
* import type { AuthConfig } from "convex/server";
|
|
12
|
+
*
|
|
13
|
+
* export default {
|
|
14
|
+
* providers: [getAuthConfigProvider()],
|
|
15
|
+
* } satisfies AuthConfig;
|
|
16
|
+
* ```
|
|
17
|
+
*
|
|
18
|
+
* We re-export the official function from @convex-dev/better-auth
|
|
19
|
+
* and also provide our own version as a fallback.
|
|
20
|
+
*/
|
|
21
|
+
export { getAuthConfigProvider } from "@convex-dev/better-auth/auth-config";
|
|
22
|
+
//# sourceMappingURL=auth-config.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"auth-config.d.ts","sourceRoot":"","sources":["../src/auth-config.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAGH,OAAO,EAAE,qBAAqB,EAAE,MAAM,qCAAqC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","file":"auth-config.js","sourcesContent":[]}
|
package/dist/auth.d.ts
ADDED
|
@@ -0,0 +1,462 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Banata Auth Convex integration — core auth instance factory.
|
|
3
|
+
*
|
|
4
|
+
* This module provides factory functions to wire Better Auth with Convex,
|
|
5
|
+
* pre-configured with all plugins needed for WorkOS-equivalent functionality.
|
|
6
|
+
*
|
|
7
|
+
* Architecture:
|
|
8
|
+
* - `@convex-dev/better-auth` bridges Better Auth to Convex's document DB
|
|
9
|
+
* - `createClient()` creates the component client with the DB adapter
|
|
10
|
+
* - `betterAuth()` is configured with all Phase 1 plugins
|
|
11
|
+
* - HTTP routes are registered on Convex's httpRouter
|
|
12
|
+
* - JWTs are signed with RS256 keys stored in the jwks table
|
|
13
|
+
* - Convex validates JWTs via the JWKS endpoint
|
|
14
|
+
*
|
|
15
|
+
* Usage in consumer's convex/ directory:
|
|
16
|
+
*
|
|
17
|
+
* ```ts
|
|
18
|
+
* // convex/banataAuth/auth.ts
|
|
19
|
+
* import { createBanataAuthComponent, createBanataAuthOptions, createBanataAuth } from "@banata-auth/convex";
|
|
20
|
+
* import { components } from "../_generated/api";
|
|
21
|
+
* import type { DataModel } from "../_generated/dataModel";
|
|
22
|
+
* import authConfig from "../auth.config";
|
|
23
|
+
* import schema from "./schema";
|
|
24
|
+
*
|
|
25
|
+
* export const authComponent = createBanataAuthComponent(components.banataAuth, schema);
|
|
26
|
+
*
|
|
27
|
+
* export const createAuthOptions = (ctx: GenericCtx<DataModel>) =>
|
|
28
|
+
* createBanataAuthOptions(ctx, {
|
|
29
|
+
* authComponent,
|
|
30
|
+
* authConfig,
|
|
31
|
+
* siteUrl: process.env.SITE_URL!,
|
|
32
|
+
* secret: process.env.BETTER_AUTH_SECRET!,
|
|
33
|
+
* });
|
|
34
|
+
*
|
|
35
|
+
* export const createAuth = (ctx: GenericCtx<DataModel>) =>
|
|
36
|
+
* createBanataAuth(ctx, { authComponent, authConfig, config: { ... } });
|
|
37
|
+
* ```
|
|
38
|
+
*/
|
|
39
|
+
import { createClient } from "@convex-dev/better-auth";
|
|
40
|
+
import type { GenericCtx } from "@convex-dev/better-auth/utils";
|
|
41
|
+
import type { BetterAuthOptions } from "better-auth";
|
|
42
|
+
import type { AuthConfig, FunctionReference, GenericDataModel, GenericSchema, SchemaDefinition } from "convex/server";
|
|
43
|
+
import { type BanataEmailOptions } from "./plugins/email";
|
|
44
|
+
import { type BanataProtectionOptions } from "./plugins/protection";
|
|
45
|
+
interface BanataAuthComponentApi {
|
|
46
|
+
adapter: {
|
|
47
|
+
create: FunctionReference<"mutation", "internal">;
|
|
48
|
+
findOne: FunctionReference<"query", "internal">;
|
|
49
|
+
findMany: FunctionReference<"query", "internal">;
|
|
50
|
+
updateOne: FunctionReference<"mutation", "internal">;
|
|
51
|
+
updateMany: FunctionReference<"mutation", "internal">;
|
|
52
|
+
deleteOne: FunctionReference<"mutation", "internal">;
|
|
53
|
+
deleteMany: FunctionReference<"mutation", "internal">;
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Configuration for email callbacks used by various auth methods.
|
|
58
|
+
*/
|
|
59
|
+
export interface BanataAuthEmailConfig {
|
|
60
|
+
/** Send email verification link to new users. */
|
|
61
|
+
sendVerificationEmail?: (params: {
|
|
62
|
+
user: {
|
|
63
|
+
email: string;
|
|
64
|
+
name: string;
|
|
65
|
+
};
|
|
66
|
+
url: string;
|
|
67
|
+
token: string;
|
|
68
|
+
}) => Promise<void>;
|
|
69
|
+
/** Send password reset link. */
|
|
70
|
+
sendResetPassword?: (params: {
|
|
71
|
+
user: {
|
|
72
|
+
email: string;
|
|
73
|
+
name: string;
|
|
74
|
+
};
|
|
75
|
+
url: string;
|
|
76
|
+
token: string;
|
|
77
|
+
}) => Promise<void>;
|
|
78
|
+
/** Send magic link for passwordless sign-in. */
|
|
79
|
+
sendMagicLink?: (params: {
|
|
80
|
+
email: string;
|
|
81
|
+
url: string;
|
|
82
|
+
token: string;
|
|
83
|
+
}) => Promise<void>;
|
|
84
|
+
/** Send one-time password for email OTP auth. */
|
|
85
|
+
sendOtp?: (params: {
|
|
86
|
+
email: string;
|
|
87
|
+
otp: string;
|
|
88
|
+
}) => Promise<void>;
|
|
89
|
+
/**
|
|
90
|
+
* Send organization invitation email.
|
|
91
|
+
* Note: The invitation ID is provided instead of a URL.
|
|
92
|
+
* The consumer constructs the accept URL from the ID.
|
|
93
|
+
*/
|
|
94
|
+
sendInvitationEmail?: (params: {
|
|
95
|
+
email: string;
|
|
96
|
+
invitationId: string;
|
|
97
|
+
organizationName: string;
|
|
98
|
+
inviterName: string;
|
|
99
|
+
}) => Promise<void>;
|
|
100
|
+
/** Send domain verification email. */
|
|
101
|
+
sendDomainVerification?: (params: {
|
|
102
|
+
email: string;
|
|
103
|
+
domain: string;
|
|
104
|
+
verificationToken: string;
|
|
105
|
+
}) => Promise<void>;
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* Social provider credentials.
|
|
109
|
+
*/
|
|
110
|
+
export interface SocialProviderConfig {
|
|
111
|
+
clientId: string;
|
|
112
|
+
clientSecret: string;
|
|
113
|
+
enabled?: boolean;
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* Supported social providers and their config shapes.
|
|
117
|
+
* Matches a subset of BetterAuthOptions["socialProviders"] keys.
|
|
118
|
+
*/
|
|
119
|
+
export interface BanataAuthSocialProviders {
|
|
120
|
+
google?: SocialProviderConfig;
|
|
121
|
+
github?: SocialProviderConfig;
|
|
122
|
+
microsoft?: SocialProviderConfig & {
|
|
123
|
+
tenantId?: string;
|
|
124
|
+
};
|
|
125
|
+
apple?: SocialProviderConfig;
|
|
126
|
+
discord?: SocialProviderConfig;
|
|
127
|
+
facebook?: SocialProviderConfig;
|
|
128
|
+
twitter?: SocialProviderConfig;
|
|
129
|
+
linkedin?: SocialProviderConfig;
|
|
130
|
+
gitlab?: SocialProviderConfig;
|
|
131
|
+
slack?: SocialProviderConfig;
|
|
132
|
+
}
|
|
133
|
+
/**
|
|
134
|
+
* Configuration for the Banata Auth instance.
|
|
135
|
+
*/
|
|
136
|
+
export interface BanataAuthConfig {
|
|
137
|
+
/** App name displayed in emails and OAuth consent screens. */
|
|
138
|
+
appName?: string;
|
|
139
|
+
/**
|
|
140
|
+
* Site URL — your application's public URL.
|
|
141
|
+
* Used as Better Auth's `baseURL` for OAuth callbacks and email links.
|
|
142
|
+
* Typically `process.env.SITE_URL` (e.g., "http://localhost:3000").
|
|
143
|
+
*
|
|
144
|
+
* The Next.js route handler at `/api/auth/[...all]` proxies auth
|
|
145
|
+
* requests to Convex, so OAuth providers redirect to this URL and
|
|
146
|
+
* the proxy forwards the callback to Convex for processing.
|
|
147
|
+
*/
|
|
148
|
+
siteUrl: string;
|
|
149
|
+
/**
|
|
150
|
+
* Better Auth secret for signing/encryption.
|
|
151
|
+
* Typically process.env.BETTER_AUTH_SECRET.
|
|
152
|
+
*/
|
|
153
|
+
secret: string;
|
|
154
|
+
/** Social providers configuration (object, not array). */
|
|
155
|
+
socialProviders?: BanataAuthSocialProviders;
|
|
156
|
+
/** Email callback configuration (optional overrides). */
|
|
157
|
+
email?: BanataAuthEmailConfig;
|
|
158
|
+
/**
|
|
159
|
+
* Built-in email sending options.
|
|
160
|
+
*
|
|
161
|
+
* When an email provider is configured through the dashboard, emails
|
|
162
|
+
* are sent automatically on auth events (verification, password reset,
|
|
163
|
+
* magic link, OTP, invitation). No consumer callbacks needed.
|
|
164
|
+
*
|
|
165
|
+
* Consumer-provided callbacks in `email` still take priority.
|
|
166
|
+
*/
|
|
167
|
+
emailOptions?: BanataEmailOptions;
|
|
168
|
+
/**
|
|
169
|
+
* Enable/disable specific auth methods.
|
|
170
|
+
* All default to true unless explicitly set to false.
|
|
171
|
+
*/
|
|
172
|
+
authMethods?: {
|
|
173
|
+
emailPassword?: boolean;
|
|
174
|
+
magicLink?: boolean;
|
|
175
|
+
emailOtp?: boolean;
|
|
176
|
+
passkey?: boolean;
|
|
177
|
+
twoFactor?: boolean;
|
|
178
|
+
anonymous?: boolean;
|
|
179
|
+
username?: boolean;
|
|
180
|
+
multiSession?: boolean;
|
|
181
|
+
organization?: boolean;
|
|
182
|
+
sso?: boolean;
|
|
183
|
+
scim?: boolean;
|
|
184
|
+
apiKey?: boolean;
|
|
185
|
+
};
|
|
186
|
+
/**
|
|
187
|
+
* Passkey (WebAuthn) configuration.
|
|
188
|
+
* Required if authMethods.passkey is enabled.
|
|
189
|
+
*/
|
|
190
|
+
passkey?: {
|
|
191
|
+
rpId: string;
|
|
192
|
+
rpName: string;
|
|
193
|
+
origin: string;
|
|
194
|
+
};
|
|
195
|
+
/**
|
|
196
|
+
* Organization plugin configuration.
|
|
197
|
+
*/
|
|
198
|
+
organizationConfig?: {
|
|
199
|
+
/** Allow users to create organizations (default: true). */
|
|
200
|
+
allowUserToCreateOrg?: boolean;
|
|
201
|
+
/** Creator role when a user creates an org (default: "owner"). */
|
|
202
|
+
creatorRole?: string;
|
|
203
|
+
/** Maximum organizations a user can create. */
|
|
204
|
+
maxOrganizations?: number;
|
|
205
|
+
};
|
|
206
|
+
/** SSO plugin configuration. */
|
|
207
|
+
ssoConfig?: {
|
|
208
|
+
/** Issuer URL for SAML SP entity ID construction. */
|
|
209
|
+
issuer?: string;
|
|
210
|
+
/** Enable domain verification for SSO connections. */
|
|
211
|
+
domainVerification?: boolean;
|
|
212
|
+
/** Default organization provisioning behavior. */
|
|
213
|
+
provisionOrganization?: boolean;
|
|
214
|
+
};
|
|
215
|
+
/** SCIM plugin configuration. */
|
|
216
|
+
scimConfig?: {
|
|
217
|
+
/** Default role for SCIM-provisioned users. */
|
|
218
|
+
defaultRole?: string;
|
|
219
|
+
/** Whether to auto-create organizations from SCIM groups. */
|
|
220
|
+
autoCreateOrganizations?: boolean;
|
|
221
|
+
};
|
|
222
|
+
/** API Key plugin configuration. */
|
|
223
|
+
apiKeyConfig?: {
|
|
224
|
+
/** API key prefix (e.g., "sk_live"). */
|
|
225
|
+
prefix?: string;
|
|
226
|
+
/** Default API key expiration in seconds. */
|
|
227
|
+
defaultExpiresIn?: number;
|
|
228
|
+
};
|
|
229
|
+
/**
|
|
230
|
+
* Bot protection configuration.
|
|
231
|
+
*
|
|
232
|
+
* When configured, Banata Auth intercepts requests to sensitive auth
|
|
233
|
+
* endpoints (sign-in, sign-up, password reset) and verifies them using
|
|
234
|
+
* the provided `verifyRequest` function before any auth processing occurs.
|
|
235
|
+
*
|
|
236
|
+
* This is provider-agnostic — implement `verifyRequest` with Vercel BotID,
|
|
237
|
+
* Cloudflare Turnstile, hCaptcha, reCAPTCHA, or any other service.
|
|
238
|
+
*
|
|
239
|
+
* @example
|
|
240
|
+
* ```ts
|
|
241
|
+
* protection: {
|
|
242
|
+
* enabled: true,
|
|
243
|
+
* verifyRequest: async (request) => {
|
|
244
|
+
* const result = await checkBotId();
|
|
245
|
+
* return { isBot: result.isBot };
|
|
246
|
+
* },
|
|
247
|
+
* },
|
|
248
|
+
* ```
|
|
249
|
+
*/
|
|
250
|
+
protection?: BanataProtectionOptions;
|
|
251
|
+
/** Lifecycle trigger handlers. */
|
|
252
|
+
triggers?: import("./triggers").BanataAuthTriggers;
|
|
253
|
+
/**
|
|
254
|
+
* Trusted origins for CSRF/origin validation.
|
|
255
|
+
*
|
|
256
|
+
* Better Auth validates the `Origin` header on cookie-bearing requests.
|
|
257
|
+
* By default, only `siteUrl` is trusted. In development, the Next.js
|
|
258
|
+
* proxy may run on a different port (e.g. `http://localhost:3002`)
|
|
259
|
+
* and forward the browser's `Origin` header, causing a 403.
|
|
260
|
+
*
|
|
261
|
+
* Add all origins your dashboard/app may run on:
|
|
262
|
+
* ```ts
|
|
263
|
+
* trustedOrigins: ["http://localhost:3000", "http://localhost:3002"]
|
|
264
|
+
* ```
|
|
265
|
+
*/
|
|
266
|
+
trustedOrigins?: string[];
|
|
267
|
+
/**
|
|
268
|
+
* Additional Better Auth options to merge.
|
|
269
|
+
* Use this for advanced configuration not covered by the typed config.
|
|
270
|
+
*/
|
|
271
|
+
advanced?: Partial<BetterAuthOptions>;
|
|
272
|
+
}
|
|
273
|
+
/**
|
|
274
|
+
* Re-export Convex's AuthConfig for convenience.
|
|
275
|
+
* This is the type consumers use in `convex/auth.config.ts`.
|
|
276
|
+
*/
|
|
277
|
+
export type { AuthConfig as BanataAuthConvexAuthConfig } from "convex/server";
|
|
278
|
+
/** The return type of `createClient` with GenericDataModel defaults. */
|
|
279
|
+
type ComponentClient = ReturnType<typeof createClient>;
|
|
280
|
+
/**
|
|
281
|
+
* Create the Better Auth Convex component client.
|
|
282
|
+
*
|
|
283
|
+
* This bridges `@convex-dev/better-auth` to your Convex component,
|
|
284
|
+
* providing the database adapter and HTTP route registration.
|
|
285
|
+
*
|
|
286
|
+
* @param componentRef - The component reference from `components.banataAuth`
|
|
287
|
+
* @param schema - The component schema definition
|
|
288
|
+
* @param options - Optional client options
|
|
289
|
+
* @returns The component client with adapter and registerRoutes
|
|
290
|
+
*
|
|
291
|
+
* @example
|
|
292
|
+
* ```ts
|
|
293
|
+
* import { createBanataAuthComponent } from "@banata-auth/convex";
|
|
294
|
+
* import { components } from "../_generated/api";
|
|
295
|
+
* import schema from "./schema";
|
|
296
|
+
*
|
|
297
|
+
* export const authComponent = createBanataAuthComponent(
|
|
298
|
+
* components.banataAuth,
|
|
299
|
+
* schema,
|
|
300
|
+
* );
|
|
301
|
+
* ```
|
|
302
|
+
*/
|
|
303
|
+
export declare function createBanataAuthComponent<TDataModel extends GenericDataModel, TSchema extends SchemaDefinition<GenericSchema, true>>(componentRef: BanataAuthComponentApi, schema: TSchema, options?: {
|
|
304
|
+
verbose?: boolean;
|
|
305
|
+
}): {
|
|
306
|
+
adapter: (ctx: GenericCtx<TDataModel>) => import("better-auth/adapters").AdapterFactory;
|
|
307
|
+
getAuth: <T extends import("@convex-dev/better-auth").CreateAuth<TDataModel>>(createAuth: T, ctx: GenericCtx<TDataModel>) => Promise<{
|
|
308
|
+
auth: ReturnType<T>;
|
|
309
|
+
headers: Headers;
|
|
310
|
+
}>;
|
|
311
|
+
getHeaders: (ctx: GenericCtx<TDataModel>) => Promise<Headers>;
|
|
312
|
+
safeGetAuthUser: (ctx: GenericCtx<TDataModel>) => Promise<(TSchema["strictTableNameTypes"] extends infer T ? T extends TSchema["strictTableNameTypes"] ? T extends true ? { [TableName in keyof TSchema["tables"] & string]: TSchema["tables"][TableName] extends import("convex/server").TableDefinition<infer DocumentType extends import("convex/values").Validator<any, any, any>, infer Indexes extends import("convex/server").GenericTableIndexes, infer SearchIndexes extends import("convex/server").GenericTableSearchIndexes, infer VectorIndexes extends import("convex/server").GenericTableVectorIndexes> ? {
|
|
313
|
+
document: import("convex/server").Expand<import("convex/server").IdField<TableName> & import("convex/server").Expand<import("convex/server").SystemFields & DocumentType["type"]>>;
|
|
314
|
+
fieldPaths: keyof import("convex/server").IdField<TableName_1> | ("_creationTime" | DocumentType["fieldPaths"]);
|
|
315
|
+
indexes: import("convex/server").Expand<Indexes & import("convex/server").SystemIndexes>;
|
|
316
|
+
searchIndexes: SearchIndexes;
|
|
317
|
+
vectorIndexes: VectorIndexes;
|
|
318
|
+
} : never; } : import("convex/server").Expand<{ [TableName in keyof TSchema["tables"] & string]: TSchema["tables"][TableName] extends import("convex/server").TableDefinition<infer DocumentType extends import("convex/values").Validator<any, any, any>, infer Indexes extends import("convex/server").GenericTableIndexes, infer SearchIndexes extends import("convex/server").GenericTableSearchIndexes, infer VectorIndexes extends import("convex/server").GenericTableVectorIndexes> ? {
|
|
319
|
+
document: import("convex/server").Expand<import("convex/server").IdField<TableName> & import("convex/server").Expand<import("convex/server").SystemFields & DocumentType["type"]>>;
|
|
320
|
+
fieldPaths: keyof import("convex/server").IdField<TableName_1> | ("_creationTime" | DocumentType["fieldPaths"]);
|
|
321
|
+
indexes: import("convex/server").Expand<Indexes & import("convex/server").SystemIndexes>;
|
|
322
|
+
searchIndexes: SearchIndexes;
|
|
323
|
+
vectorIndexes: VectorIndexes;
|
|
324
|
+
} : never; } & import("convex/server").AnyDataModel> : never : never)["user"]["document"] | undefined>;
|
|
325
|
+
getAuthUser: (ctx: GenericCtx<TDataModel>) => Promise<(TSchema["strictTableNameTypes"] extends infer T ? T extends TSchema["strictTableNameTypes"] ? T extends true ? { [TableName in keyof TSchema["tables"] & string]: TSchema["tables"][TableName] extends import("convex/server").TableDefinition<infer DocumentType extends import("convex/values").Validator<any, any, any>, infer Indexes extends import("convex/server").GenericTableIndexes, infer SearchIndexes extends import("convex/server").GenericTableSearchIndexes, infer VectorIndexes extends import("convex/server").GenericTableVectorIndexes> ? {
|
|
326
|
+
document: import("convex/server").Expand<import("convex/server").IdField<TableName> & import("convex/server").Expand<import("convex/server").SystemFields & DocumentType["type"]>>;
|
|
327
|
+
fieldPaths: keyof import("convex/server").IdField<TableName_1> | ("_creationTime" | DocumentType["fieldPaths"]);
|
|
328
|
+
indexes: import("convex/server").Expand<Indexes & import("convex/server").SystemIndexes>;
|
|
329
|
+
searchIndexes: SearchIndexes;
|
|
330
|
+
vectorIndexes: VectorIndexes;
|
|
331
|
+
} : never; } : import("convex/server").Expand<{ [TableName in keyof TSchema["tables"] & string]: TSchema["tables"][TableName] extends import("convex/server").TableDefinition<infer DocumentType extends import("convex/values").Validator<any, any, any>, infer Indexes extends import("convex/server").GenericTableIndexes, infer SearchIndexes extends import("convex/server").GenericTableSearchIndexes, infer VectorIndexes extends import("convex/server").GenericTableVectorIndexes> ? {
|
|
332
|
+
document: import("convex/server").Expand<import("convex/server").IdField<TableName> & import("convex/server").Expand<import("convex/server").SystemFields & DocumentType["type"]>>;
|
|
333
|
+
fieldPaths: keyof import("convex/server").IdField<TableName_1> | ("_creationTime" | DocumentType["fieldPaths"]);
|
|
334
|
+
indexes: import("convex/server").Expand<Indexes & import("convex/server").SystemIndexes>;
|
|
335
|
+
searchIndexes: SearchIndexes;
|
|
336
|
+
vectorIndexes: VectorIndexes;
|
|
337
|
+
} : never; } & import("convex/server").AnyDataModel> : never : never)["user"]["document"]>;
|
|
338
|
+
getAnyUserById: (ctx: GenericCtx<TDataModel>, id: string) => Promise<(TSchema["strictTableNameTypes"] extends infer T ? T extends TSchema["strictTableNameTypes"] ? T extends true ? { [TableName in keyof TSchema["tables"] & string]: TSchema["tables"][TableName] extends import("convex/server").TableDefinition<infer DocumentType extends import("convex/values").Validator<any, any, any>, infer Indexes extends import("convex/server").GenericTableIndexes, infer SearchIndexes extends import("convex/server").GenericTableSearchIndexes, infer VectorIndexes extends import("convex/server").GenericTableVectorIndexes> ? {
|
|
339
|
+
document: import("convex/server").Expand<import("convex/server").IdField<TableName> & import("convex/server").Expand<import("convex/server").SystemFields & DocumentType["type"]>>;
|
|
340
|
+
fieldPaths: keyof import("convex/server").IdField<TableName_1> | ("_creationTime" | DocumentType["fieldPaths"]);
|
|
341
|
+
indexes: import("convex/server").Expand<Indexes & import("convex/server").SystemIndexes>;
|
|
342
|
+
searchIndexes: SearchIndexes;
|
|
343
|
+
vectorIndexes: VectorIndexes;
|
|
344
|
+
} : never; } : import("convex/server").Expand<{ [TableName in keyof TSchema["tables"] & string]: TSchema["tables"][TableName] extends import("convex/server").TableDefinition<infer DocumentType extends import("convex/values").Validator<any, any, any>, infer Indexes extends import("convex/server").GenericTableIndexes, infer SearchIndexes extends import("convex/server").GenericTableSearchIndexes, infer VectorIndexes extends import("convex/server").GenericTableVectorIndexes> ? {
|
|
345
|
+
document: import("convex/server").Expand<import("convex/server").IdField<TableName> & import("convex/server").Expand<import("convex/server").SystemFields & DocumentType["type"]>>;
|
|
346
|
+
fieldPaths: keyof import("convex/server").IdField<TableName_1> | ("_creationTime" | DocumentType["fieldPaths"]);
|
|
347
|
+
indexes: import("convex/server").Expand<Indexes & import("convex/server").SystemIndexes>;
|
|
348
|
+
searchIndexes: SearchIndexes;
|
|
349
|
+
vectorIndexes: VectorIndexes;
|
|
350
|
+
} : never; } & import("convex/server").AnyDataModel> : never : never)["user"]["document"] | null>;
|
|
351
|
+
setUserId: (ctx: import("convex/server").GenericMutationCtx<TDataModel>, authId: string, userId: string) => Promise<void>;
|
|
352
|
+
clientApi: () => {
|
|
353
|
+
getAuthUser: import("convex/server").RegisteredQuery<"public", {}, Promise<(TSchema["strictTableNameTypes"] extends infer T ? T extends TSchema["strictTableNameTypes"] ? T extends true ? { [TableName in keyof TSchema["tables"] & string]: TSchema["tables"][TableName] extends import("convex/server").TableDefinition<infer DocumentType extends import("convex/values").Validator<any, any, any>, infer Indexes extends import("convex/server").GenericTableIndexes, infer SearchIndexes extends import("convex/server").GenericTableSearchIndexes, infer VectorIndexes extends import("convex/server").GenericTableVectorIndexes> ? {
|
|
354
|
+
document: import("convex/server").Expand<import("convex/server").IdField<TableName> & import("convex/server").Expand<import("convex/server").SystemFields & DocumentType["type"]>>;
|
|
355
|
+
fieldPaths: keyof import("convex/server").IdField<TableName_1> | ("_creationTime" | DocumentType["fieldPaths"]);
|
|
356
|
+
indexes: import("convex/server").Expand<Indexes & import("convex/server").SystemIndexes>;
|
|
357
|
+
searchIndexes: SearchIndexes;
|
|
358
|
+
vectorIndexes: VectorIndexes;
|
|
359
|
+
} : never; } : import("convex/server").Expand<{ [TableName in keyof TSchema["tables"] & string]: TSchema["tables"][TableName] extends import("convex/server").TableDefinition<infer DocumentType extends import("convex/values").Validator<any, any, any>, infer Indexes extends import("convex/server").GenericTableIndexes, infer SearchIndexes extends import("convex/server").GenericTableSearchIndexes, infer VectorIndexes extends import("convex/server").GenericTableVectorIndexes> ? {
|
|
360
|
+
document: import("convex/server").Expand<import("convex/server").IdField<TableName> & import("convex/server").Expand<import("convex/server").SystemFields & DocumentType["type"]>>;
|
|
361
|
+
fieldPaths: keyof import("convex/server").IdField<TableName_1> | ("_creationTime" | DocumentType["fieldPaths"]);
|
|
362
|
+
indexes: import("convex/server").Expand<Indexes & import("convex/server").SystemIndexes>;
|
|
363
|
+
searchIndexes: SearchIndexes;
|
|
364
|
+
vectorIndexes: VectorIndexes;
|
|
365
|
+
} : never; } & import("convex/server").AnyDataModel> : never : never)["user"]["document"]>>;
|
|
366
|
+
};
|
|
367
|
+
triggersApi: () => {
|
|
368
|
+
onCreate: import("convex/server").RegisteredMutation<"internal", {
|
|
369
|
+
model: string;
|
|
370
|
+
doc: any;
|
|
371
|
+
}, Promise<void>>;
|
|
372
|
+
onUpdate: import("convex/server").RegisteredMutation<"internal", {
|
|
373
|
+
model: string;
|
|
374
|
+
oldDoc: any;
|
|
375
|
+
newDoc: any;
|
|
376
|
+
}, Promise<void>>;
|
|
377
|
+
onDelete: import("convex/server").RegisteredMutation<"internal", {
|
|
378
|
+
model: string;
|
|
379
|
+
doc: any;
|
|
380
|
+
}, Promise<void>>;
|
|
381
|
+
};
|
|
382
|
+
registerRoutes: (http: import("convex/server").HttpRouter, createAuth: import("@convex-dev/better-auth").CreateAuth<TDataModel>, opts?: {
|
|
383
|
+
cors?: boolean | {
|
|
384
|
+
allowedOrigins?: string[];
|
|
385
|
+
allowedHeaders?: string[];
|
|
386
|
+
exposedHeaders?: string[];
|
|
387
|
+
};
|
|
388
|
+
}) => void;
|
|
389
|
+
};
|
|
390
|
+
/**
|
|
391
|
+
* Build the Better Auth options object from Banata Auth config.
|
|
392
|
+
*
|
|
393
|
+
* This configures all Phase 1 plugins and returns a BetterAuthOptions
|
|
394
|
+
* that can be passed to `betterAuth()`. The Convex database adapter
|
|
395
|
+
* is injected from the component client.
|
|
396
|
+
*
|
|
397
|
+
* @param ctx - Convex function context
|
|
398
|
+
* @param params - Configuration parameters
|
|
399
|
+
* @returns BetterAuthOptions ready for `betterAuth()`
|
|
400
|
+
*
|
|
401
|
+
* @example
|
|
402
|
+
* ```ts
|
|
403
|
+
* export const createAuthOptions = (ctx: GenericCtx<DataModel>) =>
|
|
404
|
+
* createBanataAuthOptions(ctx, {
|
|
405
|
+
* authComponent,
|
|
406
|
+
* authConfig,
|
|
407
|
+
* config: {
|
|
408
|
+
* siteUrl: process.env.SITE_URL!,
|
|
409
|
+
* secret: process.env.BETTER_AUTH_SECRET!,
|
|
410
|
+
* socialProviders: { github: { clientId: "...", clientSecret: "..." } },
|
|
411
|
+
* },
|
|
412
|
+
* });
|
|
413
|
+
* ```
|
|
414
|
+
*/
|
|
415
|
+
export declare function createBanataAuthOptions(ctx: GenericCtx<GenericDataModel>, params: {
|
|
416
|
+
authComponent: ComponentClient;
|
|
417
|
+
authConfig: AuthConfig;
|
|
418
|
+
config: BanataAuthConfig;
|
|
419
|
+
}): BetterAuthOptions;
|
|
420
|
+
/**
|
|
421
|
+
* Create the Better Auth instance for a given Convex context.
|
|
422
|
+
*
|
|
423
|
+
* This is the main factory function that creates a fully configured
|
|
424
|
+
* Better Auth instance ready to handle auth requests.
|
|
425
|
+
*
|
|
426
|
+
* @param ctx - Convex function context
|
|
427
|
+
* @param params - Same params as createBanataAuthOptions
|
|
428
|
+
* @returns A Better Auth instance
|
|
429
|
+
*
|
|
430
|
+
* @example
|
|
431
|
+
* ```ts
|
|
432
|
+
* export const createAuth = (ctx: GenericCtx<DataModel>) =>
|
|
433
|
+
* createBanataAuth(ctx, {
|
|
434
|
+
* authComponent,
|
|
435
|
+
* authConfig,
|
|
436
|
+
* config: { siteUrl: "...", secret: "..." },
|
|
437
|
+
* });
|
|
438
|
+
* ```
|
|
439
|
+
*/
|
|
440
|
+
export declare function createBanataAuth(ctx: GenericCtx<GenericDataModel>, params: {
|
|
441
|
+
authComponent: ComponentClient;
|
|
442
|
+
authConfig: AuthConfig;
|
|
443
|
+
config: BanataAuthConfig;
|
|
444
|
+
}): import("better-auth").Auth<BetterAuthOptions>;
|
|
445
|
+
/**
|
|
446
|
+
* Helper to create the static auth options for schema generation.
|
|
447
|
+
*
|
|
448
|
+
* The `npx auth generate` CLI needs a static options object (not bound to
|
|
449
|
+
* a Convex context). This creates one with a dummy adapter.
|
|
450
|
+
*
|
|
451
|
+
* @example
|
|
452
|
+
* ```ts
|
|
453
|
+
* // For CLI: npx auth generate --config ./convex/banataAuth/auth.ts
|
|
454
|
+
* export const options = createBanataAuthStaticOptions({ ... });
|
|
455
|
+
* ```
|
|
456
|
+
*/
|
|
457
|
+
export declare function createBanataAuthStaticOptions(params: {
|
|
458
|
+
authComponent: ComponentClient;
|
|
459
|
+
authConfig: AuthConfig;
|
|
460
|
+
config: BanataAuthConfig;
|
|
461
|
+
}): BetterAuthOptions;
|
|
462
|
+
//# sourceMappingURL=auth.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"auth.d.ts","sourceRoot":"","sources":["../src/auth.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqCG;AAOH,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AAEvD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,+BAA+B,CAAC;AAChE,OAAO,KAAK,EAAE,iBAAiB,EAAoB,MAAM,aAAa,CAAC;AAWvE,OAAO,KAAK,EACX,UAAU,EACV,iBAAiB,EACjB,gBAAgB,EAChB,aAAa,EACb,gBAAgB,EAChB,MAAM,eAAe,CAAC;AAKvB,OAAO,EAAE,KAAK,kBAAkB,EAAyC,MAAM,iBAAiB,CAAC;AAMjG,OAAO,EAAE,KAAK,uBAAuB,EAAoB,MAAM,sBAAsB,CAAC;AAStF,UAAU,sBAAsB;IAC/B,OAAO,EAAE;QACR,MAAM,EAAE,iBAAiB,CAAC,UAAU,EAAE,UAAU,CAAC,CAAC;QAClD,OAAO,EAAE,iBAAiB,CAAC,OAAO,EAAE,UAAU,CAAC,CAAC;QAChD,QAAQ,EAAE,iBAAiB,CAAC,OAAO,EAAE,UAAU,CAAC,CAAC;QACjD,SAAS,EAAE,iBAAiB,CAAC,UAAU,EAAE,UAAU,CAAC,CAAC;QACrD,UAAU,EAAE,iBAAiB,CAAC,UAAU,EAAE,UAAU,CAAC,CAAC;QACtD,SAAS,EAAE,iB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AAG,EAAE,UAAU,CAAC,gBAAgB,CAAC,EACjC,MAAM,EAAE;IACP,aAAa,EAAE,eAAe,CAAC;IAC/B,UAAU,EAAE,UAAU,CAAC;IACvB,MAAM,EAAE,gBAAgB,CAAC;CACzB,iDAGD;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,6BAA6B,CAAC,MAAM,EAAE;IACrD,aAAa,EAAE,eAAe,CAAC;IAC/B,UAAU,EAAE,UAAU,CAAC;IACvB,MAAM,EAAE,gBAAgB,CAAC;CACzB,qBAGA"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Re-export `createApi` from @convex-dev/better-auth for consumers.
|
|
3
|
+
*
|
|
4
|
+
* Per the Convex component pattern, consumers call `createApi` directly
|
|
5
|
+
* in their local `convex/banataAuth/adapter.ts` to generate the CRUD
|
|
6
|
+
* functions (create, findOne, findMany, updateOne, updateMany, deleteOne,
|
|
7
|
+
* deleteMany) needed by the component adapter.
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* ```ts
|
|
11
|
+
* // convex/banataAuth/adapter.ts
|
|
12
|
+
* import { createApi } from "@banata-auth/convex/adapter";
|
|
13
|
+
* import { createAuthOptions } from "./auth";
|
|
14
|
+
* import schema from "./schema";
|
|
15
|
+
*
|
|
16
|
+
* export const { create, findOne, findMany, updateOne, updateMany, deleteOne, deleteMany }
|
|
17
|
+
* = createApi(schema, createAuthOptions);
|
|
18
|
+
* ```
|
|
19
|
+
*/
|
|
20
|
+
export { createApi } from "@convex-dev/better-auth";
|
|
21
|
+
//# sourceMappingURL=adapter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"adapter.d.ts","sourceRoot":"","sources":["../../src/component/adapter.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,OAAO,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC"}
|