@gopherium/react-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.
@@ -1,5 +1,5 @@
1
1
  import type { ReactNode } from 'react';
2
- import type { User } from './api';
2
+ import type { User } from './api.js';
3
3
  /**
4
4
  * Guards its children behind a login session, rendering the given login
5
5
  * screen until the user is authenticated.
package/dist/AuthGate.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import { jsx as _jsx, Fragment as _Fragment } from "react/jsx-runtime";
2
2
  // SPDX-License-Identifier: Apache-2.0
3
3
  import { useQueryClient } from '@tanstack/react-query';
4
- import { sessionQueryKey, useSession } from './session';
4
+ import { sessionQueryKey, useSession } from './session.js';
5
5
  /**
6
6
  * Guards its children behind a login session, rendering the given login
7
7
  * screen until the user is authenticated.
@@ -1,6 +1,6 @@
1
1
  // SPDX-License-Identifier: Apache-2.0
2
2
  import { z } from 'zod';
3
- import { UnauthorizedError } from '../api';
3
+ import { UnauthorizedError } from '../api.js';
4
4
  export const usersQueryKey = ['users'];
5
5
  const userSchema = z.object({
6
6
  id: z.string(),
package/dist/index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
- export { InvalidCredentialsError, RateLimitedError, UnauthorizedError, fetchSession, login, logout, } from './api';
2
- export type { User } from './api';
3
- export { AuthGate } from './AuthGate';
4
- export { isSessionRevoked } from './probe';
5
- export { createAuthQueryClient } from './queryClient';
6
- export { sessionQueryKey, useLogout, useSession } from './session';
1
+ export { InvalidCredentialsError, RateLimitedError, UnauthorizedError, fetchSession, login, logout, } from './api.js';
2
+ export type { User } from './api.js';
3
+ export { AuthGate } from './AuthGate.js';
4
+ export { isSessionRevoked } from './probe.js';
5
+ export { createAuthQueryClient } from './queryClient.js';
6
+ export { sessionQueryKey, useLogout, useSession } from './session.js';
package/dist/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  // SPDX-License-Identifier: Apache-2.0
2
- export { InvalidCredentialsError, RateLimitedError, UnauthorizedError, fetchSession, login, logout, } from './api';
3
- export { AuthGate } from './AuthGate';
4
- export { isSessionRevoked } from './probe';
5
- export { createAuthQueryClient } from './queryClient';
6
- export { sessionQueryKey, useLogout, useSession } from './session';
2
+ export { InvalidCredentialsError, RateLimitedError, UnauthorizedError, fetchSession, login, logout, } from './api.js';
3
+ export { AuthGate } from './AuthGate.js';
4
+ export { isSessionRevoked } from './probe.js';
5
+ export { createAuthQueryClient } from './queryClient.js';
6
+ export { sessionQueryKey, useLogout, useSession } from './session.js';
@@ -1,7 +1,7 @@
1
1
  // SPDX-License-Identifier: Apache-2.0
2
2
  import { MutationCache, QueryCache, QueryClient } from '@tanstack/react-query';
3
- import { UnauthorizedError } from './api';
4
- import { sessionQueryKey } from './session';
3
+ import { UnauthorizedError } from './api.js';
4
+ import { sessionQueryKey } from './session.js';
5
5
  /**
6
6
  * Builds a query client that drops the cached session whenever a query
7
7
  * or mutation fails with an UnauthorizedError so the login screen takes over.
package/dist/session.js CHANGED
@@ -1,6 +1,6 @@
1
1
  // SPDX-License-Identifier: Apache-2.0
2
2
  import { hashKey, useMutation, useQuery, useQueryClient } from '@tanstack/react-query';
3
- import { fetchSession, logout } from './api';
3
+ import { fetchSession, logout } from './api.js';
4
4
  /**
5
5
  * sessionQueryKey is the react-query key the login session is cached under.
6
6
  */
@@ -1,6 +1,6 @@
1
1
  import '@testing-library/jest-dom/vitest';
2
2
  import type { QueryClient } from '@tanstack/react-query';
3
- import type { User } from '../api';
3
+ import type { User } from '../api.js';
4
4
  export { http, HttpResponse } from 'msw';
5
5
  export declare const server: import("msw/node").SetupServer;
