@binance/giftcard 4.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/LICENCE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Binance
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,181 @@
1
+ # Binance JavaScript Gift Card Connector
2
+
3
+ [![Open Issues](https://img.shields.io/github/issues/binance/binance-connector-js)](https://github.com/binance/binance-connector-js/issues)
4
+ [![Code Style: Prettier](https://img.shields.io/badge/code%20style-prettier-ff69b4)](https://prettier.io/)
5
+ [![npm version](https://badge.fury.io/js/@binance%2Fgift-card.svg)](https://badge.fury.io/js/@binance%2Fgift-card)
6
+ [![npm Downloads](https://img.shields.io/npm/dm/@binance/giftcard.svg)](https://www.npmjs.com/package/@binance/giftcard)
7
+ ![Node.js Version](https://img.shields.io/badge/Node.js-%3E=22.12.0-brightgreen)
8
+ [![Known Vulnerabilities](https://snyk.io/test/github/binance/binance-connector-js/badge.svg)](https://snyk.io/test/github/binance/binance-connector-js)
9
+ [![Docs](https://img.shields.io/badge/docs-online-blue?style=flat-square)](https://binance.github.io/binance-connector-js/modules/_binance_gift-card.html)
10
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
11
+
12
+ This is a client library for the Binance Gift Card API, enabling developers to interact programmatically with Binance's Gift Card trading platform. The library provides tools to perform crypto transfer and exchange through secured and prepaid codes through the REST API:
13
+
14
+ - [REST API](./src/rest-api/rest-api.ts)
15
+
16
+ ## Table of Contents
17
+
18
+ - [Supported Features](#supported-features)
19
+ - [Installation](#installation)
20
+ - [Documentation](#documentation)
21
+ - [REST APIs](#rest-apis)
22
+ - [Testing](#testing)
23
+ - [Migration Guide](#migration-guide)
24
+ - [Contributing](#contributing)
25
+ - [Licence](#licence)
26
+
27
+ ## Supported Features
28
+
29
+ - REST API Endpoints:
30
+ - `/sapi/v1/giftcard/*`
31
+ - Inclusion of test cases and examples for quick onboarding.
32
+
33
+ ## Installation
34
+
35
+ To use this library, ensure your environment is running Node.js version **22.12.0** or later. If you're using `nvm` (Node Version Manager), you can set the correct version as follows:
36
+
37
+ ```bash
38
+ nvm install 22.12.0
39
+ nvm use 22.12.0
40
+ ```
41
+
42
+ Then install the library using `npm`:
43
+
44
+ ```bash
45
+ npm install @binance/giftcard
46
+ ```
47
+
48
+ ## Documentation
49
+
50
+ For detailed information, refer to the [Binance API Documentation](https://developers.binance.com/docs/gift_card).
51
+
52
+ ### REST APIs
53
+
54
+ All REST API endpoints are available through the [`rest-api`](./src/rest-api/rest-api.ts) module. Note that some endpoints require authentication using your Binance API credentials.
55
+
56
+ ```typescript
57
+ import { GiftCard, GiftCardRestAPI } from '@binance/giftcard';
58
+
59
+ const configurationRestAPI = {
60
+ apiKey: 'your-api-key',
61
+ apiSecret: 'your-api-secret',
62
+ };
63
+ const client = new GiftCard({ configurationRestAPI });
64
+
65
+ client.restAPI
66
+ .createASingleTokenGiftCard({ token: '6H9EKF5ECCWFBHGE', amount: 1000 })
67
+ .then((res) => res.data())
68
+ .then((data: GiftCardRestAPI.CreateASingleTokenGiftCardResponse) => console.log(data))
69
+ .catch((err) => console.error(err));
70
+ ```
71
+
72
+ More examples can be found in the [`examples/rest-api`](./examples/rest-api/) folder.
73
+
74
+ #### Configuration Options
75
+
76
+ The REST API supports the following advanced configuration options:
77
+
78
+ - `timeout`: Timeout for requests in milliseconds (default: 1000 ms).
79
+ - `proxy`: Proxy configuration:
80
+ - `host`: Proxy server hostname.
81
+ - `port`: Proxy server port.
82
+ - `protocol`: Proxy protocol (http or https).
83
+ - `auth`: Proxy authentication credentials:
84
+ - `username`: Proxy username.
85
+ - `password`: Proxy password.
86
+ - `keepAlive`: Enable HTTP keep-alive (default: true).
87
+ - `compression`: Enable response compression (default: true).
88
+ - `retries`: Number of retry attempts for failed requests (default: 3).
89
+ - `backoff`: Delay in milliseconds between retries (default: 1000 ms).
90
+ - `httpsAgent`: Custom HTTPS agent for advanced TLS configuration.
91
+ - `privateKey`: RSA or ED25519 private key for authentication.
92
+ - `privateKeyPassphrase`: Passphrase for the private key, if encrypted.
93
+
94
+ ##### Timeout
95
+
96
+ You can configure a timeout for requests in milliseconds. If the request exceeds the specified timeout, it will be aborted. See the [Timeout example](./docs/rest-api/timeout.md) for detailed usage.
97
+
98
+ ##### Proxy
99
+
100
+ The REST API supports HTTP/HTTPS proxy configurations. See the [Proxy example](./docs/rest-api/proxy.md) for detailed usage.
101
+
102
+ ##### Keep-Alive
103
+
104
+ Enable HTTP keep-alive for persistent connections. See the [Keep-Alive example](./docs/rest-api/keepAlive.md) for detailed usage.
105
+
106
+ ##### Compression
107
+
108
+ Enable or disable response compression. See the [Compression example](./docs/rest-api/compression.md) for detailed usage.
109
+
110
+ ##### Retries
111
+
112
+ Configure the number of retry attempts and delay in milliseconds between retries for failed requests. See the [Retries example](./docs/rest-api/retries.md) for detailed usage.
113
+
114
+ ##### HTTPS Agent
115
+
116
+ Customize the HTTPS agent for advanced TLS configurations. See the [HTTPS Agent example](./docs/rest-api/httpsAgent.md) for detailed usage.
117
+
118
+ ##### Key Pair Based Authentication
119
+
120
+ The REST API supports key pair-based authentication for secure communication. You can use `RSA` or `ED25519` keys for signing requests. See the [Key Pair Based Authentication example](./docs/rest-api/key-pair-authentication.md) for detailed usage.
121
+
122
+ ##### Certificate Pinning
123
+
124
+ To enhance security, you can use certificate pinning with the `httpsAgent` option in the configuration. This ensures the client only communicates with servers using specific certificates. See the [Certificate Pinning example](./docs/rest-api/certificate-pinning.md) for detailed usage.
125
+
126
+ #### Error Handling
127
+
128
+ The REST API provides detailed error types to help you handle issues effectively:
129
+
130
+ - `ConnectorClientError`: General client error.
131
+ - `RequiredError`: Thrown when a required parameter is missing.
132
+ - `UnauthorizedError`: Indicates missing or invalid authentication credentials.
133
+ - `ForbiddenError`: Access to the requested resource is forbidden.
134
+ - `TooManyRequestsError`: Rate limit exceeded.
135
+ - `RateLimitBanError`: IP address banned for exceeding rate limits.
136
+ - `ServerError`: Internal server error.
137
+ - `NetworkError`: Issues with network connectivity.
138
+ - `NotFoundError`: Resource not found.
139
+ - `BadRequestError`: Invalid request.
140
+
141
+ See the [Error Handling example](./docs/rest-api/error-handling.md) for detailed usage.
142
+
143
+ If `basePath` is not provided, it defaults to `https://api.binance.com`.
144
+
145
+ ## Testing
146
+
147
+ To run the tests:
148
+
149
+ ```bash
150
+ npm install
151
+
152
+ npm run test
153
+ ```
154
+
155
+ The tests cover:
156
+
157
+ - REST API endpoints
158
+ - Error handling and edge cases
159
+
160
+ ## Migration Guide
161
+
162
+ If you are upgrading to the new modularized structure, refer to the [Migration Guide](./docs/migration_guide_gift_card_connector.md) for detailed steps.
163
+
164
+ ## Contributing
165
+
166
+ Contributions are welcome!
167
+
168
+ Since this repository contains auto-generated code, we encourage you to start by opening a GitHub issue to discuss your ideas or suggest improvements. This helps ensure that changes align with the project's goals and auto-generation processes.
169
+
170
+ To contribute:
171
+
172
+ 1. Open a GitHub issue describing your suggestion or the bug you've identified.
173
+ 2. If it's determined that changes are necessary, the maintainers will merge the changes into the main branch.
174
+
175
+ Please ensure that all tests pass if you're making a direct contribution. Submit a pull request only after discussing and confirming the change.
176
+
177
+ Thank you for your contributions!
178
+
179
+ ## Licence
180
+
181
+ This project is licensed under the MIT License. See the [LICENCE](./LICENCE) file for details.
package/dist/chunk.mjs ADDED
@@ -0,0 +1,13 @@
1
+ //#region rolldown:runtime
2
+ var __defProp = Object.defineProperty;
3
+ var __export = (all) => {
4
+ let target = {};
5
+ for (var name in all) __defProp(target, name, {
6
+ get: all[name],
7
+ enumerable: true
8
+ });
9
+ return target;
10
+ };
11
+
12
+ //#endregion
13
+ export { __export as t };