Skip to content

Commit 11ed1ee

Browse files
committed
chore: remove redundant code
1 parent 7abc1bd commit 11ed1ee

6 files changed

Lines changed: 11 additions & 26 deletions

File tree

packages/astro/src/env.d.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,6 @@ interface InternalEnv {
2020
readonly PUBLIC_CLERK_SIGN_UP_URL?: string;
2121
readonly PUBLIC_CLERK_TELEMETRY_DISABLED?: string;
2222
readonly PUBLIC_CLERK_TELEMETRY_DEBUG?: string;
23-
readonly PUBLIC_CLERK_KEYLESS_CLAIM_URL?: string;
24-
readonly PUBLIC_CLERK_KEYLESS_API_KEYS_URL?: string;
2523
readonly PUBLIC_CLERK_KEYLESS_DISABLED?: string;
2624
}
2725

packages/astro/src/integration/create-integration.ts

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -179,18 +179,7 @@ function createClerkEnvSchema() {
179179
PUBLIC_CLERK_UI_URL: envField.string({ context: 'client', access: 'public', optional: true, url: true }),
180180
PUBLIC_CLERK_TELEMETRY_DISABLED: envField.boolean({ context: 'client', access: 'public', optional: true }),
181181
PUBLIC_CLERK_TELEMETRY_DEBUG: envField.boolean({ context: 'client', access: 'public', optional: true }),
182-
PUBLIC_CLERK_KEYLESS_CLAIM_URL: envField.string({
183-
context: 'client',
184-
access: 'public',
185-
optional: true,
186-
url: true,
187-
}),
188-
PUBLIC_CLERK_KEYLESS_API_KEYS_URL: envField.string({
189-
context: 'client',
190-
access: 'public',
191-
optional: true,
192-
url: true,
193-
}),
182+
// Note: KEYLESS_CLAIM_URL and KEYLESS_API_KEYS_URL are dynamically resolved by middleware, not user-configurable
194183
PUBLIC_CLERK_KEYLESS_DISABLED: envField.boolean({ context: 'client', access: 'public', optional: true }),
195184
CLERK_SECRET_KEY: envField.string({ context: 'server', access: 'secret', optional: true }),
196185
CLERK_MACHINE_SECRET_KEY: envField.string({ context: 'server', access: 'secret', optional: true }),

packages/astro/src/internal/merge-env-vars-with-params.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,10 +56,10 @@ const mergeEnvVarsWithParams = (params?: AstroClerkIntegrationParams & { publish
5656
disabled: isTruthy(import.meta.env.PUBLIC_CLERK_TELEMETRY_DISABLED),
5757
debug: isTruthy(import.meta.env.PUBLIC_CLERK_TELEMETRY_DEBUG),
5858
},
59-
// Read from params (server-injected via __CLERK_ASTRO_SAFE_VARS__) with fallback to import.meta.env
60-
__internal_keylessClaimUrl: (params as any)?.keylessClaimUrl || import.meta.env.PUBLIC_CLERK_KEYLESS_CLAIM_URL,
61-
__internal_keylessApiKeysUrl:
62-
(params as any)?.keylessApiKeysUrl || import.meta.env.PUBLIC_CLERK_KEYLESS_API_KEYS_URL,
59+
// Read from params (server-injected via __CLERK_ASTRO_SAFE_VARS__)
60+
// These are dynamically resolved by middleware, not from env vars
61+
__internal_keylessClaimUrl: (params as any)?.keylessClaimUrl,
62+
__internal_keylessApiKeysUrl: (params as any)?.keylessApiKeysUrl,
6363
...rest,
6464
};
6565
};

packages/astro/src/server/clerk-middleware.ts

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -92,11 +92,7 @@ export const clerkMiddleware: ClerkMiddleware = (...args: unknown[]): any => {
9292
const configuredPublishableKey = options?.publishableKey || env.pk;
9393
const configuredSecretKey = options?.secretKey || env.sk;
9494

95-
const keylessResult = await resolveKeysWithKeylessFallback(
96-
configuredPublishableKey,
97-
configuredSecretKey,
98-
true, // isDev - keyless only works in dev
99-
);
95+
const keylessResult = await resolveKeysWithKeylessFallback(configuredPublishableKey, configuredSecretKey);
10096

10197
keylessClaimUrl = keylessResult.claimUrl;
10298
keylessApiKeysUrl = keylessResult.apiKeysUrl;

packages/astro/src/server/keyless/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ export async function keyless() {
4141
}
4242
},
4343
},
44-
framework: '@clerk/astro',
44+
framework: 'astro',
4545
frameworkVersion: PACKAGE_VERSION,
4646
});
4747
}

packages/astro/src/server/keyless/utils.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,17 +11,19 @@ export interface KeylessResult {
1111
apiKeysUrl: string | undefined;
1212
}
1313

14+
/**
15+
* Resolves Clerk keys, falling back to keyless mode in development if configured keys are missing.
16+
*/
1417
export async function resolveKeysWithKeylessFallback(
1518
configuredPublishableKey: string | undefined,
1619
configuredSecretKey: string | undefined,
17-
isDev: boolean = false,
1820
): Promise<KeylessResult> {
1921
let publishableKey = configuredPublishableKey;
2022
let secretKey = configuredSecretKey;
2123
let claimUrl: string | undefined;
2224
let apiKeysUrl: string | undefined;
2325

24-
if (!isDev || !canUseKeyless) {
26+
if (!canUseKeyless) {
2527
return { publishableKey, secretKey, claimUrl, apiKeysUrl };
2628
}
2729

0 commit comments

Comments
 (0)