@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,24 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const bun_test_1 = require("bun:test");
|
|
4
|
-
const repository_js_1 = require("../repository.js");
|
|
5
|
-
const bun_sqlite_js_1 = require("./bun-sqlite.js");
|
|
6
|
-
(0, bun_test_1.describe)("Bun SQLite", async () => {
|
|
7
|
-
(0, bun_test_1.test)("createShop", async () => {
|
|
8
|
-
const repo = new bun_sqlite_js_1.BunSqliteRepository(":memory:");
|
|
9
|
-
await repo.createShop("test", "test", "test");
|
|
10
|
-
const shop = await repo.getShopById("test");
|
|
11
|
-
(0, bun_test_1.expect)(shop).not.toBeNull();
|
|
12
|
-
(0, bun_test_1.expect)(shop?.getShopId()).toBe("test");
|
|
13
|
-
(0, bun_test_1.expect)(shop?.getShopUrl()).toBe("test");
|
|
14
|
-
(0, bun_test_1.expect)(shop?.getShopSecret()).toBe("test");
|
|
15
|
-
await repo.deleteShop("test");
|
|
16
|
-
(0, bun_test_1.expect)(repo.getShopById("test")).resolves.toBeNull();
|
|
17
|
-
await repo.createShop("test", "test", "test");
|
|
18
|
-
(0, bun_test_1.expect)(repo.getShopById("test")).resolves.not.toBeNull();
|
|
19
|
-
await repo.updateShop(new repository_js_1.SimpleShop("test", "foo.com", "test"));
|
|
20
|
-
const updatedShop = await repo.getShopById("test");
|
|
21
|
-
(0, bun_test_1.expect)(updatedShop?.getShopUrl()).toBe("foo.com");
|
|
22
|
-
});
|
|
23
|
-
});
|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EAAE,CAAC;QAEzD,MAAM,IAAI,CAAC,UAAU,CAAC,IAAI,0BAAU,CAAC,MAAM,EAAE,SAAS,EAAE,MAAM,CAAC,CAAC,CAAC;QAEjE,MAAM,WAAW,GAAG,MAAM,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC;QAEnD,IAAA,iBAAM,EAAC,WAAW,EAAE,UAAU,EAAE,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;IACnD,CAAC,CAAC,CAAC;AACJ,CAAC,CAAC,CAAC","sourcesContent":["import { describe, expect, test } from \"bun:test\";\nimport { SimpleShop } from \"../repository.js\";\nimport { BunSqliteRepository } from \"./bun-sqlite.js\";\n\ndescribe(\"Bun SQLite\", async () => {\n\ttest(\"createShop\", async () => {\n\t\tconst repo = new BunSqliteRepository(\":memory:\");\n\n\t\tawait repo.createShop(\"test\", \"test\", \"test\");\n\n\t\tconst shop = await repo.getShopById(\"test\");\n\n\t\texpect(shop).not.toBeNull();\n\n\t\texpect(shop?.getShopId()).toBe(\"test\");\n\t\texpect(shop?.getShopUrl()).toBe(\"test\");\n\t\texpect(shop?.getShopSecret()).toBe(\"test\");\n\n\t\tawait repo.deleteShop(\"test\");\n\n\t\texpect(repo.getShopById(\"test\")).resolves.toBeNull();\n\n\t\tawait repo.createShop(\"test\", \"test\", \"test\");\n\n\t\texpect(repo.getShopById(\"test\")).resolves.not.toBeNull();\n\n\t\tawait repo.updateShop(new SimpleShop(\"test\", \"foo.com\", \"test\"));\n\n\t\tconst updatedShop = await repo.getShopById(\"test\");\n\n\t\texpect(updatedShop?.getShopUrl()).toBe(\"foo.com\");\n\t});\n});\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"cloudflare.test.d.ts","sourceRoot":"","sources":["../../../src/integration/cloudflare.test.ts"],"names":[],"mappings":""}
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
//
|
|
4
|
-
const bun_test_1 = require("bun:test");
|
|
5
|
-
const cloudflare_kv_js_1 = require("../../src/integration/cloudflare-kv.js");
|
|
6
|
-
const repository_js_1 = require("../../src/repository.js");
|
|
7
|
-
(0, bun_test_1.describe)("Cloudflare", async () => {
|
|
8
|
-
(0, bun_test_1.test)("createShop", async () => {
|
|
9
|
-
const repo = new cloudflare_kv_js_1.CloudflareShopRepository(new MockedKVNamespace());
|
|
10
|
-
await repo.createShop("test", "test", "test");
|
|
11
|
-
const shop = await repo.getShopById("test");
|
|
12
|
-
(0, bun_test_1.expect)(shop).not.toBeNull();
|
|
13
|
-
(0, bun_test_1.expect)(shop?.getShopId()).toBe("test");
|
|
14
|
-
(0, bun_test_1.expect)(shop?.getShopUrl()).toBe("test");
|
|
15
|
-
(0, bun_test_1.expect)(shop?.getShopSecret()).toBe("test");
|
|
16
|
-
await repo.deleteShop("test");
|
|
17
|
-
(0, bun_test_1.expect)(repo.getShopById("test")).resolves.toBeNull();
|
|
18
|
-
await repo.updateShop(new repository_js_1.SimpleShop("test", "test", "test"));
|
|
19
|
-
(0, bun_test_1.expect)(repo.getShopById("test")).resolves.not.toBeNull();
|
|
20
|
-
});
|
|
21
|
-
});
|
|
22
|
-
class MockedKVNamespace {
|
|
23
|
-
storage;
|
|
24
|
-
constructor() {
|
|
25
|
-
this.storage = new Map();
|
|
26
|
-
}
|
|
27
|
-
get(key, options) {
|
|
28
|
-
return Promise.resolve(this.storage.get(key) || null);
|
|
29
|
-
}
|
|
30
|
-
put(key, value, options) {
|
|
31
|
-
this.storage.set(key, value);
|
|
32
|
-
return Promise.resolve();
|
|
33
|
-
}
|
|
34
|
-
delete(key) {
|
|
35
|
-
this.storage.delete(key);
|
|
36
|
-
return Promise.resolve();
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
//# sourceMappingURL=cloudflare.test.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"cloudflare.test.js","sourceRo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EH,MAAM,iBAAiB;IACtB,OAAO,CAAsB;IAC7B;QACC,IAAI,CAAC,OAAO,GAAG,IAAI,GAAG,EAAE,CAAC;IAC1B,CAAC;IAED,GAAG,CACF,GAAW,EACX,OAAmD;QAEnD,OAAO,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,IAAI,IAAI,CAAC,CAAC;IACvD,CAAC;IACD,GAAG,CACF,GAAW,EACX,KAA8D,EAC9D,OAA+B;QAE/B,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,GAAG,EAAE,KAAe,CAAC,CAAC;QACvC,OAAO,OAAO,CAAC,OAAO,EAAE,CAAC;IAC1B,CAAC;IACD,MAAM,CAAC,GAAW;QACjB,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;QACzB,OAAO,OAAO,CAAC,OAAO,EAAE,CAAC;IAC1B,CAAC;CACD","sourcesContent":["//\nimport { describe, expect, test } from \"bun:test\";\nimport { CloudflareShopRepository } from \"../../src/integration/cloudflare-kv.js\";\nimport { SimpleShop } from \"../../src/repository.js\";\n\ndescribe(\"Cloudflare\", async () => {\n\ttest(\"createShop\", async () => {\n\t\tconst repo = new CloudflareShopRepository(\n\t\t\tnew MockedKVNamespace() as unknown as KVNamespace,\n\t\t);\n\n\t\tawait repo.createShop(\"test\", \"test\", \"test\");\n\n\t\tconst shop = await repo.getShopById(\"test\");\n\n\t\texpect(shop).not.toBeNull();\n\n\t\texpect(shop?.getShopId()).toBe(\"test\");\n\t\texpect(shop?.getShopUrl()).toBe(\"test\");\n\t\texpect(shop?.getShopSecret()).toBe(\"test\");\n\n\t\tawait repo.deleteShop(\"test\");\n\n\t\texpect(repo.getShopById(\"test\")).resolves.toBeNull();\n\n\t\tawait repo.updateShop(new SimpleShop(\"test\", \"test\", \"test\"));\n\n\t\texpect(repo.getShopById(\"test\")).resolves.not.toBeNull();\n\t});\n});\n\nclass MockedKVNamespace {\n\tstorage: Map<string, string>;\n\tconstructor() {\n\t\tthis.storage = new Map();\n\t}\n\n\tget(\n\t\tkey: string,\n\t\toptions?: Partial<KVNamespaceGetOptions<undefined>>,\n\t): Promise<string | null> {\n\t\treturn Promise.resolve(this.storage.get(key) || null);\n\t}\n\tput(\n\t\tkey: string,\n\t\tvalue: string | ArrayBuffer | ArrayBufferView | ReadableStream,\n\t\toptions?: KVNamespacePutOptions,\n\t): Promise<void> {\n\t\tthis.storage.set(key, value as string);\n\t\treturn Promise.resolve();\n\t}\n\tdelete(key: string): Promise<void> {\n\t\tthis.storage.delete(key);\n\t\treturn Promise.resolve();\n\t}\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"deno.test.d.ts","sourceRoot":"","sources":["../../../src/integration/deno.test.ts"],"names":[],"mappings":""}
|
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const bun_test_1 = require("bun:test");
|
|
4
|
-
const repository_js_1 = require("../repository.js");
|
|
5
|
-
const deno_kv_js_1 = require("./deno-kv.js");
|
|
6
|
-
(0, bun_test_1.describe)("Deno", async () => {
|
|
7
|
-
const kv = {
|
|
8
|
-
storage: new Map(),
|
|
9
|
-
set(key, value) {
|
|
10
|
-
this.storage.set(key.join(""), value);
|
|
11
|
-
},
|
|
12
|
-
get(key) {
|
|
13
|
-
if (!this.storage.has(key.join(""))) {
|
|
14
|
-
return {
|
|
15
|
-
key: null,
|
|
16
|
-
value: null,
|
|
17
|
-
};
|
|
18
|
-
}
|
|
19
|
-
return Promise.resolve({
|
|
20
|
-
key: key.join(""),
|
|
21
|
-
value: this.storage.get(key.join("")),
|
|
22
|
-
});
|
|
23
|
-
},
|
|
24
|
-
delete(key) {
|
|
25
|
-
this.storage.delete(key.join(""));
|
|
26
|
-
},
|
|
27
|
-
};
|
|
28
|
-
// @ts-ignore
|
|
29
|
-
globalThis.Deno = {
|
|
30
|
-
openKv() {
|
|
31
|
-
return Promise.resolve(kv);
|
|
32
|
-
},
|
|
33
|
-
};
|
|
34
|
-
(0, bun_test_1.test)("test repository", async () => {
|
|
35
|
-
const repo = new deno_kv_js_1.DenoKVRepository();
|
|
36
|
-
await repo.createShop("test", "test", "test");
|
|
37
|
-
const shop = await repo.getShopById("test");
|
|
38
|
-
(0, bun_test_1.expect)(shop).not.toBeNull();
|
|
39
|
-
(0, bun_test_1.expect)(shop?.getShopId()).toBe("test");
|
|
40
|
-
(0, bun_test_1.expect)(shop?.getShopUrl()).toBe("test");
|
|
41
|
-
(0, bun_test_1.expect)(shop?.getShopSecret()).toBe("test");
|
|
42
|
-
await repo.deleteShop("test");
|
|
43
|
-
(0, bun_test_1.expect)(repo.getShopById("test")).resolves.toBeNull();
|
|
44
|
-
await repo.updateShop(new repository_js_1.SimpleShop("test", "test", "test"));
|
|
45
|
-
(0, bun_test_1.expect)(repo.getShopById("test")).resolves.not.toBeNull();
|
|
46
|
-
});
|
|
47
|
-
});
|
|
48
|
-
//# sourceMappingURL=deno.test.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"deno.test.js","sourceRoot":"","sources":["../../../src/integration/deno.test.ts"],"names":[],"mappings":";;AAAA,uCAAkD;AAClD,oDAA8C;AAC9C,6CAAgD;AAEhD,IAAA,mBAAQ,EAAC,MAAM,EAAE,KAAK,IAAI,EAAE;IAC3B,MAAM,EAAE,GAAG;QACV,OAAO,EAAE,IAAI,GAAG,EAAE;QAClB,GAAG,CAAC,GAAa,EAAE,KAAa;YAC/B,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,EAAE,KAAK,CAAC,CAAC;QACvC,CAAC;QAED,GAAG,CAAC,GAAa;YAChB,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC;gBACrC,OAA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AAA,iBAAM,EAAC,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC,CAAC,QAAQ,CAAC,QAAQ,EAAE,CAAC;QAErD,MAAM,IAAI,CAAC,UAAU,CAAC,IAAI,0BAAU,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;QAE9D,IAAA,iBAAM,EAAC,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC,CAAC,QAAQ,CAAC,GAAG,CAAC,QAAQ,EAAE,CAAC;IAC1D,CAAC,CAAC,CAAC;AACJ,CAAC,CAAC,CAAC","sourcesContent":["import { describe, expect, test } from \"bun:test\";\nimport { SimpleShop } from \"../repository.js\";\nimport { DenoKVRepository } from \"./deno-kv.js\";\n\ndescribe(\"Deno\", async () => {\n\tconst kv = {\n\t\tstorage: new Map(),\n\t\tset(key: string[], value: string) {\n\t\t\tthis.storage.set(key.join(\"\"), value);\n\t\t},\n\n\t\tget(key: string[]) {\n\t\t\tif (!this.storage.has(key.join(\"\"))) {\n\t\t\t\treturn {\n\t\t\t\t\tkey: null,\n\t\t\t\t\tvalue: null,\n\t\t\t\t};\n\t\t\t}\n\n\t\t\treturn Promise.resolve({\n\t\t\t\tkey: key.join(\"\"),\n\t\t\t\tvalue: this.storage.get(key.join(\"\")),\n\t\t\t});\n\t\t},\n\n\t\tdelete(key: string[]) {\n\t\t\tthis.storage.delete(key.join(\"\"));\n\t\t},\n\t};\n\n\t// @ts-ignore\n\tglobalThis.Deno = {\n\t\topenKv() {\n\t\t\treturn Promise.resolve(kv);\n\t\t},\n\t};\n\n\ttest(\"test repository\", async () => {\n\t\tconst repo = new DenoKVRepository();\n\n\t\tawait repo.createShop(\"test\", \"test\", \"test\");\n\n\t\tconst shop = await repo.getShopById(\"test\");\n\n\t\texpect(shop).not.toBeNull();\n\n\t\texpect(shop?.getShopId()).toBe(\"test\");\n\t\texpect(shop?.getShopUrl()).toBe(\"test\");\n\t\texpect(shop?.getShopSecret()).toBe(\"test\");\n\n\t\tawait repo.deleteShop(\"test\");\n\n\t\texpect(repo.getShopById(\"test\")).resolves.toBeNull();\n\n\t\tawait repo.updateShop(new SimpleShop(\"test\", \"test\", \"test\"));\n\n\t\texpect(repo.getShopById(\"test\")).resolves.not.toBeNull();\n\t});\n});\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"dynamodb.test.d.ts","sourceRoot":"","sources":["../../../src/integration/dynamodb.test.ts"],"names":[],"mappings":""}
|
|
@@ -1,132 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const bun_test_1 = require("bun:test");
|
|
4
|
-
const dynamodb_js_1 = require("./dynamodb.js");
|
|
5
|
-
const client_dynamodb_1 = require("@aws-sdk/client-dynamodb");
|
|
6
|
-
const repository_js_1 = require("../repository.js");
|
|
7
|
-
(0, bun_test_1.describe)("DynamoDB", async () => {
|
|
8
|
-
(0, bun_test_1.test)("getShopById does not exists", async () => {
|
|
9
|
-
bun_test_1.mock.module("@aws-sdk/lib-dynamodb", () => {
|
|
10
|
-
return {
|
|
11
|
-
DynamoDBDocumentClient: {
|
|
12
|
-
from() {
|
|
13
|
-
return {
|
|
14
|
-
async send() {
|
|
15
|
-
return {};
|
|
16
|
-
},
|
|
17
|
-
};
|
|
18
|
-
},
|
|
19
|
-
},
|
|
20
|
-
};
|
|
21
|
-
});
|
|
22
|
-
const repo = new dynamodb_js_1.DynamoDBRepository(new client_dynamodb_1.DynamoDBClient(), "foo");
|
|
23
|
-
(0, bun_test_1.expect)(repo.getShopById("test")).resolves.toBeNull();
|
|
24
|
-
});
|
|
25
|
-
(0, bun_test_1.test)("getShopById exists", async () => {
|
|
26
|
-
bun_test_1.mock.module("@aws-sdk/lib-dynamodb", () => {
|
|
27
|
-
return {
|
|
28
|
-
DynamoDBDocumentClient: {
|
|
29
|
-
from() {
|
|
30
|
-
return {
|
|
31
|
-
async send() {
|
|
32
|
-
return {
|
|
33
|
-
Item: {
|
|
34
|
-
id: "a",
|
|
35
|
-
url: "b",
|
|
36
|
-
secret: "c",
|
|
37
|
-
},
|
|
38
|
-
};
|
|
39
|
-
},
|
|
40
|
-
};
|
|
41
|
-
},
|
|
42
|
-
},
|
|
43
|
-
};
|
|
44
|
-
});
|
|
45
|
-
const repo = new dynamodb_js_1.DynamoDBRepository(new client_dynamodb_1.DynamoDBClient(), "foo");
|
|
46
|
-
(0, bun_test_1.expect)(repo.getShopById("test")).resolves.not.toBeNull();
|
|
47
|
-
});
|
|
48
|
-
(0, bun_test_1.test)("createShop", async () => {
|
|
49
|
-
let cmd;
|
|
50
|
-
bun_test_1.mock.module("@aws-sdk/lib-dynamodb", () => {
|
|
51
|
-
return {
|
|
52
|
-
DynamoDBDocumentClient: {
|
|
53
|
-
from() {
|
|
54
|
-
return {
|
|
55
|
-
async send(inner) {
|
|
56
|
-
cmd = inner;
|
|
57
|
-
return {};
|
|
58
|
-
},
|
|
59
|
-
};
|
|
60
|
-
},
|
|
61
|
-
},
|
|
62
|
-
};
|
|
63
|
-
});
|
|
64
|
-
const repo = new dynamodb_js_1.DynamoDBRepository(new client_dynamodb_1.DynamoDBClient(), "foo");
|
|
65
|
-
await repo.createShop("a", "b", "c");
|
|
66
|
-
// @ts-expect-error
|
|
67
|
-
(0, bun_test_1.expect)(cmd).toBeDefined();
|
|
68
|
-
// @ts-expect-error
|
|
69
|
-
(0, bun_test_1.expect)(cmd.input.Item).toEqual({
|
|
70
|
-
id: "a",
|
|
71
|
-
active: true,
|
|
72
|
-
url: "b",
|
|
73
|
-
secret: "c",
|
|
74
|
-
clientId: null,
|
|
75
|
-
clientSecret: null,
|
|
76
|
-
});
|
|
77
|
-
});
|
|
78
|
-
(0, bun_test_1.test)("updateShop", async () => {
|
|
79
|
-
let cmd;
|
|
80
|
-
bun_test_1.mock.module("@aws-sdk/lib-dynamodb", () => {
|
|
81
|
-
return {
|
|
82
|
-
DynamoDBDocumentClient: {
|
|
83
|
-
from() {
|
|
84
|
-
return {
|
|
85
|
-
async send(inner) {
|
|
86
|
-
cmd = inner;
|
|
87
|
-
return {};
|
|
88
|
-
},
|
|
89
|
-
};
|
|
90
|
-
},
|
|
91
|
-
},
|
|
92
|
-
};
|
|
93
|
-
});
|
|
94
|
-
const repo = new dynamodb_js_1.DynamoDBRepository(new client_dynamodb_1.DynamoDBClient(), "foo");
|
|
95
|
-
await repo.updateShop(new repository_js_1.SimpleShop("a", "b", "c"));
|
|
96
|
-
// @ts-expect-error
|
|
97
|
-
(0, bun_test_1.expect)(cmd).toBeDefined();
|
|
98
|
-
// @ts-expect-error
|
|
99
|
-
(0, bun_test_1.expect)(cmd.input.Item).toEqual({
|
|
100
|
-
id: "a",
|
|
101
|
-
active: true,
|
|
102
|
-
url: "b",
|
|
103
|
-
secret: "c",
|
|
104
|
-
clientId: null,
|
|
105
|
-
clientSecret: null,
|
|
106
|
-
});
|
|
107
|
-
});
|
|
108
|
-
(0, bun_test_1.test)("deleteShop", async () => {
|
|
109
|
-
let cmd;
|
|
110
|
-
bun_test_1.mock.module("@aws-sdk/lib-dynamodb", () => {
|
|
111
|
-
return {
|
|
112
|
-
DynamoDBDocumentClient: {
|
|
113
|
-
from() {
|
|
114
|
-
return {
|
|
115
|
-
async send(inner) {
|
|
116
|
-
cmd = inner;
|
|
117
|
-
return {};
|
|
118
|
-
},
|
|
119
|
-
};
|
|
120
|
-
},
|
|
121
|
-
},
|
|
122
|
-
};
|
|
123
|
-
});
|
|
124
|
-
const repo = new dynamodb_js_1.DynamoDBRepository(new client_dynamodb_1.DynamoDBClient(), "foo");
|
|
125
|
-
await repo.deleteShop("a");
|
|
126
|
-
// @ts-expect-error
|
|
127
|
-
(0, bun_test_1.expect)(cmd).toBeDefined();
|
|
128
|
-
// @ts-expect-error
|
|
129
|
-
(0, bun_test_1.expect)(cmd.input.Key).toEqual({ id: "a" });
|
|
130
|
-
});
|
|
131
|
-
});
|
|
132
|
-
//# sourceMappingURL=dynamodb.test.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"dynamodb.test.js","sourceRoot":"","sources":["../../../src/integration/dynamodb.test.ts"],"names":[],"mappings":";;AAAA,uCAAwD;AACxD,+CAAmD;AAEnD,8DAA0D;AAE1D,oDAA8C;AAE9C,IAAA,mBAAQ,EAAC,UAAU,EAAE,KAAK,IAAI,EAAE;IAC/B,IAAA,eAAI,EAAC,6BAA6B,EAAE,KAAK,IAAI,EAAE;QAC9C,eAAI,CAAC,MAAM,CAAC,uBAAuB,EAAE,GAAG,EAAE;YACzC,OAAO;gBACN,sBAAsB,EAAE;oBACvB,IAAI;wBACH,OAAO;4BACN,KAAK,CAAC,IAAI;gCACT,OAAO,EAAE,CAAC;4BACX,CAAC;yBACD,CAAC;oBACH,CAAC;iBACD;aACD,CAAC;QACH,CAAC,CAAC,CAAC;QAEH,MAAM,IAAI,GAAG,IAAI,gCAAkB,CAAC,IAAI,gCAAc,EAAE,EAAE,KAAK,CAAC,CAAC;QAEjE,IAAA,iBAAM,EAAC,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC,CAAC,QAAQ,CAAC,QAAQ,EAAE,CAAC;IACtD,CAAC,CAAC,CAAC;IAEH,IAAA,eAAI,EAAC,oBAAoB,EAAE,KAAK,IAAI,EAAE;QACrC,eAAI,CAAC,MAAM,CAAC,uBAAuB,EAAE,GAAG,EAAE;YACzC,OAAO;gBACN,sBAAsB,EAAE;oBACvB,IAAI;wBACH,OAAO;4BACN,KAAK,CAAC,IAAI;gCACT,OAAO;oCACN,IAAI,EAAE;wCACL,EAAE,EAAE,GAAG;wCACP,GAAG,EAAE,GAAG;wCACR,MAAM,EAAE,GAAG;qCACX;iCACD,CAAC;4BACH,CAAC;yBACD,CAAC;oBACH,CAAC;iBACD;aACD,CAAC;QACH,CAAC,CAAC,CAAC;QAEH,MAAM,IAAI,GAAG,IAAI,gCAAkB,CAAC,IAAI,gCAAc,EAAE,EAAE,KAAK,CAAC,CAA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,mBAAmB;QACnB,IAAA,iBAAM,EAAC,GAAG,CAAC,CAAC,WAAW,EAAE,CAAC;QAC1B,mBAAmB;QACnB,IAAA,iBAAM,EAAC,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,OAAO,CAAC,EAAE,EAAE,EAAE,GAAG,EAAE,CAAC,CAAC;IAC5C,CAAC,CAAC,CAAC;AACJ,CAAC,CAAC,CAAC","sourcesContent":["import { describe, expect, mock, test } from \"bun:test\";\nimport { DynamoDBRepository } from \"./dynamodb.js\";\n\nimport { DynamoDBClient } from \"@aws-sdk/client-dynamodb\";\nimport type { DeleteCommand, PutCommand } from \"@aws-sdk/lib-dynamodb\";\nimport { SimpleShop } from \"../repository.js\";\n\ndescribe(\"DynamoDB\", async () => {\n\ttest(\"getShopById does not exists\", async () => {\n\t\tmock.module(\"@aws-sdk/lib-dynamodb\", () => {\n\t\t\treturn {\n\t\t\t\tDynamoDBDocumentClient: {\n\t\t\t\t\tfrom() {\n\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\tasync send() {\n\t\t\t\t\t\t\t\treturn {};\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t};\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t};\n\t\t});\n\n\t\tconst repo = new DynamoDBRepository(new DynamoDBClient(), \"foo\");\n\n\t\texpect(repo.getShopById(\"test\")).resolves.toBeNull();\n\t});\n\n\ttest(\"getShopById exists\", async () => {\n\t\tmock.module(\"@aws-sdk/lib-dynamodb\", () => {\n\t\t\treturn {\n\t\t\t\tDynamoDBDocumentClient: {\n\t\t\t\t\tfrom() {\n\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\tasync send() {\n\t\t\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\t\t\tItem: {\n\t\t\t\t\t\t\t\t\t\tid: \"a\",\n\t\t\t\t\t\t\t\t\t\turl: \"b\",\n\t\t\t\t\t\t\t\t\t\tsecret: \"c\",\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t};\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t};\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t};\n\t\t});\n\n\t\tconst repo = new DynamoDBRepository(new DynamoDBClient(), \"foo\");\n\n\t\texpect(repo.getShopById(\"test\")).resolves.not.toBeNull();\n\t});\n\n\ttest(\"createShop\", async () => {\n\t\tlet cmd: PutCommand;\n\n\t\tmock.module(\"@aws-sdk/lib-dynamodb\", () => {\n\t\t\treturn {\n\t\t\t\tDynamoDBDocumentClient: {\n\t\t\t\t\tfrom() {\n\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\tasync send(inner: PutCommand) {\n\t\t\t\t\t\t\t\tcmd = inner;\n\t\t\t\t\t\t\t\treturn {};\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t};\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t};\n\t\t});\n\n\t\tconst repo = new DynamoDBRepository(new DynamoDBClient(), \"foo\");\n\n\t\tawait repo.createShop(\"a\", \"b\", \"c\");\n\n\t\t// @ts-expect-error\n\t\texpect(cmd).toBeDefined();\n\t\t// @ts-expect-error\n\t\texpect(cmd.input.Item).toEqual({\n\t\t\tid: \"a\",\n\t\t\tactive: true,\n\t\t\turl: \"b\",\n\t\t\tsecret: \"c\",\n\t\t\tclientId: null,\n\t\t\tclientSecret: null,\n\t\t});\n\t});\n\n\ttest(\"updateShop\", async () => {\n\t\tlet cmd: PutCommand;\n\n\t\tmock.module(\"@aws-sdk/lib-dynamodb\", () => {\n\t\t\treturn {\n\t\t\t\tDynamoDBDocumentClient: {\n\t\t\t\t\tfrom() {\n\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\tasync send(inner: PutCommand) {\n\t\t\t\t\t\t\t\tcmd = inner;\n\t\t\t\t\t\t\t\treturn {};\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t};\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t};\n\t\t});\n\n\t\tconst repo = new DynamoDBRepository(new DynamoDBClient(), \"foo\");\n\n\t\tawait repo.updateShop(new SimpleShop(\"a\", \"b\", \"c\"));\n\n\t\t// @ts-expect-error\n\t\texpect(cmd).toBeDefined();\n\t\t// @ts-expect-error\n\t\texpect(cmd.input.Item).toEqual({\n\t\t\tid: \"a\",\n\t\t\tactive: true,\n\t\t\turl: \"b\",\n\t\t\tsecret: \"c\",\n\t\t\tclientId: null,\n\t\t\tclientSecret: null,\n\t\t});\n\t});\n\n\ttest(\"deleteShop\", async () => {\n\t\tlet cmd: DeleteCommand;\n\n\t\tmock.module(\"@aws-sdk/lib-dynamodb\", () => {\n\t\t\treturn {\n\t\t\t\tDynamoDBDocumentClient: {\n\t\t\t\t\tfrom() {\n\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\tasync send(inner: DeleteCommand) {\n\t\t\t\t\t\t\t\tcmd = inner;\n\t\t\t\t\t\t\t\treturn {};\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t};\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t};\n\t\t});\n\n\t\tconst repo = new DynamoDBRepository(new DynamoDBClient(), \"foo\");\n\n\t\tawait repo.deleteShop(\"a\");\n\n\t\t// @ts-expect-error\n\t\texpect(cmd).toBeDefined();\n\t\t// @ts-expect-error\n\t\texpect(cmd.input.Key).toEqual({ id: \"a\" });\n\t});\n});\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"hono.test.d.ts","sourceRoot":"","sources":["../../../src/integration/hono.test.ts"],"names":[],"mappings":""}
|
|
@@ -1,86 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const bun_test_1 = require("bun:test");
|
|
4
|
-
const hono_1 = require("hono");
|
|
5
|
-
const repository_js_1 = require("../repository.js");
|
|
6
|
-
const hono_js_1 = require("./hono.js");
|
|
7
|
-
(0, bun_test_1.describe)("Hono", async () => {
|
|
8
|
-
const repo = new repository_js_1.InMemoryShopRepository();
|
|
9
|
-
await repo.createShop("a", "a", "a");
|
|
10
|
-
(0, bun_test_1.test)("configre by functions", async () => {
|
|
11
|
-
const hono = new hono_1.Hono();
|
|
12
|
-
(0, hono_js_1.configureAppServer)(hono, {
|
|
13
|
-
appName: () => "test",
|
|
14
|
-
appSecret: () => "test",
|
|
15
|
-
shopRepository: () => repo,
|
|
16
|
-
});
|
|
17
|
-
const resp = await hono.fetch(new Request("http://localhost/app/register"));
|
|
18
|
-
(0, bun_test_1.expect)(resp.status).toBe(400);
|
|
19
|
-
});
|
|
20
|
-
(0, bun_test_1.test)("register", async () => {
|
|
21
|
-
const hono = new hono_1.Hono();
|
|
22
|
-
(0, hono_js_1.configureAppServer)(hono, {
|
|
23
|
-
appName: "test",
|
|
24
|
-
appSecret: "test",
|
|
25
|
-
shopRepository: repo,
|
|
26
|
-
});
|
|
27
|
-
const resp = await hono.fetch(new Request("http://localhost/app/register"));
|
|
28
|
-
(0, bun_test_1.expect)(resp.status).toBe(400);
|
|
29
|
-
});
|
|
30
|
-
(0, bun_test_1.test)("register: success", async () => {
|
|
31
|
-
const hono = new hono_1.Hono();
|
|
32
|
-
(0, hono_js_1.configureAppServer)(hono, {
|
|
33
|
-
appName: "My App",
|
|
34
|
-
appSecret: "my-secret",
|
|
35
|
-
shopRepository: repo,
|
|
36
|
-
});
|
|
37
|
-
const resp = await hono.fetch(new Request("http://localhost/app/register?shop-id=123&shop-url=https://my-shop.com×tamp=1234567890", {
|
|
38
|
-
headers: new Headers({
|
|
39
|
-
"shopware-app-signature": "96c91f86c822e11444b7a57b54ef125ed86b1a639c5360d45c5397daa8c3f70b",
|
|
40
|
-
}),
|
|
41
|
-
}));
|
|
42
|
-
(0, bun_test_1.expect)(resp.status).toBe(200);
|
|
43
|
-
const body = (await resp.json());
|
|
44
|
-
(0, bun_test_1.expect)(body).toBeObject();
|
|
45
|
-
(0, bun_test_1.expect)(body.proof).not.toBeNull();
|
|
46
|
-
});
|
|
47
|
-
(0, bun_test_1.test)("registerConfirm", async () => {
|
|
48
|
-
const hono = new hono_1.Hono();
|
|
49
|
-
(0, hono_js_1.configureAppServer)(hono, {
|
|
50
|
-
appName: "test",
|
|
51
|
-
appSecret: "test",
|
|
52
|
-
shopRepository: repo,
|
|
53
|
-
});
|
|
54
|
-
const resp = await hono.fetch(new Request("http://localhost/app/register/confirm", {
|
|
55
|
-
method: "POST",
|
|
56
|
-
body: "{}",
|
|
57
|
-
}));
|
|
58
|
-
(0, bun_test_1.expect)(resp.status).toBe(400);
|
|
59
|
-
});
|
|
60
|
-
(0, bun_test_1.test)("signature failure", async () => {
|
|
61
|
-
const hono = new hono_1.Hono();
|
|
62
|
-
(0, hono_js_1.configureAppServer)(hono, {
|
|
63
|
-
appName: "test",
|
|
64
|
-
appSecret: "test",
|
|
65
|
-
shopRepository: repo,
|
|
66
|
-
});
|
|
67
|
-
hono.get("/app/test", (c) => c.text("ok"));
|
|
68
|
-
const resp = await hono.fetch(new Request("http://localhost/app/test?shopware-shop-signature=invalid&shop-id=a"));
|
|
69
|
-
(0, bun_test_1.expect)(resp.status).toBe(400);
|
|
70
|
-
(0, bun_test_1.expect)(await resp.text()).toBe('{"message":"Invalid request"}');
|
|
71
|
-
});
|
|
72
|
-
(0, bun_test_1.test)("signature success", async () => {
|
|
73
|
-
const hono = new hono_1.Hono();
|
|
74
|
-
(0, hono_js_1.configureAppServer)(hono, {
|
|
75
|
-
appName: "test",
|
|
76
|
-
appSecret: "test",
|
|
77
|
-
shopRepository: repo,
|
|
78
|
-
});
|
|
79
|
-
hono.get("/app/test", (c) => c.text("ok"));
|
|
80
|
-
const resp = await hono.fetch(new Request("http://localhost/app/test?shopware-shop-signature=8b523d99aeef5b456288fcec48236c3367a914c6b2c9fded63d81257ac019b25&shop-id=a"));
|
|
81
|
-
(0, bun_test_1.expect)(resp.status).toBe(200);
|
|
82
|
-
(0, bun_test_1.expect)(await resp.text()).toBe("ok");
|
|
83
|
-
(0, bun_test_1.expect)(resp.headers.get("shopware-app-signature")).toBe("4a43a105ccce57e8e38d4a1f7b3565d743b1e15fb1fec36f41fdf20164fa1c8b");
|
|
84
|
-
});
|
|
85
|
-
});
|
|
86
|
-
//# 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,uCAAkD;AAClD,+BAA4B;AAC5B,oDAA0D;AAC1D,uCAA+C;AAE/C,IAAA,mBAAQ,EAAC,MAAM,EAAE,KAAK,IAAI,EAAE;IAC3B,MAAM,IAAI,GAAG,IAAI,sCAAsB,EAAE,CAAC;IAE1C,MAAM,IAAI,CAAC,UAAU,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC;IAErC,IAAA,eAAI,EAAC,uBAAuB,EAAE,KAAK,IAAI,EAAE;QACxC,MAAM,IAAI,GAAG,IAAI,WAAI,EAAE,CAAC;QAExB,IAAA,4BAAkB,EAAC,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,IAAA,iBAAM,EAAC,IAAI,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IAC/B,CAAC,CAAC,CAAC;IAEH,IAAA,eAAI,EAAC,UAAU,EAAE,KAAK,IAAI,EAAE;QAC3B,MAAM,IAAI,GAAG,IAAI,WAAI,EAAE,CAAC;QAExB,IAAA,4BAAkB,EAAC,IAAI,EAAE;YACxB,OAAO,EAAE,MAAM;YACf,SAAS,EAAE,MAAM;YACjB,cAAc,EAAE,IAAI;SACpB,CAAC,CAA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AAC,CAAC,CAAC;QAE3C,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,KAAK,CAC5B,IAAI,OAAO,CACV,8HAA8H,CAC9H,CACD,CAAC;QAEF,IAAA,iBAAM,EAAC,IAAI,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;QAC9B,IAAA,iBAAM,EAAC,MAAM,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACrC,IAAA,iBAAM,EAAC,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,59 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const bun_test_1 = require("bun:test");
|
|
4
|
-
const app_js_1 = require("../src/app.js");
|
|
5
|
-
const repository_js_1 = require("../src/repository.js");
|
|
6
|
-
(0, bun_test_1.describe)("Registration", async () => {
|
|
7
|
-
const app = new app_js_1.AppServer({ appName: "test", appSecret: "test", authorizeCallbackUrl: "test" }, new repository_js_1.InMemoryShopRepository());
|
|
8
|
-
(0, bun_test_1.test)("authorize: invalid request", async () => {
|
|
9
|
-
const resp = await app.registration.authorize(new Request("http://localhost"));
|
|
10
|
-
(0, bun_test_1.expect)(resp.status).toBe(400);
|
|
11
|
-
});
|
|
12
|
-
(0, bun_test_1.test)("authorize: invalid signature", async () => {
|
|
13
|
-
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" }) }));
|
|
14
|
-
(0, bun_test_1.expect)(resp.status).toBe(401);
|
|
15
|
-
});
|
|
16
|
-
(0, bun_test_1.test)("authorize: valid request", async () => {
|
|
17
|
-
app.signer.verify = bun_test_1.jest.fn().mockResolvedValue(true);
|
|
18
|
-
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" }) }));
|
|
19
|
-
(0, bun_test_1.expect)(resp.status).toBe(200);
|
|
20
|
-
});
|
|
21
|
-
(0, bun_test_1.test)("authorizeCallback: invalid request", async () => {
|
|
22
|
-
const resp = await app.registration.authorizeCallback(new Request("http://localhost", { body: "{}" }));
|
|
23
|
-
(0, bun_test_1.expect)(resp.status).toBe(400);
|
|
24
|
-
});
|
|
25
|
-
(0, bun_test_1.test)("authorizeCallback: shop does not exist", async () => {
|
|
26
|
-
const resp = await app.registration.authorizeCallback(new Request("http://localhost", {
|
|
27
|
-
body: '{"shopId": "test", "apiKey": "test", "secretKey": "test"}',
|
|
28
|
-
}));
|
|
29
|
-
(0, bun_test_1.expect)(resp.status).toBe(400);
|
|
30
|
-
});
|
|
31
|
-
(0, bun_test_1.test)("activateShop", async () => {
|
|
32
|
-
await app.repository.createShop("1", "http://localhost", "test");
|
|
33
|
-
const shop = await app.repository.getShopById("1");
|
|
34
|
-
shop?.setShopActive(false);
|
|
35
|
-
app.contextResolver.fromAPI = bun_test_1.jest.fn().mockResolvedValue({ shop });
|
|
36
|
-
const resp = await app.registration.activate(new Request("http://localhost", { body: '{"source": {"shopId": "1"}}' }));
|
|
37
|
-
(0, bun_test_1.expect)(resp.status).toBe(204);
|
|
38
|
-
(0, bun_test_1.expect)(shop?.getShopActive()).toBe(true);
|
|
39
|
-
});
|
|
40
|
-
(0, bun_test_1.test)("deactivateShop", async () => {
|
|
41
|
-
await app.repository.createShop("1", "http://localhost", "test");
|
|
42
|
-
const shop = await app.repository.getShopById("1");
|
|
43
|
-
shop?.setShopActive(true);
|
|
44
|
-
app.contextResolver.fromAPI = bun_test_1.jest.fn().mockResolvedValue({ shop });
|
|
45
|
-
const resp = await app.registration.deactivate(new Request("http://localhost", { body: '{"source": {"shopId": "1"}}' }));
|
|
46
|
-
(0, bun_test_1.expect)(resp.status).toBe(204);
|
|
47
|
-
(0, bun_test_1.expect)(shop?.getShopActive()).toBe(false);
|
|
48
|
-
});
|
|
49
|
-
(0, bun_test_1.test)("deletedShop", async () => {
|
|
50
|
-
await app.repository.createShop("1", "http://localhost", "test");
|
|
51
|
-
const shop = await app.repository.getShopById("1");
|
|
52
|
-
(0, bun_test_1.expect)(shop).not.toBeNull();
|
|
53
|
-
app.contextResolver.fromAPI = bun_test_1.jest.fn().mockResolvedValue({ shop });
|
|
54
|
-
const resp = await app.registration.delete(new Request("http://localhost", { body: '{"source": {"shopId": "1"}}' }));
|
|
55
|
-
(0, bun_test_1.expect)(resp.status).toBe(204);
|
|
56
|
-
(0, bun_test_1.expect)(app.repository.getShopById("1")).resolves.toBeNull();
|
|
57
|
-
});
|
|
58
|
-
});
|
|
59
|
-
//# sourceMappingURL=registration.test.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"registration.test.js","sourceRoot":"","sources":["../../src/registration.test.ts"],"names":[],"mappings":";;AAAA,uCAAwD;AACxD,0CAA0C;AAC1C,wDAA0E;AAE1E,IAAA,mBAAQ,EAAC,cAAc,EAAE,KAAK,IAAI,EAAE;IACnC,MAAM,GAAG,GAAG,IAAI,kBAAS,CACxB,EAAE,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,oBAAoB,EAAE,MAAM,EAAE,EACpE,IAAI,sCAAsB,EAAE,CAC5B,CAAC;IAEF,IAAA,eAAI,EAAC,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,IAAA,iBAAM,EAAC,IAAI,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IAC/B,CAAC,CAAC,CAAC;IAEH,IAA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AW,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,32 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const bun_test_1 = require("bun:test");
|
|
4
|
-
const repository_js_1 = require("../src/repository.js");
|
|
5
|
-
(0, bun_test_1.describe)("Repository", async () => {
|
|
6
|
-
(0, bun_test_1.test)("SimpleShop", async () => {
|
|
7
|
-
const shop = new repository_js_1.SimpleShop("test", "test", "test");
|
|
8
|
-
(0, bun_test_1.expect)(shop.getShopId()).toBe("test");
|
|
9
|
-
(0, bun_test_1.expect)(shop.getShopUrl()).toBe("test");
|
|
10
|
-
(0, bun_test_1.expect)(shop.getShopSecret()).toBe("test");
|
|
11
|
-
(0, bun_test_1.expect)(shop.getShopClientId()).toBeNull();
|
|
12
|
-
(0, bun_test_1.expect)(shop.getShopClientSecret()).toBeNull();
|
|
13
|
-
(0, bun_test_1.expect)(shop.getShopActive()).toBe(true);
|
|
14
|
-
shop.setShopActive(false);
|
|
15
|
-
(0, bun_test_1.expect)(shop.getShopActive()).toBe(false);
|
|
16
|
-
shop.setShopCredentials("test", "test");
|
|
17
|
-
(0, bun_test_1.expect)(shop.getShopClientId()).toBe("test");
|
|
18
|
-
(0, bun_test_1.expect)(shop.getShopClientSecret()).toBe("test");
|
|
19
|
-
});
|
|
20
|
-
(0, bun_test_1.test)("InMemoryShopRepository", async () => {
|
|
21
|
-
const shop = new repository_js_1.SimpleShop("test", "test", "test");
|
|
22
|
-
const repository = new repository_js_1.InMemoryShopRepository();
|
|
23
|
-
(0, bun_test_1.expect)(repository.getShopById("test")).resolves.toBeNull();
|
|
24
|
-
await repository.createShop("test", "test", "test");
|
|
25
|
-
(0, bun_test_1.expect)(repository.getShopById("test")).resolves.toBeInstanceOf(repository_js_1.SimpleShop);
|
|
26
|
-
await repository.deleteShop("test");
|
|
27
|
-
(0, bun_test_1.expect)(repository.getShopById("test")).resolves.toBeNull();
|
|
28
|
-
await repository.updateShop(shop);
|
|
29
|
-
(0, bun_test_1.expect)(repository.getShopById("test")).resolves.toBe(shop);
|
|
30
|
-
});
|
|
31
|
-
});
|
|
32
|
-
//# sourceMappingURL=repository.test.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"repository.test.js","sourceRoot":"","sources":["../../src/repository.test.ts"],"names":[],"mappings":";;AAAA,uCAAkD;AAClD,wDAA0E;AAE1E,IAAA,mBAAQ,EAAC,YAAY,EAAE,KAAK,IAAI,EAAE;IACjC,IAAA,eAAI,EAAC,YAAY,EAAE,KAAK,IAAI,EAAE;QAC7B,MAAM,IAAI,GAAG,IAAI,0BAAU,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;QAEpD,IAAA,iBAAM,EAAC,IAAI,CAAC,SAAS,EAAE,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QACtC,IAAA,iBAAM,EAAC,IAAI,CAAC,UAAU,EAAE,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QACvC,IAAA,iBAAM,EAAC,IAAI,CAAC,aAAa,EAAE,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QAC1C,IAAA,iBAAM,EAAC,IAAI,CAAC,eAAe,EAAE,CAAC,CAAC,QAAQ,EAAE,CAAC;QAC1C,IAAA,iBAAM,EAAC,IAAI,CAAC,mBAAmB,EAAE,CAAC,CAAC,QAAQ,EAAE,CAAC;QAC9C,IAAA,iBAAM,EAAC,IAAI,CAAC,aAAa,EAAE,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAExC,IAAI,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC;QAE1B,IAAA,iBAAM,EAAC,IAAI,CAAC,aAAa,EAAE,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QAEzC,IAAI,CAAC,kBAAkB,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;QAExC,IAAA,iBAAM,EAAC,IAAI,CAAC,eAAe,EAAE,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QAC5C,IAAA,iBAAM,EAAC,IAAI,CAAC,mBAAmB,EAAE,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IACjD,CAAC,CAAC,CAAC;IAEH,IAAA,eAAI,EAAC,wBAAwB,EAAE,KAAK,IAAI,EAAE;QACzC,MAAM,IAAI,GAAG,IAAI,0BAAU,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;QAEpD,MAAM,UAAU,GAAG,IAAI,sCAAsB,EAAE,CAAC;QAEhD,IAAA,iBAAM,EAAC,UAAU,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC,CAAC,QAAQ,CAAC,QAAQ,EAAE,CAAC;QAE3D,MAAM,UAAU,CAAC,UAAU,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;QAEpD,IAAA,iBAAM,EAAC,UAAU,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC,CAAC,QAAQ,CAAC,cAAc,CAAC,0BAAU,CAAC,CAAC;QAE3E,MAAM,UAAU,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC;QAEpC,IAAA,iBAAM,EAAC,UAAU,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC,CAAC,QAAQ,CAAC,QAAQ,EAAE,CAAC;QAE3D,MAAM,UAAU,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC;QAElC,IAAA,iBAAM,EAAC,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":""}
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const bun_test_1 = require("bun:test");
|
|
4
|
-
const signer_js_1 = require("../src/signer.js");
|
|
5
|
-
(0, bun_test_1.describe)("Signer", () => {
|
|
6
|
-
(0, bun_test_1.test)("signResponse", async () => {
|
|
7
|
-
const signer = new signer_js_1.WebCryptoHmacSigner();
|
|
8
|
-
const response = new Response("Hello, World!");
|
|
9
|
-
await signer.signResponse(response, "test");
|
|
10
|
-
(0, bun_test_1.expect)(response.headers.get("shopware-app-signature")).toBe("52589bd80ccfa4acbb3f9512dfaf4f700fa5195008aae0b77a9e47dcca75beac");
|
|
11
|
-
await signer.signResponse(response, "test");
|
|
12
|
-
(0, bun_test_1.expect)(response.headers.get("shopware-app-signature")).toBe("52589bd80ccfa4acbb3f9512dfaf4f700fa5195008aae0b77a9e47dcca75beac");
|
|
13
|
-
});
|
|
14
|
-
(0, bun_test_1.test)("sign", async () => {
|
|
15
|
-
const signer = new signer_js_1.WebCryptoHmacSigner();
|
|
16
|
-
(0, bun_test_1.expect)(await signer.sign("shop-id=blaa", "test")).toBe("f2cb1044ac5a2cb807e1942b06433d23d66bcf7dfad1095b286203e5c1f39cb6");
|
|
17
|
-
});
|
|
18
|
-
(0, bun_test_1.test)("verifyGetRequest", async () => {
|
|
19
|
-
const signer = new signer_js_1.WebCryptoHmacSigner();
|
|
20
|
-
(0, bun_test_1.expect)(signer.verifyGetRequest(new Request("https://example.com/?shopware-shop-signature=52589bd80ccfa4acbb3f9512dfaf4f700fa5195008aae0b77a9e47dcca75beac"), "test")).rejects.toThrowError("Missing query parameters to verify the GET request");
|
|
21
|
-
(0, bun_test_1.expect)(signer.verifyGetRequest(new Request("https://example.com/?shopware-shop-signature=52589bd80ccfa4acbb3f9512dfaf4f700fa5195008aae0b77a9e47dcca75beac&a=1"), "test")).rejects.toThrowError("Invalid signature");
|
|
22
|
-
(0, bun_test_1.expect)(signer.verifyGetRequest(new Request("https://example.com/?shopware-shop-signature=f2cb1044ac5a2cb807e1942b06433d23d66bcf7dfad1095b286203e5c1f39cb6&shop-id=blaa"), "test")).resolves.pass();
|
|
23
|
-
});
|
|
24
|
-
});
|
|
25
|
-
//# sourceMappingURL=signer.test.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"signer.test.js","sourceRoot":"","sources":["../../src/signer.test.ts"],"names":[],"mappings":";;AAAA,uCAAkD;AAClD,gDAAuD;AAEvD,IAAA,mBAAQ,EAAC,QAAQ,EAAE,GAAG,EAAE;IACvB,IAA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;QAE5C,IAAA,iBAAM,EACL,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"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"context-resolver.test.d.ts","sourceRoot":"","sources":["../../src/context-resolver.test.ts"],"names":[],"mappings":""}
|