@develit-io/backend-sdk 9.2.0 → 9.4.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
@@ -37,7 +37,7 @@ declare const bankAccount: {
37
37
  swiftBic: drizzle_orm_sqlite_core.SQLiteTextBuilderInitial<"swift_bic", [string, ...string[]], number | undefined>;
38
38
  bicCor: drizzle_orm_sqlite_core.SQLiteTextBuilderInitial<"bic_cor", [string, ...string[]], number | undefined>;
39
39
  currency: drizzle_orm.NotNull<drizzle_orm_sqlite_core.SQLiteTextBuilderInitial<"currency", ["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")[]], number | undefined>>;
40
- countryCode: drizzle_orm.NotNull<drizzle_orm_sqlite_core.SQLiteTextBuilderInitial<"country_code", ["IM" | "EC" | "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" | "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" | "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" | "UZ" | "VU" | "VE" | "VN" | "WF" | "EH" | "YE" | "ZM" | "ZW", ...("IM" | "EC" | "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" | "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" | "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" | "UZ" | "VU" | "VE" | "VN" | "WF" | "EH" | "YE" | "ZM" | "ZW")[]], number | undefined>>;
40
+ countryCode: drizzle_orm.NotNull<drizzle_orm_sqlite_core.SQLiteTextBuilderInitial<"country_code", ["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" | "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" | "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" | "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" | "UZ" | "VU" | "VE" | "VN" | "WF" | "EH" | "YE" | "ZM" | "ZW")[]], number | undefined>>;
41
41
  routingNumber: drizzle_orm_sqlite_core.SQLiteTextBuilderInitial<"routing_number", [string, ...string[]], number | undefined>;
42
42
  sortCode: drizzle_orm_sqlite_core.SQLiteTextBuilderInitial<"sort_code", [string, ...string[]], number | undefined>;
43
43
  clabe: drizzle_orm_sqlite_core.SQLiteTextBuilderInitial<"clabe", [string, ...string[]], number | undefined>;
@@ -192,7 +192,6 @@ declare const bankAccountMetadataSchema: z$1.ZodObject<{
192
192
  }>>;
