@reclaimprotocol/js-sdk 1.3.11 → 2.0.1
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 +190 -146
- package/dist/index.d.ts +53 -161
- package/dist/index.js +637 -639
- package/dist/index.js.map +1 -1
- package/package.json +27 -12
- package/LICENSE +0 -20
package/README.md
CHANGED
|
@@ -1,152 +1,112 @@
|
|
|
1
|
-
|
|
1
|
+
<div>
|
|
2
|
+
<div>
|
|
3
|
+
<img src="https://raw.githubusercontent.com/reclaimprotocol/.github/main/assets/banners/JS-SDK.png" />
|
|
4
|
+
</div>
|
|
5
|
+
</div>
|
|
2
6
|
|
|
3
|
-
|
|
7
|
+
# Reclaim Protocol JavaScript SDK Integration Guide
|
|
4
8
|
|
|
5
|
-
|
|
9
|
+
This guide will walk you through integrating the Reclaim Protocol JavaScript SDK into your application. We'll create a simple React application that demonstrates how to use the SDK to generate proofs and verify claims.
|
|
6
10
|
|
|
7
|
-
|
|
11
|
+
## Prerequisites
|
|
8
12
|
|
|
9
|
-
|
|
13
|
+
Before we begin, make sure you have:
|
|
10
14
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
```
|
|
15
|
+
1. An application ID from Reclaim Protocol.
|
|
16
|
+
2. An application secret from Reclaim Protocol.
|
|
17
|
+
3. A provider ID for the specific service you want to verify.
|
|
15
18
|
|
|
16
|
-
|
|
19
|
+
You can obtain these details from the [Reclaim Developer Portal](https://dev.reclaimprotocol.org/).
|
|
17
20
|
|
|
18
|
-
|
|
19
|
-
npm install @reclaimprotocol/js-sdk
|
|
20
|
-
```
|
|
21
|
+
## Step 1: Create a new React application
|
|
21
22
|
|
|
22
|
-
|
|
23
|
+
Let's start by creating a new React application:
|
|
23
24
|
|
|
24
25
|
```bash
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
## Import dependencies
|
|
29
|
-
|
|
30
|
-
In your `src/App.js` file, import the Reclaim SDK and the QR code generator
|
|
31
|
-
|
|
32
|
-
```javascript
|
|
33
|
-
import { useState, useEffect } from 'react'
|
|
34
|
-
import { Reclaim } from '@reclaimprotocol/js-sdk'
|
|
35
|
-
import QRCode from 'react-qr-code'
|
|
26
|
+
npx create-react-app reclaim-app
|
|
27
|
+
cd reclaim-app
|
|
36
28
|
```
|
|
37
29
|
|
|
38
|
-
##
|
|
39
|
-
|
|
40
|
-
Declare your `application ID` and initialize the Reclaim Protocol client. Replace `YOUR_APPLICATION_ID_HERE` with the actual application ID provided by Reclaim Protocol.
|
|
41
|
-
|
|
42
|
-
File: `src/App.js`
|
|
43
|
-
|
|
44
|
-
```javascript
|
|
45
|
-
import './App.css'
|
|
46
|
-
import { useState, useEffect } from 'react'
|
|
47
|
-
import { Reclaim } from '@reclaimprotocol/js-sdk'
|
|
48
|
-
import QRCode from 'react-qr-code'
|
|
49
|
-
|
|
50
|
-
function App() {
|
|
51
|
-
const APP_ID = 'YOUR_APPLICATION_ID_HERE'
|
|
52
|
-
const reclaimProofRequest = new Reclaim.ProofRequest(APP_ID)
|
|
30
|
+
## Step 2: Install necessary dependencies
|
|
53
31
|
|
|
54
|
-
|
|
55
|
-
<div className='App'>
|
|
56
|
-
<header className='App-header'>
|
|
57
|
-
<p>Reclaim App</p>
|
|
58
|
-
</header>
|
|
59
|
-
</div>
|
|
60
|
-
)
|
|
61
|
-
}
|
|
32
|
+
Install the Reclaim Protocol SDK and a QR code generator:
|
|
62
33
|
|
|
63
|
-
|
|
34
|
+
```bash
|
|
35
|
+
npm install @reclaimprotocol/js-sdk react-qr-code
|
|
64
36
|
```
|
|
65
37
|
|
|
66
|
-
##
|
|
67
|
-
|
|
68
|
-
Create functions to handle the verification request. You'll need separate functions for prototype and production modes due to the different handling of the application secret and signature.
|
|
69
|
-
|
|
70
|
-
### Prototype Mode
|
|
38
|
+
## Step 3: Set up your React component
|
|
71
39
|
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
File: `src/App.js`
|
|
40
|
+
Replace the contents of `src/App.js` with the following code:
|
|
75
41
|
|
|
76
42
|
```javascript
|
|
77
|
-
import '
|
|
78
|
-
import {
|
|
79
|
-
import { Reclaim } from '@reclaimprotocol/js-sdk'
|
|
43
|
+
import React, { useState, useEffect } from 'react'
|
|
44
|
+
import { ReclaimProofRequest } from '@reclaimprotocol/js-sdk'
|
|
80
45
|
import QRCode from 'react-qr-code'
|
|
81
46
|
|
|
82
47
|
function App() {
|
|
48
|
+
const [reclaimProofRequest, setReclaimProofRequest] = useState(null)
|
|
83
49
|
const [requestUrl, setRequestUrl] = useState('')
|
|
84
|
-
const [
|
|
85
|
-
|
|
86
|
-
|
|
50
|
+
const [statusUrl, setStatusUrl] = useState('')
|
|
51
|
+
const [proofs, setProofs] = useState(null)
|
|
52
|
+
|
|
53
|
+
useEffect(() => {
|
|
54
|
+
async function initializeReclaim() {
|
|
55
|
+
const APP_ID = 'YOUR_APPLICATION_ID_HERE'
|
|
56
|
+
const APP_SECRET = 'YOUR_APPLICATION_SECRET_HERE'
|
|
57
|
+
const PROVIDER_ID = 'YOUR_PROVIDER_ID_HERE'
|
|
58
|
+
|
|
59
|
+
const proofRequest = await ReclaimProofRequest.init(
|
|
60
|
+
APP_ID,
|
|
61
|
+
APP_SECRET,
|
|
62
|
+
PROVIDER_ID
|
|
63
|
+
)
|
|
64
|
+
setReclaimProofRequest(proofRequest)
|
|
65
|
+
}
|
|
87
66
|
|
|
88
|
-
|
|
67
|
+
initializeReclaim()
|
|
68
|
+
}, [])
|
|
89
69
|
|
|
90
|
-
async function
|
|
91
|
-
|
|
92
|
-
|
|
70
|
+
async function handleCreateClaim() {
|
|
71
|
+
if (!reclaimProofRequest) {
|
|
72
|
+
console.error('Reclaim Proof Request not initialized')
|
|
73
|
+
return
|
|
74
|
+
}
|
|
93
75
|
|
|
94
|
-
reclaimProofRequest.
|
|
95
|
-
|
|
96
|
-
'YOUR_APPLICATION_SECRET' // Handle securely for production
|
|
97
|
-
)
|
|
98
|
-
)
|
|
76
|
+
const url = await reclaimProofRequest.getRequestUrl()
|
|
77
|
+
setRequestUrl(url)
|
|
99
78
|
|
|
100
|
-
const
|
|
101
|
-
|
|
79
|
+
const status = reclaimProofRequest.getStatusUrl()
|
|
80
|
+
setStatusUrl(status)
|
|
81
|
+
console.log('Status URL:', status)
|
|
102
82
|
|
|
103
83
|
await reclaimProofRequest.startSession({
|
|
104
|
-
|
|
84
|
+
onSuccess: (proofs) => {
|
|
105
85
|
console.log('Verification success', proofs)
|
|
106
86
|
setProofs(proofs)
|
|
107
|
-
// Your business logic here
|
|
108
87
|
},
|
|
109
|
-
|
|
88
|
+
onFailure: (error) => {
|
|
110
89
|
console.error('Verification failed', error)
|
|
111
|
-
// Your business logic here to handle the error
|
|
112
90
|
}
|
|
113
91
|
})
|
|
114
|
-
|
|
115
|
-
setRequestUrl(requestUrl)
|
|
116
92
|
}
|
|
117
93
|
|
|
118
94
|
return (
|
|
119
|
-
<div className=
|
|
120
|
-
<
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
</div>
|
|
133
|
-
)}
|
|
134
|
-
{proofs.length > 0 && (
|
|
135
|
-
<div>
|
|
136
|
-
<h3>Proofs</h3>
|
|
137
|
-
<ul>
|
|
138
|
-
{proofs.map((proof, index) => {
|
|
139
|
-
return (
|
|
140
|
-
<p key={index}>
|
|
141
|
-
{JSON.stringify(proof.extractedParameterValues)}
|
|
142
|
-
</p>
|
|
143
|
-
)
|
|
144
|
-
})}
|
|
145
|
-
</ul>
|
|
146
|
-
</div>
|
|
147
|
-
)}
|
|
95
|
+
<div className="App">
|
|
96
|
+
<h1>Reclaim Protocol Demo</h1>
|
|
97
|
+
<button onClick={handleCreateClaim}>Create Claim</button>
|
|
98
|
+
{requestUrl && (
|
|
99
|
+
<div>
|
|
100
|
+
<h2>Scan this QR code to start the verification process:</h2>
|
|
101
|
+
<QRCode value={requestUrl} />
|
|
102
|
+
</div>
|
|
103
|
+
)}
|
|
104
|
+
{proofs && (
|
|
105
|
+
<div>
|
|
106
|
+
<h2>Verification Successful!</h2>
|
|
107
|
+
<pre>{JSON.stringify(proofs, null, 2)}</pre>
|
|
148
108
|
</div>
|
|
149
|
-
|
|
109
|
+
)}
|
|
150
110
|
</div>
|
|
151
111
|
)
|
|
152
112
|
}
|
|
@@ -154,52 +114,136 @@ function App() {
|
|
|
154
114
|
export default App
|
|
155
115
|
```
|
|
156
116
|
|
|
157
|
-
|
|
117
|
+
## Step 4: Understanding the code
|
|
158
118
|
|
|
159
|
-
|
|
119
|
+
Let's break down what's happening in this code:
|
|
160
120
|
|
|
161
|
-
|
|
121
|
+
1. We initialize the Reclaim SDK with your application ID, secret, and provider ID. This happens once when the component mounts.
|
|
162
122
|
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
reclaim
|
|
169
|
-
.setSignature
|
|
170
|
-
// TODO: fetch signature from your backend
|
|
171
|
-
// On the backend, generate signature using:
|
|
172
|
-
// await Reclaim.getSignature(requestedProofs, APP_SECRET)
|
|
173
|
-
()
|
|
174
|
-
|
|
175
|
-
const { requestUrl, statusUrl } =
|
|
176
|
-
await reclaimProofRequest.createVerificationRequest()
|
|
177
|
-
|
|
178
|
-
await reclaimProofRequest.startSession({
|
|
179
|
-
onSuccessCallback: proofs => {
|
|
180
|
-
console.log('Verification success', proofs)
|
|
181
|
-
setProofs(proofs)
|
|
182
|
-
// Your business logic here
|
|
183
|
-
},
|
|
184
|
-
onFailureCallback: error => {
|
|
185
|
-
console.error('Verification failed', error)
|
|
186
|
-
// Your business logic here to handle the error
|
|
187
|
-
}
|
|
188
|
-
})
|
|
123
|
+
2. When the user clicks the "Create Claim" button, we:
|
|
124
|
+
- Generate a request URL using `getRequestUrl()`. This URL is used to create the QR code.
|
|
125
|
+
- Get the status URL using `getStatusUrl()`. This URL can be used to check the status of the claim process.
|
|
126
|
+
- Start a session with `startSession()`, which sets up callbacks for successful and failed verifications.
|
|
189
127
|
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
128
|
+
3. We display a QR code using the request URL. When a user scans this code, it starts the verification process.
|
|
129
|
+
|
|
130
|
+
4. The status URL is logged to the console. You can use this URL to check the status of the claim process programmatically.
|
|
131
|
+
|
|
132
|
+
5. When the verification is successful, we display the proof data on the page.
|
|
133
|
+
|
|
134
|
+
## Step 5: Run your application
|
|
193
135
|
|
|
194
|
-
|
|
136
|
+
Start your development server:
|
|
195
137
|
|
|
196
138
|
```bash
|
|
197
139
|
npm start
|
|
198
140
|
```
|
|
199
141
|
|
|
142
|
+
Your Reclaim SDK demo should now be running. Click the "Create Claim" button to generate a QR code. Scan this code to start the verification process.
|
|
143
|
+
|
|
144
|
+
## Understanding the Claim Process
|
|
145
|
+
|
|
146
|
+
1. **Creating a Claim**: When you click "Create Claim", the SDK generates a unique request for verification.
|
|
147
|
+
|
|
148
|
+
2. **QR Code**: The QR code contains the request URL. When scanned, it initiates the verification process.
|
|
149
|
+
|
|
150
|
+
3. **Status URL**: This URL (logged to the console) can be used to check the status of the claim process. It's useful for tracking the progress of verification.
|
|
151
|
+
|
|
152
|
+
4. **Verification**: The `onSuccess` is called when verification is successful, providing the proof data.
|
|
153
|
+
|
|
154
|
+
5. **Handling Failures**: The `onFailure` is called if verification fails, allowing you to handle errors gracefully.
|
|
155
|
+
|
|
200
156
|
## Advanced Configuration
|
|
201
157
|
|
|
202
|
-
|
|
158
|
+
The Reclaim SDK offers several advanced options to customize your integration:
|
|
159
|
+
|
|
160
|
+
1. **Adding Context**:
|
|
161
|
+
You can add context to your proof request, which can be useful for providing additional information:
|
|
162
|
+
```javascript
|
|
163
|
+
reclaimProofRequest.addContext('0x00000000000', 'Example context message')
|
|
164
|
+
```
|
|
165
|
+
|
|
166
|
+
2. **Setting Parameters**:
|
|
167
|
+
If your provider requires specific parameters, you can set them like this:
|
|
168
|
+
```javascript
|
|
169
|
+
reclaimProofRequest.setParams({ email: "test@example.com", userName: "testUser" })
|
|
170
|
+
```
|
|
171
|
+
|
|
172
|
+
3. **Custom Redirect URL**:
|
|
173
|
+
Set a custom URL to redirect users after the verification process:
|
|
174
|
+
```javascript
|
|
175
|
+
reclaimProofRequest.setRedirectUrl('https://example.com/redirect')
|
|
176
|
+
```
|
|
177
|
+
|
|
178
|
+
4. **Custom Callback URL**:
|
|
179
|
+
Set a custom callback URL for your app which allows you to receive proofs and status updates on your callback URL:
|
|
180
|
+
```javascript
|
|
181
|
+
reclaimProofRequest.setAppCallbackUrl('https://example.com/callback')
|
|
182
|
+
```
|
|
183
|
+
|
|
184
|
+
5. **Exporting and Importing SDK Configuration**:
|
|
185
|
+
You can export the entire Reclaim SDK configuration as a JSON string and use it to initialize the SDK with the same configuration on a different service or backend:
|
|
186
|
+
```javascript
|
|
187
|
+
// On the client-side or initial service
|
|
188
|
+
const configJson = reclaimProofRequest.toJsonString()
|
|
189
|
+
console.log('Exportable config:', configJson)
|
|
190
|
+
|
|
191
|
+
// Send this configJson to your backend or another service
|
|
192
|
+
|
|
193
|
+
// On the backend or different service
|
|
194
|
+
const importedRequest = ReclaimProofRequest.fromJsonString(configJson)
|
|
195
|
+
const requestUrl = await importedRequest.getRequestUrl()
|
|
196
|
+
```
|
|
197
|
+
This allows you to generate request URLs and other details from your backend or a different service while maintaining the same configuration.
|
|
198
|
+
|
|
199
|
+
## Handling Proofs on Your Backend
|
|
200
|
+
|
|
201
|
+
For production applications, it's recommended to handle proofs on your backend:
|
|
202
|
+
|
|
203
|
+
1. Set a callback URL:
|
|
204
|
+
```javascript
|
|
205
|
+
reclaimProofRequest.setCallbackUrl('https://your-backend.com/receive-proofs')
|
|
206
|
+
```
|
|
207
|
+
|
|
208
|
+
2. Set a custom status URL:
|
|
209
|
+
```javascript
|
|
210
|
+
reclaimProofRequest.setStatusUrl('https://your-backend.com/receive-status')
|
|
211
|
+
```
|
|
212
|
+
|
|
213
|
+
These options allow you to securely process proofs and status updates on your server.
|
|
214
|
+
|
|
215
|
+
## Next Steps
|
|
216
|
+
|
|
217
|
+
Explore the [Reclaim Protocol documentation](https://docs.reclaimprotocol.org/) for more advanced features and best practices for integrating the SDK into your production applications.
|
|
218
|
+
|
|
219
|
+
Happy coding with Reclaim Protocol!
|
|
220
|
+
|
|
221
|
+
## Contributing to Our Project
|
|
222
|
+
|
|
223
|
+
We welcome contributions to our project! If you find any issues or have suggestions for improvements, please open an issue or submit a pull request.
|
|
224
|
+
|
|
225
|
+
## Security Note
|
|
226
|
+
|
|
227
|
+
Always keep your Application Secret secure. Never expose it in client-side code or public repositories.
|
|
228
|
+
|
|
229
|
+
## Code of Conduct
|
|
230
|
+
|
|
231
|
+
Please read and follow our [Code of Conduct](https://github.com/reclaimprotocol/.github/blob/main/Code-of-Conduct.md) to ensure a positive and inclusive environment for all contributors.
|
|
232
|
+
|
|
233
|
+
## Security
|
|
234
|
+
|
|
235
|
+
If you discover any security-related issues, please refer to our [Security Policy](https://github.com/reclaimprotocol/.github/blob/main/SECURITY.md) for information on how to responsibly disclose vulnerabilities.
|
|
236
|
+
|
|
237
|
+
## Contributor License Agreement
|
|
238
|
+
|
|
239
|
+
Before contributing to this project, please read and sign our [Contributor License Agreement (CLA)](https://github.com/reclaimprotocol/.github/blob/main/CLA.md).
|
|
240
|
+
|
|
241
|
+
## Indie Hackers
|
|
242
|
+
|
|
243
|
+
For Indie Hackers: [Check out our guidelines and potential grant opportunities](https://github.com/reclaimprotocol/.github/blob/main/Indie-Hackers.md)
|
|
244
|
+
|
|
245
|
+
## License
|
|
246
|
+
|
|
247
|
+
This project is licensed under a [custom license](https://github.com/reclaimprotocol/.github/blob/main/LICENSE). By contributing to this project, you agree that your contributions will be licensed under its terms.
|
|
203
248
|
|
|
204
|
-
|
|
205
|
-
- **Set Status URL** - `reclaim.setStatusUrl('https://your-backend.com/receive-status')`
|
|
249
|
+
Thank you for your contributions!
|
package/dist/index.d.ts
CHANGED
|
@@ -1,51 +1,21 @@
|
|
|
1
|
-
interface
|
|
2
|
-
id: string;
|
|
1
|
+
interface ProviderData {
|
|
3
2
|
httpProviderId: string;
|
|
4
3
|
name: string;
|
|
5
|
-
logoUrl: string;
|
|
6
4
|
url: string;
|
|
7
|
-
method?: 'GET' | 'POST';
|
|
8
5
|
loginUrl: string;
|
|
9
|
-
responseSelections:
|
|
10
|
-
|
|
11
|
-
responseMatch: string;
|
|
12
|
-
xPath?: string | undefined;
|
|
13
|
-
jsonPath?: string | undefined;
|
|
14
|
-
}[];
|
|
15
|
-
headers?: {
|
|
16
|
-
[key: string]: string;
|
|
17
|
-
};
|
|
18
|
-
creatorEmail: string;
|
|
19
|
-
applicationId: string[];
|
|
20
|
-
iconPath: {
|
|
21
|
-
uri: string;
|
|
22
|
-
};
|
|
23
|
-
customInjection?: string;
|
|
24
|
-
urlType: 'CONSTANT' | 'REGEX';
|
|
25
|
-
proofCardTitle: string;
|
|
26
|
-
proofCardText: string;
|
|
27
|
-
bodySniff?: {
|
|
28
|
-
enabled: boolean;
|
|
29
|
-
regex?: string;
|
|
30
|
-
};
|
|
31
|
-
userAgent?: {
|
|
32
|
-
ios?: string;
|
|
33
|
-
android?: string;
|
|
34
|
-
};
|
|
35
|
-
geoLocation?: string;
|
|
36
|
-
matchType?: string;
|
|
37
|
-
injectionType: string;
|
|
38
|
-
verificationType: string;
|
|
39
|
-
disableRequestReplay: boolean;
|
|
6
|
+
responseSelections: ResponseSelection[];
|
|
7
|
+
bodySniff?: BodySniff;
|
|
40
8
|
}
|
|
41
9
|
interface ResponseSelection {
|
|
42
|
-
|
|
43
|
-
XPath: string;
|
|
10
|
+
invert: boolean;
|
|
44
11
|
responseMatch: string;
|
|
12
|
+
xPath?: string;
|
|
13
|
+
jsonPath?: string;
|
|
45
14
|
}
|
|
46
15
|
interface BodySniff {
|
|
47
16
|
enabled: boolean;
|
|
48
|
-
regex
|
|
17
|
+
regex?: string;
|
|
18
|
+
template?: string;
|
|
49
19
|
}
|
|
50
20
|
interface Proof {
|
|
51
21
|
identifier: string;
|
|
@@ -67,68 +37,13 @@ interface ProviderClaimData {
|
|
|
67
37
|
owner: string;
|
|
68
38
|
timestampS: number;
|
|
69
39
|
context: string;
|
|
70
|
-
/**
|
|
71
|
-
* identifier of the claim;
|
|
72
|
-
* Hash of (provider, parameters, context)
|
|
73
|
-
*
|
|
74
|
-
* This is different from the claimId returned
|
|
75
|
-
* from the smart contract
|
|
76
|
-
*/
|
|
77
40
|
identifier: string;
|
|
78
41
|
epoch: number;
|
|
79
42
|
}
|
|
80
|
-
interface
|
|
81
|
-
id: string;
|
|
82
|
-
sessionId: string;
|
|
83
|
-
name: string;
|
|
84
|
-
callbackUrl: string;
|
|
85
|
-
statusUrl: string;
|
|
86
|
-
claims: RequestedClaim[];
|
|
87
|
-
}
|
|
88
|
-
interface RequestedClaim {
|
|
89
|
-
provider: string;
|
|
90
|
-
context: string;
|
|
91
|
-
httpProviderId: string;
|
|
92
|
-
payload: Payload;
|
|
93
|
-
}
|
|
94
|
-
interface Payload {
|
|
95
|
-
metadata: {
|
|
96
|
-
name: string;
|
|
97
|
-
logoUrl: string;
|
|
98
|
-
proofCardTitle: string;
|
|
99
|
-
proofCardText: string;
|
|
100
|
-
};
|
|
43
|
+
interface RequestedProof {
|
|
101
44
|
url: string;
|
|
102
|
-
urlType: 'CONSTANT' | 'REGEX';
|
|
103
|
-
method: 'GET' | 'POST';
|
|
104
|
-
login: {
|
|
105
|
-
url: string;
|
|
106
|
-
};
|
|
107
|
-
responseSelections: {
|
|
108
|
-
invert: boolean;
|
|
109
|
-
responseMatch: string;
|
|
110
|
-
xPath?: string;
|
|
111
|
-
jsonPath?: string;
|
|
112
|
-
}[];
|
|
113
|
-
headers?: {
|
|
114
|
-
[key: string]: string;
|
|
115
|
-
};
|
|
116
|
-
customInjection?: string;
|
|
117
|
-
bodySniff?: {
|
|
118
|
-
enabled: boolean;
|
|
119
|
-
regex?: string;
|
|
120
|
-
};
|
|
121
|
-
userAgent?: {
|
|
122
|
-
ios?: string;
|
|
123
|
-
android?: string;
|
|
124
|
-
};
|
|
125
|
-
geoLocation?: string;
|
|
126
|
-
matchType?: string;
|
|
127
|
-
injectionType: string;
|
|
128
|
-
verificationType: string;
|
|
129
|
-
disableRequestReplay: boolean;
|
|
130
45
|
parameters: {
|
|
131
|
-
[key: string]: string
|
|
46
|
+
[key: string]: string;
|
|
132
47
|
};
|
|
133
48
|
}
|
|
134
49
|
interface Context {
|
|
@@ -136,10 +51,6 @@ interface Context {
|
|
|
136
51
|
contextMessage: string;
|
|
137
52
|
}
|
|
138
53
|
interface Beacon {
|
|
139
|
-
/**
|
|
140
|
-
* Get the witnesses for the epoch specified
|
|
141
|
-
* or the current epoch if none is specified
|
|
142
|
-
*/
|
|
143
54
|
getState(epoch?: number): Promise<BeaconState>;
|
|
144
55
|
close?(): Promise<void>;
|
|
145
56
|
}
|
|
@@ -151,72 +62,53 @@ type BeaconState = {
|
|
|
151
62
|
};
|
|
152
63
|
|
|
153
64
|
type StartSessionParams = {
|
|
154
|
-
|
|
155
|
-
|
|
65
|
+
onSuccess: OnSuccess;
|
|
66
|
+
onError: OnError;
|
|
156
67
|
};
|
|
157
|
-
type
|
|
158
|
-
type
|
|
68
|
+
type OnSuccess = (proof: Proof) => void;
|
|
69
|
+
type OnError = (error: Error) => void;
|
|
159
70
|
type ProofRequestOptions = {
|
|
160
71
|
log?: boolean;
|
|
161
|
-
|
|
72
|
+
acceptAiProviders?: boolean;
|
|
162
73
|
};
|
|
163
|
-
type ApplicationId = string;
|
|
164
|
-
type Signature = string;
|
|
165
|
-
type AppCallbackUrl = string;
|
|
166
|
-
type SessionId = string;
|
|
167
|
-
type StatusUrl = string;
|
|
168
|
-
type NoReturn = void;
|
|
169
74
|
|
|
170
|
-
declare
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
buildProofRequest(providerId: string, redirectUser?: boolean, linkingVersion?: string): Promise<RequestedProofs>;
|
|
208
|
-
createVerificationRequest(): Promise<{
|
|
209
|
-
statusUrl: StatusUrl;
|
|
210
|
-
requestUrl: string;
|
|
211
|
-
}>;
|
|
212
|
-
startSession({ onSuccessCallback, onFailureCallback }: StartSessionParams): Promise<void>;
|
|
213
|
-
scheduleIntervalEndingTask(onFailureCallback: OnFailureCallback): void;
|
|
214
|
-
availableParams(): string[];
|
|
215
|
-
setParams(params: {
|
|
216
|
-
[key: string]: string;
|
|
217
|
-
}): NoReturn;
|
|
218
|
-
};
|
|
219
|
-
};
|
|
75
|
+
declare function verifyProof(proof: Proof): Promise<boolean>;
|
|
76
|
+
declare function transformForOnchain(proof: Proof): {
|
|
77
|
+
claimInfo: any;
|
|
78
|
+
signedClaim: any;
|
|
79
|
+
};
|
|
80
|
+
declare class ReclaimProofRequest {
|
|
81
|
+
private applicationId;
|
|
82
|
+
private signature?;
|
|
83
|
+
private appCallbackUrl?;
|
|
84
|
+
private sessionId;
|
|
85
|
+
private options?;
|
|
86
|
+
private context;
|
|
87
|
+
private requestedProof?;
|
|
88
|
+
private providerId;
|
|
89
|
+
private redirectUrl?;
|
|
90
|
+
private intervals;
|
|
91
|
+
private timeStamp;
|
|
92
|
+
private constructor();
|
|
93
|
+
static init(applicationId: string, appSecret: string, providerId: string, options?: ProofRequestOptions): Promise<ReclaimProofRequest>;
|
|
94
|
+
static fromJsonString(jsonString: string): Promise<ReclaimProofRequest>;
|
|
95
|
+
setAppCallbackUrl(url: string): void;
|
|
96
|
+
setRedirectUrl(url: string): void;
|
|
97
|
+
addContext(address: string, message: string): void;
|
|
98
|
+
setParams(params: {
|
|
99
|
+
[key: string]: string;
|
|
100
|
+
}): void;
|
|
101
|
+
getAppCallbackUrl(): string;
|
|
102
|
+
getStatusUrl(): string;
|
|
103
|
+
private setSignature;
|
|
104
|
+
private generateSignature;
|
|
105
|
+
private buildProofRequest;
|
|
106
|
+
private getRequestedProof;
|
|
107
|
+
private availableParams;
|
|
108
|
+
private clearInterval;
|
|
109
|
+
toJsonString(options?: ProofRequestOptions): string;
|
|
110
|
+
getRequestUrl(): Promise<string>;
|
|
111
|
+
startSession({ onSuccess, onError }: StartSessionParams): Promise<void>;
|
|
220
112
|
}
|
|
221
113
|
|
|
222
|
-
export { type Beacon, type BeaconState, type BodySniff, type Context, type
|
|
114
|
+
export { type Beacon, type BeaconState, type BodySniff, type Context, type Proof, type ProviderClaimData, type ProviderData, ReclaimProofRequest, type RequestedProof, type ResponseSelection, type WitnessData, transformForOnchain, verifyProof };
|