File tree Expand file tree Collapse file tree 3 files changed +5
-7
lines changed
Expand file tree Collapse file tree 3 files changed +5
-7
lines changed Original file line number Diff line number Diff line change 11import { create , getNumericDate , verify } from "djwt" ;
22import type { KvPrimitives } from "$lib/data/kv_primitives.ts" ;
3+ import type { KvKey } from "@silverbulletmd/silverbullet/types" ;
34
4- const jwtSecretKey = "jwtSecretKey" ;
5+ const jwtSecretKey : KvKey = [ "jwtSecretKey" ] ;
56
67export class JWTIssuer {
78 private key ! : CryptoKey ;
@@ -11,7 +12,7 @@ export class JWTIssuer {
1112
1213 // authString is only used to compare hashes to see if the auth has changed
1314 async init ( authString : string ) {
14- const [ secret ] = await this . kv . batchGet ( [ [ jwtSecretKey ] ] ) ;
15+ const [ secret ] = await this . kv . batchGet ( [ jwtSecretKey ] ) ;
1516 if ( ! secret ) {
1617 console . log ( "Generating new JWT secret key" ) ;
1718 return this . generateNewKey ( ) ;
@@ -53,7 +54,7 @@ export class JWTIssuer {
5354 [ "sign" , "verify" ] ,
5455 ) ;
5556 await this . kv . batchSet ( [ {
56- key : [ jwtSecretKey ] ,
57+ key : jwtSecretKey ,
5758 value : await crypto . subtle . exportKey ( "jwk" , this . key ) ,
5859 } ] ) ;
5960 }
Original file line number Diff line number Diff line change @@ -145,7 +145,6 @@ export class HttpServer {
145145 this . spaceServer = new SpaceServer (
146146 this . options ,
147147 this . plugAssetBundle ,
148- this . baseKvPrimitives ,
149148 ) ;
150149 await this . spaceServer . init ( ) ;
151150
Original file line number Diff line number Diff line change @@ -3,7 +3,6 @@ import { FilteredSpacePrimitives } from "../lib/spaces/filtered_space_primitives
33import { ReadOnlySpacePrimitives } from "../lib/spaces/ro_space_primitives.ts" ;
44import type { SpacePrimitives } from "../lib/spaces/space_primitives.ts" ;
55import type { AssetBundle } from "../lib/asset_bundle/bundle.ts" ;
6- import type { KvPrimitives } from "$lib/data/kv_primitives.ts" ;
76import { JWTIssuer } from "./crypto.ts" ;
87import { compile as gitIgnoreCompiler } from "gitignore-parser" ;
98import { determineShellBackend , NotSupportedShell } from "./shell_backend.ts" ;
@@ -32,7 +31,6 @@ export class SpaceServer {
3231 constructor (
3332 options : ServerOptions ,
3433 private plugAssetBundle : AssetBundle ,
35- private kvPrimitives : KvPrimitives ,
3634 ) {
3735 this . pagesPath = options . pagesPath ;
3836 this . hostname = options . hostname ;
@@ -42,7 +40,7 @@ export class SpaceServer {
4240 this . enableSpaceScript = options . enableSpaceScript ;
4341 this . spaceIgnore = options . spaceIgnore ;
4442
45- this . jwtIssuer = new JWTIssuer ( kvPrimitives ) ;
43+ this . jwtIssuer = new JWTIssuer ( options . baseKvPrimitives ) ;
4644
4745 this . shellBackend = options . readOnly
4846 ? new NotSupportedShell ( ) // No shell for read only mode
You can’t perform that action at this time.
0 commit comments