@zyphr-dev/node-sdk 0.1.43 → 0.1.44
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 +6 -4
- package/dist/index.cjs +277 -8
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +326 -13
- package/dist/index.d.ts +326 -13
- package/dist/index.js +254 -8
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/.openapi-generator/FILES +5 -0
- package/src/client.ts +18 -3
- package/src/clientAuth.ts +45 -12
- package/src/src/apis/AuthApplicationApi.ts +93 -0
- package/src/src/apis/AuthEmailTemplatesApi.ts +4 -4
- package/src/src/apis/AuthUserDirectoryApi.ts +66 -0
- package/src/src/apis/index.ts +1 -0
- package/src/src/models/ApplicationSelf.ts +118 -0
- package/src/src/models/ApplicationSelfResponse.ts +88 -0
- package/src/src/models/AuthEmailTemplateTestRequest.ts +1 -1
- package/src/src/models/AuthMethods.ts +111 -0
- package/src/src/models/GetEndUserAuthMethods200Response.ts +88 -0
- package/src/src/models/index.ts +4 -0
package/package.json
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
.npmignore
|
|
3
3
|
README.md
|
|
4
4
|
package.json
|
|
5
|
+
src/apis/AuthApplicationApi.ts
|
|
5
6
|
src/apis/AuthEmailOTPApi.ts
|
|
6
7
|
src/apis/AuthEmailTemplatesApi.ts
|
|
7
8
|
src/apis/AuthEmailVerificationApi.ts
|
|
@@ -50,6 +51,8 @@ src/models/AddWorkflowStepRequest.ts
|
|
|
50
51
|
src/models/ApiError.ts
|
|
51
52
|
src/models/ApiErrorError.ts
|
|
52
53
|
src/models/ApiErrorMeta.ts
|
|
54
|
+
src/models/ApplicationSelf.ts
|
|
55
|
+
src/models/ApplicationSelfResponse.ts
|
|
53
56
|
src/models/AuthEmailTemplate.ts
|
|
54
57
|
src/models/AuthEmailTemplateDefault.ts
|
|
55
58
|
src/models/AuthEmailTemplateDefaultResponse.ts
|
|
@@ -70,6 +73,7 @@ src/models/AuthEmailType.ts
|
|
|
70
73
|
src/models/AuthLoginResponse.ts
|
|
71
74
|
src/models/AuthLoginResult.ts
|
|
72
75
|
src/models/AuthLoginResultMfaChallenge.ts
|
|
76
|
+
src/models/AuthMethods.ts
|
|
73
77
|
src/models/AuthResult.ts
|
|
74
78
|
src/models/AuthResultResponse.ts
|
|
75
79
|
src/models/AuthSession.ts
|
|
@@ -163,6 +167,7 @@ src/models/GenerateSubscriberTokenRequest.ts
|
|
|
163
167
|
src/models/GenerateWaaSPortalToken201Response.ts
|
|
164
168
|
src/models/GetDomain200Response.ts
|
|
165
169
|
src/models/GetDomain200ResponseMeta.ts
|
|
170
|
+
src/models/GetEndUserAuthMethods200Response.ts
|
|
166
171
|
src/models/GetEndUserById200Response.ts
|
|
167
172
|
src/models/GetEndUserClaims200Response.ts
|
|
168
173
|
src/models/GetEndUserClaims200ResponseData.ts
|
package/src/client.ts
CHANGED
|
@@ -16,6 +16,7 @@
|
|
|
16
16
|
import { Configuration } from './src/runtime.js';
|
|
17
17
|
import type { Middleware, ResponseContext } from './src/runtime.js';
|
|
18
18
|
import {
|
|
19
|
+
AuthApplicationApi,
|
|
19
20
|
AuthEmailOTPApi,
|
|
20
21
|
AuthEmailVerificationApi,
|
|
21
22
|
AuthLoginApi,
|
|
@@ -52,13 +53,24 @@ import {
|
|
|
52
53
|
import { parseErrorResponse } from './errors.js';
|
|
53
54
|
|
|
54
55
|
export interface ZyphrOptions {
|
|
55
|
-
/**
|
|
56
|
+
/**
|
|
57
|
+
* Your Project-scoped Zyphr API key (`zy_live_*` / `zy_test_*`), sent as
|
|
58
|
+
* `Authorization: Bearer`. Used for notification APIs (emails, push, webhooks).
|
|
59
|
+
*/
|
|
56
60
|
apiKey: string;
|
|
57
61
|
/** Override the base API URL (defaults to https://api.zyphr.dev/v1) */
|
|
58
62
|
baseUrl?: string;
|
|
59
|
-
/**
|
|
63
|
+
/**
|
|
64
|
+
* Application-scoped public key (`za_live_pub_*` / `za_test_pub_*`; legacy
|
|
65
|
+
* `za_pub_*` still accepted) for Auth-as-a-Service endpoints, sent as
|
|
66
|
+
* `X-Application-Key`. Distinct from the Project-scoped `apiKey` above.
|
|
67
|
+
*/
|
|
60
68
|
applicationKey?: string;
|
|
61
|
-
/**
|
|
69
|
+
/**
|
|
70
|
+
* Application-scoped secret key (`za_live_sec_*` / `za_test_sec_*`; legacy
|
|
71
|
+
* `za_sec_*` still accepted) for server-side Auth-as-a-Service endpoints, sent
|
|
72
|
+
* as `X-Application-Secret`. Must stay server-side — never ship in a client bundle.
|
|
73
|
+
*/
|
|
62
74
|
applicationSecret?: string;
|
|
63
75
|
}
|
|
64
76
|
|
|
@@ -115,6 +127,8 @@ export class Zyphr {
|
|
|
115
127
|
/** Server-side (secret-key) end-user directory: list/search/get/update/delete, invite, and the trusted claims store. */
|
|
116
128
|
readonly userDirectory: AuthUserDirectoryApi;
|
|
117
129
|
readonly webauthn: AuthWebAuthnApi;
|
|
130
|
+
/** Read the authenticating application's own non-sensitive metadata (id, name, environment, signing algorithm) via GET /auth/application. */
|
|
131
|
+
readonly application: AuthApplicationApi;
|
|
118
132
|
};
|
|
119
133
|
|
|
120
134
|
private readonly options: ZyphrOptions;
|
|
@@ -171,6 +185,7 @@ export class Zyphr {
|
|
|
171
185
|
profile: new AuthUserProfileApi(config),
|
|
172
186
|
userDirectory: new AuthUserDirectoryApi(config),
|
|
173
187
|
webauthn: new AuthWebAuthnApi(config),
|
|
188
|
+
application: new AuthApplicationApi(config),
|
|
174
189
|
};
|
|
175
190
|
}
|
|
176
191
|
|
package/src/clientAuth.ts
CHANGED
|
@@ -4,8 +4,14 @@
|
|
|
4
4
|
* `ZyphrClient` is a browser / React Native-safe entry point for Auth-as-a-Service.
|
|
5
5
|
* Unlike the server `Zyphr` client (which requires a secret API key and, for auth,
|
|
6
6
|
* an application SECRET key), `ZyphrClient` is constructed with ONLY the publishable
|
|
7
|
-
* application key (`
|
|
8
|
-
* plus, once the user is authenticated,
|
|
7
|
+
* application key (`za_live_pub_*` in live mode, `za_test_pub_*` in test mode) — the
|
|
8
|
+
* key that is safe to ship in a client bundle — plus, once the user is authenticated,
|
|
9
|
+
* their end-user access token.
|
|
10
|
+
*
|
|
11
|
+
* These Application-scoped credentials (`X-Application-Key` publishable key, and the
|
|
12
|
+
* server-only `X-Application-Secret`) are distinct from the Project-scoped notification
|
|
13
|
+
* keys (`zy_live_*` / `zy_test_*`, sent as `Authorization: Bearer`) used by the server
|
|
14
|
+
* `Zyphr` client for emails/push/webhooks.
|
|
9
15
|
*
|
|
10
16
|
* It deliberately exposes ONLY the end-user-scoped auth surface (login, registration,
|
|
11
17
|
* sessions, magic links, OAuth, phone, email-OTP, profile, MFA, WebAuthn, password
|
|
@@ -17,7 +23,7 @@
|
|
|
17
23
|
* ```ts
|
|
18
24
|
* import { ZyphrClient } from '@zyphr-dev/node-sdk';
|
|
19
25
|
*
|
|
20
|
-
* const zyphr = new ZyphrClient({ applicationKey: '
|
|
26
|
+
* const zyphr = new ZyphrClient({ applicationKey: 'za_live_pub_xxx' });
|
|
21
27
|
*
|
|
22
28
|
* const login = await zyphr.auth.login.loginEndUser({ ... });
|
|
23
29
|
* zyphr.setAccessToken(login.data.tokens.access_token);
|
|
@@ -47,7 +53,10 @@ import {
|
|
|
47
53
|
import { parseErrorResponse } from './errors.js';
|
|
48
54
|
|
|
49
55
|
export interface ZyphrClientOptions {
|
|
50
|
-
/**
|
|
56
|
+
/**
|
|
57
|
+
* Publishable application key (`za_live_pub_*` / `za_test_pub_*`) — safe to
|
|
58
|
+
* embed in a client bundle. Legacy `za_pub_*` keys are also accepted.
|
|
59
|
+
*/
|
|
51
60
|
applicationKey: string;
|
|
52
61
|
/** Override the base API URL (defaults to https://api.zyphr.dev/v1). */
|
|
53
62
|
baseUrl?: string;
|
|
@@ -75,8 +84,31 @@ export class ZyphrClientCredentialError extends Error {
|
|
|
75
84
|
}
|
|
76
85
|
}
|
|
77
86
|
|
|
78
|
-
|
|
79
|
-
|
|
87
|
+
// Key prefixes are mirrored from the platform source of truth,
|
|
88
|
+
// packages/shared/src/constants/api.ts (APPLICATION_KEY_PREFIXES,
|
|
89
|
+
// SECRET_KEY_PREFIXES). They are inlined here because this is a standalone
|
|
90
|
+
// published package that cannot import @zyphr/shared at runtime — keep the two
|
|
91
|
+
// in sync if the prefixes ever change.
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* Publishable application-key prefixes accepted by the client-safe SDK.
|
|
95
|
+
* `za_live_pub_` / `za_test_pub_` are the current live/test prefixes; `za_pub_`
|
|
96
|
+
* is the deprecated legacy prefix, still accepted for backward compatibility.
|
|
97
|
+
*/
|
|
98
|
+
const PUBLISHABLE_KEY_PREFIXES = ['za_live_pub_', 'za_test_pub_', 'za_pub_'];
|
|
99
|
+
|
|
100
|
+
/**
|
|
101
|
+
* Prefixes that must NEVER reach a client bundle: application SECRET keys
|
|
102
|
+
* (`za_live_sec_` / `za_test_sec_`, and legacy `za_sec_`) and Project-scoped
|
|
103
|
+
* notification API keys (`zy_live_*` / `zy_test_*`).
|
|
104
|
+
*/
|
|
105
|
+
const SECRET_KEY_PREFIXES = [
|
|
106
|
+
'za_live_sec_',
|
|
107
|
+
'za_test_sec_',
|
|
108
|
+
'za_sec_',
|
|
109
|
+
'zy_live_',
|
|
110
|
+
'zy_test_',
|
|
111
|
+
];
|
|
80
112
|
|
|
81
113
|
export class ZyphrClient {
|
|
82
114
|
readonly auth: {
|
|
@@ -103,19 +135,20 @@ export class ZyphrClient {
|
|
|
103
135
|
|
|
104
136
|
constructor(options: ZyphrClientOptions) {
|
|
105
137
|
if (!options.applicationKey) {
|
|
106
|
-
throw new ZyphrClientCredentialError('applicationKey (
|
|
138
|
+
throw new ZyphrClientCredentialError('applicationKey (za_live_pub_* / za_test_pub_*) is required');
|
|
107
139
|
}
|
|
108
140
|
// Guardrail: reject secret-shaped credentials so a secret can't be shipped
|
|
109
|
-
// in a client bundle by mistake.
|
|
141
|
+
// in a client bundle by mistake. Checked before the publishable allow-list so
|
|
142
|
+
// a secret key produces the clearer "never a secret key" message.
|
|
110
143
|
if (SECRET_KEY_PREFIXES.some((p) => options.applicationKey.startsWith(p))) {
|
|
111
144
|
throw new ZyphrClientCredentialError(
|
|
112
|
-
'ZyphrClient must be constructed with a publishable application key
|
|
113
|
-
'never a secret key. Secret keys must stay server-side.'
|
|
145
|
+
'ZyphrClient must be constructed with a publishable application key ' +
|
|
146
|
+
'(za_live_pub_* / za_test_pub_*), never a secret key. Secret keys must stay server-side.'
|
|
114
147
|
);
|
|
115
148
|
}
|
|
116
|
-
if (!options.applicationKey.startsWith(
|
|
149
|
+
if (!PUBLISHABLE_KEY_PREFIXES.some((p) => options.applicationKey.startsWith(p))) {
|
|
117
150
|
throw new ZyphrClientCredentialError(
|
|
118
|
-
'applicationKey must be a publishable application key (
|
|
151
|
+
'applicationKey must be a publishable application key (za_live_pub_* / za_test_pub_*).'
|
|
119
152
|
);
|
|
120
153
|
}
|
|
121
154
|
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
/* tslint:disable */
|
|
2
|
+
/* eslint-disable */
|
|
3
|
+
/**
|
|
4
|
+
* Zyphr API
|
|
5
|
+
* Zyphr is a multi-channel notification platform that enables developers to send emails, push notifications, SMS, and in-app messages through a unified API. ## Authentication All API requests require authentication using an API key. Include your API key in the `X-API-Key` header: ``` X-API-Key: zy_live_xxxxxxxxxxxx ``` API keys can be created in the Zyphr Dashboard. Use `zy_test_*` keys for testing and `zy_live_*` keys for production. ## Rate Limiting The API implements rate limiting to ensure fair usage. Rate limit information is included in response headers: - `X-RateLimit-Limit`: Maximum requests per window - `X-RateLimit-Remaining`: Remaining requests in current window - `X-RateLimit-Reset`: Unix timestamp when the window resets ## Account Sending Status Every authenticated response carries the account\'s current sending state so you can surface it in your own tooling without a separate call: - `X-Account-Sending-Status`: `active`, `throttled`, or `frozen` - `X-Account-Sending-Status-Reason`: human-readable reason (present only when the status is `throttled` or `frozen`) This header is informational and non-blocking on non-send endpoints (reads, billing, and deliverability stay available). Send-capable endpoints additionally enforce the state: a frozen account receives `403 account_frozen` and a throttled account receives `429 account_throttled`, both with the reason in the error message. ## Errors All errors follow a consistent format: ```json { \"error\": { \"code\": \"error_code\", \"message\": \"Human readable message\", \"details\": {} }, \"meta\": { \"request_id\": \"req_xxxx\" } } ```
|
|
6
|
+
*
|
|
7
|
+
* The version of the OpenAPI document: 1.0.0
|
|
8
|
+
* Contact: support@zyphr.dev
|
|
9
|
+
*
|
|
10
|
+
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
|
11
|
+
* https://openapi-generator.tech
|
|
12
|
+
* Do not edit the class manually.
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
import * as runtime from '../runtime';
|
|
17
|
+
import type {
|
|
18
|
+
ApiError,
|
|
19
|
+
ApplicationSelfResponse,
|
|
20
|
+
} from '../models/index';
|
|
21
|
+
import {
|
|
22
|
+
ApiErrorFromJSON,
|
|
23
|
+
ApiErrorToJSON,
|
|
24
|
+
ApplicationSelfResponseFromJSON,
|
|
25
|
+
ApplicationSelfResponseToJSON,
|
|
26
|
+
} from '../models/index';
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* AuthApplicationApi - interface
|
|
30
|
+
*
|
|
31
|
+
* @export
|
|
32
|
+
* @interface AuthApplicationApiInterface
|
|
33
|
+
*/
|
|
34
|
+
export interface AuthApplicationApiInterface {
|
|
35
|
+
/**
|
|
36
|
+
* Return non-sensitive metadata about the application whose credentials authenticated this request. Lets an integrator read their own application_id (the sole tenant discriminator embedded in every end-user token) directly from the API, rather than only from the dashboard UI or by decoding a token. Returns only id, name, the calling environment\'s mode, and the JWT signing algorithm — never secrets, signing keys, or account-internal fields.
|
|
37
|
+
* @summary Get the authenticating application
|
|
38
|
+
* @param {*} [options] Override http request option.
|
|
39
|
+
* @throws {RequiredError}
|
|
40
|
+
* @memberof AuthApplicationApiInterface
|
|
41
|
+
*/
|
|
42
|
+
getSelfApplicationRaw(initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<ApplicationSelfResponse>>;
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* Return non-sensitive metadata about the application whose credentials authenticated this request. Lets an integrator read their own application_id (the sole tenant discriminator embedded in every end-user token) directly from the API, rather than only from the dashboard UI or by decoding a token. Returns only id, name, the calling environment\'s mode, and the JWT signing algorithm — never secrets, signing keys, or account-internal fields.
|
|
46
|
+
* Get the authenticating application
|
|
47
|
+
*/
|
|
48
|
+
getSelfApplication(initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<ApplicationSelfResponse>;
|
|
49
|
+
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
*
|
|
54
|
+
*/
|
|
55
|
+
export class AuthApplicationApi extends runtime.BaseAPI implements AuthApplicationApiInterface {
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* Return non-sensitive metadata about the application whose credentials authenticated this request. Lets an integrator read their own application_id (the sole tenant discriminator embedded in every end-user token) directly from the API, rather than only from the dashboard UI or by decoding a token. Returns only id, name, the calling environment\'s mode, and the JWT signing algorithm — never secrets, signing keys, or account-internal fields.
|
|
59
|
+
* Get the authenticating application
|
|
60
|
+
*/
|
|
61
|
+
async getSelfApplicationRaw(initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<ApplicationSelfResponse>> {
|
|
62
|
+
const queryParameters: any = {};
|
|
63
|
+
|
|
64
|
+
const headerParameters: runtime.HTTPHeaders = {};
|
|
65
|
+
|
|
66
|
+
if (this.configuration && this.configuration.apiKey) {
|
|
67
|
+
headerParameters["X-Application-Secret"] = await this.configuration.apiKey("X-Application-Secret"); // ApplicationSecret authentication
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
if (this.configuration && this.configuration.apiKey) {
|
|
71
|
+
headerParameters["X-Application-Key"] = await this.configuration.apiKey("X-Application-Key"); // ApplicationPublicKey authentication
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
const response = await this.request({
|
|
75
|
+
path: `/auth/application`,
|
|
76
|
+
method: 'GET',
|
|
77
|
+
headers: headerParameters,
|
|
78
|
+
query: queryParameters,
|
|
79
|
+
}, initOverrides);
|
|
80
|
+
|
|
81
|
+
return new runtime.JSONApiResponse(response, (jsonValue) => ApplicationSelfResponseFromJSON(jsonValue));
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* Return non-sensitive metadata about the application whose credentials authenticated this request. Lets an integrator read their own application_id (the sole tenant discriminator embedded in every end-user token) directly from the API, rather than only from the dashboard UI or by decoding a token. Returns only id, name, the calling environment\'s mode, and the JWT signing algorithm — never secrets, signing keys, or account-internal fields.
|
|
86
|
+
* Get the authenticating application
|
|
87
|
+
*/
|
|
88
|
+
async getSelfApplication(initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<ApplicationSelfResponse> {
|
|
89
|
+
const response = await this.getSelfApplicationRaw(initOverrides);
|
|
90
|
+
return await response.value();
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
}
|
|
@@ -240,7 +240,7 @@ export interface AuthEmailTemplatesApiInterface {
|
|
|
240
240
|
restoreAuthEmailTemplateVersion(type: AuthEmailType, version: number, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<AuthEmailTemplateResponse>;
|
|
241
241
|
|
|
242
242
|
/**
|
|
243
|
-
* Renders the template (override or default) using sample/provided variables and sends to the recipient. The recipient must be in the application `test_recipients` allowlist. Rate-limited.
|
|
243
|
+
* Renders the template (override or default) using sample/provided variables and sends to the recipient. The recipient must be in the application `test_recipients` allowlist. Rate-limited. When non-empty, `test_recipients` gates ALL auth emails this application sends (magic link, password reset, email verification, and email OTP) — not just these test renders. Only listed recipients receive auth email; any other recipient is silently blocked. Use it to make a non-production application safe from mass sends. An empty allowlist (the default) imposes no restriction and every recipient receives auth email normally.
|
|
244
244
|
* @summary Send a test render of a template
|
|
245
245
|
* @param {AuthEmailType} type
|
|
246
246
|
* @param {AuthEmailTemplateTestRequest} authEmailTemplateTestRequest
|
|
@@ -251,7 +251,7 @@ export interface AuthEmailTemplatesApiInterface {
|
|
|
251
251
|
sendAuthEmailTemplateTestRaw(requestParameters: AuthEmailTemplatesApiSendAuthEmailTemplateTestRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<AuthEmailTemplateTestResponse>>;
|
|
252
252
|
|
|
253
253
|
/**
|
|
254
|
-
* Renders the template (override or default) using sample/provided variables and sends to the recipient. The recipient must be in the application `test_recipients` allowlist. Rate-limited.
|
|
254
|
+
* Renders the template (override or default) using sample/provided variables and sends to the recipient. The recipient must be in the application `test_recipients` allowlist. Rate-limited. When non-empty, `test_recipients` gates ALL auth emails this application sends (magic link, password reset, email verification, and email OTP) — not just these test renders. Only listed recipients receive auth email; any other recipient is silently blocked. Use it to make a non-production application safe from mass sends. An empty allowlist (the default) imposes no restriction and every recipient receives auth email normally.
|
|
255
255
|
* Send a test render of a template
|
|
256
256
|
*/
|
|
257
257
|
sendAuthEmailTemplateTest(type: AuthEmailType, authEmailTemplateTestRequest: AuthEmailTemplateTestRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<AuthEmailTemplateTestResponse>;
|
|
@@ -629,7 +629,7 @@ export class AuthEmailTemplatesApi extends runtime.BaseAPI implements AuthEmailT
|
|
|
629
629
|
}
|
|
630
630
|
|
|
631
631
|
/**
|
|
632
|
-
* Renders the template (override or default) using sample/provided variables and sends to the recipient. The recipient must be in the application `test_recipients` allowlist. Rate-limited.
|
|
632
|
+
* Renders the template (override or default) using sample/provided variables and sends to the recipient. The recipient must be in the application `test_recipients` allowlist. Rate-limited. When non-empty, `test_recipients` gates ALL auth emails this application sends (magic link, password reset, email verification, and email OTP) — not just these test renders. Only listed recipients receive auth email; any other recipient is silently blocked. Use it to make a non-production application safe from mass sends. An empty allowlist (the default) imposes no restriction and every recipient receives auth email normally.
|
|
633
633
|
* Send a test render of a template
|
|
634
634
|
*/
|
|
635
635
|
async sendAuthEmailTemplateTestRaw(requestParameters: AuthEmailTemplatesApiSendAuthEmailTemplateTestRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<AuthEmailTemplateTestResponse>> {
|
|
@@ -673,7 +673,7 @@ export class AuthEmailTemplatesApi extends runtime.BaseAPI implements AuthEmailT
|
|
|
673
673
|
}
|
|
674
674
|
|
|
675
675
|
/**
|
|
676
|
-
* Renders the template (override or default) using sample/provided variables and sends to the recipient. The recipient must be in the application `test_recipients` allowlist. Rate-limited.
|
|
676
|
+
* Renders the template (override or default) using sample/provided variables and sends to the recipient. The recipient must be in the application `test_recipients` allowlist. Rate-limited. When non-empty, `test_recipients` gates ALL auth emails this application sends (magic link, password reset, email verification, and email OTP) — not just these test renders. Only listed recipients receive auth email; any other recipient is silently blocked. Use it to make a non-production application safe from mass sends. An empty allowlist (the default) imposes no restriction and every recipient receives auth email normally.
|
|
677
677
|
* Send a test render of a template
|
|
678
678
|
*/
|
|
679
679
|
async sendAuthEmailTemplateTest(type: AuthEmailType, authEmailTemplateTestRequest: AuthEmailTemplateTestRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<AuthEmailTemplateTestResponse> {
|
|
@@ -15,6 +15,7 @@
|
|
|
15
15
|
|
|
16
16
|
import * as runtime from '../runtime';
|
|
17
17
|
import type {
|
|
18
|
+
GetEndUserAuthMethods200Response,
|
|
18
19
|
GetEndUserById200Response,
|
|
19
20
|
GetEndUserClaims200Response,
|
|
20
21
|
InviteEndUser200Response,
|
|
@@ -25,6 +26,8 @@ import type {
|
|
|
25
26
|
UpdateEndUserByApplicationRequest,
|
|
26
27
|
} from '../models/index';
|
|
27
28
|
import {
|
|
29
|
+
GetEndUserAuthMethods200ResponseFromJSON,
|
|
30
|
+
GetEndUserAuthMethods200ResponseToJSON,
|
|
28
31
|
GetEndUserById200ResponseFromJSON,
|
|
29
32
|
GetEndUserById200ResponseToJSON,
|
|
30
33
|
GetEndUserClaims200ResponseFromJSON,
|
|
@@ -47,6 +50,10 @@ export interface AuthUserDirectoryApiDeleteEndUserByApplicationRequest {
|
|
|
47
50
|
userId: string;
|
|
48
51
|
}
|
|
49
52
|
|
|
53
|
+
export interface AuthUserDirectoryApiGetEndUserAuthMethodsRequest {
|
|
54
|
+
userId: string;
|
|
55
|
+
}
|
|
56
|
+
|
|
50
57
|
export interface AuthUserDirectoryApiGetEndUserByEmailRequest {
|
|
51
58
|
email: string;
|
|
52
59
|
}
|
|
@@ -103,6 +110,22 @@ export interface AuthUserDirectoryApiInterface {
|
|
|
103
110
|
*/
|
|
104
111
|
deleteEndUserByApplication(userId: string, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<void>;
|
|
105
112
|
|
|
113
|
+
/**
|
|
114
|
+
* Secret-key-scoped, aggregate view of the sign-in methods configured for a single end user within the authenticating application. Reports whether the user has a password, which OAuth providers are linked, whether MFA is enabled, whether email/phone are verified, and how many passkeys are registered — everything a customer admin needs to build a \"sign-in methods\" screen. Scoped to the application — a caller can never read a user belonging to another application.
|
|
115
|
+
* @summary Get an end user\'s sign-in methods (server-side admin)
|
|
116
|
+
* @param {string} userId
|
|
117
|
+
* @param {*} [options] Override http request option.
|
|
118
|
+
* @throws {RequiredError}
|
|
119
|
+
* @memberof AuthUserDirectoryApiInterface
|
|
120
|
+
*/
|
|
121
|
+
getEndUserAuthMethodsRaw(requestParameters: AuthUserDirectoryApiGetEndUserAuthMethodsRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<GetEndUserAuthMethods200Response>>;
|
|
122
|
+
|
|
123
|
+
/**
|
|
124
|
+
* Secret-key-scoped, aggregate view of the sign-in methods configured for a single end user within the authenticating application. Reports whether the user has a password, which OAuth providers are linked, whether MFA is enabled, whether email/phone are verified, and how many passkeys are registered — everything a customer admin needs to build a \"sign-in methods\" screen. Scoped to the application — a caller can never read a user belonging to another application.
|
|
125
|
+
* Get an end user\'s sign-in methods (server-side admin)
|
|
126
|
+
*/
|
|
127
|
+
getEndUserAuthMethods(userId: string, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<GetEndUserAuthMethods200Response>;
|
|
128
|
+
|
|
106
129
|
/**
|
|
107
130
|
* Secret-key-scoped lookup of a single end user by email address within the authenticating application. Scoped to the application — never resolves a user from another application. Does not return the password hash.
|
|
108
131
|
* @summary Look up an end user by email (server-side admin)
|
|
@@ -269,6 +292,49 @@ export class AuthUserDirectoryApi extends runtime.BaseAPI implements AuthUserDir
|
|
|
269
292
|
await this.deleteEndUserByApplicationRaw({ userId: userId }, initOverrides);
|
|
270
293
|
}
|
|
271
294
|
|
|
295
|
+
/**
|
|
296
|
+
* Secret-key-scoped, aggregate view of the sign-in methods configured for a single end user within the authenticating application. Reports whether the user has a password, which OAuth providers are linked, whether MFA is enabled, whether email/phone are verified, and how many passkeys are registered — everything a customer admin needs to build a \"sign-in methods\" screen. Scoped to the application — a caller can never read a user belonging to another application.
|
|
297
|
+
* Get an end user\'s sign-in methods (server-side admin)
|
|
298
|
+
*/
|
|
299
|
+
async getEndUserAuthMethodsRaw(requestParameters: AuthUserDirectoryApiGetEndUserAuthMethodsRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<GetEndUserAuthMethods200Response>> {
|
|
300
|
+
if (requestParameters['userId'] == null) {
|
|
301
|
+
throw new runtime.RequiredError(
|
|
302
|
+
'userId',
|
|
303
|
+
'Required parameter "userId" was null or undefined when calling getEndUserAuthMethods().'
|
|
304
|
+
);
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
const queryParameters: any = {};
|
|
308
|
+
|
|
309
|
+
const headerParameters: runtime.HTTPHeaders = {};
|
|
310
|
+
|
|
311
|
+
if (this.configuration && this.configuration.apiKey) {
|
|
312
|
+
headerParameters["X-Application-Secret"] = await this.configuration.apiKey("X-Application-Secret"); // ApplicationSecret authentication
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
if (this.configuration && this.configuration.apiKey) {
|
|
316
|
+
headerParameters["X-Application-Key"] = await this.configuration.apiKey("X-Application-Key"); // ApplicationPublicKey authentication
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
const response = await this.request({
|
|
320
|
+
path: `/auth/users/{user_id}/auth-methods`.replace(`{${"user_id"}}`, encodeURIComponent(String(requestParameters['userId']))),
|
|
321
|
+
method: 'GET',
|
|
322
|
+
headers: headerParameters,
|
|
323
|
+
query: queryParameters,
|
|
324
|
+
}, initOverrides);
|
|
325
|
+
|
|
326
|
+
return new runtime.JSONApiResponse(response, (jsonValue) => GetEndUserAuthMethods200ResponseFromJSON(jsonValue));
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
/**
|
|
330
|
+
* Secret-key-scoped, aggregate view of the sign-in methods configured for a single end user within the authenticating application. Reports whether the user has a password, which OAuth providers are linked, whether MFA is enabled, whether email/phone are verified, and how many passkeys are registered — everything a customer admin needs to build a \"sign-in methods\" screen. Scoped to the application — a caller can never read a user belonging to another application.
|
|
331
|
+
* Get an end user\'s sign-in methods (server-side admin)
|
|
332
|
+
*/
|
|
333
|
+
async getEndUserAuthMethods(userId: string, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<GetEndUserAuthMethods200Response> {
|
|
334
|
+
const response = await this.getEndUserAuthMethodsRaw({ userId: userId }, initOverrides);
|
|
335
|
+
return await response.value();
|
|
336
|
+
}
|
|
337
|
+
|
|
272
338
|
/**
|
|
273
339
|
* Secret-key-scoped lookup of a single end user by email address within the authenticating application. Scoped to the application — never resolves a user from another application. Does not return the password hash.
|
|
274
340
|
* Look up an end user by email (server-side admin)
|
package/src/src/apis/index.ts
CHANGED
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
/* tslint:disable */
|
|
2
|
+
/* eslint-disable */
|
|
3
|
+
/**
|
|
4
|
+
* Zyphr API
|
|
5
|
+
* Zyphr is a multi-channel notification platform that enables developers to send emails, push notifications, SMS, and in-app messages through a unified API. ## Authentication All API requests require authentication using an API key. Include your API key in the `X-API-Key` header: ``` X-API-Key: zy_live_xxxxxxxxxxxx ``` API keys can be created in the Zyphr Dashboard. Use `zy_test_*` keys for testing and `zy_live_*` keys for production. ## Rate Limiting The API implements rate limiting to ensure fair usage. Rate limit information is included in response headers: - `X-RateLimit-Limit`: Maximum requests per window - `X-RateLimit-Remaining`: Remaining requests in current window - `X-RateLimit-Reset`: Unix timestamp when the window resets ## Account Sending Status Every authenticated response carries the account\'s current sending state so you can surface it in your own tooling without a separate call: - `X-Account-Sending-Status`: `active`, `throttled`, or `frozen` - `X-Account-Sending-Status-Reason`: human-readable reason (present only when the status is `throttled` or `frozen`) This header is informational and non-blocking on non-send endpoints (reads, billing, and deliverability stay available). Send-capable endpoints additionally enforce the state: a frozen account receives `403 account_frozen` and a throttled account receives `429 account_throttled`, both with the reason in the error message. ## Errors All errors follow a consistent format: ```json { \"error\": { \"code\": \"error_code\", \"message\": \"Human readable message\", \"details\": {} }, \"meta\": { \"request_id\": \"req_xxxx\" } } ```
|
|
6
|
+
*
|
|
7
|
+
* The version of the OpenAPI document: 1.0.0
|
|
8
|
+
* Contact: support@zyphr.dev
|
|
9
|
+
*
|
|
10
|
+
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
|
11
|
+
* https://openapi-generator.tech
|
|
12
|
+
* Do not edit the class manually.
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
import { mapValues } from '../runtime';
|
|
16
|
+
/**
|
|
17
|
+
* Non-sensitive metadata about the authenticating application. Returned by
|
|
18
|
+
* GET /auth/application so an integrator can read their own application_id
|
|
19
|
+
* (the sole tenant discriminator embedded in end-user tokens) directly from
|
|
20
|
+
* the API. Never includes secrets, signing keys, or account-internal fields.
|
|
21
|
+
*
|
|
22
|
+
* @export
|
|
23
|
+
* @interface ApplicationSelf
|
|
24
|
+
*/
|
|
25
|
+
export interface ApplicationSelf {
|
|
26
|
+
/**
|
|
27
|
+
* The application's unique id (application_id).
|
|
28
|
+
* @type {string}
|
|
29
|
+
* @memberof ApplicationSelf
|
|
30
|
+
*/
|
|
31
|
+
id: string;
|
|
32
|
+
/**
|
|
33
|
+
* Human-readable application name.
|
|
34
|
+
* @type {string}
|
|
35
|
+
* @memberof ApplicationSelf
|
|
36
|
+
*/
|
|
37
|
+
name: string;
|
|
38
|
+
/**
|
|
39
|
+
* The environment mode of the credentials used to authenticate this request. `null` when the environment cannot be determined (e.g. a legacy application-level key that predates environment-scoped keys) — not defaulted to a guessed value.
|
|
40
|
+
* @type {string}
|
|
41
|
+
* @memberof ApplicationSelf
|
|
42
|
+
*/
|
|
43
|
+
environment: ApplicationSelfEnvironmentEnum | null;
|
|
44
|
+
/**
|
|
45
|
+
* JWT signing algorithm for this application's end-user tokens.
|
|
46
|
+
* @type {string}
|
|
47
|
+
* @memberof ApplicationSelf
|
|
48
|
+
*/
|
|
49
|
+
signingAlgorithm: ApplicationSelfSigningAlgorithmEnum;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* @export
|
|
55
|
+
*/
|
|
56
|
+
export const ApplicationSelfEnvironmentEnum = {
|
|
57
|
+
TEST: 'test',
|
|
58
|
+
LIVE: 'live'
|
|
59
|
+
} as const;
|
|
60
|
+
export type ApplicationSelfEnvironmentEnum = typeof ApplicationSelfEnvironmentEnum[keyof typeof ApplicationSelfEnvironmentEnum];
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* @export
|
|
64
|
+
*/
|
|
65
|
+
export const ApplicationSelfSigningAlgorithmEnum = {
|
|
66
|
+
HS256: 'HS256',
|
|
67
|
+
RS256: 'RS256',
|
|
68
|
+
ES256: 'ES256'
|
|
69
|
+
} as const;
|
|
70
|
+
export type ApplicationSelfSigningAlgorithmEnum = typeof ApplicationSelfSigningAlgorithmEnum[keyof typeof ApplicationSelfSigningAlgorithmEnum];
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* Check if a given object implements the ApplicationSelf interface.
|
|
75
|
+
*/
|
|
76
|
+
export function instanceOfApplicationSelf(value: object): value is ApplicationSelf {
|
|
77
|
+
if (!('id' in value) || value['id'] === undefined) return false;
|
|
78
|
+
if (!('name' in value) || value['name'] === undefined) return false;
|
|
79
|
+
if (!('environment' in value) || value['environment'] === undefined) return false;
|
|
80
|
+
if (!('signingAlgorithm' in value) || value['signingAlgorithm'] === undefined) return false;
|
|
81
|
+
return true;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
export function ApplicationSelfFromJSON(json: any): ApplicationSelf {
|
|
85
|
+
return ApplicationSelfFromJSONTyped(json, false);
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
export function ApplicationSelfFromJSONTyped(json: any, ignoreDiscriminator: boolean): ApplicationSelf {
|
|
89
|
+
if (json == null) {
|
|
90
|
+
return json;
|
|
91
|
+
}
|
|
92
|
+
return {
|
|
93
|
+
|
|
94
|
+
'id': json['id'],
|
|
95
|
+
'name': json['name'],
|
|
96
|
+
'environment': json['environment'],
|
|
97
|
+
'signingAlgorithm': json['signing_algorithm'],
|
|
98
|
+
};
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
export function ApplicationSelfToJSON(json: any): ApplicationSelf {
|
|
102
|
+
return ApplicationSelfToJSONTyped(json, false);
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
export function ApplicationSelfToJSONTyped(value?: ApplicationSelf | null, ignoreDiscriminator: boolean = false): any {
|
|
106
|
+
if (value == null) {
|
|
107
|
+
return value;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
return {
|
|
111
|
+
|
|
112
|
+
'id': value['id'],
|
|
113
|
+
'name': value['name'],
|
|
114
|
+
'environment': value['environment'],
|
|
115
|
+
'signing_algorithm': value['signingAlgorithm'],
|
|
116
|
+
};
|
|
117
|
+
}
|
|
118
|
+
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
/* tslint:disable */
|
|
2
|
+
/* eslint-disable */
|
|
3
|
+
/**
|
|
4
|
+
* Zyphr API
|
|
5
|
+
* Zyphr is a multi-channel notification platform that enables developers to send emails, push notifications, SMS, and in-app messages through a unified API. ## Authentication All API requests require authentication using an API key. Include your API key in the `X-API-Key` header: ``` X-API-Key: zy_live_xxxxxxxxxxxx ``` API keys can be created in the Zyphr Dashboard. Use `zy_test_*` keys for testing and `zy_live_*` keys for production. ## Rate Limiting The API implements rate limiting to ensure fair usage. Rate limit information is included in response headers: - `X-RateLimit-Limit`: Maximum requests per window - `X-RateLimit-Remaining`: Remaining requests in current window - `X-RateLimit-Reset`: Unix timestamp when the window resets ## Account Sending Status Every authenticated response carries the account\'s current sending state so you can surface it in your own tooling without a separate call: - `X-Account-Sending-Status`: `active`, `throttled`, or `frozen` - `X-Account-Sending-Status-Reason`: human-readable reason (present only when the status is `throttled` or `frozen`) This header is informational and non-blocking on non-send endpoints (reads, billing, and deliverability stay available). Send-capable endpoints additionally enforce the state: a frozen account receives `403 account_frozen` and a throttled account receives `429 account_throttled`, both with the reason in the error message. ## Errors All errors follow a consistent format: ```json { \"error\": { \"code\": \"error_code\", \"message\": \"Human readable message\", \"details\": {} }, \"meta\": { \"request_id\": \"req_xxxx\" } } ```
|
|
6
|
+
*
|
|
7
|
+
* The version of the OpenAPI document: 1.0.0
|
|
8
|
+
* Contact: support@zyphr.dev
|
|
9
|
+
*
|
|
10
|
+
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
|
11
|
+
* https://openapi-generator.tech
|
|
12
|
+
* Do not edit the class manually.
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
import { mapValues } from '../runtime';
|
|
16
|
+
import type { ApplicationSelf } from './ApplicationSelf';
|
|
17
|
+
import {
|
|
18
|
+
ApplicationSelfFromJSON,
|
|
19
|
+
ApplicationSelfFromJSONTyped,
|
|
20
|
+
ApplicationSelfToJSON,
|
|
21
|
+
ApplicationSelfToJSONTyped,
|
|
22
|
+
} from './ApplicationSelf';
|
|
23
|
+
import type { RequestMeta } from './RequestMeta';
|
|
24
|
+
import {
|
|
25
|
+
RequestMetaFromJSON,
|
|
26
|
+
RequestMetaFromJSONTyped,
|
|
27
|
+
RequestMetaToJSON,
|
|
28
|
+
RequestMetaToJSONTyped,
|
|
29
|
+
} from './RequestMeta';
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
*
|
|
33
|
+
* @export
|
|
34
|
+
* @interface ApplicationSelfResponse
|
|
35
|
+
*/
|
|
36
|
+
export interface ApplicationSelfResponse {
|
|
37
|
+
/**
|
|
38
|
+
*
|
|
39
|
+
* @type {ApplicationSelf}
|
|
40
|
+
* @memberof ApplicationSelfResponse
|
|
41
|
+
*/
|
|
42
|
+
data?: ApplicationSelf;
|
|
43
|
+
/**
|
|
44
|
+
*
|
|
45
|
+
* @type {RequestMeta}
|
|
46
|
+
* @memberof ApplicationSelfResponse
|
|
47
|
+
*/
|
|
48
|
+
meta?: RequestMeta;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* Check if a given object implements the ApplicationSelfResponse interface.
|
|
53
|
+
*/
|
|
54
|
+
export function instanceOfApplicationSelfResponse(value: object): value is ApplicationSelfResponse {
|
|
55
|
+
return true;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
export function ApplicationSelfResponseFromJSON(json: any): ApplicationSelfResponse {
|
|
59
|
+
return ApplicationSelfResponseFromJSONTyped(json, false);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
export function ApplicationSelfResponseFromJSONTyped(json: any, ignoreDiscriminator: boolean): ApplicationSelfResponse {
|
|
63
|
+
if (json == null) {
|
|
64
|
+
return json;
|
|
65
|
+
}
|
|
66
|
+
return {
|
|
67
|
+
|
|
68
|
+
'data': json['data'] == null ? undefined : ApplicationSelfFromJSON(json['data']),
|
|
69
|
+
'meta': json['meta'] == null ? undefined : RequestMetaFromJSON(json['meta']),
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
export function ApplicationSelfResponseToJSON(json: any): ApplicationSelfResponse {
|
|
74
|
+
return ApplicationSelfResponseToJSONTyped(json, false);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
export function ApplicationSelfResponseToJSONTyped(value?: ApplicationSelfResponse | null, ignoreDiscriminator: boolean = false): any {
|
|
78
|
+
if (value == null) {
|
|
79
|
+
return value;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
return {
|
|
83
|
+
|
|
84
|
+
'data': ApplicationSelfToJSON(value['data']),
|
|
85
|
+
'meta': RequestMetaToJSON(value['meta']),
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
|
|
@@ -20,7 +20,7 @@ import { mapValues } from '../runtime';
|
|
|
20
20
|
*/
|
|
21
21
|
export interface AuthEmailTemplateTestRequest {
|
|
22
22
|
/**
|
|
23
|
-
* Recipient email. Must be in the application's `test_recipients` allowlist.
|
|
23
|
+
* Recipient email. Must be in the application's `test_recipients` allowlist. When non-empty, `test_recipients` gates ALL auth emails the application sends (magic link, password reset, verification, OTP) — only listed recipients receive auth email — which keeps non-production applications safe from mass sends. An empty allowlist imposes no restriction.
|
|
24
24
|
* @type {string}
|
|
25
25
|
* @memberof AuthEmailTemplateTestRequest
|
|
26
26
|
*/
|