@wrelik/auth 2.0.0 → 3.0.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.
- package/.turbo/turbo-build.log +24 -24
- package/.turbo/turbo-lint.log +4 -0
- package/.turbo/turbo-test.log +16 -0
- package/.turbo/turbo-typecheck.log +4 -0
- package/CHANGELOG.md +37 -0
- package/dist/server/index.d.mts +7 -3
- package/dist/server/index.d.ts +7 -3
- package/dist/server/index.js +3 -3
- package/dist/server/index.mjs +8 -4
- package/package.json +12 -8
- package/src/server/index.test.ts +4 -4
- package/src/server/index.ts +19 -8
- package/tsconfig.json +3 -1
package/.turbo/turbo-build.log
CHANGED
|
@@ -1,27 +1,27 @@
|
|
|
1
1
|
|
|
2
|
-
> @wrelik/auth@
|
|
2
|
+
> @wrelik/auth@3.0.1 build /Users/lee/Projects/wrelik-kit/packages/auth
|
|
3
3
|
> tsup src/server/index.ts src/client/index.ts src/shared/index.ts --format cjs,esm --dts --clean
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
5
|
+
CLI Building entry: src/shared/index.ts, src/client/index.ts, src/server/index.ts
|
|
6
|
+
CLI Using tsconfig: tsconfig.json
|
|
7
|
+
CLI tsup v8.5.1
|
|
8
|
+
CLI Target: es2019
|
|
9
|
+
CLI Cleaning output folder
|
|
10
|
+
CJS Build start
|
|
11
|
+
ESM Build start
|
|
12
|
+
CJS dist/client/index.js 1.62 KB
|
|
13
|
+
CJS dist/server/index.js 2.72 KB
|
|
14
|
+
CJS dist/shared/index.js 767.00 B
|
|
15
|
+
CJS ⚡️ Build success in 201ms
|
|
16
|
+
ESM dist/shared/index.mjs 0 B
|
|
17
|
+
ESM dist/server/index.mjs 1.55 KB
|
|
18
|
+
ESM dist/client/index.mjs 631.00 B
|
|
19
|
+
ESM ⚡️ Build success in 201ms
|
|
20
|
+
DTS Build start
|
|
21
|
+
DTS ⚡️ Build success in 3429ms
|
|
22
|
+
DTS dist/client/index.d.ts 155.00 B
|
|
23
|
+
DTS dist/server/index.d.ts 701.00 B
|
|
24
|
+
DTS dist/shared/index.d.ts 479.00 B
|
|
25
|
+
DTS dist/client/index.d.mts 156.00 B
|
|
26
|
+
DTS dist/server/index.d.mts 702.00 B
|
|
27
|
+
DTS dist/shared/index.d.mts 479.00 B
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
|
|
2
|
+
> @wrelik/auth@3.0.0 test /Users/lee/Projects/wrelik-kit/packages/auth
|
|
3
|
+
> vitest run --passWithNoTests
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
[1m[30m[46m RUN [49m[39m[22m [36mv4.1.9 [39m[90m/Users/lee/Projects/wrelik-kit/packages/auth[39m
|
|
7
|
+
|
|
8
|
+
[32m✓[39m src/client/index.contract.test.ts [2m([22m[2m1 test[22m[2m)[22m[32m 4[2mms[22m[39m
|
|
9
|
+
[32m✓[39m src/client/index.test.ts [2m([22m[2m2 tests[22m[2m)[22m[32m 6[2mms[22m[39m
|
|
10
|
+
[32m✓[39m src/server/index.test.ts [2m([22m[2m6 tests[22m[2m)[22m[32m 12[2mms[22m[39m
|
|
11
|
+
|
|
12
|
+
[2m Test Files [22m [1m[32m3 passed[39m[22m[90m (3)[39m
|
|
13
|
+
[2m Tests [22m [1m[32m9 passed[39m[22m[90m (9)[39m
|
|
14
|
+
[2m Start at [22m 15:16:09
|
|
15
|
+
[2m Duration [22m 945ms[2m (transform 886ms, setup 0ms, import 1.12s, tests 22ms, environment 0ms)[22m
|
|
16
|
+
|
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,42 @@
|
|
|
1
1
|
# @wrelik/auth
|
|
2
2
|
|
|
3
|
+
## 3.0.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 8083eb8: chore(deps): bump runtime dependencies to latest compatible versions
|
|
8
|
+
|
|
9
|
+
- `posthog-node` 5.28.11 → 5.39.4 (@wrelik/analytics)
|
|
10
|
+
- `@clerk/backend` 3.2.4 → 3.10.0 (@wrelik/auth)
|
|
11
|
+
- `resend` 6.10.0 → 6.17.1 (@wrelik/email)
|
|
12
|
+
- `@sentry/browser` + `@sentry/node` 10.47.0 → 10.63.0 (@wrelik/errors)
|
|
13
|
+
- `inngest` 4.1.2 → 4.11.0 (@wrelik/jobs)
|
|
14
|
+
- `@aws-sdk/client-s3` + `@aws-sdk/s3-request-presigner` 3.1023.0 → 3.1079.0 (@wrelik/storage)
|
|
15
|
+
|
|
16
|
+
No breaking changes. Workspace tooling also updated: turbo 2.10.3, typescript 6.0.3,
|
|
17
|
+
eslint 10.6.0, prettier 3.9.4, @changesets/cli 2.31.0, dependency-cruiser 18.0.0,
|
|
18
|
+
vitest 4.1.9, @types/node 26.x (all devDependencies, no changeset required).
|
|
19
|
+
|
|
20
|
+
- Updated dependencies [8083eb8]
|
|
21
|
+
- @wrelik/errors@2.0.2
|
|
22
|
+
|
|
23
|
+
## 3.0.0
|
|
24
|
+
|
|
25
|
+
### Major Changes
|
|
26
|
+
|
|
27
|
+
- 3262454: Upgrade runtime SDK and workspace tooling dependencies to latest compatible versions, including Clerk, Sentry, AWS SDK, Inngest, Resend, Upstash, Zod, TypeScript, Turbo, Vitest, TSUP, and ESLint.
|
|
28
|
+
|
|
29
|
+
Adopt root ESLint flat config and align wrapper peer ranges for updated SDK majors while preserving package export paths. Also apply a patched transitive Next.js resolution to close audit findings and keep production audit clean.
|
|
30
|
+
|
|
31
|
+
Note: Vite is pinned to the latest 7.x line for runtime compatibility in this environment; this avoids current rolldown native-binding failures seen with Vite 8 under Node 20.18.0.
|
|
32
|
+
|
|
33
|
+
Breaking change: `@wrelik/auth` and `@wrelik/clerk-next` now require `@clerk/nextjs@7.x` via updated peer ranges (`>=7 <8`). Consumers on Clerk v4-v6 must upgrade to Clerk v7 before adopting these versions.
|
|
34
|
+
|
|
35
|
+
### Patch Changes
|
|
36
|
+
|
|
37
|
+
- Updated dependencies [3262454]
|
|
38
|
+
- @wrelik/errors@2.0.1
|
|
39
|
+
|
|
3
40
|
## 2.0.0
|
|
4
41
|
|
|
5
42
|
### Major Changes
|
package/dist/server/index.d.mts
CHANGED
|
@@ -1,8 +1,12 @@
|
|
|
1
|
-
import { SignedInAuthObject, SignedOutAuthObject } from '@clerk/backend';
|
|
2
1
|
import { WorkflowSession } from '../shared/index.mjs';
|
|
3
2
|
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
type ClerkAuthLike = {
|
|
4
|
+
userId: string | null;
|
|
5
|
+
orgId?: string | null;
|
|
6
|
+
sessionClaims?: unknown;
|
|
7
|
+
};
|
|
8
|
+
declare function fromClerkAuth(clerkAuth: ClerkAuthLike | null): WorkflowSession;
|
|
9
|
+
declare function getSession(): Promise<WorkflowSession>;
|
|
6
10
|
declare function requireUser(session: WorkflowSession | null): string;
|
|
7
11
|
declare function requireTenant(session: WorkflowSession | null): string;
|
|
8
12
|
declare function hasRole(session: WorkflowSession | null, role: string): boolean;
|
package/dist/server/index.d.ts
CHANGED
|
@@ -1,8 +1,12 @@
|
|
|
1
|
-
import { SignedInAuthObject, SignedOutAuthObject } from '@clerk/backend';
|
|
2
1
|
import { WorkflowSession } from '../shared/index.js';
|
|
3
2
|
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
type ClerkAuthLike = {
|
|
4
|
+
userId: string | null;
|
|
5
|
+
orgId?: string | null;
|
|
6
|
+
sessionClaims?: unknown;
|
|
7
|
+
};
|
|
8
|
+
declare function fromClerkAuth(clerkAuth: ClerkAuthLike | null): WorkflowSession;
|
|
9
|
+
declare function getSession(): Promise<WorkflowSession>;
|
|
6
10
|
declare function requireUser(session: WorkflowSession | null): string;
|
|
7
11
|
declare function requireTenant(session: WorkflowSession | null): string;
|
|
8
12
|
declare function hasRole(session: WorkflowSession | null, role: string): boolean;
|
package/dist/server/index.js
CHANGED
|
@@ -28,7 +28,7 @@ __export(server_exports, {
|
|
|
28
28
|
requireUser: () => requireUser
|
|
29
29
|
});
|
|
30
30
|
module.exports = __toCommonJS(server_exports);
|
|
31
|
-
var
|
|
31
|
+
var import_server = require("@clerk/nextjs/server");
|
|
32
32
|
var import_shared = require("@wrelik/errors/shared");
|
|
33
33
|
function normalizeRoles(value) {
|
|
34
34
|
if (!Array.isArray(value)) {
|
|
@@ -49,8 +49,8 @@ function fromClerkAuth(clerkAuth) {
|
|
|
49
49
|
roles: normalizeRoles((_c = claims.publicMetadata) == null ? void 0 : _c.roles)
|
|
50
50
|
};
|
|
51
51
|
}
|
|
52
|
-
function getSession() {
|
|
53
|
-
return fromClerkAuth((0,
|
|
52
|
+
async function getSession() {
|
|
53
|
+
return fromClerkAuth(await (0, import_server.auth)());
|
|
54
54
|
}
|
|
55
55
|
function requireUser(session) {
|
|
56
56
|
if (!(session == null ? void 0 : session.userId)) {
|
package/dist/server/index.mjs
CHANGED
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
// src/server/index.ts
|
|
2
|
-
import { auth } from "@clerk/nextjs";
|
|
3
|
-
import {
|
|
2
|
+
import { auth } from "@clerk/nextjs/server";
|
|
3
|
+
import {
|
|
4
|
+
AuthRequiredError,
|
|
5
|
+
PermissionDeniedError,
|
|
6
|
+
TenantRequiredError
|
|
7
|
+
} from "@wrelik/errors/shared";
|
|
4
8
|
function normalizeRoles(value) {
|
|
5
9
|
if (!Array.isArray(value)) {
|
|
6
10
|
return [];
|
|
@@ -20,8 +24,8 @@ function fromClerkAuth(clerkAuth) {
|
|
|
20
24
|
roles: normalizeRoles((_c = claims.publicMetadata) == null ? void 0 : _c.roles)
|
|
21
25
|
};
|
|
22
26
|
}
|
|
23
|
-
function getSession() {
|
|
24
|
-
return fromClerkAuth(auth());
|
|
27
|
+
async function getSession() {
|
|
28
|
+
return fromClerkAuth(await auth());
|
|
25
29
|
}
|
|
26
30
|
function requireUser(session) {
|
|
27
31
|
if (!(session == null ? void 0 : session.userId)) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wrelik/auth",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "3.0.1",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
@@ -29,17 +29,21 @@
|
|
|
29
29
|
"./package.json": "./package.json"
|
|
30
30
|
},
|
|
31
31
|
"dependencies": {
|
|
32
|
-
"@clerk/backend": "^
|
|
33
|
-
"@wrelik/errors": "2.0.
|
|
32
|
+
"@clerk/backend": "^3.10.0",
|
|
33
|
+
"@wrelik/errors": "2.0.2"
|
|
34
34
|
},
|
|
35
35
|
"peerDependencies": {
|
|
36
|
-
"@clerk/nextjs": "
|
|
36
|
+
"@clerk/nextjs": ">=7 <8"
|
|
37
37
|
},
|
|
38
38
|
"devDependencies": {
|
|
39
|
-
"
|
|
40
|
-
"
|
|
41
|
-
"
|
|
42
|
-
"
|
|
39
|
+
"@clerk/nextjs": "^7.5.12",
|
|
40
|
+
"@types/node": "^26.1.0",
|
|
41
|
+
"next": "15.5.14",
|
|
42
|
+
"tsup": "^8.5.1",
|
|
43
|
+
"vite": "^7.3.1",
|
|
44
|
+
"vitest": "^4.1.9",
|
|
45
|
+
"@wrelik/eslint-config": "0.1.2",
|
|
46
|
+
"@wrelik/tsconfig": "0.1.2"
|
|
43
47
|
},
|
|
44
48
|
"wrelik": {
|
|
45
49
|
"runtimes": [
|
package/src/server/index.test.ts
CHANGED
|
@@ -33,7 +33,7 @@ describe('@wrelik/auth/server', () => {
|
|
|
33
33
|
|
|
34
34
|
it('retrieves and normalizes sessions from Clerk auth()', async () => {
|
|
35
35
|
vi.resetModules();
|
|
36
|
-
vi.doMock('@clerk/nextjs', () => ({
|
|
36
|
+
vi.doMock('@clerk/nextjs/server', () => ({
|
|
37
37
|
auth: () => ({
|
|
38
38
|
userId: 'u1',
|
|
39
39
|
orgId: 'o1',
|
|
@@ -42,17 +42,17 @@ describe('@wrelik/auth/server', () => {
|
|
|
42
42
|
}));
|
|
43
43
|
|
|
44
44
|
const mod = await import('./index');
|
|
45
|
-
expect(mod.getSession()).toEqual({ userId: 'u1', tenantId: 'o1', roles: ['admin'] });
|
|
45
|
+
await expect(mod.getSession()).resolves.toEqual({ userId: 'u1', tenantId: 'o1', roles: ['admin'] });
|
|
46
46
|
});
|
|
47
47
|
|
|
48
48
|
it('returns anonymous session when Clerk auth() is signed out', async () => {
|
|
49
49
|
vi.resetModules();
|
|
50
|
-
vi.doMock('@clerk/nextjs', () => ({
|
|
50
|
+
vi.doMock('@clerk/nextjs/server', () => ({
|
|
51
51
|
auth: () => ({ userId: null, orgId: null, sessionClaims: {} }),
|
|
52
52
|
}));
|
|
53
53
|
|
|
54
54
|
const mod = await import('./index');
|
|
55
|
-
expect(mod.getSession()).toEqual({ userId: null, tenantId: null, roles: [] });
|
|
55
|
+
await expect(mod.getSession()).resolves.toEqual({ userId: null, tenantId: null, roles: [] });
|
|
56
56
|
});
|
|
57
57
|
|
|
58
58
|
it('does not expose a root package import', () => {
|
package/src/server/index.ts
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
import
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
import { auth } from '@clerk/nextjs/server';
|
|
2
|
+
import {
|
|
3
|
+
AuthRequiredError,
|
|
4
|
+
PermissionDeniedError,
|
|
5
|
+
TenantRequiredError,
|
|
6
|
+
} from '@wrelik/errors/shared';
|
|
5
7
|
import type { ClerkSessionLike, WorkflowSession } from '../shared';
|
|
6
8
|
|
|
7
9
|
function normalizeRoles(value: unknown): string[] {
|
|
@@ -12,13 +14,22 @@ function normalizeRoles(value: unknown): string[] {
|
|
|
12
14
|
return value.filter((role): role is string => typeof role === 'string');
|
|
13
15
|
}
|
|
14
16
|
|
|
15
|
-
|
|
17
|
+
type ClerkAuthLike = {
|
|
18
|
+
userId: string | null;
|
|
19
|
+
orgId?: string | null;
|
|
20
|
+
sessionClaims?: unknown;
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
export function fromClerkAuth(
|
|
24
|
+
clerkAuth: ClerkAuthLike | null,
|
|
25
|
+
): WorkflowSession {
|
|
16
26
|
if (!clerkAuth?.userId) {
|
|
17
27
|
return { userId: null, tenantId: null, roles: [] };
|
|
18
28
|
}
|
|
19
29
|
|
|
20
30
|
const authLike: ClerkSessionLike = clerkAuth;
|
|
21
|
-
const claims =
|
|
31
|
+
const claims =
|
|
32
|
+
(authLike.sessionClaims as { publicMetadata?: { roles?: unknown } } | undefined) ?? {};
|
|
22
33
|
|
|
23
34
|
return {
|
|
24
35
|
userId: clerkAuth.userId,
|
|
@@ -27,8 +38,8 @@ export function fromClerkAuth(clerkAuth: SignedInAuthObject | SignedOutAuthObjec
|
|
|
27
38
|
};
|
|
28
39
|
}
|
|
29
40
|
|
|
30
|
-
export function getSession(): WorkflowSession {
|
|
31
|
-
return fromClerkAuth(auth());
|
|
41
|
+
export async function getSession(): Promise<WorkflowSession> {
|
|
42
|
+
return fromClerkAuth(await auth());
|
|
32
43
|
}
|
|
33
44
|
|
|
34
45
|
export function requireUser(session: WorkflowSession | null): string {
|