@openfort/react-native 0.1.18 → 0.1.19

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.
@@ -8,32 +8,6 @@ import { NativeStorageUtils } from '../native';
8
8
  * providing read-after-write consistency while keeping `save` synchronous.
9
9
  */
10
10
  const pendingWrites = new Map();
11
- /**
12
- * Creates a scope prefix from the publishable key.
13
- * Extracts the unique project identifier after the "pk_test_" or "pk_live_" prefix.
14
- * Uses the first 8 characters of that unique part to keep keys readable.
15
- *
16
- * e.g., "pk_test_abc123xyz789" -> "abc123xy"
17
- */
18
- function createScope(publishableKey) {
19
- // Remove the "pk_test_" or "pk_live_" prefix (8 characters)
20
- const uniquePart = publishableKey.substring(8);
21
- // Use first 8 characters of the unique part as scope
22
- return uniquePart.substring(0, 8);
23
- }
24
- // Define the StorageKeys enum values that match the Openfort SDK
25
- var StorageKeys;
26
- (function (StorageKeys) {
27
- StorageKeys["AUTHENTICATION"] = "openfort.authentication";
28
- StorageKeys["SIGNER"] = "openfort.signer";
29
- StorageKeys["CONFIGURATION"] = "openfort.configuration";
30
- StorageKeys["ACCOUNT"] = "openfort.account";
31
- StorageKeys["TEST"] = "openfort.test";
32
- StorageKeys["RECOVERY"] = "openfort.recovery";
33
- StorageKeys["SESSION"] = "openfort.session";
34
- StorageKeys["PKCE_STATE"] = "openfort.pkce_state";
35
- StorageKeys["PKCE_VERIFIER"] = "openfort.pkce_verifier";
36
- })(StorageKeys || (StorageKeys = {}));
37
11
  /**
38
12
  * Storage adapter backed by {@link SecureStore} that matches the {@link Storage} interface expected by `@openfort/openfort-js`.
39
13
  *
@@ -118,85 +92,36 @@ function normalizeKey(key) {
118
92
  return key.replaceAll(':', '-');
119
93
  }
120
94
  /**
121
- * Creates a type-safe storage adapter that bridges the Openfort SDK storage API with the React Native implementation.
122
- * Storage keys are scoped by publishable key to isolate data between different projects.
95
+ * Creates a storage adapter that bridges the Openfort SDK storage API with the React Native implementation.
96
+ * The core SDK's ScopedStorage handles key scoping, so this adapter simply passes keys through.
123
97
  *
124
- * @param publishableKey - The publishable key used to scope storage keys.
98
+ * @param _publishableKey - Unused. Key scoping is handled by the core SDK.
125
99
  * @param customStorage - Optional custom storage implementation. When omitted the {@link SecureStorageAdapter} is used.
126
100
  * @returns An object that satisfies the {@link Storage} interface expected by `@openfort/openfort-js`.
127
101
  */