6
6
  /**
@@ -4,7 +4,7 @@ import { cleanup } from '@testing-library/react';
4
4
  import { HttpResponse, http } from 'msw';
5
5
  import { setupServer } from 'msw/node';
6
6
  import { afterAll, afterEach, beforeAll } from 'vitest';
7
- import { sessionQueryKey } from '../session';
7
+ import { sessionQueryKey } from '../session.js';
8
8
  export { http, HttpResponse } from 'msw';
9
9
  export const server = setupServer();
10
10
  /**
@@ -1,7 +1,7 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  // SPDX-License-Identifier: Apache-2.0
3
3
  import { Button, Stack, Text } from '@wordpress/ui';
4
- import { useLogout, useSession } from '../session';
4
+ import { useLogout, useSession } from '../session.js';
5
5
  /**
6
6
  * Renders the signed-in user's identity with a logout control, or nothing
7
7
  * without an active session.
@@ -1,4 +1,4 @@
1
- import type { User } from '../api';
1
+ import type { User } from '../api.js';
2
2
  /**
3
3
  * Renders the login form and reports the authenticated user upward.
4
4
  * @param brand - The product name shown above the form.
@@ -3,7 +3,7 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
3
  import { useMutation } from '@tanstack/react-query';
4
4
  import { Button, Card, InputControl, Stack, Text } from '@wordpress/ui';
5
5
  import { useState } from 'react';
6
- import { InvalidCredentialsError, RateLimitedError, login } from '../api';
6
+ import { InvalidCredentialsError, RateLimitedError, login } from '../api.js';
7
7
  /**
8
8
  * Maps a login attempt error to the message shown to the user.
9
9
  * @param error - The error thrown by the login attempt.
@@ -3,7 +3,7 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
3
  import { useMutation, useQueryClient } from '@tanstack/react-query';
4
4
  import { Button, InputControl, Stack, Text } from '@wordpress/ui';
5
5
  import { useState } from 'react';
6
- import { EmailTakenError, ValidationError, createUser, usersQueryKey } from '../admin';
6
+ import { EmailTakenError, ValidationError, createUser, usersQueryKey } from '../admin/index.js';
7
7
  /**
8
8
  * Maps a creation failure to the message shown under the form, surfacing
9
9
  * the backend's explanation for rejected input.
@@ -2,8 +2,8 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  // SPDX-License-Identifier: Apache-2.0
3
3
  import { useMutation, useQuery, useQueryClient } from '@tanstack/react-query';
4
4
  import { Badge, Button, Stack, Text, VisuallyHidden } from '@wordpress/ui';
5
- import { fetchUsers, setUserDisabled, usersQueryKey } from '../admin';
6
- import { useSession } from '../session';
5
+ import { fetchUsers, setUserDisabled, usersQueryKey } from '../admin/index.js';
6
+ import { useSession } from '../session.js';
7
7
  /**
8
8
  * Renders one user row with status and a disable toggle, hidden for the
9
9
  * signed-in account.
@@ -1,5 +1,5 @@
1
- export { AccountPanel } from './AccountPanel';
2
- export { LoginScreen } from './LoginScreen';
3
- export { usersNavItem } from './nav';
4
- export { NewUserScreen } from './NewUserScreen';
5
- export { UsersScreen } from './UsersScreen';
1
+ export { AccountPanel } from './AccountPanel.js';
2
+ export { LoginScreen } from './LoginScreen.js';
3
+ export { usersNavItem } from './nav.js';
4
+ export { NewUserScreen } from './NewUserScreen.js';
5
+ export { UsersScreen } from './UsersScreen.js';
@@ -1,6 +1,6 @@
1
1
  // SPDX-License-Identifier: Apache-2.0
2
- export { AccountPanel } from './AccountPanel';
3
- export { LoginScreen } from './LoginScreen';
4
- export { usersNavItem } from './nav';
5
- export { NewUserScreen } from './NewUserScreen';
6
- export { UsersScreen } from './UsersScreen';
2
+ export { AccountPanel } from './AccountPanel.js';
3
+ export { LoginScreen } from './LoginScreen.js';
4
+ export { usersNavItem } from './nav.js';
5
+ export { NewUserScreen } from './NewUserScreen.js';
6
+ export { UsersScreen } from './UsersScreen.js';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gopherium/react-auth",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
4
  "description": "Session authentication for React apps backed by gouncer's authkit.",
5
5
  "license": "Apache-2.0",
6
6
  "type": "module",
@@ -31,6 +31,12 @@
31
31
  "default": "./dist/testing/index.js"
32
32
  }
33
33
  },
34
+ "scripts": {
35
+ "build": "tsc -p tsconfig.build.json && cp src/wpds/style.css dist/wpds/style.css",
36
+ "cover": "vitest run --coverage",
37
+ "lint": "oxlint",
38
+ "prepublishOnly": "pnpm run build"
39
+ },
34
40
  "publishConfig": {
35
41
  "access": "public"
36
42
  },
@@ -84,10 +90,5 @@
84
90
  "typescript-eslint": "^8.46.4",
85
91
  "vite": "^8.1.4",
86
92
  "vitest": "^4.1.10"
87
- },
88
- "scripts": {
89
- "build": "tsc -p tsconfig.build.json && cp src/wpds/style.css dist/wpds/style.css",
90
- "cover": "vitest run --coverage",
91
- "lint": "oxlint"
92
93
  }
93
- }
94
+ }