Skip to content

Commit 87ca921

Browse files
committed
Add new setUserTokenConfiguration.
1 parent 17a5e61 commit 87ca921

File tree

4 files changed

+91
-1
lines changed

4 files changed

+91
-1
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ This is the changelog for [Authress SDK](readme.md).
88
* [Breaking] `ServiceClientTokenProvider` is now a first-class Javascript Class, it cannot be used as a function.
99
* [Breaking] `setToken` has been removed from the interface. To set a user token, pass in a function into the AuthressClient constructor.
1010
* [Fix] Remove passing the token in the request for token verification, it is completely unnecessary, and does not work for service clients in any scenario.
11+
* Add UserTokenConfiguration and setUserTokenConfiguration
1112

1213
## 2.3 ##
1314
* Require minimum Node version to be 16.

docs/UsersApi.md

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ Method | HTTP request | Description
55
------------- | ------------- | -------------
66
[**deleteUser**](UsersApi.md#deleteUser) | **DELETE** /v1/users/{userId} | Delete a user
77
[**getUser**](UsersApi.md#getUser) | **GET** /v1/users/{userId} | Retrieve a user
8+
[**setUserTokenConfiguration**](UsersApi.md#setUserTokenConfiguration) | **PUT** /v1/users/{userId}/token-configuration | Set user token configuration
89
[**getUsers**](UsersApi.md#getUsers) | **GET** /v1/users | List users
910
[**linkTenantUser**](UsersApi.md#linkTenantUser) | **PATCH** /v1/tenants/{tenantId}/users | Link tenant user
1011

@@ -101,6 +102,33 @@ Name | Type | Description | Notes
101102
[**UserIdentityCollection**](UserIdentityCollection.md)
102103

103104

105+
## setUserTokenConfiguration
106+
107+
> UserIdentity setUserTokenConfiguration(userId, tokenConfiguration)
108+
109+
Set user token configuration.
110+
111+
Sets the user authentication configuration. This endpoint contains properties that allow detailed control over tokens generated for the user.
112+
113+
### Example
114+
115+
```javascript
116+
import { AuthressClient, UserTokenConfiguration } from '@authress/sdk';
117+
118+
const userId = "userId_example"; // UserId | The user identifier.
119+
const tokenConfiguration = new UserTokenConfiguration(); // UserTokenConfiguration
120+
await new AuthressClient().users.setUserTokenConfiguration(userId, tokenConfiguration);
121+
```
122+
123+
### Parameters
124+
125+
126+
Name | Type | Description | Notes
127+
------------- | ------------- | ------------- | -------------
128+
**userId** | **String**| The user identifier. |
129+
**tokenConfiguration** | **UserTokenConfiguration** | Token configuration dedicated for the specific user. |
130+
131+
104132
## linkTenantUser
105133

106134
> linkTenantUser(tenantId, tenantUser)

index.d.ts

Lines changed: 50 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -646,6 +646,46 @@ export interface UserIdentity {
646646
* @memberof UserIdentity
647647
*/
648648
email?: string;
649+
650+
/**
651+
*
652+
* @type {UserTokenConfiguration}
653+
* @memberof UserIdentity
654+
*/
655+
tokenConfiguration?: UserTokenConfiguration;
656+
}
657+
658+
/**
659+
* @export
660+
* @interface UserTokenConfiguration
661+
*/
662+
export interface UserTokenConfiguration {
663+
/**
664+
* Default fallback configuration for the claims inserted into the JWTs generated by Authress.
665+
* @type {DefaultClaims}
666+
* @memberof UserTokenConfiguration
667+
*/
668+
defaultClaims?: DefaultClaims;
669+
}
670+
671+
/**
672+
* @export
673+
* @interface DefaultClaims
674+
*/
675+
export interface DefaultClaims {
676+
/**
677+
* A map of claims to add to generated JWTs. These claims are used when explicitly not specified by Authress. Do not include any value specified by https://www.iana.org/assignments/jwt/jwt.xhtml as they will get overwritten. Must be smaller than 1024 Bytes.
678+
* @type {Record<string, unknown>}
679+
* @memberof DefaultClaims
680+
*/
681+
defaultAccessTokenClaims?: Record<string, unknown>;
682+
683+
/**
684+
* A map of claims to add to generated user identity tokens. These claims are used when explicitly not specified by Authress. Do not include any value specified by https://www.iana.org/assignments/jwt/jwt.xhtml as they will get overwritten. Must be smaller than 1024 Bytes.
685+
* @type {Record<string, unknown>}
686+
* @memberof DefaultClaims
687+
*/
688+
defaultUserIdentityClaims?: Record<string, unknown>;
649689
}
650690

651691
/**
@@ -931,10 +971,19 @@ export interface UsersApi {
931971
/**
932972
* Get an Authress user
933973
* @summary Retrieve a user with user data.
934-
* @param {string} [userId] The user te get.
974+
* @param {string} userId The user te get.
935975
* @throws {ArgumentRequiredError}
936976
*/
937977
getUser(userId: string): Promise<Response<UserIdentity>>;
978+
979+
/**
980+
* Set user token configuration
981+
* @summary Sets the user authentication configuration. This endpoint contains properties that allow detailed control over tokens generated for the user.
982+
* @param {string} userId The user identifier.
983+
* @param {UserTokenConfiguration} tokenConfiguration The user token configuration, used to configure token properties.
984+
* @throws {ArgumentRequiredError}
985+
*/
986+
setUserTokenConfiguration(userId: string, tokenConfiguration: UserTokenConfiguration): Promise<Response<void>>;
938987
}
939988

940989
/**

src/usersApi.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,18 @@ class UsersApi {
1414
const response = await this.client.get(url);
1515
return response;
1616
}
17+
18+
async setUserTokenConfiguration(userId, tokenConfiguration) {
19+
if (userId === null || userId === undefined) {
20+
throw new ArgumentRequiredError('userId', 'Required parameter userId was null or undefined when calling setUserTokenConfiguration.');
21+
}
22+
if (tokenConfiguration === null || tokenConfiguration === undefined) {
23+
throw new ArgumentRequiredError('tokenConfiguration', 'Required parameter tokenConfiguration was null or undefined when calling setUserTokenConfiguration.');
24+
}
25+
const url = `/v1/users/${encodeURIComponent(String(userId))}`;
26+
const response = await this.client.put(url, tokenConfiguration);
27+
return response;
28+
}
1729
}
1830

1931
module.exports = UsersApi;

0 commit comments

Comments
 (0)