128
- export function createNormalizedStorage(publishableKey, customStorage) {
102
+ export function createNormalizedStorage(_publishableKey, customStorage) {
129
103
  const baseStorage = customStorage || SecureStorageAdapter;
130
- const scope = createScope(publishableKey);
131
- /**
132
- * Prefixes a storage key with the scope.
133
- * e.g., "openfort.authentication" -> "abc123xy.openfort.authentication"
134
- */
135
- function scopeKey(key) {
136
- return `${scope}.${key}`;
137
- }
138
104
  return {
139
105
  async get(key) {
140
- // Convert the unknown key to our StorageKeys enum
141
- const storageKey = keyToStorageKeys(key);
142
- const scopedKey = scopeKey(storageKey);
143
- const result = await baseStorage.get(scopedKey);
144
- return result;
106
+ const keyString = String(key);
107
+ return baseStorage.get(keyString);
145
108
  },
146
109
  save(key, value) {
147
- logger.info(`Saving to storage key: ${key}, value: ${value}`);
148
- const storageKey = keyToStorageKeys(key);
149
- const scopedKey = scopeKey(storageKey);
110
+ const keyString = String(key);
150
111
  // Fire and forget - don't await as the SDK expects synchronous behavior
151
- baseStorage.save(scopedKey, value).catch((error) => {
112
+ baseStorage.save(keyString, value).catch((error) => {
152
113
  logger.error('Failed to save to storage', error);
153
114
  });
154
115
  },
155
116
  remove(key) {
156
- logger.info(`Removing from storage key: ${key}`);
157
- const storageKey = keyToStorageKeys(key);
158
- const scopedKey = scopeKey(storageKey);
117
+ const keyString = String(key);
159
118
  // Fire and forget - don't await as the SDK expects synchronous behavior
160
- baseStorage.remove(scopedKey).catch((error) => {
119
+ baseStorage.remove(keyString).catch((error) => {
161
120
  logger.error('Failed to remove from storage', error);
162
121
  });
163
122
  },
164
123
  flush() {
165
- logger.info('Flushing storage');
166
- // Remove all scoped keys for this project
167
- for (const key of Object.values(StorageKeys)) {
168
- const scopedKey = scopeKey(key);
169
- baseStorage.remove(scopedKey).catch((error) => {
170
- logger.error('Failed to remove from storage during flush', error);
171
- });
172
- }
124
+ baseStorage.flush();
173
125
  },
174
126
  };
175
127
  }
176
- /**
177
- * Converts a key provided by the Openfort SDK to the local {@link StorageKeys} enum.
178
- *
179
- * @param key - Value provided by the Openfort SDK. Can be a string or an enum-like
180
- * object.
181
- * @returns The matching {@link StorageKeys} value.
182
- * @throws {Error} When the key cannot be mapped to one of the known storage keys.
183
- */
184
- function keyToStorageKeys(key) {
185
- if (typeof key === 'string') {
186
- // Check if the string matches one of our enum values
187
- const storageKey = Object.values(StorageKeys).find((value) => value === key);
188
- if (storageKey) {
189
- return storageKey;
190
- }
191
- }
192
- // If it's an enum-like object, try to get its value
193
- if (typeof key === 'object' && key !== null && 'toString' in key) {
194
- const keyString = key.toString();
195
- const storageKey = Object.values(StorageKeys).find((value) => value === keyString);
196
- if (storageKey) {
197
- return storageKey;
198
- }
199
- }
200
- // Fallback: throw an error for unknown keys
201
- throw new Error(`Unknown storage key: ${key}. Expected one of: ${Object.values(StorageKeys).join(', ')}`);
202
- }
@@ -18,12 +18,12 @@ interface OpenfortStorage {
18
18
  */
19
19
  export declare const SecureStorageAdapter: OpenfortStorage;
20
20
  /**
21
- * Creates a type-safe storage adapter that bridges the Openfort SDK storage API with the React Native implementation.
22
- * Storage keys are scoped by publishable key to isolate data between different projects.
21
+ * Creates a storage adapter that bridges the Openfort SDK storage API with the React Native implementation.
22
+ * The core SDK's ScopedStorage handles key scoping, so this adapter simply passes keys through.
23
23
  *
24
- * @param publishableKey - The publishable key used to scope storage keys.
24
+ * @param _publishableKey - Unused. Key scoping is handled by the core SDK.
25
25
  * @param customStorage - Optional custom storage implementation. When omitted the {@link SecureStorageAdapter} is used.
26
26
  * @returns An object that satisfies the {@link Storage} interface expected by `@openfort/openfort-js`.
27
27
  */
28
- export declare function createNormalizedStorage(publishableKey: string, customStorage?: OpenfortStorage): Storage;
28
+ export declare function createNormalizedStorage(_publishableKey: string, customStorage?: OpenfortStorage): Storage;
29
29
  export {};
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@openfort/react-native",
3
3
  "main": "dist/index.js",
4
- "version": "0.1.18",
4
+ "version": "0.1.19",
5
5
  "license": "MIT",
6
6
  "description": "React Native SDK for Openfort platform integration",
7
7
  "types": "dist/types/index.d.ts",