@nadohq/mobile-client 0.65.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 +107 -8
- package/dist/{MobileClient-CfVZXTcz.cjs → MobileClient-M4oC4lrX.cjs} +258 -16
- package/dist/MobileClient-M4oC4lrX.cjs.map +1 -0
- package/dist/MobileClient.cjs +1 -1
- package/dist/MobileClient.d.cts +146 -16
- package/dist/MobileClient.d.cts.map +1 -1
- package/dist/MobileClient.d.ts +146 -16
- package/dist/MobileClient.d.ts.map +1 -1
- package/dist/MobileClient.js +258 -16
- package/dist/MobileClient.js.map +1 -1
- package/dist/{MobileServerFailureError-BZVwlsMg.d.ts → MobileServerFailureError-C9iqNsxI.d.ts} +2 -3
- package/dist/MobileServerFailureError-C9iqNsxI.d.ts.map +1 -0
- package/dist/{MobileServerFailureError-CbtK8kD4.d.cts → MobileServerFailureError-MtS2reel.d.cts} +2 -3
- package/dist/MobileServerFailureError-MtS2reel.d.cts.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-UeeWdYGU.d.ts → buildSignedMobileRequest-BR-KJhIF.d.ts} +2 -2
- package/dist/{buildSignedMobileRequest-UeeWdYGU.d.ts.map → buildSignedMobileRequest-BR-KJhIF.d.ts.map} +1 -1
- package/dist/{buildSignedMobileRequest-C1v0flCR.d.cts → buildSignedMobileRequest-DyKCK34Y.d.cts} +2 -2
- package/dist/{buildSignedMobileRequest-C1v0flCR.d.cts.map → buildSignedMobileRequest-DyKCK34Y.d.cts.map} +1 -1
- package/dist/{canonicalize-5eeZrkzQ.d.ts → canonicalize-Bv6UIAbR.d.ts} +2 -2
- package/dist/canonicalize-Bv6UIAbR.d.ts.map +1 -0
- package/dist/{canonicalize-CBaZprTo.d.cts → canonicalize-CWh3XZzj.d.cts} +2 -2
- package/dist/canonicalize-CWh3XZzj.d.cts.map +1 -0
- package/dist/{clientTypes-C9dJufxk.d.ts → clientTypes-BUn5_OzK.d.ts} +297 -20
- package/dist/clientTypes-BUn5_OzK.d.ts.map +1 -0
- package/dist/{clientTypes-_mEgzmNs.d.cts → clientTypes-DOpUcu80.d.cts} +297 -20
- package/dist/clientTypes-DOpUcu80.d.cts.map +1 -0
- package/dist/dataMappers.cjs +203 -5
- package/dist/dataMappers.cjs.map +1 -1
- package/dist/dataMappers.d.cts +70 -7
- package/dist/dataMappers.d.cts.map +1 -1
- package/dist/dataMappers.d.ts +70 -7
- package/dist/dataMappers.d.ts.map +1 -1
- package/dist/dataMappers.js +192 -6
- package/dist/dataMappers.js.map +1 -1
- package/dist/{eip712MethodByType-D8jLoxDu.d.cts → eip712MethodByType-CJ6BoayT.d.cts} +2 -2
- package/dist/eip712MethodByType-CJ6BoayT.d.cts.map +1 -0
- package/dist/{eip712MethodByType-DcUh8h-l.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 +7 -2
- package/dist/index.d.cts +14 -16
- package/dist/index.d.ts +14 -16
- package/dist/index.js +4 -3
- package/dist/{mobileErrorCodes-CmjYEIYm.d.ts → mobileErrorCodes-vD6rbFuF.d.cts} +8 -3
- package/dist/mobileErrorCodes-vD6rbFuF.d.cts.map +1 -0
- package/dist/{mobileErrorCodes-CmjYEIYm.d.cts → mobileErrorCodes-vD6rbFuF.d.ts} +8 -3
- package/dist/mobileErrorCodes-vD6rbFuF.d.ts.map +1 -0
- package/dist/{payloadHash-DhHmgRqL.d.cts → payloadHash-CdkF2Ocr.d.cts} +2 -2
- package/dist/payloadHash-CdkF2Ocr.d.cts.map +1 -0
- package/dist/{payloadHash-E1_8fpLW.d.ts → payloadHash-HD29K77M.d.ts} +2 -2
- package/dist/payloadHash-HD29K77M.d.ts.map +1 -0
- package/dist/{serverExecuteTypes-B-OJok19.d.cts → serverExecuteTypes-5JyyIXRK.d.ts} +21 -5
- package/dist/serverExecuteTypes-5JyyIXRK.d.ts.map +1 -0
- package/dist/{serverExecuteTypes-BwWGspOg.d.ts → serverExecuteTypes-CHrQ9Rtq.d.cts} +21 -5
- package/dist/serverExecuteTypes-CHrQ9Rtq.d.cts.map +1 -0
- package/dist/{serverModelTypes-CiA-dy1R.d.ts → serverModelTypes-CGUZCi0y.d.cts} +163 -8
- package/dist/serverModelTypes-CGUZCi0y.d.cts.map +1 -0
- package/dist/{serverModelTypes-CiA-dy1R.d.cts → serverModelTypes-CGUZCi0y.d.ts} +163 -8
- package/dist/serverModelTypes-CGUZCi0y.d.ts.map +1 -0
- package/dist/{serverResponseGuards-CShiXpHT.d.ts → serverResponseGuards-Bvw8ltYJ.d.ts} +2 -2
- package/dist/{serverResponseGuards-CShiXpHT.d.ts.map → serverResponseGuards-Bvw8ltYJ.d.ts.map} +1 -1
- package/dist/{serverResponseGuards-BW69PS7O.d.cts → serverResponseGuards-i1njcYKN.d.cts} +2 -2
- package/dist/{serverResponseGuards-BW69PS7O.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 +51 -2
- 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 +51 -2
- package/dist/signing/canonicalize.js.map +1 -1
- package/dist/signing/eip712MethodByType.cjs +7 -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 +7 -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/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 +4 -0
- package/dist/types/index.d.cts +8 -9
- package/dist/types/index.d.ts +8 -9
- package/dist/types/index.js +3 -2
- package/dist/types/mobileErrorCodes.cjs +11 -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 +11 -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 +388 -11
- package/src/dataMappers.test.ts +108 -2
- package/src/dataMappers.ts +253 -5
- package/src/feedImages.test.ts +309 -0
- package/src/notifications.test.ts +950 -0
- package/src/signing/canonicalize.ts +66 -0
- package/src/signing/eip712MethodByType.ts +10 -0
- package/src/signing/signing.test.ts +16 -1
- package/src/signing/types.ts +51 -9
- package/src/socialFeed.test.ts +38 -2
- package/src/types/MobileUnsupportedNotificationRouteError.ts +16 -0
- package/src/types/clientTypes.ts +372 -16
- package/src/types/index.ts +1 -0
- package/src/types/mobileErrorCodes.ts +10 -0
- package/src/types/serverExecuteTypes.ts +20 -0
- package/src/types/serverModelTypes.ts +205 -6
- package/src/types/serverQueryTypes.ts +74 -5
- package/src/types/serverRequestTypes.ts +101 -12
- 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-CfVZXTcz.cjs.map +0 -1
- package/dist/MobileServerFailureError-BZVwlsMg.d.ts.map +0 -1
- package/dist/MobileServerFailureError-CbtK8kD4.d.cts.map +0 -1
- package/dist/canonicalize-5eeZrkzQ.d.ts.map +0 -1
- package/dist/canonicalize-CBaZprTo.d.cts.map +0 -1
- package/dist/clientTypes-C9dJufxk.d.ts.map +0 -1
- package/dist/clientTypes-_mEgzmNs.d.cts.map +0 -1
- package/dist/eip712MethodByType-D8jLoxDu.d.cts.map +0 -1
- package/dist/eip712MethodByType-DcUh8h-l.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-CmjYEIYm.d.cts.map +0 -1
- package/dist/mobileErrorCodes-CmjYEIYm.d.ts.map +0 -1
- package/dist/payloadHash-DhHmgRqL.d.cts.map +0 -1
- package/dist/payloadHash-E1_8fpLW.d.ts.map +0 -1
- package/dist/serverBaseTypes-B5J1_TyC.d.cts +0 -25
- package/dist/serverBaseTypes-B5J1_TyC.d.cts.map +0 -1
- package/dist/serverBaseTypes-DnLzsdm-.d.ts +0 -25
- package/dist/serverBaseTypes-DnLzsdm-.d.ts.map +0 -1
- package/dist/serverExecuteTypes-B-OJok19.d.cts.map +0 -1
- package/dist/serverExecuteTypes-BwWGspOg.d.ts.map +0 -1
- package/dist/serverModelTypes-CiA-dy1R.d.cts.map +0 -1
- package/dist/serverModelTypes-CiA-dy1R.d.ts.map +0 -1
- package/dist/serverQueryTypes-CJcjLB7n.d.ts +0 -283
- package/dist/serverQueryTypes-CJcjLB7n.d.ts.map +0 -1
- package/dist/serverQueryTypes-V1f9yE7L.d.cts +0 -283
- package/dist/serverQueryTypes-V1f9yE7L.d.cts.map +0 -1
- package/dist/serverRequestTypes-CRlkNSu5.d.cts +0 -270
- package/dist/serverRequestTypes-CRlkNSu5.d.cts.map +0 -1
- package/dist/serverRequestTypes-DZoOhV2o.d.ts +0 -270
- package/dist/serverRequestTypes-DZoOhV2o.d.ts.map +0 -1
- package/dist/types-BiRmH5Iv.d.cts +0 -108
- package/dist/types-BiRmH5Iv.d.cts.map +0 -1
- package/dist/types-DoJuq0Ij.d.ts +0 -108
- package/dist/types-DoJuq0Ij.d.ts.map +0 -1
package/README.md
CHANGED
|
@@ -52,6 +52,10 @@ await mobile.setUsername({
|
|
|
52
52
|
`getSelfFeedPositions`, `resolveFeedPosition`, `resolveFeedAction`, `getFeedChartDrawing`, `getFeedComments`,
|
|
53
53
|
`getPositionHistory`, `getPositionChart`, `getPositionWatchers`.
|
|
54
54
|
|
|
55
|
+
`getNotificationRegistrationV2` and `getNotificationSettingsV2` use an active Expo token as their credential,
|
|
56
|
+
not a wallet signature. Before displaying wallet settings, compare the wallet returned by `getRegisteredWallet`
|
|
57
|
+
with the connected wallet (case-insensitively).
|
|
58
|
+
|
|
55
59
|
`getProfiles` is the only profile route: it batches up to 25 subaccounts, returns them in the requested order,
|
|
56
60
|
and carries follower totals (`include.followCounts`) and a follow summary (`include.followSummary.viewAs`) as
|
|
57
61
|
opt-in includes, so use it for a single subaccount too. The backend still serves the older singular `profile`
|
|
@@ -70,10 +74,12 @@ page is ordered by the listed relationship alone and `isFollowing` is absent rat
|
|
|
70
74
|
|
|
71
75
|
`getFeed` returns the global trade feed. Session-based feeds include `getForYouFeed`, `getTopTradersFeed`,
|
|
72
76
|
and `getFriendsFeed` (requires `viewAs`), plus `getProfileFeed`, `getMarketFeed`, and `getPositionFeed`.
|
|
73
|
-
`getFeedItem` reads one item; `
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
+
`getFeedItem` reads one item; pass `viewEventId` when the user navigates into the detail so a later
|
|
78
|
+
`recordFeedViews` can count that visit, and omit it for prefetch. `getFeedUpdates` polls session patches
|
|
79
|
+
using the returned `viewerToken`. All are unsigned. Profile, position, and item reads include the `viewAs`
|
|
80
|
+
account's own hidden content under `account_view`; the viewing account is not proof of wallet ownership.
|
|
81
|
+
Prices are decimal `BigNumber` values; quantities, notionals, and PnL retain x18 units. See method and
|
|
82
|
+
parameter JSDoc for session and polling rules.
|
|
77
83
|
|
|
78
84
|
`getSelfFeedPositions`, `resolveFeedPosition`, and `resolveFeedAction` require `viewAs` and return eligibility
|
|
79
85
|
hints for that account, not authenticated permissions. `getFeedComments` supports anchored, bidirectional
|
|
@@ -87,18 +93,111 @@ registering presence. Watching account previews are self-reported, not proof of
|
|
|
87
93
|
|
|
88
94
|
### Public Executes
|
|
89
95
|
|
|
90
|
-
`unregisterExpoToken`, `updateNotificationPreferences`. These are authenticated by possession of an active Expo
|
|
96
|
+
`unregisterExpoToken`, `updateNotificationPreferences`, `updateNotificationSettingsV2`. These are authenticated by possession of an active Expo
|
|
91
97
|
push token rather than a wallet signature, so they still work at logout when a signature may be unobtainable.
|
|
92
98
|
|
|
93
99
|
`recordFeedViews` and `setPositionPresence` use reading-session credentials rather than wallet signatures.
|
|
94
|
-
|
|
100
|
+
Exposure follows `readSession.viewTracking.mode === 'detail_visit'`: after the primary detail target is shown
|
|
101
|
+
in the foreground, call `recordFeedViews` with the same `viewEventId` previously sent to `getFeedItem`, plus
|
|
102
|
+
that response's `sessionId` / `viewerToken` and exactly one detail-target `itemId`. Reuse the event on retries
|
|
103
|
+
for the same visit; generate a new UUID only after leaving and re-entering. Fetch image bytes with
|
|
104
|
+
`getFeedImageBytes` using the same session credentials and paths from `images` / `thumbnail.url`. Legitimate
|
|
105
|
+
session reads renew the idle expiration; use the latest `expiresAtMs` rather than treating the first value as
|
|
106
|
+
fixed.
|
|
107
|
+
|
|
108
|
+
For React Native `Image` or expo-image, use `getFeedImageRequest` to pass the authenticated
|
|
109
|
+
URL and headers directly without converting bytes to base64:
|
|
110
|
+
|
|
111
|
+
```ts
|
|
112
|
+
const { url, headers } = mobile.getFeedImageRequest({
|
|
113
|
+
path: image.url,
|
|
114
|
+
sessionId: readSession.sessionId,
|
|
115
|
+
viewerToken: readSession.viewerToken,
|
|
116
|
+
});
|
|
117
|
+
const source = { uri: url, headers };
|
|
118
|
+
```
|
|
95
119
|
|
|
96
120
|
### Signed Executes
|
|
97
121
|
|
|
98
122
|
`setUsername`, `setBio`, `createAvatarUpload`, `setAvatar`, `setPrivateMode`, `registerExpoToken`, `setFollow`,
|
|
99
|
-
`createFeedPost`, `createFeedComment`, `
|
|
123
|
+
`createFeedPost`, `createFeedComment`, `createFeedPostImageUpload`, `createFeedCommentImageUpload`,
|
|
124
|
+
`createFeedChartDrawing`, `updateFeedChartDrawing`, `setFeedLike`, `registerExpoTokenV2`,
|
|
125
|
+
`updateNotificationSubscriptions`, `recordProductEvents`.
|
|
126
|
+
|
|
127
|
+
Upload images one at a time with the multipart helpers (≤ 2 MiB whole request), then pass ordered ready
|
|
128
|
+
`imageIds` to `createFeedPost` / `createFeedComment`. The SDK throws `RangeError` before requesting a signature or sending a request
|
|
129
|
+
that exceeds `MOBILE_FEED_IMAGE_MAX_REQUEST_BYTES`, including the signed payload and multipart framing.
|
|
130
|
+
Unconfigured image storage returns `SOCIAL_FEED_DATA_UNAVAILABLE` (6320, HTTP 503).
|
|
131
|
+
Posts still require nonblank text or a drawing; comments
|
|
132
|
+
still require nonblank text. See method and parameter JSDoc for publication, retries, mention offsets, drawing
|
|
133
|
+
data, and mutation ordering.
|
|
134
|
+
|
|
135
|
+
### Signed Queries
|
|
136
|
+
|
|
137
|
+
`getNotificationSubscriptions` and `getNotificationInboxV2` use wallet authentication on `/query`.
|
|
138
|
+
They do not require an Expo token or system push permission. The configured linked signer is supported.
|
|
139
|
+
|
|
140
|
+
### Notifications V2
|
|
141
|
+
|
|
142
|
+
The notification v2 operations are available on `MobileClient`, including `client.context.mobileClient` from
|
|
143
|
+
`@nadohq/client`. Settings, capabilities, subscriptions, inbox data, and product events use camelCase SDK models.
|
|
144
|
+
The SDK maps requests to snake_case wire fields and removes the success envelope from read results.
|
|
145
|
+
|
|
146
|
+
```ts
|
|
147
|
+
const auth = {
|
|
148
|
+
subaccountOwner: walletClient.account.address,
|
|
149
|
+
subaccountName: 'default',
|
|
150
|
+
chainId: ink.id,
|
|
151
|
+
verifyingAddr: '0x...' as const,
|
|
152
|
+
};
|
|
153
|
+
|
|
154
|
+
await mobile.registerExpoTokenV2({
|
|
155
|
+
...auth,
|
|
156
|
+
expoToken,
|
|
157
|
+
platform: 'ios',
|
|
158
|
+
capabilities: {
|
|
159
|
+
payloadVersions: [2],
|
|
160
|
+
typeIds: ['order_fill', 'new_follower'],
|
|
161
|
+
routes: ['portfolio', 'profile'],
|
|
162
|
+
},
|
|
163
|
+
});
|
|
164
|
+
const registration = await mobile.getNotificationRegistrationV2({ expoToken });
|
|
165
|
+
const current = await mobile.getNotificationSettingsV2({ expoToken });
|
|
166
|
+
const saved = await mobile.updateNotificationSettingsV2({
|
|
167
|
+
expoToken,
|
|
168
|
+
expectedRevision: current.revision,
|
|
169
|
+
settings: { ...current.settings, positionThresholds: [25] },
|
|
170
|
+
});
|
|
171
|
+
|
|
172
|
+
const subscriptions = await mobile.getNotificationSubscriptions(auth);
|
|
173
|
+
await mobile.updateNotificationSubscriptions({
|
|
174
|
+
...auth,
|
|
175
|
+
update: {
|
|
176
|
+
expectedRevision: subscriptions.revision,
|
|
177
|
+
market: { productId: 2, subscribed: true },
|
|
178
|
+
},
|
|
179
|
+
});
|
|
180
|
+
const updatedSubscriptions = await mobile.getNotificationSubscriptions(auth);
|
|
181
|
+
const inbox = await mobile.getNotificationInboxV2({ ...auth, limit: 20 });
|
|
182
|
+
```
|
|
100
183
|
|
|
101
|
-
|
|
184
|
+
- Declare only types/routes the application handles. Re-registration advances the generation and cancels
|
|
185
|
+
old pending deliveries; calling legacy `registerExpoToken` resets capabilities to v1.
|
|
186
|
+
- Settings replacement requires every field. Settings and subscription revisions are independent.
|
|
187
|
+
On `MOBILE_ERROR_CODES.NOTIFICATION_REVISION_CONFLICT` (6203), re-read and merge only the current user change.
|
|
188
|
+
- A subscription update selects exactly one operation; omit the other operations and the SDK sends them as `null`. Successful subscription
|
|
189
|
+
updates return only status, so re-query even after repeated ON/OFF. Favorites import merges once, never replaces.
|
|
190
|
+
- Enabling a bell requires following the target. Unfollowing clears its bell without advancing the subscription
|
|
191
|
+
revision; refresh subscriptions after follow mutations. Bells are Identity-scoped; markets are wallet-scoped.
|
|
192
|
+
Pass `traderBell.subaccount` as a `Subaccount` (`subaccountOwner` and `subaccountName`); the SDK encodes it for signing.
|
|
193
|
+
- Inbox pages are accepted intents, not delivery/read receipts. There is no title/body, unread count, mark-read,
|
|
194
|
+
or delete operation. Do not use the unimplemented legacy `notification_history` route.
|
|
195
|
+
An unknown destination rejects the page with `MobileUnsupportedNotificationRouteError`.
|
|
196
|
+
- `recordProductEvents({ ...auth, events })` accepts 1-50 events atomically. Provide the fields required by `eventName`,
|
|
197
|
+
actual millisecond timestamps, and stable `clientEventId` UUIDs across retries. The SDK fills unused wire fields with `null`. Supported
|
|
198
|
+
names are `notif_opened`, `market_viewed`, `chart_opened`, and `search`; obtain analytics consent first.
|
|
199
|
+
- Legacy preferences remain supported and synchronize overlapping v2 fields. Keep legacy push parsing because
|
|
200
|
+
order notifications may use a v1 fallback even for v2 registrations.
|
|
102
201
|
|
|
103
202
|
### Linked Signers
|
|
104
203
|
|
|
@@ -21,12 +21,16 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
21
21
|
}) : target, mod));
|
|
22
22
|
//#endregion
|
|
23
23
|
const require_dataMappers = require("./dataMappers.cjs");
|
|
24
|
+
const require_signing_nonce = require("./signing/nonce.cjs");
|
|
24
25
|
const require_signing_buildSignedMobileRequest = require("./signing/buildSignedMobileRequest.cjs");
|
|
25
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");
|
|
26
29
|
const require_utils_serverResponseGuards = require("./utils/serverResponseGuards.cjs");
|
|
27
30
|
let _nadohq_shared = require("@nadohq/shared");
|
|
28
31
|
let axios = require("axios");
|
|
29
32
|
axios = __toESM(axios, 1);
|
|
33
|
+
let viem = require("viem");
|
|
30
34
|
//#region src/MobileClient.ts
|
|
31
35
|
/**
|
|
32
36
|
* Client for the Nado mobile service API: usernames, bios, avatars, public profile lookups, the global
|
|
@@ -277,7 +281,9 @@ var MobileClient = class {
|
|
|
277
281
|
/**
|
|
278
282
|
* Reads one item visible to viewAs, including that account's own hidden content.
|
|
279
283
|
* Creates an item session directly when sessionId is omitted.
|
|
280
|
-
* @
|
|
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.
|
|
281
287
|
* @returns The complete item and authorized reading session.
|
|
282
288
|
* @throws {MobileServerFailureError} On inaccessible content or session mismatch/expiry.
|
|
283
289
|
* @throws {MobileUnsupportedFeedItemError} If the service returns an unsupported item kind.
|
|
@@ -286,6 +292,7 @@ var MobileClient = class {
|
|
|
286
292
|
const body = {
|
|
287
293
|
type: "feed_item",
|
|
288
294
|
item_id: params.itemId,
|
|
295
|
+
view_event_id: params.viewEventId,
|
|
289
296
|
comment_preview_limit: params.commentPreviewLimit,
|
|
290
297
|
session_id: params.sessionId,
|
|
291
298
|
...require_dataMappers.mapMobileSocialFeedReadParamsToServer(params)
|
|
@@ -323,6 +330,7 @@ var MobileClient = class {
|
|
|
323
330
|
*
|
|
324
331
|
* @throws {MobileServerFailureError} With error code `INVALID_EXPO_TOKEN` if the token is malformed, or is
|
|
325
332
|
* not currently registered to a wallet.
|
|
333
|
+
* @deprecated Use {@link getNotificationSettingsV2} instead.
|
|
326
334
|
*/
|
|
327
335
|
async getNotificationPreferences(params) {
|
|
328
336
|
const body = {
|
|
@@ -415,6 +423,40 @@ var MobileClient = class {
|
|
|
415
423
|
return require_dataMappers.mapMobileSocialFeedDrawingResult(await this.publicQuery(body));
|
|
416
424
|
}
|
|
417
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
|
+
/**
|
|
418
460
|
* Reads a comment thread with an optional anchor and bidirectional pagination.
|
|
419
461
|
* Independent reads create a public-only session; reused sessions retain their original scope.
|
|
420
462
|
* @param params - Root item, optional anchor or cursor (mutually exclusive), page size, and read perspective.
|
|
@@ -497,6 +539,57 @@ var MobileClient = class {
|
|
|
497
539
|
return require_dataMappers.mapMobileSocialFeedWatchers(await this.publicQuery(body));
|
|
498
540
|
}
|
|
499
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
|
+
/**
|
|
500
593
|
* Unregisters an Expo push token, stopping delivery to that device. Unsigned, so it still works at logout
|
|
501
594
|
* when a wallet signature may no longer be obtainable. Idempotent: unregistering an inactive or unknown
|
|
502
595
|
* well-formed token succeeds.
|
|
@@ -524,6 +617,7 @@ var MobileClient = class {
|
|
|
524
617
|
*
|
|
525
618
|
* @throws {MobileServerFailureError} With error code `INVALID_PREFERENCES` if those rules are violated, or
|
|
526
619
|
* `INVALID_EXPO_TOKEN` if the token is malformed or is not currently registered to a wallet.
|
|
620
|
+
* @deprecated Use {@link updateNotificationSettingsV2} instead.
|
|
527
621
|
*/
|
|
528
622
|
async updateNotificationPreferences(params) {
|
|
529
623
|
const body = {
|
|
@@ -534,20 +628,39 @@ var MobileClient = class {
|
|
|
534
628
|
return this.publicExecute(body);
|
|
535
629
|
}
|
|
536
630
|
/**
|
|
537
|
-
*
|
|
538
|
-
*
|
|
539
|
-
* @
|
|
540
|
-
*
|
|
541
|
-
*
|
|
542
|
-
|
|
543
|
-
|
|
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.
|
|
544
656
|
*/
|
|
545
657
|
async recordFeedViews(params) {
|
|
546
658
|
const body = {
|
|
547
659
|
type: "record_feed_views",
|
|
548
660
|
session_id: params.sessionId,
|
|
549
|
-
|
|
550
|
-
|
|
661
|
+
viewer_token: params.viewerToken,
|
|
662
|
+
view_event_id: params.viewEventId,
|
|
663
|
+
item_ids: [params.itemId]
|
|
551
664
|
};
|
|
552
665
|
return require_dataMappers.mapMobileSocialFeedViewsResult(await this.publicExecute(body));
|
|
553
666
|
}
|
|
@@ -638,11 +751,13 @@ var MobileClient = class {
|
|
|
638
751
|
}
|
|
639
752
|
/**
|
|
640
753
|
* Registers an Expo push token for the wallet, transferring active ownership of the token if another
|
|
641
|
-
* wallet had registered it.
|
|
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.
|
|
642
756
|
*
|
|
643
757
|
* @throws {MobileServerFailureError} With error code `INVALID_EXPO_TOKEN` if the token is not a valid Expo
|
|
644
758
|
* push token, or `INVALID_DEVICE_METADATA` if `locale` (max 35 chars) or `appVersion` (max 64 chars) is
|
|
645
759
|
* too long.
|
|
760
|
+
* @deprecated Use {@link registerExpoTokenV2} instead.
|
|
646
761
|
*/
|
|
647
762
|
async registerExpoToken(params) {
|
|
648
763
|
const signedRequest = await this.getSignedRequest("register_expo_token", params, {
|
|
@@ -654,6 +769,47 @@ var MobileClient = class {
|
|
|
654
769
|
return this.execute(signedRequest);
|
|
655
770
|
}
|
|
656
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
|
+
/**
|
|
657
813
|
* Sets whether the signing subaccount follows a Profile. Both directions are idempotent: following again
|
|
658
814
|
* keeps the original relationship creation time, so it does not move the account in recency order, and
|
|
659
815
|
* unfollowing a relationship that does not exist succeeds with `isFollowing: false`. Unfollowing deletes
|
|
@@ -718,11 +874,41 @@ var MobileClient = class {
|
|
|
718
874
|
action_id: params.actionId,
|
|
719
875
|
text: params.text,
|
|
720
876
|
mentions: params.mentions.map(require_dataMappers.mapMobileSocialFeedMentionToServer),
|
|
721
|
-
drawing_data_json: params.drawingDataJson
|
|
877
|
+
drawing_data_json: params.drawingDataJson,
|
|
878
|
+
image_ids: params.imageIds
|
|
722
879
|
});
|
|
723
880
|
return require_dataMappers.mapMobileSocialFeedItem((await this.execute(request)).item);
|
|
724
881
|
}
|
|
725
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
|
+
/**
|
|
726
912
|
* First attaches a drawing to an owned post or trade card while the author still holds its position.
|
|
727
913
|
* The original JSON is signed unchanged; false and zero are valid drawing documents.
|
|
728
914
|
* For an exact retry after a timeout, generate a nonce up front with {@link getMobileNonce} and reuse
|
|
@@ -778,7 +964,8 @@ var MobileClient = class {
|
|
|
778
964
|
reply_to_item_id: params.replyToItemId,
|
|
779
965
|
text: params.text,
|
|
780
966
|
mentions: params.mentions.map(require_dataMappers.mapMobileSocialFeedMentionToServer),
|
|
781
|
-
attached_position_id: params.attachedPositionId
|
|
967
|
+
attached_position_id: params.attachedPositionId,
|
|
968
|
+
image_ids: params.imageIds
|
|
782
969
|
});
|
|
783
970
|
return require_dataMappers.mapMobileSocialFeedCommentResult(await this.execute(request));
|
|
784
971
|
}
|
|
@@ -820,18 +1007,73 @@ var MobileClient = class {
|
|
|
820
1007
|
this.checkServerStatus(response);
|
|
821
1008
|
return response.data;
|
|
822
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
|
+
}
|
|
823
1030
|
async publicExecute(body) {
|
|
824
1031
|
const response = await this.axiosInstance.post(`${this.opts.url}/public_execute`, body);
|
|
825
1032
|
this.checkResponseStatus(response);
|
|
826
1033
|
this.checkServerStatus(response);
|
|
827
1034
|
return response.data;
|
|
828
1035
|
}
|
|
829
|
-
|
|
830
|
-
|
|
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);
|
|
831
1044
|
this.checkResponseStatus(response);
|
|
832
1045
|
this.checkServerStatus(response);
|
|
833
1046
|
return response.data;
|
|
834
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
|
+
}
|
|
835
1077
|
/**
|
|
836
1078
|
* Validates the HTTP status before interpreting the body. Unlike the engine, the mobile backend returns
|
|
837
1079
|
* failure envelopes with non-2xx statuses (e.g. 404 for `PROFILE_NOT_FOUND`), so a non-2xx response with a
|
|
@@ -856,4 +1098,4 @@ Object.defineProperty(exports, "MobileClient", {
|
|
|
856
1098
|
}
|
|
857
1099
|
});
|
|
858
1100
|
|
|
859
|
-
//# sourceMappingURL=MobileClient-
|
|
1101
|
+
//# sourceMappingURL=MobileClient-M4oC4lrX.cjs.map
|