Enable CORS, fix nsec1 keys

This commit is contained in:
Alex Gleason
2023-03-04 22:49:08 -06:00
parent 825fed7d21
commit 48f04e48de
4 changed files with 11 additions and 2 deletions

View File

@@ -1,3 +1,5 @@
import converter from 'npm:bech32-converting';
import { validator, z } from '@/deps.ts';
const createTokenSchema = z.object({
@@ -8,8 +10,11 @@ const createTokenController = validator('json', (value, c) => {
const result = createTokenSchema.safeParse(value);
if (result.success) {
const password = result.data.password;
const token = password.startsWith('nsec1') ? converter('nsec').toHex(password).slice(2) : password;
return c.json({
access_token: result.data.password,
access_token: token,
token_type: 'Bearer',
scope: 'read write follow push',
created_at: Math.floor(new Date().getTime() / 1000),