@aptos-labs/aptos-client 0.1.1 → 1.0.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/LICENSE CHANGED
@@ -2,180 +2,180 @@
2
2
  Version 2.0, January 2004
3
3
  http://www.apache.org/licenses/
4
4
 
5
- TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
-
7
- 1. Definitions.
8
-
9
- "License" shall mean the terms and conditions for use, reproduction,
10
- and distribution as defined by Sections 1 through 9 of this document.
11
-
12
- "Licensor" shall mean the copyright owner or entity authorized by
13
- the copyright owner that is granting the License.
14
-
15
- "Legal Entity" shall mean the union of the acting entity and all
16
- other entities that control, are controlled by, or are under common
17
- control with that entity. For the purposes of this definition,
18
- "control" means (i) the power, direct or indirect, to cause the
19
- direction or management of such entity, whether by contract or
20
- otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
- outstanding shares, or (iii) beneficial ownership of such entity.
22
-
23
- "You" (or "Your") shall mean an individual or Legal Entity
24
- exercising permissions granted by this License.
25
-
26
- "Source" form shall mean the preferred form for making modifications,
27
- including but not limited to software source code, documentation
28
- source, and configuration files.
29
-
30
- "Object" form shall mean any form resulting from mechanical
31
- transformation or translation of a Source form, including but
32
- not limited to compiled object code, generated documentation,
33
- and conversions to other media types.
34
-
35
- "Work" shall mean the work of authorship, whether in Source or
36
- Object form, made available under the License, as indicated by a
37
- copyright notice that is included in or attached to the work
38
- (an example is provided in the Appendix below).
39
-
40
- "Derivative Works" shall mean any work, whether in Source or Object
41
- form, that is based on (or derived from) the Work and for which the
42
- editorial revisions, annotations, elaborations, or other modifications
43
- represent, as a whole, an original work of authorship. For the purposes
44
- of this License, Derivative Works shall not include works that remain
45
- separable from, or merely link (or bind by name) to the interfaces of,
46
- the Work and Derivative Works thereof.
47
-
48
- "Contribution" shall mean any work of authorship, including
49
- the original version of the Work and any modifications or additions
50
- to that Work or Derivative Works thereof, that is intentionally
51
- submitted to Licensor for inclusion in the Work by the copyright owner
52
- or by an individual or Legal Entity authorized to submit on behalf of
53
- the copyright owner. For the purposes of this definition, "submitted"
54
- means any form of electronic, verbal, or written communication sent
55
- to the Licensor or its representatives, including but not limited to
56
- communication on electronic mailing lists, source code control systems,
57
- and issue tracking systems that are managed by, or on behalf of, the
58
- Licensor for the purpose of discussing and improving the Work, but
59
- excluding communication that is conspicuously marked or otherwise
60
- designated in writing by the copyright owner as "Not a Contribution."
61
-
62
- "Contributor" shall mean Licensor and any individual or Legal Entity
63
- on behalf of whom a Contribution has been received by Licensor and
64
- subsequently incorporated within the Work.
65
-
66
- 2. Grant of Copyright License. Subject to the terms and conditions of
67
- this License, each Contributor hereby grants to You a perpetual,
68
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
- copyright license to reproduce, prepare Derivative Works of,
70
- publicly display, publicly perform, sublicense, and distribute the
71
- Work and such Derivative Works in Source or Object form.
72
-
73
- 3. Grant of Patent License. Subject to the terms and conditions of
74
- this License, each Contributor hereby grants to You a perpetual,
75
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
- (except as stated in this section) patent license to make, have made,
77
- use, offer to sell, sell, import, and otherwise transfer the Work,
78
- where such license applies only to those patent claims licensable
79
- by such Contributor that are necessarily infringed by their
80
- Contribution(s) alone or by combination of their Contribution(s)
81
- with the Work to which such Contribution(s) was submitted. If You
82
- institute patent litigation against any entity (including a
83
- cross-claim or counterclaim in a lawsuit) alleging that the Work
84
- or a Contribution incorporated within the Work constitutes direct
85
- or contributory patent infringement, then any patent licenses
86
- granted to You under this License for that Work shall terminate
87
- as of the date such litigation is filed.
88
-
89
- 4. Redistribution. You may reproduce and distribute copies of the
90
- Work or Derivative Works thereof in any medium, with or without
91
- modifications, and in Source or Object form, provided that You
92
- meet the following conditions:
93
-
94
- (a) You must give any other recipients of the Work or
95
- Derivative Works a copy of this License; and
96
-
97
- (b) You must cause any modified files to carry prominent notices
98
- stating that You changed the files; and
99
-
100
- (c) You must retain, in the Source form of any Derivative Works
101
- that You distribute, all copyright, patent, trademark, and
102
- attribution notices from the Source form of the Work,
103
- excluding those notices that do not pertain to any part of
104
- the Derivative Works; and
105
-
106
- (d) If the Work includes a "NOTICE" text file as part of its
107
- distribution, then any Derivative Works that You distribute must
108
- include a readable copy of the attribution notices contained
109
- within such NOTICE file, excluding those notices that do not
110
- pertain to any part of the Derivative Works, in at least one
111
- of the following places: within a NOTICE text file distributed
112
- as part of the Derivative Works; within the Source form or
113
- documentation, if provided along with the Derivative Works; or,
114
- within a display generated by the Derivative Works, if and
115
- wherever such third-party notices normally appear. The contents
116
- of the NOTICE file are for informational purposes only and
117
- do not modify the License. You may add Your own attribution
118
- notices within Derivative Works that You distribute, alongside
119
- or as an addendum to the NOTICE text from the Work, provided
120
- that such additional attribution notices cannot be construed
121
- as modifying the License.
122
-
123
- You may add Your own copyright statement to Your modifications and
124
- may provide additional or different license terms and conditions
125
- for use, reproduction, or distribution of Your modifications, or
126
- for any such Derivative Works as a whole, provided Your use,
127
- reproduction, and distribution of the Work otherwise complies with
128
- the conditions stated in this License.
129
-
130
- 5. Submission of Contributions. Unless You explicitly state otherwise,
131
- any Contribution intentionally submitted for inclusion in the Work
132
- by You to the Licensor shall be under the terms and conditions of
133
- this License, without any additional terms or conditions.
134
- Notwithstanding the above, nothing herein shall supersede or modify
135
- the terms of any separate license agreement you may have executed
136
- with Licensor regarding such Contributions.
137
-
138
- 6. Trademarks. This License does not grant permission to use the trade
139
- names, trademarks, service marks, or product names of the Licensor,
140
- except as required for reasonable and customary use in describing the
141
- origin of the Work and reproducing the content of the NOTICE file.
142
-
143
- 7. Disclaimer of Warranty. Unless required by applicable law or
144
- agreed to in writing, Licensor provides the Work (and each
145
- Contributor provides its Contributions) on an "AS IS" BASIS,
146
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
- implied, including, without limitation, any warranties or conditions
148
- of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
- PARTICULAR PURPOSE. You are solely responsible for determining the
150
- appropriateness of using or redistributing the Work and assume any
151
- risks associated with Your exercise of permissions under this License.
152
-
153
- 8. Limitation of Liability. In no event and under no legal theory,
154
- whether in tort (including negligence), contract, or otherwise,
155
- unless required by applicable law (such as deliberate and grossly
156
- negligent acts) or agreed to in writing, shall any Contributor be
157
- liable to You for damages, including any direct, indirect, special,
158
- incidental, or consequential damages of any character arising as a
159
- result of this License or out of the use or inability to use the
160
- Work (including but not limited to damages for loss of goodwill,
161
- work stoppage, computer failure or malfunction, or any and all
162
- other commercial damages or losses), even if such Contributor
163
- has been advised of the possibility of such damages.
164
-
165
- 9. Accepting Warranty or Additional Liability. While redistributing
166
- the Work or Derivative Works thereof, You may choose to offer,
167
- and charge a fee for, acceptance of support, warranty, indemnity,
168
- or other liability obligations and/or rights consistent with this
169
- License. However, in accepting such obligations, You may act only
170
- on Your own behalf and on Your sole responsibility, not on behalf
171
- of any other Contributor, and only if You agree to indemnify,
172
- defend, and hold each Contributor harmless for any liability
173
- incurred by, or claims asserted against, such Contributor by reason
174
- of your accepting any such warranty or additional liability.
175
-
176
- END OF TERMS AND CONDITIONS
177
-
178
- APPENDIX: How to apply the Apache License to your work.
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
179
 
180
180
  To apply the Apache License to your work, attach the following
181
181
  boilerplate notice, with the fields enclosed by brackets "[]"
@@ -186,16 +186,16 @@ APPENDIX: How to apply the Apache License to your work.
186
186
  same "printed page" as the copyright notice for easier
187
187
  identification within third-party archives.
188
188
 
189
- Copyright [yyyy] [name of copyright owner]
189
+ Copyright [yyyy] [name of copyright owner]
190
190
 
191
- Licensed under the Apache License, Version 2.0 (the "License");
192
- you may not use this file except in compliance with the License.
193
- You may obtain a copy of the License at
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
194
 
195
195
  http://www.apache.org/licenses/LICENSE-2.0
196
196
 
197
- Unless required by applicable law or agreed to in writing, software
198
- distributed under the License is distributed on an "AS IS" BASIS,
199
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
- See the License for the specific language governing permissions and
201
- limitations under the License.
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
package/README.md CHANGED
@@ -12,7 +12,9 @@ The `@aptos-labs/aptos-client` package supports http2 protocol and implements 2
12
12
  #### Function signature
13
13
 
14
14
  ```ts
15
- async function aptosClient<Res>(requestOptions: AptosClientRequest): Promise<AptosClientResponse<Res>>;
15
+ async function aptosClient<Res>(
16
+ requestOptions: AptosClientRequest,
17
+ ): Promise<AptosClientResponse<Res>>;
16
18
  ```
17
19
 
18
20
  #### Types
