UNPKG

2.23 kBTypeScriptView Raw
1import type { Except } from 'type-fest';
2import type { BasicMetaSysProps, DefaultElements, MakeRequest, SysLink } from '../common-types';
3type AppKeySys = Except<BasicMetaSysProps, 'version'> & {
4 appDefinition: SysLink;
5 organization: SysLink;
6};
7export interface JWK {
8 alg: 'RS256';
9 kty: 'RSA';
10 use: 'sig';
11 x5c: [string];
12 kid: string;
13 x5t: string;
14}
15export type AppKeyProps = {
16 /**
17 * System metadata
18 */
19 sys: AppKeySys;
20 /**
21 * JSON Web Key
22 */
23 jwk: JWK;
24 /**
25 * If generated, private key is returned
26 */
27 generated?: {
28 /**
29 * Base64 PEM
30 */
31 privateKey: string;
32 };
33};
34export type CreateAppKeyProps = {
35 /**
36 * Toggle for automatic private key generation
37 */
38 generate?: boolean;
39 /**
40 * JSON Web Key, required if generate is falsy
41 */
42 jwk?: JWK;
43};
44export interface AppKey extends AppKeyProps, DefaultElements<AppKeyProps> {
45 /**
46 * Deletes this object on the server.
47 * @return Promise for the deletion. It contains no data, but the Promise error case should be handled.
48 * @example ```javascript
49 * const contentful = require('contentful-management')
50 *
51 * const client = contentful.createClient({
52 * accessToken: '<content_management_api_key>'
53 * })
54 * client.getOrganization('<organization_id>')
55 * .then((organization) => organization.getAppKey(<api-key-id>))
56 * .then((signingSecret) => signingSecret.delete())
57 * .then(() => console.log('signingSecret deleted'))
58 * .catch(console.error)
59 * ```
60 */
61 delete(): Promise<void>;
62}
63/**
64 * @private
65 * @param http - HTTP client instance
66 * @param data - Raw AppKey data
67 * @return Wrapped AppKey data
68 */
69export declare function wrapAppKey(makeRequest: MakeRequest, data: AppKeyProps): AppKey;
70/**
71 * @private
72 * @param makeRequest - function to make requests via an adapter
73 * @param data - Raw App Key collection data
74 * @return Wrapped App Key collection data
75 */
76export declare const wrapAppKeyCollection: (makeRequest: MakeRequest, data: import("../common-types").CollectionProp<AppKeyProps>) => import("../common-types").Collection<AppKey, AppKeyProps>;
77export {};