Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions apps/docs_web/docs/v0/lifecycle.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,9 @@ For new users, distributed key shares are created:
- Stores encrypted shares in key share nodes

2. Database Updates:
- ewallet_wallets table: new entry with public key
- oko_wallets table: new entry with public key
- wallet_ks_nodes table: key share node assignments
- ewallet_users table: user account information
- oko_users table: user account information
```

**User Experience:**
Expand Down
2 changes: 1 addition & 1 deletion backend/admin_api/src/api/wallet/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import type {
import {
getAllWallets,
getWalletsCount,
} from "@oko-wallet/oko-pg-interface/ewallet_wallets";
} from "@oko-wallet/oko-pg-interface/oko_wallets";

export async function getWalletList(
db: Pool,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import type { Knex } from "knex";

export async function up(knex: Knex): Promise<void> {
await knex.schema.renameTable("ewallet_users", "oko_users");
await knex.schema.renameTable("ewallet_wallets", "oko_wallets");

await knex.raw(`
ALTER TABLE oko_users RENAME CONSTRAINT ewallet_users_pkey TO oko_users_pkey;
ALTER TABLE oko_users RENAME CONSTRAINT ewallet_users_email_auth_type_key TO oko_users_email_auth_type_key;
ALTER TABLE oko_wallets RENAME CONSTRAINT ewallet_wallets_pkey TO oko_wallets_pkey;
ALTER TABLE oko_wallets RENAME CONSTRAINT ewallet_wallets_public_key_key TO oko_wallets_public_key_key;
`);

await knex.raw(`
ALTER INDEX idx_ewallet_wallets_created_at RENAME TO idx_oko_wallets_created_at;
ALTER INDEX idx_ewallet_wallets_user_id_curve_type_status RENAME TO idx_oko_wallets_user_id_curve_type_status;
`);
}

export async function down(knex: Knex): Promise<void> {
await knex.raw(`
ALTER INDEX idx_oko_wallets_created_at RENAME TO idx_ewallet_wallets_created_at;
ALTER INDEX idx_oko_wallets_user_id_curve_type_status RENAME TO idx_ewallet_wallets_user_id_curve_type_status;
`);

await knex.raw(`
ALTER TABLE oko_users RENAME CONSTRAINT oko_users_pkey TO ewallet_users_pkey;
ALTER TABLE oko_users RENAME CONSTRAINT oko_users_email_auth_type_key TO ewallet_users_email_auth_type_key;
ALTER TABLE oko_wallets RENAME CONSTRAINT oko_wallets_pkey TO ewallet_wallets_pkey;
ALTER TABLE oko_wallets RENAME CONSTRAINT oko_wallets_public_key_key TO ewallet_wallets_public_key_key;
`);

await knex.schema.renameTable("oko_users", "ewallet_users");
await knex.schema.renameTable("oko_wallets", "ewallet_wallets");
}

4 changes: 2 additions & 2 deletions backend/oko_pg_interface/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@
"./customers": "./src/customers/index.ts",
"./email_verifications": "./src/email_verifications/index.ts",
"./email_sent_logs": "./src/email_sent_logs/index.ts",
"./ewallet_users": "./src/ewallet_users/index.ts",
"./ewallet_wallets": "./src/ewallet_wallets/index.ts",
"./oko_users": "./src/oko_users/index.ts",
"./oko_wallets": "./src/oko_wallets/index.ts",
"./tss": "./src/tss/index.ts",
"./tss_activate": "./src/tss_activate/index.ts",
"./key_share_node_meta": "./src/key_share_node_meta/index.ts",
Expand Down
4 changes: 2 additions & 2 deletions backend/oko_pg_interface/scripts/seed_backup/data/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import type {
CustomerAndCTDUserWithPasswordHash,
PasswordHash,
} from "@oko-wallet/oko-types/ct_dashboard";
import type { EWalletAdminUser } from "@oko-wallet/oko-types/admin";
import type { OkoAdminUser } from "@oko-wallet/oko-types/admin";
import type { KeyShareNodeMeta } from "@oko-wallet/oko-types/key_share_node_meta";
import type { TssActivationSetting } from "@oko-wallet-types/tss_activate";

Expand All @@ -30,7 +30,7 @@ export function createKeyShareNodeMeta(): KeyShareNodeMeta {
};
}

export async function createAdmin(): Promise<EWalletAdminUser> {
export async function createAdmin(): Promise<OkoAdminUser> {
return {
user_id: ADMIN_USER_ID,
email: ADMIN_EMAIL,
Expand Down
4 changes: 2 additions & 2 deletions backend/oko_pg_interface/scripts/seed_backup/data/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import type {
CustomerDashboardUser,
PasswordHash,
} from "@oko-wallet/oko-types/ct_dashboard";
import type { EWalletAdminUser } from "@oko-wallet/oko-types/admin";
import type { OkoAdminUser } from "@oko-wallet/oko-types/admin";

import {
createAdmin,
Expand All @@ -19,7 +19,7 @@ import type { KeyShareNodeMeta } from "@oko-wallet-types/key_share_node_meta";
import type { TssActivationSetting } from "@oko-wallet-types/tss_activate";

export interface SeedData {
admin: EWalletAdminUser;
admin: OkoAdminUser;
customer: Customer;
customerDashboardUser: CustomerDashboardUser & PasswordHash;
apiKeys: { customer_id: string; hashed_key: string }[];
Expand Down
4 changes: 2 additions & 2 deletions backend/oko_pg_interface/seeds/data/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import type {
CustomerAndCTDUserWithPasswordHash,
PasswordHash,
} from "@oko-wallet/oko-types/ct_dashboard";
import type { EWalletAdminUser } from "@oko-wallet/oko-types/admin";
import type { OkoAdminUser } from "@oko-wallet/oko-types/admin";
import type { KeyShareNodeMeta } from "@oko-wallet/oko-types/key_share_node_meta";
import type { TssActivationSetting } from "@oko-wallet-types/tss_activate";

Expand All @@ -30,7 +30,7 @@ export function createKeyShareNodeMeta(): KeyShareNodeMeta {
};
}

export async function createAdmin(): Promise<EWalletAdminUser> {
export async function createAdmin(): Promise<OkoAdminUser> {
return {
user_id: ADMIN_USER_ID,
email: ADMIN_EMAIL,
Expand Down
4 changes: 2 additions & 2 deletions backend/oko_pg_interface/seeds/initial_seed.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ export async function seed(knex: Knex): Promise<void> {
await knex("ks_node_health_checks").del();
await knex("key_share_nodes").del();
await knex("key_share_node_meta").del();
await knex("ewallet_wallets").del();
await knex("ewallet_users").del();
await knex("oko_wallets").del();
await knex("oko_users").del();
await knex("email_verifications").del();
await knex("customer_dashboard_users").del();
await knex("api_keys").del();
Expand Down
14 changes: 7 additions & 7 deletions backend/oko_pg_interface/src/admin_users/index.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { Pool, type PoolClient } from "pg";
import type { EWalletAdminUser } from "@oko-wallet/oko-types/admin";
import type { OkoAdminUser } from "@oko-wallet/oko-types/admin";
import type { Result } from "@oko-wallet/stdlib-js";

export async function createAdmin(
db: Pool | PoolClient,
adminUser: EWalletAdminUser,
adminUser: OkoAdminUser,
): Promise<Result<string, string>> {
const query = `
INSERT INTO admin_users (
Expand All @@ -27,7 +27,7 @@ RETURNING user_id
];

