@ethersphere/bee-js 6.0.0-pre.1 → 6.0.0-pre.10

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.
@@ -27,6 +27,9 @@ export class BeeDebug {
27
27
  if (options?.headers) {
28
28
  requestOptions.headers = options.headers;
29
29
  }
30
+ if (options?.onRequest) {
31
+ requestOptions.onRequest = options.onRequest;
32
+ }
30
33
  this.requestOptions = requestOptions;
31
34
  }
32
35
  async getNodeAddresses(options) {
package/dist/mjs/bee.js CHANGED
@@ -54,6 +54,9 @@ export class Bee {
54
54
  if (options?.headers) {
55
55
  requestOptions.headers = options.headers;
56
56
  }
57
+ if (options?.onRequest) {
58
+ requestOptions.onRequest = options.onRequest;
59
+ }
57
60
  this.requestOptions = requestOptions;
58
61
  }
59
62
  /**
@@ -1,5 +1,4 @@
1
1
  import { wrapBytesWithHelpers } from "../utils/bytes.js";
2
- import { prepareData } from "../utils/data.js";
3
2
  import { extractUploadHeaders } from "../utils/headers.js";
4
3
  import { http } from "../utils/http.js";
5
4
  import { makeTagUid } from "../utils/type.js";
@@ -17,7 +16,7 @@ export async function upload(requestOptions, data, postageBatchId, options) {
17
16
  url: endpoint,
18
17
  method: 'post',
19
18
  responseType: 'json',
20
- data: await prepareData(data),
19
+ data,
21
20
  headers: {
22
21
  'content-type': 'application/octet-stream',
23
22
  ...extractUploadHeaders(postageBatchId, options)
@@ -1,7 +1,7 @@
1
1
  import getMajorSemver from 'semver/functions/major.js';
2
2
  import { http } from "../../utils/http.js"; // Following lines bellow are automatically updated with GitHub Action when Bee version is updated
3
3
  // so if you are changing anything about them change the `update_bee` action accordingly!
4
- export const SUPPORTED_BEE_VERSION_EXACT = '1.12.0-88c1d236';
4
+ export const SUPPORTED_BEE_VERSION_EXACT = '1.13.0-f1067884';
5
5
  export const SUPPORTED_API_VERSION = '4.0.0';
6
6
  export const SUPPORTED_DEBUG_API_VERSION = '4.0.0';
7
7
  export const SUPPORTED_BEE_VERSION = SUPPORTED_BEE_VERSION_EXACT.substring(0, SUPPORTED_BEE_VERSION_EXACT.indexOf('-'));
@@ -1,5 +1,4 @@
1
1
  import WebSocket from 'isomorphic-ws';
2
- import { prepareData } from "../utils/data.js";
3
2
  import { extractUploadHeaders } from "../utils/headers.js";
4
3
  import { http } from "../utils/http.js";
5
4
  const endpoint = 'pss';
@@ -18,7 +17,7 @@ export async function send(requestOptions, topic, target, data, postageBatchId,
18
17
  await http(requestOptions, {
19
18
  method: 'post',
20
19
  url: `${endpoint}/send/${topic}/${target}`,
21
- data: await prepareData(data),
20
+ data,
22
21
  responseType: 'json',
23
22
  params: {
24
23
  recipient
@@ -1,9 +1,8 @@
1
1
  import axios from 'axios';
2
- import { Objects } from 'cafe-utility';
2
+ import { Objects, Strings } from 'cafe-utility';
3
3
  export const DEFAULT_HTTP_CONFIG = {
4
4
  headers: {
5
- accept: 'application/json, text/plain, */*',
6
- 'user-agent': `bee-js`
5
+ accept: 'application/json, text/plain, */*'
7
6
  }
8
7
  };
