Skip to content

Commit

Permalink
🛠fix wsUrl bug & 🤖 randomize default token
Browse files Browse the repository at this point in the history
  • Loading branch information
stevejpurves committed Nov 21, 2023
1 parent 93c32dd commit cc01e32
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions packages/core/src/options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import type {
SavedSessionOptions,
MathjaxOptions,
} from './types';
import { shortId } from './utils';

export function makeBinderOptions(opts: BinderOptions) {
return {
Expand Down Expand Up @@ -36,12 +37,15 @@ export function makeKernelOptions(opts: KernelOptions): Required<KernelOptions>
}

export function makeServerSettings(settings: ServerSettings): Required<ServerSettings> {
const baseUrl = settings.baseUrl ?? 'http://localhost:8888';
const wsUrl = settings.wsUrl ?? baseUrl.replace(/^http/, 'ws');

return {
baseUrl: 'http://localhost:8888',
token: 'test-secret',
token: shortId(), // randomized default token to prevent accidental access to a local server
appendToken: true,
wsUrl: 'ws://localhost:8888',
...settings,
wsUrl,
baseUrl,
};
}

Expand Down

0 comments on commit cc01e32

Please sign in to comment.