@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.
@@ -0,0 +1,41 @@
1
+ {
2
+ "name": "@monerium/sdk",
3
+ "version": "2.7.0",
4
+ "description": "Everything you need to interact with the Monerium API - an electronic money issuer.",
5
+ "license": "MIT",
6
+ "repository": {
7
+ "type": "git",
8
+ "url": "git+https://github.com/monerium/sdk.git"
9
+ },
10
+ "bugs": {
11
+ "url": "https://github.com/monerium/sdk/issues"
12
+ },
13
+ "main": "./dist/index.js",
14
+ "module": "./dist/index.mjs",
15
+ "typings": "./dist/index.d.ts",
16
+ "exports": {
17
+ ".": {
18
+ "import": "./dist/index.mjs",
19
+ "require": "./dist/index.js"
20
+ }
21
+ },
22
+ "files": [
23
+ "dist"
24
+ ],
25
+ "engines": {
26
+ "node": ">= 16.15"
27
+ },
28
+ "packageManager": "yarn@3.5.0",
29
+ "dependencies": {
30
+ "crypto-js": "^4.2.0"
31
+ },
32
+ "scripts": {
33
+ "build:watch": "yarn build:main --watch",
34
+ "docs": "yarn typedoc --options docs/typedoc.json && node docs/editStatic.js",
35
+ "docs:watch": "nodemon --watch . --ignore static -e ts,css,md --exec 'typedoc --options docs/typedoc.json && node docs/editStatic.js'"
36
+ },
37
+ "devDependencies": {
38
+ "typedoc": "0.23.23",
39
+ "typedoc-theme-hierarchy": "^3.2.1"
40
+ }
41
+ }
@@ -0,0 +1,348 @@
1
+ export type Environment = {
2
+ api: string;
3
+ web: string;
4
+ wss: string;
5
+ };
6
+ export type Config = {
7
+ environments: {
8
+ production: Environment;
9
+ sandbox: Environment;
10
+ };
11
+ };
12
+ export type ENV = 'sandbox' | 'production';
13
+ export type EthereumTestnet = 'goerli';
14
+ export type GnosisTestnet = 'chiado';
15
+ export type PolygonTestnet = 'mumbai';
16
+ export type Chain = 'ethereum' | 'gnosis' | 'polygon';
17
+ export type Networks = EthereumTestnet | GnosisTestnet | PolygonTestnet | 'mainnet';
18
+ export type NetworkSemiStrict<C extends Chain> = C extends 'ethereum' ? EthereumTestnet | 'mainnet' : C extends 'gnosis' ? GnosisTestnet | 'mainnet' : C extends 'polygon' ? PolygonTestnet | 'mainnet' : never;
19
+ 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;
20
+ 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
+ export type ChainId = 1 | 5 | 100 | 137 | 10200 | 80001;
22
+ export declare enum Currency {
23
+ eur = "eur"
24
+ }
25
+ export type TokenSymbol = 'EURe';
26
+ export type Ticker = 'EUR';
27
+ export type AuthArgs = Omit<AuthCodeRequest, 'grant_type'> | Omit<RefreshTokenRequest, 'grant_type'> | Omit<ClientCredentialsRequest, 'grant_type'>;
28
+ export type OpenArgs = Omit<AuthCodeRequest, 'grant_type' | 'code' | 'code_verifier'> | Omit<RefreshTokenRequest, 'grant_type'> | Omit<ClientCredentialsRequest, 'grant_type'> | PKCERequestArgs;
29
+ /** One of the options for the {@link AuthArgs}.
30
+ *
31
+ * [Auth endpoint in API documentation:](https://monerium.dev/api-docs#operation/auth).
32
+ * */
33
+ export interface AuthCodeRequest {
34
+ grant_type: 'authorization_code';
35
+ client_id: string;
36
+ code: string;
37
+ code_verifier: string;
38
+ redirect_uri: string;
39
+ scope?: string;
40
+ }
41
+ /** One of the options for the {@link AuthArgs}.
42
+ *
43
+ * [Auth endpoint in API documentation:](https://monerium.dev/api-docs#operation/auth).
44
+ * */
45
+ export interface RefreshTokenRequest {
46
+ grant_type: 'refresh_token';
47
+ client_id: string;
48
+ refresh_token: string;
49
+ scope?: string;
50
+ }
51
+ /** One of the options for the {@link AuthArgs}.
52
+ *
53
+ * [Auth endpoint in API documentation:](https://monerium.dev/api-docs#operation/auth).
54
+ * */
55
+ export interface ClientCredentialsRequest {
56
+ grant_type: 'client_credentials';
57
+ client_id: string;
58
+ client_secret: string;
59
+ scope?: string;
60
+ }
61
+ export interface BearerProfile {
62
+ access_token: string;
63
+ token_type: string;
64
+ expires_in: number;
65
+ refresh_token: string;
66
+ profile: string;
67
+ userId: string;
68
+ }
69
+ /**
70
+ * @returns A {@link PKCERequest} object with properties omitted that are automatically computed in by the SDK.
71
+ */
72
+ export type PKCERequestArgs = Omit<PKCERequest, 'code_challenge' | 'code_challenge_method' | 'response_type'>;
73
+ export type PKCERequest = {
74
+ /** the authentication flow client id of the application */
75
+ client_id: string;
76
+ /** the code challenge automatically generated by the SDK */
77
+ code_challenge: string;
78
+ /** the code challenge method for the authentication flow , handled by the SDK */
79
+ code_challenge_method: 'S256';
80
+ /** the response type of the authentication flow, handled by the SDK */
81
+ response_type: 'code';
82
+ /** the state of the application */
83
+ state?: string;
84
+ /** the redirect uri of the application */
85
+ redirect_uri: string;
86
+ /** the scope of the application */
87
+ scope?: string;
88
+ /** the address of the wallet to automatically link */
89
+ address?: string;
90
+ /** the signature of the wallet to automatically link */
91
+ signature?: string;
92
+ /** @deprecated - Use chainId - the network of the wallet to automatically link */
93
+ network?: Network;
94
+ /** @deprecated - Use chainId - the chain of the wallet to automatically link */
95
+ chain?: Chain;
96
+ /** The network of the wallet to automatically link */
97
+ chainId?: ChainId | number;
98
+ };
99
+ declare enum Method {
100
+ password = "password",
101
+ resource = "resource",
102
+ jwt = "jwt",
103
+ apiKey = "apiKey"
104
+ }
105
+ export declare enum ProfileType {
106
+ corporate = "corporate",
107
+ personal = "personal"
108
+ }
109
+ export declare enum Permission {
110
+ read = "read",
111
+ write = "write"
112
+ }
113
+ export interface AuthProfile {
114
+ id: string;
115
+ type: ProfileType;
116
+ name: string;
117
+ perms: Permission[];
118
+ }
119
+ export interface AuthContext {
120
+ userId: string;
121
+ email: string;
122
+ name: string;
123
+ roles: 'admin'[];
124
+ auth: {
125
+ method: Method;
126
+ subject: string;
127
+ verified: boolean;
128
+ };
129
+ defaultProfile: string;
130
+ profiles: AuthProfile[];
131
+ }
132
+ export declare enum KYCState {
133
+ absent = "absent",
134
+ submitted = "submitted",
135
+ pending = "pending",
136
+ confirmed = "confirmed"
137
+ }
138
+ export declare enum KYCOutcome {
139
+ approved = "approved",
140
+ rejected = "rejected",
141
+ unknown = "unknown"
142
+ }
143
+ export declare enum AccountState {
144
+ requested = "requested",
145
+ approved = "approved",
146
+ pending = "pending"
147
+ }
148
+ export interface KYC {
149
+ state: KYCState;
150
+ outcome: KYCOutcome;
151
+ }
152
+ export declare enum PaymentStandard {
153
+ iban = "iban",
154
+ scan = "scan"
155
+ }
156
+ export interface Account {
157
+ address: string;
158
+ currency: Currency;
159
+ standard: PaymentStandard;
160
+ iban?: string;
161
+ network: Network;
162
+ chain: Chain;
163
+ id?: string;
164
+ state?: AccountState;
165
+ }
166
+ export interface Profile {
167
+ id: string;
168
+ name: string;
169
+ kyc: KYC;
170
+ accounts: Account[];
171
+ }
172
+ export interface Balance {
173
+ currency: Currency;
174
+ amount: string;
175
+ }
176
+ export interface Balances {
177
+ id: string;
178
+ address: string;
179
+ chain: Chain;
180
+ network: Network;
181
+ balances: Balance[];
182
+ }
183
+ export declare enum OrderKind {
184
+ redeem = "redeem",
185
+ issue = "issue"
186
+ }
187
+ export declare enum OrderState {
188
+ placed = "placed",
189
+ pending = "pending",
190
+ processed = "processed",
191
+ rejected = "rejected"
192
+ }
193
+ export interface Fee {
194
+ provider: 'satchel';
195
+ currency: Currency;
196
+ amount: string;
197
+ }
198
+ export interface IBAN {
199
+ standard: PaymentStandard.iban;
200
+ iban: string;
201
+ }
202
+ export interface SCAN {
203
+ standard: PaymentStandard.scan;
204
+ sortCode: string;
205
+ accountNumber: string;
206
+ }
207
+ export interface Individual {
208
+ firstName: string;
209
+ lastName: string;
210
+ country?: string;
211
+ }
212
+ export interface Corporation {
213
+ companyName: string;
214
+ country: string;
215
+ }
216
+ export interface Counterpart {
217
+ identifier: IBAN | SCAN;
218
+ details: Individual | Corporation;
219
+ }
220
+ export interface OrderMetadata {
221
+ approvedAt: string;
222
+ processedAt: string;
223
+ rejectedAt: string;
224
+ state: OrderState;
225
+ placedBy: string;
226
+ placedAt: string;
227
+ receivedAmount: string;
228
+ sentAmount: string;
229
+ }
230
+ export interface OrderFilter {
231
+ address?: string;
232
+ txHash?: string;
233
+ profile?: string;
234
+ memo?: string;
235
+ accountId?: string;
236
+ state?: OrderState;
237
+ }
238
+ export interface Order {
239
+ id: string;
240
+ profile: string;
241
+ accountId: string;
242
+ address: string;
243
+ kind: OrderKind;
244
+ amount: string;
245
+ currency: Currency;
246
+ totalFee: string;
247
+ fees: Fee[];
248
+ counterpart: Counterpart;
249
+ memo: string;
250
+ rejectedReason: string;
251
+ supportingDocumentId: string;
252
+ meta: OrderMetadata;
253
+ }
254
+ /**
255
+ * Information about the EURe token on different networks.
256
+ */
257
+ export interface Token {
258
+ currency: Currency;
259
+ ticker: Ticker;
260
+ symbol: TokenSymbol;
261
+ chain: Chain;
262
+ network: Network;
263
+ /** The address of the EURe contract on this network */
264
+ address: string;
265
+ /** How many decimals this token supports */
266
+ decimals: number;
267
+ }
268
+ export type NewOrder = NewOrderByAddress | NewOrderByAccountId;
269
+ export interface NewOrderCommon {
270
+ amount: string;
271
+ signature: string;
272
+ counterpart: Counterpart;
273
+ message: string;
274
+ memo?: string;
275
+ supportingDocumentId?: string;
276
+ }
277
+ export interface NewOrderByAddress extends NewOrderCommon {
278
+ address: string;
279
+ chain: Chain;
280
+ network: Network;
281
+ }
282
+ export interface NewOrderByAccountId extends NewOrderCommon {
283
+ accountId: string;
284
+ }
285
+ export interface SupportingDocMetadata {
286
+ uploadedBy: string;
287
+ createdAt: string;
288
+ updatedAt: string;
289
+ }
290
+ export interface SupportingDoc {
291
+ id: string;
292
+ name: string;
293
+ type: string;
294
+ size: number;
295
+ hash: string;
296
+ meta: SupportingDocMetadata;
297
+ }
298
+ export interface CurrencyAccounts {
299
+ network: Network;
300
+ chain: Chain;
301
+ currency: Currency;
302
+ }
303
+ export interface LinkAddress {
304
+ address: string;
305
+ message: string;
306
+ signature: string;
307
+ accounts: CurrencyAccounts[];
308
+ network?: Network;
309
+ chain?: Chain;
310
+ }
311
+ export type OrderNotification = {
312
+ id: string;
313
+ profile: string;
314
+ accountId: string;
315
+ address: string;
316
+ kind: string;
317
+ amount: string;
318
+ currency: string;
319
+ totalFee: string;
320
+ fees: Fee[];
321
+ counterpart: Counterpart;
322
+ memo: string;
323
+ rejectedReason: string;
324
+ supportingDocumentId: string;
325
+ meta: OrderMetadata;
326
+ };
327
+ export type MoneriumEvent = OrderState;
328
+ export type MoneriumEventListener = (notification: OrderNotification) => void;
329
+ export type ClassOptions = {
330
+ environment?: ENV;
331
+ } & BearerTokenCredentials;
332
+ export type AuthFlowOptions = {
333
+ clientId?: string;
334
+ redirectUrl?: string;
335
+ address?: string;
336
+ signature?: string;
337
+ chainId?: number;
338
+ };
339
+ export type ClientCredentials = {
340
+ clientId: string;
341
+ clientSecret: string;
342
+ };
343
+ export type AuthorizationCodeCredentials = {
344
+ clientId: string;
345
+ redirectUrl: string;
346
+ };
347
+ export type BearerTokenCredentials = ClientCredentials | AuthorizationCodeCredentials;
348
+ export {};
@@ -0,0 +1,27 @@
1
+ import { Balances, Chain, ChainId, Networks, Profile } from '../src/types';
2
+ export declare const rfc3339: (d: Date) => string;
3
+ /**
4
+ * The message to be signed when placing an order.
5
+ *
6
+ * @returns string
7
+ */
8
+ export declare const placeOrderMessage: (amount: string | number, iban: string) => string;
9
+ /**
10
+ * Replacement for URLSearchParams, Metamask snaps do not include node globals.
11
+ * It will not handle all special characters the same way as URLSearchParams, but it will be good enough for our use case.
12
+ * @param body a json format of the body to be encoded
13
+ * @returns 'application/x-www-form-urlencoded' compatible string
14
+ */
15
+ export declare const urlEncoded: (body: Record<string, string>) => string | undefined;
16
+ /**
17
+ * Get the corresponding Monerium SDK Chain from the current chain id
18
+ * @returns The Chain
19
+ */
20
+ export declare const getChain: (chainId: number) => Chain;
21
+ /**
22
+ * Get the corresponding Monerium SDK Network from the current chain id
23
+ * @returns The Network
24
+ */
25
+ export declare const getNetwork: (chainId: number) => Networks;
26
+ export declare const getIban: (profile: Profile, address: string, chainId: number) => string;
27
+ export declare const getAmount: (balances?: Balances[], address?: string, chainId?: ChainId) => string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@monerium/sdk",
3
- "version": "2.6.4",
3
+ "version": "2.7.0",
4
4
  "description": "Everything you need to interact with the Monerium API - an electronic money issuer.",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -10,62 +10,32 @@
