@shopware-ag/app-server-sdk 1.0.1 → 1.1.1
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/README.md +52 -41
- 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/commonjs/integration/bun-sqlite.d.ts +11 -0
- package/dist/commonjs/integration/bun-sqlite.d.ts.map +1 -0
- package/dist/commonjs/integration/bun-sqlite.js +60 -0
- package/dist/commonjs/integration/bun-sqlite.js.map +1 -0
- package/dist/commonjs/integration/cloudflare-kv.d.ts +20 -0
- package/dist/commonjs/integration/cloudflare-kv.d.ts.map +1 -0
- package/dist/commonjs/integration/cloudflare-kv.js +49 -0
- package/dist/commonjs/integration/cloudflare-kv.js.map +1 -0
- package/dist/commonjs/integration/deno-kv.d.ts +18 -0
- package/dist/commonjs/integration/deno-kv.d.ts.map +1 -0
- package/dist/commonjs/integration/deno-kv.js +52 -0
- package/dist/commonjs/integration/deno-kv.js.map +1 -0
- package/dist/commonjs/integration/dynamodb.d.ts +13 -0
- package/dist/commonjs/integration/dynamodb.d.ts.map +1 -0
- package/dist/commonjs/integration/dynamodb.js +73 -0
- package/dist/commonjs/integration/dynamodb.js.map +1 -0
- package/dist/commonjs/integration/hono.d.ts +29 -0
- package/dist/commonjs/integration/hono.d.ts.map +1 -0
- package/dist/commonjs/integration/hono.js +105 -0
- package/dist/commonjs/integration/hono.js.map +1 -0
- 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/dist/esm/integration/bun-sqlite.d.ts +11 -0
- package/dist/esm/integration/bun-sqlite.d.ts.map +1 -0
- package/dist/esm/integration/bun-sqlite.js +56 -0
- package/dist/esm/integration/bun-sqlite.js.map +1 -0
- package/dist/esm/integration/cloudflare-kv.d.ts +20 -0
- package/dist/esm/integration/cloudflare-kv.d.ts.map +1 -0
- package/dist/esm/integration/cloudflare-kv.js +45 -0
- package/dist/esm/integration/cloudflare-kv.js.map +1 -0
- package/dist/esm/integration/deno-kv.d.ts +18 -0
- package/dist/esm/integration/deno-kv.d.ts.map +1 -0
- package/dist/esm/integration/deno-kv.js +48 -0
- package/dist/esm/integration/deno-kv.js.map +1 -0
- package/dist/esm/integration/dynamodb.d.ts +13 -0
- package/dist/esm/integration/dynamodb.d.ts.map +1 -0
- package/dist/esm/integration/dynamodb.js +69 -0
- package/dist/esm/integration/dynamodb.js.map +1 -0
- package/dist/esm/integration/hono.d.ts +29 -0
- package/dist/esm/integration/hono.d.ts.map +1 -0
- package/dist/esm/integration/hono.js +102 -0
- package/dist/esm/integration/hono.js.map +1 -0
- package/package.json +117 -6
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import { AppServer } from "../app.js";
|
|
2
|
+
/**
|
|
3
|
+
* Configure the Hono server to handle the app registration and context resolution
|
|
4
|
+
*/
|
|
5
|
+
export function configureAppServer(hono, cfg) {
|
|
6
|
+
let app = null;
|
|
7
|
+
cfg.registrationUrl = cfg.registrationUrl || "/app/register";
|
|
8
|
+
cfg.registerConfirmationUrl =
|
|
9
|
+
cfg.registerConfirmationUrl || "/app/register/confirm";
|
|
10
|
+
cfg.appActivateUrl = cfg.appActivateUrl || "/app/activate";
|
|
11
|
+
cfg.appDeactivateUrl = cfg.appDeactivateUrl || "/app/deactivate";
|
|
12
|
+
cfg.appDeleteUrl = cfg.appDeleteUrl || "/app/delete";
|
|
13
|
+
cfg.appPath = cfg.appPath || "/app/*";
|
|
14
|
+
hono.use("*", async (ctx, next) => {
|
|
15
|
+
if (app === null) {
|
|
16
|
+
const appUrl = cfg.appUrl || buildBaseUrl(ctx.req.url);
|
|
17
|
+
if (typeof cfg.shopRepository === "function") {
|
|
18
|
+
cfg.shopRepository = cfg.shopRepository(ctx);
|
|
19
|
+
}
|
|
20
|
+
if (typeof cfg.appName === "function") {
|
|
21
|
+
cfg.appName = cfg.appName(ctx);
|
|
22
|
+
}
|
|
23
|
+
if (typeof cfg.appSecret === "function") {
|
|
24
|
+
cfg.appSecret = cfg.appSecret(ctx);
|
|
25
|
+
}
|
|
26
|
+
app = new AppServer({
|
|
27
|
+
appName: cfg.appName,
|
|
28
|
+
appSecret: cfg.appSecret,
|
|
29
|
+
authorizeCallbackUrl: appUrl + cfg.registerConfirmationUrl,
|
|
30
|
+
}, cfg.shopRepository);
|
|
31
|
+
}
|
|
32
|
+
// @ts-ignore
|
|
33
|
+
ctx.set("app", app);
|
|
34
|
+
await next();
|
|
35
|
+
});
|
|
36
|
+
hono.use(cfg.appPath, async (ctx, next) => {
|
|
37
|
+
// @ts-ignore
|
|
38
|
+
const app = ctx.get("app");
|
|
39
|
+
// Don't validate signature for registration
|
|
40
|
+
if (ctx.req.path === cfg.registrationUrl ||
|
|
41
|
+
ctx.req.path === cfg.registerConfirmationUrl ||
|
|
42
|
+
ctx.req.path === cfg.appActivateUrl ||
|
|
43
|
+
ctx.req.path === cfg.appDeactivateUrl ||
|
|
44
|
+
ctx.req.path === cfg.appDeleteUrl) {
|
|
45
|
+
await next();
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
48
|
+
let context;
|
|
49
|
+
try {
|
|
50
|
+
context =
|
|
51
|
+
ctx.req.method === "GET"
|
|
52
|
+
? await app.contextResolver.fromBrowser(ctx.req.raw)
|
|
53
|
+
: await app.contextResolver.fromAPI(ctx.req.raw);
|
|
54
|
+
}
|
|
55
|
+
catch (_e) {
|
|
56
|
+
return jsonResponse({ message: "Invalid request" }, 400);
|
|
57
|
+
}
|
|
58
|
+
// @ts-ignore
|
|
59
|
+
ctx.set("shop", context.shop);
|
|
60
|
+
// @ts-ignore
|
|
61
|
+
ctx.set("context", context);
|
|
62
|
+
await next();
|
|
63
|
+
const cloned = ctx.res.clone();
|
|
64
|
+
await ctx
|
|
65
|
+
.get("app")
|
|
66
|
+
.signer.signResponse(cloned, ctx.get("shop").getShopSecret());
|
|
67
|
+
ctx.header("shopware-app-signature", cloned.headers.get("shopware-app-signature"));
|
|
68
|
+
});
|
|
69
|
+
hono.get(cfg.registrationUrl, async (ctx) => {
|
|
70
|
+
const app = ctx.get("app");
|
|
71
|
+
return await app.registration.authorize(ctx.req.raw);
|
|
72
|
+
});
|
|
73
|
+
hono.post(cfg.registerConfirmationUrl, async (ctx) => {
|
|
74
|
+
const app = ctx.get("app");
|
|
75
|
+
return await app.registration.authorizeCallback(ctx.req.raw);
|
|
76
|
+
});
|
|
77
|
+
hono.post(cfg.appActivateUrl, async (ctx) => {
|
|
78
|
+
const app = ctx.get("app");
|
|
79
|
+
return await app.registration.activate(ctx.req.raw);
|
|
80
|
+
});
|
|
81
|
+
hono.post(cfg.appDeactivateUrl, async (ctx) => {
|
|
82
|
+
const app = ctx.get("app");
|
|
83
|
+
return await app.registration.deactivate(ctx.req.raw);
|
|
84
|
+
});
|
|
85
|
+
hono.post(cfg.appDeleteUrl, async (ctx) => {
|
|
86
|
+
const app = ctx.get("app");
|
|
87
|
+
return await app.registration.delete(ctx.req.raw);
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
function jsonResponse(body, status = 200) {
|
|
91
|
+
return new Response(JSON.stringify(body), {
|
|
92
|
+
status,
|
|
93
|
+
headers: {
|
|
94
|
+
"Content-Type": "application/json",
|
|
95
|
+
},
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
function buildBaseUrl(url) {
|
|
99
|
+
const u = new URL(url);
|
|
100
|
+
return `${u.protocol}//${u.host}`;
|
|
101
|
+
}
|
|
102
|
+
//# sourceMappingURL=hono.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hono.js","sourceRoot":"","sources":["../../../src/integration/hono.ts"],"names":[],"mappings":"AAAA,OAAO,EAA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js\";\nimport type { ShopInterface, ShopRepositoryInterface } from \"../repository.js\";\n\nimport type { Hono, Context as HonoContext } from \"hono\";\n\ndeclare module \"hono\" {\n\tinterface ContextVariableMap {\n\t\t// @ts-ignore\n\t\tapp: AppServer<ShopInterface>;\n\t\tshop: ShopInterface;\n\t\t// @ts-ignore\n\t\tcontext: Context<ShopInterface, unknown>;\n\t}\n}\n\ninterface MiddlewareConfig {\n\tappName: string | ((c: HonoContext) => string);\n\tappSecret: string | ((c: HonoContext) => string);\n\tappUrl?: string | null;\n\tregistrationUrl?: string | null;\n\tregisterConfirmationUrl?: string | null;\n\tappActivateUrl?: string | null;\n\tappDeactivateUrl?: string | null;\n\tappDeleteUrl?: string | null;\n\tappPath?: string | null;\n\tshopRepository:\n\t\t| ShopRepositoryInterface\n\t\t| ((c: HonoContext) => ShopRepositoryInterface);\n}\n\n/**\n * Configure the Hono server to handle the app registration and context resolution\n */\nexport function configureAppServer(hono: Hono, cfg: MiddlewareConfig) {\n\tlet app: AppServer | null = null;\n\n\tcfg.registrationUrl = cfg.registrationUrl || \"/app/register\";\n\tcfg.registerConfirmationUrl =\n\t\tcfg.registerConfirmationUrl || \"/app/register/confirm\";\n\tcfg.appActivateUrl = cfg.appActivateUrl || \"/app/activate\";\n\tcfg.appDeactivateUrl = cfg.appDeactivateUrl || \"/app/deactivate\";\n\tcfg.appDeleteUrl = cfg.appDeleteUrl || \"/app/delete\";\n\tcfg.appPath = cfg.appPath || \"/app/*\";\n\n\thono.use(\"*\", async (ctx, next) => {\n\t\tif (app === null) {\n\t\t\tconst appUrl = cfg.appUrl || buildBaseUrl(ctx.req.url);\n\n\t\t\tif (typeof cfg.shopRepository === \"function\") {\n\t\t\t\tcfg.shopRepository = cfg.shopRepository(ctx);\n\t\t\t}\n\n\t\t\tif (typeof cfg.appName === \"function\") {\n\t\t\t\tcfg.appName = cfg.appName(ctx);\n\t\t\t}\n\n\t\t\tif (typeof cfg.appSecret === \"function\") {\n\t\t\t\tcfg.appSecret = cfg.appSecret(ctx);\n\t\t\t}\n\n\t\t\tapp = new AppServer(\n\t\t\t\t{\n\t\t\t\t\tappName: cfg.appName,\n\t\t\t\t\tappSecret: cfg.appSecret,\n\t\t\t\t\tauthorizeCallbackUrl: appUrl + cfg.registerConfirmationUrl,\n\t\t\t\t},\n\t\t\t\tcfg.shopRepository,\n\t\t\t);\n\t\t}\n\n\t\t// @ts-ignore\n\t\tctx.set(\"app\", app);\n\n\t\tawait next();\n\t});\n\n\thono.use(cfg.appPath, async (ctx, next) => {\n\t\t// @ts-ignore\n\t\tconst app = ctx.get(\"app\") as AppServer;\n\n\t\t// Don't validate signature for registration\n\t\tif (\n\t\t\tctx.req.path === cfg.registrationUrl ||\n\t\t\tctx.req.path === cfg.registerConfirmationUrl ||\n\t\t\tctx.req.path === cfg.appActivateUrl ||\n\t\t\tctx.req.path === cfg.appDeactivateUrl ||\n\t\t\tctx.req.path === cfg.appDeleteUrl\n\t\t) {\n\t\t\tawait next();\n\t\t\treturn;\n\t\t}\n\n\t\tlet context: Context<ShopInterface, unknown>;\n\t\ttry {\n\t\t\tcontext =\n\t\t\t\tctx.req.method === \"GET\"\n\t\t\t\t\t? await app.contextResolver.fromBrowser(ctx.req.raw)\n\t\t\t\t\t: await app.contextResolver.fromAPI(ctx.req.raw);\n\t\t} catch (_e) {\n\t\t\treturn jsonResponse({ message: \"Invalid request\" }, 400);\n\t\t}\n\n\t\t// @ts-ignore\n\t\tctx.set(\"shop\", context.shop);\n\t\t// @ts-ignore\n\t\tctx.set(\"context\", context);\n\n\t\tawait next();\n\n\t\tconst cloned = ctx.res.clone();\n\n\t\tawait ctx\n\t\t\t.get(\"app\")\n\t\t\t.signer.signResponse(cloned, ctx.get(\"shop\").getShopSecret());\n\n\t\tctx.header(\n\t\t\t\"shopware-app-signature\",\n\t\t\tcloned.headers.get(\"shopware-app-signature\") as string,\n\t\t);\n\t});\n\n\thono.get(cfg.registrationUrl, async (ctx) => {\n\t\tconst app = ctx.get(\"app\");\n\n\t\treturn await app.registration.authorize(ctx.req.raw);\n\t});\n\n\thono.post(cfg.registerConfirmationUrl, async (ctx) => {\n\t\tconst app = ctx.get(\"app\");\n\n\t\treturn await app.registration.authorizeCallback(ctx.req.raw);\n\t});\n\n\thono.post(cfg.appActivateUrl, async (ctx) => {\n\t\tconst app = ctx.get(\"app\");\n\n\t\treturn await app.registration.activate(ctx.req.raw);\n\t});\n\n\thono.post(cfg.appDeactivateUrl, async (ctx) => {\n\t\tconst app = ctx.get(\"app\");\n\n\t\treturn await app.registration.deactivate(ctx.req.raw);\n\t});\n\n\thono.post(cfg.appDeleteUrl, async (ctx) => {\n\t\tconst app = ctx.get(\"app\");\n\n\t\treturn await app.registration.delete(ctx.req.raw);\n\t});\n}\n\nfunction jsonResponse(body: object, status = 200): Response {\n\treturn new Response(JSON.stringify(body), {\n\t\tstatus,\n\t\theaders: {\n\t\t\t\"Content-Type\": \"application/json\",\n\t\t},\n\t});\n}\n\nfunction buildBaseUrl(url: string): string {\n\tconst u = new URL(url);\n\n\treturn `${u.protocol}//${u.host}`;\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@shopware-ag/app-server-sdk",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.1.1",
|
|
4
4
|
"description": "App Server SDK for JavaScript",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -30,6 +30,66 @@
|
|
|
30
30
|
"default": "./dist/commonjs/helper/app-actions.js"
|
|
31
31
|
}
|
|
32
32
|
},
|
|
33
|
+
"./integration/hono": {
|
|
34
|
+
"import": {
|
|
35
|
+
"types": "./dist/esm/integration/hono.d.ts",
|
|
36
|
+
"default": "./dist/esm/integration/hono.js"
|
|
37
|
+
},
|
|
38
|
+
"require": {
|
|
39
|
+
"types": "./dist/commonjs/integration/hono.d.ts",
|
|
40
|
+
"default": "./dist/commonjs/integration/hono.js"
|
|
41
|
+
}
|
|
42
|
+
},
|
|
43
|
+
"./integration/cloudflare-kv": {
|
|
44
|
+
"import": {
|
|
45
|
+
"types": "./dist/esm/integration/cloudflare-kv.d.ts",
|
|
46
|
+
"default": "./dist/esm/integration/cloudflare-kv.js"
|
|
47
|
+
},
|
|
48
|
+
"require": {
|
|
49
|
+
"types": "./dist/commonjs/integration/cloudflare-kv.d.ts",
|
|
50
|
+
"default": "./dist/commonjs/integration/cloudflare-kv.js"
|
|
51
|
+
}
|
|
52
|
+
},
|
|
53
|
+
"./integration/deno-kv": {
|
|
54
|
+
"import": {
|
|
55
|
+
"types": "./dist/esm/integration/deno-kv.d.ts",
|
|
56
|
+
"default": "./dist/esm/integration/deno-kv.js"
|
|
57
|
+
},
|
|
58
|
+
"require": {
|
|
59
|
+
"types": "./dist/commonjs/integration/deno-kv.d.ts",
|
|
60
|
+
"default": "./dist/commonjs/integration/deno-kv.js"
|
|
61
|
+
}
|
|
62
|
+
},
|
|
63
|
+
"./integration/dynamodb": {
|
|
64
|
+
"import": {
|
|
65
|
+
"types": "./dist/esm/integration/dynamodb.d.ts",
|
|
66
|
+
"default": "./dist/esm/integration/dynamodb.js"
|
|
67
|
+
},
|
|
68
|
+
"require": {
|
|
69
|
+
"types": "./dist/commonjs/integration/dynamodb.d.ts",
|
|
70
|
+
"default": "./dist/commonjs/integration/dynamodb.js"
|
|
71
|
+
}
|
|
72
|
+
},
|
|
73
|
+
"./integration/bun-sqlite": {
|
|
74
|
+
"import": {
|
|
75
|
+
"types": "./dist/esm/integration/bun-sqlite.d.ts",
|
|
76
|
+
"default": "./dist/esm/integration/bun-sqlite.js"
|
|
77
|
+
},
|
|
78
|
+
"require": {
|
|
79
|
+
"types": "./dist/commonjs/integration/bun-sqlite.d.ts",
|
|
80
|
+
"default": "./dist/commonjs/integration/bun-sqlite.js"
|
|
81
|
+
}
|
|
82
|
+
},
|
|
83
|
+
"./integration/better-sqlite3": {
|
|
84
|
+
"import": {
|
|
85
|
+
"types": "./dist/esm/integration/better-sqlite3.d.ts",
|
|
86
|
+
"default": "./dist/esm/integration/better-sqlite3.js"
|
|
87
|
+
},
|
|
88
|
+
"require": {
|
|
89
|
+
"types": "./dist/commonjs/integration/better-sqlite3.d.ts",
|
|
90
|
+
"default": "./dist/commonjs/integration/better-sqlite3.js"
|
|
91
|
+
}
|
|
92
|
+
},
|
|
33
93
|
"./types": {
|
|
34
94
|
"import": {
|
|
35
95
|
"types": "./dist/esm/types.d.ts",
|
|
@@ -47,18 +107,69 @@
|
|
|
47
107
|
"files": [
|
|
48
108
|
"dist"
|
|
49
109
|
],
|
|
110
|
+
"publishConfig": {
|
|
111
|
+
"access": "public",
|
|
112
|
+
"provenance": true
|
|
113
|
+
},
|
|
114
|
+
"repository": {
|
|
115
|
+
"url": "https://github.com/shopware/app-sdk-js"
|
|
116
|
+
},
|
|
117
|
+
"peerDependencies": {
|
|
118
|
+
"@aws-sdk/client-dynamodb": "~3.637",
|
|
119
|
+
"@aws-sdk/lib-dynamodb": "~3.637",
|
|
120
|
+
"better-sqlite3": "^11",
|
|
121
|
+
"hono": "^4"
|
|
122
|
+
},
|
|
123
|
+
"peerDependenciesMeta": {
|
|
124
|
+
"hono": {
|
|
125
|
+
"optional": true
|
|
126
|
+
},
|
|
127
|
+
"@aws-sdk/client-dynamodb": {
|
|
128
|
+
"optional": true
|
|
129
|
+
},
|
|
130
|
+
"@aws-sdk/lib-dynamodb": {
|
|
131
|
+
"optional": true
|
|
132
|
+
},
|
|
133
|
+
"better-sqlite3": {
|
|
134
|
+
"optional": true
|
|
135
|
+
}
|
|
136
|
+
},
|
|
50
137
|
"devDependencies": {
|
|
138
|
+
"@aws-sdk/client-dynamodb": "~3.637",
|
|
139
|
+
"@aws-sdk/lib-dynamodb": "~3.637",
|
|
51
140
|
"@biomejs/biome": "1.8.3",
|
|
141
|
+
"@cloudflare/workers-types": "^4.20240821.1",
|
|
142
|
+
"@types/better-sqlite3": "^7.6.11",
|
|
52
143
|
"@types/bun": "^1.1.6",
|
|
53
|
-
"
|
|
54
|
-
"hono": "^4.5.6"
|
|
144
|
+
"better-sqlite3": "^11",
|
|
145
|
+
"hono": "^4.5.6",
|
|
146
|
+
"tshy": "^3.0.2"
|
|
55
147
|
},
|
|
56
148
|
"tshy": {
|
|
57
149
|
"exports": {
|
|
58
150
|
"./package.json": "./package.json",
|
|
59
151
|
".": "./src/mod.ts",
|
|
60
152
|
"./helper/app-actions": "./src/helper/app-actions.ts",
|
|
153
|
+
"./integration/hono": "./src/integration/hono.ts",
|
|
154
|
+
"./integration/cloudflare-kv": "./src/integration/cloudflare-kv.ts",
|
|
155
|
+
"./integration/deno-kv": "./src/integration/deno-kv.ts",
|
|
156
|
+
"./integration/dynamodb": "./src/integration/dynamodb.ts",
|
|
157
|
+
"./integration/bun-sqlite": "./src/integration/bun-sqlite.ts",
|
|
158
|
+
"./integration/better-sqlite3": "./src/integration/better-sqlite3.ts",
|
|
61
159
|
"./types": "./src/types.ts"
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
|
|
160
|
+
},
|
|
161
|
+
"exclude": [
|
|
162
|
+
"src/**/*.test.ts"
|
|
163
|
+
]
|
|
164
|
+
},
|
|
165
|
+
"scripts": {
|
|
166
|
+
"init": "tshy && biome format . --write",
|
|
167
|
+
"lint": "biome ci .",
|
|
168
|
+
"lint:fix": "biome lint . --write && biome format . --write && biome check . --write",
|
|
169
|
+
"typecheck": "tsc --noEmit"
|
|
170
|
+
},
|
|
171
|
+
"trustedDependencies": [
|
|
172
|
+
"@biomejs/biome",
|
|
173
|
+
"better-sqlite3"
|
|
174
|
+
]
|
|
175
|
+
}
|