@crowdedkingdoms/crowdyjs 18.23.1 → 18.25.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 +91 -0
  2. package/README.md +181 -28
  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 +49 -3
  13. package/dist/domains/apps.d.ts.map +1 -1
  14. package/dist/domains/apps.js +52 -3
  15. package/dist/domains/auth.d.ts +145 -16
  16. package/dist/domains/auth.d.ts.map +1 -1
  17. package/dist/domains/auth.js +158 -16
  18. package/dist/domains/inputLog.d.ts +9 -2
  19. package/dist/domains/inputLog.d.ts.map +1 -1
  20. package/dist/domains/inputLog.js +9 -2
  21. package/dist/domains/managedPlayers.d.ts +66 -3
  22. package/dist/domains/managedPlayers.d.ts.map +1 -1
  23. package/dist/domains/managedPlayers.js +19 -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 +16 -0
  28. package/dist/domains/platform.d.ts.map +1 -1
  29. package/dist/domains/platform.js +17 -0
  30. package/dist/domains/portal.d.ts +88 -8
  31. package/dist/domains/portal.d.ts.map +1 -1
  32. package/dist/domains/portal.js +80 -8
  33. package/dist/domains/safety.d.ts +164 -0
  34. package/dist/domains/safety.d.ts.map +1 -0
  35. package/dist/domains/safety.js +168 -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 +163 -0
  40. package/dist/errors.d.ts.map +1 -1
  41. package/dist/errors.js +188 -0
  42. package/dist/generated/graphql-schema.d.ts +568 -17
  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 +378 -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
@@ -1,5 +1,5 @@
1
1
  import { parse } from 'graphql';
2
- import { LogoutAllDevicesDocument, LogoutDocument } from '../generated/graphql.js';
2
+ import { LogoutAllDevicesDocument, LogoutDocument, } from '../generated/graphql.js';
3
3
  /**
4
4
  * The `extensions.code` of the first GraphQL error, if there is one.
5
5
  *
@@ -130,8 +130,23 @@ const SocialLoginCompleteDocument = parse(`mutation SocialLoginComplete($input:
130
130
  const LoginDocument = parse(`mutation Login($loginUserInput: LoginUserInput!) { login(loginUserInput: $loginUserInput) { ${AUTH_RESPONSE_FIELDS} } }`);
131
131
  const RegisterDocument = parse(`mutation Register($registerUserInput: RegisterUserInput!) { register(registerUserInput: $registerUserInput) { ${AUTH_RESPONSE_FIELDS} } }`);
132
132
  // THE CLICKWRAP (ck-api v2.35.0). A gameplay token is refused until both are stored.
133
+ // This document is the 18.23 one, kept byte for byte: an API before v2.60.0 declares the
134
+ // attestation `Boolean!`, so a nullable variable would fail validation there. It is sent
135
+ // whenever the call is the old one (both flags, no app, no method).
133
136
  const RecordPlayerConsentsDocument = parse(`mutation RecordPlayerConsents($acceptLegal: Boolean!, $attestAgeOfMajority: Boolean!) { recordPlayerConsents(acceptLegal: $acceptLegal, attestAgeOfMajority: $attestAgeOfMajority) }`);
137
+ // ck-api v2.60.0: an app's own documents, how they were accepted, and an attestation the
138
+ // platform ignores once it asks for a birth date instead.
139
+ const RecordPlayerConsentsForAppDocument = parse(`mutation RecordPlayerConsentsForApp($acceptLegal: Boolean!, $attestAgeOfMajority: Boolean, $appId: BigInt, $method: LegalAcceptanceMethod) { recordPlayerConsents(acceptLegal: $acceptLegal, attestAgeOfMajority: $attestAgeOfMajority, appId: $appId, method: $method) }`);
134
140
  const PlayerLegalAcceptanceDocument = parse(`query PlayerLegalAcceptance { playerLegalAcceptance }`);
141
+ const PlayerLegalAcceptanceForAppDocument = parse(`query PlayerLegalAcceptanceForApp($appId: BigInt!) { playerLegalAcceptance(appId: $appId) }`);
142
+ // THE AGE (ck-api v2.60.0). Only the year and month are kept.
143
+ const RecordPlayerAgeDocument = parse(`mutation RecordPlayerAge($input: RecordPlayerAgeInput!) { recordPlayerAge(input: $input) { userId ageBracket country } }`);
144
+ const LEGAL_DOCUMENT_FIELDS = 'documentId version title url appId';
145
+ const PlayerLegalDocumentsDocument = parse(`query PlayerLegalDocuments { playerLegalDocuments { ${LEGAL_DOCUMENT_FIELDS} } }`);
146
+ const AppRequiredDocumentsDocument = parse(`query AppRequiredDocuments($appId: BigInt!) { appRequiredDocuments(appId: $appId) { ${LEGAL_DOCUMENT_FIELDS} } }`);
147
+ const DeveloperLegalDocumentsDocument = parse(`query DeveloperLegalDocuments { developerLegalDocuments { ${LEGAL_DOCUMENT_FIELDS} } }`);
148
+ const DeveloperLegalAcceptanceDocument = parse(`query DeveloperLegalAcceptance { developerLegalAcceptance }`);
149
+ const RecordDeveloperConsentsDocument = parse(`mutation RecordDeveloperConsents($acceptDeveloperTerms: Boolean!) { recordDeveloperConsents(acceptDeveloperTerms: $acceptDeveloperTerms) }`);
135
150
  // PASSWORD MANAGEMENT. Four mutations, and they are four rather than one or two
136
151
  // on purpose: each is defined by what the CALLER has already proven, and
137
152
  // collapsing any pair would delete the proof.
@@ -247,6 +262,19 @@ export class AuthAPI {
247
262
  * exists; the account then starts accepted. A client with no browser origin may
248
263
  * omit them and call {@link recordPlayerConsents} before its first gameplay
249
264
  * token.
265
+ *
266
+ * **The age (ck-api v2.60.0).** `birthDate`, `country` and, for a player under 18,
267
+ * `parentalConfirmation` are the answers of a neutral age screen: it asks the date
268
+ * of birth and the country and shows no age, and only a player under 18 sees the
269
+ * line that a parent or guardian agreed. They are optional until the platform
270
+ * admits players under 18; after that a browser sign-up without them is refused
271
+ * `AGE_REQUIRED`, and a request with no browser origin may give them later with
272
+ * {@link recordPlayerAge}. A country Crowded Kingdoms does not serve, declared or
273
+ * detected, is refused `TERRITORY_NOT_SUPPORTED` (`territoryNotSupportedOf`), and an
274
+ * age the platform does not admit `AGE_REQUIREMENT_NOT_MET`
275
+ * (`ageRequirementNotMetOf`); either way no account is made. Since ck-api v2.61.0
276
+ * the age refusal names no age, and for 24 hours the same client (address and user
277
+ * agent) is refused it whatever it sends.
250
278
  */
