@yielded/auth-persistence-drizzle 0.1.0-beta.12 → 0.1.0-beta.14

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/D1.d.mts CHANGED
@@ -82,8 +82,6 @@ export declare const makeOAuthConnectedServices: <S extends AnySQLiteTable<{
82
82
  readonly _tag: "Cancelled";
83
83
  } | {
84
84
  readonly _tag: "Ambiguous";
85
- } | {
86
- readonly _tag: "Conflict";
87
85
  } | {
88
86
  readonly _tag: "Connected";
89
87
  readonly grant: {
@@ -153,6 +151,8 @@ export declare const makeOAuthConnectedServices: <S extends AnySQLiteTable<{
153
151
  readonly ciphertext: import("effect/Redacted").Redacted<string>;
154
152
  };
155
153
  };
154
+ } | {
155
+ readonly _tag: "Conflict";
156
156
  } | {
157
157
  readonly _tag: "Busy";
158
158
  }, A>) => Effect.Effect<import("@yielded/auth/Hooks").PreparedCommit<A>, import("@yielded/auth/OAuth").OAuthUnavailable, never>;
@@ -428,8 +428,6 @@ export declare const makeOAuthConnectedServices: <S extends AnySQLiteTable<{
428
428
  readonly _tag: "Cancelled";
429
429
  } | {
430
430
  readonly _tag: "Ambiguous";
431
- } | {
432
- readonly _tag: "Conflict";
433
431
  } | {
434
432
  readonly _tag: "Connected";
435
433
  readonly grant: {
@@ -499,6 +497,8 @@ export declare const makeOAuthConnectedServices: <S extends AnySQLiteTable<{
499
497
  readonly ciphertext: import("effect/Redacted").Redacted<string>;
500
498
  };
501
499
  };
500
+ } | {
501
+ readonly _tag: "Conflict";
502
502
  } | {
503
503
  readonly _tag: "Busy";
504
504
  }, A>) => Effect.Effect<import("@yielded/auth/Hooks").PreparedCommit<A>, import("@yielded/auth/OAuth").OAuthUnavailable, never>;
package/dist/Libsql.d.mts CHANGED
@@ -350,6 +350,8 @@ export declare const makeOAuthAccountsServices: <S extends AnySQLiteTable<{
350
350
  readonly flow: import("@yielded/auth/OAuth").OAuthLinkPendingFlow;
351
351
  readonly authorization: import("@yielded/auth/OAuth").OAuthActionAuthorization;
352
352
  }, prepare: import("@yielded/auth/OAuth").PrepareOAuthCommit<{
353
+ readonly _tag: "Rejected";
354
+ } | {
353
355
  readonly _tag: "Issued";
354
356
  readonly flow: {
355
357
  readonly context: {
@@ -405,8 +407,6 @@ export declare const makeOAuthAccountsServices: <S extends AnySQLiteTable<{
405
407
  };
406
408
  readonly retentionUntilMillis: number;
407
409
  };
408
- } | {
409
- readonly _tag: "Rejected";
410
410
  }, A>) => Effect.Effect<import("@yielded/auth/Hooks").PreparedCommit<A>, import("@yielded/auth/OAuth").OAuthUnavailable>;
411
411
  readonly preflight: (input: import("@yielded/auth/OAuth").OAuthLinkAccess) => Effect.Effect<import("@yielded/auth/OAuth").OAuthLinkPendingFlow | undefined, import("@yielded/auth/OAuth").OAuthUnavailable>;
