@friendsofshopware/app-server-sdk
Advanced tools
Comparing version 0.0.38 to 0.0.39
@@ -16,7 +16,7 @@ export class Registration { | ||
!url.searchParams.has("timestamp")) { | ||
throw new Error("Invalid Request"); | ||
return new InvalidRequestResponse('Invalid Request'); | ||
} | ||
const v = await this.app.signer.verify(req.headers.get("shopware-app-signature"), `shop-id=${url.searchParams.get("shop-id")}&shop-url=${url.searchParams.get("shop-url")}×tamp=${url.searchParams.get("timestamp")}`, this.app.cfg.appSecret); | ||
if (!v) { | ||
throw new Error("Cannot validate app signature"); | ||
return new InvalidRequestResponse('Cannot validate app signature'); | ||
} | ||
@@ -41,7 +41,7 @@ const shop = this.app.repository.createShopStruct(url.searchParams.get("shop-id"), url.searchParams.get("shop-url"), randomString()); | ||
!req.headers.has("shopware-shop-signature")) { | ||
throw new Error("Invalid Request"); | ||
return new InvalidRequestResponse('Invalid Request'); | ||
} | ||
const shop = await this.app.repository.getShopById(body.shopId); | ||
if (shop === null) { | ||
throw new Error(`Cannot find shop for this id: ${body.shopId}`); | ||
return new InvalidRequestResponse('Invalid shop given'); | ||
} | ||
@@ -52,3 +52,3 @@ const v = await this.app.signer.verify(req.headers.get("shopware-shop-signature"), bodyContent, shop.getShopSecret()); | ||
await this.app.repository.deleteShop(shop.getShopId()); | ||
throw new Error("Cannot validate app signature"); | ||
return new InvalidRequestResponse('Cannot validate app signature'); | ||
} | ||
@@ -64,1 +64,11 @@ shop.setShopCredentials(body.apiKey, body.secretKey); | ||
} | ||
class InvalidRequestResponse extends Response { | ||
constructor(message, status = 401) { | ||
super(JSON.stringify({ message }), { | ||
status, | ||
headers: { | ||
"content-type": "application/json", | ||
}, | ||
}); | ||
} | ||
} |
{ | ||
"module": "./esm/mod.js", | ||
"types": "./types/mod.d.ts", | ||
"name": "@friendsofshopware/app-server-sdk", | ||
"version": "0.0.38", | ||
"version": "0.0.39", | ||
"description": "Shopware App Server SDK", | ||
@@ -26,8 +25,5 @@ "keywords": [ | ||
".": { | ||
"import": { | ||
"types": "./types/mod.d.ts", | ||
"default": "./esm/mod.js" | ||
} | ||
"import": "./esm/mod.js" | ||
} | ||
} | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
24682
625