@nadohq/mobile-client 0.29.0 → 0.31.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.
Files changed (208) hide show
  1. package/README.md +15 -8
  2. package/dist/{MobileClient-9JSAzblH.cjs → MobileClient-_i0ZV6Dq.cjs} +104 -44
  3. package/dist/MobileClient-_i0ZV6Dq.cjs.map +1 -0
  4. package/dist/MobileClient.cjs +1 -1
  5. package/dist/MobileClient.d.cts +77 -36
  6. package/dist/MobileClient.d.cts.map +1 -1
  7. package/dist/MobileClient.d.ts +77 -36
  8. package/dist/MobileClient.d.ts.map +1 -1
  9. package/dist/MobileClient.js +105 -45
  10. package/dist/MobileClient.js.map +1 -1
  11. package/dist/{MobileServerFailureError-ZggEcEda.d.cts → MobileServerFailureError-BoyAfEZA.d.cts} +3 -2
  12. package/dist/MobileServerFailureError-BoyAfEZA.d.cts.map +1 -0
  13. package/dist/{MobileServerFailureError-f9KhKnJj.d.ts → MobileServerFailureError-MgYVBh5p.d.ts} +3 -2
  14. package/dist/MobileServerFailureError-MgYVBh5p.d.ts.map +1 -0
  15. package/dist/{buildSignedMobileRequest-BsbBkU0K.d.cts → buildSignedMobileRequest-CBMt97aY.d.cts} +2 -2
  16. package/dist/{buildSignedMobileRequest-BsbBkU0K.d.cts.map → buildSignedMobileRequest-CBMt97aY.d.cts.map} +1 -1
  17. package/dist/{buildSignedMobileRequest-CDRsRNHm.d.ts → buildSignedMobileRequest-qEC4gWaI.d.ts} +2 -2
  18. package/dist/{buildSignedMobileRequest-CDRsRNHm.d.ts.map → buildSignedMobileRequest-qEC4gWaI.d.ts.map} +1 -1
  19. package/dist/{canonicalize-PX6dTIdF.d.ts → canonicalize-QNARV_Xc.d.cts} +4 -4
  20. package/dist/canonicalize-QNARV_Xc.d.cts.map +1 -0
  21. package/dist/{canonicalize-Dm7sXwPg.d.cts → canonicalize-wVdGejB1.d.ts} +4 -4
  22. package/dist/canonicalize-wVdGejB1.d.ts.map +1 -0
  23. package/dist/clientTypes-6utzUU-b.d.ts +240 -0
  24. package/dist/clientTypes-6utzUU-b.d.ts.map +1 -0
  25. package/dist/clientTypes-D9qgtNlE.d.cts +240 -0
  26. package/dist/clientTypes-D9qgtNlE.d.cts.map +1 -0
  27. package/dist/dataMappers.cjs +35 -1
  28. package/dist/dataMappers.cjs.map +1 -1
  29. package/dist/dataMappers.d.cts +8 -3
  30. package/dist/dataMappers.d.cts.map +1 -1
  31. package/dist/dataMappers.d.ts +8 -3
  32. package/dist/dataMappers.d.ts.map +1 -1
  33. package/dist/dataMappers.js +35 -2
  34. package/dist/dataMappers.js.map +1 -1
  35. package/dist/{eip712MethodByType-DLh9MRsD.d.cts → eip712MethodByType-CroIPqsJ.d.cts} +2 -2
  36. package/dist/eip712MethodByType-CroIPqsJ.d.cts.map +1 -0
  37. package/dist/{eip712MethodByType-DJgXal9r.d.ts → eip712MethodByType-DBUy4AdI.d.ts} +2 -2
  38. package/dist/eip712MethodByType-DBUy4AdI.d.ts.map +1 -0
  39. package/dist/feed-BF5k6Ryu.d.ts +14 -0
  40. package/dist/feed-BF5k6Ryu.d.ts.map +1 -0
  41. package/dist/feed-CBIwOhTO.d.cts +14 -0
  42. package/dist/feed-CBIwOhTO.d.cts.map +1 -0
  43. package/dist/index.cjs +8 -1
  44. package/dist/index.d.cts +17 -15
  45. package/dist/index.d.ts +17 -15
  46. package/dist/index.js +3 -1
  47. package/dist/{mobileErrorCodes-BeyBKmwh.d.cts → mobileErrorCodes-CuQ5lyBV.d.ts} +8 -8
  48. package/dist/mobileErrorCodes-CuQ5lyBV.d.ts.map +1 -0
  49. package/dist/{mobileErrorCodes-QG5XbEY6.d.ts → mobileErrorCodes-D_SyBm0k.d.cts} +8 -8
  50. package/dist/mobileErrorCodes-D_SyBm0k.d.cts.map +1 -0
  51. package/dist/{patterns-BbxH3_VA.d.ts → patterns-B5gi7OfV.d.ts} +1 -1
  52. package/dist/patterns-B5gi7OfV.d.ts.map +1 -0
  53. package/dist/{patterns-B9J2ldpx.d.cts → patterns-Db6fgz8i.d.cts} +1 -1
  54. package/dist/patterns-Db6fgz8i.d.cts.map +1 -0
  55. package/dist/{payloadHash-nj8WuLUP.d.cts → payloadHash-B0tlFOK8.d.cts} +2 -2
  56. package/dist/payloadHash-B0tlFOK8.d.cts.map +1 -0
  57. package/dist/{payloadHash-Bmhzs78N.d.ts → payloadHash-D1yTQSF4.d.ts} +2 -2
  58. package/dist/payloadHash-D1yTQSF4.d.ts.map +1 -0
  59. package/dist/serverBaseTypes-CzRgwUvA.d.ts +25 -0
  60. package/dist/serverBaseTypes-CzRgwUvA.d.ts.map +1 -0
  61. package/dist/serverBaseTypes-DSRgU2Fb.d.cts +25 -0
  62. package/dist/serverBaseTypes-DSRgU2Fb.d.cts.map +1 -0
  63. package/dist/serverExecuteTypes-BCb6bUMP.d.cts +19 -0
  64. package/dist/serverExecuteTypes-BCb6bUMP.d.cts.map +1 -0
  65. package/dist/serverExecuteTypes-CI3NBW2Z.d.ts +19 -0
  66. package/dist/serverExecuteTypes-CI3NBW2Z.d.ts.map +1 -0
  67. package/dist/serverModelTypes-BYQcsRrx.d.cts +146 -0
  68. package/dist/serverModelTypes-BYQcsRrx.d.cts.map +1 -0
  69. package/dist/serverModelTypes-DvPs5qs3.d.ts +146 -0
  70. package/dist/serverModelTypes-DvPs5qs3.d.ts.map +1 -0
  71. package/dist/serverQueryTypes-9H6P1vJ5.d.cts +92 -0
  72. package/dist/serverQueryTypes-9H6P1vJ5.d.cts.map +1 -0
  73. package/dist/serverQueryTypes-Cbjx0bIj.d.ts +92 -0
  74. package/dist/serverQueryTypes-Cbjx0bIj.d.ts.map +1 -0
  75. package/dist/serverRequestTypes-CHDk6JwE.d.cts +85 -0
  76. package/dist/serverRequestTypes-CHDk6JwE.d.cts.map +1 -0
  77. package/dist/serverRequestTypes-DYTLrCpz.d.ts +85 -0
  78. package/dist/serverRequestTypes-DYTLrCpz.d.ts.map +1 -0
  79. package/dist/{serverResponseGuards-DjCNL3CR.d.cts → serverResponseGuards-DRMHmfXh.d.cts} +2 -2
  80. package/dist/{serverResponseGuards-DjCNL3CR.d.cts.map → serverResponseGuards-DRMHmfXh.d.cts.map} +1 -1
  81. package/dist/{serverResponseGuards-C_vZIgGl.d.ts → serverResponseGuards-DpbZvJfL.d.ts} +2 -2
  82. package/dist/{serverResponseGuards-C_vZIgGl.d.ts.map → serverResponseGuards-DpbZvJfL.d.ts.map} +1 -1
  83. package/dist/signing/buildSignedMobileRequest.cjs +1 -1
  84. package/dist/signing/buildSignedMobileRequest.d.cts +1 -1
  85. package/dist/signing/buildSignedMobileRequest.d.ts +1 -1
  86. package/dist/signing/canonicalize.cjs +4 -37
  87. package/dist/signing/canonicalize.cjs.map +1 -1
  88. package/dist/signing/canonicalize.d.cts +1 -1
  89. package/dist/signing/canonicalize.d.ts +1 -1
  90. package/dist/signing/canonicalize.js +4 -37
  91. package/dist/signing/canonicalize.js.map +1 -1
  92. package/dist/signing/eip712MethodByType.cjs +1 -5
  93. package/dist/signing/eip712MethodByType.cjs.map +1 -1
  94. package/dist/signing/eip712MethodByType.d.cts +1 -1
  95. package/dist/signing/eip712MethodByType.d.ts +1 -1
  96. package/dist/signing/eip712MethodByType.js +1 -5
  97. package/dist/signing/eip712MethodByType.js.map +1 -1
  98. package/dist/signing/index.d.cts +5 -5
  99. package/dist/signing/index.d.ts +5 -5
  100. package/dist/signing/payloadHash.cjs +1 -1
  101. package/dist/signing/payloadHash.d.cts +1 -1
  102. package/dist/signing/payloadHash.d.ts +1 -1
  103. package/dist/signing/types.d.cts +1 -1
  104. package/dist/signing/types.d.ts +1 -1
  105. package/dist/types/MobileServerFailureError.cjs +1 -1
  106. package/dist/types/MobileServerFailureError.cjs.map +1 -1
  107. package/dist/types/MobileServerFailureError.d.cts +1 -1
  108. package/dist/types/MobileServerFailureError.d.ts +1 -1
  109. package/dist/types/MobileServerFailureError.js.map +1 -1
  110. package/dist/types/clientTypes.d.cts +2 -2
  111. package/dist/types/clientTypes.d.ts +2 -2
  112. package/dist/types/index.cjs +4 -0
  113. package/dist/types/index.d.cts +9 -8
  114. package/dist/types/index.d.ts +9 -8
  115. package/dist/types/index.js +2 -1
  116. package/dist/types/mobileErrorCodes.cjs +10 -7
  117. package/dist/types/mobileErrorCodes.cjs.map +1 -1
  118. package/dist/types/mobileErrorCodes.d.cts +1 -1
  119. package/dist/types/mobileErrorCodes.d.ts +1 -1
  120. package/dist/types/mobileErrorCodes.js +9 -6
  121. package/dist/types/mobileErrorCodes.js.map +1 -1
  122. package/dist/types/serverBaseTypes.d.cts +2 -2
  123. package/dist/types/serverBaseTypes.d.ts +2 -2
  124. package/dist/types/serverExecuteTypes.d.cts +2 -2
  125. package/dist/types/serverExecuteTypes.d.ts +2 -2
  126. package/dist/types/serverModelTypes.cjs +29 -0
  127. package/dist/types/serverModelTypes.cjs.map +1 -0
  128. package/dist/types/serverModelTypes.d.cts +2 -2
  129. package/dist/types/serverModelTypes.d.ts +2 -2
  130. package/dist/types/serverModelTypes.js +26 -1
  131. package/dist/types/serverModelTypes.js.map +1 -0
  132. package/dist/types/serverQueryTypes.d.cts +2 -2
  133. package/dist/types/serverQueryTypes.d.ts +2 -2
  134. package/dist/types/serverRequestTypes.cjs +0 -0
  135. package/dist/types/serverRequestTypes.d.cts +2 -0
  136. package/dist/types/serverRequestTypes.d.ts +2 -0
  137. package/dist/types/serverRequestTypes.js +1 -0
  138. package/dist/{types-B76Pn7Sy.d.ts → types-CQE3HD2V.d.ts} +4 -15
  139. package/dist/types-CQE3HD2V.d.ts.map +1 -0
  140. package/dist/{types-uCD4BNZR.d.cts → types-bNB98pYk.d.cts} +4 -15
  141. package/dist/types-bNB98pYk.d.cts.map +1 -0
  142. package/dist/utils/feed.cjs +17 -0
  143. package/dist/utils/feed.cjs.map +1 -0
  144. package/dist/utils/feed.d.cts +2 -0
  145. package/dist/utils/feed.d.ts +2 -0
  146. package/dist/utils/feed.js +15 -0
  147. package/dist/utils/feed.js.map +1 -0
  148. package/dist/utils/index.cjs +3 -0
  149. package/dist/utils/index.d.cts +4 -3
  150. package/dist/utils/index.d.ts +4 -3
  151. package/dist/utils/index.js +2 -1
  152. package/dist/utils/patterns.d.cts +1 -1
  153. package/dist/utils/patterns.d.ts +1 -1
  154. package/dist/utils/serverResponseGuards.d.cts +1 -1
  155. package/dist/utils/serverResponseGuards.d.ts +1 -1
  156. package/package.json +3 -3
  157. package/src/MobileClient.ts +163 -112
  158. package/src/dataMappers.ts +41 -0
  159. package/src/signing/canonicalize.ts +4 -37
  160. package/src/signing/eip712MethodByType.ts +1 -5
  161. package/src/signing/signing.test.ts +17 -60
  162. package/src/signing/types.ts +2 -12
  163. package/src/types/MobileServerFailureError.ts +2 -4
  164. package/src/types/clientTypes.ts +105 -27
  165. package/src/types/index.ts +1 -0
  166. package/src/types/mobileErrorCodes.ts +8 -5
  167. package/src/types/serverBaseTypes.ts +7 -28
  168. package/src/types/serverExecuteTypes.ts +17 -0
  169. package/src/types/serverModelTypes.ts +104 -8
  170. package/src/types/serverQueryTypes.ts +84 -39
  171. package/src/types/serverRequestTypes.ts +91 -0
  172. package/src/utils/feed.ts +11 -0
  173. package/src/utils/index.ts +1 -0
  174. package/dist/MobileClient-9JSAzblH.cjs.map +0 -1
  175. package/dist/MobileServerFailureError-ZggEcEda.d.cts.map +0 -1
  176. package/dist/MobileServerFailureError-f9KhKnJj.d.ts.map +0 -1
  177. package/dist/canonicalize-Dm7sXwPg.d.cts.map +0 -1
  178. package/dist/canonicalize-PX6dTIdF.d.ts.map +0 -1
  179. package/dist/clientTypes-DWW2N66c.d.ts +0 -168
  180. package/dist/clientTypes-DWW2N66c.d.ts.map +0 -1
  181. package/dist/clientTypes-Et0PUa2d.d.cts +0 -168
  182. package/dist/clientTypes-Et0PUa2d.d.cts.map +0 -1
  183. package/dist/eip712MethodByType-DJgXal9r.d.ts.map +0 -1
  184. package/dist/eip712MethodByType-DLh9MRsD.d.cts.map +0 -1
  185. package/dist/mobileErrorCodes-BeyBKmwh.d.cts.map +0 -1
  186. package/dist/mobileErrorCodes-QG5XbEY6.d.ts.map +0 -1
  187. package/dist/patterns-B9J2ldpx.d.cts.map +0 -1
  188. package/dist/patterns-BbxH3_VA.d.ts.map +0 -1
  189. package/dist/payloadHash-Bmhzs78N.d.ts.map +0 -1
  190. package/dist/payloadHash-nj8WuLUP.d.cts.map +0 -1
  191. package/dist/serverBaseTypes-BicXMrZV.d.cts +0 -43
  192. package/dist/serverBaseTypes-BicXMrZV.d.cts.map +0 -1
  193. package/dist/serverBaseTypes-ewbo8l4R.d.ts +0 -43
  194. package/dist/serverBaseTypes-ewbo8l4R.d.ts.map +0 -1
  195. package/dist/serverExecuteTypes-CXnMjKnt.d.ts +0 -11
  196. package/dist/serverExecuteTypes-CXnMjKnt.d.ts.map +0 -1
  197. package/dist/serverExecuteTypes-DKYK1V7C.d.cts +0 -11
  198. package/dist/serverExecuteTypes-DKYK1V7C.d.cts.map +0 -1
  199. package/dist/serverModelTypes-CQgfqgW3.d.cts +0 -69
  200. package/dist/serverModelTypes-CQgfqgW3.d.cts.map +0 -1
  201. package/dist/serverModelTypes-vEPhHIit.d.ts +0 -69
  202. package/dist/serverModelTypes-vEPhHIit.d.ts.map +0 -1
  203. package/dist/serverQueryTypes-BI-2TD8F.d.ts +0 -53
  204. package/dist/serverQueryTypes-BI-2TD8F.d.ts.map +0 -1
  205. package/dist/serverQueryTypes-D7Yharse.d.cts +0 -53
  206. package/dist/serverQueryTypes-D7Yharse.d.cts.map +0 -1
  207. package/dist/types-B76Pn7Sy.d.ts.map +0 -1
  208. package/dist/types-uCD4BNZR.d.cts.map +0 -1