10
10
  "bugs": {
11
11
  "url": "https://github.com/monerium/sdk/issues"
12
12
  },
13
- "main": "dist/index.umd.js",
14
- "module": "dist/index.mjs",
13
+ "main": "./dist/index.js",
14
+ "module": "./dist/index.mjs",
15
+ "typings": "./dist/index.d.ts",
15
16
  "exports": {
16
17
  ".": {
17
18
  "import": "./dist/index.mjs",
18
- "require": "./dist/index.umd.js"
19
+ "require": "./dist/index.js"
19
20
  }
20
21
  },
21
- "types": "dist/index.d.ts",
22
22
  "files": [
23
23
  "dist"
24
24
  ],
25
25
  "engines": {
26
26
  "node": ">= 16.15"
27
27
  },
28
+ "packageManager": "yarn@3.5.0",
29
+ "dependencies": {
30
+ "crypto-js": "^4.2.0"
31
+ },
28
32
  "scripts": {
29
- "build": "NODE_OPTIONS=--experimental-fetch yarn build:main",
30
- "build:main": "tsc && vite --config ./configs/vite.config.ts build && dts-bundle-generator --config ./configs/dts-bundle-generator.ts",
31
- "clean": "rm -rf dist && rm -rf node_modules && rm -rf static",
32
- "docs": "typedoc --options configs/typedoc.json",
33
- "docs:watch": "yarn docs --watch",
34
- "format": "prettier . --write --ignore-path ./configs/.prettierignore",
35
- "lint": "eslint . -c ./.eslintrc --ext .ts",
36
- "prepare": "husky install",
37
- "prepublish": "yarn build && yarn lint && yarn format && yarn test:coverage",
38
- "test": "NODE_OPTIONS=\"--experimental-fetch --experimental-vm-modules\" yarn test:main",
39
- "test:main": "jest --config ./jest.config.ts",
40
- "test:coverage": "yarn test --coverage",
41
- "watch": "tsc && vite build --config ./configs/vite.config.ts --watch"
33
+ "build:watch": "yarn build:main --watch",
34
+ "docs": "yarn typedoc --options docs/typedoc.json && node docs/editStatic.js",
35
+ "docs:watch": "nodemon --watch . --ignore static -e ts,css,md --exec 'typedoc --options docs/typedoc.json && node docs/editStatic.js'"
42
36
  },
