@crowdedkingdoms/crowdyjs 18.23.1-test.1 → 18.24.0-dev.1

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.
Files changed (55) hide show
  1. package/MIGRATION.md +62 -0
  2. package/README.md +135 -14
  3. package/dist/crowdy-client.d.ts +10 -1
  4. package/dist/crowdy-client.d.ts.map +1 -1
  5. package/dist/crowdy-client.js +5 -0
  6. package/dist/default-origin.d.ts +6 -6
  7. package/dist/default-origin.d.ts.map +1 -1
  8. package/dist/default-origin.js +6 -6
  9. package/dist/domains/admin.d.ts +4 -0
  10. package/dist/domains/admin.d.ts.map +1 -1
  11. package/dist/domains/admin.js +1 -0
  12. package/dist/domains/apps.d.ts +43 -3
  13. package/dist/domains/apps.d.ts.map +1 -1
  14. package/dist/domains/apps.js +46 -3
  15. package/dist/domains/auth.d.ts +140 -16
  16. package/dist/domains/auth.d.ts.map +1 -1
  17. package/dist/domains/auth.js +153 -16
  18. package/dist/domains/inputLog.d.ts +4 -1
  19. package/dist/domains/inputLog.d.ts.map +1 -1
  20. package/dist/domains/inputLog.js +4 -1
  21. package/dist/domains/managedPlayers.d.ts +56 -3
  22. package/dist/domains/managedPlayers.d.ts.map +1 -1
  23. package/dist/domains/managedPlayers.js +16 -3
  24. package/dist/domains/moderation.d.ts +53 -0
  25. package/dist/domains/moderation.d.ts.map +1 -0
  26. package/dist/domains/moderation.js +68 -0
  27. package/dist/domains/platform.d.ts +13 -0
  28. package/dist/domains/platform.d.ts.map +1 -1
  29. package/dist/domains/platform.js +14 -0
  30. package/dist/domains/portal.d.ts +86 -8
  31. package/dist/domains/portal.d.ts.map +1 -1
  32. package/dist/domains/portal.js +78 -8
  33. package/dist/domains/safety.d.ts +163 -0
  34. package/dist/domains/safety.d.ts.map +1 -0
  35. package/dist/domains/safety.js +167 -0
  36. package/dist/domains/users.d.ts +9 -1
  37. package/dist/domains/users.d.ts.map +1 -1
  38. package/dist/domains/users.js +9 -1
  39. package/dist/errors.d.ts +135 -0
  40. package/dist/errors.d.ts.map +1 -1
  41. package/dist/errors.js +163 -0
  42. package/dist/generated/graphql-schema.d.ts +522 -14
  43. package/dist/generated/graphql-schema.d.ts.map +1 -1
  44. package/dist/generated/graphql-schema.js +64 -0
  45. package/dist/generated/graphql.d.ts +375 -0
  46. package/dist/generated/graphql.d.ts.map +1 -1
  47. package/dist/generated/graphql.js +24 -3
  48. package/dist/index.d.ts +12 -9
  49. package/dist/index.d.ts.map +1 -1
  50. package/dist/index.js +6 -4
  51. package/dist/live-coding/assets/browser-authoring-index.json +1 -1
  52. package/dist/live-coding/assets/manifest.json +1 -1
  53. package/dist/live-coding/browser-authoring-index.generated.d.ts.map +1 -1
  54. package/dist/live-coding/browser-authoring-index.generated.js +265 -6
  55. package/package.json +1 -1
package/dist/errors.js CHANGED
@@ -280,6 +280,52 @@ export const ASSERTION_REJECTED_CODE = 'ASSERTION_REJECTED';
280
280
  * provisioning; see {@link orgLegalAcceptanceRequiredOf}.
281
281
  */
282
282
  export const ORG_LEGAL_ACCEPTANCE_REQUIRED_CODE = 'ORG_LEGAL_ACCEPTANCE_REQUIRED';