try {
const result = await db.query<EWalletAdminUser>(query, values);
const result = await db.query<OkoAdminUser>(query, values);

const row = result.rows[0];
if (!row) {
Expand All @@ -49,7 +49,7 @@ RETURNING user_id
export async function getAdminByEmail(
db: Pool,
email: string,
): Promise<Result<EWalletAdminUser | null, string>> {
): Promise<Result<OkoAdminUser | null, string>> {
const query = `
SELECT *
FROM admin_users
Expand All @@ -58,7 +58,7 @@ LIMIT 1
`;

try {
const result = await db.query<EWalletAdminUser>(query, [email]);
const result = await db.query<OkoAdminUser>(query, [email]);
return {
success: true,
data: result.rows.length > 0 ? result.rows[0] : null,
Expand All @@ -74,7 +74,7 @@ LIMIT 1
export async function getAdminById(
db: Pool,
adminId: string,
): Promise<Result<EWalletAdminUser | null, string>> {
): Promise<Result<OkoAdminUser | null, string>> {
const query = `
SELECT *
FROM admin_users
Expand All @@ -83,7 +83,7 @@ LIMIT 1
`;

try {
const result = await db.query<EWalletAdminUser>(query, [adminId]);
const result = await db.query<OkoAdminUser>(query, [adminId]);
return {
success: true,
data: result.rows.length > 0 ? result.rows[0] : null,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export async function createUser(
): Promise<Result<User, string>> {
try {
const query = `
INSERT INTO ewallet_users (
INSERT INTO oko_users (
user_id, email, auth_type
) VALUES (
$1, $2, $3
Expand Down Expand Up @@ -50,7 +50,7 @@ export async function getUserByEmailAndAuthType(
try {
const query = `
SELECT *
FROM ewallet_users
FROM oko_users
WHERE email = $1 AND auth_type = $2
LIMIT 1
`;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export async function createWallet(
): Promise<Result<Wallet, string>> {
try {
const createWalletQuery = `
INSERT INTO ewallet_wallets (
INSERT INTO oko_wallets (
wallet_id, user_id, curve_type,
public_key, enc_tss_share, sss_threshold, status
)
Expand Down Expand Up @@ -66,7 +66,7 @@ export async function getWalletById(
try {
const query = `
SELECT *
FROM ewallet_wallets
FROM oko_wallets
WHERE wallet_id = $1 LIMIT 1
`;

Expand Down Expand Up @@ -96,8 +96,8 @@ export async function getWalletByIdWithEmail(
try {
const query = `
SELECT w.*, u.email AS email
FROM ewallet_wallets w
LEFT JOIN ewallet_users u ON w.user_id = u.user_id
FROM oko_wallets w
LEFT JOIN oko_users u ON w.user_id = u.user_id
WHERE w.wallet_id = $1
LIMIT 1
`;
Expand Down Expand Up @@ -128,7 +128,7 @@ export async function getWalletByPublicKey(
try {
const query = `
SELECT *
FROM ewallet_wallets
FROM oko_wallets
WHERE public_key = $1
LIMIT 1
`;
Expand Down Expand Up @@ -160,7 +160,7 @@ export async function getActiveWalletByUserIdAndCurveType(
try {
const query = `
SELECT *
FROM ewallet_wallets
FROM oko_wallets
WHERE user_id = $1
AND curve_type = $2
AND status = $3
Expand Down Expand Up @@ -204,8 +204,8 @@ SELECT
JSON_AGG(wk.node_id) FILTER (WHERE wk.wallet_ks_node_id IS NOT NULL),
'[]'::json
) as wallet_ks_nodes
FROM ewallet_wallets w
LEFT JOIN ewallet_users u ON w.user_id = u.user_id
FROM oko_wallets w
LEFT JOIN oko_users u ON w.user_id = u.user_id
LEFT JOIN wallet_ks_nodes wk ON w.wallet_id = wk.wallet_id
GROUP BY w.wallet_id, w.user_id, w.curve_type, w.public_key, w.status, w.enc_tss_share, w.metadata, w.created_at, w.updated_at, u.email
ORDER BY w.created_at DESC
Expand All @@ -232,7 +232,7 @@ export async function getWalletsCount(
): Promise<Result<number, string>> {
try {
const query = `
SELECT COUNT(*) FROM ewallet_wallets
SELECT COUNT(*) FROM oko_wallets
`;

const result = await db.query(query);
Expand All @@ -256,7 +256,7 @@ export async function updateWalletStatus(
): Promise<Result<void, string>> {
try {
const query = `
UPDATE ewallet_wallets
UPDATE oko_wallets
SET status = $1, updated_at = now()
WHERE wallet_id = $2
`;
Expand Down
4 changes: 2 additions & 2 deletions backend/oko_pg_interface/src/tss/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -294,8 +294,8 @@ SELECT
u.email AS user_email
FROM tss_sessions s
JOIN customers c ON s.customer_id = c.customer_id
LEFT JOIN ewallet_wallets w ON s.wallet_id = w.wallet_id
LEFT JOIN ewallet_users u ON w.user_id = u.user_id
LEFT JOIN oko_wallets w ON s.wallet_id = w.wallet_id
LEFT JOIN oko_users u ON w.user_id = u.user_id
`;

const conditions: string[] = [];
Expand Down
2 changes: 1 addition & 1 deletion backend/social_login_api/src/routes/referral.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import {
} from "@oko-wallet/oko-pg-interface/referrals";

const CIVITIA_ORIGIN = "https://app.civitia.org";
import { getWalletById } from "@oko-wallet/oko-pg-interface/ewallet_wallets";
import { getWalletById } from "@oko-wallet/oko-pg-interface/oko_wallets";

import {
type UserAuthenticatedRequest,
Expand Down
4 changes: 2 additions & 2 deletions backend/tss_api/src/api/keygen/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ import {
} from "@oko-wallet/oko-pg-interface/ks_nodes";
import { decryptData } from "@oko-wallet/crypto-js/node";
import { createPgConn } from "@oko-wallet/postgres-lib";
import { createUser } from "@oko-wallet/oko-pg-interface/ewallet_users";
import { createUser } from "@oko-wallet/oko-pg-interface/oko_users";
import {
createWallet,
getWalletById,
} from "@oko-wallet/oko-pg-interface/ewallet_wallets";
} from "@oko-wallet/oko-pg-interface/oko_wallets";
import { insertKeyShareNodeMeta } from "@oko-wallet/oko-pg-interface/key_share_node_meta";

import { resetPgDatabase } from "@oko-wallet-tss-api/testing/database";
Expand Down
4 changes: 2 additions & 2 deletions backend/tss_api/src/api/keygen/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { Pool } from "pg";
import {
createUser,
getUserByEmailAndAuthType,
} from "@oko-wallet/oko-pg-interface/ewallet_users";
} from "@oko-wallet/oko-pg-interface/oko_users";
import type { Result } from "@oko-wallet/stdlib-js";
import { encryptDataAsync } from "@oko-wallet/crypto-js/node";
import { Bytes, type Bytes33 } from "@oko-wallet/bytes";
Expand All @@ -14,7 +14,7 @@ import {
createWallet,
getActiveWalletByUserIdAndCurveType,
getWalletByPublicKey,
} from "@oko-wallet/oko-pg-interface/ewallet_wallets";
} from "@oko-wallet/oko-pg-interface/oko_wallets";
import {
createWalletKSNodes,
getActiveKSNodes,
Expand Down
4 changes: 2 additions & 2 deletions backend/tss_api/src/api/presign/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,8 @@ import { createPgConn } from "@oko-wallet/postgres-lib";
import type { WalletStatus } from "@oko-wallet/oko-types/wallets";
import { insertKSNode } from "@oko-wallet/oko-pg-interface/ks_nodes";
import { insertCustomer } from "@oko-wallet/oko-pg-interface/customers";
import { createUser } from "@oko-wallet/oko-pg-interface/ewallet_users";
import { createWallet } from "@oko-wallet/oko-pg-interface/ewallet_wallets";
import { createUser } from "@oko-wallet/oko-pg-interface/oko_users";
import { createWallet } from "@oko-wallet/oko-pg-interface/oko_wallets";
import { insertKeyShareNodeMeta } from "@oko-wallet/oko-pg-interface/key_share_node_meta";

import { resetPgDatabase } from "@oko-wallet-tss-api/testing/database";
Expand Down
4 changes: 2 additions & 2 deletions backend/tss_api/src/api/sign/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,8 @@ import { createPgConn } from "@oko-wallet/postgres-lib";
import type { WalletStatus } from "@oko-wallet/oko-types/wallets";
import { insertKSNode } from "@oko-wallet/oko-pg-interface/ks_nodes";
import { insertCustomer } from "@oko-wallet/oko-pg-interface/customers";
import { createWallet } from "@oko-wallet/oko-pg-interface/ewallet_wallets";
import { createUser } from "@oko-wallet/oko-pg-interface/ewallet_users";
import { createWallet } from "@oko-wallet/oko-pg-interface/oko_wallets";
import { createUser } from "@oko-wallet/oko-pg-interface/oko_users";
import { insertKeyShareNodeMeta } from "@oko-wallet/oko-pg-interface/key_share_node_meta";

import { resetPgDatabase } from "@oko-wallet-tss-api/testing/database";
Expand Down
4 changes: 2 additions & 2 deletions backend/tss_api/src/api/triples/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ import {
} from "@oko-wallet/oko-pg-interface/tss";
import { createPgConn } from "@oko-wallet/postgres-lib";
import type { WalletStatus } from "@oko-wallet/oko-types/wallets";
import { createWallet } from "@oko-wallet/oko-pg-interface/ewallet_wallets";
import { createUser } from "@oko-wallet/oko-pg-interface/ewallet_users";
import { createWallet } from "@oko-wallet/oko-pg-interface/oko_wallets";
import { createUser } from "@oko-wallet/oko-pg-interface/oko_users";
import { insertCustomer } from "@oko-wallet/oko-pg-interface/customers";
import { insertKeyShareNodeMeta } from "@oko-wallet/oko-pg-interface/key_share_node_meta";

Expand Down
4 changes: 2 additions & 2 deletions backend/tss_api/src/api/tss_session/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import { createPgConn } from "@oko-wallet/postgres-lib";
import type { WalletStatus } from "@oko-wallet/oko-types/wallets";
import { createTssSession } from "@oko-wallet/oko-pg-interface/tss";
import { insertCustomer } from "@oko-wallet/oko-pg-interface/customers";
import { createWallet } from "@oko-wallet/oko-pg-interface/ewallet_wallets";
import { createUser } from "@oko-wallet/oko-pg-interface/ewallet_users";
import { createWallet } from "@oko-wallet/oko-pg-interface/oko_wallets";
import { createUser } from "@oko-wallet/oko-pg-interface/oko_users";
import { TssStageType, TriplesStageStatus } from "@oko-wallet/oko-types/tss";
import {
napiRunTriples2ClientStep1,
Expand Down
4 changes: 2 additions & 2 deletions backend/tss_api/src/api/user/index.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Pool } from "pg";
import { createPgConn } from "@oko-wallet/postgres-lib";
import { createUser } from "@oko-wallet/oko-pg-interface/ewallet_users";
import { createUser } from "@oko-wallet/oko-pg-interface/oko_users";
import type { WalletStatus } from "@oko-wallet/oko-types/wallets";
import { type KeyShareNode } from "@oko-wallet/oko-types/tss";
import {
Expand All @@ -10,7 +10,7 @@ import {
import {
createWallet,
updateWalletStatus,
} from "@oko-wallet/oko-pg-interface/ewallet_wallets";
} from "@oko-wallet/oko-pg-interface/oko_wallets";
import { insertKeyShareNodeMeta } from "@oko-wallet/oko-pg-interface/key_share_node_meta";

import { resetPgDatabase } from "@oko-wallet-tss-api/testing/database";
Expand Down
Loading