@netlify/identity 0.4.2 → 1.0.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/dist/index.d.cts CHANGED
@@ -1,10 +1,10 @@
1
1
  /** The supported OAuth and authentication providers. */
2
- declare const AUTH_PROVIDERS: readonly ["google", "github", "gitlab", "bitbucket", "facebook", "saml", "email"];
2
+ declare const AUTH_PROVIDERS: readonly ["google", "github", "gitlab", "bitbucket", "facebook", "email"];
3
3
  /** A supported authentication provider name (e.g., `'google'`, `'github'`, `'email'`). */
4
4
  type AuthProvider = (typeof AUTH_PROVIDERS)[number];
5
5
  /**
6
6
  * Provider and role metadata stored in a user's `app_metadata` field.
7
- * GoTrue sets `provider` automatically on signup; `roles` controls authorization.
7
+ * The `provider` field is set automatically on signup; `roles` controls authorization.
8
8
  * Additional keys may be present depending on your Identity configuration.
9
9
  *
10
10
  * @example
@@ -27,7 +27,7 @@ interface AppMetadata {
27
27
  * On the server, `token` is the operator token for admin operations.
28
28
  */
29
29
  interface IdentityConfig {
30
- /** The GoTrue API endpoint URL (e.g., `https://example.com/.netlify/identity`). */
30
+ /** The Identity API endpoint URL (e.g., `https://example.com/.netlify/identity`). */
31
31
  url: string;
32
32
  /** Operator token for server-side admin requests. Only available in Netlify Functions. */
33
33
  token?: string;
@@ -86,8 +86,6 @@ interface AdminUserUpdates {
86
86
  password?: string;
87
87
  /** The user's role (e.g., `'admin'`, `'editor'`). */
88
88
  role?: string;
89
- /** The user's audience (rarely needed; defaults to the site's audience). */
90
- aud?: string;
91
89
  /** Set to `true` to force-confirm the user's email without sending a confirmation email. */
92
90
  confirm?: boolean;
93
91
  /** Server-managed metadata. Only writable via admin operations. */
@@ -107,8 +105,8 @@ interface ListUsersOptions {
107
105
  /**
108
106
  * Parameters for {@link admin.createUser}.
109
107
  *
110
- * The optional `data` fields are forwarded as top-level attributes in the GoTrue
111
- * request body. Only these keys are accepted: `role`, `aud`, `app_metadata`,
108
+ * The optional `data` fields are forwarded as top-level attributes in the Identity API
109
+ * request body. Only these keys are accepted: `role`, `app_metadata`,
112
110
  * `user_metadata`. Any other keys are silently ignored. `data` cannot override
113
111
  * `email`, `password`, or `confirm`.
114
112
  *
@@ -124,14 +122,18 @@ interface ListUsersOptions {
124
122
  interface CreateUserParams {
125
123
  email: string;
126
124
  password: string;
127
- /** GoTrue user fields: `role`, `aud`, `app_metadata`, `user_metadata`. Other keys are ignored. */
125
+ /** Identity user fields: `role`, `app_metadata`, `user_metadata`. Other keys are ignored. */
128
126
  data?: Record<string, unknown>;
129
127
  }
130
128
 
131
129
  /**
132
130
  * A normalized user object returned by all auth and admin functions.
133
131
  * Provides a consistent shape regardless of whether the user was loaded
134
- * from gotrue-js, a JWT cookie, or the server-side identity context.
132
+ * from the Identity API, a JWT cookie, or the server-side identity context.
133
+ *
134
+ * All fields except `id` are optional and may be `undefined`. Empty strings
135
+ * are normalized to `undefined`. State-dependent fields (invite,
136
+ * recovery, email-change) are only present when the user is in that state.
135
137
  *
136
138
  * @example
137
139
  * ```ts
@@ -142,30 +144,46 @@ interface CreateUserParams {
142
144
  * ```
143
145
  */
144
146
  interface User {
145
- /** The user's unique identifier (GoTrue UUID). */
147
+ /** The user's unique identifier. */
146
148
  id: string;
147
149
  /** The user's email address. */
148
150
  email?: string;
149
- /** `true` if the user's email has been confirmed. */
150
- emailVerified?: boolean;
151
+ /** ISO 8601 timestamp of when the user's email was confirmed. `undefined` if not yet confirmed. */
152
+ confirmedAt?: string;
151
153
  /** ISO 8601 timestamp of when the account was created. */
152
154
  createdAt?: string;
153
155
  /** ISO 8601 timestamp of the last account update. */
154
156
  updatedAt?: string;
155
- /** The authentication provider used to create the account. */
157
+ /**
158
+ * The account-level role string (e.g., `"admin"`). This is a single value
159
+ * set via the admin API, distinct from `roles` which is an array in `app_metadata`.
160
+ * `undefined` when not set or empty.
161
+ */
162
+ role?: string;
163
+ /** The authentication provider used to create the account (from `app_metadata.provider`). */
156
164
  provider?: AuthProvider;
157
165
  /** Display name from `user_metadata.full_name` or `user_metadata.name`. */
158
166
  name?: string;
159
167
  /** Avatar URL from `user_metadata.avatar_url`. */
160
168
  pictureUrl?: string;
161
- /** Roles from `app_metadata.roles`, set via the admin API or Netlify UI. */
169
+ /** Application-level roles from `app_metadata.roles`, set via the admin API or Netlify UI. */
162
170
  roles?: string[];
163
- /** The full `user_metadata` object. */
164
- metadata?: Record<string, unknown>;
165
- /** The full `app_metadata` object. */
171
+ /** ISO 8601 timestamp of when the user was invited. Only present if the user was created via invitation. */
172
+ invitedAt?: string;
173
+ /** ISO 8601 timestamp of when the confirmation email was last sent. */
174
+ confirmationSentAt?: string;
175
+ /** ISO 8601 timestamp of when the recovery email was last sent. */
176
+ recoverySentAt?: string;
177
+ /** The pending email address during an email change flow. Only present while the change is awaiting confirmation. */
178
+ pendingEmail?: string;
179
+ /** ISO 8601 timestamp of when the email change verification was last sent. */
180
+ emailChangeSentAt?: string;
181
+ /** ISO 8601 timestamp of the user's most recent sign-in. */
182
+ lastSignInAt?: string;
183
+ /** Custom user metadata. Contains profile data like `full_name` and `avatar_url`, and any custom fields set via `updateUser()`. */
184
+ userMetadata?: Record<string, unknown>;
185
+ /** Application metadata managed by the server. Contains `provider`, `roles`, and other system-managed fields. */
166
186
  appMetadata?: Record<string, unknown>;
167
- /** The raw GoTrue user data, for accessing fields not mapped to this interface. */
168
- rawGoTrueData?: Record<string, unknown>;
169
187
  }
170
188
  /**
171
189
  * Returns the currently authenticated user, or `null` if not logged in.
@@ -175,11 +193,11 @@ interface User {
175
193
  * (email, roles, timestamps, metadata, etc.) regardless of whether the
176
194
  * call happens in the browser or on the server.
177
195
  *
178
- * In the browser, checks gotrue-js localStorage first. If no localStorage
196
+ * In the browser, checks localStorage first. If no localStorage
179
197
  * session exists, hydrates from the `nf_jwt` cookie (set by server-side login).
180
198
  *
181
- * On the server, fetches the full user from GoTrue using the JWT from
182
- * the request. Falls back to JWT claims if GoTrue is unreachable.
199
+ * On the server, fetches the full user from the Identity API using the JWT from
200
+ * the request. Falls back to JWT claims if the Identity API is unreachable.
183
201
  *
184
202
  * On the server in a Next.js App Router context, calls `headers()` from
185
203
  * `next/headers` to opt the route into dynamic rendering. Without this,
@@ -343,7 +361,7 @@ interface CallbackResult {
343
361
  */
344
362
  declare const handleAuthCallback: () => Promise<CallbackResult | null>;
345
363
  /**
346
- * Hydrates the browser-side gotrue-js session from server-set auth cookies.
364
+ * Hydrates the browser-side session from server-set auth cookies.
347
365
  * Call this on page load when using server-side login to enable browser
348
366
  * account operations (updateUser, verifyEmailChange, etc.).
349
367
  *
@@ -388,7 +406,7 @@ declare const refreshSession: () => Promise<string | null>;
388
406
  * Thrown by auth operations when something goes wrong: invalid credentials,
389
407
  * network failures, missing runtime context, etc.
390
408
  *
391
- * The `status` field contains the HTTP status code from GoTrue when available
409
+ * The `status` field contains the HTTP status code from the Identity API when available
392
410
  * (e.g., 401 for bad credentials, 422 for validation errors).
393
411
  * The `cause` field preserves the original error for debugging.
394
412
  *
@@ -405,7 +423,7 @@ declare const refreshSession: () => Promise<string | null>;
405
423
  */
406
424
  declare class AuthError extends Error {
407
425
  name: string;
408
- /** HTTP status code from GoTrue, if the error originated from an API response. */
426
+ /** HTTP status code from the Identity API, if the error originated from an API response. */
409
427
  status?: number;
410
428
  cause?: unknown;
411
429
  constructor(message: string, status?: number, options?: {
@@ -414,7 +432,7 @@ declare class AuthError extends Error {
414
432
  static from(error: unknown): AuthError;
415
433
  }
416
434
  /**
417
- * Thrown when a function requires a gotrue-js client but Netlify Identity
435
+ * Thrown when a function requires the Identity client but Netlify Identity
418
436
  * is not configured (no endpoint URL could be discovered).
419
437
  *
420
438
  * This typically means the site does not have Identity enabled, or the app
@@ -436,7 +454,7 @@ interface Admin {
436
454
  /**
437
455
  * Lists all users. Server-only.
438
456
  *
439
- * Calls GoTrue `GET /admin/users` with the operator token. Pagination
457
+ * Calls `GET /admin/users` with the operator token. Pagination
440
458
  * options (`page`, `perPage`) are forwarded as query parameters.
441
459
  *
442
460
  * @throws {AuthError} If called from a browser, or if the operator token is missing.
@@ -445,7 +463,7 @@ interface Admin {
445
463
  /**
446
464
  * Gets a single user by ID. Server-only.
447
465
  *
448
- * Calls GoTrue `GET /admin/users/:id` with the operator token.
466
+ * Calls `GET /admin/users/:id` with the operator token.
449
467
  *
450
468
  * @throws {AuthError} If called from a browser, the user is not found,
451
469
  * or the operator token is missing.
@@ -455,12 +473,12 @@ interface Admin {
455
473
  * Creates a new user. The user is auto-confirmed (no confirmation email is sent).
456
474
  * Server-only.
457
475
  *
458
- * The optional `data` fields are forwarded as top-level attributes in the GoTrue
459
- * request body. Accepted fields: `role`, `aud`, `app_metadata`, `user_metadata`.
476
+ * The optional `data` fields are forwarded as top-level attributes in the Identity API
477
+ * request body. Accepted fields: `role`, `app_metadata`, `user_metadata`.
460
478
  * Any other keys in `data` are silently ignored. `data` cannot override `email`,
461
479
  * `password`, or `confirm`.
462
480
  *
463
- * Calls GoTrue `POST /admin/users` with the operator token.
481
+ * Calls `POST /admin/users` with the operator token.
464
482
  *
465
483
  * @throws {AuthError} If called from a browser, the email already exists,
466
484
  * or the operator token is missing.
@@ -469,7 +487,7 @@ interface Admin {
469
487
  /**
470
488
  * Updates an existing user by ID. Server-only.
471
489
  *
472
- * Calls GoTrue `PUT /admin/users/:id` with the operator token.
490
+ * Calls `PUT /admin/users/:id` with the operator token.
473
491
  *
474
492
  * @throws {AuthError} If called from a browser, the user is not found,
475
493
  * the update fails, or the operator token is missing.
@@ -478,7 +496,7 @@ interface Admin {
478
496
  /**
479
497
  * Deletes a user by ID. Server-only.
480
498
  *
481
- * Calls GoTrue `DELETE /admin/users/:id` with the operator token.
499
+ * Calls `DELETE /admin/users/:id` with the operator token.
482
500
  *
483
501
  * @throws {AuthError} If called from a browser, the user is not found,
484
502
  * the deletion fails, or the operator token is missing.
package/dist/index.d.ts CHANGED
@@ -1,10 +1,10 @@
1
1
  /** The supported OAuth and authentication providers. */
2
- declare const AUTH_PROVIDERS: readonly ["google", "github", "gitlab", "bitbucket", "facebook", "saml", "email"];
2
+ declare const AUTH_PROVIDERS: readonly ["google", "github", "gitlab", "bitbucket", "facebook", "email"];
3
3
  /** A supported authentication provider name (e.g., `'google'`, `'github'`, `'email'`). */
4
4
  type AuthProvider = (typeof AUTH_PROVIDERS)[number];
5
5
  /**
6
6
  * Provider and role metadata stored in a user's `app_metadata` field.
7
- * GoTrue sets `provider` automatically on signup; `roles` controls authorization.
7
+ * The `provider` field is set automatically on signup; `roles` controls authorization.
8
8
  * Additional keys may be present depending on your Identity configuration.
9
9
  *
10
10
  * @example
@@ -27,7 +27,7 @@ interface AppMetadata {
27
27
  * On the server, `token` is the operator token for admin operations.
28
28
  */
29
29
  interface IdentityConfig {
30
- /** The GoTrue API endpoint URL (e.g., `https://example.com/.netlify/identity`). */
30
+ /** The Identity API endpoint URL (e.g., `https://example.com/.netlify/identity`). */
31
31
  url: string;
32
32
  /** Operator token for server-side admin requests. Only available in Netlify Functions. */
33
33
  token?: string;
@@ -86,8 +86,6 @@ interface AdminUserUpdates {
86
86
  password?: string;
87
87
  /** The user's role (e.g., `'admin'`, `'editor'`). */
88
88
  role?: string;
89
- /** The user's audience (rarely needed; defaults to the site's audience). */
90
- aud?: string;
91
89
  /** Set to `true` to force-confirm the user's email without sending a confirmation email. */
92
90
  confirm?: boolean;
93
91
  /** Server-managed metadata. Only writable via admin operations. */
@@ -107,8 +105,8 @@ interface ListUsersOptions {
107
105
  /**
108
106
  * Parameters for {@link admin.createUser}.
109
107
  *
110
- * The optional `data` fields are forwarded as top-level attributes in the GoTrue
111
- * request body. Only these keys are accepted: `role`, `aud`, `app_metadata`,
108
+ * The optional `data` fields are forwarded as top-level attributes in the Identity API
109
+ * request body. Only these keys are accepted: `role`, `app_metadata`,
112
110
  * `user_metadata`. Any other keys are silently ignored. `data` cannot override
113
111
  * `email`, `password`, or `confirm`.
114
112
  *
@@ -124,14 +122,18 @@ interface ListUsersOptions {
124
122
  interface CreateUserParams {
125
123
  email: string;
126
124
  password: string;
127
- /** GoTrue user fields: `role`, `aud`, `app_metadata`, `user_metadata`. Other keys are ignored. */
125
+ /** Identity user fields: `role`, `app_metadata`, `user_metadata`. Other keys are ignored. */
128
126
  data?: Record<string, unknown>;
129
127
  }
130
128
 
131
129
  /**
132
130
  * A normalized user object returned by all auth and admin functions.
133
131
  * Provides a consistent shape regardless of whether the user was loaded
134
- * from gotrue-js, a JWT cookie, or the server-side identity context.
132
+ * from the Identity API, a JWT cookie, or the server-side identity context.
133
+ *
134
+ * All fields except `id` are optional and may be `undefined`. Empty strings
135
+ * are normalized to `undefined`. State-dependent fields (invite,
136
+ * recovery, email-change) are only present when the user is in that state.
135
137
  *
136
138
  * @example
137
139
  * ```ts
@@ -142,30 +144,46 @@ interface CreateUserParams {
142
144
  * ```
143
145
  */
144
146
  interface User {
145
- /** The user's unique identifier (GoTrue UUID). */
147
+ /** The user's unique identifier. */
146
148
  id: string;
147
149
  /** The user's email address. */
148
150
  email?: string;
149
- /** `true` if the user's email has been confirmed. */
150
- emailVerified?: boolean;
151
+ /** ISO 8601 timestamp of when the user's email was confirmed. `undefined` if not yet confirmed. */
152
+ confirmedAt?: string;
151
153
  /** ISO 8601 timestamp of when the account was created. */
152
154
  createdAt?: string;
153
155
  /** ISO 8601 timestamp of the last account update. */
154
156
  updatedAt?: string;
155
- /** The authentication provider used to create the account. */
157
+ /**
158
+ * The account-level role string (e.g., `"admin"`). This is a single value
159
+ * set via the admin API, distinct from `roles` which is an array in `app_metadata`.
160
+ * `undefined` when not set or empty.
161
+ */
162
+ role?: string;
163
+ /** The authentication provider used to create the account (from `app_metadata.provider`). */
156
164
  provider?: AuthProvider;
157
165
  /** Display name from `user_metadata.full_name` or `user_metadata.name`. */
158
166
  name?: string;
159
167
  /** Avatar URL from `user_metadata.avatar_url`. */
160
168
  pictureUrl?: string;
161
- /** Roles from `app_metadata.roles`, set via the admin API or Netlify UI. */
169
+ /** Application-level roles from `app_metadata.roles`, set via the admin API or Netlify UI. */
162
170
  roles?: string[];
163
- /** The full `user_metadata` object. */
164
- metadata?: Record<string, unknown>;
165
- /** The full `app_metadata` object. */
171
+ /** ISO 8601 timestamp of when the user was invited. Only present if the user was created via invitation. */
172
+ invitedAt?: string;
173
+ /** ISO 8601 timestamp of when the confirmation email was last sent. */
174
+ confirmationSentAt?: string;
175
+ /** ISO 8601 timestamp of when the recovery email was last sent. */
176
+ recoverySentAt?: string;
177
+ /** The pending email address during an email change flow. Only present while the change is awaiting confirmation. */
178
+ pendingEmail?: string;
179
+ /** ISO 8601 timestamp of when the email change verification was last sent. */
180
+ emailChangeSentAt?: string;
181
+ /** ISO 8601 timestamp of the user's most recent sign-in. */
182
+ lastSignInAt?: string;
183
+ /** Custom user metadata. Contains profile data like `full_name` and `avatar_url`, and any custom fields set via `updateUser()`. */
184
+ userMetadata?: Record<string, unknown>;
185
+ /** Application metadata managed by the server. Contains `provider`, `roles`, and other system-managed fields. */
166
186
  appMetadata?: Record<string, unknown>;
167
- /** The raw GoTrue user data, for accessing fields not mapped to this interface. */
168
- rawGoTrueData?: Record<string, unknown>;
169
187
  }
170
188
  /**
171
189
  * Returns the currently authenticated user, or `null` if not logged in.
@@ -175,11 +193,11 @@ interface User {
175
193
  * (email, roles, timestamps, metadata, etc.) regardless of whether the
176
194
  * call happens in the browser or on the server.
177
195
  *
178
- * In the browser, checks gotrue-js localStorage first. If no localStorage
196
+ * In the browser, checks localStorage first. If no localStorage
179
197
  * session exists, hydrates from the `nf_jwt` cookie (set by server-side login).
180
198
  *
181
- * On the server, fetches the full user from GoTrue using the JWT from
182
- * the request. Falls back to JWT claims if GoTrue is unreachable.
199
+ * On the server, fetches the full user from the Identity API using the JWT from
200
+ * the request. Falls back to JWT claims if the Identity API is unreachable.
183
201
  *
184
202
  * On the server in a Next.js App Router context, calls `headers()` from
185
203
  * `next/headers` to opt the route into dynamic rendering. Without this,
@@ -343,7 +361,7 @@ interface CallbackResult {
343
361
  */
344
362
  declare const handleAuthCallback: () => Promise<CallbackResult | null>;
345
363
  /**
346
- * Hydrates the browser-side gotrue-js session from server-set auth cookies.
364
+ * Hydrates the browser-side session from server-set auth cookies.
347
365
  * Call this on page load when using server-side login to enable browser
348
366
  * account operations (updateUser, verifyEmailChange, etc.).
349
367
  *
@@ -388,7 +406,7 @@ declare const refreshSession: () => Promise<string | null>;
388
406
  * Thrown by auth operations when something goes wrong: invalid credentials,
389
407
  * network failures, missing runtime context, etc.
390
408
  *
391
- * The `status` field contains the HTTP status code from GoTrue when available
409
+ * The `status` field contains the HTTP status code from the Identity API when available
392
410
  * (e.g., 401 for bad credentials, 422 for validation errors).
393
411
  * The `cause` field preserves the original error for debugging.
394
412
  *
@@ -405,7 +423,7 @@ declare const refreshSession: () => Promise<string | null>;
405
423
  */
406
424
  declare class AuthError extends Error {
407
425
  name: string;
408
- /** HTTP status code from GoTrue, if the error originated from an API response. */
426
+ /** HTTP status code from the Identity API, if the error originated from an API response. */
409
427
  status?: number;
410
428
  cause?: unknown;
411
429
  constructor(message: string, status?: number, options?: {
@@ -414,7 +432,7 @@ declare class AuthError extends Error {
414
432
  static from(error: unknown): AuthError;
415
433
  }
416
434
  /**
417
- * Thrown when a function requires a gotrue-js client but Netlify Identity
435
+ * Thrown when a function requires the Identity client but Netlify Identity
418
436
  * is not configured (no endpoint URL could be discovered).
419
437
  *
420
438
  * This typically means the site does not have Identity enabled, or the app
@@ -436,7 +454,7 @@ interface Admin {
436
454
  /**
437
455
  * Lists all users. Server-only.
438
456
  *
439
- * Calls GoTrue `GET /admin/users` with the operator token. Pagination
457
+ * Calls `GET /admin/users` with the operator token. Pagination
440
458
  * options (`page`, `perPage`) are forwarded as query parameters.
441
459
  *
442
460
  * @throws {AuthError} If called from a browser, or if the operator token is missing.
@@ -445,7 +463,7 @@ interface Admin {
445
463
  /**
446
464
  * Gets a single user by ID. Server-only.
447
465
  *
448
- * Calls GoTrue `GET /admin/users/:id` with the operator token.
466
+ * Calls `GET /admin/users/:id` with the operator token.
449
467
  *
450
468
  * @throws {AuthError} If called from a browser, the user is not found,
451
469
  * or the operator token is missing.
@@ -455,12 +473,12 @@ interface Admin {
455
473
  * Creates a new user. The user is auto-confirmed (no confirmation email is sent).
456
474
  * Server-only.
457
475
  *
458
- * The optional `data` fields are forwarded as top-level attributes in the GoTrue
459
- * request body. Accepted fields: `role`, `aud`, `app_metadata`, `user_metadata`.
476
+ * The optional `data` fields are forwarded as top-level attributes in the Identity API
477
+ * request body. Accepted fields: `role`, `app_metadata`, `user_metadata`.
460
478
  * Any other keys in `data` are silently ignored. `data` cannot override `email`,
461
479
  * `password`, or `confirm`.
462
480
  *
463
- * Calls GoTrue `POST /admin/users` with the operator token.
481
+ * Calls `POST /admin/users` with the operator token.
464
482
  *
465
483
  * @throws {AuthError} If called from a browser, the email already exists,
466
484
  * or the operator token is missing.
@@ -469,7 +487,7 @@ interface Admin {
469
487
  /**
470
488
  * Updates an existing user by ID. Server-only.
471
489
  *
472
- * Calls GoTrue `PUT /admin/users/:id` with the operator token.
490
+ * Calls `PUT /admin/users/:id` with the operator token.
473
491
  *
474
492
  * @throws {AuthError} If called from a browser, the user is not found,
475
493
  * the update fails, or the operator token is missing.
@@ -478,7 +496,7 @@ interface Admin {
478
496
  /**
479
497
  * Deletes a user by ID. Server-only.
480
498
  *
481
- * Calls GoTrue `DELETE /admin/users/:id` with the operator token.
499
+ * Calls `DELETE /admin/users/:id` with the operator token.
482
500
  *
483
501
  * @throws {AuthError} If called from a browser, the user is not found,
484
502
  * the deletion fails, or the operator token is missing.
package/dist/index.js CHANGED
@@ -6,7 +6,7 @@ var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require
6
6
  });
7
7
 
8
8
  // src/types.ts
9
- var AUTH_PROVIDERS = ["google", "github", "gitlab", "bitbucket", "facebook", "saml", "email"];
9
+ var AUTH_PROVIDERS = ["google", "github", "gitlab", "bitbucket", "facebook", "email"];
10
10
 
11
11
  // src/environment.ts
12
12
  import GoTrue from "gotrue-js";
@@ -631,6 +631,7 @@ var hydrateSession = async () => {
631
631
 
632
632
  // src/user.ts
633
633
  var toAuthProvider = (value) => typeof value === "string" && AUTH_PROVIDERS.includes(value) ? value : void 0;
634
+ var toOptionalString = (value) => typeof value === "string" && value !== "" ? value : void 0;
634
635
  var toRoles = (appMeta) => {
635
636
  const roles = appMeta.roles;
636
637
  if (Array.isArray(roles) && roles.every((r) => typeof r === "string")) {
@@ -643,20 +644,25 @@ var toUser = (userData) => {
643
644
  const appMeta = userData.app_metadata ?? {};
644
645
  const name = userMeta.full_name || userMeta.name;
645
646
  const pictureUrl = userMeta.avatar_url;
646
- const { token: _token, ...safeUserData } = userData;
647
647
  return {
648
648
  id: userData.id,
649
649
  email: userData.email,
650
- emailVerified: !!userData.confirmed_at,
650
+ confirmedAt: toOptionalString(userData.confirmed_at),
651
651
  createdAt: userData.created_at,
652
652
  updatedAt: userData.updated_at,
653
+ role: toOptionalString(userData.role),
653
654
  provider: toAuthProvider(appMeta.provider),
654
655
  name: typeof name === "string" ? name : void 0,
655
656
  pictureUrl: typeof pictureUrl === "string" ? pictureUrl : void 0,
656
657
  roles: toRoles(appMeta),
657
- metadata: userMeta,
658
- appMetadata: appMeta,
659
- rawGoTrueData: { ...safeUserData }
658
+ invitedAt: toOptionalString(userData.invited_at),
659
+ confirmationSentAt: toOptionalString(userData.confirmation_sent_at),
660
+ recoverySentAt: toOptionalString(userData.recovery_sent_at),
661
+ pendingEmail: toOptionalString(userData.new_email),
662
+ emailChangeSentAt: toOptionalString(userData.email_change_sent_at),
663
+ lastSignInAt: toOptionalString(userData.last_sign_in_at),
664
+ userMetadata: userMeta,
665
+ appMetadata: appMeta
660
666
  };
661
667
  };
662
668
  var claimsToUser = (claims) => {
@@ -671,7 +677,7 @@ var claimsToUser = (claims) => {
671
677
  name: typeof name === "string" ? name : void 0,
672
678
  pictureUrl: typeof pictureUrl === "string" ? pictureUrl : void 0,
673
679
  roles: toRoles(appMeta),
674
- metadata: userMeta,
680
+ userMetadata: userMeta,
675
681
  appMetadata: appMeta
676
682
  };
677
683
  };
@@ -768,8 +774,7 @@ var getSettings = async () => {
768
774
  gitlab: external.gitlab ?? false,
769
775
  bitbucket: external.bitbucket ?? false,
770
776
  facebook: external.facebook ?? false,
771
- email: external.email ?? false,
772
- saml: external.saml ?? false
777
+ email: external.email ?? false
773
778
  }
774
779
  };
775
780
  } catch (err) {
@@ -946,7 +951,7 @@ var createUser = async (params) => {
946
951
  confirm: true
947
952
  };
948
953
  if (params.data) {
949
- const allowedKeys = ["role", "aud", "app_metadata", "user_metadata"];
954
+ const allowedKeys = ["role", "app_metadata", "user_metadata"];
950
955
  for (const key of allowedKeys) {
951
956
  if (key in params.data) {
952
957
  body[key] = params.data[key];
@@ -964,7 +969,7 @@ var updateUser2 = async (userId, attributes) => {
964
969
  assertServer();
965
970
  const sanitizedUserId = sanitizeUserId(userId);
966
971
  const body = {};
967
- const allowedKeys = ["email", "password", "role", "aud", "confirm", "app_metadata", "user_metadata"];
972
+ const allowedKeys = ["email", "password", "role", "confirm", "app_metadata", "user_metadata"];
968
973
  for (const key of allowedKeys) {
969
974
  if (key in attributes) {
970
975
  body[key] = attributes[key];