@odla-ai/chapter 0.13.0 → 0.14.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.
package/dist/index.cjs CHANGED
@@ -36,6 +36,7 @@ __export(index_exports, {
36
36
  clampArray: () => clampArray,
37
37
  clerkGetUser: () => clerkGetUser,
38
38
  clerkGetUserByEmail: () => clerkGetUserByEmail,
39
+ clerkIntegration: () => clerkIntegration,
39
40
  clerkInviteRequest: () => clerkInviteRequest,
40
41
  clerkListUsers: () => clerkListUsers,
41
42
  clerkSetRole: () => clerkSetRole,
@@ -1023,6 +1024,72 @@ async function clerkSetRole(secretKey, id2, role, fetchImpl = fetch) {
1023
1024
  return res.ok;
1024
1025
  }
1025
1026
 
1027
+ // src/clerk-integration.ts
1028
+ var clerkIntegration = {
1029
+ id: "clerk",
1030
+ title: "Clerk end-user auth",
1031
+ npm: "@odla-ai/chapter",
1032
+ settings: [
1033
+ {
1034
+ key: "publishableKey",
1035
+ description: "Clerk publishable key (pk_*). Public by design; served to the SPA (loads clerk-js from Clerk's CDN via @odla-ai/auth-clerk).",
1036
+ public: true,
1037
+ pattern: "pk_",
1038
+ perEnv: true,
1039
+ source: "apps-registry auth[env].publishableKey (from odla.config.mjs auth.clerk.<env>)"
1040
+ }
1041
+ ],
1042
+ secrets: [
1043
+ {
1044
+ key: "CLERK_WEBHOOK_SECRET",
1045
+ description: "Svix signing secret for Clerk user webhooks \u2014 verifies $users sync events.",
1046
+ pattern: "whsec_",
1047
+ mode: "full",
1048
+ vault: true
1049
+ },
1050
+ {
1051
+ key: "clerk_secret_key",
1052
+ description: "Clerk backend key (sk_*) \u2014 powers the odla->Clerk writes (account create, role + profile via public_metadata) and lets odla-db resolve user email/name via the Clerk API.",
1053
+ pattern: "sk_",
1054
+ mode: "full",
1055
+ vault: true
1056
+ }
1057
+ ],
1058
+ syncs: [
1059
+ {
1060
+ engine: "@odla-ai/db $users (Clerk webhook -> tenant graph)",
1061
+ direction: "provider->odla",
1062
+ entity: "$users",
1063
+ // Matches the webhook mapper: the mirror carries id + primary email + name + avatar.
1064
+ fields: ["id", "email", "name", "imageUrl"],
1065
+ webhook: "whsec_ (svix-signed)",
1066
+ onDelete: "tombstone (never row-delete)"
1067
+ },
1068
+ {
1069
+ engine: "@odla-ai/chapter clerk.ts (Clerk Backend API via vault clerk_secret_key)",
1070
+ direction: "odla->provider",
1071
+ entity: "clerk user",
1072
+ // Separate merge-PATCHes so a role write never clobbers a profile write.
1073
+ fields: ["public_metadata.role", "public_metadata.profile"],
1074
+ onDelete: "n/a (writes only)"
1075
+ }
1076
+ ],
1077
+ provision: {
1078
+ human: [
1079
+ "Run `npx clerk auth login` \u2014 the one interactive step; the agent then creates + configures the Clerk app with the Clerk CLI (no pk_ to hand-paste).",
1080
+ 'For auth mode "full": create the Clerk user-sync webhook and store its whsec_, plus the sk_ as clerk_secret_key, in the tenant vault (Studio, write-only).'
1081
+ ],
1082
+ cli: [
1083
+ "Clerk CLI (`npx clerk apps create/link/config patch`) creates + configures the instance and pulls the pk_.",
1084
+ "odla `provision` records it: setAuth(env, publishableKey) -> apps-registry (issuer/JWKS derived from the key)."
1085
+ ],
1086
+ doctor: [
1087
+ "registry auth[env] present when the app mounts <SignIn>?",
1088
+ 'auth mode "full" => whsec_ and clerk_secret_key present in the tenant vault?'
1089
+ ]
1090
+ }
1091
+ };
1092
+
1026
1093
  // src/session.ts
1027
1094
  function applicationSummary(app) {
1028
1095
  return {