-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(challenge): omit solution from client js bundle (#67)
* fix(challenge): omit solution from client js bundle * build: use backticks instead of quotes for challenge input variable
- Loading branch information
Showing
9 changed files
with
359 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
export const caesarShift = (str: string, amount: number): string => { | ||
if (amount < 0) { | ||
return caesarShift(str, amount + 26); | ||
} | ||
let output = ""; | ||
for (let i = 0; i < str.length; i++) { | ||
let c = str[i]!; | ||
if (c.match(/[a-z]/i)) { | ||
const code = str.charCodeAt(i); | ||
if (code >= 65 && code <= 90) { | ||
c = String.fromCharCode(((code - 65 + amount) % 26) + 65); | ||
} else if (code >= 97 && code <= 122) { | ||
c = String.fromCharCode(((code - 97 + amount) % 26) + 97); | ||
} | ||
} | ||
output += c; | ||
} | ||
return output; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import "server-only"; | ||
// NOTE: if the first line of this file is changed, updates to `scripts/build-challenge-input.ts` are required | ||
import { z } from "zod"; | ||
|
||
const DEFAULT_CHALLENGE_SOLUTION = `this-is-so-secret`; | ||
|
||
const serverEnvironmentSchema = z.object({ | ||
CHALLENGE_SOLUTION: z.string().min(1).optional(), | ||
}); | ||
const safeServerEnv = serverEnvironmentSchema.parse(process.env); | ||
|
||
export const CHALLENGE_SOLUTION = | ||
safeServerEnv.CHALLENGE_SOLUTION ?? DEFAULT_CHALLENGE_SOLUTION; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.