@explorins/pers-sdk-react-native 2.0.3 → 2.0.4

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.
@@ -5,7 +5,7 @@
5
5
  * - Web: Uses LocalStorageTokenStorage from core SDK
6
6
  * - Mobile: Uses AsyncStorage-based storage
7
7
  */
8
- import { DefaultAuthProvider, AuthType } from '@explorins/pers-sdk/core';
8
+ import { DefaultAuthProvider, AccountOwnerType } from '@explorins/pers-sdk/core';
9
9
  import type { TokenStorage } from '@explorins/pers-sdk/core';
10
10
  /**
11
11
  * Configuration for React Native Auth Provider
@@ -17,8 +17,8 @@ export interface ReactNativeAuthConfig {
17
17
  debug?: boolean;
18
18
  /** Custom token storage implementation */
19
19
  customStorage?: TokenStorage;
20
- /** Authentication type (default: 'user') */
21
- authType?: AuthType;
20
+ /** Authentication type (default: AccountOwnerType.USER) */
21
+ authType?: AccountOwnerType;
22
22
  /** DPoP Configuration (optional) */
23
23
  dpop?: {
24
24
  enabled?: boolean;
@@ -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,EAAW,QAAQ,EAA4B,MAAM,0BAA0B,CAAC;AAG5G,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AAK7D;;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,4CAA4C;IAC5C,QAAQ,CAAC,EAAE,QAAQ,CAAC;IACpB,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,CAsCrB"}
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,EAAW,gBAAgB,EAA4B,MAAM,0BAA0B,CAAC;AAGpH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AAK7D;;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,CAsCrB"}
@@ -6,7 +6,7 @@
6
6
  * - Mobile: Uses AsyncStorage-based storage
7
7
  */
8
8
  import { Platform } from 'react-native';
9
- import { DefaultAuthProvider, LocalStorageTokenStorage } from '@explorins/pers-sdk/core';
9
+ import { DefaultAuthProvider, AccountOwnerType, LocalStorageTokenStorage } 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';
@@ -25,7 +25,7 @@ export function createReactNativeAuthProvider(projectKey, config = {}) {
25
25
  if (!projectKey || typeof projectKey !== 'string') {
26
26
  throw new Error('createReactNativeAuthProvider: projectKey is required and must be a string');
27
27
  }
28
- const { keyPrefix = `pers_${projectKey.slice(0, 8)}_`, debug = false, customStorage, authType = 'user', dpop } = config;
28
+ const { keyPrefix = `pers_${projectKey.slice(0, 8)}_`, debug = false, customStorage, authType = AccountOwnerType.USER, dpop } = config;
29
29
  // Platform-specific storage selection
30
30
  const tokenStorage = customStorage || (isWebPlatform
31
31
  ? new LocalStorageTokenStorage()
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@explorins/pers-sdk-react-native",
3
- "version": "2.0.3",
3
+ "version": "2.0.4",
4
4
  "description": "React Native SDK for PERS Platform - Tourism Loyalty System with Blockchain Transaction Signing and WebAuthn Authentication",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -37,7 +37,7 @@
37
37
  "author": "eXplorins",
38
38
  "license": "MIT",
39
39
  "dependencies": {
40
- "@explorins/pers-sdk": "^2.0.4",
40
+ "@explorins/pers-sdk": "^2.0.5",
41
41
  "@explorins/pers-shared": "^2.1.64",
42
42
  "@explorins/pers-signer": "^1.0.33",
43
43
  "@explorins/web3-ts": "^0.3.77",
@@ -1,6 +1,7 @@
1
1
  import { useCallback } from 'react';
2
2
  import { usePersSDK } from '../providers/PersSDKProvider';
3
3
  import type { RawUserData } from '@explorins/pers-sdk/core';
4
+ import { AccountOwnerType } from '@explorins/pers-sdk/core';
4
5
  import type { UserDTO, AdminDTO, SessionAuthContextResponseDTO } from '@explorins/pers-shared';
5
6
 
6
7
  // Re-export RawUserData for convenience
@@ -58,18 +59,18 @@ export const useAuth = () => {
58
59
  * Authenticates a user with a JWT token
59
60
  *
60
61
  * @param jwtToken - The JWT token to authenticate with
61
- * @param userType - The type of user ('user' | 'admin'), defaults to 'user'
62
+ * @param userType - The type of user (AccountOwnerType), defaults to USER
62
63
  * @returns Promise resolving to session auth context with user data
63
64
  * @throws Error if SDK is not initialized or authentication fails
64
65
  *
65
66
  * @example
66
67
  * ```typescript
67
68
  * const { login } = useAuth();
68
- * const result = await login(jwtToken, 'user');
69
+ * const result = await login(jwtToken, AccountOwnerType.USER);
69
70
  * console.log('Logged in user:', result.user);
70
71
  * ```
71
72
  */
72
- const login = useCallback(async (jwtToken: string, userType: 'user' | 'admin' = 'user'): Promise<SessionAuthContextResponseDTO> => {
73
+ const login = useCallback(async (jwtToken: string, userType: AccountOwnerType = AccountOwnerType.USER): Promise<SessionAuthContextResponseDTO> => {
73
74
  if (!sdk || !authProvider) {
74
75
  throw new Error('SDK not initialized. Call initialize() first.');
75
76
  }
@@ -7,7 +7,7 @@
7
7
  */
8
8
 
9
9
  import { Platform } from 'react-native';
10
- import { DefaultAuthProvider, AuthApi, AuthType, LocalStorageTokenStorage } from '@explorins/pers-sdk/core';
10
+ import { DefaultAuthProvider, AuthApi, AccountOwnerType, LocalStorageTokenStorage } from '@explorins/pers-sdk/core';
11
11
  import { AsyncStorageTokenStorage } from '../storage/async-storage-token-storage';
12
12
  import { ReactNativeSecureStorage } from '../storage/rn-secure-storage';
13
13
  import type { TokenStorage } from '@explorins/pers-sdk/core';
@@ -25,8 +25,8 @@ export interface ReactNativeAuthConfig {
25
25
  debug?: boolean;
26
26
  /** Custom token storage implementation */
27
27
  customStorage?: TokenStorage;
28
- /** Authentication type (default: 'user') */
29
- authType?: AuthType;
28
+ /** Authentication type (default: AccountOwnerType.USER) */
29
+ authType?: AccountOwnerType;
30
30
  /** DPoP Configuration (optional) */
31
31
  dpop?: {
32
32
  enabled?: boolean;
@@ -57,7 +57,7 @@ export function createReactNativeAuthProvider(
57
57
  keyPrefix = `pers_${projectKey.slice(0, 8)}_`,
58
58
  debug = false,
59
59
  customStorage,
60
- authType = 'user',
60
+ authType = AccountOwnerType.USER,
61
61
  dpop
62
62
  } = config;
63
63