mirror of
https://github.com/spacedriveapp/spacedrive.git
synced 2026-05-18 21:36:56 -04:00
* added companies carousel * vdfs section wip * Fix for compile error on Vercel * better bento boxes and security animation * goated vault animation * cloud page * sike ig thats a pricing page * improvement to button components * added yearly pricing * roadmap updates * hero updates (wip in figma) * mobile app section * upgrade next in hopes of successful deploy * downgrade next * changes to content layer for deployment * Fix vercel compile error, again * Update next.config.js * Fix for onboarding * mut http_client_builder * fix cloud URL * Fix mobile compile * Remove auth * Fix volumes deadlock * Update pnpm-lock.yaml * Update lib.rs * Get statistics working with volumes * Disable date filters * Updates * Roadmap updates * Update team members * Update page.tsx * Fix to date filters * Get readable dates & fix date filter search * Change version to `0.4.3` --------- Co-authored-by: Arnab Chakraborty <11457760+Rocky43007@users.noreply.github.com>
33 lines
1.2 KiB
TypeScript
33 lines
1.2 KiB
TypeScript
import cryptoRandomString from 'crypto-random-string';
|
|
import { ExplorerItem, getIndexedItemFilePath, nonLibraryClient } from '@sd/client';
|
|
|
|
// NOTE: `crypto` module is not available in RN so this can't be in client
|
|
export const generatePassword = (length: number) =>
|
|
cryptoRandomString({ length, type: 'ascii-printable' });
|
|
|
|
export type NonEmptyArray<T> = [T, ...T[]];
|
|
|
|
export const isNonEmpty = <T,>(input: T[]): input is NonEmptyArray<T> => input.length > 0;
|
|
export const isNonEmptyObject = (input: object) => Object.keys(input).length > 0;
|
|
|
|
export const AUTH_SERVER_URL = 'https://auth.spacedrive.com';
|
|
// export const AUTH_SERVER_URL = 'http://localhost:9420';
|
|
|
|
export async function getTokens(): Promise<{ accessToken: string; refreshToken: string }> {
|
|
const tokens = await nonLibraryClient.query(['keys.get']);
|
|
const tokensArray = JSON.parse(tokens);
|
|
|
|
const refreshToken: string =
|
|
tokensArray
|
|
.find((cookie: string) => cookie.startsWith('st-refresh-token'))
|
|
?.split('=')[1]
|
|
.split(';')[0] || '';
|
|
const accessToken: string =
|
|
tokensArray
|
|
.find((cookie: string) => cookie.startsWith('st-access-token'))
|
|
?.split('=')[1]
|
|
.split(';')[0] || '';
|
|
|
|
return { accessToken, refreshToken };
|
|
}
|