@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/placement.js CHANGED
@@ -1,124 +1,124 @@
1
1
  // src/auth/grant-table.generated.ts
2
2
  var GRANT_TABLE = [
3
- ["records:read", true, ["own", "all"], []],
4
- ["records:create", true, [], []],
5
- ["records:write", true, ["own", "all"], []],
6
- ["records:delete", true, ["own", "all"], []],
7
- ["records:publish", true, ["own", "all"], []],
8
- ["records:attribute", true, [], []],
9
- ["search:read", true, [], []],
10
- ["embeddings:read", false, [], []],
11
- ["embeddings:write", false, [], []],
12
- ["schemas:read", false, [], []],
13
- ["drafts:read", false, [], []],
14
- ["files:read", false, ["own", "all"], []],
15
- ["files:write", false, ["own", "all"], []],
16
- ["files:delete", false, ["own", "all"], []],
17
- ["notifications:read", false, ["own", "all"], []],
18
- ["notifications:write", false, ["own", "named", "all"], []],
19
- ["notifications:consent", false, [], []],
20
- ["pushcredentials:read", false, [], []],
21
- ["pushcredentials:write", false, [], []],
22
- ["notes:read", false, ["own", "all"], []],
23
- ["notes:write", false, ["own", "all"], []],
24
- ["notes:create", false, [], []],
25
- ["approvals:read", false, [], []],
26
- ["approvals:write", false, [], []],
27
- ["rooms:read", true, [], []],
28
- ["rooms:write", true, [], []],
29
- ["presence:read", true, [], []],
30
- ["operations:read", false, [], []],
31
- ["operations:execute", true, [], []],
32
- ["operations:write", false, [], []],
33
- ["operations:complete", false, [], []],
34
- ["status:write", false, [], []],
35
- ["appconfig:read", false, [], []],
36
- ["schedules:read", false, [], []],
37
- ["schedules:write", false, [], []],
38
- ["hooks:read", false, [], []],
39
- ["hooks:write", false, [], []],
40
- ["relyingparties:read", false, [], []],
41
- ["relyingparties:write", false, [], []],
42
- ["domains:read", false, [], []],
43
- ["domains:write", false, [], []],
44
- ["secrets:read", false, [], []],
45
- ["secrets:list", false, [], []],
46
- ["secrets:put", false, [], []],
47
- ["secrets:delete", false, [], []],
48
- ["appsecrets:read", false, [], []],
49
- ["appsecrets:list", false, [], []],
50
- ["appsecrets:put", false, [], []],
51
- ["appsecrets:delete", false, [], []],
52
- ["opsecrets:read", false, [], []],
53
- ["opsecrets:write", false, [], []],
54
- ["settings:read", false, [], []],
55
- ["settings:write", false, [], []],
56
- ["designtokens:read", false, [], []],
57
- ["designtokens:write", false, [], []],
58
- ["models:read", false, [], []],
59
- ["models:write", false, [], []],
60
- ["configs:read", false, [], []],
61
- ["configs:write", false, [], []],
62
- ["apps:read", false, [], []],
63
- ["apps:write", false, [], []],
64
- ["events:read", false, [], []],
65
- ["targeting:debug", false, [], []],
66
- ["visitors:forward", false, [], []],
67
- ["apikeys:read", false, [], []],
68
- ["apikeys:write", false, [], []],
69
- ["organizations:read", false, [], []],
70
- ["organizations:write", false, [], []],
71
- ["organizations:create", false, [], []],
72
- ["organizations:delete", false, [], []],
73
- ["organizations:reach", false, [], []],
74
- ["members:read", false, [], []],
75
- ["members:write", false, [], []],
76
- ["roles:read", false, [], []],
77
- ["roles:write", false, [], []],
78
- ["projects:read", false, [], []],
79
- ["projects:write", false, [], []],
80
- ["project:stand", false, [], []],
81
- ["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"]],
82
- ["projects:create", false, [], []],
83
- ["projects:delete", false, [], []],
84
- ["tenants:read", false, [], []],
85
- ["tenants:write", false, [], []],
86
- ["tenants:delete", false, [], []],
87
- ["audit:read", false, [], []],
88
- ["export:run", false, [], []],
89
- ["billing:read", false, [], []],
90
- ["billing:manage", false, [], []],
91
- ["usage:read", false, [], []],
92
- ["controlkeys:read", false, [], []],
93
- ["controlkeys:write", false, [], []],
94
- ["tenantsigninproviders:read", false, [], []],
95
- ["tenantsigninproviders:write", false, [], []],
96
- ["tenanthooks:read", false, [], []],
97
- ["tenanthooks:write", false, [], []],
98
- ["apps:install", false, [], []],
99
- ["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"]],
100
- ["platform:read", false, [], []],
101
- ["platform:manage", false, [], ["tenant:manage", "platform:read", "platform:create_workspace"]],
102
- ["platform:create_workspace", false, [], []],
103
- ["users:read", false, ["own", "named", "all"], []],
104
- ["users:write", false, ["own", "all"], []],
105
- ["users:setup", false, [], []],
106
- ["users:delete", false, ["own", "all"], []],
107
- ["users:create", false, [], []],
108
- ["identities:read", false, [], []],
109
- ["identities:delete", false, [], []],
110
- ["usersecrets:read", false, [], []],
111
- ["usersecrets:list", false, [], []],
112
- ["usersecrets:put", false, [], []],
113
- ["usersecrets:delete", false, [], []],
114
- ["auth:login_with_foir", false, [], []],
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 (!permission[1]) return null;
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
- return held.permission === required.permission && reachRank[held.reach] >= reachRank[required.reach] && (held.target === "" || held.target === required.target);
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 `pk_` key). */
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, because
65
- * these two arrive as plain GraphQL errors with no `extensions.code` to read.
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.