43
37
  "devDependencies": {
44
- "@commitlint/cli": "^17.4.1",
45
- "@commitlint/config-conventional": "^17.4.0",
46
- "@types/crypto-js": "^4.1.1",
47
- "@types/jest": "^29.5.1",
48
- "@types/node": "^18.11.18",
49
- "@typescript-eslint/eslint-plugin": "^5.46.0",
50
- "@typescript-eslint/parser": "^5.46.0",
51
- "crypto-js": "^4.1.1",
52
- "dts-bundle-generator": "^7.1.0",
53
- "eslint": "^8.29.0",
54
- "eslint-config-prettier": "^8.5.0",
55
- "eslint-plugin-jest": "^27.1.7",
56
- "eslint-plugin-prettier": "^4.2.1",
57
- "husky": "^8.0.2",
58
- "jest": "^29.5.0",
59
- "jest-fetch-mock": "^3.0.3",
60
- "prettier": "^2.8.8",
61
- "ts-jest": "^29.0.3",
62
- "ts-node": "^10.9.1",
63
- "tslib": "^2.4.1",
64
- "typedoc": "^0.23.23",
65
- "typedoc-theme-hierarchy": "^3.0.2",
66
- "typescript": "^5.0.4",
67
- "vite": "^4.0.0"
68
- },
69
- "packageManager": "yarn@3.5.0",
70
- "prettier": "./configs/.prettierrc.js"
71
- }
38
+ "typedoc": "0.23.23",
39
+ "typedoc-theme-hierarchy": "^3.2.1"
40
+ }
41
+ }