@nadohq/mobile-client 0.30.0 → 0.32.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 (164) hide show
  1. package/README.md +15 -8
  2. package/dist/{MobileClient-CfDtaEeL.cjs → MobileClient-_i0ZV6Dq.cjs} +88 -48
  3. package/dist/MobileClient-_i0ZV6Dq.cjs.map +1 -0
  4. package/dist/MobileClient.cjs +1 -1
  5. package/dist/MobileClient.d.cts +66 -37
  6. package/dist/MobileClient.d.cts.map +1 -1
  7. package/dist/MobileClient.d.ts +66 -37
  8. package/dist/MobileClient.d.ts.map +1 -1
  9. package/dist/MobileClient.js +88 -48
  10. package/dist/MobileClient.js.map +1 -1
  11. package/dist/{MobileServerFailureError-B11rr9O5.d.cts → MobileServerFailureError-BoyAfEZA.d.cts} +3 -3
  12. package/dist/{MobileServerFailureError-B11rr9O5.d.cts.map → MobileServerFailureError-BoyAfEZA.d.cts.map} +1 -1
  13. package/dist/{MobileServerFailureError-DoIvXqYV.d.ts → MobileServerFailureError-MgYVBh5p.d.ts} +3 -3
  14. package/dist/{MobileServerFailureError-DoIvXqYV.d.ts.map → MobileServerFailureError-MgYVBh5p.d.ts.map} +1 -1
  15. package/dist/{buildSignedMobileRequest-EEnDgZF8.d.cts → buildSignedMobileRequest-CBMt97aY.d.cts} +2 -2
  16. package/dist/{buildSignedMobileRequest-EEnDgZF8.d.cts.map → buildSignedMobileRequest-CBMt97aY.d.cts.map} +1 -1
  17. package/dist/{buildSignedMobileRequest-B4KJ6T1y.d.ts → buildSignedMobileRequest-qEC4gWaI.d.ts} +2 -2
  18. package/dist/{buildSignedMobileRequest-B4KJ6T1y.d.ts.map → buildSignedMobileRequest-qEC4gWaI.d.ts.map} +1 -1
  19. package/dist/{canonicalize-Cc7hdZLJ.d.ts → canonicalize-QNARV_Xc.d.cts} +4 -4
  20. package/dist/canonicalize-QNARV_Xc.d.cts.map +1 -0
  21. package/dist/{canonicalize-CDdYnhL3.d.cts → canonicalize-wVdGejB1.d.ts} +4 -4
  22. package/dist/canonicalize-wVdGejB1.d.ts.map +1 -0
  23. package/dist/{clientTypes-BsOps_pY.d.ts → clientTypes-6utzUU-b.d.ts} +40 -32
  24. package/dist/clientTypes-6utzUU-b.d.ts.map +1 -0
  25. package/dist/{clientTypes-UFInIAQd.d.cts → clientTypes-D9qgtNlE.d.cts} +40 -32
  26. package/dist/clientTypes-D9qgtNlE.d.cts.map +1 -0
  27. package/dist/dataMappers.cjs +2 -1
  28. package/dist/dataMappers.cjs.map +1 -1
  29. package/dist/dataMappers.d.cts +3 -3
  30. package/dist/dataMappers.d.cts.map +1 -1
  31. package/dist/dataMappers.d.ts +3 -3
  32. package/dist/dataMappers.d.ts.map +1 -1
  33. package/dist/dataMappers.js +2 -1
  34. package/dist/dataMappers.js.map +1 -1
  35. package/dist/{eip712MethodByType-DCU415zf.d.cts → eip712MethodByType-CroIPqsJ.d.cts} +2 -2
  36. package/dist/eip712MethodByType-CroIPqsJ.d.cts.map +1 -0
  37. package/dist/{eip712MethodByType-B67XiwTu.d.ts → eip712MethodByType-DBUy4AdI.d.ts} +2 -2
  38. package/dist/eip712MethodByType-DBUy4AdI.d.ts.map +1 -0
  39. package/dist/index.cjs +1 -1
  40. package/dist/index.d.cts +15 -15
  41. package/dist/index.d.ts +15 -15
  42. package/dist/{mobileErrorCodes-Cj84nBnT.d.cts → mobileErrorCodes-CuQ5lyBV.d.ts} +2 -4
  43. package/dist/mobileErrorCodes-CuQ5lyBV.d.ts.map +1 -0
  44. package/dist/{mobileErrorCodes-Czmigq9x.d.ts → mobileErrorCodes-D_SyBm0k.d.cts} +2 -4
  45. package/dist/mobileErrorCodes-D_SyBm0k.d.cts.map +1 -0
  46. package/dist/{payloadHash-BSoGv3Lz.d.cts → payloadHash-B0tlFOK8.d.cts} +2 -2
  47. package/dist/payloadHash-B0tlFOK8.d.cts.map +1 -0
  48. package/dist/{payloadHash-BVP2v3p9.d.ts → payloadHash-D1yTQSF4.d.ts} +2 -2
  49. package/dist/payloadHash-D1yTQSF4.d.ts.map +1 -0
  50. package/dist/{serverBaseTypes-m3zEi0X9.d.ts → serverBaseTypes-CzRgwUvA.d.ts} +2 -2
  51. package/dist/{serverBaseTypes-m3zEi0X9.d.ts.map → serverBaseTypes-CzRgwUvA.d.ts.map} +1 -1
  52. package/dist/{serverBaseTypes-A16onlPN.d.cts → serverBaseTypes-DSRgU2Fb.d.cts} +2 -2
  53. package/dist/{serverBaseTypes-A16onlPN.d.cts.map → serverBaseTypes-DSRgU2Fb.d.cts.map} +1 -1
  54. package/dist/serverExecuteTypes-BCb6bUMP.d.cts +19 -0
  55. package/dist/serverExecuteTypes-BCb6bUMP.d.cts.map +1 -0
  56. package/dist/serverExecuteTypes-CI3NBW2Z.d.ts +19 -0
  57. package/dist/serverExecuteTypes-CI3NBW2Z.d.ts.map +1 -0
  58. package/dist/{serverModelTypes-CPZUvVil.d.cts → serverModelTypes-BYQcsRrx.d.cts} +14 -11
  59. package/dist/serverModelTypes-BYQcsRrx.d.cts.map +1 -0
  60. package/dist/{serverModelTypes-CqnqHY5F.d.ts → serverModelTypes-DvPs5qs3.d.ts} +14 -11
  61. package/dist/serverModelTypes-DvPs5qs3.d.ts.map +1 -0
  62. package/dist/{serverQueryTypes-CJLWWZBs.d.ts → serverQueryTypes-9H6P1vJ5.d.cts} +9 -8
  63. package/dist/serverQueryTypes-9H6P1vJ5.d.cts.map +1 -0
  64. package/dist/{serverQueryTypes-C_cCx0Ac.d.cts → serverQueryTypes-Cbjx0bIj.d.ts} +9 -8
  65. package/dist/serverQueryTypes-Cbjx0bIj.d.ts.map +1 -0
  66. package/dist/{serverRequestTypes-DQDy3K9O.d.ts → serverRequestTypes-CHDk6JwE.d.cts} +31 -8
  67. package/dist/serverRequestTypes-CHDk6JwE.d.cts.map +1 -0
  68. package/dist/{serverRequestTypes-DnU_FfMI.d.cts → serverRequestTypes-DYTLrCpz.d.ts} +31 -8
  69. package/dist/serverRequestTypes-DYTLrCpz.d.ts.map +1 -0
  70. package/dist/{serverResponseGuards-BlvfJjsa.d.cts → serverResponseGuards-DRMHmfXh.d.cts} +2 -2
  71. package/dist/{serverResponseGuards-BlvfJjsa.d.cts.map → serverResponseGuards-DRMHmfXh.d.cts.map} +1 -1
  72. package/dist/{serverResponseGuards-gpHH8SHk.d.ts → serverResponseGuards-DpbZvJfL.d.ts} +2 -2
  73. package/dist/{serverResponseGuards-gpHH8SHk.d.ts.map → serverResponseGuards-DpbZvJfL.d.ts.map} +1 -1
  74. package/dist/signing/buildSignedMobileRequest.cjs +1 -1
  75. package/dist/signing/buildSignedMobileRequest.d.cts +1 -1
  76. package/dist/signing/buildSignedMobileRequest.d.ts +1 -1
  77. package/dist/signing/canonicalize.cjs +4 -37
  78. package/dist/signing/canonicalize.cjs.map +1 -1
  79. package/dist/signing/canonicalize.d.cts +1 -1
  80. package/dist/signing/canonicalize.d.ts +1 -1
  81. package/dist/signing/canonicalize.js +4 -37
  82. package/dist/signing/canonicalize.js.map +1 -1
  83. package/dist/signing/eip712MethodByType.cjs +1 -5
  84. package/dist/signing/eip712MethodByType.cjs.map +1 -1
  85. package/dist/signing/eip712MethodByType.d.cts +1 -1
  86. package/dist/signing/eip712MethodByType.d.ts +1 -1
  87. package/dist/signing/eip712MethodByType.js +1 -5
  88. package/dist/signing/eip712MethodByType.js.map +1 -1
  89. package/dist/signing/index.d.cts +5 -5
  90. package/dist/signing/index.d.ts +5 -5
  91. package/dist/signing/payloadHash.cjs +1 -1
  92. package/dist/signing/payloadHash.d.cts +1 -1
  93. package/dist/signing/payloadHash.d.ts +1 -1
  94. package/dist/signing/types.d.cts +1 -1
  95. package/dist/signing/types.d.ts +1 -1
  96. package/dist/types/MobileServerFailureError.cjs +1 -1
  97. package/dist/types/MobileServerFailureError.d.cts +1 -1
  98. package/dist/types/MobileServerFailureError.d.ts +1 -1
  99. package/dist/types/clientTypes.d.cts +2 -2
  100. package/dist/types/clientTypes.d.ts +2 -2
  101. package/dist/types/index.d.cts +9 -9
  102. package/dist/types/index.d.ts +9 -9
  103. package/dist/types/mobileErrorCodes.cjs +2 -3
  104. package/dist/types/mobileErrorCodes.cjs.map +1 -1
  105. package/dist/types/mobileErrorCodes.d.cts +1 -1
  106. package/dist/types/mobileErrorCodes.d.ts +1 -1
  107. package/dist/types/mobileErrorCodes.js +1 -2
  108. package/dist/types/mobileErrorCodes.js.map +1 -1
  109. package/dist/types/serverBaseTypes.d.cts +1 -1
  110. package/dist/types/serverBaseTypes.d.ts +1 -1
  111. package/dist/types/serverExecuteTypes.d.cts +2 -2
  112. package/dist/types/serverExecuteTypes.d.ts +2 -2
  113. package/dist/types/serverModelTypes.cjs.map +1 -1
  114. package/dist/types/serverModelTypes.d.cts +1 -1
  115. package/dist/types/serverModelTypes.d.ts +1 -1
  116. package/dist/types/serverModelTypes.js.map +1 -1
  117. package/dist/types/serverQueryTypes.d.cts +1 -1
  118. package/dist/types/serverQueryTypes.d.ts +1 -1
  119. package/dist/types/serverRequestTypes.d.cts +2 -2
  120. package/dist/types/serverRequestTypes.d.ts +2 -2
  121. package/dist/{types-UHjZR-js.d.ts → types-CQE3HD2V.d.ts} +4 -15
  122. package/dist/types-CQE3HD2V.d.ts.map +1 -0
  123. package/dist/{types-CzOeSYnW.d.cts → types-bNB98pYk.d.cts} +4 -15
  124. package/dist/types-bNB98pYk.d.cts.map +1 -0
  125. package/dist/utils/index.d.cts +1 -1
  126. package/dist/utils/index.d.ts +1 -1
  127. package/dist/utils/serverResponseGuards.d.cts +1 -1
  128. package/dist/utils/serverResponseGuards.d.ts +1 -1
  129. package/package.json +3 -3
  130. package/src/MobileClient.ts +119 -90
  131. package/src/dataMappers.ts +1 -0
  132. package/src/signing/canonicalize.ts +4 -37
  133. package/src/signing/eip712MethodByType.ts +1 -5
  134. package/src/signing/signing.test.ts +17 -60
  135. package/src/signing/types.ts +2 -12
  136. package/src/types/clientTypes.ts +38 -30
  137. package/src/types/mobileErrorCodes.ts +1 -2
  138. package/src/types/serverExecuteTypes.ts +17 -0
  139. package/src/types/serverModelTypes.ts +13 -10
  140. package/src/types/serverQueryTypes.ts +5 -4
  141. package/src/types/serverRequestTypes.ts +27 -4
  142. package/dist/MobileClient-CfDtaEeL.cjs.map +0 -1
  143. package/dist/canonicalize-CDdYnhL3.d.cts.map +0 -1
  144. package/dist/canonicalize-Cc7hdZLJ.d.ts.map +0 -1
  145. package/dist/clientTypes-BsOps_pY.d.ts.map +0 -1
  146. package/dist/clientTypes-UFInIAQd.d.cts.map +0 -1
  147. package/dist/eip712MethodByType-B67XiwTu.d.ts.map +0 -1
  148. package/dist/eip712MethodByType-DCU415zf.d.cts.map +0 -1
  149. package/dist/mobileErrorCodes-Cj84nBnT.d.cts.map +0 -1
  150. package/dist/mobileErrorCodes-Czmigq9x.d.ts.map +0 -1
  151. package/dist/payloadHash-BSoGv3Lz.d.cts.map +0 -1
  152. package/dist/payloadHash-BVP2v3p9.d.ts.map +0 -1
  153. package/dist/serverExecuteTypes-C-bioiuQ.d.cts +0 -11
  154. package/dist/serverExecuteTypes-C-bioiuQ.d.cts.map +0 -1
  155. package/dist/serverExecuteTypes-DfzWOeIx.d.ts +0 -11
  156. package/dist/serverExecuteTypes-DfzWOeIx.d.ts.map +0 -1
  157. package/dist/serverModelTypes-CPZUvVil.d.cts.map +0 -1
  158. package/dist/serverModelTypes-CqnqHY5F.d.ts.map +0 -1
  159. package/dist/serverQueryTypes-CJLWWZBs.d.ts.map +0 -1
  160. package/dist/serverQueryTypes-C_cCx0Ac.d.cts.map +0 -1
  161. package/dist/serverRequestTypes-DQDy3K9O.d.ts.map +0 -1
  162. package/dist/serverRequestTypes-DnU_FfMI.d.cts.map +0 -1
  163. package/dist/types-CzOeSYnW.d.cts.map +0 -1
  164. package/dist/types-UHjZR-js.d.ts.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,23 +63,26 @@ 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 a page of the global trade feed: public, named, perpetual trades, newest first, optionally
