From 260db313fd4224a5c1d96d6ca050178b62200ffc Mon Sep 17 00:00:00 2001 From: gllm-dev Date: Wed, 18 Dec 2024 14:25:36 +0100 Subject: [PATCH] feat: login as guest --- .../openapi-clients/src/backend-openapi.json | 250 +++++++++++++----- .../src/backend/.openapi-generator/FILES | 1 + .../src/backend/domain/authentication-api.ts | 86 ++++++ .../src/backend/domain/policies-api.ts | 47 ++-- .../models/authenticated-player-response.ts | 33 +++ .../backend/models/authorize200-response.ts | 14 +- .../backend/models/create-policy-request.ts | 6 + .../src/backend/models/index.ts | 1 + .../backend/models/policy-report-queries.ts | 19 +- .../src/backend/models/policy-response.ts | 6 + .../src/backend/models/policy.ts | 6 + .../transaction-intent-response-policy.ts | 6 + .../backend/models/update-policy-request.ts | 6 + sdk/package.json | 2 +- sdk/src/authManager.ts | 6 + sdk/src/openfort.ts | 15 ++ sdk/src/version.ts | 2 +- 17 files changed, 402 insertions(+), 104 deletions(-) create mode 100644 packages/internal/openapi-clients/src/backend/models/authenticated-player-response.ts diff --git a/packages/internal/openapi-clients/src/backend-openapi.json b/packages/internal/openapi-clients/src/backend-openapi.json index f294f80a..42aededb 100644 --- a/packages/internal/openapi-clients/src/backend-openapi.json +++ b/packages/internal/openapi-clients/src/backend-openapi.json @@ -978,25 +978,15 @@ "type": "object", "additionalProperties": false }, - "AuthResponse": { + "AuthenticatedPlayerResponse": { "properties": { "player": { "$ref": "#/components/schemas/AuthPlayerResponse", "description": "Player's identifier." - }, - "token": { - "type": "string", - "description": "JWT access token." - }, - "refreshToken": { - "type": "string", - "description": "Refresh token." } }, "required": [ - "player", - "token", - "refreshToken" + "player" ], "type": "object", "additionalProperties": false @@ -1768,6 +1758,29 @@ "$ref": "#/components/schemas/AuthConfig", "description": "Request for the configuration endpoints for the OAuth providers" }, + "AuthResponse": { + "properties": { + "player": { + "$ref": "#/components/schemas/AuthPlayerResponse", + "description": "Player's identifier." + }, + "token": { + "type": "string", + "description": "JWT access token." + }, + "refreshToken": { + "type": "string", + "description": "Refresh token." + } + }, + "required": [ + "player", + "token", + "refreshToken" + ], + "type": "object", + "additionalProperties": false + }, "OAuthConfigListResponse": { "description": "Response for the OAuth config list method.", "properties": { @@ -2704,6 +2717,9 @@ "paymaster": { "$ref": "#/components/schemas/EntityIdResponse" }, + "forwarderContract": { + "$ref": "#/components/schemas/EntityIdResponse" + }, "strategy": { "$ref": "#/components/schemas/PolicyStrategy" }, @@ -3572,6 +3588,34 @@ "type": "object", "additionalProperties": false }, + "PrivateKeyPolicy": { + "enum": [ + "INDIVIDUAL", + "PROJECT" + ], + "type": "string" + }, + "CreateProjectRequest": { + "properties": { + "name": { + "type": "string", + "description": "Name of the project.", + "example": "My Project", + "minLength": 1, + "maxLength": 256 + }, + "pkPolicy": { + "$ref": "#/components/schemas/PrivateKeyPolicy", + "description": "The private key policyfor the project.", + "example": "PROJECT" + } + }, + "required": [ + "name" + ], + "type": "object", + "additionalProperties": false + }, "CreateEcosystemConfigurationRequest": { "properties": { "customDomain": { @@ -4166,34 +4210,6 @@ "type": "object", "additionalProperties": false }, - "PrivateKeyPolicy": { - "enum": [ - "INDIVIDUAL", - "PROJECT" - ], - "type": "string" - }, - "CreateProjectRequest": { - "properties": { - "name": { - "type": "string", - "description": "Name of the project.", - "example": "My Project", - "minLength": 1, - "maxLength": 256 - }, - "pkPolicy": { - "$ref": "#/components/schemas/PrivateKeyPolicy", - "description": "The private key policyfor the project.", - "example": "PROJECT" - } - }, - "required": [ - "name" - ], - "type": "object", - "additionalProperties": false - }, "UpdateProjectRequest": { "properties": { "name": { @@ -6517,6 +6533,9 @@ "paymaster": { "$ref": "#/components/schemas/EntityIdResponse" }, + "forwarderContract": { + "$ref": "#/components/schemas/EntityIdResponse" + }, "strategy": { "$ref": "#/components/schemas/PolicyStrategy" }, @@ -6707,6 +6726,11 @@ "type": "string", "description": "The ID of the paymaster.", "example": "pay_6f6c9067-89fa-4fc8-ac72-c242a268c584" + }, + "forwarderContract": { + "type": "string", + "description": "The ID of the forwarder contract.", + "example": "cfo_f0f89cf2-c185-40f4-beef-2a250d7a472b" } }, "required": [ @@ -6739,6 +6763,11 @@ "description": "The ID of the paymaster.", "example": "pay_6f6c9067-89fa-4fc8-ac72-c242a268c584" }, + "forwarderContract": { + "type": "string", + "description": "The ID of the forwarder contract.", + "example": "cfo_f0f89cf2-c185-40f4-beef-2a250d7a472b" + }, "deleted": { "type": "boolean", "description": "Specifies whether to delete the policy.", @@ -6890,17 +6919,21 @@ }, "PolicyReportQueries": { "properties": { - "to": { - "type": "number", - "format": "double", - "description": "The start date of the period in unix timestamp.", - "example": 1612137600 + "limit": { + "type": "integer", + "format": "int32", + "description": "Specifies the maximum number of records to return.", + "minimum": 1 }, - "from": { - "type": "number", - "format": "double", - "description": "The end date of the period in unix timestamp.", - "example": 1612137600 + "skip": { + "type": "integer", + "format": "int32", + "description": "Specifies the offset for the first records to return.", + "minimum": 0 + }, + "order": { + "$ref": "#/components/schemas/SortOrder", + "description": "Specifies the order in which to sort the results." } }, "type": "object", @@ -8599,7 +8632,7 @@ "$ref": "#/components/schemas/AuthPlayerResponse" }, { - "$ref": "#/components/schemas/AuthResponse" + "$ref": "#/components/schemas/AuthenticatedPlayerResponse" } ] }, @@ -8999,6 +9032,69 @@ } } }, + "/iam/v1/guest": { + "post": { + "operationId": "RegisterGuest", + "responses": { + "201": { + "description": "Success response", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/AuthResponse" + }, + "examples": { + "Example 1": { + "value": { + "player": { + "id": "pla_...", + "object": "player", + "createdAt": 1234567890, + "linkedAccounts": [ + { + "provider": "email", + "email": "jaume@openfort.xyz", + "disabled": false + } + ] + }, + "token": "abcd....", + "refreshToken": "efgh...." + } + } + } + } + } + }, + "401": { + "description": "Api key is not valid" + }, + "409": { + "description": "User already exists" + } + }, + "description": "Create a guest player.", + "summary": "Create a guest player.", + "tags": [ + "Authentication" + ], + "security": [ + { + "pk": [] + } + ], + "parameters": [ + { + "in": "header", + "name": "x-game", + "required": false, + "schema": { + "type": "string" + } + } + ] + } + }, "/iam/v1/oauth": { "get": { "operationId": "ListOAuthConfig", @@ -10565,7 +10661,7 @@ "custodial": false, "embeddedSigner": false, "object": "account", - "accountType": "Upgradeable_v05", + "accountType": "Upgradeable_v06", "ownerAddress": "0x8C5cedA46A26214A52A9D7BF036Ad2F6255BdBEa", "player": { "id": "pla_c502d628-5bb3-42f2-b8d5-62ba46717f3a" @@ -10686,7 +10782,7 @@ "custodial": false, "embeddedSigner": false, "object": "account", - "accountType": "Upgradeable_v05", + "accountType": "Upgradeable_v06", "ownerAddress": "0x8C5cedA46A26214A52A9D7BF036Ad2F6255BdBEa", "player": { "id": "pla_c502d628-5bb3-42f2-b8d5-62ba46717f3a" @@ -10763,7 +10859,7 @@ "custodial": false, "embeddedSigner": false, "object": "account", - "accountType": "Upgradeable_v05", + "accountType": "Upgradeable_v06", "ownerAddress": "0x8C5cedA46A26214A52A9D7BF036Ad2F6255BdBEa", "player": { "id": "pla_c502d628-5bb3-42f2-b8d5-62ba46717f3a" @@ -11146,7 +11242,7 @@ "custodial": false, "embeddedSigner": false, "object": "account", - "accountType": "Upgradeable_v05", + "accountType": "Upgradeable_v06", "ownerAddress": "0x8C5cedA46A26214A52A9D7BF036Ad2F6255BdBEa", "player": { "id": "pla_c502d628-5bb3-42f2-b8d5-62ba46717f3a" @@ -11218,7 +11314,7 @@ "custodial": false, "embeddedSigner": false, "object": "account", - "accountType": "Upgradeable_v05", + "accountType": "Upgradeable_v06", "ownerAddress": "0x8C5cedA46A26214A52A9D7BF036Ad2F6255BdBEa", "player": { "id": "pla_c502d628-5bb3-42f2-b8d5-62ba46717f3a" @@ -15017,26 +15113,35 @@ "example": "pol_48eeba57-2cd5-4159-a2cb-057a23a35e65" }, { - "description": "The start date of the period in unix timestamp.", + "description": "Specifies the maximum number of records to return.", "in": "query", - "name": "to", + "name": "limit", "required": false, "schema": { - "format": "double", - "type": "number" - }, - "example": 1612137600 + "format": "int32", + "type": "integer", + "minimum": 1 + } }, { - "description": "The end date of the period in unix timestamp.", + "description": "Specifies the offset for the first records to return.", "in": "query", - "name": "from", + "name": "skip", "required": false, "schema": { - "format": "double", - "type": "number" - }, - "example": 1612137600 + "format": "int32", + "type": "integer", + "minimum": 0 + } + }, + { + "description": "Specifies the order in which to sort the results.", + "in": "query", + "name": "order", + "required": false, + "schema": { + "$ref": "#/components/schemas/SortOrder" + } } ] } @@ -17985,6 +18090,15 @@ }, { "user_project": [] + }, + { + "pk_third_party": [] + }, + { + "pk_access_token": [] + }, + { + "pk_identity_token": [] } ], "parameters": [ diff --git a/packages/internal/openapi-clients/src/backend/.openapi-generator/FILES b/packages/internal/openapi-clients/src/backend/.openapi-generator/FILES index 1c4fa213..a7bc0650 100644 --- a/packages/internal/openapi-clients/src/backend/.openapi-generator/FILES +++ b/packages/internal/openapi-clients/src/backend/.openapi-generator/FILES @@ -63,6 +63,7 @@ models/auth-provider.ts models/auth-response.ts models/auth-session-response.ts models/authenticate-oauth-request.ts +models/authenticated-player-response.ts models/authentication-type.ts models/authorize-player-request.ts models/authorize200-response.ts diff --git a/packages/internal/openapi-clients/src/backend/domain/authentication-api.ts b/packages/internal/openapi-clients/src/backend/domain/authentication-api.ts index 5f00bfc6..7cad7f25 100644 --- a/packages/internal/openapi-clients/src/backend/domain/authentication-api.ts +++ b/packages/internal/openapi-clients/src/backend/domain/authentication-api.ts @@ -727,6 +727,45 @@ export const AuthenticationApiAxiosParamCreator = function (configuration?: Conf options: localVarRequestOptions, }; }, + /** + * Create a guest player. + * @summary Create a guest player. + * @param {string} [xGame] + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + registerGuest: async (xGame?: string, options: AxiosRequestConfig = {}): Promise => { + const localVarPath = `/iam/v1/guest`; + // use dummy base URL string because the URL constructor only accepts absolute URLs. + const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL); + let baseOptions; + if (configuration) { + baseOptions = configuration.baseOptions; + } + + const localVarRequestOptions = { method: 'POST', ...baseOptions, ...options}; + const localVarHeaderParameter = {} as any; + const localVarQueryParameter = {} as any; + + // authentication pk required + // http bearer authentication required + await setBearerAuthToObject(localVarHeaderParameter, configuration) + + if (xGame != null) { + localVarHeaderParameter['x-game'] = String(xGame); + } + + + + setSearchParams(localVarUrlObj, localVarQueryParameter); + let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {}; + localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers}; + + return { + url: toPathString(localVarUrlObj), + options: localVarRequestOptions, + }; + }, /** * Start the Email Verification process for a player. * @summary Request an Email Verification. @@ -1362,6 +1401,17 @@ export const AuthenticationApiFp = function(configuration?: Configuration) { const localVarAxiosArgs = await localVarAxiosParamCreator.refresh(refreshTokenRequest, options); return createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration); }, + /** + * Create a guest player. + * @summary Create a guest player. + * @param {string} [xGame] + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + async registerGuest(xGame?: string, options?: AxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise> { + const localVarAxiosArgs = await localVarAxiosParamCreator.registerGuest(xGame, options); + return createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration); + }, /** * Start the Email Verification process for a player. * @summary Request an Email Verification. @@ -1655,6 +1705,16 @@ export const AuthenticationApiFactory = function (configuration?: Configuration, refresh(requestParameters: AuthenticationApiRefreshRequest, options?: AxiosRequestConfig): AxiosPromise { return localVarFp.refresh(requestParameters.refreshTokenRequest, options).then((request) => request(axios, basePath)); }, + /** + * Create a guest player. + * @summary Create a guest player. + * @param {AuthenticationApiRegisterGuestRequest} requestParameters Request parameters. + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + registerGuest(requestParameters: AuthenticationApiRegisterGuestRequest = {}, options?: AxiosRequestConfig): AxiosPromise { + return localVarFp.registerGuest(requestParameters.xGame, options).then((request) => request(axios, basePath)); + }, /** * Start the Email Verification process for a player. * @summary Request an Email Verification. @@ -2034,6 +2094,20 @@ export interface AuthenticationApiRefreshRequest { readonly refreshTokenRequest: RefreshTokenRequest } +/** + * Request parameters for registerGuest operation in AuthenticationApi. + * @export + * @interface AuthenticationApiRegisterGuestRequest + */ +export interface AuthenticationApiRegisterGuestRequest { + /** + * + * @type {string} + * @memberof AuthenticationApiRegisterGuest + */ + readonly xGame?: string +} + /** * Request parameters for requestEmailVerification operation in AuthenticationApi. * @export @@ -2407,6 +2481,18 @@ export class AuthenticationApi extends BaseAPI { return AuthenticationApiFp(this.configuration).refresh(requestParameters.refreshTokenRequest, options).then((request) => request(this.axios, this.basePath)); } + /** + * Create a guest player. + * @summary Create a guest player. + * @param {AuthenticationApiRegisterGuestRequest} requestParameters Request parameters. + * @param {*} [options] Override http request option. + * @throws {RequiredError} + * @memberof AuthenticationApi + */ + public registerGuest(requestParameters: AuthenticationApiRegisterGuestRequest = {}, options?: AxiosRequestConfig) { + return AuthenticationApiFp(this.configuration).registerGuest(requestParameters.xGame, options).then((request) => request(this.axios, this.basePath)); + } + /** * Start the Email Verification process for a player. * @summary Request an Email Verification. diff --git a/packages/internal/openapi-clients/src/backend/domain/policies-api.ts b/packages/internal/openapi-clients/src/backend/domain/policies-api.ts index 0957cf72..43103544 100644 --- a/packages/internal/openapi-clients/src/backend/domain/policies-api.ts +++ b/packages/internal/openapi-clients/src/backend/domain/policies-api.ts @@ -460,12 +460,13 @@ export const PoliciesApiAxiosParamCreator = function (configuration?: Configurat * * @summary List all gas reports of a policy. * @param {string} id Specifies the unique policy ID (starts with pol_). - * @param {number} [to] The start date of the period in unix timestamp. - * @param {number} [from] The end date of the period in unix timestamp. + * @param {number} [limit] Specifies the maximum number of records to return. + * @param {number} [skip] Specifies the offset for the first records to return. + * @param {SortOrder} [order] Specifies the order in which to sort the results. * @param {*} [options] Override http request option. * @throws {RequiredError} */ - getPolicyTotalGasUsage: async (id: string, to?: number, from?: number, options: AxiosRequestConfig = {}): Promise => { + getPolicyTotalGasUsage: async (id: string, limit?: number, skip?: number, order?: SortOrder, options: AxiosRequestConfig = {}): Promise => { // verify required parameter 'id' is not null or undefined assertParamExists('getPolicyTotalGasUsage', 'id', id) const localVarPath = `/v1/policies/{id}/reports` @@ -485,12 +486,16 @@ export const PoliciesApiAxiosParamCreator = function (configuration?: Configurat // http bearer authentication required await setBearerAuthToObject(localVarHeaderParameter, configuration) - if (to !== undefined) { - localVarQueryParameter['to'] = to; + if (limit !== undefined) { + localVarQueryParameter['limit'] = limit; } - if (from !== undefined) { - localVarQueryParameter['from'] = from; + if (skip !== undefined) { + localVarQueryParameter['skip'] = skip; + } + + if (order !== undefined) { + localVarQueryParameter['order'] = order; } @@ -672,13 +677,14 @@ export const PoliciesApiFp = function(configuration?: Configuration) { * * @summary List all gas reports of a policy. * @param {string} id Specifies the unique policy ID (starts with pol_). - * @param {number} [to] The start date of the period in unix timestamp. - * @param {number} [from] The end date of the period in unix timestamp. + * @param {number} [limit] Specifies the maximum number of records to return. + * @param {number} [skip] Specifies the offset for the first records to return. + * @param {SortOrder} [order] Specifies the order in which to sort the results. * @param {*} [options] Override http request option. * @throws {RequiredError} */ - async getPolicyTotalGasUsage(id: string, to?: number, from?: number, options?: AxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise> { - const localVarAxiosArgs = await localVarAxiosParamCreator.getPolicyTotalGasUsage(id, to, from, options); + async getPolicyTotalGasUsage(id: string, limit?: number, skip?: number, order?: SortOrder, options?: AxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise> { + const localVarAxiosArgs = await localVarAxiosParamCreator.getPolicyTotalGasUsage(id, limit, skip, order, options); return createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration); }, /** @@ -801,7 +807,7 @@ export const PoliciesApiFactory = function (configuration?: Configuration, baseP * @throws {RequiredError} */ getPolicyTotalGasUsage(requestParameters: PoliciesApiGetPolicyTotalGasUsageRequest, options?: AxiosRequestConfig): AxiosPromise { - return localVarFp.getPolicyTotalGasUsage(requestParameters.id, requestParameters.to, requestParameters.from, options).then((request) => request(axios, basePath)); + return localVarFp.getPolicyTotalGasUsage(requestParameters.id, requestParameters.limit, requestParameters.skip, requestParameters.order, options).then((request) => request(axios, basePath)); }, /** * @@ -1033,18 +1039,25 @@ export interface PoliciesApiGetPolicyTotalGasUsageRequest { readonly id: string /** - * The start date of the period in unix timestamp. + * Specifies the maximum number of records to return. * @type {number} * @memberof PoliciesApiGetPolicyTotalGasUsage */ - readonly to?: number + readonly limit?: number /** - * The end date of the period in unix timestamp. + * Specifies the offset for the first records to return. * @type {number} * @memberof PoliciesApiGetPolicyTotalGasUsage */ - readonly from?: number + readonly skip?: number + + /** + * Specifies the order in which to sort the results. + * @type {SortOrder} + * @memberof PoliciesApiGetPolicyTotalGasUsage + */ + readonly order?: SortOrder } /** @@ -1192,7 +1205,7 @@ export class PoliciesApi extends BaseAPI { * @memberof PoliciesApi */ public getPolicyTotalGasUsage(requestParameters: PoliciesApiGetPolicyTotalGasUsageRequest, options?: AxiosRequestConfig) { - return PoliciesApiFp(this.configuration).getPolicyTotalGasUsage(requestParameters.id, requestParameters.to, requestParameters.from, options).then((request) => request(this.axios, this.basePath)); + return PoliciesApiFp(this.configuration).getPolicyTotalGasUsage(requestParameters.id, requestParameters.limit, requestParameters.skip, requestParameters.order, options).then((request) => request(this.axios, this.basePath)); } /** diff --git a/packages/internal/openapi-clients/src/backend/models/authenticated-player-response.ts b/packages/internal/openapi-clients/src/backend/models/authenticated-player-response.ts new file mode 100644 index 00000000..b020f754 --- /dev/null +++ b/packages/internal/openapi-clients/src/backend/models/authenticated-player-response.ts @@ -0,0 +1,33 @@ +/* tslint:disable */ +/* eslint-disable */ +/** + * Openfort API + * Complete Openfort API references and guides can be found at: https://openfort.xyz/docs + * + * The version of the OpenAPI document: 1.0.0 + * Contact: founders@openfort.xyz + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +// May contain unused imports in some cases +// @ts-ignore +import { AuthPlayerResponse } from './auth-player-response'; + +/** + * + * @export + * @interface AuthenticatedPlayerResponse + */ +export interface AuthenticatedPlayerResponse { + /** + * + * @type {AuthPlayerResponse} + * @memberof AuthenticatedPlayerResponse + */ + 'player': AuthPlayerResponse; +} + diff --git a/packages/internal/openapi-clients/src/backend/models/authorize200-response.ts b/packages/internal/openapi-clients/src/backend/models/authorize200-response.ts index 55c597d5..a7dac1d0 100644 --- a/packages/internal/openapi-clients/src/backend/models/authorize200-response.ts +++ b/packages/internal/openapi-clients/src/backend/models/authorize200-response.ts @@ -18,7 +18,7 @@ import { AuthPlayerResponse } from './auth-player-response'; // May contain unused imports in some cases // @ts-ignore -import { AuthResponse } from './auth-response'; +import { AuthenticatedPlayerResponse } from './authenticated-player-response'; // May contain unused imports in some cases // @ts-ignore import { EntityTypePLAYER } from './entity-type-player'; @@ -62,18 +62,6 @@ export interface Authorize200Response { * @memberof Authorize200Response */ 'linkedAccounts': Array; - /** - * JWT access token. - * @type {string} - * @memberof Authorize200Response - */ - 'token': string; - /** - * Refresh token. - * @type {string} - * @memberof Authorize200Response - */ - 'refreshToken': string; } diff --git a/packages/internal/openapi-clients/src/backend/models/create-policy-request.ts b/packages/internal/openapi-clients/src/backend/models/create-policy-request.ts index c976ba82..7acf0ee1 100644 --- a/packages/internal/openapi-clients/src/backend/models/create-policy-request.ts +++ b/packages/internal/openapi-clients/src/backend/models/create-policy-request.ts @@ -47,5 +47,11 @@ export interface CreatePolicyRequest { * @memberof CreatePolicyRequest */ 'paymaster'?: string; + /** + * The ID of the forwarder contract. + * @type {string} + * @memberof CreatePolicyRequest + */ + 'forwarderContract'?: string; } diff --git a/packages/internal/openapi-clients/src/backend/models/index.ts b/packages/internal/openapi-clients/src/backend/models/index.ts index f13aa764..36322fe2 100644 --- a/packages/internal/openapi-clients/src/backend/models/index.ts +++ b/packages/internal/openapi-clients/src/backend/models/index.ts @@ -37,6 +37,7 @@ export * from './auth-provider-with-type-response'; export * from './auth-response'; export * from './auth-session-response'; export * from './authenticate-oauth-request'; +export * from './authenticated-player-response'; export * from './authentication-type'; export * from './authorize200-response'; export * from './authorize-player-request'; diff --git a/packages/internal/openapi-clients/src/backend/models/policy-report-queries.ts b/packages/internal/openapi-clients/src/backend/models/policy-report-queries.ts index d78c01df..80d4c440 100644 --- a/packages/internal/openapi-clients/src/backend/models/policy-report-queries.ts +++ b/packages/internal/openapi-clients/src/backend/models/policy-report-queries.ts @@ -13,6 +13,9 @@ */ +// May contain unused imports in some cases +// @ts-ignore +import { SortOrder } from './sort-order'; /** * @@ -21,16 +24,24 @@ */ export interface PolicyReportQueries { /** - * The start date of the period in unix timestamp. + * Specifies the maximum number of records to return. * @type {number} * @memberof PolicyReportQueries */ - 'to'?: number; + 'limit'?: number; /** - * The end date of the period in unix timestamp. + * Specifies the offset for the first records to return. * @type {number} * @memberof PolicyReportQueries */ - 'from'?: number; + 'skip'?: number; + /** + * + * @type {SortOrder} + * @memberof PolicyReportQueries + */ + 'order'?: SortOrder; } + + diff --git a/packages/internal/openapi-clients/src/backend/models/policy-response.ts b/packages/internal/openapi-clients/src/backend/models/policy-response.ts index 3908ce7a..2d5a718a 100644 --- a/packages/internal/openapi-clients/src/backend/models/policy-response.ts +++ b/packages/internal/openapi-clients/src/backend/models/policy-response.ts @@ -83,6 +83,12 @@ export interface PolicyResponse { * @memberof PolicyResponse */ 'paymaster'?: EntityIdResponse; + /** + * + * @type {EntityIdResponse} + * @memberof PolicyResponse + */ + 'forwarderContract'?: EntityIdResponse; /** * * @type {PolicyStrategy} diff --git a/packages/internal/openapi-clients/src/backend/models/policy.ts b/packages/internal/openapi-clients/src/backend/models/policy.ts index 6d731176..e0829f94 100644 --- a/packages/internal/openapi-clients/src/backend/models/policy.ts +++ b/packages/internal/openapi-clients/src/backend/models/policy.ts @@ -77,6 +77,12 @@ export interface Policy { * @memberof Policy */ 'paymaster'?: EntityIdResponse; + /** + * + * @type {EntityIdResponse} + * @memberof Policy + */ + 'forwarderContract'?: EntityIdResponse; /** * * @type {PolicyStrategy} diff --git a/packages/internal/openapi-clients/src/backend/models/transaction-intent-response-policy.ts b/packages/internal/openapi-clients/src/backend/models/transaction-intent-response-policy.ts index 2464101c..7047ea8e 100644 --- a/packages/internal/openapi-clients/src/backend/models/transaction-intent-response-policy.ts +++ b/packages/internal/openapi-clients/src/backend/models/transaction-intent-response-policy.ts @@ -80,6 +80,12 @@ export interface TransactionIntentResponsePolicy { * @memberof TransactionIntentResponsePolicy */ 'paymaster'?: EntityIdResponse; + /** + * + * @type {EntityIdResponse} + * @memberof TransactionIntentResponsePolicy + */ + 'forwarderContract'?: EntityIdResponse; /** * * @type {PolicyStrategy} diff --git a/packages/internal/openapi-clients/src/backend/models/update-policy-request.ts b/packages/internal/openapi-clients/src/backend/models/update-policy-request.ts index 48966dee..50a5602a 100644 --- a/packages/internal/openapi-clients/src/backend/models/update-policy-request.ts +++ b/packages/internal/openapi-clients/src/backend/models/update-policy-request.ts @@ -47,6 +47,12 @@ export interface UpdatePolicyRequest { * @memberof UpdatePolicyRequest */ 'paymaster'?: string; + /** + * The ID of the forwarder contract. + * @type {string} + * @memberof UpdatePolicyRequest + */ + 'forwarderContract'?: string; /** * Specifies whether to delete the policy. * @type {boolean} diff --git a/sdk/package.json b/sdk/package.json index 13433d89..cd9709e9 100644 --- a/sdk/package.json +++ b/sdk/package.json @@ -1,6 +1,6 @@ { "name": "@openfort/openfort-js", - "version": "0.8.13", + "version": "0.8.14", "author": "Openfort (https://www.openfort.xyz)", "bugs": "https://github.com/openfort-xyz/openfort-js/issues", "repository": "openfort-xyz/openfort-js.git", diff --git a/sdk/src/authManager.ts b/sdk/src/authManager.ts index 04882daa..f50ec2da 100644 --- a/sdk/src/authManager.ts +++ b/sdk/src/authManager.ts @@ -77,6 +77,12 @@ export default class AuthManager { }; } + public async registerGuest(): Promise { + const request = {}; + const response = await this.backendApiClients.authenticationApi.registerGuest(request); + return response.data; + } + public async poolOAuth( key: string, ): Promise { diff --git a/sdk/src/openfort.ts b/sdk/src/openfort.ts index d3ee37ac..e96b24c5 100644 --- a/sdk/src/openfort.ts +++ b/sdk/src/openfort.ts @@ -271,6 +271,21 @@ export class Openfort { return result; } + /** + * Registers a new guest user. + * + * @returns An AuthResponse object containing authentication details. + */ + public async registerGuest(): Promise { + const previousAuth = Authentication.fromStorage(this.storage); + const result = await this.authManager.registerGuest(); + if (previousAuth && previousAuth.player !== result.player.id) { + this.logout(); + } + new Authentication('jwt', result.token, result.player.id, result.refreshToken).save(this.storage); + return result; + } + /** * Signs up a new user with email and password. * diff --git a/sdk/src/version.ts b/sdk/src/version.ts index 742df8bd..18d8f780 100644 --- a/sdk/src/version.ts +++ b/sdk/src/version.ts @@ -1,2 +1,2 @@ -export const VERSION = '0.8.12'; +export const VERSION = '0.8.14'; export const PACKAGE = '@openfort/openfort-js';