@polyester/sdk 0.3.0 → 0.4.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.
- package/CHANGELOG.md +44 -0
- package/README.md +63 -17
- package/dist/_virtual/_rolldown/runtime.js +15 -1
- package/dist/account-signer/types.d.ts.map +1 -1
- package/dist/account-signer/types.js +6 -3
- package/dist/account-signer/types.js.map +1 -1
- package/dist/browser-client.d.ts +4 -2
- package/dist/browser-client.d.ts.map +1 -1
- package/dist/browser-client.js +3 -4
- package/dist/browser-client.js.map +1 -1
- package/dist/catalogs/client-catalog.d.ts.map +1 -1
- package/dist/catalogs/client-catalog.js +11 -4
- package/dist/catalogs/client-catalog.js.map +1 -1
- package/dist/catalogs/index.js +1 -1
- package/dist/catalogs/readers.d.ts.map +1 -1
- package/dist/catalogs/readers.js +3 -1
- package/dist/catalogs/readers.js.map +1 -1
- package/dist/catalogs/snapshot-validation.js +132 -0
- package/dist/catalogs/snapshot-validation.js.map +1 -0
- package/dist/catalogs/snapshot.d.ts.map +1 -1
- package/dist/catalogs/snapshot.js +16 -7
- package/dist/catalogs/snapshot.js.map +1 -1
- package/dist/catalogs/zipper-supply.d.ts.map +1 -1
- package/dist/catalogs/zipper-supply.js +10 -7
- package/dist/catalogs/zipper-supply.js.map +1 -1
- package/dist/core-client.d.ts +24 -17
- package/dist/core-client.d.ts.map +1 -1
- package/dist/core-client.js +21 -3
- package/dist/core-client.js.map +1 -1
- package/dist/environment.d.ts.map +1 -1
- package/dist/environment.js +32 -1
- package/dist/environment.js.map +1 -1
- package/dist/gen/marketoverview/v1/marketoverview_pb.d.ts +7 -0
- package/dist/gen/marketoverview/v1/marketoverview_pb.d.ts.map +1 -1
- package/dist/gen/marketoverview/v1/marketoverview_pb.js +1 -1
- package/dist/gen/marketoverview/v1/marketoverview_pb.js.map +1 -1
- package/dist/index.js +3 -3
- package/dist/realtime/client.js +13 -2
- package/dist/realtime/client.js.map +1 -1
- package/dist/realtime/snapshot-then-stream.js +1 -1
- package/dist/realtime/snapshot-then-stream.js.map +1 -1
- package/dist/realtime/types.d.ts +2 -0
- package/dist/realtime/types.d.ts.map +1 -1
- package/dist/server-client.d.ts +17 -8
- package/dist/server-client.d.ts.map +1 -1
- package/dist/server-client.js +8 -11
- package/dist/server-client.js.map +1 -1
- package/dist/services/accounts/accounts.js +3 -3
- package/dist/services/accounts/accounts.js.map +1 -1
- package/dist/services/accounts/accounts.schemas.d.ts +13 -13
- package/dist/services/accounts/accounts.schemas.d.ts.map +1 -1
- package/dist/services/accounts/accounts.schemas.js +11 -11
- package/dist/services/accounts/accounts.schemas.js.map +1 -1
- package/dist/services/address-book/address-book.js +28 -28
- package/dist/services/address-book/address-book.js.map +1 -1
- package/dist/services/address-book/address-book.schemas.d.ts +751 -751
- package/dist/services/address-book/address-book.schemas.d.ts.map +1 -1
- package/dist/services/address-book/address-book.schemas.js +160 -160
- package/dist/services/address-book/address-book.schemas.js.map +1 -1
- package/dist/services/api-keys/api-keys.d.ts +6 -6
- package/dist/services/api-keys/api-keys.d.ts.map +1 -1
- package/dist/services/api-keys/api-keys.js +12 -12
- package/dist/services/api-keys/api-keys.js.map +1 -1
- package/dist/services/api-keys/api-keys.schemas.d.ts +62 -62
- package/dist/services/api-keys/api-keys.schemas.d.ts.map +1 -1
- package/dist/services/api-keys/api-keys.schemas.js +34 -34
- package/dist/services/api-keys/api-keys.schemas.js.map +1 -1
- package/dist/services/auth/auth.d.ts +46 -40
- package/dist/services/auth/auth.d.ts.map +1 -1
- package/dist/services/auth/auth.js +28 -25
- package/dist/services/auth/auth.js.map +1 -1
- package/dist/services/auth/profile/profile.d.ts +2 -2
- package/dist/services/auth/profile/profile.d.ts.map +1 -1
- package/dist/services/auth/profile/profile.js +7 -7
- package/dist/services/auth/profile/profile.js.map +1 -1
- package/dist/services/auth/profile/profile.schemas.d.ts +41 -41
- package/dist/services/auth/profile/profile.schemas.d.ts.map +1 -1
- package/dist/services/auth/profile/profile.schemas.js +27 -27
- package/dist/services/auth/profile/profile.schemas.js.map +1 -1
- package/dist/services/auth/session.d.ts +1 -1
- package/dist/services/auth/session.d.ts.map +1 -1
- package/dist/services/auth/session.js +6 -2
- package/dist/services/auth/session.js.map +1 -1
- package/dist/services/auth/session.schemas.js +17 -17
- package/dist/services/auth/session.schemas.js.map +1 -1
- package/dist/services/auth/session.types.d.ts +3 -2
- package/dist/services/auth/session.types.d.ts.map +1 -1
- package/dist/services/balances/balances.d.ts +1 -1
- package/dist/services/balances/balances.js +9 -9
- package/dist/services/balances/balances.js.map +1 -1
- package/dist/services/balances/balances.schemas.d.ts +95 -95
- package/dist/services/balances/balances.schemas.d.ts.map +1 -1
- package/dist/services/balances/balances.schemas.js +61 -61
- package/dist/services/balances/balances.schemas.js.map +1 -1
- package/dist/services/candles/candles.js +12 -12
- package/dist/services/candles/candles.js.map +1 -1
- package/dist/services/candles/candles.schemas.d.ts +64 -64
- package/dist/services/candles/candles.schemas.d.ts.map +1 -1
- package/dist/services/candles/candles.schemas.js +47 -48
- package/dist/services/candles/candles.schemas.js.map +1 -1
- package/dist/services/chain-analytics/chain-analytics.js +7 -7
- package/dist/services/chain-analytics/chain-analytics.js.map +1 -1
- package/dist/services/chain-analytics/chain-analytics.schemas.d.ts +68 -68
- package/dist/services/chain-analytics/chain-analytics.schemas.d.ts.map +1 -1
- package/dist/services/chain-analytics/chain-analytics.schemas.js +29 -29
- package/dist/services/chain-analytics/chain-analytics.schemas.js.map +1 -1
- package/dist/services/deposit/deposit.js +5 -5
- package/dist/services/deposit/deposit.js.map +1 -1
- package/dist/services/deposit/deposit.schemas.d.ts +17 -17
- package/dist/services/deposit/deposit.schemas.d.ts.map +1 -1
- package/dist/services/deposit/deposit.schemas.js +11 -11
- package/dist/services/deposit/deposit.schemas.js.map +1 -1
- package/dist/services/guard-signer/guard-signer.js +13 -13
- package/dist/services/guard-signer/guard-signer.js.map +1 -1
- package/dist/services/guard-signer/guard-signer.schemas.d.ts +75 -75
- package/dist/services/guard-signer/guard-signer.schemas.d.ts.map +1 -1
- package/dist/services/guard-signer/guard-signer.schemas.js +42 -42
- package/dist/services/guard-signer/guard-signer.schemas.js.map +1 -1
- package/dist/services/heatmap/heatmap.js +9 -9
- package/dist/services/heatmap/heatmap.js.map +1 -1
- package/dist/services/heatmap/heatmap.schemas.d.ts +141 -141
- package/dist/services/heatmap/heatmap.schemas.d.ts.map +1 -1
- package/dist/services/heatmap/heatmap.schemas.js +47 -47
- package/dist/services/heatmap/heatmap.schemas.js.map +1 -1
- package/dist/services/internal-transfers/internal-transfers.js +3 -3
- package/dist/services/internal-transfers/internal-transfers.js.map +1 -1
- package/dist/services/internal-transfers/internal-transfers.schemas.d.ts +53 -53
- package/dist/services/internal-transfers/internal-transfers.schemas.d.ts.map +1 -1
- package/dist/services/internal-transfers/internal-transfers.schemas.js +27 -27
- package/dist/services/internal-transfers/internal-transfers.schemas.js.map +1 -1
- package/dist/services/lifecycle/lifecycle.js +10 -10
- package/dist/services/lifecycle/lifecycle.js.map +1 -1
- package/dist/services/lifecycle/lifecycle.schemas.d.ts +614 -614
- package/dist/services/lifecycle/lifecycle.schemas.d.ts.map +1 -1
- package/dist/services/lifecycle/lifecycle.schemas.js +146 -146
- package/dist/services/lifecycle/lifecycle.schemas.js.map +1 -1
- package/dist/services/market-data/market-data.js +6 -6
- package/dist/services/market-data/market-data.js.map +1 -1
- package/dist/services/market-data/market-data.schemas.d.ts +20 -20
- package/dist/services/market-data/market-data.schemas.d.ts.map +1 -1
- package/dist/services/market-data/market-data.schemas.js +51 -55
- package/dist/services/market-data/market-data.schemas.js.map +1 -1
- package/dist/services/market-overview/market-overview.d.ts +1 -1
- package/dist/services/market-overview/market-overview.js +5 -5
- package/dist/services/market-overview/market-overview.js.map +1 -1
- package/dist/services/market-overview/market-overview.schemas.d.ts +39 -36
- package/dist/services/market-overview/market-overview.schemas.d.ts.map +1 -1
- package/dist/services/market-overview/market-overview.schemas.js +34 -32
- package/dist/services/market-overview/market-overview.schemas.js.map +1 -1
- package/dist/services/mfa/mfa.js +27 -27
- package/dist/services/mfa/mfa.js.map +1 -1
- package/dist/services/mfa/mfa.schemas.d.ts +206 -206
- package/dist/services/mfa/mfa.schemas.d.ts.map +1 -1
- package/dist/services/mfa/mfa.schemas.js +83 -83
- package/dist/services/mfa/mfa.schemas.js.map +1 -1
- package/dist/services/orderbook/orderbook.d.ts +2 -2
- package/dist/services/orderbook/orderbook.d.ts.map +1 -1
- package/dist/services/orderbook/orderbook.js +5 -5
- package/dist/services/orderbook/orderbook.js.map +1 -1
- package/dist/services/orderbook/orderbook.schemas.d.ts +23 -23
- package/dist/services/orderbook/orderbook.schemas.d.ts.map +1 -1
- package/dist/services/orderbook/orderbook.schemas.js +15 -15
- package/dist/services/orderbook/orderbook.schemas.js.map +1 -1
- package/dist/services/orders/order-errors.schemas.d.ts +18 -18
- package/dist/services/orders/order-errors.schemas.d.ts.map +1 -1
- package/dist/services/orders/order-errors.schemas.js +8 -8
- package/dist/services/orders/order-errors.schemas.js.map +1 -1
- package/dist/services/orders/orders-batch.schemas.d.ts +492 -492
- package/dist/services/orders/orders-batch.schemas.d.ts.map +1 -1
- package/dist/services/orders/orders-batch.schemas.js +118 -118
- package/dist/services/orders/orders-batch.schemas.js.map +1 -1
- package/dist/services/orders/orders-identifiers.schemas.js +5 -5
- package/dist/services/orders/orders-identifiers.schemas.js.map +1 -1
- package/dist/services/orders/orders-input.schemas.d.ts +657 -648
- package/dist/services/orders/orders-input.schemas.d.ts.map +1 -1
- package/dist/services/orders/orders-input.schemas.js +100 -96
- package/dist/services/orders/orders-input.schemas.js.map +1 -1
- package/dist/services/orders/orders-modify.schemas.d.ts +370 -351
- package/dist/services/orders/orders-modify.schemas.d.ts.map +1 -1
- package/dist/services/orders/orders-modify.schemas.js +48 -44
- package/dist/services/orders/orders-modify.schemas.js.map +1 -1
- package/dist/services/orders/orders-output.schemas.d.ts +179 -179
- package/dist/services/orders/orders-output.schemas.d.ts.map +1 -1
- package/dist/services/orders/orders-output.schemas.js +49 -49
- package/dist/services/orders/orders-output.schemas.js.map +1 -1
- package/dist/services/orders/orders-risk.schemas.d.ts +226 -226
- package/dist/services/orders/orders-risk.schemas.d.ts.map +1 -1
- package/dist/services/orders/orders-risk.schemas.js +69 -69
- package/dist/services/orders/orders-risk.schemas.js.map +1 -1
- package/dist/services/orders/orders.d.ts +8 -8
- package/dist/services/orders/orders.d.ts.map +1 -1
- package/dist/services/orders/orders.js +44 -32
- package/dist/services/orders/orders.js.map +1 -1
- package/dist/services/policies/api-key-policies/api-key-policies.d.ts +6 -6
- package/dist/services/policies/api-key-policies/api-key-policies.d.ts.map +1 -1
- package/dist/services/policies/api-key-policies/api-key-policies.js +11 -11
- package/dist/services/policies/api-key-policies/api-key-policies.js.map +1 -1
- package/dist/services/policies/api-key-policies/api-key-policies.schemas.d.ts +105 -105
- package/dist/services/policies/api-key-policies/api-key-policies.schemas.d.ts.map +1 -1
- package/dist/services/policies/api-key-policies/api-key-policies.schemas.js +49 -49
- package/dist/services/policies/api-key-policies/api-key-policies.schemas.js.map +1 -1
- package/dist/services/policies/shared.d.ts +5 -5
- package/dist/services/policies/shared.d.ts.map +1 -1
- package/dist/services/policies/shared.js +10 -10
- package/dist/services/policies/shared.js.map +1 -1
- package/dist/services/policies/subaccount-policies/subaccount-policies.d.ts +6 -6
- package/dist/services/policies/subaccount-policies/subaccount-policies.d.ts.map +1 -1
- package/dist/services/policies/subaccount-policies/subaccount-policies.js +13 -13
- package/dist/services/policies/subaccount-policies/subaccount-policies.js.map +1 -1
- package/dist/services/policies/subaccount-policies/subaccount-policies.schemas.d.ts +124 -124
- package/dist/services/policies/subaccount-policies/subaccount-policies.schemas.d.ts.map +1 -1
- package/dist/services/policies/subaccount-policies/subaccount-policies.schemas.js +75 -75
- package/dist/services/policies/subaccount-policies/subaccount-policies.schemas.js.map +1 -1
- package/dist/services/shared.js +11 -11
- package/dist/services/shared.js.map +1 -1
- package/dist/services/social-verification/social-verification.d.ts +3 -3
- package/dist/services/social-verification/social-verification.d.ts.map +1 -1
- package/dist/services/social-verification/social-verification.js +7 -7
- package/dist/services/social-verification/social-verification.js.map +1 -1
- package/dist/services/social-verification/social-verification.schemas.d.ts +54 -54
- package/dist/services/social-verification/social-verification.schemas.d.ts.map +1 -1
- package/dist/services/social-verification/social-verification.schemas.js +28 -28
- package/dist/services/social-verification/social-verification.schemas.js.map +1 -1
- package/dist/services/subaccount-resolver.js +5 -3
- package/dist/services/subaccount-resolver.js.map +1 -1
- package/dist/services/subaccounts/subaccounts.d.ts +15 -15
- package/dist/services/subaccounts/subaccounts.d.ts.map +1 -1
- package/dist/services/subaccounts/subaccounts.js +35 -35
- package/dist/services/subaccounts/subaccounts.js.map +1 -1
- package/dist/services/subaccounts/subaccounts.schemas.d.ts +137 -137
- package/dist/services/subaccounts/subaccounts.schemas.d.ts.map +1 -1
- package/dist/services/subaccounts/subaccounts.schemas.js +72 -72
- package/dist/services/subaccounts/subaccounts.schemas.js.map +1 -1
- package/dist/services/trades/trades.d.ts +2 -2
- package/dist/services/trades/trades.d.ts.map +1 -1
- package/dist/services/trades/trades.js +5 -5
- package/dist/services/trades/trades.js.map +1 -1
- package/dist/services/trades/trades.schemas.d.ts +31 -31
- package/dist/services/trades/trades.schemas.d.ts.map +1 -1
- package/dist/services/trades/trades.schemas.js +24 -24
- package/dist/services/trades/trades.schemas.js.map +1 -1
- package/dist/services/trading-withdraws/trading-withdraws.js +8 -8
- package/dist/services/trading-withdraws/trading-withdraws.js.map +1 -1
- package/dist/services/trading-withdraws/trading-withdraws.schemas.d.ts +45 -45
- package/dist/services/trading-withdraws/trading-withdraws.schemas.d.ts.map +1 -1
- package/dist/services/trading-withdraws/trading-withdraws.schemas.js +36 -36
- package/dist/services/trading-withdraws/trading-withdraws.schemas.js.map +1 -1
- package/dist/services/transfers/transfers.d.ts +1 -1
- package/dist/services/transfers/transfers.d.ts.map +1 -1
- package/dist/services/transfers/transfers.js +5 -5
- package/dist/services/transfers/transfers.js.map +1 -1
- package/dist/services/transfers/transfers.schemas.d.ts +42 -42
- package/dist/services/transfers/transfers.schemas.d.ts.map +1 -1
- package/dist/services/transfers/transfers.schemas.js +30 -30
- package/dist/services/transfers/transfers.schemas.js.map +1 -1
- package/dist/services/triggers/trigger-child-order.schemas.js +23 -23
- package/dist/services/triggers/trigger-child-order.schemas.js.map +1 -1
- package/dist/services/triggers/trigger-input.schemas.d.ts +226 -226
- package/dist/services/triggers/trigger-input.schemas.d.ts.map +1 -1
- package/dist/services/triggers/trigger-input.schemas.js +53 -53
- package/dist/services/triggers/trigger-input.schemas.js.map +1 -1
- package/dist/services/triggers/triggers-output.schemas.d.ts +218 -218
- package/dist/services/triggers/triggers-output.schemas.d.ts.map +1 -1
- package/dist/services/triggers/triggers-output.schemas.js +152 -152
- package/dist/services/triggers/triggers-output.schemas.js.map +1 -1
- package/dist/services/triggers/triggers.js +21 -21
- package/dist/services/triggers/triggers.js.map +1 -1
- package/dist/services/whiteboard/whiteboard.js +15 -15
- package/dist/services/whiteboard/whiteboard.js.map +1 -1
- package/dist/services/whiteboard/whiteboard.schemas.d.ts +379 -379
- package/dist/services/whiteboard/whiteboard.schemas.d.ts.map +1 -1
- package/dist/services/whiteboard/whiteboard.schemas.js +71 -71
- package/dist/services/whiteboard/whiteboard.schemas.js.map +1 -1
- package/dist/services/zipper/zipper.js +3 -3
- package/dist/services/zipper/zipper.js.map +1 -1
- package/dist/services/zipper/zipper.schemas.d.ts +1 -1
- package/dist/services/zipper/zipper.schemas.js +54 -54
- package/dist/services/zipper/zipper.schemas.js.map +1 -1
- package/dist/shared/account-scope.d.ts +6 -6
- package/dist/shared/account-scope.d.ts.map +1 -1
- package/dist/shared/account-scope.js +3 -3
- package/dist/shared/account-scope.js.map +1 -1
- package/dist/shared/connect-error-mapping.d.ts +1 -1
- package/dist/shared/connect-error-mapping.js +29 -3
- package/dist/shared/connect-error-mapping.js.map +1 -1
- package/dist/shared/rate-limit.schemas.d.ts +12 -12
- package/dist/shared/rate-limit.schemas.d.ts.map +1 -1
- package/dist/shared/rate-limit.schemas.js +7 -7
- package/dist/shared/rate-limit.schemas.js.map +1 -1
- package/dist/shared/schemas.js +26 -26
- package/dist/shared/schemas.js.map +1 -1
- package/dist/shared/transports.js +7 -12
- package/dist/shared/transports.js.map +1 -1
- package/dist/shared/types.d.ts +12 -0
- package/dist/shared/types.d.ts.map +1 -1
- package/dist/shared/validation.d.ts +14 -0
- package/dist/shared/validation.d.ts.map +1 -0
- package/dist/shared/validation.js +24 -0
- package/dist/shared/validation.js.map +1 -0
- package/dist/utils/connect-order-errors.js +2 -2
- package/dist/utils/connect-order-errors.js.map +1 -1
- package/dist/utils/cookies.d.ts +8 -3
- package/dist/utils/cookies.d.ts.map +1 -1
- package/dist/utils/cookies.js +7 -1
- package/dist/utils/cookies.js.map +1 -1
- package/dist/utils/event-emitter.d.ts +1 -1
- package/dist/utils/event-emitter.d.ts.map +1 -1
- package/dist/utils/event-emitter.js +4 -2
- package/dist/utils/event-emitter.js.map +1 -1
- package/dist/utils/evm.js +2 -2
- package/dist/utils/evm.js.map +1 -1
- package/dist/utils/jwt.d.ts +2 -2
- package/dist/utils/jwt.d.ts.map +1 -1
- package/dist/utils/jwt.js +2 -2
- package/dist/utils/jwt.js.map +1 -1
- package/package.json +1 -1
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { validation_exports } from "../../shared/validation.js";
|
|
1
2
|
import { requiredEnumLabel } from "../../shared/proto-enum-codec.js";
|
|
2
3
|
import { tsObjToMs, tsObjToNsString } from "../../utils/time.js";
|
|
3
4
|
import { BigIntStringSchema, OptionalPublicIdSchema, OptionalTimestampMsSchema, TimestampMsSchema, TimestampSchema, positiveBigintStringInputSchema } from "../../shared/schemas.js";
|
|
@@ -6,21 +7,20 @@ import { buildProtoPatch, defineProtoPatchFields } from "../../utils/proto-patch
|
|
|
6
7
|
import { toTimestamp } from "../../utils/timestamp.js";
|
|
7
8
|
import { AccountScopeInputEntries, accountScopeToSubaccountId } from "../../shared/account-scope.js";
|
|
8
9
|
import { API_KEY_STATUS_VALUES, API_KEY_UPDATE_STATUS_VALUES, ApiKeyStatusCodec } from "./api-keys.codecs.js";
|
|
9
|
-
import * as v from "valibot";
|
|
10
10
|
import { bytesToHex } from "@noble/hashes/utils.js";
|
|
11
11
|
//#region src/services/api-keys/api-keys.schemas.ts
|
|
12
|
-
|
|
13
|
-
const ApiKeyUpdateStatusSchema =
|
|
14
|
-
const ApiKeysListInputSchema =
|
|
15
|
-
const ApiKeyIdInputSchema =
|
|
16
|
-
const ApiKeysCreateInputSchema =
|
|
17
|
-
label:
|
|
18
|
-
icon:
|
|
19
|
-
color:
|
|
12
|
+
validation_exports.picklist(API_KEY_STATUS_VALUES);
|
|
13
|
+
const ApiKeyUpdateStatusSchema = validation_exports.picklist(API_KEY_UPDATE_STATUS_VALUES);
|
|
14
|
+
const ApiKeysListInputSchema = validation_exports.pipe(validation_exports.strictObject({ ...AccountScopeInputEntries }), validation_exports.transform(({ account }) => ({ subaccountId: accountScopeToSubaccountId(account) })));
|
|
15
|
+
const ApiKeyIdInputSchema = validation_exports.strictObject({ keyId: validation_exports.pipe(validation_exports.string(), validation_exports.trim(), validation_exports.minLength(1, "keyId is required")) });
|
|
16
|
+
const ApiKeysCreateInputSchema = validation_exports.pipe(validation_exports.strictObject({
|
|
17
|
+
label: validation_exports.string(),
|
|
18
|
+
icon: validation_exports.optional(validation_exports.string(), ""),
|
|
19
|
+
color: validation_exports.optional(validation_exports.string(), ""),
|
|
20
20
|
...AccountScopeInputEntries,
|
|
21
|
-
ipWhitelist:
|
|
22
|
-
publicKeyEd25519:
|
|
23
|
-
}),
|
|
21
|
+
ipWhitelist: validation_exports.optional(validation_exports.array(validation_exports.string()), []),
|
|
22
|
+
publicKeyEd25519: validation_exports.instance(Uint8Array)
|
|
23
|
+
}), validation_exports.transform(({ account, ...input }) => ({
|
|
24
24
|
...input,
|
|
25
25
|
subaccountId: accountScopeToSubaccountId(account)
|
|
26
26
|
})));
|
|
@@ -57,16 +57,16 @@ const API_KEY_PATCH_FIELDS = defineProtoPatchFields()({
|
|
|
57
57
|
}
|
|
58
58
|
}
|
|
59
59
|
});
|
|
60
|
-
const ApiKeysUpdateInputSchema =
|
|
61
|
-
keyId:
|
|
60
|
+
const ApiKeysUpdateInputSchema = validation_exports.pipe(validation_exports.strictObject({
|
|
61
|
+
keyId: validation_exports.pipe(validation_exports.string(), validation_exports.trim(), validation_exports.minLength(1, "keyId is required")),
|
|
62
62
|
expectedRevision: positiveBigintStringInputSchema("expectedRevision"),
|
|
63
|
-
label:
|
|
64
|
-
icon:
|
|
65
|
-
color:
|
|
66
|
-
status:
|
|
67
|
-
ipWhitelist:
|
|
68
|
-
expiresAtIso:
|
|
69
|
-
}),
|
|
63
|
+
label: validation_exports.optional(validation_exports.string()),
|
|
64
|
+
icon: validation_exports.optional(validation_exports.string()),
|
|
65
|
+
color: validation_exports.optional(validation_exports.string()),
|
|
66
|
+
status: validation_exports.optional(ApiKeyUpdateStatusSchema),
|
|
67
|
+
ipWhitelist: validation_exports.optional(validation_exports.array(validation_exports.string())),
|
|
68
|
+
expiresAtIso: validation_exports.optional(validation_exports.nullable(validation_exports.pipe(validation_exports.string(), validation_exports.check((value) => Number.isFinite(Date.parse(value)), "expiresAtIso must be a valid timestamp"))))
|
|
69
|
+
}), validation_exports.check(({ label, icon, color, status, ipWhitelist, expiresAtIso }) => label !== void 0 || icon !== void 0 || color !== void 0 || status !== void 0 || ipWhitelist !== void 0 || expiresAtIso !== void 0, "At least one API key field must be provided"), validation_exports.transform(({ keyId, expectedRevision, ...input }) => {
|
|
70
70
|
const { patch: apiKey, updateMask } = buildProtoPatch(input, API_KEY_PATCH_FIELDS);
|
|
71
71
|
return {
|
|
72
72
|
keyId,
|
|
@@ -75,26 +75,26 @@ const ApiKeysUpdateInputSchema = v.pipe(v.strictObject({
|
|
|
75
75
|
expectedRevision
|
|
76
76
|
};
|
|
77
77
|
}));
|
|
78
|
-
const ApiKeySchema =
|
|
79
|
-
keyId:
|
|
80
|
-
label:
|
|
81
|
-
icon:
|
|
82
|
-
color:
|
|
83
|
-
ipWhitelist:
|
|
78
|
+
const ApiKeySchema = validation_exports.pipe(validation_exports.object({
|
|
79
|
+
keyId: validation_exports.string(),
|
|
80
|
+
label: validation_exports.optional(validation_exports.string(), ""),
|
|
81
|
+
icon: validation_exports.optional(validation_exports.string(), ""),
|
|
82
|
+
color: validation_exports.optional(validation_exports.string(), ""),
|
|
83
|
+
ipWhitelist: validation_exports.optional(validation_exports.array(validation_exports.string()), []),
|
|
84
84
|
subaccountId: OptionalPublicIdSchema,
|
|
85
85
|
policyId: OptionalPublicIdSchema,
|
|
86
86
|
createdAt: TimestampMsSchema,
|
|
87
|
-
updatedAt:
|
|
87
|
+
updatedAt: validation_exports.optional(TimestampSchema),
|
|
88
88
|
lastUsedAt: OptionalTimestampMsSchema,
|
|
89
|
-
publicKeyEd25519:
|
|
90
|
-
expiresAt:
|
|
89
|
+
publicKeyEd25519: validation_exports.instance(Uint8Array),
|
|
90
|
+
expiresAt: validation_exports.pipe(validation_exports.optional(TimestampSchema), validation_exports.transform((v) => {
|
|
91
91
|
const ms = tsObjToMs(v);
|
|
92
92
|
return ms ? new Date(ms).toISOString() : void 0;
|
|
93
93
|
})),
|
|
94
|
-
status:
|
|
95
|
-
createdByActor:
|
|
94
|
+
status: validation_exports.pipe(validation_exports.enum(ApiKeyStatus), validation_exports.transform((v) => requiredEnumLabel(ApiKeyStatusCodec.protoToOutput, v, "PolyesterClient.ApiKeySchema", "status"))),
|
|
95
|
+
createdByActor: validation_exports.string(),
|
|
96
96
|
revision: BigIntStringSchema
|
|
97
|
-
}),
|
|
97
|
+
}), validation_exports.transform(({ subaccountId, updatedAt, ...rest }) => {
|
|
98
98
|
const hex = bytesToHex(rest.publicKeyEd25519);
|
|
99
99
|
return {
|
|
100
100
|
...rest,
|
|
@@ -104,7 +104,7 @@ const ApiKeySchema = v.pipe(v.object({
|
|
|
104
104
|
publicKeyHex: hex
|
|
105
105
|
};
|
|
106
106
|
}));
|
|
107
|
-
const ApiKeysSchema =
|
|
107
|
+
const ApiKeysSchema = validation_exports.array(ApiKeySchema);
|
|
108
108
|
//#endregion
|
|
109
109
|
export { ApiKeyIdInputSchema, ApiKeySchema, ApiKeysCreateInputSchema, ApiKeysListInputSchema, ApiKeysSchema, ApiKeysUpdateInputSchema };
|
|
110
110
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"api-keys.schemas.js","names":["Proto.ApiKeyStatus"],"sources":["../../../src/services/api-keys/api-keys.schemas.ts"],"sourcesContent":["import * as Proto from \"../../gen/auth/v1/api_keys_pb.js\";\nimport * as v from \"
|
|
1
|
+
{"version":3,"file":"api-keys.schemas.js","names":["v","Proto.ApiKeyStatus"],"sources":["../../../src/services/api-keys/api-keys.schemas.ts"],"sourcesContent":["import * as Proto from \"../../gen/auth/v1/api_keys_pb.js\";\nimport * as v from \"../../shared/validation.js\";\nimport { toTimestamp } from \"../../utils/timestamp.js\";\nimport { tsObjToMs, tsObjToNsString } from \"../../utils/time.js\";\nimport {\n OptionalPublicIdSchema,\n OptionalTimestampMsSchema,\n BigIntStringSchema,\n TimestampMsSchema,\n TimestampSchema,\n positiveBigintStringInputSchema,\n} from \"../../shared/schemas.js\";\nimport {\n AccountScopeInputEntries,\n accountScopeToSubaccountId,\n} from \"../../shared/account-scope.js\";\nimport { requiredEnumLabel } from \"../../shared/proto-enum-codec.js\";\nimport { bytesToHex } from \"@noble/hashes/utils.js\";\nimport {\n API_KEY_STATUS_VALUES,\n API_KEY_UPDATE_STATUS_VALUES,\n ApiKeyStatusCodec,\n} from \"./api-keys.codecs.js\";\nimport { buildProtoPatch, defineProtoPatchFields } from \"../../utils/proto-patch.js\";\n\nconst ApiKeyStatusSchema = v.picklist(API_KEY_STATUS_VALUES);\nconst ApiKeyUpdateStatusSchema = v.picklist(API_KEY_UPDATE_STATUS_VALUES);\n\nexport type ApiKeyStatus = v.InferOutput<typeof ApiKeyStatusSchema>;\n\nexport const ApiKeysListInputSchema = v.pipe(\n v.strictObject({\n ...AccountScopeInputEntries,\n }),\n v.transform(({ account }) => ({\n subaccountId: accountScopeToSubaccountId(account),\n })),\n);\n\nexport type ApiKeysListInput = v.InferInput<typeof ApiKeysListInputSchema>;\n\nexport const ApiKeyIdInputSchema = v.strictObject({\n keyId: v.pipe(v.string(), v.trim(), v.minLength(1, \"keyId is required\")),\n});\n\nexport type ApiKeyIdInput = v.InferInput<typeof ApiKeyIdInputSchema>;\n\nexport const ApiKeysCreateInputSchema = v.pipe(\n v.strictObject({\n label: v.string(),\n icon: v.optional(v.string(), \"\"),\n color: v.optional(v.string(), \"\"),\n ...AccountScopeInputEntries,\n ipWhitelist: v.optional(v.array(v.string()), []),\n publicKeyEd25519: v.instance(Uint8Array<ArrayBufferLike>),\n }),\n v.transform(({ account, ...input }) => ({\n ...input,\n subaccountId: accountScopeToSubaccountId(account),\n })),\n);\n\nexport type ApiKeysCreateInput = v.InferInput<typeof ApiKeysCreateInputSchema>;\n\ntype ApiKeyPatch = {\n label?: string;\n icon?: string;\n color?: string;\n status?: v.InferOutput<typeof ApiKeyUpdateStatusSchema>;\n ipWhitelist?: string[];\n expiresAtIso?: string | null;\n};\n\nconst API_KEY_PATCH_FIELDS = defineProtoPatchFields<ApiKeyPatch>()({\n label: { path: \"label\", encode: (label) => ({ label }) },\n icon: { path: \"icon\", encode: (icon) => ({ icon }) },\n color: { path: \"color\", encode: (color) => ({ color }) },\n status: {\n path: \"status\",\n encode: (status) => ({ status: ApiKeyStatusCodec.inputToProto[status] }),\n },\n ipWhitelist: {\n path: \"ip_whitelist\",\n encode: (ipWhitelist) => ({ ipWhitelist }),\n },\n expiresAtIso: {\n path: \"expires_at\",\n encode: (expiresAtIso) => {\n if (expiresAtIso === null) return {};\n const expiresAtMs = new Date(expiresAtIso).getTime();\n return {\n expiresAt: toTimestamp({\n seconds: BigInt(Math.floor(expiresAtMs / 1000)),\n nanos: (expiresAtMs % 1000) * 1_000_000,\n }),\n };\n },\n },\n});\n\nexport const ApiKeysUpdateInputSchema = v.pipe(\n v.strictObject({\n keyId: v.pipe(v.string(), v.trim(), v.minLength(1, \"keyId is required\")),\n expectedRevision: positiveBigintStringInputSchema(\"expectedRevision\"),\n label: v.optional(v.string()),\n icon: v.optional(v.string()),\n color: v.optional(v.string()),\n status: v.optional(ApiKeyUpdateStatusSchema),\n ipWhitelist: v.optional(v.array(v.string())),\n expiresAtIso: v.optional(\n v.nullable(\n v.pipe(\n v.string(),\n v.check(\n (value) => Number.isFinite(Date.parse(value)),\n \"expiresAtIso must be a valid timestamp\",\n ),\n ),\n ),\n ),\n }),\n v.check(\n ({ label, icon, color, status, ipWhitelist, expiresAtIso }) =>\n label !== undefined ||\n icon !== undefined ||\n color !== undefined ||\n status !== undefined ||\n ipWhitelist !== undefined ||\n expiresAtIso !== undefined,\n \"At least one API key field must be provided\",\n ),\n v.transform(({ keyId, expectedRevision, ...input }) => {\n const { patch: apiKey, updateMask } = buildProtoPatch(input, API_KEY_PATCH_FIELDS);\n return { keyId, apiKey, updateMask, expectedRevision };\n }),\n);\n\nexport type ApiKeysUpdateInput = v.InferInput<typeof ApiKeysUpdateInputSchema>;\n\nexport const ApiKeySchema = v.pipe(\n v.object({\n keyId: v.string(),\n label: v.optional(v.string(), \"\"),\n icon: v.optional(v.string(), \"\"),\n color: v.optional(v.string(), \"\"),\n ipWhitelist: v.optional(v.array(v.string()), []),\n subaccountId: OptionalPublicIdSchema,\n policyId: OptionalPublicIdSchema,\n createdAt: TimestampMsSchema,\n updatedAt: v.optional(TimestampSchema),\n lastUsedAt: OptionalTimestampMsSchema,\n publicKeyEd25519: v.instance(Uint8Array<ArrayBufferLike>),\n expiresAt: v.pipe(\n v.optional(TimestampSchema),\n v.transform((v) => {\n const ms = tsObjToMs(v);\n return ms ? new Date(ms).toISOString() : undefined;\n }),\n ),\n status: v.pipe(\n v.enum(Proto.ApiKeyStatus),\n v.transform((v) =>\n requiredEnumLabel(\n ApiKeyStatusCodec.protoToOutput,\n v,\n \"PolyesterClient.ApiKeySchema\",\n \"status\",\n ),\n ),\n ),\n createdByActor: v.string(),\n revision: BigIntStringSchema,\n }),\n v.transform(({ subaccountId, updatedAt, ...rest }) => {\n const hex = bytesToHex(rest.publicKeyEd25519);\n return {\n ...rest,\n subaccountId,\n updatedAt: tsObjToMs(updatedAt),\n updatedAtNs: tsObjToNsString(updatedAt),\n publicKeyHex: hex,\n };\n }),\n);\n\nexport type ApiKey = v.InferOutput<typeof ApiKeySchema>;\n\nexport const ApiKeysSchema = v.array(ApiKeySchema);\n"],"mappings":"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"}
|
|
@@ -1,41 +1,41 @@
|
|
|
1
|
+
import { validation_d_exports } from "../../shared/validation.js";
|
|
1
2
|
import { SessionLevel } from "../../gen/auth/v1/mfa_pb.js";
|
|
2
3
|
import { PolyesterMutationOptions, PolyesterRequestOptions } from "../../shared/request-options.js";
|
|
3
4
|
import { PolyesterRealtime } from "../../realtime/types.js";
|
|
4
5
|
import "../../realtime/index.js";
|
|
5
6
|
import { ProfileService } from "./profile/profile.js";
|
|
6
7
|
import { Transport } from "@connectrpc/connect";
|
|
7
|
-
import * as v from "valibot";
|
|
8
8
|
//#region src/services/auth/auth.d.ts
|
|
9
|
-
declare const LoginWithWalletInputSchema:
|
|
10
|
-
readonly smartAccountAddress:
|
|
11
|
-
readonly nonce:
|
|
12
|
-
readonly signature:
|
|
13
|
-
readonly userAgent:
|
|
14
|
-
readonly ip:
|
|
15
|
-
readonly primaryWalletAddress:
|
|
16
|
-
readonly walletProvider:
|
|
9
|
+
declare const LoginWithWalletInputSchema: validation_d_exports.StrictObjectSchema<{
|
|
10
|
+
readonly smartAccountAddress: validation_d_exports.StringSchema<undefined>;
|
|
11
|
+
readonly nonce: validation_d_exports.StringSchema<undefined>;
|
|
12
|
+
readonly signature: validation_d_exports.StringSchema<undefined>;
|
|
13
|
+
readonly userAgent: validation_d_exports.OptionalSchema<validation_d_exports.StringSchema<undefined>, "">;
|
|
14
|
+
readonly ip: validation_d_exports.OptionalSchema<validation_d_exports.StringSchema<undefined>, "">;
|
|
15
|
+
readonly primaryWalletAddress: validation_d_exports.OptionalSchema<validation_d_exports.StringSchema<undefined>, "">;
|
|
16
|
+
readonly walletProvider: validation_d_exports.OptionalSchema<validation_d_exports.StringSchema<undefined>, "">;
|
|
17
17
|
}, undefined>;
|
|
18
|
-
type LoginWithWalletInput =
|
|
18
|
+
type LoginWithWalletInput = validation_d_exports.InferInput<typeof LoginWithWalletInputSchema>;
|
|
19
19
|
interface AuthServiceTransports {
|
|
20
20
|
publicApi: Transport;
|
|
21
21
|
authApi: Transport;
|
|
22
22
|
}
|
|
23
|
-
declare const MeSchema:
|
|
24
|
-
readonly accountId:
|
|
25
|
-
readonly apiKeyId:
|
|
26
|
-
readonly username:
|
|
27
|
-
readonly session:
|
|
28
|
-
readonly sessionId:
|
|
29
|
-
readonly sessionLevel:
|
|
30
|
-
readonly authenticationMethods:
|
|
31
|
-
readonly authTime:
|
|
32
|
-
readonly seconds:
|
|
33
|
-
readonly nanos:
|
|
34
|
-
}, undefined>, undefined>,
|
|
23
|
+
declare const MeSchema: validation_d_exports.ObjectSchema<{
|
|
24
|
+
readonly accountId: validation_d_exports.SchemaWithPipe<readonly [validation_d_exports.BigintSchema<undefined>, validation_d_exports.TransformAction<bigint, string>]>;
|
|
25
|
+
readonly apiKeyId: validation_d_exports.SchemaWithPipe<readonly [validation_d_exports.OptionalSchema<validation_d_exports.BigintSchema<undefined>, undefined>, validation_d_exports.TransformAction<bigint | undefined, string | undefined>]>;
|
|
26
|
+
readonly username: validation_d_exports.StringSchema<undefined>;
|
|
27
|
+
readonly session: validation_d_exports.OptionalSchema<validation_d_exports.SchemaWithPipe<readonly [validation_d_exports.ObjectSchema<{
|
|
28
|
+
readonly sessionId: validation_d_exports.StringSchema<undefined>;
|
|
29
|
+
readonly sessionLevel: validation_d_exports.SchemaWithPipe<readonly [validation_d_exports.EnumSchema<typeof SessionLevel, undefined>, validation_d_exports.TransformAction<SessionLevel, "unspecified" | "primaryAuthenticated" | "mfaElevated" | "freshStepUp">]>;
|
|
30
|
+
readonly authenticationMethods: validation_d_exports.OptionalSchema<validation_d_exports.ArraySchema<validation_d_exports.StringSchema<undefined>, undefined>, readonly []>;
|
|
31
|
+
readonly authTime: validation_d_exports.SchemaWithPipe<readonly [validation_d_exports.OptionalSchema<validation_d_exports.ObjectSchema<{
|
|
32
|
+
readonly seconds: validation_d_exports.BigintSchema<undefined>;
|
|
33
|
+
readonly nanos: validation_d_exports.OptionalSchema<validation_d_exports.NumberSchema<undefined>, 0>;
|
|
34
|
+
}, undefined>, undefined>, validation_d_exports.TransformAction<{
|
|
35
35
|
seconds: bigint;
|
|
36
36
|
nanos: number;
|
|
37
37
|
} | undefined, number | undefined>]>;
|
|
38
|
-
}, undefined>,
|
|
38
|
+
}, undefined>, validation_d_exports.TransformAction<{
|
|
39
39
|
sessionId: string;
|
|
40
40
|
sessionLevel: "unspecified" | "primaryAuthenticated" | "mfaElevated" | "freshStepUp";
|
|
41
41
|
authenticationMethods: string[];
|
|
@@ -47,25 +47,28 @@ declare const MeSchema: v.ObjectSchema<{
|
|
|
47
47
|
authTimeMs: number | undefined;
|
|
48
48
|
}>]>, undefined>;
|
|
49
49
|
}, undefined>;
|
|
50
|
-
type Me =
|
|
51
|
-
declare const LoginWithWalletResponseSchema:
|
|
52
|
-
readonly accessToken:
|
|
53
|
-
readonly expiresAt:
|
|
54
|
-
readonly seconds:
|
|
55
|
-
readonly nanos:
|
|
50
|
+
type Me = validation_d_exports.InferOutput<typeof MeSchema>;
|
|
51
|
+
declare const LoginWithWalletResponseSchema: validation_d_exports.ObjectSchema<{
|
|
52
|
+
readonly accessToken: validation_d_exports.StringSchema<undefined>;
|
|
53
|
+
readonly expiresAt: validation_d_exports.OptionalSchema<validation_d_exports.ObjectSchema<{
|
|
54
|
+
readonly seconds: validation_d_exports.BigintSchema<undefined>;
|
|
55
|
+
readonly nanos: validation_d_exports.OptionalSchema<validation_d_exports.NumberSchema<undefined>, 0>;
|
|
56
56
|
}, undefined>, undefined>;
|
|
57
|
-
readonly accountId:
|
|
58
|
-
readonly username:
|
|
57
|
+
readonly accountId: validation_d_exports.SchemaWithPipe<readonly [validation_d_exports.BigintSchema<undefined>, validation_d_exports.TransformAction<bigint, string>]>;
|
|
58
|
+
readonly username: validation_d_exports.StringSchema<undefined>;
|
|
59
59
|
}, undefined>;
|
|
60
|
-
type LoginWithWalletResponse =
|
|
61
|
-
declare const NonceSchema:
|
|
62
|
-
readonly nonce:
|
|
63
|
-
readonly expiresAt:
|
|
64
|
-
readonly seconds:
|
|
65
|
-
readonly nanos:
|
|
66
|
-
}, undefined>, undefined
|
|
60
|
+
type LoginWithWalletResponse = validation_d_exports.InferOutput<typeof LoginWithWalletResponseSchema>;
|
|
61
|
+
declare const NonceSchema: validation_d_exports.ObjectSchema<{
|
|
62
|
+
readonly nonce: validation_d_exports.StringSchema<undefined>;
|
|
63
|
+
readonly expiresAt: validation_d_exports.SchemaWithPipe<readonly [validation_d_exports.OptionalSchema<validation_d_exports.ObjectSchema<{
|
|
64
|
+
readonly seconds: validation_d_exports.BigintSchema<undefined>;
|
|
65
|
+
readonly nanos: validation_d_exports.OptionalSchema<validation_d_exports.NumberSchema<undefined>, 0>;
|
|
66
|
+
}, undefined>, undefined>, validation_d_exports.TransformAction<{
|
|
67
|
+
seconds: bigint;
|
|
68
|
+
nanos: number;
|
|
69
|
+
} | undefined, number | undefined>]>;
|
|
67
70
|
}, undefined>;
|
|
68
|
-
type Nonce =
|
|
71
|
+
type Nonce = validation_d_exports.InferOutput<typeof NonceSchema>;
|
|
69
72
|
/**
|
|
70
73
|
* Handles wallet-based authentication, caller introspection, and authenticated profile operations.
|
|
71
74
|
*/
|
|
@@ -78,7 +81,10 @@ declare class AuthService {
|
|
|
78
81
|
*/
|
|
79
82
|
me(options?: PolyesterRequestOptions): Promise<Me>;
|
|
80
83
|
/**
|
|
81
|
-
* Requests a short-lived nonce for the given smart-account EVM address
|
|
84
|
+
* Requests a short-lived nonce for the given smart-account EVM address.
|
|
85
|
+
* The nonce is single-purpose, replaced by subsequent requests, and expires
|
|
86
|
+
* after about five minutes. The optional expiry is milliseconds since the
|
|
87
|
+
* Unix epoch.
|
|
82
88
|
*/
|
|
83
89
|
requestLoginNonce(smartAccountAddress: string, options?: PolyesterRequestOptions): Promise<Nonce>;
|
|
84
90
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"auth.d.ts","names":[],"sources":["../../../src/services/auth/auth.ts"],"mappings":";;;;;;;;
|
|
1
|
+
{"version":3,"file":"auth.d.ts","names":[],"sources":["../../../src/services/auth/auth.ts"],"mappings":";;;;;;;;cAkBa,4BAA0B,qBAAA;;;;;;;;;KAU3B,uBAAuB,qBAAE,kBAAkB;UAEtC;EACb,WAAW;EACX,SAAS;;cAGP,UAAQ,qBAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;KAOF,KAAK,qBAAE,mBAAmB;cAEhC,+BAA6B,qBAAA;;;;;;;;;KAOvB,0BAA0B,qBAAE,mBAAmB;cAErD,aAAW,qBAAA;;;;;;;;;;KAKL,QAAQ,qBAAE,mBAAmB;;;;cAK5B;;EAGT,SAAS;EAEG,YAAA,YAAY,uBAAuB,UAAU;;;;EASnD,GAAG,UAAU,0BAA0B,QAAQ;;;;;;;EAW/C,kBACF,6BACA,UAAU,0BACX,QAAQ;;;;YAaK,gBACZ,OAAO,sBACP,UAAU,2BACX,QAAQ"}
|
|
@@ -1,35 +1,35 @@
|
|
|
1
|
+
import { parse, validation_exports } from "../../shared/validation.js";
|
|
1
2
|
import { AuthService as AuthService$1 } from "../../gen/auth/v1/auth_pb.js";
|
|
2
|
-
import { OptionalPublicIdSchema, PublicIdSchema, TimestampSchema } from "../../shared/schemas.js";
|
|
3
|
+
import { OptionalPublicIdSchema, OptionalTimestampMsSchema, PublicIdSchema, TimestampSchema } from "../../shared/schemas.js";
|
|
3
4
|
import { toConnectCallOptions } from "../../shared/request-options.js";
|
|
4
5
|
import { ProfileService } from "./profile/profile.js";
|
|
5
6
|
import { MfaSessionInfoSchema } from "../mfa/mfa.schemas.js";
|
|
6
7
|
import { createClient } from "@connectrpc/connect";
|
|
7
|
-
import * as v from "valibot";
|
|
8
8
|
//#region src/services/auth/auth.ts
|
|
9
|
-
const LoginWithWalletInputSchema =
|
|
10
|
-
smartAccountAddress:
|
|
11
|
-
nonce:
|
|
12
|
-
signature:
|
|
13
|
-
userAgent:
|
|
14
|
-
ip:
|
|
15
|
-
primaryWalletAddress:
|
|
16
|
-
walletProvider:
|
|
9
|
+
const LoginWithWalletInputSchema = validation_exports.strictObject({
|
|
10
|
+
smartAccountAddress: validation_exports.string(),
|
|
11
|
+
nonce: validation_exports.string(),
|
|
12
|
+
signature: validation_exports.string(),
|
|
13
|
+
userAgent: validation_exports.optional(validation_exports.string(), ""),
|
|
14
|
+
ip: validation_exports.optional(validation_exports.string(), ""),
|
|
15
|
+
primaryWalletAddress: validation_exports.optional(validation_exports.string(), ""),
|
|
16
|
+
walletProvider: validation_exports.optional(validation_exports.string(), "")
|
|
17
17
|
});
|
|
18
|
-
const MeSchema =
|
|
18
|
+
const MeSchema = validation_exports.object({
|
|
19
19
|
accountId: PublicIdSchema,
|
|
20
20
|
apiKeyId: OptionalPublicIdSchema,
|
|
21
|
-
username:
|
|
22
|
-
session:
|
|
21
|
+
username: validation_exports.string(),
|
|
22
|
+
session: validation_exports.optional(MfaSessionInfoSchema)
|
|
23
23
|
});
|
|
24
|
-
const LoginWithWalletResponseSchema =
|
|
25
|
-
accessToken:
|
|
26
|
-
expiresAt:
|
|
24
|
+
const LoginWithWalletResponseSchema = validation_exports.object({
|
|
25
|
+
accessToken: validation_exports.string(),
|
|
26
|
+
expiresAt: validation_exports.optional(TimestampSchema),
|
|
27
27
|
accountId: PublicIdSchema,
|
|
28
|
-
username:
|
|
28
|
+
username: validation_exports.string()
|
|
29
29
|
});
|
|
30
|
-
const NonceSchema =
|
|
31
|
-
nonce:
|
|
32
|
-
expiresAt:
|
|
30
|
+
const NonceSchema = validation_exports.object({
|
|
31
|
+
nonce: validation_exports.string(),
|
|
32
|
+
expiresAt: OptionalTimestampMsSchema
|
|
33
33
|
});
|
|
34
34
|
/**
|
|
35
35
|
* Handles wallet-based authentication, caller introspection, and authenticated profile operations.
|
|
@@ -48,21 +48,24 @@ var AuthService = class {
|
|
|
48
48
|
*/
|
|
49
49
|
async me(options) {
|
|
50
50
|
const res = await this.#authClient.me({}, toConnectCallOptions(options));
|
|
51
|
-
return
|
|
51
|
+
return parse(MeSchema, res);
|
|
52
52
|
}
|
|
53
53
|
/**
|
|
54
|
-
* Requests a short-lived nonce for the given smart-account EVM address
|
|
54
|
+
* Requests a short-lived nonce for the given smart-account EVM address.
|
|
55
|
+
* The nonce is single-purpose, replaced by subsequent requests, and expires
|
|
56
|
+
* after about five minutes. The optional expiry is milliseconds since the
|
|
57
|
+
* Unix epoch.
|
|
55
58
|
*/
|
|
56
59
|
async requestLoginNonce(smartAccountAddress, options) {
|
|
57
|
-
return
|
|
60
|
+
return parse(NonceSchema, await this.#publicClient.getNonce({ smartAccountAddress }, toConnectCallOptions(options)));
|
|
58
61
|
}
|
|
59
62
|
/**
|
|
60
63
|
* Exchanges a signed login nonce for an authenticated session token and account identity returned by the auth API.
|
|
61
64
|
*/
|
|
62
65
|
async loginWithWallet(input, options) {
|
|
63
|
-
const validatedInput =
|
|
66
|
+
const validatedInput = parse(LoginWithWalletInputSchema, input);
|
|
64
67
|
const res = await this.#publicClient.loginWithWallet(validatedInput, toConnectCallOptions(options));
|
|
65
|
-
return
|
|
68
|
+
return parse(LoginWithWalletResponseSchema, res);
|
|
66
69
|
}
|
|
67
70
|
};
|
|
68
71
|
//#endregion
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"auth.js","names":["#publicClient","Proto.AuthService","#authClient"],"sources":["../../../src/services/auth/auth.ts"],"sourcesContent":["import { createClient, type Client, type Transport } from \"@connectrpc/connect\";\nimport * as Proto from \"../../gen/auth/v1/auth_pb.js\";\nimport * as v from \"
|
|
1
|
+
{"version":3,"file":"auth.js","names":["v","#publicClient","Proto.AuthService","#authClient","v.parse"],"sources":["../../../src/services/auth/auth.ts"],"sourcesContent":["import { createClient, type Client, type Transport } from \"@connectrpc/connect\";\nimport * as Proto from \"../../gen/auth/v1/auth_pb.js\";\nimport * as v from \"../../shared/validation.js\";\nimport { ProfileService } from \"./profile/profile.js\";\nimport {\n OptionalPublicIdSchema,\n OptionalTimestampMsSchema,\n PublicIdSchema,\n TimestampSchema,\n} from \"../../shared/schemas.js\";\nimport {\n toConnectCallOptions,\n type PolyesterMutationOptions,\n type PolyesterRequestOptions,\n} from \"../../shared/request-options.js\";\nimport { MfaSessionInfoSchema } from \"../mfa/mfa.schemas.js\";\nimport type { PolyesterRealtime } from \"../../realtime/index.js\";\n\nexport const LoginWithWalletInputSchema = v.strictObject({\n smartAccountAddress: v.string(),\n nonce: v.string(),\n signature: v.string(),\n userAgent: v.optional(v.string(), \"\"),\n ip: v.optional(v.string(), \"\"),\n primaryWalletAddress: v.optional(v.string(), \"\"),\n walletProvider: v.optional(v.string(), \"\"),\n});\n\nexport type LoginWithWalletInput = v.InferInput<typeof LoginWithWalletInputSchema>;\n\nexport interface AuthServiceTransports {\n publicApi: Transport;\n authApi: Transport;\n}\n\nconst MeSchema = v.object({\n accountId: PublicIdSchema,\n apiKeyId: OptionalPublicIdSchema,\n username: v.string(),\n session: v.optional(MfaSessionInfoSchema),\n});\n\nexport type Me = v.InferOutput<typeof MeSchema>;\n\nconst LoginWithWalletResponseSchema = v.object({\n accessToken: v.string(),\n expiresAt: v.optional(TimestampSchema),\n accountId: PublicIdSchema,\n username: v.string(),\n});\n\nexport type LoginWithWalletResponse = v.InferOutput<typeof LoginWithWalletResponseSchema>;\n\nconst NonceSchema = v.object({\n nonce: v.string(),\n expiresAt: OptionalTimestampMsSchema,\n});\n\nexport type Nonce = v.InferOutput<typeof NonceSchema>;\n\n/**\n * Handles wallet-based authentication, caller introspection, and authenticated profile operations.\n */\nexport class AuthService {\n #publicClient: Client<typeof Proto.AuthService>;\n #authClient: Client<typeof Proto.AuthService>;\n profile: ProfileService;\n\n constructor(transports: AuthServiceTransports, realtime: PolyesterRealtime) {\n this.#publicClient = createClient(Proto.AuthService, transports.publicApi);\n this.#authClient = createClient(Proto.AuthService, transports.authApi);\n this.profile = new ProfileService(transports.authApi, realtime);\n }\n\n /**\n * Returns the authenticated caller's account context, including account ID, optional API key ID, username, and session assurance details from the presented token or API key.\n */\n async me(options?: PolyesterRequestOptions): Promise<Me> {\n const res = await this.#authClient.me({}, toConnectCallOptions(options));\n return v.parse(MeSchema, res);\n }\n\n /**\n * Requests a short-lived nonce for the given smart-account EVM address.\n * The nonce is single-purpose, replaced by subsequent requests, and expires\n * after about five minutes. The optional expiry is milliseconds since the\n * Unix epoch.\n */\n async requestLoginNonce(\n smartAccountAddress: string,\n options?: PolyesterRequestOptions,\n ): Promise<Nonce> {\n return v.parse(\n NonceSchema,\n await this.#publicClient.getNonce(\n { smartAccountAddress },\n toConnectCallOptions(options),\n ),\n );\n }\n\n /**\n * Exchanges a signed login nonce for an authenticated session token and account identity returned by the auth API.\n */\n protected async loginWithWallet(\n input: LoginWithWalletInput,\n options?: PolyesterMutationOptions,\n ): Promise<LoginWithWalletResponse> {\n const validatedInput = v.parse(LoginWithWalletInputSchema, input);\n const res = await this.#publicClient.loginWithWallet(\n validatedInput,\n toConnectCallOptions(options),\n );\n return v.parse(LoginWithWalletResponseSchema, res);\n }\n}\n"],"mappings":";;;;;;;;AAkBA,MAAa,6BAA6BA,mBAAE,aAAa;CACrD,qBAAqBA,mBAAE,OAAO;CAC9B,OAAOA,mBAAE,OAAO;CAChB,WAAWA,mBAAE,OAAO;CACpB,WAAWA,mBAAE,SAASA,mBAAE,OAAO,GAAG,EAAE;CACpC,IAAIA,mBAAE,SAASA,mBAAE,OAAO,GAAG,EAAE;CAC7B,sBAAsBA,mBAAE,SAASA,mBAAE,OAAO,GAAG,EAAE;CAC/C,gBAAgBA,mBAAE,SAASA,mBAAE,OAAO,GAAG,EAAE;AAC7C,CAAC;AASD,MAAM,WAAWA,mBAAE,OAAO;CACtB,WAAW;CACX,UAAU;CACV,UAAUA,mBAAE,OAAO;CACnB,SAASA,mBAAE,SAAS,oBAAoB;AAC5C,CAAC;AAID,MAAM,gCAAgCA,mBAAE,OAAO;CAC3C,aAAaA,mBAAE,OAAO;CACtB,WAAWA,mBAAE,SAAS,eAAe;CACrC,WAAW;CACX,UAAUA,mBAAE,OAAO;AACvB,CAAC;AAID,MAAM,cAAcA,mBAAE,OAAO;CACzB,OAAOA,mBAAE,OAAO;CAChB,WAAW;AACf,CAAC;;;;AAOD,IAAa,cAAb,MAAyB;CACrB;CACA;CACA;CAEA,YAAY,YAAmC,UAA6B;EACxE,KAAKC,gBAAgB,aAAaC,eAAmB,WAAW,SAAS;EACzE,KAAKC,cAAc,aAAaD,eAAmB,WAAW,OAAO;EACrE,KAAK,UAAU,IAAI,eAAe,WAAW,SAAS,QAAQ;CAClE;;;;CAKA,MAAM,GAAG,SAAgD;EACrD,MAAM,MAAM,MAAM,KAAKC,YAAY,GAAG,CAAC,GAAG,qBAAqB,OAAO,CAAC;EACvE,OAAOC,MAAQ,UAAU,GAAG;CAChC;;;;;;;CAQA,MAAM,kBACF,qBACA,SACc;EACd,OAAOA,MACH,aACA,MAAM,KAAKH,cAAc,SACrB,EAAE,oBAAoB,GACtB,qBAAqB,OAAO,CAChC,CACJ;CACJ;;;;CAKA,MAAgB,gBACZ,OACA,SACgC;EAChC,MAAM,iBAAiBG,MAAQ,4BAA4B,KAAK;EAChE,MAAM,MAAM,MAAM,KAAKH,cAAc,gBACjC,gBACA,qBAAqB,OAAO,CAChC;EACA,OAAOG,MAAQ,+BAA+B,GAAG;CACrD;AACJ"}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
+
import { validation_d_exports } from "../../../shared/validation.js";
|
|
1
2
|
import { PolyesterMutationOptions, PolyesterRequestOptions } from "../../../shared/request-options.js";
|
|
2
3
|
import { PolyesterRealtime } from "../../../realtime/types.js";
|
|
3
4
|
import "../../../realtime/index.js";
|
|
4
5
|
import { BaseSubscribeInput } from "../../../shared/types.js";
|
|
5
6
|
import { AccountIdentity, Profile, UpdateProfileInputSchema, UsernameHistoryEntry } from "./profile.schemas.js";
|
|
6
7
|
import { Transport } from "@connectrpc/connect";
|
|
7
|
-
import * as v from "valibot";
|
|
8
8
|
//#region src/services/auth/profile/profile.d.ts
|
|
9
9
|
interface SubscribeIdentityInput extends BaseSubscribeInput<AccountIdentity> {}
|
|
10
10
|
/**
|
|
@@ -20,7 +20,7 @@ declare class ProfileService {
|
|
|
20
20
|
/**
|
|
21
21
|
* Updates only the provided mutable profile fields; omitted fields are unchanged, while present empty strings clear optional text fields such as bio, website, Twitter, and avatar URL.
|
|
22
22
|
*/
|
|
23
|
-
update(input:
|
|
23
|
+
update(input: validation_d_exports.InferInput<typeof UpdateProfileInputSchema>, options?: PolyesterMutationOptions): Promise<Profile>;
|
|
24
24
|
/**
|
|
25
25
|
* Returns the caller's recent username changes, newest first, capped at 20 entries.
|
|
26
26
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"profile.d.ts","names":[],"sources":["../../../../src/services/auth/profile/profile.ts"],"mappings":";;;;;;;;UAqBU,+BAA+B,mBAAmB;;;;cAK/C;;EAIG,YAAA,WAAW,WAAW,UAAU;;;;EAQtC,IAAI,UAAU,0BAA0B,QAAQ;;;;EAShD,OACF,OAAO,
|
|
1
|
+
{"version":3,"file":"profile.d.ts","names":[],"sources":["../../../../src/services/auth/profile/profile.ts"],"mappings":";;;;;;;;UAqBU,+BAA+B,mBAAmB;;;;cAK/C;;EAIG,YAAA,WAAW,WAAW,UAAU;;;;EAQtC,IAAI,UAAU,0BAA0B,QAAQ;;;;EAShD,OACF,OAAO,qBAAE,kBAAkB,2BAC3B,UAAU,2BACX,QAAQ;;;;EAYL,mBAAmB,UAAU,0BAA0B,QAAQ;;;;EAQrE,kBAAkB,OAAO"}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
+
import { parse, validation_exports } from "../../../shared/validation.js";
|
|
1
2
|
import { toConnectCallOptions } from "../../../shared/request-options.js";
|
|
2
3
|
import { removeUndefined } from "../../../utils/remove-undefined.js";
|
|
3
4
|
import { AccountIdentitySchema, ProfileService as ProfileService$1 } from "../../../gen/auth/v1/profile_pb.js";
|
|
4
5
|
import { AccountIdentitySchema as AccountIdentitySchema$1, ProfileSchema, UpdateProfileInputSchema, UsernameHistoryEntrySchema } from "./profile.schemas.js";
|
|
5
6
|
import { createClient } from "@connectrpc/connect";
|
|
6
|
-
import * as v from "valibot";
|
|
7
7
|
//#region src/services/auth/profile/profile.ts
|
|
8
8
|
/**
|
|
9
9
|
* Manages the authenticated account's public profile and realtime identity updates.
|
|
@@ -21,22 +21,22 @@ var ProfileService = class {
|
|
|
21
21
|
async get(options) {
|
|
22
22
|
const res = await this.#client.getProfile({}, toConnectCallOptions(options));
|
|
23
23
|
if (!res) throw new Error("Profile not found");
|
|
24
|
-
return
|
|
24
|
+
return parse(ProfileSchema, res);
|
|
25
25
|
}
|
|
26
26
|
/**
|
|
27
27
|
* Updates only the provided mutable profile fields; omitted fields are unchanged, while present empty strings clear optional text fields such as bio, website, Twitter, and avatar URL.
|
|
28
28
|
*/
|
|
29
29
|
async update(input, options) {
|
|
30
|
-
const validatedInput =
|
|
30
|
+
const validatedInput = parse(UpdateProfileInputSchema, input);
|
|
31
31
|
const res = await this.#client.updateProfile(removeUndefined(validatedInput), toConnectCallOptions(options));
|
|
32
|
-
return
|
|
32
|
+
return parse(ProfileSchema, res);
|
|
33
33
|
}
|
|
34
34
|
/**
|
|
35
35
|
* Returns the caller's recent username changes, newest first, capped at 20 entries.
|
|
36
36
|
*/
|
|
37
37
|
async getUsernameHistory(options) {
|
|
38
38
|
const res = await this.#client.getUsernameHistory({}, toConnectCallOptions(options));
|
|
39
|
-
return
|
|
39
|
+
return parse(validation_exports.array(UsernameHistoryEntrySchema), res.history);
|
|
40
40
|
}
|
|
41
41
|
/**
|
|
42
42
|
* Subscribes to public identity updates and emits normalized account identity records with base58 account IDs, username, avatar URL, and root smart-account address.
|
|
@@ -46,12 +46,12 @@ var ProfileService = class {
|
|
|
46
46
|
channel: "public:identity:updates:proto",
|
|
47
47
|
schema: AccountIdentitySchema,
|
|
48
48
|
onPublication: (data) => {
|
|
49
|
-
const identity =
|
|
49
|
+
const identity = parse(AccountIdentitySchema$1, data);
|
|
50
50
|
input.onEvent(identity);
|
|
51
51
|
},
|
|
52
52
|
onConnected: () => input.onOpen?.(),
|
|
53
53
|
onDisconnected: () => input.onClose?.(),
|
|
54
|
-
onError:
|
|
54
|
+
onError: input.onError
|
|
55
55
|
});
|
|
56
56
|
}
|
|
57
57
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"profile.js","names":["#client","Proto.ProfileService","#realtime","Proto.AccountIdentitySchema","AccountIdentitySchema"],"sources":["../../../../src/services/auth/profile/profile.ts"],"sourcesContent":["import { createClient, type Client, type Transport } from \"@connectrpc/connect\";\nimport * as Proto from \"../../../gen/auth/v1/profile_pb.js\";\nimport * as v from \"
|
|
1
|
+
{"version":3,"file":"profile.js","names":["#client","Proto.ProfileService","#realtime","v.parse","v","Proto.AccountIdentitySchema","AccountIdentitySchema"],"sources":["../../../../src/services/auth/profile/profile.ts"],"sourcesContent":["import { createClient, type Client, type Transport } from \"@connectrpc/connect\";\nimport * as Proto from \"../../../gen/auth/v1/profile_pb.js\";\nimport * as v from \"../../../shared/validation.js\";\nimport { removeUndefined } from \"../../../utils/remove-undefined.js\";\nimport {\n toConnectCallOptions,\n type PolyesterMutationOptions,\n type PolyesterRequestOptions,\n} from \"../../../shared/request-options.js\";\nimport {\n AccountIdentitySchema,\n ProfileSchema,\n UpdateProfileInputSchema,\n UsernameHistoryEntrySchema,\n type AccountIdentity,\n type Profile,\n type UsernameHistoryEntry,\n} from \"./profile.schemas.js\";\nimport type { BaseSubscribeInput } from \"../../../shared/types.js\";\nimport type { PolyesterRealtime } from \"../../../realtime/index.js\";\n\ninterface SubscribeIdentityInput extends BaseSubscribeInput<AccountIdentity> {}\n\n/**\n * Manages the authenticated account's public profile and realtime identity updates.\n */\nexport class ProfileService {\n #client: Client<typeof Proto.ProfileService>;\n #realtime: PolyesterRealtime;\n\n constructor(transport: Transport, realtime: PolyesterRealtime) {\n this.#client = createClient(Proto.ProfileService, transport);\n this.#realtime = realtime;\n }\n\n /**\n * Fetches the caller's public profile, including username eligibility/cooldown, verified social handles, avatar, VIP tier, and account creation timestamp.\n */\n async get(options?: PolyesterRequestOptions): Promise<Profile> {\n const res = await this.#client.getProfile({}, toConnectCallOptions(options));\n if (!res) throw new Error(\"Profile not found\");\n return v.parse(ProfileSchema, res);\n }\n\n /**\n * Updates only the provided mutable profile fields; omitted fields are unchanged, while present empty strings clear optional text fields such as bio, website, Twitter, and avatar URL.\n */\n async update(\n input: v.InferInput<typeof UpdateProfileInputSchema>,\n options?: PolyesterMutationOptions,\n ): Promise<Profile> {\n const validatedInput = v.parse(UpdateProfileInputSchema, input);\n const res = await this.#client.updateProfile(\n removeUndefined(validatedInput),\n toConnectCallOptions(options),\n );\n return v.parse(ProfileSchema, res);\n }\n\n /**\n * Returns the caller's recent username changes, newest first, capped at 20 entries.\n */\n async getUsernameHistory(options?: PolyesterRequestOptions): Promise<UsernameHistoryEntry[]> {\n const res = await this.#client.getUsernameHistory({}, toConnectCallOptions(options));\n return v.parse(v.array(UsernameHistoryEntrySchema), res.history);\n }\n\n /**\n * Subscribes to public identity updates and emits normalized account identity records with base58 account IDs, username, avatar URL, and root smart-account address.\n */\n subscribeIdentity(input: SubscribeIdentityInput): () => void {\n const channel = \"public:identity:updates:proto\";\n return this.#realtime.connectProtoChannel({\n channel,\n schema: Proto.AccountIdentitySchema,\n onPublication: (data) => {\n const identity = v.parse(AccountIdentitySchema, data);\n input.onEvent(identity);\n },\n onConnected: () => input.onOpen?.(),\n onDisconnected: () => input.onClose?.(),\n onError: input.onError,\n });\n }\n}\n"],"mappings":";;;;;;;;;;AA0BA,IAAa,iBAAb,MAA4B;CACxB;CACA;CAEA,YAAY,WAAsB,UAA6B;EAC3D,KAAKA,UAAU,aAAaC,kBAAsB,SAAS;EAC3D,KAAKC,YAAY;CACrB;;;;CAKA,MAAM,IAAI,SAAqD;EAC3D,MAAM,MAAM,MAAM,KAAKF,QAAQ,WAAW,CAAC,GAAG,qBAAqB,OAAO,CAAC;EAC3E,IAAI,CAAC,KAAK,MAAM,IAAI,MAAM,mBAAmB;EAC7C,OAAOG,MAAQ,eAAe,GAAG;CACrC;;;;CAKA,MAAM,OACF,OACA,SACgB;EAChB,MAAM,iBAAiBA,MAAQ,0BAA0B,KAAK;EAC9D,MAAM,MAAM,MAAM,KAAKH,QAAQ,cAC3B,gBAAgB,cAAc,GAC9B,qBAAqB,OAAO,CAChC;EACA,OAAOG,MAAQ,eAAe,GAAG;CACrC;;;;CAKA,MAAM,mBAAmB,SAAoE;EACzF,MAAM,MAAM,MAAM,KAAKH,QAAQ,mBAAmB,CAAC,GAAG,qBAAqB,OAAO,CAAC;EACnF,OAAOG,MAAQC,mBAAE,MAAM,0BAA0B,GAAG,IAAI,OAAO;CACnE;;;;CAKA,kBAAkB,OAA2C;EAEzD,OAAO,KAAKF,UAAU,oBAAoB;GACtC,SAAA;GACA,QAAQG;GACR,gBAAgB,SAAS;IACrB,MAAM,WAAWF,MAAQG,yBAAuB,IAAI;IACpD,MAAM,QAAQ,QAAQ;GAC1B;GACA,mBAAmB,MAAM,SAAS;GAClC,sBAAsB,MAAM,UAAU;GACtC,SAAS,MAAM;EACnB,CAAC;CACL;AACJ"}
|