Skip to content

Commit 978c4c6

Browse files
authored
Docs: Add Web SDK (#305)
# Problem The SDK for Web needed to be included in the mdbook documentation. ## How to Test - Clone - `cd docs` - `mdbook serve` - http://localhost:3000
1 parent 67bf200 commit 978c4c6

File tree

4 files changed

+55
-6
lines changed

4 files changed

+55
-6
lines changed

docs/src/SDK/Overview.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ These guides will walk you through integrating the SIWF SDK into your **iOS** or
77

88
- [Android](Android.md)
99
- [iOS](iOS.md)
10+
- [Web](Web.md)
1011

1112
---
1213

@@ -26,7 +27,8 @@ You may also specify other options such as the button style (light/dark) and the
2627
You will need to create a redirect handler to receive information from the Authorization (i.e. the redirect URL provided to the Signed Request Payload).
2728
This redirect handler will receive information once the authorization is complete, which may then be sent and processed by your system’s backend to initiate the session.
2829

29-
See platform-specific details in the [Android](Android.md) or [iOS](iOS.md) sections for instructions for creating the callback handler
30+
See platform-specific details in the [Android](Android.md) or [iOS](iOS.md) sections for instructions for creating the callback handler.
31+
[Web](Web.md) requires your own callback processing to extract the `authorizationCode` from the URL parameters.
3032

3133
### 4. Process Authorization Code
3234

docs/src/SDK/Web.md

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
# Web SIWF SDK
2+
3+
## Quick Reference
4+
5+
- [SIWF Web SDK Source Code + Example](https://github.com/ProjectLibertyLabs/siwf/tree/main/libraries/sdk-web#readme)
6+
- [NPM Package: `@projectlibertylabs/siwf-sdk-web`](https://www.npmjs.com/package/@projectlibertylabs/siwf-sdk-web)
7+
- [jsDelivr: `https://cdn.jsdelivr.net/npm/@projectlibertylabs/[email protected]/siwf-sdk-web.min.js`](https://www.jsdelivr.com/package/npm/@projectlibertylabs/siwf-sdk-web)
8+
9+
## 1. Installation
10+
11+
Simply include the SDK in your HTML from [jsDelivr](https://www.jsdelivr.com/package/npm/@projectlibertylabs/siwf-sdk-web) (update the version as needed):
12+
13+
```html
14+
<script src="https://cdn.jsdelivr.net/npm/@projectlibertylabs/[email protected]/siwf-sdk-web.min.js"></script>
15+
```
16+
17+
Or download from [GitHub Releases](https://github.com/ProjectLibertyLabs/siwf/releases?q=sdk-web&expanded=true) and include it locally:
18+
19+
```html
20+
<script src="path/to/siwf-sdk-web.min.js"></script>
21+
```
22+
23+
## 2. Displaying the SIWF Button
24+
25+
To create a SIWF Button, use the `Siwf.createSignInButton` method:
26+
27+
```html
28+
<!-- Add a button container with data attributes -->
29+
<div data-siwf-button="YOUR_ENCODED_SIGNED_REQUEST" data-siwf-mode="primary" data-siwf-endpoint="mainnet"></div>
30+
```
31+
32+
`data-siwf-button` requires the [Signed Request Payload](../Actions/Start.html#step-1-generate-the-signed-request-payload) in `base64url` encoded form.
33+
34+
You can also use a [JavaScript render call](https://github.com/ProjectLibertyLabs/siwf/tree/main/libraries/sdk-web#option-b-javascript-implementation).
35+
36+
## 3. Handling Authorization Callbacks
37+
38+
You will need to handle the callback URL specified and extract the `authorizationCode` parameter from the callback and passing it to your backend service.
39+
40+
## 4. Process Authorization Code
41+
42+
On your backend service, process the authorization code and start your session.
43+
44+
Resources:
45+
- [Documentation on Processing a Result](../Actions/Response.html)
46+
- [Frequency Gateway SSO Tutorial](https://projectlibertylabs.github.io/gateway/GettingStarted/SSO.html)

docs/src/SUMMARY.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,4 @@
1616
- [SIWF SDK](SDK/Overview.md)
1717
- [Android](SDK/Android.md)
1818
- [iOS](SDK/iOS.md)
19+
- [Web](SDK/Web.md)

libraries/sdk-web/README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@ This repository contains the SIWF Button Web SDK and example implementation for
66

77
## 📌 **Index**
88

9-
1. 🚀 [Getting Started - SIWF Button Demo](#getting-started---siwf-button-demo)
10-
2. 📝 [Getting Started - SIWF Button For Your Web App](#getting-started---siwf-button-for-your-web-app)
11-
3. 🛠 [Usage For Your Web App](#usage-for-your-web-app)
12-
4. ⚙️ [Configuration Options](#configuration-options)
13-
5. 🤝 [Contributing](#contributing)
9+
1. 🚀 [Getting Started - SIWF Button Demo](#-getting-started---siwf-button-demo)
10+
2. 📝 [Getting Started - SIWF Button For Your Web App](#-getting-started---siwf-button-for-your-web-app)
11+
3. 🛠 [Usage For Your Web App](#-usage-for-your-web-app)
12+
4. ⚙️ [Configuration Options](#%EF%B8%8F-configuration-options)
13+
5. 🤝 [Contributing](#-contributing)
1414

1515
## 🚀 **Getting Started - SIWF Button Demo**
1616

0 commit comments

Comments
 (0)