@monerium/sdk 2.0.0 → 2.0.3

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 ADDED
@@ -0,0 +1,25 @@
1
+ # Changelog
2
+
3
+ ## [2.0.3](https://github.com/monerium/sdk/compare/v2.0.2...v2.0.3) (2023-01-05)
4
+
5
+ ### Bug Fixes
6
+
7
+ - build missing and static page deploy not being triggered([#7](https://github.com/monerium/sdk/issues/7)) ([#9](https://github.com/monerium/sdk/issues/9)) ([0c5e955](https://github.com/monerium/sdk/commit/0c5e955a9823c9d2c79cac5d21120fa49ce79741))
8
+ - workflow ([cb27cb4](https://github.com/monerium/sdk/commit/cb27cb484e6f46beb379d9e46d1874c436eb7208))
9
+ - workflow broken ([09623f0](https://github.com/monerium/sdk/commit/09623f0eee78535ee5e3712e6009e44c6082bbd7))
10
+
11
+ ## [2.0.2](https://github.com/monerium/sdk/compare/v2.0.1...v2.0.2) (2023-01-05)
12
+
13
+ ### Bug Fixes
14
+
15
+ - Update TypeDocs and set workflow to run only on release ([#7](https://github.com/monerium/sdk/issues/7)) ([79c9ec9](https://github.com/monerium/sdk/commit/79c9ec9e7a68ccfb4d9debaacbc9b7b90be0fcde))
16
+
17
+ ## [2.0.1](https://github.com/monerium/sdk/compare/v2.0.0...v2.0.1) (2023-01-05)
18
+
19
+ ### Bug Fixes
20
+
21
+ - Update TypeDocs and set workflow to run only on release ([#7](https://github.com/monerium/sdk/issues/7)) ([553d765](https://github.com/monerium/sdk/commit/553d765a4a40c807de6628b31b59ddf3064f89a4))
22
+
23
+ ### Miscellaneous
24
+
25
+ - cleanup ([5aeebbc](https://github.com/monerium/sdk/commit/5aeebbca9a53592e7229168ad66849113638d070))
package/README.md CHANGED
@@ -5,6 +5,10 @@ Everything you need to interact with the Monerium API - an electronic money issu
5
5
  _This package is in development. Please make sure to check if any future updates contain commits
6
6
  that may change the behavior of your application before you upgrade._
7
7
 
8
+ [Documentation](https://monerium.github.io/sdk/)
9
+
10
+ [Code coverage](https://monerium.github.io/sdk/coverage)
11
+
8
12
  ## Installing
9
13
 
10
14
  ```sh
@@ -22,15 +26,4 @@ yarn add @monerium/sdk
22
26
 
23
27
  ## Publishing
24
28
 
25
- Update your `package.json` to next version number, and remember to tag a release.
26
-
27
- Once ready to submit your package to the NPM Registry, execute the following tasks via `yarn`:
28
-
29
- - `yarn clean` — Assure a clean build
30
- - `yarn build` — Build the package
31
-
32
- Submit your package to the registry:
33
-
34
- ```
35
- yarn publish
36
- ```
29
+ 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.
@@ -0,0 +1,314 @@
1
+ // Generated by dts-bundle-generator v7.1.0
2
+
3
+ export type Environment = {
4
+ api: string;
5
+ web: string;
6
+ };
7
+ export type Config = {
8
+ environments: {
9
+ production: Environment;
10
+ sandbox: Environment;
11
+ };
12
+ };
13
+ export interface BearerProfile {
14
+ access_token: string;
15
+ token_type: string;
16
+ expires_in: number;
17
+ refresh_token: string;
18
+ profile: string;
19
+ userId: string;
20
+ }
21
+ export declare enum Currency {
22
+ eur = "eur",
23
+ usd = "usd",
24
+ gbp = "gbp",
25
+ isk = "isk",
26
+ }
27
+ export type AuthArgs =
28
+ | Omit<AuthCode, "grant_type">
29
+ | Omit<RefreshToken, "grant_type">
30
+ | Omit<ClientCredentials, "grant_type">;
31
+ export interface AuthCode {
32
+ grant_type: "authorization_code";
33
+ client_id: string;
34
+ code: string;
35
+ code_verifier: string;
36
+ redirect_uri: string;
37
+ scope?: string;
38
+ }
39
+ export interface RefreshToken {
40
+ grant_type: "refresh_token";
41
+ client_id: string;
42
+ refresh_token: string;
43
+ scope?: string;
44
+ }
45
+ export interface ClientCredentials {
46
+ grant_type: "client_credentials";
47
+ client_id: string;
48
+ client_secret: string;
49
+ scope?: string;
50
+ }
51
+ export type PKCERequestArgs = Omit<
52
+ PKCERequest,
53
+ "code_challenge" | "code_challenge_method" | "response_type"
54
+ >;
55
+ export type PKCERequest = {
56
+ client_id: string;
57
+ code_challenge: string;
58
+ code_challenge_method: string;
59
+ response_type: string;
60
+ state: string;
61
+ redirect_uri?: string;
62
+ scope?: string;
63
+ address?: string;
64
+ };
65
+ declare enum Method {
66
+ password = "password",
67
+ resource = "resource",
68
+ jwt = "jwt",
69
+ apiKey = "apiKey",
70
+ }
71
+ export declare enum ProfileType {
72
+ corporate = "corporate",
73
+ personal = "personal",
74
+ }
75
+ export declare enum Permission {
76
+ read = "read",
77
+ write = "write",
78
+ }
79
+ export interface AuthProfile {
80
+ id: string;
81
+ type: ProfileType;
82
+ name: string;
83
+ perms: Permission[];
84
+ }
85
+ export interface AuthContext {
86
+ userId: string;
87
+ email: string;
88
+ name: string;
89
+ roles: "admin"[];
90
+ auth: {
91
+ method: Method;
92
+ subject: string;
93
+ verified: boolean;
94
+ };
95
+ defaultProfile: string;
96
+ profiles: AuthProfile[];
97
+ }
98
+ export declare enum KYCState {
99
+ absent = "absent",
100
+ submitted = "submitted",
101
+ pending = "pending",
102
+ confirmed = "confirmed",
103
+ }
104
+ export declare enum KYCOutcome {
105
+ approved = "approved",
106
+ rejected = "rejected",
107
+ unknown = "unknown",
108
+ }
109
+ export interface KYC {
110
+ state: KYCState;
111
+ outcome: KYCOutcome;
112
+ }
113
+ export declare enum PaymentStandard {
114
+ iban = "iban",
115
+ scan = "scan",
116
+ }
117
+ export interface Account {
118
+ address: string;
119
+ currency: Currency;
120
+ standard: PaymentStandard;
121
+ iban?: string;
122
+ sortCode?: string;
123
+ accountNumber?: string;
124
+ network: Network;
125
+ chain: Chain;
126
+ id?: string;
127
+ }
128
+ export interface Profile {
129
+ id: string;
130
+ name: string;
131
+ kyc: KYC;
132
+ accounts: Account[];
133
+ }
134
+ export declare enum Chain {
135
+ polygon = "polygon",
136
+ ethereum = "ethereum",
137
+ gnosis = "gnosis",
138
+ }
139
+ export declare enum Network {
140
+ mainnet = "mainnet",
141
+ chiado = "chiado",
142
+ goerli = "goerli",
143
+ mumbai = "mumbai",
144
+ }
145
+ export interface Balance {
146
+ currency: Currency;
147
+ amount: string;
148
+ }
149
+ export interface Balances {
150
+ id: string;
151
+ address: string;
152
+ chain: Chain;
153
+ network: Network;
154
+ balances: Balance[];
155
+ }
156
+ export declare enum OrderKind {
157
+ redeem = "redeem",
158
+ issue = "issue",
159
+ }
160
+ export declare enum OrderState {
161
+ placed = "placed",
162
+ pending = "pending",
163
+ processed = "processed",
164
+ rejected = "rejected",
165
+ }
166
+ export interface Fee {
167
+ provider: "satchel";
168
+ currency: Currency;
169
+ amount: string;
170
+ }
171
+ export interface IBAN {
172
+ standard: PaymentStandard.iban;
173
+ iban: string;
174
+ }
175
+ export interface SCAN {
176
+ standard: PaymentStandard.scan;
177
+ sortCode: string;
178
+ accountNumber: string;
179
+ }
180
+ export interface Individual {
181
+ firstName: string;
182
+ lastName: string;
183
+ country?: string;
184
+ }
185
+ export interface Corporation {
186
+ companyName: string;
187
+ country: string;
188
+ }
189
+ export interface Counterpart {
190
+ identifier: IBAN | SCAN;
191
+ details: Individual | Corporation;
192
+ }
193
+ export interface OrderMetadata {
194
+ approvedAt: string;
195
+ processedAt: string;
196
+ rejectedAt: string;
197
+ state: OrderState;
198
+ placedBy: string;
199
+ placedAt: string;
200
+ receivedAmount: string;
201
+ sentAmount: string;
202
+ }
203
+ export interface OrderFilter {
204
+ address?: string;
205
+ txHash?: string;
206
+ profile?: string;
207
+ memo?: string;
208
+ accountId?: string;
209
+ state?: OrderState;
210
+ }
211
+ export interface Order {
212
+ id: string;
213
+ profile: string;
214
+ accountId: string;
215
+ address: string;
216
+ kind: OrderKind;
217
+ amount: string;
218
+ currency: Currency;
219
+ totalFee: string;
220
+ fees: Fee[];
221
+ counterpart: Counterpart;
222
+ memo: string;
223
+ rejectedReason: string;
224
+ supportingDocumentId: string;
225
+ meta: OrderMetadata;
226
+ }
227
+ export interface Token {
228
+ currency: Currency;
229
+ ticker: string;
230
+ symbol: string;
231
+ chain: Chain;
232
+ network: Network;
233
+ address: string;
234
+ decimals: number;
235
+ }
236
+ export interface NewOrder {
237
+ kind: OrderKind;
238
+ amount: string;
239
+ signature: string;
240
+ accountId?: string;
241
+ address: string;
242
+ currency: Currency;
243
+ counterpart: Counterpart;
244
+ message: string;
245
+ memo: string;
246
+ supportingDocumentId?: string;
247
+ chain: Chain;
248
+ network: Network;
249
+ }
250
+ export interface SupportingDocMetadata {
251
+ uploadedBy: string;
252
+ createdAt: string;
253
+ updatedAt: string;
254
+ }
255
+ export interface SupportingDoc {
256
+ id: string;
257
+ name: string;
258
+ type: string;
259
+ size: number;
260
+ hash: string;
261
+ meta: SupportingDocMetadata;
262
+ }
263
+ export interface CurrencyAccounts {
264
+ network: Network;
265
+ chain: Chain;
266
+ currency: Currency;
267
+ }
268
+ export interface LinkAddress {
269
+ address: string;
270
+ message: string;
271
+ signature: string;
272
+ accounts: CurrencyAccounts[];
273
+ }
274
+ /**
275
+ * How to authenticate
276
+ * ```ts
277
+ *
278
+ * import { MoneriumClient } from '@monerium/sdk'
279
+ *
280
+ * const client = new MoneriumClient();
281
+ *
282
+ * // Start by authenticating
283
+ * await client.auth({
284
+ * client_id:
285
+ * client_secret:
286
+ * })
287
+ * ```
288
+ * */
289
+ export declare class MoneriumClient {
290
+ #private;
291
+ /** The PKCE code verifier */
292
+ codeVerifier?: string;
293
+ bearerProfile?: BearerProfile;
294
+ constructor(env?: "production" | "sandbox");
295
+ auth(args: AuthArgs): Promise<void>;
296
+ pkceRequest(args: PKCERequestArgs): string;
297
+ getAuthContext(): Promise<AuthContext>;
298
+ /**
299
+ * @param {string} profileId - the id of the profile to fetch.
300
+ */
301
+ getProfile(profileId: string): Promise<Profile>;
302
+ /**
303
+ * @param {string=} profileId - the id of the profile to fetch balances.
304
+ */
305
+ getBalances(profileId?: string): Promise<Balances> | Promise<Balances[]>;
306
+ getOrders(filter?: OrderFilter): Promise<Order[]>;
307
+ getOrder(orderId: string): Promise<Order>;
308
+ getTokens(): Promise<Token[]>;
309
+ linkAddress(profileId: string, body: LinkAddress): Promise<any>;
310
+ placeOrder(order: NewOrder, profileId?: string): Promise<Order>;
311
+ uploadSupportingDocument(document: File): Promise<SupportingDoc>;
312
+ }
313
+
314
+ export {};
package/dist/index.es.js CHANGED
@@ -19,18 +19,6 @@ var E = (e, t, i) => (
19
19
  F(e, t, "write to private field"), c ? c.call(e, i) : t.set(e, i), i
20
20
  );
21
21
  var x = (e, t, i) => (F(e, t, "access private method"), i);
22
- const se = {
23
- environments: {
24
- production: {
25
- api: "https://api.monerium.app",
26
- web: "https://monerium.app",
27
- },
28
- sandbox: {
29
- api: "https://api.monerium.dev",
30
- web: "https://sandbox.monerium.dev",
31
- },
32
- },
33
- };
34
22
  var U =
35
23
  typeof globalThis < "u"
36
24
  ? globalThis
@@ -41,7 +29,7 @@ var U =
41
29
  : typeof self < "u"
42
30
  ? self
43
31
  : {};
44
- function ae(e) {
32
+ function se(e) {
45
33
  if (e.__esModule) return e;
46
34
  var t = e.default;
47
35
  if (typeof t == "function") {
@@ -77,7 +65,7 @@ function ae(e) {
77
65
  );
78
66
  }
79
67
  var M = {},
80
- ce = {
68
+ ae = {
81
69
  get exports() {
82
70
  return M;
83
71
  },
@@ -85,7 +73,7 @@ var M = {},
85
73
  M = e;
86
74
  },
87
75
  };
88
- function ue(e) {
76
+ function ce(e) {
89
77
  throw new Error(
90
78
  'Could not dynamically require "' +
91
79
  e +
@@ -93,7 +81,7 @@ function ue(e) {
93
81
  );
94
82
  }
95
83
  var L = {},
96
- fe = {
84
+ ue = {
97
85
  get exports() {
98
86
  return L;
99
87
  },
@@ -101,18 +89,18 @@ var L = {},
101
89
  L = e;
102
90
  },
103
91
  };
104
- const le = {},
105
- he = /* @__PURE__ */ Object.freeze(
92
+ const fe = {},
93
+ le = /* @__PURE__ */ Object.freeze(
106
94
  /* @__PURE__ */ Object.defineProperty(
107
95
  {
108
96
  __proto__: null,
109
- default: le,
97
+ default: fe,
110
98
  },
111
99
  Symbol.toStringTag,
112
100
  { value: "Module" }
113
101
  )
114
102
  ),
115
- pe = /* @__PURE__ */ ae(he);
103
+ he = /* @__PURE__ */ se(le);
116
104
  var Q;
117
105
  function G() {
118
106
  return (
@@ -137,10 +125,10 @@ function G() {
137
125
  window.msCrypto &&
138
126
  (p = window.msCrypto),
139
127
  !p && typeof U < "u" && U.crypto && (p = U.crypto),
140
- !p && typeof ue == "function")
128
+ !p && typeof ce == "function")
141
129
  )
142
130
  try {
143
- p = pe;
131
+ p = he;
144
132
  } catch {}
145
133
  var R = function () {
146
134
  if (p) {
@@ -362,7 +350,7 @@ function G() {
362
350
  })(Math);
363
351
  return i;
364
352
  });
365
- })(fe)),
353
+ })(ue)),
366
354
  L
367
355
  );
368
356
  }
@@ -430,9 +418,9 @@ function G() {
430
418
  i.enc.Base64url
431
419
  );
432
420
  });
433
- })(ce);
421
+ })(ae);
434
422
  var V = {},
435
- ve = {
423
+ pe = {
436
424
  get exports() {
437
425
  return V;
438
426
  },
@@ -440,6 +428,53 @@ var V = {},
440
428
  V = e;
441
429
  },
442
430
  };
431
+ (function (e, t) {
432
+ (function (i, c) {
433
+ e.exports = c(G());
434
+ })(U, function (i) {
435
+ return (
436
+ (function () {
437
+ if (typeof ArrayBuffer == "function") {
438
+ var c = i,
439
+ y = c.lib,
440
+ p = y.WordArray,
441
+ R = p.init,
442
+ k = (p.init = function (a) {
443
+ if (
444
+ (a instanceof ArrayBuffer && (a = new Uint8Array(a)),
445
+ (a instanceof Int8Array ||
446
+ (typeof Uint8ClampedArray < "u" &&
447
+ a instanceof Uint8ClampedArray) ||
448
+ a instanceof Int16Array ||
449
+ a instanceof Uint16Array ||
450
+ a instanceof Int32Array ||
451
+ a instanceof Uint32Array ||
452
+ a instanceof Float32Array ||
453
+ a instanceof Float64Array) &&
454
+ (a = new Uint8Array(a.buffer, a.byteOffset, a.byteLength)),
455
+ a instanceof Uint8Array)
456
+ ) {
457
+ for (var w = a.byteLength, d = [], l = 0; l < w; l++)
458
+ d[l >>> 2] |= a[l] << (24 - (l % 4) * 8);
459
+ R.call(this, d, w);
460
+ } else R.apply(this, arguments);
461
+ });
462
+ k.prototype = p;
463
+ }
464
+ })(),
465
+ i.lib.WordArray
466
+ );
467
+ });
468
+ })(pe);
469
+ var N = {},
470
+ ve = {
471
+ get exports() {
472
+ return N;
473
+ },
474
+ set exports(e) {
475
+ N = e;
476
+ },
477
+ };
443
478
  (function (e, t) {
444
479
  (function (i, c) {
445
480
  e.exports = c(G());
@@ -558,53 +593,18 @@ var V = {},
558
593
  );
559
594
  });
560
595
  })(ve);
561
- var N = {},
562
- de = {
563
- get exports() {
564
- return N;
596
+ const de = {
597
+ environments: {
598
+ production: {
599
+ api: "https://api.monerium.app",
600
+ web: "https://monerium.app",
565
601
  },
566
- set exports(e) {
567
- N = e;
602
+ sandbox: {
603
+ api: "https://api.monerium.dev",
604
+ web: "https://sandbox.monerium.dev",
568
605
  },
569
- };
570
- (function (e, t) {
571
- (function (i, c) {
572
- e.exports = c(G());
573
- })(U, function (i) {
574
- return (
575
- (function () {
576
- if (typeof ArrayBuffer == "function") {
577
- var c = i,
578
- y = c.lib,
579
- p = y.WordArray,
580
- R = p.init,
581
- k = (p.init = function (a) {
582
- if (
583
- (a instanceof ArrayBuffer && (a = new Uint8Array(a)),
584
- (a instanceof Int8Array ||
585
- (typeof Uint8ClampedArray < "u" &&
586
- a instanceof Uint8ClampedArray) ||
587
- a instanceof Int16Array ||
588
- a instanceof Uint16Array ||
589
- a instanceof Int32Array ||
590
- a instanceof Uint32Array ||
591
- a instanceof Float32Array ||
592
- a instanceof Float64Array) &&
593
- (a = new Uint8Array(a.buffer, a.byteOffset, a.byteLength)),
594
- a instanceof Uint8Array)
595
- ) {
596
- for (var w = a.byteLength, d = [], l = 0; l < w; l++)
597
- d[l >>> 2] |= a[l] << (24 - (l % 4) * 8);
598
- R.call(this, d, w);
599
- } else R.apply(this, arguments);
600
- });
601
- k.prototype = p;
602
- }
603
- })(),
604
- i.lib.WordArray
605
- );
606
- });
607
- })(de);
606
+ },
607
+ };
608
608
  var O, z, S, A, T, X, q, Z, I, K;
609
609
  class Re {
610
610
  constructor(t = "sandbox") {
@@ -616,7 +616,7 @@ class Re {
616
616
  P(this, z, void 0);
617
617
  j(this, "codeVerifier");
618
618
  j(this, "bearerProfile");
619
- D(this, O, se.environments[t]);
619
+ D(this, O, de.environments[t]);
620
620
  }
621
621
  async auth(t) {
622
622
  let i;
@@ -637,8 +637,8 @@ class Re {
637
637
  D(this, z, `Bearer ${this.bearerProfile.access_token}`);
638
638
  }
639
639
  pkceRequest(t) {
640
- this.codeVerifier = N.random(64).toString();
641
- const i = M.stringify(V(this.codeVerifier)),
640
+ this.codeVerifier = V.random(64).toString();
641
+ const i = M.stringify(N(this.codeVerifier)),
642
642
  c = {
643
643
  ...t,
644
644
  code_challenge: i,