@prosopo/server 0.2.6 → 0.2.8

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.
@@ -1,114 +1,12 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- const api$1 = require("@polkadot/api");
4
- const types = require("@prosopo/types");
5
- const keyring = require("@polkadot/keyring");
6
- const common = require("@prosopo/common");
3
+ const server = require("./server.cjs");
4
+ const config = require("./config.cjs");
7
5
  const contract = require("@prosopo/contract");
8
- const api = require("@prosopo/api");
9
- const publicProsopoPair = require("./publicProsopoPair.cjs");
10
- require("./contracts/captcha/dist/index.cjs");
11
- const rpcProvider = require("@polkadot/rpc-provider");
12
- const util = require("@prosopo/util");
13
- const captcha = require("./contracts/captcha/dist/contract-info/captcha.cjs");
14
- class ProsopoServer {
15
- constructor(pair, config) {
16
- this.config = config;
17
- this.pair = pair;
18
- if (this.config.defaultEnvironment && Object.prototype.hasOwnProperty.call(this.config.networks, this.config.defaultEnvironment)) {
19
- this.defaultEnvironment = this.config.defaultEnvironment;
20
- const networkName = types.NetworkNamesSchema.parse(this.defaultEnvironment);
21
- this.network = util.get(this.config.networks, networkName);
22
- this.wsProvider = new rpcProvider.WsProvider(this.network.endpoint);
23
- this.prosopoContractAddress = this.network.contract.address;
24
- this.dappContractAddress = this.config.account.address;
25
- this.contractName = this.network.contract.name;
26
- this.logger = common.getLogger(this.config.logLevel, "@prosopo/server");
27
- this.keyring = new keyring.Keyring({
28
- type: "sr25519"
29
- // TODO get this from the chain
30
- });
31
- this.abi = JSON.parse(captcha.ContractAbi);
32
- } else {
33
- throw new common.ProsopoEnvError(
34
- "CONFIG.UNKNOWN_ENVIRONMENT",
35
- this.constructor.name,
36
- {},
37
- this.config.defaultEnvironment
38
- );
39
- }
40
- }
41
- async getProviderApi(providerUrl) {
42
- return new api.ProviderApi(this.network, providerUrl, this.config.account.address);
43
- }
44
- async isReady() {
45
- try {
46
- this.api = await api$1.ApiPromise.create({ provider: this.wsProvider });
47
- await this.getSigner();
48
- await this.getContractApi();
49
- } catch (err) {
50
- throw new common.ProsopoEnvError(err, "GENERAL.ENVIRONMENT_NOT_READY");
51
- }
52
- }
53
- async getSigner() {
54
- if (!this.api) {
55
- this.api = await api$1.ApiPromise.create({ provider: this.wsProvider });
56
- }
57
- await this.api.isReadyOrError;
58
- try {
59
- this.pair = this.keyring.addPair(this.pair);
60
- } catch (err) {
61
- throw new common.ProsopoEnvError("CONTRACT.SIGNER_UNDEFINED", this.getSigner.name, {}, err);
62
- }
63
- }
64
- getApi() {
65
- if (this.api === void 0) {
66
- throw new common.ProsopoEnvError(new Error("api undefined"));
67
- }
68
- return this.api;
69
- }
70
- getContract() {
71
- if (this.contract === void 0) {
72
- throw new common.ProsopoEnvError(new Error("contract undefined"));
73
- }
74
- return this.contract;
75
- }
76
- async isVerified(payload) {
77
- const { user, dapp, providerUrl, commitmentId, blockNumber } = payload;
78
- const contractApi = await this.getContractApi();
79
- const block = await this.getApi().rpc.chain.getBlockHash(blockNumber);
80
- const getRandomProviderResponse = await this.getContract().queryAtBlock(
81
- block,
82
- "getRandomActiveProvider",
83
- [user, dapp]
84
- );
85
- const providerUrlTrimmed = common.trimProviderUrl(getRandomProviderResponse.provider.url.toString());
86
- if (providerUrlTrimmed !== providerUrl) {
87
- return false;
88
- }
89
- if (providerUrlTrimmed && commitmentId) {
90
- const providerApi = await this.getProviderApi(providerUrl);
91
- const result = await providerApi.verifyDappUser(user, commitmentId);
92
- return result.solutionApproved;
93
- } else {
94
- return (await contractApi.query.dappOperatorIsHumanUser(user, this.config.solutionThreshold)).value.unwrap().unwrap();
95
- }
96
- }
97
- async getContractApi() {
98
- this.contract = new contract.ProsopoCaptchaContract(
99
- this.getApi(),
100
- this.abi,
101
- this.prosopoContractAddress,
102
- this.pair,
103
- this.contractName,
104
- 0
105
- );
106
- return this.contract;
107
- }
108
- }
109
- const PublicProsopoServer = async (config, publicAccountNetwork) => {
110
- const publicProsopoPair$1 = await publicProsopoPair.getPublicProsopoPair(publicAccountNetwork);
111
- return new ProsopoServer(publicProsopoPair$1, config);
6
+ const PublicProsopoServer = async (config2) => {
7
+ const pair = await contract.getPairAsync(config2.networks[config2.defaultNetwork], void 0, config2.account.address);
8
+ return new server.ProsopoServer(config2, pair);
112
9
  };
113
- exports.ProsopoServer = ProsopoServer;
10
+ exports.ProsopoServer = server.ProsopoServer;
11
+ exports.getServerConfig = config.getServerConfig;
114
12
  exports.PublicProsopoServer = PublicProsopoServer;
@@ -0,0 +1,112 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ const api$1 = require("@polkadot/api");
4
+ const types = require("@prosopo/types");
5
+ const keyring = require("@polkadot/keyring");
6
+ const common = require("@prosopo/common");
7
+ const contract = require("@prosopo/contract");
8
+ const api = require("@prosopo/api");
9
+ require("./contracts/captcha/dist/index.cjs");
10
+ const rpcProvider = require("@polkadot/rpc-provider");
11
+ const util = require("@prosopo/util");
12
+ const captcha = require("./contracts/captcha/dist/contract-info/captcha.cjs");
13
+ class ProsopoServer {
14
+ constructor(config, pair) {
15
+ this.config = config;
16
+ this.pair = pair;
17
+ if (this.config.defaultEnvironment && Object.prototype.hasOwnProperty.call(this.config.networks, this.config.defaultEnvironment)) {
18
+ this.defaultEnvironment = this.config.defaultEnvironment;
19
+ const networkName = types.NetworkNamesSchema.parse(this.config.defaultNetwork);
20
+ this.network = util.get(this.config.networks, networkName);
21
+ this.wsProvider = new rpcProvider.WsProvider(this.network.endpoint);
22
+ this.prosopoContractAddress = this.network.contract.address;
23
+ this.dappContractAddress = this.config.account.address || contract.getZeroAddress().toString();
24
+ this.contractName = this.network.contract.name;
25
+ this.logger = common.getLogger(this.config.logLevel, "@prosopo/server");
26
+ this.keyring = new keyring.Keyring({
27
+ type: "sr25519"
28
+ // TODO get this from the chain
29
+ });
30
+ this.abi = JSON.parse(captcha.ContractAbi);
31
+ } else {
32
+ throw new common.ProsopoEnvError(
33
+ "CONFIG.UNKNOWN_ENVIRONMENT",
34
+ this.constructor.name,
35
+ {},
36
+ this.config.defaultEnvironment
37
+ );
38
+ }
39
+ }
40
+ async getProviderApi(providerUrl) {
41
+ return new api.ProviderApi(this.network, providerUrl, this.dappContractAddress);
42
+ }
43
+ async isReady() {
44
+ try {
45
+ this.api = await api$1.ApiPromise.create({ provider: this.wsProvider });
46
+ await this.getSigner();
47
+ await this.getContractApi();
48
+ } catch (err) {
49
+ throw new common.ProsopoEnvError(err, "GENERAL.ENVIRONMENT_NOT_READY");
50
+ }
51
+ }
52
+ async getSigner() {
53
+ if (this.pair) {
54
+ if (!this.api) {
55
+ this.api = await api$1.ApiPromise.create({ provider: this.wsProvider });
56
+ }
57
+ await this.api.isReadyOrError;
58
+ try {
59
+ this.pair = this.keyring.addPair(this.pair);
60
+ } catch (err) {
61
+ throw new common.ProsopoEnvError("CONTRACT.SIGNER_UNDEFINED", this.getSigner.name, {}, err);
62
+ }
63
+ }
64
+ }
65
+ getApi() {
66
+ if (this.api === void 0) {
67
+ throw new common.ProsopoEnvError(new Error("api undefined"));
68
+ }
69
+ return this.api;
70
+ }
71
+ getContract() {
72
+ if (this.contract === void 0) {
73
+ throw new common.ProsopoEnvError(new Error("contract undefined"));
74
+ }
75
+ return this.contract;
76
+ }
77
+ async isVerified(payload) {
78
+ const { user, dapp, providerUrl, commitmentId, blockNumber } = payload;
79
+ const contractApi = await this.getContractApi();
80
+ const block = await this.getApi().rpc.chain.getBlockHash(blockNumber);
81
+ const getRandomProviderResponse = await this.getContract().queryAtBlock(
82
+ block,
83
+ "getRandomActiveProvider",
84
+ [user, dapp]
85
+ );
86
+ const providerUrlTrimmed = common.trimProviderUrl(getRandomProviderResponse.provider.url.toString());
87
+ if (providerUrlTrimmed !== providerUrl) {
88
+ return false;
89
+ }
90
+ console.log("providerUrlTrimmed", providerUrlTrimmed, "commitmentId", commitmentId);
91
+ if (providerUrlTrimmed && commitmentId) {
92
+ const providerApi = await this.getProviderApi(providerUrl);
93
+ const result = await providerApi.verifyDappUser(user, commitmentId);
94
+ console.log(result);
95
+ return result.solutionApproved;
96
+ } else {
97
+ return (await contractApi.query.dappOperatorIsHumanUser(user, this.config.solutionThreshold)).value.unwrap().unwrap();
98
+ }
99
+ }
100
+ async getContractApi() {
101
+ this.contract = new contract.ProsopoCaptchaContract(
102
+ this.getApi(),
103
+ this.abi,
104
+ this.prosopoContractAddress,
105
+ this.contractName,
106
+ 0,
107
+ this.pair
108
+ );
109
+ return this.contract;
110
+ }
111
+ }
112
+ exports.ProsopoServer = ProsopoServer;
@@ -0,0 +1,31 @@
1
+ export declare const getServerConfig: () => {
2
+ logLevel: "trace" | "debug" | "info" | "warn" | "error" | "fatal";
3
+ defaultEnvironment: "development" | "staging" | "production";
4
+ defaultNetwork: "development" | "rococo" | "shiden";
5
+ account: {
6
+ address?: string | undefined;
7
+ secret?: string | undefined;
8
+ password?: string | undefined;
9
+ };
10
+ networks: Record<"development" | "rococo" | "shiden", {
11
+ endpoint: string;
12
+ contract: {
13
+ address: string;
14
+ name: string;
15
+ };
16
+ pairType: "sr25519" | "ed25519" | "ecdsa" | "ethereum";
17
+ ss58Format: number;
18
+ }>;
19
+ web2: boolean;
20
+ solutionThreshold: number;
21
+ dappName: string;
22
+ serverUrl: string;
23
+ database?: Partial<Record<"development" | "staging" | "production", {
24
+ type: string;
25
+ endpoint: string;
26
+ dbname: string;
27
+ authSource: string;
28
+ }>> | undefined;
29
+ userAccountAddress?: string | undefined;
30
+ };
31
+ //# sourceMappingURL=config.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAeA,eAAO,MAAM,eAAe;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CActB,CAAA"}
package/dist/config.js ADDED
@@ -0,0 +1,29 @@
1
+ // Copyright 2021-2022 Prosopo (UK) Ltd.
2
+ //
3
+ // Licensed under the Apache License, Version 2.0 (the "License");
4
+ // you may not use this file except in compliance with the License.
5
+ // You may obtain a copy of the License at
6
+ //
7
+ // http://www.apache.org/licenses/LICENSE-2.0
8
+ //
9
+ // Unless required by applicable law or agreed to in writing, software
10
+ // distributed under the License is distributed on an "AS IS" BASIS,
11
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ // See the License for the specific language governing permissions and
13
+ // limitations under the License.
14
+ import { ProsopoServerConfigSchema } from '@prosopo/types';
15
+ export const getServerConfig = () => ProsopoServerConfigSchema.parse({
16
+ defaultEnvironment: process.env.DEFAULT_ENVIRONMENT,
17
+ defaultNetwork: process.env.DEFAULT_NETWORK,
18
+ serverUrl:
19
+ // https://github.com/prosopo/captcha/issues/701
20
+ process.env.REACT_APP_SERVER_URL && process.env.REACT_APP_SERVER_PORT
21
+ ? `${process.env.REACT_APP_SERVER_URL}:${process.env.REACT_APP_SERVER_PORT}`
22
+ : 'http://localhost:9228',
23
+ dappName: process.env.REACT_APP_DAPP_NAME || 'client-example-server',
24
+ account: {
25
+ password: '',
26
+ address: process.env.REACT_APP_SERVER_ACCOUNT_ADDRESS || '',
27
+ },
28
+ });
29
+ //# sourceMappingURL=config.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA,wCAAwC;AACxC,EAAE;AACF,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,iDAAiD;AACjD,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AACjC,OAAO,EAAE,yBAAyB,EAAE,MAAM,gBAAgB,CAAA;AAE1D,MAAM,CAAC,MAAM,eAAe,GAAG,GAAG,EAAE,CAChC,yBAAyB,CAAC,KAAK,CAAC;IAC5B,kBAAkB,EAAE,OAAO,CAAC,GAAG,CAAC,mBAAmB;IACnD,cAAc,EAAE,OAAO,CAAC,GAAG,CAAC,eAAe;IAC3C,SAAS;IACL,gDAAgD;IAChD,OAAO,CAAC,GAAG,CAAC,oBAAoB,IAAI,OAAO,CAAC,GAAG,CAAC,qBAAqB;QACjE,CAAC,CAAC,GAAG,OAAO,CAAC,GAAG,CAAC,oBAAoB,IAAI,OAAO,CAAC,GAAG,CAAC,qBAAqB,EAAE;QAC5E,CAAC,CAAC,uBAAuB;IACjC,QAAQ,EAAE,OAAO,CAAC,GAAG,CAAC,mBAAmB,IAAI,uBAAuB;IACpE,OAAO,EAAE;QACL,QAAQ,EAAE,EAAE;QACZ,OAAO,EAAE,OAAO,CAAC,GAAG,CAAC,gCAAgC,IAAI,EAAE;KAC9D;CACJ,CAAC,CAAA"}
package/dist/index.d.ts CHANGED
@@ -1,35 +1,6 @@
1
- import { ApiPromise } from '@polkadot/api';
2
- import { ContractAbi, NetworkConfig, ProsopoServerConfig } from '@prosopo/types';
3
- import { Keyring } from '@polkadot/keyring';
4
- import { KeyringPair } from '@polkadot/keyring/types';
5
- import { Logger } from '@prosopo/common';
6
- import { ProcaptchaOutput } from '@prosopo/types';
7
- import { ProsopoCaptchaContract } from '@prosopo/contract';
8
- import { ProviderApi } from '@prosopo/api';
9
- import { PublicAccountNetwork } from './publicProsopoPair.js';
10
- import { WsProvider } from '@polkadot/rpc-provider';
11
- export declare class ProsopoServer {
12
- config: ProsopoServerConfig;
13
- contract: ProsopoCaptchaContract | undefined;
14
- prosopoContractAddress: string;
15
- dappContractAddress: string;
16
- defaultEnvironment: string;
17
- contractName: string;
18
- abi: ContractAbi;
19
- logger: Logger;
20
- wsProvider: WsProvider;
21
- keyring: Keyring;
22
- pair: KeyringPair;
23
- api: ApiPromise | undefined;
24
- network: NetworkConfig;
25
- constructor(pair: KeyringPair, config: ProsopoServerConfig);
26
- getProviderApi(providerUrl: string): Promise<ProviderApi>;
27
- isReady(): Promise<void>;
28
- getSigner(): Promise<void>;
29
- getApi(): ApiPromise;
30
- getContract(): ProsopoCaptchaContract;
31
- isVerified(payload: ProcaptchaOutput): Promise<boolean>;
32
- getContractApi(): Promise<ProsopoCaptchaContract>;
33
- }
34
- export declare const PublicProsopoServer: (config: ProsopoServerConfig, publicAccountNetwork: PublicAccountNetwork) => Promise<ProsopoServer>;
1
+ import { ProsopoServer } from './server.js';
2
+ export { ProsopoServer } from './server.js';
3
+ export { getServerConfig } from './config.js';
4
+ import { ProsopoServerConfigOutput } from '@prosopo/types';
5
+ export declare const PublicProsopoServer: (config: ProsopoServerConfigOutput) => Promise<ProsopoServer>;
35
6
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAA;AAE1C,OAAO,EAAE,WAAW,EAAE,aAAa,EAAsB,mBAAmB,EAAE,MAAM,gBAAgB,CAAA;AACpG,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAA;AAC3C,OAAO,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAA;AACrD,OAAO,EAAY,MAAM,EAAa,MAAM,iBAAiB,CAAA;AAC7D,OAAO,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAA;AACjD,OAAO,EAAE,sBAAsB,EAAE,MAAM,mBAAmB,CAAA;AAE1D,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAA;AAC1C,OAAO,EAAE,oBAAoB,EAAwB,MAAM,wBAAwB,CAAA;AAEnF,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAA;AAGnD,qBAAa,aAAa;IACtB,MAAM,EAAE,mBAAmB,CAAA;IAC3B,QAAQ,EAAE,sBAAsB,GAAG,SAAS,CAAA;IAC5C,sBAAsB,EAAE,MAAM,CAAA;IAC9B,mBAAmB,EAAE,MAAM,CAAA;IAC3B,kBAAkB,EAAE,MAAM,CAAA;IAC1B,YAAY,EAAE,MAAM,CAAA;IACpB,GAAG,EAAE,WAAW,CAAA;IAChB,MAAM,EAAE,MAAM,CAAA;IACd,UAAU,EAAE,UAAU,CAAA;IACtB,OAAO,EAAE,OAAO,CAAA;IAChB,IAAI,EAAE,WAAW,CAAA;IACjB,GAAG,EAAE,UAAU,GAAG,SAAS,CAAA;IAC3B,OAAO,EAAE,aAAa,CAAA;gBAEV,IAAI,EAAE,WAAW,EAAE,MAAM,EAAE,mBAAmB;IA6B7C,cAAc,CAAC,WAAW,EAAE,MAAM;IAIzC,OAAO;IAUP,SAAS,IAAI,OAAO,CAAC,IAAI,CAAC;IAYhC,MAAM,IAAI,UAAU;IAOpB,WAAW,IAAI,sBAAsB;IAOxB,UAAU,CAAC,OAAO,EAAE,gBAAgB,GAAG,OAAO,CAAC,OAAO,CAAC;IAyBvD,cAAc,IAAI,OAAO,CAAC,sBAAsB,CAAC;CAWjE;AAED,eAAO,MAAM,mBAAmB,WAAkB,mBAAmB,wBAAwB,oBAAoB,2BAIhH,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAA;AAC3C,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAA;AAC3C,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAA;AAC7C,OAAO,EAAE,yBAAyB,EAAE,MAAM,gBAAgB,CAAA;AAE1D,eAAO,MAAM,mBAAmB,WAAkB,yBAAyB,2BAI1E,CAAA"}
package/dist/index.js CHANGED
@@ -1,115 +1,10 @@
1
- // Copyright 2021-2023 Prosopo (UK) Ltd.
2
- //
3
- // Licensed under the Apache License, Version 2.0 (the "License");
4
- // you may not use this file except in compliance with the License.
5
- // You may obtain a copy of the License at
6
- //
7
- // http://www.apache.org/licenses/LICENSE-2.0
8
- //
9
- // Unless required by applicable law or agreed to in writing, software
10
- // distributed under the License is distributed on an "AS IS" BASIS,
11
- // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
- // See the License for the specific language governing permissions and
13
- // limitations under the License.
14
- import { ApiPromise } from '@polkadot/api';
15
- import { NetworkNamesSchema } from '@prosopo/types';
16
- import { Keyring } from '@polkadot/keyring';
17
- import { getLogger } from '@prosopo/common';
18
- import { ProsopoCaptchaContract } from '@prosopo/contract';
19
- import { ProsopoEnvError, trimProviderUrl } from '@prosopo/common';
20
- import { ProviderApi } from '@prosopo/api';
21
- import { getPublicProsopoPair } from './publicProsopoPair.js';
22
- import { ContractAbi as abiJson } from '@prosopo/captcha-contract';
23
- import { WsProvider } from '@polkadot/rpc-provider';
24
- import { get } from '@prosopo/util';
25
- export class ProsopoServer {
26
- constructor(pair, config) {
27
- this.config = config;
28
- this.pair = pair;
29
- if (this.config.defaultEnvironment &&
30
- Object.prototype.hasOwnProperty.call(this.config.networks, this.config.defaultEnvironment)) {
31
- this.defaultEnvironment = this.config.defaultEnvironment;
32
- const networkName = NetworkNamesSchema.parse(this.defaultEnvironment);
33
- this.network = get(this.config.networks, networkName);
34
- this.wsProvider = new WsProvider(this.network.endpoint);
35
- this.prosopoContractAddress = this.network.contract.address;
36
- this.dappContractAddress = this.config.account.address;
37
- this.contractName = this.network.contract.name;
38
- this.logger = getLogger(this.config.logLevel, '@prosopo/server');
39
- this.keyring = new Keyring({
40
- type: 'sr25519', // TODO get this from the chain
41
- });
42
- this.abi = JSON.parse(abiJson);
43
- }
44
- else {
45
- throw new ProsopoEnvError('CONFIG.UNKNOWN_ENVIRONMENT', this.constructor.name, {}, this.config.defaultEnvironment);
46
- }
47
- }
48
- async getProviderApi(providerUrl) {
49
- return new ProviderApi(this.network, providerUrl, this.config.account.address);
50
- }
51
- async isReady() {
52
- try {
53
- this.api = await ApiPromise.create({ provider: this.wsProvider });
54
- await this.getSigner();
55
- await this.getContractApi();
56
- }
57
- catch (err) {
58
- throw new ProsopoEnvError(err, 'GENERAL.ENVIRONMENT_NOT_READY');
59
- }
60
- }
61
- async getSigner() {
62
- if (!this.api) {
63
- this.api = await ApiPromise.create({ provider: this.wsProvider });
64
- }
65
- await this.api.isReadyOrError;
66
- try {
67
- this.pair = this.keyring.addPair(this.pair);
68
- }
69
- catch (err) {
70
- throw new ProsopoEnvError('CONTRACT.SIGNER_UNDEFINED', this.getSigner.name, {}, err);
71
- }
72
- }
73
- getApi() {
74
- if (this.api === undefined) {
75
- throw new ProsopoEnvError(new Error('api undefined'));
76
- }
77
- return this.api;
78
- }
79
- getContract() {
80
- if (this.contract === undefined) {
81
- throw new ProsopoEnvError(new Error('contract undefined'));
82
- }
83
- return this.contract;
84
- }
85
- async isVerified(payload) {
86
- const { user, dapp, providerUrl, commitmentId, blockNumber } = payload;
87
- // first check if the provider was actually chosen at blockNumber
88
- const contractApi = await this.getContractApi();
89
- const block = (await this.getApi().rpc.chain.getBlockHash(blockNumber));
90
- const getRandomProviderResponse = await this.getContract().queryAtBlock(block, 'getRandomActiveProvider', [user, dapp]);
91
- const providerUrlTrimmed = trimProviderUrl(getRandomProviderResponse.provider.url.toString());
92
- if (providerUrlTrimmed !== providerUrl) {
93
- return false;
94
- }
95
- if (providerUrlTrimmed && commitmentId) {
96
- const providerApi = await this.getProviderApi(providerUrl);
97
- const result = await providerApi.verifyDappUser(user, commitmentId);
98
- return result.solutionApproved;
99
- }
100
- else {
101
- return (await contractApi.query.dappOperatorIsHumanUser(user, this.config.solutionThreshold)).value
102
- .unwrap()
103
- .unwrap();
104
- }
105
- }
106
- async getContractApi() {
107
- this.contract = new ProsopoCaptchaContract(this.getApi(), this.abi, this.prosopoContractAddress, this.pair, this.contractName, 0);
108
- return this.contract;
109
- }
110
- }
111
- export const PublicProsopoServer = async (config, publicAccountNetwork) => {
112
- const publicProsopoPair = await getPublicProsopoPair(publicAccountNetwork);
113
- return new ProsopoServer(publicProsopoPair, config);
1
+ import { ProsopoServer } from './server.js';
2
+ export { ProsopoServer } from './server.js';
3
+ export { getServerConfig } from './config.js';
4
+ import { getPairAsync } from '@prosopo/contract';
5
+ export const PublicProsopoServer = async (config) => {
6
+ // if site key is '' then it will burn address
7
+ const pair = await getPairAsync(config.networks[config.defaultNetwork], undefined, config.account.address);
8
+ return new ProsopoServer(config, pair);
114
9
  };
115
10
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,wCAAwC;AACxC,EAAE;AACF,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,iDAAiD;AACjD,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AACjC,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAA;AAE1C,OAAO,EAA8B,kBAAkB,EAAuB,MAAM,gBAAgB,CAAA;AACpG,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAA;AAE3C,OAAO,EAAoB,SAAS,EAAE,MAAM,iBAAiB,CAAA;AAE7D,OAAO,EAAE,sBAAsB,EAAE,MAAM,mBAAmB,CAAA;AAC1D,OAAO,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAA;AAClE,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAA;AAC1C,OAAO,EAAwB,oBAAoB,EAAE,MAAM,wBAAwB,CAAA;AACnF,OAAO,EAAkB,WAAW,IAAI,OAAO,EAAE,MAAM,2BAA2B,CAAA;AAClF,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAA;AACnD,OAAO,EAAE,GAAG,EAAE,MAAM,eAAe,CAAA;AAEnC,MAAM,OAAO,aAAa;IAetB,YAAY,IAAiB,EAAE,MAA2B;QACtD,IAAI,CAAC,MAAM,GAAG,MAAM,CAAA;QACpB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAA;QAChB,IACI,IAAI,CAAC,MAAM,CAAC,kBAAkB;YAC9B,MAAM,CAAC,SAAS,CAAC,cAAc,CAAC,IAAI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,CAAC,GAAG,EACR,IAAI,CAAC,sBAAsB,EAC3B,IAAI,CAAC,IAAI,EACT,IAAI,CAAC,YAAY,EACjB,CAAC,CACJ,CAAA;QACD,OAAO,IAAI,CAAC,QAAQ,CAAA;IACxB,CAAC;CACJ;AAED,MAAM,CAAC,MAAM,mBAAmB,GAAG,KAAK,EAAE,MAA2B,EAAE,oBAA0C,EAAE,EAAE;IACjH,MAAM,iBAAiB,GAAG,MAAM,oBAAoB,CAAC,oBAAoB,CAAC,CAAA;IAE1E,OAAO,IAAI,aAAa,CAAC,iBAAiB,EAAE,MAAM,CAAC,CAAA;AACvD,CAAC,CAAA"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAA;AAC3C,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAA;AAC3C,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAA;AAE7C,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAA;AAChD,MAAM,CAAC,MAAM,mBAAmB,GAAG,KAAK,EAAE,MAAiC,EAAE,EAAE;IAC3E,8CAA8C;IAC9C,MAAM,IAAI,GAAG,MAAM,YAAY,CAAC,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,cAAc,CAAC,EAAE,SAAS,EAAE,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,CAAA;IAC1G,OAAO,IAAI,aAAa,CAAC,MAAM,EAAE,IAAI,CAAC,CAAA;AAC1C,CAAC,CAAA"}
@@ -0,0 +1,33 @@
1
+ import { ApiPromise } from '@polkadot/api';
2
+ import { ContractAbi, NetworkConfig, ProsopoServerConfigOutput } from '@prosopo/types';
3
+ import { Keyring } from '@polkadot/keyring';
4
+ import { KeyringPair } from '@polkadot/keyring/types';
5
+ import { Logger } from '@prosopo/common';
6
+ import { ProcaptchaOutput } from '@prosopo/types';
7
+ import { ProsopoCaptchaContract } from '@prosopo/contract';
8
+ import { ProviderApi } from '@prosopo/api';
9
+ import { WsProvider } from '@polkadot/rpc-provider';
10
+ export declare class ProsopoServer {
11
+ config: ProsopoServerConfigOutput;
12
+ contract: ProsopoCaptchaContract | undefined;
13
+ prosopoContractAddress: string;
14
+ dappContractAddress: string;
15
+ defaultEnvironment: string;
16
+ contractName: string;
17
+ abi: ContractAbi;
18
+ logger: Logger;
19
+ wsProvider: WsProvider;
20
+ keyring: Keyring;
21
+ pair: KeyringPair | undefined;
22
+ api: ApiPromise | undefined;
23
+ network: NetworkConfig;
24
+ constructor(config: ProsopoServerConfigOutput, pair?: KeyringPair);
25
+ getProviderApi(providerUrl: string): Promise<ProviderApi>;
26
+ isReady(): Promise<void>;
27
+ getSigner(): Promise<void>;
28
+ getApi(): ApiPromise;
29
+ getContract(): ProsopoCaptchaContract;
30
+ isVerified(payload: ProcaptchaOutput): Promise<boolean>;
31
+ getContractApi(): Promise<ProsopoCaptchaContract>;
32
+ }
33
+ //# sourceMappingURL=server.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAA;AAE1C,OAAO,EAAE,WAAW,EAAE,aAAa,EAAsB,yBAAyB,EAAE,MAAM,gBAAgB,CAAA;AAC1G,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAA;AAC3C,OAAO,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAA;AACrD,OAAO,EAAY,MAAM,EAAa,MAAM,iBAAiB,CAAA;AAC7D,OAAO,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAA;AACjD,OAAO,EAAE,sBAAsB,EAAkB,MAAM,mBAAmB,CAAA;AAE1E,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAA;AAE1C,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAA;AAGnD,qBAAa,aAAa;IACtB,MAAM,EAAE,yBAAyB,CAAA;IACjC,QAAQ,EAAE,sBAAsB,GAAG,SAAS,CAAA;IAC5C,sBAAsB,EAAE,MAAM,CAAA;IAC9B,mBAAmB,EAAE,MAAM,CAAA;IAC3B,kBAAkB,EAAE,MAAM,CAAA;IAC1B,YAAY,EAAE,MAAM,CAAA;IACpB,GAAG,EAAE,WAAW,CAAA;IAChB,MAAM,EAAE,MAAM,CAAA;IACd,UAAU,EAAE,UAAU,CAAA;IACtB,OAAO,EAAE,OAAO,CAAA;IAChB,IAAI,EAAE,WAAW,GAAG,SAAS,CAAA;IAC7B,GAAG,EAAE,UAAU,GAAG,SAAS,CAAA;IAC3B,OAAO,EAAE,aAAa,CAAA;gBAEV,MAAM,EAAE,yBAAyB,EAAE,IAAI,CAAC,EAAE,WAAW;IA6BpD,cAAc,CAAC,WAAW,EAAE,MAAM;IAIzC,OAAO;IAUP,SAAS,IAAI,OAAO,CAAC,IAAI,CAAC;IAchC,MAAM,IAAI,UAAU;IAOpB,WAAW,IAAI,sBAAsB;IAOxB,UAAU,CAAC,OAAO,EAAE,gBAAgB,GAAG,OAAO,CAAC,OAAO,CAAC;IA2BvD,cAAc,IAAI,OAAO,CAAC,sBAAsB,CAAC;CAWjE"}
package/dist/server.js ADDED
@@ -0,0 +1,114 @@
1
+ // Copyright 2021-2023 Prosopo (UK) Ltd.
2
+ //
3
+ // Licensed under the Apache License, Version 2.0 (the "License");
4
+ // you may not use this file except in compliance with the License.
5
+ // You may obtain a copy of the License at
6
+ //
7
+ // http://www.apache.org/licenses/LICENSE-2.0
8
+ //
9
+ // Unless required by applicable law or agreed to in writing, software
10
+ // distributed under the License is distributed on an "AS IS" BASIS,
11
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ // See the License for the specific language governing permissions and
13
+ // limitations under the License.
14
+ import { ApiPromise } from '@polkadot/api';
15
+ import { NetworkNamesSchema } from '@prosopo/types';
16
+ import { Keyring } from '@polkadot/keyring';
17
+ import { getLogger } from '@prosopo/common';
18
+ import { ProsopoCaptchaContract, getZeroAddress } from '@prosopo/contract';
19
+ import { ProsopoEnvError, trimProviderUrl } from '@prosopo/common';
20
+ import { ProviderApi } from '@prosopo/api';
21
+ import { ContractAbi as abiJson } from '@prosopo/captcha-contract';
22
+ import { WsProvider } from '@polkadot/rpc-provider';
23
+ import { get } from '@prosopo/util';
24
+ export class ProsopoServer {
25
+ constructor(config, pair) {
26
+ this.config = config;
27
+ this.pair = pair;
28
+ if (this.config.defaultEnvironment &&
29
+ Object.prototype.hasOwnProperty.call(this.config.networks, this.config.defaultEnvironment)) {
30
+ this.defaultEnvironment = this.config.defaultEnvironment;
31
+ const networkName = NetworkNamesSchema.parse(this.config.defaultNetwork);
32
+ this.network = get(this.config.networks, networkName);
33
+ this.wsProvider = new WsProvider(this.network.endpoint);
34
+ this.prosopoContractAddress = this.network.contract.address;
35
+ this.dappContractAddress = this.config.account.address || getZeroAddress().toString();
36
+ this.contractName = this.network.contract.name;
37
+ this.logger = getLogger(this.config.logLevel, '@prosopo/server');
38
+ this.keyring = new Keyring({
39
+ type: 'sr25519', // TODO get this from the chain
40
+ });
41
+ this.abi = JSON.parse(abiJson);
42
+ }
43
+ else {
44
+ throw new ProsopoEnvError('CONFIG.UNKNOWN_ENVIRONMENT', this.constructor.name, {}, this.config.defaultEnvironment);
45
+ }
46
+ }
47
+ async getProviderApi(providerUrl) {
48
+ return new ProviderApi(this.network, providerUrl, this.dappContractAddress);
49
+ }
50
+ async isReady() {
51
+ try {
52
+ this.api = await ApiPromise.create({ provider: this.wsProvider });
53
+ await this.getSigner();
54
+ await this.getContractApi();
55
+ }
56
+ catch (err) {
57
+ throw new ProsopoEnvError(err, 'GENERAL.ENVIRONMENT_NOT_READY');
58
+ }
59
+ }
60
+ async getSigner() {
61
+ if (this.pair) {
62
+ if (!this.api) {
63
+ this.api = await ApiPromise.create({ provider: this.wsProvider });
64
+ }
65
+ await this.api.isReadyOrError;
66
+ try {
67
+ this.pair = this.keyring.addPair(this.pair);
68
+ }
69
+ catch (err) {
70
+ throw new ProsopoEnvError('CONTRACT.SIGNER_UNDEFINED', this.getSigner.name, {}, err);
71
+ }
72
+ }
73
+ }
74
+ getApi() {
75
+ if (this.api === undefined) {
76
+ throw new ProsopoEnvError(new Error('api undefined'));
77
+ }
78
+ return this.api;
79
+ }
80
+ getContract() {
81
+ if (this.contract === undefined) {
82
+ throw new ProsopoEnvError(new Error('contract undefined'));
83
+ }
84
+ return this.contract;
85
+ }
86
+ async isVerified(payload) {
87
+ const { user, dapp, providerUrl, commitmentId, blockNumber } = payload;
88
+ // first check if the provider was actually chosen at blockNumber
89
+ const contractApi = await this.getContractApi();
90
+ const block = (await this.getApi().rpc.chain.getBlockHash(blockNumber));
91
+ const getRandomProviderResponse = await this.getContract().queryAtBlock(block, 'getRandomActiveProvider', [user, dapp]);
92
+ const providerUrlTrimmed = trimProviderUrl(getRandomProviderResponse.provider.url.toString());
93
+ if (providerUrlTrimmed !== providerUrl) {
94
+ return false;
95
+ }
96
+ console.log('providerUrlTrimmed', providerUrlTrimmed, 'commitmentId', commitmentId);
97
+ if (providerUrlTrimmed && commitmentId) {
98
+ const providerApi = await this.getProviderApi(providerUrl);
99
+ const result = await providerApi.verifyDappUser(user, commitmentId);
100
+ console.log(result);
101
+ return result.solutionApproved;
102
+ }
103
+ else {
104
+ return (await contractApi.query.dappOperatorIsHumanUser(user, this.config.solutionThreshold)).value
105
+ .unwrap()
106
+ .unwrap();
107
+ }
108
+ }
109
+ async getContractApi() {
110
+ this.contract = new ProsopoCaptchaContract(this.getApi(), this.abi, this.prosopoContractAddress, this.contractName, 0, this.pair);
111
+ return this.contract;
112
+ }
113
+ }
114
+ //# sourceMappingURL=server.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"server.js","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":"AAAA,wCAAwC;AACxC,EAAE;AACF,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1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