attlaz-client 1.16.4 → 1.16.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -4,7 +4,7 @@ import { CursorPagination } from '../Model/Pagination/CursorPagination.js';
|
|
|
4
4
|
import { UserAccessToken } from '../Model/AccessToken/UserAccessToken.js';
|
|
5
5
|
export declare class AccessTokenEndpoint extends Endpoint {
|
|
6
6
|
getByUser(pagination: CursorPagination): Promise<CollectionResult<UserAccessToken>>;
|
|
7
|
-
create(name: string, scopes: string[]): Promise<UserAccessToken>;
|
|
7
|
+
create(name: string, scopes: string[], expiresAt: Date): Promise<UserAccessToken>;
|
|
8
8
|
update(tokenId: string, name: string, scopes: string[]): Promise<UserAccessToken>;
|
|
9
9
|
revoke(tokenId: string): Promise<boolean>;
|
|
10
10
|
}
|
|
@@ -16,10 +16,15 @@ export class AccessTokenEndpoint extends Endpoint {
|
|
|
16
16
|
throw e;
|
|
17
17
|
}
|
|
18
18
|
}
|
|
19
|
-
async create(name, scopes) {
|
|
19
|
+
async create(name, scopes, expiresAt) {
|
|
20
20
|
try {
|
|
21
21
|
const url = '/access-tokens';
|
|
22
|
-
const
|
|
22
|
+
const data = {
|
|
23
|
+
name,
|
|
24
|
+
scopes,
|
|
25
|
+
expires_at: expiresAt,
|
|
26
|
+
};
|
|
27
|
+
const result = await this.requestObject(url, data, UserAccessToken.parse, 'POST');
|
|
23
28
|
const createdToken = result.getData();
|
|
24
29
|
if (createdToken === null) {
|
|
25
30
|
throw new Error('Unable to create token: wrong response from API');
|
|
@@ -36,7 +41,9 @@ export class AccessTokenEndpoint extends Endpoint {
|
|
|
36
41
|
async update(tokenId, name, scopes) {
|
|
37
42
|
try {
|
|
38
43
|
const url = '/access-tokens/' + tokenId;
|
|
39
|
-
const result = await this.requestObject(url, {
|
|
44
|
+
const result = await this.requestObject(url, {
|
|
45
|
+
name, scopes,
|
|
46
|
+
}, UserAccessToken.parse, 'POST');
|
|
40
47
|
const updatedToken = result.getData();
|
|
41
48
|
if (updatedToken === null) {
|
|
42
49
|
throw new Error('Unable to create token: wrong response from API');
|