Skip to content

Commit

Permalink
Merge branch 'nats-io:main' into introduce-client-state-enum
Browse files Browse the repository at this point in the history
  • Loading branch information
stankudrow authored Nov 12, 2024
2 parents 6090aa0 + 7e7883e commit 72112c3
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions nats/aio/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
from email.parser import BytesParser
from enum import Enum
from io import BytesIO
from pathlib import Path
from random import shuffle
from secrets import token_hex
from typing import Any, Awaitable, Callable, Dict, List, Optional, Tuple, Union
Expand Down Expand Up @@ -109,7 +110,7 @@ class RawCredentials(UserString):
pass


Credentials = Union[str, Tuple[str, str], RawCredentials]
Credentials = Union[str, Tuple[str, str], RawCredentials, Path]


@dataclass
Expand Down Expand Up @@ -561,7 +562,8 @@ def sig_cb(nonce: str) -> bytes:
return sig

self._signature_cb = sig_cb
elif isinstance(creds, str) or isinstance(creds, UserString):
elif (isinstance(creds, str) or isinstance(creds, UserString)
or isinstance(creds, Path)):
# Define the functions to be able to sign things using nkeys.
def user_cb() -> bytearray:
return self._read_creds_user_jwt(creds)
Expand All @@ -582,7 +584,9 @@ def sig_cb(nonce: str) -> bytes:

self._signature_cb = sig_cb

def _read_creds_user_nkey(self, creds: str | UserString) -> bytearray:
def _read_creds_user_nkey(
self, creds: str | UserString | Path
) -> bytearray:

def get_user_seed(f):
for line in f:
Expand Down Expand Up @@ -611,7 +615,7 @@ def get_user_seed(f):
with open(creds, "rb", buffering=0) as f:
return get_user_seed(f)

def _read_creds_user_jwt(self, creds: str | RawCredentials):
def _read_creds_user_jwt(self, creds: str | RawCredentials | Path):

def get_user_jwt(f):
user_jwt = None
Expand Down

0 comments on commit 72112c3

Please sign in to comment.