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 { createBillingClient, type BillingClient } from '@bytelyst/billing-client';
|
||||||
import { API_CONFIG, PRODUCT_ID } from '../api/config';
|
import { API_CONFIG, PRODUCT_ID } from '../api/config';
|
||||||
import { mmkvStorage } from '../store/mmkv-storage';
|
import { getAccessToken } from './auth-helpers';
|
||||||
|
|
||||||
function getAccessToken(): string | null {
|
|
||||||
return mmkvStorage.getItem(`${PRODUCT_ID}_access_token`);
|
|
||||||
}
|
|
||||||
|
|
||||||
let _client: BillingClient | null = null;
|
let _client: BillingClient | null = null;
|
||||||
|
|
||||||
|
|||||||
@ -1,10 +1,6 @@
|
|||||||
import { createPlatformClient, type PlatformClient } from '@bytelyst/platform-client';
|
import { createPlatformClient, type PlatformClient } from '@bytelyst/platform-client';
|
||||||
import { API_CONFIG, PRODUCT_ID } from '../api/config';
|
import { API_CONFIG, PRODUCT_ID } from '../api/config';
|
||||||
import { mmkvStorage } from '../store/mmkv-storage';
|
import { getAccessToken } from './auth-helpers';
|
||||||
|
|
||||||
function getAccessToken(): string | null {
|
|
||||||
return mmkvStorage.getItem(`${PRODUCT_ID}_access_token`);
|
|
||||||
}
|
|
||||||
|
|
||||||
let _client: PlatformClient | null = null;
|
let _client: PlatformClient | null = null;
|
||||||
|
|
||||||
|
|||||||
@ -6,10 +6,7 @@ import { DiagnosticsClient } from '@bytelyst/diagnostics-client';
|
|||||||
import { API_CONFIG, PRODUCT_ID } from '../api/config';
|
import { API_CONFIG, PRODUCT_ID } from '../api/config';
|
||||||
import { mmkvStorage } from '../store/mmkv-storage';
|
import { mmkvStorage } from '../store/mmkv-storage';
|
||||||
import { APP_VERSION, BUILD_NUMBER, OS_VERSION } from './app-metadata';
|
import { APP_VERSION, BUILD_NUMBER, OS_VERSION } from './app-metadata';
|
||||||
|
import { getAccessToken } from './auth-helpers';
|
||||||
function getAccessToken(): string | null {
|
|
||||||
return mmkvStorage.getItem(`${PRODUCT_ID}_access_token`);
|
|
||||||
}
|
|
||||||
|
|
||||||
export const telemetryClient = createTelemetryClient({
|
export const telemetryClient = createTelemetryClient({
|
||||||
productId: PRODUCT_ID,
|
productId: PRODUCT_ID,
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user