412
412
  readonly claim: <A>(input: {
@@ -490,6 +490,8 @@ export declare const makeOAuthAccountsServices: <S extends AnySQLiteTable<{
490
490
  readonly _tag: "Cancelled";
491
491
  } | {
492
492
  readonly _tag: "Ambiguous";
493
+ } | {
494
+ readonly _tag: "Conflict";
493
495
  } | {
494
496
  readonly _tag: "Linked";
495
497
  readonly credential: {
@@ -511,8 +513,6 @@ export declare const makeOAuthAccountsServices: <S extends AnySQLiteTable<{
511
513
  };
512
514
  };
513
515
  readonly changed: boolean;
514
- } | {
515
- readonly _tag: "Conflict";
516
516
  }, A>) => Effect.Effect<import("@yielded/auth/Hooks").PreparedCommit<A>, import("@yielded/auth/OAuth").OAuthUnavailable>;
517
517
  readonly inspectUnlink: (input: {
518
518
  readonly moduleId: string & import("effect/Brand").Brand<"effect-auth/OAuthModuleId">;
@@ -863,8 +863,6 @@ export declare const makeOAuthAccountsServices: <S extends AnySQLiteTable<{
863
863
  readonly _tag: "Cancelled";
864
864
  } | {
865
865
  readonly _tag: "Ambiguous";
866
- } | {
867
- readonly _tag: "Conflict";
868
866
  } | {
869
867
  readonly _tag: "Connected";
870
868
  readonly grant: {
@@ -934,6 +932,8 @@ export declare const makeOAuthAccountsServices: <S extends AnySQLiteTable<{
934
932
  readonly ciphertext: import("effect/Redacted").Redacted<string>;
935
933
  };
936
934
  };
935
+ } | {
936
+ readonly _tag: "Conflict";
937
937
  } | {
938
938
  readonly _tag: "Busy";
939
939
  }, A>) => Effect.Effect<import("@yielded/auth/Hooks").PreparedCommit<A>, import("@yielded/auth/OAuth").OAuthUnavailable, never>;
@@ -1209,8 +1209,6 @@ export declare const makeOAuthAccountsServices: <S extends AnySQLiteTable<{
1209
1209
  readonly _tag: "Cancelled";
1210
1210
  } | {
1211
1211
  readonly _tag: "Ambiguous";
1212
- } | {
1213
- readonly _tag: "Conflict";
1214
1212
  } | {
1215
1213
  readonly _tag: "Connected";
1216
1214
  readonly grant: {
@@ -1280,6 +1278,8 @@ export declare const makeOAuthAccountsServices: <S extends AnySQLiteTable<{
1280
1278
  readonly ciphertext: import("effect/Redacted").Redacted<string>;
1281
1279
  };
1282
1280
  };
1281
+ } | {
1282
+ readonly _tag: "Conflict";
1283
1283
  } | {
1284
1284
  readonly _tag: "Busy";
1285
1285
  }, A>) => Effect.Effect<import("@yielded/auth/Hooks").PreparedCommit<A>, import("@yielded/auth/OAuth").OAuthUnavailable, never>;
package/dist/Mysql2.d.mts CHANGED
@@ -65,6 +65,8 @@ export declare const makeOAuthAccountsServices: <S extends AnyMySqlTable<{
65
65
  readonly flow: import("@yielded/auth/OAuth").OAuthLinkPendingFlow;
66
66
  readonly authorization: import("@yielded/auth/OAuth").OAuthActionAuthorization;
67
67
  }, prepare: import("@yielded/auth/OAuth").PrepareOAuthCommit<{
68
+ readonly _tag: "Rejected";
69
+ } | {
68
70
  readonly _tag: "Issued";
69
71
  readonly flow: {
70
72
  readonly context: {
@@ -120,8 +122,6 @@ export declare const makeOAuthAccountsServices: <S extends AnyMySqlTable<{
120
122
  };
121
123
  readonly retentionUntilMillis: number;
122
124
  };
123
- } | {
124
- readonly _tag: "Rejected";
125
125
  }, A>) => import("effect/Effect").Effect<import("@yielded/auth/Hooks").PreparedCommit<A>, import("@yielded/auth/OAuth").OAuthUnavailable>;
126
126
  readonly preflight: (input: import("@yielded/auth/OAuth").OAuthLinkAccess) => import("effect/Effect").Effect<import("@yielded/auth/OAuth").OAuthLinkPendingFlow | undefined, import("@yielded/auth/OAuth").OAuthUnavailable>;
127
127
  readonly claim: <A>(input: {
@@ -205,6 +205,8 @@ export declare const makeOAuthAccountsServices: <S extends AnyMySqlTable<{
205
205
  readonly _tag: "Cancelled";
206
206
  } | {
207
207
  readonly _tag: "Ambiguous";
208
+ } | {
209
+ readonly _tag: "Conflict";
208
210
  } | {
209
211
  readonly _tag: "Linked";
210
212
  readonly credential: {
@@ -226,8 +228,6 @@ export declare const makeOAuthAccountsServices: <S extends AnyMySqlTable<{
226
228
  };
227
229
  };
228
230
  readonly changed: boolean;
229
- } | {
230
- readonly _tag: "Conflict";
231
231
  }, A>) => import("effect/Effect").Effect<import("@yielded/auth/Hooks").PreparedCommit<A>, import("@yielded/auth/OAuth").OAuthUnavailable>;
232
232
  readonly inspectUnlink: (input: {
233
233
  readonly moduleId: string & import("effect/Brand").Brand<"effect-auth/OAuthModuleId">;
@@ -578,8 +578,6 @@ export declare const makeOAuthAccountsServices: <S extends AnyMySqlTable<{
578
578
  readonly _tag: "Cancelled";
579
579
  } | {
580
580
  readonly _tag: "Ambiguous";
581
- } | {
582
- readonly _tag: "Conflict";
583
581
  } | {
584
582
  readonly _tag: "Connected";
585
583
  readonly grant: {
@@ -649,6 +647,8 @@ export declare const makeOAuthAccountsServices: <S extends AnyMySqlTable<{
649
647
  readonly ciphertext: import("effect/Redacted").Redacted<string>;
650
648
  };
651
649
  };
650
+ } | {
651
+ readonly _tag: "Conflict";
652
652
  } | {
653
653
  readonly _tag: "Busy";
654
654
  }, A>) => import("effect/Effect").Effect<import("@yielded/auth/Hooks").PreparedCommit<A>, import("@yielded/auth/OAuth").OAuthUnavailable, never>;
@@ -924,8 +924,6 @@ export declare const makeOAuthAccountsServices: <S extends AnyMySqlTable<{
924
924
  readonly _tag: "Cancelled";
925
925
  } | {
926
926
  readonly _tag: "Ambiguous";
927
- } | {
928
- readonly _tag: "Conflict";
929
927
  } | {
930
928
  readonly _tag: "Connected";
931
929
  readonly grant: {
@@ -995,6 +993,8 @@ export declare const makeOAuthAccountsServices: <S extends AnyMySqlTable<{
995
993
  readonly ciphertext: import("effect/Redacted").Redacted<string>;
996
994
  };
997
995
  };
996
+ } | {
997
+ readonly _tag: "Conflict";
998
998
  } | {
999
999
  readonly _tag: "Busy";
1000
1000
  }, A>) => import("effect/Effect").Effect<import("@yielded/auth/Hooks").PreparedCommit<A>, import("@yielded/auth/OAuth").OAuthUnavailable, never>;
@@ -369,6 +369,8 @@ export declare const makeOAuthAccountsServices: <S extends AnySQLiteTable<{
369
369
  readonly flow: import("@yielded/auth/OAuth").OAuthLinkPendingFlow;
370
370
  readonly authorization: import("@yielded/auth/OAuth").OAuthActionAuthorization;
371
371
  }, prepare: import("@yielded/auth/OAuth").PrepareOAuthCommit<{
372
+ readonly _tag: "Rejected";
373
+ } | {
372
374
  readonly _tag: "Issued";
373
375
  readonly flow: {
374
376
  readonly context: {
@@ -424,8 +426,6 @@ export declare const makeOAuthAccountsServices: <S extends AnySQLiteTable<{
424
426
  };
425
427
  readonly retentionUntilMillis: number;
426
428
  };
427
- } | {
428
- readonly _tag: "Rejected";
429
429
  }, A>) => Effect.Effect<import("@yielded/auth/Hooks").PreparedCommit<A>, import("@yielded/auth/OAuth").OAuthUnavailable>;
430
430
  readonly preflight: (input: import("@yielded/auth/OAuth").OAuthLinkAccess) => Effect.Effect<import("@yielded/auth/OAuth").OAuthLinkPendingFlow | undefined, import("@yielded/auth/OAuth").OAuthUnavailable>;
431
431
  readonly claim: <A>(input: {
@@ -509,6 +509,8 @@ export declare const makeOAuthAccountsServices: <S extends AnySQLiteTable<{
509
509
  readonly _tag: "Cancelled";
510
510
  } | {
511
511
  readonly _tag: "Ambiguous";
512
+ } | {
513
+ readonly _tag: "Conflict";
512
514
  } | {
513
515
  readonly _tag: "Linked";
514
516
  readonly credential: {
@@ -530,8 +532,6 @@ export declare const makeOAuthAccountsServices: <S extends AnySQLiteTable<{
530
532
  };
531
533
  };
532
534
  readonly changed: boolean;
533
- } | {
534
- readonly _tag: "Conflict";
535
535
  }, A>) => Effect.Effect<import("@yielded/auth/Hooks").PreparedCommit<A>, import("@yielded/auth/OAuth").OAuthUnavailable>;
536
536
  readonly inspectUnlink: (input: {
537
537
  readonly moduleId: string & import("effect/Brand").Brand<"effect-auth/OAuthModuleId">;
@@ -882,8 +882,6 @@ export declare const makeOAuthAccountsServices: <S extends AnySQLiteTable<{
882
882
  readonly _tag: "Cancelled";
883
883
  } | {
884
884
  readonly _tag: "Ambiguous";
885
- } | {
886
- readonly _tag: "Conflict";
887
885
  } | {
888
886
  readonly _tag: "Connected";
889
887
  readonly grant: {
@@ -953,6 +951,8 @@ export declare const makeOAuthAccountsServices: <S extends AnySQLiteTable<{
953
951
  readonly ciphertext: import("effect/Redacted").Redacted<string>;
954
952
  };
955
953
  };
954
+ } | {
955
+ readonly _tag: "Conflict";
956
956
  } | {
957
957
  readonly _tag: "Busy";
958
958
  }, A>) => Effect.Effect<import("@yielded/auth/Hooks").PreparedCommit<A>, import("@yielded/auth/OAuth").OAuthUnavailable, never>;
@@ -1228,8 +1228,6 @@ export declare const makeOAuthAccountsServices: <S extends AnySQLiteTable<{
1228
1228
  readonly _tag: "Cancelled";
1229
1229
  } | {
1230
1230
  readonly _tag: "Ambiguous";
1231
- } | {
1232
- readonly _tag: "Conflict";
1233
1231
  } | {
1234
1232
  readonly _tag: "Connected";
1235
1233
  readonly grant: {
@@ -1299,6 +1297,8 @@ export declare const makeOAuthAccountsServices: <S extends AnySQLiteTable<{
1299
1297
  readonly ciphertext: import("effect/Redacted").Redacted<string>;
1300
1298
  };
1301
1299
  };
1300
+ } | {
1301
+ readonly _tag: "Conflict";
1302
1302
  } | {
1303
1303
  readonly _tag: "Busy";
1304
1304
  }, A>) => Effect.Effect<import("@yielded/auth/Hooks").PreparedCommit<A>, import("@yielded/auth/OAuth").OAuthUnavailable, never>;
@@ -346,6 +346,8 @@ export declare const makeOAuthAccountsServices: <S extends AnySQLiteTable<{
346
346
  readonly flow: import("@yielded/auth/OAuth").OAuthLinkPendingFlow;
347
347
  readonly authorization: import("@yielded/auth/OAuth").OAuthActionAuthorization;
348
348
  }, prepare: import("@yielded/auth/OAuth").PrepareOAuthCommit<{
349
+ readonly _tag: "Rejected";
350
+ } | {
349
351
  readonly _tag: "Issued";
350
352
  readonly flow: {
351
353
  readonly context: {
@@ -401,8 +403,6 @@ export declare const makeOAuthAccountsServices: <S extends AnySQLiteTable<{
401
403
  };
402
404
  readonly retentionUntilMillis: number;
403
405
  };
404
- } | {
405
- readonly _tag: "Rejected";
406
406
  }, A>) => Effect.Effect<import("@yielded/auth/Hooks").PreparedCommit<A>, import("@yielded/auth/OAuth").OAuthUnavailable>;
407
407
  readonly preflight: (input: import("@yielded/auth/OAuth").OAuthLinkAccess) => Effect.Effect<import("@yielded/auth/OAuth").OAuthLinkPendingFlow | undefined, import("@yielded/auth/OAuth").OAuthUnavailable>;
408
408
  readonly claim: <A>(input: {
@@ -486,6 +486,8 @@ export declare const makeOAuthAccountsServices: <S extends AnySQLiteTable<{
486
486
  readonly _tag: "Cancelled";
487
487
  } | {
488
488
  readonly _tag: "Ambiguous";
489
+ } | {
490
+ readonly _tag: "Conflict";
489
491
  } | {
490
492
  readonly _tag: "Linked";
491
493
  readonly credential: {
@@ -507,8 +509,6 @@ export declare const makeOAuthAccountsServices: <S extends AnySQLiteTable<{
507
509
  };
508
510
  };
509
511
  readonly changed: boolean;
510
- } | {
511
- readonly _tag: "Conflict";
512
512
  }, A>) => Effect.Effect<import("@yielded/auth/Hooks").PreparedCommit<A>, import("@yielded/auth/OAuth").OAuthUnavailable>;
513
513
  readonly inspectUnlink: (input: {
514
514
  readonly moduleId: string & import("effect/Brand").Brand<"effect-auth/OAuthModuleId">;
@@ -859,8 +859,6 @@ export declare const makeOAuthAccountsServices: <S extends AnySQLiteTable<{
859
859
  readonly _tag: "Cancelled";
860
860
  } | {
861
861
  readonly _tag: "Ambiguous";
862
- } | {
863
- readonly _tag: "Conflict";
864
862
  } | {
865
863
  readonly _tag: "Connected";
866
864
  readonly grant: {
@@ -930,6 +928,8 @@ export declare const makeOAuthAccountsServices: <S extends AnySQLiteTable<{
930
928
  readonly ciphertext: import("effect/Redacted").Redacted<string>;
931
929
  };
932
930
  };
931
+ } | {
932
+ readonly _tag: "Conflict";
933
933
  } | {
934
934
  readonly _tag: "Busy";
935
935
  }, A>) => Effect.Effect<import("@yielded/auth/Hooks").PreparedCommit<A>, import("@yielded/auth/OAuth").OAuthUnavailable, never>;
@@ -1205,8 +1205,6 @@ export declare const makeOAuthAccountsServices: <S extends AnySQLiteTable<{
1205
1205
  readonly _tag: "Cancelled";
1206
1206
  } | {
1207
1207
  readonly _tag: "Ambiguous";
1208
- } | {
1209
- readonly _tag: "Conflict";
1210
1208
  } | {
1211
1209
  readonly _tag: "Connected";
1212
1210
  readonly grant: {
@@ -1276,6 +1274,8 @@ export declare const makeOAuthAccountsServices: <S extends AnySQLiteTable<{
1276
1274
  readonly ciphertext: import("effect/Redacted").Redacted<string>;
1277
1275
  };
1278
1276
  };
1277
+ } | {
1278
+ readonly _tag: "Conflict";
1279
1279
  } | {
1280
1280
  readonly _tag: "Busy";
1281
1281
  }, A>) => Effect.Effect<import("@yielded/auth/Hooks").PreparedCommit<A>, import("@yielded/auth/OAuth").OAuthUnavailable, never>;
@@ -27,6 +27,8 @@ export declare const makeD1OAuthAccountsServices: <S extends SQLiteTable, O exte
27
27
  readonly flow: import("@yielded/auth/OAuth").OAuthLinkPendingFlow;
28
28
  readonly authorization: import("@yielded/auth/OAuth").OAuthActionAuthorization;
29
29
  }, prepare: import("@yielded/auth/OAuth").PrepareOAuthCommit<{
30
+ readonly _tag: "Rejected";
31
+ } | {
30
32
  readonly _tag: "Issued";
31
33
  readonly flow: {
32
34
  readonly context: {
@@ -82,8 +84,6 @@ export declare const makeD1OAuthAccountsServices: <S extends SQLiteTable, O exte
82
84
  };
83
85
  readonly retentionUntilMillis: number;
84
86
  };
85
- } | {
86
- readonly _tag: "Rejected";
87
87
  }, A>) => Effect.Effect<import("@yielded/auth/Hooks").PreparedCommit<A>, OAuthUnavailable>;
88
88
  readonly preflight: (input: import("@yielded/auth/OAuth").OAuthLinkAccess) => Effect.Effect<import("@yielded/auth/OAuth").OAuthLinkPendingFlow | undefined, OAuthUnavailable>;
89
89
  readonly claim: <A>(input: {
@@ -167,6 +167,8 @@ export declare const makeD1OAuthAccountsServices: <S extends SQLiteTable, O exte
167
167
  readonly _tag: "Cancelled";
168
168
  } | {
169
169
  readonly _tag: "Ambiguous";
170
+ } | {
171
+ readonly _tag: "Conflict";
170
172
  } | {
171
173
  readonly _tag: "Linked";
172
174
  readonly credential: {
@@ -188,8 +190,6 @@ export declare const makeD1OAuthAccountsServices: <S extends SQLiteTable, O exte
188
190
  };
189
191
  };
190
192
  readonly changed: boolean;
191
- } | {
192
- readonly _tag: "Conflict";
193
193
  }, A>) => Effect.Effect<import("@yielded/auth/Hooks").PreparedCommit<A>, OAuthUnavailable>;
194
194
  readonly inspectUnlink: (input: {
195
195
  readonly moduleId: string & import("effect/Brand").Brand<"effect-auth/OAuthModuleId">;
@@ -194,22 +194,23 @@ const scopeEntries = (keys, policy) => {
194
194
  });
195
195
  return entries;
196
196
  };
197
+ const livePendingAttempts = (mapping, moduleId, action, entry, identifier, nativeSubjectId, activeAt) => {
198
+ const a = attemptColumns(mapping);
199
+ return and(entry.kind === "action" ? and(eq(a.moduleId, moduleId), eq(a.action, action)) : entry.kind === "identifier" ? and(eq(a.moduleId, moduleId), eq(a.action, action), eq(a.identifierNamespace, identifier.namespace), eq(a.identifierValue, identifier.value)) : and(eq(a.moduleId, moduleId), eq(a.action, action), eq(a.subjectId, nativeSubjectId)), eq(a.state, "pending"), sql`${a.retentionUntil} > ${activeAt}`);
200
+ };
197
201
  const scopeAdmissionCondition = (mapping, moduleId, action, entry, policy, identifier, nativeSubjectId) => {
198
202
  const c = chargeColumns(mapping);
199
- const a = attemptColumns(mapping);
200
- const pending = entry.kind === "action" ? and(eq(a.moduleId, moduleId), eq(a.action, action), eq(a.state, "pending")) : entry.kind === "identifier" ? and(eq(a.moduleId, moduleId), eq(a.action, action), eq(a.identifierNamespace, identifier.namespace), eq(a.identifierValue, identifier.value), eq(a.state, "pending")) : and(eq(a.moduleId, moduleId), eq(a.action, action), eq(a.subjectId, nativeSubjectId), eq(a.state, "pending"));
203
+ const pending = livePendingAttempts(mapping, moduleId, action, entry, identifier, nativeSubjectId, mapping.d1.engineNow);
201
204
  return sql`(select count(*) from ${mapping.charge.table} where ${c.moduleId} = ${sql.param(moduleId, c.moduleId)} and ${c.action} = ${sql.param(action, c.action)} and ${c.scopeKind} = ${sql.param(entry.kind, c.scopeKind)} and ${c.scopeKey} = ${sql.param(entry.key, c.scopeKey)} and ${c.occurredAt} >= ${mapping.d1.engineInstantMinus(entry.windowMillis)}) < ${entry.limit} and (select count(*) from ${mapping.attempt.table} where ${pending}) < ${policy.maximumPending}`;
202
205
  };
203
206
  const readScopeAdmission = Effect.fn("DrizzleD1Password.readScopeAdmission")(function* (mapping, moduleId, action, entries, policy, identifier, nativeSubjectId, now) {
204
207
  const database = yield* CurrentD1PlanningDatabase;
205
208
  const c = chargeColumns(mapping);
206
- const a = attemptColumns(mapping);
207
209
  const admitted = [];
208
210
  for (let index = 0; index < entries.length; index++) {
209
211
  const entry = entries[index];
210
212
  const chargeRows = yield* mapAdapter(database.select({ total: count() }).from(mapping.charge.table).where(and(eq(c.moduleId, moduleId), eq(c.action, action), eq(c.scopeKind, entry.kind), eq(c.scopeKey, entry.key), gte(c.occurredAt, mapping.encodeInstant(now - entry.windowMillis)))));
211
- const pendingWhere = entry.kind === "action" ? and(eq(a.moduleId, moduleId), eq(a.action, action), eq(a.state, "pending")) : entry.kind === "identifier" ? and(eq(a.moduleId, moduleId), eq(a.action, action), eq(a.identifierNamespace, identifier.namespace), eq(a.identifierValue, identifier.value), eq(a.state, "pending")) : and(eq(a.moduleId, moduleId), eq(a.action, action), eq(a.subjectId, nativeSubjectId), eq(a.state, "pending"));
212
- const pendingRows = yield* mapAdapter(database.select({ total: count() }).from(mapping.attempt.table).where(pendingWhere));
213
+ const pendingRows = yield* mapAdapter(database.select({ total: count() }).from(mapping.attempt.table).where(livePendingAttempts(mapping, moduleId, action, entry, identifier, nativeSubjectId, mapping.encodeInstant(now))));
213
214
  if (Number(chargeRows[0]?.total ?? 0) < entry.limit && Number(pendingRows[0]?.total ?? 0) < policy.maximumPending) admitted.push(entry);
214
215
  else if (index === 0) break;
215
216
  }