irdata_js 0.2.0 → 0.2.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/README.md CHANGED
@@ -110,19 +110,27 @@ npm run build
110
110
 
111
111
  ### Manual Verification (OAuth Flow)
112
112
 
113
- This repository includes a local development proxy server to test the OAuth flow and API interaction, avoiding CORS issues during development.
113
+ This repository includes a local development proxy server and a demo application to test the OAuth flow and API interaction, avoiding CORS issues during development.
114
114
 
115
- 1. Create a file named `auth_config.json` in the `examples/` directory (ignored by git) with your credentials:
115
+ 1. Create a file named `config.json` in the `demo/` directory (ignored by git) with your configuration:
116
116
 
117
117
  ```json
118
118
  {
119
- "clientId": "YOUR_CLIENT_ID",
120
- "redirectUri": "http://127.0.0.1/irdata_js/callback",
121
- "tokenEndpoint": "http://127.0.0.1/token"
119
+ "port": 80,
120
+ "basePath": "/irdata_js",
121
+ "redirectPath": "/irdata_js/callback",
122
+ "auth": {
123
+ "clientId": "YOUR_CLIENT_ID",
124
+ "redirectUri": "http://127.0.0.1/irdata_js/callback",
125
+ "tokenEndpoint": "http://127.0.0.1/irdata_js/token"
126
+ }
122
127
  }
123
128
  ```
124
129
 
125
- _Note: The `redirectUri` should match what you registered with iRacing. The proxy server is configured to intercept the path specified in `redirectUri` (e.g. `/irdata_js/callback`) and redirect it to the example app while preserving the auth code._
130
+ * `port`: The port the proxy server will listen on.
131
+ * `basePath`: The path prefix where the static files and proxy endpoints are served from.
132
+ * `redirectPath`: The path the proxy server intercepts for OAuth callbacks.
133
+ * `auth`: Your iRacing API credentials. Note that `tokenEndpoint` should include the `basePath`.
126
134
 
127
135
  2. Start the proxy server:
128
136
 
@@ -130,10 +138,12 @@ This repository includes a local development proxy server to test the OAuth flow
130
138
  npm run dev
131
139
  ```
132
140
 
133
- _This starts the proxy server on port 80. Depending on your system configuration, you might need elevated privileges (e.g., `sudo`) to listen on port 80._
141
+ *This command automatically generates the `demo/index.html` from the template using your configuration and starts the proxy server.*
142
+ *Depending on your system configuration, you might need elevated privileges (e.g., `sudo`) to listen on port 80.*
143
+
144
+ 3. Open `http://127.0.0.1/irdata_js/` (or your configured `basePath`) in your browser.
145
+ * The demo app is configured to use the local proxy endpoints (e.g., `/irdata_js/token`, `/irdata_js/data`, `/irdata_js/passthrough`) to bypass CORS restrictions.
134
146
 
135
- 3. Open `http://127.0.0.1/examples/index.html` in your browser.
136
- - The `index.html` is configured to use the local proxy endpoints (`/token`, `/data`, `/passthrough`) to bypass CORS restrictions enforced by the browser.
137
147
 
138
148
  ## License
139
149
 
@@ -21,5 +21,6 @@ export declare class AuthManager {
21
21
  generateAuthUrl(): Promise<string>;
22
22
  handleCallback(code: string): Promise<void>;
23
23
  refreshAccessToken(): Promise<boolean>;
24
+ logout(): void;
24
25
  }
25
26
  export {};
@@ -167,4 +167,7 @@ export class AuthManager {
167
167
  return false;
168
168
  }
169
169
  }
170
+ logout() {
171
+ this.tokenStore.clear();
172
+ }
170
173
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "irdata_js",
3
- "version": "0.2.0",
3
+ "version": "0.2.1",
4
4
  "description": "JavaScript library to interact with the iRacing /data API",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -14,7 +14,7 @@
14
14
  "scripts": {
15
15
  "test": "vitest run",
16
16
  "build": "tsc",
17
- "dev": "node proxy_server.js",
17
+ "dev": "./generate_demo.sh && node proxy_server.js",
18
18
  "lint": "eslint .",
19
19
  "lint:fix": "eslint . --fix",
20
20
  "format": "prettier --write .",