@explorins/pers-sdk-react-native 2.1.18 → 2.1.20
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.js +250 -121
- package/dist/index.js.map +1 -1
- package/dist/providers/PersSDKProvider.d.ts.map +1 -1
- package/dist/providers/PersSDKProvider.js +7 -0
- package/dist/providers/react-native-auth-provider.d.ts +1 -1
- package/dist/providers/react-native-auth-provider.d.ts.map +1 -1
- package/dist/providers/react-native-auth-provider.js +42 -9
- package/package.json +182 -182
- package/src/providers/PersSDKProvider.tsx +8 -0
- package/src/providers/react-native-auth-provider.ts +42 -12
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PersSDKProvider.d.ts","sourceRoot":"","sources":["../../src/providers/PersSDKProvider.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAuC,SAAS,EAA2C,MAAM,OAAO,CAAC;AAEvH,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAIpF,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,wBAAwB,CAAC;AAkB3D,YAAY,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AAE3D;;;;;;;;GAQG;AACH,MAAM,WAAW,cAAc;IAE7B,GAAG,EAAE,OAAO,GAAG,IAAI,CAAC;IAGpB,YAAY,EAAE,mBAAmB,GAAG,IAAI,CAAC;IAGzC,aAAa,EAAE,OAAO,CAAC;IACvB,eAAe,EAAE,OAAO,CAAC;IACzB,IAAI,EAAE,OAAO,GAAG,QAAQ,GAAG,IAAI,CAAC;IAGhC,UAAU,EAAE,CAAC,MAAM,EAAE,UAAU,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IAClD,sBAAsB,EAAE,CAAC,IAAI,EAAE,OAAO,GAAG,QAAQ,GAAG,IAAI,EAAE,eAAe,EAAE,OAAO,KAAK,IAAI,CAAC;IAC5F,eAAe,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;IACrC,cAAc,EAAE,MAAM,OAAO,CAAC,OAAO,GAAG,IAAI,CAAC,CAAC;CAC/C;AAKD;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,eAAO,MAAM,eAAe,EAAE,KAAK,CAAC,EAAE,CAAC;IACrC,QAAQ,EAAE,SAAS,CAAC;IACpB,MAAM,CAAC,EAAE,UAAU,CAAC;CACrB,
|
|
1
|
+
{"version":3,"file":"PersSDKProvider.d.ts","sourceRoot":"","sources":["../../src/providers/PersSDKProvider.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAuC,SAAS,EAA2C,MAAM,OAAO,CAAC;AAEvH,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAIpF,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,wBAAwB,CAAC;AAkB3D,YAAY,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AAE3D;;;;;;;;GAQG;AACH,MAAM,WAAW,cAAc;IAE7B,GAAG,EAAE,OAAO,GAAG,IAAI,CAAC;IAGpB,YAAY,EAAE,mBAAmB,GAAG,IAAI,CAAC;IAGzC,aAAa,EAAE,OAAO,CAAC;IACvB,eAAe,EAAE,OAAO,CAAC;IACzB,IAAI,EAAE,OAAO,GAAG,QAAQ,GAAG,IAAI,CAAC;IAGhC,UAAU,EAAE,CAAC,MAAM,EAAE,UAAU,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IAClD,sBAAsB,EAAE,CAAC,IAAI,EAAE,OAAO,GAAG,QAAQ,GAAG,IAAI,EAAE,eAAe,EAAE,OAAO,KAAK,IAAI,CAAC;IAC5F,eAAe,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;IACrC,cAAc,EAAE,MAAM,OAAO,CAAC,OAAO,GAAG,IAAI,CAAC,CAAC;CAC/C;AAKD;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,eAAO,MAAM,eAAe,EAAE,KAAK,CAAC,EAAE,CAAC;IACrC,QAAQ,EAAE,SAAS,CAAC;IACpB,MAAM,CAAC,EAAE,UAAU,CAAC;CACrB,CAqOA,CAAC;AAGF,eAAO,MAAM,UAAU,QAAO,cAQ7B,CAAC"}
|
|
@@ -72,6 +72,13 @@ export const PersSDKProvider = ({ children, config }) => {
|
|
|
72
72
|
if (Platform.OS !== 'web' && isDpopEnabled && !dpopSettings.cryptoProvider) {
|
|
73
73
|
dpopSettings.cryptoProvider = new ReactNativeDPoPProvider();
|
|
74
74
|
}
|
|
75
|
+
// Log DPoP settings before creating auth provider
|
|
76
|
+
console.log('[PersSDKProvider] DPoP settings:', {
|
|
77
|
+
platform: Platform.OS,
|
|
78
|
+
isDpopEnabled,
|
|
79
|
+
hasCryptoProvider: !!dpopSettings.cryptoProvider,
|
|
80
|
+
cryptoProviderType: dpopSettings.cryptoProvider?.constructor?.name || 'none'
|
|
81
|
+
});
|
|
75
82
|
// Create platform-aware auth provider if not provided
|
|
76
83
|
let authProvider;
|
|
77
84
|
if (config.authProvider) {
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* React Native Unified Auth Provider
|
|
3
3
|
*
|
|
4
4
|
* Creates a platform-specific auth provider that automatically selects the appropriate storage:
|
|
5
|
-
* - Web: Uses
|
|
5
|
+
* - Web: Uses IndexedDBTokenStorage for DPoP (CryptoKey persistence) or LocalStorage
|
|
6
6
|
* - Mobile: Uses AsyncStorage-based storage
|
|
7
7
|
*/
|
|
8
8
|
import { DefaultAuthProvider, AccountOwnerType } from '@explorins/pers-sdk/core';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"react-native-auth-provider.d.ts","sourceRoot":"","sources":["../../src/providers/react-native-auth-provider.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAGH,OAAO,EAAE,mBAAmB,
|
|
1
|
+
{"version":3,"file":"react-native-auth-provider.d.ts","sourceRoot":"","sources":["../../src/providers/react-native-auth-provider.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAGH,OAAO,EAAE,mBAAmB,EAAE,gBAAgB,EAAmD,MAAM,0BAA0B,CAAC;AAElI,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AAc7D;;GAEG;AACH,MAAM,WAAW,qBAAqB;IACpC,gCAAgC;IAChC,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,2BAA2B;IAC3B,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,0CAA0C;IAC1C,aAAa,CAAC,EAAE,YAAY,CAAC;IAC7B,2DAA2D;IAC3D,QAAQ,CAAC,EAAE,gBAAgB,CAAC;IAC5B,oCAAoC;IACpC,IAAI,CAAC,EAAE;QACL,OAAO,CAAC,EAAE,OAAO,CAAC;QAClB,cAAc,CAAC,EAAE,OAAO,0BAA0B,EAAE,kBAAkB,CAAC;KACxE,CAAC;CACH;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,6BAA6B,CAC3C,UAAU,EAAE,MAAM,EAClB,MAAM,GAAE,qBAA0B,GACjC,mBAAmB,CA4DrB"}
|
|
@@ -2,14 +2,22 @@
|
|
|
2
2
|
* React Native Unified Auth Provider
|
|
3
3
|
*
|
|
4
4
|
* Creates a platform-specific auth provider that automatically selects the appropriate storage:
|
|
5
|
-
* - Web: Uses
|
|
5
|
+
* - Web: Uses IndexedDBTokenStorage for DPoP (CryptoKey persistence) or LocalStorage
|
|
6
6
|
* - Mobile: Uses AsyncStorage-based storage
|
|
7
7
|
*/
|
|
8
8
|
import { Platform } from 'react-native';
|
|
9
|
-
import { DefaultAuthProvider, AccountOwnerType, LocalStorageTokenStorage } from '@explorins/pers-sdk/core';
|
|
9
|
+
import { DefaultAuthProvider, AccountOwnerType, LocalStorageTokenStorage, IndexedDBTokenStorage } from '@explorins/pers-sdk/core';
|
|
10
10
|
import { ReactNativeSecureStorage } from '../storage/rn-secure-storage';
|
|
11
11
|
// Use React Native's built-in platform detection
|
|
12
12
|
const isWebPlatform = Platform.OS === 'web';
|
|
13
|
+
/**
|
|
14
|
+
* Check if IndexedDB is available (web environments only)
|
|
15
|
+
* Uses globalThis to avoid TypeScript errors in React Native context
|
|
16
|
+
*/
|
|
17
|
+
function hasIndexedDB() {
|
|
18
|
+
return typeof globalThis !== 'undefined' &&
|
|
19
|
+
typeof globalThis.indexedDB !== 'undefined';
|
|
20
|
+
}
|
|
13
21
|
/**
|
|
14
22
|
* Create a React Native auth provider with platform-appropriate storage
|
|
15
23
|
*
|
|
@@ -27,18 +35,43 @@ export function createReactNativeAuthProvider(projectKey, config = {}) {
|
|
|
27
35
|
}
|
|
28
36
|
const { keyPrefix = `pers_${projectKey.slice(0, 8)}_`, debug = false, customStorage, authType = AccountOwnerType.USER, dpop } = config;
|
|
29
37
|
// Platform-specific storage selection
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
38
|
+
// Web with DPoP: Use IndexedDB for CryptoKey persistence
|
|
39
|
+
// Web without DPoP or no IndexedDB: Use LocalStorage
|
|
40
|
+
// Mobile: Use ReactNativeSecureStorage
|
|
41
|
+
let tokenStorage;
|
|
42
|
+
if (customStorage) {
|
|
43
|
+
tokenStorage = customStorage;
|
|
44
|
+
}
|
|
45
|
+
else if (isWebPlatform) {
|
|
46
|
+
// On web, prefer IndexedDB when DPoP is enabled for proper CryptoKey persistence
|
|
47
|
+
const dpopEnabled = dpop?.enabled ?? true;
|
|
48
|
+
if (dpopEnabled && hasIndexedDB()) {
|
|
49
|
+
tokenStorage = new IndexedDBTokenStorage();
|
|
50
|
+
}
|
|
51
|
+
else {
|
|
52
|
+
if (dpopEnabled && !hasIndexedDB()) {
|
|
53
|
+
console.warn('[ReactNativeAuthProvider] DPoP requested but IndexedDB not available. Falling back to LocalStorage (DPoP will be disabled by DefaultAuthProvider).');
|
|
54
|
+
}
|
|
55
|
+
tokenStorage = new LocalStorageTokenStorage();
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
else {
|
|
59
|
+
tokenStorage = new ReactNativeSecureStorage(keyPrefix);
|
|
60
|
+
}
|
|
33
61
|
// Prepare DPoP config ensuring enabled is boolean (default true)
|
|
34
62
|
const dpopConfig = dpop ? {
|
|
35
63
|
enabled: dpop.enabled ?? true,
|
|
36
64
|
cryptoProvider: dpop.cryptoProvider
|
|
37
65
|
} : undefined;
|
|
38
|
-
//
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
66
|
+
// Always log DPoP config for debugging (critical for mobile auth)
|
|
67
|
+
console.log('[ReactNativeAuthProvider] Config:', {
|
|
68
|
+
platform: Platform.OS,
|
|
69
|
+
isWebPlatform,
|
|
70
|
+
dpopEnabled: dpopConfig?.enabled ?? false,
|
|
71
|
+
hasCryptoProvider: !!dpopConfig?.cryptoProvider,
|
|
72
|
+
cryptoProviderType: dpopConfig?.cryptoProvider?.constructor?.name || 'none',
|
|
73
|
+
storageType: tokenStorage.constructor.name
|
|
74
|
+
});
|
|
42
75
|
// Return DefaultAuthProvider configured with platform-appropriate storage
|
|
43
76
|
return new DefaultAuthProvider({
|
|
44
77
|
authType,
|
package/package.json
CHANGED
|
@@ -1,182 +1,182 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@explorins/pers-sdk-react-native",
|
|
3
|
-
"version": "2.1.
|
|
4
|
-
"description": "React Native SDK for PERS Platform - Tourism Loyalty System with Blockchain Transaction Signing and WebAuthn Authentication",
|
|
5
|
-
"main": "dist/index.js",
|
|
6
|
-
"types": "dist/index.d.ts",
|
|
7
|
-
"scripts": {
|
|
8
|
-
"build": "tsc && rollup -c --bundleConfigAsCjs",
|
|
9
|
-
"build:watch": "rollup -c --bundleConfigAsCjs --watch",
|
|
10
|
-
"dev": "tsc --watch",
|
|
11
|
-
"clean": "rimraf dist",
|
|
12
|
-
"docs": "typedoc",
|
|
13
|
-
"docs:dev": "typedoc --watch",
|
|
14
|
-
"docs:json": "typedoc --json docs/api.json",
|
|
15
|
-
"docs:serve": "npx http-server docs -p 8080",
|
|
16
|
-
"prepublishOnly": "npm run clean && npm run build",
|
|
17
|
-
"publish-version": "npm run clean && npm run build && npm version patch && npm publish",
|
|
18
|
-
"publish-with-docs": "npm run clean && npm run build && npm run docs && npm version patch && npm publish",
|
|
19
|
-
"yalc:publish": "npm version patch --no-git-tag-version && npm run build && yalc publish",
|
|
20
|
-
"yalc:push": "npm version patch --no-git-tag-version && npm run build && yalc push"
|
|
21
|
-
},
|
|
22
|
-
"keywords": [
|
|
23
|
-
"pers",
|
|
24
|
-
"sdk",
|
|
25
|
-
"react-native",
|
|
26
|
-
"tourism",
|
|
27
|
-
"loyalty",
|
|
28
|
-
"blockchain",
|
|
29
|
-
"web3",
|
|
30
|
-
"webauthn",
|
|
31
|
-
"transaction-signing",
|
|
32
|
-
"rewards",
|
|
33
|
-
"authentication",
|
|
34
|
-
"biometrics",
|
|
35
|
-
"secure-storage"
|
|
36
|
-
],
|
|
37
|
-
"author": "eXplorins",
|
|
38
|
-
"license": "MIT",
|
|
39
|
-
"dependencies": {
|
|
40
|
-
"@explorins/pers-sdk": "
|
|
41
|
-
"@explorins/pers-signer": "^1.0.33",
|
|
42
|
-
"buffer": "^6.0.3",
|
|
43
|
-
"ethers": "^6.15.0",
|
|
44
|
-
"react-native-get-random-values": "^2.0.0",
|
|
45
|
-
"react-native-keychain": "^10.0.0",
|
|
46
|
-
"react-native-passkey": "^3.3.2",
|
|
47
|
-
"react-native-quick-crypto": "^1.0.6"
|
|
48
|
-
},
|
|
49
|
-
"browser": {
|
|
50
|
-
"crypto": false,
|
|
51
|
-
"url": false,
|
|
52
|
-
"http": false,
|
|
53
|
-
"https": false,
|
|
54
|
-
"zlib": false,
|
|
55
|
-
"stream": false,
|
|
56
|
-
"assert": false,
|
|
57
|
-
"path": false,
|
|
58
|
-
"fs": false,
|
|
59
|
-
"os": false,
|
|
60
|
-
"readable-stream": false,
|
|
61
|
-
"util": false,
|
|
62
|
-
"events": false,
|
|
63
|
-
"net": false,
|
|
64
|
-
"tls": false,
|
|
65
|
-
"child_process": false,
|
|
66
|
-
"pngjs": false,
|
|
67
|
-
"pngjs/lib/bitmapper": false,
|
|
68
|
-
"pngjs/lib/parser-async": false,
|
|
69
|
-
"pngjs/lib/parser-sync": false,
|
|
70
|
-
"./bitmapper": false,
|
|
71
|
-
"hash-base": false,
|
|
72
|
-
"@ethereumjs/common": false,
|
|
73
|
-
"@ethereumjs/tx": false,
|
|
74
|
-
"@ethereumjs/util": false,
|
|
75
|
-
"stream-browserify": false,
|
|
76
|
-
"crypto-browserify": false,
|
|
77
|
-
"inherits": false,
|
|
78
|
-
"safe-buffer": false,
|
|
79
|
-
"string_decoder": false,
|
|
80
|
-
"process-nextick-args": false,
|
|
81
|
-
"isarray": false,
|
|
82
|
-
"core-util-is": false,
|
|
83
|
-
"util-deprecate": false,
|
|
84
|
-
"ethereum-cryptography": false,
|
|
85
|
-
"keccak": false,
|
|
86
|
-
"secp256k1": false,
|
|
87
|
-
"scrypt-js": false,
|
|
88
|
-
"bech32": false,
|
|
89
|
-
"ws": false,
|
|
90
|
-
"xhr2-cookies": false,
|
|
91
|
-
"aes-js": false,
|
|
92
|
-
"@ethersproject/sha2": false,
|
|
93
|
-
"@ethersproject/pbkdf2": false,
|
|
94
|
-
"@ethersproject/scrypt": false
|
|
95
|
-
},
|
|
96
|
-
"peerDependencies": {
|
|
97
|
-
"@react-native-async-storage/async-storage": ">=1.15.0",
|
|
98
|
-
"react": ">=16.8.0",
|
|
99
|
-
"react-native": ">=0.60.0"
|
|
100
|
-
},
|
|
101
|
-
"peerDependenciesMeta": {
|
|
102
|
-
"react-native-keychain": {
|
|
103
|
-
"optional": true
|
|
104
|
-
},
|
|
105
|
-
"@react-native-async-storage/async-storage": {
|
|
106
|
-
"optional": false
|
|
107
|
-
},
|
|
108
|
-
"react-native-get-random-values": {
|
|
109
|
-
"optional": true
|
|
110
|
-
},
|
|
111
|
-
"react-native-url-polyfill": {
|
|
112
|
-
"optional": true
|
|
113
|
-
},
|
|
114
|
-
"react-native-polyfill-globals": {
|
|
115
|
-
"optional": true
|
|
116
|
-
},
|
|
117
|
-
"web-streams-polyfill": {
|
|
118
|
-
"optional": true
|
|
119
|
-
}
|
|
120
|
-
},
|
|
121
|
-
"overrides": {
|
|
122
|
-
"readable-stream": false,
|
|
123
|
-
"@ethereumjs/common": false,
|
|
124
|
-
"@ethereumjs/util": false,
|
|
125
|
-
"@ethereumjs/rlp": false,
|
|
126
|
-
"@ethereumjs/tx": false,
|
|
127
|
-
"stream": false,
|
|
128
|
-
"util": false,
|
|
129
|
-
"events": false,
|
|
130
|
-
"crypto": false,
|
|
131
|
-
"fs": false,
|
|
132
|
-
"path": false,
|
|
133
|
-
"os": false,
|
|
134
|
-
"net": false,
|
|
135
|
-
"tls": false,
|
|
136
|
-
"child_process": false,
|
|
137
|
-
"hash-base": false,
|
|
138
|
-
"inherits": false,
|
|
139
|
-
"safe-buffer": false,
|
|
140
|
-
"string_decoder": false,
|
|
141
|
-
"process-nextick-args": false,
|
|
142
|
-
"isarray": false,
|
|
143
|
-
"core-util-is": false,
|
|
144
|
-
"util-deprecate": false,
|
|
145
|
-
"ethereum-cryptography": false,
|
|
146
|
-
"keccak": false,
|
|
147
|
-
"secp256k1": false,
|
|
148
|
-
"scrypt-js": false,
|
|
149
|
-
"bech32": false,
|
|
150
|
-
"ws": false,
|
|
151
|
-
"xhr2-cookies": false,
|
|
152
|
-
"aes-js": false,
|
|
153
|
-
"@ethersproject/sha2": false,
|
|
154
|
-
"@ethersproject/pbkdf2": false,
|
|
155
|
-
"@ethersproject/scrypt": false
|
|
156
|
-
},
|
|
157
|
-
"devDependencies": {
|
|
158
|
-
"@explorins/pers-shared": "^2.1.128",
|
|
159
|
-
"@react-native-async-storage/async-storage": "^3.0.2",
|
|
160
|
-
"@rollup/plugin-commonjs": "^25.0.7",
|
|
161
|
-
"@rollup/plugin-json": "^6.1.0",
|
|
162
|
-
"@rollup/plugin-node-resolve": "^15.2.3",
|
|
163
|
-
"@types/react": "^19.1.1",
|
|
164
|
-
"@types/react-native": "^0.72.8",
|
|
165
|
-
"rimraf": "^5.0.0",
|
|
166
|
-
"rollup": "^4.0.0",
|
|
167
|
-
"rollup-plugin-typescript2": "^0.36.0",
|
|
168
|
-
"typedoc": "^0.25.13",
|
|
169
|
-
"typedoc-plugin-markdown": "^3.17.1",
|
|
170
|
-
"typescript": "^5.2.0"
|
|
171
|
-
},
|
|
172
|
-
"files": [
|
|
173
|
-
"dist/**/*",
|
|
174
|
-
"src/**/*",
|
|
175
|
-
"README.md"
|
|
176
|
-
],
|
|
177
|
-
"repository": {
|
|
178
|
-
"type": "git",
|
|
179
|
-
"url": "git+https://github.com/eXplorins/pers-sdk.git",
|
|
180
|
-
"directory": "packages/pers-sdk-react-native"
|
|
181
|
-
}
|
|
182
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "@explorins/pers-sdk-react-native",
|
|
3
|
+
"version": "2.1.20",
|
|
4
|
+
"description": "React Native SDK for PERS Platform - Tourism Loyalty System with Blockchain Transaction Signing and WebAuthn Authentication",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"types": "dist/index.d.ts",
|
|
7
|
+
"scripts": {
|
|
8
|
+
"build": "tsc && rollup -c --bundleConfigAsCjs",
|
|
9
|
+
"build:watch": "rollup -c --bundleConfigAsCjs --watch",
|
|
10
|
+
"dev": "tsc --watch",
|
|
11
|
+
"clean": "rimraf dist",
|
|
12
|
+
"docs": "typedoc",
|
|
13
|
+
"docs:dev": "typedoc --watch",
|
|
14
|
+
"docs:json": "typedoc --json docs/api.json",
|
|
15
|
+
"docs:serve": "npx http-server docs -p 8080",
|
|
16
|
+
"prepublishOnly": "npm run clean && npm run build",
|
|
17
|
+
"publish-version": "npm run clean && npm run build && npm version patch && npm publish",
|
|
18
|
+
"publish-with-docs": "npm run clean && npm run build && npm run docs && npm version patch && npm publish",
|
|
19
|
+
"yalc:publish": "npm version patch --no-git-tag-version && npm run build && yalc publish",
|
|
20
|
+
"yalc:push": "npm version patch --no-git-tag-version && npm run build && yalc push"
|
|
21
|
+
},
|
|
22
|
+
"keywords": [
|
|
23
|
+
"pers",
|
|
24
|
+
"sdk",
|
|
25
|
+
"react-native",
|
|
26
|
+
"tourism",
|
|
27
|
+
"loyalty",
|
|
28
|
+
"blockchain",
|
|
29
|
+
"web3",
|
|
30
|
+
"webauthn",
|
|
31
|
+
"transaction-signing",
|
|
32
|
+
"rewards",
|
|
33
|
+
"authentication",
|
|
34
|
+
"biometrics",
|
|
35
|
+
"secure-storage"
|
|
36
|
+
],
|
|
37
|
+
"author": "eXplorins",
|
|
38
|
+
"license": "MIT",
|
|
39
|
+
"dependencies": {
|
|
40
|
+
"@explorins/pers-sdk": "file:.yalc/@explorins/pers-sdk",
|
|
41
|
+
"@explorins/pers-signer": "^1.0.33",
|
|
42
|
+
"buffer": "^6.0.3",
|
|
43
|
+
"ethers": "^6.15.0",
|
|
44
|
+
"react-native-get-random-values": "^2.0.0",
|
|
45
|
+
"react-native-keychain": "^10.0.0",
|
|
46
|
+
"react-native-passkey": "^3.3.2",
|
|
47
|
+
"react-native-quick-crypto": "^1.0.6"
|
|
48
|
+
},
|
|
49
|
+
"browser": {
|
|
50
|
+
"crypto": false,
|
|
51
|
+
"url": false,
|
|
52
|
+
"http": false,
|
|
53
|
+
"https": false,
|
|
54
|
+
"zlib": false,
|
|
55
|
+
"stream": false,
|
|
56
|
+
"assert": false,
|
|
57
|
+
"path": false,
|
|
58
|
+
"fs": false,
|
|
59
|
+
"os": false,
|
|
60
|
+
"readable-stream": false,
|
|
61
|
+
"util": false,
|
|
62
|
+
"events": false,
|
|
63
|
+
"net": false,
|
|
64
|
+
"tls": false,
|
|
65
|
+
"child_process": false,
|
|
66
|
+
"pngjs": false,
|
|
67
|
+
"pngjs/lib/bitmapper": false,
|
|
68
|
+
"pngjs/lib/parser-async": false,
|
|
69
|
+
"pngjs/lib/parser-sync": false,
|
|
70
|
+
"./bitmapper": false,
|
|
71
|
+
"hash-base": false,
|
|
72
|
+
"@ethereumjs/common": false,
|
|
73
|
+
"@ethereumjs/tx": false,
|
|
74
|
+
"@ethereumjs/util": false,
|
|
75
|
+
"stream-browserify": false,
|
|
76
|
+
"crypto-browserify": false,
|
|
77
|
+
"inherits": false,
|
|
78
|
+
"safe-buffer": false,
|
|
79
|
+
"string_decoder": false,
|
|
80
|
+
"process-nextick-args": false,
|
|
81
|
+
"isarray": false,
|
|
82
|
+
"core-util-is": false,
|
|
83
|
+
"util-deprecate": false,
|
|
84
|
+
"ethereum-cryptography": false,
|
|
85
|
+
"keccak": false,
|
|
86
|
+
"secp256k1": false,
|
|
87
|
+
"scrypt-js": false,
|
|
88
|
+
"bech32": false,
|
|
89
|
+
"ws": false,
|
|
90
|
+
"xhr2-cookies": false,
|
|
91
|
+
"aes-js": false,
|
|
92
|
+
"@ethersproject/sha2": false,
|
|
93
|
+
"@ethersproject/pbkdf2": false,
|
|
94
|
+
"@ethersproject/scrypt": false
|
|
95
|
+
},
|
|
96
|
+
"peerDependencies": {
|
|
97
|
+
"@react-native-async-storage/async-storage": ">=1.15.0",
|
|
98
|
+
"react": ">=16.8.0",
|
|
99
|
+
"react-native": ">=0.60.0"
|
|
100
|
+
},
|
|
101
|
+
"peerDependenciesMeta": {
|
|
102
|
+
"react-native-keychain": {
|
|
103
|
+
"optional": true
|
|
104
|
+
},
|
|
105
|
+
"@react-native-async-storage/async-storage": {
|
|
106
|
+
"optional": false
|
|
107
|
+
},
|
|
108
|
+
"react-native-get-random-values": {
|
|
109
|
+
"optional": true
|
|
110
|
+
},
|
|
111
|
+
"react-native-url-polyfill": {
|
|
112
|
+
"optional": true
|
|
113
|
+
},
|
|
114
|
+
"react-native-polyfill-globals": {
|
|
115
|
+
"optional": true
|
|
116
|
+
},
|
|
117
|
+
"web-streams-polyfill": {
|
|
118
|
+
"optional": true
|
|
119
|
+
}
|
|
120
|
+
},
|
|
121
|
+
"overrides": {
|
|
122
|
+
"readable-stream": false,
|
|
123
|
+
"@ethereumjs/common": false,
|
|
124
|
+
"@ethereumjs/util": false,
|
|
125
|
+
"@ethereumjs/rlp": false,
|
|
126
|
+
"@ethereumjs/tx": false,
|
|
127
|
+
"stream": false,
|
|
128
|
+
"util": false,
|
|
129
|
+
"events": false,
|
|
130
|
+
"crypto": false,
|
|
131
|
+
"fs": false,
|
|
132
|
+
"path": false,
|
|
133
|
+
"os": false,
|
|
134
|
+
"net": false,
|
|
135
|
+
"tls": false,
|
|
136
|
+
"child_process": false,
|
|
137
|
+
"hash-base": false,
|
|
138
|
+
"inherits": false,
|
|
139
|
+
"safe-buffer": false,
|
|
140
|
+
"string_decoder": false,
|
|
141
|
+
"process-nextick-args": false,
|
|
142
|
+
"isarray": false,
|
|
143
|
+
"core-util-is": false,
|
|
144
|
+
"util-deprecate": false,
|
|
145
|
+
"ethereum-cryptography": false,
|
|
146
|
+
"keccak": false,
|
|
147
|
+
"secp256k1": false,
|
|
148
|
+
"scrypt-js": false,
|
|
149
|
+
"bech32": false,
|
|
150
|
+
"ws": false,
|
|
151
|
+
"xhr2-cookies": false,
|
|
152
|
+
"aes-js": false,
|
|
153
|
+
"@ethersproject/sha2": false,
|
|
154
|
+
"@ethersproject/pbkdf2": false,
|
|
155
|
+
"@ethersproject/scrypt": false
|
|
156
|
+
},
|
|
157
|
+
"devDependencies": {
|
|
158
|
+
"@explorins/pers-shared": "^2.1.128",
|
|
159
|
+
"@react-native-async-storage/async-storage": "^3.0.2",
|
|
160
|
+
"@rollup/plugin-commonjs": "^25.0.7",
|
|
161
|
+
"@rollup/plugin-json": "^6.1.0",
|
|
162
|
+
"@rollup/plugin-node-resolve": "^15.2.3",
|
|
163
|
+
"@types/react": "^19.1.1",
|
|
164
|
+
"@types/react-native": "^0.72.8",
|
|
165
|
+
"rimraf": "^5.0.0",
|
|
166
|
+
"rollup": "^4.0.0",
|
|
167
|
+
"rollup-plugin-typescript2": "^0.36.0",
|
|
168
|
+
"typedoc": "^0.25.13",
|
|
169
|
+
"typedoc-plugin-markdown": "^3.17.1",
|
|
170
|
+
"typescript": "^5.2.0"
|
|
171
|
+
},
|
|
172
|
+
"files": [
|
|
173
|
+
"dist/**/*",
|
|
174
|
+
"src/**/*",
|
|
175
|
+
"README.md"
|
|
176
|
+
],
|
|
177
|
+
"repository": {
|
|
178
|
+
"type": "git",
|
|
179
|
+
"url": "git+https://github.com/eXplorins/pers-sdk.git",
|
|
180
|
+
"directory": "packages/pers-sdk-react-native"
|
|
181
|
+
}
|
|
182
|
+
}
|
|
@@ -135,6 +135,14 @@ export const PersSDKProvider: React.FC<{
|
|
|
135
135
|
dpopSettings.cryptoProvider = new ReactNativeDPoPProvider();
|
|
136
136
|
}
|
|
137
137
|
|
|
138
|
+
// Log DPoP settings before creating auth provider
|
|
139
|
+
console.log('[PersSDKProvider] DPoP settings:', {
|
|
140
|
+
platform: Platform.OS,
|
|
141
|
+
isDpopEnabled,
|
|
142
|
+
hasCryptoProvider: !!dpopSettings.cryptoProvider,
|
|
143
|
+
cryptoProviderType: dpopSettings.cryptoProvider?.constructor?.name || 'none'
|
|
144
|
+
});
|
|
145
|
+
|
|
138
146
|
// Create platform-aware auth provider if not provided
|
|
139
147
|
let authProvider: DefaultAuthProvider;
|
|
140
148
|
if (config.authProvider) {
|
|
@@ -2,19 +2,27 @@
|
|
|
2
2
|
* React Native Unified Auth Provider
|
|
3
3
|
*
|
|
4
4
|
* Creates a platform-specific auth provider that automatically selects the appropriate storage:
|
|
5
|
-
* - Web: Uses
|
|
5
|
+
* - Web: Uses IndexedDBTokenStorage for DPoP (CryptoKey persistence) or LocalStorage
|
|
6
6
|
* - Mobile: Uses AsyncStorage-based storage
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
9
|
import { Platform } from 'react-native';
|
|
10
|
-
import { DefaultAuthProvider,
|
|
11
|
-
import { AsyncStorageTokenStorage } from '../storage/async-storage-token-storage';
|
|
10
|
+
import { DefaultAuthProvider, AccountOwnerType, LocalStorageTokenStorage, IndexedDBTokenStorage } from '@explorins/pers-sdk/core';
|
|
12
11
|
import { ReactNativeSecureStorage } from '../storage/rn-secure-storage';
|
|
13
12
|
import type { TokenStorage } from '@explorins/pers-sdk/core';
|
|
14
13
|
|
|
15
14
|
// Use React Native's built-in platform detection
|
|
16
15
|
const isWebPlatform = Platform.OS === 'web';
|
|
17
16
|
|
|
17
|
+
/**
|
|
18
|
+
* Check if IndexedDB is available (web environments only)
|
|
19
|
+
* Uses globalThis to avoid TypeScript errors in React Native context
|
|
20
|
+
*/
|
|
21
|
+
function hasIndexedDB(): boolean {
|
|
22
|
+
return typeof globalThis !== 'undefined' &&
|
|
23
|
+
typeof (globalThis as Record<string, unknown>).indexedDB !== 'undefined';
|
|
24
|
+
}
|
|
25
|
+
|
|
18
26
|
/**
|
|
19
27
|
* Configuration for React Native Auth Provider
|
|
20
28
|
*/
|
|
@@ -62,11 +70,28 @@ export function createReactNativeAuthProvider(
|
|
|
62
70
|
} = config;
|
|
63
71
|
|
|
64
72
|
// Platform-specific storage selection
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
73
|
+
// Web with DPoP: Use IndexedDB for CryptoKey persistence
|
|
74
|
+
// Web without DPoP or no IndexedDB: Use LocalStorage
|
|
75
|
+
// Mobile: Use ReactNativeSecureStorage
|
|
76
|
+
let tokenStorage: TokenStorage;
|
|
77
|
+
|
|
78
|
+
if (customStorage) {
|
|
79
|
+
tokenStorage = customStorage;
|
|
80
|
+
} else if (isWebPlatform) {
|
|
81
|
+
// On web, prefer IndexedDB when DPoP is enabled for proper CryptoKey persistence
|
|
82
|
+
const dpopEnabled = dpop?.enabled ?? true;
|
|
83
|
+
|
|
84
|
+
if (dpopEnabled && hasIndexedDB()) {
|
|
85
|
+
tokenStorage = new IndexedDBTokenStorage();
|
|
86
|
+
} else {
|
|
87
|
+
if (dpopEnabled && !hasIndexedDB()) {
|
|
88
|
+
console.warn('[ReactNativeAuthProvider] DPoP requested but IndexedDB not available. Falling back to LocalStorage (DPoP will be disabled by DefaultAuthProvider).');
|
|
89
|
+
}
|
|
90
|
+
tokenStorage = new LocalStorageTokenStorage();
|
|
91
|
+
}
|
|
92
|
+
} else {
|
|
93
|
+
tokenStorage = new ReactNativeSecureStorage(keyPrefix);
|
|
94
|
+
}
|
|
70
95
|
|
|
71
96
|
// Prepare DPoP config ensuring enabled is boolean (default true)
|
|
72
97
|
const dpopConfig = dpop ? {
|
|
@@ -74,10 +99,15 @@ export function createReactNativeAuthProvider(
|
|
|
74
99
|
cryptoProvider: dpop.cryptoProvider
|
|
75
100
|
} : undefined;
|
|
76
101
|
|
|
77
|
-
//
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
102
|
+
// Always log DPoP config for debugging (critical for mobile auth)
|
|
103
|
+
console.log('[ReactNativeAuthProvider] Config:', {
|
|
104
|
+
platform: Platform.OS,
|
|
105
|
+
isWebPlatform,
|
|
106
|
+
dpopEnabled: dpopConfig?.enabled ?? false,
|
|
107
|
+
hasCryptoProvider: !!dpopConfig?.cryptoProvider,
|
|
108
|
+
cryptoProviderType: dpopConfig?.cryptoProvider?.constructor?.name || 'none',
|
|
109
|
+
storageType: tokenStorage.constructor.name
|
|
110
|
+
});
|
|
81
111
|
|
|
82
112
|
// Return DefaultAuthProvider configured with platform-appropriate storage
|
|
83
113
|
return new DefaultAuthProvider({
|