@monerium/sdk 2.12.1 → 2.13.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +31 -34
- package/dist/index.d.ts +568 -4
- package/dist/index.js +31 -1
- package/dist/index.mjs +6 -1092
- package/package.json +31 -18
- package/dist/client.d.ts +0 -112
- package/dist/config.d.ts +0 -3
- package/dist/constants.d.ts +0 -9
- package/dist/helpers/auth.helpers.d.ts +0 -23
- package/dist/helpers/index.d.ts +0 -2
- package/dist/helpers/service.helpers.d.ts +0 -1
- package/dist/package.json +0 -41
- package/dist/types.d.ts +0 -373
- package/dist/utils.d.ts +0 -28
package/README.md
CHANGED
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
| [Monerium.com](https://monerium.com/) | [Monerium.app](https://monerium.app/) | [Monerium.dev](https://monerium.dev/) |
|
|
2
|
+
| ------------------------------------- | ------------------------------------- | ------------------------------------- |
|
|
3
|
+
|
|
1
4
|
# Monerium SDK Documentation
|
|
2
5
|
|
|
3
6
|
Monerium connects your web3 wallet to any euro bank account with your personal IBAN.
|
|
@@ -5,6 +8,13 @@ All incoming euro payments are automatically minted as EURe tokens to your walle
|
|
|
5
8
|
Sending EURe to traditional bank accounts is just as easy.
|
|
6
9
|
With a single signature from your wallet, your EURe is burned and sent as Euros to any bank account.
|
|
7
10
|
|
|
11
|
+
## Useful resources
|
|
12
|
+
|
|
13
|
+
- [Documentation](./docs/generated/README.md)
|
|
14
|
+
- [API Documentation](https://monerium.dev/api-docs)
|
|
15
|
+
- [Developer portal](https://monerium.dev/')
|
|
16
|
+
- [NPM](https://www.npmjs.com/package/@monerium/sdk)
|
|
17
|
+
|
|
8
18
|
## Table of Contents
|
|
9
19
|
|
|
10
20
|
- [Installation](#installation)
|
|
@@ -49,7 +59,7 @@ yarn add @monerium/sdk
|
|
|
49
59
|
|
|
50
60
|
## Usage Examples
|
|
51
61
|
|
|
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.
|
|
62
|
+
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.
|
|
53
63
|
|
|
54
64
|
#### Initialize and authenticate using Client Credentials
|
|
55
65
|
|
|
@@ -87,7 +97,7 @@ API documentation:
|
|
|
87
97
|
|
|
88
98
|
> 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.
|
|
89
99
|
|
|
90
|
-
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.
|
|
100
|
+
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.
|
|
91
101
|
|
|
92
102
|
```ts
|
|
93
103
|
import { MoneriumClient } from '@monerium/sdk';
|
|
@@ -163,7 +173,9 @@ API documentation:
|
|
|
163
173
|
const authCtx: AuthContext = await monerium.getAuthContext();
|
|
164
174
|
|
|
165
175
|
// Fetching all accounts for a specific profile
|
|
166
|
-
const { id: profileId, accounts }: Profile = await monerium.getProfile(
|
|
176
|
+
const { id: profileId, accounts }: Profile = await monerium.getProfile(
|
|
177
|
+
authCtx.profiles[0].id
|
|
178
|
+
);
|
|
167
179
|
|
|
168
180
|
// Fetching all balances for a specific profile
|
|
169
181
|
const balances: Balances = await monerium.getBalances(profileId);
|
|
@@ -199,7 +211,7 @@ API documentation:
|
|
|
199
211
|
|
|
200
212
|
#### Link a new address to Monerium
|
|
201
213
|
|
|
202
|
-
It's important to understand
|
|
214
|
+
It's important to understand when interacting with a blockchain, the user needs to provide a signature in their wallet.
|
|
203
215
|
This signature is used to verify that the user is the owner of the wallet address.
|
|
204
216
|
|
|
205
217
|
We recommend Viem as an Ethereum interface, see: https://viem.sh/docs/actions/wallet/signMessage.html
|
|
@@ -302,7 +314,8 @@ When placing orders with payouts above 15,000 EUR, a supporting document is requ
|
|
|
302
314
|
|
|
303
315
|
```ts
|
|
304
316
|
// Upload a supporting document
|
|
305
|
-
const supportingDocumentId: SupportingDoc =
|
|
317
|
+
const supportingDocumentId: SupportingDoc =
|
|
318
|
+
await uploadSupportingDocument(document);
|
|
306
319
|
```
|
|
307
320
|
|
|
308
321
|
Interfaces:
|
|
@@ -350,45 +363,27 @@ monerium.subscribeOrders(OrderState.processed, (notification) => {
|
|
|
350
363
|
|
|
351
364
|
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.
|
|
352
365
|
|
|
353
|
-
We are using
|
|
366
|
+
We are using PNPM as a package manager.
|
|
354
367
|
|
|
355
|
-
|
|
356
|
-
# Install dependencies
|
|
357
|
-
nx run sdk:init
|
|
368
|
+
#### Development mode
|
|
358
369
|
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
# Run Vite in watch mode to detect changes to files during development
|
|
363
|
-
nx run sdk:build --watch
|
|
364
|
-
|
|
365
|
-
# Update the docs. This will run the build and update the docs in the static folder.
|
|
366
|
-
# Open static/index.html in your browser to view the docs. Refresh the page to see changes.
|
|
367
|
-
nx run sdk:docs:watch
|
|
370
|
+
```
|
|
371
|
+
pnpm dev
|
|
368
372
|
```
|
|
369
373
|
|
|
370
|
-
|
|
374
|
+
While in development mode, TypeScript declaration maps (`.d.ts.map`) are generated. TypeScript declaration maps are mainly used to quickly jump to type definitions in the context of a monorepo.
|
|
371
375
|
|
|
372
|
-
|
|
376
|
+
#### Build
|
|
373
377
|
|
|
374
|
-
```sh
|
|
375
|
-
YARN_IGNORE_PATH=1 yarn link
|
|
376
378
|
```
|
|
377
|
-
|
|
378
|
-
Use `yarn link "@monerium/sdk"` to link and test into your current project.
|
|
379
|
-
|
|
380
|
-
```sh
|
|
381
|
-
cd ../your-project
|
|
382
|
-
yarn link "@monerium/sdk"
|
|
379
|
+
pnpm build
|
|
383
380
|
```
|
|
384
381
|
|
|
385
|
-
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.
|
|
386
|
-
|
|
387
382
|
### Documentation
|
|
388
383
|
|
|
389
|
-
Refer to [Typedocs](https://typedoc.org/) syntaxes to use for this [documentation](https://monerium.github.io/js-
|
|
384
|
+
Refer to [Typedocs](https://typedoc.org/) syntaxes to use for this [documentation](https://monerium.github.io/js-monorepo/).
|
|
390
385
|
|
|
391
|
-
There is a Github action that will automatically run on the successful release of the SDK. It will generate a static output of the documentation and push it to the `gh-pages` branch. The documentation is then available at https://monerium.github.io/js-
|
|
386
|
+
There is a Github action that will automatically run on the successful release of the SDK. It will generate a static output of the documentation and push it to the `gh-pages` branch. The documentation is then available at https://monerium.github.io/js-monorepo/.
|
|
392
387
|
|
|
393
388
|
#### Publishing
|
|
394
389
|
|
|
@@ -401,9 +396,11 @@ Common questions developers have regarding the SDK.
|
|
|
401
396
|
## Support
|
|
402
397
|
|
|
403
398
|
[Support](https://monerium.app/help)
|
|
399
|
+
|
|
404
400
|
[Telegram](https://t.me/+lGtM1gY9zWthNGE8)
|
|
405
|
-
|
|
401
|
+
|
|
402
|
+
[Github Issues](https://github.com/monerium/js-monorepo/issues)
|
|
406
403
|
|
|
407
404
|
## Release Notes
|
|
408
405
|
|
|
409
|
-
https://github.com/monerium/js-
|
|
406
|
+
https://github.com/monerium/js-monorepo/releases
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,568 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
type Environment = {
|
|
2
|
+
api: string;
|
|
3
|
+
web: string;
|
|
4
|
+
wss: string;
|
|
5
|
+
};
|
|
6
|
+
type Config = {
|
|
7
|
+
environments: {
|
|
8
|
+
production: Environment;
|
|
9
|
+
sandbox: Environment;
|
|
10
|
+
};
|
|
11
|
+
};
|
|
12
|
+
type ENV = 'sandbox' | 'production';
|
|
13
|
+
type EthereumTestnet = 'sepolia';
|
|
14
|
+
type GnosisTestnet = 'chiado';
|
|
15
|
+
type PolygonTestnet = 'amoy';
|
|
16
|
+
type Chain = 'ethereum' | 'gnosis' | 'polygon';
|
|
17
|
+
type Networks = EthereumTestnet | GnosisTestnet | PolygonTestnet | 'mainnet';
|
|
18
|
+
type NetworkSemiStrict<C extends Chain> = C extends 'ethereum' ? EthereumTestnet | 'mainnet' : C extends 'gnosis' ? GnosisTestnet | 'mainnet' : C extends 'polygon' ? PolygonTestnet | 'mainnet' : never;
|
|
19
|
+
type NetworkStrict<C extends Chain, E extends ENV> = E extends 'production' ? 'mainnet' : E extends 'sandbox' ? C extends 'ethereum' ? EthereumTestnet : C extends 'gnosis' ? GnosisTestnet : C extends 'polygon' ? PolygonTestnet : never : never;
|
|
20
|
+
type Network<C extends Chain = Chain, E extends ENV = ENV> = C extends Chain ? E extends ENV ? NetworkStrict<C, E> & NetworkSemiStrict<C> : never : never;
|
|
21
|
+
type ChainId = number | 1 | 11155111 | 100 | 137 | 10200 | 80002;
|
|
22
|
+
declare enum Currency {
|
|
23
|
+
eur = "eur",
|
|
24
|
+
usd = "usd",
|
|
25
|
+
gbp = "gbp",
|
|
26
|
+
isk = "isk"
|
|
27
|
+
}
|
|
28
|
+
type TokenSymbol = 'EURe' | 'GBPe' | 'USDe' | 'ISKe';
|
|
29
|
+
type Ticker = 'EUR' | 'GBP' | 'USD' | 'ISK';
|
|
30
|
+
type AuthArgs = Omit<AuthCodeRequest, 'grant_type'> | Omit<RefreshTokenRequest, 'grant_type'> | Omit<ClientCredentialsRequest, 'grant_type'>;
|
|
31
|
+
type OpenArgs = Omit<AuthCodeRequest, 'grant_type' | 'code' | 'code_verifier'> | Omit<RefreshTokenRequest, 'grant_type'> | Omit<ClientCredentialsRequest, 'grant_type'> | PKCERequestArgs;
|
|
32
|
+
/** One of the options for the {@link AuthArgs}.
|
|
33
|
+
*
|
|
34
|
+
* [Auth endpoint in API documentation:](https://monerium.dev/api-docs#operation/auth).
|
|
35
|
+
* */
|
|
36
|
+
interface AuthCodeRequest {
|
|
37
|
+
grant_type: 'authorization_code';
|
|
38
|
+
client_id: string;
|
|
39
|
+
code: string;
|
|
40
|
+
code_verifier: string;
|
|
41
|
+
redirect_uri: string;
|
|
42
|
+
scope?: string;
|
|
43
|
+
}
|
|
44
|
+
/** One of the options for the {@link AuthArgs}.
|
|
45
|
+
*
|
|
46
|
+
* [Auth endpoint in API documentation:](https://monerium.dev/api-docs#operation/auth).
|
|
47
|
+
* */
|
|
48
|
+
interface RefreshTokenRequest {
|
|
49
|
+
grant_type: 'refresh_token';
|
|
50
|
+
client_id: string;
|
|
51
|
+
refresh_token: string;
|
|
52
|
+
scope?: string;
|
|
53
|
+
}
|
|
54
|
+
/** One of the options for the {@link AuthArgs}.
|
|
55
|
+
*
|
|
56
|
+
* [Auth endpoint in API documentation:](https://monerium.dev/api-docs#operation/auth).
|
|
57
|
+
* */
|
|
58
|
+
interface ClientCredentialsRequest {
|
|
59
|
+
grant_type: 'client_credentials';
|
|
60
|
+
client_id: string;
|
|
61
|
+
client_secret: string;
|
|
62
|
+
scope?: string;
|
|
63
|
+
}
|
|
64
|
+
interface BearerProfile {
|
|
65
|
+
access_token: string;
|
|
66
|
+
token_type: string;
|
|
67
|
+
expires_in: number;
|
|
68
|
+
refresh_token: string;
|
|
69
|
+
profile: string;
|
|
70
|
+
userId: string;
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* @returns A {@link PKCERequest} object with properties omitted that are automatically computed in by the SDK.
|
|
74
|
+
*/
|
|
75
|
+
type PKCERequestArgs = Omit<PKCERequest, 'code_challenge' | 'code_challenge_method' | 'response_type'>;
|
|
76
|
+
type PKCERequest = {
|
|
77
|
+
/** the authentication flow client id of the application */
|
|
78
|
+
client_id: string;
|
|
79
|
+
/** the code challenge automatically generated by the SDK */
|
|
80
|
+
code_challenge: string;
|
|
81
|
+
/** the code challenge method for the authentication flow , handled by the SDK */
|
|
82
|
+
code_challenge_method: 'S256';
|
|
83
|
+
/** the response type of the authentication flow, handled by the SDK */
|
|
84
|
+
response_type: 'code';
|
|
85
|
+
/** the state of the application */
|
|
86
|
+
state?: string;
|
|
87
|
+
/** the redirect uri of the application */
|
|
88
|
+
redirect_uri: string;
|
|
89
|
+
/** the scope of the application */
|
|
90
|
+
scope?: string;
|
|
91
|
+
/** the address of the wallet to automatically link */
|
|
92
|
+
address?: string;
|
|
93
|
+
/** the signature of the wallet to automatically link */
|
|
94
|
+
signature?: string;
|
|
95
|
+
/** @deprecated - Use chainId */
|
|
96
|
+
network?: Network;
|
|
97
|
+
/** @deprecated - Use chainId */
|
|
98
|
+
chain?: Chain;
|
|
99
|
+
/** The network of the wallet to automatically link */
|
|
100
|
+
chainId?: ChainId;
|
|
101
|
+
};
|
|
102
|
+
declare enum Method {
|
|
103
|
+
password = "password",
|
|
104
|
+
resource = "resource",
|
|
105
|
+
jwt = "jwt",
|
|
106
|
+
apiKey = "apiKey"
|
|
107
|
+
}
|
|
108
|
+
declare enum ProfileType {
|
|
109
|
+
corporate = "corporate",
|
|
110
|
+
personal = "personal"
|
|
111
|
+
}
|
|
112
|
+
declare enum Permission {
|
|
113
|
+
read = "read",
|
|
114
|
+
write = "write"
|
|
115
|
+
}
|
|
116
|
+
interface AuthProfile {
|
|
117
|
+
id: string;
|
|
118
|
+
type: ProfileType;
|
|
119
|
+
name: string;
|
|
120
|
+
perms: Permission[];
|
|
121
|
+
}
|
|
122
|
+
interface AuthContext {
|
|
123
|
+
userId: string;
|
|
124
|
+
email: string;
|
|
125
|
+
name: string;
|
|
126
|
+
roles: 'admin'[];
|
|
127
|
+
auth: {
|
|
128
|
+
method: Method;
|
|
129
|
+
subject: string;
|
|
130
|
+
verified: boolean;
|
|
131
|
+
};
|
|
132
|
+
defaultProfile: string;
|
|
133
|
+
profiles: AuthProfile[];
|
|
134
|
+
}
|
|
135
|
+
declare enum KYCState {
|
|
136
|
+
absent = "absent",
|
|
137
|
+
submitted = "submitted",
|
|
138
|
+
pending = "pending",
|
|
139
|
+
confirmed = "confirmed"
|
|
140
|
+
}
|
|
141
|
+
declare enum KYCOutcome {
|
|
142
|
+
approved = "approved",
|
|
143
|
+
rejected = "rejected",
|
|
144
|
+
unknown = "unknown"
|
|
145
|
+
}
|
|
146
|
+
declare enum AccountState {
|
|
147
|
+
requested = "requested",
|
|
148
|
+
approved = "approved",
|
|
149
|
+
pending = "pending"
|
|
150
|
+
}
|
|
151
|
+
interface KYC {
|
|
152
|
+
state: KYCState;
|
|
153
|
+
outcome: KYCOutcome;
|
|
154
|
+
}
|
|
155
|
+
declare enum PaymentStandard {
|
|
156
|
+
iban = "iban",
|
|
157
|
+
scan = "scan",
|
|
158
|
+
chain = "chain"
|
|
159
|
+
}
|
|
160
|
+
interface Identifier {
|
|
161
|
+
standard: PaymentStandard;
|
|
162
|
+
bic?: string;
|
|
163
|
+
}
|
|
164
|
+
interface Account {
|
|
165
|
+
address: string;
|
|
166
|
+
currency: Currency;
|
|
167
|
+
standard: PaymentStandard;
|
|
168
|
+
iban?: string;
|
|
169
|
+
network?: Network;
|
|
170
|
+
chain: Chain;
|
|
171
|
+
id?: string;
|
|
172
|
+
state?: AccountState;
|
|
173
|
+
}
|
|
174
|
+
interface Profile {
|
|
175
|
+
id: string;
|
|
176
|
+
name: string;
|
|
177
|
+
email: string;
|
|
178
|
+
kyc: KYC;
|
|
179
|
+
kind: ProfileType;
|
|
180
|
+
accounts: Account[];
|
|
181
|
+
}
|
|
182
|
+
interface Balance {
|
|
183
|
+
currency: Currency;
|
|
184
|
+
amount: string;
|
|
185
|
+
}
|
|
186
|
+
interface Balances {
|
|
187
|
+
id: string;
|
|
188
|
+
address: string;
|
|
189
|
+
chain: Chain;
|
|
190
|
+
network: Network;
|
|
191
|
+
balances: Balance[];
|
|
192
|
+
}
|
|
193
|
+
declare enum OrderKind {
|
|
194
|
+
redeem = "redeem",
|
|
195
|
+
issue = "issue"
|
|
196
|
+
}
|
|
197
|
+
declare enum OrderState {
|
|
198
|
+
placed = "placed",
|
|
199
|
+
pending = "pending",
|
|
200
|
+
processed = "processed",
|
|
201
|
+
rejected = "rejected"
|
|
202
|
+
}
|
|
203
|
+
interface Fee {
|
|
204
|
+
provider: 'satchel';
|
|
205
|
+
currency: Currency;
|
|
206
|
+
amount: string;
|
|
207
|
+
}
|
|
208
|
+
interface IBAN extends Identifier {
|
|
209
|
+
standard: PaymentStandard.iban;
|
|
210
|
+
iban: string;
|
|
211
|
+
}
|
|
212
|
+
interface CrossChain extends Identifier {
|
|
213
|
+
standard: PaymentStandard.chain;
|
|
214
|
+
address: string;
|
|
215
|
+
chainId: ChainId;
|
|
216
|
+
/** @deprecated - Use chainId */
|
|
217
|
+
chain?: Chain;
|
|
218
|
+
/** @deprecated - Use chainId */
|
|
219
|
+
network?: Network;
|
|
220
|
+
}
|
|
221
|
+
interface SCAN extends Identifier {
|
|
222
|
+
standard: PaymentStandard.scan;
|
|
223
|
+
sortCode: string;
|
|
224
|
+
accountNumber: string;
|
|
225
|
+
}
|
|
226
|
+
interface Individual {
|
|
227
|
+
firstName: string;
|
|
228
|
+
lastName: string;
|
|
229
|
+
country?: string;
|
|
230
|
+
}
|
|
231
|
+
interface Corporation {
|
|
232
|
+
companyName: string;
|
|
233
|
+
country: string;
|
|
234
|
+
}
|
|
235
|
+
interface Counterpart {
|
|
236
|
+
identifier: IBAN | SCAN | CrossChain;
|
|
237
|
+
details: Individual | Corporation;
|
|
238
|
+
}
|
|
239
|
+
interface OrderMetadata {
|
|
240
|
+
approvedAt: string;
|
|
241
|
+
processedAt: string;
|
|
242
|
+
rejectedAt: string;
|
|
243
|
+
state: OrderState;
|
|
244
|
+
placedBy: string;
|
|
245
|
+
placedAt: string;
|
|
246
|
+
receivedAmount: string;
|
|
247
|
+
sentAmount: string;
|
|
248
|
+
}
|
|
249
|
+
interface OrderFilter {
|
|
250
|
+
address?: string;
|
|
251
|
+
txHash?: string;
|
|
252
|
+
profile?: string;
|
|
253
|
+
memo?: string;
|
|
254
|
+
accountId?: string;
|
|
255
|
+
state?: OrderState;
|
|
256
|
+
}
|
|
257
|
+
interface Order {
|
|
258
|
+
id: string;
|
|
259
|
+
profile: string;
|
|
260
|
+
accountId: string;
|
|
261
|
+
address: string;
|
|
262
|
+
kind: OrderKind;
|
|
263
|
+
amount: string;
|
|
264
|
+
currency: Currency;
|
|
265
|
+
totalFee: string;
|
|
266
|
+
fees: Fee[];
|
|
267
|
+
counterpart: Counterpart;
|
|
268
|
+
memo: string;
|
|
269
|
+
rejectedReason: string;
|
|
270
|
+
supportingDocumentId: string;
|
|
271
|
+
meta: OrderMetadata;
|
|
272
|
+
}
|
|
273
|
+
/**
|
|
274
|
+
* Information about the EURe token on different networks.
|
|
275
|
+
*/
|
|
276
|
+
interface Token {
|
|
277
|
+
currency: Currency;
|
|
278
|
+
ticker: Ticker;
|
|
279
|
+
symbol: TokenSymbol;
|
|
280
|
+
chain: Chain;
|
|
281
|
+
network: Network;
|
|
282
|
+
/** The address of the EURe contract on this network */
|
|
283
|
+
address: string;
|
|
284
|
+
/** How many decimals this token supports */
|
|
285
|
+
decimals: number;
|
|
286
|
+
}
|
|
287
|
+
type NewOrder = NewOrderByAddress | NewOrderByAccountId;
|
|
288
|
+
interface NewOrderCommon {
|
|
289
|
+
amount: string;
|
|
290
|
+
signature: string;
|
|
291
|
+
currency?: Currency /** Not needed right now, only EUR */;
|
|
292
|
+
counterpart: Counterpart;
|
|
293
|
+
message: string;
|
|
294
|
+
memo?: string;
|
|
295
|
+
supportingDocumentId?: string;
|
|
296
|
+
}
|
|
297
|
+
interface NewOrderByAddress extends NewOrderCommon {
|
|
298
|
+
address: string;
|
|
299
|
+
/** @deprecated - Use 'chainId' */
|
|
300
|
+
chain?: Chain;
|
|
301
|
+
/** @deprecated - Use 'chainId' */
|
|
302
|
+
network?: Network;
|
|
303
|
+
chainId: ChainId;
|
|
304
|
+
}
|
|
305
|
+
interface NewOrderByAccountId extends NewOrderCommon {
|
|
306
|
+
accountId: string;
|
|
307
|
+
}
|
|
308
|
+
interface SupportingDocMetadata {
|
|
309
|
+
uploadedBy: string;
|
|
310
|
+
createdAt: string;
|
|
311
|
+
updatedAt: string;
|
|
312
|
+
}
|
|
313
|
+
interface SupportingDoc {
|
|
314
|
+
id: string;
|
|
315
|
+
name: string;
|
|
316
|
+
type: string;
|
|
317
|
+
size: number;
|
|
318
|
+
hash: string;
|
|
319
|
+
meta: SupportingDocMetadata;
|
|
320
|
+
}
|
|
321
|
+
interface CurrencyAccounts {
|
|
322
|
+
/** @deprecated - Use 'chainId' */
|
|
323
|
+
network?: Network;
|
|
324
|
+
/** @deprecated - Use 'chainId' */
|
|
325
|
+
chain?: Chain;
|
|
326
|
+
chainId: ChainId;
|
|
327
|
+
currency: Currency;
|
|
328
|
+
}
|
|
329
|
+
interface LinkAddress {
|
|
330
|
+
address: string;
|
|
331
|
+
message: string;
|
|
332
|
+
signature: string;
|
|
333
|
+
accounts: CurrencyAccounts[];
|
|
334
|
+
/** @deprecated - Use 'chainId' */
|
|
335
|
+
network?: Network;
|
|
336
|
+
/** @deprecated - Use 'chainId' */
|
|
337
|
+
chain?: Chain;
|
|
338
|
+
chainId?: ChainId;
|
|
339
|
+
}
|
|
340
|
+
interface OrderNotification {
|
|
341
|
+
id: string;
|
|
342
|
+
profile: string;
|
|
343
|
+
accountId: string;
|
|
344
|
+
address: string;
|
|
345
|
+
kind: string;
|
|
346
|
+
amount: string;
|
|
347
|
+
currency: string;
|
|
348
|
+
totalFee: string;
|
|
349
|
+
fees: Fee[];
|
|
350
|
+
counterpart: Counterpart;
|
|
351
|
+
memo: string;
|
|
352
|
+
rejectedReason: string;
|
|
353
|
+
supportingDocumentId: string;
|
|
354
|
+
meta: OrderMetadata;
|
|
355
|
+
}
|
|
356
|
+
type MoneriumEvent = OrderState;
|
|
357
|
+
type MoneriumEventListener = (notification: OrderNotification) => void;
|
|
358
|
+
type ClassOptions = {
|
|
359
|
+
environment?: ENV;
|
|
360
|
+
} & BearerTokenCredentials;
|
|
361
|
+
interface AuthFlowOptions {
|
|
362
|
+
clientId?: string;
|
|
363
|
+
redirectUrl?: string;
|
|
364
|
+
address?: string;
|
|
365
|
+
signature?: string;
|
|
366
|
+
chainId?: ChainId;
|
|
367
|
+
state?: string;
|
|
368
|
+
}
|
|
369
|
+
interface ClientCredentials {
|
|
370
|
+
clientId: string;
|
|
371
|
+
clientSecret: string;
|
|
372
|
+
}
|
|
373
|
+
interface AuthorizationCodeCredentials {
|
|
374
|
+
clientId: string;
|
|
375
|
+
redirectUrl: string;
|
|
376
|
+
}
|
|
377
|
+
type BearerTokenCredentials = ClientCredentials | AuthorizationCodeCredentials;
|
|
378
|
+
|
|
379
|
+
declare class MoneriumClient {
|
|
380
|
+
#private;
|
|
381
|
+
/**
|
|
382
|
+
* The PKCE code verifier
|
|
383
|
+
* @deprecated, use localStorage, will be removed in v3
|
|
384
|
+
* @hidden
|
|
385
|
+
* */
|
|
386
|
+
codeVerifier?: string;
|
|
387
|
+
/**
|
|
388
|
+
* The bearer profile will be available after authentication, it includes the `access_token` and `refresh_token`
|
|
389
|
+
* */
|
|
390
|
+
bearerProfile?: BearerProfile;
|
|
391
|
+
isAuthorized: boolean;
|
|
392
|
+
/**
|
|
393
|
+
* The state parameter is used to maintain state between the request and the callback.
|
|
394
|
+
* */
|
|
395
|
+
state: string | undefined;
|
|
396
|
+
/**
|
|
397
|
+
* @defaultValue `sandbox`
|
|
398
|
+
* @example
|
|
399
|
+
* new MoneriumClient() // defaults to `sandbox`
|
|
400
|
+
*
|
|
401
|
+
* new MoneriumClient('production')
|
|
402
|
+
*
|
|
403
|
+
* new MoneriumClient({
|
|
404
|
+
* environment: 'sandbox',
|
|
405
|
+
* clientId: 'your-client-id',
|
|
406
|
+
* redirectUrl: 'your-redirect-url'
|
|
407
|
+
* })
|
|
408
|
+
* */
|
|
409
|
+
constructor(envOrOptions?: ENV | ClassOptions);
|
|
410
|
+
/**
|
|
411
|
+
* Construct the url to the authorization code flow,
|
|
412
|
+
* Code Verifier needed for the code challenge is stored in local storage
|
|
413
|
+
* For automatic wallet link, add the following properties: `address`, `signature` & `chainId`
|
|
414
|
+
* @returns string
|
|
415
|
+
* {@link https://monerium.dev/api-docs#operation/auth}
|
|
416
|
+
* @category Auth
|
|
417
|
+
*/
|
|
418
|
+
authorize(client?: AuthFlowOptions): Promise<void>;
|
|
419
|
+
/**
|
|
420
|
+
* Get access to the API
|
|
421
|
+
* @param {AuthorizationCodeCredentials | ClientCredentials} client - the client credentials
|
|
422
|
+
* @returns boolean to indicate if access has been granted
|
|
423
|
+
* @category Auth
|
|
424
|
+
*/
|
|
425
|
+
getAccess(client?: AuthorizationCodeCredentials | ClientCredentials): Promise<boolean>;
|
|
426
|
+
/**
|
|
427
|
+
* {@link https://monerium.dev/api-docs#operation/auth-context}
|
|
428
|
+
* @category Auth
|
|
429
|
+
*/
|
|
430
|
+
getAuthContext(): Promise<AuthContext>;
|
|
431
|
+
/**
|
|
432
|
+
* {@link https://monerium.dev/api-docs#operation/profile}
|
|
433
|
+
* @param {string} profileId - the id of the profile to fetch.
|
|
434
|
+
* @category Profiles
|
|
435
|
+
*/
|
|
436
|
+
getProfile(profileId: string): Promise<Profile>;
|
|
437
|
+
/**
|
|
438
|
+
* {@link https://monerium.dev/api-docs#operation/profile-balances}
|
|
439
|
+
* @param {string=} profileId - the id of the profile to fetch balances.
|
|
440
|
+
* @category Accounts
|
|
441
|
+
*/
|
|
442
|
+
getBalances(profileId?: string): Promise<Balances[]>;
|
|
443
|
+
/**
|
|
444
|
+
* {@link https://monerium.dev/api-docs#operation/orders}
|
|
445
|
+
* @category Orders
|
|
446
|
+
*/
|
|
447
|
+
getOrders(filter?: OrderFilter): Promise<Order[]>;
|
|
448
|
+
/**
|
|
449
|
+
* {@link https://monerium.dev/api-docs#operation/order}
|
|
450
|
+
* @category Orders
|
|
451
|
+
*/
|
|
452
|
+
getOrder(orderId: string): Promise<Order>;
|
|
453
|
+
/**
|
|
454
|
+
* {@link https://monerium.dev/api-docs#operation/tokens}
|
|
455
|
+
* @category Tokens
|
|
456
|
+
*/
|
|
457
|
+
getTokens(): Promise<Token[]>;
|
|
458
|
+
/**
|
|
459
|
+
* {@link https://monerium.dev/api-docs#operation/profile-addresses}
|
|
460
|
+
* @category Accounts
|
|
461
|
+
*/
|
|
462
|
+
linkAddress(profileId: string, body: LinkAddress): Promise<unknown>;
|
|
463
|
+
/**
|
|
464
|
+
* {@link https://monerium.dev/api-docs#operation/post-orders}
|
|
465
|
+
* @category Orders
|
|
466
|
+
*/
|
|
467
|
+
placeOrder(order: NewOrder, profileId?: string): Promise<Order>;
|
|
468
|
+
/**
|
|
469
|
+
* {@link https://monerium.dev/api-docs#operation/supporting-document}
|
|
470
|
+
* @category Orders
|
|
471
|
+
*/
|
|
472
|
+
uploadSupportingDocument(document: File): Promise<SupportingDoc>;
|
|
473
|
+
/**
|
|
474
|
+
* Connects to the order notifications socket
|
|
475
|
+
* @category Orders
|
|
476
|
+
*/
|
|
477
|
+
connectOrderSocket(): Promise<void>;
|
|
478
|
+
/**
|
|
479
|
+
* Subscribes to the order notifications socket
|
|
480
|
+
* @category Orders
|
|
481
|
+
*/
|
|
482
|
+
subscribeToOrderNotifications: () => WebSocket;
|
|
483
|
+
/**
|
|
484
|
+
* Cleanups the socket and the subscriptions
|
|
485
|
+
* @category Auth
|
|
486
|
+
*/
|
|
487
|
+
disconnect(): Promise<void>;
|
|
488
|
+
/**
|
|
489
|
+
* Revokes access
|
|
490
|
+
* @category Auth
|
|
491
|
+
*/
|
|
492
|
+
revokeAccess(): Promise<void>;
|
|
493
|
+
/**
|
|
494
|
+
* Subscribe to MoneriumEvent to receive notifications using the Monerium API (WebSocket)
|
|
495
|
+
* We are setting a subscription map because we need the user to have a token to start the WebSocket connection
|
|
496
|
+
* {@link https://monerium.dev/api-docs#operation/profile-orders-notifications}
|
|
497
|
+
* @param event The event to subscribe to
|
|
498
|
+
* @param handler The handler to be called when the event is triggered
|
|
499
|
+
* @category Orders
|
|
500
|
+
*/
|
|
501
|
+
subscribeOrders(event: MoneriumEvent, handler: MoneriumEventListener): void;
|
|
502
|
+
/**
|
|
503
|
+
* Unsubscribe from MoneriumEvent and close the socket if there are no more subscriptions
|
|
504
|
+
* @param event The event to unsubscribe from
|
|
505
|
+
* @category Orders
|
|
506
|
+
*/
|
|
507
|
+
unsubscribeOrders(event: MoneriumEvent): void;
|
|
508
|
+
/**
|
|
509
|
+
* @deprecated since v2.6.4, will be removed in 2.7.2+, use {@link getAccess} instead.
|
|
510
|
+
* @hidden
|
|
511
|
+
*/
|
|
512
|
+
auth: (args: AuthArgs) => Promise<BearerProfile>;
|
|
513
|
+
/**
|
|
514
|
+
* @deprecated since v2.7.1, will be removed in 2.7.2+, use {@link getAccess} instead.
|
|
515
|
+
* @hidden
|
|
516
|
+
*/
|
|
517
|
+
connect: (args: AuthArgs) => Promise<BearerProfile>;
|
|
518
|
+
/**
|
|
519
|
+
* @deprecated since v2.6.4, will be removed in 2.7.2+, use {@link authorize} instead.
|
|
520
|
+
* @hidden
|
|
521
|
+
*/
|
|
522
|
+
getAuthFlowURI: (args: PKCERequestArgs) => string;
|
|
523
|
+
/**
|
|
524
|
+
* @deprecated since v2.0.7, will be removed in 2.7.2+, use {@link getAuthFlowURI} instead.
|
|
525
|
+
* @hidden
|
|
526
|
+
*/
|
|
527
|
+
pkceRequest: (args: PKCERequestArgs) => string;
|
|
528
|
+
/**
|
|
529
|
+
* @hidden
|
|
530
|
+
*/
|
|
531
|
+
getEnvironment: () => Environment;
|
|
532
|
+
}
|
|
533
|
+
|
|
534
|
+
declare const _default: {
|
|
535
|
+
/**
|
|
536
|
+
* The message used to link addresses.
|
|
537
|
+
*/
|
|
538
|
+
LINK_MESSAGE: string;
|
|
539
|
+
/**
|
|
540
|
+
* The key used to store the code verifier in the local storage.
|
|
541
|
+
*/
|
|
542
|
+
STORAGE_CODE_VERIFIER: string;
|
|
543
|
+
/**
|
|
544
|
+
* The key used to store the refresh token in the local storage.
|
|
545
|
+
*/
|
|
546
|
+
STORAGE_REFRESH_TOKEN: string;
|
|
547
|
+
};
|
|
548
|
+
|
|
549
|
+
declare const rfc3339: (d: Date) => string;
|
|
550
|
+
/**
|
|
551
|
+
* The message to be signed when placing an order.
|
|
552
|
+
*
|
|
553
|
+
* @returns string
|
|
554
|
+
*/
|
|
555
|
+
declare const placeOrderMessage: (amount: string | number, receiver: string, chainId?: number, currency?: 'eur' | 'gbp' | 'usd' | 'isk') => string;
|
|
556
|
+
/**
|
|
557
|
+
* Get the corresponding Monerium SDK Chain from the current chain id
|
|
558
|
+
* @returns The Chain
|
|
559
|
+
*/
|
|
560
|
+
declare const getChain: (chainId: number) => Chain;
|
|
561
|
+
/**
|
|
562
|
+
* Get the corresponding Monerium SDK Network from the current chain id
|
|
563
|
+
* @returns The Network
|
|
564
|
+
* @deprecated network will be removed from Monerium API in the near future.
|
|
565
|
+
*/
|
|
566
|
+
declare const getNetwork: (chainId: number) => Networks;
|
|
567
|
+
|
|
568
|
+
export { type Account, AccountState, type AuthArgs, type AuthCodeRequest, type AuthContext, type AuthFlowOptions, type AuthProfile, type AuthorizationCodeCredentials, type Balance, type Balances, type BearerProfile, type BearerTokenCredentials, type Chain, type ChainId, type ClassOptions, type ClientCredentials, type ClientCredentialsRequest, type Config, type Corporation, type Counterpart, type CrossChain, Currency, type CurrencyAccounts, type ENV, type Environment, type EthereumTestnet, type Fee, type GnosisTestnet, type IBAN, type Identifier, type Individual, type KYC, KYCOutcome, KYCState, type LinkAddress, Method, MoneriumClient, type MoneriumEvent, type MoneriumEventListener, type Network, type NetworkSemiStrict, type NetworkStrict, type Networks, type NewOrder, type NewOrderByAccountId, type NewOrderByAddress, type NewOrderCommon, type OpenArgs, type Order, type OrderFilter, OrderKind, type OrderMetadata, type OrderNotification, OrderState, type PKCERequest, type PKCERequestArgs, PaymentStandard, Permission, type PolygonTestnet, type Profile, ProfileType, type RefreshTokenRequest, type SCAN, type SupportingDoc, type SupportingDocMetadata, type Ticker, type Token, type TokenSymbol, _default as constants, MoneriumClient as default, getChain, getNetwork, placeOrderMessage, rfc3339 };
|