@reyaxyz/api-sdk 0.127.3 → 0.127.4

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.
Files changed (31) hide show
  1. package/README.md +1 -1
  2. package/dist/clients/api-client.js +16 -8
  3. package/dist/clients/api-client.js.map +1 -1
  4. package/dist/clients/modules/auth/index.js +31 -9
  5. package/dist/clients/modules/auth/index.js.map +1 -1
  6. package/dist/clients/modules/auth/types.js.map +1 -1
  7. package/dist/types/clients/api-client.d.ts +10 -0
  8. package/dist/types/clients/api-client.d.ts.map +1 -1
  9. package/dist/types/clients/modules/auth/index.d.ts +4 -3
  10. package/dist/types/clients/modules/auth/index.d.ts.map +1 -1
  11. package/dist/types/clients/modules/auth/types.d.ts +2 -0
  12. package/dist/types/clients/modules/auth/types.d.ts.map +1 -1
  13. package/package.json +2 -3
  14. package/src/clients/api-client.ts +6 -11
  15. package/src/clients/modules/auth/index.ts +27 -10
  16. package/src/clients/modules/auth/types.ts +2 -0
  17. package/dist/clients/modules/auth/authenticate.js +0 -73
  18. package/dist/clients/modules/auth/authenticate.js.map +0 -1
  19. package/dist/clients/modules/auth/checkSupport.js +0 -5
  20. package/dist/clients/modules/auth/checkSupport.js.map +0 -1
  21. package/dist/clients/modules/auth/register.js +0 -93
  22. package/dist/clients/modules/auth/register.js.map +0 -1
  23. package/dist/types/clients/modules/auth/authenticate.d.ts +0 -2
  24. package/dist/types/clients/modules/auth/authenticate.d.ts.map +0 -1
  25. package/dist/types/clients/modules/auth/checkSupport.d.ts +0 -1
  26. package/dist/types/clients/modules/auth/checkSupport.d.ts.map +0 -1
  27. package/dist/types/clients/modules/auth/register.d.ts +0 -4
  28. package/dist/types/clients/modules/auth/register.d.ts.map +0 -1
  29. package/src/clients/modules/auth/authenticate.ts +0 -22
  30. package/src/clients/modules/auth/checkSupport.ts +0 -3
  31. package/src/clients/modules/auth/register.ts +0 -51
package/README.md CHANGED
@@ -6,5 +6,5 @@
6
6
 
7
7
  | Statements | Branches | Functions | Lines |
8
8
  | --------------------------- | ----------------------- | ------------------------- | ----------------- |
