@idealyst/oauth-client 1.0.75 → 1.0.77

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/package.json CHANGED
@@ -1,12 +1,15 @@
1
1
  {
2
2
  "name": "@idealyst/oauth-client",
3
- "version": "1.0.75",
3
+ "version": "1.0.77",
4
4
  "description": "Universal OAuth2 client for web and React Native",
5
5
  "main": "src/index.ts",
6
6
  "module": "src/index.ts",
7
7
  "types": "src/index.ts",
8
+ "react-native": "src/index.native.ts",
8
9
  "exports": {
9
10
  ".": {
11
+ "react-native": "./src/index.native.ts",
12
+ "browser": "./src/index.web.ts",
10
13
  "import": "./src/index.ts",
11
14
  "require": "./src/index.ts",
12
15
  "types": "./src/index.ts"
@@ -29,11 +32,8 @@
29
32
  ],
30
33
  "author": "",
31
34
  "license": "MIT",
32
- "dependencies": {
33
- "@idealyst/storage": "1.0.75",
34
- "crypto": "^1.0.1"
35
- },
36
35
  "devDependencies": {
36
+ "@idealyst/storage": "^1.0.76",
37
37
  "@types/react": "^18.3.18",
38
38
  "@types/react-native": "^0.73.0",
39
39
  "react": "^19.1.0",
@@ -42,7 +42,7 @@
42
42
  "typescript": "^5.7.3"
43
43
  },
44
44
  "peerDependencies": {
45
- "@idealyst/storage": "1.0.75",
45
+ "@idealyst/storage": "^1.0.76",
46
46
  "react-native": ">=0.60.0"
47
47
  },
48
48
  "files": [
@@ -1,5 +1,5 @@
1
1
  import type { OAuthClient, OAuthConfig, OAuthResult } from './types'
2
- import crypto from 'crypto'
2
+
3
3
  export class WebOAuthClient implements OAuthClient {
4
4
  private config: OAuthConfig
5
5
 
@@ -8,7 +8,6 @@ export class WebOAuthClient implements OAuthClient {
8
8
  }
9
9
 
10
10
  async authorize(): Promise<OAuthResult> {
11
- console.log("AAAAAA")
12
11
  const state = this.generateState()
13
12
 
14
13
  // Check if we're already in a callback
@@ -74,11 +73,12 @@ export class WebOAuthClient implements OAuthClient {
74
73
  }
75
74
 
76
75
  private generateState(): string {
77
- const array = new Uint8Array(16)
78
- crypto.getRandomValues(array)
79
- return btoa(String.fromCharCode.apply(null, Array.from(array)))
80
- .replace(/\+/g, '-')
81
- .replace(/\//g, '_')
82
- .replace(/=/g, '')
76
+ // Generate random state for CSRF protection
77
+ let result = ''
78
+ const chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-._~'
79
+ for (let i = 0; i < 32; i++) {
80
+ result += chars.charAt(Math.floor(Math.random() * chars.length))
81
+ }
82
+ return result
83
83
  }
84
84
  }