@pluv/io 0.34.1 → 0.35.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,9 +1,9 @@
1
1
 
2
- > @pluv/io@0.34.1 build /home/runner/work/pluv/pluv/packages/io
2
+ > @pluv/io@0.35.0 build /home/runner/work/pluv/pluv/packages/io
3
3
  > pnpm run version && tsup src/index.ts --format esm,cjs --dts
4
4
 
5
5
 
6
- > @pluv/io@0.34.1 version /home/runner/work/pluv/pluv/packages/io
6
+ > @pluv/io@0.35.0 version /home/runner/work/pluv/pluv/packages/io
7
7
  > genversion ./src/version.generated.ts --esm
8
8
 
9
9
  CLI Building entry: src/index.ts
@@ -12,11 +12,11 @@
12
12
  CLI Target: es6
13
13
  ESM Build start
14
14
  CJS Build start
15
- CJS dist/index.js 45.55 KB
16
- CJS ⚡️ Build success in 157ms
17
- ESM dist/index.mjs 43.38 KB
18
- ESM ⚡️ Build success in 158ms
15
+ CJS dist/index.js 45.71 KB
16
+ CJS ⚡️ Build success in 171ms
17
+ ESM dist/index.mjs 43.53 KB
18
+ ESM ⚡️ Build success in 172ms
19
19
  DTS Build start
20
- DTS ⚡️ Build success in 2554ms
21
- DTS dist/index.d.mts 29.94 KB
22
- DTS dist/index.d.ts 29.94 KB
20
+ DTS ⚡️ Build success in 2615ms
21
+ DTS dist/index.d.mts 29.57 KB
22
+ DTS dist/index.d.ts 29.57 KB
package/CHANGELOG.md CHANGED
@@ -1,5 +1,53 @@
1
1
  # @pluv/io
2
2
 
3
+ ## 0.35.0
4
+
5
+ ### Minor Changes
6
+
7
+ - c9073ad: **BREAKING**
8
+
9
+ Removed the `required` property on the `authorize` config when creating a `PluvIO` instance. When `authorize` is provided, the session will be required to be authorized.
10
+
11
+ ```ts
12
+ // Before
13
+ import { z } from "zod";
14
+
15
+ const io = createIO({
16
+ // ...
17
+ authorize: {
18
+ // Previously required: true to force all users to authorize
19
+ required: true,
20
+ user: z.object({
21
+ id: z.string(),
22
+ name: z.string(),
23
+ }),
24
+ secret: "sk_...",
25
+ },
26
+ // ...
27
+ });
28
+
29
+ // After
30
+
31
+ const io = createIO({
32
+ // ...
33
+ authorize: {
34
+ // No more `required` property. Now automatically applied always if
35
+ // `authorize` prop is provided to `createIO`
36
+ user: z.object({
37
+ id: z.string(),
38
+ name: z.string(),
39
+ }),
40
+ secret: "sk_...",
41
+ },
42
+ // ...
43
+ });
44
+ ```
45
+
46
+ ### Patch Changes
47
+
48
+ - @pluv/crdt@0.35.0
49
+ - @pluv/types@0.35.0
50
+
3
51
  ## 0.34.1
4
52
 
5
53
  ### Patch Changes
package/dist/index.d.mts CHANGED
@@ -1,4 +1,4 @@
1
- import { JsonObject, MaybePromise, IOAuthorize, IOEventMessage, EventRecord, InputZodLike, ProcedureLike, IORouterLike, BaseIOAuthorize, InferIOAuthorizeUser, Id, Maybe, BaseUser, UndefinedProps, InferEventMessage, InferEventsOutput, IOLike, InferIOOutput, InferIOInput, InferIOAuthorize } from '@pluv/types';
1
+ import { JsonObject, MaybePromise, IOAuthorize, IOEventMessage, EventRecord, InputZodLike, ProcedureLike, IORouterLike, InferIOAuthorizeUser, Id, Maybe, BaseUser, UndefinedProps, InferEventMessage, InferEventsOutput, IOLike, InferIOOutput, InferIOInput, InferIOAuthorize } from '@pluv/types';
2
2
  export { BaseUser, EventMessage, EventRecord, IOEventMessage } from '@pluv/types';
3
3
  import { AbstractCrdtDocFactory, AbstractCrdtDoc } from '@pluv/crdt';
4
4
 
@@ -77,18 +77,18 @@ declare abstract class AbstractWebSocket<TWebSocket = any> {
77
77
  abstract close(code?: number | undefined, reason?: string | undefined): void;
78
78
  abstract send(message: ArrayBuffer | ArrayBufferView | string): void;
79
79
  abstract terminate(): void;
80
- getSession<TAuthorize extends IOAuthorize<any, any, any>>(): Promise<WebSocketSession<TAuthorize>>;
80
+ getSession<TAuthorize extends IOAuthorize<any, any> | null>(): Promise<WebSocketSession<TAuthorize>>;
81
81
  handleError(params: AbstractWebSocketHandleErrorParams): void;
82
82
  sendMessage<TMessage extends IOEventMessage<any> = IOEventMessage<any>>(data: TMessage): void;
83
83
  }
