@depay/widgets 6.0.0 → 6.2.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/README.md +82 -5
- package/dist/esm/index.bundle.js +1456 -4372
- package/dist/esm/index.js +196 -3
- package/dist/umd/index.bundle.js +1456 -4372
- package/dist/umd/index.js +196 -3
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
You can either load the `@depay/widgets` package via CDN:
|
|
4
4
|
|
|
5
5
|
```
|
|
6
|
-
<script src="https://integrate.depay.fi/widgets/
|
|
6
|
+
<script src="https://integrate.depay.fi/widgets/v6.js"></script>
|
|
7
7
|
```
|
|
8
8
|
|
|
9
9
|
or you install `@depay/widgets` via the package manager of your choice and ship it as part of your application bundle:
|
|
@@ -58,7 +58,7 @@ In order to receive decentralized payments on any blockchain you need to have yo
|
|
|
58
58
|
### Quick start
|
|
59
59
|
|
|
60
60
|
```
|
|
61
|
-
<script src="https://integrate.depay.fi/widgets/
|
|
61
|
+
<script src="https://integrate.depay.fi/widgets/v6.js"/>
|
|
62
62
|
```
|
|
63
63
|
|
|
64
64
|
```
|
|
@@ -539,7 +539,7 @@ In order to sell tokens in a decentralized way, that token needs to have a liqui
|
|
|
539
539
|
### Quick start
|
|
540
540
|
|
|
541
541
|
```
|
|
542
|
-
<script src="https://integrate.depay.fi/widgets/
|
|
542
|
+
<script src="https://integrate.depay.fi/widgets/v6.js"/>
|
|
543
543
|
```
|
|
544
544
|
|
|
545
545
|
```javascript
|
|
@@ -901,7 +901,7 @@ In order to receive decentralized donation payments on any blockchain you need t
|
|
|
901
901
|
### Quick start
|
|
902
902
|
|
|
903
903
|
```
|
|
904
|
-
<script src="https://integrate.depay.fi/widgets/
|
|
904
|
+
<script src="https://integrate.depay.fi/widgets/v6.js"/>
|
|
905
905
|
```
|
|
906
906
|
|
|
907
907
|
```javascript
|
|
@@ -1255,7 +1255,7 @@ DePay Connect allows you to have your users connect their crypto wallet to your
|
|
|
1255
1255
|
Returns connected `account`, `accounts` and `wallet` in return.
|
|
1256
1256
|
|
|
1257
1257
|
```
|
|
1258
|
-
<script src="https://integrate.depay.fi/widgets/
|
|
1258
|
+
<script src="https://integrate.depay.fi/widgets/v6.js"/>
|
|
1259
1259
|
```
|
|
1260
1260
|
|
|
1261
1261
|
```javascript
|
|
@@ -1276,6 +1276,83 @@ DePayWidgets.Connect().then(()=>{}).catch((error)=>{
|
|
|
1276
1276
|
|
|
1277
1277
|
```
|
|
1278
1278
|
|
|
1279
|
+
## DePay Login
|
|
1280
|
+
|
|
1281
|
+
DePay Login allows you to perform web3 wallet logins with ease.
|
|
1282
|
+
|
|
1283
|
+
Returns `account` if succesfully signed and recovered log in message.
|
|
1284
|
+
|
|
1285
|
+
```
|
|
1286
|
+
<script src="https://integrate.depay.fi/widgets/v6.js"/>
|
|
1287
|
+
```
|
|
1288
|
+
|
|
1289
|
+
```javascript
|
|
1290
|
+
let message = "Sign to login"
|
|
1291
|
+
let account = await DePayWidgets.Login({ message })
|
|
1292
|
+
```
|
|
1293
|
+
|
|
1294
|
+
Connects wallet and instructs connected wallet to sign `message`, afterwards sends `signature` and `message` to `POST /login` (or `endpoint` if defined):
|
|
1295
|
+
|
|
1296
|
+
```
|
|
1297
|
+
POST /login
|
|
1298
|
+
BODY
|
|
1299
|
+
{
|
|
1300
|
+
"message": "Sign to login",
|
|
1301
|
+
"signature": "0x123456" // raw signature
|
|
1302
|
+
}
|
|
1303
|
+
```
|
|
1304
|
+
|
|
1305
|
+
The `/login` endpoint needs to recover the address for `message` and `signature` and needs to return it in the response:
|
|
1306
|
+
|
|
1307
|
+
```
|
|
1308
|
+
POST /login
|
|
1309
|
+
RESPONSE
|
|
1310
|
+
"0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045"
|
|
1311
|
+
```
|
|
1312
|
+
|
|
1313
|
+
Which will resolve the `DePayWidgets.Login` request to the resolved account:
|
|
1314
|
+
|
|
1315
|
+
```javascript
|
|
1316
|
+
account // 0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045
|
|
1317
|
+
```
|
|
1318
|
+
|
|
1319
|
+
You can also pass a `recover` function that takes care of signature recovery:
|
|
1320
|
+
|
|
1321
|
+
```javascript
|
|
1322
|
+
DePayWidgets.Login({ message, recover: ({ message, signature })=>{
|
|
1323
|
+
return new Promise((resolve, reject)=>{
|
|
1324
|
+
fetch('https://example.com/login', {
|
|
1325
|
+
method: 'POST',
|
|
1326
|
+
body: JSON.stringify({ message, signature })
|
|
1327
|
+
})
|
|
1328
|
+
.then((response)=>{
|
|
1329
|
+
if(response.status == 200) {
|
|
1330
|
+
response.text().then((account)=>{
|
|
1331
|
+
resolve(account)
|
|
1332
|
+
}).catch(reject)
|
|
1333
|
+
} else {
|
|
1334
|
+
response.text().then((text)=>{
|
|
1335
|
+
reject(text || 'Recovering login signature failed!')
|
|
1336
|
+
}).catch(reject)
|
|
1337
|
+
}
|
|
1338
|
+
})
|
|
1339
|
+
})
|
|
1340
|
+
}
|
|
1341
|
+
})
|
|
1342
|
+
```
|
|
1343
|
+
|
|
1344
|
+
### Rejections
|
|
1345
|
+
|
|
1346
|
+
1. Rejects if user just closes the dialog without connecting any wallet:
|
|
1347
|
+
|
|
1348
|
+
```javascript
|
|
1349
|
+
|
|
1350
|
+
DePayWidgets.Login().then(()=>{}).catch((error)=>{
|
|
1351
|
+
error // "USER_CLOSED_DIALOG"
|
|
1352
|
+
})
|
|
1353
|
+
|
|
1354
|
+
```
|
|
1355
|
+
|
|
1279
1356
|
## Development
|
|
1280
1357
|
|
|
1281
1358
|
### Quick start
|