@primitive.ai/prim 0.1.0-alpha.124 → 0.1.0-alpha.126
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/README.md +27 -0
- package/dist/{chunk-5KPDY5GF.js → chunk-5D2C6RCH.js} +4 -4
- package/dist/{chunk-3OKVMKK2.js → chunk-6KXQQ7CQ.js} +3 -3
- package/dist/{chunk-EER7VG3P.js → chunk-74DQDWLW.js} +2 -2
- package/dist/{chunk-KMWXI7KO.js → chunk-BFYJLI7V.js} +1 -1
- package/dist/{chunk-TS2NX6YT.js → chunk-C5VBPHOS.js} +9 -8
- package/dist/{chunk-ZMH6GJUG.js → chunk-DT7E3SD5.js} +4 -4
- package/dist/{chunk-6W72SEXC.js → chunk-EZXIKEMA.js} +3 -3
- package/dist/{chunk-6WKJWW6D.js → chunk-FYYHBOOM.js} +2 -2
- package/dist/{chunk-DGZX3MID.js → chunk-JFWJN2ME.js} +3 -3
- package/dist/{chunk-A6YTFBQ4.js → chunk-KKUDAQQZ.js} +7 -8
- package/dist/{chunk-WLVEXOHC.js → chunk-L32WYFJT.js} +1 -1
- package/dist/{chunk-6VJ7C2B5.js → chunk-NBNQI3YJ.js} +2 -2
- package/dist/{chunk-KTXJJE5K.js → chunk-ND6TYHNI.js} +2 -2
- package/dist/{chunk-Q2PVD5W2.js → chunk-NJBN3WXF.js} +37 -5
- package/dist/{chunk-5MH2C5QG.js → chunk-O73J3KQQ.js} +7121 -5513
- package/dist/{chunk-EWV7VIZ3.js → chunk-PPZ56EVJ.js} +1 -1
- package/dist/{chunk-WQFJ5TEG.js → chunk-R6NDP7OF.js} +2 -2
- package/dist/{chunk-5BZWFN62.js → chunk-TI37ME2D.js} +12 -8
- package/dist/{chunk-6PSCGY2A.js → chunk-YP4OXKNX.js} +4 -2
- package/dist/{chunk-QZWLZH6D.js → chunk-ZKXNJB6U.js} +3 -3
- package/dist/daemon/server.js +7128 -5507
- package/dist/hook-runtime/daemon/server.js +7128 -5507
- package/dist/hook-runtime/hooks/post-commit.js +7106 -5496
- package/dist/hook-runtime/hooks/post-rewrite.js +7106 -5496
- package/dist/hook-runtime/hooks/post-tool-use.js +3595 -1977
- package/dist/hook-runtime/hooks/pre-commit.js +17 -7
- package/dist/hook-runtime/hooks/pre-tool-use-worker.js +3796 -2184
- package/dist/hook-runtime/hooks/prim-hook.js +7117 -5502
- package/dist/hook-runtime/hooks/session-end.js +11 -4
- package/dist/hook-runtime/hooks/session-start.js +3584 -1970
- package/dist/hook-runtime/index.js +6376 -4464
- package/dist/hook-runtime/statusline-main.js +11 -4
- package/dist/hooks/post-commit.js +7 -7
- package/dist/hooks/post-rewrite.js +6 -6
- package/dist/hooks/post-tool-use.js +15 -15
- package/dist/hooks/pre-commit.js +4 -4
- package/dist/hooks/pre-tool-use-worker.js +9 -9
- package/dist/hooks/prim-hook.js +16 -16
- package/dist/hooks/session-end.js +4 -4
- package/dist/hooks/session-start.js +11 -11
- package/dist/index.js +9117 -8836
- package/dist/statusline-main.js +11 -4
- package/package.json +1 -1
|
@@ -570,7 +570,11 @@ function parseMachineConfiguration(value) {
|
|
|
570
570
|
"The WorkOS issuer must be an HTTPS origin."
|
|
571
571
|
);
|
|
572
572
|
}
|
|
573
|
-
return {
|
|
573
|
+
return {
|
|
574
|
+
issuer: record.issuer,
|
|
575
|
+
audience: record.audience,
|
|
576
|
+
...record.developer_enrollment === true ? { developerEnrollment: true } : {}
|
|
577
|
+
};
|
|
574
578
|
}
|
|
575
579
|
function machineSignal(signal) {
|
|
576
580
|
return signal ? AbortSignal.any([signal, AbortSignal.timeout(1e4)]) : AbortSignal.timeout(1e4);
|
|
@@ -670,7 +674,7 @@ async function exchangeMachineCredentials(configuration, clientId, clientSecret,
|
|
|
670
674
|
function parseMachineIdentity(value, clientId) {
|
|
671
675
|
const data = machineRecord(value);
|
|
672
676
|
const principal = machineRecord(data.principal);
|
|
673
|
-
if (data.authenticated !== true || data.captureAuthorityKind !== "workos_m2m" || data.organizationBindingVersion !==
|
|
677
|
+
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))) {
|
|
674
678
|
throw new MachineAuthError(
|
|
675
679
|
"machine_identity_rejected",
|
|
676
680
|
"The API did not verify a machine identity.",
|
|
@@ -679,6 +683,7 @@ function parseMachineIdentity(value, clientId) {
|
|
|
679
683
|
}
|
|
680
684
|
return {
|
|
681
685
|
machineId: principal.machineId,
|
|
686
|
+
...data.organizationBindingVersion === 3 ? { authorizedUserId: principal.authorizedUserId } : {},
|
|
682
687
|
clientId,
|
|
683
688
|
displayName: principal.displayName,
|
|
684
689
|
organizationId: data.organizationId,
|
|
@@ -991,6 +996,7 @@ function writeEnvironmentContext(credential, deps) {
|
|
|
991
996
|
organizationId,
|
|
992
997
|
workosOrganizationId,
|
|
993
998
|
displayName,
|
|
999
|
+
authorizedUserId,
|
|
994
1000
|
scopes,
|
|
995
1001
|
expiresAt
|
|
996
1002
|
} = credential;
|
|
@@ -1006,6 +1012,7 @@ function writeEnvironmentContext(credential, deps) {
|
|
|
1006
1012
|
organizationId,
|
|
1007
1013
|
workosOrganizationId,
|
|
1008
1014
|
displayName,
|
|
1015
|
+
authorizedUserId,
|
|
1009
1016
|
scopes,
|
|
1010
1017
|
expiresAt
|
|
1011
1018
|
});
|
|
@@ -1103,7 +1110,7 @@ function parseStoredIdentity(data) {
|
|
|
1103
1110
|
return parseMachineIdentity(
|
|
1104
1111
|
{
|
|
1105
1112
|
authenticated: true,
|
|
1106
|
-
organizationBindingVersion: 2,
|
|
1113
|
+
organizationBindingVersion: data.authorizedUserId ? 3 : 2,
|
|
1107
1114
|
captureAuthorityKind: "workos_m2m",
|
|
1108
1115
|
organizationId: data.organizationId,
|
|
1109
1116
|
workosOrganizationId: data.workosOrganizationId,
|
|
@@ -1211,6 +1218,7 @@ async function loadRecord(profile, deps, signal) {
|
|
|
1211
1218
|
"generation",
|
|
1212
1219
|
"storage",
|
|
1213
1220
|
"machineId",
|
|
1221
|
+
"authorizedUserId",
|
|
1214
1222
|
"clientId",
|
|
1215
1223
|
"organizationId",
|
|
1216
1224
|
"workosOrganizationId"
|
|
@@ -1381,7 +1389,7 @@ async function acquireMachineCredential(options = {}, deps = {}) {
|
|
|
1381
1389
|
return { tokens: tokens2, identity: identity2 };
|
|
1382
1390
|
}
|
|
1383
1391
|
);
|
|
1384
|
-
if (identity.machineId !== profile.machineId || identity.organizationId !== profile.organizationId || identity.workosOrganizationId !== profile.workosOrganizationId)
|
|
1392
|
+
if (identity.machineId !== profile.machineId || identity.authorizedUserId !== profile.authorizedUserId || identity.organizationId !== profile.organizationId || identity.workosOrganizationId !== profile.workosOrganizationId)
|
|
1385
1393
|
throw new MachineAuthError(
|
|
1386
1394
|
"identity_changed",
|
|
1387
1395
|
"Machine identity changed; configure the new identity explicitly.",
|
|
@@ -2136,7 +2144,7 @@ async function machineClient(options = {}, management = false) {
|
|
|
2136
2144
|
throw new HttpError(409, "Machine identity changed; restart the operation.");
|
|
2137
2145
|
}
|
|
2138
2146
|
const current = await acquireMachineCredential({ signal: requestOptions.signal });
|
|
2139
|
-
if (!current || current.generation !== selected.generation || current.machineId !== selected.machineId || current.organizationId !== selected.organizationId)
|
|
2147
|
+
if (!current || current.generation !== selected.generation || current.machineId !== selected.machineId || current.authorizedUserId !== selected.authorizedUserId || current.organizationId !== selected.organizationId)
|
|
2140
2148
|
throw new HttpError(409, "Machine identity changed; restart the operation.");
|
|
2141
2149
|
let response = await fetchWithToken(
|
|
2142
2150
|
method,
|
|
@@ -2151,7 +2159,7 @@ async function machineClient(options = {}, management = false) {
|
|
|
2151
2159
|
force: true,
|
|
2152
2160
|
signal: requestOptions.signal
|
|
2153
2161
|
});
|
|
2154
|
-
if (!renewed || renewed.generation !== selected.generation || renewed.machineId !== selected.machineId || renewed.organizationId !== selected.organizationId) {
|
|
2162
|
+
if (!renewed || renewed.generation !== selected.generation || renewed.machineId !== selected.machineId || renewed.authorizedUserId !== selected.authorizedUserId || renewed.organizationId !== selected.organizationId) {
|
|
2155
2163
|
throw new HttpError(409, "Machine identity changed; restart the operation.");
|
|
2156
2164
|
}
|
|
2157
2165
|
response = await fetchWithToken(
|
|
@@ -2236,7 +2244,9 @@ function resolveDaemonPrincipal(token = resolveAuthCredential()?.token) {
|
|
|
2236
2244
|
if (hasMachineConfiguration()) {
|
|
2237
2245
|
const machine = machineContext();
|
|
2238
2246
|
return machine ? {
|
|
2239
|
-
principalId: sha256(
|
|
2247
|
+
principalId: sha256(
|
|
2248
|
+
`${machine.issuer}\0${machine.clientId}${machine.authorizedUserId ? `\0${machine.authorizedUserId}` : ""}`
|
|
2249
|
+
),
|
|
2240
2250
|
organizationId: machine.workosOrganizationId,
|
|
2241
2251
|
credentialFingerprint: sha256(machine.generation)
|
|
2242
2252
|
} : void 0;
|