9
8
  /**
@@ -14,9 +13,22 @@ export const DEFAULT_HTTP_CONFIG = {
14
13
  export async function http(options, config) {
15
14
  try {
16
15
  const requestConfig = Objects.deepMerge3(DEFAULT_HTTP_CONFIG, config, options);
16
+ maybeRunOnRequestHook(options, requestConfig);
17
17
  const response = await axios(requestConfig);
18
18
  return response;
19
19
  } catch (e) {
20
20
  throw e;
21
21
  }
22
+ }
23
+ function maybeRunOnRequestHook(options, requestConfig) {
24
+ if (options.onRequest) {
25
+ options.onRequest({
26
+ method: requestConfig.method || 'GET',
27
+ url: Strings.joinUrl(requestConfig.baseURL, requestConfig.url),
28
+ headers: {
29
+ ...requestConfig.headers
30
+ },
31
+ params: requestConfig.params
32
+ });
33
+ }
22
34
  }
@@ -9,7 +9,7 @@ function fixUnicodePath(path) {
9
9
  };
10
10
  }
11
11
  export function makeTar(data) {
12
- const tar = new Tar();
12
+ const tar = new Tar(1);
13
13
  for (const entry of data) {
14
14
  const path = fixUnicodePath(entry.path);
15
15
  tar.append(path, entry.data);
@@ -1,7 +1,7 @@
1
1
  import { BeeRequestOptions } from '../../index';
2
2
  import type { Health, NodeInfo } from '../../types/debug';
3
3
  import { BeeVersions } from '../../types/debug';
4
- export declare const SUPPORTED_BEE_VERSION_EXACT = "1.12.0-88c1d236";
4
+ export declare const SUPPORTED_BEE_VERSION_EXACT = "1.13.0-f1067884";
5
5
  export declare const SUPPORTED_API_VERSION = "4.0.0";
6
6
  export declare const SUPPORTED_DEBUG_API_VERSION = "4.0.0";
7
7
  export declare const SUPPORTED_BEE_VERSION: string;
@@ -78,12 +78,14 @@ export type BeeRequestOptions = {
78
78
  timeout?: number | false;
79
79
  retry?: number | false;
80
80
  headers?: Record<string, string>;
81
+ onRequest?: (request: BeeRequest) => void;
81
82
  };
82
83
  export interface BeeOptions extends BeeRequestOptions {
83
84
  /**
84
85
  * Signer object or private key of the Signer in form of either hex string or Uint8Array that will be default signer for the instance.
85
86
  */
86
87
  signer?: Signer | Uint8Array | string;
88
+ onRequest?: (request: BeeRequest) => void;
87
89
  }
88
90
  export interface UploadResultWithCid extends UploadResult {
89
91
  /**
@@ -277,7 +279,7 @@ export type HttpMethod = 'GET' | 'DELETE' | 'POST' | 'PATCH' | 'PUT';
277
279
  export type HookCallback<V> = (value: V) => void | Promise<void>;
278
280
  export interface BeeRequest {
279
281
  url: string;
280
- method: HttpMethod;
282
+ method: string;
281
283
  headers?: Record<string, string>;
282
284
  params?: Record<string, unknown>;
283
285
  }
@@ -3,7 +3,6 @@ import { BeeRequestOptions } from '../index';
3
3
  export declare const DEFAULT_HTTP_CONFIG: {
4
4
  headers: {
5
5
  accept: string;
6
- 'user-agent': string;
7
6
  };
8
7
  };
9
8
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ethersphere/bee-js",
3
- "version": "6.0.0-pre.1",
3
+ "version": "6.0.0-pre.10",
4
4
  "description": "Javascript client for Bee",
5
5
  "keywords": [
6
6
  "bee",
@@ -55,21 +55,19 @@
55
55
  "lint": "eslint --fix \"src/**/*.ts\" \"test/**/*.ts\" && prettier --write \"src/**/*.ts\" \"test/**/*.ts\"",
56
56
  "lint:check": "eslint \"src/**/*.ts\" \"test/**/*.ts\" && prettier --check \"src/**/*.ts\" \"test/**/*.ts\"",
57
57
  "depcheck": "depcheck .",
58
- "bee": "bee-factory start"
58
+ "bee": "npx bee-factory start"
59
59
  },
60
60
  "dependencies": {
61
61
  "@ethersphere/swarm-cid": "^0.1.0",
62
62
  "@types/readable-stream": "^2.3.13",
63
63
  "axios": "^1.3.4",
64
- "bufferutil": "^4.0.6",
65
- "cafe-utility": "8.0.0",
64
+ "cafe-utility": "^9.0.1",
66
65
  "elliptic": "^6.5.4",
67
66
  "fetch-blob": "2.1.2",
68
67
  "isomorphic-ws": "^4.0.1",
69
68
  "js-sha3": "^0.8.0",
70
69
  "semver": "^7.3.5",
71
70
  "tar-js": "^0.3.0",
72
- "utf-8-validate": "^5.0.9",
73
71
  "web-streams-polyfill": "^4.0.0-beta.3",
74
72
  "ws": "^8.7.0"
75
73
  },
@@ -82,7 +80,6 @@
82
80
  "@babel/preset-typescript": "^7.18.6",
83
81
  "@commitlint/cli": "^17.0.2",
84
82
  "@commitlint/config-conventional": "^17.4.2",
85
- "@ethersphere/bee-factory": "^0.5.2",
86
83
  "@fluffy-spoon/substitute": "^1.208.0",
87
84
  "@naholyr/cross-env": "^1.0.0",
88
85
  "@types/chai": "^4.3.4",
@@ -132,6 +129,6 @@
132
129
  "npm": ">=6.0.0",
133
130
  "beeApiVersion": "4.0.0",
134
131
  "beeDebugApiVersion": "4.0.0",
135
- "bee": "1.12.0-88c1d236"
132
+ "bee": "1.13.0-f1067884"
136
133
  }
137
134
  }