Skip to content

Commit 769a6c5

Browse files
authored
Rename handle to username (#25)
This better reflects current best practices and API documentation.
1 parent facb70f commit 769a6c5

File tree

3 files changed

+9
-9
lines changed

3 files changed

+9
-9
lines changed

README.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ Once you obtain a registration token from your frontend, use the `Client` to com
4949
$token = 'value_from_frontend'; // $_POST['snapauth_token'] or similar
5050
$userInfo = [
5151
'id' => 'your_user_id',
52-
'handle' => 'your_user_handle',
52+
'username' => 'your_username',
5353
];
5454
$snapAuth->attachRegistration($token, $userInfo);
5555
```
@@ -64,24 +64,24 @@ This activates the passkey and associates it with the user.
6464

6565
`id` should be some sort of _stable_ identifer, like a database primary key.
6666

67-
`handle` can be anything you want, or omitted entirely.
67+
`username` can be anything you want, or omitted entirely.
6868
It's a convenience during _client_ authentication so you don't need to look up the user id again.
6969
This would commonly be the value a user provides to sign in, such as a username or email.
70+
It is _not_ a given name.
7071

7172
Both must be strings, and can be up to 255 characters long.
7273
Lookups during authentication are **case-insensitive**.
7374

7475
> [!TIP]
75-
> We strongly ENCOURAGE you to obfuscate any possibly sensitive information, such as email addresses.
76-
> You can accomplish this by hashing the value.
77-
> Be aware that to use the handle during authentication, you will want to replicate the obfuscation procedure on your frontend.
76+
> In order to preseve user privacy, we store only a one-way hash of the `username` values.
77+
> As a result, we cannot return the original value in other API calls.
7878
7979
### Authentication
8080

8181
Like registration, you will need to obtain a token from your frontend provided by the client SDK.
8282

8383
Use the `verifyAuthToken` method to get information about the authentication process, in the form of an `AuthResponse` object.
84-
This object contains the previously-registered User `id` and `handle`.
84+
This object contains the previously-registered User `id`.
8585

8686
```php
8787
$token = 'value_from_frontend'; // $_POST['snapauth_token'] or similar

src/Client.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ public function verifyAuthToken(string $authToken): AuthResponse
7676

7777
/**
7878
* @param array{
79-
* handle?: string,
79+
* username?: string,
8080
* id: string,
8181
* } $user
8282
*/

src/ErrorCode.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@ enum ErrorCode: string
88
{
99
case AuthenticatingUserAccountNotFound = 'AuthenticatingUserAccountNotFound';
1010
case EntityNotFound = 'EntityNotFound';
11-
case HandleCannotChange = 'HandleCannotChange';
12-
case HandleInUseByDifferentAccount = 'HandleInUseByDifferentAccount';
1311
case InvalidAuthorizationHeader = 'InvalidAuthorizationHeader';
1412
case InvalidInput = 'InvalidInput';
1513
case PermissionViolation = 'PermissionViolation';
@@ -19,6 +17,8 @@ enum ErrorCode: string
1917
case SecretKeyNotFound = 'SecretKeyNotFound';
2018
case TokenExpired = 'TokenExpired';
2119
case TokenNotFound = 'TokenNotFound';
20+
case UsernameCannotChange = 'UsernameCannotChange';
21+
case UsernameInUseByDifferentAccount = 'UsernameInUseByDifferentAccount';
2222
case UsingDeactivatedCredential = 'UsingDeactivatedCredential';
2323

2424
/**

0 commit comments

Comments
 (0)