@monerium/sdk 2.12.0 → 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/dist/client.d.ts DELETED
@@ -1,112 +0,0 @@
1
- import type { AuthArgs, AuthorizationCodeCredentials, AuthContext, Balances, BearerProfile, ClassOptions, ENV, Environment, LinkAddress, MoneriumEvent, MoneriumEventListener, NewOrder, AuthFlowOptions, Order, OrderFilter, PKCERequestArgs, Profile, SupportingDoc, Token, ClientCredentials } from './types';
2
- export declare class MoneriumClient {
3
- #private;
4
- /**
5
- * @deprecated, use localStorage, will be removed in v3
6
- * The PKCE code verifier
7
- * */
8
- codeVerifier?: string;
9
- /** The bearer profile will be available after authentication, it includes the access_token and refresh_token */
10
- bearerProfile?: BearerProfile;
11
- isAuthorized: boolean;
12
- state: string | undefined;
13
- /** Constructor for no arguments, defaults to sandbox */
14
- constructor();
15
- /** Constructor with only env as an argument*/
16
- constructor(env: ENV);
17
- /** Constructor with {@link ClassOptions} */
18
- constructor(options: ClassOptions);
19
- /**
20
- * Construct the url to the authorization code flow,
21
- * Code Verifier needed for the code challenge is stored in local storage
22
- * For automatic wallet link, add the following properties: `address`, `signature` & `chainId`
23
- * @returns string
24
- * {@link https://monerium.dev/api-docs#operation/auth}
25
- */
26
- authorize(client?: AuthFlowOptions): Promise<void>;
27
- /**
28
- * Get access to the API
29
- * @param {AuthorizationCodeCredentials | ClientCredentials} client - the client credentials
30
- * @returns boolean to indicate if access has been granted
31
- */
32
- getAccess(client?: AuthorizationCodeCredentials | ClientCredentials): Promise<boolean>;
33
- /**
34
- * {@link https://monerium.dev/api-docs#operation/auth-context}
35
- */
36
- getAuthContext(): Promise<AuthContext>;
37
- /**
38
- * {@link https://monerium.dev/api-docs#operation/profile}
39
- * @param {string} profileId - the id of the profile to fetch.
40
-
41
- */
42
- getProfile(profileId: string): Promise<Profile>;
43
- /**
44
- * {@link https://monerium.dev/api-docs#operation/profile-balances}
45
- * @param {string=} profileId - the id of the profile to fetch balances.
46
- */
47
- getBalances(profileId?: string): Promise<Balances[]>;
48
- /**
49
- * {@link https://monerium.dev/api-docs#operation/orders}
50
- */
51
- getOrders(filter?: OrderFilter): Promise<Order[]>;
52
- /**
53
- * {@link https://monerium.dev/api-docs#operation/order}
54
- */
55
- getOrder(orderId: string): Promise<Order>;
56
- /**
57
- * {@link https://monerium.dev/api-docs#operation/tokens}
58
- */
59
- getTokens(): Promise<Token[]>;
60
- /**
61
- * {@link https://monerium.dev/api-docs#operation/profile-addresses}
62
- */
63
- linkAddress(profileId: string, body: LinkAddress): Promise<unknown>;
64
- /**
65
- * {@link https://monerium.dev/api-docs#operation/post-orders}
66
- */
67
- placeOrder(order: NewOrder, profileId?: string): Promise<Order>;
68
- /**
69
- * {@link https://monerium.dev/api-docs#operation/supporting-document}
70
- */
71
- uploadSupportingDocument(document: File): Promise<SupportingDoc>;
72
- connectOrderSocket(): Promise<void>;
73
- subscribeToOrderNotifications: () => WebSocket;
74
- /**
75
- * Cleanups the socket and the subscriptions
76
- */
77
- disconnect(): Promise<void>;
78
- /**
79
- * Revokes access
80
- */
81
- revokeAccess(): Promise<void>;
82
- /**
83
- * Subscribe to MoneriumEvent to receive notifications using the Monerium API (WebSocket)
84
- * We are setting a subscription map because we need the user to have a token to start the WebSocket connection
85
- * {@link https://monerium.dev/api-docs#operation/profile-orders-notifications}
86
- * @param event The event to subscribe to
87
- * @param handler The handler to be called when the event is triggered
88
- */
89
- subscribeOrders(event: MoneriumEvent, handler: MoneriumEventListener): void;
90
- /**
91
- * Unsubscribe from MoneriumEvent and close the socket if there are no more subscriptions
92
- * @param event The event to unsubscribe from
93
- */
94
- unsubscribeOrders(event: MoneriumEvent): void;
95
- /**
96
- * @deprecated since v2.6.4, will be removed in 2.7.2+, use {@link getAccess} instead.
97
- */
98
- auth: (args: AuthArgs) => Promise<BearerProfile>;
99
- /**
100
- * @deprecated since v2.7.1, will be removed in 2.7.2+, use {@link getAccess} instead.
101
- */
102
- connect: (args: AuthArgs) => Promise<BearerProfile>;
103
- /**
104
- * @deprecated since v2.6.4, will be removed in 2.7.2+, use {@link authorize} instead.
105
- */
106
- getAuthFlowURI: (args: PKCERequestArgs) => string;
107
- /**
108
- * @deprecated since v2.0.7, will be removed in 2.7.2+, use {@link getAuthFlowURI} instead.
109
- */
110
- pkceRequest: (args: PKCERequestArgs) => string;
111
- getEnvironment: () => Environment;
112
- }
package/dist/config.d.ts DELETED
@@ -1,3 +0,0 @@
1
- import type { Config } from './types';
2
- declare const MONERIUM_CONFIG: Config;
3
- export { MONERIUM_CONFIG };
@@ -1,9 +0,0 @@
1
- export declare const LINK_MESSAGE = "I hereby declare that I am the address owner.";
2
- export declare const STORAGE_CODE_VERIFIER = "monerium.sdk.code_verifier";
3
- export declare const STORAGE_REFRESH_TOKEN = "monerium.sdk.refresh_token";
4
- declare const constants: {
5
- LINK_MESSAGE: string;
6
- STORAGE_CODE_VERIFIER: string;
7
- STORAGE_REFRESH_TOKEN: string;
8
- };
9
- export default constants;
@@ -1,23 +0,0 @@
1
- import { AuthArgs, AuthCodeRequest, ClientCredentialsRequest, PKCERequestArgs, RefreshTokenRequest } from '../types';
2
- /** Structure the Auth Flow params, support for ChainId instead of chain & network */
3
- export declare const getAuthFlowParams: (args: PKCERequestArgs, codeChallenge: string) => string | undefined;
4
- /**
5
- * Find a more secure way to generate a random string
6
- * Using crypto-js to generate a random string was causing the following error:
7
- * `Error: Native crypto module could not be used to get secure random number.`
8
- * https://github.com/brix/crypto-js/issues/256
9
- */
10
- export declare const generateRandomString: () => string;
11
- /** Generate the PKCE code challenge */
12
- export declare const generateCodeChallenge: (codeVerifier: string) => string;
13
- /**
14
- * Constructs the Auth Flow URL and stores the code verifier in the local storage
15
- */
16
- export declare const getAuthFlowUrlAndStoreCodeVerifier: (baseUrl: string, args: PKCERequestArgs) => string;
17
- /**
18
- * Clean the query string from the URL
19
- */
20
- export declare const cleanQueryString: () => void;
21
- export declare const isAuthCode: (args: AuthArgs) => args is AuthCodeRequest;
22
- export declare const isRefreshToken: (args: AuthArgs) => args is RefreshTokenRequest;
23
- export declare const isClientCredentials: (args: AuthArgs) => args is ClientCredentialsRequest;
@@ -1,2 +0,0 @@
1
- export * from './auth.helpers';
2
- export * from './service.helpers';
@@ -1 +0,0 @@
1
- export declare const rest: <T>(url: string, method: string, body?: BodyInit | Record<string, string>, headers?: Record<string, string>) => Promise<T>;
package/dist/package.json DELETED
@@ -1,40 +0,0 @@
1
- {
2
- "name": "@monerium/sdk",
3
- "version": "2.12.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/js-sdk.git"
9
- },
10
- "bugs": {
11
- "url": "https://github.com/monerium/js-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
- "dependencies": {
29
- "crypto-js": "^4.2.0"
30
- },
31
- "scripts": {
32
- "docs": "yarn typedoc --options docs/typedoc.json && node docs/editStatic.js",
33
- "docs:watch": "nodemon --watch . --ignore static -e ts,css,md --exec 'typedoc --options docs/typedoc.json && node docs/editStatic.js'"
34
- },
35
- "devDependencies": {
36
- "nodemon": "3.0.1",
37
- "typedoc": "0.23.23",
38
- "typedoc-theme-hierarchy": "^3.2.1"
39
- }
40
- }
package/dist/types.d.ts DELETED
@@ -1,373 +0,0 @@
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 = 'sepolia';
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 = number | 1 | 11155111 | 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 */
93
- network?: Network;
94
- /** @deprecated - Use chainId */
95
- chain?: Chain;
96
- /** The network of the wallet to automatically link */
97
- chainId?: ChainId;
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
- chain = "chain"
156
- }
157
- export interface Identifier {
158
- standard: PaymentStandard;
159
- bic?: string;
160
- }
161
- export interface Account {
162
- address: string;
163
- currency: Currency;
164
- standard: PaymentStandard;
165
- iban?: string;
166
- network: Network;
167
- chain: Chain;
168
- id?: string;
169
- state?: AccountState;
170
- }
171
- export interface Profile {
172
- id: string;
173
- name: string;
174
- kyc: KYC;
175
- accounts: Account[];
176
- }
177
- export interface Balance {
178
- currency: Currency;
179
- amount: string;
180
- }
181
- export interface Balances {
182
- id: string;
183
- address: string;
184
- chain: Chain;
185
- network: Network;
186
- balances: Balance[];
187
- }
188
- export declare enum OrderKind {
189
- redeem = "redeem",
190
- issue = "issue"
191
- }
192
- export declare enum OrderState {
193
- placed = "placed",
194
- pending = "pending",
195
- processed = "processed",
196
- rejected = "rejected"
197
- }
198
- export interface Fee {
199
- provider: 'satchel';
200
- currency: Currency;
201
- amount: string;
202
- }
203
- export interface IBAN extends Identifier {
204
- standard: PaymentStandard.iban;
205
- iban: string;
206
- }
207
- export interface CrossChain extends Identifier {
208
- standard: PaymentStandard.chain;
209
- address: string;
210
- chainId: ChainId;
211
- /** @deprecated - Use chainId */
212
- chain?: Chain;
213
- /** @deprecated - Use chainId */
214
- network?: Network;
215
- }
216
- export interface SCAN extends Identifier {
217
- standard: PaymentStandard.scan;
218
- sortCode: string;
219
- accountNumber: string;
220
- }
221
- export interface Individual {
222
- firstName: string;
223
- lastName: string;
224
- country?: string;
225
- }
226
- export interface Corporation {
227
- companyName: string;
228
- country: string;
229
- }
230
- export interface Counterpart {
231
- identifier: IBAN | SCAN | CrossChain;
232
- details: Individual | Corporation;
233
- }
234
- export interface OrderMetadata {
235
- approvedAt: string;
236
- processedAt: string;
237
- rejectedAt: string;
238
- state: OrderState;
239
- placedBy: string;
240
- placedAt: string;
241
- receivedAmount: string;
242
- sentAmount: string;
243
- }
244
- export interface OrderFilter {
245
- address?: string;
246
- txHash?: string;
247
- profile?: string;
248
- memo?: string;
249
- accountId?: string;
250
- state?: OrderState;
251
- }
252
- export interface Order {
253
- id: string;
254
- profile: string;
255
- accountId: string;
256
- address: string;
257
- kind: OrderKind;
258
- amount: string;
259
- currency: Currency;
260
- totalFee: string;
261
- fees: Fee[];
262
- counterpart: Counterpart;
263
- memo: string;
264
- rejectedReason: string;
265
- supportingDocumentId: string;
266
- meta: OrderMetadata;
267
- }
268
- /**
269
- * Information about the EURe token on different networks.
270
- */
271
- export interface Token {
272
- currency: Currency;
273
- ticker: Ticker;
274
- symbol: TokenSymbol;
275
- chain: Chain;
276
- network: Network;
277
- /** The address of the EURe contract on this network */
278
- address: string;
279
- /** How many decimals this token supports */
280
- decimals: number;
281
- }
282
- export type NewOrder = NewOrderByAddress | NewOrderByAccountId;
283
- export interface NewOrderCommon {
284
- amount: string;
285
- signature: string;
286
- currency?: Currency /** Not needed right now, only EUR */;
287
- counterpart: Counterpart;
288
- message: string;
289
- memo?: string;
290
- supportingDocumentId?: string;
291
- }
292
- export interface NewOrderByAddress extends NewOrderCommon {
293
- address: string;
294
- /** @deprecated - Use 'chainId' */
295
- chain?: Chain;
296
- /** @deprecated - Use 'chainId' */
297
- network?: Network;
298
- chainId: ChainId;
299
- }
300
- export interface NewOrderByAccountId extends NewOrderCommon {
301
- accountId: string;
302
- }
303
- export interface SupportingDocMetadata {
304
- uploadedBy: string;
305
- createdAt: string;
306
- updatedAt: string;
307
- }
308
- export interface SupportingDoc {
309
- id: string;
310
- name: string;
311
- type: string;
312
- size: number;
313
- hash: string;
314
- meta: SupportingDocMetadata;
315
- }
316
- export interface CurrencyAccounts {
317
- /** @deprecated - Use 'chainId' */
318
- network?: Network;
319
- /** @deprecated - Use 'chainId' */
320
- chain?: Chain;
321
- chainId: ChainId;
322
- currency: Currency;
323
- }
324
- export interface LinkAddress {
325
- address: string;
326
- message: string;
327
- signature: string;
328
- accounts: CurrencyAccounts[];
329
- /** @deprecated - Use 'chainId' */
330
- network?: Network;
331
- /** @deprecated - Use 'chainId' */
332
- chain?: Chain;
333
- chainId?: ChainId;
334
- }
335
- export type OrderNotification = {
336
- id: string;
337
- profile: string;
338
- accountId: string;
339
- address: string;
340
- kind: string;
341
- amount: string;
342
- currency: string;
343
- totalFee: string;
344
- fees: Fee[];
345
- counterpart: Counterpart;
346
- memo: string;
347
- rejectedReason: string;
348
- supportingDocumentId: string;
349
- meta: OrderMetadata;
350
- };
351
- export type MoneriumEvent = OrderState;
352
- export type MoneriumEventListener = (notification: OrderNotification) => void;
353
- export type ClassOptions = {
354
- environment?: ENV;
355
- } & BearerTokenCredentials;
356
- export type AuthFlowOptions = {
357
- clientId?: string;
358
- redirectUrl?: string;
359
- address?: string;
360
- signature?: string;
361
- chainId?: ChainId;
362
- state?: string;
363
- };
364
- export type ClientCredentials = {
365
- clientId: string;
366
- clientSecret: string;
367
- };
368
- export type AuthorizationCodeCredentials = {
369
- clientId: string;
370
- redirectUrl: string;
371
- };
372
- export type BearerTokenCredentials = ClientCredentials | AuthorizationCodeCredentials;
373
- export {};
package/dist/utils.d.ts DELETED
@@ -1,28 +0,0 @@
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, receiver: string, chainId?: number, currency?: 'eur' | 'gbp' | 'usd' | 'isk') => 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;
28
- export declare const mapChainAndNetwork: (body: any) => any;