@zyphr-dev/node-sdk 0.1.37 → 0.1.38
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.
- package/README.md +39 -0
- package/dist/index.cjs +690 -47
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +660 -59
- package/dist/index.d.ts +660 -59
- package/dist/index.js +659 -47
- package/dist/index.js.map +1 -1
- package/package.json +8 -3
- package/src/.openapi-generator/FILES +6 -0
- package/src/clientAuth.ts +182 -0
- package/src/errors.ts +29 -16
- package/src/index.ts +4 -1
- package/src/src/apis/AuthOAuthApi.ts +27 -24
- package/src/src/apis/AuthRegistrationApi.ts +69 -4
- package/src/src/apis/AuthUserDirectoryApi.ts +596 -0
- package/src/src/apis/AuthUserProfileApi.ts +0 -62
- package/src/src/apis/index.ts +1 -0
- package/src/src/models/InviteEndUserRequest.ts +110 -0
- package/src/src/models/OAuthProviderName.ts +56 -0
- package/src/src/models/SetEndUserClaimsRequest.ts +65 -0
- package/src/src/models/SignInAnonymouslyRequest.ts +16 -0
- package/src/src/models/SignInWithGameCenterRequest.ts +111 -0
- package/src/src/models/UpdateEndUserByApplicationRequest.ts +97 -0
- package/src/src/models/index.ts +5 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zyphr-dev/node-sdk",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.38",
|
|
4
4
|
"description": "Official Zyphr SDK for Node.js, React, and React Native",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.cjs",
|
|
@@ -49,10 +49,15 @@
|
|
|
49
49
|
"openapi"
|
|
50
50
|
],
|
|
51
51
|
"license": "MIT",
|
|
52
|
-
"homepage": "https://
|
|
52
|
+
"homepage": "https://zyphr.dev/docs/sdks/node",
|
|
53
|
+
"repository": {
|
|
54
|
+
"type": "git",
|
|
55
|
+
"url": "git+https://github.com/ArcRaz/zyphr.git",
|
|
56
|
+
"directory": "packages/sdk/node"
|
|
57
|
+
},
|
|
53
58
|
"bugs": {
|
|
54
59
|
"email": "support@zyphr.dev",
|
|
55
|
-
"url": "https://
|
|
60
|
+
"url": "https://zyphr.dev/docs"
|
|
56
61
|
},
|
|
57
62
|
"engines": {
|
|
58
63
|
"node": ">=18.0.0"
|
|
@@ -14,6 +14,7 @@ src/apis/AuthPasswordResetApi.ts
|
|
|
14
14
|
src/apis/AuthPhoneApi.ts
|
|
15
15
|
src/apis/AuthRegistrationApi.ts
|
|
16
16
|
src/apis/AuthSessionsApi.ts
|
|
17
|
+
src/apis/AuthUserDirectoryApi.ts
|
|
17
18
|
src/apis/AuthUserProfileApi.ts
|
|
18
19
|
src/apis/AuthWebAuthnApi.ts
|
|
19
20
|
src/apis/DevicesApi.ts
|
|
@@ -166,6 +167,7 @@ src/models/InboundEmailResponse.ts
|
|
|
166
167
|
src/models/InboxListMeta.ts
|
|
167
168
|
src/models/InboxListResponse.ts
|
|
168
169
|
src/models/InboxNotificationResponse.ts
|
|
170
|
+
src/models/InviteEndUserRequest.ts
|
|
169
171
|
src/models/ListWaaSApplications200Response.ts
|
|
170
172
|
src/models/ListWaaSEndpointDeliveries200Response.ts
|
|
171
173
|
src/models/ListWaaSEndpoints200Response.ts
|
|
@@ -210,6 +212,7 @@ src/models/OAuthConnectionsResponse.ts
|
|
|
210
212
|
src/models/OAuthConnectionsResponseData.ts
|
|
211
213
|
src/models/OAuthProvider.ts
|
|
212
214
|
src/models/OAuthProviderInfo.ts
|
|
215
|
+
src/models/OAuthProviderName.ts
|
|
213
216
|
src/models/OAuthProvidersResponse.ts
|
|
214
217
|
src/models/OAuthProvidersResponseData.ts
|
|
215
218
|
src/models/OAuthTokensRefreshResponse.ts
|
|
@@ -313,9 +316,11 @@ src/models/SessionListResponse.ts
|
|
|
313
316
|
src/models/SessionListResponseData.ts
|
|
314
317
|
src/models/SessionListResponseDataSessionInfo.ts
|
|
315
318
|
src/models/SetDomainInboundRequest.ts
|
|
319
|
+
src/models/SetEndUserClaimsRequest.ts
|
|
316
320
|
src/models/SetPreferencesRequest.ts
|
|
317
321
|
src/models/SetPreferencesRequestPreferencesInner.ts
|
|
318
322
|
src/models/SignInAnonymouslyRequest.ts
|
|
323
|
+
src/models/SignInWithGameCenterRequest.ts
|
|
319
324
|
src/models/SlackMessage.ts
|
|
320
325
|
src/models/SlackMessageListResponse.ts
|
|
321
326
|
src/models/SlackMessageListResponseMeta.ts
|
|
@@ -371,6 +376,7 @@ src/models/UnsubscribeListResponse.ts
|
|
|
371
376
|
src/models/UnsubscribeRequest.ts
|
|
372
377
|
src/models/UnsubscribeResponse.ts
|
|
373
378
|
src/models/UpdateCategoryRequest.ts
|
|
379
|
+
src/models/UpdateEndUserByApplicationRequest.ts
|
|
374
380
|
src/models/UpdateEndUserRequest.ts
|
|
375
381
|
src/models/UpdateOrganizationMemberRoleRequest.ts
|
|
376
382
|
src/models/UpdateOrganizationRequest.ts
|
|
@@ -0,0 +1,182 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Zyphr client-side auth (sc-7326, Option A).
|
|
3
|
+
*
|
|
4
|
+
* `ZyphrClient` is a browser / React Native-safe entry point for Auth-as-a-Service.
|
|
5
|
+
* Unlike the server `Zyphr` client (which requires a secret API key and, for auth,
|
|
6
|
+
* an application SECRET key), `ZyphrClient` is constructed with ONLY the publishable
|
|
7
|
+
* application key (`za_pub_*`) — the key that is safe to ship in a client bundle —
|
|
8
|
+
* plus, once the user is authenticated, their end-user access token.
|
|
9
|
+
*
|
|
10
|
+
* It deliberately exposes ONLY the end-user-scoped auth surface (login, registration,
|
|
11
|
+
* sessions, magic links, OAuth, phone, email-OTP, profile, MFA, WebAuthn, password
|
|
12
|
+
* reset, email verification) and device registration for push. It does NOT expose
|
|
13
|
+
* server-only APIs (emails, templates, webhooks, the secret-key user directory, etc.),
|
|
14
|
+
* because those require a secret this client must never hold.
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* ```ts
|
|
18
|
+
* import { ZyphrClient } from '@zyphr-dev/node-sdk';
|
|
19
|
+
*
|
|
20
|
+
* const zyphr = new ZyphrClient({ applicationKey: 'za_pub_xxx' });
|
|
21
|
+
*
|
|
22
|
+
* const login = await zyphr.auth.login.loginEndUser({ ... });
|
|
23
|
+
* zyphr.setAccessToken(login.data.tokens.access_token);
|
|
24
|
+
*
|
|
25
|
+
* const me = await zyphr.auth.profile.getEndUser(zyphr.authedRequest());
|
|
26
|
+
* ```
|
|
27
|
+
*/
|
|
28
|
+
|
|
29
|
+
import { Configuration } from './src/runtime.js';
|
|
30
|
+
import type { Middleware, ResponseContext } from './src/runtime.js';
|
|
31
|
+
import {
|
|
32
|
+
AuthEmailOTPApi,
|
|
33
|
+
AuthEmailVerificationApi,
|
|
34
|
+
AuthLoginApi,
|
|
35
|
+
AuthMFAApi,
|
|
36
|
+
AuthMagicLinksApi,
|
|
37
|
+
AuthOAuthApi,
|
|
38
|
+
AuthOrganizationsApi,
|
|
39
|
+
AuthPasswordResetApi,
|
|
40
|
+
AuthPhoneApi,
|
|
41
|
+
AuthRegistrationApi,
|
|
42
|
+
AuthSessionsApi,
|
|
43
|
+
AuthUserProfileApi,
|
|
44
|
+
AuthWebAuthnApi,
|
|
45
|
+
DevicesApi,
|
|
46
|
+
} from './src/apis/index.js';
|
|
47
|
+
import { parseErrorResponse } from './errors.js';
|
|
48
|
+
|
|
49
|
+
export interface ZyphrClientOptions {
|
|
50
|
+
/** Publishable application key (za_pub_*) — safe to embed in a client bundle. */
|
|
51
|
+
applicationKey: string;
|
|
52
|
+
/** Override the base API URL (defaults to https://api.zyphr.dev/v1). */
|
|
53
|
+
baseUrl?: string;
|
|
54
|
+
/** Optional end-user access token, if you already have a session on construction. */
|
|
55
|
+
accessToken?: string;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
const errorMiddleware: Middleware = {
|
|
59
|
+
async post(context: ResponseContext): Promise<Response | void> {
|
|
60
|
+
if (context.response.status >= 200 && context.response.status < 300) {
|
|
61
|
+
return;
|
|
62
|
+
}
|
|
63
|
+
throw await parseErrorResponse(context.response);
|
|
64
|
+
},
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* Thrown when a secret-shaped credential is passed to the client-safe SDK. This
|
|
69
|
+
* is a guardrail against accidentally shipping a secret in a client bundle.
|
|
70
|
+
*/
|
|
71
|
+
export class ZyphrClientCredentialError extends Error {
|
|
72
|
+
constructor(message: string) {
|
|
73
|
+
super(message);
|
|
74
|
+
this.name = 'ZyphrClientCredentialError';
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
/** Prefixes that must NEVER reach a client bundle. */
|
|
79
|
+
const SECRET_KEY_PREFIXES = ['za_sec_', 'zy_live_', 'zy_test_'];
|
|
80
|
+
|
|
81
|
+
export class ZyphrClient {
|
|
82
|
+
readonly auth: {
|
|
83
|
+
readonly login: AuthLoginApi;
|
|
84
|
+
readonly registration: AuthRegistrationApi;
|
|
85
|
+
readonly sessions: AuthSessionsApi;
|
|
86
|
+
readonly emailVerification: AuthEmailVerificationApi;
|
|
87
|
+
readonly passwordReset: AuthPasswordResetApi;
|
|
88
|
+
readonly mfa: AuthMFAApi;
|
|
89
|
+
readonly magicLinks: AuthMagicLinksApi;
|
|
90
|
+
readonly oauth: AuthOAuthApi;
|
|
91
|
+
readonly organizations: AuthOrganizationsApi;
|
|
92
|
+
readonly phone: AuthPhoneApi;
|
|
93
|
+
readonly emailOtp: AuthEmailOTPApi;
|
|
94
|
+
readonly profile: AuthUserProfileApi;
|
|
95
|
+
readonly webauthn: AuthWebAuthnApi;
|
|
96
|
+
};
|
|
97
|
+
|
|
98
|
+
/** Device registration for push (takes an OS-acquired token). */
|
|
99
|
+
readonly devices: DevicesApi;
|
|
100
|
+
|
|
101
|
+
private readonly applicationKey: string;
|
|
102
|
+
private accessToken?: string;
|
|
103
|
+
|
|
104
|
+
constructor(options: ZyphrClientOptions) {
|
|
105
|
+
if (!options.applicationKey) {
|
|
106
|
+
throw new ZyphrClientCredentialError('applicationKey (za_pub_*) is required');
|
|
107
|
+
}
|
|
108
|
+
// Guardrail: reject secret-shaped credentials so a secret can't be shipped
|
|
109
|
+
// in a client bundle by mistake.
|
|
110
|
+
if (SECRET_KEY_PREFIXES.some((p) => options.applicationKey.startsWith(p))) {
|
|
111
|
+
throw new ZyphrClientCredentialError(
|
|
112
|
+
'ZyphrClient must be constructed with a publishable application key (za_pub_*), ' +
|
|
113
|
+
'never a secret key. Secret keys must stay server-side.'
|
|
114
|
+
);
|
|
115
|
+
}
|
|
116
|
+
if (!options.applicationKey.startsWith('za_pub_')) {
|
|
117
|
+
throw new ZyphrClientCredentialError(
|
|
118
|
+
'applicationKey must be a publishable application key (za_pub_*).'
|
|
119
|
+
);
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
this.applicationKey = options.applicationKey;
|
|
123
|
+
this.accessToken = options.accessToken;
|
|
124
|
+
|
|
125
|
+
const config = new Configuration({
|
|
126
|
+
basePath: options.baseUrl,
|
|
127
|
+
// The only credential this client sends automatically is the publishable
|
|
128
|
+
// application key. End-user Bearer tokens are attached per-request via
|
|
129
|
+
// authedRequest() so token rotation doesn't require rebuilding the client.
|
|
130
|
+
apiKey: (name: string) => (name === 'X-Application-Key' ? this.applicationKey : ''),
|
|
131
|
+
middleware: [errorMiddleware],
|
|
132
|
+
});
|
|
133
|
+
|
|
134
|
+
this.auth = {
|
|
135
|
+
login: new AuthLoginApi(config),
|
|
136
|
+
registration: new AuthRegistrationApi(config),
|
|
137
|
+
sessions: new AuthSessionsApi(config),
|
|
138
|
+
emailVerification: new AuthEmailVerificationApi(config),
|
|
139
|
+
passwordReset: new AuthPasswordResetApi(config),
|
|
140
|
+
mfa: new AuthMFAApi(config),
|
|
141
|
+
magicLinks: new AuthMagicLinksApi(config),
|
|
142
|
+
oauth: new AuthOAuthApi(config),
|
|
143
|
+
organizations: new AuthOrganizationsApi(config),
|
|
144
|
+
phone: new AuthPhoneApi(config),
|
|
145
|
+
emailOtp: new AuthEmailOTPApi(config),
|
|
146
|
+
profile: new AuthUserProfileApi(config),
|
|
147
|
+
webauthn: new AuthWebAuthnApi(config),
|
|
148
|
+
};
|
|
149
|
+
this.devices = new DevicesApi(config);
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
/** Store the end-user access token for subsequent authedRequest() calls. */
|
|
153
|
+
setAccessToken(accessToken: string | undefined): void {
|
|
154
|
+
this.accessToken = accessToken;
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
/** True when an end-user access token is currently set. */
|
|
158
|
+
get isAuthenticated(): boolean {
|
|
159
|
+
return Boolean(this.accessToken);
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
/**
|
|
163
|
+
* Build request overrides that authenticate as the current end user: the
|
|
164
|
+
* stored Bearer token plus the publishable application key required by
|
|
165
|
+
* user-scoped endpoints. Pass an explicit token to override the stored one.
|
|
166
|
+
*
|
|
167
|
+
* @example
|
|
168
|
+
* ```ts
|
|
169
|
+
* const me = await zyphr.auth.profile.getEndUser(zyphr.authedRequest());
|
|
170
|
+
* ```
|
|
171
|
+
*/
|
|
172
|
+
authedRequest(accessToken?: string): RequestInit {
|
|
173
|
+
const token = accessToken ?? this.accessToken;
|
|
174
|
+
const headers: Record<string, string> = {
|
|
175
|
+
'X-Application-Key': this.applicationKey,
|
|
176
|
+
};
|
|
177
|
+
if (token) {
|
|
178
|
+
headers.Authorization = `Bearer ${token}`;
|
|
179
|
+
}
|
|
180
|
+
return { headers };
|
|
181
|
+
}
|
|
182
|
+
}
|
package/src/errors.ts
CHANGED
|
@@ -43,8 +43,8 @@ export class ZyphrError extends Error {
|
|
|
43
43
|
* Thrown when the API returns a 400/422 validation error.
|
|
44
44
|
*/
|
|
45
45
|
export class ZyphrValidationError extends ZyphrError {
|
|
46
|
-
constructor(message: string, details?: Record<string, unknown
|
|
47
|
-
super({ message, status: 422, code
|
|
46
|
+
constructor(message: string, details?: Record<string, unknown>, code = 'validation_error') {
|
|
47
|
+
super({ message, status: 422, code, details });
|
|
48
48
|
this.name = 'ZyphrValidationError';
|
|
49
49
|
}
|
|
50
50
|
}
|
|
@@ -53,8 +53,8 @@ export class ZyphrValidationError extends ZyphrError {
|
|
|
53
53
|
* Thrown when the API returns a 401/403 authentication error.
|
|
54
54
|
*/
|
|
55
55
|
export class ZyphrAuthenticationError extends ZyphrError {
|
|
56
|
-
constructor(message: string) {
|
|
57
|
-
super({ message, status: 401, code
|
|
56
|
+
constructor(message: string, code = 'authentication_error') {
|
|
57
|
+
super({ message, status: 401, code });
|
|
58
58
|
this.name = 'ZyphrAuthenticationError';
|
|
59
59
|
}
|
|
60
60
|
}
|
|
@@ -65,8 +65,8 @@ export class ZyphrAuthenticationError extends ZyphrError {
|
|
|
65
65
|
export class ZyphrRateLimitError extends ZyphrError {
|
|
66
66
|
readonly retryAfter?: number;
|
|
67
67
|
|
|
68
|
-
constructor(message: string, retryAfter?: number) {
|
|
69
|
-
super({ message, status: 429, code
|
|
68
|
+
constructor(message: string, retryAfter?: number, code = 'rate_limit_exceeded') {
|
|
69
|
+
super({ message, status: 429, code });
|
|
70
70
|
this.name = 'ZyphrRateLimitError';
|
|
71
71
|
this.retryAfter = retryAfter;
|
|
72
72
|
}
|
|
@@ -76,8 +76,8 @@ export class ZyphrRateLimitError extends ZyphrError {
|
|
|
76
76
|
* Thrown when the API returns a 404 not found error.
|
|
77
77
|
*/
|
|
78
78
|
export class ZyphrNotFoundError extends ZyphrError {
|
|
79
|
-
constructor(message: string) {
|
|
80
|
-
super({ message, status: 404, code
|
|
79
|
+
constructor(message: string, code = 'not_found') {
|
|
80
|
+
super({ message, status: 404, code });
|
|
81
81
|
this.name = 'ZyphrNotFoundError';
|
|
82
82
|
}
|
|
83
83
|
}
|
|
@@ -93,8 +93,13 @@ export class ZyphrNotFoundError extends ZyphrError {
|
|
|
93
93
|
* @see https://zyphr.dev/resources/api-limits
|
|
94
94
|
*/
|
|
95
95
|
export class ZyphrPayloadTooLargeError extends ZyphrError {
|
|
96
|
-
constructor(
|
|
97
|
-
|
|
96
|
+
constructor(
|
|
97
|
+
message: string,
|
|
98
|
+
details?: Record<string, unknown>,
|
|
99
|
+
requestId?: string,
|
|
100
|
+
code = 'payload_too_large',
|
|
101
|
+
) {
|
|
102
|
+
super({ message, status: 413, code, details, requestId });
|
|
98
103
|
this.name = 'ZyphrPayloadTooLargeError';
|
|
99
104
|
}
|
|
100
105
|
|
|
@@ -145,25 +150,33 @@ export async function parseErrorResponse(response: Response): Promise<ZyphrError
|
|
|
145
150
|
const error = (body.error ?? {}) as Record<string, unknown>;
|
|
146
151
|
const meta = (body.meta ?? {}) as Record<string, unknown>;
|
|
147
152
|
const message = (error.message as string) ?? response.statusText ?? 'Unknown error';
|
|
148
|
-
|
|
153
|
+
// Coerce a missing / null / empty code to `undefined` so the typed-error
|
|
154
|
+
// constructors fall back to their generic default (a bare `null`/'' from a
|
|
155
|
+
// malformed or proxy-mangled response would otherwise be preserved verbatim).
|
|
156
|
+
const code = (error.code as string | undefined) || undefined;
|
|
149
157
|
const requestId = meta.request_id as string | undefined;
|
|
150
158
|
const details = error.details as Record<string, unknown> | undefined;
|
|
151
159
|
|
|
160
|
+
// Preserve the API's machine-readable `error.code` on the typed error so
|
|
161
|
+
// consumers can branch on it (e.g. `account_frozen`, `otp_invalid`,
|
|
162
|
+
// `email_not_found`) instead of matching `message` text. The subclass
|
|
163
|
+
// identity and `status` are unchanged; when the body omits a code we fall
|
|
164
|
+
// back to each subclass's generic default (older API responses).
|
|
152
165
|
switch (response.status) {
|
|
153
166
|
case 400:
|
|
154
167
|
case 422:
|
|
155
|
-
return new ZyphrValidationError(message, details);
|
|
168
|
+
return new ZyphrValidationError(message, details, code);
|
|
156
169
|
case 401:
|
|
157
170
|
case 403:
|
|
158
|
-
return new ZyphrAuthenticationError(message);
|
|
171
|
+
return new ZyphrAuthenticationError(message, code);
|
|
159
172
|
case 404:
|
|
160
|
-
return new ZyphrNotFoundError(message);
|
|
173
|
+
return new ZyphrNotFoundError(message, code);
|
|
161
174
|
case 413:
|
|
162
|
-
return new ZyphrPayloadTooLargeError(message, details, requestId);
|
|
175
|
+
return new ZyphrPayloadTooLargeError(message, details, requestId, code);
|
|
163
176
|
case 429: {
|
|
164
177
|
const retryAfterHeader = response.headers.get('Retry-After');
|
|
165
178
|
const retryAfter = retryAfterHeader ? parseInt(retryAfterHeader, 10) : undefined;
|
|
166
|
-
return new ZyphrRateLimitError(message, retryAfter);
|
|
179
|
+
return new ZyphrRateLimitError(message, retryAfter, code);
|
|
167
180
|
}
|
|
168
181
|
default:
|
|
169
182
|
return new ZyphrError({ message, status: response.status, code, requestId, details });
|
package/src/index.ts
CHANGED
|
@@ -21,5 +21,8 @@ export * from './src/models/index.js';
|
|
|
21
21
|
// Error classes
|
|
22
22
|
export * from './errors.js';
|
|
23
23
|
|
|
24
|
-
// Client
|
|
24
|
+
// Client (server-side; requires secret keys)
|
|
25
25
|
export * from './client.js';
|
|
26
|
+
|
|
27
|
+
// Client-safe auth (browser / React Native; publishable key only) — sc-7326
|
|
28
|
+
export * from './clientAuth.js';
|
|
@@ -21,6 +21,7 @@ import type {
|
|
|
21
21
|
OAuthCallbackResponse,
|
|
22
22
|
OAuthConnectionInfoResponse,
|
|
23
23
|
OAuthConnectionsResponse,
|
|
24
|
+
OAuthProviderName,
|
|
24
25
|
OAuthProvidersResponse,
|
|
25
26
|
OAuthTokensRefreshResponse,
|
|
26
27
|
OAuthTokensResponse,
|
|
@@ -40,6 +41,8 @@ import {
|
|
|
40
41
|
OAuthConnectionInfoResponseToJSON,
|
|
41
42
|
OAuthConnectionsResponseFromJSON,
|
|
42
43
|
OAuthConnectionsResponseToJSON,
|
|
44
|
+
OAuthProviderNameFromJSON,
|
|
45
|
+
OAuthProviderNameToJSON,
|
|
43
46
|
OAuthProvidersResponseFromJSON,
|
|
44
47
|
OAuthProvidersResponseToJSON,
|
|
45
48
|
OAuthTokensRefreshResponseFromJSON,
|
|
@@ -53,30 +56,30 @@ import {
|
|
|
53
56
|
} from '../models/index';
|
|
54
57
|
|
|
55
58
|
export interface AuthOAuthApiDisconnectOAuthProviderRequest {
|
|
56
|
-
provider:
|
|
59
|
+
provider: OAuthProviderName;
|
|
57
60
|
}
|
|
58
61
|
|
|
59
62
|
export interface AuthOAuthApiGetOAuthAuthorizationUrlRequest {
|
|
60
|
-
provider:
|
|
63
|
+
provider: OAuthProviderName;
|
|
61
64
|
redirectUri: string;
|
|
62
65
|
}
|
|
63
66
|
|
|
64
67
|
export interface AuthOAuthApiGetOAuthConnectionInfoRequest {
|
|
65
|
-
provider:
|
|
68
|
+
provider: OAuthProviderName;
|
|
66
69
|
}
|
|
67
70
|
|
|
68
71
|
export interface AuthOAuthApiGetOAuthTokensRequest {
|
|
69
|
-
provider:
|
|
72
|
+
provider: OAuthProviderName;
|
|
70
73
|
userId: string;
|
|
71
74
|
}
|
|
72
75
|
|
|
73
76
|
export interface AuthOAuthApiHandleOAuthCallbackRequest {
|
|
74
|
-
provider:
|
|
77
|
+
provider: OAuthProviderName;
|
|
75
78
|
oAuthCallbackRequest: OAuthCallbackRequest;
|
|
76
79
|
}
|
|
77
80
|
|
|
78
81
|
export interface AuthOAuthApiRefreshOAuthTokensOperationRequest {
|
|
79
|
-
provider:
|
|
82
|
+
provider: OAuthProviderName;
|
|
80
83
|
refreshOAuthTokensRequest: RefreshOAuthTokensRequest;
|
|
81
84
|
}
|
|
82
85
|
|
|
@@ -90,7 +93,7 @@ export interface AuthOAuthApiInterface {
|
|
|
90
93
|
/**
|
|
91
94
|
* Disconnect an OAuth provider from the current user.
|
|
92
95
|
* @summary Disconnect OAuth provider
|
|
93
|
-
* @param {
|
|
96
|
+
* @param {OAuthProviderName} provider OAuth provider name
|
|
94
97
|
* @param {*} [options] Override http request option.
|
|
95
98
|
* @throws {RequiredError}
|
|
96
99
|
* @memberof AuthOAuthApiInterface
|
|
@@ -101,12 +104,12 @@ export interface AuthOAuthApiInterface {
|
|
|
101
104
|
* Disconnect an OAuth provider from the current user.
|
|
102
105
|
* Disconnect OAuth provider
|
|
103
106
|
*/
|
|
104
|
-
disconnectOAuthProvider(provider:
|
|
107
|
+
disconnectOAuthProvider(provider: OAuthProviderName, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<SuccessResult>;
|
|
105
108
|
|
|
106
109
|
/**
|
|
107
110
|
* Generate an OAuth authorization URL for the specified provider.
|
|
108
111
|
* @summary Get OAuth authorization URL
|
|
109
|
-
* @param {
|
|
112
|
+
* @param {OAuthProviderName} provider OAuth provider name
|
|
110
113
|
* @param {string} redirectUri Redirect URI after authorization
|
|
111
114
|
* @param {*} [options] Override http request option.
|
|
112
115
|
* @throws {RequiredError}
|
|
@@ -118,12 +121,12 @@ export interface AuthOAuthApiInterface {
|
|
|
118
121
|
* Generate an OAuth authorization URL for the specified provider.
|
|
119
122
|
* Get OAuth authorization URL
|
|
120
123
|
*/
|
|
121
|
-
getOAuthAuthorizationUrl(provider:
|
|
124
|
+
getOAuthAuthorizationUrl(provider: OAuthProviderName, redirectUri: string, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<OAuthAuthorizationUrlResponse>;
|
|
122
125
|
|
|
123
126
|
/**
|
|
124
127
|
* Get OAuth connection info for a specific provider (without tokens). Safe for public key authentication.
|
|
125
128
|
* @summary Get OAuth connection info
|
|
126
|
-
* @param {
|
|
129
|
+
* @param {OAuthProviderName} provider OAuth provider name
|
|
127
130
|
* @param {*} [options] Override http request option.
|
|
128
131
|
* @throws {RequiredError}
|
|
129
132
|
* @memberof AuthOAuthApiInterface
|
|
@@ -134,12 +137,12 @@ export interface AuthOAuthApiInterface {
|
|
|
134
137
|
* Get OAuth connection info for a specific provider (without tokens). Safe for public key authentication.
|
|
135
138
|
* Get OAuth connection info
|
|
136
139
|
*/
|
|
137
|
-
getOAuthConnectionInfo(provider:
|
|
140
|
+
getOAuthConnectionInfo(provider: OAuthProviderName, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<OAuthConnectionInfoResponse>;
|
|
138
141
|
|
|
139
142
|
/**
|
|
140
143
|
* Get OAuth provider tokens for an end user. Requires secret key authentication (server-side only). This allows developers to access downstream APIs on behalf of their users.
|
|
141
144
|
* @summary Get OAuth provider tokens
|
|
142
|
-
* @param {
|
|
145
|
+
* @param {OAuthProviderName} provider OAuth provider name
|
|
143
146
|
* @param {string} userId End user ID
|
|
144
147
|
* @param {*} [options] Override http request option.
|
|
145
148
|
* @throws {RequiredError}
|
|
@@ -151,12 +154,12 @@ export interface AuthOAuthApiInterface {
|
|
|
151
154
|
* Get OAuth provider tokens for an end user. Requires secret key authentication (server-side only). This allows developers to access downstream APIs on behalf of their users.
|
|
152
155
|
* Get OAuth provider tokens
|
|
153
156
|
*/
|
|
154
|
-
getOAuthTokens(provider:
|
|
157
|
+
getOAuthTokens(provider: OAuthProviderName, userId: string, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<OAuthTokensResponse>;
|
|
155
158
|
|
|
156
159
|
/**
|
|
157
160
|
* Handle the OAuth callback by exchanging the authorization code for tokens and authenticating the user.
|
|
158
161
|
* @summary Handle OAuth callback
|
|
159
|
-
* @param {
|
|
162
|
+
* @param {OAuthProviderName} provider OAuth provider name
|
|
160
163
|
* @param {OAuthCallbackRequest} oAuthCallbackRequest
|
|
161
164
|
* @param {*} [options] Override http request option.
|
|
162
165
|
* @throws {RequiredError}
|
|
@@ -168,7 +171,7 @@ export interface AuthOAuthApiInterface {
|
|
|
168
171
|
* Handle the OAuth callback by exchanging the authorization code for tokens and authenticating the user.
|
|
169
172
|
* Handle OAuth callback
|
|
170
173
|
*/
|
|
171
|
-
handleOAuthCallback(provider:
|
|
174
|
+
handleOAuthCallback(provider: OAuthProviderName, oAuthCallbackRequest: OAuthCallbackRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<OAuthCallbackResponse>;
|
|
172
175
|
|
|
173
176
|
/**
|
|
174
177
|
* Get OAuth connections for the current user with metadata.
|
|
@@ -203,7 +206,7 @@ export interface AuthOAuthApiInterface {
|
|
|
203
206
|
/**
|
|
204
207
|
* Refresh OAuth provider tokens for an end user. Requires secret key authentication (server-side only). Only supported for providers that support token refresh (e.g., Google, Microsoft).
|
|
205
208
|
* @summary Refresh OAuth provider tokens
|
|
206
|
-
* @param {
|
|
209
|
+
* @param {OAuthProviderName} provider OAuth provider name
|
|
207
210
|
* @param {RefreshOAuthTokensRequest} refreshOAuthTokensRequest
|
|
208
211
|
* @param {*} [options] Override http request option.
|
|
209
212
|
* @throws {RequiredError}
|
|
@@ -215,7 +218,7 @@ export interface AuthOAuthApiInterface {
|
|
|
215
218
|
* Refresh OAuth provider tokens for an end user. Requires secret key authentication (server-side only). Only supported for providers that support token refresh (e.g., Google, Microsoft).
|
|
216
219
|
* Refresh OAuth provider tokens
|
|
217
220
|
*/
|
|
218
|
-
refreshOAuthTokens(provider:
|
|
221
|
+
refreshOAuthTokens(provider: OAuthProviderName, refreshOAuthTokensRequest: RefreshOAuthTokensRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<OAuthTokensRefreshResponse>;
|
|
219
222
|
|
|
220
223
|
}
|
|
221
224
|
|
|
@@ -266,7 +269,7 @@ export class AuthOAuthApi extends runtime.BaseAPI implements AuthOAuthApiInterfa
|
|
|
266
269
|
* Disconnect an OAuth provider from the current user.
|
|
267
270
|
* Disconnect OAuth provider
|
|
268
271
|
*/
|
|
269
|
-
async disconnectOAuthProvider(provider:
|
|
272
|
+
async disconnectOAuthProvider(provider: OAuthProviderName, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<SuccessResult> {
|
|
270
273
|
const response = await this.disconnectOAuthProviderRaw({ provider: provider }, initOverrides);
|
|
271
274
|
return await response.value();
|
|
272
275
|
}
|
|
@@ -316,7 +319,7 @@ export class AuthOAuthApi extends runtime.BaseAPI implements AuthOAuthApiInterfa
|
|
|
316
319
|
* Generate an OAuth authorization URL for the specified provider.
|
|
317
320
|
* Get OAuth authorization URL
|
|
318
321
|
*/
|
|
319
|
-
async getOAuthAuthorizationUrl(provider:
|
|
322
|
+
async getOAuthAuthorizationUrl(provider: OAuthProviderName, redirectUri: string, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<OAuthAuthorizationUrlResponse> {
|
|
320
323
|
const response = await this.getOAuthAuthorizationUrlRaw({ provider: provider, redirectUri: redirectUri }, initOverrides);
|
|
321
324
|
return await response.value();
|
|
322
325
|
}
|
|
@@ -363,7 +366,7 @@ export class AuthOAuthApi extends runtime.BaseAPI implements AuthOAuthApiInterfa
|
|
|
363
366
|
* Get OAuth connection info for a specific provider (without tokens). Safe for public key authentication.
|
|
364
367
|
* Get OAuth connection info
|
|
365
368
|
*/
|
|
366
|
-
async getOAuthConnectionInfo(provider:
|
|
369
|
+
async getOAuthConnectionInfo(provider: OAuthProviderName, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<OAuthConnectionInfoResponse> {
|
|
367
370
|
const response = await this.getOAuthConnectionInfoRaw({ provider: provider }, initOverrides);
|
|
368
371
|
return await response.value();
|
|
369
372
|
}
|
|
@@ -417,7 +420,7 @@ export class AuthOAuthApi extends runtime.BaseAPI implements AuthOAuthApiInterfa
|
|
|
417
420
|
* Get OAuth provider tokens for an end user. Requires secret key authentication (server-side only). This allows developers to access downstream APIs on behalf of their users.
|
|
418
421
|
* Get OAuth provider tokens
|
|
419
422
|
*/
|
|
420
|
-
async getOAuthTokens(provider:
|
|
423
|
+
async getOAuthTokens(provider: OAuthProviderName, userId: string, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<OAuthTokensResponse> {
|
|
421
424
|
const response = await this.getOAuthTokensRaw({ provider: provider, userId: userId }, initOverrides);
|
|
422
425
|
return await response.value();
|
|
423
426
|
}
|
|
@@ -462,7 +465,7 @@ export class AuthOAuthApi extends runtime.BaseAPI implements AuthOAuthApiInterfa
|
|
|
462
465
|
* Handle the OAuth callback by exchanging the authorization code for tokens and authenticating the user.
|
|
463
466
|
* Handle OAuth callback
|
|
464
467
|
*/
|
|
465
|
-
async handleOAuthCallback(provider:
|
|
468
|
+
async handleOAuthCallback(provider: OAuthProviderName, oAuthCallbackRequest: OAuthCallbackRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<OAuthCallbackResponse> {
|
|
466
469
|
const response = await this.handleOAuthCallbackRaw({ provider: provider, oAuthCallbackRequest: oAuthCallbackRequest }, initOverrides);
|
|
467
470
|
return await response.value();
|
|
468
471
|
}
|
|
@@ -587,7 +590,7 @@ export class AuthOAuthApi extends runtime.BaseAPI implements AuthOAuthApiInterfa
|
|
|
587
590
|
* Refresh OAuth provider tokens for an end user. Requires secret key authentication (server-side only). Only supported for providers that support token refresh (e.g., Google, Microsoft).
|
|
588
591
|
* Refresh OAuth provider tokens
|
|
589
592
|
*/
|
|
590
|
-
async refreshOAuthTokens(provider:
|
|
593
|
+
async refreshOAuthTokens(provider: OAuthProviderName, refreshOAuthTokensRequest: RefreshOAuthTokensRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<OAuthTokensRefreshResponse> {
|
|
591
594
|
const response = await this.refreshOAuthTokensRaw({ provider: provider, refreshOAuthTokensRequest: refreshOAuthTokensRequest }, initOverrides);
|
|
592
595
|
return await response.value();
|
|
593
596
|
}
|