251
279
  async register(input) {
252
280
  const data = await this.graphql.request(RegisterDocument, {
@@ -257,32 +285,146 @@ export class AuthAPI {
257
285
  return data.register;
258
286
  }
259
287
  /**
260
- * Store the signed-in player's agreement to the current required legal
261
- * documents (Game Terms, API Terms, SDK Developer Terms, Free Tier and Billing
262
- * Basis, Overworld Privacy Policy) and their attestation that they are at least
263
- * 18, or the age of majority where they live if that is higher. Requires the
264
- * identity session token; both must be `true`, and repeating it is harmless.
288
+ * Store the signed-in player's agreement to the platform's current player
289
+ * documents ({@link playerLegalDocuments}) and, with `appId`, to that app's own
290
+ * ({@link appRequiredDocuments}). Requires the identity session token;
291
+ * `acceptLegal` must be `true`, and repeating it is harmless.
292
+ *
293
+ * `attestAgeOfMajority` (the player is at least 18, or the age of majority where
294
+ * they live if higher) must be `true` while the platform still uses the
295
+ * attestation; once players give a birth date instead ({@link recordPlayerAge})
296
+ * the server ignores it, and it may be left out. `method` records how the player
297
+ * accepted: `CLICKWRAP` (the default; a Crowded Kingdoms or SDK form) or `IN_GAME`
298
+ * (the app's own screen).
265
299
  *
266
300
  * Since ck-api v2.35.0 a gameplay token (`portal.mintAppToken`,
267
301
  * `portal.createAuthorizationCode`, `portal.refresh`) is refused with
268
- * `LEGAL_ACCEPTANCE_REQUIRED` ({@link isLegalAcceptanceRequiredError}) until
269
- * this is stored. It records the PLAYER's agreement: call it only after they
270
- * have ticked both boxes in your own UI, linking each document. A browser game
271
- * never needs it, because Studio's hosted `/authorize` asks for both.
302
+ * `LEGAL_ACCEPTANCE_REQUIRED` ({@link isLegalAcceptanceRequiredError};
303
+ * `legalAcceptanceRequiredOf` lists the missing documents) until this is stored.
304
+ * It records the PLAYER's agreement: call it only after they ticked the box in
305
+ * your own UI, which links each document. A browser game never needs it, because
306
+ * Studio's hosted `/authorize` asks.
307
+ *
308
+ * `appId`, `method` and leaving the attestation out need ck-api v2.60.0; the call
309
+ * with both flags and neither of those works against any API since v2.35.0.
272
310
  */
273
311
  async recordPlayerConsents(input) {
274
- const data = await this.graphql.request(RecordPlayerConsentsDocument, input);
312
+ const { acceptLegal, attestAgeOfMajority, appId, method } = input;
313
+ if (typeof attestAgeOfMajority === 'boolean' &&
314
+ appId === undefined &&
315
+ method === undefined) {
316
+ const data = await this.graphql.request(RecordPlayerConsentsDocument, {
317
+ acceptLegal,
318
+ attestAgeOfMajority,
319
+ });
320
+ return data.recordPlayerConsents;
321
+ }
322
+ const data = await this.graphql.request(RecordPlayerConsentsForAppDocument, {
323
+ acceptLegal,
324
+ ...(attestAgeOfMajority !== undefined ? { attestAgeOfMajority } : {}),
325
+ ...(appId !== undefined ? { appId } : {}),
326
+ ...(method !== undefined ? { method } : {}),
327
+ });
275
328
  return data.recordPlayerConsents;
276
329
  }
277
330
  /**
278
- * Whether the signed-in player has the current required documents and the age
279
- * attestation stored, i.e. whether a gameplay token would be issued. Requires
280
- * the identity session token. ck-api v2.35.0.
331
+ * Whether the signed-in player has stored the platform's current player
332
+ * documents and, while the platform asks for one, the age attestation or a birth
333
+ * date: whether a gameplay token would be issued. With `appId` the app's own
334
+ * documents count too (ck-api v2.60.0). Requires the identity session token.
335
+ * ck-api v2.35.0.
281
336
  */
282
- async playerLegalAcceptance() {
283
- const data = await this.graphql.request(PlayerLegalAcceptanceDocument, {});
337
+ async playerLegalAcceptance(options = {}) {
338
+ const data = options.appId !== undefined
339
+ ? await this.graphql.request(PlayerLegalAcceptanceForAppDocument, {
340
+ appId: options.appId,
341
+ })
342
+ : await this.graphql.request(PlayerLegalAcceptanceDocument, {});
284
343
  return data.playerLegalAcceptance;
285
344
  }
345
+ /**
346
+ * The platform's documents every player accepts before playing, at the versions
347
+ * required now: show them (with the app's own, {@link appRequiredDocuments})
348
+ * before {@link recordPlayerConsents}. Each has `documentId`, `version`, `title`
349
+ * and `url`. Public. ck-api v2.60.0.
350
+ */
351
+ async playerLegalDocuments() {
352
+ const data = await this.graphql.request(PlayerLegalDocumentsDocument, {});
353
+ return data.playerLegalDocuments;
354
+ }
355
+ /**
356
+ * An app's own documents (its rules, an addendum), which its players accept on top
357
+ * of the platform's: record them with {@link recordPlayerConsents} and the
358
+ * `appId` before the player's next mint. Empty when the app requires none. Its
359
+ * admins set them with `apps.setRequiredDocuments`. Public. ck-api v2.60.0.
360
+ */
361
+ async appRequiredDocuments(appId) {
362
+ const data = await this.graphql.request(AppRequiredDocumentsDocument, { appId });
363
+ return data.appRequiredDocuments;
364
+ }
365
+ /**
366
+ * Record the signed-in player's birth date and country, and under 18 that a parent
367
+ * or guardian agreed, for an account whose age is not known yet (`users.me()`'s
368
+ * `ageBracket` is `unknown`, and a mint answers `AGE_REQUIRED`). Only the year and
369
+ * month are kept. Requires the identity session token. ck-api v2.60.0.
370
+ *
371
+ * Ask on a neutral screen: the date of birth and the country, with no age shown,
372
+ * and the parental line only for a player under 18. Refused with `CONFLICT` once
373
+ * the account has an age, `TERRITORY_NOT_SUPPORTED` where Crowded Kingdoms does not
374
+ * serve (the declared country, or the network's country or region), and
375
+ * `AGE_REQUIREMENT_NOT_MET` under the platform's youngest age. Since ck-api v2.61.0
376
+ * that refusal names no age, the account is deleted and erased as
377
+ * `users.deleteMyAccount` does, and for 24 hours the same client (address and user
378
+ * agent) is refused here and at sign-up whatever it sends: drop the session and do
379
+ * not ask again. Whether the player may play a given app is decided at the mint.
380
+ * Returns the account's `ageBracket` and `country`.
381
+ */
382
+ async recordPlayerAge(input) {
383
+ const data = await this.graphql.request(RecordPlayerAgeDocument, {
384
+ input: {
385
+ birthDate: input.birthDate,
386
+ country: input.country,
387
+ ...(input.parentalConfirmation !== undefined
388
+ ? { parentalConfirmation: input.parentalConfirmation }
389
+ : {}),
390
+ },
391
+ });
392
+ return data.recordPlayerAge;
393
+ }
394
+ /**
395
+ * The documents a developer accepts before creating or administering an
396
+ * organization, at the versions required now. Empty while the platform asks
397
+ * developers for nothing beyond the player documents. Public. ck-api v2.60.0.
398
+ */
399
+ async developerLegalDocuments() {
400
+ const data = await this.graphql.request(DeveloperLegalDocumentsDocument, {});
401
+ return data.developerLegalDocuments;
402
+ }
403
+ /**
404
+ * Whether the signed-in account has accepted the current developer documents.
405
+ * False means creating or administering an organization is refused with
406
+ * `LEGAL_ACCEPTANCE_REQUIRED` until {@link recordDeveloperConsents}. Requires the
407
+ * identity session token. ck-api v2.60.0.
408
+ */
409
+ async developerLegalAcceptance() {
410
+ const data = await this.graphql.request(DeveloperLegalAcceptanceDocument, {});
411
+ return data.developerLegalAcceptance;
412
+ }
413
+ /**
414
+ * Store the signed-in account's agreement to the current developer documents
415
+ * ({@link developerLegalDocuments}); `acceptDeveloperTerms` must be `true`, and
416
+ * repeating it is harmless. It records a person's agreement: call it only after
417
+ * they ticked the box in your own UI, linking each document. The developer
418
+ * documents are for adults: an account with no age is refused `AGE_REQUIRED`
419
+ * ({@link recordPlayerAge} first) and one under 18 `AGE_REQUIREMENT_NOT_MET`.
420
+ * Requires the identity session token. ck-api v2.60.0.
421
+ */
422
+ async recordDeveloperConsents(input) {
423
+ const data = await this.graphql.request(RecordDeveloperConsentsDocument, {
424
+ acceptDeveloperTerms: input.acceptDeveloperTerms,
425
+ });
426
+ return data.recordDeveloperConsents;
427
+ }
286
428
  /**
287
429
  * Email-first adaptive login: does this address have password sign-in enabled?
288
430
  * Public, and deliberately does not reveal whether the address is registered.
@@ -32,8 +32,15 @@ export interface InputLogPageOptions<Filter> {
32
32
  * or hosted sign-in). An identity session token is refused, and the client follows
33
33
  * the app to its datacenter like any gameplay call.
34
34
  *
35
- * **Who sees what.** A player reads only the sessions and inputs they sent. A holder of
36
- * `manage_apps` on the app reads every session and may filter by `userId`.
35
+ * **Who sees what.** Every player reads the sessions and inputs they sent: on an app with
36
+ * the safety log, that is the player's own records (call {@link sessions} without a filter,
37
+ * then {@link messages} for one of them). A moderator (`moderate_safety`: an appointed
38
+ * moderator or the organization's admins, ck-api v2.60.0) reads only the sessions an open or
39
+ * escalated safety report covers (`client.moderation.reports(appId)`, each report's
40
+ * `sessions`; `filter.userId` narrows them). `manage_apps` reads every session and may
41
+ * filter by `userId` only on an app for adults (effective minimum age 18), and never a
42
+ * player under 18's (ck-api v2.61.0). Every read of another player's session is audited, and
43
+ * on an app that admits players under 18 every read is, the player's own included.
37
44
  *
38
45
  * Inputs are kept for the input log's published retention (crowdedkingdoms.com/pricing,
39
46
  * up to about an hour longer) and then deleted, so an old session can still be listed
@@ -1 +1 @@
1
- {"version":3,"file":"inputLog.d.ts","sourceRoot":"","sources":["../../src/domains/inputLog.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAElD,OAAO,EAGL,KAAK,qBAAqB,EAC1B,KAAK,qBAAqB,EAC1B,KAAK,qBAAqB,EAC1B,KAAK,qBAAqB,EAC3B,MAAM,yBAAyB,CAAC;AAEjC,gDAAgD;AAChD,MAAM,MAAM,mBAAmB,GAAG,qBAAqB,CAAC,kBAAkB,CAAC,CAAC;AAC5E,wEAAwE;AACxE,MAAM,MAAM,qBAA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C;AAEjC,gDAAgD;AAChD,MAAM,MAAM,mBAAmB,GAAG,qBAAqB,CAAC,kBAAkB,CAAC,CAAC;AAC5E,wEAAwE;AACxE,MAAM,MAAM,qBAAqB,GAAG,mBAAmB,CAAC,OAAO,CAAC,CAAC,MAAM,CAAC,CAAC,MAAM,CAAC,CAAC;AACjF,gDAAgD;AAChD,MAAM,MAAM,mBAAmB,GAAG,qBAAqB,CAAC,kBAAkB,CAAC,CAAC;AAC5E,sEAAsE;AACtE,MAAM,MAAM,qBAAqB,GAAG,mBAAmB,CAAC,OAAO,CAAC,CAAC,MAAM,CAAC,CAAC,MAAM,CAAC,CAAC;AAEjF,4FAA4F;AAC5F,MAAM,WAAW,mBAAmB,CAAC,MAAM;IACzC,iEAAiE;IACjE,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,uEAAuE;IACvE,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB;;;;;OAKG;IACH,MAAM,CAAC,EAAE,WAAW,CAAC;CACtB;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AACH,qBAAa,WAAW;IACV,OAAO,CAAC,GAAG;gBAAH,GAAG,EAAE,aAAa;IAEtC;;;;;;;;;;;;;;;;;;;;;OAqBG;IACG,QAAQ,CACZ,KAAK,EAAE,MAAM,EACb,IAAI,GAAE,mBAAmB,CAAC,qBAAqB,CAAM,GACpD,OAAO,CAAC,mBAAmB,CAAC;IAS/B;;;;;;;;;;;;;;;;;;;;;;;;;OAyBG;IACG,QAAQ,CACZ,KAAK,EAAE,MAAM,EACb,WAAW,EAAE,MAAM,EACnB,IAAI,GAAE,mBAAmB,CAAC,qBAAqB,CAAM,GACpD,OAAO,CAAC,mBAAmB,CAAC;CAQhC"}
@@ -8,8 +8,15 @@ import { InputLogMessagesDocument, InputLogSessionsDocument, } from '../generate
8
8
  * or hosted sign-in). An identity session token is refused, and the client follows
9
9
  * the app to its datacenter like any gameplay call.
10
10
  *
11
- * **Who sees what.** A player reads only the sessions and inputs they sent. A holder of
12
- * `manage_apps` on the app reads every session and may filter by `userId`.
11
+ * **Who sees what.** Every player reads the sessions and inputs they sent: on an app with
12
+ * the safety log, that is the player's own records (call {@link sessions} without a filter,
13
+ * then {@link messages} for one of them). A moderator (`moderate_safety`: an appointed
14
+ * moderator or the organization's admins, ck-api v2.60.0) reads only the sessions an open or
15
+ * escalated safety report covers (`client.moderation.reports(appId)`, each report's
16
+ * `sessions`; `filter.userId` narrows them). `manage_apps` reads every session and may
17
+ * filter by `userId` only on an app for adults (effective minimum age 18), and never a
18
+ * player under 18's (ck-api v2.61.0). Every read of another player's session is audited, and
19
+ * on an app that admits players under 18 every read is, the player's own included.
13
20
  *
14
21
  * Inputs are kept for the input log's published retention (crowdedkingdoms.com/pricing,
15
22
  * up to about an hour longer) and then deleted, so an old session can still be listed
@@ -4,6 +4,53 @@ import { type ManagedPlayersQuery, type ManagedPlayerQuery, type ProvisionManage
4
4
  export type OrgSigningKeyRegistration = Omit<RegisterOrgSigningKeyInput, 'publicJwk'> & {
5
5
  publicJwk: string | Record<string, unknown>;
6
6
  };
7
+ /**
8
+ * The claims of a player assertion, as the organization's sign-in service signs them (a
9
+ * compact JWS whose header names `alg`, `EdDSA`, `ES256` or `RS256`, and the registered key's
10
+ * `kid`). The device trades the assertion with `portal.exchangeManagedPlayerAssertion`. This
11
+ * SDK does not sign assertions: the private key stays with the sign-in service.
12
+ */
13
+ export interface ManagedPlayerAssertionClaims {
14
+ /** The issuer registered with the key. */
15
+ iss: string;
16
+ /** The key's audience, or `ck:app:<appId>` when it has none. */
17
+ aud: string | string[];
18
+ /** The organization's own id for the player: 1-256 characters, no control characters. */
19
+ sub: string;
20
+ /** Issued at, in seconds since the epoch. */
21
+ iat: number;
22
+ /** Expiry, in seconds since the epoch: at most 300 seconds after `iat`. */
23
+ exp: number;
24
+ /** Not before, in seconds since the epoch. */
25
+ nbf?: number;
26
+ /** A fresh id (1-128 characters), accepted once per app. */
27
+ jti: string;
28
+ /** Display name, at most 64 characters. */
29
+ gamertag?: string;
30
+ /**
31
+ * The player's age in whole years, as the organization knows it (ck-api v2.60.0). Stored as
32
+ * an age bracket that sets a minor's defaults; a player under the app's, the country's or
33
+ * the platform's youngest age is refused `AGE_REQUIREMENT_NOT_MET`. Optional while every
34
+ * managed player is 18 or older under the Org-Managed Players Addendum (left out, the
35
+ * player counts as an adult); required once the platform admits players under 18
36
+ * (`AGE_REQUIRED` without it).
37
+ */
38
+ ageYears?: number;
39
+ /**
40
+ * The country the player lives in, ISO 3166-1 alpha-2 (ck-api v2.60.0). A country Crowded
41
+ * Kingdoms does not serve is refused `TERRITORY_NOT_SUPPORTED`, and the country's own
42
+ * youngest age applies. Optional until the platform admits players under 18, required
43
+ * after.
44
+ */
45
+ country?: string;
46
+ /**
47
+ * The region the player lives in, ISO 3166-2 within `country` (such as `UA-30`; ck-api
48
+ * v2.61.0). Required in a country Crowded Kingdoms checks by region (the regions
49
+ * `platform.territoryPolicies()` lists, Ukraine's today): without it, or in a blocked region,
50
+ * the player is refused `TERRITORY_NOT_SUPPORTED`. Checked at each sign-in, not stored.
51
+ */
52
+ region?: string;
53
+ }
7
54
  /**
8
55
  * Org-managed players: an organization's own players, signed in by the organization
9
56
  * instead of with a Crowded Kingdoms email and password. Exposed as
@@ -19,8 +66,22 @@ export type OrgSigningKeyRegistration = Omit<RegisterOrgSigningKeyInput, 'public
19
66
  * it never belongs in a browser or a game client, and the API refuses one sent with an
20
67
  * `Origin` header.
21
68
  * - **With a signed assertion**: the organization registers a public key here
22
- * ({@link registerSigningKey}), its sign-in service signs a short JWS for the player, and
23
- * the device trades it with `client.portal.exchangeManagedPlayerAssertion`.
69
+ * ({@link registerSigningKey}), its sign-in service signs a short JWS for the player
70
+ * ({@link ManagedPlayerAssertionClaims}), and the device trades it with
71
+ * `client.portal.exchangeManagedPlayerAssertion`.
72
+ *
73
+ * **Age and country (ck-api v2.60.0).** Either way the organization says how old the player
74
+ * is and where it lives: `ageYears`, `country` and, where the country is checked by region,
75
+ * `region` (v2.61.0) on the mint's input (`MintManagedPlayerTokenInput`) or as the assertion's
76
+ * claims. Crowded Kingdoms stores an age bracket and the country on the player, applies a
77
+ * minor's defaults itself, and refuses the sign-in with `TERRITORY_NOT_SUPPORTED` in a country
78
+ * or region it does not serve (or without a region it needs) and `AGE_REQUIREMENT_NOT_MET`
79
+ * under the app's, the country's or the platform's youngest age, before the player is created.
80
+ * That refusal names no age, the same player is refused for 24 hours whatever is sent, and a
81
+ * player that exists and is said to be under 13 is deleted. The age and country are optional
82
+ * while every managed player is 18 or older under the Org-Managed Players Addendum (left out,
83
+ * the player counts as an adult), and required once the platform admits players under 18
84
+ * (`AGE_REQUIRED` without an age).
24
85
  *
25
86
  * The methods below are the organization's administration. They take an org admin's
26
87
  * session with the `manage_players` permission (or, from the organization's server, an org
@@ -74,7 +135,9 @@ export declare class ManagedPlayersAPI {
74
135
  * again, so a later sign-in with it creates a new player. Since Game API v2.54.0 its
75
136
  * player-side content is erased within minutes (usage and billing records and world edits
76
137
  * stay), and a legal hold on the player or its organization refuses the delete with
77
- * `LEGAL_HOLD`; the player stays as it was.
138
+ * `LEGAL_HOLD`; the player stays as it was. Since v2.60.0 an open or escalated safety
139
+ * report about the player sets such a hold first: disable the player instead
140
+ * ({@link update}), which keeps everything.
78
141
  */
79
142
  delete(orgId: string, externalId: string): Promise<boolean>;
80
143
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"managedPlayers.d.ts","sourceRoot":"","sources":["../../src/domains/managedPlayers.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAClD,OAAO,EAaL,KAAK,mBAAmB,EACxB,KAAK,kBAAkB,EACvB,KAAK,+BAA+B,EACpC,KAAK,2BAA2B,EAChC,KAAK,6BAA6B,EAClC,KAAK,mBAAmB,EACxB,KAAK,6BAA6B,EAClC,KAAK,4BAA4B,EACjC,KAAK,wBA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ClF,WAAW,CAAC,KAAK,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAKtE;;;;;;;;OAQG;IACG,MAAM,CAAC,KAAK,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAKjE;;;;;;OAMG;IACG,QAAQ,CACZ,KAAK,EAAE,MAAM,GACZ,OAAO,CAAC,6BAA6B,CAAC,0BAA0B,CAAC,CAAC;IAKrE,wEAAwE;IAClE,WAAW,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,mBAAmB,CAAC,gBAAgB,CAAC,CAAC;IAKhF;;;;;;;OAOG;IACG,kBAAkB,CACtB,KAAK,EAAE,yBAAyB,GAC/B,OAAO,CAAC,6BAA6B,CAAC,uBAAuB,CAAC,CAAC;IAiBlE,0EAA0E;IACpE,gBAAgB,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAKtE;;;;;OAKG;IACG,cAAc,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAKrD;;;;OAIG;IACG,UAAU,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC;CAIpE"}
@@ -28,8 +28,22 @@ function privateJwkMember(json) {
28
28
  * it never belongs in a browser or a game client, and the API refuses one sent with an
29
29
  * `Origin` header.
30
30
  * - **With a signed assertion**: the organization registers a public key here
31
- * ({@link registerSigningKey}), its sign-in service signs a short JWS for the player, and
32
- * the device trades it with `client.portal.exchangeManagedPlayerAssertion`.
31
+ * ({@link registerSigningKey}), its sign-in service signs a short JWS for the player
32
+ * ({@link ManagedPlayerAssertionClaims}), and the device trades it with
33
+ * `client.portal.exchangeManagedPlayerAssertion`.
34
+ *
35
+ * **Age and country (ck-api v2.60.0).** Either way the organization says how old the player
36
+ * is and where it lives: `ageYears`, `country` and, where the country is checked by region,
37
+ * `region` (v2.61.0) on the mint's input (`MintManagedPlayerTokenInput`) or as the assertion's
38
+ * claims. Crowded Kingdoms stores an age bracket and the country on the player, applies a
39
+ * minor's defaults itself, and refuses the sign-in with `TERRITORY_NOT_SUPPORTED` in a country
40
+ * or region it does not serve (or without a region it needs) and `AGE_REQUIREMENT_NOT_MET`
41
+ * under the app's, the country's or the platform's youngest age, before the player is created.
42
+ * That refusal names no age, the same player is refused for 24 hours whatever is sent, and a
43
+ * player that exists and is said to be under 13 is deleted. The age and country are optional
44
+ * while every managed player is 18 or older under the Org-Managed Players Addendum (left out,
45
+ * the player counts as an adult), and required once the platform admits players under 18
46
+ * (`AGE_REQUIRED` without an age).
33
47
  *
34
48
  * The methods below are the organization's administration. They take an org admin's
35
49
  * session with the `manage_players` permission (or, from the organization's server, an org
@@ -95,7 +109,9 @@ export class ManagedPlayersAPI {
95
109
  * again, so a later sign-in with it creates a new player. Since Game API v2.54.0 its
96
110
  * player-side content is erased within minutes (usage and billing records and world edits
97
111
  * stay), and a legal hold on the player or its organization refuses the delete with
98
- * `LEGAL_HOLD`; the player stays as it was.
112
+ * `LEGAL_HOLD`; the player stays as it was. Since v2.60.0 an open or escalated safety
113
+ * report about the player sets such a hold first: disable the player instead
114
+ * ({@link update}), which keeps everything.
99
115
  */
100
116
  async delete(orgId, externalId) {
101
117
  const data = await this.api.request(DeleteManagedPlayerDocument, { orgId, externalId });
@@ -0,0 +1,53 @@
1
+ import type { GraphQLClient } from '../client.js';
2
+ import { type SafetyReportsQuery } from '../generated/graphql.js';
3
+ /** Where a safety report stands: waiting, closed with an outcome, or sent to the CyberTipline. */
4
+ export type SafetyReportStatusValue = 'OPEN' | 'RESOLVED' | 'ESCALATED';
5
+ /** A safety report as a moderator reads it ({@link ModerationAPI.reports}). */
6
+ export type SafetyReportRecord = SafetyReportsQuery['safetyReports'][number];
7
+ /**
8
+ * An app's safety reports, for its moderators — exposed as `client.moderation` (and
9
+ * `client.admin.moderation`; ck-api v2.60.0).
10
+ *
11
+ * Players file reports with `client.safety.fileReport`. Each one links both players'
12
+ * recorded sessions around it, and the platform preserves those with both identities while
13
+ * the report is open. A moderator reads the reports, reads the sessions a report covers, and
14
+ * decides it: {@link resolveReport} closes it and deletes the preserved copy;
15
+ * {@link escalateReport} records a CyberTipline submission and keeps the copy for a year.
16
+ *
17
+ * **Who.** Every call needs `moderate_safety` on the app: an organization role that grants it,
18
+ * or an admin of the app's organization. Send the moderator's identity session (not an app
19
+ * token) to the app's datacenter (`apps.routeFor`, or `discovery`).
20
+ *
21
+ * **Reading a reported session.** `SafetyReport.sessions` names the recorded sessions
22
+ * (`InputLogSession.gameTokenId`) the report covers. A moderator mints an app token for the
23
+ * app (`portal.mintAppToken`) and reads them with `client.inputLog.messages(appId,
24
+ * gameTokenId)` on the app's client while the report is open or escalated; every read is
25
+ * audited.
26
+ */
27
+ export declare class ModerationAPI {
28
+ private readonly api;
29
+ constructor(api: GraphQLClient);
30
+ /**
31
+ * The app's reports, newest first, with open `CHILD_SAFETY` reports ahead of the rest.
32
+ * `status` keeps one kind; `first` defaults to 50 (1 to 200).
33
+ */
34
+ reports(appId: string, options?: {
35
+ status?: SafetyReportStatusValue;
36
+ first?: number;
37
+ }): Promise<SafetyReportRecord[]>;
38
+ /**
39
+ * Resolve an open report with its outcome (at most 1,000 characters): its preserved copy is
40
+ * deleted, and a legal hold its reported account got on deletion is released. Resolving it
41
+ * again changes nothing; an escalated report cannot be resolved (`BAD_REQUEST`).
42
+ */
43
+ resolveReport(appId: string, reportId: string, outcome: string): Promise<SafetyReportRecord>;
44
+ /**
45
+ * Record that an open report was submitted to NCMEC's CyberTipline, under the id NCMEC
46
+ * gave the submission: its preserved copy is kept under retention for a year from now, and
47
+ * the reported account's legal hold, if any, as long. Again under the same id changes
48
+ * nothing; under another id is `CONFLICT`; a resolved report cannot be escalated
49
+ * (`BAD_REQUEST`).
50
+ */
51
+ escalateReport(appId: string, reportId: string, ncmecReportId: string): Promise<SafetyReportRecord>;
52
+ }
53
+ //# sourceMappingURL=moderation.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"moderation.d.ts","sourceRoot":"","sources":["../../src/domains/moderation.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAClD,OAAO,EAKL,KAAK,kBAAkB,EACxB,MAAM,yBAAyB,CAAC;AAEjC,kGAAkG;AAClG,MAAM,MAAM,uBAAuB,GAAG,MAAM,GAAG,UAAU,GAAG,WAAW,CAAC;AAExE,+EAA+E;AAC/E,MAAM,MAAM,kBAAkB,GAAG,kBAAkB,CAAC,eAAe,CAAC,CAAC,MAAM,CAAC,CAAC;AAE7E;;;;;;;;;;;;;;;;;;;GAmBG;AACH,qBAAa,aAAa;IACZ,OAAO,CAAC,QAAQ,CAAC,GAAG;gBAAH,GAAG,EAAE,aAAa;IAE/C;;;OAGG;IACG,OAAO,CACX,KAAK,EAAE,MAAM,EACb,OAAO,GAAE;QAAE,MAAM,CAAC,EAAE,uBAAuB,CAAC;QAAC,KAAK,CAAC,EAAE,MAAM,CAAA;KAAO,GACjE,OAAO,CAAC,kBAAkB,EAAE,CAAC;IAWhC;;;;OAIG;IACG,aAAa,CACjB,KAAK,EAAE,MAAM,EACb,QAAQ,EAAE,MAAM,EAChB,OAAO,EAAE,MAAM,GACd,OAAO,CAAC,kBAAkB,CAAC;IAS9B;;;;;;OAMG;IACG,cAAc,CAClB,KAAK,EAAE,MAAM,EACb,QAAQ,EAAE,MAAM,EAChB,aAAa,EAAE,MAAM,GACpB,OAAO,CAAC,kBAAkB,CAAC;CAQ/B"}
@@ -0,0 +1,68 @@
1
+ import { SafetyReportsDocument, ResolveSafetyReportDocument, EscalateSafetyReportDocument, } from '../generated/graphql.js';
2
+ /**
3
+ * An app's safety reports, for its moderators — exposed as `client.moderation` (and
4
+ * `client.admin.moderation`; ck-api v2.60.0).
5
+ *
6
+ * Players file reports with `client.safety.fileReport`. Each one links both players'
7
+ * recorded sessions around it, and the platform preserves those with both identities while
8
+ * the report is open. A moderator reads the reports, reads the sessions a report covers, and
9
+ * decides it: {@link resolveReport} closes it and deletes the preserved copy;
10
+ * {@link escalateReport} records a CyberTipline submission and keeps the copy for a year.
11
+ *
12
+ * **Who.** Every call needs `moderate_safety` on the app: an organization role that grants it,
13
+ * or an admin of the app's organization. Send the moderator's identity session (not an app
14
+ * token) to the app's datacenter (`apps.routeFor`, or `discovery`).
15
+ *
16
+ * **Reading a reported session.** `SafetyReport.sessions` names the recorded sessions
17
+ * (`InputLogSession.gameTokenId`) the report covers. A moderator mints an app token for the
18
+ * app (`portal.mintAppToken`) and reads them with `client.inputLog.messages(appId,
19
+ * gameTokenId)` on the app's client while the report is open or escalated; every read is
20
+ * audited.
21
+ */
22
+ export class ModerationAPI {
23
+ constructor(api) {
24
+ this.api = api;
25
+ }
26
+ /**
27
+ * The app's reports, newest first, with open `CHILD_SAFETY` reports ahead of the rest.
28
+ * `status` keeps one kind; `first` defaults to 50 (1 to 200).
29
+ */
30
+ async reports(appId, options = {}) {
31
+ const data = await this.api.request(SafetyReportsDocument, {
32
+ appId,
33
+ ...(options.status !== undefined
34
+ ? { status: options.status }
35
+ : {}),
36
+ ...(options.first !== undefined ? { first: options.first } : {}),
37
+ });
38
+ return data.safetyReports;
39
+ }
40
+ /**
41
+ * Resolve an open report with its outcome (at most 1,000 characters): its preserved copy is
42
+ * deleted, and a legal hold its reported account got on deletion is released. Resolving it
43
+ * again changes nothing; an escalated report cannot be resolved (`BAD_REQUEST`).
44
+ */
45
+ async resolveReport(appId, reportId, outcome) {
46
+ const data = await this.api.request(ResolveSafetyReportDocument, {
47
+ appId,
48
+ reportId,
49
+ outcome,
50
+ });
51
+ return data.resolveSafetyReport;
52
+ }
53
+ /**
54
+ * Record that an open report was submitted to NCMEC's CyberTipline, under the id NCMEC
55
+ * gave the submission: its preserved copy is kept under retention for a year from now, and
56
+ * the reported account's legal hold, if any, as long. Again under the same id changes
57
+ * nothing; under another id is `CONFLICT`; a resolved report cannot be escalated
58
+ * (`BAD_REQUEST`).
59
+ */
60
+ async escalateReport(appId, reportId, ncmecReportId) {
61
+ const data = await this.api.request(EscalateSafetyReportDocument, {
62
+ appId,
63
+ reportId,
64
+ ncmecReportId,
65
+ });
66
+ return data.escalateSafetyReport;
67
+ }
68
+ }
@@ -1,4 +1,7 @@
1
1
  import type { GraphQLClient } from '../client.js';
2
+ import { type TerritoryPoliciesQuery } from '../generated/graphql.js';
3
+ /** One country Crowded Kingdoms lists ({@link PlatformAPI.territoryPolicies}). */
4
+ export type TerritoryPolicyRecord = TerritoryPoliciesQuery['territoryPolicies'][number];
2
5
  /**
3
6
  * Public platform discovery returned by {@link PlatformAPI.config}: how SDKs
4
7
  * find the shared game-api so they can route apps deployed to the shared
@@ -44,5 +47,18 @@ export declare class PlatformAPI {
44
47
  * @throws {CrowdyGraphQLError} on transport/validation failures.
45
48
  */
46
49
  config(): Promise<PlatformConfig>;
50
+ /**
51
+ * The countries Crowded Kingdoms lists, by ISO 3166-1 alpha-2 `countryCode`: `status`
52
+ * `blocked` for one it does not serve (sign-up and play are refused there with
53
+ * `TERRITORY_NOT_SUPPORTED`, by the country a player gives or connects from), and `open`
54
+ * with a `minAge` above the platform's for the others it lists. A country not listed is
55
+ * open at the platform's youngest age. Since ck-api v2.61.0 a row may be for one region of
56
+ * a country (`regionCode`, ISO 3166-2, such as `UA-43`; null on a country's own row): a
57
+ * country with a region listed is checked by region, so a connection whose region cannot be
58
+ * told is refused there, and an organization sends its players' `region`. **Public**, so a
59
+ * sign-up form can tell a player before an account exists that the service is not available
60
+ * where they are. Do not show the ages: a sign-up screen names none. ck-api v2.60.0.
61
+ */
62
+ territoryPolicies(): Promise<TerritoryPolicyRecord[]>;
47
63
  }
48
64
  //# sourceMappingURL=platform.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"platform.d.ts","sourceRoot":"","sources":["../../src/domains/platform.ts"],"names":[],"mappings":"AAEA,OAA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'graphql';
2
+ import { TerritoryPoliciesDocument, } from '../generated/graphql.js';
2
3
  // Hand-written document so the SDK can discover the shared game-api URL even
3
4
  // before codegen picks up the new schema (see src/operations/platform/).
4
5
  const PlatformConfigDocument = parse(/* GraphQL */ `
@@ -46,4 +47,20 @@ export class PlatformAPI {
46
47
  const data = await this.api.request(PlatformConfigDocument, {});
47
48
  return data.platformConfig;
48
49
  }
50
+ /**
51
+ * The countries Crowded Kingdoms lists, by ISO 3166-1 alpha-2 `countryCode`: `status`
52
+ * `blocked` for one it does not serve (sign-up and play are refused there with
53
+ * `TERRITORY_NOT_SUPPORTED`, by the country a player gives or connects from), and `open`
54
+ * with a `minAge` above the platform's for the others it lists. A country not listed is
55
+ * open at the platform's youngest age. Since ck-api v2.61.0 a row may be for one region of
56
+ * a country (`regionCode`, ISO 3166-2, such as `UA-43`; null on a country's own row): a
57
+ * country with a region listed is checked by region, so a connection whose region cannot be
58
+ * told is refused there, and an organization sends its players' `region`. **Public**, so a
59
+ * sign-up form can tell a player before an account exists that the service is not available
60
+ * where they are. Do not show the ages: a sign-up screen names none. ck-api v2.60.0.
61
+ */
62
+ async territoryPolicies() {
63
+ const data = await this.api.request(TerritoryPoliciesDocument, {});
64
+ return data.territoryPolicies;
65
+ }
49
66
  }