@foir/sdk 0.22.0 → 0.23.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) {
@@ -1232,6 +1229,16 @@ function providerSignInRefusalOf(error) {
1232
1229
  }
1233
1230
  return null;
1234
1231
  }
1232
+ function signInRefusalOf(error) {
1233
+ if (!(error instanceof FoirRequestError)) return null;
1234
+ for (const entry of error.graphQLErrors ?? []) {
1235
+ const value = entry.extensions?.signIn;
1236
+ if (!value || typeof value !== "object" || Array.isArray(value)) continue;
1237
+ const { code } = value;
1238
+ if (typeof code === "string") return { code };
1239
+ }
1240
+ return null;
1241
+ }
1235
1242
  async function confirmProviderLink(env, input) {
1236
1243
  return authOp(env, AUTH_OPS.confirmProviderLink, { input });
1237
1244
  }
@@ -1253,8 +1260,8 @@ async function signupContext(env) {
1253
1260
  async function joinWaitlist(env, email) {
1254
1261
  return authOp(env, AUTH_OPS.joinWaitlist, { email });
1255
1262
  }
1256
- async function requestPasswordReset(env, email) {
1257
- return authOp(env, AUTH_OPS.requestPasswordReset, { email });
1263
+ async function requestPasswordReset(env, email, options) {
1264
+ return authOp(env, AUTH_OPS.requestPasswordReset, { email, clientId: options?.clientId });
1258
1265
  }
1259
1266
  async function resetPassword(env, vars) {
1260
1267
  return authOp(env, AUTH_OPS.resetPassword, vars);
@@ -1269,7 +1276,9 @@ async function currentUser(env, options) {
1269
1276
  return authOp(env, AUTH_OPS.currentUser, void 0, options);
1270
1277
  }
1271
1278
  async function myProviderToken(env, providerKey, options) {
1272
- return authOp(env, AUTH_OPS.myProviderToken, { providerKey }, options);
1279
+ const { forceRefresh, ...rest } = options ?? {};
1280
+ const vars = forceRefresh ? { providerKey, forceRefresh: true } : { providerKey };
1281
+ return authOp(env, AUTH_OPS.myProviderToken, vars, rest);
1273
1282
  }
1274
1283
  async function logout(env, options) {
1275
1284
  return authOp(env, AUTH_OPS.logout, void 0, options);
@@ -1486,125 +1495,125 @@ async function recoverSessionUser(adapter, env, token) {
1486
1495
 
1487
1496
  // src/auth/grant-table.generated.ts
1488
1497
  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, [], []]
1498
+ ["records:read", "model", ["own", "all"], []],
1499
+ ["records:create", "model", [], []],
1500
+ ["records:write", "model", ["own", "all"], []],
1501
+ ["records:delete", "model", ["own", "all"], []],
1502
+ ["records:publish", "model", ["own", "all"], []],
1503
+ ["records:attribute", "model", [], []],
1504
+ ["search:read", "model", [], []],
1505
+ ["embeddings:read", "none", [], []],
1506
+ ["embeddings:write", "none", [], []],
1507
+ ["schemas:read", "none", [], []],
1508
+ ["drafts:read", "none", [], []],
1509
+ ["files:read", "none", ["own", "all"], []],
1510
+ ["files:write", "none", ["own", "all"], []],
1511
+ ["files:delete", "none", ["own", "all"], []],
1512
+ ["notifications:read", "none", ["own", "all"], []],
1513
+ ["notifications:write", "none", ["own", "named", "all"], []],
1514
+ ["notifications:consent", "none", [], []],
1515
+ ["pushcredentials:read", "none", [], []],
1516
+ ["pushcredentials:write", "none", [], []],
1517
+ ["notes:read", "none", ["own", "all"], []],
1518
+ ["notes:write", "none", ["own", "all"], []],
1519
+ ["notes:create", "none", [], []],
1520
+ ["approvals:read", "none", [], []],
1521
+ ["approvals:write", "none", [], []],
1522
+ ["rooms:read", "model", [], []],
1523
+ ["rooms:write", "model", [], []],
1524
+ ["presence:read", "model", [], []],
1525
+ ["operations:read", "none", [], []],
1526
+ ["operations:execute", "operation", [], []],
1527
+ ["operations:write", "none", [], []],
1528
+ ["operations:complete", "none", [], []],
1529
+ ["status:write", "none", [], []],
1530
+ ["appconfig:read", "none", [], []],
1531
+ ["schedules:read", "none", [], []],
1532
+ ["schedules:write", "none", [], []],
1533
+ ["hooks:read", "none", [], []],
1534
+ ["hooks:write", "none", [], []],
1535
+ ["authclients:read", "none", [], []],
1536
+ ["authclients:write", "none", [], []],
1537
+ ["domains:read", "none", [], []],
1538
+ ["domains:write", "none", [], []],
1539
+ ["secrets:read", "none", [], []],
1540
+ ["secrets:list", "none", [], []],
1541
+ ["secrets:put", "none", [], []],
1542
+ ["secrets:delete", "none", [], []],
1543
+ ["appsecrets:read", "none", [], []],
1544
+ ["appsecrets:list", "none", [], []],
1545
+ ["appsecrets:put", "none", [], []],
1546
+ ["appsecrets:delete", "none", [], []],
1547
+ ["opsecrets:read", "none", [], []],
1548
+ ["opsecrets:write", "none", [], []],
1549
+ ["settings:read", "none", [], []],
1550
+ ["settings:write", "none", [], []],
1551
+ ["designtokens:read", "none", [], []],
1552
+ ["designtokens:write", "none", [], []],
1553
+ ["models:read", "none", [], []],
1554
+ ["models:write", "none", [], []],
1555
+ ["configs:read", "none", [], []],
1556
+ ["configs:write", "none", [], []],
1557
+ ["apps:read", "none", [], []],
1558
+ ["apps:write", "none", [], []],
1559
+ ["events:read", "none", [], []],
1560
+ ["targeting:debug", "none", [], []],
1561
+ ["visitors:forward", "none", [], []],
1562
+ ["apikeys:read", "none", [], []],
1563
+ ["apikeys:write", "none", [], []],
1564
+ ["organizations:read", "none", [], []],
1565
+ ["organizations:write", "none", [], []],
1566
+ ["organizations:create", "none", [], []],
1567
+ ["organizations:delete", "none", [], []],
1568
+ ["organizations:reach", "none", [], []],
1569
+ ["members:read", "none", [], []],
1570
+ ["members:write", "none", [], []],
1571
+ ["roles:read", "none", [], []],
1572
+ ["roles:write", "none", [], []],
1573
+ ["projects:read", "none", [], []],
1574
+ ["projects:write", "none", [], []],
1575
+ ["project:stand", "none", [], []],
1576
+ ["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"]],
1577
+ ["projects:create", "none", [], []],
1578
+ ["projects:delete", "none", [], []],
1579
+ ["tenants:read", "none", [], []],
1580
+ ["tenants:write", "none", [], []],
1581
+ ["tenants:delete", "none", [], []],
1582
+ ["audit:read", "none", [], []],
1583
+ ["export:run", "none", [], []],
1584
+ ["billing:read", "none", [], []],
1585
+ ["billing:manage", "none", [], []],
1586
+ ["usage:read", "none", [], []],
1587
+ ["controlkeys:read", "none", [], []],
1588
+ ["controlkeys:write", "none", [], []],
1589
+ ["tenanthooks:read", "none", [], []],
1590
+ ["tenanthooks:write", "none", [], []],
1591
+ ["apps:install", "none", [], []],
1592
+ ["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"]],
1593
+ ["platform:read", "none", [], []],
1594
+ ["platform:manage", "none", [], ["tenant:manage", "platform:read", "platform:create_workspace"]],
1595
+ ["platform:create_workspace", "none", [], []],
1596
+ ["users:read", "none", ["own", "named", "all"], []],
1597
+ ["users:write", "none", ["own", "all"], []],
1598
+ ["users:setup", "none", [], []],
1599
+ ["users:delete", "none", ["own", "all"], []],
1600
+ ["users:create", "none", [], []],
1601
+ ["identities:read", "none", [], []],
1602
+ ["identities:delete", "none", [], []],
1603
+ ["usersecrets:read", "none", [], []],
1604
+ ["usersecrets:list", "none", [], []],
1605
+ ["usersecrets:put", "none", [], []],
1606
+ ["usersecrets:delete", "none", [], []],
1607
+ ["auth:login_with_foir", "none", [], []],
1608
+ ["signinproviders:read", "none", [], []],
1609
+ ["signinproviders:write", "none", [], []]
1603
1610
  ];
1604
1611
 
1605
1612
  // src/auth/grants.ts
1606
1613
  var WILDCARD = "*";
1607
1614
  var RESOURCE_WILDCARD = ":*";
1615
+ var FIELD_PERMISSIONS = ["records:read", "records:write"];
1616
+ var FIELD_KEY = /^[A-Za-z_][A-Za-z0-9_]*$/;
1608
1617
  var index;
1609
1618
  function catalogue() {
1610
1619
  if (!index) {
@@ -1645,15 +1654,23 @@ function parseGrant(s) {
1645
1654
  let target = "";
1646
1655
  if (rest.startsWith(":")) {
1647
1656
  target = rest.slice(1);
1648
- if (!permission[1]) return null;
1657
+ if (permission[1] === "none") return null;
1649
1658
  if (target === "" || /[: \t\n*]/.test(target)) return null;
1659
+ const dot = target.indexOf(".");
1660
+ if (permission[1] === "model" && dot >= 0) {
1661
+ if (!FIELD_PERMISSIONS.includes(name) || dot === 0 || !FIELD_KEY.test(target.slice(dot + 1))) return null;
1662
+ }
1650
1663
  }
1651
1664
  return { permission, reach, target };
1652
1665
  }
1653
1666
  return null;
1654
1667
  }
1655
1668
  function covers(held, required) {
1656
- return held.permission === required.permission && reachRank[held.reach] >= reachRank[required.reach] && (held.target === "" || held.target === required.target);
1669
+ if (held.permission !== required.permission || reachRank[held.reach] < reachRank[required.reach]) return false;
1670
+ if (required.permission[1] === "model" && required.target.includes(".")) {
1671
+ return held.target === required.target || held.target === "" && held.reach === "all";
1672
+ }
1673
+ return held.target === "" || held.target === required.target;
1657
1674
  }
1658
1675
  function resourceWildcard(held) {
1659
1676
  if (!held.endsWith(RESOURCE_WILDCARD)) return null;
@@ -1818,6 +1835,38 @@ async function fetchHostedSession(request, config) {
1818
1835
  function escapeRegExp(s) {
1819
1836
  return s.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
1820
1837
  }
1838
+ function hostedSignInNoticeOf(location, names) {
1839
+ const params = location instanceof URLSearchParams ? location : location instanceof URL ? location.searchParams : new URL(location, "https://callback.invalid").searchParams;
1840
+ const code = params.get("foir_error") ?? (params.get("error") ? params.get("error_description") : null);
1841
+ if (code) {
1842
+ return { kind: "refused", code, message: refusalMessage(code) };
1843
+ }
1844
+ const provider = params.get("foir_connected");
1845
+ if (provider) {
1846
+ const name = names?.[provider] ?? provider;
1847
+ return { kind: "connected", provider, message: `Your ${name} sign-in is now connected to your account.` };
1848
+ }
1849
+ return null;
1850
+ }
1851
+ var REFUSAL_MESSAGES = {
1852
+ account_unavailable: "This account can\u2019t sign in right now.",
1853
+ account_not_here: "That account doesn\u2019t sign in here.",
1854
+ email_unavailable: "This app can\u2019t send email yet, so no code was sent. Sign in another way.",
1855
+ signup_closed: "There\u2019s no account for that address here, and it can\u2019t be made by signing in.",
1856
+ user_cap_reached: "This app can\u2019t take any more people right now.",
1857
+ provider_named_no_subject: "The provider didn\u2019t say who you are, so it can\u2019t sign you in. Try another way.",
1858
+ provider_has_no_issuer: "The provider didn\u2019t say who you are, so it can\u2019t sign you in. Try another way.",
1859
+ provider_named_no_address: "The provider didn\u2019t share an email address, so it can\u2019t sign you in. Try another way.",
1860
+ provider_refused: "The provider didn\u2019t finish the sign-in.",
1861
+ provider_unavailable: "The provider couldn\u2019t be reached. Try again in a moment.",
1862
+ provider_exchange_failed: "The provider couldn\u2019t be reached. Try again in a moment.",
1863
+ two_step_sign_in: "This account uses two-step sign-in. Sign in with your password or a passkey.",
1864
+ mfa_required: "This app needs a second factor, which a provider sign-in can\u2019t give. Sign in with your password instead.",
1865
+ sign_in_expired: "This sign-in has expired. Start again."
1866
+ };
1867
+ function refusalMessage(code) {
1868
+ return REFUSAL_MESSAGES[code] ?? "The sign-in couldn\u2019t be finished. Try again.";
1869
+ }
1821
1870
 
1822
1871
  // src/auth/session-client.ts
1823
1872
  var DEFAULT_SESSION_PATH2 = "/session/token";
@@ -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,
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;
@@ -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;