@sylphx/sdk 0.3.5 → 0.3.7

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/dist/index.mjs CHANGED
@@ -490,9 +490,9 @@ function parseKey(key) {
490
490
  );
491
491
  }
492
492
  const [, env, ref, token] = parts;
493
- if (env !== "prod" && env !== "dev" && env !== "stg") {
493
+ if (env !== "prod" && env !== "dev" && env !== "stg" && env !== "prev") {
494
494
  throw new SylphxError(
495
- `[Sylphx] Invalid key environment "${env}". Must be 'prod', 'dev', or 'stg'.`,
495
+ `[Sylphx] Invalid key environment "${env}". Must be 'prod', 'dev', 'stg', or 'prev'.`,
496
496
  { code: "BAD_REQUEST" }
497
497
  );
498
498
  }
@@ -1314,11 +1314,14 @@ async function verifyTwoFactor(config, userId, code) {
1314
1314
  async function introspectToken(config, token, tokenTypeHint) {
1315
1315
  const response = await fetch(buildApiUrl(config, "/auth/introspect"), {
1316
1316
  method: "POST",
1317
- headers: { "Content-Type": "application/json" },
1317
+ headers: {
1318
+ "Content-Type": "application/json",
1319
+ // RFC 7662 §2: server-to-server call — authenticate with secret key
1320
+ "x-app-secret": config.secretKey ?? ""
1321
+ },
1318
1322
  body: JSON.stringify({
1319
1323
  token,
1320
- token_type_hint: tokenTypeHint,
1321
- client_secret: config.secretKey
1324
+ token_type_hint: tokenTypeHint
1322
1325
  })
1323
1326
  });
1324
1327
  if (!response.ok) {
@@ -1353,6 +1356,12 @@ async function inviteUser(config, input) {
1353
1356
  body: input
1354
1357
  });
1355
1358
  }
1359
+ async function switchOrg(config, orgId) {
1360
+ return callApi(config, "/auth/switch-org", {
1361
+ method: "POST",
1362
+ body: JSON.stringify({ orgId })
1363
+ });
1364
+ }
1356
1365
 
1357
1366
  // src/admin.ts
1358
1367
  async function listUsers(config, opts) {
@@ -3699,6 +3708,7 @@ export {
3699
3708
  streamToString,
3700
3709
  submitScore,
3701
3710
  suspendUser,
3711
+ switchOrg,
3702
3712
  toSylphxError,
3703
3713
  track,
3704
3714
  trackBatch,