84
84
 
85
- interface PluvProcedureConfig<TPlatform extends AbstractPlatform<any>, TAuthorize extends IOAuthorize<any, any, InferInitContextType<TPlatform>>, TContext extends Record<string, any>, TInput extends JsonObject = {}, TOutput extends EventRecord<string, any> = {}> {
85
+ interface PluvProcedureConfig<TPlatform extends AbstractPlatform<any>, TAuthorize extends IOAuthorize<any, InferInitContextType<TPlatform>> | null, TContext extends Record<string, any>, TInput extends JsonObject = {}, TOutput extends EventRecord<string, any> = {}> {
86
86
  broadcast?: EventResolver<"broadcast", TPlatform, TAuthorize, TContext, TInput, Partial<TOutput>> | null;
87
87
  input?: InputZodLike<TInput>;
88
88
  self?: EventResolver<"self", TPlatform, TAuthorize, TContext, TInput, Partial<TOutput>> | null;
89
89
  sync?: EventResolver<"sync", TPlatform, TAuthorize, TContext, TInput, Partial<TOutput>> | null;
90
90
  }
91
- declare class PluvProcedure<TPlatform extends AbstractPlatform<any>, TAuthorize extends IOAuthorize<any, any, InferInitContextType<TPlatform>>, TContext extends Record<string, any>, TInput extends JsonObject = {}, TOutput extends EventRecord<string, any> = {}, TFilled extends "input" | "broadcast" | "self" | "sync" | "" = ""> {
91
+ declare class PluvProcedure<TPlatform extends AbstractPlatform<any>, TAuthorize extends IOAuthorize<any, InferInitContextType<TPlatform>> | null, TContext extends Record<string, any>, TInput extends JsonObject = {}, TOutput extends EventRecord<string, any> = {}, TFilled extends "input" | "broadcast" | "self" | "sync" | "" = ""> {
92
92
  private _broadcast;
93
93
  private _input;
94
94
  private _self;
@@ -102,14 +102,14 @@ declare class PluvProcedure<TPlatform extends AbstractPlatform<any>, TAuthorize
102
102
  private _resolver;
103
103
  }
104
104
 
105
- type PluvRouterEventConfig<TPlatform extends AbstractPlatform<any> = AbstractPlatform<any>, TAuthorize extends PluvIOAuthorize<TPlatform, any, any, InferInitContextType<TPlatform>> = any, TContext extends Record<string, any> = {}> = {
105
+ type PluvRouterEventConfig<TPlatform extends AbstractPlatform<any> = AbstractPlatform<any>, TAuthorize extends PluvIOAuthorize<TPlatform, any, InferInitContextType<TPlatform>> | null = any, TContext extends Record<string, any> = {}> = {
106
106
  [P: string]: Pick<PluvProcedure<TPlatform, TAuthorize, TContext, any, any>, "config">;
107
107
  };
108
- type MergedRouter<TRouters extends PluvRouter<TPlatform, TAuthorize, TContext, any>[] = [], TPlatform extends AbstractPlatform<any> = AbstractPlatform<any>, TAuthorize extends PluvIOAuthorize<TPlatform, any, any, InferInitContextType<TPlatform>> = any, TContext extends Record<string, any> = {}, TRoot extends TRouters[0]["_defs"]["events"] = {}> = TRouters extends [
108
+ type MergedRouter<TRouters extends PluvRouter<TPlatform, TAuthorize, TContext, any>[] = [], TPlatform extends AbstractPlatform<any> = AbstractPlatform<any>, TAuthorize extends PluvIOAuthorize<TPlatform, any, InferInitContextType<TPlatform>> = any, TContext extends Record<string, any> = {}, TRoot extends TRouters[0]["_defs"]["events"] = {}> = TRouters extends [
109
109
  infer IHead extends PluvRouter<TPlatform, TAuthorize, TContext, any>,
110
110
  ...infer ITail extends PluvRouter<TPlatform, TAuthorize, TContext, any>[]
111
111
  ] ? MergedRouter<ITail, TPlatform, TAuthorize, TContext, TRoot & IHead["_defs"]["events"]> : PluvRouter<TPlatform, TAuthorize, TContext, TRoot>;
112
- declare class PluvRouter<TPlatform extends AbstractPlatform<any> = AbstractPlatform<any>, TAuthorize extends PluvIOAuthorize<TPlatform, any, any, InferInitContextType<TPlatform>> = any, TContext extends Record<string, any> = {}, TEvents extends PluvRouterEventConfig<TPlatform, TAuthorize, TContext> = {}> implements IORouterLike<TEvents> {
112
+ declare class PluvRouter<TPlatform extends AbstractPlatform<any> = AbstractPlatform<any>, TAuthorize extends PluvIOAuthorize<TPlatform, any, InferInitContextType<TPlatform>> | null = any, TContext extends Record<string, any> = {}, TEvents extends PluvRouterEventConfig<TPlatform, TAuthorize, TContext> = {}> implements IORouterLike<TEvents> {
113
113
  readonly _defs: {
114
114
  events: TEvents;
115
115
  };
@@ -128,8 +128,8 @@ interface CrdtLibraryType {
128
128
  kind: "loro" | "yjs";
129
129
  }
130
130
  type EventResolverKind = "broadcast" | "self" | "sync";
131
- type EventResolver<TKind extends EventResolverKind = EventResolverKind, TPlatform extends AbstractPlatform = AbstractPlatform, TAuthorize extends IOAuthorize<any, any, InferInitContextType<TPlatform>> = BaseIOAuthorize, TContext extends Record<string, any> = {}, TInput extends JsonObject = {}, TOutput extends EventRecord<string, any> = {}> = (data: TInput, context: EventResolverContext<TKind, TPlatform, TAuthorize, TContext>) => MaybePromise<TOutput | void>;
132
- interface EventResolverContext<TKind extends EventResolverKind = EventResolverKind, TPlatform extends AbstractPlatform = AbstractPlatform, TAuthorize extends IOAuthorize<any, any, InferInitContextType<TPlatform>> = BaseIOAuthorize, TContext extends Record<string, any> = {}> {
131
+ type EventResolver<TKind extends EventResolverKind = EventResolverKind, TPlatform extends AbstractPlatform = AbstractPlatform, TAuthorize extends IOAuthorize<any, InferInitContextType<TPlatform>> | null = null, TContext extends Record<string, any> = {}, TInput extends JsonObject = {}, TOutput extends EventRecord<string, any> = {}> = (data: TInput, context: EventResolverContext<TKind, TPlatform, TAuthorize, TContext>) => MaybePromise<TOutput | void>;
132
+ interface EventResolverContext<TKind extends EventResolverKind = EventResolverKind, TPlatform extends AbstractPlatform = AbstractPlatform, TAuthorize extends IOAuthorize<any, InferInitContextType<TPlatform>> | null = null, TContext extends Record<string, any> = {}> {
133
133
  context: TContext;
134
134
  doc: AbstractCrdtDoc<any>;
135
135
  room: string;
@@ -153,7 +153,7 @@ interface WebSocketSerializedState {
153
153
  room: string;
154
154
  timers: WebSocketSessionTimers;
155
155
  }
156
- type WebSocketSession<TAuthorize extends IOAuthorize<any, any, any> = BaseIOAuthorize> = WebSocketSerializedState & {
156
+ type WebSocketSession<TAuthorize extends IOAuthorize<any, any> | null = null> = WebSocketSerializedState & {
157
157
  id: string;
158
158
  user: InferIOAuthorizeUser<TAuthorize>;
159
159
  webSocket: AbstractWebSocket;
@@ -173,7 +173,6 @@ type HandleMode = "io" | "fetch";
173
173
  type WebSocketRegistrationMode = "attached" | "detached";
174
174
  interface PlatformConfig {
175
175
  authorize: {
176
- required?: boolean;
177
176
  secret?: boolean;
178
177
  };
179
178
  requireAuth?: boolean;
@@ -187,21 +186,20 @@ interface PlatformConfig {
187
186
  onUserDisconnected?: boolean;
188
187
  };
189
188
  }
190
- type ResolvedPluvIOAuthorize<TPlatform extends AbstractPlatform<any, any, any, any>, TUser extends BaseUser = any, TRequired extends boolean = false> = {
189
+ type ResolvedPluvIOAuthorize<TPlatform extends AbstractPlatform<any, any, any, any>, TUser extends BaseUser = any> = {
191
190
  user: InputZodLike<TUser>;
192
- required?: TRequired;
193
191
  } & UndefinedProps<{
194
192
  secret?: string;
195
193
  }, Exclude<"secret", InferPlatformAuthorizeProperties<TPlatform>>>;
196
- type PluvIOAuthorize<TPlatform extends AbstractPlatform<any, any, any, any>, TUser extends BaseUser = any, TRequired extends boolean = false, TContext extends Record<string, unknown> = {}> = ResolvedPluvIOAuthorize<TPlatform, TUser, TRequired> | ((context: TContext) => ResolvedPluvIOAuthorize<TPlatform, TUser, TRequired>);
197
- type BasePluvIOListeners<TPlatform extends AbstractPlatform<any, any, any, any>, TAuthorize extends PluvIOAuthorize<TPlatform, any, any, InferInitContextType<TPlatform>>, TContext extends Record<string, any>, TEvents extends PluvRouterEventConfig<TPlatform, TAuthorize, TContext>> = {
194
+ type PluvIOAuthorize<TPlatform extends AbstractPlatform<any, any, any, any>, TUser extends BaseUser = any, TContext extends Record<string, unknown> = {}> = ResolvedPluvIOAuthorize<TPlatform, TUser> | ((context: TContext) => ResolvedPluvIOAuthorize<TPlatform, TUser>);
195
+ type BasePluvIOListeners<TPlatform extends AbstractPlatform<any, any, any, any>, TAuthorize extends PluvIOAuthorize<TPlatform, any, InferInitContextType<TPlatform>> | null, TContext extends Record<string, any>, TEvents extends PluvRouterEventConfig<TPlatform, TAuthorize, TContext>> = {
198
196
  onRoomDeleted: (event: IORoomListenerEvent<TContext>) => void;
199
197
  onRoomMessage: (event: IORoomMessageEvent<TPlatform, TAuthorize, TContext, TEvents>) => void;
200
198
  onStorageUpdated: (event: IOStorageUpdatedEvent<TPlatform, TAuthorize, TContext>) => void;
201
199
  onUserConnected: (event: IOUserConnectedEvent<TPlatform, TAuthorize, TContext>) => void;
202
200
  onUserDisconnected: (event: IOUserDisconnectedEvent<TPlatform, TAuthorize, TContext>) => void;
203
201
  };
204
- type PluvIOListeners<TPlatform extends AbstractPlatform<any, any, any, any>, TAuthorize extends PluvIOAuthorize<TPlatform, any, any, InferInitContextType<TPlatform>>, TContext extends Record<string, any>, TEvents extends PluvRouterEventConfig<TPlatform, TAuthorize, TContext>> = UndefinedProps<BasePluvIOListeners<TPlatform, TAuthorize, TContext, TEvents>, Exclude<keyof BasePluvIOListeners<TPlatform, TAuthorize, TContext, TEvents>, InferPlatformListeners<TPlatform>>>;
202
+ type PluvIOListeners<TPlatform extends AbstractPlatform<any, any, any, any>, TAuthorize extends PluvIOAuthorize<TPlatform, any, InferInitContextType<TPlatform>> | null, TContext extends Record<string, any>, TEvents extends PluvRouterEventConfig<TPlatform, TAuthorize, TContext>> = UndefinedProps<BasePluvIOListeners<TPlatform, TAuthorize, TContext, TEvents>, Exclude<keyof BasePluvIOListeners<TPlatform, TAuthorize, TContext, TEvents>, InferPlatformListeners<TPlatform>>>;
205
203
  type InferPlatformConfig<TPlatform extends AbstractPlatform<any, any, any, any>> = TPlatform extends AbstractPlatform<any, any, any, infer IConfig> ? IConfig : never;
206
204
  type InferPlatformAuthorizeProperties<TPlatform extends AbstractPlatform<any, any, any, any>> = keyof {
207
205
  [P in keyof PlatformConfig["authorize"] as InferPlatformConfig<TPlatform>["authorize"][P] extends true | undefined ? P : never]: true;
@@ -214,20 +212,20 @@ type IORoomListenerEvent<TContext extends Record<string, any>> = {
214
212
  encodedState: string | null;
215
213
  room: string;
216
214
  };
217
- type IORoomMessageEvent<TPlatform extends AbstractPlatform<any>, TAuthorize extends PluvIOAuthorize<TPlatform, any, any, InferInitContextType<TPlatform>>, TContext extends Record<string, any>, TEvents extends PluvRouterEventConfig<TPlatform, TAuthorize, TContext>> = IORoomListenerEvent<TContext> & {
215
+ type IORoomMessageEvent<TPlatform extends AbstractPlatform<any>, TAuthorize extends PluvIOAuthorize<TPlatform, any, InferInitContextType<TPlatform>> | null, TContext extends Record<string, any>, TEvents extends PluvRouterEventConfig<TPlatform, TAuthorize, TContext>> = IORoomListenerEvent<TContext> & {
218
216
  message: InferEventMessage<InferEventsOutput<TEvents>, keyof InferEventsOutput<TEvents>>;
219
217
  user?: InferIOAuthorizeUser<TAuthorize>;
220
218
  webSocket?: InferPlatformWebSocketSource<TPlatform>;
221
219
  };
222
- type IOStorageUpdatedEvent<TPlatform extends AbstractPlatform<any>, TAuthorize extends IOAuthorize<any, any, InferInitContextType<TPlatform>>, TContext extends Record<string, any>> = IORoomListenerEvent<TContext> & {
220
+ type IOStorageUpdatedEvent<TPlatform extends AbstractPlatform<any>, TAuthorize extends IOAuthorize<any, InferInitContextType<TPlatform>> | null, TContext extends Record<string, any>> = IORoomListenerEvent<TContext> & {
223
221
  user?: InferIOAuthorizeUser<TAuthorize>;
224
222
  webSocket?: InferPlatformWebSocketSource<TPlatform>;
225
223
  };
226
- type IOUserConnectedEvent<TPlatform extends AbstractPlatform<any>, TAuthorize extends IOAuthorize<any, any, InferInitContextType<TPlatform>>, TContext extends Record<string, any>> = IORoomListenerEvent<TContext> & {
224
+ type IOUserConnectedEvent<TPlatform extends AbstractPlatform<any>, TAuthorize extends IOAuthorize<any, InferInitContextType<TPlatform>> | null, TContext extends Record<string, any>> = IORoomListenerEvent<TContext> & {
227
225
  user?: InferIOAuthorizeUser<TAuthorize>;
228
226
  webSocket?: InferPlatformWebSocketSource<TPlatform>;
229
227
  };
230
- type IOUserDisconnectedEvent<TPlatform extends AbstractPlatform<any>, TAuthorize extends IOAuthorize<any, any, InferInitContextType<TPlatform>>, TContext extends Record<string, any>> = IORoomListenerEvent<TContext> & {
228
+ type IOUserDisconnectedEvent<TPlatform extends AbstractPlatform<any>, TAuthorize extends IOAuthorize<any, InferInitContextType<TPlatform>> | null, TContext extends Record<string, any>> = IORoomListenerEvent<TContext> & {
231
229
  user?: InferIOAuthorizeUser<TAuthorize>;
232
230
  };
233
231
  type WebSocketType<TPlatform extends AbstractPlatform> = InferPlatformWebSocketType<TPlatform> | InferPlatformWebSocketSource<TPlatform>;
@@ -246,10 +244,10 @@ interface JWT<TUser extends BaseUser> {
246
244
  sub: string;
247
245
  user: TUser;
248
246
  }
249
- type JWTEncodeParams<TUser extends BaseUser, TPlatform extends AbstractPlatform> = {
247
+ type JWTEncodeParams<TUser extends BaseUser | null, TPlatform extends AbstractPlatform> = {
250
248
  maxAge?: number;
251
249
  room: string;
252
- user: TUser;
250
+ user: TUser extends BaseUser ? TUser : "Error: Cannot create token without authorization!";
253
251
  } & InferInitContextType<TPlatform>;
254
252
  interface AuthorizeParams {
255
253
  platform: AbstractPlatform;
@@ -301,7 +299,7 @@ declare abstract class AbstractPlatform<TWebSocket extends AbstractWebSocket = A
301
299
  protected _initialize(): this;
302
300
  }
303
301
 
304
- interface IORoomListeners<TPlatform extends AbstractPlatform<any>, TAuthorize extends PluvIOAuthorize<TPlatform, any, any, InferInitContextType<TPlatform>>, TContext extends Record<string, any>, TEvents extends PluvRouterEventConfig<TPlatform, TAuthorize, TContext>> {
302
+ interface IORoomListeners<TPlatform extends AbstractPlatform<any>, TAuthorize extends PluvIOAuthorize<TPlatform, any, InferInitContextType<TPlatform>> | null, TContext extends Record<string, any>, TEvents extends PluvRouterEventConfig<TPlatform, TAuthorize, TContext>> {
305
303
  onDestroy: (event: IORoomListenerEvent<TContext>) => void;
306
304
  onMessage: (event: IORoomMessageEvent<TPlatform, TAuthorize, TContext, TEvents>) => void;
307
305
  onUserConnected: (event: IOUserConnectedEvent<TPlatform, TAuthorize, TContext>) => void;
@@ -310,7 +308,7 @@ interface IORoomListeners<TPlatform extends AbstractPlatform<any>, TAuthorize ex
310
308
  type BroadcastProxy<TIO extends IORoom<any, any, any, any>> = (<TEvent extends keyof InferIOInput<TIO>>(event: TEvent, data: Id<InferIOInput<TIO>[TEvent]>) => Promise<void>) & {
311
309
  [event in keyof InferIOInput<TIO>]: (data: Id<InferIOInput<TIO>>[event]) => Promise<void>;
312
310
  };
313
- type IORoomConfig<TPlatform extends AbstractPlatform<any> = AbstractPlatform<any>, TAuthorize extends PluvIOAuthorize<TPlatform, any, any, InferInitContextType<TPlatform>> = any, TContext extends Record<string, any> = {}, TEvents extends PluvRouterEventConfig<TPlatform, TAuthorize, TContext> = {}> = Partial<IORoomListeners<TPlatform, TAuthorize, TContext, TEvents>> & {
311
+ type IORoomConfig<TPlatform extends AbstractPlatform<any> = AbstractPlatform<any>, TAuthorize extends PluvIOAuthorize<TPlatform, any, InferInitContextType<TPlatform>> | null = any, TContext extends Record<string, any> = {}, TEvents extends PluvRouterEventConfig<TPlatform, TAuthorize, TContext> = {}> = Partial<IORoomListeners<TPlatform, TAuthorize, TContext, TEvents>> & {
314
312
  authorize?: TAuthorize;
315
313
  context: TContext;
316
314
  crdt?: {
@@ -324,7 +322,7 @@ type IORoomConfig<TPlatform extends AbstractPlatform<any> = AbstractPlatform<any
324
322
  type WebsocketRegisterConfig<TPlatform extends AbstractPlatform<any> = AbstractPlatform<any>> = {
325
323
  token?: string | null;
326
324
  } & InferInitContextType<TPlatform>;
327
- declare class IORoom<TPlatform extends AbstractPlatform<any> = AbstractPlatform<any>, TAuthorize extends PluvIOAuthorize<TPlatform, any, any, InferInitContextType<TPlatform>> = any, TContext extends Record<string, any> = {}, TEvents extends PluvRouterEventConfig<TPlatform, TAuthorize, TContext> = {}> implements IOLike<TAuthorize, TEvents> {
325
+ declare class IORoom<TPlatform extends AbstractPlatform<any> = AbstractPlatform<any>, TAuthorize extends PluvIOAuthorize<TPlatform, any, InferInitContextType<TPlatform>> | null = null, TContext extends Record<string, any> = {}, TEvents extends PluvRouterEventConfig<TPlatform, TAuthorize, TContext> = {}> implements IOLike<TAuthorize, TEvents> {
328
326
  readonly id: string;
329
327
  private _doc;
330
328
  private _uninitialize;
@@ -342,7 +340,7 @@ declare class IORoom<TPlatform extends AbstractPlatform<any> = AbstractPlatform<
342
340
  * @deprecated Internal use only. Changes to this will never be marked as breaking.
343
341
  */
344
342
  get _defs(): {
345
- authorize: TAuthorize | null;
343
+ authorize: TAuthorize;
346
344
  context: TContext;
347
345
  events: TEvents;
348
346
  platform: TPlatform;
@@ -392,7 +390,7 @@ declare class IORoom<TPlatform extends AbstractPlatform<any> = AbstractPlatform<
392
390
  }
393
391
 
394
392
  type InferIORoom<TServer extends PluvServer<any, any, any, any>> = TServer extends PluvServer<infer IPlatform, infer IAuthorize, infer IContext, infer IEvents> ? IORoom<IPlatform, IAuthorize, IContext, IEvents> : never;
395
- type PluvServerConfig<TPlatform extends AbstractPlatform<any> = AbstractPlatform<any>, TAuthorize extends PluvIOAuthorize<TPlatform, any, any, InferInitContextType<TPlatform>> = any, TContext extends Record<string, any> = {}, TEvents extends PluvRouterEventConfig<TPlatform, TAuthorize, TContext> = {}> = Partial<PluvIOListeners<TPlatform, TAuthorize, TContext, TEvents>> & {
393
+ type PluvServerConfig<TPlatform extends AbstractPlatform<any> = AbstractPlatform<any>, TAuthorize extends PluvIOAuthorize<TPlatform, any, InferInitContextType<TPlatform>> | null = any, TContext extends Record<string, any> = {}, TEvents extends PluvRouterEventConfig<TPlatform, TAuthorize, TContext> = {}> = Partial<PluvIOListeners<TPlatform, TAuthorize, TContext, TEvents>> & {
396
394
  authorize?: TAuthorize;
397
395
  context?: PluvContext<TPlatform, TContext>;
398
396
  crdt?: {
@@ -403,11 +401,11 @@ type PluvServerConfig<TPlatform extends AbstractPlatform<any> = AbstractPlatform
403
401
  platform: TPlatform;
404
402
  router?: PluvRouter<TPlatform, TAuthorize, TContext, TEvents>;
405
403
  };
406
- type BaseCreateRoomOptions<TPlatform extends AbstractPlatform<any>, TAuthorize extends PluvIOAuthorize<TPlatform, any, any, InferInitContextType<TPlatform>>, TContext extends Record<string, any>, TEvents extends PluvRouterEventConfig<TPlatform, TAuthorize, TContext>> = Partial<IORoomListeners<TPlatform, TAuthorize, TContext, TEvents>> & {
404
+ type BaseCreateRoomOptions<TPlatform extends AbstractPlatform<any>, TAuthorize extends PluvIOAuthorize<TPlatform, any, InferInitContextType<TPlatform>> | null, TContext extends Record<string, any>, TEvents extends PluvRouterEventConfig<TPlatform, TAuthorize, TContext>> = Partial<IORoomListeners<TPlatform, TAuthorize, TContext, TEvents>> & {
407
405
  debug?: boolean;
408
406
  };
409
- type CreateRoomOptions<TPlatform extends AbstractPlatform<any>, TAuthorize extends PluvIOAuthorize<TPlatform, any, any, InferInitContextType<TPlatform>>, TContext extends Record<string, any>, TEvents extends PluvRouterEventConfig<TPlatform, TAuthorize, TContext>> = keyof InferRoomContextType<TPlatform> extends never ? [BaseCreateRoomOptions<TPlatform, TAuthorize, TContext, TEvents>] | [] : [Id<BaseCreateRoomOptions<TPlatform, TAuthorize, TContext, TEvents> & InferRoomContextType<TPlatform>>];
410
- declare class PluvServer<TPlatform extends AbstractPlatform<any> = AbstractPlatform<any>, TAuthorize extends PluvIOAuthorize<TPlatform, any, any, InferInitContextType<TPlatform>> = any, TContext extends Record<string, any> = {}, TEvents extends PluvRouterEventConfig<TPlatform, TAuthorize, TContext> = {}> implements IOLike<TAuthorize, TEvents> {
407
+ type CreateRoomOptions<TPlatform extends AbstractPlatform<any>, TAuthorize extends PluvIOAuthorize<TPlatform, any, InferInitContextType<TPlatform>> | null, TContext extends Record<string, any>, TEvents extends PluvRouterEventConfig<TPlatform, TAuthorize, TContext>> = keyof InferRoomContextType<TPlatform> extends never ? [BaseCreateRoomOptions<TPlatform, TAuthorize, TContext, TEvents>] | [] : [Id<BaseCreateRoomOptions<TPlatform, TAuthorize, TContext, TEvents> & InferRoomContextType<TPlatform>>];
408
+ declare class PluvServer<TPlatform extends AbstractPlatform<any> = AbstractPlatform<any>, TAuthorize extends PluvIOAuthorize<TPlatform, any, InferInitContextType<TPlatform>> | null = any, TContext extends Record<string, any> = {}, TEvents extends PluvRouterEventConfig<TPlatform, TAuthorize, TContext> = {}> implements IOLike<TAuthorize, TEvents> {
411
409
  readonly version: string;
412
410
  private readonly _authorize;
413
411
  private readonly _baseRouter;
@@ -424,8 +422,8 @@ declare class PluvServer<TPlatform extends AbstractPlatform<any> = AbstractPlatf
424
422
  * @deprecated Internal use only. Changes to this will never be marked as breaking.
425
423
  */
426
424
  get _defs(): {
427
- authorize: TAuthorize | null;
428
- context: PluvContext<TPlatform, TContext>;
425
+ authorize: TAuthorize;
426
+ context: TContext;
429
427
  events: TEvents;
430
428
  platform: TPlatform;
431
429
  };
@@ -438,21 +436,18 @@ declare class PluvServer<TPlatform extends AbstractPlatform<any> = AbstractPlatf
438
436
  private _logDebug;
439
437
  }
440
438
 
441
- type PluvIOConfig<TPlatform extends AbstractPlatform<any>, TAuthorize extends IOAuthorize<any, any, InferInitContextType<TPlatform>>, TContext extends Record<string, any>> = {
439
+ type PluvIOConfig<TPlatform extends AbstractPlatform<any>, TAuthorize extends IOAuthorize<any, InferInitContextType<TPlatform>> | null, TContext extends Record<string, any>> = {
440
+ authorize?: TAuthorize;
442
441
  context?: PluvContext<TPlatform, TContext>;
443
442
  crdt?: CrdtLibraryType;
444
443
  debug?: boolean;
445
444
  platform: TPlatform;
446
- } & (InferPlatformConfig<TPlatform>["requireAuth"] extends true ? {
447
- authorize: TAuthorize;
448
- } : {
449
- authorize?: TAuthorize;
450
- });
451
- type ServerConfig<TPlatform extends AbstractPlatform<any> = AbstractPlatform<any>, TAuthorize extends PluvIOAuthorize<TPlatform, any, any, InferInitContextType<TPlatform>> = any, TContext extends Record<string, any> = {}, TEvents extends PluvRouterEventConfig<TPlatform, TAuthorize, TContext> = {}> = Partial<PluvIOListeners<TPlatform, TAuthorize, TContext, TEvents>> & {
445
+ };
446
+ type ServerConfig<TPlatform extends AbstractPlatform<any> = AbstractPlatform<any>, TAuthorize extends PluvIOAuthorize<TPlatform, any, InferInitContextType<TPlatform>> | null = any, TContext extends Record<string, any> = {}, TEvents extends PluvRouterEventConfig<TPlatform, TAuthorize, TContext> = {}> = Partial<PluvIOListeners<TPlatform, TAuthorize, TContext, TEvents>> & {
452
447
  getInitialStorage?: GetInitialStorageFn<TContext>;
453
448
  router?: PluvRouter<TPlatform, TAuthorize, TContext, TEvents>;
454
449
  };
455
- declare class PluvIO<TPlatform extends AbstractPlatform<any> = AbstractPlatform<any>, TAuthorize extends PluvIOAuthorize<TPlatform, any, any, InferInitContextType<TPlatform>> = any, TContext extends Record<string, any> = {}> {
450
+ declare class PluvIO<TPlatform extends AbstractPlatform<any> = AbstractPlatform<any>, TAuthorize extends PluvIOAuthorize<TPlatform, any, InferInitContextType<TPlatform>> | null = any, TContext extends Record<string, any> = {}> {
456
451
  readonly version: string;
457
452
  private readonly _authorize;
458
453
  private readonly _context;
@@ -468,13 +463,13 @@ declare class PluvIO<TPlatform extends AbstractPlatform<any> = AbstractPlatform<
468
463
  private _getIOAuthorize;
469
464
  }
470
465
 
471
- type CreateIOParams<TPlatform extends AbstractPlatform<any> = AbstractPlatform<any>, TContext extends Record<string, any> = {}, TAuthorizeUser extends BaseUser = BaseUser, TAuthorizeRequired extends boolean = false> = {
472
- authorize?: PluvIOAuthorize<TPlatform, TAuthorizeUser, TAuthorizeRequired, InferInitContextType<TPlatform>>;
466
+ type CreateIOParams<TPlatform extends AbstractPlatform<any> = AbstractPlatform<any>, TContext extends Record<string, any> = {}, TAuthorize extends PluvIOAuthorize<TPlatform, any, InferInitContextType<TPlatform>> | null = null> = {
467
+ authorize?: TAuthorize;
473
468
  context?: PluvContext<TPlatform, TContext>;
474
469
  crdt?: CrdtLibraryType;
475
470
  debug?: boolean;
476
471
  platform: TPlatform;
477
472
  };
478
- declare const createIO: <TPlatform extends AbstractPlatform<any> = AbstractPlatform<any, {}, {}, PlatformConfig>, TContext extends Record<string, any> = {}, TAuthorizeUser extends BaseUser = BaseUser, TAuthorizeRequired extends boolean = false>(params: CreateIOParams<TPlatform, TContext, TAuthorizeUser, TAuthorizeRequired>) => PluvIO<TPlatform, PluvIOAuthorize<TPlatform, TAuthorizeUser, TAuthorizeRequired, InferInitContextType<TPlatform>>, TContext>;
473
+ declare const createIO: <TPlatform extends AbstractPlatform<any> = AbstractPlatform<any, {}, {}, PlatformConfig>, TContext extends Record<string, any> = {}, TAuthorize extends PluvIOAuthorize<TPlatform, any, InferInitContextType<TPlatform>> | null = null>(params: CreateIOParams<TPlatform, TContext, TAuthorize>) => PluvIO<TPlatform, TAuthorize, TContext>;
479
474
 
480
475
  export { type AbstractCloseEvent, type AbstractErrorEvent, type AbstractEvent, type AbstractEventMap, type AbstractListener, type AbstractMessageEvent, AbstractPersistence, AbstractPlatform, type AbstractPlatformConfig, AbstractPubSub, AbstractWebSocket, type AbstractWebSocketConfig, type AbstractWebSocketHandleErrorParams, type AuthorizeModule, type AuthorizeParams, type ConvertWebSocketConfig, type CrdtLibraryType, type CreateIOParams, type CreateRoomOptions, type GetInitialStorageFn, type HandleMode, type IOPubSubEventMessage, IORoom, type IORoomListenerEvent, type IORoomMessageEvent, type IOStorageUpdatedEvent, type IOUserConnectedEvent, type IOUserDisconnectedEvent, type InferIORoom, type InferInitContextType, type InferPlatformWebSocketType, type InferRoomContextType, type JWT, type JWTEncodeParams, type MergedRouter, type PlatformConfig, PluvIO, type PluvIOConfig, type PluvIOListeners, PluvProcedure, type PluvProcedureConfig, PluvRouter, type PluvRouterEventConfig, PluvServer, type PluvServerConfig, type ServerConfig, type WebSocketRegistrationMode, type WebSocketSerializedState, type WebSocketSession, authorize, createIO };