@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/CHANGELOG.md +51 -0
- package/README.md +6 -6
- package/dist/app/client.d.ts +5 -4
- package/dist/app/errors.d.ts +8 -6
- package/dist/auth/auth.d.ts +41 -9
- package/dist/auth/grant-table.generated.d.ts +5 -4
- package/dist/auth/hosted.d.ts +24 -0
- package/dist/auth/index.d.ts +4 -4
- package/dist/auth/operations.d.ts +28 -4
- package/dist/auth.js +174 -123
- package/dist/client.js +1 -4
- package/dist/codegen/preset.d.ts +1 -1
- package/dist/data/client.d.ts +1 -1
- package/dist/data/schema.d.ts +1 -1
- package/dist/data/transport.d.ts +7 -6
- package/dist/data.js +2 -5
- package/dist/index.js +1 -4
- package/dist/next.js +1 -4
- package/dist/placement.js +124 -116
- package/dist/push.js +1 -4
- package/dist/react/FoirProvider.d.ts +1 -1
- package/dist/react/feedback-notes.d.ts +4 -2
- package/dist/react.js +125 -120
- package/dist/server/events-client.d.ts +7 -7
- package/dist/server/types.d.ts +1 -1
- package/dist/server.js +121 -120
- package/dist/transport/foir-http.d.ts +1 -1
- package/dist/transport/key-kind.d.ts +1 -12
- package/package.json +3 -3
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
|
-
|
|
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",
|
|
1490
|
-
["records:create",
|
|
1491
|
-
["records:write",
|
|
1492
|
-
["records:delete",
|
|
1493
|
-
["records:publish",
|
|
1494
|
-
["records:attribute",
|
|
1495
|
-
["search:read",
|
|
1496
|
-
["embeddings:read",
|
|
1497
|
-
["embeddings:write",
|
|
1498
|
-
["schemas:read",
|
|
1499
|
-
["drafts:read",
|
|
1500
|
-
["files:read",
|
|
1501
|
-
["files:write",
|
|
1502
|
-
["files:delete",
|
|
1503
|
-
["notifications:read",
|
|
1504
|
-
["notifications:write",
|
|
1505
|
-
["notifications:consent",
|
|
1506
|
-
["pushcredentials:read",
|
|
1507
|
-
["pushcredentials:write",
|
|
1508
|
-
["notes:read",
|
|
1509
|
-
["notes:write",
|
|
1510
|
-
["notes:create",
|
|
1511
|
-
["approvals:read",
|
|
1512
|
-
["approvals:write",
|
|
1513
|
-
["rooms:read",
|
|
1514
|
-
["rooms:write",
|
|
1515
|
-
["presence:read",
|
|
1516
|
-
["operations:read",
|
|
1517
|
-
["operations:execute",
|
|
1518
|
-
["operations:write",
|
|
1519
|
-
["operations:complete",
|
|
1520
|
-
["status:write",
|
|
1521
|
-
["appconfig:read",
|
|
1522
|
-
["schedules:read",
|
|
1523
|
-
["schedules:write",
|
|
1524
|
-
["hooks:read",
|
|
1525
|
-
["hooks:write",
|
|
1526
|
-
["
|
|
1527
|
-
["
|
|
1528
|
-
["domains:read",
|
|
1529
|
-
["domains:write",
|
|
1530
|
-
["secrets:read",
|
|
1531
|
-
["secrets:list",
|
|
1532
|
-
["secrets:put",
|
|
1533
|
-
["secrets:delete",
|
|
1534
|
-
["appsecrets:read",
|
|
1535
|
-
["appsecrets:list",
|
|
1536
|
-
["appsecrets:put",
|
|
1537
|
-
["appsecrets:delete",
|
|
1538
|
-
["opsecrets:read",
|
|
1539
|
-
["opsecrets:write",
|
|
1540
|
-
["settings:read",
|
|
1541
|
-
["settings:write",
|
|
1542
|
-
["designtokens:read",
|
|
1543
|
-
["designtokens:write",
|
|
1544
|
-
["models:read",
|
|
1545
|
-
["models:write",
|
|
1546
|
-
["configs:read",
|
|
1547
|
-
["configs:write",
|
|
1548
|
-
["apps:read",
|
|
1549
|
-
["apps:write",
|
|
1550
|
-
["events:read",
|
|
1551
|
-
["targeting:debug",
|
|
1552
|
-
["visitors:forward",
|
|
1553
|
-
["apikeys:read",
|
|
1554
|
-
["apikeys:write",
|
|
1555
|
-
["organizations:read",
|
|
1556
|
-
["organizations:write",
|
|
1557
|
-
["organizations:create",
|
|
1558
|
-
["organizations:delete",
|
|
1559
|
-
["organizations:reach",
|
|
1560
|
-
["members:read",
|
|
1561
|
-
["members:write",
|
|
1562
|
-
["roles:read",
|
|
1563
|
-
["roles:write",
|
|
1564
|
-
["projects:read",
|
|
1565
|
-
["projects:write",
|
|
1566
|
-
["project:stand",
|
|
1567
|
-
["project:manage",
|
|
1568
|
-
["projects:create",
|
|
1569
|
-
["projects:delete",
|
|
1570
|
-
["tenants:read",
|
|
1571
|
-
["tenants:write",
|
|
1572
|
-
["tenants:delete",
|
|
1573
|
-
["audit:read",
|
|
1574
|
-
["export:run",
|
|
1575
|
-
["billing:read",
|
|
1576
|
-
["billing:manage",
|
|
1577
|
-
["usage:read",
|
|
1578
|
-
["controlkeys:read",
|
|
1579
|
-
["controlkeys:write",
|
|
1580
|
-
["
|
|
1581
|
-
["
|
|
1582
|
-
["
|
|
1583
|
-
["
|
|
1584
|
-
["
|
|
1585
|
-
["
|
|
1586
|
-
["platform:
|
|
1587
|
-
["
|
|
1588
|
-
["
|
|
1589
|
-
["users:
|
|
1590
|
-
["users:
|
|
1591
|
-
["users:
|
|
1592
|
-
["
|
|
1593
|
-
["
|
|
1594
|
-
["
|
|
1595
|
-
["
|
|
1596
|
-
["usersecrets:
|
|
1597
|
-
["usersecrets:
|
|
1598
|
-
["
|
|
1599
|
-
["
|
|
1600
|
-
["
|
|
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 (
|
|
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
|
-
|
|
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) {
|
package/dist/codegen/preset.d.ts
CHANGED
|
@@ -16,7 +16,7 @@ export interface FoirCodegenOptions {
|
|
|
16
16
|
/** Foir public API GraphQL endpoint. */
|
|
17
17
|
apiUrl: string;
|
|
18
18
|
/**
|
|
19
|
-
*
|
|
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;
|
package/dist/data/client.d.ts
CHANGED
|
@@ -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
|
|
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]>;
|
package/dist/data/schema.d.ts
CHANGED
|
@@ -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
|
-
*
|
|
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
|
*
|
package/dist/data/transport.d.ts
CHANGED
|
@@ -5,12 +5,12 @@
|
|
|
5
5
|
* Where a call goes
|
|
6
6
|
* ---------------------------------------------------------------------------
|
|
7
7
|
*
|
|
8
|
-
* read +
|
|
9
|
-
* → `GET /cdn/graphql?key=
|
|
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
|
|
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
|
|
186
|
-
*
|
|
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
|
-
/** `
|
|
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"
|
|
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;
|