better-auth 1.4.18 → 1.4.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 (118) hide show
  1. package/dist/adapters/drizzle-adapter/drizzle-adapter.mjs +37 -5
  2. package/dist/adapters/drizzle-adapter/drizzle-adapter.mjs.map +1 -1
  3. package/dist/adapters/kysely-adapter/kysely-adapter.mjs +13 -3
  4. package/dist/adapters/kysely-adapter/kysely-adapter.mjs.map +1 -1
  5. package/dist/adapters/memory-adapter/memory-adapter.mjs +21 -17
  6. package/dist/adapters/memory-adapter/memory-adapter.mjs.map +1 -1
  7. package/dist/adapters/mongodb-adapter/mongodb-adapter.mjs +12 -1
  8. package/dist/adapters/mongodb-adapter/mongodb-adapter.mjs.map +1 -1
  9. package/dist/adapters/prisma-adapter/prisma-adapter.mjs +2 -2
  10. package/dist/adapters/prisma-adapter/prisma-adapter.mjs.map +1 -1
  11. package/dist/api/index.d.mts +407 -407
  12. package/dist/api/routes/account.d.mts +11 -11
  13. package/dist/api/routes/account.mjs +1 -1
  14. package/dist/api/routes/account.mjs.map +1 -1
  15. package/dist/api/routes/callback.d.mts +2 -2
  16. package/dist/api/routes/callback.mjs +1 -1
  17. package/dist/api/routes/callback.mjs.map +1 -1
  18. package/dist/api/routes/email-verification.d.mts +4 -4
  19. package/dist/api/routes/email-verification.mjs +1 -1
  20. package/dist/api/routes/email-verification.mjs.map +1 -1
  21. package/dist/api/routes/error.d.mts +2 -2
  22. package/dist/api/routes/ok.d.mts +2 -2
  23. package/dist/api/routes/password.d.mts +7 -7
  24. package/dist/api/routes/session.d.mts +14 -14
  25. package/dist/api/routes/sign-in.d.mts +4 -4
  26. package/dist/api/routes/sign-out.d.mts +2 -2
  27. package/dist/api/routes/sign-up.d.mts +3 -3
  28. package/dist/api/routes/update-user.d.mts +13 -13
  29. package/dist/api/routes/update-user.mjs +1 -1
  30. package/dist/api/routes/update-user.mjs.map +1 -1
  31. package/dist/client/react/index.d.mts +13 -13
  32. package/dist/client/svelte/index.d.mts +15 -15
  33. package/dist/client/vanilla.d.mts +15 -15
  34. package/dist/client/vue/index.d.mts +15 -15
  35. package/dist/context/create-context.mjs +1 -1
  36. package/dist/context/create-context.mjs.map +1 -1
  37. package/dist/cookies/index.d.mts +6 -6
  38. package/dist/cookies/index.mjs +5 -8
  39. package/dist/cookies/index.mjs.map +1 -1
  40. package/dist/db/field.d.mts +10 -10
  41. package/dist/db/field.mjs.map +1 -1
  42. package/dist/db/internal-adapter.mjs +1 -1
  43. package/dist/db/internal-adapter.mjs.map +1 -1
  44. package/dist/integrations/next-js.d.mts +4 -4
  45. package/dist/integrations/svelte-kit.d.mts +2 -2
  46. package/dist/integrations/tanstack-start-solid.d.mts +4 -4
  47. package/dist/integrations/tanstack-start.d.mts +4 -4
  48. package/dist/plugins/access/types.d.mts +1 -1
  49. package/dist/plugins/admin/admin.d.mts +114 -119
  50. package/dist/plugins/admin/admin.mjs +1 -1
  51. package/dist/plugins/admin/admin.mjs.map +1 -1
  52. package/dist/plugins/admin/routes.mjs +1 -1
  53. package/dist/plugins/admin/routes.mjs.map +1 -1
  54. package/dist/plugins/anonymous/index.d.mts +7 -7
  55. package/dist/plugins/api-key/index.d.mts +95 -80
  56. package/dist/plugins/api-key/routes/verify-api-key.mjs +1 -0
  57. package/dist/plugins/api-key/routes/verify-api-key.mjs.map +1 -1
  58. package/dist/plugins/bearer/index.d.mts +6 -6
  59. package/dist/plugins/captcha/index.d.mts +2 -2
  60. package/dist/plugins/custom-session/index.d.mts +5 -5
  61. package/dist/plugins/custom-session/index.mjs +13 -5
  62. package/dist/plugins/custom-session/index.mjs.map +1 -1
  63. package/dist/plugins/device-authorization/index.d.mts +6 -6
  64. package/dist/plugins/email-otp/index.d.mts +16 -16
  65. package/dist/plugins/email-otp/routes.mjs +1 -1
  66. package/dist/plugins/email-otp/routes.mjs.map +1 -1
  67. package/dist/plugins/generic-oauth/error-codes.mjs +3 -1
  68. package/dist/plugins/generic-oauth/error-codes.mjs.map +1 -1
  69. package/dist/plugins/generic-oauth/index.d.mts +32 -29
  70. package/dist/plugins/generic-oauth/index.mjs +8 -0
  71. package/dist/plugins/generic-oauth/index.mjs.map +1 -1
  72. package/dist/plugins/generic-oauth/routes.mjs +19 -2
  73. package/dist/plugins/generic-oauth/routes.mjs.map +1 -1
  74. package/dist/plugins/generic-oauth/types.d.mts +14 -0
  75. package/dist/plugins/haveibeenpwned/index.d.mts +3 -3
  76. package/dist/plugins/jwt/client.d.mts +2 -2
  77. package/dist/plugins/jwt/index.d.mts +9 -9
  78. package/dist/plugins/last-login-method/index.d.mts +4 -4
  79. package/dist/plugins/magic-link/index.d.mts +4 -4
  80. package/dist/plugins/mcp/authorize.mjs +1 -1
  81. package/dist/plugins/mcp/authorize.mjs.map +1 -1
  82. package/dist/plugins/mcp/index.d.mts +10 -10
  83. package/dist/plugins/multi-session/index.d.mts +9 -9
  84. package/dist/plugins/oauth-proxy/index.d.mts +8 -8
  85. package/dist/plugins/oidc-provider/authorize.mjs +1 -1
  86. package/dist/plugins/oidc-provider/authorize.mjs.map +1 -1
  87. package/dist/plugins/oidc-provider/index.d.mts +15 -15
  88. package/dist/plugins/one-tap/client.d.mts +5 -5
  89. package/dist/plugins/one-tap/index.d.mts +2 -2
  90. package/dist/plugins/one-time-token/index.d.mts +5 -5
  91. package/dist/plugins/open-api/index.d.mts +3 -3
  92. package/dist/plugins/organization/client.d.mts +9 -9
  93. package/dist/plugins/organization/error-codes.d.mts +1 -0
  94. package/dist/plugins/organization/error-codes.mjs +2 -1
  95. package/dist/plugins/organization/error-codes.mjs.map +1 -1
  96. package/dist/plugins/organization/organization.d.mts +4 -4
  97. package/dist/plugins/organization/routes/crud-access-control.d.mts +22 -22
  98. package/dist/plugins/organization/routes/crud-access-control.mjs +22 -0
  99. package/dist/plugins/organization/routes/crud-access-control.mjs.map +1 -1
  100. package/dist/plugins/organization/routes/crud-invites.d.mts +70 -70
  101. package/dist/plugins/organization/routes/crud-invites.mjs +0 -4
  102. package/dist/plugins/organization/routes/crud-invites.mjs.map +1 -1
  103. package/dist/plugins/organization/routes/crud-members.d.mts +67 -67
  104. package/dist/plugins/organization/routes/crud-org.d.mts +59 -59
  105. package/dist/plugins/organization/routes/crud-team.d.mts +79 -79
  106. package/dist/plugins/phone-number/index.d.mts +33 -33
  107. package/dist/plugins/phone-number/routes.mjs +6 -2
  108. package/dist/plugins/phone-number/routes.mjs.map +1 -1
  109. package/dist/plugins/siwe/index.d.mts +3 -3
  110. package/dist/plugins/two-factor/backup-codes/index.d.mts +5 -5
  111. package/dist/plugins/two-factor/client.d.mts +2 -2
  112. package/dist/plugins/two-factor/index.d.mts +18 -18
  113. package/dist/plugins/two-factor/otp/index.d.mts +3 -3
  114. package/dist/plugins/two-factor/totp/index.d.mts +5 -5
  115. package/dist/plugins/username/index.d.mts +12 -12
  116. package/dist/plugins/username/schema.d.mts +3 -3
  117. package/dist/test-utils/test-instance.d.mts +1242 -1242
  118. package/package.json +3 -3
