@imbue-ai/detent 1.14.0 → 1.15.1
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/src/schemas/generatedBuiltinSchemas.d.ts.map +1 -1
- package/dist/src/schemas/generatedBuiltinSchemas.js +744 -18
- package/dist/src/schemas/generatedBuiltinSchemas.js.map +1 -1
- package/dist/tests/builtinSchemas.test.js +326 -89
- package/dist/tests/builtinSchemas.test.js.map +1 -1
- package/dist/tests/cli.test.js +6 -1
- package/dist/tests/cli.test.js.map +1 -1
- package/package.json +1 -1
|
@@ -1056,18 +1056,28 @@ describe('builtin schemas: sentry', () => {
|
|
|
1056
1056
|
});
|
|
1057
1057
|
});
|
|
1058
1058
|
describe('builtin schemas: slack', () => {
|
|
1059
|
+
function makeSlackRequest(overrides = {}) {
|
|
1060
|
+
return makeRequest({ domain: 'slack.com', ...overrides });
|
|
1061
|
+
}
|
|
1059
1062
|
it('slack scope matches slack.com', () => {
|
|
1060
1063
|
expectSchemaExists('slack-api');
|
|
1061
|
-
const request =
|
|
1062
|
-
domain: 'slack.com',
|
|
1064
|
+
const request = makeSlackRequest({
|
|
1063
1065
|
path: '/api/chat.postMessage',
|
|
1064
1066
|
});
|
|
1065
1067
|
expect(builtinRegistry.get('slack-api').match(request)).toBe(true);
|
|
1066
1068
|
});
|
|
1067
1069
|
it('slack scope rejects unrelated domains', () => {
|
|
1068
|
-
const request =
|
|
1070
|
+
const request = makeSlackRequest({ domain: 'slack.example.com' });
|
|
1069
1071
|
expect(builtinRegistry.get('slack-api').match(request)).toBe(false);
|
|
1070
1072
|
});
|
|
1073
|
+
it('slack scope matches files.slack.com, the file-content host', () => {
|
|
1074
|
+
expectSchemaExists('slack-api');
|
|
1075
|
+
const request = makeSlackRequest({
|
|
1076
|
+
domain: 'files.slack.com',
|
|
1077
|
+
path: '/files-pri/TEAM123-FILE456/download/image.png',
|
|
1078
|
+
});
|
|
1079
|
+
expect(builtinRegistry.get('slack-api').match(request)).toBe(true);
|
|
1080
|
+
});
|
|
1071
1081
|
it('slack-read-all matches known read methods across all families', () => {
|
|
1072
1082
|
expectSchemaExists('slack-read-all');
|
|
1073
1083
|
const readMethods = [
|
|
@@ -1108,22 +1118,53 @@ describe('builtin schemas: slack', () => {
|
|
|
1108
1118
|
'/api/threads.getView',
|
|
1109
1119
|
];
|
|
1110
1120
|
for (const path of readMethods) {
|
|
1111
|
-
expect(builtinRegistry.get('slack-read-all').match(
|
|
1121
|
+
expect(builtinRegistry.get('slack-read-all').match(makeSlackRequest({ path })), `Expected slack-read-all to match "${path}"`).toBe(true);
|
|
1112
1122
|
}
|
|
1113
1123
|
});
|
|
1124
|
+
it('slack-read-all matches file content and thumbnail downloads on files.slack.com only', () => {
|
|
1125
|
+
const filePaths = [
|
|
1126
|
+
'/files-pri/TEAM123-FILE456/image.png',
|
|
1127
|
+
'/files-pri/TEAM123-FILE456/download/image.png',
|
|
1128
|
+
'/files-tmb/TEAM123-FILE456-abcdef1234/image_360.png',
|
|
1129
|
+
];
|
|
1130
|
+
for (const path of filePaths) {
|
|
1131
|
+
expect(builtinRegistry
|
|
1132
|
+
.get('slack-read-all')
|
|
1133
|
+
.match(makeRequest({ domain: 'files.slack.com', path })), `Expected slack-read-all to match "${path}" on files.slack.com`).toBe(true);
|
|
1134
|
+
expect(builtinRegistry.get('slack-read-all').match(makeSlackRequest({ path })), `Expected slack-read-all to reject "${path}" on slack.com`).toBe(false);
|
|
1135
|
+
}
|
|
1136
|
+
expect(builtinRegistry
|
|
1137
|
+
.get('slack-read-all')
|
|
1138
|
+
.match(makeRequest({ domain: 'files.slack.com', path: '/api/conversations.history' }))).toBe(false);
|
|
1139
|
+
});
|
|
1140
|
+
it('slack scopes reject unrelated domains even for matching paths', () => {
|
|
1141
|
+
expect(builtinRegistry
|
|
1142
|
+
.get('slack-read-all')
|
|
1143
|
+
.match(makeRequest({ path: '/api/conversations.history' }))).toBe(false);
|
|
1144
|
+
expect(builtinRegistry.get('slack-chat-write').match(makeRequest({ path: '/api/chat.postMessage' }))).toBe(false);
|
|
1145
|
+
expect(builtinRegistry
|
|
1146
|
+
.get('slack-files-read')
|
|
1147
|
+
.match(makeRequest({ path: '/files-pri/TEAM123-FILE456/download/image.png' }))).toBe(false);
|
|
1148
|
+
});
|
|
1114
1149
|
it('slack-auth-read matches read auth methods but not write', () => {
|
|
1115
1150
|
expectSchemaExists('slack-auth-read');
|
|
1116
|
-
expect(builtinRegistry.get('slack-auth-read').match(
|
|
1117
|
-
expect(builtinRegistry
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
expect(builtinRegistry.get('slack-auth-read').match(
|
|
1151
|
+
expect(builtinRegistry.get('slack-auth-read').match(makeSlackRequest({ path: '/api/auth.test' }))).toBe(true);
|
|
1152
|
+
expect(builtinRegistry
|
|
1153
|
+
.get('slack-auth-read')
|
|
1154
|
+
.match(makeSlackRequest({ path: '/api/auth.teams.list' }))).toBe(true);
|
|
1155
|
+
expect(builtinRegistry.get('slack-auth-read').match(makeSlackRequest({ path: '/api/auth.revoke' }))).toBe(false);
|
|
1156
|
+
expect(builtinRegistry.get('slack-auth-read').match(makeSlackRequest({ path: '/api/auth.testfoo' }))).toBe(false);
|
|
1157
|
+
expect(builtinRegistry
|
|
1158
|
+
.get('slack-auth-read')
|
|
1159
|
+
.match(makeSlackRequest({ path: '/api/chat.postMessage' }))).toBe(false);
|
|
1121
1160
|
});
|
|
1122
1161
|
it('slack-auth-write matches write auth methods but not read', () => {
|
|
1123
1162
|
expectSchemaExists('slack-auth-write');
|
|
1124
|
-
expect(builtinRegistry.get('slack-auth-write').match(
|
|
1125
|
-
expect(builtinRegistry.get('slack-auth-write').match(
|
|
1126
|
-
expect(builtinRegistry
|
|
1163
|
+
expect(builtinRegistry.get('slack-auth-write').match(makeSlackRequest({ path: '/api/auth.revoke' }))).toBe(true);
|
|
1164
|
+
expect(builtinRegistry.get('slack-auth-write').match(makeSlackRequest({ path: '/api/auth.test' }))).toBe(false);
|
|
1165
|
+
expect(builtinRegistry
|
|
1166
|
+
.get('slack-auth-write')
|
|
1167
|
+
.match(makeSlackRequest({ path: '/api/auth.teams.list' }))).toBe(false);
|
|
1127
1168
|
});
|
|
1128
1169
|
it('slack-read-all rejects known write methods', () => {
|
|
1129
1170
|
const writeMethods = [
|
|
@@ -1142,7 +1183,7 @@ describe('builtin schemas: slack', () => {
|
|
|
1142
1183
|
'/api/subscriptions.thread.mark',
|
|
1143
1184
|
];
|
|
1144
1185
|
for (const path of writeMethods) {
|
|
1145
|
-
expect(builtinRegistry.get('slack-read-all').match(
|
|
1186
|
+
expect(builtinRegistry.get('slack-read-all').match(makeSlackRequest({ path })), `Expected slack-read-all to reject "${path}"`).toBe(false);
|
|
1146
1187
|
}
|
|
1147
1188
|
});
|
|
1148
1189
|
it('slack-write-all matches known write methods across all families', () => {
|
|
@@ -1205,7 +1246,7 @@ describe('builtin schemas: slack', () => {
|
|
|
1205
1246
|
'/api/subscriptions.thread.mark',
|
|
1206
1247
|
];
|
|
1207
1248
|
for (const path of writeMethods) {
|
|
1208
|
-
expect(builtinRegistry.get('slack-write-all').match(
|
|
1249
|
+
expect(builtinRegistry.get('slack-write-all').match(makeSlackRequest({ path })), `Expected slack-write-all to match "${path}"`).toBe(true);
|
|
1209
1250
|
}
|
|
1210
1251
|
});
|
|
1211
1252
|
it('slack-write-all rejects known read methods', () => {
|
|
@@ -1227,229 +1268,263 @@ describe('builtin schemas: slack', () => {
|
|
|
1227
1268
|
'/api/threads.getView',
|
|
1228
1269
|
];
|
|
1229
1270
|
for (const path of readMethods) {
|
|
1230
|
-
expect(builtinRegistry.get('slack-write-all').match(
|
|
1271
|
+
expect(builtinRegistry.get('slack-write-all').match(makeSlackRequest({ path })), `Expected slack-write-all to reject "${path}"`).toBe(false);
|
|
1231
1272
|
}
|
|
1232
1273
|
});
|
|
1233
1274
|
it('slack-chat-read matches read chat methods but not write', () => {
|
|
1234
1275
|
expectSchemaExists('slack-chat-read');
|
|
1235
|
-
expect(builtinRegistry.get('slack-chat-read').match(makeRequest({ path: '/api/chat.getPermalink' }))).toBe(true);
|
|
1236
1276
|
expect(builtinRegistry
|
|
1237
1277
|
.get('slack-chat-read')
|
|
1238
|
-
.match(
|
|
1239
|
-
expect(builtinRegistry
|
|
1240
|
-
|
|
1278
|
+
.match(makeSlackRequest({ path: '/api/chat.getPermalink' }))).toBe(true);
|
|
1279
|
+
expect(builtinRegistry
|
|
1280
|
+
.get('slack-chat-read')
|
|
1281
|
+
.match(makeSlackRequest({ path: '/api/chat.scheduledMessages.list' }))).toBe(true);
|
|
1282
|
+
expect(builtinRegistry
|
|
1283
|
+
.get('slack-chat-read')
|
|
1284
|
+
.match(makeSlackRequest({ path: '/api/chat.postMessage' }))).toBe(false);
|
|
1285
|
+
expect(builtinRegistry.get('slack-chat-read').match(makeSlackRequest({ path: '/api/chat.delete' }))).toBe(false);
|
|
1241
1286
|
});
|
|
1242
1287
|
it('slack-chat-write matches write chat methods but not read', () => {
|
|
1243
1288
|
expectSchemaExists('slack-chat-write');
|
|
1244
|
-
expect(builtinRegistry.get('slack-chat-write').match(makeRequest({ path: '/api/chat.postMessage' }))).toBe(true);
|
|
1245
|
-
expect(builtinRegistry.get('slack-chat-write').match(makeRequest({ path: '/api/chat.delete' }))).toBe(true);
|
|
1246
|
-
expect(builtinRegistry.get('slack-chat-write').match(makeRequest({ path: '/api/chat.update' }))).toBe(true);
|
|
1247
1289
|
expect(builtinRegistry
|
|
1248
1290
|
.get('slack-chat-write')
|
|
1249
|
-
.match(
|
|
1250
|
-
expect(builtinRegistry.get('slack-chat-write').match(
|
|
1251
|
-
expect(builtinRegistry.get('slack-chat-write').match(
|
|
1291
|
+
.match(makeSlackRequest({ path: '/api/chat.postMessage' }))).toBe(true);
|
|
1292
|
+
expect(builtinRegistry.get('slack-chat-write').match(makeSlackRequest({ path: '/api/chat.delete' }))).toBe(true);
|
|
1293
|
+
expect(builtinRegistry.get('slack-chat-write').match(makeSlackRequest({ path: '/api/chat.update' }))).toBe(true);
|
|
1294
|
+
expect(builtinRegistry
|
|
1295
|
+
.get('slack-chat-write')
|
|
1296
|
+
.match(makeSlackRequest({ path: '/api/chat.appendStream' }))).toBe(true);
|
|
1297
|
+
expect(builtinRegistry
|
|
1298
|
+
.get('slack-chat-write')
|
|
1299
|
+
.match(makeSlackRequest({ path: '/api/chat.startStream' }))).toBe(true);
|
|
1300
|
+
expect(builtinRegistry
|
|
1301
|
+
.get('slack-chat-write')
|
|
1302
|
+
.match(makeSlackRequest({ path: '/api/chat.stopStream' }))).toBe(true);
|
|
1252
1303
|
expect(builtinRegistry
|
|
1253
1304
|
.get('slack-chat-write')
|
|
1254
|
-
.match(
|
|
1305
|
+
.match(makeSlackRequest({ path: '/api/chat.getPermalink' }))).toBe(false);
|
|
1255
1306
|
});
|
|
1256
1307
|
it('slack-conversations-read matches read conversation methods but not write', () => {
|
|
1257
1308
|
expectSchemaExists('slack-conversations-read');
|
|
1258
1309
|
expect(builtinRegistry
|
|
1259
1310
|
.get('slack-conversations-read')
|
|
1260
|
-
.match(
|
|
1311
|
+
.match(makeSlackRequest({ path: '/api/conversations.list' }))).toBe(true);
|
|
1261
1312
|
expect(builtinRegistry
|
|
1262
1313
|
.get('slack-conversations-read')
|
|
1263
|
-
.match(
|
|
1314
|
+
.match(makeSlackRequest({ path: '/api/conversations.history' }))).toBe(true);
|
|
1264
1315
|
expect(builtinRegistry
|
|
1265
1316
|
.get('slack-conversations-read')
|
|
1266
|
-
.match(
|
|
1317
|
+
.match(makeSlackRequest({ path: '/api/conversations.listConnectInvites' }))).toBe(true);
|
|
1267
1318
|
expect(builtinRegistry
|
|
1268
1319
|
.get('slack-conversations-read')
|
|
1269
|
-
.match(
|
|
1320
|
+
.match(makeSlackRequest({ path: '/api/conversations.requestSharedInvite.list' }))).toBe(true);
|
|
1270
1321
|
expect(builtinRegistry
|
|
1271
1322
|
.get('slack-conversations-read')
|
|
1272
|
-
.match(
|
|
1323
|
+
.match(makeSlackRequest({ path: '/api/conversations.kick' }))).toBe(false);
|
|
1273
1324
|
expect(builtinRegistry
|
|
1274
1325
|
.get('slack-conversations-read')
|
|
1275
|
-
.match(
|
|
1326
|
+
.match(makeSlackRequest({ path: '/api/conversations.archive' }))).toBe(false);
|
|
1276
1327
|
});
|
|
1277
1328
|
it('slack-conversations-write matches write conversation methods but not read', () => {
|
|
1278
1329
|
expectSchemaExists('slack-conversations-write');
|
|
1279
1330
|
expect(builtinRegistry
|
|
1280
1331
|
.get('slack-conversations-write')
|
|
1281
|
-
.match(
|
|
1332
|
+
.match(makeSlackRequest({ path: '/api/conversations.kick' }))).toBe(true);
|
|
1282
1333
|
expect(builtinRegistry
|
|
1283
1334
|
.get('slack-conversations-write')
|
|
1284
|
-
.match(
|
|
1335
|
+
.match(makeSlackRequest({ path: '/api/conversations.archive' }))).toBe(true);
|
|
1285
1336
|
expect(builtinRegistry
|
|
1286
1337
|
.get('slack-conversations-write')
|
|
1287
|
-
.match(
|
|
1338
|
+
.match(makeSlackRequest({ path: '/api/conversations.create' }))).toBe(true);
|
|
1288
1339
|
expect(builtinRegistry
|
|
1289
1340
|
.get('slack-conversations-write')
|
|
1290
|
-
.match(
|
|
1341
|
+
.match(makeSlackRequest({ path: '/api/conversations.acceptSharedInvite' }))).toBe(true);
|
|
1291
1342
|
expect(builtinRegistry
|
|
1292
1343
|
.get('slack-conversations-write')
|
|
1293
|
-
.match(
|
|
1344
|
+
.match(makeSlackRequest({ path: '/api/conversations.canvasCreate' }))).toBe(true);
|
|
1294
1345
|
expect(builtinRegistry
|
|
1295
1346
|
.get('slack-conversations-write')
|
|
1296
|
-
.match(
|
|
1347
|
+
.match(makeSlackRequest({ path: '/api/conversations.inviteShared' }))).toBe(true);
|
|
1297
1348
|
expect(builtinRegistry
|
|
1298
1349
|
.get('slack-conversations-write')
|
|
1299
|
-
.match(
|
|
1350
|
+
.match(makeSlackRequest({ path: '/api/conversations.externalInvitePermissions.set' }))).toBe(true);
|
|
1300
1351
|
expect(builtinRegistry
|
|
1301
1352
|
.get('slack-conversations-write')
|
|
1302
|
-
.match(
|
|
1353
|
+
.match(makeSlackRequest({ path: '/api/conversations.requestSharedInvite.approve' }))).toBe(true);
|
|
1303
1354
|
expect(builtinRegistry
|
|
1304
1355
|
.get('slack-conversations-write')
|
|
1305
|
-
.match(
|
|
1356
|
+
.match(makeSlackRequest({ path: '/api/conversations.requestSharedInvite.deny' }))).toBe(true);
|
|
1306
1357
|
expect(builtinRegistry
|
|
1307
1358
|
.get('slack-conversations-write')
|
|
1308
|
-
.match(
|
|
1359
|
+
.match(makeSlackRequest({ path: '/api/conversations.list' }))).toBe(false);
|
|
1309
1360
|
expect(builtinRegistry
|
|
1310
1361
|
.get('slack-conversations-write')
|
|
1311
|
-
.match(
|
|
1362
|
+
.match(makeSlackRequest({ path: '/api/conversations.history' }))).toBe(false);
|
|
1312
1363
|
});
|
|
1313
1364
|
it('slack-users-read matches read user methods but not write', () => {
|
|
1314
1365
|
expectSchemaExists('slack-users-read');
|
|
1315
|
-
expect(builtinRegistry.get('slack-users-read').match(
|
|
1316
|
-
expect(builtinRegistry.get('slack-users-read').match(
|
|
1366
|
+
expect(builtinRegistry.get('slack-users-read').match(makeSlackRequest({ path: '/api/users.list' }))).toBe(true);
|
|
1367
|
+
expect(builtinRegistry.get('slack-users-read').match(makeSlackRequest({ path: '/api/users.info' }))).toBe(true);
|
|
1317
1368
|
expect(builtinRegistry
|
|
1318
1369
|
.get('slack-users-read')
|
|
1319
|
-
.match(
|
|
1370
|
+
.match(makeSlackRequest({ path: '/api/users.profile.get' }))).toBe(true);
|
|
1320
1371
|
expect(builtinRegistry
|
|
1321
1372
|
.get('slack-users-read')
|
|
1322
|
-
.match(
|
|
1373
|
+
.match(makeSlackRequest({ path: '/api/users.setPresence' }))).toBe(false);
|
|
1323
1374
|
expect(builtinRegistry
|
|
1324
1375
|
.get('slack-users-read')
|
|
1325
|
-
.match(
|
|
1376
|
+
.match(makeSlackRequest({ path: '/api/users.profile.set' }))).toBe(false);
|
|
1326
1377
|
});
|
|
1327
1378
|
it('slack-users-write matches write user methods but not read', () => {
|
|
1328
1379
|
expectSchemaExists('slack-users-write');
|
|
1329
1380
|
expect(builtinRegistry
|
|
1330
1381
|
.get('slack-users-write')
|
|
1331
|
-
.match(
|
|
1382
|
+
.match(makeSlackRequest({ path: '/api/users.setPresence' }))).toBe(true);
|
|
1332
1383
|
expect(builtinRegistry
|
|
1333
1384
|
.get('slack-users-write')
|
|
1334
|
-
.match(
|
|
1335
|
-
expect(builtinRegistry.get('slack-users-write').match(
|
|
1385
|
+
.match(makeSlackRequest({ path: '/api/users.profile.set' }))).toBe(true);
|
|
1386
|
+
expect(builtinRegistry.get('slack-users-write').match(makeSlackRequest({ path: '/api/users.list' }))).toBe(false);
|
|
1336
1387
|
});
|
|
1337
1388
|
it('slack-files-read matches read file methods but not write', () => {
|
|
1338
1389
|
expectSchemaExists('slack-files-read');
|
|
1339
|
-
expect(builtinRegistry.get('slack-files-read').match(
|
|
1340
|
-
expect(builtinRegistry.get('slack-files-read').match(
|
|
1390
|
+
expect(builtinRegistry.get('slack-files-read').match(makeSlackRequest({ path: '/api/files.info' }))).toBe(true);
|
|
1391
|
+
expect(builtinRegistry.get('slack-files-read').match(makeSlackRequest({ path: '/api/files.list' }))).toBe(true);
|
|
1392
|
+
expect(builtinRegistry
|
|
1393
|
+
.get('slack-files-read')
|
|
1394
|
+
.match(makeSlackRequest({ path: '/api/files.remote.info' }))).toBe(true);
|
|
1341
1395
|
expect(builtinRegistry
|
|
1342
1396
|
.get('slack-files-read')
|
|
1343
|
-
.match(
|
|
1397
|
+
.match(makeSlackRequest({ path: '/api/files.getUploadURLExternal' }))).toBe(false);
|
|
1344
1398
|
expect(builtinRegistry
|
|
1345
1399
|
.get('slack-files-read')
|
|
1346
|
-
.match(
|
|
1347
|
-
|
|
1400
|
+
.match(makeSlackRequest({ path: '/api/files.delete' }))).toBe(false);
|
|
1401
|
+
});
|
|
1402
|
+
it('slack-files-read matches file content and thumbnail downloads on files.slack.com only', () => {
|
|
1403
|
+
expectSchemaExists('slack-files-read');
|
|
1404
|
+
const filesDomain = 'files.slack.com';
|
|
1405
|
+
expect(builtinRegistry
|
|
1406
|
+
.get('slack-files-read')
|
|
1407
|
+
.match(makeRequest({ domain: filesDomain, path: '/files-pri/TEAM123-FILE456/image.png' }))).toBe(true);
|
|
1408
|
+
expect(builtinRegistry.get('slack-files-read').match(makeRequest({
|
|
1409
|
+
domain: filesDomain,
|
|
1410
|
+
path: '/files-pri/TEAM123-FILE456/download/image.png',
|
|
1411
|
+
}))).toBe(true);
|
|
1412
|
+
expect(builtinRegistry.get('slack-files-read').match(makeRequest({
|
|
1413
|
+
domain: filesDomain,
|
|
1414
|
+
path: '/files-tmb/TEAM123-FILE456-abcdef1234/image_360.png',
|
|
1415
|
+
}))).toBe(true);
|
|
1416
|
+
expect(builtinRegistry
|
|
1417
|
+
.get('slack-files-read')
|
|
1418
|
+
.match(makeRequest({ domain: filesDomain, path: '/api/files.info' }))).toBe(false);
|
|
1348
1419
|
});
|
|
1349
1420
|
it('slack-files-write matches write file methods but not read', () => {
|
|
1350
1421
|
expectSchemaExists('slack-files-write');
|
|
1351
1422
|
expect(builtinRegistry
|
|
1352
1423
|
.get('slack-files-write')
|
|
1353
|
-
.match(
|
|
1424
|
+
.match(makeSlackRequest({ path: '/api/files.getUploadURLExternal' }))).toBe(true);
|
|
1354
1425
|
expect(builtinRegistry
|
|
1355
1426
|
.get('slack-files-write')
|
|
1356
|
-
.match(
|
|
1357
|
-
expect(builtinRegistry.get('slack-files-write').match(makeRequest({ path: '/api/files.delete' }))).toBe(true);
|
|
1427
|
+
.match(makeSlackRequest({ path: '/api/files.completeUploadExternal' }))).toBe(true);
|
|
1358
1428
|
expect(builtinRegistry
|
|
1359
1429
|
.get('slack-files-write')
|
|
1360
|
-
.match(
|
|
1361
|
-
expect(builtinRegistry
|
|
1362
|
-
|
|
1430
|
+
.match(makeSlackRequest({ path: '/api/files.delete' }))).toBe(true);
|
|
1431
|
+
expect(builtinRegistry
|
|
1432
|
+
.get('slack-files-write')
|
|
1433
|
+
.match(makeSlackRequest({ path: '/api/files.remote.remove' }))).toBe(true);
|
|
1434
|
+
expect(builtinRegistry.get('slack-files-write').match(makeSlackRequest({ path: '/api/files.info' }))).toBe(false);
|
|
1435
|
+
expect(builtinRegistry.get('slack-files-write').match(makeSlackRequest({ path: '/api/files.list' }))).toBe(false);
|
|
1363
1436
|
});
|
|
1364
1437
|
it('slack-reactions-read matches read reaction methods but not write', () => {
|
|
1365
1438
|
expectSchemaExists('slack-reactions-read');
|
|
1366
1439
|
expect(builtinRegistry
|
|
1367
1440
|
.get('slack-reactions-read')
|
|
1368
|
-
.match(
|
|
1441
|
+
.match(makeSlackRequest({ path: '/api/reactions.get' }))).toBe(true);
|
|
1369
1442
|
expect(builtinRegistry
|
|
1370
1443
|
.get('slack-reactions-read')
|
|
1371
|
-
.match(
|
|
1444
|
+
.match(makeSlackRequest({ path: '/api/reactions.list' }))).toBe(true);
|
|
1372
1445
|
expect(builtinRegistry
|
|
1373
1446
|
.get('slack-reactions-read')
|
|
1374
|
-
.match(
|
|
1447
|
+
.match(makeSlackRequest({ path: '/api/reactions.add' }))).toBe(false);
|
|
1375
1448
|
});
|
|
1376
1449
|
it('slack-reactions-write matches write reaction methods but not read', () => {
|
|
1377
1450
|
expectSchemaExists('slack-reactions-write');
|
|
1378
1451
|
expect(builtinRegistry
|
|
1379
1452
|
.get('slack-reactions-write')
|
|
1380
|
-
.match(
|
|
1453
|
+
.match(makeSlackRequest({ path: '/api/reactions.add' }))).toBe(true);
|
|
1381
1454
|
expect(builtinRegistry
|
|
1382
1455
|
.get('slack-reactions-write')
|
|
1383
|
-
.match(
|
|
1456
|
+
.match(makeSlackRequest({ path: '/api/reactions.remove' }))).toBe(true);
|
|
1384
1457
|
expect(builtinRegistry
|
|
1385
1458
|
.get('slack-reactions-write')
|
|
1386
|
-
.match(
|
|
1459
|
+
.match(makeSlackRequest({ path: '/api/reactions.get' }))).toBe(false);
|
|
1387
1460
|
});
|
|
1388
1461
|
it('slack-search matches search methods', () => {
|
|
1389
1462
|
expectSchemaExists('slack-search');
|
|
1390
|
-
expect(builtinRegistry.get('slack-search').match(
|
|
1391
|
-
expect(builtinRegistry.get('slack-search').match(
|
|
1392
|
-
expect(builtinRegistry.get('slack-search').match(
|
|
1463
|
+
expect(builtinRegistry.get('slack-search').match(makeSlackRequest({ path: '/api/search.messages' }))).toBe(true);
|
|
1464
|
+
expect(builtinRegistry.get('slack-search').match(makeSlackRequest({ path: '/api/search.files' }))).toBe(true);
|
|
1465
|
+
expect(builtinRegistry.get('slack-search').match(makeSlackRequest({ path: '/api/search.all' }))).toBe(true);
|
|
1393
1466
|
expect(builtinRegistry
|
|
1394
1467
|
.get('slack-search')
|
|
1395
|
-
.match(
|
|
1396
|
-
expect(builtinRegistry
|
|
1468
|
+
.match(makeSlackRequest({ path: '/api/search.modules.messages' }))).toBe(true);
|
|
1469
|
+
expect(builtinRegistry
|
|
1470
|
+
.get('slack-search')
|
|
1471
|
+
.match(makeSlackRequest({ path: '/api/chat.postMessage' }))).toBe(false);
|
|
1397
1472
|
});
|
|
1398
1473
|
it('slack-pins-read matches pins.list but not pins.add', () => {
|
|
1399
1474
|
expectSchemaExists('slack-pins-read');
|
|
1400
|
-
expect(builtinRegistry.get('slack-pins-read').match(
|
|
1401
|
-
expect(builtinRegistry.get('slack-pins-read').match(
|
|
1475
|
+
expect(builtinRegistry.get('slack-pins-read').match(makeSlackRequest({ path: '/api/pins.list' }))).toBe(true);
|
|
1476
|
+
expect(builtinRegistry.get('slack-pins-read').match(makeSlackRequest({ path: '/api/pins.add' }))).toBe(false);
|
|
1402
1477
|
});
|
|
1403
1478
|
it('slack-pins-write matches pins.add and pins.remove but not pins.list', () => {
|
|
1404
1479
|
expectSchemaExists('slack-pins-write');
|
|
1405
|
-
expect(builtinRegistry.get('slack-pins-write').match(
|
|
1406
|
-
expect(builtinRegistry.get('slack-pins-write').match(
|
|
1407
|
-
expect(builtinRegistry.get('slack-pins-write').match(
|
|
1480
|
+
expect(builtinRegistry.get('slack-pins-write').match(makeSlackRequest({ path: '/api/pins.add' }))).toBe(true);
|
|
1481
|
+
expect(builtinRegistry.get('slack-pins-write').match(makeSlackRequest({ path: '/api/pins.remove' }))).toBe(true);
|
|
1482
|
+
expect(builtinRegistry.get('slack-pins-write').match(makeSlackRequest({ path: '/api/pins.list' }))).toBe(false);
|
|
1408
1483
|
});
|
|
1409
1484
|
it('slack-bookmarks-read matches bookmarks.list but not bookmarks.add', () => {
|
|
1410
1485
|
expectSchemaExists('slack-bookmarks-read');
|
|
1411
1486
|
expect(builtinRegistry
|
|
1412
1487
|
.get('slack-bookmarks-read')
|
|
1413
|
-
.match(
|
|
1488
|
+
.match(makeSlackRequest({ path: '/api/bookmarks.list' }))).toBe(true);
|
|
1414
1489
|
expect(builtinRegistry
|
|
1415
1490
|
.get('slack-bookmarks-read')
|
|
1416
|
-
.match(
|
|
1491
|
+
.match(makeSlackRequest({ path: '/api/bookmarks.add' }))).toBe(false);
|
|
1417
1492
|
});
|
|
1418
1493
|
it('slack-bookmarks-write matches bookmarks.add and bookmarks.edit but not bookmarks.list', () => {
|
|
1419
1494
|
expectSchemaExists('slack-bookmarks-write');
|
|
1420
1495
|
expect(builtinRegistry
|
|
1421
1496
|
.get('slack-bookmarks-write')
|
|
1422
|
-
.match(
|
|
1497
|
+
.match(makeSlackRequest({ path: '/api/bookmarks.add' }))).toBe(true);
|
|
1423
1498
|
expect(builtinRegistry
|
|
1424
1499
|
.get('slack-bookmarks-write')
|
|
1425
|
-
.match(
|
|
1500
|
+
.match(makeSlackRequest({ path: '/api/bookmarks.edit' }))).toBe(true);
|
|
1426
1501
|
expect(builtinRegistry
|
|
1427
1502
|
.get('slack-bookmarks-write')
|
|
1428
|
-
.match(
|
|
1503
|
+
.match(makeSlackRequest({ path: '/api/bookmarks.list' }))).toBe(false);
|
|
1429
1504
|
});
|
|
1430
1505
|
it('slack-reminders-read matches reminders.info and reminders.list but not reminders.add', () => {
|
|
1431
1506
|
expectSchemaExists('slack-reminders-read');
|
|
1432
1507
|
expect(builtinRegistry
|
|
1433
1508
|
.get('slack-reminders-read')
|
|
1434
|
-
.match(
|
|
1509
|
+
.match(makeSlackRequest({ path: '/api/reminders.info' }))).toBe(true);
|
|
1435
1510
|
expect(builtinRegistry
|
|
1436
1511
|
.get('slack-reminders-read')
|
|
1437
|
-
.match(
|
|
1512
|
+
.match(makeSlackRequest({ path: '/api/reminders.list' }))).toBe(true);
|
|
1438
1513
|
expect(builtinRegistry
|
|
1439
1514
|
.get('slack-reminders-read')
|
|
1440
|
-
.match(
|
|
1515
|
+
.match(makeSlackRequest({ path: '/api/reminders.add' }))).toBe(false);
|
|
1441
1516
|
});
|
|
1442
1517
|
it('slack-reminders-write matches reminders.add and reminders.delete but not reminders.list', () => {
|
|
1443
1518
|
expectSchemaExists('slack-reminders-write');
|
|
1444
1519
|
expect(builtinRegistry
|
|
1445
1520
|
.get('slack-reminders-write')
|
|
1446
|
-
.match(
|
|
1521
|
+
.match(makeSlackRequest({ path: '/api/reminders.add' }))).toBe(true);
|
|
1447
1522
|
expect(builtinRegistry
|
|
1448
1523
|
.get('slack-reminders-write')
|
|
1449
|
-
.match(
|
|
1524
|
+
.match(makeSlackRequest({ path: '/api/reminders.delete' }))).toBe(true);
|
|
1450
1525
|
expect(builtinRegistry
|
|
1451
1526
|
.get('slack-reminders-write')
|
|
1452
|
-
.match(
|
|
1527
|
+
.match(makeSlackRequest({ path: '/api/reminders.list' }))).toBe(false);
|
|
1453
1528
|
});
|
|
1454
1529
|
});
|
|
1455
1530
|
describe('builtin schemas: stripe', () => {
|
|
@@ -2048,4 +2123,166 @@ describe('builtin schemas: tailscale', () => {
|
|
|
2048
2123
|
}))).toBe(false);
|
|
2049
2124
|
});
|
|
2050
2125
|
});
|
|
2126
|
+
describe('builtin schemas: fastmail', () => {
|
|
2127
|
+
/** A JMAP method-call envelope: `POST /jmap/api/` carrying the named calls. */
|
|
2128
|
+
function jmapRequest(methodNames, domain = 'phl.api.fastmail.com') {
|
|
2129
|
+
return makeRequest({
|
|
2130
|
+
domain,
|
|
2131
|
+
method: 'POST',
|
|
2132
|
+
path: '/jmap/api/',
|
|
2133
|
+
parsedBody: {
|
|
2134
|
+
using: ['urn:ietf:params:jmap:core', 'urn:ietf:params:jmap:mail'],
|
|
2135
|
+
methodCalls: methodNames.map((name, index) => [name, {}, String(index)]),
|
|
2136
|
+
},
|
|
2137
|
+
});
|
|
2138
|
+
}
|
|
2139
|
+
it('fastmail-api matches the API host, its regional shards, and the blob host', () => {
|
|
2140
|
+
expectSchemaExists('fastmail-api');
|
|
2141
|
+
const api = builtinRegistry.get('fastmail-api');
|
|
2142
|
+
for (const domain of [
|
|
2143
|
+
'api.fastmail.com',
|
|
2144
|
+
'phl.api.fastmail.com',
|
|
2145
|
+
'www.fastmailusercontent.com',
|
|
2146
|
+
'phl-www.fastmailusercontent.com',
|
|
2147
|
+
]) {
|
|
2148
|
+
expect(api.match(makeRequest({ domain })), `expected fastmail-api to match ${domain}`).toBe(true);
|
|
2149
|
+
}
|
|
2150
|
+
});
|
|
2151
|
+
it('fastmail-api rejects lookalike and DAV domains', () => {
|
|
2152
|
+
const api = builtinRegistry.get('fastmail-api');
|
|
2153
|
+
// The DAV hosts take a different credential and have their own schemas.
|
|
2154
|
+
expect(api.match(makeRequest({ domain: 'carddav.fastmail.com' }))).toBe(false);
|
|
2155
|
+
expect(api.match(makeRequest({ domain: 'api.fastmail.com.evil.test' }))).toBe(false);
|
|
2156
|
+
expect(api.match(makeRequest({ domain: 'fastmailusercontent.com.evil.test' }))).toBe(false);
|
|
2157
|
+
});
|
|
2158
|
+
it('fastmail-read-all matches read-only method calls, the session document and downloads', () => {
|
|
2159
|
+
expectSchemaExists('fastmail-read-all');
|
|
2160
|
+
const read = builtinRegistry.get('fastmail-read-all');
|
|
2161
|
+
expect(read.match(jmapRequest(['Email/get', 'Mailbox/changes', 'Thread/get']))).toBe(true);
|
|
2162
|
+
expect(read.match(jmapRequest(['Email/query', 'Email/queryChanges']))).toBe(true);
|
|
2163
|
+
expect(read.match(makeRequest({ domain: 'api.fastmail.com', method: 'GET', path: '/jmap/session' }))).toBe(true);
|
|
2164
|
+
expect(read.match(makeRequest({
|
|
2165
|
+
domain: 'phl-www.fastmailusercontent.com',
|
|
2166
|
+
method: 'GET',
|
|
2167
|
+
path: '/jmap/download/u1/G1/message.eml',
|
|
2168
|
+
}))).toBe(true);
|
|
2169
|
+
});
|
|
2170
|
+
it('fastmail-read-all rejects a batch where any single call writes', () => {
|
|
2171
|
+
// JMAP batches many calls into one request, so a read-only grant is only
|
|
2172
|
+
// meaningful if one write anywhere in the envelope disqualifies the whole
|
|
2173
|
+
// request.
|
|
2174
|
+
const read = builtinRegistry.get('fastmail-read-all');
|
|
2175
|
+
expect(read.match(jmapRequest(['Email/set']))).toBe(false);
|
|
2176
|
+
expect(read.match(jmapRequest(['Email/get', 'Email/set']))).toBe(false);
|
|
2177
|
+
expect(read.match(jmapRequest(['Email/get', 'Mailbox/get', 'EmailSubmission/set']))).toBe(false);
|
|
2178
|
+
});
|
|
2179
|
+
it('fastmail-write-all matches writes and blob uploads', () => {
|
|
2180
|
+
expectSchemaExists('fastmail-write-all');
|
|
2181
|
+
const write = builtinRegistry.get('fastmail-write-all');
|
|
2182
|
+
expect(write.match(jmapRequest(['Email/set', 'Mailbox/set']))).toBe(true);
|
|
2183
|
+
expect(write.match(jmapRequest(['Email/import']))).toBe(true);
|
|
2184
|
+
expect(write.match(makeRequest({ domain: 'phl.api.fastmail.com', method: 'POST', path: '/jmap/upload/u1/' }))).toBe(true);
|
|
2185
|
+
expect(write.match(jmapRequest(['Email/get']))).toBe(false);
|
|
2186
|
+
});
|
|
2187
|
+
it('per-capability schemas keep mail, contacts and calendars apart', () => {
|
|
2188
|
+
for (const name of [
|
|
2189
|
+
'fastmail-read-mail',
|
|
2190
|
+
'fastmail-read-contacts',
|
|
2191
|
+
'fastmail-read-calendars',
|
|
2192
|
+
]) {
|
|
2193
|
+
expectSchemaExists(name);
|
|
2194
|
+
}
|
|
2195
|
+
const mail = builtinRegistry.get('fastmail-read-mail');
|
|
2196
|
+
const contacts = builtinRegistry.get('fastmail-read-contacts');
|
|
2197
|
+
const calendars = builtinRegistry.get('fastmail-read-calendars');
|
|
2198
|
+
expect(mail.match(jmapRequest(['Email/get', 'Mailbox/get']))).toBe(true);
|
|
2199
|
+
expect(mail.match(jmapRequest(['ContactCard/get']))).toBe(false);
|
|
2200
|
+
expect(mail.match(jmapRequest(['CalendarEvent/get']))).toBe(false);
|
|
2201
|
+
expect(contacts.match(jmapRequest(['AddressBook/get', 'ContactCard/query']))).toBe(true);
|
|
2202
|
+
expect(contacts.match(jmapRequest(['Email/get']))).toBe(false);
|
|
2203
|
+
expect(contacts.match(jmapRequest(['ContactCard/set']))).toBe(false);
|
|
2204
|
+
expect(calendars.match(jmapRequest(['Calendar/get', 'CalendarEvent/query']))).toBe(true);
|
|
2205
|
+
expect(calendars.match(jmapRequest(['Email/get']))).toBe(false);
|
|
2206
|
+
});
|
|
2207
|
+
it('fastmail-send-mail is separate from fastmail-write-mail', () => {
|
|
2208
|
+
expectSchemaExists('fastmail-send-mail');
|
|
2209
|
+
const send = builtinRegistry.get('fastmail-send-mail');
|
|
2210
|
+
const writeMail = builtinRegistry.get('fastmail-write-mail');
|
|
2211
|
+
// Sending is externally visible and irreversible, so mailbox writes must not
|
|
2212
|
+
// carry it along.
|
|
2213
|
+
expect(send.match(jmapRequest(['EmailSubmission/set']))).toBe(true);
|
|
2214
|
+
expect(writeMail.match(jmapRequest(['EmailSubmission/set']))).toBe(false);
|
|
2215
|
+
expect(writeMail.match(jmapRequest(['Email/set', 'Mailbox/set']))).toBe(true);
|
|
2216
|
+
});
|
|
2217
|
+
it('fastmail-session covers discovery without exposing content', () => {
|
|
2218
|
+
expectSchemaExists('fastmail-session');
|
|
2219
|
+
const session = builtinRegistry.get('fastmail-session');
|
|
2220
|
+
expect(session.match(makeRequest({ domain: 'api.fastmail.com', method: 'GET', path: '/jmap/session' }))).toBe(true);
|
|
2221
|
+
expect(session.match(makeRequest({ domain: 'api.fastmail.com', method: 'GET', path: '/.well-known/jmap' }))).toBe(true);
|
|
2222
|
+
expect(session.match(jmapRequest(['Email/get']))).toBe(false);
|
|
2223
|
+
});
|
|
2224
|
+
});
|
|
2225
|
+
describe('builtin schemas: fastmail (DAV scope)', () => {
|
|
2226
|
+
it('fastmail-dav-api matches the CardDAV and CalDAV hosts only', () => {
|
|
2227
|
+
expectSchemaExists('fastmail-dav-api');
|
|
2228
|
+
const api = builtinRegistry.get('fastmail-dav-api');
|
|
2229
|
+
for (const domain of ['carddav.fastmail.com', 'caldav.fastmail.com']) {
|
|
2230
|
+
expect(api.match(makeRequest({ domain })), `expected match for ${domain}`).toBe(true);
|
|
2231
|
+
}
|
|
2232
|
+
// The JMAP hosts take a different credential entirely.
|
|
2233
|
+
expect(api.match(makeRequest({ domain: 'api.fastmail.com' }))).toBe(false);
|
|
2234
|
+
expect(api.match(makeRequest({ domain: 'carddav.fastmail.com.evil.test' }))).toBe(false);
|
|
2235
|
+
});
|
|
2236
|
+
it('fastmail-dav read and write split on the DAV method verbs', () => {
|
|
2237
|
+
expectSchemaExists('fastmail-dav-read-all');
|
|
2238
|
+
expectSchemaExists('fastmail-dav-write-all');
|
|
2239
|
+
const read = builtinRegistry.get('fastmail-dav-read-all');
|
|
2240
|
+
const write = builtinRegistry.get('fastmail-dav-write-all');
|
|
2241
|
+
const dav = {
|
|
2242
|
+
domain: 'carddav.fastmail.com',
|
|
2243
|
+
path: '/dav/addressbooks/user/a@b.test/Default/',
|
|
2244
|
+
};
|
|
2245
|
+
for (const method of ['GET', 'PROPFIND', 'REPORT', 'OPTIONS', 'HEAD']) {
|
|
2246
|
+
expect(read.match(makeRequest({ ...dav, method })), `read should match ${method}`).toBe(true);
|
|
2247
|
+
expect(write.match(makeRequest({ ...dav, method })), `write should not match ${method}`).toBe(false);
|
|
2248
|
+
}
|
|
2249
|
+
for (const method of ['PUT', 'DELETE', 'PROPPATCH', 'MKCOL', 'MOVE']) {
|
|
2250
|
+
expect(write.match(makeRequest({ ...dav, method })), `write should match ${method}`).toBe(true);
|
|
2251
|
+
expect(read.match(makeRequest({ ...dav, method })), `read should not match ${method}`).toBe(false);
|
|
2252
|
+
}
|
|
2253
|
+
});
|
|
2254
|
+
it('fastmail-dav per-capability schemas split on collection path', () => {
|
|
2255
|
+
const contacts = builtinRegistry.get('fastmail-dav-read-contacts');
|
|
2256
|
+
const calendars = builtinRegistry.get('fastmail-dav-read-calendars');
|
|
2257
|
+
expect(contacts.match(makeRequest({
|
|
2258
|
+
domain: 'carddav.fastmail.com',
|
|
2259
|
+
method: 'PROPFIND',
|
|
2260
|
+
path: '/dav/addressbooks/user/a@b.test/Default/',
|
|
2261
|
+
}))).toBe(true);
|
|
2262
|
+
expect(contacts.match(makeRequest({
|
|
2263
|
+
domain: 'caldav.fastmail.com',
|
|
2264
|
+
method: 'PROPFIND',
|
|
2265
|
+
path: '/dav/calendars/user/a@b.test/Default/',
|
|
2266
|
+
}))).toBe(false);
|
|
2267
|
+
expect(calendars.match(makeRequest({
|
|
2268
|
+
domain: 'caldav.fastmail.com',
|
|
2269
|
+
method: 'PROPFIND',
|
|
2270
|
+
path: '/dav/calendars/user/a@b.test/Default/',
|
|
2271
|
+
}))).toBe(true);
|
|
2272
|
+
});
|
|
2273
|
+
it('fastmail-dav-discover covers the principal lookup a client must make first', () => {
|
|
2274
|
+
expectSchemaExists('fastmail-dav-discover');
|
|
2275
|
+
const discover = builtinRegistry.get('fastmail-dav-discover');
|
|
2276
|
+
expect(discover.match(makeRequest({
|
|
2277
|
+
domain: 'carddav.fastmail.com',
|
|
2278
|
+
method: 'PROPFIND',
|
|
2279
|
+
path: '/dav/principals/',
|
|
2280
|
+
}))).toBe(true);
|
|
2281
|
+
expect(discover.match(makeRequest({
|
|
2282
|
+
domain: 'carddav.fastmail.com',
|
|
2283
|
+
method: 'PROPFIND',
|
|
2284
|
+
path: '/dav/addressbooks/user/a@b.test/',
|
|
2285
|
+
}))).toBe(false);
|
|
2286
|
+
});
|
|
2287
|
+
});
|
|
2051
2288
|
//# sourceMappingURL=builtinSchemas.test.js.map
|