| 1 | import { createAuthPlugin } from "@better-auth-ui/core"; |
| 2 | import { |
| 3 | type ApiKeyPluginOptions, |
| 4 | apiKeyPlugin as coreApiKeyPlugin, |
| 5 | } from "@better-auth-ui/core/plugins/api-key"; |
| 6 | |
| 7 | import { ApiKeys } |
| 8 | import { OrganizationApiKeys } |
| 9 | |
| 10 | /** Ghost calls these personal access tokens - they authenticate git over HTTP. */ |
| 11 | const patLocalization: ApiKeyPluginOptions |
| 12 | apiKey: "Personal access token", |
| 13 | apiKeys: "Personal access tokens", |
| 14 | apiKeysDescription: |
| 15 | "Create a personal access token to push and pull repositories over HTTP.", |
| 16 | createApiKey: "Create token", |
| 17 | noApiKeys: "No personal access tokens", |
| 18 | newApiKey: "New personal access token", |
| 19 | newApiKeyWarning: |
| 20 | "This is the only time you'll see this token. Copy and store it somewhere safe.", |
| 21 | deleteApiKey: "Delete token", |
| 22 | deleteApiKeyWarning: |
| 23 | "This action cannot be undone. Any clone using this token will stop working immediately.", |
| 24 | dismissNewKey: "I've saved my token", |
| 25 | editApiKey: "Edit token", |
| 26 | }; |
| 27 | |
| 28 | export const apiKeyPlugin = |
| 29 | coreApiKeyPlugin.id, |
| 30 | (options: ApiKeyPluginOptions |
| 31 | const core = |
| 32 | ...options, |
| 33 | localization: { ...patLocalization |
| 34 | }); |
| 35 | |
| 36 | return { |
| 37 | ...core, |
| 38 | securityCards: [ApiKeys], |
| 39 | ...(core.organization |
| 40 | ? { organizationCards: [OrganizationApiKeys |
| 41 | : {}), |
| 42 | }; |
| 43 | }, |
| 44 | ); |