@monerium/sdk 2.13.3 → 2.14.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 +46 -21
- package/dist/index.d.ts +36 -44
- package/dist/index.js +11 -12
- package/dist/index.mjs +4 -4
- package/package.json +1 -3
package/README.md
CHANGED
|
@@ -3,17 +3,43 @@
|
|
|
3
3
|
|
|
4
4
|
# Monerium SDK Documentation
|
|
5
5
|
|
|
6
|
+
<a href="https://monerium.dev/">
|
|
7
|
+
<picture>
|
|
8
|
+
<source media="(prefers-color-scheme: dark)" srcset="https://img.shields.io/badge/Developer_portal-2c6ca7">
|
|
9
|
+
<img src="https://img.shields.io/badge/Developer_portal-2c6ca7" alt="Static Badge">
|
|
10
|
+
</picture>
|
|
11
|
+
</a>
|
|
12
|
+
<a href="https://monerium.dev/api-docs">
|
|
13
|
+
<picture>
|
|
14
|
+
<source media="(prefers-color-scheme: dark)" srcset="https://img.shields.io/badge/API_documentation-2c6ca7">
|
|
15
|
+
<img src="https://img.shields.io/badge/API_documentation-2c6ca7" alt="Static Badge">
|
|
16
|
+
</picture>
|
|
17
|
+
</a>
|
|
18
|
+
</br>
|
|
19
|
+
<a href="https://www.npmjs.com/package/@monerium/sdk">
|
|
20
|
+
<picture>
|
|
21
|
+
<source media="(prefers-color-scheme: dark)" srcset="https://img.shields.io/npm/v/%40monerium%2Fsdk?colorA=2c6ca7&colorB=21262d">
|
|
22
|
+
<img src="https://img.shields.io/npm/v/%40monerium%2Fsdk?colorA=f6f8fa&colorB=f6f8fa" alt="Version">
|
|
23
|
+
</picture>
|
|
24
|
+
</a>
|
|
25
|
+
<a href="https://github.com/monerium/js-monorepo/issues>
|
|
26
|
+
<picture>
|
|
27
|
+
<source media="(prefers-color-scheme: dark)" srcset="https://img.shields.io/github/issues/monerium/js-monorepo?colorA=2c6ca7&colorB=21262d">
|
|
28
|
+
<img src="https://img.shields.io/github/issues/monerium/js-monorepo?colorA=2c6ca7&colorB=21262d" alt="Version">
|
|
29
|
+
</picture>
|
|
30
|
+
</a>
|
|
31
|
+
|
|
32
|
+
## Introduction
|
|
33
|
+
|
|
6
34
|
Monerium connects your web3 wallet to any euro bank account with your personal IBAN.
|
|
7
35
|
All incoming euro payments are automatically minted as EURe tokens to your wallet.
|
|
8
36
|
Sending EURe to traditional bank accounts is just as easy.
|
|
9
37
|
With a single signature from your wallet, your EURe is burned and sent as Euros to any bank account.
|
|
10
38
|
|
|
11
|
-
##
|
|
39
|
+
## Documentation
|
|
12
40
|
|
|
13
41
|
- [Documentation](./docs/generated/README.md)
|
|
14
|
-
- [
|
|
15
|
-
- [Developer portal](https://monerium.dev/')
|
|
16
|
-
- [NPM](https://www.npmjs.com/package/@monerium/sdk)
|
|
42
|
+
- [Documentation - MoneriumClient](./docs/generated/classes/MoneriumClient.md)
|
|
17
43
|
|
|
18
44
|
## Table of Contents
|
|
19
45
|
|
|
@@ -85,8 +111,8 @@ const { access_token, refresh_token } = monerium.bearerProfile as BearerProfile;
|
|
|
85
111
|
|
|
86
112
|
Interfaces:
|
|
87
113
|
|
|
88
|
-
-
|
|
89
|
-
-
|
|
114
|
+
- [MoneriumClient](./docs/generated/classes/MoneriumClient.md)
|
|
115
|
+
- [BearerProfile](./docs/generated/interfaces/BearerProfile.md)
|
|
90
116
|
|
|
91
117
|
API documentation:
|
|
92
118
|
|
|
@@ -157,8 +183,8 @@ export function App() {
|
|
|
157
183
|
|
|
158
184
|
Interfaces:
|
|
159
185
|
|
|
160
|
-
-
|
|
161
|
-
-
|
|
186
|
+
- [AuthCodeRequest](./docs/generated/interfaces/AuthCodeRequest.md)
|
|
187
|
+
- [BearerProfile](./docs/generated/interfaces/BearerProfile.md)
|
|
162
188
|
|
|
163
189
|
API documentation:
|
|
164
190
|
|
|
@@ -183,9 +209,9 @@ const balances: Balances = await monerium.getBalances(profileId);
|
|
|
183
209
|
|
|
184
210
|
Interfaces:
|
|
185
211
|
|
|
186
|
-
-
|
|
187
|
-
-
|
|
188
|
-
-
|
|
212
|
+
- [AuthContext](./docs/generated/interfaces/AuthContext.md)
|
|
213
|
+
- [Profile](./docs/generated/interfaces/Profile.md)
|
|
214
|
+
- [Balances](./docs/generated/interfaces/Balances.md)
|
|
189
215
|
|
|
190
216
|
API documentation:
|
|
191
217
|
|
|
@@ -203,7 +229,7 @@ const tokens: Token[] = await monerium.getTokens();
|
|
|
203
229
|
|
|
204
230
|
Interfaces:
|
|
205
231
|
|
|
206
|
-
-
|
|
232
|
+
- [Token](./docs/generated/interfaces/Token.md)
|
|
207
233
|
|
|
208
234
|
API documentation:
|
|
209
235
|
|
|
@@ -234,15 +260,15 @@ await monerium.linkAddress(profileId, {
|
|
|
234
260
|
message: LINK_MESSAGE
|
|
235
261
|
signature,
|
|
236
262
|
accounts: [
|
|
237
|
-
{"currency":"eur","chain":"ethereum"
|
|
238
|
-
{"currency":"eur","chain":"gnosis"
|
|
263
|
+
{"currency":"eur","chain":"ethereum"},
|
|
264
|
+
{"currency":"eur","chain":"gnosis"}
|
|
239
265
|
],
|
|
240
266
|
} as LinkAddress);
|
|
241
267
|
```
|
|
242
268
|
|
|
243
269
|
Interfaces:
|
|
244
270
|
|
|
245
|
-
-
|
|
271
|
+
- [LinkAddress](./docs/generated/interfaces/LinkAddress.md)
|
|
246
272
|
|
|
247
273
|
API documentation:
|
|
248
274
|
|
|
@@ -264,7 +290,7 @@ const amount = '100'; // replace with the amount in EUR
|
|
|
264
290
|
const iban = 'EE12341234123412341234'; // replace with requested IBAN
|
|
265
291
|
|
|
266
292
|
// First you have to form the message that will be signed by the user
|
|
267
|
-
const message = placeOrderMessage(amount, iban);
|
|
293
|
+
const message = placeOrderMessage(amount, 'eur', iban);
|
|
268
294
|
|
|
269
295
|
// The message should look like this, with the current date and time in RFC3339 format:
|
|
270
296
|
// Send EUR 100 to EE12341234123412341234 at Thu, 29 Dec 2022 14:58:29Z
|
|
@@ -278,6 +304,7 @@ const signature = await walletClient.signMessage({
|
|
|
278
304
|
const order = await monerium.placeOrder({
|
|
279
305
|
amount,
|
|
280
306
|
signature,
|
|
307
|
+
currency: 'eur',
|
|
281
308
|
address: '0xUserAddress72413Fa92980B889A1eCE84dD', // user wallet address
|
|
282
309
|
counterpart: {
|
|
283
310
|
identifier: {
|
|
@@ -300,8 +327,8 @@ const order = await monerium.placeOrder({
|
|
|
300
327
|
|
|
301
328
|
Interfaces:
|
|
302
329
|
|
|
303
|
-
-
|
|
304
|
-
-
|
|
330
|
+
- [Order](./docs/generated/interfaces/Order.md)
|
|
331
|
+
- [PaymentStandard](./docs/generated/enumerations/PaymentStandard.md)
|
|
305
332
|
|
|
306
333
|
API documentation:
|
|
307
334
|
|
|
@@ -320,7 +347,7 @@ const supportingDocumentId: SupportingDoc =
|
|
|
320
347
|
|
|
321
348
|
Interfaces:
|
|
322
349
|
|
|
323
|
-
-
|
|
350
|
+
- [SupportingDoc](./docs/generated/interfaces/SupportingDoc.md)
|
|
324
351
|
|
|
325
352
|
API documentation:
|
|
326
353
|
|
|
@@ -383,8 +410,6 @@ pnpm build
|
|
|
383
410
|
|
|
384
411
|
Refer to [Typedocs](https://typedoc.org/) syntaxes to use for this [documentation](https://monerium.github.io/js-monorepo/).
|
|
385
412
|
|
|
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/.
|
|
387
|
-
|
|
388
413
|
#### Publishing
|
|
389
414
|
|
|
390
415
|
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.
|
package/dist/index.d.ts
CHANGED
|
@@ -13,7 +13,7 @@ type ENV = 'sandbox' | 'production';
|
|
|
13
13
|
type EthereumTestnet = 'sepolia';
|
|
14
14
|
type GnosisTestnet = 'chiado';
|
|
15
15
|
type PolygonTestnet = 'amoy';
|
|
16
|
-
type Chain = 'ethereum' | 'gnosis' | 'polygon';
|
|
16
|
+
type Chain = 'ethereum' | 'gnosis' | 'polygon' | 'gnosismainnet';
|
|
17
17
|
type Networks = EthereumTestnet | GnosisTestnet | PolygonTestnet | 'mainnet';
|
|
18
18
|
type NetworkSemiStrict<C extends Chain> = C extends 'ethereum' ? EthereumTestnet | 'mainnet' : C extends 'gnosis' ? GnosisTestnet | 'mainnet' : C extends 'polygon' ? PolygonTestnet | 'mainnet' : never;
|
|
19
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;
|
|
@@ -92,9 +92,8 @@ type PKCERequest = {
|
|
|
92
92
|
address?: string;
|
|
93
93
|
/** the signature of the wallet to automatically link */
|
|
94
94
|
signature?: string;
|
|
95
|
-
/** @deprecated - Use chainId
|
|
95
|
+
/** @deprecated - Use 'chainId' or 'chain' */
|
|
96
96
|
network?: Network;
|
|
97
|
-
/** @deprecated - Use chainId */
|
|
98
97
|
chain?: Chain;
|
|
99
98
|
/** The network of the wallet to automatically link */
|
|
100
99
|
chainId?: ChainId;
|
|
@@ -212,10 +211,9 @@ interface IBAN extends Identifier {
|
|
|
212
211
|
interface CrossChain extends Identifier {
|
|
213
212
|
standard: PaymentStandard.chain;
|
|
214
213
|
address: string;
|
|
215
|
-
chainId
|
|
216
|
-
/** @deprecated - Use chainId */
|
|
214
|
+
chainId?: ChainId;
|
|
217
215
|
chain?: Chain;
|
|
218
|
-
/** @deprecated - Use chainId */
|
|
216
|
+
/** @deprecated - Use 'chainId' or 'chain' */
|
|
219
217
|
network?: Network;
|
|
220
218
|
}
|
|
221
219
|
interface SCAN extends Identifier {
|
|
@@ -288,7 +286,7 @@ type NewOrder = NewOrderByAddress | NewOrderByAccountId;
|
|
|
288
286
|
interface NewOrderCommon {
|
|
289
287
|
amount: string;
|
|
290
288
|
signature: string;
|
|
291
|
-
currency
|
|
289
|
+
currency: Currency;
|
|
292
290
|
counterpart: Counterpart;
|
|
293
291
|
message: string;
|
|
294
292
|
memo?: string;
|
|
@@ -296,11 +294,10 @@ interface NewOrderCommon {
|
|
|
296
294
|
}
|
|
297
295
|
interface NewOrderByAddress extends NewOrderCommon {
|
|
298
296
|
address: string;
|
|
299
|
-
/** @deprecated - Use 'chainId' */
|
|
300
297
|
chain?: Chain;
|
|
301
|
-
/** @deprecated - Use 'chainId' */
|
|
298
|
+
/** @deprecated - Use 'chainId' or 'chain' */
|
|
302
299
|
network?: Network;
|
|
303
|
-
chainId
|
|
300
|
+
chainId?: ChainId;
|
|
304
301
|
}
|
|
305
302
|
interface NewOrderByAccountId extends NewOrderCommon {
|
|
306
303
|
accountId: string;
|
|
@@ -319,11 +316,10 @@ interface SupportingDoc {
|
|
|
319
316
|
meta: SupportingDocMetadata;
|
|
320
317
|
}
|
|
321
318
|
interface CurrencyAccounts {
|
|
322
|
-
/** @deprecated - Use 'chainId' */
|
|
319
|
+
/** @deprecated - Use 'chainId' or 'chain' */
|
|
323
320
|
network?: Network;
|
|
324
|
-
/** @deprecated - Use 'chainId' */
|
|
325
321
|
chain?: Chain;
|
|
326
|
-
chainId
|
|
322
|
+
chainId?: ChainId;
|
|
327
323
|
currency: Currency;
|
|
328
324
|
}
|
|
329
325
|
interface LinkAddress {
|
|
@@ -331,12 +327,21 @@ interface LinkAddress {
|
|
|
331
327
|
message: string;
|
|
332
328
|
signature: string;
|
|
333
329
|
accounts: CurrencyAccounts[];
|
|
334
|
-
/** @deprecated - Use 'chainId' */
|
|
330
|
+
/** @deprecated - Use 'chainId' or 'chain' */
|
|
335
331
|
network?: Network;
|
|
336
|
-
/** @deprecated - Use 'chainId' */
|
|
337
332
|
chain?: Chain;
|
|
338
333
|
chainId?: ChainId;
|
|
339
334
|
}
|
|
335
|
+
interface LinkedAddress {
|
|
336
|
+
id: string;
|
|
337
|
+
profile: string;
|
|
338
|
+
address: string;
|
|
339
|
+
message: string;
|
|
340
|
+
meta: {
|
|
341
|
+
linkedBy: string;
|
|
342
|
+
linkedAt: string;
|
|
343
|
+
};
|
|
344
|
+
}
|
|
340
345
|
interface OrderNotification {
|
|
341
346
|
id: string;
|
|
342
347
|
profile: string;
|
|
@@ -365,6 +370,7 @@ interface AuthFlowOptions {
|
|
|
365
370
|
signature?: string;
|
|
366
371
|
chainId?: ChainId;
|
|
367
372
|
state?: string;
|
|
373
|
+
scope?: string;
|
|
368
374
|
}
|
|
369
375
|
interface ClientCredentials {
|
|
370
376
|
clientId: string;
|
|
@@ -408,7 +414,7 @@ declare class MoneriumClient {
|
|
|
408
414
|
* */
|
|
409
415
|
constructor(envOrOptions?: ENV | ClassOptions);
|
|
410
416
|
/**
|
|
411
|
-
* Construct the url to the authorization code flow,
|
|
417
|
+
* Construct the url to the authorization code flow and redirects,
|
|
412
418
|
* Code Verifier needed for the code challenge is stored in local storage
|
|
413
419
|
* For automatic wallet link, add the following properties: `address`, `signature` & `chainId`
|
|
414
420
|
* @returns string
|
|
@@ -434,6 +440,11 @@ declare class MoneriumClient {
|
|
|
434
440
|
* @category Profiles
|
|
435
441
|
*/
|
|
436
442
|
getProfile(profileId: string): Promise<Profile>;
|
|
443
|
+
/**
|
|
444
|
+
* {@link https://monerium.dev/api-docs#operation/profiles}
|
|
445
|
+
* @category Profiles
|
|
446
|
+
*/
|
|
447
|
+
getProfiles(): Promise<Profile[]>;
|
|
437
448
|
/**
|
|
438
449
|
* {@link https://monerium.dev/api-docs#operation/profile-balances}
|
|
439
450
|
* @param {string=} profileId - the id of the profile to fetch balances.
|
|
@@ -459,12 +470,12 @@ declare class MoneriumClient {
|
|
|
459
470
|
* {@link https://monerium.dev/api-docs#operation/profile-addresses}
|
|
460
471
|
* @category Accounts
|
|
461
472
|
*/
|
|
462
|
-
linkAddress(profileId: string, body: LinkAddress): Promise<
|
|
473
|
+
linkAddress(profileId: string, body: LinkAddress): Promise<LinkedAddress>;
|
|
463
474
|
/**
|
|
464
475
|
* {@link https://monerium.dev/api-docs#operation/post-orders}
|
|
465
476
|
* @category Orders
|
|
466
477
|
*/
|
|
467
|
-
placeOrder(order: NewOrder
|
|
478
|
+
placeOrder(order: NewOrder): Promise<Order>;
|
|
468
479
|
/**
|
|
469
480
|
* {@link https://monerium.dev/api-docs#operation/supporting-document}
|
|
470
481
|
* @category Orders
|
|
@@ -506,29 +517,13 @@ declare class MoneriumClient {
|
|
|
506
517
|
*/
|
|
507
518
|
unsubscribeOrders(event: MoneriumEvent): void;
|
|
508
519
|
/**
|
|
509
|
-
* @deprecated since v2.6.4, will be removed in 2.7.2+, use {@link getAccess} instead.
|
|
510
520
|
* @hidden
|
|
511
521
|
*/
|
|
512
|
-
|
|
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>;
|
|
522
|
+
getEnvironment: () => Environment;
|
|
518
523
|
/**
|
|
519
|
-
* @deprecated since v2.6.4, will be removed in 2.7.2+, use {@link authorize} instead.
|
|
520
524
|
* @hidden
|
|
521
525
|
*/
|
|
522
526
|
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
527
|
}
|
|
533
528
|
|
|
534
529
|
declare const _default: {
|
|
@@ -549,20 +544,17 @@ declare const _default: {
|
|
|
549
544
|
declare const rfc3339: (d: Date) => string;
|
|
550
545
|
/**
|
|
551
546
|
* The message to be signed when placing an order.
|
|
552
|
-
*
|
|
547
|
+
* @param amount The amount to be sent
|
|
548
|
+
* @param currency The currency to be sent
|
|
549
|
+
* @param receiver The receiver of the funds
|
|
550
|
+
* @param chain The chainId of the network if it's a cross-chain transaction
|
|
553
551
|
* @returns string
|
|
554
552
|
*/
|
|
555
|
-
declare const placeOrderMessage: (amount: string | number,
|
|
553
|
+
declare const placeOrderMessage: (amount: string | number, currency: Currency, receiver: string, chain?: ChainId | Chain) => string;
|
|
556
554
|
/**
|
|
557
555
|
* Get the corresponding Monerium SDK Chain from the current chain id
|
|
558
556
|
* @returns The Chain
|
|
559
557
|
*/
|
|
560
558
|
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
559
|
|
|
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,
|
|
560
|
+
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, type LinkedAddress, 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, placeOrderMessage, rfc3339 };
|
package/dist/index.js
CHANGED
|
@@ -2,30 +2,29 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
var
|
|
6
|
-
var
|
|
5
|
+
var M = require('crypto-js/enc-base64url.js');
|
|
6
|
+
var z = require('crypto-js/sha256.js');
|
|
7
7
|
|
|
8
8
|
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
9
9
|
|
|
10
|
+
var M__default = /*#__PURE__*/_interopDefault(M);
|
|
10
11
|
var z__default = /*#__PURE__*/_interopDefault(z);
|
|
11
|
-
var F__default = /*#__PURE__*/_interopDefault(F);
|
|
12
12
|
|
|
13
|
-
var h={environments:{production:{api:"https://api.monerium.app",web:"https://monerium.app",wss:"wss://api.monerium.app"},sandbox:{api:"https://api.monerium.dev",web:"https://sandbox.monerium.dev",wss:"wss://api.monerium.dev"}}};var
|
|
13
|
+
var h={environments:{production:{api:"https://api.monerium.app",web:"https://monerium.app",wss:"wss://api.monerium.app"},sandbox:{api:"https://api.monerium.dev",web:"https://sandbox.monerium.dev",wss:"wss://api.monerium.dev"}}};var c={LINK_MESSAGE:"I hereby declare that I am the address owner.",STORAGE_CODE_VERIFIER:"monerium.sdk.code_verifier",STORAGE_REFRESH_TOKEN:"monerium.sdk.refresh_token"};var I=(i=>(i.eur="eur",i.usd="usd",i.gbp="gbp",i.isk="isk",i))(I||{}),b=(i=>(i.password="password",i.resource="resource",i.jwt="jwt",i.apiKey="apiKey",i))(b||{}),P=(t=>(t.corporate="corporate",t.personal="personal",t))(P||{}),O=(t=>(t.read="read",t.write="write",t))(O||{}),T=(i=>(i.absent="absent",i.submitted="submitted",i.pending="pending",i.confirmed="confirmed",i))(T||{}),N=(r=>(r.approved="approved",r.rejected="rejected",r.unknown="unknown",r))(N||{}),v=(r=>(r.requested="requested",r.approved="approved",r.pending="pending",r))(v||{}),q=(r=>(r.iban="iban",r.scan="scan",r.chain="chain",r))(q||{}),B=(t=>(t.redeem="redeem",t.issue="issue",t))(B||{}),$=(i=>(i.placed="placed",i.pending="pending",i.processed="processed",i.rejected="rejected",i))($||{});var C=n=>{if(n.toString()==="Invalid Date")throw n;let e=r=>r<10?"0"+r:r,t=r=>{if(r===0)return "Z";let i=r>0?"-":"+";return r=Math.abs(r),i+e(Math.floor(r/60))+":"+e(r%60)};return n.getFullYear()+"-"+e(n.getMonth()+1)+"-"+e(n.getDate())+"T"+e(n.getHours())+":"+e(n.getMinutes())+":"+e(n.getSeconds())+t(n.getTimezoneOffset())},U=(n,e,t,r)=>{let i=`${e?.toUpperCase()||"EUR"}`,s=r;return typeof r=="number"&&(s=g(r)),s?`Send ${i} ${n} to ${t} on ${s} at ${C(new Date)}`:`Send ${i} ${n} to ${t} at ${C(new Date)}`},u=n=>n&&Object.entries(n)?.length>0?Object.entries(n).map(([e,t])=>`${encodeURIComponent(e)}=${encodeURIComponent(t)}`).join("&"):"",g=n=>{switch(n){case 1:case 11155111:return "ethereum";case 100:case 10200:return "gnosis";case 137:case 80002:return "polygon";default:throw new Error(`Chain not supported: ${n}`)}};var p=n=>{if(n?.chainId){let{chainId:e,...t}=n;return {...t,chain:g(e)}}return n};var F=(n,e)=>{let{client_id:t,redirect_uri:r,scope:i,state:s,chainId:o,address:d,signature:k,chain:E}=n,S=d?{address:d,...k!==void 0?{signature:k}:{},...o!==void 0||E!==void 0?{chain:o?g(o):E}:{}}:{};return u({client_id:t,redirect_uri:r,...i!==void 0?{scope:i}:{},...s!==void 0?{state:s}:{},code_challenge:e,code_challenge_method:"S256",response_type:"code",...S})},D=()=>{let n="",e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",t=e.length,r=0;for(;r<128;)n+=e.charAt(Math.floor(Math.random()*t)),r+=1;return n},L=n=>M__default.default.stringify(z__default.default(n)),x=(n,e)=>{let t=D(),r=L(t);return localStorage.setItem(c.STORAGE_CODE_VERIFIER,t||""),`${n}/auth?${F(e,r)}`},w=()=>{let n=window.location.href;if(!n||!n?.includes("?"))return;let[e,t]=n.split("?");t&&window.history.replaceState(null,"",e);},y=n=>n.code!=null,R=n=>n.refresh_token!=null,_=n=>n.client_secret!=null;var A=async(n,e,t,r)=>{let i=await fetch(`${n}`,{method:e,headers:r,body:t}),s,o=await i.text();try{s=JSON.parse(o);}catch{throw o}if(!i.ok)throw s;return s};var {STORAGE_CODE_VERIFIER:l,STORAGE_REFRESH_TOKEN:m}=c,a=typeof window>"u",f=class{#t;#i;codeVerifier;bearerProfile;#s;#n=new Map;isAuthorized=!!this.bearerProfile;#r;state;constructor(e){if(!e){this.#t=h.environments.sandbox;return}if(typeof e=="string")this.#t=h.environments[e];else if(this.#t=h.environments[e.environment||"sandbox"],a){let{clientId:t,clientSecret:r}=e;this.#r={clientId:t,clientSecret:r};}else {let{clientId:t,redirectUrl:r}=e;this.#r={clientId:t,redirectUrl:r};}}async authorize(e){let t=e?.clientId||this.#r?.clientId,r=e?.redirectUrl||this.#r?.redirectUrl;if(!t)throw new Error("Missing ClientId");if(!r)throw new Error("Missing RedirectUrl");let i=x(this.#t.api,{client_id:t,redirect_uri:r,address:e?.address,signature:e?.signature,chainId:e?.chainId,state:e?.state,scope:e?.scope});window.location.assign(i);}async getAccess(e){let t=e?.clientId||this.#r?.clientId;if(e?.clientSecret||this.#r?.clientSecret){if(!a)throw new Error("Only use client credentials on server side");return await this.#d(this.#r),!!this.bearerProfile}let i=e?.redirectUrl||this.#r?.redirectUrl;if(!t)throw new Error("Missing ClientId");if(a)throw new Error("This only works client side");let s=new URLSearchParams(window.location.search).get("code")||void 0,o=new URLSearchParams(window.location.search).get("state")||void 0,d=localStorage.getItem(m)||void 0;return d?await this.#c(t,d):s&&await this.#a(t,i,s,o),!!this.bearerProfile}async#o(e){let t;if(y(e))t={...e,grant_type:"authorization_code"};else if(R(e))t={...e,grant_type:"refresh_token"};else if(_(e))t={...e,grant_type:"client_credentials"};else throw new Error("Authorization grant type could not be detected.");return await this.#e("post","auth/token",t,!0).then(r=>{this.bearerProfile=r,this.isAuthorized=!!r,this.#i=`Bearer ${r?.access_token}`,a||window.localStorage.setItem(m,this.bearerProfile?.refresh_token||"");}).catch(r=>{throw a||(localStorage.removeItem(l),localStorage.removeItem(m),w()),new Error(r?.message)}),y(e)&&w(),this.bearerProfile}getAuthContext(){return this.#e("get","auth/context")}getProfile(e){return this.#e("get",`profiles/${e}`)}getProfiles(){return this.#e("get","profiles")}getBalances(e){return e?this.#e("get",`profiles/${e}/balances`):this.#e("get","balances")}getOrders(e){let t=u(e),r=t?`orders?${t}`:"orders";return this.#e("get",r)}getOrder(e){return this.#e("get",`orders/${e}`)}getTokens(){return this.#e("get","tokens")}linkAddress(e,t){return t=p(t),t.accounts=t.accounts.map(r=>p(r)),this.#e("post",`profiles/${e}/addresses`,JSON.stringify(t))}placeOrder(e){let t={kind:"redeem",...p(e),counterpart:{...e.counterpart,identifier:p(e.counterpart.identifier)}};return this.#e("post","orders",JSON.stringify(t))}uploadSupportingDocument(e){let t=new FormData;return t.append("file",e),A(`${this.#t.api}/files`,"post",t,{Authorization:this.#i||""})}async#e(e,t,r,i){return A(`${this.#t.api}/${t}`,e,i?u(r):r,{Authorization:this.#i||"","Content-Type":`application/${i?"x-www-form-urlencoded":"json"}`})}#a=async(e,t,r,i)=>{let s=localStorage.getItem(l)||"";if(!s)throw new Error("Code verifier not found");return this.codeVerifier=s,this.state=i,localStorage.removeItem(l),await this.#o({code:r,redirect_uri:t,client_id:e,code_verifier:s})};#d=async({clientId:e,clientSecret:t})=>await this.#o({client_id:e,client_secret:t});#c=async(e,t)=>await this.#o({refresh_token:t,client_id:e});async connectOrderSocket(){this.bearerProfile?.access_token&&this.#n.size>0&&(this.#s=this.subscribeToOrderNotifications());}subscribeToOrderNotifications=()=>{let e=`${this.#t.wss}/profiles/${this.bearerProfile?.profile}/orders?access_token=${this.bearerProfile?.access_token}`,t=new WebSocket(e);return t.addEventListener("open",()=>{console.info(`Socket connected: ${e}`);}),t.addEventListener("error",r=>{throw console.error(r),new Error(`Socket error: ${e}`)}),t.addEventListener("message",r=>{let i=JSON.parse(r.data);this.#n.get(i.meta.state)?.(i);}),t.addEventListener("close",()=>{console.info(`Socket connection closed: ${e}`);}),t};async disconnect(){a||localStorage.removeItem(l),this.#n.clear(),this.#s?.close(),this.#i=void 0,this.bearerProfile=void 0;}async revokeAccess(){a||localStorage.removeItem(m),this.disconnect();}subscribeOrders(e,t){this.#n.set(e,t);}unsubscribeOrders(e){this.#n.delete(e),this.#n.size===0&&(this.#s?.close(),this.#s=void 0);}getEnvironment=()=>this.#t;getAuthFlowURI=e=>{let t=x(this.#t.api,e);return this.codeVerifier=localStorage.getItem(l),t}};var he=f;
|
|
14
14
|
|
|
15
15
|
exports.AccountState = v;
|
|
16
|
-
exports.Currency =
|
|
17
|
-
exports.KYCOutcome =
|
|
18
|
-
exports.KYCState =
|
|
16
|
+
exports.Currency = I;
|
|
17
|
+
exports.KYCOutcome = N;
|
|
18
|
+
exports.KYCState = T;
|
|
19
19
|
exports.Method = b;
|
|
20
20
|
exports.MoneriumClient = f;
|
|
21
21
|
exports.OrderKind = B;
|
|
22
22
|
exports.OrderState = $;
|
|
23
23
|
exports.PaymentStandard = q;
|
|
24
|
-
exports.Permission =
|
|
25
|
-
exports.ProfileType =
|
|
26
|
-
exports.constants =
|
|
27
|
-
exports.default =
|
|
24
|
+
exports.Permission = O;
|
|
25
|
+
exports.ProfileType = P;
|
|
26
|
+
exports.constants = c;
|
|
27
|
+
exports.default = he;
|
|
28
28
|
exports.getChain = g;
|
|
29
|
-
exports.getNetwork = M;
|
|
30
29
|
exports.placeOrderMessage = U;
|
|
31
30
|
exports.rfc3339 = C;
|
package/dist/index.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
1
|
+
import M from 'crypto-js/enc-base64url.js';
|
|
2
|
+
import z from 'crypto-js/sha256.js';
|
|
3
3
|
|
|
4
|
-
var h={environments:{production:{api:"https://api.monerium.app",web:"https://monerium.app",wss:"wss://api.monerium.app"},sandbox:{api:"https://api.monerium.dev",web:"https://sandbox.monerium.dev",wss:"wss://api.monerium.dev"}}};var
|
|
4
|
+
var h={environments:{production:{api:"https://api.monerium.app",web:"https://monerium.app",wss:"wss://api.monerium.app"},sandbox:{api:"https://api.monerium.dev",web:"https://sandbox.monerium.dev",wss:"wss://api.monerium.dev"}}};var c={LINK_MESSAGE:"I hereby declare that I am the address owner.",STORAGE_CODE_VERIFIER:"monerium.sdk.code_verifier",STORAGE_REFRESH_TOKEN:"monerium.sdk.refresh_token"};var I=(i=>(i.eur="eur",i.usd="usd",i.gbp="gbp",i.isk="isk",i))(I||{}),b=(i=>(i.password="password",i.resource="resource",i.jwt="jwt",i.apiKey="apiKey",i))(b||{}),P=(t=>(t.corporate="corporate",t.personal="personal",t))(P||{}),O=(t=>(t.read="read",t.write="write",t))(O||{}),T=(i=>(i.absent="absent",i.submitted="submitted",i.pending="pending",i.confirmed="confirmed",i))(T||{}),N=(r=>(r.approved="approved",r.rejected="rejected",r.unknown="unknown",r))(N||{}),v=(r=>(r.requested="requested",r.approved="approved",r.pending="pending",r))(v||{}),q=(r=>(r.iban="iban",r.scan="scan",r.chain="chain",r))(q||{}),B=(t=>(t.redeem="redeem",t.issue="issue",t))(B||{}),$=(i=>(i.placed="placed",i.pending="pending",i.processed="processed",i.rejected="rejected",i))($||{});var C=n=>{if(n.toString()==="Invalid Date")throw n;let e=r=>r<10?"0"+r:r,t=r=>{if(r===0)return "Z";let i=r>0?"-":"+";return r=Math.abs(r),i+e(Math.floor(r/60))+":"+e(r%60)};return n.getFullYear()+"-"+e(n.getMonth()+1)+"-"+e(n.getDate())+"T"+e(n.getHours())+":"+e(n.getMinutes())+":"+e(n.getSeconds())+t(n.getTimezoneOffset())},U=(n,e,t,r)=>{let i=`${e?.toUpperCase()||"EUR"}`,s=r;return typeof r=="number"&&(s=g(r)),s?`Send ${i} ${n} to ${t} on ${s} at ${C(new Date)}`:`Send ${i} ${n} to ${t} at ${C(new Date)}`},u=n=>n&&Object.entries(n)?.length>0?Object.entries(n).map(([e,t])=>`${encodeURIComponent(e)}=${encodeURIComponent(t)}`).join("&"):"",g=n=>{switch(n){case 1:case 11155111:return "ethereum";case 100:case 10200:return "gnosis";case 137:case 80002:return "polygon";default:throw new Error(`Chain not supported: ${n}`)}};var p=n=>{if(n?.chainId){let{chainId:e,...t}=n;return {...t,chain:g(e)}}return n};var F=(n,e)=>{let{client_id:t,redirect_uri:r,scope:i,state:s,chainId:o,address:d,signature:k,chain:E}=n,S=d?{address:d,...k!==void 0?{signature:k}:{},...o!==void 0||E!==void 0?{chain:o?g(o):E}:{}}:{};return u({client_id:t,redirect_uri:r,...i!==void 0?{scope:i}:{},...s!==void 0?{state:s}:{},code_challenge:e,code_challenge_method:"S256",response_type:"code",...S})},D=()=>{let n="",e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",t=e.length,r=0;for(;r<128;)n+=e.charAt(Math.floor(Math.random()*t)),r+=1;return n},L=n=>M.stringify(z(n)),x=(n,e)=>{let t=D(),r=L(t);return localStorage.setItem(c.STORAGE_CODE_VERIFIER,t||""),`${n}/auth?${F(e,r)}`},w=()=>{let n=window.location.href;if(!n||!n?.includes("?"))return;let[e,t]=n.split("?");t&&window.history.replaceState(null,"",e);},y=n=>n.code!=null,R=n=>n.refresh_token!=null,_=n=>n.client_secret!=null;var A=async(n,e,t,r)=>{let i=await fetch(`${n}`,{method:e,headers:r,body:t}),s,o=await i.text();try{s=JSON.parse(o);}catch{throw o}if(!i.ok)throw s;return s};var {STORAGE_CODE_VERIFIER:l,STORAGE_REFRESH_TOKEN:m}=c,a=typeof window>"u",f=class{#t;#i;codeVerifier;bearerProfile;#s;#n=new Map;isAuthorized=!!this.bearerProfile;#r;state;constructor(e){if(!e){this.#t=h.environments.sandbox;return}if(typeof e=="string")this.#t=h.environments[e];else if(this.#t=h.environments[e.environment||"sandbox"],a){let{clientId:t,clientSecret:r}=e;this.#r={clientId:t,clientSecret:r};}else {let{clientId:t,redirectUrl:r}=e;this.#r={clientId:t,redirectUrl:r};}}async authorize(e){let t=e?.clientId||this.#r?.clientId,r=e?.redirectUrl||this.#r?.redirectUrl;if(!t)throw new Error("Missing ClientId");if(!r)throw new Error("Missing RedirectUrl");let i=x(this.#t.api,{client_id:t,redirect_uri:r,address:e?.address,signature:e?.signature,chainId:e?.chainId,state:e?.state,scope:e?.scope});window.location.assign(i);}async getAccess(e){let t=e?.clientId||this.#r?.clientId;if(e?.clientSecret||this.#r?.clientSecret){if(!a)throw new Error("Only use client credentials on server side");return await this.#d(this.#r),!!this.bearerProfile}let i=e?.redirectUrl||this.#r?.redirectUrl;if(!t)throw new Error("Missing ClientId");if(a)throw new Error("This only works client side");let s=new URLSearchParams(window.location.search).get("code")||void 0,o=new URLSearchParams(window.location.search).get("state")||void 0,d=localStorage.getItem(m)||void 0;return d?await this.#c(t,d):s&&await this.#a(t,i,s,o),!!this.bearerProfile}async#o(e){let t;if(y(e))t={...e,grant_type:"authorization_code"};else if(R(e))t={...e,grant_type:"refresh_token"};else if(_(e))t={...e,grant_type:"client_credentials"};else throw new Error("Authorization grant type could not be detected.");return await this.#e("post","auth/token",t,!0).then(r=>{this.bearerProfile=r,this.isAuthorized=!!r,this.#i=`Bearer ${r?.access_token}`,a||window.localStorage.setItem(m,this.bearerProfile?.refresh_token||"");}).catch(r=>{throw a||(localStorage.removeItem(l),localStorage.removeItem(m),w()),new Error(r?.message)}),y(e)&&w(),this.bearerProfile}getAuthContext(){return this.#e("get","auth/context")}getProfile(e){return this.#e("get",`profiles/${e}`)}getProfiles(){return this.#e("get","profiles")}getBalances(e){return e?this.#e("get",`profiles/${e}/balances`):this.#e("get","balances")}getOrders(e){let t=u(e),r=t?`orders?${t}`:"orders";return this.#e("get",r)}getOrder(e){return this.#e("get",`orders/${e}`)}getTokens(){return this.#e("get","tokens")}linkAddress(e,t){return t=p(t),t.accounts=t.accounts.map(r=>p(r)),this.#e("post",`profiles/${e}/addresses`,JSON.stringify(t))}placeOrder(e){let t={kind:"redeem",...p(e),counterpart:{...e.counterpart,identifier:p(e.counterpart.identifier)}};return this.#e("post","orders",JSON.stringify(t))}uploadSupportingDocument(e){let t=new FormData;return t.append("file",e),A(`${this.#t.api}/files`,"post",t,{Authorization:this.#i||""})}async#e(e,t,r,i){return A(`${this.#t.api}/${t}`,e,i?u(r):r,{Authorization:this.#i||"","Content-Type":`application/${i?"x-www-form-urlencoded":"json"}`})}#a=async(e,t,r,i)=>{let s=localStorage.getItem(l)||"";if(!s)throw new Error("Code verifier not found");return this.codeVerifier=s,this.state=i,localStorage.removeItem(l),await this.#o({code:r,redirect_uri:t,client_id:e,code_verifier:s})};#d=async({clientId:e,clientSecret:t})=>await this.#o({client_id:e,client_secret:t});#c=async(e,t)=>await this.#o({refresh_token:t,client_id:e});async connectOrderSocket(){this.bearerProfile?.access_token&&this.#n.size>0&&(this.#s=this.subscribeToOrderNotifications());}subscribeToOrderNotifications=()=>{let e=`${this.#t.wss}/profiles/${this.bearerProfile?.profile}/orders?access_token=${this.bearerProfile?.access_token}`,t=new WebSocket(e);return t.addEventListener("open",()=>{console.info(`Socket connected: ${e}`);}),t.addEventListener("error",r=>{throw console.error(r),new Error(`Socket error: ${e}`)}),t.addEventListener("message",r=>{let i=JSON.parse(r.data);this.#n.get(i.meta.state)?.(i);}),t.addEventListener("close",()=>{console.info(`Socket connection closed: ${e}`);}),t};async disconnect(){a||localStorage.removeItem(l),this.#n.clear(),this.#s?.close(),this.#i=void 0,this.bearerProfile=void 0;}async revokeAccess(){a||localStorage.removeItem(m),this.disconnect();}subscribeOrders(e,t){this.#n.set(e,t);}unsubscribeOrders(e){this.#n.delete(e),this.#n.size===0&&(this.#s?.close(),this.#s=void 0);}getEnvironment=()=>this.#t;getAuthFlowURI=e=>{let t=x(this.#t.api,e);return this.codeVerifier=localStorage.getItem(l),t}};var he=f;
|
|
5
5
|
|
|
6
|
-
export { v as AccountState,
|
|
6
|
+
export { v as AccountState, I as Currency, N as KYCOutcome, T as KYCState, b as Method, f as MoneriumClient, B as OrderKind, $ as OrderState, q as PaymentStandard, O as Permission, P as ProfileType, c as constants, he as default, g as getChain, U as placeOrderMessage, C as rfc3339 };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@monerium/sdk",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.14.0",
|
|
4
4
|
"description": "Essential tools to interact with the Monerium API, an electronic money issuer.",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -33,8 +33,6 @@
|
|
|
33
33
|
"jest-fetch-mock": "^3.0.3",
|
|
34
34
|
"jest-localstorage-mock": "^2.4.26",
|
|
35
35
|
"timezone-mock": "^1.3.6",
|
|
36
|
-
"typedoc": "^0.25.13",
|
|
37
|
-
"typedoc-plugin-markdown": "^4.0.3",
|
|
38
36
|
"typescript": "latest"
|
|
39
37
|
},
|
|
40
38
|
"engines": {
|