@yourself_id/siwys-react-js 0.33.2-jahatch512-docs-keymaster-init.48.0 → 0.33.2-jahatch512-docs-keymaster-init.49.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 +158 -4
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -1,8 +1,154 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @yourself_id/siwys-react-js
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
React component library for **Sign In With YourSelf (SIWYS)** and **Connect YourSelf (CYS)**.
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
This package provides pre-built, accessible, and customizable React components to authenticate users via the SELF mobile wallet.
|
|
6
|
+
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
## Installation
|
|
10
|
+
|
|
11
|
+
```bash
|
|
12
|
+
npm install @yourself_id/siwys-react-js styled-components
|
|
13
|
+
# or
|
|
14
|
+
yarn add @yourself_id/siwys-react-js styled-components
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
> **Note:** `styled-components` (v6+) and `react` (v18+) are required peer dependencies.
|
|
18
|
+
|
|
19
|
+
---
|
|
20
|
+
|
|
21
|
+
## Available Components
|
|
22
|
+
|
|
23
|
+
| Component | Description |
|
|
24
|
+
|---|---|
|
|
25
|
+
| `<SignInWithYourSelf />` | All-in-one authentication component. Handles challenge creation, QR code display, polling, and success states. |
|
|
26
|
+
| `<ConnectYourSelf />` | Streamlined component for Connect YourSelf flows. |
|
|
27
|
+
| `<SiwysButton />` | Official "Sign in with your SELF" branded button with themes and loading states. |
|
|
28
|
+
| `<CysButton />` | Official "Connect your SELF" branded button. |
|
|
29
|
+
| `<QRCode />` | Standalone QR code renderer for challenge URLs. |
|
|
30
|
+
|
|
31
|
+
---
|
|
32
|
+
|
|
33
|
+
## Usage Examples
|
|
34
|
+
|
|
35
|
+
### 1. Fully Managed Authentication (`SignInWithYourSelf`)
|
|
36
|
+
|
|
37
|
+
This is the recommended approach for most web apps. It automatically calls your backend to create a challenge, displays the QR code, polls your authentication verification endpoint, and displays a success view once verified.
|
|
38
|
+
|
|
39
|
+
```tsx
|
|
40
|
+
import React from "react";
|
|
41
|
+
import { SignInWithYourSelf } from "@yourself_id/siwys-react-js";
|
|
42
|
+
|
|
43
|
+
export function LoginCard() {
|
|
44
|
+
return (
|
|
45
|
+
<SignInWithYourSelf
|
|
46
|
+
createChallengeUrl="https://api.yourcompany.com/challenges"
|
|
47
|
+
pollForAuthUrl="https://api.yourcompany.com/check-auth"
|
|
48
|
+
theme="dark" // "light" | "dark"
|
|
49
|
+
showLogo={true}
|
|
50
|
+
showInstructions={true}
|
|
51
|
+
successComponent={
|
|
52
|
+
<div style={{ textAlign: "center", color: "#fff" }}>
|
|
53
|
+
<h2>Authentication Successful!</h2>
|
|
54
|
+
<p>Redirecting to dashboard...</p>
|
|
55
|
+
</div>
|
|
56
|
+
}
|
|
57
|
+
onSiwysPress={() => console.log("Sign-in initiated")}
|
|
58
|
+
/>
|
|
59
|
+
);
|
|
60
|
+
}
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
### 2. Manual / Custom Flow (`ConnectYourSelf` & `QRCode`)
|
|
64
|
+
|
|
65
|
+
If you want complete control over challenge fetching, polling lifecycle, or custom animations:
|
|
66
|
+
|
|
67
|
+
```tsx
|
|
68
|
+
import React, { useState, useEffect } from "react";
|
|
69
|
+
import { QRCode, CysButton } from "@yourself_id/siwys-react-js";
|
|
70
|
+
|
|
71
|
+
export function CustomAuth() {
|
|
72
|
+
const [challengeData, setChallengeData] = useState<{ challenge: string; challengeUrl: string } | null>(null);
|
|
73
|
+
const [loading, setLoading] = useState(false);
|
|
74
|
+
|
|
75
|
+
const requestChallenge = async () => {
|
|
76
|
+
setLoading(true);
|
|
77
|
+
const res = await fetch("https://api.yourcompany.com/challenges", { method: "POST" });
|
|
78
|
+
const data = await res.json();
|
|
79
|
+
setChallengeData(data);
|
|
80
|
+
setLoading(false);
|
|
81
|
+
};
|
|
82
|
+
|
|
83
|
+
return (
|
|
84
|
+
<div>
|
|
85
|
+
{!challengeData ? (
|
|
86
|
+
<CysButton onClick={requestChallenge} disabled={loading} colorTheme="dark" />
|
|
87
|
+
) : (
|
|
88
|
+
<QRCode challengeUrl={challengeData.challengeUrl} size={256} />
|
|
89
|
+
)}
|
|
90
|
+
</div>
|
|
91
|
+
);
|
|
92
|
+
}
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
### 3. Standalone Branded Buttons
|
|
96
|
+
|
|
97
|
+
You can use the standalone buttons to trigger custom modal dialogs or authentication drawers:
|
|
98
|
+
|
|
99
|
+
```tsx
|
|
100
|
+
import React from "react";
|
|
101
|
+
import { SiwysButton, CysButton } from "@yourself_id/siwys-react-js";
|
|
102
|
+
|
|
103
|
+
export function AuthButtons() {
|
|
104
|
+
return (
|
|
105
|
+
<div style={{ display: "flex", flexDirection: "column", gap: "1rem" }}>
|
|
106
|
+
{/* Sign In button with dark theme */}
|
|
107
|
+
<SiwysButton
|
|
108
|
+
onClick={() => alert("Open Sign In Modal")}
|
|
109
|
+
colorTheme="dark" // "light" | "dark" | "blue"
|
|
110
|
+
/>
|
|
111
|
+
|
|
112
|
+
{/* Connect button with light theme */}
|
|
113
|
+
<CysButton
|
|
114
|
+
onClick={() => alert("Open Connect Modal")}
|
|
115
|
+
colorTheme="light"
|
|
116
|
+
/>
|
|
117
|
+
</div>
|
|
118
|
+
);
|
|
119
|
+
}
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
---
|
|
123
|
+
|
|
124
|
+
## Component Props Reference
|
|
125
|
+
|
|
126
|
+
### `<SignInWithYourSelf />` Props
|
|
127
|
+
|
|
128
|
+
| Prop | Type | Default | Description |
|
|
129
|
+
|---|---|---|---|
|
|
130
|
+
| `createChallengeUrl` | `string` | Optional | Backend URL that returns `{ challenge, challengeUrl }`. |
|
|
131
|
+
| `pollForAuthUrl` | `string` | Optional | Backend URL to poll for auth status with `?challenge={did}`. |
|
|
132
|
+
| `challengeDID` | `string` | `""` | Existing challenge DID if already created manually. |
|
|
133
|
+
| `challengeBaseUrl` | `string` | Optional | Override callback base URL. |
|
|
134
|
+
| `theme` | `"light" \| "dark"` | `"light"` | Color theme for container and typography. |
|
|
135
|
+
| `showLogo` | `boolean` | `true` | Show the official SELF logo alongside the QR code. |
|
|
136
|
+
| `showInstructions` | `boolean` | `true` | Show step-by-step instructions and app store download badges. |
|
|
137
|
+
| `successComponent` | `React.ReactNode` | Optional | Custom component to render upon successful authentication. |
|
|
138
|
+
| `onSiwysPress` | `() => void` | Optional | Callback fired when the user initiates authentication. |
|
|
139
|
+
| `isCYS` | `boolean` | `false` | Switch copy from "Sign in" to "Connect your SELF". |
|
|
140
|
+
|
|
141
|
+
### `<SiwysButton />` & `<CysButton />` Props
|
|
142
|
+
|
|
143
|
+
| Prop | Type | Default | Description |
|
|
144
|
+
|---|---|---|---|
|
|
145
|
+
| `onClick` | `() => void` | Required | Click handler. |
|
|
146
|
+
| `colorTheme` | `"light" \| "dark" \| "blue"` | Auto (system preference) | Visual theme of the button. |
|
|
147
|
+
| `disabled` | `boolean` | `false` | Disables the button. |
|
|
148
|
+
|
|
149
|
+
---
|
|
150
|
+
|
|
151
|
+
## Local Development
|
|
6
152
|
|
|
7
153
|
Uses [Vite](https://vite.dev/) for testing components locally.
|
|
8
154
|
|
|
@@ -10,10 +156,18 @@ Uses [Vite](https://vite.dev/) for testing components locally.
|
|
|
10
156
|
2. Run `yarn dev`
|
|
11
157
|
3. Test at http://localhost:5173
|
|
12
158
|
|
|
13
|
-
|
|
159
|
+
## Importing Icons as SVGs
|
|
14
160
|
|
|
15
161
|
Uses [SVGR](https://react-svgr.com/) to transform SVGs into React components.
|
|
16
162
|
|
|
17
163
|
1. Save the SVG in the `icons/` folder
|
|
18
164
|
2. Run `yarn generate-icons`
|
|
19
165
|
3. The associated React components will be generated inside `src/icons`
|
|
166
|
+
|
|
167
|
+
---
|
|
168
|
+
|
|
169
|
+
## Related Documentation
|
|
170
|
+
|
|
171
|
+
- [Backend SDK (`@yourself_id/siwys-api-js`)](../api-js/README.md)
|
|
172
|
+
- [React Native SDK (`@yourself_id/siwys-react-native`)](../react-native/README.md)
|
|
173
|
+
- [Full Keymaster Integration Guide](../../demo/README.md#integrating-keymaster)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@yourself_id/siwys-react-js",
|
|
3
|
-
"version": "0.33.2-jahatch512-docs-keymaster-init.
|
|
3
|
+
"version": "0.33.2-jahatch512-docs-keymaster-init.49.0",
|
|
4
4
|
"description": "A React component library",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -54,5 +54,5 @@
|
|
|
54
54
|
"resolutions": {
|
|
55
55
|
"styled-components": "^6"
|
|
56
56
|
},
|
|
57
|
-
"gitHead": "
|
|
57
|
+
"gitHead": "a07a6e39d3dec57ed2da137800488e3badad717c"
|
|
58
58
|
}
|