@crowdedkingdoms/crowdyjs 1.0.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/LICENSE +21 -0
- package/MIGRATION.md +247 -0
- package/README.md +303 -0
- package/dist/auth-state.d.ts +11 -0
- package/dist/auth-state.d.ts.map +1 -0
- package/dist/auth-state.js +13 -0
- package/dist/client.d.ts +135 -0
- package/dist/client.d.ts.map +1 -0
- package/dist/client.js +150 -0
- package/dist/crowdy-client.d.ts +182 -0
- package/dist/crowdy-client.d.ts.map +1 -0
- package/dist/crowdy-client.js +146 -0
- package/dist/domains/actors.d.ts +117 -0
- package/dist/domains/actors.d.ts.map +1 -0
- package/dist/domains/actors.js +140 -0
- package/dist/domains/admin.d.ts +61 -0
- package/dist/domains/admin.d.ts.map +1 -0
- package/dist/domains/admin.js +33 -0
- package/dist/domains/appAccess.d.ts +141 -0
- package/dist/domains/appAccess.d.ts.map +1 -0
- package/dist/domains/appAccess.js +198 -0
- package/dist/domains/apps.d.ts +192 -0
- package/dist/domains/apps.d.ts.map +1 -0
- package/dist/domains/apps.js +217 -0
- package/dist/domains/auth.d.ts +163 -0
- package/dist/domains/auth.d.ts.map +1 -0
- package/dist/domains/auth.js +208 -0
- package/dist/domains/avatars.d.ts +94 -0
- package/dist/domains/avatars.d.ts.map +1 -0
- package/dist/domains/avatars.js +137 -0
- package/dist/domains/billing.d.ts +97 -0
- package/dist/domains/billing.d.ts.map +1 -0
- package/dist/domains/billing.js +131 -0
- package/dist/domains/channels.d.ts +293 -0
- package/dist/domains/channels.d.ts.map +1 -0
- package/dist/domains/channels.js +353 -0
- package/dist/domains/chunks.d.ts +133 -0
- package/dist/domains/chunks.d.ts.map +1 -0
- package/dist/domains/chunks.js +153 -0
- package/dist/domains/controlPlane.d.ts +174 -0
- package/dist/domains/controlPlane.d.ts.map +1 -0
- package/dist/domains/controlPlane.js +252 -0
- package/dist/domains/environments.d.ts +155 -0
- package/dist/domains/environments.d.ts.map +1 -0
- package/dist/domains/environments.js +223 -0
- package/dist/domains/gameApps.d.ts +114 -0
- package/dist/domains/gameApps.d.ts.map +1 -0
- package/dist/domains/gameApps.js +169 -0
- package/dist/domains/gameModel.d.ts +668 -0
- package/dist/domains/gameModel.d.ts.map +1 -0
- package/dist/domains/gameModel.js +816 -0
- package/dist/domains/host.d.ts +35 -0
- package/dist/domains/host.d.ts.map +1 -0
- package/dist/domains/host.js +40 -0
- package/dist/domains/organizations.d.ts +179 -0
- package/dist/domains/organizations.d.ts.map +1 -0
- package/dist/domains/organizations.js +269 -0
- package/dist/domains/payments.d.ts +104 -0
- package/dist/domains/payments.d.ts.map +1 -0
- package/dist/domains/payments.js +129 -0
- package/dist/domains/platform.d.ts +49 -0
- package/dist/domains/platform.d.ts.map +1 -0
- package/dist/domains/platform.js +50 -0
- package/dist/domains/quotas.d.ts +62 -0
- package/dist/domains/quotas.d.ts.map +1 -0
- package/dist/domains/quotas.js +79 -0
- package/dist/domains/serverStatus.d.ts +90 -0
- package/dist/domains/serverStatus.d.ts.map +1 -0
- package/dist/domains/serverStatus.js +104 -0
- package/dist/domains/sharedEnvironment.d.ts +133 -0
- package/dist/domains/sharedEnvironment.d.ts.map +1 -0
- package/dist/domains/sharedEnvironment.js +179 -0
- package/dist/domains/state.d.ts +64 -0
- package/dist/domains/state.d.ts.map +1 -0
- package/dist/domains/state.js +75 -0
- package/dist/domains/teams.d.ts +292 -0
- package/dist/domains/teams.d.ts.map +1 -0
- package/dist/domains/teams.js +352 -0
- package/dist/domains/teleport.d.ts +41 -0
- package/dist/domains/teleport.d.ts.map +1 -0
- package/dist/domains/teleport.js +43 -0
- package/dist/domains/udp.d.ts +405 -0
- package/dist/domains/udp.d.ts.map +1 -0
- package/dist/domains/udp.js +457 -0
- package/dist/domains/usage.d.ts +76 -0
- package/dist/domains/usage.d.ts.map +1 -0
- package/dist/domains/usage.js +110 -0
- package/dist/domains/users.d.ts +147 -0
- package/dist/domains/users.d.ts.map +1 -0
- package/dist/domains/users.js +195 -0
- package/dist/domains/voxels.d.ts +136 -0
- package/dist/domains/voxels.d.ts.map +1 -0
- package/dist/domains/voxels.js +153 -0
- package/dist/errors.d.ts +158 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/errors.js +142 -0
- package/dist/generated/graphql.d.ts +12206 -0
- package/dist/generated/graphql.d.ts.map +1 -0
- package/dist/generated/graphql.js +474 -0
- package/dist/index.d.ts +84 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +85 -0
- package/dist/logger.d.ts +8 -0
- package/dist/logger.d.ts.map +1 -0
- package/dist/logger.js +1 -0
- package/dist/realtime.d.ts +319 -0
- package/dist/realtime.d.ts.map +1 -0
- package/dist/realtime.js +390 -0
- package/dist/session.d.ts +73 -0
- package/dist/session.d.ts.map +1 -0
- package/dist/session.js +96 -0
- package/dist/subscriptions.d.ts +2 -0
- package/dist/subscriptions.d.ts.map +1 -0
- package/dist/subscriptions.js +1 -0
- package/dist/types.d.ts +658 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +61 -0
- package/dist/utils.d.ts +98 -0
- package/dist/utils.d.ts.map +1 -0
- package/dist/utils.js +136 -0
- package/dist/world.d.ts +236 -0
- package/dist/world.d.ts.map +1 -0
- package/dist/world.js +275 -0
- package/package.json +73 -0
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
import type { GraphQLClient } from '../client.js';
|
|
2
|
+
import type { AuthState } from '../auth-state.js';
|
|
3
|
+
import { type LoginMutation, type LoginUserInput, type RegisterMutation, type RegisterUserInput, type ResetPasswordInput } from '../generated/graphql.js';
|
|
4
|
+
/**
|
|
5
|
+
* Authentication and account-lifecycle flows — exposed as `client.auth`.
|
|
6
|
+
*
|
|
7
|
+
* Targets the **management-api**: every call routes to `managementUrl` (falling
|
|
8
|
+
* back to the game-api endpoint only in legacy single-endpoint mode). The
|
|
9
|
+
* management API owns the `game_tokens` table that backs every login / register
|
|
10
|
+
* / password / email-confirmation flow; the `token` it returns is a
|
|
11
|
+
* `game_tokens` row that game-api validates against the same shared Postgres.
|
|
12
|
+
*
|
|
13
|
+
* {@link login} and {@link register} mint that session token **and** store it on
|
|
14
|
+
* the shared session state automatically, so every later call on *either*
|
|
15
|
+
* endpoint (auth, users, apps, actors, chunks, udp, ...) is authenticated
|
|
16
|
+
* without you threading the token through by hand. Use {@link setToken} to
|
|
17
|
+
* rehydrate a saved token and {@link getToken} to read the current one. `BigInt`
|
|
18
|
+
* ids on the returned user (e.g. `userId`, `orgId`) are decimal strings.
|
|
19
|
+
*
|
|
20
|
+
* **Public — no session required:** {@link login}, {@link register},
|
|
21
|
+
* {@link confirmEmail}, {@link requestPasswordReset}, {@link resetPassword}, and
|
|
22
|
+
* {@link resendConfirmationEmail}. **Require a valid session:** {@link logout},
|
|
23
|
+
* {@link logoutAllDevices}, and {@link changePassword}, which otherwise throw
|
|
24
|
+
* {@link CrowdyGraphQLError} with `UNAUTHENTICATED` when the bearer token is
|
|
25
|
+
* missing, expired, or revoked.
|
|
26
|
+
*/
|
|
27
|
+
export declare class AuthAPI {
|
|
28
|
+
private readonly graphql;
|
|
29
|
+
private readonly session;
|
|
30
|
+
constructor(graphql: GraphQLClient, session: AuthState);
|
|
31
|
+
/**
|
|
32
|
+
* Authenticate with email + password and start a new session. **Public** — no
|
|
33
|
+
* existing session required.
|
|
34
|
+
*
|
|
35
|
+
* On success the returned `token` is minted **and** stored on the shared
|
|
36
|
+
* session state, so subsequent calls on any sub-client (management-api or
|
|
37
|
+
* game-api) carry it automatically — no need to call {@link setToken}.
|
|
38
|
+
*
|
|
39
|
+
* @param input - Credentials ({@link LoginUserInput}): `email` and `password`
|
|
40
|
+
* (min 8 characters).
|
|
41
|
+
* @returns An {@link AuthResponse}: the opaque session `token` (sent as
|
|
42
|
+
* `Authorization: Bearer <token>`), `gameTokenId` (the session row id, a
|
|
43
|
+
* string), and the authenticated `user`.
|
|
44
|
+
* @throws {CrowdyGraphQLError} `UNAUTHENTICATED` on invalid credentials, or
|
|
45
|
+
* `BAD_USER_INPUT` on malformed input.
|
|
46
|
+
* @example
|
|
47
|
+
* ```ts
|
|
48
|
+
* const { user } = await client.auth.login({ email, password });
|
|
49
|
+
* // the session token is now stored; later calls are authenticated for you
|
|
50
|
+
* await client.users.me();
|
|
51
|
+
* ```
|
|
52
|
+
*/
|
|
53
|
+
login(input: LoginUserInput): Promise<LoginMutation['login']>;
|
|
54
|
+
/**
|
|
55
|
+
* Create a new (initially unconfirmed) account, send a confirmation email, and
|
|
56
|
+
* return a session for immediate login. **Public** — no existing session
|
|
57
|
+
* required. Same token-persistence behaviour as {@link login}: the new `token`
|
|
58
|
+
* is stored on the shared session state automatically.
|
|
59
|
+
*
|
|
60
|
+
* @param input - New-account details ({@link RegisterUserInput}): `email`
|
|
61
|
+
* (where the confirmation email is sent), `password` (min 8 characters), and
|
|
62
|
+
* an optional initial `gamertag` (min 3 characters; can also be set later via
|
|
63
|
+
* `client.users.updateGamertag`).
|
|
64
|
+
* @returns An {@link AuthResponse} (session `token`, `gameTokenId`, and the new
|
|
65
|
+
* `user`).
|
|
66
|
+
* @throws {CrowdyGraphQLError} `BAD_USER_INPUT` if the email already exists or
|
|
67
|
+
* the input is invalid.
|
|
68
|
+
*/
|
|
69
|
+
register(input: RegisterUserInput): Promise<RegisterMutation['register']>;
|
|
70
|
+
/**
|
|
71
|
+
* Single-device logout: revoke the `game_tokens` row that authenticated this
|
|
72
|
+
* request; other devices/tokens are unaffected. After a successful server-side
|
|
73
|
+
* revoke the in-memory token is cleared from the shared session state so the
|
|
74
|
+
* other sub-clients stop using it. Requires a valid session.
|
|
75
|
+
*
|
|
76
|
+
* @returns `true` if a token was revoked, or `false` if the request carried no
|
|
77
|
+
* game token.
|
|
78
|
+
* @throws {CrowdyGraphQLError} `UNAUTHENTICATED` if the session is invalid.
|
|
79
|
+
*/
|
|
80
|
+
logout(): Promise<boolean>;
|
|
81
|
+
/**
|
|
82
|
+
* Revoke **every** active session for the authenticated user (deletes all
|
|
83
|
+
* their `game_tokens` rows and records revocations). Requires a valid session;
|
|
84
|
+
* use {@link logout} to end only the current one.
|
|
85
|
+
*
|
|
86
|
+
* Note: unlike {@link logout}, this does not clear the SDK's in-memory token —
|
|
87
|
+
* call {@link setToken}`(null)` afterwards if you also want to drop it locally.
|
|
88
|
+
*
|
|
89
|
+
* @returns `true` on success.
|
|
90
|
+
* @throws {CrowdyGraphQLError} `UNAUTHENTICATED` if the session is invalid.
|
|
91
|
+
*/
|
|
92
|
+
logoutAllDevices(): Promise<boolean>;
|
|
93
|
+
/**
|
|
94
|
+
* Confirm a user's email address using the token from the confirmation email.
|
|
95
|
+
* **Public** — the token itself authorizes the call.
|
|
96
|
+
*
|
|
97
|
+
* @param token - The confirmation token from the emailed link.
|
|
98
|
+
* @returns `true` on success, or `false` if the token is invalid or expired.
|
|
99
|
+
* @throws {CrowdyGraphQLError} on transport/validation failures (invalid or
|
|
100
|
+
* expired tokens resolve to `false` rather than throwing).
|
|
101
|
+
*/
|
|
102
|
+
confirmEmail(token: string): Promise<boolean>;
|
|
103
|
+
/**
|
|
104
|
+
* Start the password-reset flow by emailing a reset link to the address.
|
|
105
|
+
* **Public**. Always returns `true` regardless of whether the email exists or
|
|
106
|
+
* is confirmed, to prevent account enumeration.
|
|
107
|
+
*
|
|
108
|
+
* @param email - Email address to send the password-reset link to.
|
|
109
|
+
* @returns `true` (always, even when no such account exists).
|
|
110
|
+
* @throws {CrowdyGraphQLError} on transport/validation failures.
|
|
111
|
+
*/
|
|
112
|
+
requestPasswordReset(email: string): Promise<boolean>;
|
|
113
|
+
/**
|
|
114
|
+
* Complete a password reset using the reset token and a new password.
|
|
115
|
+
* **Public** — the reset token authorizes the call. Existing sessions are
|
|
116
|
+
* **not** revoked.
|
|
117
|
+
*
|
|
118
|
+
* @param input - {@link ResetPasswordInput}: the `token` from the emailed reset
|
|
119
|
+
* link and the `newPassword` to set (min 8 characters).
|
|
120
|
+
* @returns `true` on success.
|
|
121
|
+
* @throws {CrowdyGraphQLError} `BAD_USER_INPUT` if the token is invalid or
|
|
122
|
+
* expired.
|
|
123
|
+
*/
|
|
124
|
+
resetPassword(input: ResetPasswordInput): Promise<boolean>;
|
|
125
|
+
/**
|
|
126
|
+
* Re-send the email-confirmation link. **Public**. Always returns `true`
|
|
127
|
+
* regardless of whether the account exists or is already confirmed (prevents
|
|
128
|
+
* enumeration); the email is only actually sent for existing unconfirmed
|
|
129
|
+
* accounts.
|
|
130
|
+
*
|
|
131
|
+
* @param email - Email address of the account to re-send confirmation to.
|
|
132
|
+
* @returns `true` (always).
|
|
133
|
+
* @throws {CrowdyGraphQLError} on transport/validation failures.
|
|
134
|
+
*/
|
|
135
|
+
resendConfirmationEmail(email: string): Promise<boolean>;
|
|
136
|
+
/**
|
|
137
|
+
* Change the authenticated user's password after verifying the current one.
|
|
138
|
+
* Requires a valid session. Existing sessions are **not** revoked.
|
|
139
|
+
*
|
|
140
|
+
* @param currentPassword - The user's current password, for verification.
|
|
141
|
+
* @param newPassword - The new password to set (min 8 characters).
|
|
142
|
+
* @returns `true` on success.
|
|
143
|
+
* @throws {CrowdyGraphQLError} `UNAUTHENTICATED` without a valid session, or
|
|
144
|
+
* `BAD_USER_INPUT` if the current password is wrong.
|
|
145
|
+
*/
|
|
146
|
+
changePassword(currentPassword: string, newPassword: string): Promise<boolean>;
|
|
147
|
+
/**
|
|
148
|
+
* Imperatively replace the in-memory bearer token on the shared session state
|
|
149
|
+
* (e.g. to rehydrate a token persisted to disk). Affects every sub-client.
|
|
150
|
+
* Local only — performs no network call. Pass `null` to clear it.
|
|
151
|
+
*
|
|
152
|
+
* @param token - The bearer token to use, or `null` to clear the session.
|
|
153
|
+
*/
|
|
154
|
+
setToken(token: string | null): void;
|
|
155
|
+
/**
|
|
156
|
+
* Read the current in-memory bearer token from the shared session state. Local
|
|
157
|
+
* only — performs no network call.
|
|
158
|
+
*
|
|
159
|
+
* @returns The current bearer token, or `null` if none is set.
|
|
160
|
+
*/
|
|
161
|
+
getToken(): string | null;
|
|
162
|
+
}
|
|
163
|
+
//# sourceMappingURL=auth.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"auth.d.ts","sourceRoot":"","sources":["../../src/domains/auth.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAClD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAUL,KAAK,aAAa,EAClB,KAAK,cAAc,EACnB,KAAK,gBAAgB,EACrB,KAAK,iBAAiB,EACtB,KAAK,kBAAkB,EACxB,MAAM,yBAAyB,CAAC;AAEjC;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,qBAAa,OAAO;IAEhB,OAAO,CAAC,QAAQ,CAAC,OAAO;IACxB,OAAO,CAAC,QAAQ,CAAC,OAAO;gBADP,OAAO,EAAE,aAAa,EACtB,OAAO,EAAE,SAAS;IAGrC;;;;;;;;;;;;;;;;;;;;;OAqBG;IACG,KAAK,CAAC,KAAK,EAAE,cAAc,GAAG,OAAO,CAAC,aAAa,CAAC,OAAO,CAAC,CAAC;IAQnE;;;;;;;;;;;;;;OAcG;IACG,QAAQ,CACZ,KAAK,EAAE,iBAAiB,GACvB,OAAO,CAAC,gBAAgB,CAAC,UAAU,CAAC,CAAC;IAQxC;;;;;;;;;OASG;IACG,MAAM,IAAI,OAAO,CAAC,OAAO,CAAC;IAMhC;;;;;;;;;;OAUG;IACG,gBAAgB,IAAI,OAAO,CAAC,OAAO,CAAC;IAK1C;;;;;;;;OAQG;IACG,YAAY,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAKnD;;;;;;;;OAQG;IACG,oBAAoB,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAO3D;;;;;;;;;;OAUG;IACG,aAAa,CAAC,KAAK,EAAE,kBAAkB,GAAG,OAAO,CAAC,OAAO,CAAC;IAOhE;;;;;;;;;OASG;IACG,uBAAuB,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAO9D;;;;;;;;;OASG;IACG,cAAc,CAClB,eAAe,EAAE,MAAM,EACvB,WAAW,EAAE,MAAM,GAClB,OAAO,CAAC,OAAO,CAAC;IAQnB;;;;;;OAMG;IACH,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,GAAG,IAAI;IAIpC;;;;;OAKG;IACH,QAAQ,IAAI,MAAM,GAAG,IAAI;CAG1B"}
|
|
@@ -0,0 +1,208 @@
|
|
|
1
|
+
import { ChangePasswordDocument, ConfirmEmailDocument, LoginDocument, LogoutAllDevicesDocument, LogoutDocument, RegisterDocument, RequestPasswordResetDocument, ResendConfirmationEmailDocument, ResetPasswordDocument, } from '../generated/graphql.js';
|
|
2
|
+
/**
|
|
3
|
+
* Authentication and account-lifecycle flows — exposed as `client.auth`.
|
|
4
|
+
*
|
|
5
|
+
* Targets the **management-api**: every call routes to `managementUrl` (falling
|
|
6
|
+
* back to the game-api endpoint only in legacy single-endpoint mode). The
|
|
7
|
+
* management API owns the `game_tokens` table that backs every login / register
|
|
8
|
+
* / password / email-confirmation flow; the `token` it returns is a
|
|
9
|
+
* `game_tokens` row that game-api validates against the same shared Postgres.
|
|
10
|
+
*
|
|
11
|
+
* {@link login} and {@link register} mint that session token **and** store it on
|
|
12
|
+
* the shared session state automatically, so every later call on *either*
|
|
13
|
+
* endpoint (auth, users, apps, actors, chunks, udp, ...) is authenticated
|
|
14
|
+
* without you threading the token through by hand. Use {@link setToken} to
|
|
15
|
+
* rehydrate a saved token and {@link getToken} to read the current one. `BigInt`
|
|
16
|
+
* ids on the returned user (e.g. `userId`, `orgId`) are decimal strings.
|
|
17
|
+
*
|
|
18
|
+
* **Public — no session required:** {@link login}, {@link register},
|
|
19
|
+
* {@link confirmEmail}, {@link requestPasswordReset}, {@link resetPassword}, and
|
|
20
|
+
* {@link resendConfirmationEmail}. **Require a valid session:** {@link logout},
|
|
21
|
+
* {@link logoutAllDevices}, and {@link changePassword}, which otherwise throw
|
|
22
|
+
* {@link CrowdyGraphQLError} with `UNAUTHENTICATED` when the bearer token is
|
|
23
|
+
* missing, expired, or revoked.
|
|
24
|
+
*/
|
|
25
|
+
export class AuthAPI {
|
|
26
|
+
constructor(graphql, session) {
|
|
27
|
+
this.graphql = graphql;
|
|
28
|
+
this.session = session;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Authenticate with email + password and start a new session. **Public** — no
|
|
32
|
+
* existing session required.
|
|
33
|
+
*
|
|
34
|
+
* On success the returned `token` is minted **and** stored on the shared
|
|
35
|
+
* session state, so subsequent calls on any sub-client (management-api or
|
|
36
|
+
* game-api) carry it automatically — no need to call {@link setToken}.
|
|
37
|
+
*
|
|
38
|
+
* @param input - Credentials ({@link LoginUserInput}): `email` and `password`
|
|
39
|
+
* (min 8 characters).
|
|
40
|
+
* @returns An {@link AuthResponse}: the opaque session `token` (sent as
|
|
41
|
+
* `Authorization: Bearer <token>`), `gameTokenId` (the session row id, a
|
|
42
|
+
* string), and the authenticated `user`.
|
|
43
|
+
* @throws {CrowdyGraphQLError} `UNAUTHENTICATED` on invalid credentials, or
|
|
44
|
+
* `BAD_USER_INPUT` on malformed input.
|
|
45
|
+
* @example
|
|
46
|
+
* ```ts
|
|
47
|
+
* const { user } = await client.auth.login({ email, password });
|
|
48
|
+
* // the session token is now stored; later calls are authenticated for you
|
|
49
|
+
* await client.users.me();
|
|
50
|
+
* ```
|
|
51
|
+
*/
|
|
52
|
+
async login(input) {
|
|
53
|
+
const data = await this.graphql.request(LoginDocument, { input });
|
|
54
|
+
if (data.login?.token) {
|
|
55
|
+
this.session.setToken(data.login.token);
|
|
56
|
+
}
|
|
57
|
+
return data.login;
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Create a new (initially unconfirmed) account, send a confirmation email, and
|
|
61
|
+
* return a session for immediate login. **Public** — no existing session
|
|
62
|
+
* required. Same token-persistence behaviour as {@link login}: the new `token`
|
|
63
|
+
* is stored on the shared session state automatically.
|
|
64
|
+
*
|
|
65
|
+
* @param input - New-account details ({@link RegisterUserInput}): `email`
|
|
66
|
+
* (where the confirmation email is sent), `password` (min 8 characters), and
|
|
67
|
+
* an optional initial `gamertag` (min 3 characters; can also be set later via
|
|
68
|
+
* `client.users.updateGamertag`).
|
|
69
|
+
* @returns An {@link AuthResponse} (session `token`, `gameTokenId`, and the new
|
|
70
|
+
* `user`).
|
|
71
|
+
* @throws {CrowdyGraphQLError} `BAD_USER_INPUT` if the email already exists or
|
|
72
|
+
* the input is invalid.
|
|
73
|
+
*/
|
|
74
|
+
async register(input) {
|
|
75
|
+
const data = await this.graphql.request(RegisterDocument, { input });
|
|
76
|
+
if (data.register?.token) {
|
|
77
|
+
this.session.setToken(data.register.token);
|
|
78
|
+
}
|
|
79
|
+
return data.register;
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* Single-device logout: revoke the `game_tokens` row that authenticated this
|
|
83
|
+
* request; other devices/tokens are unaffected. After a successful server-side
|
|
84
|
+
* revoke the in-memory token is cleared from the shared session state so the
|
|
85
|
+
* other sub-clients stop using it. Requires a valid session.
|
|
86
|
+
*
|
|
87
|
+
* @returns `true` if a token was revoked, or `false` if the request carried no
|
|
88
|
+
* game token.
|
|
89
|
+
* @throws {CrowdyGraphQLError} `UNAUTHENTICATED` if the session is invalid.
|
|
90
|
+
*/
|
|
91
|
+
async logout() {
|
|
92
|
+
const data = await this.graphql.request(LogoutDocument);
|
|
93
|
+
this.session.setToken(null);
|
|
94
|
+
return data.logout;
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* Revoke **every** active session for the authenticated user (deletes all
|
|
98
|
+
* their `game_tokens` rows and records revocations). Requires a valid session;
|
|
99
|
+
* use {@link logout} to end only the current one.
|
|
100
|
+
*
|
|
101
|
+
* Note: unlike {@link logout}, this does not clear the SDK's in-memory token —
|
|
102
|
+
* call {@link setToken}`(null)` afterwards if you also want to drop it locally.
|
|
103
|
+
*
|
|
104
|
+
* @returns `true` on success.
|
|
105
|
+
* @throws {CrowdyGraphQLError} `UNAUTHENTICATED` if the session is invalid.
|
|
106
|
+
*/
|
|
107
|
+
async logoutAllDevices() {
|
|
108
|
+
const data = await this.graphql.request(LogoutAllDevicesDocument);
|
|
109
|
+
return data.logoutAllDevices;
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* Confirm a user's email address using the token from the confirmation email.
|
|
113
|
+
* **Public** — the token itself authorizes the call.
|
|
114
|
+
*
|
|
115
|
+
* @param token - The confirmation token from the emailed link.
|
|
116
|
+
* @returns `true` on success, or `false` if the token is invalid or expired.
|
|
117
|
+
* @throws {CrowdyGraphQLError} on transport/validation failures (invalid or
|
|
118
|
+
* expired tokens resolve to `false` rather than throwing).
|
|
119
|
+
*/
|
|
120
|
+
async confirmEmail(token) {
|
|
121
|
+
const data = await this.graphql.request(ConfirmEmailDocument, { token });
|
|
122
|
+
return data.confirmEmail;
|
|
123
|
+
}
|
|
124
|
+
/**
|
|
125
|
+
* Start the password-reset flow by emailing a reset link to the address.
|
|
126
|
+
* **Public**. Always returns `true` regardless of whether the email exists or
|
|
127
|
+
* is confirmed, to prevent account enumeration.
|
|
128
|
+
*
|
|
129
|
+
* @param email - Email address to send the password-reset link to.
|
|
130
|
+
* @returns `true` (always, even when no such account exists).
|
|
131
|
+
* @throws {CrowdyGraphQLError} on transport/validation failures.
|
|
132
|
+
*/
|
|
133
|
+
async requestPasswordReset(email) {
|
|
134
|
+
const data = await this.graphql.request(RequestPasswordResetDocument, {
|
|
135
|
+
email,
|
|
136
|
+
});
|
|
137
|
+
return data.requestPasswordReset;
|
|
138
|
+
}
|
|
139
|
+
/**
|
|
140
|
+
* Complete a password reset using the reset token and a new password.
|
|
141
|
+
* **Public** — the reset token authorizes the call. Existing sessions are
|
|
142
|
+
* **not** revoked.
|
|
143
|
+
*
|
|
144
|
+
* @param input - {@link ResetPasswordInput}: the `token` from the emailed reset
|
|
145
|
+
* link and the `newPassword` to set (min 8 characters).
|
|
146
|
+
* @returns `true` on success.
|
|
147
|
+
* @throws {CrowdyGraphQLError} `BAD_USER_INPUT` if the token is invalid or
|
|
148
|
+
* expired.
|
|
149
|
+
*/
|
|
150
|
+
async resetPassword(input) {
|
|
151
|
+
const data = await this.graphql.request(ResetPasswordDocument, {
|
|
152
|
+
input,
|
|
153
|
+
});
|
|
154
|
+
return data.resetPassword;
|
|
155
|
+
}
|
|
156
|
+
/**
|
|
157
|
+
* Re-send the email-confirmation link. **Public**. Always returns `true`
|
|
158
|
+
* regardless of whether the account exists or is already confirmed (prevents
|
|
159
|
+
* enumeration); the email is only actually sent for existing unconfirmed
|
|
160
|
+
* accounts.
|
|
161
|
+
*
|
|
162
|
+
* @param email - Email address of the account to re-send confirmation to.
|
|
163
|
+
* @returns `true` (always).
|
|
164
|
+
* @throws {CrowdyGraphQLError} on transport/validation failures.
|
|
165
|
+
*/
|
|
166
|
+
async resendConfirmationEmail(email) {
|
|
167
|
+
const data = await this.graphql.request(ResendConfirmationEmailDocument, {
|
|
168
|
+
email,
|
|
169
|
+
});
|
|
170
|
+
return data.resendConfirmationEmail;
|
|
171
|
+
}
|
|
172
|
+
/**
|
|
173
|
+
* Change the authenticated user's password after verifying the current one.
|
|
174
|
+
* Requires a valid session. Existing sessions are **not** revoked.
|
|
175
|
+
*
|
|
176
|
+
* @param currentPassword - The user's current password, for verification.
|
|
177
|
+
* @param newPassword - The new password to set (min 8 characters).
|
|
178
|
+
* @returns `true` on success.
|
|
179
|
+
* @throws {CrowdyGraphQLError} `UNAUTHENTICATED` without a valid session, or
|
|
180
|
+
* `BAD_USER_INPUT` if the current password is wrong.
|
|
181
|
+
*/
|
|
182
|
+
async changePassword(currentPassword, newPassword) {
|
|
183
|
+
const data = await this.graphql.request(ChangePasswordDocument, {
|
|
184
|
+
currentPassword,
|
|
185
|
+
newPassword,
|
|
186
|
+
});
|
|
187
|
+
return data.changePassword;
|
|
188
|
+
}
|
|
189
|
+
/**
|
|
190
|
+
* Imperatively replace the in-memory bearer token on the shared session state
|
|
191
|
+
* (e.g. to rehydrate a token persisted to disk). Affects every sub-client.
|
|
192
|
+
* Local only — performs no network call. Pass `null` to clear it.
|
|
193
|
+
*
|
|
194
|
+
* @param token - The bearer token to use, or `null` to clear the session.
|
|
195
|
+
*/
|
|
196
|
+
setToken(token) {
|
|
197
|
+
this.session.setToken(token);
|
|
198
|
+
}
|
|
199
|
+
/**
|
|
200
|
+
* Read the current in-memory bearer token from the shared session state. Local
|
|
201
|
+
* only — performs no network call.
|
|
202
|
+
*
|
|
203
|
+
* @returns The current bearer token, or `null` if none is set.
|
|
204
|
+
*/
|
|
205
|
+
getToken() {
|
|
206
|
+
return this.session.getToken();
|
|
207
|
+
}
|
|
208
|
+
}
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import type { GraphQLClient } from '../client.js';
|
|
2
|
+
import { type UserAvatarsQuery, type AvatarByIdQuery, type MyAvatarsQuery, type AvatarAppStateQuery, type AvatarAppStatesQuery, type CreateAvatarMutation, type UpdateAvatarMutation, type DeleteAvatarMutation, type UpdateAvatarStateMutation, type UpdateAvatarAppStateMutation, type CreateAvatarInput, type UpdateAvatarInput, type UpdateAvatarStateInput, type UpdateAvatarAppStateInput } from '../generated/graphql.js';
|
|
3
|
+
/**
|
|
4
|
+
* Avatars + per-app avatar state — exposed as `client.avatars`.
|
|
5
|
+
*
|
|
6
|
+
* Targets the **game-api**. Avatars are durable player identities (distinct
|
|
7
|
+
* from realtime actors). Reads are owner-aware: non-owners receive
|
|
8
|
+
* `privateState` stripped to `null`. Create/update/delete and state writes are
|
|
9
|
+
* owner-exclusive (throw on a non-owner). All require a valid session; state
|
|
10
|
+
* blobs are base64-encoded binary; `BigInt` ids are decimal strings.
|
|
11
|
+
*
|
|
12
|
+
* @throws {CrowdyGraphQLError} `UNAUTHENTICATED` without a session; an
|
|
13
|
+
* authorization error when writing an avatar you do not own.
|
|
14
|
+
*/
|
|
15
|
+
export declare class AvatarsAPI {
|
|
16
|
+
private readonly graphql;
|
|
17
|
+
constructor(graphql: GraphQLClient);
|
|
18
|
+
/**
|
|
19
|
+
* List a user's avatars (owner-aware: `privateState` stripped for non-owners).
|
|
20
|
+
*
|
|
21
|
+
* @param userId - Owner user id.
|
|
22
|
+
* @returns The user's avatars.
|
|
23
|
+
*/
|
|
24
|
+
listForUser(userId: string): Promise<UserAvatarsQuery['userAvatars']>;
|
|
25
|
+
/**
|
|
26
|
+
* Fetch one avatar by id (owner-aware). Throws if it does not exist.
|
|
27
|
+
*
|
|
28
|
+
* @param id - Avatar id.
|
|
29
|
+
* @returns The avatar.
|
|
30
|
+
*/
|
|
31
|
+
get(id: string): Promise<AvatarByIdQuery['avatar']>;
|
|
32
|
+
/**
|
|
33
|
+
* List the authenticated caller's own avatars (full state included).
|
|
34
|
+
*
|
|
35
|
+
* @returns The caller's avatars.
|
|
36
|
+
*/
|
|
37
|
+
mine(): Promise<MyAvatarsQuery['myAvatars']>;
|
|
38
|
+
/**
|
|
39
|
+
* Read one avatar's per-app state (public read). Returns `null` when unset.
|
|
40
|
+
*
|
|
41
|
+
* @param appId - App id the state is scoped to.
|
|
42
|
+
* @param avatarId - Avatar id whose per-app state to read.
|
|
43
|
+
* @returns The per-app state, or `null`.
|
|
44
|
+
*/
|
|
45
|
+
appState(appId: string, avatarId: string): Promise<AvatarAppStateQuery['avatarAppState']>;
|
|
46
|
+
/**
|
|
47
|
+
* Batch-read per-app state for many avatars under one app (public read).
|
|
48
|
+
*
|
|
49
|
+
* @param appId - App id the states are scoped to.
|
|
50
|
+
* @param avatarIds - Avatar ids to fetch.
|
|
51
|
+
* @returns The per-app states (avatars with no row are omitted).
|
|
52
|
+
*/
|
|
53
|
+
appStates(appId: string, avatarIds: string[]): Promise<AvatarAppStatesQuery['avatarAppStates']>;
|
|
54
|
+
/**
|
|
55
|
+
* Create a new avatar owned by the caller.
|
|
56
|
+
*
|
|
57
|
+
* @param input - {@link CreateAvatarInput} (optional `name`).
|
|
58
|
+
* @returns The created avatar.
|
|
59
|
+
*/
|
|
60
|
+
create(input: CreateAvatarInput): Promise<CreateAvatarMutation['createAvatar']>;
|
|
61
|
+
/**
|
|
62
|
+
* Update an avatar's mutable fields (owner-exclusive).
|
|
63
|
+
*
|
|
64
|
+
* @param id - Avatar id.
|
|
65
|
+
* @param input - {@link UpdateAvatarInput} fields to change.
|
|
66
|
+
* @returns The updated avatar.
|
|
67
|
+
*/
|
|
68
|
+
update(id: string, input: UpdateAvatarInput): Promise<UpdateAvatarMutation['updateAvatar']>;
|
|
69
|
+
/**
|
|
70
|
+
* Permanently delete an avatar (owner-exclusive). Returns the deleted row.
|
|
71
|
+
*
|
|
72
|
+
* @param id - Avatar id.
|
|
73
|
+
* @param idempotencyKey - Optional idempotency key for safe retries.
|
|
74
|
+
* @returns The now-deleted avatar.
|
|
75
|
+
*/
|
|
76
|
+
delete(id: string, idempotencyKey?: string): Promise<DeleteAvatarMutation['deleteAvatar']>;
|
|
77
|
+
/**
|
|
78
|
+
* Replace an avatar's public/private state blobs (owner-exclusive).
|
|
79
|
+
*
|
|
80
|
+
* @param id - Avatar id.
|
|
81
|
+
* @param input - {@link UpdateAvatarStateInput} (base64 blobs).
|
|
82
|
+
* @returns The updated avatar.
|
|
83
|
+
*/
|
|
84
|
+
updateState(id: string, input: UpdateAvatarStateInput): Promise<UpdateAvatarStateMutation['updateAvatarState']>;
|
|
85
|
+
/**
|
|
86
|
+
* Create/replace an avatar's per-app state (owner-exclusive write, public
|
|
87
|
+
* read).
|
|
88
|
+
*
|
|
89
|
+
* @param input - {@link UpdateAvatarAppStateInput} (appId, avatarId, state).
|
|
90
|
+
* @returns The upserted per-app state.
|
|
91
|
+
*/
|
|
92
|
+
updateAppState(input: UpdateAvatarAppStateInput): Promise<UpdateAvatarAppStateMutation['updateAvatarAppState']>;
|
|
93
|
+
}
|
|
94
|
+
//# sourceMappingURL=avatars.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"avatars.d.ts","sourceRoot":"","sources":["../../src/domains/avatars.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAClD,OAAO,EAWL,KAAK,gBAAgB,EACrB,KAAK,eAAe,EACpB,KAAK,cAAc,EACnB,KAAK,mBAAmB,EACxB,KAAK,oBAAoB,EACzB,KAAK,oBAAoB,EACzB,KAAK,oBAAoB,EACzB,KAAK,oBAAoB,EACzB,KAAK,yBAAyB,EAC9B,KAAK,4BAA4B,EACjC,KAAK,iBAAiB,EACtB,KAAK,iBAAiB,EACtB,KAAK,sBAAsB,EAC3B,KAAK,yBAAyB,EAC/B,MAAM,yBAAyB,CAAC;AAEjC;;;;;;;;;;;GAWG;AACH,qBAAa,UAAU;IACT,OAAO,CAAC,QAAQ,CAAC,OAAO;gBAAP,OAAO,EAAE,aAAa;IAEnD;;;;;OAKG;IACG,WAAW,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,gBAAgB,CAAC,aAAa,CAAC,CAAC;IAK3E;;;;;OAKG;IACG,GAAG,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,eAAe,CAAC,QAAQ,CAAC,CAAC;IAKzD;;;;OAIG;IACG,IAAI,IAAI,OAAO,CAAC,cAAc,CAAC,WAAW,CAAC,CAAC;IAKlD;;;;;;OAMG;IACG,QAAQ,CACZ,KAAK,EAAE,MAAM,EACb,QAAQ,EAAE,MAAM,GACf,OAAO,CAAC,mBAAmB,CAAC,gBAAgB,CAAC,CAAC;IAQjD;;;;;;OAMG;IACG,SAAS,CACb,KAAK,EAAE,MAAM,EACb,SAAS,EAAE,MAAM,EAAE,GAClB,OAAO,CAAC,oBAAoB,CAAC,iBAAiB,CAAC,CAAC;IAQnD;;;;;OAKG;IACG,MAAM,CACV,KAAK,EAAE,iBAAiB,GACvB,OAAO,CAAC,oBAAoB,CAAC,cAAc,CAAC,CAAC;IAKhD;;;;;;OAMG;IACG,MAAM,CACV,EAAE,EAAE,MAAM,EACV,KAAK,EAAE,iBAAiB,GACvB,OAAO,CAAC,oBAAoB,CAAC,cAAc,CAAC,CAAC;IAKhD;;;;;;OAMG;IACG,MAAM,CACV,EAAE,EAAE,MAAM,EACV,cAAc,CAAC,EAAE,MAAM,GACtB,OAAO,CAAC,oBAAoB,CAAC,cAAc,CAAC,CAAC;IAQhD;;;;;;OAMG;IACG,WAAW,CACf,EAAE,EAAE,MAAM,EACV,KAAK,EAAE,sBAAsB,GAC5B,OAAO,CAAC,yBAAyB,CAAC,mBAAmB,CAAC,CAAC;IAQ1D;;;;;;OAMG;IACG,cAAc,CAClB,KAAK,EAAE,yBAAyB,GAC/B,OAAO,CAAC,4BAA4B,CAAC,sBAAsB,CAAC,CAAC;CAMjE"}
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
import { UserAvatarsDocument, AvatarByIdDocument, MyAvatarsDocument, AvatarAppStateDocument, AvatarAppStatesDocument, CreateAvatarDocument, UpdateAvatarDocument, DeleteAvatarDocument, UpdateAvatarStateDocument, UpdateAvatarAppStateDocument, } from '../generated/graphql.js';
|
|
2
|
+
/**
|
|
3
|
+
* Avatars + per-app avatar state — exposed as `client.avatars`.
|
|
4
|
+
*
|
|
5
|
+
* Targets the **game-api**. Avatars are durable player identities (distinct
|
|
6
|
+
* from realtime actors). Reads are owner-aware: non-owners receive
|
|
7
|
+
* `privateState` stripped to `null`. Create/update/delete and state writes are
|
|
8
|
+
* owner-exclusive (throw on a non-owner). All require a valid session; state
|
|
9
|
+
* blobs are base64-encoded binary; `BigInt` ids are decimal strings.
|
|
10
|
+
*
|
|
11
|
+
* @throws {CrowdyGraphQLError} `UNAUTHENTICATED` without a session; an
|
|
12
|
+
* authorization error when writing an avatar you do not own.
|
|
13
|
+
*/
|
|
14
|
+
export class AvatarsAPI {
|
|
15
|
+
constructor(graphql) {
|
|
16
|
+
this.graphql = graphql;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* List a user's avatars (owner-aware: `privateState` stripped for non-owners).
|
|
20
|
+
*
|
|
21
|
+
* @param userId - Owner user id.
|
|
22
|
+
* @returns The user's avatars.
|
|
23
|
+
*/
|
|
24
|
+
async listForUser(userId) {
|
|
25
|
+
const data = await this.graphql.request(UserAvatarsDocument, { userId });
|
|
26
|
+
return data.userAvatars;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Fetch one avatar by id (owner-aware). Throws if it does not exist.
|
|
30
|
+
*
|
|
31
|
+
* @param id - Avatar id.
|
|
32
|
+
* @returns The avatar.
|
|
33
|
+
*/
|
|
34
|
+
async get(id) {
|
|
35
|
+
const data = await this.graphql.request(AvatarByIdDocument, { id });
|
|
36
|
+
return data.avatar;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* List the authenticated caller's own avatars (full state included).
|
|
40
|
+
*
|
|
41
|
+
* @returns The caller's avatars.
|
|
42
|
+
*/
|
|
43
|
+
async mine() {
|
|
44
|
+
const data = await this.graphql.request(MyAvatarsDocument, {});
|
|
45
|
+
return data.myAvatars;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Read one avatar's per-app state (public read). Returns `null` when unset.
|
|
49
|
+
*
|
|
50
|
+
* @param appId - App id the state is scoped to.
|
|
51
|
+
* @param avatarId - Avatar id whose per-app state to read.
|
|
52
|
+
* @returns The per-app state, or `null`.
|
|
53
|
+
*/
|
|
54
|
+
async appState(appId, avatarId) {
|
|
55
|
+
const data = await this.graphql.request(AvatarAppStateDocument, {
|
|
56
|
+
appId,
|
|
57
|
+
avatarId,
|
|
58
|
+
});
|
|
59
|
+
return data.avatarAppState;
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Batch-read per-app state for many avatars under one app (public read).
|
|
63
|
+
*
|
|
64
|
+
* @param appId - App id the states are scoped to.
|
|
65
|
+
* @param avatarIds - Avatar ids to fetch.
|
|
66
|
+
* @returns The per-app states (avatars with no row are omitted).
|
|
67
|
+
*/
|
|
68
|
+
async appStates(appId, avatarIds) {
|
|
69
|
+
const data = await this.graphql.request(AvatarAppStatesDocument, {
|
|
70
|
+
appId,
|
|
71
|
+
avatarIds,
|
|
72
|
+
});
|
|
73
|
+
return data.avatarAppStates;
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Create a new avatar owned by the caller.
|
|
77
|
+
*
|
|
78
|
+
* @param input - {@link CreateAvatarInput} (optional `name`).
|
|
79
|
+
* @returns The created avatar.
|
|
80
|
+
*/
|
|
81
|
+
async create(input) {
|
|
82
|
+
const data = await this.graphql.request(CreateAvatarDocument, { input });
|
|
83
|
+
return data.createAvatar;
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Update an avatar's mutable fields (owner-exclusive).
|
|
87
|
+
*
|
|
88
|
+
* @param id - Avatar id.
|
|
89
|
+
* @param input - {@link UpdateAvatarInput} fields to change.
|
|
90
|
+
* @returns The updated avatar.
|
|
91
|
+
*/
|
|
92
|
+
async update(id, input) {
|
|
93
|
+
const data = await this.graphql.request(UpdateAvatarDocument, { id, input });
|
|
94
|
+
return data.updateAvatar;
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* Permanently delete an avatar (owner-exclusive). Returns the deleted row.
|
|
98
|
+
*
|
|
99
|
+
* @param id - Avatar id.
|
|
100
|
+
* @param idempotencyKey - Optional idempotency key for safe retries.
|
|
101
|
+
* @returns The now-deleted avatar.
|
|
102
|
+
*/
|
|
103
|
+
async delete(id, idempotencyKey) {
|
|
104
|
+
const data = await this.graphql.request(DeleteAvatarDocument, {
|
|
105
|
+
id,
|
|
106
|
+
idempotencyKey,
|
|
107
|
+
});
|
|
108
|
+
return data.deleteAvatar;
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* Replace an avatar's public/private state blobs (owner-exclusive).
|
|
112
|
+
*
|
|
113
|
+
* @param id - Avatar id.
|
|
114
|
+
* @param input - {@link UpdateAvatarStateInput} (base64 blobs).
|
|
115
|
+
* @returns The updated avatar.
|
|
116
|
+
*/
|
|
117
|
+
async updateState(id, input) {
|
|
118
|
+
const data = await this.graphql.request(UpdateAvatarStateDocument, {
|
|
119
|
+
id,
|
|
120
|
+
input,
|
|
121
|
+
});
|
|
122
|
+
return data.updateAvatarState;
|
|
123
|
+
}
|
|
124
|
+
/**
|
|
125
|
+
* Create/replace an avatar's per-app state (owner-exclusive write, public
|
|
126
|
+
* read).
|
|
127
|
+
*
|
|
128
|
+
* @param input - {@link UpdateAvatarAppStateInput} (appId, avatarId, state).
|
|
129
|
+
* @returns The upserted per-app state.
|
|
130
|
+
*/
|
|
131
|
+
async updateAppState(input) {
|
|
132
|
+
const data = await this.graphql.request(UpdateAvatarAppStateDocument, {
|
|
133
|
+
input,
|
|
134
|
+
});
|
|
135
|
+
return data.updateAvatarAppState;
|
|
136
|
+
}
|
|
137
|
+
}
|