Skip to content

Commit 8fca2a5

Browse files
Patch (backport #3297) (#3298)
Co-authored-by: Kefan Cao <76069770+Kefancao@users.noreply.github.com>
1 parent 5478b37 commit 8fca2a5

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

indexer/services/comlink/src/config.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,7 @@ export const configSchema = {
120120
TURNKEY_API_SENDER_PRIVATE_KEY: parseString({ default: '' }),
121121
TURNKEY_API_SENDER_PUBLIC_KEY: parseString({ default: '' }),
122122
TURNKEY_MAGIC_LINK_TEMPLATE: parseString({ default: '' }),
123+
TURNKEY_MAGIC_LINK_VALIDATION: parseString({ default: 'https://dydx.trade' }),
123124
TURNKEY_ORGANIZATION_ID: parseString({ default: '' }),
124125
SOLANA_SPONSOR_PUBLIC_KEY: parseString({ default: '' }),
125126
SKIP_SLIPPAGE_TOLERANCE_PERCENTAGE: parseString({ default: '0' }),

indexer/services/comlink/src/controllers/api/v4/turnkey-controller.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,12 @@ export class TurnkeyController extends Controller {
167167
if (!userEmail || !targetPublicKey) {
168168
throw new Error('userEmail and targetPublicKey are required for email signin');
169169
}
170+
if (magicLink) {
171+
const isValidMagicLink = magicLink.startsWith(config.TURNKEY_MAGIC_LINK_VALIDATION);
172+
if (!isValidMagicLink) {
173+
throw new Error('Invalid magic link template');
174+
}
175+
}
170176
try {
171177
const resp = await this.turnkeyHelpers.emailSignin(userEmail, targetPublicKey!, magicLink);
172178
if (resp.userId === undefined || resp.apiKeyId === undefined) {
@@ -229,7 +235,7 @@ export class TurnkeyController extends Controller {
229235

230236
// Validate Apple configuration
231237
if (!config.APPLE_TEAM_ID || !config.APPLE_SERVICE_ID ||
232-
!config.APPLE_KEY_ID || !config.APPLE_PRIVATE_KEY) {
238+
!config.APPLE_KEY_ID || !config.APPLE_PRIVATE_KEY) {
233239
throw new TurnkeyError('Apple Sign-In configuration is incomplete');
234240
}
235241

0 commit comments

Comments
 (0)