@sylphx/sdk 0.19.2 → 0.20.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 +88 -1
- package/dist/index.d.ts +468 -9
- package/dist/index.mjs +394 -4
- package/dist/index.mjs.map +1 -1
- package/dist/nextjs/index.mjs +11 -2
- package/dist/nextjs/index.mjs.map +1 -1
- package/dist/react/index.d.ts +38 -7
- package/dist/react/index.mjs +71 -40
- package/dist/react/index.mjs.map +1 -1
- package/dist/server/index.d.ts +78 -6
- package/dist/server/index.mjs +11 -2
- package/dist/server/index.mjs.map +1 -1
- package/dist/tasks.d.ts +1450 -0
- package/dist/tasks.mjs +1895 -0
- package/dist/tasks.mjs.map +1 -0
- package/dist/web-analytics.mjs.map +1 -1
- package/package.json +7 -2
package/README.md
CHANGED
|
@@ -191,6 +191,51 @@ const plans = await getPlans(sylphx)
|
|
|
191
191
|
await track(sylphx, { event: 'purchase', properties: { amount: 99 } })
|
|
192
192
|
```
|
|
193
193
|
|
|
194
|
+
## CI Runner Profile Helpers
|
|
195
|
+
|
|
196
|
+
`@sylphx/sdk` also exports browser-safe CI runner profile helpers for tools
|
|
197
|
+
that generate GitHub Actions workflows:
|
|
198
|
+
|
|
199
|
+
```ts
|
|
200
|
+
import { formatCiRunnerWorkflowRunsOn, getCiRunnerProfileById } from '@sylphx/sdk'
|
|
201
|
+
|
|
202
|
+
const profile = getCiRunnerProfileById('macos-standard')
|
|
203
|
+
const runsOn = formatCiRunnerWorkflowRunsOn(profile)
|
|
204
|
+
// [self-hosted, sylphx, macos, standard]
|
|
205
|
+
```
|
|
206
|
+
|
|
207
|
+
These helpers expose the public workflow label contract only. Applications do
|
|
208
|
+
not need to know the backing scheduler, cluster, runner group, capacity formula,
|
|
209
|
+
or placement details.
|
|
210
|
+
|
|
211
|
+
## Sandbox Capability Catalog
|
|
212
|
+
|
|
213
|
+
Sandbox clients expose the authenticated capability report served by the
|
|
214
|
+
exec-server:
|
|
215
|
+
|
|
216
|
+
```ts
|
|
217
|
+
import { SandboxClient } from '@sylphx/sdk'
|
|
218
|
+
|
|
219
|
+
const sandbox = await SandboxClient.create(sylphx)
|
|
220
|
+
const report = await sandbox.capabilities.get()
|
|
221
|
+
|
|
222
|
+
const storage = report.capabilities.find((capability) => capability.id === 'workspace-storage')
|
|
223
|
+
if (storage?.workspaceStorage?.pressure === 'critical') {
|
|
224
|
+
// Clean caches/artifacts, fork from a clean workspace, or offload heavy work.
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
const mobile = report.capabilities.find((capability) => capability.id === 'mobile-device-test')
|
|
228
|
+
if (mobile?.status === 'not-local') {
|
|
229
|
+
// Build artifacts in the workspace or CI, then run device tests through the
|
|
230
|
+
// managed mobile device runtime when available.
|
|
231
|
+
}
|
|
232
|
+
```
|
|
233
|
+
|
|
234
|
+
The report is tenant-neutral and product-level. It tells agents what is local to
|
|
235
|
+
the sandbox (`exec`, files, browser, desktop) versus another Platform execution
|
|
236
|
+
plane (`ci-runner`, `managed-device-runtime`) without exposing Kubernetes
|
|
237
|
+
placement or storage internals.
|
|
238
|
+
|
|
194
239
|
### Prefetch App Config
|
|
195
240
|
|
|
196
241
|
```ts
|
|
@@ -253,14 +298,56 @@ export const POST = createWebhookHandler({
|
|
|
253
298
|
### JWT Verification
|
|
254
299
|
|
|
255
300
|
```ts
|
|
301
|
+
import { createServerClient } from '@sylphx/sdk'
|
|
256
302
|
import { verifyAccessToken } from '@sylphx/sdk/server'
|
|
257
303
|
|
|
304
|
+
const sylphx = createServerClient(process.env.SYLPHX_SECRET_URL!)
|
|
305
|
+
|
|
258
306
|
const payload = await verifyAccessToken(token, {
|
|
259
|
-
|
|
307
|
+
platformUrl: sylphx.baseUrl.replace(/\/v[0-9]+$/, ''),
|
|
308
|
+
audience: process.env.NEXT_PUBLIC_SYLPHX_APP_ID!,
|
|
260
309
|
})
|
|
261
310
|
// payload.sub, payload.email, payload.role, payload.app_id
|
|
311
|
+
// Org-scoped tokens also preserve payload.org_id, payload.org_slug, payload.org_role
|
|
312
|
+
// DPoP-bound tokens preserve payload.cnf?.jkt for proof validation.
|
|
313
|
+
```
|
|
314
|
+
|
|
315
|
+
Always pass `audience` on a resource server. The server verifier rejects a
|
|
316
|
+
validly-signed token when its `aud` claim is for another app or API. Omitting
|
|
317
|
+
`audience` is kept only for backward compatibility and skips audience
|
|
318
|
+
validation. If you authorize organization resources, compare `payload.org_id`
|
|
319
|
+
with the addressed resource's org and check `payload.org_role` before granting
|
|
320
|
+
access.
|
|
321
|
+
|
|
322
|
+
---
|
|
323
|
+
|
|
324
|
+
### Service Accounts (machine-to-machine)
|
|
325
|
+
|
|
326
|
+
Authenticate **as a service account** with the OAuth 2.0 client-credentials
|
|
327
|
+
grant (RFC 6749 §4.4, ADR-2062). Returns a short-lived org-scoped access token
|
|
328
|
+
carrying `org_id` / `org_slug` / `org_role` claims — verify it on the resource
|
|
329
|
+
server with `verifyAccessToken` (above).
|
|
330
|
+
|
|
331
|
+
```ts
|
|
332
|
+
import { createServerClient, signInAsService, withToken } from '@sylphx/sdk'
|
|
333
|
+
|
|
334
|
+
const sylphx = createServerClient(process.env.SYLPHX_SECRET_URL!)
|
|
335
|
+
|
|
336
|
+
const { token, expiresIn } = await signInAsService(sylphx, {
|
|
337
|
+
clientId: process.env.SYLPHX_SERVICE_CLIENT_ID!, // `sa_…`, stable across rotations
|
|
338
|
+
clientSecret: process.env.SYLPHX_SERVICE_CLIENT_SECRET!,
|
|
339
|
+
// scope: 'read:foo write:bar', // optional scope downgrade
|
|
340
|
+
})
|
|
341
|
+
|
|
342
|
+
const authed = withToken(sylphx, token)
|
|
262
343
|
```
|
|
263
344
|
|
|
345
|
+
No refresh token is issued — re-mint before `expiresIn` (seconds) elapses.
|
|
346
|
+
Secrets support rotation with a grace window, so a rotated secret keeps
|
|
347
|
+
authenticating running consumers until its deadline. `org_role` is one of
|
|
348
|
+
`admin` / `developer` / `viewer` (never `owner` / `super_admin` — those stay
|
|
349
|
+
human-only).
|
|
350
|
+
|
|
264
351
|
---
|
|
265
352
|
|
|
266
353
|
## React Hooks
|