@shopware-ag/app-server-sdk 1.1.0 → 1.1.2
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/commonjs/helper/admin-api.d.ts +56 -0
- package/dist/commonjs/helper/admin-api.d.ts.map +1 -0
- package/dist/commonjs/helper/admin-api.js +126 -0
- package/dist/commonjs/helper/admin-api.js.map +1 -0
- package/dist/commonjs/helper/criteria.d.ts +377 -0
- package/dist/commonjs/helper/criteria.d.ts.map +1 -0
- package/dist/commonjs/helper/criteria.js +456 -0
- package/dist/commonjs/helper/criteria.js.map +1 -0
- package/dist/commonjs/http-client.js +2 -1
- package/dist/commonjs/http-client.js.map +1 -1
- package/dist/commonjs/integration/better-sqlite3.d.ts +11 -0
- package/dist/commonjs/integration/better-sqlite3.d.ts.map +1 -0
- package/dist/commonjs/integration/better-sqlite3.js +58 -0
- package/dist/commonjs/integration/better-sqlite3.js.map +1 -0
- package/dist/esm/helper/admin-api.d.ts +56 -0
- package/dist/esm/helper/admin-api.d.ts.map +1 -0
- package/dist/esm/helper/admin-api.js +117 -0
- package/dist/esm/helper/admin-api.js.map +1 -0
- package/dist/esm/helper/criteria.d.ts +377 -0
- package/dist/esm/helper/criteria.d.ts.map +1 -0
- package/dist/esm/helper/criteria.js +452 -0
- package/dist/esm/helper/criteria.js.map +1 -0
- package/dist/esm/http-client.js +2 -1
- package/dist/esm/http-client.js.map +1 -1
- package/dist/esm/integration/better-sqlite3.d.ts +11 -0
- package/dist/esm/integration/better-sqlite3.d.ts.map +1 -0
- package/dist/esm/integration/better-sqlite3.js +51 -0
- package/dist/esm/integration/better-sqlite3.js.map +1 -0
- package/package.json +206 -141
- package/dist/commonjs/context-resolver.test.d.ts +0 -2
- package/dist/commonjs/context-resolver.test.d.ts.map +0 -1
- package/dist/commonjs/context-resolver.test.js +0 -81
- package/dist/commonjs/context-resolver.test.js.map +0 -1
- package/dist/commonjs/helper/app-actions.test.d.ts +0 -2
- package/dist/commonjs/helper/app-actions.test.d.ts.map +0 -1
- package/dist/commonjs/helper/app-actions.test.js +0 -31
- package/dist/commonjs/helper/app-actions.test.js.map +0 -1
- package/dist/commonjs/http-client.test.d.ts +0 -2
- package/dist/commonjs/http-client.test.d.ts.map +0 -1
- package/dist/commonjs/http-client.test.js +0 -71
- package/dist/commonjs/http-client.test.js.map +0 -1
- package/dist/commonjs/integration/bun-sqlite.test.d.ts +0 -2
- package/dist/commonjs/integration/bun-sqlite.test.d.ts.map +0 -1
- package/dist/commonjs/integration/bun-sqlite.test.js +0 -24
- package/dist/commonjs/integration/bun-sqlite.test.js.map +0 -1
- package/dist/commonjs/integration/cloudflare.test.d.ts +0 -2
- package/dist/commonjs/integration/cloudflare.test.d.ts.map +0 -1
- package/dist/commonjs/integration/cloudflare.test.js +0 -39
- package/dist/commonjs/integration/cloudflare.test.js.map +0 -1
- package/dist/commonjs/integration/deno.test.d.ts +0 -2
- package/dist/commonjs/integration/deno.test.d.ts.map +0 -1
- package/dist/commonjs/integration/deno.test.js +0 -48
- package/dist/commonjs/integration/deno.test.js.map +0 -1
- package/dist/commonjs/integration/dynamodb.test.d.ts +0 -2
- package/dist/commonjs/integration/dynamodb.test.d.ts.map +0 -1
- package/dist/commonjs/integration/dynamodb.test.js +0 -132
- package/dist/commonjs/integration/dynamodb.test.js.map +0 -1
- package/dist/commonjs/integration/hono.test.d.ts +0 -2
- package/dist/commonjs/integration/hono.test.d.ts.map +0 -1
- package/dist/commonjs/integration/hono.test.js +0 -86
- package/dist/commonjs/integration/hono.test.js.map +0 -1
- package/dist/commonjs/registration.test.d.ts +0 -2
- package/dist/commonjs/registration.test.d.ts.map +0 -1
- package/dist/commonjs/registration.test.js +0 -59
- package/dist/commonjs/registration.test.js.map +0 -1
- package/dist/commonjs/repository.test.d.ts +0 -2
- package/dist/commonjs/repository.test.d.ts.map +0 -1
- package/dist/commonjs/repository.test.js +0 -32
- package/dist/commonjs/repository.test.js.map +0 -1
- package/dist/commonjs/signer.test.d.ts +0 -2
- package/dist/commonjs/signer.test.d.ts.map +0 -1
- package/dist/commonjs/signer.test.js +0 -25
- package/dist/commonjs/signer.test.js.map +0 -1
- package/dist/esm/context-resolver.test.d.ts +0 -2
- package/dist/esm/context-resolver.test.d.ts.map +0 -1
- package/dist/esm/context-resolver.test.js +0 -79
- package/dist/esm/context-resolver.test.js.map +0 -1
- package/dist/esm/helper/app-actions.test.d.ts +0 -2
- package/dist/esm/helper/app-actions.test.d.ts.map +0 -1
- package/dist/esm/helper/app-actions.test.js +0 -29
- package/dist/esm/helper/app-actions.test.js.map +0 -1
- package/dist/esm/http-client.test.d.ts +0 -2
- package/dist/esm/http-client.test.d.ts.map +0 -1
- package/dist/esm/http-client.test.js +0 -69
- package/dist/esm/http-client.test.js.map +0 -1
- package/dist/esm/integration/bun-sqlite.test.d.ts +0 -2
- package/dist/esm/integration/bun-sqlite.test.d.ts.map +0 -1
- package/dist/esm/integration/bun-sqlite.test.js +0 -22
- package/dist/esm/integration/bun-sqlite.test.js.map +0 -1
- package/dist/esm/integration/cloudflare.test.d.ts +0 -2
- package/dist/esm/integration/cloudflare.test.d.ts.map +0 -1
- package/dist/esm/integration/cloudflare.test.js +0 -37
- package/dist/esm/integration/cloudflare.test.js.map +0 -1
- package/dist/esm/integration/deno.test.d.ts +0 -2
- package/dist/esm/integration/deno.test.d.ts.map +0 -1
- package/dist/esm/integration/deno.test.js +0 -46
- package/dist/esm/integration/deno.test.js.map +0 -1
- package/dist/esm/integration/dynamodb.test.d.ts +0 -2
- package/dist/esm/integration/dynamodb.test.d.ts.map +0 -1
- package/dist/esm/integration/dynamodb.test.js +0 -130
- package/dist/esm/integration/dynamodb.test.js.map +0 -1
- package/dist/esm/integration/hono.test.d.ts +0 -2
- package/dist/esm/integration/hono.test.d.ts.map +0 -1
- package/dist/esm/integration/hono.test.js +0 -84
- package/dist/esm/integration/hono.test.js.map +0 -1
- package/dist/esm/registration.test.d.ts +0 -2
- package/dist/esm/registration.test.d.ts.map +0 -1
- package/dist/esm/registration.test.js +0 -57
- package/dist/esm/registration.test.js.map +0 -1
- package/dist/esm/repository.test.d.ts +0 -2
- package/dist/esm/repository.test.d.ts.map +0 -1
- package/dist/esm/repository.test.js +0 -30
- package/dist/esm/repository.test.js.map +0 -1
- package/dist/esm/signer.test.d.ts +0 -2
- package/dist/esm/signer.test.d.ts.map +0 -1
- package/dist/esm/signer.test.js +0 -23
- package/dist/esm/signer.test.js.map +0 -1
|
@@ -1,84 +0,0 @@
|
|
|
1
|
-
import { describe, expect, test } from "bun:test";
|
|
2
|
-
import { Hono } from "hono";
|
|
3
|
-
import { InMemoryShopRepository } from "../repository.js";
|
|
4
|
-
import { configureAppServer } from "./hono.js";
|
|
5
|
-
describe("Hono", async () => {
|
|
6
|
-
const repo = new InMemoryShopRepository();
|
|
7
|
-
await repo.createShop("a", "a", "a");
|
|
8
|
-
test("configre by functions", async () => {
|
|
9
|
-
const hono = new Hono();
|
|
10
|
-
configureAppServer(hono, {
|
|
11
|
-
appName: () => "test",
|
|
12
|
-
appSecret: () => "test",
|
|
13
|
-
shopRepository: () => repo,
|
|
14
|
-
});
|
|
15
|
-
const resp = await hono.fetch(new Request("http://localhost/app/register"));
|
|
16
|
-
expect(resp.status).toBe(400);
|
|
17
|
-
});
|
|
18
|
-
test("register", async () => {
|
|
19
|
-
const hono = new Hono();
|
|
20
|
-
configureAppServer(hono, {
|
|
21
|
-
appName: "test",
|
|
22
|
-
appSecret: "test",
|
|
23
|
-
shopRepository: repo,
|
|
24
|
-
});
|
|
25
|
-
const resp = await hono.fetch(new Request("http://localhost/app/register"));
|
|
26
|
-
expect(resp.status).toBe(400);
|
|
27
|
-
});
|
|
28
|
-
test("register: success", async () => {
|
|
29
|
-
const hono = new Hono();
|
|
30
|
-
configureAppServer(hono, {
|
|
31
|
-
appName: "My App",
|
|
32
|
-
appSecret: "my-secret",
|
|
33
|
-
shopRepository: repo,
|
|
34
|
-
});
|
|
35
|
-
const resp = await hono.fetch(new Request("http://localhost/app/register?shop-id=123&shop-url=https://my-shop.com×tamp=1234567890", {
|
|
36
|
-
headers: new Headers({
|
|
37
|
-
"shopware-app-signature": "96c91f86c822e11444b7a57b54ef125ed86b1a639c5360d45c5397daa8c3f70b",
|
|
38
|
-
}),
|
|
39
|
-
}));
|
|
40
|
-
expect(resp.status).toBe(200);
|
|
41
|
-
const body = (await resp.json());
|
|
42
|
-
expect(body).toBeObject();
|
|
43
|
-
expect(body.proof).not.toBeNull();
|
|
44
|
-
});
|
|
45
|
-
test("registerConfirm", async () => {
|
|
46
|
-
const hono = new Hono();
|
|
47
|
-
configureAppServer(hono, {
|
|
48
|
-
appName: "test",
|
|
49
|
-
appSecret: "test",
|
|
50
|
-
shopRepository: repo,
|
|
51
|
-
});
|
|
52
|
-
const resp = await hono.fetch(new Request("http://localhost/app/register/confirm", {
|
|
53
|
-
method: "POST",
|
|
54
|
-
body: "{}",
|
|
55
|
-
}));
|
|
56
|
-
expect(resp.status).toBe(400);
|
|
57
|
-
});
|
|
58
|
-
test("signature failure", async () => {
|
|
59
|
-
const hono = new Hono();
|
|
60
|
-
configureAppServer(hono, {
|
|
61
|
-
appName: "test",
|
|
62
|
-
appSecret: "test",
|
|
63
|
-
shopRepository: repo,
|
|
64
|
-
});
|
|
65
|
-
hono.get("/app/test", (c) => c.text("ok"));
|
|
66
|
-
const resp = await hono.fetch(new Request("http://localhost/app/test?shopware-shop-signature=invalid&shop-id=a"));
|
|
67
|
-
expect(resp.status).toBe(400);
|
|
68
|
-
expect(await resp.text()).toBe('{"message":"Invalid request"}');
|
|
69
|
-
});
|
|
70
|
-
test("signature success", async () => {
|
|
71
|
-
const hono = new Hono();
|
|
72
|
-
configureAppServer(hono, {
|
|
73
|
-
appName: "test",
|
|
74
|
-
appSecret: "test",
|
|
75
|
-
shopRepository: repo,
|
|
76
|
-
});
|
|
77
|
-
hono.get("/app/test", (c) => c.text("ok"));
|
|
78
|
-
const resp = await hono.fetch(new Request("http://localhost/app/test?shopware-shop-signature=8b523d99aeef5b456288fcec48236c3367a914c6b2c9fded63d81257ac019b25&shop-id=a"));
|
|
79
|
-
expect(resp.status).toBe(200);
|
|
80
|
-
expect(await resp.text()).toBe("ok");
|
|
81
|
-
expect(resp.headers.get("shopware-app-signature")).toBe("4a43a105ccce57e8e38d4a1f7b3565d743b1e15fb1fec36f41fdf20164fa1c8b");
|
|
82
|
-
});
|
|
83
|
-
});
|
|
84
|
-
//# sourceMappingURL=hono.test.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"hono.test.js","sourceRoot":"","sources":["../../../src/integration/hono.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,UAAU,CAAC;AAClD,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAC5B,OAAO,EAAE,sBAAsB,EAAE,MAAM,kBAAkB,CAAC;AAC1D,OAAO,EAAE,kBAAkB,EAAE,MAAM,WAAW,CAAC;AAE/C,QAAQ,CAAC,MAAM,EAAE,KAAK,IAAI,EAAE;IAC3B,MAAM,IAAI,GAAG,IAAI,sBAAsB,EAAE,CAAC;IAE1C,MAAM,IAAI,CAAC,UAAU,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC;IAErC,IAAI,CAAC,uBAAuB,EAAE,KAAK,IAAI,EAAE;QACxC,MAAM,IAAI,GAAG,IAAI,IAAI,EAAE,CAAC;QAExB,kBAAkB,CAAC,IAAI,EAAE;YACxB,OAAO,EAAE,GAAG,EAAE,CAAC,MAAM;YACrB,SAAS,EAAE,GAAG,EAAE,CAAC,MAAM;YACvB,cAAc,EAAE,GAAG,EAAE,CAAC,IAAI;SAC1B,CAAC,CAAC;QAEH,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,KAAK,CAAC,IAAI,OAAO,CAAC,+BAA+B,CAAC,CAAC,CAAC;QAE5E,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC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MAAM;YACf,SAAS,EAAE,MAAM;YACjB,cAAc,EAAE,IAAI;SACpB,CAAC,CAAC;QAEH,IAAI,CAAC,GAAG,CAAC,WAAW,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;QAE3C,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,KAAK,CAC5B,IAAI,OAAO,CACV,8HAA8H,CAC9H,CACD,CAAC;QAEF,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;QAC9B,MAAM,CAAC,MAAM,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACrC,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,wBAAwB,CAAC,CAAC,CAAC,IAAI,CACtD,kEAAkE,CAClE,CAAC;IACH,CAAC,CAAC,CAAC;AACJ,CAAC,CAAC,CAAC","sourcesContent":["import { describe, expect, test } from \"bun:test\";\nimport { Hono } from \"hono\";\nimport { InMemoryShopRepository } from \"../repository.js\";\nimport { configureAppServer } from \"./hono.js\";\n\ndescribe(\"Hono\", async () => {\n\tconst repo = new InMemoryShopRepository();\n\n\tawait repo.createShop(\"a\", \"a\", \"a\");\n\n\ttest(\"configre by functions\", async () => {\n\t\tconst hono = new Hono();\n\n\t\tconfigureAppServer(hono, {\n\t\t\tappName: () => \"test\",\n\t\t\tappSecret: () => \"test\",\n\t\t\tshopRepository: () => repo,\n\t\t});\n\n\t\tconst resp = await hono.fetch(new Request(\"http://localhost/app/register\"));\n\n\t\texpect(resp.status).toBe(400);\n\t});\n\n\ttest(\"register\", async () => {\n\t\tconst hono = new Hono();\n\n\t\tconfigureAppServer(hono, {\n\t\t\tappName: \"test\",\n\t\t\tappSecret: \"test\",\n\t\t\tshopRepository: repo,\n\t\t});\n\n\t\tconst resp = await hono.fetch(new Request(\"http://localhost/app/register\"));\n\n\t\texpect(resp.status).toBe(400);\n\t});\n\n\ttest(\"register: success\", async () => {\n\t\tconst hono = new Hono();\n\n\t\tconfigureAppServer(hono, {\n\t\t\tappName: \"My App\",\n\t\t\tappSecret: \"my-secret\",\n\t\t\tshopRepository: repo,\n\t\t});\n\n\t\tconst resp = await hono.fetch(\n\t\t\tnew Request(\n\t\t\t\t\"http://localhost/app/register?shop-id=123&shop-url=https://my-shop.com×tamp=1234567890\",\n\t\t\t\t{\n\t\t\t\t\theaders: new Headers({\n\t\t\t\t\t\t\"shopware-app-signature\":\n\t\t\t\t\t\t\t\"96c91f86c822e11444b7a57b54ef125ed86b1a639c5360d45c5397daa8c3f70b\",\n\t\t\t\t\t}),\n\t\t\t\t},\n\t\t\t),\n\t\t);\n\n\t\texpect(resp.status).toBe(200);\n\n\t\tconst body = (await resp.json()) as { proof: string };\n\n\t\texpect(body).toBeObject();\n\n\t\texpect(body.proof).not.toBeNull();\n\t});\n\n\ttest(\"registerConfirm\", async () => {\n\t\tconst hono = new Hono();\n\n\t\tconfigureAppServer(hono, {\n\t\t\tappName: \"test\",\n\t\t\tappSecret: \"test\",\n\t\t\tshopRepository: repo,\n\t\t});\n\n\t\tconst resp = await hono.fetch(\n\t\t\tnew Request(\"http://localhost/app/register/confirm\", {\n\t\t\t\tmethod: \"POST\",\n\t\t\t\tbody: \"{}\",\n\t\t\t}),\n\t\t);\n\n\t\texpect(resp.status).toBe(400);\n\t});\n\n\ttest(\"signature failure\", async () => {\n\t\tconst hono = new Hono();\n\n\t\tconfigureAppServer(hono, {\n\t\t\tappName: \"test\",\n\t\t\tappSecret: \"test\",\n\t\t\tshopRepository: repo,\n\t\t});\n\n\t\thono.get(\"/app/test\", (c) => c.text(\"ok\"));\n\n\t\tconst resp = await hono.fetch(\n\t\t\tnew Request(\n\t\t\t\t\"http://localhost/app/test?shopware-shop-signature=invalid&shop-id=a\",\n\t\t\t),\n\t\t);\n\n\t\texpect(resp.status).toBe(400);\n\t\texpect(await resp.text()).toBe('{\"message\":\"Invalid request\"}');\n\t});\n\n\ttest(\"signature success\", async () => {\n\t\tconst hono = new Hono();\n\n\t\tconfigureAppServer(hono, {\n\t\t\tappName: \"test\",\n\t\t\tappSecret: \"test\",\n\t\t\tshopRepository: repo,\n\t\t});\n\n\t\thono.get(\"/app/test\", (c) => c.text(\"ok\"));\n\n\t\tconst resp = await hono.fetch(\n\t\t\tnew Request(\n\t\t\t\t\"http://localhost/app/test?shopware-shop-signature=8b523d99aeef5b456288fcec48236c3367a914c6b2c9fded63d81257ac019b25&shop-id=a\",\n\t\t\t),\n\t\t);\n\n\t\texpect(resp.status).toBe(200);\n\t\texpect(await resp.text()).toBe(\"ok\");\n\t\texpect(resp.headers.get(\"shopware-app-signature\")).toBe(\n\t\t\t\"4a43a105ccce57e8e38d4a1f7b3565d743b1e15fb1fec36f41fdf20164fa1c8b\",\n\t\t);\n\t});\n});\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"registration.test.d.ts","sourceRoot":"","sources":["../../src/registration.test.ts"],"names":[],"mappings":""}
|
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
import { describe, expect, jest, test } from "bun:test";
|
|
2
|
-
import { AppServer } from "../src/app.js";
|
|
3
|
-
import { InMemoryShopRepository } from "../src/repository.js";
|
|
4
|
-
describe("Registration", async () => {
|
|
5
|
-
const app = new AppServer({ appName: "test", appSecret: "test", authorizeCallbackUrl: "test" }, new InMemoryShopRepository());
|
|
6
|
-
test("authorize: invalid request", async () => {
|
|
7
|
-
const resp = await app.registration.authorize(new Request("http://localhost"));
|
|
8
|
-
expect(resp.status).toBe(400);
|
|
9
|
-
});
|
|
10
|
-
test("authorize: invalid signature", async () => {
|
|
11
|
-
const resp = await app.registration.authorize(new Request("http://localhost?shop-url=test&shop-id=test×tamp=test", { headers: new Headers({ "shopware-app-signature": "test" }) }));
|
|
12
|
-
expect(resp.status).toBe(401);
|
|
13
|
-
});
|
|
14
|
-
test("authorize: valid request", async () => {
|
|
15
|
-
app.signer.verify = jest.fn().mockResolvedValue(true);
|
|
16
|
-
const resp = await app.registration.authorize(new Request("http://localhost?shop-url=test&shop-id=test×tamp=test", { headers: new Headers({ "shopware-app-signature": "test" }) }));
|
|
17
|
-
expect(resp.status).toBe(200);
|
|
18
|
-
});
|
|
19
|
-
test("authorizeCallback: invalid request", async () => {
|
|
20
|
-
const resp = await app.registration.authorizeCallback(new Request("http://localhost", { body: "{}" }));
|
|
21
|
-
expect(resp.status).toBe(400);
|
|
22
|
-
});
|
|
23
|
-
test("authorizeCallback: shop does not exist", async () => {
|
|
24
|
-
const resp = await app.registration.authorizeCallback(new Request("http://localhost", {
|
|
25
|
-
body: '{"shopId": "test", "apiKey": "test", "secretKey": "test"}',
|
|
26
|
-
}));
|
|
27
|
-
expect(resp.status).toBe(400);
|
|
28
|
-
});
|
|
29
|
-
test("activateShop", async () => {
|
|
30
|
-
await app.repository.createShop("1", "http://localhost", "test");
|
|
31
|
-
const shop = await app.repository.getShopById("1");
|
|
32
|
-
shop?.setShopActive(false);
|
|
33
|
-
app.contextResolver.fromAPI = jest.fn().mockResolvedValue({ shop });
|
|
34
|
-
const resp = await app.registration.activate(new Request("http://localhost", { body: '{"source": {"shopId": "1"}}' }));
|
|
35
|
-
expect(resp.status).toBe(204);
|
|
36
|
-
expect(shop?.getShopActive()).toBe(true);
|
|
37
|
-
});
|
|
38
|
-
test("deactivateShop", async () => {
|
|
39
|
-
await app.repository.createShop("1", "http://localhost", "test");
|
|
40
|
-
const shop = await app.repository.getShopById("1");
|
|
41
|
-
shop?.setShopActive(true);
|
|
42
|
-
app.contextResolver.fromAPI = jest.fn().mockResolvedValue({ shop });
|
|
43
|
-
const resp = await app.registration.deactivate(new Request("http://localhost", { body: '{"source": {"shopId": "1"}}' }));
|
|
44
|
-
expect(resp.status).toBe(204);
|
|
45
|
-
expect(shop?.getShopActive()).toBe(false);
|
|
46
|
-
});
|
|
47
|
-
test("deletedShop", async () => {
|
|
48
|
-
await app.repository.createShop("1", "http://localhost", "test");
|
|
49
|
-
const shop = await app.repository.getShopById("1");
|
|
50
|
-
expect(shop).not.toBeNull();
|
|
51
|
-
app.contextResolver.fromAPI = jest.fn().mockResolvedValue({ shop });
|
|
52
|
-
const resp = await app.registration.delete(new Request("http://localhost", { body: '{"source": {"shopId": "1"}}' }));
|
|
53
|
-
expect(resp.status).toBe(204);
|
|
54
|
-
expect(app.repository.getShopById("1")).resolves.toBeNull();
|
|
55
|
-
});
|
|
56
|
-
});
|
|
57
|
-
//# sourceMappingURL=registration.test.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"registration.test.js","sourceRoot":"","sources":["../../src/registration.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,UAAU,CAAC;AACxD,OAAO,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAC1C,OAAO,EAAE,sBAAsB,EAAc,MAAM,sBAAsB,CAAC;AAE1E,QAAQ,CAAC,cAAc,EAAE,KAAK,IAAI,EAAE;IACnC,MAAM,GAAG,GAAG,IAAI,SAAS,CACxB,EAAE,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,oBAAoB,EAAE,MAAM,EAAE,EACpE,IAAI,sBAAsB,EAAE,CAC5B,CAAC;IAEF,IAAI,CAAC,4BAA4B,EAAE,KAAK,IAAI,EAAE;QAC7C,MAAM,IAAI,GAAG,MAAM,GAAG,CAAC,YAAY,CAAC,SAAS,CAC5C,IAAI,OAAO,CAAC,kBAAkB,CAAC,CAC/B,CAAC;QAEF,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IAC/B,CAAC,CAAC,CAAC;IAEH,IAAI,CAAC,8BAA8B,EAAE,KAAK,IAAI,EAAE;QAC/C,MAAM,IAAI,GAAG,MAAM,GAAG,CAAC,YAAY,CAAC,SAAS,CAC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,MAAM,GAAG,CAAC,YAAY,CAAC,UAAU,CAC7C,IAAI,OAAO,CAAC,kBAAkB,EAAE,EAAE,IAAI,EAAE,6BAA6B,EAAE,CAAC,CACxE,CAAC;QAEF,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;QAE9B,MAAM,CAAC,IAAI,EAAE,aAAa,EAAE,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IAC3C,CAAC,CAAC,CAAC;IAEH,IAAI,CAAC,aAAa,EAAE,KAAK,IAAI,EAAE;QAC9B,MAAM,GAAG,CAAC,UAAU,CAAC,UAAU,CAAC,GAAG,EAAE,kBAAkB,EAAE,MAAM,CAAC,CAAC;QAEjE,MAAM,IAAI,GAAG,MAAM,GAAG,CAAC,UAAU,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC;QAEnD,MAAM,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,QAAQ,EAAE,CAAC;QAE5B,GAAG,CAAC,eAAe,CAAC,OAAO,GAAG,IAAI,CAAC,EAAE,EAAE,CAAC,iBAAiB,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC;QAEpE,MAAM,IAAI,GAAG,MAAM,GAAG,CAAC,YAAY,CAAC,MAAM,CACzC,IAAI,OAAO,CAAC,kBAAkB,EAAE,EAAE,IAAI,EAAE,6BAA6B,EAAE,CAAC,CACxE,CAAC;QAEF,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;QAE9B,MAAM,CAAC,GAAG,CAAC,UAAU,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC,CAAC,QAAQ,CAAC,QAAQ,EAAE,CAAC;IAC7D,CAAC,CAAC,CAAC;AACJ,CAAC,CAAC,CAAC","sourcesContent":["import { describe, expect, jest, test } from \"bun:test\";\nimport { AppServer } from \"../src/app.js\";\nimport { InMemoryShopRepository, SimpleShop } from \"../src/repository.js\";\n\ndescribe(\"Registration\", async () => {\n\tconst app = new AppServer(\n\t\t{ appName: \"test\", appSecret: \"test\", authorizeCallbackUrl: \"test\" },\n\t\tnew InMemoryShopRepository(),\n\t);\n\n\ttest(\"authorize: invalid request\", async () => {\n\t\tconst resp = await app.registration.authorize(\n\t\t\tnew Request(\"http://localhost\"),\n\t\t);\n\n\t\texpect(resp.status).toBe(400);\n\t});\n\n\ttest(\"authorize: invalid signature\", async () => {\n\t\tconst resp = await app.registration.authorize(\n\t\t\tnew Request(\n\t\t\t\t\"http://localhost?shop-url=test&shop-id=test×tamp=test\",\n\t\t\t\t{ headers: new Headers({ \"shopware-app-signature\": \"test\" }) },\n\t\t\t),\n\t\t);\n\n\t\texpect(resp.status).toBe(401);\n\t});\n\n\ttest(\"authorize: valid request\", async () => {\n\t\tapp.signer.verify = jest.fn().mockResolvedValue(true);\n\n\t\tconst resp = await app.registration.authorize(\n\t\t\tnew Request(\n\t\t\t\t\"http://localhost?shop-url=test&shop-id=test×tamp=test\",\n\t\t\t\t{ headers: new Headers({ \"shopware-app-signature\": \"test\" }) },\n\t\t\t),\n\t\t);\n\n\t\texpect(resp.status).toBe(200);\n\t});\n\n\ttest(\"authorizeCallback: invalid request\", async () => {\n\t\tconst resp = await app.registration.authorizeCallback(\n\t\t\tnew Request(\"http://localhost\", { body: \"{}\" }),\n\t\t);\n\n\t\texpect(resp.status).toBe(400);\n\t});\n\n\ttest(\"authorizeCallback: shop does not exist\", async () => {\n\t\tconst resp = await app.registration.authorizeCallback(\n\t\t\tnew Request(\"http://localhost\", {\n\t\t\t\tbody: '{\"shopId\": \"test\", \"apiKey\": \"test\", \"secretKey\": \"test\"}',\n\t\t\t}),\n\t\t);\n\n\t\texpect(resp.status).toBe(400);\n\t});\n\n\ttest(\"activateShop\", async () => {\n\t\tawait app.repository.createShop(\"1\", \"http://localhost\", \"test\");\n\n\t\tconst shop = await app.repository.getShopById(\"1\");\n\n\t\tshop?.setShopActive(false);\n\n\t\tapp.contextResolver.fromAPI = jest.fn().mockResolvedValue({ shop });\n\n\t\tconst resp = await app.registration.activate(\n\t\t\tnew Request(\"http://localhost\", { body: '{\"source\": {\"shopId\": \"1\"}}' }),\n\t\t);\n\n\t\texpect(resp.status).toBe(204);\n\n\t\texpect(shop?.getShopActive()).toBe(true);\n\t});\n\n\ttest(\"deactivateShop\", async () => {\n\t\tawait app.repository.createShop(\"1\", \"http://localhost\", \"test\");\n\n\t\tconst shop = await app.repository.getShopById(\"1\");\n\n\t\tshop?.setShopActive(true);\n\n\t\tapp.contextResolver.fromAPI = jest.fn().mockResolvedValue({ shop });\n\n\t\tconst resp = await app.registration.deactivate(\n\t\t\tnew Request(\"http://localhost\", { body: '{\"source\": {\"shopId\": \"1\"}}' }),\n\t\t);\n\n\t\texpect(resp.status).toBe(204);\n\n\t\texpect(shop?.getShopActive()).toBe(false);\n\t});\n\n\ttest(\"deletedShop\", async () => {\n\t\tawait app.repository.createShop(\"1\", \"http://localhost\", \"test\");\n\n\t\tconst shop = await app.repository.getShopById(\"1\");\n\n\t\texpect(shop).not.toBeNull();\n\n\t\tapp.contextResolver.fromAPI = jest.fn().mockResolvedValue({ shop });\n\n\t\tconst resp = await app.registration.delete(\n\t\t\tnew Request(\"http://localhost\", { body: '{\"source\": {\"shopId\": \"1\"}}' }),\n\t\t);\n\n\t\texpect(resp.status).toBe(204);\n\n\t\texpect(app.repository.getShopById(\"1\")).resolves.toBeNull();\n\t});\n});\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"repository.test.d.ts","sourceRoot":"","sources":["../../src/repository.test.ts"],"names":[],"mappings":""}
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import { describe, expect, test } from "bun:test";
|
|
2
|
-
import { InMemoryShopRepository, SimpleShop } from "../src/repository.js";
|
|
3
|
-
describe("Repository", async () => {
|
|
4
|
-
test("SimpleShop", async () => {
|
|
5
|
-
const shop = new SimpleShop("test", "test", "test");
|
|
6
|
-
expect(shop.getShopId()).toBe("test");
|
|
7
|
-
expect(shop.getShopUrl()).toBe("test");
|
|
8
|
-
expect(shop.getShopSecret()).toBe("test");
|
|
9
|
-
expect(shop.getShopClientId()).toBeNull();
|
|
10
|
-
expect(shop.getShopClientSecret()).toBeNull();
|
|
11
|
-
expect(shop.getShopActive()).toBe(true);
|
|
12
|
-
shop.setShopActive(false);
|
|
13
|
-
expect(shop.getShopActive()).toBe(false);
|
|
14
|
-
shop.setShopCredentials("test", "test");
|
|
15
|
-
expect(shop.getShopClientId()).toBe("test");
|
|
16
|
-
expect(shop.getShopClientSecret()).toBe("test");
|
|
17
|
-
});
|
|
18
|
-
test("InMemoryShopRepository", async () => {
|
|
19
|
-
const shop = new SimpleShop("test", "test", "test");
|
|
20
|
-
const repository = new InMemoryShopRepository();
|
|
21
|
-
expect(repository.getShopById("test")).resolves.toBeNull();
|
|
22
|
-
await repository.createShop("test", "test", "test");
|
|
23
|
-
expect(repository.getShopById("test")).resolves.toBeInstanceOf(SimpleShop);
|
|
24
|
-
await repository.deleteShop("test");
|
|
25
|
-
expect(repository.getShopById("test")).resolves.toBeNull();
|
|
26
|
-
await repository.updateShop(shop);
|
|
27
|
-
expect(repository.getShopById("test")).resolves.toBe(shop);
|
|
28
|
-
});
|
|
29
|
-
});
|
|
30
|
-
//# sourceMappingURL=repository.test.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"repository.test.js","sourceRoot":"","sources":["../../src/repository.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,UAAU,CAAC;AAClD,OAAO,EAAE,sBAAsB,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAE1E,QAAQ,CAAC,YAAY,EAAE,KAAK,IAAI,EAAE;IACjC,IAAI,CAAC,YAAY,EAAE,KAAK,IAAI,EAAE;QAC7B,MAAM,IAAI,GAAG,IAAI,UAAU,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,C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AAM,EAAE,MAAM,CAAC,CAAC;QAEpD,MAAM,CAAC,UAAU,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC,CAAC,QAAQ,CAAC,cAAc,CAAC,UAAU,CAAC,CAAC;QAE3E,MAAM,UAAU,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC;QAEpC,MAAM,CAAC,UAAU,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC,CAAC,QAAQ,CAAC,QAAQ,EAAE,CAAC;QAE3D,MAAM,UAAU,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC;QAElC,MAAM,CAAC,UAAU,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAC5D,CAAC,CAAC,CAAC;AACJ,CAAC,CAAC,CAAC","sourcesContent":["import { describe, expect, test } from \"bun:test\";\nimport { InMemoryShopRepository, SimpleShop } from \"../src/repository.js\";\n\ndescribe(\"Repository\", async () => {\n\ttest(\"SimpleShop\", async () => {\n\t\tconst shop = new SimpleShop(\"test\", \"test\", \"test\");\n\n\t\texpect(shop.getShopId()).toBe(\"test\");\n\t\texpect(shop.getShopUrl()).toBe(\"test\");\n\t\texpect(shop.getShopSecret()).toBe(\"test\");\n\t\texpect(shop.getShopClientId()).toBeNull();\n\t\texpect(shop.getShopClientSecret()).toBeNull();\n\t\texpect(shop.getShopActive()).toBe(true);\n\n\t\tshop.setShopActive(false);\n\n\t\texpect(shop.getShopActive()).toBe(false);\n\n\t\tshop.setShopCredentials(\"test\", \"test\");\n\n\t\texpect(shop.getShopClientId()).toBe(\"test\");\n\t\texpect(shop.getShopClientSecret()).toBe(\"test\");\n\t});\n\n\ttest(\"InMemoryShopRepository\", async () => {\n\t\tconst shop = new SimpleShop(\"test\", \"test\", \"test\");\n\n\t\tconst repository = new InMemoryShopRepository();\n\n\t\texpect(repository.getShopById(\"test\")).resolves.toBeNull();\n\n\t\tawait repository.createShop(\"test\", \"test\", \"test\");\n\n\t\texpect(repository.getShopById(\"test\")).resolves.toBeInstanceOf(SimpleShop);\n\n\t\tawait repository.deleteShop(\"test\");\n\n\t\texpect(repository.getShopById(\"test\")).resolves.toBeNull();\n\n\t\tawait repository.updateShop(shop);\n\n\t\texpect(repository.getShopById(\"test\")).resolves.toBe(shop);\n\t});\n});\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"signer.test.d.ts","sourceRoot":"","sources":["../../src/signer.test.ts"],"names":[],"mappings":""}
|
package/dist/esm/signer.test.js
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import { describe, expect, test } from "bun:test";
|
|
2
|
-
import { WebCryptoHmacSigner } from "../src/signer.js";
|
|
3
|
-
describe("Signer", () => {
|
|
4
|
-
test("signResponse", async () => {
|
|
5
|
-
const signer = new WebCryptoHmacSigner();
|
|
6
|
-
const response = new Response("Hello, World!");
|
|
7
|
-
await signer.signResponse(response, "test");
|
|
8
|
-
expect(response.headers.get("shopware-app-signature")).toBe("52589bd80ccfa4acbb3f9512dfaf4f700fa5195008aae0b77a9e47dcca75beac");
|
|
9
|
-
await signer.signResponse(response, "test");
|
|
10
|
-
expect(response.headers.get("shopware-app-signature")).toBe("52589bd80ccfa4acbb3f9512dfaf4f700fa5195008aae0b77a9e47dcca75beac");
|
|
11
|
-
});
|
|
12
|
-
test("sign", async () => {
|
|
13
|
-
const signer = new WebCryptoHmacSigner();
|
|
14
|
-
expect(await signer.sign("shop-id=blaa", "test")).toBe("f2cb1044ac5a2cb807e1942b06433d23d66bcf7dfad1095b286203e5c1f39cb6");
|
|
15
|
-
});
|
|
16
|
-
test("verifyGetRequest", async () => {
|
|
17
|
-
const signer = new WebCryptoHmacSigner();
|
|
18
|
-
expect(signer.verifyGetRequest(new Request("https://example.com/?shopware-shop-signature=52589bd80ccfa4acbb3f9512dfaf4f700fa5195008aae0b77a9e47dcca75beac"), "test")).rejects.toThrowError("Missing query parameters to verify the GET request");
|
|
19
|
-
expect(signer.verifyGetRequest(new Request("https://example.com/?shopware-shop-signature=52589bd80ccfa4acbb3f9512dfaf4f700fa5195008aae0b77a9e47dcca75beac&a=1"), "test")).rejects.toThrowError("Invalid signature");
|
|
20
|
-
expect(signer.verifyGetRequest(new Request("https://example.com/?shopware-shop-signature=f2cb1044ac5a2cb807e1942b06433d23d66bcf7dfad1095b286203e5c1f39cb6&shop-id=blaa"), "test")).resolves.pass();
|
|
21
|
-
});
|
|
22
|
-
});
|
|
23
|
-
//# sourceMappingURL=signer.test.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"signer.test.js","sourceRoot":"","sources":["../../src/signer.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,UAAU,CAAC;AAClD,OAAO,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AAEvD,QAAQ,CAAC,QAAQ,EAAE,GAAG,EAAE;IACvB,IAAI,CAAC,cAAc,EAAE,KAAK,IAAI,EAAE;QAC/B,MAAM,MAAM,GAAG,IAAI,mBAAmB,EAAE,CAAC;QAEzC,MAAM,QAAQ,GAAG,IAAI,QAAQ,CAAC,eAAe,CAAC,CAAC;QAE/C,MAAM,MAAM,CAAC,YAAY,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC;QAE5C,MAAM,CAAC,QAAQ,CAAC,OAAO,CAAC,GAAG,CAAC,wBAAwB,CAAC,CAAC,CAAC,IAAI,CAC1D,kEAAkE,CAClE,CAAC;QAEF,MAAM,MAAM,CAAC,YAAY,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC;QAE5C,MAAM,CAAC,QAAQ,CAAC,OAAO,CAAC,GAAG,CAAC,wBAAwB,CAAC,CAAC,CAAC,IAAI,CAC1D,kEAAkE,CAClE,CAAC;IACH,CAAC,CAAC,CAAC;IAEH,IAAI,CAAC,MAAM,EAAE,KAAK,IAAI,EAAE;QACvB,MAAM,MAAM,GAAG,IAAI,mBAAmB,EAAE,CAAC;QAEzC,MAAM,CAAC,MAAM,MAAM,CAAC,IAAI,CAAC,cAAc,EAAE,MAAM,CAAC,CAAC,CAAC,IAAI,CACrD,kEAAkE,CAClE,CAAC;IACH,CAAC,CAAC,CAAC;IAEH,IAAI,CAAC,kBAAkB,EAAE,KAAK,IAAI,EAAE;QACnC,MAAM,MAAM,GAAG,IAAI,mBAAmB,EAAE,CAAC;QAEzC,MAAM,CACL,MAAM,CAAC,gBAAgB,CACtB,IAAI,OAAO,CACV,+GAA+G,CAC/G,EACD,MAAM,CACN,CACD,CAAC,OAAO,CAAC,YAAY,CACrB,oDAAoD,CACpD,CAAC;QACF,MAAM,CACL,MAAM,CAAC,gBAAgB,CACtB,IAAI,OAAO,CACV,mHAAmH,CACnH,EACD,MAAM,CACN,CACD,CAAC,OAAO,CAAC,YAAY,CAAC,mBAAmB,CAAC,CAAC;QAE5C,MAAM,CACL,MAAM,CAAC,gBAAgB,CACtB,IAAI,OAAO,CACV,4HAA4H,CAC5H,EACD,MAAM,CACN,CACD,CAAC,QAAQ,CAAC,IAAI,EAAE,CAAC;IACnB,CAAC,CAAC,CAAC;AACJ,CAAC,CAAC,CAAC","sourcesContent":["import { describe, expect, test } from \"bun:test\";\nimport { WebCryptoHmacSigner } from \"../src/signer.js\";\n\ndescribe(\"Signer\", () => {\n\ttest(\"signResponse\", async () => {\n\t\tconst signer = new WebCryptoHmacSigner();\n\n\t\tconst response = new Response(\"Hello, World!\");\n\n\t\tawait signer.signResponse(response, \"test\");\n\n\t\texpect(response.headers.get(\"shopware-app-signature\")).toBe(\n\t\t\t\"52589bd80ccfa4acbb3f9512dfaf4f700fa5195008aae0b77a9e47dcca75beac\",\n\t\t);\n\n\t\tawait signer.signResponse(response, \"test\");\n\n\t\texpect(response.headers.get(\"shopware-app-signature\")).toBe(\n\t\t\t\"52589bd80ccfa4acbb3f9512dfaf4f700fa5195008aae0b77a9e47dcca75beac\",\n\t\t);\n\t});\n\n\ttest(\"sign\", async () => {\n\t\tconst signer = new WebCryptoHmacSigner();\n\n\t\texpect(await signer.sign(\"shop-id=blaa\", \"test\")).toBe(\n\t\t\t\"f2cb1044ac5a2cb807e1942b06433d23d66bcf7dfad1095b286203e5c1f39cb6\",\n\t\t);\n\t});\n\n\ttest(\"verifyGetRequest\", async () => {\n\t\tconst signer = new WebCryptoHmacSigner();\n\n\t\texpect(\n\t\t\tsigner.verifyGetRequest(\n\t\t\t\tnew Request(\n\t\t\t\t\t\"https://example.com/?shopware-shop-signature=52589bd80ccfa4acbb3f9512dfaf4f700fa5195008aae0b77a9e47dcca75beac\",\n\t\t\t\t),\n\t\t\t\t\"test\",\n\t\t\t),\n\t\t).rejects.toThrowError(\n\t\t\t\"Missing query parameters to verify the GET request\",\n\t\t);\n\t\texpect(\n\t\t\tsigner.verifyGetRequest(\n\t\t\t\tnew Request(\n\t\t\t\t\t\"https://example.com/?shopware-shop-signature=52589bd80ccfa4acbb3f9512dfaf4f700fa5195008aae0b77a9e47dcca75beac&a=1\",\n\t\t\t\t),\n\t\t\t\t\"test\",\n\t\t\t),\n\t\t).rejects.toThrowError(\"Invalid signature\");\n\n\t\texpect(\n\t\t\tsigner.verifyGetRequest(\n\t\t\t\tnew Request(\n\t\t\t\t\t\"https://example.com/?shopware-shop-signature=f2cb1044ac5a2cb807e1942b06433d23d66bcf7dfad1095b286203e5c1f39cb6&shop-id=blaa\",\n\t\t\t\t),\n\t\t\t\t\"test\",\n\t\t\t),\n\t\t).resolves.pass();\n\t});\n});\n"]}
|