@reyaxyz/api-sdk 0.160.8 → 0.161.0

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.
@@ -22,7 +22,6 @@ var depth_chart_simulation_1 = __importDefault(require("./modules/depth-chart.si
22
22
  var funding_rate_1 = __importDefault(require("./modules/funding-rate"));
23
23
  var conditional_orders_1 = __importDefault(require("./modules/conditional-orders"));
24
24
  var referral_1 = __importDefault(require("./modules/referral"));
25
- var auth_1 = __importDefault(require("./modules/auth"));
26
25
  /**
27
26
  * @description Client for API
28
27
  */
@@ -47,7 +46,6 @@ var ApiClient = /** @class */ (function () {
47
46
  this._owner = new owner_1.default(ApiClient.config.apiEndpoint);
48
47
  this._conditionalOrders = new conditional_orders_1.default(ApiClient.network, ApiClient.config.apiEndpoint);
49
48
  this._referral = new referral_1.default(ApiClient.config.apiEndpoint);
50
- this._auth = new auth_1.default(ApiClient.config.apiEndpoint);
51
49
  }
52
50
  ApiClient.configure = function (environment) {
53
51
  ApiClient.config = (0, common_1.getApiClientConfig)(environment);
@@ -357,20 +355,6 @@ var ApiClient = /** @class */ (function () {
357
355
  enumerable: false,
358
356
  configurable: true
359
357
  });
360
- Object.defineProperty(ApiClient, "auth", {
361
- /**
362
- * Gets the current instance of the AuthClient from the ApiClient.
363
- *
364
- * 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.
365
- *
366
- * @returns {AuthClient} The AuthClient instance currently held by the ApiClient.
367
- */
368
- get: function () {
369
- return ApiClient.getInstance()._auth;
370
- },
371
- enumerable: false,
372
- configurable: true
373
- });
374
358
  ApiClient.config = (0, common_1.getApiClientConfig)('test');
375
359
  return ApiClient;
376
360
  }());
@@ -1 +1 @@
1
- {"version":3,"file":"api-client.js","sourceRoot":"/","sources":["clients/api-client.ts"],"names":[],"mappings":";;;;;;AAAA,0CAIyB;AACzB,8DAA8C;AAC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;OAAA;IAvVc,gBAAM,GAAkB,IAAA,2BAAkB,EAAC,MAAM,CAAC,CAAC;IAwVpE,gBAAC;CAAA,AA1VD,IA0VC;AA1VY,8BAAS","sourcesContent":["import {\n ServiceConfig,\n ReyaChainId,\n getApiClientConfig,\n} from '@reyaxyz/common';\nimport MarketsClient from './modules/markets';\nimport AccountClient from './modules/account';\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 ConditionalOrdersClient from './modules/conditional-orders';\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 = getApiClientConfig('test');\n private readonly _markets: MarketsClient;\n private readonly _account: AccountClient;\n private readonly _lp: LpClient;\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 _tokens: TokensClient;\n private readonly _owner: OwnerClient;\n private readonly _conditionalOrders: ConditionalOrdersClient;\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._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._referral = new ReferralClient(ApiClient.config.apiEndpoint);\n this._auth = new AuthClient(ApiClient.config.apiEndpoint);\n }\n\n public static configure(environment: ServiceConfig['environment']): void {\n ApiClient.config = getApiClientConfig(environment);\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 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 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 /**\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,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,oFAAmE;AACnE,gEAAgD;AAEhD;;GAEG;AACH;IAqBE;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,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,eAAE;QAVpB;;;;;;;;;WASG;aACH;YACE,OAAO,SAAS,CAAC,WAAW,EAAE,CAAC,GAAG,CAAC;QACrC,CAAC;;;OAAA;IAYD,sBAAkB,mBAAM;QAVxB;;;;;;;;;WASG;aACH;YACE,OAAO,SAAS,CAAC,WAAW,EAAE,CAAC,OAAO,CAAC;QACzC,CAAC;;;OAAA;IAYD,sBAAkB,kBAAK;QAVvB;;;;;;;;;WASG;aACH;YACE,OAAO,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,qBAAQ;QAP1B;;;;;;WAMG;aACH;YACE,OAAO,SAAS,CAAC,WAAW,EAAE,CAAC,SAAS,CAAC;QAC3C,CAAC;;;OAAA;IA1Uc,gBAAM,GAAkB,IAAA,2BAAkB,EAAC,MAAM,CAAC,CAAC;IA2UpE,gBAAC;CAAA,AA7UD,IA6UC;AA7UY,8BAAS","sourcesContent":["import {\n ServiceConfig,\n ReyaChainId,\n getApiClientConfig,\n} from '@reyaxyz/common';\nimport MarketsClient from './modules/markets';\nimport AccountClient from './modules/account';\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 ConditionalOrdersClient from './modules/conditional-orders';\nimport ReferralClient from './modules/referral';\n\n/**\n * @description Client for API\n */\nexport class ApiClient {\n private static instance: ApiClient;\n private static config: ServiceConfig = getApiClientConfig('test');\n private readonly _markets: MarketsClient;\n private readonly _account: AccountClient;\n private readonly _lp: LpClient;\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 _tokens: TokensClient;\n private readonly _owner: OwnerClient;\n private readonly _conditionalOrders: ConditionalOrdersClient;\n private readonly _referral: ReferralClient;\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._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._referral = new ReferralClient(ApiClient.config.apiEndpoint);\n }\n\n public static configure(environment: ServiceConfig['environment']): void {\n ApiClient.config = getApiClientConfig(environment);\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 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 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"]}
@@ -16,7 +16,6 @@ import DepthChartSimulationClient from './modules/depth-chart.simulation';
16
16
  import FundingRateClient from './modules/funding-rate';
17
17
  import ConditionalOrdersClient from './modules/conditional-orders';
18
18
  import ReferralClient from './modules/referral';
19
- import AuthClient from './modules/auth';
20
19
  /**
21
20
  * @description Client for API
22
21
  */
@@ -40,7 +39,6 @@ export declare class ApiClient {
40
39
  private readonly _owner;
41
40
  private readonly _conditionalOrders;
42
41
  private readonly _referral;
43
- private readonly _auth;
44
42
  private constructor();
45
43
  static configure(environment: ServiceConfig['environment']): void;
46
44
  private static getInstance;
@@ -231,13 +229,5 @@ export declare class ApiClient {
231
229
  * @returns {ReferralClient} The ReferralClient instance currently held by the ApiClient.
232
230
  */
233
231
  static get referral(): ReferralClient;
234
- /**
235
- * Gets the current instance of the AuthClient from the ApiClient.
236
- *
237
- * 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.
238
- *
239
- * @returns {AuthClient} The AuthClient instance currently held by the ApiClient.
240
- */
241
- static get auth(): AuthClient;
242
232
  }
243
233
  //# 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,EACL,aAAa,EACb,WAAW,EAEZ,MAAM,iBAAiB,CAAC;AACzB,OAAO,aAAa,MAAM,mBAAmB,CAAC;AAC9C,OAAO,aAAa,MAAM,mBAAmB,CAAC;AAC9C,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,OAAO,mCAAmC,MAAM,4CAA4C,CAAC;AAC7F,OAAO,wCAAwC,MAAM,kDAAkD,CAAC;AACxG,OAAO,8BAA8B,MAAM,uCAAuC,CAAC;AACnF,OAAO,0BAA0B,MAAM,kCAAkC,CAAC;AAC1E,OAAO,iBAAiB,MAAM,wBAA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B,wBAAwB,IAAI,8BAA8B,CAE3E;IAED;;;;;;;;;OASG;IACH,WAAkB,EAAE,IAAI,QAAQ,CAE/B;IAED;;;;;;;;;OASG;IACH,WAAkB,MAAM,IAAI,YAAY,CAEvC;IAED;;;;;;;;;OASG;IACH,WAAkB,KAAK,IAAI,WAAW,CAErC;IAED;;;;;;OAMG;IACH,WAAkB,iBAAiB,IAAI,uBAAuB,CAE7D;IAED;;;;;;OAMG;IACH,WAAkB,QAAQ,IAAI,cAAc,CAE3C;CACF"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@reyaxyz/api-sdk",
3
- "version": "0.160.8",
3
+ "version": "0.161.0",
4
4
  "publishConfig": {
5
5
  "access": "public",
6
6
  "registry": "https://registry.npmjs.org"
@@ -33,15 +33,15 @@
33
33
  "generate:coverage-badges": "npx istanbul-badges-readme --silent"
34
34
  },
35
35
  "dependencies": {
36
- "@reyaxyz/common": "0.315.0",
36
+ "@reyaxyz/common": "0.317.0",
37
37
  "@simplewebauthn/types": "10.0.0",
38
38
  "bignumber.js": "9.1.2",
39
39
  "ethers": "6.9.0",
40
40
  "isomorphic-ws": "5.0.0"
41
41
  },
42
42
  "packageManager": "pnpm@8.3.1",
43
- "gitHead": "ae5e0edc0b875184d1d8bfccca5abdb43ce163b3",
43
+ "gitHead": "1ee6df49c8b20d53bbfe442ea2e98c9543274196",
44
44
  "devDependencies": {
45
- "@reyaxyz/database": "0.151.4"
45
+ "@reyaxyz/database": "0.151.6"
46
46
  }
47
47
  }
@@ -20,7 +20,6 @@ import DepthChartSimulationClient from './modules/depth-chart.simulation';
20
20
  import FundingRateClient from './modules/funding-rate';
21
21
  import ConditionalOrdersClient from './modules/conditional-orders';
22
22
  import ReferralClient from './modules/referral';
23
- import AuthClient from './modules/auth';
24
23
 
25
24
  /**
26
25
  * @description Client for API
@@ -45,7 +44,6 @@ export class ApiClient {
45
44
  private readonly _owner: OwnerClient;
46
45
  private readonly _conditionalOrders: ConditionalOrdersClient;
47
46
  private readonly _referral: ReferralClient;
48
- private readonly _auth: AuthClient;
49
47
 
50
48
  private constructor() {
51
49
  this._markets = new MarketsClient(ApiClient.config.apiEndpoint);
@@ -93,7 +91,6 @@ export class ApiClient {
93
91
  ApiClient.config.apiEndpoint,
94
92
  );
95
93
  this._referral = new ReferralClient(ApiClient.config.apiEndpoint);
96
- this._auth = new AuthClient(ApiClient.config.apiEndpoint);
97
94
  }
98
95
 
99
96
  public static configure(environment: ServiceConfig['environment']): void {
@@ -360,15 +357,4 @@ export class ApiClient {
360
357
  public static get referral(): ReferralClient {
361
358
  return ApiClient.getInstance()._referral;
362
359
  }
363
-
364
- /**
365
- * Gets the current instance of the AuthClient from the ApiClient.
366
- *
367
- * 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.
368
- *
369
- * @returns {AuthClient} The AuthClient instance currently held by the ApiClient.
370
- */
371
- public static get auth(): AuthClient {
372
- return ApiClient.getInstance()._auth;
373
- }
374
360
  }
@@ -1,101 +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
- Object.defineProperty(exports, "__esModule", { value: true });
39
- exports.generateEmbeddedWallet = void 0;
40
- var ethers_1 = require("ethers");
41
- var crypto_1 = require("crypto");
42
- var generateEmbeddedWallet = function (attestationResponse) { return __awaiter(void 0, void 0, void 0, function () {
43
- var embeddedWallet, encryptionKey, _a, ciphertext, iv;
44
- return __generator(this, function (_b) {
45
- switch (_b.label) {
46
- case 0:
47
- embeddedWallet = ethers_1.ethers.Wallet.createRandom();
48
- return [4 /*yield*/, deriveEncryptionKey(attestationResponse)];
49
- case 1:
50
- encryptionKey = _b.sent();
51
- return [4 /*yield*/, encryptPrivateKey(embeddedWallet.privateKey, encryptionKey)];
52
- case 2:
53
- _a = _b.sent(), ciphertext = _a.ciphertext, iv = _a.iv;
54
- return [2 /*return*/, {
55
- embeddedWalletAddress: embeddedWallet.address,
56
- ciphertext: ciphertext,
57
- iv: iv,
58
- }];
59
- }
60
- });
61
- }); };
62
- exports.generateEmbeddedWallet = generateEmbeddedWallet;
63
- var deriveEncryptionKey = function (publicKeyCredential) { return __awaiter(void 0, void 0, void 0, function () {
64
- var rawIdBuffer, keyMaterial;
65
- return __generator(this, function (_a) {
66
- switch (_a.label) {
67
- case 0:
68
- rawIdBuffer = new TextEncoder().encode(publicKeyCredential.rawId);
69
- return [4 /*yield*/, crypto_1.subtle.importKey('raw', rawIdBuffer, { name: 'HKDF' }, false, ['deriveKey'])];
70
- case 1:
71
- keyMaterial = _a.sent();
72
- return [4 /*yield*/, crypto_1.subtle.deriveKey({
73
- name: 'HKDF',
74
- hash: 'SHA-256',
75
- salt: new Uint8Array(16), // Use a consistent salt
76
- info: new TextEncoder().encode('encryption key'),
77
- }, keyMaterial, { name: 'AES-GCM', length: 256 }, false, ['encrypt', 'decrypt'])];
78
- case 2: return [2 /*return*/, _a.sent()];
79
- }
80
- });
81
- }); };
82
- var encryptPrivateKey = function (embeddedWalletPrivateKey, encryptionKey) { return __awaiter(void 0, void 0, void 0, function () {
83
- var iv, encrypted;
84
- return __generator(this, function (_a) {
85
- switch (_a.label) {
86
- case 0:
87
- iv = crypto.getRandomValues(new Uint8Array(12));
88
- return [4 /*yield*/, crypto_1.subtle.encrypt({
89
- name: 'AES-GCM',
90
- iv: iv,
91
- }, encryptionKey, new TextEncoder().encode(embeddedWalletPrivateKey))];
92
- case 1:
93
- encrypted = _a.sent();
94
- return [2 /*return*/, {
95
- ciphertext: encrypted,
96
- iv: iv,
97
- }];
98
- }
99
- });
100
- }); };
101
- //# sourceMappingURL=embeddedWalletHelpers.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"embeddedWalletHelpers.js","sourceRoot":"/","sources":["clients/modules/auth/embeddedWalletHel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AA;oBAXD,sBAAO,SAWN,EAAC;;;KACH,CAAC;AAEF,IAAM,iBAAiB,GAAG,UACxB,wBAAgC,EAChC,aAAwB;;;;;gBAElB,EAAE,GAAG,MAAM,CAAC,eAAe,CAAC,IAAI,UAAU,CAAC,EAAE,CAAC,CAAC,CAAC;gBACpC,qBAAM,eAAM,CAAC,OAAO,CACpC;wBACE,IAAI,EAAE,SAAS;wBACf,EAAE,EAAE,EAAE;qBACP,EACD,aAAa,EACb,IAAI,WAAW,EAAE,CAAC,MAAM,CAAC,wBAAwB,CAAC,CACnD,EAAA;;gBAPK,SAAS,GAAG,SAOjB;gBAED,sBAAO;wBACL,UAAU,EAAE,SAAS;wBACrB,EAAE,EAAE,EAAE;qBACP,EAAC;;;KACH,CAAC","sourcesContent":["import { ethers } from 'ethers';\nimport { subtle } from 'crypto';\nimport type { RegistrationResponseJSON } from '@simplewebauthn/types';\n\nexport const generateEmbeddedWallet = async (\n attestationResponse: RegistrationResponseJSON,\n) => {\n const embeddedWallet = ethers.Wallet.createRandom();\n\n const encryptionKey = await deriveEncryptionKey(attestationResponse);\n\n const { ciphertext, iv } = await encryptPrivateKey(\n embeddedWallet.privateKey,\n encryptionKey,\n );\n\n return {\n embeddedWalletAddress: embeddedWallet.address,\n ciphertext: ciphertext,\n iv: iv,\n };\n};\n\nconst deriveEncryptionKey = async (\n publicKeyCredential: RegistrationResponseJSON,\n) => {\n // Convert rawId to Uint8Array if it is not already\n const rawIdBuffer = new TextEncoder().encode(publicKeyCredential.rawId);\n\n const keyMaterial = await subtle.importKey(\n 'raw',\n rawIdBuffer,\n { name: 'HKDF' },\n false,\n ['deriveKey'],\n );\n\n return await subtle.deriveKey(\n {\n name: 'HKDF',\n hash: 'SHA-256',\n salt: new Uint8Array(16), // Use a consistent salt\n info: new TextEncoder().encode('encryption key'),\n },\n keyMaterial,\n { name: 'AES-GCM', length: 256 },\n false,\n ['encrypt', 'decrypt'],\n );\n};\n\nconst encryptPrivateKey = async (\n embeddedWalletPrivateKey: string,\n encryptionKey: CryptoKey,\n) => {\n const iv = crypto.getRandomValues(new Uint8Array(12)); // 12 bytes IV for AES-GCM\n const encrypted = await subtle.encrypt(\n {\n name: 'AES-GCM',\n iv: iv,\n },\n encryptionKey,\n new TextEncoder().encode(embeddedWalletPrivateKey),\n );\n\n return {\n ciphertext: encrypted,\n iv: iv,\n };\n};\n"]}
@@ -1,102 +0,0 @@
1
- "use strict";
2
- var __extends = (this && this.__extends) || (function () {
3
- var extendStatics = function (d, b) {
4
- extendStatics = Object.setPrototypeOf ||
5
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
6
- function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
7
- return extendStatics(d, b);
8
- };
9
- return function (d, b) {
10
- if (typeof b !== "function" && b !== null)
11
- throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
12
- extendStatics(d, b);
13
- function __() { this.constructor = d; }
14
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
15
- };
16
- })();
17
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
18
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
19
- return new (P || (P = Promise))(function (resolve, reject) {
20
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
21
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
22
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
23
- step((generator = generator.apply(thisArg, _arguments || [])).next());
24
- });
25
- };
26
- var __generator = (this && this.__generator) || function (thisArg, body) {
27
- var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
28
- return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
29
- function verb(n) { return function (v) { return step([n, v]); }; }
30
- function step(op) {
31
- if (f) throw new TypeError("Generator is already executing.");
32
- while (g && (g = 0, op[0] && (_ = 0)), _) try {
33
- 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;
34
- if (y = 0, t) op = [op[0] & 2, t.value];
35
- switch (op[0]) {
36
- case 0: case 1: t = op; break;
37
- case 4: _.label++; return { value: op[1], done: false };
38
- case 5: _.label++; y = op[1]; op = [0]; continue;
39
- case 7: op = _.ops.pop(); _.trys.pop(); continue;
40
- default:
41
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
42
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
43
- if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
44
- if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
45
- if (t[2]) _.ops.pop();
46
- _.trys.pop(); continue;
47
- }
48
- op = body.call(thisArg, _);
49
- } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
50
- if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
51
- }
52
- };
53
- Object.defineProperty(exports, "__esModule", { value: true });
54
- var common_1 = require("@reyaxyz/common");
55
- var embeddedWalletHelpers_1 = require("./embeddedWalletHelpers");
56
- var common_2 = require("@reyaxyz/common");
57
- var AuthClient = /** @class */ (function (_super) {
58
- __extends(AuthClient, _super);
59
- function AuthClient(host) {
60
- return _super.call(this, host) || this;
61
- }
62
- AuthClient.prototype.register = function (params) {
63
- return __awaiter(this, void 0, void 0, function () {
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
- case 1:
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
- });
85
- return [2 /*return*/];
86
- }
87
- });
88
- });
89
- };
90
- AuthClient.prototype.generateRegistrationOptions = function (marginAccountId) {
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
- accountId: marginAccountId,
95
- })];
96
- });
97
- });
98
- };
99
- return AuthClient;
100
- }(common_1.RestClient));
101
- exports.default = AuthClient;
102
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
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,UACE,eAAuB;;;gBAEvB,sBAAO,IAAI,CAAC,GAAG,CACb,yCAAyC,EACzC;wBACE,SAAS,EAAE,eAAe;qBAC3B,CACF,EAAC;;;KACH;IACH,iBAAC;AAAD,CAAC,AApCD,CAAwC,mBAAU,GAoCjD","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(\n marginAccountId: number,\n ): Promise<PublicKeyCredentialCreationOptionsJSON> {\n return this.get<PublicKeyCredentialCreationOptionsJSON>(\n '/api/auth/generate-registration-options',\n {\n accountId: marginAccountId,\n },\n );\n }\n}\n"]}
@@ -1,3 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- //# sourceMappingURL=types.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"types.js","sourceRoot":"/","sources":["clients/modules/auth/types.ts"],"names":[],"mappings":"","sourcesContent":["import { JsonRpcSigner, Signer } from 'ethers';\nimport { RegistrationResponseJSON } from '@simplewebauthn/types';\n\nexport type RegisterParams = {\n signer: Signer | JsonRpcSigner;\n marginAccountId: number;\n attestationResponse: RegistrationResponseJSON;\n};\n"]}
@@ -1,7 +0,0 @@
1
- import type { RegistrationResponseJSON } from '@simplewebauthn/types';
2
- export declare const generateEmbeddedWallet: (attestationResponse: RegistrationResponseJSON) => Promise<{
3
- embeddedWalletAddress: string;
4
- ciphertext: ArrayBuffer;
5
- iv: Uint8Array;
6
- }>;
7
- //# sourceMappingURL=embeddedWalletHelpers.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"embeddedWalletHelpers.d.ts","sourceRoot":"/","sources":["clients/modules/auth/embeddedWalletHelpers.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,uBAAuB,CAAC;AAEtE,eAAO,MAAM,sBAAsB,wBACZ,wBAAwB;;;;EAgB9C,CAAC"}
@@ -1,9 +0,0 @@
1
- import { RestClient } from '@reyaxyz/common';
2
- import { RegisterParams } from './types';
3
- import { PublicKeyCredentialCreationOptionsJSON } from '@simplewebauthn/types';
4
- export default class AuthClient extends RestClient {
5
- constructor(host: string);
6
- register(params: RegisterParams): Promise<void>;
7
- generateRegistrationOptions(marginAccountId: number): Promise<PublicKeyCredentialCreationOptionsJSON>;
8
- }
9
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
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,CAC/B,eAAe,EAAE,MAAM,GACtB,OAAO,CAAC,sCAAsC,CAAC;CAQnD"}
@@ -1,8 +0,0 @@
1
- import { JsonRpcSigner, Signer } from 'ethers';
2
- import { RegistrationResponseJSON } from '@simplewebauthn/types';
3
- export type RegisterParams = {
4
- signer: Signer | JsonRpcSigner;
5
- marginAccountId: number;
6
- attestationResponse: RegistrationResponseJSON;
7
- };
8
- //# sourceMappingURL=types.d.ts.map
@@ -1 +0,0 @@
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,wBAAwB,EAAE,MAAM,uBAAuB,CAAC;AAEjE,MAAM,MAAM,cAAc,GAAG;IAC3B,MAAM,EAAE,MAAM,GAAG,aAAa,CAAC;IAC/B,eAAe,EAAE,MAAM,CAAC;IACxB,mBAAmB,EAAE,wBAAwB,CAAC;CAC/C,CAAC"}
@@ -1,70 +0,0 @@
1
- import { ethers } from 'ethers';
2
- import { subtle } from 'crypto';
3
- import type { RegistrationResponseJSON } from '@simplewebauthn/types';
4
-
5
- export const generateEmbeddedWallet = async (
6
- attestationResponse: RegistrationResponseJSON,
7
- ) => {
8
- const embeddedWallet = ethers.Wallet.createRandom();
9
-
10
- const encryptionKey = await deriveEncryptionKey(attestationResponse);
11
-
12
- const { ciphertext, iv } = await encryptPrivateKey(
13
- embeddedWallet.privateKey,
14
- encryptionKey,
15
- );
16
-
17
- return {
18
- embeddedWalletAddress: embeddedWallet.address,
19
- ciphertext: ciphertext,
20
- iv: iv,
21
- };
22
- };
23
-
24
- const deriveEncryptionKey = async (
25
- publicKeyCredential: RegistrationResponseJSON,
26
- ) => {
27
- // Convert rawId to Uint8Array if it is not already
28
- const rawIdBuffer = new TextEncoder().encode(publicKeyCredential.rawId);
29
-
30
- const keyMaterial = await subtle.importKey(
31
- 'raw',
32
- rawIdBuffer,
33
- { name: 'HKDF' },
34
- false,
35
- ['deriveKey'],
36
- );
37
-
38
- return await subtle.deriveKey(
39
- {
40
- name: 'HKDF',
41
- hash: 'SHA-256',
42
- salt: new Uint8Array(16), // Use a consistent salt
43
- info: new TextEncoder().encode('encryption key'),
44
- },
45
- keyMaterial,
46
- { name: 'AES-GCM', length: 256 },
47
- false,
48
- ['encrypt', 'decrypt'],
49
- );
50
- };
51
-
52
- const encryptPrivateKey = async (
53
- embeddedWalletPrivateKey: string,
54
- encryptionKey: CryptoKey,
55
- ) => {
56
- const iv = crypto.getRandomValues(new Uint8Array(12)); // 12 bytes IV for AES-GCM
57
- const encrypted = await subtle.encrypt(
58
- {
59
- name: 'AES-GCM',
60
- iv: iv,
61
- },
62
- encryptionKey,
63
- new TextEncoder().encode(embeddedWalletPrivateKey),
64
- );
65
-
66
- return {
67
- ciphertext: encrypted,
68
- iv: iv,
69
- };
70
- };
@@ -1,43 +0,0 @@
1
- import { RestClient } from '@reyaxyz/common';
2
- import { RegisterParams } from './types';
3
- import { PublicKeyCredentialCreationOptionsJSON } from '@simplewebauthn/types';
4
- import { generateEmbeddedWallet } from './embeddedWalletHelpers';
5
- import { signRegisterEmbeddedWallet } from '@reyaxyz/common';
6
-
7
- export default class AuthClient extends RestClient {
8
- constructor(host: string) {
9
- super(host);
10
- }
11
-
12
- async register(params: RegisterParams): Promise<void> {
13
- const { embeddedWalletAddress, ciphertext, iv } =
14
- await generateEmbeddedWallet(params.attestationResponse);
15
-
16
- const signerAddress = await params.signer.getAddress();
17
- const signature = await signRegisterEmbeddedWallet(
18
- params.signer,
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(
34
- marginAccountId: number,
35
- ): Promise<PublicKeyCredentialCreationOptionsJSON> {
36
- return this.get<PublicKeyCredentialCreationOptionsJSON>(
37
- '/api/auth/generate-registration-options',
38
- {
39
- accountId: marginAccountId,
40
- },
41
- );
42
- }
43
- }
@@ -1,8 +0,0 @@
1
- import { JsonRpcSigner, Signer } from 'ethers';
2
- import { RegistrationResponseJSON } from '@simplewebauthn/types';
3
-
4
- export type RegisterParams = {
5
- signer: Signer | JsonRpcSigner;
6
- marginAccountId: number;
7
- attestationResponse: RegistrationResponseJSON;
8
- };