@irtio/schema 4.6.0 → 4.7.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.
package/dist/index.d.ts CHANGED
@@ -594,6 +594,16 @@ declare const MAX_USER_RPCS = 60000;
594
594
  interface SchemaOptions<Rpc extends RpcMap, Roles extends readonly string[], Msgs extends MessageMap = MessageMap> {
595
595
  readonly rpc?: Rpc;
596
596
  readonly roles?: Roles;
597
+ /**
598
+ * Issue #123: let a client choose its own role. Off by default.
599
+ *
600
+ * Without it a role comes from a JWT `role` claim, a resume token, or room code
601
+ * (`room.setRole`), and a client that names a role in its join gets the default role
602
+ * (`roles[0]`) instead. A key join is anonymous, so a role it types is a request nobody
603
+ * verified; a schema that trusts one anyway (a party game where anyone may host) says so here.
604
+ * Identity, not shape: like `project`, it is not part of the hash.
605
+ */
606
+ readonly clientRoles?: boolean;
597
607
  /**
598
608
  * D70: peer message shapes. `messages: { emote: { kind: enumOf('wave', 'laugh'), x: f32 } }`
599
609
  * gives the client `room.messages.emote.send(target, value)` / `.on(cb)` and the room the same
@@ -615,6 +625,8 @@ interface Schema<Defs extends DefMap = DefMap, Rpc extends RpcMap = RpcMap, Role
615
625
  /** D70: the declared message map, as written. */
616
626
  readonly messageDefs: Msgs;
617
627
  readonly project: string | undefined;
628
+ /** Issue #123: `SchemaOptions.clientRoles`, resolved. `false` unless the schema opted in. */
629
+ readonly clientRoles: boolean;
618
630
  /** Collections sorted by name; index = wire index. */
619
631
  readonly collections: readonly CollectionDesc[];
620
632
  readonly collection: (name: string) => CollectionDesc;
package/dist/index.js CHANGED
@@ -974,6 +974,7 @@ function defineSchema(defs, options = {}) {
974
974
  roles,
975
975
  messageDefs: messageMap,
976
976
  project: options.project,
977
+ clientRoles: options.clientRoles === true,
977
978
  collections,
978
979
  collection: (name) => {
979
980
  const c = byName.get(name);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@irtio/schema",
3
- "version": "4.6.0",
3
+ "version": "4.7.0",
4
4
  "description": "irtio schema DSL, type inference, canonical hash, codec, change tracking, and schema diff",
5
5
  "license": "MIT",
6
6
  "repository": {