@kubun/hub 0.17.0 → 0.17.1
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/lib/create-relay.d.ts +11 -1
- package/lib/create-relay.js +4 -0
- package/lib/index.d.ts +7 -1
- package/lib/index.js +1 -0
- package/package.json +1 -1
package/lib/create-relay.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { Identity } from '@kokuin/token';
|
|
2
2
|
import type { Adapter } from '@kubun/db-adapter';
|
|
3
3
|
import { type AdapterInput } from '@kubun/db-provider';
|
|
4
|
-
import type { AuthorizeHook } from '@kumiai/hub-server';
|
|
4
|
+
import type { AuthorizeHook, HubRateLimits } from '@kumiai/hub-server';
|
|
5
5
|
import { Kysely } from 'kysely';
|
|
6
6
|
import { type HubDatabase, type KubunHubStore } from './hub-store.js';
|
|
7
7
|
import { type RelayObservers } from './observers.js';
|
|
@@ -29,6 +29,15 @@ export type CreateRelayOptions = {
|
|
|
29
29
|
*/
|
|
30
30
|
authorize?: AuthorizeHook;
|
|
31
31
|
allowedOrigin?: string | Array<string>;
|
|
32
|
+
/**
|
|
33
|
+
* Per-DID / per-topic rate limits, forwarded verbatim to `@kumiai/hub-server`
|
|
34
|
+
* `createHub`. Merged per-field over its `DEFAULT_RATE_LIMITS`
|
|
35
|
+
* (`perDID: { rate: 20, burst: 50 }`, `perTopic: { rate: 100, burst: 200 }`),
|
|
36
|
+
* so a partial override touches only the fields it sets. Omitted, the hub
|
|
37
|
+
* keeps those defaults. An embedded/loopback relay can raise or effectively
|
|
38
|
+
* disable the limit for high-op-rate use.
|
|
39
|
+
*/
|
|
40
|
+
rateLimits?: Partial<HubRateLimits>;
|
|
32
41
|
retention?: RelayRetentionConfig;
|
|
33
42
|
defaultRetention?: number;
|
|
34
43
|
maxRetention?: number;
|
|
@@ -54,6 +63,7 @@ export type RelayInternalOptions = {
|
|
|
54
63
|
*/
|
|
55
64
|
authorize?: AuthorizeHook;
|
|
56
65
|
allowedOrigin?: string | Array<string>;
|
|
66
|
+
rateLimits?: Partial<HubRateLimits>;
|
|
57
67
|
retention?: RelayRetentionConfig;
|
|
58
68
|
defaultRetention?: number;
|
|
59
69
|
maxRetention?: number;
|
package/lib/create-relay.js
CHANGED
|
@@ -98,6 +98,9 @@ export async function createRelayInternal(options) {
|
|
|
98
98
|
identity: options.identity,
|
|
99
99
|
accessRules,
|
|
100
100
|
authorize: options.authorize,
|
|
101
|
+
...options.rateLimits != null ? {
|
|
102
|
+
rateLimits: options.rateLimits
|
|
103
|
+
} : {},
|
|
101
104
|
purge: false
|
|
102
105
|
});
|
|
103
106
|
if (observers?.onAuthRejected != null) {
|
|
@@ -225,6 +228,7 @@ export async function createRelay(options) {
|
|
|
225
228
|
auth: options.auth,
|
|
226
229
|
authorize: options.authorize,
|
|
227
230
|
allowedOrigin: options.allowedOrigin,
|
|
231
|
+
rateLimits: options.rateLimits,
|
|
228
232
|
retention: options.retention,
|
|
229
233
|
defaultRetention: options.defaultRetention,
|
|
230
234
|
maxRetention: options.maxRetention,
|
package/lib/index.d.ts
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import type { Identity } from '@kokuin/token';
|
|
2
2
|
import type { Adapter } from '@kubun/db-adapter';
|
|
3
|
+
import type { HubRateLimits } from '@kumiai/hub-server';
|
|
3
4
|
import type { Kysely } from 'kysely';
|
|
4
5
|
import { type HubAuthConfig, type RelayRetentionConfig } from './create-relay.js';
|
|
5
6
|
import type { HubDatabase } from './hub-store.js';
|
|
6
7
|
import type { RelayObservers } from './observers.js';
|
|
7
|
-
export type { AuthorizeDecision, AuthorizeHook, AuthorizeRequest } from '@kumiai/hub-server';
|
|
8
|
+
export type { AuthorizeDecision, AuthorizeHook, AuthorizeRequest, HubRateLimits, RateLimitConfig, } from '@kumiai/hub-server';
|
|
8
9
|
export { type CreateRelayOptions, createRelay, createRelayInternal, type HubAuthConfig, type Relay, type RelayRetentionConfig, } from './create-relay.js';
|
|
9
10
|
export { type CreateHubStoreParams, createHubStore, type HubDatabase, type KubunHubStore, type PurgedSubscription, type PurgeSubscriptionsParams, } from './hub-store.js';
|
|
10
11
|
export { type JoinLaneAuthorizeConfig, joinLaneAuthorize } from './join-lane-authorize.js';
|
|
@@ -30,6 +31,11 @@ export type HubOptions = {
|
|
|
30
31
|
* omitted, no access rules are configured beyond signature verification.
|
|
31
32
|
*/
|
|
32
33
|
auth?: HubAuthConfig;
|
|
34
|
+
/**
|
|
35
|
+
* Per-DID / per-topic rate limits, forwarded verbatim to `@kumiai/hub-server`.
|
|
36
|
+
* Omitted, its defaults apply. See `CreateRelayOptions.rateLimits`.
|
|
37
|
+
*/
|
|
38
|
+
rateLimits?: Partial<HubRateLimits>;
|
|
33
39
|
/** Optional retention scheduler. */
|
|
34
40
|
retention?: RelayRetentionConfig;
|
|
35
41
|
/** Optional observers for counters / diagnostics. */
|
package/lib/index.js
CHANGED