@@ -1 +1 @@
1
- {"version":3,"file":"authorize.mjs","names":["query"],"sources":["../../../src/plugins/oidc-provider/authorize.ts"],"sourcesContent":["import type { GenericEndpointContext } from \"@better-auth/core\";\nimport { APIError } from \"better-call\";\nimport { getSessionFromCtx } from \"../../api\";\nimport { generateRandomString } from \"../../crypto\";\nimport { getClient } from \"./index\";\nimport type { AuthorizationQuery, OIDCOptions } from \"./types\";\nimport { parsePrompt } from \"./utils/prompt\";\n\nfunction formatErrorURL(url: string, error: string, description: string) {\n\treturn `${\n\t\turl.includes(\"?\") ? \"&\" : \"?\"\n\t}error=${error}&error_description=${description}`;\n}\n\nfunction getErrorURL(\n\tctx: GenericEndpointContext,\n\terror: string,\n\tdescription: string,\n) {\n\tconst baseURL =\n\t\tctx.context.options.onAPIError?.errorURL || `${ctx.context.baseURL}/error`;\n\tconst formattedURL = formatErrorURL(baseURL, error, description);\n\treturn formattedURL;\n}\n\nexport async function authorize(\n\tctx: GenericEndpointContext,\n\toptions: OIDCOptions,\n) {\n\tconst handleRedirect = (url: string) => {\n\t\tconst fromFetch = ctx.request?.headers.get(\"sec-fetch-mode\") === \"cors\";\n\t\tif (fromFetch) {\n\t\t\treturn ctx.json({\n\t\t\t\tredirect: true,\n\t\t\t\turl,\n\t\t\t});\n\t\t} else {\n\t\t\tthrow ctx.redirect(url);\n\t\t}\n\t};\n\n\tconst opts = {\n\t\tcodeExpiresIn: 600,\n\t\tdefaultScope: \"openid\",\n\t\t...options,\n\t\tscopes: [\n\t\t\t\"openid\",\n\t\t\t\"profile\",\n\t\t\t\"email\",\n\t\t\t\"offline_access\",\n\t\t\t...(options?.scopes || []),\n\t\t],\n\t};\n\tif (!ctx.request) {\n\t\tthrow new APIError(\"UNAUTHORIZED\", {\n\t\t\terror_description: \"request not found\",\n\t\t\terror: \"invalid_request\",\n\t\t});\n\t}\n\tconst session = await getSessionFromCtx(ctx);\n\tif (!session) {\n\t\t// Handle prompt=none per OIDC spec - must return error instead of redirecting\n\t\tconst query = ctx.query as AuthorizationQuery;\n\t\tconst promptSet = parsePrompt(query.prompt ?? \"\");\n\t\tif (promptSet.has(\"none\") && query.redirect_uri) {\n\t\t\treturn handleRedirect(\n\t\t\t\tformatErrorURL(\n\t\t\t\t\tquery.redirect_uri,\n\t\t\t\t\t\"login_required\",\n\t\t\t\t\t\"Authentication required but prompt is none\",\n\t\t\t\t),\n\t\t\t);\n\t\t}\n\n\t\t/**\n\t\t * If the user is not logged in, we need to redirect them to the\n\t\t * login page.\n\t\t */\n\t\tawait ctx.setSignedCookie(\n\t\t\t\"oidc_login_prompt\",\n\t\t\tJSON.stringify(ctx.query),\n\t\t\tctx.context.secret,\n\t\t\t{\n\t\t\t\tmaxAge: 600,\n\t\t\t\tpath: \"/\",\n\t\t\t\tsameSite: \"lax\",\n\t\t\t},\n\t\t);\n\t\tconst queryFromURL = ctx.request.url?.split(\"?\")[1]!;\n\t\treturn handleRedirect(`${options.loginPage}?${queryFromURL}`);\n\t}\n\n\tconst query = ctx.query as AuthorizationQuery;\n\tif (!query.client_id) {\n\t\tconst errorURL = getErrorURL(\n\t\t\tctx,\n\t\t\t\"invalid_client\",\n\t\t\t\"client_id is required\",\n\t\t);\n\t\tthrow ctx.redirect(errorURL);\n\t}\n\n\tif (!query.response_type) {\n\t\tconst errorURL = getErrorURL(\n\t\t\tctx,\n\t\t\t\"invalid_request\",\n\t\t\t\"response_type is required\",\n\t\t);\n\t\tthrow ctx.redirect(errorURL);\n\t}\n\n\tconst client = await getClient(\n\t\tctx.query.client_id,\n\t\toptions.trustedClients || [],\n\t);\n\tif (!client) {\n\t\tconst errorURL = getErrorURL(\n\t\t\tctx,\n\t\t\t\"invalid_client\",\n\t\t\t\"client_id is required\",\n\t\t);\n\t\tthrow ctx.redirect(errorURL);\n\t}\n\tconst redirectURI = client.redirectUrls.find(\n\t\t(url) => url === ctx.query.redirect_uri,\n\t);\n\n\tif (!redirectURI || !query.redirect_uri) {\n\t\t/**\n\t\t * show UI error here warning the user that the redirect URI is invalid\n\t\t */\n\t\tthrow new APIError(\"BAD_REQUEST\", {\n\t\t\tmessage: \"Invalid redirect URI\",\n\t\t});\n\t}\n\tif (client.disabled) {\n\t\tconst errorURL = getErrorURL(ctx, \"client_disabled\", \"client is disabled\");\n\t\tthrow ctx.redirect(errorURL);\n\t}\n\n\tif (query.response_type !== \"code\") {\n\t\tconst errorURL = getErrorURL(\n\t\t\tctx,\n\t\t\t\"unsupported_response_type\",\n\t\t\t\"unsupported response type\",\n\t\t);\n\t\tthrow ctx.redirect(errorURL);\n\t}\n\n\tconst requestScope =\n\t\tquery.scope?.split(\" \").filter((s) => s) ||\n\t\topts.defaultScope?.split(\" \") ||\n\t\t[];\n\tconst invalidScopes = requestScope.filter((scope) => {\n\t\treturn !opts.scopes.includes(scope);\n\t});\n\tif (invalidScopes.length) {\n\t\treturn handleRedirect(\n\t\t\tformatErrorURL(\n\t\t\t\tquery.redirect_uri,\n\t\t\t\t\"invalid_scope\",\n\t\t\t\t`The following scopes are invalid: ${invalidScopes.join(\", \")}`,\n\t\t\t),\n\t\t);\n\t}\n\n\tif (\n\t\t(!query.code_challenge || !query.code_challenge_method) &&\n\t\toptions.requirePKCE\n\t) {\n\t\treturn handleRedirect(\n\t\t\tformatErrorURL(query.redirect_uri, \"invalid_request\", \"pkce is required\"),\n\t\t);\n\t}\n\n\tif (!query.code_challenge_method) {\n\t\tquery.code_challenge_method = \"plain\";\n\t}\n\n\tif (\n\t\t![\n\t\t\t\"s256\",\n\t\t\toptions.allowPlainCodeChallengeMethod ? \"plain\" : \"s256\",\n\t\t].includes(query.code_challenge_method?.toLowerCase() || \"\")\n\t) {\n\t\treturn handleRedirect(\n\t\t\tformatErrorURL(\n\t\t\t\tquery.redirect_uri,\n\t\t\t\t\"invalid_request\",\n\t\t\t\t\"invalid code_challenge method\",\n\t\t\t),\n\t\t);\n\t}\n\n\tconst code = generateRandomString(32, \"a-z\", \"A-Z\", \"0-9\");\n\tconst codeExpiresInMs = opts.codeExpiresIn! * 1000;\n\tconst expiresAt = new Date(Date.now() + codeExpiresInMs);\n\n\t// Determine if consent is required\n\t// Consent is ALWAYS required unless:\n\t// 1. The client is trusted (skipConsent = true)\n\t// 2. The user has already consented and prompt is not \"consent\"\n\tconst skipConsentForTrustedClient = client.skipConsent;\n\tconst hasAlreadyConsented = await ctx.context.adapter\n\t\t.findOne<{\n\t\t\tconsentGiven: boolean;\n\t\t\tscopes: string;\n\t\t}>({\n\t\t\tmodel: \"oauthConsent\",\n\t\t\twhere: [\n\t\t\t\t{\n\t\t\t\t\tfield: \"clientId\",\n\t\t\t\t\tvalue: client.clientId,\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\tfield: \"userId\",\n\t\t\t\t\tvalue: session.user.id,\n\t\t\t\t},\n\t\t\t],\n\t\t})\n\t\t.then((res) => {\n\t\t\tif (!res?.consentGiven) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\tconst consentedScopes = res.scopes ? res.scopes.split(\" \") : [];\n\t\t\tconst hasConsented = requestScope.every((scope) =>\n\t\t\t\tconsentedScopes.includes(scope),\n\t\t\t);\n\t\t\treturn hasConsented;\n\t\t});\n\n\tconst promptSet = parsePrompt(query.prompt ?? \"\");\n\n\t// Handle prompt=none per OIDC spec 3.1.2.1\n\t// The Authorization Server MUST NOT display any authentication or consent UI\n\tif (promptSet.has(\"none\")) {\n\t\t// If consent is required, return consent_required error\n\t\tif (!skipConsentForTrustedClient && !hasAlreadyConsented) {\n\t\t\treturn handleRedirect(\n\t\t\t\tformatErrorURL(\n\t\t\t\t\tquery.redirect_uri,\n\t\t\t\t\t\"consent_required\",\n\t\t\t\t\t\"Consent required but prompt is none\",\n\t\t\t\t),\n\t\t\t);\n\t\t}\n\t\t// If we reach here, user is authenticated and consent is satisfied\n\t\t// Continue without any UI interaction\n\t}\n\n\t// Handle max_age parameter per OIDC spec 3.1.2.1\n\t// max_age=0 is equivalent to prompt=login\n\tlet requireLogin = promptSet.has(\"login\");\n\tif (query.max_age !== undefined) {\n\t\tconst maxAge = Number(query.max_age);\n\t\tif (Number.isInteger(maxAge) && maxAge >= 0) {\n\t\t\tconst sessionAge =\n\t\t\t\t(Date.now() - new Date(session.session.createdAt).getTime()) / 1000;\n\t\t\tif (sessionAge > maxAge) {\n\t\t\t\t// Session is older than max_age, force re-authentication\n\t\t\t\trequireLogin = true;\n\t\t\t}\n\t\t}\n\t\t// If max_age is invalid (not a non-negative integer), ignore it per OIDC spec\n\t}\n\n\tconst requireConsent =\n\t\t!skipConsentForTrustedClient &&\n\t\t(!hasAlreadyConsented || promptSet.has(\"consent\"));\n\n\ttry {\n\t\t/**\n\t\t * Save the code in the database\n\t\t */\n\t\tawait ctx.context.internalAdapter.createVerificationValue({\n\t\t\tvalue: JSON.stringify({\n\t\t\t\tclientId: client.clientId,\n\t\t\t\tredirectURI: query.redirect_uri,\n\t\t\t\tscope: requestScope,\n\t\t\t\tuserId: session.user.id,\n\t\t\t\tauthTime: new Date(session.session.createdAt).getTime(),\n\t\t\t\t/**\n\t\t\t\t * Consent is required per OIDC spec unless:\n\t\t\t\t * 1. Client is trusted (skipConsent = true)\n\t\t\t\t * 2. User has already consented (and prompt is not \"consent\")\n\t\t\t\t *\n\t\t\t\t * When consent is required, the code needs to be treated as a\n\t\t\t\t * consent request. Once the user consents, the code will be\n\t\t\t\t * updated with the actual authorization code.\n\t\t\t\t */\n\t\t\t\trequireConsent,\n\t\t\t\tstate: requireConsent ? query.state : null,\n\t\t\t\tcodeChallenge: query.code_challenge,\n\t\t\t\tcodeChallengeMethod: query.code_challenge_method,\n\t\t\t\tnonce: query.nonce,\n\t\t\t}),\n\t\t\tidentifier: code,\n\t\t\texpiresAt,\n\t\t});\n\t} catch {\n\t\treturn handleRedirect(\n\t\t\tformatErrorURL(\n\t\t\t\tquery.redirect_uri,\n\t\t\t\t\"server_error\",\n\t\t\t\t\"An error occurred while processing the request\",\n\t\t\t),\n\t\t);\n\t}\n\n\tif (requireLogin) {\n\t\tawait ctx.setSignedCookie(\n\t\t\t\"oidc_login_prompt\",\n\t\t\tJSON.stringify(ctx.query),\n\t\t\tctx.context.secret,\n\t\t\t{\n\t\t\t\tmaxAge: 600,\n\t\t\t\tpath: \"/\",\n\t\t\t\tsameSite: \"lax\",\n\t\t\t},\n\t\t);\n\t\tawait ctx.setSignedCookie(\"oidc_consent_prompt\", code, ctx.context.secret, {\n\t\t\tmaxAge: 600,\n\t\t\tpath: \"/\",\n\t\t\tsameSite: \"lax\",\n\t\t});\n\n\t\tconst loginURI = `${options.loginPage}?${new URLSearchParams({\n\t\t\tclient_id: client.clientId,\n\t\t\tcode,\n\t\t\tstate: query.state,\n\t\t}).toString()}`;\n\t\treturn handleRedirect(loginURI);\n\t}\n\n\t// If consent is not required, redirect with the code immediately\n\tif (!requireConsent) {\n\t\tconst redirectURIWithCode = new URL(redirectURI);\n\t\tredirectURIWithCode.searchParams.set(\"code\", code);\n\t\tredirectURIWithCode.searchParams.set(\"state\", ctx.query.state);\n\t\treturn handleRedirect(redirectURIWithCode.toString());\n\t}\n\n\t// Consent is required - redirect to consent page or show consent HTML\n\n\tif (options?.consentPage) {\n\t\t// Set cookie to support cookie-based consent flows\n\t\tawait ctx.setSignedCookie(\"oidc_consent_prompt\", code, ctx.context.secret, {\n\t\t\tmaxAge: 600,\n\t\t\tpath: \"/\",\n\t\t\tsameSite: \"lax\",\n\t\t});\n\n\t\t// Pass the consent code as a URL parameter to support URL-based consent flows\n\t\tconst urlParams = new URLSearchParams();\n\t\turlParams.set(\"consent_code\", code);\n\t\turlParams.set(\"client_id\", client.clientId);\n\t\turlParams.set(\"scope\", requestScope.join(\" \"));\n\t\tconst consentURI = `${options.consentPage}?${urlParams.toString()}`;\n\n\t\treturn handleRedirect(consentURI);\n\t}\n\tconst htmlFn = options?.getConsentHTML;\n\n\tif (!htmlFn) {\n\t\tthrow new APIError(\"INTERNAL_SERVER_ERROR\", {\n\t\t\tmessage: \"No consent page provided\",\n\t\t});\n\t}\n\n\treturn new Response(\n\t\thtmlFn({\n\t\t\tscopes: requestScope,\n\t\t\tclientMetadata: client.metadata,\n\t\t\tclientIcon: client?.icon,\n\t\t\tclientId: client.clientId,\n\t\t\tclientName: client.name,\n\t\t\tcode,\n\t\t}),\n\t\t{\n\t\t\theaders: {\n\t\t\t\t\"content-type\": \"text/html\",\n\t\t\t},\n\t\t},\n\t);\n}\n"],"mappings":";;;;;;;;;AAQA,SAAS,eAAe,KAAa,OAAe,aAAqB;AACxE,QAAO,GACN,IAAI,SAAS,IAAI,GAAG,MAAM,IAC1B,QAAQ,MAAM,qBAAqB;;AAGrC,SAAS,YACR,KACA,OACA,aACC;AAID,QADqB,eADpB,IAAI,QAAQ,QAAQ,YAAY,YAAY,GAAG,IAAI,QAAQ,QAAQ,SACvB,OAAO,YAAY;;AAIjE,eAAsB,UACrB,KACA,SACC;CACD,MAAM,kBAAkB,QAAgB;AAEvC,MADkB,IAAI,SAAS,QAAQ,IAAI,iBAAiB,KAAK,OAEhE,QAAO,IAAI,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,QAAQ;GAC1E,QAAQ;GACR,MAAM;GACN,UAAU;GACV,CAAC;AAOF,SAAO,eALU,GAAG,QAAQ,UAAU,GAAG,IAAI,gBAAgB;GAC5D,WAAW,OAAO;GAClB;GACA,OAAO,MAAM;GACb,CAAC,CAAC,UAAU,GACkB;;AAIhC,KAAI,CAAC,gBAAgB;EACpB,MAAM,sBAAsB,IAAI,IAAI,YAAY;AAChD,sBAAoB,aAAa,IAAI,QAAQ,KAAK;AAClD,sBAAoB,aAAa,IAAI,SAAS,IAAI,MAAM,MAAM;AAC9D,SAAO,eAAe,oBAAoB,UAAU,CAAC;;AAKtD,KAAI,SAAS,aAAa;AAEzB,QAAM,IAAI,gBAAgB,uBAAuB,MAAM,IAAI,QAAQ,QAAQ;GAC1E,QAAQ;GACR,MAAM;GACN,UAAU;GACV,CAAC;EAGF,MAAM,YAAY,IAAI,iBAAiB;AACvC,YAAU,IAAI,gBAAgB,KAAK;AACnC,YAAU,IAAI,aAAa,OAAO,SAAS;AAC3C,YAAU,IAAI,SAAS,aAAa,KAAK,IAAI,CAAC;AAG9C,SAAO,eAFY,GAAG,QAAQ,YAAY,GAAG,UAAU,UAAU,GAEhC;;CAElC,MAAM,SAAS,SAAS;AAExB,KAAI,CAAC,OACJ,OAAM,IAAI,SAAS,yBAAyB,EAC3C,SAAS,4BACT,CAAC;AAGH,QAAO,IAAI,SACV,OAAO;EACN,QAAQ;EACR,gBAAgB,OAAO;EACvB,YAAY,QAAQ;EACpB,UAAU,OAAO;EACjB,YAAY,OAAO;EACnB;EACA,CAAC,EACF,EACC,SAAS,EACR,gBAAgB,aAChB,EACD,CACD"}
1
+ {"version":3,"file":"authorize.mjs","names":["query"],"sources":["../../../src/plugins/oidc-provider/authorize.ts"],"sourcesContent":["import type { GenericEndpointContext } from \"@better-auth/core\";\nimport { APIError } from \"better-call\";\nimport { getSessionFromCtx } from \"../../api\";\nimport { generateRandomString } from \"../../crypto\";\nimport { getClient } from \"./index\";\nimport type { AuthorizationQuery, OIDCOptions } from \"./types\";\nimport { parsePrompt } from \"./utils/prompt\";\n\nfunction formatErrorURL(url: string, error: string, description: string) {\n\treturn `${url}${\n\t\turl.includes(\"?\") ? \"&\" : \"?\"\n\t}error=${error}&error_description=${description}`;\n}\n\nfunction getErrorURL(\n\tctx: GenericEndpointContext,\n\terror: string,\n\tdescription: string,\n) {\n\tconst baseURL =\n\t\tctx.context.options.onAPIError?.errorURL || `${ctx.context.baseURL}/error`;\n\tconst formattedURL = formatErrorURL(baseURL, error, description);\n\treturn formattedURL;\n}\n\nexport async function authorize(\n\tctx: GenericEndpointContext,\n\toptions: OIDCOptions,\n) {\n\tconst handleRedirect = (url: string) => {\n\t\tconst fromFetch = ctx.request?.headers.get(\"sec-fetch-mode\") === \"cors\";\n\t\tif (fromFetch) {\n\t\t\treturn ctx.json({\n\t\t\t\tredirect: true,\n\t\t\t\turl,\n\t\t\t});\n\t\t} else {\n\t\t\tthrow ctx.redirect(url);\n\t\t}\n\t};\n\n\tconst opts = {\n\t\tcodeExpiresIn: 600,\n\t\tdefaultScope: \"openid\",\n\t\t...options,\n\t\tscopes: [\n\t\t\t\"openid\",\n\t\t\t\"profile\",\n\t\t\t\"email\",\n\t\t\t\"offline_access\",\n\t\t\t...(options?.scopes || []),\n\t\t],\n\t};\n\tif (!ctx.request) {\n\t\tthrow new APIError(\"UNAUTHORIZED\", {\n\t\t\terror_description: \"request not found\",\n\t\t\terror: \"invalid_request\",\n\t\t});\n\t}\n\tconst session = await getSessionFromCtx(ctx);\n\tif (!session) {\n\t\t// Handle prompt=none per OIDC spec - must return error instead of redirecting\n\t\tconst query = ctx.query as AuthorizationQuery;\n\t\tconst promptSet = parsePrompt(query.prompt ?? \"\");\n\t\tif (promptSet.has(\"none\") && query.redirect_uri) {\n\t\t\treturn handleRedirect(\n\t\t\t\tformatErrorURL(\n\t\t\t\t\tquery.redirect_uri,\n\t\t\t\t\t\"login_required\",\n\t\t\t\t\t\"Authentication required but prompt is none\",\n\t\t\t\t),\n\t\t\t);\n\t\t}\n\n\t\t/**\n\t\t * If the user is not logged in, we need to redirect them to the\n\t\t * login page.\n\t\t */\n\t\tawait ctx.setSignedCookie(\n\t\t\t\"oidc_login_prompt\",\n\t\t\tJSON.stringify(ctx.query),\n\t\t\tctx.context.secret,\n\t\t\t{\n\t\t\t\tmaxAge: 600,\n\t\t\t\tpath: \"/\",\n\t\t\t\tsameSite: \"lax\",\n\t\t\t},\n\t\t);\n\t\tconst queryFromURL = ctx.request.url?.split(\"?\")[1]!;\n\t\treturn handleRedirect(`${options.loginPage}?${queryFromURL}`);\n\t}\n\n\tconst query = ctx.query as AuthorizationQuery;\n\tif (!query.client_id) {\n\t\tconst errorURL = getErrorURL(\n\t\t\tctx,\n\t\t\t\"invalid_client\",\n\t\t\t\"client_id is required\",\n\t\t);\n\t\tthrow ctx.redirect(errorURL);\n\t}\n\n\tif (!query.response_type) {\n\t\tconst errorURL = getErrorURL(\n\t\t\tctx,\n\t\t\t\"invalid_request\",\n\t\t\t\"response_type is required\",\n\t\t);\n\t\tthrow ctx.redirect(errorURL);\n\t}\n\n\tconst client = await getClient(\n\t\tctx.query.client_id,\n\t\toptions.trustedClients || [],\n\t);\n\tif (!client) {\n\t\tconst errorURL = getErrorURL(\n\t\t\tctx,\n\t\t\t\"invalid_client\",\n\t\t\t\"client_id is required\",\n\t\t);\n\t\tthrow ctx.redirect(errorURL);\n\t}\n\tconst redirectURI = client.redirectUrls.find(\n\t\t(url) => url === ctx.query.redirect_uri,\n\t);\n\n\tif (!redirectURI || !query.redirect_uri) {\n\t\t/**\n\t\t * show UI error here warning the user that the redirect URI is invalid\n\t\t */\n\t\tthrow new APIError(\"BAD_REQUEST\", {\n\t\t\tmessage: \"Invalid redirect URI\",\n\t\t});\n\t}\n\tif (client.disabled) {\n\t\tconst errorURL = getErrorURL(ctx, \"client_disabled\", \"client is disabled\");\n\t\tthrow ctx.redirect(errorURL);\n\t}\n\n\tif (query.response_type !== \"code\") {\n\t\tconst errorURL = getErrorURL(\n\t\t\tctx,\n\t\t\t\"unsupported_response_type\",\n\t\t\t\"unsupported response type\",\n\t\t);\n\t\tthrow ctx.redirect(errorURL);\n\t}\n\n\tconst requestScope =\n\t\tquery.scope?.split(\" \").filter((s) => s) ||\n\t\topts.defaultScope?.split(\" \") ||\n\t\t[];\n\tconst invalidScopes = requestScope.filter((scope) => {\n\t\treturn !opts.scopes.includes(scope);\n\t});\n\tif (invalidScopes.length) {\n\t\treturn handleRedirect(\n\t\t\tformatErrorURL(\n\t\t\t\tquery.redirect_uri,\n\t\t\t\t\"invalid_scope\",\n\t\t\t\t`The following scopes are invalid: ${invalidScopes.join(\", \")}`,\n\t\t\t),\n\t\t);\n\t}\n\n\tif (\n\t\t(!query.code_challenge || !query.code_challenge_method) &&\n\t\toptions.requirePKCE\n\t) {\n\t\treturn handleRedirect(\n\t\t\tformatErrorURL(query.redirect_uri, \"invalid_request\", \"pkce is required\"),\n\t\t);\n\t}\n\n\tif (!query.code_challenge_method) {\n\t\tquery.code_challenge_method = \"plain\";\n\t}\n\n\tif (\n\t\t![\n\t\t\t\"s256\",\n\t\t\toptions.allowPlainCodeChallengeMethod ? \"plain\" : \"s256\",\n\t\t].includes(query.code_challenge_method?.toLowerCase() || \"\")\n\t) {\n\t\treturn handleRedirect(\n\t\t\tformatErrorURL(\n\t\t\t\tquery.redirect_uri,\n\t\t\t\t\"invalid_request\",\n\t\t\t\t\"invalid code_challenge method\",\n\t\t\t),\n\t\t);\n\t}\n\n\tconst code = generateRandomString(32, \"a-z\", \"A-Z\", \"0-9\");\n\tconst codeExpiresInMs = opts.codeExpiresIn! * 1000;\n\tconst expiresAt = new Date(Date.now() + codeExpiresInMs);\n\n\t// Determine if consent is required\n\t// Consent is ALWAYS required unless:\n\t// 1. The client is trusted (skipConsent = true)\n\t// 2. The user has already consented and prompt is not \"consent\"\n\tconst skipConsentForTrustedClient = client.skipConsent;\n\tconst hasAlreadyConsented = await ctx.context.adapter\n\t\t.findOne<{\n\t\t\tconsentGiven: boolean;\n\t\t\tscopes: string;\n\t\t}>({\n\t\t\tmodel: \"oauthConsent\",\n\t\t\twhere: [\n\t\t\t\t{\n\t\t\t\t\tfield: \"clientId\",\n\t\t\t\t\tvalue: client.clientId,\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\tfield: \"userId\",\n\t\t\t\t\tvalue: session.user.id,\n\t\t\t\t},\n\t\t\t],\n\t\t})\n\t\t.then((res) => {\n\t\t\tif (!res?.consentGiven) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\tconst consentedScopes = res.scopes ? res.scopes.split(\" \") : [];\n\t\t\tconst hasConsented = requestScope.every((scope) =>\n\t\t\t\tconsentedScopes.includes(scope),\n\t\t\t);\n\t\t\treturn hasConsented;\n\t\t});\n\n\tconst promptSet = parsePrompt(query.prompt ?? \"\");\n\n\t// Handle prompt=none per OIDC spec 3.1.2.1\n\t// The Authorization Server MUST NOT display any authentication or consent UI\n\tif (promptSet.has(\"none\")) {\n\t\t// If consent is required, return consent_required error\n\t\tif (!skipConsentForTrustedClient && !hasAlreadyConsented) {\n\t\t\treturn handleRedirect(\n\t\t\t\tformatErrorURL(\n\t\t\t\t\tquery.redirect_uri,\n\t\t\t\t\t\"consent_required\",\n\t\t\t\t\t\"Consent required but prompt is none\",\n\t\t\t\t),\n\t\t\t);\n\t\t}\n\t\t// If we reach here, user is authenticated and consent is satisfied\n\t\t// Continue without any UI interaction\n\t}\n\n\t// Handle max_age parameter per OIDC spec 3.1.2.1\n\t// max_age=0 is equivalent to prompt=login\n\tlet requireLogin = promptSet.has(\"login\");\n\tif (query.max_age !== undefined) {\n\t\tconst maxAge = Number(query.max_age);\n\t\tif (Number.isInteger(maxAge) && maxAge >= 0) {\n\t\t\tconst sessionAge =\n\t\t\t\t(Date.now() - new Date(session.session.createdAt).getTime()) / 1000;\n\t\t\tif (sessionAge > maxAge) {\n\t\t\t\t// Session is older than max_age, force re-authentication\n\t\t\t\trequireLogin = true;\n\t\t\t}\n\t\t}\n\t\t// If max_age is invalid (not a non-negative integer), ignore it per OIDC spec\n\t}\n\n\tconst requireConsent =\n\t\t!skipConsentForTrustedClient &&\n\t\t(!hasAlreadyConsented || promptSet.has(\"consent\"));\n\n\ttry {\n\t\t/**\n\t\t * Save the code in the database\n\t\t */\n\t\tawait ctx.context.internalAdapter.createVerificationValue({\n\t\t\tvalue: JSON.stringify({\n\t\t\t\tclientId: client.clientId,\n\t\t\t\tredirectURI: query.redirect_uri,\n\t\t\t\tscope: requestScope,\n\t\t\t\tuserId: session.user.id,\n\t\t\t\tauthTime: new Date(session.session.createdAt).getTime(),\n\t\t\t\t/**\n\t\t\t\t * Consent is required per OIDC spec unless:\n\t\t\t\t * 1. Client is trusted (skipConsent = true)\n\t\t\t\t * 2. User has already consented (and prompt is not \"consent\")\n\t\t\t\t *\n\t\t\t\t * When consent is required, the code needs to be treated as a\n\t\t\t\t * consent request. Once the user consents, the code will be\n\t\t\t\t * updated with the actual authorization code.\n\t\t\t\t */\n\t\t\t\trequireConsent,\n\t\t\t\tstate: requireConsent ? query.state : null,\n\t\t\t\tcodeChallenge: query.code_challenge,\n\t\t\t\tcodeChallengeMethod: query.code_challenge_method,\n\t\t\t\tnonce: query.nonce,\n\t\t\t}),\n\t\t\tidentifier: code,\n\t\t\texpiresAt,\n\t\t});\n\t} catch {\n\t\treturn handleRedirect(\n\t\t\tformatErrorURL(\n\t\t\t\tquery.redirect_uri,\n\t\t\t\t\"server_error\",\n\t\t\t\t\"An error occurred while processing the request\",\n\t\t\t),\n\t\t);\n\t}\n\n\tif (requireLogin) {\n\t\tawait ctx.setSignedCookie(\n\t\t\t\"oidc_login_prompt\",\n\t\t\tJSON.stringify(ctx.query),\n\t\t\tctx.context.secret,\n\t\t\t{\n\t\t\t\tmaxAge: 600,\n\t\t\t\tpath: \"/\",\n\t\t\t\tsameSite: \"lax\",\n\t\t\t},\n\t\t);\n\t\tawait ctx.setSignedCookie(\"oidc_consent_prompt\", code, ctx.context.secret, {\n\t\t\tmaxAge: 600,\n\t\t\tpath: \"/\",\n\t\t\tsameSite: \"lax\",\n\t\t});\n\n\t\tconst loginURI = `${options.loginPage}?${new URLSearchParams({\n\t\t\tclient_id: client.clientId,\n\t\t\tcode,\n\t\t\tstate: query.state,\n\t\t}).toString()}`;\n\t\treturn handleRedirect(loginURI);\n\t}\n\n\t// If consent is not required, redirect with the code immediately\n\tif (!requireConsent) {\n\t\tconst redirectURIWithCode = new URL(redirectURI);\n\t\tredirectURIWithCode.searchParams.set(\"code\", code);\n\t\tredirectURIWithCode.searchParams.set(\"state\", ctx.query.state);\n\t\treturn handleRedirect(redirectURIWithCode.toString());\n\t}\n\n\t// Consent is required - redirect to consent page or show consent HTML\n\n\tif (options?.consentPage) {\n\t\t// Set cookie to support cookie-based consent flows\n\t\tawait ctx.setSignedCookie(\"oidc_consent_prompt\", code, ctx.context.secret, {\n\t\t\tmaxAge: 600,\n\t\t\tpath: \"/\",\n\t\t\tsameSite: \"lax\",\n\t\t});\n\n\t\t// Pass the consent code as a URL parameter to support URL-based consent flows\n\t\tconst urlParams = new URLSearchParams();\n\t\turlParams.set(\"consent_code\", code);\n\t\turlParams.set(\"client_id\", client.clientId);\n\t\turlParams.set(\"scope\", requestScope.join(\" \"));\n\t\tconst consentURI = `${options.consentPage}?${urlParams.toString()}`;\n\n\t\treturn handleRedirect(consentURI);\n\t}\n\tconst htmlFn = options?.getConsentHTML;\n\n\tif (!htmlFn) {\n\t\tthrow new APIError(\"INTERNAL_SERVER_ERROR\", {\n\t\t\tmessage: \"No consent page provided\",\n\t\t});\n\t}\n\n\treturn new Response(\n\t\thtmlFn({\n\t\t\tscopes: requestScope,\n\t\t\tclientMetadata: client.metadata,\n\t\t\tclientIcon: client?.icon,\n\t\t\tclientId: client.clientId,\n\t\t\tclientName: client.name,\n\t\t\tcode,\n\t\t}),\n\t\t{\n\t\t\theaders: {\n\t\t\t\t\"content-type\": \"text/html\",\n\t\t\t},\n\t\t},\n\t);\n}\n"],"mappings":";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AI,SACV,OAAO;EACN,QAAQ;EACR,gBAAgB,OAAO;EACvB,YAAY,QAAQ;EACpB,UAAU,OAAO;EACjB,YAAY,OAAO;EACnB;EACA,CAAC,EACF,EACC,SAAS,EACR,gBAAgB,aAChB,EACD,CACD"}
@@ -3,8 +3,8 @@ import { schema } from "./schema.mjs";
3
3
  import { AuthorizationQuery, Client, CodeVerificationValue, OAuthAccessToken, OIDCMetadata, OIDCOptions, TokenBody } from "./types.mjs";
