1export type CredentialType =
2 | "CREDENTIAL_TYPE_UNSPECIFIED"
3 | "USERNAME_AND_PASSWORD"
4 | "API_KEY"
5 | "OAUTH2_AUTHORIZATION_CODE"
6 | "OAUTH2_IMPLICIT"
7 | "OAUTH2_CLIENT_CREDENTIALS"
8 | "OAUTH2_RESOURCE_OWNER_CREDENTIALS"
9 | "JWT"
10 | "AUTH_TOKEN"
11 | "SERVICE_ACCOUNT"
12 | "CLIENT_CERTIFICATE_ONLY"
13 | "OIDC_TOKEN"
14 | (string & {});
15
16export type AuthConfigVisibility =
17 | "AUTH_CONFIG_VISIBILITY_UNSPECIFIED"
18 | "PRIVATE"
19 | "CLIENT_VISIBLE"
20 | (string & {});
21
22export type UsernameAndPassword = {
23 /** Username used to authenticate. */
24 username?: string;
25 /** Password used to authenticate. */
26 password?: string;
27};
28
29export type AuthToken = {
30 /** Token type (`Basic`, `Bearer`, …). */
31 type?: string;
32 /** Token value. */
33 token?: string;
34};
35
36export type JwtCredential = {
37 /** JWT header JSON. */
38 jwtHeader?: string;
39 /** JWT payload JSON. */
40 jwtPayload?: string;
41 /** Shared secret used to sign the token. */
42 secret?: string;
43};
44
45export type ServiceAccountCredentials = {
46 /** Service account email. */
47 serviceAccount?: string;
48 /** Space-delimited OAuth scopes. */
49 scope?: string;
50};
51
52export type OidcToken = {
53 /** Service account email used as the token identity. */
54 serviceAccountEmail?: string;
55 /** Audience claim. */
56 audience?: string;
57};
58
59export type DecryptedCredential = {
60 /** Credential type matching `credentialType` on the auth config. */
61 credentialType?: CredentialType;
62 /** Username and password credential. */
63 usernameAndPassword?: UsernameAndPassword;
64 /** HTTP Authorization token. */
65 authToken?: AuthToken;
66 /** JWT credential. */
67 jwt?: JwtCredential;
68 /** Service account credential. */
69 serviceAccountCredentials?: ServiceAccountCredentials;
70 /** Google OIDC ID token. */
71 oidcToken?: OidcToken;
72};
73
74export type TriggerType =
75 | "TRIGGER_TYPE_UNSPECIFIED"
76 | "CRON"
77 | "API"
78 | "SFDC_CHANNEL"
79 | "CLOUD_PUBSUB_EXTERNAL"
80 | "SFDC_CDC_CHANNEL"
81 | "CLOUD_SCHEDULER"
82 | "INTEGRATION_CONNECTOR_TRIGGER"
83 | "PRIVATE_TRIGGER"
84 | "CLOUD_PUBSUB"
85 | "EVENTARC_TRIGGER"
86 | (string & {});
87
88export type TriggerConfig = {
89 /** User-created label. */
90 label?: string;
91 /** Trigger type. */
92 triggerType?: TriggerType;
93 /** Unique number within the integration UI. */
94 triggerNumber?: string;
95 /**
96 * Trigger id. For API triggers this is `api_trigger/{name}` when
97 * `properties` contains `Trigger name`.
98 */
99 triggerId?: string;
100 /** Configurable trigger properties (`Trigger name`, …). */
101 properties?: Record<string, string | undefined>;
102 /** Human-readable description. */
103 description?: string;
104};
105
106export type ClientCertificate = {
107 /** PEM-encoded X.509 certificate, including BEGIN/END lines. */
108 sslCertificate?: string;
109 /** PEM-encoded private key, including BEGIN/END lines. */
110 encryptedPrivateKey?: string;
111 /** Passphrase if the private key is encrypted. */
112 passphrase?: string;
113};
114
115export const credentialBody = (
116 credential: DecryptedCredential | undefined,
117 defaultType?: CredentialType,
118) =>
119 credential === undefined
120 ? undefined
121 : {
122 credentialType: credential.credentialType ?? defaultType,
123 usernameAndPassword: credential.usernameAndPassword,
124 authToken: credential.authToken,
125 jwt: credential.jwt,
126 serviceAccountCredentials: credential.serviceAccountCredentials,
127 oidcToken: credential.oidcToken,
128 };