@@ -43,6 +45,13 @@ type AptosClientRequest = {
43
45
  ```ts
44
46
  import aptosClient from "@aptos-labs/aptos-client";
45
47
 
46
- const response = await aptosClient<Res>({ url, method, body, params, headers, overrides });
48
+ const response = await aptosClient<Res>({
49
+ url,
50
+ method,
51
+ body,
52
+ params,
53
+ headers,
54
+ overrides,
55
+ });
47
56
  return response;
48
57
  ```
@@ -16,6 +16,19 @@ type AptosClientRequest = {
16
16
  overrides?: any;
17
17
  };
18
18
 
19
+ /**
20
+ * Used for JSON responses
21
+ *
22
+ * @param options
23
+ */
19
24
  declare function aptosClient<Res>(options: AptosClientRequest): Promise<AptosClientResponse<Res>>;
25
+ declare function jsonRequest<Res>(options: AptosClientRequest): Promise<AptosClientResponse<Res>>;
26
+ /**
27
+ * Used for binary responses, such as BCS outputs
28
+ *
29
+ * @experimental
30
+ * @param options
31
+ */
32
+ declare function bcsRequest(options: AptosClientRequest): Promise<AptosClientResponse<Buffer>>;
20
33
 
21
- export { aptosClient as default };
34
+ export { bcsRequest, aptosClient as default, jsonRequest };
@@ -16,6 +16,19 @@ type AptosClientRequest = {
16
16
  overrides?: any;
17
17
  };
18
18
 
19
+ /**
20
+ * Used for JSON responses
21
+ *
22
+ * @param options
23
+ */
19
24
  declare function aptosClient<Res>(options: AptosClientRequest): Promise<AptosClientResponse<Res>>;
25
+ declare function jsonRequest<Res>(options: AptosClientRequest): Promise<AptosClientResponse<Res>>;
26
+ /**
27
+ * Used for binary responses, such as BCS outputs
28
+ *
29
+ * @experimental
30
+ * @param options
31
+ */
32
+ declare function bcsRequest(options: AptosClientRequest): Promise<AptosClientResponse<Buffer>>;
20
33
 
21
- export { aptosClient as default };
34
+ export { bcsRequest, aptosClient as default, jsonRequest };
@@ -30,11 +30,16 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
30
30
  // src/index.browser.ts
31
31
  var index_browser_exports = {};
32
32
  __export(index_browser_exports, {
33
- default: () => aptosClient
33
+ bcsRequest: () => bcsRequest,
34
+ default: () => aptosClient,
35
+ jsonRequest: () => jsonRequest
34
36
  });
35
37
  module.exports = __toCommonJS(index_browser_exports);
36
38
  var import_axios = __toESM(require("axios"));
37
39
  async function aptosClient(options) {
40
+ return jsonRequest(options);
41
+ }
42
+ async function jsonRequest(options) {
38
43
  var _a;
39
44
  const { params, method, url, headers, body, overrides } = options;
40
45
  const requestConfig = {
@@ -62,4 +67,37 @@ async function aptosClient(options) {
62
67
  throw error;
63
68
  }
64
69
  }
70
+ async function bcsRequest(options) {
71
+ var _a;
72
+ const { params, method, url, headers, body, overrides } = options;
73
+ const requestConfig = {
74
+ headers,
75
+ method,
76
+ url,
77
+ params,
78
+ data: body,
79
+ withCredentials: (_a = overrides == null ? void 0 : overrides.WITH_CREDENTIALS) != null ? _a : true
80
+ };
81
+ try {
82
+ const response = await (0, import_axios.default)(requestConfig);
83
+ return {
84
+ status: response.status,
85
+ statusText: response.statusText,
86
+ data: response.data,
87
+ headers: response.headers,
88
+ config: response.config
89
+ };
90
+ } catch (error) {
91
+ const axiosError = error;
92
+ if (axiosError.response) {
93
+ return axiosError.response;
94
+ }
95
+ throw error;
96
+ }
97
+ }
98
+ // Annotate the CommonJS export names for ESM import in node:
99
+ 0 && (module.exports = {
100
+ bcsRequest,
101
+ jsonRequest
102
+ });
65
103
  //# sourceMappingURL=index.browser.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/index.browser.ts"],"sourcesContent":["import axios, { AxiosRequestConfig, AxiosError } from \"axios\";\nimport { AptosClientRequest, AptosClientResponse } from \"./types\";\n\nexport default async function aptosClient<Res>(options: AptosClientRequest): Promise<AptosClientResponse<Res>> {\n const { params, method, url, headers, body, overrides } = options;\n const requestConfig: AxiosRequestConfig = {\n headers,\n method,\n url,\n params,\n data: body,\n withCredentials: overrides?.WITH_CREDENTIALS ?? true,\n };\n\n try {\n const response = await axios(requestConfig);\n return {\n status: response.status,\n statusText: response.statusText!,\n data: response.data,\n headers: response.headers,\n config: response.config,\n };\n } catch (error) {\n const axiosError = error as AxiosError<Res>;\n if (axiosError.response) {\n return axiosError.response;\n }\n throw error;\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAAsD;AAGtD,eAAO,YAAwC,SAAgE;AAH/G;AAIE,QAAM,EAAE,QAAQ,QAAQ,KAAK,SAAS,MAAM,UAAU,IAAI;AAC1D,QAAM,gBAAoC;AAAA,IACxC;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,MAAM;AAAA,IACN,kBAAiB,4CAAW,qBAAX,YAA+B;AAAA,EAClD;AAEA,MAAI;AACF,UAAM,WAAW,UAAM,aAAAA,SAAM,aAAa;AAC1C,WAAO;AAAA,MACL,QAAQ,SAAS;AAAA,MACjB,YAAY,SAAS;AAAA,MACrB,MAAM,SAAS;AAAA,MACf,SAAS,SAAS;AAAA,MAClB,QAAQ,SAAS;AAAA,IACnB;AAAA,EACF,SAAS,OAAO;AACd,UAAM,aAAa;AACnB,QAAI,WAAW,UAAU;AACvB,aAAO,WAAW;AAAA,IACpB;AACA,UAAM;AAAA,EACR;AACF;","names":["axios"]}
1
+ {"version":3,"sources":["../../src/index.browser.ts"],"sourcesContent":["import axios, { AxiosRequestConfig, AxiosError } from \"axios\";\nimport { AptosClientRequest, AptosClientResponse } from \"./types\";\n\n/**\n * Used for JSON responses\n *\n * @param options\n */\nexport default async function aptosClient<Res>(\n options: AptosClientRequest,\n): Promise<AptosClientResponse<Res>> {\n return jsonRequest<Res>(options);\n}\n\nexport async function jsonRequest<Res>(\n options: AptosClientRequest,\n): Promise<AptosClientResponse<Res>> {\n const { params, method, url, headers, body, overrides } = options;\n const requestConfig: AxiosRequestConfig = {\n headers,\n method,\n url,\n params,\n data: body,\n withCredentials: overrides?.WITH_CREDENTIALS ?? true,\n };\n\n try {\n const response = await axios(requestConfig);\n return {\n status: response.status,\n statusText: response.statusText!,\n data: response.data,\n headers: response.headers,\n config: response.config,\n };\n } catch (error) {\n const axiosError = error as AxiosError<Res>;\n if (axiosError.response) {\n return axiosError.response;\n }\n throw error;\n }\n}\n\n\n/**\n * Used for binary responses, such as BCS outputs\n *\n * @experimental\n * @param options\n */\nexport async function bcsRequest(\n options: AptosClientRequest,\n): Promise<AptosClientResponse<Buffer>> {\n const { params, method, url, headers, body, overrides } = options;\n const requestConfig: AxiosRequestConfig = {\n headers,\n method,\n url,\n params,\n data: body,\n withCredentials: overrides?.WITH_CREDENTIALS ?? true,\n };\n\n try {\n const response = await axios(requestConfig);\n return {\n status: response.status,\n statusText: response.statusText!,\n data: response.data,\n headers: response.headers,\n config: response.config,\n };\n } catch (error) {\n const axiosError = error as AxiosError<Buffer>;\n if (axiosError.response) {\n return axiosError.response;\n }\n throw error;\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAAsD;AAQtD,eAAO,YACL,SACmC;AACnC,SAAO,YAAiB,OAAO;AACjC;AAEA,eAAsB,YAClB,SACiC;AAhBrC;AAiBE,QAAM,EAAE,QAAQ,QAAQ,KAAK,SAAS,MAAM,UAAU,IAAI;AAC1D,QAAM,gBAAoC;AAAA,IACxC;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,MAAM;AAAA,IACN,kBAAiB,4CAAW,qBAAX,YAA+B;AAAA,EAClD;AAEA,MAAI;AACF,UAAM,WAAW,UAAM,aAAAA,SAAM,aAAa;AAC1C,WAAO;AAAA,MACL,QAAQ,SAAS;AAAA,MACjB,YAAY,SAAS;AAAA,MACrB,MAAM,SAAS;AAAA,MACf,SAAS,SAAS;AAAA,MAClB,QAAQ,SAAS;AAAA,IACnB;AAAA,EACF,SAAS,OAAO;AACd,UAAM,aAAa;AACnB,QAAI,WAAW,UAAU;AACvB,aAAO,WAAW;AAAA,IACpB;AACA,UAAM;AAAA,EACR;AACF;AASA,eAAsB,WACpB,SACsC;AAtDxC;AAuDE,QAAM,EAAE,QAAQ,QAAQ,KAAK,SAAS,MAAM,UAAU,IAAI;AAC1D,QAAM,gBAAoC;AAAA,IACxC;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,MAAM;AAAA,IACN,kBAAiB,4CAAW,qBAAX,YAA+B;AAAA,EAClD;AAEA,MAAI;AACF,UAAM,WAAW,UAAM,aAAAA,SAAM,aAAa;AAC1C,WAAO;AAAA,MACL,QAAQ,SAAS;AAAA,MACjB,YAAY,SAAS;AAAA,MACrB,MAAM,SAAS;AAAA,MACf,SAAS,SAAS;AAAA,MAClB,QAAQ,SAAS;AAAA,IACnB;AAAA,EACF,SAAS,OAAO;AACd,UAAM,aAAa;AACnB,QAAI,WAAW,UAAU;AACvB,aAAO,WAAW;AAAA,IACpB;AACA,UAAM;AAAA,EACR;AACF;","names":["axios"]}
@@ -1,6 +1,37 @@
1
1
  // src/index.browser.ts
2
2
  import axios from "axios";
3
3
  async function aptosClient(options) {
4
+ return jsonRequest(options);
5
+ }
6
+ async function jsonRequest(options) {
7
+ var _a;
8
+ const { params, method, url, headers, body, overrides } = options;
9
+ const requestConfig = {
10
+ headers,
11
+ method,
12
+ url,
13
+ params,
14
+ data: body,
15
+ withCredentials: (_a = overrides == null ? void 0 : overrides.WITH_CREDENTIALS) != null ? _a : true
16
+ };
17
+ try {
18
+ const response = await axios(requestConfig);
19
+ return {
20
+ status: response.status,
21
+ statusText: response.statusText,
22
+ data: response.data,
23
+ headers: response.headers,
24
+ config: response.config
25
+ };
26
+ } catch (error) {
27
+ const axiosError = error;
28
+ if (axiosError.response) {
29
+ return axiosError.response;
30
+ }
31
+ throw error;
32
+ }
33
+ }
34
+ async function bcsRequest(options) {
4
35
  var _a;
5
36
  const { params, method, url, headers, body, overrides } = options;
6
37
  const requestConfig = {
@@ -29,6 +60,8 @@ async function aptosClient(options) {
29
60
  }
30
61
  }
31
62
  export {
32
- aptosClient as default
63
+ bcsRequest,
64
+ aptosClient as default,
65
+ jsonRequest
33
66
  };
34
67
  //# sourceMappingURL=index.browser.mjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/index.browser.ts"],"sourcesContent":["import axios, { AxiosRequestConfig, AxiosError } from \"axios\";\nimport { AptosClientRequest, AptosClientResponse } from \"./types\";\n\nexport default async function aptosClient<Res>(options: AptosClientRequest): Promise<AptosClientResponse<Res>> {\n const { params, method, url, headers, body, overrides } = options;\n const requestConfig: AxiosRequestConfig = {\n headers,\n method,\n url,\n params,\n data: body,\n withCredentials: overrides?.WITH_CREDENTIALS ?? true,\n };\n\n try {\n const response = await axios(requestConfig);\n return {\n status: response.status,\n statusText: response.statusText!,\n data: response.data,\n headers: response.headers,\n config: response.config,\n };\n } catch (error) {\n const axiosError = error as AxiosError<Res>;\n if (axiosError.response) {\n return axiosError.response;\n }\n throw error;\n }\n}\n"],"mappings":";AAAA,OAAO,WAA+C;AAGtD,eAAO,YAAwC,SAAgE;AAH/G;AAIE,QAAM,EAAE,QAAQ,QAAQ,KAAK,SAAS,MAAM,UAAU,IAAI;AAC1D,QAAM,gBAAoC;AAAA,IACxC;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,MAAM;AAAA,IACN,kBAAiB,4CAAW,qBAAX,YAA+B;AAAA,EAClD;AAEA,MAAI;AACF,UAAM,WAAW,MAAM,MAAM,aAAa;AAC1C,WAAO;AAAA,MACL,QAAQ,SAAS;AAAA,MACjB,YAAY,SAAS;AAAA,MACrB,MAAM,SAAS;AAAA,MACf,SAAS,SAAS;AAAA,MAClB,QAAQ,SAAS;AAAA,IACnB;AAAA,EACF,SAAS,OAAO;AACd,UAAM,aAAa;AACnB,QAAI,WAAW,UAAU;AACvB,aAAO,WAAW;AAAA,IACpB;AACA,UAAM;AAAA,EACR;AACF;","names":[]}
1
+ {"version":3,"sources":["../../src/index.browser.ts"],"sourcesContent":["import axios, { AxiosRequestConfig, AxiosError } from \"axios\";\nimport { AptosClientRequest, AptosClientResponse } from \"./types\";\n\n/**\n * Used for JSON responses\n *\n * @param options\n */\nexport default async function aptosClient<Res>(\n options: AptosClientRequest,\n): Promise<AptosClientResponse<Res>> {\n return jsonRequest<Res>(options);\n}\n\nexport async function jsonRequest<Res>(\n options: AptosClientRequest,\n): Promise<AptosClientResponse<Res>> {\n const { params, method, url, headers, body, overrides } = options;\n const requestConfig: AxiosRequestConfig = {\n headers,\n method,\n url,\n params,\n data: body,\n withCredentials: overrides?.WITH_CREDENTIALS ?? true,\n };\n\n try {\n const response = await axios(requestConfig);\n return {\n status: response.status,\n statusText: response.statusText!,\n data: response.data,\n headers: response.headers,\n config: response.config,\n };\n } catch (error) {\n const axiosError = error as AxiosError<Res>;\n if (axiosError.response) {\n return axiosError.response;\n }\n throw error;\n }\n}\n\n\n/**\n * Used for binary responses, such as BCS outputs\n *\n * @experimental\n * @param options\n */\nexport async function bcsRequest(\n options: AptosClientRequest,\n): Promise<AptosClientResponse<Buffer>> {\n const { params, method, url, headers, body, overrides } = options;\n const requestConfig: AxiosRequestConfig = {\n headers,\n method,\n url,\n params,\n data: body,\n withCredentials: overrides?.WITH_CREDENTIALS ?? true,\n };\n\n try {\n const response = await axios(requestConfig);\n return {\n status: response.status,\n statusText: response.statusText!,\n data: response.data,\n headers: response.headers,\n config: response.config,\n };\n } catch (error) {\n const axiosError = error as AxiosError<Buffer>;\n if (axiosError.response) {\n return axiosError.response;\n }\n throw error;\n }\n}\n"],"mappings":";AAAA,OAAO,WAA+C;AAQtD,eAAO,YACL,SACmC;AACnC,SAAO,YAAiB,OAAO;AACjC;AAEA,eAAsB,YAClB,SACiC;AAhBrC;AAiBE,QAAM,EAAE,QAAQ,QAAQ,KAAK,SAAS,MAAM,UAAU,IAAI;AAC1D,QAAM,gBAAoC;AAAA,IACxC;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,MAAM;AAAA,IACN,kBAAiB,4CAAW,qBAAX,YAA+B;AAAA,EAClD;AAEA,MAAI;AACF,UAAM,WAAW,MAAM,MAAM,aAAa;AAC1C,WAAO;AAAA,MACL,QAAQ,SAAS;AAAA,MACjB,YAAY,SAAS;AAAA,MACrB,MAAM,SAAS;AAAA,MACf,SAAS,SAAS;AAAA,MAClB,QAAQ,SAAS;AAAA,IACnB;AAAA,EACF,SAAS,OAAO;AACd,UAAM,aAAa;AACnB,QAAI,WAAW,UAAU;AACvB,aAAO,WAAW;AAAA,IACpB;AACA,UAAM;AAAA,EACR;AACF;AASA,eAAsB,WACpB,SACsC;AAtDxC;AAuDE,QAAM,EAAE,QAAQ,QAAQ,KAAK,SAAS,MAAM,UAAU,IAAI;AAC1D,QAAM,gBAAoC;AAAA,IACxC;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,MAAM;AAAA,IACN,kBAAiB,4CAAW,qBAAX,YAA+B;AAAA,EAClD;AAEA,MAAI;AACF,UAAM,WAAW,MAAM,MAAM,aAAa;AAC1C,WAAO;AAAA,MACL,QAAQ,SAAS;AAAA,MACjB,YAAY,SAAS;AAAA,MACrB,MAAM,SAAS;AAAA,MACf,SAAS,SAAS;AAAA,MAClB,QAAQ,SAAS;AAAA,IACnB;AAAA,EACF,SAAS,OAAO;AACd,UAAM,aAAa;AACnB,QAAI,WAAW,UAAU;AACvB,aAAO,WAAW;AAAA,IACpB;AACA,UAAM;AAAA,EACR;AACF;","names":[]}
@@ -16,6 +16,18 @@ type AptosClientRequest = {
16
16
  overrides?: any;
17
17
  };
18
18
 
19
+ /**
20
+ * Used for JSON responses
21
+ * @param requestOptions
22
+ */
19
23
  declare function aptosClient<Res>(requestOptions: AptosClientRequest): Promise<AptosClientResponse<Res>>;
24
+ declare function jsonRequest<Res>(requestOptions: AptosClientRequest): Promise<AptosClientResponse<Res>>;
25
+ /**
26
+ * Used for binary responses, such as BCS outputs
27
+ *
28
+ * @experimental
29
+ * @param requestOptions
30
+ */
31
+ declare function bcsRequest(requestOptions: AptosClientRequest): Promise<AptosClientResponse<Buffer>>;
20
32
 
21
- export { aptosClient as default };
33
+ export { bcsRequest, aptosClient as default, jsonRequest };
@@ -16,6 +16,18 @@ type AptosClientRequest = {
16
16
  overrides?: any;
17
17
  };
18
18
 
19
+ /**
20
+ * Used for JSON responses
21
+ * @param requestOptions
22
+ */
19
23
  declare function aptosClient<Res>(requestOptions: AptosClientRequest): Promise<AptosClientResponse<Res>>;
24
+ declare function jsonRequest<Res>(requestOptions: AptosClientRequest): Promise<AptosClientResponse<Res>>;
25
+ /**
26
+ * Used for binary responses, such as BCS outputs
27
+ *
28
+ * @experimental
29
+ * @param requestOptions
30
+ */
31
+ declare function bcsRequest(requestOptions: AptosClientRequest): Promise<AptosClientResponse<Buffer>>;
20
32
 
21
- export { aptosClient as default };
33
+ export { bcsRequest, aptosClient as default, jsonRequest };
@@ -30,7 +30,9 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
30
30
  // src/index.node.ts
31
31
  var index_node_exports = {};
32
32
  __export(index_node_exports, {
33
- default: () => aptosClient
33
+ bcsRequest: () => bcsRequest,
34
+ default: () => aptosClient,
35
+ jsonRequest: () => jsonRequest
34
36
  });
35
37
  module.exports = __toCommonJS(index_node_exports);
36
38
  var import_got = __toESM(require("got"));
@@ -47,7 +49,10 @@ var CookieJar = class _CookieJar {
47
49
  this.jar.set(key, []);
48
50
  }
49
51
  const cookie = _CookieJar.parse(cookieStr);
50
- this.jar.set(key, [...((_a = this.jar.get(key)) == null ? void 0 : _a.filter((c) => c.name !== cookie.name)) || [], cookie]);
52
+ this.jar.set(key, [
53
+ ...((_a = this.jar.get(key)) == null ? void 0 : _a.filter((c) => c.name !== cookie.name)) || [],
54
+ cookie
55
+ ]);
51
56
  }
52
57
  getCookies(url) {
53
58
  var _a;
@@ -81,7 +86,10 @@ var CookieJar = class _CookieJar {
81
86
  throw new Error("Invalid cookie");
82
87
  }
83
88
  const nameLow = name.toLowerCase();
84
- const val = (value == null ? void 0 : value.charAt(0)) === "'" || (value == null ? void 0 : value.charAt(0)) === '"' ? value == null ? void 0 : value.slice(1, -1) : value;
89
+ const val = (
90
+ // eslint-disable-next-line quotes
91
+ (value == null ? void 0 : value.charAt(0)) === "'" || (value == null ? void 0 : value.charAt(0)) === '"' ? value == null ? void 0 : value.slice(1, -1) : value
92
+ );
85
93
  if (nameLow === "expires") {
86
94
  cookie.expires = new Date(val);
87
95
  }
@@ -105,6 +113,9 @@ var CookieJar = class _CookieJar {
105
113
  // src/index.node.ts
106
114
  var cookieJar = new CookieJar();
107
115
  async function aptosClient(requestOptions) {
116
+ return jsonRequest(requestOptions);
117
+ }
118
+ async function jsonRequest(requestOptions) {
108
119
  const { params, method, url, headers, body } = requestOptions;
109
120
  const request = {
110
121
  http2: true,
@@ -152,6 +163,60 @@ async function aptosClient(requestOptions) {
152
163
  throw error;
153
164
  }
154
165
  }
166
+ async function bcsRequest(requestOptions) {
167
+ const { params, method, url, headers, body } = requestOptions;
168
+ const request = {
169
+ http2: true,
170
+ searchParams: convertBigIntToString(params),
171
+ method,
172
+ url,
173
+ responseType: "buffer",
174
+ headers,
175
+ hooks: {
176
+ beforeRequest: [
177
+ (options) => {
178
+ const cookies = cookieJar.getCookies(new URL(options.url));
179
+ if ((cookies == null ? void 0 : cookies.length) > 0 && options.headers) {
180
+ options.headers.cookie = cookies.map((cookie) => `${cookie.name}=${cookie.value}`).join("; ");
181
+ }
182
+ }
183
+ ],
184
+ afterResponse: [
185
+ (response) => {
186
+ if (Array.isArray(response.headers["set-cookie"])) {
187
+ response.headers["set-cookie"].forEach((c) => {
188
+ cookieJar.setCookie(new URL(response.url), c);
189
+ });
190
+ }
191
+ return response;
192
+ }
193
+ ]
194
+ }
195
+ };
196
+ if (body) {
197
+ if (body instanceof Uint8Array) {
198
+ request.body = Buffer.from(body);
199
+ } else {
200
+ request.body = Buffer.from(JSON.stringify(body));
201
+ }
202
+ }
203
+ try {
204
+ switch (method) {
205
+ case "GET":
206
+ return parseResponse(await import_got.default.get(request));
207
+ case "POST":
208
+ return parseResponse(await import_got.default.post(request));
209
+ default:
210
+ }
211
+ } catch (error) {
212
+ const gotError = error;
213
+ if (gotError.response) {
214
+ return parseResponse(gotError.response);
215
+ }
216
+ throw error;
217
+ }
218
+ throw new Error(`Unsupported method: ${method}`);
219
+ }
155
220
  function parseResponse(response) {
156
221
  return {
157
222
  status: response.statusCode,
@@ -165,8 +230,7 @@ function parseResponse(response) {
165
230
  }
166
231
  function convertBigIntToString(obj) {
167
232
  const result = {};
168
- if (!obj)
169
- return result;
233
+ if (!obj) return result;
170
234
  Object.entries(obj).forEach(([key, value]) => {
171
235
  if (Object.prototype.hasOwnProperty.call(obj, key)) {
172
236
  if (typeof value === "bigint") {
@@ -178,4 +242,9 @@ function convertBigIntToString(obj) {
178
242
  });
179
243
  return result;
180
244
  }
245
+ // Annotate the CommonJS export names for ESM import in node:
246
+ 0 && (module.exports = {
247
+ bcsRequest,
248
+ jsonRequest
249
+ });
181
250
  //# sourceMappingURL=index.node.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/index.node.ts","../../src/cookieJar.ts"],"sourcesContent":["import got, { OptionsOfJSONResponseBody, RequestError, Response } from \"got\";\nimport { CookieJar } from \"./cookieJar\";\nimport { AptosClientRequest, AptosClientResponse } from \"./types\";\n\nconst cookieJar = new CookieJar();\n\nexport default async function aptosClient<Res>(requestOptions: AptosClientRequest): Promise<AptosClientResponse<Res>> {\n const { params, method, url, headers, body } = requestOptions;\n\n const request: OptionsOfJSONResponseBody = {\n http2: true,\n searchParams: convertBigIntToString(params),\n method,\n url,\n responseType: \"json\",\n headers,\n hooks: {\n beforeRequest: [\n (options) => {\n const cookies = cookieJar.getCookies(new URL(options.url!));\n\n if (cookies?.length > 0 && options.headers) {\n /* eslint-disable no-param-reassign */\n options.headers.cookie = cookies.map((cookie: any) => `${cookie.name}=${cookie.value}`).join(\"; \");\n }\n },\n ],\n afterResponse: [\n (response) => {\n if (Array.isArray(response.headers[\"set-cookie\"])) {\n response.headers[\"set-cookie\"].forEach((c) => {\n cookieJar.setCookie(new URL(response.url!), c);\n });\n }\n return response;\n },\n ],\n },\n };\n\n if (body) {\n if (body instanceof Uint8Array) {\n request.body = Buffer.from(body);\n } else {\n request.body = Buffer.from(JSON.stringify(body));\n }\n }\n\n try {\n const response = await got<Res>(request);\n return parseResponse<Res>(response);\n } catch (error) {\n const gotError = error as RequestError;\n if (gotError.response) {\n return parseResponse<Res>(gotError.response as Response<Res>);\n }\n throw error;\n }\n}\n\nfunction parseResponse<Res>(response: Response<Res>): AptosClientResponse<Res> {\n return {\n status: response.statusCode,\n statusText: response.statusMessage || \"\",\n data: response.body,\n config: response.request.options,\n request: response.request,\n response,\n headers: response.headers,\n };\n}\n\n/**\n * got supports only - string | number | boolean | null | undefined as searchParam value,\n * so if we have bigint type, convert it to string\n */\nfunction convertBigIntToString(obj: any): any {\n const result: any = {};\n if (!obj) return result;\n\n Object.entries(obj).forEach(([key, value]) => {\n if (Object.prototype.hasOwnProperty.call(obj, key)) {\n if (typeof value === \"bigint\") {\n result[key] = String(value);\n } else {\n result[key] = value;\n }\n }\n });\n\n return result;\n}\n","interface Cookie {\n name: string;\n value: string;\n expires?: Date;\n path?: string;\n sameSite?: \"Lax\" | \"None\" | \"Strict\";\n secure?: boolean;\n}\n\nexport class CookieJar {\n constructor(private jar = new Map<string, Cookie[]>()) {}\n\n setCookie(url: URL, cookieStr: string) {\n const key = url.origin.toLowerCase();\n if (!this.jar.has(key)) {\n this.jar.set(key, []);\n }\n\n const cookie = CookieJar.parse(cookieStr);\n this.jar.set(key, [...(this.jar.get(key)?.filter((c) => c.name !== cookie.name) || []), cookie]);\n }\n\n getCookies(url: URL): Cookie[] {\n const key = url.origin.toLowerCase();\n if (!this.jar.get(key)) {\n return [];\n }\n\n // Filter out expired cookies\n return this.jar.get(key)?.filter((cookie) => !cookie.expires || cookie.expires > new Date()) || [];\n }\n\n static parse(str: string): Cookie {\n if (typeof str !== \"string\") {\n throw new Error(\"argument str must be a string\");\n }\n\n const parts = str.split(\";\").map((part) => part.trim());\n\n let cookie: Cookie;\n\n if (parts.length > 0) {\n const [name, value] = parts[0].split(\"=\");\n if (!name || !value) {\n throw new Error(\"Invalid cookie\");\n }\n\n cookie = {\n name,\n value,\n };\n } else {\n throw new Error(\"Invalid cookie\");\n }\n\n parts.slice(1).forEach((part) => {\n const [name, value] = part.split(\"=\");\n if (!name.trim()) {\n throw new Error(\"Invalid cookie\");\n }\n\n const nameLow = name.toLowerCase();\n // eslint-disable-next-line quotes\n const val = value?.charAt(0) === \"'\" || value?.charAt(0) === '\"' ? value?.slice(1, -1) : value;\n if (nameLow === \"expires\") {\n cookie.expires = new Date(val);\n }\n if (nameLow === \"path\") {\n cookie.path = val;\n }\n if (nameLow === \"samesite\") {\n if (val !== \"Lax\" && val !== \"None\" && val !== \"Strict\") {\n throw new Error(\"Invalid cookie SameSite value\");\n }\n cookie.sameSite = val;\n }\n if (nameLow === \"secure\") {\n cookie.secure = true;\n }\n });\n\n return cookie;\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,iBAAuE;;;ACShE,IAAM,YAAN,MAAM,WAAU;AAAA,EACrB,YAAoB,MAAM,oBAAI,IAAsB,GAAG;AAAnC;AAAA,EAAoC;AAAA,EAExD,UAAU,KAAU,WAAmB;AAZzC;AAaI,UAAM,MAAM,IAAI,OAAO,YAAY;AACnC,QAAI,CAAC,KAAK,IAAI,IAAI,GAAG,GAAG;AACtB,WAAK,IAAI,IAAI,KAAK,CAAC,CAAC;AAAA,IACtB;AAEA,UAAM,SAAS,WAAU,MAAM,SAAS;AACxC,SAAK,IAAI,IAAI,KAAK,CAAC,KAAI,UAAK,IAAI,IAAI,GAAG,MAAhB,mBAAmB,OAAO,CAAC,MAAM,EAAE,SAAS,OAAO,UAAS,CAAC,GAAI,MAAM,CAAC;AAAA,EACjG;AAAA,EAEA,WAAW,KAAoB;AAtBjC;AAuBI,UAAM,MAAM,IAAI,OAAO,YAAY;AACnC,QAAI,CAAC,KAAK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AA,EACpC,SAAS,OAAO;AACd,UAAM,WAAW;AACjB,QAAI,SAAS,UAAU;AACrB,aAAO,cAAmB,SAAS,QAAyB;AAAA,IAC9D;AACA,UAAM;AAAA,EACR;AACF;AAEA,SAAS,cAAmB,UAAmD;AAC7E,SAAO;AAAA,IACL,QAAQ,SAAS;AAAA,IACjB,YAAY,SAAS,iBAAiB;AAAA,IACtC,MAAM,SAAS;AAAA,IACf,QAAQ,SAAS,QAAQ;AAAA,IACzB,SAAS,SAAS;AAAA,IAClB;AAAA,IACA,SAAS,SAAS;AAAA,EACpB;AACF;AAMA,SAAS,sBAAsB,KAAe;AAC5C,QAAM,SAAc,CAAC;AACrB,MAAI,CAAC;AAAK,WAAO;AAEjB,SAAO,QAAQ,GAAG,EAAE,QAAQ,CAAC,CAAC,KAAK,KAAK,MAAM;AAC5C,QAAI,OAAO,UAAU,eAAe,KAAK,KAAK,GAAG,GAAG;AAClD,UAAI,OAAO,UAAU,UAAU;AAC7B,eAAO,GAAG,IAAI,OAAO,KAAK;AAAA,MAC5B,OAAO;AACL,eAAO,GAAG,IAAI;AAAA,MAChB;AAAA,IACF;AAAA,EACF,CAAC;AAED,SAAO;AACT;","names":["got"]}
1
+ {"version":3,"sources":["../../src/index.node.ts","../../src/cookieJar.ts"],"sourcesContent":["import got, {\n OptionsOfBufferResponseBody,\n OptionsOfJSONResponseBody,\n RequestError,\n Response,\n} from \"got\";\nimport {CookieJar} from \"./cookieJar\";\nimport {AptosClientRequest, AptosClientResponse} from \"./types\";\n\nconst cookieJar = new CookieJar();\n\n/**\n * Used for JSON responses\n * @param requestOptions\n */\nexport default async function aptosClient<Res>(\n requestOptions: AptosClientRequest,\n): Promise<AptosClientResponse<Res>> {\n return jsonRequest<Res>(requestOptions);\n}\n\nexport async function jsonRequest<Res>(\n requestOptions: AptosClientRequest\n): Promise<AptosClientResponse<Res>> {\n const {params, method, url, headers, body} = requestOptions;\n\n const request: OptionsOfJSONResponseBody = {\n http2: true,\n searchParams: convertBigIntToString(params),\n method,\n url,\n responseType: \"json\",\n headers,\n hooks: {\n beforeRequest: [\n (options) => {\n const cookies = cookieJar.getCookies(new URL(options.url!));\n\n if (cookies?.length > 0 && options.headers) {\n /* eslint-disable no-param-reassign */\n options.headers.cookie = cookies\n .map((cookie: any) => `${cookie.name}=${cookie.value}`)\n .join(\"; \");\n }\n },\n ],\n afterResponse: [\n (response) => {\n if (Array.isArray(response.headers[\"set-cookie\"])) {\n response.headers[\"set-cookie\"].forEach((c) => {\n cookieJar.setCookie(new URL(response.url!), c);\n });\n }\n return response;\n },\n ],\n },\n };\n\n if (body) {\n if (body instanceof Uint8Array) {\n request.body = Buffer.from(body);\n } else {\n request.body = Buffer.from(JSON.stringify(body));\n }\n }\n\n try {\n const response = await got<Res>(request);\n return parseResponse<Res>(response);\n } catch (error) {\n const gotError = error as RequestError;\n if (gotError.response) {\n return parseResponse<Res>(gotError.response as Response<Res>);\n }\n throw error;\n }\n}\n\n/**\n * Used for binary responses, such as BCS outputs\n *\n * @experimental\n * @param requestOptions\n */\nexport async function bcsRequest(\n requestOptions: AptosClientRequest,\n): Promise<AptosClientResponse<Buffer>> {\n const {params, method, url, headers, body} = requestOptions;\n\n const request: OptionsOfBufferResponseBody = {\n http2: true,\n searchParams: convertBigIntToString(params),\n method,\n url,\n responseType: \"buffer\",\n headers,\n hooks: {\n beforeRequest: [\n (options) => {\n const cookies = cookieJar.getCookies(new URL(options.url!));\n\n if (cookies?.length > 0 && options.headers) {\n /* eslint-disable no-param-reassign */\n options.headers.cookie = cookies\n .map((cookie: any) => `${cookie.name}=${cookie.value}`)\n .join(\"; \");\n }\n },\n ],\n afterResponse: [\n (response) => {\n if (Array.isArray(response.headers[\"set-cookie\"])) {\n response.headers[\"set-cookie\"].forEach((c) => {\n cookieJar.setCookie(new URL(response.url!), c);\n });\n }\n return response;\n },\n ],\n },\n };\n\n if (body) {\n if (body instanceof Uint8Array) {\n request.body = Buffer.from(body);\n } else {\n request.body = Buffer.from(JSON.stringify(body));\n }\n }\n\n try {\n switch (method) {\n case \"GET\":\n return parseResponse<Buffer>(await got.get(request));\n case \"POST\":\n return parseResponse<Buffer>(await got.post(request));\n default:\n // Do nothing, fall through\n }\n } catch (error) {\n const gotError = error as RequestError;\n if (gotError.response) {\n return parseResponse<Buffer>(gotError.response as Response<Buffer>);\n }\n throw error;\n }\n\n throw new Error(`Unsupported method: ${method}`);\n}\n\nfunction parseResponse<Res>(response: Response<Res>): AptosClientResponse<Res> {\n return {\n status: response.statusCode,\n statusText: response.statusMessage || \"\",\n data: response.body,\n config: response.request.options,\n request: response.request,\n response,\n headers: response.headers,\n };\n}\n\n/**\n * got supports only - string | number | boolean | null | undefined as searchParam value,\n * so if we have bigint type, convert it to string\n */\nfunction convertBigIntToString(obj: any): any {\n const result: any = {};\n if (!obj) return result;\n\n Object.entries(obj).forEach(([key, value]) => {\n if (Object.prototype.hasOwnProperty.call(obj, key)) {\n if (typeof value === \"bigint\") {\n result[key] = String(value);\n } else {\n result[key] = value;\n }\n }\n });\n\n return result;\n}\n","interface Cookie {\n name: string;\n value: string;\n expires?: Date;\n path?: string;\n sameSite?: \"Lax\" | \"None\" | \"Strict\";\n secure?: boolean;\n}\n\nexport class CookieJar {\n constructor(private jar = new Map<string, Cookie[]>()) {}\n\n setCookie(url: URL, cookieStr: string) {\n const key = url.origin.toLowerCase();\n if (!this.jar.has(key)) {\n this.jar.set(key, []);\n }\n\n const cookie = CookieJar.parse(cookieStr);\n this.jar.set(key, [\n ...(this.jar.get(key)?.filter((c) => c.name !== cookie.name) || []),\n cookie,\n ]);\n }\n\n getCookies(url: URL): Cookie[] {\n const key = url.origin.toLowerCase();\n if (!this.jar.get(key)) {\n return [];\n }\n\n // Filter out expired cookies\n return (\n this.jar\n .get(key)\n ?.filter((cookie) => !cookie.expires || cookie.expires > new Date()) ||\n []\n );\n }\n\n static parse(str: string): Cookie {\n if (typeof str !== \"string\") {\n throw new Error(\"argument str must be a string\");\n }\n\n const parts = str.split(\";\").map((part) => part.trim());\n\n let cookie: Cookie;\n\n if (parts.length > 0) {\n const [name, value] = parts[0].split(\"=\");\n if (!name || !value) {\n throw new Error(\"Invalid cookie\");\n }\n\n cookie = {\n name,\n value,\n };\n } else {\n throw new Error(\"Invalid cookie\");\n }\n\n parts.slice(1).forEach((part) => {\n const [name, value] = part.split(\"=\");\n if (!name.trim()) {\n throw new Error(\"Invalid cookie\");\n }\n\n const nameLow = name.toLowerCase();\n const val =\n // eslint-disable-next-line quotes\n value?.charAt(0) === \"'\" || value?.charAt(0) === '\"'\n ? value?.slice(1, -1)\n : value;\n if (nameLow === \"expires\") {\n cookie.expires = new Date(val);\n }\n if (nameLow === \"path\") {\n cookie.path = val;\n }\n if (nameLow === \"samesite\") {\n if (val !== \"Lax\" && val !== \"None\" && val !== \"Strict\") {\n throw new Error(\"Invalid cookie SameSite value\");\n }\n cookie.sameSite = val;\n }\n if (nameLow === \"secure\") {\n cookie.secure = true;\n }\n });\n\n return cookie;\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,iBAKO;;;ACIA,IAAM,YAAN,MAAM,WAAU;AAAA,EACrB,YAAoB,MAAM,oBAAI,IAAsB,GAAG;AAAnC;AAAA,EAAoC;AAAA,EAExD,UAAU,KAAU,WAAmB;AAZzC;AAaI,UAAM,MAAM,IAAI,OAAO,YAAY;AACnC,QAAI,CAAC,KAAK,IAAI,IAAI,GAAG,GAAG;AACtB,WAAK,IAAI,IAAI,KAAK,CAAC,CAAC;AAAA,IACtB;AAEA,UAAM,SAAS,WAAU,MAAM,SAAS;AACxC,SAAK,IAAI,IAAI,KAAK;AAAA,MAChB,KAAI,UAAK,IAAI,IAAI,GAAG,MAAhB,mBAAmB,OAAO,CAAC,MAAM,EAAE,SAAS,OAAO,UAAS,CAAC;AAAA,MACjE;AAAA,IACF,CAAC;AAAA,EACH;AAAA,EAEA,WAAW,KAAoB;AAzBj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;AAAA,IACnD;AAAA,EACJ;AAEA,MAAI;AACA,YAAQ,QAAQ;AAAA,MACZ,KAAK;AACD,eAAO,cAAsB,MAAM,WAAAA,QAAI,IAAI,OAAO,CAAC;AAAA,MACvD,KAAK;AACD,eAAO,cAAsB,MAAM,WAAAA,QAAI,KAAK,OAAO,CAAC;AAAA,MACxD;AAAA,IAEJ;AAAA,EACJ,SAAS,OAAO;AACZ,UAAM,WAAW;AACjB,QAAI,SAAS,UAAU;AACnB,aAAO,cAAsB,SAAS,QAA4B;AAAA,IACtE;AACA,UAAM;AAAA,EACV;AAEA,QAAM,IAAI,MAAM,uBAAuB,MAAM,EAAE;AACnD;AAEA,SAAS,cAAmB,UAAmD;AAC3E,SAAO;AAAA,IACH,QAAQ,SAAS;AAAA,IACjB,YAAY,SAAS,iBAAiB;AAAA,IACtC,MAAM,SAAS;AAAA,IACf,QAAQ,SAAS,QAAQ;AAAA,IACzB,SAAS,SAAS;AAAA,IAClB;AAAA,IACA,SAAS,SAAS;AAAA,EACtB;AACJ;AAMA,SAAS,sBAAsB,KAAe;AAC1C,QAAM,SAAc,CAAC;AACrB,MAAI,CAAC,IAAK,QAAO;AAEjB,SAAO,QAAQ,GAAG,EAAE,QAAQ,CAAC,CAAC,KAAK,KAAK,MAAM;AAC1C,QAAI,OAAO,UAAU,eAAe,KAAK,KAAK,GAAG,GAAG;AAChD,UAAI,OAAO,UAAU,UAAU;AAC3B,eAAO,GAAG,IAAI,OAAO,KAAK;AAAA,MAC9B,OAAO;AACH,eAAO,GAAG,IAAI;AAAA,MAClB;AAAA,IACJ;AAAA,EACJ,CAAC;AAED,SAAO;AACX;","names":["got"]}
@@ -13,7 +13,10 @@ var CookieJar = class _CookieJar {
13
13
  this.jar.set(key, []);
14
14
  }
15
15
  const cookie = _CookieJar.parse(cookieStr);
16
- this.jar.set(key, [...((_a = this.jar.get(key)) == null ? void 0 : _a.filter((c) => c.name !== cookie.name)) || [], cookie]);
16
+ this.jar.set(key, [
17
+ ...((_a = this.jar.get(key)) == null ? void 0 : _a.filter((c) => c.name !== cookie.name)) || [],
18
+ cookie
19
+ ]);
17
20
  }
18
21
  getCookies(url) {
19
22
  var _a;
@@ -47,7 +50,10 @@ var CookieJar = class _CookieJar {
47
50
  throw new Error("Invalid cookie");
48
51
  }
49
52
  const nameLow = name.toLowerCase();
50
- const val = (value == null ? void 0 : value.charAt(0)) === "'" || (value == null ? void 0 : value.charAt(0)) === '"' ? value == null ? void 0 : value.slice(1, -1) : value;
53
+ const val = (
54
+ // eslint-disable-next-line quotes
55
+ (value == null ? void 0 : value.charAt(0)) === "'" || (value == null ? void 0 : value.charAt(0)) === '"' ? value == null ? void 0 : value.slice(1, -1) : value
56
+ );
51
57
  if (nameLow === "expires") {
52
58
  cookie.expires = new Date(val);
53
59
  }
@@ -71,6 +77,9 @@ var CookieJar = class _CookieJar {
71
77
  // src/index.node.ts
72
78
  var cookieJar = new CookieJar();
73
79
  async function aptosClient(requestOptions) {
80
+ return jsonRequest(requestOptions);
81
+ }
82
+ async function jsonRequest(requestOptions) {
74
83
  const { params, method, url, headers, body } = requestOptions;
75
84
  const request = {
76
85
  http2: true,
@@ -118,6 +127,60 @@ async function aptosClient(requestOptions) {
118
127
  throw error;
119
128
  }
120
129
  }
130
+ async function bcsRequest(requestOptions) {
131
+ const { params, method, url, headers, body } = requestOptions;
132
+ const request = {
133
+ http2: true,
134
+ searchParams: convertBigIntToString(params),
135
+ method,
136
+ url,
137
+ responseType: "buffer",
138
+ headers,
139
+ hooks: {
140
+ beforeRequest: [
141
+ (options) => {
142
+ const cookies = cookieJar.getCookies(new URL(options.url));
143
+ if ((cookies == null ? void 0 : cookies.length) > 0 && options.headers) {
144
+ options.headers.cookie = cookies.map((cookie) => `${cookie.name}=${cookie.value}`).join("; ");
145
+ }
146
+ }
147
+ ],
148
+ afterResponse: [
149
+ (response) => {
150
+ if (Array.isArray(response.headers["set-cookie"])) {
151
+ response.headers["set-cookie"].forEach((c) => {
152
+ cookieJar.setCookie(new URL(response.url), c);
153
+ });
154
+ }
155
+ return response;
156
+ }
157
+ ]
158
+ }
159
+ };
160
+ if (body) {
161
+ if (body instanceof Uint8Array) {
162
+ request.body = Buffer.from(body);
163
+ } else {
164
+ request.body = Buffer.from(JSON.stringify(body));
165
+ }
166
+ }
167
+ try {
168
+ switch (method) {
169
+ case "GET":
170
+ return parseResponse(await got.get(request));
171
+ case "POST":
172
+ return parseResponse(await got.post(request));
173
+ default:
174
+ }
175
+ } catch (error) {
176
+ const gotError = error;
177
+ if (gotError.response) {
178
+ return parseResponse(gotError.response);
179
+ }
180
+ throw error;
181
+ }
182
+ throw new Error(`Unsupported method: ${method}`);
183
+ }
121
184
  function parseResponse(response) {
122
185
  return {
123
186
  status: response.statusCode,
@@ -131,8 +194,7 @@ function parseResponse(response) {
131
194
  }
132
195
  function convertBigIntToString(obj) {
133
196
  const result = {};
134
- if (!obj)
135
- return result;
197
+ if (!obj) return result;
136
198
  Object.entries(obj).forEach(([key, value]) => {
137
199
  if (Object.prototype.hasOwnProperty.call(obj, key)) {
138
200
  if (typeof value === "bigint") {
@@ -145,6 +207,8 @@ function convertBigIntToString(obj) {
145
207
  return result;
146
208
  }
147
209
  export {
148
- aptosClient as default
210
+ bcsRequest,
211
+ aptosClient as default,
212
+ jsonRequest
149
213
  };
150
214
  //# sourceMappingURL=index.node.mjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/index.node.ts","../../src/cookieJar.ts"],"sourcesContent":["import got, { OptionsOfJSONResponseBody, RequestError, Response } from \"got\";\nimport { CookieJar } from \"./cookieJar\";\nimport { AptosClientRequest, AptosClientResponse } from \"./types\";\n\nconst cookieJar = new CookieJar();\n\nexport default async function aptosClient<Res>(requestOptions: AptosClientRequest): Promise<AptosClientResponse<Res>> {\n const { params, method, url, headers, body } = requestOptions;\n\n const request: OptionsOfJSONResponseBody = {\n http2: true,\n searchParams: convertBigIntToString(params),\n method,\n url,\n responseType: \"json\",\n headers,\n hooks: {\n beforeRequest: [\n (options) => {\n const cookies = cookieJar.getCookies(new URL(options.url!));\n\n if (cookies?.length > 0 && options.headers) {\n /* eslint-disable no-param-reassign */\n options.headers.cookie = cookies.map((cookie: any) => `${cookie.name}=${cookie.value}`).join(\"; \");\n }\n },\n ],\n afterResponse: [\n (response) => {\n if (Array.isArray(response.headers[\"set-cookie\"])) {\n response.headers[\"set-cookie\"].forEach((c) => {\n cookieJar.setCookie(new URL(response.url!), c);\n });\n }\n return response;\n },\n ],\n },\n };\n\n if (body) {\n if (body instanceof Uint8Array) {\n request.body = Buffer.from(body);\n } else {\n request.body = Buffer.from(JSON.stringify(body));\n }\n }\n\n try {\n const response = await got<Res>(request);\n return parseResponse<Res>(response);\n } catch (error) {\n const gotError = error as RequestError;\n if (gotError.response) {\n return parseResponse<Res>(gotError.response as Response<Res>);\n }\n throw error;\n }\n}\n\nfunction parseResponse<Res>(response: Response<Res>): AptosClientResponse<Res> {\n return {\n status: response.statusCode,\n statusText: response.statusMessage || \"\",\n data: response.body,\n config: response.request.options,\n request: response.request,\n response,\n headers: response.headers,\n };\n}\n\n/**\n * got supports only - string | number | boolean | null | undefined as searchParam value,\n * so if we have bigint type, convert it to string\n */\nfunction convertBigIntToString(obj: any): any {\n const result: any = {};\n if (!obj) return result;\n\n Object.entries(obj).forEach(([key, value]) => {\n if (Object.prototype.hasOwnProperty.call(obj, key)) {\n if (typeof value === \"bigint\") {\n result[key] = String(value);\n } else {\n result[key] = value;\n }\n }\n });\n\n return result;\n}\n","interface Cookie {\n name: string;\n value: string;\n expires?: Date;\n path?: string;\n sameSite?: \"Lax\" | \"None\" | \"Strict\";\n secure?: boolean;\n}\n\nexport class CookieJar {\n constructor(private jar = new Map<string, Cookie[]>()) {}\n\n setCookie(url: URL, cookieStr: string) {\n const key = url.origin.toLowerCase();\n if (!this.jar.has(key)) {\n this.jar.set(key, []);\n }\n\n const cookie = CookieJar.parse(cookieStr);\n this.jar.set(key, [...(this.jar.get(key)?.filter((c) => c.name !== cookie.name) || []), cookie]);\n }\n\n getCookies(url: URL): Cookie[] {\n const key = url.origin.toLowerCase();\n if (!this.jar.get(key)) {\n return [];\n }\n\n // Filter out expired cookies\n return this.jar.get(key)?.filter((cookie) => !cookie.expires || cookie.expires > new Date()) || [];\n }\n\n static parse(str: string): Cookie {\n if (typeof str !== \"string\") {\n throw new Error(\"argument str must be a string\");\n }\n\n const parts = str.split(\";\").map((part) => part.trim());\n\n let cookie: Cookie;\n\n if (parts.length > 0) {\n const [name, value] = parts[0].split(\"=\");\n if (!name || !value) {\n throw new Error(\"Invalid cookie\");\n }\n\n cookie = {\n name,\n value,\n };\n } else {\n throw new Error(\"Invalid cookie\");\n }\n\n parts.slice(1).forEach((part) => {\n const [name, value] = part.split(\"=\");\n if (!name.trim()) {\n throw new Error(\"Invalid cookie\");\n }\n\n const nameLow = name.toLowerCase();\n // eslint-disable-next-line quotes\n const val = value?.charAt(0) === \"'\" || value?.charAt(0) === '\"' ? value?.slice(1, -1) : value;\n if (nameLow === \"expires\") {\n cookie.expires = new Date(val);\n }\n if (nameLow === \"path\") {\n cookie.path = val;\n }\n if (nameLow === \"samesite\") {\n if (val !== \"Lax\" && val !== \"None\" && val !== \"Strict\") {\n throw new Error(\"Invalid cookie SameSite value\");\n }\n cookie.sameSite = val;\n }\n if (nameLow === \"secure\") {\n cookie.secure = true;\n }\n });\n\n return cookie;\n }\n}\n"],"mappings":";AAAA,OAAO,SAAgE;;;ACShE,IAAM,YAAN,MAAM,WAAU;AAAA,EACrB,YAAoB,MAAM,oBAAI,IAAsB,GAAG;AAAnC;AAAA,EAAoC;AAAA,EAExD,UAAU,KAAU,WAAmB;AAZzC;AAaI,UAAM,MAAM,IAAI,OAAO,YAAY;AACnC,QAAI,CAAC,KAAK,IAAI,IAAI,GAAG,GAAG;AACtB,WAAK,IAAI,IAAI,KAAK,CAAC,CAAC;AAAA,IACtB;AAEA,UAAM,SAAS,WAAU,MAAM,SAAS;AACxC,SAAK,IAAI,IAAI,KAAK,CAAC,K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AAC9B,cAAQ,OAAO,OAAO,KAAK,IAAI;AAAA,IACjC,OAAO;AACL,cAAQ,OAAO,OAAO,KAAK,KAAK,UAAU,IAAI,CAAC;AAAA,IACjD;AAAA,EACF;AAEA,MAAI;AACF,UAAM,WAAW,MAAM,IAAS,OAAO;AACvC,WAAO,cAAmB,QAAQ;AAAA,EACpC,SAAS,OAAO;AACd,UAAM,WAAW;AACjB,QAAI,SAAS,UAAU;AACrB,aAAO,cAAmB,SAAS,QAAyB;AAAA,IAC9D;AACA,UAAM;AAAA,EACR;AACF;AAEA,SAAS,cAAmB,UAAmD;AAC7E,SAAO;AAAA,IACL,QAAQ,SAAS;AAAA,IACjB,YAAY,SAAS,iBAAiB;AAAA,IACtC,MAAM,SAAS;AAAA,IACf,QAAQ,SAAS,QAAQ;AAAA,IACzB,SAAS,SAAS;AAAA,IAClB;AAAA,IACA,SAAS,SAAS;AAAA,EACpB;AACF;AAMA,SAAS,sBAAsB,KAAe;AAC5C,QAAM,SAAc,CAAC;AACrB,MAAI,CAAC;AAAK,WAAO;AAEjB,SAAO,QAAQ,GAAG,EAAE,QAAQ,CAAC,CAAC,KAAK,KAAK,MAAM;AAC5C,QAAI,OAAO,UAAU,eAAe,KAAK,KAAK,GAAG,GAAG;AAClD,UAAI,OAAO,UAAU,UAAU;AAC7B,eAAO,GAAG,IAAI,OAAO,KAAK;AAAA,MAC5B,OAAO;AACL,eAAO,GAAG,IAAI;AAAA,MAChB;AAAA,IACF;AAAA,EACF,CAAC;AAED,SAAO;AACT;","names":[]}
1
+ {"version":3,"sources":["../../src/index.node.ts","../../src/cookieJar.ts"],"sourcesContent":["import got, {\n OptionsOfBufferResponseBody,\n OptionsOfJSONResponseBody,\n RequestError,\n Response,\n} from \"got\";\nimport {CookieJar} from \"./cookieJar\";\nimport {AptosClientRequest, AptosClientResponse} from \"./types\";\n\nconst cookieJar = new CookieJar();\n\n/**\n * Used for JSON responses\n * @param requestOptions\n */\nexport default async function aptosClient<Res>(\n requestOptions: AptosClientRequest,\n): Promise<AptosClientResponse<Res>> {\n return jsonRequest<Res>(requestOptions);\n}\n\nexport async function jsonRequest<Res>(\n requestOptions: AptosClientRequest\n): Promise<AptosClientResponse<Res>> {\n const {params, method, url, headers, body} = requestOptions;\n\n const request: OptionsOfJSONResponseBody = {\n http2: true,\n searchParams: convertBigIntToString(params),\n method,\n url,\n responseType: \"json\",\n headers,\n hooks: {\n beforeRequest: [\n (options) => {\n const cookies = cookieJar.getCookies(new URL(options.url!));\n\n if (cookies?.length > 0 && options.headers) {\n /* eslint-disable no-param-reassign */\n options.headers.cookie = cookies\n .map((cookie: any) => `${cookie.name}=${cookie.value}`)\n .join(\"; \");\n }\n },\n ],\n afterResponse: [\n (response) => {\n if (Array.isArray(response.headers[\"set-cookie\"])) {\n response.headers[\"set-cookie\"].forEach((c) => {\n cookieJar.setCookie(new URL(response.url!), c);\n });\n }\n return response;\n },\n ],\n },\n };\n\n if (body) {\n if (body instanceof Uint8Array) {\n request.body = Buffer.from(body);\n } else {\n request.body = Buffer.from(JSON.stringify(body));\n }\n }\n\n try {\n const response = await got<Res>(request);\n return parseResponse<Res>(response);\n } catch (error) {\n const gotError = error as RequestError;\n if (gotError.response) {\n return parseResponse<Res>(gotError.response as Response<Res>);\n }\n throw error;\n }\n}\n\n/**\n * Used for binary responses, such as BCS outputs\n *\n * @experimental\n * @param requestOptions\n */\nexport async function bcsRequest(\n requestOptions: AptosClientRequest,\n): Promise<AptosClientResponse<Buffer>> {\n const {params, method, url, headers, body} = requestOptions;\n\n const request: OptionsOfBufferResponseBody = {\n http2: true,\n searchParams: convertBigIntToString(params),\n method,\n url,\n responseType: \"buffer\",\n headers,\n hooks: {\n beforeRequest: [\n (options) => {\n const cookies = cookieJar.getCookies(new URL(options.url!));\n\n if (cookies?.length > 0 && options.headers) {\n /* eslint-disable no-param-reassign */\n options.headers.cookie = cookies\n .map((cookie: any) => `${cookie.name}=${cookie.value}`)\n .join(\"; \");\n }\n },\n ],\n afterResponse: [\n (response) => {\n if (Array.isArray(response.headers[\"set-cookie\"])) {\n response.headers[\"set-cookie\"].forEach((c) => {\n cookieJar.setCookie(new URL(response.url!), c);\n });\n }\n return response;\n },\n ],\n },\n };\n\n if (body) {\n if (body instanceof Uint8Array) {\n request.body = Buffer.from(body);\n } else {\n request.body = Buffer.from(JSON.stringify(body));\n }\n }\n\n try {\n switch (method) {\n case \"GET\":\n return parseResponse<Buffer>(await got.get(request));\n case \"POST\":\n return parseResponse<Buffer>(await got.post(request));\n default:\n // Do nothing, fall through\n }\n } catch (error) {\n const gotError = error as RequestError;\n if (gotError.response) {\n return parseResponse<Buffer>(gotError.response as Response<Buffer>);\n }\n throw error;\n }\n\n throw new Error(`Unsupported method: ${method}`);\n}\n\nfunction parseResponse<Res>(response: Response<Res>): AptosClientResponse<Res> {\n return {\n status: response.statusCode,\n statusText: response.statusMessage || \"\",\n data: response.body,\n config: response.request.options,\n request: response.request,\n response,\n headers: response.headers,\n };\n}\n\n/**\n * got supports only - string | number | boolean | null | undefined as searchParam value,\n * so if we have bigint type, convert it to string\n */\nfunction convertBigIntToString(obj: any): any {\n const result: any = {};\n if (!obj) return result;\n\n Object.entries(obj).forEach(([key, value]) => {\n if (Object.prototype.hasOwnProperty.call(obj, key)) {\n if (typeof value === \"bigint\") {\n result[key] = String(value);\n } else {\n result[key] = value;\n }\n }\n });\n\n return result;\n}\n","interface Cookie {\n name: string;\n value: string;\n expires?: Date;\n path?: string;\n sameSite?: \"Lax\" | \"None\" | \"Strict\";\n secure?: boolean;\n}\n\nexport class CookieJar {\n constructor(private jar = new Map<string, Cookie[]>()) {}\n\n setCookie(url: URL, cookieStr: string) {\n const key = url.origin.toLowerCase();\n if (!this.jar.has(key)) {\n this.jar.set(key, []);\n }\n\n const cookie = CookieJar.parse(cookieStr);\n this.jar.set(key, [\n ...(this.jar.get(key)?.filter((c) => c.name !== cookie.name) || []),\n cookie,\n ]);\n }\n\n getCookies(url: URL): Cookie[] {\n const key = url.origin.toLowerCase();\n if (!this.jar.get(key)) {\n return [];\n }\n\n // Filter out expired cookies\n return (\n this.jar\n .get(key)\n ?.filter((cookie) => !cookie.expires || cookie.expires > new Date()) ||\n []\n );\n }\n\n static parse(str: string): Cookie {\n if (typeof str !== \"string\") {\n throw new Error(\"argument str must be a string\");\n }\n\n const parts = str.split(\";\").map((part) => part.trim());\n\n let cookie: Cookie;\n\n if (parts.length > 0) {\n const [name, value] = parts[0].split(\"=\");\n if (!name || !value) {\n throw new Error(\"Invalid cookie\");\n }\n\n cookie = {\n name,\n value,\n };\n } else {\n throw new Error(\"Invalid cookie\");\n }\n\n parts.slice(1).forEach((part) => {\n const [name, value] = part.split(\"=\");\n if (!name.trim()) {\n throw new Error(\"Invalid cookie\");\n }\n\n const nameLow = name.toLowerCase();\n const val =\n // eslint-disable-next-line quotes\n value?.charAt(0) === \"'\" || value?.charAt(0) === '\"'\n ? value?.slice(1, -1)\n : value;\n if (nameLow === \"expires\") {\n cookie.expires = new Date(val);\n }\n if (nameLow === \"path\") {\n cookie.path = val;\n }\n if (nameLow === \"samesite\") {\n if (val !== \"Lax\" && val !== \"None\" && val !== \"Strict\") {\n throw new Error(\"Invalid cookie SameSite value\");\n }\n cookie.sameSite = val;\n }\n if (nameLow === \"secure\") {\n cookie.secure = true;\n }\n });\n\n return cookie;\n }\n}\n"],"mappings":";AAAA,OAAO,SAKA;;;ACIA,IAAM,YAAN,MAAM,WAAU;AAAA,EACrB,YAAoB,MAAM,oBAAI,IAAsB,GAAG;AAAnC;AAAA,EAAoC;AAAA,EAExD,UAAU,KAAU,WAAmB;AAZzC;AAaI,UAAM,MAAM,IAAI,OAAO,YAAY;AACnC,QAAI,CAAC,KAAK,IAAI,IAAI,GAAG,GAAG;AACtB,WAAK,IAAI,IAAI,KAAK,CAAC,CAAC;AAAA,IACtB;AAEA,UAAM,SAAS,WAAU,MAAM,SAAS;AACxC,SAAK,IAAI,IAAI,KAAK;AAAA,MAChB,KAAI,UAAK,IAAI,IAAI,GAAG,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Str);
25
- this.jar.set(key, __spreadArray(__spreadArray([], (((_a = this.jar.get(key)) === null || _a === void 0 ? void 0 : _a.filter(function (c) { return c.name !== cookie.name; })) || []), true), [cookie], false));
25
+ this.jar.set(key, __spreadArray(__spreadArray([], (((_a = this.jar.get(key)) === null || _a === void 0 ? void 0 : _a.filter(function (c) { return c.name !== cookie.name; })) || []), true), [
26
+ cookie,
27
+ ], false));
26
28
  };
27
29
  CookieJar.prototype.getCookies = function (url) {
28
30
  var _a;
@@ -31,7 +33,9 @@ var CookieJar = /** @class */ (function () {
31
33
  return [];
32
34
  }
33
35
  // Filter out expired cookies
34
- return ((_a = this.jar.get(key)) === null || _a === void 0 ? void 0 : _a.filter(function (cookie) { return !cookie.expires || cookie.expires > new Date(); })) || [];
36
+ return (((_a = this.jar
37
+ .get(key)) === null || _a === void 0 ? void 0 : _a.filter(function (cookie) { return !cookie.expires || cookie.expires > new Date(); })) ||
38
+ []);
35
39
  };
36
40
  CookieJar.parse = function (str) {
37
41
  if (typeof str !== "string") {
@@ -58,8 +62,11 @@ var CookieJar = /** @class */ (function () {
58
62
  throw new Error("Invalid cookie");
59
63
  }
60
64
  var nameLow = name.toLowerCase();
65
+ var val =
61
66
  // eslint-disable-next-line quotes
62
- var val = (value === null || value === void 0 ? void 0 : value.charAt(0)) === "'" || (value === null || value === void 0 ? void 0 : value.charAt(0)) === '"' ? value === null || value === void 0 ? void 0 : value.slice(1, -1) : value;
67
+ (value === null || value === void 0 ? void 0 : value.charAt(0)) === "'" || (value === null || value === void 0 ? void 0 : value.charAt(0)) === '"'
68
+ ? value === null || value === void 0 ? void 0 : value.slice(1, -1)
69
+ : value;
63
70
  if (nameLow === "expires") {
64
71
  cookie.expires = new Date(val);
65
72
  }
@@ -1,2 +1,14 @@
1
1
  import { AptosClientRequest, AptosClientResponse } from "./types";
2
+ /**
3
+ * Used for JSON responses
4
+ * @param requestOptions
5
+ */
2
6
  export default function aptosClient<Res>(requestOptions: AptosClientRequest): Promise<AptosClientResponse<Res>>;
7
+ export declare function jsonRequest<Res>(requestOptions: AptosClientRequest): Promise<AptosClientResponse<Res>>;
8
+ /**
9
+ * Used for binary responses, such as BCS outputs
10
+ *
11
+ * @experimental
12
+ * @param requestOptions
13
+ */
14
+ export declare function bcsRequest(requestOptions: AptosClientRequest): Promise<AptosClientResponse<Buffer>>;
@@ -9,8 +9,8 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
9
9
  });
10
10
  };
11
11
  var __generator = (this && this.__generator) || function (thisArg, body) {
12
- var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
13
- return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
12
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
13
+ return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
14
14
  function verb(n) { return function (v) { return step([n, v]); }; }
15
15
  function step(op) {
16
16
  if (f) throw new TypeError("Generator is already executing.");
@@ -36,10 +36,24 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
36
36
  }
37
37
  };
38
38
  Object.defineProperty(exports, "__esModule", { value: true });
39
+ exports.default = aptosClient;
40
+ exports.jsonRequest = jsonRequest;
41
+ exports.bcsRequest = bcsRequest;
39
42
  var got_1 = require("got");
40
43
  var cookieJar_1 = require("./cookieJar");
41
44
  var cookieJar = new cookieJar_1.CookieJar();
45
+ /**
46
+ * Used for JSON responses
47
+ * @param requestOptions
48
+ */
42
49
  function aptosClient(requestOptions) {
50
+ return __awaiter(this, void 0, void 0, function () {
51
+ return __generator(this, function (_a) {
52
+ return [2 /*return*/, jsonRequest(requestOptions)];
53
+ });
54
+ });
55
+ }
56
+ function jsonRequest(requestOptions) {
43
57
  return __awaiter(this, void 0, void 0, function () {
44
58
  var params, method, url, headers, body, request, response, error_1, gotError;
45
59
  return __generator(this, function (_a) {
@@ -59,7 +73,9 @@ function aptosClient(requestOptions) {
59
73
  var cookies = cookieJar.getCookies(new URL(options.url));
60
74
  if ((cookies === null || cookies === void 0 ? void 0 : cookies.length) > 0 && options.headers) {
61
75
  /* eslint-disable no-param-reassign */
62
- options.headers.cookie = cookies.map(function (cookie) { return "".concat(cookie.name, "=").concat(cookie.value); }).join("; ");
76
+ options.headers.cookie = cookies
77
+ .map(function (cookie) { return "".concat(cookie.name, "=").concat(cookie.value); })
78
+ .join("; ");
63
79
  }
64
80
  },
65
81
  ],
@@ -102,7 +118,88 @@ function aptosClient(requestOptions) {
102
118
  });
103
119
  });
104
120
  }
105
- exports.default = aptosClient;
121
+ /**
122
+ * Used for binary responses, such as BCS outputs
123
+ *
124
+ * @experimental
125
+ * @param requestOptions
126
+ */
127
+ function bcsRequest(requestOptions) {
128
+ return __awaiter(this, void 0, void 0, function () {
129
+ var params, method, url, headers, body, request, _a, _b, _c, error_2, gotError;
130
+ return __generator(this, function (_d) {
131
+ switch (_d.label) {
132
+ case 0:
133
+ params = requestOptions.params, method = requestOptions.method, url = requestOptions.url, headers = requestOptions.headers, body = requestOptions.body;
134
+ request = {
135
+ http2: true,
136
+ searchParams: convertBigIntToString(params),
137
+ method: method,
138
+ url: url,
139
+ responseType: "buffer",
140
+ headers: headers,
141
+ hooks: {
142
+ beforeRequest: [
143
+ function (options) {
144
+ var cookies = cookieJar.getCookies(new URL(options.url));
145
+ if ((cookies === null || cookies === void 0 ? void 0 : cookies.length) > 0 && options.headers) {
146
+ /* eslint-disable no-param-reassign */
147
+ options.headers.cookie = cookies
148
+ .map(function (cookie) { return "".concat(cookie.name, "=").concat(cookie.value); })
149
+ .join("; ");
150
+ }
151
+ },
152
+ ],
153
+ afterResponse: [
154
+ function (response) {
155
+ if (Array.isArray(response.headers["set-cookie"])) {
156
+ response.headers["set-cookie"].forEach(function (c) {
157
+ cookieJar.setCookie(new URL(response.url), c);
158
+ });
159
+ }
160
+ return response;
161
+ },
162
+ ],
163
+ },
164
+ };
165
+ if (body) {
166
+ if (body instanceof Uint8Array) {
167
+ request.body = Buffer.from(body);
168
+ }
169
+ else {
170
+ request.body = Buffer.from(JSON.stringify(body));
171
+ }
172
+ }
173
+ _d.label = 1;
174
+ case 1:
175
+ _d.trys.push([1, 7, , 8]);
176
+ _a = method;
177
+ switch (_a) {
178
+ case "GET": return [3 /*break*/, 2];
179
+ case "POST": return [3 /*break*/, 4];
180
+ }
181
+ return [3 /*break*/, 6];
182
+ case 2:
183
+ _b = parseResponse;
184
+ return [4 /*yield*/, got_1.default.get(request)];
185
+ case 3: return [2 /*return*/, _b.apply(void 0, [_d.sent()])];
186
+ case 4:
187
+ _c = parseResponse;
188
+ return [4 /*yield*/, got_1.default.post(request)];
189
+ case 5: return [2 /*return*/, _c.apply(void 0, [_d.sent()])];
190
+ case 6: return [3 /*break*/, 8];
191
+ case 7:
192
+ error_2 = _d.sent();
193
+ gotError = error_2;
194
+ if (gotError.response) {
195
+ return [2 /*return*/, parseResponse(gotError.response)];
196
+ }
197
+ throw error_2;
198
+ case 8: throw new Error("Unsupported method: ".concat(method));
199
+ }
200
+ });
201
+ });
202
+ }
106
203
  function parseResponse(response) {
107
204
  return {
108
205
  status: response.statusCode,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aptos-labs/aptos-client",
3
- "description": "client package for accessing the Aptos network API",
3
+ "description": "Client package for accessing the Aptos network API.",
4
4
  "packageManager": "pnpm@8.3.1",
5
5
  "license": "Apache-2.0",
6
6
  "engines": {
@@ -8,14 +8,14 @@
8
8
  },
9
9
  "exports": {
10
10
  "browser": {
11
- "import": "./dist/browser/index.browser.mjs",
12
11
  "require": "./dist/browser/index.browser.js",
13
- "types": "./dist/browser/index.browser.d.ts"
12
+ "types": "./dist/browser/index.browser.d.ts",
13
+ "import": "./dist/browser/index.browser.mjs"
14
14
  },
15
15
  "node": {
16
- "import": "./dist/node/index.node.mjs",
17
16
  "require": "./dist/node/index.node.js",
18
- "types": "./dist/node/index.node.d.ts"
17
+ "types": "./dist/node/index.node.d.ts",
18
+ "import": "./dist/node/index.node.mjs"
19
19
  }
20
20
  },
21
21
  "browser": {
@@ -40,11 +40,11 @@
40
40
  },
41
41
  "repository": {
42
42
  "type": "git",
43
- "url": "https://github.com/aptos-labs/aptos-core.git"
43
+ "url": "https://github.com/aptos-labs/aptos-client.git"
44
44
  },
45
- "homepage": "https://github.com/aptos-labs/aptos-core",
45
+ "homepage": "https://github.com/aptos-labs/aptos-client",
46
46
  "bugs": {
47
- "url": "https://github.com/aptos-labs/aptos-core/issues"
47
+ "url": "https://github.com/aptos-labs/aptos-client/issues"
48
48
  },
49
49
  "author": "aptoslabs.com",
50
50
  "keywords": [
@@ -52,24 +52,24 @@
52
52
  "Aptos Labs",
53
53
  "Aptos SDK"
54
54
  ],
55
- "dependencies": {
56
- "axios": "1.7.4",
55
+ "peerDependencies": {
56
+ "axios": "^1.7.7",
57
57
  "got": "^11.8.6"
58
58
  },
59
59
  "devDependencies": {
60
- "@types/node": "20.10.4",
61
- "@typescript-eslint/eslint-plugin": "6.13.2",
62
- "@typescript-eslint/parser": "6.13.2",
63
- "eslint": "8.55.0",
60
+ "@types/node": "22.9.0",
61
+ "@typescript-eslint/eslint-plugin": "6.21.0",
62
+ "@typescript-eslint/parser": "6.21.0",
63
+ "eslint": "8.57.1",
64
64
  "eslint-config-prettier": "9.1.0",
65
65
  "eslint-config-airbnb-base": "15.0.0",
66
66
  "eslint-config-airbnb-typescript": "17.1.0",
67
- "eslint-plugin-import": "2.29.0",
68
- "prettier": "3.1.0",
69
- "semver": "6.3.1",
67
+ "eslint-plugin-import": "2.31.0",
68
+ "prettier": "3.3.3",
69
+ "semver": "7.6.3",
70
70
  "ts-node": "10.9.2",
71
- "tsup": "8.0.1",
72
- "typescript": "5.3.3"
71
+ "tsup": "8.3.5",
72
+ "typescript": "5.6.3"
73
73
  },
74
- "version": "0.1.1"
74
+ "version": "1.0.0"
75
75
  }