@remit/backend 0.0.144 → 0.0.145

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.
Files changed (91) hide show
  1. package/dist/src/api.d.ts +0 -2
  2. package/dist/src/api.js +9 -80
  3. package/dist/src/auth.d.ts +13 -19
  4. package/dist/src/auth.js +51 -43
  5. package/dist/src/config/api-config.d.ts +20 -0
  6. package/dist/src/config/api-config.js +1 -0
  7. package/dist/src/config/from-env.d.ts +2 -0
  8. package/dist/src/config/from-env.js +65 -0
  9. package/dist/src/config/msoauth-secrets-manager.d.ts +2 -0
  10. package/dist/src/config/msoauth-secrets-manager.js +28 -0
  11. package/dist/src/config/msoauth.d.ts +18 -29
  12. package/dist/src/config/msoauth.js +4 -28
  13. package/dist/src/derive/contentSignature.d.ts +3 -4
  14. package/dist/src/derive/contentSignature.js +4 -13
  15. package/dist/src/derive/contentUrl.d.ts +0 -13
  16. package/dist/src/derive/contentUrl.js +0 -19
  17. package/dist/src/handlers/account-oauth.d.ts +4 -3
  18. package/dist/src/handlers/account-oauth.js +197 -250
  19. package/dist/src/handlers/account.d.ts +4 -3
  20. package/dist/src/handlers/account.js +26 -39
  21. package/dist/src/handlers/address.d.ts +2 -2
  22. package/dist/src/handlers/address.js +11 -19
  23. package/dist/src/handlers/calendar-event.js +18 -26
  24. package/dist/src/handlers/calendar-feed.d.ts +2 -2
  25. package/dist/src/handlers/calendar-feed.js +24 -32
  26. package/dist/src/handlers/calendar-suggestion.js +18 -26
  27. package/dist/src/handlers/calendar.d.ts +1 -1
  28. package/dist/src/handlers/calendar.js +15 -22
  29. package/dist/src/handlers/config.d.ts +5 -5
  30. package/dist/src/handlers/config.js +23 -35
  31. package/dist/src/handlers/filter.d.ts +2 -2
  32. package/dist/src/handlers/filter.js +17 -32
  33. package/dist/src/handlers/folder-role.js +3 -6
  34. package/dist/src/handlers/index.d.ts +88 -2
  35. package/dist/src/handlers/index.js +6 -4
  36. package/dist/src/handlers/label.js +15 -22
  37. package/dist/src/handlers/mailbox.d.ts +3 -3
  38. package/dist/src/handlers/mailbox.js +18 -26
  39. package/dist/src/handlers/me.d.ts +1 -1
  40. package/dist/src/handlers/me.js +26 -47
  41. package/dist/src/handlers/message.d.ts +3 -5
  42. package/dist/src/handlers/message.js +34 -46
  43. package/dist/src/handlers/organize.d.ts +2 -2
  44. package/dist/src/handlers/organize.js +11 -20
  45. package/dist/src/handlers/outbox-attachment.d.ts +5 -3
  46. package/dist/src/handlers/outbox-attachment.js +11 -15
  47. package/dist/src/handlers/outbox.d.ts +3 -3
  48. package/dist/src/handlers/outbox.js +27 -35
  49. package/dist/src/handlers/sync.d.ts +5 -5
  50. package/dist/src/handlers/sync.js +13 -22
  51. package/dist/src/handlers/system-update.js +14 -27
  52. package/dist/src/handlers/thread.js +9 -14
  53. package/dist/src/handlers/unified-threads.js +3 -6
  54. package/dist/src/index.d.ts +4 -1
  55. package/dist/src/index.js +18 -2
  56. package/dist/src/jwt-auth.d.ts +9 -12
  57. package/dist/src/jwt-auth.js +19 -71
  58. package/dist/src/lambda.d.ts +13 -0
  59. package/dist/src/lambda.js +33 -0
  60. package/dist/src/request.d.ts +8 -2
  61. package/dist/src/request.js +16 -6
  62. package/dist/src/response.d.ts +20 -3
  63. package/dist/src/response.js +15 -22
  64. package/dist/src/serve.d.ts +31 -0
  65. package/dist/src/serve.js +117 -0
  66. package/dist/src/service/account-deletion.d.ts +2 -4
  67. package/dist/src/service/account-deletion.js +3 -9
  68. package/dist/src/service/compose-sqlite.d.ts +2 -1
  69. package/dist/src/service/compose-sqlite.js +5 -3
  70. package/dist/src/service/create-remit-client.d.ts +25 -11
  71. package/dist/src/service/create-remit-client.js +96 -115
  72. package/dist/src/service/data-client.js +3 -5
  73. package/dist/src/service/export-identity.d.ts +2 -1
  74. package/dist/src/service/export-identity.js +4 -6
  75. package/dist/src/service/fire-and-forget.js +1 -2
  76. package/dist/src/service/organize.d.ts +7 -10
  77. package/dist/src/service/organize.js +10 -27
  78. package/dist/src/service/queues.d.ts +12 -0
  79. package/dist/src/service/queues.js +1 -0
  80. package/dist/src/service/shared-deps.d.ts +6 -0
  81. package/dist/src/service/shared-deps.js +24 -0
  82. package/dist/src/service/trigger-sync.d.ts +11 -5
  83. package/dist/src/service/trigger-sync.js +10 -18
  84. package/dist/src/types.d.ts +24 -1
  85. package/package.json +20 -8
  86. package/dist/src/data-backend.d.ts +0 -12
  87. package/dist/src/data-backend.js +0 -12
  88. package/dist/src/request-context.d.ts +0 -9
  89. package/dist/src/request-context.js +0 -22
  90. package/dist/src/service/sqs.d.ts +0 -1
  91. package/dist/src/service/sqs.js +0 -3
