@primitive.ai/prim 0.1.0-alpha.124 → 0.1.0-alpha.125

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 (44) hide show
  1. package/README.md +27 -0
  2. package/dist/{chunk-WQFJ5TEG.js → chunk-2BEUR3DU.js} +2 -2
  3. package/dist/{chunk-3OKVMKK2.js → chunk-6KXQQ7CQ.js} +3 -3
  4. package/dist/{chunk-TS2NX6YT.js → chunk-6OPSSJHO.js} +5 -5
  5. package/dist/{chunk-EER7VG3P.js → chunk-74DQDWLW.js} +2 -2
  6. package/dist/{chunk-KMWXI7KO.js → chunk-BFYJLI7V.js} +1 -1
  7. package/dist/{chunk-ZMH6GJUG.js → chunk-DT7E3SD5.js} +4 -4
  8. package/dist/{chunk-6W72SEXC.js → chunk-EZXIKEMA.js} +3 -3
  9. package/dist/{chunk-6WKJWW6D.js → chunk-FYYHBOOM.js} +2 -2
  10. package/dist/{chunk-A6YTFBQ4.js → chunk-HPA7RGSZ.js} +3 -3
  11. package/dist/{chunk-DGZX3MID.js → chunk-JFWJN2ME.js} +3 -3
  12. package/dist/{chunk-WLVEXOHC.js → chunk-L32WYFJT.js} +1 -1
  13. package/dist/{chunk-6VJ7C2B5.js → chunk-NBNQI3YJ.js} +2 -2
  14. package/dist/{chunk-KTXJJE5K.js → chunk-ND6TYHNI.js} +2 -2
  15. package/dist/{chunk-Q2PVD5W2.js → chunk-NJBN3WXF.js} +37 -5
  16. package/dist/{chunk-5MH2C5QG.js → chunk-O73J3KQQ.js} +7121 -5513
  17. package/dist/{chunk-EWV7VIZ3.js → chunk-PPZ56EVJ.js} +1 -1
  18. package/dist/{chunk-5KPDY5GF.js → chunk-R35M4RCY.js} +4 -4
  19. package/dist/{chunk-5BZWFN62.js → chunk-TI37ME2D.js} +12 -8
  20. package/dist/{chunk-6PSCGY2A.js → chunk-YP4OXKNX.js} +4 -2
  21. package/dist/{chunk-QZWLZH6D.js → chunk-ZKXNJB6U.js} +3 -3
  22. package/dist/daemon/server.js +7128 -5507
  23. package/dist/hook-runtime/daemon/server.js +7128 -5507
  24. package/dist/hook-runtime/hooks/post-commit.js +7106 -5496
  25. package/dist/hook-runtime/hooks/post-rewrite.js +7106 -5496
  26. package/dist/hook-runtime/hooks/post-tool-use.js +3595 -1977
  27. package/dist/hook-runtime/hooks/pre-commit.js +17 -7
  28. package/dist/hook-runtime/hooks/pre-tool-use-worker.js +7112 -5500
  29. package/dist/hook-runtime/hooks/prim-hook.js +7117 -5502
  30. package/dist/hook-runtime/hooks/session-end.js +11 -4
  31. package/dist/hook-runtime/hooks/session-start.js +3584 -1970
  32. package/dist/hook-runtime/index.js +6376 -4464
  33. package/dist/hook-runtime/statusline-main.js +11 -4
  34. package/dist/hooks/post-commit.js +7 -7
  35. package/dist/hooks/post-rewrite.js +6 -6
  36. package/dist/hooks/post-tool-use.js +15 -15
  37. package/dist/hooks/pre-commit.js +4 -4
  38. package/dist/hooks/pre-tool-use-worker.js +9 -9
  39. package/dist/hooks/prim-hook.js +16 -16
  40. package/dist/hooks/session-end.js +4 -4
  41. package/dist/hooks/session-start.js +11 -11
  42. package/dist/index.js +9117 -8836
  43. package/dist/statusline-main.js +11 -4
  44. package/package.json +1 -1
@@ -202,12 +202,16 @@ function parseMachineConfiguration(value) {
202
202
  "The WorkOS issuer must be an HTTPS origin."
203
203
  );
204
204
  }
205
- return { issuer: record.issuer, audience: record.audience };
205
+ return {
206
+ issuer: record.issuer,
207
+ audience: record.audience,
208
+ ...record.developer_enrollment === true ? { developerEnrollment: true } : {}
209
+ };
206
210
  }
207
211
  function parseMachineIdentity(value, clientId) {
208
212
  const data = machineRecord(value);
209
213
  const principal = machineRecord(data.principal);
210
- if (data.authenticated !== true || data.captureAuthorityKind !== "workos_m2m" || data.organizationBindingVersion !== 2 || principal.kind !== "machine" || principal.clientId !== clientId || !machineString(principal.machineId, 256) || !machineString(principal.displayName, 256) || !machineString(data.organizationId, 256) || !machineString(data.workosOrganizationId, 256) || !Array.isArray(principal.scopes) || !principal.scopes.every((scope) => machineString(scope, 128))) {
214
+ if (data.authenticated !== true || data.captureAuthorityKind !== "workos_m2m" || ![2, 3].includes(data.organizationBindingVersion) || (data.organizationBindingVersion === 3 ? !machineString(principal.authorizedUserId, 256) : principal.authorizedUserId !== void 0) || principal.kind !== "machine" || principal.clientId !== clientId || !machineString(principal.machineId, 256) || !machineString(principal.displayName, 256) || !machineString(data.organizationId, 256) || !machineString(data.workosOrganizationId, 256) || !Array.isArray(principal.scopes) || !principal.scopes.every((scope) => machineString(scope, 128))) {
211
215
  throw new MachineAuthError(
212
216
  "machine_identity_rejected",
213
217
  "The API did not verify a machine identity.",
@@ -216,6 +220,7 @@ function parseMachineIdentity(value, clientId) {
216
220
  }
217
221
  return {
218
222
  machineId: principal.machineId,
223
+ ...data.organizationBindingVersion === 3 ? { authorizedUserId: principal.authorizedUserId } : {},
219
224
  clientId,
220
225
  displayName: principal.displayName,
221
226
  organizationId: data.organizationId,
@@ -327,7 +332,7 @@ function parseStoredIdentity(data) {
327
332
  return parseMachineIdentity(
328
333
  {
329
334
  authenticated: true,
330
- organizationBindingVersion: 2,
335
+ organizationBindingVersion: data.authorizedUserId ? 3 : 2,
331
336
  captureAuthorityKind: "workos_m2m",
332
337
  organizationId: data.organizationId,
333
338
  workosOrganizationId: data.workosOrganizationId,
@@ -560,7 +565,9 @@ function resolveDaemonPrincipal(token = resolveAuthCredential()?.token) {
560
565
  if (hasMachineConfiguration()) {
561
566
  const machine = machineContext();
562
567
  return machine ? {
563
- principalId: sha256(`${machine.issuer}\0${machine.clientId}`),
568
+ principalId: sha256(
569
+ `${machine.issuer}\0${machine.clientId}${machine.authorizedUserId ? `\0${machine.authorizedUserId}` : ""}`
570
+ ),
564
571
  organizationId: machine.workosOrganizationId,
565
572
  credentialFingerprint: sha256(machine.generation)
566
573
  } : void 0;