@nadohq/otc-client 0.55.0 → 0.57.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 (50) hide show
  1. package/README.md +27 -0
  2. package/dist/{OtcClient-qUPYb1BP.cjs → OtcClient-BYspxGIn.cjs} +28 -1
  3. package/dist/OtcClient-BYspxGIn.cjs.map +1 -0
  4. package/dist/OtcClient.cjs +1 -1
  5. package/dist/OtcClient.d.cts +16 -2
  6. package/dist/OtcClient.d.cts.map +1 -1
  7. package/dist/OtcClient.d.ts +16 -2
  8. package/dist/OtcClient.d.ts.map +1 -1
  9. package/dist/OtcClient.js +27 -0
  10. package/dist/OtcClient.js.map +1 -1
  11. package/dist/{clientTypes-CMksWClt.d.ts → clientTypes-DadMpdOk.d.ts} +29 -5
  12. package/dist/clientTypes-DadMpdOk.d.ts.map +1 -0
  13. package/dist/{clientTypes-CjBtkKtk.d.cts → clientTypes-_bJZ6Psb.d.cts} +29 -5
  14. package/dist/clientTypes-_bJZ6Psb.d.cts.map +1 -0
  15. package/dist/index.cjs +4 -1
  16. package/dist/index.d.cts +4 -3
  17. package/dist/index.d.ts +4 -3
  18. package/dist/index.js +2 -1
  19. package/dist/rfqSubscription.d.cts +2 -2
  20. package/dist/rfqSubscription.d.ts +2 -2
  21. package/dist/{serverTypes-CGY8MQaT.d.cts → serverTypes-CgQcIVf1.d.cts} +16 -2
  22. package/dist/serverTypes-CgQcIVf1.d.cts.map +1 -0
  23. package/dist/{serverTypes-CGY8MQaT.d.ts → serverTypes-CgQcIVf1.d.ts} +16 -2
  24. package/dist/serverTypes-CgQcIVf1.d.ts.map +1 -0
  25. package/dist/siweMessage.cjs +31 -0
  26. package/dist/siweMessage.cjs.map +1 -0
  27. package/dist/siweMessage.d.cts +23 -0
  28. package/dist/siweMessage.d.cts.map +1 -0
  29. package/dist/siweMessage.d.ts +23 -0
  30. package/dist/siweMessage.d.ts.map +1 -0
  31. package/dist/siweMessage.js +29 -0
  32. package/dist/siweMessage.js.map +1 -0
  33. package/dist/types/clientTypes.d.cts +2 -2
  34. package/dist/types/clientTypes.d.ts +2 -2
  35. package/dist/types/index.d.cts +3 -3
  36. package/dist/types/index.d.ts +3 -3
  37. package/dist/types/serverTypes.d.cts +2 -2
  38. package/dist/types/serverTypes.d.ts +2 -2
  39. package/package.json +4 -4
  40. package/src/OtcClient.ts +49 -2
  41. package/src/index.ts +1 -0
  42. package/src/siweMessage.test.ts +34 -0
  43. package/src/siweMessage.ts +36 -0
  44. package/src/types/clientTypes.ts +29 -2
  45. package/src/types/serverTypes.ts +16 -0
  46. package/dist/OtcClient-qUPYb1BP.cjs.map +0 -1
  47. package/dist/clientTypes-CMksWClt.d.ts.map +0 -1
  48. package/dist/clientTypes-CjBtkKtk.d.cts.map +0 -1
  49. package/dist/serverTypes-CGY8MQaT.d.cts.map +0 -1
  50. package/dist/serverTypes-CGY8MQaT.d.ts.map +0 -1
package/README.md CHANGED
@@ -37,6 +37,33 @@ It is also available on a `NadoClient` context.
37
37
  const result = await nadoClient.context.otcClient.execute({ dealId, taker });
