Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@peektravel/app-cli",
"version": "1.2.1",
"version": "1.2.2",
"description": "CLI for scaffolding, developing, and publishing Peek apps",
"license": "MIT",
"author": "Peek Travel, Inc.",
Expand Down
4 changes: 2 additions & 2 deletions src/skills/platform/acme/backoffice-api/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -156,8 +156,8 @@ Phase 0 ships no database. **When you add persistence:**
`update_installed` upserts the record but **keeps the existing `installDataId`**. On uninstall, flip
the flag off and mark the old data for wipe. Key on `accountId`, since `installId` may change.
- **Build the client from `apiUrl`.** Construct `AcmeAccessService` with the persisted `apiUrl`, or use
**`createAccessServiceForInstall({ platform, apiUrl, installId }, config)`**. The config's
`baseUrl`/`appId`/`mode` are **deprecated** (hardcoded gateway default) and will be removed —
**`createAccessServiceForInstall({ platform, apiUrl, installId }, config)`**. The config's legacy
`baseUrl`/`appId` fields are **deprecated** (hardcoded gateway default) and will be removed —
source the URL from the webhook's `apiUrl`.
- **These identity fields always arrive and are never null — model them as non-nullable columns**
(`installId`, `accountId`, `accountName`, `platform`, `isTest`); `apiUrl`/`timezone` may be `""` on a
Expand Down
12 changes: 6 additions & 6 deletions src/skills/platform/acme/embed-and-auth/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,7 @@ export function createAcmeService(auth: PeekAuthTokenClaims): AcmeAccessService
installId: auth.installId, // ← the entire user-token contribution
jwtSecret: env.PEEK_APP_SECRET, // ← everything else is your app's own secret/config
issuer: env.PEEK_APP_ID,
appId: env.PEEK_APP_ID,
baseUrl: env.PEEK_API_URL,
apiUrl: appApiUrl(env), // the install's endpoint (`<registry-prefix>/<app-slug>`); swap in the webhook's api.url once persisted
});
}
```
Expand Down Expand Up @@ -144,10 +143,11 @@ export function createAcmeServiceForInstall(installId: string, apiUrl: string):
```

Or use the SDK factory: `createAccessServiceForInstall({ platform, apiUrl, installId }, { jwtSecret,
issuer })`. **Use the install's own `apiUrl`, not a hardcoded endpoint** — the config's
`baseUrl`/`appId`/`mode` are **deprecated** and the hardcoded fallback will be removed (see
`acme-backoffice-api`). *(Until this starter has a DB it falls back to the app-level `PEEK_API_URL`;
wire the per-install `apiUrl` in once you persist installs.)*
issuer })`. **Use the install's own `apiUrl`, not a hardcoded endpoint** — the legacy
`baseUrl`/`appId` config fields are **deprecated** and the hardcoded fallback will be removed (see
`acme-backoffice-api`). *(Until this starter has a DB, `appApiUrl(env)` — from `lib/peek-service.ts`
— stands in with the app-level `PEEK_API_URL` prefix plus the app slug; wire the per-install
`apiUrl` in once you persist installs.)*

**Guardrail:** `installId`/`apiUrl` must come from a trusted server-side source (your DB, a verified
webhook — see `acme-webhooks`), **never** from a query param or request body a caller can forge.
Expand Down
4 changes: 2 additions & 2 deletions src/skills/platform/cng/backoffice-api/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -152,8 +152,8 @@ Phase 0 ships no database. **When you add persistence:**
`update_installed` upserts the record but **keeps the existing `installDataId`**. On uninstall, flip
the flag off and mark the old data for wipe. Key on `accountId`, since `installId` may change.
- **Build the client from `apiUrl`.** Construct `CngAccessService` with the persisted `apiUrl`, or use
**`createAccessServiceForInstall({ platform, apiUrl, installId }, config)`**. The config's
`baseUrl`/`appId`/`mode` are **deprecated** (hardcoded gateway default) and will be removed —
**`createAccessServiceForInstall({ platform, apiUrl, installId }, config)`**. The config's legacy
`baseUrl`/`appId` fields are **deprecated** (hardcoded gateway default) and will be removed —
source the URL from the webhook's `apiUrl`.
- **These identity fields always arrive and are never null — model them as non-nullable columns**
(`installId`, `accountId`, `accountName`, `platform`, `isTest`); `apiUrl`/`timezone` may be `""` on a
Expand Down
12 changes: 6 additions & 6 deletions src/skills/platform/cng/embed-and-auth/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,7 @@ export function createCngService(auth: PeekAuthTokenClaims): CngAccessService {
installId: auth.installId, // ← the entire user-token contribution
jwtSecret: env.PEEK_APP_SECRET, // ← everything else is your app's own secret/config
issuer: env.PEEK_APP_ID,
appId: env.PEEK_APP_ID,
baseUrl: env.PEEK_API_URL,
apiUrl: appApiUrl(env), // the install's endpoint (`<registry-prefix>/<app-slug>`); swap in the webhook's api.url once persisted
});
}
```
Expand Down Expand Up @@ -144,10 +143,11 @@ export function createCngServiceForInstall(installId: string, apiUrl: string): C
```

Or use the SDK factory: `createAccessServiceForInstall({ platform, apiUrl, installId }, { jwtSecret,
issuer })`. **Use the install's own `apiUrl`, not a hardcoded endpoint** — the config's
`baseUrl`/`appId`/`mode` are **deprecated** and the hardcoded fallback will be removed (see
`cng-backoffice-api`). *(Until this starter has a DB it falls back to the app-level `PEEK_API_URL`;
wire the per-install `apiUrl` in once you persist installs.)*
issuer })`. **Use the install's own `apiUrl`, not a hardcoded endpoint** — the legacy
`baseUrl`/`appId` config fields are **deprecated** and the hardcoded fallback will be removed (see
`cng-backoffice-api`). *(Until this starter has a DB, `appApiUrl(env)` — from `lib/peek-service.ts`
— stands in with the app-level `PEEK_API_URL` prefix plus the app slug; wire the per-install
`apiUrl` in once you persist installs.)*