package/README.md CHANGED
@@ -1,7 +1,7 @@
1
1
  # `@nadohq/mobile-client`
2
2
 
3
- HTTP client for the Nado mobile service API. Manages username claims, public profile lookups, privacy settings, and
4
- push notification devices/preferences, using EIP-712 + msgpack signed authentication.
3
+ HTTP client for the Nado mobile service API. Manages usernames, public profile lookups, the global trade feed,
4
+ privacy settings, and push notification devices/preferences, using EIP-712 + msgpack signed authentication.
5
5
 
6
6
  [Full SDK Documentation](https://nadohq.github.io/nado-typescript-sdk/index.html)
7
7
 
@@ -26,7 +26,10 @@ const mobile = new MobileClient({
26
26
 
27
27
  // Unsigned public lookups
28
28
  const availability = await mobile.getUsernameAvailability({ displayName: 'Alice.One' });
29
- const profile = await mobile.getPublicProfile({ username: 'alice.one' });
29
+ const profile = await mobile.getPublicProfile({
30
+ subaccountOwner: '0x...',
31
+ subaccountName: 'default',
32
+ });
30
33
 
31
34
  // Signed operations
32
35
  const identity = await mobile.getSelfIdentity({
@@ -36,7 +39,7 @@ const identity = await mobile.getSelfIdentity({
36
39
  verifyingAddr: '0x...',
37
40
  });
38
41
 
39
- await mobile.claimUsername({
42
+ await mobile.setUsername({
40
43
  subaccountOwner: walletClient.account.address,
41
44
  subaccountName: 'default',
42
45
  chainId: ink.id,
@@ -49,16 +52,20 @@ await mobile.claimUsername({
49
52
 
50
53
  ### Public Queries
51
54
 
52
- `getUsernameAvailability`, `getPublicProfile`.
55
+ `getUsernameAvailability`, `getPublicProfile`, `getFeed`, `getNotificationPreferences`.
56
+
57
+ ### Public Executes
58
+
59
+ `unregisterExpoToken`, `updateNotificationPreferences`. These are authenticated by possession of an active Expo
60
+ push token rather than a wallet signature, so they still work at logout when a signature may be unobtainable.
53
61
 
54
62
  ### Signed Queries
55
63
 
56
- `getSelfIdentity`, `getNotificationPreferences`, `getRegisteredDevices`.
64
+ `getSelfIdentity`, `getRegisteredDevices`.
57
65
 
58
66
  ### Signed Executes
59
67
 
60
- `claimUsername`, `updateUsername`, `setPrivateMode`, `registerExpoToken`, `unregisterExpoToken`,
61
- `updateNotificationPreferences`.
68
+ `setUsername`, `setPrivateMode`, `registerExpoToken`.
62
69
 
63
70
  ### Linked Signers
64
71
 
@@ -29,8 +29,8 @@ let axios = require("axios");
29
29
  axios = __toESM(axios, 1);
30
30
  //#region src/MobileClient.ts
31
31
  /**
32
- * Client for the Nado mobile service API: username claims, public profile lookups, privacy settings, and
33
- * push notification device/preference management.
32
+ * Client for the Nado mobile service API: usernames, public profile lookups, the global trade feed, privacy
33
+ * settings, and push notification device/preference management.
34
34
  */
35
35
  var MobileClient = class {
36
36
  constructor(opts) {
@@ -63,34 +63,105 @@ var MobileClient = class {
63
63
  };
64
64
  }
65
65
  /**
66
- * Looks up a subaccount's public profile by username.
66
+ * Looks up a subaccount's public profile. Every non-isolated subaccount resolves, with `username` and
67
+ * `displayName` `null` until a username is claimed. Private Mode does not hide the profile itself, only the
68
+ * account's activity.
67
69
  *
68
- * @throws {MobileServerFailureError} With error code `PROFILE_NOT_FOUND` if no identity has claimed the
69
- * username or it is invalid. Private Mode does not hide the profile itself, only the account's activity.
70
+ * @throws {MobileServerFailureError} With error code `PROFILE_NOT_FOUND` if the subaccount is in the
71
+ * engine-created isolated namespace, which cannot own a profile.
70
72
  */
71
73
  async getPublicProfile(params) {
72
74
  const body = {
73
75
  type: "profile",
74
- username: params.username
76
+ subaccount: (0, _nadohq_shared.subaccountToHex)(params)
75
77
  };
76
78
  return require_dataMappers.mapMobilePublicProfile((await this.publicQuery(body)).profile);
77
79
  }
78
80
  /**
79
- * Fetches the caller's own identity for a subaccount. Returns `null` if the subaccount has not claimed a
80
- * username yet — this is normal data, not an error.
81
+ * Fetches a page of the global trade feed: public perpetual trades, newest first, optionally filtered by a
82
+ * whole-dollar minimum notional (omitted means unfiltered). Trades by subaccounts that have not claimed a
83
+ * username are included with `null` name fields; only private accounts are filtered out. The feed is
84
+ * best-effort rather than authoritative history, and pagination is live (not snapshot), so deduplicate pages
85
+ * by {@link MobileFeedTrade.orderDigest}.
86
+ *
87
+ * @throws {MobileServerFailureError} With error code `INVALID_FEED_FILTER` if `minimumNotional` or
88
+ * `limit` is outside its allowed domain (fix the request; do not retry unchanged), or
89
+ * `INVALID_FEED_CURSOR` if the cursor is malformed or was issued for a different `minimumNotional`
90
+ * (discard the cursor and restart from the first page).
81
91
  */
82
- async getSelfIdentity(params) {
83
- const signedRequest = await this.getSignedRequest("self_identity", params, {});
84
- const data = await this.query(signedRequest);
85
- return data.identity ? require_dataMappers.mapMobileIdentity(data.identity) : null;
92
+ async getFeed(params = {}) {
93
+ const body = {
94
+ type: "feed",
95
+ minimum_notional: params.minimumNotional,
96
+ limit: params.limit,
97
+ cursor: params.cursor
98
+ };
99
+ return require_dataMappers.mapMobileFeedPage(await this.publicQuery(body));
86
100
  }
87
101
  /**
88
- * Fetches a wallet's push notification preferences. Falls back to the backend's defaults if the wallet has
89
- * never updated its preferences.
102
+ * Fetches the push notification preferences of the wallet that owns the given Expo push token. Unsigned —
103
+ * the token identifies the wallet on its own. Falls back to the backend's defaults if the wallet has never
104
+ * updated its preferences.
105
+ *
106
+ * @throws {MobileServerFailureError} With error code `INVALID_EXPO_TOKEN` if the token is malformed, or is
107
+ * not currently registered to a wallet.
90
108
  */
91
109
  async getNotificationPreferences(params) {
92
- const signedRequest = await this.getSignedRequest("notification_preferences", params, {});
93
- return require_dataMappers.mapMobileNotificationPreferences((await this.query(signedRequest)).preferences);
110
+ const body = {
111
+ type: "notification_preferences",
112
+ expo_token: params.expoToken
113
+ };
114
+ return require_dataMappers.mapMobileNotificationPreferences((await this.publicQuery(body)).preferences);
115
+ }
116
+ /**
117
+ * Unregisters an Expo push token, stopping delivery to that device. Unsigned, so it still works at logout
118
+ * when a wallet signature may no longer be obtainable. Idempotent: unregistering an inactive or unknown
119
+ * well-formed token succeeds.
120
+ *
121
+ * A registration that commits after this call re-activates the token, so stop or await any in-flight
122
+ * {@link MobileClient.registerExpoToken} before unregistering.
123
+ *
124
+ * @throws {MobileServerFailureError} With error code `INVALID_EXPO_TOKEN` if the token is malformed.
125
+ */
126
+ async unregisterExpoToken(params) {
127
+ const body = {
128
+ type: "unregister_expo_token",
129
+ expo_token: params.expoToken
130
+ };
131
+ return this.publicExecute(body);
132
+ }
133
+ /**
134
+ * Replaces the push notification preferences of the wallet that owns the given Expo push token. Possession
135
+ * of an active token is the credential rather than a signature, so anyone holding the token can overwrite
136
+ * that wallet's preferences. The backend requires `schemaVersion` of 1, exactly one entry per known
137
+ * category, and empty `scopes` on every entry.
138
+ *
139
+ * Writes are last-write-wins on commit order rather than ordered by a client nonce, so callers must
140
+ * serialize their own preference writes.
141
+ *
142
+ * @throws {MobileServerFailureError} With error code `INVALID_PREFERENCES` if those rules are violated, or
143
+ * `INVALID_EXPO_TOKEN` if the token is malformed or is not currently registered to a wallet.
144
+ */
145
+ async updateNotificationPreferences(params) {
146
+ const body = {
147
+ type: "update_preferences",
148
+ expo_token: params.expoToken,
149
+ preferences: require_dataMappers.mapMobileNotificationPreferencesToServer(params.preferences)
150
+ };
151
+ return this.publicExecute(body);
152
+ }
153
+ /**
154
+ * Fetches the caller's own identity for a subaccount. Every non-isolated subaccount has an implicit
155
+ * identity, so this resolves for any valid sender with `username` and `displayName` `null` until a username
156
+ * is claimed.
157
+ *
158
+ * @throws {MobileServerFailureError} With error code `INVALID_IDENTITY_TARGET` if the sender is in the
159
+ * engine-created isolated namespace, which cannot own an identity.
160
+ */
161
+ async getSelfIdentity(params) {
162
+ const signedRequest = await this.getSignedRequest("self_identity", params, {});
163
+ const data = await this.query(signedRequest);
164
+ return data.identity ? require_dataMappers.mapMobileIdentity(data.identity) : null;
94
165
  }
95
166
  /**
96
167
  * Fetches the devices registered for push notifications for a wallet.
@@ -100,17 +171,17 @@ var MobileClient = class {
100
171
  return (await this.query(signedRequest)).devices.map(require_dataMappers.mapMobileRegisteredDevice);
101
172
  }
102
173
  /**
103
- * Claims a username for a subaccount, derived from the given display name.
104
- */
105
- async claimUsername(params) {
106
- const signedRequest = await this.getSignedRequest("claim_username", params, { display_name: params.displayName });
107
- return this.execute(signedRequest);
108
- }
109
- /**
110
- * Updates the display name for a subaccount's already-claimed identity.
174
+ * Sets a subaccount's username, derived from the given display name. Upserts: the same call claims a first
175
+ * username and renames an existing one, so callers never need to read the current identity first.
176
+ *
177
+ * @throws {MobileServerFailureError} With error code `INVALID_DISPLAY_NAME` if the display name violates
178
+ * `MOBILE_DISPLAY_NAME_PATTERN`, `USERNAME_UNAVAILABLE` if the derived username is reserved or already
179
+ * taken by another subaccount, `INVALID_IDENTITY_TARGET` if the sender is in the engine-created isolated
180
+ * namespace, or `STALE_IDENTITY_UPDATE` if another identity write for this subaccount committed with a
181
+ * later nonce (re-read the identity before retrying).
111
182
  */
112
- async updateUsername(params) {
113
- const signedRequest = await this.getSignedRequest("update_username", params, { display_name: params.displayName });
183
+ async setUsername(params) {
184
+ const signedRequest = await this.getSignedRequest("set_username", params, { display_name: params.displayName });
114
185
  return this.execute(signedRequest);
115
186
  }
116
187
  /**
@@ -137,23 +208,6 @@ var MobileClient = class {
137
208
  });
138
209
  return this.execute(signedRequest);
139
210
  }
140
- /**
141
- * Unregisters an Expo push token for the wallet. Idempotent — unregistering an unknown token succeeds.
142
- */
143
- async unregisterExpoToken(params) {
144
- const signedRequest = await this.getSignedRequest("unregister_expo_token", params, { expo_token: params.expoToken });
145
- return this.execute(signedRequest);
146
- }
147
- /**
148
- * Replaces the wallet's push notification preferences. The backend requires `schemaVersion` of 1, exactly
149
- * one entry per known category, and empty `scopes` on every entry.
150
- *
151
- * @throws {MobileServerFailureError} With error code `INVALID_PREFERENCES` if those rules are violated.
152
- */
153
- async updateNotificationPreferences(params) {
154
- const signedRequest = await this.getSignedRequest("update_preferences", params, { preferences: require_dataMappers.mapMobileNotificationPreferencesToServer(params.preferences) });
155
- return this.execute(signedRequest);
156
- }
157
211
  async getSignedRequest(type, params, innerParams) {
158
212
  const walletClient = this.opts.linkedSignerWalletClient ?? this.opts.walletClient;
159
213
  if (walletClient == null) throw new _nadohq_shared.WalletNotProvidedError();
@@ -173,6 +227,12 @@ var MobileClient = class {
173
227
  this.checkServerStatus(response);
174
228
  return response.data;
175
229
  }
230
+ async publicExecute(body) {
231
+ const response = await this.axiosInstance.post(`${this.opts.url}/mobile/public_execute`, body);
232
+ this.checkResponseStatus(response);
233
+ this.checkServerStatus(response);
234
+ return response.data;
235
+ }
176
236
  async query(body) {
177
237
  const response = await this.axiosInstance.post(`${this.opts.url}/mobile/query`, body);
178
238
  this.checkResponseStatus(response);
@@ -215,4 +275,4 @@ Object.defineProperty(exports, "__toESM", {
215
275
  }
216
276
  });
217
277
 
218
- //# sourceMappingURL=MobileClient-9JSAzblH.cjs.map
278
+ //# sourceMappingURL=MobileClient-_i0ZV6Dq.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MobileClient-_i0ZV6Dq.cjs","names":["mapMobilePublicProfile","mapMobileFeedPage","mapMobileNotificationPreferences","mapMobileNotificationPreferencesToServer","mapMobileIdentity","mapMobileRegisteredDevice","WalletNotProvidedError","buildSignedMobileRequest","isMobileServerFailureResponse","MobileServerFailureError","isMobileServerSuccessResponse"],"sources":["../src/MobileClient.ts"],"sourcesContent":["import {\n subaccountToHex,\n WalletClientWithAccount,\n WalletNotProvidedError,\n} from '@nadohq/shared';\nimport axios, { AxiosInstance, AxiosResponse } from 'axios';\nimport {\n mapMobileFeedPage,\n mapMobileIdentity,\n mapMobileNotificationPreferences,\n mapMobileNotificationPreferencesToServer,\n mapMobilePublicProfile,\n mapMobileRegisteredDevice,\n} from './dataMappers';\nimport {\n buildSignedMobileRequest,\n MobileSignedInner,\n MobileSignedInnerParams,\n MobileSignedRequest,\n} from './signing';\nimport {\n GetMobileFeedParams,\n GetMobileNotificationPreferencesParams,\n GetMobilePublicProfileParams,\n GetMobileRegisteredDevicesParams,\n GetMobileSelfIdentityParams,\n GetMobileUsernameAvailabilityParams,\n MobileFeedPage,\n MobileIdentity,\n MobileNotificationPreferences,\n MobilePublicProfile,\n MobileRegisteredDevice,\n MobileRegisterExpoTokenParams,\n MobileSetPrivateModeParams,\n MobileSetUsernameParams,\n MobileSignedRequestParams,\n MobileUnregisterExpoTokenParams,\n MobileUpdateNotificationPreferencesParams,\n MobileUsernameAvailability,\n} from './types/clientTypes';\nimport { MobileServerFailureError } from './types/MobileServerFailureError';\nimport { MobileServerSuccessResponse } from './types/serverBaseTypes';\nimport {\n MobileServerExecuteResult,\n MobileServerPublicExecuteRequest,\n} from './types/serverExecuteTypes';\nimport {\n MobileServerPublicQueryRequest,\n MobileServerPublicQuerySuccessResponse,\n MobileServerSignedQuerySuccessResponse,\n} from './types/serverQueryTypes';\nimport {\n MobileServerPublicQueryRequestByType,\n MobileServerPublicQueryRequestType,\n MobileServerSignedQueryRequestType,\n} from './types/serverRequestTypes';\nimport {\n isMobileServerFailureResponse,\n isMobileServerSuccessResponse,\n} from './utils/serverResponseGuards';\n\n/**\n * Options for constructing a {@link MobileClient}.\n */\nexport interface MobileClientOpts {\n /**\n * Base URL of the mobile service API, e.g. {@link MOBILE_CLIENT_ENDPOINTS}.\n */\n url: string;\n /**\n * Wallet client used to sign requests.\n */\n walletClient?: WalletClientWithAccount;\n /**\n * If provided, this signer is used instead of `walletClient` for all signed requests.\n */\n linkedSignerWalletClient?: WalletClientWithAccount;\n}\n\n/**\n * Client for the Nado mobile service API: usernames, public profile lookups, the global trade feed, privacy\n * settings, and push notification device/preference management.\n */\nexport class MobileClient {\n readonly opts: MobileClientOpts;\n readonly axiosInstance: AxiosInstance;\n\n constructor(opts: MobileClientOpts) {\n this.opts = opts;\n this.axiosInstance = axios.create({\n withCredentials: true,\n // We have custom logic to validate response status and create an appropriate error\n validateStatus: () => true,\n });\n }\n\n /**\n * Sets the linked signer for requests\n *\n * @param linkedSignerWalletClient The linkedSigner to use for all signatures. Set to null to revert to the chain signer\n */\n public setLinkedSigner(\n linkedSignerWalletClient: WalletClientWithAccount | null,\n ) {\n this.opts.linkedSignerWalletClient = linkedSignerWalletClient ?? undefined;\n }\n\n /*\n Public queries\n */\n\n /**\n * Checks whether a username derived from the given display name is available to claim.\n */\n async getUsernameAvailability(\n params: GetMobileUsernameAvailabilityParams,\n ): Promise<MobileUsernameAvailability> {\n const body: MobileServerPublicQueryRequest<'username_availability'> = {\n type: 'username_availability',\n display_name: params.displayName,\n };\n const data = await this.publicQuery(body);\n return { username: data.username, available: data.available };\n }\n\n /**\n * Looks up a subaccount's public profile. Every non-isolated subaccount resolves, with `username` and\n * `displayName` `null` until a username is claimed. Private Mode does not hide the profile itself, only the\n * account's activity.\n *\n * @throws {MobileServerFailureError} With error code `PROFILE_NOT_FOUND` if the subaccount is in the\n * engine-created isolated namespace, which cannot own a profile.\n */\n async getPublicProfile(\n params: GetMobilePublicProfileParams,\n ): Promise<MobilePublicProfile> {\n const body: MobileServerPublicQueryRequest<'profile'> = {\n type: 'profile',\n subaccount: subaccountToHex(params),\n };\n const data = await this.publicQuery(body);\n return mapMobilePublicProfile(data.profile);\n }\n\n /**\n * Fetches a page of the global trade feed: public perpetual trades, newest first, optionally filtered by a\n * whole-dollar minimum notional (omitted means unfiltered). Trades by subaccounts that have not claimed a\n * username are included with `null` name fields; only private accounts are filtered out. The feed is\n * best-effort rather than authoritative history, and pagination is live (not snapshot), so deduplicate pages\n * by {@link MobileFeedTrade.orderDigest}.\n *\n * @throws {MobileServerFailureError} With error code `INVALID_FEED_FILTER` if `minimumNotional` or\n * `limit` is outside its allowed domain (fix the request; do not retry unchanged), or\n * `INVALID_FEED_CURSOR` if the cursor is malformed or was issued for a different `minimumNotional`\n * (discard the cursor and restart from the first page).\n */\n async getFeed(params: GetMobileFeedParams = {}): Promise<MobileFeedPage> {\n const body: MobileServerPublicQueryRequest<'feed'> = {\n type: 'feed',\n minimum_notional: params.minimumNotional,\n limit: params.limit,\n cursor: params.cursor,\n };\n const data = await this.publicQuery(body);\n return mapMobileFeedPage(data);\n }\n\n /**\n * Fetches the push notification preferences of the wallet that owns the given Expo push token. Unsigned —\n * the token identifies the wallet on its own. Falls back to the backend's defaults if the wallet has never\n * updated its preferences.\n *\n * @throws {MobileServerFailureError} With error code `INVALID_EXPO_TOKEN` if the token is malformed, or is\n * not currently registered to a wallet.\n */\n async getNotificationPreferences(\n params: GetMobileNotificationPreferencesParams,\n ): Promise<MobileNotificationPreferences> {\n const body: MobileServerPublicQueryRequest<'notification_preferences'> = {\n type: 'notification_preferences',\n expo_token: params.expoToken,\n };\n const data = await this.publicQuery(body);\n return mapMobileNotificationPreferences(data.preferences);\n }\n\n /*\n Public executes\n */\n\n /**\n * Unregisters an Expo push token, stopping delivery to that device. Unsigned, so it still works at logout\n * when a wallet signature may no longer be obtainable. Idempotent: unregistering an inactive or unknown\n * well-formed token succeeds.\n *\n * A registration that commits after this call re-activates the token, so stop or await any in-flight\n * {@link MobileClient.registerExpoToken} before unregistering.\n *\n * @throws {MobileServerFailureError} With error code `INVALID_EXPO_TOKEN` if the token is malformed.\n */\n async unregisterExpoToken(\n params: MobileUnregisterExpoTokenParams,\n ): Promise<MobileServerSuccessResponse> {\n const body: MobileServerPublicExecuteRequest<'unregister_expo_token'> = {\n type: 'unregister_expo_token',\n expo_token: params.expoToken,\n };\n return this.publicExecute(body);\n }\n\n /**\n * Replaces the push notification preferences of the wallet that owns the given Expo push token. Possession\n * of an active token is the credential rather than a signature, so anyone holding the token can overwrite\n * that wallet's preferences. The backend requires `schemaVersion` of 1, exactly one entry per known\n * category, and empty `scopes` on every entry.\n *\n * Writes are last-write-wins on commit order rather than ordered by a client nonce, so callers must\n * serialize their own preference writes.\n *\n * @throws {MobileServerFailureError} With error code `INVALID_PREFERENCES` if those rules are violated, or\n * `INVALID_EXPO_TOKEN` if the token is malformed or is not currently registered to a wallet.\n */\n async updateNotificationPreferences(\n params: MobileUpdateNotificationPreferencesParams,\n ): Promise<MobileServerSuccessResponse> {\n const body: MobileServerPublicExecuteRequest<'update_preferences'> = {\n type: 'update_preferences',\n expo_token: params.expoToken,\n preferences: mapMobileNotificationPreferencesToServer(params.preferences),\n };\n return this.publicExecute(body);\n }\n\n /*\n Signed queries\n */\n\n /**\n * Fetches the caller's own identity for a subaccount. Every non-isolated subaccount has an implicit\n * identity, so this resolves for any valid sender with `username` and `displayName` `null` until a username\n * is claimed.\n *\n * @throws {MobileServerFailureError} With error code `INVALID_IDENTITY_TARGET` if the sender is in the\n * engine-created isolated namespace, which cannot own an identity.\n */\n async getSelfIdentity(\n params: GetMobileSelfIdentityParams,\n ): Promise<MobileIdentity | null> {\n const signedRequest = await this.getSignedRequest(\n 'self_identity',\n params,\n {},\n );\n const data = await this.query<'self_identity'>(signedRequest);\n return data.identity ? mapMobileIdentity(data.identity) : null;\n }\n\n /**\n * Fetches the devices registered for push notifications for a wallet.\n */\n async getRegisteredDevices(\n params: GetMobileRegisteredDevicesParams,\n ): Promise<MobileRegisteredDevice[]> {\n const signedRequest = await this.getSignedRequest(\n 'registered_devices',\n params,\n {},\n );\n const data = await this.query<'registered_devices'>(signedRequest);\n return data.devices.map(mapMobileRegisteredDevice);\n }\n\n /*\n Signed executes\n */\n\n /**\n * Sets a subaccount's username, derived from the given display name. Upserts: the same call claims a first\n * username and renames an existing one, so callers never need to read the current identity first.\n *\n * @throws {MobileServerFailureError} With error code `INVALID_DISPLAY_NAME` if the display name violates\n * `MOBILE_DISPLAY_NAME_PATTERN`, `USERNAME_UNAVAILABLE` if the derived username is reserved or already\n * taken by another subaccount, `INVALID_IDENTITY_TARGET` if the sender is in the engine-created isolated\n * namespace, or `STALE_IDENTITY_UPDATE` if another identity write for this subaccount committed with a\n * later nonce (re-read the identity before retrying).\n */\n async setUsername(\n params: MobileSetUsernameParams,\n ): Promise<MobileServerSuccessResponse> {\n const signedRequest = await this.getSignedRequest('set_username', params, {\n display_name: params.displayName,\n });\n return this.execute(signedRequest);\n }\n\n /**\n * Sets whether a subaccount's profile is private.\n */\n async setPrivateMode(\n params: MobileSetPrivateModeParams,\n ): Promise<MobileServerSuccessResponse> {\n const signedRequest = await this.getSignedRequest(\n 'set_private_mode',\n params,\n { private_mode: params.privateMode },\n );\n return this.execute(signedRequest);\n }\n\n /**\n * Registers an Expo push token for the wallet, transferring active ownership of the token if another\n * wallet had registered it. Idempotent per `(wallet, token)`.\n *\n * @throws {MobileServerFailureError} With error code `INVALID_EXPO_TOKEN` if the token is not a valid Expo\n * push token, or `INVALID_DEVICE_METADATA` if `locale` (max 35 chars) or `appVersion` (max 64 chars) is\n * too long.\n */\n async registerExpoToken(\n params: MobileRegisterExpoTokenParams,\n ): Promise<MobileServerSuccessResponse> {\n const signedRequest = await this.getSignedRequest(\n 'register_expo_token',\n params,\n {\n expo_token: params.expoToken,\n platform: params.platform,\n locale: params.locale ?? null,\n app_version: params.appVersion ?? null,\n },\n );\n return this.execute(signedRequest);\n }\n\n /*\n Base Fns\n */\n\n protected async getSignedRequest<T extends MobileSignedInner['type']>(\n type: T,\n params: MobileSignedRequestParams,\n innerParams: MobileSignedInnerParams<T>,\n ): Promise<MobileSignedRequest> {\n // Use the linked signer if provided, otherwise use the default signer provided to the client\n const walletClient =\n this.opts.linkedSignerWalletClient ?? this.opts.walletClient;\n\n if (walletClient == null) {\n throw new WalletNotProvidedError();\n }\n\n const inner = { type, ...innerParams } as MobileSignedInner;\n return buildSignedMobileRequest({ ...params, walletClient, inner });\n }\n\n // Spelled out as an intersection rather than `MobileServerPublicQueryRequest<T>`: the latter is an indexed\n // access on a mapped type, which is not an inference site, so `T` would always widen to the full union.\n protected async publicQuery<T extends MobileServerPublicQueryRequestType>(\n body: { type: T } & MobileServerPublicQueryRequestByType[T],\n ): Promise<MobileServerPublicQuerySuccessResponse<T>> {\n const response = await this.axiosInstance.post<unknown>(\n `${this.opts.url}/mobile/public_query`,\n body,\n );\n\n this.checkResponseStatus(response);\n this.checkServerStatus(response);\n\n // checkServerStatus throws on failure responses so the cast to the success response is acceptable here\n return response.data as MobileServerPublicQuerySuccessResponse<T>;\n }\n\n protected async publicExecute(\n body: MobileServerPublicExecuteRequest,\n ): Promise<MobileServerSuccessResponse> {\n const response = await this.axiosInstance.post<MobileServerExecuteResult>(\n `${this.opts.url}/mobile/public_execute`,\n body,\n );\n\n this.checkResponseStatus(response);\n this.checkServerStatus(response);\n\n // checkServerStatus catches the failure result and throws the error, so the cast to the success response is acceptable here\n return response.data as MobileServerSuccessResponse;\n }\n\n protected async query<T extends MobileServerSignedQueryRequestType>(\n body: MobileSignedRequest,\n ): Promise<MobileServerSignedQuerySuccessResponse<T>> {\n const response = await this.axiosInstance.post<unknown>(\n `${this.opts.url}/mobile/query`,\n body,\n );\n\n this.checkResponseStatus(response);\n this.checkServerStatus(response);\n\n // checkServerStatus throws on failure responses so the cast to the success response is acceptable here\n return response.data as MobileServerSignedQuerySuccessResponse<T>;\n }\n\n protected async execute(\n body: MobileSignedRequest,\n ): Promise<MobileServerSuccessResponse> {\n const response = await this.axiosInstance.post<MobileServerExecuteResult>(\n `${this.opts.url}/mobile/execute`,\n body,\n );\n\n this.checkResponseStatus(response);\n this.checkServerStatus(response);\n\n // checkServerStatus catches the failure result and throws the error, so the cast to the success response is acceptable here\n return response.data as MobileServerSuccessResponse;\n }\n\n /**\n * Validates the HTTP status before interpreting the body. Unlike the engine, the mobile backend returns\n * failure envelopes with non-2xx statuses (e.g. 404 for `PROFILE_NOT_FOUND`), so a non-2xx response with a\n * failure envelope still throws the typed error; anything else is a transport-level error.\n */\n private checkResponseStatus(response: AxiosResponse<unknown>) {\n if (response.status >= 200 && response.status < 300) {\n return;\n }\n if (isMobileServerFailureResponse(response.data)) {\n throw new MobileServerFailureError(response.data, response.status);\n }\n throw new Error(\n `Unexpected response from mobile service: ${response.status} ${response.statusText}. Data: ${JSON.stringify(response.data)}`,\n );\n }\n\n private checkServerStatus(response: AxiosResponse<unknown>) {\n const { data } = response;\n\n if (isMobileServerFailureResponse(data)) {\n throw new MobileServerFailureError(data, response.status);\n }\n if (!isMobileServerSuccessResponse(data)) {\n throw new Error(\n `Unexpected response from mobile service: missing success envelope. Data: ${JSON.stringify(data)}`,\n );\n }\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAmFA,IAAa,eAAb,MAA0B;CAIxB,YAAY,MAAwB;EAClC,KAAK,OAAO;EACZ,KAAK,gBAAgB,MAAA,QAAM,OAAO;GAChC,iBAAiB;GAEjB,sBAAsB;EACxB,CAAC;CACH;;;;;;CA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d,MACsC;EACtC,MAAM,WAAW,MAAM,KAAK,cAAc,KACxC,GAAG,KAAK,KAAK,IAAI,yBACjB,IACF;EAEA,KAAK,oBAAoB,QAAQ;EACjC,KAAK,kBAAkB,QAAQ;EAG/B,OAAO,SAAS;CAClB;CAEA,MAAgB,MACd,MACoD;EACpD,MAAM,WAAW,MAAM,KAAK,cAAc,KACxC,GAAG,KAAK,KAAK,IAAI,gBACjB,IACF;EAEA,KAAK,oBAAoB,QAAQ;EACjC,KAAK,kBAAkB,QAAQ;EAG/B,OAAO,SAAS;CAClB;CAEA,MAAgB,QACd,MACsC;EACtC,MAAM,WAAW,MAAM,KAAK,cAAc,KACxC,GAAG,KAAK,KAAK,IAAI,kBACjB,IACF;EAEA,KAAK,oBAAoB,QAAQ;EACjC,KAAK,kBAAkB,QAAQ;EAG/B,OAAO,SAAS;CAClB;;;;;;CAOA,oBAA4B,UAAkC;EAC5D,IAAI,SAAS,UAAU,OAAO,SAAS,SAAS,KAC9C;EAEF,IAAIC,mCAAAA,8BAA8B,SAAS,IAAI,GAC7C,MAAM,IAAIC,uCAAAA,yBAAyB,SAAS,MAAM,SAAS,MAAM;EAEnE,MAAM,IAAI,MACR,4CAA4C,SAAS,OAAO,GAAG,SAAS,WAAW,UAAU,KAAK,UAAU,SAAS,IAAI,GAC3H;CACF;CAEA,kBAA0B,UAAkC;EAC1D,MAAM,EAAE,SAAS;EAEjB,IAAID,mCAAAA,8BAA8B,IAAI,GACpC,MAAM,IAAIC,uCAAAA,yBAAyB,MAAM,SAAS,MAAM;EAE1D,IAAI,CAACC,mCAAAA,8BAA8B,IAAI,GACrC,MAAM,IAAI,MACR,4EAA4E,KAAK,UAAU,IAAI,GACjG;CAEJ;AACF"}
@@ -1,4 +1,4 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_MobileClient = require("./MobileClient-9JSAzblH.cjs");
2
+ const require_MobileClient = require("./MobileClient-_i0ZV6Dq.cjs");
3
3
  require("./signing/index.cjs");
4
4
  exports.MobileClient = require_MobileClient.MobileClient;
@@ -1,6 +1,9 @@
1
- import { _ as MobileUpdateNotificationPreferencesParams, a as GetMobileUsernameAvailabilityParams, d as MobilePublicProfile, f as MobileRegisterExpoTokenParams, g as MobileUnregisterExpoTokenParams, h as MobileSignedRequestParams, i as GetMobileSelfIdentityParams, m as MobileSetPrivateModeParams, n as GetMobilePublicProfileParams, o as MobileClaimUsernameParams, p as MobileRegisteredDevice, r as GetMobileRegisteredDevicesParams, s as MobileIdentity, t as GetMobileNotificationPreferencesParams, u as MobileNotificationPreferences, v as MobileUpdateUsernameParams, y as MobileUsernameAvailability } from "./clientTypes-Et0PUa2d.cjs";
2
- import { i as MobileSignedRequest, n as MobileSignedInner, r as MobileSignedInnerParams } from "./types-uCD4BNZR.cjs";
3
- import { a as MobileServerSuccessResponse } from "./serverBaseTypes-BicXMrZV.cjs";
1
+ import { S as MobileUsernameAvailability, _ as MobileSetPrivateModeParams, a as GetMobileSelfIdentityParams, b as MobileUnregisterExpoTokenParams, c as MobileFeedPage, g as MobileRegisteredDevice, h as MobileRegisterExpoTokenParams, i as GetMobileRegisteredDevicesParams, m as MobilePublicProfile, n as GetMobileNotificationPreferencesParams, o as GetMobileUsernameAvailabilityParams, p as MobileNotificationPreferences, r as GetMobilePublicProfileParams, t as GetMobileFeedParams, u as MobileIdentity, v as MobileSetUsernameParams, x as MobileUpdateNotificationPreferencesParams, y as MobileSignedRequestParams } from "./clientTypes-D9qgtNlE.cjs";
2
+ import { i as MobileSignedRequest, n as MobileSignedInner, r as MobileSignedInnerParams } from "./types-bNB98pYk.cjs";
3
+ import { a as MobileServerPublicQueryRequestType, c as MobileServerSignedQueryRequestType, i as MobileServerPublicQueryRequestByType } from "./serverRequestTypes-CHDk6JwE.cjs";
4
+ import { n as MobileServerSuccessResponse } from "./serverBaseTypes-DSRgU2Fb.cjs";
5
+ import { n as MobileServerPublicExecuteRequest } from "./serverExecuteTypes-BCb6bUMP.cjs";
6
+ import { o as MobileServerPublicQuerySuccessResponse, u as MobileServerSignedQuerySuccessResponse } from "./serverQueryTypes-9H6P1vJ5.cjs";
4
7
  import { WalletClientWithAccount } from "@nadohq/shared";
5
8
  import { AxiosInstance } from "axios";
6
9
 
@@ -23,8 +26,8 @@ interface MobileClientOpts {
23
26
  linkedSignerWalletClient?: WalletClientWithAccount;
24
27
  }
25
28
  /**
26
- * Client for the Nado mobile service API: username claims, public profile lookups, privacy settings, and
27
- * push notification device/preference management.
29
+ * Client for the Nado mobile service API: usernames, public profile lookups, the global trade feed, privacy
30
+ * settings, and push notification device/preference management.
28
31
  */
29
32
  declare class MobileClient {
30
33
  readonly opts: MobileClientOpts;
@@ -41,34 +44,84 @@ declare class MobileClient {
41
44
  */
42
45
  getUsernameAvailability(params: GetMobileUsernameAvailabilityParams): Promise<MobileUsernameAvailability>;
43
46
  /**
44
- * Looks up a subaccount's public profile by username.
47
+ * Looks up a subaccount's public profile. Every non-isolated subaccount resolves, with `username` and
48
+ * `displayName` `null` until a username is claimed. Private Mode does not hide the profile itself, only the
49
+ * account's activity.
45
50
  *
46
- * @throws {MobileServerFailureError} With error code `PROFILE_NOT_FOUND` if no identity has claimed the
47
- * username or it is invalid. Private Mode does not hide the profile itself, only the account's activity.
51
+ * @throws {MobileServerFailureError} With error code `PROFILE_NOT_FOUND` if the subaccount is in the
52
+ * engine-created isolated namespace, which cannot own a profile.
48
53
  */
49
54
  getPublicProfile(params: GetMobilePublicProfileParams): Promise<MobilePublicProfile>;
50
55
  /**
51
- * Fetches the caller's own identity for a subaccount. Returns `null` if the subaccount has not claimed a
52
- * username yet — this is normal data, not an error.
56
+ * Fetches a page of the global trade feed: public perpetual trades, newest first, optionally filtered by a
57
+ * whole-dollar minimum notional (omitted means unfiltered). Trades by subaccounts that have not claimed a
58
+ * username are included with `null` name fields; only private accounts are filtered out. The feed is
59
+ * best-effort rather than authoritative history, and pagination is live (not snapshot), so deduplicate pages
60
+ * by {@link MobileFeedTrade.orderDigest}.
61
+ *
62
+ * @throws {MobileServerFailureError} With error code `INVALID_FEED_FILTER` if `minimumNotional` or
63
+ * `limit` is outside its allowed domain (fix the request; do not retry unchanged), or
64
+ * `INVALID_FEED_CURSOR` if the cursor is malformed or was issued for a different `minimumNotional`
65
+ * (discard the cursor and restart from the first page).
53
66
  */
54
- getSelfIdentity(params: GetMobileSelfIdentityParams): Promise<MobileIdentity | null>;
67
+ getFeed(params?: GetMobileFeedParams): Promise<MobileFeedPage>;
55
68
  /**
56
- * Fetches a wallet's push notification preferences. Falls back to the backend's defaults if the wallet has
57
- * never updated its preferences.
69
+ * Fetches the push notification preferences of the wallet that owns the given Expo push token. Unsigned —
70
+ * the token identifies the wallet on its own. Falls back to the backend's defaults if the wallet has never
71
+ * updated its preferences.
72
+ *
73
+ * @throws {MobileServerFailureError} With error code `INVALID_EXPO_TOKEN` if the token is malformed, or is
74
+ * not currently registered to a wallet.
58
75
  */
59
76
  getNotificationPreferences(params: GetMobileNotificationPreferencesParams): Promise<MobileNotificationPreferences>;
60
77
  /**
61
- * Fetches the devices registered for push notifications for a wallet.
78
+ * Unregisters an Expo push token, stopping delivery to that device. Unsigned, so it still works at logout
79
+ * when a wallet signature may no longer be obtainable. Idempotent: unregistering an inactive or unknown
80
+ * well-formed token succeeds.
81
+ *
82
+ * A registration that commits after this call re-activates the token, so stop or await any in-flight
83
+ * {@link MobileClient.registerExpoToken} before unregistering.
84
+ *
85
+ * @throws {MobileServerFailureError} With error code `INVALID_EXPO_TOKEN` if the token is malformed.
62
86
  */
63
- getRegisteredDevices(params: GetMobileRegisteredDevicesParams): Promise<MobileRegisteredDevice[]>;
87
+ unregisterExpoToken(params: MobileUnregisterExpoTokenParams): Promise<MobileServerSuccessResponse>;
64
88
  /**
65
- * Claims a username for a subaccount, derived from the given display name.
89
+ * Replaces the push notification preferences of the wallet that owns the given Expo push token. Possession
90
+ * of an active token is the credential rather than a signature, so anyone holding the token can overwrite
91
+ * that wallet's preferences. The backend requires `schemaVersion` of 1, exactly one entry per known
92
+ * category, and empty `scopes` on every entry.
93
+ *
94
+ * Writes are last-write-wins on commit order rather than ordered by a client nonce, so callers must
95
+ * serialize their own preference writes.
96
+ *
97
+ * @throws {MobileServerFailureError} With error code `INVALID_PREFERENCES` if those rules are violated, or
98
+ * `INVALID_EXPO_TOKEN` if the token is malformed or is not currently registered to a wallet.
66
99
  */
67
- claimUsername(params: MobileClaimUsernameParams): Promise<MobileServerSuccessResponse>;
100
+ updateNotificationPreferences(params: MobileUpdateNotificationPreferencesParams): Promise<MobileServerSuccessResponse>;
68
101
  /**
69
- * Updates the display name for a subaccount's already-claimed identity.
102
+ * Fetches the caller's own identity for a subaccount. Every non-isolated subaccount has an implicit
103
+ * identity, so this resolves for any valid sender with `username` and `displayName` `null` until a username
104
+ * is claimed.
105
+ *
106
+ * @throws {MobileServerFailureError} With error code `INVALID_IDENTITY_TARGET` if the sender is in the
107
+ * engine-created isolated namespace, which cannot own an identity.
70
108
  */
71
- updateUsername(params: MobileUpdateUsernameParams): Promise<MobileServerSuccessResponse>;
109
+ getSelfIdentity(params: GetMobileSelfIdentityParams): Promise<MobileIdentity | null>;
110
+ /**
111
+ * Fetches the devices registered for push notifications for a wallet.
112
+ */
113
+ getRegisteredDevices(params: GetMobileRegisteredDevicesParams): Promise<MobileRegisteredDevice[]>;
114
+ /**
115
+ * Sets a subaccount's username, derived from the given display name. Upserts: the same call claims a first
116
+ * username and renames an existing one, so callers never need to read the current identity first.
117
+ *
118
+ * @throws {MobileServerFailureError} With error code `INVALID_DISPLAY_NAME` if the display name violates
119
+ * `MOBILE_DISPLAY_NAME_PATTERN`, `USERNAME_UNAVAILABLE` if the derived username is reserved or already
120
+ * taken by another subaccount, `INVALID_IDENTITY_TARGET` if the sender is in the engine-created isolated
121
+ * namespace, or `STALE_IDENTITY_UPDATE` if another identity write for this subaccount committed with a
122
+ * later nonce (re-read the identity before retrying).
123
+ */
124
+ setUsername(params: MobileSetUsernameParams): Promise<MobileServerSuccessResponse>;
72
125
  /**
73
126
  * Sets whether a subaccount's profile is private.
74
127
  */
@@ -82,24 +135,12 @@ declare class MobileClient {
82
135
  * too long.
83
136
  */
84
137
  registerExpoToken(params: MobileRegisterExpoTokenParams): Promise<MobileServerSuccessResponse>;
85
- /**
86
- * Unregisters an Expo push token for the wallet. Idempotent — unregistering an unknown token succeeds.
87
- */
88
- unregisterExpoToken(params: MobileUnregisterExpoTokenParams): Promise<MobileServerSuccessResponse>;
89
- /**
90
- * Replaces the wallet's push notification preferences. The backend requires `schemaVersion` of 1, exactly
91
- * one entry per known category, and empty `scopes` on every entry.
92
- *
93
- * @throws {MobileServerFailureError} With error code `INVALID_PREFERENCES` if those rules are violated.
94
- */
95
- updateNotificationPreferences(params: MobileUpdateNotificationPreferencesParams): Promise<MobileServerSuccessResponse>;
96
138
  protected getSignedRequest<T extends MobileSignedInner['type']>(type: T, params: MobileSignedRequestParams, innerParams: MobileSignedInnerParams<T>): Promise<MobileSignedRequest>;
97
- protected publicQuery<TResponse extends {
98
- status: 'success';
99
- }>(body: object): Promise<TResponse>;
100
- protected query<TResponse extends {
101
- status: 'success';
102
- }>(body: MobileSignedRequest): Promise<TResponse>;
139
+ protected publicQuery<T extends MobileServerPublicQueryRequestType>(body: {
140
+ type: T;
141
+ } & MobileServerPublicQueryRequestByType[T]): Promise<MobileServerPublicQuerySuccessResponse<T>>;
142
+ protected publicExecute(body: MobileServerPublicExecuteRequest): Promise<MobileServerSuccessResponse>;
143
+ protected query<T extends MobileServerSignedQueryRequestType>(body: MobileSignedRequest): Promise<MobileServerSignedQuerySuccessResponse<T>>;
103
144
  protected execute(body: MobileSignedRequest): Promise<MobileServerSuccessResponse>;
104
145
  /**
105
146
  * Validates the HTTP status before interpreting the body. Unlike the engine, the mobile backend returns
@@ -1 +1 @@
1
- {"version":3,"file":"MobileClient.d.cts","names":[],"sources":["../src/src/MobileClient.ts"],"mappings":";;;;;;;;;;UAyDiB,gBAAA;EAAgB;;;EAI/B,GAAA;EAIA;;;EA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