@develit-io/backend-sdk 8.6.0 → 8.6.2
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 +7 -3
- package/dist/index.d.ts +7 -3
- package/dist/index.mjs +1 -1
- package/dist/middlewares.d.mts +4 -6
- package/dist/middlewares.d.ts +4 -6
- package/dist/middlewares.mjs +4 -7
- package/dist/shared/{backend-sdk.BUgF1b5c.mjs → backend-sdk.BRwKpes3.mjs} +19 -3
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -453,9 +453,9 @@ interface IdempotencyVariables {
|
|
|
453
453
|
key: string;
|
|
454
454
|
};
|
|
455
455
|
}
|
|
456
|
-
interface UserVariables
|
|
456
|
+
interface UserVariables {
|
|
457
457
|
user: AuthUser;
|
|
458
|
-
jwt:
|
|
458
|
+
jwt: unknown;
|
|
459
459
|
}
|
|
460
460
|
|
|
461
461
|
declare const paginationQuerySchema: z.$ZodObject<Readonly<Readonly<{
|
|
@@ -740,6 +740,10 @@ interface UseFetchOptions extends RequestInit {
|
|
|
740
740
|
}
|
|
741
741
|
declare function useFetch<T = unknown>(url: string, { parseAs, ...options }?: UseFetchOptions): Promise<Result<T>>;
|
|
742
742
|
|
|
743
|
+
declare const createSignatureKeyPair: () => Promise<{
|
|
744
|
+
publicKey: string;
|
|
745
|
+
privateKey: string;
|
|
746
|
+
}>;
|
|
743
747
|
declare const signPayload: ({ payload, privateKey, }: {
|
|
744
748
|
payload: string;
|
|
745
749
|
privateKey: string;
|
|
@@ -849,5 +853,5 @@ interface WithRetryCounterOptions {
|
|
|
849
853
|
type AsyncMethod<TArgs extends unknown[] = unknown[], TResult = unknown> = (...args: TArgs) => Promise<TResult>;
|
|
850
854
|
declare function cloudflareQueue<TArgs extends unknown[] = unknown[], TResult = unknown>(options: WithRetryCounterOptions): (target: unknown, propertyKey: string | symbol, descriptor: TypedPropertyDescriptor<AsyncMethod<TArgs, TResult>>) => void;
|
|
851
855
|
|
|
852
|
-
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, handleActionResponse, ibanSchema, isInternalError, nullToOptional, optionalToNull, paginationQuerySchema, paginationSchema, resolveColumn, service, signPayload, useFetch, useResult, useResultSync, uuidv4, verifyPayloadSignature, workflowInstanceStatusSchema };
|
|
856
|
+
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, handleActionResponse, ibanSchema, isInternalError, nullToOptional, optionalToNull, paginationQuerySchema, paginationSchema, resolveColumn, service, signPayload, useFetch, useResult, useResultSync, uuidv4, verifyPayloadSignature, workflowInstanceStatusSchema };
|
|
853
857
|
export type { ActionExecution, ActionHandlerOptions, AuditLogWriter, AuthUser, BankAccountMetadata, BaseEvent, BuildSearchOptions, Command, CommandLogPayload, DevelitWorkerMethods, Environment, GatewayResponse, IRPCResponse, IdempotencyVariables, IncludeRelation, InferResultType, InternalError, InternalErrorResponseStatus, Project, UserRole, UserVariables, ValidatedInput, WorkflowInstanceStatus };
|
package/dist/index.d.ts
CHANGED
|
@@ -453,9 +453,9 @@ interface IdempotencyVariables {
|
|
|
453
453
|
key: string;
|
|
454
454
|
};
|
|
455
455
|
}
|
|
456
|
-
interface UserVariables
|
|
456
|
+
interface UserVariables {
|
|
457
457
|
user: AuthUser;
|
|
458
|
-
jwt:
|
|
458
|
+
jwt: unknown;
|
|
459
459
|
}
|
|
460
460
|
|
|
461
461
|
declare const paginationQuerySchema: z.$ZodObject<Readonly<Readonly<{
|
|
@@ -740,6 +740,10 @@ interface UseFetchOptions extends RequestInit {
|
|
|
740
740
|
}
|
|
741
741
|
declare function useFetch<T = unknown>(url: string, { parseAs, ...options }?: UseFetchOptions): Promise<Result<T>>;
|
|
742
742
|
|
|
743
|
+
declare const createSignatureKeyPair: () => Promise<{
|
|
744
|
+
publicKey: string;
|
|
745
|
+
privateKey: string;
|
|
746
|
+
}>;
|
|
743
747
|
declare const signPayload: ({ payload, privateKey, }: {
|
|
744
748
|
payload: string;
|
|
745
749
|
privateKey: string;
|
|
@@ -849,5 +853,5 @@ interface WithRetryCounterOptions {
|
|
|
849
853
|
type AsyncMethod<TArgs extends unknown[] = unknown[], TResult = unknown> = (...args: TArgs) => Promise<TResult>;
|
|
850
854
|
declare function cloudflareQueue<TArgs extends unknown[] = unknown[], TResult = unknown>(options: WithRetryCounterOptions): (target: unknown, propertyKey: string | symbol, descriptor: TypedPropertyDescriptor<AsyncMethod<TArgs, TResult>>) => void;
|
|
851
855
|
|
|
852
|
-
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, handleActionResponse, ibanSchema, isInternalError, nullToOptional, optionalToNull, paginationQuerySchema, paginationSchema, resolveColumn, service, signPayload, useFetch, useResult, useResultSync, uuidv4, verifyPayloadSignature, workflowInstanceStatusSchema };
|
|
856
|
+
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, handleActionResponse, ibanSchema, isInternalError, nullToOptional, optionalToNull, paginationQuerySchema, paginationSchema, resolveColumn, service, signPayload, useFetch, useResult, useResultSync, uuidv4, verifyPayloadSignature, workflowInstanceStatusSchema };
|
|
853
857
|
export type { ActionExecution, ActionHandlerOptions, AuditLogWriter, AuthUser, BankAccountMetadata, BaseEvent, BuildSearchOptions, Command, CommandLogPayload, DevelitWorkerMethods, Environment, GatewayResponse, IRPCResponse, IdempotencyVariables, IncludeRelation, InferResultType, InternalError, InternalErrorResponseStatus, Project, UserRole, UserVariables, ValidatedInput, WorkflowInstanceStatus };
|
package/dist/index.mjs
CHANGED
|
@@ -9,7 +9,7 @@ import fs from 'node:fs';
|
|
|
9
9
|
import crypto$1 from 'node:crypto';
|
|
10
10
|
import path from 'node:path';
|
|
11
11
|
import { parse } from 'comment-json';
|
|
12
|
-
export { s as signPayload, v as verifyPayloadSignature } from './shared/backend-sdk.
|
|
12
|
+
export { c as createSignatureKeyPair, s as signPayload, v as verifyPayloadSignature } from './shared/backend-sdk.BRwKpes3.mjs';
|
|
13
13
|
import superjson from 'superjson';
|
|
14
14
|
|
|
15
15
|
const ENVIRONMENT = ["dev", "test", "staging", "production"];
|
package/dist/middlewares.d.mts
CHANGED
|
@@ -1,15 +1,13 @@
|
|
|
1
1
|
import { MiddlewareHandler } from 'hono/types';
|
|
2
2
|
|
|
3
|
-
declare const idempotency:
|
|
4
|
-
IDEMPOTENCY_KV: KVNamespace;
|
|
5
|
-
}>() => MiddlewareHandler;
|
|
3
|
+
declare const idempotency: () => MiddlewareHandler;
|
|
6
4
|
|
|
7
|
-
declare const jwt:
|
|
5
|
+
declare const jwt: () => MiddlewareHandler;
|
|
8
6
|
|
|
9
|
-
declare const ip:
|
|
7
|
+
declare const ip: () => MiddlewareHandler;
|
|
10
8
|
|
|
11
9
|
declare const logger: () => MiddlewareHandler;
|
|
12
10
|
|
|
13
|
-
declare const signature:
|
|
11
|
+
declare const signature: () => MiddlewareHandler;
|
|
14
12
|
|
|
15
13
|
export { idempotency, ip, jwt, logger, signature };
|
package/dist/middlewares.d.ts
CHANGED
|
@@ -1,15 +1,13 @@
|
|
|
1
1
|
import { MiddlewareHandler } from 'hono/types';
|
|
2
2
|
|
|
3
|
-
declare const idempotency:
|
|
4
|
-
IDEMPOTENCY_KV: KVNamespace;
|
|
5
|
-
}>() => MiddlewareHandler;
|
|
3
|
+
declare const idempotency: () => MiddlewareHandler;
|
|
6
4
|
|
|
7
|
-
declare const jwt:
|
|
5
|
+
declare const jwt: () => MiddlewareHandler;
|
|
8
6
|
|
|
9
|
-
declare const ip:
|
|
7
|
+
declare const ip: () => MiddlewareHandler;
|
|
10
8
|
|
|
11
9
|
declare const logger: () => MiddlewareHandler;
|
|
12
10
|
|
|
13
|
-
declare const signature:
|
|
11
|
+
declare const signature: () => MiddlewareHandler;
|
|
14
12
|
|
|
15
13
|
export { idempotency, ip, jwt, logger, signature };
|
package/dist/middlewares.mjs
CHANGED
|
@@ -8,7 +8,7 @@ import 'node:crypto';
|
|
|
8
8
|
import 'node:path';
|
|
9
9
|
import 'comment-json';
|
|
10
10
|
import 'drizzle-orm';
|
|
11
|
-
import { v as verifyPayloadSignature } from './shared/backend-sdk.
|
|
11
|
+
import { v as verifyPayloadSignature } from './shared/backend-sdk.BRwKpes3.mjs';
|
|
12
12
|
|
|
13
13
|
const validateBearerScheme = (header) => {
|
|
14
14
|
return header.startsWith("Bearer ") && header.length > 7 && !header.slice(7).includes(" ");
|
|
@@ -75,8 +75,7 @@ const jwt = () => {
|
|
|
75
75
|
message: `The Bearer token in the 'Authorization' header value must be a JWT.`
|
|
76
76
|
});
|
|
77
77
|
}
|
|
78
|
-
const
|
|
79
|
-
const { data, error } = await authService.verifyAccessToken({
|
|
78
|
+
const { data, error } = await context.env.AUTH_SERVICE.verifyAccessToken({
|
|
80
79
|
accessToken: bearerToken
|
|
81
80
|
});
|
|
82
81
|
if (!data || error) {
|
|
@@ -117,8 +116,7 @@ const ip = () => {
|
|
|
117
116
|
message: "Failed to retrieve request organization ID."
|
|
118
117
|
});
|
|
119
118
|
}
|
|
120
|
-
const
|
|
121
|
-
const { data: organization, error } = await organizationService.getOrganization({
|
|
119
|
+
const { data: organization, error } = await context.env.ORGANIZATION_SERVICE.getOrganization({
|
|
122
120
|
organizationId: user.organizationId
|
|
123
121
|
});
|
|
124
122
|
if (!organization || error) {
|
|
@@ -195,8 +193,7 @@ const signature = () => {
|
|
|
195
193
|
message: "Failed to retrieve request organization ID."
|
|
196
194
|
});
|
|
197
195
|
}
|
|
198
|
-
const
|
|
199
|
-
const { data: organization, error } = await organizationService.getOrganization({
|
|
196
|
+
const { data: organization, error } = await context.env.ORGANIZATION_SERVICE.getOrganization({
|
|
200
197
|
organizationId: user.organizationId
|
|
201
198
|
});
|
|
202
199
|
if (!organization || error) {
|
|
@@ -1,5 +1,21 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
const createSignatureKeyPair = async () => {
|
|
2
|
+
const { publicKey, privateKey } = await crypto.subtle.generateKey(
|
|
3
|
+
{
|
|
4
|
+
name: "RSASSA-PKCS1-v1_5",
|
|
5
|
+
modulusLength: 4096,
|
|
6
|
+
publicExponent: new Uint8Array([1, 0, 1]),
|
|
7
|
+
hash: "SHA-256"
|
|
8
|
+
},
|
|
9
|
+
true,
|
|
10
|
+
["sign", "verify"]
|
|
11
|
+
);
|
|
12
|
+
const exportedPublicKey = await crypto.subtle.exportKey("spki", publicKey);
|
|
13
|
+
const exportedPrivateKey = await crypto.subtle.exportKey("pkcs8", privateKey);
|
|
14
|
+
return {
|
|
15
|
+
publicKey: Buffer.from(exportedPublicKey).toString("base64"),
|
|
16
|
+
privateKey: Buffer.from(exportedPrivateKey).toString("base64")
|
|
17
|
+
};
|
|
18
|
+
};
|
|
3
19
|
const signPayload = async ({
|
|
4
20
|
payload,
|
|
5
21
|
privateKey
|
|
@@ -77,4 +93,4 @@ const verifyPayloadSignature = async ({
|
|
|
77
93
|
return isValid;
|
|
78
94
|
};
|
|
79
95
|
|
|
80
|
-
export { signPayload as s, verifyPayloadSignature as v };
|
|
96
|
+
export { createSignatureKeyPair as c, signPayload as s, verifyPayloadSignature as v };
|