Skip to content
This repository was archived by the owner on Nov 22, 2023. It is now read-only.

Commit fd093a9

Browse files
committed
feat: update README
1 parent 68c62ea commit fd093a9

File tree

6 files changed

+461
-83
lines changed

6 files changed

+461
-83
lines changed

README.md

Lines changed: 115 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -1,122 +1,149 @@
1-
# @monerium/sdk
1+
# Monerium SDK Documentation
22

3-
Everything you need to interact with the [Monerium API](https://monerium.dev/api-docs) - an electronic money issuer.
3+
Monerium connects your web3 wallet to any euro bank account with your personal IBAN.
4+
All incoming euro payments are automatically minted as EURe tokens to your wallet.
5+
Sending EURe to traditional bank accounts is just as easy.
6+
With a single signature from your wallet, your EURe is burned and sent as Euros to any bank account.
47

5-
_This package is in development. Please make sure to check if any future updates contain commits
6-
that may change the behavior of your application before you upgrade. If you find any issues please report them [here](https://github.com/monerium/sdk/issues)._
8+
## Table of Contents
79

8-
[NPM package](https://www.npmjs.com/package/@monerium/sdk)
10+
- [Installation](#installation)
11+
- [Configuration](#configuration)
12+
- [Usage Examples](#usage-examples)
13+
- [API Reference](#api-reference)
14+
- [Contributing](#contributing)
15+
- [FAQs](#faqs)
16+
- [Support](#support)
17+
- [Release Notes](#release-notes)
18+
- [License](#license)
919

10-
[Source code](https://github.com/monerium/sdk)
20+
## Installation
1121

12-
[SDK Documentation](https://monerium.github.io/sdk/)
22+
### Prerequisites
1323

14-
[SDK JS-Docs](https://monerium.github.io/sdk/)
15-
16-
[Code coverage](https://monerium.github.io/sdk/coverage)
17-
18-
## Installing
24+
Node v16.15 or higher is required.
1925

2026
```sh
21-
# Node
2227
yarn add @monerium/sdk
2328
```
2429

25-
## Usage
26-
27-
- `watch`: Run Vite in watch mode to detect changes to files during development
28-
- `build`: Run Vite to build a production release distributable
29-
30-
### Environments
30+
## Configuration
3131

32-
#### Sandbox:
32+
### Environments - URLs
3333

34-
chains: `ethereum`, `polygon`, `gnosis`.
34+
| Environment | Web | API |
35+
| ----------- | -------------------- | ------------------------ |
36+
| sandbox | https://monerium.dev | https://api.monerium.dev |
37+
| production | https://monerium.app | https://api.monerium.app |
3538

36-
networks: `goerli`, `mumbai`, `chiado`.
39+
### Environments - Networks
3740

38-
#### Production:
41+
| Environment | Chain | Network |
42+
| ----------- | -------- | ------- |
43+
| sandbox | ethereum | goerli |
44+
| | polygon | mumbai |
45+
| | gnosis | chiado |
46+
| production | ethereum | mainnet |
47+
| | polygon | mainnet |
48+
| | gnosis | mainnet |
3949

40-
chains: `ethereum`, `polygon`, `gnosis`.
41-
42-
networks: `mainnet`, `mainnet`, `mainnet`.
43-
44-
## Getting started
50+
## Usage Examples
4551

4652
We recommend starting in the [Developer Portal](https://monerium.dev/docs/welcome). There you will learn more about `client_id`'s and ways of authenticating.
4753

48-
### Import the SDK and initialize a client
54+
#### Import the SDK and initialize a client
4955

5056
```ts
5157
import { MoneriumClient } from '@monerium/sdk';
5258

53-
// By default, the client will use the sandbox environment.
54-
// To change to production, pass "production" as the first argument.
59+
// Initialize the client. By default, it uses the sandbox environment.
60+
// For using the production environment, replace 'sandbox' with 'production'.
5561
const client = new MoneriumClient('sandbox');
5662
```
5763

58-
### Authenticate using client credentials
64+
#### Authenticate using client credentials
5965

6066
```ts
6167
await client.auth({
62-
client_id: "your_client_credentials_uuid"
63-
client_secret: "your_client_secret"
64-
})
68+
client_id: 'your_client_credentials_uuid', // replace with your client ID
69+
client_secret: 'your_client_secret', // replace with your client secret
70+
});
6571

66-
// User is now authenticated, get authentication data
67-
await client.getAuthContext()
72+
// Retrieve authentication data after successful authentication.
73+
await client.getAuthContext();
6874

69-
// You can now find your access and refresh token here:
70-
const { access_token, refresh_token } = client.bearerProfile;
75+
// Access tokens are now available for use.
76+
const { access_token, refresh_token } = client.bearerProfile;
7177
```
7278

73-
### Authenticate using auth flow
79+
#### Authenticate using auth flow
80+
81+
First you have to navigate the user to the Monerium authentication flow. This can be done by generating a URL and redirecting the user to it. After the user has authenticated, Monerium will redirect back to your specified URI with a code. You can then finalize the authentication process by exchanging the code for access and refresh tokens.
7482

7583
```ts
76-
// Construct the authFlowUrl for your application and redirect your customer.
84+
// Generate the URL where users will be redirected to authenticate.
7785
let authFlowUrl = client.getAuthFlowURI({
78-
client_id: "your_client_authflow_uuid",
79-
redirect_uri: "http://your-webpage.com/monerium-integration"
80-
// optional automatic wallet selection:
81-
network: "mumbai",
82-
chain: "polygon",
83-
address: "0xValidAddress72413Fa92980B889A1eCE84dD",
84-
signature: "0xValidSignature0df2b6c9e0fc067ab29bdbf322bec30aad7c46dcd97f62498a91ef7795957397e0f49426e000b0f500c347219ddd98dc5080982563055e918031c"
85-
86-
})
87-
// Store the code verifier in localStorage
88-
window.localStorage.setItem("myCodeVerifier", client.codeVerifier);
89-
// Redirecting to the Monerium onboarding / Authentication flow.
90-
window.location.replace(authFlowUrl)
86+
client_id: 'your_client_authflow_uuid', // replace with your auth flow client ID
87+
redirect_uri: 'http://your-webpage.com/monerium-integration', // specify your redirect URI
88+
// Optional parameters for automatic wallet selection (if applicable)
89+
network: 'mumbai', // specify the network
90+
chain: 'polygon', // specify the chain
91+
address: '0xValidAddress72413Fa92980B889A1eCE84dD', // user wallet address
92+
signature:
93+
'0xValidSignature0df2b6c9e0fc067ab29bdbf322bec30aad7c46dcd97f62498a91ef7795957397e0f49426e000b0f500c347219ddd98dc5080982563055e918031c', // user wallet signature
94+
});
95+
96+
// Store the code verifier securely between requests.
97+
window.localStorage.setItem('myCodeVerifier', client.codeVerifier);
98+
99+
// Redirect the user to the Monerium authentication flow.
100+
window.location.replace(authFlowUrl);
91101
```
92102

93103
```ts
94-
// As the final step of the flow, the customer will be routed back to the `redirect_uri` with a `code` parameter attached to it.
95-
// i.e. http://your-webpage.com/monerium-integration?code=1234abcd
104+
// After user authentication, Monerium redirects back to your specified URI with a code.
105+
// Capture this code from the URL and proceed with the authentication.
106+
107+
// Extract the 'code' URL parameter.
108+
const authCode = new URLSearchParams(window.location.search).get('code');
96109

110+
// Retrieve the stored code verifier.
111+
const retrievedCodeVerifier = window.localStorage.getItem('myCodeVerifier');
112+
113+
// Finalize the authentication process.
97114
await client.auth({
98-
client_id: 'your_client_authflow_uuid',
99-
code: new URLSearchParams(window.location.search).get('code'),
100-
code_verifier: window.localStorage.getItem('myCodeVerifier'),
101-
redirect_url: 'http://your-webpage.com/monerium-integration',
115+
client_id: 'your_client_authflow_uuid', // replace with your client ID
116+
code: authCode,
117+
code_verifier: retrievedCodeVerifier,
118+
redirect_url: 'http://your-webpage.com/monerium-integration', // ensure this matches the redirect_uri used initially
102119
});
103120

104-
// User is now authenticated, get authentication data
121+
// Confirm the user is authenticated and retrieve the authentication data.
105122
await client.getAuthContext();
106123

107-
// You can now find your access and refresh token here:
124+
// Your access and refresh tokens are now available.
108125
const { access_token, refresh_token } = client.bearerProfile;
109126
```
110127

128+
## API Reference
129+
130+
[API Documentation](https://monerium.dev/docs/api)
131+
111132
## Contributing
112133

113134
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.
114135

115136
We are using Yarn as a package manager.
116137

117-
```
138+
```sh
139+
# Install dependencies
118140
yarn
141+
142+
# Run Vite to build a production release distributable
119143
yarn build
144+
145+
# Run Vite in watch mode to detect changes to files during development
146+
yarn watch
120147
```
121148

122149
Smart IDEs (such as VSCode) require [special configuration](https://yarnpkg.com/getting-started/editor-sdks) for TypeScript to work when using Yarn Plug'n'Play installs.
@@ -138,6 +165,30 @@ cd ../your-project
138165
yarn link "@monerium/sdk"
139166
```
140167

141-
## Publishing
168+
#### Publishing
142169

143170
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.
171+
172+
## FAQs
173+
174+
Common questions developers have regarding the SDK.
175+
176+
## Support
177+
178+
[Support](https://monerium.app/help)
179+
[Telegram](https://t.me/+lGtM1gY9zWthNGE8)
180+
[Github Issues](https://github.com/monerium/sdk/issues)
181+
182+
## Release Notes
183+
184+
https://github.com/monerium/sdk/releases
185+
186+
## License
187+
188+
Information about the software license.
189+
190+
[End of the SDK Documentation]
191+
192+
---
193+
194+
This template is a comprehensive starting point. Each section should contain detailed information relevant to your SDK to guide your users from installation to effective usage and troubleshooting. Be sure to adjust the headers and content to suit your SDK's unique needs and features.

configs/typedoc.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,5 +22,5 @@
2222
},
2323
"entryPointStrategy": "expand",
2424
"plugin": ["typedoc-theme-hierarchy"],
25-
"theme": "hierarchy"
25+
"theme": "hierarchy",
2626
}

package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
"build:main": "tsc && vite --config ./configs/vite.config.ts build && dts-bundle-generator --config ./configs/dts-bundle-generator.ts",
3131
"clean": "rm -rf dist && rm -rf node_modules && rm -rf static",
3232
"docs": "typedoc --options configs/typedoc.json && node scripts/editStatic.js",
33-
"docs:watch": "typedoc --options configs/typedoc.json --watch",
33+
"docs:watch": "nodemon --watch . --ignore static -e ts,css,md --exec 'typedoc --options configs/typedoc.json && node scripts/editStatic.js'",
3434
"format": "prettier . --write --ignore-path ./configs/.prettierignore",
3535
"lint": "eslint . -c ./.eslintrc --ext .ts",
3636
"prepare": "husky install",
@@ -57,12 +57,13 @@
5757
"husky": "^8.0.2",
5858
"jest": "^29.5.0",
5959
"jest-fetch-mock": "^3.0.3",
60+
"nodemon": "^3.0.1",
6061
"prettier": "^2.8.8",
6162
"ts-jest": "^29.0.3",
6263
"ts-node": "^10.9.1",
6364
"tslib": "^2.4.1",
6465
"typedoc": "^0.23.23",
65-
"typedoc-theme-hierarchy": "^3.0.2",
66+
"typedoc-theme-hierarchy": "^3.2.1",
6667
"typescript": "^5.0.4",
6768
"vite": "^4.0.0"
6869
},

scripts/editStatic.js

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
var fs = require('fs');
77

8-
function readWriteAsync() {
8+
function forceOpenSidebar() {
99
fs.readFile('static/index.html', 'utf-8', function (err, data) {
1010
if (err) throw err;
1111

@@ -20,5 +20,25 @@ function readWriteAsync() {
2020
});
2121
});
2222
}
23+
function forceCustomCss() {
24+
fs.copyFile('src/styles/typedoc.css', 'static/assets/monerium.css', (err) => {
25+
if (err) throw err;
26+
console.log('typedoc.css was copied to static/assets/monerium.css');
27+
});
28+
fs.readFile('static/index.html', 'utf-8', function (err, data) {
29+
if (err) throw err;
30+
31+
var newValue = data.replace(
32+
'<link rel="stylesheet" href="assets/custom.css"/>',
33+
'<link rel="stylesheet" href="assets/custom.css"/><link rel="stylesheet" href="assets/monerium.css"/>',
34+
);
35+
36+
fs.writeFile('static/index.html', newValue, 'utf-8', function (err) {
37+
if (err) throw err;
38+
console.log('Finished manually editing static/index.html');
39+
});
40+
});
41+
}
2342

24-
readWriteAsync();
43+
forceOpenSidebar();
44+
forceCustomCss();

0 commit comments

Comments
 (0)