@nadohq/otc-client 0.62.0 → 0.64.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -44,23 +44,20 @@ the public wallet `0xfffffffffffffffffffffffffffffffffffffffe` never do. The ses
44
44
  cookie the browser keeps; open a new quote socket after logging in, since a socket keeps whatever
45
45
  session it had at its handshake.
46
46
 
47
- ```ts
48
- import { buildOtcSiweMessage, OtcClient } from '@nadohq/otc-client';
47
+ `login` signs in the wallet client's owner for a subaccount, with the linked signer or the
48
+ wallet itself, like the other clients. Throws on a non-200.
49
49
 
50
- const nonce = await otcClient.getAuthNonce({ sender });
51
- const message = buildOtcSiweMessage({
50
+ ```ts
51
+ const session = await otcClient.login({
52
52
  domain: 'testnet.nado.xyz',
53
53
  uri: 'https://testnet.nado.xyz',
54
- address: signerAddress, // owner or the sender's linked signer, checksummed
55
54
  chainId: 763373,
56
- nonce: nonce.nonce,
57
- issuedAtMs: nonce.issued_at_ms,
58
- sender,
55
+ subaccountName: 'default',
59
56
  });
60
- const signature = await walletClient.signMessage({ message });
61
- await otcClient.verifyAuth({ message, signature }); // throws on a non-200
62
57
  ```
63
58
 
59
+ To sign elsewhere, `getAuthNonce`, `buildOtcSiweMessage` and `verifyAuth` are the three steps.
60
+
64
61
  The login routes only admit approved web origins, so they can be called from a browser page
65
62
  on one of those origins.
66
63
 
@@ -20,6 +20,7 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
20
20
  enumerable: true
21
21
  }) : target, mod));
22
22
  //#endregion
23
+ const require_siweMessage = require("./siweMessage.cjs");
23
24
  let _nadohq_shared = require("@nadohq/shared");
24
25
  let axios = require("axios");
25
26
  axios = __toESM(axios, 1);
@@ -27,8 +28,9 @@ axios = __toESM(axios, 1);
27
28
  /**
28
29
  * Client for the public OTC service.
29
30
  *
30
- * {@link OtcClient.execute} does not sign. The caller supplies an already-signed taker order.
31
- * A quote is not required. {@link OtcClient.getExecutionStatus} only reads a deal; it does not
31
+ * {@link OtcClient.login} signs the private quote login with the linked signer, or the wallet
32
+ * when there is none. {@link OtcClient.execute} does not sign. The caller supplies an
33
+ * already-signed taker order. A quote is not required. {@link OtcClient.getExecutionStatus} only reads a deal; it does not
32
34
  * start or resume one.
33
35
  *
34
36
  * Responses are the JSON body as returned, including non-200 admission responses. Branch on
@@ -44,16 +46,54 @@ var OtcClient = class {
44
46
  });
45
47
  }
46
48
  /**
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
+ * Sets the linked signer for the private quote login
50
+ *
51
+ * @param linkedSignerWalletClient The linkedSigner to use for all signatures. Set to null to revert to the chain signer
52
+ */
53
+ setLinkedSigner(linkedSignerWalletClient) {
54
+ this.opts.linkedSignerWalletClient = linkedSignerWalletClient ?? void 0;
55
+ }
56
+ /**
57
+ * Logs the wallet's subaccount in for private quotes: fetches a nonce, signs the SIWE text
58
+ * with the linked signer (or the wallet) and verifies it. On success the browser holds the
59
+ * session cookie; open a new quote socket afterwards, since a socket keeps the session it
60
+ * had at its handshake. Throws on a non-200; the message carries the service's `error` code.
61
+ */
62
+ async login(params) {
63
+ const { walletClient, linkedSignerWalletClient } = this.opts;
64
+ if (!walletClient) throw new _nadohq_shared.WalletNotProvidedError();
65
+ const sender = (0, _nadohq_shared.subaccountToHex)({
66
+ subaccountOwner: walletClient.account.address,
67
+ subaccountName: params.subaccountName
68
+ });
69
+ const signer = linkedSignerWalletClient ?? walletClient;
70
+ const nonce = await this.getAuthNonce({ sender });
71
+ const message = require_siweMessage.buildOtcSiweMessage({
72
+ domain: params.domain,
73
+ uri: params.uri,
74
+ chainId: params.chainId,
75
+ address: signer.account.address,
76
+ nonce: nonce.nonce,
77
+ issuedAtMs: nonce.issued_at_ms,
78
+ sender
79
+ });
80
+ const signature = await signer.signMessage({ message });
81
+ return this.verifyAuth({
82
+ message,
83
+ signature
84
+ });
85
+ }
86
+ /**
87
+ * First step of {@link OtcClient.login}, for signing outside the client. Build the message
88
+ * with `buildOtcSiweMessage`, sign it, and pass it to {@link OtcClient.verifyAuth} within
89
+ * 60s. Throws on a non-200.
49
90
  */
50
91
  async getAuthNonce(params) {
51
92
  return this.postAuth("/v1/auth/nonce", { sender: params.sender });
52
93
  }
53
94
  /**
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.
95
+ * Last step of {@link OtcClient.login}, for signing outside the client. Throws on a non-200;
96
+ * the message carries the service's `error` code.
57
97
  */
58
98
  async verifyAuth(params) {
59
99
  return this.postAuth("/v1/auth/verify", {
@@ -112,4 +152,4 @@ Object.defineProperty(exports, "OtcClient", {
112
152
  }
113
153
  });
114
154
 
115
- //# sourceMappingURL=OtcClient-BYspxGIn.cjs.map
155
+ //# sourceMappingURL=OtcClient-gkP2YE4s.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"OtcClient-gkP2YE4s.cjs","names":["WalletNotProvidedError","buildOtcSiweMessage"],"sources":["../src/OtcClient.ts"],"sourcesContent":["import {\n getNadoClientTypeHeaders,\n subaccountToHex,\n WalletClientWithAccount,\n WalletNotProvidedError,\n} from '@nadohq/shared';\nimport axios, { AxiosInstance, AxiosResponse } from 'axios';\nimport { buildOtcSiweMessage } from './siweMessage';\nimport {\n OtcExecuteParams,\n OtcGetAuthNonceParams,\n OtcGetExecutionStatusParams,\n OtcGetReadyParams,\n OtcLoginParams,\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 // Wallet client for the private quote login signature\n walletClient?: WalletClientWithAccount;\n // Linked signer registered through the engine, if provided, the login uses this signer\n linkedSignerWalletClient?: WalletClientWithAccount;\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.login} signs the private quote login with the linked signer, or the wallet\n * when there is none. {@link OtcClient.execute} does not sign. The caller supplies an\n * already-signed taker order. 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 * Sets the linked signer for the private quote login\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 * Logs the wallet's subaccount in for private quotes: fetches a nonce, signs the SIWE text\n * with the linked signer (or the wallet) and verifies it. On success the browser holds the\n * session cookie; open a new quote socket afterwards, since a socket keeps the session it\n * had at its handshake. Throws on a non-200; the message carries the service's `error` code.\n */\n async login(params: OtcLoginParams): Promise<OtcServerAuthSession> {\n const { walletClient, linkedSignerWalletClient } = this.opts;\n if (!walletClient) {\n throw new WalletNotProvidedError();\n }\n const sender = subaccountToHex({\n subaccountOwner: walletClient.account.address,\n subaccountName: params.subaccountName,\n });\n const signer = linkedSignerWalletClient ?? walletClient;\n const nonce = await this.getAuthNonce({ sender });\n const message = buildOtcSiweMessage({\n domain: params.domain,\n uri: params.uri,\n chainId: params.chainId,\n address: signer.account.address,\n nonce: nonce.nonce,\n issuedAtMs: nonce.issued_at_ms,\n sender,\n });\n const signature = await signer.signMessage({ message });\n return this.verifyAuth({ message, signature });\n }\n\n /**\n * First step of {@link OtcClient.login}, for signing outside the client. Build the message\n * with `buildOtcSiweMessage`, sign it, and pass it to {@link OtcClient.verifyAuth} within\n * 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 * Last step of {@link OtcClient.login}, for signing outside the client. Throws on a non-200;\n * 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":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA+CA,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;;;;;;CAOA,gBACE,0BACA;EACA,KAAK,KAAK,2BAA2B,4BAA4B,KAAA;CACnE;;;;;;;CAQA,MAAM,MAAM,QAAuD;EACjE,MAAM,EAAE,cAAc,6BAA6B,KAAK;EACxD,IAAI,CAAC,cACH,MAAM,IAAIA,eAAAA,uBAAuB;EAEnC,MAAM,UAAA,GAAA,eAAA,iBAAyB;GAC7B,iBAAiB,aAAa,QAAQ;GACtC,gBAAgB,OAAO;EACzB,CAAC;EACD,MAAM,SAAS,4BAA4B;EAC3C,MAAM,QAAQ,MAAM,KAAK,aAAa,EAAE,OAAO,CAAC;EAChD,MAAM,UAAUC,oBAAAA,oBAAoB;GAClC,QAAQ,OAAO;GACf,KAAK,OAAO;GACZ,SAAS,OAAO;GAChB,SAAS,OAAO,QAAQ;GACxB,OAAO,MAAM;GACb,YAAY,MAAM;GAClB;EACF,CAAC;EACD,MAAM,YAAY,MAAM,OAAO,YAAY,EAAE,QAAQ,CAAC;EACtD,OAAO,KAAK,WAAW;GAAE;GAAS;EAAU,CAAC;CAC/C;;;;;;CAOA,MAAM,aACJ,QAC6B;EAC7B,OAAO,KAAK,SAAS,kBAAkB,EAAE,QAAQ,OAAO,OAAO,CAAC;CAClE;;;;;CAMA,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,4 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_OtcClient = require("./OtcClient-BYspxGIn.cjs");
2
+ const require_OtcClient = require("./OtcClient-gkP2YE4s.cjs");
3
+ require("./siweMessage.cjs");
3
4
  exports.OtcClient = require_OtcClient.OtcClient;
@@ -1,5 +1,6 @@
1
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";
2
+ import { a as OtcLoginParams, d as OtcVerifyAuthParams, i as OtcGetReadyParams, n as OtcGetAuthNonceParams, r as OtcGetExecutionStatusParams, s as OtcReadyResult, t as OtcExecuteParams } from "./clientTypes-HHvq70F0.cjs";
3
+ import { WalletClientWithAccount } from "@nadohq/shared";
3
4
  import { AxiosInstance } from "axios";
4
5
 
5
6
  //#region src/OtcClient.d.ts
@@ -8,13 +9,16 @@ interface OtcClientOpts {
8
9
  * OTC service origin, without a path, e.g. {@link OTC_CLIENT_ENDPOINTS}.
9
10
  */
10
11
  url: string;
12
+ walletClient?: WalletClientWithAccount;
13
+ linkedSignerWalletClient?: WalletClientWithAccount;
11
14
  clientType?: string;
12
15
  }
13
16
  /**
14
17
  * Client for the public OTC service.
15
18
  *
16
- * {@link OtcClient.execute} does not sign. The caller supplies an already-signed taker order.
17
- * A quote is not required. {@link OtcClient.getExecutionStatus} only reads a deal; it does not
19
+ * {@link OtcClient.login} signs the private quote login with the linked signer, or the wallet
20
+ * when there is none. {@link OtcClient.execute} does not sign. The caller supplies an
21
+ * already-signed taker order. A quote is not required. {@link OtcClient.getExecutionStatus} only reads a deal; it does not
18
22
  * start or resume one.
19
23
  *
20
24
  * Responses are the JSON body as returned, including non-200 admission responses. Branch on
@@ -25,14 +29,27 @@ declare class OtcClient {
25
29
  readonly axiosInstance: AxiosInstance;
26
30
  constructor(opts: OtcClientOpts);
27
31
  /**
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.
32
+ * Sets the linked signer for the private quote login
33
+ *
34
+ * @param linkedSignerWalletClient The linkedSigner to use for all signatures. Set to null to revert to the chain signer
35
+ */
36
+ setLinkedSigner(linkedSignerWalletClient: WalletClientWithAccount | null): void;
37
+ /**
38
+ * Logs the wallet's subaccount in for private quotes: fetches a nonce, signs the SIWE text
39
+ * with the linked signer (or the wallet) and verifies it. On success the browser holds the
40
+ * session cookie; open a new quote socket afterwards, since a socket keeps the session it
41
+ * had at its handshake. Throws on a non-200; the message carries the service's `error` code.
42
+ */
43
+ login(params: OtcLoginParams): Promise<OtcServerAuthSession>;
44
+ /**
45
+ * First step of {@link OtcClient.login}, for signing outside the client. Build the message
46
+ * with `buildOtcSiweMessage`, sign it, and pass it to {@link OtcClient.verifyAuth} within
47
+ * 60s. Throws on a non-200.
30
48
  */
31
49
  getAuthNonce(params: OtcGetAuthNonceParams): Promise<OtcServerAuthNonce>;
32
50
  /**
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.
51
+ * Last step of {@link OtcClient.login}, for signing outside the client. Throws on a non-200;
52
+ * the message carries the service's `error` code.
36
53
  */
37
54
  verifyAuth(params: OtcVerifyAuthParams): Promise<OtcServerAuthSession>;
38
55
  /**
@@ -1 +1 @@
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
+ {"version":3,"file":"OtcClient.d.cts","names":[],"sources":["../src/src/OtcClient.ts"],"mappings":";;;;;;UAuBiB,aAAA;;AAAjB;;EAIE,GAAA;EAEA,YAAA,GAAe,uBAAA;EAEf,wBAAA,GAA2B,uBAAuB;EAElD,UAAA;AAAA;;;;;AAAU;AAcZ;;;;;;cAAa,SAAA;EAAA,SACF,IAAA,EAAM,aAAA;EAAA,SACN,aAAA,EAAe,aAAA;cAEZ,IAAA,EAAM,aAAA;EAwDR;;;;;EA1CH,eAAA,CACL,wBAAA,EAA0B,uBAAA;EA4DN;;;;;;EAjDhB,KAAA,CAAM,MAAA,EAAQ,cAAA,GAAiB,OAAA,CAAQ,oBAAA;EAyEW;;;;;EA5ClD,YAAA,CACJ,MAAA,EAAQ,qBAAA,GACP,OAAA,CAAQ,kBAAA;EA3DF;;;;EAmEH,UAAA,CAAW,MAAA,EAAQ,mBAAA,GAAsB,OAAA,CAAQ,oBAAA;EAnDhD;;;EA6DD,OAAA,CAAQ,MAAA,EAAQ,gBAAA,GAAmB,OAAA,CAAQ,0BAAA;EAjD7B;;;EA4Dd,kBAAA,CACJ,MAAA,EAAQ,2BAAA,GACP,OAAA,CAAQ,0BAAA;EAjCL;;;;EA4CA,QAAA,CAAS,MAAA,GAAQ,iBAAA,GAAyB,OAAA,CAAQ,cAAA;EAlClD;EAAA,QA6CQ,QAAA;EAAA,QAUN,mBAAA;EAAA,QAQM,aAAA;AAAA"}
@@ -1,5 +1,6 @@
1
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";
2
+ import { a as OtcLoginParams, d as OtcVerifyAuthParams, i as OtcGetReadyParams, n as OtcGetAuthNonceParams, r as OtcGetExecutionStatusParams, s as OtcReadyResult, t as OtcExecuteParams } from "./clientTypes-Dn4FvgqX.js";
3
+ import { WalletClientWithAccount } from "@nadohq/shared";
3
4
  import { AxiosInstance } from "axios";
4
5
 
5
6
  //#region src/OtcClient.d.ts
@@ -8,13 +9,16 @@ interface OtcClientOpts {
8
9
  * OTC service origin, without a path, e.g. {@link OTC_CLIENT_ENDPOINTS}.
9
10
  */
10
11
  url: string;
12
+ walletClient?: WalletClientWithAccount;
13
+ linkedSignerWalletClient?: WalletClientWithAccount;
11
14
  clientType?: string;
12
15
  }
13
16
  /**
14
17
  * Client for the public OTC service.
15
18
  *
16
- * {@link OtcClient.execute} does not sign. The caller supplies an already-signed taker order.
17
- * A quote is not required. {@link OtcClient.getExecutionStatus} only reads a deal; it does not
19
+ * {@link OtcClient.login} signs the private quote login with the linked signer, or the wallet
20
+ * when there is none. {@link OtcClient.execute} does not sign. The caller supplies an
21
+ * already-signed taker order. A quote is not required. {@link OtcClient.getExecutionStatus} only reads a deal; it does not
18
22
  * start or resume one.
19
23
  *
20
24
  * Responses are the JSON body as returned, including non-200 admission responses. Branch on
@@ -25,14 +29,27 @@ declare class OtcClient {
25
29
  readonly axiosInstance: AxiosInstance;
26
30
  constructor(opts: OtcClientOpts);
27
31
  /**
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.
32
+ * Sets the linked signer for the private quote login
33
+ *
34
+ * @param linkedSignerWalletClient The linkedSigner to use for all signatures. Set to null to revert to the chain signer
35
+ */
36
+ setLinkedSigner(linkedSignerWalletClient: WalletClientWithAccount | null): void;
37
+ /**
38
+ * Logs the wallet's subaccount in for private quotes: fetches a nonce, signs the SIWE text
39
+ * with the linked signer (or the wallet) and verifies it. On success the browser holds the
40
+ * session cookie; open a new quote socket afterwards, since a socket keeps the session it
41
+ * had at its handshake. Throws on a non-200; the message carries the service's `error` code.
42
+ */
43
+ login(params: OtcLoginParams): Promise<OtcServerAuthSession>;
44
+ /**
45
+ * First step of {@link OtcClient.login}, for signing outside the client. Build the message
46
+ * with `buildOtcSiweMessage`, sign it, and pass it to {@link OtcClient.verifyAuth} within
47
+ * 60s. Throws on a non-200.
30
48
  */
31
49
  getAuthNonce(params: OtcGetAuthNonceParams): Promise<OtcServerAuthNonce>;
32
50
  /**
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.
51
+ * Last step of {@link OtcClient.login}, for signing outside the client. Throws on a non-200;
52
+ * the message carries the service's `error` code.
36
53
  */
37
54
  verifyAuth(params: OtcVerifyAuthParams): Promise<OtcServerAuthSession>;
38
55
  /**
@@ -1 +1 @@
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"}
1
+ {"version":3,"file":"OtcClient.d.ts","names":[],"sources":["../src/src/OtcClient.ts"],"mappings":";;;;;;UAuBiB,aAAA;;AAAjB;;EAIE,GAAA;EAEA,YAAA,GAAe,uBAAA;EAEf,wBAAA,GAA2B,uBAAuB;EAElD,UAAA;AAAA;;;;;AAAU;AAcZ;;;;;;cAAa,SAAA;EAAA,SACF,IAAA,EAAM,aAAA;EAAA,SACN,aAAA,EAAe,aAAA;cAEZ,IAAA,EAAM,aAAA;EAwDR;;;;;EA1CH,eAAA,CACL,wBAAA,EAA0B,uBAAA;EA4DN;;;;;;EAjDhB,KAAA,CAAM,MAAA,EAAQ,cAAA,GAAiB,OAAA,CAAQ,oBAAA;EAyEW;;;;;EA5ClD,YAAA,CACJ,MAAA,EAAQ,qBAAA,GACP,OAAA,CAAQ,kBAAA;EA3DF;;;;EAmEH,UAAA,CAAW,MAAA,EAAQ,mBAAA,GAAsB,OAAA,CAAQ,oBAAA;EAnDhD;;;EA6DD,OAAA,CAAQ,MAAA,EAAQ,gBAAA,GAAmB,OAAA,CAAQ,0BAAA;EAjD7B;;;EA4Dd,kBAAA,CACJ,MAAA,EAAQ,2BAAA,GACP,OAAA,CAAQ,0BAAA;EAjCL;;;;EA4CA,QAAA,CAAS,MAAA,GAAQ,iBAAA,GAAyB,OAAA,CAAQ,cAAA;EAlClD;EAAA,QA6CQ,QAAA;EAAA,QAUN,mBAAA;EAAA,QAQM,aAAA;AAAA"}
package/dist/OtcClient.js CHANGED
@@ -1,11 +1,13 @@
1
- import { getNadoClientTypeHeaders } from "@nadohq/shared";
1
+ import { buildOtcSiweMessage } from "./siweMessage.js";
2
+ import { WalletNotProvidedError, getNadoClientTypeHeaders, subaccountToHex } from "@nadohq/shared";
2
3
  import axios from "axios";
3
4
  //#region src/OtcClient.ts
4
5
  /**
5
6
  * Client for the public OTC service.
6
7
  *
7
- * {@link OtcClient.execute} does not sign. The caller supplies an already-signed taker order.
8
- * A quote is not required. {@link OtcClient.getExecutionStatus} only reads a deal; it does not
8
+ * {@link OtcClient.login} signs the private quote login with the linked signer, or the wallet
9
+ * when there is none. {@link OtcClient.execute} does not sign. The caller supplies an
10
+ * already-signed taker order. A quote is not required. {@link OtcClient.getExecutionStatus} only reads a deal; it does not
9
11
  * start or resume one.
10
12
  *
11
13
  * Responses are the JSON body as returned, including non-200 admission responses. Branch on
@@ -21,16 +23,54 @@ var OtcClient = class {
21
23
  });
22
24
  }
23
25
  /**
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
+ * Sets the linked signer for the private quote login
27
+ *
28
+ * @param linkedSignerWalletClient The linkedSigner to use for all signatures. Set to null to revert to the chain signer
29
+ */
30
+ setLinkedSigner(linkedSignerWalletClient) {
31
+ this.opts.linkedSignerWalletClient = linkedSignerWalletClient ?? void 0;
32
+ }
33
+ /**
34
+ * Logs the wallet's subaccount in for private quotes: fetches a nonce, signs the SIWE text
35
+ * with the linked signer (or the wallet) and verifies it. On success the browser holds the
36
+ * session cookie; open a new quote socket afterwards, since a socket keeps the session it
37
+ * had at its handshake. Throws on a non-200; the message carries the service's `error` code.
38
+ */
39
+ async login(params) {
40
+ const { walletClient, linkedSignerWalletClient } = this.opts;
41
+ if (!walletClient) throw new WalletNotProvidedError();
42
+ const sender = subaccountToHex({
43
+ subaccountOwner: walletClient.account.address,
44
+ subaccountName: params.subaccountName
45
+ });
46
+ const signer = linkedSignerWalletClient ?? walletClient;
47
+ const nonce = await this.getAuthNonce({ sender });
48
+ const message = buildOtcSiweMessage({
49
+ domain: params.domain,
50
+ uri: params.uri,
51
+ chainId: params.chainId,
52
+ address: signer.account.address,
53
+ nonce: nonce.nonce,
54
+ issuedAtMs: nonce.issued_at_ms,
55
+ sender
56
+ });
57
+ const signature = await signer.signMessage({ message });
58
+ return this.verifyAuth({
59
+ message,
60
+ signature
61
+ });
62
+ }
63
+ /**
64
+ * First step of {@link OtcClient.login}, for signing outside the client. Build the message
65
+ * with `buildOtcSiweMessage`, sign it, and pass it to {@link OtcClient.verifyAuth} within
66
+ * 60s. Throws on a non-200.
26
67
  */
27
68
  async getAuthNonce(params) {
28
69
  return this.postAuth("/v1/auth/nonce", { sender: params.sender });
29
70
  }
30
71
  /**
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.
72
+ * Last step of {@link OtcClient.login}, for signing outside the client. Throws on a non-200;
73
+ * the message carries the service's `error` code.
34
74
  */
35
75
  async verifyAuth(params) {
36
76
  return this.postAuth("/v1/auth/verify", {
@@ -1 +1 @@
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
+ {"version":3,"file":"OtcClient.js","names":[],"sources":["../src/OtcClient.ts"],"sourcesContent":["import {\n getNadoClientTypeHeaders,\n subaccountToHex,\n WalletClientWithAccount,\n WalletNotProvidedError,\n} from '@nadohq/shared';\nimport axios, { AxiosInstance, AxiosResponse } from 'axios';\nimport { buildOtcSiweMessage } from './siweMessage';\nimport {\n OtcExecuteParams,\n OtcGetAuthNonceParams,\n OtcGetExecutionStatusParams,\n OtcGetReadyParams,\n OtcLoginParams,\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 // Wallet client for the private quote login signature\n walletClient?: WalletClientWithAccount;\n // Linked signer registered through the engine, if provided, the login uses this signer\n linkedSignerWalletClient?: WalletClientWithAccount;\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.login} signs the private quote login with the linked signer, or the wallet\n * when there is none. {@link OtcClient.execute} does not sign. The caller supplies an\n * already-signed taker order. 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 * Sets the linked signer for the private quote login\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 * Logs the wallet's subaccount in for private quotes: fetches a nonce, signs the SIWE text\n * with the linked signer (or the wallet) and verifies it. On success the browser holds the\n * session cookie; open a new quote socket afterwards, since a socket keeps the session it\n * had at its handshake. Throws on a non-200; the message carries the service's `error` code.\n */\n async login(params: OtcLoginParams): Promise<OtcServerAuthSession> {\n const { walletClient, linkedSignerWalletClient } = this.opts;\n if (!walletClient) {\n throw new WalletNotProvidedError();\n }\n const sender = subaccountToHex({\n subaccountOwner: walletClient.account.address,\n subaccountName: params.subaccountName,\n });\n const signer = linkedSignerWalletClient ?? walletClient;\n const nonce = await this.getAuthNonce({ sender });\n const message = buildOtcSiweMessage({\n domain: params.domain,\n uri: params.uri,\n chainId: params.chainId,\n address: signer.account.address,\n nonce: nonce.nonce,\n issuedAtMs: nonce.issued_at_ms,\n sender,\n });\n const signature = await signer.signMessage({ message });\n return this.verifyAuth({ message, signature });\n }\n\n /**\n * First step of {@link OtcClient.login}, for signing outside the client. Build the message\n * with `buildOtcSiweMessage`, sign it, and pass it to {@link OtcClient.verifyAuth} within\n * 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 * Last step of {@link OtcClient.login}, for signing outside the client. Throws on a non-200;\n * 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":";;;;;;;;;;;;;;;AA+CA,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;;;;;;CAOA,gBACE,0BACA;EACA,KAAK,KAAK,2BAA2B,4BAA4B,KAAA;CACnE;;;;;;;CAQA,MAAM,MAAM,QAAuD;EACjE,MAAM,EAAE,cAAc,6BAA6B,KAAK;EACxD,IAAI,CAAC,cACH,MAAM,IAAI,uBAAuB;EAEnC,MAAM,SAAS,gBAAgB;GAC7B,iBAAiB,aAAa,QAAQ;GACtC,gBAAgB,OAAO;EACzB,CAAC;EACD,MAAM,SAAS,4BAA4B;EAC3C,MAAM,QAAQ,MAAM,KAAK,aAAa,EAAE,OAAO,CAAC;EAChD,MAAM,UAAU,oBAAoB;GAClC,QAAQ,OAAO;GACf,KAAK,OAAO;GACZ,SAAS,OAAO;GAChB,SAAS,OAAO,QAAQ;GACxB,OAAO,MAAM;GACb,YAAY,MAAM;GAClB;EACF,CAAC;EACD,MAAM,YAAY,MAAM,OAAO,YAAY,EAAE,QAAQ,CAAC;EACtD,OAAO,KAAK,WAAW;GAAE;GAAS;EAAU,CAAC;CAC/C;;;;;;CAOA,MAAM,aACJ,QAC6B;EAC7B,OAAO,KAAK,SAAS,kBAAkB,EAAE,QAAQ,OAAO,OAAO,CAAC;CAClE;;;;;CAMA,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"}
@@ -39,6 +39,10 @@ interface OtcSiweMessageParams {
39
39
  /** The same sender as the nonce request. */
40
40
  sender: string;
41
41
  }
42
+ /** The login's page and chain. The sender is the wallet client's owner and this subaccount. */
43
+ type OtcLoginParams = Pick<OtcSiweMessageParams, 'domain' | 'uri' | 'chainId'> & {
44
+ subaccountName: string;
45
+ };
42
46
  interface OtcVerifyAuthParams {
43
47
  /** The SIWE text exactly as signed. */
44
48
  message: string;
@@ -72,5 +76,5 @@ interface OtcRfqSubscriptionParams {
72
76
  streams: OtcQuoteStream[];
73
77
  }
74
78
  //#endregion
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
79
+ export { OtcLoginParams as a, OtcRfqSubscriptionParams as c, OtcVerifyAuthParams as d, OtcGetReadyParams as i, OtcServerTakerOrderParams as l, OtcGetAuthNonceParams as n, OtcQuoteStream as o, OtcGetExecutionStatusParams as r, OtcReadyResult as s, OtcExecuteParams as t, OtcSiweMessageParams as u };
80
+ //# sourceMappingURL=clientTypes-Dn4FvgqX.d.ts.map
@@ -1 +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
+ {"version":3,"file":"clientTypes-Dn4FvgqX.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;;KAIU,cAAA,GAAiB,IAAI,CAC/B,oBAAA;EAGA,cAAA;AAAA;AAAA,UAGe,mBAAA;EAXf;EAaA,OAAA;EAbM;EAeN,SAAS;AAAA;;;;;UAOM,cAAA;EACf,UAAA;EACA,KAAK;AAAA;;;;AATI;UAgBM,cAAA;EACf,IAAA;EACA,SAAA;EACA,MAAA;EACA,IAAA;EACA,QAAA,EAAU,gBAAgB;EALG;EAO7B,QAAA;AAAA;;UAIe,wBAAA;EACf,EAAA;EACA,OAAA,EAAS,cAAc;AAAA"}
@@ -39,6 +39,10 @@ interface OtcSiweMessageParams {
39
39
  /** The same sender as the nonce request. */
40
40
  sender: string;
41
41
  }
42
+ /** The login's page and chain. The sender is the wallet client's owner and this subaccount. */
43
+ type OtcLoginParams = Pick<OtcSiweMessageParams, 'domain' | 'uri' | 'chainId'> & {
44
+ subaccountName: string;
45
+ };
42
46
  interface OtcVerifyAuthParams {
43
47
  /** The SIWE text exactly as signed. */
44
48
  message: string;
@@ -72,5 +76,5 @@ interface OtcRfqSubscriptionParams {
72
76
  streams: OtcQuoteStream[];
73
77
  }
74
78
  //#endregion
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
79
+ export { OtcLoginParams as a, OtcRfqSubscriptionParams as c, OtcVerifyAuthParams as d, OtcGetReadyParams as i, OtcServerTakerOrderParams as l, OtcGetAuthNonceParams as n, OtcQuoteStream as o, OtcGetExecutionStatusParams as r, OtcReadyResult as s, OtcExecuteParams as t, OtcSiweMessageParams as u };
80
+ //# sourceMappingURL=clientTypes-HHvq70F0.d.cts.map
@@ -1 +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"}
1
+ {"version":3,"file":"clientTypes-HHvq70F0.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;;KAIU,cAAA,GAAiB,IAAI,CAC/B,oBAAA;EAGA,cAAA;AAAA;AAAA,UAGe,mBAAA;EAXf;EAaA,OAAA;EAbM;EAeN,SAAS;AAAA;;;;;UAOM,cAAA;EACf,UAAA;EACA,KAAK;AAAA;;;;AATI;UAgBM,cAAA;EACf,IAAA;EACA,SAAA;EACA,MAAA;EACA,IAAA;EACA,QAAA,EAAU,gBAAgB;EALG;EAO7B,QAAA;AAAA;;UAIe,wBAAA;EACf,EAAA;EACA,OAAA,EAAS,cAAc;AAAA"}
package/dist/index.cjs CHANGED
@@ -1,8 +1,8 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_OtcClient = require("./OtcClient-BYspxGIn.cjs");
2
+ const require_OtcClient = require("./OtcClient-gkP2YE4s.cjs");
3
+ const require_siweMessage = require("./siweMessage.cjs");
3
4
  const require_endpoints = require("./endpoints.cjs");
4
5
  const require_rfqSubscription = require("./rfqSubscription.cjs");
5
- const require_siweMessage = require("./siweMessage.cjs");
6
6
  const require_types_otcErrorCodes = require("./types/otcErrorCodes.cjs");
7
7
  require("./types/index.cjs");
8
8
  exports.OTC_CLIENT_ENDPOINTS = require_endpoints.OTC_CLIENT_ENDPOINTS;
package/dist/index.d.cts CHANGED
@@ -1,8 +1,8 @@
1
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";
2
+ import { a as OtcLoginParams, c as OtcRfqSubscriptionParams, d as OtcVerifyAuthParams, i as OtcGetReadyParams, l as OtcServerTakerOrderParams, n as OtcGetAuthNonceParams, o as OtcQuoteStream, r as OtcGetExecutionStatusParams, s as OtcReadyResult, t as OtcExecuteParams, u as OtcSiweMessageParams } from "./clientTypes-HHvq70F0.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
6
  import { OTC_SIWE_STATEMENT, buildOtcSiweMessage } from "./siweMessage.cjs";
7
7
  import { n as OtcErrorCode, t as OTC_ERROR_CODES } from "./otcErrorCodes-CsmoGjD_.cjs";
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 };
8
+ export { OTC_CLIENT_ENDPOINTS, OTC_ERROR_CODES, OTC_RFQ_WS_CLIENT_ENDPOINTS, OTC_SIWE_STATEMENT, OtcClient, OtcClientOpts, OtcErrorCode, OtcExecuteParams, OtcGetAuthNonceParams, OtcGetExecutionStatusParams, OtcGetReadyParams, OtcLoginParams, 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,8 +1,8 @@
1
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";
2
+ import { a as OtcLoginParams, c as OtcRfqSubscriptionParams, d as OtcVerifyAuthParams, i as OtcGetReadyParams, l as OtcServerTakerOrderParams, n as OtcGetAuthNonceParams, o as OtcQuoteStream, r as OtcGetExecutionStatusParams, s as OtcReadyResult, t as OtcExecuteParams, u as OtcSiweMessageParams } from "./clientTypes-Dn4FvgqX.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
6
  import { OTC_SIWE_STATEMENT, buildOtcSiweMessage } from "./siweMessage.js";
7
7
  import { n as OtcErrorCode, t as OTC_ERROR_CODES } from "./otcErrorCodes-CsmoGjD_.js";
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 };
8
+ export { OTC_CLIENT_ENDPOINTS, OTC_ERROR_CODES, OTC_RFQ_WS_CLIENT_ENDPOINTS, OTC_SIWE_STATEMENT, OtcClient, OtcClientOpts, OtcErrorCode, OtcExecuteParams, OtcGetAuthNonceParams, OtcGetExecutionStatusParams, OtcGetReadyParams, OtcLoginParams, 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,7 +1,7 @@
1
+ import { OTC_SIWE_STATEMENT, buildOtcSiweMessage } from "./siweMessage.js";
1
2
  import { OtcClient } from "./OtcClient.js";
2
3
  import { OTC_CLIENT_ENDPOINTS, OTC_RFQ_WS_CLIENT_ENDPOINTS } from "./endpoints.js";
3
4
  import { buildOtcRfqSubscriptionMessage } from "./rfqSubscription.js";
4
- import { OTC_SIWE_STATEMENT, buildOtcSiweMessage } from "./siweMessage.js";
5
5
  import { OTC_ERROR_CODES } from "./types/otcErrorCodes.js";
6
6
  import "./types/index.js";
7
7
  export { OTC_CLIENT_ENDPOINTS, OTC_ERROR_CODES, OTC_RFQ_WS_CLIENT_ENDPOINTS, OTC_SIWE_STATEMENT, OtcClient, buildOtcRfqSubscriptionMessage, buildOtcSiweMessage };
@@ -1,5 +1,5 @@
1
1
  import { m as OtcServerRfqSubscriptionRequest } from "./serverTypes-CgQcIVf1.cjs";
2
- import { s as OtcRfqSubscriptionParams } from "./clientTypes-_bJZ6Psb.cjs";
2
+ import { c as OtcRfqSubscriptionParams } from "./clientTypes-HHvq70F0.cjs";
3
3
 
4
4
  //#region src/rfqSubscription.d.ts
5
5
  /**
@@ -1,5 +1,5 @@
1
1
  import { m as OtcServerRfqSubscriptionRequest } from "./serverTypes-CgQcIVf1.js";
2
- import { s as OtcRfqSubscriptionParams } from "./clientTypes-DadMpdOk.js";
2
+ import { c as OtcRfqSubscriptionParams } from "./clientTypes-Dn4FvgqX.js";
3
3
 
4
4
  //#region src/rfqSubscription.d.ts
5
5
  /**
@@ -1,4 +1,4 @@
1
- import { l as OtcSiweMessageParams } from "./clientTypes-_bJZ6Psb.cjs";
1
+ import { u as OtcSiweMessageParams } from "./clientTypes-HHvq70F0.cjs";
2
2
 
3
3
  //#region src/siweMessage.d.ts
4
4
  /**
@@ -1,4 +1,4 @@
1
- import { l as OtcSiweMessageParams } from "./clientTypes-DadMpdOk.js";
1
+ import { u as OtcSiweMessageParams } from "./clientTypes-Dn4FvgqX.js";
2
2
 
3
3
  //#region src/siweMessage.d.ts
4
4
  /**
@@ -1,2 +1,2 @@
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
+ import { a as OtcLoginParams, c as OtcRfqSubscriptionParams, d as OtcVerifyAuthParams, i as OtcGetReadyParams, l as OtcServerTakerOrderParams, n as OtcGetAuthNonceParams, o as OtcQuoteStream, r as OtcGetExecutionStatusParams, s as OtcReadyResult, t as OtcExecuteParams, u as OtcSiweMessageParams } from "../clientTypes-HHvq70F0.cjs";
2
+ export { OtcExecuteParams, OtcGetAuthNonceParams, OtcGetExecutionStatusParams, OtcGetReadyParams, OtcLoginParams, OtcQuoteStream, OtcReadyResult, OtcRfqSubscriptionParams, OtcServerTakerOrderParams, OtcSiweMessageParams, OtcVerifyAuthParams };
@@ -1,2 +1,2 @@
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
+ import { a as OtcLoginParams, c as OtcRfqSubscriptionParams, d as OtcVerifyAuthParams, i as OtcGetReadyParams, l as OtcServerTakerOrderParams, n as OtcGetAuthNonceParams, o as OtcQuoteStream, r as OtcGetExecutionStatusParams, s as OtcReadyResult, t as OtcExecuteParams, u as OtcSiweMessageParams } from "../clientTypes-Dn4FvgqX.js";
2
+ export { OtcExecuteParams, OtcGetAuthNonceParams, OtcGetExecutionStatusParams, OtcGetReadyParams, OtcLoginParams, OtcQuoteStream, OtcReadyResult, OtcRfqSubscriptionParams, OtcServerTakerOrderParams, OtcSiweMessageParams, OtcVerifyAuthParams };
@@ -1,4 +1,4 @@
1
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";
2
+ import { a as OtcLoginParams, c as OtcRfqSubscriptionParams, d as OtcVerifyAuthParams, i as OtcGetReadyParams, l as OtcServerTakerOrderParams, n as OtcGetAuthNonceParams, o as OtcQuoteStream, r as OtcGetExecutionStatusParams, s as OtcReadyResult, t as OtcExecuteParams, u as OtcSiweMessageParams } from "../clientTypes-HHvq70F0.cjs";
3
3
  import { n as OtcErrorCode, t as OTC_ERROR_CODES } from "../otcErrorCodes-CsmoGjD_.cjs";
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 };
4
+ export { OTC_ERROR_CODES, OtcErrorCode, OtcExecuteParams, OtcGetAuthNonceParams, OtcGetExecutionStatusParams, OtcGetReadyParams, OtcLoginParams, 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
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";
2
+ import { a as OtcLoginParams, c as OtcRfqSubscriptionParams, d as OtcVerifyAuthParams, i as OtcGetReadyParams, l as OtcServerTakerOrderParams, n as OtcGetAuthNonceParams, o as OtcQuoteStream, r as OtcGetExecutionStatusParams, s as OtcReadyResult, t as OtcExecuteParams, u as OtcSiweMessageParams } from "../clientTypes-Dn4FvgqX.js";
3
3
  import { n as OtcErrorCode, t as OTC_ERROR_CODES } from "../otcErrorCodes-CsmoGjD_.js";
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 };
4
+ export { OTC_ERROR_CODES, OtcErrorCode, OtcExecuteParams, OtcGetAuthNonceParams, OtcGetExecutionStatusParams, OtcGetReadyParams, OtcLoginParams, OtcQuoteSizeUnit, OtcQuoteStream, OtcReadyResult, OtcRfqSubscriptionParams, OtcServerAuthNonce, OtcServerAuthSession, OtcServerExecutionFailure, OtcServerExecutionPendingResolution, OtcServerExecutionResponse, OtcServerExecutionSuccess, OtcServerQuote, OtcServerQuoteBatch, OtcServerQuoteStream, OtcServerRfqAck, OtcServerRfqMessage, OtcServerRfqSubscribeStreamsRequest, OtcServerRfqSubscriptionRequest, OtcServerRfqUnsubscribeStreamsRequest, OtcServerTakerOrderParams, OtcSiweMessageParams, OtcVerifyAuthParams };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nadohq/otc-client",
3
- "version": "0.62.0",
3
+ "version": "0.64.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.62.0",
45
- "@nadohq/shared": "^0.62.0",
44
+ "@nadohq/engine-client": "^0.64.0",
45
+ "@nadohq/shared": "^0.64.0",
46
46
  "axios": "1.16.1"
47
47
  },
48
48
  "devDependencies": {
49
49
  "@jest/globals": "30.4.1"
50
50
  },
51
- "gitHead": "c0904f66ef691563e3fb32a76576f846f397f1fc"
51
+ "gitHead": "072fde1084b081b941ac471fe2e6c143cd0afffb"
52
52
  }
package/src/OtcClient.ts CHANGED
@@ -1,10 +1,17 @@
1
- import { getNadoClientTypeHeaders } from '@nadohq/shared';
1
+ import {
2
+ getNadoClientTypeHeaders,
3
+ subaccountToHex,
4
+ WalletClientWithAccount,
5
+ WalletNotProvidedError,
6
+ } from '@nadohq/shared';
2
7
  import axios, { AxiosInstance, AxiosResponse } from 'axios';
8
+ import { buildOtcSiweMessage } from './siweMessage';
3
9
  import {
4
10
  OtcExecuteParams,
5
11
  OtcGetAuthNonceParams,
6
12
  OtcGetExecutionStatusParams,
7
13
  OtcGetReadyParams,
14
+ OtcLoginParams,
8
15
  OtcReadyResult,
9
16
  OtcVerifyAuthParams,
10
17
  } from './types/clientTypes';
@@ -19,6 +26,10 @@ export interface OtcClientOpts {
19
26
  * OTC service origin, without a path, e.g. {@link OTC_CLIENT_ENDPOINTS}.
20
27
  */
21
28
  url: string;
29
+ // Wallet client for the private quote login signature
30
+ walletClient?: WalletClientWithAccount;
31
+ // Linked signer registered through the engine, if provided, the login uses this signer
32
+ linkedSignerWalletClient?: WalletClientWithAccount;
22
33
  // If provided, identifies the calling client, sent as a header with every request
23
34
  clientType?: string;
24
35
  }
@@ -26,8 +37,9 @@ export interface OtcClientOpts {
26
37
  /**
27
38
  * Client for the public OTC service.
28
39
  *
29
- * {@link OtcClient.execute} does not sign. The caller supplies an already-signed taker order.
30
- * A quote is not required. {@link OtcClient.getExecutionStatus} only reads a deal; it does not
40
+ * {@link OtcClient.login} signs the private quote login with the linked signer, or the wallet
41
+ * when there is none. {@link OtcClient.execute} does not sign. The caller supplies an
42
+ * already-signed taker order. A quote is not required. {@link OtcClient.getExecutionStatus} only reads a deal; it does not
31
43
  * start or resume one.
32
44
  *
33
45
  * Responses are the JSON body as returned, including non-200 admission responses. Branch on
@@ -47,8 +59,50 @@ export class OtcClient {
47
59
  }
48
60
 
49
61
  /**
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.
62
+ * Sets the linked signer for the private quote login
63
+ *
64
+ * @param linkedSignerWalletClient The linkedSigner to use for all signatures. Set to null to revert to the chain signer
65
+ */
66
+ public setLinkedSigner(
67
+ linkedSignerWalletClient: WalletClientWithAccount | null,
68
+ ) {
69
+ this.opts.linkedSignerWalletClient = linkedSignerWalletClient ?? undefined;
70
+ }
71
+
72
+ /**
73
+ * Logs the wallet's subaccount in for private quotes: fetches a nonce, signs the SIWE text
74
+ * with the linked signer (or the wallet) and verifies it. On success the browser holds the
75
+ * session cookie; open a new quote socket afterwards, since a socket keeps the session it
76
+ * had at its handshake. Throws on a non-200; the message carries the service's `error` code.
77
+ */
78
+ async login(params: OtcLoginParams): Promise<OtcServerAuthSession> {
79
+ const { walletClient, linkedSignerWalletClient } = this.opts;
80
+ if (!walletClient) {
81
+ throw new WalletNotProvidedError();
82
+ }
83
+ const sender = subaccountToHex({
84
+ subaccountOwner: walletClient.account.address,
85
+ subaccountName: params.subaccountName,
86
+ });
87
+ const signer = linkedSignerWalletClient ?? walletClient;
88
+ const nonce = await this.getAuthNonce({ sender });
89
+ const message = buildOtcSiweMessage({
90
+ domain: params.domain,
91
+ uri: params.uri,
92
+ chainId: params.chainId,
93
+ address: signer.account.address,
94
+ nonce: nonce.nonce,
95
+ issuedAtMs: nonce.issued_at_ms,
96
+ sender,
97
+ });
98
+ const signature = await signer.signMessage({ message });
99
+ return this.verifyAuth({ message, signature });
100
+ }
101
+
102
+ /**
103
+ * First step of {@link OtcClient.login}, for signing outside the client. Build the message
104
+ * with `buildOtcSiweMessage`, sign it, and pass it to {@link OtcClient.verifyAuth} within
105
+ * 60s. Throws on a non-200.
52
106
  */
53
107
  async getAuthNonce(
54
108
  params: OtcGetAuthNonceParams,
@@ -57,9 +111,8 @@ export class OtcClient {
57
111
  }
58
112
 
59
113
  /**
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.
114
+ * Last step of {@link OtcClient.login}, for signing outside the client. Throws on a non-200;
115
+ * the message carries the service's `error` code.
63
116
  */
64
117
  async verifyAuth(params: OtcVerifyAuthParams): Promise<OtcServerAuthSession> {
65
118
  return this.postAuth('/v1/auth/verify', {
@@ -47,6 +47,14 @@ export interface OtcSiweMessageParams {
47
47
  sender: string;
48
48
  }
49
49
 
50
+ /** The login's page and chain. The sender is the wallet client's owner and this subaccount. */
51
+ export type OtcLoginParams = Pick<
52
+ OtcSiweMessageParams,
53
+ 'domain' | 'uri' | 'chainId'
54
+ > & {
55
+ subaccountName: string;
56
+ };
57
+
50
58
  export interface OtcVerifyAuthParams {
51
59
  /** The SIWE text exactly as signed. */
52
60
  message: string;
@@ -1 +0,0 @@
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"}