@ultimat3/auth 31.46.0 → 31.47.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/README.md CHANGED
@@ -9,6 +9,10 @@ authorizes on a session row, a user row or an api key — http, actions, jobs an
9
9
  ```ts
10
10
  import { defineAuth, login, oauthLogin, postgresAuthAdapter } from '@ultimat3/auth';
11
11
 
12
+ declare const email: string;
13
+ declare const password: string;
14
+ declare const ip: string;
15
+
12
16
  export const auth = defineAuth({
13
17
  adapter: postgresAuthAdapter(), // or memoryAuthAdapter(), or your Better Auth binding
14
18
  session: { absoluteTtlMs: 30 * 864e5, idleTtlMs: 7 * 864e5 },
@@ -57,6 +61,11 @@ account survive 15 guesses and hides each replica's lockout from the other two.
57
61
  more than one process says so and brings a limiter that says the same:
58
62
 
59
63
  ```ts
64
+ import { type AuthAdapter, type AuthLimiter, defineAuth } from '@ultimat3/auth';
65
+
66
+ declare const adapter: AuthAdapter;
67
+ declare const myLimiter: AuthLimiter;
68
+
60
69
  defineAuth({
61
70
  adapter,
62
71
  rateLimit: { maxAttempts: 5, scope: 'shared' }, // the whole fleet's allowance
@@ -98,6 +107,12 @@ same JWT: a Kubernetes projected service-account token, a SPIFFE JWT-SVID, and a
98
107
  It is also the shape RFC 8693's `subject_token` takes.
99
108
 
100
109
  ```ts
110
+ import { actorFromService, jwksClient, verifyWorkloadToken } from '@ultimat3/auth';
111
+ import { type Clock } from '@ultimat3/core';
112
+
113
+ declare const clock: Clock;
114
+ declare const token: string;
115
+
101
116
  const { identity } = await verifyWorkloadToken({
102
117
  token,
103
118
  issuers: ['https://kubernetes.default.svc'],
@@ -364,6 +379,14 @@ export const login = oauthLogin(auth, {
364
379
  ```
365
380
 
366
381
  ```ts
382
+ import { providerFor, providerJwks, verifyIdToken } from '@ultimat3/auth';
383
+ import { type Clock } from '@ultimat3/core';
384
+
385
+ declare const clock: Clock;
386
+ declare const clientId: string;
387
+ declare const idToken: string;
388
+ declare const nonce: string;
389
+
367
390
  const keys = providerJwks(providerFor('bigco-sso'));
368
391
  const claims = await verifyIdToken({ provider: 'bigco-sso', idToken, clientId, nonce, clock, keys });
369
392
  ```
@@ -386,6 +409,14 @@ throws before the query is built. SSO "works" and the person can do nothing unti
386
409
  SQL, so the omission logs `auth.oauth.user_created_without_grants` rather than passing silently.
387
410
 
388
411
  ```ts
412
+ import { type Auth, oauthLogin } from '@ultimat3/auth';
413
+
414
+ declare const auth: Auth;
415
+ declare const directory: {
416
+ lookup(email: string | null): Promise<{ orgId: string; groups: readonly string[] }>;
417
+ };
418
+ declare function toRole(group: string): string;
419
+
389
420
  oauthLogin(auth, {
390
421
  resolveGrants: async (profile) => {
391
422
  const member = await directory.lookup(profile.email);
@@ -945,6 +976,10 @@ seams — but they are the seams, not the path.
945
976
  ### Account linking
946
977
 
947
978
  ```ts
979
+ import { type AuthAdapter, defineAuth } from '@ultimat3/auth';
980
+
981
+ declare const adapter: AuthAdapter;
982
+
948
983
  defineAuth({ adapter, providers: ['github'], link: 'verified-email' }) // the default
949
984
  ```
950
985
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ultimat3/auth",
3
- "version": "31.46.0",
3
+ "version": "31.47.0",
4
4
  "description": "Sessions, passwords, OAuth, MFA and api keys — resolved to one Actor",
5
5
  "keywords": [
6
6
  "ultimate",
@@ -50,8 +50,8 @@
50
50
  "test": "bun test"
51
51
  },
52
52
  "dependencies": {
53
- "@ultimat3/core": "31.46.0",
54
- "@ultimat3/db": "31.46.0",
55
- "@ultimat3/schema": "31.46.0"
53
+ "@ultimat3/core": "31.47.0",
54
+ "@ultimat3/db": "31.47.0",
55
+ "@ultimat3/schema": "31.47.0"
56
56
  }
57
57
  }
@@ -3,7 +3,7 @@
3
3
  // size-capped, metered per caller, cached oldest-first — and proving a confidential one's secret.
4
4
  // The secret is hashed at rest and compared hash to hash in constant time, never with `===`.
5
5
 
6
- import { logger, stringField, timingSafeEqual } from '@ultimat3/core';
6
+ import { isJsonObject, logger, stringField, timingSafeEqual } from '@ultimat3/core';
7
7
  import { outbound } from '@ultimat3/core/outbound';
8
8
  import type { ResolvedAuthServerConfig } from './authorization-server-config';
9
9
  import { type ClientListField, clientInvalid } from './authorization-server-errors';
@@ -12,7 +12,6 @@ import type {
12
12
  AuthServerGrant,
13
13
  ClientAuthMethod,
14
14
  } from './authorization-server-types';
15
- import { isRecord } from './json';
16
15
  import { randomToken, sha256Hex } from './tokens';
17
16
 
18
17
  /** A metadata document is a few hundred bytes; 5 KiB is RFC 7591 metadata with room to spare. */
@@ -53,7 +52,7 @@ const strings = (value: unknown): readonly string[] | null =>
53
52
 
54
53
  /** The document, read as a public client or not at all. A secret in it would be published. */
55
54
  function clientFromDocument(clientId: string, body: unknown, at: Date): AuthServerClient | null {
56
- if (!isRecord(body) || body['client_id'] !== clientId) return null;
55
+ if (!isJsonObject(body) || body['client_id'] !== clientId) return null;
57
56
  const redirects = strings(body['redirect_uris']);
58
57
  if (redirects === null || redirects.length === 0 || !redirects.every(isRedirectUri)) return null;
59
58
  const method = body['token_endpoint_auth_method'];
@@ -2,13 +2,13 @@
2
2
  // it — on only under `registration: 'dynamic'`, counted per address. Never a machine client: an
3
3
  // open endpoint handing out `client_credentials` would let anyone mint itself a scope.
4
4
 
5
+ import { isJsonObject } from '@ultimat3/core';
5
6
  import { isRedirectUri, storeClient } from './authorization-server-clients';
6
7
  import type { ResolvedAuthServerConfig } from './authorization-server-config';
7
8
  import type { AuthServerGrant, ClientAuthMethod } from './authorization-server-types';
8
9
  import { DEVICE_GRANT } from './authorization-server-types';
9
10
  import type { AuthServerHttpContext, AuthServerHttpRequest } from './authorization-server-wire';
10
11
  import { jsonAnswer, throttledAnswer } from './authorization-server-wire';
11
- import { isRecord } from './json';
12
12
 
13
13
  const SELF_SERVICE_GRANTS: ReadonlySet<string> = new Set<AuthServerGrant>([
14
14
  'authorization_code',
@@ -45,7 +45,8 @@ export async function registerHandler(
45
45
  } catch {
46
46
  return metadataError('invalid_client_metadata', 'the body is not JSON');
47
47
  }
48
- if (!isRecord(body)) return metadataError('invalid_client_metadata', 'the body is not an object');
48
+ if (!isJsonObject(body))
49
+ return metadataError('invalid_client_metadata', 'the body is not an object');
49
50
  const grants = stringList(body['grant_types'] ?? ['authorization_code', 'refresh_token']);
50
51
  if (
51
52
  grants === null ||
@@ -4,12 +4,9 @@
4
4
  // the HTML is cacheable by a browser and readable by every script on the page.
5
5
 
6
6
  import type { Actor } from '@ultimat3/core';
7
- import { hmac, logger } from '@ultimat3/core';
7
+ import { clientScopeId } from '@ultimat3/core';
8
8
  import { AuthError } from './errors';
9
9
 
10
- /** 128 bits: a scope only has to differ between principals, never to authenticate anyone. */
11
- const SCOPE_HEX_CHARS = 32;
12
-
13
10
  /** `wiki/Configuration.md`'s floor for `SESSION_SECRET`, the same one the oauth handshake reads. */
14
11
  const MIN_SECRET_LENGTH = 32;
15
12
 
@@ -19,53 +16,24 @@ export interface ClientScopeOptions {
19
16
  readonly env?: Readonly<Record<string, string | undefined>> | undefined;
20
17
  }
21
18
 
22
- /** Minted on first need when no `SESSION_SECRET` exists: stable per process, never per request. */
23
- let processKey: string | undefined;
24
-
25
19
  /**
26
20
  * `''` for the anonymous page — the empty scope core reads as "nobody". Otherwise the principal
27
21
  * AND who is really acting, so an admin impersonating a user is not the user's own scope: their
28
- * stores must never share records, on the page or on disk.
22
+ * stores must never share records, on the page or on disk. The derivation is core's, because
23
+ * `@ultimat3/action` compares against it and may not reach this tier's sibling for one function.
29
24
  */
30
25
  export function clientScopeOf(actor: Actor, options: ClientScopeOptions = {}): string {
31
26
  if (actor.kind === 'anonymous') return '';
32
- const material = JSON.stringify([
33
- actor.kind,
34
- actor.id,
35
- actor.onBehalfOf?.actorKind ?? null,
36
- actor.onBehalfOf?.actorId ?? null,
37
- ]);
38
- return hmac('sha256', scopeKey(options), material, 'hex').slice(0, SCOPE_HEX_CHARS);
39
- }
40
-
41
- function scopeKey(options: ClientScopeOptions): string {
42
- if (options.secret !== undefined) {
43
- // The same floor as the env path below: an explicit key is a caller's value, so a short one is
44
- // refused rather than silently swapped for the process key.
45
- if (options.secret.length < MIN_SECRET_LENGTH) {
46
- // Never its length: how long the key handed over is narrows a guess at it.
47
- throw new AuthError({
48
- code: 'X_CONFIG_INVALID',
49
- cause: `clientScopeOf({ secret }) was passed a key shorter than the ${String(MIN_SECRET_LENGTH)} characters required, so the scope id would be keyed by a guessable secret`,
50
- fix: 'openssl rand -hex 32 # pass the output as clientScopeOf({ secret }), or omit secret to read SESSION_SECRET',
51
- meta: { option: 'secret', minLength: MIN_SECRET_LENGTH },
52
- });
53
- }
54
- return options.secret;
55
- }
56
- const configured = (options.env ?? Bun.env)['SESSION_SECRET']?.trim() ?? '';
57
- if (configured.length >= MIN_SECRET_LENGTH) return configured;
58
- if (processKey === undefined) {
59
- // `SESSION_SECRET` is optional in the env schema, so its absence cannot refuse a render. A
60
- // random per-process key keeps the id opaque; what it costs is stability across replicas and
61
- // restarts — a principal's page then rescopes, which clears its store, never leaks it.
62
- processKey = Array.from(crypto.getRandomValues(new Uint8Array(32)), (byte) =>
63
- byte.toString(16).padStart(2, '0'),
64
- ).join('');
65
- logger.warn('auth.client_scope.process_key', {
66
- reason: 'SESSION_SECRET unset or shorter than 32 chars',
67
- fix: 'export SESSION_SECRET="$(openssl rand -hex 32)"',
27
+ // The same floor as `SESSION_SECRET`: an explicit key is a caller's value, so a short one is
28
+ // refused rather than silently swapped for the process key.
29
+ if (options.secret !== undefined && options.secret.length < MIN_SECRET_LENGTH) {
30
+ // Never its length: how long the key handed over is narrows a guess at it.
31
+ throw new AuthError({
32
+ code: 'X_CONFIG_INVALID',
33
+ cause: `clientScopeOf({ secret }) was passed a key shorter than the ${String(MIN_SECRET_LENGTH)} characters required, so the scope id would be keyed by a guessable secret`,
34
+ fix: 'openssl rand -hex 32 # pass the output as clientScopeOf({ secret }), or omit secret to read SESSION_SECRET',
35
+ meta: { option: 'secret', minLength: MIN_SECRET_LENGTH },
68
36
  });
69
37
  }
70
- return processKey;
38
+ return clientScopeId(actor, options);
71
39
  }
@@ -3,14 +3,13 @@
3
3
  // behind the port, no protocol of its own. The port adds one thing: the handshake's `state` is
4
4
  // claimed ONCE in the shared replay store, keyed on when it was issued, before the code is spent.
5
5
 
6
- import { timingSafeEqual } from '@ultimat3/core';
6
+ import { isJsonObject, timingSafeEqual } from '@ultimat3/core';
7
7
  import {
8
8
  type IdentityProvider,
9
9
  type IdentityRedirect,
10
10
  replayStepFor,
11
11
  type VerifiedIdentity,
12
12
  } from './identity-provider';
13
- import { isRecord } from './json';
14
13
  import type { IdTokenKeys } from './jwks';
15
14
  import {
16
15
  assertOAuthCallback,
@@ -67,7 +66,7 @@ export function decodeOidcState(provider: OAuthProviderId, state: string): Store
67
66
  parsed = null;
68
67
  }
69
68
  if (
70
- !isRecord(parsed) ||
69
+ !isJsonObject(parsed) ||
71
70
  !FIELDS.every((field) => typeof parsed[field] === 'string') ||
72
71
  typeof parsed['issuedAt'] !== 'number' ||
73
72
  !Number.isFinite(parsed['issuedAt'])
package/src/json.ts CHANGED
@@ -1,19 +1,11 @@
1
- // Single responsibility: reading untrusted JSON — a provider's response body, or a JWT payload the
2
- // caller presented. Both questions were answered six and three times over in this package, and on a
3
- // JWT payload "is this an object" is what gates every claim read after it, so two copies quietly
4
- // disagreeing about (say) an array would be two different answers to a security question.
1
+ // Single responsibility: decoding a JWT payload segment the caller presented. Answered three times
2
+ // over in this package until it moved here; "is this an object" — the question that gates every
3
+ // claim read after it — is core's `isJsonObject`, which refuses an array, so `[]` never narrows to a
4
+ // claims record.
5
5
 
6
+ import { isJsonObject } from '@ultimat3/core';
6
7
  import { base64UrlBytes } from './tokens';
7
8
 
8
- /**
9
- * An ARRAY IS NOT A RECORD. That is the whole of the disagreement between the two variants of this
10
- * predicate in the wild, and it matters here: `JSON.parse('[1,2]')` is an object with numeric keys,
11
- * so without the array check a JWT payload of `[]` narrows to `Record<string, unknown>` and every
12
- * `parsed['iss']` below it reads `undefined` from a shape no issuer ever sends.
13
- */
14
- export const isRecord = (value: unknown): value is Record<string, unknown> =>
15
- typeof value === 'object' && value !== null && !Array.isArray(value);
16
-
17
9
  /**
18
10
  * A base64url JWT segment as a JSON object, or `null` for every way it can fail to be one: not
19
11
  * base64url, not JSON, not an object. `null` rather than a throw because every caller is holding an
@@ -29,5 +21,5 @@ export function decodeJwtSegment(segment: string): Record<string, unknown> | nul
29
21
  } catch {
30
22
  return null;
31
23
  }
32
- return isRecord(parsed) ? parsed : null;
24
+ return isJsonObject(parsed) ? parsed : null;
33
25
  }
package/src/jwks.ts CHANGED
@@ -11,6 +11,7 @@ import type { Clock, Scheduler } from '@ultimat3/core';
11
11
  import {
12
12
  generationFence,
13
13
  isFixShellSafe,
14
+ isJsonObject,
14
15
  liveClock,
15
16
  logger,
16
17
  renderFixLiteral,
@@ -19,7 +20,7 @@ import {
19
20
  singleFlight,
20
21
  } from '@ultimat3/core';
21
22
  import { outboundResponse } from '@ultimat3/core/outbound';
22
- import { decodeJwtSegment, isRecord } from './json';
23
+ import { decodeJwtSegment } from './json';
23
24
  import type { OAuthProvider } from './oauth';
24
25
  import { oauthExchangeFailed, oauthTokenInvalid } from './oauth-errors';
25
26
  import type { OAuthFetch } from './oauth-exchange';
@@ -227,10 +228,10 @@ export function jwksClient(options: JwksClientOptions): JwksKeySource {
227
228
  });
228
229
  }
229
230
  const body: unknown = await response.json().catch(() => undefined);
230
- const entries = isRecord(body) && Array.isArray(body['keys']) ? body['keys'] : [];
231
+ const entries = isJsonObject(body) && Array.isArray(body['keys']) ? body['keys'] : [];
231
232
  const next = new Map<string, CryptoKey>();
232
233
  for (const entry of entries) {
233
- if (!isRecord(entry)) continue;
234
+ if (!isJsonObject(entry)) continue;
234
235
  const alg = algorithmOf(entry);
235
236
  const kid = entry['kid'];
236
237
  const named = typeof kid === 'string' && kid !== '';
@@ -2,10 +2,16 @@
2
2
  // carrying a sealed, short-lived challenge; `completeMfa` opens it, meters the code against the
3
3
  // same buckets a password guess spends, and only then mints the session.
4
4
 
5
- import { isUltimateError, openText, randomHex, type SealKeySource, seal } from '@ultimat3/core';
5
+ import {
6
+ isJsonObject,
7
+ isUltimateError,
8
+ openText,
9
+ randomHex,
10
+ type SealKeySource,
11
+ seal,
12
+ } from '@ultimat3/core';
6
13
  import type { Auth, LoginResult } from './auth';
7
14
  import { type AuthError, mfaChallengeInvalid, mfaCodeRejected, mfaRequired } from './errors';
8
- import { isRecord } from './json';
9
15
  import { openLoginAttempt } from './login-attempt';
10
16
  import { recoveryCodeHash, TOTP_DIGITS, verifyTotp } from './mfa';
11
17
  import { openTotpSecret } from './mfa-secret';
@@ -63,7 +69,7 @@ async function openChallenge(
63
69
  if (isUltimateError(thrown) && !UNOPENABLE.has(thrown.code)) throw thrown;
64
70
  throw mfaChallengeInvalid();
65
71
  }
66
- if (!isRecord(parsed)) throw mfaChallengeInvalid();
72
+ if (!isJsonObject(parsed)) throw mfaChallengeInvalid();
67
73
  const { userId, nonce, expiresAtMs } = parsed;
68
74
  if (typeof userId !== 'string' || typeof nonce !== 'string' || typeof expiresAtMs !== 'number') {
69
75
  throw mfaChallengeInvalid();
@@ -4,6 +4,7 @@
4
4
  // four endpoints that nobody re-checks when the vendor moves one.
5
5
 
6
6
  import {
7
+ isJsonObject,
7
8
  renderCauseValue,
8
9
  renderFixLiteral,
9
10
  renderFixShellArg,
@@ -11,7 +12,6 @@ import {
11
12
  trimTrailingSlashes,
12
13
  } from '@ultimat3/core';
13
14
  import { outboundResponse } from '@ultimat3/core/outbound';
14
- import { isRecord } from './json';
15
15
  import type { OAuthProvider, TokenEndpointAuth } from './oauth';
16
16
  import { oauthExchangeFailed } from './oauth-errors';
17
17
  import type { OAuthFetch } from './oauth-exchange';
@@ -123,7 +123,7 @@ export async function discoverOAuthProvider(
123
123
  }
124
124
 
125
125
  const body: unknown = await response.json().catch(() => undefined);
126
- if (!isRecord(body)) {
126
+ if (!isJsonObject(body)) {
127
127
  throw oauthExchangeFailed({
128
128
  provider: input.id,
129
129
  stage: 'discovery',
@@ -6,6 +6,7 @@
6
6
  import type { Clock } from '@ultimat3/core';
7
7
  import {
8
8
  EnvMissingError,
9
+ isJsonObject,
9
10
  liveClock,
10
11
  logger,
11
12
  renderCauseValue,
@@ -15,7 +16,6 @@ import {
15
16
  } from '@ultimat3/core';
16
17
  import { outboundResponse } from '@ultimat3/core/outbound';
17
18
  import { type IdTokenClaims, verifyIdToken } from './id-token';
18
- import { isRecord } from './json';
19
19
  import { type IdTokenKeys, providerJwks } from './jwks';
20
20
  import {
21
21
  assertOAuthCallback,
@@ -150,7 +150,7 @@ export async function providerDetail(
150
150
  if (text === '') return 'the response body was empty';
151
151
  try {
152
152
  const parsed: unknown = JSON.parse(text);
153
- if (isRecord(parsed)) {
153
+ if (isJsonObject(parsed)) {
154
154
  // `message` is not an OAuth error field (RFC 6749 §5.2 defines `error` and
155
155
  // `error_description`), and a gateway that echoes the request body puts `client_secret` in
156
156
  // it — so a `coded-only` leg never reads it.
@@ -269,7 +269,7 @@ async function postForm(
269
269
  }
270
270
 
271
271
  const parsed: unknown = await response.json().catch(() => undefined);
272
- if (!isRecord(parsed)) {
272
+ if (!isJsonObject(parsed)) {
273
273
  throw oauthExchangeFailed({
274
274
  provider,
275
275
  stage: 'token',
@@ -3,10 +3,15 @@
3
3
  // when there is not. `emailVerified` is carried honestly rather than assumed — it is what
4
4
  // decides whether this login may attach itself to an existing account by address.
5
5
 
6
- import { logger, renderFixLiteral, renderFixShellArg, renderThrowable } from '@ultimat3/core';
6
+ import {
7
+ isJsonObject,
8
+ logger,
9
+ renderFixLiteral,
10
+ renderFixShellArg,
11
+ renderThrowable,
12
+ } from '@ultimat3/core';
7
13
  import { outboundResponse } from '@ultimat3/core/outbound';
8
14
  import { idTokenEmailVerified, isVerifiedFlag } from './id-token';
9
- import { isRecord } from './json';
10
15
  import type { OAuthProviderId } from './oauth';
11
16
  import { oauthExchangeFailed, restartAt } from './oauth-errors';
12
17
  import {
@@ -136,7 +141,7 @@ async function githubPrimaryEmail(
136
141
  const entries = Array.isArray(result.body) ? result.body : [];
137
142
  const verified = entries.filter(
138
143
  (entry): entry is GithubEmail =>
139
- isRecord(entry) &&
144
+ isJsonObject(entry) &&
140
145
  typeof entry['email'] === 'string' &&
141
146
  entry['verified'] === true &&
142
147
  typeof entry['primary'] === 'boolean',
@@ -175,7 +180,7 @@ export async function userinfoBody(
175
180
  fix: `providerFor(${renderFixLiteral(provider, "'<id>'")}).scopes // confirm the ${provider} app still grants each one, then ${restartAt(provider)}`,
176
181
  });
