@yourself_id/siwys-react-js 0.0.28-sapp-118-documentation.0 → 0.0.28
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 +12 -118
- package/dist/index.js +10 -6
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +10 -6
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -1,125 +1,19 @@
|
|
|
1
|
-
#
|
|
1
|
+
# SIWYS JS
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
TODO: Update me.
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
# Local Development
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
Uses [Vite](https://vite.dev/) for testing components locally.
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
1. Render the component(s) you want to test inside `src/demo/demo.tsx`
|
|
10
|
+
2. Run `yarn dev`
|
|
11
|
+
3. Test at http://localhost:5173
|
|
10
12
|
|
|
11
|
-
|
|
12
|
-
npm install @yourself_id/siwys-react-js
|
|
13
|
-
```
|
|
14
|
-
or
|
|
15
|
-
```
|
|
16
|
-
yarn add @yourself_id/siwys-react-js
|
|
17
|
-
```
|
|
13
|
+
# Importing Icons as SVGs
|
|
18
14
|
|
|
19
|
-
|
|
15
|
+
Uses [SVGR](https://react-svgr.com/) to transform SVGs into React components.
|
|
20
16
|
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
// navigate to dedicated SIWYS page
|
|
25
|
-
}}
|
|
26
|
-
colorTheme="dark"
|
|
27
|
-
glow
|
|
28
|
-
/>
|
|
29
|
-
```
|
|
30
|
-
|
|
31
|
-
The following are the acceptable props for the `SiwysButton` component:
|
|
32
|
-
|
|
33
|
-
|Parameter|Type|Description|Required|Default|
|
|
34
|
-
|--|-|-|-|-|
|
|
35
|
-
|onClick|func|Function to execute.<br/>This should redirect to a dedicated page that renders the `SignInWithYourSelf` Component (below) |Yes||
|
|
36
|
-
|colorTheme|string|Color theme of button. <br/>Either "light" or "dark"|No|Auto-detect from system|
|
|
37
|
-
|glow|boolean|Whether to show glow hover effect|No|false|
|
|
38
|
-
|
|
39
|
-
# Render SIWYS Component
|
|
40
|
-
|
|
41
|
-
The SIWYS component includes the QR code for scanning as well as additional information to inform users on how to take action. Consequently, this component should ideally be rendered on its own dedicated page to avoid any formatting/styling issues.
|
|
42
|
-
|
|
43
|
-
```js
|
|
44
|
-
<SignInWithYourSelf
|
|
45
|
-
createChallengeUrl="https://your-sever-url/challenges"
|
|
46
|
-
pollForChallengeComplete="https://your-server-url/auth"
|
|
47
|
-
pollingIntervalSec={5}
|
|
48
|
-
onChallengeComplete={(resp) => console.log("Auth Respone:", resp)}
|
|
49
|
-
/>
|
|
50
|
-
```
|
|
51
|
-
|
|
52
|
-
The following are the acceptable props for the `SignInWithYourSelf` component:
|
|
53
|
-
|
|
54
|
-
|Parameter|Type|Description|Required|Default|
|
|
55
|
-
|--|-|-|-|-|
|
|
56
|
-
|createChallengeUrl|func|URL for creating the Challenge.<br/>This should be the endpoint you created when setting up the SIWYS API SDK.|Yes||
|
|
57
|
-
|pollForChallengeComplete|string|URL polling for challenge completion status.<br/>This should be the endpoint you created when setting up the SIWYS API SDK.|No|The component will not poll for challenge completion.|
|
|
58
|
-
|pollingIntervalSec|boolean|How often to poll for Challenge completion.|No|5|
|
|
59
|
-
|onChallengeComplete|boolean|Callback for handling a completed Challenge.<br/>Will pass back the result of the polling endpoint.<br/>Required when `pollForAuthUrl` is supplied.|No|N/A|
|
|
60
|
-
|
|
61
|
-
> [!IMPORTANT]
|
|
62
|
-
> If you do not provide the `pollForAuthUrl` you must implement your own logic of informing the Client when the challenge has been completed.
|
|
63
|
-
> For more information see the setup guide for the SIWYS API SDK.
|
|
64
|
-
|
|
65
|
-
# Complete Example
|
|
66
|
-
|
|
67
|
-
The following is a complete, minimal example using Next.js and assuming that the `pollForChallengeCompleteUrl` sets the appropriate authentication mechansim, eg a JWT cookie.
|
|
68
|
-
|
|
69
|
-
```js
|
|
70
|
-
// index.tsx entrypoint
|
|
71
|
-
import React, { render, useEffect, useState } from "react"
|
|
72
|
-
|
|
73
|
-
import { useRouter } from 'next/router';
|
|
74
|
-
|
|
75
|
-
import { SiwysButton } from "@yourself_id/react-js";
|
|
76
|
-
|
|
77
|
-
const App: React.FC<{}> = () => {
|
|
78
|
-
const [user, setUser] = useState();
|
|
79
|
-
|
|
80
|
-
const router = useRouter();
|
|
81
|
-
|
|
82
|
-
useEffect(() => {
|
|
83
|
-
// fetch user info if authenticated
|
|
84
|
-
fetch("/me").then(setUser)
|
|
85
|
-
}, [])
|
|
86
|
-
|
|
87
|
-
return (
|
|
88
|
-
<div>
|
|
89
|
-
{user && <Homepage />}
|
|
90
|
-
{!user && (
|
|
91
|
-
<SiwysButton
|
|
92
|
-
colorTheme="dark"
|
|
93
|
-
glow
|
|
94
|
-
onClick={() => router.push("/login")}
|
|
95
|
-
/>
|
|
96
|
-
)}
|
|
97
|
-
</div>
|
|
98
|
-
);
|
|
99
|
-
};
|
|
100
|
-
|
|
101
|
-
export default App;
|
|
102
|
-
|
|
103
|
-
render(<App />, document.getElementById('app')!)
|
|
104
|
-
|
|
105
|
-
// pages/login/index.tsx
|
|
106
|
-
import React, { render, useState } from "react"
|
|
107
|
-
|
|
108
|
-
import { SignInWithYourSelf } from "@yourself_id/react-js";
|
|
109
|
-
|
|
110
|
-
const Login: React.FC<{}> = () => {
|
|
111
|
-
const router = useRouter();
|
|
112
|
-
|
|
113
|
-
return (
|
|
114
|
-
<SignInWithYourSelf
|
|
115
|
-
createChallengeUrl="https://your-server-url/challenges"
|
|
116
|
-
pollForChallengeCompleteUrl="https://your-server-url/auth"
|
|
117
|
-
onChallengeComplete={() => router.push("/")}
|
|
118
|
-
/>
|
|
119
|
-
);
|
|
120
|
-
};
|
|
121
|
-
|
|
122
|
-
export default Login;
|
|
123
|
-
```
|
|
124
|
-
|
|
125
|
-
Note: `onChallengeComplete` may have a Coo
|
|
17
|
+
1. Save the SVG in the `icons/` folder
|
|
18
|
+
2. Run `yarn generate-icons`
|
|
19
|
+
3. The associated React components will be generated inside `src/icons`
|
package/dist/index.js
CHANGED
|
@@ -1029,6 +1029,14 @@ var Box = import_styled_components5.default.div(_templateObject13(), function(pr
|
|
|
1029
1029
|
});
|
|
1030
1030
|
var DownloadApp = function(param) {
|
|
1031
1031
|
var ref = _object_destructuring_empty(param);
|
|
1032
|
+
var openIOSLink = function() {
|
|
1033
|
+
var url = "https://apps.apple.com/app/id.yourself.selfid";
|
|
1034
|
+
window.open(url, "_blank");
|
|
1035
|
+
};
|
|
1036
|
+
var openAndroidLink = function() {
|
|
1037
|
+
var url = "https://play.google.com/store/apps/details?id=prod.id.yourself.selfid";
|
|
1038
|
+
window.open(url, "_blank");
|
|
1039
|
+
};
|
|
1032
1040
|
return /* @__PURE__ */ import_react5.default.createElement(Wrapper2, null, /* @__PURE__ */ import_react5.default.createElement(Header2, null, /* @__PURE__ */ import_react5.default.createElement("h3", null, "Get", " ", /* @__PURE__ */ import_react5.default.createElement("span", {
|
|
1033
1041
|
style: {
|
|
1034
1042
|
color: "#D8EE4F"
|
|
@@ -1050,18 +1058,14 @@ var DownloadApp = function(param) {
|
|
|
1050
1058
|
})), /* @__PURE__ */ import_react5.default.createElement(AppleAppStore_default, {
|
|
1051
1059
|
width: "8rem",
|
|
1052
1060
|
height: "2.5rem",
|
|
1053
|
-
onClick:
|
|
1054
|
-
return console.log("TODO: Update with iOS App URL");
|
|
1055
|
-
},
|
|
1061
|
+
onClick: openIOSLink,
|
|
1056
1062
|
style: {
|
|
1057
1063
|
cursor: "pointer"
|
|
1058
1064
|
}
|
|
1059
1065
|
}), /* @__PURE__ */ import_react5.default.createElement(GooglePlayStore_default, {
|
|
1060
1066
|
width: "8rem",
|
|
1061
1067
|
height: "2.5rem",
|
|
1062
|
-
onClick:
|
|
1063
|
-
return console.log("TODO: Update with Google Play URL");
|
|
1064
|
-
},
|
|
1068
|
+
onClick: openAndroidLink,
|
|
1065
1069
|
style: {
|
|
1066
1070
|
cursor: "pointer"
|
|
1067
1071
|
}
|