@devite/shopware-client 1.7.2 → 1.7.4

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/dist/index.cjs CHANGED
@@ -141,7 +141,7 @@ class ShopwareClient {
141
141
  body: await this.parseBody(response)
142
142
  });
143
143
  }
144
- })
144
+ }).catch(() => void 0)
145
145
  );
146
146
  }
147
147
  async parseBody(response) {
@@ -164,6 +164,14 @@ class ShopwareClient {
164
164
  }
165
165
  }
166
166
 
167
+ class ShopwareError extends Error {
168
+ response;
169
+ constructor(message, response) {
170
+ super(message + ": " + response.statusCode + " " + response.statusMessage);
171
+ this.response = response;
172
+ }
173
+ }
174
+
167
175
  var AuthenticationType = /* @__PURE__ */ ((AuthenticationType2) => {
168
176
  AuthenticationType2["CONTEXT_TOKEN"] = "context_token";
169
177
  AuthenticationType2["OAUTH"] = "oauth";
@@ -252,14 +260,6 @@ class Client {
252
260
  }
253
261
  }
254
262
 
255
- class ShopwareError extends Error {
256
- response;
257
- constructor(message, response) {
258
- super(message + ": " + response.statusCode + " " + response.statusMessage);
259
- this.response = response;
260
- }
261
- }
262
-
263
263
  function buildQuery(criteria) {
264
264
  return criteria ? `?${qs.stringify(criteria, { encode: false })}` : "";
265
265
  }
@@ -1290,6 +1290,8 @@ class AdminShopwareClient extends ShopwareClient {
1290
1290
  client_secret: clientSecret
1291
1291
  })
1292
1292
  });
1293
+ if (authResponse.statusCode !== 200)
1294
+ throw new ShopwareError("Authentication as client failed", authResponse);
1293
1295
  this.authStore.getOrCreateEntry(new OAuthEntry()).save(authResponse);
1294
1296
  }
1295
1297
  async authenticateAsUser(username, password, scopes) {
@@ -1304,6 +1306,8 @@ class AdminShopwareClient extends ShopwareClient {
1304
1306
  password
1305
1307
  })
1306
1308
  });
1309
+ if (authResponse.statusCode !== 200)
1310
+ throw new ShopwareError("Authentication as user failed", authResponse);
1307
1311
  this.authStore.getOrCreateEntry(new OAuthEntry()).save(authResponse);
1308
1312
  }
1309
1313
  async withOAuth(options = {}) {
package/dist/index.mjs CHANGED
@@ -139,7 +139,7 @@ class ShopwareClient {
139
139
  body: await this.parseBody(response)
140
140
  });
141
141
  }
142
- })
142
+ }).catch(() => void 0)
143
143
  );
144
144
  }
145
145
  async parseBody(response) {
@@ -162,6 +162,14 @@ class ShopwareClient {
162
162
  }
163
163
  }
164
164
 
165
+ class ShopwareError extends Error {
166
+ response;
167
+ constructor(message, response) {
168
+ super(message + ": " + response.statusCode + " " + response.statusMessage);
169
+ this.response = response;
170
+ }
171
+ }
172
+
165
173
  var AuthenticationType = /* @__PURE__ */ ((AuthenticationType2) => {
166
174
  AuthenticationType2["CONTEXT_TOKEN"] = "context_token";
167
175
  AuthenticationType2["OAUTH"] = "oauth";
@@ -250,14 +258,6 @@ class Client {
250
258
  }
251
259
  }
252
260
 
253
- class ShopwareError extends Error {
254
- response;
255
- constructor(message, response) {
256
- super(message + ": " + response.statusCode + " " + response.statusMessage);
257
- this.response = response;
258
- }
259
- }
260
-
261
261
  function buildQuery(criteria) {
262
262
  return criteria ? `?${stringify(criteria, { encode: false })}` : "";
263
263
  }
@@ -1288,6 +1288,8 @@ class AdminShopwareClient extends ShopwareClient {
1288
1288
  client_secret: clientSecret
1289
1289
  })
1290
1290
  });
1291
+ if (authResponse.statusCode !== 200)
1292
+ throw new ShopwareError("Authentication as client failed", authResponse);
1291
1293
  this.authStore.getOrCreateEntry(new OAuthEntry()).save(authResponse);
1292
1294
  }
1293
1295
  async authenticateAsUser(username, password, scopes) {
@@ -1302,6 +1304,8 @@ class AdminShopwareClient extends ShopwareClient {
1302
1304
  password
1303
1305
  })
1304
1306
  });
1307
+ if (authResponse.statusCode !== 200)
1308
+ throw new ShopwareError("Authentication as user failed", authResponse);
1305
1309
  this.authStore.getOrCreateEntry(new OAuthEntry()).save(authResponse);
1306
1310
  }
1307
1311
  async withOAuth(options = {}) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@devite/shopware-client",
3
- "version": "1.7.2",
3
+ "version": "1.7.4",
4
4
  "description": "Third party API client for Shopware 6.",
5
5
  "repository": "devite-io/shopware-client",
6
6
  "license": "MIT",