@develit-io/backend-sdk 12.4.1 → 12.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.mts CHANGED
@@ -40,6 +40,7 @@ declare const structuredAddressSchema: z$1.ZodObject<{
40
40
  city: z$1.ZodOptional<z$1.ZodString>;
41
41
  postalCode: z$1.ZodOptional<z$1.ZodString>;
42
42
  countryCode: z$1.ZodOptional<z$1.ZodEnum<{
43
+ IM: "IM";
43
44
  AF: "AF";
44
45
  AL: "AL";
45
46
  DZ: "DZ";
@@ -129,7 +130,6 @@ declare const structuredAddressSchema: z$1.ZodObject<{
129
130
  IR: "IR";
130
131
  IQ: "IQ";
131
132
  IE: "IE";
132
- IM: "IM";
133
133
  IL: "IL";
134
134
  IT: "IT";
135
135
  CI: "CI";
@@ -330,6 +330,7 @@ declare const bankAccountMetadataSchema: z$1.ZodObject<{
330
330
  city: z$1.ZodOptional<z$1.ZodString>;
331
331
  postalCode: z$1.ZodOptional<z$1.ZodString>;
332
332
  countryCode: z$1.ZodOptional<z$1.ZodEnum<{
333
+ IM: "IM";
333
334
  AF: "AF";
334
335
  AL: "AL";
335
336
  DZ: "DZ";
@@ -419,7 +420,6 @@ declare const bankAccountMetadataSchema: z$1.ZodObject<{
419
420
  IR: "IR";
420
421
  IQ: "IQ";
421
422
  IE: "IE";
422
- IM: "IM";
423
423
  IL: "IL";
424
424
  IT: "IT";
425
425
  CI: "CI";
@@ -602,6 +602,7 @@ declare const bankAccountMetadataSchema: z$1.ZodObject<{
602
602
  AVAX: "AVAX";
603
603
  }>>;
604
604
  countryCode: z$1.ZodOptional<z$1.ZodEnum<{
605
+ IM: "IM";
605
606
  AF: "AF";
606
607
  AL: "AL";
607
608
  DZ: "DZ";
@@ -691,7 +692,6 @@ declare const bankAccountMetadataSchema: z$1.ZodObject<{
691
692
  IR: "IR";
692
693
  IQ: "IQ";
693
694
  IE: "IE";
694
- IM: "IM";
695
695
  IL: "IL";
696
696
  IT: "IT";
697
697
  CI: "CI";
@@ -833,7 +833,7 @@ declare const bankAccount: {
833
833
  swiftBic: drizzle_orm_sqlite_core.SQLiteTextBuilder<[string, ...string[]]>;
834
834
  bicCor: drizzle_orm_sqlite_core.SQLiteTextBuilder<[string, ...string[]]>;
835
835
  currency: drizzle_orm.NotNull<drizzle_orm_sqlite_core.SQLiteTextBuilder<["CZK" | "EUR" | "USD" | "PLN" | "RON" | "GBP" | "RUB" | "HUF" | "CHF" | "DKK" | "SEK" | "HRK" | "NOK" | "BGN" | "TRY" | "AUD" | "CAD" | "JPY" | "CNY" | "INR" | "BRL" | "MXN" | "ZAR" | "SGD" | "HKD" | "KRW" | "MYR" | "THB" | "IDR" | "PHP" | "AED" | "SAR" | "ILS" | "EGP" | "NGN" | "PKR" | "COP" | "CLP" | "PEN" | "VND" | "KZT" | "UAH" | "BTC" | "ETH" | "ADA" | "DOT" | "ATOM" | "XRP" | "LTC" | "SOL" | "DOGE" | "MATIC" | "AVAX", ...("CZK" | "EUR" | "USD" | "PLN" | "RON" | "GBP" | "RUB" | "HUF" | "CHF" | "DKK" | "SEK" | "HRK" | "NOK" | "BGN" | "TRY" | "AUD" | "CAD" | "JPY" | "CNY" | "INR" | "BRL" | "MXN" | "ZAR" | "SGD" | "HKD" | "KRW" | "MYR" | "THB" | "IDR" | "PHP" | "AED" | "SAR" | "ILS" | "EGP" | "NGN" | "PKR" | "COP" | "CLP" | "PEN" | "VND" | "KZT" | "UAH" | "BTC" | "ETH" | "ADA" | "DOT" | "ATOM" | "XRP" | "LTC" | "SOL" | "DOGE" | "MATIC" | "AVAX")[]]>>;
836
- countryCode: drizzle_orm.NotNull<drizzle_orm_sqlite_core.SQLiteTextBuilder<["AF" | "AL" | "DZ" | "AS" | "AD" | "AO" | "AG" | "AR" | "AM" | "AW" | "AU" | "AT" | "AZ" | "BS" | "BH" | "BD" | "BB" | "BY" | "BE" | "BZ" | "BJ" | "BO" | "BQ" | "BA" | "BW" | "BR" | "IO" | "VG" | "BG" | "BF" | "BI" | "KH" | "CM" | "CA" | "CV" | "CF" | "TD" | "CL" | "CN" | "CO" | "KM" | "CK" | "CR" | "HR" | "CW" | "CY" | "CZ" | "CD" | "DK" | "DJ" | "DM" | "DO" | "TL" | "EC" | "EG" | "SV" | "GQ" | "ER" | "EE" | "ET" | "FO" | "FJ" | "FI" | "FR" | "GF" | "PF" | "GA" | "GM" | "GE" | "DE" | "GH" | "GR" | "GD" | "GP" | "GU" | "GT" | "GN" | "GW" | "GY" | "HT" | "HK" | "HN" | "HU" | "IS" | "IN" | "ID" | "IR" | "IQ" | "IE" | "IM" | "IL" | "IT" | "CI" | "JM" | "JP" | "JE" | "JO" | "KZ" | "KE" | "KI" | "XK" | "KW" | "KG" | "LA" | "LV" | "LB" | "LS" | "LR" | "LI" | "LT" | "LU" | "MK" | "MG" | "MW" | "MY" | "MV" | "ML" | "MT" | "MQ" | "MR" | "MU" | "MX" | "FM" | "MD" | "MC" | "MN" | "ME" | "MS" | "MA" | "MZ" | "NA" | "NP" | "NL" | "NZ" | "NI" | "NE" | "NG" | "NU" | "NF" | "KP" | "NO" | "OM" | "PK" | "PS" | "PA" | "PG" | "PY" | "PE" | "PH" | "PL" | "PT" | "PR" | "QA" | "CG" | "RE" | "RO" | "RU" | "RW" | "BL" | "KN" | "LC" | "MF" | "VC" | "WS" | "SM" | "SA" | "SN" | "RS" | "SC" | "SL" | "SG" | "SX" | "SK" | "SI" | "SO" | "ZA" | "KR" | "SS" | "ES" | "LK" | "SD" | "SR" | "SJ" | "SZ" | "SE" | "CH" | "TW" | "TJ" | "TZ" | "TH" | "TG" | "TO" | "TT" | "TN" | "TR" | "TM" | "UM" | "VI" | "UG" | "UA" | "AE" | "GB" | "US" | "UZ" | "VU" | "VE" | "VN" | "WF" | "EH" | "YE" | "ZM" | "ZW", ...("AF" | "AL" | "DZ" | "AS" | "AD" | "AO" | "AG" | "AR" | "AM" | "AW" | "AU" | "AT" | "AZ" | "BS" | "BH" | "BD" | "BB" | "BY" | "BE" | "BZ" | "BJ" | "BO" | "BQ" | "BA" | "BW" | "BR" | "IO" | "VG" | "BG" | "BF" | "BI" | "KH" | "CM" | "CA" | "CV" | "CF" | "TD" | "CL" | "CN" | "CO" | "KM" | "CK" | "CR" | "HR" | "CW" | "CY" | "CZ" | "CD" | "DK" | "DJ" | "DM" | "DO" | "TL" | "EC" | "EG" | "SV" | "GQ" | "ER" | "EE" | "ET" | "FO" | "FJ" | "FI" | "FR" | "GF" | "PF" | "GA" | "GM" | "GE" | "DE" | "GH" | "GR" | "GD" | "GP" | "GU" | "GT" | "GN" | "GW" | "GY" | "HT" | "HK" | "HN" | "HU" | "IS" | "IN" | "ID" | "IR" | "IQ" | "IE" | "IM" | "IL" | "IT" | "CI" | "JM" | "JP" | "JE" | "JO" | "KZ" | "KE" | "KI" | "XK" | "KW" | "KG" | "LA" | "LV" | "LB" | "LS" | "LR" | "LI" | "LT" | "LU" | "MK" | "MG" | "MW" | "MY" | "MV" | "ML" | "MT" | "MQ" | "MR" | "MU" | "MX" | "FM" | "MD" | "MC" | "MN" | "ME" | "MS" | "MA" | "MZ" | "NA" | "NP" | "NL" | "NZ" | "NI" | "NE" | "NG" | "NU" | "NF" | "KP" | "NO" | "OM" | "PK" | "PS" | "PA" | "PG" | "PY" | "PE" | "PH" | "PL" | "PT" | "PR" | "QA" | "CG" | "RE" | "RO" | "RU" | "RW" | "BL" | "KN" | "LC" | "MF" | "VC" | "WS" | "SM" | "SA" | "SN" | "RS" | "SC" | "SL" | "SG" | "SX" | "SK" | "SI" | "SO" | "ZA" | "KR" | "SS" | "ES" | "LK" | "SD" | "SR" | "SJ" | "SZ" | "SE" | "CH" | "TW" | "TJ" | "TZ" | "TH" | "TG" | "TO" | "TT" | "TN" | "TR" | "TM" | "UM" | "VI" | "UG" | "UA" | "AE" | "GB" | "US" | "UZ" | "VU" | "VE" | "VN" | "WF" | "EH" | "YE" | "ZM" | "ZW")[]]>>;
836
+ countryCode: drizzle_orm.NotNull<drizzle_orm_sqlite_core.SQLiteTextBuilder<["IM" | "AF" | "AL" | "DZ" | "AS" | "AD" | "AO" | "AG" | "AR" | "AM" | "AW" | "AU" | "AT" | "AZ" | "BS" | "BH" | "BD" | "BB" | "BY" | "BE" | "BZ" | "BJ" | "BO" | "BQ" | "BA" | "BW" | "BR" | "IO" | "VG" | "BG" | "BF" | "BI" | "KH" | "CM" | "CA" | "CV" | "CF" | "TD" | "CL" | "CN" | "CO" | "KM" | "CK" | "CR" | "HR" | "CW" | "CY" | "CZ" | "CD" | "DK" | "DJ" | "DM" | "DO" | "TL" | "EC" | "EG" | "SV" | "GQ" | "ER" | "EE" | "ET" | "FO" | "FJ" | "FI" | "FR" | "GF" | "PF" | "GA" | "GM" | "GE" | "DE" | "GH" | "GR" | "GD" | "GP" | "GU" | "GT" | "GN" | "GW" | "GY" | "HT" | "HK" | "HN" | "HU" | "IS" | "IN" | "ID" | "IR" | "IQ" | "IE" | "IL" | "IT" | "CI" | "JM" | "JP" | "JE" | "JO" | "KZ" | "KE" | "KI" | "XK" | "KW" | "KG" | "LA" | "LV" | "LB" | "LS" | "LR" | "LI" | "LT" | "LU" | "MK" | "MG" | "MW" | "MY" | "MV" | "ML" | "MT" | "MQ" | "MR" | "MU" | "MX" | "FM" | "MD" | "MC" | "MN" | "ME" | "MS" | "MA" | "MZ" | "NA" | "NP" | "NL" | "NZ" | "NI" | "NE" | "NG" | "NU" | "NF" | "KP" | "NO" | "OM" | "PK" | "PS" | "PA" | "PG" | "PY" | "PE" | "PH" | "PL" | "PT" | "PR" | "QA" | "CG" | "RE" | "RO" | "RU" | "RW" | "BL" | "KN" | "LC" | "MF" | "VC" | "WS" | "SM" | "SA" | "SN" | "RS" | "SC" | "SL" | "SG" | "SX" | "SK" | "SI" | "SO" | "ZA" | "KR" | "SS" | "ES" | "LK" | "SD" | "SR" | "SJ" | "SZ" | "SE" | "CH" | "TW" | "TJ" | "TZ" | "TH" | "TG" | "TO" | "TT" | "TN" | "TR" | "TM" | "UM" | "VI" | "UG" | "UA" | "AE" | "GB" | "US" | "UZ" | "VU" | "VE" | "VN" | "WF" | "EH" | "YE" | "ZM" | "ZW", ...("IM" | "AF" | "AL" | "DZ" | "AS" | "AD" | "AO" | "AG" | "AR" | "AM" | "AW" | "AU" | "AT" | "AZ" | "BS" | "BH" | "BD" | "BB" | "BY" | "BE" | "BZ" | "BJ" | "BO" | "BQ" | "BA" | "BW" | "BR" | "IO" | "VG" | "BG" | "BF" | "BI" | "KH" | "CM" | "CA" | "CV" | "CF" | "TD" | "CL" | "CN" | "CO" | "KM" | "CK" | "CR" | "HR" | "CW" | "CY" | "CZ" | "CD" | "DK" | "DJ" | "DM" | "DO" | "TL" | "EC" | "EG" | "SV" | "GQ" | "ER" | "EE" | "ET" | "FO" | "FJ" | "FI" | "FR" | "GF" | "PF" | "GA" | "GM" | "GE" | "DE" | "GH" | "GR" | "GD" | "GP" | "GU" | "GT" | "GN" | "GW" | "GY" | "HT" | "HK" | "HN" | "HU" | "IS" | "IN" | "ID" | "IR" | "IQ" | "IE" | "IL" | "IT" | "CI" | "JM" | "JP" | "JE" | "JO" | "KZ" | "KE" | "KI" | "XK" | "KW" | "KG" | "LA" | "LV" | "LB" | "LS" | "LR" | "LI" | "LT" | "LU" | "MK" | "MG" | "MW" | "MY" | "MV" | "ML" | "MT" | "MQ" | "MR" | "MU" | "MX" | "FM" | "MD" | "MC" | "MN" | "ME" | "MS" | "MA" | "MZ" | "NA" | "NP" | "NL" | "NZ" | "NI" | "NE" | "NG" | "NU" | "NF" | "KP" | "NO" | "OM" | "PK" | "PS" | "PA" | "PG" | "PY" | "PE" | "PH" | "PL" | "PT" | "PR" | "QA" | "CG" | "RE" | "RO" | "RU" | "RW" | "BL" | "KN" | "LC" | "MF" | "VC" | "WS" | "SM" | "SA" | "SN" | "RS" | "SC" | "SL" | "SG" | "SX" | "SK" | "SI" | "SO" | "ZA" | "KR" | "SS" | "ES" | "LK" | "SD" | "SR" | "SJ" | "SZ" | "SE" | "CH" | "TW" | "TJ" | "TZ" | "TH" | "TG" | "TO" | "TT" | "TN" | "TR" | "TM" | "UM" | "VI" | "UG" | "UA" | "AE" | "GB" | "US" | "UZ" | "VU" | "VE" | "VN" | "WF" | "EH" | "YE" | "ZM" | "ZW")[]]>>;
837
837
  routingNumber: drizzle_orm_sqlite_core.SQLiteTextBuilder<[string, ...string[]]>;
838
838
  sortCode: drizzle_orm_sqlite_core.SQLiteTextBuilder<[string, ...string[]]>;
839
839
  clabe: drizzle_orm_sqlite_core.SQLiteTextBuilder<[string, ...string[]]>;
@@ -1152,6 +1152,10 @@ type AuditLogWriter<TAuditAction = string> = (logs: AuditLogPayload<TAuditAction
1152
1152
  */
1153
1153
  declare function createAuditLogWriter<TAuditAction = string>(table: AuditLogTable): AuditLogWriter<TAuditAction>;
1154
1154
 
1155
+ declare const validateBearerScheme: (header: string) => boolean;
1156
+ declare const extractBearerToken: (header: string) => string;
1157
+ declare const validateBearerToken: (bearerToken: string) => boolean;
1158
+
1155
1159
  declare function durableObjectNamespaceIdFromName(uniqueKey: string, name: string): string;
1156
1160
  declare const getLocalD1DatabaseIdFromWrangler: () => string | undefined;
1157
1161
  declare const getD1Credentials: () => Promise<{
@@ -1292,14 +1296,21 @@ type DlqAlert = {
1292
1296
  subject: string;
1293
1297
  text: string;
1294
1298
  };
1299
+ /** Minimal shape of a dead-lettered message used to build a safe alert. */
1300
+ type DlqMessageInfo = {
1301
+ id?: string;
1302
+ attempts?: number;
1303
+ body: unknown;
1304
+ };
1295
1305
  /**
1296
- * Builds the alert subject + plain-text body summarizing the dead-lettered
1297
- * messages. Bodies are stringified defensively — DLQ messages may come from any
1298
- * consumed queue, so no shape is assumed.
1306
+ * Builds the alert subject + plain-text body for dead-lettered messages.
1307
+ *
1308
+ * SAFETY: emits only non-sensitive identifiers (`eventType`, `eventSignal`,
1309
+ * `metadata.entityId`/`correlationId`, message `id`, `attempts`) — never the
1310
+ * raw payload, which for FX/payment events holds PII and financial data. Use
1311
+ * the identifiers to look the full record up via access-controlled tooling.
1299
1312
  */
1300
- declare function buildDlqAlert(queueName: string, messages: ReadonlyArray<{
1301
- body: unknown;
1302
- }>): DlqAlert;
1313
+ declare function buildDlqAlert(queueName: string, messages: ReadonlyArray<DlqMessageInfo>): DlqAlert;
1303
1314
  type HandleDlqBatchOptions = {
1304
1315
  /** Comma-separated recipient list (e.g. from an env var). */
1305
1316
  recipientsRaw: string | undefined;
@@ -1315,6 +1326,12 @@ type HandleDlqBatchOptions = {
1315
1326
  }) => Promise<{
1316
1327
  error?: unknown;
1317
1328
  }>;
1329
+ /**
1330
+ * Optional custom alert formatter. Defaults to `buildDlqAlert` (safe —
1331
+ * identifiers only). Override only if you deliberately need a different
1332
+ * format; take care not to include sensitive payload.
1333
+ */
1334
+ formatAlert?: (queueName: string, messages: ReadonlyArray<DlqMessageInfo>) => DlqAlert;
1318
1335
  /** Alert immediately once a batch reaches this size. Default 50. */
1319
1336
  minSize?: number;
1320
1337
  /** Min seconds between alerts for the same queue while batches are small. Default 21600. */
@@ -1488,5 +1505,5 @@ interface WithRetryCounterOptions {
1488
1505
  type AsyncMethod<TArgs extends unknown[] = unknown[], TResult = unknown> = (...args: TArgs) => Promise<TResult>;
1489
1506
  declare function cloudflareQueue<TArgs extends unknown[] = unknown[], TResult = unknown>(options: WithRetryCounterOptions): (target: unknown, propertyKey: string | symbol, descriptor: TypedPropertyDescriptor<AsyncMethod<TArgs, TResult>>) => void;
1490
1507
 
1491
- export { DLQ_ALERT_DEFAULT_MAX_INTERVAL, DLQ_ALERT_DEFAULT_MIN_SIZE, DatabaseTransaction, ENVIRONMENT, RPCResponse, USER_ROLES, action, asNonEmpty, bankAccount, bankAccountMetadataSchema, base, bicSchema, buildDlqAlert, buildMultiFilterConditions, buildRangeFilterConditions, buildSearchConditions, calculateExponentialBackoff, chunkQueueMessages, cloudflareQueue, composeWranglerBase, createAuditLogWriter, createInsertSchema, createInternalError, createPatchSchema, createSelectSchema, createUpdateSchema, defineCommand, derivePortFromId, develitWorker, durableObjectNamespaceIdFromName, first, firstOrError, getD1Credentials, getDrizzleD1Config, getLocalD1DatabaseIdFromWrangler, getSecret, handleAction, handleDlqBatch, ibanSchema, isDlqQueue, isInternalError, nullToOptional, optionalToNull, paginationQuerySchema, paginationSchema, parseDlqAlertRecipients, pushToQueue, queryInChunks, redact, resolveColumn, service, shouldAlertDlq, structuredAddressSchema, useFetch, useResult, useResultSync, uuidv4, uuidv5, workflowInstanceStatusSchema };
1492
- export type { ActionExecution, ActionHandlerOptions, AuditLogWriter, BankAccountMetadata, BaseEvent, BuildSearchOptions, Command, CommandLogPayload, DevelitWorkerMethods, DlqAlert, Environment, GatewayResponse, HandleDlqBatchOptions, IRPCResponse, IdempotencyContextVariables, IdentityContextVariables, InternalError, InternalErrorResponseStatus, Project, RequestLog, ResponseLog, ShouldAlertDlqParams, StructuredAddress, UserRole, ValidatedInput, WorkflowInstanceStatus };
1508
+ export { DLQ_ALERT_DEFAULT_MAX_INTERVAL, DLQ_ALERT_DEFAULT_MIN_SIZE, DatabaseTransaction, ENVIRONMENT, RPCResponse, USER_ROLES, action, asNonEmpty, bankAccount, bankAccountMetadataSchema, base, bicSchema, buildDlqAlert, buildMultiFilterConditions, buildRangeFilterConditions, buildSearchConditions, calculateExponentialBackoff, chunkQueueMessages, cloudflareQueue, composeWranglerBase, createAuditLogWriter, createInsertSchema, createInternalError, createPatchSchema, createSelectSchema, createUpdateSchema, defineCommand, derivePortFromId, develitWorker, durableObjectNamespaceIdFromName, extractBearerToken, first, firstOrError, getD1Credentials, getDrizzleD1Config, getLocalD1DatabaseIdFromWrangler, getSecret, handleAction, handleDlqBatch, ibanSchema, isDlqQueue, isInternalError, nullToOptional, optionalToNull, paginationQuerySchema, paginationSchema, parseDlqAlertRecipients, pushToQueue, queryInChunks, redact, resolveColumn, service, shouldAlertDlq, structuredAddressSchema, useFetch, useResult, useResultSync, uuidv4, uuidv5, validateBearerScheme, validateBearerToken, workflowInstanceStatusSchema };
1509
+ export type { ActionExecution, ActionHandlerOptions, AuditLogWriter, BankAccountMetadata, BaseEvent, BuildSearchOptions, Command, CommandLogPayload, DevelitWorkerMethods, DlqAlert, DlqMessageInfo, Environment, GatewayResponse, HandleDlqBatchOptions, IRPCResponse, IdempotencyContextVariables, IdentityContextVariables, InternalError, InternalErrorResponseStatus, Project, RequestLog, ResponseLog, ShouldAlertDlqParams, StructuredAddress, UserRole, ValidatedInput, WorkflowInstanceStatus };
package/dist/index.d.ts CHANGED
@@ -40,6 +40,7 @@ declare const structuredAddressSchema: z$1.ZodObject<{
40
40
  city: z$1.ZodOptional<z$1.ZodString>;
41
41
  postalCode: z$1.ZodOptional<z$1.ZodString>;
42
42
  countryCode: z$1.ZodOptional<z$1.ZodEnum<{
43
+ IM: "IM";
43
44
  AF: "AF";
44
45
  AL: "AL";
45
46
  DZ: "DZ";
@@ -129,7 +130,6 @@ declare const structuredAddressSchema: z$1.ZodObject<{
129
130
  IR: "IR";
130
131
  IQ: "IQ";
131
132
  IE: "IE";
132
- IM: "IM";
133
133
  IL: "IL";
134
134
  IT: "IT";
135
135
  CI: "CI";
@@ -330,6 +330,7 @@ declare const bankAccountMetadataSchema: z$1.ZodObject<{
330
330
  city: z$1.ZodOptional<z$1.ZodString>;
331
331
  postalCode: z$1.ZodOptional<z$1.ZodString>;
332
332
  countryCode: z$1.ZodOptional<z$1.ZodEnum<{
333
+ IM: "IM";
333
334
  AF: "AF";
334
335
  AL: "AL";
335
336
  DZ: "DZ";
@@ -419,7 +420,6 @@ declare const bankAccountMetadataSchema: z$1.ZodObject<{
419
420
  IR: "IR";
420
421
  IQ: "IQ";
421
422
  IE: "IE";
422
- IM: "IM";
423
423
  IL: "IL";
424
424
  IT: "IT";
425
425
  CI: "CI";
@@ -602,6 +602,7 @@ declare const bankAccountMetadataSchema: z$1.ZodObject<{
602
602
  AVAX: "AVAX";
603
603
  }>>;
604
604
  countryCode: z$1.ZodOptional<z$1.ZodEnum<{
605
+ IM: "IM";
605
606
  AF: "AF";
606
607
  AL: "AL";
607
608
  DZ: "DZ";
@@ -691,7 +692,6 @@ declare const bankAccountMetadataSchema: z$1.ZodObject<{
691
692
  IR: "IR";
692
693
  IQ: "IQ";
693
694
  IE: "IE";
694
- IM: "IM";
695
695
  IL: "IL";
696
696
  IT: "IT";
697
697
  CI: "CI";
@@ -833,7 +833,7 @@ declare const bankAccount: {
833
833
  swiftBic: drizzle_orm_sqlite_core.SQLiteTextBuilder<[string, ...string[]]>;
834
834
  bicCor: drizzle_orm_sqlite_core.SQLiteTextBuilder<[string, ...string[]]>;
835
835
  currency: drizzle_orm.NotNull<drizzle_orm_sqlite_core.SQLiteTextBuilder<["CZK" | "EUR" | "USD" | "PLN" | "RON" | "GBP" | "RUB" | "HUF" | "CHF" | "DKK" | "SEK" | "HRK" | "NOK" | "BGN" | "TRY" | "AUD" | "CAD" | "JPY" | "CNY" | "INR" | "BRL" | "MXN" | "ZAR" | "SGD" | "HKD" | "KRW" | "MYR" | "THB" | "IDR" | "PHP" | "AED" | "SAR" | "ILS" | "EGP" | "NGN" | "PKR" | "COP" | "CLP" | "PEN" | "VND" | "KZT" | "UAH" | "BTC" | "ETH" | "ADA" | "DOT" | "ATOM" | "XRP" | "LTC" | "SOL" | "DOGE" | "MATIC" | "AVAX", ...("CZK" | "EUR" | "USD" | "PLN" | "RON" | "GBP" | "RUB" | "HUF" | "CHF" | "DKK" | "SEK" | "HRK" | "NOK" | "BGN" | "TRY" | "AUD" | "CAD" | "JPY" | "CNY" | "INR" | "BRL" | "MXN" | "ZAR" | "SGD" | "HKD" | "KRW" | "MYR" | "THB" | "IDR" | "PHP" | "AED" | "SAR" | "ILS" | "EGP" | "NGN" | "PKR" | "COP" | "CLP" | "PEN" | "VND" | "KZT" | "UAH" | "BTC" | "ETH" | "ADA" | "DOT" | "ATOM" | "XRP" | "LTC" | "SOL" | "DOGE" | "MATIC" | "AVAX")[]]>>;
836
- countryCode: drizzle_orm.NotNull<drizzle_orm_sqlite_core.SQLiteTextBuilder<["AF" | "AL" | "DZ" | "AS" | "AD" | "AO" | "AG" | "AR" | "AM" | "AW" | "AU" | "AT" | "AZ" | "BS" | "BH" | "BD" | "BB" | "BY" | "BE" | "BZ" | "BJ" | "BO" | "BQ" | "BA" | "BW" | "BR" | "IO" | "VG" | "BG" | "BF" | "BI" | "KH" | "CM" | "CA" | "CV" | "CF" | "TD" | "CL" | "CN" | "CO" | "KM" | "CK" | "CR" | "HR" | "CW" | "CY" | "CZ" | "CD" | "DK" | "DJ" | "DM" | "DO" | "TL" | "EC" | "EG" | "SV" | "GQ" | "ER" | "EE" | "ET" | "FO" | "FJ" | "FI" | "FR" | "GF" | "PF" | "GA" | "GM" | "GE" | "DE" | "GH" | "GR" | "GD" | "GP" | "GU" | "GT" | "GN" | "GW" | "GY" | "HT" | "HK" | "HN" | "HU" | "IS" | "IN" | "ID" | "IR" | "IQ" | "IE" | "IM" | "IL" | "IT" | "CI" | "JM" | "JP" | "JE" | "JO" | "KZ" | "KE" | "KI" | "XK" | "KW" | "KG" | "LA" | "LV" | "LB" | "LS" | "LR" | "LI" | "LT" | "LU" | "MK" | "MG" | "MW" | "MY" | "MV" | "ML" | "MT" | "MQ" | "MR" | "MU" | "MX" | "FM" | "MD" | "MC" | "MN" | "ME" | "MS" | "MA" | "MZ" | "NA" | "NP" | "NL" | "NZ" | "NI" | "NE" | "NG" | "NU" | "NF" | "KP" | "NO" | "OM" | "PK" | "PS" | "PA" | "PG" | "PY" | "PE" | "PH" | "PL" | "PT" | "PR" | "QA" | "CG" | "RE" | "RO" | "RU" | "RW" | "BL" | "KN" | "LC" | "MF" | "VC" | "WS" | "SM" | "SA" | "SN" | "RS" | "SC" | "SL" | "SG" | "SX" | "SK" | "SI" | "SO" | "ZA" | "KR" | "SS" | "ES" | "LK" | "SD" | "SR" | "SJ" | "SZ" | "SE" | "CH" | "TW" | "TJ" | "TZ" | "TH" | "TG" | "TO" | "TT" | "TN" | "TR" | "TM" | "UM" | "VI" | "UG" | "UA" | "AE" | "GB" | "US" | "UZ" | "VU" | "VE" | "VN" | "WF" | "EH" | "YE" | "ZM" | "ZW", ...("AF" | "AL" | "DZ" | "AS" | "AD" | "AO" | "AG" | "AR" | "AM" | "AW" | "AU" | "AT" | "AZ" | "BS" | "BH" | "BD" | "BB" | "BY" | "BE" | "BZ" | "BJ" | "BO" | "BQ" | "BA" | "BW" | "BR" | "IO" | "VG" | "BG" | "BF" | "BI" | "KH" | "CM" | "CA" | "CV" | "CF" | "TD" | "CL" | "CN" | "CO" | "KM" | "CK" | "CR" | "HR" | "CW" | "CY" | "CZ" | "CD" | "DK" | "DJ" | "DM" | "DO" | "TL" | "EC" | "EG" | "SV" | "GQ" | "ER" | "EE" | "ET" | "FO" | "FJ" | "FI" | "FR" | "GF" | "PF" | "GA" | "GM" | "GE" | "DE" | "GH" | "GR" | "GD" | "GP" | "GU" | "GT" | "GN" | "GW" | "GY" | "HT" | "HK" | "HN" | "HU" | "IS" | "IN" | "ID" | "IR" | "IQ" | "IE" | "IM" | "IL" | "IT" | "CI" | "JM" | "JP" | "JE" | "JO" | "KZ" | "KE" | "KI" | "XK" | "KW" | "KG" | "LA" | "LV" | "LB" | "LS" | "LR" | "LI" | "LT" | "LU" | "MK" | "MG" | "MW" | "MY" | "MV" | "ML" | "MT" | "MQ" | "MR" | "MU" | "MX" | "FM" | "MD" | "MC" | "MN" | "ME" | "MS" | "MA" | "MZ" | "NA" | "NP" | "NL" | "NZ" | "NI" | "NE" | "NG" | "NU" | "NF" | "KP" | "NO" | "OM" | "PK" | "PS" | "PA" | "PG" | "PY" | "PE" | "PH" | "PL" | "PT" | "PR" | "QA" | "CG" | "RE" | "RO" | "RU" | "RW" | "BL" | "KN" | "LC" | "MF" | "VC" | "WS" | "SM" | "SA" | "SN" | "RS" | "SC" | "SL" | "SG" | "SX" | "SK" | "SI" | "SO" | "ZA" | "KR" | "SS" | "ES" | "LK" | "SD" | "SR" | "SJ" | "SZ" | "SE" | "CH" | "TW" | "TJ" | "TZ" | "TH" | "TG" | "TO" | "TT" | "TN" | "TR" | "TM" | "UM" | "VI" | "UG" | "UA" | "AE" | "GB" | "US" | "UZ" | "VU" | "VE" | "VN" | "WF" | "EH" | "YE" | "ZM" | "ZW")[]]>>;
836
+ countryCode: drizzle_orm.NotNull<drizzle_orm_sqlite_core.SQLiteTextBuilder<["IM" | "AF" | "AL" | "DZ" | "AS" | "AD" | "AO" | "AG" | "AR" | "AM" | "AW" | "AU" | "AT" | "AZ" | "BS" | "BH" | "BD" | "BB" | "BY" | "BE" | "BZ" | "BJ" | "BO" | "BQ" | "BA" | "BW" | "BR" | "IO" | "VG" | "BG" | "BF" | "BI" | "KH" | "CM" | "CA" | "CV" | "CF" | "TD" | "CL" | "CN" | "CO" | "KM" | "CK" | "CR" | "HR" | "CW" | "CY" | "CZ" | "CD" | "DK" | "DJ" | "DM" | "DO" | "TL" | "EC" | "EG" | "SV" | "GQ" | "ER" | "EE" | "ET" | "FO" | "FJ" | "FI" | "FR" | "GF" | "PF" | "GA" | "GM" | "GE" | "DE" | "GH" | "GR" | "GD" | "GP" | "GU" | "GT" | "GN" | "GW" | "GY" | "HT" | "HK" | "HN" | "HU" | "IS" | "IN" | "ID" | "IR" | "IQ" | "IE" | "IL" | "IT" | "CI" | "JM" | "JP" | "JE" | "JO" | "KZ" | "KE" | "KI" | "XK" | "KW" | "KG" | "LA" | "LV" | "LB" | "LS" | "LR" | "LI" | "LT" | "LU" | "MK" | "MG" | "MW" | "MY" | "MV" | "ML" | "MT" | "MQ" | "MR" | "MU" | "MX" | "FM" | "MD" | "MC" | "MN" | "ME" | "MS" | "MA" | "MZ" | "NA" | "NP" | "NL" | "NZ" | "NI" | "NE" | "NG" | "NU" | "NF" | "KP" | "NO" | "OM" | "PK" | "PS" | "PA" | "PG" | "PY" | "PE" | "PH" | "PL" | "PT" | "PR" | "QA" | "CG" | "RE" | "RO" | "RU" | "RW" | "BL" | "KN" | "LC" | "MF" | "VC" | "WS" | "SM" | "SA" | "SN" | "RS" | "SC" | "SL" | "SG" | "SX" | "SK" | "SI" | "SO" | "ZA" | "KR" | "SS" | "ES" | "LK" | "SD" | "SR" | "SJ" | "SZ" | "SE" | "CH" | "TW" | "TJ" | "TZ" | "TH" | "TG" | "TO" | "TT" | "TN" | "TR" | "TM" | "UM" | "VI" | "UG" | "UA" | "AE" | "GB" | "US" | "UZ" | "VU" | "VE" | "VN" | "WF" | "EH" | "YE" | "ZM" | "ZW", ...("IM" | "AF" | "AL" | "DZ" | "AS" | "AD" | "AO" | "AG" | "AR" | "AM" | "AW" | "AU" | "AT" | "AZ" | "BS" | "BH" | "BD" | "BB" | "BY" | "BE" | "BZ" | "BJ" | "BO" | "BQ" | "BA" | "BW" | "BR" | "IO" | "VG" | "BG" | "BF" | "BI" | "KH" | "CM" | "CA" | "CV" | "CF" | "TD" | "CL" | "CN" | "CO" | "KM" | "CK" | "CR" | "HR" | "CW" | "CY" | "CZ" | "CD" | "DK" | "DJ" | "DM" | "DO" | "TL" | "EC" | "EG" | "SV" | "GQ" | "ER" | "EE" | "ET" | "FO" | "FJ" | "FI" | "FR" | "GF" | "PF" | "GA" | "GM" | "GE" | "DE" | "GH" | "GR" | "GD" | "GP" | "GU" | "GT" | "GN" | "GW" | "GY" | "HT" | "HK" | "HN" | "HU" | "IS" | "IN" | "ID" | "IR" | "IQ" | "IE" | "IL" | "IT" | "CI" | "JM" | "JP" | "JE" | "JO" | "KZ" | "KE" | "KI" | "XK" | "KW" | "KG" | "LA" | "LV" | "LB" | "LS" | "LR" | "LI" | "LT" | "LU" | "MK" | "MG" | "MW" | "MY" | "MV" | "ML" | "MT" | "MQ" | "MR" | "MU" | "MX" | "FM" | "MD" | "MC" | "MN" | "ME" | "MS" | "MA" | "MZ" | "NA" | "NP" | "NL" | "NZ" | "NI" | "NE" | "NG" | "NU" | "NF" | "KP" | "NO" | "OM" | "PK" | "PS" | "PA" | "PG" | "PY" | "PE" | "PH" | "PL" | "PT" | "PR" | "QA" | "CG" | "RE" | "RO" | "RU" | "RW" | "BL" | "KN" | "LC" | "MF" | "VC" | "WS" | "SM" | "SA" | "SN" | "RS" | "SC" | "SL" | "SG" | "SX" | "SK" | "SI" | "SO" | "ZA" | "KR" | "SS" | "ES" | "LK" | "SD" | "SR" | "SJ" | "SZ" | "SE" | "CH" | "TW" | "TJ" | "TZ" | "TH" | "TG" | "TO" | "TT" | "TN" | "TR" | "TM" | "UM" | "VI" | "UG" | "UA" | "AE" | "GB" | "US" | "UZ" | "VU" | "VE" | "VN" | "WF" | "EH" | "YE" | "ZM" | "ZW")[]]>>;
837
837
  routingNumber: drizzle_orm_sqlite_core.SQLiteTextBuilder<[string, ...string[]]>;
838
838
  sortCode: drizzle_orm_sqlite_core.SQLiteTextBuilder<[string, ...string[]]>;
839
839
  clabe: drizzle_orm_sqlite_core.SQLiteTextBuilder<[string, ...string[]]>;
@@ -1152,6 +1152,10 @@ type AuditLogWriter<TAuditAction = string> = (logs: AuditLogPayload<TAuditAction
1152
1152
  */
1153
1153
  declare function createAuditLogWriter<TAuditAction = string>(table: AuditLogTable): AuditLogWriter<TAuditAction>;
1154
1154
 
1155
+ declare const validateBearerScheme: (header: string) => boolean;
1156
+ declare const extractBearerToken: (header: string) => string;
1157
+ declare const validateBearerToken: (bearerToken: string) => boolean;
1158
+
1155
1159
  declare function durableObjectNamespaceIdFromName(uniqueKey: string, name: string): string;
1156
1160
  declare const getLocalD1DatabaseIdFromWrangler: () => string | undefined;
1157
1161
  declare const getD1Credentials: () => Promise<{
@@ -1292,14 +1296,21 @@ type DlqAlert = {
1292
1296
  subject: string;
1293
1297
  text: string;
1294
1298
  };
1299
+ /** Minimal shape of a dead-lettered message used to build a safe alert. */
1300
+ type DlqMessageInfo = {
1301
+ id?: string;
1302
+ attempts?: number;
1303
+ body: unknown;
1304
+ };
1295
1305
  /**
1296
- * Builds the alert subject + plain-text body summarizing the dead-lettered
1297
- * messages. Bodies are stringified defensively — DLQ messages may come from any
1298
- * consumed queue, so no shape is assumed.
1306
+ * Builds the alert subject + plain-text body for dead-lettered messages.
1307
+ *
1308
+ * SAFETY: emits only non-sensitive identifiers (`eventType`, `eventSignal`,
1309
+ * `metadata.entityId`/`correlationId`, message `id`, `attempts`) — never the
1310
+ * raw payload, which for FX/payment events holds PII and financial data. Use
1311
+ * the identifiers to look the full record up via access-controlled tooling.
1299
1312
  */
1300
- declare function buildDlqAlert(queueName: string, messages: ReadonlyArray<{
1301
- body: unknown;
1302
- }>): DlqAlert;
1313
+ declare function buildDlqAlert(queueName: string, messages: ReadonlyArray<DlqMessageInfo>): DlqAlert;
1303
1314
  type HandleDlqBatchOptions = {
1304
1315
  /** Comma-separated recipient list (e.g. from an env var). */
1305
1316
  recipientsRaw: string | undefined;
@@ -1315,6 +1326,12 @@ type HandleDlqBatchOptions = {
1315
1326
  }) => Promise<{
1316
1327
  error?: unknown;
1317
1328
  }>;
1329
+ /**
1330
+ * Optional custom alert formatter. Defaults to `buildDlqAlert` (safe —
1331
+ * identifiers only). Override only if you deliberately need a different
1332
+ * format; take care not to include sensitive payload.
1333
+ */
1334
+ formatAlert?: (queueName: string, messages: ReadonlyArray<DlqMessageInfo>) => DlqAlert;
1318
1335
  /** Alert immediately once a batch reaches this size. Default 50. */
1319
1336
  minSize?: number;
1320
1337
  /** Min seconds between alerts for the same queue while batches are small. Default 21600. */
@@ -1488,5 +1505,5 @@ interface WithRetryCounterOptions {
1488
1505
  type AsyncMethod<TArgs extends unknown[] = unknown[], TResult = unknown> = (...args: TArgs) => Promise<TResult>;
1489
1506
  declare function cloudflareQueue<TArgs extends unknown[] = unknown[], TResult = unknown>(options: WithRetryCounterOptions): (target: unknown, propertyKey: string | symbol, descriptor: TypedPropertyDescriptor<AsyncMethod<TArgs, TResult>>) => void;
1490
1507
 
1491
- export { DLQ_ALERT_DEFAULT_MAX_INTERVAL, DLQ_ALERT_DEFAULT_MIN_SIZE, DatabaseTransaction, ENVIRONMENT, RPCResponse, USER_ROLES, action, asNonEmpty, bankAccount, bankAccountMetadataSchema, base, bicSchema, buildDlqAlert, buildMultiFilterConditions, buildRangeFilterConditions, buildSearchConditions, calculateExponentialBackoff, chunkQueueMessages, cloudflareQueue, composeWranglerBase, createAuditLogWriter, createInsertSchema, createInternalError, createPatchSchema, createSelectSchema, createUpdateSchema, defineCommand, derivePortFromId, develitWorker, durableObjectNamespaceIdFromName, first, firstOrError, getD1Credentials, getDrizzleD1Config, getLocalD1DatabaseIdFromWrangler, getSecret, handleAction, handleDlqBatch, ibanSchema, isDlqQueue, isInternalError, nullToOptional, optionalToNull, paginationQuerySchema, paginationSchema, parseDlqAlertRecipients, pushToQueue, queryInChunks, redact, resolveColumn, service, shouldAlertDlq, structuredAddressSchema, useFetch, useResult, useResultSync, uuidv4, uuidv5, workflowInstanceStatusSchema };
1492
- export type { ActionExecution, ActionHandlerOptions, AuditLogWriter, BankAccountMetadata, BaseEvent, BuildSearchOptions, Command, CommandLogPayload, DevelitWorkerMethods, DlqAlert, Environment, GatewayResponse, HandleDlqBatchOptions, IRPCResponse, IdempotencyContextVariables, IdentityContextVariables, InternalError, InternalErrorResponseStatus, Project, RequestLog, ResponseLog, ShouldAlertDlqParams, StructuredAddress, UserRole, ValidatedInput, WorkflowInstanceStatus };
1508
+ export { DLQ_ALERT_DEFAULT_MAX_INTERVAL, DLQ_ALERT_DEFAULT_MIN_SIZE, DatabaseTransaction, ENVIRONMENT, RPCResponse, USER_ROLES, action, asNonEmpty, bankAccount, bankAccountMetadataSchema, base, bicSchema, buildDlqAlert, buildMultiFilterConditions, buildRangeFilterConditions, buildSearchConditions, calculateExponentialBackoff, chunkQueueMessages, cloudflareQueue, composeWranglerBase, createAuditLogWriter, createInsertSchema, createInternalError, createPatchSchema, createSelectSchema, createUpdateSchema, defineCommand, derivePortFromId, develitWorker, durableObjectNamespaceIdFromName, extractBearerToken, first, firstOrError, getD1Credentials, getDrizzleD1Config, getLocalD1DatabaseIdFromWrangler, getSecret, handleAction, handleDlqBatch, ibanSchema, isDlqQueue, isInternalError, nullToOptional, optionalToNull, paginationQuerySchema, paginationSchema, parseDlqAlertRecipients, pushToQueue, queryInChunks, redact, resolveColumn, service, shouldAlertDlq, structuredAddressSchema, useFetch, useResult, useResultSync, uuidv4, uuidv5, validateBearerScheme, validateBearerToken, workflowInstanceStatusSchema };
1509
+ export type { ActionExecution, ActionHandlerOptions, AuditLogWriter, BankAccountMetadata, BaseEvent, BuildSearchOptions, Command, CommandLogPayload, DevelitWorkerMethods, DlqAlert, DlqMessageInfo, Environment, GatewayResponse, HandleDlqBatchOptions, IRPCResponse, IdempotencyContextVariables, IdentityContextVariables, InternalError, InternalErrorResponseStatus, Project, RequestLog, ResponseLog, ShouldAlertDlqParams, StructuredAddress, UserRole, ValidatedInput, WorkflowInstanceStatus };
package/dist/index.mjs CHANGED
@@ -1,5 +1,5 @@
1
- import { s as summarizeBinary, a as serializeLog } from './shared/backend-sdk.DANN3OYI.mjs';
2
- export { u as uuidv4, b as uuidv5 } from './shared/backend-sdk.DANN3OYI.mjs';
1
+ import { s as summarizeBinary, a as serializeLog } from './shared/backend-sdk.BFjyTkk2.mjs';
2
+ export { e as extractBearerToken, u as uuidv4, b as uuidv5, v as validateBearerScheme, c as validateBearerToken } from './shared/backend-sdk.BFjyTkk2.mjs';
3
3
  import { sql, inArray, eq, gte, lte, and, or } from 'drizzle-orm';
4
4
  import { text, integer } from 'drizzle-orm/sqlite-core';
5
5
  import { COUNTRY_CODES_2, CURRENCY_CODES, BANK_CODES } from '@develit-io/general-codes';
@@ -719,20 +719,29 @@ function shouldAlertDlq({
719
719
  const suppress = batchSize < minSize && secondsSinceLastAlert < maxInterval;
720
720
  return !suppress;
721
721
  }
722
+ const asString = (value) => typeof value === "string" ? value : void 0;
722
723
  function buildDlqAlert(queueName, messages) {
723
724
  const summary = messages.map((message, index) => {
724
- let serialized;
725
- try {
726
- serialized = JSON.stringify(message.body, null, 2);
727
- } catch {
728
- serialized = "[unserializable message body]";
729
- }
730
- return `#${index + 1}:
731
- ${serialized}`;
732
- }).join("\n\n");
725
+ const body = typeof message.body === "object" && message.body !== null ? message.body : void 0;
726
+ const metadata = body && typeof body.metadata === "object" && body.metadata !== null ? body.metadata : void 0;
727
+ const fields = [
728
+ ["eventType", asString(body?.eventType)],
729
+ ["eventSignal", asString(body?.eventSignal)],
730
+ ["entityId", asString(metadata?.entityId)],
731
+ ["correlationId", asString(metadata?.correlationId)],
732
+ ["id", message.id],
733
+ [
734
+ "attempts",
735
+ message.attempts === void 0 ? void 0 : String(message.attempts)
736
+ ]
737
+ ];
738
+ const known = fields.filter(([, value]) => value !== void 0);
739
+ const label = known.length ? known.map(([key, value]) => `${key}=${value}`).join(" ") : "(no safe identifiers available)";
740
+ return `#${index + 1} ${label}`;
741
+ }).join("\n");
733
742
  return {
734
743
  subject: `\u{1F534} DLQ events in ${queueName} (${messages.length})`,
735
- text: `${messages.length} dead-lettered message(s) on queue "${queueName}".
744
+ text: `${messages.length} dead-lettered message(s) on queue "${queueName}". Identifiers only \u2014 no payload.
736
745
 
737
746
  ${summary}`
738
747
  };
@@ -765,7 +774,10 @@ async function handleDlqBatch(batch, opts) {
765
774
  batch.ackAll();
766
775
  return;
767
776
  }
768
- const { subject, text } = buildDlqAlert(queueName, batch.messages);
777
+ const { subject, text } = (opts.formatAlert ?? buildDlqAlert)(
778
+ queueName,
779
+ batch.messages
780
+ );
769
781
  try {
770
782
  const { error } = await opts.sendAlert({ recipients, subject, text });
771
783
  if (error) throw error;
@@ -28,6 +28,7 @@ type AccessRequestResolver<TScope extends string = string> = ScopeCondition<TSco
28
28
  * @param options.errorMessage - Custom 403 error message.
29
29
  * @param Can be disabled by setting `MIDDLEWARE_ACCESS_DISABLED` env var.
30
30
  * @throws {HTTPException} 403 if the user does not have the required access.
31
+ * @throws {HTTPException} 503 if the RBAC service fails to verify the access.
31
32
  */
32
33
  declare const access: <TScope extends string = string>(accessRequests: AccessRequestResolver<TScope>, options?: AccessMiddlewareOptions) => MiddlewareHandler;
33
34
 
@@ -28,6 +28,7 @@ type AccessRequestResolver<TScope extends string = string> = ScopeCondition<TSco
28
28
  * @param options.errorMessage - Custom 403 error message.
29
29
  * @param Can be disabled by setting `MIDDLEWARE_ACCESS_DISABLED` env var.
30
30
  * @throws {HTTPException} 403 if the user does not have the required access.
31
+ * @throws {HTTPException} 503 if the RBAC service fails to verify the access.
31
32
  */
32
33
  declare const access: <TScope extends string = string>(accessRequests: AccessRequestResolver<TScope>, options?: AccessMiddlewareOptions) => MiddlewareHandler;
33
34
 
@@ -1,26 +1,16 @@
1
1
  import { createMiddleware } from 'hono/factory';
2
2
  import { HTTPException } from 'hono/http-exception';
3
- import { z } from 'zod';
3
+ import { v as validateBearerScheme, e as extractBearerToken, c as validateBearerToken, u as uuidv4 } from './shared/backend-sdk.BFjyTkk2.mjs';
4
4
  import 'cloudflare';
5
5
  import 'comment-json';
6
6
  import 'node:crypto';
7
7
  import 'node:fs';
8
8
  import 'node:path';
9
9
  import 'drizzle-orm';
10
- import { u as uuidv4 } from './shared/backend-sdk.DANN3OYI.mjs';
10
+ import 'zod';
11
11
  import { verifyPayloadSignature } from './utils/signature.util.mjs';
12
12
  import 'superjson';
13
13
 
14
- const validateBearerScheme = (header) => {
15
- return header.startsWith("Bearer ") && header.length > 7 && !header.slice(7).includes(" ");
16
- };
17
- const extractBearerToken = (header) => {
18
- return header.slice(7).trim();
19
- };
20
- const validateBearerToken = (bearerToken) => {
21
- return z.jwt().safeParse(bearerToken).success;
22
- };
23
-
24
14
  const logRequest = (log) => {
25
15
  console.log("REQUEST | An incoming request has been recorded.", log);
26
16
  };
@@ -44,7 +34,12 @@ const access = (accessRequests, options = {}) => {
44
34
  accessRequests: requests,
45
35
  jwt: identity
46
36
  });
47
- if (verifyError || !verifyData?.isVerified) {
37
+ if (verifyError || !verifyData) {
38
+ throw new HTTPException(503, {
39
+ message: "Access verification unavailable"
40
+ });
41
+ }
42
+ if (!verifyData.isVerified) {
48
43
  throw new HTTPException(403, {
49
44
  message: options.errorMessage || "Forbidden"
50
45
  });
@@ -1,3 +1,4 @@
1
+ import { z } from 'zod';
1
2
  import superjson from 'superjson';
2
3
 
3
4
  const uuidv4 = () => crypto.randomUUID();
@@ -60,6 +61,16 @@ function summarizeBinary(value) {
60
61
  return void 0;
61
62
  }
62
63
 
64
+ const validateBearerScheme = (header) => {
65
+ return header.startsWith("Bearer ") && header.length > 7 && !header.slice(7).includes(" ");
66
+ };
67
+ const extractBearerToken = (header) => {
68
+ return header.slice(7).trim();
69
+ };
70
+ const validateBearerToken = (bearerToken) => {
71
+ return z.jwt().safeParse(bearerToken).success;
72
+ };
73
+
63
74
  const DEFAULT_LOG_BOUND_LIMITS = {
64
75
  maxStringLength: 2048,
65
76
  maxArrayLength: 100,
@@ -158,4 +169,4 @@ function serializeLog(data, limits = DEFAULT_LOG_BOUND_LIMITS) {
158
169
  }
159
170
  }
160
171
 
161
- export { serializeLog as a, uuidv5 as b, summarizeBinary as s, uuidv4 as u };
172
+ export { serializeLog as a, uuidv5 as b, validateBearerToken as c, extractBearerToken as e, summarizeBinary as s, uuidv4 as u, validateBearerScheme as v };
package/package.json CHANGED
@@ -1,9 +1,13 @@
1
1
  {
2
2
  "name": "@develit-io/backend-sdk",
3
- "version": "12.4.1",
3
+ "version": "12.6.0",
4
4
  "description": "Develit Backend SDK",
5
5
  "author": "Develit.io",
6
6
  "license": "ISC",
7
+ "repository": {
8
+ "type": "git",
9
+ "url": "git+https://github.com/develit-io/develit-sdk.git"
10
+ },
7
11
  "type": "module",
8
12
  "scripts": {
9
13
  "build": "unbuild",
@@ -34,7 +38,7 @@
34
38
  "dist"
35
39
  ],
36
40
  "dependencies": {
37
- "@cloudflare/workers-types": "^4.20260217.0",
41
+ "@cloudflare/workers-types": "^4.20260217.0 || ^5.0.0",
38
42
  "cloudflare": "^5.2.0",
39
43
  "comment-json": "^4.5.1",
40
44
  "superjson": "^2.2.5"