Skip to content

Commit

Permalink
Remove FQDN, and move stripe key test.
Browse files Browse the repository at this point in the history
  • Loading branch information
Kio-td authored Jul 8, 2024
1 parent bcc2d9b commit 6832038
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 16 deletions.
9 changes: 6 additions & 3 deletions src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@ const ConfigSchema = z.object({
environment: z
.enum(["debug","production"])
.default("production")
fqdn: z
.string()
stripe: z.object({
secret_key: z.string().default(""),
}),
Expand Down Expand Up @@ -72,7 +70,12 @@ export class Config {
await Bun.sleep(Number.POSITIVE_INFINITY);
process.exit(1);
}

// Test stripe keys for possible mistake
.refine(data => {
data.stripe.secret_key.startsWith("sk_test_") && data.environment !== "debug",
`Stripe testing keys are not permitted to be used in production!`
})

return new Config(parsed.data);
}
}
14 changes: 1 addition & 13 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,6 @@ export class AgeVerificationSystem {
logger.info`Booting...`;
const me = await this.server.request("i", {});
logger.info`Signed in as ${me.username}`;

// Stripe key testing.
if (this.config.stripe.secret_key.startsWith("sk_test_") && this.config.environment !== "debug")
throw`You are using Stripe testing keys in production! This is not allowed. aborting...`
if (this.config.stripe.secret_key.startsWith("sk_live_") && this.config.environment === "debug")
logger.warn`You are using a live Stripe key in a debug environment! This is discouraged.`

logger.info`Stripe is online`;

await this.setupServer();
Expand Down Expand Up @@ -93,13 +86,8 @@ export class AgeVerificationSystem {
],
url: new URL("/callback", url ?? "").toString(),
});
} else {
// Do not register webhook with stripe in prod.
// it'll just become super freaking messy.
const url = this.config.fqdn;
logger.info`Public URL: https://${chalk.gray(url)}` // Trying my best with the resources I have c:
}

// Removed this bit. Server doesn't need to know who it is in production.
}

/**
Expand Down

0 comments on commit 6832038

Please sign in to comment.