Skip to content

Commit f3c61de

Browse files
Update docs with information about SIWF SDKs and Troubleshooting (#815)
# Problem Needed to update some docs Part of frequency-chain/docs#123 # Solution - @wilwade added docs around the SIWF SDK usage - @mattheworris updated the Troubleshooting docs ## Screenshots (optional): ### SIWF SDK Docs (Main changed section) ![image](https://github.com/user-attachments/assets/8af315ee-f9e8-4662-8ab1-df8ac6769e70) --------- Co-authored-by: Matthew Orris <[email protected]>
1 parent 9ce793f commit f3c61de

File tree

7 files changed

+464
-350
lines changed

7 files changed

+464
-350
lines changed

.spellcheckerdict.txt

+1
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,7 @@ S3-compatible
113113
scalable
114114
Schemas
115115
SDK
116+
SDKs
116117
signin
117118
signup
118119
SIWF

docs/src/GettingStarted/SSO.md

+24-6
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ Key benefits:
1313
Resources:
1414

1515
- [SIWF v2 Documentation](https://projectlibertylabs.github.io/siwf/v2/docs)
16+
- [SIWF v2 SDKs](https://projectlibertylabs.github.io/siwf/v2/docs/SDK/Overview.html)
1617
- [Account Service Documentation](../Build/AccountService/AccountService.md)
1718

1819
## Setup Tutorial
@@ -23,23 +24,23 @@ In this tutorial, you will set up a Sign In With Frequency button for use with T
2324

2425
Before proceeding, ensure you have completed the following steps:
2526

26-
**Registered as a Provider**
27+
**Registered as a Provider**
2728
Register your application as a [Provider on Frequency Testnet](./BecomeProvider.md).
2829

29-
**Completed the Access Form**
30+
**Completed the Access Form**
3031
Fill out the [Frequency Access Testnet Account Setup form](https://docs.google.com/forms/d/e/1FAIpQLScN_aNMZpYqEdchSHrAR6MhKrVI1pA3SP6wxolAQCFckYoPOA/viewform).
3132

32-
**Set Up a Backend Instance**
33+
**Set Up a Backend Instance**
3334
You need a **backend-only-accessible** [running instance](../Run/GatewayServices/RunGatewayServices.md) of the Account Service.
3435

35-
**Access to a Frequency RPC Node**
36+
**Access to a Frequency RPC Node**
3637

37-
- **Public Testnet Node:**
38+
- **Public Testnet Node:**
3839

3940
```plaintext
4041
wss://0.rpc.testnet.amplica.io
4142
```
42-
43+
4344
## Overview
4445

4546
1. Application creates a signed request SIWF URL that contains a callback URL.
@@ -109,13 +110,30 @@ See list of [SIWF v2 Credentials](https://projectlibertylabs.github.io/siwf/v2/d
109110

110111
## Step 2: Forward the User for Authentication
111112

113+
### Option A: SIWF Button SDK
114+
115+
The SIWF SDK provides an easy way to use your `signedRequest` and display a button for your users.
116+
117+
The example below is with the SIWF SDK for the Web.
118+
Guides for Android, iOS that also support handling the callback correctly and more are available [in the SIWF SDK documentation](https://projectlibertylabs.github.io/siwf/v2/docs/SDK/Overview.html).
119+
120+
```html
121+
<!-- Add a button container with data attributes and replace "YOUR_ENCODED_SIGNED_REQUEST" with your "signedRequest" value -->
122+
<div data-siwf-button="YOUR_ENCODED_SIGNED_REQUEST" data-siwf-mode="primary" data-siwf-endpoint="mainnet"></div>
123+
<!-- Include the latest version of the script -->
124+
<script src="https://cdn.jsdelivr.net/npm/@projectlibertylabs/[email protected]/siwf-sdk-web.min.js"></script>
125+
```
126+
127+
### Option B: Manually
128+
112129
Redirect the user to the URL obtained from the previous step:
113130

114131
```javascript
115132
window.location.href = '"https://testnet.frequencyaccess.com/siwa/start?signedRequest=eyJyZXF1ZXN0ZWRTaWduYXR1cmVzIjp7InB1YmxpY0tleSI6eyJlbmNvZGVkVmFsdWUiOiJmNmNMNHdxMUhVTngxMVRjdmRBQk5mOVVOWFhveUg0N21WVXdUNTl0elNGUlc4eURIIiwiZW5jb2RpbmciOiJiYXNlNTgiLCJmb3JtYXQiOiJzczU4IiwidHlwZSI6IlNyMjU1MTkifSwic2lnbmF0dXJlIjp7ImFsZ28iOiJTUjI1NTE5IiwiZW5jb2RpbmciOiJiYXNlMTYiLCJlbmNvZGVkVmFsdWUiOiIweDNlMTdhYzM3Yzk3ZWE3M2E3YzM1ZjBjYTJkZTcxYmY3MmE5NjlkYjhiNjQyYzU3ZTI2N2Q4N2Q1OTA3ZGM4MzVmYTJjODI4MTdlODA2YTQ5NGIyY2E5Y2U5MjJmNDM1NDY4M2U4YzAxMzY5NTNlMGZlNWExODJkMzU0NjQ2Yzg4In0sInBheWxvYWQiOnsiY2FsbGJhY2siOiJodHRwOi8vbG9jYWxob3N0OjMwMDAiLCJwZXJtaXNzaW9ucyI6WzUsNyw4LDksMTBdfX0sInJlcXVlc3RlZENyZWRlbnRpYWxzIjpbeyJ0eXBlIjoiVmVyaWZpZWRHcmFwaEtleUNyZWRlbnRpYWwiLCJoYXNoIjpbImJjaXFtZHZteGQ1NHp2ZTVraWZ5Y2dzZHRvYWhzNWVjZjRoYWwydHMzZWV4a2dvY3ljNW9jYTJ5Il19LHsiYW55T2YiOlt7InR5cGUiOiJWZXJpZmllZEVtYWlsQWRkcmVzc0NyZWRlbnRpYWwiLCJoYXNoIjpbImJjaXFlNHFvY3poZnRpY2k0ZHpmdmZiZWw3Zm80aDRzcjVncmNvM29vdnd5azZ5NHluZjQ0dHNpIl19LHsidHlwZSI6IlZlcmlmaWVkUGhvbmVOdW1iZXJDcmVkZW50aWFsIiwiaGFzaCI6WyJiY2lxanNwbmJ3cGMzd2p4NGZld2NlazVkYXlzZGpwYmY1eGppbXo1d251NXVqN2UzdnUydXducSJdfV19XX0&mode=dark"';
116133
```
117134

118135
For mobile applications, use an embedded browser to handle the redirection smoothly with minimal impact on user experience.
136+
SDKs for [Android](https://projectlibertylabs.github.io/siwf/v2/docs/SDK/Android.html) and [iOS](https://projectlibertylabs.github.io/siwf/v2/docs/SDK/iOS.html) are available that handle this part for you.
119137

120138
## Step 3: Handle the Callback
121139

docs/src/Troubleshooting.md

+21-3
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ Provider registration is required to setup a Provider on Frequency. This is a on
1616

1717
The Register User flow is the process by which a user registers with a Provider. This is a one-time process required each time a user signs up with a new Provider. The user will be able to log in to the Provider's app using the Sign In With Frequency [SIWF](https://github.com/ProjectLibertyLabs/siwf) process. The user will now be able to interact with the Provider's app.
1818

19-
The Login User flow is the process by which a user logs in to the Provider's app after the user has registered. The user will be able to interact with the Provider's app.
19+
The Login User flow is the process by which a user logs in to the Provider's app after the user has registered. The user will subsequently be able to interact with the Provider's app.
2020

2121
<!-- This diagram is excerpted from the original here: [Account Service Flow Chart](https://github.com/ProjectLibertyLabs/gateway/blob/main/developer-docs/account/account-service-flow.md). Please keep these diagrams in sync.-->
2222
```mermaid
@@ -229,7 +229,7 @@ VERBOSE [TxnNotifierService] Successfully found transaction 0xdefab4526e86f83aec
229229

230230
Look in these logs for any errors or warnings. If you see any, they will give you a clue as to what went wrong.
231231

232-
Use the block number to look up the transaction on the [Polkadot blockchain explorer](https://polkadot.js.org/apps/?rpc=wss%3A%2F%2F0.rpc.testnet.amplica.io#/explorer).
232+
Find the block number that corresponds with the error in the log, and then use that block number to look up the transaction on the [Polkadot blockchain explorer](https://polkadot.js.org/apps/?rpc=wss%3A%2F%2F0.rpc.testnet.amplica.io#/explorer).
233233
This will give you more information about the transaction and the error that occurred.
234234

235235
<!-- {{#png-embed ./src/PolkadotBlockExplorer.png Polkadot Block Explorer}} -->
@@ -251,7 +251,25 @@ In the below example, the error index is 60 and the error code is 0. Error index
251251

252252
![Polkadot Block Explorer Error](./BlockchainError.png)
253253

254-
### Other Debugging Tools
254+
### Validate Your Deployment
255+
256+
Confirm that Frequency Developer Gateway Services are properly deployed and running. This guide provides examples for using [Docker Swarm](https://projectlibertylabs.github.io/gateway/Run/Deployment.html#part-1-deploying-with-docker-swarm) and [Kubernetes](https://projectlibertylabs.github.io/gateway/Run/Kubernetes.html) in AWS. However, the same principles apply to other deployment methods.
257+
258+
#### Validate Your Services
259+
260+
Gateway depends on a number of [standard services](https://projectlibertylabs.github.io/gateway/Fundamentals/Architecture.html?highlight=Redis#standard-services-gateway-uses) including Redis, BullMQ and IPFS Kubo API. Each of these services must be correctly configured and deployed within your development environment in order for Gateway to function properly. As part of this process, you may also wish to double check your [environment variables](https://github.com/ProjectLibertyLabs/gateway/blob/main/developer-docs/account/ENVIRONMENT.md).
261+
262+
#### Validating Your IPFS Environment
263+
264+
1. Ensure your [IPFS node](https://projectlibertylabs.github.io/gateway/Run/IPFS.html) is running correctly and check the status of your IPFS node.
265+
2. For additional management tasks and tests refer to the [IPFS Documentation](https://docs.ipfs.io).
266+
267+
#### Validating Your Redis and BullMQ Environment
268+
269+
1. Inspect all of your container logs, not just the ones pertaining to the API Service. (Any one of your logs may show a problem with Redis.) Look for error messages in your logs, specifically related to BullMQ or Redis.
270+
2. Try to execute a command shell in the container that your service is running in and invoke the Redis command line or ping the Redis node in order to verify your application container has network connectivity to your Redis environment.
271+
3. Further configuration information may be found in the [environment files](https://github.com/ProjectLibertyLabs/gateway/blob/main/env-files/account.template.env#L36).
272+
4. If either of these tests fail, you will need to first correct the problems in the Redis environment before you can move forward with Gateway.
255273

256274
#### Swagger/OpenAPI Documentation
257275

libs/cache/src/cache.config.spec.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ describe('Cache module config', () => {
5959
const options = {
6060
host: 'localhost',
6161
port: 6379,
62-
commandTimeout: 10000,
62+
commandTimeout: 25000,
6363
};
6464
expect(cacheConf.redisOptions).toStrictEqual(options);
6565
});
@@ -76,7 +76,7 @@ describe('Cache module config', () => {
7676
keepAliveTimeout: 300,
7777
};
7878
const cacheConf = await setupConfigService({ ...optionsEnv, REDIS_OPTIONS: JSON.stringify(options) });
79-
expect(cacheConf.redisOptions).toStrictEqual({ ...options, commandTimeout: 10000 });
79+
expect(cacheConf.redisOptions).toStrictEqual({ ...options, commandTimeout: 25000 });
8080
});
8181

8282
it('should get redis options with overriden defaults', async () => {

tools/ci-k6/main.mjs

+5-3
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ export async function createAndStake(providerUrl, keyUri) {
4444
api.tx.capacity.stake(1, 10_000_000_000_000),
4545
// Need to create an 'OnChain' schema in order to test endpoints, as there are no registered 'OnChain' DSNP schemas
4646
// **SHOULD** get created as SchemaID 16001
47-
api.tx.schemas.createSchema(JSON.stringify(AVRO_GRAPH_CHANGE), 'AvroBinary', 'OnChain'),
47+
api.tx.schemas.createSchemaV3(JSON.stringify(AVRO_GRAPH_CHANGE), 'AvroBinary', 'OnChain', [], 'test.graphchange'),
4848
]);
4949

5050
console.log('Submitting call...');
@@ -61,7 +61,9 @@ export async function createAndStake(providerUrl, keyUri) {
6161
);
6262
const success = events.find((x) => api.events.system.ExtrinsicSuccess.is(x.event));
6363
const failure = events.find((x) => api.events.system.ExtrinsicFailed.is(x.event));
64-
const { event: schemaCreated } = events.find((x) => api.events.schemas.SchemaCreated.is(x.event));
64+
const { event: schemaCreated } = success
65+
? events.find((x) => api.events.schemas.SchemaCreated.is(x.event))
66+
: { event: null };
6567
unsub();
6668
if (schemaCreated) {
6769
console.log(`Created OnChain schema ID ${schemaCreated.data.schemaId.toNumber()}`);
@@ -70,7 +72,7 @@ export async function createAndStake(providerUrl, keyUri) {
7072
console.log('Success!');
7173
resolve();
7274
} else {
73-
console.error('FAILED!');
75+
console.error('FAILED!', failure.toHuman());
7476
reject();
7577
}
7678
}

0 commit comments

Comments
 (0)