refactor(mobile): DRY getAccessToken into shared auth-helpers.ts
Extract the duplicated getAccessToken() function from platform.ts, billing-client.ts, and platform-api.ts into a single auth-helpers.ts. All three now import from the shared module.
This commit is contained in:
parent
4813c850a3
commit
bb6d77b1a4
6
mobile/src/lib/auth-helpers.ts
Normal file
6
mobile/src/lib/auth-helpers.ts
Normal file
@ -0,0 +1,6 @@
|
||||
import { PRODUCT_ID } from '../api/config';
|
||||
import { mmkvStorage } from '../store/mmkv-storage';
|
||||
|
||||
export function getAccessToken(): string | null {
|
||||
return mmkvStorage.getItem(`${PRODUCT_ID}_access_token`);
|
||||
}
|
||||
@ -1,10 +1,6 @@
|
||||
import { createBillingClient, type BillingClient } from '@bytelyst/billing-client';
|
||||
import { API_CONFIG, PRODUCT_ID } from '../api/config';
|
||||
import { mmkvStorage } from '../store/mmkv-storage';
|
||||
|
||||
function getAccessToken(): string | null {
|
||||
return mmkvStorage.getItem(`${PRODUCT_ID}_access_token`);
|
||||
}
|
||||
import { getAccessToken } from './auth-helpers';
|
||||
|
||||
let _client: BillingClient | null = null;
|
||||
|
||||
|
||||
@ -1,10 +1,6 @@
|
||||
import { createPlatformClient, type PlatformClient } from '@bytelyst/platform-client';
|
||||
import { API_CONFIG, PRODUCT_ID } from '../api/config';
|
||||
import { mmkvStorage } from '../store/mmkv-storage';
|
||||
|
||||
function getAccessToken(): string | null {
|
||||
return mmkvStorage.getItem(`${PRODUCT_ID}_access_token`);
|
||||
}
|
||||
import { getAccessToken } from './auth-helpers';
|
||||
|
||||
let _client: PlatformClient | null = null;
|
||||
|
||||
|
||||
@ -6,10 +6,7 @@ import { DiagnosticsClient } from '@bytelyst/diagnostics-client';
|
||||
import { API_CONFIG, PRODUCT_ID } from '../api/config';
|
||||
import { mmkvStorage } from '../store/mmkv-storage';
|
||||
import { APP_VERSION, BUILD_NUMBER, OS_VERSION } from './app-metadata';
|
||||
|
||||
function getAccessToken(): string | null {
|
||||
return mmkvStorage.getItem(`${PRODUCT_ID}_access_token`);
|
||||
}
|
||||
import { getAccessToken } from './auth-helpers';
|
||||
|
||||
export const telemetryClient = createTelemetryClient({
|
||||
productId: PRODUCT_ID,
|
||||
|
||||
Loading…
Reference in New Issue
Block a user