9
- | ![Statements](https://img.shields.io/badge/statements-1.37%25-red.svg?style=flat) | ![Branches](https://img.shields.io/badge/branches-7.37%25-red.svg?style=flat) | ![Functions](https://img.shields.io/badge/functions-0.55%25-red.svg?style=flat) | ![Lines](https://img.shields.io/badge/lines-1.38%25-red.svg?style=flat) |
9
+ | ![Statements](https://img.shields.io/badge/statements-1.4%25-red.svg?style=flat) | ![Branches](https://img.shields.io/badge/branches-7.37%25-red.svg?style=flat) | ![Functions](https://img.shields.io/badge/functions-0.55%25-red.svg?style=flat) | ![Lines](https://img.shields.io/badge/lines-1.41%25-red.svg?style=flat) |
10
10
 
@@ -25,12 +25,11 @@ var isolated_order_simulation_1 = __importDefault(require("./modules/isolated-or
25
25
  var conditional_orders_1 = __importDefault(require("./modules/conditional-orders"));
26
26
  var lottery_1 = __importDefault(require("./modules/lottery"));
27
27
  var referral_1 = __importDefault(require("./modules/referral"));
28
- // import AuthClient from './modules/auth';
28
+ var auth_1 = __importDefault(require("./modules/auth"));
29
29
  /**
30
30
  * @description Client for API
31
31
  */
32
32
  var ApiClient = /** @class */ (function () {
33
- // private readonly _auth?: AuthClient;
34
33
  function ApiClient() {
35
34
  this._markets = new markets_1.default(ApiClient.config.apiEndpoint);
36
35
  this._account = new account_1.default(ApiClient.config.apiEndpoint);
@@ -54,12 +53,7 @@ var ApiClient = /** @class */ (function () {
54
53
  this._conditionalOrders = new conditional_orders_1.default(ApiClient.network, ApiClient.config.apiEndpoint);
55
54
  this._lottery = new lottery_1.default(ApiClient.config.environment, ApiClient.config.apiEndpoint);
56
55
  this._referral = new referral_1.default(ApiClient.config.apiEndpoint);
57
- // if (typeof window !== 'undefined') {
58
- // this._auth = new AuthClient(
59
- // ApiClient.network,
60
- // ApiClient.config.apiEndpoint,
61
- // );
62
- // }
56
+ this._auth = new auth_1.default(ApiClient.config.apiEndpoint);
63
57
  }
64
58
  ApiClient.configure = function (environment) {
65
59
  ApiClient.config =
@@ -424,6 +418,20 @@ var ApiClient = /** @class */ (function () {
424
418
  enumerable: false,
425
419
  configurable: true
426
420
  });
421
+ Object.defineProperty(ApiClient, "auth", {
422
+ /**
423
+ * Gets the current instance of the AuthClient from the ApiClient.
424
+ *
425
+ * This static getter allows access to the AuthClient instance managed within the ApiClient's singleton instance. It is a convenience method for retrieving the AuthClient directly, bypassing the need to manually access the internal `_auth` property of the ApiClient instance.
426
+ *
427
+ * @returns {AuthClient} The AuthClient instance currently held by the ApiClient.
428
+ */
429
+ get: function () {
430
+ return ApiClient.getInstance()._auth;
431
+ },
432
+ enumerable: false,
433
+ configurable: true
434
+ });
427
435
  ApiClient.config = common_1.API_CLIENT_CONFIGS['test'];
428
436
  return ApiClient;
429
437
  }());
@@ -1 +1 @@
1
- {"version":3,"file":"api-client.js","sourceRoot":"/","sources":["clients/api-client.ts"],"names":[],"mappings":";;;;;;AAAA,0CAIyB;AACzB,8DAA8C;AAC9C,8DAA8C;AAC9C,gFAA+D;AAC/D,oDAAoC;AACpC,4DAA4C;AAC5C,0DAA0C;AAC1C,oGAAkF;AAClF,4GAAyF;AACzF,kGAA+E;AAC/E,8GAA2F;AAC3F,4FAA0E;AAC1E,gHAA6F;AAC7F,4HAAwG;AACxG,sGAAmF;AACnF,4FAA0E;AAC1E,wEAAuD;AACvD,kGAAgF;AAChF,oFAAmE;AACnE,8DAA8C;AAC9C,gEAAgD;AAChD,2CAA2C;AAE3C;;GAEG;AACH;IAuBE,uCAAuC;IAEvC;QACE,IAAI,CAAC,QAAQ,GAAG,IAAI,iBAAa,CAAC,SAAS,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC;QAChE,IAAI,CAAC,QAAQ,GAAG,IAAI,iBAAa,CAAC,SAAS,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC;QAChE,IAAI,CAAC,GAAG,GAAG,IAAI,YAAQ,CAAC,SAAS,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC;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S,CAAC;QAC3C,CAAC;;;OAAA;IA5Yc,gBAAM,GAAkB,2BAAkB,CAAC,MAAM,CAAC,CAAC;IAuZpE,gBAAC;CAAA,AAzZD,IAyZC;AAzZY,8BAAS","sourcesContent":["import {\n API_CLIENT_CONFIGS,\n ServiceConfig,\n ReyaChainId,\n} from '@reyaxyz/common';\nimport MarketsClient from './modules/markets';\nimport AccountClient from './modules/account';\nimport TradeSimulationClient from './modules/trade.simulation';\nimport LpClient from './modules/lp';\nimport TokensClient from './modules/tokens';\nimport OwnerClient from './modules/owner';\nimport EditCollateralSimulationClient from './modules/edit-collateral.simulation';\nimport DepositExistingMASimulationClient from './modules/deposit-existing-MA.simulation';\nimport DepositNewMASimulationClient from './modules/deposit-new-MA.simulation';\nimport DepositPassivePoolSimulationClient from './modules/deposit-passive-pool.simulation';\nimport WithdrawMASimulationClient from './modules/withdraw-MA.simulation';\nimport WithdrawPassivePoolSimulationClient from './modules/withdraw-passive-pool.simulation';\nimport TransferMarginBetweenMAsSimulationClient from './modules/transfer-margin-between-MAs.simulation';\nimport TransferMAPoolSimulationClient from './modules/transfer-MA-Pool.simulation';\nimport DepthChartSimulationClient from './modules/depth-chart.simulation';\nimport FundingRateClient from './modules/funding-rate';\nimport IsolatedOrderSimulationClient from './modules/isolated-order.simulation';\nimport ConditionalOrdersClient from './modules/conditional-orders';\nimport LotteryClient from './modules/lottery';\nimport ReferralClient from './modules/referral';\n// import AuthClient from './modules/auth';\n\n/**\n * @description Client for API\n */\nexport class ApiClient {\n private static instance: ApiClient;\n private static config: ServiceConfig = API_CLIENT_CONFIGS['test'];\n private readonly _markets: MarketsClient;\n private readonly _account: AccountClient;\n private readonly _lp: LpClient;\n private readonly _tradeSimulation: TradeSimulationClient;\n private readonly _fundingRateHistory: FundingRateClient;\n private readonly _editCollateralSimulation: EditCollateralSimulationClient;\n private readonly _depositExistingMASimulation: DepositExistingMASimulationClient;\n private readonly _depositNewMASimulation: DepositNewMASimulationClient;\n private readonly _depositPassivePoolSimulation: DepositPassivePoolSimulationClient;\n private readonly _withdrawMASimulation: WithdrawMASimulationClient;\n private readonly _withdrawPassivePoolSimulation: WithdrawPassivePoolSimulationClient;\n private readonly _transferMarginBetweenMAsSimulation: TransferMarginBetweenMAsSimulationClient;\n private readonly _transferMAPoolSimulation: TransferMAPoolSimulationClient;\n private readonly _depthSimulation: DepthChartSimulationClient;\n private readonly _isolatedOrderSimulation: IsolatedOrderSimulationClient;\n private readonly _tokens: TokensClient;\n private readonly _owner: OwnerClient;\n private readonly _conditionalOrders: ConditionalOrdersClient;\n private readonly _lottery: LotteryClient;\n private readonly _referral: ReferralClient;\n // private readonly _auth?: AuthClient;\n\n private constructor() {\n this._markets = new MarketsClient(ApiClient.config.apiEndpoint);\n this._account = new AccountClient(ApiClient.config.apiEndpoint);\n this._lp = new LpClient(ApiClient.config.apiEndpoint);\n this._tradeSimulation = new TradeSimulationClient(this._account);\n this._isolatedOrderSimulation = new IsolatedOrderSimulationClient(\n this._account,\n );\n this._fundingRateHistory = new FundingRateClient(this._markets);\n this._editCollateralSimulation = new EditCollateralSimulationClient(\n ApiClient.network,\n this._account,\n );\n this._depositExistingMASimulation = new DepositExistingMASimulationClient(\n this._editCollateralSimulation,\n ApiClient.config.apiEndpoint,\n );\n this._depositNewMASimulation = new DepositNewMASimulationClient(\n this._depositExistingMASimulation,\n );\n this._depositPassivePoolSimulation = new DepositPassivePoolSimulationClient(\n ApiClient.config.apiEndpoint,\n );\n this._withdrawMASimulation = new WithdrawMASimulationClient(\n this._editCollateralSimulation,\n ApiClient.config.chain,\n ApiClient.config.apiEndpoint,\n );\n this._withdrawPassivePoolSimulation =\n new WithdrawPassivePoolSimulationClient(\n ApiClient.config.chain,\n ApiClient.config.apiEndpoint,\n );\n this._transferMarginBetweenMAsSimulation =\n new TransferMarginBetweenMAsSimulationClient(\n ApiClient.network,\n this._account,\n );\n this._transferMAPoolSimulation = new TransferMAPoolSimulationClient(\n this._editCollateralSimulation,\n );\n\n this._depthSimulation = new DepthChartSimulationClient(this._lp);\n this._tokens = new TokensClient(ApiClient.config.apiEndpoint);\n this._owner = new OwnerClient(ApiClient.config.apiEndpoint);\n this._conditionalOrders = new ConditionalOrdersClient(\n ApiClient.network,\n ApiClient.config.apiEndpoint,\n );\n this._lottery = new LotteryClient(\n ApiClient.config.environment,\n ApiClient.config.apiEndpoint,\n );\n this._referral = new ReferralClient(ApiClient.config.apiEndpoint);\n\n // if (typeof window !== 'undefined') {\n // this._auth = new AuthClient(\n // ApiClient.network,\n // ApiClient.config.apiEndpoint,\n // );\n // }\n }\n\n public static configure(environment: ServiceConfig['environment']): void {\n ApiClient.config =\n API_CLIENT_CONFIGS[environment] || API_CLIENT_CONFIGS['test'];\n ApiClient.instance = new ApiClient();\n }\n\n private static getInstance(): ApiClient {\n if (!ApiClient.instance) {\n throw new Error(\n 'ApiClient is not configured. Please configure it before using.',\n );\n }\n return ApiClient.instance;\n }\n public static get network(): ReyaChainId {\n if (!ApiClient.config.chain) {\n throw new Error('ApiClient is not configured');\n }\n return ApiClient.config.chain;\n }\n\n /**\n * Provides access to the MarketsClient instance.\n * This getter allows for interacting with market-related API functionalities.\n *\n * @returns {MarketsClient} An instance of MarketsClient for market-related operations.\n * @memberof ApiClient\n */\n public static get markets(): MarketsClient {\n return ApiClient.getInstance()._markets;\n }\n\n /**\n * Provides access to the AccountClient instance.\n * This getter allows for interacting with account-related API functionalities.\n *\n * @returns {AccountClient} An instance of AccountClient for account-related operations.\n * @memberof ApiClient\n */\n public static get account(): AccountClient {\n return ApiClient.getInstance()._account;\n }\n\n /**\n * Provides access to the TradeSimulationClient instance.\n * This getter allows for interacting with trade simulation functionalities.\n * It ensures a singleton pattern by fetching the instance from the ApiClient's\n * private `_tradeSimulation` property, ensuring that trade simulation operations\n * use a consistent client configuration and state.\n *\n * @returns {TradeSimulationClient} An instance of TradeSimulationClient for trade simulation operations.\n * @memberof ApiClient\n * @example\n * // Access the trade simulation client from the ApiClient\n * const tradeSimulationClient = ApiClient.tradeSimulation;\n */\n\n public static get tradeSimulation(): TradeSimulationClient {\n return ApiClient.getInstance()._tradeSimulation;\n }\n\n /**\n * Provides access to the IsolatedOrderSimulationClient instance.\n * This getter allows for interacting with isolatedTrade simulation functionalities.\n * It ensures a singleton pattern by fetching the instance from the ApiClient's\n * private `_isolatedTradeSimulation` property, ensuring that isolatedTrade simulation operations\n * use a consistent client configuration and state.\n *\n * @returns {IsolatedOrderSimulationClient} An instance of IsolatedOrderSimulationClient for isolatedTrade simulation operations.\n * @memberof ApiClient\n * @example\n * // Access the isolatedTrade simulation client from the ApiClient\n * const isolatedTradeSimulationClient = ApiClient.isolatedTradeSimulation;\n */\n public static get isolatedSimulation(): IsolatedOrderSimulationClient {\n return ApiClient.getInstance()._isolatedOrderSimulation;\n }\n\n public static get fundingRateHistory(): FundingRateClient {\n return ApiClient.getInstance()._fundingRateHistory;\n }\n\n /**\n * Retrieves the DepthChartSimulationClient instance used for depth simulation.\n * This method provides access to the depth simulation client through the ApiClient.\n * @returns {DepthChartSimulationClient} The DepthChartSimulationClient instance.\n * @static\n * @public\n */\n public static get depthSimulation(): DepthChartSimulationClient {\n return ApiClient.getInstance()._depthSimulation;\n }\n\n /**\n * Provides access to the EditCollateralSimulationClient instance.\n * This getter allows for interacting with edit collateral simulation functionalities.\n * It ensures a singleton pattern by fetching the instance from the ApiClient's\n * private `_editCollateralSimulation` property, ensuring that edit collateral simulation operations\n * use a consistent client configuration and state.\n *\n * @returns {EditCollateralSimulationClient} An instance of EditCollateralSimulationClient for edit collateral simulation operations.\n * @memberof ApiClient\n * @example\n * // Access the edit collateral simulation client from the ApiClient\n * const editCollateralSimulationClient = ApiClient.editCollateralSimulation;\n */\n\n public static get editCollateralSimulationClient(): EditCollateralSimulationClient {\n return ApiClient.getInstance()._editCollateralSimulation;\n }\n\n /**\n * Provides access to the DepositExistingMASimulationClient instance.\n * This getter allows for interacting with trade simulation functionalities.\n * It ensures a singleton pattern by fetching the instance from the ApiClient's\n * private `_depositExistingMASimulation` property, ensuring that trade simulation operations\n * use a consistent client configuration and state.\n *\n * @returns {DepositExistingMASimulationClient} An instance of DepositExistingMASimulationClient for trade simulation operations.\n * @memberof ApiClient\n * @example\n * // Access the deposit existing Ma simulation client from the ApiClient\n * const depositExistingMASimulationClient = ApiClient.depositExistingMASimulation;\n */\n\n public static get depositExistingMASimulation(): DepositExistingMASimulationClient {\n return ApiClient.getInstance()._depositExistingMASimulation;\n }\n\n /**\n * Provides access to the DepositNewMASimulationClient instance.\n * This getter allows for interacting with trade simulation functionalities.\n * It ensures a singleton pattern by fetching the instance from the ApiClient's\n * private `_depositNewMASimulation` property, ensuring that trade simulation operations\n * use a consistent client configuration and state.\n *\n * @returns {DepositNewMASimulationClient} An instance of DepositNewMASimulationClient for trade simulation operations.\n * @memberof ApiClient\n * @example\n * // Access the deposit new MA simulation client from the ApiClient\n * const depositNewMASimulationClient = ApiClient.depositNewMASimulation;\n */\n\n public static get depositNewMASimulation(): DepositNewMASimulationClient {\n return ApiClient.getInstance()._depositNewMASimulation;\n }\n\n /**\n * Provides access to the DepositPassivePoolSimulationClient instance.\n * This getter allows for interacting with trade simulation functionalities.\n * It ensures a singleton pattern by fetching the instance from the ApiClient's\n * private `_depositPassivePoolSimulation` property, ensuring that trade simulation operations\n * use a consistent client configuration and state.\n *\n * @returns {DepositPassivePoolSimulationClient} An instance of DepositPassivePoolSimulationClient for trade simulation operations.\n * @memberof ApiClient\n * @example\n * // Access the deposit existing Ma simulation client from the ApiClient\n * const depositPassivePoolSimulationClient = ApiClient.depositPassivePoolSimulation;\n */\n\n public static get depositPassivePoolSimulation(): DepositPassivePoolSimulationClient {\n return ApiClient.getInstance()._depositPassivePoolSimulation;\n }\n\n /**\n * Provides access to the WithdrawMASimulationClient instance.\n * This getter allows for interacting with trade simulation functionalities.\n * It ensures a singleton pattern by fetching the instance from the ApiClient's\n * private `_withdrawMASimulation` property, ensuring that trade simulation operations\n * use a consistent client configuration and state.\n *\n * @returns {WithdrawMASimulationClient} An instance of WithdrawMASimulationClient for trade simulation operations.\n * @memberof ApiClient\n * @example\n * // Access the withdraw MA simulation client from the ApiClient\n * const withdrawMASimulationClient = ApiClient.withdrawMASimulation;\n */\n\n public static get withdrawMASimulation(): WithdrawMASimulationClient {\n return ApiClient.getInstance()._withdrawMASimulation;\n }\n\n /**\n * Provides access to the WithdrawPassivePoolSimulationClient instance.\n * This getter allows for interacting with trade simulation functionalities.\n * It ensures a singleton pattern by fetching the instance from the ApiClient's\n * private `_withdrawPassivePoolSimulation` property, ensuring that trade simulation operations\n * use a consistent client configuration and state.\n *\n * @returns {WithdrawPassivePoolSimulationClient} An instance of WithdrawPassivePoolSimulationClient for trade simulation operations.\n * @memberof ApiClient\n * @example\n * // Access the withdraw MA simulation client from the ApiClient\n * const withdrawPassivePoolSimulationClient = ApiClient.withdrawPassivePoolSimulation;\n */\n\n public static get withdrawPassivePoolSimulation(): WithdrawPassivePoolSimulationClient {\n return ApiClient.getInstance()._withdrawPassivePoolSimulation;\n }\n\n /**\n * Provides access to the TransferMarginBetweenMAsSimulationClient instance.\n * This getter allows for interacting with trade simulation functionalities.\n * It ensures a singleton pattern by fetching the instance from the ApiClient's\n * private `_transferMarginBetweenMAsSimulation` property, ensuring that trade simulation operations\n * use a consistent client configuration and state.\n *\n * @returns {TransferMarginBetweenMAsSimulationClient} An instance of TransferMarginBetweenMAsSimulationClient for trade simulation operations.\n * @memberof ApiClient\n * @example\n * // Access the transfer margin between MAs simulation client from the ApiClient\n * const transferMarginBetweenMAsSimulationClient = ApiClient.transferMarginBetweenMAsSimulation;\n */\n\n public static get transferMarginBetweenMAsSimulation(): TransferMarginBetweenMAsSimulationClient {\n return ApiClient.getInstance()._transferMarginBetweenMAsSimulation;\n }\n\n /**\n * Provides access to the TransferMAPoolSimulationClient instance.\n * This getter allows for interacting with trade simulation functionalities.\n * It ensures a singleton pattern by fetching the instance from the ApiClient's\n * private `_TransferMAPoolSimulation` property, ensuring that trade simulation operations\n * use a consistent client configuration and state.\n *\n * @returns {TransferMAPoolSimulationClient} An instance of TransferMAPoolSimulationClient for trade simulation operations.\n * @memberof ApiClient\n * @example\n * // Access the transfer from MA to Pool simulation client from the ApiClient\n * const transferMAPoolSimulationClient = ApiClient.transferMAPoolSimulation;\n */\n\n public static get transferMAPoolSimulation(): TransferMAPoolSimulationClient {\n return ApiClient.getInstance()._transferMAPoolSimulation;\n }\n\n /**\n * Gets the current instance of the LpClient from the ApiClient.\n *\n * This static getter allows access to the LpClient instance managed within the ApiClient's singleton instance. It is a convenience method for retrieving the LpClient directly, bypassing the need to manually access the internal `_lp` property of the ApiClient instance.\n *\n * @returns {LpClient} The LpClient instance currently held by the ApiClient.\n * @example\n * // Assuming ApiClient and LpClient are properly set up\n * const lpClient = ApiClient.lp;\n */\n public static get lp(): LpClient {\n return ApiClient.getInstance()._lp;\n }\n\n /**\n * Gets the current instance of the TokensClient from the ApiClient.\n *\n * This static getter allows access to the TokensClient instance managed within the ApiClient's singleton instance. It is a convenience method for retrieving the TokensClient directly, bypassing the need to manually access the internal `_tokens` property of the ApiClient instance.\n *\n * @returns {TokensClient} The TokensClient instance currently held by the ApiClient.\n * @example\n * // Assuming ApiClient and TokensClient are properly set up\n * const tokensClient = ApiClient.tokens;\n */\n public static get tokens(): TokensClient {\n return ApiClient.getInstance()._tokens;\n }\n\n /**\n * Gets the current instance of the OwnerClient from the ApiClient.\n *\n * This static getter allows access to the OwnerClient instance managed within the ApiClient's singleton instance. It is a convenience method for retrieving the OwnerClient directly, bypassing the need to manually access the internal `_owner` property of the ApiClient instance.\n *\n * @returns {OwnerClient} The OwnerClient instance currently held by the ApiClient.\n * @example\n * // Assuming ApiClient and OwnerClient are properly set up\n * const ownerClient = ApiClient.tokens;\n */\n public static get owner(): OwnerClient {\n return ApiClient.getInstance()._owner;\n }\n\n /**\n * Gets the current instance of the ConditionalOrdersClient from the ApiClient.\n *\n * This static getter allows access to the ConditionalOrdersClient instance managed within the ApiClient's singleton instance. It is a convenience method for retrieving the ConditionalOrdersClient directly, bypassing the need to manually access the internal `_conditionalOrders` property of the ApiClient instance.\n *\n * @returns {ConditionalOrdersClient} The ConditionalOrdersClient instance currently held by the ApiClient.\n */\n public static get conditionalOrders(): ConditionalOrdersClient {\n return ApiClient.getInstance()._conditionalOrders;\n }\n\n /**\n * Gets the current instance of the LotteryClient from the ApiClient.\n *\n * This static getter allows access to the LotteryClient instance managed within the ApiClient's singleton instance. It is a convenience method for retrieving the LotteryClient directly, bypassing the need to manually access the internal `_lottery` property of the ApiClient instance.\n *\n * @returns {LotteryClient} The LotteryClient instance currently held by the ApiClient.\n */\n public static get lottery(): LotteryClient {\n return ApiClient.getInstance()._lottery;\n }\n\n /**\n * Gets the current instance of the ReferralClient from the ApiClient.\n *\n * This static getter allows access to the ReferralClient instance managed within the ApiClient's singleton instance. It is a convenience method for retrieving the ReferralClient directly, bypassing the need to manually access the internal `_referral` property of the ApiClient instance.\n *\n * @returns {ReferralClient} The ReferralClient instance currently held by the ApiClient.\n */\n public static get referral(): ReferralClient {\n return ApiClient.getInstance()._referral;\n }\n /**\n * Gets the current instance of the AuthClient from the ApiClient.\n *\n * This static getter allows access to the AuthClient instance managed within the ApiClient's singleton instance. It is a convenience method for retrieving the AuthClient directly, bypassing the need to manually access the internal `_auth` property of the ApiClient instance.\n *\n * @returns {AuthClient} The AuthClient instance currently held by the ApiClient.\n */\n // public static get auth(): AuthClient {\n // return ApiClient.getInstance()._auth;\n // }\n}\n"]}
1
+ {"version":3,"file":"api-client.js","sourceRoot":"/","sources":["clients/api-client.ts"],"names":[],"mappings":";;;;;;AAAA,0CAIyB;AACzB,8DAA8C;AAC9C,8DAA8C;AAC9C,gFAA+D;AAC/D,oDAAoC;AACpC,4DAA4C;AAC5C,0DAA0C;AAC1C,oGAAkF;AAClF,4GAAyF;AACzF,kGAA+E;AAC/E,8GAA2F;AAC3F,4FAA0E;AAC1E,gHAA6F;AAC7F,4HAAwG;AACxG,sGAAmF;AACnF,4FAA0E;AAC1E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,SAAS,CAAC,WAAW,EAAE,CAAC,MAAM,CAAC;QACxC,CAAC;;;OAAA;IASD,sBAAkB,8BAAiB;QAPnC;;;;;;WAMG;aACH;YACE,OAAO,SAAS,CAAC,WAAW,EAAE,CAAC,kBAAkB,CAAC;QACpD,CAAC;;;OAAA;IASD,sBAAkB,oBAAO;QAPzB;;;;;;WAMG;aACH;YACE,OAAO,SAAS,CAAC,WAAW,EAAE,CAAC,QAAQ,CAAC;QAC1C,CAAC;;;OAAA;IASD,sBAAkB,qBAAQ;QAP1B;;;;;;WAMG;aACH;YACE,OAAO,SAAS,CAAC,WAAW,EAAE,CAAC,SAAS,CAAC;QAC3C,CAAC;;;OAAA;IAQD,sBAAkB,iBAAI;QAPtB;;;;;;WAMG;aACH;YACE,OAAO,SAAS,CAAC,WAAW,EAAE,CAAC,KAAK,CAAC;QACvC,CAAC;;;OAAA;IAjZc,gBAAM,GAAkB,2BAAkB,CAAC,MAAM,CAAC,CAAC;IAkZpE,gBAAC;CAAA,AApZD,IAoZC;AApZY,8BAAS","sourcesContent":["import {\n API_CLIENT_CONFIGS,\n ServiceConfig,\n ReyaChainId,\n} from '@reyaxyz/common';\nimport MarketsClient from './modules/markets';\nimport AccountClient from './modules/account';\nimport TradeSimulationClient from './modules/trade.simulation';\nimport LpClient from './modules/lp';\nimport TokensClient from './modules/tokens';\nimport OwnerClient from './modules/owner';\nimport EditCollateralSimulationClient from './modules/edit-collateral.simulation';\nimport DepositExistingMASimulationClient from './modules/deposit-existing-MA.simulation';\nimport DepositNewMASimulationClient from './modules/deposit-new-MA.simulation';\nimport DepositPassivePoolSimulationClient from './modules/deposit-passive-pool.simulation';\nimport WithdrawMASimulationClient from './modules/withdraw-MA.simulation';\nimport WithdrawPassivePoolSimulationClient from './modules/withdraw-passive-pool.simulation';\nimport TransferMarginBetweenMAsSimulationClient from './modules/transfer-margin-between-MAs.simulation';\nimport TransferMAPoolSimulationClient from './modules/transfer-MA-Pool.simulation';\nimport DepthChartSimulationClient from './modules/depth-chart.simulation';\nimport FundingRateClient from './modules/funding-rate';\nimport IsolatedOrderSimulationClient from './modules/isolated-order.simulation';\nimport ConditionalOrdersClient from './modules/conditional-orders';\nimport LotteryClient from './modules/lottery';\nimport ReferralClient from './modules/referral';\nimport AuthClient from './modules/auth';\n\n/**\n * @description Client for API\n */\nexport class ApiClient {\n private static instance: ApiClient;\n private static config: ServiceConfig = API_CLIENT_CONFIGS['test'];\n private readonly _markets: MarketsClient;\n private readonly _account: AccountClient;\n private readonly _lp: LpClient;\n private readonly _tradeSimulation: TradeSimulationClient;\n private readonly _fundingRateHistory: FundingRateClient;\n private readonly _editCollateralSimulation: EditCollateralSimulationClient;\n private readonly _depositExistingMASimulation: DepositExistingMASimulationClient;\n private readonly _depositNewMASimulation: DepositNewMASimulationClient;\n private readonly _depositPassivePoolSimulation: DepositPassivePoolSimulationClient;\n private readonly _withdrawMASimulation: WithdrawMASimulationClient;\n private readonly _withdrawPassivePoolSimulation: WithdrawPassivePoolSimulationClient;\n private readonly _transferMarginBetweenMAsSimulation: TransferMarginBetweenMAsSimulationClient;\n private readonly _transferMAPoolSimulation: TransferMAPoolSimulationClient;\n private readonly _depthSimulation: DepthChartSimulationClient;\n private readonly _isolatedOrderSimulation: IsolatedOrderSimulationClient;\n private readonly _tokens: TokensClient;\n private readonly _owner: OwnerClient;\n private readonly _conditionalOrders: ConditionalOrdersClient;\n private readonly _lottery: LotteryClient;\n private readonly _referral: ReferralClient;\n private readonly _auth: AuthClient;\n\n private constructor() {\n this._markets = new MarketsClient(ApiClient.config.apiEndpoint);\n this._account = new AccountClient(ApiClient.config.apiEndpoint);\n this._lp = new LpClient(ApiClient.config.apiEndpoint);\n this._tradeSimulation = new TradeSimulationClient(this._account);\n this._isolatedOrderSimulation = new IsolatedOrderSimulationClient(\n this._account,\n );\n this._fundingRateHistory = new FundingRateClient(this._markets);\n this._editCollateralSimulation = new EditCollateralSimulationClient(\n ApiClient.network,\n this._account,\n );\n this._depositExistingMASimulation = new DepositExistingMASimulationClient(\n this._editCollateralSimulation,\n ApiClient.config.apiEndpoint,\n );\n this._depositNewMASimulation = new DepositNewMASimulationClient(\n this._depositExistingMASimulation,\n );\n this._depositPassivePoolSimulation = new DepositPassivePoolSimulationClient(\n ApiClient.config.apiEndpoint,\n );\n this._withdrawMASimulation = new WithdrawMASimulationClient(\n this._editCollateralSimulation,\n ApiClient.config.chain,\n ApiClient.config.apiEndpoint,\n );\n this._withdrawPassivePoolSimulation =\n new WithdrawPassivePoolSimulationClient(\n ApiClient.config.chain,\n ApiClient.config.apiEndpoint,\n );\n this._transferMarginBetweenMAsSimulation =\n new TransferMarginBetweenMAsSimulationClient(\n ApiClient.network,\n this._account,\n );\n this._transferMAPoolSimulation = new TransferMAPoolSimulationClient(\n this._editCollateralSimulation,\n );\n\n this._depthSimulation = new DepthChartSimulationClient(this._lp);\n this._tokens = new TokensClient(ApiClient.config.apiEndpoint);\n this._owner = new OwnerClient(ApiClient.config.apiEndpoint);\n this._conditionalOrders = new ConditionalOrdersClient(\n ApiClient.network,\n ApiClient.config.apiEndpoint,\n );\n this._lottery = new LotteryClient(\n ApiClient.config.environment,\n ApiClient.config.apiEndpoint,\n );\n this._referral = new ReferralClient(ApiClient.config.apiEndpoint);\n\n this._auth = new AuthClient(ApiClient.config.apiEndpoint);\n }\n\n public static configure(environment: ServiceConfig['environment']): void {\n ApiClient.config =\n API_CLIENT_CONFIGS[environment] || API_CLIENT_CONFIGS['test'];\n ApiClient.instance = new ApiClient();\n }\n\n private static getInstance(): ApiClient {\n if (!ApiClient.instance) {\n throw new Error(\n 'ApiClient is not configured. Please configure it before using.',\n );\n }\n return ApiClient.instance;\n }\n public static get network(): ReyaChainId {\n if (!ApiClient.config.chain) {\n throw new Error('ApiClient is not configured');\n }\n return ApiClient.config.chain;\n }\n\n /**\n * Provides access to the MarketsClient instance.\n * This getter allows for interacting with market-related API functionalities.\n *\n * @returns {MarketsClient} An instance of MarketsClient for market-related operations.\n * @memberof ApiClient\n */\n public static get markets(): MarketsClient {\n return ApiClient.getInstance()._markets;\n }\n\n /**\n * Provides access to the AccountClient instance.\n * This getter allows for interacting with account-related API functionalities.\n *\n * @returns {AccountClient} An instance of AccountClient for account-related operations.\n * @memberof ApiClient\n */\n public static get account(): AccountClient {\n return ApiClient.getInstance()._account;\n }\n\n /**\n * Provides access to the TradeSimulationClient instance.\n * This getter allows for interacting with trade simulation functionalities.\n * It ensures a singleton pattern by fetching the instance from the ApiClient's\n * private `_tradeSimulation` property, ensuring that trade simulation operations\n * use a consistent client configuration and state.\n *\n * @returns {TradeSimulationClient} An instance of TradeSimulationClient for trade simulation operations.\n * @memberof ApiClient\n * @example\n * // Access the trade simulation client from the ApiClient\n * const tradeSimulationClient = ApiClient.tradeSimulation;\n */\n\n public static get tradeSimulation(): TradeSimulationClient {\n return ApiClient.getInstance()._tradeSimulation;\n }\n\n /**\n * Provides access to the IsolatedOrderSimulationClient instance.\n * This getter allows for interacting with isolatedTrade simulation functionalities.\n * It ensures a singleton pattern by fetching the instance from the ApiClient's\n * private `_isolatedTradeSimulation` property, ensuring that isolatedTrade simulation operations\n * use a consistent client configuration and state.\n *\n * @returns {IsolatedOrderSimulationClient} An instance of IsolatedOrderSimulationClient for isolatedTrade simulation operations.\n * @memberof ApiClient\n * @example\n * // Access the isolatedTrade simulation client from the ApiClient\n * const isolatedTradeSimulationClient = ApiClient.isolatedTradeSimulation;\n */\n public static get isolatedSimulation(): IsolatedOrderSimulationClient {\n return ApiClient.getInstance()._isolatedOrderSimulation;\n }\n\n public static get fundingRateHistory(): FundingRateClient {\n return ApiClient.getInstance()._fundingRateHistory;\n }\n\n /**\n * Retrieves the DepthChartSimulationClient instance used for depth simulation.\n * This method provides access to the depth simulation client through the ApiClient.\n * @returns {DepthChartSimulationClient} The DepthChartSimulationClient instance.\n * @static\n * @public\n */\n public static get depthSimulation(): DepthChartSimulationClient {\n return ApiClient.getInstance()._depthSimulation;\n }\n\n /**\n * Provides access to the EditCollateralSimulationClient instance.\n * This getter allows for interacting with edit collateral simulation functionalities.\n * It ensures a singleton pattern by fetching the instance from the ApiClient's\n * private `_editCollateralSimulation` property, ensuring that edit collateral simulation operations\n * use a consistent client configuration and state.\n *\n * @returns {EditCollateralSimulationClient} An instance of EditCollateralSimulationClient for edit collateral simulation operations.\n * @memberof ApiClient\n * @example\n * // Access the edit collateral simulation client from the ApiClient\n * const editCollateralSimulationClient = ApiClient.editCollateralSimulation;\n */\n\n public static get editCollateralSimulationClient(): EditCollateralSimulationClient {\n return ApiClient.getInstance()._editCollateralSimulation;\n }\n\n /**\n * Provides access to the DepositExistingMASimulationClient instance.\n * This getter allows for interacting with trade simulation functionalities.\n * It ensures a singleton pattern by fetching the instance from the ApiClient's\n * private `_depositExistingMASimulation` property, ensuring that trade simulation operations\n * use a consistent client configuration and state.\n *\n * @returns {DepositExistingMASimulationClient} An instance of DepositExistingMASimulationClient for trade simulation operations.\n * @memberof ApiClient\n * @example\n * // Access the deposit existing Ma simulation client from the ApiClient\n * const depositExistingMASimulationClient = ApiClient.depositExistingMASimulation;\n */\n\n public static get depositExistingMASimulation(): DepositExistingMASimulationClient {\n return ApiClient.getInstance()._depositExistingMASimulation;\n }\n\n /**\n * Provides access to the DepositNewMASimulationClient instance.\n * This getter allows for interacting with trade simulation functionalities.\n * It ensures a singleton pattern by fetching the instance from the ApiClient's\n * private `_depositNewMASimulation` property, ensuring that trade simulation operations\n * use a consistent client configuration and state.\n *\n * @returns {DepositNewMASimulationClient} An instance of DepositNewMASimulationClient for trade simulation operations.\n * @memberof ApiClient\n * @example\n * // Access the deposit new MA simulation client from the ApiClient\n * const depositNewMASimulationClient = ApiClient.depositNewMASimulation;\n */\n\n public static get depositNewMASimulation(): DepositNewMASimulationClient {\n return ApiClient.getInstance()._depositNewMASimulation;\n }\n\n /**\n * Provides access to the DepositPassivePoolSimulationClient instance.\n * This getter allows for interacting with trade simulation functionalities.\n * It ensures a singleton pattern by fetching the instance from the ApiClient's\n * private `_depositPassivePoolSimulation` property, ensuring that trade simulation operations\n * use a consistent client configuration and state.\n *\n * @returns {DepositPassivePoolSimulationClient} An instance of DepositPassivePoolSimulationClient for trade simulation operations.\n * @memberof ApiClient\n * @example\n * // Access the deposit existing Ma simulation client from the ApiClient\n * const depositPassivePoolSimulationClient = ApiClient.depositPassivePoolSimulation;\n */\n\n public static get depositPassivePoolSimulation(): DepositPassivePoolSimulationClient {\n return ApiClient.getInstance()._depositPassivePoolSimulation;\n }\n\n /**\n * Provides access to the WithdrawMASimulationClient instance.\n * This getter allows for interacting with trade simulation functionalities.\n * It ensures a singleton pattern by fetching the instance from the ApiClient's\n * private `_withdrawMASimulation` property, ensuring that trade simulation operations\n * use a consistent client configuration and state.\n *\n * @returns {WithdrawMASimulationClient} An instance of WithdrawMASimulationClient for trade simulation operations.\n * @memberof ApiClient\n * @example\n * // Access the withdraw MA simulation client from the ApiClient\n * const withdrawMASimulationClient = ApiClient.withdrawMASimulation;\n */\n\n public static get withdrawMASimulation(): WithdrawMASimulationClient {\n return ApiClient.getInstance()._withdrawMASimulation;\n }\n\n /**\n * Provides access to the WithdrawPassivePoolSimulationClient instance.\n * This getter allows for interacting with trade simulation functionalities.\n * It ensures a singleton pattern by fetching the instance from the ApiClient's\n * private `_withdrawPassivePoolSimulation` property, ensuring that trade simulation operations\n * use a consistent client configuration and state.\n *\n * @returns {WithdrawPassivePoolSimulationClient} An instance of WithdrawPassivePoolSimulationClient for trade simulation operations.\n * @memberof ApiClient\n * @example\n * // Access the withdraw MA simulation client from the ApiClient\n * const withdrawPassivePoolSimulationClient = ApiClient.withdrawPassivePoolSimulation;\n */\n\n public static get withdrawPassivePoolSimulation(): WithdrawPassivePoolSimulationClient {\n return ApiClient.getInstance()._withdrawPassivePoolSimulation;\n }\n\n /**\n * Provides access to the TransferMarginBetweenMAsSimulationClient instance.\n * This getter allows for interacting with trade simulation functionalities.\n * It ensures a singleton pattern by fetching the instance from the ApiClient's\n * private `_transferMarginBetweenMAsSimulation` property, ensuring that trade simulation operations\n * use a consistent client configuration and state.\n *\n * @returns {TransferMarginBetweenMAsSimulationClient} An instance of TransferMarginBetweenMAsSimulationClient for trade simulation operations.\n * @memberof ApiClient\n * @example\n * // Access the transfer margin between MAs simulation client from the ApiClient\n * const transferMarginBetweenMAsSimulationClient = ApiClient.transferMarginBetweenMAsSimulation;\n */\n\n public static get transferMarginBetweenMAsSimulation(): TransferMarginBetweenMAsSimulationClient {\n return ApiClient.getInstance()._transferMarginBetweenMAsSimulation;\n }\n\n /**\n * Provides access to the TransferMAPoolSimulationClient instance.\n * This getter allows for interacting with trade simulation functionalities.\n * It ensures a singleton pattern by fetching the instance from the ApiClient's\n * private `_TransferMAPoolSimulation` property, ensuring that trade simulation operations\n * use a consistent client configuration and state.\n *\n * @returns {TransferMAPoolSimulationClient} An instance of TransferMAPoolSimulationClient for trade simulation operations.\n * @memberof ApiClient\n * @example\n * // Access the transfer from MA to Pool simulation client from the ApiClient\n * const transferMAPoolSimulationClient = ApiClient.transferMAPoolSimulation;\n */\n\n public static get transferMAPoolSimulation(): TransferMAPoolSimulationClient {\n return ApiClient.getInstance()._transferMAPoolSimulation;\n }\n\n /**\n * Gets the current instance of the LpClient from the ApiClient.\n *\n * This static getter allows access to the LpClient instance managed within the ApiClient's singleton instance. It is a convenience method for retrieving the LpClient directly, bypassing the need to manually access the internal `_lp` property of the ApiClient instance.\n *\n * @returns {LpClient} The LpClient instance currently held by the ApiClient.\n * @example\n * // Assuming ApiClient and LpClient are properly set up\n * const lpClient = ApiClient.lp;\n */\n public static get lp(): LpClient {\n return ApiClient.getInstance()._lp;\n }\n\n /**\n * Gets the current instance of the TokensClient from the ApiClient.\n *\n * This static getter allows access to the TokensClient instance managed within the ApiClient's singleton instance. It is a convenience method for retrieving the TokensClient directly, bypassing the need to manually access the internal `_tokens` property of the ApiClient instance.\n *\n * @returns {TokensClient} The TokensClient instance currently held by the ApiClient.\n * @example\n * // Assuming ApiClient and TokensClient are properly set up\n * const tokensClient = ApiClient.tokens;\n */\n public static get tokens(): TokensClient {\n return ApiClient.getInstance()._tokens;\n }\n\n /**\n * Gets the current instance of the OwnerClient from the ApiClient.\n *\n * This static getter allows access to the OwnerClient instance managed within the ApiClient's singleton instance. It is a convenience method for retrieving the OwnerClient directly, bypassing the need to manually access the internal `_owner` property of the ApiClient instance.\n *\n * @returns {OwnerClient} The OwnerClient instance currently held by the ApiClient.\n * @example\n * // Assuming ApiClient and OwnerClient are properly set up\n * const ownerClient = ApiClient.tokens;\n */\n public static get owner(): OwnerClient {\n return ApiClient.getInstance()._owner;\n }\n\n /**\n * Gets the current instance of the ConditionalOrdersClient from the ApiClient.\n *\n * This static getter allows access to the ConditionalOrdersClient instance managed within the ApiClient's singleton instance. It is a convenience method for retrieving the ConditionalOrdersClient directly, bypassing the need to manually access the internal `_conditionalOrders` property of the ApiClient instance.\n *\n * @returns {ConditionalOrdersClient} The ConditionalOrdersClient instance currently held by the ApiClient.\n */\n public static get conditionalOrders(): ConditionalOrdersClient {\n return ApiClient.getInstance()._conditionalOrders;\n }\n\n /**\n * Gets the current instance of the LotteryClient from the ApiClient.\n *\n * This static getter allows access to the LotteryClient instance managed within the ApiClient's singleton instance. It is a convenience method for retrieving the LotteryClient directly, bypassing the need to manually access the internal `_lottery` property of the ApiClient instance.\n *\n * @returns {LotteryClient} The LotteryClient instance currently held by the ApiClient.\n */\n public static get lottery(): LotteryClient {\n return ApiClient.getInstance()._lottery;\n }\n\n /**\n * Gets the current instance of the ReferralClient from the ApiClient.\n *\n * This static getter allows access to the ReferralClient instance managed within the ApiClient's singleton instance. It is a convenience method for retrieving the ReferralClient directly, bypassing the need to manually access the internal `_referral` property of the ApiClient instance.\n *\n * @returns {ReferralClient} The ReferralClient instance currently held by the ApiClient.\n */\n public static get referral(): ReferralClient {\n return ApiClient.getInstance()._referral;\n }\n /**\n * Gets the current instance of the AuthClient from the ApiClient.\n *\n * This static getter allows access to the AuthClient instance managed within the ApiClient's singleton instance. It is a convenience method for retrieving the AuthClient directly, bypassing the need to manually access the internal `_auth` property of the ApiClient instance.\n *\n * @returns {AuthClient} The AuthClient instance currently held by the ApiClient.\n */\n public static get auth(): AuthClient {\n return ApiClient.getInstance()._auth;\n }\n}\n"]}
@@ -52,26 +52,48 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
52
52
  };
53
53
  Object.defineProperty(exports, "__esModule", { value: true });
54
54
  var common_1 = require("@reyaxyz/common");
55
- var register_1 = require("./register");
55
+ var embeddedWalletHelpers_1 = require("./embeddedWalletHelpers");
56
+ var common_2 = require("@reyaxyz/common");
56
57
  var AuthClient = /** @class */ (function (_super) {
57
58
  __extends(AuthClient, _super);
58
- function AuthClient(reyaChainId, host) {
59
- var _this = _super.call(this, host) || this;
60
- _this.reyaChainId = reyaChainId;
61
- return _this;
59
+ function AuthClient(host) {
60
+ return _super.call(this, host) || this;
62
61
  }
63
62
  AuthClient.prototype.register = function (params) {
64
63
  return __awaiter(this, void 0, void 0, function () {
65
- return __generator(this, function (_a) {
66
- switch (_a.label) {
67
- case 0: return [4 /*yield*/, (0, register_1.register)(this.host, params.signer, this.reyaChainId, params.marginAccountId)];
64
+ var _a, embeddedWalletAddress, ciphertext, iv, signerAddress, signature;
65
+ return __generator(this, function (_b) {
66
+ switch (_b.label) {
67
+ case 0: return [4 /*yield*/, (0, embeddedWalletHelpers_1.generateEmbeddedWallet)(params.attestationResponse)];
68
68
  case 1:
69
- _a.sent();
69
+ _a = _b.sent(), embeddedWalletAddress = _a.embeddedWalletAddress, ciphertext = _a.ciphertext, iv = _a.iv;
70
+ return [4 /*yield*/, params.signer.getAddress()];
71
+ case 2:
72
+ signerAddress = _b.sent();
73
+ return [4 /*yield*/, (0, common_2.signRegisterEmbeddedWallet)(params.signer, embeddedWalletAddress)];
74
+ case 3:
75
+ signature = _b.sent();
76
+ this.post('/api/auth/verify-registration', {
77
+ registrationResponse: JSON.stringify(params.attestationResponse),
78
+ accountId: params.marginAccountId,
79
+ signature: signature,
80
+ embeddedWalletAddress: embeddedWalletAddress,
81
+ embeddedWalletPrivateKeyCypherText: ciphertext,
82
+ embeddedWalletPrivateKeyIv: iv,
83
+ mainWalletAddress: signerAddress,
84
+ });
70
85
  return [2 /*return*/];
71
86
  }
72
87
  });
73
88
  });
74
89
  };
90
+ AuthClient.prototype.generateRegistrationOptions = function () {
91
+ return __awaiter(this, void 0, void 0, function () {
92
+ return __generator(this, function (_a) {
93
+ return [2 /*return*/, this.get('/api/auth/generate-registration-options')];
94
+ });
95
+ });
96
+ };
75
97
  return AuthClient;
76
98
  }(common_1.RestClient));
77
99
  exports.default = AuthClient;
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"/","sources":["clients/modules/auth/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,0CAA0D;AAC1D,uCAAsC;AAGtC;IAAwC,8BAAU;IAGhD,oBAAY,WAAwB,EAAE,IAAY;QAChD,YAAA,MAAK,YAAC,IAAI,CAAC,SAAC;QACZ,KAAI,CAAC,WAAW,GAAG,WAAW,CAAC;;IACjC,CAAC;IAEK,6BAAQ,GAAd,UAAe,MAAsB;;;;4BACnC,qBAAM,IAAA,mBAAQ,EACZ,IAAI,CAAC,IAAI,EACT,MAAM,CAAC,MAAM,EACb,IAAI,CAAC,WAAW,EAChB,MAAM,CAAC,eAAe,CACvB,EAAA;;wBALD,SAKC,CAAC;;;;;KACH;IACH,iBAAC;AAAD,CAAC,AAhBD,CAAwC,mBAAU,GAgBjD","sourcesContent":["import { RestClient, ReyaChainId } from '@reyaxyz/common';\nimport { register } from './register';\nimport { RegisterParams } from './types';\n\nexport default class AuthClient extends RestClient {\n private reyaChainId: ReyaChainId;\n\n constructor(reyaChainId: ReyaChainId, host: string) {\n super(host);\n this.reyaChainId = reyaChainId;\n }\n\n async register(params: RegisterParams): Promise<void> {\n await register(\n this.host,\n params.signer,\n this.reyaChainId,\n params.marginAccountId,\n );\n }\n}\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"/","sources":["clients/modules/auth/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,0CAA6C;AAG7C,iEAAiE;AACjE,0CAA6D;AAE7D;IAAwC,8BAAU;IAChD,oBAAY,IAAY;QACtB,OAAA,MAAK,YAAC,IAAI,CAAC,SAAC;IACd,CAAC;IAEK,6BAAQ,GAAd,UAAe,MAAsB;;;;;4BAEjC,qBAAM,IAAA,8CAAsB,EAAC,MAAM,CAAC,mBAAmB,CAAC,EAAA;;wBADpD,KACJ,SAAwD,EADlD,qBAAqB,2BAAA,EAAE,UAAU,gBAAA,EAAE,EAAE,QAAA;wBAGvB,qBAAM,MAAM,CAAC,MAAM,CAAC,UAAU,EAAE,EAAA;;wBAAhD,aAAa,GAAG,SAAgC;wBACpC,qBAAM,IAAA,mCAA0B,EAChD,MAAM,CAAC,MAAM,EACb,qBAAqB,CACtB,EAAA;;wBAHK,SAAS,GAAG,SAGjB;wBAED,IAAI,CAAC,IAAI,CAAC,+BAA+B,EAAE;4BACzC,oBAAoB,EAAE,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,mBAAmB,CAAC;4BAChE,SAAS,EAAE,MAAM,CAAC,eAAe;4BACjC,SAAS,EAAE,SAAS;4BACpB,qBAAqB,EAAE,qBAAqB;4BAC5C,kCAAkC,EAAE,UAAU;4BAC9C,0BAA0B,EAAE,EAAE;4BAC9B,iBAAiB,EAAE,aAAa;yBACjC,CAAC,CAAC;;;;;KACJ;IAEK,gDAA2B,GAAjC;;;gBACE,sBAAO,IAAI,CAAC,GAAG,CACb,yCAAyC,CAC1C,EAAC;;;KACH;IACH,iBAAC;AAAD,CAAC,AA/BD,CAAwC,mBAAU,GA+BjD","sourcesContent":["import { RestClient } from '@reyaxyz/common';\nimport { RegisterParams } from './types';\nimport { PublicKeyCredentialCreationOptionsJSON } from '@simplewebauthn/types';\nimport { generateEmbeddedWallet } from './embeddedWalletHelpers';\nimport { signRegisterEmbeddedWallet } from '@reyaxyz/common';\n\nexport default class AuthClient extends RestClient {\n constructor(host: string) {\n super(host);\n }\n\n async register(params: RegisterParams): Promise<void> {\n const { embeddedWalletAddress, ciphertext, iv } =\n await generateEmbeddedWallet(params.attestationResponse);\n\n const signerAddress = await params.signer.getAddress();\n const signature = await signRegisterEmbeddedWallet(\n params.signer,\n embeddedWalletAddress,\n );\n\n this.post('/api/auth/verify-registration', {\n registrationResponse: JSON.stringify(params.attestationResponse),\n accountId: params.marginAccountId,\n signature: signature,\n embeddedWalletAddress: embeddedWalletAddress,\n embeddedWalletPrivateKeyCypherText: ciphertext,\n embeddedWalletPrivateKeyIv: iv,\n mainWalletAddress: signerAddress,\n });\n }\n\n async generateRegistrationOptions(): Promise<PublicKeyCredentialCreationOptionsJSON> {\n return this.get<PublicKeyCredentialCreationOptionsJSON>(\n '/api/auth/generate-registration-options',\n );\n }\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","sourceRoot":"/","sources":["clients/modules/auth/types.ts"],"names":[],"mappings":"","sourcesContent":["import { JsonRpcSigner, Signer } from 'ethers';\nimport { MarginAccountEntity } from '@reyaxyz/common';\n\nexport type RegisterParams = {\n signer: Signer | JsonRpcSigner;\n marginAccountId: MarginAccountEntity['id'];\n};\n"]}
1
+ {"version":3,"file":"types.js","sourceRoot":"/","sources":["clients/modules/auth/types.ts"],"names":[],"mappings":"","sourcesContent":["import { JsonRpcSigner, Signer } from 'ethers';\nimport { MarginAccountEntity } from '@reyaxyz/common';\nimport { RegistrationResponseJSON } from '@simplewebauthn/types';\n\nexport type RegisterParams = {\n signer: Signer | JsonRpcSigner;\n marginAccountId: MarginAccountEntity['id'];\n attestationResponse: RegistrationResponseJSON;\n};\n"]}
@@ -19,6 +19,7 @@ import IsolatedOrderSimulationClient from './modules/isolated-order.simulation';
19
19
  import ConditionalOrdersClient from './modules/conditional-orders';
20
20
  import LotteryClient from './modules/lottery';
21
21
  import ReferralClient from './modules/referral';
22
+ import AuthClient from './modules/auth';
22
23
  /**
23
24
  * @description Client for API
24
25
  */
@@ -45,6 +46,7 @@ export declare class ApiClient {
45
46
  private readonly _conditionalOrders;
46
47
  private readonly _lottery;
47
48
  private readonly _referral;
49
+ private readonly _auth;
48
50
  private constructor();
49
51
  static configure(environment: ServiceConfig['environment']): void;
50
52
  private static getInstance;
@@ -271,5 +273,13 @@ export declare class ApiClient {
271
273
  * @returns {ReferralClient} The ReferralClient instance currently held by the ApiClient.
272
274
  */
273
275
  static get referral(): ReferralClient;
276
+ /**
277
+ * Gets the current instance of the AuthClient from the ApiClient.
278
+ *
279
+ * This static getter allows access to the AuthClient instance managed within the ApiClient's singleton instance. It is a convenience method for retrieving the AuthClient directly, bypassing the need to manually access the internal `_auth` property of the ApiClient instance.
280
+ *
281
+ * @returns {AuthClient} The AuthClient instance currently held by the ApiClient.
282
+ */
283
+ static get auth(): AuthClient;
274
284
  }
275
285
  //# sourceMappingURL=api-client.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"api-client.d.ts","sourceRoot":"/","sources":["clients/api-client.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,aAAa,EACb,WAAW,EACZ,MAAM,iBAAiB,CAAC;AACzB,OAAO,aAAa,MAAM,mBAAmB,CAAC;AAC9C,OAAO,aAAa,MAAM,mBAAmB,CAAC;AAC9C,OAAO,qBAAqB,MAAM,4BAA4B,CAAC;AAC/D,OAAO,QAAQ,MAAM,cAAc,CAAC;AACpC,OAAO,YAAY,MAAM,kBAAkB,CAAC;AAC5C,OAAO,WAAW,MAAM,iBAAiB,CAAC;AAC1C,OAAO,8BAA8B,MAAM,sCAAsC,CAAC;AAClF,OAAO,iCAAiC,MAAM,0CAA0C,CAAC;AACzF,OAAO,4BAA4B,MAAM,qCAAqC,CAAC;AAC/E,OAAO,kCAAkC,MAAM,2CAA2C,CAAC;AAC3F,OAAO,0BAA0B,MAAM,kCAAkC,CAAC;AAC1E,OA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AAI,aAAa,CAEzC;IAED;;;;;;OAMG;IACH,WAAkB,QAAQ,IAAI,cAAc,CAE3C;IACD;;;;;;OAMG;IACH,WAAkB,IAAI,IAAI,UAAU,CAEnC;CACF"}
@@ -1,8 +1,9 @@
1
- import { RestClient, ReyaChainId } from '@reyaxyz/common';
1
+ import { RestClient } from '@reyaxyz/common';
2
2
  import { RegisterParams } from './types';
3
+ import { PublicKeyCredentialCreationOptionsJSON } from '@simplewebauthn/types';
3
4
  export default class AuthClient extends RestClient {
4
- private reyaChainId;
5
- constructor(reyaChainId: ReyaChainId, host: string);
5
+ constructor(host: string);
6
6
  register(params: RegisterParams): Promise<void>;
7
+ generateRegistrationOptions(): Promise<PublicKeyCredentialCreationOptionsJSON>;
7
8
  }
8
9
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"/","sources":["clients/modules/auth/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAE1D,OAAO,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAEzC,MAAM,CAAC,OAAO,OAAO,UAAW,SAAQ,UAAU;IAChD,OAAO,CAAC,WAAW,CAAc;gBAErB,WAAW,EAAE,WAAW,EAAE,IAAI,EAAE,MAAM;IAK5C,QAAQ,CAAC,MAAM,EAAE,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC;CAQtD"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"/","sources":["clients/modules/auth/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC7C,OAAO,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AACzC,OAAO,EAAE,sCAAsC,EAAE,MAAM,uBAAuB,CAAC;AAI/E,MAAM,CAAC,OAAO,OAAO,UAAW,SAAQ,UAAU;gBACpC,IAAI,EAAE,MAAM;IAIlB,QAAQ,CAAC,MAAM,EAAE,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC;IAqB/C,2BAA2B,IAAI,OAAO,CAAC,sCAAsC,CAAC;CAKrF"}
@@ -1,7 +1,9 @@
1
1
  import { JsonRpcSigner, Signer } from 'ethers';
2
2
  import { MarginAccountEntity } from '@reyaxyz/common';
3
+ import { RegistrationResponseJSON } from '@simplewebauthn/types';
3
4
  export type RegisterParams = {
4
5
  signer: Signer | JsonRpcSigner;
5
6
  marginAccountId: MarginAccountEntity['id'];
7
+ attestationResponse: RegistrationResponseJSON;
6
8
  };
7
9
  //# sourceMappingURL=types.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"/","sources":["clients/modules/auth/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAC/C,OAAO,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AAEtD,MAAM,MAAM,cAAc,GAAG;IAC3B,MAAM,EAAE,MAAM,GAAG,aAAa,CAAC;IAC/B,eAAe,EAAE,mBAAmB,CAAC,IAAI,CAAC,CAAC;CAC5C,CAAC"}
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"/","sources":["clients/modules/auth/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAC/C,OAAO,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AACtD,OAAO,EAAE,wBAAwB,EAAE,MAAM,uBAAuB,CAAC;AAEjE,MAAM,MAAM,cAAc,GAAG;IAC3B,MAAM,EAAE,MAAM,GAAG,aAAa,CAAC;IAC/B,eAAe,EAAE,mBAAmB,CAAC,IAAI,CAAC,CAAC;IAC3C,mBAAmB,EAAE,wBAAwB,CAAC;CAC/C,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@reyaxyz/api-sdk",
3
- "version": "0.127.3",
3
+ "version": "0.127.4",
4
4
  "publishConfig": {
5
5
  "access": "public",
6
6
  "registry": "https://registry.npmjs.org"
@@ -34,7 +34,6 @@
34
34
  },
35
35
  "dependencies": {
36
36
  "@reyaxyz/common": "0.197.4",
37
- "@simplewebauthn/browser": "^10.0.0",
38
37
  "@simplewebauthn/types": "^10.0.0",
39
38
  "axios": "^1.6.2",
40
39
  "bignumber.js": "^9.1.2",
@@ -43,7 +42,7 @@
43
42
  "ws": "^8.16.0"
44
43
  },
45
44
  "packageManager": "pnpm@8.3.1",
46
- "gitHead": "90f2fccc4477c00e18148e225596c4096aa55102",
45
+ "gitHead": "3af17ed80dc9376c7ca2ca95ec811cbb6fa4b010",
47
46
  "devDependencies": {
48
47
  "@types/ws": "8.5.10"
49
48
  }
@@ -23,7 +23,7 @@ import IsolatedOrderSimulationClient from './modules/isolated-order.simulation';
23
23
  import ConditionalOrdersClient from './modules/conditional-orders';
24
24
  import LotteryClient from './modules/lottery';
25
25
  import ReferralClient from './modules/referral';
26
- // import AuthClient from './modules/auth';
26
+ import AuthClient from './modules/auth';
27
27
 
28
28
  /**
29
29
  * @description Client for API
@@ -51,7 +51,7 @@ export class ApiClient {
51
51
  private readonly _conditionalOrders: ConditionalOrdersClient;
52
52
  private readonly _lottery: LotteryClient;
53
53
  private readonly _referral: ReferralClient;
54
- // private readonly _auth?: AuthClient;
54
+ private readonly _auth: AuthClient;
55
55
 
56
56
  private constructor() {
57
57
  this._markets = new MarketsClient(ApiClient.config.apiEndpoint);
@@ -108,12 +108,7 @@ export class ApiClient {
108
108
  );
109
109
  this._referral = new ReferralClient(ApiClient.config.apiEndpoint);
110
110
 
111
- // if (typeof window !== 'undefined') {
112
- // this._auth = new AuthClient(
113
- // ApiClient.network,
114
- // ApiClient.config.apiEndpoint,
115
- // );
116
- // }
111
+ this._auth = new AuthClient(ApiClient.config.apiEndpoint);
117
112
  }
118
113
 
119
114
  public static configure(environment: ServiceConfig['environment']): void {
@@ -434,7 +429,7 @@ export class ApiClient {
434
429
  *
435
430
  * @returns {AuthClient} The AuthClient instance currently held by the ApiClient.
436
431
  */
437
- // public static get auth(): AuthClient {
438
- // return ApiClient.getInstance()._auth;
439
- // }
432
+ public static get auth(): AuthClient {
433
+ return ApiClient.getInstance()._auth;
434
+ }
440
435
  }
@@ -1,21 +1,38 @@
1
- import { RestClient, ReyaChainId } from '@reyaxyz/common';
2
- import { register } from './register';
1
+ import { RestClient } from '@reyaxyz/common';
3
2
  import { RegisterParams } from './types';
3
+ import { PublicKeyCredentialCreationOptionsJSON } from '@simplewebauthn/types';
4
+ import { generateEmbeddedWallet } from './embeddedWalletHelpers';
5
+ import { signRegisterEmbeddedWallet } from '@reyaxyz/common';
4
6
 
5
7
  export default class AuthClient extends RestClient {
6
- private reyaChainId: ReyaChainId;
7
-
8
- constructor(reyaChainId: ReyaChainId, host: string) {
8
+ constructor(host: string) {
9
9
  super(host);
10
- this.reyaChainId = reyaChainId;
11
10
  }
12
11
 
13
12
  async register(params: RegisterParams): Promise<void> {
14
- await register(
15
- this.host,
13
+ const { embeddedWalletAddress, ciphertext, iv } =
14
+ await generateEmbeddedWallet(params.attestationResponse);
15
+
16
+ const signerAddress = await params.signer.getAddress();
17
+ const signature = await signRegisterEmbeddedWallet(
16
18
  params.signer,
17
- this.reyaChainId,
18
- params.marginAccountId,
19
+ embeddedWalletAddress,
20
+ );
21
+
22
+ this.post('/api/auth/verify-registration', {
23
+ registrationResponse: JSON.stringify(params.attestationResponse),
24
+ accountId: params.marginAccountId,
25
+ signature: signature,
26
+ embeddedWalletAddress: embeddedWalletAddress,
27
+ embeddedWalletPrivateKeyCypherText: ciphertext,
28
+ embeddedWalletPrivateKeyIv: iv,
29
+ mainWalletAddress: signerAddress,
30
+ });
31
+ }
32
+
33
+ async generateRegistrationOptions(): Promise<PublicKeyCredentialCreationOptionsJSON> {
34
+ return this.get<PublicKeyCredentialCreationOptionsJSON>(
35
+ '/api/auth/generate-registration-options',
19
36
  );
20
37
  }
21
38
  }
@@ -1,7 +1,9 @@
1
1
  import { JsonRpcSigner, Signer } from 'ethers';
2
2
  import { MarginAccountEntity } from '@reyaxyz/common';
3
+ import { RegistrationResponseJSON } from '@simplewebauthn/types';
3
4
 
4
5
  export type RegisterParams = {
5
6
  signer: Signer | JsonRpcSigner;
6
7
  marginAccountId: MarginAccountEntity['id'];
8
+ attestationResponse: RegistrationResponseJSON;
7
9
  };
@@ -1,73 +0,0 @@
1
- "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
- var __generator = (this && this.__generator) || function (thisArg, body) {
12
- var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
13
- return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
14
- function verb(n) { return function (v) { return step([n, v]); }; }
15
- function step(op) {
16
- if (f) throw new TypeError("Generator is already executing.");
17
- while (g && (g = 0, op[0] && (_ = 0)), _) try {
18
- if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
19
- if (y = 0, t) op = [op[0] & 2, t.value];
20
- switch (op[0]) {
21
- case 0: case 1: t = op; break;
22
- case 4: _.label++; return { value: op[1], done: false };
23
- case 5: _.label++; y = op[1]; op = [0]; continue;
24
- case 7: op = _.ops.pop(); _.trys.pop(); continue;
25
- default:
26
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
27
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
28
- if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
29
- if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
30
- if (t[2]) _.ops.pop();
31
- _.trys.pop(); continue;
32
- }
33
- op = body.call(thisArg, _);
34
- } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
35
- if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
36
- }
37
- };
38
- var __importDefault = (this && this.__importDefault) || function (mod) {
39
- return (mod && mod.__esModule) ? mod : { "default": mod };
40
- };
41
- Object.defineProperty(exports, "__esModule", { value: true });
42
- exports.authenticate = void 0;
43
- var axios_1 = __importDefault(require("axios"));
44
- var browser_1 = require("@simplewebauthn/browser");
45
- var authenticate = function (baseUrl) { return __awaiter(void 0, void 0, void 0, function () {
46
- var authenticationOptions, attestationResponse, error_1, verificationResponse;
47
- return __generator(this, function (_a) {
48
- switch (_a.label) {
49
- case 0: return [4 /*yield*/, axios_1.default.get("".concat(baseUrl, "/api/auth/generate-authentication-options"))];
50
- case 1:
51
- authenticationOptions = _a.sent();
52
- _a.label = 2;
53
- case 2:
54
- _a.trys.push([2, 4, , 5]);
55
- return [4 /*yield*/, (0, browser_1.startAuthentication)(authenticationOptions.data)];
56
- case 3:
57
- // Pass the options to the authenticator and wait for a response
58
- attestationResponse = _a.sent();
59
- return [3 /*break*/, 5];
60
- case 4:
61
- error_1 = _a.sent();
62
- console.error(error_1);
63
- throw new Error('Failed to authenticate');
64
- case 5: return [4 /*yield*/, axios_1.default.post("".concat(baseUrl, "/api/auth/verify-authentication"), JSON.stringify(attestationResponse))];
65
- case 6:
66
- verificationResponse = _a.sent();
67
- return [4 /*yield*/, verificationResponse.data];
68
- case 7: return [2 /*return*/, _a.sent()];
69
- }
70
- });
71
- }); };
72
- exports.authenticate = authenticate;
73
- //# sourceMappingURL=authenticate.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"authenticate.js","sourceRoot":"/","sources":["clients/modules/auth/authenticate.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,gDAA0B;AAC1B,mDAA8D;AAEvD,IAAM,YAAY,GAAG,UAAO,OAAe;;;;oBAClB,qBAAM,eAAK,CAAC,GAAG,CAC3C,UAAG,OAAO,8CAA2C,CACtD,EAAA;;gBAFK,qBAAqB,GAAG,SAE7B;;;;gBAIuB,qBAAM,IAAA,6BAAmB,EAAC,qBAAqB,CAAC,IAAI,CAAC,EAAA;;gBAD3E,gEAAgE;gBAChE,mBAAmB,GAAG,SAAqD,CAAC;;;;gBAE5E,OAAO,CAAC,KAAK,CAAC,OAAK,CAAC,CAAC;gBACrB,MAAM,IAAI,KAAK,CAAC,wBAAwB,CAAC,CAAC;oBAGf,qBAAM,eAAK,CAAC,IAAI,CAC3C,UAAG,OAAO,oCAAiC,EAC3C,IAAI,CAAC,SAAS,CAAC,mBAAmB,CAAC,CACpC,EAAA;;gBAHK,oBAAoB,GAAG,SAG5B;gBACM,qBAAM,oBAAoB,CAAC,IAAI,EAAA;oBAAtC,sBAAO,SAA+B,EAAC;;;KACxC,CAAC;AAlBW,QAAA,YAAY,gBAkBvB","sourcesContent":["import axios from 'axios';\nimport { startAuthentication } from '@simplewebauthn/browser';\n\nexport const authenticate = async (baseUrl: string) => {\n const authenticationOptions = await axios.get(\n `${baseUrl}/api/auth/generate-authentication-options`,\n );\n let attestationResponse;\n try {\n // Pass the options to the authenticator and wait for a response\n attestationResponse = await startAuthentication(authenticationOptions.data);\n } catch (error) {\n console.error(error);\n throw new Error('Failed to authenticate');\n }\n\n const verificationResponse = await axios.post(\n `${baseUrl}/api/auth/verify-authentication`,\n JSON.stringify(attestationResponse),\n );\n return await verificationResponse.data;\n};\n"]}
@@ -1,5 +0,0 @@
1
- "use strict";
2
- // todo: p2: browserSupportsWebAuthn()
3
- // todo: p2: browserSupportsWebAuthnAutofill()
4
- // todo: p2: platformAuthenticatorIsAvailable()
5
- //# sourceMappingURL=checkSupport.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"checkSupport.js","sourceRoot":"/","sources":["clients/modules/auth/checkSupport.ts"],"names":[],"mappings":";AAAA,sCAAsC;AACtC,8CAA8C;AAC9C,+CAA+C","sourcesContent":["// todo: p2: browserSupportsWebAuthn()\n// todo: p2: browserSupportsWebAuthnAutofill()\n// todo: p2: platformAuthenticatorIsAvailable()\n"]}
@@ -1,93 +0,0 @@
1
- "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
- var __generator = (this && this.__generator) || function (thisArg, body) {
12
- var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
13
- return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
14
- function verb(n) { return function (v) { return step([n, v]); }; }
15
- function step(op) {
16
- if (f) throw new TypeError("Generator is already executing.");
17
- while (g && (g = 0, op[0] && (_ = 0)), _) try {
18
- if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
19
- if (y = 0, t) op = [op[0] & 2, t.value];
20
- switch (op[0]) {
21
- case 0: case 1: t = op; break;
22
- case 4: _.label++; return { value: op[1], done: false };
23
- case 5: _.label++; y = op[1]; op = [0]; continue;
24
- case 7: op = _.ops.pop(); _.trys.pop(); continue;
25
- default:
26
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
27
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
28
- if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
29
- if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
30
- if (t[2]) _.ops.pop();
31
- _.trys.pop(); continue;
32
- }
33
- op = body.call(thisArg, _);
34
- } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
35
- if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
36
- }
37
- };
38
- var __importDefault = (this && this.__importDefault) || function (mod) {
39
- return (mod && mod.__esModule) ? mod : { "default": mod };
40
- };
41
- Object.defineProperty(exports, "__esModule", { value: true });
42
- exports.register = void 0;
43
- var browser_1 = require("@simplewebauthn/browser");
44
- var embeddedWalletHelpers_1 = require("./embeddedWalletHelpers");
45
- var axios_1 = __importDefault(require("axios"));
46
- var common_1 = require("@reyaxyz/common");
47
- var register = function (baseUrl, signer, reyaChainId, accountId) { return __awaiter(void 0, void 0, void 0, function () {
48
- var registrationOptions, attestationResponse, error_1, _a, embeddedWalletAddress, ciphertext, iv, signerAddress, signature, verificationResponse;
49
- return __generator(this, function (_b) {
50
- switch (_b.label) {
51
- case 0: return [4 /*yield*/, axios_1.default.get("".concat(baseUrl, "/api/auth/generate-registration-options"))];
52
- case 1:
53
- registrationOptions = _b.sent();
54
- _b.label = 2;
55
- case 2:
56
- _b.trys.push([2, 4, , 5]);
57
- return [4 /*yield*/, (0, browser_1.startRegistration)(registrationOptions.data)];
58
- case 3:
59
- // Pass the options to the authenticator and wait for a response
60
- attestationResponse = _b.sent();
61
- return [3 /*break*/, 5];
62
- case 4:
63
- error_1 = _b.sent();
64
- // if InvalidStateError -> Authenticator was probably already registered by user
65
- console.error(error_1);
66
- throw new Error('Failed to register');
67
- case 5: return [4 /*yield*/, (0, embeddedWalletHelpers_1.generateEmbeddedWallet)(attestationResponse)];
68
- case 6:
69
- _a = _b.sent(), embeddedWalletAddress = _a.embeddedWalletAddress, ciphertext = _a.ciphertext, iv = _a.iv;
70
- return [4 /*yield*/, signer.getAddress()];
71
- case 7:
72
- signerAddress = _b.sent();
73
- return [4 /*yield*/, (0, common_1.signRegisterEmbeddedWallet)(signer, embeddedWalletAddress)];
74
- case 8:
75
- signature = _b.sent();
76
- return [4 /*yield*/, axios_1.default.post("".concat(baseUrl, "/api/auth/verify-registration"), {
77
- registrationResponse: JSON.stringify(attestationResponse),
78
- accountId: accountId,
79
- signature: signature,
80
- embeddedWalletAddress: embeddedWalletAddress,
81
- embeddedWalletPrivateKeyCypherText: ciphertext,
82
- embeddedWalletPrivateKeyIv: iv,
83
- mainWalletAddress: signerAddress,
84
- })];
85
- case 9:
86
- verificationResponse = _b.sent();
87
- return [4 /*yield*/, verificationResponse.data];
88
- case 10: return [2 /*return*/, _b.sent()];
89
- }
90
- });
91
- }); };
92
- exports.register = register;
93
- //# sourceMappingURL=register.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"register.js","sourceRoot":"/","sources":["clients/modules/auth/register.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,mDAA4D;AAC5D,iEAAiE;AACjE,gDAA0B;AAG1B,0CAA6D;AAEtD,IAAM,QAAQ,GAAG,UACtB,OAAe,EACf,MAA8B,EAC9B,WAAwB,EACxB,SAAiB;;;;oBAKW,qBAAM,eAAK,CAAC,GAAG,CACzC,UAAG,OAAO,4CAAyC,CACpD,EAAA;;gBAFK,mBAAmB,GAAG,SAE3B;;;;gBAIuB,qBAAM,IAAA,2BAAiB,EAAC,mBAAmB,CAAC,IAAI,CAAC,EAAA;;gBADvE,gEAAgE;gBAChE,mBAAmB,GAAG,SAAiD,CAAC;;;;gBAExE,gFAAgF;gBAChF,OAAO,CAAC,KAAK,CAAC,OAAK,CAAC,CAAC;gBACrB,MAAM,IAAI,KAAK,CAAC,oBAAoB,CAAC,CAAC;oBAItC,qBAAM,IAAA,8CAAsB,EAAC,mBAAmB,CAAC,EAAA;;gBAD7C,KACJ,SAAiD,EAD3C,qBAAqB,2BAAA,EAAE,UAAU,gBAAA,EAAE,EAAE,QAAA;gBAEvB,qBAAM,MAAM,CAAC,UAAU,EAAE,EAAA;;gBAAzC,aAAa,GAAG,SAAyB;gBAC7B,qBAAM,IAAA,mCAA0B,EAChD,MAAM,EACN,qBAAqB,CACtB,EAAA;;gBAHK,SAAS,GAAG,SAGjB;gBAE4B,qBAAM,eAAK,CAAC,IAAI,CAC3C,UAAG,OAAO,kCAA+B,EACzC;wBACE,oBAAoB,EAAE,IAAI,CAAC,SAAS,CAAC,mBAAmB,CAAC;wBACzD,SAAS,EAAE,SAAS;wBACpB,SAAS,EAAE,SAAS;wBACpB,qBAAqB,EAAE,qBAAqB;wBAC5C,kCAAkC,EAAE,UAAU;wBAC9C,0BAA0B,EAAE,EAAE;wBAC9B,iBAAiB,EAAE,aAAa;qBACjC,CACF,EAAA;;gBAXK,oBAAoB,GAAG,SAW5B;gBACM,qBAAM,oBAAoB,CAAC,IAAI,EAAA;qBAAtC,sBAAO,SAA+B,EAAC;;;KACxC,CAAC;AA3CW,QAAA,QAAQ,YA2CnB","sourcesContent":["import { startRegistration } from '@simplewebauthn/browser';\nimport { generateEmbeddedWallet } from './embeddedWalletHelpers';\nimport axios from 'axios';\nimport { JsonRpcSigner, Signer } from 'ethers';\nimport { ReyaChainId } from '@reyaxyz/common';\nimport { signRegisterEmbeddedWallet } from '@reyaxyz/common';\n\nexport const register = async (\n baseUrl: string,\n signer: Signer | JsonRpcSigner,\n reyaChainId: ReyaChainId,\n accountId: number,\n) => {\n // todo: p1: leverage this.get of the rest client\n // GET registration options from the endpoint that calls\n // @simplewebauthn/server -> generateRegistrationOptions()\n const registrationOptions = await axios.get(\n `${baseUrl}/api/auth/generate-registration-options`,\n );\n let attestationResponse;\n try {\n // Pass the options to the authenticator and wait for a response\n attestationResponse = await startRegistration(registrationOptions.data);\n } catch (error) {\n // if InvalidStateError -> Authenticator was probably already registered by user\n console.error(error);\n throw new Error('Failed to register');\n }\n\n const { embeddedWalletAddress, ciphertext, iv } =\n await generateEmbeddedWallet(attestationResponse);\n const signerAddress = await signer.getAddress();\n const signature = await signRegisterEmbeddedWallet(\n signer,\n embeddedWalletAddress,\n );\n\n const verificationResponse = await axios.post(\n `${baseUrl}/api/auth/verify-registration`,\n {\n registrationResponse: JSON.stringify(attestationResponse),\n accountId: accountId,\n signature: signature,\n embeddedWalletAddress: embeddedWalletAddress,\n embeddedWalletPrivateKeyCypherText: ciphertext,\n embeddedWalletPrivateKeyIv: iv,\n mainWalletAddress: signerAddress,\n },\n );\n return await verificationResponse.data;\n};\n"]}
@@ -1,2 +0,0 @@
1
- export declare const authenticate: (baseUrl: string) => Promise<any>;
2
- //# sourceMappingURL=authenticate.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"authenticate.d.ts","sourceRoot":"/","sources":["clients/modules/auth/authenticate.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,YAAY,YAAmB,MAAM,iBAkBjD,CAAC"}
@@ -1 +0,0 @@
1
- //# sourceMappingURL=checkSupport.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"checkSupport.d.ts","sourceRoot":"/","sources":["clients/modules/auth/checkSupport.ts"],"names":[],"mappings":""}
@@ -1,4 +0,0 @@
1
- import { JsonRpcSigner, Signer } from 'ethers';
2
- import { ReyaChainId } from '@reyaxyz/common';
3
- export declare const register: (baseUrl: string, signer: Signer | JsonRpcSigner, reyaChainId: ReyaChainId, accountId: number) => Promise<any>;
4
- //# sourceMappingURL=register.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"register.d.ts","sourceRoot":"/","sources":["clients/modules/auth/register.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,aAAa,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAC/C,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAG9C,eAAO,MAAM,QAAQ,YACV,MAAM,UACP,MAAM,GAAG,aAAa,eACjB,WAAW,aACb,MAAM,iBAuClB,CAAC"}
@@ -1,22 +0,0 @@
1
- import axios from 'axios';
2
- import { startAuthentication } from '@simplewebauthn/browser';
3
-
4
- export const authenticate = async (baseUrl: string) => {
5
- const authenticationOptions = await axios.get(
6
- `${baseUrl}/api/auth/generate-authentication-options`,
7
- );
8
- let attestationResponse;
9
- try {
10
- // Pass the options to the authenticator and wait for a response
11
- attestationResponse = await startAuthentication(authenticationOptions.data);
12
- } catch (error) {
13
- console.error(error);
14
- throw new Error('Failed to authenticate');
15
- }
16
-
17
- const verificationResponse = await axios.post(
18
- `${baseUrl}/api/auth/verify-authentication`,
19
- JSON.stringify(attestationResponse),
20
- );
21
- return await verificationResponse.data;
22
- };
@@ -1,3 +0,0 @@
1
- // todo: p2: browserSupportsWebAuthn()
2
- // todo: p2: browserSupportsWebAuthnAutofill()
3
- // todo: p2: platformAuthenticatorIsAvailable()
@@ -1,51 +0,0 @@
1
- import { startRegistration } from '@simplewebauthn/browser';
2
- import { generateEmbeddedWallet } from './embeddedWalletHelpers';
3
- import axios from 'axios';
4
- import { JsonRpcSigner, Signer } from 'ethers';
5
- import { ReyaChainId } from '@reyaxyz/common';
6
- import { signRegisterEmbeddedWallet } from '@reyaxyz/common';
7
-
8
- export const register = async (
9
- baseUrl: string,
10
- signer: Signer | JsonRpcSigner,
11
- reyaChainId: ReyaChainId,
12
- accountId: number,
13
- ) => {
14
- // todo: p1: leverage this.get of the rest client
15
- // GET registration options from the endpoint that calls
16
- // @simplewebauthn/server -> generateRegistrationOptions()
17
- const registrationOptions = await axios.get(
18
- `${baseUrl}/api/auth/generate-registration-options`,
19
- );
20
- let attestationResponse;
21
- try {
22
- // Pass the options to the authenticator and wait for a response
23
- attestationResponse = await startRegistration(registrationOptions.data);
24
- } catch (error) {
25
- // if InvalidStateError -> Authenticator was probably already registered by user
26
- console.error(error);
27
- throw new Error('Failed to register');
28
- }
29
-
30
- const { embeddedWalletAddress, ciphertext, iv } =
31
- await generateEmbeddedWallet(attestationResponse);
32
- const signerAddress = await signer.getAddress();
33
- const signature = await signRegisterEmbeddedWallet(
34
- signer,
35
- embeddedWalletAddress,
36
- );
37
-
38
- const verificationResponse = await axios.post(
39
- `${baseUrl}/api/auth/verify-registration`,
40
- {
41
- registrationResponse: JSON.stringify(attestationResponse),
42
- accountId: accountId,
43
- signature: signature,
44
- embeddedWalletAddress: embeddedWalletAddress,
45
- embeddedWalletPrivateKeyCypherText: ciphertext,
46
- embeddedWalletPrivateKeyIv: iv,
47
- mainWalletAddress: signerAddress,
48
- },
49
- );
50
- return await verificationResponse.data;
51
- };