@lucern/sdk 0.3.0-alpha.2 → 0.3.0-alpha.4

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 (168) hide show
  1. package/dist/adminClient.d.ts +2 -0
  2. package/dist/adminClient.js +195 -3
  3. package/dist/adminClient.js.map +1 -1
  4. package/dist/answersClient.d.ts +2 -0
  5. package/dist/answersClient.js +195 -3
  6. package/dist/answersClient.js.map +1 -1
  7. package/dist/audiencesClient.d.ts +2 -0
  8. package/dist/audiencesClient.js +195 -3
  9. package/dist/audiencesClient.js.map +1 -1
  10. package/dist/auditClient.d.ts +2 -0
  11. package/dist/auditClient.js +197 -5
  12. package/dist/auditClient.js.map +1 -1
  13. package/dist/authContext.d.ts +56 -0
  14. package/dist/authContext.js +170 -0
  15. package/dist/authContext.js.map +1 -0
  16. package/dist/authDeviceClient.d.ts +49 -0
  17. package/dist/authDeviceClient.js +108 -0
  18. package/dist/authDeviceClient.js.map +1 -0
  19. package/dist/beliefs/index.d.ts +19 -2
  20. package/dist/beliefs/index.js +2648 -327
  21. package/dist/beliefs/index.js.map +1 -1
  22. package/dist/beliefsClient.d.ts +2 -0
  23. package/dist/beliefsClient.js +199 -7
  24. package/dist/beliefsClient.js.map +1 -1
  25. package/dist/boundaryClientSurface.d.ts +20 -0
  26. package/dist/boundaryClientSurface.js +66 -0
  27. package/dist/boundaryClientSurface.js.map +1 -0
  28. package/dist/{client-B6aWUUwp.d.ts → client-DOLqClbU.d.ts} +548 -9
  29. package/dist/client.d.ts +20 -3
  30. package/dist/client.js +2648 -327
  31. package/dist/client.js.map +1 -1
  32. package/dist/contextClient.d.ts +2 -0
  33. package/dist/contextClient.js +201 -9
  34. package/dist/contextClient.js.map +1 -1
  35. package/dist/contracts/api-enums.contract.d.ts +1 -1
  36. package/dist/contracts/api-enums.contract.js.map +1 -1
  37. package/dist/contracts/index.d.ts +1 -0
  38. package/dist/contracts/index.js +104 -1
  39. package/dist/contracts/index.js.map +1 -1
  40. package/dist/contracts/mcpTools.d.ts +46 -1
  41. package/dist/contracts/mcpTools.js +102 -0
  42. package/dist/contracts/mcpTools.js.map +1 -1
  43. package/dist/contradictions/index.d.ts +19 -2
  44. package/dist/contradictions/index.js +2648 -327
  45. package/dist/contradictions/index.js.map +1 -1
  46. package/dist/coreClient.d.ts +9 -0
  47. package/dist/coreClient.js +195 -3
  48. package/dist/coreClient.js.map +1 -1
  49. package/dist/decisions/index.d.ts +19 -2
  50. package/dist/decisions/index.js +2648 -327
  51. package/dist/decisions/index.js.map +1 -1
  52. package/dist/decisionsClient.d.ts +2 -0
  53. package/dist/decisionsClient.js +198 -6
  54. package/dist/decisionsClient.js.map +1 -1
  55. package/dist/edges/index.d.ts +19 -2
  56. package/dist/edges/index.js +2648 -327
  57. package/dist/edges/index.js.map +1 -1
  58. package/dist/embeddingsClient.d.ts +106 -0
  59. package/dist/embeddingsClient.js +708 -0
  60. package/dist/embeddingsClient.js.map +1 -0
  61. package/dist/eventingClient.d.ts +96 -0
  62. package/dist/eventingClient.js +705 -0
  63. package/dist/eventingClient.js.map +1 -0
  64. package/dist/eventsCore.d.ts +2 -0
  65. package/dist/eventsCore.js +195 -3
  66. package/dist/eventsCore.js.map +1 -1
  67. package/dist/evidence/index.d.ts +19 -2
  68. package/dist/evidence/index.js +2648 -327
  69. package/dist/evidence/index.js.map +1 -1
  70. package/dist/evidenceClient.d.ts +2 -0
  71. package/dist/evidenceClient.js +195 -3
  72. package/dist/evidenceClient.js.map +1 -1
  73. package/dist/gatewayFacades.d.ts +38 -3
  74. package/dist/gatewayFacades.js +371 -12
  75. package/dist/gatewayFacades.js.map +1 -1
  76. package/dist/graphAnalysisClient.d.ts +147 -0
  77. package/dist/graphAnalysisClient.js +756 -0
  78. package/dist/graphAnalysisClient.js.map +1 -0
  79. package/dist/graphClient.d.ts +2 -0
  80. package/dist/graphClient.js +202 -10
  81. package/dist/graphClient.js.map +1 -1
  82. package/dist/graphRecommendationsClient.d.ts +56 -0
  83. package/dist/graphRecommendationsClient.js +646 -0
  84. package/dist/graphRecommendationsClient.js.map +1 -0
  85. package/dist/graphStateClassifierClient.d.ts +73 -0
  86. package/dist/graphStateClassifierClient.js +694 -0
  87. package/dist/graphStateClassifierClient.js.map +1 -0
  88. package/dist/harnessClient.d.ts +2 -0
  89. package/dist/harnessClient.js +197 -5
  90. package/dist/harnessClient.js.map +1 -1
  91. package/dist/identityClient.d.ts +89 -3
  92. package/dist/identityClient.js +363 -4
  93. package/dist/identityClient.js.map +1 -1
  94. package/dist/index.d.ts +23 -4
  95. package/dist/index.js +3098 -353
  96. package/dist/index.js.map +1 -1
  97. package/dist/infisicalRuntime.d.ts +42 -0
  98. package/dist/infisicalRuntime.js +291 -0
  99. package/dist/infisicalRuntime.js.map +1 -0
  100. package/dist/jobsClient.d.ts +98 -0
  101. package/dist/jobsClient.js +704 -0
  102. package/dist/jobsClient.js.map +1 -0
  103. package/dist/learningClient.d.ts +2 -0
  104. package/dist/learningClient.js +197 -5
  105. package/dist/learningClient.js.map +1 -1
  106. package/dist/lenses/index.d.ts +43 -2
  107. package/dist/lenses/index.js +2648 -327
  108. package/dist/lenses/index.js.map +1 -1
  109. package/dist/mcpClient.d.ts +28 -0
  110. package/dist/mcpClient.js +650 -0
  111. package/dist/mcpClient.js.map +1 -0
  112. package/dist/modelRuntimeClient.d.ts +72 -0
  113. package/dist/modelRuntimeClient.js +681 -0
  114. package/dist/modelRuntimeClient.js.map +1 -0
  115. package/dist/nodes/index.d.ts +37 -2
  116. package/dist/nodes/index.js +2648 -327
  117. package/dist/nodes/index.js.map +1 -1
  118. package/dist/ontologies/index.d.ts +19 -2
  119. package/dist/ontologies/index.js +2648 -327
  120. package/dist/ontologies/index.js.map +1 -1
  121. package/dist/ontologyClient.d.ts +2 -0
  122. package/dist/ontologyClient.js +195 -3
  123. package/dist/ontologyClient.js.map +1 -1
  124. package/dist/ontologyLinksClient.d.ts +71 -0
  125. package/dist/ontologyLinksClient.js +675 -0
  126. package/dist/ontologyLinksClient.js.map +1 -0
  127. package/dist/orgGraphSearchClient.d.ts +85 -0
  128. package/dist/orgGraphSearchClient.js +652 -0
  129. package/dist/orgGraphSearchClient.js.map +1 -0
  130. package/dist/packRuntime.d.ts +1 -2
  131. package/dist/packsClient.d.ts +2 -0
  132. package/dist/packsClient.js +195 -3
  133. package/dist/packsClient.js.map +1 -1
  134. package/dist/policyClient.d.ts +2 -0
  135. package/dist/policyClient.js +195 -3
  136. package/dist/policyClient.js.map +1 -1
  137. package/dist/questions/index.d.ts +19 -2
  138. package/dist/questions/index.js +2648 -327
  139. package/dist/questions/index.js.map +1 -1
  140. package/dist/reportsClient.d.ts +2 -0
  141. package/dist/reportsClient.js +197 -5
  142. package/dist/reportsClient.js.map +1 -1
  143. package/dist/schemaClient.d.ts +2 -0
  144. package/dist/schemaClient.js +195 -3
  145. package/dist/schemaClient.js.map +1 -1
  146. package/dist/sdkSurface.d.ts +2 -0
  147. package/dist/sourcesClient.d.ts +2 -0
  148. package/dist/sourcesClient.js +195 -3
  149. package/dist/sourcesClient.js.map +1 -1
  150. package/dist/telemetryClient.d.ts +94 -0
  151. package/dist/telemetryClient.js +719 -0
  152. package/dist/telemetryClient.js.map +1 -0
  153. package/dist/toolRegistryClient.d.ts +107 -0
  154. package/dist/toolRegistryClient.js +733 -0
  155. package/dist/toolRegistryClient.js.map +1 -0
  156. package/dist/topics/index.d.ts +19 -2
  157. package/dist/topics/index.js +2648 -327
  158. package/dist/topics/index.js.map +1 -1
  159. package/dist/topicsClient.d.ts +2 -0
  160. package/dist/topicsClient.js +200 -8
  161. package/dist/topicsClient.js.map +1 -1
  162. package/dist/workflowClient.d.ts +43 -7
  163. package/dist/workflowClient.js +200 -8
  164. package/dist/workflowClient.js.map +1 -1
  165. package/dist/worktrees/index.d.ts +43 -2
  166. package/dist/worktrees/index.js +2648 -327
  167. package/dist/worktrees/index.js.map +1 -1
  168. package/package.json +3 -3
