add project
This commit is contained in:
13
packages/shared/package.json
Normal file
13
packages/shared/package.json
Normal file
@@ -0,0 +1,13 @@
|
||||
{
|
||||
"name": "@cryptowallet/shared",
|
||||
"version": "0.1.0",
|
||||
"private": true,
|
||||
"main": "./src/index.ts",
|
||||
"types": "./src/index.ts",
|
||||
"scripts": {
|
||||
"typecheck": "tsc --noEmit"
|
||||
},
|
||||
"devDependencies": {
|
||||
"typescript": "^5.6.0"
|
||||
}
|
||||
}
|
||||
9
packages/shared/src/constants/chains.ts
Normal file
9
packages/shared/src/constants/chains.ts
Normal file
@@ -0,0 +1,9 @@
|
||||
export const CHAINS = ['ETH', 'BTC', 'SOL', 'TRX'] as const;
|
||||
export type Chain = (typeof CHAINS)[number];
|
||||
|
||||
export const DERIVATION_PATHS: Record<Chain, string> = {
|
||||
ETH: "m/44'/60'/0'/0/0",
|
||||
BTC: "m/84'/0'/0'/0/0",
|
||||
SOL: "m/44'/501'/0'/0'",
|
||||
TRX: "m/44'/195'/0'/0/0",
|
||||
};
|
||||
3
packages/shared/src/index.ts
Normal file
3
packages/shared/src/index.ts
Normal file
@@ -0,0 +1,3 @@
|
||||
export { CHAINS, DERIVATION_PATHS } from './constants/chains';
|
||||
export type { Chain } from './constants/chains';
|
||||
export type { ApiResponse, AccessTokenPayload, AuthContext } from './types/auth';
|
||||
22
packages/shared/src/types/auth.ts
Normal file
22
packages/shared/src/types/auth.ts
Normal file
@@ -0,0 +1,22 @@
|
||||
export interface ApiResponse<T = unknown> {
|
||||
success: boolean;
|
||||
data?: T;
|
||||
error?: string;
|
||||
}
|
||||
|
||||
export interface AccessTokenPayload {
|
||||
sub: string;
|
||||
type: string;
|
||||
sid: string;
|
||||
iat: number;
|
||||
nbf: number;
|
||||
exp: number;
|
||||
iss?: string;
|
||||
aud?: string;
|
||||
}
|
||||
|
||||
export interface AuthContext {
|
||||
userId: string;
|
||||
sid: string;
|
||||
token: AccessTokenPayload;
|
||||
}
|
||||
11
packages/shared/tsconfig.json
Normal file
11
packages/shared/tsconfig.json
Normal file
@@ -0,0 +1,11 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"target": "ES2020",
|
||||
"module": "commonjs",
|
||||
"strict": true,
|
||||
"esModuleInterop": true,
|
||||
"skipLibCheck": true,
|
||||
"declaration": true
|
||||
},
|
||||
"include": ["src/**/*"]
|
||||
}
|
||||
Reference in New Issue
Block a user