@nkmc/gateway 0.1.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.
Files changed (130) hide show
  1. package/dist/chunk-56RA53VS.js +37 -0
  2. package/dist/chunk-CZJ75YTV.js +969 -0
  3. package/dist/chunk-QGM4M3NI.js +37 -0
  4. package/dist/http.cjs +1772 -0
  5. package/dist/http.d.cts +49 -0
  6. package/dist/http.d.ts +49 -0
  7. package/dist/http.js +748 -0
  8. package/dist/index.cjs +2436 -0
  9. package/dist/index.d.cts +436 -0
  10. package/dist/index.d.ts +436 -0
  11. package/dist/index.js +1434 -0
  12. package/dist/proxy-ClPcDgsO.d.cts +283 -0
  13. package/dist/proxy-qpda1ANS.d.ts +283 -0
  14. package/dist/proxy.cjs +148 -0
  15. package/dist/proxy.d.cts +6 -0
  16. package/dist/proxy.d.ts +6 -0
  17. package/dist/proxy.js +90 -0
  18. package/dist/testing.cjs +865 -0
  19. package/dist/testing.d.cts +12 -0
  20. package/dist/testing.d.ts +12 -0
  21. package/dist/testing.js +831 -0
  22. package/dist/tunnels-BviBEaih.d.cts +12 -0
  23. package/dist/tunnels-DFHNgmN7.d.ts +12 -0
  24. package/dist/types-C6JC9oTm.d.cts +21 -0
  25. package/dist/types-C6JC9oTm.d.ts +21 -0
  26. package/package.json +47 -0
  27. package/src/__tests__/sqlite-integration.test.ts +384 -0
  28. package/src/credential/d1-vault.ts +134 -0
  29. package/src/credential/memory-vault.ts +50 -0
  30. package/src/credential/types.ts +16 -0
  31. package/src/d1/__tests__/sqlite-adapter.test.ts +75 -0
  32. package/src/d1/sqlite-adapter.ts +59 -0
  33. package/src/d1/types.ts +22 -0
  34. package/src/federation/__tests__/d1-peer-store.test.ts +218 -0
  35. package/src/federation/__tests__/peer-client.test.ts +205 -0
  36. package/src/federation/__tests__/peer-store.test.ts +114 -0
  37. package/src/federation/d1-peer-store.ts +164 -0
  38. package/src/federation/peer-backend.ts +60 -0
  39. package/src/federation/peer-client.ts +122 -0
  40. package/src/federation/peer-store.ts +45 -0
  41. package/src/federation/types.ts +39 -0
  42. package/src/http/app.ts +152 -0
  43. package/src/http/lib/dns.ts +30 -0
  44. package/src/http/middleware/admin-auth.ts +18 -0
  45. package/src/http/middleware/agent-auth.ts +27 -0
  46. package/src/http/middleware/publish-auth.ts +39 -0
  47. package/src/http/routes/__tests__/federation.test.ts +364 -0
  48. package/src/http/routes/__tests__/peers.test.ts +290 -0
  49. package/src/http/routes/__tests__/proxy.test.ts +159 -0
  50. package/src/http/routes/auth.ts +39 -0
  51. package/src/http/routes/byok.ts +62 -0
  52. package/src/http/routes/credentials.ts +40 -0
  53. package/src/http/routes/domains.ts +174 -0
  54. package/src/http/routes/federation.ts +170 -0
  55. package/src/http/routes/fs.ts +89 -0
  56. package/src/http/routes/peers.ts +103 -0
  57. package/src/http/routes/proxy.ts +57 -0
  58. package/src/http/routes/registry.ts +222 -0
  59. package/src/http/routes/tunnels.ts +124 -0
  60. package/src/http.ts +9 -0
  61. package/src/index.ts +63 -0
  62. package/src/metering/d1-store.ts +123 -0
  63. package/src/metering/memory-store.ts +29 -0
  64. package/src/metering/pricing-guard.ts +68 -0
  65. package/src/metering/types.ts +25 -0
  66. package/src/onboard/apis-guru.ts +64 -0
  67. package/src/onboard/index.ts +4 -0
  68. package/src/onboard/manifest.ts +362 -0
  69. package/src/onboard/pipeline.ts +214 -0
  70. package/src/onboard/types.ts +72 -0
  71. package/src/proxy/__tests__/tool-registry.test.ts +93 -0
  72. package/src/proxy/tool-registry.ts +122 -0
  73. package/src/proxy.ts +12 -0
  74. package/src/registry/context7-backend.ts +93 -0
  75. package/src/registry/context7.ts +54 -0
  76. package/src/registry/d1-store.ts +242 -0
  77. package/src/registry/memory-store.ts +101 -0
  78. package/src/registry/openapi-compiler.ts +284 -0
  79. package/src/registry/resolver.ts +196 -0
  80. package/src/registry/rpc-compiler.ts +142 -0
  81. package/src/registry/skill-parser.ts +119 -0
  82. package/src/registry/skill-to-config.ts +239 -0
  83. package/src/registry/source-refresher.ts +83 -0
  84. package/src/registry/types.ts +129 -0
  85. package/src/registry/virtual-files.ts +76 -0
  86. package/src/testing/sqlite-d1.ts +64 -0
  87. package/src/testing.ts +2 -0
  88. package/src/tunnel/__tests__/cloudflare-provider.test.ts +255 -0
  89. package/src/tunnel/__tests__/tunnel.test.ts +542 -0
  90. package/src/tunnel/cloudflare-provider.ts +121 -0
  91. package/src/tunnel/memory-store.ts +30 -0
  92. package/src/tunnel/types.ts +28 -0
  93. package/test/credential/d1-vault.test.ts +127 -0
  94. package/test/credential/injection.test.ts +67 -0
  95. package/test/credential/memory-vault.test.ts +63 -0
  96. package/test/http/app.test.ts +300 -0
  97. package/test/http/byok-e2e.test.ts +240 -0
  98. package/test/http/byok.test.ts +115 -0
  99. package/test/http/credentials.test.ts +57 -0
  100. package/test/http/e2e.test.ts +260 -0
  101. package/test/integration/authenticated-apis.test.ts +185 -0
  102. package/test/integration/free-apis-e2e.test.ts +222 -0
  103. package/test/metering/d1-store.test.ts +82 -0
  104. package/test/metering/memory-store.test.ts +76 -0
  105. package/test/metering/pricing-guard.test.ts +108 -0
  106. package/test/onboard/apis-guru.test.ts +57 -0
  107. package/test/onboard/e2e.test.ts +70 -0
  108. package/test/onboard/pipeline.test.ts +318 -0
  109. package/test/onboard/real-apis.test.ts +483 -0
  110. package/test/registry/compilation-correctness.test.ts +132 -0
  111. package/test/registry/context7-backend.test.ts +88 -0
  112. package/test/registry/context7-e2e.test.ts +92 -0
  113. package/test/registry/context7.test.ts +73 -0
  114. package/test/registry/d1-store.test.ts +184 -0
  115. package/test/registry/integration.test.ts +129 -0
  116. package/test/registry/lazy-mount.test.ts +138 -0
  117. package/test/registry/memory-store.test.ts +171 -0
  118. package/test/registry/openapi-compiler.test.ts +267 -0
  119. package/test/registry/openapi-e2e.test.ts +154 -0
  120. package/test/registry/passthrough-e2e.test.ts +109 -0
  121. package/test/registry/resolver-peer.test.ts +299 -0
  122. package/test/registry/resolver.test.ts +228 -0
  123. package/test/registry/rpc-compiler.test.ts +112 -0
  124. package/test/registry/skill-parser.test.ts +151 -0
  125. package/test/registry/skill-to-config.test.ts +151 -0
  126. package/test/registry/skill-to-rpc-config.test.ts +142 -0
  127. package/test/registry/source-refresher.test.ts +90 -0
  128. package/test/registry/virtual-files.test.ts +96 -0
  129. package/tsconfig.json +4 -0
  130. package/tsup.config.ts +8 -0
