@prosopo/load-balancer 2.6.17 → 2.8.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.
- package/CHANGELOG.md +258 -0
- package/README.md +49 -0
- package/coverage/balancer.ts.html +280 -0
- package/coverage/base.css +224 -0
- package/coverage/block-navigation.js +87 -0
- package/coverage/clover.xml +82 -0
- package/coverage/coverage-final.json +4 -0
- package/coverage/favicon.png +0 -0
- package/coverage/index.html +146 -0
- package/coverage/index.ts.html +130 -0
- package/coverage/prettify.css +1 -0
- package/coverage/prettify.js +2 -0
- package/coverage/providers.ts.html +220 -0
- package/coverage/sort-arrow-sprite.png +0 -0
- package/coverage/sorter.js +210 -0
- package/dist/balancer.d.ts +25 -0
- package/dist/balancer.d.ts.map +1 -0
- package/dist/balancer.js +53 -0
- package/dist/balancer.js.map +1 -0
- package/dist/cjs/balancer.cjs +53 -0
- package/dist/cjs/index.cjs +8 -36
- package/dist/cjs/providers.cjs +43 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +8 -36
- package/dist/index.js.map +1 -0
- package/dist/providers.d.ts +6 -0
- package/dist/providers.d.ts.map +1 -0
- package/dist/providers.js +43 -0
- package/dist/providers.js.map +1 -0
- package/dist/tests/providers.unit.test.d.ts +2 -0
- package/dist/tests/providers.unit.test.d.ts.map +1 -0
- package/dist/tests/providers.unit.test.js +224 -0
- package/dist/tests/providers.unit.test.js.map +1 -0
- package/package.json +14 -16
- package/vite.test.config.ts +33 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,263 @@
|
|
|
1
1
|
# @prosopo/load-balancer
|
|
2
2
|
|
|
3
|
+
## 2.8.8
|
|
4
|
+
### Patch Changes
|
|
5
|
+
|
|
6
|
+
- Updated dependencies [8f1773a]
|
|
7
|
+
- @prosopo/types@3.5.11
|
|
8
|
+
|
|
9
|
+
## 2.8.7
|
|
10
|
+
### Patch Changes
|
|
11
|
+
|
|
12
|
+
- Updated dependencies [cb8ab85]
|
|
13
|
+
- @prosopo/types@3.5.10
|
|
14
|
+
|
|
15
|
+
## 2.8.6
|
|
16
|
+
### Patch Changes
|
|
17
|
+
|
|
18
|
+
- 005ce66: Split load balancer into URL fn and getter fn for private repo
|
|
19
|
+
- b58046d: Export fn
|
|
20
|
+
|
|
21
|
+
#Please enter a summary for your changes.
|
|
22
|
+
- Updated dependencies [43907e8]
|
|
23
|
+
- Updated dependencies [7101036]
|
|
24
|
+
- @prosopo/types@3.5.9
|
|
25
|
+
|
|
26
|
+
## 2.8.5
|
|
27
|
+
### Patch Changes
|
|
28
|
+
|
|
29
|
+
- Updated dependencies [e5c259d]
|
|
30
|
+
- @prosopo/types@3.5.8
|
|
31
|
+
|
|
32
|
+
## 2.8.4
|
|
33
|
+
### Patch Changes
|
|
34
|
+
|
|
35
|
+
- Updated dependencies [c9d8fdf]
|
|
36
|
+
- Updated dependencies [b8185a4]
|
|
37
|
+
- @prosopo/common@3.1.21
|
|
38
|
+
- @prosopo/config@3.1.21
|
|
39
|
+
- @prosopo/types@3.5.7
|
|
40
|
+
|
|
41
|
+
## 2.8.3
|
|
42
|
+
### Patch Changes
|
|
43
|
+
|
|
44
|
+
- Updated dependencies [5d11a81]
|
|
45
|
+
- @prosopo/types@3.5.6
|
|
46
|
+
|
|
47
|
+
## 2.8.2
|
|
48
|
+
### Patch Changes
|
|
49
|
+
|
|
50
|
+
- Updated dependencies [494c5a8]
|
|
51
|
+
- @prosopo/types@3.5.5
|
|
52
|
+
|
|
53
|
+
## 2.8.1
|
|
54
|
+
### Patch Changes
|
|
55
|
+
|
|
56
|
+
- Updated dependencies [08ff50f]
|
|
57
|
+
- @prosopo/types@3.5.4
|
|
58
|
+
|
|
59
|
+
## 2.8.0
|
|
60
|
+
### Minor Changes
|
|
61
|
+
|
|
62
|
+
- 04d0f1a: weighted random provider selection
|
|
63
|
+
|
|
64
|
+
### Patch Changes
|
|
65
|
+
|
|
66
|
+
- Updated dependencies [1e3a838]
|
|
67
|
+
- @prosopo/config@3.1.20
|
|
68
|
+
- @prosopo/common@3.1.20
|
|
69
|
+
- @prosopo/types@3.5.3
|
|
70
|
+
|
|
71
|
+
## 2.7.12
|
|
72
|
+
### Patch Changes
|
|
73
|
+
|
|
74
|
+
- 5659b24: Release 3.4.4
|
|
75
|
+
- Updated dependencies [f912439]
|
|
76
|
+
- Updated dependencies [5659b24]
|
|
77
|
+
- @prosopo/common@3.1.19
|
|
78
|
+
- @prosopo/types@3.5.2
|
|
79
|
+
- @prosopo/util@3.1.4
|
|
80
|
+
- @prosopo/config@3.1.19
|
|
81
|
+
|
|
82
|
+
## 2.7.11
|
|
83
|
+
### Patch Changes
|
|
84
|
+
|
|
85
|
+
- 50c4120: Release 3.4.3
|
|
86
|
+
- Updated dependencies [52cd544]
|
|
87
|
+
- Updated dependencies [b117ba3]
|
|
88
|
+
- Updated dependencies [50c4120]
|
|
89
|
+
- @prosopo/types@3.5.1
|
|
90
|
+
- @prosopo/common@3.1.18
|
|
91
|
+
- @prosopo/util@3.1.3
|
|
92
|
+
- @prosopo/config@3.1.18
|
|
93
|
+
|
|
94
|
+
## 2.7.10
|
|
95
|
+
### Patch Changes
|
|
96
|
+
|
|
97
|
+
- 618703f: Release 3.4.2
|
|
98
|
+
- Updated dependencies [618703f]
|
|
99
|
+
- Updated dependencies [e20ad6b]
|
|
100
|
+
- @prosopo/common@3.1.17
|
|
101
|
+
- @prosopo/types@3.5.0
|
|
102
|
+
- @prosopo/util@3.1.2
|
|
103
|
+
- @prosopo/config@3.1.17
|
|
104
|
+
|
|
105
|
+
## 2.7.9
|
|
106
|
+
### Patch Changes
|
|
107
|
+
|
|
108
|
+
- 11303d9: Release 3.4.0
|
|
109
|
+
- 18cb28b: Release 3.4.1
|
|
110
|
+
- Updated dependencies [11303d9]
|
|
111
|
+
- Updated dependencies [18cb28b]
|
|
112
|
+
- Updated dependencies [11303d9]
|
|
113
|
+
- @prosopo/common@3.1.16
|
|
114
|
+
- @prosopo/types@3.4.1
|
|
115
|
+
- @prosopo/util@3.1.1
|
|
116
|
+
- @prosopo/config@3.1.16
|
|
117
|
+
|
|
118
|
+
## 2.7.8
|
|
119
|
+
### Patch Changes
|
|
120
|
+
|
|
121
|
+
- f3f7aec: Release 3.4.0
|
|
122
|
+
- Updated dependencies [f3f7aec]
|
|
123
|
+
- Updated dependencies [6768f14]
|
|
124
|
+
- @prosopo/common@3.1.15
|
|
125
|
+
- @prosopo/types@3.4.0
|
|
126
|
+
- @prosopo/util@3.1.0
|
|
127
|
+
- @prosopo/config@3.1.15
|
|
128
|
+
|
|
129
|
+
## 2.7.7
|
|
130
|
+
### Patch Changes
|
|
131
|
+
|
|
132
|
+
- Release 3.3.1
|
|
133
|
+
- 0824221: Release 3.2.4
|
|
134
|
+
- Updated dependencies [97edf3f]
|
|
135
|
+
- Updated dependencies
|
|
136
|
+
- Updated dependencies [0824221]
|
|
137
|
+
- @prosopo/types@3.3.0
|
|
138
|
+
- @prosopo/common@3.1.14
|
|
139
|
+
- @prosopo/util@3.0.17
|
|
140
|
+
- @prosopo/config@3.1.14
|
|
141
|
+
|
|
142
|
+
## 2.7.6
|
|
143
|
+
### Patch Changes
|
|
144
|
+
|
|
145
|
+
- 008d112: Release 3.3.0
|
|
146
|
+
- Updated dependencies [509be28]
|
|
147
|
+
- Updated dependencies [008d112]
|
|
148
|
+
- @prosopo/types@3.2.1
|
|
149
|
+
- @prosopo/common@3.1.13
|
|
150
|
+
- @prosopo/util@3.0.16
|
|
151
|
+
- @prosopo/config@3.1.13
|
|
152
|
+
|
|
153
|
+
## 2.7.5
|
|
154
|
+
### Patch Changes
|
|
155
|
+
|
|
156
|
+
- 0824221: Release 3.2.4
|
|
157
|
+
- Updated dependencies [cf48565]
|
|
158
|
+
- Updated dependencies [0824221]
|
|
159
|
+
- @prosopo/types@3.2.0
|
|
160
|
+
- @prosopo/common@3.1.12
|
|
161
|
+
- @prosopo/util@3.0.15
|
|
162
|
+
- @prosopo/config@3.1.12
|
|
163
|
+
|
|
164
|
+
## 2.7.4
|
|
165
|
+
### Patch Changes
|
|
166
|
+
|
|
167
|
+
- 1a23649: Release 3.2.3
|
|
168
|
+
- Updated dependencies [0d1a33e]
|
|
169
|
+
- Updated dependencies [0d1a33e]
|
|
170
|
+
- Updated dependencies [1a23649]
|
|
171
|
+
- @prosopo/types@3.1.4
|
|
172
|
+
- @prosopo/common@3.1.11
|
|
173
|
+
- @prosopo/util@3.0.14
|
|
174
|
+
- @prosopo/config@3.1.11
|
|
175
|
+
|
|
176
|
+
## 2.7.3
|
|
177
|
+
### Patch Changes
|
|
178
|
+
|
|
179
|
+
- 657a827: Release 3.2.2
|
|
180
|
+
- Updated dependencies [657a827]
|
|
181
|
+
- @prosopo/common@3.1.10
|
|
182
|
+
- @prosopo/types@3.1.3
|
|
183
|
+
- @prosopo/util@3.0.13
|
|
184
|
+
- @prosopo/config@3.1.10
|
|
185
|
+
|
|
186
|
+
## 2.7.2
|
|
187
|
+
### Patch Changes
|
|
188
|
+
|
|
189
|
+
- 4440947: fix type-only tsc compilation
|
|
190
|
+
- 7bdaca6: Release 3.2.1
|
|
191
|
+
- Updated dependencies [4440947]
|
|
192
|
+
- Updated dependencies [7bdaca6]
|
|
193
|
+
- Updated dependencies [809b984]
|
|
194
|
+
- Updated dependencies [1249ce0]
|
|
195
|
+
- Updated dependencies [809b984]
|
|
196
|
+
- @prosopo/common@3.1.9
|
|
197
|
+
- @prosopo/types@3.1.2
|
|
198
|
+
- @prosopo/util@3.0.12
|
|
199
|
+
- @prosopo/config@3.1.9
|
|
200
|
+
|
|
201
|
+
## 2.7.1
|
|
202
|
+
### Patch Changes
|
|
203
|
+
|
|
204
|
+
- 1f980c4: Fix types mismatch in decryption
|
|
205
|
+
- 6fe8570: Release 3.2.0
|
|
206
|
+
- Updated dependencies [1f980c4]
|
|
207
|
+
- Updated dependencies [6fe8570]
|
|
208
|
+
- @prosopo/types@3.1.1
|
|
209
|
+
- @prosopo/common@3.1.8
|
|
210
|
+
- @prosopo/util@3.0.11
|
|
211
|
+
- @prosopo/config@3.1.8
|
|
212
|
+
|
|
213
|
+
## 2.7.0
|
|
214
|
+
### Minor Changes
|
|
215
|
+
|
|
216
|
+
- 8bdc7f0: Using detector to select provider
|
|
217
|
+
|
|
218
|
+
### Patch Changes
|
|
219
|
+
|
|
220
|
+
- f304be9: Release 3.1.13
|
|
221
|
+
- Updated dependencies [f304be9]
|
|
222
|
+
- Updated dependencies [8bdc7f0]
|
|
223
|
+
- @prosopo/common@3.1.7
|
|
224
|
+
- @prosopo/types@3.1.0
|
|
225
|
+
- @prosopo/util@3.0.10
|
|
226
|
+
- @prosopo/config@3.1.7
|
|
227
|
+
|
|
228
|
+
## 2.6.21
|
|
229
|
+
### Patch Changes
|
|
230
|
+
|
|
231
|
+
- Updated dependencies [9eed772]
|
|
232
|
+
- @prosopo/config@3.1.6
|
|
233
|
+
- @prosopo/common@3.1.6
|
|
234
|
+
- @prosopo/types@3.0.10
|
|
235
|
+
|
|
236
|
+
## 2.6.20
|
|
237
|
+
### Patch Changes
|
|
238
|
+
|
|
239
|
+
- 6960643: lint detect missing and unneccessary imports
|
|
240
|
+
- Updated dependencies [6960643]
|
|
241
|
+
- @prosopo/common@3.1.5
|
|
242
|
+
- @prosopo/types@3.0.9
|
|
243
|
+
|
|
244
|
+
## 2.6.19
|
|
245
|
+
### Patch Changes
|
|
246
|
+
|
|
247
|
+
- Updated dependencies [30e7d4d]
|
|
248
|
+
- @prosopo/config@3.1.5
|
|
249
|
+
- @prosopo/common@3.1.4
|
|
250
|
+
- @prosopo/types@3.0.8
|
|
251
|
+
|
|
252
|
+
## 2.6.18
|
|
253
|
+
### Patch Changes
|
|
254
|
+
|
|
255
|
+
- Updated dependencies [44ffda2]
|
|
256
|
+
- Updated dependencies [a49b538]
|
|
257
|
+
- @prosopo/config@3.1.4
|
|
258
|
+
- @prosopo/common@3.1.3
|
|
259
|
+
- @prosopo/types@3.0.7
|
|
260
|
+
|
|
3
261
|
## 2.6.17
|
|
4
262
|
### Patch Changes
|
|
5
263
|
|
package/README.md
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
# @prosopo/load-balancer
|
|
2
|
+
|
|
3
|
+
Provider load balancer for Procaptcha
|
|
4
|
+
|
|
5
|
+
## Provider Selection Config
|
|
6
|
+
|
|
7
|
+
Each provider in the json has the following properties:
|
|
8
|
+
|
|
9
|
+
```typescript
|
|
10
|
+
{
|
|
11
|
+
address: string; // Provider account address
|
|
12
|
+
url: string; // Provider API endpoint
|
|
13
|
+
datasetId: string; // Dataset identifier
|
|
14
|
+
weight?: number; // Optional weight (1-100, defaults to 1)
|
|
15
|
+
}
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
### Weight Field
|
|
19
|
+
|
|
20
|
+
The `weight` field controls how often a provider is selected:
|
|
21
|
+
|
|
22
|
+
- **Range**: 1-100 (values outside this range are automatically coerced)
|
|
23
|
+
- **Default**: 1 (if not specified)
|
|
24
|
+
- **Type**: Integer (decimal values are rounded)
|
|
25
|
+
- **Effect**: Higher weight = more traffic
|
|
26
|
+
|
|
27
|
+
#### Examples
|
|
28
|
+
|
|
29
|
+
```json
|
|
30
|
+
{
|
|
31
|
+
"provider1": {
|
|
32
|
+
"address": "...",
|
|
33
|
+
"url": "https://provider1.example.com",
|
|
34
|
+
"datasetId": "...",
|
|
35
|
+
"weight": 1
|
|
36
|
+
},
|
|
37
|
+
"provider2": {
|
|
38
|
+
"address": "...",
|
|
39
|
+
"url": "https://provider2.example.com",
|
|
40
|
+
"datasetId": "...",
|
|
41
|
+
"weight": 3
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
In this example:
|
|
47
|
+
- Total weight = 4
|
|
48
|
+
- Provider 1 receives ~25% of traffic
|
|
49
|
+
- Provider 2 receives ~75% of traffic
|
|
@@ -0,0 +1,280 @@
|
|
|
1
|
+
|
|
2
|
+
<!doctype html>
|
|
3
|
+
<html lang="en">
|
|
4
|
+
|
|
5
|
+
<head>
|
|
6
|
+
<title>Code coverage report for balancer.ts</title>
|
|
7
|
+
<meta charset="utf-8" />
|
|
8
|
+
<link rel="stylesheet" href="prettify.css" />
|
|
9
|
+
<link rel="stylesheet" href="base.css" />
|
|
10
|
+
<link rel="shortcut icon" type="image/x-icon" href="favicon.png" />
|
|
11
|
+
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
|
12
|
+
<style type='text/css'>
|
|
13
|
+
.coverage-summary .sorter {
|
|
14
|
+
background-image: url(sort-arrow-sprite.png);
|
|
15
|
+
}
|
|
16
|
+
</style>
|
|
17
|
+
</head>
|
|
18
|
+
|
|
19
|
+
<body>
|
|
20
|
+
<div class='wrapper'>
|
|
21
|
+
<div class='pad1'>
|
|
22
|
+
<h1><a href="index.html">All files</a> balancer.ts</h1>
|
|
23
|
+
<div class='clearfix'>
|
|
24
|
+
|
|
25
|
+
<div class='fl pad1y space-right2'>
|
|
26
|
+
<span class="strong">0% </span>
|
|
27
|
+
<span class="quiet">Statements</span>
|
|
28
|
+
<span class='fraction'>0/40</span>
|
|
29
|
+
</div>
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
<div class='fl pad1y space-right2'>
|
|
33
|
+
<span class="strong">100% </span>
|
|
34
|
+
<span class="quiet">Branches</span>
|
|
35
|
+
<span class='fraction'>1/1</span>
|
|
36
|
+
</div>
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
<div class='fl pad1y space-right2'>
|
|
40
|
+
<span class="strong">100% </span>
|
|
41
|
+
<span class="quiet">Functions</span>
|
|
42
|
+
<span class='fraction'>1/1</span>
|
|
43
|
+
</div>
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
<div class='fl pad1y space-right2'>
|
|
47
|
+
<span class="strong">0% </span>
|
|
48
|
+
<span class="quiet">Lines</span>
|
|
49
|
+
<span class='fraction'>0/40</span>
|
|
50
|
+
</div>
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
</div>
|
|
54
|
+
<p class="quiet">
|
|
55
|
+
Press <em>n</em> or <em>j</em> to go to the next uncovered block, <em>b</em>, <em>p</em> or <em>k</em> for the previous block.
|
|
56
|
+
</p>
|
|
57
|
+
<template id="filterTemplate">
|
|
58
|
+
<div class="quiet">
|
|
59
|
+
Filter:
|
|
60
|
+
<input type="search" id="fileSearch">
|
|
61
|
+
</div>
|
|
62
|
+
</template>
|
|
63
|
+
</div>
|
|
64
|
+
<div class='status-line low'></div>
|
|
65
|
+
<pre><table class="coverage">
|
|
66
|
+
<tr><td class="line-count quiet"><a name='L1'></a><a href='#L1'>1</a>
|
|
67
|
+
<a name='L2'></a><a href='#L2'>2</a>
|
|
68
|
+
<a name='L3'></a><a href='#L3'>3</a>
|
|
69
|
+
<a name='L4'></a><a href='#L4'>4</a>
|
|
70
|
+
<a name='L5'></a><a href='#L5'>5</a>
|
|
71
|
+
<a name='L6'></a><a href='#L6'>6</a>
|
|
72
|
+
<a name='L7'></a><a href='#L7'>7</a>
|
|
73
|
+
<a name='L8'></a><a href='#L8'>8</a>
|
|
74
|
+
<a name='L9'></a><a href='#L9'>9</a>
|
|
75
|
+
<a name='L10'></a><a href='#L10'>10</a>
|
|
76
|
+
<a name='L11'></a><a href='#L11'>11</a>
|
|
77
|
+
<a name='L12'></a><a href='#L12'>12</a>
|
|
78
|
+
<a name='L13'></a><a href='#L13'>13</a>
|
|
79
|
+
<a name='L14'></a><a href='#L14'>14</a>
|
|
80
|
+
<a name='L15'></a><a href='#L15'>15</a>
|
|
81
|
+
<a name='L16'></a><a href='#L16'>16</a>
|
|
82
|
+
<a name='L17'></a><a href='#L17'>17</a>
|
|
83
|
+
<a name='L18'></a><a href='#L18'>18</a>
|
|
84
|
+
<a name='L19'></a><a href='#L19'>19</a>
|
|
85
|
+
<a name='L20'></a><a href='#L20'>20</a>
|
|
86
|
+
<a name='L21'></a><a href='#L21'>21</a>
|
|
87
|
+
<a name='L22'></a><a href='#L22'>22</a>
|
|
88
|
+
<a name='L23'></a><a href='#L23'>23</a>
|
|
89
|
+
<a name='L24'></a><a href='#L24'>24</a>
|
|
90
|
+
<a name='L25'></a><a href='#L25'>25</a>
|
|
91
|
+
<a name='L26'></a><a href='#L26'>26</a>
|
|
92
|
+
<a name='L27'></a><a href='#L27'>27</a>
|
|
93
|
+
<a name='L28'></a><a href='#L28'>28</a>
|
|
94
|
+
<a name='L29'></a><a href='#L29'>29</a>
|
|
95
|
+
<a name='L30'></a><a href='#L30'>30</a>
|
|
96
|
+
<a name='L31'></a><a href='#L31'>31</a>
|
|
97
|
+
<a name='L32'></a><a href='#L32'>32</a>
|
|
98
|
+
<a name='L33'></a><a href='#L33'>33</a>
|
|
99
|
+
<a name='L34'></a><a href='#L34'>34</a>
|
|
100
|
+
<a name='L35'></a><a href='#L35'>35</a>
|
|
101
|
+
<a name='L36'></a><a href='#L36'>36</a>
|
|
102
|
+
<a name='L37'></a><a href='#L37'>37</a>
|
|
103
|
+
<a name='L38'></a><a href='#L38'>38</a>
|
|
104
|
+
<a name='L39'></a><a href='#L39'>39</a>
|
|
105
|
+
<a name='L40'></a><a href='#L40'>40</a>
|
|
106
|
+
<a name='L41'></a><a href='#L41'>41</a>
|
|
107
|
+
<a name='L42'></a><a href='#L42'>42</a>
|
|
108
|
+
<a name='L43'></a><a href='#L43'>43</a>
|
|
109
|
+
<a name='L44'></a><a href='#L44'>44</a>
|
|
110
|
+
<a name='L45'></a><a href='#L45'>45</a>
|
|
111
|
+
<a name='L46'></a><a href='#L46'>46</a>
|
|
112
|
+
<a name='L47'></a><a href='#L47'>47</a>
|
|
113
|
+
<a name='L48'></a><a href='#L48'>48</a>
|
|
114
|
+
<a name='L49'></a><a href='#L49'>49</a>
|
|
115
|
+
<a name='L50'></a><a href='#L50'>50</a>
|
|
116
|
+
<a name='L51'></a><a href='#L51'>51</a>
|
|
117
|
+
<a name='L52'></a><a href='#L52'>52</a>
|
|
118
|
+
<a name='L53'></a><a href='#L53'>53</a>
|
|
119
|
+
<a name='L54'></a><a href='#L54'>54</a>
|
|
120
|
+
<a name='L55'></a><a href='#L55'>55</a>
|
|
121
|
+
<a name='L56'></a><a href='#L56'>56</a>
|
|
122
|
+
<a name='L57'></a><a href='#L57'>57</a>
|
|
123
|
+
<a name='L58'></a><a href='#L58'>58</a>
|
|
124
|
+
<a name='L59'></a><a href='#L59'>59</a>
|
|
125
|
+
<a name='L60'></a><a href='#L60'>60</a>
|
|
126
|
+
<a name='L61'></a><a href='#L61'>61</a>
|
|
127
|
+
<a name='L62'></a><a href='#L62'>62</a>
|
|
128
|
+
<a name='L63'></a><a href='#L63'>63</a>
|
|
129
|
+
<a name='L64'></a><a href='#L64'>64</a>
|
|
130
|
+
<a name='L65'></a><a href='#L65'>65</a>
|
|
131
|
+
<a name='L66'></a><a href='#L66'>66</a></td><td class="line-coverage quiet"><span class="cline-any cline-neutral"> </span>
|
|
132
|
+
<span class="cline-any cline-neutral"> </span>
|
|
133
|
+
<span class="cline-any cline-neutral"> </span>
|
|
134
|
+
<span class="cline-any cline-neutral"> </span>
|
|
135
|
+
<span class="cline-any cline-neutral"> </span>
|
|
136
|
+
<span class="cline-any cline-neutral"> </span>
|
|
137
|
+
<span class="cline-any cline-neutral"> </span>
|
|
138
|
+
<span class="cline-any cline-neutral"> </span>
|
|
139
|
+
<span class="cline-any cline-neutral"> </span>
|
|
140
|
+
<span class="cline-any cline-neutral"> </span>
|
|
141
|
+
<span class="cline-any cline-neutral"> </span>
|
|
142
|
+
<span class="cline-any cline-neutral"> </span>
|
|
143
|
+
<span class="cline-any cline-neutral"> </span>
|
|
144
|
+
<span class="cline-any cline-no"> </span>
|
|
145
|
+
<span class="cline-any cline-neutral"> </span>
|
|
146
|
+
<span class="cline-any cline-neutral"> </span>
|
|
147
|
+
<span class="cline-any cline-neutral"> </span>
|
|
148
|
+
<span class="cline-any cline-neutral"> </span>
|
|
149
|
+
<span class="cline-any cline-neutral"> </span>
|
|
150
|
+
<span class="cline-any cline-neutral"> </span>
|
|
151
|
+
<span class="cline-any cline-neutral"> </span>
|
|
152
|
+
<span class="cline-any cline-neutral"> </span>
|
|
153
|
+
<span class="cline-any cline-neutral"> </span>
|
|
154
|
+
<span class="cline-any cline-neutral"> </span>
|
|
155
|
+
<span class="cline-any cline-no"> </span>
|
|
156
|
+
<span class="cline-any cline-no"> </span>
|
|
157
|
+
<span class="cline-any cline-no"> </span>
|
|
158
|
+
<span class="cline-any cline-no"> </span>
|
|
159
|
+
<span class="cline-any cline-no"> </span>
|
|
160
|
+
<span class="cline-any cline-neutral"> </span>
|
|
161
|
+
<span class="cline-any cline-no"> </span>
|
|
162
|
+
<span class="cline-any cline-no"> </span>
|
|
163
|
+
<span class="cline-any cline-no"> </span>
|
|
164
|
+
<span class="cline-any cline-no"> </span>
|
|
165
|
+
<span class="cline-any cline-no"> </span>
|
|
166
|
+
<span class="cline-any cline-no"> </span>
|
|
167
|
+
<span class="cline-any cline-no"> </span>
|
|
168
|
+
<span class="cline-any cline-no"> </span>
|
|
169
|
+
<span class="cline-any cline-no"> </span>
|
|
170
|
+
<span class="cline-any cline-no"> </span>
|
|
171
|
+
<span class="cline-any cline-no"> </span>
|
|
172
|
+
<span class="cline-any cline-no"> </span>
|
|
173
|
+
<span class="cline-any cline-no"> </span>
|
|
174
|
+
<span class="cline-any cline-no"> </span>
|
|
175
|
+
<span class="cline-any cline-no"> </span>
|
|
176
|
+
<span class="cline-any cline-no"> </span>
|
|
177
|
+
<span class="cline-any cline-no"> </span>
|
|
178
|
+
<span class="cline-any cline-no"> </span>
|
|
179
|
+
<span class="cline-any cline-no"> </span>
|
|
180
|
+
<span class="cline-any cline-no"> </span>
|
|
181
|
+
<span class="cline-any cline-no"> </span>
|
|
182
|
+
<span class="cline-any cline-no"> </span>
|
|
183
|
+
<span class="cline-any cline-no"> </span>
|
|
184
|
+
<span class="cline-any cline-no"> </span>
|
|
185
|
+
<span class="cline-any cline-no"> </span>
|
|
186
|
+
<span class="cline-any cline-no"> </span>
|
|
187
|
+
<span class="cline-any cline-no"> </span>
|
|
188
|
+
<span class="cline-any cline-no"> </span>
|
|
189
|
+
<span class="cline-any cline-no"> </span>
|
|
190
|
+
<span class="cline-any cline-no"> </span>
|
|
191
|
+
<span class="cline-any cline-neutral"> </span>
|
|
192
|
+
<span class="cline-any cline-no"> </span>
|
|
193
|
+
<span class="cline-any cline-no"> </span>
|
|
194
|
+
<span class="cline-any cline-no"> </span>
|
|
195
|
+
<span class="cline-any cline-no"> </span>
|
|
196
|
+
<span class="cline-any cline-neutral"> </span></td><td class="text"><pre class="prettyprint lang-js">// Copyright 2021-2025 Prosopo (UK) Ltd.
|
|
197
|
+
//
|
|
198
|
+
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
199
|
+
// you may not use this file except in compliance with the License.
|
|
200
|
+
// You may obtain a copy of the License at
|
|
201
|
+
//
|
|
202
|
+
// http://www.apache.org/licenses/LICENSE-2.0
|
|
203
|
+
//
|
|
204
|
+
// Unless required by applicable law or agreed to in writing, software
|
|
205
|
+
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
206
|
+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
207
|
+
// See the License for the specific language governing permissions and
|
|
208
|
+
// limitations under the License.
|
|
209
|
+
<span class="cstat-no" title="statement not covered" >import { ProsopoEnvError } from "@prosopo/common";</span>
|
|
210
|
+
import type { EnvironmentTypes } from "@prosopo/types";
|
|
211
|
+
|
|
212
|
+
export type HardcodedProvider = {
|
|
213
|
+
address: string;
|
|
214
|
+
url: string;
|
|
215
|
+
datasetId: string;
|
|
216
|
+
};
|
|
217
|
+
|
|
218
|
+
type hostedProviders = Record<string, HardcodedProvider>;
|
|
219
|
+
|
|
220
|
+
<span class="cstat-no" title="statement not covered" >const convertHostedProvider = (</span>
|
|
221
|
+
<span class="cstat-no" title="statement not covered" > provider: hostedProviders,</span>
|
|
222
|
+
<span class="cstat-no" title="statement not covered" >): HardcodedProvider[] => {</span>
|
|
223
|
+
<span class="cstat-no" title="statement not covered" > return Object.values(provider).sort((a, b) => a.url.localeCompare(b.url));</span>
|
|
224
|
+
<span class="cstat-no" title="statement not covered" >};</span>
|
|
225
|
+
|
|
226
|
+
<span class="cstat-no" title="statement not covered" >export const loadBalancer = async (</span>
|
|
227
|
+
<span class="cstat-no" title="statement not covered" > environment: EnvironmentTypes,</span>
|
|
228
|
+
<span class="cstat-no" title="statement not covered" >): Promise<HardcodedProvider[]> => {</span>
|
|
229
|
+
<span class="cstat-no" title="statement not covered" > if (environment === "production") {</span>
|
|
230
|
+
<span class="cstat-no" title="statement not covered" > const providers: hostedProviders = await fetch(</span>
|
|
231
|
+
<span class="cstat-no" title="statement not covered" > "https://provider-list.prosopo.io/",</span>
|
|
232
|
+
<span class="cstat-no" title="statement not covered" > {</span>
|
|
233
|
+
<span class="cstat-no" title="statement not covered" > method: "GET",</span>
|
|
234
|
+
<span class="cstat-no" title="statement not covered" > mode: "cors",</span>
|
|
235
|
+
<span class="cstat-no" title="statement not covered" > },</span>
|
|
236
|
+
<span class="cstat-no" title="statement not covered" > ).then((res) => res.json());</span>
|
|
237
|
+
<span class="cstat-no" title="statement not covered" > return convertHostedProvider(providers);</span>
|
|
238
|
+
<span class="cstat-no" title="statement not covered" > }</span>
|
|
239
|
+
<span class="cstat-no" title="statement not covered" > if (environment === "staging") {</span>
|
|
240
|
+
<span class="cstat-no" title="statement not covered" > const providers: hostedProviders = await fetch(</span>
|
|
241
|
+
<span class="cstat-no" title="statement not covered" > "https://provider-list.prosopo.io/staging.json",</span>
|
|
242
|
+
<span class="cstat-no" title="statement not covered" > { method: "GET", mode: "cors" },</span>
|
|
243
|
+
<span class="cstat-no" title="statement not covered" > ).then((res) => res.json());</span>
|
|
244
|
+
<span class="cstat-no" title="statement not covered" > return convertHostedProvider(providers);</span>
|
|
245
|
+
<span class="cstat-no" title="statement not covered" > }</span>
|
|
246
|
+
<span class="cstat-no" title="statement not covered" > if (environment === "development") {</span>
|
|
247
|
+
<span class="cstat-no" title="statement not covered" > return [</span>
|
|
248
|
+
<span class="cstat-no" title="statement not covered" > {</span>
|
|
249
|
+
<span class="cstat-no" title="statement not covered" > address: "5EjTA28bKSbFPPyMbUjNtArxyqjwq38r1BapVmLZShaqEedV",</span>
|
|
250
|
+
<span class="cstat-no" title="statement not covered" > url: "http://localhost:9229",</span>
|
|
251
|
+
<span class="cstat-no" title="statement not covered" > datasetId:</span>
|
|
252
|
+
<span class="cstat-no" title="statement not covered" > "0x9f460e81ac9c71b486f796a21bb36e2263694756a6621134d110da217fd3ef25",</span>
|
|
253
|
+
<span class="cstat-no" title="statement not covered" > },</span>
|
|
254
|
+
<span class="cstat-no" title="statement not covered" > ];</span>
|
|
255
|
+
<span class="cstat-no" title="statement not covered" > }</span>
|
|
256
|
+
|
|
257
|
+
<span class="cstat-no" title="statement not covered" > throw new ProsopoEnvError("CONFIG.UNKNOWN_ENVIRONMENT", {</span>
|
|
258
|
+
<span class="cstat-no" title="statement not covered" > context: { environment },</span>
|
|
259
|
+
<span class="cstat-no" title="statement not covered" > });</span>
|
|
260
|
+
<span class="cstat-no" title="statement not covered" >};</span>
|
|
261
|
+
</pre></td></tr></table></pre>
|
|
262
|
+
|
|
263
|
+
<div class='push'></div><!-- for sticky footer -->
|
|
264
|
+
</div><!-- /wrapper -->
|
|
265
|
+
<div class='footer quiet pad2 space-top1 center small'>
|
|
266
|
+
Code coverage generated by
|
|
267
|
+
<a href="https://istanbul.js.org/" target="_blank" rel="noopener noreferrer">istanbul</a>
|
|
268
|
+
at 2025-09-29T09:25:03.005Z
|
|
269
|
+
</div>
|
|
270
|
+
<script src="prettify.js"></script>
|
|
271
|
+
<script>
|
|
272
|
+
window.onload = function () {
|
|
273
|
+
prettyPrint();
|
|
274
|
+
};
|
|
275
|
+
</script>
|
|
276
|
+
<script src="sorter.js"></script>
|
|
277
|
+
<script src="block-navigation.js"></script>
|
|
278
|
+
</body>
|
|
279
|
+
</html>
|
|
280
|
+
|