@monerium/sdk 2.6.4 → 2.7.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/CHANGELOG.md +507 -49
- package/README.md +303 -66
- package/dist/client.d.ts +99 -0
- package/dist/config.d.ts +3 -0
- package/dist/constants.d.ts +9 -0
- package/dist/helpers/auth.helpers.d.ts +23 -0
- package/dist/helpers/index.d.ts +2 -0
- package/dist/helpers/service.helpers.d.ts +1 -0
- package/dist/index.d.ts +4 -334
- package/dist/index.js +1 -0
- package/dist/index.mjs +542 -364
- package/dist/package.json +41 -0
- package/dist/types.d.ts +348 -0
- package/dist/utils.d.ts +27 -0
- package/package.json +16 -46
- package/dist/index.mjs.map +0 -1
- package/dist/index.umd.js +0 -2
- package/dist/index.umd.js.map +0 -1
package/README.md
CHANGED
|
@@ -1,122 +1,339 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Monerium SDK Documentation
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Monerium connects your web3 wallet to any euro bank account with your personal IBAN.
|
|
4
|
+
All incoming euro payments are automatically minted as EURe tokens to your wallet.
|
|
5
|
+
Sending EURe to traditional bank accounts is just as easy.
|
|
6
|
+
With a single signature from your wallet, your EURe is burned and sent as Euros to any bank account.
|
|
4
7
|
|
|
5
|
-
|
|
6
|
-
that may change the behavior of your application before you upgrade. If you find any issues please report them [here](https://github.com/monerium/sdk/issues)._
|
|
8
|
+
## Table of Contents
|
|
7
9
|
|
|
8
|
-
[
|
|
10
|
+
- [Installation](#installation)
|
|
11
|
+
- [Configuration](#configuration)
|
|
12
|
+
- [Usage Examples](#usage-examples)
|
|
13
|
+
- [API Reference](#api-reference)
|
|
14
|
+
- [Contributing](#contributing)
|
|
15
|
+
- [FAQs](#faqs)
|
|
16
|
+
- [Support](#support)
|
|
17
|
+
- [Release Notes](#release-notes)
|
|
18
|
+
- [License](#license)
|
|
9
19
|
|
|
10
|
-
|
|
20
|
+
## Installation
|
|
11
21
|
|
|
12
|
-
|
|
22
|
+
### Prerequisites
|
|
13
23
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
[Code coverage](https://monerium.github.io/sdk/coverage)
|
|
17
|
-
|
|
18
|
-
## Installing
|
|
24
|
+
Node v16.15 or higher is required.
|
|
19
25
|
|
|
20
26
|
```sh
|
|
21
|
-
# Node
|
|
22
27
|
yarn add @monerium/sdk
|
|
23
28
|
```
|
|
24
29
|
|
|
25
|
-
##
|
|
30
|
+
## Configuration
|
|
31
|
+
|
|
32
|
+
### Environments - URLs
|
|
26
33
|
|
|
27
|
-
|
|
28
|
-
|
|
34
|
+
| Environment | Web | API |
|
|
35
|
+
| ----------- | -------------------- | ------------------------ |
|
|
36
|
+
| sandbox | https://monerium.dev | https://api.monerium.dev |
|
|
37
|
+
| production | https://monerium.app | https://api.monerium.app |
|
|
29
38
|
|
|
30
|
-
### Environments
|
|
39
|
+
### Environments - Networks
|
|
31
40
|
|
|
32
|
-
|
|
41
|
+
| Environment | Chain | Network |
|
|
42
|
+
| ----------- | -------- | ------- |
|
|
43
|
+
| sandbox | ethereum | goerli |
|
|
44
|
+
| | polygon | mumbai |
|
|
45
|
+
| | gnosis | chiado |
|
|
46
|
+
| production | ethereum | mainnet |
|
|
47
|
+
| | polygon | mainnet |
|
|
48
|
+
| | gnosis | mainnet |
|
|
33
49
|
|
|
34
|
-
|
|
50
|
+
## Usage Examples
|
|
51
|
+
|
|
52
|
+
We recommend starting in the [Developer Portal](https://monerium.dev/docs/welcome). There you will learn more about `client_id`'s and ways of authenticating.
|
|
35
53
|
|
|
36
|
-
|
|
54
|
+
#### Initialize and authenticate using Client Credentials
|
|
37
55
|
|
|
38
|
-
|
|
56
|
+
> Client Credentials is used when there's no need for user interaction, and the system-to-system interaction requires authentication.
|
|
39
57
|
|
|
40
|
-
|
|
58
|
+
```ts
|
|
59
|
+
import { MoneriumClient } from '@monerium/sdk';
|
|
60
|
+
// Initialize the client with credentials
|
|
61
|
+
const monerium = new MoneriumClient({
|
|
62
|
+
environment: 'sandbox',
|
|
63
|
+
clientId: 'your_client_credentials_uuid', // replace with your client ID
|
|
64
|
+
clientSecret: 'your_client_secret', // replace with your client secret
|
|
65
|
+
});
|
|
41
66
|
|
|
42
|
-
|
|
67
|
+
// Retrieve authentication data after successful authentication.
|
|
68
|
+
await monerium.getAuthContext();
|
|
43
69
|
|
|
44
|
-
|
|
70
|
+
// Access tokens are now available for use.
|
|
71
|
+
const { access_token, refresh_token } = monerium.bearerProfile as BearerProfile;
|
|
72
|
+
```
|
|
45
73
|
|
|
46
|
-
|
|
74
|
+
Interfaces:
|
|
47
75
|
|
|
48
|
-
|
|
76
|
+
- {@link client.MoneriumClient}
|
|
77
|
+
- {@link types.BearerProfile}
|
|
78
|
+
|
|
79
|
+
API documentation:
|
|
80
|
+
|
|
81
|
+
- [/auth/token](https://monerium.dev/api-docs#operation/auth-token)
|
|
82
|
+
- [/auth/context](https://monerium.dev/api-docs#operation/auth-context)
|
|
83
|
+
|
|
84
|
+
#### Initialize and authenticate using Authorization Code Flow with PKCE
|
|
85
|
+
|
|
86
|
+
> Authorization Code Flow with PKCE is used for apps where direct user interaction is involved, and the application is running on an environment where the confidentiality of a secret cannot be safely maintained. It allows the application to authorize users without handling their passwords and mitigates the additional risk involved in this sort of delegation.
|
|
87
|
+
|
|
88
|
+
First you have to navigate the user to the Monerium authentication flow. This can be done by generating a URL and redirecting the user to it. After the user has authenticated, Monerium will redirect back to your specified URI with a code. You can then finalize the authentication process by exchanging the code for access and refresh tokens.
|
|
49
89
|
|
|
50
90
|
```ts
|
|
51
91
|
import { MoneriumClient } from '@monerium/sdk';
|
|
52
92
|
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
const
|
|
93
|
+
export function App() {
|
|
94
|
+
const [authCtx, setAuthCtx] = useState<AuthContext | null>(null);
|
|
95
|
+
const [monerium, setMonerium] = useState<MoneriumClient>();
|
|
96
|
+
const [isAuthorized, setIsAuthorized] = useState<boolean>(false);
|
|
97
|
+
|
|
98
|
+
useEffect(() => {
|
|
99
|
+
const sdk = new MoneriumClient({
|
|
100
|
+
environment: 'sandbox',
|
|
101
|
+
clientId: 'f99e629b-6dca-11ee-8aa6-5273f65ed05b',
|
|
102
|
+
redirectUrl: 'http://localhost:4200',
|
|
103
|
+
});
|
|
104
|
+
setMonerium(sdk);
|
|
105
|
+
}, []);
|
|
106
|
+
|
|
107
|
+
useEffect(() => {
|
|
108
|
+
const connect = async () => {
|
|
109
|
+
if (monerium) {
|
|
110
|
+
setIsAuthorized(await monerium.connect());
|
|
111
|
+
}
|
|
112
|
+
};
|
|
113
|
+
|
|
114
|
+
connect();
|
|
115
|
+
|
|
116
|
+
return () => {
|
|
117
|
+
if (monerium) {
|
|
118
|
+
monerium.disconnect();
|
|
119
|
+
}
|
|
120
|
+
};
|
|
121
|
+
}, [monerium]);
|
|
122
|
+
|
|
123
|
+
useEffect(() => {
|
|
124
|
+
const fetchData = async () => {
|
|
125
|
+
if (monerium && isAuthorized) {
|
|
126
|
+
try {
|
|
127
|
+
setAuthCtx(await monerium.getAuthContext());
|
|
128
|
+
} catch (err) {
|
|
129
|
+
console.error('Error fetching data:', err);
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
};
|
|
133
|
+
fetchData();
|
|
134
|
+
}, [monerium, isAuthorized]);
|
|
135
|
+
|
|
136
|
+
return (
|
|
137
|
+
<div>
|
|
138
|
+
{!isAuthorized && <button onClick={() => monerium?.authorize()}>Connect</button>}
|
|
139
|
+
|
|
140
|
+
<p>{authCtx?.name || authCtx?.email}</p>
|
|
141
|
+
</div>
|
|
142
|
+
);
|
|
143
|
+
}
|
|
56
144
|
```
|
|
57
145
|
|
|
58
|
-
|
|
146
|
+
Interfaces:
|
|
147
|
+
|
|
148
|
+
- {@link types.AuthCodeRequest}
|
|
149
|
+
- {@link types.BearerProfile}
|
|
150
|
+
|
|
151
|
+
API documentation:
|
|
152
|
+
|
|
153
|
+
- [/auth](https://monerium.dev/api-docs#operation/auth)
|
|
154
|
+
- [/auth/token](https://monerium.dev/api-docs#operation/auth-token)
|
|
155
|
+
- [/auth/context](https://monerium.dev/api-docs#operation/auth-context)
|
|
156
|
+
|
|
157
|
+
#### Get account information
|
|
59
158
|
|
|
60
159
|
```ts
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
client_secret: "your_client_secret"
|
|
64
|
-
})
|
|
160
|
+
// Get all profiles for the authenticated user.
|
|
161
|
+
const authCtx: AuthContext = await monerium.getAuthContext();
|
|
65
162
|
|
|
66
|
-
//
|
|
67
|
-
await
|
|
163
|
+
// Fetching all accounts for a specific profile
|
|
164
|
+
const { id: profileId, accounts }: Profile = await monerium.getProfile(authCtx.profiles[0].id);
|
|
68
165
|
|
|
69
|
-
//
|
|
70
|
-
const
|
|
166
|
+
// Fetching all balances for a specific profile
|
|
167
|
+
const balances: Balances = await monerium.getBalances(profileId);
|
|
71
168
|
```
|
|
72
169
|
|
|
73
|
-
|
|
170
|
+
Interfaces:
|
|
171
|
+
|
|
172
|
+
- {@link types.AuthContext}
|
|
173
|
+
- {@link types.Profile}
|
|
174
|
+
- {@link types.Balances}
|
|
175
|
+
|
|
176
|
+
API documentation:
|
|
177
|
+
|
|
178
|
+
- [/auth/context](https://monerium.dev/api-docs#operation/auth-context)
|
|
179
|
+
- [/profile](https://monerium.dev/api-docs#operation/profile)
|
|
180
|
+
- [/profile/{profiledId}/balances](https://monerium.dev/api-docs#operation/profile-balances)
|
|
181
|
+
|
|
182
|
+
#### Get token information
|
|
183
|
+
|
|
184
|
+
Get the contract addresses of EURe tokens.
|
|
185
|
+
|
|
186
|
+
```ts
|
|
187
|
+
const tokens: Token[] = await monerium.getTokens();
|
|
188
|
+
```
|
|
189
|
+
|
|
190
|
+
Interfaces:
|
|
191
|
+
|
|
192
|
+
- {@link types.Token}
|
|
193
|
+
|
|
194
|
+
API documentation:
|
|
195
|
+
|
|
196
|
+
- [/tokens](https://monerium.dev/api-docs#operation/tokens)
|
|
197
|
+
|
|
198
|
+
#### Link a new address to Monerium
|
|
199
|
+
|
|
200
|
+
It's important to understand, when interacting with a blockchain, the user needs to provide a signature in their wallet.
|
|
201
|
+
This signature is used to verify that the user is the owner of the wallet address.
|
|
202
|
+
|
|
203
|
+
We recommend Viem as an Ethereum interface, see: https://viem.sh/docs/actions/wallet/signMessage.html
|
|
74
204
|
|
|
75
205
|
```ts
|
|
76
|
-
// Construct the authFlowUrl for your application and redirect your customer.
|
|
77
|
-
let authFlowUrl = client.getAuthFlowURI({
|
|
78
|
-
client_id: "your_client_authflow_uuid",
|
|
79
|
-
redirect_uri: "http://your-webpage.com/monerium-integration"
|
|
80
|
-
// optional automatic wallet selection:
|
|
81
|
-
network: "mumbai",
|
|
82
|
-
chain: "polygon",
|
|
83
|
-
address: "0xValidAddress72413Fa92980B889A1eCE84dD",
|
|
84
|
-
signature: "0xValidSignature0df2b6c9e0fc067ab29bdbf322bec30aad7c46dcd97f62498a91ef7795957397e0f49426e000b0f500c347219ddd98dc5080982563055e918031c"
|
|
85
206
|
|
|
207
|
+
import { constants } from '@monerium/sdk';
|
|
208
|
+
import { walletClient } from '...' // See Viem documentation
|
|
209
|
+
|
|
210
|
+
const { LINK_MESSAGE } = constants; // "I hereby declare that I am the address owner."
|
|
211
|
+
|
|
212
|
+
// Send a signature request to the wallet.
|
|
213
|
+
const signature = await walletClient.signMessage({
|
|
214
|
+
message: LINK_MESSAGE,
|
|
86
215
|
})
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
216
|
+
|
|
217
|
+
// Link a new address to Monerium and create accounts for ethereum and gnosis.
|
|
218
|
+
await monerium.linkAddress(profileId, {
|
|
219
|
+
address: '0xUserAddress72413Fa92980B889A1eCE84dD', // user wallet address
|
|
220
|
+
message: LINK_MESSAGE
|
|
221
|
+
signature,
|
|
222
|
+
accounts: [
|
|
223
|
+
{"currency":"eur","chain":"ethereum","network":"goerli"},
|
|
224
|
+
{"currency":"eur","chain":"gnosis","network":"chiado"}
|
|
225
|
+
],
|
|
226
|
+
} as LinkAddress);
|
|
227
|
+
```
|
|
228
|
+
|
|
229
|
+
Interfaces:
|
|
230
|
+
|
|
231
|
+
- {@link types.LinkAddress}
|
|
232
|
+
|
|
233
|
+
API documentation:
|
|
234
|
+
|
|
235
|
+
- [/profile/{profiledId}/addresses](https://monerium.dev/api-docs#operation/profile-addresses)
|
|
236
|
+
|
|
237
|
+
#### Get and place orders
|
|
238
|
+
|
|
239
|
+
```ts
|
|
240
|
+
// Get orders for a specific profile
|
|
241
|
+
const orders: Order[] = await monerium.getOrders(profileId);
|
|
91
242
|
```
|
|
92
243
|
|
|
93
244
|
```ts
|
|
94
|
-
//
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
245
|
+
// Place a redeem order
|
|
246
|
+
import { placeOrderMessage } from '@monerium/sdk';
|
|
247
|
+
import { walletClient } from '...'; // See Viem documentation
|
|
248
|
+
|
|
249
|
+
const amount = '100'; // replace with the amount in EUR
|
|
250
|
+
const iban = 'EE12341234123412341234'; // replace with requested IBAN
|
|
251
|
+
|
|
252
|
+
// First you have to form the message that will be signed by the user
|
|
253
|
+
const message = placeOrderMessage(amount, iban);
|
|
254
|
+
|
|
255
|
+
// The message should look like this, with the current date and time in RFC3339 format:
|
|
256
|
+
// Send EUR 100 to EE12341234123412341234 at Thu, 29 Dec 2022 14:58:29Z
|
|
257
|
+
|
|
258
|
+
// Send a signature request to the wallet.
|
|
259
|
+
const signature = await walletClient.signMessage({
|
|
260
|
+
message: message,
|
|
102
261
|
});
|
|
103
262
|
|
|
104
|
-
//
|
|
105
|
-
await
|
|
263
|
+
// Place the order
|
|
264
|
+
const order = await monerium.placeOrder({
|
|
265
|
+
amount,
|
|
266
|
+
signature,
|
|
267
|
+
address: '0xUserAddress72413Fa92980B889A1eCE84dD', // user wallet address
|
|
268
|
+
counterpart: {
|
|
269
|
+
identifier: {
|
|
270
|
+
standard: 'iban', // PaymentStandard.iban,
|
|
271
|
+
iban,
|
|
272
|
+
},
|
|
273
|
+
details: {
|
|
274
|
+
firstName: 'User',
|
|
275
|
+
lastName: 'Userson',
|
|
276
|
+
county: 'IS',
|
|
277
|
+
},
|
|
278
|
+
},
|
|
279
|
+
message,
|
|
280
|
+
memo: 'Powered by Monerium SDK',
|
|
281
|
+
chain: 'ethereum',
|
|
282
|
+
network: 'goerli',
|
|
283
|
+
// supportingDocumentId, see below
|
|
284
|
+
});
|
|
285
|
+
```
|
|
286
|
+
|
|
287
|
+
Interfaces:
|
|
288
|
+
|
|
289
|
+
- {@link types.Order}
|
|
290
|
+
- {@link types.PaymentStandard}
|
|
291
|
+
|
|
292
|
+
API documentation:
|
|
106
293
|
|
|
107
|
-
|
|
108
|
-
|
|
294
|
+
- [GET /orders](https://monerium.dev/api-docs#operation/orders)
|
|
295
|
+
- [POST /orders](https://monerium.dev/api-docs#operation/post-orders)
|
|
296
|
+
|
|
297
|
+
#### Add supporting documents
|
|
298
|
+
|
|
299
|
+
When placing orders with payouts above 15,000 EUR, a supporting document is required. The document must be uploaded to Monerium before the order can be placed. Supporting documents can be an invoice or an agreement.
|
|
300
|
+
|
|
301
|
+
```ts
|
|
302
|
+
// Upload a supporting document
|
|
303
|
+
const supportingDocumentId: SupportingDoc = await uploadSupportingDocument(document);
|
|
109
304
|
```
|
|
110
305
|
|
|
306
|
+
Interfaces:
|
|
307
|
+
|
|
308
|
+
- {@link types.SupportingDoc}
|
|
309
|
+
|
|
310
|
+
API documentation:
|
|
311
|
+
|
|
312
|
+
- [/files](https://monerium.dev/api-docs#operation/supporting-document)
|
|
313
|
+
|
|
314
|
+
## API Reference
|
|
315
|
+
|
|
316
|
+
[API Documentation](https://monerium.dev/docs/api)
|
|
317
|
+
|
|
111
318
|
## Contributing
|
|
112
319
|
|
|
113
320
|
We are using [commitlint](https://github.com/conventional-changelog/commitlint/tree/master/@commitlint/config-conventional) to enforce that developers format the commit messages according to the [Conventional Commits](https://www.conventionalcommits.org/en/v1.0.0/) guidelines.
|
|
114
321
|
|
|
115
322
|
We are using Yarn as a package manager.
|
|
116
323
|
|
|
117
|
-
```
|
|
324
|
+
```sh
|
|
325
|
+
# Install dependencies
|
|
118
326
|
yarn
|
|
327
|
+
|
|
328
|
+
# Run Vite to build a production release distributable
|
|
119
329
|
yarn build
|
|
330
|
+
|
|
331
|
+
# Run Vite in watch mode to detect changes to files during development
|
|
332
|
+
yarn watch
|
|
333
|
+
|
|
334
|
+
# Update the docs. This will run the build and update the docs in the static folder.
|
|
335
|
+
# Open static/index.html in your browser to view the docs. Refresh the page to see changes.
|
|
336
|
+
yarn docs:watch
|
|
120
337
|
```
|
|
121
338
|
|
|
122
339
|
Smart IDEs (such as VSCode) require [special configuration](https://yarnpkg.com/getting-started/editor-sdks) for TypeScript to work when using Yarn Plug'n'Play installs.
|
|
@@ -138,6 +355,26 @@ cd ../your-project
|
|
|
138
355
|
yarn link "@monerium/sdk"
|
|
139
356
|
```
|
|
140
357
|
|
|
141
|
-
|
|
358
|
+
If you get an error that there is already a package called '@monerium/sdk' registered, but you can't find it and unlinking does nothing, remove it manually with `rm -rf ~/.config/yarn/link/@monerium` and try again.
|
|
359
|
+
|
|
360
|
+
#### Documentation
|
|
361
|
+
|
|
362
|
+
Refer to [Typedocs](https://typedoc.org/) syntaxes to use for this [documentation](https://monerium.github.io/sdk/).
|
|
363
|
+
|
|
364
|
+
#### Publishing
|
|
142
365
|
|
|
143
366
|
When changes are merged to the `main` branch that follows the [conventional commits](https://www.conventionalcommits.org/en/v1.0.0/) standard, [release-please](https://github.com/googleapis/release-please) workflow creates a pull request, preparing for the next release. If kept open, the following commits will also be added to the PR. Merging that PR will create a new release, a workflow will publish it on NPM and tag it on Github.
|
|
367
|
+
|
|
368
|
+
## FAQs
|
|
369
|
+
|
|
370
|
+
Common questions developers have regarding the SDK.
|
|
371
|
+
|
|
372
|
+
## Support
|
|
373
|
+
|
|
374
|
+
[Support](https://monerium.app/help)
|
|
375
|
+
[Telegram](https://t.me/+lGtM1gY9zWthNGE8)
|
|
376
|
+
[Github Issues](https://github.com/monerium/sdk/issues)
|
|
377
|
+
|
|
378
|
+
## Release Notes
|
|
379
|
+
|
|
380
|
+
https://github.com/monerium/sdk/releases
|
package/dist/client.d.ts
ADDED
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import type { AuthArgs, AuthorizationCodeCredentials, AuthContext, Balances, BearerProfile, ClassOptions, ENV, Environment, LinkAddress, MoneriumEvent, MoneriumEventListener, NewOrder, AuthFlowOptions, Order, OrderFilter, PKCERequestArgs, Profile, SupportingDoc, Token, ClientCredentials } from './types';
|
|
2
|
+
export declare class MoneriumClient {
|
|
3
|
+
#private;
|
|
4
|
+
/**
|
|
5
|
+
* @deprecated, use sessionStorage
|
|
6
|
+
* The PKCE code verifier
|
|
7
|
+
* */
|
|
8
|
+
codeVerifier?: string;
|
|
9
|
+
/** The bearer profile will be available after authentication, it includes the access_token and refresh_token */
|
|
10
|
+
bearerProfile?: BearerProfile;
|
|
11
|
+
isAuthorized: boolean;
|
|
12
|
+
/** Constructor for no arguments, defaults to sandbox */
|
|
13
|
+
constructor();
|
|
14
|
+
/** Constructor with only env as an argument*/
|
|
15
|
+
constructor(env: ENV);
|
|
16
|
+
/** Constructor with {@link ClassOptions} */
|
|
17
|
+
constructor(options: ClassOptions);
|
|
18
|
+
/**
|
|
19
|
+
* Construct the url to the authorization code flow,
|
|
20
|
+
* Code Verifier needed for the code challenge is stored in session storage
|
|
21
|
+
* For automatic wallet link, add the following properties: `address`, `signature` & `chainId`
|
|
22
|
+
* @returns string
|
|
23
|
+
* {@link https://monerium.dev/api-docs#operation/auth}
|
|
24
|
+
*/
|
|
25
|
+
authorize(client?: AuthFlowOptions): Promise<void>;
|
|
26
|
+
connect(client?: AuthorizationCodeCredentials | ClientCredentials): Promise<boolean>;
|
|
27
|
+
/**
|
|
28
|
+
* {@link https://monerium.dev/api-docs#operation/auth-token}
|
|
29
|
+
*/
|
|
30
|
+
getBearerToken(args: AuthArgs): Promise<BearerProfile>;
|
|
31
|
+
/**
|
|
32
|
+
* {@link https://monerium.dev/api-docs#operation/auth-context}
|
|
33
|
+
*/
|
|
34
|
+
getAuthContext(): Promise<AuthContext>;
|
|
35
|
+
/**
|
|
36
|
+
* {@link https://monerium.dev/api-docs#operation/profile}
|
|
37
|
+
* @param {string} profileId - the id of the profile to fetch.
|
|
38
|
+
|
|
39
|
+
*/
|
|
40
|
+
getProfile(profileId: string): Promise<Profile>;
|
|
41
|
+
/**
|
|
42
|
+
* {@link https://monerium.dev/api-docs#operation/profile-balances}
|
|
43
|
+
* @param {string=} profileId - the id of the profile to fetch balances.
|
|
44
|
+
*/
|
|
45
|
+
getBalances(profileId?: string): Promise<Balances[]>;
|
|
46
|
+
/**
|
|
47
|
+
* {@link https://monerium.dev/api-docs#operation/orders}
|
|
48
|
+
*/
|
|
49
|
+
getOrders(filter?: OrderFilter): Promise<Order[]>;
|
|
50
|
+
/**
|
|
51
|
+
* {@link https://monerium.dev/api-docs#operation/order}
|
|
52
|
+
*/
|
|
53
|
+
getOrder(orderId: string): Promise<Order>;
|
|
54
|
+
/**
|
|
55
|
+
* {@link https://monerium.dev/api-docs#operation/tokens}
|
|
56
|
+
*/
|
|
57
|
+
getTokens(): Promise<Token[]>;
|
|
58
|
+
/**
|
|
59
|
+
* {@link https://monerium.dev/api-docs#operation/profile-addresses}
|
|
60
|
+
*/
|
|
61
|
+
linkAddress(profileId: string, body: LinkAddress): Promise<unknown>;
|
|
62
|
+
/**
|
|
63
|
+
* {@link https://monerium.dev/api-docs#operation/post-orders}
|
|
64
|
+
*/
|
|
65
|
+
placeOrder(order: NewOrder, profileId?: string): Promise<Order>;
|
|
66
|
+
/**
|
|
67
|
+
* {@link https://monerium.dev/api-docs#operation/supporting-document}
|
|
68
|
+
*/
|
|
69
|
+
uploadSupportingDocument(document: File): Promise<SupportingDoc>;
|
|
70
|
+
connectOrderSocket(): Promise<void>;
|
|
71
|
+
subscribeToOrderNotifications: () => WebSocket;
|
|
72
|
+
disconnect(): Promise<void>;
|
|
73
|
+
/**
|
|
74
|
+
* Subscribe to MoneriumEvent to receive notifications using the Monerium API (WebSocket)
|
|
75
|
+
* We are setting a subscription map because we need the user to have a token to start the WebSocket connection
|
|
76
|
+
* {@link https://monerium.dev/api-docs#operation/profile-orders-notifications}
|
|
77
|
+
* @param event The event to subscribe to
|
|
78
|
+
* @param handler The handler to be called when the event is triggered
|
|
79
|
+
*/
|
|
80
|
+
subscribeOrders(event: MoneriumEvent, handler: MoneriumEventListener): void;
|
|
81
|
+
/**
|
|
82
|
+
* Unsubscribe from MoneriumEvent and close the socket if there are no more subscriptions
|
|
83
|
+
* @param event The event to unsubscribe from
|
|
84
|
+
*/
|
|
85
|
+
unsubscribeOrders(event: MoneriumEvent): void;
|
|
86
|
+
/**
|
|
87
|
+
* @deprecated since v2.6.4, use {@link getBearerToken} instead.
|
|
88
|
+
*/
|
|
89
|
+
auth: (args: AuthArgs) => Promise<BearerProfile>;
|
|
90
|
+
/**
|
|
91
|
+
* @deprecated since v2.6.4, use {@link authorize} instead.
|
|
92
|
+
*/
|
|
93
|
+
getAuthFlowURI: (args: PKCERequestArgs) => string;
|
|
94
|
+
/**
|
|
95
|
+
* @deprecated since v2.0.7, use {@link getAuthFlowURI} instead.
|
|
96
|
+
*/
|
|
97
|
+
pkceRequest: (args: PKCERequestArgs) => string;
|
|
98
|
+
getEnvironment: () => Environment;
|
|
99
|
+
}
|
package/dist/config.d.ts
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export declare const LINK_MESSAGE = "I hereby declare that I am the address owner.";
|
|
2
|
+
export declare const STORAGE_CODE_VERIFIER = "monerium.sdk.code_verifier";
|
|
3
|
+
export declare const STORAGE_REFRESH_TOKEN = "monerium.sdk.refresh_token";
|
|
4
|
+
declare const constants: {
|
|
5
|
+
LINK_MESSAGE: string;
|
|
6
|
+
STORAGE_CODE_VERIFIER: string;
|
|
7
|
+
STORAGE_REFRESH_TOKEN: string;
|
|
8
|
+
};
|
|
9
|
+
export default constants;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { AuthArgs, AuthCodeRequest, ClientCredentialsRequest, PKCERequestArgs, RefreshTokenRequest } from '../types';
|
|
2
|
+
/** Structure the Auth Flow params, support for ChainId instead of chain & network */
|
|
3
|
+
export declare const getAuthFlowParams: (args: PKCERequestArgs, codeChallenge: string) => string | undefined;
|
|
4
|
+
/**
|
|
5
|
+
* Find a more secure way to generate a random string
|
|
6
|
+
* Using crypto-js to generate a random string was causing the following error:
|
|
7
|
+
* `Error: Native crypto module could not be used to get secure random number.`
|
|
8
|
+
* https://github.com/brix/crypto-js/issues/256
|
|
9
|
+
*/
|
|
10
|
+
export declare const generateRandomString: () => string;
|
|
11
|
+
/** Generate the PKCE code challenge */
|
|
12
|
+
export declare const generateCodeChallenge: (codeVerifier: string) => string;
|
|
13
|
+
/**
|
|
14
|
+
* Constructs the Auth Flow URL and stores the code verifier in the session storage
|
|
15
|
+
*/
|
|
16
|
+
export declare const getAuthFlowUrlAndStoreCodeVerifier: (baseUrl: string, args: PKCERequestArgs) => string;
|
|
17
|
+
/**
|
|
18
|
+
* Clean the query string from the URL
|
|
19
|
+
*/
|
|
20
|
+
export declare const cleanQueryString: () => void;
|
|
21
|
+
export declare const isAuthCode: (args: AuthArgs) => args is AuthCodeRequest;
|
|
22
|
+
export declare const isRefreshToken: (args: AuthArgs) => args is RefreshTokenRequest;
|
|
23
|
+
export declare const isClientCredentials: (args: AuthArgs) => args is ClientCredentialsRequest;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const rest: <T>(url: string, method: string, body?: BodyInit | Record<string, string>, headers?: Record<string, string>) => Promise<T>;
|