193
193
  countryCode: z$1.ZodOptional<z$1.ZodEnum<{
194
194
  IM: "IM";
195
- EC: "EC";
196
195
  AF: "AF";
197
196
  AL: "AL";
198
197
  DZ: "DZ";
@@ -246,6 +245,7 @@ declare const bankAccountMetadataSchema: z$1.ZodObject<{
246
245
  DM: "DM";
247
246
  DO: "DO";
248
247
  TL: "TL";
248
+ EC: "EC";
249
249
  EG: "EG";
250
250
  SV: "SV";
251
251
  GQ: "GQ";
@@ -447,11 +447,14 @@ interface CommandItem<TAuditAction = string> {
447
447
  interface IdempotencyContextVariables {
448
448
  key: string;
449
449
  }
450
- interface UserContextVariables {
451
- email: string;
452
- role: string;
453
- organizationId: string;
454
- }
450
+ type IdentityContextVariables = {
451
+ user: {
452
+ id: string;
453
+ email: string;
454
+ role: string;
455
+ rawUserMetaData: string | null;
456
+ };
457
+ };
455
458
 
456
459
  /**
457
460
  * Utility type to infer possible relation includes (`with`) for a given table.
@@ -824,21 +827,6 @@ declare const useResultSync: <T>(fn: () => T) => Result<T>;
824
827
 
825
828
  declare const getSecret: (secretName: string, env: unknown) => Promise<string>;
826
829
 
827
- declare const createSignatureKeyPair: () => Promise<{
828
- publicKey: string;
829
- privateKey: string;
830
- }>;
831
- declare const signPayload: ({ payload, privateKey, }: {
832
- payload: string;
833
- privateKey: string;
834
- }) => Promise<string>;
835
- declare const verifyPayloadSignature: ({ signature, data, publicKey, algorithm, }: {
836
- signature: string;
837
- data: string;
838
- publicKey: string;
839
- algorithm?: "RSA" | "EC" | "HMAC";
840
- }) => Promise<boolean>;
841
-
842
830
  declare const service: (serviceName: string) => <T extends new (...args: any[]) => object>(constructor: T) => {
843
831
  new (...args: any[]): {
844
832
  name: string;
@@ -858,5 +846,5 @@ interface WithRetryCounterOptions {
858
846
  type AsyncMethod<TArgs extends unknown[] = unknown[], TResult = unknown> = (...args: TArgs) => Promise<TResult>;
859
847
  declare function cloudflareQueue<TArgs extends unknown[] = unknown[], TResult = unknown>(options: WithRetryCounterOptions): (target: unknown, propertyKey: string | symbol, descriptor: TypedPropertyDescriptor<AsyncMethod<TArgs, TResult>>) => void;
860
848
 
861
- export { DatabaseTransaction, ENVIRONMENT, RPCResponse, USER_ROLES, action, asNonEmpty, bankAccount, bankAccountMetadataSchema, base, bicSchema, buildMultiFilterConditions, buildRangeFilterConditions, buildSearchConditions, calculateExponentialBackoff, cloudflareQueue, composeWranglerBase, createAuditLogWriter, createInternalError, createSignatureKeyPair, defineCommand, derivePortFromId, develitWorker, durableObjectNamespaceIdFromName, first, firstOrError, getD1Credentials, getD1DatabaseIdFromWrangler, getDrizzleD1Config, getSecret, handleAction, ibanSchema, isInternalError, nullToOptional, optionalToNull, paginationQuerySchema, paginationSchema, resolveColumn, service, signPayload, useFetch, useResult, useResultSync, uuidv4, verifyPayloadSignature, workflowInstanceStatusSchema };
862
- export type { ActionExecution, ActionHandlerOptions, AuditLogWriter, BankAccountMetadata, BaseEvent, BuildSearchOptions, Command, CommandLogPayload, DevelitWorkerMethods, Environment, GatewayResponse, IRPCResponse, IdempotencyContextVariables, IncludeRelation, InferResultType, InternalError, InternalErrorResponseStatus, Project, RequestLog, ResponseLog, UserContextVariables, UserRole, ValidatedInput, WorkflowInstanceStatus };
849
+ export { DatabaseTransaction, ENVIRONMENT, RPCResponse, USER_ROLES, action, asNonEmpty, bankAccount, bankAccountMetadataSchema, base, bicSchema, buildMultiFilterConditions, buildRangeFilterConditions, buildSearchConditions, calculateExponentialBackoff, cloudflareQueue, composeWranglerBase, createAuditLogWriter, createInternalError, defineCommand, derivePortFromId, develitWorker, durableObjectNamespaceIdFromName, first, firstOrError, getD1Credentials, getD1DatabaseIdFromWrangler, getDrizzleD1Config, getSecret, handleAction, ibanSchema, isInternalError, nullToOptional, optionalToNull, paginationQuerySchema, paginationSchema, resolveColumn, service, useFetch, useResult, useResultSync, uuidv4, workflowInstanceStatusSchema };
850
+ export type { ActionExecution, ActionHandlerOptions, AuditLogWriter, BankAccountMetadata, BaseEvent, BuildSearchOptions, Command, CommandLogPayload, DevelitWorkerMethods, Environment, GatewayResponse, IRPCResponse, IdempotencyContextVariables, IdentityContextVariables, IncludeRelation, InferResultType, InternalError, InternalErrorResponseStatus, Project, RequestLog, ResponseLog, UserRole, ValidatedInput, WorkflowInstanceStatus };
package/dist/index.d.ts CHANGED
@@ -37,7 +37,7 @@ declare const bankAccount: {
37
37
  swiftBic: drizzle_orm_sqlite_core.SQLiteTextBuilderInitial<"swift_bic", [string, ...string[]], number | undefined>;
38
38
  bicCor: drizzle_orm_sqlite_core.SQLiteTextBuilderInitial<"bic_cor", [string, ...string[]], number | undefined>;
39
39
  currency: drizzle_orm.NotNull<drizzle_orm_sqlite_core.SQLiteTextBuilderInitial<"currency", ["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")[]], number | undefined>>;
40
- countryCode: drizzle_orm.NotNull<drizzle_orm_sqlite_core.SQLiteTextBuilderInitial<"country_code", ["IM" | "EC" | "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" | "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" | "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" | "UZ" | "VU" | "VE" | "VN" | "WF" | "EH" | "YE" | "ZM" | "ZW", ...("IM" | "EC" | "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" | "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" | "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" | "UZ" | "VU" | "VE" | "VN" | "WF" | "EH" | "YE" | "ZM" | "ZW")[]], number | undefined>>;
40
+ countryCode: drizzle_orm.NotNull<drizzle_orm_sqlite_core.SQLiteTextBuilderInitial<"country_code", ["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" | "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" | "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" | "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" | "UZ" | "VU" | "VE" | "VN" | "WF" | "EH" | "YE" | "ZM" | "ZW")[]], number | undefined>>;
41
41
  routingNumber: drizzle_orm_sqlite_core.SQLiteTextBuilderInitial<"routing_number", [string, ...string[]], number | undefined>;
42
42
  sortCode: drizzle_orm_sqlite_core.SQLiteTextBuilderInitial<"sort_code", [string, ...string[]], number | undefined>;
43
43
  clabe: drizzle_orm_sqlite_core.SQLiteTextBuilderInitial<"clabe", [string, ...string[]], number | undefined>;
@@ -192,7 +192,6 @@ declare const bankAccountMetadataSchema: z$1.ZodObject<{
192
192
  }>>;
193
193
  countryCode: z$1.ZodOptional<z$1.ZodEnum<{
194
194
  IM: "IM";
195
- EC: "EC";
196
195
  AF: "AF";
197
196
  AL: "AL";
198
197
  DZ: "DZ";
@@ -246,6 +245,7 @@ declare const bankAccountMetadataSchema: z$1.ZodObject<{
246
245
  DM: "DM";
247
246
  DO: "DO";
248
247
  TL: "TL";
248
+ EC: "EC";
249
249
  EG: "EG";
250
250
  SV: "SV";
251
251
  GQ: "GQ";
@@ -447,11 +447,14 @@ interface CommandItem<TAuditAction = string> {
447
447
  interface IdempotencyContextVariables {
448
448
  key: string;
449
449
  }
450
- interface UserContextVariables {
451
- email: string;
452
- role: string;
453
- organizationId: string;
454
- }
450
+ type IdentityContextVariables = {
451
+ user: {
452
+ id: string;
453
+ email: string;
454
+ role: string;
455
+ rawUserMetaData: string | null;
456
+ };
457
+ };
455
458
 
456
459
  /**
457
460
  * Utility type to infer possible relation includes (`with`) for a given table.
@@ -824,21 +827,6 @@ declare const useResultSync: <T>(fn: () => T) => Result<T>;
824
827
 
825
828
  declare const getSecret: (secretName: string, env: unknown) => Promise<string>;
826
829
 
827
- declare const createSignatureKeyPair: () => Promise<{
828
- publicKey: string;
829
- privateKey: string;
830
- }>;
831
- declare const signPayload: ({ payload, privateKey, }: {
832
- payload: string;
833
- privateKey: string;
834
- }) => Promise<string>;
835
- declare const verifyPayloadSignature: ({ signature, data, publicKey, algorithm, }: {
836
- signature: string;
837
- data: string;
838
- publicKey: string;
839
- algorithm?: "RSA" | "EC" | "HMAC";
840
- }) => Promise<boolean>;
841
-
842
830
  declare const service: (serviceName: string) => <T extends new (...args: any[]) => object>(constructor: T) => {
843
831
  new (...args: any[]): {
844
832
  name: string;
@@ -858,5 +846,5 @@ interface WithRetryCounterOptions {
858
846
  type AsyncMethod<TArgs extends unknown[] = unknown[], TResult = unknown> = (...args: TArgs) => Promise<TResult>;
859
847
  declare function cloudflareQueue<TArgs extends unknown[] = unknown[], TResult = unknown>(options: WithRetryCounterOptions): (target: unknown, propertyKey: string | symbol, descriptor: TypedPropertyDescriptor<AsyncMethod<TArgs, TResult>>) => void;
860
848
 
861
- export { DatabaseTransaction, ENVIRONMENT, RPCResponse, USER_ROLES, action, asNonEmpty, bankAccount, bankAccountMetadataSchema, base, bicSchema, buildMultiFilterConditions, buildRangeFilterConditions, buildSearchConditions, calculateExponentialBackoff, cloudflareQueue, composeWranglerBase, createAuditLogWriter, createInternalError, createSignatureKeyPair, defineCommand, derivePortFromId, develitWorker, durableObjectNamespaceIdFromName, first, firstOrError, getD1Credentials, getD1DatabaseIdFromWrangler, getDrizzleD1Config, getSecret, handleAction, ibanSchema, isInternalError, nullToOptional, optionalToNull, paginationQuerySchema, paginationSchema, resolveColumn, service, signPayload, useFetch, useResult, useResultSync, uuidv4, verifyPayloadSignature, workflowInstanceStatusSchema };
862
- export type { ActionExecution, ActionHandlerOptions, AuditLogWriter, BankAccountMetadata, BaseEvent, BuildSearchOptions, Command, CommandLogPayload, DevelitWorkerMethods, Environment, GatewayResponse, IRPCResponse, IdempotencyContextVariables, IncludeRelation, InferResultType, InternalError, InternalErrorResponseStatus, Project, RequestLog, ResponseLog, UserContextVariables, UserRole, ValidatedInput, WorkflowInstanceStatus };
849
+ export { DatabaseTransaction, ENVIRONMENT, RPCResponse, USER_ROLES, action, asNonEmpty, bankAccount, bankAccountMetadataSchema, base, bicSchema, buildMultiFilterConditions, buildRangeFilterConditions, buildSearchConditions, calculateExponentialBackoff, cloudflareQueue, composeWranglerBase, createAuditLogWriter, createInternalError, defineCommand, derivePortFromId, develitWorker, durableObjectNamespaceIdFromName, first, firstOrError, getD1Credentials, getD1DatabaseIdFromWrangler, getDrizzleD1Config, getSecret, handleAction, ibanSchema, isInternalError, nullToOptional, optionalToNull, paginationQuerySchema, paginationSchema, resolveColumn, service, useFetch, useResult, useResultSync, uuidv4, workflowInstanceStatusSchema };
850
+ export type { ActionExecution, ActionHandlerOptions, AuditLogWriter, BankAccountMetadata, BaseEvent, BuildSearchOptions, Command, CommandLogPayload, DevelitWorkerMethods, Environment, GatewayResponse, IRPCResponse, IdempotencyContextVariables, IdentityContextVariables, IncludeRelation, InferResultType, InternalError, InternalErrorResponseStatus, Project, RequestLog, ResponseLog, UserRole, ValidatedInput, WorkflowInstanceStatus };
package/dist/index.mjs CHANGED
@@ -1,4 +1,4 @@
1
- export { c as createSignatureKeyPair, s as signPayload, u as uuidv4, v as verifyPayloadSignature } from './shared/backend-sdk.Cp_yMf_u.mjs';
1
+ export { u as uuidv4 } from './shared/backend-sdk.ZjCbR507.mjs';
2
2
  import { sql, inArray, eq, gte, lte, and, or } from 'drizzle-orm';
3
3
  import { text, integer } from 'drizzle-orm/sqlite-core';
4
4
  import { COUNTRY_CODES_2, CURRENCY_CODES, BANK_CODES } from '@develit-io/general-codes';
@@ -1,5 +1,16 @@
1
1
  import { MiddlewareHandler } from 'hono/types';
2
2
 
3
+ interface AccessMiddlewareOptions {
4
+ errorMessage?: string;
5
+ }
6
+ interface AccessRequest<TScope extends string = string> {
7
+ scope: TScope;
8
+ resourceId?: string;
9
+ resourcePath?: string;
10
+ }
11
+ type AccessRequestResolver<TScope extends string = string> = AccessRequest<TScope>[] | ((context: unknown) => AccessRequest<TScope>[]);
12
+ declare const access: <TScope extends string = string>(accessRequests: AccessRequestResolver<TScope>, options?: AccessMiddlewareOptions) => MiddlewareHandler;
13
+
3
14
  declare const idempotency: () => MiddlewareHandler;
4
15
 
5
16
  declare const jwt: () => MiddlewareHandler;
@@ -10,4 +21,4 @@ declare const logger: () => MiddlewareHandler;
10
21
 
11
22
  declare const signature: () => MiddlewareHandler;
12
23
 
13
- export { idempotency, ip, jwt, logger, signature };
24
+ export { access, idempotency, ip, jwt, logger, signature };
@@ -1,5 +1,16 @@
1
1
  import { MiddlewareHandler } from 'hono/types';
2
2
 
3
+ interface AccessMiddlewareOptions {
4
+ errorMessage?: string;
5
+ }
6
+ interface AccessRequest<TScope extends string = string> {
7
+ scope: TScope;
8
+ resourceId?: string;
9
+ resourcePath?: string;
10
+ }
11
+ type AccessRequestResolver<TScope extends string = string> = AccessRequest<TScope>[] | ((context: unknown) => AccessRequest<TScope>[]);
12
+ declare const access: <TScope extends string = string>(accessRequests: AccessRequestResolver<TScope>, options?: AccessMiddlewareOptions) => MiddlewareHandler;
13
+
3
14
  declare const idempotency: () => MiddlewareHandler;
4
15
 
5
16
  declare const jwt: () => MiddlewareHandler;
@@ -10,4 +21,4 @@ declare const logger: () => MiddlewareHandler;
10
21
 
11
22
  declare const signature: () => MiddlewareHandler;
12
23
 
13
- export { idempotency, ip, jwt, logger, signature };
24
+ export { access, idempotency, ip, jwt, logger, signature };
@@ -7,7 +7,8 @@ import 'node:crypto';
7
7
  import 'node:path';
8
8
  import 'comment-json';
9
9
  import 'drizzle-orm';
10
- import { u as uuidv4, v as verifyPayloadSignature } from './shared/backend-sdk.Cp_yMf_u.mjs';
10
+ import { u as uuidv4 } from './shared/backend-sdk.ZjCbR507.mjs';
11
+ import { verifyPayloadSignature } from './utils/signature.util.mjs';
11
12
 
12
13
  const validateBearerScheme = (header) => {
13
14
  return header.startsWith("Bearer ") && header.length > 7 && !header.slice(7).includes(" ");
@@ -32,6 +33,26 @@ const getRequestUserAgent = (request) => {
32
33
  return request.header("user-agent") || "UNKNOWN";
33
34
  };
34
35
 
36
+ const access = (accessRequests, options = {}) => {
37
+ return createMiddleware(async (context, next) => {
38
+ if (!context.env.MIDDLEWARE_ACCESS_DISABLED) {
39
+ const identity = context.get("identity");
40
+ const requests = typeof accessRequests === "function" ? accessRequests(context) : accessRequests;
41
+ const { data: verifyData, error: verifyError } = await context.env.RBAC_SERVICE.verifyAccess({
42
+ userId: identity.user.id,
43
+ accessRequests: requests,
44
+ jwt: identity
45
+ });
46
+ if (verifyError || !verifyData?.isVerified) {
47
+ throw new HTTPException(404, {
48
+ message: options.errorMessage || "Forbidden"
49
+ });
50
+ }
51
+ }
52
+ await next();
53
+ });
54
+ };
55
+
35
56
  const idempotency = () => {
36
57
  return createMiddleware(async (context, next) => {
37
58
  if (!context.env.MIDDLEWARE_IDEMPOTENCY_DISABLED) {
@@ -93,17 +114,13 @@ const jwt = () => {
93
114
  }
94
115
  const rawUserMetaDataString = data.payload.user.rawUserMetaData;
95
116
  const rawUserMetaData = rawUserMetaDataString ? JSON.parse(rawUserMetaDataString) : null;
96
- const organizationId = rawUserMetaData?.organizationId ?? null;
97
- if (!organizationId) {
117
+ const identityId = rawUserMetaData.organizationId ?? rawUserMetaData.exchangeOfficeId;
118
+ if (!identityId) {
98
119
  throw new HTTPException(422, {
99
120
  message: "User data integrity check failed."
100
121
  });
101
122
  }
102
- context.set("user", {
103
- email: data.payload.user.email,
104
- role: data.payload.user.role,
105
- organizationId
106
- });
123
+ context.set("identity", data.payload);
107
124
  }
108
125
  await next();
109
126
  });
@@ -113,14 +130,17 @@ const ip = () => {
113
130
  return createMiddleware(async (context, next) => {
114
131
  if (!context.env.MIDDLEWARE_IP_DISABLED) {
115
132
  const requestIp = getRequestIpAddress(context.req);
116
- const user = context.get("user");
117
- if (!user.organizationId) {
133
+ const identityContext = context.get("identity");
134
+ const rawUserMetaDataString = identityContext.user.rawUserMetaData;
135
+ const rawUserMetaData = rawUserMetaDataString ? JSON.parse(rawUserMetaDataString) : null;
136
+ const organizationId = rawUserMetaData.organizationId;
137
+ if (!organizationId) {
118
138
  throw new HTTPException(401, {
119
139
  message: "Failed to retrieve request organization ID."
120
140
  });
121
141
  }
122
142
  const { data: organization, error } = await context.env.ORGANIZATION_SERVICE.getOrganization({
123
- organizationId: user.organizationId
143
+ organizationId
124
144
  });
125
145
  if (!organization || error) {
126
146
  throw new HTTPException(404, {
@@ -165,7 +185,15 @@ const logger = () => {
165
185
  const requestLog = await composeRequestLog(context.req);
166
186
  logRequest(requestLog);
167
187
  if (!context.env.MIDDLEWARE_LOGGER_AUDITLOG_DISABLED) {
168
- const userContext = context.get("user");
188
+ const identityContext = context.get("identity");
189
+ const rawUserMetaDataString = identityContext.user.rawUserMetaData;
190
+ const rawUserMetaData = rawUserMetaDataString ? JSON.parse(rawUserMetaDataString) : null;
191
+ const identityId = rawUserMetaData.organizationId ?? rawUserMetaData.exchangeOfficeId;
192
+ if (!identityId) {
193
+ throw new HTTPException(422, {
194
+ message: "User data integrity check failed."
195
+ });
196
+ }
169
197
  const requestId = uuidv4();
170
198
  context.set("auditLog", {
171
199
  requestId
@@ -175,8 +203,12 @@ const logger = () => {
175
203
  method: requestLog.method,
176
204
  path: requestLog.path,
177
205
  actor: {
178
- email: userContext?.email || "NOT_AUTHORIZED",
179
- organizationId: userContext?.organizationId || "NOT_AUTHORIZED"
206
+ email: identityContext.user.email || "NOT_AUTHORIZED",
207
+ ...rawUserMetaData.organizationId ? {
208
+ organizationId: rawUserMetaData.organizationId || "NOT_AUTHORIZED"
209
+ } : rawUserMetaData.organizationId ? {
210
+ exchangeOfficeId: rawUserMetaData.exchangeOfficeId || "NOT_AUTHORIZED"
211
+ } : null
180
212
  },
181
213
  metadata: {
182
214
  ip: getRequestIpAddress(context.req),
@@ -197,15 +229,27 @@ const logger = () => {
197
229
  );
198
230
  logResponse(responseLog);
199
231
  if (!context.env.MIDDLEWARE_LOGGER_AUDITLOG_DISABLED) {
200
- const userContext = context.get("user");
232
+ const identityContext = context.get("identity");
233
+ const rawUserMetaDataString = identityContext.user.rawUserMetaData;
234
+ const rawUserMetaData = rawUserMetaDataString ? JSON.parse(rawUserMetaDataString) : null;
235
+ const identityId = rawUserMetaData.organizationId ?? rawUserMetaData.exchangeOfficeId;
236
+ if (!identityId) {
237
+ throw new HTTPException(422, {
238
+ message: "User data integrity check failed."
239
+ });
240
+ }
201
241
  const auditLogContext = context.get("auditLog");
202
242
  await context.env.AUDITLOG_SERVICE.processLog({
203
243
  type: "RESPONSE",
204
244
  method: responseLog.method,
205
245
  path: responseLog.path,
206
246
  actor: {
207
- email: userContext?.email || "NOT_AUTHORIZED",
208
- organizationId: userContext?.organizationId || "NOT_AUTHORIZED"
247
+ email: identityContext.user.email || "NOT_AUTHORIZED",
248
+ ...rawUserMetaData.organizationId ? {
249
+ organizationId: rawUserMetaData.organizationId || "NOT_AUTHORIZED"
250
+ } : rawUserMetaData.organizationId ? {
251
+ exchangeOfficeId: rawUserMetaData.exchangeOfficeId || "NOT_AUTHORIZED"
252
+ } : null
209
253
  },
210
254
  metadata: {
211
255
  ip: getRequestIpAddress(context.req),
@@ -235,14 +279,17 @@ const signature = () => {
235
279
  });
236
280
  }
237
281
  const payload = JSON.stringify(await context.req.json().catch(() => null));
238
- const user = context.get("user");
239
- if (!user.organizationId) {
282
+ const identityContext = context.get("identity");
283
+ const rawUserMetaDataString = identityContext.user.rawUserMetaData;
284
+ const rawUserMetaData = rawUserMetaDataString ? JSON.parse(rawUserMetaDataString) : null;
285
+ const identityId = rawUserMetaData.organizationId ?? rawUserMetaData.exchangeOfficeId;
286
+ if (!identityId) {
240
287
  throw new HTTPException(401, {
241
- message: "Failed to retrieve request organization ID."
288
+ message: "Failed to retrieve request identity ID."
242
289
  });
243
290
  }
244
291
  const { data: organization, error } = await context.env.ORGANIZATION_SERVICE.getOrganization({
245
- organizationId: user.organizationId
292
+ organizationId: identityId
246
293
  });
247
294
  if (!organization || error) {
248
295
  throw new HTTPException(404, {
@@ -272,4 +319,4 @@ const signature = () => {
272
319
  });
273
320
  };
274
321
 
275
- export { idempotency, ip, jwt, logger, signature };
322
+ export { access, idempotency, ip, jwt, logger, signature };
@@ -0,0 +1,3 @@
1
+ const uuidv4 = () => crypto.randomUUID();
2
+
3
+ export { uuidv4 as u };
@@ -0,0 +1,26 @@
1
+ declare const signPayload: ({ payload, privateKey, }: {
2
+ payload: string;
3
+ privateKey: string;
4
+ }) => Promise<string>;
5
+
6
+ declare const createSignatureKeyPair: () => Promise<{
7
+ publicKey: string;
8
+ privateKey: string;
9
+ }>;
10
+ declare const algParams: {
11
+ [key: string]: {
12
+ name: string;
13
+ hash?: {
14
+ name: string;
15
+ };
16
+ namedCurve?: string;
17
+ };
18
+ };
19
+ declare const verifyPayloadSignature: ({ signature, data, publicKey, algorithm, }: {
20
+ signature: string;
21
+ data: string;
22
+ publicKey: string;
23
+ algorithm?: "RSA" | "EC" | "HMAC";
24
+ }) => Promise<boolean>;
25
+
26
+ export { algParams, createSignatureKeyPair, signPayload, verifyPayloadSignature };
@@ -0,0 +1,26 @@
1
+ declare const signPayload: ({ payload, privateKey, }: {
2
+ payload: string;
3
+ privateKey: string;
4
+ }) => Promise<string>;
5
+
6
+ declare const createSignatureKeyPair: () => Promise<{
7
+ publicKey: string;
8
+ privateKey: string;
9
+ }>;
10
+ declare const algParams: {
11
+ [key: string]: {
12
+ name: string;
13
+ hash?: {
14
+ name: string;
15
+ };
16
+ namedCurve?: string;
17
+ };
18
+ };
19
+ declare const verifyPayloadSignature: ({ signature, data, publicKey, algorithm, }: {
20
+ signature: string;
21
+ data: string;
22
+ publicKey: string;
23
+ algorithm?: "RSA" | "EC" | "HMAC";
24
+ }) => Promise<boolean>;
25
+
26
+ export { algParams, createSignatureKeyPair, signPayload, verifyPayloadSignature };
@@ -1,23 +1,3 @@
1
- const uuidv4 = () => crypto.randomUUID();
2
-
3
- const createSignatureKeyPair = async () => {
4
- const { publicKey, privateKey } = await crypto.subtle.generateKey(
5
- {
6
- name: "RSASSA-PKCS1-v1_5",
7
- modulusLength: 4096,
8
- publicExponent: new Uint8Array([1, 0, 1]),
9
- hash: "SHA-256"
10
- },
11
- true,
12
- ["sign", "verify"]
13
- );
14
- const exportedPublicKey = await crypto.subtle.exportKey("spki", publicKey);
15
- const exportedPrivateKey = await crypto.subtle.exportKey("pkcs8", privateKey);
16
- return {
17
- publicKey: Buffer.from(exportedPublicKey).toString("base64"),
18
- privateKey: Buffer.from(exportedPrivateKey).toString("base64")
19
- };
20
- };
21
1
  const signPayload = async ({
22
2
  payload,
23
3
  privateKey
@@ -49,6 +29,25 @@ const signPayload = async ({
49
29
  );
50
30
  return base64Signature;
51
31
  };
32
+
33
+ const createSignatureKeyPair = async () => {
34
+ const { publicKey, privateKey } = await crypto.subtle.generateKey(
35
+ {
36
+ name: "RSASSA-PKCS1-v1_5",
37
+ modulusLength: 4096,
38
+ publicExponent: new Uint8Array([1, 0, 1]),
39
+ hash: "SHA-256"
40
+ },
41
+ true,
42
+ ["sign", "verify"]
43
+ );
44
+ const exportedPublicKey = await crypto.subtle.exportKey("spki", publicKey);
45
+ const exportedPrivateKey = await crypto.subtle.exportKey("pkcs8", privateKey);
46
+ return {
47
+ publicKey: Buffer.from(exportedPublicKey).toString("base64"),
48
+ privateKey: Buffer.from(exportedPrivateKey).toString("base64")
49
+ };
50
+ };
52
51
  const algParams = {
53
52
  RSA: {
54
53
  name: "RSASSA-PKCS1-v1_5",
@@ -95,4 +94,4 @@ const verifyPayloadSignature = async ({
95
94
  return isValid;
96
95
  };
97
96
 
98
- export { createSignatureKeyPair as c, signPayload as s, uuidv4 as u, verifyPayloadSignature as v };
97
+ export { algParams, createSignatureKeyPair, signPayload, verifyPayloadSignature };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@develit-io/backend-sdk",
3
- "version": "9.2.0",
3
+ "version": "9.4.0",
4
4
  "description": "Develit Backend SDK",
5
5
  "author": "Develit.io",
6
6
  "license": "ISC",
@@ -23,6 +23,11 @@
23
23
  "import": "./dist/middlewares.mjs",
24
24
  "default": "./dist/middlewares.mjs"
25
25
  },
26
+ "./signature": {
27
+ "types": "./dist/utils/signature.util.d.ts",
28
+ "import": "./dist/utils/signature.util.mjs",
29
+ "default": "./dist/utils/signature.util.mjs"
30
+ },
26
31
  "./package.json": "./package.json"
27
32
  },
28
33
  "files": [
@@ -31,7 +36,7 @@
31
36
  "dependencies": {
32
37
  "@cloudflare/workers-types": "4.20251121.0",
33
38
  "comment-json": "^4.4.1",
34
- "drizzle-kit": "^0.31.6",
39
+ "drizzle-kit": "^0.31.8",
35
40
  "drizzle-orm": "^0.44.7",
36
41
  "superjson": "^2.2.5"
37
42
  },
@@ -41,7 +46,7 @@
41
46
  "zod": "^4.1.13"
42
47
  },
43
48
  "devDependencies": {
44
- "hono": "^4.10.4",
49
+ "hono": "^4.10.8",
45
50
  "zod": "^4.1.13"
46
51
  }
47
52
  }