@steve31415/request-button 1.0.2 → 1.0.3
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 +15 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/session.d.ts +31 -0
- package/dist/session.d.ts.map +1 -0
- package/dist/session.js +32 -0
- package/dist/session.js.map +1 -0
- package/package.json +1 -1
package/README.md
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
# @steve31415/request-button
|
|
2
|
+
|
|
3
|
+
Shared Request button for Plasticine Way apps — submit feature requests and bug reports to the Todo app.
|
|
4
|
+
|
|
5
|
+
## Publishing
|
|
6
|
+
|
|
7
|
+
Published via npm Trusted Publishing. Push a `v*` tag to trigger the GitHub Actions workflow, which builds, tests, and publishes automatically.
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
# 1. Bump version in package.json
|
|
11
|
+
# 2. Commit the version bump
|
|
12
|
+
# 3. Tag and push:
|
|
13
|
+
git tag v<version>
|
|
14
|
+
git push && git push origin v<version>
|
|
15
|
+
```
|
package/dist/index.d.ts
CHANGED
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAC;AAC7C,YAAY,EAAE,mBAAmB,EAAE,MAAM,SAAS,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAC;AAC7C,YAAY,EAAE,mBAAmB,EAAE,MAAM,SAAS,CAAC;AACnD,OAAO,EAAE,kBAAkB,EAAE,MAAM,WAAW,CAAC"}
|
package/dist/index.js
CHANGED
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAC;AAE7C,OAAO,EAAE,kBAAkB,EAAE,MAAM,WAAW,CAAC"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { Context } from "hono";
|
|
2
|
+
/**
|
|
3
|
+
* D1-compatible database interface — matches what consuming apps expose via
|
|
4
|
+
* `c.env.DB`.
|
|
5
|
+
*/
|
|
6
|
+
interface D1Database {
|
|
7
|
+
prepare(query: string): {
|
|
8
|
+
bind(...values: unknown[]): {
|
|
9
|
+
first(): Promise<unknown>;
|
|
10
|
+
run(): Promise<unknown>;
|
|
11
|
+
};
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Store the authenticated session cookie in D1 for reuse with other services.
|
|
16
|
+
*
|
|
17
|
+
* Uses read-before-write to skip the write when the cookie is already stored,
|
|
18
|
+
* which is the common case. Call this at most once per page handler, right
|
|
19
|
+
* after successful authentication.
|
|
20
|
+
*
|
|
21
|
+
* Requires a `session_cookies` table:
|
|
22
|
+
* ```sql
|
|
23
|
+
* CREATE TABLE session_cookies (
|
|
24
|
+
* value TEXT PRIMARY KEY,
|
|
25
|
+
* created_at TEXT NOT NULL DEFAULT (datetime('now'))
|
|
26
|
+
* );
|
|
27
|
+
* ```
|
|
28
|
+
*/
|
|
29
|
+
export declare function storeSessionCookie(c: Context, db: D1Database): Promise<void>;
|
|
30
|
+
export {};
|
|
31
|
+
//# sourceMappingURL=session.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"session.d.ts","sourceRoot":"","sources":["../src/session.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AAGpC;;;GAGG;AACH,UAAU,UAAU;IAClB,OAAO,CAAC,KAAK,EAAE,MAAM,GAAG;QACtB,IAAI,CAAC,GAAG,MAAM,EAAE,OAAO,EAAE,GAAG;YAC1B,KAAK,IAAI,OAAO,CAAC,OAAO,CAAC,CAAC;YAC1B,GAAG,IAAI,OAAO,CAAC,OAAO,CAAC,CAAC;SACzB,CAAC;KACH,CAAC;CACH;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAsB,kBAAkB,CAAC,CAAC,EAAE,OAAO,EAAE,EAAE,EAAE,UAAU,GAAG,OAAO,CAAC,IAAI,CAAC,CAclF"}
|
package/dist/session.js
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { getCookie } from "hono/cookie";
|
|
2
|
+
/**
|
|
3
|
+
* Store the authenticated session cookie in D1 for reuse with other services.
|
|
4
|
+
*
|
|
5
|
+
* Uses read-before-write to skip the write when the cookie is already stored,
|
|
6
|
+
* which is the common case. Call this at most once per page handler, right
|
|
7
|
+
* after successful authentication.
|
|
8
|
+
*
|
|
9
|
+
* Requires a `session_cookies` table:
|
|
10
|
+
* ```sql
|
|
11
|
+
* CREATE TABLE session_cookies (
|
|
12
|
+
* value TEXT PRIMARY KEY,
|
|
13
|
+
* created_at TEXT NOT NULL DEFAULT (datetime('now'))
|
|
14
|
+
* );
|
|
15
|
+
* ```
|
|
16
|
+
*/
|
|
17
|
+
export async function storeSessionCookie(c, db) {
|
|
18
|
+
const sessionCookie = getCookie(c, "session");
|
|
19
|
+
if (!sessionCookie)
|
|
20
|
+
return;
|
|
21
|
+
const existing = await db
|
|
22
|
+
.prepare("SELECT 1 FROM session_cookies WHERE value = ?")
|
|
23
|
+
.bind(sessionCookie)
|
|
24
|
+
.first();
|
|
25
|
+
if (!existing) {
|
|
26
|
+
await db
|
|
27
|
+
.prepare("INSERT INTO session_cookies (value) VALUES (?)")
|
|
28
|
+
.bind(sessionCookie)
|
|
29
|
+
.run();
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
//# sourceMappingURL=session.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"session.js","sourceRoot":"","sources":["../src/session.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAexC;;;;;;;;;;;;;;GAcG;AACH,MAAM,CAAC,KAAK,UAAU,kBAAkB,CAAC,CAAU,EAAE,EAAc;IACjE,MAAM,aAAa,GAAG,SAAS,CAAC,CAAC,EAAE,SAAS,CAAC,CAAC;IAC9C,IAAI,CAAC,aAAa;QAAE,OAAO;IAE3B,MAAM,QAAQ,GAAG,MAAM,EAAE;SACtB,OAAO,CAAC,+CAA+C,CAAC;SACxD,IAAI,CAAC,aAAa,CAAC;SACnB,KAAK,EAAE,CAAC;IACX,IAAI,CAAC,QAAQ,EAAE,CAAC;QACd,MAAM,EAAE;aACL,OAAO,CAAC,gDAAgD,CAAC;aACzD,IAAI,CAAC,aAAa,CAAC;aACnB,GAAG,EAAE,CAAC;IACX,CAAC;AACH,CAAC"}
|
package/package.json
CHANGED