**Guardrail:** `installId`/`apiUrl` must come from a trusted server-side source (your DB, a verified
webhook — see `cng-webhooks`), **never** from a query param or request body a caller can forge.
Expand Down
7 changes: 4 additions & 3 deletions src/skills/platform/peek/backoffice-api/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -200,9 +200,10 @@ Phase 0 has no database, so there's nothing to scope yet. **When you add persist
**Build the client from `apiUrl`.** To act on an install, construct its `PeekAccessService` from the
persisted **`apiUrl`** — pass it as the config's `apiUrl` (used *as given*), or hand the whole record
to **`createAccessServiceForInstall({ platform, apiUrl, installId }, { jwtSecret, issuer })`** which
wires it. The config's **`baseUrl`/`appId`/`mode` are deprecated** (they rebuild the URL from a
hardcoded gateway default that can't be right for every install); `apiUrl` takes precedence, and the
**hardcoded fallback will be removed — a URL will become required**, so source it from the webhook now.
wires it. The config's legacy **`baseUrl`/`appId` are deprecated** (they rebuild the URL from a
hardcoded gateway default that can't be right for every install); `apiUrl` takes precedence. **Under
`mode: "v2"` an `apiUrl` is now required — the constructor throws without it**, so source it from the
webhook now.

**These identity fields always arrive on the install delivery and are never null — model them as
non-nullable columns** (`installId`, `accountId`, `accountName`, `platform`, `isTest`). `apiUrl` and
Expand Down
15 changes: 8 additions & 7 deletions src/skills/platform/peek/embed-and-auth/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -132,9 +132,7 @@ export function createPeekService(auth: PeekAuthTokenClaims): PeekAccessService
installId: auth.installId, // ← the entire user-token contribution
jwtSecret: env.PEEK_APP_SECRET, // ← everything else is your app's own secret/config
issuer: env.PEEK_APP_ID,
appId: env.PEEK_APP_ID,
gatewayKey: env.PEEK_APP_ID,
baseUrl: env.PEEK_API_URL,
apiUrl: appApiUrl(env), // `<registry-prefix>/<app-slug>`; v2 REQUIRES it (throws otherwise)
mode: "v2",
});
}
Expand All @@ -161,7 +159,7 @@ export function createPeekServiceForInstall(installId: string, apiUrl: string):
apiUrl, // the install's OWN endpoint (from the webhook, persisted) — used as given
jwtSecret: env.PEEK_APP_SECRET,
issuer: env.PEEK_APP_ID,
gatewayKey: env.PEEK_APP_ID,
mode: "v2", // required; v2 authenticates on the JWT alone (no gatewayKey)
});
}
```
Expand All @@ -180,9 +178,12 @@ const activities = await peek.getProductService().getAllActivities();
**Endpoint = the install's `apiUrl`, not a hardcoded URL.** Each install has its own back-office
endpoint; source it from the persisted install (the webhook's `apiUrl`), for **both** this
server-to-host path **and** the embed pipeline's `createPeekService(auth)` — look the install's
`apiUrl` up by `auth.installId`. The config's `baseUrl`/`appId`/`mode` are **deprecated** (a hardcoded
gateway default) and will be removed. *(Until this starter has a DB it falls back to the app-level
`PEEK_API_URL`; wire the per-install `apiUrl` in once you persist installs.)*
`apiUrl` up by `auth.installId`. For `mode: "v2"` the config's **`apiUrl` is required — the
constructor throws without it** (no `gatewayKey` is needed; the legacy `baseUrl`/`appId` fields are
deprecated and ignored under v2). *(Until this starter has a DB, `appApiUrl(env)` — defined in
`lib/peek-service.ts` — stands in with the app-level `PEEK_API_URL` prefix plus the app slug
(`<registry-prefix>/<app-slug>`), the shape the webhook's `api.url` also takes; wire the per-install
`apiUrl` in once you persist installs.)*

**Guardrails.** This bypasses user-identity checks by design, so `installId`/`apiUrl` must come from a
trusted server-side source (your DB, a verified webhook), **never** from a query param or request
Expand Down
4 changes: 2 additions & 2 deletions src/skills/platform/peek/manifest-and-deploy/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -138,8 +138,8 @@ that test app's env.**

> **`PEEK_APP_ID` is in the back-office gateway *path*, but nothing verifies it — so a wrong id
> passes every auth check and only fails at the back-office.** `PeekAccessService` builds the
> gateway URL as `{PEEK_API_URL}/{PEEK_APP_ID}/peek_backoffice_api-v1/sales` (the id is the
> `gatewayKey`; see `peek-embed-and-auth`). But `verifyPeekAuthToken` **and** the webhook validate
> gateway URL as `{PEEK_API_URL}/{PEEK_APP_ID}/peek_backoffice_api-v1/sales` (the id is the app slug
> in the `apiUrl` path; see `peek-embed-and-auth`). But `verifyPeekAuthToken` **and** the webhook validate
> only the **secret** (`PEEK_APP_SECRET`) — never the id. So a wrong `PEEK_APP_ID` **passes the
> token check *and* the webhook check**, then **404s the back-office** because the gateway path
> points at a nonexistent app. Symptom: auth looks fine, back-office calls 404. If a wrong secret
Expand Down
9 changes: 5 additions & 4 deletions src/skills/stack/javascript/app-utilities/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -187,11 +187,12 @@ await installs.upsert(event.installId, { // full-snapshot
const svc = createAccessServiceForInstall(await installs.get(id), { jwtSecret, issuer });
```

