@ethersphere/bee-js 2.1.0 → 3.2.0

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.
Files changed (160) hide show
  1. package/README.md +3 -3
  2. package/dist/index.browser.min.js +1 -1
  3. package/dist/index.browser.min.js.map +1 -1
  4. package/dist/index.min.js +1 -1
  5. package/dist/index.min.js.map +1 -1
  6. package/dist/src/bee-debug.d.ts +5 -1
  7. package/dist/src/bee.d.ts +23 -46
  8. package/dist/src/modules/chunk.d.ts +2 -10
  9. package/dist/src/modules/debug/status.d.ts +10 -4
  10. package/dist/src/types/debug.d.ts +19 -0
  11. package/dist/src/types/index.d.ts +31 -2
  12. package/dist/src/utils/bytes.d.ts +1 -1
  13. package/dist/src/utils/error.d.ts +21 -2
  14. package/dist/src/utils/expose.d.ts +1 -0
  15. package/dist/src/utils/http.d.ts +7 -9
  16. package/dist/src/utils/stamps.d.ts +12 -0
  17. package/dist/src/utils/type.d.ts +6 -0
  18. package/package.json +28 -27
  19. package/.babelrc.js +0 -33
  20. package/.depcheckrc.json +0 -27
  21. package/.editorconfig +0 -6
  22. package/.eslintignore +0 -1
  23. package/.eslintrc.js +0 -109
  24. package/.gitattributes +0 -1
  25. package/.github/config.yaml +0 -23
  26. package/.github/workflows/check.yaml +0 -57
  27. package/.github/workflows/publish_npmjs.yaml +0 -20
  28. package/.github/workflows/release_github.yaml +0 -20
  29. package/.github/workflows/tests.yaml +0 -128
  30. package/.huskyrc +0 -5
  31. package/.prettierrc +0 -13
  32. package/.vscode/launch.json +0 -49
  33. package/.vscode/settings.json +0 -39
  34. package/CHANGELOG.md +0 -520
  35. package/CODEOWNERS +0 -1
  36. package/CODE_OF_CONDUCT.md +0 -76
  37. package/commitlint.config.js +0 -3
  38. package/dist/src/modules/stamps.d.ts +0 -4
  39. package/jest-puppeteer.config.js +0 -5
  40. package/jest.config.ts +0 -85
  41. package/src/bee-debug.ts +0 -601
  42. package/src/bee.ts +0 -1087
  43. package/src/chunk/bmt.ts +0 -55
  44. package/src/chunk/cac.ts +0 -79
  45. package/src/chunk/serialize.ts +0 -16
  46. package/src/chunk/signer.ts +0 -141
  47. package/src/chunk/soc.ts +0 -190
  48. package/src/chunk/span.ts +0 -33
  49. package/src/feed/index.ts +0 -217
  50. package/src/feed/json.ts +0 -33
  51. package/src/feed/topic.ts +0 -23
  52. package/src/feed/type.ts +0 -12
  53. package/src/index.ts +0 -24
  54. package/src/modules/bytes.ts +0 -70
  55. package/src/modules/bzz.ts +0 -179
  56. package/src/modules/chunk.ts +0 -69
  57. package/src/modules/debug/balance.ts +0 -63
  58. package/src/modules/debug/chequebook.ts +0 -175
  59. package/src/modules/debug/chunk.ts +0 -39
  60. package/src/modules/debug/connectivity.ts +0 -61
  61. package/src/modules/debug/settlements.ts +0 -33
  62. package/src/modules/debug/stamps.ts +0 -96
  63. package/src/modules/debug/states.ts +0 -35
  64. package/src/modules/debug/status.ts +0 -34
  65. package/src/modules/debug/tag.ts +0 -19
  66. package/src/modules/debug/transactions.ts +0 -79
  67. package/src/modules/feed.ts +0 -105
  68. package/src/modules/pinning.ts +0 -74
  69. package/src/modules/pss.ts +0 -49
  70. package/src/modules/soc.ts +0 -40
  71. package/src/modules/stamps.ts +0 -59
  72. package/src/modules/status.ts +0 -13
  73. package/src/modules/stewardship.ts +0 -32
  74. package/src/modules/tag.ts +0 -83
  75. package/src/types/debug.ts +0 -204
  76. package/src/types/index.ts +0 -561
  77. package/src/types/ky-universal/common.d.ts +0 -17
  78. package/src/types/ky-universal/hooks.d.ts +0 -103
  79. package/src/types/ky-universal/index.d.ts +0 -125
  80. package/src/types/ky-universal/options.d.ts +0 -235
  81. package/src/types/ky-universal/response.d.ts +0 -38
  82. package/src/types/ky-universal/retry.d.ts +0 -39
  83. package/src/types/tar-js.d.ts +0 -1
  84. package/src/types/webpack-bundle-analyzer/index.d.ts +0 -13
  85. package/src/utils/bytes.ts +0 -144
  86. package/src/utils/collection.ts +0 -151
  87. package/src/utils/data.browser.ts +0 -68
  88. package/src/utils/data.ts +0 -48
  89. package/src/utils/error.ts +0 -23
  90. package/src/utils/eth.ts +0 -229
  91. package/src/utils/expose.ts +0 -48
  92. package/src/utils/file.ts +0 -40
  93. package/src/utils/hash.ts +0 -16
  94. package/src/utils/headers.ts +0 -63
  95. package/src/utils/hex.ts +0 -186
  96. package/src/utils/http.ts +0 -141
  97. package/src/utils/merge.ts +0 -34
  98. package/src/utils/pss.ts +0 -16
  99. package/src/utils/stream.ts +0 -146
  100. package/src/utils/tar.ts +0 -30
  101. package/src/utils/type.ts +0 -394
  102. package/src/utils/uint64.ts +0 -31
  103. package/src/utils/url.ts +0 -52
  104. package/test/bee.sh +0 -187
  105. package/test/data/1.txt +0 -1
  106. package/test/data/2.txt +0 -0
  107. package/test/data/empty +0 -0
  108. package/test/data/sub/3.txt +0 -1
  109. package/test/data/sub//303/251 +0 -0
  110. package/test/data/sub//360/237/230/216 +0 -0
  111. package/test/integration/bee-class.browser.spec.ts +0 -272
  112. package/test/integration/bee-class.spec.ts +0 -648
  113. package/test/integration/bee-debug-class.spec.ts +0 -114
  114. package/test/integration/chunk/bmt.spec.ts +0 -33
  115. package/test/integration/chunk/cac.spec.ts +0 -27
  116. package/test/integration/chunk/soc.spec.ts +0 -38
  117. package/test/integration/feed/index.spec.ts +0 -84
  118. package/test/integration/modules/bytes.spec.ts +0 -23
  119. package/test/integration/modules/bzz.spec.ts +0 -265
  120. package/test/integration/modules/chunk.spec.ts +0 -29
  121. package/test/integration/modules/debug/balance.spec.ts +0 -70
  122. package/test/integration/modules/debug/chequebook.spec.ts +0 -64
  123. package/test/integration/modules/debug/connectivity.spec.ts +0 -69
  124. package/test/integration/modules/debug/settlements.spec.ts +0 -34
  125. package/test/integration/modules/debug/states.spec.ts +0 -34
  126. package/test/integration/modules/debug/status.spec.ts +0 -65
  127. package/test/integration/modules/debug/tag.spec.ts +0 -27
  128. package/test/integration/modules/debug/transactions.spec.ts +0 -10
  129. package/test/integration/modules/feed.spec.ts +0 -61
  130. package/test/integration/modules/pinning.spec.ts +0 -155
  131. package/test/integration/modules/pss.spec.ts +0 -105
  132. package/test/integration/modules/status.spec.ts +0 -10
  133. package/test/integration/modules/stewardship.spec.ts +0 -32
  134. package/test/integration/modules/tag.spec.ts +0 -51
  135. package/test/test-type-sequencer.js +0 -36
  136. package/test/testpage/testpage.html +0 -20
  137. package/test/tests-setup.ts +0 -94
  138. package/test/unit/assertions.ts +0 -460
  139. package/test/unit/bee-class.spec.ts +0 -976
  140. package/test/unit/bee-debug-class.spec.ts +0 -435
  141. package/test/unit/chunk/bmt.spec.ts +0 -16
  142. package/test/unit/chunk/cac.spec.ts +0 -29
  143. package/test/unit/chunk/serialize.spec.ts +0 -24
  144. package/test/unit/chunk/signer.spec.ts +0 -140
  145. package/test/unit/chunk/soc.spec.ts +0 -25
  146. package/test/unit/chunk/span.spec.ts +0 -38
  147. package/test/unit/feed/json.spec.ts +0 -73
  148. package/test/unit/nock.ts +0 -151
  149. package/test/unit/utils/bytes.spec.ts +0 -32
  150. package/test/unit/utils/collection.spec.ts +0 -22
  151. package/test/unit/utils/eth.spec.ts +0 -224
  152. package/test/unit/utils/hex.spec.ts +0 -115
  153. package/test/unit/utils/stream.spec.ts +0 -30
  154. package/test/unit/utils/type.spec.ts +0 -32
  155. package/test/unit/utils/uint64.spec.ts +0 -102
  156. package/test/utils.ts +0 -426
  157. package/tsconfig.json +0 -18
  158. package/tsconfig.test.json +0 -11
  159. package/typedoc.json +0 -7
  160. package/webpack.config.ts +0 -141
