@zyphr-dev/node-sdk 0.1.37 → 0.1.39

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.
@@ -20,6 +20,8 @@ import type {
20
20
  ConvertAnonymousUserRequest,
21
21
  RegisterRequest,
22
22
  SignInAnonymouslyRequest,
23
+ SignInWithGameCenterRequest,
24
+ SignInWithGooglePlayGamesRequest,
23
25
  } from '../models/index';
24
26
  import {
25
27
  ApiErrorFromJSON,
@@ -32,6 +34,10 @@ import {
32
34
  RegisterRequestToJSON,
33
35
  SignInAnonymouslyRequestFromJSON,
34
36
  SignInAnonymouslyRequestToJSON,
37
+ SignInWithGameCenterRequestFromJSON,
38
+ SignInWithGameCenterRequestToJSON,
39
+ SignInWithGooglePlayGamesRequestFromJSON,
40
+ SignInWithGooglePlayGamesRequestToJSON,
35
41
  } from '../models/index';
36
42
 
37
43
  export interface AuthRegistrationApiConvertAnonymousUserOperationRequest {
@@ -46,6 +52,14 @@ export interface AuthRegistrationApiSignInAnonymouslyOperationRequest {
46
52
  signInAnonymouslyRequest: SignInAnonymouslyRequest;
47
53
  }
48
54
 
55
+ export interface AuthRegistrationApiSignInWithGameCenterOperationRequest {
56
+ signInWithGameCenterRequest: SignInWithGameCenterRequest;
57
+ }
58
+
59
+ export interface AuthRegistrationApiSignInWithGooglePlayGamesOperationRequest {
60
+ signInWithGooglePlayGamesRequest: SignInWithGooglePlayGamesRequest;
61
+ }
62
+
49
63
  /**
50
64
  * AuthRegistrationApi - interface
51
65
  *
@@ -86,7 +100,7 @@ export interface AuthRegistrationApiInterface {
86
100
  registerEndUser(registerRequest: RegisterRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<AuthResultResponse>;
87
101
 
88
102
  /**
89
- * 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.
103
+ * 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.
90
104
  * @summary Sign in anonymously
91
105
  * @param {SignInAnonymouslyRequest} signInAnonymouslyRequest
92
106
  * @param {*} [options] Override http request option.
@@ -96,11 +110,43 @@ export interface AuthRegistrationApiInterface {
96
110
  signInAnonymouslyRaw(requestParameters: AuthRegistrationApiSignInAnonymouslyOperationRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<AuthResultResponse>>;
97
111
 
98
112
  /**
99
- * 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.
113
+ * 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.
100
114
  * Sign in anonymously
101
115
  */
102
116
  signInAnonymously(signInAnonymouslyRequest: SignInAnonymouslyRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<AuthResultResponse>;
103
117
 
118
+ /**
119
+ * 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.
120
+ * @summary Sign in with Apple Game Center
121
+ * @param {SignInWithGameCenterRequest} signInWithGameCenterRequest
122
+ * @param {*} [options] Override http request option.
123
+ * @throws {RequiredError}
124
+ * @memberof AuthRegistrationApiInterface
125
+ */
126
+ signInWithGameCenterRaw(requestParameters: AuthRegistrationApiSignInWithGameCenterOperationRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<AuthResultResponse>>;
127
+
128
+ /**
129
+ * 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.
130
+ * Sign in with Apple Game Center
131
+ */
132
+ signInWithGameCenter(signInWithGameCenterRequest: SignInWithGameCenterRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<AuthResultResponse>;
133
+
134
+ /**
135
+ * Exchange a Google Play Games Services (GPGS) **server auth code** for a Zyphr end-user session. Unlike Game Center (which submits an Apple-signed assertion), GPGS is verified by Google: Zyphr exchanges the single-use server auth code at Google\'s OAuth2 token endpoint, then calls the Play Games REST API (`players/me`) server-side to obtain the trusted, tamper-proof `playerId`. The user is provisioned-or-looked-up on that server-fetched `playerId` and tokens are minted. ## Producing the server auth code (Integration) The server auth code is obtained **on-device by the Android app** — there is no server-side way to mint it. The app calls `GamesSignInClient.requestServerSideAccess(serverClientId, …)` using the Google Cloud **web (server) client id** configured for the game, which returns a single-use auth code string. Submit that string here as `serverAuthCode`. The **backend-relayed** shape is the common one: the app forwards the auth code to the customer\'s own backend, which relays it to this endpoint; the app never holds Zyphr keys. ## Security The `playerId` is derived **only** from Zyphr\'s own server-side call to Google after the token exchange — a client-supplied player id is never accepted or trusted. On any verification failure the response is a single opaque `401` `invalid_auth_code`; the specific control that failed is never disclosed.
136
+ * @summary Sign in with Google Play Games Services
137
+ * @param {SignInWithGooglePlayGamesRequest} signInWithGooglePlayGamesRequest
138
+ * @param {*} [options] Override http request option.
139
+ * @throws {RequiredError}
140
+ * @memberof AuthRegistrationApiInterface
141
+ */
142
+ signInWithGooglePlayGamesRaw(requestParameters: AuthRegistrationApiSignInWithGooglePlayGamesOperationRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<AuthResultResponse>>;
143
+
144
+ /**
145
+ * Exchange a Google Play Games Services (GPGS) **server auth code** for a Zyphr end-user session. Unlike Game Center (which submits an Apple-signed assertion), GPGS is verified by Google: Zyphr exchanges the single-use server auth code at Google\'s OAuth2 token endpoint, then calls the Play Games REST API (`players/me`) server-side to obtain the trusted, tamper-proof `playerId`. The user is provisioned-or-looked-up on that server-fetched `playerId` and tokens are minted. ## Producing the server auth code (Integration) The server auth code is obtained **on-device by the Android app** — there is no server-side way to mint it. The app calls `GamesSignInClient.requestServerSideAccess(serverClientId, …)` using the Google Cloud **web (server) client id** configured for the game, which returns a single-use auth code string. Submit that string here as `serverAuthCode`. The **backend-relayed** shape is the common one: the app forwards the auth code to the customer\'s own backend, which relays it to this endpoint; the app never holds Zyphr keys. ## Security The `playerId` is derived **only** from Zyphr\'s own server-side call to Google after the token exchange — a client-supplied player id is never accepted or trusted. On any verification failure the response is a single opaque `401` `invalid_auth_code`; the specific control that failed is never disclosed.
146
+ * Sign in with Google Play Games Services
147
+ */
148
+ signInWithGooglePlayGames(signInWithGooglePlayGamesRequest: SignInWithGooglePlayGamesRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<AuthResultResponse>;
149
+
104
150
  }
105
151
 
106
152
  /**
@@ -193,7 +239,7 @@ export class AuthRegistrationApi extends runtime.BaseAPI implements AuthRegistra
193
239
  }
194
240
 
195
241
  /**
196
- * 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.
242
+ * 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.
197
243
  * Sign in anonymously
198
244
  */
199
245
  async signInAnonymouslyRaw(requestParameters: AuthRegistrationApiSignInAnonymouslyOperationRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<AuthResultResponse>> {
@@ -226,7 +272,7 @@ export class AuthRegistrationApi extends runtime.BaseAPI implements AuthRegistra
226
272
  }
227
273
 
228
274
  /**
229
- * 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.
275
+ * 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.
230
276
  * Sign in anonymously
231
277
  */
232
278
  async signInAnonymously(signInAnonymouslyRequest: SignInAnonymouslyRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<AuthResultResponse> {
@@ -234,4 +280,88 @@ export class AuthRegistrationApi extends runtime.BaseAPI implements AuthRegistra
234
280
  return await response.value();
235
281
  }
236
282
 
283
+ /**
284
+ * 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.
285
+ * Sign in with Apple Game Center
286
+ */
287
+ async signInWithGameCenterRaw(requestParameters: AuthRegistrationApiSignInWithGameCenterOperationRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<AuthResultResponse>> {
288
+ if (requestParameters['signInWithGameCenterRequest'] == null) {
289
+ throw new runtime.RequiredError(
290
+ 'signInWithGameCenterRequest',
291
+ 'Required parameter "signInWithGameCenterRequest" was null or undefined when calling signInWithGameCenter().'
292
+ );
293
+ }
294
+
295
+ const queryParameters: any = {};
296
+
297
+ const headerParameters: runtime.HTTPHeaders = {};
298
+
299
+ headerParameters['Content-Type'] = 'application/json';
300
+
301
+ if (this.configuration && this.configuration.apiKey) {
302
+ headerParameters["X-Application-Key"] = await this.configuration.apiKey("X-Application-Key"); // ApplicationPublicKey authentication
303
+ }
304
+
305
+ const response = await this.request({
306
+ path: `/auth/game-center`,
307
+ method: 'POST',
308
+ headers: headerParameters,
309
+ query: queryParameters,
310
+ body: SignInWithGameCenterRequestToJSON(requestParameters['signInWithGameCenterRequest']),
311
+ }, initOverrides);
312
+
313
+ return new runtime.JSONApiResponse(response, (jsonValue) => AuthResultResponseFromJSON(jsonValue));
314
+ }
315
+
316
+ /**
317
+ * 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.
318
+ * Sign in with Apple Game Center
319
+ */
320
+ async signInWithGameCenter(signInWithGameCenterRequest: SignInWithGameCenterRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<AuthResultResponse> {
321
+ const response = await this.signInWithGameCenterRaw({ signInWithGameCenterRequest: signInWithGameCenterRequest }, initOverrides);
322
+ return await response.value();
323
+ }
324
+
325
+ /**
326
+ * Exchange a Google Play Games Services (GPGS) **server auth code** for a Zyphr end-user session. Unlike Game Center (which submits an Apple-signed assertion), GPGS is verified by Google: Zyphr exchanges the single-use server auth code at Google\'s OAuth2 token endpoint, then calls the Play Games REST API (`players/me`) server-side to obtain the trusted, tamper-proof `playerId`. The user is provisioned-or-looked-up on that server-fetched `playerId` and tokens are minted. ## Producing the server auth code (Integration) The server auth code is obtained **on-device by the Android app** — there is no server-side way to mint it. The app calls `GamesSignInClient.requestServerSideAccess(serverClientId, …)` using the Google Cloud **web (server) client id** configured for the game, which returns a single-use auth code string. Submit that string here as `serverAuthCode`. The **backend-relayed** shape is the common one: the app forwards the auth code to the customer\'s own backend, which relays it to this endpoint; the app never holds Zyphr keys. ## Security The `playerId` is derived **only** from Zyphr\'s own server-side call to Google after the token exchange — a client-supplied player id is never accepted or trusted. On any verification failure the response is a single opaque `401` `invalid_auth_code`; the specific control that failed is never disclosed.
327
+ * Sign in with Google Play Games Services
328
+ */
329
+ async signInWithGooglePlayGamesRaw(requestParameters: AuthRegistrationApiSignInWithGooglePlayGamesOperationRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<AuthResultResponse>> {
330
+ if (requestParameters['signInWithGooglePlayGamesRequest'] == null) {
331
+ throw new runtime.RequiredError(
332
+ 'signInWithGooglePlayGamesRequest',
333
+ 'Required parameter "signInWithGooglePlayGamesRequest" was null or undefined when calling signInWithGooglePlayGames().'
334
+ );
335
+ }
336
+
337
+ const queryParameters: any = {};
338
+
339
+ const headerParameters: runtime.HTTPHeaders = {};
340
+
341
+ headerParameters['Content-Type'] = 'application/json';
342
+
343
+ if (this.configuration && this.configuration.apiKey) {
344
+ headerParameters["X-Application-Key"] = await this.configuration.apiKey("X-Application-Key"); // ApplicationPublicKey authentication
345
+ }
346
+
347
+ const response = await this.request({
348
+ path: `/auth/google-play-games`,
349
+ method: 'POST',
350
+ headers: headerParameters,
351
+ query: queryParameters,
352
+ body: SignInWithGooglePlayGamesRequestToJSON(requestParameters['signInWithGooglePlayGamesRequest']),
353
+ }, initOverrides);
354
+
355
+ return new runtime.JSONApiResponse(response, (jsonValue) => AuthResultResponseFromJSON(jsonValue));
356
+ }
357
+
358
+ /**
359
+ * Exchange a Google Play Games Services (GPGS) **server auth code** for a Zyphr end-user session. Unlike Game Center (which submits an Apple-signed assertion), GPGS is verified by Google: Zyphr exchanges the single-use server auth code at Google\'s OAuth2 token endpoint, then calls the Play Games REST API (`players/me`) server-side to obtain the trusted, tamper-proof `playerId`. The user is provisioned-or-looked-up on that server-fetched `playerId` and tokens are minted. ## Producing the server auth code (Integration) The server auth code is obtained **on-device by the Android app** — there is no server-side way to mint it. The app calls `GamesSignInClient.requestServerSideAccess(serverClientId, …)` using the Google Cloud **web (server) client id** configured for the game, which returns a single-use auth code string. Submit that string here as `serverAuthCode`. The **backend-relayed** shape is the common one: the app forwards the auth code to the customer\'s own backend, which relays it to this endpoint; the app never holds Zyphr keys. ## Security The `playerId` is derived **only** from Zyphr\'s own server-side call to Google after the token exchange — a client-supplied player id is never accepted or trusted. On any verification failure the response is a single opaque `401` `invalid_auth_code`; the specific control that failed is never disclosed.
360
+ * Sign in with Google Play Games Services
361
+ */
362
+ async signInWithGooglePlayGames(signInWithGooglePlayGamesRequest: SignInWithGooglePlayGamesRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<AuthResultResponse> {
363
+ const response = await this.signInWithGooglePlayGamesRaw({ signInWithGooglePlayGamesRequest: signInWithGooglePlayGamesRequest }, initOverrides);
364
+ return await response.value();
365
+ }
366
+
237
367
  }