@rdlabo/workers-hono-kit 0.1.0 → 0.2.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/db/database.d.ts +1 -1
- package/dist/db/database.js +2 -2
- package/dist/db/index.d.ts +10 -10
- package/dist/db/index.js +6 -6
- package/dist/firebase/jose-firebase-verifier.d.ts +2 -2
- package/dist/firebase/remote-verifier.d.ts +1 -1
- package/dist/firebase/remote-verifier.js +2 -2
- package/dist/index.d.ts +30 -30
- package/dist/index.js +18 -18
- package/dist/middleware/auth.d.ts +1 -1
- package/dist/middleware/auth.js +1 -1
- package/dist/testing/auth.d.ts +2 -2
- package/dist/testing/fakes.d.ts +2 -2
- package/dist/testing/fakes.js +1 -1
- package/dist/testing/index.d.ts +8 -8
- package/dist/testing/index.js +5 -5
- package/package.json +19 -9
- package/src/db/database.ts +3 -3
- package/src/db/index.ts +10 -10
- package/src/firebase/jose-firebase-verifier.ts +2 -2
- package/src/firebase/remote-verifier.ts +3 -3
- package/src/index.ts +36 -30
- package/src/middleware/auth.ts +2 -2
- package/src/testing/auth.ts +2 -2
- package/src/testing/fakes.ts +3 -3
- package/src/testing/index.ts +8 -8
package/dist/db/database.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Connection, Pool } from 'mysql2/promise';
|
|
2
|
-
import type { HyperdriveLike } from './connection';
|
|
2
|
+
import type { HyperdriveLike } from './connection.js';
|
|
3
3
|
/**
|
|
4
4
|
* フリート共通のデータ層(NestJS/TypeORM の master/slave + retryWhenDeadlock 置換)。
|
|
5
5
|
* - reads → replica。透明性のため生 SQL を維持(旧 helper.slave().query 相当)。
|
package/dist/db/database.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { createConnection } from 'mysql2/promise';
|
|
2
|
-
import { hyperdriveConnectionOptions } from './connection';
|
|
3
|
-
import { retryWhenDeadlock } from './retry';
|
|
2
|
+
import { hyperdriveConnectionOptions } from './connection.js';
|
|
3
|
+
import { retryWhenDeadlock } from './retry.js';
|
|
4
4
|
/**
|
|
5
5
|
* 接続済みの orm/replica を受け取り Database を組み立てる(receptray/tipsys の MysqlDatabase 相当)。
|
|
6
6
|
* 接続・orm の生成と接続の破棄は呼び出し側(worker entry)が担う。
|
package/dist/db/index.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
export { retryWhenDeadlock } from './retry';
|
|
2
|
-
export { createMysqlDatabase, createHyperdriveDatabase, databaseFrom } from './database';
|
|
3
|
-
export type { Database, DisposableDatabase, QueryRunner, TxOf, CreateMysqlDatabaseOptions, CreateHyperdriveDatabaseOptions, Connection, Pool, } from './database';
|
|
4
|
-
export { insertIdOf, affectedRowsOf, insertedIdsOf } from './write-result';
|
|
5
|
-
export type { DzWriteResult } from './write-result';
|
|
6
|
-
export { hyperdriveConnectionOptions, withMysqlConnections } from './connection';
|
|
7
|
-
export type { HyperdriveLike, ExecutionContextLike } from './connection';
|
|
8
|
-
export { toJstDate, jstTimestampParams, jstDatetimeParams, jstDateParams } from './jst';
|
|
9
|
-
export { DRIZZLE_ORM_OPTIONS, honoDrizzleConfig } from './orm-config';
|
|
10
|
-
export type { HonoDrizzleConfigOptions } from './orm-config';
|
|
1
|
+
export { retryWhenDeadlock } from './retry.js';
|
|
2
|
+
export { createMysqlDatabase, createHyperdriveDatabase, databaseFrom } from './database.js';
|
|
3
|
+
export type { Database, DisposableDatabase, QueryRunner, TxOf, CreateMysqlDatabaseOptions, CreateHyperdriveDatabaseOptions, Connection, Pool, } from './database.js';
|
|
4
|
+
export { insertIdOf, affectedRowsOf, insertedIdsOf } from './write-result.js';
|
|
5
|
+
export type { DzWriteResult } from './write-result.js';
|
|
6
|
+
export { hyperdriveConnectionOptions, withMysqlConnections } from './connection.js';
|
|
7
|
+
export type { HyperdriveLike, ExecutionContextLike } from './connection.js';
|
|
8
|
+
export { toJstDate, jstTimestampParams, jstDatetimeParams, jstDateParams } from './jst.js';
|
|
9
|
+
export { DRIZZLE_ORM_OPTIONS, honoDrizzleConfig } from './orm-config.js';
|
|
10
|
+
export type { HonoDrizzleConfigOptions } from './orm-config.js';
|
package/dist/db/index.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
// @rdlabo/workers-hono-kit/db — mysql2 依存のデータ層ヘルパ(ルート `.` は web 標準のみのため別サブパス)。
|
|
2
2
|
// drizzle-orm の型同一性には依存しない(orm は消費側が渡す)。
|
|
3
|
-
export { retryWhenDeadlock } from './retry';
|
|
4
|
-
export { createMysqlDatabase, createHyperdriveDatabase, databaseFrom } from './database';
|
|
5
|
-
export { insertIdOf, affectedRowsOf, insertedIdsOf } from './write-result';
|
|
6
|
-
export { hyperdriveConnectionOptions, withMysqlConnections } from './connection';
|
|
7
|
-
export { toJstDate, jstTimestampParams, jstDatetimeParams, jstDateParams } from './jst';
|
|
8
|
-
export { DRIZZLE_ORM_OPTIONS, honoDrizzleConfig } from './orm-config';
|
|
3
|
+
export { retryWhenDeadlock } from './retry.js';
|
|
4
|
+
export { createMysqlDatabase, createHyperdriveDatabase, databaseFrom } from './database.js';
|
|
5
|
+
export { insertIdOf, affectedRowsOf, insertedIdsOf } from './write-result.js';
|
|
6
|
+
export { hyperdriveConnectionOptions, withMysqlConnections } from './connection.js';
|
|
7
|
+
export { toJstDate, jstTimestampParams, jstDatetimeParams, jstDateParams } from './jst.js';
|
|
8
|
+
export { DRIZZLE_ORM_OPTIONS, honoDrizzleConfig } from './orm-config.js';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { CryptoKey, JWK, JWTVerifyGetKey, KeyObject } from 'jose';
|
|
2
|
-
import type { DecodedIdToken, FirebaseVerifier } from './firebase-verifier';
|
|
3
|
-
import type { IdentityToolkit } from './identity-toolkit';
|
|
2
|
+
import type { DecodedIdToken, FirebaseVerifier } from './firebase-verifier.js';
|
|
3
|
+
import type { IdentityToolkit } from './identity-toolkit.js';
|
|
4
4
|
type KeyInput = CryptoKey | KeyObject | JWK | Uint8Array | JWTVerifyGetKey;
|
|
5
5
|
/**
|
|
6
6
|
* Replaces firebase-admin getAuth().verifyIdToken() with jose RS256 verification against
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { JoseFirebaseVerifier } from './jose-firebase-verifier';
|
|
1
|
+
import { JoseFirebaseVerifier } from './jose-firebase-verifier.js';
|
|
2
2
|
export declare function createRemoteFirebaseVerifier(projectId: string): JoseFirebaseVerifier;
|
|
3
3
|
/**
|
|
4
4
|
* サービスアカウント JSON から検証器を作る便宜ファクトリ(receptray/tipsys hono の `firebaseFor` 相当)。
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { createRemoteJWKSet } from 'jose';
|
|
2
|
-
import { IdentityToolkit } from './identity-toolkit';
|
|
3
|
-
import { JoseFirebaseVerifier, SECURETOKEN_JWK_URL } from './jose-firebase-verifier';
|
|
2
|
+
import { IdentityToolkit } from './identity-toolkit.js';
|
|
3
|
+
import { JoseFirebaseVerifier, SECURETOKEN_JWK_URL } from './jose-firebase-verifier.js';
|
|
4
4
|
/**
|
|
5
5
|
* 本番用の便宜ファクトリ。`createRemoteJWKSet` で Google securetoken の公開鍵を取り、
|
|
6
6
|
* `JoseFirebaseVerifier` を返す。トークン検証のみ用途(getUser/deleteUser は不要 = Identity Toolkit 無し)。
|
package/dist/index.d.ts
CHANGED
|
@@ -1,30 +1,30 @@
|
|
|
1
|
-
export { finalizeResponse } from './middleware/finalize-response';
|
|
2
|
-
export { validate, createSentryValidate } from './middleware/validation';
|
|
3
|
-
export type { ValidateOptions, ValidationTarget, ZodErrorLike, SentryLike, SentryScopeLike, } from './middleware/validation';
|
|
4
|
-
export { zNum, zNumNullable, zNumOptional, zNumWithDefault } from './middleware/zod-coerce';
|
|
5
|
-
export { createAuthMiddleware } from './middleware/auth';
|
|
6
|
-
export type { AuthMiddlewareOptions } from './middleware/auth';
|
|
7
|
-
export { getUserProtocol } from './http/user-protocol';
|
|
8
|
-
export type { IUserProtocol } from './http/user-protocol';
|
|
9
|
-
export { getAppInfo } from './http/app-info';
|
|
10
|
-
export type { AppInfo } from './http/app-info';
|
|
11
|
-
export { resolveAppEnv, isProductionEnv } from './http/app-env';
|
|
12
|
-
export type { AppEnv } from './http/app-env';
|
|
13
|
-
export { HttpStatus } from './http/http-status';
|
|
14
|
-
export { createNestErrorHandler, nestNotFoundHandler, NEST_REASON_PHRASES } from './http/nest-error';
|
|
15
|
-
export type { NestErrorHandlerOptions, ErrorReportContext, ErrorReporter } from './http/nest-error';
|
|
16
|
-
export { KVCache } from './cache/kv-cache';
|
|
17
|
-
export type { KVNamespace, KVCacheOptions } from './cache/kv-cache';
|
|
18
|
-
export { createStripeClient, verifyStripeWebhook } from './stripe/client';
|
|
19
|
-
export type { CreateStripeClientOptions } from './stripe/client';
|
|
20
|
-
export { retryWhenDeadlock } from './db/retry';
|
|
21
|
-
export { createAiGatewayProvider } from './ai/gateway';
|
|
22
|
-
export type { AiGatewayConfig, AiGatewayProvider, AiGatewayBinding, AiGateway, AiGatewayOptions } from './ai/gateway';
|
|
23
|
-
export { getAuthenticationSecret } from './aws/secrets-manager';
|
|
24
|
-
export type { AwsSecretsOptions } from './aws/secrets-manager';
|
|
25
|
-
export { getCloudFrontSignedUrl } from './aws/cloudfront';
|
|
26
|
-
export type { DecodedIdToken, FirebaseVerifier } from './firebase/firebase-verifier';
|
|
27
|
-
export { JoseFirebaseVerifier, SECURETOKEN_JWK_URL } from './firebase/jose-firebase-verifier';
|
|
28
|
-
export { IdentityToolkit } from './firebase/identity-toolkit';
|
|
29
|
-
export type { ServiceAccount } from './firebase/identity-toolkit';
|
|
30
|
-
export { createRemoteFirebaseVerifier, createServiceAccountVerifier } from './firebase/remote-verifier';
|
|
1
|
+
export { finalizeResponse } from './middleware/finalize-response.js';
|
|
2
|
+
export { validate, createSentryValidate } from './middleware/validation.js';
|
|
3
|
+
export type { ValidateOptions, ValidationTarget, ZodErrorLike, SentryLike, SentryScopeLike, } from './middleware/validation.js';
|
|
4
|
+
export { zNum, zNumNullable, zNumOptional, zNumWithDefault } from './middleware/zod-coerce.js';
|
|
5
|
+
export { createAuthMiddleware } from './middleware/auth.js';
|
|
6
|
+
export type { AuthMiddlewareOptions } from './middleware/auth.js';
|
|
7
|
+
export { getUserProtocol } from './http/user-protocol.js';
|
|
8
|
+
export type { IUserProtocol } from './http/user-protocol.js';
|
|
9
|
+
export { getAppInfo } from './http/app-info.js';
|
|
10
|
+
export type { AppInfo } from './http/app-info.js';
|
|
11
|
+
export { resolveAppEnv, isProductionEnv } from './http/app-env.js';
|
|
12
|
+
export type { AppEnv } from './http/app-env.js';
|
|
13
|
+
export { HttpStatus } from './http/http-status.js';
|
|
14
|
+
export { createNestErrorHandler, nestNotFoundHandler, NEST_REASON_PHRASES } from './http/nest-error.js';
|
|
15
|
+
export type { NestErrorHandlerOptions, ErrorReportContext, ErrorReporter } from './http/nest-error.js';
|
|
16
|
+
export { KVCache } from './cache/kv-cache.js';
|
|
17
|
+
export type { KVNamespace, KVCacheOptions } from './cache/kv-cache.js';
|
|
18
|
+
export { createStripeClient, verifyStripeWebhook } from './stripe/client.js';
|
|
19
|
+
export type { CreateStripeClientOptions } from './stripe/client.js';
|
|
20
|
+
export { retryWhenDeadlock } from './db/retry.js';
|
|
21
|
+
export { createAiGatewayProvider } from './ai/gateway.js';
|
|
22
|
+
export type { AiGatewayConfig, AiGatewayProvider, AiGatewayBinding, AiGateway, AiGatewayOptions, } from './ai/gateway.js';
|
|
23
|
+
export { getAuthenticationSecret } from './aws/secrets-manager.js';
|
|
24
|
+
export type { AwsSecretsOptions } from './aws/secrets-manager.js';
|
|
25
|
+
export { getCloudFrontSignedUrl } from './aws/cloudfront.js';
|
|
26
|
+
export type { DecodedIdToken, FirebaseVerifier } from './firebase/firebase-verifier.js';
|
|
27
|
+
export { JoseFirebaseVerifier, SECURETOKEN_JWK_URL } from './firebase/jose-firebase-verifier.js';
|
|
28
|
+
export { IdentityToolkit } from './firebase/identity-toolkit.js';
|
|
29
|
+
export type { ServiceAccount } from './firebase/identity-toolkit.js';
|
|
30
|
+
export { createRemoteFirebaseVerifier, createServiceAccountVerifier } from './firebase/remote-verifier.js';
|
package/dist/index.js
CHANGED
|
@@ -2,27 +2,27 @@
|
|
|
2
2
|
// ドメイン・DB・各 repo 固有の parity 差異(auth エラー status/body、secretId、Secret スキーマ)は
|
|
3
3
|
// 各 repo 側に残し、ここには「設定注入で汎用化できるインフラ」だけを置く。
|
|
4
4
|
// middleware
|
|
5
|
-
export { finalizeResponse } from './middleware/finalize-response';
|
|
6
|
-
export { validate, createSentryValidate } from './middleware/validation';
|
|
7
|
-
export { zNum, zNumNullable, zNumOptional, zNumWithDefault } from './middleware/zod-coerce';
|
|
8
|
-
export { createAuthMiddleware } from './middleware/auth';
|
|
5
|
+
export { finalizeResponse } from './middleware/finalize-response.js';
|
|
6
|
+
export { validate, createSentryValidate } from './middleware/validation.js';
|
|
7
|
+
export { zNum, zNumNullable, zNumOptional, zNumWithDefault } from './middleware/zod-coerce.js';
|
|
8
|
+
export { createAuthMiddleware } from './middleware/auth.js';
|
|
9
9
|
// http
|
|
10
|
-
export { getUserProtocol } from './http/user-protocol';
|
|
11
|
-
export { getAppInfo } from './http/app-info';
|
|
12
|
-
export { resolveAppEnv, isProductionEnv } from './http/app-env';
|
|
13
|
-
export { HttpStatus } from './http/http-status';
|
|
14
|
-
export { createNestErrorHandler, nestNotFoundHandler, NEST_REASON_PHRASES } from './http/nest-error';
|
|
10
|
+
export { getUserProtocol } from './http/user-protocol.js';
|
|
11
|
+
export { getAppInfo } from './http/app-info.js';
|
|
12
|
+
export { resolveAppEnv, isProductionEnv } from './http/app-env.js';
|
|
13
|
+
export { HttpStatus } from './http/http-status.js';
|
|
14
|
+
export { createNestErrorHandler, nestNotFoundHandler, NEST_REASON_PHRASES } from './http/nest-error.js';
|
|
15
15
|
// cache
|
|
16
|
-
export { KVCache } from './cache/kv-cache';
|
|
16
|
+
export { KVCache } from './cache/kv-cache.js';
|
|
17
17
|
// stripe
|
|
18
|
-
export { createStripeClient, verifyStripeWebhook } from './stripe/client';
|
|
18
|
+
export { createStripeClient, verifyStripeWebhook } from './stripe/client.js';
|
|
19
19
|
// db
|
|
20
|
-
export { retryWhenDeadlock } from './db/retry';
|
|
20
|
+
export { retryWhenDeadlock } from './db/retry.js';
|
|
21
21
|
// ai
|
|
22
|
-
export { createAiGatewayProvider } from './ai/gateway';
|
|
22
|
+
export { createAiGatewayProvider } from './ai/gateway.js';
|
|
23
23
|
// aws
|
|
24
|
-
export { getAuthenticationSecret } from './aws/secrets-manager';
|
|
25
|
-
export { getCloudFrontSignedUrl } from './aws/cloudfront';
|
|
26
|
-
export { JoseFirebaseVerifier, SECURETOKEN_JWK_URL } from './firebase/jose-firebase-verifier';
|
|
27
|
-
export { IdentityToolkit } from './firebase/identity-toolkit';
|
|
28
|
-
export { createRemoteFirebaseVerifier, createServiceAccountVerifier } from './firebase/remote-verifier';
|
|
24
|
+
export { getAuthenticationSecret } from './aws/secrets-manager.js';
|
|
25
|
+
export { getCloudFrontSignedUrl } from './aws/cloudfront.js';
|
|
26
|
+
export { JoseFirebaseVerifier, SECURETOKEN_JWK_URL } from './firebase/jose-firebase-verifier.js';
|
|
27
|
+
export { IdentityToolkit } from './firebase/identity-toolkit.js';
|
|
28
|
+
export { createRemoteFirebaseVerifier, createServiceAccountVerifier } from './firebase/remote-verifier.js';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { Context, Env, MiddlewareHandler } from 'hono';
|
|
2
2
|
import type { ContentfulStatusCode } from 'hono/utils/http-status';
|
|
3
|
-
import type { AppInfo } from '../http/app-info';
|
|
3
|
+
import type { AppInfo } from '../http/app-info.js';
|
|
4
4
|
export interface AuthMiddlewareOptions<E extends Env, Verified, Id = unknown> {
|
|
5
5
|
/** ID トークンを載せるヘッダ。既定 `'x-amz-security-token'`(フリート共通)。 */
|
|
6
6
|
tokenHeader?: string;
|
package/dist/middleware/auth.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { HTTPException } from 'hono/http-exception';
|
|
2
|
-
import { getAppInfo } from '../http/app-info';
|
|
2
|
+
import { getAppInfo } from '../http/app-info.js';
|
|
3
3
|
/**
|
|
4
4
|
* NestJS の AuthGuard / TokenGuard 相当の認証 middleware を作る(フリート共通)。
|
|
5
5
|
* スケルトン(ヘッダ読取 → verify → getAppInfo → resolveUserId → setContext、失敗で console.error +
|
package/dist/testing/auth.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { Pool } from 'mysql2/promise';
|
|
2
|
-
import type { DecodedIdToken } from '../firebase/firebase-verifier';
|
|
3
|
-
import type { FakeFirebaseVerifier } from './fakes';
|
|
2
|
+
import type { DecodedIdToken } from '../firebase/firebase-verifier.js';
|
|
3
|
+
import type { FakeFirebaseVerifier } from './fakes.js';
|
|
4
4
|
/**
|
|
5
5
|
* app interceptor 互換の認証ヘッダ(`x-amz-security-token` + `x-amz-meta-*`)を組む。
|
|
6
6
|
* fleet 全 hono repo の route spec で同形に重複していたものを集約。
|
package/dist/testing/fakes.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { Pool } from 'mysql2/promise';
|
|
2
|
-
import type { DisposableDatabase } from '../db/database';
|
|
3
|
-
import type { DecodedIdToken, FirebaseVerifier } from '../firebase/firebase-verifier';
|
|
2
|
+
import type { DisposableDatabase } from '../db/database.js';
|
|
3
|
+
import type { DecodedIdToken, FirebaseVerifier } from '../firebase/firebase-verifier.js';
|
|
4
4
|
/**
|
|
5
5
|
* オフライン route テスト用の in-memory FirebaseVerifier(4 repo 同一実装を集約)。
|
|
6
6
|
* `register(token, { uid })` で偽 ID を仕込む。
|
package/dist/testing/fakes.js
CHANGED
package/dist/testing/index.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
export { createTestDb } from './db';
|
|
2
|
-
export type { TestDb, CreateTestDbOptions, TestDbConnection } from './db';
|
|
3
|
-
export { FakeFirebaseVerifier, createPoolDatabase, createNoopDatabase } from './fakes';
|
|
4
|
-
export type { CreatePoolDatabaseOptions } from './fakes';
|
|
5
|
-
export type { Database, DisposableDatabase, QueryRunner, TxOf } from '../db/database';
|
|
6
|
-
export { authHeaders, registerFirebaseToken, provisionUser } from './auth';
|
|
7
|
-
export { configurableFake } from './configurable-fake';
|
|
8
|
-
export { fakeApiList, fakePaymentIntent, fakeStripeEvent, fakeCheckoutSession, fakeCustomer, fakePrice, fakeSubscription, } from './stripe-fixtures';
|
|
1
|
+
export { createTestDb } from './db.js';
|
|
2
|
+
export type { TestDb, CreateTestDbOptions, TestDbConnection } from './db.js';
|
|
3
|
+
export { FakeFirebaseVerifier, createPoolDatabase, createNoopDatabase } from './fakes.js';
|
|
4
|
+
export type { CreatePoolDatabaseOptions } from './fakes.js';
|
|
5
|
+
export type { Database, DisposableDatabase, QueryRunner, TxOf } from '../db/database.js';
|
|
6
|
+
export { authHeaders, registerFirebaseToken, provisionUser } from './auth.js';
|
|
7
|
+
export { configurableFake } from './configurable-fake.js';
|
|
8
|
+
export { fakeApiList, fakePaymentIntent, fakeStripeEvent, fakeCheckoutSession, fakeCustomer, fakePrice, fakeSubscription, } from './stripe-fixtures.js';
|
package/dist/testing/index.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
// @rdlabo/workers-hono-kit/testing — フリート共通のテスト基盤(mysql2/drizzle 依存)。
|
|
2
2
|
// 実行時には読み込まれないテスト専用ヘルパ。各 repo の testing/db.ts・fakes.ts を集約。
|
|
3
|
-
export { createTestDb } from './db';
|
|
4
|
-
export { FakeFirebaseVerifier, createPoolDatabase, createNoopDatabase } from './fakes';
|
|
3
|
+
export { createTestDb } from './db.js';
|
|
4
|
+
export { FakeFirebaseVerifier, createPoolDatabase, createNoopDatabase } from './fakes.js';
|
|
5
5
|
// 認証テストヘルパ(route spec のヘッダ生成・ユーザ provision を集約)。
|
|
6
|
-
export { authHeaders, registerFirebaseToken, provisionUser } from './auth';
|
|
6
|
+
export { authHeaders, registerFirebaseToken, provisionUser } from './auth.js';
|
|
7
7
|
// test double ヘルパ(未設定メソッドで明示 throw する部分実装 fake)。
|
|
8
|
-
export { configurableFake } from './configurable-fake';
|
|
8
|
+
export { configurableFake } from './configurable-fake.js';
|
|
9
9
|
// Stripe オブジェクトの test fixture factory。
|
|
10
|
-
export { fakeApiList, fakePaymentIntent, fakeStripeEvent, fakeCheckoutSession, fakeCustomer, fakePrice, fakeSubscription, } from './stripe-fixtures';
|
|
10
|
+
export { fakeApiList, fakePaymentIntent, fakeStripeEvent, fakeCheckoutSession, fakeCustomer, fakePrice, fakeSubscription, } from './stripe-fixtures.js';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rdlabo/workers-hono-kit",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"private": false,
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
@@ -68,7 +68,11 @@
|
|
|
68
68
|
"lint": "eslint \"src/**/*.ts\"",
|
|
69
69
|
"lint:fix": "eslint \"src/**/*.ts\" --fix",
|
|
70
70
|
"format": "prettier --write \"src/**/*.ts\"",
|
|
71
|
-
"format:check": "prettier --check \"src/**/*.ts\""
|
|
71
|
+
"format:check": "prettier --check \"src/**/*.ts\"",
|
|
72
|
+
"release": "np --no-tests --no-publish"
|
|
73
|
+
},
|
|
74
|
+
"dependencies": {
|
|
75
|
+
"stripe": "^20.4.1"
|
|
72
76
|
},
|
|
73
77
|
"peerDependencies": {
|
|
74
78
|
"@hono/zod-validator": "^0.8.0",
|
|
@@ -79,15 +83,21 @@
|
|
|
79
83
|
"hono": "^4.6.0",
|
|
80
84
|
"jose": "^6.2.0",
|
|
81
85
|
"mysql2": "^3.14.0",
|
|
82
|
-
"stripe": ">=15",
|
|
83
86
|
"zod": "^4.4.0"
|
|
84
87
|
},
|
|
85
88
|
"peerDependenciesMeta": {
|
|
86
|
-
"ai": {
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
"
|
|
90
|
-
|
|
89
|
+
"ai": {
|
|
90
|
+
"optional": true
|
|
91
|
+
},
|
|
92
|
+
"ai-gateway-provider": {
|
|
93
|
+
"optional": true
|
|
94
|
+
},
|
|
95
|
+
"drizzle-orm": {
|
|
96
|
+
"optional": true
|
|
97
|
+
},
|
|
98
|
+
"mysql2": {
|
|
99
|
+
"optional": true
|
|
100
|
+
}
|
|
91
101
|
},
|
|
92
102
|
"devDependencies": {
|
|
93
103
|
"@ai-sdk/anthropic": "^3.0.84",
|
|
@@ -103,8 +113,8 @@
|
|
|
103
113
|
"hono": "^4.6.0",
|
|
104
114
|
"jose": "^6.2.3",
|
|
105
115
|
"mysql2": "3.22.5",
|
|
116
|
+
"np": "^8.0.4",
|
|
106
117
|
"prettier": "^3.8.4",
|
|
107
|
-
"stripe": "^20.4.1",
|
|
108
118
|
"typescript": "~5.6.2",
|
|
109
119
|
"typescript-eslint": "^8.61.1",
|
|
110
120
|
"vitest": "^2.1.0",
|
package/src/db/database.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { createConnection } from 'mysql2/promise';
|
|
2
2
|
import type { Connection, Pool } from 'mysql2/promise';
|
|
3
|
-
import { hyperdriveConnectionOptions } from './connection';
|
|
4
|
-
import type { HyperdriveLike } from './connection';
|
|
5
|
-
import { retryWhenDeadlock } from './retry';
|
|
3
|
+
import { hyperdriveConnectionOptions } from './connection.js';
|
|
4
|
+
import type { HyperdriveLike } from './connection.js';
|
|
5
|
+
import { retryWhenDeadlock } from './retry.js';
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
8
|
* フリート共通のデータ層(NestJS/TypeORM の master/slave + retryWhenDeadlock 置換)。
|
package/src/db/index.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
// @rdlabo/workers-hono-kit/db — mysql2 依存のデータ層ヘルパ(ルート `.` は web 標準のみのため別サブパス)。
|
|
2
2
|
// drizzle-orm の型同一性には依存しない(orm は消費側が渡す)。
|
|
3
3
|
|
|
4
|
-
export { retryWhenDeadlock } from './retry';
|
|
4
|
+
export { retryWhenDeadlock } from './retry.js';
|
|
5
5
|
|
|
6
|
-
export { createMysqlDatabase, createHyperdriveDatabase, databaseFrom } from './database';
|
|
6
|
+
export { createMysqlDatabase, createHyperdriveDatabase, databaseFrom } from './database.js';
|
|
7
7
|
export type {
|
|
8
8
|
Database,
|
|
9
9
|
DisposableDatabase,
|
|
@@ -13,15 +13,15 @@ export type {
|
|
|
13
13
|
CreateHyperdriveDatabaseOptions,
|
|
14
14
|
Connection,
|
|
15
15
|
Pool,
|
|
16
|
-
} from './database';
|
|
16
|
+
} from './database.js';
|
|
17
17
|
|
|
18
|
-
export { insertIdOf, affectedRowsOf, insertedIdsOf } from './write-result';
|
|
19
|
-
export type { DzWriteResult } from './write-result';
|
|
18
|
+
export { insertIdOf, affectedRowsOf, insertedIdsOf } from './write-result.js';
|
|
19
|
+
export type { DzWriteResult } from './write-result.js';
|
|
20
20
|
|
|
21
|
-
export { hyperdriveConnectionOptions, withMysqlConnections } from './connection';
|
|
22
|
-
export type { HyperdriveLike, ExecutionContextLike } from './connection';
|
|
21
|
+
export { hyperdriveConnectionOptions, withMysqlConnections } from './connection.js';
|
|
22
|
+
export type { HyperdriveLike, ExecutionContextLike } from './connection.js';
|
|
23
23
|
|
|
24
|
-
export { toJstDate, jstTimestampParams, jstDatetimeParams, jstDateParams } from './jst';
|
|
24
|
+
export { toJstDate, jstTimestampParams, jstDatetimeParams, jstDateParams } from './jst.js';
|
|
25
25
|
|
|
26
|
-
export { DRIZZLE_ORM_OPTIONS, honoDrizzleConfig } from './orm-config';
|
|
27
|
-
export type { HonoDrizzleConfigOptions } from './orm-config';
|
|
26
|
+
export { DRIZZLE_ORM_OPTIONS, honoDrizzleConfig } from './orm-config.js';
|
|
27
|
+
export type { HonoDrizzleConfigOptions } from './orm-config.js';
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { jwtVerify } from 'jose';
|
|
2
2
|
import type { CryptoKey, JWK, JWTVerifyGetKey, KeyObject } from 'jose';
|
|
3
|
-
import type { DecodedIdToken, FirebaseVerifier } from './firebase-verifier';
|
|
4
|
-
import type { IdentityToolkit } from './identity-toolkit';
|
|
3
|
+
import type { DecodedIdToken, FirebaseVerifier } from './firebase-verifier.js';
|
|
4
|
+
import type { IdentityToolkit } from './identity-toolkit.js';
|
|
5
5
|
|
|
6
6
|
// jose v6 removed `KeyLike`; the verification key is a static key (prod: createRemoteJWKSet,
|
|
7
7
|
// test: a CryptoKey) or a dynamic getKey function. Union both overloads' key params.
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { createRemoteJWKSet } from 'jose';
|
|
2
|
-
import { IdentityToolkit } from './identity-toolkit';
|
|
3
|
-
import type { ServiceAccount } from './identity-toolkit';
|
|
4
|
-
import { JoseFirebaseVerifier, SECURETOKEN_JWK_URL } from './jose-firebase-verifier';
|
|
2
|
+
import { IdentityToolkit } from './identity-toolkit.js';
|
|
3
|
+
import type { ServiceAccount } from './identity-toolkit.js';
|
|
4
|
+
import { JoseFirebaseVerifier, SECURETOKEN_JWK_URL } from './jose-firebase-verifier.js';
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* 本番用の便宜ファクトリ。`createRemoteJWKSet` で Google securetoken の公開鍵を取り、
|
package/src/index.ts
CHANGED
|
@@ -3,53 +3,59 @@
|
|
|
3
3
|
// 各 repo 側に残し、ここには「設定注入で汎用化できるインフラ」だけを置く。
|
|
4
4
|
|
|
5
5
|
// middleware
|
|
6
|
-
export { finalizeResponse } from './middleware/finalize-response';
|
|
7
|
-
export { validate, createSentryValidate } from './middleware/validation';
|
|
6
|
+
export { finalizeResponse } from './middleware/finalize-response.js';
|
|
7
|
+
export { validate, createSentryValidate } from './middleware/validation.js';
|
|
8
8
|
export type {
|
|
9
9
|
ValidateOptions,
|
|
10
10
|
ValidationTarget,
|
|
11
11
|
ZodErrorLike,
|
|
12
12
|
SentryLike,
|
|
13
13
|
SentryScopeLike,
|
|
14
|
-
} from './middleware/validation';
|
|
15
|
-
export { zNum, zNumNullable, zNumOptional, zNumWithDefault } from './middleware/zod-coerce';
|
|
16
|
-
export { createAuthMiddleware } from './middleware/auth';
|
|
17
|
-
export type { AuthMiddlewareOptions } from './middleware/auth';
|
|
14
|
+
} from './middleware/validation.js';
|
|
15
|
+
export { zNum, zNumNullable, zNumOptional, zNumWithDefault } from './middleware/zod-coerce.js';
|
|
16
|
+
export { createAuthMiddleware } from './middleware/auth.js';
|
|
17
|
+
export type { AuthMiddlewareOptions } from './middleware/auth.js';
|
|
18
18
|
|
|
19
19
|
// http
|
|
20
|
-
export { getUserProtocol } from './http/user-protocol';
|
|
21
|
-
export type { IUserProtocol } from './http/user-protocol';
|
|
22
|
-
export { getAppInfo } from './http/app-info';
|
|
23
|
-
export type { AppInfo } from './http/app-info';
|
|
24
|
-
export { resolveAppEnv, isProductionEnv } from './http/app-env';
|
|
25
|
-
export type { AppEnv } from './http/app-env';
|
|
26
|
-
export { HttpStatus } from './http/http-status';
|
|
27
|
-
export { createNestErrorHandler, nestNotFoundHandler, NEST_REASON_PHRASES } from './http/nest-error';
|
|
28
|
-
export type { NestErrorHandlerOptions, ErrorReportContext, ErrorReporter } from './http/nest-error';
|
|
20
|
+
export { getUserProtocol } from './http/user-protocol.js';
|
|
21
|
+
export type { IUserProtocol } from './http/user-protocol.js';
|
|
22
|
+
export { getAppInfo } from './http/app-info.js';
|
|
23
|
+
export type { AppInfo } from './http/app-info.js';
|
|
24
|
+
export { resolveAppEnv, isProductionEnv } from './http/app-env.js';
|
|
25
|
+
export type { AppEnv } from './http/app-env.js';
|
|
26
|
+
export { HttpStatus } from './http/http-status.js';
|
|
27
|
+
export { createNestErrorHandler, nestNotFoundHandler, NEST_REASON_PHRASES } from './http/nest-error.js';
|
|
28
|
+
export type { NestErrorHandlerOptions, ErrorReportContext, ErrorReporter } from './http/nest-error.js';
|
|
29
29
|
|
|
30
30
|
// cache
|
|
31
|
-
export { KVCache } from './cache/kv-cache';
|
|
32
|
-
export type { KVNamespace, KVCacheOptions } from './cache/kv-cache';
|
|
31
|
+
export { KVCache } from './cache/kv-cache.js';
|
|
32
|
+
export type { KVNamespace, KVCacheOptions } from './cache/kv-cache.js';
|
|
33
33
|
|
|
34
34
|
// stripe
|
|
35
|
-
export { createStripeClient, verifyStripeWebhook } from './stripe/client';
|
|
36
|
-
export type { CreateStripeClientOptions } from './stripe/client';
|
|
35
|
+
export { createStripeClient, verifyStripeWebhook } from './stripe/client.js';
|
|
36
|
+
export type { CreateStripeClientOptions } from './stripe/client.js';
|
|
37
37
|
|
|
38
38
|
// db
|
|
39
|
-
export { retryWhenDeadlock } from './db/retry';
|
|
39
|
+
export { retryWhenDeadlock } from './db/retry.js';
|
|
40
40
|
|
|
41
41
|
// ai
|
|
42
|
-
export { createAiGatewayProvider } from './ai/gateway';
|
|
43
|
-
export type {
|
|
42
|
+
export { createAiGatewayProvider } from './ai/gateway.js';
|
|
43
|
+
export type {
|
|
44
|
+
AiGatewayConfig,
|
|
45
|
+
AiGatewayProvider,
|
|
46
|
+
AiGatewayBinding,
|
|
47
|
+
AiGateway,
|
|
48
|
+
AiGatewayOptions,
|
|
49
|
+
} from './ai/gateway.js';
|
|
44
50
|
|
|
45
51
|
// aws
|
|
46
|
-
export { getAuthenticationSecret } from './aws/secrets-manager';
|
|
47
|
-
export type { AwsSecretsOptions } from './aws/secrets-manager';
|
|
48
|
-
export { getCloudFrontSignedUrl } from './aws/cloudfront';
|
|
52
|
+
export { getAuthenticationSecret } from './aws/secrets-manager.js';
|
|
53
|
+
export type { AwsSecretsOptions } from './aws/secrets-manager.js';
|
|
54
|
+
export { getCloudFrontSignedUrl } from './aws/cloudfront.js';
|
|
49
55
|
|
|
50
56
|
// firebase
|
|
51
|
-
export type { DecodedIdToken, FirebaseVerifier } from './firebase/firebase-verifier';
|
|
52
|
-
export { JoseFirebaseVerifier, SECURETOKEN_JWK_URL } from './firebase/jose-firebase-verifier';
|
|
53
|
-
export { IdentityToolkit } from './firebase/identity-toolkit';
|
|
54
|
-
export type { ServiceAccount } from './firebase/identity-toolkit';
|
|
55
|
-
export { createRemoteFirebaseVerifier, createServiceAccountVerifier } from './firebase/remote-verifier';
|
|
57
|
+
export type { DecodedIdToken, FirebaseVerifier } from './firebase/firebase-verifier.js';
|
|
58
|
+
export { JoseFirebaseVerifier, SECURETOKEN_JWK_URL } from './firebase/jose-firebase-verifier.js';
|
|
59
|
+
export { IdentityToolkit } from './firebase/identity-toolkit.js';
|
|
60
|
+
export type { ServiceAccount } from './firebase/identity-toolkit.js';
|
|
61
|
+
export { createRemoteFirebaseVerifier, createServiceAccountVerifier } from './firebase/remote-verifier.js';
|
package/src/middleware/auth.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import type { Context, Env, MiddlewareHandler } from 'hono';
|
|
2
2
|
import { HTTPException } from 'hono/http-exception';
|
|
3
3
|
import type { ContentfulStatusCode } from 'hono/utils/http-status';
|
|
4
|
-
import { getAppInfo } from '../http/app-info';
|
|
5
|
-
import type { AppInfo } from '../http/app-info';
|
|
4
|
+
import { getAppInfo } from '../http/app-info.js';
|
|
5
|
+
import type { AppInfo } from '../http/app-info.js';
|
|
6
6
|
|
|
7
7
|
export interface AuthMiddlewareOptions<E extends Env, Verified, Id = unknown> {
|
|
8
8
|
/** ID トークンを載せるヘッダ。既定 `'x-amz-security-token'`(フリート共通)。 */
|
package/src/testing/auth.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { Pool } from 'mysql2/promise';
|
|
2
|
-
import type { DecodedIdToken } from '../firebase/firebase-verifier';
|
|
3
|
-
import type { FakeFirebaseVerifier } from './fakes';
|
|
2
|
+
import type { DecodedIdToken } from '../firebase/firebase-verifier.js';
|
|
3
|
+
import type { FakeFirebaseVerifier } from './fakes.js';
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* app interceptor 互換の認証ヘッダ(`x-amz-security-token` + `x-amz-meta-*`)を組む。
|
package/src/testing/fakes.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { Pool } from 'mysql2/promise';
|
|
2
|
-
import { databaseFrom } from '../db/database';
|
|
3
|
-
import type { DisposableDatabase } from '../db/database';
|
|
4
|
-
import type { DecodedIdToken, FirebaseVerifier } from '../firebase/firebase-verifier';
|
|
2
|
+
import { databaseFrom } from '../db/database.js';
|
|
3
|
+
import type { DisposableDatabase } from '../db/database.js';
|
|
4
|
+
import type { DecodedIdToken, FirebaseVerifier } from '../firebase/firebase-verifier.js';
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* オフライン route テスト用の in-memory FirebaseVerifier(4 repo 同一実装を集約)。
|
package/src/testing/index.ts
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
// @rdlabo/workers-hono-kit/testing — フリート共通のテスト基盤(mysql2/drizzle 依存)。
|
|
2
2
|
// 実行時には読み込まれないテスト専用ヘルパ。各 repo の testing/db.ts・fakes.ts を集約。
|
|
3
3
|
|
|
4
|
-
export { createTestDb } from './db';
|
|
5
|
-
export type { TestDb, CreateTestDbOptions, TestDbConnection } from './db';
|
|
4
|
+
export { createTestDb } from './db.js';
|
|
5
|
+
export type { TestDb, CreateTestDbOptions, TestDbConnection } from './db.js';
|
|
6
6
|
|
|
7
|
-
export { FakeFirebaseVerifier, createPoolDatabase, createNoopDatabase } from './fakes';
|
|
8
|
-
export type { CreatePoolDatabaseOptions } from './fakes';
|
|
9
|
-
export type { Database, DisposableDatabase, QueryRunner, TxOf } from '../db/database';
|
|
7
|
+
export { FakeFirebaseVerifier, createPoolDatabase, createNoopDatabase } from './fakes.js';
|
|
8
|
+
export type { CreatePoolDatabaseOptions } from './fakes.js';
|
|
9
|
+
export type { Database, DisposableDatabase, QueryRunner, TxOf } from '../db/database.js';
|
|
10
10
|
|
|
11
11
|
// 認証テストヘルパ(route spec のヘッダ生成・ユーザ provision を集約)。
|
|
12
|
-
export { authHeaders, registerFirebaseToken, provisionUser } from './auth';
|
|
12
|
+
export { authHeaders, registerFirebaseToken, provisionUser } from './auth.js';
|
|
13
13
|
|
|
14
14
|
// test double ヘルパ(未設定メソッドで明示 throw する部分実装 fake)。
|
|
15
|
-
export { configurableFake } from './configurable-fake';
|
|
15
|
+
export { configurableFake } from './configurable-fake.js';
|
|
16
16
|
|
|
17
17
|
// Stripe オブジェクトの test fixture factory。
|
|
18
18
|
export {
|
|
@@ -23,4 +23,4 @@ export {
|
|
|
23
23
|
fakeCustomer,
|
|
24
24
|
fakePrice,
|
|
25
25
|
fakeSubscription,
|
|
26
|
-
} from './stripe-fixtures';
|
|
26
|
+
} from './stripe-fixtures.js';
|