@@ -1,125 +0,0 @@
1
- /**
2
- * Types extracted from Ky as a backport for older Ky non-ESM version
3
- *
4
- * @author https://github.com/sindresorhus
5
- * @licence MIT https://github.com/sindresorhus/ky/blob/main/license
6
- */
7
-
8
- declare module 'ky-universal' {
9
- type Options = import('./options').Options
10
- type Input = import('./options').Input
11
- type ResponsePromise = import('./response').ResponsePromise
12
- const stop: unique symbol
13
-
14
- interface KyInterface {
15
- /**
16
- Fetch the given `url` using the option `{method: 'get'}`.
17
-
18
- @param url - `Request` object, `URL` object, or URL string.
19
- @returns A promise with `Body` methods added.
20
- */
21
- get: (url: Input, options?: Options) => ResponsePromise
22
- /**
23
- Fetch the given `url` using the option `{method: 'post'}`.
24
-
25
- @param url - `Request` object, `URL` object, or URL string.
26
- @returns A promise with `Body` methods added.
27
- */
28
- post: (url: Input, options?: Options) => ResponsePromise
29
- /**
30
- Fetch the given `url` using the option `{method: 'put'}`.
31
-
32
- @param url - `Request` object, `URL` object, or URL string.
33
- @returns A promise with `Body` methods added.
34
- */
35
- put: (url: Input, options?: Options) => ResponsePromise
36
- /**
37
- Fetch the given `url` using the option `{method: 'delete'}`.
38
-
39
- @param url - `Request` object, `URL` object, or URL string.
40
- @returns A promise with `Body` methods added.
41
- */
42
- delete: (url: Input, options?: Options) => ResponsePromise
43
- /**
44
- Fetch the given `url` using the option `{method: 'patch'}`.
45
-
46
- @param url - `Request` object, `URL` object, or URL string.
47
- @returns A promise with `Body` methods added.
48
- */
49
- patch: (url: Input, options?: Options) => ResponsePromise
50
- /**
51
- Fetch the given `url` using the option `{method: 'head'}`.
52
-
53
- @param url - `Request` object, `URL` object, or URL string.
54
- @returns A promise with `Body` methods added.
55
- */
56
- head: (url: Input, options?: Options) => ResponsePromise
57
- /**
58
- Create a new Ky instance with complete new defaults.
59
-
60
- @returns A new Ky instance.
61
- */
62
- create: (defaultOptions: Options) => KyInterface
63
- /**
64
- Create a new Ky instance with some defaults overridden with your own.
65
-
66
- In contrast to `ky.create()`, `ky.extend()` inherits defaults from its parent.
67
-
68
- @returns A new Ky instance.
69
- */
70
- extend: (defaultOptions: Options) => KyInterface
71
- /**
72
- A `Symbol` that can be returned by a `beforeRetry` hook to stop the retry. This will also short circuit the remaining `beforeRetry` hooks.
73
-
74
- Note: Returning this symbol makes Ky abort and return with an `undefined` response. Be sure to check for a response before accessing any properties on it or use [optional chaining](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Optional_chaining). It is also incompatible with body methods, such as `.json()` or `.text()`, because there is no response to parse. In general, we recommend throwing an error instead of returning this symbol, as that will cause Ky to abort and then throw, which avoids these limitations.
75
-
76
- A valid use-case for `ky.stop` is to prevent retries when making requests for side effects, where the returned data is not important. For example, logging client activity to the server.
77
-
78
- @example
79
- ```
80
- import ky from 'ky';
81
-
82
- const options = {
83
- hooks: {
84
- beforeRetry: [
85
- async ({request, options, error, retryCount}) => {
86
- const shouldStopRetry = await ky('https://example.com/api');
87
- if (shouldStopRetry) {
88
- return ky.stop;
89
- }
90
- }
91
- ]
92
- }
93
- };
94
-
95
- // Note that response will be `undefined` in case `ky.stop` is returned.
96
- const response = await ky.post('https://example.com', options);
97
-
98
- // Using `.text()` or other body methods is not suppported.
99
- const text = await ky('https://example.com', options).text();
100
- ```
101
- */
102
- readonly stop: typeof stop
103
- /**
104
- Fetch the given `url`.
105
-
106
- @param url - `Request` object, `URL` object, or URL string.
107
- @returns A promise with `Body` method added.
108
-
109
- @example
110
- ```
111
- import ky from 'ky';
112
-
113
- const json = await ky('https://example.com', {json: {foo: true}}).json();
114
-
115
- console.log(json);
116
- //=> `{data: '🦄'}`
117
- ```
118
- */
119
- (url: Input, options?: Options): ResponsePromise
120
- }
121
-
122
- const ky: KyInterface
123
- export default ky
124
- export { Options }
125
- }
@@ -1,235 +0,0 @@
1
- /**
2
- * Types extracted from Ky as a backport for older Ky non-ESM version
3
- *
4
- * @author https://github.com/sindresorhus
5
- * @licence MIT https://github.com/sindresorhus/ky/blob/main/license
6
- */
7
-
8
- import type { LiteralUnion, Required } from './common.js'
9
- import type { Hooks } from './hooks.js'
10
- import type { RetryOptions } from './retry.js'
11
-
12
- export declare type SearchParamsInit = string | string[][] | Record<string, string> | URLSearchParams | undefined
13
- export declare type SearchParamsOption =
14
- | SearchParamsInit
15
- | Record<string, string | number | boolean>
16
- | Array<Array<string | number | boolean>>
17
- export declare type HTTPMethod = 'get' | 'post' | 'put' | 'patch' | 'head' | 'delete'
18
- export declare type Input = string | URL | Request
19
-
20
- export interface DownloadProgress {
21
- percent: number
22
- transferredBytes: number
23
- /**
24
- Note: If it's not possible to retrieve the body size, it will be `0`.
25
- */
26
- totalBytes: number
27
- }
28
-
29
- export declare type KyHeadersInit = HeadersInit | Record<string, string | undefined>
30
-
31
- /**
32
- Options are the same as `window.fetch`, with some exceptions.
33
- */
34
- export interface Options extends Omit<RequestInit, 'headers'> {
35
- /**
36
- HTTP method used to make the request.
37
-
38
- Internally, the standard methods (`GET`, `POST`, `PUT`, `PATCH`, `HEAD` and `DELETE`) are uppercased in order to avoid server errors due to case sensitivity.
39
- */
40
- method?: LiteralUnion<HTTPMethod, string>
41
- /**
42
- HTTP headers used to make the request.
43
-
44
- You can pass a `Headers` instance or a plain object.
45
-
46
- You can remove a header with `.extend()` by passing the header with an `undefined` value.
47
-
48
- @example
49
- ```
50
- import ky from 'ky';
51
-
52
- const url = 'https://sindresorhus.com';
53
-
54
- const original = ky.create({
55
- headers: {
56
- rainbow: 'rainbow',
57
- unicorn: 'unicorn'
58
- }
59
- });
60
-
61
- const extended = original.extend({
62
- headers: {
63
- rainbow: undefined
64
- }
65
- });
66
-
67
- const response = await extended(url).json();
68
-
69
- console.log('rainbow' in response);
70
- //=> false
71
-
72
- console.log('unicorn' in response);
73
- //=> true
74
- ```
75
- */
76
- headers?: KyHeadersInit
77
- /**
78
- Shortcut for sending JSON. Use this instead of the `body` option.
79
-
80
- Accepts any plain object or value, which will be `JSON.stringify()`'d and sent in the body with the correct header set.
81
- */
82
- json?: unknown
83
- /**
84
- User-defined JSON-parsing function.
85
-
86
- Use-cases:
87
- 1. Parse JSON via the [`bourne` package](https://github.com/hapijs/bourne) to protect from prototype pollution.
88
- 2. Parse JSON with [`reviver` option of `JSON.parse()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/parse).
89
-
90
- @default JSON.parse()
91
-
92
- @example
93
- ```
94
- import ky from 'ky';
95
- import bourne from '@hapijs/bourne';
96
-
97
- const json = await ky('https://example.com', {
98
- parseJson: text => bourne(text)
99
- }).json();
100
- ```
101
- */
102
- parseJson?: (text: string) => unknown
103
- /**
104
- Search parameters to include in the request URL. Setting this will override all existing search parameters in the input URL.
105
-
106
- Accepts any value supported by [`URLSearchParams()`](https://developer.mozilla.org/en-US/docs/Web/API/URLSearchParams/URLSearchParams).
107
- */
108
- searchParams?: SearchParamsOption
109
- /**
110
- A prefix to prepend to the `input` URL when making the request. It can be any valid URL, either relative or absolute. A trailing slash `/` is optional and will be added automatically, if needed, when it is joined with `input`. Only takes effect when `input` is a string. The `input` argument cannot start with a slash `/` when using this option.
111
-
112
- Useful when used with [`ky.extend()`](#kyextenddefaultoptions) to create niche-specific Ky-instances.
113
-
114
- Notes:
115
- - After `prefixUrl` and `input` are joined, the result is resolved against the [base URL](https://developer.mozilla.org/en-US/docs/Web/API/Node/baseURI) of the page (if any).
116
- - Leading slashes in `input` are disallowed when using this option to enforce consistency and avoid confusion about how the `input` URL is handled, given that `input` will not follow the normal URL resolution rules when `prefixUrl` is being used, which changes the meaning of a leading slash.
117
-
118
- @example
119
- ```
120
- import ky from 'ky';
121
-
122
- // On https://example.com
123
-
124
- const response = await ky('unicorn', {prefixUrl: '/api'});
125
- //=> 'https://example.com/api/unicorn'
126
-
127
- const response = await ky('unicorn', {prefixUrl: 'https://cats.com'});
128
- //=> 'https://cats.com/unicorn'
129
- ```
130
- */
131
- prefixUrl?: URL | string
132
- /**
133
- An object representing `limit`, `methods`, `statusCodes` and `maxRetryAfter` fields for maximum retry count, allowed methods, allowed status codes and maximum [`Retry-After`](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Retry-After) time.
134
-
135
- If `retry` is a number, it will be used as `limit` and other defaults will remain in place.
136
-
137
- If `maxRetryAfter` is set to `undefined`, it will use `options.timeout`. If [`Retry-After`](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Retry-After) header is greater than `maxRetryAfter`, it will cancel the request.
138
-
139
- Delays between retries is calculated with the function `0.3 * (2 ** (retry - 1)) * 1000`, where `retry` is the attempt number (starts from 1).
140
-
141
- @example
142
- ```
143
- import ky from 'ky';
144
-
145
- const json = await ky('https://example.com', {
146
- retry: {
147
- limit: 10,
148
- methods: ['get'],
149
- statusCodes: [413]
150
- }
151
- }).json();
152
- ```
153
- */
154
- retry?: RetryOptions | number
155
- /**
156
- Timeout in milliseconds for getting a response. Can not be greater than 2147483647.
157
- If set to `false`, there will be no timeout.
158
-
159
- @default 10000
160
- */
161
- timeout?: number | false
162
- /**
163
- Hooks allow modifications during the request lifecycle. Hook functions may be async and are run serially.
164
- */
165
- hooks?: Hooks
166
- /**
167
- Throw an `HTTPError` when, after following redirects, the response has a non-2xx status code. To also throw for redirects instead of following them, set the [`redirect`](https://developer.mozilla.org/en-US/docs/Web/API/WindowOrWorkerGlobalScope/fetch#Parameters) option to `'manual'`.
168
-
169
- Setting this to `false` may be useful if you are checking for resource availability and are expecting error responses.
170
-
171
- @default true
172
- */
173
- throwHttpErrors?: boolean
174
- /**
175
- Download progress event handler.
176
-
177
- @param chunk - Note: It's empty for the first call.
178
-
179
- @example
180
- ```
181
- import ky from 'ky';
182
-
183
- const response = await ky('https://example.com', {
184
- onDownloadProgress: (progress, chunk) => {
185
- // Example output:
186
- // `0% - 0 of 1271 bytes`
187
- // `100% - 1271 of 1271 bytes`
188
- console.log(`${progress.percent * 100}% - ${progress.transferredBytes} of ${progress.totalBytes} bytes`);
189
- }
190
- });
191
- ```
192
- */
193
- onDownloadProgress?: (progress: DownloadProgress, chunk: Uint8Array) => void
194
- /**
195
- User-defined `fetch` function.
196
- Has to be fully compatible with the [Fetch API](https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API) standard.
197
-
198
- Use-cases:
199
- 1. Use custom `fetch` implementations like [`isomorphic-unfetch`](https://www.npmjs.com/package/isomorphic-unfetch).
200
- 2. Use the `fetch` wrapper function provided by some frameworks that use server-side rendering (SSR).
201
-
202
- @default fetch
203
-
204
- @example
205
- ```
206
- import ky from 'ky';
207
- import fetch from 'isomorphic-unfetch';
208
-
209
- const json = await ky('https://example.com', {fetch}).json();
210
- ```
211
- */
212
- fetch?: (input: RequestInfo, init?: RequestInit) => Promise<Response>
213
- }
214
-
215
- export declare type InternalOptions = Required<
216
- Omit<Options, 'hooks' | 'retry'>,
217
- 'credentials' | 'fetch' | 'prefixUrl' | 'timeout'
218
- > & {
219
- hooks: Required<Hooks>
220
- retry: Required<RetryOptions>
221
- prefixUrl: string
222
- }
223
-
224
- /**
225
- Normalized options passed to the `fetch` call and the `beforeRequest` hooks.
226
- */
227
- export interface NormalizedOptions extends RequestInit {
228
- method: RequestInit['method']
229
- credentials: RequestInit['credentials']
230
- retry: RetryOptions
231
- prefixUrl: string
232
- onDownloadProgress: Options['onDownloadProgress']
233
- }
234
-
235
- export { RetryOptions }
@@ -1,38 +0,0 @@
1
- /**
2
- * Types extracted from Ky as a backport for older Ky non-ESM version
3
- *
4
- * @author https://github.com/sindresorhus
5
- * @licence MIT https://github.com/sindresorhus/ky/blob/main/license
6
- */
7
-
8
- /**
9
- Returns a `Response` object with `Body` methods added for convenience. So you can, for example, call `ky.get(input).json()` directly without having to await the `Response` first. When called like that, an appropriate `Accept` header will be set depending on the body method used. Unlike the `Body` methods of `window.Fetch`; these will throw an `HTTPError` if the response status is not in the range of `200...299`. Also, `.json()` will return an empty string if the response status is `204` instead of throwing a parse error due to an empty body.
10
- */
11
- export interface ResponsePromise extends Promise<Response> {
12
- arrayBuffer: () => Promise<ArrayBuffer>
13
- blob: () => Promise<Blob>
14
- formData: () => Promise<FormData>
15
- /**
16
- Get the response body as JSON.
17
-
18
- @example
19
- ```
20
- import ky from 'ky';
21
-
22
- const json = await ky(…).json();
23
- ```
24
-
25
- @example
26
- ```
27
- import ky from 'ky';
28
-
29
- interface Result {
30
- value: number;
31
- }
32
-
33
- const result = await ky(…).json<Result>();
34
- ```
35
- */
36
- json: <T>() => Promise<T>
37
- text: () => Promise<string>
38
- }
@@ -1,39 +0,0 @@
1
- /**
2
- * Types extracted from Ky as a backport for older Ky non-ESM version
3
- *
4
- * @author https://github.com/sindresorhus
5
- * @licence MIT https://github.com/sindresorhus/ky/blob/main/license
6
- */
7
-
8
- export interface RetryOptions {
9
- /**
10
- The number of times to retry failed requests.
11
-
12
- @default 2
13
- */
14
- limit?: number
15
- /**
16
- The HTTP methods allowed to retry.
17
-
18
- @default ['get', 'put', 'head', 'delete', 'options', 'trace']
19
- */
20
- methods?: string[]
21
- /**
22
- The HTTP status codes allowed to retry.
23
-
24
- @default [408, 413, 429, 500, 502, 503, 504]
25
- */
26
- statusCodes?: number[]
27
- /**
28
- The HTTP status codes allowed to retry with a `Retry-After` header.
29
-
30
- @default [413, 429, 503]
31
- */
32
- afterStatusCodes?: number[]
33
- /**
34
- If the `Retry-After` header is greater than `maxRetryAfter`, the request will be canceled.
35
-
36
- @default Infinity
37
- */
38
- maxRetryAfter?: number
39
- }
@@ -1 +0,0 @@
1
- declare module 'tar-js'
@@ -1,13 +0,0 @@
1
- /**
2
- * We declare this module manually instead of using the @types/webpack-bundle-analyzer
3
- * because it relies on the old @types/webpack for v4 that cause incompatibilities with v5
4
- * because v5 ships its own definitions.
5
- */
6
- declare module 'webpack-bundle-analyzer' {
7
- import { Compiler, WebpackPluginInstance } from 'webpack'
8
-
9
- export class BundleAnalyzerPlugin implements WebpackPluginInstance {
10
- constructor(options?: unknown)
11
- apply(compiler: Compiler): void
12
- }
13
- }
@@ -1,144 +0,0 @@
1
- /**
2
- * Helper type for dealing with fixed size byte arrays.
3
- *
4
- * It changes the type of `length` property of `Uint8Array` to the
5
- * generic `Length` type parameter which is runtime compatible with
6
- * the original, because it extends from the `number` type.
7
- */
8
- import { Data } from '../types'
9
- import { bytesToHex } from './hex'
10
-
11
- export interface Bytes<Length extends number> extends Uint8Array {
12
- readonly length: Length
13
- }
14
-
15
- /**
16
- * Helper type for dealing with flexible sized byte arrays.
17
- *
18
- * The actual min and and max values are not stored in runtime, they
19
- * are only there to differentiate the type from the Uint8Array at
20
- * compile time.
21
- * @see BrandedType
22
- */
23
- export interface FlexBytes<Min extends number, Max extends number> extends Uint8Array {
24
- readonly __min__: Min
25
- readonly __max__: Max
26
- }
27
-
28
- /**
29
- * Type guard for Bytes<T> type
30
- *
31
- * @param b The byte array
32
- * @param length The length of the byte array
33
- */
34
- export function isBytes<Length extends number>(b: unknown, length: Length): b is Bytes<Length> {
35
- return b instanceof Uint8Array && b.length === length
36
- }
37
-
38
- /**
39
- * Verifies if a byte array has a certain length
40
- *
41
- * @param b The byte array
42
- * @param length The specified length
43
- */
44
- export function assertBytes<Length extends number>(b: unknown, length: Length): asserts b is Bytes<Length> {
45
- if (!isBytes(b, length)) {
46
- throw new TypeError(`Parameter is not valid Bytes of length: ${length} !== ${(b as Uint8Array).length}`)
47
- }
48
- }
49
-
50
- /**
51
- * Type guard for FlexBytes<Min,Max> type
52
- *
53
- * @param b The byte array
54
- * @param min Minimum size of the array
55
- * @param max Maximum size of the array
56
- */
57
- export function isFlexBytes<Min extends number, Max extends number = Min>(
58
- b: unknown,
59
- min: Min,
60
- max: Max,
61
- ): b is FlexBytes<Min, Max> {
62
- return b instanceof Uint8Array && b.length >= min && b.length <= max
63
- }
64
-
65
- /**
66
- * Verifies if a byte array has a certain length between min and max
67
- *
68
- * @param b The byte array
69
- * @param min Minimum size of the array
70
- * @param max Maximum size of the array
71
- */
72
- export function assertFlexBytes<Min extends number, Max extends number = Min>(
73
- b: unknown,
74
- min: Min,
75
- max: Max,
76
- ): asserts b is FlexBytes<Min, Max> {
77
- if (!isFlexBytes(b, min, max)) {
78
- throw new TypeError(
79
- `Parameter is not valid FlexBytes of min: ${min}, max: ${max}, length: ${(b as Uint8Array).length}`,
80
- )
81
- }
82
- }
83
-
84
- /**
85
- * Return `length` bytes starting from `offset`
86
- *
87
- * @param data The original data
88
- * @param offset The offset to start from
89
- * @param length The length of data to be returned
90
- */
91
- export function bytesAtOffset<Length extends number>(data: Uint8Array, offset: number, length: Length): Bytes<Length> {
92
- const offsetBytes = data.slice(offset, offset + length) as Bytes<Length>
93
-
94
- // We are returning strongly typed Bytes so we have to verify that length is really what we claim
95
- assertBytes<Length>(offsetBytes, length)
96
-
97
- return offsetBytes
98
- }
99
-
100
- /**
101
- * Return flex bytes starting from `offset`
102
- *
103
- * @param data The original data
104
- * @param offset The offset to start from
105
- * @param _min The minimum size of the data
106
- * @param _max The maximum size of the data
107
- */
108
- export function flexBytesAtOffset<Min extends number, Max extends number>(
109
- data: Uint8Array,
110
- offset: number,
111
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
112
- _min: Min,
113
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
114
- _max: Max,
115
- ): FlexBytes<Min, Max> {
116
- return data.slice(offset) as FlexBytes<Min, Max>
117
- }
118
-
119
- /**
120
- * Returns true if two byte arrays are equal
121
- *
122
- * @param a Byte array to compare
123
- * @param b Byte array to compare
124
- */
125
- export function bytesEqual(a: Uint8Array, b: Uint8Array): boolean {
126
- return a.length === b.length && a.every((value, index) => value === b[index])
127
- }
128
-
129
- /**
130
- * Returns a new byte array filled with zeroes with the specified length
131
- *
132
- * @param length The length of data to be returned
133
- */
134
- export function makeBytes<Length extends number>(length: Length): Bytes<Length> {
135
- return new Uint8Array(length) as Bytes<Length>
136
- }
137
-
138
- export function wrapBytesWithHelpers(data: Uint8Array): Data {
139
- return Object.assign(data, {
140
- text: () => new TextDecoder('utf-8').decode(data),
141
- json: () => JSON.parse(new TextDecoder('utf-8').decode(data)),
142
- hex: () => bytesToHex(data),
143
- })
144
- }