@segmentstream/ontology 0.181.0 → 0.182.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/manifest.js CHANGED
@@ -509,6 +509,8 @@ export const SignUpManifest = Schema.Struct({
509
509
  * know admit nobody.
510
510
  */
511
511
  export const GuestManifest = Schema.Struct({
512
+ openOnInvite: Schema.optionalKey(Schema.Array(Schema.String)),
513
+ byChannel: Schema.optionalKey(Schema.Record(Schema.String, Schema.Array(Schema.String))),
512
514
  channels: Schema.Array(Schema.String),
513
515
  origins: Schema.Array(Schema.String),
514
516
  /** The challenge a new guest passes, and the workspace secret holding its secret key. */
@@ -872,7 +874,7 @@ export function guestOf(manifest) {
872
874
  if (typeof declared !== "object" || declared === null) {
873
875
  return undefined;
874
876
  }
875
- const { channels, origins, botCheck, confirmations } = declared;
877
+ const { channels, origins, byChannel, openOnInvite, botCheck, confirmations } = declared;
876
878
  const known = Array.isArray(channels) ? channels.filter(isGuestChannel) : [];
877
879
  const websites = Array.isArray(origins)
878
880
  ? origins.flatMap((candidate) => {
@@ -887,7 +889,16 @@ export function guestOf(manifest) {
887
889
  check.connection !== "" &&
888
890
  typeof check.input === "string" &&
889
891
  check.input !== "";
890
- if (known.length === 0 || websites.length === 0) {
892
+ if (byChannel !== undefined &&
893
+ (byChannel === null ||
894
+ typeof byChannel !== "object" ||
895
+ Array.isArray(byChannel) ||
896
+ Object.entries(byChannel).some(([key, roles]) => !known.some((channel) => channel === key) ||
897
+ !Array.isArray(roles) ||
898
+ !roles.every((role) => typeof role === "string")))) {
899
+ return undefined;
900
+ }
901
+ if (known.length === 0 || (known.includes("web") && websites.length === 0)) {
891
902
  return undefined;
892
903
  }
893
904
  // A bot check this reader cannot verify admits no new guest, rather than none without a check.
@@ -901,6 +912,8 @@ export function guestOf(manifest) {
901
912
  return {
902
913
  channels: [...new Set(known)],
903
914
  origins: websites,
915
+ ...(byChannel && { byChannel }),
916
+ ...(Array.isArray(openOnInvite) && { openOnInvite }),
904
917
  ...(check === undefined
905
918
  ? {}
906
919
  : connected
@@ -1187,6 +1200,15 @@ export function buildManifest(input) {
1187
1200
  : {
1188
1201
  guest: {
1189
1202
  channels: [...input.signIn.guest.channels],
1203
+ ...(input.signIn.guest.openOnInvite && {
1204
+ openOnInvite: input.signIn.guest.openOnInvite,
1205
+ }),
1206
+ ...(input.signIn.guest.byChannel && {
1207
+ byChannel: Object.fromEntries(Object.entries(input.signIn.guest.byChannel).map(([channel, roles]) => [
1208
+ channel,
1209
+ [...roles],
1210
+ ])),
1211
+ }),
1190
1212
  origins: [...input.signIn.guest.origins],
1191
1213
  ...(input.signIn.guest.botCheck === undefined
1192
1214
  ? {}