> **Source the endpoint from `apiUrl`, not `baseUrl`/`appId`.** The access-service config's
> `baseUrl`/`appId`/`mode` are **deprecated** — they reconstruct the URL from a **hardcoded gateway
> **Source the endpoint from `apiUrl`, not `baseUrl`/`appId`.** The access-service config's legacy
> `baseUrl`/`appId` fields are **deprecated** — they reconstruct the URL from a **hardcoded gateway
> default** that can't be right for every install. `apiUrl` (the install webhook's `api.url`) takes
> precedence and is used *as given*. **The hardcoded fallbacks will be removed and a URL will become
> required**, so persist and pass `apiUrl` now.
> precedence and is used *as given*. **For Peek `mode: "v2"` an `apiUrl` is now required — the
> constructor throws without it** (no `gatewayKey` needed under v2); the hardcoded `baseUrl` fallback
> will be removed for the other platforms too, so persist and pass `apiUrl` now.

Beyond `accountId`/`installId`, still **mint your own `installDataId`** (an install-time marker) to
scope an install's working data so a fresh reinstall wipes cleanly — but **mint a new one only on a
Expand Down
8 changes: 4 additions & 4 deletions templates/nextjs-starter-kit/lib/acme-service.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
import { AcmeAccessService, type PeekAuthTokenClaims } from "@peektravel/app-utilities";
import { parseEnv } from "@/lib/env";
import { appApiUrl } from "@/lib/peek-service";