@@ -154,25 +154,17 @@ export const buildOrganizeMatchDeps = (client) => ({
154
154
  * {@link PlacementMoveService} over the shared message-management queue. A move
155
155
  * commits locally (marker + ThreadMessage + Message row) and enqueues a
156
156
  * `PLACEMENT_MOVE_PUSH` for the reconciler; its marker state engine makes a
157
- * redelivered job idempotent (mirrors #1297). Returns `undefined` when no
158
- * message-management queue is wired — the same gate body sync uses to keep the
159
- * move path off — so a move requested in that environment is counted as failed
160
- * rather than silently dropped (see {@link applyOrganize}).
157
+ * redelivered job idempotent (mirrors #1297).
161
158
  */
162
- export const buildOrganizeMoveService = (client) => {
163
- const queueUrl = process.env.SQS_QUEUE_URL_MESSAGE_MGMT;
164
- if (!queueUrl)
165
- return undefined;
166
- return new PlacementMoveService({
167
- messageService: client.message,
168
- threadMessageService: client.threadMessage,
169
- markerService: client.placementMove,
170
- addressService: client.address,
171
- mailboxSpecialUseService: client.mailboxSpecialUse,
172
- mailboxService: client.mailbox,
173
- sqsQueueUrl: queueUrl,
174
- });
175
- };
159
+ export const buildOrganizeMoveService = (client) => new PlacementMoveService({
160
+ messageService: client.message,
161
+ threadMessageService: client.threadMessage,
162
+ markerService: client.placementMove,
163
+ addressService: client.address,
164
+ mailboxSpecialUseService: client.mailboxSpecialUse,
165
+ mailboxService: client.mailbox,
166
+ queue: client.queues.messageManagement,
167
+ });
176
168
  /**
177
169
  * Apply the back-apply action to every matched message, reusing the index-time
178
170
  * apply plumbing: an idempotent MessageLabel upsert (additive) with
@@ -195,12 +187,6 @@ export const applyOrganize = async (deps, accountConfigId, messageIds, predicate
195
187
  const applyMove = predicate.actionMailboxId !== NO_ACTION && predicate.actionMailboxId !== "";
196
188
  const applyToMessage = async (messageId) => {
197
189
  if (applyMove) {
198
- if (!moveService) {
199
- // An exclusive move was requested but this caller wired no move
200
- // service. Never silently pretend it applied — surface it as a
201
- // failed message so the job's failedCount reflects reality.
202
- throw new Error("Organize move action requested but no move service is wired");
203
- }
204
190
  const message = await client.message.get(messageId);
205
191
  const accountId = await client.mailbox.resolveAccountId(message.mailboxId);
206
192
  if (!accountId) {
@@ -324,9 +310,6 @@ export const backApplyFilter = async (deps, accountConfigId, filterId) => {
324
310
  mailboxService: client.mailbox,
325
311
  placementMoveService: moveService,
326
312
  });
327
- if (!config) {
328
- throw new Error("Filter back-apply needs the message-management queue to move mail");
329
- }
330
313
  const pipeline = new FilterPipeline(config, logger);
331
314
  const mailboxIds = await inboxMailboxIds(client, accountConfigId);
332
315
  const nothing = {
@@ -0,0 +1,12 @@
1
+ import type { AccountFanoutEvent, FifoQueueProducer, QueueProducer } from "@remit/data-ports";
2
+ import type { FlagPushEvent, MailboxManagementEvent, MessageMoveQueueEvent, PlacementMovePushEvent, SendMessageEvent, SyncMessageBodyEvent } from "@remit/mailbox-service";
3
+ import type { SyncMailboxesEvent } from "./trigger-sync.js";
4
+ export type SyncQueueEvent = SyncMailboxesEvent | FlagPushEvent | MailboxManagementEvent | MessageMoveQueueEvent;
5
+ export interface RemitClientQueues {
6
+ sync: FifoQueueProducer<SyncQueueEvent>;
7
+ accountFanout: QueueProducer<AccountFanoutEvent>;
8
+ smtp: FifoQueueProducer<SendMessageEvent>;
9
+ messageManagement: QueueProducer<PlacementMovePushEvent>;
10
+ body: QueueProducer<SyncMessageBodyEvent>;
11
+ }
12
+ export type QueueName = keyof RemitClientQueues;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,6 @@
1
+ import type { RemitClientSharedDeps } from "./create-remit-client.js";
2
+ import type { QueueName, RemitClientQueues } from "./queues.js";
3
+ export type SqsQueueUrls = Record<QueueName, string>;
4
+ export declare const sqsQueueUrlsFromEnv: () => SqsQueueUrls;
5
+ export declare const sqsQueues: (urls: SqsQueueUrls) => RemitClientQueues;
6
+ export declare const buildSharedDeps: (queues: RemitClientQueues) => RemitClientSharedDeps;
@@ -0,0 +1,24 @@
1
+ import { createCachedDataKeyProvider, createSecretsService, } from "@remit/secrets-service";
2
+ import { createKmsDataKeyProvider, FAKE_KMS_KEY_ID, } from "@remit/secrets-service/kms";
3
+ import { createQueueProducer } from "@remit/sqs-client/producer";
4
+ import { createStorageService } from "@remit/storage-service/s3";
5
+ import { env } from "expect-env";
6
+ export const sqsQueueUrlsFromEnv = () => ({
7
+ sync: env.SQS_QUEUE_URL,
8
+ accountFanout: env.SQS_QUEUE_URL_ACCOUNT_FANOUT,
9
+ smtp: env.SQS_QUEUE_URL_SMTP,
10
+ messageManagement: env.SQS_QUEUE_URL_MESSAGE_MGMT,
11
+ body: env.SQS_QUEUE_URL_BODY,
12
+ });
13
+ export const sqsQueues = (urls) => ({
14
+ sync: createQueueProducer({ queueUrl: urls.sync }),
15
+ accountFanout: createQueueProducer({ queueUrl: urls.accountFanout }),
16
+ smtp: createQueueProducer({ queueUrl: urls.smtp }),
17
+ messageManagement: createQueueProducer({ queueUrl: urls.messageManagement }),
18
+ body: createQueueProducer({ queueUrl: urls.body }),
19
+ });
20
+ export const buildSharedDeps = (queues) => ({
21
+ storage: createStorageService(),
22
+ secrets: createSecretsService(createCachedDataKeyProvider(createKmsDataKeyProvider(process.env.KMS_KEY_ID ?? FAKE_KMS_KEY_ID))),
23
+ queues,
24
+ });
@@ -1,7 +1,13 @@
1
- import { SendMessageCommand, type SQSClient } from "@aws-sdk/client-sqs";
1
+ import type { FifoQueueMessage, FifoQueueProducer } from "@remit/data-ports";
2
+ export interface SyncMailboxesEvent {
3
+ type: "SYNC_MAILBOXES";
4
+ eventId: string;
5
+ timestamp: number;
6
+ accountId: string;
7
+ explicitRequest?: boolean;
8
+ }
2
9
  interface TriggerAccountSyncInput {
3
- sqsClient: SQSClient;
4
- queueUrl: string;
10
+ queue: FifoQueueProducer<SyncMailboxesEvent>;
5
11
  accountId: string;
6
12
  /**
7
13
  * Set by POST /sync, whose callers ask for a sync of one named account: the
@@ -21,7 +27,7 @@ interface TriggerAccountSyncInput {
21
27
  */
22
28
  explicitRequest?: boolean;
23
29
  /**
24
- * Override the FIFO `MessageDeduplicationId`. Defaults to the event's own
30
+ * Override the queue deduplication id. Defaults to the event's own
25
31
  * id, so the queue suppresses a re-send of one event and nothing else —
26
32
  * every manual call site (POST /sync, OAuth connect, config load,
27
33
  * pull-to-refresh, the client's online-poll) always enqueues. A shared,
@@ -44,7 +50,7 @@ interface TriggerAccountSyncInput {
44
50
  * retried Lambda) — see `dedupId` above.
45
51
  */
46
52
  export declare const buildScheduledSyncDedupId: (accountId: string, now: number, bucketMs: number) => string;
47
- export declare const buildSyncMailboxesCommand: (input: Omit<TriggerAccountSyncInput, "sqsClient">) => SendMessageCommand;
53
+ export declare const buildSyncMailboxesMessage: (input: Omit<TriggerAccountSyncInput, "queue">) => FifoQueueMessage<SyncMailboxesEvent>;
48
54
  export declare const triggerAccountSync: (input: TriggerAccountSyncInput) => Promise<{
49
55
  eventId: string;
50
56
  }>;
@@ -1,6 +1,4 @@
1
1
  import { randomUUID } from "node:crypto";
2
- import { SendMessageCommand } from "@aws-sdk/client-sqs";
3
- const isFifoQueue = (queueUrl) => queueUrl.endsWith(".fifo");
4
2
  /**
5
3
  * Build the scheduler's own dedup namespace, bucketed by tick interval so
6
4
  * consecutive ticks each get a fresh id (never colliding with each other)
@@ -11,8 +9,8 @@ export const buildScheduledSyncDedupId = (accountId, now, bucketMs) => {
11
9
  const bucket = Math.floor(now / bucketMs);
12
10
  return `SYNC_MAILBOXES:scheduled:${accountId}:${bucket}`;
13
11
  };
14
- export const buildSyncMailboxesCommand = (input) => {
15
- const { queueUrl, accountId, dedupId, explicitRequest } = input;
12
+ export const buildSyncMailboxesMessage = (input) => {
13
+ const { accountId, dedupId, explicitRequest } = input;
16
14
  const event = {
17
15
  type: "SYNC_MAILBOXES",
18
16
  eventId: randomUUID(),
@@ -20,20 +18,14 @@ export const buildSyncMailboxesCommand = (input) => {
20
18
  accountId,
21
19
  ...(explicitRequest && { explicitRequest }),
22
20
  };
23
- const useFifo = isFifoQueue(queueUrl);
24
- return new SendMessageCommand({
25
- QueueUrl: queueUrl,
26
- MessageBody: JSON.stringify(event),
27
- ...(useFifo && {
28
- MessageGroupId: accountId,
29
- MessageDeduplicationId: dedupId ?? event.eventId,
30
- }),
31
- });
21
+ return {
22
+ body: event,
23
+ groupId: accountId,
24
+ deduplicationId: dedupId ?? event.eventId,
25
+ };
32
26
  };
33
27
  export const triggerAccountSync = async (input) => {
34
- const command = buildSyncMailboxesCommand(input);
35
- await input.sqsClient.send(command);
36
- const body = command.input.MessageBody ?? "{}";
37
- const parsed = JSON.parse(body);
38
- return { eventId: parsed.eventId };
28
+ const message = buildSyncMailboxesMessage(input);
29
+ await input.queue.send(message);
30
+ return { eventId: message.body.eventId };
39
31
  };
@@ -1,4 +1,7 @@
1
1
  import type { Context } from "openapi-backend";
2
+ import type { ApiConfig } from "./config/api-config.js";
3
+ import type { RemitClient } from "./service/create-remit-client.js";
4
+ import type { QueueName } from "./service/queues.js";
2
5
  type MatchPrefix<Prefix extends string, S extends string> = S extends `${Prefix}${infer _}` ? S : never;
3
6
  export type OperationIds = "MeOperations_deleteMe" | "MeOperations_listVipSuggestions" | "MeOperations_createExport" | "MeOperations_getExport" | "MeOperations_listQuarantine" | "ConfigOperations_getConfig" | "ConfigOperations_exportConfig" | "ConfigOperations_importConfig" | "SystemOperations_getSystemUpdate" | "SystemOperations_applySystemUpdate" | "AccountOperations_createAccount" | "AccountOperations_testConnection" | "AccountDetailOperations_updateAccount" | "AccountDetailOperations_deleteAccount" | "MicrosoftOAuthOperations_microsoftOAuthStart" | "MicrosoftOAuthOperations_microsoftOAuthCallback" | "MailboxOperations_listMailboxes" | "MailboxOperations_createMailbox" | "MailboxDetailOperations_getMailbox" | "MailboxDetailOperations_renameMailbox" | "MailboxDetailOperations_deleteMailbox" | "FolderRoleOperations_appointFolderRole" | "FilterOperations_listFilters" | "FilterOperations_createFilter" | "FilterDetailOperations_getFilter" | "FilterDetailOperations_updateFilter" | "FilterDetailOperations_deleteFilter" | "LabelOperations_listLabels" | "LabelOperations_createLabel" | "LabelDetailOperations_getLabel" | "LabelDetailOperations_updateLabel" | "LabelDetailOperations_deleteLabel" | "OrganizeOperations_createOrganizeJob" | "OrganizeOperations_previewOrganize" | "OrganizeJobDetailOperations_getOrganizeJob" | "SyncOperations_triggerSync" | "SyncOperations_getSyncStatus" | "ThreadDetailOperations_listThreadMessages" | "UnifiedThreadOperations_listAllThreads" | "ThreadOperations_listThreads" | "ThreadOperations_searchThreads" | "MessageOperations_describeMessage" | "MessageOperations_getRawMessage" | "MessageOperations_updateMessageFlags" | "MessageBulkOperations_deleteMessages" | "MessageBulkOperations_moveMessages" | "MessageBulkOperations_updateFlags" | "MessageBulkOperations_copyMessages" | "MessageBulkOperations_updateMessageLabels" | "MessageBulkOperations_reportSpam" | "MessageBulkOperations_notSpam" | "CalendarOperations_listCalendars" | "CalendarOperations_createCalendar" | "CalendarDetailOperations_getCalendar" | "CalendarDetailOperations_updateCalendar" | "CalendarDetailOperations_deleteCalendar" | "CalendarDetailOperations_getCalendarFeed" | "CalendarDetailOperations_putCalendarFeed" | "CalendarDetailOperations_revokeCalendarFeed" | "CalendarFeedOperations_getCalendarFeedIcal" | "CalendarEventOperations_listCalendarEvents" | "CalendarEventOperations_createCalendarEvent" | "CalendarEventDetailOperations_getCalendarEvent" | "CalendarEventDetailOperations_updateCalendarEvent" | "CalendarEventDetailOperations_deleteCalendarEvent" | "CalendarFreeBusyOperations_listCalendarFreeBusy" | "TrashOperations_emptyTrash" | "OutboxOperations_createOutboxMessage" | "OutboxOperations_listOutboxMessages" | "OutboxDetailOperations_getOutboxMessage" | "OutboxDetailOperations_updateOutboxMessage" | "OutboxDetailOperations_deleteOutboxMessage" | "OutboxDetailOperations_sendOutboxMessage" | "OutboxDetailOperations_mintOutboxAttachment" | "OutboxAttachmentOperations_completeOutboxAttachment" | "AddressOperations_searchAddresses" | "AddressDetailOperations_updateAddress" | "CalendarSuggestionOperations_listCalendarSuggestions" | "MessageCalendarSuggestionOperations_listMessageCalendarSuggestions" | "CalendarSuggestionActionOperations_acceptCalendarSuggestion" | "CalendarSuggestionActionOperations_declineCalendarSuggestion" | "CalendarSuggestionActionOperations_dismissCalendarSuggestion" | "CalendarSuggestionActionOperations_reopenCalendarSuggestion";
4
7
  export type MeOperationIds = MatchPrefix<"MeOperations_", OperationIds>;
@@ -45,5 +48,25 @@ export type CalendarSuggestionOperationIds = MatchPrefix<"CalendarSuggestionOper
45
48
  export type MessageCalendarSuggestionOperationIds = MatchPrefix<"MessageCalendarSuggestionOperations_", OperationIds>;
46
49
  export type CalendarSuggestionActionOperationIds = MatchPrefix<"CalendarSuggestionActionOperations_", OperationIds>;
47
50
  type HandlerResponse = Record<string, any>;
48
- export type OperationHandler<_T extends OperationIds = OperationIds> = (context: Context) => Promise<HandlerResponse>;
51
+ export interface UserIdentity {
52
+ kind: "user";
53
+ accountConfigId: string;
54
+ sub: string;
55
+ email: string;
56
+ }
57
+ export type HandlerIdentity = {
58
+ kind: "anonymous";
59
+ } | UserIdentity;
60
+ export interface HandlerContext<K extends QueueName = never> {
61
+ client: RemitClient<K>;
62
+ identity: UserIdentity;
63
+ config: ApiConfig;
64
+ }
65
+ export interface PublicHandlerContext<K extends QueueName = never> {
66
+ client: RemitClient<K>;
67
+ config: ApiConfig;
68
+ }
69
+ export type PublicOperationIds = "MicrosoftOAuthOperations_microsoftOAuthCallback" | "CalendarFeedOperations_getCalendarFeedIcal";
70
+ export type OperationHandler<_T extends OperationIds = OperationIds, K extends QueueName = never> = (context: Context, ctx: HandlerContext<K>) => Promise<HandlerResponse>;
71
+ export type PublicOperationHandler<K extends QueueName = never> = (context: Context, ctx: PublicHandlerContext<K>) => Promise<HandlerResponse>;
49
72
  export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@remit/backend",
3
- "version": "0.0.144",
3
+ "version": "0.0.145",
4
4
  "description": "Remit Mail Inspector API backend",
5
5
  "license": "MIT",
6
6
  "author": "",
@@ -15,6 +15,10 @@
15
15
  "types": "./dist/src/api.d.ts",
16
16
  "default": "./dist/src/api.js"
17
17
  },
18
+ "./serve": {
19
+ "types": "./dist/src/serve.d.ts",
20
+ "default": "./dist/src/serve.js"
21
+ },
18
22
  "./client": {
19
23
  "types": "./dist/src/service/data-client.d.ts",
20
24
  "default": "./dist/src/service/data-client.js"
@@ -23,6 +27,14 @@
23
27
  "types": "./dist/src/service/create-remit-client.d.ts",
24
28
  "default": "./dist/src/service/create-remit-client.js"
25
29
  },
30
+ "./shared-deps": {
31
+ "types": "./dist/src/service/shared-deps.d.ts",
32
+ "default": "./dist/src/service/shared-deps.js"
33
+ },
34
+ "./compose-sqlite": {
35
+ "types": "./dist/src/service/compose-sqlite.d.ts",
36
+ "default": "./dist/src/service/compose-sqlite.js"
37
+ },
26
38
  "./folder-role-appointments": {
27
39
  "types": "./dist/src/handlers/folder-role-appointments.d.ts",
28
40
  "default": "./dist/src/handlers/folder-role-appointments.js"
@@ -89,16 +101,16 @@
89
101
  "@remit/auth-service": "*",
90
102
  "@remit/drizzle-service": "*",
91
103
  "@remit/sqs-client": "*",
92
- "@aws-sdk/client-secrets-manager": "*",
93
- "@aws-sdk/client-sqs": "*",
104
+ "@aws-sdk/client-secrets-manager": "^3.1090.0",
94
105
  "better-sqlite3": "^12.11.1",
95
- "expect-env": "*",
96
- "openapi-backend": "*",
97
- "p-map": "*",
98
- "@types/aws-lambda": "*",
106
+ "expect-env": "^1.0.1",
107
+ "openapi-backend": "^5.18.0",
108
+ "p-map": "^2.1.0",
109
+ "@types/aws-lambda": "^8.10.162",
99
110
  "@types/better-sqlite3": "^7.6.13",
100
111
  "@remit/logger": "*",
101
- "@remit/api-openapi-spec": "*"
112
+ "@remit/api-openapi-spec": "*",
113
+ "zod": "^3.25.0"
102
114
  },
103
115
  "publishConfig": {
104
116
  "access": "public"
@@ -1,12 +0,0 @@
1
- /**
2
- * The self-host SQL backend (RFC 034/035/036), as opposed to the AWS DynamoDB
3
- * path.
4
- */
5
- export declare const isSelfHostSqlBackend: () => boolean;
6
- /**
7
- * The self-host SQL backend authenticates requests and signs content URLs with
8
- * a better-auth RS256 JWT verified at the edge and re-verified in-process, no
9
- * Cognito authorizer. DynamoDB is the AWS path (Cognito claims, Lambda@Edge
10
- * content guard) and is deliberately excluded.
11
- */
12
- export declare const usesBetterAuthJwt: () => boolean;
@@ -1,12 +0,0 @@
1
- /**
2
- * The self-host SQL backend (RFC 034/035/036), as opposed to the AWS DynamoDB
3
- * path.
4
- */
5
- export const isSelfHostSqlBackend = () => process.env.DATA_BACKEND === "sqlite";
6
- /**
7
- * The self-host SQL backend authenticates requests and signs content URLs with
8
- * a better-auth RS256 JWT verified at the edge and re-verified in-process, no
9
- * Cognito authorizer. DynamoDB is the AWS path (Cognito claims, Lambda@Edge
10
- * content guard) and is deliberately excluded.
11
- */
12
- export const usesBetterAuthJwt = () => isSelfHostSqlBackend();
@@ -1,9 +0,0 @@
1
- interface RequestContext {
2
- origin?: string;
3
- correlationId?: string;
4
- }
5
- export declare const runWithRequestContext: <T>(ctx: RequestContext, fn: () => T) => T;
6
- export declare const getRequestOrigin: () => string | undefined;
7
- export declare const getRequestCorrelationId: () => string | undefined;
8
- export declare const resolveAllowedOrigin: (origin: string | undefined) => string;
9
- export {};
@@ -1,22 +0,0 @@
1
- import { AsyncLocalStorage } from "node:async_hooks";
2
- const storage = new AsyncLocalStorage();
3
- export const runWithRequestContext = (ctx, fn) => storage.run(ctx, fn);
4
- export const getRequestOrigin = () => storage.getStore()?.origin;
5
- export const getRequestCorrelationId = () => storage.getStore()?.correlationId;
6
- const parseAllowedOrigins = () => {
7
- const raw = process.env.CORS_ALLOWED_ORIGINS;
8
- if (!raw)
9
- return [];
10
- return raw
11
- .split(",")
12
- .map((s) => s.trim())
13
- .filter((s) => s.length > 0);
14
- };
15
- export const resolveAllowedOrigin = (origin) => {
16
- const allowed = parseAllowedOrigins();
17
- if (allowed.length === 0)
18
- return "*";
19
- if (origin && allowed.includes(origin))
20
- return origin;
21
- return allowed[0];
22
- };
@@ -1 +0,0 @@
1
- export declare const sqsClient: import("@aws-sdk/client-sqs").SQSClient;
@@ -1,3 +0,0 @@
1
- import { createQueueProducer } from "@remit/sqs-client/producer";
2
- import { env } from "expect-env";
3
- export const sqsClient = createQueueProducer({ queueUrl: env.SQS_QUEUE_URL });