4
4
  import "../index.mjs";
5
5
  import { GenericEndpointContext } from "@better-auth/core";
6
- import * as _better_auth_core_db2 from "@better-auth/core/db";
7
- import * as better_call247 from "better-call";
6
+ import * as _better_auth_core_db0 from "@better-auth/core/db";
7
+ import * as better_call219 from "better-call";
8
8
  import { OpenAPIParameter } from "better-call";
9
9
  import * as z from "zod";
10
10
 
@@ -31,21 +31,21 @@ declare const oidcProvider: (options: OIDCOptions) => {
31
31
  hooks: {
32
32
  after: {
33
33
  matcher(): true;
34
- handler: (inputContext: better_call247.MiddlewareInputContext<better_call247.MiddlewareOptions>) => Promise<Response | {
34
+ handler: (inputContext: better_call219.MiddlewareInputContext<better_call219.MiddlewareOptions>) => Promise<Response | {
35
35
  redirect: boolean;
36
36
  url: string;
37
37
  } | undefined>;
38
38
  }[];
39
39
  };
40
40
  endpoints: {
41
- getOpenIdConfig: better_call247.StrictEndpoint<"/.well-known/openid-configuration", {
41
+ getOpenIdConfig: better_call219.StrictEndpoint<"/.well-known/openid-configuration", {
42
42
  method: "GET";
43
43
  operationId: string;
44
44
  metadata: {
45
45
  readonly scope: "server";
46
46
  };
47
47
  }, OIDCMetadata>;
48
- oAuth2authorize: better_call247.StrictEndpoint<"/oauth2/authorize", {
48
+ oAuth2authorize: better_call219.StrictEndpoint<"/oauth2/authorize", {
49
49
  method: "GET";
50
50
  operationId: string;
51
51
  query: z.ZodRecord<z.ZodString, z.ZodAny>;
@@ -72,14 +72,14 @@ declare const oidcProvider: (options: OIDCOptions) => {
72
72
  redirect: boolean;
73
73
  url: string;
74
74
  }>;
75
- oAuthConsent: better_call247.StrictEndpoint<"/oauth2/consent", {
75
+ oAuthConsent: better_call219.StrictEndpoint<"/oauth2/consent", {
76
76
  method: "POST";
77
77
  operationId: string;
78
78
  body: z.ZodObject<{
79
79
  accept: z.ZodBoolean;
80
80
  consent_code: z.ZodOptional<z.ZodNullable<z.ZodOptional<z.ZodString>>>;
81
81
  }, z.core.$strip>;
82
- use: ((inputContext: better_call247.MiddlewareInputContext<better_call247.MiddlewareOptions>) => Promise<{
82
+ use: ((inputContext: better_call219.MiddlewareInputContext<better_call219.MiddlewareOptions>) => Promise<{
83
83
  session: {
84
84
  session: Record<string, any> & {
85
85
  id: string;
@@ -151,7 +151,7 @@ declare const oidcProvider: (options: OIDCOptions) => {
151
151
  }, {
152
152
  redirectURI: string;
153
153
  }>;
154
- oAuth2token: better_call247.StrictEndpoint<"/oauth2/token", {
154
+ oAuth2token: better_call219.StrictEndpoint<"/oauth2/token", {
155
155
  method: "POST";
156
156
  operationId: string;
157
157
  body: z.ZodRecord<z.ZodAny, z.ZodAny>;
@@ -173,7 +173,7 @@ declare const oidcProvider: (options: OIDCOptions) => {
173
173
  scope: string;
174
174
  id_token: string | undefined;
175
175
  }>;
176
- oAuth2userInfo: better_call247.StrictEndpoint<"/oauth2/userinfo", {
176
+ oAuth2userInfo: better_call219.StrictEndpoint<"/oauth2/userinfo", {
177
177
  method: "GET";
178
178
  operationId: string;
179
179
  metadata: {
@@ -265,7 +265,7 @@ declare const oidcProvider: (options: OIDCOptions) => {
265
265
  *
266
266
  * @see [Read our docs to learn more.](https://better-auth.com/docs/plugins/oidc-provider#api-method-oauth2-register)
267
267
  */
268
- registerOAuthApplication: better_call247.StrictEndpoint<"/oauth2/register", {
268
+ registerOAuthApplication: better_call219.StrictEndpoint<"/oauth2/register", {
269
269
  method: "POST";
270
270
  body: z.ZodObject<{
271
271
  redirect_uris: z.ZodArray<z.ZodString>;
@@ -405,9 +405,9 @@ declare const oidcProvider: (options: OIDCOptions) => {
405
405
  client_secret?: string | undefined;
406
406
  client_id: string;
407
407
  }>;
408
- getOAuthClient: better_call247.StrictEndpoint<"/oauth2/client/:id", {
408
+ getOAuthClient: better_call219.StrictEndpoint<"/oauth2/client/:id", {
409
409
  method: "GET";
410
- use: ((inputContext: better_call247.MiddlewareInputContext<better_call247.MiddlewareOptions>) => Promise<{
410
+ use: ((inputContext: better_call219.MiddlewareInputContext<better_call219.MiddlewareOptions>) => Promise<{
411
411
  session: {
412
412
  session: Record<string, any> & {
413
413
  id: string;
@@ -478,7 +478,7 @@ declare const oidcProvider: (options: OIDCOptions) => {
478
478
  *
479
479
  * @see [OpenID Connect RP-Initiated Logout Spec](https://openid.net/specs/openid-connect-rpinitiated-1_0.html)
480
480
  */
481
- endSession: better_call247.StrictEndpoint<"/oauth2/endsession", {
481
+ endSession: better_call219.StrictEndpoint<"/oauth2/endsession", {
482
482
  method: ("GET" | "POST")[];
483
483
  query: z.ZodOptional<z.ZodObject<{
484
484
  id_token_hint: z.ZodOptional<z.ZodString>;
@@ -504,7 +504,7 @@ declare const oidcProvider: (options: OIDCOptions) => {
504
504
  scope: "server";
505
505
  };
506
506
  }, {
507
- status: ("OK" | "CREATED" | "ACCEPTED" | "NO_CONTENT" | "MULTIPLE_CHOICES" | "MOVED_PERMANENTLY" | "FOUND" | "SEE_OTHER" | "NOT_MODIFIED" | "TEMPORARY_REDIRECT" | "BAD_REQUEST" | "UNAUTHORIZED" | "PAYMENT_REQUIRED" | "FORBIDDEN" | "NOT_FOUND" | "METHOD_NOT_ALLOWED" | "NOT_ACCEPTABLE" | "PROXY_AUTHENTICATION_REQUIRED" | "REQUEST_TIMEOUT" | "CONFLICT" | "GONE" | "LENGTH_REQUIRED" | "PRECONDITION_FAILED" | "PAYLOAD_TOO_LARGE" | "URI_TOO_LONG" | "UNSUPPORTED_MEDIA_TYPE" | "RANGE_NOT_SATISFIABLE" | "EXPECTATION_FAILED" | "I'M_A_TEAPOT" | "MISDIRECTED_REQUEST" | "UNPROCESSABLE_ENTITY" | "LOCKED" | "FAILED_DEPENDENCY" | "TOO_EARLY" | "UPGRADE_REQUIRED" | "PRECONDITION_REQUIRED" | "TOO_MANY_REQUESTS" | "REQUEST_HEADER_FIELDS_TOO_LARGE" | "UNAVAILABLE_FOR_LEGAL_REASONS" | "INTERNAL_SERVER_ERROR" | "NOT_IMPLEMENTED" | "BAD_GATEWAY" | "SERVICE_UNAVAILABLE" | "GATEWAY_TIMEOUT" | "HTTP_VERSION_NOT_SUPPORTED" | "VARIANT_ALSO_NEGOTIATES" | "INSUFFICIENT_STORAGE" | "LOOP_DETECTED" | "NOT_EXTENDED" | "NETWORK_AUTHENTICATION_REQUIRED") | better_call247.Status;
507
+ status: ("OK" | "CREATED" | "ACCEPTED" | "NO_CONTENT" | "MULTIPLE_CHOICES" | "MOVED_PERMANENTLY" | "FOUND" | "SEE_OTHER" | "NOT_MODIFIED" | "TEMPORARY_REDIRECT" | "BAD_REQUEST" | "UNAUTHORIZED" | "PAYMENT_REQUIRED" | "FORBIDDEN" | "NOT_FOUND" | "METHOD_NOT_ALLOWED" | "NOT_ACCEPTABLE" | "PROXY_AUTHENTICATION_REQUIRED" | "REQUEST_TIMEOUT" | "CONFLICT" | "GONE" | "LENGTH_REQUIRED" | "PRECONDITION_FAILED" | "PAYLOAD_TOO_LARGE" | "URI_TOO_LONG" | "UNSUPPORTED_MEDIA_TYPE" | "RANGE_NOT_SATISFIABLE" | "EXPECTATION_FAILED" | "I'M_A_TEAPOT" | "MISDIRECTED_REQUEST" | "UNPROCESSABLE_ENTITY" | "LOCKED" | "FAILED_DEPENDENCY" | "TOO_EARLY" | "UPGRADE_REQUIRED" | "PRECONDITION_REQUIRED" | "TOO_MANY_REQUESTS" | "REQUEST_HEADER_FIELDS_TOO_LARGE" | "UNAVAILABLE_FOR_LEGAL_REASONS" | "INTERNAL_SERVER_ERROR" | "NOT_IMPLEMENTED" | "BAD_GATEWAY" | "SERVICE_UNAVAILABLE" | "GATEWAY_TIMEOUT" | "HTTP_VERSION_NOT_SUPPORTED" | "VARIANT_ALSO_NEGOTIATES" | "INSUFFICIENT_STORAGE" | "LOOP_DETECTED" | "NOT_EXTENDED" | "NETWORK_AUTHENTICATION_REQUIRED") | better_call219.Status;
508
508
  body: ({
509
509
  message?: string;
510
510
  code?: string;
@@ -678,7 +678,7 @@ declare const oidcProvider: (options: OIDCOptions) => {
678
678
  allowPlainCodeChallengeMethod: boolean;
679
679
  generateClientId?: (() => string) | undefined;
680
680
  generateClientSecret?: (() => string) | undefined;
681
- getAdditionalUserInfoClaim?: ((user: _better_auth_core_db2.User & Record<string, any>, scopes: string[], client: Client) => Record<string, any> | Promise<Record<string, any>>) | undefined;
681
+ getAdditionalUserInfoClaim?: ((user: _better_auth_core_db0.User & Record<string, any>, scopes: string[], client: Client) => Record<string, any> | Promise<Record<string, any>>) | undefined;
682
682
  trustedClients?: Client[] | undefined;
683
683
  storeClientSecret: "hashed" | "plain" | "encrypted" | {
684
684
  hash: (clientSecret: string) => Promise<string>;
@@ -1,6 +1,6 @@
1
- import * as _better_auth_core24 from "@better-auth/core";
1
+ import * as _better_auth_core40 from "@better-auth/core";
2
2
  import { ClientFetchOption } from "@better-auth/core";
3
- import * as _better_fetch_fetch96 from "@better-fetch/fetch";
3
+ import * as _better_fetch_fetch112 from "@better-fetch/fetch";
4
4
 
5
5
  //#region src/plugins/one-tap/client.d.ts
6
6
  declare global {
@@ -161,13 +161,13 @@ declare const oneTapClient: (options: GoogleOneTapOptions) => {
161
161
  id: string;
162
162
  name: string;
163
163
  hooks: {
164
- onResponse(ctx: _better_fetch_fetch96.ResponseContext): Promise<void>;
164
+ onResponse(ctx: _better_fetch_fetch112.ResponseContext): Promise<void>;
165
165
  };
166
166
  }[];
167
- getActions: ($fetch: _better_fetch_fetch96.BetterFetch, _: _better_auth_core24.ClientStore) => {
167
+ getActions: ($fetch: _better_fetch_fetch112.BetterFetch, _: _better_auth_core40.ClientStore) => {
168
168
  oneTap: (opts?: GoogleOneTapActionOptions | undefined, fetchOptions?: ClientFetchOption | undefined) => Promise<void>;
169
169
  };
170
- getAtoms($fetch: _better_fetch_fetch96.BetterFetch): {};
170
+ getAtoms($fetch: _better_fetch_fetch112.BetterFetch): {};
171
171
  };
172
172
  //#endregion
173
173
  export { GoogleOneTapActionOptions, GoogleOneTapOptions, GsiButtonConfiguration, oneTapClient };
@@ -1,4 +1,4 @@
1
- import * as better_call10 from "better-call";
1
+ import * as better_call7 from "better-call";
2
2
  import * as z from "zod";
3
3
 
4
4
  //#region src/plugins/one-tap/index.d.ts
@@ -20,7 +20,7 @@ interface OneTapOptions {
20
20
  declare const oneTap: (options?: OneTapOptions | undefined) => {
21
21
  id: "one-tap";
22
22
  endpoints: {
23
- oneTapCallback: better_call10.StrictEndpoint<"/one-tap/callback", {
23
+ oneTapCallback: better_call7.StrictEndpoint<"/one-tap/callback", {
24
24
  method: "POST";
25
25
  body: z.ZodObject<{
26
26
  idToken: z.ZodString;
@@ -1,7 +1,7 @@
1
1
  import { Session, User } from "../../types/models.mjs";
2
2
  import "../../types/index.mjs";
3
3
  import { GenericEndpointContext } from "@better-auth/core";
4
- import * as better_call241 from "better-call";
4
+ import * as better_call252 from "better-call";
5
5
  import * as z from "zod";
6
6
 
7
7
  //#region src/plugins/one-time-token/index.d.ts
@@ -60,9 +60,9 @@ declare const oneTimeToken: (options?: OneTimeTokenOptions | undefined) => {
60
60
  *
61
61
  * @see [Read our docs to learn more.](https://better-auth.com/docs/plugins/one-time-token#api-method-one-time-token-generate)
62
62
  */
63
- generateOneTimeToken: better_call241.StrictEndpoint<"/one-time-token/generate", {
63
+ generateOneTimeToken: better_call252.StrictEndpoint<"/one-time-token/generate", {
64
64
  method: "GET";
65
- use: ((inputContext: better_call241.MiddlewareInputContext<better_call241.MiddlewareOptions>) => Promise<{
65
+ use: ((inputContext: better_call252.MiddlewareInputContext<better_call252.MiddlewareOptions>) => Promise<{
66
66
  session: {
67
67
  session: Record<string, any> & {
68
68
  id: string;
@@ -103,7 +103,7 @@ declare const oneTimeToken: (options?: OneTimeTokenOptions | undefined) => {
103
103
  *
104
104
  * @see [Read our docs to learn more.](https://better-auth.com/docs/plugins/one-time-token#api-method-one-time-token-verify)
105
105
  */
106
- verifyOneTimeToken: better_call241.StrictEndpoint<"/one-time-token/verify", {
106
+ verifyOneTimeToken: better_call252.StrictEndpoint<"/one-time-token/verify", {
107
107
  method: "POST";
108
108
  body: z.ZodObject<{
109
109
  token: z.ZodString;
@@ -116,7 +116,7 @@ declare const oneTimeToken: (options?: OneTimeTokenOptions | undefined) => {
116
116
  hooks: {
117
117
  after: {
118
118
  matcher: () => true;
119
- handler: (inputContext: better_call241.MiddlewareInputContext<better_call241.MiddlewareOptions>) => Promise<void>;
119
+ handler: (inputContext: better_call252.MiddlewareInputContext<better_call252.MiddlewareOptions>) => Promise<void>;
120
120
  }[];
121
121
  };
122
122
  options: OneTimeTokenOptions | undefined;
@@ -1,6 +1,6 @@
1
1
  import { FieldSchema, OpenAPIModelSchema, Path, generator } from "./generator.mjs";
2
2
  import { LiteralString } from "@better-auth/core";
3
- import * as better_call75 from "better-call";
3
+ import * as better_call190 from "better-call";
4
4
 
5
5
  //#region src/plugins/open-api/index.d.ts
6
6
  type ScalarTheme = "alternate" | "default" | "moon" | "purple" | "solarized" | "bluePlanet" | "saturn" | "kepler" | "mars" | "deepSpace" | "laserwave" | "none";
@@ -36,7 +36,7 @@ interface OpenAPIOptions {
36
36
  declare const openAPI: <O extends OpenAPIOptions>(options?: O | undefined) => {
37
37
  id: "open-api";
38
38
  endpoints: {
39
- generateOpenAPISchema: better_call75.StrictEndpoint<"/open-api/generate-schema", {
39
+ generateOpenAPISchema: better_call190.StrictEndpoint<"/open-api/generate-schema", {
40
40
  method: "GET";
41
41
  }, {
42
42
  openapi: string;
@@ -76,7 +76,7 @@ declare const openAPI: <O extends OpenAPIOptions>(options?: O | undefined) => {
76
76
  }[];
77
77
  paths: Record<string, Path>;
78
78
  }>;
79
- openAPIReference: better_call75.StrictEndpoint<"/reference", {
79
+ openAPIReference: better_call190.StrictEndpoint<"/reference", {
80
80
  method: "GET";
81
81
  metadata: {
82
82
  readonly scope: "server";
@@ -12,10 +12,10 @@ import { OrganizationPlugin } from "./organization.mjs";
12
12
  import "./index.mjs";
13
13
  import "../../client/index.mjs";
14
14
  import { HasPermissionBaseInput } from "./permission.mjs";
15
- import * as _better_auth_core25 from "@better-auth/core";
15
+ import * as _better_auth_core41 from "@better-auth/core";
16
16
  import { DBFieldAttribute } from "@better-auth/core/db";
17
- import * as nanostores4 from "nanostores";
18
- import * as _better_fetch_fetch99 from "@better-fetch/fetch";
17
+ import * as nanostores6 from "nanostores";
18
+ import * as _better_fetch_fetch115 from "@better-fetch/fetch";
19
19
 
20
20
  //#region src/plugins/organization/client.d.ts
21
21
  /**
@@ -86,7 +86,7 @@ declare const organizationClient: <CO extends OrganizationClientOptions>(options
86
86
  } ? true : false;
87
87
  };
88
88
  }>;
89
- getActions: ($fetch: _better_fetch_fetch99.BetterFetch, _$store: _better_auth_core25.ClientStore, co: _better_auth_core25.BetterAuthClientOptions | undefined) => {
89
+ getActions: ($fetch: _better_fetch_fetch115.BetterFetch, _$store: _better_auth_core41.ClientStore, co: _better_auth_core41.BetterAuthClientOptions | undefined) => {
90
90
  $Infer: {
91
91
  ActiveOrganization: CO["teams"] extends {
92
92
  enabled: true;
@@ -178,11 +178,11 @@ declare const organizationClient: <CO extends OrganizationClientOptions>(options
178
178
  }) => boolean;
179
179
  };
180
180
  };
181
- getAtoms: ($fetch: _better_fetch_fetch99.BetterFetch) => {
182
- $listOrg: nanostores4.PreinitializedWritableAtom<boolean> & object;
183
- $activeOrgSignal: nanostores4.PreinitializedWritableAtom<boolean> & object;
184
- $activeMemberSignal: nanostores4.PreinitializedWritableAtom<boolean> & object;
185
- $activeMemberRoleSignal: nanostores4.PreinitializedWritableAtom<boolean> & object;
181
+ getAtoms: ($fetch: _better_fetch_fetch115.BetterFetch) => {
182
+ $listOrg: nanostores6.PreinitializedWritableAtom<boolean> & object;
183
+ $activeOrgSignal: nanostores6.PreinitializedWritableAtom<boolean> & object;
184
+ $activeMemberSignal: nanostores6.PreinitializedWritableAtom<boolean> & object;
185
+ $activeMemberRoleSignal: nanostores6.PreinitializedWritableAtom<boolean> & object;
186
186
  activeOrganization: AuthQueryAtom<Prettify<({
187
187
  id: string;
188
188
  name: string;
@@ -56,6 +56,7 @@ declare const ORGANIZATION_ERROR_CODES: {
56
56
  readonly INVALID_RESOURCE: "The provided permission includes an invalid resource";
57
57
  readonly ROLE_NAME_IS_ALREADY_TAKEN: "That role name is already taken";
58
58
  readonly CANNOT_DELETE_A_PRE_DEFINED_ROLE: "Cannot delete a pre-defined role";
59
+ readonly ROLE_IS_ASSIGNED_TO_MEMBERS: "Cannot delete a role that is assigned to members. Please reassign the members to a different role first";
59
60
  };
60
61
  //#endregion
61
62
  export { ORGANIZATION_ERROR_CODES };
@@ -57,7 +57,8 @@ const ORGANIZATION_ERROR_CODES = defineErrorCodes({
57
57
  TOO_MANY_ROLES: "This organization has too many roles",
58
58
  INVALID_RESOURCE: "The provided permission includes an invalid resource",
59
59
  ROLE_NAME_IS_ALREADY_TAKEN: "That role name is already taken",
60
- CANNOT_DELETE_A_PRE_DEFINED_ROLE: "Cannot delete a pre-defined role"
60
+ CANNOT_DELETE_A_PRE_DEFINED_ROLE: "Cannot delete a pre-defined role",
61
+ ROLE_IS_ASSIGNED_TO_MEMBERS: "Cannot delete a role that is assigned to members. Please reassign the members to a different role first"
61
62
  });
62
63
 
63
64
  //#endregion
@@ -1 +1 @@
1
- {"version":3,"file":"error-codes.mjs","names":[],"sources":["../../../src/plugins/organization/error-codes.ts"],"sourcesContent":["import { defineErrorCodes } from \"@better-auth/core/utils\";\n\nexport const ORGANIZATION_ERROR_CODES = defineErrorCodes({\n\tYOU_ARE_NOT_ALLOWED_TO_CREATE_A_NEW_ORGANIZATION:\n\t\t\"You are not allowed to create a new organization\",\n\tYOU_HAVE_REACHED_THE_MAXIMUM_NUMBER_OF_ORGANIZATIONS:\n\t\t\"You have reached the maximum number of organizations\",\n\tORGANIZATION_ALREADY_EXISTS: \"Organization already exists\",\n\tORGANIZATION_SLUG_ALREADY_TAKEN: \"Organization slug already taken\",\n\tORGANIZATION_NOT_FOUND: \"Organization not found\",\n\tUSER_IS_NOT_A_MEMBER_OF_THE_ORGANIZATION:\n\t\t\"User is not a member of the organization\",\n\tYOU_ARE_NOT_ALLOWED_TO_UPDATE_THIS_ORGANIZATION:\n\t\t\"You are not allowed to update this organization\",\n\tYOU_ARE_NOT_ALLOWED_TO_DELETE_THIS_ORGANIZATION:\n\t\t\"You are not allowed to delete this organization\",\n\tNO_ACTIVE_ORGANIZATION: \"No active organization\",\n\tUSER_IS_ALREADY_A_MEMBER_OF_THIS_ORGANIZATION:\n\t\t\"User is already a member of this organization\",\n\tMEMBER_NOT_FOUND: \"Member not found\",\n\tROLE_NOT_FOUND: \"Role not found\",\n\tYOU_ARE_NOT_ALLOWED_TO_CREATE_A_NEW_TEAM:\n\t\t\"You are not allowed to create a new team\",\n\tTEAM_ALREADY_EXISTS: \"Team already exists\",\n\tTEAM_NOT_FOUND: \"Team not found\",\n\tYOU_CANNOT_LEAVE_THE_ORGANIZATION_AS_THE_ONLY_OWNER:\n\t\t\"You cannot leave the organization as the only owner\",\n\tYOU_CANNOT_LEAVE_THE_ORGANIZATION_WITHOUT_AN_OWNER:\n\t\t\"You cannot leave the organization without an owner\",\n\tYOU_ARE_NOT_ALLOWED_TO_DELETE_THIS_MEMBER:\n\t\t\"You are not allowed to delete this member\",\n\tYOU_ARE_NOT_ALLOWED_TO_INVITE_USERS_TO_THIS_ORGANIZATION:\n\t\t\"You are not allowed to invite users to this organization\",\n\tUSER_IS_ALREADY_INVITED_TO_THIS_ORGANIZATION:\n\t\t\"User is already invited to this organization\",\n\tINVITATION_NOT_FOUND: \"Invitation not found\",\n\tYOU_ARE_NOT_THE_RECIPIENT_OF_THE_INVITATION:\n\t\t\"You are not the recipient of the invitation\",\n\tEMAIL_VERIFICATION_REQUIRED_BEFORE_ACCEPTING_OR_REJECTING_INVITATION:\n\t\t\"Email verification required before accepting or rejecting invitation\",\n\tYOU_ARE_NOT_ALLOWED_TO_CANCEL_THIS_INVITATION:\n\t\t\"You are not allowed to cancel this invitation\",\n\tINVITER_IS_NO_LONGER_A_MEMBER_OF_THE_ORGANIZATION:\n\t\t\"Inviter is no longer a member of the organization\",\n\tYOU_ARE_NOT_ALLOWED_TO_INVITE_USER_WITH_THIS_ROLE:\n\t\t\"You are not allowed to invite a user with this role\",\n\tFAILED_TO_RETRIEVE_INVITATION: \"Failed to retrieve invitation\",\n\tYOU_HAVE_REACHED_THE_MAXIMUM_NUMBER_OF_TEAMS:\n\t\t\"You have reached the maximum number of teams\",\n\tUNABLE_TO_REMOVE_LAST_TEAM: \"Unable to remove last team\",\n\tYOU_ARE_NOT_ALLOWED_TO_UPDATE_THIS_MEMBER:\n\t\t\"You are not allowed to update this member\",\n\tORGANIZATION_MEMBERSHIP_LIMIT_REACHED:\n\t\t\"Organization membership limit reached\",\n\tYOU_ARE_NOT_ALLOWED_TO_CREATE_TEAMS_IN_THIS_ORGANIZATION:\n\t\t\"You are not allowed to create teams in this organization\",\n\tYOU_ARE_NOT_ALLOWED_TO_DELETE_TEAMS_IN_THIS_ORGANIZATION:\n\t\t\"You are not allowed to delete teams in this organization\",\n\tYOU_ARE_NOT_ALLOWED_TO_UPDATE_THIS_TEAM:\n\t\t\"You are not allowed to update this team\",\n\tYOU_ARE_NOT_ALLOWED_TO_DELETE_THIS_TEAM:\n\t\t\"You are not allowed to delete this team\",\n\tINVITATION_LIMIT_REACHED: \"Invitation limit reached\",\n\tTEAM_MEMBER_LIMIT_REACHED: \"Team member limit reached\",\n\tUSER_IS_NOT_A_MEMBER_OF_THE_TEAM: \"User is not a member of the team\",\n\tYOU_CAN_NOT_ACCESS_THE_MEMBERS_OF_THIS_TEAM:\n\t\t\"You are not allowed to list the members of this team\",\n\tYOU_DO_NOT_HAVE_AN_ACTIVE_TEAM: \"You do not have an active team\",\n\tYOU_ARE_NOT_ALLOWED_TO_CREATE_A_NEW_TEAM_MEMBER:\n\t\t\"You are not allowed to create a new member\",\n\tYOU_ARE_NOT_ALLOWED_TO_REMOVE_A_TEAM_MEMBER:\n\t\t\"You are not allowed to remove a team member\",\n\tYOU_ARE_NOT_ALLOWED_TO_ACCESS_THIS_ORGANIZATION:\n\t\t\"You are not allowed to access this organization as an owner\",\n\tYOU_ARE_NOT_A_MEMBER_OF_THIS_ORGANIZATION:\n\t\t\"You are not a member of this organization\",\n\tMISSING_AC_INSTANCE:\n\t\t\"Dynamic Access Control requires a pre-defined ac instance on the server auth plugin. Read server logs for more information\",\n\tYOU_MUST_BE_IN_AN_ORGANIZATION_TO_CREATE_A_ROLE:\n\t\t\"You must be in an organization to create a role\",\n\tYOU_ARE_NOT_ALLOWED_TO_CREATE_A_ROLE: \"You are not allowed to create a role\",\n\tYOU_ARE_NOT_ALLOWED_TO_UPDATE_A_ROLE: \"You are not allowed to update a role\",\n\tYOU_ARE_NOT_ALLOWED_TO_DELETE_A_ROLE: \"You are not allowed to delete a role\",\n\tYOU_ARE_NOT_ALLOWED_TO_READ_A_ROLE: \"You are not allowed to read a role\",\n\tYOU_ARE_NOT_ALLOWED_TO_LIST_A_ROLE: \"You are not allowed to list a role\",\n\tYOU_ARE_NOT_ALLOWED_TO_GET_A_ROLE: \"You are not allowed to get a role\",\n\tTOO_MANY_ROLES: \"This organization has too many roles\",\n\tINVALID_RESOURCE: \"The provided permission includes an invalid resource\",\n\tROLE_NAME_IS_ALREADY_TAKEN: \"That role name is already taken\",\n\tCANNOT_DELETE_A_PRE_DEFINED_ROLE: \"Cannot delete a pre-defined role\",\n});\n"],"mappings":";;;AAEA,MAAa,2BAA2B,iBAAiB;CACxD,kDACC;CACD,sDACC;CACD,6BAA6B;CAC7B,iCAAiC;CACjC,wBAAwB;CACxB,0CACC;CACD,iDACC;CACD,iDACC;CACD,wBAAwB;CACxB,+CACC;CACD,kBAAkB;CAClB,gBAAgB;CAChB,0CACC;CACD,qBAAqB;CACrB,gBAAgB;CAChB,qDACC;CACD,oDACC;CACD,2CACC;CACD,0DACC;CACD,8CACC;CACD,sBAAsB;CACtB,6CACC;CACD,sEACC;CACD,+CACC;CACD,mDACC;CACD,mDACC;CACD,+BAA+B;CAC/B,8CACC;CACD,4BAA4B;CAC5B,2CACC;CACD,uCACC;CACD,0DACC;CACD,0DACC;CACD,yCACC;CACD,yCACC;CACD,0BAA0B;CAC1B,2BAA2B;CAC3B,kCAAkC;CAClC,6CACC;CACD,gCAAgC;CAChC,iDACC;CACD,6CACC;CACD,iDACC;CACD,2CACC;CACD,qBACC;CACD,iDACC;CACD,sCAAsC;CACtC,sCAAsC;CACtC,sCAAsC;CACtC,oCAAoC;CACpC,oCAAoC;CACpC,mCAAmC;CACnC,gBAAgB;CAChB,kBAAkB;CAClB,4BAA4B;CAC5B,kCAAkC;CAClC,CAAC"}
1
+ {"version":3,"file":"error-codes.mjs","names":[],"sources":["../../../src/plugins/organization/error-codes.ts"],"sourcesContent":["import { defineErrorCodes } from \"@better-auth/core/utils\";\n\nexport const ORGANIZATION_ERROR_CODES = defineErrorCodes({\n\tYOU_ARE_NOT_ALLOWED_TO_CREATE_A_NEW_ORGANIZATION:\n\t\t\"You are not allowed to create a new organization\",\n\tYOU_HAVE_REACHED_THE_MAXIMUM_NUMBER_OF_ORGANIZATIONS:\n\t\t\"You have reached the maximum number of organizations\",\n\tORGANIZATION_ALREADY_EXISTS: \"Organization already exists\",\n\tORGANIZATION_SLUG_ALREADY_TAKEN: \"Organization slug already taken\",\n\tORGANIZATION_NOT_FOUND: \"Organization not found\",\n\tUSER_IS_NOT_A_MEMBER_OF_THE_ORGANIZATION:\n\t\t\"User is not a member of the organization\",\n\tYOU_ARE_NOT_ALLOWED_TO_UPDATE_THIS_ORGANIZATION:\n\t\t\"You are not allowed to update this organization\",\n\tYOU_ARE_NOT_ALLOWED_TO_DELETE_THIS_ORGANIZATION:\n\t\t\"You are not allowed to delete this organization\",\n\tNO_ACTIVE_ORGANIZATION: \"No active organization\",\n\tUSER_IS_ALREADY_A_MEMBER_OF_THIS_ORGANIZATION:\n\t\t\"User is already a member of this organization\",\n\tMEMBER_NOT_FOUND: \"Member not found\",\n\tROLE_NOT_FOUND: \"Role not found\",\n\tYOU_ARE_NOT_ALLOWED_TO_CREATE_A_NEW_TEAM:\n\t\t\"You are not allowed to create a new team\",\n\tTEAM_ALREADY_EXISTS: \"Team already exists\",\n\tTEAM_NOT_FOUND: \"Team not found\",\n\tYOU_CANNOT_LEAVE_THE_ORGANIZATION_AS_THE_ONLY_OWNER:\n\t\t\"You cannot leave the organization as the only owner\",\n\tYOU_CANNOT_LEAVE_THE_ORGANIZATION_WITHOUT_AN_OWNER:\n\t\t\"You cannot leave the organization without an owner\",\n\tYOU_ARE_NOT_ALLOWED_TO_DELETE_THIS_MEMBER:\n\t\t\"You are not allowed to delete this member\",\n\tYOU_ARE_NOT_ALLOWED_TO_INVITE_USERS_TO_THIS_ORGANIZATION:\n\t\t\"You are not allowed to invite users to this organization\",\n\tUSER_IS_ALREADY_INVITED_TO_THIS_ORGANIZATION:\n\t\t\"User is already invited to this organization\",\n\tINVITATION_NOT_FOUND: \"Invitation not found\",\n\tYOU_ARE_NOT_THE_RECIPIENT_OF_THE_INVITATION:\n\t\t\"You are not the recipient of the invitation\",\n\tEMAIL_VERIFICATION_REQUIRED_BEFORE_ACCEPTING_OR_REJECTING_INVITATION:\n\t\t\"Email verification required before accepting or rejecting invitation\",\n\tYOU_ARE_NOT_ALLOWED_TO_CANCEL_THIS_INVITATION:\n\t\t\"You are not allowed to cancel this invitation\",\n\tINVITER_IS_NO_LONGER_A_MEMBER_OF_THE_ORGANIZATION:\n\t\t\"Inviter is no longer a member of the organization\",\n\tYOU_ARE_NOT_ALLOWED_TO_INVITE_USER_WITH_THIS_ROLE:\n\t\t\"You are not allowed to invite a user with this role\",\n\tFAILED_TO_RETRIEVE_INVITATION: \"Failed to retrieve invitation\",\n\tYOU_HAVE_REACHED_THE_MAXIMUM_NUMBER_OF_TEAMS:\n\t\t\"You have reached the maximum number of teams\",\n\tUNABLE_TO_REMOVE_LAST_TEAM: \"Unable to remove last team\",\n\tYOU_ARE_NOT_ALLOWED_TO_UPDATE_THIS_MEMBER:\n\t\t\"You are not allowed to update this member\",\n\tORGANIZATION_MEMBERSHIP_LIMIT_REACHED:\n\t\t\"Organization membership limit reached\",\n\tYOU_ARE_NOT_ALLOWED_TO_CREATE_TEAMS_IN_THIS_ORGANIZATION:\n\t\t\"You are not allowed to create teams in this organization\",\n\tYOU_ARE_NOT_ALLOWED_TO_DELETE_TEAMS_IN_THIS_ORGANIZATION:\n\t\t\"You are not allowed to delete teams in this organization\",\n\tYOU_ARE_NOT_ALLOWED_TO_UPDATE_THIS_TEAM:\n\t\t\"You are not allowed to update this team\",\n\tYOU_ARE_NOT_ALLOWED_TO_DELETE_THIS_TEAM:\n\t\t\"You are not allowed to delete this team\",\n\tINVITATION_LIMIT_REACHED: \"Invitation limit reached\",\n\tTEAM_MEMBER_LIMIT_REACHED: \"Team member limit reached\",\n\tUSER_IS_NOT_A_MEMBER_OF_THE_TEAM: \"User is not a member of the team\",\n\tYOU_CAN_NOT_ACCESS_THE_MEMBERS_OF_THIS_TEAM:\n\t\t\"You are not allowed to list the members of this team\",\n\tYOU_DO_NOT_HAVE_AN_ACTIVE_TEAM: \"You do not have an active team\",\n\tYOU_ARE_NOT_ALLOWED_TO_CREATE_A_NEW_TEAM_MEMBER:\n\t\t\"You are not allowed to create a new member\",\n\tYOU_ARE_NOT_ALLOWED_TO_REMOVE_A_TEAM_MEMBER:\n\t\t\"You are not allowed to remove a team member\",\n\tYOU_ARE_NOT_ALLOWED_TO_ACCESS_THIS_ORGANIZATION:\n\t\t\"You are not allowed to access this organization as an owner\",\n\tYOU_ARE_NOT_A_MEMBER_OF_THIS_ORGANIZATION:\n\t\t\"You are not a member of this organization\",\n\tMISSING_AC_INSTANCE:\n\t\t\"Dynamic Access Control requires a pre-defined ac instance on the server auth plugin. Read server logs for more information\",\n\tYOU_MUST_BE_IN_AN_ORGANIZATION_TO_CREATE_A_ROLE:\n\t\t\"You must be in an organization to create a role\",\n\tYOU_ARE_NOT_ALLOWED_TO_CREATE_A_ROLE: \"You are not allowed to create a role\",\n\tYOU_ARE_NOT_ALLOWED_TO_UPDATE_A_ROLE: \"You are not allowed to update a role\",\n\tYOU_ARE_NOT_ALLOWED_TO_DELETE_A_ROLE: \"You are not allowed to delete a role\",\n\tYOU_ARE_NOT_ALLOWED_TO_READ_A_ROLE: \"You are not allowed to read a role\",\n\tYOU_ARE_NOT_ALLOWED_TO_LIST_A_ROLE: \"You are not allowed to list a role\",\n\tYOU_ARE_NOT_ALLOWED_TO_GET_A_ROLE: \"You are not allowed to get a role\",\n\tTOO_MANY_ROLES: \"This organization has too many roles\",\n\tINVALID_RESOURCE: \"The provided permission includes an invalid resource\",\n\tROLE_NAME_IS_ALREADY_TAKEN: \"That role name is already taken\",\n\tCANNOT_DELETE_A_PRE_DEFINED_ROLE: \"Cannot delete a pre-defined role\",\n\tROLE_IS_ASSIGNED_TO_MEMBERS:\n\t\t\"Cannot delete a role that is assigned to members. Please reassign the members to a different role first\",\n});\n"],"mappings":";;;AAEA,MAAa,2BAA2B,iBAAiB;CACxD,kDACC;CACD,sDACC;CACD,6BAA6B;CAC7B,iCAAiC;CACjC,wBAAwB;CACxB,0CACC;CACD,iDACC;CACD,iDACC;CACD,wBAAwB;CACxB,+CACC;CACD,kBAAkB;CAClB,gBAAgB;CAChB,0CACC;CACD,qBAAqB;CACrB,gBAAgB;CAChB,qDACC;CACD,oDACC;CACD,2CACC;CACD,0DACC;CACD,8CACC;CACD,sBAAsB;CACtB,6CACC;CACD,sEACC;CACD,+CACC;CACD,mDACC;CACD,mDACC;CACD,+BAA+B;CAC/B,8CACC;CACD,4BAA4B;CAC5B,2CACC;CACD,uCACC;CACD,0DACC;CACD,0DACC;CACD,yCACC;CACD,yCACC;CACD,0BAA0B;CAC1B,2BAA2B;CAC3B,kCAAkC;CAClC,6CACC;CACD,gCAAgC;CAChC,iDACC;CACD,6CACC;CACD,iDACC;CACD,2CACC;CACD,qBACC;CACD,iDACC;CACD,sCAAsC;CACtC,sCAAsC;CACtC,sCAAsC;CACtC,oCAAoC;CACpC,oCAAoC;CACpC,mCAAmC;CACnC,gBAAgB;CAChB,kBAAkB;CAClB,4BAA4B;CAC5B,kCAAkC;CAClC,6BACC;CACD,CAAC"}
@@ -10,7 +10,7 @@ import { addMember, getActiveMember, getActiveMemberRole, leaveOrganization, lis
10
10
  import { checkOrganizationSlug, createOrganization, deleteOrganization, getFullOrganization, listOrganizations, setActiveOrganization, updateOrganization } from "./routes/crud-org.mjs";
11
11
  import { addTeamMember, createTeam, listOrganizationTeams, listTeamMembers, listUserTeams, removeTeam, removeTeamMember, setActiveTeam, updateTeam } from "./routes/crud-team.mjs";
12
12
  import * as _better_auth_core_db58 from "@better-auth/core/db";
13
- import * as better_call747 from "better-call";
13
+ import * as better_call759 from "better-call";
14
14
  import * as z from "zod";
15
15
 
16
16
  //#region src/plugins/organization/organization.d.ts
@@ -88,7 +88,7 @@ type OrganizationEndpoints<O extends OrganizationOptions> = {
88
88
  getActiveMemberRole: ReturnType<typeof getActiveMemberRole<O>>;
89
89
  hasPermission: ReturnType<typeof createHasPermission<O>>;
90
90
  };
91
- declare const createHasPermission: <O extends OrganizationOptions>(options: O) => better_call747.StrictEndpoint<"/organization/has-permission", {
91
+ declare const createHasPermission: <O extends OrganizationOptions>(options: O) => better_call759.StrictEndpoint<"/organization/has-permission", {
92
92
  method: "POST";
93
93
  requireHeaders: true;
94
94
  body: z.ZodIntersection<z.ZodObject<{
@@ -100,8 +100,8 @@ declare const createHasPermission: <O extends OrganizationOptions>(options: O) =
100
100
  permission: z.ZodUndefined;
101
101
  permissions: z.ZodRecord<z.ZodString, z.ZodArray<z.ZodString>>;
102
102
  }, z.core.$strip>]>>;
103
- use: ((inputContext: better_call747.MiddlewareInputContext<{
104
- use: ((inputContext: better_call747.MiddlewareInputContext<better_call747.MiddlewareOptions>) => Promise<{
103
+ use: ((inputContext: better_call759.MiddlewareInputContext<{
104
+ use: ((inputContext: better_call759.MiddlewareInputContext<better_call759.MiddlewareOptions>) => Promise<{
105
105
  session: {
106
106
  session: Record<string, any> & {
107
107
  id: string;
@@ -6,13 +6,13 @@ import { Statements, Subset } from "../../access/types.mjs";
6
6
  import { OrganizationOptions } from "../types.mjs";
7
7
  import { OrganizationRole } from "../schema.mjs";
8
8
  import "../../index.mjs";
9
- import * as _better_auth_core_db130 from "@better-auth/core/db";
10
- import * as better_call929 from "better-call";
9
+ import * as _better_auth_core_db123 from "@better-auth/core/db";
10
+ import * as better_call913 from "better-call";
11
11
  import * as z from "zod";
12
12
 
13
13
  //#region src/plugins/organization/routes/crud-access-control.d.ts
14
14
  type IsExactlyEmptyObject<T> = keyof T extends never ? T extends {} ? {} extends T ? true : false : false : false;
15
- declare const createOrgRole: <O extends OrganizationOptions>(options: O) => better_call929.StrictEndpoint<"/organization/create-role", {
15
+ declare const createOrgRole: <O extends OrganizationOptions>(options: O) => better_call913.StrictEndpoint<"/organization/create-role", {
16
16
  method: "POST";
17
17
  body: z.ZodObject<{
18
18
  organizationId: z.ZodOptional<z.ZodString>;
@@ -36,8 +36,8 @@ declare const createOrgRole: <O extends OrganizationOptions>(options: O) => bett
36
36
  };
37
37
  };
38
38
  requireHeaders: true;
39
- use: ((inputContext: better_call929.MiddlewareInputContext<{
40
- use: ((inputContext: better_call929.MiddlewareInputContext<better_call929.MiddlewareOptions>) => Promise<{
39
+ use: ((inputContext: better_call913.MiddlewareInputContext<{
40
+ use: ((inputContext: better_call913.MiddlewareInputContext<better_call913.MiddlewareOptions>) => Promise<{
41
41
  session: {
42
42
  session: Record<string, any> & {
43
43
  id: string;
@@ -62,7 +62,7 @@ declare const createOrgRole: <O extends OrganizationOptions>(options: O) => bett
62
62
  }>)[];
63
63
  }>) => Promise<{
64
64
  session: {
65
- session: _better_auth_core_db130.Session & {
65
+ session: _better_auth_core_db123.Session & {
66
66
  activeTeamId?: string | undefined;
67
67
  activeOrganizationId?: string | undefined;
68
68
  };
@@ -81,7 +81,7 @@ declare const createOrgRole: <O extends OrganizationOptions>(options: O) => bett
81
81
  } & InferAdditionalFieldsFromPluginOptions<"organizationRole", O, false>;
82
82
  statements: Subset<string, Statements>;
83
83
  }>;
84
- declare const deleteOrgRole: <O extends OrganizationOptions>(options: O) => better_call929.StrictEndpoint<"/organization/delete-role", {
84
+ declare const deleteOrgRole: <O extends OrganizationOptions>(options: O) => better_call913.StrictEndpoint<"/organization/delete-role", {
85
85
  method: "POST";
86
86
  body: z.ZodIntersection<z.ZodObject<{
87
87
  organizationId: z.ZodOptional<z.ZodString>;
@@ -91,8 +91,8 @@ declare const deleteOrgRole: <O extends OrganizationOptions>(options: O) => bett
91
91
  roleId: z.ZodString;
92
92
  }, z.core.$strip>]>>;
93
93
  requireHeaders: true;
94
- use: ((inputContext: better_call929.MiddlewareInputContext<{
95
- use: ((inputContext: better_call929.MiddlewareInputContext<better_call929.MiddlewareOptions>) => Promise<{
94
+ use: ((inputContext: better_call913.MiddlewareInputContext<{
95
+ use: ((inputContext: better_call913.MiddlewareInputContext<better_call913.MiddlewareOptions>) => Promise<{
96
96
  session: {
97
97
  session: Record<string, any> & {
98
98
  id: string;
@@ -117,7 +117,7 @@ declare const deleteOrgRole: <O extends OrganizationOptions>(options: O) => bett
117
117
  }>)[];
118
118
  }>) => Promise<{
119
119
  session: {
120
- session: _better_auth_core_db130.Session & {
120
+ session: _better_auth_core_db123.Session & {
121
121
  activeTeamId?: string | undefined;
122
122
  activeOrganizationId?: string | undefined;
123
123
  };
@@ -136,11 +136,11 @@ declare const deleteOrgRole: <O extends OrganizationOptions>(options: O) => bett
136
136
  }, {
137
137
  success: boolean;
138
138
  }>;
139
- declare const listOrgRoles: <O extends OrganizationOptions>(options: O) => better_call929.StrictEndpoint<"/organization/list-roles", {
139
+ declare const listOrgRoles: <O extends OrganizationOptions>(options: O) => better_call913.StrictEndpoint<"/organization/list-roles", {
140
140
  method: "GET";
141
141
  requireHeaders: true;
142
- use: ((inputContext: better_call929.MiddlewareInputContext<{
143
- use: ((inputContext: better_call929.MiddlewareInputContext<better_call929.MiddlewareOptions>) => Promise<{
142
+ use: ((inputContext: better_call913.MiddlewareInputContext<{
143
+ use: ((inputContext: better_call913.MiddlewareInputContext<better_call913.MiddlewareOptions>) => Promise<{
144
144
  session: {
145
145
  session: Record<string, any> & {
146
146
  id: string;
@@ -165,7 +165,7 @@ declare const listOrgRoles: <O extends OrganizationOptions>(options: O) => bette
165
165
  }>)[];
166
166
  }>) => Promise<{
167
167
  session: {
168
- session: _better_auth_core_db130.Session & {
168
+ session: _better_auth_core_db123.Session & {
169
169
  activeTeamId?: string | undefined;
170
170
  activeOrganizationId?: string | undefined;
171
171
  };
@@ -183,11 +183,11 @@ declare const listOrgRoles: <O extends OrganizationOptions>(options: O) => bette
183
183
  createdAt: Date;
184
184
  updatedAt?: Date | undefined;
185
185
  } & InferAdditionalFieldsFromPluginOptions<"organizationRole", O, false>)[]>;
186
- declare const getOrgRole: <O extends OrganizationOptions>(options: O) => better_call929.StrictEndpoint<"/organization/get-role", {
186
+ declare const getOrgRole: <O extends OrganizationOptions>(options: O) => better_call913.StrictEndpoint<"/organization/get-role", {
187
187
  method: "GET";
188
188
  requireHeaders: true;
189
- use: ((inputContext: better_call929.MiddlewareInputContext<{
190
- use: ((inputContext: better_call929.MiddlewareInputContext<better_call929.MiddlewareOptions>) => Promise<{
189
+ use: ((inputContext: better_call913.MiddlewareInputContext<{
190
+ use: ((inputContext: better_call913.MiddlewareInputContext<better_call913.MiddlewareOptions>) => Promise<{
191
191
  session: {
192
192
  session: Record<string, any> & {
193
193
  id: string;
@@ -212,7 +212,7 @@ declare const getOrgRole: <O extends OrganizationOptions>(options: O) => better_
212
212
  }>)[];
213
213
  }>) => Promise<{
214
214
  session: {
215
- session: _better_auth_core_db130.Session & {
215
+ session: _better_auth_core_db123.Session & {
216
216
  activeTeamId?: string | undefined;
217
217
  activeOrganizationId?: string | undefined;
218
218
  };
@@ -243,7 +243,7 @@ declare const getOrgRole: <O extends OrganizationOptions>(options: O) => better_
243
243
  createdAt: Date;
244
244
  updatedAt?: Date | undefined;
245
245
  } & InferAdditionalFieldsFromPluginOptions<"organizationRole", O, false>>;
246
- declare const updateOrgRole: <O extends OrganizationOptions>(options: O) => better_call929.StrictEndpoint<"/organization/update-role", {
246
+ declare const updateOrgRole: <O extends OrganizationOptions>(options: O) => better_call913.StrictEndpoint<"/organization/update-role", {
247
247
  method: "POST";
248
248
  body: z.ZodIntersection<z.ZodObject<{
249
249
  organizationId: z.ZodOptional<z.ZodString>;
@@ -270,8 +270,8 @@ declare const updateOrgRole: <O extends OrganizationOptions>(options: O) => bett
270
270
  };
271
271
  };
272
272
  requireHeaders: true;
273
- use: ((inputContext: better_call929.MiddlewareInputContext<{
274
- use: ((inputContext: better_call929.MiddlewareInputContext<better_call929.MiddlewareOptions>) => Promise<{
273
+ use: ((inputContext: better_call913.MiddlewareInputContext<{
274
+ use: ((inputContext: better_call913.MiddlewareInputContext<better_call913.MiddlewareOptions>) => Promise<{
275
275
  session: {
276
276
  session: Record<string, any> & {
277
277
  id: string;
@@ -296,7 +296,7 @@ declare const updateOrgRole: <O extends OrganizationOptions>(options: O) => bett
296
296
  }>)[];
297
297
  }>) => Promise<{
298
298
  session: {
299
- session: _better_auth_core_db130.Session & {
299
+ session: _better_auth_core_db123.Session & {
300
300
  activeTeamId?: string | undefined;
301
301
  activeOrganizationId?: string | undefined;
302
302
  };
@@ -248,6 +248,28 @@ const deleteOrgRole = (options) => {
248
248
  throw new APIError("BAD_REQUEST", { message: ORGANIZATION_ERROR_CODES.ROLE_NOT_FOUND });
249
249
  }
250
250
  existingRoleInDB.permission = JSON.parse(existingRoleInDB.permission);
251
+ const roleToDelete = existingRoleInDB.role;
252
+ if ((await ctx.context.adapter.findMany({
253
+ model: "member",
254
+ where: [{
255
+ field: "organizationId",
256
+ value: organizationId,
257
+ operator: "eq",
258
+ connector: "AND"
259
+ }, {
260
+ field: "role",
261
+ value: roleToDelete,
262
+ operator: "contains"
263
+ }]
264
+ })).find((member$1) => {
265
+ return member$1.role.split(",").map((r) => r.trim()).includes(roleToDelete);
266
+ })) {
267
+ ctx.context.logger.error(`[Dynamic Access Control] Cannot delete a role that is assigned to members.`, {
268
+ role: existingRoleInDB.role,
269
+ organizationId
270
+ });
271
+ throw new APIError("BAD_REQUEST", { message: ORGANIZATION_ERROR_CODES.ROLE_IS_ASSIGNED_TO_MEMBERS });
272
+ }
251
273
  await ctx.context.adapter.delete({
252
274
  model: "organizationRole",
253
275
  where: [{