/**
* Build an AcmeAccessService scoped to the install the request authenticated as.
*
* The ACME sibling of {@link import("@/lib/cng-service").createCngService}. It
* talks to the ACME backoffice REST gateway instead of Connect&GO's, but
* authenticates on the same app JWT (installId + app secret) and routes through
* the same app-registry base URL, so the config is identical to the CNG one —
* no `gatewayKey`/`mode`, ACME adds no fields of its own.
* the same install `apiUrl`, so the config is identical to the CNG one — no
* `gatewayKey`/`mode`, ACME adds no fields of its own.
*/
export function createAcmeService(auth: PeekAuthTokenClaims): AcmeAccessService {
const env = parseEnv();
Expand All @@ -17,7 +18,6 @@ export function createAcmeService(auth: PeekAuthTokenClaims): AcmeAccessService
installId: auth.installId,
jwtSecret: env.PEEK_APP_SECRET,
issuer: env.PEEK_APP_ID,
appId: env.PEEK_APP_ID,
baseUrl: env.PEEK_API_URL,
apiUrl: appApiUrl(env),
});
}
8 changes: 4 additions & 4 deletions templates/nextjs-starter-kit/lib/cng-service.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
import { CngAccessService, type PeekAuthTokenClaims } from "@peektravel/app-utilities";
import { parseEnv } from "@/lib/env";
import { appApiUrl } from "@/lib/peek-service";

/**
* Build a CngAccessService scoped to the install the request authenticated as.
*
* The CNG sibling of {@link import("@/lib/peek-service").createPeekService}. It
* talks to the Connect&GO backoffice REST gateway instead of Peek's GraphQL one,
* but authenticates on the same app JWT (installId + app secret) and routes
* through the same app-registry base URL, so the config is a subset of the Peek
* one — no `gatewayKey`/`mode`, CNG adds no fields of its own.
* through the same install `apiUrl`, so the config is a subset of the Peek one —
* no `gatewayKey`/`mode`, CNG adds no fields of its own.
*/
export function createCngService(auth: PeekAuthTokenClaims): CngAccessService {
const env = parseEnv();
Expand All @@ -17,7 +18,6 @@ export function createCngService(auth: PeekAuthTokenClaims): CngAccessService {
installId: auth.installId,
jwtSecret: env.PEEK_APP_SECRET,
issuer: env.PEEK_APP_ID,
appId: env.PEEK_APP_ID,
baseUrl: env.PEEK_API_URL,
apiUrl: appApiUrl(env),
});
}
19 changes: 14 additions & 5 deletions templates/nextjs-starter-kit/lib/peek-service.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
import { PeekAccessService, type PeekAuthTokenClaims } from "@peektravel/app-utilities";
import { parseEnv } from "@/lib/env";
import { parseEnv, type Env } from "@/lib/env";

/**
* The install's back-office API endpoint to call. The access service's `apiUrl`
* is each install's own `api.url` from the install webhook — persist it and pass
* it per install (see app/examples/webhooks/install-status). This starter has no
* DB, so it stands in with the app-level `PEEK_API_URL` prefix plus the app slug
* (`<registry-prefix>/<app-slug>`), the shape the webhook's `api.url` also takes.
*/
export function appApiUrl(env: Env): string {
return `${env.PEEK_API_URL.replace(/\/+$/, "")}/${env.PEEK_APP_ID}`;
}

export function createPeekService(auth: PeekAuthTokenClaims): PeekAccessService {
const env = parseEnv();
Expand All @@ -8,9 +19,7 @@ export function createPeekService(auth: PeekAuthTokenClaims): PeekAccessService
installId: auth.installId,
jwtSecret: env.PEEK_APP_SECRET,
issuer: env.PEEK_APP_ID,
appId: env.PEEK_APP_ID,
gatewayKey: env.PEEK_APP_ID,
baseUrl: env.PEEK_API_URL,
apiUrl: appApiUrl(env),
mode: "v2",
});
}
Expand All @@ -28,7 +37,7 @@ export function verifyPeekAuthToken(token: string): PeekAuthTokenClaims {
installId: env.PEEK_APP_ID,
jwtSecret: env.PEEK_APP_SECRET,
issuer: env.PEEK_APP_ID,
appId: env.PEEK_APP_ID,
apiUrl: appApiUrl(env),
mode: "v2",
});

Expand Down
2 changes: 1 addition & 1 deletion templates/nextjs-starter-kit/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"test:coverage": "vitest run --coverage"
},
"dependencies": {
"@peektravel/app-utilities": "^0.9.0",
"@peektravel/app-utilities": "^1.3.0",
"next": "16.2.9",
"react": "19.2.4",
"react-dom": "19.2.4",
Expand Down
10 changes: 5 additions & 5 deletions templates/nextjs-starter-kit/pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading