@kubun/plugin-rpc 0.13.0 → 0.13.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/lib/handlers.js CHANGED
@@ -55,7 +55,8 @@ export function createGraphHandlers(params) {
55
55
  clusters: ctx.param.clusters,
56
56
  id: ctx.param.id,
57
57
  name: ctx.param.name,
58
- plugins: ctx.param.plugins
58
+ plugins: ctx.param.plugins,
59
+ search: ctx.param.search
59
60
  });
60
61
  },
61
62
  'graph/list': async ()=>{
package/lib/index.d.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  import type { ServerTransportOf } from '@enkaku/protocol';
2
2
  import { type AccessRules, type Server } from '@enkaku/server';
3
+ import { type DIDResolver, type MethodRegistry } from '@kokuin/token';
3
4
  import type { KubunPlugin, PluginFactoryParams } from '@kubun/engine';
4
5
  import type { GraphProtocol } from '@kubun/protocol';
5
6
  import { type TransactionManagerOptions } from './transaction-manager.js';
@@ -18,12 +19,49 @@ export type RPCPluginOptions = {
18
19
  allowDelegatedMutations?: boolean;
19
20
  /** Configuration for the transaction manager. */
20
21
  transactionConfig?: TransactionManagerOptions;
22
+ /**
23
+ * DID resolver forwarded to Enkaku's transport-level message-signature
24
+ * verification. Rarely needed — supply one only to resolve a DID method the
25
+ * default `methods` registry does not cover.
26
+ */
27
+ resolver?: DIDResolver;
28
+ /**
29
+ * Method registry forwarded to Enkaku's transport-level message-signature
30
+ * verification. Defaults to the engine's own `did:kokuin:` controller
31
+ * resolver so a `did:kokuin:`-signed message over an authenticated socket
32
+ * verifies out of the box; pass a registry here to override that default.
33
+ */
34
+ methods?: MethodRegistry;
35
+ };
36
+ /**
37
+ * Parameters for a single `serve()` call.
38
+ */
39
+ export type RPCServerParams = {
40
+ /** The server-side transport this server reads and writes. */
41
+ transport: ServerTransport;
42
+ /** Aborts the server when signalled. */
43
+ signal?: AbortSignal;
44
+ /**
45
+ * Replaces the plugin-level `accessRules` for THIS server only, letting one
46
+ * host expose different procedure sets on different transports — e.g. a full
47
+ * admin transport plus a restricted agent channel that must not reach
48
+ * `graph/deploy` / `graph/list` / `graph/load`. `false` disables auth for
49
+ * this serve. Omit to keep the plugin default.
50
+ *
51
+ * Enkaku access checks are OR across every matching pattern (a procedure is
52
+ * admitted by the FIRST rule that allows it; a denying rule merely falls
53
+ * through), so a restricted rule set must ENUMERATE the procedures it grants
54
+ * rather than pairing a blanket `'*'` allow with per-procedure denials — a
55
+ * `'*'` allow re-admits everything. Omitting a procedure from the rules is
56
+ * what denies it (no matching allow rule).
57
+ */
58
+ accessRules?: false | AccessRules;
21
59
  };
22
60
  /**
23
61
  * API provided by the RPC plugin.
24
62
  */
25
63
  export type RPCPluginAPI = {
26
- serve: (transport: ServerTransport, signal?: AbortSignal) => Server<GraphProtocol>;
64
+ serve: (params: RPCServerParams) => Server<GraphProtocol>;
27
65
  };
28
66
  /**
29
67
  * Creates the RPC plugin.
package/lib/index.js CHANGED
@@ -16,6 +16,15 @@ import { TransactionManager } from './transaction-manager.js';
16
16
  return (params)=>{
17
17
  const servers = [];
18
18
  const signer = isSigningIdentity(params.identity) ? params.identity : null;
19
+ // Transport-level message-signature verification (Enkaku's `verifyToken`)
20
+ // runs per message, before any handler opens a write transaction — the same
21
+ // pre-transaction position as the engine's own `#controllerResolver`. So a
22
+ // `did:kokuin:` resolver over the base db is correct and deadlock-free here:
23
+ // it reads the controller store on the main connection while no write tx is
24
+ // held. A host may override the default via `options.methods`.
25
+ const methods = options?.methods ?? [
26
+ params.controllerResolverFor(params.db)
27
+ ];
19
28
  const transactionManager = new TransactionManager({
20
29
  runtime: params.runtime,
21
30
  ...options?.transactionConfig
@@ -31,14 +40,20 @@ import { TransactionManager } from './transaction-manager.js';
31
40
  transactionManager
32
41
  });
33
42
  const api = {
34
- serve: (transport, signal)=>{
35
- const accessRules = options?.accessRules;
43
+ serve: (serverParams)=>{
44
+ const { transport, signal } = serverParams;
45
+ // A per-serve override replaces the plugin-level rules for this server
46
+ // only; omitting the key keeps the plugin default, while an explicit
47
+ // `false` disables auth for this serve.
48
+ const accessRules = 'accessRules' in serverParams ? serverParams.accessRules : options?.accessRules;
36
49
  const baseParams = {
37
50
  runtime: params.runtime,
38
51
  handlers,
39
52
  logger: params.getLogger('rpc-server'),
40
53
  signal,
41
- transport
54
+ transport,
55
+ resolver: options?.resolver,
56
+ methods
42
57
  };
43
58
  const serveParams = accessRules === false ? {
44
59
  ...baseParams,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kubun/plugin-rpc",
3
- "version": "0.13.0",
3
+ "version": "0.13.2",
4
4
  "license": "see LICENSE.md",
5
5
  "sideEffects": false,
6
6
  "type": "module",
@@ -20,21 +20,23 @@
20
20
  "@sozai/runtime": "^0.1.0",
21
21
  "graphql": "^16.14.2",
22
22
  "@kubun/db": "^0.13.0",
23
- "@kubun/engine": "^0.13.0",
24
- "@kubun/mutation": "^0.13.0",
25
- "@kubun/protocol": "^0.13.0",
23
+ "@kubun/protocol": "^0.13.1",
24
+ "@kubun/graphql": "^0.13.1",
26
25
  "@kubun/hlc": "^0.13.0",
27
- "@kubun/graphql": "^0.13.0"
26
+ "@kubun/engine": "^0.13.1",
27
+ "@kubun/mutation": "^0.13.0"
28
28
  },
29
29
  "devDependencies": {
30
30
  "@enkaku/transport": "^0.21.0",
31
31
  "@kokuin/capability": "^0.3.0",
32
- "@kubun/client": "^0.13.0",
32
+ "@kokuin/controller": "^0.1.0",
33
+ "@kubun/store-controller": "^0.13.0",
33
34
  "@kubun/store-delegation": "^0.13.0",
35
+ "@kubun/test-utils": "^0.13.0",
34
36
  "@kubun/id": "^0.13.0",
35
- "@kubun/store-p2p": "^0.13.0",
36
- "@kubun/store-graph": "^0.13.0",
37
- "@kubun/test-utils": "^0.13.0"
37
+ "@kubun/store-graph": "^0.13.2",
38
+ "@kubun/client": "^0.13.0",
39
+ "@kubun/store-p2p": "^0.13.0"
38
40
  },
39
41
  "publishConfig": {
40
42
  "access": "public"