UNPKG

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