@forward-software/react-auth 1.1.0 → 2.0.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.
package/dist/index.d.ts CHANGED
@@ -1,21 +1,2 @@
1
- import React from 'react';
2
- import { BaseAuthClient } from './types';
3
- /**
4
- * Props that can be passed to AuthProvider
5
- */
6
- export declare type AuthProviderProps = {
7
- children?: React.ReactNode;
8
- /**
9
- * An optional component to display if AuthClient initialization failed.
10
- */
11
- ErrorComponent?: JSX.Element;
12
- /**
13
- * An optional component to display while AuthClient instance is being initialized.
14
- */
15
- LoadingComponent?: JSX.Element;
16
- };
17
- export declare function createAuth<C extends BaseAuthClient>(authClient: C): {
18
- AuthProvider: React.FC<AuthProviderProps>;
19
- useAuthClient: () => C;
20
- };
21
- export { BaseAuthClient };
1
+ export { createAuth } from "./auth";
2
+ export type { AuthClient } from "./auth";
package/dist/index.js CHANGED
@@ -1,8 +1 @@
1
-
2
- 'use strict'
3
-
4
- if (process.env.NODE_ENV === 'production') {
5
- module.exports = require('./react-auth.cjs.production.min.js')
6
- } else {
7
- module.exports = require('./react-auth.cjs.development.js')
8
- }
1
+ export { createAuth } from "./auth";
@@ -1,10 +1,17 @@
1
- declare type EventsMap = Record<string, any>;
2
- export declare type EventKey<T extends EventsMap> = string & keyof T;
3
- export declare type EventReceiver<T> = (params: T) => void;
4
- interface Emitter<T extends EventsMap> {
5
- on<K extends EventKey<T>>(eventName: K, fn: EventReceiver<T[K]>): void;
6
- off<K extends EventKey<T>>(eventName: K, fn: EventReceiver<T[K]>): void;
7
- emit<K extends EventKey<T>>(eventName: K, params: T[K]): void;
8
- }
9
- export declare function createEventEmitter<T extends EventsMap>(): Emitter<T>;
10
- export {};
1
+ export declare class Deferred<T> {
2
+ private promise;
3
+ resolve: (value: T | PromiseLike<T>) => void;
4
+ reject: (reason?: any) => void;
5
+ constructor();
6
+ getPromise(): Promise<T>;
7
+ }
8
+ type EventsMap = Record<string, any>;
9
+ export type EventKey<T extends EventsMap> = string & keyof T;
10
+ export type EventReceiver<T> = (params: T) => void;
11
+ interface Emitter<T extends EventsMap> {
12
+ on<K extends EventKey<T>>(eventName: K, fn: EventReceiver<T[K]>): void;
13
+ off<K extends EventKey<T>>(eventName: K, fn: EventReceiver<T[K]>): void;
14
+ emit<K extends EventKey<T>>(eventName: K, params: T[K]): void;
15
+ }
16
+ export declare function createEventEmitter<T extends EventsMap>(): Emitter<T>;
17
+ export {};
package/dist/utils.js ADDED
@@ -0,0 +1,30 @@
1
+ export class Deferred {
2
+ constructor() {
3
+ this.promise = new Promise((resolve, reject) => {
4
+ this.reject = reject;
5
+ this.resolve = resolve;
6
+ });
7
+ }
8
+ getPromise() {
9
+ return this.promise;
10
+ }
11
+ }
12
+ export function createEventEmitter() {
13
+ const listeners = {};
14
+ return {
15
+ on(key, fn) {
16
+ listeners[key] = (listeners[key] || []).concat(fn);
17
+ },
18
+ off(key, fn) {
19
+ listeners[key] = (listeners[key] || []).filter((f) => f !== fn);
20
+ },
21
+ emit(key, data) {
22
+ (listeners[key] || []).forEach(function (fn) {
23
+ try {
24
+ fn(data);
25
+ }
26
+ catch (_a) { }
27
+ });
28
+ },
29
+ };
30
+ }
package/package.json CHANGED
@@ -1,14 +1,11 @@
1
1
  {
2
2
  "name": "@forward-software/react-auth",
3
- "version": "1.1.0",
4
- "author": "ForWarD Software (https://github.com/Forward-Software)",
5
- "license": "MIT",
6
- "publishConfig": {
7
- "access": "public"
8
- },
9
3
  "description": "Simplify your Auth flow when working with React apps",
10
- "repository": "https://github.com/Forward-Software/react-auth",
11
- "homepage": "https://github.com/Forward-Software/react-auth#readme",
4
+ "version": "2.0.0",
5
+ "author": "ForWarD Software (https://forwardsoftware.solutions/)",
6
+ "license": "MIT",
7
+ "repository": "https://github.com/forwardsoftware/react-auth",
8
+ "homepage": "https://github.com/forwardsoftware/react-auth#readme",
12
9
  "keywords": [
13
10
  "react",
14
11
  "react-native",
@@ -16,70 +13,41 @@
16
13
  "authentication"
17
14
  ],
18
15
  "main": "dist/index.js",
19
- "typings": "dist/index.d.ts",
20
- "module": "dist/react-auth.esm.js",
16
+ "types": "dist/index.d.ts",
21
17
  "react-native": "src/index.tsx",
22
18
  "source": "src/index.tsx",
23
19
  "files": [
24
20
  "dist",
25
21
  "src"
26
22
  ],
27
- "engines": {
28
- "node": ">=12"
29
- },
30
23
  "scripts": {
31
- "start": "tsdx watch",
32
- "build": "tsdx build",
33
- "test": "tsdx test",
34
- "test:watch": "tsdx test --watch",
35
- "test:coverage": "tsdx test --coverage",
36
- "lint": "tsdx lint",
37
- "prepare": "tsdx build",
38
- "size": "size-limit",
39
- "analyze": "size-limit --why",
40
- "examples:base": "yarn --cwd examples/base",
41
- "examples:reqres": "yarn --cwd examples/reqres",
42
- "examples:refresh-token": "yarn --cwd examples/refresh-token",
43
- "examples:native": "yarn --cwd examples/native"
24
+ "build:code": "tsc --removeComments",
25
+ "build:types": "tsc --declaration --emitDeclarationOnly",
26
+ "build": "run-p clean build:*",
27
+ "lint": "eslint src",
28
+ "test": "vitest",
29
+ "test:watch": "vitest watch",
30
+ "clean": "rimraf dist"
44
31
  },
45
32
  "devDependencies": {
46
- "@size-limit/preset-small-lib": "^8.1.0",
47
- "@testing-library/jest-dom": "^5.16.5",
48
- "@testing-library/react": "^13.4.0",
49
- "@types/react": "^18.0.25",
50
- "@types/react-dom": "^18.0.9",
51
- "@types/use-sync-external-store": "^0.0.3",
52
- "husky": "^8.0.2",
53
- "react": "^18.2.0",
54
- "react-dom": "^18.2.0",
55
- "size-limit": "^8.1.0",
56
- "tsdx": "^0.14.1"
33
+ "@testing-library/dom": "^10.0.0",
34
+ "@testing-library/jest-dom": "^6.6.3",
35
+ "@testing-library/react": "^16.3.0",
36
+ "@types/node": "^22.15.17",
37
+ "@types/react": "catalog:",
38
+ "@types/react-dom": "catalog:",
39
+ "@types/use-sync-external-store": "^1.5.0",
40
+ "@vitejs/plugin-react": "catalog:",
41
+ "jsdom": "^26.1.0",
42
+ "react": "catalog:",
43
+ "react-dom": "catalog:",
44
+ "vite": "catalog:",
45
+ "vitest": "^3.1.2"
57
46
  },
58
47
  "dependencies": {
59
- "use-sync-external-store": "^1.2.0"
48
+ "use-sync-external-store": "^1.5.0"
60
49
  },
61
50
  "peerDependencies": {
62
51
  "react": ">=16.8"
63
- },
64
- "husky": {
65
- "hooks": {
66
- "pre-commit": "tsdx lint"
67
- }
68
- },
69
- "prettier": {
70
- "printWidth": 80,
71
- "semi": true,
72
- "singleQuote": true,
73
- "trailingComma": "es5"
74
- },
75
- "size-limit": [
76
- {
77
- "path": "dist/react-auth.cjs.production.min.js",
78
- "limit": "10 KB"
79
- },
80
- {
81
- "path": "dist/react-auth.esm.js",
82
- "limit": "10 KB"
83
- }
84
- ]
52
+ }
85
53
  }