UNPKG

2 kBTypeScriptView Raw
1import type { DefaultElements, MakeRequest, BasicMetaSysProps, SysLink } from '../common-types';
2type Application = {
3 id?: string;
4 name?: string;
5 sys: SysLink;
6};
7type AccessTokenSysProps = BasicMetaSysProps & {
8 application: Application | null;
9 expiresAt: string | null;
10 lastUsedAt: string | null;
11 redactedValue: string;
12};
13export type AccessTokenProps = {
14 sys: AccessTokenSysProps;
15 name: string;
16 scopes: 'content_management_manage'[];
17 revokedAt: null | string;
18 token?: string;
19};
20/**
21 * @deprecated Use `AccessTokenProps` instead.
22 */
23export type AccessTokenProp = AccessTokenProps;
24export type CreatePersonalAccessTokenProps = Pick<AccessToken, 'name' | 'scopes'> & {
25 expiresIn: number;
26};
27export interface AccessToken extends AccessTokenProps, DefaultElements<AccessTokenProps> {
28 /**
29 * Revokes access token
30 * @return Object the revoked access token
31 * @example ```javascript
32 * const contentful = require('contentful-management')
33 *
34 * const client = contentful.createClient({
35 * accessToken: <content_management_api_key>
36 * })
37 *
38 * client.getAccessToken('<token-id>')
39 * .then((AccessToken) => {
40 * return accessToken.revoke()
41 * })
42 * .catch(console.error)
43 * ```
44 */
45 revoke(): Promise<AccessToken>;
46}
47/**
48 * @private
49 * @param makeRequest - function to make requests via an adapter
50 * @param data - Raw access token data
51 * @return Wrapped access token
52 */
53export declare function wrapAccessToken(makeRequest: MakeRequest, data: AccessTokenProps): AccessToken;
54/**
55 * @private
56 * @param makeRequest - function to make requests via an adapter
57 * @param data - Raw access collection data
58 * @return Wrapped access token collection data
59 */
60export declare const wrapAccessTokenCollection: (makeRequest: MakeRequest, data: import("../common-types").CollectionProp<AccessTokenProps>) => import("../common-types").Collection<AccessToken, AccessTokenProps>;
61export {};