@soroi/auth 0.1.0 → 0.1.1

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.
@@ -117,6 +117,13 @@ const migrations = [
117
117
  ],
118
118
  },
119
119
  { id: 3, statements: oauthServerTables },
120
+ {
121
+ // Apps that share the users table can tell who has a password without access to the hashes.
122
+ id: 4,
123
+ statements: (s) => [
124
+ `alter table ${s}.users add column has_password boolean not null generated always as (password_hash is not null) stored`,
125
+ ],
126
+ },
120
127
  ];
121
128
  export const latestMigration = migrations.at(-1).id;
122
129
  export async function appliedMigration(db, s) {
@@ -13,6 +13,8 @@ export type Member = {
13
13
  user: Pick<User, "id" | "email" | "name" | "image">;
14
14
  role: string;
15
15
  joinedAt: Date;
16
+ /** The colour the member picked for this workspace, or null for automatic. */
17
+ color: string | null;
16
18
  };
17
19
  export type Invite = {
18
20
  email: string;
@@ -126,13 +126,15 @@ export async function remove(core, ctx, input = {}) {
126
126
  }
127
127
  export async function members(core, ctx, input = {}) {
128
128
  const { workspace } = await resolve(core, ctx, input?.workspaceId);
129
- const rows = await core.db.query(`select u.id::text, u.email, u.name, u.image, m.role, m.created_at from ${core.s}.members m
129
+ // Soroi Account adds the color column. to_jsonb reads it, and gives null where it does not exist.
130
+ const rows = await core.db.query(`select u.id::text, u.email, u.name, u.image, m.role, m.created_at, to_jsonb(m)->>'color' as color from ${core.s}.members m
130
131
  join ${core.s}.users u on u.id = m.user_id where m.workspace_id = $1::uuid order by m.created_at`, [workspace.id]);
131
132
  return rows
132
133
  .map((row) => ({
133
134
  user: { id: row.id, email: row.email, name: row.name, image: row.image },
134
135
  role: row.role,
135
136
  joinedAt: new Date(row.created_at),
137
+ color: row.color,
136
138
  }))
137
139
  .sort((a, b) => rank(core, a.role) - rank(core, b.role));
138
140
  }
package/dist/sessions.js CHANGED
@@ -5,7 +5,7 @@ import { AuthException } from "./errors.js";
5
5
  const DAY = 86_400;
6
6
  const CHALLENGE_SECONDS = 600;
7
7
  export const userColumns = (a) => `${a}.id::text as u_id, ${a}.email as u_email, ${a}.email_verified_at is not null as u_verified,
8
- ${a}.name as u_name, ${a}.image as u_image, ${a}.password_hash is not null as u_has_password,
8
+ ${a}.name as u_name, ${a}.image as u_image, ${a}.has_password as u_has_password,
9
9
  ${a}.created_at as u_created_at`;
10
10
  export const toUser = (row) => ({
11
11
  id: String(row.u_id),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@soroi/auth",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
4
  "description": "Framework-agnostic, server-only auth for TypeScript apps. No UI, no client SDK, no runtime dependencies.",
5
5
  "license": "MIT",
6
6
  "homepage": "https://auth.kaarel.dev",