diff --git a/.changeset/eleven-mirrors-fry.md b/.changeset/eleven-mirrors-fry.md new file mode 100644 index 00000000..b98cca8c --- /dev/null +++ b/.changeset/eleven-mirrors-fry.md @@ -0,0 +1,5 @@ +--- +'@bnb-chain/greenfield-js-sdk': patch +--- + +feat: Export Auth type diff --git a/packages/js-sdk/src/api/bucket.ts b/packages/js-sdk/src/api/bucket.ts index 1ddd2d44..71c23769 100644 --- a/packages/js-sdk/src/api/bucket.ts +++ b/packages/js-sdk/src/api/bucket.ts @@ -29,6 +29,7 @@ import { bytesToUtf8, hexToBytes } from 'ethereum-cryptography/utils'; import Long from 'long'; import { container, delay, inject, injectable } from 'tsyringe'; import { + AuthType, GRNToString, MsgCreateBucketTypeUrl, MsgDeleteBucketTypeUrl, @@ -65,7 +66,7 @@ import { getQueryBucketReadQuotaMetaInfo, parseReadQuotaResponse, } from '../clients/spclient/spApis/queryBucketReadQuota'; -import { AuthType, SpClient } from '../clients/spclient/spClient'; +import { SpClient } from '../clients/spclient/spClient'; import { TxClient } from '../clients/txClient'; import { METHOD_GET, NORMAL_ERROR_CODE } from '../constants/http'; import { MsgCreateBucketSDKTypeEIP712 } from '../messages/greenfield/storage/MsgCreateBucket'; diff --git a/packages/js-sdk/src/api/objects.ts b/packages/js-sdk/src/api/objects.ts index 53641df1..316f47ae 100644 --- a/packages/js-sdk/src/api/objects.ts +++ b/packages/js-sdk/src/api/objects.ts @@ -66,8 +66,9 @@ import { newObjectGRN, } from '..'; import { RpcQueryClient } from '../clients/queryclient'; -import { AuthType, SpClient } from '../clients/spclient/spClient'; +import { SpClient } from '../clients/spclient/spClient'; import { + AuthType, CreateObjectApprovalRequest, CreateObjectApprovalResponse, GetListObjectPoliciesRequest, diff --git a/packages/js-sdk/src/api/payment.ts b/packages/js-sdk/src/api/payment.ts index 1039e48a..77e062c5 100644 --- a/packages/js-sdk/src/api/payment.ts +++ b/packages/js-sdk/src/api/payment.ts @@ -29,6 +29,7 @@ import { } from '@bnb-chain/greenfield-cosmos-types/greenfield/payment/tx'; import { container, delay, inject, injectable } from 'tsyringe'; import { + AuthType, MsgDepositTypeUrl, MsgDisableRefundTypeUrl, MsgWithdrawTypeUrl, @@ -41,7 +42,7 @@ import { getListUserPaymentAccountMetaInfo, parseListUserPaymentAccountResponse, } from '../clients/spclient/spApis/listUserPaymentAccounts'; -import { AuthType, SpClient } from '../clients/spclient/spClient'; +import { SpClient } from '../clients/spclient/spClient'; import { TxClient } from '../clients/txClient'; import { MsgDepositSDKTypeEIP712 } from '../messages/greenfield/payment/MsgDeposit'; import { MsgDisableRefundSDKTypeEIP712 } from '../messages/greenfield/payment/MsgDisableRefund'; diff --git a/packages/js-sdk/src/clients/spclient/auth.ts b/packages/js-sdk/src/clients/spclient/auth.ts index 9fea4cd2..8d50a96e 100644 --- a/packages/js-sdk/src/clients/spclient/auth.ts +++ b/packages/js-sdk/src/clients/spclient/auth.ts @@ -1,11 +1,10 @@ import { signSignatureByEddsa } from '@/offchainauth'; -import { ReqMeta } from '@/types/auth'; +import { AuthType, ReqMeta } from '@/types/auth'; import { hexlify, joinSignature } from '@ethersproject/bytes'; import { SigningKey } from '@ethersproject/signing-key'; import { Headers } from 'cross-fetch'; import { keccak256 } from 'ethereum-cryptography/keccak.js'; import { utf8ToBytes } from 'ethereum-cryptography/utils.js'; -import { AuthType } from './spClient'; export const getCanonicalHeaders = (reqMeta: Partial, reqHeaders: Headers) => { const sortedHeaders = getSortedHeaders(reqHeaders, SUPPORTED_HEADERS); diff --git a/packages/js-sdk/src/clients/spclient/spClient.ts b/packages/js-sdk/src/clients/spclient/spClient.ts index 05db7865..9f748199 100644 --- a/packages/js-sdk/src/clients/spclient/spClient.ts +++ b/packages/js-sdk/src/clients/spclient/spClient.ts @@ -7,29 +7,11 @@ import { } from '@/clients/spclient/auth'; import { parseError } from '@/clients/spclient/spApis/parseError'; import { SP_NOT_AVAILABLE_ERROR_CODE, SP_NOT_AVAILABLE_ERROR_MSG } from '@/constants/http'; -import { ReqMeta } from '@/types/auth'; +import { AuthType, ReqMeta } from '@/types/auth'; import { injectable } from 'tsyringe'; import { getGetObjectMetaInfo } from './spApis/getObject'; import { getPutObjectMetaInfo } from './spApis/putObject'; -/** - * ECDSA Signature - */ -export type ECDSA = { - type: 'ECDSA'; - privateKey: string; -}; -/** - * EDDSA Signature - */ -export type EDDSA = { - type: 'EDDSA'; - seed: string; - domain: string; - address: string; -}; -export type AuthType = ECDSA | EDDSA; - export interface ISpClient { callApi( url: string, diff --git a/packages/js-sdk/src/types/auth.ts b/packages/js-sdk/src/types/auth.ts index a577d7c9..e77959b7 100644 --- a/packages/js-sdk/src/types/auth.ts +++ b/packages/js-sdk/src/types/auth.ts @@ -1,5 +1,23 @@ import { METHOD_GET, METHOD_POST, METHOD_PUT } from '@/constants/http'; +/** + * ECDSA Signature + */ +export type ECDSA = { + type: 'ECDSA'; + privateKey: string; +}; +/** + * EDDSA Signature + */ +export type EDDSA = { + type: 'EDDSA'; + seed: string; + domain: string; + address: string; +}; +export type AuthType = ECDSA | EDDSA; + export interface ReqMeta { method: typeof METHOD_GET | typeof METHOD_POST | typeof METHOD_PUT; contentType: string;