283
+ /**
284
+ * `extensions.code` for "the player has not accepted the current required documents" (HTTP
285
+ * 403): the platform's player documents or the app's own, listed in
286
+ * `extensions.missingDocuments`; see {@link legalAcceptanceRequiredOf}.
287
+ */
288
+ export const LEGAL_ACCEPTANCE_REQUIRED_CODE = 'LEGAL_ACCEPTANCE_REQUIRED';
289
+ /**
290
+ * `extensions.code` for "the player's age is not known" (HTTP 403), at a token's mint or
291
+ * refresh, or the developer documents for an account with no age; see {@link ageRequiredOf}.
292
+ */
293
+ export const AGE_REQUIRED_CODE = 'AGE_REQUIRED';
294
+ /**
295
+ * `extensions.code` for "the player may not play this" by age (HTTP 403); see
296
+ * {@link ageRequirementNotMetOf}.
297
+ */
298
+ export const AGE_REQUIREMENT_NOT_MET_CODE = 'AGE_REQUIREMENT_NOT_MET';
299
+ /**
300
+ * `extensions.code` for "Crowded Kingdoms does not serve the player's country" (HTTP 403); see
301
+ * {@link territoryNotSupportedOf}.
302
+ */
303
+ export const TERRITORY_NOT_SUPPORTED_CODE = 'TERRITORY_NOT_SUPPORTED';
304
+ /**
305
+ * `extensions.code` for "the app does not keep the safety log where it must" (HTTP 403); see
306
+ * {@link safetyLogRequiredOf}.
307
+ */
308
+ export const SAFETY_LOG_REQUIRED_CODE = 'SAFETY_LOG_REQUIRED';
309
+ /**
310
+ * `extensions.code` for "parental consent cannot be requested on this deployment" (HTTP 503);
311
+ * see {@link parentalConsentUnavailableOf}.
312
+ */
313
+ export const PARENTAL_CONSENT_UNAVAILABLE_CODE = 'PARENTAL_CONSENT_UNAVAILABLE';
314
+ /**
315
+ * `extensions.code` for "the player has as many contacts, waiting requests or blocks in the app
316
+ * as the platform allows" (HTTP 409); see {@link socialLimitReachedOf}.
317
+ */
318
+ export const SOCIAL_LIMIT_REACHED_CODE = 'SOCIAL_LIMIT_REACHED';
319
+ /**
320
+ * `extensions.code` for "the Minecraft account could not be confirmed" (HTTP 401), with the
321
+ * failed check in `extensions.reason`; see {@link minecraftVerificationFailedOf}.
322
+ */
323
+ export const MINECRAFT_VERIFICATION_FAILED_CODE = 'MINECRAFT_VERIFICATION_FAILED';
324
+ /**
325
+ * `extensions.code` for "Mojang's session service did not answer" (HTTP 503, retryable); see
326
+ * {@link minecraftVerificationUnavailableOf}.
327
+ */
328
+ export const MINECRAFT_VERIFICATION_UNAVAILABLE_CODE = 'MINECRAFT_VERIFICATION_UNAVAILABLE';
283
329
  /** The first error entry carrying `code`, from an error or a raw payload. */
