@entro314labs/entro-auth-iris 1.8.0-beta.11 → 1.8.0-beta.12
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.mts +11 -1
- package/dist/index.mjs +11 -5
- package/package.json +4 -4
package/dist/index.d.mts
CHANGED
|
@@ -259,6 +259,16 @@ interface AccountSecurityOptions {
|
|
|
259
259
|
revokeOtherSessions?: boolean;
|
|
260
260
|
/** How a date reads beside a session or a passkey. */
|
|
261
261
|
formatDate?: (date: Date) => string;
|
|
262
|
+
/**
|
|
263
|
+
* How a session is named from what its user agent tells: "Chrome on macOS"
|
|
264
|
+
* when left out. Either part is missing when it could not be told.
|
|
265
|
+
*/
|
|
266
|
+
formatDevice?: (device: SessionDevice) => string;
|
|
267
|
+
}
|
|
268
|
+
/** The browser and the system of a session, as far as its user agent tells them. */
|
|
269
|
+
interface SessionDevice {
|
|
270
|
+
browser?: string;
|
|
271
|
+
system?: string;
|
|
262
272
|
}
|
|
263
273
|
/**
|
|
264
274
|
* Loads what the Iris UI `AccountSecurity` block draws, for the sections
|
|
@@ -661,4 +671,4 @@ interface SignUpHandlers {
|
|
|
661
671
|
* ```
|
|
662
672
|
*/
|
|
663
673
|
export declare function signUpHandlers(client: SignUpClient, options?: SignUpHandlerOptions): SignUpHandlers;
|
|
664
|
-
export type { AccountProfileClient, AccountProfileData, AccountProfileHandlers, AccountProfileOptions, AccountSecurityClient, AccountSecurityData, AccountSecurityHandlers, AccountSecurityOptions, AccountSecuritySection, AuthAccount, AuthProvider, AuthResult, OrganizationMembersClient, OrganizationMembersData, OrganizationMembersHandlers, OrganizationMembersOptions, OrganizationSwitcherClient, OrganizationSwitcherData, OrganizationSwitcherHandlers, ResetPasswordClient, ResetPasswordHandlers, SecondFactorMethod, SignInClient, SignInHandlerOptions, SignInHandlers, SignInMethod, SignUpClient, SignUpHandlerOptions, SignUpHandlers, SignUpResult, SignupDetails, TwoFactorMethod };
|
|
674
|
+
export type { AccountProfileClient, AccountProfileData, AccountProfileHandlers, AccountProfileOptions, AccountSecurityClient, AccountSecurityData, AccountSecurityHandlers, AccountSecurityOptions, AccountSecuritySection, AuthAccount, AuthProvider, AuthResult, OrganizationMembersClient, OrganizationMembersData, OrganizationMembersHandlers, OrganizationMembersOptions, OrganizationSwitcherClient, OrganizationSwitcherData, OrganizationSwitcherHandlers, ResetPasswordClient, ResetPasswordHandlers, SecondFactorMethod, SessionDevice, SignInClient, SignInHandlerOptions, SignInHandlers, SignInMethod, SignUpClient, SignUpHandlerOptions, SignUpHandlers, SignUpResult, SignupDetails, TwoFactorMethod };
|
package/dist/index.mjs
CHANGED
|
@@ -201,11 +201,16 @@ const systems = [
|
|
|
201
201
|
[/Mac OS X/, "macOS"],
|
|
202
202
|
[/Linux/, "Linux"]
|
|
203
203
|
];
|
|
204
|
-
/**
|
|
205
|
-
function
|
|
204
|
+
/** The browser and the system in a user agent, as far as they can be told. */
|
|
205
|
+
function deviceOf(userAgent) {
|
|
206
206
|
const find = (table) => table.find(([pattern]) => pattern.test(userAgent ?? ""))?.[1];
|
|
207
|
-
|
|
208
|
-
|
|
207
|
+
return {
|
|
208
|
+
browser: find(browsers),
|
|
209
|
+
system: find(systems)
|
|
210
|
+
};
|
|
211
|
+
}
|
|
212
|
+
/** "Chrome on macOS". */
|
|
213
|
+
function deviceName({ browser, system }) {
|
|
209
214
|
if (browser && system) return `${browser} on ${system}`;
|
|
210
215
|
return browser ?? system ?? "Unknown device";
|
|
211
216
|
}
|
|
@@ -217,6 +222,7 @@ const providerNames = new Map(Object.entries(providerIds).map(([name, id]) => [i
|
|
|
217
222
|
async function loadAccountSecurity(client, options) {
|
|
218
223
|
const shows = (section) => options.sections.includes(section);
|
|
219
224
|
const formatDate = options.formatDate ?? ((date) => date.toLocaleDateString());
|
|
225
|
+
const formatDevice = options.formatDevice ?? deviceName;
|
|
220
226
|
const data = {};
|
|
221
227
|
const current = unwrap(await client.getSession());
|
|
222
228
|
const listPasskeys = async () => unwrap(await need(client.passkey, "passkeyClient").listUserPasskeys()) ?? [];
|
|
@@ -233,7 +239,7 @@ async function loadAccountSecurity(client, options) {
|
|
|
233
239
|
}));
|
|
234
240
|
if (shows("sessions")) data.sessions = (unwrap(await client.listSessions()) ?? []).map((session) => ({
|
|
235
241
|
id: session.token,
|
|
236
|
-
device:
|
|
242
|
+
device: formatDevice(deviceOf(session.userAgent)),
|
|
237
243
|
detail: [session.ipAddress, formatDate(new Date(session.updatedAt))].filter(Boolean).join(" · "),
|
|
238
244
|
current: session.token === current?.session.token
|
|
239
245
|
}));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@entro314labs/entro-auth-iris",
|
|
3
|
-
"version": "1.8.0-beta.
|
|
3
|
+
"version": "1.8.0-beta.12",
|
|
4
4
|
"description": "Handlers that connect an Entro Auth client to the Iris UI sign-in blocks",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -36,9 +36,9 @@
|
|
|
36
36
|
},
|
|
37
37
|
"devDependencies": {
|
|
38
38
|
"@better-auth/utils": "0.5.1",
|
|
39
|
-
"@entro314labs/entro-auth-core": "1.8.0-beta.
|
|
40
|
-
"@entro314labs/entro-auth-passkey": "1.8.0-beta.
|
|
41
|
-
"@entro314labs/entro-auth": "1.8.0-beta.
|
|
39
|
+
"@entro314labs/entro-auth-core": "1.8.0-beta.12",
|
|
40
|
+
"@entro314labs/entro-auth-passkey": "1.8.0-beta.12",
|
|
41
|
+
"@entro314labs/entro-auth": "1.8.0-beta.12",
|
|
42
42
|
"happy-dom": "^21.0.4",
|
|
43
43
|
"tsdown": "0.23.1",
|
|
44
44
|
"typescript": "^6.0.3"
|