@techdigger/humanode-agentlink 0.2.0 → 0.3.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.
@@ -812,7 +812,7 @@ declare function decodeLinkSession(value: string): AgentLinkSession;
812
812
  declare function buildHostedLinkUrl(baseUrl: string, session: AgentLinkSession): string;
813
813
  declare function buildEmbeddedHostedLinkUrl(baseUrl: string, session: AgentLinkSession): string;
814
814
 
815
- interface BiomapperLinkProtectedRoute extends Omit<RouteConfig, 'accepts'> {
815
+ interface AgentLinkProtectedRoute extends Omit<RouteConfig, 'accepts'> {
816
816
  price: Price | DynamicPrice;
817
817
  payTo: string | DynamicPayTo;
818
818
  network?: Network;
@@ -820,16 +820,16 @@ interface BiomapperLinkProtectedRoute extends Omit<RouteConfig, 'accepts'> {
820
820
  maxTimeoutSeconds?: number;
821
821
  extra?: Record<string, unknown>;
822
822
  }
823
- interface BiomapperLinkSchemeRegistration {
823
+ interface AgentLinkSchemeRegistration {
824
824
  network: Network;
825
825
  server: SchemeNetworkServer;
826
826
  }
827
827
  /** Generic middleware signature compatible with Hono and similar frameworks. */
828
828
  type AgentLinkMiddleware<TContext = unknown> = (context: TContext, next: () => Promise<void>) => Promise<Response | void>;
829
- interface BiomapperLinkCallable {
829
+ interface AgentLinkCallable {
830
830
  <TContext = unknown>(context: TContext, next: () => Promise<void>): Promise<Response | void>;
831
831
  }
832
- interface BiomapperLinkOptions {
832
+ interface AgentLinkOptions {
833
833
  /** "base" or "base-sepolia" */
834
834
  network: BiomapperRegistryNetwork;
835
835
  /** Deployed BiomapperAgentRegistry contract address. */
@@ -857,7 +857,7 @@ interface BiomapperLinkOptions {
857
857
  /** Domain for the SIWE message. Derived from request URL if omitted. */
858
858
  domain?: string;
859
859
  /** Simplified x402 route config for the ready-to-use middleware path. */
860
- protect?: Record<string, BiomapperLinkProtectedRoute>;
860
+ protect?: Record<string, AgentLinkProtectedRoute>;
861
861
  /** Full x402 routes config for the ready-to-use middleware path. */
862
862
  routes?: RoutesConfig;
863
863
  /** Custom facilitator client(s) for the ready-to-use middleware path. */
@@ -865,13 +865,13 @@ interface BiomapperLinkOptions {
865
865
  /** Override the default x402 facilitator URL for the ready-to-use middleware path. */
866
866
  facilitatorUrl?: string;
867
867
  /** Override automatic exact-EVM scheme registration for the ready-to-use middleware path. */
868
- schemes?: BiomapperLinkSchemeRegistration[];
868
+ schemes?: AgentLinkSchemeRegistration[];
869
869
  /** Built-in paywall config for the ready-to-use middleware path. */
870
870
  paywallConfig?: PaywallConfig;
871
871
  /** Custom paywall provider for the ready-to-use middleware path. */
872
872
  paywall?: PaywallProvider;
873
873
  }
874
- interface BiomapperLinkControlSurface {
874
+ interface AgentLinkControlSurface {
875
875
  extension: typeof agentlinkResourceServerExtension;
876
876
  declare(overrides?: Partial<DeclareAgentLinkOptions>): ReturnType<typeof declareAgentLinkExtension>;
877
877
  requestHook: ReturnType<typeof createAgentLinkHooks>['requestHook'];
@@ -882,7 +882,7 @@ interface BiomapperLinkControlSurface {
882
882
  httpServer?: x402HTTPResourceServer;
883
883
  }
884
884
  /**
885
- * One-call setup for Biomapper Link.
885
+ * One-call setup for Humanode Agentlink.
886
886
  *
887
887
  * Collapses registry verifier, storage, hooks, extension declaration,
888
888
  * and webhook wiring into a single factory. When `protect` or `routes`
@@ -890,7 +890,7 @@ interface BiomapperLinkControlSurface {
890
890
  *
891
891
  * @example
892
892
  * ```ts
893
- * const link = createBiomapperLink({
893
+ * const link = createAgentLink({
894
894
  * network: "base-sepolia",
895
895
  * registry: "0xYourRegistry",
896
896
  * protect: {
@@ -904,8 +904,8 @@ interface BiomapperLinkControlSurface {
904
904
  * app.use(link);
905
905
  * ```
906
906
  */
907
- declare function createBiomapperLink(options: BiomapperLinkOptions): BiomapperLink;
908
- type BiomapperLink = BiomapperLinkCallable & BiomapperLinkControlSurface;
907
+ declare function createAgentLink(options: AgentLinkOptions): AgentLink;
908
+ type AgentLink = AgentLinkCallable & AgentLinkControlSurface;
909
909
 
910
910
  /** A Next.js App Router route handler: `(request: Request) => Promise<Response>` */
911
911
  type NextRouteHandler = (request: Request) => Promise<Response>;
@@ -960,4 +960,4 @@ declare function verifyAgentLinkWebhookSignature(options: VerifyAgentLinkWebhook
960
960
  declare function dispatchAgentLinkWebhook<TEvent extends AgentLinkEvent>(event: TEvent, options: AgentLinkWebhookDispatcherOptions): Promise<AgentLinkWebhookEnvelope<TEvent>>;
961
961
  declare function createAgentLinkWebhookDispatcher(options: AgentLinkWebhookDispatcherOptions): AgentLinkEventHandler;
962
962
 
963
- export { AGENTLINK, AGENT_LINK_TYPES, type AgentLinkAuthorization, type AgentLinkConsentClient, type AgentLinkConsentOutput, type AgentLinkConsentSigner, type AgentLinkEntitlement, type AgentLinkEntitlementContext, type AgentLinkEntitlementResolver, type AgentLinkEvent, type AgentLinkEventHandler, type AgentLinkExtension, type AgentLinkExtensionInfo, type AgentLinkExtensionSchema, type AgentLinkHookEvent, type AgentLinkMiddleware, type AgentLinkMode, type AgentLinkPayload, AgentLinkPayloadSchema, type AgentLinkSession, type AgentLinkSessionBranding, type AgentLinkSessionEvent, type AgentLinkSessionStore, type AgentLinkStorage, type AgentLinkUsageContext, type AgentLinkValidationOptions, type AgentLinkValidationResult, type AgentLinkVerifyResult, type AgentLinkWebhookDispatcherOptions, type AgentLinkWebhookEnvelope, type AgentLinkWebhookSignatureVerificationResult, BIOMAPPER_AGENT_REGISTRY_ABI$1 as BIOMAPPER_AGENT_REGISTRY_ABI, BIOMAPPER_AGENT_REGISTRY_NAME, BIOMAPPER_AGENT_REGISTRY_VERSION, BIOMAPPER_APP_URLS, BRIDGED_BIOMAPPER_ADDRESSES, BRIDGED_BIOMAPPER_READ_ABI, type BiomapperAgentStatus, type BiomapperBridgeNetwork, type BiomapperLink, type BiomapperLinkControlSurface, type BiomapperLinkOptions, type BiomapperLinkProtectedRoute, type BiomapperLinkSchemeRegistration, type BiomapperNetworkInfo, BiomapperNetworkSchema, type BiomapperQueryClient, BiomapperQueryError, type BiomapperQueryErrorCode, type BiomapperQueryNetwork, type BiomapperRegistryNetwork, type BiomapperRegistryOptions, type BiomapperRegistryVerifier, CHECK_AGENT_STATUS_TOOL_DESCRIPTION, CHECK_AGENT_STATUS_TOOL_NAME, type CheckAgentStatusInput, CheckAgentStatusInputSchema, type CheckAgentStatusResult, CheckAgentStatusResultSchema, type CompleteAgentLinkInfo, type CreateAgentLinkConsentOptions, type CreateAgentLinkHooksOptions, type CreateBiomapperQueryClientOptions, type CreateLinkSessionInput, type CreateLinkSessionOptions, type DeclareAgentLinkOptions, GET_BIOMAPPER_INFO_TOOL_DESCRIPTION, GET_BIOMAPPER_INFO_TOOL_NAME, GET_CURRENT_GENERATION_TOOL_DESCRIPTION, GET_CURRENT_GENERATION_TOOL_NAME, type GetBiomapperInfoInput, GetBiomapperInfoInputSchema, type GetBiomapperInfoResult, GetBiomapperInfoResultSchema, type GetCurrentGenerationInput, GetCurrentGenerationInputSchema, type GetCurrentGenerationResult, GetCurrentGenerationResultSchema, type HonoLikeMiddleware, type HonoPaymentMiddleware, InMemoryAgentLinkStorage, InMemoryLinkSessionStore, type LinkSessionValidationOptions, type LinkSessionValidationResult, type NextPaymentMiddleware, type NextRouteHandler, type ResolveAgentLinkEntitlementInput, type SignatureScheme, type SignatureType, type SupportedChain, type VerifyAgentLinkWebhookSignatureOptions, agentlinkResourceServerExtension, buildAgentLinkSchema, buildAgentLinkTypedData, buildAgentLinkUsageKey, buildEmbeddedHostedLinkUrl, buildHostedLinkUrl, createAgentLinkConsent, createAgentLinkHooks, createAgentLinkWebhookDispatcher, createAgentLinkWebhookEnvelope, createBiomapperLink, createBiomapperQueryClient, createBiomapperRegistryVerifier, createHonoPaymentMiddlewareFromHTTPServer, createLinkSession, createNextPaymentHandlerFromHTTPServer, declareAgentLinkExtension, decodeLinkSession, dispatchAgentLinkWebhook, encodeLinkSession, extractEVMChainId, formatSIWEMessage, getLinkSession, parseAgentLinkHeader, validateAgentLinkMessage, validateLinkSession, verifyAgentLinkSignature, verifyAgentLinkWebhookSignature, verifyEVMSignature };
963
+ export { AGENTLINK, AGENT_LINK_TYPES, type AgentLink, type AgentLinkAuthorization, type AgentLinkCallable, type AgentLinkConsentClient, type AgentLinkConsentOutput, type AgentLinkConsentSigner, type AgentLinkControlSurface, type AgentLinkEntitlement, type AgentLinkEntitlementContext, type AgentLinkEntitlementResolver, type AgentLinkEvent, type AgentLinkEventHandler, type AgentLinkExtension, type AgentLinkExtensionInfo, type AgentLinkExtensionSchema, type AgentLinkHookEvent, type AgentLinkMiddleware, type AgentLinkMode, type AgentLinkOptions, type AgentLinkPayload, AgentLinkPayloadSchema, type AgentLinkProtectedRoute, type AgentLinkSchemeRegistration, type AgentLinkSession, type AgentLinkSessionBranding, type AgentLinkSessionEvent, type AgentLinkSessionStore, type AgentLinkStorage, type AgentLinkUsageContext, type AgentLinkValidationOptions, type AgentLinkValidationResult, type AgentLinkVerifyResult, type AgentLinkWebhookDispatcherOptions, type AgentLinkWebhookEnvelope, type AgentLinkWebhookSignatureVerificationResult, BIOMAPPER_AGENT_REGISTRY_ABI$1 as BIOMAPPER_AGENT_REGISTRY_ABI, BIOMAPPER_AGENT_REGISTRY_NAME, BIOMAPPER_AGENT_REGISTRY_VERSION, BIOMAPPER_APP_URLS, BRIDGED_BIOMAPPER_ADDRESSES, BRIDGED_BIOMAPPER_READ_ABI, type BiomapperAgentStatus, type BiomapperBridgeNetwork, type BiomapperNetworkInfo, BiomapperNetworkSchema, type BiomapperQueryClient, BiomapperQueryError, type BiomapperQueryErrorCode, type BiomapperQueryNetwork, type BiomapperRegistryNetwork, type BiomapperRegistryOptions, type BiomapperRegistryVerifier, CHECK_AGENT_STATUS_TOOL_DESCRIPTION, CHECK_AGENT_STATUS_TOOL_NAME, type CheckAgentStatusInput, CheckAgentStatusInputSchema, type CheckAgentStatusResult, CheckAgentStatusResultSchema, type CompleteAgentLinkInfo, type CreateAgentLinkConsentOptions, type CreateAgentLinkHooksOptions, type CreateBiomapperQueryClientOptions, type CreateLinkSessionInput, type CreateLinkSessionOptions, type DeclareAgentLinkOptions, GET_BIOMAPPER_INFO_TOOL_DESCRIPTION, GET_BIOMAPPER_INFO_TOOL_NAME, GET_CURRENT_GENERATION_TOOL_DESCRIPTION, GET_CURRENT_GENERATION_TOOL_NAME, type GetBiomapperInfoInput, GetBiomapperInfoInputSchema, type GetBiomapperInfoResult, GetBiomapperInfoResultSchema, type GetCurrentGenerationInput, GetCurrentGenerationInputSchema, type GetCurrentGenerationResult, GetCurrentGenerationResultSchema, type HonoLikeMiddleware, type HonoPaymentMiddleware, InMemoryAgentLinkStorage, InMemoryLinkSessionStore, type LinkSessionValidationOptions, type LinkSessionValidationResult, type NextPaymentMiddleware, type NextRouteHandler, type ResolveAgentLinkEntitlementInput, type SignatureScheme, type SignatureType, type SupportedChain, type VerifyAgentLinkWebhookSignatureOptions, agentlinkResourceServerExtension, buildAgentLinkSchema, buildAgentLinkTypedData, buildAgentLinkUsageKey, buildEmbeddedHostedLinkUrl, buildHostedLinkUrl, createAgentLink, createAgentLinkConsent, createAgentLinkHooks, createAgentLinkWebhookDispatcher, createAgentLinkWebhookEnvelope, createBiomapperQueryClient, createBiomapperRegistryVerifier, createHonoPaymentMiddlewareFromHTTPServer, createLinkSession, createNextPaymentHandlerFromHTTPServer, declareAgentLinkExtension, decodeLinkSession, dispatchAgentLinkWebhook, encodeLinkSession, extractEVMChainId, formatSIWEMessage, getLinkSession, parseAgentLinkHeader, validateAgentLinkMessage, validateLinkSession, verifyAgentLinkSignature, verifyAgentLinkWebhookSignature, verifyEVMSignature };
package/dist/cjs/index.js CHANGED
@@ -61,11 +61,11 @@ __export(src_exports, {
61
61
  buildAgentLinkUsageKey: () => buildAgentLinkUsageKey,
62
62
  buildEmbeddedHostedLinkUrl: () => buildEmbeddedHostedLinkUrl,
63
63
  buildHostedLinkUrl: () => buildHostedLinkUrl,
64
+ createAgentLink: () => createAgentLink,
64
65
  createAgentLinkConsent: () => createAgentLinkConsent,
65
66
  createAgentLinkHooks: () => createAgentLinkHooks,
66
67
  createAgentLinkWebhookDispatcher: () => createAgentLinkWebhookDispatcher,
67
68
  createAgentLinkWebhookEnvelope: () => createAgentLinkWebhookEnvelope,
68
- createBiomapperLink: () => createBiomapperLink,
69
69
  createBiomapperQueryClient: () => createBiomapperQueryClient,
70
70
  createBiomapperRegistryVerifier: () => createBiomapperRegistryVerifier,
71
71
  createHonoPaymentMiddlewareFromHTTPServer: () => createHonoPaymentMiddlewareFromHTTPServer,
@@ -1654,7 +1654,7 @@ function buildEmbeddedHostedLinkUrl(baseUrl, session) {
1654
1654
  return url.toString();
1655
1655
  }
1656
1656
 
1657
- // src/biomapper-link.ts
1657
+ // src/agentlink.ts
1658
1658
  var import_server = require("@x402/evm/exact/server");
1659
1659
  var import_server2 = require("@x402/core/server");
1660
1660
  var import_http = require("@x402/core/http");
@@ -1708,10 +1708,12 @@ function encodeHex(bytes) {
1708
1708
  return Array.from(bytes, (byte) => byte.toString(16).padStart(2, "0")).join("");
1709
1709
  }
1710
1710
  function constantTimeEqual(left, right) {
1711
- if (left.length !== right.length) return false;
1712
- let mismatch = 0;
1713
- for (let index = 0; index < left.length; index += 1) {
1714
- mismatch |= left.charCodeAt(index) ^ right.charCodeAt(index);
1711
+ const maxLength = Math.max(left.length, right.length);
1712
+ let mismatch = left.length ^ right.length;
1713
+ for (let index = 0; index < maxLength; index += 1) {
1714
+ const leftCode = index < left.length ? left.charCodeAt(index) : 0;
1715
+ const rightCode = index < right.length ? right.charCodeAt(index) : 0;
1716
+ mismatch |= leftCode ^ rightCode;
1715
1717
  }
1716
1718
  return mismatch === 0;
1717
1719
  }
@@ -1769,8 +1771,8 @@ async function dispatchAgentLinkWebhook(event, options) {
1769
1771
  const body = stringifyWebhookEnvelope(envelope);
1770
1772
  const timestamp = Math.floor(Date.now() / 1e3).toString();
1771
1773
  const signature = options.secret ? await createHmacSignature(options.secret, timestamp, body) : void 0;
1774
+ const includeLegacySecretHeader = options.includeLegacySecretHeader ?? false;
1772
1775
  for (const url of urls) {
1773
- const includeLegacySecretHeader = options.includeLegacySecretHeader ?? true;
1774
1776
  const response = await fetchImpl(url, {
1775
1777
  method: "POST",
1776
1778
  headers: {
@@ -1912,14 +1914,14 @@ function createHonoPaymentMiddlewareFromHTTPServer(httpServer, paywallConfig, pa
1912
1914
  return { middleware, initialize };
1913
1915
  }
1914
1916
 
1915
- // src/biomapper-link.ts
1917
+ // src/agentlink.ts
1916
1918
  var NETWORK_TO_CHAIN_ID = {
1917
1919
  base: "eip155:8453",
1918
1920
  "base-sepolia": "eip155:84532"
1919
1921
  };
1920
1922
  var DEFAULT_X402_FACILITATOR_URL = "https://x402.org/facilitator";
1921
1923
  var hasWarnedAboutInMemoryStorageDefault = false;
1922
- function createBiomapperLink(options) {
1924
+ function createAgentLink(options) {
1923
1925
  const chainId = NETWORK_TO_CHAIN_ID[options.network];
1924
1926
  const storage = options.storage ?? resolveDefaultStorage();
1925
1927
  const registry = createBiomapperRegistryVerifier({
@@ -1960,7 +1962,7 @@ function createBiomapperLink(options) {
1960
1962
  let httpServer;
1961
1963
  let middleware = async () => {
1962
1964
  throw new Error(
1963
- "createBiomapperLink was used as middleware without x402 route configuration. Pass `protect` or `routes` to enable the one-call middleware path."
1965
+ "createAgentLink was used as middleware without x402 route configuration. Pass `protect` or `routes` to enable the one-call middleware path."
1964
1966
  );
1965
1967
  };
1966
1968
  let initialize = async () => {
@@ -2013,20 +2015,20 @@ function createBiomapperLink(options) {
2013
2015
  function resolveDefaultStorage() {
2014
2016
  if (process.env.NODE_ENV === "production") {
2015
2017
  throw new Error(
2016
- "createBiomapperLink requires an explicit storage backend in production. Pass persistent/shared storage instead of relying on the in-memory development default."
2018
+ "createAgentLink requires an explicit storage backend in production. Pass persistent/shared storage instead of relying on the in-memory development default."
2017
2019
  );
2018
2020
  }
2019
2021
  if (!hasWarnedAboutInMemoryStorageDefault) {
2020
2022
  hasWarnedAboutInMemoryStorageDefault = true;
2021
2023
  console.warn(
2022
- "[agentlink] createBiomapperLink is using InMemoryAgentLinkStorage because no storage backend was provided. This is only safe for local development and tests."
2024
+ "[agentlink] createAgentLink is using InMemoryAgentLinkStorage because no storage backend was provided. This is only safe for local development and tests."
2023
2025
  );
2024
2026
  }
2025
2027
  return new InMemoryAgentLinkStorage();
2026
2028
  }
2027
2029
  function buildRoutes(options, agentlinkExtensions, defaultNetwork) {
2028
2030
  if (options.routes && options.protect) {
2029
- throw new Error("Pass either `routes` or `protect` to createBiomapperLink, not both.");
2031
+ throw new Error("Pass either `routes` or `protect` to createAgentLink, not both.");
2030
2032
  }
2031
2033
  if (options.routes) {
2032
2034
  return mergeAgentLinkExtensions(options.routes, agentlinkExtensions);
@@ -2273,11 +2275,11 @@ function createNextPaymentHandlerFromHTTPServer(httpServer, paywallConfig, paywa
2273
2275
  buildAgentLinkUsageKey,
2274
2276
  buildEmbeddedHostedLinkUrl,
2275
2277
  buildHostedLinkUrl,
2278
+ createAgentLink,
2276
2279
  createAgentLinkConsent,
2277
2280
  createAgentLinkHooks,
2278
2281
  createAgentLinkWebhookDispatcher,
2279
2282
  createAgentLinkWebhookEnvelope,
2280
- createBiomapperLink,
2281
2283
  createBiomapperQueryClient,
2282
2284
  createBiomapperRegistryVerifier,
2283
2285
  createHonoPaymentMiddlewareFromHTTPServer,