@peektravel/app-utilities 0.7.0 → 0.7.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 +6 -3
- package/dist/index.cjs +10 -4
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +10 -5
- package/dist/index.d.ts +10 -5
- package/dist/index.js +10 -4
- package/dist/index.js.map +1 -1
- package/docs/webhooks.md +9 -5
- package/llms.txt +5 -3
- package/package.json +1 -1
package/docs/webhooks.md
CHANGED
|
@@ -195,10 +195,12 @@ App Store config. There is no GraphQL selection to paste.
|
|
|
195
195
|
|
|
196
196
|
## Step 2 — verify and parse the delivery
|
|
197
197
|
|
|
198
|
-
|
|
199
|
-
header with the
|
|
200
|
-
|
|
201
|
-
`
|
|
198
|
+
Peek delivers the signed token in the **`x-peek-auth` request header**. Pass that
|
|
199
|
+
header value as-is, along with the JSON body and your app's signing secret (the
|
|
200
|
+
same `jwtSecret` you construct `PeekAccessService` with — conventionally
|
|
201
|
+
`PEEK_INTERNAL_SECRET`), to `parseInstallWebhook`. You do **not** need to strip a
|
|
202
|
+
`Bearer ` prefix: `parseInstallWebhook` tolerates the header value with or
|
|
203
|
+
without it.
|
|
202
204
|
|
|
203
205
|
```ts
|
|
204
206
|
import { parseInstallWebhook, type InstallWebhook } from "@peektravel/app-utilities";
|
|
@@ -206,7 +208,9 @@ import { parseInstallWebhook, type InstallWebhook } from "@peektravel/app-utilit
|
|
|
206
208
|
app.post("/webhooks/install", async (req, res) => {
|
|
207
209
|
let event: InstallWebhook;
|
|
208
210
|
try {
|
|
209
|
-
|
|
211
|
+
// `x-peek-auth` carries the token (a `Bearer ` prefix, if any, is stripped for you):
|
|
212
|
+
const token = req.header("x-peek-auth") ?? "";
|
|
213
|
+
event = parseInstallWebhook(token, req.body, process.env.PEEK_INTERNAL_SECRET!);
|
|
210
214
|
} catch {
|
|
211
215
|
return res.sendStatus(401); // signature/issuer/audience/expiry failed
|
|
212
216
|
}
|
package/llms.txt
CHANGED
|
@@ -196,9 +196,11 @@ an external system** (App Store config), not from code.
|
|
|
196
196
|
are **nullable**: a value this version does not recognise maps to `null` (wire
|
|
197
197
|
value kept on `rawStatus`) rather than being coerced, because Peek does not
|
|
198
198
|
redeliver a 2xx and a coerced status silently drops a lifecycle transition. Give
|
|
199
|
-
both a `default:` branch that fails loudly. `
|
|
200
|
-
|
|
201
|
-
|
|
199
|
+
both a `default:` branch that fails loudly. `token` is Peek's `x-peek-auth`
|
|
200
|
+
request header value — pass it as-is, a `Bearer ` prefix is stripped for you.
|
|
201
|
+
`secret` is the app's `jwtSecret`, app-wide, so it verifies fine on a brand-new
|
|
202
|
+
install before any record exists. No query to register; just subscribe to the
|
|
203
|
+
event.
|
|
202
204
|
- **Deprecated / removed:** `verifyInstallWebhook(token, secret):
|
|
203
205
|
InstallWebhookClaims` still verifies the token but is `@deprecated` — it reads
|
|
204
206
|
only the token, missing the account name/platform/test flag. `parseInstallEvent`
|