@remit/backend 0.0.142 → 0.0.144
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/dev-server/content-handler.d.ts +38 -0
- package/dist/dev-server/content-handler.js +46 -0
- package/dist/src/api.d.ts +7 -0
- package/dist/src/api.js +144 -0
- package/dist/src/auth.d.ts +30 -0
- package/dist/src/auth.js +73 -0
- package/dist/src/config/msoauth.d.ts +30 -0
- package/dist/src/config/msoauth.js +30 -0
- package/{src/data-backend.ts → dist/src/data-backend.d.ts} +2 -4
- package/dist/src/data-backend.js +12 -0
- package/{src/derive/autoMoved.ts → dist/src/derive/autoMoved.d.ts} +1 -29
- package/dist/src/derive/autoMoved.js +49 -0
- package/dist/src/derive/contentSignature.d.ts +41 -0
- package/{src/derive/contentSignature.ts → dist/src/derive/contentSignature.js} +27 -72
- package/dist/src/derive/contentUrl.d.ts +46 -0
- package/dist/src/derive/contentUrl.js +46 -0
- package/{src/derive/deriveMuted.ts → dist/src/derive/deriveMuted.d.ts} +1 -3
- package/dist/src/derive/deriveMuted.js +7 -0
- package/dist/src/derive/enrichThreadRows.d.ts +118 -0
- package/dist/src/derive/enrichThreadRows.js +151 -0
- package/dist/src/derive/filterThreadCriteria.d.ts +23 -0
- package/dist/src/derive/filterThreadCriteria.js +24 -0
- package/{src/derive/pendingMoveCounts.ts → dist/src/derive/pendingMoveCounts.d.ts} +5 -53
- package/dist/src/derive/pendingMoveCounts.js +53 -0
- package/{src/derive/senderTrust.ts → dist/src/derive/senderTrust.d.ts} +1 -9
- package/dist/src/derive/senderTrust.js +19 -0
- package/dist/src/error.d.ts +21 -0
- package/dist/src/error.js +85 -0
- package/dist/src/handlers/account-guards.d.ts +36 -0
- package/dist/src/handlers/account-guards.js +107 -0
- package/dist/src/handlers/account-oauth.d.ts +14 -0
- package/dist/src/handlers/account-oauth.js +387 -0
- package/dist/src/handlers/account-overrides.d.ts +53 -0
- package/dist/src/handlers/account-overrides.js +233 -0
- package/dist/src/handlers/account-signature.d.ts +28 -0
- package/dist/src/handlers/account-signature.js +85 -0
- package/dist/src/handlers/account.d.ts +6 -0
- package/dist/src/handlers/account.js +350 -0
- package/dist/src/handlers/address.d.ts +35 -0
- package/dist/src/handlers/address.js +141 -0
- package/dist/src/handlers/calendar-event.d.ts +70 -0
- package/dist/src/handlers/calendar-event.js +425 -0
- package/dist/src/handlers/calendar-feed.d.ts +47 -0
- package/dist/src/handlers/calendar-feed.js +192 -0
- package/dist/src/handlers/calendar-suggestion.d.ts +47 -0
- package/dist/src/handlers/calendar-suggestion.js +212 -0
- package/dist/src/handlers/calendar.d.ts +116 -0
- package/dist/src/handlers/calendar.js +330 -0
- package/dist/src/handlers/config.d.ts +43 -0
- package/dist/src/handlers/config.js +176 -0
- package/dist/src/handlers/ensure-account-config.d.ts +9 -0
- package/dist/src/handlers/ensure-account-config.js +27 -0
- package/dist/src/handlers/filter.d.ts +3 -0
- package/dist/src/handlers/filter.js +103 -0
- package/dist/src/handlers/folder-role-appointments.d.ts +68 -0
- package/dist/src/handlers/folder-role-appointments.js +168 -0
- package/dist/src/handlers/folder-role-labels.d.ts +26 -0
- package/dist/src/handlers/folder-role-labels.js +40 -0
- package/dist/src/handlers/folder-role.d.ts +9 -0
- package/dist/src/handlers/folder-role.js +40 -0
- package/dist/src/handlers/index.d.ts +2 -0
- package/dist/src/handlers/index.js +60 -0
- package/dist/src/handlers/label.d.ts +43 -0
- package/dist/src/handlers/label.js +114 -0
- package/dist/src/handlers/mailbox-bindings.d.ts +41 -0
- package/dist/src/handlers/mailbox-bindings.js +61 -0
- package/dist/src/handlers/mailbox.d.ts +23 -0
- package/dist/src/handlers/mailbox.js +219 -0
- package/dist/src/handlers/me.d.ts +2 -0
- package/dist/src/handlers/me.js +138 -0
- package/dist/src/handlers/message.d.ts +84 -0
- package/dist/src/handlers/message.js +607 -0
- package/dist/src/handlers/organize.d.ts +10 -0
- package/dist/src/handlers/organize.js +112 -0
- package/dist/src/handlers/outbox-attachment.d.ts +23 -0
- package/dist/src/handlers/outbox-attachment.js +81 -0
- package/dist/src/handlers/outbox.d.ts +4 -0
- package/dist/src/handlers/outbox.js +144 -0
- package/dist/src/handlers/sync-progress.d.ts +46 -0
- package/dist/src/handlers/sync-progress.js +63 -0
- package/dist/src/handlers/sync.d.ts +28 -0
- package/dist/src/handlers/sync.js +82 -0
- package/dist/src/handlers/system-update.d.ts +2 -0
- package/dist/src/handlers/system-update.js +172 -0
- package/dist/src/handlers/thread.d.ts +148 -0
- package/dist/src/handlers/thread.js +233 -0
- package/dist/src/handlers/unified-threads.d.ts +247 -0
- package/dist/src/handlers/unified-threads.js +409 -0
- package/{src/handlers/vip-suggestions.ts → dist/src/handlers/vip-suggestions.d.ts} +1 -13
- package/dist/src/handlers/vip-suggestions.js +16 -0
- package/dist/src/index.d.ts +2 -0
- package/dist/src/index.js +37 -0
- package/{src/json.ts → dist/src/json.d.ts} +1 -4
- package/dist/src/json.js +10 -0
- package/dist/src/jwt-auth.d.ts +18 -0
- package/dist/src/jwt-auth.js +97 -0
- package/dist/src/request-context.d.ts +9 -0
- package/dist/src/request-context.js +22 -0
- package/dist/src/request.d.ts +3 -0
- package/dist/src/request.js +7 -0
- package/dist/src/response.d.ts +27 -0
- package/dist/src/response.js +87 -0
- package/dist/src/service/account-deletion.d.ts +22 -0
- package/dist/src/service/account-deletion.js +39 -0
- package/dist/src/service/compose-sqlite.d.ts +2 -0
- package/dist/src/service/compose-sqlite.js +11 -0
- package/dist/src/service/create-remit-client.d.ts +95 -0
- package/dist/src/service/create-remit-client.js +207 -0
- package/dist/src/service/data-client.d.ts +12 -0
- package/dist/src/service/data-client.js +44 -0
- package/dist/src/service/export-identity.d.ts +3 -0
- package/dist/src/service/export-identity.js +35 -0
- package/dist/src/service/fire-and-forget.d.ts +54 -0
- package/dist/src/service/fire-and-forget.js +38 -0
- package/dist/src/service/organize.d.ts +184 -0
- package/dist/src/service/organize.js +384 -0
- package/dist/src/service/refusal.d.ts +4 -0
- package/dist/src/service/refusal.js +20 -0
- package/dist/src/service/sender-category.d.ts +51 -0
- package/{src/service/sender-category.ts → dist/src/service/sender-category.js} +40 -81
- package/dist/src/service/sqs.d.ts +1 -0
- package/{src/service/sqs.ts → dist/src/service/sqs.js} +0 -1
- package/dist/src/service/trigger-sync.d.ts +51 -0
- package/dist/src/service/trigger-sync.js +39 -0
- package/dist/src/types.d.ts +49 -0
- package/dist/src/types.js +1 -0
- package/package.json +113 -98
- package/.env.test +0 -4
- package/dev-server/content-auth.test.ts +0 -113
- package/dev-server/content-auth.ts +0 -54
- package/dev-server/content-handler.test.ts +0 -105
- package/dev-server/content-handler.ts +0 -79
- package/dev-server/content-path.test.ts +0 -37
- package/dev-server/content-path.ts +0 -27
- package/dev-server/cors.test.ts +0 -48
- package/dev-server/cors.ts +0 -25
- package/dev-server/keep-alive.test.ts +0 -24
- package/dev-server/lambda-helpers.ts +0 -69
- package/dev-server/log-output.test.ts +0 -173
- package/dev-server/oauth-callback-route.test.ts +0 -66
- package/dev-server/relational-health.test.ts +0 -83
- package/dev-server/relational-health.ts +0 -39
- package/dev-server/server.ts +0 -384
- package/dev-server/sync-age.test.ts +0 -91
- package/dev-server/sync-age.ts +0 -55
- package/dev-server/upload-handler.ts +0 -132
- package/dev-server/upload-route.test.ts +0 -196
- package/scripts/backfill-classification.ts +0 -91
- package/scripts/backfill-list-id.ts +0 -83
- package/scripts/config-save.ts +0 -128
- package/src/auth.test.ts +0 -12
- package/src/auth.ts +0 -92
- package/src/config/msoauth.test.ts +0 -48
- package/src/config/msoauth.ts +0 -48
- package/src/data-backend.test.ts +0 -23
- package/src/derive/autoMoved.test.ts +0 -104
- package/src/derive/contentSignature.test.ts +0 -161
- package/src/derive/contentUrl.test.ts +0 -172
- package/src/derive/contentUrl.ts +0 -86
- package/src/derive/deriveMuted.test.ts +0 -34
- package/src/derive/enrichThreadRows.test.ts +0 -360
- package/src/derive/enrichThreadRows.ts +0 -234
- package/src/derive/filterThreadCriteria.test.ts +0 -126
- package/src/derive/filterThreadCriteria.ts +0 -51
- package/src/derive/senderTrust.test.ts +0 -67
- package/src/error.test.ts +0 -201
- package/src/error.ts +0 -123
- package/src/handlers/account-guards.test.ts +0 -67
- package/src/handlers/account-guards.ts +0 -169
- package/src/handlers/account-oauth-callback.test.ts +0 -155
- package/src/handlers/account-oauth-consent.test.ts +0 -336
- package/src/handlers/account-oauth-start.test.ts +0 -191
- package/src/handlers/account-oauth.test.ts +0 -439
- package/src/handlers/account-oauth.ts +0 -635
- package/src/handlers/account-overrides.test.ts +0 -88
- package/src/handlers/account-overrides.ts +0 -323
- package/src/handlers/account-ownership.ts +0 -25
- package/src/handlers/account-signature.ts +0 -117
- package/src/handlers/account-synced-services.test.ts +0 -245
- package/src/handlers/account.ts +0 -552
- package/src/handlers/address.test.ts +0 -381
- package/src/handlers/address.ts +0 -200
- package/src/handlers/calendar-event.test.ts +0 -685
- package/src/handlers/calendar-event.ts +0 -738
- package/src/handlers/calendar-feed-validators.test.ts +0 -228
- package/src/handlers/calendar-feed.test.ts +0 -439
- package/src/handlers/calendar-feed.ts +0 -291
- package/src/handlers/calendar-sqlite-fixture.ts +0 -36
- package/src/handlers/calendar-suggestion.test.ts +0 -1269
- package/src/handlers/calendar-suggestion.ts +0 -425
- package/src/handlers/calendar.test.ts +0 -1080
- package/src/handlers/calendar.ts +0 -517
- package/src/handlers/config.test.ts +0 -245
- package/src/handlers/config.ts +0 -332
- package/src/handlers/ensure-account-config.ts +0 -30
- package/src/handlers/filter.test.ts +0 -644
- package/src/handlers/filter.ts +0 -518
- package/src/handlers/folder-role-appointments.test.ts +0 -438
- package/src/handlers/folder-role-appointments.ts +0 -249
- package/src/handlers/folder-role-labels.ts +0 -63
- package/src/handlers/folder-role.test.ts +0 -209
- package/src/handlers/folder-role.ts +0 -80
- package/src/handlers/index.ts +0 -83
- package/src/handlers/label.test.ts +0 -112
- package/src/handlers/label.ts +0 -210
- package/src/handlers/mailbox-bindings.ts +0 -111
- package/src/handlers/mailbox-rename-refusal.test.ts +0 -247
- package/src/handlers/mailbox-settled-target.test.ts +0 -251
- package/src/handlers/mailbox.test.ts +0 -280
- package/src/handlers/mailbox.ts +0 -581
- package/src/handlers/me.test.ts +0 -81
- package/src/handlers/me.ts +0 -203
- package/src/handlers/message-read-backfill.test.ts +0 -103
- package/src/handlers/message.test.ts +0 -131
- package/src/handlers/message.ts +0 -1131
- package/src/handlers/organize.test.ts +0 -277
- package/src/handlers/organize.ts +0 -197
- package/src/handlers/outbox-attachment.test.ts +0 -765
- package/src/handlers/outbox-attachment.ts +0 -126
- package/src/handlers/outbox-list.test.ts +0 -179
- package/src/handlers/outbox.test.ts +0 -772
- package/src/handlers/outbox.ts +0 -258
- package/src/handlers/search.test.ts +0 -161
- package/src/handlers/search.ts +0 -105
- package/src/handlers/sync-progress.test.ts +0 -205
- package/src/handlers/sync-progress.ts +0 -99
- package/src/handlers/sync.test.ts +0 -168
- package/src/handlers/sync.ts +0 -118
- package/src/handlers/system-update.test.ts +0 -497
- package/src/handlers/system-update.ts +0 -230
- package/src/handlers/thread.test.ts +0 -396
- package/src/handlers/thread.ts +0 -427
- package/src/handlers/unified-threads-mail-sources.sqlite.test.ts +0 -197
- package/src/handlers/unified-threads.test.ts +0 -785
- package/src/handlers/unified-threads.ts +0 -669
- package/src/index.test.ts +0 -83
- package/src/index.ts +0 -228
- package/src/jwt-auth.test.ts +0 -152
- package/src/jwt-auth.ts +0 -132
- package/src/log-redaction.test.ts +0 -144
- package/src/openapi-spec.test.ts +0 -118
- package/src/request-context.test.ts +0 -61
- package/src/request-context.ts +0 -33
- package/src/request-pipeline.test.ts +0 -88
- package/src/request.ts +0 -10
- package/src/response.test.ts +0 -130
- package/src/response.ts +0 -144
- package/src/service/compose-sqlite.ts +0 -98
- package/src/service/config-import.ts +0 -39
- package/src/service/create-remit-client.ts +0 -521
- package/src/service/data-client.test.ts +0 -97
- package/src/service/data-client.ts +0 -58
- package/src/service/export-identity.ts +0 -39
- package/src/service/filter.ts +0 -40
- package/src/service/fire-and-forget.test.ts +0 -126
- package/src/service/fire-and-forget.ts +0 -79
- package/src/service/localhost-env-config.test.ts +0 -36
- package/src/service/organize-queue.ts +0 -98
- package/src/service/organize.test.ts +0 -1451
- package/src/service/organize.ts +0 -1025
- package/src/service/read-path-filter-config.test.ts +0 -243
- package/src/service/semantic-capability.test.ts +0 -78
- package/src/service/semantic-capability.ts +0 -95
- package/src/service/sender-category.test.ts +0 -235
- package/src/service/trigger-sync.test.ts +0 -205
- package/src/service/trigger-sync.ts +0 -100
- package/src/stdout-capture-fixture.ts +0 -40
- package/src/types.ts +0 -271
- package/tsconfig.json +0 -7
|
@@ -1,126 +0,0 @@
|
|
|
1
|
-
import assert from "node:assert/strict";
|
|
2
|
-
import { describe, it } from "node:test";
|
|
3
|
-
import type { ThreadMessageResponse } from "@remit/api-openapi-types";
|
|
4
|
-
import {
|
|
5
|
-
MessageCategory,
|
|
6
|
-
MessageMutation,
|
|
7
|
-
MessageStatus,
|
|
8
|
-
MessageSyncStatus,
|
|
9
|
-
SenderTrust,
|
|
10
|
-
StarColor,
|
|
11
|
-
} from "@remit/domain-enums";
|
|
12
|
-
import {
|
|
13
|
-
filterByOffRowCriteria,
|
|
14
|
-
hasOffRowCriteria,
|
|
15
|
-
} from "./filterThreadCriteria.js";
|
|
16
|
-
|
|
17
|
-
const row = (
|
|
18
|
-
overrides: Partial<ThreadMessageResponse>,
|
|
19
|
-
): ThreadMessageResponse => ({
|
|
20
|
-
threadMessageId: "tm",
|
|
21
|
-
threadId: "t",
|
|
22
|
-
messageId: "m",
|
|
23
|
-
accountConfigId: "acc",
|
|
24
|
-
mailboxId: "mb",
|
|
25
|
-
subject: "s",
|
|
26
|
-
fromEmail: "a@example.com",
|
|
27
|
-
fromName: "A",
|
|
28
|
-
sentDate: 0,
|
|
29
|
-
isRead: false,
|
|
30
|
-
hasAttachment: false,
|
|
31
|
-
hasStars: false,
|
|
32
|
-
star: StarColor.None,
|
|
33
|
-
isDeleted: false,
|
|
34
|
-
snippet: "",
|
|
35
|
-
category: MessageCategory.uncategorized,
|
|
36
|
-
createdAt: 0,
|
|
37
|
-
updatedAt: 0,
|
|
38
|
-
senderTrust: SenderTrust.Unknown,
|
|
39
|
-
muted: false,
|
|
40
|
-
status: MessageStatus.active,
|
|
41
|
-
syncStatus: MessageSyncStatus.pending,
|
|
42
|
-
abandonedMutation: MessageMutation.none,
|
|
43
|
-
...overrides,
|
|
44
|
-
});
|
|
45
|
-
|
|
46
|
-
describe("hasOffRowCriteria", () => {
|
|
47
|
-
it("is false for an empty criteria object", () => {
|
|
48
|
-
assert.equal(hasOffRowCriteria({}), false);
|
|
49
|
-
});
|
|
50
|
-
|
|
51
|
-
it("is false for empty arrays", () => {
|
|
52
|
-
assert.equal(hasOffRowCriteria({ senderTrust: [] }), false);
|
|
53
|
-
});
|
|
54
|
-
|
|
55
|
-
it("is true when any criterion is set", () => {
|
|
56
|
-
assert.equal(hasOffRowCriteria({ senderTrust: [SenderTrust.Vip] }), true);
|
|
57
|
-
assert.equal(hasOffRowCriteria({ dkimMismatch: false }), true);
|
|
58
|
-
});
|
|
59
|
-
});
|
|
60
|
-
|
|
61
|
-
describe("filterByOffRowCriteria", () => {
|
|
62
|
-
it("returns rows untouched when no criteria are active", () => {
|
|
63
|
-
const rows = [row({}), row({})];
|
|
64
|
-
assert.equal(filterByOffRowCriteria(rows, {}).length, 2);
|
|
65
|
-
});
|
|
66
|
-
|
|
67
|
-
it("filters by senderTrust any-of", () => {
|
|
68
|
-
const rows = [
|
|
69
|
-
row({ senderTrust: SenderTrust.Vip }),
|
|
70
|
-
row({ senderTrust: SenderTrust.Wellknown }),
|
|
71
|
-
row({ senderTrust: SenderTrust.Unknown }),
|
|
72
|
-
];
|
|
73
|
-
const result = filterByOffRowCriteria(rows, {
|
|
74
|
-
senderTrust: [SenderTrust.Vip, SenderTrust.Wellknown],
|
|
75
|
-
});
|
|
76
|
-
assert.equal(result.length, 2);
|
|
77
|
-
assert.ok(result.every((r) => r.senderTrust !== SenderTrust.Unknown));
|
|
78
|
-
});
|
|
79
|
-
|
|
80
|
-
it("leaves category alone — it is a SQL predicate, not an off-row criterion", () => {
|
|
81
|
-
const rows = [
|
|
82
|
-
row({ category: MessageCategory.newsletter }),
|
|
83
|
-
row({ category: MessageCategory.personal }),
|
|
84
|
-
];
|
|
85
|
-
assert.equal(filterByOffRowCriteria(rows, {}).length, 2);
|
|
86
|
-
});
|
|
87
|
-
|
|
88
|
-
it("filters by dkimMismatch and never matches rows lacking an authenticity signal", () => {
|
|
89
|
-
const rows = [
|
|
90
|
-
row({ authenticity: { fromDomain: "x", dkimMismatch: false } }),
|
|
91
|
-
row({ authenticity: { fromDomain: "y", dkimMismatch: true } }),
|
|
92
|
-
row({ authenticity: undefined }),
|
|
93
|
-
];
|
|
94
|
-
const aligned = filterByOffRowCriteria(rows, { dkimMismatch: false });
|
|
95
|
-
assert.equal(aligned.length, 1);
|
|
96
|
-
assert.equal(aligned[0].authenticity?.dkimMismatch, false);
|
|
97
|
-
|
|
98
|
-
const mismatched = filterByOffRowCriteria(rows, { dkimMismatch: true });
|
|
99
|
-
assert.equal(mismatched.length, 1);
|
|
100
|
-
assert.equal(mismatched[0].authenticity?.dkimMismatch, true);
|
|
101
|
-
});
|
|
102
|
-
|
|
103
|
-
it("ANDs criteria together (Rescue shape: trust set + dkim aligned)", () => {
|
|
104
|
-
const rows = [
|
|
105
|
-
row({
|
|
106
|
-
senderTrust: SenderTrust.Vip,
|
|
107
|
-
authenticity: { fromDomain: "x", dkimMismatch: false },
|
|
108
|
-
}),
|
|
109
|
-
row({
|
|
110
|
-
senderTrust: SenderTrust.Vip,
|
|
111
|
-
authenticity: { fromDomain: "y", dkimMismatch: true },
|
|
112
|
-
}),
|
|
113
|
-
row({
|
|
114
|
-
senderTrust: SenderTrust.Unknown,
|
|
115
|
-
authenticity: { fromDomain: "z", dkimMismatch: false },
|
|
116
|
-
}),
|
|
117
|
-
];
|
|
118
|
-
const result = filterByOffRowCriteria(rows, {
|
|
119
|
-
senderTrust: [SenderTrust.Vip, SenderTrust.Wellknown],
|
|
120
|
-
dkimMismatch: false,
|
|
121
|
-
});
|
|
122
|
-
assert.equal(result.length, 1);
|
|
123
|
-
assert.equal(result[0].senderTrust, SenderTrust.Vip);
|
|
124
|
-
assert.equal(result[0].authenticity?.dkimMismatch, false);
|
|
125
|
-
});
|
|
126
|
-
});
|
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
SenderTrust,
|
|
3
|
-
ThreadMessageResponse,
|
|
4
|
-
} from "@remit/api-openapi-types";
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* Off-row search criteria — fields that live on the underlying Message/Address,
|
|
8
|
-
* not on the ThreadMessage row. They are resolved by enriching the windowed
|
|
9
|
-
* rows (see enrichThreadRows) and filtering in app code, because no index or
|
|
10
|
-
* FilterExpression can serve them.
|
|
11
|
-
*
|
|
12
|
-
* `senderTrust` derives from AddressItem.flags and `dkimMismatch` from
|
|
13
|
-
* MessageItem.authenticity. `category` is not one of these: it is denormalized
|
|
14
|
-
* onto the ThreadMessage row and filtered in SQL, inside the window.
|
|
15
|
-
*/
|
|
16
|
-
export interface OffRowCriteria {
|
|
17
|
-
senderTrust?: SenderTrust[];
|
|
18
|
-
dkimMismatch?: boolean;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
export const hasOffRowCriteria = (criteria: OffRowCriteria): boolean =>
|
|
22
|
-
Boolean(criteria.senderTrust?.length) || criteria.dkimMismatch !== undefined;
|
|
23
|
-
|
|
24
|
-
/**
|
|
25
|
-
* Filter enriched rows by the off-row criteria. Each active criterion is an
|
|
26
|
-
* any-of set (AND across criteria, OR within a set). A row with no
|
|
27
|
-
* `authenticity` signal never matches a `dkimMismatch` filter (absence means no
|
|
28
|
-
* signal, not a verdict).
|
|
29
|
-
*/
|
|
30
|
-
export const filterByOffRowCriteria = (
|
|
31
|
-
rows: ThreadMessageResponse[],
|
|
32
|
-
criteria: OffRowCriteria,
|
|
33
|
-
): ThreadMessageResponse[] => {
|
|
34
|
-
if (!hasOffRowCriteria(criteria)) return rows;
|
|
35
|
-
|
|
36
|
-
const trustSet = criteria.senderTrust?.length
|
|
37
|
-
? new Set(criteria.senderTrust)
|
|
38
|
-
: undefined;
|
|
39
|
-
const { dkimMismatch } = criteria;
|
|
40
|
-
|
|
41
|
-
return rows.filter((row) => {
|
|
42
|
-
if (trustSet && !trustSet.has(row.senderTrust)) return false;
|
|
43
|
-
if (
|
|
44
|
-
dkimMismatch !== undefined &&
|
|
45
|
-
row.authenticity?.dkimMismatch !== dkimMismatch
|
|
46
|
-
) {
|
|
47
|
-
return false;
|
|
48
|
-
}
|
|
49
|
-
return true;
|
|
50
|
-
});
|
|
51
|
-
};
|
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
import assert from "node:assert/strict";
|
|
2
|
-
import { describe, it } from "node:test";
|
|
3
|
-
import type { AddressFlags } from "@remit/api-openapi-types";
|
|
4
|
-
import { deriveSenderTrust } from "./senderTrust.js";
|
|
5
|
-
|
|
6
|
-
// AddressFlagBase requires setAt; deriveSenderTrust only reads `value`, so the
|
|
7
|
-
// timestamp value is irrelevant to these assertions.
|
|
8
|
-
const SET_AT = 1_700_000_000_000;
|
|
9
|
-
|
|
10
|
-
describe("deriveSenderTrust", () => {
|
|
11
|
-
it("returns 'unknown' when flags is undefined", () => {
|
|
12
|
-
assert.equal(deriveSenderTrust(undefined), "unknown");
|
|
13
|
-
});
|
|
14
|
-
|
|
15
|
-
it("returns 'unknown' for an empty flags object", () => {
|
|
16
|
-
assert.equal(deriveSenderTrust({}), "unknown");
|
|
17
|
-
});
|
|
18
|
-
|
|
19
|
-
it("returns 'unknown' when wellknown.value is false", () => {
|
|
20
|
-
const flags: AddressFlags = { wellknown: { value: false, setAt: SET_AT } };
|
|
21
|
-
assert.equal(deriveSenderTrust(flags), "unknown");
|
|
22
|
-
});
|
|
23
|
-
|
|
24
|
-
it("returns 'wellknown' when wellknown.value is true", () => {
|
|
25
|
-
const flags: AddressFlags = { wellknown: { value: true, setAt: SET_AT } };
|
|
26
|
-
assert.equal(deriveSenderTrust(flags), "wellknown");
|
|
27
|
-
});
|
|
28
|
-
|
|
29
|
-
it("returns 'vip' when vip.value is true", () => {
|
|
30
|
-
const flags: AddressFlags = { vip: { value: true, setAt: SET_AT } };
|
|
31
|
-
assert.equal(deriveSenderTrust(flags), "vip");
|
|
32
|
-
});
|
|
33
|
-
|
|
34
|
-
it("returns 'unknown' when vip.value is false", () => {
|
|
35
|
-
const flags: AddressFlags = { vip: { value: false, setAt: SET_AT } };
|
|
36
|
-
assert.equal(deriveSenderTrust(flags), "unknown");
|
|
37
|
-
});
|
|
38
|
-
|
|
39
|
-
it("vip wins over wellknown when both are true", () => {
|
|
40
|
-
const flags: AddressFlags = {
|
|
41
|
-
vip: { value: true, setAt: SET_AT },
|
|
42
|
-
wellknown: { value: true, setAt: SET_AT },
|
|
43
|
-
};
|
|
44
|
-
assert.equal(deriveSenderTrust(flags), "vip");
|
|
45
|
-
});
|
|
46
|
-
|
|
47
|
-
it("falls back to wellknown when vip is false but wellknown is true", () => {
|
|
48
|
-
const flags: AddressFlags = {
|
|
49
|
-
vip: { value: false, setAt: SET_AT },
|
|
50
|
-
wellknown: { value: true, setAt: SET_AT },
|
|
51
|
-
};
|
|
52
|
-
assert.equal(deriveSenderTrust(flags), "wellknown");
|
|
53
|
-
});
|
|
54
|
-
|
|
55
|
-
it("ignores trusted flag (orthogonal axis)", () => {
|
|
56
|
-
const flags: AddressFlags = { trusted: { value: true, setAt: SET_AT } };
|
|
57
|
-
assert.equal(deriveSenderTrust(flags), "unknown");
|
|
58
|
-
});
|
|
59
|
-
|
|
60
|
-
it("ignores trusted even when wellknown is also set", () => {
|
|
61
|
-
const flags: AddressFlags = {
|
|
62
|
-
trusted: { value: true, setAt: SET_AT },
|
|
63
|
-
wellknown: { value: true, setAt: SET_AT },
|
|
64
|
-
};
|
|
65
|
-
assert.equal(deriveSenderTrust(flags), "wellknown");
|
|
66
|
-
});
|
|
67
|
-
});
|
package/src/error.test.ts
DELETED
|
@@ -1,201 +0,0 @@
|
|
|
1
|
-
import assert from "node:assert/strict";
|
|
2
|
-
import { describe, it } from "node:test";
|
|
3
|
-
import type { ApiError, FolderRoleConflict } from "@remit/api-openapi-types";
|
|
4
|
-
import {
|
|
5
|
-
BadRequestError,
|
|
6
|
-
ClientError,
|
|
7
|
-
ConflictError,
|
|
8
|
-
FolderRoleUnresolvedError,
|
|
9
|
-
ForbiddenError,
|
|
10
|
-
NotFoundError,
|
|
11
|
-
UnhandledError,
|
|
12
|
-
UnrecoverableBodyError,
|
|
13
|
-
} from "@remit/data-ports/errors";
|
|
14
|
-
import { NO_TRASH_FOLDER_REASON } from "@remit/data-ports/folder-role";
|
|
15
|
-
import { CanonicalMailboxRole } from "@remit/domain-enums";
|
|
16
|
-
import { NoTrashMailboxError } from "@remit/mailbox-service";
|
|
17
|
-
import { handleError } from "./error.js";
|
|
18
|
-
|
|
19
|
-
const parseBody = (body: string): Record<string, unknown> =>
|
|
20
|
-
JSON.parse(body) as Record<string, unknown>;
|
|
21
|
-
|
|
22
|
-
// One shape for every error the API answers with (issue #371): flat, always a
|
|
23
|
-
// `code`, always a `message`. A status class that reaches a client without a
|
|
24
|
-
// code leaves it branching on prose.
|
|
25
|
-
describe("the wire shape of a refusal, per status class", () => {
|
|
26
|
-
const cases: ReadonlyArray<[string, Error, number, string]> = [
|
|
27
|
-
[
|
|
28
|
-
"400",
|
|
29
|
-
new BadRequestError("confirmEmail is required"),
|
|
30
|
-
400,
|
|
31
|
-
"invalid_request",
|
|
32
|
-
],
|
|
33
|
-
["401", new ClientError("Session expired"), 401, "unauthorized"],
|
|
34
|
-
["403", new ForbiddenError("Not your account"), 403, "forbidden"],
|
|
35
|
-
["404", new NotFoundError("Mailbox not found: mb-1"), 404, "not_found"],
|
|
36
|
-
[
|
|
37
|
-
"409",
|
|
38
|
-
new ConflictError("An update is already in progress."),
|
|
39
|
-
409,
|
|
40
|
-
"conflict",
|
|
41
|
-
],
|
|
42
|
-
[
|
|
43
|
-
"422",
|
|
44
|
-
new UnrecoverableBodyError("This message's body could not be read."),
|
|
45
|
-
422,
|
|
46
|
-
"unprocessable_entity",
|
|
47
|
-
],
|
|
48
|
-
];
|
|
49
|
-
|
|
50
|
-
for (const [name, error, statusCode, code] of cases) {
|
|
51
|
-
it(`answers ${name} with a flat code and message`, async () => {
|
|
52
|
-
const response = await handleError(error);
|
|
53
|
-
|
|
54
|
-
assert.equal(response.statusCode, statusCode);
|
|
55
|
-
assert.deepEqual(parseBody(response.body), {
|
|
56
|
-
code,
|
|
57
|
-
message: error.message,
|
|
58
|
-
});
|
|
59
|
-
});
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
// A 5xx is the one class whose message is not the thrower's. Those sentences
|
|
63
|
-
// are written for a log line and name hosts, queries and ids; the correlation
|
|
64
|
-
// id on the response is how the real one is found.
|
|
65
|
-
it("answers 500 with one code and one sentence, never the thrower's", async () => {
|
|
66
|
-
const response = await handleError(
|
|
67
|
-
new UnhandledError(
|
|
68
|
-
"pg://reader@db-3.internal:5432 timed out on SELECT * FROM message",
|
|
69
|
-
),
|
|
70
|
-
);
|
|
71
|
-
|
|
72
|
-
assert.equal(response.statusCode, 500);
|
|
73
|
-
assert.deepEqual(parseBody(response.body), {
|
|
74
|
-
code: "internal_error",
|
|
75
|
-
message: "Internal server error",
|
|
76
|
-
});
|
|
77
|
-
});
|
|
78
|
-
|
|
79
|
-
it("types every one of those bodies as the declared ApiError", async () => {
|
|
80
|
-
const response = await handleError(new NotFoundError("Gone"));
|
|
81
|
-
const body: ApiError = JSON.parse(response.body);
|
|
82
|
-
|
|
83
|
-
assert.equal(body.code, "not_found");
|
|
84
|
-
assert.equal(body.message, "Gone");
|
|
85
|
-
});
|
|
86
|
-
});
|
|
87
|
-
|
|
88
|
-
describe("handleError coded refusals", () => {
|
|
89
|
-
it("puts the code and every detail of a folder-role 409 on the wire", async () => {
|
|
90
|
-
const response = await handleError(
|
|
91
|
-
new FolderRoleUnresolvedError(
|
|
92
|
-
"The folder you chose for Trash is gone.",
|
|
93
|
-
CanonicalMailboxRole.Trash,
|
|
94
|
-
"stale",
|
|
95
|
-
"account-7",
|
|
96
|
-
),
|
|
97
|
-
);
|
|
98
|
-
|
|
99
|
-
assert.equal(response.statusCode, 409);
|
|
100
|
-
assert.deepEqual(parseBody(response.body), {
|
|
101
|
-
message: "The folder you chose for Trash is gone.",
|
|
102
|
-
code: "folder_role_unresolved",
|
|
103
|
-
details: { role: "Trash", reason: "stale", accountId: "account-7" },
|
|
104
|
-
});
|
|
105
|
-
});
|
|
106
|
-
|
|
107
|
-
it("carries NoTrashMailboxError as the Trash role with reason none", async () => {
|
|
108
|
-
const response = await handleError(new NoTrashMailboxError("account-7"));
|
|
109
|
-
|
|
110
|
-
assert.equal(response.statusCode, 409);
|
|
111
|
-
assert.deepEqual(parseBody(response.body), {
|
|
112
|
-
message: NO_TRASH_FOLDER_REASON,
|
|
113
|
-
code: "folder_role_unresolved",
|
|
114
|
-
details: { role: "Trash", reason: "none", accountId: "account-7" },
|
|
115
|
-
});
|
|
116
|
-
});
|
|
117
|
-
|
|
118
|
-
it("keeps an unhandled 500 to a code and a message — no stack, no cause, no details", async () => {
|
|
119
|
-
const response = await handleError(
|
|
120
|
-
new UnhandledError("Something went wrong", new Error("connection reset")),
|
|
121
|
-
);
|
|
122
|
-
|
|
123
|
-
assert.equal(response.statusCode, 500);
|
|
124
|
-
assert.deepEqual(parseBody(response.body), {
|
|
125
|
-
code: "internal_error",
|
|
126
|
-
message: "Internal server error",
|
|
127
|
-
});
|
|
128
|
-
});
|
|
129
|
-
|
|
130
|
-
it("replaces a code a 5xx should never have carried, and drops its details", async () => {
|
|
131
|
-
const error = new UnhandledError("Something went wrong");
|
|
132
|
-
error.publicApiError = {
|
|
133
|
-
code: "folder_role_unresolved",
|
|
134
|
-
details: { role: "Trash", reason: "none", accountId: "account-7" },
|
|
135
|
-
};
|
|
136
|
-
|
|
137
|
-
const response = await handleError(error);
|
|
138
|
-
|
|
139
|
-
assert.equal(response.statusCode, 500);
|
|
140
|
-
assert.deepEqual(parseBody(response.body), {
|
|
141
|
-
code: "internal_error",
|
|
142
|
-
message: "Internal server error",
|
|
143
|
-
});
|
|
144
|
-
});
|
|
145
|
-
|
|
146
|
-
it("keeps an infrastructure failure to the generic message and code", async () => {
|
|
147
|
-
const error = Object.assign(
|
|
148
|
-
new Error("aws-error: ProvisionedThroughputExceeded on remit-main"),
|
|
149
|
-
{ name: "ElectroError" },
|
|
150
|
-
);
|
|
151
|
-
|
|
152
|
-
const response = await handleError(error);
|
|
153
|
-
|
|
154
|
-
assert.equal(response.statusCode, 500);
|
|
155
|
-
assert.deepEqual(parseBody(response.body), {
|
|
156
|
-
code: "internal_error",
|
|
157
|
-
message: "Database temporarily unavailable",
|
|
158
|
-
});
|
|
159
|
-
});
|
|
160
|
-
|
|
161
|
-
it("answers a malformed query as a 400 with the query's own message", async () => {
|
|
162
|
-
const error = Object.assign(new Error("Invalid attribute: sentDate"), {
|
|
163
|
-
name: "ElectroError",
|
|
164
|
-
});
|
|
165
|
-
|
|
166
|
-
const response = await handleError(error);
|
|
167
|
-
|
|
168
|
-
assert.equal(response.statusCode, 400);
|
|
169
|
-
assert.deepEqual(parseBody(response.body), {
|
|
170
|
-
code: "invalid_request",
|
|
171
|
-
message: "Invalid attribute: sentDate",
|
|
172
|
-
});
|
|
173
|
-
});
|
|
174
|
-
|
|
175
|
-
// The contract and the emitter cannot drift apart: this asserts the response
|
|
176
|
-
// `handleError` actually builds against the generated model. Nesting the body
|
|
177
|
-
// under `error` again would leave `code` off `keyof FolderRoleConflict` and
|
|
178
|
-
// fail to compile here, long before a client reads a 409 it cannot parse.
|
|
179
|
-
it("matches the generated FolderRoleConflict model field for field", async () => {
|
|
180
|
-
const response = await handleError(
|
|
181
|
-
new FolderRoleUnresolvedError(
|
|
182
|
-
"Nobody has confirmed a Trash folder.",
|
|
183
|
-
CanonicalMailboxRole.Trash,
|
|
184
|
-
"unconfirmed",
|
|
185
|
-
"account-7",
|
|
186
|
-
),
|
|
187
|
-
);
|
|
188
|
-
const body: Omit<FolderRoleConflict, "statusCode"> = JSON.parse(
|
|
189
|
-
response.body,
|
|
190
|
-
);
|
|
191
|
-
const declaredFields: ReadonlyArray<keyof typeof body> = [
|
|
192
|
-
"code",
|
|
193
|
-
"details",
|
|
194
|
-
"message",
|
|
195
|
-
];
|
|
196
|
-
|
|
197
|
-
assert.equal(response.statusCode, 409);
|
|
198
|
-
assert.deepEqual(Object.keys(body).sort(), [...declaredFields].sort());
|
|
199
|
-
assert.equal(body.code, "folder_role_unresolved");
|
|
200
|
-
});
|
|
201
|
-
});
|
package/src/error.ts
DELETED
|
@@ -1,123 +0,0 @@
|
|
|
1
|
-
import { isPublicApiError } from "@remit/data-ports/errors";
|
|
2
|
-
import { logger } from "@remit/logger-lambda";
|
|
3
|
-
import type { APIGatewayProxyResult } from "aws-lambda";
|
|
4
|
-
import { formatResponse } from "./response.js";
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* The `code` a refusal carries when it does not name its own. Every error body
|
|
8
|
-
* the API emits is flat `{ code, message }` (issue #371), and `code` is the
|
|
9
|
-
* only field a client may branch on — a message is a sentence for a person and
|
|
10
|
-
* is free to change.
|
|
11
|
-
*
|
|
12
|
-
* A 5xx always answers `internal_error`, whatever the throw site said: a coded
|
|
13
|
-
* 5xx is a mistake at the throw site, not a contract, and a fixed token cannot
|
|
14
|
-
* carry anything about the failure out of the process.
|
|
15
|
-
*/
|
|
16
|
-
export const INTERNAL_ERROR_CODE = "internal_error";
|
|
17
|
-
|
|
18
|
-
/**
|
|
19
|
-
* The one sentence any 5xx answers with. A thrown message is written for a log
|
|
20
|
-
* line, not for a stranger — it names hosts, queries and ids — so it is
|
|
21
|
-
* replaced rather than trusted. The real message is already on the error log
|
|
22
|
-
* beside the correlation id the response carries.
|
|
23
|
-
*/
|
|
24
|
-
export const INTERNAL_ERROR_MESSAGE = "Internal server error";
|
|
25
|
-
|
|
26
|
-
const CODE_BY_STATUS: Record<number, string> = {
|
|
27
|
-
400: "invalid_request",
|
|
28
|
-
401: "unauthorized",
|
|
29
|
-
403: "forbidden",
|
|
30
|
-
404: "not_found",
|
|
31
|
-
409: "conflict",
|
|
32
|
-
412: "precondition_failed",
|
|
33
|
-
413: "payload_too_large",
|
|
34
|
-
422: "unprocessable_entity",
|
|
35
|
-
};
|
|
36
|
-
|
|
37
|
-
export const defaultErrorCode = (statusCode: number): string => {
|
|
38
|
-
if (statusCode >= 500) return INTERNAL_ERROR_CODE;
|
|
39
|
-
return CODE_BY_STATUS[statusCode] ?? "request_refused";
|
|
40
|
-
};
|
|
41
|
-
|
|
42
|
-
export const handleError = async (
|
|
43
|
-
error: unknown,
|
|
44
|
-
): Promise<APIGatewayProxyResult> => {
|
|
45
|
-
if (error instanceof Error) {
|
|
46
|
-
if ("statusCode" in error) {
|
|
47
|
-
logger.error(
|
|
48
|
-
{
|
|
49
|
-
error: error.message,
|
|
50
|
-
statusCode: error.statusCode,
|
|
51
|
-
stack: error.stack,
|
|
52
|
-
},
|
|
53
|
-
"Error with statusCode",
|
|
54
|
-
);
|
|
55
|
-
// An error that opted in names its own code and details, and only below
|
|
56
|
-
// 500: the status bound keeps a coded 5xx from reaching a client rather
|
|
57
|
-
// than trusting every future thrower to leave `publicApiError` alone.
|
|
58
|
-
// Everything else takes the status class's code, so no response goes out
|
|
59
|
-
// without one. A 5xx keeps neither the thrower's code nor its message —
|
|
60
|
-
// one status, one code, one sentence, whatever failed.
|
|
61
|
-
const statusCode =
|
|
62
|
-
typeof error.statusCode === "number" ? error.statusCode : 500;
|
|
63
|
-
if (statusCode >= 500) {
|
|
64
|
-
return formatResponse(
|
|
65
|
-
{ code: INTERNAL_ERROR_CODE, message: INTERNAL_ERROR_MESSAGE },
|
|
66
|
-
statusCode,
|
|
67
|
-
);
|
|
68
|
-
}
|
|
69
|
-
const publicApiError =
|
|
70
|
-
"publicApiError" in error && isPublicApiError(error.publicApiError)
|
|
71
|
-
? error.publicApiError
|
|
72
|
-
: undefined;
|
|
73
|
-
return formatResponse(
|
|
74
|
-
{
|
|
75
|
-
code: defaultErrorCode(statusCode),
|
|
76
|
-
message: error.message,
|
|
77
|
-
...publicApiError,
|
|
78
|
-
},
|
|
79
|
-
statusCode,
|
|
80
|
-
);
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
if (error.name === "ElectroError") {
|
|
84
|
-
// DynamoDB client/infrastructure errors should be 500
|
|
85
|
-
// These contain "aws-error" in the message or reference URL
|
|
86
|
-
const isInfrastructureError =
|
|
87
|
-
error.message.includes("aws-error") ||
|
|
88
|
-
error.message.includes("DynamoDB client");
|
|
89
|
-
|
|
90
|
-
const statusCode = isInfrastructureError ? 500 : 400;
|
|
91
|
-
const logMessage = isInfrastructureError
|
|
92
|
-
? "DynamoDB infrastructure error"
|
|
93
|
-
: "ElectroError";
|
|
94
|
-
|
|
95
|
-
logger.error({ error: error.message, stack: error.stack }, logMessage);
|
|
96
|
-
|
|
97
|
-
// Don't expose internal details for infrastructure errors
|
|
98
|
-
const responseMessage = isInfrastructureError
|
|
99
|
-
? "Database temporarily unavailable"
|
|
100
|
-
: error.message;
|
|
101
|
-
|
|
102
|
-
return formatResponse(
|
|
103
|
-
{ code: defaultErrorCode(statusCode), message: responseMessage },
|
|
104
|
-
statusCode,
|
|
105
|
-
);
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
logger.error(
|
|
109
|
-
{ error: error.message, name: error.name, stack: error.stack },
|
|
110
|
-
"Unhandled Error",
|
|
111
|
-
);
|
|
112
|
-
return formatResponse(
|
|
113
|
-
{ code: INTERNAL_ERROR_CODE, message: INTERNAL_ERROR_MESSAGE },
|
|
114
|
-
500,
|
|
115
|
-
);
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
logger.error({ error: JSON.stringify(error) }, "Unknown error type");
|
|
119
|
-
return formatResponse(
|
|
120
|
-
{ code: INTERNAL_ERROR_CODE, message: INTERNAL_ERROR_MESSAGE },
|
|
121
|
-
500,
|
|
122
|
-
);
|
|
123
|
-
};
|
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
import assert from "node:assert/strict";
|
|
2
|
-
import { describe, it } from "node:test";
|
|
3
|
-
import { AccountAuthType } from "@remit/domain-enums";
|
|
4
|
-
import type { APIGatewayProxyResult } from "aws-lambda";
|
|
5
|
-
import { handleError } from "../error.js";
|
|
6
|
-
import {
|
|
7
|
-
assertNotOAuthCreate,
|
|
8
|
-
assertPasswordProvided,
|
|
9
|
-
} from "./account-guards.js";
|
|
10
|
-
|
|
11
|
-
const refusalOf = (guard: () => void): Promise<APIGatewayProxyResult> => {
|
|
12
|
-
let thrown: unknown;
|
|
13
|
-
assert.throws(guard, (error: unknown) => {
|
|
14
|
-
thrown = error;
|
|
15
|
-
return true;
|
|
16
|
-
});
|
|
17
|
-
return handleError(thrown);
|
|
18
|
-
};
|
|
19
|
-
|
|
20
|
-
// Both guards used to throw `{ status: 400 }`, and the emitter reads
|
|
21
|
-
// `statusCode`. The status never matched, so a create the API meant to refuse
|
|
22
|
-
// as malformed answered 500 with "Internal server error" — telling the caller
|
|
23
|
-
// the server broke rather than what to change (issue #371).
|
|
24
|
-
describe("the create-account guards", () => {
|
|
25
|
-
it("refuses an OAuth create as a 400 the caller can act on", async () => {
|
|
26
|
-
const response = await refusalOf(() =>
|
|
27
|
-
assertNotOAuthCreate(AccountAuthType.OauthMicrosoft),
|
|
28
|
-
);
|
|
29
|
-
|
|
30
|
-
assert.equal(response.statusCode, 400);
|
|
31
|
-
const body = JSON.parse(response.body) as {
|
|
32
|
-
code: string;
|
|
33
|
-
message: string;
|
|
34
|
-
};
|
|
35
|
-
assert.equal(body.code, "invalid_request");
|
|
36
|
-
assert.match(body.message, /OAuth connect flow/);
|
|
37
|
-
});
|
|
38
|
-
|
|
39
|
-
it("refuses a password create with no password as a 400", async () => {
|
|
40
|
-
const response = await refusalOf(() =>
|
|
41
|
-
assertPasswordProvided(AccountAuthType.Password, undefined),
|
|
42
|
-
);
|
|
43
|
-
|
|
44
|
-
assert.equal(response.statusCode, 400);
|
|
45
|
-
const body = JSON.parse(response.body) as {
|
|
46
|
-
code: string;
|
|
47
|
-
message: string;
|
|
48
|
-
};
|
|
49
|
-
assert.equal(body.code, "invalid_request");
|
|
50
|
-
assert.match(body.message, /password is required/);
|
|
51
|
-
});
|
|
52
|
-
|
|
53
|
-
it("refuses a create that omits authType and password alike", async () => {
|
|
54
|
-
const response = await refusalOf(() =>
|
|
55
|
-
assertPasswordProvided(undefined, undefined),
|
|
56
|
-
);
|
|
57
|
-
|
|
58
|
-
assert.equal(response.statusCode, 400);
|
|
59
|
-
});
|
|
60
|
-
|
|
61
|
-
it("lets a password create with a password through", () => {
|
|
62
|
-
assert.doesNotThrow(() =>
|
|
63
|
-
assertPasswordProvided(AccountAuthType.Password, "hunter2"),
|
|
64
|
-
);
|
|
65
|
-
assert.doesNotThrow(() => assertNotOAuthCreate(AccountAuthType.Password));
|
|
66
|
-
});
|
|
67
|
-
});
|