177
182
  }
178
- if (!isRecord(result.body)) {
183
+ if (!isJsonObject(result.body)) {
179
184
  throw oauthExchangeFailed({
180
185
  provider,
181
186
  stage: 'userinfo',
@@ -3,9 +3,9 @@
3
3
  // and UV flags, the attested key, the signature. Pure: no store, no clock. Every refusal answers
4
4
  // `null` plus the name of the check, which the caller logs; the challenge is the caller's to match.
5
5
 
6
+ import { isJsonObject } from '@ultimat3/core';
6
7
  import { base64Url, canonicalBase64UrlBytes } from './base64url';
7
8
  import { importCoseKey, PASSKEY_ALGORITHMS, verifyCoseSignature } from './cose-key';
8
- import { isRecord } from './json';
9
9
  import type { PasskeyRelyingParty } from './passkey-config';
10
10
  import {
11
11
  type AuthenticatorData,
@@ -63,7 +63,7 @@ export function readEnvelope(
63
63
  raw: unknown,
64
64
  type: 'webauthn.create' | 'webauthn.get',
65
65
  ): Checked<CeremonyEnvelope> {
66
- if (!isRecord(raw) || raw['type'] !== 'public-key' || !isRecord(raw['response'])) {
66
+ if (!isJsonObject(raw) || raw['type'] !== 'public-key' || !isJsonObject(raw['response'])) {
67
67
  return refuse('envelope');
68
68
  }
69
69
  const id = raw['id'];
@@ -3,14 +3,13 @@
3
3
  // (RelayState + InResponseTo), verifies it (`verifySamlResponse`), claims its assertion ID once,
4
4
  // and reads one profile out of it.
5
5
 
6
- import { timingSafeEqual } from '@ultimat3/core';
6
+ import { isJsonObject, timingSafeEqual } from '@ultimat3/core';
7
7
  import {
8
8
  type IdentityProvider,
9
9
  type IdentityRedirect,
10
10
  replayStepFor,
11
11
  type VerifiedIdentity,
12
12
  } from './identity-provider';
13
- import { isRecord } from './json';
14
13
  import { assertFiniteAuthCount } from './policy-numbers';
15
14
  import type { SamlAssertion } from './saml-assertion';
16
15
  import { NAMEID_EMAIL } from './saml-dom';
@@ -69,7 +68,7 @@ function readState(provider: string, state: string): SamlState {
69
68
  parsed = null;
70
69
  }
71
70
  if (
72
- !isRecord(parsed) ||
71
+ !isJsonObject(parsed) ||
73
72
  typeof parsed['requestId'] !== 'string' ||
74
73
  typeof parsed['relayState'] !== 'string'
75
74
  ) {
@@ -2,9 +2,9 @@
2
2
  // bytes the browser forwarded — `authenticatorData` (W3C WebAuthn L3 §6.1) and `clientDataJSON`
3
3
  // (§5.8.1). Parsing only: what each field must equal is `passkey-verify.ts`'s to decide.
4
4
 
5
+ import { isJsonObject } from '@ultimat3/core';
5
6
  import { canonicalBase64UrlBytes } from './base64url';
6
7
  import { type CborValue, decodeCborItem } from './cbor';
7
- import { isRecord } from './json';
8
8
 
9
9
  /** User Present, User Verified, Attested credential data, Extension data (§6.1 flags). */
10
10
  export const FLAG_UP = 0x01;
@@ -79,7 +79,7 @@ export function parseClientData(bytes: Uint8Array): ClientData | null {
79
79
  } catch {
80
80
  return null;
81
81
  }
82
- if (!isRecord(parsed)) return null;
82
+ if (!isJsonObject(parsed)) return null;
83
83
  const { type, challenge, origin, crossOrigin } = parsed;
84
84
  if (typeof type !== 'string' || typeof origin !== 'string') return null;
85
85
  if (canonicalBase64UrlBytes(challenge) === null || typeof challenge !== 'string') return null;