@absolutejs/auth 0.27.0-beta.9 → 0.27.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.
@@ -6,6 +6,12 @@ export type OidcProviderConfig<UserType> = {
6
6
  accessTokenTtlMs?: number;
7
7
  authorizationCodeStore: AuthorizationCodeStore;
8
8
  clientStore: OAuthClientStore;
9
+ getAccessTokenClaims?: (context: {
10
+ audience?: string;
11
+ clientId: string;
12
+ scopes: string[];
13
+ sub: string;
14
+ }) => Record<string, unknown> | Promise<Record<string, unknown>>;
9
15
  getClaims?: (user: UserType) => Record<string, unknown>;
10
16
  getGrantedScopes?: (context: {
11
17
  client: {
@@ -27,9 +27,9 @@ export declare const oidcProviderRoutes: <UserType>(config: OidcProviderConfig<U
27
27
  body: unknown;
28
28
  params: {};
29
29
  query: {
30
- nonce?: string | undefined;
31
30
  client_id?: string | undefined;
32
31
  scope?: string | undefined;
32
+ nonce?: string | undefined;
33
33
  code_challenge?: string | undefined;
34
34
  code_challenge_method?: string | undefined;
35
35
  redirect_uri?: string | undefined;
@@ -55,10 +55,10 @@ export declare const oidcProviderRoutes: <UserType>(config: OidcProviderConfig<U
55
55
  [x: string]: {
56
56
  post: {
57
57
  body: {
58
- audience?: string | undefined;
59
- resource?: string | undefined;
60
58
  client_id?: string | undefined;
61
59
  scope?: string | undefined;
60
+ audience?: string | undefined;
61
+ resource?: string | undefined;
62
62
  refresh_token?: string | undefined;
63
63
  client_secret?: string | undefined;
64
64
  grant_type?: string | undefined;
@@ -5,6 +5,13 @@ export declare const acceptInvitation: ({ organizationStore, token, userId }: {
5
5
  token: string;
6
6
  userId: string;
7
7
  }) => Promise<OrganizationMembership | undefined>;
8
+ export declare const autoAssignOrgsByEmail: ({ email, getOrgsForDomain, organizationStore, roles, userId }: {
9
+ email: string;
10
+ getOrgsForDomain: (domain: string) => Promise<OrganizationId[]> | OrganizationId[];
11
+ organizationStore: OrganizationStore;
12
+ roles?: string[];
13
+ userId: string;
14
+ }) => Promise<string[]>;
8
15
  export declare const createOrganization: ({ metadata, name, organizationStore, ownerRoles, ownerUserId }: {
9
16
  metadata?: Record<string, unknown>;
10
17
  name: string;
@@ -0,0 +1,20 @@
1
+ import { type SecretCipher } from '../compliance/cipher';
2
+ import type { VaultStore } from './types';
3
+ export type Vault = {
4
+ delete: (ownerId: string, name: string) => Promise<void>;
5
+ get: (ownerId: string, name: string) => Promise<string | undefined>;
6
+ list: (ownerId: string) => Promise<string[]>;
7
+ put: (ownerId: string, name: string, value: string) => Promise<void>;
8
+ };
9
+ export declare const createVault: ({ cipher, store }: {
10
+ cipher: SecretCipher;
11
+ store: VaultStore;
12
+ }) => Vault;
13
+ export type VaultKeyRotationResult = {
14
+ rotated: number;
15
+ };
16
+ export declare const rotateVaultKey: ({ newKey, oldKey, store }: {
17
+ newKey: string;
18
+ oldKey: string;
19
+ store: VaultStore;
20
+ }) => Promise<VaultKeyRotationResult>;
@@ -0,0 +1,2 @@
1
+ import type { VaultStore } from './types';
2
+ export declare const createInMemoryVaultStore: () => VaultStore;
@@ -0,0 +1,100 @@
1
+ import { type AnyPgDatabase } from '../stores/postgres';
2
+ import type { VaultStore } from './types';
3
+ export declare const vaultEntriesTable: import("drizzle-orm/pg-core").PgTableWithColumns<{
4
+ name: "auth_vault_entries";
5
+ schema: undefined;
6
+ columns: {
7
+ created_at_ms: import("drizzle-orm/pg-core").PgColumn<{
8
+ name: "created_at_ms";
9
+ tableName: "auth_vault_entries";
10
+ dataType: "number";
11
+ columnType: "PgBigInt53";
12
+ data: number;
13
+ driverParam: string | number;
14
+ notNull: true;
15
+ hasDefault: false;
16
+ isPrimaryKey: false;
17
+ isAutoincrement: false;
18
+ hasRuntimeDefault: false;
19
+ enumValues: undefined;
20
+ baseColumn: never;
21
+ identity: undefined;
22
+ generated: undefined;
23
+ }, {}, {}>;
24
+ encrypted_value: import("drizzle-orm/pg-core").PgColumn<{
25
+ name: "encrypted_value";
26
+ tableName: "auth_vault_entries";
27
+ dataType: "string";
28
+ columnType: "PgText";
29
+ data: string;
30
+ driverParam: string;
31
+ notNull: true;
32
+ hasDefault: false;
33
+ isPrimaryKey: false;
34
+ isAutoincrement: false;
35
+ hasRuntimeDefault: false;
36
+ enumValues: [string, ...string[]];
37
+ baseColumn: never;
38
+ identity: undefined;
39
+ generated: undefined;
40
+ }, {}, {}>;
41
+ name: import("drizzle-orm/pg-core").PgColumn<{
42
+ name: "name";
43
+ tableName: "auth_vault_entries";
44
+ dataType: "string";
45
+ columnType: "PgVarchar";
46
+ data: string;
47
+ driverParam: string;
48
+ notNull: true;
49
+ hasDefault: false;
50
+ isPrimaryKey: false;
51
+ isAutoincrement: false;
52
+ hasRuntimeDefault: false;
53
+ enumValues: [string, ...string[]];
54
+ baseColumn: never;
55
+ identity: undefined;
56
+ generated: undefined;
57
+ }, {}, {
58
+ length: 255;
59
+ }>;
60
+ owner_id: import("drizzle-orm/pg-core").PgColumn<{
61
+ name: "owner_id";
62
+ tableName: "auth_vault_entries";
63
+ dataType: "string";
64
+ columnType: "PgVarchar";
65
+ data: string;
66
+ driverParam: string;
67
+ notNull: true;
68
+ hasDefault: false;
69
+ isPrimaryKey: false;
70
+ isAutoincrement: false;
71
+ hasRuntimeDefault: false;
72
+ enumValues: [string, ...string[]];
73
+ baseColumn: never;
74
+ identity: undefined;
75
+ generated: undefined;
76
+ }, {}, {
77
+ length: 255;
78
+ }>;
79
+ updated_at_ms: import("drizzle-orm/pg-core").PgColumn<{
80
+ name: "updated_at_ms";
81
+ tableName: "auth_vault_entries";
82
+ dataType: "number";
83
+ columnType: "PgBigInt53";
84
+ data: number;
85
+ driverParam: string | number;
86
+ notNull: true;
87
+ hasDefault: false;
88
+ isPrimaryKey: false;
89
+ isAutoincrement: false;
90
+ hasRuntimeDefault: false;
91
+ enumValues: undefined;
92
+ baseColumn: never;
93
+ identity: undefined;
94
+ generated: undefined;
95
+ }, {}, {}>;
96
+ };
97
+ dialect: "pg";
98
+ }>;
99
+ export declare const createNeonVaultStore: (databaseUrl: string) => VaultStore;
100
+ export declare const createPostgresVaultStore: (db: AnyPgDatabase) => VaultStore;
@@ -0,0 +1,14 @@
1
+ export type VaultEntry = {
2
+ createdAt: number;
3
+ encryptedValue: string;
4
+ name: string;
5
+ ownerId: string;
6
+ updatedAt: number;
7
+ };
8
+ export type VaultStore = {
9
+ deleteEntry: (ownerId: string, name: string) => Promise<void>;
10
+ getEntry: (ownerId: string, name: string) => Promise<VaultEntry | undefined>;
11
+ listAllEntries: () => Promise<VaultEntry[]>;
12
+ listEntries: (ownerId: string) => Promise<VaultEntry[]>;
13
+ saveEntry: (entry: VaultEntry) => Promise<void>;
14
+ };
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "0.27.0-beta.9",
2
+ "version": "0.27.0",
3
3
  "name": "@absolutejs/auth",
4
4
  "description": "An authorization library for absolutejs",
5
5
  "repository": {
@@ -10,7 +10,7 @@
10
10
  "license": "CC BY-NC 4.0",
11
11
  "author": "Alex Kahn",
12
12
  "scripts": {
13
- "build": "rm -rf dist && bun build src/index.ts src/htmx/index.ts --outdir dist --sourcemap --target=bun --external elysia && tsc --emitDeclarationOnly --project tsconfig.json",
13
+ "build": "rm -rf dist && bun build src/index.ts src/htmx/index.ts src/client/index.ts src/client/react.ts --outdir dist --sourcemap --target=bun --external elysia --external react && tsc --emitDeclarationOnly --project tsconfig.json",
14
14
  "config": "absolute config",
15
15
  "test": "bun test",
16
16
  "format": "absolute prettier --write",
@@ -27,7 +27,13 @@
27
27
  ],
28
28
  "types": "./dist/index.d.ts",
29
29
  "peerDependencies": {
30
- "elysia": ">= 1.4.26"
30
+ "elysia": ">= 1.4.26",
31
+ "react": ">=18 <20"
32
+ },
33
+ "peerDependenciesMeta": {
34
+ "react": {
35
+ "optional": true
36
+ }
31
37
  },
32
38
  "dependencies": {
33
39
  "@absolutejs/linked-providers": "0.0.2",
@@ -40,6 +46,7 @@
40
46
  "@eslint/js": "^10.0.1",
41
47
  "@stylistic/eslint-plugin": "^5.10.0",
42
48
  "@types/bun": "1.2.9",
49
+ "@types/react": "^19.0.0",
43
50
  "@typescript-eslint/parser": "^8.57.2",
44
51
  "elysia": "1.4.26",
45
52
  "eslint": "^10.1.0",
@@ -57,9 +64,17 @@
57
64
  "import": "./dist/index.js",
58
65
  "types": "./dist/index.d.ts"
59
66
  },
67
+ "./client": {
68
+ "import": "./dist/client/index.js",
69
+ "types": "./dist/client/index.d.ts"
70
+ },
60
71
  "./htmx": {
61
72
  "import": "./dist/htmx/index.js",
62
73
  "types": "./dist/htmx/index.d.ts"
74
+ },
75
+ "./react": {
76
+ "import": "./dist/client/react.js",
77
+ "types": "./dist/client/react.d.ts"
63
78
  }
64
79
  },
65
80
  "type": "module",