@nadohq/mobile-client 0.54.0 → 0.56.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/README.md +4 -4
- package/dist/{MobileClient-BbTaqTzi.cjs → MobileClient-DjNpN7Dw.cjs} +55 -4
- package/dist/MobileClient-DjNpN7Dw.cjs.map +1 -0
- package/dist/MobileClient.cjs +1 -1
- package/dist/MobileClient.d.cts +49 -9
- package/dist/MobileClient.d.cts.map +1 -1
- package/dist/MobileClient.d.ts +49 -9
- package/dist/MobileClient.d.ts.map +1 -1
- package/dist/MobileClient.js +55 -4
- package/dist/MobileClient.js.map +1 -1
- package/dist/{MobileServerFailureError-B2og8e5O.d.ts → MobileServerFailureError-DvtkMAVX.d.ts} +3 -3
- package/dist/{MobileServerFailureError-B2og8e5O.d.ts.map → MobileServerFailureError-DvtkMAVX.d.ts.map} +1 -1
- package/dist/{MobileServerFailureError-BrLtaHnU.d.cts → MobileServerFailureError-kbMi1Ntc.d.cts} +3 -3
- package/dist/{MobileServerFailureError-BrLtaHnU.d.cts.map → MobileServerFailureError-kbMi1Ntc.d.cts.map} +1 -1
- package/dist/{buildSignedMobileRequest-CZ-EdxYI.d.cts → buildSignedMobileRequest-DBWN0z0u.d.cts} +2 -2
- package/dist/{buildSignedMobileRequest-CZ-EdxYI.d.cts.map → buildSignedMobileRequest-DBWN0z0u.d.cts.map} +1 -1
- package/dist/{buildSignedMobileRequest-CoAVSDPx.d.ts → buildSignedMobileRequest-lSIJmG6D.d.ts} +2 -2
- package/dist/{buildSignedMobileRequest-CoAVSDPx.d.ts.map → buildSignedMobileRequest-lSIJmG6D.d.ts.map} +1 -1
- package/dist/{canonicalize-BC-JICjp.d.ts → canonicalize-Cx3lCVpm.d.ts} +2 -2
- package/dist/canonicalize-Cx3lCVpm.d.ts.map +1 -0
- package/dist/{canonicalize-0_B6UOxO.d.cts → canonicalize-DNgB8Jsm.d.cts} +2 -2
- package/dist/canonicalize-DNgB8Jsm.d.cts.map +1 -0
- package/dist/{clientTypes-YF5d8bvg.d.cts → clientTypes-DnPE1zZO.d.cts} +64 -12
- package/dist/clientTypes-DnPE1zZO.d.cts.map +1 -0
- package/dist/{clientTypes-P4LAjreY.d.ts → clientTypes-ws9CDHw4.d.ts} +64 -12
- package/dist/clientTypes-ws9CDHw4.d.ts.map +1 -0
- package/dist/dataMappers.cjs +39 -3
- package/dist/dataMappers.cjs.map +1 -1
- package/dist/dataMappers.d.cts +18 -6
- package/dist/dataMappers.d.cts.map +1 -1
- package/dist/dataMappers.d.ts +18 -6
- package/dist/dataMappers.d.ts.map +1 -1
- package/dist/dataMappers.js +37 -4
- package/dist/dataMappers.js.map +1 -1
- package/dist/{eip712MethodByType-DWtLyPY7.d.ts → eip712MethodByType-Bmu9PYx6.d.ts} +2 -2
- package/dist/eip712MethodByType-Bmu9PYx6.d.ts.map +1 -0
- package/dist/{eip712MethodByType-sHQ-VTHd.d.cts → eip712MethodByType-T7dfjmC_.d.cts} +2 -2
- package/dist/eip712MethodByType-T7dfjmC_.d.cts.map +1 -0
- package/dist/index.cjs +5 -1
- package/dist/index.d.cts +16 -15
- package/dist/index.d.ts +16 -15
- package/dist/index.js +2 -1
- package/dist/{mobileErrorCodes-DccrM4NI.d.ts → mobileErrorCodes-B3kTLit_.d.cts} +4 -2
- package/dist/mobileErrorCodes-B3kTLit_.d.cts.map +1 -0
- package/dist/{mobileErrorCodes-DccrM4NI.d.cts → mobileErrorCodes-B3kTLit_.d.ts} +4 -2
- package/dist/mobileErrorCodes-B3kTLit_.d.ts.map +1 -0
- package/dist/{payloadHash-CSgTglN4.d.cts → payloadHash-Brc5ceFq.d.cts} +2 -2
- package/dist/payloadHash-Brc5ceFq.d.cts.map +1 -0
- package/dist/{payloadHash-qsU1DEF0.d.ts → payloadHash-cZgv7NSo.d.ts} +2 -2
- package/dist/payloadHash-cZgv7NSo.d.ts.map +1 -0
- package/dist/profile-BozA3yVP.d.cts +16 -0
- package/dist/profile-BozA3yVP.d.cts.map +1 -0
- package/dist/profile-BozA3yVP.d.ts +16 -0
- package/dist/profile-BozA3yVP.d.ts.map +1 -0
- package/dist/{serverBaseTypes-DKCLDn3x.d.ts → serverBaseTypes-CWBdZomv.d.ts} +2 -2
- package/dist/{serverBaseTypes-DKCLDn3x.d.ts.map → serverBaseTypes-CWBdZomv.d.ts.map} +1 -1
- package/dist/{serverBaseTypes-CuMsGXgc.d.cts → serverBaseTypes-CcWT_ZBe.d.cts} +2 -2
- package/dist/{serverBaseTypes-CuMsGXgc.d.cts.map → serverBaseTypes-CcWT_ZBe.d.cts.map} +1 -1
- package/dist/{serverExecuteTypes-TPX0GCgv.d.cts → serverExecuteTypes-CgjzwBaA.d.cts} +24 -5
- package/dist/serverExecuteTypes-CgjzwBaA.d.cts.map +1 -0
- package/dist/{serverExecuteTypes-DKG1mqy1.d.ts → serverExecuteTypes-jyr5aO5q.d.ts} +24 -5
- package/dist/serverExecuteTypes-jyr5aO5q.d.ts.map +1 -0
- package/dist/{serverModelTypes-MlqdaMRd.d.ts → serverModelTypes-DAqEyYtB.d.cts} +25 -7
- package/dist/serverModelTypes-DAqEyYtB.d.cts.map +1 -0
- package/dist/{serverModelTypes-MlqdaMRd.d.cts → serverModelTypes-DAqEyYtB.d.ts} +25 -7
- package/dist/serverModelTypes-DAqEyYtB.d.ts.map +1 -0
- package/dist/{serverQueryTypes-BLUe10AI.d.ts → serverQueryTypes-DPRP61yA.d.ts} +14 -5
- package/dist/serverQueryTypes-DPRP61yA.d.ts.map +1 -0
- package/dist/{serverQueryTypes-BZOoJBpb.d.cts → serverQueryTypes-H_mI6fPl.d.cts} +14 -5
- package/dist/serverQueryTypes-H_mI6fPl.d.cts.map +1 -0
- package/dist/{serverRequestTypes-BULjZnnz.d.ts → serverRequestTypes-BY0f5woc.d.ts} +5 -3
- package/dist/serverRequestTypes-BY0f5woc.d.ts.map +1 -0
- package/dist/{serverRequestTypes-XbnLUsXT.d.cts → serverRequestTypes-DGGqQMK3.d.cts} +5 -3
- package/dist/serverRequestTypes-DGGqQMK3.d.cts.map +1 -0
- package/dist/{serverResponseGuards-DY_8lAo7.d.ts → serverResponseGuards-BGHTBbtz.d.ts} +2 -2
- package/dist/{serverResponseGuards-DY_8lAo7.d.ts.map → serverResponseGuards-BGHTBbtz.d.ts.map} +1 -1
- package/dist/{serverResponseGuards-DIj9MIrJ.d.cts → serverResponseGuards-DGhrUL_c.d.cts} +2 -2
- package/dist/{serverResponseGuards-DIj9MIrJ.d.cts.map → serverResponseGuards-DGhrUL_c.d.cts.map} +1 -1
- package/dist/signing/buildSignedMobileRequest.d.cts +1 -1
- package/dist/signing/buildSignedMobileRequest.d.ts +1 -1
- package/dist/signing/canonicalize.cjs +25 -0
- package/dist/signing/canonicalize.cjs.map +1 -1
- package/dist/signing/canonicalize.d.cts +1 -1
- package/dist/signing/canonicalize.d.ts +1 -1
- package/dist/signing/canonicalize.js +25 -0
- package/dist/signing/canonicalize.js.map +1 -1
- package/dist/signing/eip712MethodByType.cjs +3 -0
- package/dist/signing/eip712MethodByType.cjs.map +1 -1
- package/dist/signing/eip712MethodByType.d.cts +1 -1
- package/dist/signing/eip712MethodByType.d.ts +1 -1
- package/dist/signing/eip712MethodByType.js +3 -0
- package/dist/signing/eip712MethodByType.js.map +1 -1
- package/dist/signing/index.d.cts +5 -5
- package/dist/signing/index.d.ts +5 -5
- package/dist/signing/payloadHash.d.cts +1 -1
- package/dist/signing/payloadHash.d.ts +1 -1
- package/dist/signing/types.d.cts +1 -1
- package/dist/signing/types.d.ts +1 -1
- package/dist/types/MobileServerFailureError.d.cts +1 -1
- package/dist/types/MobileServerFailureError.d.ts +1 -1
- package/dist/types/clientTypes.d.cts +2 -2
- package/dist/types/clientTypes.d.ts +2 -2
- package/dist/types/index.d.cts +9 -9
- package/dist/types/index.d.ts +9 -9
- package/dist/types/mobileErrorCodes.cjs +4 -0
- package/dist/types/mobileErrorCodes.cjs.map +1 -1
- package/dist/types/mobileErrorCodes.d.cts +1 -1
- package/dist/types/mobileErrorCodes.d.ts +1 -1
- package/dist/types/mobileErrorCodes.js +4 -0
- package/dist/types/mobileErrorCodes.js.map +1 -1
- package/dist/types/serverBaseTypes.d.cts +1 -1
- package/dist/types/serverBaseTypes.d.ts +1 -1
- package/dist/types/serverExecuteTypes.d.cts +2 -2
- package/dist/types/serverExecuteTypes.d.ts +2 -2
- package/dist/types/serverModelTypes.cjs.map +1 -1
- package/dist/types/serverModelTypes.d.cts +2 -2
- package/dist/types/serverModelTypes.d.ts +2 -2
- package/dist/types/serverModelTypes.js.map +1 -1
- package/dist/types/serverQueryTypes.d.cts +2 -2
- package/dist/types/serverQueryTypes.d.ts +2 -2
- package/dist/types/serverRequestTypes.d.cts +1 -1
- package/dist/types/serverRequestTypes.d.ts +1 -1
- package/dist/{types-B_4veFLc.d.ts → types-B021odcS.d.ts} +12 -3
- package/dist/types-B021odcS.d.ts.map +1 -0
- package/dist/{types-CwpXP7xM.d.cts → types-l47aSWtA.d.cts} +12 -3
- package/dist/types-l47aSWtA.d.cts.map +1 -0
- package/dist/utils/index.cjs +4 -0
- package/dist/utils/index.d.cts +3 -2
- package/dist/utils/index.d.ts +3 -2
- package/dist/utils/index.js +2 -1
- package/dist/utils/profile.cjs +22 -0
- package/dist/utils/profile.cjs.map +1 -0
- package/dist/utils/profile.d.cts +2 -0
- package/dist/utils/profile.d.ts +2 -0
- package/dist/utils/profile.js +19 -0
- package/dist/utils/profile.js.map +1 -0
- package/dist/utils/serverResponseGuards.d.cts +1 -1
- package/dist/utils/serverResponseGuards.d.ts +1 -1
- package/package.json +3 -3
- package/src/MobileClient.ts +85 -3
- package/src/dataMappers.ts +49 -4
- package/src/signing/canonicalize.ts +20 -0
- package/src/signing/eip712MethodByType.ts +3 -0
- package/src/signing/signing.test.ts +67 -1
- package/src/signing/types.ts +10 -1
- package/src/types/clientTypes.ts +73 -9
- package/src/types/mobileErrorCodes.ts +4 -0
- package/src/types/serverExecuteTypes.ts +21 -1
- package/src/types/serverModelTypes.ts +31 -5
- package/src/types/serverQueryTypes.ts +11 -0
- package/src/types/serverRequestTypes.ts +2 -0
- package/src/utils/index.ts +1 -0
- package/src/utils/profile.test.ts +22 -0
- package/src/utils/profile.ts +16 -0
- package/dist/MobileClient-BbTaqTzi.cjs.map +0 -1
- package/dist/canonicalize-0_B6UOxO.d.cts.map +0 -1
- package/dist/canonicalize-BC-JICjp.d.ts.map +0 -1
- package/dist/clientTypes-P4LAjreY.d.ts.map +0 -1
- package/dist/clientTypes-YF5d8bvg.d.cts.map +0 -1
- package/dist/eip712MethodByType-DWtLyPY7.d.ts.map +0 -1
- package/dist/eip712MethodByType-sHQ-VTHd.d.cts.map +0 -1
- package/dist/mobileErrorCodes-DccrM4NI.d.cts.map +0 -1
- package/dist/mobileErrorCodes-DccrM4NI.d.ts.map +0 -1
- package/dist/payloadHash-CSgTglN4.d.cts.map +0 -1
- package/dist/payloadHash-qsU1DEF0.d.ts.map +0 -1
- package/dist/serverExecuteTypes-DKG1mqy1.d.ts.map +0 -1
- package/dist/serverExecuteTypes-TPX0GCgv.d.cts.map +0 -1
- package/dist/serverModelTypes-MlqdaMRd.d.cts.map +0 -1
- package/dist/serverModelTypes-MlqdaMRd.d.ts.map +0 -1
- package/dist/serverQueryTypes-BLUe10AI.d.ts.map +0 -1
- package/dist/serverQueryTypes-BZOoJBpb.d.cts.map +0 -1
- package/dist/serverRequestTypes-BULjZnnz.d.ts.map +0 -1
- package/dist/serverRequestTypes-XbnLUsXT.d.cts.map +0 -1
- package/dist/types-B_4veFLc.d.ts.map +0 -1
- package/dist/types-CwpXP7xM.d.cts.map +0 -1
package/README.md
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
# `@nadohq/mobile-client`
|
|
2
2
|
|
|
3
|
-
HTTP client for the Nado mobile service API. Manages usernames, public profile lookups,
|
|
4
|
-
session-based trade feeds, the follower/following graph, privacy settings, and push notification
|
|
3
|
+
HTTP client for the Nado mobile service API. Manages usernames, bios, avatars, public profile lookups,
|
|
4
|
+
global and session-based trade feeds, the follower/following graph, privacy settings, and push notification
|
|
5
5
|
devices/preferences. Public queries require no wallet; authenticated operations use EIP-712 + msgpack signing.
|
|
6
6
|
|
|
7
7
|
[Full SDK Documentation](https://nadohq.github.io/nado-typescript-sdk/index.html)
|
|
@@ -46,7 +46,7 @@ await mobile.setUsername({
|
|
|
46
46
|
|
|
47
47
|
### Public Queries
|
|
48
48
|
|
|
49
|
-
`getUsernameAvailability`, `getProfiles`, `getFollowers`, `getFollowing`, `getFeed`,
|
|
49
|
+
`getAvatarPresets`, `getUsernameAvailability`, `getProfiles`, `getFollowers`, `getFollowing`, `getFeed`,
|
|
50
50
|
`getNotificationPreferences`, `getRegisteredWallet`, `getForYouFeed`, `getTopTradersFeed`,
|
|
51
51
|
`getFriendsFeed`, `getProfileFeed`, `getMarketFeed`, `getPositionFeed`, `getFeedItem`, `getFeedUpdates`.
|
|
52
52
|
|
|
@@ -75,7 +75,7 @@ push token rather than a wallet signature, so they still work at logout when a s
|
|
|
75
75
|
|
|
76
76
|
### Signed Executes
|
|
77
77
|
|
|
78
|
-
`setUsername`, `setPrivateMode`, `registerExpoToken`, `setFollow`.
|
|
78
|
+
`setUsername`, `setBio`, `createAvatarUpload`, `setAvatar`, `setPrivateMode`, `registerExpoToken`, `setFollow`.
|
|
79
79
|
|
|
80
80
|
### Linked Signers
|
|
81
81
|
|
|
@@ -29,9 +29,9 @@ let axios = require("axios");
|
|
|
29
29
|
axios = __toESM(axios, 1);
|
|
30
30
|
//#region src/MobileClient.ts
|
|
31
31
|
/**
|
|
32
|
-
* Client for the Nado mobile service API: usernames, public profile lookups, the global
|
|
33
|
-
* session-based social feeds, the follower/following graph, privacy settings, and push
|
|
34
|
-
* device/preference management.
|
|
32
|
+
* Client for the Nado mobile service API: usernames, bios, avatars, public profile lookups, the global
|
|
33
|
+
* trade feed, session-based social feeds, the follower/following graph, privacy settings, and push
|
|
34
|
+
* notification device/preference management.
|
|
35
35
|
*/
|
|
36
36
|
var MobileClient = class {
|
|
37
37
|
constructor(opts) {
|
|
@@ -51,6 +51,14 @@ var MobileClient = class {
|
|
|
51
51
|
this.opts.linkedSignerWalletClient = linkedSignerWalletClient ?? void 0;
|
|
52
52
|
}
|
|
53
53
|
/**
|
|
54
|
+
* Returns the current server-owned avatar catalogue in display order.
|
|
55
|
+
*
|
|
56
|
+
* @throws {MobileServerFailureError} With `SERVICE_UNAVAILABLE` when avatar storage is not configured.
|
|
57
|
+
*/
|
|
58
|
+
async getAvatarPresets() {
|
|
59
|
+
return (await this.publicQuery({ type: "avatar_presets" })).presets.map(require_dataMappers.mapMobileAvatarPreset);
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
54
62
|
* Checks whether a username derived from the given display name is available to claim.
|
|
55
63
|
*/
|
|
56
64
|
async getUsernameAvailability(params) {
|
|
@@ -348,9 +356,51 @@ var MobileClient = class {
|
|
|
348
356
|
return this.publicExecute(body);
|
|
349
357
|
}
|
|
350
358
|
/**
|
|
359
|
+
* Updates the biography, or clears it when the text is whitespace-only.
|
|
360
|
+
*
|
|
361
|
+
* Serialize this with {@link MobileClient.setAvatar}, {@link MobileClient.setUsername} and
|
|
362
|
+
* {@link MobileClient.setPrivateMode} for the same subaccount: all share the identity update nonce.
|
|
363
|
+
*
|
|
364
|
+
* @throws {MobileServerFailureError} With `INVALID_BIO` for exceeding `MOBILE_BIO_MAX_LENGTH` or null
|
|
365
|
+
* characters, `INVALID_IDENTITY_TARGET` for an isolated subaccount, or `STALE_IDENTITY_UPDATE` when a
|
|
366
|
+
* later write has committed (re-read the profile before retrying).
|
|
367
|
+
*/
|
|
368
|
+
async setBio(params) {
|
|
369
|
+
const signedRequest = await this.getSignedRequest("set_bio", params, { bio: params.bio });
|
|
370
|
+
return this.execute(signedRequest);
|
|
371
|
+
}
|
|
372
|
+
/**
|
|
373
|
+
* Creates a short-lived upload grant. The caller uploads an image meeting {@link MobileAvatarUpload}'s requirements;
|
|
374
|
+
* file access and transport remain platform-specific. This does not change the saved avatar.
|
|
375
|
+
*
|
|
376
|
+
* @throws {MobileServerFailureError} With `INVALID_AVATAR` for a zero or oversized upload,
|
|
377
|
+
* `INVALID_IDENTITY_TARGET` for an isolated subaccount, or `SERVICE_UNAVAILABLE` when storage is unavailable.
|
|
378
|
+
*/
|
|
379
|
+
async createAvatarUpload(params) {
|
|
380
|
+
const signedRequest = await this.getSignedRequest("create_avatar_upload", params, { content_length: params.contentLength });
|
|
381
|
+
return require_dataMappers.mapMobileAvatarUpload(await this.execute(signedRequest));
|
|
382
|
+
}
|
|
383
|
+
/**
|
|
384
|
+
* Publishes a preset/staged upload, or clears the saved avatar when avatar is null.
|
|
385
|
+
* Uploaded JPEG/PNG images must be square, at most 4096 × 4096 pixels, and within
|
|
386
|
+
* `MOBILE_AVATAR_MAX_UPLOAD_BYTES`. A successful PUT can still fail this publication check.
|
|
387
|
+
*
|
|
388
|
+
* Serialize identity writes for the same subaccount; see {@link MobileClient.setBio}.
|
|
389
|
+
*
|
|
390
|
+
* @throws {MobileServerFailureError} With `INVALID_AVATAR` for an invalid preset, staging key, or image,
|
|
391
|
+
* `INVALID_IDENTITY_TARGET` for an isolated subaccount, `SERVICE_UNAVAILABLE` when storage is unavailable,
|
|
392
|
+
* or `STALE_IDENTITY_UPDATE` when a later write has committed (re-read the profile before retrying).
|
|
393
|
+
*/
|
|
394
|
+
async setAvatar(params) {
|
|
395
|
+
const signedRequest = await this.getSignedRequest("set_avatar", params, { avatar: require_dataMappers.mapMobileAvatarSelectionToServer(params.avatar) });
|
|
396
|
+
return this.execute(signedRequest);
|
|
397
|
+
}
|
|
398
|
+
/**
|
|
351
399
|
* Sets a subaccount's username, derived from the given display name. Upserts: the same call claims a first
|
|
352
400
|
* username and renames an existing one, so callers never need to read the current identity first.
|
|
353
401
|
*
|
|
402
|
+
* Serialize identity writes for the same subaccount; see {@link MobileClient.setBio}.
|
|
403
|
+
*
|
|
354
404
|
* @throws {MobileServerFailureError} With error code `INVALID_DISPLAY_NAME` if the display name violates
|
|
355
405
|
* `MOBILE_DISPLAY_NAME_PATTERN`, `USERNAME_UNAVAILABLE` if the derived username is reserved or already
|
|
356
406
|
* taken by another subaccount, `INVALID_IDENTITY_TARGET` if the sender is in the engine-created isolated
|
|
@@ -363,6 +413,7 @@ var MobileClient = class {
|
|
|
363
413
|
}
|
|
364
414
|
/**
|
|
365
415
|
* Sets whether a subaccount's profile is private.
|
|
416
|
+
* Serialize identity writes for the same subaccount; see {@link MobileClient.setBio}.
|
|
366
417
|
*/
|
|
367
418
|
async setPrivateMode(params) {
|
|
368
419
|
const signedRequest = await this.getSignedRequest("set_private_mode", params, { private_mode: params.privateMode });
|
|
@@ -462,4 +513,4 @@ Object.defineProperty(exports, "MobileClient", {
|
|
|
462
513
|
}
|
|
463
514
|
});
|
|
464
515
|
|
|
465
|
-
//# sourceMappingURL=MobileClient-
|
|
516
|
+
//# sourceMappingURL=MobileClient-DjNpN7Dw.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MobileClient-DjNpN7Dw.cjs","names":["mapMobileAvatarPreset","subaccountToHex","mapMobileProfilesIncludeToServer","mapMobilePublicProfile","mapMobileFollowListParamsToServer","mapMobileFollowListPage","mapMobileFeedPage","mapMobileSocialFeedListParamsToServer","mapMobileSocialFeedReadParamsToServer","mapMobileSocialFeedRankedPage","mapMobileSocialFeedTopTradersPage","mapMobileSocialFeedPage","mapMobileSocialFeedItemResponse","mapMobileSocialFeedUpdates","mapMobileNotificationPreferences","mapMobileRegisteredWallet","mapMobileNotificationPreferencesToServer","mapMobileAvatarUpload","mapMobileAvatarSelectionToServer","mapMobileFollowMutationResult","WalletNotProvidedError","buildSignedMobileRequest","isMobileServerFailureResponse","MobileServerFailureError","isMobileServerSuccessResponse"],"sources":["../src/MobileClient.ts"],"sourcesContent":["import {\n getNadoClientTypeHeaders,\n subaccountToHex,\n WalletClientWithAccount,\n WalletNotProvidedError,\n} from '@nadohq/shared';\nimport axios, { AxiosInstance, AxiosResponse } from 'axios';\nimport {\n mapMobileAvatarPreset,\n mapMobileAvatarSelectionToServer,\n mapMobileAvatarUpload,\n mapMobileFeedPage,\n mapMobileFollowListPage,\n mapMobileFollowListParamsToServer,\n mapMobileFollowMutationResult,\n mapMobileNotificationPreferences,\n mapMobileNotificationPreferencesToServer,\n mapMobileProfilesIncludeToServer,\n mapMobilePublicProfile,\n mapMobileRegisteredWallet,\n mapMobileSocialFeedItemResponse,\n mapMobileSocialFeedListParamsToServer,\n mapMobileSocialFeedPage,\n mapMobileSocialFeedRankedPage,\n mapMobileSocialFeedReadParamsToServer,\n mapMobileSocialFeedTopTradersPage,\n mapMobileSocialFeedUpdates,\n} from './dataMappers';\nimport {\n buildSignedMobileRequest,\n MobileSignedInner,\n MobileSignedInnerByType,\n MobileSignedInnerParams,\n MobileSignedRequest,\n} from './signing';\nimport {\n GetMobileFeedItemParams,\n GetMobileFeedParams,\n GetMobileFeedUpdatesParams,\n GetMobileFollowersParams,\n GetMobileFollowingParams,\n GetMobileForYouFeedParams,\n GetMobileFriendsFeedParams,\n GetMobileMarketFeedParams,\n GetMobileNotificationPreferencesParams,\n GetMobilePositionFeedParams,\n GetMobileProfileFeedParams,\n GetMobileProfilesParams,\n GetMobileRegisteredWalletParams,\n GetMobileTopTradersFeedParams,\n GetMobileUsernameAvailabilityParams,\n MobileAvatarPreset,\n MobileAvatarUpload,\n MobileCreateAvatarUploadParams,\n MobileFeedPage,\n MobileFollowListPage,\n MobileFollowMutationResult,\n MobileNotificationPreferences,\n MobilePublicProfile,\n MobileRegisteredWallet,\n MobileRegisterExpoTokenParams,\n MobileSetAvatarParams,\n MobileSetBioParams,\n MobileSetFollowParams,\n MobileSetPrivateModeParams,\n MobileSetUsernameParams,\n MobileSignedRequestParams,\n MobileSocialFeedItemResponse,\n MobileSocialFeedPage,\n MobileSocialFeedRankedPage,\n MobileSocialFeedTopTradersPage,\n MobileSocialFeedUpdates,\n MobileUnregisterExpoTokenParams,\n MobileUpdateNotificationPreferencesParams,\n MobileUsernameAvailability,\n} from './types/clientTypes';\nimport { MobileServerFailureError } from './types/MobileServerFailureError';\nimport { MobileServerSuccessResponse } from './types/serverBaseTypes';\nimport {\n MobileServerExecuteResult,\n MobileServerExecuteSuccessResponse,\n MobileServerPublicExecuteRequest,\n} from './types/serverExecuteTypes';\nimport {\n MobileServerPublicQueryRequest,\n MobileServerPublicQuerySuccessResponse,\n} from './types/serverQueryTypes';\nimport {\n MobileServerExecuteRequestType,\n MobileServerPublicQueryRequestByType,\n MobileServerPublicQueryRequestType,\n} from './types/serverRequestTypes';\nimport {\n isMobileServerFailureResponse,\n isMobileServerSuccessResponse,\n} from './utils/serverResponseGuards';\n\n/**\n * Options for constructing a {@link MobileClient}.\n */\nexport interface MobileClientOpts {\n /**\n * Base URL of the mobile service API, e.g. {@link MOBILE_CLIENT_ENDPOINTS}.\n */\n url: string;\n /**\n * Wallet client used to sign requests.\n */\n walletClient?: WalletClientWithAccount;\n /**\n * If provided, this signer is used instead of `walletClient` for all signed requests.\n */\n linkedSignerWalletClient?: WalletClientWithAccount;\n /**\n * If provided, identifies the calling client, sent as a header with every request.\n */\n clientType?: string;\n}\n\n/**\n * Client for the Nado mobile service API: usernames, bios, avatars, public profile lookups, the global\n * trade feed, session-based social feeds, the follower/following graph, privacy settings, and push\n * notification device/preference management.\n */\nexport class MobileClient {\n readonly opts: MobileClientOpts;\n readonly axiosInstance: AxiosInstance;\n\n constructor(opts: MobileClientOpts) {\n this.opts = opts;\n this.axiosInstance = axios.create({\n withCredentials: true,\n // We have custom logic to validate response status and create an appropriate error\n validateStatus: () => true,\n headers: getNadoClientTypeHeaders(opts.clientType),\n });\n }\n\n /**\n * Sets the linked signer for requests\n *\n * @param linkedSignerWalletClient The linkedSigner to use for all signatures. Set to null to revert to the chain signer\n */\n public setLinkedSigner(\n linkedSignerWalletClient: WalletClientWithAccount | null,\n ) {\n this.opts.linkedSignerWalletClient = linkedSignerWalletClient ?? undefined;\n }\n\n /*\n Public queries\n */\n\n /**\n * Returns the current server-owned avatar catalogue in display order.\n *\n * @throws {MobileServerFailureError} With `SERVICE_UNAVAILABLE` when avatar storage is not configured.\n */\n async getAvatarPresets(): Promise<MobileAvatarPreset[]> {\n const body: MobileServerPublicQueryRequest<'avatar_presets'> = {\n type: 'avatar_presets',\n };\n const data = await this.publicQuery(body);\n return data.presets.map(mapMobileAvatarPreset);\n }\n\n /**\n * Checks whether a username derived from the given display name is available to claim.\n */\n async getUsernameAvailability(\n params: GetMobileUsernameAvailabilityParams,\n ): Promise<MobileUsernameAvailability> {\n const body: MobileServerPublicQueryRequest<'username_availability'> = {\n type: 'username_availability',\n display_name: params.displayName,\n };\n const data = await this.publicQuery(body);\n return { username: data.username, available: data.available };\n }\n\n /**\n * Looks up public profiles, optionally with follower totals and a follow summary. Returns one profile per\n * requested subaccount, in the requested order, so callers can correlate positionally. Every non-isolated\n * subaccount resolves, with `username` and `displayName` `null` until a username is claimed. Private Mode\n * does not hide the profile itself, only the account's activity.\n *\n * This is the only profile route, so use it for a single subaccount too. It is unsigned, which means\n * `include.followSummary.viewAs` is an unauthenticated claim.\n *\n * @throws {MobileServerFailureError} With error code `INVALID_PROFILES_REQUEST` if `subaccounts` is empty,\n * holds duplicates, or exceeds `MOBILE_PROFILES_MAX_BATCH_SIZE` (25), or `PROFILE_NOT_FOUND` if any\n * requested subaccount — or the follow summary's `viewAs` — is in the engine-created isolated namespace.\n * One isolated member fails the whole batch rather than being omitted.\n */\n async getProfiles(\n params: GetMobileProfilesParams,\n ): Promise<MobilePublicProfile[]> {\n const body: MobileServerPublicQueryRequest<'profiles'> = {\n type: 'profiles',\n subaccounts: params.subaccounts.map(subaccountToHex),\n include: params.include\n ? mapMobileProfilesIncludeToServer(params.include)\n : undefined,\n };\n const data = await this.publicQuery(body);\n return data.profiles.map(mapMobilePublicProfile);\n }\n\n /**\n * Fetches a page of the accounts that follow the given Profile.\n *\n * Ordering depends on `viewAs`. With it, accounts the Viewer already follows come first, unfamiliar\n * accounts second, and every row carries an `isFollowing`. Without it, the page is ordered by the listed\n * relationship alone and no row carries an `isFollowing`. In both cases the newest listed relationship\n * comes first within a group, with a bytes32 tie-break. The grouping is evaluated per request against the\n * live graph, so following an account from inside the list moves it between groups on the next page —\n * deduplicate by subaccount and do not re-sort locally.\n *\n * @throws {MobileServerFailureError} With error code `PROFILE_NOT_FOUND` if the viewed Profile or `viewAs`\n * is isolated, `INVALID_FOLLOW_CURSOR` if the cursor is malformed or was issued for a different `viewAs`,\n * Profile, or list direction (discard it and restart from the first page), or `INVALID_FOLLOW_LIMIT` if\n * `limit` is outside 1–50.\n */\n async getFollowers(\n params: GetMobileFollowersParams,\n ): Promise<MobileFollowListPage> {\n const body: MobileServerPublicQueryRequest<'followers'> = {\n type: 'followers',\n ...mapMobileFollowListParamsToServer(params),\n };\n const data = await this.publicQuery(body);\n return mapMobileFollowListPage(data);\n }\n\n /**\n * Fetches a page of the accounts the given Profile follows. Ordering, cursor rules, and errors match\n * {@link MobileClient.getFollowers}. When `viewAs` reads its own Following list every row is familiar, so\n * every `isFollowing` is `true`.\n */\n async getFollowing(\n params: GetMobileFollowingParams,\n ): Promise<MobileFollowListPage> {\n const body: MobileServerPublicQueryRequest<'following'> = {\n type: 'following',\n ...mapMobileFollowListParamsToServer(params),\n };\n const data = await this.publicQuery(body);\n return mapMobileFollowListPage(data);\n }\n\n /**\n * Fetches a page of the global trade feed: public perpetual trades, newest first, optionally filtered by a\n * whole-dollar minimum notional (omitted means unfiltered). Trades by subaccounts that have not claimed a\n * username are included with `null` name fields; only private accounts are filtered out. The feed is\n * best-effort rather than authoritative history, and pagination is live (not snapshot), so deduplicate pages\n * by {@link MobileFeedTrade.orderDigest}.\n *\n * @throws {MobileServerFailureError} With error code `INVALID_FEED_FILTER` if `minimumNotional` or\n * `limit` is outside its allowed domain (fix the request; do not retry unchanged), or\n * `INVALID_FEED_CURSOR` if the cursor is malformed or was issued for a different `minimumNotional`\n * (discard the cursor and restart from the first page).\n */\n async getFeed(params: GetMobileFeedParams = {}): Promise<MobileFeedPage> {\n const body: MobileServerPublicQueryRequest<'feed'> = {\n type: 'feed',\n minimum_notional: params.minimumNotional,\n limit: params.limit,\n cursor: params.cursor,\n };\n const data = await this.publicQuery(body);\n return mapMobileFeedPage(data);\n }\n\n /**\n * Fetches chronological For You recommendations with server-side author/thread constraints.\n * Always public, with optional viewAs for relationship state. Preserve the session, viewAs, filters, and limit\n * when paging, including through empty pages with a nextCursor. A 6312 error requires a refresh.\n * @param params - Filters, pagination, optional viewing account, and browser credential; no signing identity.\n * @returns A fixed-session page with its ranking version and new-content watermark.\n * @throws {MobileServerFailureError} On invalid parameters, session mismatch/expiry, or unavailable data.\n */\n async getForYouFeed(\n params: GetMobileForYouFeedParams = {},\n ): Promise<MobileSocialFeedRankedPage> {\n const body: MobileServerPublicQueryRequest<'for_you_feed'> = {\n type: 'for_you_feed',\n market_category: params.marketCategory,\n ...mapMobileSocialFeedListParamsToServer(params),\n ...mapMobileSocialFeedReadParamsToServer(params),\n };\n const data = await this.publicQuery(body);\n return mapMobileSocialFeedRankedPage(data);\n }\n\n /**\n * Fetches chronological content by qualified Top Traders, with official account PnL badges.\n * Always public; neither a wallet nor one-click trading setup is required.\n * @param params - Filters, pagination, optional viewing account, and browser credential.\n * @returns A page with its qualification cohort; an unavailable cohort fails instead of returning an empty ranking.\n * @throws {MobileServerFailureError} On request/session errors or unavailable cohort data.\n */\n async getTopTradersFeed(\n params: GetMobileTopTradersFeedParams = {},\n ): Promise<MobileSocialFeedTopTradersPage> {\n const body: MobileServerPublicQueryRequest<'top_traders_feed'> = {\n type: 'top_traders_feed',\n market_category: params.marketCategory,\n ...mapMobileSocialFeedListParamsToServer(params),\n ...mapMobileSocialFeedReadParamsToServer(params),\n };\n const data = await this.publicQuery(body);\n return mapMobileSocialFeedTopTradersPage(data);\n }\n\n /**\n * Fetches public content by authors followed by viewAs, without a signature. One-way following is sufficient.\n * @param params - Required viewing account on every request, filters, pagination, and browser credential.\n * @returns A chronological Friends page and reading session.\n * @throws {MobileServerFailureError} On invalid viewing account, session errors, or feed query failure.\n */\n async getFriendsFeed(\n params: GetMobileFriendsFeedParams,\n ): Promise<MobileSocialFeedRankedPage> {\n const body: MobileServerPublicQueryRequest<'friends_feed'> = {\n type: 'friends_feed',\n market_category: params.marketCategory,\n ...mapMobileSocialFeedListParamsToServer(params),\n view_as: subaccountToHex(params.viewAs),\n viewer_token: params.viewerToken,\n };\n const data = await this.publicQuery(body);\n return mapMobileSocialFeedRankedPage(data);\n }\n\n /**\n * Fetches an author's content visible to viewAs, including that account's own hidden content.\n * @param params - Target identity, filters, pagination, and optional public viewing account.\n * @returns An author page without main-feed ranking or cohort fields.\n * @throws {MobileServerFailureError} On invalid parameters, session errors, or inaccessible content.\n */\n async getProfileFeed(\n params: GetMobileProfileFeedParams,\n ): Promise<MobileSocialFeedPage> {\n const body: MobileServerPublicQueryRequest<'profile_feed'> = {\n type: 'profile_feed',\n subaccount: subaccountToHex(params.subaccount),\n market_category: params.marketCategory,\n ...mapMobileSocialFeedListParamsToServer(params),\n ...mapMobileSocialFeedReadParamsToServer(params),\n };\n const data = await this.publicQuery(body);\n return mapMobileSocialFeedPage(data);\n }\n\n /**\n * Fetches published content for one market.\n * @param params - Product ID, content/size filters, pagination, and public viewing account.\n * @returns A market page without main-feed ranking fields.\n * @throws {MobileServerFailureError} On an unknown market, session errors, or unavailable data.\n */\n async getMarketFeed(\n params: GetMobileMarketFeedParams,\n ): Promise<MobileSocialFeedPage> {\n const body: MobileServerPublicQueryRequest<'market_feed'> = {\n type: 'market_feed',\n product_id: params.productId,\n ...mapMobileSocialFeedListParamsToServer(params),\n ...mapMobileSocialFeedReadParamsToServer(params),\n };\n const data = await this.publicQuery(body);\n return mapMobileSocialFeedPage(data);\n }\n\n /**\n * Fetches already published content for a position lifecycle. This is not full position history\n * and includes hidden content owned by viewAs under account_view. It does not recreate suppressed activity.\n * @param params - Position UUID, filters, pagination, and public viewing account.\n * @returns A fixed-session position feed page.\n * @throws {MobileServerFailureError} On inaccessible content, session errors, or unavailable data.\n */\n async getPositionFeed(\n params: GetMobilePositionFeedParams,\n ): Promise<MobileSocialFeedPage> {\n const body: MobileServerPublicQueryRequest<'position_feed'> = {\n type: 'position_feed',\n position_id: params.positionId,\n ...mapMobileSocialFeedListParamsToServer(params),\n ...mapMobileSocialFeedReadParamsToServer(params),\n };\n const data = await this.publicQuery(body);\n return mapMobileSocialFeedPage(data);\n }\n\n /**\n * Reads one item visible to viewAs, including that account's own hidden content.\n * Creates an item session directly when sessionId is omitted.\n * @param params - Item UUID, preview limit, and optional existing session/read identity.\n * @returns The complete item and authorized reading session.\n * @throws {MobileServerFailureError} On inaccessible content or session mismatch/expiry.\n */\n async getFeedItem(\n params: GetMobileFeedItemParams,\n ): Promise<MobileSocialFeedItemResponse> {\n const body: MobileServerPublicQueryRequest<'feed_item'> = {\n type: 'feed_item',\n item_id: params.itemId,\n comment_preview_limit: params.commentPreviewLimit,\n session_id: params.sessionId,\n ...mapMobileSocialFeedReadParamsToServer(params),\n };\n const data = await this.publicQuery(body);\n return mapMobileSocialFeedItemResponse(data);\n }\n\n /**\n * Polls authorized visible items and positions without inserting or reordering list members.\n * Increment requestSeq across the entire session, including viewport changes; never reset it for a new viewport.\n * Accept only the current session and viewportRevision's latest requestSeq; discard stale patches and cursors together.\n * Updates currently always return reset=true. Apply current author details, follow state, and badges even if the item version is unchanged.\n * Null patches clear values;\n * omitted fields leave them unchanged. Stop polling off-screen and refresh on error 6312.\n * @param params - Session, visible IDs, update baseline, sequence, and matching read identity.\n * @returns Item/position patches, revoked targets, and a new-content hint.\n * @throws {MobileServerFailureError} On invalid or unauthorized targets, session expiry, or unavailable data.\n */\n async getFeedUpdates(\n params: GetMobileFeedUpdatesParams,\n ): Promise<MobileSocialFeedUpdates> {\n const body: MobileServerPublicQueryRequest<'feed_updates'> = {\n type: 'feed_updates',\n session_id: params.sessionId,\n visible_item_ids: params.visibleItemIds,\n visible_position_ids: params.visiblePositionIds,\n update_cursor: params.updateCursor,\n viewport_revision: params.viewportRevision,\n request_seq: params.requestSeq,\n viewer_token: params.viewerToken,\n };\n const data = await this.publicQuery(body);\n return mapMobileSocialFeedUpdates(data);\n }\n\n /**\n * Fetches the push notification preferences of the wallet that owns the given Expo push token. Unsigned —\n * the token identifies the wallet on its own. Falls back to the backend's defaults if the wallet has never\n * updated its preferences.\n *\n * @throws {MobileServerFailureError} With error code `INVALID_EXPO_TOKEN` if the token is malformed, or is\n * not currently registered to a wallet.\n */\n async getNotificationPreferences(\n params: GetMobileNotificationPreferencesParams,\n ): Promise<MobileNotificationPreferences> {\n const body: MobileServerPublicQueryRequest<'notification_preferences'> = {\n type: 'notification_preferences',\n expo_token: params.expoToken,\n };\n const data = await this.publicQuery(body);\n return mapMobileNotificationPreferences(data.preferences);\n }\n\n /**\n * Resolves the wallet that an Expo push token is currently registered to, along with the redacted metadata\n * of the device that registered it. Unsigned — the token identifies the wallet on its own. Use it to check\n * whether a locally held token is still active and which wallet currently owns it, since registering the\n * same token under another wallet transfers ownership.\n *\n * @throws {MobileServerFailureError} With error code `INVALID_EXPO_TOKEN` if the token is malformed, or is\n * not currently registered to a wallet — including a token that was unregistered. The backend does not\n * distinguish those cases.\n */\n async getRegisteredWallet(\n params: GetMobileRegisteredWalletParams,\n ): Promise<MobileRegisteredWallet> {\n const body: MobileServerPublicQueryRequest<'registered_wallet'> = {\n type: 'registered_wallet',\n expo_token: params.expoToken,\n };\n const data = await this.publicQuery(body);\n return mapMobileRegisteredWallet(data);\n }\n\n /*\n Public executes\n */\n\n /**\n * Unregisters an Expo push token, stopping delivery to that device. Unsigned, so it still works at logout\n * when a wallet signature may no longer be obtainable. Idempotent: unregistering an inactive or unknown\n * well-formed token succeeds.\n *\n * A registration that commits after this call re-activates the token, so stop or await any in-flight\n * {@link MobileClient.registerExpoToken} before unregistering.\n *\n * @throws {MobileServerFailureError} With error code `INVALID_EXPO_TOKEN` if the token is malformed.\n */\n async unregisterExpoToken(\n params: MobileUnregisterExpoTokenParams,\n ): Promise<MobileServerSuccessResponse> {\n const body: MobileServerPublicExecuteRequest<'unregister_expo_token'> = {\n type: 'unregister_expo_token',\n expo_token: params.expoToken,\n };\n return this.publicExecute(body);\n }\n\n /**\n * Replaces the push notification preferences of the wallet that owns the given Expo push token. Possession\n * of an active token is the credential rather than a signature, so anyone holding the token can overwrite\n * that wallet's preferences. The backend requires `schemaVersion` of 1, exactly one entry per known\n * category, and empty `scopes` on every entry.\n *\n * Writes are last-write-wins on commit order rather than ordered by a client nonce, so callers must\n * serialize their own preference writes.\n *\n * @throws {MobileServerFailureError} With error code `INVALID_PREFERENCES` if those rules are violated, or\n * `INVALID_EXPO_TOKEN` if the token is malformed or is not currently registered to a wallet.\n */\n async updateNotificationPreferences(\n params: MobileUpdateNotificationPreferencesParams,\n ): Promise<MobileServerSuccessResponse> {\n const body: MobileServerPublicExecuteRequest<'update_preferences'> = {\n type: 'update_preferences',\n expo_token: params.expoToken,\n preferences: mapMobileNotificationPreferencesToServer(params.preferences),\n };\n return this.publicExecute(body);\n }\n\n /*\n Signed executes\n */\n\n /**\n * Updates the biography, or clears it when the text is whitespace-only.\n *\n * Serialize this with {@link MobileClient.setAvatar}, {@link MobileClient.setUsername} and\n * {@link MobileClient.setPrivateMode} for the same subaccount: all share the identity update nonce.\n *\n * @throws {MobileServerFailureError} With `INVALID_BIO` for exceeding `MOBILE_BIO_MAX_LENGTH` or null\n * characters, `INVALID_IDENTITY_TARGET` for an isolated subaccount, or `STALE_IDENTITY_UPDATE` when a\n * later write has committed (re-read the profile before retrying).\n */\n async setBio(\n params: MobileSetBioParams,\n ): Promise<MobileServerSuccessResponse> {\n const signedRequest = await this.getSignedRequest('set_bio', params, {\n bio: params.bio,\n });\n return this.execute(signedRequest);\n }\n\n /**\n * Creates a short-lived upload grant. The caller uploads an image meeting {@link MobileAvatarUpload}'s requirements;\n * file access and transport remain platform-specific. This does not change the saved avatar.\n *\n * @throws {MobileServerFailureError} With `INVALID_AVATAR` for a zero or oversized upload,\n * `INVALID_IDENTITY_TARGET` for an isolated subaccount, or `SERVICE_UNAVAILABLE` when storage is unavailable.\n */\n async createAvatarUpload(\n params: MobileCreateAvatarUploadParams,\n ): Promise<MobileAvatarUpload> {\n const signedRequest = await this.getSignedRequest(\n 'create_avatar_upload',\n params,\n { content_length: params.contentLength },\n );\n const data = await this.execute(signedRequest);\n return mapMobileAvatarUpload(data);\n }\n\n /**\n * Publishes a preset/staged upload, or clears the saved avatar when avatar is null.\n * Uploaded JPEG/PNG images must be square, at most 4096 × 4096 pixels, and within\n * `MOBILE_AVATAR_MAX_UPLOAD_BYTES`. A successful PUT can still fail this publication check.\n *\n * Serialize identity writes for the same subaccount; see {@link MobileClient.setBio}.\n *\n * @throws {MobileServerFailureError} With `INVALID_AVATAR` for an invalid preset, staging key, or image,\n * `INVALID_IDENTITY_TARGET` for an isolated subaccount, `SERVICE_UNAVAILABLE` when storage is unavailable,\n * or `STALE_IDENTITY_UPDATE` when a later write has committed (re-read the profile before retrying).\n */\n async setAvatar(\n params: MobileSetAvatarParams,\n ): Promise<MobileServerSuccessResponse> {\n const signedRequest = await this.getSignedRequest('set_avatar', params, {\n avatar: mapMobileAvatarSelectionToServer(params.avatar),\n });\n return this.execute(signedRequest);\n }\n\n /**\n * Sets a subaccount's username, derived from the given display name. Upserts: the same call claims a first\n * username and renames an existing one, so callers never need to read the current identity first.\n *\n * Serialize identity writes for the same subaccount; see {@link MobileClient.setBio}.\n *\n * @throws {MobileServerFailureError} With error code `INVALID_DISPLAY_NAME` if the display name violates\n * `MOBILE_DISPLAY_NAME_PATTERN`, `USERNAME_UNAVAILABLE` if the derived username is reserved or already\n * taken by another subaccount, `INVALID_IDENTITY_TARGET` if the sender is in the engine-created isolated\n * namespace, or `STALE_IDENTITY_UPDATE` if another identity write for this subaccount committed with a\n * later nonce (re-read the identity before retrying).\n */\n async setUsername(\n params: MobileSetUsernameParams,\n ): Promise<MobileServerSuccessResponse> {\n const signedRequest = await this.getSignedRequest('set_username', params, {\n display_name: params.displayName,\n });\n return this.execute(signedRequest);\n }\n\n /**\n * Sets whether a subaccount's profile is private.\n * Serialize identity writes for the same subaccount; see {@link MobileClient.setBio}.\n */\n async setPrivateMode(\n params: MobileSetPrivateModeParams,\n ): Promise<MobileServerSuccessResponse> {\n const signedRequest = await this.getSignedRequest(\n 'set_private_mode',\n params,\n { private_mode: params.privateMode },\n );\n return this.execute(signedRequest);\n }\n\n /**\n * Registers an Expo push token for the wallet, transferring active ownership of the token if another\n * wallet had registered it. Idempotent per `(wallet, token)`.\n *\n * @throws {MobileServerFailureError} With error code `INVALID_EXPO_TOKEN` if the token is not a valid Expo\n * push token, or `INVALID_DEVICE_METADATA` if `locale` (max 35 chars) or `appVersion` (max 64 chars) is\n * too long.\n */\n async registerExpoToken(\n params: MobileRegisterExpoTokenParams,\n ): Promise<MobileServerSuccessResponse> {\n const signedRequest = await this.getSignedRequest(\n 'register_expo_token',\n params,\n {\n expo_token: params.expoToken,\n platform: params.platform,\n locale: params.locale ?? null,\n app_version: params.appVersion ?? null,\n },\n );\n return this.execute(signedRequest);\n }\n\n /**\n * Sets whether the signing subaccount follows a Profile. Both directions are idempotent: following again\n * keeps the original relationship creation time, so it does not move the account in recency order, and\n * unfollowing a relationship that does not exist succeeds with `isFollowing: false`. Unfollowing deletes\n * the relationship rather than deactivating it, so a later follow gets a new creation time and moves the\n * account to the front of recency order.\n *\n * Only `isFollowing: true` is checked against the canonical Query DB subaccount index, so unfollowing still\n * works while that index lags.\n *\n * @throws {MobileServerFailureError} With error code `INVALID_FOLLOW_TARGET` if the target is the sender or\n * either party is isolated, `FOLLOWER_NOT_ELIGIBLE` if the sender is not yet in the canonical Query DB\n * subaccount index, or `FOLLOWING_NOT_FOUND` if the target is not. Both index errors are transient for an\n * account that is being recorded, so they are retryable after catch-up — unlike `INVALID_FOLLOW_TARGET`.\n */\n async setFollow(\n params: MobileSetFollowParams,\n ): Promise<MobileFollowMutationResult> {\n const signedRequest = await this.getSignedRequest('set_follow', params, {\n subaccount: subaccountToHex(params.target),\n is_following: params.isFollowing,\n });\n const data = await this.execute(signedRequest);\n return mapMobileFollowMutationResult(data);\n }\n\n /*\n Base Fns\n */\n\n // Returns the request narrowed to `type` so `execute` can infer its response from the request it is given,\n // instead of being told the type a second time at the call site.\n protected async getSignedRequest<T extends MobileSignedInner['type']>(\n type: T,\n params: MobileSignedRequestParams,\n innerParams: MobileSignedInnerParams<T>,\n ): Promise<MobileSignedRequest<MobileSignedInnerByType<T>>> {\n // Use the linked signer if provided, otherwise use the default signer provided to the client\n const walletClient =\n this.opts.linkedSignerWalletClient ?? this.opts.walletClient;\n\n if (walletClient == null) {\n throw new WalletNotProvidedError();\n }\n\n const inner = {\n type,\n ...innerParams,\n } as unknown as MobileSignedInnerByType<T>;\n return buildSignedMobileRequest({ ...params, walletClient, inner });\n }\n\n // Spelled out as an intersection rather than `MobileServerPublicQueryRequest<T>`: the latter is an indexed\n // access on a mapped type, which is not an inference site, so `T` would always widen to the full union.\n protected async publicQuery<T extends MobileServerPublicQueryRequestType>(\n body: { type: T } & MobileServerPublicQueryRequestByType[T],\n ): Promise<MobileServerPublicQuerySuccessResponse<T>> {\n const response = await this.axiosInstance.post<unknown>(\n `${this.opts.url}/public_query`,\n body,\n );\n\n this.checkResponseStatus(response);\n this.checkServerStatus(response);\n\n // checkServerStatus throws on failure responses so the cast to the success response is acceptable here\n return response.data as MobileServerPublicQuerySuccessResponse<T>;\n }\n\n protected async publicExecute(\n body: MobileServerPublicExecuteRequest,\n ): Promise<MobileServerSuccessResponse> {\n const response = await this.axiosInstance.post<MobileServerExecuteResult>(\n `${this.opts.url}/public_execute`,\n body,\n );\n\n this.checkResponseStatus(response);\n this.checkServerStatus(response);\n\n // checkServerStatus catches the failure result and throws the error, so the cast to the success response is acceptable here\n return response.data as MobileServerSuccessResponse;\n }\n\n // `T` is inferred from the body's `type` rather than declared by the caller, for the same reason\n // `publicQuery` spells its body out as an intersection: an indexed access is not an inference site.\n protected async execute<T extends MobileServerExecuteRequestType>(\n body: MobileSignedRequest & { type: T },\n ): Promise<MobileServerExecuteSuccessResponse<T>> {\n const response = await this.axiosInstance.post<MobileServerExecuteResult>(\n `${this.opts.url}/execute`,\n body,\n );\n\n this.checkResponseStatus(response);\n this.checkServerStatus(response);\n\n // checkServerStatus catches the failure result and throws the error, so the cast to the success response is acceptable here\n return response.data as MobileServerExecuteSuccessResponse<T>;\n }\n\n /**\n * Validates the HTTP status before interpreting the body. Unlike the engine, the mobile backend returns\n * failure envelopes with non-2xx statuses (e.g. 404 for `PROFILE_NOT_FOUND`), so a non-2xx response with a\n * failure envelope still throws the typed error; anything else is a transport-level error.\n */\n private checkResponseStatus(response: AxiosResponse<unknown>) {\n if (response.status >= 200 && response.status < 300) {\n return;\n }\n if (isMobileServerFailureResponse(response.data)) {\n throw new MobileServerFailureError(response.data, response.status);\n }\n throw new Error(\n `Unexpected response from mobile service: ${response.status} ${response.statusText}. Data: ${JSON.stringify(response.data)}`,\n );\n }\n\n private checkServerStatus(response: AxiosResponse<unknown>) {\n const { data } = response;\n\n if (isMobileServerFailureResponse(data)) {\n throw new MobileServerFailureError(data, response.status);\n }\n if (!isMobileServerSuccessResponse(data)) {\n throw new Error(\n `Unexpected response from mobile service: missing success envelope. Data: ${JSON.stringify(data)}`,\n );\n }\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA4HA,IAAa,eAAb,MAA0B;CAIxB,YAAY,MAAwB;EAClC,KAAK,OAAO;EACZ,KAAK,gBAAgB,MAAA,QAAM,OAAO;GAChC,iBAAiB;GAEjB,sBAAsB;GACtB,UAAA,GAAA,eAAA,0BAAkC,KAAK,UAAU;EACnD,CAAC;CACH;;;;;;CAOA,gBACE,0BACA;EACA,KAAK,KAAK,2BAA2B,4BAA4B,KAAA;CACnE;;;;;;CAWA,MAAM,mBAAkD;EAKtD,QAAO,MADY,KAAK,YAAY,EAFlC,MA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AA,yBAAyB,MAAM,SAAS,MAAM;EAE1D,IAAI,CAACC,mCAAAA,8BAA8B,IAAI,GACrC,MAAM,IAAI,MACR,4EAA4E,KAAK,UAAU,IAAI,GACjG;CAEJ;AACF"}
|
package/dist/MobileClient.cjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
const require_MobileClient = require("./MobileClient-
|
|
2
|
+
const require_MobileClient = require("./MobileClient-DjNpN7Dw.cjs");
|
|
3
3
|
require("./signing/index.cjs");
|
|
4
4
|
exports.MobileClient = require_MobileClient.MobileClient;
|
package/dist/MobileClient.d.cts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { a as MobileSignedRequest, i as MobileSignedInnerParams, n as MobileSignedInner, r as MobileSignedInnerByType } from "./types-
|
|
3
|
-
import { o as MobileServerPublicQueryRequestByType, s as MobileServerPublicQueryRequestType, t as MobileServerExecuteRequestType } from "./serverRequestTypes-
|
|
4
|
-
import { n as MobileServerSuccessResponse } from "./serverBaseTypes-
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
1
|
+
import { B as MobileSetUsernameParams, E as MobileFollowMutationResult, F as MobileRegisteredWallet, I as MobileSetAvatarParams, L as MobileSetBioParams, N as MobilePublicProfile, P as MobileRegisterExpoTokenParams, Q as MobileSocialFeedItemResponse, R as MobileSetFollowParams, S as MobileFeedPage, T as MobileFollowListPage, V as MobileSignedRequestParams, _ as MobileAvatarPreset, _t as MobileUsernameAvailability, a as GetMobileFollowersParams, at as MobileSocialFeedRankedPage, b as MobileCreateAvatarUploadParams, c as GetMobileFriendsFeedParams, ct as MobileSocialFeedTopTradersPage, d as GetMobilePositionFeedParams, f as GetMobileProfileFeedParams, g as GetMobileUsernameAvailabilityParams, gt as MobileUpdateNotificationPreferencesParams, h as GetMobileTopTradersFeedParams, ht as MobileUnregisterExpoTokenParams, j as MobileNotificationPreferences, l as GetMobileMarketFeedParams, m as GetMobileRegisteredWalletParams, n as GetMobileFeedParams, o as GetMobileFollowingParams, p as GetMobileProfilesParams, pt as MobileSocialFeedUpdates, r as GetMobileFeedUpdatesParams, s as GetMobileForYouFeedParams, t as GetMobileFeedItemParams, tt as MobileSocialFeedPage, u as GetMobileNotificationPreferencesParams, y as MobileAvatarUpload, z as MobileSetPrivateModeParams } from "./clientTypes-DnPE1zZO.cjs";
|
|
2
|
+
import { a as MobileSignedRequest, i as MobileSignedInnerParams, n as MobileSignedInner, r as MobileSignedInnerByType } from "./types-l47aSWtA.cjs";
|
|
3
|
+
import { o as MobileServerPublicQueryRequestByType, s as MobileServerPublicQueryRequestType, t as MobileServerExecuteRequestType } from "./serverRequestTypes-DGGqQMK3.cjs";
|
|
4
|
+
import { n as MobileServerSuccessResponse } from "./serverBaseTypes-CcWT_ZBe.cjs";
|
|
5
|
+
import { a as MobileServerExecuteSuccessResponse, s as MobileServerPublicExecuteRequest } from "./serverExecuteTypes-CgjzwBaA.cjs";
|
|
6
|
+
import { c as MobileServerPublicQuerySuccessResponse } from "./serverQueryTypes-H_mI6fPl.cjs";
|
|
7
7
|
import { WalletClientWithAccount } from "@nadohq/shared";
|
|
8
8
|
import { AxiosInstance } from "axios";
|
|
9
9
|
|
|
@@ -30,9 +30,9 @@ interface MobileClientOpts {
|
|
|
30
30
|
clientType?: string;
|
|
31
31
|
}
|
|
32
32
|
/**
|
|
33
|
-
* Client for the Nado mobile service API: usernames, public profile lookups, the global
|
|
34
|
-
* session-based social feeds, the follower/following graph, privacy settings, and push
|
|
35
|
-
* device/preference management.
|
|
33
|
+
* Client for the Nado mobile service API: usernames, bios, avatars, public profile lookups, the global
|
|
34
|
+
* trade feed, session-based social feeds, the follower/following graph, privacy settings, and push
|
|
35
|
+
* notification device/preference management.
|
|
36
36
|
*/
|
|
37
37
|
declare class MobileClient {
|
|
38
38
|
readonly opts: MobileClientOpts;
|
|
@@ -44,6 +44,12 @@ declare class MobileClient {
|
|
|
44
44
|
* @param linkedSignerWalletClient The linkedSigner to use for all signatures. Set to null to revert to the chain signer
|
|
45
45
|
*/
|
|
46
46
|
setLinkedSigner(linkedSignerWalletClient: WalletClientWithAccount | null): void;
|
|
47
|
+
/**
|
|
48
|
+
* Returns the current server-owned avatar catalogue in display order.
|
|
49
|
+
*
|
|
50
|
+
* @throws {MobileServerFailureError} With `SERVICE_UNAVAILABLE` when avatar storage is not configured.
|
|
51
|
+
*/
|
|
52
|
+
getAvatarPresets(): Promise<MobileAvatarPreset[]>;
|
|
47
53
|
/**
|
|
48
54
|
* Checks whether a username derived from the given display name is available to claim.
|
|
49
55
|
*/
|
|
@@ -208,10 +214,43 @@ declare class MobileClient {
|
|
|
208
214
|
* `INVALID_EXPO_TOKEN` if the token is malformed or is not currently registered to a wallet.
|
|
209
215
|
*/
|
|
210
216
|
updateNotificationPreferences(params: MobileUpdateNotificationPreferencesParams): Promise<MobileServerSuccessResponse>;
|
|
217
|
+
/**
|
|
218
|
+
* Updates the biography, or clears it when the text is whitespace-only.
|
|
219
|
+
*
|
|
220
|
+
* Serialize this with {@link MobileClient.setAvatar}, {@link MobileClient.setUsername} and
|
|
221
|
+
* {@link MobileClient.setPrivateMode} for the same subaccount: all share the identity update nonce.
|
|
222
|
+
*
|
|
223
|
+
* @throws {MobileServerFailureError} With `INVALID_BIO` for exceeding `MOBILE_BIO_MAX_LENGTH` or null
|
|
224
|
+
* characters, `INVALID_IDENTITY_TARGET` for an isolated subaccount, or `STALE_IDENTITY_UPDATE` when a
|
|
225
|
+
* later write has committed (re-read the profile before retrying).
|
|
226
|
+
*/
|
|
227
|
+
setBio(params: MobileSetBioParams): Promise<MobileServerSuccessResponse>;
|
|
228
|
+
/**
|
|
229
|
+
* Creates a short-lived upload grant. The caller uploads an image meeting {@link MobileAvatarUpload}'s requirements;
|
|
230
|
+
* file access and transport remain platform-specific. This does not change the saved avatar.
|
|
231
|
+
*
|
|
232
|
+
* @throws {MobileServerFailureError} With `INVALID_AVATAR` for a zero or oversized upload,
|
|
233
|
+
* `INVALID_IDENTITY_TARGET` for an isolated subaccount, or `SERVICE_UNAVAILABLE` when storage is unavailable.
|
|
234
|
+
*/
|
|
235
|
+
createAvatarUpload(params: MobileCreateAvatarUploadParams): Promise<MobileAvatarUpload>;
|
|
236
|
+
/**
|
|
237
|
+
* Publishes a preset/staged upload, or clears the saved avatar when avatar is null.
|
|
238
|
+
* Uploaded JPEG/PNG images must be square, at most 4096 × 4096 pixels, and within
|
|
239
|
+
* `MOBILE_AVATAR_MAX_UPLOAD_BYTES`. A successful PUT can still fail this publication check.
|
|
240
|
+
*
|
|
241
|
+
* Serialize identity writes for the same subaccount; see {@link MobileClient.setBio}.
|
|
242
|
+
*
|
|
243
|
+
* @throws {MobileServerFailureError} With `INVALID_AVATAR` for an invalid preset, staging key, or image,
|
|
244
|
+
* `INVALID_IDENTITY_TARGET` for an isolated subaccount, `SERVICE_UNAVAILABLE` when storage is unavailable,
|
|
245
|
+
* or `STALE_IDENTITY_UPDATE` when a later write has committed (re-read the profile before retrying).
|
|
246
|
+
*/
|
|
247
|
+
setAvatar(params: MobileSetAvatarParams): Promise<MobileServerSuccessResponse>;
|
|
211
248
|
/**
|
|
212
249
|
* Sets a subaccount's username, derived from the given display name. Upserts: the same call claims a first
|
|
213
250
|
* username and renames an existing one, so callers never need to read the current identity first.
|
|
214
251
|
*
|
|
252
|
+
* Serialize identity writes for the same subaccount; see {@link MobileClient.setBio}.
|
|
253
|
+
*
|
|
215
254
|
* @throws {MobileServerFailureError} With error code `INVALID_DISPLAY_NAME` if the display name violates
|
|
216
255
|
* `MOBILE_DISPLAY_NAME_PATTERN`, `USERNAME_UNAVAILABLE` if the derived username is reserved or already
|
|
217
256
|
* taken by another subaccount, `INVALID_IDENTITY_TARGET` if the sender is in the engine-created isolated
|
|
@@ -221,6 +260,7 @@ declare class MobileClient {
|
|
|
221
260
|
setUsername(params: MobileSetUsernameParams): Promise<MobileServerSuccessResponse>;
|
|
222
261
|
/**
|
|
223
262
|
* Sets whether a subaccount's profile is private.
|
|
263
|
+
* Serialize identity writes for the same subaccount; see {@link MobileClient.setBio}.
|
|
224
264
|
*/
|
|
225
265
|
setPrivateMode(params: MobileSetPrivateModeParams): Promise<MobileServerSuccessResponse>;
|
|
226
266
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MobileClient.d.cts","names":[],"sources":["../src/src/MobileClient.ts"],"mappings":";;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"MobileClient.d.cts","names":[],"sources":["../src/src/MobileClient.ts"],"mappings":";;;;;;;;;;;;;UAoGiB,gBAAA;EAAgB;;;EAI/B,GAAA;EAIA;;;EAAA,YAAA,GAAe,uBAAA;EAQf;;AAAU;EAJV,wBAAA,GAA2B,uBAAuB;EAY3B;;;EARvB,UAAA;AAAA;;;;;;cAQW,YAAA;EAAA,SACF,IAAA,EAAM,gBAAA;EAAA,SACN,aAAA,EAAe,aAAA;cAEZ,IAAA,EAAM,gBAAA;EAgGR;;;;;EAjFH,eAAA,CACL,wBAAA,EAA0B,uBAAA;EAsHN;;;;;EAxGhB,gBAAA,CAAA,GAAoB,OAAA,CAAQ,kBAAA;EAgJxB;;;EArIJ,uBAAA,CACJ,MAAA,EAAQ,mCAAA,GACP,OAAA,CAAQ,0BAAA;EAuJA;;;;;;;;;;;;;;EAhIL,WAAA,CACJ,MAAA,EAAQ,uBAAA,GACP,OAAA,CAAQ,mBAAA;EAuOA;;;;;;;;;;;;;;;EA5ML,YAAA,CACJ,MAAA,EAAQ,wBAAA,GACP,OAAA,CAAQ,oBAAA;EAgUR;;;;;EAlTG,YAAA,CACJ,MAAA,EAAQ,wBAAA,GACP,OAAA,CAAQ,oBAAA;EAuVR;;;;;;;;;;;;EAlUG,OAAA,CAAQ,MAAA,GAAQ,mBAAA,GAA2B,OAAA,CAAQ,cAAA;EAqad;;;;;;;;EAlZrC,aAAA,CACJ,MAAA,GAAQ,yBAAA,GACP,OAAA,CAAQ,0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EAgCA;;;;EArBL,cAAA,CACJ,MAAA,EAAQ,0BAAA,GACP,OAAA,CAAQ,2BAAA;EAkDA;;;;;;;;EAjCL,iBAAA,CACJ,MAAA,EAAQ,6BAAA,GACP,OAAA,CAAQ,2BAAA;EAiD4B;;;;;;;;;;;;;;;EApBjC,SAAA,CACJ,MAAA,EAAQ,qBAAA,GACP,OAAA,CAAQ,0BAAA;EAAA,UAeK,gBAAA,WAA2B,iBAAA,SAAA,CACzC,IAAA,EAAM,CAAA,EACN,MAAA,EAAQ,yBAAA,EACR,WAAA,EAAa,uBAAA,CAAwB,CAAA,IACpC,OAAA,CAAQ,mBAAA,CAAoB,uBAAA,CAAwB,CAAA;EAAA,UAkBvC,WAAA,WAAsB,kCAAA,CAAA,CACpC,IAAA;IAAQ,IAAA,EAAM,CAAA;EAAA,IAAM,oCAAA,CAAqC,CAAA,IACxD,OAAA,CAAQ,sCAAA,CAAuC,CAAA;EAAA,UAalC,aAAA,CACd,IAAA,EAAM,gCAAA,GACL,OAAA,CAAQ,2BAAA;EAAA,UAeK,OAAA,WAAkB,8BAAA,CAAA,CAChC,IAAA,EAAM,mBAAA;IAAwB,IAAA,EAAM,CAAA;EAAA,IACnC,OAAA,CAAQ,kCAAA,CAAmC,CAAA;EAFZ;;;;;EAAA,QAoB1B,mBAAA;EAAA,QAYA,iBAAA;AAAA"}
|
package/dist/MobileClient.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { a as MobileSignedRequest, i as MobileSignedInnerParams, n as MobileSignedInner, r as MobileSignedInnerByType } from "./types-
|
|
3
|
-
import { o as MobileServerPublicQueryRequestByType, s as MobileServerPublicQueryRequestType, t as MobileServerExecuteRequestType } from "./serverRequestTypes-
|
|
4
|
-
import { n as MobileServerSuccessResponse } from "./serverBaseTypes-
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
1
|
+
import { B as MobileSetUsernameParams, E as MobileFollowMutationResult, F as MobileRegisteredWallet, I as MobileSetAvatarParams, L as MobileSetBioParams, N as MobilePublicProfile, P as MobileRegisterExpoTokenParams, Q as MobileSocialFeedItemResponse, R as MobileSetFollowParams, S as MobileFeedPage, T as MobileFollowListPage, V as MobileSignedRequestParams, _ as MobileAvatarPreset, _t as MobileUsernameAvailability, a as GetMobileFollowersParams, at as MobileSocialFeedRankedPage, b as MobileCreateAvatarUploadParams, c as GetMobileFriendsFeedParams, ct as MobileSocialFeedTopTradersPage, d as GetMobilePositionFeedParams, f as GetMobileProfileFeedParams, g as GetMobileUsernameAvailabilityParams, gt as MobileUpdateNotificationPreferencesParams, h as GetMobileTopTradersFeedParams, ht as MobileUnregisterExpoTokenParams, j as MobileNotificationPreferences, l as GetMobileMarketFeedParams, m as GetMobileRegisteredWalletParams, n as GetMobileFeedParams, o as GetMobileFollowingParams, p as GetMobileProfilesParams, pt as MobileSocialFeedUpdates, r as GetMobileFeedUpdatesParams, s as GetMobileForYouFeedParams, t as GetMobileFeedItemParams, tt as MobileSocialFeedPage, u as GetMobileNotificationPreferencesParams, y as MobileAvatarUpload, z as MobileSetPrivateModeParams } from "./clientTypes-ws9CDHw4.js";
|
|
2
|
+
import { a as MobileSignedRequest, i as MobileSignedInnerParams, n as MobileSignedInner, r as MobileSignedInnerByType } from "./types-B021odcS.js";
|
|
3
|
+
import { o as MobileServerPublicQueryRequestByType, s as MobileServerPublicQueryRequestType, t as MobileServerExecuteRequestType } from "./serverRequestTypes-BY0f5woc.js";
|
|
4
|
+
import { n as MobileServerSuccessResponse } from "./serverBaseTypes-CWBdZomv.js";
|
|
5
|
+
import { a as MobileServerExecuteSuccessResponse, s as MobileServerPublicExecuteRequest } from "./serverExecuteTypes-jyr5aO5q.js";
|
|
6
|
+
import { c as MobileServerPublicQuerySuccessResponse } from "./serverQueryTypes-DPRP61yA.js";
|
|
7
7
|
import { WalletClientWithAccount } from "@nadohq/shared";
|
|
8
8
|
import { AxiosInstance } from "axios";
|
|
9
9
|
|
|
@@ -30,9 +30,9 @@ interface MobileClientOpts {
|
|
|
30
30
|
clientType?: string;
|
|
31
31
|
}
|
|
32
32
|
/**
|
|
33
|
-
* Client for the Nado mobile service API: usernames, public profile lookups, the global
|
|
34
|
-
* session-based social feeds, the follower/following graph, privacy settings, and push
|
|
35
|
-
* device/preference management.
|
|
33
|
+
* Client for the Nado mobile service API: usernames, bios, avatars, public profile lookups, the global
|
|
34
|
+
* trade feed, session-based social feeds, the follower/following graph, privacy settings, and push
|
|
35
|
+
* notification device/preference management.
|
|
36
36
|
*/
|
|
37
37
|
declare class MobileClient {
|
|
38
38
|
readonly opts: MobileClientOpts;
|
|
@@ -44,6 +44,12 @@ declare class MobileClient {
|
|
|
44
44
|
* @param linkedSignerWalletClient The linkedSigner to use for all signatures. Set to null to revert to the chain signer
|
|
45
45
|
*/
|
|
46
46
|
setLinkedSigner(linkedSignerWalletClient: WalletClientWithAccount | null): void;
|
|
47
|
+
/**
|
|
48
|
+
* Returns the current server-owned avatar catalogue in display order.
|
|
49
|
+
*
|
|
50
|
+
* @throws {MobileServerFailureError} With `SERVICE_UNAVAILABLE` when avatar storage is not configured.
|
|
51
|
+
*/
|
|
52
|
+
getAvatarPresets(): Promise<MobileAvatarPreset[]>;
|
|
47
53
|
/**
|
|
48
54
|
* Checks whether a username derived from the given display name is available to claim.
|
|
49
55
|
*/
|
|
@@ -208,10 +214,43 @@ declare class MobileClient {
|
|
|
208
214
|
* `INVALID_EXPO_TOKEN` if the token is malformed or is not currently registered to a wallet.
|
|
209
215
|
*/
|
|
210
216
|
updateNotificationPreferences(params: MobileUpdateNotificationPreferencesParams): Promise<MobileServerSuccessResponse>;
|
|
217
|
+
/**
|
|
218
|
+
* Updates the biography, or clears it when the text is whitespace-only.
|
|
219
|
+
*
|
|
220
|
+
* Serialize this with {@link MobileClient.setAvatar}, {@link MobileClient.setUsername} and
|
|
221
|
+
* {@link MobileClient.setPrivateMode} for the same subaccount: all share the identity update nonce.
|
|
222
|
+
*
|
|
223
|
+
* @throws {MobileServerFailureError} With `INVALID_BIO` for exceeding `MOBILE_BIO_MAX_LENGTH` or null
|
|
224
|
+
* characters, `INVALID_IDENTITY_TARGET` for an isolated subaccount, or `STALE_IDENTITY_UPDATE` when a
|
|
225
|
+
* later write has committed (re-read the profile before retrying).
|
|
226
|
+
*/
|
|
227
|
+
setBio(params: MobileSetBioParams): Promise<MobileServerSuccessResponse>;
|
|
228
|
+
/**
|
|
229
|
+
* Creates a short-lived upload grant. The caller uploads an image meeting {@link MobileAvatarUpload}'s requirements;
|
|
230
|
+
* file access and transport remain platform-specific. This does not change the saved avatar.
|
|
231
|
+
*
|
|
232
|
+
* @throws {MobileServerFailureError} With `INVALID_AVATAR` for a zero or oversized upload,
|
|
233
|
+
* `INVALID_IDENTITY_TARGET` for an isolated subaccount, or `SERVICE_UNAVAILABLE` when storage is unavailable.
|
|
234
|
+
*/
|
|
235
|
+
createAvatarUpload(params: MobileCreateAvatarUploadParams): Promise<MobileAvatarUpload>;
|
|
236
|
+
/**
|
|
237
|
+
* Publishes a preset/staged upload, or clears the saved avatar when avatar is null.
|
|
238
|
+
* Uploaded JPEG/PNG images must be square, at most 4096 × 4096 pixels, and within
|
|
239
|
+
* `MOBILE_AVATAR_MAX_UPLOAD_BYTES`. A successful PUT can still fail this publication check.
|
|
240
|
+
*
|
|
241
|
+
* Serialize identity writes for the same subaccount; see {@link MobileClient.setBio}.
|
|
242
|
+
*
|
|
243
|
+
* @throws {MobileServerFailureError} With `INVALID_AVATAR` for an invalid preset, staging key, or image,
|
|
244
|
+
* `INVALID_IDENTITY_TARGET` for an isolated subaccount, `SERVICE_UNAVAILABLE` when storage is unavailable,
|
|
245
|
+
* or `STALE_IDENTITY_UPDATE` when a later write has committed (re-read the profile before retrying).
|
|
246
|
+
*/
|
|
247
|
+
setAvatar(params: MobileSetAvatarParams): Promise<MobileServerSuccessResponse>;
|
|
211
248
|
/**
|
|
212
249
|
* Sets a subaccount's username, derived from the given display name. Upserts: the same call claims a first
|
|
213
250
|
* username and renames an existing one, so callers never need to read the current identity first.
|
|
214
251
|
*
|
|
252
|
+
* Serialize identity writes for the same subaccount; see {@link MobileClient.setBio}.
|
|
253
|
+
*
|
|
215
254
|
* @throws {MobileServerFailureError} With error code `INVALID_DISPLAY_NAME` if the display name violates
|
|
216
255
|
* `MOBILE_DISPLAY_NAME_PATTERN`, `USERNAME_UNAVAILABLE` if the derived username is reserved or already
|
|
217
256
|
* taken by another subaccount, `INVALID_IDENTITY_TARGET` if the sender is in the engine-created isolated
|
|
@@ -221,6 +260,7 @@ declare class MobileClient {
|
|
|
221
260
|
setUsername(params: MobileSetUsernameParams): Promise<MobileServerSuccessResponse>;
|
|
222
261
|
/**
|
|
223
262
|
* Sets whether a subaccount's profile is private.
|
|
263
|
+
* Serialize identity writes for the same subaccount; see {@link MobileClient.setBio}.
|
|
224
264
|
*/
|
|
225
265
|
setPrivateMode(params: MobileSetPrivateModeParams): Promise<MobileServerSuccessResponse>;
|
|
226
266
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MobileClient.d.ts","names":[],"sources":["../src/src/MobileClient.ts"],"mappings":";;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"MobileClient.d.ts","names":[],"sources":["../src/src/MobileClient.ts"],"mappings":";;;;;;;;;;;;;UAoGiB,gBAAA;EAAgB;;;EAI/B,GAAA;EAIA;;;EAAA,YAAA,GAAe,uBAAA;EAQf;;AAAU;EAJV,wBAAA,GAA2B,uBAAuB;EAY3B;;;EARvB,UAAA;AAAA;;;;;;cAQW,YAAA;EAAA,SACF,IAAA,EAAM,gBAAA;EAAA,SACN,aAAA,EAAe,aAAA;cAEZ,IAAA,EAAM,gBAAA;EAgGR;;;;;EAjFH,eAAA,CACL,wBAAA,EAA0B,uBAAA;EAsHN;;;;;EAxGhB,gBAAA,CAAA,GAAoB,OAAA,CAAQ,kBAAA;EAgJxB;;;EArIJ,uBAAA,CACJ,MAAA,EAAQ,mCAAA,GACP,OAAA,CAAQ,0BA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;EAAA,QAYA,iBAAA;AAAA"}
|
package/dist/MobileClient.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { mapMobileFeedPage, mapMobileFollowListPage, mapMobileFollowListParamsToServer, mapMobileFollowMutationResult, mapMobileNotificationPreferences, mapMobileNotificationPreferencesToServer, mapMobileProfilesIncludeToServer, mapMobilePublicProfile, mapMobileRegisteredWallet, mapMobileSocialFeedItemResponse, mapMobileSocialFeedListParamsToServer, mapMobileSocialFeedPage, mapMobileSocialFeedRankedPage, mapMobileSocialFeedReadParamsToServer, mapMobileSocialFeedTopTradersPage, mapMobileSocialFeedUpdates } from "./dataMappers.js";
|
|
1
|
+
import { mapMobileAvatarPreset, mapMobileAvatarSelectionToServer, mapMobileAvatarUpload, mapMobileFeedPage, mapMobileFollowListPage, mapMobileFollowListParamsToServer, mapMobileFollowMutationResult, mapMobileNotificationPreferences, mapMobileNotificationPreferencesToServer, mapMobileProfilesIncludeToServer, mapMobilePublicProfile, mapMobileRegisteredWallet, mapMobileSocialFeedItemResponse, mapMobileSocialFeedListParamsToServer, mapMobileSocialFeedPage, mapMobileSocialFeedRankedPage, mapMobileSocialFeedReadParamsToServer, mapMobileSocialFeedTopTradersPage, mapMobileSocialFeedUpdates } from "./dataMappers.js";
|
|
2
2
|
import { buildSignedMobileRequest } from "./signing/buildSignedMobileRequest.js";
|
|
3
3
|
import "./signing/index.js";
|
|
4
4
|
import { MobileServerFailureError } from "./types/MobileServerFailureError.js";
|
|
@@ -7,9 +7,9 @@ import { WalletNotProvidedError, getNadoClientTypeHeaders, subaccountToHex } fro
|
|
|
7
7
|
import axios from "axios";
|
|
8
8
|
//#region src/MobileClient.ts
|
|
9
9
|
/**
|
|
10
|
-
* Client for the Nado mobile service API: usernames, public profile lookups, the global
|
|
11
|
-
* session-based social feeds, the follower/following graph, privacy settings, and push
|
|
12
|
-
* device/preference management.
|
|
10
|
+
* Client for the Nado mobile service API: usernames, bios, avatars, public profile lookups, the global
|
|
11
|
+
* trade feed, session-based social feeds, the follower/following graph, privacy settings, and push
|
|
12
|
+
* notification device/preference management.
|
|
13
13
|
*/
|
|
14
14
|
var MobileClient = class {
|
|
15
15
|
constructor(opts) {
|
|
@@ -29,6 +29,14 @@ var MobileClient = class {
|
|
|
29
29
|
this.opts.linkedSignerWalletClient = linkedSignerWalletClient ?? void 0;
|
|
30
30
|
}
|
|
31
31
|
/**
|
|
32
|
+
* Returns the current server-owned avatar catalogue in display order.
|
|
33
|
+
*
|
|
34
|
+
* @throws {MobileServerFailureError} With `SERVICE_UNAVAILABLE` when avatar storage is not configured.
|
|
35
|
+
*/
|
|
36
|
+
async getAvatarPresets() {
|
|
37
|
+
return (await this.publicQuery({ type: "avatar_presets" })).presets.map(mapMobileAvatarPreset);
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
32
40
|
* Checks whether a username derived from the given display name is available to claim.
|
|
33
41
|
*/
|
|
34
42
|
async getUsernameAvailability(params) {
|
|
@@ -326,9 +334,51 @@ var MobileClient = class {
|
|
|
326
334
|
return this.publicExecute(body);
|
|
327
335
|
}
|
|
328
336
|
/**
|
|
337
|
+
* Updates the biography, or clears it when the text is whitespace-only.
|
|
338
|
+
*
|
|
339
|
+
* Serialize this with {@link MobileClient.setAvatar}, {@link MobileClient.setUsername} and
|
|
340
|
+
* {@link MobileClient.setPrivateMode} for the same subaccount: all share the identity update nonce.
|
|
341
|
+
*
|
|
342
|
+
* @throws {MobileServerFailureError} With `INVALID_BIO` for exceeding `MOBILE_BIO_MAX_LENGTH` or null
|
|
343
|
+
* characters, `INVALID_IDENTITY_TARGET` for an isolated subaccount, or `STALE_IDENTITY_UPDATE` when a
|
|
344
|
+
* later write has committed (re-read the profile before retrying).
|
|
345
|
+
*/
|
|
346
|
+
async setBio(params) {
|
|
347
|
+
const signedRequest = await this.getSignedRequest("set_bio", params, { bio: params.bio });
|
|
348
|
+
return this.execute(signedRequest);
|
|
349
|
+
}
|
|
350
|
+
/**
|
|
351
|
+
* Creates a short-lived upload grant. The caller uploads an image meeting {@link MobileAvatarUpload}'s requirements;
|
|
352
|
+
* file access and transport remain platform-specific. This does not change the saved avatar.
|
|
353
|
+
*
|
|
354
|
+
* @throws {MobileServerFailureError} With `INVALID_AVATAR` for a zero or oversized upload,
|
|
355
|
+
* `INVALID_IDENTITY_TARGET` for an isolated subaccount, or `SERVICE_UNAVAILABLE` when storage is unavailable.
|
|
356
|
+
*/
|
|
357
|
+
async createAvatarUpload(params) {
|
|
358
|
+
const signedRequest = await this.getSignedRequest("create_avatar_upload", params, { content_length: params.contentLength });
|
|
359
|
+
return mapMobileAvatarUpload(await this.execute(signedRequest));
|
|
360
|
+
}
|
|
361
|
+
/**
|
|
362
|
+
* Publishes a preset/staged upload, or clears the saved avatar when avatar is null.
|
|
363
|
+
* Uploaded JPEG/PNG images must be square, at most 4096 × 4096 pixels, and within
|
|
364
|
+
* `MOBILE_AVATAR_MAX_UPLOAD_BYTES`. A successful PUT can still fail this publication check.
|
|
365
|
+
*
|
|
366
|
+
* Serialize identity writes for the same subaccount; see {@link MobileClient.setBio}.
|
|
367
|
+
*
|
|
368
|
+
* @throws {MobileServerFailureError} With `INVALID_AVATAR` for an invalid preset, staging key, or image,
|
|
369
|
+
* `INVALID_IDENTITY_TARGET` for an isolated subaccount, `SERVICE_UNAVAILABLE` when storage is unavailable,
|
|
370
|
+
* or `STALE_IDENTITY_UPDATE` when a later write has committed (re-read the profile before retrying).
|
|
371
|
+
*/
|
|
372
|
+
async setAvatar(params) {
|
|
373
|
+
const signedRequest = await this.getSignedRequest("set_avatar", params, { avatar: mapMobileAvatarSelectionToServer(params.avatar) });
|
|
374
|
+
return this.execute(signedRequest);
|
|
375
|
+
}
|
|
376
|
+
/**
|
|
329
377
|
* Sets a subaccount's username, derived from the given display name. Upserts: the same call claims a first
|
|
330
378
|
* username and renames an existing one, so callers never need to read the current identity first.
|
|
331
379
|
*
|
|
380
|
+
* Serialize identity writes for the same subaccount; see {@link MobileClient.setBio}.
|
|
381
|
+
*
|
|
332
382
|
* @throws {MobileServerFailureError} With error code `INVALID_DISPLAY_NAME` if the display name violates
|
|
333
383
|
* `MOBILE_DISPLAY_NAME_PATTERN`, `USERNAME_UNAVAILABLE` if the derived username is reserved or already
|
|
334
384
|
* taken by another subaccount, `INVALID_IDENTITY_TARGET` if the sender is in the engine-created isolated
|
|
@@ -341,6 +391,7 @@ var MobileClient = class {
|
|
|
341
391
|
}
|
|
342
392
|
/**
|
|
343
393
|
* Sets whether a subaccount's profile is private.
|
|
394
|
+
* Serialize identity writes for the same subaccount; see {@link MobileClient.setBio}.
|
|
344
395
|
*/
|
|
345
396
|
async setPrivateMode(params) {
|
|
346
397
|
const signedRequest = await this.getSignedRequest("set_private_mode", params, { private_mode: params.privateMode });
|