@monerium/sdk 2.0.7 → 2.0.10
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 +23 -0
- package/README.md +60 -6
- package/dist/index.d.ts +26 -26
- package/dist/index.es.js +122 -120
- package/dist/index.es.js.map +1 -1
- package/dist/index.umd.js +128 -126
- package/dist/index.umd.js.map +1 -1
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,28 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [2.0.10](https://github.com/monerium/sdk/compare/v2.0.9...v2.0.10) (2023-02-16)
|
|
4
|
+
|
|
5
|
+
### Miscellaneous
|
|
6
|
+
|
|
7
|
+
- define properties for automatic wallet link on auth flow ([#19](https://github.com/monerium/sdk/issues/19)) ([3bf845c](https://github.com/monerium/sdk/commit/3bf845cac60bb8a2d5ee7a9dbfa56c76f6996178))
|
|
8
|
+
|
|
9
|
+
## [2.0.9](https://github.com/monerium/sdk/compare/v2.0.8...v2.0.9) (2023-02-06)
|
|
10
|
+
|
|
11
|
+
### Bug Fixes
|
|
12
|
+
|
|
13
|
+
- build files ([1b0f99f](https://github.com/monerium/sdk/commit/1b0f99fcc6635de69b62de72198f22daa2d36b10))
|
|
14
|
+
|
|
15
|
+
## [2.0.8](https://github.com/monerium/sdk/compare/v2.0.7...v2.0.8) (2023-02-06)
|
|
16
|
+
|
|
17
|
+
### Bug Fixes
|
|
18
|
+
|
|
19
|
+
- move dts-bundle config to configs and update paths ([2de558f](https://github.com/monerium/sdk/commit/2de558f6c69b5c72d77ee1065e326d05072ad16c))
|
|
20
|
+
|
|
21
|
+
### Miscellaneous
|
|
22
|
+
|
|
23
|
+
- add getting started to README and document pckeRequest ([8cf68dd](https://github.com/monerium/sdk/commit/8cf68dd7fcf28b098192ca0da8dfdb3878a3e449))
|
|
24
|
+
- deprecate pkceRequest for getAuthFlowURI ([4f33174](https://github.com/monerium/sdk/commit/4f33174abbdbc0758b61efc4161e4fc234524ca5))
|
|
25
|
+
|
|
3
26
|
## [2.0.7](https://github.com/monerium/sdk/compare/v2.0.6...v2.0.7) (2023-01-11)
|
|
4
27
|
|
|
5
28
|
### Miscellaneous
|
package/README.md
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
# @monerium/sdk
|
|
2
2
|
|
|
3
|
-
Everything you need to interact with the Monerium API - an electronic money issuer.
|
|
3
|
+
Everything you need to interact with the [Monerium API](https://monerium.dev/api-docs) - an electronic money issuer.
|
|
4
4
|
|
|
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/)
|
|
8
|
+
[SDK Documentation](https://monerium.github.io/sdk/)
|
|
9
9
|
|
|
10
10
|
[Code coverage](https://monerium.github.io/sdk/coverage)
|
|
11
11
|
|
|
@@ -16,16 +16,70 @@ that may change the behavior of your application before you upgrade._
|
|
|
16
16
|
yarn add @monerium/sdk
|
|
17
17
|
```
|
|
18
18
|
|
|
19
|
-
## Developing
|
|
20
|
-
|
|
21
|
-
We are using [commitlint](https://github.com/conventional-changelog/commitlint/tree/master/@commitlint/config-conventional) to enforce that developers format the commit messages according to the [Conventional Commits](https://www.conventionalcommits.org/en/v1.0.0/) guidelines.
|
|
22
|
-
|
|
23
19
|
## Usage
|
|
24
20
|
|
|
25
21
|
- `start`: Run Vite in host mode for a local development environment (not included in production build)
|
|
26
22
|
- `watch`: Run Vite in watch mode to detect changes to files during development
|
|
27
23
|
- `build`: Run Vite to build a production release distributable
|
|
28
24
|
|
|
25
|
+
## Getting started
|
|
26
|
+
|
|
27
|
+
If you are new here, we recommend starting in the [Developer Portal](https://monerium.dev/docs/welcome). There you will more about `client_id`'s and ways of authenticating.
|
|
28
|
+
|
|
29
|
+
### Import the SDK and initialize a client
|
|
30
|
+
|
|
31
|
+
```ts
|
|
32
|
+
import { MoneriumClient } from "@monerium/sdk";
|
|
33
|
+
|
|
34
|
+
const client = new MoneriumClient();
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
### Authenticate using client credentials
|
|
38
|
+
|
|
39
|
+
```ts
|
|
40
|
+
await client.auth({
|
|
41
|
+
client_id: "your_client_credentials_uuid"
|
|
42
|
+
client_secret: "your_client_secret"
|
|
43
|
+
})
|
|
44
|
+
|
|
45
|
+
// User is now authenticated, get authentication data
|
|
46
|
+
await client.getAuthContext()
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
### Authenticate using auth flow
|
|
50
|
+
|
|
51
|
+
```ts
|
|
52
|
+
// Construct the authFlowUrl for your application and redirect your customer.
|
|
53
|
+
let authFlowUrl = client.getAuthFlowURI({
|
|
54
|
+
client_id: "your_client_authflow_uuid"
|
|
55
|
+
// optional automatic wallet selection:
|
|
56
|
+
network: "mumbai",
|
|
57
|
+
chain: "polygon",
|
|
58
|
+
address: "0xValidAddress72413Fa92980B889A1eCE84dD",
|
|
59
|
+
signature: "0xValidSignature0df2b6c9e0fc067ab29bdbf322bec30aad7c46dcd97f62498a91ef7795957397e0f49426e000b0f500c347219ddd98dc5080982563055e918031c"
|
|
60
|
+
|
|
61
|
+
})
|
|
62
|
+
// Redirecting to the Monerium onboarding / Authentication flow.
|
|
63
|
+
window.location.replace(authFlowUrl)
|
|
64
|
+
|
|
65
|
+
// As the final step of the flow, the customer will be routed back to the `redirect_uri` with a `code` parameter attached to it.
|
|
66
|
+
// i.e. http://your-webpage.com/monerium-integration?code=1234abcd
|
|
67
|
+
|
|
68
|
+
await client.auth({
|
|
69
|
+
client_id: "your_client_authflow_uuid",
|
|
70
|
+
code: new URLSearchParams(window.location.search).get('code'),
|
|
71
|
+
code_verifier: client.code_verifier,
|
|
72
|
+
redirect_url: "http://your-webpage.com/monerium-integration"
|
|
73
|
+
})
|
|
74
|
+
|
|
75
|
+
// User is now authenticated, get authentication data
|
|
76
|
+
await client.getAuthContext()
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
## Developing
|
|
80
|
+
|
|
81
|
+
We are using [commitlint](https://github.com/conventional-changelog/commitlint/tree/master/@commitlint/config-conventional) to enforce that developers format the commit messages according to the [Conventional Commits](https://www.conventionalcommits.org/en/v1.0.0/) guidelines.
|
|
82
|
+
|
|
29
83
|
## Publishing
|
|
30
84
|
|
|
31
85
|
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
|
@@ -48,19 +48,36 @@ export interface ClientCredentials {
|
|
|
48
48
|
client_secret: string;
|
|
49
49
|
scope?: string;
|
|
50
50
|
}
|
|
51
|
+
/**
|
|
52
|
+
* @returns A {@link PKCERequest} object with properties omitted that are automatically computed in by the SDK.
|
|
53
|
+
*/
|
|
51
54
|
export type PKCERequestArgs = Omit<
|
|
52
55
|
PKCERequest,
|
|
53
56
|
"code_challenge" | "code_challenge_method" | "response_type"
|
|
54
57
|
>;
|
|
55
58
|
export type PKCERequest = {
|
|
59
|
+
/** the authentication flow client id of the application */
|
|
56
60
|
client_id: string;
|
|
61
|
+
/** the code challenge automatically generated by the SDK */
|
|
57
62
|
code_challenge: string;
|
|
58
|
-
|
|
59
|
-
|
|
63
|
+
/** the code challenge method for the authentication flow , handled by the SDK */
|
|
64
|
+
code_challenge_method: "S256";
|
|
65
|
+
/** the response type of the authentication flow, handled by the SDK */
|
|
66
|
+
response_type: "code";
|
|
67
|
+
/** the state of the application */
|
|
60
68
|
state?: string;
|
|
69
|
+
/** the redirect uri of the application */
|
|
61
70
|
redirect_uri?: string;
|
|
71
|
+
/** the scope of the application */
|
|
62
72
|
scope?: string;
|
|
73
|
+
/** the address of the wallet to automatically link */
|
|
63
74
|
address?: string;
|
|
75
|
+
/** the signature of the wallet to automatically link */
|
|
76
|
+
signature?: string;
|
|
77
|
+
/** the network of the wallet to automatically link */
|
|
78
|
+
network?: Network;
|
|
79
|
+
/** the chain of the wallet to automatically link */
|
|
80
|
+
chain?: Chain;
|
|
64
81
|
};
|
|
65
82
|
declare enum Method {
|
|
66
83
|
password = "password",
|
|
@@ -271,21 +288,6 @@ export interface LinkAddress {
|
|
|
271
288
|
signature: string;
|
|
272
289
|
accounts: CurrencyAccounts[];
|
|
273
290
|
}
|
|
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: "your_client_id"
|
|
285
|
-
* client_secret: "your_client_secret"
|
|
286
|
-
* })
|
|
287
|
-
* ```
|
|
288
|
-
* */
|
|
289
291
|
export declare class MoneriumClient {
|
|
290
292
|
#private;
|
|
291
293
|
/** The PKCE code verifier */
|
|
@@ -295,17 +297,15 @@ export declare class MoneriumClient {
|
|
|
295
297
|
auth(args: AuthArgs): Promise<void>;
|
|
296
298
|
/**
|
|
297
299
|
* Construct the url to the authorization code flow,
|
|
298
|
-
* the code verifier is needed afterwards to obtain an access token and is therefore stored in this.codeVerifier
|
|
299
|
-
*
|
|
300
|
-
* ```
|
|
301
|
-
* let authFlowUrl = client.pkceRequest({
|
|
302
|
-
* client_id:
|
|
303
|
-
* redirect_uri:
|
|
304
|
-
* })
|
|
305
|
-
* ```
|
|
300
|
+
* the code verifier is needed afterwards to obtain an access token and is therefore stored in `this.codeVerifier`
|
|
301
|
+
* For automatic wallet link, add the following properties: `address`, `signature`, `chain` & `network`
|
|
306
302
|
* @returns string
|
|
307
303
|
*/
|
|
308
|
-
|
|
304
|
+
getAuthFlowURI(args: PKCERequestArgs): string;
|
|
305
|
+
/**
|
|
306
|
+
* @deprecated since v2.0.7, use {@link getAuthFlowURI} instead.
|
|
307
|
+
*/
|
|
308
|
+
pkceRequest: (args: PKCERequestArgs) => string;
|
|
309
309
|
getAuthContext(): Promise<AuthContext>;
|
|
310
310
|
/**
|
|
311
311
|
* @param {string} profileId - the id of the profile to fetch.
|