@prosopo/server 0.2.1 → 0.2.4
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 +47 -0
- package/dist/cjs/contracts/captcha/dist/build-extrinsic/captcha.cjs +339 -0
- package/dist/cjs/contracts/captcha/dist/contract-info/captcha.cjs +6 -0
- package/dist/cjs/contracts/captcha/dist/contracts/captcha.cjs +79 -0
- package/dist/cjs/contracts/captcha/dist/data/captcha.json.cjs +3374 -0
- package/dist/cjs/contracts/captcha/dist/event-data/captcha.json.cjs +3 -0
- package/dist/cjs/contracts/captcha/dist/events/captcha.cjs +23 -0
- package/dist/cjs/contracts/captcha/dist/index.cjs +44 -0
- package/dist/cjs/contracts/captcha/dist/mixed-methods/captcha.cjs +470 -0
- package/dist/cjs/contracts/captcha/dist/query/captcha.cjs +468 -0
- package/dist/cjs/contracts/captcha/dist/shared/utils.cjs +31 -0
- package/dist/cjs/contracts/captcha/dist/tx-sign-and-send/captcha.cjs +426 -0
- package/dist/cjs/contracts/captcha/dist/types-arguments/captcha.cjs +62 -0
- package/dist/cjs/index.cjs +3 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -2
- package/dist/index.js.map +1 -1
- package/package.json +12 -7
package/README.md
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
# @prosopo/server
|
|
2
|
+
|
|
3
|
+
npm package to make verifying Procaptcha soltions easy.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
You can install this library with:
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
npm install @prosopo/server --save
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## Basic Usage
|
|
14
|
+
|
|
15
|
+
Simply import the `ProsopoServer` class and instantiate it with your Procaptcha API key.
|
|
16
|
+
|
|
17
|
+
```typescript
|
|
18
|
+
import {ApiParams, ProcaptchaResponse} from '@prosopo/types'
|
|
19
|
+
import {ProsopoServer} from '@prosopo/server'
|
|
20
|
+
|
|
21
|
+
async function getProsopoServer() {
|
|
22
|
+
const config = getProsopoConfig()
|
|
23
|
+
const pairType = (process.env.PAIR_TYPE as KeypairType) || ('sr25519' as KeypairType)
|
|
24
|
+
const ss58Format = parseInt(process.env.SS58_FORMAT || '') || 42
|
|
25
|
+
const pair = await getPair(pairType, ss58Format, process.env.REACT_APP_SERVER_MNEMONIC)
|
|
26
|
+
const prosopoServer = new ProsopoServer(pair, config)
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
async function protectedFunction(server: ProsopoServer, payload: ProcaptchaResponse) {
|
|
30
|
+
|
|
31
|
+
if (await server.isVerified(payload[ApiParams.procaptchaResponse])) {
|
|
32
|
+
// perform CAPTCHA protected action
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
const payload = getPayloadFromRequest() // your request payload
|
|
38
|
+
getProsopoServer().then((server) => {
|
|
39
|
+
protectedFunction(server, payload).then(() => {
|
|
40
|
+
// ...
|
|
41
|
+
})
|
|
42
|
+
})
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
The full example can be seen [here](https://github.com/prosopo/captcha/blob/main/demos/client-example-server/src/app.ts).
|
|
@@ -0,0 +1,339 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
const typechainTypes = require("@727-ventures/typechain-types");
|
|
3
|
+
class Methods {
|
|
4
|
+
constructor(nativeContract, apiPromise) {
|
|
5
|
+
this.__nativeContract = nativeContract;
|
|
6
|
+
this.__apiPromise = apiPromise;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* getGitCommitId
|
|
10
|
+
*
|
|
11
|
+
*/
|
|
12
|
+
getGitCommitId(__options) {
|
|
13
|
+
return typechainTypes.buildSubmittableExtrinsic(this.__apiPromise, this.__nativeContract, "getGitCommitId", [], __options);
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* getAdmin
|
|
17
|
+
*
|
|
18
|
+
*/
|
|
19
|
+
getAdmin(__options) {
|
|
20
|
+
return typechainTypes.buildSubmittableExtrinsic(this.__apiPromise, this.__nativeContract, "getAdmin", [], __options);
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* getPayees
|
|
24
|
+
*
|
|
25
|
+
*/
|
|
26
|
+
getPayees(__options) {
|
|
27
|
+
return typechainTypes.buildSubmittableExtrinsic(this.__apiPromise, this.__nativeContract, "getPayees", [], __options);
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* getDappPayees
|
|
31
|
+
*
|
|
32
|
+
*/
|
|
33
|
+
getDappPayees(__options) {
|
|
34
|
+
return typechainTypes.buildSubmittableExtrinsic(this.__apiPromise, this.__nativeContract, "getDappPayees", [], __options);
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* getStatuses
|
|
38
|
+
*
|
|
39
|
+
*/
|
|
40
|
+
getStatuses(__options) {
|
|
41
|
+
return typechainTypes.buildSubmittableExtrinsic(this.__apiPromise, this.__nativeContract, "getStatuses", [], __options);
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* getProviderStakeThreshold
|
|
45
|
+
*
|
|
46
|
+
*/
|
|
47
|
+
getProviderStakeThreshold(__options) {
|
|
48
|
+
return typechainTypes.buildSubmittableExtrinsic(this.__apiPromise, this.__nativeContract, "getProviderStakeThreshold", [], __options);
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* getDappStakeThreshold
|
|
52
|
+
*
|
|
53
|
+
*/
|
|
54
|
+
getDappStakeThreshold(__options) {
|
|
55
|
+
return typechainTypes.buildSubmittableExtrinsic(this.__apiPromise, this.__nativeContract, "getDappStakeThreshold", [], __options);
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* getMaxProviderFee
|
|
59
|
+
*
|
|
60
|
+
*/
|
|
61
|
+
getMaxProviderFee(__options) {
|
|
62
|
+
return typechainTypes.buildSubmittableExtrinsic(this.__apiPromise, this.__nativeContract, "getMaxProviderFee", [], __options);
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* getMinNumActiveProviders
|
|
66
|
+
*
|
|
67
|
+
*/
|
|
68
|
+
getMinNumActiveProviders(__options) {
|
|
69
|
+
return typechainTypes.buildSubmittableExtrinsic(this.__apiPromise, this.__nativeContract, "getMinNumActiveProviders", [], __options);
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* getBlockTime
|
|
73
|
+
*
|
|
74
|
+
*/
|
|
75
|
+
getBlockTime(__options) {
|
|
76
|
+
return typechainTypes.buildSubmittableExtrinsic(this.__apiPromise, this.__nativeContract, "getBlockTime", [], __options);
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* getMaxUserHistoryAgeSeconds
|
|
80
|
+
*
|
|
81
|
+
*/
|
|
82
|
+
getMaxUserHistoryAgeSeconds(__options) {
|
|
83
|
+
return typechainTypes.buildSubmittableExtrinsic(this.__apiPromise, this.__nativeContract, "getMaxUserHistoryAgeSeconds", [], __options);
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* getMaxUserHistoryLen
|
|
87
|
+
*
|
|
88
|
+
*/
|
|
89
|
+
getMaxUserHistoryLen(__options) {
|
|
90
|
+
return typechainTypes.buildSubmittableExtrinsic(this.__apiPromise, this.__nativeContract, "getMaxUserHistoryLen", [], __options);
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* getMaxUserHistoryAgeBlocks
|
|
94
|
+
*
|
|
95
|
+
*/
|
|
96
|
+
getMaxUserHistoryAgeBlocks(__options) {
|
|
97
|
+
return typechainTypes.buildSubmittableExtrinsic(this.__apiPromise, this.__nativeContract, "getMaxUserHistoryAgeBlocks", [], __options);
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* providerRegister
|
|
101
|
+
*
|
|
102
|
+
* @param { Array<(number | string | BN)> } url,
|
|
103
|
+
* @param { (number | string | BN) } fee,
|
|
104
|
+
* @param { ArgumentTypes.Payee } payee,
|
|
105
|
+
*/
|
|
106
|
+
providerRegister(url, fee, payee, __options) {
|
|
107
|
+
return typechainTypes.buildSubmittableExtrinsic(this.__apiPromise, this.__nativeContract, "providerRegister", [url, fee, payee], __options);
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* providerUpdate
|
|
111
|
+
*
|
|
112
|
+
* @param { Array<(number | string | BN)> } url,
|
|
113
|
+
* @param { (number | string | BN) } fee,
|
|
114
|
+
* @param { ArgumentTypes.Payee } payee,
|
|
115
|
+
*/
|
|
116
|
+
providerUpdate(url, fee, payee, __options) {
|
|
117
|
+
return typechainTypes.buildSubmittableExtrinsic(this.__apiPromise, this.__nativeContract, "providerUpdate", [url, fee, payee], __options);
|
|
118
|
+
}
|
|
119
|
+
/**
|
|
120
|
+
* providerDeactivate
|
|
121
|
+
*
|
|
122
|
+
*/
|
|
123
|
+
providerDeactivate(__options) {
|
|
124
|
+
return typechainTypes.buildSubmittableExtrinsic(this.__apiPromise, this.__nativeContract, "providerDeactivate", [], __options);
|
|
125
|
+
}
|
|
126
|
+
/**
|
|
127
|
+
* providerDeregister
|
|
128
|
+
*
|
|
129
|
+
*/
|
|
130
|
+
providerDeregister(__options) {
|
|
131
|
+
return typechainTypes.buildSubmittableExtrinsic(this.__apiPromise, this.__nativeContract, "providerDeregister", [], __options);
|
|
132
|
+
}
|
|
133
|
+
/**
|
|
134
|
+
* getProvider
|
|
135
|
+
*
|
|
136
|
+
* @param { ArgumentTypes.AccountId } account,
|
|
137
|
+
*/
|
|
138
|
+
getProvider(account, __options) {
|
|
139
|
+
return typechainTypes.buildSubmittableExtrinsic(this.__apiPromise, this.__nativeContract, "getProvider", [account], __options);
|
|
140
|
+
}
|
|
141
|
+
/**
|
|
142
|
+
* providerFund
|
|
143
|
+
*
|
|
144
|
+
*/
|
|
145
|
+
providerFund(__options) {
|
|
146
|
+
return typechainTypes.buildSubmittableExtrinsic(this.__apiPromise, this.__nativeContract, "providerFund", [], __options);
|
|
147
|
+
}
|
|
148
|
+
/**
|
|
149
|
+
* providerSetDataset
|
|
150
|
+
*
|
|
151
|
+
* @param { ArgumentTypes.Hash } datasetId,
|
|
152
|
+
* @param { ArgumentTypes.Hash } datasetIdContent,
|
|
153
|
+
*/
|
|
154
|
+
providerSetDataset(datasetId, datasetIdContent, __options) {
|
|
155
|
+
return typechainTypes.buildSubmittableExtrinsic(this.__apiPromise, this.__nativeContract, "providerSetDataset", [datasetId, datasetIdContent], __options);
|
|
156
|
+
}
|
|
157
|
+
/**
|
|
158
|
+
* getDapp
|
|
159
|
+
*
|
|
160
|
+
* @param { ArgumentTypes.AccountId } contract,
|
|
161
|
+
*/
|
|
162
|
+
getDapp(contract, __options) {
|
|
163
|
+
return typechainTypes.buildSubmittableExtrinsic(this.__apiPromise, this.__nativeContract, "getDapp", [contract], __options);
|
|
164
|
+
}
|
|
165
|
+
/**
|
|
166
|
+
* dappRegister
|
|
167
|
+
*
|
|
168
|
+
* @param { ArgumentTypes.AccountId } contract,
|
|
169
|
+
* @param { ArgumentTypes.DappPayee } payee,
|
|
170
|
+
*/
|
|
171
|
+
dappRegister(contract, payee, __options) {
|
|
172
|
+
return typechainTypes.buildSubmittableExtrinsic(this.__apiPromise, this.__nativeContract, "dappRegister", [contract, payee], __options);
|
|
173
|
+
}
|
|
174
|
+
/**
|
|
175
|
+
* dappUpdate
|
|
176
|
+
*
|
|
177
|
+
* @param { ArgumentTypes.AccountId } contract,
|
|
178
|
+
* @param { ArgumentTypes.DappPayee } payee,
|
|
179
|
+
* @param { ArgumentTypes.AccountId } owner,
|
|
180
|
+
*/
|
|
181
|
+
dappUpdate(contract, payee, owner, __options) {
|
|
182
|
+
return typechainTypes.buildSubmittableExtrinsic(this.__apiPromise, this.__nativeContract, "dappUpdate", [contract, payee, owner], __options);
|
|
183
|
+
}
|
|
184
|
+
/**
|
|
185
|
+
* dappFund
|
|
186
|
+
*
|
|
187
|
+
* @param { ArgumentTypes.AccountId } contract,
|
|
188
|
+
*/
|
|
189
|
+
dappFund(contract, __options) {
|
|
190
|
+
return typechainTypes.buildSubmittableExtrinsic(this.__apiPromise, this.__nativeContract, "dappFund", [contract], __options);
|
|
191
|
+
}
|
|
192
|
+
/**
|
|
193
|
+
* dappDeregister
|
|
194
|
+
*
|
|
195
|
+
* @param { ArgumentTypes.AccountId } contract,
|
|
196
|
+
*/
|
|
197
|
+
dappDeregister(contract, __options) {
|
|
198
|
+
return typechainTypes.buildSubmittableExtrinsic(this.__apiPromise, this.__nativeContract, "dappDeregister", [contract], __options);
|
|
199
|
+
}
|
|
200
|
+
/**
|
|
201
|
+
* dappDeactivate
|
|
202
|
+
*
|
|
203
|
+
* @param { ArgumentTypes.AccountId } contract,
|
|
204
|
+
*/
|
|
205
|
+
dappDeactivate(contract, __options) {
|
|
206
|
+
return typechainTypes.buildSubmittableExtrinsic(this.__apiPromise, this.__nativeContract, "dappDeactivate", [contract], __options);
|
|
207
|
+
}
|
|
208
|
+
/**
|
|
209
|
+
* getUserHistorySummary
|
|
210
|
+
*
|
|
211
|
+
* @param { ArgumentTypes.AccountId } userAccount,
|
|
212
|
+
*/
|
|
213
|
+
getUserHistorySummary(userAccount, __options) {
|
|
214
|
+
return typechainTypes.buildSubmittableExtrinsic(this.__apiPromise, this.__nativeContract, "getUserHistorySummary", [userAccount], __options);
|
|
215
|
+
}
|
|
216
|
+
/**
|
|
217
|
+
* providerCommit
|
|
218
|
+
*
|
|
219
|
+
* @param { ArgumentTypes.Commit } commit,
|
|
220
|
+
*/
|
|
221
|
+
providerCommit(commit, __options) {
|
|
222
|
+
return typechainTypes.buildSubmittableExtrinsic(this.__apiPromise, this.__nativeContract, "providerCommit", [commit], __options);
|
|
223
|
+
}
|
|
224
|
+
/**
|
|
225
|
+
* providerCommitMany
|
|
226
|
+
*
|
|
227
|
+
* @param { Array<ArgumentTypes.Commit> } commits,
|
|
228
|
+
*/
|
|
229
|
+
providerCommitMany(commits, __options) {
|
|
230
|
+
return typechainTypes.buildSubmittableExtrinsic(this.__apiPromise, this.__nativeContract, "providerCommitMany", [commits], __options);
|
|
231
|
+
}
|
|
232
|
+
/**
|
|
233
|
+
* dappOperatorIsHumanUser
|
|
234
|
+
*
|
|
235
|
+
* @param { ArgumentTypes.AccountId } userAccount,
|
|
236
|
+
* @param { (number | string | BN) } threshold,
|
|
237
|
+
*/
|
|
238
|
+
dappOperatorIsHumanUser(userAccount, threshold, __options) {
|
|
239
|
+
return typechainTypes.buildSubmittableExtrinsic(this.__apiPromise, this.__nativeContract, "dappOperatorIsHumanUser", [userAccount, threshold], __options);
|
|
240
|
+
}
|
|
241
|
+
/**
|
|
242
|
+
* dappOperatorLastCorrectCaptcha
|
|
243
|
+
*
|
|
244
|
+
* @param { ArgumentTypes.AccountId } userAccount,
|
|
245
|
+
*/
|
|
246
|
+
dappOperatorLastCorrectCaptcha(userAccount, __options) {
|
|
247
|
+
return typechainTypes.buildSubmittableExtrinsic(this.__apiPromise, this.__nativeContract, "dappOperatorLastCorrectCaptcha", [userAccount], __options);
|
|
248
|
+
}
|
|
249
|
+
/**
|
|
250
|
+
* getCaptchaData
|
|
251
|
+
*
|
|
252
|
+
* @param { ArgumentTypes.Hash } datasetId,
|
|
253
|
+
*/
|
|
254
|
+
getCaptchaData(datasetId, __options) {
|
|
255
|
+
return typechainTypes.buildSubmittableExtrinsic(this.__apiPromise, this.__nativeContract, "getCaptchaData", [datasetId], __options);
|
|
256
|
+
}
|
|
257
|
+
/**
|
|
258
|
+
* getUser
|
|
259
|
+
*
|
|
260
|
+
* @param { ArgumentTypes.AccountId } userAccount,
|
|
261
|
+
*/
|
|
262
|
+
getUser(userAccount, __options) {
|
|
263
|
+
return typechainTypes.buildSubmittableExtrinsic(this.__apiPromise, this.__nativeContract, "getUser", [userAccount], __options);
|
|
264
|
+
}
|
|
265
|
+
/**
|
|
266
|
+
* getCommit
|
|
267
|
+
*
|
|
268
|
+
* @param { ArgumentTypes.Hash } commitId,
|
|
269
|
+
*/
|
|
270
|
+
getCommit(commitId, __options) {
|
|
271
|
+
return typechainTypes.buildSubmittableExtrinsic(this.__apiPromise, this.__nativeContract, "getCommit", [commitId], __options);
|
|
272
|
+
}
|
|
273
|
+
/**
|
|
274
|
+
* listProvidersByAccounts
|
|
275
|
+
*
|
|
276
|
+
* @param { Array<ArgumentTypes.AccountId> } providerAccounts,
|
|
277
|
+
*/
|
|
278
|
+
listProvidersByAccounts(providerAccounts, __options) {
|
|
279
|
+
return typechainTypes.buildSubmittableExtrinsic(this.__apiPromise, this.__nativeContract, "listProvidersByAccounts", [providerAccounts], __options);
|
|
280
|
+
}
|
|
281
|
+
/**
|
|
282
|
+
* listProvidersByStatus
|
|
283
|
+
*
|
|
284
|
+
* @param { Array<ArgumentTypes.GovernanceStatus> } statuses,
|
|
285
|
+
*/
|
|
286
|
+
listProvidersByStatus(statuses, __options) {
|
|
287
|
+
return typechainTypes.buildSubmittableExtrinsic(this.__apiPromise, this.__nativeContract, "listProvidersByStatus", [statuses], __options);
|
|
288
|
+
}
|
|
289
|
+
/**
|
|
290
|
+
* getRandomActiveProvider
|
|
291
|
+
*
|
|
292
|
+
* @param { ArgumentTypes.AccountId } userAccount,
|
|
293
|
+
* @param { ArgumentTypes.AccountId } dappContract,
|
|
294
|
+
*/
|
|
295
|
+
getRandomActiveProvider(userAccount, dappContract, __options) {
|
|
296
|
+
return typechainTypes.buildSubmittableExtrinsic(this.__apiPromise, this.__nativeContract, "getRandomActiveProvider", [userAccount, dappContract], __options);
|
|
297
|
+
}
|
|
298
|
+
/**
|
|
299
|
+
* getAllProviderAccounts
|
|
300
|
+
*
|
|
301
|
+
*/
|
|
302
|
+
getAllProviderAccounts(__options) {
|
|
303
|
+
return typechainTypes.buildSubmittableExtrinsic(this.__apiPromise, this.__nativeContract, "getAllProviderAccounts", [], __options);
|
|
304
|
+
}
|
|
305
|
+
/**
|
|
306
|
+
* getRandomNumber
|
|
307
|
+
*
|
|
308
|
+
* @param { (string | number | BN) } len,
|
|
309
|
+
* @param { ArgumentTypes.AccountId } userAccount,
|
|
310
|
+
* @param { ArgumentTypes.AccountId } dappContract,
|
|
311
|
+
*/
|
|
312
|
+
getRandomNumber(len, userAccount, dappContract, __options) {
|
|
313
|
+
return typechainTypes.buildSubmittableExtrinsic(this.__apiPromise, this.__nativeContract, "getRandomNumber", [len, userAccount, dappContract], __options);
|
|
314
|
+
}
|
|
315
|
+
/**
|
|
316
|
+
* terminate
|
|
317
|
+
*
|
|
318
|
+
*/
|
|
319
|
+
terminate(__options) {
|
|
320
|
+
return typechainTypes.buildSubmittableExtrinsic(this.__apiPromise, this.__nativeContract, "terminate", [], __options);
|
|
321
|
+
}
|
|
322
|
+
/**
|
|
323
|
+
* withdraw
|
|
324
|
+
*
|
|
325
|
+
* @param { (string | number | BN) } amount,
|
|
326
|
+
*/
|
|
327
|
+
withdraw(amount, __options) {
|
|
328
|
+
return typechainTypes.buildSubmittableExtrinsic(this.__apiPromise, this.__nativeContract, "withdraw", [amount], __options);
|
|
329
|
+
}
|
|
330
|
+
/**
|
|
331
|
+
* setCodeHash
|
|
332
|
+
*
|
|
333
|
+
* @param { Array<(number | string | BN)> } codeHash,
|
|
334
|
+
*/
|
|
335
|
+
setCodeHash(codeHash, __options) {
|
|
336
|
+
return typechainTypes.buildSubmittableExtrinsic(this.__apiPromise, this.__nativeContract, "setCodeHash", [codeHash], __options);
|
|
337
|
+
}
|
|
338
|
+
}
|
|
339
|
+
module.exports = Methods;
|