38
38
  ```
39
39
 
40
+ ## Private quote login
41
+
42
+ Quotes keyed by an owner address need a session while `owner_auth_enabled` is on. Quotes keyed by
43
+ the public wallet `0xfffffffffffffffffffffffffffffffffffffffe` never do. The session is an HttpOnly
44
+ cookie the browser keeps; open a new quote socket after logging in, since a socket keeps whatever
45
+ session it had at its handshake.
46
+
47
+ ```ts
48
+ import { buildOtcSiweMessage, OtcClient } from '@nadohq/otc-client';
49
+
50
+ const nonce = await otcClient.getAuthNonce({ sender });
51
+ const message = buildOtcSiweMessage({
52
+ domain: 'testnet.nado.xyz',
53
+ uri: 'https://testnet.nado.xyz',
54
+ address: signerAddress, // owner or the sender's linked signer, checksummed
55
+ chainId: 763373,
56
+ nonce: nonce.nonce,
57
+ issuedAtMs: nonce.issued_at_ms,
58
+ sender,
59
+ });
60
+ const signature = await walletClient.signMessage({ message });
61
+ await otcClient.verifyAuth({ message, signature }); // throws on a non-200
62
+ ```
63
+
64
+ The login routes only admit approved web origins, so they can be called from a browser page
65
+ on one of those origins.
66
+
40
67
  ## Quotes
41
68
 
42
69
  `subscribe` and `unsubscribe` are the only RFQ methods. Pass `streams`, 1–100 entries applied
@@ -44,6 +44,24 @@ var OtcClient = class {
44
44
  });
45
45
  }
46
46
  /**
47
+ * Starts a private quote login for `sender`. Build the message with `buildOtcSiweMessage`,
48
+ * sign it, and pass it to {@link OtcClient.verifyAuth} within 60s. Throws on a non-200.
49
+ */
50
+ async getAuthNonce(params) {
51
+ return this.postAuth("/v1/auth/nonce", { sender: params.sender });
52
+ }
53
+ /**
54
+ * Completes a private quote login. On success the browser holds the session cookie; open a
55
+ * new quote socket afterwards, since a socket keeps the session it had at its handshake.
56
+ * Throws on a non-200; the message carries the service's `error` code.
57
+ */
58
+ async verifyAuth(params) {
59
+ return this.postAuth("/v1/auth/verify", {
60
+ message: params.message,
61
+ signature: params.signature
62
+ });
63
+ }
64
+ /**
47
65
  * Submits a signed taker order. Send this body unchanged on `retry_same_request`.
48
66
  */
49
67
  async execute(params) {
@@ -73,6 +91,15 @@ var OtcClient = class {
73
91
  ready: response.status === 200
74
92
  };
75
93
  }
94
+ /** The login routes need credentials. */
95
+ async postAuth(path, body) {
96
+ const response = await this.axiosInstance.post(`${this.opts.url}${path}`, body, { withCredentials: true });
97
+ this.checkResponseStatus(response);
98
+ return response.data;
99
+ }
100
+ checkResponseStatus(response) {
101
+ if (response.status !== 200 || !response.data) throw Error(`Unexpected response from server: ${response.status} ${response.statusText}. Data: ${JSON.stringify(response.data)}`);
102
+ }
76
103
  async postExecution(path, body) {
77
104
  return (await this.axiosInstance.post(`${this.opts.url}${path}`, body)).data;
78
105
  }
@@ -85,4 +112,4 @@ Object.defineProperty(exports, "OtcClient", {
85
112
  }
86
113
  });
87
114
 
88
- //# sourceMappingURL=OtcClient-qUPYb1BP.cjs.map
115
+ //# sourceMappingURL=OtcClient-BYspxGIn.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"OtcClient-BYspxGIn.cjs","names":[],"sources":["../src/OtcClient.ts"],"sourcesContent":["import { getNadoClientTypeHeaders } from '@nadohq/shared';\nimport axios, { AxiosInstance, AxiosResponse } from 'axios';\nimport {\n OtcExecuteParams,\n OtcGetAuthNonceParams,\n OtcGetExecutionStatusParams,\n OtcGetReadyParams,\n OtcReadyResult,\n OtcVerifyAuthParams,\n} from './types/clientTypes';\nimport {\n OtcServerAuthNonce,\n OtcServerAuthSession,\n OtcServerExecutionResponse,\n} from './types/serverTypes';\n\nexport interface OtcClientOpts {\n /**\n * OTC service origin, without a path, e.g. {@link OTC_CLIENT_ENDPOINTS}.\n */\n url: string;\n // If provided, identifies the calling client, sent as a header with every request\n clientType?: string;\n}\n\n/**\n * Client for the public OTC service.\n *\n * {@link OtcClient.execute} does not sign. The caller supplies an already-signed taker order.\n * A quote is not required. {@link OtcClient.getExecutionStatus} only reads a deal; it does not\n * start or resume one.\n *\n * Responses are the JSON body as returned, including non-200 admission responses. Branch on\n * `status` and `recovery_action`.\n */\nexport class OtcClient {\n readonly opts: OtcClientOpts;\n readonly axiosInstance: AxiosInstance;\n\n constructor(opts: OtcClientOpts) {\n this.opts = opts;\n this.axiosInstance = axios.create({\n withCredentials: false,\n validateStatus: () => true,\n headers: getNadoClientTypeHeaders(opts.clientType),\n });\n }\n\n /**\n * Starts a private quote login for `sender`. Build the message with `buildOtcSiweMessage`,\n * sign it, and pass it to {@link OtcClient.verifyAuth} within 60s. Throws on a non-200.\n */\n async getAuthNonce(\n params: OtcGetAuthNonceParams,\n ): Promise<OtcServerAuthNonce> {\n return this.postAuth('/v1/auth/nonce', { sender: params.sender });\n }\n\n /**\n * Completes a private quote login. On success the browser holds the session cookie; open a\n * new quote socket afterwards, since a socket keeps the session it had at its handshake.\n * Throws on a non-200; the message carries the service's `error` code.\n */\n async verifyAuth(params: OtcVerifyAuthParams): Promise<OtcServerAuthSession> {\n return this.postAuth('/v1/auth/verify', {\n message: params.message,\n signature: params.signature,\n });\n }\n\n /**\n * Submits a signed taker order. Send this body unchanged on `retry_same_request`.\n */\n async execute(params: OtcExecuteParams): Promise<OtcServerExecutionResponse> {\n return this.postExecution('/v1/executor', {\n deal_id: params.dealId,\n taker: params.taker,\n ...(params.pricerId ? { pricer_id: params.pricerId } : {}),\n });\n }\n\n /**\n * Reads one execution. Use it after a lost response, a refresh, or `wait`.\n */\n async getExecutionStatus(\n params: OtcGetExecutionStatusParams,\n ): Promise<OtcServerExecutionResponse> {\n return this.postExecution('/v1/executor/status', {\n deal_id: params.dealId,\n taker_digest: params.takerDigest,\n });\n }\n\n /**\n * Checks that quote and deal product scopes overlap for a route. An omitted `pricerId`\n * asks the service default. A direct execution needs a matching deal worker, not a prior quote.\n */\n async getReady(params: OtcGetReadyParams = {}): Promise<OtcReadyResult> {\n const response = await this.axiosInstance.get(`${this.opts.url}/ready`, {\n params: params.pricerId ? { pricer_id: params.pricerId } : undefined,\n });\n return {\n httpStatus: response.status,\n ready: response.status === 200,\n };\n }\n\n /** The login routes need credentials. */\n private async postAuth<T>(path: string, body: unknown): Promise<T> {\n const response = await this.axiosInstance.post(\n `${this.opts.url}${path}`,\n body,\n { withCredentials: true },\n );\n this.checkResponseStatus(response);\n return response.data as T;\n }\n\n private checkResponseStatus(response: AxiosResponse) {\n if (response.status !== 200 || !response.data) {\n throw Error(\n `Unexpected response from server: ${response.status} ${response.statusText}. Data: ${JSON.stringify(response.data)}`,\n );\n }\n }\n\n private async postExecution(\n path: string,\n body: unknown,\n ): Promise<OtcServerExecutionResponse> {\n const response = await this.axiosInstance.post(\n `${this.opts.url}${path}`,\n body,\n );\n return response.data as OtcServerExecutionResponse;\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAmCA,IAAa,YAAb,MAAuB;CAIrB,YAAY,MAAqB;EAC/B,KAAK,OAAO;EACZ,KAAK,gBAAgB,MAAA,QAAM,OAAO;GAChC,iBAAiB;GACjB,sBAAsB;GACtB,UAAA,GAAA,eAAA,0BAAkC,KAAK,UAAU;EACnD,CAAC;CACH;;;;;CAMA,MAAM,aACJ,QAC6B;EAC7B,OAAO,KAAK,SAAS,kBAAkB,EAAE,QAAQ,OAAO,OAAO,CAAC;CAClE;;;;;;CAOA,MAAM,WAAW,QAA4D;EAC3E,OAAO,KAAK,SAAS,mBAAmB;GACtC,SAAS,OAAO;GAChB,WAAW,OAAO;EACpB,CAAC;CACH;;;;CAKA,MAAM,QAAQ,QAA+D;EAC3E,OAAO,KAAK,cAAc,gBAAgB;GACxC,SAAS,OAAO;GAChB,OAAO,OAAO;GACd,GAAI,OAAO,WAAW,EAAE,WAAW,OAAO,SAAS,IAAI,CAAC;EAC1D,CAAC;CACH;;;;CAKA,MAAM,mBACJ,QACqC;EACrC,OAAO,KAAK,cAAc,uBAAuB;GAC/C,SAAS,OAAO;GAChB,cAAc,OAAO;EACvB,CAAC;CACH;;;;;CAMA,MAAM,SAAS,SAA4B,CAAC,GAA4B;EACtE,MAAM,WAAW,MAAM,KAAK,cAAc,IAAI,GAAG,KAAK,KAAK,IAAI,SAAS,EACtE,QAAQ,OAAO,WAAW,EAAE,WAAW,OAAO,SAAS,IAAI,KAAA,EAC7D,CAAC;EACD,OAAO;GACL,YAAY,SAAS;GACrB,OAAO,SAAS,WAAW;EAC7B;CACF;;CAGA,MAAc,SAAY,MAAc,MAA2B;EACjE,MAAM,WAAW,MAAM,KAAK,cAAc,KACxC,GAAG,KAAK,KAAK,MAAM,QACnB,MACA,EAAE,iBAAiB,KAAK,CAC1B;EACA,KAAK,oBAAoB,QAAQ;EACjC,OAAO,SAAS;CAClB;CAEA,oBAA4B,UAAyB;EACnD,IAAI,SAAS,WAAW,OAAO,CAAC,SAAS,MACvC,MAAM,MACJ,oCAAoC,SAAS,OAAO,GAAG,SAAS,WAAW,UAAU,KAAK,UAAU,SAAS,IAAI,GACnH;CAEJ;CAEA,MAAc,cACZ,MACA,MACqC;EAKrC,QAAO,MAJgB,KAAK,cAAc,KACxC,GAAG,KAAK,KAAK,MAAM,QACnB,IACF,GACgB;CAClB;AACF"}
@@ -1,3 +1,3 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_OtcClient = require("./OtcClient-qUPYb1BP.cjs");
2
+ const require_OtcClient = require("./OtcClient-BYspxGIn.cjs");
3
3
  exports.OtcClient = require_OtcClient.OtcClient;
@@ -1,5 +1,5 @@
1
- import { i as OtcServerExecutionResponse } from "./serverTypes-CGY8MQaT.cjs";
2
- import { a as OtcReadyResult, n as OtcGetExecutionStatusParams, r as OtcGetReadyParams, t as OtcExecuteParams } from "./clientTypes-CjBtkKtk.cjs";
1
+ import { n as OtcServerAuthNonce, o as OtcServerExecutionResponse, r as OtcServerAuthSession } from "./serverTypes-CgQcIVf1.cjs";
2
+ import { i as OtcGetReadyParams, n as OtcGetAuthNonceParams, o as OtcReadyResult, r as OtcGetExecutionStatusParams, t as OtcExecuteParams, u as OtcVerifyAuthParams } from "./clientTypes-_bJZ6Psb.cjs";
3
3
  import { AxiosInstance } from "axios";
4
4
 
5
5
  //#region src/OtcClient.d.ts
@@ -24,6 +24,17 @@ declare class OtcClient {
24
24
  readonly opts: OtcClientOpts;
25
25
  readonly axiosInstance: AxiosInstance;
26
26
  constructor(opts: OtcClientOpts);
27
+ /**
28
+ * Starts a private quote login for `sender`. Build the message with `buildOtcSiweMessage`,
29
+ * sign it, and pass it to {@link OtcClient.verifyAuth} within 60s. Throws on a non-200.
30
+ */
31
+ getAuthNonce(params: OtcGetAuthNonceParams): Promise<OtcServerAuthNonce>;
32
+ /**
33
+ * Completes a private quote login. On success the browser holds the session cookie; open a
34
+ * new quote socket afterwards, since a socket keeps the session it had at its handshake.
35
+ * Throws on a non-200; the message carries the service's `error` code.
36
+ */
37
+ verifyAuth(params: OtcVerifyAuthParams): Promise<OtcServerAuthSession>;
27
38
  /**
28
39
  * Submits a signed taker order. Send this body unchanged on `retry_same_request`.
29
40
  */
@@ -37,6 +48,9 @@ declare class OtcClient {
37
48
  * asks the service default. A direct execution needs a matching deal worker, not a prior quote.
38
49
  */
39
50
  getReady(params?: OtcGetReadyParams): Promise<OtcReadyResult>;
51
+ /** The login routes need credentials. */
52
+ private postAuth;
53
+ private checkResponseStatus;
40
54
  private postExecution;
41
55
  }
42
56
  //#endregion
@@ -1 +1 @@
1
- {"version":3,"file":"OtcClient.d.cts","names":[],"sources":["../src/src/OtcClient.ts"],"mappings":";;;;;UAUiB,aAAA;;AAAjB;;EAIE,GAAA;EAEA,UAAU;AAAA;AAaZ;;;;;;;;;;AAAA,cAAa,SAAA;EAAA,SACF,IAAA,EAAM,aAAA;EAAA,SACN,aAAA,EAAe,aAAA;cAEZ,IAAA,EAAM,aAAA;EAoC8B;;;EAxB1C,OAAA,CAAQ,MAAA,EAAQ,gBAAA,GAAmB,OAAA,CAAQ,0BAAA;EAflC;;;EA0BT,kBAAA,CACJ,MAAA,EAAQ,2BAAA,GACP,OAAA,CAAQ,0BAAA;EAzBO;;;;EAoCZ,QAAA,CAAS,MAAA,GAAQ,iBAAA,GAAyB,OAAA,CAAQ,cAAA;EAAA,QAU1C,aAAA;AAAA"}
1
+ {"version":3,"file":"OtcClient.d.cts","names":[],"sources":["../src/src/OtcClient.ts"],"mappings":";;;;;UAgBiB,aAAA;;AAAjB;;EAIE,GAAA;EAEA,UAAU;AAAA;AAaZ;;;;;;;;;;AAAA,cAAa,SAAA;EAAA,SACF,IAAA,EAAM,aAAA;EAAA,SACN,aAAA,EAAe,aAAA;cAEZ,IAAA,EAAM,aAAA;EAkCuB;;;;EArBnC,YAAA,CACJ,MAAA,EAAQ,qBAAA,GACP,OAAA,CAAQ,kBAAA;EA2C6C;;;;;EAlClD,UAAA,CAAW,MAAA,EAAQ,mBAAA,GAAsB,OAAA,CAAQ,oBAAA;EA1B9C;;;EAoCH,OAAA,CAAQ,MAAA,EAAQ,gBAAA,GAAmB,OAAA,CAAQ,0BAAA;EAlCrC;;;EA6CN,kBAAA,CACJ,MAAA,EAAQ,2BAAA,GACP,OAAA,CAAQ,0BAAA;EAhCR;;;;EA2CG,QAAA,CAAS,MAAA,GAAQ,iBAAA,GAAyB,OAAA,CAAQ,cAAA;EAlCT;EAAA,QA6CjC,QAAA;EAAA,QAUN,mBAAA;EAAA,QAQM,aAAA;AAAA"}
@@ -1,5 +1,5 @@
1
- import { i as OtcServerExecutionResponse } from "./serverTypes-CGY8MQaT.js";
2
- import { a as OtcReadyResult, n as OtcGetExecutionStatusParams, r as OtcGetReadyParams, t as OtcExecuteParams } from "./clientTypes-CMksWClt.js";
1
+ import { n as OtcServerAuthNonce, o as OtcServerExecutionResponse, r as OtcServerAuthSession } from "./serverTypes-CgQcIVf1.js";
2
+ import { i as OtcGetReadyParams, n as OtcGetAuthNonceParams, o as OtcReadyResult, r as OtcGetExecutionStatusParams, t as OtcExecuteParams, u as OtcVerifyAuthParams } from "./clientTypes-DadMpdOk.js";
3
3
  import { AxiosInstance } from "axios";
4
4
 
5
5
  //#region src/OtcClient.d.ts
@@ -24,6 +24,17 @@ declare class OtcClient {
24
24
  readonly opts: OtcClientOpts;
25
25
  readonly axiosInstance: AxiosInstance;
26
26
  constructor(opts: OtcClientOpts);
27
+ /**
28
+ * Starts a private quote login for `sender`. Build the message with `buildOtcSiweMessage`,
29
+ * sign it, and pass it to {@link OtcClient.verifyAuth} within 60s. Throws on a non-200.
30
+ */
31
+ getAuthNonce(params: OtcGetAuthNonceParams): Promise<OtcServerAuthNonce>;
32
+ /**
33
+ * Completes a private quote login. On success the browser holds the session cookie; open a
34
+ * new quote socket afterwards, since a socket keeps the session it had at its handshake.
35
+ * Throws on a non-200; the message carries the service's `error` code.
36
+ */
37
+ verifyAuth(params: OtcVerifyAuthParams): Promise<OtcServerAuthSession>;
27
38
  /**
28
39
  * Submits a signed taker order. Send this body unchanged on `retry_same_request`.
29
40
  */
@@ -37,6 +48,9 @@ declare class OtcClient {
37
48
  * asks the service default. A direct execution needs a matching deal worker, not a prior quote.
38
49
  */
39
50
  getReady(params?: OtcGetReadyParams): Promise<OtcReadyResult>;
51
+ /** The login routes need credentials. */
52
+ private postAuth;
53
+ private checkResponseStatus;
40
54
  private postExecution;
41
55
  }
42
56
  //#endregion
@@ -1 +1 @@
1
- {"version":3,"file":"OtcClient.d.ts","names":[],"sources":["../src/src/OtcClient.ts"],"mappings":";;;;;UAUiB,aAAA;;AAAjB;;EAIE,GAAA;EAEA,UAAU;AAAA;AAaZ;;;;;;;;;;AAAA,cAAa,SAAA;EAAA,SACF,IAAA,EAAM,aAAA;EAAA,SACN,aAAA,EAAe,aAAA;cAEZ,IAAA,EAAM,aAAA;EAoC8B;;;EAxB1C,OAAA,CAAQ,MAAA,EAAQ,gBAAA,GAAmB,OAAA,CAAQ,0BAAA;EAflC;;;EA0BT,kBAAA,CACJ,MAAA,EAAQ,2BAAA,GACP,OAAA,CAAQ,0BAAA;EAzBO;;;;EAoCZ,QAAA,CAAS,MAAA,GAAQ,iBAAA,GAAyB,OAAA,CAAQ,cAAA;EAAA,QAU1C,aAAA;AAAA"}
1
+ {"version":3,"file":"OtcClient.d.ts","names":[],"sources":["../src/src/OtcClient.ts"],"mappings":";;;;;UAgBiB,aAAA;;AAAjB;;EAIE,GAAA;EAEA,UAAU;AAAA;AAaZ;;;;;;;;;;AAAA,cAAa,SAAA;EAAA,SACF,IAAA,EAAM,aAAA;EAAA,SACN,aAAA,EAAe,aAAA;cAEZ,IAAA,EAAM,aAAA;EAkCuB;;;;EArBnC,YAAA,CACJ,MAAA,EAAQ,qBAAA,GACP,OAAA,CAAQ,kBAAA;EA2C6C;;;;;EAlClD,UAAA,CAAW,MAAA,EAAQ,mBAAA,GAAsB,OAAA,CAAQ,oBAAA;EA1B9C;;;EAoCH,OAAA,CAAQ,MAAA,EAAQ,gBAAA,GAAmB,OAAA,CAAQ,0BAAA;EAlCrC;;;EA6CN,kBAAA,CACJ,MAAA,EAAQ,2BAAA,GACP,OAAA,CAAQ,0BAAA;EAhCR;;;;EA2CG,QAAA,CAAS,MAAA,GAAQ,iBAAA,GAAyB,OAAA,CAAQ,cAAA;EAlCT;EAAA,QA6CjC,QAAA;EAAA,QAUN,mBAAA;EAAA,QAQM,aAAA;AAAA"}
package/dist/OtcClient.js CHANGED
@@ -21,6 +21,24 @@ var OtcClient = class {
21
21
  });
22
22
  }
23
23
  /**
24
+ * Starts a private quote login for `sender`. Build the message with `buildOtcSiweMessage`,
25
+ * sign it, and pass it to {@link OtcClient.verifyAuth} within 60s. Throws on a non-200.
26
+ */
27
+ async getAuthNonce(params) {
28
+ return this.postAuth("/v1/auth/nonce", { sender: params.sender });
29
+ }
30
+ /**
31
+ * Completes a private quote login. On success the browser holds the session cookie; open a
32
+ * new quote socket afterwards, since a socket keeps the session it had at its handshake.
33
+ * Throws on a non-200; the message carries the service's `error` code.
34
+ */
35
+ async verifyAuth(params) {
36
+ return this.postAuth("/v1/auth/verify", {
37
+ message: params.message,
38
+ signature: params.signature
39
+ });
40
+ }
41
+ /**
24
42
  * Submits a signed taker order. Send this body unchanged on `retry_same_request`.
25
43
  */
26
44
  async execute(params) {
@@ -50,6 +68,15 @@ var OtcClient = class {
50
68
  ready: response.status === 200
51
69
  };
52
70
  }
71
+ /** The login routes need credentials. */
72
+ async postAuth(path, body) {
73
+ const response = await this.axiosInstance.post(`${this.opts.url}${path}`, body, { withCredentials: true });
74
+ this.checkResponseStatus(response);
75
+ return response.data;
76
+ }
77
+ checkResponseStatus(response) {
78
+ if (response.status !== 200 || !response.data) throw Error(`Unexpected response from server: ${response.status} ${response.statusText}. Data: ${JSON.stringify(response.data)}`);
79
+ }
53
80
  async postExecution(path, body) {
54
81
  return (await this.axiosInstance.post(`${this.opts.url}${path}`, body)).data;
55
82
  }
@@ -1 +1 @@
1
- {"version":3,"file":"OtcClient.js","names":[],"sources":["../src/OtcClient.ts"],"sourcesContent":["import { getNadoClientTypeHeaders } from '@nadohq/shared';\nimport axios, { AxiosInstance } from 'axios';\nimport {\n OtcExecuteParams,\n OtcGetExecutionStatusParams,\n OtcGetReadyParams,\n OtcReadyResult,\n} from './types/clientTypes';\nimport { OtcServerExecutionResponse } from './types/serverTypes';\n\nexport interface OtcClientOpts {\n /**\n * OTC service origin, without a path, e.g. {@link OTC_CLIENT_ENDPOINTS}.\n */\n url: string;\n // If provided, identifies the calling client, sent as a header with every request\n clientType?: string;\n}\n\n/**\n * Client for the public OTC service.\n *\n * {@link OtcClient.execute} does not sign. The caller supplies an already-signed taker order.\n * A quote is not required. {@link OtcClient.getExecutionStatus} only reads a deal; it does not\n * start or resume one.\n *\n * Responses are the JSON body as returned, including non-200 admission responses. Branch on\n * `status` and `recovery_action`.\n */\nexport class OtcClient {\n readonly opts: OtcClientOpts;\n readonly axiosInstance: AxiosInstance;\n\n constructor(opts: OtcClientOpts) {\n this.opts = opts;\n this.axiosInstance = axios.create({\n withCredentials: false,\n validateStatus: () => true,\n headers: getNadoClientTypeHeaders(opts.clientType),\n });\n }\n\n /**\n * Submits a signed taker order. Send this body unchanged on `retry_same_request`.\n */\n async execute(params: OtcExecuteParams): Promise<OtcServerExecutionResponse> {\n return this.postExecution('/v1/executor', {\n deal_id: params.dealId,\n taker: params.taker,\n ...(params.pricerId ? { pricer_id: params.pricerId } : {}),\n });\n }\n\n /**\n * Reads one execution. Use it after a lost response, a refresh, or `wait`.\n */\n async getExecutionStatus(\n params: OtcGetExecutionStatusParams,\n ): Promise<OtcServerExecutionResponse> {\n return this.postExecution('/v1/executor/status', {\n deal_id: params.dealId,\n taker_digest: params.takerDigest,\n });\n }\n\n /**\n * Checks that quote and deal product scopes overlap for a route. An omitted `pricerId`\n * asks the service default. A direct execution needs a matching deal worker, not a prior quote.\n */\n async getReady(params: OtcGetReadyParams = {}): Promise<OtcReadyResult> {\n const response = await this.axiosInstance.get(`${this.opts.url}/ready`, {\n params: params.pricerId ? { pricer_id: params.pricerId } : undefined,\n });\n return {\n httpStatus: response.status,\n ready: response.status === 200,\n };\n }\n\n private async postExecution(\n path: string,\n body: unknown,\n ): Promise<OtcServerExecutionResponse> {\n const response = await this.axiosInstance.post(\n `${this.opts.url}${path}`,\n body,\n );\n return response.data as OtcServerExecutionResponse;\n }\n}\n"],"mappings":";;;;;;;;;;;;;AA6BA,IAAa,YAAb,MAAuB;CAIrB,YAAY,MAAqB;EAC/B,KAAK,OAAO;EACZ,KAAK,gBAAgB,MAAM,OAAO;GAChC,iBAAiB;GACjB,sBAAsB;GACtB,SAAS,yBAAyB,KAAK,UAAU;EACnD,CAAC;CACH;;;;CAKA,MAAM,QAAQ,QAA+D;EAC3E,OAAO,KAAK,cAAc,gBAAgB;GACxC,SAAS,OAAO;GAChB,OAAO,OAAO;GACd,GAAI,OAAO,WAAW,EAAE,WAAW,OAAO,SAAS,IAAI,CAAC;EAC1D,CAAC;CACH;;;;CAKA,MAAM,mBACJ,QACqC;EACrC,OAAO,KAAK,cAAc,uBAAuB;GAC/C,SAAS,OAAO;GAChB,cAAc,OAAO;EACvB,CAAC;CACH;;;;;CAMA,MAAM,SAAS,SAA4B,CAAC,GAA4B;EACtE,MAAM,WAAW,MAAM,KAAK,cAAc,IAAI,GAAG,KAAK,KAAK,IAAI,SAAS,EACtE,QAAQ,OAAO,WAAW,EAAE,WAAW,OAAO,SAAS,IAAI,KAAA,EAC7D,CAAC;EACD,OAAO;GACL,YAAY,SAAS;GACrB,OAAO,SAAS,WAAW;EAC7B;CACF;CAEA,MAAc,cACZ,MACA,MACqC;EAKrC,QAAO,MAJgB,KAAK,cAAc,KACxC,GAAG,KAAK,KAAK,MAAM,QACnB,IACF,GACgB;CAClB;AACF"}
1
+ {"version":3,"file":"OtcClient.js","names":[],"sources":["../src/OtcClient.ts"],"sourcesContent":["import { getNadoClientTypeHeaders } from '@nadohq/shared';\nimport axios, { AxiosInstance, AxiosResponse } from 'axios';\nimport {\n OtcExecuteParams,\n OtcGetAuthNonceParams,\n OtcGetExecutionStatusParams,\n OtcGetReadyParams,\n OtcReadyResult,\n OtcVerifyAuthParams,\n} from './types/clientTypes';\nimport {\n OtcServerAuthNonce,\n OtcServerAuthSession,\n OtcServerExecutionResponse,\n} from './types/serverTypes';\n\nexport interface OtcClientOpts {\n /**\n * OTC service origin, without a path, e.g. {@link OTC_CLIENT_ENDPOINTS}.\n */\n url: string;\n // If provided, identifies the calling client, sent as a header with every request\n clientType?: string;\n}\n\n/**\n * Client for the public OTC service.\n *\n * {@link OtcClient.execute} does not sign. The caller supplies an already-signed taker order.\n * A quote is not required. {@link OtcClient.getExecutionStatus} only reads a deal; it does not\n * start or resume one.\n *\n * Responses are the JSON body as returned, including non-200 admission responses. Branch on\n * `status` and `recovery_action`.\n */\nexport class OtcClient {\n readonly opts: OtcClientOpts;\n readonly axiosInstance: AxiosInstance;\n\n constructor(opts: OtcClientOpts) {\n this.opts = opts;\n this.axiosInstance = axios.create({\n withCredentials: false,\n validateStatus: () => true,\n headers: getNadoClientTypeHeaders(opts.clientType),\n });\n }\n\n /**\n * Starts a private quote login for `sender`. Build the message with `buildOtcSiweMessage`,\n * sign it, and pass it to {@link OtcClient.verifyAuth} within 60s. Throws on a non-200.\n */\n async getAuthNonce(\n params: OtcGetAuthNonceParams,\n ): Promise<OtcServerAuthNonce> {\n return this.postAuth('/v1/auth/nonce', { sender: params.sender });\n }\n\n /**\n * Completes a private quote login. On success the browser holds the session cookie; open a\n * new quote socket afterwards, since a socket keeps the session it had at its handshake.\n * Throws on a non-200; the message carries the service's `error` code.\n */\n async verifyAuth(params: OtcVerifyAuthParams): Promise<OtcServerAuthSession> {\n return this.postAuth('/v1/auth/verify', {\n message: params.message,\n signature: params.signature,\n });\n }\n\n /**\n * Submits a signed taker order. Send this body unchanged on `retry_same_request`.\n */\n async execute(params: OtcExecuteParams): Promise<OtcServerExecutionResponse> {\n return this.postExecution('/v1/executor', {\n deal_id: params.dealId,\n taker: params.taker,\n ...(params.pricerId ? { pricer_id: params.pricerId } : {}),\n });\n }\n\n /**\n * Reads one execution. Use it after a lost response, a refresh, or `wait`.\n */\n async getExecutionStatus(\n params: OtcGetExecutionStatusParams,\n ): Promise<OtcServerExecutionResponse> {\n return this.postExecution('/v1/executor/status', {\n deal_id: params.dealId,\n taker_digest: params.takerDigest,\n });\n }\n\n /**\n * Checks that quote and deal product scopes overlap for a route. An omitted `pricerId`\n * asks the service default. A direct execution needs a matching deal worker, not a prior quote.\n */\n async getReady(params: OtcGetReadyParams = {}): Promise<OtcReadyResult> {\n const response = await this.axiosInstance.get(`${this.opts.url}/ready`, {\n params: params.pricerId ? { pricer_id: params.pricerId } : undefined,\n });\n return {\n httpStatus: response.status,\n ready: response.status === 200,\n };\n }\n\n /** The login routes need credentials. */\n private async postAuth<T>(path: string, body: unknown): Promise<T> {\n const response = await this.axiosInstance.post(\n `${this.opts.url}${path}`,\n body,\n { withCredentials: true },\n );\n this.checkResponseStatus(response);\n return response.data as T;\n }\n\n private checkResponseStatus(response: AxiosResponse) {\n if (response.status !== 200 || !response.data) {\n throw Error(\n `Unexpected response from server: ${response.status} ${response.statusText}. Data: ${JSON.stringify(response.data)}`,\n );\n }\n }\n\n private async postExecution(\n path: string,\n body: unknown,\n ): Promise<OtcServerExecutionResponse> {\n const response = await this.axiosInstance.post(\n `${this.opts.url}${path}`,\n body,\n );\n return response.data as OtcServerExecutionResponse;\n }\n}\n"],"mappings":";;;;;;;;;;;;;AAmCA,IAAa,YAAb,MAAuB;CAIrB,YAAY,MAAqB;EAC/B,KAAK,OAAO;EACZ,KAAK,gBAAgB,MAAM,OAAO;GAChC,iBAAiB;GACjB,sBAAsB;GACtB,SAAS,yBAAyB,KAAK,UAAU;EACnD,CAAC;CACH;;;;;CAMA,MAAM,aACJ,QAC6B;EAC7B,OAAO,KAAK,SAAS,kBAAkB,EAAE,QAAQ,OAAO,OAAO,CAAC;CAClE;;;;;;CAOA,MAAM,WAAW,QAA4D;EAC3E,OAAO,KAAK,SAAS,mBAAmB;GACtC,SAAS,OAAO;GAChB,WAAW,OAAO;EACpB,CAAC;CACH;;;;CAKA,MAAM,QAAQ,QAA+D;EAC3E,OAAO,KAAK,cAAc,gBAAgB;GACxC,SAAS,OAAO;GAChB,OAAO,OAAO;GACd,GAAI,OAAO,WAAW,EAAE,WAAW,OAAO,SAAS,IAAI,CAAC;EAC1D,CAAC;CACH;;;;CAKA,MAAM,mBACJ,QACqC;EACrC,OAAO,KAAK,cAAc,uBAAuB;GAC/C,SAAS,OAAO;GAChB,cAAc,OAAO;EACvB,CAAC;CACH;;;;;CAMA,MAAM,SAAS,SAA4B,CAAC,GAA4B;EACtE,MAAM,WAAW,MAAM,KAAK,cAAc,IAAI,GAAG,KAAK,KAAK,IAAI,SAAS,EACtE,QAAQ,OAAO,WAAW,EAAE,WAAW,OAAO,SAAS,IAAI,KAAA,EAC7D,CAAC;EACD,OAAO;GACL,YAAY,SAAS;GACrB,OAAO,SAAS,WAAW;EAC7B;CACF;;CAGA,MAAc,SAAY,MAAc,MAA2B;EACjE,MAAM,WAAW,MAAM,KAAK,cAAc,KACxC,GAAG,KAAK,KAAK,MAAM,QACnB,MACA,EAAE,iBAAiB,KAAK,CAC1B;EACA,KAAK,oBAAoB,QAAQ;EACjC,OAAO,SAAS;CAClB;CAEA,oBAA4B,UAAyB;EACnD,IAAI,SAAS,WAAW,OAAO,CAAC,SAAS,MACvC,MAAM,MACJ,oCAAoC,SAAS,OAAO,GAAG,SAAS,WAAW,UAAU,KAAK,UAAU,SAAS,IAAI,GACnH;CAEJ;CAEA,MAAc,cACZ,MACA,MACqC;EAKrC,QAAO,MAJgB,KAAK,cAAc,KACxC,GAAG,KAAK,KAAK,MAAM,QACnB,IACF,GACgB;CAClB;AACF"}
@@ -1,4 +1,4 @@
1
- import { t as OtcQuoteSizeUnit } from "./serverTypes-CGY8MQaT.js";
1
+ import { t as OtcQuoteSizeUnit } from "./serverTypes-CgQcIVf1.js";
2
2
  import { EngineServerPlaceOrderParams } from "@nadohq/engine-client";
3
3
 
4
4
  //#region src/types/clientTypes.d.ts
@@ -11,7 +11,7 @@ interface OtcExecuteParams {
11
11
  /** Client-generated idempotency key, 1–128 bytes. Kept across retries of this intent. */
12
12
  dealId: string;
13
13
  taker: OtcServerTakerOrderParams;
14
- /** Execution route. Omitted selects the service default (`awr`). */
14
+ /** The route. The service requires it and has no default. */
15
15
  pricerId?: string;
16
16
  }
17
17
  interface OtcGetExecutionStatusParams {
@@ -21,6 +21,30 @@ interface OtcGetExecutionStatusParams {
21
21
  interface OtcGetReadyParams {
22
22
  pricerId?: string;
23
23
  }
24
+ interface OtcGetAuthNonceParams {
25
+ /** The 32-byte subaccount the login is bound to. */
26
+ sender: string;
27
+ }
28
+ interface OtcSiweMessageParams {
29
+ /** Host of the page origin, e.g. `testnet.nado.xyz`. */
30
+ domain: string;
31
+ /** The page origin, with no path or trailing slash. */
32
+ uri: string;
33
+ /** The signing address, EIP-55 checksummed: the owner or the sender's linked signer. */
34
+ address: string;
35
+ chainId: number;
36
+ nonce: string;
37
+ /** `issued_at_ms` from the nonce response; a local clock can be rejected as future. */
38
+ issuedAtMs: number;
39
+ /** The same sender as the nonce request. */
40
+ sender: string;
41
+ }
42
+ interface OtcVerifyAuthParams {
43
+ /** The SIWE text exactly as signed. */
44
+ message: string;
45
+ /** 65-byte hex `personal_sign` signature of `message`. */
46
+ signature: string;
47
+ }
24
48
  /**
25
49
  * Route coverage. HTTP 200 is ready; 400 and 503 are not. This does not guarantee liquidity
26
50
  * or that an order will be accepted.
@@ -39,7 +63,7 @@ interface OtcQuoteStream {
39
63
  wallet: string;
40
64
  size: string;
41
65
  sizeUnit: OtcQuoteSizeUnit;
42
- /** Execution route. Omitted selects the service default (`awr`). */
66
+ /** The route. The service requires it and has no default. */
43
67
  pricerId?: string;
44
68
  }
45
69
  /** Subscribe or unsubscribe target: 1–100 streams, applied atomically. */
@@ -48,5 +72,5 @@ interface OtcRfqSubscriptionParams {
48
72
  streams: OtcQuoteStream[];
49
73
  }
50
74
  //#endregion
51
- export { OtcReadyResult as a, OtcQuoteStream as i, OtcGetExecutionStatusParams as n, OtcRfqSubscriptionParams as o, OtcGetReadyParams as r, OtcServerTakerOrderParams as s, OtcExecuteParams as t };
52
- //# sourceMappingURL=clientTypes-CMksWClt.d.ts.map
75
+ export { OtcQuoteStream as a, OtcServerTakerOrderParams as c, OtcGetReadyParams as i, OtcSiweMessageParams as l, OtcGetAuthNonceParams as n, OtcReadyResult as o, OtcGetExecutionStatusParams as r, OtcRfqSubscriptionParams as s, OtcExecuteParams as t, OtcVerifyAuthParams as u };
76
+ //# sourceMappingURL=clientTypes-DadMpdOk.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"clientTypes-DadMpdOk.d.ts","names":[],"sources":["../src/types/src/types/clientTypes.ts"],"mappings":";;;;;;AAOA;;KAAY,yBAAA,GAA4B,IAAI,CAC1C,4BAAA;AAAA,UAIe,gBAAA;EAJa;EAM5B,MAAA;EACA,KAAA,EAAO,yBAAyB;;EAEhC,QAAA;AAAA;AAAA,UAGe,2BAAA;EACf,MAAA;EACA,WAAW;AAAA;AAAA,UAGI,iBAAA;EACf,QAAQ;AAAA;AAAA,UAGO,qBAAA;EARf;EAUA,MAAM;AAAA;AAAA,UAGS,oBAAA;;EAEf,MAAA;EAVQ;EAYR,GAAA;EAToC;EAWpC,OAAA;EACA,OAAA;EACA,KAAA;EARe;EAUf,UAAA;;EAEA,MAAA;AAAA;AAAA,UAGe,mBAAA;EATf;EAWA,OAAA;EATA;EAWA,SAAS;AAAA;;AAPH;AAGR;;UAWiB,cAAA;EACf,UAAA;EACA,KAAK;AAAA;;;;AAAA;UAOU,cAAA;EACf,IAAA;EACA,SAAA;EACA,MAAA;EACA,IAAA;EACA,QAAA,EAAU,gBAAgB;EAF1B;EAIA,QAAA;AAAA;;UAIe,wBAAA;EACf,EAAA;EACA,OAAA,EAAS,cAAc;AAAA"}
@@ -1,4 +1,4 @@
1
- import { t as OtcQuoteSizeUnit } from "./serverTypes-CGY8MQaT.cjs";
1
+ import { t as OtcQuoteSizeUnit } from "./serverTypes-CgQcIVf1.cjs";
2
2
  import { EngineServerPlaceOrderParams } from "@nadohq/engine-client";
3
3
 
4
4
  //#region src/types/clientTypes.d.ts
@@ -11,7 +11,7 @@ interface OtcExecuteParams {
11
11
  /** Client-generated idempotency key, 1–128 bytes. Kept across retries of this intent. */
12
12
  dealId: string;
13
13
  taker: OtcServerTakerOrderParams;
14
- /** Execution route. Omitted selects the service default (`awr`). */
14
+ /** The route. The service requires it and has no default. */
15
15
  pricerId?: string;
16
16
  }
17
17
  interface OtcGetExecutionStatusParams {
@@ -21,6 +21,30 @@ interface OtcGetExecutionStatusParams {
21
21
  interface OtcGetReadyParams {
22
22
  pricerId?: string;
23
23
  }
24
+ interface OtcGetAuthNonceParams {
25
+ /** The 32-byte subaccount the login is bound to. */
26
+ sender: string;
27
+ }
28
+ interface OtcSiweMessageParams {
29
+ /** Host of the page origin, e.g. `testnet.nado.xyz`. */
30
+ domain: string;
31
+ /** The page origin, with no path or trailing slash. */
32
+ uri: string;
33
+ /** The signing address, EIP-55 checksummed: the owner or the sender's linked signer. */
34
+ address: string;
35
+ chainId: number;
36
+ nonce: string;
37
+ /** `issued_at_ms` from the nonce response; a local clock can be rejected as future. */
38
+ issuedAtMs: number;
39
+ /** The same sender as the nonce request. */
40
+ sender: string;
41
+ }
42
+ interface OtcVerifyAuthParams {
43
+ /** The SIWE text exactly as signed. */
44
+ message: string;
45
+ /** 65-byte hex `personal_sign` signature of `message`. */
46
+ signature: string;
47
+ }
24
48
  /**
25
49
  * Route coverage. HTTP 200 is ready; 400 and 503 are not. This does not guarantee liquidity
26
50
  * or that an order will be accepted.
@@ -39,7 +63,7 @@ interface OtcQuoteStream {
39
63
  wallet: string;
40
64
  size: string;
41
65
  sizeUnit: OtcQuoteSizeUnit;
42
- /** Execution route. Omitted selects the service default (`awr`). */
66
+ /** The route. The service requires it and has no default. */
43
67
  pricerId?: string;
44
68
  }
45
69
  /** Subscribe or unsubscribe target: 1–100 streams, applied atomically. */
@@ -48,5 +72,5 @@ interface OtcRfqSubscriptionParams {
48
72
  streams: OtcQuoteStream[];
49
73
  }
50
74
  //#endregion
51
- export { OtcReadyResult as a, OtcQuoteStream as i, OtcGetExecutionStatusParams as n, OtcRfqSubscriptionParams as o, OtcGetReadyParams as r, OtcServerTakerOrderParams as s, OtcExecuteParams as t };
52
- //# sourceMappingURL=clientTypes-CjBtkKtk.d.cts.map
75
+ export { OtcQuoteStream as a, OtcServerTakerOrderParams as c, OtcGetReadyParams as i, OtcSiweMessageParams as l, OtcGetAuthNonceParams as n, OtcReadyResult as o, OtcGetExecutionStatusParams as r, OtcRfqSubscriptionParams as s, OtcExecuteParams as t, OtcVerifyAuthParams as u };
76
+ //# sourceMappingURL=clientTypes-_bJZ6Psb.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"clientTypes-_bJZ6Psb.d.cts","names":[],"sources":["../src/types/src/types/clientTypes.ts"],"mappings":";;;;;;AAOA;;KAAY,yBAAA,GAA4B,IAAI,CAC1C,4BAAA;AAAA,UAIe,gBAAA;EAJa;EAM5B,MAAA;EACA,KAAA,EAAO,yBAAyB;;EAEhC,QAAA;AAAA;AAAA,UAGe,2BAAA;EACf,MAAA;EACA,WAAW;AAAA;AAAA,UAGI,iBAAA;EACf,QAAQ;AAAA;AAAA,UAGO,qBAAA;EARf;EAUA,MAAM;AAAA;AAAA,UAGS,oBAAA;;EAEf,MAAA;EAVQ;EAYR,GAAA;EAToC;EAWpC,OAAA;EACA,OAAA;EACA,KAAA;EARe;EAUf,UAAA;;EAEA,MAAA;AAAA;AAAA,UAGe,mBAAA;EATf;EAWA,OAAA;EATA;EAWA,SAAS;AAAA;;AAPH;AAGR;;UAWiB,cAAA;EACf,UAAA;EACA,KAAK;AAAA;;;;AAAA;UAOU,cAAA;EACf,IAAA;EACA,SAAA;EACA,MAAA;EACA,IAAA;EACA,QAAA,EAAU,gBAAgB;EAF1B;EAIA,QAAA;AAAA;;UAIe,wBAAA;EACf,EAAA;EACA,OAAA,EAAS,cAAc;AAAA"}
package/dist/index.cjs CHANGED
@@ -1,11 +1,14 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_OtcClient = require("./OtcClient-qUPYb1BP.cjs");
2
+ const require_OtcClient = require("./OtcClient-BYspxGIn.cjs");
3
3
  const require_endpoints = require("./endpoints.cjs");
4
4
  const require_rfqSubscription = require("./rfqSubscription.cjs");
5
+ const require_siweMessage = require("./siweMessage.cjs");
5
6
  const require_types_otcErrorCodes = require("./types/otcErrorCodes.cjs");
6
7
  require("./types/index.cjs");
7
8
  exports.OTC_CLIENT_ENDPOINTS = require_endpoints.OTC_CLIENT_ENDPOINTS;
8
9
  exports.OTC_ERROR_CODES = require_types_otcErrorCodes.OTC_ERROR_CODES;
9
10
  exports.OTC_RFQ_WS_CLIENT_ENDPOINTS = require_endpoints.OTC_RFQ_WS_CLIENT_ENDPOINTS;
11
+ exports.OTC_SIWE_STATEMENT = require_siweMessage.OTC_SIWE_STATEMENT;
10
12
  exports.OtcClient = require_OtcClient.OtcClient;
11
13
  exports.buildOtcRfqSubscriptionMessage = require_rfqSubscription.buildOtcRfqSubscriptionMessage;
14
+ exports.buildOtcSiweMessage = require_siweMessage.buildOtcSiweMessage;
package/dist/index.d.cts CHANGED
@@ -1,7 +1,8 @@
1
- import { a as OtcServerExecutionSuccess, c as OtcServerQuoteStream, d as OtcServerRfqSubscribeStreamsRequest, f as OtcServerRfqSubscriptionRequest, i as OtcServerExecutionResponse, l as OtcServerRfqAck, n as OtcServerExecutionFailure, o as OtcServerQuote, p as OtcServerRfqUnsubscribeStreamsRequest, r as OtcServerExecutionPendingResolution, s as OtcServerQuoteBatch, t as OtcQuoteSizeUnit, u as OtcServerRfqMessage } from "./serverTypes-CGY8MQaT.cjs";
2
- import { a as OtcReadyResult, i as OtcQuoteStream, n as OtcGetExecutionStatusParams, o as OtcRfqSubscriptionParams, r as OtcGetReadyParams, s as OtcServerTakerOrderParams, t as OtcExecuteParams } from "./clientTypes-CjBtkKtk.cjs";
1
+ import { a as OtcServerExecutionPendingResolution, c as OtcServerQuote, d as OtcServerRfqAck, f as OtcServerRfqMessage, h as OtcServerRfqUnsubscribeStreamsRequest, i as OtcServerExecutionFailure, l as OtcServerQuoteBatch, m as OtcServerRfqSubscriptionRequest, n as OtcServerAuthNonce, o as OtcServerExecutionResponse, p as OtcServerRfqSubscribeStreamsRequest, r as OtcServerAuthSession, s as OtcServerExecutionSuccess, t as OtcQuoteSizeUnit, u as OtcServerQuoteStream } from "./serverTypes-CgQcIVf1.cjs";
2
+ import { a as OtcQuoteStream, c as OtcServerTakerOrderParams, i as OtcGetReadyParams, l as OtcSiweMessageParams, n as OtcGetAuthNonceParams, o as OtcReadyResult, r as OtcGetExecutionStatusParams, s as OtcRfqSubscriptionParams, t as OtcExecuteParams, u as OtcVerifyAuthParams } from "./clientTypes-_bJZ6Psb.cjs";
3
3
  import { OtcClient, OtcClientOpts } from "./OtcClient.cjs";
4
4
  import { OTC_CLIENT_ENDPOINTS, OTC_RFQ_WS_CLIENT_ENDPOINTS } from "./endpoints.cjs";
5
5
  import { buildOtcRfqSubscriptionMessage } from "./rfqSubscription.cjs";
6
+ import { OTC_SIWE_STATEMENT, buildOtcSiweMessage } from "./siweMessage.cjs";
6
7
  import { n as OtcErrorCode, t as OTC_ERROR_CODES } from "./otcErrorCodes-CsmoGjD_.cjs";
7
- export { OTC_CLIENT_ENDPOINTS, OTC_ERROR_CODES, OTC_RFQ_WS_CLIENT_ENDPOINTS, OtcClient, OtcClientOpts, OtcErrorCode, OtcExecuteParams, OtcGetExecutionStatusParams, OtcGetReadyParams, OtcQuoteSizeUnit, OtcQuoteStream, OtcReadyResult, OtcRfqSubscriptionParams, OtcServerExecutionFailure, OtcServerExecutionPendingResolution, OtcServerExecutionResponse, OtcServerExecutionSuccess, OtcServerQuote, OtcServerQuoteBatch, OtcServerQuoteStream, OtcServerRfqAck, OtcServerRfqMessage, OtcServerRfqSubscribeStreamsRequest, OtcServerRfqSubscriptionRequest, OtcServerRfqUnsubscribeStreamsRequest, OtcServerTakerOrderParams, buildOtcRfqSubscriptionMessage };
8
+ export { OTC_CLIENT_ENDPOINTS, OTC_ERROR_CODES, OTC_RFQ_WS_CLIENT_ENDPOINTS, OTC_SIWE_STATEMENT, OtcClient, OtcClientOpts, OtcErrorCode, OtcExecuteParams, OtcGetAuthNonceParams, OtcGetExecutionStatusParams, OtcGetReadyParams, OtcQuoteSizeUnit, OtcQuoteStream, OtcReadyResult, OtcRfqSubscriptionParams, OtcServerAuthNonce, OtcServerAuthSession, OtcServerExecutionFailure, OtcServerExecutionPendingResolution, OtcServerExecutionResponse, OtcServerExecutionSuccess, OtcServerQuote, OtcServerQuoteBatch, OtcServerQuoteStream, OtcServerRfqAck, OtcServerRfqMessage, OtcServerRfqSubscribeStreamsRequest, OtcServerRfqSubscriptionRequest, OtcServerRfqUnsubscribeStreamsRequest, OtcServerTakerOrderParams, OtcSiweMessageParams, OtcVerifyAuthParams, buildOtcRfqSubscriptionMessage, buildOtcSiweMessage };
package/dist/index.d.ts CHANGED
@@ -1,7 +1,8 @@
1
- import { a as OtcServerExecutionSuccess, c as OtcServerQuoteStream, d as OtcServerRfqSubscribeStreamsRequest, f as OtcServerRfqSubscriptionRequest, i as OtcServerExecutionResponse, l as OtcServerRfqAck, n as OtcServerExecutionFailure, o as OtcServerQuote, p as OtcServerRfqUnsubscribeStreamsRequest, r as OtcServerExecutionPendingResolution, s as OtcServerQuoteBatch, t as OtcQuoteSizeUnit, u as OtcServerRfqMessage } from "./serverTypes-CGY8MQaT.js";
2
- import { a as OtcReadyResult, i as OtcQuoteStream, n as OtcGetExecutionStatusParams, o as OtcRfqSubscriptionParams, r as OtcGetReadyParams, s as OtcServerTakerOrderParams, t as OtcExecuteParams } from "./clientTypes-CMksWClt.js";
1
+ import { a as OtcServerExecutionPendingResolution, c as OtcServerQuote, d as OtcServerRfqAck, f as OtcServerRfqMessage, h as OtcServerRfqUnsubscribeStreamsRequest, i as OtcServerExecutionFailure, l as OtcServerQuoteBatch, m as OtcServerRfqSubscriptionRequest, n as OtcServerAuthNonce, o as OtcServerExecutionResponse, p as OtcServerRfqSubscribeStreamsRequest, r as OtcServerAuthSession, s as OtcServerExecutionSuccess, t as OtcQuoteSizeUnit, u as OtcServerQuoteStream } from "./serverTypes-CgQcIVf1.js";
2
+ import { a as OtcQuoteStream, c as OtcServerTakerOrderParams, i as OtcGetReadyParams, l as OtcSiweMessageParams, n as OtcGetAuthNonceParams, o as OtcReadyResult, r as OtcGetExecutionStatusParams, s as OtcRfqSubscriptionParams, t as OtcExecuteParams, u as OtcVerifyAuthParams } from "./clientTypes-DadMpdOk.js";
3
3
  import { OtcClient, OtcClientOpts } from "./OtcClient.js";
4
4
  import { OTC_CLIENT_ENDPOINTS, OTC_RFQ_WS_CLIENT_ENDPOINTS } from "./endpoints.js";
5
5
  import { buildOtcRfqSubscriptionMessage } from "./rfqSubscription.js";
6
+ import { OTC_SIWE_STATEMENT, buildOtcSiweMessage } from "./siweMessage.js";
6
7
  import { n as OtcErrorCode, t as OTC_ERROR_CODES } from "./otcErrorCodes-CsmoGjD_.js";
7
- export { OTC_CLIENT_ENDPOINTS, OTC_ERROR_CODES, OTC_RFQ_WS_CLIENT_ENDPOINTS, OtcClient, OtcClientOpts, OtcErrorCode, OtcExecuteParams, OtcGetExecutionStatusParams, OtcGetReadyParams, OtcQuoteSizeUnit, OtcQuoteStream, OtcReadyResult, OtcRfqSubscriptionParams, OtcServerExecutionFailure, OtcServerExecutionPendingResolution, OtcServerExecutionResponse, OtcServerExecutionSuccess, OtcServerQuote, OtcServerQuoteBatch, OtcServerQuoteStream, OtcServerRfqAck, OtcServerRfqMessage, OtcServerRfqSubscribeStreamsRequest, OtcServerRfqSubscriptionRequest, OtcServerRfqUnsubscribeStreamsRequest, OtcServerTakerOrderParams, buildOtcRfqSubscriptionMessage };
8
+ export { OTC_CLIENT_ENDPOINTS, OTC_ERROR_CODES, OTC_RFQ_WS_CLIENT_ENDPOINTS, OTC_SIWE_STATEMENT, OtcClient, OtcClientOpts, OtcErrorCode, OtcExecuteParams, OtcGetAuthNonceParams, OtcGetExecutionStatusParams, OtcGetReadyParams, OtcQuoteSizeUnit, OtcQuoteStream, OtcReadyResult, OtcRfqSubscriptionParams, OtcServerAuthNonce, OtcServerAuthSession, OtcServerExecutionFailure, OtcServerExecutionPendingResolution, OtcServerExecutionResponse, OtcServerExecutionSuccess, OtcServerQuote, OtcServerQuoteBatch, OtcServerQuoteStream, OtcServerRfqAck, OtcServerRfqMessage, OtcServerRfqSubscribeStreamsRequest, OtcServerRfqSubscriptionRequest, OtcServerRfqUnsubscribeStreamsRequest, OtcServerTakerOrderParams, OtcSiweMessageParams, OtcVerifyAuthParams, buildOtcRfqSubscriptionMessage, buildOtcSiweMessage };
package/dist/index.js CHANGED
@@ -1,6 +1,7 @@
1
1
  import { OtcClient } from "./OtcClient.js";
2
2
  import { OTC_CLIENT_ENDPOINTS, OTC_RFQ_WS_CLIENT_ENDPOINTS } from "./endpoints.js";
3
3
  import { buildOtcRfqSubscriptionMessage } from "./rfqSubscription.js";
4
+ import { OTC_SIWE_STATEMENT, buildOtcSiweMessage } from "./siweMessage.js";
4
5
  import { OTC_ERROR_CODES } from "./types/otcErrorCodes.js";
5
6
  import "./types/index.js";
6
- export { OTC_CLIENT_ENDPOINTS, OTC_ERROR_CODES, OTC_RFQ_WS_CLIENT_ENDPOINTS, OtcClient, buildOtcRfqSubscriptionMessage };
7
+ export { OTC_CLIENT_ENDPOINTS, OTC_ERROR_CODES, OTC_RFQ_WS_CLIENT_ENDPOINTS, OTC_SIWE_STATEMENT, OtcClient, buildOtcRfqSubscriptionMessage, buildOtcSiweMessage };
@@ -1,5 +1,5 @@
1
- import { f as OtcServerRfqSubscriptionRequest } from "./serverTypes-CGY8MQaT.cjs";
2
- import { o as OtcRfqSubscriptionParams } from "./clientTypes-CjBtkKtk.cjs";
1
+ import { m as OtcServerRfqSubscriptionRequest } from "./serverTypes-CgQcIVf1.cjs";
2
+ import { s as OtcRfqSubscriptionParams } from "./clientTypes-_bJZ6Psb.cjs";
3
3
 
4
4
  //#region src/rfqSubscription.d.ts
5
5
  /**
@@ -1,5 +1,5 @@
1
- import { f as OtcServerRfqSubscriptionRequest } from "./serverTypes-CGY8MQaT.js";
2
- import { o as OtcRfqSubscriptionParams } from "./clientTypes-CMksWClt.js";
1
+ import { m as OtcServerRfqSubscriptionRequest } from "./serverTypes-CgQcIVf1.js";
2
+ import { s as OtcRfqSubscriptionParams } from "./clientTypes-DadMpdOk.js";
3
3
 
4
4
  //#region src/rfqSubscription.d.ts
5
5
  /**
@@ -1,5 +1,19 @@
1
1
  //#region src/types/serverTypes.d.ts
2
2
  type OtcQuoteSizeUnit = 'base' | 'quote';
3
+ interface OtcServerAuthNonce {
4
+ nonce: string;
5
+ issued_at_ms: number;
6
+ /** The nonce lasts 60s from issuance. */
7
+ expires_at_ms: number;
8
+ session_expires_at_ms: number | null;
9
+ }
10
+ /** The verified login identity. The session itself lives in an HttpOnly cookie. */
11
+ interface OtcServerAuthSession {
12
+ owner: string;
13
+ sender: string;
14
+ signer: string;
15
+ expires_at_ms: number;
16
+ }
3
17
  interface OtcServerExecutionDiagnostics {
4
18
  failure_source?: string;
5
19
  failure_stage?: string;
@@ -79,5 +93,5 @@ interface OtcServerRfqAck {
79
93
  }
80
94
  type OtcServerRfqMessage = OtcServerRfqAck | OtcServerQuoteBatch;
81
95
  //#endregion
82
- export { OtcServerExecutionSuccess as a, OtcServerQuoteStream as c, OtcServerRfqSubscribeStreamsRequest as d, OtcServerRfqSubscriptionRequest as f, OtcServerExecutionResponse as i, OtcServerRfqAck as l, OtcServerExecutionFailure as n, OtcServerQuote as o, OtcServerRfqUnsubscribeStreamsRequest as p, OtcServerExecutionPendingResolution as r, OtcServerQuoteBatch as s, OtcQuoteSizeUnit as t, OtcServerRfqMessage as u };
83
- //# sourceMappingURL=serverTypes-CGY8MQaT.d.cts.map
96
+ export { OtcServerExecutionPendingResolution as a, OtcServerQuote as c, OtcServerRfqAck as d, OtcServerRfqMessage as f, OtcServerRfqUnsubscribeStreamsRequest as h, OtcServerExecutionFailure as i, OtcServerQuoteBatch as l, OtcServerRfqSubscriptionRequest as m, OtcServerAuthNonce as n, OtcServerExecutionResponse as o, OtcServerRfqSubscribeStreamsRequest as p, OtcServerAuthSession as r, OtcServerExecutionSuccess as s, OtcQuoteSizeUnit as t, OtcServerQuoteStream as u };
97
+ //# sourceMappingURL=serverTypes-CgQcIVf1.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"serverTypes-CgQcIVf1.d.cts","names":[],"sources":["../src/types/src/types/serverTypes.ts"],"mappings":";KAAY,gBAAA;AAAA,UAEK,kBAAA;EACf,KAAA;EACA,YAAA;EAJ0B;EAM1B,aAAA;EACA,qBAAA;AAAA;;UAIe,oBAAA;EACf,KAAA;EACA,MAAA;EACA,MAAA;EACA,aAAA;AAAA;AAAA,UAGQ,6BAAA;EACR,cAAA;EACA,aAAA;EACA,mBAAA;EACA,SAAA;EAVA;;;;EAeA,eAAA;EACA,cAAA;AAAA;AAAA,UAGe,yBAAA;EACf,MAAA;EACA,OAAA;EACA,YAAA;EACA,aAAA;AAAA;AAAA,UAGe,yBAAA,SAAkC,6BAA6B;EAC9E,MAAA;EACA,KAAA;EACA,UAAA;EACA,OAAA;EACA,YAAA;AAAA;AAAA,UAGe,mCAAA,SAA4C,6BAA6B;EACxF,MAAA;EACA,OAAA;EACA,YAAA;EACA,KAAA;EACA,UAAA;AAAA;AAhBa;AAAA,KAoBH,0BAAA,GACR,yBAAA,GACA,yBAAA,GACA,mCAAA;AAAA,UAEa,oBAAA;EACf,IAAA;EACA,UAAA;EACA,MAAA;EACA,IAAA;EACA,SAAA,EAAW,gBAAgB;EAC3B,SAAA;AAAA;AAAA,UAGe,mCAAA;EACf,MAAA;EACA,EAAA;EACA,OAAA,EAAS,oBAAoB;AAAA;AAAA,UAGd,qCAAA;EACf,MAAA;EACA,EAAA;EACA,OAAA,EAAS,oBAAoB;AAAA;AAAA,KAGnB,+BAAA,GACR,mCAAA,GACA,qCAAqC;;UAGxB,cAAA;EACf,UAAA;EACA,IAAA;EACA,SAAA,EAAW,gBAAgB;EAC3B,IAAA;EACA,MAAA;EACA,SAAA;EACA,MAAA;EACA,SAAA;EACA,cAAA;EACA,SAAA;AAAA;AAAA,UAGe,mBAAA;EACf,IAAA;EACA,IAAA;EACA,MAAA,EAAQ,cAAc;AAAA;AAAA,UAGP,eAAA;EACf,MAAA;EACA,EAAA;EA9CA;EAgDA,KAAA;AAAA;AAAA,KAGU,mBAAA,GAAsB,eAAA,GAAkB,mBAAmB"}
@@ -1,5 +1,19 @@
1
1
  //#region src/types/serverTypes.d.ts
2
2
  type OtcQuoteSizeUnit = 'base' | 'quote';
3
+ interface OtcServerAuthNonce {
4
+ nonce: string;
5
+ issued_at_ms: number;
6
+ /** The nonce lasts 60s from issuance. */
7
+ expires_at_ms: number;
8
+ session_expires_at_ms: number | null;
9
+ }
10
+ /** The verified login identity. The session itself lives in an HttpOnly cookie. */
11
+ interface OtcServerAuthSession {
12
+ owner: string;
13
+ sender: string;
14
+ signer: string;
15
+ expires_at_ms: number;
16
+ }
3
17
  interface OtcServerExecutionDiagnostics {
4
18
  failure_source?: string;
5
19
  failure_stage?: string;
@@ -79,5 +93,5 @@ interface OtcServerRfqAck {
79
93
  }
80
94
  type OtcServerRfqMessage = OtcServerRfqAck | OtcServerQuoteBatch;
81
95
  //#endregion
82
- export { OtcServerExecutionSuccess as a, OtcServerQuoteStream as c, OtcServerRfqSubscribeStreamsRequest as d, OtcServerRfqSubscriptionRequest as f, OtcServerExecutionResponse as i, OtcServerRfqAck as l, OtcServerExecutionFailure as n, OtcServerQuote as o, OtcServerRfqUnsubscribeStreamsRequest as p, OtcServerExecutionPendingResolution as r, OtcServerQuoteBatch as s, OtcQuoteSizeUnit as t, OtcServerRfqMessage as u };
83
- //# sourceMappingURL=serverTypes-CGY8MQaT.d.ts.map
96
+ export { OtcServerExecutionPendingResolution as a, OtcServerQuote as c, OtcServerRfqAck as d, OtcServerRfqMessage as f, OtcServerRfqUnsubscribeStreamsRequest as h, OtcServerExecutionFailure as i, OtcServerQuoteBatch as l, OtcServerRfqSubscriptionRequest as m, OtcServerAuthNonce as n, OtcServerExecutionResponse as o, OtcServerRfqSubscribeStreamsRequest as p, OtcServerAuthSession as r, OtcServerExecutionSuccess as s, OtcQuoteSizeUnit as t, OtcServerQuoteStream as u };
97
+ //# sourceMappingURL=serverTypes-CgQcIVf1.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"serverTypes-CgQcIVf1.d.ts","names":[],"sources":["../src/types/src/types/serverTypes.ts"],"mappings":";KAAY,gBAAA;AAAA,UAEK,kBAAA;EACf,KAAA;EACA,YAAA;EAJ0B;EAM1B,aAAA;EACA,qBAAA;AAAA;;UAIe,oBAAA;EACf,KAAA;EACA,MAAA;EACA,MAAA;EACA,aAAA;AAAA;AAAA,UAGQ,6BAAA;EACR,cAAA;EACA,aAAA;EACA,mBAAA;EACA,SAAA;EAVA;;;;EAeA,eAAA;EACA,cAAA;AAAA;AAAA,UAGe,yBAAA;EACf,MAAA;EACA,OAAA;EACA,YAAA;EACA,aAAA;AAAA;AAAA,UAGe,yBAAA,SAAkC,6BAA6B;EAC9E,MAAA;EACA,KAAA;EACA,UAAA;EACA,OAAA;EACA,YAAA;AAAA;AAAA,UAGe,mCAAA,SAA4C,6BAA6B;EACxF,MAAA;EACA,OAAA;EACA,YAAA;EACA,KAAA;EACA,UAAA;AAAA;AAhBa;AAAA,KAoBH,0BAAA,GACR,yBAAA,GACA,yBAAA,GACA,mCAAA;AAAA,UAEa,oBAAA;EACf,IAAA;EACA,UAAA;EACA,MAAA;EACA,IAAA;EACA,SAAA,EAAW,gBAAgB;EAC3B,SAAA;AAAA;AAAA,UAGe,mCAAA;EACf,MAAA;EACA,EAAA;EACA,OAAA,EAAS,oBAAoB;AAAA;AAAA,UAGd,qCAAA;EACf,MAAA;EACA,EAAA;EACA,OAAA,EAAS,oBAAoB;AAAA;AAAA,KAGnB,+BAAA,GACR,mCAAA,GACA,qCAAqC;;UAGxB,cAAA;EACf,UAAA;EACA,IAAA;EACA,SAAA,EAAW,gBAAgB;EAC3B,IAAA;EACA,MAAA;EACA,SAAA;EACA,MAAA;EACA,SAAA;EACA,cAAA;EACA,SAAA;AAAA;AAAA,UAGe,mBAAA;EACf,IAAA;EACA,IAAA;EACA,MAAA,EAAQ,cAAc;AAAA;AAAA,UAGP,eAAA;EACf,MAAA;EACA,EAAA;EA9CA;EAgDA,KAAA;AAAA;AAAA,KAGU,mBAAA,GAAsB,eAAA,GAAkB,mBAAmB"}
@@ -0,0 +1,31 @@
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ //#region src/siweMessage.ts
3
+ /**
4
+ * Statement shown to the user when the owner wallet signs. The service does not check it.
5
+ */
6
+ const OTC_SIWE_STATEMENT = "Sign in to read Nado OTC quotes. This signature cannot place or authorize trades.";
7
+ /**
8
+ * Builds the exact ERC-4361 text the OTC service verifies for private quote login. Sign it
9
+ * with `personal_sign` and send it unchanged to `verifyAuth`.
10
+ */
11
+ function buildOtcSiweMessage({ domain, uri, address, chainId, nonce, issuedAtMs, sender }) {
12
+ return [
13
+ `${domain} wants you to sign in with your Ethereum account:`,
14
+ address,
15
+ "",
16
+ OTC_SIWE_STATEMENT,
17
+ "",
18
+ `URI: ${uri}`,
19
+ "Version: 1",
20
+ `Chain ID: ${chainId}`,
21
+ `Nonce: ${nonce}`,
22
+ `Issued At: ${new Date(issuedAtMs).toISOString()}`,
23
+ "Resources:",
24
+ `- urn:nado:subaccount:${sender}`
25
+ ].join("\n");
26
+ }
27
+ //#endregion
28
+ exports.OTC_SIWE_STATEMENT = OTC_SIWE_STATEMENT;
29
+ exports.buildOtcSiweMessage = buildOtcSiweMessage;
30
+
31
+ //# sourceMappingURL=siweMessage.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"siweMessage.cjs","names":[],"sources":["../src/siweMessage.ts"],"sourcesContent":["import { OtcSiweMessageParams } from './types/clientTypes';\n\n/**\n * Statement shown to the user when the owner wallet signs. The service does not check it.\n */\nexport const OTC_SIWE_STATEMENT =\n 'Sign in to read Nado OTC quotes. This signature cannot place or authorize trades.';\n\n/**\n * Builds the exact ERC-4361 text the OTC service verifies for private quote login. Sign it\n * with `personal_sign` and send it unchanged to `verifyAuth`.\n */\nexport function buildOtcSiweMessage({\n domain,\n uri,\n address,\n chainId,\n nonce,\n issuedAtMs,\n sender,\n}: OtcSiweMessageParams): string {\n return [\n `${domain} wants you to sign in with your Ethereum account:`,\n address,\n '',\n OTC_SIWE_STATEMENT,\n '',\n `URI: ${uri}`,\n 'Version: 1',\n `Chain ID: ${chainId}`,\n `Nonce: ${nonce}`,\n `Issued At: ${new Date(issuedAtMs).toISOString()}`,\n 'Resources:',\n `- urn:nado:subaccount:${sender}`,\n ].join('\\n');\n}\n"],"mappings":";;;;;AAKA,MAAa,qBACX;;;;;AAMF,SAAgB,oBAAoB,EAClC,QACA,KACA,SACA,SACA,OACA,YACA,UAC+B;CAC/B,OAAO;EACL,GAAG,OAAO;EACV;EACA;EACA;EACA;EACA,QAAQ;EACR;EACA,aAAa;EACb,UAAU;EACV,cAAc,IAAI,KAAK,UAAU,EAAE,YAAY;EAC/C;EACA,yBAAyB;CAC3B,EAAE,KAAK,IAAI;AACb"}
@@ -0,0 +1,23 @@
1
+ import { l as OtcSiweMessageParams } from "./clientTypes-_bJZ6Psb.cjs";
2
+
3
+ //#region src/siweMessage.d.ts
4
+ /**
5
+ * Statement shown to the user when the owner wallet signs. The service does not check it.
6
+ */
7
+ declare const OTC_SIWE_STATEMENT = "Sign in to read Nado OTC quotes. This signature cannot place or authorize trades.";
8
+ /**
9
+ * Builds the exact ERC-4361 text the OTC service verifies for private quote login. Sign it
10
+ * with `personal_sign` and send it unchanged to `verifyAuth`.
11
+ */
12
+ declare function buildOtcSiweMessage({
13
+ domain,
14
+ uri,
15
+ address,
16
+ chainId,
17
+ nonce,
18
+ issuedAtMs,
19
+ sender
20
+ }: OtcSiweMessageParams): string;
21
+ //#endregion
22
+ export { OTC_SIWE_STATEMENT, buildOtcSiweMessage };
23
+ //# sourceMappingURL=siweMessage.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"siweMessage.d.cts","names":[],"sources":["../src/src/siweMessage.ts"],"mappings":";;;;;AAKA;cAAa,kBAAA;;;AAAkB;AAO/B;iBAAgB,mBAAA,CAAA;EACd,MAAA;EACA,GAAA;EACA,OAAA;EACA,OAAA;EACA,KAAA;EACA,UAAA;EACA;AAAA,GACC,oBAAA"}
@@ -0,0 +1,23 @@
1
+ import { l as OtcSiweMessageParams } from "./clientTypes-DadMpdOk.js";
2
+
3
+ //#region src/siweMessage.d.ts
4
+ /**
5
+ * Statement shown to the user when the owner wallet signs. The service does not check it.
6
+ */
7
+ declare const OTC_SIWE_STATEMENT = "Sign in to read Nado OTC quotes. This signature cannot place or authorize trades.";
8
+ /**
9
+ * Builds the exact ERC-4361 text the OTC service verifies for private quote login. Sign it
10
+ * with `personal_sign` and send it unchanged to `verifyAuth`.
11
+ */
12
+ declare function buildOtcSiweMessage({
13
+ domain,
14
+ uri,
15
+ address,
16
+ chainId,
17
+ nonce,
18
+ issuedAtMs,
19
+ sender
20
+ }: OtcSiweMessageParams): string;
21
+ //#endregion
22
+ export { OTC_SIWE_STATEMENT, buildOtcSiweMessage };
23
+ //# sourceMappingURL=siweMessage.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"siweMessage.d.ts","names":[],"sources":["../src/src/siweMessage.ts"],"mappings":";;;;;AAKA;cAAa,kBAAA;;;AAAkB;AAO/B;iBAAgB,mBAAA,CAAA;EACd,MAAA;EACA,GAAA;EACA,OAAA;EACA,OAAA;EACA,KAAA;EACA,UAAA;EACA;AAAA,GACC,oBAAA"}
@@ -0,0 +1,29 @@
1
+ //#region src/siweMessage.ts
2
+ /**
3
+ * Statement shown to the user when the owner wallet signs. The service does not check it.
4
+ */
5
+ const OTC_SIWE_STATEMENT = "Sign in to read Nado OTC quotes. This signature cannot place or authorize trades.";
6
+ /**
7
+ * Builds the exact ERC-4361 text the OTC service verifies for private quote login. Sign it
8
+ * with `personal_sign` and send it unchanged to `verifyAuth`.
9
+ */
10
+ function buildOtcSiweMessage({ domain, uri, address, chainId, nonce, issuedAtMs, sender }) {
11
+ return [
12
+ `${domain} wants you to sign in with your Ethereum account:`,
13
+ address,
14
+ "",
15
+ OTC_SIWE_STATEMENT,
16
+ "",
17
+ `URI: ${uri}`,
18
+ "Version: 1",
19
+ `Chain ID: ${chainId}`,
20
+ `Nonce: ${nonce}`,
21
+ `Issued At: ${new Date(issuedAtMs).toISOString()}`,
22
+ "Resources:",
23
+ `- urn:nado:subaccount:${sender}`
24
+ ].join("\n");
25
+ }
26
+ //#endregion
27
+ export { OTC_SIWE_STATEMENT, buildOtcSiweMessage };
28
+
29
+ //# sourceMappingURL=siweMessage.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"siweMessage.js","names":[],"sources":["../src/siweMessage.ts"],"sourcesContent":["import { OtcSiweMessageParams } from './types/clientTypes';\n\n/**\n * Statement shown to the user when the owner wallet signs. The service does not check it.\n */\nexport const OTC_SIWE_STATEMENT =\n 'Sign in to read Nado OTC quotes. This signature cannot place or authorize trades.';\n\n/**\n * Builds the exact ERC-4361 text the OTC service verifies for private quote login. Sign it\n * with `personal_sign` and send it unchanged to `verifyAuth`.\n */\nexport function buildOtcSiweMessage({\n domain,\n uri,\n address,\n chainId,\n nonce,\n issuedAtMs,\n sender,\n}: OtcSiweMessageParams): string {\n return [\n `${domain} wants you to sign in with your Ethereum account:`,\n address,\n '',\n OTC_SIWE_STATEMENT,\n '',\n `URI: ${uri}`,\n 'Version: 1',\n `Chain ID: ${chainId}`,\n `Nonce: ${nonce}`,\n `Issued At: ${new Date(issuedAtMs).toISOString()}`,\n 'Resources:',\n `- urn:nado:subaccount:${sender}`,\n ].join('\\n');\n}\n"],"mappings":";;;;AAKA,MAAa,qBACX;;;;;AAMF,SAAgB,oBAAoB,EAClC,QACA,KACA,SACA,SACA,OACA,YACA,UAC+B;CAC/B,OAAO;EACL,GAAG,OAAO;EACV;EACA;EACA;EACA;EACA,QAAQ;EACR;EACA,aAAa;EACb,UAAU;EACV,cAAc,IAAI,KAAK,UAAU,EAAE,YAAY;EAC/C;EACA,yBAAyB;CAC3B,EAAE,KAAK,IAAI;AACb"}
@@ -1,2 +1,2 @@
1
- import { a as OtcReadyResult, i as OtcQuoteStream, n as OtcGetExecutionStatusParams, o as OtcRfqSubscriptionParams, r as OtcGetReadyParams, s as OtcServerTakerOrderParams, t as OtcExecuteParams } from "../clientTypes-CjBtkKtk.cjs";
2
- export { OtcExecuteParams, OtcGetExecutionStatusParams, OtcGetReadyParams, OtcQuoteStream, OtcReadyResult, OtcRfqSubscriptionParams, OtcServerTakerOrderParams };
1
+ import { a as OtcQuoteStream, c as OtcServerTakerOrderParams, i as OtcGetReadyParams, l as OtcSiweMessageParams, n as OtcGetAuthNonceParams, o as OtcReadyResult, r as OtcGetExecutionStatusParams, s as OtcRfqSubscriptionParams, t as OtcExecuteParams, u as OtcVerifyAuthParams } from "../clientTypes-_bJZ6Psb.cjs";
2
+ export { OtcExecuteParams, OtcGetAuthNonceParams, OtcGetExecutionStatusParams, OtcGetReadyParams, OtcQuoteStream, OtcReadyResult, OtcRfqSubscriptionParams, OtcServerTakerOrderParams, OtcSiweMessageParams, OtcVerifyAuthParams };
@@ -1,2 +1,2 @@
1
- import { a as OtcReadyResult, i as OtcQuoteStream, n as OtcGetExecutionStatusParams, o as OtcRfqSubscriptionParams, r as OtcGetReadyParams, s as OtcServerTakerOrderParams, t as OtcExecuteParams } from "../clientTypes-CMksWClt.js";
2
- export { OtcExecuteParams, OtcGetExecutionStatusParams, OtcGetReadyParams, OtcQuoteStream, OtcReadyResult, OtcRfqSubscriptionParams, OtcServerTakerOrderParams };
1
+ import { a as OtcQuoteStream, c as OtcServerTakerOrderParams, i as OtcGetReadyParams, l as OtcSiweMessageParams, n as OtcGetAuthNonceParams, o as OtcReadyResult, r as OtcGetExecutionStatusParams, s as OtcRfqSubscriptionParams, t as OtcExecuteParams, u as OtcVerifyAuthParams } from "../clientTypes-DadMpdOk.js";
2
+ export { OtcExecuteParams, OtcGetAuthNonceParams, OtcGetExecutionStatusParams, OtcGetReadyParams, OtcQuoteStream, OtcReadyResult, OtcRfqSubscriptionParams, OtcServerTakerOrderParams, OtcSiweMessageParams, OtcVerifyAuthParams };
@@ -1,4 +1,4 @@
1
- import { a as OtcServerExecutionSuccess, c as OtcServerQuoteStream, d as OtcServerRfqSubscribeStreamsRequest, f as OtcServerRfqSubscriptionRequest, i as OtcServerExecutionResponse, l as OtcServerRfqAck, n as OtcServerExecutionFailure, o as OtcServerQuote, p as OtcServerRfqUnsubscribeStreamsRequest, r as OtcServerExecutionPendingResolution, s as OtcServerQuoteBatch, t as OtcQuoteSizeUnit, u as OtcServerRfqMessage } from "../serverTypes-CGY8MQaT.cjs";
2
- import { a as OtcReadyResult, i as OtcQuoteStream, n as OtcGetExecutionStatusParams, o as OtcRfqSubscriptionParams, r as OtcGetReadyParams, s as OtcServerTakerOrderParams, t as OtcExecuteParams } from "../clientTypes-CjBtkKtk.cjs";
1
+ import { a as OtcServerExecutionPendingResolution, c as OtcServerQuote, d as OtcServerRfqAck, f as OtcServerRfqMessage, h as OtcServerRfqUnsubscribeStreamsRequest, i as OtcServerExecutionFailure, l as OtcServerQuoteBatch, m as OtcServerRfqSubscriptionRequest, n as OtcServerAuthNonce, o as OtcServerExecutionResponse, p as OtcServerRfqSubscribeStreamsRequest, r as OtcServerAuthSession, s as OtcServerExecutionSuccess, t as OtcQuoteSizeUnit, u as OtcServerQuoteStream } from "../serverTypes-CgQcIVf1.cjs";
2
+ import { a as OtcQuoteStream, c as OtcServerTakerOrderParams, i as OtcGetReadyParams, l as OtcSiweMessageParams, n as OtcGetAuthNonceParams, o as OtcReadyResult, r as OtcGetExecutionStatusParams, s as OtcRfqSubscriptionParams, t as OtcExecuteParams, u as OtcVerifyAuthParams } from "../clientTypes-_bJZ6Psb.cjs";
3
3
  import { n as OtcErrorCode, t as OTC_ERROR_CODES } from "../otcErrorCodes-CsmoGjD_.cjs";
4
- export { OTC_ERROR_CODES, OtcErrorCode, OtcExecuteParams, OtcGetExecutionStatusParams, OtcGetReadyParams, OtcQuoteSizeUnit, OtcQuoteStream, OtcReadyResult, OtcRfqSubscriptionParams, OtcServerExecutionFailure, OtcServerExecutionPendingResolution, OtcServerExecutionResponse, OtcServerExecutionSuccess, OtcServerQuote, OtcServerQuoteBatch, OtcServerQuoteStream, OtcServerRfqAck, OtcServerRfqMessage, OtcServerRfqSubscribeStreamsRequest, OtcServerRfqSubscriptionRequest, OtcServerRfqUnsubscribeStreamsRequest, OtcServerTakerOrderParams };
4
+ export { OTC_ERROR_CODES, OtcErrorCode, OtcExecuteParams, OtcGetAuthNonceParams, OtcGetExecutionStatusParams, OtcGetReadyParams, OtcQuoteSizeUnit, OtcQuoteStream, OtcReadyResult, OtcRfqSubscriptionParams, OtcServerAuthNonce, OtcServerAuthSession, OtcServerExecutionFailure, OtcServerExecutionPendingResolution, OtcServerExecutionResponse, OtcServerExecutionSuccess, OtcServerQuote, OtcServerQuoteBatch, OtcServerQuoteStream, OtcServerRfqAck, OtcServerRfqMessage, OtcServerRfqSubscribeStreamsRequest, OtcServerRfqSubscriptionRequest, OtcServerRfqUnsubscribeStreamsRequest, OtcServerTakerOrderParams, OtcSiweMessageParams, OtcVerifyAuthParams };
@@ -1,4 +1,4 @@
1
- import { a as OtcServerExecutionSuccess, c as OtcServerQuoteStream, d as OtcServerRfqSubscribeStreamsRequest, f as OtcServerRfqSubscriptionRequest, i as OtcServerExecutionResponse, l as OtcServerRfqAck, n as OtcServerExecutionFailure, o as OtcServerQuote, p as OtcServerRfqUnsubscribeStreamsRequest, r as OtcServerExecutionPendingResolution, s as OtcServerQuoteBatch, t as OtcQuoteSizeUnit, u as OtcServerRfqMessage } from "../serverTypes-CGY8MQaT.js";
2
- import { a as OtcReadyResult, i as OtcQuoteStream, n as OtcGetExecutionStatusParams, o as OtcRfqSubscriptionParams, r as OtcGetReadyParams, s as OtcServerTakerOrderParams, t as OtcExecuteParams } from "../clientTypes-CMksWClt.js";
1
+ import { a as OtcServerExecutionPendingResolution, c as OtcServerQuote, d as OtcServerRfqAck, f as OtcServerRfqMessage, h as OtcServerRfqUnsubscribeStreamsRequest, i as OtcServerExecutionFailure, l as OtcServerQuoteBatch, m as OtcServerRfqSubscriptionRequest, n as OtcServerAuthNonce, o as OtcServerExecutionResponse, p as OtcServerRfqSubscribeStreamsRequest, r as OtcServerAuthSession, s as OtcServerExecutionSuccess, t as OtcQuoteSizeUnit, u as OtcServerQuoteStream } from "../serverTypes-CgQcIVf1.js";
2
+ import { a as OtcQuoteStream, c as OtcServerTakerOrderParams, i as OtcGetReadyParams, l as OtcSiweMessageParams, n as OtcGetAuthNonceParams, o as OtcReadyResult, r as OtcGetExecutionStatusParams, s as OtcRfqSubscriptionParams, t as OtcExecuteParams, u as OtcVerifyAuthParams } from "../clientTypes-DadMpdOk.js";
3
3
  import { n as OtcErrorCode, t as OTC_ERROR_CODES } from "../otcErrorCodes-CsmoGjD_.js";
4
- export { OTC_ERROR_CODES, OtcErrorCode, OtcExecuteParams, OtcGetExecutionStatusParams, OtcGetReadyParams, OtcQuoteSizeUnit, OtcQuoteStream, OtcReadyResult, OtcRfqSubscriptionParams, OtcServerExecutionFailure, OtcServerExecutionPendingResolution, OtcServerExecutionResponse, OtcServerExecutionSuccess, OtcServerQuote, OtcServerQuoteBatch, OtcServerQuoteStream, OtcServerRfqAck, OtcServerRfqMessage, OtcServerRfqSubscribeStreamsRequest, OtcServerRfqSubscriptionRequest, OtcServerRfqUnsubscribeStreamsRequest, OtcServerTakerOrderParams };
4
+ export { OTC_ERROR_CODES, OtcErrorCode, OtcExecuteParams, OtcGetAuthNonceParams, OtcGetExecutionStatusParams, OtcGetReadyParams, OtcQuoteSizeUnit, OtcQuoteStream, OtcReadyResult, OtcRfqSubscriptionParams, OtcServerAuthNonce, OtcServerAuthSession, OtcServerExecutionFailure, OtcServerExecutionPendingResolution, OtcServerExecutionResponse, OtcServerExecutionSuccess, OtcServerQuote, OtcServerQuoteBatch, OtcServerQuoteStream, OtcServerRfqAck, OtcServerRfqMessage, OtcServerRfqSubscribeStreamsRequest, OtcServerRfqSubscriptionRequest, OtcServerRfqUnsubscribeStreamsRequest, OtcServerTakerOrderParams, OtcSiweMessageParams, OtcVerifyAuthParams };
@@ -1,2 +1,2 @@
1
- import { a as OtcServerExecutionSuccess, c as OtcServerQuoteStream, d as OtcServerRfqSubscribeStreamsRequest, f as OtcServerRfqSubscriptionRequest, i as OtcServerExecutionResponse, l as OtcServerRfqAck, n as OtcServerExecutionFailure, o as OtcServerQuote, p as OtcServerRfqUnsubscribeStreamsRequest, r as OtcServerExecutionPendingResolution, s as OtcServerQuoteBatch, t as OtcQuoteSizeUnit, u as OtcServerRfqMessage } from "../serverTypes-CGY8MQaT.cjs";
2
- export { OtcQuoteSizeUnit, OtcServerExecutionFailure, OtcServerExecutionPendingResolution, OtcServerExecutionResponse, OtcServerExecutionSuccess, OtcServerQuote, OtcServerQuoteBatch, OtcServerQuoteStream, OtcServerRfqAck, OtcServerRfqMessage, OtcServerRfqSubscribeStreamsRequest, OtcServerRfqSubscriptionRequest, OtcServerRfqUnsubscribeStreamsRequest };
1
+ import { a as OtcServerExecutionPendingResolution, c as OtcServerQuote, d as OtcServerRfqAck, f as OtcServerRfqMessage, h as OtcServerRfqUnsubscribeStreamsRequest, i as OtcServerExecutionFailure, l as OtcServerQuoteBatch, m as OtcServerRfqSubscriptionRequest, n as OtcServerAuthNonce, o as OtcServerExecutionResponse, p as OtcServerRfqSubscribeStreamsRequest, r as OtcServerAuthSession, s as OtcServerExecutionSuccess, t as OtcQuoteSizeUnit, u as OtcServerQuoteStream } from "../serverTypes-CgQcIVf1.cjs";
2
+ export { OtcQuoteSizeUnit, OtcServerAuthNonce, OtcServerAuthSession, OtcServerExecutionFailure, OtcServerExecutionPendingResolution, OtcServerExecutionResponse, OtcServerExecutionSuccess, OtcServerQuote, OtcServerQuoteBatch, OtcServerQuoteStream, OtcServerRfqAck, OtcServerRfqMessage, OtcServerRfqSubscribeStreamsRequest, OtcServerRfqSubscriptionRequest, OtcServerRfqUnsubscribeStreamsRequest };
@@ -1,2 +1,2 @@
1
- import { a as OtcServerExecutionSuccess, c as OtcServerQuoteStream, d as OtcServerRfqSubscribeStreamsRequest, f as OtcServerRfqSubscriptionRequest, i as OtcServerExecutionResponse, l as OtcServerRfqAck, n as OtcServerExecutionFailure, o as OtcServerQuote, p as OtcServerRfqUnsubscribeStreamsRequest, r as OtcServerExecutionPendingResolution, s as OtcServerQuoteBatch, t as OtcQuoteSizeUnit, u as OtcServerRfqMessage } from "../serverTypes-CGY8MQaT.js";
2
- export { OtcQuoteSizeUnit, OtcServerExecutionFailure, OtcServerExecutionPendingResolution, OtcServerExecutionResponse, OtcServerExecutionSuccess, OtcServerQuote, OtcServerQuoteBatch, OtcServerQuoteStream, OtcServerRfqAck, OtcServerRfqMessage, OtcServerRfqSubscribeStreamsRequest, OtcServerRfqSubscriptionRequest, OtcServerRfqUnsubscribeStreamsRequest };
1
+ import { a as OtcServerExecutionPendingResolution, c as OtcServerQuote, d as OtcServerRfqAck, f as OtcServerRfqMessage, h as OtcServerRfqUnsubscribeStreamsRequest, i as OtcServerExecutionFailure, l as OtcServerQuoteBatch, m as OtcServerRfqSubscriptionRequest, n as OtcServerAuthNonce, o as OtcServerExecutionResponse, p as OtcServerRfqSubscribeStreamsRequest, r as OtcServerAuthSession, s as OtcServerExecutionSuccess, t as OtcQuoteSizeUnit, u as OtcServerQuoteStream } from "../serverTypes-CgQcIVf1.js";
2
+ export { OtcQuoteSizeUnit, OtcServerAuthNonce, OtcServerAuthSession, OtcServerExecutionFailure, OtcServerExecutionPendingResolution, OtcServerExecutionResponse, OtcServerExecutionSuccess, OtcServerQuote, OtcServerQuoteBatch, OtcServerQuoteStream, OtcServerRfqAck, OtcServerRfqMessage, OtcServerRfqSubscribeStreamsRequest, OtcServerRfqSubscriptionRequest, OtcServerRfqUnsubscribeStreamsRequest };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nadohq/otc-client",
3
- "version": "0.55.0",
3
+ "version": "0.57.0",
4
4
  "type": "module",
5
5
  "sideEffects": false,
6
6
  "description": "HTTP client for the Nado OTC service - execute a signed fill-or-kill order, read its status, and build RFQ quote subscriptions",
@@ -41,12 +41,12 @@
41
41
  "module": "./dist/index.js",
42
42
  "types": "./dist/index.d.ts",
43
43
  "dependencies": {
44
- "@nadohq/engine-client": "^0.55.0",
45
- "@nadohq/shared": "^0.55.0",
44
+ "@nadohq/engine-client": "^0.57.0",
45
+ "@nadohq/shared": "^0.57.0",
46
46
  "axios": "1.16.1"
47
47
  },
48
48
  "devDependencies": {
49
49
  "@jest/globals": "30.4.1"
50
50
  },
51
- "gitHead": "b76772999226b64d52b03662246c7e98ba5b7d06"
51
+ "gitHead": "7cb8102ccb2b3632cad3a8c44c3bbe6c7a081ae6"
52
52
  }
package/src/OtcClient.ts CHANGED
@@ -1,12 +1,18 @@
1
1
  import { getNadoClientTypeHeaders } from '@nadohq/shared';
2
- import axios, { AxiosInstance } from 'axios';
2
+ import axios, { AxiosInstance, AxiosResponse } from 'axios';
3
3
  import {
4
4
  OtcExecuteParams,
5
+ OtcGetAuthNonceParams,
5
6
  OtcGetExecutionStatusParams,
6
7
  OtcGetReadyParams,
7
8
  OtcReadyResult,
9
+ OtcVerifyAuthParams,
8
10
  } from './types/clientTypes';
9
- import { OtcServerExecutionResponse } from './types/serverTypes';
11
+ import {
12
+ OtcServerAuthNonce,
13
+ OtcServerAuthSession,
14
+ OtcServerExecutionResponse,
15
+ } from './types/serverTypes';
10
16
 
11
17
  export interface OtcClientOpts {
12
18
  /**
@@ -40,6 +46,28 @@ export class OtcClient {
40
46
  });
41
47
  }
42
48
 
49
+ /**
50
+ * Starts a private quote login for `sender`. Build the message with `buildOtcSiweMessage`,
51
+ * sign it, and pass it to {@link OtcClient.verifyAuth} within 60s. Throws on a non-200.
52
+ */
53
+ async getAuthNonce(
54
+ params: OtcGetAuthNonceParams,
55
+ ): Promise<OtcServerAuthNonce> {
56
+ return this.postAuth('/v1/auth/nonce', { sender: params.sender });
57
+ }
58
+
59
+ /**
60
+ * Completes a private quote login. On success the browser holds the session cookie; open a
61
+ * new quote socket afterwards, since a socket keeps the session it had at its handshake.
62
+ * Throws on a non-200; the message carries the service's `error` code.
63
+ */
64
+ async verifyAuth(params: OtcVerifyAuthParams): Promise<OtcServerAuthSession> {
65
+ return this.postAuth('/v1/auth/verify', {
66
+ message: params.message,
67
+ signature: params.signature,
68
+ });
69
+ }
70
+
43
71
  /**
44
72
  * Submits a signed taker order. Send this body unchanged on `retry_same_request`.
45
73
  */
@@ -77,6 +105,25 @@ export class OtcClient {
77
105
  };
78
106
  }
79
107
 
108
+ /** The login routes need credentials. */
109
+ private async postAuth<T>(path: string, body: unknown): Promise<T> {
110
+ const response = await this.axiosInstance.post(
111
+ `${this.opts.url}${path}`,
112
+ body,
113
+ { withCredentials: true },
114
+ );
115
+ this.checkResponseStatus(response);
116
+ return response.data as T;
117
+ }
118
+
119
+ private checkResponseStatus(response: AxiosResponse) {
120
+ if (response.status !== 200 || !response.data) {
121
+ throw Error(
122
+ `Unexpected response from server: ${response.status} ${response.statusText}. Data: ${JSON.stringify(response.data)}`,
123
+ );
124
+ }
125
+ }
126
+
80
127
  private async postExecution(
81
128
  path: string,
82
129
  body: unknown,
package/src/index.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  export * from './endpoints';
2
2
  export * from './OtcClient';
3
3
  export * from './rfqSubscription';
4
+ export * from './siweMessage';
4
5
  export * from './types';
@@ -0,0 +1,34 @@
1
+ import { describe, expect, it } from '@jest/globals';
2
+ import { buildOtcSiweMessage } from './siweMessage';
3
+
4
+ describe('buildOtcSiweMessage', () => {
5
+ it('matches the documented message layout', () => {
6
+ expect(
7
+ buildOtcSiweMessage({
8
+ domain: 'testnet.nado.xyz',
9
+ uri: 'https://testnet.nado.xyz',
10
+ address: '0x1111111111111111111111111111111111111111',
11
+ chainId: 763373,
12
+ nonce: 'Qm3Ys8Pd5Hc1Ja6R',
13
+ issuedAtMs: Date.UTC(2026, 9, 6, 12),
14
+ sender:
15
+ '0x111111111111111111111111111111111111111164656661756c740000000000',
16
+ }),
17
+ ).toBe(
18
+ [
19
+ 'testnet.nado.xyz wants you to sign in with your Ethereum account:',
20
+ '0x1111111111111111111111111111111111111111',
21
+ '',
22
+ 'Sign in to read Nado OTC quotes. This signature cannot place or authorize trades.',
23
+ '',
24
+ 'URI: https://testnet.nado.xyz',
25
+ 'Version: 1',
26
+ 'Chain ID: 763373',
27
+ 'Nonce: Qm3Ys8Pd5Hc1Ja6R',
28
+ 'Issued At: 2026-10-06T12:00:00.000Z',
29
+ 'Resources:',
30
+ '- urn:nado:subaccount:0x111111111111111111111111111111111111111164656661756c740000000000',
31
+ ].join('\n'),
32
+ );
33
+ });
34
+ });
@@ -0,0 +1,36 @@
1
+ import { OtcSiweMessageParams } from './types/clientTypes';
2
+
3
+ /**
4
+ * Statement shown to the user when the owner wallet signs. The service does not check it.
5
+ */
6
+ export const OTC_SIWE_STATEMENT =
7
+ 'Sign in to read Nado OTC quotes. This signature cannot place or authorize trades.';
8
+
9
+ /**
10
+ * Builds the exact ERC-4361 text the OTC service verifies for private quote login. Sign it
11
+ * with `personal_sign` and send it unchanged to `verifyAuth`.
12
+ */
13
+ export function buildOtcSiweMessage({
14
+ domain,
15
+ uri,
16
+ address,
17
+ chainId,
18
+ nonce,
19
+ issuedAtMs,
20
+ sender,
21
+ }: OtcSiweMessageParams): string {
22
+ return [
23
+ `${domain} wants you to sign in with your Ethereum account:`,
24
+ address,
25
+ '',
26
+ OTC_SIWE_STATEMENT,
27
+ '',
28
+ `URI: ${uri}`,
29
+ 'Version: 1',
30
+ `Chain ID: ${chainId}`,
31
+ `Nonce: ${nonce}`,
32
+ `Issued At: ${new Date(issuedAtMs).toISOString()}`,
33
+ 'Resources:',
34
+ `- urn:nado:subaccount:${sender}`,
35
+ ].join('\n');
36
+ }
@@ -14,7 +14,7 @@ export interface OtcExecuteParams {
14
14
  /** Client-generated idempotency key, 1–128 bytes. Kept across retries of this intent. */
15
15
  dealId: string;
16
16
  taker: OtcServerTakerOrderParams;
17
- /** Execution route. Omitted selects the service default (`awr`). */
17
+ /** The route. The service requires it and has no default. */
18
18
  pricerId?: string;
19
19
  }
20
20
 
@@ -27,6 +27,33 @@ export interface OtcGetReadyParams {
27
27
  pricerId?: string;
28
28
  }
29
29
 
30
+ export interface OtcGetAuthNonceParams {
31
+ /** The 32-byte subaccount the login is bound to. */
32
+ sender: string;
33
+ }
34
+
35
+ export interface OtcSiweMessageParams {
36
+ /** Host of the page origin, e.g. `testnet.nado.xyz`. */
37
+ domain: string;
38
+ /** The page origin, with no path or trailing slash. */
39
+ uri: string;
40
+ /** The signing address, EIP-55 checksummed: the owner or the sender's linked signer. */
41
+ address: string;
42
+ chainId: number;
43
+ nonce: string;
44
+ /** `issued_at_ms` from the nonce response; a local clock can be rejected as future. */
45
+ issuedAtMs: number;
46
+ /** The same sender as the nonce request. */
47
+ sender: string;
48
+ }
49
+
50
+ export interface OtcVerifyAuthParams {
51
+ /** The SIWE text exactly as signed. */
52
+ message: string;
53
+ /** 65-byte hex `personal_sign` signature of `message`. */
54
+ signature: string;
55
+ }
56
+
30
57
  /**
31
58
  * Route coverage. HTTP 200 is ready; 400 and 503 are not. This does not guarantee liquidity
32
59
  * or that an order will be accepted.
@@ -46,7 +73,7 @@ export interface OtcQuoteStream {
46
73
  wallet: string;
47
74
  size: string;
48
75
  sizeUnit: OtcQuoteSizeUnit;
49
- /** Execution route. Omitted selects the service default (`awr`). */
76
+ /** The route. The service requires it and has no default. */
50
77
  pricerId?: string;
51
78
  }
52
79
 
@@ -1,5 +1,21 @@
1
1
  export type OtcQuoteSizeUnit = 'base' | 'quote';
2
2
 
3
+ export interface OtcServerAuthNonce {
4
+ nonce: string;
5
+ issued_at_ms: number;
6
+ /** The nonce lasts 60s from issuance. */
7
+ expires_at_ms: number;
8
+ session_expires_at_ms: number | null;
9
+ }
10
+
11
+ /** The verified login identity. The session itself lives in an HttpOnly cookie. */
12
+ export interface OtcServerAuthSession {
13
+ owner: string;
14
+ sender: string;
15
+ signer: string;
16
+ expires_at_ms: number;
17
+ }
18
+
3
19
  interface OtcServerExecutionDiagnostics {
4
20
  failure_source?: string;
5
21
  failure_stage?: string;
@@ -1 +0,0 @@
1
- {"version":3,"file":"OtcClient-qUPYb1BP.cjs","names":[],"sources":["../src/OtcClient.ts"],"sourcesContent":["import { getNadoClientTypeHeaders } from '@nadohq/shared';\nimport axios, { AxiosInstance } from 'axios';\nimport {\n OtcExecuteParams,\n OtcGetExecutionStatusParams,\n OtcGetReadyParams,\n OtcReadyResult,\n} from './types/clientTypes';\nimport { OtcServerExecutionResponse } from './types/serverTypes';\n\nexport interface OtcClientOpts {\n /**\n * OTC service origin, without a path, e.g. {@link OTC_CLIENT_ENDPOINTS}.\n */\n url: string;\n // If provided, identifies the calling client, sent as a header with every request\n clientType?: string;\n}\n\n/**\n * Client for the public OTC service.\n *\n * {@link OtcClient.execute} does not sign. The caller supplies an already-signed taker order.\n * A quote is not required. {@link OtcClient.getExecutionStatus} only reads a deal; it does not\n * start or resume one.\n *\n * Responses are the JSON body as returned, including non-200 admission responses. Branch on\n * `status` and `recovery_action`.\n */\nexport class OtcClient {\n readonly opts: OtcClientOpts;\n readonly axiosInstance: AxiosInstance;\n\n constructor(opts: OtcClientOpts) {\n this.opts = opts;\n this.axiosInstance = axios.create({\n withCredentials: false,\n validateStatus: () => true,\n headers: getNadoClientTypeHeaders(opts.clientType),\n });\n }\n\n /**\n * Submits a signed taker order. Send this body unchanged on `retry_same_request`.\n */\n async execute(params: OtcExecuteParams): Promise<OtcServerExecutionResponse> {\n return this.postExecution('/v1/executor', {\n deal_id: params.dealId,\n taker: params.taker,\n ...(params.pricerId ? { pricer_id: params.pricerId } : {}),\n });\n }\n\n /**\n * Reads one execution. Use it after a lost response, a refresh, or `wait`.\n */\n async getExecutionStatus(\n params: OtcGetExecutionStatusParams,\n ): Promise<OtcServerExecutionResponse> {\n return this.postExecution('/v1/executor/status', {\n deal_id: params.dealId,\n taker_digest: params.takerDigest,\n });\n }\n\n /**\n * Checks that quote and deal product scopes overlap for a route. An omitted `pricerId`\n * asks the service default. A direct execution needs a matching deal worker, not a prior quote.\n */\n async getReady(params: OtcGetReadyParams = {}): Promise<OtcReadyResult> {\n const response = await this.axiosInstance.get(`${this.opts.url}/ready`, {\n params: params.pricerId ? { pricer_id: params.pricerId } : undefined,\n });\n return {\n httpStatus: response.status,\n ready: response.status === 200,\n };\n }\n\n private async postExecution(\n path: string,\n body: unknown,\n ): Promise<OtcServerExecutionResponse> {\n const response = await this.axiosInstance.post(\n `${this.opts.url}${path}`,\n body,\n );\n return response.data as OtcServerExecutionResponse;\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA6BA,IAAa,YAAb,MAAuB;CAIrB,YAAY,MAAqB;EAC/B,KAAK,OAAO;EACZ,KAAK,gBAAgB,MAAA,QAAM,OAAO;GAChC,iBAAiB;GACjB,sBAAsB;GACtB,UAAA,GAAA,eAAA,0BAAkC,KAAK,UAAU;EACnD,CAAC;CACH;;;;CAKA,MAAM,QAAQ,QAA+D;EAC3E,OAAO,KAAK,cAAc,gBAAgB;GACxC,SAAS,OAAO;GAChB,OAAO,OAAO;GACd,GAAI,OAAO,WAAW,EAAE,WAAW,OAAO,SAAS,IAAI,CAAC;EAC1D,CAAC;CACH;;;;CAKA,MAAM,mBACJ,QACqC;EACrC,OAAO,KAAK,cAAc,uBAAuB;GAC/C,SAAS,OAAO;GAChB,cAAc,OAAO;EACvB,CAAC;CACH;;;;;CAMA,MAAM,SAAS,SAA4B,CAAC,GAA4B;EACtE,MAAM,WAAW,MAAM,KAAK,cAAc,IAAI,GAAG,KAAK,KAAK,IAAI,SAAS,EACtE,QAAQ,OAAO,WAAW,EAAE,WAAW,OAAO,SAAS,IAAI,KAAA,EAC7D,CAAC;EACD,OAAO;GACL,YAAY,SAAS;GACrB,OAAO,SAAS,WAAW;EAC7B;CACF;CAEA,MAAc,cACZ,MACA,MACqC;EAKrC,QAAO,MAJgB,KAAK,cAAc,KACxC,GAAG,KAAK,KAAK,MAAM,QACnB,IACF,GACgB;CAClB;AACF"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"clientTypes-CMksWClt.d.ts","names":[],"sources":["../src/types/src/types/clientTypes.ts"],"mappings":";;;;;;AAOA;;KAAY,yBAAA,GAA4B,IAAI,CAC1C,4BAAA;AAAA,UAIe,gBAAA;EAJa;EAM5B,MAAA;EACA,KAAA,EAAO,yBAAyB;;EAEhC,QAAA;AAAA;AAAA,UAGe,2BAAA;EACf,MAAA;EACA,WAAW;AAAA;AAAA,UAGI,iBAAA;EACf,QAAQ;AAAA;;;AAJG;AAGb;UAQiB,cAAA;EACf,UAAA;EACA,KAAK;AAAA;AAFP;;;;AAAA,UASiB,cAAA;EACf,IAAA;EACA,SAAA;EACA,MAAA;EACA,IAAA;EACA,QAAA,EAAU,gBAAgB;EAH1B;EAKA,QAAA;AAAA;;UAIe,wBAAA;EACf,EAAA;EACA,OAAA,EAAS,cAAc;AAAA"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"clientTypes-CjBtkKtk.d.cts","names":[],"sources":["../src/types/src/types/clientTypes.ts"],"mappings":";;;;;;AAOA;;KAAY,yBAAA,GAA4B,IAAI,CAC1C,4BAAA;AAAA,UAIe,gBAAA;EAJa;EAM5B,MAAA;EACA,KAAA,EAAO,yBAAyB;;EAEhC,QAAA;AAAA;AAAA,UAGe,2BAAA;EACf,MAAA;EACA,WAAW;AAAA;AAAA,UAGI,iBAAA;EACf,QAAQ;AAAA;;;AAJG;AAGb;UAQiB,cAAA;EACf,UAAA;EACA,KAAK;AAAA;AAFP;;;;AAAA,UASiB,cAAA;EACf,IAAA;EACA,SAAA;EACA,MAAA;EACA,IAAA;EACA,QAAA,EAAU,gBAAgB;EAH1B;EAKA,QAAA;AAAA;;UAIe,wBAAA;EACf,EAAA;EACA,OAAA,EAAS,cAAc;AAAA"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"serverTypes-CGY8MQaT.d.cts","names":[],"sources":["../src/types/src/types/serverTypes.ts"],"mappings":";KAAY,gBAAA;AAAA,UAEF,6BAAA;EACR,cAAA;EACA,aAAA;EACA,mBAAA;EACA,SAAA;EAJQ;;;;EASR,eAAA;EACA,cAAA;AAAA;AAAA,UAGe,yBAAA;EACf,MAAA;EACA,OAAA;EACA,YAAA;EACA,aAAA;AAAA;AAAA,UAGe,yBAAA,SAAkC,6BAA6B;EAC9E,MAAA;EACA,KAAA;EACA,UAAA;EACA,OAAA;EACA,YAAA;AAAA;AAAA,UAGe,mCAAA,SAA4C,6BAA6B;EACxF,MAAA;EACA,OAAA;EACA,YAAA;EACA,KAAA;EACA,UAAA;AAAA;;KAIU,0BAAA,GACR,yBAAA,GACA,yBAAA,GACA,mCAAA;AAAA,UAEa,oBAAA;EACf,IAAA;EACA,UAAA;EACA,MAAA;EACA,IAAA;EACA,SAAA,EAAW,gBAAgB;EAC3B,SAAA;AAAA;AAAA,UAGe,mCAAA;EACf,MAAA;EACA,EAAA;EACA,OAAA,EAAS,oBAAoB;AAAA;AAAA,UAGd,qCAAA;EACf,MAAA;EACA,EAAA;EACA,OAAA,EAAS,oBAAoB;AAAA;AAAA,KAGnB,+BAAA,GACR,mCAAA,GACA,qCAAqC;;UAGxB,cAAA;EACf,UAAA;EACA,IAAA;EACA,SAAA,EAAW,gBAAgB;EAC3B,IAAA;EACA,MAAA;EACA,SAAA;EACA,MAAA;EACA,SAAA;EACA,cAAA;EACA,SAAA;AAAA;AAAA,UAGe,mBAAA;EACf,IAAA;EACA,IAAA;EACA,MAAA,EAAQ,cAAc;AAAA;AAAA,UAGP,eAAA;EACf,MAAA;EACA,EAAA;EAzCA;EA2CA,KAAA;AAAA;AAAA,KAGU,mBAAA,GAAsB,eAAA,GAAkB,mBAAmB"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"serverTypes-CGY8MQaT.d.ts","names":[],"sources":["../src/types/src/types/serverTypes.ts"],"mappings":";KAAY,gBAAA;AAAA,UAEF,6BAAA;EACR,cAAA;EACA,aAAA;EACA,mBAAA;EACA,SAAA;EAJQ;;;;EASR,eAAA;EACA,cAAA;AAAA;AAAA,UAGe,yBAAA;EACf,MAAA;EACA,OAAA;EACA,YAAA;EACA,aAAA;AAAA;AAAA,UAGe,yBAAA,SAAkC,6BAA6B;EAC9E,MAAA;EACA,KAAA;EACA,UAAA;EACA,OAAA;EACA,YAAA;AAAA;AAAA,UAGe,mCAAA,SAA4C,6BAA6B;EACxF,MAAA;EACA,OAAA;EACA,YAAA;EACA,KAAA;EACA,UAAA;AAAA;;KAIU,0BAAA,GACR,yBAAA,GACA,yBAAA,GACA,mCAAA;AAAA,UAEa,oBAAA;EACf,IAAA;EACA,UAAA;EACA,MAAA;EACA,IAAA;EACA,SAAA,EAAW,gBAAgB;EAC3B,SAAA;AAAA;AAAA,UAGe,mCAAA;EACf,MAAA;EACA,EAAA;EACA,OAAA,EAAS,oBAAoB;AAAA;AAAA,UAGd,qCAAA;EACf,MAAA;EACA,EAAA;EACA,OAAA,EAAS,oBAAoB;AAAA;AAAA,KAGnB,+BAAA,GACR,mCAAA,GACA,qCAAqC;;UAGxB,cAAA;EACf,UAAA;EACA,IAAA;EACA,SAAA,EAAW,gBAAgB;EAC3B,IAAA;EACA,MAAA;EACA,SAAA;EACA,MAAA;EACA,SAAA;EACA,cAAA;EACA,SAAA;AAAA;AAAA,UAGe,mBAAA;EACf,IAAA;EACA,IAAA;EACA,MAAA,EAAQ,cAAc;AAAA;AAAA,UAGP,eAAA;EACf,MAAA;EACA,EAAA;EAzCA;EA2CA,KAAA;AAAA;AAAA,KAGU,mBAAA,GAAsB,eAAA,GAAkB,mBAAmB"}