@commercetools/sdk-client-v2 0.2.0 → 1.1.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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,33 @@
1
1
  # @commercetools/sdk-client-v2
2
2
 
3
+ ## 1.1.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [#188](https://github.com/commercetools/commercetools-sdk-typescript/pull/188) [`4c2d9b6`](https://github.com/commercetools/commercetools-sdk-typescript/commit/4c2d9b64b204200dffbeb18130239138dd2ad7d3) Thanks [@ajimae](https://github.com/ajimae)! - February package release
8
+
9
+ ### Patch Changes
10
+
11
+ - [#149](https://github.com/commercetools/commercetools-sdk-typescript/pull/149) [`08caea9`](https://github.com/commercetools/commercetools-sdk-typescript/commit/08caea93560c01e2158f018538b7a2b9f4be39c1) Thanks [@renovate](https://github.com/apps/renovate)! - fix(deps): update all dependencies
12
+
13
+ ## 1.0.2
14
+
15
+ ### Patch Changes
16
+
17
+ - [#167](https://github.com/commercetools/commercetools-sdk-typescript/pull/167) [`b31612d`](https://github.com/commercetools/commercetools-sdk-typescript/commit/b31612dbcc3d644847cb42cf67bce407ab202cb0) Thanks [@ajimae](https://github.com/ajimae)! - Add Buffer Dependency
18
+
19
+ ## 1.0.1
20
+
21
+ ### Patch Changes
22
+
23
+ - [#163](https://github.com/commercetools/commercetools-sdk-typescript/pull/163) [`fcd35a0`](https://github.com/commercetools/commercetools-sdk-typescript/commit/fcd35a0f26b2780d0004c4e9d7b48233a86c2453) Thanks [@ajimae](https://github.com/ajimae)! - Fix issues with Buffer and node process
24
+
25
+ ## 1.0.0
26
+
27
+ ### Major Changes
28
+
29
+ - [#154](https://github.com/commercetools/commercetools-sdk-typescript/pull/154) [`25f1dea`](https://github.com/commercetools/commercetools-sdk-typescript/commit/25f1dea23eccdfdda01e9144ec2afe968ead58f2) Thanks [@jherey](https://github.com/jherey)! - This is the first major release of the sdk client
30
+
3
31
  ## 0.2.0
4
32
 
5
33
  ### Minor Changes
package/README.md CHANGED
@@ -1 +1,196 @@
1
- # `@commercetools/sdk-client-v2`
1
+ # Commercetools TypeScript SDK client.
2
+
3
+ ## Usage examples
4
+
5
+ ### Browser environment
6
+
7
+ ```html
8
+ <script src="https://unpkg.com/@commercetools/sdk-client-v2@latest/dist/commercetools-sdk-client-v2.umd.js"></script>
9
+ <script src="https://unpkg.com/@commercetools/platform-sdk@latest/dist/commercetools-platform-sdk.umd.js"></script>
10
+ ```
11
+
12
+ ```html
13
+ <script>
14
+ // global: @commercetools/sdk-client-v2
15
+ // global: @commercetools/platform-sdk
16
+ ;(function () {
17
+ // We can now access the sdk-client-v2 and platform-sdk object as:
18
+ // const { ClientBuilder } = this['@commercetools/sdk-client-v2']
19
+ // const { createApiBuilderFromCtpClient } = this['@commercetools/platform-sdk']
20
+ // or
21
+ // const { ClientBuilder } = window['@commercetools/sdk-client-v2']
22
+ // const { createApiBuilderFromCtpClient } = window['@commercetools/platform-sdk']
23
+ })()
24
+ </script>
25
+ ```
26
+
27
+ See full usage example [here](https://github.com/commercetools/commercetools-sdk-typescript/blob/master/examples/browser/browser.html)
28
+
29
+ ### Node environment
30
+
31
+ ```bash
32
+ npm install --save @commercetools/sdk-client-v2
33
+ npm install --save @commercetools/platform-sdk
34
+ ```
35
+
36
+ ```ts
37
+ const {
38
+ ClientBuilder,
39
+ createAuthForClientCredentialsFlow,
40
+ createHttpClient,
41
+ } = require('@commercetools/sdk-client-v2')
42
+ const { createApiBuilderFromCtpClient } = require('@commercetools/platform-sdk')
43
+ const fetch = require('node-fetch')
44
+
45
+ const projectKey = 'mc-project-key'
46
+ const authMiddlewareOptions = {
47
+ host: 'https://auth.europe-west1.gcp.commercetools.com',
48
+ projectKey,
49
+ credentials: {
50
+ clientId: 'mc-client-id',
51
+ clientSecret: 'mc-client-secrets',
52
+ },
53
+ oauthUri: '/oauth/token', // - optional: custom oauthUri
54
+ scopes: [`manage_project:${projectKey}`],
55
+ fetch,
56
+ }
57
+
58
+ const httpMiddlewareOptions = {
59
+ host: 'https://api.europe-west1.gcp.commercetools.com',
60
+ fetch,
61
+ }
62
+
63
+ const client = new ClientBuilder()
64
+ .withProjectKey(projectKey)
65
+ .withMiddleware(createAuthForClientCredentialsFlow(authMiddlewareOptions))
66
+ .withMiddleware(createHttpClient(httpMiddlewareOptions))
67
+ .withUserAgentMiddleware()
68
+ .build()
69
+
70
+ // or
71
+ const client = new ClientBuilder()
72
+ .withProjectKey(projectKey)
73
+ .withClientCredentialsFlow(authMiddlewareOptions)
74
+ .withHttpMiddleware(httpMiddlewareOptions)
75
+ .withUserAgentMiddleware()
76
+ .build()
77
+
78
+ const apiRoot = createApiBuilderFromCtpClient(client)
79
+
80
+ // calling the platform functions
81
+ // get project details
82
+ apiRoot
83
+ .withProjectKey({
84
+ projectKey,
85
+ })
86
+ .get()
87
+ .execute()
88
+ .then((x) => {
89
+ /*...*/
90
+ })
91
+
92
+ // create a productType
93
+ apiRoot
94
+ .withProjectKey({ projectKey })
95
+ .productTypes()
96
+ .post({
97
+ body: { name: 'product-type-name', description: 'some description' },
98
+ })
99
+ .execute()
100
+ .then((x) => {
101
+ /*...*/
102
+ })
103
+
104
+ // create a product
105
+ apiRoot
106
+ .withProjectKey({ projectKey })
107
+ .products()
108
+ .post({
109
+ body: {
110
+ name: { en: 'our-great-product-name' },
111
+ productType: {
112
+ typeId: 'product-type',
113
+ id: 'some-product-type-id',
114
+ },
115
+ slug: { en: 'some-slug' },
116
+ },
117
+ })
118
+ .execute()
119
+ .then((x) => {
120
+ /*...*/
121
+ })
122
+
123
+ // -----------------------------------------------------------------------
124
+ // The sdk-client-v2 also has support for the old syntax
125
+ import {
126
+ createClient,
127
+ createHttpClient,
128
+ createAuthForClientCredentialsFlow,
129
+ } from '@commercetools/sdk-client-v2'
130
+ import { createApiBuilderFromCtpClient } from '@commercetools/platform-sdk'
131
+ import fetch from 'node-fetch'
132
+
133
+ const projectKey = 'some_project_key'
134
+
135
+ const authMiddleware = createAuthForClientCredentialsFlow({
136
+ host: 'https://auth.europe-west1.gcp.commercetools.com',
137
+ projectKey,
138
+ credentials: {
139
+ clientId: 'some_id',
140
+ clientSecret: 'some_secret',
141
+ },
142
+ fetch,
143
+ })
144
+
145
+ const httpMiddleware = createHttpClient({
146
+ host: 'https://api.europe-west1.gcp.commercetools.com',
147
+ fetch,
148
+ })
149
+
150
+ const ctpClient = createClient({
151
+ middlewares: [authMiddleware, httpMiddleware],
152
+ })
153
+
154
+ const apiRoot = createApiBuilderFromCtpClient(ctpClient)
155
+
156
+ apiRoot
157
+ .withProjectKey({
158
+ projectKey,
159
+ })
160
+ .get()
161
+ .execute()
162
+ .then((x) => {
163
+ /*...*/
164
+ })
165
+
166
+ apiRoot
167
+ .withProjectKey({ projectKey })
168
+ .productTypes()
169
+ .post({
170
+ body: { name: 'product-type-name', description: 'some description' },
171
+ })
172
+ .execute()
173
+ .then((x) => {
174
+ /*...*/
175
+ })
176
+
177
+ apiRoot
178
+ .withProjectKey({ projectKey })
179
+ .products()
180
+ .post({
181
+ body: {
182
+ name: { en: 'our-great-product-name' },
183
+ productType: {
184
+ typeId: 'product-type',
185
+ id: 'some-product-type-id',
186
+ },
187
+ slug: { en: 'some-slug' },
188
+ },
189
+ })
190
+ .execute()
191
+ .then((x) => {
192
+ /*...*/
193
+ })
194
+ ```
195
+
196
+ See full usage example [here](https://github.com/commercetools/commercetools-sdk-typescript/blob/master/examples/node/node.js)
@@ -177,6 +177,8 @@ function createClient(options) {
177
177
 
178
178
  // POST https://{host}/oauth/token?grant_type=client_credentials&scope={scope}
179
179
  // Authorization: Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ==
180
+ const Buffer$2 = require('buffer/').Buffer;
181
+
180
182
  function buildRequestForClientCredentialsFlow(options) {
181
183
  if (!options) throw new Error('Missing required options');
182
184
  if (!options.host) throw new Error('Missing required option (host)');
@@ -188,7 +190,7 @@ function buildRequestForClientCredentialsFlow(options) {
188
190
  } = options.credentials;
189
191
  if (!(clientId && clientSecret)) throw new Error('Missing required credentials (clientId, clientSecret)');
190
192
  const scope = options.scopes ? options.scopes.join(' ') : undefined;
191
- const basicAuth = Buffer.from(`${clientId}:${clientSecret}`).toString('base64'); // This is mostly useful for internal testing purposes to be able to check
193
+ const basicAuth = Buffer$2.from(`${clientId}:${clientSecret}`).toString('base64'); // This is mostly useful for internal testing purposes to be able to check
192
194
  // other oauth endpoints.
193
195
 
194
196
  const oauthUri = options.oauthUri || '/oauth/token';
@@ -219,7 +221,7 @@ function buildRequestForPasswordFlow(options) {
219
221
  if (!(username && password)) throw new Error('Missing required user credentials (username, password)');
220
222
  const scope = (options.scopes || []).join(' ');
221
223
  const scopeStr = scope ? `&scope=${scope}` : '';
222
- const basicAuth = Buffer.from(`${clientId}:${clientSecret}`).toString('base64');
224
+ const basicAuth = Buffer$2.from(`${clientId}:${clientSecret}`).toString('base64');
223
225
  /**
224
226
  * This is mostly useful for internal testing purposes to be able to check
225
227
  * other oauth endpoints.
@@ -246,7 +248,7 @@ function buildRequestForRefreshTokenFlow(options) {
246
248
  clientSecret
247
249
  } = options.credentials;
248
250
  if (!(clientId && clientSecret)) throw new Error('Missing required credentials (clientId, clientSecret)');
249
- const basicAuth = Buffer.from(`${clientId}:${clientSecret}`).toString('base64'); // This is mostly useful for internal testing purposes to be able to check
251
+ const basicAuth = Buffer$2.from(`${clientId}:${clientSecret}`).toString('base64'); // This is mostly useful for internal testing purposes to be able to check
250
252
  // other oauth endpoints.
251
253
 
252
254
  const oauthUri = options.oauthUri || '/oauth/token';
@@ -269,6 +271,8 @@ function buildRequestForAnonymousSessionFlow(options) {
269
271
  };
270
272
  }
271
273
 
274
+ const Buffer$1 = require('buffer/').Buffer;
275
+
272
276
  function mergeAuthHeader(token, req) {
273
277
  return { ...req,
274
278
  headers: { ...req.headers,
@@ -298,7 +302,7 @@ async function executeRequest({
298
302
  method: 'POST',
299
303
  headers: {
300
304
  Authorization: `Basic ${basicAuth}`,
301
- 'Content-Length': Buffer.byteLength(body).toString(),
305
+ 'Content-Length': Buffer$1.byteLength(body).toString(),
302
306
  'Content-Type': 'application/x-www-form-urlencoded'
303
307
  },
304
308
  body
@@ -703,6 +707,8 @@ function parseHeaders(headers) {
703
707
  return map;
704
708
  }
705
709
 
710
+ const Buffer = require('buffer/').Buffer;
711
+
706
712
  function createError({
707
713
  statusCode,
708
714
  message,
@@ -976,7 +982,7 @@ function createQueueMiddleware({
976
982
 
977
983
  var packageJson = {
978
984
  name: "@commercetools/sdk-client-v2",
979
- version: "0.2.0",
985
+ version: "1.1.0",
980
986
  description: "commercetools TypeScript SDK client.",
981
987
  keywords: [
982
988
  "commercetools",
@@ -1005,6 +1011,7 @@ var packageJson = {
1005
1011
  url: "https://github.com/commercetools/commercetools-sdk-typescript/issues"
1006
1012
  },
1007
1013
  dependencies: {
1014
+ buffer: "^6.0.3",
1008
1015
  "node-fetch": "^2.6.1",
1009
1016
  querystring: "^0.2.1"
1010
1017
  },
@@ -1023,9 +1030,9 @@ var packageJson = {
1023
1030
  "abort-controller": "3.0.0",
1024
1031
  "common-tags": "1.8.2",
1025
1032
  dotenv: "10.0.0",
1026
- jest: "27.3.1",
1033
+ jest: "27.4.7",
1027
1034
  nock: "12.0.3",
1028
- "organize-imports-cli": "0.8.0"
1035
+ "organize-imports-cli": "0.9.0"
1029
1036
  },
1030
1037
  scripts: {
1031
1038
  organize_imports: "find src -type f -name '*.ts' | xargs organize-imports-cli",
@@ -1045,8 +1052,11 @@ var packageJson = {
1045
1052
  const isBrowser = () => window.document && window.document.nodeType === 9;
1046
1053
 
1047
1054
  function getSystemInfo() {
1055
+ var _process;
1056
+
1048
1057
  if (isBrowser()) return window.navigator.userAgent;
1049
- const nodeVersion = process.version.slice(1); // const platformInfo = `(${process.platform}; ${process.arch})`
1058
+ const nodeVersion = ((_process = process) === null || _process === void 0 ? void 0 : _process.version.slice(1)) || '12'; // temporary fix for rn environment
1059
+ // const platformInfo = `(${process.platform}; ${process.arch})`
1050
1060
  // return `Node.js/${nodeVersion} ${platformInfo}`
1051
1061
 
1052
1062
  return `node.js/${nodeVersion}`;
@@ -1153,8 +1163,8 @@ class ClientBuilder {
1153
1163
  host: options.host || 'https://auth.europe-west1.gcp.commercetools.com',
1154
1164
  projectKey: options.projectKey || this.projectKey,
1155
1165
  credentials: {
1156
- clientId: process.env.myClientId,
1157
- clientSecret: process.env.myClientSecret,
1166
+ clientId: options.credentials.clientId || '',
1167
+ clientSecret: options.credentials.clientSecret || '',
1158
1168
  user: {
1159
1169
  username: options.credentials.user.username || '',
1160
1170
  password: options.credentials.user.password || ''
@@ -168,6 +168,8 @@ function createClient(options) {
168
168
 
169
169
  // POST https://{host}/oauth/token?grant_type=client_credentials&scope={scope}
170
170
  // Authorization: Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ==
171
+ const Buffer$2 = require('buffer/').Buffer;
172
+
171
173
  function buildRequestForClientCredentialsFlow(options) {
172
174
  if (!options) throw new Error('Missing required options');
173
175
  if (!options.host) throw new Error('Missing required option (host)');
@@ -179,7 +181,7 @@ function buildRequestForClientCredentialsFlow(options) {
179
181
  } = options.credentials;
180
182
  if (!(clientId && clientSecret)) throw new Error('Missing required credentials (clientId, clientSecret)');
181
183
  const scope = options.scopes ? options.scopes.join(' ') : undefined;
182
- const basicAuth = Buffer.from(`${clientId}:${clientSecret}`).toString('base64'); // This is mostly useful for internal testing purposes to be able to check
184
+ const basicAuth = Buffer$2.from(`${clientId}:${clientSecret}`).toString('base64'); // This is mostly useful for internal testing purposes to be able to check
183
185
  // other oauth endpoints.
184
186
 
185
187
  const oauthUri = options.oauthUri || '/oauth/token';
@@ -210,7 +212,7 @@ function buildRequestForPasswordFlow(options) {
210
212
  if (!(username && password)) throw new Error('Missing required user credentials (username, password)');
211
213
  const scope = (options.scopes || []).join(' ');
212
214
  const scopeStr = scope ? `&scope=${scope}` : '';
213
- const basicAuth = Buffer.from(`${clientId}:${clientSecret}`).toString('base64');
215
+ const basicAuth = Buffer$2.from(`${clientId}:${clientSecret}`).toString('base64');
214
216
  /**
215
217
  * This is mostly useful for internal testing purposes to be able to check
216
218
  * other oauth endpoints.
@@ -237,7 +239,7 @@ function buildRequestForRefreshTokenFlow(options) {
237
239
  clientSecret
238
240
  } = options.credentials;
239
241
  if (!(clientId && clientSecret)) throw new Error('Missing required credentials (clientId, clientSecret)');
240
- const basicAuth = Buffer.from(`${clientId}:${clientSecret}`).toString('base64'); // This is mostly useful for internal testing purposes to be able to check
242
+ const basicAuth = Buffer$2.from(`${clientId}:${clientSecret}`).toString('base64'); // This is mostly useful for internal testing purposes to be able to check
241
243
  // other oauth endpoints.
242
244
 
243
245
  const oauthUri = options.oauthUri || '/oauth/token';
@@ -260,6 +262,8 @@ function buildRequestForAnonymousSessionFlow(options) {
260
262
  };
261
263
  }
262
264
 
265
+ const Buffer$1 = require('buffer/').Buffer;
266
+
263
267
  function mergeAuthHeader(token, req) {
264
268
  return { ...req,
265
269
  headers: { ...req.headers,
@@ -289,7 +293,7 @@ async function executeRequest({
289
293
  method: 'POST',
290
294
  headers: {
291
295
  Authorization: `Basic ${basicAuth}`,
292
- 'Content-Length': Buffer.byteLength(body).toString(),
296
+ 'Content-Length': Buffer$1.byteLength(body).toString(),
293
297
  'Content-Type': 'application/x-www-form-urlencoded'
294
298
  },
295
299
  body
@@ -694,6 +698,8 @@ function parseHeaders(headers) {
694
698
  return map;
695
699
  }
696
700
 
701
+ const Buffer = require('buffer/').Buffer;
702
+
697
703
  function createError({
698
704
  statusCode,
699
705
  message,
@@ -967,7 +973,7 @@ function createQueueMiddleware({
967
973
 
968
974
  var packageJson = {
969
975
  name: "@commercetools/sdk-client-v2",
970
- version: "0.2.0",
976
+ version: "1.1.0",
971
977
  description: "commercetools TypeScript SDK client.",
972
978
  keywords: [
973
979
  "commercetools",
@@ -996,6 +1002,7 @@ var packageJson = {
996
1002
  url: "https://github.com/commercetools/commercetools-sdk-typescript/issues"
997
1003
  },
998
1004
  dependencies: {
1005
+ buffer: "^6.0.3",
999
1006
  "node-fetch": "^2.6.1",
1000
1007
  querystring: "^0.2.1"
1001
1008
  },
@@ -1014,9 +1021,9 @@ var packageJson = {
1014
1021
  "abort-controller": "3.0.0",
1015
1022
  "common-tags": "1.8.2",
1016
1023
  dotenv: "10.0.0",
1017
- jest: "27.3.1",
1024
+ jest: "27.4.7",
1018
1025
  nock: "12.0.3",
1019
- "organize-imports-cli": "0.8.0"
1026
+ "organize-imports-cli": "0.9.0"
1020
1027
  },
1021
1028
  scripts: {
1022
1029
  organize_imports: "find src -type f -name '*.ts' | xargs organize-imports-cli",
@@ -1036,8 +1043,11 @@ var packageJson = {
1036
1043
  const isBrowser = () => window.document && window.document.nodeType === 9;
1037
1044
 
1038
1045
  function getSystemInfo() {
1046
+ var _process;
1047
+
1039
1048
  if (isBrowser()) return window.navigator.userAgent;
1040
- const nodeVersion = process.version.slice(1); // const platformInfo = `(${process.platform}; ${process.arch})`
1049
+ const nodeVersion = ((_process = process) === null || _process === void 0 ? void 0 : _process.version.slice(1)) || '12'; // temporary fix for rn environment
1050
+ // const platformInfo = `(${process.platform}; ${process.arch})`
1041
1051
  // return `Node.js/${nodeVersion} ${platformInfo}`
1042
1052
 
1043
1053
  return `node.js/${nodeVersion}`;
@@ -1144,8 +1154,8 @@ class ClientBuilder {
1144
1154
  host: options.host || 'https://auth.europe-west1.gcp.commercetools.com',
1145
1155
  projectKey: options.projectKey || this.projectKey,
1146
1156
  credentials: {
1147
- clientId: process.env.myClientId,
1148
- clientSecret: process.env.myClientSecret,
1157
+ clientId: options.credentials.clientId || '',
1158
+ clientSecret: options.credentials.clientSecret || '',
1149
1159
  user: {
1150
1160
  username: options.credentials.user.username || '',
1151
1161
  password: options.credentials.user.password || ''
@@ -177,6 +177,8 @@ function createClient(options) {
177
177
 
178
178
  // POST https://{host}/oauth/token?grant_type=client_credentials&scope={scope}
179
179
  // Authorization: Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ==
180
+ const Buffer$2 = require('buffer/').Buffer;
181
+
180
182
  function buildRequestForClientCredentialsFlow(options) {
181
183
  if (!options) throw new Error('Missing required options');
182
184
  if (!options.host) throw new Error('Missing required option (host)');
@@ -188,7 +190,7 @@ function buildRequestForClientCredentialsFlow(options) {
188
190
  } = options.credentials;
189
191
  if (!(clientId && clientSecret)) throw new Error('Missing required credentials (clientId, clientSecret)');
190
192
  const scope = options.scopes ? options.scopes.join(' ') : undefined;
191
- const basicAuth = Buffer.from(`${clientId}:${clientSecret}`).toString('base64'); // This is mostly useful for internal testing purposes to be able to check
193
+ const basicAuth = Buffer$2.from(`${clientId}:${clientSecret}`).toString('base64'); // This is mostly useful for internal testing purposes to be able to check
192
194
  // other oauth endpoints.
193
195
 
194
196
  const oauthUri = options.oauthUri || '/oauth/token';
@@ -219,7 +221,7 @@ function buildRequestForPasswordFlow(options) {
219
221
  if (!(username && password)) throw new Error('Missing required user credentials (username, password)');
220
222
  const scope = (options.scopes || []).join(' ');
221
223
  const scopeStr = scope ? `&scope=${scope}` : '';
222
- const basicAuth = Buffer.from(`${clientId}:${clientSecret}`).toString('base64');
224
+ const basicAuth = Buffer$2.from(`${clientId}:${clientSecret}`).toString('base64');
223
225
  /**
224
226
  * This is mostly useful for internal testing purposes to be able to check
225
227
  * other oauth endpoints.
@@ -246,7 +248,7 @@ function buildRequestForRefreshTokenFlow(options) {
246
248
  clientSecret
247
249
  } = options.credentials;
248
250
  if (!(clientId && clientSecret)) throw new Error('Missing required credentials (clientId, clientSecret)');
249
- const basicAuth = Buffer.from(`${clientId}:${clientSecret}`).toString('base64'); // This is mostly useful for internal testing purposes to be able to check
251
+ const basicAuth = Buffer$2.from(`${clientId}:${clientSecret}`).toString('base64'); // This is mostly useful for internal testing purposes to be able to check
250
252
  // other oauth endpoints.
251
253
 
252
254
  const oauthUri = options.oauthUri || '/oauth/token';
@@ -269,6 +271,8 @@ function buildRequestForAnonymousSessionFlow(options) {
269
271
  };
270
272
  }
271
273
 
274
+ const Buffer$1 = require('buffer/').Buffer;
275
+
272
276
  function mergeAuthHeader(token, req) {
273
277
  return { ...req,
274
278
  headers: { ...req.headers,
@@ -298,7 +302,7 @@ async function executeRequest({
298
302
  method: 'POST',
299
303
  headers: {
300
304
  Authorization: `Basic ${basicAuth}`,
301
- 'Content-Length': Buffer.byteLength(body).toString(),
305
+ 'Content-Length': Buffer$1.byteLength(body).toString(),
302
306
  'Content-Type': 'application/x-www-form-urlencoded'
303
307
  },
304
308
  body
@@ -703,6 +707,8 @@ function parseHeaders(headers) {
703
707
  return map;
704
708
  }
705
709
 
710
+ const Buffer = require('buffer/').Buffer;
711
+
706
712
  function createError({
707
713
  statusCode,
708
714
  message,
@@ -976,7 +982,7 @@ function createQueueMiddleware({
976
982
 
977
983
  var packageJson = {
978
984
  name: "@commercetools/sdk-client-v2",
979
- version: "0.2.0",
985
+ version: "1.1.0",
980
986
  description: "commercetools TypeScript SDK client.",
981
987
  keywords: [
982
988
  "commercetools",
@@ -1005,6 +1011,7 @@ var packageJson = {
1005
1011
  url: "https://github.com/commercetools/commercetools-sdk-typescript/issues"
1006
1012
  },
1007
1013
  dependencies: {
1014
+ buffer: "^6.0.3",
1008
1015
  "node-fetch": "^2.6.1",
1009
1016
  querystring: "^0.2.1"
1010
1017
  },
@@ -1023,9 +1030,9 @@ var packageJson = {
1023
1030
  "abort-controller": "3.0.0",
1024
1031
  "common-tags": "1.8.2",
1025
1032
  dotenv: "10.0.0",
1026
- jest: "27.3.1",
1033
+ jest: "27.4.7",
1027
1034
  nock: "12.0.3",
1028
- "organize-imports-cli": "0.8.0"
1035
+ "organize-imports-cli": "0.9.0"
1029
1036
  },
1030
1037
  scripts: {
1031
1038
  organize_imports: "find src -type f -name '*.ts' | xargs organize-imports-cli",
@@ -1045,8 +1052,11 @@ var packageJson = {
1045
1052
  const isBrowser = () => typeof window !== 'undefined' && window.document && window.document.nodeType === 9;
1046
1053
 
1047
1054
  function getSystemInfo() {
1055
+ var _process;
1056
+
1048
1057
  if (isBrowser()) return window.navigator.userAgent;
1049
- const nodeVersion = process.version.slice(1); // const platformInfo = `(${process.platform}; ${process.arch})`
1058
+ const nodeVersion = ((_process = process) === null || _process === void 0 ? void 0 : _process.version.slice(1)) || '12'; // temporary fix for rn environment
1059
+ // const platformInfo = `(${process.platform}; ${process.arch})`
1050
1060
  // return `Node.js/${nodeVersion} ${platformInfo}`
1051
1061
 
1052
1062
  return `node.js/${nodeVersion}`;
@@ -1153,8 +1163,8 @@ class ClientBuilder {
1153
1163
  host: options.host || 'https://auth.europe-west1.gcp.commercetools.com',
1154
1164
  projectKey: options.projectKey || this.projectKey,
1155
1165
  credentials: {
1156
- clientId: process.env.myClientId,
1157
- clientSecret: process.env.myClientSecret,
1166
+ clientId: options.credentials.clientId || '',
1167
+ clientSecret: options.credentials.clientSecret || '',
1158
1168
  user: {
1159
1169
  username: options.credentials.user.username || '',
1160
1170
  password: options.credentials.user.password || ''