@@ -0,0 +1,49 @@
1
+ import { E as Env, R as RegistryStore } from './proxy-ClPcDgsO.cjs';
2
+ export { G as GatewayOptions, c as createGateway } from './proxy-ClPcDgsO.cjs';
3
+ import * as hono from 'hono';
4
+ import { Hono } from 'hono';
5
+ import { JWK } from 'jose';
6
+ import * as hono_types from 'hono/types';
7
+ import { D as D1Database } from './types-C6JC9oTm.cjs';
8
+ import { AgentFs } from '@nkmc/agent-fs';
9
+ export { T as TunnelRouteOptions, t as tunnelRoutes } from './tunnels-BviBEaih.cjs';
10
+
11
+ declare function adminAuth(adminToken: string): hono.MiddlewareHandler<Env, string, {}, Response>;
12
+
13
+ type PublishAuthContext = {
14
+ type: "admin";
15
+ } | {
16
+ type: "publish";
17
+ domain: string;
18
+ };
19
+ type PublishAuthEnv = {
20
+ Variables: {
21
+ publishAuth: PublishAuthContext;
22
+ };
23
+ };
24
+ declare function publishOrAdminAuth(adminToken: string, publicKey: JWK): hono.MiddlewareHandler<PublishAuthEnv, string, {}, Response>;
25
+
26
+ declare function agentAuth(publicKey: JWK): hono.MiddlewareHandler<Env, string, {}, Response>;
27
+
28
+ interface AuthRouteOptions {
29
+ privateKey: JWK;
30
+ }
31
+ declare function authRoutes(options: AuthRouteOptions): Hono<Env, hono_types.BlankSchema, "/">;
32
+
33
+ interface RegistryRouteOptions {
34
+ store: RegistryStore;
35
+ }
36
+ declare function registryRoutes(options: RegistryRouteOptions): Hono<Env, hono_types.BlankSchema, "/">;
37
+
38
+ interface DomainRouteOptions {
39
+ db: D1Database;
40
+ gatewayPrivateKey: JWK;
41
+ }
42
+ declare function domainRoutes(options: DomainRouteOptions): Hono<hono_types.BlankEnv, hono_types.BlankSchema, "/">;
43
+
44
+ interface FsRouteOptions {
45
+ agentFs: AgentFs;
46
+ }
47
+ declare function fsRoutes(options: FsRouteOptions): Hono<Env, hono_types.BlankSchema, "/">;
48
+
49
+ export { type AuthRouteOptions, type DomainRouteOptions, Env, type FsRouteOptions, type PublishAuthContext, type RegistryRouteOptions, adminAuth, agentAuth, authRoutes, domainRoutes, fsRoutes, publishOrAdminAuth, registryRoutes };
package/dist/http.d.ts ADDED
@@ -0,0 +1,49 @@
1
+ import { E as Env, R as RegistryStore } from './proxy-qpda1ANS.js';
2
+ export { G as GatewayOptions, c as createGateway } from './proxy-qpda1ANS.js';
3
+ import * as hono from 'hono';
4
+ import { Hono } from 'hono';
5
+ import { JWK } from 'jose';
6
+ import * as hono_types from 'hono/types';
7
+ import { D as D1Database } from './types-C6JC9oTm.js';
8
+ import { AgentFs } from '@nkmc/agent-fs';
9
+ export { T as TunnelRouteOptions, t as tunnelRoutes } from './tunnels-DFHNgmN7.js';
10
+
11
+ declare function adminAuth(adminToken: string): hono.MiddlewareHandler<Env, string, {}, Response>;
12
+
13
+ type PublishAuthContext = {
14
+ type: "admin";
15
+ } | {
16
+ type: "publish";
17
+ domain: string;
18
+ };
19
+ type PublishAuthEnv = {
20
+ Variables: {
21
+ publishAuth: PublishAuthContext;
22
+ };
23
+ };
24
+ declare function publishOrAdminAuth(adminToken: string, publicKey: JWK): hono.MiddlewareHandler<PublishAuthEnv, string, {}, Response>;
25
+
26
+ declare function agentAuth(publicKey: JWK): hono.MiddlewareHandler<Env, string, {}, Response>;
27
+
28
+ interface AuthRouteOptions {
29
+ privateKey: JWK;
30
+ }
31
+ declare function authRoutes(options: AuthRouteOptions): Hono<Env, hono_types.BlankSchema, "/">;
32
+
33
+ interface RegistryRouteOptions {
34
+ store: RegistryStore;
35
+ }
36
+ declare function registryRoutes(options: RegistryRouteOptions): Hono<Env, hono_types.BlankSchema, "/">;
37
+
38
+ interface DomainRouteOptions {
39
+ db: D1Database;
40
+ gatewayPrivateKey: JWK;
41
+ }
42
+ declare function domainRoutes(options: DomainRouteOptions): Hono<hono_types.BlankEnv, hono_types.BlankSchema, "/">;
43
+
44
+ interface FsRouteOptions {
45
+ agentFs: AgentFs;
46
+ }
47
+ declare function fsRoutes(options: FsRouteOptions): Hono<Env, hono_types.BlankSchema, "/">;
48
+
49
+ export { type AuthRouteOptions, type DomainRouteOptions, Env, type FsRouteOptions, type PublishAuthContext, type RegistryRouteOptions, adminAuth, agentAuth, authRoutes, domainRoutes, fsRoutes, publishOrAdminAuth, registryRoutes };