Skip to content

Commit

Permalink
Merge pull request #337 from tonkeeper/feature/2fa
Browse files Browse the repository at this point in the history
Two FA
  • Loading branch information
KuznetsovNikita authored Jan 2, 2025
2 parents 5373eb3 + 580f1c9 commit 7fbaac8
Show file tree
Hide file tree
Showing 130 changed files with 6,192 additions and 580 deletions.
1 change: 1 addition & 0 deletions packages/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
"generate:tonConsoleApi": "rm -r ./src/tonConsoleApi || true && npx openapi-typescript-codegen --input 'https://raw.githubusercontent.com/tonkeeper/tonconsole_backend/refs/heads/main/swagger.yaml?token=GHSAT0AAAAAACJYQUOCGQXJBM2BFNOB6XREZ2ZZZCA' --output ./src/tonConsoleApi",
"generate:swapsApi": "rm -r ./src/swapsApi || true && npx openapi-typescript-codegen --input 'https://raw.githubusercontent.com/tonkeeper/swaps-backend/master/swagger.yaml?token=GHSAT0AAAAAACJYQUODBKR67AB7WULZBFWEZSUUGFQ' --output ./src/swapsApi",
"generate:batteryApi": "rm -fr ./src/batteryApi && docker build -f resource/Dockerfile.batteryApi . -t batteryapi && docker run --rm --user=$(id -u):$(id -g) -v \"$PWD\":/local batteryapi",
"generate:2faApi": "rm -fr src/2faApi && docker build -f resource/Dockerfile.2faApi . -t 2faapi && docker run --rm --user=$(id -u):$(id -g) -v \"$PWD\":/local 2faapi",
"build:pkg": "yarn build"
},
"devDependencies": {
Expand Down
3 changes: 3 additions & 0 deletions packages/core/resource/Dockerfile.2faApi
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
FROM openapitools/openapi-generator-cli

CMD ["generate", "-i", "https://raw.githubusercontent.com/tonkeeper/tonkeeper_2fa_backend/refs/heads/main/swagger.yaml?token=GHSAT0AAAAAACJYQUOCG3M3IRKQM3KPJSAUZ3MA5IA", "-g", "typescript-fetch", "-o", "/local/src/2faApi", "-p", "supportsES6=true,withInterfaces=true", "--openapi-normalizer", "KEEP_ONLY_FIRST_TAG_IN_OPERATION=true"]
2 changes: 1 addition & 1 deletion packages/core/resource/Dockerfile.apiV2
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
FROM openapitools/openapi-generator-cli

CMD ["generate", "-i", "https://raw.githubusercontent.com/tonkeeper/opentonapi/master/api/openapi.yml", "-g", "typescript-fetch", "-o", "/local/src/tonApiV2", "-p", "supportsES6=true,withInterfaces=true", "--openapi-normalizer", "KEEP_ONLY_FIRST_TAG_IN_OPERATION=true"]
CMD ["generate", "-i", "https://raw.githubusercontent.com/tonkeeper/opentonapi/master/api/openapi.yml", "-g", "typescript-fetch", "-o", "/local/src/tonApiV2", "-p", "supportsES6=true,withInterfaces=true", "--openapi-normalizer", "KEEP_ONLY_FIRST_TAG_IN_OPERATION=true", "--skip-validate-spec"]
23 changes: 23 additions & 0 deletions packages/core/src/2faApi/.openapi-generator-ignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# OpenAPI Generator Ignore
# Generated by openapi-generator https://github.com/openapitools/openapi-generator

# Use this file to prevent files from being overwritten by the generator.
# The patterns follow closely to .gitignore or .dockerignore.

# As an example, the C# client generator defines ApiClient.cs.
# You can make changes and tell OpenAPI Generator to ignore just this file by uncommenting the following line:
#ApiClient.cs

# You can match any string of characters against a directory, file or extension with a single asterisk (*):
#foo/*/qux
# The above matches foo/bar/qux and foo/baz/qux, but not foo/bar/baz/qux

# You can recursively match patterns against a directory, file or extension with a double asterisk (**):
#foo/**/qux
# This matches foo/bar/qux, foo/baz/qux, and foo/bar/baz/qux

# You can also negate patterns with an exclamation (!).
# For example, you can ignore all files in a docs folder with the file extension .md:
#docs/*.md
# Then explicitly reverse the ignore rule for a single file:
#!docs/README.md
21 changes: 21 additions & 0 deletions packages/core/src/2faApi/.openapi-generator/FILES
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
.openapi-generator-ignore
apis/AuthApi.ts
apis/MessageApi.ts
apis/SystemApi.ts
apis/index.ts
index.ts
models/ConnectRequest.ts
models/ErrorCode.ts
models/ExistsExtensionRequest.ts
models/Message.ts
models/MessageID.ts
models/MessageState.ts
models/ModelError.ts
models/Ok.ts
models/Payload.ts
models/PingReadyGet500Response.ts
models/Proof.ts
models/RemoveExtensionRequest.ts
models/Url.ts
models/index.ts
runtime.ts
1 change: 1 addition & 0 deletions packages/core/src/2faApi/.openapi-generator/VERSION
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
7.10.0-SNAPSHOT
292 changes: 292 additions & 0 deletions packages/core/src/2faApi/apis/AuthApi.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,292 @@
/* tslint:disable */
/* eslint-disable */
/**
* REST API
* No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
*
* The version of the OpenAPI document: 0.0.1
* Contact: [email protected]
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
* Do not edit the class manually.
*/


import * as runtime from '../runtime';
import type {
ConnectRequest,
ExistsExtensionRequest,
MessageID,
Ok,
Payload,
PingReadyGet500Response,
RemoveExtensionRequest,
Url,
} from '../models/index';
import {
ConnectRequestFromJSON,
ConnectRequestToJSON,
ExistsExtensionRequestFromJSON,
ExistsExtensionRequestToJSON,
MessageIDFromJSON,
MessageIDToJSON,
OkFromJSON,
OkToJSON,
PayloadFromJSON,
PayloadToJSON,
PingReadyGet500ResponseFromJSON,
PingReadyGet500ResponseToJSON,
RemoveExtensionRequestFromJSON,
RemoveExtensionRequestToJSON,
UrlFromJSON,
UrlToJSON,
} from '../models/index';

export interface ConnectOperationRequest {
connectRequest?: ConnectRequest;
}

export interface ExistsExtensionOperationRequest {
existsExtensionRequest?: ExistsExtensionRequest;
}

export interface ReConnectRequest {
connectRequest?: ConnectRequest;
}

export interface RemoveExtensionOperationRequest {
removeExtensionRequest?: RemoveExtensionRequest;
}

/**
* AuthApi - interface
*
* @export
* @interface AuthApiInterface
*/
export interface AuthApiInterface {
/**
*
* @summary Receive a deep link for the Telegram bot
* @param {ConnectRequest} [connectRequest] Data that is expected
* @param {*} [options] Override http request option.
* @throws {RequiredError}
* @memberof AuthApiInterface
*/
connectRaw(requestParameters: ConnectOperationRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<Url>>;

/**
* Receive a deep link for the Telegram bot
*/
connect(requestParameters: ConnectOperationRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<Url>;

/**
*
* @summary Verify if a wallet is linked to a Telegram bot
* @param {ExistsExtensionRequest} [existsExtensionRequest] Data that is expected
* @param {*} [options] Override http request option.
* @throws {RequiredError}
* @memberof AuthApiInterface
*/
existsExtensionRaw(requestParameters: ExistsExtensionOperationRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<Ok>>;

/**
* Verify if a wallet is linked to a Telegram bot
*/
existsExtension(requestParameters: ExistsExtensionOperationRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<Ok>;

/**
*
* @summary Retrieve the payload
* @param {*} [options] Override http request option.
* @throws {RequiredError}
* @memberof AuthApiInterface
*/
getPayloadRaw(initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<Payload>>;

/**
* Retrieve the payload
*/
getPayload(initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<Payload>;

/**
*
* @summary Relink your account with the Telegram bot
* @param {ConnectRequest} [connectRequest] Data that is expected
* @param {*} [options] Override http request option.
* @throws {RequiredError}
* @memberof AuthApiInterface
*/
reConnectRaw(requestParameters: ReConnectRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<Url>>;

/**
* Relink your account with the Telegram bot
*/
reConnect(requestParameters: ReConnectRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<Url>;

/**
*
* @summary Disable 2FA for the wallet
* @param {RemoveExtensionRequest} [removeExtensionRequest] Data that is expected
* @param {*} [options] Override http request option.
* @throws {RequiredError}
* @memberof AuthApiInterface
*/
removeExtensionRaw(requestParameters: RemoveExtensionOperationRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<MessageID>>;

/**
* Disable 2FA for the wallet
*/
removeExtension(requestParameters: RemoveExtensionOperationRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<MessageID>;

}

/**
*
*/
export class AuthApi extends runtime.BaseAPI implements AuthApiInterface {

/**
* Receive a deep link for the Telegram bot
*/
async connectRaw(requestParameters: ConnectOperationRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<Url>> {
const queryParameters: any = {};

const headerParameters: runtime.HTTPHeaders = {};

headerParameters['Content-Type'] = 'application/json';

const response = await this.request({
path: `/api/v1/connect`,
method: 'POST',
headers: headerParameters,
query: queryParameters,
body: ConnectRequestToJSON(requestParameters['connectRequest']),
}, initOverrides);

return new runtime.JSONApiResponse(response, (jsonValue) => UrlFromJSON(jsonValue));
}

/**
* Receive a deep link for the Telegram bot
*/
async connect(requestParameters: ConnectOperationRequest = {}, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<Url> {
const response = await this.connectRaw(requestParameters, initOverrides);
return await response.value();
}

/**
* Verify if a wallet is linked to a Telegram bot
*/
async existsExtensionRaw(requestParameters: ExistsExtensionOperationRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<Ok>> {
const queryParameters: any = {};

const headerParameters: runtime.HTTPHeaders = {};

headerParameters['Content-Type'] = 'application/json';

const response = await this.request({
path: `/api/v1/exists`,
method: 'POST',
headers: headerParameters,
query: queryParameters,
body: ExistsExtensionRequestToJSON(requestParameters['existsExtensionRequest']),
}, initOverrides);

return new runtime.JSONApiResponse(response, (jsonValue) => OkFromJSON(jsonValue));
}

/**
* Verify if a wallet is linked to a Telegram bot
*/
async existsExtension(requestParameters: ExistsExtensionOperationRequest = {}, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<Ok> {
const response = await this.existsExtensionRaw(requestParameters, initOverrides);
return await response.value();
}

/**
* Retrieve the payload
*/
async getPayloadRaw(initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<Payload>> {
const queryParameters: any = {};

const headerParameters: runtime.HTTPHeaders = {};

const response = await this.request({
path: `/api/v1/payload`,
method: 'GET',
headers: headerParameters,
query: queryParameters,
}, initOverrides);

return new runtime.JSONApiResponse(response, (jsonValue) => PayloadFromJSON(jsonValue));
}

/**
* Retrieve the payload
*/
async getPayload(initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<Payload> {
const response = await this.getPayloadRaw(initOverrides);
return await response.value();
}

/**
* Relink your account with the Telegram bot
*/
async reConnectRaw(requestParameters: ReConnectRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<Url>> {
const queryParameters: any = {};

const headerParameters: runtime.HTTPHeaders = {};

headerParameters['Content-Type'] = 'application/json';

const response = await this.request({
path: `/api/v1/reconnect`,
method: 'POST',
headers: headerParameters,
query: queryParameters,
body: ConnectRequestToJSON(requestParameters['connectRequest']),
}, initOverrides);

return new runtime.JSONApiResponse(response, (jsonValue) => UrlFromJSON(jsonValue));
}

/**
* Relink your account with the Telegram bot
*/
async reConnect(requestParameters: ReConnectRequest = {}, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<Url> {
const response = await this.reConnectRaw(requestParameters, initOverrides);
return await response.value();
}

/**
* Disable 2FA for the wallet
*/
async removeExtensionRaw(requestParameters: RemoveExtensionOperationRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<MessageID>> {
const queryParameters: any = {};

const headerParameters: runtime.HTTPHeaders = {};

headerParameters['Content-Type'] = 'application/json';

const response = await this.request({
path: `/api/v1/remove`,
method: 'POST',
headers: headerParameters,
query: queryParameters,
body: RemoveExtensionRequestToJSON(requestParameters['removeExtensionRequest']),
}, initOverrides);

return new runtime.JSONApiResponse(response, (jsonValue) => MessageIDFromJSON(jsonValue));
}

/**
* Disable 2FA for the wallet
*/
async removeExtension(requestParameters: RemoveExtensionOperationRequest = {}, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<MessageID> {
const response = await this.removeExtensionRaw(requestParameters, initOverrides);
return await response.value();
}

}
Loading

0 comments on commit 7fbaac8

Please sign in to comment.