@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/CHANGELOG.md +230 -154
- package/README.md +6 -6
- package/dist/app/client.d.ts +5 -4
- package/dist/app/contract/proto/apps/v1/apps_pb.d.ts +104 -99
- package/dist/app/contract/proto/apps/v1/discovery_pb.d.ts +10 -10
- package/dist/app/errors.d.ts +8 -6
- package/dist/auth/auth.d.ts +56 -17
- package/dist/auth/grant-table.generated.d.ts +5 -4
- package/dist/auth/hosted.d.ts +29 -0
- package/dist/auth/index.d.ts +4 -4
- package/dist/auth/operations.d.ts +34 -11
- package/dist/auth/ops.d.ts +0 -1
- package/dist/auth/session-client.d.ts +5 -0
- package/dist/auth-session.js +3 -2
- package/dist/auth.js +182 -132
- package/dist/client.js +1 -4
- package/dist/codegen/preset.d.ts +1 -1
- package/dist/components/EditorProvider.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 -5
- package/dist/placement.js +124 -116
- package/dist/push.js +1 -5
- package/dist/react/FoirProvider.d.ts +1 -1
- package/dist/react/feedback-notes.d.ts +4 -2
- package/dist/react.js +128 -123
- package/dist/server/events-client.d.ts +9 -9
- package/dist/server/types.d.ts +1 -1
- package/dist/server.js +123 -122
- package/dist/transport/foir-http.d.ts +1 -1
- package/dist/transport/key-kind.d.ts +1 -12
- package/package.json +1 -1
package/dist/placement.js
CHANGED
|
@@ -1,124 +1,124 @@
|
|
|
1
1
|
// src/auth/grant-table.generated.ts
|
|
2
2
|
var GRANT_TABLE = [
|
|
3
|
-
["records:read",
|
|
4
|
-
["records:create",
|
|
5
|
-
["records:write",
|
|
6
|
-
["records:delete",
|
|
7
|
-
["records:publish",
|
|
8
|
-
["records:attribute",
|
|
9
|
-
["search:read",
|
|
10
|
-
["embeddings:read",
|
|
11
|
-
["embeddings:write",
|
|
12
|
-
["schemas:read",
|
|
13
|
-
["drafts:read",
|
|
14
|
-
["files:read",
|
|
15
|
-
["files:write",
|
|
16
|
-
["files:delete",
|
|
17
|
-
["notifications:read",
|
|
18
|
-
["notifications:write",
|
|
19
|
-
["notifications:consent",
|
|
20
|
-
["pushcredentials:read",
|
|
21
|
-
["pushcredentials:write",
|
|
22
|
-
["notes:read",
|
|
23
|
-
["notes:write",
|
|
24
|
-
["notes:create",
|
|
25
|
-
["approvals:read",
|
|
26
|
-
["approvals:write",
|
|
27
|
-
["rooms:read",
|
|
28
|
-
["rooms:write",
|
|
29
|
-
["presence:read",
|
|
30
|
-
["operations:read",
|
|
31
|
-
["operations:execute",
|
|
32
|
-
["operations:write",
|
|
33
|
-
["operations:complete",
|
|
34
|
-
["status:write",
|
|
35
|
-
["appconfig:read",
|
|
36
|
-
["schedules:read",
|
|
37
|
-
["schedules:write",
|
|
38
|
-
["hooks:read",
|
|
39
|
-
["hooks:write",
|
|
40
|
-
["
|
|
41
|
-
["
|
|
42
|
-
["domains:read",
|
|
43
|
-
["domains:write",
|
|
44
|
-
["secrets:read",
|
|
45
|
-
["secrets:list",
|
|
46
|
-
["secrets:put",
|
|
47
|
-
["secrets:delete",
|
|
48
|
-
["appsecrets:read",
|
|
49
|
-
["appsecrets:list",
|
|
50
|
-
["appsecrets:put",
|
|
51
|
-
["appsecrets:delete",
|
|
52
|
-
["opsecrets:read",
|
|
53
|
-
["opsecrets:write",
|
|
54
|
-
["settings:read",
|
|
55
|
-
["settings:write",
|
|
56
|
-
["designtokens:read",
|
|
57
|
-
["designtokens:write",
|
|
58
|
-
["models:read",
|
|
59
|
-
["models:write",
|
|
60
|
-
["configs:read",
|
|
61
|
-
["configs:write",
|
|
62
|
-
["apps:read",
|
|
63
|
-
["apps:write",
|
|
64
|
-
["events:read",
|
|
65
|
-
["targeting:debug",
|
|
66
|
-
["visitors:forward",
|
|
67
|
-
["apikeys:read",
|
|
68
|
-
["apikeys:write",
|
|
69
|
-
["organizations:read",
|
|
70
|
-
["organizations:write",
|
|
71
|
-
["organizations:create",
|
|
72
|
-
["organizations:delete",
|
|
73
|
-
["organizations:reach",
|
|
74
|
-
["members:read",
|
|
75
|
-
["members:write",
|
|
76
|
-
["roles:read",
|
|
77
|
-
["roles:write",
|
|
78
|
-
["projects:read",
|
|
79
|
-
["projects:write",
|
|
80
|
-
["project:stand",
|
|
81
|
-
["project:manage",
|
|
82
|
-
["projects:create",
|
|
83
|
-
["projects:delete",
|
|
84
|
-
["tenants:read",
|
|
85
|
-
["tenants:write",
|
|
86
|
-
["tenants:delete",
|
|
87
|
-
["audit:read",
|
|
88
|
-
["export:run",
|
|
89
|
-
["billing:read",
|
|
90
|
-
["billing:manage",
|
|
91
|
-
["usage:read",
|
|
92
|
-
["controlkeys:read",
|
|
93
|
-
["controlkeys:write",
|
|
94
|
-
["
|
|
95
|
-
["
|
|
96
|
-
["
|
|
97
|
-
["
|
|
98
|
-
["
|
|
99
|
-
["
|
|
100
|
-
["platform:
|
|
101
|
-
["
|
|
102
|
-
["
|
|
103
|
-
["users:
|
|
104
|
-
["users:
|
|
105
|
-
["users:
|
|
106
|
-
["
|
|
107
|
-
["
|
|
108
|
-
["
|
|
109
|
-
["
|
|
110
|
-
["usersecrets:
|
|
111
|
-
["usersecrets:
|
|
112
|
-
["
|
|
113
|
-
["
|
|
114
|
-
["
|
|
115
|
-
["signinproviders:read", false, [], []],
|
|
116
|
-
["signinproviders:write", false, [], []]
|
|
3
|
+
["records:read", "model", ["own", "all"], []],
|
|
4
|
+
["records:create", "model", [], []],
|
|
5
|
+
["records:write", "model", ["own", "all"], []],
|
|
6
|
+
["records:delete", "model", ["own", "all"], []],
|
|
7
|
+
["records:publish", "model", ["own", "all"], []],
|
|
8
|
+
["records:attribute", "model", [], []],
|
|
9
|
+
["search:read", "model", [], []],
|
|
10
|
+
["embeddings:read", "none", [], []],
|
|
11
|
+
["embeddings:write", "none", [], []],
|
|
12
|
+
["schemas:read", "none", [], []],
|
|
13
|
+
["drafts:read", "none", [], []],
|
|
14
|
+
["files:read", "none", ["own", "all"], []],
|
|
15
|
+
["files:write", "none", ["own", "all"], []],
|
|
16
|
+
["files:delete", "none", ["own", "all"], []],
|
|
17
|
+
["notifications:read", "none", ["own", "all"], []],
|
|
18
|
+
["notifications:write", "none", ["own", "named", "all"], []],
|
|
19
|
+
["notifications:consent", "none", [], []],
|
|
20
|
+
["pushcredentials:read", "none", [], []],
|
|
21
|
+
["pushcredentials:write", "none", [], []],
|
|
22
|
+
["notes:read", "none", ["own", "all"], []],
|
|
23
|
+
["notes:write", "none", ["own", "all"], []],
|
|
24
|
+
["notes:create", "none", [], []],
|
|
25
|
+
["approvals:read", "none", [], []],
|
|
26
|
+
["approvals:write", "none", [], []],
|
|
27
|
+
["rooms:read", "model", [], []],
|
|
28
|
+
["rooms:write", "model", [], []],
|
|
29
|
+
["presence:read", "model", [], []],
|
|
30
|
+
["operations:read", "none", [], []],
|
|
31
|
+
["operations:execute", "operation", [], []],
|
|
32
|
+
["operations:write", "none", [], []],
|
|
33
|
+
["operations:complete", "none", [], []],
|
|
34
|
+
["status:write", "none", [], []],
|
|
35
|
+
["appconfig:read", "none", [], []],
|
|
36
|
+
["schedules:read", "none", [], []],
|
|
37
|
+
["schedules:write", "none", [], []],
|
|
38
|
+
["hooks:read", "none", [], []],
|
|
39
|
+
["hooks:write", "none", [], []],
|
|
40
|
+
["authclients:read", "none", [], []],
|
|
41
|
+
["authclients:write", "none", [], []],
|
|
42
|
+
["domains:read", "none", [], []],
|
|
43
|
+
["domains:write", "none", [], []],
|
|
44
|
+
["secrets:read", "none", [], []],
|
|
45
|
+
["secrets:list", "none", [], []],
|
|
46
|
+
["secrets:put", "none", [], []],
|
|
47
|
+
["secrets:delete", "none", [], []],
|
|
48
|
+
["appsecrets:read", "none", [], []],
|
|
49
|
+
["appsecrets:list", "none", [], []],
|
|
50
|
+
["appsecrets:put", "none", [], []],
|
|
51
|
+
["appsecrets:delete", "none", [], []],
|
|
52
|
+
["opsecrets:read", "none", [], []],
|
|
53
|
+
["opsecrets:write", "none", [], []],
|
|
54
|
+
["settings:read", "none", [], []],
|
|
55
|
+
["settings:write", "none", [], []],
|
|
56
|
+
["designtokens:read", "none", [], []],
|
|
57
|
+
["designtokens:write", "none", [], []],
|
|
58
|
+
["models:read", "none", [], []],
|
|
59
|
+
["models:write", "none", [], []],
|
|
60
|
+
["configs:read", "none", [], []],
|
|
61
|
+
["configs:write", "none", [], []],
|
|
62
|
+
["apps:read", "none", [], []],
|
|
63
|
+
["apps:write", "none", [], []],
|
|
64
|
+
["events:read", "none", [], []],
|
|
65
|
+
["targeting:debug", "none", [], []],
|
|
66
|
+
["visitors:forward", "none", [], []],
|
|
67
|
+
["apikeys:read", "none", [], []],
|
|
68
|
+
["apikeys:write", "none", [], []],
|
|
69
|
+
["organizations:read", "none", [], []],
|
|
70
|
+
["organizations:write", "none", [], []],
|
|
71
|
+
["organizations:create", "none", [], []],
|
|
72
|
+
["organizations:delete", "none", [], []],
|
|
73
|
+
["organizations:reach", "none", [], []],
|
|
74
|
+
["members:read", "none", [], []],
|
|
75
|
+
["members:write", "none", [], []],
|
|
76
|
+
["roles:read", "none", [], []],
|
|
77
|
+
["roles:write", "none", [], []],
|
|
78
|
+
["projects:read", "none", [], []],
|
|
79
|
+
["projects:write", "none", [], []],
|
|
80
|
+
["project:stand", "none", [], []],
|
|
81
|
+
["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"]],
|
|
82
|
+
["projects:create", "none", [], []],
|
|
83
|
+
["projects:delete", "none", [], []],
|
|
84
|
+
["tenants:read", "none", [], []],
|
|
85
|
+
["tenants:write", "none", [], []],
|
|
86
|
+
["tenants:delete", "none", [], []],
|
|
87
|
+
["audit:read", "none", [], []],
|
|
88
|
+
["export:run", "none", [], []],
|
|
89
|
+
["billing:read", "none", [], []],
|
|
90
|
+
["billing:manage", "none", [], []],
|
|
91
|
+
["usage:read", "none", [], []],
|
|
92
|
+
["controlkeys:read", "none", [], []],
|
|
93
|
+
["controlkeys:write", "none", [], []],
|
|
94
|
+
["tenanthooks:read", "none", [], []],
|
|
95
|
+
["tenanthooks:write", "none", [], []],
|
|
96
|
+
["apps:install", "none", [], []],
|
|
97
|
+
["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"]],
|
|
98
|
+
["platform:read", "none", [], []],
|
|
99
|
+
["platform:manage", "none", [], ["tenant:manage", "platform:read", "platform:create_workspace"]],
|
|
100
|
+
["platform:create_workspace", "none", [], []],
|
|
101
|
+
["users:read", "none", ["own", "named", "all"], []],
|
|
102
|
+
["users:write", "none", ["own", "all"], []],
|
|
103
|
+
["users:setup", "none", [], []],
|
|
104
|
+
["users:delete", "none", ["own", "all"], []],
|
|
105
|
+
["users:create", "none", [], []],
|
|
106
|
+
["identities:read", "none", [], []],
|
|
107
|
+
["identities:delete", "none", [], []],
|
|
108
|
+
["usersecrets:read", "none", [], []],
|
|
109
|
+
["usersecrets:list", "none", [], []],
|
|
110
|
+
["usersecrets:put", "none", [], []],
|
|
111
|
+
["usersecrets:delete", "none", [], []],
|
|
112
|
+
["auth:login_with_foir", "none", [], []],
|
|
113
|
+
["signinproviders:read", "none", [], []],
|
|
114
|
+
["signinproviders:write", "none", [], []]
|
|
117
115
|
];
|
|
118
116
|
|
|
119
117
|
// src/auth/grants.ts
|
|
120
118
|
var WILDCARD = "*";
|
|
121
119
|
var RESOURCE_WILDCARD = ":*";
|
|
120
|
+
var FIELD_PERMISSIONS = ["records:read", "records:write"];
|
|
121
|
+
var FIELD_KEY = /^[A-Za-z_][A-Za-z0-9_]*$/;
|
|
122
122
|
var index;
|
|
123
123
|
function catalogue() {
|
|
124
124
|
if (!index) {
|
|
@@ -159,15 +159,23 @@ function parseGrant(s) {
|
|
|
159
159
|
let target = "";
|
|
160
160
|
if (rest.startsWith(":")) {
|
|
161
161
|
target = rest.slice(1);
|
|
162
|
-
if (
|
|
162
|
+
if (permission[1] === "none") return null;
|
|
163
163
|
if (target === "" || /[: \t\n*]/.test(target)) return null;
|
|
164
|
+
const dot = target.indexOf(".");
|
|
165
|
+
if (permission[1] === "model" && dot >= 0) {
|
|
166
|
+
if (!FIELD_PERMISSIONS.includes(name) || dot === 0 || !FIELD_KEY.test(target.slice(dot + 1))) return null;
|
|
167
|
+
}
|
|
164
168
|
}
|
|
165
169
|
return { permission, reach, target };
|
|
166
170
|
}
|
|
167
171
|
return null;
|
|
168
172
|
}
|
|
169
173
|
function covers(held, required) {
|
|
170
|
-
|
|
174
|
+
if (held.permission !== required.permission || reachRank[held.reach] < reachRank[required.reach]) return false;
|
|
175
|
+
if (required.permission[1] === "model" && required.target.includes(".")) {
|
|
176
|
+
return held.target === required.target || held.target === "" && held.reach === "all";
|
|
177
|
+
}
|
|
178
|
+
return held.target === "" || held.target === required.target;
|
|
171
179
|
}
|
|
172
180
|
function resourceWildcard(held) {
|
|
173
181
|
if (!held.endsWith(RESOURCE_WILDCARD)) return null;
|
package/dist/push.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",
|
|
@@ -58,7 +58,7 @@ export interface FoirContextValue {
|
|
|
58
58
|
hostedSignInUrl: ((returnTo?: string) => string) | null;
|
|
59
59
|
}
|
|
60
60
|
export interface FoirProviderProps {
|
|
61
|
-
/** API config: `{ PLATFORM_API_URL, PLATFORM_API_KEY }` (a publishable
|
|
61
|
+
/** API config: `{ PLATFORM_API_URL, PLATFORM_API_KEY }` (a publishable key). */
|
|
62
62
|
env: FoirEnv;
|
|
63
63
|
/** Session store for token mode. Defaults to a browser localStorage adapter. */
|
|
64
64
|
adapter?: SessionAdapter;
|
|
@@ -61,8 +61,10 @@ export type FoirFeedbackFault = {
|
|
|
61
61
|
/**
|
|
62
62
|
* Read the refusal, if it is one of the two the widget can act on.
|
|
63
63
|
*
|
|
64
|
-
* Matched on the platform's own sentences rather than on an error code
|
|
65
|
-
*
|
|
64
|
+
* Matched on the platform's own sentences rather than on an error code: the
|
|
65
|
+
* sign-in refusal carries no `extensions.code`, and the scope refusal's code
|
|
66
|
+
* (`PERMISSION_DENIED`) does not say which permission, which only its sentence
|
|
67
|
+
* names.
|
|
66
68
|
* Both the wrapper's message and every individual GraphQL error are scanned: the
|
|
67
69
|
* transport joins them into one string on the way out, but a partial-error
|
|
68
70
|
* envelope keeps them apart, and only one of the two forms is guaranteed.
|