@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/dist/index.js
CHANGED
|
@@ -5092,6 +5092,47 @@ function InboxNotificationResponseToJSONTyped(value, ignoreDiscriminator = false
|
|
|
5092
5092
|
};
|
|
5093
5093
|
}
|
|
5094
5094
|
|
|
5095
|
+
// src/src/models/InviteEndUserRequest.ts
|
|
5096
|
+
var InviteEndUserRequestSendLinkEnum = {
|
|
5097
|
+
MAGIC: "magic",
|
|
5098
|
+
PASSWORD_RESET: "password_reset",
|
|
5099
|
+
NONE: "none"
|
|
5100
|
+
};
|
|
5101
|
+
function instanceOfInviteEndUserRequest(value) {
|
|
5102
|
+
if (!("email" in value) || value["email"] === void 0) return false;
|
|
5103
|
+
return true;
|
|
5104
|
+
}
|
|
5105
|
+
function InviteEndUserRequestFromJSON(json) {
|
|
5106
|
+
return InviteEndUserRequestFromJSONTyped(json, false);
|
|
5107
|
+
}
|
|
5108
|
+
function InviteEndUserRequestFromJSONTyped(json, ignoreDiscriminator) {
|
|
5109
|
+
if (json == null) {
|
|
5110
|
+
return json;
|
|
5111
|
+
}
|
|
5112
|
+
return {
|
|
5113
|
+
"email": json["email"],
|
|
5114
|
+
"name": json["name"] == null ? void 0 : json["name"],
|
|
5115
|
+
"metadata": json["metadata"] == null ? void 0 : json["metadata"],
|
|
5116
|
+
"sendLink": json["send_link"] == null ? void 0 : json["send_link"],
|
|
5117
|
+
"redirectUrl": json["redirect_url"] == null ? void 0 : json["redirect_url"]
|
|
5118
|
+
};
|
|
5119
|
+
}
|
|
5120
|
+
function InviteEndUserRequestToJSON(json) {
|
|
5121
|
+
return InviteEndUserRequestToJSONTyped(json, false);
|
|
5122
|
+
}
|
|
5123
|
+
function InviteEndUserRequestToJSONTyped(value, ignoreDiscriminator = false) {
|
|
5124
|
+
if (value == null) {
|
|
5125
|
+
return value;
|
|
5126
|
+
}
|
|
5127
|
+
return {
|
|
5128
|
+
"email": value["email"],
|
|
5129
|
+
"name": value["name"],
|
|
5130
|
+
"metadata": value["metadata"],
|
|
5131
|
+
"send_link": value["sendLink"],
|
|
5132
|
+
"redirect_url": value["redirectUrl"]
|
|
5133
|
+
};
|
|
5134
|
+
}
|
|
5135
|
+
|
|
5095
5136
|
// src/src/models/ListWaaSApplications200Response.ts
|
|
5096
5137
|
function instanceOfListWaaSApplications200Response(value) {
|
|
5097
5138
|
return true;
|
|
@@ -6471,6 +6512,37 @@ function OAuthProviderToJSONTyped(value, ignoreDiscriminator = false) {
|
|
|
6471
6512
|
};
|
|
6472
6513
|
}
|
|
6473
6514
|
|
|
6515
|
+
// src/src/models/OAuthProviderName.ts
|
|
6516
|
+
var OAuthProviderName = {
|
|
6517
|
+
GOOGLE: "google",
|
|
6518
|
+
APPLE: "apple",
|
|
6519
|
+
FACEBOOK: "facebook",
|
|
6520
|
+
GITHUB: "github",
|
|
6521
|
+
MICROSOFT: "microsoft"
|
|
6522
|
+
};
|
|
6523
|
+
function instanceOfOAuthProviderName(value) {
|
|
6524
|
+
for (const key in OAuthProviderName) {
|
|
6525
|
+
if (Object.prototype.hasOwnProperty.call(OAuthProviderName, key)) {
|
|
6526
|
+
if (OAuthProviderName[key] === value) {
|
|
6527
|
+
return true;
|
|
6528
|
+
}
|
|
6529
|
+
}
|
|
6530
|
+
}
|
|
6531
|
+
return false;
|
|
6532
|
+
}
|
|
6533
|
+
function OAuthProviderNameFromJSON(json) {
|
|
6534
|
+
return OAuthProviderNameFromJSONTyped(json, false);
|
|
6535
|
+
}
|
|
6536
|
+
function OAuthProviderNameFromJSONTyped(json, ignoreDiscriminator) {
|
|
6537
|
+
return json;
|
|
6538
|
+
}
|
|
6539
|
+
function OAuthProviderNameToJSON(value) {
|
|
6540
|
+
return value;
|
|
6541
|
+
}
|
|
6542
|
+
function OAuthProviderNameToJSONTyped(value, ignoreDiscriminator) {
|
|
6543
|
+
return value;
|
|
6544
|
+
}
|
|
6545
|
+
|
|
6474
6546
|
// src/src/models/OAuthProvidersResponseData.ts
|
|
6475
6547
|
function instanceOfOAuthProvidersResponseData(value) {
|
|
6476
6548
|
return true;
|
|
@@ -10054,6 +10126,33 @@ function SetDomainInboundRequestToJSONTyped(value, ignoreDiscriminator = false)
|
|
|
10054
10126
|
};
|
|
10055
10127
|
}
|
|
10056
10128
|
|
|
10129
|
+
// src/src/models/SetEndUserClaimsRequest.ts
|
|
10130
|
+
function instanceOfSetEndUserClaimsRequest(value) {
|
|
10131
|
+
return true;
|
|
10132
|
+
}
|
|
10133
|
+
function SetEndUserClaimsRequestFromJSON(json) {
|
|
10134
|
+
return SetEndUserClaimsRequestFromJSONTyped(json, false);
|
|
10135
|
+
}
|
|
10136
|
+
function SetEndUserClaimsRequestFromJSONTyped(json, ignoreDiscriminator) {
|
|
10137
|
+
if (json == null) {
|
|
10138
|
+
return json;
|
|
10139
|
+
}
|
|
10140
|
+
return {
|
|
10141
|
+
"claims": json["claims"] == null ? void 0 : json["claims"]
|
|
10142
|
+
};
|
|
10143
|
+
}
|
|
10144
|
+
function SetEndUserClaimsRequestToJSON(json) {
|
|
10145
|
+
return SetEndUserClaimsRequestToJSONTyped(json, false);
|
|
10146
|
+
}
|
|
10147
|
+
function SetEndUserClaimsRequestToJSONTyped(value, ignoreDiscriminator = false) {
|
|
10148
|
+
if (value == null) {
|
|
10149
|
+
return value;
|
|
10150
|
+
}
|
|
10151
|
+
return {
|
|
10152
|
+
"claims": value["claims"]
|
|
10153
|
+
};
|
|
10154
|
+
}
|
|
10155
|
+
|
|
10057
10156
|
// src/src/models/SetPreferencesRequestPreferencesInner.ts
|
|
10058
10157
|
function instanceOfSetPreferencesRequestPreferencesInner(value) {
|
|
10059
10158
|
return true;
|
|
@@ -10128,7 +10227,9 @@ function SignInAnonymouslyRequestFromJSONTyped(json, ignoreDiscriminator) {
|
|
|
10128
10227
|
return {
|
|
10129
10228
|
"deviceId": json["device_id"],
|
|
10130
10229
|
"name": json["name"] == null ? void 0 : json["name"],
|
|
10131
|
-
"metadata": json["metadata"] == null ? void 0 : json["metadata"]
|
|
10230
|
+
"metadata": json["metadata"] == null ? void 0 : json["metadata"],
|
|
10231
|
+
"organizationId": json["organization_id"] == null ? void 0 : json["organization_id"],
|
|
10232
|
+
"organizationRole": json["organization_role"] == null ? void 0 : json["organization_role"]
|
|
10132
10233
|
};
|
|
10133
10234
|
}
|
|
10134
10235
|
function SignInAnonymouslyRequestToJSON(json) {
|
|
@@ -10141,7 +10242,52 @@ function SignInAnonymouslyRequestToJSONTyped(value, ignoreDiscriminator = false)
|
|
|
10141
10242
|
return {
|
|
10142
10243
|
"device_id": value["deviceId"],
|
|
10143
10244
|
"name": value["name"],
|
|
10144
|
-
"metadata": value["metadata"]
|
|
10245
|
+
"metadata": value["metadata"],
|
|
10246
|
+
"organization_id": value["organizationId"],
|
|
10247
|
+
"organization_role": value["organizationRole"]
|
|
10248
|
+
};
|
|
10249
|
+
}
|
|
10250
|
+
|
|
10251
|
+
// src/src/models/SignInWithGameCenterRequest.ts
|
|
10252
|
+
function instanceOfSignInWithGameCenterRequest(value) {
|
|
10253
|
+
if (!("playerId" in value) || value["playerId"] === void 0) return false;
|
|
10254
|
+
if (!("publicKeyUrl" in value) || value["publicKeyUrl"] === void 0) return false;
|
|
10255
|
+
if (!("signature" in value) || value["signature"] === void 0) return false;
|
|
10256
|
+
if (!("salt" in value) || value["salt"] === void 0) return false;
|
|
10257
|
+
if (!("timestamp" in value) || value["timestamp"] === void 0) return false;
|
|
10258
|
+
if (!("bundleId" in value) || value["bundleId"] === void 0) return false;
|
|
10259
|
+
return true;
|
|
10260
|
+
}
|
|
10261
|
+
function SignInWithGameCenterRequestFromJSON(json) {
|
|
10262
|
+
return SignInWithGameCenterRequestFromJSONTyped(json, false);
|
|
10263
|
+
}
|
|
10264
|
+
function SignInWithGameCenterRequestFromJSONTyped(json, ignoreDiscriminator) {
|
|
10265
|
+
if (json == null) {
|
|
10266
|
+
return json;
|
|
10267
|
+
}
|
|
10268
|
+
return {
|
|
10269
|
+
"playerId": json["playerId"],
|
|
10270
|
+
"publicKeyUrl": json["publicKeyUrl"],
|
|
10271
|
+
"signature": json["signature"],
|
|
10272
|
+
"salt": json["salt"],
|
|
10273
|
+
"timestamp": json["timestamp"],
|
|
10274
|
+
"bundleId": json["bundleId"]
|
|
10275
|
+
};
|
|
10276
|
+
}
|
|
10277
|
+
function SignInWithGameCenterRequestToJSON(json) {
|
|
10278
|
+
return SignInWithGameCenterRequestToJSONTyped(json, false);
|
|
10279
|
+
}
|
|
10280
|
+
function SignInWithGameCenterRequestToJSONTyped(value, ignoreDiscriminator = false) {
|
|
10281
|
+
if (value == null) {
|
|
10282
|
+
return value;
|
|
10283
|
+
}
|
|
10284
|
+
return {
|
|
10285
|
+
"playerId": value["playerId"],
|
|
10286
|
+
"publicKeyUrl": value["publicKeyUrl"],
|
|
10287
|
+
"signature": value["signature"],
|
|
10288
|
+
"salt": value["salt"],
|
|
10289
|
+
"timestamp": value["timestamp"],
|
|
10290
|
+
"bundleId": value["bundleId"]
|
|
10145
10291
|
};
|
|
10146
10292
|
}
|
|
10147
10293
|
|
|
@@ -11800,6 +11946,41 @@ function UpdateCategoryRequestToJSONTyped(value, ignoreDiscriminator = false) {
|
|
|
11800
11946
|
};
|
|
11801
11947
|
}
|
|
11802
11948
|
|
|
11949
|
+
// src/src/models/UpdateEndUserByApplicationRequest.ts
|
|
11950
|
+
function instanceOfUpdateEndUserByApplicationRequest(value) {
|
|
11951
|
+
return true;
|
|
11952
|
+
}
|
|
11953
|
+
function UpdateEndUserByApplicationRequestFromJSON(json) {
|
|
11954
|
+
return UpdateEndUserByApplicationRequestFromJSONTyped(json, false);
|
|
11955
|
+
}
|
|
11956
|
+
function UpdateEndUserByApplicationRequestFromJSONTyped(json, ignoreDiscriminator) {
|
|
11957
|
+
if (json == null) {
|
|
11958
|
+
return json;
|
|
11959
|
+
}
|
|
11960
|
+
return {
|
|
11961
|
+
"email": json["email"] == null ? void 0 : json["email"],
|
|
11962
|
+
"name": json["name"] == null ? void 0 : json["name"],
|
|
11963
|
+
"avatarUrl": json["avatar_url"] == null ? void 0 : json["avatar_url"],
|
|
11964
|
+
"metadata": json["metadata"] == null ? void 0 : json["metadata"],
|
|
11965
|
+
"status": json["status"] == null ? void 0 : json["status"]
|
|
11966
|
+
};
|
|
11967
|
+
}
|
|
11968
|
+
function UpdateEndUserByApplicationRequestToJSON(json) {
|
|
11969
|
+
return UpdateEndUserByApplicationRequestToJSONTyped(json, false);
|
|
11970
|
+
}
|
|
11971
|
+
function UpdateEndUserByApplicationRequestToJSONTyped(value, ignoreDiscriminator = false) {
|
|
11972
|
+
if (value == null) {
|
|
11973
|
+
return value;
|
|
11974
|
+
}
|
|
11975
|
+
return {
|
|
11976
|
+
"email": value["email"],
|
|
11977
|
+
"name": value["name"],
|
|
11978
|
+
"avatar_url": value["avatarUrl"],
|
|
11979
|
+
"metadata": value["metadata"],
|
|
11980
|
+
"status": value["status"]
|
|
11981
|
+
};
|
|
11982
|
+
}
|
|
11983
|
+
|
|
11803
11984
|
// src/src/models/UpdateEndUserRequest.ts
|
|
11804
11985
|
function instanceOfUpdateEndUserRequest(value) {
|
|
11805
11986
|
return true;
|
|
@@ -16685,7 +16866,7 @@ var AuthRegistrationApi = class extends BaseAPI {
|
|
|
16685
16866
|
return await response.value();
|
|
16686
16867
|
}
|
|
16687
16868
|
/**
|
|
16688
|
-
* Issue an end-user identity to a device without email, password, OAuth, or any other credential. Idempotent per (application, environment, device_id): repeated calls with the same device_id return the same user but a fresh token pair. Prior sessions for the user remain valid until natural expiry. Anonymous users do not count toward MAU quota until their first authenticated request after sign-in (excluding /v1/auth/refresh). Convert an anonymous user to a full account via POST /v1/auth/users/convert.
|
|
16869
|
+
* Issue an end-user identity to a device without email, password, OAuth, or any other credential. Idempotent per (application, environment, device_id): repeated calls with the same device_id return the same user but a fresh token pair. Prior sessions for the user remain valid until natural expiry. Anonymous users do not count toward MAU quota until their first authenticated request after sign-in (excluding /v1/auth/refresh). Convert an anonymous user to a full account via POST /v1/auth/users/convert. Pass an optional `organization_id` to create the anonymous user directly in an organization; the returned access token then carries `org_id` (and `orgs`), matching the org-scoped register/login flow.
|
|
16689
16870
|
* Sign in anonymously
|
|
16690
16871
|
*/
|
|
16691
16872
|
async signInAnonymouslyRaw(requestParameters, initOverrides) {
|
|
@@ -16711,13 +16892,47 @@ var AuthRegistrationApi = class extends BaseAPI {
|
|
|
16711
16892
|
return new JSONApiResponse(response, (jsonValue) => AuthResultResponseFromJSON(jsonValue));
|
|
16712
16893
|
}
|
|
16713
16894
|
/**
|
|
16714
|
-
* Issue an end-user identity to a device without email, password, OAuth, or any other credential. Idempotent per (application, environment, device_id): repeated calls with the same device_id return the same user but a fresh token pair. Prior sessions for the user remain valid until natural expiry. Anonymous users do not count toward MAU quota until their first authenticated request after sign-in (excluding /v1/auth/refresh). Convert an anonymous user to a full account via POST /v1/auth/users/convert.
|
|
16895
|
+
* Issue an end-user identity to a device without email, password, OAuth, or any other credential. Idempotent per (application, environment, device_id): repeated calls with the same device_id return the same user but a fresh token pair. Prior sessions for the user remain valid until natural expiry. Anonymous users do not count toward MAU quota until their first authenticated request after sign-in (excluding /v1/auth/refresh). Convert an anonymous user to a full account via POST /v1/auth/users/convert. Pass an optional `organization_id` to create the anonymous user directly in an organization; the returned access token then carries `org_id` (and `orgs`), matching the org-scoped register/login flow.
|
|
16715
16896
|
* Sign in anonymously
|
|
16716
16897
|
*/
|
|
16717
16898
|
async signInAnonymously(signInAnonymouslyRequest, initOverrides) {
|
|
16718
16899
|
const response = await this.signInAnonymouslyRaw({ signInAnonymouslyRequest }, initOverrides);
|
|
16719
16900
|
return await response.value();
|
|
16720
16901
|
}
|
|
16902
|
+
/**
|
|
16903
|
+
* Exchange an Apple Game Center identity-verification assertion for a Zyphr end-user session. Zyphr independently re-verifies the assertion server-side (Apple certificate chain, RSA-SHA256 signature, timestamp freshness, single-use replay guard, and bundle-id binding) before provisioning-or-looking-up the user and minting tokens. The user is keyed on the modern scoped `playerId` (gamePlayerID). ## Producing the assertion (Integration) The assertion is produced **on-device by the iOS app** — there is no server-side way to mint it. The app calls GameKit\'s `GKLocalPlayer.fetchItems(forIdentityVerificationSignature:)`, which returns `publicKeyURL`, `signature`, `salt`, and `timestamp`; combine those with the local player\'s `gamePlayerID` and the app\'s bundle identifier and submit them here. Two integration shapes are supported: - **client-direct** — the iOS app holds the Zyphr application public key and calls this endpoint itself. - **backend-relayed** — the app forwards the fetched assertion fields to the customer\'s own backend, which relays them to this endpoint; the app never holds Zyphr keys. (This is the common shape for games.) On any verification failure the response is a single opaque `401` `invalid_assertion` — the specific control that failed is never disclosed.
|
|
16904
|
+
* Sign in with Apple Game Center
|
|
16905
|
+
*/
|
|
16906
|
+
async signInWithGameCenterRaw(requestParameters, initOverrides) {
|
|
16907
|
+
if (requestParameters["signInWithGameCenterRequest"] == null) {
|
|
16908
|
+
throw new RequiredError(
|
|
16909
|
+
"signInWithGameCenterRequest",
|
|
16910
|
+
'Required parameter "signInWithGameCenterRequest" was null or undefined when calling signInWithGameCenter().'
|
|
16911
|
+
);
|
|
16912
|
+
}
|
|
16913
|
+
const queryParameters = {};
|
|
16914
|
+
const headerParameters = {};
|
|
16915
|
+
headerParameters["Content-Type"] = "application/json";
|
|
16916
|
+
if (this.configuration && this.configuration.apiKey) {
|
|
16917
|
+
headerParameters["X-Application-Key"] = await this.configuration.apiKey("X-Application-Key");
|
|
16918
|
+
}
|
|
16919
|
+
const response = await this.request({
|
|
16920
|
+
path: `/auth/game-center`,
|
|
16921
|
+
method: "POST",
|
|
16922
|
+
headers: headerParameters,
|
|
16923
|
+
query: queryParameters,
|
|
16924
|
+
body: SignInWithGameCenterRequestToJSON(requestParameters["signInWithGameCenterRequest"])
|
|
16925
|
+
}, initOverrides);
|
|
16926
|
+
return new JSONApiResponse(response, (jsonValue) => AuthResultResponseFromJSON(jsonValue));
|
|
16927
|
+
}
|
|
16928
|
+
/**
|
|
16929
|
+
* Exchange an Apple Game Center identity-verification assertion for a Zyphr end-user session. Zyphr independently re-verifies the assertion server-side (Apple certificate chain, RSA-SHA256 signature, timestamp freshness, single-use replay guard, and bundle-id binding) before provisioning-or-looking-up the user and minting tokens. The user is keyed on the modern scoped `playerId` (gamePlayerID). ## Producing the assertion (Integration) The assertion is produced **on-device by the iOS app** — there is no server-side way to mint it. The app calls GameKit\'s `GKLocalPlayer.fetchItems(forIdentityVerificationSignature:)`, which returns `publicKeyURL`, `signature`, `salt`, and `timestamp`; combine those with the local player\'s `gamePlayerID` and the app\'s bundle identifier and submit them here. Two integration shapes are supported: - **client-direct** — the iOS app holds the Zyphr application public key and calls this endpoint itself. - **backend-relayed** — the app forwards the fetched assertion fields to the customer\'s own backend, which relays them to this endpoint; the app never holds Zyphr keys. (This is the common shape for games.) On any verification failure the response is a single opaque `401` `invalid_assertion` — the specific control that failed is never disclosed.
|
|
16930
|
+
* Sign in with Apple Game Center
|
|
16931
|
+
*/
|
|
16932
|
+
async signInWithGameCenter(signInWithGameCenterRequest, initOverrides) {
|
|
16933
|
+
const response = await this.signInWithGameCenterRaw({ signInWithGameCenterRequest }, initOverrides);
|
|
16934
|
+
return await response.value();
|
|
16935
|
+
}
|
|
16721
16936
|
};
|
|
16722
16937
|
|
|
16723
16938
|
// src/src/apis/AuthSessionsApi.ts
|
|
@@ -16867,50 +17082,88 @@ var AuthSessionsApi = class extends BaseAPI {
|
|
|
16867
17082
|
}
|
|
16868
17083
|
};
|
|
16869
17084
|
|
|
16870
|
-
// src/src/apis/
|
|
16871
|
-
var
|
|
17085
|
+
// src/src/apis/AuthUserDirectoryApi.ts
|
|
17086
|
+
var AuthUserDirectoryApi = class extends BaseAPI {
|
|
16872
17087
|
/**
|
|
16873
|
-
*
|
|
16874
|
-
* Delete
|
|
17088
|
+
* Secret-key-scoped admin soft-delete for an arbitrary end user in the authenticating application. Works in both test and live environments. Scoped to the application via the application_id filter — a caller can never delete a user belonging to another application. Mirrors the self-service `DELETE /auth/users/me` flow: revokes all sessions, soft-deletes the row (status=\'deleted\'), and emits a `user.deleted` webhook with `method=\'application_admin\'`. The audit log row survives (no FK to end_users), so org-history queries still resolve.
|
|
17089
|
+
* Delete an end user (server-side admin)
|
|
16875
17090
|
*/
|
|
16876
|
-
async
|
|
17091
|
+
async deleteEndUserByApplicationRaw(requestParameters, initOverrides) {
|
|
17092
|
+
if (requestParameters["userId"] == null) {
|
|
17093
|
+
throw new RequiredError(
|
|
17094
|
+
"userId",
|
|
17095
|
+
'Required parameter "userId" was null or undefined when calling deleteEndUserByApplication().'
|
|
17096
|
+
);
|
|
17097
|
+
}
|
|
16877
17098
|
const queryParameters = {};
|
|
16878
17099
|
const headerParameters = {};
|
|
16879
|
-
if (this.configuration && this.configuration.
|
|
16880
|
-
|
|
16881
|
-
const tokenString = await token("EndUserToken", []);
|
|
16882
|
-
if (tokenString) {
|
|
16883
|
-
headerParameters["Authorization"] = `Bearer ${tokenString}`;
|
|
16884
|
-
}
|
|
17100
|
+
if (this.configuration && this.configuration.apiKey) {
|
|
17101
|
+
headerParameters["X-Application-Secret"] = await this.configuration.apiKey("X-Application-Secret");
|
|
16885
17102
|
}
|
|
16886
17103
|
if (this.configuration && this.configuration.apiKey) {
|
|
16887
17104
|
headerParameters["X-Application-Key"] = await this.configuration.apiKey("X-Application-Key");
|
|
16888
17105
|
}
|
|
16889
17106
|
const response = await this.request({
|
|
16890
|
-
path: `/auth/users/
|
|
17107
|
+
path: `/auth/users/{user_id}`.replace(`{${"user_id"}}`, encodeURIComponent(String(requestParameters["userId"]))),
|
|
16891
17108
|
method: "DELETE",
|
|
16892
17109
|
headers: headerParameters,
|
|
16893
17110
|
query: queryParameters
|
|
16894
17111
|
}, initOverrides);
|
|
16895
|
-
return new
|
|
17112
|
+
return new VoidApiResponse(response);
|
|
16896
17113
|
}
|
|
16897
17114
|
/**
|
|
16898
|
-
*
|
|
16899
|
-
* Delete
|
|
17115
|
+
* Secret-key-scoped admin soft-delete for an arbitrary end user in the authenticating application. Works in both test and live environments. Scoped to the application via the application_id filter — a caller can never delete a user belonging to another application. Mirrors the self-service `DELETE /auth/users/me` flow: revokes all sessions, soft-deletes the row (status=\'deleted\'), and emits a `user.deleted` webhook with `method=\'application_admin\'`. The audit log row survives (no FK to end_users), so org-history queries still resolve.
|
|
17116
|
+
* Delete an end user (server-side admin)
|
|
16900
17117
|
*/
|
|
16901
|
-
async
|
|
16902
|
-
|
|
16903
|
-
return await response.value();
|
|
17118
|
+
async deleteEndUserByApplication(userId, initOverrides) {
|
|
17119
|
+
await this.deleteEndUserByApplicationRaw({ userId }, initOverrides);
|
|
16904
17120
|
}
|
|
16905
17121
|
/**
|
|
16906
|
-
*
|
|
16907
|
-
*
|
|
17122
|
+
* 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.
|
|
17123
|
+
* Look up an end user by email (server-side admin)
|
|
16908
17124
|
*/
|
|
16909
|
-
async
|
|
17125
|
+
async getEndUserByEmailRaw(requestParameters, initOverrides) {
|
|
17126
|
+
if (requestParameters["email"] == null) {
|
|
17127
|
+
throw new RequiredError(
|
|
17128
|
+
"email",
|
|
17129
|
+
'Required parameter "email" was null or undefined when calling getEndUserByEmail().'
|
|
17130
|
+
);
|
|
17131
|
+
}
|
|
17132
|
+
const queryParameters = {};
|
|
17133
|
+
if (requestParameters["email"] != null) {
|
|
17134
|
+
queryParameters["email"] = requestParameters["email"];
|
|
17135
|
+
}
|
|
17136
|
+
const headerParameters = {};
|
|
17137
|
+
if (this.configuration && this.configuration.apiKey) {
|
|
17138
|
+
headerParameters["X-Application-Secret"] = await this.configuration.apiKey("X-Application-Secret");
|
|
17139
|
+
}
|
|
17140
|
+
if (this.configuration && this.configuration.apiKey) {
|
|
17141
|
+
headerParameters["X-Application-Key"] = await this.configuration.apiKey("X-Application-Key");
|
|
17142
|
+
}
|
|
17143
|
+
const response = await this.request({
|
|
17144
|
+
path: `/auth/users/by-email`,
|
|
17145
|
+
method: "GET",
|
|
17146
|
+
headers: headerParameters,
|
|
17147
|
+
query: queryParameters
|
|
17148
|
+
}, initOverrides);
|
|
17149
|
+
return new VoidApiResponse(response);
|
|
17150
|
+
}
|
|
17151
|
+
/**
|
|
17152
|
+
* 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.
|
|
17153
|
+
* Look up an end user by email (server-side admin)
|
|
17154
|
+
*/
|
|
17155
|
+
async getEndUserByEmail(email, initOverrides) {
|
|
17156
|
+
await this.getEndUserByEmailRaw({ email }, initOverrides);
|
|
17157
|
+
}
|
|
17158
|
+
/**
|
|
17159
|
+
* Secret-key-scoped fetch of a single end user by id within the authenticating application. Scoped to the application — a caller can never read a user belonging to another application.
|
|
17160
|
+
* Get an end user by id (server-side admin)
|
|
17161
|
+
*/
|
|
17162
|
+
async getEndUserByIdRaw(requestParameters, initOverrides) {
|
|
16910
17163
|
if (requestParameters["userId"] == null) {
|
|
16911
17164
|
throw new RequiredError(
|
|
16912
17165
|
"userId",
|
|
16913
|
-
'Required parameter "userId" was null or undefined when calling
|
|
17166
|
+
'Required parameter "userId" was null or undefined when calling getEndUserById().'
|
|
16914
17167
|
);
|
|
16915
17168
|
}
|
|
16916
17169
|
const queryParameters = {};
|
|
@@ -16923,18 +17176,253 @@ var AuthUserProfileApi = class extends BaseAPI {
|
|
|
16923
17176
|
}
|
|
16924
17177
|
const response = await this.request({
|
|
16925
17178
|
path: `/auth/users/{user_id}`.replace(`{${"user_id"}}`, encodeURIComponent(String(requestParameters["userId"]))),
|
|
16926
|
-
method: "
|
|
17179
|
+
method: "GET",
|
|
16927
17180
|
headers: headerParameters,
|
|
16928
17181
|
query: queryParameters
|
|
16929
17182
|
}, initOverrides);
|
|
16930
17183
|
return new VoidApiResponse(response);
|
|
16931
17184
|
}
|
|
16932
17185
|
/**
|
|
16933
|
-
*
|
|
16934
|
-
*
|
|
17186
|
+
* Secret-key-scoped fetch of a single end user by id within the authenticating application. Scoped to the application — a caller can never read a user belonging to another application.
|
|
17187
|
+
* Get an end user by id (server-side admin)
|
|
16935
17188
|
*/
|
|
16936
|
-
async
|
|
16937
|
-
await this.
|
|
17189
|
+
async getEndUserById(userId, initOverrides) {
|
|
17190
|
+
await this.getEndUserByIdRaw({ userId }, initOverrides);
|
|
17191
|
+
}
|
|
17192
|
+
/**
|
|
17193
|
+
* Secret-key-scoped read of the authoritative custom_claims stored for an end user. These are the TRUSTED claims embedded into the user\'s JWTs on login/refresh — use them (not the client-writable `metadata` field) for authorization decisions. Returns an empty object when none are set.
|
|
17194
|
+
* Get an end user\'s stored custom claims (server-side admin)
|
|
17195
|
+
*/
|
|
17196
|
+
async getEndUserClaimsRaw(requestParameters, initOverrides) {
|
|
17197
|
+
if (requestParameters["userId"] == null) {
|
|
17198
|
+
throw new RequiredError(
|
|
17199
|
+
"userId",
|
|
17200
|
+
'Required parameter "userId" was null or undefined when calling getEndUserClaims().'
|
|
17201
|
+
);
|
|
17202
|
+
}
|
|
17203
|
+
const queryParameters = {};
|
|
17204
|
+
const headerParameters = {};
|
|
17205
|
+
if (this.configuration && this.configuration.apiKey) {
|
|
17206
|
+
headerParameters["X-Application-Secret"] = await this.configuration.apiKey("X-Application-Secret");
|
|
17207
|
+
}
|
|
17208
|
+
if (this.configuration && this.configuration.apiKey) {
|
|
17209
|
+
headerParameters["X-Application-Key"] = await this.configuration.apiKey("X-Application-Key");
|
|
17210
|
+
}
|
|
17211
|
+
const response = await this.request({
|
|
17212
|
+
path: `/auth/users/{user_id}/claims`.replace(`{${"user_id"}}`, encodeURIComponent(String(requestParameters["userId"]))),
|
|
17213
|
+
method: "GET",
|
|
17214
|
+
headers: headerParameters,
|
|
17215
|
+
query: queryParameters
|
|
17216
|
+
}, initOverrides);
|
|
17217
|
+
return new VoidApiResponse(response);
|
|
17218
|
+
}
|
|
17219
|
+
/**
|
|
17220
|
+
* Secret-key-scoped read of the authoritative custom_claims stored for an end user. These are the TRUSTED claims embedded into the user\'s JWTs on login/refresh — use them (not the client-writable `metadata` field) for authorization decisions. Returns an empty object when none are set.
|
|
17221
|
+
* Get an end user\'s stored custom claims (server-side admin)
|
|
17222
|
+
*/
|
|
17223
|
+
async getEndUserClaims(userId, initOverrides) {
|
|
17224
|
+
await this.getEndUserClaimsRaw({ userId }, initOverrides);
|
|
17225
|
+
}
|
|
17226
|
+
/**
|
|
17227
|
+
* Secret-key-scoped pre-provisioning for an end user. Creates a passwordless user in the authenticating application (idempotent on email — an existing, non-deleted user is reused, not duplicated) and, when `send_link` is set, sends a first-login link so the user can set up their account without self-registration. - `send_link: \"magic\"` sends a magic-link sign-in email. - `send_link: \"password_reset\"` sends a set-password email. - `send_link: \"none\"` (default) creates the user with no email. A `redirect_url` is required when `send_link` is \"magic\" or \"password_reset\"; it must match the application\'s redirect_uris allowlist (custom schemes such as yourapp://path are permitted).
|
|
17228
|
+
* Pre-provision (invite) an end user (server-side admin)
|
|
17229
|
+
*/
|
|
17230
|
+
async inviteEndUserRaw(requestParameters, initOverrides) {
|
|
17231
|
+
if (requestParameters["inviteEndUserRequest"] == null) {
|
|
17232
|
+
throw new RequiredError(
|
|
17233
|
+
"inviteEndUserRequest",
|
|
17234
|
+
'Required parameter "inviteEndUserRequest" was null or undefined when calling inviteEndUser().'
|
|
17235
|
+
);
|
|
17236
|
+
}
|
|
17237
|
+
const queryParameters = {};
|
|
17238
|
+
const headerParameters = {};
|
|
17239
|
+
headerParameters["Content-Type"] = "application/json";
|
|
17240
|
+
if (this.configuration && this.configuration.apiKey) {
|
|
17241
|
+
headerParameters["X-Application-Secret"] = await this.configuration.apiKey("X-Application-Secret");
|
|
17242
|
+
}
|
|
17243
|
+
if (this.configuration && this.configuration.apiKey) {
|
|
17244
|
+
headerParameters["X-Application-Key"] = await this.configuration.apiKey("X-Application-Key");
|
|
17245
|
+
}
|
|
17246
|
+
const response = await this.request({
|
|
17247
|
+
path: `/auth/users/invite`,
|
|
17248
|
+
method: "POST",
|
|
17249
|
+
headers: headerParameters,
|
|
17250
|
+
query: queryParameters,
|
|
17251
|
+
body: InviteEndUserRequestToJSON(requestParameters["inviteEndUserRequest"])
|
|
17252
|
+
}, initOverrides);
|
|
17253
|
+
return new VoidApiResponse(response);
|
|
17254
|
+
}
|
|
17255
|
+
/**
|
|
17256
|
+
* Secret-key-scoped pre-provisioning for an end user. Creates a passwordless user in the authenticating application (idempotent on email — an existing, non-deleted user is reused, not duplicated) and, when `send_link` is set, sends a first-login link so the user can set up their account without self-registration. - `send_link: \"magic\"` sends a magic-link sign-in email. - `send_link: \"password_reset\"` sends a set-password email. - `send_link: \"none\"` (default) creates the user with no email. A `redirect_url` is required when `send_link` is \"magic\" or \"password_reset\"; it must match the application\'s redirect_uris allowlist (custom schemes such as yourapp://path are permitted).
|
|
17257
|
+
* Pre-provision (invite) an end user (server-side admin)
|
|
17258
|
+
*/
|
|
17259
|
+
async inviteEndUser(inviteEndUserRequest, initOverrides) {
|
|
17260
|
+
await this.inviteEndUserRaw({ inviteEndUserRequest }, initOverrides);
|
|
17261
|
+
}
|
|
17262
|
+
/**
|
|
17263
|
+
* Secret-key-scoped directory listing of end users in the authenticating application. Supports substring search over email, name, and phone, an optional environment filter (test/live), and pagination. Scoped to the application — never returns users from another application.
|
|
17264
|
+
* List / search end users (server-side admin)
|
|
17265
|
+
*/
|
|
17266
|
+
async listEndUsersRaw(requestParameters, initOverrides) {
|
|
17267
|
+
const queryParameters = {};
|
|
17268
|
+
if (requestParameters["page"] != null) {
|
|
17269
|
+
queryParameters["page"] = requestParameters["page"];
|
|
17270
|
+
}
|
|
17271
|
+
if (requestParameters["perPage"] != null) {
|
|
17272
|
+
queryParameters["per_page"] = requestParameters["perPage"];
|
|
17273
|
+
}
|
|
17274
|
+
if (requestParameters["search"] != null) {
|
|
17275
|
+
queryParameters["search"] = requestParameters["search"];
|
|
17276
|
+
}
|
|
17277
|
+
if (requestParameters["environment"] != null) {
|
|
17278
|
+
queryParameters["environment"] = requestParameters["environment"];
|
|
17279
|
+
}
|
|
17280
|
+
const headerParameters = {};
|
|
17281
|
+
if (this.configuration && this.configuration.apiKey) {
|
|
17282
|
+
headerParameters["X-Application-Secret"] = await this.configuration.apiKey("X-Application-Secret");
|
|
17283
|
+
}
|
|
17284
|
+
if (this.configuration && this.configuration.apiKey) {
|
|
17285
|
+
headerParameters["X-Application-Key"] = await this.configuration.apiKey("X-Application-Key");
|
|
17286
|
+
}
|
|
17287
|
+
const response = await this.request({
|
|
17288
|
+
path: `/auth/users`,
|
|
17289
|
+
method: "GET",
|
|
17290
|
+
headers: headerParameters,
|
|
17291
|
+
query: queryParameters
|
|
17292
|
+
}, initOverrides);
|
|
17293
|
+
return new VoidApiResponse(response);
|
|
17294
|
+
}
|
|
17295
|
+
/**
|
|
17296
|
+
* Secret-key-scoped directory listing of end users in the authenticating application. Supports substring search over email, name, and phone, an optional environment filter (test/live), and pagination. Scoped to the application — never returns users from another application.
|
|
17297
|
+
* List / search end users (server-side admin)
|
|
17298
|
+
*/
|
|
17299
|
+
async listEndUsers(page, perPage, search, environment, initOverrides) {
|
|
17300
|
+
await this.listEndUsersRaw({ page, perPage, search, environment }, initOverrides);
|
|
17301
|
+
}
|
|
17302
|
+
/**
|
|
17303
|
+
* Secret-key-scoped upsert of the authoritative custom_claims for an end user. Set server-side only — clients cannot write these, which is what makes them safe for authorization (e.g. an account-type/admin flag). Claims are embedded into the user\'s JWTs on the next login/refresh. Max 4KB; reserved JWT/Zyphr claim names are rejected. To make a change take effect immediately on already-issued tokens (e.g. revoking admin), call POST /auth/sessions/revoke-all for the user after updating claims — that bumps the revocation epoch so outstanding access tokens stop verifying.
|
|
17304
|
+
* Set an end user\'s stored custom claims (server-side admin)
|
|
17305
|
+
*/
|
|
17306
|
+
async setEndUserClaimsRaw(requestParameters, initOverrides) {
|
|
17307
|
+
if (requestParameters["userId"] == null) {
|
|
17308
|
+
throw new RequiredError(
|
|
17309
|
+
"userId",
|
|
17310
|
+
'Required parameter "userId" was null or undefined when calling setEndUserClaims().'
|
|
17311
|
+
);
|
|
17312
|
+
}
|
|
17313
|
+
if (requestParameters["setEndUserClaimsRequest"] == null) {
|
|
17314
|
+
throw new RequiredError(
|
|
17315
|
+
"setEndUserClaimsRequest",
|
|
17316
|
+
'Required parameter "setEndUserClaimsRequest" was null or undefined when calling setEndUserClaims().'
|
|
17317
|
+
);
|
|
17318
|
+
}
|
|
17319
|
+
const queryParameters = {};
|
|
17320
|
+
const headerParameters = {};
|
|
17321
|
+
headerParameters["Content-Type"] = "application/json";
|
|
17322
|
+
if (this.configuration && this.configuration.apiKey) {
|
|
17323
|
+
headerParameters["X-Application-Secret"] = await this.configuration.apiKey("X-Application-Secret");
|
|
17324
|
+
}
|
|
17325
|
+
if (this.configuration && this.configuration.apiKey) {
|
|
17326
|
+
headerParameters["X-Application-Key"] = await this.configuration.apiKey("X-Application-Key");
|
|
17327
|
+
}
|
|
17328
|
+
const response = await this.request({
|
|
17329
|
+
path: `/auth/users/{user_id}/claims`.replace(`{${"user_id"}}`, encodeURIComponent(String(requestParameters["userId"]))),
|
|
17330
|
+
method: "PUT",
|
|
17331
|
+
headers: headerParameters,
|
|
17332
|
+
query: queryParameters,
|
|
17333
|
+
body: SetEndUserClaimsRequestToJSON(requestParameters["setEndUserClaimsRequest"])
|
|
17334
|
+
}, initOverrides);
|
|
17335
|
+
return new VoidApiResponse(response);
|
|
17336
|
+
}
|
|
17337
|
+
/**
|
|
17338
|
+
* Secret-key-scoped upsert of the authoritative custom_claims for an end user. Set server-side only — clients cannot write these, which is what makes them safe for authorization (e.g. an account-type/admin flag). Claims are embedded into the user\'s JWTs on the next login/refresh. Max 4KB; reserved JWT/Zyphr claim names are rejected. To make a change take effect immediately on already-issued tokens (e.g. revoking admin), call POST /auth/sessions/revoke-all for the user after updating claims — that bumps the revocation epoch so outstanding access tokens stop verifying.
|
|
17339
|
+
* Set an end user\'s stored custom claims (server-side admin)
|
|
17340
|
+
*/
|
|
17341
|
+
async setEndUserClaims(userId, setEndUserClaimsRequest, initOverrides) {
|
|
17342
|
+
await this.setEndUserClaimsRaw({ userId, setEndUserClaimsRequest }, initOverrides);
|
|
17343
|
+
}
|
|
17344
|
+
/**
|
|
17345
|
+
* Secret-key-scoped update of an arbitrary end user in the authenticating application. Updatable fields: email, name, avatar_url, metadata, status. Scoped to the application — a caller can never modify a user belonging to another application.
|
|
17346
|
+
* Update an end user (server-side admin)
|
|
17347
|
+
*/
|
|
17348
|
+
async updateEndUserByApplicationRaw(requestParameters, initOverrides) {
|
|
17349
|
+
if (requestParameters["userId"] == null) {
|
|
17350
|
+
throw new RequiredError(
|
|
17351
|
+
"userId",
|
|
17352
|
+
'Required parameter "userId" was null or undefined when calling updateEndUserByApplication().'
|
|
17353
|
+
);
|
|
17354
|
+
}
|
|
17355
|
+
if (requestParameters["updateEndUserByApplicationRequest"] == null) {
|
|
17356
|
+
throw new RequiredError(
|
|
17357
|
+
"updateEndUserByApplicationRequest",
|
|
17358
|
+
'Required parameter "updateEndUserByApplicationRequest" was null or undefined when calling updateEndUserByApplication().'
|
|
17359
|
+
);
|
|
17360
|
+
}
|
|
17361
|
+
const queryParameters = {};
|
|
17362
|
+
const headerParameters = {};
|
|
17363
|
+
headerParameters["Content-Type"] = "application/json";
|
|
17364
|
+
if (this.configuration && this.configuration.apiKey) {
|
|
17365
|
+
headerParameters["X-Application-Secret"] = await this.configuration.apiKey("X-Application-Secret");
|
|
17366
|
+
}
|
|
17367
|
+
if (this.configuration && this.configuration.apiKey) {
|
|
17368
|
+
headerParameters["X-Application-Key"] = await this.configuration.apiKey("X-Application-Key");
|
|
17369
|
+
}
|
|
17370
|
+
const response = await this.request({
|
|
17371
|
+
path: `/auth/users/{user_id}`.replace(`{${"user_id"}}`, encodeURIComponent(String(requestParameters["userId"]))),
|
|
17372
|
+
method: "PATCH",
|
|
17373
|
+
headers: headerParameters,
|
|
17374
|
+
query: queryParameters,
|
|
17375
|
+
body: UpdateEndUserByApplicationRequestToJSON(requestParameters["updateEndUserByApplicationRequest"])
|
|
17376
|
+
}, initOverrides);
|
|
17377
|
+
return new VoidApiResponse(response);
|
|
17378
|
+
}
|
|
17379
|
+
/**
|
|
17380
|
+
* Secret-key-scoped update of an arbitrary end user in the authenticating application. Updatable fields: email, name, avatar_url, metadata, status. Scoped to the application — a caller can never modify a user belonging to another application.
|
|
17381
|
+
* Update an end user (server-side admin)
|
|
17382
|
+
*/
|
|
17383
|
+
async updateEndUserByApplication(userId, updateEndUserByApplicationRequest, initOverrides) {
|
|
17384
|
+
await this.updateEndUserByApplicationRaw({ userId, updateEndUserByApplicationRequest }, initOverrides);
|
|
17385
|
+
}
|
|
17386
|
+
};
|
|
17387
|
+
var ListEndUsersEnvironmentEnum = {
|
|
17388
|
+
TEST: "test",
|
|
17389
|
+
LIVE: "live"
|
|
17390
|
+
};
|
|
17391
|
+
|
|
17392
|
+
// src/src/apis/AuthUserProfileApi.ts
|
|
17393
|
+
var AuthUserProfileApi = class extends BaseAPI {
|
|
17394
|
+
/**
|
|
17395
|
+
* Delete the current end user account (GDPR right to erasure). This is a soft delete — the account is marked as deleted but data is retained for a period to allow for recovery or legal requirements.
|
|
17396
|
+
* Delete current end user account
|
|
17397
|
+
*/
|
|
17398
|
+
async deleteEndUserRaw(initOverrides) {
|
|
17399
|
+
const queryParameters = {};
|
|
17400
|
+
const headerParameters = {};
|
|
17401
|
+
if (this.configuration && this.configuration.accessToken) {
|
|
17402
|
+
const token = this.configuration.accessToken;
|
|
17403
|
+
const tokenString = await token("EndUserToken", []);
|
|
17404
|
+
if (tokenString) {
|
|
17405
|
+
headerParameters["Authorization"] = `Bearer ${tokenString}`;
|
|
17406
|
+
}
|
|
17407
|
+
}
|
|
17408
|
+
if (this.configuration && this.configuration.apiKey) {
|
|
17409
|
+
headerParameters["X-Application-Key"] = await this.configuration.apiKey("X-Application-Key");
|
|
17410
|
+
}
|
|
17411
|
+
const response = await this.request({
|
|
17412
|
+
path: `/auth/users/me`,
|
|
17413
|
+
method: "DELETE",
|
|
17414
|
+
headers: headerParameters,
|
|
17415
|
+
query: queryParameters
|
|
17416
|
+
}, initOverrides);
|
|
17417
|
+
return new JSONApiResponse(response, (jsonValue) => EndUserDeleteResponseFromJSON(jsonValue));
|
|
17418
|
+
}
|
|
17419
|
+
/**
|
|
17420
|
+
* Delete the current end user account (GDPR right to erasure). This is a soft delete — the account is marked as deleted but data is retained for a period to allow for recovery or legal requirements.
|
|
17421
|
+
* Delete current end user account
|
|
17422
|
+
*/
|
|
17423
|
+
async deleteEndUser(initOverrides) {
|
|
17424
|
+
const response = await this.deleteEndUserRaw(initOverrides);
|
|
17425
|
+
return await response.value();
|
|
16938
17426
|
}
|
|
16939
17427
|
/**
|
|
16940
17428
|
* Retrieve the profile of the currently authenticated end user.
|
|
@@ -23105,34 +23593,34 @@ var ZyphrError = class extends Error {
|
|
|
23105
23593
|
}
|
|
23106
23594
|
};
|
|
23107
23595
|
var ZyphrValidationError = class extends ZyphrError {
|
|
23108
|
-
constructor(message, details) {
|
|
23109
|
-
super({ message, status: 422, code
|
|
23596
|
+
constructor(message, details, code = "validation_error") {
|
|
23597
|
+
super({ message, status: 422, code, details });
|
|
23110
23598
|
this.name = "ZyphrValidationError";
|
|
23111
23599
|
}
|
|
23112
23600
|
};
|
|
23113
23601
|
var ZyphrAuthenticationError = class extends ZyphrError {
|
|
23114
|
-
constructor(message) {
|
|
23115
|
-
super({ message, status: 401, code
|
|
23602
|
+
constructor(message, code = "authentication_error") {
|
|
23603
|
+
super({ message, status: 401, code });
|
|
23116
23604
|
this.name = "ZyphrAuthenticationError";
|
|
23117
23605
|
}
|
|
23118
23606
|
};
|
|
23119
23607
|
var ZyphrRateLimitError = class extends ZyphrError {
|
|
23120
23608
|
retryAfter;
|
|
23121
|
-
constructor(message, retryAfter) {
|
|
23122
|
-
super({ message, status: 429, code
|
|
23609
|
+
constructor(message, retryAfter, code = "rate_limit_exceeded") {
|
|
23610
|
+
super({ message, status: 429, code });
|
|
23123
23611
|
this.name = "ZyphrRateLimitError";
|
|
23124
23612
|
this.retryAfter = retryAfter;
|
|
23125
23613
|
}
|
|
23126
23614
|
};
|
|
23127
23615
|
var ZyphrNotFoundError = class extends ZyphrError {
|
|
23128
|
-
constructor(message) {
|
|
23129
|
-
super({ message, status: 404, code
|
|
23616
|
+
constructor(message, code = "not_found") {
|
|
23617
|
+
super({ message, status: 404, code });
|
|
23130
23618
|
this.name = "ZyphrNotFoundError";
|
|
23131
23619
|
}
|
|
23132
23620
|
};
|
|
23133
23621
|
var ZyphrPayloadTooLargeError = class extends ZyphrError {
|
|
23134
|
-
constructor(message, details, requestId) {
|
|
23135
|
-
super({ message, status: 413, code
|
|
23622
|
+
constructor(message, details, requestId, code = "payload_too_large") {
|
|
23623
|
+
super({ message, status: 413, code, details, requestId });
|
|
23136
23624
|
this.name = "ZyphrPayloadTooLargeError";
|
|
23137
23625
|
}
|
|
23138
23626
|
/** Maximum allowed request body size in bytes (server-enforced). */
|
|
@@ -23162,24 +23650,24 @@ async function parseErrorResponse(response) {
|
|
|
23162
23650
|
const error = body.error ?? {};
|
|
23163
23651
|
const meta = body.meta ?? {};
|
|
23164
23652
|
const message = error.message ?? response.statusText ?? "Unknown error";
|
|
23165
|
-
const code = error.code;
|
|
23653
|
+
const code = error.code || void 0;
|
|
23166
23654
|
const requestId = meta.request_id;
|
|
23167
23655
|
const details = error.details;
|
|
23168
23656
|
switch (response.status) {
|
|
23169
23657
|
case 400:
|
|
23170
23658
|
case 422:
|
|
23171
|
-
return new ZyphrValidationError(message, details);
|
|
23659
|
+
return new ZyphrValidationError(message, details, code);
|
|
23172
23660
|
case 401:
|
|
23173
23661
|
case 403:
|
|
23174
|
-
return new ZyphrAuthenticationError(message);
|
|
23662
|
+
return new ZyphrAuthenticationError(message, code);
|
|
23175
23663
|
case 404:
|
|
23176
|
-
return new ZyphrNotFoundError(message);
|
|
23664
|
+
return new ZyphrNotFoundError(message, code);
|
|
23177
23665
|
case 413:
|
|
23178
|
-
return new ZyphrPayloadTooLargeError(message, details, requestId);
|
|
23666
|
+
return new ZyphrPayloadTooLargeError(message, details, requestId, code);
|
|
23179
23667
|
case 429: {
|
|
23180
23668
|
const retryAfterHeader = response.headers.get("Retry-After");
|
|
23181
23669
|
const retryAfter = retryAfterHeader ? parseInt(retryAfterHeader, 10) : void 0;
|
|
23182
|
-
return new ZyphrRateLimitError(message, retryAfter);
|
|
23670
|
+
return new ZyphrRateLimitError(message, retryAfter, code);
|
|
23183
23671
|
}
|
|
23184
23672
|
default:
|
|
23185
23673
|
return new ZyphrError({ message, status: response.status, code, requestId, details });
|
|
@@ -23290,6 +23778,99 @@ var Zyphr = class {
|
|
|
23290
23778
|
}
|
|
23291
23779
|
};
|
|
23292
23780
|
|
|
23781
|
+
// src/clientAuth.ts
|
|
23782
|
+
var errorMiddleware2 = {
|
|
23783
|
+
async post(context) {
|
|
23784
|
+
if (context.response.status >= 200 && context.response.status < 300) {
|
|
23785
|
+
return;
|
|
23786
|
+
}
|
|
23787
|
+
throw await parseErrorResponse(context.response);
|
|
23788
|
+
}
|
|
23789
|
+
};
|
|
23790
|
+
var ZyphrClientCredentialError = class extends Error {
|
|
23791
|
+
constructor(message) {
|
|
23792
|
+
super(message);
|
|
23793
|
+
this.name = "ZyphrClientCredentialError";
|
|
23794
|
+
}
|
|
23795
|
+
};
|
|
23796
|
+
var SECRET_KEY_PREFIXES = ["za_sec_", "zy_live_", "zy_test_"];
|
|
23797
|
+
var ZyphrClient = class {
|
|
23798
|
+
auth;
|
|
23799
|
+
/** Device registration for push (takes an OS-acquired token). */
|
|
23800
|
+
devices;
|
|
23801
|
+
applicationKey;
|
|
23802
|
+
accessToken;
|
|
23803
|
+
constructor(options) {
|
|
23804
|
+
if (!options.applicationKey) {
|
|
23805
|
+
throw new ZyphrClientCredentialError("applicationKey (za_pub_*) is required");
|
|
23806
|
+
}
|
|
23807
|
+
if (SECRET_KEY_PREFIXES.some((p) => options.applicationKey.startsWith(p))) {
|
|
23808
|
+
throw new ZyphrClientCredentialError(
|
|
23809
|
+
"ZyphrClient must be constructed with a publishable application key (za_pub_*), never a secret key. Secret keys must stay server-side."
|
|
23810
|
+
);
|
|
23811
|
+
}
|
|
23812
|
+
if (!options.applicationKey.startsWith("za_pub_")) {
|
|
23813
|
+
throw new ZyphrClientCredentialError(
|
|
23814
|
+
"applicationKey must be a publishable application key (za_pub_*)."
|
|
23815
|
+
);
|
|
23816
|
+
}
|
|
23817
|
+
this.applicationKey = options.applicationKey;
|
|
23818
|
+
this.accessToken = options.accessToken;
|
|
23819
|
+
const config = new Configuration({
|
|
23820
|
+
basePath: options.baseUrl,
|
|
23821
|
+
// The only credential this client sends automatically is the publishable
|
|
23822
|
+
// application key. End-user Bearer tokens are attached per-request via
|
|
23823
|
+
// authedRequest() so token rotation doesn't require rebuilding the client.
|
|
23824
|
+
apiKey: (name) => name === "X-Application-Key" ? this.applicationKey : "",
|
|
23825
|
+
middleware: [errorMiddleware2]
|
|
23826
|
+
});
|
|
23827
|
+
this.auth = {
|
|
23828
|
+
login: new AuthLoginApi(config),
|
|
23829
|
+
registration: new AuthRegistrationApi(config),
|
|
23830
|
+
sessions: new AuthSessionsApi(config),
|
|
23831
|
+
emailVerification: new AuthEmailVerificationApi(config),
|
|
23832
|
+
passwordReset: new AuthPasswordResetApi(config),
|
|
23833
|
+
mfa: new AuthMFAApi(config),
|
|
23834
|
+
magicLinks: new AuthMagicLinksApi(config),
|
|
23835
|
+
oauth: new AuthOAuthApi(config),
|
|
23836
|
+
organizations: new AuthOrganizationsApi(config),
|
|
23837
|
+
phone: new AuthPhoneApi(config),
|
|
23838
|
+
emailOtp: new AuthEmailOTPApi(config),
|
|
23839
|
+
profile: new AuthUserProfileApi(config),
|
|
23840
|
+
webauthn: new AuthWebAuthnApi(config)
|
|
23841
|
+
};
|
|
23842
|
+
this.devices = new DevicesApi(config);
|
|
23843
|
+
}
|
|
23844
|
+
/** Store the end-user access token for subsequent authedRequest() calls. */
|
|
23845
|
+
setAccessToken(accessToken) {
|
|
23846
|
+
this.accessToken = accessToken;
|
|
23847
|
+
}
|
|
23848
|
+
/** True when an end-user access token is currently set. */
|
|
23849
|
+
get isAuthenticated() {
|
|
23850
|
+
return Boolean(this.accessToken);
|
|
23851
|
+
}
|
|
23852
|
+
/**
|
|
23853
|
+
* Build request overrides that authenticate as the current end user: the
|
|
23854
|
+
* stored Bearer token plus the publishable application key required by
|
|
23855
|
+
* user-scoped endpoints. Pass an explicit token to override the stored one.
|
|
23856
|
+
*
|
|
23857
|
+
* @example
|
|
23858
|
+
* ```ts
|
|
23859
|
+
* const me = await zyphr.auth.profile.getEndUser(zyphr.authedRequest());
|
|
23860
|
+
* ```
|
|
23861
|
+
*/
|
|
23862
|
+
authedRequest(accessToken) {
|
|
23863
|
+
const token = accessToken ?? this.accessToken;
|
|
23864
|
+
const headers = {
|
|
23865
|
+
"X-Application-Key": this.applicationKey
|
|
23866
|
+
};
|
|
23867
|
+
if (token) {
|
|
23868
|
+
headers.Authorization = `Bearer ${token}`;
|
|
23869
|
+
}
|
|
23870
|
+
return { headers };
|
|
23871
|
+
}
|
|
23872
|
+
};
|
|
23873
|
+
|
|
23293
23874
|
// src/index.ts
|
|
23294
23875
|
var SDK_VERSION = "0.1.0";
|
|
23295
23876
|
export {
|
|
@@ -23436,6 +24017,7 @@ export {
|
|
|
23436
24017
|
AuthTokensFromJSONTyped,
|
|
23437
24018
|
AuthTokensToJSON,
|
|
23438
24019
|
AuthTokensToJSONTyped,
|
|
24020
|
+
AuthUserDirectoryApi,
|
|
23439
24021
|
AuthUserFromJSON,
|
|
23440
24022
|
AuthUserFromJSONTyped,
|
|
23441
24023
|
AuthUserProfileApi,
|
|
@@ -23850,10 +24432,16 @@ export {
|
|
|
23850
24432
|
InboxNotificationResponseFromJSONTyped,
|
|
23851
24433
|
InboxNotificationResponseToJSON,
|
|
23852
24434
|
InboxNotificationResponseToJSONTyped,
|
|
24435
|
+
InviteEndUserRequestFromJSON,
|
|
24436
|
+
InviteEndUserRequestFromJSONTyped,
|
|
24437
|
+
InviteEndUserRequestSendLinkEnum,
|
|
24438
|
+
InviteEndUserRequestToJSON,
|
|
24439
|
+
InviteEndUserRequestToJSONTyped,
|
|
23853
24440
|
JSONApiResponse,
|
|
23854
24441
|
ListAllInboxStatusEnum,
|
|
23855
24442
|
ListDevicesPlatformEnum,
|
|
23856
24443
|
ListEmailsStatusEnum,
|
|
24444
|
+
ListEndUsersEnvironmentEnum,
|
|
23857
24445
|
ListInboundEmailsStatusEnum,
|
|
23858
24446
|
ListPushStatusEnum,
|
|
23859
24447
|
ListSlackMessagesStatusEnum,
|
|
@@ -24040,6 +24628,11 @@ export {
|
|
|
24040
24628
|
OAuthProviderInfoFromJSONTyped,
|
|
24041
24629
|
OAuthProviderInfoToJSON,
|
|
24042
24630
|
OAuthProviderInfoToJSONTyped,
|
|
24631
|
+
OAuthProviderName,
|
|
24632
|
+
OAuthProviderNameFromJSON,
|
|
24633
|
+
OAuthProviderNameFromJSONTyped,
|
|
24634
|
+
OAuthProviderNameToJSON,
|
|
24635
|
+
OAuthProviderNameToJSONTyped,
|
|
24043
24636
|
OAuthProviderToJSON,
|
|
24044
24637
|
OAuthProviderToJSONTyped,
|
|
24045
24638
|
OAuthProvidersResponseDataFromJSON,
|
|
@@ -24469,6 +25062,10 @@ export {
|
|
|
24469
25062
|
SetDomainInboundRequestFromJSONTyped,
|
|
24470
25063
|
SetDomainInboundRequestToJSON,
|
|
24471
25064
|
SetDomainInboundRequestToJSONTyped,
|
|
25065
|
+
SetEndUserClaimsRequestFromJSON,
|
|
25066
|
+
SetEndUserClaimsRequestFromJSONTyped,
|
|
25067
|
+
SetEndUserClaimsRequestToJSON,
|
|
25068
|
+
SetEndUserClaimsRequestToJSONTyped,
|
|
24472
25069
|
SetPreferencesRequestFromJSON,
|
|
24473
25070
|
SetPreferencesRequestFromJSONTyped,
|
|
24474
25071
|
SetPreferencesRequestPreferencesInnerFromJSON,
|
|
@@ -24481,6 +25078,10 @@ export {
|
|
|
24481
25078
|
SignInAnonymouslyRequestFromJSONTyped,
|
|
24482
25079
|
SignInAnonymouslyRequestToJSON,
|
|
24483
25080
|
SignInAnonymouslyRequestToJSONTyped,
|
|
25081
|
+
SignInWithGameCenterRequestFromJSON,
|
|
25082
|
+
SignInWithGameCenterRequestFromJSONTyped,
|
|
25083
|
+
SignInWithGameCenterRequestToJSON,
|
|
25084
|
+
SignInWithGameCenterRequestToJSONTyped,
|
|
24484
25085
|
SlackApi,
|
|
24485
25086
|
SlackMessageFromJSON,
|
|
24486
25087
|
SlackMessageFromJSONTyped,
|
|
@@ -24714,6 +25315,10 @@ export {
|
|
|
24714
25315
|
UpdateCategoryRequestFromJSONTyped,
|
|
24715
25316
|
UpdateCategoryRequestToJSON,
|
|
24716
25317
|
UpdateCategoryRequestToJSONTyped,
|
|
25318
|
+
UpdateEndUserByApplicationRequestFromJSON,
|
|
25319
|
+
UpdateEndUserByApplicationRequestFromJSONTyped,
|
|
25320
|
+
UpdateEndUserByApplicationRequestToJSON,
|
|
25321
|
+
UpdateEndUserByApplicationRequestToJSONTyped,
|
|
24717
25322
|
UpdateEndUserRequestFromJSON,
|
|
24718
25323
|
UpdateEndUserRequestFromJSONTyped,
|
|
24719
25324
|
UpdateEndUserRequestToJSON,
|
|
@@ -25131,6 +25736,8 @@ export {
|
|
|
25131
25736
|
WorkflowStepExecutionToJSONTyped,
|
|
25132
25737
|
Zyphr,
|
|
25133
25738
|
ZyphrAuthenticationError,
|
|
25739
|
+
ZyphrClient,
|
|
25740
|
+
ZyphrClientCredentialError,
|
|
25134
25741
|
ZyphrError,
|
|
25135
25742
|
ZyphrNotFoundError,
|
|
25136
25743
|
ZyphrPayloadTooLargeError,
|
|
@@ -25265,6 +25872,7 @@ export {
|
|
|
25265
25872
|
instanceOfInboxListMeta,
|
|
25266
25873
|
instanceOfInboxListResponse,
|
|
25267
25874
|
instanceOfInboxNotificationResponse,
|
|
25875
|
+
instanceOfInviteEndUserRequest,
|
|
25268
25876
|
instanceOfListWaaSApplications200Response,
|
|
25269
25877
|
instanceOfListWaaSEndpointDeliveries200Response,
|
|
25270
25878
|
instanceOfListWaaSEndpoints200Response,
|
|
@@ -25309,6 +25917,7 @@ export {
|
|
|
25309
25917
|
instanceOfOAuthConnectionsResponseData,
|
|
25310
25918
|
instanceOfOAuthProvider,
|
|
25311
25919
|
instanceOfOAuthProviderInfo,
|
|
25920
|
+
instanceOfOAuthProviderName,
|
|
25312
25921
|
instanceOfOAuthProvidersResponse,
|
|
25313
25922
|
instanceOfOAuthProvidersResponseData,
|
|
25314
25923
|
instanceOfOAuthTokensRefreshResponse,
|
|
@@ -25412,9 +26021,11 @@ export {
|
|
|
25412
26021
|
instanceOfSessionListResponseData,
|
|
25413
26022
|
instanceOfSessionListResponseDataSessionInfo,
|
|
25414
26023
|
instanceOfSetDomainInboundRequest,
|
|
26024
|
+
instanceOfSetEndUserClaimsRequest,
|
|
25415
26025
|
instanceOfSetPreferencesRequest,
|
|
25416
26026
|
instanceOfSetPreferencesRequestPreferencesInner,
|
|
25417
26027
|
instanceOfSignInAnonymouslyRequest,
|
|
26028
|
+
instanceOfSignInWithGameCenterRequest,
|
|
25418
26029
|
instanceOfSlackMessage,
|
|
25419
26030
|
instanceOfSlackMessageListResponse,
|
|
25420
26031
|
instanceOfSlackMessageListResponseMeta,
|
|
@@ -25470,6 +26081,7 @@ export {
|
|
|
25470
26081
|
instanceOfUnsubscribeRequest,
|
|
25471
26082
|
instanceOfUnsubscribeResponse,
|
|
25472
26083
|
instanceOfUpdateCategoryRequest,
|
|
26084
|
+
instanceOfUpdateEndUserByApplicationRequest,
|
|
25473
26085
|
instanceOfUpdateEndUserRequest,
|
|
25474
26086
|
instanceOfUpdateOrganizationMemberRoleRequest,
|
|
25475
26087
|
instanceOfUpdateOrganizationRequest,
|