284
330
  function errorWithCode(value, code) {
285
331
  if (!value || typeof value !== 'object')
@@ -375,6 +421,123 @@ export function assertionRejectedOf(value) {
375
421
  export function orgLegalAcceptanceRequiredOf(value) {
376
422
  return errorWithCode(value, ORG_LEGAL_ACCEPTANCE_REQUIRED_CODE) !== null;
377
423
  }
424
+ /**
425
+ * A `LEGAL_ACCEPTANCE_REQUIRED` refusal (HTTP 403), or `null`. `missingDocuments` is what the
426
+ * player still has to accept: the platform's player documents (`appId` null) and the app's own
427
+ * (`appId` set). Show those documents, then record the player's agreement
428
+ * (`auth.recordPlayerConsents`, with the app's `appId` for its own); a browser game sends the
429
+ * player back through `portal.signIn`, where Studio asks. Empty when the server did not list
430
+ * them (an older API, or a refused `register` or `recordPlayerConsents`). Not fixed by retrying.
431
+ * Distinct from the organization's `ORG_LEGAL_ACCEPTANCE_REQUIRED`
432
+ * ({@link orgLegalAcceptanceRequiredOf}).
433
+ */
434
+ export function legalAcceptanceRequiredOf(value) {
435
+ const entry = errorWithCode(value, LEGAL_ACCEPTANCE_REQUIRED_CODE);
436
+ if (!entry)
437
+ return null;
438
+ const listed = entry.extensions?.missingDocuments;
439
+ const missingDocuments = [];
440
+ if (Array.isArray(listed)) {
441
+ for (const item of listed) {
442
+ const doc = item;
443
+ if (typeof doc?.documentId !== 'string' || typeof doc.version !== 'string')
444
+ continue;
445
+ const appId = doc.appId;
446
+ missingDocuments.push({
447
+ documentId: doc.documentId,
448
+ version: doc.version,
449
+ appId: typeof appId === 'string' && appId.length > 0
450
+ ? appId
451
+ : typeof appId === 'number'
452
+ ? String(appId)
453
+ : null,
454
+ });
455
+ }
456
+ }
457
+ return { missingDocuments };
458
+ }
459
+ /**
460
+ * Whether an error is an `AGE_REQUIRED` refusal (HTTP 403): the player's age is not known.
461
+ * For an account, ask the player's birth date and country on your own neutral screen and call
462
+ * `auth.recordPlayerAge`, then mint again; a browser game sends the player back through
463
+ * `portal.signIn`, where Studio asks. For an org-managed player, the organization sends
464
+ * `ageYears` and `country` when it signs the player in. Not fixed by retrying as is.
465
+ */
466
+ export function ageRequiredOf(value) {
467
+ return errorWithCode(value, AGE_REQUIRED_CODE) !== null;
468
+ }
469
+ /**
470
+ * Whether an error is an `AGE_REQUIREMENT_NOT_MET` refusal (HTTP 403): by age, the player may
471
+ * not play this app, or create or administer an organization. Not retryable, and asking for
472
+ * the age again changes nothing: an account keeps the answer it gave.
473
+ *
474
+ * Deliberately a boolean. No refusal names an age (the platform's neutral age screen): tell the
475
+ * player they cannot play this, without naming an age or a minimum, and do not offer to enter
476
+ * the date again. Older APIs put `minimumAge` and `ageBracket` in the extensions; this reader
477
+ * does not surface them, and a game must not show them.
478
+ */
479
+ export function ageRequirementNotMetOf(value) {
480
+ return errorWithCode(value, AGE_REQUIREMENT_NOT_MET_CODE) !== null;
481
+ }
482
+ /**
483
+ * A `TERRITORY_NOT_SUPPORTED` refusal (HTTP 403), or `null`: Crowded Kingdoms does not serve
484
+ * the player's country (the one they connect from, the one they declared, or the one their
485
+ * organization asserted). `country` is `extensions.country` (ISO 3166-1 alpha-2), null when the
486
+ * server did not say. Not retryable; tell the player it is not available where they are.
487
+ */
488
+ export function territoryNotSupportedOf(value) {
489
+ const entry = errorWithCode(value, TERRITORY_NOT_SUPPORTED_CODE);
490
+ if (!entry)
491
+ return null;
492
+ const country = entry.extensions?.country;
493
+ return { country: typeof country === 'string' && country.length > 0 ? country : null };
494
+ }
495
+ /**
496
+ * Whether an error is a `SAFETY_LOG_REQUIRED` refusal (HTTP 403): the app does not keep the
497
+ * safety log (replay logging) where it must. A player under 18 gets it at the mint of an app
498
+ * without one, and an app admitting players under 18 cannot turn its log off. The player
499
+ * cannot fix it: the app's admins turn the log on (`apps.update`) or raise its minimum age.
500
+ */
501
+ export function safetyLogRequiredOf(value) {
502
+ return errorWithCode(value, SAFETY_LOG_REQUIRED_CODE) !== null;
503
+ }
504
+ /**
505
+ * Whether an error is a `PARENTAL_CONSENT_UNAVAILABLE` refusal (HTTP 503) from
506
+ * `safety.requestParentalConsent`: the deployment's consent service is not configured. Not
507
+ * fixed by retrying soon; voice and video stay off for the player meanwhile.
508
+ */
509
+ export function parentalConsentUnavailableOf(value) {
510
+ return errorWithCode(value, PARENTAL_CONSENT_UNAVAILABLE_CODE) !== null;
511
+ }
512
+ /**
513
+ * Whether an error is a `SOCIAL_LIMIT_REACHED` refusal (HTTP 409): the player already has as
514
+ * many contacts, waiting contact requests or blocks in the app as the platform allows (the
515
+ * message says which). Remove some first; not fixed by retrying.
516
+ */
517
+ export function socialLimitReachedOf(value) {
518
+ return errorWithCode(value, SOCIAL_LIMIT_REACHED_CODE) !== null;
519
+ }
520
+ /**
521
+ * A `MINECRAFT_VERIFICATION_FAILED` refusal (HTTP 401) from `portal.signInWithMinecraft`, or
522
+ * `null`. `reason` is `extensions.reason`: `malformed`, `forged`, `expired`, `not_joined` or
523
+ * `replayed`. Never resend the same server id: ask for a new challenge
524
+ * (`portal.minecraftChallenge`) and join it again.
525
+ */
526
+ export function minecraftVerificationFailedOf(value) {
527
+ const entry = errorWithCode(value, MINECRAFT_VERIFICATION_FAILED_CODE);
528
+ if (!entry)
529
+ return null;
530
+ const reason = entry.extensions?.reason;
531
+ return { reason: typeof reason === 'string' && reason.length > 0 ? reason : null };
532
+ }
533
+ /**
534
+ * Whether an error is a `MINECRAFT_VERIFICATION_UNAVAILABLE` refusal (HTTP 503): Mojang's
535
+ * session service did not answer, so the account was not confirmed. Retryable shortly, with a
536
+ * new challenge.
537
+ */
538
+ export function minecraftVerificationUnavailableOf(value) {
539
+ return errorWithCode(value, MINECRAFT_VERIFICATION_UNAVAILABLE_CODE) !== null;
540
+ }
378
541
  /**
379
542
  * An `APP_PAUSED` refusal (HTTP 403: the app's runtime gate is not ACTIVE), or
380
543
  * `null`. `reason` is `extensions.reason`. Show the player that the world is