Skip to content

Commit 02e20c9

Browse files
authored
Merge pull request #17 from phasehq/chore--clean-up-code
chore: clean up code
2 parents 92b557d + 97db08d commit 02e20c9

File tree

2 files changed

+1
-49
lines changed

2 files changed

+1
-49
lines changed

src/phase/utils/crypto.py

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,25 +2,15 @@
22
from typing import Tuple
33
import string
44
from nacl.secret import SecretBox
5-
from typing import List
6-
from nacl.encoding import RawEncoder
75
import functools
86
import nacl.bindings
9-
from nacl.encoding import HexEncoder
10-
from nacl.public import PrivateKey
117
from nacl.bindings import (
128
crypto_kx_keypair,
139
crypto_aead_xchacha20poly1305_ietf_encrypt,
1410
crypto_aead_xchacha20poly1305_ietf_decrypt,
15-
randombytes,
16-
crypto_secretbox_NONCEBYTES,
17-
crypto_kx_server_session_keys,
18-
crypto_kx_client_session_keys,
19-
crypto_kx_seed_keypair,
2011
)
2112
from nacl.hash import blake2b
2213
from nacl.utils import random
23-
from base64 import b64encode, b64decode
2414
from .const import __ph_version__
2515

2616

src/phase/utils/misc.py

Lines changed: 1 addition & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,45 +1,7 @@
1-
import os
21
import platform
3-
import subprocess
4-
import webbrowser
52
import getpass
6-
import json
73
from .exceptions import EnvironmentNotFoundException
8-
from urllib.parse import urlparse
9-
from typing import Union, List
10-
from .const import __version__, PHASE_CLOUD_API_HOST, cross_env_pattern, local_ref_pattern
11-
12-
13-
def get_default_user_token() -> str:
14-
"""
15-
Fetch the default user's personal access token from the config file in PHASE_SECRETS_DIR.
16-
17-
Returns:
18-
- str: The default user's personal access token.
19-
20-
Raises:
21-
- ValueError: If the config file is not found, the default user's ID is missing, or the token is not set.
22-
"""
23-
config_file_path = os.path.join(PHASE_SECRETS_DIR, 'config.json')
24-
25-
if not os.path.exists(config_file_path):
26-
raise ValueError("Config file not found. Please login with phase auth or supply a PHASE_SERVICE_TOKEN as an environment variable.")
27-
28-
with open(config_file_path, 'r') as f:
29-
config_data = json.load(f)
30-
31-
default_user_id = config_data.get("default-user")
32-
if not default_user_id:
33-
raise ValueError("Default user ID is missing in the config file.")
34-
35-
for user in config_data.get("phase-users", []):
36-
if user['id'] == default_user_id:
37-
token = user.get("token")
38-
if not token:
39-
raise ValueError(f"Token for the default user (ID: {default_user_id}) is not found in the config file.")
40-
return token
41-
42-
raise ValueError("Default user not found in the config file.")
4+
from .const import __version__
435

446

457
def phase_get_context(user_data, app_name=None, env_name=None, app_id=None):

0 commit comments

Comments
 (0)