@@ -1 +1 @@
1
- {"version":3,"s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,GAAU,WAAA,CAAY,KAAA,CAAM,OAAO,CAAA;AACzC,EAAA,IAAI,CAAC,OAAA,EAAS;AACZ,IAAA,OAAO,KAAA;AAAA,EACT;AACA,EAAA,OAAO,EAAE,GAAG,KAAA,EAAO,OAAA,EAAQ;AAC7B;AAwBO,SAAS,gBAAA,CACd,OACA,SAAA,EAC0B;AAC1B,EAAA,MAAM,MAAA,GAAS;AAAA,IACb,KAAA;AAAA,IACA,OAAO,KAAA,CAAM;AAAA,GACf;AAEA,EAAe;AACb,IAAC,MAAA,CAAmC,SAAS,CAAA,GAAI,KAAA;AAAA,EACnD;AAEA,EAAA,OAAO,MAAA;AACT;AAKO,SAAS,cAAA,CACd,UACA,MAAA,EAC2B;AAC3B,EAAA,OAAO;AAAA,IACL,GAAG,QAAA;AAAA,IACH,IAAA,EAAM,MAAA,CAAO,QAAA,CAAS,IAAI;AAAA,GAC5B;AACF;;;ACxJO,SAAS,iBAAA,CAAkB,MAAA,GAA4B,EAAC,EAAG;AAChE,EAAA,MAAM,OAAA,GAAU,2BAA2B,MAAM,CAAA;AAEjD,EAAA,OAAO;AAAA;AAAA;AAAA;AAAA,IAIL,MAAM,UAAA,CACJ,KAAA,GAO2B,EAAC,EAC5B;AACA,MAAA,OAAO,QAAQ,OAAA,CAAiB;AAAA,QAC9B,MAAM,CAAA,6BAAA,EAAgC,aAAA;AAAA,UACpC,oBAAoB,KAAK;AAAA,SAC1B,CAAA;AAAA,OACF,CAAA,CAAE,IAAA;AAAA,QAAK,CAAC,QAAA,KACP,cAAA;AAAA,UAAe,QAAA;AAAA,UAAU,CAAC,IAAA,KACxB,gBAAA,CAAiB,KAAA,CAAM,OAAA,CAAQ,IAAI,CAAA,GAAI,IAAA,GAAO,EAAC,EAAG,QAAQ;AAAA;AAC5D,OACF;AAAA,IACF;AAAA,GACF;AACF","file":"auditClient.js","sourcesContent":["import type { JsonObject, JsonValue } from \"./types\";\n\n/** Tenant and workspace identifiers used to scope gateway requests. */\nexport type GatewayScope = {\n tenantId?: string;\n workspaceId?: string;\n};\n\n/** Successful response envelope from the platform gateway with correlation metadata. */\nexport type PlatformGatewaySuccess<T> = {\n success: true;\n data: T;\n correlationId: string;\n policyTraceId: string | null;\n idempotentReplay: boolean;\n};\n\n/** Failed response envelope with structured error codes and optional invariant references. */\nexport type PlatformGatewayFailure = {\n success: false;\n /**\n * Error string is the canonical envelope field.\n * Object form is legacy-only compatibility for older gateway responses.\n */\n error:\n | string\n | {\n code: string;\n message: string;\n details?: JsonValue;\n };\n code?: string;\n invariant?: string | null;\n suggestion?: string | null;\n details?: JsonValue;\n legacyError?: {\n code: string;\n message: string;\n details?: JsonValue;\n };\n correlationId: string;\n policyTraceId: string | null;\n};\n\n/** Discriminated union of success and failure gateway responses. */\nexport type PlatformGatewayEnvelope<T> =\n | PlatformGatewaySuccess<T>\n | PlatformGatewayFailure;\n\n/**\n * Structured error thrown when a platform API request fails.\n *\n * Includes HTTP status, machine-readable error code, optional invariant\n * reference, and actionable suggestions for common failure modes.\n */\nexport class LucernApiError extends Error {\n public readonly code: string;\n public readonly status: number;\n public readonly invariant?: string | null;\n public readonly suggestion?: string | null;\n public readonly details?: JsonValue;\n public readonly requestId?: string;\n public readonly correlationId?: string;\n public readonly policyTraceId?: string | null;\n\n constructor(args: {\n code: string;\n message: string;\n status: number;\n invariant?: string | null;\n suggestion?: string | null;\n details?: JsonValue;\n requestId?: string;\n correlationId?: string;\n policyTraceId?: string | null;\n }) {\n super(args.message);\n this.name = \"LucernApiError\";\n this.code = args.code;\n this.status = args.status;\n this.invariant = args.invariant;\n this.suggestion = args.suggestion;\n this.details = args.details;\n this.requestId = args.requestId;\n this.correlationId = args.correlationId;\n this.policyTraceId = args.policyTraceId;\n }\n}\n\n/** Supported HTTP methods for gateway requests. */\nexport type GatewayHttpMethod = \"GET\" | \"POST\" | \"PUT\" | \"PATCH\" | \"DELETE\";\n\ntype FetchLike = (\n input: RequestInfo | URL,\n init?: RequestInit\n) => Promise<Response>;\n\n/** Context passed to the `onRequest` hook before each gateway request attempt. */\nexport type GatewayRequestHookContext = {\n requestId: string;\n attempt: number;\n maxRetries: number;\n method: GatewayHttpMethod;\n path: string;\n url: string;\n headers: Headers;\n body?: string;\n timeoutMs: number;\n};\n\n/** Context passed to the `onResponse` hook after each gateway request attempt (including retries and failures). */\nexport type GatewayResponseHookContext = GatewayRequestHookContext & {\n durationMs: number;\n status?: number;\n response?: Response;\n error?: unknown;\n correlationId?: string;\n policyTraceId?: string | null;\n idempotentReplay?: boolean;\n retryAfterMs?: number | null;\n willRetry: boolean;\n};\n\n/**\n * Low-level transport configuration for the platform gateway client.\n *\n * Most developers should use {@link createLucernClient} instead, which wraps\n * this config with higher-level conveniences like `apiKey` and `environment`.\n */\nexport type GatewayClientConfig = {\n baseUrl?: string;\n fetchImpl?: FetchLike;\n getAuthHeaders?:\n | (() => Promise<Record<string, string>>)\n | (() => Record<string, string>);\n /** Max retries for transient errors (5xx, network). Defaults to 2. */\n maxRetries?: number;\n /** Request timeout in ms. Defaults to 15000. */\n timeoutMs?: number;\n /** Optional timeout overrides by HTTP method. */\n timeoutMsByMethod?: Partial<Record<GatewayHttpMethod, number>>;\n /** Optional request ID factory used for correlation headers. */\n requestIdFactory?: () => string;\n /** Invoked before each request attempt, including retries. */\n onRequest?:\n | ((context: GatewayRequestHookContext) => void)\n | ((context: GatewayRequestHookContext) => Promise<void>);\n /** Invoked after each request attempt, including retries and failures. */\n onResponse?:\n | ((context: GatewayResponseHookContext) => void)\n | ((context: GatewayResponseHookContext) => Promise<void>);\n};\n\n/**\n * Serialize a gateway query object into a URL query string.\n */\nexport function toQueryString(\n scope: GatewayScope & Record<string, string | number | boolean | undefined>\n): string {\n const params = new URLSearchParams();\n if (scope.tenantId) {\n params.set(\"tenantId\", scope.tenantId);\n }\n if (scope.workspaceId) {\n params.set(\"workspaceId\", scope.workspaceId);\n }\n for (const [key, value] of Object.entries(scope)) {\n if (key === \"tenantId\" || key === \"workspaceId\") {\n continue;\n }\n if (value === undefined) {\n continue;\n }\n params.set(key, String(value));\n }\n const serialized = params.toString();\n return serialized.length > 0 ? `?${serialized}` : \"\";\n}\n\nfunction fillRandomBytes(length: number): Uint8Array {\n const bytes = new Uint8Array(length);\n if (typeof globalThis.crypto?.getRandomValues === \"function\") {\n globalThis.crypto.getRandomValues(bytes);\n return bytes;\n }\n\n for (let index = 0; index < length; index += 1) {\n bytes[index] = Math.floor(Math.random() * 256);\n }\n return bytes;\n}\n\nfunction generatePortableRequestId(): string {\n if (typeof globalThis.crypto?.randomUUID === \"function\") {\n return globalThis.crypto.randomUUID();\n }\n\n const bytes = fillRandomBytes(16);\n bytes[6] = (bytes[6] & 0x0f) | 0x40;\n bytes[8] = (bytes[8] & 0x3f) | 0x80;\n const hex = Array.from(bytes, (value) => value.toString(16).padStart(2, \"0\"));\n return `${hex.slice(0, 4).join(\"\")}-${hex.slice(4, 6).join(\"\")}-${hex.slice(\n 6,\n 8\n ).join(\"\")}-${hex.slice(8, 10).join(\"\")}-${hex.slice(10).join(\"\")}`;\n}\n\n/**\n * Generate a random idempotency key for retry-safe writes.\n */\nexport function randomIdempotencyKey(): string {\n return generatePortableRequestId();\n}\n\nfunction isRetryableStatus(status: number): boolean {\n return status >= 500 || status === 408 || status === 429;\n}\n\nfunction fallbackErrorCode(status: number): string {\n if (status === 401) {\n return \"AUTHENTICATION_REQUIRED\";\n }\n if (status === 403) {\n return \"FORBIDDEN\";\n }\n if (status === 404) {\n return \"NOT_FOUND\";\n }\n if (status === 408) {\n return \"UPSTREAM_ERROR\";\n }\n if (status === 409) {\n return \"CONFLICT\";\n }\n if (status === 429) {\n return \"RATE_LIMIT_EXCEEDED\";\n }\n if (status >= 500) {\n return \"UPSTREAM_ERROR\";\n }\n return \"INTERNAL_ERROR\";\n}\n\nfunction delay(ms: number): Promise<void> {\n return new Promise((resolve) => setTimeout(resolve, ms));\n}\n\nfunction parseRetryAfterMs(value: string | null): number | null {\n if (!value) {\n return null;\n }\n const trimmed = value.trim();\n if (!trimmed) {\n return null;\n }\n const numeric = Number(trimmed);\n if (Number.isFinite(numeric)) {\n return Math.max(0, Math.round(numeric * 1000));\n }\n const parsedDate = Date.parse(trimmed);\n if (Number.isFinite(parsedDate)) {\n return Math.max(0, parsedDate - Date.now());\n }\n return null;\n}\n\nfunction computeRetryDelayMs(args: {\n attempt: number;\n status?: number;\n retryAfterMs?: number | null;\n}): number {\n const baseDelay =\n args.status === 429\n ? Math.max(\n args.retryAfterMs ?? 0,\n Math.min(1000 * 2 ** args.attempt, 10_000)\n )\n : Math.min(1000 * 2 ** args.attempt, 4000);\n\n if (args.status !== 429) {\n return baseDelay;\n }\n\n const jitterWindow = Math.max(250, Math.round(baseDelay * 0.25));\n return baseDelay + Math.round(Math.random() * jitterWindow);\n}\n\nfunction timeoutError(timeoutMs: number): Error {\n const error = new Error(`Request timed out after ${timeoutMs}ms`);\n error.name = \"AbortError\";\n return error;\n}\n\nfunction readPolicySummaryFromDetails(details?: JsonValue): string | null {\n if (!details || typeof details !== \"object\" || Array.isArray(details)) {\n return null;\n }\n\n const directSummary = (details as { summary?: JsonValue }).summary;\n if (typeof directSummary === \"string\" && directSummary.trim().length > 0) {\n return directSummary.trim();\n }\n\n const policy = (details as { policy?: JsonValue }).policy;\n if (!policy || typeof policy !== \"object\" || Array.isArray(policy)) {\n return null;\n }\n\n const explanation = (policy as { explanation?: JsonValue }).explanation;\n if (!explanation || typeof explanation !== \"object\" || Array.isArray(explanation)) {\n return null;\n }\n\n const nestedSummary = (explanation as { summary?: JsonValue }).summary;\n if (typeof nestedSummary === \"string\" && nestedSummary.trim().length > 0) {\n return nestedSummary.trim();\n }\n\n return null;\n}\n\n/**\n * Create the transport client used by all SDK modules.\n */\nexport function createGatewayRequestClient(config: GatewayClientConfig = {}) {\n const fetchImpl = config.fetchImpl ?? fetch;\n const baseUrl = config.baseUrl?.replace(/\\/+$/, \"\") ?? \"\";\n const maxRetries = config.maxRetries ?? 2;\n const requestIdFactory = config.requestIdFactory ?? (() => generatePortableRequestId());\n\n async function resolveAuthHeaders(): Promise<Record<string, string>> {\n if (!config.getAuthHeaders) {\n return {};\n }\n return await config.getAuthHeaders();\n }\n\n async function fetchWithTimeout(\n url: string,\n init: RequestInit,\n timeoutMs: number\n ): Promise<Response> {\n const controller = new AbortController();\n const timer = setTimeout(() => controller.abort(), timeoutMs);\n try {\n return await fetchImpl(url, { ...init, signal: controller.signal });\n } catch (error) {\n if (controller.signal.aborted) {\n throw timeoutError(timeoutMs);\n }\n throw error;\n } finally {\n clearTimeout(timer);\n }\n }\n\n async function parsePayload<T>(\n response: Response\n ): Promise<PlatformGatewayEnvelope<T> | null> {\n const text = await response.text();\n if (!text) {\n return null;\n }\n try {\n return JSON.parse(text) as PlatformGatewayEnvelope<T>;\n } catch {\n return null;\n }\n }\n\n function resolveTimeoutMs(\n method: GatewayHttpMethod,\n requestTimeoutMs?: number\n ): number {\n if (typeof requestTimeoutMs === \"number\") {\n return requestTimeoutMs;\n }\n const methodTimeoutMs = config.timeoutMsByMethod?.[method];\n if (typeof methodTimeoutMs === \"number\") {\n return methodTimeoutMs;\n }\n return config.timeoutMs ?? 15_000;\n }\n\n function buildApiError(args: {\n requestId: string;\n response: Response;\n failure?: PlatformGatewayFailure | null;\n }): LucernApiError {\n const failure = args.failure;\n const legacyError =\n failure && typeof failure.error === \"object\" && failure.error !== null\n ? failure.error\n : failure?.legacyError;\n const correlationId =\n failure?.correlationId ??\n args.response.headers.get(\"x-lucern-correlation-id\")?.trim() ??\n args.requestId;\n const policyTraceId =\n failure?.policyTraceId ??\n args.response.headers.get(\"x-lucern-policy-trace-id\")?.trim() ??\n null;\n const details = failure?.details ?? legacyError?.details;\n const policySummary = readPolicySummaryFromDetails(details);\n\n return new LucernApiError({\n code: failure?.code ?? legacyError?.code ?? fallbackErrorCode(args.response.status),\n message:\n policySummary ??\n (typeof failure?.error === \"string\"\n ? failure.error\n : legacyError?.message ??\n (args.response.ok\n ? \"Platform API returned an invalid success payload.\"\n : \"Platform API request failed.\")),\n status: args.response.status,\n invariant: failure?.invariant,\n suggestion: failure?.suggestion,\n details,\n requestId: args.requestId,\n correlationId,\n policyTraceId,\n });\n }\n\n async function request<T>(args: {\n path: string;\n method?: GatewayHttpMethod;\n body?: JsonObject;\n idempotencyKey?: string;\n requestId?: string;\n timeoutMs?: number;\n }): Promise<PlatformGatewaySuccess<T>> {\n const authHeaders = await resolveAuthHeaders();\n const method = args.method ?? \"GET\";\n const timeoutMs = resolveTimeoutMs(method, args.timeoutMs);\n const headers = new Headers({\n \"content-type\": \"application/json\",\n ...authHeaders,\n });\n if (args.idempotencyKey) {\n headers.set(\"idempotency-key\", args.idempotencyKey);\n }\n const requestId =\n headers.get(\"x-correlation-id\")?.trim() ||\n headers.get(\"x-request-id\")?.trim() ||\n args.requestId ||\n requestIdFactory();\n if (!headers.has(\"x-correlation-id\") && !headers.has(\"x-request-id\")) {\n headers.set(\"x-correlation-id\", requestId);\n }\n\n const url = `${baseUrl}${args.path}`;\n const serializedBody = args.body ? JSON.stringify(args.body) : undefined;\n const init: RequestInit = {\n method,\n headers,\n body: serializedBody,\n };\n\n let lastError: unknown;\n\n for (let attempt = 0; attempt <= maxRetries; attempt++) {\n const hookRequestContext: GatewayRequestHookContext = {\n requestId,\n attempt,\n maxRetries,\n method,\n path: args.path,\n url,\n headers: new Headers(headers),\n body: serializedBody,\n timeoutMs,\n };\n await config.onRequest?.(hookRequestContext);\n const startedAt = Date.now();\n try {\n const response = await fetchWithTimeout(url, init, timeoutMs);\n const responseClone = response.clone();\n const payload = await parsePayload<T>(response);\n const retryAfterMs = parseRetryAfterMs(\n response.headers.get(\"Retry-After\")\n );\n\n if (!response.ok || !payload?.success) {\n const failure =\n payload && !payload.success ? (payload as PlatformGatewayFailure) : null;\n const apiError = buildApiError({\n requestId,\n response,\n failure,\n });\n const willRetry = attempt < maxRetries && isRetryableStatus(response.status);\n\n await config.onResponse?.({\n ...hookRequestContext,\n durationMs: Date.now() - startedAt,\n status: response.status,\n response: responseClone,\n error: apiError,\n correlationId: apiError.correlationId ?? requestId,\n policyTraceId: apiError.policyTraceId ?? null,\n retryAfterMs,\n willRetry,\n });\n\n if (willRetry) {\n lastError = apiError;\n await delay(\n computeRetryDelayMs({\n attempt,\n status: response.status,\n retryAfterMs,\n })\n );\n continue;\n }\n\n throw apiError;\n }\n\n const successPayload = payload as PlatformGatewaySuccess<T>;\n await config.onResponse?.({\n ...hookRequestContext,\n durationMs: Date.now() - startedAt,\n status: response.status,\n response: responseClone,\n correlationId:\n successPayload.correlationId ??\n response.headers.get(\"x-lucern-correlation-id\")?.trim() ??\n requestId,\n policyTraceId:\n successPayload.policyTraceId ??\n response.headers.get(\"x-lucern-policy-trace-id\")?.trim() ??\n null,\n idempotentReplay: successPayload.idempotentReplay,\n retryAfterMs,\n willRetry: false,\n });\n\n return successPayload;\n } catch (fetchError) {\n if (fetchError instanceof LucernApiError) {\n throw fetchError;\n }\n const willRetry = attempt < maxRetries;\n await config.onResponse?.({\n ...hookRequestContext,\n durationMs: Date.now() - startedAt,\n error: fetchError,\n correlationId: requestId,\n policyTraceId: null,\n willRetry,\n });\n lastError = fetchError;\n if (willRetry) {\n await delay(computeRetryDelayMs({ attempt }));\n }\n }\n }\n\n throw lastError instanceof Error\n ? lastError\n : new Error(\"Platform API request failed after retries.\");\n }\n\n return {\n request,\n };\n}\n","import type { PlatformGatewaySuccess } from \"./coreClient\";\nimport type { JsonObject, ListResult } from \"./types\";\n\ntype TopicScopedValue = {\n topicId?: string;\n};\n\ntype TextScopedValue = {\n text?: string;\n canonicalText?: string;\n};\n\ntype AnyRecord = Record<string, unknown>;\n\nfunction asRecord(value: unknown): AnyRecord {\n return value && typeof value === \"object\" ? (value as AnyRecord) : {};\n}\n\nfunction cleanString(value: unknown): string | undefined {\n return typeof value === \"string\" && value.trim().length > 0\n ? value.trim()\n : undefined;\n}\n\nfunction normalizeVerificationStatus(value: unknown): string | undefined {\n const status = cleanString(value);\n if (!status) {\n return undefined;\n }\n if (status === \"verified\") {\n return \"human_verified\";\n }\n if (status === \"rejected\") {\n return \"contradicted\";\n }\n return status;\n}\n\nfunction cloneWith<T extends AnyRecord>(value: T, patch: AnyRecord): T {\n return { ...value, ...patch } as T;\n}\n\n/**\n * Resolve the canonical topic identifier.\n */\nexport function resolveTopicId(value: TopicScopedValue): string | undefined {\n return cleanString(value.topicId);\n}\n\n/**\n * Resolve the canonical text field from text-first or legacy canonicalText-first inputs.\n */\nexport function resolveText(value: TextScopedValue): string | undefined {\n return cleanString(value.text) ?? cleanString(value.canonicalText);\n}\n\n/**\n * Attach the topicId to a record.\n */\nexport function withTopicAlias<T extends AnyRecord>(value: T): T {\n const topicId = cleanString(value.topicId) ?? undefined;\n if (!topicId) {\n return value;\n }\n return cloneWith(value, { topicId });\n}\n\n/**\n * Attach the text/canonicalText alias pair to a record.\n */\nexport function withTextAlias<T extends AnyRecord>(value: T): T {\n const text =\n cleanString(value.text) ?? cleanString(value.canonicalText) ?? undefined;\n if (!text) {\n return value;\n }\n return cloneWith(value, { text, canonicalText: text });\n}\n\n/**\n * Attach topic and text aliases to SDK node-like records.\n */\nexport function withSdkAliases<T extends AnyRecord>(value: T): T {\n return withTopicAlias(withTextAlias(value));\n}\n\n/**\n * Normalize a belief/question/evidence write payload to the canonical gateway shape.\n */\nexport function normalizeNodeWriteInput<T extends JsonObject>(value: T): T {\n const topicId = resolveTopicId(value);\n const text = resolveText(value);\n const verificationStatus = normalizeVerificationStatus(value.verificationStatus);\n const next = { ...value } as JsonObject;\n\n if (topicId) {\n next.topicId = topicId;\n }\n if (text) {\n next.text = text;\n next.canonicalText = text;\n }\n if (verificationStatus) {\n next.verificationStatus = verificationStatus;\n }\n\n return next as T;\n}\n\nexport function normalizeNodeVerificationStatus(value: unknown) {\n return normalizeVerificationStatus(value);\n}\n\n/**\n * Build a topic-aware query object.\n */\nexport function normalizeTopicQuery<T extends JsonObject>(value: T): T {\n const topicId = cleanString(value.topicId);\n if (!topicId) {\n return value;\n }\n return { ...value, topicId } as T;\n}\n\n/**\n * Extract list items from array or list-envelope payloads.\n */\nexport function asListItems<T>(data: unknown, legacyKey?: string): T[] {\n if (Array.isArray(data)) {\n return data as T[];\n }\n\n const record = asRecord(data);\n if (Array.isArray(record.items)) {\n return record.items as T[];\n }\n if (legacyKey && Array.isArray(record[legacyKey])) {\n return record[legacyKey] as T[];\n }\n\n return [];\n}\n\n/**\n * Standardize list data to { items, total } while retaining an optional legacy array key.\n */\nexport function createListResult<T, LegacyKey extends string>(\n items: T[],\n legacyKey?: LegacyKey\n): ListResult<T, LegacyKey> {\n const result = {\n items,\n total: items.length,\n } as ListResult<T, LegacyKey>;\n\n if (legacyKey) {\n (result as Record<string, unknown>)[legacyKey] = items;\n }\n\n return result;\n}\n\n/**\n * Map a gateway success envelope's data while preserving the transport metadata.\n */\nexport function mapGatewayData<T, U>(\n response: PlatformGatewaySuccess<T>,\n mapper: (data: T) => U\n): PlatformGatewaySuccess<U> {\n return {\n ...response,\n data: mapper(response.data),\n };\n}\n\n/**\n * Apply SDK aliases across all items in a list-like payload.\n */\nexport function mapAliasedList<\n TItem extends AnyRecord,\n LegacyKey extends string,\n>(\n data: unknown,\n legacyKey?: LegacyKey\n): ListResult<TItem, LegacyKey> {\n const items = asListItems<TItem>(data, legacyKey).map((item) =>\n withSdkAliases(item)\n );\n return createListResult(items, legacyKey);\n}\n","import {\n createGatewayRequestClient,\n type GatewayClientConfig,\n type GatewayScope,\n LucernApiError,\n toQueryString,\n} from \"./coreClient\";\nimport { createListResult, mapGatewayData, normalizeTopicQuery } from \"./sdkSurface\";\nimport type { TopicIdentifierInput } from \"./types\";\n\nexport { LucernApiError };\nexport type { GatewayScope, PlatformGatewaySuccess } from \"./coreClient\";\n\n/** Configuration for the audit client. */\nexport type AuditClientConfig = GatewayClientConfig;\n\n/**\n * Create the audit client for transport-level audit event reads.\n * @param config - Gateway transport configuration.\n * @returns An object with methods to list audit events.\n */\nexport function createAuditClient(config: AuditClientConfig = {}) {\n const gateway = createGatewayRequestClient(config);\n\n return {\n /**\n * List audit events for the current scope.\n */\n async listEvents(\n query: GatewayScope & {\n action?: string;\n decision?: string;\n traceId?: string;\n principalId?: string;\n topicId?: string;\n limit?: number;\n } & TopicIdentifierInput = {}\n ) {\n return gateway.request<unknown>({\n path: `/api/platform/v1/audit/events${toQueryString(\n normalizeTopicQuery(query)\n )}`,\n }).then((response) =>\n mapGatewayData(response, (data) =>\n createListResult(Array.isArray(data) ? data : [], \"events\")\n )\n );\n },\n };\n}\n"]}
1
+ {"version":3,"sources":["../src/authContext.ts","../src/coreClient.ts","../src/sdkSurface.ts","../src/auditClient.ts"],"names":["cleanString"],"mappings":";AA2DO,IAAM,yBAAA,GAAN,cAAwC,KAAA,CAAM;AAAA,EAC1C,MAAA;AAAA,EAET,WAAA,CAAY,QAAoC,OAAA,EAAiB;AAC/D,IAAA,KAAA,CAAM,OAAO,CAAA;AACb,IAAA,IAAA,CAAK,IAAA,GAAO,2BAAA;AACZ,IAAA,IAAA,CAAK,MAAA,GAAS,MAAA;AAAA,EAChB;AACF,CAAA;AAEA,SAAS,YAAY,KAAA,EAA+C;AAClE,EAAA,MAAM,UAAA,GAAa,OAAO,IAAA,EAAK;AAC/B,EAAA,OAAO,aAAa,UAAA,GAAa,MAAA;AACnC;AAEA,SAAS,gBAAgB,MAAA,EAAiD;AACxE,EAAA,IAAI,CAAC,MAAA,EAAQ;AACX,IAAA,OAAO,EAAC;AAAA,EACV;AACA,EAAA,OAAO,OACJ,GAAA,CAAI,CAAC,UAAU,KAAA,CAAM,IAAA,EAAM,CAAA,CAC3B,MAAA;AAAA,IACC,CAAC,KAAA,EAAO,KAAA,EAAO,IAAA,KACb,KAAA,CAAM,SAAS,CAAA,IAAK,IAAA,CAAK,OAAA,CAAQ,KAAK,CAAA,KAAM;AAAA,GAChD;AACJ;AAEA,SAAS,aAAA,CACP,KAAA,EACA,MAAA,EACA,KAAA,EACQ;AACR,EAAA,MAAM,UAAA,GAAa,YAAY,KAAK,CA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A,OAAO,MAAA;AACT;AAKO,SAAS,cAAA,CACd,UACA,MAAA,EAC2B;AAC3B,EAAA,OAAO;AAAA,IACL,GAAG,QAAA;AAAA,IACH,IAAA,EAAM,MAAA,CAAO,QAAA,CAAS,IAAI;AAAA,GAC5B;AACF;;;ACxJO,SAAS,iBAAA,CAAkB,MAAA,GAA4B,EAAC,EAAG;AAChE,EAAA,MAAM,OAAA,GAAU,2BAA2B,MAAM,CAAA;AAEjD,EAAA,OAAO;AAAA;AAAA;AAAA;AAAA,IAIL,MAAM,UAAA,CACJ,KAAA,GAO2B,EAAC,EAC5B;AACA,MAAA,OAAO,QAAQ,OAAA,CAAiB;AAAA,QAC9B,MAAM,CAAA,6BAAA,EAAgC,aAAA;AAAA,UACpC,oBAAoB,KAAK;AAAA,SAC1B,CAAA;AAAA,OACF,CAAA,CAAE,IAAA;AAAA,QAAK,CAAC,QAAA,KACP,cAAA;AAAA,UAAe,QAAA;AAAA,UAAU,CAAC,IAAA,KACxB,gBAAA,CAAiB,KAAA,CAAM,OAAA,CAAQ,IAAI,CAAA,GAAI,IAAA,GAAO,EAAC,EAAG,QAAQ;AAAA;AAC5D,OACF;AAAA,IACF;AAAA,GACF;AACF","file":"auditClient.js","sourcesContent":["import type {\n SessionAuthMode,\n SessionDelegationHop,\n SessionPrincipalType,\n} from \"./contracts/auth-session.contract\";\nimport type { JsonObject } from \"./types\";\n\nexport type LucernSdkAuthFailureReason =\n | \"principal_missing\"\n | \"tenant_missing\"\n | \"membership_missing\"\n | \"workspace_missing\"\n | \"policy_denied\";\n\nexport type PermitReadyAuthContext = {\n subject: string;\n tenant: string;\n workspace: string;\n resource?: string;\n action?: string;\n relation?: string;\n context?: JsonObject;\n};\n\nexport type LucernSdkAuthPolicyDecision = \"allow\" | \"deny\" | \"unknown\";\n\nexport type LucernSdkAuthContextInput = {\n clerkId?: string;\n principalId?: string;\n tenantId?: string;\n workspaceId?: string;\n principalType?: SessionPrincipalType;\n authMode?: SessionAuthMode;\n roles?: readonly string[];\n scopes?: readonly string[];\n delegationChain?: readonly SessionDelegationHop[];\n policyTraceId?: string;\n correlationId?: string;\n membershipId?: string;\n policyDecision?: LucernSdkAuthPolicyDecision;\n permit?: Partial<PermitReadyAuthContext>;\n};\n\nexport type CanonicalLucernSdkAuthContext = {\n clerkId?: string;\n principalId: string;\n tenantId: string;\n workspaceId: string;\n principalType: SessionPrincipalType;\n authMode: SessionAuthMode;\n roles: string[];\n scopes: string[];\n delegationChain: SessionDelegationHop[];\n policyTraceId?: string;\n correlationId?: string;\n membershipId?: string;\n permit: PermitReadyAuthContext;\n};\n\nexport class LucernSdkAuthContextError extends Error {\n readonly reason: LucernSdkAuthFailureReason;\n\n constructor(reason: LucernSdkAuthFailureReason, message: string) {\n super(message);\n this.name = \"LucernSdkAuthContextError\";\n this.reason = reason;\n }\n}\n\nfunction cleanString(value: string | undefined): string | undefined {\n const normalized = value?.trim();\n return normalized ? normalized : undefined;\n}\n\nfunction cleanStringList(values: readonly string[] | undefined): string[] {\n if (!values) {\n return [];\n }\n return values\n .map((value) => value.trim())\n .filter(\n (value, index, list) =>\n value.length > 0 && list.indexOf(value) === index\n );\n}\n\nfunction requireString(\n value: string | undefined,\n reason: LucernSdkAuthFailureReason,\n label: string\n): string {\n const normalized = cleanString(value);\n if (!normalized) {\n throw new LucernSdkAuthContextError(\n reason,\n `Canonical Lucern SDK auth context is missing ${label}.`\n );\n }\n return normalized;\n}\n\nfunction requirePrincipalType(\n principalType: SessionPrincipalType | undefined\n): SessionPrincipalType {\n if (!principalType) {\n throw new LucernSdkAuthContextError(\n \"principal_missing\",\n \"Canonical Lucern SDK auth context is missing principalType.\"\n );\n }\n return principalType;\n}\n\nfunction requireAuthMode(authMode: SessionAuthMode | undefined): SessionAuthMode {\n if (!authMode) {\n throw new LucernSdkAuthContextError(\n \"principal_missing\",\n \"Canonical Lucern SDK auth context is missing authMode.\"\n );\n }\n return authMode;\n}\n\nfunction ensurePermitMatch(args: {\n field: keyof PermitReadyAuthContext;\n expected: string;\n actual?: string;\n}) {\n const actual = cleanString(args.actual);\n if (actual && actual !== args.expected) {\n throw new LucernSdkAuthContextError(\n \"policy_denied\",\n `Canonical Lucern SDK auth context has conflicting Permit ${args.field}.`\n );\n }\n}\n\nexport function normalizeCanonicalLucernAuthContext(\n input: LucernSdkAuthContextInput | undefined\n): CanonicalLucernSdkAuthContext {\n if (!input) {\n throw new LucernSdkAuthContextError(\n \"principal_missing\",\n \"Canonical Lucern SDK auth context is required.\"\n );\n }\n\n if (input.policyDecision === \"deny\") {\n throw new LucernSdkAuthContextError(\n \"policy_denied\",\n \"Canonical Lucern SDK auth context carries a denied policy decision.\"\n );\n }\n\n const principalId = requireString(\n input.principalId,\n \"principal_missing\",\n \"principalId\"\n );\n const tenantId = requireString(input.tenantId, \"tenant_missing\", \"tenantId\");\n const workspaceId = requireString(\n input.workspaceId,\n \"workspace_missing\",\n \"workspaceId\"\n );\n const roles = cleanStringList(input.roles);\n const scopes = cleanStringList(input.scopes);\n const principalType = requirePrincipalType(input.principalType);\n const authMode = requireAuthMode(input.authMode);\n const roleBasedInteractiveAuth =\n authMode === \"interactive_user\" && roles.length > 0;\n if (\n roles.length === 0 ||\n (scopes.length === 0 && !roleBasedInteractiveAuth)\n ) {\n throw new LucernSdkAuthContextError(\n \"membership_missing\",\n \"Canonical Lucern SDK auth context requires non-empty roles and scopes.\"\n );\n }\n\n const subject = cleanString(input.permit?.subject) ?? principalId;\n const tenant = cleanString(input.permit?.tenant) ?? tenantId;\n const workspace = cleanString(input.permit?.workspace) ?? workspaceId;\n\n ensurePermitMatch({\n field: \"subject\",\n expected: principalId,\n actual: subject,\n });\n ensurePermitMatch({ field: \"tenant\", expected: tenantId, actual: tenant });\n ensurePermitMatch({\n field: \"workspace\",\n expected: workspaceId,\n actual: workspace,\n });\n\n const context = input.permit?.context\n ? ({ ...input.permit.context } as JsonObject)\n : undefined;\n\n return {\n clerkId: cleanString(input.clerkId),\n principalId,\n tenantId,\n workspaceId,\n principalType,\n authMode,\n roles,\n scopes,\n delegationChain: input.delegationChain ? [...input.delegationChain] : [],\n policyTraceId: cleanString(input.policyTraceId),\n correlationId: cleanString(input.correlationId),\n membershipId: cleanString(input.membershipId),\n permit: {\n subject,\n tenant,\n workspace,\n resource: cleanString(input.permit?.resource),\n action: cleanString(input.permit?.action),\n relation: cleanString(input.permit?.relation),\n context,\n },\n };\n}\n\nexport function createCanonicalAuthHeaders(\n authContext: CanonicalLucernSdkAuthContext\n): Record<string, string> {\n const headers: Record<string, string> = {\n \"x-lucern-principal-id\": authContext.principalId,\n \"x-lucern-principal-type\": authContext.principalType,\n \"x-lucern-tenant\": authContext.tenantId,\n \"x-lucern-tenant-id\": authContext.tenantId,\n \"x-lucern-workspace\": authContext.workspaceId,\n \"x-lucern-workspace-id\": authContext.workspaceId,\n \"x-lucern-auth-mode\": authContext.authMode,\n \"x-lucern-roles\": authContext.roles.join(\",\"),\n \"x-lucern-scopes\": authContext.scopes.join(\",\"),\n \"x-lucern-permit-context\": JSON.stringify(authContext.permit),\n };\n\n if (authContext.clerkId) {\n headers[\"x-lucern-clerk-id\"] = authContext.clerkId;\n headers[\"x-lucern-user-id\"] = authContext.clerkId;\n }\n if (authContext.delegationChain.length > 0) {\n headers[\"x-lucern-delegation-chain\"] = JSON.stringify(\n authContext.delegationChain\n );\n }\n if (authContext.policyTraceId) {\n headers[\"x-lucern-policy-trace-id\"] = authContext.policyTraceId;\n }\n if (authContext.correlationId) {\n headers[\"x-correlation-id\"] = authContext.correlationId;\n headers[\"x-lucern-correlation-id\"] = authContext.correlationId;\n }\n if (authContext.membershipId) {\n headers[\"x-lucern-membership-id\"] = authContext.membershipId;\n }\n\n return headers;\n}\n","import {\n createCanonicalAuthHeaders,\n LucernSdkAuthContextError,\n normalizeCanonicalLucernAuthContext,\n type LucernSdkAuthContextInput,\n} from \"./authContext\";\nimport type { JsonObject, JsonValue } from \"./types\";\n\n/** Tenant and workspace identifiers used to scope gateway requests. */\nexport type GatewayScope = {\n tenantId?: string;\n workspaceId?: string;\n};\n\n/** Successful response envelope from the platform gateway with correlation metadata. */\nexport type PlatformGatewaySuccess<T> = {\n success: true;\n data: T;\n correlationId: string;\n policyTraceId: string | null;\n idempotentReplay: boolean;\n};\n\n/** Failed response envelope with structured error codes and optional invariant references. */\nexport type PlatformGatewayFailure = {\n success: false;\n /**\n * Error string is the canonical envelope field.\n * Object form is legacy-only compatibility for older gateway responses.\n */\n error:\n | string\n | {\n code: string;\n message: string;\n details?: JsonValue;\n };\n code?: string;\n invariant?: string | null;\n suggestion?: string | null;\n details?: JsonValue;\n legacyError?: {\n code: string;\n message: string;\n details?: JsonValue;\n };\n correlationId: string;\n policyTraceId: string | null;\n};\n\n/** Discriminated union of success and failure gateway responses. */\nexport type PlatformGatewayEnvelope<T> =\n | PlatformGatewaySuccess<T>\n | PlatformGatewayFailure;\n\n/**\n * Structured error thrown when a platform API request fails.\n *\n * Includes HTTP status, machine-readable error code, optional invariant\n * reference, and actionable suggestions for common failure modes.\n */\nexport class LucernApiError extends Error {\n public readonly code: string;\n public readonly status: number;\n public readonly invariant?: string | null;\n public readonly suggestion?: string | null;\n public readonly details?: JsonValue;\n public readonly requestId?: string;\n public readonly correlationId?: string;\n public readonly policyTraceId?: string | null;\n\n constructor(args: {\n code: string;\n message: string;\n status: number;\n invariant?: string | null;\n suggestion?: string | null;\n details?: JsonValue;\n requestId?: string;\n correlationId?: string;\n policyTraceId?: string | null;\n }) {\n super(args.message);\n this.name = \"LucernApiError\";\n this.code = args.code;\n this.status = args.status;\n this.invariant = args.invariant;\n this.suggestion = args.suggestion;\n this.details = args.details;\n this.requestId = args.requestId;\n this.correlationId = args.correlationId;\n this.policyTraceId = args.policyTraceId;\n }\n}\n\n/** Supported HTTP methods for gateway requests. */\nexport type GatewayHttpMethod = \"GET\" | \"POST\" | \"PUT\" | \"PATCH\" | \"DELETE\";\n\ntype FetchLike = (\n input: RequestInfo | URL,\n init?: RequestInit\n) => Promise<Response>;\n\n/** Context passed to the `onRequest` hook before each gateway request attempt. */\nexport type GatewayRequestHookContext = {\n requestId: string;\n attempt: number;\n maxRetries: number;\n method: GatewayHttpMethod;\n path: string;\n url: string;\n headers: Headers;\n body?: string;\n timeoutMs: number;\n};\n\n/** Context passed to the `onResponse` hook after each gateway request attempt (including retries and failures). */\nexport type GatewayResponseHookContext = GatewayRequestHookContext & {\n durationMs: number;\n status?: number;\n response?: Response;\n error?: unknown;\n correlationId?: string;\n policyTraceId?: string | null;\n idempotentReplay?: boolean;\n retryAfterMs?: number | null;\n willRetry: boolean;\n};\n\n/**\n * Low-level transport configuration for the platform gateway client.\n *\n * Most developers should use {@link createLucernClient} instead, which wraps\n * this config with higher-level conveniences like `apiKey` and `environment`.\n */\nexport type GatewayClientConfig = {\n baseUrl?: string;\n fetchImpl?: FetchLike;\n getAuthHeaders?:\n | (() => Promise<Record<string, string>>)\n | (() => Record<string, string>);\n /**\n * Canonical Master Control identity tuple applied to every SDK request.\n * Use this for tenant/workspace-scoped graph and identity operations.\n */\n authContext?:\n | LucernSdkAuthContextInput\n | (() => Promise<LucernSdkAuthContextInput | undefined>)\n | (() => LucernSdkAuthContextInput | undefined);\n /** When true, requests fail before fetch if `authContext` is absent. */\n requireCanonicalAuthContext?: boolean;\n /** Max retries for transient errors (5xx, network). Defaults to 2. */\n maxRetries?: number;\n /** Request timeout in ms. Defaults to 15000. */\n timeoutMs?: number;\n /** Optional timeout overrides by HTTP method. */\n timeoutMsByMethod?: Partial<Record<GatewayHttpMethod, number>>;\n /** Optional request ID factory used for correlation headers. */\n requestIdFactory?: () => string;\n /** Invoked before each request attempt, including retries. */\n onRequest?:\n | ((context: GatewayRequestHookContext) => void)\n | ((context: GatewayRequestHookContext) => Promise<void>);\n /** Invoked after each request attempt, including retries and failures. */\n onResponse?:\n | ((context: GatewayResponseHookContext) => void)\n | ((context: GatewayResponseHookContext) => Promise<void>);\n};\n\n/**\n * Serialize a gateway query object into a URL query string.\n */\nexport function toQueryString(\n scope: GatewayScope & Record<string, string | number | boolean | undefined>\n): string {\n const params = new URLSearchParams();\n if (scope.tenantId) {\n params.set(\"tenantId\", scope.tenantId);\n }\n if (scope.workspaceId) {\n params.set(\"workspaceId\", scope.workspaceId);\n }\n for (const [key, value] of Object.entries(scope)) {\n if (key === \"tenantId\" || key === \"workspaceId\") {\n continue;\n }\n if (value === undefined) {\n continue;\n }\n params.set(key, String(value));\n }\n const serialized = params.toString();\n return serialized.length > 0 ? `?${serialized}` : \"\";\n}\n\nfunction fillRandomBytes(length: number): Uint8Array {\n const bytes = new Uint8Array(length);\n if (typeof globalThis.crypto?.getRandomValues === \"function\") {\n globalThis.crypto.getRandomValues(bytes);\n return bytes;\n }\n\n for (let index = 0; index < length; index += 1) {\n bytes[index] = Math.floor(Math.random() * 256);\n }\n return bytes;\n}\n\nfunction generatePortableRequestId(): string {\n if (typeof globalThis.crypto?.randomUUID === \"function\") {\n return globalThis.crypto.randomUUID();\n }\n\n const bytes = fillRandomBytes(16);\n bytes[6] = (bytes[6] & 0x0f) | 0x40;\n bytes[8] = (bytes[8] & 0x3f) | 0x80;\n const hex = Array.from(bytes, (value) => value.toString(16).padStart(2, \"0\"));\n return `${hex.slice(0, 4).join(\"\")}-${hex.slice(4, 6).join(\"\")}-${hex.slice(\n 6,\n 8\n ).join(\"\")}-${hex.slice(8, 10).join(\"\")}-${hex.slice(10).join(\"\")}`;\n}\n\n/**\n * Generate a random idempotency key for retry-safe writes.\n */\nexport function randomIdempotencyKey(): string {\n return generatePortableRequestId();\n}\n\nfunction isRetryableStatus(status: number): boolean {\n return status >= 500 || status === 408 || status === 429;\n}\n\nfunction fallbackErrorCode(status: number): string {\n if (status === 401) {\n return \"AUTHENTICATION_REQUIRED\";\n }\n if (status === 403) {\n return \"FORBIDDEN\";\n }\n if (status === 404) {\n return \"NOT_FOUND\";\n }\n if (status === 408) {\n return \"UPSTREAM_ERROR\";\n }\n if (status === 409) {\n return \"CONFLICT\";\n }\n if (status === 429) {\n return \"RATE_LIMIT_EXCEEDED\";\n }\n if (status >= 500) {\n return \"UPSTREAM_ERROR\";\n }\n return \"INTERNAL_ERROR\";\n}\n\nfunction delay(ms: number): Promise<void> {\n return new Promise((resolve) => setTimeout(resolve, ms));\n}\n\nfunction parseRetryAfterMs(value: string | null): number | null {\n if (!value) {\n return null;\n }\n const trimmed = value.trim();\n if (!trimmed) {\n return null;\n }\n const numeric = Number(trimmed);\n if (Number.isFinite(numeric)) {\n return Math.max(0, Math.round(numeric * 1000));\n }\n const parsedDate = Date.parse(trimmed);\n if (Number.isFinite(parsedDate)) {\n return Math.max(0, parsedDate - Date.now());\n }\n return null;\n}\n\nfunction computeRetryDelayMs(args: {\n attempt: number;\n status?: number;\n retryAfterMs?: number | null;\n}): number {\n const baseDelay =\n args.status === 429\n ? Math.max(\n args.retryAfterMs ?? 0,\n Math.min(1000 * 2 ** args.attempt, 10_000)\n )\n : Math.min(1000 * 2 ** args.attempt, 4000);\n\n if (args.status !== 429) {\n return baseDelay;\n }\n\n const jitterWindow = Math.max(250, Math.round(baseDelay * 0.25));\n return baseDelay + Math.round(Math.random() * jitterWindow);\n}\n\nfunction timeoutError(timeoutMs: number): Error {\n const error = new Error(`Request timed out after ${timeoutMs}ms`);\n error.name = \"AbortError\";\n return error;\n}\n\nfunction readPolicySummaryFromDetails(details?: JsonValue): string | null {\n if (!details || typeof details !== \"object\" || Array.isArray(details)) {\n return null;\n }\n\n const directSummary = (details as { summary?: JsonValue }).summary;\n if (typeof directSummary === \"string\" && directSummary.trim().length > 0) {\n return directSummary.trim();\n }\n\n const policy = (details as { policy?: JsonValue }).policy;\n if (!policy || typeof policy !== \"object\" || Array.isArray(policy)) {\n return null;\n }\n\n const explanation = (policy as { explanation?: JsonValue }).explanation;\n if (!explanation || typeof explanation !== \"object\" || Array.isArray(explanation)) {\n return null;\n }\n\n const nestedSummary = (explanation as { summary?: JsonValue }).summary;\n if (typeof nestedSummary === \"string\" && nestedSummary.trim().length > 0) {\n return nestedSummary.trim();\n }\n\n return null;\n}\n\nasync function resolveConfiguredAuthContext(\n authContext: GatewayClientConfig[\"authContext\"]\n): Promise<LucernSdkAuthContextInput | undefined> {\n if (typeof authContext === \"function\") {\n return await authContext();\n }\n return authContext;\n}\n\nfunction mergeHeaderRecord(\n base: Record<string, string>,\n addition: Record<string, string>\n): Record<string, string> {\n const headers = new Headers(base);\n for (const [key, value] of Object.entries(addition)) {\n const existing = headers.get(key);\n if (existing !== null && existing !== value) {\n throw new LucernSdkAuthContextError(\n \"policy_denied\",\n `Canonical Lucern SDK auth context conflicts with existing ${key} header.`\n );\n }\n headers.set(key, value);\n }\n return Object.fromEntries(headers.entries());\n}\n\n/**\n * Create the transport client used by all SDK modules.\n */\nexport function createGatewayRequestClient(config: GatewayClientConfig = {}) {\n const fetchImpl = config.fetchImpl ?? fetch;\n const baseUrl = config.baseUrl?.replace(/\\/+$/, \"\") ?? \"\";\n const maxRetries = config.maxRetries ?? 2;\n const requestIdFactory = config.requestIdFactory ?? (() => generatePortableRequestId());\n\n async function resolveAuthHeaders(): Promise<Record<string, string>> {\n const base = config.getAuthHeaders ? await config.getAuthHeaders() : {};\n const authContextInput = await resolveConfiguredAuthContext(\n config.authContext\n );\n if (!authContextInput && !config.requireCanonicalAuthContext) {\n return base;\n }\n const authContext = normalizeCanonicalLucernAuthContext(authContextInput);\n return mergeHeaderRecord(base, createCanonicalAuthHeaders(authContext));\n }\n\n async function fetchWithTimeout(\n url: string,\n init: RequestInit,\n timeoutMs: number\n ): Promise<Response> {\n const controller = new AbortController();\n const timer = setTimeout(() => controller.abort(), timeoutMs);\n try {\n return await fetchImpl(url, { ...init, signal: controller.signal });\n } catch (error) {\n if (controller.signal.aborted) {\n throw timeoutError(timeoutMs);\n }\n throw error;\n } finally {\n clearTimeout(timer);\n }\n }\n\n async function parsePayload<T>(\n response: Response\n ): Promise<PlatformGatewayEnvelope<T> | null> {\n const text = await response.text();\n if (!text) {\n return null;\n }\n try {\n return JSON.parse(text) as PlatformGatewayEnvelope<T>;\n } catch {\n return null;\n }\n }\n\n function resolveTimeoutMs(\n method: GatewayHttpMethod,\n requestTimeoutMs?: number\n ): number {\n if (typeof requestTimeoutMs === \"number\") {\n return requestTimeoutMs;\n }\n const methodTimeoutMs = config.timeoutMsByMethod?.[method];\n if (typeof methodTimeoutMs === \"number\") {\n return methodTimeoutMs;\n }\n return config.timeoutMs ?? 15_000;\n }\n\n function buildApiError(args: {\n requestId: string;\n response: Response;\n failure?: PlatformGatewayFailure | null;\n }): LucernApiError {\n const failure = args.failure;\n const legacyError =\n failure && typeof failure.error === \"object\" && failure.error !== null\n ? failure.error\n : failure?.legacyError;\n const correlationId =\n failure?.correlationId ??\n args.response.headers.get(\"x-lucern-correlation-id\")?.trim() ??\n args.requestId;\n const policyTraceId =\n failure?.policyTraceId ??\n args.response.headers.get(\"x-lucern-policy-trace-id\")?.trim() ??\n null;\n const details = failure?.details ?? legacyError?.details;\n const policySummary = readPolicySummaryFromDetails(details);\n\n return new LucernApiError({\n code: failure?.code ?? legacyError?.code ?? fallbackErrorCode(args.response.status),\n message:\n policySummary ??\n (typeof failure?.error === \"string\"\n ? failure.error\n : legacyError?.message ??\n (args.response.ok\n ? \"Platform API returned an invalid success payload.\"\n : \"Platform API request failed.\")),\n status: args.response.status,\n invariant: failure?.invariant,\n suggestion: failure?.suggestion,\n details,\n requestId: args.requestId,\n correlationId,\n policyTraceId,\n });\n }\n\n async function request<T>(args: {\n path: string;\n method?: GatewayHttpMethod;\n body?: JsonObject;\n idempotencyKey?: string;\n requestId?: string;\n timeoutMs?: number;\n }): Promise<PlatformGatewaySuccess<T>> {\n const authHeaders = await resolveAuthHeaders();\n const method = args.method ?? \"GET\";\n const timeoutMs = resolveTimeoutMs(method, args.timeoutMs);\n const headers = new Headers({\n \"content-type\": \"application/json\",\n ...authHeaders,\n });\n if (args.idempotencyKey) {\n headers.set(\"idempotency-key\", args.idempotencyKey);\n }\n const requestId =\n headers.get(\"x-correlation-id\")?.trim() ||\n headers.get(\"x-request-id\")?.trim() ||\n args.requestId ||\n requestIdFactory();\n if (!headers.has(\"x-correlation-id\") && !headers.has(\"x-request-id\")) {\n headers.set(\"x-correlation-id\", requestId);\n }\n\n const url = `${baseUrl}${args.path}`;\n const serializedBody = args.body ? JSON.stringify(args.body) : undefined;\n const init: RequestInit = {\n method,\n headers,\n body: serializedBody,\n };\n\n let lastError: unknown;\n\n for (let attempt = 0; attempt <= maxRetries; attempt++) {\n const hookRequestContext: GatewayRequestHookContext = {\n requestId,\n attempt,\n maxRetries,\n method,\n path: args.path,\n url,\n headers: new Headers(headers),\n body: serializedBody,\n timeoutMs,\n };\n await config.onRequest?.(hookRequestContext);\n const startedAt = Date.now();\n try {\n const response = await fetchWithTimeout(url, init, timeoutMs);\n const responseClone = response.clone();\n const payload = await parsePayload<T>(response);\n const retryAfterMs = parseRetryAfterMs(\n response.headers.get(\"Retry-After\")\n );\n\n if (!response.ok || !payload?.success) {\n const failure =\n payload && !payload.success ? (payload as PlatformGatewayFailure) : null;\n const apiError = buildApiError({\n requestId,\n response,\n failure,\n });\n const willRetry = attempt < maxRetries && isRetryableStatus(response.status);\n\n await config.onResponse?.({\n ...hookRequestContext,\n durationMs: Date.now() - startedAt,\n status: response.status,\n response: responseClone,\n error: apiError,\n correlationId: apiError.correlationId ?? requestId,\n policyTraceId: apiError.policyTraceId ?? null,\n retryAfterMs,\n willRetry,\n });\n\n if (willRetry) {\n lastError = apiError;\n await delay(\n computeRetryDelayMs({\n attempt,\n status: response.status,\n retryAfterMs,\n })\n );\n continue;\n }\n\n throw apiError;\n }\n\n const successPayload = payload as PlatformGatewaySuccess<T>;\n await config.onResponse?.({\n ...hookRequestContext,\n durationMs: Date.now() - startedAt,\n status: response.status,\n response: responseClone,\n correlationId:\n successPayload.correlationId ??\n response.headers.get(\"x-lucern-correlation-id\")?.trim() ??\n requestId,\n policyTraceId:\n successPayload.policyTraceId ??\n response.headers.get(\"x-lucern-policy-trace-id\")?.trim() ??\n null,\n idempotentReplay: successPayload.idempotentReplay,\n retryAfterMs,\n willRetry: false,\n });\n\n return successPayload;\n } catch (fetchError) {\n if (fetchError instanceof LucernApiError) {\n throw fetchError;\n }\n const willRetry = attempt < maxRetries;\n await config.onResponse?.({\n ...hookRequestContext,\n durationMs: Date.now() - startedAt,\n error: fetchError,\n correlationId: requestId,\n policyTraceId: null,\n willRetry,\n });\n lastError = fetchError;\n if (willRetry) {\n await delay(computeRetryDelayMs({ attempt }));\n }\n }\n }\n\n throw lastError instanceof Error\n ? lastError\n : new Error(\"Platform API request failed after retries.\");\n }\n\n return {\n request,\n };\n}\n","import type { PlatformGatewaySuccess } from \"./coreClient\";\nimport type { JsonObject, ListResult } from \"./types\";\n\ntype TopicScopedValue = {\n topicId?: string;\n};\n\ntype TextScopedValue = {\n text?: string;\n canonicalText?: string;\n};\n\ntype AnyRecord = Record<string, unknown>;\n\nfunction asRecord(value: unknown): AnyRecord {\n return value && typeof value === \"object\" ? (value as AnyRecord) : {};\n}\n\nfunction cleanString(value: unknown): string | undefined {\n return typeof value === \"string\" && value.trim().length > 0\n ? value.trim()\n : undefined;\n}\n\nfunction normalizeVerificationStatus(value: unknown): string | undefined {\n const status = cleanString(value);\n if (!status) {\n return undefined;\n }\n if (status === \"verified\") {\n return \"human_verified\";\n }\n if (status === \"rejected\") {\n return \"contradicted\";\n }\n return status;\n}\n\nfunction cloneWith<T extends AnyRecord>(value: T, patch: AnyRecord): T {\n return { ...value, ...patch } as T;\n}\n\n/**\n * Resolve the canonical topic identifier.\n */\nexport function resolveTopicId(value: TopicScopedValue): string | undefined {\n return cleanString(value.topicId);\n}\n\n/**\n * Resolve the canonical text field from text-first or legacy canonicalText-first inputs.\n */\nexport function resolveText(value: TextScopedValue): string | undefined {\n return cleanString(value.text) ?? cleanString(value.canonicalText);\n}\n\n/**\n * Attach the topicId to a record.\n */\nexport function withTopicAlias<T extends AnyRecord>(value: T): T {\n const topicId = cleanString(value.topicId) ?? undefined;\n if (!topicId) {\n return value;\n }\n return cloneWith(value, { topicId });\n}\n\n/**\n * Attach the text/canonicalText alias pair to a record.\n */\nexport function withTextAlias<T extends AnyRecord>(value: T): T {\n const text =\n cleanString(value.text) ?? cleanString(value.canonicalText) ?? undefined;\n if (!text) {\n return value;\n }\n return cloneWith(value, { text, canonicalText: text });\n}\n\n/**\n * Attach topic and text aliases to SDK node-like records.\n */\nexport function withSdkAliases<T extends AnyRecord>(value: T): T {\n return withTopicAlias(withTextAlias(value));\n}\n\n/**\n * Normalize a belief/question/evidence write payload to the canonical gateway shape.\n */\nexport function normalizeNodeWriteInput<T extends JsonObject>(value: T): T {\n const topicId = resolveTopicId(value);\n const text = resolveText(value);\n const verificationStatus = normalizeVerificationStatus(value.verificationStatus);\n const next = { ...value } as JsonObject;\n\n if (topicId) {\n next.topicId = topicId;\n }\n if (text) {\n next.text = text;\n next.canonicalText = text;\n }\n if (verificationStatus) {\n next.verificationStatus = verificationStatus;\n }\n\n return next as T;\n}\n\nexport function normalizeNodeVerificationStatus(value: unknown) {\n return normalizeVerificationStatus(value);\n}\n\n/**\n * Build a topic-aware query object.\n */\nexport function normalizeTopicQuery<T extends JsonObject>(value: T): T {\n const topicId = cleanString(value.topicId);\n if (!topicId) {\n return value;\n }\n return { ...value, topicId } as T;\n}\n\n/**\n * Extract list items from array or list-envelope payloads.\n */\nexport function asListItems<T>(data: unknown, legacyKey?: string): T[] {\n if (Array.isArray(data)) {\n return data as T[];\n }\n\n const record = asRecord(data);\n if (Array.isArray(record.items)) {\n return record.items as T[];\n }\n if (legacyKey && Array.isArray(record[legacyKey])) {\n return record[legacyKey] as T[];\n }\n\n return [];\n}\n\n/**\n * Standardize list data to { items, total } while retaining an optional legacy array key.\n */\nexport function createListResult<T, LegacyKey extends string>(\n items: T[],\n legacyKey?: LegacyKey\n): ListResult<T, LegacyKey> {\n const result = {\n items,\n total: items.length,\n } as ListResult<T, LegacyKey>;\n\n if (legacyKey) {\n (result as Record<string, unknown>)[legacyKey] = items;\n }\n\n return result;\n}\n\n/**\n * Map a gateway success envelope's data while preserving the transport metadata.\n */\nexport function mapGatewayData<T, U>(\n response: PlatformGatewaySuccess<T>,\n mapper: (data: T) => U\n): PlatformGatewaySuccess<U> {\n return {\n ...response,\n data: mapper(response.data),\n };\n}\n\n/**\n * Apply SDK aliases across all items in a list-like payload.\n */\nexport function mapAliasedList<\n TItem extends AnyRecord,\n LegacyKey extends string,\n>(\n data: unknown,\n legacyKey?: LegacyKey\n): ListResult<TItem, LegacyKey> {\n const items = asListItems<TItem>(data, legacyKey).map((item) =>\n withSdkAliases(item)\n );\n return createListResult(items, legacyKey);\n}\n","import {\n createGatewayRequestClient,\n type GatewayClientConfig,\n type GatewayScope,\n LucernApiError,\n toQueryString,\n} from \"./coreClient\";\nimport { createListResult, mapGatewayData, normalizeTopicQuery } from \"./sdkSurface\";\nimport type { TopicIdentifierInput } from \"./types\";\n\nexport { LucernApiError };\nexport type { GatewayScope, PlatformGatewaySuccess } from \"./coreClient\";\n\n/** Configuration for the audit client. */\nexport type AuditClientConfig = GatewayClientConfig;\n\n/**\n * Create the audit client for transport-level audit event reads.\n * @param config - Gateway transport configuration.\n * @returns An object with methods to list audit events.\n */\nexport function createAuditClient(config: AuditClientConfig = {}) {\n const gateway = createGatewayRequestClient(config);\n\n return {\n /**\n * List audit events for the current scope.\n */\n async listEvents(\n query: GatewayScope & {\n action?: string;\n decision?: string;\n traceId?: string;\n principalId?: string;\n topicId?: string;\n limit?: number;\n } & TopicIdentifierInput = {}\n ) {\n return gateway.request<unknown>({\n path: `/api/platform/v1/audit/events${toQueryString(\n normalizeTopicQuery(query)\n )}`,\n }).then((response) =>\n mapGatewayData(response, (data) =>\n createListResult(Array.isArray(data) ? data : [], \"events\")\n )\n );\n },\n };\n}\n"]}
@@ -0,0 +1,56 @@
1
+ import { SessionPrincipalType, SessionAuthMode, SessionDelegationHop } from './contracts/auth-session.contract.js';
2
+ import { JsonObject } from './types.js';
3
+ import './contracts/workflow-runtime.contract.js';
4
+ import './contracts/lens-workflow.contract.js';
5
+ import './contracts/lens-filter.contract.js';
6
+
7
+ type LucernSdkAuthFailureReason = "principal_missing" | "tenant_missing" | "membership_missing" | "workspace_missing" | "policy_denied";
8
+ type PermitReadyAuthContext = {
9
+ subject: string;
10
+ tenant: string;
11
+ workspace: string;
12
+ resource?: string;
13
+ action?: string;
14
+ relation?: string;
15
+ context?: JsonObject;
16
+ };
17
+ type LucernSdkAuthPolicyDecision = "allow" | "deny" | "unknown";
18
+ type LucernSdkAuthContextInput = {
19
+ clerkId?: string;
20
+ principalId?: string;
21
+ tenantId?: string;
22
+ workspaceId?: string;
23
+ principalType?: SessionPrincipalType;
24
+ authMode?: SessionAuthMode;
25
+ roles?: readonly string[];
26
+ scopes?: readonly string[];
27
+ delegationChain?: readonly SessionDelegationHop[];
28
+ policyTraceId?: string;
29
+ correlationId?: string;
30
+ membershipId?: string;
31
+ policyDecision?: LucernSdkAuthPolicyDecision;
32
+ permit?: Partial<PermitReadyAuthContext>;
33
+ };
34
+ type CanonicalLucernSdkAuthContext = {
35
+ clerkId?: string;
36
+ principalId: string;
37
+ tenantId: string;
38
+ workspaceId: string;
39
+ principalType: SessionPrincipalType;
40
+ authMode: SessionAuthMode;
41
+ roles: string[];
42
+ scopes: string[];
43
+ delegationChain: SessionDelegationHop[];
44
+ policyTraceId?: string;
45
+ correlationId?: string;
46
+ membershipId?: string;
47
+ permit: PermitReadyAuthContext;
48
+ };
49
+ declare class LucernSdkAuthContextError extends Error {
50
+ readonly reason: LucernSdkAuthFailureReason;
51
+ constructor(reason: LucernSdkAuthFailureReason, message: string);
52
+ }
53
+ declare function normalizeCanonicalLucernAuthContext(input: LucernSdkAuthContextInput | undefined): CanonicalLucernSdkAuthContext;
54
+ declare function createCanonicalAuthHeaders(authContext: CanonicalLucernSdkAuthContext): Record<string, string>;
55
+
56
+ export { type CanonicalLucernSdkAuthContext, LucernSdkAuthContextError, type LucernSdkAuthContextInput, type LucernSdkAuthFailureReason, type LucernSdkAuthPolicyDecision, type PermitReadyAuthContext, createCanonicalAuthHeaders, normalizeCanonicalLucernAuthContext };
@@ -0,0 +1,170 @@
1
+ // src/authContext.ts
2
+ var LucernSdkAuthContextError = class extends Error {
3
+ reason;
4
+ constructor(reason, message) {
5
+ super(message);
6
+ this.name = "LucernSdkAuthContextError";
7
+ this.reason = reason;
8
+ }
9
+ };
10
+ function cleanString(value) {
11
+ const normalized = value?.trim();
12
+ return normalized ? normalized : void 0;
13
+ }
14
+ function cleanStringList(values) {
15
+ if (!values) {
16
+ return [];
17
+ }
18
+ return values.map((value) => value.trim()).filter(
19
+ (value, index, list) => value.length > 0 && list.indexOf(value) === index
20
+ );
21
+ }
22
+ function requireString(value, reason, label) {
23
+ const normalized = cleanString(value);
24
+ if (!normalized) {
25
+ throw new LucernSdkAuthContextError(
26
+ reason,
27
+ `Canonical Lucern SDK auth context is missing ${label}.`
28
+ );
29
+ }
30
+ return normalized;
31
+ }
32
+ function requirePrincipalType(principalType) {
33
+ if (!principalType) {
34
+ throw new LucernSdkAuthContextError(
35
+ "principal_missing",
36
+ "Canonical Lucern SDK auth context is missing principalType."
37
+ );
38
+ }
39
+ return principalType;
40
+ }
41
+ function requireAuthMode(authMode) {
42
+ if (!authMode) {
43
+ throw new LucernSdkAuthContextError(
44
+ "principal_missing",
45
+ "Canonical Lucern SDK auth context is missing authMode."
46
+ );
47
+ }
48
+ return authMode;
49
+ }
50
+ function ensurePermitMatch(args) {
51
+ const actual = cleanString(args.actual);
52
+ if (actual && actual !== args.expected) {
53
+ throw new LucernSdkAuthContextError(
54
+ "policy_denied",
55
+ `Canonical Lucern SDK auth context has conflicting Permit ${args.field}.`
56
+ );
57
+ }
58
+ }
59
+ function normalizeCanonicalLucernAuthContext(input) {
60
+ if (!input) {
61
+ throw new LucernSdkAuthContextError(
62
+ "principal_missing",
63
+ "Canonical Lucern SDK auth context is required."
64
+ );
65
+ }
66
+ if (input.policyDecision === "deny") {
67
+ throw new LucernSdkAuthContextError(
68
+ "policy_denied",
69
+ "Canonical Lucern SDK auth context carries a denied policy decision."
70
+ );
71
+ }
72
+ const principalId = requireString(
73
+ input.principalId,
74
+ "principal_missing",
75
+ "principalId"
76
+ );
77
+ const tenantId = requireString(input.tenantId, "tenant_missing", "tenantId");
78
+ const workspaceId = requireString(
79
+ input.workspaceId,
80
+ "workspace_missing",
81
+ "workspaceId"
82
+ );
83
+ const roles = cleanStringList(input.roles);
84
+ const scopes = cleanStringList(input.scopes);
85
+ const principalType = requirePrincipalType(input.principalType);
86
+ const authMode = requireAuthMode(input.authMode);
87
+ const roleBasedInteractiveAuth = authMode === "interactive_user" && roles.length > 0;
88
+ if (roles.length === 0 || scopes.length === 0 && !roleBasedInteractiveAuth) {
89
+ throw new LucernSdkAuthContextError(
90
+ "membership_missing",
91
+ "Canonical Lucern SDK auth context requires non-empty roles and scopes."
92
+ );
93
+ }
94
+ const subject = cleanString(input.permit?.subject) ?? principalId;
95
+ const tenant = cleanString(input.permit?.tenant) ?? tenantId;
96
+ const workspace = cleanString(input.permit?.workspace) ?? workspaceId;
97
+ ensurePermitMatch({
98
+ field: "subject",
99
+ expected: principalId,
100
+ actual: subject
101
+ });
102
+ ensurePermitMatch({ field: "tenant", expected: tenantId, actual: tenant });
103
+ ensurePermitMatch({
104
+ field: "workspace",
105
+ expected: workspaceId,
106
+ actual: workspace
107
+ });
108
+ const context = input.permit?.context ? { ...input.permit.context } : void 0;
109
+ return {
110
+ clerkId: cleanString(input.clerkId),
111
+ principalId,
112
+ tenantId,
113
+ workspaceId,
114
+ principalType,
115
+ authMode,
116
+ roles,
117
+ scopes,
118
+ delegationChain: input.delegationChain ? [...input.delegationChain] : [],
119
+ policyTraceId: cleanString(input.policyTraceId),
120
+ correlationId: cleanString(input.correlationId),
121
+ membershipId: cleanString(input.membershipId),
122
+ permit: {
123
+ subject,
124
+ tenant,
125
+ workspace,
126
+ resource: cleanString(input.permit?.resource),
127
+ action: cleanString(input.permit?.action),
128
+ relation: cleanString(input.permit?.relation),
129
+ context
130
+ }
131
+ };
132
+ }
133
+ function createCanonicalAuthHeaders(authContext) {
134
+ const headers = {
135
+ "x-lucern-principal-id": authContext.principalId,
136
+ "x-lucern-principal-type": authContext.principalType,
137
+ "x-lucern-tenant": authContext.tenantId,
138
+ "x-lucern-tenant-id": authContext.tenantId,
139
+ "x-lucern-workspace": authContext.workspaceId,
140
+ "x-lucern-workspace-id": authContext.workspaceId,
141
+ "x-lucern-auth-mode": authContext.authMode,
142
+ "x-lucern-roles": authContext.roles.join(","),
143
+ "x-lucern-scopes": authContext.scopes.join(","),
144
+ "x-lucern-permit-context": JSON.stringify(authContext.permit)
145
+ };
146
+ if (authContext.clerkId) {
147
+ headers["x-lucern-clerk-id"] = authContext.clerkId;
148
+ headers["x-lucern-user-id"] = authContext.clerkId;
149
+ }
150
+ if (authContext.delegationChain.length > 0) {
151
+ headers["x-lucern-delegation-chain"] = JSON.stringify(
152
+ authContext.delegationChain
153
+ );
154
+ }
155
+ if (authContext.policyTraceId) {
156
+ headers["x-lucern-policy-trace-id"] = authContext.policyTraceId;
157
+ }
158
+ if (authContext.correlationId) {
159
+ headers["x-correlation-id"] = authContext.correlationId;
160
+ headers["x-lucern-correlation-id"] = authContext.correlationId;
161
+ }
162
+ if (authContext.membershipId) {
163
+ headers["x-lucern-membership-id"] = authContext.membershipId;
164
+ }
165
+ return headers;
166
+ }
167
+
168
+ export { LucernSdkAuthContextError, createCanonicalAuthHeaders, normalizeCanonicalLucernAuthContext };
169
+ //# sourceMappingURL=authContext.js.map
170
+ //# sourceMappingURL=authContext.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/authContext.ts"],"names":[],"mappings":";AA2DO,IAAM,yBAAA,GAAN,cAAwC,KAAA,CAAM;AAAA,EAC1C,MAAA;AAAA,EAET,WAAA,CAAY,QAAoC,OAAA,EAAiB;AAC/D,IAAA,KAAA,CAAM,OAAO,CAAA;AACb,IAAA,IAAA,CAAK,IAAA,GAAO,2BAAA;AACZ,IAAA,IAAA,C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2BAA2B,IAAI,IAAA,CAAK,SAAA;AAAA,MAC1C,WAAA,CAAY;AAAA,KACd;AAAA,EACF;AACA,EAAA,IAAI,YAAY,aAAA,EAAe;AAC7B,IAAA,OAAA,CAAQ,0BAA0B,IAAI,WAAA,CAAY,aAAA;AAAA,EACpD;AACA,EAAA,IAAI,YAAY,aAAA,EAAe;AAC7B,IAAA,OAAA,CAAQ,kBAAkB,IAAI,WAAA,CAAY,aAAA;AAC1C,IAAA,OAAA,CAAQ,yBAAyB,IAAI,WAAA,CAAY,aAAA;AAAA,EACnD;AACA,EAAA,IAAI,YAAY,YAAA,EAAc;AAC5B,IAAA,OAAA,CAAQ,wBAAwB,IAAI,WAAA,CAAY,YAAA;AAAA,EAClD;AAEA,EAAA,OAAO,OAAA;AACT","file":"authContext.js","sourcesContent":["import type {\n SessionAuthMode,\n SessionDelegationHop,\n SessionPrincipalType,\n} from \"./contracts/auth-session.contract\";\nimport type { JsonObject } from \"./types\";\n\nexport type LucernSdkAuthFailureReason =\n | \"principal_missing\"\n | \"tenant_missing\"\n | \"membership_missing\"\n | \"workspace_missing\"\n | \"policy_denied\";\n\nexport type PermitReadyAuthContext = {\n subject: string;\n tenant: string;\n workspace: string;\n resource?: string;\n action?: string;\n relation?: string;\n context?: JsonObject;\n};\n\nexport type LucernSdkAuthPolicyDecision = \"allow\" | \"deny\" | \"unknown\";\n\nexport type LucernSdkAuthContextInput = {\n clerkId?: string;\n principalId?: string;\n tenantId?: string;\n workspaceId?: string;\n principalType?: SessionPrincipalType;\n authMode?: SessionAuthMode;\n roles?: readonly string[];\n scopes?: readonly string[];\n delegationChain?: readonly SessionDelegationHop[];\n policyTraceId?: string;\n correlationId?: string;\n membershipId?: string;\n policyDecision?: LucernSdkAuthPolicyDecision;\n permit?: Partial<PermitReadyAuthContext>;\n};\n\nexport type CanonicalLucernSdkAuthContext = {\n clerkId?: string;\n principalId: string;\n tenantId: string;\n workspaceId: string;\n principalType: SessionPrincipalType;\n authMode: SessionAuthMode;\n roles: string[];\n scopes: string[];\n delegationChain: SessionDelegationHop[];\n policyTraceId?: string;\n correlationId?: string;\n membershipId?: string;\n permit: PermitReadyAuthContext;\n};\n\nexport class LucernSdkAuthContextError extends Error {\n readonly reason: LucernSdkAuthFailureReason;\n\n constructor(reason: LucernSdkAuthFailureReason, message: string) {\n super(message);\n this.name = \"LucernSdkAuthContextError\";\n this.reason = reason;\n }\n}\n\nfunction cleanString(value: string | undefined): string | undefined {\n const normalized = value?.trim();\n return normalized ? normalized : undefined;\n}\n\nfunction cleanStringList(values: readonly string[] | undefined): string[] {\n if (!values) {\n return [];\n }\n return values\n .map((value) => value.trim())\n .filter(\n (value, index, list) =>\n value.length > 0 && list.indexOf(value) === index\n );\n}\n\nfunction requireString(\n value: string | undefined,\n reason: LucernSdkAuthFailureReason,\n label: string\n): string {\n const normalized = cleanString(value);\n if (!normalized) {\n throw new LucernSdkAuthContextError(\n reason,\n `Canonical Lucern SDK auth context is missing ${label}.`\n );\n }\n return normalized;\n}\n\nfunction requirePrincipalType(\n principalType: SessionPrincipalType | undefined\n): SessionPrincipalType {\n if (!principalType) {\n throw new LucernSdkAuthContextError(\n \"principal_missing\",\n \"Canonical Lucern SDK auth context is missing principalType.\"\n );\n }\n return principalType;\n}\n\nfunction requireAuthMode(authMode: SessionAuthMode | undefined): SessionAuthMode {\n if (!authMode) {\n throw new LucernSdkAuthContextError(\n \"principal_missing\",\n \"Canonical Lucern SDK auth context is missing authMode.\"\n );\n }\n return authMode;\n}\n\nfunction ensurePermitMatch(args: {\n field: keyof PermitReadyAuthContext;\n expected: string;\n actual?: string;\n}) {\n const actual = cleanString(args.actual);\n if (actual && actual !== args.expected) {\n throw new LucernSdkAuthContextError(\n \"policy_denied\",\n `Canonical Lucern SDK auth context has conflicting Permit ${args.field}.`\n );\n }\n}\n\nexport function normalizeCanonicalLucernAuthContext(\n input: LucernSdkAuthContextInput | undefined\n): CanonicalLucernSdkAuthContext {\n if (!input) {\n throw new LucernSdkAuthContextError(\n \"principal_missing\",\n \"Canonical Lucern SDK auth context is required.\"\n );\n }\n\n if (input.policyDecision === \"deny\") {\n throw new LucernSdkAuthContextError(\n \"policy_denied\",\n \"Canonical Lucern SDK auth context carries a denied policy decision.\"\n );\n }\n\n const principalId = requireString(\n input.principalId,\n \"principal_missing\",\n \"principalId\"\n );\n const tenantId = requireString(input.tenantId, \"tenant_missing\", \"tenantId\");\n const workspaceId = requireString(\n input.workspaceId,\n \"workspace_missing\",\n \"workspaceId\"\n );\n const roles = cleanStringList(input.roles);\n const scopes = cleanStringList(input.scopes);\n const principalType = requirePrincipalType(input.principalType);\n const authMode = requireAuthMode(input.authMode);\n const roleBasedInteractiveAuth =\n authMode === \"interactive_user\" && roles.length > 0;\n if (\n roles.length === 0 ||\n (scopes.length === 0 && !roleBasedInteractiveAuth)\n ) {\n throw new LucernSdkAuthContextError(\n \"membership_missing\",\n \"Canonical Lucern SDK auth context requires non-empty roles and scopes.\"\n );\n }\n\n const subject = cleanString(input.permit?.subject) ?? principalId;\n const tenant = cleanString(input.permit?.tenant) ?? tenantId;\n const workspace = cleanString(input.permit?.workspace) ?? workspaceId;\n\n ensurePermitMatch({\n field: \"subject\",\n expected: principalId,\n actual: subject,\n });\n ensurePermitMatch({ field: \"tenant\", expected: tenantId, actual: tenant });\n ensurePermitMatch({\n field: \"workspace\",\n expected: workspaceId,\n actual: workspace,\n });\n\n const context = input.permit?.context\n ? ({ ...input.permit.context } as JsonObject)\n : undefined;\n\n return {\n clerkId: cleanString(input.clerkId),\n principalId,\n tenantId,\n workspaceId,\n principalType,\n authMode,\n roles,\n scopes,\n delegationChain: input.delegationChain ? [...input.delegationChain] : [],\n policyTraceId: cleanString(input.policyTraceId),\n correlationId: cleanString(input.correlationId),\n membershipId: cleanString(input.membershipId),\n permit: {\n subject,\n tenant,\n workspace,\n resource: cleanString(input.permit?.resource),\n action: cleanString(input.permit?.action),\n relation: cleanString(input.permit?.relation),\n context,\n },\n };\n}\n\nexport function createCanonicalAuthHeaders(\n authContext: CanonicalLucernSdkAuthContext\n): Record<string, string> {\n const headers: Record<string, string> = {\n \"x-lucern-principal-id\": authContext.principalId,\n \"x-lucern-principal-type\": authContext.principalType,\n \"x-lucern-tenant\": authContext.tenantId,\n \"x-lucern-tenant-id\": authContext.tenantId,\n \"x-lucern-workspace\": authContext.workspaceId,\n \"x-lucern-workspace-id\": authContext.workspaceId,\n \"x-lucern-auth-mode\": authContext.authMode,\n \"x-lucern-roles\": authContext.roles.join(\",\"),\n \"x-lucern-scopes\": authContext.scopes.join(\",\"),\n \"x-lucern-permit-context\": JSON.stringify(authContext.permit),\n };\n\n if (authContext.clerkId) {\n headers[\"x-lucern-clerk-id\"] = authContext.clerkId;\n headers[\"x-lucern-user-id\"] = authContext.clerkId;\n }\n if (authContext.delegationChain.length > 0) {\n headers[\"x-lucern-delegation-chain\"] = JSON.stringify(\n authContext.delegationChain\n );\n }\n if (authContext.policyTraceId) {\n headers[\"x-lucern-policy-trace-id\"] = authContext.policyTraceId;\n }\n if (authContext.correlationId) {\n headers[\"x-correlation-id\"] = authContext.correlationId;\n headers[\"x-lucern-correlation-id\"] = authContext.correlationId;\n }\n if (authContext.membershipId) {\n headers[\"x-lucern-membership-id\"] = authContext.membershipId;\n }\n\n return headers;\n}\n"]}
@@ -0,0 +1,49 @@
1
+ import { GatewayClientConfig } from './coreClient.js';
2
+ import './authContext.js';
3
+ import './contracts/auth-session.contract.js';
4
+ import './types.js';
5
+ import './contracts/workflow-runtime.contract.js';
6
+ import './contracts/lens-workflow.contract.js';
7
+ import './contracts/lens-filter.contract.js';
8
+
9
+ type DeviceCodeInput = {
10
+ clientId?: string;
11
+ scope?: string;
12
+ };
13
+ type DeviceCodeResponse = {
14
+ device_code: string;
15
+ user_code: string;
16
+ verification_uri: string;
17
+ verification_uri_complete: string;
18
+ expires_in: number;
19
+ interval: number;
20
+ };
21
+ type DeviceTokenResponse = {
22
+ access_token: string;
23
+ token_type: "Bearer";
24
+ expires_in: number;
25
+ scope: string;
26
+ tenant_id: string;
27
+ workspace_id?: string;
28
+ principal_id: string;
29
+ user?: {
30
+ id: string;
31
+ principalId: string;
32
+ };
33
+ };
34
+ type DeviceTokenErrorCode = "authorization_pending" | "slow_down" | "access_denied" | "expired_token" | "invalid_grant" | "invalid_request";
35
+ declare class DeviceAuthorizationError extends Error {
36
+ readonly error: DeviceTokenErrorCode;
37
+ readonly interval?: number;
38
+ constructor(args: {
39
+ error: DeviceTokenErrorCode;
40
+ description?: string;
41
+ interval?: number;
42
+ });
43
+ }
44
+ declare function createAuthDeviceClient(config?: GatewayClientConfig): {
45
+ createDeviceCode(input?: DeviceCodeInput): Promise<DeviceCodeResponse>;
46
+ pollDeviceToken(deviceCode: string): Promise<DeviceTokenResponse>;
47
+ };
48
+
49
+ export { DeviceAuthorizationError, type DeviceCodeInput, type DeviceCodeResponse, type DeviceTokenErrorCode, type DeviceTokenResponse, createAuthDeviceClient };
@@ -0,0 +1,108 @@
1
+ // src/authDeviceClient.ts
2
+ var DeviceAuthorizationError = class extends Error {
3
+ error;
4
+ interval;
5
+ constructor(args) {
6
+ super(args.description ?? args.error);
7
+ this.name = "DeviceAuthorizationError";
8
+ this.error = args.error;
9
+ this.interval = args.interval;
10
+ }
11
+ };
12
+ function authBaseUrl(config) {
13
+ return config.baseUrl?.replace(/\/+$/, "") ?? "";
14
+ }
15
+ async function readJson(response) {
16
+ const payload = await response.json().catch(() => ({}));
17
+ return payload && typeof payload === "object" && !Array.isArray(payload) ? payload : {};
18
+ }
19
+ function readString(value) {
20
+ const normalized = typeof value === "string" ? value.trim() : "";
21
+ return normalized || void 0;
22
+ }
23
+ function assertDeviceCodeResponse(payload) {
24
+ const deviceCode = readString(payload.device_code);
25
+ const userCode = readString(payload.user_code);
26
+ const verificationUri = readString(payload.verification_uri);
27
+ const verificationUriComplete = readString(payload.verification_uri_complete);
28
+ const expiresIn = payload.expires_in;
29
+ const interval = payload.interval;
30
+ if (!deviceCode || !userCode || !verificationUri || !verificationUriComplete || typeof expiresIn !== "number" || typeof interval !== "number") {
31
+ throw new Error("Gateway returned an invalid device-code response.");
32
+ }
33
+ return {
34
+ device_code: deviceCode,
35
+ user_code: userCode,
36
+ verification_uri: verificationUri,
37
+ verification_uri_complete: verificationUriComplete,
38
+ expires_in: expiresIn,
39
+ interval
40
+ };
41
+ }
42
+ function assertDeviceTokenResponse(payload) {
43
+ const accessToken = readString(payload.access_token);
44
+ const tokenType = readString(payload.token_type);
45
+ const scope = readString(payload.scope);
46
+ const tenantId = readString(payload.tenant_id);
47
+ const principalId = readString(payload.principal_id);
48
+ if (!accessToken || tokenType !== "Bearer" || typeof payload.expires_in !== "number" || !scope || !tenantId || !principalId) {
49
+ throw new Error("Gateway returned an invalid device token response.");
50
+ }
51
+ return {
52
+ access_token: accessToken,
53
+ token_type: "Bearer",
54
+ expires_in: payload.expires_in,
55
+ scope,
56
+ tenant_id: tenantId,
57
+ workspace_id: readString(payload.workspace_id),
58
+ principal_id: principalId,
59
+ user: payload.user && typeof payload.user === "object" && !Array.isArray(payload.user) ? payload.user : void 0
60
+ };
61
+ }
62
+ function maybeThrowDeviceError(payload) {
63
+ const error = readString(payload.error);
64
+ throw new DeviceAuthorizationError({
65
+ error: error ?? "invalid_request",
66
+ description: readString(payload.error_description),
67
+ interval: typeof payload.interval === "number" ? payload.interval : void 0
68
+ });
69
+ }
70
+ function createAuthDeviceClient(config = {}) {
71
+ const fetchImpl = config.fetchImpl ?? fetch;
72
+ const baseUrl = authBaseUrl(config);
73
+ async function post(path, body) {
74
+ return fetchImpl(`${baseUrl}${path}`, {
75
+ method: "POST",
76
+ headers: { "content-type": "application/json" },
77
+ body: JSON.stringify(body)
78
+ });
79
+ }
80
+ return {
81
+ async createDeviceCode(input = {}) {
82
+ const response = await post("/api/platform/v1/auth/device/code", {
83
+ client_id: input.clientId ?? "lucern-cli",
84
+ scope: input.scope ?? "graph.read graph.write"
85
+ });
86
+ const payload = await readJson(response);
87
+ if (!response.ok) {
88
+ maybeThrowDeviceError(payload);
89
+ }
90
+ return assertDeviceCodeResponse(payload);
91
+ },
92
+ async pollDeviceToken(deviceCode) {
93
+ const response = await post("/api/platform/v1/auth/device/token", {
94
+ grant_type: "urn:ietf:params:oauth:grant-type:device_code",
95
+ device_code: deviceCode
96
+ });
97
+ const payload = await readJson(response);
98
+ if (!response.ok) {
99
+ maybeThrowDeviceError(payload);
100
+ }
101
+ return assertDeviceTokenResponse(payload);
102
+ }
103
+ };
104
+ }
105
+
106
+ export { DeviceAuthorizationError, createAuthDeviceClient };
107
+ //# sourceMappingURL=authDeviceClient.js.map
108
+ //# sourceMappingURL=authDeviceClient.js.map