@crowdedkingdoms/crowdyjs 18.15.0 → 18.17.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.
@@ -0,0 +1,162 @@
1
+ import { ManagedPlayersDocument, ManagedPlayerDocument, ProvisionManagedPlayersDocument, UpdateManagedPlayerDocument, EndManagedPlayerSessionsDocument, DeleteManagedPlayerDocument, OrgManagedPlayerSettingsDocument, OrgSigningKeysDocument, RegisterOrgSigningKeyDocument, RevokeOrgSigningKeyDocument, AppManagedPlayerModsDocument, SetAppManagedPlayerModsDocument, } from '../generated/graphql.js';
2
+ /** The JWK members that only a private key has (RFC 7518: EC and OKP `d`, RSA's CRT values, `oct`'s `k`). */
3
+ const PRIVATE_JWK_MEMBERS = ['d', 'p', 'q', 'dp', 'dq', 'qi', 'oth', 'k'];
4
+ function privateJwkMember(json) {
5
+ let parsed;
6
+ try {
7
+ parsed = JSON.parse(json);
8
+ }
9
+ catch {
10
+ return null; // not JSON: the API refuses it with its own message
11
+ }
12
+ if (!parsed || typeof parsed !== 'object')
13
+ return null;
14
+ return PRIVATE_JWK_MEMBERS.find((m) => m in parsed) ?? null;
15
+ }
16
+ /**
17
+ * Org-managed players: an organization's own players, signed in by the organization
18
+ * instead of with a Crowded Kingdoms email and password. Exposed as
19
+ * `client.managedPlayers` (and `client.admin.managedPlayers`).
20
+ *
21
+ * An org-managed player has no email, password, session or wallet. Its organization
22
+ * vouches for it in one of two ways, and either one ends in the player's own app token:
23
+ *
24
+ * - **From its server, with an org token** (`cko_…`, scope `players:mint`): the server calls
25
+ * the `mintManagedPlayerToken` mutation itself and hands the response to the player's
26
+ * device, which stores it with `client.portal.adoptAppToken`. This SDK has no wrapper for
27
+ * that mutation on purpose: an org token signs in any of the organization's players, so
28
+ * it never belongs in a browser or a game client, and the API refuses one sent with an
29
+ * `Origin` header.
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`.
33
+ *
34
+ * The methods below are the organization's administration. They take an org admin's
35
+ * session with the `manage_players` permission (or, from the organization's server, an org
36
+ * token with `players:manage` for the player operations). An operator turns the feature on
37
+ * for an organization and sets its limits; {@link settings} reads them.
38
+ *
39
+ * **The Org-Managed Players Addendum** (ck-api v2.53.0). Before any of the organization's
40
+ * players is created or signed in, an admin of the organization accepts the addendum in
41
+ * Studio, on the organization's Players tab. Until then sign-ins (both ways), refreshes and
42
+ * {@link provision} answer `ORG_LEGAL_ACCEPTANCE_REQUIRED` (`orgLegalAcceptanceRequiredOf`).
43
+ * {@link settings} reports `termsVersion`, `termsUrl`, `termsAccepted` and whether the
44
+ * signed-in user may accept (`viewerMayAcceptTerms`). This SDK has no wrapper for the
45
+ * acceptance on purpose: it binds the organization, so a person makes it, in Studio.
46
+ *
47
+ * A tier that does not serve org-managed players answers `FEATURE_DISABLED` to every field.
48
+ */
49
+ export class ManagedPlayersAPI {
50
+ constructor(api) {
51
+ this.api = api;
52
+ }
53
+ /**
54
+ * The organization's players in the order they were created, a page at a time (`first`
55
+ * defaults to 50, at most 200). `search` matches the start of an external id (exactly) or
56
+ * of a gamertag (any case). Pass `nextCursor` back as `after` for the next page; it is
57
+ * null on the last.
58
+ */
59
+ async list(orgId, options = {}) {
60
+ const data = await this.api.request(ManagedPlayersDocument, { orgId, ...options });
61
+ return data.managedPlayers;
62
+ }
63
+ /** One player by the id the organization knows it by, or null. */
64
+ async get(orgId, externalId) {
65
+ const data = await this.api.request(ManagedPlayerDocument, { orgId, externalId });
66
+ return data.managedPlayer;
67
+ }
68
+ /**
69
+ * Create players ahead of their first sign-in, up to 500 per call (one statement, much
70
+ * faster than first sign-ins one at a time: pre-provision before a launch). A player
71
+ * that already exists is left as it is and counted in `existing`. Refused with
72
+ * `ORG_LEGAL_ACCEPTANCE_REQUIRED` until the organization has accepted the current
73
+ * Org-Managed Players Addendum.
74
+ */
75
+ async provision(input) {
76
+ const data = await this.api.request(ProvisionManagedPlayersDocument, { input });
77
+ return data.provisionManagedPlayers;
78
+ }
79
+ /**
80
+ * Rename a player, or disable or enable it. Disabling ends every session the player has
81
+ * (its devices stop at once) and refuses its sign-ins until enabled again. A block a
82
+ * platform operator set also reads as disabled, and only an operator lifts it.
83
+ */
84
+ async update(input) {
85
+ const data = await this.api.request(UpdateManagedPlayerDocument, { input });
86
+ return data.updateManagedPlayer;
87
+ }
88
+ /** End every session of a player now (sign it out everywhere); it can sign in again. */
89
+ async endSessions(orgId, externalId) {
90
+ const data = await this.api.request(EndManagedPlayerSessionsDocument, { orgId, externalId });
91
+ return data.endManagedPlayerSessions;
92
+ }
93
+ /**
94
+ * Delete a player: its sessions end and its account is scrubbed. The external id is free
95
+ * again, so a later sign-in with it creates a new player.
96
+ */
97
+ async delete(orgId, externalId) {
98
+ const data = await this.api.request(DeleteManagedPlayerDocument, { orgId, externalId });
99
+ return data.deleteManagedPlayer;
100
+ }
101
+ /**
102
+ * Whether an operator has turned managed players on for the organization, and its limits:
103
+ * the player cap, sign-ins per minute and the session lengths. Also where the organization
104
+ * stands on the Org-Managed Players Addendum: the current `termsVersion` and `termsUrl`,
105
+ * `termsAccepted`, the latest acceptance, and `viewerMayAcceptTerms` (whether the signed-in
106
+ * user is an admin of the organization who may accept it, in Studio). Read-only here.
107
+ */
108
+ async settings(orgId) {
109
+ const data = await this.api.request(OrgManagedPlayerSettingsDocument, { orgId });
110
+ return data.orgManagedPlayerSettings;
111
+ }
112
+ /** The organization's assertion signing keys, revoked ones included. */
113
+ async signingKeys(orgId) {
114
+ const data = await this.api.request(OrgSigningKeysDocument, { orgId });
115
+ return data.orgSigningKeys;
116
+ }
117
+ /**
118
+ * Register a PUBLIC key the organization's sign-in service signs player assertions with:
119
+ * `EdDSA` (Ed25519), `ES256` (P-256) or `RS256` (RSA, 2048 bits or more). `publicJwk` may be
120
+ * the JWK object (for example `publicKey.export({ format: 'jwk' })` in Node) or its JSON.
121
+ * A JWK with private members is refused. `appIds` limits the key to some of the
122
+ * organization's apps; `audience` replaces the default `ck:app:<appId>` when the
123
+ * organization's identity provider sets its own.
124
+ */
125
+ async registerSigningKey(input) {
126
+ const publicJwk = typeof input.publicJwk === 'string' ? input.publicJwk : JSON.stringify(input.publicJwk);
127
+ // The API refuses a private JWK too; refusing here keeps the private key from ever
128
+ // leaving the machine that holds it.
129
+ const privateMember = privateJwkMember(publicJwk);
130
+ if (privateMember) {
131
+ throw new TypeError(`registerSigningKey: the JWK carries the private member '${privateMember}'. Register the PUBLIC key only.`);
132
+ }
133
+ const data = await this.api.request(RegisterOrgSigningKeyDocument, {
134
+ input: { ...input, publicJwk },
135
+ });
136
+ return data.registerOrgSigningKey;
137
+ }
138
+ /** Revoke a signing key: assertions it signed are refused from now on. */
139
+ async revokeSigningKey(orgId, keyId) {
140
+ const data = await this.api.request(RevokeOrgSigningKeyDocument, { orgId, keyId });
141
+ return data.revokeOrgSigningKey;
142
+ }
143
+ /**
144
+ * Whether the organization pays for its managed players' mods in this app. A managed
145
+ * player has no wallet, so with this off its mods, its Crowdy Studio writes and its use
146
+ * of the Studio agent are refused with `MANAGED_PLAYER_NOT_ALLOWED`. False for an app the
147
+ * caller cannot see.
148
+ */
149
+ async appModsEnabled(appId) {
150
+ const data = await this.api.request(AppManagedPlayerModsDocument, { appId });
151
+ return data.app?.managedPlayerModsEnabled ?? false;
152
+ }
153
+ /**
154
+ * Switch the organization paying for its managed players' mods in this app on or off
155
+ * (`manage_billing` on the app). On, their mods' compute, storage and agent use are billed
156
+ * to the organization; off, those mods are switched off at once.
157
+ */
158
+ async setAppMods(appId, enabled) {
159
+ const data = await this.api.request(SetAppManagedPlayerModsDocument, { appId, enabled });
160
+ return data.setAppManagedPlayerMods;
161
+ }
162
+ }
@@ -91,10 +91,14 @@ export declare class OrganizationsAPI {
91
91
  create(input: CreateOrganizationInput): Promise<CreateOrganizationMutation['createOrganization']>;
92
92
  /**
93
93
  * Mint a new org API token (for server-side studio backends). Requires the
94
- * `manage_tokens` org permission. The plaintext secret is returned **once**.
94
+ * `manage_tokens` org permission. The plaintext secret (`cko_…`) is returned
95
+ * **once**. Keep it on the organization's server: the API refuses a request
96
+ * that carries it with an `Origin` header.
95
97
  *
96
98
  * @param input - {@link CreateOrgTokenInput}: `orgId`, optional `label` and
97
- * `expiresAt`.
99
+ * `expiresAt`; for org-managed players, `scopes`
100
+ * (`players:mint`, `players:manage`) and `appIds` (limit the token to some
101
+ * of the org's apps). A token with no scope can do nothing.
98
102
  * @returns The created token including its one-time plaintext secret.
99
103
  */
100
104
  createToken(input: CreateOrgTokenInput): Promise<CreateOrgTokenMutation['createOrgToken']>;
@@ -111,9 +115,14 @@ export declare class OrganizationsAPI {
111
115
  * Revoke (disable) an org token. Requires the `manage_tokens` org permission.
112
116
  *
113
117
  * @param orgTokenId - Numeric token id.
118
+ * @param options - `endSessions: true` also ends every session the token signed
119
+ * org-managed players in with, so their devices stop now rather than at
120
+ * their sessions' end.
114
121
  * @returns `true` on success.
115
122
  */
116
- revokeToken(orgTokenId: string): Promise<RevokeOrgTokenMutation['revokeOrgToken']>;
123
+ revokeToken(orgTokenId: string, options?: {
124
+ endSessions?: boolean;
125
+ }): Promise<RevokeOrgTokenMutation['revokeOrgToken']>;
117
126
  /**
118
127
  * Invite a user to an organization (by email or user id), optionally with
119
128
  * initial roles. Requires the `manage_members` org permission.
@@ -1 +1 @@
1
- {"version":3,"file":"organizations.d.ts","sourceRoot":"","sources":["../../src/domains/organizations.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAClD,OAAO,EAmBL,KAAK,iBAAiB,EACtB,KAAK,uBAAuB,EAC5B,KAAK,oBAAoB,EACzB,KAAK,eAAe,EACpB,KAAK,aAAa,EAClB,KAAK,gBAAgB,EACrB,KAAK,mBAAmB,EACxB,KAAK,cAAc,EACnB,KAAK,0BAA0B,EAC/B,KAAK,sBAAsB,EAC3B,KAAK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G,UAAU,CACd,KAAK,EAAE,kBAAkB,GACxB,OAAO,CAAC,qBAAqB,CAAC,eAAe,CAAC,CAAC;IAOlD;;;;;;;OAOG;IACG,UAAU,CACd,SAAS,EAAE,MAAM,EACjB,KAAK,EAAE,kBAAkB,GACxB,OAAO,CAAC,qBAAqB,CAAC,eAAe,CAAC,CAAC;IAQlD;;;;;;OAMG;IACG,UAAU,CACd,SAAS,EAAE,MAAM,GAChB,OAAO,CAAC,qBAAqB,CAAC,eAAe,CAAC,CAAC;CAMnD"}
@@ -126,10 +126,14 @@ export class OrganizationsAPI {
126
126
  }
127
127
  /**
128
128
  * Mint a new org API token (for server-side studio backends). Requires the
129
- * `manage_tokens` org permission. The plaintext secret is returned **once**.
129
+ * `manage_tokens` org permission. The plaintext secret (`cko_…`) is returned
130
+ * **once**. Keep it on the organization's server: the API refuses a request
131
+ * that carries it with an `Origin` header.
130
132
  *
131
133
  * @param input - {@link CreateOrgTokenInput}: `orgId`, optional `label` and
132
- * `expiresAt`.
134
+ * `expiresAt`; for org-managed players, `scopes`
135
+ * (`players:mint`, `players:manage`) and `appIds` (limit the token to some
136
+ * of the org's apps). A token with no scope can do nothing.
133
137
  * @returns The created token including its one-time plaintext secret.
134
138
  */
135
139
  async createToken(input) {
@@ -157,11 +161,15 @@ export class OrganizationsAPI {
157
161
  * Revoke (disable) an org token. Requires the `manage_tokens` org permission.
158
162
  *
159
163
  * @param orgTokenId - Numeric token id.
164
+ * @param options - `endSessions: true` also ends every session the token signed
165
+ * org-managed players in with, so their devices stop now rather than at
166
+ * their sessions' end.
160
167
  * @returns `true` on success.
161
168
  */
162
- async revokeToken(orgTokenId) {
169
+ async revokeToken(orgTokenId, options = {}) {
163
170
  const data = await this.api.request(RevokeOrgTokenDocument, {
164
171
  orgTokenId,
172
+ ...(options.endSessions === undefined ? {} : { endSessions: options.endSessions }),
165
173
  });
166
174
  return data.revokeOrgToken;
167
175
  }
@@ -275,6 +275,39 @@ export declare class PortalAPI {
275
275
  * back through {@link signIn}, where `/authorize` asks for them.
276
276
  */
277
277
  refresh(currentServer?: CurrentServer): Promise<AppTokenResponse>;
278
+ /**
279
+ * Store an app token the player's organization minted for it, so this client plays with
280
+ * it and {@link refresh} rotates it. For an org-managed player: the organization's server
281
+ * calls `mintManagedPlayerToken` with its org token and sends the response to the
282
+ * player's device, which passes it here. Returns the response unchanged; point the game
283
+ * client at its `gameApiUrl` / `gameApiWsUrl` as after any mint.
284
+ *
285
+ * The token refreshes until the sign-in's lifetime (the organization's setting) ends;
286
+ * after that `refresh()` is refused and the device gets a new token from its organization.
287
+ * A refresh is also refused with `ORG_LEGAL_ACCEPTANCE_REQUIRED`
288
+ * ({@link orgLegalAcceptanceRequiredOf}) while the organization has not accepted the
289
+ * current Org-Managed Players Addendum; only an admin of the organization can fix that.
290
+ *
291
+ * Refuses an org token (`cko_…`). That is the organization's server credential: it signs
292
+ * in any of the organization's players, so a device must never hold one.
293
+ */
294
+ adoptAppToken(response: AppTokenResponse): AppTokenResponse;
295
+ /**
296
+ * Trade an assertion the player's organization signed for the player's app token, and
297
+ * store it (as {@link adoptAppToken} does). For an org-managed player whose organization
298
+ * registered a signing key: its sign-in service signs a short JWS for the player and the
299
+ * device brings it here. Public: needs no session and no org token.
300
+ *
301
+ * Each assertion works once. A refusal is `ASSERTION_REJECTED`, with the failed check in
302
+ * `extensions.reason` ({@link assertionRejectedOf}); resending the same assertion cannot
303
+ * succeed, so ask the sign-in service for a new one. A valid assertion is refused with
304
+ * `ORG_LEGAL_ACCEPTANCE_REQUIRED` ({@link orgLegalAcceptanceRequiredOf}) while the
305
+ * organization has not accepted the current Org-Managed Players Addendum.
306
+ */
307
+ exchangeManagedPlayerAssertion(params: {
308
+ appId: string;
309
+ assertion: string;
310
+ }): Promise<AppTokenResponse>;
278
311
  /** Whether portaling into an app needs a consent prompt (Overworld side). */
279
312
  getConsent(appId: string): Promise<PortalConsentState>;
280
313
  /** Record the user's consent for an app (call from the consent screen). */
@@ -1 +1 @@
1
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AG,OAAO,CAAC,MAAM,CAAC;IAa3D;;;;;;OAMG;IACG,sBAAsB,CAC1B,MAAM,CAAC,EAAE,MAAM,EACf,OAAO,CAAC,EAAE;QAAE,YAAY,CAAC,EAAE,OAAO,CAAC;QAAC,MAAM,CAAC,EAAE,MAAM,EAAE,CAAA;KAAE,GACtD,OAAO,CAAC,MAAM,CAAC;IAoClB;;;;;OAKG;IACG,aAAa,CAAC,MAAM,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,gBAAgB,GAAG,IAAI,CAAC;CAmBvE"}
@@ -65,6 +65,9 @@ const RefreshAppTokenDocument = parse(`mutation RefreshAppToken { refreshAppToke
65
65
  // Asked for only when a server is named, so a client against a Game API older than
66
66
  // v1.83.7 (no `currentServer` argument, no `authorizedServer` field) keeps refreshing.
67
67
  const RefreshAppTokenOnServerDocument = parse(`mutation RefreshAppTokenOnServer($currentServer: CurrentServerInput) { refreshAppToken(currentServer: $currentServer) { ${APP_TOKEN_FIELDS} authorizedServer { ip4 clientPort } } }`);
68
+ const ExchangeManagedPlayerAssertionDocument = parse(`mutation ExchangeManagedPlayerAssertion($input: ExchangeManagedPlayerAssertionInput!) { exchangeManagedPlayerAssertion(input: $input) { ${APP_TOKEN_FIELDS} } }`);
69
+ /** What every org token starts with: an organization's server credential, never a device's. */
70
+ const ORG_TOKEN_PREFIX = 'cko_';
68
71
  /** Thrown by {@link PortalAPI.handleAuthorizeRequest} when the user must consent. */
69
72
  export class PortalConsentRequiredError extends Error {
70
73
  constructor(appId, appName) {
@@ -135,7 +138,8 @@ export function isLegalAcceptanceRequiredError(error) {
135
138
  ];
136
139
  if (codes.includes('LEGAL_ACCEPTANCE_REQUIRED'))
137
140
  return true;
138
- return /LEGAL_ACCEPTANCE_REQUIRED/.test(typeof e?.message === 'string' ? e.message : '');
141
+ // Not the organization's ORG_LEGAL_ACCEPTANCE_REQUIRED: no player clickwrap answers that.
142
+ return /(^|[^A-Z_])LEGAL_ACCEPTANCE_REQUIRED/.test(typeof e?.message === 'string' ? e.message : '');
139
143
  }
140
144
  export class PortalAPI {
141
145
  constructor(api, session, pkceStore = new BrowserSessionPkceStore(),
@@ -213,6 +217,53 @@ export class PortalAPI {
213
217
  this.session.setToken(data.refreshAppToken.token);
214
218
  return data.refreshAppToken;
215
219
  }
220
+ // ----- Org-managed players ---------------------------------------------------
221
+ /**
222
+ * Store an app token the player's organization minted for it, so this client plays with
223
+ * it and {@link refresh} rotates it. For an org-managed player: the organization's server
224
+ * calls `mintManagedPlayerToken` with its org token and sends the response to the
225
+ * player's device, which passes it here. Returns the response unchanged; point the game
226
+ * client at its `gameApiUrl` / `gameApiWsUrl` as after any mint.
227
+ *
228
+ * The token refreshes until the sign-in's lifetime (the organization's setting) ends;
229
+ * after that `refresh()` is refused and the device gets a new token from its organization.
230
+ * A refresh is also refused with `ORG_LEGAL_ACCEPTANCE_REQUIRED`
231
+ * ({@link orgLegalAcceptanceRequiredOf}) while the organization has not accepted the
232
+ * current Org-Managed Players Addendum; only an admin of the organization can fix that.
233
+ *
234
+ * Refuses an org token (`cko_…`). That is the organization's server credential: it signs
235
+ * in any of the organization's players, so a device must never hold one.
236
+ */
237
+ adoptAppToken(response) {
238
+ const token = response?.token;
239
+ if (typeof token !== 'string' || token.length === 0) {
240
+ throw new TypeError('adoptAppToken: the response has no token');
241
+ }
242
+ if (token.startsWith(ORG_TOKEN_PREFIX)) {
243
+ throw new TypeError("adoptAppToken: that is an org token, your organization's server credential. Give the device the app token mintManagedPlayerToken returns, never the org token.");
244
+ }
245
+ this.session.setToken(token);
246
+ return response;
247
+ }
248
+ /**
249
+ * Trade an assertion the player's organization signed for the player's app token, and
250
+ * store it (as {@link adoptAppToken} does). For an org-managed player whose organization
251
+ * registered a signing key: its sign-in service signs a short JWS for the player and the
252
+ * device brings it here. Public: needs no session and no org token.
253
+ *
254
+ * Each assertion works once. A refusal is `ASSERTION_REJECTED`, with the failed check in
255
+ * `extensions.reason` ({@link assertionRejectedOf}); resending the same assertion cannot
256
+ * succeed, so ask the sign-in service for a new one. A valid assertion is refused with
257
+ * `ORG_LEGAL_ACCEPTANCE_REQUIRED` ({@link orgLegalAcceptanceRequiredOf}) while the
258
+ * organization has not accepted the current Org-Managed Players Addendum.
259
+ */
260
+ async exchangeManagedPlayerAssertion(params) {
261
+ const data = await this.api.request(ExchangeManagedPlayerAssertionDocument, {
262
+ input: { appId: params.appId, assertion: params.assertion },
263
+ });
264
+ this.session.setToken(data.exchangeManagedPlayerAssertion.token);
265
+ return data.exchangeManagedPlayerAssertion;
266
+ }
216
267
  // ----- Consent + connected apps ------------------------------------------
217
268
  /** Whether portaling into an app needs a consent prompt (Overworld side). */
218
269
  async getConsent(appId) {
package/dist/errors.d.ts CHANGED
@@ -267,6 +267,23 @@ export declare const ACCOUNT_BLOCKED_CODE = "ACCOUNT_BLOCKED";
267
267
  * request, an add or an invite; see {@link groupMemberBannedOf}.
268
268
  */
269
269
  export declare const GROUP_MEMBER_BANNED_CODE = "GROUP_MEMBER_BANNED";
270
+ /**
271
+ * `extensions.code` for "an org-managed player cannot do this" (HTTP 403): it has no wallet,
272
+ * and its mods are refused where its organization has not switched them on for the app; see
273
+ * {@link managedPlayerNotAllowedOf}.
274
+ */
275
+ export declare const MANAGED_PLAYER_NOT_ALLOWED_CODE = "MANAGED_PLAYER_NOT_ALLOWED";
276
+ /**
277
+ * `extensions.code` for "the organization's signed player assertion was refused" (HTTP 401),
278
+ * with the failed check in `extensions.reason`; see {@link assertionRejectedOf}.
279
+ */
280
+ export declare const ASSERTION_REJECTED_CODE = "ASSERTION_REJECTED";
281
+ /**
282
+ * `extensions.code` for "the player's organization has not accepted the current Org-Managed
283
+ * Players Addendum" (HTTP 403), on an org-managed player's sign-in and refresh and on
284
+ * provisioning; see {@link orgLegalAcceptanceRequiredOf}.
285
+ */
286
+ export declare const ORG_LEGAL_ACCEPTANCE_REQUIRED_CODE = "ORG_LEGAL_ACCEPTANCE_REQUIRED";
270
287
  /**
271
288
  * Why an app is paused, as `extensions.reason` on `APP_PAUSED` and
272
289
  * `AppRuntimeGate.reason` carry it. Open union: the server may add one.
@@ -304,6 +321,32 @@ export declare function accountBlockedOf(value: unknown): {
304
321
  } | null;
305
322
  /** Whether an error is a `GROUP_MEMBER_BANNED` refusal (HTTP 403); only an unban lifts it. */
306
323
  export declare function groupMemberBannedOf(value: unknown): boolean;
324
+ /**
325
+ * Whether an error is a `MANAGED_PLAYER_NOT_ALLOWED` refusal (HTTP 403): an org-managed
326
+ * player asked for a wallet, or for a mod, a Crowdy Studio write or the Studio agent in an app
327
+ * whose organization has not switched its managed players' mods on. Not fixed by retrying.
328
+ */
329
+ export declare function managedPlayerNotAllowedOf(value: unknown): boolean;
330
+ /**
331
+ * An `ASSERTION_REJECTED` refusal (HTTP 401) from
332
+ * `portal.exchangeManagedPlayerAssertion`, or `null`. `reason` is `extensions.reason`, the
333
+ * check that failed: for example `expired`, `replayed`, `signature`, `audience` or
334
+ * `unknown_key`. Resending the same assertion cannot succeed; ask the organization's
335
+ * sign-in service for a new one.
336
+ */
337
+ export declare function assertionRejectedOf(value: unknown): {
338
+ reason: string | null;
339
+ } | null;
340
+ /**
341
+ * Whether an error is an `ORG_LEGAL_ACCEPTANCE_REQUIRED` refusal (HTTP 403, ck-api v2.53.0):
342
+ * the player's organization has not accepted the current Org-Managed Players Addendum, so it
343
+ * signs no player in, provisions none, and its players' tokens do not refresh. The player
344
+ * cannot fix it, and neither can the organization's server: an admin of the organization
345
+ * accepts it in Studio. Not fixed by retrying. Distinct from the player's own
346
+ * `LEGAL_ACCEPTANCE_REQUIRED` ({@link isLegalAcceptanceRequiredError}), which a managed
347
+ * player never gets.
348
+ */
349
+ export declare function orgLegalAcceptanceRequiredOf(value: unknown): boolean;
307
350
  /**
308
351
  * An `APP_PAUSED` refusal (HTTP 403: the app's runtime gate is not ACTIVE), or
309
352
  * `null`. `reason` is `extensions.reason`. Show the player that the world is
@@ -1 +1 @@
1
- {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":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GAQG;AACH,wBAAgB,4BAA4B,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CAEpE;AAED;;;;GAIG;AACH,wBAAgB,WAAW,CAAC,KAAK,EAAE,OAAO,GAAG;IAAE,MAAM,EAAE,cAAc,GAAG,IAAI,CAAA;CAAE,GAAG,IAAI,CAKpF;AAED;;;;GAIG;AACH,wBAAgB,WAAW,CACzB,IAAI,EAAE;IAAE,MAAM,EAAE,MAAM,CAAA;CAAE,GAAG,IAAI,GAAG,SAAS,GAC1C,OAAO,CAET;AAED;;;;GAIG;AACH,qBAAa,kBAAmB,SAAQ,WAAW;gBACrC,KAAK,EAAE,OAAO;CAG3B;AAED;;;;;;;GAOG;AACH,qBAAa,kBAAmB,SAAQ,WAAW;gBACrC,SAAS,EAAE,MAAM;CAG9B;AAED;;;;;;;;;;;;;;GAcG;AACH,qBAAa,mBAAoB,SAAQ,WAAW;IAClD,8DAA8D;IAC9D,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;IACvB,yEAAyE;IACzE,QAAQ,CAAC,SAAS,CAAC,EAAE,OAAO,CAAC;gBAEjB,OAAO,EAAE,MAAM,EAAE,OAAO,GAAE;QAAE,IAAI,CAAC,EAAE,MAAM,CAAC;QAAC,SAAS,CAAC,EAAE,OAAO,CAAC;QAAC,KAAK,CAAC,EAAE,OAAO,CAAA;KAAO;CAKnG;AAED;;;;;GAKG;AACH,qBAAa,mBAAoB,SAAQ,WAAW;CAAG"}
package/dist/errors.js CHANGED
@@ -263,6 +263,23 @@ export const ACCOUNT_BLOCKED_CODE = 'ACCOUNT_BLOCKED';
263
263
  * request, an add or an invite; see {@link groupMemberBannedOf}.
264
264
  */
265
265
  export const GROUP_MEMBER_BANNED_CODE = 'GROUP_MEMBER_BANNED';
266
+ /**
267
+ * `extensions.code` for "an org-managed player cannot do this" (HTTP 403): it has no wallet,
268
+ * and its mods are refused where its organization has not switched them on for the app; see
269
+ * {@link managedPlayerNotAllowedOf}.
270
+ */
271
+ export const MANAGED_PLAYER_NOT_ALLOWED_CODE = 'MANAGED_PLAYER_NOT_ALLOWED';
272
+ /**
273
+ * `extensions.code` for "the organization's signed player assertion was refused" (HTTP 401),
274
+ * with the failed check in `extensions.reason`; see {@link assertionRejectedOf}.
275
+ */
276
+ export const ASSERTION_REJECTED_CODE = 'ASSERTION_REJECTED';
277
+ /**
278
+ * `extensions.code` for "the player's organization has not accepted the current Org-Managed
279
+ * Players Addendum" (HTTP 403), on an org-managed player's sign-in and refresh and on
280
+ * provisioning; see {@link orgLegalAcceptanceRequiredOf}.
281
+ */
282
+ export const ORG_LEGAL_ACCEPTANCE_REQUIRED_CODE = 'ORG_LEGAL_ACCEPTANCE_REQUIRED';
266
283
  /** The first error entry carrying `code`, from an error or a raw payload. */
267
284
  function errorWithCode(value, code) {
268
285
  if (!value || typeof value !== 'object')
@@ -324,6 +341,40 @@ export function accountBlockedOf(value) {
324
341
  export function groupMemberBannedOf(value) {
325
342
  return errorWithCode(value, GROUP_MEMBER_BANNED_CODE) !== null;
326
343
  }
344
+ /**
345
+ * Whether an error is a `MANAGED_PLAYER_NOT_ALLOWED` refusal (HTTP 403): an org-managed
346
+ * player asked for a wallet, or for a mod, a Crowdy Studio write or the Studio agent in an app
347
+ * whose organization has not switched its managed players' mods on. Not fixed by retrying.
348
+ */
349
+ export function managedPlayerNotAllowedOf(value) {
350
+ return errorWithCode(value, MANAGED_PLAYER_NOT_ALLOWED_CODE) !== null;
351
+ }
352
+ /**
353
+ * An `ASSERTION_REJECTED` refusal (HTTP 401) from
354
+ * `portal.exchangeManagedPlayerAssertion`, or `null`. `reason` is `extensions.reason`, the
355
+ * check that failed: for example `expired`, `replayed`, `signature`, `audience` or
356
+ * `unknown_key`. Resending the same assertion cannot succeed; ask the organization's
357
+ * sign-in service for a new one.
358
+ */
359
+ export function assertionRejectedOf(value) {
360
+ const entry = errorWithCode(value, ASSERTION_REJECTED_CODE);
361
+ if (!entry)
362
+ return null;
363
+ const reason = entry.extensions?.reason;
364
+ return { reason: typeof reason === 'string' && reason.length > 0 ? reason : null };
365
+ }
366
+ /**
367
+ * Whether an error is an `ORG_LEGAL_ACCEPTANCE_REQUIRED` refusal (HTTP 403, ck-api v2.53.0):
368
+ * the player's organization has not accepted the current Org-Managed Players Addendum, so it
369
+ * signs no player in, provisions none, and its players' tokens do not refresh. The player
370
+ * cannot fix it, and neither can the organization's server: an admin of the organization
371
+ * accepts it in Studio. Not fixed by retrying. Distinct from the player's own
372
+ * `LEGAL_ACCEPTANCE_REQUIRED` ({@link isLegalAcceptanceRequiredError}), which a managed
373
+ * player never gets.
374
+ */
375
+ export function orgLegalAcceptanceRequiredOf(value) {
376
+ return errorWithCode(value, ORG_LEGAL_ACCEPTANCE_REQUIRED_CODE) !== null;
377
+ }
327
378
  /**
328
379
  * An `APP_PAUSED` refusal (HTTP 403: the app's runtime gate is not ACTIVE), or
329
380
  * `null`. `reason` is `extensions.reason`. Show the player that the world is