@foir/sdk 0.22.0 → 0.24.0

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/auth.js CHANGED
@@ -5,10 +5,7 @@ import { print as print2 } from "graphql";
5
5
  var KEY_PREFIXES = [
6
6
  ["foir_pub_", "publishable"],
7
7
  ["foir_srv_", "server"],
8
- ["foir_adm_", "admin"],
9
- ["pk_", "publishable"],
10
- ["sk_", "older"],
11
- ["tc_", "older"]
8
+ ["foir_adm_", "admin"]
12
9
  ];
13
10
  var FOIR_CREDENTIALS_DOC = "https://docs.foir.dev/credentials";
14
11
  function foirKeyKind(apiKey) {
@@ -1096,7 +1093,6 @@ var AUTH_OPS = {
1096
1093
  requestPasswordReset: "requestPasswordReset",
1097
1094
  resetPassword: "resetPassword",
1098
1095
  updatePassword: "updatePassword",
1099
- verifyEmail: "verifyEmail",
1100
1096
  deleteMyAccount: "deleteMyAccount",
1101
1097
  // The user's own profile, and the apps they have agreed may act for them.
1102
1098
  updateMyProfile: "updateMyProfile",
@@ -1232,6 +1228,16 @@ function providerSignInRefusalOf(error) {
1232
1228
  }
1233
1229
  return null;
1234
1230
  }
1231
+ function signInRefusalOf(error) {
1232
+ if (!(error instanceof FoirRequestError)) return null;
1233
+ for (const entry of error.graphQLErrors ?? []) {
1234
+ const value = entry.extensions?.signIn;
1235
+ if (!value || typeof value !== "object" || Array.isArray(value)) continue;
1236
+ const { code } = value;
1237
+ if (typeof code === "string") return { code };
1238
+ }
1239
+ return null;
1240
+ }
1235
1241
  async function confirmProviderLink(env, input) {
1236
1242
  return authOp(env, AUTH_OPS.confirmProviderLink, { input });
1237
1243
  }
@@ -1253,15 +1259,12 @@ async function signupContext(env) {
1253
1259
  async function joinWaitlist(env, email) {
1254
1260
  return authOp(env, AUTH_OPS.joinWaitlist, { email });
1255
1261
  }
1256
- async function requestPasswordReset(env, email) {
1257
- return authOp(env, AUTH_OPS.requestPasswordReset, { email });
1262
+ async function requestPasswordReset(env, email, options) {
1263
+ return authOp(env, AUTH_OPS.requestPasswordReset, { email, clientId: options?.clientId });
1258
1264
  }
1259
1265
  async function resetPassword(env, vars) {
1260
1266
  return authOp(env, AUTH_OPS.resetPassword, vars);
1261
1267
  }
1262
- async function verifyEmail(env, token) {
1263
- return authOp(env, AUTH_OPS.verifyEmail, { token });
1264
- }
1265
1268
  async function updatePassword(env, vars, options) {
1266
1269
  return authOp(env, AUTH_OPS.updatePassword, vars, options);
1267
1270
  }
@@ -1269,7 +1272,9 @@ async function currentUser(env, options) {
1269
1272
  return authOp(env, AUTH_OPS.currentUser, void 0, options);
1270
1273
  }
1271
1274
  async function myProviderToken(env, providerKey, options) {
1272
- return authOp(env, AUTH_OPS.myProviderToken, { providerKey }, options);
1275
+ const { forceRefresh, ...rest } = options ?? {};
1276
+ const vars = forceRefresh ? { providerKey, forceRefresh: true } : { providerKey };
1277
+ return authOp(env, AUTH_OPS.myProviderToken, vars, rest);
1273
1278
  }
1274
1279
  async function logout(env, options) {
1275
1280
  return authOp(env, AUTH_OPS.logout, void 0, options);
@@ -1486,125 +1491,125 @@ async function recoverSessionUser(adapter, env, token) {
1486
1491
 
1487
1492
  // src/auth/grant-table.generated.ts
1488
1493
  var GRANT_TABLE = [
1489
- ["records:read", true, ["own", "all"], []],
1490
- ["records:create", true, [], []],
1491
- ["records:write", true, ["own", "all"], []],
1492
- ["records:delete", true, ["own", "all"], []],
1493
- ["records:publish", true, ["own", "all"], []],
1494
- ["records:attribute", true, [], []],
1495
- ["search:read", true, [], []],
1496
- ["embeddings:read", false, [], []],
1497
- ["embeddings:write", false, [], []],
1498
- ["schemas:read", false, [], []],
1499
- ["drafts:read", false, [], []],
1500
- ["files:read", false, ["own", "all"], []],
1501
- ["files:write", false, ["own", "all"], []],
1502
- ["files:delete", false, ["own", "all"], []],
1503
- ["notifications:read", false, ["own", "all"], []],
1504
- ["notifications:write", false, ["own", "named", "all"], []],
1505
- ["notifications:consent", false, [], []],
1506
- ["pushcredentials:read", false, [], []],
1507
- ["pushcredentials:write", false, [], []],
1508
- ["notes:read", false, ["own", "all"], []],
1509
- ["notes:write", false, ["own", "all"], []],
1510
- ["notes:create", false, [], []],
1511
- ["approvals:read", false, [], []],
1512
- ["approvals:write", false, [], []],
1513
- ["rooms:read", true, [], []],
1514
- ["rooms:write", true, [], []],
1515
- ["presence:read", true, [], []],
1516
- ["operations:read", false, [], []],
1517
- ["operations:execute", true, [], []],
1518
- ["operations:write", false, [], []],
1519
- ["operations:complete", false, [], []],
1520
- ["status:write", false, [], []],
1521
- ["appconfig:read", false, [], []],
1522
- ["schedules:read", false, [], []],
1523
- ["schedules:write", false, [], []],
1524
- ["hooks:read", false, [], []],
1525
- ["hooks:write", false, [], []],
1526
- ["relyingparties:read", false, [], []],
1527
- ["relyingparties:write", false, [], []],
1528
- ["domains:read", false, [], []],
1529
- ["domains:write", false, [], []],
1530
- ["secrets:read", false, [], []],
1531
- ["secrets:list", false, [], []],
1532
- ["secrets:put", false, [], []],
1533
- ["secrets:delete", false, [], []],
1534
- ["appsecrets:read", false, [], []],
1535
- ["appsecrets:list", false, [], []],
1536
- ["appsecrets:put", false, [], []],
1537
- ["appsecrets:delete", false, [], []],
1538
- ["opsecrets:read", false, [], []],
1539
- ["opsecrets:write", false, [], []],
1540
- ["settings:read", false, [], []],
1541
- ["settings:write", false, [], []],
1542
- ["designtokens:read", false, [], []],
1543
- ["designtokens:write", false, [], []],
1544
- ["models:read", false, [], []],
1545
- ["models:write", false, [], []],
1546
- ["configs:read", false, [], []],
1547
- ["configs:write", false, [], []],
1548
- ["apps:read", false, [], []],
1549
- ["apps:write", false, [], []],
1550
- ["events:read", false, [], []],
1551
- ["targeting:debug", false, [], []],
1552
- ["visitors:forward", false, [], []],
1553
- ["apikeys:read", false, [], []],
1554
- ["apikeys:write", false, [], []],
1555
- ["organizations:read", false, [], []],
1556
- ["organizations:write", false, [], []],
1557
- ["organizations:create", false, [], []],
1558
- ["organizations:delete", false, [], []],
1559
- ["organizations:reach", false, [], []],
1560
- ["members:read", false, [], []],
1561
- ["members:write", false, [], []],
1562
- ["roles:read", false, [], []],
1563
- ["roles:write", false, [], []],
1564
- ["projects:read", false, [], []],
1565
- ["projects:write", false, [], []],
1566
- ["project:stand", false, [], []],
1567
- ["project:manage", false, [], ["project:stand", "records:read.all", "records:create", "records:write.all", "records:delete.all", "records:publish.all", "records:attribute", "search:read", "embeddings:read", "embeddings:write", "schemas:read", "drafts:read", "files:read.all", "files:write.all", "files:delete.all", "users:read.all", "identities:read", "users:create", "identities:delete", "users:write.all", "users:setup", "users:delete.all", "notifications:read.all", "notifications:write.all", "notifications:consent", "pushcredentials:read", "pushcredentials:write", "notes:read.all", "notes:write.all", "notes:create", "approvals:read", "approvals:write", "rooms:read", "rooms:write", "presence:read", "operations:read", "operations:execute", "operations:write", "appconfig:read", "schedules:read", "schedules:write", "hooks:read", "hooks:write", "auth:login_with_foir", "relyingparties:read", "relyingparties:write", "domains:read", "domains:write", "secrets:read", "secrets:list", "secrets:put", "secrets:delete", "appsecrets:read", "appsecrets:list", "appsecrets:put", "appsecrets:delete", "usersecrets:read", "usersecrets:list", "usersecrets:put", "usersecrets:delete", "opsecrets:read", "opsecrets:write", "settings:read", "settings:write", "designtokens:read", "designtokens:write", "models:read", "models:write", "configs:read", "configs:write", "signinproviders:read", "signinproviders:write", "apps:read", "apps:write", "events:read", "targeting:debug", "visitors:forward", "apikeys:read", "apikeys:write", "organizations:read", "organizations:create", "organizations:delete", "organizations:write", "organizations:reach", "members:read", "members:write", "roles:read", "roles:write", "projects:read", "projects:write", "audit:read"]],
1568
- ["projects:create", false, [], []],
1569
- ["projects:delete", false, [], []],
1570
- ["tenants:read", false, [], []],
1571
- ["tenants:write", false, [], []],
1572
- ["tenants:delete", false, [], []],
1573
- ["audit:read", false, [], []],
1574
- ["export:run", false, [], []],
1575
- ["billing:read", false, [], []],
1576
- ["billing:manage", false, [], []],
1577
- ["usage:read", false, [], []],
1578
- ["controlkeys:read", false, [], []],
1579
- ["controlkeys:write", false, [], []],
1580
- ["tenantsigninproviders:read", false, [], []],
1581
- ["tenantsigninproviders:write", false, [], []],
1582
- ["tenanthooks:read", false, [], []],
1583
- ["tenanthooks:write", false, [], []],
1584
- ["apps:install", false, [], []],
1585
- ["tenant:manage", false, [], ["project:manage", "projects:create", "projects:delete", "tenants:read", "tenants:write", "tenants:delete", "export:run", "billing:read", "billing:manage", "usage:read", "controlkeys:read", "controlkeys:write", "tenanthooks:read", "tenanthooks:write", "tenantsigninproviders:read", "tenantsigninproviders:write", "apps:install"]],
1586
- ["platform:read", false, [], []],
1587
- ["platform:manage", false, [], ["tenant:manage", "platform:read", "platform:create_workspace"]],
1588
- ["platform:create_workspace", false, [], []],
1589
- ["users:read", false, ["own", "named", "all"], []],
1590
- ["users:write", false, ["own", "all"], []],
1591
- ["users:setup", false, [], []],
1592
- ["users:delete", false, ["own", "all"], []],
1593
- ["users:create", false, [], []],
1594
- ["identities:read", false, [], []],
1595
- ["identities:delete", false, [], []],
1596
- ["usersecrets:read", false, [], []],
1597
- ["usersecrets:list", false, [], []],
1598
- ["usersecrets:put", false, [], []],
1599
- ["usersecrets:delete", false, [], []],
1600
- ["auth:login_with_foir", false, [], []],
1601
- ["signinproviders:read", false, [], []],
1602
- ["signinproviders:write", false, [], []]
1494
+ ["records:read", "model", ["own", "all"], []],
1495
+ ["records:create", "model", [], []],
1496
+ ["records:write", "model", ["own", "all"], []],
1497
+ ["records:delete", "model", ["own", "all"], []],
1498
+ ["records:publish", "model", ["own", "all"], []],
1499
+ ["records:attribute", "model", [], []],
1500
+ ["search:read", "model", [], []],
1501
+ ["embeddings:read", "none", [], []],
1502
+ ["embeddings:write", "none", [], []],
1503
+ ["schemas:read", "none", [], []],
1504
+ ["drafts:read", "none", [], []],
1505
+ ["files:read", "none", ["own", "all"], []],
1506
+ ["files:write", "none", ["own", "all"], []],
1507
+ ["files:delete", "none", ["own", "all"], []],
1508
+ ["notifications:read", "none", ["own", "all"], []],
1509
+ ["notifications:write", "none", ["own", "named", "all"], []],
1510
+ ["notifications:consent", "none", [], []],
1511
+ ["pushcredentials:read", "none", [], []],
1512
+ ["pushcredentials:write", "none", [], []],
1513
+ ["notes:read", "none", ["own", "all"], []],
1514
+ ["notes:write", "none", ["own", "all"], []],
1515
+ ["notes:create", "none", [], []],
1516
+ ["approvals:read", "none", [], []],
1517
+ ["approvals:write", "none", [], []],
1518
+ ["rooms:read", "model", [], []],
1519
+ ["rooms:write", "model", [], []],
1520
+ ["presence:read", "model", [], []],
1521
+ ["operations:read", "none", [], []],
1522
+ ["operations:execute", "operation", [], []],
1523
+ ["operations:write", "none", [], []],
1524
+ ["operations:complete", "none", [], []],
1525
+ ["status:write", "none", [], []],
1526
+ ["appconfig:read", "none", [], []],
1527
+ ["schedules:read", "none", [], []],
1528
+ ["schedules:write", "none", [], []],
1529
+ ["hooks:read", "none", [], []],
1530
+ ["hooks:write", "none", [], []],
1531
+ ["authclients:read", "none", [], []],
1532
+ ["authclients:write", "none", [], []],
1533
+ ["domains:read", "none", [], []],
1534
+ ["domains:write", "none", [], []],
1535
+ ["secrets:read", "none", [], []],
1536
+ ["secrets:list", "none", [], []],
1537
+ ["secrets:put", "none", [], []],
1538
+ ["secrets:delete", "none", [], []],
1539
+ ["appsecrets:read", "none", [], []],
1540
+ ["appsecrets:list", "none", [], []],
1541
+ ["appsecrets:put", "none", [], []],
1542
+ ["appsecrets:delete", "none", [], []],
1543
+ ["opsecrets:read", "none", [], []],
1544
+ ["opsecrets:write", "none", [], []],
1545
+ ["settings:read", "none", [], []],
1546
+ ["settings:write", "none", [], []],
1547
+ ["designtokens:read", "none", [], []],
1548
+ ["designtokens:write", "none", [], []],
1549
+ ["models:read", "none", [], []],
1550
+ ["models:write", "none", [], []],
1551
+ ["configs:read", "none", [], []],
1552
+ ["configs:write", "none", [], []],
1553
+ ["apps:read", "none", [], []],
1554
+ ["apps:write", "none", [], []],
1555
+ ["events:read", "none", [], []],
1556
+ ["targeting:debug", "none", [], []],
1557
+ ["visitors:forward", "none", [], []],
1558
+ ["apikeys:read", "none", [], []],
1559
+ ["apikeys:write", "none", [], []],
1560
+ ["organizations:read", "none", [], []],
1561
+ ["organizations:write", "none", [], []],
1562
+ ["organizations:create", "none", [], []],
1563
+ ["organizations:delete", "none", [], []],
1564
+ ["organizations:reach", "none", [], []],
1565
+ ["members:read", "none", [], []],
1566
+ ["members:write", "none", [], []],
1567
+ ["roles:read", "none", [], []],
1568
+ ["roles:write", "none", [], []],
1569
+ ["projects:read", "none", [], []],
1570
+ ["projects:write", "none", [], []],
1571
+ ["project:stand", "none", [], []],
1572
+ ["project:manage", "none", [], ["project:stand", "records:read.all", "records:create", "records:write.all", "records:delete.all", "records:publish.all", "records:attribute", "search:read", "embeddings:read", "embeddings:write", "schemas:read", "drafts:read", "files:read.all", "files:write.all", "files:delete.all", "users:read.all", "identities:read", "users:create", "identities:delete", "users:write.all", "users:setup", "users:delete.all", "notifications:read.all", "notifications:write.all", "notifications:consent", "pushcredentials:read", "pushcredentials:write", "notes:read.all", "notes:write.all", "notes:create", "approvals:read", "approvals:write", "rooms:read", "rooms:write", "presence:read", "operations:read", "operations:execute", "operations:write", "appconfig:read", "schedules:read", "schedules:write", "hooks:read", "hooks:write", "auth:login_with_foir", "authclients:read", "authclients:write", "domains:read", "domains:write", "secrets:read", "secrets:list", "secrets:put", "secrets:delete", "appsecrets:read", "appsecrets:list", "appsecrets:put", "appsecrets:delete", "usersecrets:read", "usersecrets:list", "usersecrets:put", "usersecrets:delete", "opsecrets:read", "opsecrets:write", "settings:read", "settings:write", "designtokens:read", "designtokens:write", "models:read", "models:write", "configs:read", "configs:write", "signinproviders:read", "signinproviders:write", "apps:read", "apps:write", "events:read", "targeting:debug", "visitors:forward", "apikeys:read", "apikeys:write", "organizations:read", "organizations:create", "organizations:delete", "organizations:write", "organizations:reach", "members:read", "members:write", "roles:read", "roles:write", "projects:read", "projects:write", "audit:read"]],
1573
+ ["projects:create", "none", [], []],
1574
+ ["projects:delete", "none", [], []],
1575
+ ["tenants:read", "none", [], []],
1576
+ ["tenants:write", "none", [], []],
1577
+ ["tenants:delete", "none", [], []],
1578
+ ["audit:read", "none", [], []],
1579
+ ["export:run", "none", [], []],
1580
+ ["billing:read", "none", [], []],
1581
+ ["billing:manage", "none", [], []],
1582
+ ["usage:read", "none", [], []],
1583
+ ["controlkeys:read", "none", [], []],
1584
+ ["controlkeys:write", "none", [], []],
1585
+ ["tenanthooks:read", "none", [], []],
1586
+ ["tenanthooks:write", "none", [], []],
1587
+ ["apps:install", "none", [], []],
1588
+ ["tenant:manage", "none", [], ["project:manage", "projects:create", "projects:delete", "tenants:read", "tenants:write", "tenants:delete", "export:run", "billing:read", "billing:manage", "usage:read", "controlkeys:read", "controlkeys:write", "tenanthooks:read", "tenanthooks:write", "apps:install"]],
1589
+ ["platform:read", "none", [], []],
1590
+ ["platform:manage", "none", [], ["tenant:manage", "platform:read", "platform:create_workspace"]],
1591
+ ["platform:create_workspace", "none", [], []],
1592
+ ["users:read", "none", ["own", "named", "all"], []],
1593
+ ["users:write", "none", ["own", "all"], []],
1594
+ ["users:setup", "none", [], []],
1595
+ ["users:delete", "none", ["own", "all"], []],
1596
+ ["users:create", "none", [], []],
1597
+ ["identities:read", "none", [], []],
1598
+ ["identities:delete", "none", [], []],
1599
+ ["usersecrets:read", "none", [], []],
1600
+ ["usersecrets:list", "none", [], []],
1601
+ ["usersecrets:put", "none", [], []],
1602
+ ["usersecrets:delete", "none", [], []],
1603
+ ["auth:login_with_foir", "none", [], []],
1604
+ ["signinproviders:read", "none", [], []],
1605
+ ["signinproviders:write", "none", [], []]
1603
1606
  ];
1604
1607
 
1605
1608
  // src/auth/grants.ts
1606
1609
  var WILDCARD = "*";
1607
1610
  var RESOURCE_WILDCARD = ":*";
1611
+ var FIELD_PERMISSIONS = ["records:read", "records:write"];
1612
+ var FIELD_KEY = /^[A-Za-z_][A-Za-z0-9_]*$/;
1608
1613
  var index;
1609
1614
  function catalogue() {
1610
1615
  if (!index) {
@@ -1645,15 +1650,23 @@ function parseGrant(s) {
1645
1650
  let target = "";
1646
1651
  if (rest.startsWith(":")) {
1647
1652
  target = rest.slice(1);
1648
- if (!permission[1]) return null;
1653
+ if (permission[1] === "none") return null;
1649
1654
  if (target === "" || /[: \t\n*]/.test(target)) return null;
1655
+ const dot = target.indexOf(".");
1656
+ if (permission[1] === "model" && dot >= 0) {
1657
+ if (!FIELD_PERMISSIONS.includes(name) || dot === 0 || !FIELD_KEY.test(target.slice(dot + 1))) return null;
1658
+ }
1650
1659
  }
1651
1660
  return { permission, reach, target };
1652
1661
  }
1653
1662
  return null;
1654
1663
  }
1655
1664
  function covers(held, required) {
1656
- return held.permission === required.permission && reachRank[held.reach] >= reachRank[required.reach] && (held.target === "" || held.target === required.target);
1665
+ if (held.permission !== required.permission || reachRank[held.reach] < reachRank[required.reach]) return false;
1666
+ if (required.permission[1] === "model" && required.target.includes(".")) {
1667
+ return held.target === required.target || held.target === "" && held.reach === "all";
1668
+ }
1669
+ return held.target === "" || held.target === required.target;
1657
1670
  }
1658
1671
  function resourceWildcard(held) {
1659
1672
  if (!held.endsWith(RESOURCE_WILDCARD)) return null;
@@ -1775,7 +1788,7 @@ async function fetchHostedSession(request, config) {
1775
1788
  if (!match) return { outcome: "signed-out", reason: "no-cookie" };
1776
1789
  let res;
1777
1790
  try {
1778
- res = await fetch(`${config.loginOrigin}${sessionPath}`, {
1791
+ res = await fetch(`${config.loginOrigin}${sessionPath}${forApp(config.clientId)}`, {
1779
1792
  headers: {
1780
1793
  Cookie: `${cookieName}=${match[1]}`,
1781
1794
  "X-Foir-Session": "1"
@@ -1818,6 +1831,41 @@ async function fetchHostedSession(request, config) {
1818
1831
  function escapeRegExp(s) {
1819
1832
  return s.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
1820
1833
  }
1834
+ function hostedSignInNoticeOf(location, names) {
1835
+ const params = location instanceof URLSearchParams ? location : location instanceof URL ? location.searchParams : new URL(location, "https://callback.invalid").searchParams;
1836
+ const code = params.get("foir_error") ?? (params.get("error") ? params.get("error_description") : null);
1837
+ if (code) {
1838
+ return { kind: "refused", code, message: refusalMessage(code) };
1839
+ }
1840
+ const provider = params.get("foir_connected");
1841
+ if (provider) {
1842
+ const name = names?.[provider] ?? provider;
1843
+ return { kind: "connected", provider, message: `Your ${name} sign-in is now connected to your account.` };
1844
+ }
1845
+ return null;
1846
+ }
1847
+ var REFUSAL_MESSAGES = {
1848
+ account_unavailable: "This account can\u2019t sign in right now.",
1849
+ account_not_here: "That account doesn\u2019t sign in here.",
1850
+ email_unavailable: "This app can\u2019t send email yet, so no code was sent. Sign in another way.",
1851
+ signup_closed: "There\u2019s no account for that address here, and it can\u2019t be made by signing in.",
1852
+ user_cap_reached: "This app can\u2019t take any more people right now.",
1853
+ provider_named_no_subject: "The provider didn\u2019t say who you are, so it can\u2019t sign you in. Try another way.",
1854
+ provider_has_no_issuer: "The provider didn\u2019t say who you are, so it can\u2019t sign you in. Try another way.",
1855
+ provider_named_no_address: "The provider didn\u2019t share an email address, so it can\u2019t sign you in. Try another way.",
1856
+ provider_refused: "The provider didn\u2019t finish the sign-in.",
1857
+ provider_unavailable: "The provider couldn\u2019t be reached. Try again in a moment.",
1858
+ provider_exchange_failed: "The provider couldn\u2019t be reached. Try again in a moment.",
1859
+ two_step_sign_in: "This account uses two-step sign-in. Sign in with your password or a passkey.",
1860
+ mfa_required: "This app needs a second factor, which a provider sign-in can\u2019t give. Sign in with your password instead.",
1861
+ sign_in_expired: "This sign-in has expired. Start again."
1862
+ };
1863
+ function refusalMessage(code) {
1864
+ return REFUSAL_MESSAGES[code] ?? "The sign-in couldn\u2019t be finished. Try again.";
1865
+ }
1866
+ function forApp(clientId) {
1867
+ return clientId ? `?client_id=${encodeURIComponent(clientId)}` : "";
1868
+ }
1821
1869
 
1822
1870
  // src/auth/session-client.ts
1823
1871
  var DEFAULT_SESSION_PATH2 = "/session/token";
@@ -1826,8 +1874,9 @@ var DEFAULT_REFRESH_SKEW_SECONDS = 60;
1826
1874
  var MIN_REFRESH_DELAY_MS = 5e3;
1827
1875
  var CSRF_HEADER = { "X-Foir-Session": "1" };
1828
1876
  function createFoirSessionClient(config) {
1829
- const sessionUrl = `${trimSlash(config.loginOrigin)}${config.sessionPath ?? DEFAULT_SESSION_PATH2}`;
1830
- const logoutUrl = `${trimSlash(config.loginOrigin)}${config.logoutPath ?? DEFAULT_LOGOUT_PATH}`;
1877
+ const forApp2 = config.clientId ? `?client_id=${encodeURIComponent(config.clientId)}` : "";
1878
+ const sessionUrl = `${trimSlash(config.loginOrigin)}${config.sessionPath ?? DEFAULT_SESSION_PATH2}${forApp2}`;
1879
+ const logoutUrl = `${trimSlash(config.loginOrigin)}${config.logoutPath ?? DEFAULT_LOGOUT_PATH}${forApp2}`;
1831
1880
  const skewMs = (config.refreshSkewSeconds ?? DEFAULT_REFRESH_SKEW_SECONDS) * 1e3;
1832
1881
  let cached = null;
1833
1882
  let inflight = null;
@@ -1984,6 +2033,7 @@ export {
1984
2033
  hasScope,
1985
2034
  hostedLoginUrl,
1986
2035
  hostedLogoutUrl,
2036
+ hostedSignInNoticeOf,
1987
2037
  joinWaitlist,
1988
2038
  login,
1989
2039
  loginWithOTP,
@@ -2015,6 +2065,7 @@ export {
2015
2065
  resetPasswordAndSignIn,
2016
2066
  revokeAuthorizedApp,
2017
2067
  saveSession,
2068
+ signInRefusalOf,
2018
2069
  signInWithOTP,
2019
2070
  signInWithPassword,
2020
2071
  signOut,
@@ -2023,6 +2074,5 @@ export {
2023
2074
  signupContext,
2024
2075
  updateMyProfile,
2025
2076
  updatePassword,
2026
- userAccess,
2027
- verifyEmail
2077
+ userAccess
2028
2078
  };
package/dist/client.js CHANGED
@@ -5,10 +5,7 @@ import { print as print2 } from "graphql";
5
5
  var KEY_PREFIXES = [
6
6
  ["foir_pub_", "publishable"],
7
7
  ["foir_srv_", "server"],
8
- ["foir_adm_", "admin"],
9
- ["pk_", "publishable"],
10
- ["sk_", "older"],
11
- ["tc_", "older"]
8
+ ["foir_adm_", "admin"]
12
9
  ];
13
10
  var FOIR_CREDENTIALS_DOC = "https://docs.foir.dev/credentials";
14
11
  function foirKeyKind(apiKey) {
@@ -16,7 +16,7 @@ export interface FoirCodegenOptions {
16
16
  /** Foir public API GraphQL endpoint. */
17
17
  apiUrl: string;
18
18
  /**
19
- * Public (`pk_`) API key. Reads the published schema. Used as the fallback
19
+ * Publishable API key. Reads the published schema. Used as the fallback
20
20
  * when no preview key is set.
21
21
  */
22
22
  apiKey?: string;
@@ -11,7 +11,7 @@ export interface EditorProviderProps {
11
11
  children: ReactNode;
12
12
  /**
13
13
  * Parent window origin for postMessage validation.
14
- * Must be an explicit origin (e.g., 'https://admin.example.com').
14
+ * Must be an explicit origin (e.g., 'https://console.example.com').
15
15
  * Falls back to VITE_PARENT_ORIGIN or NEXT_PUBLIC_PARENT_ORIGIN env var.
16
16
  */
17
17
  parentOrigin?: string;
@@ -221,7 +221,7 @@ export interface FoirClientCore<S extends FoirSchemaDefinition> {
221
221
  /**
222
222
  * The client, shaped by the credential's manifest. An op that is not in
223
223
  * `FoirSchema` is not on this type, so `foir.tilly_block.create(...)` under a
224
- * read-only `pk_` key is a compile error rather than a 400.
224
+ * read-only publishable key is a compile error rather than a 400.
225
225
  */
226
226
  export type FoirClient<S extends FoirSchemaDefinition> = FoirClientCore<S> & {
227
227
  [MK in keyof S['models']]: FoirModelClient<S, S['models'][MK]>;
@@ -130,7 +130,7 @@
130
130
  * 3. **Emit only what the manifest returned.** The manifest is already the
131
131
  * per-caller projection of `SchemaForCaller(scopes)`, so "only the ops this
132
132
  * credential can perform" needs no extra filtering — it is what arrives. A
133
- * `pk_` key's generated schema simply has no `create`, and
133
+ * publishable key's generated schema simply has no `create`, and
134
134
  * `foir.tilly_block.create(...)` is then a compile error, which is the
135
135
  * entire point of per-key shaping.
136
136
  *
@@ -5,12 +5,12 @@
5
5
  * Where a call goes
6
6
  * ---------------------------------------------------------------------------
7
7
  *
8
- * read + `pk_` key + no user bearer + published channel
9
- * → `GET /cdn/graphql?key=pk_…&extensions={"persistedQuery":{"sha256Hash":…}}`
8
+ * read + publishable key + no user bearer + published channel
9
+ * → `GET /cdn/graphql?key=foir_pub_…&extensions={"persistedQuery":{"sha256Hash":…}}`
10
10
  * A shared cache in front of the caller stores the response, because the
11
11
  * request is a GET and the credential is in the URL.
12
12
  *
13
- * anything else — `sk_`, a user bearer, a mutation, the draft channel
13
+ * anything else: a server or admin key, a user bearer, a mutation, the draft channel
14
14
  * → `POST /graphql` with the `x-api-key` header and the APQ body.
15
15
  *
16
16
  * a call made AS an operation, with its dispatch token
@@ -182,8 +182,9 @@ export interface FoirDispatchCredential {
182
182
  context?: string | null;
183
183
  }
184
184
  /**
185
- * A client that calls Foir with an api key: a storefront's `pk_`, a server's
186
- * `sk_`, optionally for a signed-in user.
185
+ * A client that calls Foir with an api key: a storefront's publishable key, or
186
+ * the server key of the server that renders its pages, optionally for a
187
+ * signed-in user.
187
188
  */
188
189
  export interface FoirKeyClientConfig<S extends FoirSchemaDefinition = FoirSchemaDefinition> {
189
190
  /**
@@ -194,7 +195,7 @@ export interface FoirKeyClientConfig<S extends FoirSchemaDefinition = FoirSchema
194
195
  * a trailing `/graphql` is stripped before a path is appended.
195
196
  */
196
197
  apiUrl: string;
197
- /** `pk_…` or `sk_…`. The manifest, and therefore the generated types, are shaped by it. */
198
+ /** `foir_pub_…` or `foir_srv_…`. The manifest, and therefore the generated types, are shaped by it. */
198
199
  apiKey: string;
199
200
  /** A key client has no dispatch token; see {@link FoirDispatchClientConfig}. */
200
201
  dispatch?: never;
package/dist/data.js CHANGED
@@ -240,10 +240,7 @@ function readFoirEnvelope(json, options) {
240
240
  var KEY_PREFIXES = [
241
241
  ["foir_pub_", "publishable"],
242
242
  ["foir_srv_", "server"],
243
- ["foir_adm_", "admin"],
244
- ["pk_", "publishable"],
245
- ["sk_", "older"],
246
- ["tc_", "older"]
243
+ ["foir_adm_", "admin"]
247
244
  ];
248
245
  var FOIR_CREDENTIALS_DOC = "https://docs.foir.dev/credentials";
249
246
  function foirKeyKind(apiKey) {
@@ -356,7 +353,7 @@ function assertFoirCredential(config) {
356
353
  if (kind === "admin") {
357
354
  throw new FoirRequestError(adminKeyRefusal("createFoirClient"));
358
355
  }
359
- if (loose.visitor !== void 0 && kind !== "server" && kind !== "older") {
356
+ if (loose.visitor !== void 0 && kind !== "server") {
360
357
  throw new FoirRequestError(
361
358
  `[foir] createFoirClient: \`visitor\` names the visitor a server calls for, and only a server key holding visitors:forward may send it. A publishable key already calls as its visitor, and cannot hold the permission. Drop \`visitor\`, or build this client from your server key on the server that renders your pages. See ${FOIR_CREDENTIALS_DOC}`
362
359
  );
package/dist/index.js CHANGED
@@ -98,10 +98,7 @@ function isValidHostMessage(data) {
98
98
  var KEY_PREFIXES = [
99
99
  ["foir_pub_", "publishable"],
100
100
  ["foir_srv_", "server"],
101
- ["foir_adm_", "admin"],
102
- ["pk_", "publishable"],
103
- ["sk_", "older"],
104
- ["tc_", "older"]
101
+ ["foir_adm_", "admin"]
105
102
  ];
106
103
  var FOIR_CREDENTIALS_DOC = "https://docs.foir.dev/credentials";
107
104
  function foirKeyKind(apiKey) {
package/dist/next.js CHANGED
@@ -24,10 +24,7 @@ import { print as print2 } from "graphql";
24
24
  var KEY_PREFIXES = [
25
25
  ["foir_pub_", "publishable"],
26
26
  ["foir_srv_", "server"],
27
- ["foir_adm_", "admin"],
28
- ["pk_", "publishable"],
29
- ["sk_", "older"],
30
- ["tc_", "older"]
27
+ ["foir_adm_", "admin"]
31
28
  ];
32
29
  function foirKeyKind(apiKey) {
33
30
  if (typeof apiKey !== "string") return void 0;
@@ -976,7 +973,6 @@ var AUTH_OPS = {
976
973
  requestPasswordReset: "requestPasswordReset",
977
974
  resetPassword: "resetPassword",
978
975
  updatePassword: "updatePassword",
979
- verifyEmail: "verifyEmail",
980
976
  deleteMyAccount: "deleteMyAccount",
981
977
  // The user's own profile, and the apps they have agreed may act for them.
982
978
  updateMyProfile: "updateMyProfile",