@lupinum/better-convex-nuxt 0.8.0-beta.40
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/LICENSES/Apache-2.0.txt +201 -0
- package/README.md +151 -0
- package/THIRD_PARTY_NOTICES.md +38 -0
- package/dist/module.d.mts +55 -0
- package/dist/module.json +12 -0
- package/dist/module.mjs +309 -0
- package/dist/runtime/auth/auth-identity.d.ts +31 -0
- package/dist/runtime/auth/auth-identity.js +21 -0
- package/dist/runtime/auth/better-auth-browser-adapter.d.ts +33 -0
- package/dist/runtime/auth/better-auth-browser-adapter.js +215 -0
- package/dist/runtime/auth/client-engine-types.d.ts +4 -0
- package/dist/runtime/auth/client-engine-types.js +0 -0
- package/dist/runtime/auth/integrated-client.d.ts +25 -0
- package/dist/runtime/auth/integrated-client.js +132 -0
- package/dist/runtime/auth/operation-tracker.d.ts +7 -0
- package/dist/runtime/auth/operation-tracker.js +14 -0
- package/dist/runtime/auth/session-synchronization.d.ts +23 -0
- package/dist/runtime/auth/session-synchronization.js +156 -0
- package/dist/runtime/auth/token-fetcher.d.ts +66 -0
- package/dist/runtime/auth/token-fetcher.js +131 -0
- package/dist/runtime/auth/validate-auth-client-definition.d.ts +12 -0
- package/dist/runtime/auth/validate-auth-client-definition.js +47 -0
- package/dist/runtime/auth-client/convex-client-plugin.d.ts +31 -0
- package/dist/runtime/auth-client/convex-client-plugin.js +14 -0
- package/dist/runtime/auth-client/definition-types.d.ts +6 -0
- package/dist/runtime/auth-client/definition-types.js +0 -0
- package/dist/runtime/auth-client/empty-definition.d.ts +2 -0
- package/dist/runtime/auth-client/empty-definition.js +2 -0
- package/dist/runtime/auth-client/index.d.ts +71 -0
- package/dist/runtime/auth-client/index.js +3 -0
- package/dist/runtime/cli/auth-schema.d.ts +2 -0
- package/dist/runtime/cli/auth-schema.js +169 -0
- package/dist/runtime/cli/convex.d.ts +11 -0
- package/dist/runtime/cli/convex.js +274 -0
- package/dist/runtime/composables/useConvex.d.ts +4 -0
- package/dist/runtime/composables/useConvex.js +9 -0
- package/dist/runtime/composables/useConvexAction.d.ts +4 -0
- package/dist/runtime/composables/useConvexAction.js +18 -0
- package/dist/runtime/composables/useConvexAttachment.d.ts +9 -0
- package/dist/runtime/composables/useConvexAttachment.js +14 -0
- package/dist/runtime/composables/useConvexAuth.d.ts +10 -0
- package/dist/runtime/composables/useConvexAuth.js +37 -0
- package/dist/runtime/composables/useConvexConfig.d.ts +12 -0
- package/dist/runtime/composables/useConvexConfig.js +7 -0
- package/dist/runtime/composables/useConvexConnectionState.d.ts +33 -0
- package/dist/runtime/composables/useConvexConnectionState.js +24 -0
- package/dist/runtime/composables/useConvexFileUpload.d.ts +169 -0
- package/dist/runtime/composables/useConvexFileUpload.js +198 -0
- package/dist/runtime/composables/useConvexMutation.d.ts +13 -0
- package/dist/runtime/composables/useConvexMutation.js +24 -0
- package/dist/runtime/composables/useConvexPaginatedQuery.d.ts +13 -0
- package/dist/runtime/composables/useConvexPaginatedQuery.js +256 -0
- package/dist/runtime/composables/useConvexQuery.d.ts +19 -0
- package/dist/runtime/composables/useConvexQuery.js +308 -0
- package/dist/runtime/convex-auth/adapter/create-adapter.d.ts +33 -0
- package/dist/runtime/convex-auth/adapter/create-adapter.js +308 -0
- package/dist/runtime/convex-auth/adapter/define-functions.d.ts +160 -0
- package/dist/runtime/convex-auth/adapter/define-functions.js +497 -0
- package/dist/runtime/convex-auth/adapter/generate-schema.d.ts +16 -0
- package/dist/runtime/convex-auth/adapter/generate-schema.js +332 -0
- package/dist/runtime/convex-auth/adapter/metadata.d.ts +44 -0
- package/dist/runtime/convex-auth/adapter/metadata.js +91 -0
- package/dist/runtime/convex-auth/adapter/query.d.ts +32 -0
- package/dist/runtime/convex-auth/adapter/query.js +275 -0
- package/dist/runtime/convex-auth/adapter/relationships.d.ts +20 -0
- package/dist/runtime/convex-auth/adapter/relationships.js +128 -0
- package/dist/runtime/convex-auth/component/_generated/api.js +5 -0
- package/dist/runtime/convex-auth/component/_generated/component.d.ts +116 -0
- package/dist/runtime/convex-auth/component/_generated/component.js +0 -0
- package/dist/runtime/convex-auth/component/_generated/dataModel.js +0 -0
- package/dist/runtime/convex-auth/component/_generated/server.js +16 -0
- package/dist/runtime/convex-auth/component/adapter.d.ts +142 -0
- package/dist/runtime/convex-auth/component/adapter.js +16 -0
- package/dist/runtime/convex-auth/component/convex.config.d.ts +2 -0
- package/dist/runtime/convex-auth/component/convex.config.js +3 -0
- package/dist/runtime/convex-auth/component/schema.d.ts +799 -0
- package/dist/runtime/convex-auth/component/schema.js +180 -0
- package/dist/runtime/convex-auth/component/schemaMetadata.d.ts +2094 -0
- package/dist/runtime/convex-auth/component/schemaMetadata.js +2161 -0
- package/dist/runtime/convex-auth/context.d.ts +5 -0
- package/dist/runtime/convex-auth/context.js +8 -0
- package/dist/runtime/convex-auth/create-auth-component.d.ts +41 -0
- package/dist/runtime/convex-auth/create-auth-component.js +157 -0
- package/dist/runtime/convex-auth/index.d.ts +11 -0
- package/dist/runtime/convex-auth/index.js +7 -0
- package/dist/runtime/convex-auth/internal-session.d.ts +2 -0
- package/dist/runtime/convex-auth/internal-session.js +1 -0
- package/dist/runtime/convex-auth/jwks-rotation.d.ts +58 -0
- package/dist/runtime/convex-auth/jwks-rotation.js +163 -0
- package/dist/runtime/convex-auth/oauth-live-access.d.ts +17 -0
- package/dist/runtime/convex-auth/oauth-live-access.js +78 -0
- package/dist/runtime/convex-auth/oauth-provider-compat.d.ts +10 -0
- package/dist/runtime/convex-auth/oauth-provider-compat.js +170 -0
- package/dist/runtime/convex-auth/oauth-resource.d.ts +39 -0
- package/dist/runtime/convex-auth/oauth-resource.js +118 -0
- package/dist/runtime/convex-auth/oauth-security.d.ts +82 -0
- package/dist/runtime/convex-auth/oauth-security.js +454 -0
- package/dist/runtime/convex-auth/origin.d.ts +4 -0
- package/dist/runtime/convex-auth/origin.js +9 -0
- package/dist/runtime/convex-auth/plugin.d.ts +18 -0
- package/dist/runtime/convex-auth/plugin.js +605 -0
- package/dist/runtime/convex-auth/provider.d.ts +2 -0
- package/dist/runtime/convex-auth/provider.js +11 -0
- package/dist/runtime/convex-auth/test.d.ts +410 -0
- package/dist/runtime/convex-auth/test.js +9 -0
- package/dist/runtime/convex-auth/types.d.ts +18 -0
- package/dist/runtime/convex-auth/types.js +0 -0
- package/dist/runtime/convex-auth/user-projection.d.ts +106 -0
- package/dist/runtime/convex-auth/user-projection.js +128 -0
- package/dist/runtime/devtools/auth-proxy-registry.d.ts +4 -0
- package/dist/runtime/devtools/auth-proxy-registry.js +47 -0
- package/dist/runtime/devtools/bridge-setup.d.ts +21 -0
- package/dist/runtime/devtools/bridge-setup.js +165 -0
- package/dist/runtime/devtools/path-utils.d.ts +2 -0
- package/dist/runtime/devtools/path-utils.js +12 -0
- package/dist/runtime/devtools/server.d.ts +2 -0
- package/dist/runtime/devtools/server.js +108 -0
- package/dist/runtime/devtools/setup-client.d.ts +16 -0
- package/dist/runtime/devtools/setup-client.js +43 -0
- package/dist/runtime/devtools/sink.d.ts +18 -0
- package/dist/runtime/devtools/sink.js +110 -0
- package/dist/runtime/devtools/transport.d.ts +16 -0
- package/dist/runtime/devtools/transport.js +149 -0
- package/dist/runtime/devtools/types.d.ts +167 -0
- package/dist/runtime/devtools/types.js +1 -0
- package/dist/runtime/devtools/ui/dist/200.html +1 -0
- package/dist/runtime/devtools/ui/dist/404.html +1 -0
- package/dist/runtime/devtools/ui/dist/_nuxt/C4MASuCh.js +1 -0
- package/dist/runtime/devtools/ui/dist/_nuxt/DJHkqtZq.js +3 -0
- package/dist/runtime/devtools/ui/dist/_nuxt/DWwrCltl.js +2 -0
- package/dist/runtime/devtools/ui/dist/_nuxt/DZ_UiYoH.js +1 -0
- package/dist/runtime/devtools/ui/dist/_nuxt/_m9ujb-i.js +1 -0
- package/dist/runtime/devtools/ui/dist/_nuxt/builds/latest.json +1 -0
- package/dist/runtime/devtools/ui/dist/_nuxt/builds/meta/better-convex-nuxt-devtools.json +1 -0
- package/dist/runtime/devtools/ui/dist/_nuxt/entry.DpFDKYZ5.css +1 -0
- package/dist/runtime/devtools/ui/dist/_nuxt/error-404.DYUJo5xt.css +1 -0
- package/dist/runtime/devtools/ui/dist/_nuxt/error-500.DQdoJJXg.css +1 -0
- package/dist/runtime/devtools/ui/dist/convex-logo.svg +5 -0
- package/dist/runtime/devtools/ui/dist/index.html +1 -0
- package/dist/runtime/errors/index.d.ts +7 -0
- package/dist/runtime/errors/index.js +5 -0
- package/dist/runtime/middleware/convex-auth.global.d.ts +2 -0
- package/dist/runtime/middleware/convex-auth.global.js +31 -0
- package/dist/runtime/plugin.auth.client.d.ts +3 -0
- package/dist/runtime/plugin.auth.client.js +217 -0
- package/dist/runtime/plugin.client.d.ts +3 -0
- package/dist/runtime/plugin.client.js +43 -0
- package/dist/runtime/plugin.server.d.ts +12 -0
- package/dist/runtime/plugin.server.js +98 -0
- package/dist/runtime/plugins/convex-call-error-payload.d.ts +14 -0
- package/dist/runtime/plugins/convex-call-error-payload.js +12 -0
- package/dist/runtime/runtime-context.d.ts +26 -0
- package/dist/runtime/runtime-context.js +48 -0
- package/dist/runtime/server/api/auth/[...].d.ts +10 -0
- package/dist/runtime/server/api/auth/[...].js +509 -0
- package/dist/runtime/server/api/auth/authorization-server-metadata.d.ts +2 -0
- package/dist/runtime/server/api/auth/authorization-server-metadata.js +6 -0
- package/dist/runtime/server/api/auth/body-size.d.ts +15 -0
- package/dist/runtime/server/api/auth/body-size.js +179 -0
- package/dist/runtime/server/api/auth/headers.d.ts +6 -0
- package/dist/runtime/server/api/auth/headers.js +98 -0
- package/dist/runtime/server/api/auth/jwks.d.ts +2 -0
- package/dist/runtime/server/api/auth/jwks.js +6 -0
- package/dist/runtime/server/api/auth/security.d.ts +14 -0
- package/dist/runtime/server/api/auth/security.js +85 -0
- package/dist/runtime/server/api/release-fingerprint.d.ts +2 -0
- package/dist/runtime/server/api/release-fingerprint.js +36 -0
- package/dist/runtime/server/index.d.ts +1 -0
- package/dist/runtime/server/index.js +3 -0
- package/dist/runtime/server/plugins/runtime-config.d.ts +7 -0
- package/dist/runtime/server/plugins/runtime-config.js +7 -0
- package/dist/runtime/server/utils/auth-snapshot.d.ts +26 -0
- package/dist/runtime/server/utils/auth-snapshot.js +165 -0
- package/dist/runtime/server/utils/http.d.ts +16 -0
- package/dist/runtime/server/utils/http.js +133 -0
- package/dist/runtime/server/utils/server-convex-caller.d.ts +31 -0
- package/dist/runtime/server/utils/server-convex-caller.js +151 -0
- package/dist/runtime/server/utils/server-convex-options.d.ts +83 -0
- package/dist/runtime/server/utils/server-convex-options.js +69 -0
- package/dist/runtime/server/utils/signed-client-ip.d.ts +6 -0
- package/dist/runtime/server/utils/signed-client-ip.js +29 -0
- package/dist/runtime/server/utils/ssr-auth-headers.d.ts +26 -0
- package/dist/runtime/server/utils/ssr-auth-headers.js +49 -0
- package/dist/runtime/server/utils/token-exchange.d.ts +27 -0
- package/dist/runtime/server/utils/token-exchange.js +96 -0
- package/dist/runtime/shared/auth-cookie.d.ts +4 -0
- package/dist/runtime/shared/auth-cookie.js +25 -0
- package/dist/runtime/shared/auth-origin.d.ts +15 -0
- package/dist/runtime/shared/auth-origin.js +42 -0
- package/dist/runtime/shared/bounded-stream.d.ts +2 -0
- package/dist/runtime/shared/bounded-stream.js +50 -0
- package/dist/runtime/shared/client-ip.d.ts +21 -0
- package/dist/runtime/shared/client-ip.js +123 -0
- package/dist/runtime/shared/release-fingerprint.d.ts +5 -0
- package/dist/runtime/shared/release-fingerprint.js +17 -0
- package/dist/runtime/types.d.ts +19 -0
- package/dist/runtime/utils/auth-config.d.ts +24 -0
- package/dist/runtime/utils/auth-config.js +45 -0
- package/dist/runtime/utils/auth-contract.d.ts +22 -0
- package/dist/runtime/utils/auth-contract.js +0 -0
- package/dist/runtime/utils/auth-errors.d.ts +5 -0
- package/dist/runtime/utils/auth-errors.js +22 -0
- package/dist/runtime/utils/auth-identity-state.d.ts +4 -0
- package/dist/runtime/utils/auth-identity-state.js +8 -0
- package/dist/runtime/utils/auth-pending-state.d.ts +13 -0
- package/dist/runtime/utils/auth-pending-state.js +4 -0
- package/dist/runtime/utils/auth-pending.d.ts +10 -0
- package/dist/runtime/utils/auth-pending.js +30 -0
- package/dist/runtime/utils/auth-route-protection.d.ts +16 -0
- package/dist/runtime/utils/auth-route-protection.js +58 -0
- package/dist/runtime/utils/auth-status.d.ts +47 -0
- package/dist/runtime/utils/auth-status.js +8 -0
- package/dist/runtime/utils/bounded-convex-fetch.d.ts +18 -0
- package/dist/runtime/utils/bounded-convex-fetch.js +152 -0
- package/dist/runtime/utils/callable-devtools.d.ts +17 -0
- package/dist/runtime/utils/callable-devtools.js +49 -0
- package/dist/runtime/utils/callable-observer.d.ts +2 -0
- package/dist/runtime/utils/callable-observer.js +1 -0
- package/dist/runtime/utils/composable-scope.d.ts +2 -0
- package/dist/runtime/utils/composable-scope.js +8 -0
- package/dist/runtime/utils/config-defaults.d.ts +8 -0
- package/dist/runtime/utils/config-defaults.js +8 -0
- package/dist/runtime/utils/convex-cache.d.ts +68 -0
- package/dist/runtime/utils/convex-cache.js +47 -0
- package/dist/runtime/utils/convex-config.d.ts +16 -0
- package/dist/runtime/utils/convex-config.js +50 -0
- package/dist/runtime/utils/convex-shared.d.ts +67 -0
- package/dist/runtime/utils/convex-shared.js +134 -0
- package/dist/runtime/utils/identity-changed-error.d.ts +4 -0
- package/dist/runtime/utils/identity-changed-error.js +12 -0
- package/dist/runtime/utils/identity-key.d.ts +19 -0
- package/dist/runtime/utils/identity-key.js +10 -0
- package/dist/runtime/utils/integrated-auth-client.d.ts +5 -0
- package/dist/runtime/utils/integrated-auth-client.js +0 -0
- package/dist/runtime/utils/logger.d.ts +42 -0
- package/dist/runtime/utils/logger.js +190 -0
- package/dist/runtime/utils/mime-type.d.ts +33 -0
- package/dist/runtime/utils/mime-type.js +10 -0
- package/dist/runtime/utils/query-execution-gate.d.ts +47 -0
- package/dist/runtime/utils/query-execution-gate.js +63 -0
- package/dist/runtime/utils/query-execution.d.ts +8 -0
- package/dist/runtime/utils/query-execution.js +19 -0
- package/dist/runtime/utils/query-foundation.d.ts +20 -0
- package/dist/runtime/utils/query-foundation.js +39 -0
- package/dist/runtime/utils/query-state.d.ts +12 -0
- package/dist/runtime/utils/query-state.js +12 -0
- package/dist/runtime/utils/reactive-args.d.ts +5 -0
- package/dist/runtime/utils/reactive-args.js +42 -0
- package/dist/runtime/utils/runtime-config-normalize.d.ts +22 -0
- package/dist/runtime/utils/runtime-config-normalize.js +28 -0
- package/dist/runtime/utils/runtime-config.d.ts +4 -0
- package/dist/runtime/utils/runtime-config.js +8 -0
- package/dist/runtime/utils/sanitize-diagnostic.d.ts +6 -0
- package/dist/runtime/utils/sanitize-diagnostic.js +81 -0
- package/dist/runtime/utils/shared-helpers.d.ts +46 -0
- package/dist/runtime/utils/shared-helpers.js +139 -0
- package/dist/runtime/utils/site-url.d.ts +4 -0
- package/dist/runtime/utils/site-url.js +15 -0
- package/dist/runtime/utils/ssr-pagination-state.d.ts +3 -0
- package/dist/runtime/utils/ssr-pagination-state.js +3 -0
- package/dist/runtime/utils/types.d.ts +29 -0
- package/dist/runtime/utils/types.js +0 -0
- package/dist/runtime/utils/upload-core.d.ts +16 -0
- package/dist/runtime/utils/upload-core.js +116 -0
- package/dist/types.d.mts +21 -0
- package/package.json +253 -0
- package/security/upstream-convex-better-auth.json +477 -0
|
@@ -0,0 +1,454 @@
|
|
|
1
|
+
import { readStreamWithByteLimit } from "../shared/bounded-stream.js";
|
|
2
|
+
const OAUTH_CONFIG_ERROR = "AUTH_OAUTH_CONFIG_INVALID";
|
|
3
|
+
const OAUTH_REQUEST_ERROR = "AUTH_OAUTH_REQUEST_INVALID";
|
|
4
|
+
const OAUTH_TOKEN_ERROR = "AUTH_OAUTH_TOKEN_INVALID";
|
|
5
|
+
const FORBIDDEN_SCOPES = /* @__PURE__ */ new Set(["email", "offline_access", "openid", "profile"]);
|
|
6
|
+
const SCOPE_PATTERN = /^[\w:./-]+$/;
|
|
7
|
+
const TOKEN_CLAIMS = /* @__PURE__ */ new Set([
|
|
8
|
+
"aud",
|
|
9
|
+
"azp",
|
|
10
|
+
"client_id",
|
|
11
|
+
"exp",
|
|
12
|
+
"iat",
|
|
13
|
+
"iss",
|
|
14
|
+
"jti",
|
|
15
|
+
"scope",
|
|
16
|
+
"sid",
|
|
17
|
+
"sub",
|
|
18
|
+
"token_use"
|
|
19
|
+
]);
|
|
20
|
+
const PINNED_OAUTH_PROVIDER_KEYS = [
|
|
21
|
+
"accessTokenExpiresIn",
|
|
22
|
+
"allowDynamicClientRegistration",
|
|
23
|
+
"allowPublicClientPrelogin",
|
|
24
|
+
"allowUnauthenticatedClientRegistration",
|
|
25
|
+
"advertisedMetadata",
|
|
26
|
+
"clientCredentialGrantDefaultScopes",
|
|
27
|
+
"clientPrivileges",
|
|
28
|
+
"clientRegistrationRequirePKCE",
|
|
29
|
+
"codeExpiresIn",
|
|
30
|
+
"consentPage",
|
|
31
|
+
"customAccessTokenClaims",
|
|
32
|
+
"customIdTokenClaims",
|
|
33
|
+
"customTokenResponseFields",
|
|
34
|
+
"customUserInfoClaims",
|
|
35
|
+
"disableJwtPlugin",
|
|
36
|
+
"dpop",
|
|
37
|
+
"enforcePerClientResources",
|
|
38
|
+
"extensions",
|
|
39
|
+
"grantTypes",
|
|
40
|
+
"loginPage",
|
|
41
|
+
"m2mAccessTokenExpiresIn",
|
|
42
|
+
"pairwiseSecret",
|
|
43
|
+
"rateLimit",
|
|
44
|
+
"requestUriResolver",
|
|
45
|
+
"resourcePrivileges",
|
|
46
|
+
"resources",
|
|
47
|
+
"scopes",
|
|
48
|
+
"storeClientSecret",
|
|
49
|
+
"storeTokens",
|
|
50
|
+
"validateInitialAccessToken"
|
|
51
|
+
];
|
|
52
|
+
const PINNED_OAUTH_PROVIDER_KEY_SET = new Set(PINNED_OAUTH_PROVIDER_KEYS);
|
|
53
|
+
const hardenedProfiles = /* @__PURE__ */ new WeakMap();
|
|
54
|
+
export class OAuthSecurityError extends Error {
|
|
55
|
+
code;
|
|
56
|
+
constructor(code) {
|
|
57
|
+
super(code);
|
|
58
|
+
this.name = "OAuthSecurityError";
|
|
59
|
+
this.code = code;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
export function installUrlCanParseCompatibility(target = URL) {
|
|
63
|
+
if (typeof target.canParse === "function") return;
|
|
64
|
+
Object.defineProperty(target, "canParse", {
|
|
65
|
+
configurable: true,
|
|
66
|
+
value: (input, base) => {
|
|
67
|
+
try {
|
|
68
|
+
new URL(input, base);
|
|
69
|
+
return true;
|
|
70
|
+
} catch {
|
|
71
|
+
return false;
|
|
72
|
+
}
|
|
73
|
+
},
|
|
74
|
+
writable: true
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
function invalidConfig() {
|
|
78
|
+
throw new OAuthSecurityError(OAUTH_CONFIG_ERROR);
|
|
79
|
+
}
|
|
80
|
+
function invalidRequest() {
|
|
81
|
+
throw new OAuthSecurityError(OAUTH_REQUEST_ERROR);
|
|
82
|
+
}
|
|
83
|
+
function invalidToken() {
|
|
84
|
+
throw new OAuthSecurityError(OAUTH_TOKEN_ERROR);
|
|
85
|
+
}
|
|
86
|
+
function isRecord(value) {
|
|
87
|
+
return Boolean(value && typeof value === "object" && !Array.isArray(value));
|
|
88
|
+
}
|
|
89
|
+
function exactArray(value, expected) {
|
|
90
|
+
return Array.isArray(value) && value.length === expected.length && value.every((item, index) => item === expected[index]);
|
|
91
|
+
}
|
|
92
|
+
function emptyValue(value) {
|
|
93
|
+
if (value === void 0 || value === null || value === false) return true;
|
|
94
|
+
if (Array.isArray(value)) return value.length === 0;
|
|
95
|
+
if (isRecord(value)) return Object.keys(value).length === 0;
|
|
96
|
+
return false;
|
|
97
|
+
}
|
|
98
|
+
function validatePagePath(value) {
|
|
99
|
+
if (typeof value !== "string" || !value.startsWith("/") || value.startsWith("//") || value.includes("?") || value.includes("#")) {
|
|
100
|
+
invalidConfig();
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
export function validateOAuthScopes(scopes) {
|
|
104
|
+
if (!Array.isArray(scopes) || scopes.length === 0 || scopes.length > 64) invalidConfig();
|
|
105
|
+
const seen = /* @__PURE__ */ new Set();
|
|
106
|
+
for (const scope of scopes) {
|
|
107
|
+
if (typeof scope !== "string" || !SCOPE_PATTERN.test(scope) || FORBIDDEN_SCOPES.has(scope) || seen.has(scope)) {
|
|
108
|
+
invalidConfig();
|
|
109
|
+
}
|
|
110
|
+
seen.add(scope);
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
function validateRateLimit(value, expected) {
|
|
114
|
+
if (!isRecord(value) || value.max !== expected.max || value.window !== expected.window) {
|
|
115
|
+
invalidConfig();
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
function validateConfiguredResource(value, allowedScopes) {
|
|
119
|
+
if (typeof value === "string") {
|
|
120
|
+
validateResourceIdentifier(value);
|
|
121
|
+
return;
|
|
122
|
+
}
|
|
123
|
+
if (!isRecord(value)) invalidConfig();
|
|
124
|
+
assertSafeStoredOAuthResource(
|
|
125
|
+
{
|
|
126
|
+
accessTokenTtl: value.accessTokenTtl,
|
|
127
|
+
allowedScopes: value.allowedScopes,
|
|
128
|
+
customClaims: value.customClaims,
|
|
129
|
+
disabled: value.disabled,
|
|
130
|
+
dpopBoundAccessTokensRequired: value.dpopBoundAccessTokensRequired,
|
|
131
|
+
identifier: value.identifier,
|
|
132
|
+
name: typeof value.name === "string" ? value.name : "Configured resource",
|
|
133
|
+
refreshTokenTtl: value.refreshTokenTtl,
|
|
134
|
+
signingAlgorithm: value.signingAlgorithm,
|
|
135
|
+
signingKeyId: value.signingKeyId
|
|
136
|
+
},
|
|
137
|
+
allowedScopes
|
|
138
|
+
);
|
|
139
|
+
}
|
|
140
|
+
export function validateOAuthProviderProfile(options) {
|
|
141
|
+
if (!isRecord(options)) invalidConfig();
|
|
142
|
+
for (const key of Reflect.ownKeys(options)) {
|
|
143
|
+
if (typeof key !== "string" || !PINNED_OAUTH_PROVIDER_KEY_SET.has(key)) invalidConfig();
|
|
144
|
+
}
|
|
145
|
+
if (options.accessTokenExpiresIn !== 600 || options.codeExpiresIn !== 120 || options.allowDynamicClientRegistration !== false || options.allowPublicClientPrelogin !== true || options.allowUnauthenticatedClientRegistration !== false || options.enforcePerClientResources !== true || options.storeClientSecret !== "hashed" || options.storeTokens !== "hashed" || options.disableJwtPlugin === true || options.clientRegistrationRequirePKCE === false || !exactArray(options.grantTypes, ["authorization_code"]) || typeof options.clientPrivileges !== "function" || typeof options.resourcePrivileges !== "function" || typeof options.customAccessTokenClaims !== "function") {
|
|
146
|
+
invalidConfig();
|
|
147
|
+
}
|
|
148
|
+
validatePagePath(options.loginPage);
|
|
149
|
+
validatePagePath(options.consentPage);
|
|
150
|
+
validateOAuthScopes(options.scopes);
|
|
151
|
+
if (!isRecord(options.dpop) || !Array.isArray(options.dpop.signingAlgorithms) || options.dpop.signingAlgorithms.length !== 0) {
|
|
152
|
+
invalidConfig();
|
|
153
|
+
}
|
|
154
|
+
if (!isRecord(options.rateLimit)) invalidConfig();
|
|
155
|
+
validateRateLimit(options.rateLimit.token, { max: 20, window: 60 });
|
|
156
|
+
validateRateLimit(options.rateLimit.authorize, { max: 30, window: 60 });
|
|
157
|
+
validateRateLimit(options.rateLimit.revoke, { max: 30, window: 60 });
|
|
158
|
+
if (!emptyValue(options.extensions) || !emptyValue(options.validateInitialAccessToken) || !emptyValue(options.requestUriResolver) || !emptyValue(options.customIdTokenClaims) || !emptyValue(options.customUserInfoClaims) || !emptyValue(options.customTokenResponseFields) || !emptyValue(options.clientCredentialGrantDefaultScopes) || !emptyValue(options.pairwiseSecret) || options.m2mAccessTokenExpiresIn !== void 0) {
|
|
159
|
+
invalidConfig();
|
|
160
|
+
}
|
|
161
|
+
if (options.advertisedMetadata !== void 0) {
|
|
162
|
+
if (!isRecord(options.advertisedMetadata) || !emptyValue(options.advertisedMetadata.claims_supported) || options.advertisedMetadata.scopes_supported !== void 0 && !exactArray(options.advertisedMetadata.scopes_supported, options.scopes)) {
|
|
163
|
+
invalidConfig();
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
if (options.resources !== void 0 && !Array.isArray(options.resources)) invalidConfig();
|
|
167
|
+
for (const resource of options.resources ?? []) {
|
|
168
|
+
if (typeof resource !== "string" && !isRecord(resource)) invalidConfig();
|
|
169
|
+
validateConfiguredResource(resource, options.scopes);
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
async function runPrivilegeCallback(callback, context) {
|
|
173
|
+
if (!context || typeof context !== "object" || !context.user || !context.session) return false;
|
|
174
|
+
let timer;
|
|
175
|
+
try {
|
|
176
|
+
const result = await Promise.race([
|
|
177
|
+
Promise.resolve().then(() => callback(context)).catch(() => false),
|
|
178
|
+
new Promise((resolve) => {
|
|
179
|
+
timer = setTimeout(() => resolve(false), 500);
|
|
180
|
+
})
|
|
181
|
+
]);
|
|
182
|
+
return result === true;
|
|
183
|
+
} finally {
|
|
184
|
+
if (timer !== void 0) clearTimeout(timer);
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
export function hardenOAuthProviderCallbacks(options) {
|
|
188
|
+
validateOAuthProviderProfile(options);
|
|
189
|
+
const existing = hardenedProfiles.get(options);
|
|
190
|
+
if (existing) return existing;
|
|
191
|
+
const clientPrivileges = options.clientPrivileges;
|
|
192
|
+
const resourcePrivileges = options.resourcePrivileges;
|
|
193
|
+
const accessTokenClaims = options.customAccessTokenClaims;
|
|
194
|
+
const hardened = {
|
|
195
|
+
clientPrivileges: (context) => runPrivilegeCallback(clientPrivileges, context),
|
|
196
|
+
resourcePrivileges: (context) => runPrivilegeCallback(resourcePrivileges, context),
|
|
197
|
+
customAccessTokenClaims: async (info) => {
|
|
198
|
+
let claims;
|
|
199
|
+
try {
|
|
200
|
+
claims = await accessTokenClaims(info);
|
|
201
|
+
} catch {
|
|
202
|
+
invalidConfig();
|
|
203
|
+
}
|
|
204
|
+
if (!isRecord(claims) || Object.keys(claims).length !== 1 || claims.token_use !== "oauth-access") {
|
|
205
|
+
invalidConfig();
|
|
206
|
+
}
|
|
207
|
+
return { token_use: "oauth-access" };
|
|
208
|
+
}
|
|
209
|
+
};
|
|
210
|
+
try {
|
|
211
|
+
Object.assign(options, hardened);
|
|
212
|
+
} catch {
|
|
213
|
+
invalidConfig();
|
|
214
|
+
}
|
|
215
|
+
if (options.clientPrivileges !== hardened.clientPrivileges || options.resourcePrivileges !== hardened.resourcePrivileges || options.customAccessTokenClaims !== hardened.customAccessTokenClaims) {
|
|
216
|
+
invalidConfig();
|
|
217
|
+
}
|
|
218
|
+
hardenedProfiles.set(options, hardened);
|
|
219
|
+
return hardened;
|
|
220
|
+
}
|
|
221
|
+
export function validateResourceIdentifier(identifier) {
|
|
222
|
+
let url;
|
|
223
|
+
try {
|
|
224
|
+
url = new URL(identifier);
|
|
225
|
+
} catch {
|
|
226
|
+
invalidConfig();
|
|
227
|
+
}
|
|
228
|
+
if (url.protocol !== "https:" && url.protocol !== "http:" || url.hash || url.username || url.password || url.href !== identifier) {
|
|
229
|
+
invalidConfig();
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
function isLoopbackRedirectHost(hostname) {
|
|
233
|
+
return hostname === "localhost" || hostname === "127.0.0.1" || hostname === "[::1]";
|
|
234
|
+
}
|
|
235
|
+
export function validateOAuthRedirectUris(value) {
|
|
236
|
+
if (!Array.isArray(value) || value.length === 0 || value.length > 32) invalidConfig();
|
|
237
|
+
const seen = /* @__PURE__ */ new Set();
|
|
238
|
+
for (const redirectUri of value) {
|
|
239
|
+
if (typeof redirectUri !== "string" || seen.has(redirectUri) || redirectUri.includes("*") || redirectUri.includes("#")) {
|
|
240
|
+
invalidConfig();
|
|
241
|
+
}
|
|
242
|
+
let url;
|
|
243
|
+
try {
|
|
244
|
+
url = new URL(redirectUri);
|
|
245
|
+
} catch {
|
|
246
|
+
invalidConfig();
|
|
247
|
+
}
|
|
248
|
+
const loopbackHost = isLoopbackRedirectHost(url.hostname);
|
|
249
|
+
const fixedLoopback = url.protocol === "http:" && loopbackHost && url.port !== "" && Number.isSafeInteger(Number(url.port)) && Number(url.port) > 0 && Number(url.port) <= 65535;
|
|
250
|
+
if ((url.protocol === "https:" ? loopbackHost : !fixedLoopback) || url.hash || url.username || url.password || url.href !== redirectUri) {
|
|
251
|
+
invalidConfig();
|
|
252
|
+
}
|
|
253
|
+
seen.add(redirectUri);
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
function validateScopeSubset(value, allowedScopes, requireValue) {
|
|
257
|
+
if (!Array.isArray(value)) {
|
|
258
|
+
if (!requireValue && value === void 0) return;
|
|
259
|
+
invalidConfig();
|
|
260
|
+
}
|
|
261
|
+
if (requireValue && value.length === 0) invalidConfig();
|
|
262
|
+
const allowed = new Set(allowedScopes);
|
|
263
|
+
const seen = /* @__PURE__ */ new Set();
|
|
264
|
+
for (const scope of value) {
|
|
265
|
+
if (typeof scope !== "string" || !allowed.has(scope) || seen.has(scope)) invalidConfig();
|
|
266
|
+
seen.add(scope);
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
function assertNoHiddenClientMetadata(client) {
|
|
270
|
+
for (const field of [
|
|
271
|
+
"backchannelLogoutUri",
|
|
272
|
+
"backchannelLogoutSessionRequired",
|
|
273
|
+
"jwks",
|
|
274
|
+
"jwksUri",
|
|
275
|
+
"metadata",
|
|
276
|
+
"postLogoutRedirectUris",
|
|
277
|
+
"softwareStatement"
|
|
278
|
+
]) {
|
|
279
|
+
if (!emptyValue(client[field])) invalidConfig();
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
export function assertSafeStoredOAuthClient(client, allowedScopes) {
|
|
283
|
+
if (client.expiresAt !== void 0 && client.expiresAt !== null) {
|
|
284
|
+
const expiresAt = client.expiresAt instanceof Date ? client.expiresAt.getTime() : typeof client.expiresAt === "number" ? client.expiresAt : Number.NaN;
|
|
285
|
+
if (!Number.isFinite(expiresAt) || expiresAt <= Date.now()) invalidConfig();
|
|
286
|
+
}
|
|
287
|
+
const confidentialBasic = client.public === false && client.tokenEndpointAuthMethod === "client_secret_basic" && typeof client.clientSecret === "string" && client.clientSecret.length > 0 && (client.type === void 0 || client.type === "web");
|
|
288
|
+
const publicNone = client.public === true && client.tokenEndpointAuthMethod === "none" && (client.clientSecret === void 0 || client.clientSecret === null) && (client.type === void 0 || client.type === "native" || client.type === "user-agent-based");
|
|
289
|
+
if (typeof client.clientId !== "string" || client.clientId.length === 0 || client.disabled === true || !confidentialBasic && !publicNone || client.requirePKCE !== true || client.skipConsent !== false || client.enableEndSession !== false || client.dpopBoundAccessTokens !== false || client.subjectType !== void 0 && client.subjectType !== "public" || !exactArray(client.grantTypes, ["authorization_code"]) || !exactArray(client.responseTypes, ["code"])) {
|
|
290
|
+
invalidConfig();
|
|
291
|
+
}
|
|
292
|
+
validateScopeSubset(client.scopes, allowedScopes, true);
|
|
293
|
+
validateOAuthRedirectUris(client.redirectUris);
|
|
294
|
+
assertNoHiddenClientMetadata(client);
|
|
295
|
+
}
|
|
296
|
+
export function assertSafeStoredOAuthResource(resource, allowedScopes) {
|
|
297
|
+
if (typeof resource.identifier !== "string" || typeof resource.name !== "string" || resource.name.length === 0 || resource.disabled === true || resource.dpopBoundAccessTokensRequired === true || !emptyValue(resource.refreshTokenTtl) || !emptyValue(resource.signingKeyId) || !emptyValue(resource.customClaims) || resource.signingAlgorithm !== void 0 && resource.signingAlgorithm !== "RS256") {
|
|
298
|
+
invalidConfig();
|
|
299
|
+
}
|
|
300
|
+
validateResourceIdentifier(resource.identifier);
|
|
301
|
+
if (resource.accessTokenTtl !== void 0) {
|
|
302
|
+
if (!Number.isSafeInteger(resource.accessTokenTtl) || resource.accessTokenTtl <= 0 || resource.accessTokenTtl > 600) {
|
|
303
|
+
invalidConfig();
|
|
304
|
+
}
|
|
305
|
+
}
|
|
306
|
+
validateScopeSubset(resource.allowedScopes, allowedScopes, false);
|
|
307
|
+
}
|
|
308
|
+
export function assertSafeStoredOAuthClientResource(link, clientId, resourceId) {
|
|
309
|
+
if (link.id !== `${clientId}::${resourceId}` || link.clientId !== clientId || link.resourceId !== resourceId || !emptyValue(link.metadata)) {
|
|
310
|
+
invalidConfig();
|
|
311
|
+
}
|
|
312
|
+
}
|
|
313
|
+
export function assertSingleParameters(parameters, singletonFields) {
|
|
314
|
+
for (const field of singletonFields) {
|
|
315
|
+
if (parameters.getAll(field).length > 1) invalidRequest();
|
|
316
|
+
}
|
|
317
|
+
}
|
|
318
|
+
export function requireSingleParameter(parameters, field) {
|
|
319
|
+
const values = parameters.getAll(field);
|
|
320
|
+
if (values.length !== 1 || values[0] === "") invalidRequest();
|
|
321
|
+
return values[0];
|
|
322
|
+
}
|
|
323
|
+
export async function parseBoundedFormRequest(request, allowedFields, maxBytes = 16 * 1024) {
|
|
324
|
+
const parameters = await parseBoundedFormBody(request, maxBytes);
|
|
325
|
+
const allowed = new Set(allowedFields);
|
|
326
|
+
for (const field of parameters.keys()) {
|
|
327
|
+
if (!allowed.has(field)) invalidRequest();
|
|
328
|
+
}
|
|
329
|
+
assertSingleParameters(parameters, allowedFields);
|
|
330
|
+
return parameters;
|
|
331
|
+
}
|
|
332
|
+
export async function parseBoundedFormBody(request, maxBytes) {
|
|
333
|
+
const contentType = request.headers.get("content-type")?.split(";", 1)[0]?.trim().toLowerCase();
|
|
334
|
+
if (contentType !== "application/x-www-form-urlencoded") invalidRequest();
|
|
335
|
+
const contentLength = request.headers.get("content-length");
|
|
336
|
+
if (contentLength !== null) {
|
|
337
|
+
const bytes = Number(contentLength);
|
|
338
|
+
if (!Number.isSafeInteger(bytes) || bytes < 0 || bytes > maxBytes) invalidRequest();
|
|
339
|
+
}
|
|
340
|
+
const body = await readStreamWithByteLimit(
|
|
341
|
+
request.clone().body,
|
|
342
|
+
maxBytes,
|
|
343
|
+
() => new OAuthSecurityError(OAUTH_REQUEST_ERROR),
|
|
344
|
+
request.signal
|
|
345
|
+
);
|
|
346
|
+
return new URLSearchParams(new TextDecoder().decode(body ?? new Uint8Array()));
|
|
347
|
+
}
|
|
348
|
+
function metadataUrl(value, expected) {
|
|
349
|
+
if (value !== expected) invalidConfig();
|
|
350
|
+
let url;
|
|
351
|
+
try {
|
|
352
|
+
url = new URL(value);
|
|
353
|
+
} catch {
|
|
354
|
+
invalidConfig();
|
|
355
|
+
}
|
|
356
|
+
if (url.href !== expected) invalidConfig();
|
|
357
|
+
}
|
|
358
|
+
export function projectOAuthAuthorizationServerMetadata(officialMetadata, issuer, scopes) {
|
|
359
|
+
if (!isRecord(officialMetadata)) invalidConfig();
|
|
360
|
+
const expected = {
|
|
361
|
+
authorization_endpoint: `${issuer}/oauth2/authorize`,
|
|
362
|
+
issuer,
|
|
363
|
+
jwks_uri: `${issuer}/jwks`,
|
|
364
|
+
revocation_endpoint: `${issuer}/oauth2/revoke`,
|
|
365
|
+
token_endpoint: `${issuer}/oauth2/token`
|
|
366
|
+
};
|
|
367
|
+
for (const [field, value] of Object.entries(expected)) metadataUrl(officialMetadata[field], value);
|
|
368
|
+
const expectedOrigin = new URL(issuer).origin;
|
|
369
|
+
for (const [field, value] of Object.entries(officialMetadata)) {
|
|
370
|
+
if ((field.endsWith("_endpoint") || field.endsWith("_uri")) && typeof value === "string") {
|
|
371
|
+
let url;
|
|
372
|
+
try {
|
|
373
|
+
url = new URL(value);
|
|
374
|
+
} catch {
|
|
375
|
+
invalidConfig();
|
|
376
|
+
}
|
|
377
|
+
if (url.origin !== expectedOrigin) invalidConfig();
|
|
378
|
+
}
|
|
379
|
+
}
|
|
380
|
+
if (!exactArray(officialMetadata.scopes_supported, scopes) || !Array.isArray(officialMetadata.response_types_supported) || !officialMetadata.response_types_supported.includes("code") || !Array.isArray(officialMetadata.grant_types_supported) || !officialMetadata.grant_types_supported.includes("authorization_code") || !Array.isArray(officialMetadata.token_endpoint_auth_methods_supported) || !officialMetadata.token_endpoint_auth_methods_supported.includes("client_secret_basic") || !Array.isArray(officialMetadata.code_challenge_methods_supported) || !officialMetadata.code_challenge_methods_supported.includes("S256") || officialMetadata.authorization_response_iss_parameter_supported !== true) {
|
|
381
|
+
invalidConfig();
|
|
382
|
+
}
|
|
383
|
+
return Object.freeze({
|
|
384
|
+
issuer: expected.issuer,
|
|
385
|
+
authorization_endpoint: expected.authorization_endpoint,
|
|
386
|
+
token_endpoint: expected.token_endpoint,
|
|
387
|
+
jwks_uri: expected.jwks_uri,
|
|
388
|
+
revocation_endpoint: expected.revocation_endpoint,
|
|
389
|
+
scopes_supported: [...scopes],
|
|
390
|
+
response_types_supported: ["code"],
|
|
391
|
+
grant_types_supported: ["authorization_code"],
|
|
392
|
+
token_endpoint_auth_methods_supported: ["none", "client_secret_basic"],
|
|
393
|
+
code_challenge_methods_supported: ["S256"],
|
|
394
|
+
authorization_response_iss_parameter_supported: true
|
|
395
|
+
});
|
|
396
|
+
}
|
|
397
|
+
function requiredString(payload, field) {
|
|
398
|
+
const value = payload[field];
|
|
399
|
+
if (typeof value !== "string" || value.length === 0) invalidToken();
|
|
400
|
+
return value;
|
|
401
|
+
}
|
|
402
|
+
function requiredNumericDate(payload, field) {
|
|
403
|
+
const value = payload[field];
|
|
404
|
+
if (!Number.isSafeInteger(value) || value <= 0) invalidToken();
|
|
405
|
+
return value;
|
|
406
|
+
}
|
|
407
|
+
export function assertOAuthAccessTokenClaims(payload, expectations) {
|
|
408
|
+
return assertOAuthAccessTokenClaimsAt(
|
|
409
|
+
payload,
|
|
410
|
+
expectations,
|
|
411
|
+
Math.floor((/* @__PURE__ */ new Date()).getTime() / 1e3)
|
|
412
|
+
);
|
|
413
|
+
}
|
|
414
|
+
function assertOAuthAccessTokenClaimsAt(payload, expectations, now) {
|
|
415
|
+
if (!isRecord(payload)) invalidToken();
|
|
416
|
+
for (const claim of Object.keys(payload)) {
|
|
417
|
+
if (!TOKEN_CLAIMS.has(claim)) invalidToken();
|
|
418
|
+
}
|
|
419
|
+
const maxLifetime = expectations.maxLifetimeSeconds ?? 600;
|
|
420
|
+
if (!Number.isSafeInteger(maxLifetime) || maxLifetime <= 0 || maxLifetime > 600) invalidToken();
|
|
421
|
+
const issuer = requiredString(payload, "iss");
|
|
422
|
+
const subject = requiredString(payload, "sub");
|
|
423
|
+
const audience = requiredString(payload, "aud");
|
|
424
|
+
const clientId = requiredString(payload, "client_id");
|
|
425
|
+
const authorizedParty = requiredString(payload, "azp");
|
|
426
|
+
const sessionId = requiredString(payload, "sid");
|
|
427
|
+
requiredString(payload, "jti");
|
|
428
|
+
const issuedAt = requiredNumericDate(payload, "iat");
|
|
429
|
+
const expiresAt = requiredNumericDate(payload, "exp");
|
|
430
|
+
if (issuer !== expectations.issuer || audience !== expectations.audience || clientId !== authorizedParty || payload.token_use !== "oauth-access" || issuedAt > now || expiresAt <= now || expiresAt <= issuedAt || expiresAt - issuedAt > maxLifetime || expectations.clientId !== void 0 && clientId !== expectations.clientId || expectations.subject !== void 0 && subject !== expectations.subject) {
|
|
431
|
+
invalidToken();
|
|
432
|
+
}
|
|
433
|
+
const rawScope = requiredString(payload, "scope");
|
|
434
|
+
const scopes = rawScope.split(" ");
|
|
435
|
+
if (scopes.some((scope) => scope.length === 0) || new Set(scopes).size !== scopes.length) {
|
|
436
|
+
invalidToken();
|
|
437
|
+
}
|
|
438
|
+
const allowed = new Set(expectations.allowedScopes);
|
|
439
|
+
if (scopes.some((scope) => !allowed.has(scope))) invalidToken();
|
|
440
|
+
for (const required of expectations.requiredScopes ?? []) {
|
|
441
|
+
if (!allowed.has(required) || !scopes.includes(required)) invalidToken();
|
|
442
|
+
}
|
|
443
|
+
return Object.freeze({ clientId, expiresAt, scopes, sessionId, subject });
|
|
444
|
+
}
|
|
445
|
+
export function prepareOAuthAccessTokenVerification(expectations) {
|
|
446
|
+
const currentDate = /* @__PURE__ */ new Date();
|
|
447
|
+
const now = Math.floor(currentDate.getTime() / 1e3);
|
|
448
|
+
return Object.freeze({
|
|
449
|
+
currentDate,
|
|
450
|
+
assert(payload) {
|
|
451
|
+
return assertOAuthAccessTokenClaimsAt(payload, expectations, now);
|
|
452
|
+
}
|
|
453
|
+
});
|
|
454
|
+
}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { isExactLoopbackHost, normalizeAuthOrigin } from '../shared/auth-origin.js';
|
|
2
|
+
type AuthOriginName = 'CONVEX_SITE_URL' | 'SITE_URL';
|
|
3
|
+
export { isExactLoopbackHost, normalizeAuthOrigin };
|
|
4
|
+
export declare function requireAuthOrigin(name: AuthOriginName, env?: Readonly<Record<string, string | undefined>>): string;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import {
|
|
2
|
+
isExactLoopbackHost,
|
|
3
|
+
normalizeAuthOrigin,
|
|
4
|
+
requireAuthOrigin as requireSharedAuthOrigin
|
|
5
|
+
} from "../shared/auth-origin.js";
|
|
6
|
+
export { isExactLoopbackHost, normalizeAuthOrigin };
|
|
7
|
+
export function requireAuthOrigin(name, env = process.env) {
|
|
8
|
+
return requireSharedAuthOrigin(name, env);
|
|
9
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { BetterAuthPlugin, Session, User } from 'better-auth';
|
|
2
|
+
import type { JwtOptions } from 'better-auth/plugins/jwt';
|
|
3
|
+
import { type PinnedOAuthProviderProfile } from './oauth-security.js';
|
|
4
|
+
type SessionJwtOptions = Pick<NonNullable<JwtOptions['jwt']>, 'audience' | 'expirationTime' | 'issuer'> & {
|
|
5
|
+
definePayload?: (value: {
|
|
6
|
+
session: Session & Record<string, unknown>;
|
|
7
|
+
user: User & Record<string, unknown>;
|
|
8
|
+
}) => Promise<Record<string, unknown>> | Record<string, unknown> | undefined;
|
|
9
|
+
};
|
|
10
|
+
export interface ConvexAuthOptions {
|
|
11
|
+
authConfig: {
|
|
12
|
+
providers: readonly unknown[];
|
|
13
|
+
};
|
|
14
|
+
oauthProvider?: PinnedOAuthProviderProfile;
|
|
15
|
+
sessionJwt: SessionJwtOptions;
|
|
16
|
+
}
|
|
17
|
+
export declare function convexAuth(options: ConvexAuthOptions): BetterAuthPlugin;
|
|
18
|
+
export {};
|