@monerium/sdk 2.2.3 → 2.4.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 +40 -0
- package/README.md +11 -6
- package/dist/index.d.ts +37 -32
- package/dist/index.mjs +338 -306
- package/dist/index.mjs.map +1 -1
- package/dist/index.umd.js +1 -1
- package/dist/index.umd.js.map +1 -1
- package/package.json +7 -6
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,45 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [2.4.0](https://github.com/monerium/sdk/compare/v2.3.0...v2.4.0) (2023-05-09)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### Features
|
|
7
|
+
|
|
8
|
+
* kind always redeem from place order [#87](https://github.com/monerium/sdk/issues/87) ([#88](https://github.com/monerium/sdk/issues/88)) ([850921e](https://github.com/monerium/sdk/commit/850921ed0aa8d36e180ee7c1df439e04f5d7085b))
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
### Bug Fixes
|
|
12
|
+
|
|
13
|
+
* custom urlEncoder for x-www-forms so the package works for Metamask snapa ([#91](https://github.com/monerium/sdk/issues/91)) ([8375164](https://github.com/monerium/sdk/commit/83751645565c4b7054f8aabffaa8f91eea8d5caf))
|
|
14
|
+
* lint ([82f8f7c](https://github.com/monerium/sdk/commit/82f8f7c0192b235c4e0e584a25d52490e1575aa3))
|
|
15
|
+
* vscode cant detect the configs in nested folder ([#89](https://github.com/monerium/sdk/issues/89)) ([398dcf1](https://github.com/monerium/sdk/commit/398dcf1513de86a7c3949493e3728aac746349fa))
|
|
16
|
+
* we only support EUR for now + adjust placeOrder request type ([1c54932](https://github.com/monerium/sdk/commit/1c549321192c115947f1ce574c97cf618353a6ef))
|
|
17
|
+
* we only support EUR for now + adjust placeOrder request type ([07f801a](https://github.com/monerium/sdk/commit/07f801a1088bf2df014af549214199bb17ee8f51))
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
### Miscellaneous
|
|
21
|
+
|
|
22
|
+
* add a comment to explain how to use the Network type ([c913224](https://github.com/monerium/sdk/commit/c9132242d2f977524ba6467210344b1c8dc51e85))
|
|
23
|
+
* add info about sdks to Readme ([ad10488](https://github.com/monerium/sdk/commit/ad10488ce634787bee3b1eab8be6b8d78f56f834))
|
|
24
|
+
|
|
25
|
+
## [2.3.0](https://github.com/monerium/sdk/compare/v2.2.3...v2.3.0) (2023-04-30)
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
### ⚠ BREAKING CHANGES
|
|
29
|
+
|
|
30
|
+
* '@monerium/sdk' now exports Network and Chain as types, previously enums </br> Enums are now exported under 'constants' </br> import { constants } from '@monerium/sdk'; </br> const { Network } = constants; </br></br> new Network type takes two optional params for Chain and Environmant</br> import { Network } from '@monerium/sdk'</br></br> // is valid </br> const network: Network<'gnosis','production> = 'mainnet';</br> const network: Network<'gnosis','sandbox> = 'chiado';</br> const network: Network<'gnosis',> = 'chiado';</br> const network: Network = 'chiado';</br></br> // is invalid </br> const network: Network<'gnosis','sandbox> = 'mainnet';</br> const network: Network<'gnosis'> = 'goerli';</br>
|
|
31
|
+
|
|
32
|
+
### Features
|
|
33
|
+
|
|
34
|
+
* expose helper to create place order message ([#85](https://github.com/monerium/sdk/issues/85)) ([b124370](https://github.com/monerium/sdk/commit/b1243702c534a6d40e0ce657ff8db9a6f55546a5))
|
|
35
|
+
* network types with optional chain and env type params ([#82](https://github.com/monerium/sdk/issues/82)) ([154d626](https://github.com/monerium/sdk/commit/154d626798150640ac2ed331b98029a18984555c))
|
|
36
|
+
* refactor, improve and test fetch ([#86](https://github.com/monerium/sdk/issues/86)) ([26a8ceb](https://github.com/monerium/sdk/commit/26a8ceb78ec38553709afa2add0108ee3e10e125))
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
### Miscellaneous
|
|
40
|
+
|
|
41
|
+
* release 2.3.0 ([bff6ece](https://github.com/monerium/sdk/commit/bff6ece14c0b7b7a362b21df0b024b0a6a8f6678))
|
|
42
|
+
|
|
3
43
|
## [2.2.3](https://github.com/monerium/sdk/compare/v2.2.2...v2.2.3) (2023-04-28)
|
|
4
44
|
|
|
5
45
|
|
package/README.md
CHANGED
|
@@ -16,9 +16,14 @@ that may change the behavior of your application before you upgrade._
|
|
|
16
16
|
yarn add @monerium/sdk
|
|
17
17
|
```
|
|
18
18
|
|
|
19
|
+
Smart IDEs (such as VSCode) require [special configuration](https://yarnpkg.com/getting-started/editor-sdks) for TypeScript to work when using Plug'n'Play installs.
|
|
20
|
+
|
|
21
|
+
```sh
|
|
22
|
+
yarn dlx @yarnpkg/sdks vscode
|
|
23
|
+
```
|
|
24
|
+
|
|
19
25
|
## Usage
|
|
20
26
|
|
|
21
|
-
- `start`: Run Vite in host mode for a local development environment (not included in production build)
|
|
22
27
|
- `watch`: Run Vite in watch mode to detect changes to files during development
|
|
23
28
|
- `build`: Run Vite to build a production release distributable
|
|
24
29
|
|
|
@@ -43,7 +48,7 @@ If you are new here, we recommend starting in the [Developer Portal](https://mon
|
|
|
43
48
|
### Import the SDK and initialize a client
|
|
44
49
|
|
|
45
50
|
```ts
|
|
46
|
-
import { MoneriumClient } from
|
|
51
|
+
import { MoneriumClient } from '@monerium/sdk';
|
|
47
52
|
|
|
48
53
|
const client = new MoneriumClient();
|
|
49
54
|
```
|
|
@@ -84,10 +89,10 @@ window.location.replace(authFlowUrl)
|
|
|
84
89
|
// i.e. http://your-webpage.com/monerium-integration?code=1234abcd
|
|
85
90
|
|
|
86
91
|
await client.auth({
|
|
87
|
-
client_id:
|
|
88
|
-
code: new URLSearchParams(window.location.search).get(
|
|
89
|
-
code_verifier: window.localStorage.getItem(
|
|
90
|
-
redirect_url:
|
|
92
|
+
client_id: 'your_client_authflow_uuid',
|
|
93
|
+
code: new URLSearchParams(window.location.search).get('code'),
|
|
94
|
+
code_verifier: window.localStorage.getItem('myCodeVerifier'),
|
|
95
|
+
redirect_url: 'http://your-webpage.com/monerium-integration',
|
|
91
96
|
});
|
|
92
97
|
|
|
93
98
|
// User is now authenticated, get authentication data
|
package/dist/index.d.ts
CHANGED
|
@@ -10,19 +10,17 @@ export type Config = {
|
|
|
10
10
|
sandbox: Environment;
|
|
11
11
|
};
|
|
12
12
|
};
|
|
13
|
-
export
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
13
|
+
export type ENV = "sandbox" | "production";
|
|
14
|
+
export type EthereumTestnet = "goerli";
|
|
15
|
+
export type GnosisTestnet = "chiado";
|
|
16
|
+
export type PolygonTestnet = "mumbai";
|
|
17
|
+
export type Chain = "ethereum" | "gnosis" | "polygon";
|
|
18
|
+
export type Networks = EthereumTestnet | GnosisTestnet | PolygonTestnet | "mainnet";
|
|
19
|
+
export type NetworkSemiStrict<C extends Chain> = C extends "ethereum" ? EthereumTestnet | "mainnet" : C extends "gnosis" ? GnosisTestnet | "mainnet" : C extends "polygon" ? PolygonTestnet | "mainnet" : never;
|
|
20
|
+
export 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;
|
|
21
|
+
export type Network<C extends Chain = Chain, E extends ENV = ENV> = C extends Chain ? E extends ENV ? NetworkStrict<C, E> & NetworkSemiStrict<C> : never : never;
|
|
21
22
|
export declare enum Currency {
|
|
22
|
-
eur = "eur"
|
|
23
|
-
usd = "usd",
|
|
24
|
-
gbp = "gbp",
|
|
25
|
-
isk = "isk"
|
|
23
|
+
eur = "eur"
|
|
26
24
|
}
|
|
27
25
|
export type AuthArgs = Omit<AuthCode, "grant_type"> | Omit<RefreshToken, "grant_type"> | Omit<ClientCredentials, "grant_type">;
|
|
28
26
|
export interface AuthCode {
|
|
@@ -33,6 +31,14 @@ export interface AuthCode {
|
|
|
33
31
|
redirect_uri: string;
|
|
34
32
|
scope?: string;
|
|
35
33
|
}
|
|
34
|
+
export interface BearerProfile {
|
|
35
|
+
access_token: string;
|
|
36
|
+
token_type: string;
|
|
37
|
+
expires_in: number;
|
|
38
|
+
refresh_token: string;
|
|
39
|
+
profile: string;
|
|
40
|
+
userId: string;
|
|
41
|
+
}
|
|
36
42
|
export interface RefreshToken {
|
|
37
43
|
grant_type: "refresh_token";
|
|
38
44
|
client_id: string;
|
|
@@ -130,8 +136,6 @@ export interface Account {
|
|
|
130
136
|
currency: Currency;
|
|
131
137
|
standard: PaymentStandard;
|
|
132
138
|
iban?: string;
|
|
133
|
-
sortCode?: string;
|
|
134
|
-
accountNumber?: string;
|
|
135
139
|
network: Network;
|
|
136
140
|
chain: Chain;
|
|
137
141
|
id?: string;
|
|
@@ -142,17 +146,6 @@ export interface Profile {
|
|
|
142
146
|
kyc: KYC;
|
|
143
147
|
accounts: Account[];
|
|
144
148
|
}
|
|
145
|
-
export declare enum Chain {
|
|
146
|
-
polygon = "polygon",
|
|
147
|
-
ethereum = "ethereum",
|
|
148
|
-
gnosis = "gnosis"
|
|
149
|
-
}
|
|
150
|
-
export declare enum Network {
|
|
151
|
-
mainnet = "mainnet",
|
|
152
|
-
chiado = "chiado",
|
|
153
|
-
goerli = "goerli",
|
|
154
|
-
mumbai = "mumbai"
|
|
155
|
-
}
|
|
156
149
|
export interface Balance {
|
|
157
150
|
currency: Currency;
|
|
158
151
|
amount: string;
|
|
@@ -244,20 +237,23 @@ export interface Token {
|
|
|
244
237
|
address: string;
|
|
245
238
|
decimals: number;
|
|
246
239
|
}
|
|
247
|
-
export
|
|
248
|
-
|
|
240
|
+
export type NewOrder = NewOrderByAddress | NewOrderByAccountId;
|
|
241
|
+
export interface NewOrderCommon {
|
|
249
242
|
amount: string;
|
|
250
243
|
signature: string;
|
|
251
|
-
accountId?: string;
|
|
252
|
-
address: string;
|
|
253
|
-
currency: Currency;
|
|
254
244
|
counterpart: Counterpart;
|
|
255
245
|
message: string;
|
|
256
|
-
memo
|
|
246
|
+
memo?: string;
|
|
257
247
|
supportingDocumentId?: string;
|
|
248
|
+
}
|
|
249
|
+
export interface NewOrderByAddress extends NewOrderCommon {
|
|
250
|
+
address: string;
|
|
258
251
|
chain: Chain;
|
|
259
252
|
network: Network;
|
|
260
253
|
}
|
|
254
|
+
export interface NewOrderByAccountId extends NewOrderCommon {
|
|
255
|
+
accountId: string;
|
|
256
|
+
}
|
|
261
257
|
export interface SupportingDocMetadata {
|
|
262
258
|
uploadedBy: string;
|
|
263
259
|
createdAt: string;
|
|
@@ -314,9 +310,18 @@ export declare class MoneriumClient {
|
|
|
314
310
|
getOrders(filter?: OrderFilter): Promise<Order[]>;
|
|
315
311
|
getOrder(orderId: string): Promise<Order>;
|
|
316
312
|
getTokens(): Promise<Token[]>;
|
|
317
|
-
linkAddress(profileId: string, body: LinkAddress): Promise<
|
|
313
|
+
linkAddress(profileId: string, body: LinkAddress): Promise<unknown>;
|
|
318
314
|
placeOrder(order: NewOrder, profileId?: string): Promise<Order>;
|
|
319
315
|
uploadSupportingDocument(document: File): Promise<SupportingDoc>;
|
|
320
316
|
}
|
|
317
|
+
/**
|
|
318
|
+
* The message to be signed when placing an order.
|
|
319
|
+
*
|
|
320
|
+
* @returns string
|
|
321
|
+
*/
|
|
322
|
+
export declare const placeOrderMessage: ({ amount, iban, }: {
|
|
323
|
+
amount: string | number;
|
|
324
|
+
iban: string;
|
|
325
|
+
}) => string;
|
|
321
326
|
|
|
322
327
|
export {};
|