@absolutejs/auth 0.57.8 → 0.57.9
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/agents/index.d.ts +1 -1
- package/dist/agents/index.js +66 -35
- package/dist/agents/index.js.map +3 -3
- package/dist/agents/postgresStores.d.ts +586 -1
- package/dist/cli/migrate.js +32 -13
- package/dist/cli/migrate.js.map +3 -3
- package/dist/index.d.ts +1 -1
- package/dist/index.js +66 -35
- package/dist/index.js.map +4 -4
- package/dist/server.js +60 -35
- package/dist/server.js.map +4 -4
- package/package.json +1 -1
package/dist/server.js
CHANGED
|
@@ -34639,23 +34639,28 @@ var portableJsonb = customType({
|
|
|
34639
34639
|
fromDriver: (value) => typeof value === "string" ? JSON.parse(value) : value,
|
|
34640
34640
|
toDriver: (value) => JSON.stringify(value)
|
|
34641
34641
|
});
|
|
34642
|
-
var
|
|
34642
|
+
var bunSqlJsonb = customType({
|
|
34643
|
+
dataType: () => "jsonb",
|
|
34644
|
+
fromDriver: (value) => typeof value === "string" ? JSON.parse(value) : value,
|
|
34645
|
+
toDriver: (value) => value
|
|
34646
|
+
});
|
|
34647
|
+
var createAgentDelegationsTable = (json5) => pgTable("auth_agent_delegations", {
|
|
34643
34648
|
agent_id: varchar("agent_id", { length: ID_LENGTH7 }).notNull(),
|
|
34644
|
-
authorization_details:
|
|
34649
|
+
authorization_details: json5("authorization_details").$type(),
|
|
34645
34650
|
created_at_ms: bigint("created_at_ms", { mode: "number" }).notNull(),
|
|
34646
34651
|
delegation_id: varchar("delegation_id", {
|
|
34647
34652
|
length: ID_LENGTH7
|
|
34648
34653
|
}).primaryKey(),
|
|
34649
34654
|
expires_at_ms: bigint("expires_at_ms", { mode: "number" }),
|
|
34650
34655
|
organization_id: varchar("organization_id", { length: ID_LENGTH7 }),
|
|
34651
|
-
scopes:
|
|
34656
|
+
scopes: json5("scopes").$type().notNull().default([]),
|
|
34652
34657
|
status: varchar("status", { length: STATUS_LENGTH2 }).$type().notNull(),
|
|
34653
34658
|
updated_at_ms: bigint("updated_at_ms", { mode: "number" }).notNull(),
|
|
34654
34659
|
user_id: varchar("user_id", { length: ID_LENGTH7 }).notNull()
|
|
34655
34660
|
});
|
|
34656
|
-
var
|
|
34661
|
+
var createAgentIdentityRegistrationsTable = (json5) => pgTable("auth_agent_identity_registrations", {
|
|
34657
34662
|
agent_id: varchar("agent_id", { length: ID_LENGTH7 }).notNull().unique(),
|
|
34658
|
-
claim_attempt:
|
|
34663
|
+
claim_attempt: json5("claim_attempt").$type(),
|
|
34659
34664
|
claim_attempt_token_hash: varchar("claim_attempt_token_hash", {
|
|
34660
34665
|
length: ID_LENGTH7
|
|
34661
34666
|
}).unique(),
|
|
@@ -34665,8 +34670,12 @@ var agentIdentityRegistrationsTable = pgTable("auth_agent_identity_registrations
|
|
|
34665
34670
|
claim_token_hash: varchar("claim_token_hash", {
|
|
34666
34671
|
length: ID_LENGTH7
|
|
34667
34672
|
}).notNull().unique(),
|
|
34668
|
-
created_at_ms: bigint("created_at_ms", {
|
|
34669
|
-
|
|
34673
|
+
created_at_ms: bigint("created_at_ms", {
|
|
34674
|
+
mode: "number"
|
|
34675
|
+
}).notNull(),
|
|
34676
|
+
expires_at_ms: bigint("expires_at_ms", {
|
|
34677
|
+
mode: "number"
|
|
34678
|
+
}).notNull(),
|
|
34670
34679
|
kind: varchar("kind", { length: 32 }).$type().notNull(),
|
|
34671
34680
|
last_polled_at_ms: bigint("last_polled_at_ms", { mode: "number" }),
|
|
34672
34681
|
login_hint: varchar("login_hint", { length: ID_LENGTH7 }),
|
|
@@ -34674,27 +34683,37 @@ var agentIdentityRegistrationsTable = pgTable("auth_agent_identity_registrations
|
|
|
34674
34683
|
length: ID_LENGTH7
|
|
34675
34684
|
}).primaryKey(),
|
|
34676
34685
|
status: varchar("status", { length: STATUS_LENGTH2 }).$type().notNull(),
|
|
34677
|
-
updated_at_ms: bigint("updated_at_ms", {
|
|
34686
|
+
updated_at_ms: bigint("updated_at_ms", {
|
|
34687
|
+
mode: "number"
|
|
34688
|
+
}).notNull(),
|
|
34678
34689
|
upstream_client_id: varchar("upstream_client_id", {
|
|
34679
34690
|
length: ID_LENGTH7
|
|
34680
34691
|
}),
|
|
34681
34692
|
upstream_issuer: varchar("upstream_issuer", { length: ID_LENGTH7 }),
|
|
34682
|
-
upstream_subject: varchar("upstream_subject", {
|
|
34693
|
+
upstream_subject: varchar("upstream_subject", {
|
|
34694
|
+
length: ID_LENGTH7
|
|
34695
|
+
}),
|
|
34683
34696
|
user_id: varchar("user_id", { length: ID_LENGTH7 }),
|
|
34684
34697
|
version: integer("version").notNull()
|
|
34685
34698
|
}, (table) => [
|
|
34686
34699
|
uniqueIndex("auth_agent_identity_upstream_unique").on(table.upstream_issuer, table.upstream_subject, table.upstream_client_id)
|
|
34687
34700
|
]);
|
|
34688
|
-
var
|
|
34701
|
+
var createAgentRegistrationsTable = (json5) => pgTable("auth_agent_registrations", {
|
|
34689
34702
|
agent_id: varchar("agent_id", { length: ID_LENGTH7 }).primaryKey(),
|
|
34690
|
-
allowed_scopes:
|
|
34703
|
+
allowed_scopes: json5("allowed_scopes").$type().notNull().default([]),
|
|
34691
34704
|
client_id: varchar("client_id", { length: ID_LENGTH7 }).unique(),
|
|
34692
34705
|
created_at_ms: bigint("created_at_ms", { mode: "number" }).notNull(),
|
|
34693
|
-
metadata:
|
|
34706
|
+
metadata: json5("metadata").$type(),
|
|
34694
34707
|
name: varchar("name", { length: NAME_LENGTH }).notNull(),
|
|
34695
34708
|
status: varchar("status", { length: STATUS_LENGTH2 }).$type().notNull(),
|
|
34696
34709
|
updated_at_ms: bigint("updated_at_ms", { mode: "number" }).notNull()
|
|
34697
34710
|
});
|
|
34711
|
+
var agentDelegationsBunSqlTable = createAgentDelegationsTable(bunSqlJsonb);
|
|
34712
|
+
var agentDelegationsTable = createAgentDelegationsTable(portableJsonb);
|
|
34713
|
+
var agentIdentityRegistrationsBunSqlTable = createAgentIdentityRegistrationsTable(bunSqlJsonb);
|
|
34714
|
+
var agentIdentityRegistrationsTable = createAgentIdentityRegistrationsTable(portableJsonb);
|
|
34715
|
+
var agentRegistrationsBunSqlTable = createAgentRegistrationsTable(bunSqlJsonb);
|
|
34716
|
+
var agentRegistrationsTable = createAgentRegistrationsTable(portableJsonb);
|
|
34698
34717
|
var toRegistration = (row) => ({
|
|
34699
34718
|
agentId: row.agent_id,
|
|
34700
34719
|
allowedScopes: row.allowed_scopes,
|
|
@@ -34761,24 +34780,24 @@ var identityRegistrationValues = (registration) => ({
|
|
|
34761
34780
|
var createNeonAgentDelegationStore = (databaseUrl) => createDrizzleAgentDelegationStore(createNeonDatabase(databaseUrl));
|
|
34762
34781
|
var createNeonAgentIdentityRegistrationStore = (databaseUrl) => createPostgresAgentIdentityRegistrationStore(createNeonDatabase(databaseUrl));
|
|
34763
34782
|
var createNeonAgentRegistrationStore = (databaseUrl) => createPostgresAgentRegistrationStore(createNeonDatabase(databaseUrl));
|
|
34764
|
-
var
|
|
34783
|
+
var createDrizzleAgentDelegationStoreFor = (db, table) => ({
|
|
34765
34784
|
findActiveDelegation: async ({
|
|
34766
34785
|
agentId,
|
|
34767
34786
|
now = Date.now(),
|
|
34768
34787
|
organizationId,
|
|
34769
34788
|
userId
|
|
34770
34789
|
}) => {
|
|
34771
|
-
const organizationCondition = organizationId === undefined ? isNull(
|
|
34772
|
-
const [row] = await db.select().from(
|
|
34790
|
+
const organizationCondition = organizationId === undefined ? isNull(table.organization_id) : eq(table.organization_id, organizationId);
|
|
34791
|
+
const [row] = await db.select().from(table).where(and(eq(table.agent_id, agentId), eq(table.user_id, userId), organizationCondition, eq(table.status, "active"), or(isNull(table.expires_at_ms), gt(table.expires_at_ms, now)))).orderBy(desc(table.updated_at_ms)).limit(1);
|
|
34773
34792
|
return row === undefined ? undefined : toDelegation(row);
|
|
34774
34793
|
},
|
|
34775
34794
|
findByDelegationId: async (delegationId) => {
|
|
34776
|
-
const [row] = await db.select().from(
|
|
34795
|
+
const [row] = await db.select().from(table).where(eq(table.delegation_id, delegationId)).limit(1);
|
|
34777
34796
|
return row === undefined ? undefined : toDelegation(row);
|
|
34778
34797
|
},
|
|
34779
34798
|
listDelegations: async (agentId) => {
|
|
34780
|
-
const base = db.select().from(
|
|
34781
|
-
const rows = await (agentId === undefined ? base.orderBy(desc(
|
|
34799
|
+
const base = db.select().from(table);
|
|
34800
|
+
const rows = await (agentId === undefined ? base.orderBy(desc(table.created_at_ms)) : base.where(eq(table.agent_id, agentId)).orderBy(desc(table.created_at_ms)));
|
|
34782
34801
|
return rows.map(toDelegation);
|
|
34783
34802
|
},
|
|
34784
34803
|
saveDelegation: async (delegation) => {
|
|
@@ -34794,36 +34813,38 @@ var createDrizzleAgentDelegationStore = (db) => ({
|
|
|
34794
34813
|
updated_at_ms: delegation.updatedAt,
|
|
34795
34814
|
user_id: delegation.userId
|
|
34796
34815
|
};
|
|
34797
|
-
await db.insert(
|
|
34816
|
+
await db.insert(table).values(values).onConflictDoUpdate({
|
|
34798
34817
|
set: values,
|
|
34799
|
-
target:
|
|
34818
|
+
target: table.delegation_id
|
|
34800
34819
|
});
|
|
34801
34820
|
}
|
|
34802
34821
|
});
|
|
34822
|
+
var createDrizzleAgentDelegationStore = (db) => createDrizzleAgentDelegationStoreFor(db, agentDelegationsTable);
|
|
34823
|
+
var createBunSqlDrizzleAgentDelegationStore = (db) => createDrizzleAgentDelegationStoreFor(db, agentDelegationsBunSqlTable);
|
|
34803
34824
|
var createPostgresAgentDelegationStore = createDrizzleAgentDelegationStore;
|
|
34804
|
-
var
|
|
34825
|
+
var createPostgresAgentIdentityRegistrationStoreFor = (db, table) => ({
|
|
34805
34826
|
create: async (registration) => {
|
|
34806
|
-
const rows = await db.insert(
|
|
34827
|
+
const rows = await db.insert(table).values(identityRegistrationValues(registration)).onConflictDoNothing().returning({ id: table.registration_id });
|
|
34807
34828
|
return rows.length === 1;
|
|
34808
34829
|
},
|
|
34809
34830
|
findByAgentId: async (agentId) => {
|
|
34810
|
-
const [row] = await db.select().from(
|
|
34831
|
+
const [row] = await db.select().from(table).where(eq(table.agent_id, agentId)).limit(1);
|
|
34811
34832
|
return row === undefined ? undefined : toIdentityRegistration(row);
|
|
34812
34833
|
},
|
|
34813
34834
|
findByAttemptTokenHash: async (attemptTokenHash) => {
|
|
34814
|
-
const [row] = await db.select().from(
|
|
34835
|
+
const [row] = await db.select().from(table).where(eq(table.claim_attempt_token_hash, attemptTokenHash)).limit(1);
|
|
34815
34836
|
return row === undefined ? undefined : toIdentityRegistration(row);
|
|
34816
34837
|
},
|
|
34817
34838
|
findByClaimTokenHash: async (claimTokenHash) => {
|
|
34818
|
-
const [row] = await db.select().from(
|
|
34839
|
+
const [row] = await db.select().from(table).where(eq(table.claim_token_hash, claimTokenHash)).limit(1);
|
|
34819
34840
|
return row === undefined ? undefined : toIdentityRegistration(row);
|
|
34820
34841
|
},
|
|
34821
34842
|
findByRegistrationId: async (registrationId) => {
|
|
34822
|
-
const [row] = await db.select().from(
|
|
34843
|
+
const [row] = await db.select().from(table).where(eq(table.registration_id, registrationId)).limit(1);
|
|
34823
34844
|
return row === undefined ? undefined : toIdentityRegistration(row);
|
|
34824
34845
|
},
|
|
34825
34846
|
findByUpstreamIdentity: async ({ clientId, issuer, subject }) => {
|
|
34826
|
-
const [row] = await db.select().from(
|
|
34847
|
+
const [row] = await db.select().from(table).where(and(eq(table.upstream_client_id, clientId), eq(table.upstream_issuer, issuer), eq(table.upstream_subject, subject))).limit(1);
|
|
34827
34848
|
return row === undefined ? undefined : toIdentityRegistration(row);
|
|
34828
34849
|
},
|
|
34829
34850
|
replace: async (registration, expectedVersion) => {
|
|
@@ -34832,21 +34853,23 @@ var createPostgresAgentIdentityRegistrationStore = (db) => ({
|
|
|
34832
34853
|
version: expectedVersion + 1
|
|
34833
34854
|
};
|
|
34834
34855
|
const values = identityRegistrationValues(next);
|
|
34835
|
-
const rows = await db.update(
|
|
34856
|
+
const rows = await db.update(table).set(values).where(and(eq(table.registration_id, registration.registrationId), eq(table.version, expectedVersion))).returning({ id: table.registration_id });
|
|
34836
34857
|
return rows.length === 1;
|
|
34837
34858
|
}
|
|
34838
34859
|
});
|
|
34839
|
-
var
|
|
34860
|
+
var createBunSqlDrizzleAgentIdentityRegistrationStore = (db) => createPostgresAgentIdentityRegistrationStoreFor(db, agentIdentityRegistrationsBunSqlTable);
|
|
34861
|
+
var createPostgresAgentIdentityRegistrationStore = (db) => createPostgresAgentIdentityRegistrationStoreFor(db, agentIdentityRegistrationsTable);
|
|
34862
|
+
var createPostgresAgentRegistrationStoreFor = (db, table) => ({
|
|
34840
34863
|
findByAgentId: async (agentId) => {
|
|
34841
|
-
const [row] = await db.select().from(
|
|
34864
|
+
const [row] = await db.select().from(table).where(eq(table.agent_id, agentId)).limit(1);
|
|
34842
34865
|
return row === undefined ? undefined : toRegistration(row);
|
|
34843
34866
|
},
|
|
34844
34867
|
findByClientId: async (clientId) => {
|
|
34845
|
-
const [row] = await db.select().from(
|
|
34868
|
+
const [row] = await db.select().from(table).where(eq(table.client_id, clientId)).limit(1);
|
|
34846
34869
|
return row === undefined ? undefined : toRegistration(row);
|
|
34847
34870
|
},
|
|
34848
34871
|
listRegistrations: async () => {
|
|
34849
|
-
const rows = await db.select().from(
|
|
34872
|
+
const rows = await db.select().from(table).orderBy(desc(table.created_at_ms));
|
|
34850
34873
|
return rows.map(toRegistration);
|
|
34851
34874
|
},
|
|
34852
34875
|
saveRegistration: async (registration) => {
|
|
@@ -34860,12 +34883,14 @@ var createPostgresAgentRegistrationStore = (db) => ({
|
|
|
34860
34883
|
status: registration.status,
|
|
34861
34884
|
updated_at_ms: registration.updatedAt
|
|
34862
34885
|
};
|
|
34863
|
-
await db.insert(
|
|
34886
|
+
await db.insert(table).values(values).onConflictDoUpdate({
|
|
34864
34887
|
set: values,
|
|
34865
|
-
target:
|
|
34888
|
+
target: table.agent_id
|
|
34866
34889
|
});
|
|
34867
34890
|
}
|
|
34868
34891
|
});
|
|
34892
|
+
var createBunSqlDrizzleAgentRegistrationStore = (db) => createPostgresAgentRegistrationStoreFor(db, agentRegistrationsBunSqlTable);
|
|
34893
|
+
var createPostgresAgentRegistrationStore = (db) => createPostgresAgentRegistrationStoreFor(db, agentRegistrationsTable);
|
|
34869
34894
|
// src/apikeys/inMemoryStores.ts
|
|
34870
34895
|
var createInMemoryAccessTokenStore = () => {
|
|
34871
34896
|
const tokens = new Map;
|
|
@@ -38258,5 +38283,5 @@ export {
|
|
|
38258
38283
|
auth2 as auth
|
|
38259
38284
|
};
|
|
38260
38285
|
|
|
38261
|
-
//# debugId=
|
|
38286
|
+
//# debugId=8E94D3B40F6913D564756E2164756E21
|
|
38262
38287
|
//# sourceMappingURL=server.js.map
|