sign-in-with-stacks 0.1.4 → 0.1.5
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/package.json +5 -4
- package/README.md +0 -52
package/package.json
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "sign-in-with-stacks",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.5",
|
|
4
4
|
"license": "MIT",
|
|
5
|
+
"description": "Sign-in with Stacks is a library for creating and verifying Sign-In with Stacks messages",
|
|
5
6
|
"repository": "pradel/sign-in-with-stacks",
|
|
6
7
|
"funding": "https://github.com/sponsors/pradel",
|
|
7
8
|
"type": "module",
|
|
@@ -44,9 +45,9 @@
|
|
|
44
45
|
},
|
|
45
46
|
"scripts": {
|
|
46
47
|
"build": "tsdown",
|
|
47
|
-
"test": "vitest",
|
|
48
48
|
"check-types": "tsc --noEmit",
|
|
49
|
-
"
|
|
50
|
-
"
|
|
49
|
+
"dev": "tsdown --watch",
|
|
50
|
+
"lint": "oxlint .",
|
|
51
|
+
"test": "vitest"
|
|
51
52
|
}
|
|
52
53
|
}
|
package/README.md
DELETED
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
# sign-in-with-stacks
|
|
2
|
-
|
|
3
|
-
Sign-in with Stacks is a library for creating and verifying Sign-In with Stacks messages.
|
|
4
|
-
|
|
5
|
-
## Installation
|
|
6
|
-
|
|
7
|
-
```
|
|
8
|
-
npm install sign-in-with-stacks
|
|
9
|
-
```
|
|
10
|
-
|
|
11
|
-
## Usage
|
|
12
|
-
|
|
13
|
-
On the client create a message and sign it with the user's wallet.
|
|
14
|
-
|
|
15
|
-
```ts
|
|
16
|
-
import { createSiwsMessage, generateSiwsNonce } from 'sign-in-with-stacks'
|
|
17
|
-
import { STACKS_MAINNET } from '@stacks/network';
|
|
18
|
-
import { openSignatureRequestPopup } from '@stacks/connect';
|
|
19
|
-
|
|
20
|
-
const message = createSiwsMessage({
|
|
21
|
-
address: 'ST1PQHQKV0RJXZFY1DGX8MNSNYVE3VGZJSRTPGZGM',
|
|
22
|
-
chainId: STACKS_MAINNET.chainId,
|
|
23
|
-
domain: 'example.com',
|
|
24
|
-
nonce: generateSiwsNonce(),
|
|
25
|
-
uri: 'https://example.com/path',
|
|
26
|
-
version: '1',
|
|
27
|
-
});
|
|
28
|
-
|
|
29
|
-
await openSignatureRequestPopup({
|
|
30
|
-
message,
|
|
31
|
-
onFinish: async ({ signature }) => {
|
|
32
|
-
// Pass the signature to your backend
|
|
33
|
-
},
|
|
34
|
-
});
|
|
35
|
-
```
|
|
36
|
-
|
|
37
|
-
On the backend verify the signature, can be used with any framework, next-auth, better-auth, express, etc.
|
|
38
|
-
|
|
39
|
-
```ts
|
|
40
|
-
import { verifySiwsMessage } from 'sign-in-with-stacks'
|
|
41
|
-
import { STACKS_MAINNET } from '@stacks/network';
|
|
42
|
-
|
|
43
|
-
const valid = verifySiwsMessage({
|
|
44
|
-
message,
|
|
45
|
-
signature,
|
|
46
|
-
nonce: 'your-nonce',
|
|
47
|
-
})
|
|
48
|
-
```
|
|
49
|
-
|
|
50
|
-
## Credits
|
|
51
|
-
|
|
52
|
-
The first version of this library is a port of the view siwe implementation.
|