80
- * filtered by a whole-dollar minimum notional (omitted means unfiltered). The feed is best-effort rather
81
- * than authoritative history, and pagination is live (not snapshot), so deduplicate pages by
82
- * {@link MobileFeedTrade.orderDigest}.
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}.
83
86
  *
84
87
  * @throws {MobileServerFailureError} With error code `INVALID_FEED_FILTER` if `minimumNotional` or
85
88
  * `limit` is outside its allowed domain (fix the request; do not retry unchanged), or
@@ -96,8 +99,64 @@ var MobileClient = class {
96
99
  return require_dataMappers.mapMobileFeedPage(await this.publicQuery(body));
97
100
  }
98
101
  /**
99
- * Fetches the caller's own identity for a subaccount. Returns `null` if the subaccount has not claimed a
100
- * username yet — this is normal data, not an error.
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.
108
+ */
109
+ async getNotificationPreferences(params) {
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.
101
160
  */
102
161
  async getSelfIdentity(params) {
103
162
  const signedRequest = await this.getSignedRequest("self_identity", params, {});
@@ -105,14 +164,6 @@ var MobileClient = class {
105
164
  return data.identity ? require_dataMappers.mapMobileIdentity(data.identity) : null;
106
165
  }
107
166
  /**
108
- * Fetches a wallet's push notification preferences. Falls back to the backend's defaults if the wallet has
109
- * never updated its preferences.
110
- */
111
- async getNotificationPreferences(params) {
112
- const signedRequest = await this.getSignedRequest("notification_preferences", params, {});
113
- return require_dataMappers.mapMobileNotificationPreferences((await this.query(signedRequest)).preferences);
114
- }
115
- /**
116
167
  * Fetches the devices registered for push notifications for a wallet.
117
168
  */
118
169
  async getRegisteredDevices(params) {
@@ -120,17 +171,17 @@ var MobileClient = class {
120
171
  return (await this.query(signedRequest)).devices.map(require_dataMappers.mapMobileRegisteredDevice);
121
172
  }
122
173
  /**
123
- * Claims a username for a subaccount, derived from the given display name.
124
- */
125
- async claimUsername(params) {
126
- const signedRequest = await this.getSignedRequest("claim_username", params, { display_name: params.displayName });
127
- return this.execute(signedRequest);
128
- }
129
- /**
130
- * 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).
131
182
  */
132
- async updateUsername(params) {
133
- 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 });
134
185
  return this.execute(signedRequest);
135
186
  }
136
187
  /**
@@ -157,23 +208,6 @@ var MobileClient = class {
157
208
  });
158
209
  return this.execute(signedRequest);
159
210
  }
160
- /**
161
- * Unregisters an Expo push token for the wallet. Idempotent — unregistering an unknown token succeeds.
162
- */
163
- async unregisterExpoToken(params) {
164
- const signedRequest = await this.getSignedRequest("unregister_expo_token", params, { expo_token: params.expoToken });
165
- return this.execute(signedRequest);
166
- }
167
- /**
168
- * Replaces the wallet's push notification preferences. The backend requires `schemaVersion` of 1, exactly
169
- * one entry per known category, and empty `scopes` on every entry.
170
- *
171
- * @throws {MobileServerFailureError} With error code `INVALID_PREFERENCES` if those rules are violated.
172
- */
173
- async updateNotificationPreferences(params) {
174
- const signedRequest = await this.getSignedRequest("update_preferences", params, { preferences: require_dataMappers.mapMobileNotificationPreferencesToServer(params.preferences) });
175
- return this.execute(signedRequest);
176
- }
177
211
  async getSignedRequest(type, params, innerParams) {
178
212
  const walletClient = this.opts.linkedSignerWalletClient ?? this.opts.walletClient;
179
213
  if (walletClient == null) throw new _nadohq_shared.WalletNotProvidedError();
@@ -193,6 +227,12 @@ var MobileClient = class {
193
227
  this.checkServerStatus(response);
194
228
  return response.data;
195
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
+ }
196
236
  async query(body) {
197
237
  const response = await this.axiosInstance.post(`${this.opts.url}/mobile/query`, body);
198
238
  this.checkResponseStatus(response);
@@ -235,4 +275,4 @@ Object.defineProperty(exports, "__toESM", {
235
275
  }
236
276
  });
237
277
 
238
- //# sourceMappingURL=MobileClient-CfDtaEeL.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,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AQ;EACjC,KAAK,kBAAkB,QAAQ;EAG/B,OAAO,SAAS;CAClB;CAEA,MAAgB,cACd,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-CfDtaEeL.cjs");
2
+ const require_MobileClient = require("./MobileClient-_i0ZV6Dq.cjs");
3
3
  require("./signing/index.cjs");
4
4
  exports.MobileClient = require_MobileClient.MobileClient;
@@ -1,8 +1,9 @@
1
- import { C as MobileUsernameAvailability, S as MobileUpdateUsernameParams, _ as MobileRegisteredDevice, a as GetMobileSelfIdentityParams, b as MobileUnregisterExpoTokenParams, d as MobileIdentity, g as MobileRegisterExpoTokenParams, h as MobilePublicProfile, i as GetMobileRegisteredDevicesParams, l as MobileFeedPage, m as MobileNotificationPreferences, n as GetMobileNotificationPreferencesParams, o as GetMobileUsernameAvailabilityParams, r as GetMobilePublicProfileParams, s as MobileClaimUsernameParams, t as GetMobileFeedParams, v as MobileSetPrivateModeParams, x as MobileUpdateNotificationPreferencesParams, y as MobileSignedRequestParams } from "./clientTypes-UFInIAQd.cjs";
2
- import { i as MobileSignedRequest, n as MobileSignedInner, r as MobileSignedInnerParams } from "./types-CzOeSYnW.cjs";
3
- import { n as MobileServerPublicQueryRequestByType, o as MobileServerSignedQueryRequestType, r as MobileServerPublicQueryRequestType } from "./serverRequestTypes-DnU_FfMI.cjs";
4
- import { n as MobileServerSuccessResponse } from "./serverBaseTypes-A16onlPN.cjs";
5
- import { o as MobileServerPublicQuerySuccessResponse, u as MobileServerSignedQuerySuccessResponse } from "./serverQueryTypes-C_cCx0Ac.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";
6
7
  import { WalletClientWithAccount } from "@nadohq/shared";
7
8
  import { AxiosInstance } from "axios";
8
9
 
@@ -25,8 +26,8 @@ interface MobileClientOpts {
25
26
  linkedSignerWalletClient?: WalletClientWithAccount;
26
27
  }
27
28
  /**
28
- * Client for the Nado mobile service API: username claims, public profile lookups, privacy settings, and
29
- * 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.
30
31
  */
31
32
  declare class MobileClient {
32
33
  readonly opts: MobileClientOpts;
@@ -43,17 +44,20 @@ declare class MobileClient {
43
44
  */
44
45
  getUsernameAvailability(params: GetMobileUsernameAvailabilityParams): Promise<MobileUsernameAvailability>;
45
46
  /**
46
- * 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.
47
50
  *
48
- * @throws {MobileServerFailureError} With error code `PROFILE_NOT_FOUND` if no identity has claimed the
49
- * 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.
50
53
  */
51
54
  getPublicProfile(params: GetMobilePublicProfileParams): Promise<MobilePublicProfile>;
52
55
  /**
53
- * Fetches a page of the global trade feed: public, named, perpetual trades, newest first, optionally
54
- * filtered by a whole-dollar minimum notional (omitted means unfiltered). The feed is best-effort rather
55
- * than authoritative history, and pagination is live (not snapshot), so deduplicate pages by
56
- * {@link MobileFeedTrade.orderDigest}.
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}.
57
61
  *
58
62
  * @throws {MobileServerFailureError} With error code `INVALID_FEED_FILTER` if `minimumNotional` or
59
63
  * `limit` is outside its allowed domain (fix the request; do not retry unchanged), or
@@ -62,27 +66,62 @@ declare class MobileClient {
62
66
  */
63
67
  getFeed(params?: GetMobileFeedParams): Promise<MobileFeedPage>;
64
68
  /**
65
- * Fetches the caller's own identity for a subaccount. Returns `null` if the subaccount has not claimed a
66
- * username yet — this is normal data, not an error.
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.
67
75
  */
68
- getSelfIdentity(params: GetMobileSelfIdentityParams): Promise<MobileIdentity | null>;
76
+ getNotificationPreferences(params: GetMobileNotificationPreferencesParams): Promise<MobileNotificationPreferences>;
69
77
  /**
70
- * Fetches a wallet's push notification preferences. Falls back to the backend's defaults if the wallet has
71
- * never updated its preferences.
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.
72
86
  */
73
- getNotificationPreferences(params: GetMobileNotificationPreferencesParams): Promise<MobileNotificationPreferences>;
87
+ unregisterExpoToken(params: MobileUnregisterExpoTokenParams): Promise<MobileServerSuccessResponse>;
74
88
  /**
75
- * Fetches the devices registered for push notifications for a wallet.
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.
76
99
  */
77
- getRegisteredDevices(params: GetMobileRegisteredDevicesParams): Promise<MobileRegisteredDevice[]>;
100
+ updateNotificationPreferences(params: MobileUpdateNotificationPreferencesParams): Promise<MobileServerSuccessResponse>;
101
+ /**
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.
108
+ */
109
+ getSelfIdentity(params: GetMobileSelfIdentityParams): Promise<MobileIdentity | null>;
78
110
  /**
79
- * Claims a username for a subaccount, derived from the given display name.
111
+ * Fetches the devices registered for push notifications for a wallet.
80
112
  */
81
- claimUsername(params: MobileClaimUsernameParams): Promise<MobileServerSuccessResponse>;
113
+ getRegisteredDevices(params: GetMobileRegisteredDevicesParams): Promise<MobileRegisteredDevice[]>;
82
114
  /**
83
- * Updates the display name for a subaccount's already-claimed identity.
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).
84
123
  */
85
- updateUsername(params: MobileUpdateUsernameParams): Promise<MobileServerSuccessResponse>;
124
+ setUsername(params: MobileSetUsernameParams): Promise<MobileServerSuccessResponse>;
86
125
  /**
87
126
  * Sets whether a subaccount's profile is private.
88
127
  */
@@ -96,21 +135,11 @@ declare class MobileClient {
96
135
  * too long.
97
136
  */
98
137
  registerExpoToken(params: MobileRegisterExpoTokenParams): Promise<MobileServerSuccessResponse>;
99
- /**
100
- * Unregisters an Expo push token for the wallet. Idempotent — unregistering an unknown token succeeds.
101
- */
102
- unregisterExpoToken(params: MobileUnregisterExpoTokenParams): Promise<MobileServerSuccessResponse>;
103
- /**
104
- * Replaces the wallet's push notification preferences. The backend requires `schemaVersion` of 1, exactly
105
- * one entry per known category, and empty `scopes` on every entry.
106
- *
107
- * @throws {MobileServerFailureError} With error code `INVALID_PREFERENCES` if those rules are violated.
108
- */
109
- updateNotificationPreferences(params: MobileUpdateNotificationPreferencesParams): Promise<MobileServerSuccessResponse>;
110
138
  protected getSignedRequest<T extends MobileSignedInner['type']>(type: T, params: MobileSignedRequestParams, innerParams: MobileSignedInnerParams<T>): Promise<MobileSignedRequest>;
111
139
  protected publicQuery<T extends MobileServerPublicQueryRequestType>(body: {
112
140
  type: T;
113
141
  } & MobileServerPublicQueryRequestByType[T]): Promise<MobileServerPublicQuerySuccessResponse<T>>;
142
+ protected publicExecute(body: MobileServerPublicExecuteRequest): Promise<MobileServerSuccessResponse>;
114
143
  protected query<T extends MobileServerSignedQueryRequestType>(body: MobileSignedRequest): Promise<MobileServerSignedQuerySuccessResponse<T>>;
115
144
  protected execute(body: MobileSignedRequest): Promise<MobileServerSuccessResponse>;
116
145
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"MobileClient.d.cts","names":[],"sources":["../src/src/MobileClient.ts"],"mappings":";;;;;;;;;;;;UA6DiB,gBAAA;EAAgB;;;EAI/B,GAAA;EAIA;;;EAAA,YAAA,GAAe,uBAAA;EAImC;AAAA;AAOpD;EAPE,wBAAA,GAA2B,uBAAuB;AAAA;;;;;cAOvC,YAAA;EAAA,SACF,IAAA,EAAM,gBAAA;EAAA,SACN,aAAA,EAAe,aAAA;cAEZ,IAAA,EAAM,gBAAA;EA8CP;;;;;EAhCJ,eAAA,CACL,wBAAA,EAA0B,uBAAA;EAwEjB;;;EA5DL,uBAAA,CACJ,MAAA,EAAQ,mCAAA,GACP,OAAA,CAAQ,0BAAA;EA0ER;;;;;;EA3DG,gBAAA,CACJ,MAAA,EAAQ,4BAAA,GACP,OAAA,CAAQ,mBAAA;EA0GD;;;;;;;;;;;EAtFJ,OAAA,CAAQ,MAAA,GAAQ,mBAAA,GAA2B,OAAA,CAAQ,cAAA;EA2J/C;;;;EAxIJ,eAAA,CACJ,MAAA,EAAQ,2BAAA,GACP,OAAA,CAAQ,cAAA;EA0JD;;;;EA5IJ,0BAAA,CACJ,MAAA,EAAQ,sCAAA,GACP,OAAA,CAAQ,6BAAA;EA2J2B;;;EA9IhC,oBAAA,CACJ,MAAA,EAAQ,gCAAA,GACP,OAAA,CAAQ,sBAAA;EA8IuC;;;EA7H5C,aAAA,CACJ,MAAA,EAAQ,yBAAA,GACP,OAAA,CAAQ,2BAAA;EAyIH;;;EA3HF,cAAA,CACJ,MAAA,EAAQ,0BAAA,GACP,OAAA,CAAQ,2BAAA;EAwIH;;;EA5HF,cAAA,CACJ,MAAA,EAAQ,0BAAA,GACP,OAAA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