@nadohq/mobile-client 0.64.0 → 0.66.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 +124 -7
- package/dist/MobileClient-M4oC4lrX.cjs +1101 -0
- package/dist/MobileClient-M4oC4lrX.cjs.map +1 -0
- package/dist/MobileClient.cjs +1 -1
- package/dist/MobileClient.d.cts +306 -10
- package/dist/MobileClient.d.cts.map +1 -1
- package/dist/MobileClient.d.ts +306 -10
- package/dist/MobileClient.d.ts.map +1 -1
- package/dist/MobileClient.js +544 -5
- package/dist/MobileClient.js.map +1 -1
- package/dist/{MobileServerFailureError-Dd3c6P_Z.d.ts → MobileServerFailureError-C9iqNsxI.d.ts} +2 -3
- package/dist/MobileServerFailureError-C9iqNsxI.d.ts.map +1 -0
- package/dist/{MobileServerFailureError-Bpa_WA9f.d.cts → MobileServerFailureError-MtS2reel.d.cts} +2 -3
- package/dist/MobileServerFailureError-MtS2reel.d.cts.map +1 -0
- package/dist/MobileUnsupportedFeedItemError-BsZvW8i2.d.cts +15 -0
- package/dist/MobileUnsupportedFeedItemError-BsZvW8i2.d.cts.map +1 -0
- package/dist/MobileUnsupportedFeedItemError-BsZvW8i2.d.ts +15 -0
- package/dist/MobileUnsupportedFeedItemError-BsZvW8i2.d.ts.map +1 -0
- package/dist/MobileUnsupportedNotificationRouteError-DpiNBvvY.d.cts +15 -0
- package/dist/MobileUnsupportedNotificationRouteError-DpiNBvvY.d.cts.map +1 -0
- package/dist/MobileUnsupportedNotificationRouteError-DpiNBvvY.d.ts +15 -0
- package/dist/MobileUnsupportedNotificationRouteError-DpiNBvvY.d.ts.map +1 -0
- package/dist/{buildSignedMobileRequest-Cb1T74xV.d.ts → buildSignedMobileRequest-BR-KJhIF.d.ts} +2 -2
- package/dist/{buildSignedMobileRequest-Cb1T74xV.d.ts.map → buildSignedMobileRequest-BR-KJhIF.d.ts.map} +1 -1
- package/dist/{buildSignedMobileRequest-NHbMAPzd.d.cts → buildSignedMobileRequest-DyKCK34Y.d.cts} +2 -2
- package/dist/{buildSignedMobileRequest-NHbMAPzd.d.cts.map → buildSignedMobileRequest-DyKCK34Y.d.cts.map} +1 -1
- package/dist/{canonicalize-BBYGh17w.d.ts → canonicalize-Bv6UIAbR.d.ts} +2 -2
- package/dist/canonicalize-Bv6UIAbR.d.ts.map +1 -0
- package/dist/{canonicalize-BF_SiNvO.d.cts → canonicalize-CWh3XZzj.d.cts} +2 -2
- package/dist/canonicalize-CWh3XZzj.d.cts.map +1 -0
- package/dist/clientTypes-BUn5_OzK.d.ts +1665 -0
- package/dist/clientTypes-BUn5_OzK.d.ts.map +1 -0
- package/dist/clientTypes-DOpUcu80.d.cts +1665 -0
- package/dist/clientTypes-DOpUcu80.d.cts.map +1 -0
- package/dist/dataMappers.cjs +691 -14
- package/dist/dataMappers.cjs.map +1 -1
- package/dist/dataMappers.d.cts +254 -8
- package/dist/dataMappers.d.cts.map +1 -1
- package/dist/dataMappers.d.ts +254 -8
- package/dist/dataMappers.d.ts.map +1 -1
- package/dist/dataMappers.js +651 -15
- package/dist/dataMappers.js.map +1 -1
- package/dist/{eip712MethodByType-BSx11xG-.d.cts → eip712MethodByType-CJ6BoayT.d.cts} +2 -2
- package/dist/eip712MethodByType-CJ6BoayT.d.cts.map +1 -0
- package/dist/{eip712MethodByType-DkiAjCLs.d.ts → eip712MethodByType-Dx4mvgni.d.ts} +2 -2
- package/dist/eip712MethodByType-Dx4mvgni.d.ts.map +1 -0
- package/dist/{feed-DTJlsg8W.d.ts → feed-DErOLaoY.d.cts} +4 -2
- package/dist/feed-DErOLaoY.d.cts.map +1 -0
- package/dist/{feed-DTJlsg8W.d.cts → feed-DErOLaoY.d.ts} +4 -2
- package/dist/feed-DErOLaoY.d.ts.map +1 -0
- package/dist/index.cjs +9 -2
- package/dist/index.d.cts +15 -16
- package/dist/index.d.ts +15 -16
- package/dist/index.js +5 -3
- package/dist/{mobileErrorCodes-3LtreeZM.d.ts → mobileErrorCodes-vD6rbFuF.d.cts} +25 -6
- package/dist/mobileErrorCodes-vD6rbFuF.d.cts.map +1 -0
- package/dist/{mobileErrorCodes-3LtreeZM.d.cts → mobileErrorCodes-vD6rbFuF.d.ts} +25 -6
- package/dist/mobileErrorCodes-vD6rbFuF.d.ts.map +1 -0
- package/dist/{payloadHash-BOWGjqdb.d.cts → payloadHash-CdkF2Ocr.d.cts} +2 -2
- package/dist/payloadHash-CdkF2Ocr.d.cts.map +1 -0
- package/dist/{payloadHash-Bzf4CtjV.d.ts → payloadHash-HD29K77M.d.ts} +2 -2
- package/dist/payloadHash-HD29K77M.d.ts.map +1 -0
- package/dist/serverExecuteTypes-5JyyIXRK.d.ts +178 -0
- package/dist/serverExecuteTypes-5JyyIXRK.d.ts.map +1 -0
- package/dist/serverExecuteTypes-CHrQ9Rtq.d.cts +178 -0
- package/dist/serverExecuteTypes-CHrQ9Rtq.d.cts.map +1 -0
- package/dist/serverModelTypes-CGUZCi0y.d.cts +938 -0
- package/dist/serverModelTypes-CGUZCi0y.d.cts.map +1 -0
- package/dist/serverModelTypes-CGUZCi0y.d.ts +938 -0
- package/dist/serverModelTypes-CGUZCi0y.d.ts.map +1 -0
- package/dist/{serverResponseGuards-BU1Xv_tG.d.ts → serverResponseGuards-Bvw8ltYJ.d.ts} +2 -2
- package/dist/{serverResponseGuards-BU1Xv_tG.d.ts.map → serverResponseGuards-Bvw8ltYJ.d.ts.map} +1 -1
- package/dist/{serverResponseGuards-Dkdok0Sm.d.cts → serverResponseGuards-i1njcYKN.d.cts} +2 -2
- package/dist/{serverResponseGuards-Dkdok0Sm.d.cts.map → serverResponseGuards-i1njcYKN.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 +86 -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 +86 -0
- package/dist/signing/canonicalize.js.map +1 -1
- package/dist/signing/eip712MethodByType.cjs +12 -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 +12 -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.cjs +1 -1
- package/dist/signing/payloadHash.d.cts +1 -1
- package/dist/signing/payloadHash.d.ts +1 -1
- package/dist/signing/payloadHash.js +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/MobileUnsupportedFeedItemError.cjs +19 -0
- package/dist/types/MobileUnsupportedFeedItemError.cjs.map +1 -0
- package/dist/types/MobileUnsupportedFeedItemError.d.cts +2 -0
- package/dist/types/MobileUnsupportedFeedItemError.d.ts +2 -0
- package/dist/types/MobileUnsupportedFeedItemError.js +18 -0
- package/dist/types/MobileUnsupportedFeedItemError.js.map +1 -0
- package/dist/types/MobileUnsupportedNotificationRouteError.cjs +19 -0
- package/dist/types/MobileUnsupportedNotificationRouteError.cjs.map +1 -0
- package/dist/types/MobileUnsupportedNotificationRouteError.d.cts +2 -0
- package/dist/types/MobileUnsupportedNotificationRouteError.d.ts +2 -0
- package/dist/types/MobileUnsupportedNotificationRouteError.js +18 -0
- package/dist/types/MobileUnsupportedNotificationRouteError.js.map +1 -0
- package/dist/types/clientTypes.d.cts +2 -2
- package/dist/types/clientTypes.d.ts +2 -2
- package/dist/types/index.cjs +6 -0
- package/dist/types/index.d.cts +9 -9
- package/dist/types/index.d.ts +9 -9
- package/dist/types/index.js +4 -2
- package/dist/types/mobileErrorCodes.cjs +39 -1
- 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 +39 -1
- 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 +15 -0
- 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 +14 -1
- 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 +2 -2
- package/dist/types/serverRequestTypes.d.ts +2 -2
- package/dist/types-C9YE4EIt.d.cts +794 -0
- package/dist/types-C9YE4EIt.d.cts.map +1 -0
- package/dist/types-Cwy1y_9x.d.ts +794 -0
- package/dist/types-Cwy1y_9x.d.ts.map +1 -0
- package/dist/utils/buildMobileFeedImageMultipart.cjs +31 -0
- package/dist/utils/buildMobileFeedImageMultipart.cjs.map +1 -0
- package/dist/utils/buildMobileFeedImageMultipart.d.cts +15 -0
- package/dist/utils/buildMobileFeedImageMultipart.d.cts.map +1 -0
- package/dist/utils/buildMobileFeedImageMultipart.d.ts +15 -0
- package/dist/utils/buildMobileFeedImageMultipart.d.ts.map +1 -0
- package/dist/utils/buildMobileFeedImageMultipart.js +30 -0
- package/dist/utils/buildMobileFeedImageMultipart.js.map +1 -0
- package/dist/utils/feed.cjs +3 -0
- package/dist/utils/feed.cjs.map +1 -1
- package/dist/utils/feed.d.cts +2 -2
- package/dist/utils/feed.d.ts +2 -2
- package/dist/utils/feed.js +3 -1
- package/dist/utils/feed.js.map +1 -1
- package/dist/utils/index.cjs +2 -1
- package/dist/utils/index.d.cts +3 -3
- package/dist/utils/index.d.ts +3 -3
- package/dist/utils/index.js +2 -2
- 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 +789 -7
- package/src/dataMappers.test.ts +848 -0
- package/src/dataMappers.ts +924 -17
- package/src/feedImages.test.ts +309 -0
- package/src/notifications.test.ts +950 -0
- package/src/signing/canonicalize.ts +119 -0
- package/src/signing/eip712MethodByType.ts +15 -0
- package/src/signing/signing.test.ts +362 -0
- package/src/signing/types.ts +108 -13
- package/src/socialFeed.test.ts +38 -2
- package/src/types/MobileUnsupportedFeedItemError.ts +18 -0
- package/src/types/MobileUnsupportedNotificationRouteError.ts +16 -0
- package/src/types/clientTypes.ts +1012 -34
- package/src/types/index.ts +2 -0
- package/src/types/mobileErrorCodes.ts +38 -0
- package/src/types/serverExecuteTypes.ts +112 -3
- package/src/types/serverModelTypes.ts +581 -28
- package/src/types/serverQueryTypes.ts +212 -5
- package/src/types/serverRequestTypes.ts +213 -13
- package/src/utils/buildMobileFeedImageMultipart.test.ts +45 -0
- package/src/utils/buildMobileFeedImageMultipart.ts +36 -0
- package/src/utils/feed.ts +3 -0
- package/dist/MobileClient-aDxiM_Kf.cjs +0 -562
- package/dist/MobileClient-aDxiM_Kf.cjs.map +0 -1
- package/dist/MobileServerFailureError-Bpa_WA9f.d.cts.map +0 -1
- package/dist/MobileServerFailureError-Dd3c6P_Z.d.ts.map +0 -1
- package/dist/canonicalize-BBYGh17w.d.ts.map +0 -1
- package/dist/canonicalize-BF_SiNvO.d.cts.map +0 -1
- package/dist/clientTypes-BWFKo9oE.d.cts +0 -844
- package/dist/clientTypes-BWFKo9oE.d.cts.map +0 -1
- package/dist/clientTypes-DCTiUV0H.d.ts +0 -844
- package/dist/clientTypes-DCTiUV0H.d.ts.map +0 -1
- package/dist/eip712MethodByType-BSx11xG-.d.cts.map +0 -1
- package/dist/eip712MethodByType-DkiAjCLs.d.ts.map +0 -1
- package/dist/feed-DTJlsg8W.d.cts.map +0 -1
- package/dist/feed-DTJlsg8W.d.ts.map +0 -1
- package/dist/mobileErrorCodes-3LtreeZM.d.cts.map +0 -1
- package/dist/mobileErrorCodes-3LtreeZM.d.ts.map +0 -1
- package/dist/payloadHash-BOWGjqdb.d.cts.map +0 -1
- package/dist/payloadHash-Bzf4CtjV.d.ts.map +0 -1
- package/dist/serverBaseTypes-DWf3iGWy.d.ts +0 -25
- package/dist/serverBaseTypes-DWf3iGWy.d.ts.map +0 -1
- package/dist/serverBaseTypes-KREDe2M9.d.cts +0 -25
- package/dist/serverBaseTypes-KREDe2M9.d.cts.map +0 -1
- package/dist/serverExecuteTypes-DVRa6ifu.d.cts +0 -89
- package/dist/serverExecuteTypes-DVRa6ifu.d.cts.map +0 -1
- package/dist/serverExecuteTypes-DlYZCp1f.d.ts +0 -89
- package/dist/serverExecuteTypes-DlYZCp1f.d.ts.map +0 -1
- package/dist/serverModelTypes-DAqEyYtB.d.cts +0 -508
- package/dist/serverModelTypes-DAqEyYtB.d.cts.map +0 -1
- package/dist/serverModelTypes-DAqEyYtB.d.ts +0 -508
- package/dist/serverModelTypes-DAqEyYtB.d.ts.map +0 -1
- package/dist/serverQueryTypes-BFdwq0Z2.d.ts +0 -171
- package/dist/serverQueryTypes-BFdwq0Z2.d.ts.map +0 -1
- package/dist/serverQueryTypes-DNdMpmDr.d.cts +0 -171
- package/dist/serverQueryTypes-DNdMpmDr.d.cts.map +0 -1
- package/dist/serverRequestTypes-BNA7FCY6.d.ts +0 -200
- package/dist/serverRequestTypes-BNA7FCY6.d.ts.map +0 -1
- package/dist/serverRequestTypes-CxDRFKfv.d.cts +0 -200
- package/dist/serverRequestTypes-CxDRFKfv.d.cts.map +0 -1
- package/dist/types-BCr2G5gS.d.cts +0 -84
- package/dist/types-BCr2G5gS.d.cts.map +0 -1
- package/dist/types-C18k-9Vy.d.ts +0 -84
- package/dist/types-C18k-9Vy.d.ts.map +0 -1
|
@@ -0,0 +1,1101 @@
|
|
|
1
|
+
//#region \0rolldown/runtime.js
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __copyProps = (to, from, except, desc) => {
|
|
9
|
+
if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
10
|
+
key = keys[i];
|
|
11
|
+
if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
12
|
+
get: ((k) => from[k]).bind(null, key),
|
|
13
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
19
|
+
value: mod,
|
|
20
|
+
enumerable: true
|
|
21
|
+
}) : target, mod));
|
|
22
|
+
//#endregion
|
|
23
|
+
const require_dataMappers = require("./dataMappers.cjs");
|
|
24
|
+
const require_signing_nonce = require("./signing/nonce.cjs");
|
|
25
|
+
const require_signing_buildSignedMobileRequest = require("./signing/buildSignedMobileRequest.cjs");
|
|
26
|
+
const require_types_MobileServerFailureError = require("./types/MobileServerFailureError.cjs");
|
|
27
|
+
const require_utils_buildMobileFeedImageMultipart = require("./utils/buildMobileFeedImageMultipart.cjs");
|
|
28
|
+
const require_utils_feed = require("./utils/feed.cjs");
|
|
29
|
+
const require_utils_serverResponseGuards = require("./utils/serverResponseGuards.cjs");
|
|
30
|
+
let _nadohq_shared = require("@nadohq/shared");
|
|
31
|
+
let axios = require("axios");
|
|
32
|
+
axios = __toESM(axios, 1);
|
|
33
|
+
let viem = require("viem");
|
|
34
|
+
//#region src/MobileClient.ts
|
|
35
|
+
/**
|
|
36
|
+
* Client for the Nado mobile service API: usernames, bios, avatars, public profile lookups, the global
|
|
37
|
+
* trade feed, session-based social feeds, the follower/following graph, privacy settings, and push
|
|
38
|
+
* notification device/preference management.
|
|
39
|
+
*/
|
|
40
|
+
var MobileClient = class {
|
|
41
|
+
constructor(opts) {
|
|
42
|
+
this.opts = opts;
|
|
43
|
+
this.axiosInstance = axios.default.create({
|
|
44
|
+
withCredentials: true,
|
|
45
|
+
validateStatus: () => true,
|
|
46
|
+
headers: (0, _nadohq_shared.getNadoClientTypeHeaders)(opts.clientType)
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Sets the linked signer for requests
|
|
51
|
+
*
|
|
52
|
+
* @param linkedSignerWalletClient The linkedSigner to use for all signatures. Set to null to revert to the chain signer
|
|
53
|
+
*/
|
|
54
|
+
setLinkedSigner(linkedSignerWalletClient) {
|
|
55
|
+
this.opts.linkedSignerWalletClient = linkedSignerWalletClient ?? void 0;
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Returns the current server-owned avatar catalogue in display order.
|
|
59
|
+
*
|
|
60
|
+
* @throws {MobileServerFailureError} With `SERVICE_UNAVAILABLE` when avatar storage is not configured.
|
|
61
|
+
*/
|
|
62
|
+
async getAvatarPresets() {
|
|
63
|
+
return (await this.publicQuery({ type: "avatar_presets" })).presets.map(require_dataMappers.mapMobileAvatarPreset);
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Checks whether a username derived from the given display name is available to claim.
|
|
67
|
+
*/
|
|
68
|
+
async getUsernameAvailability(params) {
|
|
69
|
+
const body = {
|
|
70
|
+
type: "username_availability",
|
|
71
|
+
display_name: params.displayName
|
|
72
|
+
};
|
|
73
|
+
const data = await this.publicQuery(body);
|
|
74
|
+
return {
|
|
75
|
+
username: data.username,
|
|
76
|
+
available: data.available
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Looks up public profiles, optionally with follower totals and a follow summary. Returns one profile per
|
|
81
|
+
* requested subaccount, in the requested order, so callers can correlate positionally. Every non-isolated
|
|
82
|
+
* subaccount resolves, with `username` and `displayName` `null` until a username is claimed. Private Mode
|
|
83
|
+
* does not hide the profile itself, only the account's activity.
|
|
84
|
+
*
|
|
85
|
+
* This is the only profile route, so use it for a single subaccount too. It is unsigned, which means
|
|
86
|
+
* `include.followSummary.viewAs` is an unauthenticated claim.
|
|
87
|
+
*
|
|
88
|
+
* @throws {MobileServerFailureError} With error code `INVALID_PROFILES_REQUEST` if `subaccounts` is empty,
|
|
89
|
+
* holds duplicates, or exceeds `MOBILE_PROFILES_MAX_BATCH_SIZE` (25), or `PROFILE_NOT_FOUND` if any
|
|
90
|
+
* requested subaccount — or the follow summary's `viewAs` — is in the engine-created isolated namespace.
|
|
91
|
+
* One isolated member fails the whole batch rather than being omitted.
|
|
92
|
+
*/
|
|
93
|
+
async getProfiles(params) {
|
|
94
|
+
const body = {
|
|
95
|
+
type: "profiles",
|
|
96
|
+
subaccounts: params.subaccounts.map(_nadohq_shared.subaccountToHex),
|
|
97
|
+
include: params.include ? require_dataMappers.mapMobileProfilesIncludeToServer(params.include) : void 0
|
|
98
|
+
};
|
|
99
|
+
return (await this.publicQuery(body)).profiles.map(require_dataMappers.mapMobilePublicProfile);
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* Searches claimed profiles by the start of their username, in ascending username order with an exact
|
|
103
|
+
* match first. Only current claimed identities match: an unnamed profile never does, and Private Mode does
|
|
104
|
+
* not hide one. Takes the same `include` as {@link MobileClient.getProfiles}, so a page can carry follower
|
|
105
|
+
* totals and a follow summary without a second request; as there, `include.followSummary.viewAs` is an
|
|
106
|
+
* unauthenticated claim on an unsigned route.
|
|
107
|
+
*
|
|
108
|
+
* Pagination is live rather than snapshot, so deduplicate matches by subaccount across pages. A cursor is
|
|
109
|
+
* bound to the query alone, so `include` and `limit` may change between pages.
|
|
110
|
+
*
|
|
111
|
+
* @throws {MobileServerFailureError} With error code `INVALID_PROFILE_SEARCH_REQUEST` if `query` is outside
|
|
112
|
+
* the username alphabet or length or `limit` is out of range (1-50, or 1-25 with an include),
|
|
113
|
+
* `INVALID_PROFILE_SEARCH_CURSOR` if the cursor is malformed or was issued for a different query (discard
|
|
114
|
+
* it and restart from the first page), or `PROFILE_NOT_FOUND` if `include.followSummary.viewAs` is in the
|
|
115
|
+
* engine-created isolated namespace.
|
|
116
|
+
*/
|
|
117
|
+
async searchProfiles(params) {
|
|
118
|
+
const body = {
|
|
119
|
+
type: "search_profiles",
|
|
120
|
+
...require_dataMappers.mapMobileProfileSearchParamsToServer(params)
|
|
121
|
+
};
|
|
122
|
+
return require_dataMappers.mapMobileProfileSearchPage(await this.publicQuery(body));
|
|
123
|
+
}
|
|
124
|
+
/**
|
|
125
|
+
* Fetches a page of the accounts that follow the given Profile.
|
|
126
|
+
*
|
|
127
|
+
* Ordering depends on `viewAs`. With it, accounts the Viewer already follows come first, unfamiliar
|
|
128
|
+
* accounts second, and every row carries an `isFollowing`. Without it, the page is ordered by the listed
|
|
129
|
+
* relationship alone and no row carries an `isFollowing`. In both cases the newest listed relationship
|
|
130
|
+
* comes first within a group, with a bytes32 tie-break. The grouping is evaluated per request against the
|
|
131
|
+
* live graph, so following an account from inside the list moves it between groups on the next page —
|
|
132
|
+
* deduplicate by subaccount and do not re-sort locally.
|
|
133
|
+
*
|
|
134
|
+
* @throws {MobileServerFailureError} With error code `PROFILE_NOT_FOUND` if the viewed Profile or `viewAs`
|
|
135
|
+
* is isolated, `INVALID_FOLLOW_CURSOR` if the cursor is malformed or was issued for a different `viewAs`,
|
|
136
|
+
* Profile, or list direction (discard it and restart from the first page), or `INVALID_FOLLOW_LIMIT` if
|
|
137
|
+
* `limit` is outside 1–50.
|
|
138
|
+
*/
|
|
139
|
+
async getFollowers(params) {
|
|
140
|
+
const body = {
|
|
141
|
+
type: "followers",
|
|
142
|
+
...require_dataMappers.mapMobileFollowListParamsToServer(params)
|
|
143
|
+
};
|
|
144
|
+
return require_dataMappers.mapMobileFollowListPage(await this.publicQuery(body));
|
|
145
|
+
}
|
|
146
|
+
/**
|
|
147
|
+
* Fetches a page of the accounts the given Profile follows. Ordering, cursor rules, and errors match
|
|
148
|
+
* {@link MobileClient.getFollowers}. When `viewAs` reads its own Following list every row is familiar, so
|
|
149
|
+
* every `isFollowing` is `true`.
|
|
150
|
+
*/
|
|
151
|
+
async getFollowing(params) {
|
|
152
|
+
const body = {
|
|
153
|
+
type: "following",
|
|
154
|
+
...require_dataMappers.mapMobileFollowListParamsToServer(params)
|
|
155
|
+
};
|
|
156
|
+
return require_dataMappers.mapMobileFollowListPage(await this.publicQuery(body));
|
|
157
|
+
}
|
|
158
|
+
/**
|
|
159
|
+
* Fetches a page of the global trade feed: public perpetual trades, newest first, optionally filtered by a
|
|
160
|
+
* whole-dollar minimum notional (omitted means unfiltered). Trades by subaccounts that have not claimed a
|
|
161
|
+
* username are included with `null` name fields; only private accounts are filtered out. The feed is
|
|
162
|
+
* best-effort rather than authoritative history, and pagination is live (not snapshot), so deduplicate pages
|
|
163
|
+
* by {@link MobileFeedTrade.orderDigest}.
|
|
164
|
+
*
|
|
165
|
+
* @throws {MobileServerFailureError} With error code `INVALID_FEED_FILTER` if `minimumNotional` or
|
|
166
|
+
* `limit` is outside its allowed domain (fix the request; do not retry unchanged), or
|
|
167
|
+
* `INVALID_FEED_CURSOR` if the cursor is malformed or was issued for a different `minimumNotional`
|
|
168
|
+
* (discard the cursor and restart from the first page).
|
|
169
|
+
*/
|
|
170
|
+
async getFeed(params = {}) {
|
|
171
|
+
const body = {
|
|
172
|
+
type: "feed",
|
|
173
|
+
minimum_notional: params.minimumNotional,
|
|
174
|
+
limit: params.limit,
|
|
175
|
+
cursor: params.cursor
|
|
176
|
+
};
|
|
177
|
+
return require_dataMappers.mapMobileFeedPage(await this.publicQuery(body));
|
|
178
|
+
}
|
|
179
|
+
/**
|
|
180
|
+
* Fetches chronological For You recommendations with server-side author/thread constraints.
|
|
181
|
+
* Always public, with optional viewAs for relationship state. Preserve the session, viewAs, filters, and limit
|
|
182
|
+
* when paging, including through empty pages with a nextCursor. A 6312 error requires a refresh.
|
|
183
|
+
* @param params - Filters, pagination, optional viewing account, and browser credential; no signing identity.
|
|
184
|
+
* @returns A fixed-session page with its ranking version and new-content watermark.
|
|
185
|
+
* @throws {MobileServerFailureError} On invalid parameters, session mismatch/expiry, or unavailable data.
|
|
186
|
+
* @throws {MobileUnsupportedFeedItemError} If the service returns an unsupported item kind.
|
|
187
|
+
*/
|
|
188
|
+
async getForYouFeed(params = {}) {
|
|
189
|
+
const body = {
|
|
190
|
+
type: "for_you_feed",
|
|
191
|
+
market_category: params.marketCategory,
|
|
192
|
+
...require_dataMappers.mapMobileSocialFeedListParamsToServer(params),
|
|
193
|
+
...require_dataMappers.mapMobileSocialFeedReadParamsToServer(params)
|
|
194
|
+
};
|
|
195
|
+
return require_dataMappers.mapMobileSocialFeedRankedPage(await this.publicQuery(body));
|
|
196
|
+
}
|
|
197
|
+
/**
|
|
198
|
+
* Fetches chronological content by qualified Top Traders, with official account PnL badges.
|
|
199
|
+
* Always public; neither a wallet nor one-click trading setup is required.
|
|
200
|
+
* @param params - Filters, pagination, optional viewing account, and browser credential.
|
|
201
|
+
* @returns A page with its qualification cohort; an unavailable cohort fails instead of returning an empty ranking.
|
|
202
|
+
* @throws {MobileServerFailureError} On request/session errors or unavailable cohort data.
|
|
203
|
+
* @throws {MobileUnsupportedFeedItemError} If the service returns an unsupported item kind.
|
|
204
|
+
*/
|
|
205
|
+
async getTopTradersFeed(params = {}) {
|
|
206
|
+
const body = {
|
|
207
|
+
type: "top_traders_feed",
|
|
208
|
+
market_category: params.marketCategory,
|
|
209
|
+
...require_dataMappers.mapMobileSocialFeedListParamsToServer(params),
|
|
210
|
+
...require_dataMappers.mapMobileSocialFeedReadParamsToServer(params)
|
|
211
|
+
};
|
|
212
|
+
return require_dataMappers.mapMobileSocialFeedTopTradersPage(await this.publicQuery(body));
|
|
213
|
+
}
|
|
214
|
+
/**
|
|
215
|
+
* Fetches public content by authors followed by viewAs, without a signature. One-way following is sufficient.
|
|
216
|
+
* @param params - Required viewing account on every request, filters, pagination, and browser credential.
|
|
217
|
+
* @returns A chronological Friends page and reading session.
|
|
218
|
+
* @throws {MobileServerFailureError} On invalid viewing account, session errors, or feed query failure.
|
|
219
|
+
* @throws {MobileUnsupportedFeedItemError} If the service returns an unsupported item kind.
|
|
220
|
+
*/
|
|
221
|
+
async getFriendsFeed(params) {
|
|
222
|
+
const body = {
|
|
223
|
+
type: "friends_feed",
|
|
224
|
+
market_category: params.marketCategory,
|
|
225
|
+
...require_dataMappers.mapMobileSocialFeedListParamsToServer(params),
|
|
226
|
+
view_as: (0, _nadohq_shared.subaccountToHex)(params.viewAs),
|
|
227
|
+
viewer_token: params.viewerToken
|
|
228
|
+
};
|
|
229
|
+
return require_dataMappers.mapMobileSocialFeedRankedPage(await this.publicQuery(body));
|
|
230
|
+
}
|
|
231
|
+
/**
|
|
232
|
+
* Fetches an author's content visible to viewAs, including that account's own hidden content.
|
|
233
|
+
* @param params - Target identity, filters, pagination, and optional public viewing account.
|
|
234
|
+
* @returns An author page without main-feed ranking or cohort fields.
|
|
235
|
+
* @throws {MobileServerFailureError} On invalid parameters, session errors, or inaccessible content.
|
|
236
|
+
* @throws {MobileUnsupportedFeedItemError} If the service returns an unsupported item kind.
|
|
237
|
+
*/
|
|
238
|
+
async getProfileFeed(params) {
|
|
239
|
+
const body = {
|
|
240
|
+
type: "profile_feed",
|
|
241
|
+
subaccount: (0, _nadohq_shared.subaccountToHex)(params.subaccount),
|
|
242
|
+
market_category: params.marketCategory,
|
|
243
|
+
...require_dataMappers.mapMobileSocialFeedListParamsToServer(params),
|
|
244
|
+
...require_dataMappers.mapMobileSocialFeedReadParamsToServer(params)
|
|
245
|
+
};
|
|
246
|
+
return require_dataMappers.mapMobileSocialFeedPage(await this.publicQuery(body));
|
|
247
|
+
}
|
|
248
|
+
/**
|
|
249
|
+
* Fetches published content for one market.
|
|
250
|
+
* @param params - Product ID, content/size filters, pagination, and public viewing account.
|
|
251
|
+
* @returns A market page without main-feed ranking fields.
|
|
252
|
+
* @throws {MobileServerFailureError} On an unknown market, session errors, or unavailable data.
|
|
253
|
+
* @throws {MobileUnsupportedFeedItemError} If the service returns an unsupported item kind.
|
|
254
|
+
*/
|
|
255
|
+
async getMarketFeed(params) {
|
|
256
|
+
const body = {
|
|
257
|
+
type: "market_feed",
|
|
258
|
+
product_id: params.productId,
|
|
259
|
+
...require_dataMappers.mapMobileSocialFeedListParamsToServer(params),
|
|
260
|
+
...require_dataMappers.mapMobileSocialFeedReadParamsToServer(params)
|
|
261
|
+
};
|
|
262
|
+
return require_dataMappers.mapMobileSocialFeedPage(await this.publicQuery(body));
|
|
263
|
+
}
|
|
264
|
+
/**
|
|
265
|
+
* Fetches already published content for a position lifecycle. This is not full position history
|
|
266
|
+
* and includes hidden content owned by viewAs under account_view. It does not recreate suppressed activity.
|
|
267
|
+
* @param params - Position UUID, filters, pagination, and public viewing account.
|
|
268
|
+
* @returns A fixed-session position feed page.
|
|
269
|
+
* @throws {MobileServerFailureError} On inaccessible content, session errors, or unavailable data.
|
|
270
|
+
* @throws {MobileUnsupportedFeedItemError} If the service returns an unsupported item kind.
|
|
271
|
+
*/
|
|
272
|
+
async getPositionFeed(params) {
|
|
273
|
+
const body = {
|
|
274
|
+
type: "position_feed",
|
|
275
|
+
position_id: params.positionId,
|
|
276
|
+
...require_dataMappers.mapMobileSocialFeedListParamsToServer(params),
|
|
277
|
+
...require_dataMappers.mapMobileSocialFeedReadParamsToServer(params)
|
|
278
|
+
};
|
|
279
|
+
return require_dataMappers.mapMobileSocialFeedPage(await this.publicQuery(body));
|
|
280
|
+
}
|
|
281
|
+
/**
|
|
282
|
+
* Reads one item visible to viewAs, including that account's own hidden content.
|
|
283
|
+
* Creates an item session directly when sessionId is omitted.
|
|
284
|
+
* Pass {@link GetMobileFeedItemParams.viewEventId} when the user navigates into the detail so the
|
|
285
|
+
* subsequent {@link recordFeedViews} call can count that visit; omit it for prefetch.
|
|
286
|
+
* @param params - Item UUID, optional detail-visit event, preview limit, and optional existing session/read identity.
|
|
287
|
+
* @returns The complete item and authorized reading session.
|
|
288
|
+
* @throws {MobileServerFailureError} On inaccessible content or session mismatch/expiry.
|
|
289
|
+
* @throws {MobileUnsupportedFeedItemError} If the service returns an unsupported item kind.
|
|
290
|
+
*/
|
|
291
|
+
async getFeedItem(params) {
|
|
292
|
+
const body = {
|
|
293
|
+
type: "feed_item",
|
|
294
|
+
item_id: params.itemId,
|
|
295
|
+
view_event_id: params.viewEventId,
|
|
296
|
+
comment_preview_limit: params.commentPreviewLimit,
|
|
297
|
+
session_id: params.sessionId,
|
|
298
|
+
...require_dataMappers.mapMobileSocialFeedReadParamsToServer(params)
|
|
299
|
+
};
|
|
300
|
+
return require_dataMappers.mapMobileSocialFeedItemResponse(await this.publicQuery(body));
|
|
301
|
+
}
|
|
302
|
+
/**
|
|
303
|
+
* Polls authorized visible items and positions without inserting or reordering list members.
|
|
304
|
+
* Increment requestSeq across the entire session, including viewport changes; never reset it for a new viewport.
|
|
305
|
+
* Accept only the current session and viewportRevision's latest requestSeq; discard stale patches and cursors together.
|
|
306
|
+
* Updates currently always return reset=true. Apply current author details, follow state, and badges even if the item version is unchanged.
|
|
307
|
+
* Null patches clear values;
|
|
308
|
+
* omitted fields leave them unchanged. Stop polling off-screen and refresh on error 6312.
|
|
309
|
+
* @param params - Session, visible IDs, update baseline, sequence, and matching read identity.
|
|
310
|
+
* @returns Item/position patches, revoked targets, and a new-content hint.
|
|
311
|
+
* @throws {MobileServerFailureError} On invalid or unauthorized targets, session expiry, or unavailable data.
|
|
312
|
+
*/
|
|
313
|
+
async getFeedUpdates(params) {
|
|
314
|
+
const body = {
|
|
315
|
+
type: "feed_updates",
|
|
316
|
+
session_id: params.sessionId,
|
|
317
|
+
visible_item_ids: params.visibleItemIds,
|
|
318
|
+
visible_position_ids: params.visiblePositionIds,
|
|
319
|
+
update_cursor: params.updateCursor,
|
|
320
|
+
viewport_revision: params.viewportRevision,
|
|
321
|
+
request_seq: params.requestSeq,
|
|
322
|
+
viewer_token: params.viewerToken
|
|
323
|
+
};
|
|
324
|
+
return require_dataMappers.mapMobileSocialFeedUpdates(await this.publicQuery(body));
|
|
325
|
+
}
|
|
326
|
+
/**
|
|
327
|
+
* Fetches the push notification preferences of the wallet that owns the given Expo push token. Unsigned —
|
|
328
|
+
* the token identifies the wallet on its own. Falls back to the backend's defaults if the wallet has never
|
|
329
|
+
* updated its preferences.
|
|
330
|
+
*
|
|
331
|
+
* @throws {MobileServerFailureError} With error code `INVALID_EXPO_TOKEN` if the token is malformed, or is
|
|
332
|
+
* not currently registered to a wallet.
|
|
333
|
+
* @deprecated Use {@link getNotificationSettingsV2} instead.
|
|
334
|
+
*/
|
|
335
|
+
async getNotificationPreferences(params) {
|
|
336
|
+
const body = {
|
|
337
|
+
type: "notification_preferences",
|
|
338
|
+
expo_token: params.expoToken
|
|
339
|
+
};
|
|
340
|
+
return require_dataMappers.mapMobileNotificationPreferences((await this.publicQuery(body)).preferences);
|
|
341
|
+
}
|
|
342
|
+
/**
|
|
343
|
+
* Resolves the wallet that an Expo push token is currently registered to, along with the redacted metadata
|
|
344
|
+
* of the device that registered it. Unsigned — the token identifies the wallet on its own. Use it to check
|
|
345
|
+
* whether a locally held token is still active and which wallet currently owns it, since registering the
|
|
346
|
+
* same token under another wallet transfers ownership.
|
|
347
|
+
*
|
|
348
|
+
* @throws {MobileServerFailureError} With error code `INVALID_EXPO_TOKEN` if the token is malformed, or is
|
|
349
|
+
* not currently registered to a wallet — including a token that was unregistered. The backend does not
|
|
350
|
+
* distinguish those cases.
|
|
351
|
+
*/
|
|
352
|
+
async getRegisteredWallet(params) {
|
|
353
|
+
const body = {
|
|
354
|
+
type: "registered_wallet",
|
|
355
|
+
expo_token: params.expoToken
|
|
356
|
+
};
|
|
357
|
+
return require_dataMappers.mapMobileRegisteredWallet(await this.publicQuery(body));
|
|
358
|
+
}
|
|
359
|
+
/**
|
|
360
|
+
* Lists a selected account's current positions without signing or authenticating ownership.
|
|
361
|
+
* Publication and attachment eligibility are hints that the service rechecks on writes.
|
|
362
|
+
* @param params - Viewing subaccount, optional market filter, page size, and opaque cursor.
|
|
363
|
+
* @returns Current position candidates, their eligibility hints, the next cursor, and observation time.
|
|
364
|
+
* @throws {MobileServerFailureError} On invalid parameters, an unsupported viewing account, or unavailable
|
|
365
|
+
* position data. An account with no open positions returns an empty page instead of an error.
|
|
366
|
+
*/
|
|
367
|
+
async getSelfFeedPositions(params) {
|
|
368
|
+
const body = {
|
|
369
|
+
type: "self_feed_positions",
|
|
370
|
+
view_as: (0, _nadohq_shared.subaccountToHex)(params.viewAs),
|
|
371
|
+
product_id: params.productId,
|
|
372
|
+
cursor: params.cursor,
|
|
373
|
+
limit: params.limit
|
|
374
|
+
};
|
|
375
|
+
return require_dataMappers.mapMobileSocialFeedPositionsPage(await this.publicQuery(body));
|
|
376
|
+
}
|
|
377
|
+
/**
|
|
378
|
+
* Resolves a slash command against a selected account without changing the caller's input.
|
|
379
|
+
* @param params - Viewing subaccount, original command text, and optional market disambiguation.
|
|
380
|
+
* @returns The resolution, nullable market, candidate positions, and reason for an empty result.
|
|
381
|
+
* @throws {MobileServerFailureError} On invalid parameters, an unsupported viewing account, or unavailable
|
|
382
|
+
* source data. Unknown markets and accounts without open positions are normal resolution results.
|
|
383
|
+
*/
|
|
384
|
+
async resolveFeedPosition(params) {
|
|
385
|
+
const body = {
|
|
386
|
+
type: "resolve_feed_position",
|
|
387
|
+
view_as: (0, _nadohq_shared.subaccountToHex)(params.viewAs),
|
|
388
|
+
input: params.input,
|
|
389
|
+
product_id: params.productId
|
|
390
|
+
};
|
|
391
|
+
return require_dataMappers.mapMobileSocialFeedPositionResolutionResult(await this.publicQuery(body));
|
|
392
|
+
}
|
|
393
|
+
/**
|
|
394
|
+
* Resolves every trusted lifecycle segment of an order without requiring a signature.
|
|
395
|
+
* @param params - Order-owning subaccount and order digest; selecting the account is not authentication.
|
|
396
|
+
* @returns Trusted action candidates and their observation time, or a pending result with no actions.
|
|
397
|
+
* @throws {MobileServerFailureError} On invalid parameters, an inaccessible order, or unavailable source
|
|
398
|
+
* data. Pending projection is a successful result, not a source failure.
|
|
399
|
+
*/
|
|
400
|
+
async resolveFeedAction(params) {
|
|
401
|
+
const body = {
|
|
402
|
+
type: "resolve_feed_action",
|
|
403
|
+
view_as: (0, _nadohq_shared.subaccountToHex)(params.viewAs),
|
|
404
|
+
order_digest: params.orderDigest
|
|
405
|
+
};
|
|
406
|
+
return require_dataMappers.mapMobileSocialFeedActionResolutionResult(await this.publicQuery(body));
|
|
407
|
+
}
|
|
408
|
+
/**
|
|
409
|
+
* Reads a drawing publicly without issuing a reading session. Supplied sessions retain their scope.
|
|
410
|
+
* @param params - Parent item, optional viewing account, and optional original session and viewer token.
|
|
411
|
+
* @returns The parent ID and version, with a nullable drawing whose data may legitimately be false or zero.
|
|
412
|
+
* @throws {MobileServerFailureError} On invalid parameters, session mismatch or expiry, unavailable data,
|
|
413
|
+
* or `SOCIAL_FEED_DRAWING_UNAVAILABLE` when the parent is inaccessible. A readable parent without a drawing
|
|
414
|
+
* returns null. Acquire a new reading session when the original has expired.
|
|
415
|
+
*/
|
|
416
|
+
async getFeedChartDrawing(params) {
|
|
417
|
+
const body = {
|
|
418
|
+
type: "feed_chart_drawing",
|
|
419
|
+
item_id: params.itemId,
|
|
420
|
+
session_id: params.sessionId,
|
|
421
|
+
...require_dataMappers.mapMobileSocialFeedReadParamsToServer(params)
|
|
422
|
+
};
|
|
423
|
+
return require_dataMappers.mapMobileSocialFeedDrawingResult(await this.publicQuery(body));
|
|
424
|
+
}
|
|
425
|
+
/**
|
|
426
|
+
* Resolves a backend feed image path against this client's mobile gateway URL.
|
|
427
|
+
* @param path - Backend path from image metadata, rooted at /v1/mobile or the mobile service root.
|
|
428
|
+
* @returns An absolute URL suitable for authenticated fetches.
|
|
429
|
+
*/
|
|
430
|
+
resolveFeedImageUrl(path) {
|
|
431
|
+
return `${this.opts.url}${path.replace(/^\/v1\/mobile(?=\/)/, "")}`;
|
|
432
|
+
}
|
|
433
|
+
/**
|
|
434
|
+
* Prepares a protected image request for native image components without downloading or encoding bytes.
|
|
435
|
+
* Does not count as a detail visit or recorded view.
|
|
436
|
+
* @param params - Image path from metadata plus the original session credentials.
|
|
437
|
+
* @returns Absolute URL and headers; pass them as the image source's URI and headers.
|
|
438
|
+
*/
|
|
439
|
+
getFeedImageRequest(params) {
|
|
440
|
+
return {
|
|
441
|
+
url: this.resolveFeedImageUrl(params.path),
|
|
442
|
+
headers: {
|
|
443
|
+
"x-feed-session-id": params.sessionId,
|
|
444
|
+
"x-feed-viewer-token": params.viewerToken
|
|
445
|
+
}
|
|
446
|
+
};
|
|
447
|
+
}
|
|
448
|
+
/**
|
|
449
|
+
* Fetches protected feed image bytes using the reading session that fully delivered the parent item.
|
|
450
|
+
* Does not count as a detail visit or recorded view.
|
|
451
|
+
* @param params - Image path from metadata plus the original session credentials.
|
|
452
|
+
* @returns Raw image bytes.
|
|
453
|
+
* @throws {MobileServerFailureError} On session, permission, or availability errors.
|
|
454
|
+
*/
|
|
455
|
+
async getFeedImageBytes(params) {
|
|
456
|
+
const { url, headers } = this.getFeedImageRequest(params);
|
|
457
|
+
return this.publicGetBytes(url, headers);
|
|
458
|
+
}
|
|
459
|
+
/**
|
|
460
|
+
* Reads a comment thread with an optional anchor and bidirectional pagination.
|
|
461
|
+
* Independent reads create a public-only session; reused sessions retain their original scope.
|
|
462
|
+
* @param params - Root item, optional anchor or cursor (mutually exclusive), page size, and read perspective.
|
|
463
|
+
* Paging requires the original session and viewer token.
|
|
464
|
+
* @returns Replies, total count, forward and backward cursors, the anchor, and the actual reading session.
|
|
465
|
+
* @throws {MobileServerFailureError} On invalid parameters, session mismatch or expiry, inaccessible content,
|
|
466
|
+
* or unavailable data. Restart pagination with a new session after expiry; do not reuse the old cursor.
|
|
467
|
+
*/
|
|
468
|
+
async getFeedComments(params) {
|
|
469
|
+
const body = {
|
|
470
|
+
type: "feed_comments",
|
|
471
|
+
root_item_id: params.rootItemId,
|
|
472
|
+
cursor: params.cursor,
|
|
473
|
+
limit: params.limit,
|
|
474
|
+
anchor_reply_id: params.anchorReplyId,
|
|
475
|
+
session_id: params.sessionId,
|
|
476
|
+
...require_dataMappers.mapMobileSocialFeedReadParamsToServer(params)
|
|
477
|
+
};
|
|
478
|
+
return require_dataMappers.mapMobileSocialFeedCommentsPage(await this.publicQuery(body));
|
|
479
|
+
}
|
|
480
|
+
/**
|
|
481
|
+
* Reads the full position lifecycle and creates or reuses a position session.
|
|
482
|
+
* Unlike getPositionFeed, this includes lifecycle actions as well as published takes.
|
|
483
|
+
* @param params - Position, optional takes-only filter, pagination, and read perspective. Paging requires
|
|
484
|
+
* the original position session and viewer token, not a feed session.
|
|
485
|
+
* @returns Position metrics, ordered action/take history, summary, trading hints, cursor, and reading session.
|
|
486
|
+
* @throws {MobileServerFailureError} On invalid parameters, session mismatch or expiry, inaccessible content,
|
|
487
|
+
* or unavailable source data. Restart with a new position session after expiry.
|
|
488
|
+
* @throws {MobileUnsupportedFeedItemError} If a timeline entry or take has an unsupported kind.
|
|
489
|
+
*/
|
|
490
|
+
async getPositionHistory(params) {
|
|
491
|
+
const body = {
|
|
492
|
+
type: "position_history",
|
|
493
|
+
position_id: params.positionId,
|
|
494
|
+
takes_only: params.takesOnly,
|
|
495
|
+
cursor: params.cursor,
|
|
496
|
+
limit: params.limit,
|
|
497
|
+
session_id: params.sessionId,
|
|
498
|
+
...require_dataMappers.mapMobileSocialFeedReadParamsToServer(params)
|
|
499
|
+
};
|
|
500
|
+
return require_dataMappers.mapMobileSocialFeedPositionHistory(await this.publicQuery(body));
|
|
501
|
+
}
|
|
502
|
+
/**
|
|
503
|
+
* Reads candles and action markers without creating a reading session.
|
|
504
|
+
* Preserve the original range, interval, and read perspective when paging with nextBeforeMs.
|
|
505
|
+
* @param params - Position, candle interval, half-open time range, pagination, and optional original session
|
|
506
|
+
* and viewer token. An independent read omits both session credentials.
|
|
507
|
+
* @returns Candles with decimal prices and x18 volume, action markers, a nullable liquidation line, and paging metadata.
|
|
508
|
+
* @throws {MobileServerFailureError} On invalid parameters, session mismatch or expiry, inaccessible content,
|
|
509
|
+
* or wholly unavailable chart sources. Partially available data is returned with its quality indicator.
|
|
510
|
+
*/
|
|
511
|
+
async getPositionChart(params) {
|
|
512
|
+
const body = {
|
|
513
|
+
type: "position_chart",
|
|
514
|
+
position_id: params.positionId,
|
|
515
|
+
session_id: params.sessionId,
|
|
516
|
+
interval: params.interval,
|
|
517
|
+
range: {
|
|
518
|
+
from_ms: params.range.fromMs,
|
|
519
|
+
to_ms: params.range.toMs
|
|
520
|
+
},
|
|
521
|
+
before_ms: params.beforeMs,
|
|
522
|
+
limit: params.limit,
|
|
523
|
+
...require_dataMappers.mapMobileSocialFeedReadParamsToServer(params)
|
|
524
|
+
};
|
|
525
|
+
return require_dataMappers.mapMobileSocialFeedPositionChart(await this.publicQuery(body));
|
|
526
|
+
}
|
|
527
|
+
/**
|
|
528
|
+
* Reads active visitor counts and self-reported account previews without registering presence.
|
|
529
|
+
* @param params - Position and optional viewing account, used only for preview relationship information.
|
|
530
|
+
* @returns The visitor count, public account previews, and observation time; previews need not match the count.
|
|
531
|
+
* @throws {MobileServerFailureError} On invalid parameters, an unavailable position, or unavailable source data.
|
|
532
|
+
*/
|
|
533
|
+
async getPositionWatchers(params) {
|
|
534
|
+
const body = {
|
|
535
|
+
type: "position_watchers",
|
|
536
|
+
position_id: params.positionId,
|
|
537
|
+
view_as: params.viewAs === void 0 ? void 0 : (0, _nadohq_shared.subaccountToHex)(params.viewAs)
|
|
538
|
+
};
|
|
539
|
+
return require_dataMappers.mapMobileSocialFeedWatchers(await this.publicQuery(body));
|
|
540
|
+
}
|
|
541
|
+
/**
|
|
542
|
+
* Reads the token's latest registration generation and saved capabilities, including legacy v1 registrations.
|
|
543
|
+
* @param params - Active Expo token credential; no wallet signature is needed.
|
|
544
|
+
* @returns Saved generation as an opaque string and the complete capability declaration.
|
|
545
|
+
* @throws {MobileServerFailureError} If the token is invalid or inactive (`INVALID_EXPO_TOKEN`).
|
|
546
|
+
*/
|
|
547
|
+
async getNotificationRegistrationV2(params) {
|
|
548
|
+
return require_dataMappers.mapMobileNotificationRegistrationV2(await this.publicQuery({
|
|
549
|
+
type: "notification_registration_v2",
|
|
550
|
+
expo_token: params.expoToken
|
|
551
|
+
}));
|
|
552
|
+
}
|
|
553
|
+
/**
|
|
554
|
+
* Reads the wallet's full v2 settings document, including legacy preference mappings.
|
|
555
|
+
* @param params - Active Expo token credential. Before displaying settings, compare the wallet returned by
|
|
556
|
+
* {@link MobileClient.getRegisteredWallet} with the connected wallet (case-insensitively).
|
|
557
|
+
* @returns CamelCase settings with the current settings revision.
|
|
558
|
+
* @throws {MobileServerFailureError} If the token is invalid or inactive (`INVALID_EXPO_TOKEN`).
|
|
559
|
+
*/
|
|
560
|
+
async getNotificationSettingsV2(params) {
|
|
561
|
+
return require_dataMappers.mapMobileNotificationSettingsV2(await this.publicQuery({
|
|
562
|
+
type: "notification_settings_v2",
|
|
563
|
+
expo_token: params.expoToken
|
|
564
|
+
}));
|
|
565
|
+
}
|
|
566
|
+
/**
|
|
567
|
+
* Reads wallet market subscriptions and the signing Identity's enabled trader bells.
|
|
568
|
+
* @param params - Wallet authentication context; no Expo token is needed.
|
|
569
|
+
* @returns Subscriptions, import state, and the independent subscription revision.
|
|
570
|
+
* @throws {WalletNotProvidedError} If neither a linked signer nor a default wallet is configured.
|
|
571
|
+
* @throws {MobileServerFailureError} If authentication or the query fails.
|
|
572
|
+
*/
|
|
573
|
+
async getNotificationSubscriptions(params) {
|
|
574
|
+
const request = await this.getSignedRequest("notification_subscriptions", params, {});
|
|
575
|
+
return require_dataMappers.mapMobileNotificationSubscriptions(await this.query(request));
|
|
576
|
+
}
|
|
577
|
+
/**
|
|
578
|
+
* Reads private accepted notification intents, not delivery receipts or read states.
|
|
579
|
+
* @param params - Wallet authentication and optional cursor/page size (1-50, default 20).
|
|
580
|
+
* @returns A camelCase page; discard cached pages and cursors when switching wallets.
|
|
581
|
+
* @throws {WalletNotProvidedError} If neither a linked signer nor a default wallet is configured.
|
|
582
|
+
* @throws {MobileServerFailureError} If authentication or pagination validation fails.
|
|
583
|
+
* @throws {MobileUnsupportedNotificationRouteError} If a notification has an unsupported route name.
|
|
584
|
+
*/
|
|
585
|
+
async getNotificationInboxV2(params) {
|
|
586
|
+
const request = await this.getSignedRequest("notification_inbox_v2", params, {
|
|
587
|
+
cursor: params.cursor ?? null,
|
|
588
|
+
limit: params.limit ?? null
|
|
589
|
+
});
|
|
590
|
+
return require_dataMappers.mapMobileNotificationInboxV2(await this.query(request));
|
|
591
|
+
}
|
|
592
|
+
/**
|
|
593
|
+
* Unregisters an Expo push token, stopping delivery to that device. Unsigned, so it still works at logout
|
|
594
|
+
* when a wallet signature may no longer be obtainable. Idempotent: unregistering an inactive or unknown
|
|
595
|
+
* well-formed token succeeds.
|
|
596
|
+
*
|
|
597
|
+
* A registration that commits after this call re-activates the token, so stop or await any in-flight
|
|
598
|
+
* {@link MobileClient.registerExpoToken} before unregistering.
|
|
599
|
+
*
|
|
600
|
+
* @throws {MobileServerFailureError} With error code `INVALID_EXPO_TOKEN` if the token is malformed.
|
|
601
|
+
*/
|
|
602
|
+
async unregisterExpoToken(params) {
|
|
603
|
+
const body = {
|
|
604
|
+
type: "unregister_expo_token",
|
|
605
|
+
expo_token: params.expoToken
|
|
606
|
+
};
|
|
607
|
+
return this.publicExecute(body);
|
|
608
|
+
}
|
|
609
|
+
/**
|
|
610
|
+
* Replaces the push notification preferences of the wallet that owns the given Expo push token. Possession
|
|
611
|
+
* of an active token is the credential rather than a signature, so anyone holding the token can overwrite
|
|
612
|
+
* that wallet's preferences. The backend requires `schemaVersion` of 1, exactly one entry per known
|
|
613
|
+
* category, and empty `scopes` on every entry.
|
|
614
|
+
*
|
|
615
|
+
* Writes are last-write-wins on commit order rather than ordered by a client nonce, so callers must
|
|
616
|
+
* serialize their own preference writes.
|
|
617
|
+
*
|
|
618
|
+
* @throws {MobileServerFailureError} With error code `INVALID_PREFERENCES` if those rules are violated, or
|
|
619
|
+
* `INVALID_EXPO_TOKEN` if the token is malformed or is not currently registered to a wallet.
|
|
620
|
+
* @deprecated Use {@link updateNotificationSettingsV2} instead.
|
|
621
|
+
*/
|
|
622
|
+
async updateNotificationPreferences(params) {
|
|
623
|
+
const body = {
|
|
624
|
+
type: "update_preferences",
|
|
625
|
+
expo_token: params.expoToken,
|
|
626
|
+
preferences: require_dataMappers.mapMobileNotificationPreferencesToServer(params.preferences)
|
|
627
|
+
};
|
|
628
|
+
return this.publicExecute(body);
|
|
629
|
+
}
|
|
630
|
+
/**
|
|
631
|
+
* Replaces all v2 settings fields using optimistic concurrency; legacy overlapping preferences are synced.
|
|
632
|
+
* @param params - Active Expo token, latest settings revision, and complete replacement settings.
|
|
633
|
+
* @returns The saved settings document with its incremented revision.
|
|
634
|
+
* @throws {MobileServerFailureError} On invalid token/settings or revision conflict (`NOTIFICATION_REVISION_CONFLICT`). Re-read and
|
|
635
|
+
* merge only the user's current change before retrying; never blindly replay a stale document.
|
|
636
|
+
*/
|
|
637
|
+
async updateNotificationSettingsV2(params) {
|
|
638
|
+
return require_dataMappers.mapMobileNotificationSettingsV2(await this.publicExecute({
|
|
639
|
+
type: "update_notification_settings_v2",
|
|
640
|
+
expo_token: params.expoToken,
|
|
641
|
+
expected_revision: params.expectedRevision,
|
|
642
|
+
settings: require_dataMappers.mapMobileNotificationSettingsToServer(params.settings)
|
|
643
|
+
}));
|
|
644
|
+
}
|
|
645
|
+
/**
|
|
646
|
+
* Reports a detail visit without signing. Feed-list card impressions and previews do not count.
|
|
647
|
+
* After the primary detail target is shown in the foreground, send the same viewEventId previously
|
|
648
|
+
* registered through {@link getFeedItem}, together with that response's sessionId and viewerToken.
|
|
649
|
+
* Reuse the event ID on retries for the same visit; generate a new one only after leaving and re-entering.
|
|
650
|
+
* @param params - Original reading session and viewer token, the registered detail-visit event, and exactly
|
|
651
|
+
* one fully delivered, readable detail-target item ID.
|
|
652
|
+
* @returns Separate lists of newly accepted and already-counted item IDs for that event.
|
|
653
|
+
* @throws {MobileServerFailureError} On invalid parameters, an unregistered or rebound event
|
|
654
|
+
* (`SOCIAL_FEED_VIEW_EVENT_REBOUND`), session mismatch or expiry, or an ineligible item.
|
|
655
|
+
* Acquire a new session after expiry, re-register the same event via getFeedItem, then retry.
|
|
656
|
+
*/
|
|
657
|
+
async recordFeedViews(params) {
|
|
658
|
+
const body = {
|
|
659
|
+
type: "record_feed_views",
|
|
660
|
+
session_id: params.sessionId,
|
|
661
|
+
viewer_token: params.viewerToken,
|
|
662
|
+
view_event_id: params.viewEventId,
|
|
663
|
+
item_ids: [params.itemId]
|
|
664
|
+
};
|
|
665
|
+
return require_dataMappers.mapMobileSocialFeedViewsResult(await this.publicExecute(body));
|
|
666
|
+
}
|
|
667
|
+
/**
|
|
668
|
+
* Registers, renews, or leaves a page lease without signing or authenticating the displayed account.
|
|
669
|
+
* Omitting watcherSubaccount preserves its value; null clears it. This operation does not record item views.
|
|
670
|
+
* @param params - Authorized position, original session and viewer token, page-scoped viewSessionId,
|
|
671
|
+
* lease state, and optional self-reported display account. Retain viewSessionId for the lifetime of the page.
|
|
672
|
+
* @returns Visitor count, public previews, recommended heartbeat interval, and remaining lease lifetime.
|
|
673
|
+
* @throws {MobileServerFailureError} On invalid parameters, session mismatch or expiry, or an inaccessible
|
|
674
|
+
* position. Rejected requests leave leases unchanged; acquire a new reading session after expiry.
|
|
675
|
+
*/
|
|
676
|
+
async setPositionPresence(params) {
|
|
677
|
+
const body = {
|
|
678
|
+
type: "position_presence",
|
|
679
|
+
position_id: params.positionId,
|
|
680
|
+
session_id: params.sessionId,
|
|
681
|
+
view_session_id: params.viewSessionId,
|
|
682
|
+
state: params.state,
|
|
683
|
+
viewer_token: params.viewerToken,
|
|
684
|
+
...params.watcherSubaccount === void 0 ? {} : { watcher_subaccount: params.watcherSubaccount === null ? null : (0, _nadohq_shared.subaccountToHex)(params.watcherSubaccount) }
|
|
685
|
+
};
|
|
686
|
+
return require_dataMappers.mapMobileSocialFeedPresence(await this.publicExecute(body));
|
|
687
|
+
}
|
|
688
|
+
/**
|
|
689
|
+
* Updates the biography, or clears it when the text is whitespace-only.
|
|
690
|
+
*
|
|
691
|
+
* Serialize this with {@link MobileClient.setAvatar}, {@link MobileClient.setUsername} and
|
|
692
|
+
* {@link MobileClient.setPrivateMode} for the same subaccount: all share the identity update nonce.
|
|
693
|
+
*
|
|
694
|
+
* @throws {MobileServerFailureError} With `INVALID_BIO` for exceeding `MOBILE_BIO_MAX_LENGTH` or null
|
|
695
|
+
* characters, `INVALID_IDENTITY_TARGET` for an isolated subaccount, or `STALE_IDENTITY_UPDATE` when a
|
|
696
|
+
* later write has committed (re-read the profile before retrying).
|
|
697
|
+
*/
|
|
698
|
+
async setBio(params) {
|
|
699
|
+
const signedRequest = await this.getSignedRequest("set_bio", params, { bio: params.bio });
|
|
700
|
+
return this.execute(signedRequest);
|
|
701
|
+
}
|
|
702
|
+
/**
|
|
703
|
+
* Creates a short-lived upload grant. The caller uploads an image meeting {@link MobileAvatarUpload}'s requirements;
|
|
704
|
+
* file access and transport remain platform-specific. This does not change the saved avatar.
|
|
705
|
+
*
|
|
706
|
+
* @throws {MobileServerFailureError} With `INVALID_AVATAR` for a zero or oversized upload,
|
|
707
|
+
* `INVALID_IDENTITY_TARGET` for an isolated subaccount, or `SERVICE_UNAVAILABLE` when storage is unavailable.
|
|
708
|
+
*/
|
|
709
|
+
async createAvatarUpload(params) {
|
|
710
|
+
const signedRequest = await this.getSignedRequest("create_avatar_upload", params, { content_length: params.contentLength });
|
|
711
|
+
return require_dataMappers.mapMobileAvatarUpload(await this.execute(signedRequest));
|
|
712
|
+
}
|
|
713
|
+
/**
|
|
714
|
+
* Publishes a preset/staged upload, or clears the saved avatar when avatar is null.
|
|
715
|
+
* Uploaded JPEG/PNG images must be square, at most 4096 × 4096 pixels, and within
|
|
716
|
+
* `MOBILE_AVATAR_MAX_UPLOAD_BYTES`. A successful PUT can still fail this publication check.
|
|
717
|
+
*
|
|
718
|
+
* Serialize identity writes for the same subaccount; see {@link MobileClient.setBio}.
|
|
719
|
+
*
|
|
720
|
+
* @throws {MobileServerFailureError} With `INVALID_AVATAR` for an invalid preset, staging key, or image,
|
|
721
|
+
* `INVALID_IDENTITY_TARGET` for an isolated subaccount, `SERVICE_UNAVAILABLE` when storage is unavailable,
|
|
722
|
+
* or `STALE_IDENTITY_UPDATE` when a later write has committed (re-read the profile before retrying).
|
|
723
|
+
*/
|
|
724
|
+
async setAvatar(params) {
|
|
725
|
+
const signedRequest = await this.getSignedRequest("set_avatar", params, { avatar: require_dataMappers.mapMobileAvatarSelectionToServer(params.avatar) });
|
|
726
|
+
return this.execute(signedRequest);
|
|
727
|
+
}
|
|
728
|
+
/**
|
|
729
|
+
* Sets a subaccount's username, derived from the given display name. Upserts: the same call claims a first
|
|
730
|
+
* username and renames an existing one, so callers never need to read the current identity first.
|
|
731
|
+
*
|
|
732
|
+
* Serialize identity writes for the same subaccount; see {@link MobileClient.setBio}.
|
|
733
|
+
*
|
|
734
|
+
* @throws {MobileServerFailureError} With error code `INVALID_DISPLAY_NAME` if the display name violates
|
|
735
|
+
* `MOBILE_DISPLAY_NAME_PATTERN`, `USERNAME_UNAVAILABLE` if the derived username is reserved or already
|
|
736
|
+
* taken by another subaccount, `INVALID_IDENTITY_TARGET` if the sender is in the engine-created isolated
|
|
737
|
+
* namespace, or `STALE_IDENTITY_UPDATE` if another identity write for this subaccount committed with a
|
|
738
|
+
* later nonce (re-read the identity before retrying).
|
|
739
|
+
*/
|
|
740
|
+
async setUsername(params) {
|
|
741
|
+
const signedRequest = await this.getSignedRequest("set_username", params, { display_name: params.displayName });
|
|
742
|
+
return this.execute(signedRequest);
|
|
743
|
+
}
|
|
744
|
+
/**
|
|
745
|
+
* Sets whether a subaccount's profile is private.
|
|
746
|
+
* Serialize identity writes for the same subaccount; see {@link MobileClient.setBio}.
|
|
747
|
+
*/
|
|
748
|
+
async setPrivateMode(params) {
|
|
749
|
+
const signedRequest = await this.getSignedRequest("set_private_mode", params, { private_mode: params.privateMode });
|
|
750
|
+
return this.execute(signedRequest);
|
|
751
|
+
}
|
|
752
|
+
/**
|
|
753
|
+
* Registers an Expo push token for the wallet, transferring active ownership of the token if another
|
|
754
|
+
* wallet had registered it. Each registration advances its generation and cancels old pending deliveries.
|
|
755
|
+
* This legacy method replaces capabilities with v1; use registerExpoTokenV2 consistently after upgrading.
|
|
756
|
+
*
|
|
757
|
+
* @throws {MobileServerFailureError} With error code `INVALID_EXPO_TOKEN` if the token is not a valid Expo
|
|
758
|
+
* push token, or `INVALID_DEVICE_METADATA` if `locale` (max 35 chars) or `appVersion` (max 64 chars) is
|
|
759
|
+
* too long.
|
|
760
|
+
* @deprecated Use {@link registerExpoTokenV2} instead.
|
|
761
|
+
*/
|
|
762
|
+
async registerExpoToken(params) {
|
|
763
|
+
const signedRequest = await this.getSignedRequest("register_expo_token", params, {
|
|
764
|
+
expo_token: params.expoToken,
|
|
765
|
+
platform: params.platform,
|
|
766
|
+
locale: params.locale ?? null,
|
|
767
|
+
app_version: params.appVersion ?? null
|
|
768
|
+
});
|
|
769
|
+
return this.execute(signedRequest);
|
|
770
|
+
}
|
|
771
|
+
/**
|
|
772
|
+
* Registers a device with its actual v2 capabilities; do not use repeated registration as a heartbeat.
|
|
773
|
+
* @param params - Wallet authentication, Expo token, metadata, and supported notification types/routes.
|
|
774
|
+
* @returns Success only; query registration separately for its new generation.
|
|
775
|
+
* @throws {WalletNotProvidedError} If neither a linked signer nor a default wallet is configured.
|
|
776
|
+
* @throws {MobileServerFailureError} On `INVALID_EXPO_TOKEN`, `INVALID_DEVICE_METADATA`,
|
|
777
|
+
* `NOTIFICATION_DEVICE_LIMIT` when the wallet already has 32 active devices, or authentication errors.
|
|
778
|
+
*/
|
|
779
|
+
async registerExpoTokenV2(params) {
|
|
780
|
+
const request = await this.getSignedRequest("register_expo_token_v2", params, {
|
|
781
|
+
expo_token: params.expoToken,
|
|
782
|
+
platform: params.platform,
|
|
783
|
+
locale: params.locale ?? null,
|
|
784
|
+
app_version: params.appVersion ?? null,
|
|
785
|
+
capabilities: require_dataMappers.mapMobileNotificationCapabilitiesToServer(params.capabilities)
|
|
786
|
+
});
|
|
787
|
+
return this.execute(request);
|
|
788
|
+
}
|
|
789
|
+
/**
|
|
790
|
+
* Applies exactly one bell, market, or one-time favorites-import operation.
|
|
791
|
+
* @param params - Wallet authentication and subscription update with the latest subscription revision.
|
|
792
|
+
* @returns Success only; re-query subscriptions for the new revision even after a repeated ON/OFF.
|
|
793
|
+
* @throws {WalletNotProvidedError} If neither a linked signer nor a default wallet is configured.
|
|
794
|
+
* @throws {MobileServerFailureError} On `NOTIFICATION_REVISION_CONFLICT`, `INVALID_NOTIFICATION_REQUEST`, or
|
|
795
|
+
* `INVALID_IDENTITY_TARGET`.
|
|
796
|
+
*/
|
|
797
|
+
async updateNotificationSubscriptions(params) {
|
|
798
|
+
const request = await this.getSignedRequest("update_notification_subscriptions", params, require_dataMappers.mapMobileNotificationSubscriptionsUpdateToServer(params.update));
|
|
799
|
+
return this.execute(request);
|
|
800
|
+
}
|
|
801
|
+
/**
|
|
802
|
+
* Atomically records 1-50 analytics events after the user has consented to analytics.
|
|
803
|
+
* @param params - Wallet authentication and events with stable UUIDs and actual millisecond timestamps.
|
|
804
|
+
* @returns Success only; reuse event IDs on retries. Notification clicks do not mark an inbox item as read.
|
|
805
|
+
* @throws {WalletNotProvidedError} If neither a linked signer nor a default wallet is configured.
|
|
806
|
+
* @throws {MobileServerFailureError} If any event, timestamp, batch size, or notification ownership is invalid.
|
|
807
|
+
*/
|
|
808
|
+
async recordProductEvents(params) {
|
|
809
|
+
const request = await this.getSignedRequest("record_product_events", params, { events: params.events.map(require_dataMappers.mapMobileProductEventToServer) });
|
|
810
|
+
return this.execute(request);
|
|
811
|
+
}
|
|
812
|
+
/**
|
|
813
|
+
* Sets whether the signing subaccount follows a Profile. Both directions are idempotent: following again
|
|
814
|
+
* keeps the original relationship creation time, so it does not move the account in recency order, and
|
|
815
|
+
* unfollowing a relationship that does not exist succeeds with `isFollowing: false`. Unfollowing deletes
|
|
816
|
+
* the relationship rather than deactivating it, so a later follow gets a new creation time and moves the
|
|
817
|
+
* account to the front of recency order.
|
|
818
|
+
*
|
|
819
|
+
* Only `isFollowing: true` is checked against the canonical Query DB subaccount index, so unfollowing still
|
|
820
|
+
* works while that index lags.
|
|
821
|
+
*
|
|
822
|
+
* @throws {MobileServerFailureError} With error code `INVALID_FOLLOW_TARGET` if the target is the sender or
|
|
823
|
+
* either party is isolated, `FOLLOWER_NOT_ELIGIBLE` if the sender is not yet in the canonical Query DB
|
|
824
|
+
* subaccount index, or `FOLLOWING_NOT_FOUND` if the target is not. Both index errors are transient for an
|
|
825
|
+
* account that is being recorded, so they are retryable after catch-up — unlike `INVALID_FOLLOW_TARGET`.
|
|
826
|
+
*/
|
|
827
|
+
async setFollow(params) {
|
|
828
|
+
const signedRequest = await this.getSignedRequest("set_follow", params, {
|
|
829
|
+
subaccount: (0, _nadohq_shared.subaccountToHex)(params.target),
|
|
830
|
+
is_following: params.isFollowing
|
|
831
|
+
});
|
|
832
|
+
return require_dataMappers.mapMobileFollowMutationResult(await this.execute(signedRequest));
|
|
833
|
+
}
|
|
834
|
+
/**
|
|
835
|
+
* Sets whether the signing subaccount follows each of up to `MOBILE_FOLLOW_BATCH_MAX_SIZE` (25) Profiles in
|
|
836
|
+
* one signed request, which costs far less of the shared IP rate limit than one {@link MobileClient.setFollow}
|
|
837
|
+
* per target. The server validates the whole list before writing and commits every target in one database
|
|
838
|
+
* transaction, so the batch either fully applies or changes nothing. Each target has the same idempotent
|
|
839
|
+
* semantics as `setFollow`, so resending a batch is safe.
|
|
840
|
+
*
|
|
841
|
+
* Targets are lowercased before signing but not deduplicated, and two spellings of one subaccount are a
|
|
842
|
+
* duplicate. Longer lists must be split by the caller; each request commits on its own, so earlier chunks
|
|
843
|
+
* stay applied when a later one fails.
|
|
844
|
+
*
|
|
845
|
+
* @returns One result per target, in request order, carrying each target's post-commit follower count.
|
|
846
|
+
* @throws {MobileServerFailureError} With error code `INVALID_FOLLOW_BATCH` if `targets` is empty, holds
|
|
847
|
+
* duplicates, or exceeds the maximum, or `INVALID_FOLLOW_TARGET` if any target is the sender or either party
|
|
848
|
+
* is isolated. Either rejects the whole batch before any write, so do not retry it unchanged.
|
|
849
|
+
*/
|
|
850
|
+
async setFollowBatch(params) {
|
|
851
|
+
const signedRequest = await this.getSignedRequest("set_follow_batch", params, {
|
|
852
|
+
subaccounts: params.targets.map(_nadohq_shared.subaccountToHex),
|
|
853
|
+
is_following: params.isFollowing
|
|
854
|
+
});
|
|
855
|
+
return require_dataMappers.mapMobileFollowBatchResult(await this.execute(signedRequest));
|
|
856
|
+
}
|
|
857
|
+
/**
|
|
858
|
+
* Publishes text, a drawing, or both atomically using the signed author identity.
|
|
859
|
+
* For an idempotent retry, reuse clientRequestId and the exact original content with a valid signature.
|
|
860
|
+
* The SDK does not trim text or reformat the signed drawing JSON.
|
|
861
|
+
* @param params - Author subaccount and signing options, request UUID, owned position, original text and
|
|
862
|
+
* mentions, plus an optional trusted action and original drawing JSON.
|
|
863
|
+
* @returns The published item, including authoritative interaction state and any drawing or comment preview.
|
|
864
|
+
* @throws {WalletNotProvidedError} If neither a linked signer nor a default wallet is configured.
|
|
865
|
+
* @throws {MobileServerFailureError} On authentication, ownership, eligibility, content, mention, or drawing
|
|
866
|
+
* errors, or `SOCIAL_FEED_REQUEST_CONFLICT` when a request UUID is reused with different content. Do not
|
|
867
|
+
* change an earlier request to retry it; use a new UUID for a genuinely new publication.
|
|
868
|
+
* @throws {MobileUnsupportedFeedItemError} If the service returns an unsupported item kind.
|
|
869
|
+
*/
|
|
870
|
+
async createFeedPost(params) {
|
|
871
|
+
const request = await this.getSignedRequest("create_feed_post", params, {
|
|
872
|
+
client_request_id: params.clientRequestId,
|
|
873
|
+
position_id: params.positionId,
|
|
874
|
+
action_id: params.actionId,
|
|
875
|
+
text: params.text,
|
|
876
|
+
mentions: params.mentions.map(require_dataMappers.mapMobileSocialFeedMentionToServer),
|
|
877
|
+
drawing_data_json: params.drawingDataJson,
|
|
878
|
+
image_ids: params.imageIds
|
|
879
|
+
});
|
|
880
|
+
return require_dataMappers.mapMobileSocialFeedItem((await this.execute(request)).item);
|
|
881
|
+
}
|
|
882
|
+
/**
|
|
883
|
+
* Uploads one static JPEG/PNG for a later {@link createFeedPost} via multipart execute.
|
|
884
|
+
* The whole HTTP request must stay within 2 MiB including signature overhead; upload one file per call
|
|
885
|
+
* and bind up to nine ready IDs at publication. There is no complete/PUT step — success means ready.
|
|
886
|
+
* @param params - Author subaccount and signing options, plus the original file bytes.
|
|
887
|
+
* @returns Ready image metadata, including original and thumbnail paths.
|
|
888
|
+
* @throws {WalletNotProvidedError} If neither a linked signer nor a default wallet is configured.
|
|
889
|
+
* @throws {RangeError} If the complete multipart request exceeds {@link MOBILE_FEED_IMAGE_MAX_REQUEST_BYTES}.
|
|
890
|
+
* @throws {MobileServerFailureError} On authentication, format/size/hash errors (`INVALID_SOCIAL_FEED_IMAGE`),
|
|
891
|
+
* or when publishing is disabled (`SERVICE_UNAVAILABLE`), or image storage is unavailable
|
|
892
|
+
* (`SOCIAL_FEED_DATA_UNAVAILABLE`, 6320, HTTP 503).
|
|
893
|
+
*/
|
|
894
|
+
async createFeedPostImageUpload(params) {
|
|
895
|
+
return this.createFeedImageUpload("create_feed_post_image_uploads", params);
|
|
896
|
+
}
|
|
897
|
+
/**
|
|
898
|
+
* Uploads one static JPEG/PNG for a later {@link createFeedComment} via multipart execute.
|
|
899
|
+
* Same size and readiness rules as {@link createFeedPostImageUpload}; comment text remains required.
|
|
900
|
+
* @param params - Author subaccount and signing options, plus the original file bytes.
|
|
901
|
+
* @returns Ready image metadata, including original and thumbnail paths.
|
|
902
|
+
* @throws {WalletNotProvidedError} If neither a linked signer nor a default wallet is configured.
|
|
903
|
+
* @throws {RangeError} If the complete multipart request exceeds {@link MOBILE_FEED_IMAGE_MAX_REQUEST_BYTES}.
|
|
904
|
+
* @throws {MobileServerFailureError} On authentication, format/size/hash errors (`INVALID_SOCIAL_FEED_IMAGE`),
|
|
905
|
+
* or when comments are disabled (`SERVICE_UNAVAILABLE`), or image storage is unavailable
|
|
906
|
+
* (`SOCIAL_FEED_DATA_UNAVAILABLE`, 6320, HTTP 503).
|
|
907
|
+
*/
|
|
908
|
+
async createFeedCommentImageUpload(params) {
|
|
909
|
+
return this.createFeedImageUpload("create_feed_comment_image_uploads", params);
|
|
910
|
+
}
|
|
911
|
+
/**
|
|
912
|
+
* First attaches a drawing to an owned post or trade card while the author still holds its position.
|
|
913
|
+
* The original JSON is signed unchanged; false and zero are valid drawing documents.
|
|
914
|
+
* For an exact retry after a timeout, generate a nonce up front with {@link getMobileNonce} and reuse
|
|
915
|
+
* that nonce and the original JSON before its receive deadline. A fresh nonce is not an exact replay.
|
|
916
|
+
* If a retry returns `SOCIAL_FEED_DRAWING_EXISTS`, use {@link getFeedChartDrawing} to confirm that the
|
|
917
|
+
* stored data matches the intended drawing before treating the original create as successful.
|
|
918
|
+
* @param params - Author subaccount and signing options, parent item, and complete original drawing JSON.
|
|
919
|
+
* @returns The parent ID and updated version together with the stored drawing.
|
|
920
|
+
* @throws {WalletNotProvidedError} If neither a linked signer nor a default wallet is configured.
|
|
921
|
+
* @throws {MobileServerFailureError} On authentication, ownership, eligibility, or invalid/oversized drawing
|
|
922
|
+
* errors, an unavailable parent, or `SOCIAL_FEED_DRAWING_EXISTS` for a conflicting existing drawing.
|
|
923
|
+
* Read the existing drawing and use updateFeedChartDrawing when replacement is intended.
|
|
924
|
+
*/
|
|
925
|
+
async createFeedChartDrawing(params) {
|
|
926
|
+
const request = await this.getSignedRequest("create_feed_chart_drawing", params, {
|
|
927
|
+
item_id: params.itemId,
|
|
928
|
+
data_json: params.dataJson
|
|
929
|
+
});
|
|
930
|
+
return require_dataMappers.mapMobileSocialFeedDrawingMutationResult(await this.execute(request));
|
|
931
|
+
}
|
|
932
|
+
/**
|
|
933
|
+
* Replaces an existing drawing, including after the associated position has closed.
|
|
934
|
+
* Serialize writes per item and preserve the original JSON text when retrying.
|
|
935
|
+
* @param params - Author subaccount and signing options, parent item, and complete replacement JSON.
|
|
936
|
+
* @returns The parent ID and updated version together with the stored replacement drawing.
|
|
937
|
+
* @throws {WalletNotProvidedError} If neither a linked signer nor a default wallet is configured.
|
|
938
|
+
* @throws {MobileServerFailureError} On authentication, ownership, or invalid/oversized drawing errors, an
|
|
939
|
+
* unavailable parent or drawing, or `STALE_SOCIAL_FEED_DRAWING_UPDATE`. Re-read the drawing before retrying
|
|
940
|
+
* a stale or conflicting update instead of blindly replacing newer content.
|
|
941
|
+
*/
|
|
942
|
+
async updateFeedChartDrawing(params) {
|
|
943
|
+
const request = await this.getSignedRequest("update_feed_chart_drawing", params, {
|
|
944
|
+
item_id: params.itemId,
|
|
945
|
+
data_json: params.dataJson
|
|
946
|
+
});
|
|
947
|
+
return require_dataMappers.mapMobileSocialFeedDrawingMutationResult(await this.execute(request));
|
|
948
|
+
}
|
|
949
|
+
/**
|
|
950
|
+
* Publishes a comment or reply atomically; an invalid position attachment rejects the entire request.
|
|
951
|
+
* For an idempotent retry, reuse clientRequestId and the unmodified text, mentions, and attachment.
|
|
952
|
+
* @param params - Author subaccount and signing options, request UUID, root item, original nonblank text
|
|
953
|
+
* and mentions, plus an optional reply target in the same thread and currently owned position attachment.
|
|
954
|
+
* @returns The created reply and authoritative root comment count; this write does not create a reading session.
|
|
955
|
+
* @throws {WalletNotProvidedError} If neither a linked signer nor a default wallet is configured.
|
|
956
|
+
* @throws {MobileServerFailureError} On authentication, inaccessible content, invalid text/mentions/reply
|
|
957
|
+
* relationships, an ineligible attachment, or `SOCIAL_FEED_REQUEST_CONFLICT`. Correct invalid input before
|
|
958
|
+
* a new submission, and never reuse an existing request UUID with different content.
|
|
959
|
+
*/
|
|
960
|
+
async createFeedComment(params) {
|
|
961
|
+
const request = await this.getSignedRequest("create_feed_comment", params, {
|
|
962
|
+
client_request_id: params.clientRequestId,
|
|
963
|
+
root_item_id: params.rootItemId,
|
|
964
|
+
reply_to_item_id: params.replyToItemId,
|
|
965
|
+
text: params.text,
|
|
966
|
+
mentions: params.mentions.map(require_dataMappers.mapMobileSocialFeedMentionToServer),
|
|
967
|
+
attached_position_id: params.attachedPositionId,
|
|
968
|
+
image_ids: params.imageIds
|
|
969
|
+
});
|
|
970
|
+
return require_dataMappers.mapMobileSocialFeedCommentResult(await this.execute(request));
|
|
971
|
+
}
|
|
972
|
+
/**
|
|
973
|
+
* Sets or clears a signed user's like without requiring an open position.
|
|
974
|
+
* Serialize mutations per item and author. Retrying the same isLiked state with a fresh nonce is safe
|
|
975
|
+
* when no newer change intervenes; an unchanged state does not increment the count or version again.
|
|
976
|
+
* Pass the original nonce on a retry before its deadline to avoid overwriting a newer change from
|
|
977
|
+
* another device. Re-read the current state if that retry conflicts.
|
|
978
|
+
* @param params - Acting subaccount and signing options, interactive item, and desired like state.
|
|
979
|
+
* @returns The applied like state, authoritative count, and item version after the mutation.
|
|
980
|
+
* @throws {WalletNotProvidedError} If neither a linked signer nor a default wallet is configured.
|
|
981
|
+
* @throws {MobileServerFailureError} On authentication errors, inaccessible or non-interactive content,
|
|
982
|
+
* or `STALE_SOCIAL_FEED_LIKE_UPDATE`. Re-read the current state before submitting a new mutation after a conflict.
|
|
983
|
+
*/
|
|
984
|
+
async setFeedLike(params) {
|
|
985
|
+
const request = await this.getSignedRequest("set_feed_like", params, {
|
|
986
|
+
item_id: params.itemId,
|
|
987
|
+
is_liked: params.isLiked
|
|
988
|
+
});
|
|
989
|
+
return require_dataMappers.mapMobileSocialFeedLikeResult(await this.execute(request));
|
|
990
|
+
}
|
|
991
|
+
async getSignedRequest(type, params, innerParams) {
|
|
992
|
+
const walletClient = this.opts.linkedSignerWalletClient ?? this.opts.walletClient;
|
|
993
|
+
if (walletClient == null) throw new _nadohq_shared.WalletNotProvidedError();
|
|
994
|
+
const inner = {
|
|
995
|
+
type,
|
|
996
|
+
...innerParams
|
|
997
|
+
};
|
|
998
|
+
return require_signing_buildSignedMobileRequest.buildSignedMobileRequest({
|
|
999
|
+
...params,
|
|
1000
|
+
walletClient,
|
|
1001
|
+
inner
|
|
1002
|
+
});
|
|
1003
|
+
}
|
|
1004
|
+
async publicQuery(body) {
|
|
1005
|
+
const response = await this.axiosInstance.post(`${this.opts.url}/public_query`, body);
|
|
1006
|
+
this.checkResponseStatus(response);
|
|
1007
|
+
this.checkServerStatus(response);
|
|
1008
|
+
return response.data;
|
|
1009
|
+
}
|
|
1010
|
+
async publicGetBytes(url, headers) {
|
|
1011
|
+
const response = await this.axiosInstance.get(url, {
|
|
1012
|
+
responseType: "arraybuffer",
|
|
1013
|
+
headers
|
|
1014
|
+
});
|
|
1015
|
+
if (response.status < 200 || response.status >= 300) {
|
|
1016
|
+
const responseText = (0, viem.bytesToString)(new Uint8Array(response.data));
|
|
1017
|
+
let errorData;
|
|
1018
|
+
try {
|
|
1019
|
+
errorData = JSON.parse(responseText);
|
|
1020
|
+
} catch {
|
|
1021
|
+
errorData = responseText;
|
|
1022
|
+
}
|
|
1023
|
+
this.checkResponseStatus({
|
|
1024
|
+
...response,
|
|
1025
|
+
data: errorData
|
|
1026
|
+
});
|
|
1027
|
+
}
|
|
1028
|
+
return new Uint8Array(response.data);
|
|
1029
|
+
}
|
|
1030
|
+
async publicExecute(body) {
|
|
1031
|
+
const response = await this.axiosInstance.post(`${this.opts.url}/public_execute`, body);
|
|
1032
|
+
this.checkResponseStatus(response);
|
|
1033
|
+
this.checkServerStatus(response);
|
|
1034
|
+
return response.data;
|
|
1035
|
+
}
|
|
1036
|
+
/**
|
|
1037
|
+
* Sends an authenticated read through the signed query route.
|
|
1038
|
+
* @param body - Canonical inner payload with its signature, sender, and nonce.
|
|
1039
|
+
* @returns The successful query envelope and its type-specific payload.
|
|
1040
|
+
* @throws {MobileServerFailureError} For a structured service failure, including non-2xx responses.
|
|
1041
|
+
*/
|
|
1042
|
+
async query(body) {
|
|
1043
|
+
const response = await this.axiosInstance.post(`${this.opts.url}/query`, body);
|
|
1044
|
+
this.checkResponseStatus(response);
|
|
1045
|
+
this.checkServerStatus(response);
|
|
1046
|
+
return response.data;
|
|
1047
|
+
}
|
|
1048
|
+
async execute(body, fileBytes) {
|
|
1049
|
+
const multipart = fileBytes == null ? void 0 : require_utils_buildMobileFeedImageMultipart.buildMobileFeedImageMultipart(JSON.stringify(body), fileBytes);
|
|
1050
|
+
if (multipart) this.checkFeedImageRequestSize(multipart.body.byteLength);
|
|
1051
|
+
const response = await this.axiosInstance.post(`${this.opts.url}/execute`, multipart?.body ?? body, multipart ? { headers: { "Content-Type": multipart.contentType } } : void 0);
|
|
1052
|
+
this.checkResponseStatus(response);
|
|
1053
|
+
this.checkServerStatus(response);
|
|
1054
|
+
return response.data;
|
|
1055
|
+
}
|
|
1056
|
+
async createFeedImageUpload(type, params) {
|
|
1057
|
+
const nonce = params.nonce ?? require_signing_nonce.getMobileNonce();
|
|
1058
|
+
const sizePayload = {
|
|
1059
|
+
type,
|
|
1060
|
+
content_hash: viem.zeroHash,
|
|
1061
|
+
signature: `0x${"00".repeat(65)}`,
|
|
1062
|
+
sender: (0, _nadohq_shared.subaccountToHex)(params),
|
|
1063
|
+
nonce: nonce.toString()
|
|
1064
|
+
};
|
|
1065
|
+
const overhead = require_utils_buildMobileFeedImageMultipart.buildMobileFeedImageMultipart(JSON.stringify(sizePayload), new Uint8Array()).body.byteLength;
|
|
1066
|
+
this.checkFeedImageRequestSize(overhead + params.fileBytes.byteLength);
|
|
1067
|
+
const contentHash = (0, viem.keccak256)(params.fileBytes);
|
|
1068
|
+
const request = await this.getSignedRequest(type, {
|
|
1069
|
+
...params,
|
|
1070
|
+
nonce
|
|
1071
|
+
}, { content_hash: contentHash });
|
|
1072
|
+
return require_dataMappers.mapMobileSocialFeedImage((await this.execute(request, params.fileBytes)).image);
|
|
1073
|
+
}
|
|
1074
|
+
checkFeedImageRequestSize(byteLength) {
|
|
1075
|
+
if (byteLength > 2097152) throw new RangeError(`Feed image upload request exceeds ${require_utils_feed.MOBILE_FEED_IMAGE_MAX_REQUEST_BYTES} bytes (2 MiB).`);
|
|
1076
|
+
}
|
|
1077
|
+
/**
|
|
1078
|
+
* Validates the HTTP status before interpreting the body. Unlike the engine, the mobile backend returns
|
|
1079
|
+
* failure envelopes with non-2xx statuses (e.g. 404 for `PROFILE_NOT_FOUND`), so a non-2xx response with a
|
|
1080
|
+
* failure envelope still throws the typed error; anything else is a transport-level error.
|
|
1081
|
+
*/
|
|
1082
|
+
checkResponseStatus(response) {
|
|
1083
|
+
if (response.status >= 200 && response.status < 300) return;
|
|
1084
|
+
if (require_utils_serverResponseGuards.isMobileServerFailureResponse(response.data)) throw new require_types_MobileServerFailureError.MobileServerFailureError(response.data, response.status);
|
|
1085
|
+
throw new Error(`Unexpected response from mobile service: ${response.status} ${response.statusText}. Data: ${JSON.stringify(response.data)}`);
|
|
1086
|
+
}
|
|
1087
|
+
checkServerStatus(response) {
|
|
1088
|
+
const { data } = response;
|
|
1089
|
+
if (require_utils_serverResponseGuards.isMobileServerFailureResponse(data)) throw new require_types_MobileServerFailureError.MobileServerFailureError(data, response.status);
|
|
1090
|
+
if (!require_utils_serverResponseGuards.isMobileServerSuccessResponse(data)) throw new Error(`Unexpected response from mobile service: missing success envelope. Data: ${JSON.stringify(data)}`);
|
|
1091
|
+
}
|
|
1092
|
+
};
|
|
1093
|
+
//#endregion
|
|
1094
|
+
Object.defineProperty(exports, "MobileClient", {
|
|
1095
|
+
enumerable: true,
|
|
1096
|
+
get: function() {
|
|
1097
|
+
return MobileClient;
|
|
1098
|
+
}
|
|
1099
|
+
});
|
|
1100
|
+
|
|
1101
|
+
//# sourceMappingURL=MobileClient-M4oC4lrX.cjs.map
|