Skip to content
This repository has been archived by the owner on Aug 16, 2024. It is now read-only.

Commit

Permalink
Merge pull request #37 from magiclabs/hcote-auto-jwt-gen
Browse files Browse the repository at this point in the history
auto jwt gen for hasura template
  • Loading branch information
hcote authored Mar 25, 2021
2 parents 73088e6 + 6cc9a3d commit 11dfd6f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "make-magic",
"version": "2.1.1",
"version": "2.1.2",
"description": "A tool for quickly scaffolding an app with Magic authentication baked-in!",
"repository": "magiclabs/create-magic-app",
"license": "MIT",
Expand Down
13 changes: 7 additions & 6 deletions scaffolds/hasura/scaffold.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { Template, Zombi } from 'compiled/zombi';
import { createScaffold } from 'cli/utils/scaffold-helpers';
import { mergePrompts } from 'cli/utils/merge-prompts';
import { NpmClientPrompt, PublishableApiKeyPrompt, SecretApiKeyPrompt } from 'scaffolds/prompts';
import crypto from 'crypto';

type HasuraData = NpmClientPrompt.Data &
PublishableApiKeyPrompt.Data &
Expand All @@ -11,10 +12,16 @@ type HasuraData = NpmClientPrompt.Data &
jwtSecret: string;
};

function generateJwtSecret() {
const buffer = crypto.randomBytes(32);
return buffer.toString('hex');
}

export default createScaffold<HasuraData>(
(props) => (
<Zombi
{...props}
data={{ ...props.data, jwtSecret: props.data.jwtSecret ?? generateJwtSecret() }}
prompts={mergePrompts(
PublishableApiKeyPrompt.questions,
SecretApiKeyPrompt.questions,
Expand All @@ -25,12 +32,6 @@ export default createScaffold<HasuraData>(
message: "Enter your project's Hasura URL:",
},

{
type: 'input',
name: 'jwtSecret',
message: 'Enter your 32+ character JWT secret:',
},

NpmClientPrompt.questions,
)}
>
Expand Down

0 comments on commit 11dfd6f

Please sign in to comment.