@privy-io/node 0.1.0-alpha.2
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 +146 -0
- package/LICENSE +201 -0
- package/README.md +48 -0
- package/api-promise.d.mts +2 -0
- package/api-promise.d.mts.map +1 -0
- package/api-promise.d.ts +2 -0
- package/api-promise.d.ts.map +1 -0
- package/api-promise.js +6 -0
- package/api-promise.js.map +1 -0
- package/api-promise.mjs +2 -0
- package/api-promise.mjs.map +1 -0
- package/client.d.mts +215 -0
- package/client.d.mts.map +1 -0
- package/client.d.ts +215 -0
- package/client.d.ts.map +1 -0
- package/client.js +499 -0
- package/client.js.map +1 -0
- package/client.mjs +495 -0
- package/client.mjs.map +1 -0
- package/core/api-promise.d.mts +46 -0
- package/core/api-promise.d.mts.map +1 -0
- package/core/api-promise.d.ts +46 -0
- package/core/api-promise.d.ts.map +1 -0
- package/core/api-promise.js +74 -0
- package/core/api-promise.js.map +1 -0
- package/core/api-promise.mjs +70 -0
- package/core/api-promise.mjs.map +1 -0
- package/core/error.d.mts +46 -0
- package/core/error.d.mts.map +1 -0
- package/core/error.d.ts +46 -0
- package/core/error.d.ts.map +1 -0
- package/core/error.js +113 -0
- package/core/error.js.map +1 -0
- package/core/error.mjs +97 -0
- package/core/error.mjs.map +1 -0
- package/core/pagination.d.mts +54 -0
- package/core/pagination.d.mts.map +1 -0
- package/core/pagination.d.ts +54 -0
- package/core/pagination.d.ts.map +1 -0
- package/core/pagination.js +101 -0
- package/core/pagination.js.map +1 -0
- package/core/pagination.mjs +95 -0
- package/core/pagination.mjs.map +1 -0
- package/core/resource.d.mts +6 -0
- package/core/resource.d.mts.map +1 -0
- package/core/resource.d.ts +6 -0
- package/core/resource.d.ts.map +1 -0
- package/core/resource.js +11 -0
- package/core/resource.js.map +1 -0
- package/core/resource.mjs +7 -0
- package/core/resource.mjs.map +1 -0
- package/core/uploads.d.mts +3 -0
- package/core/uploads.d.mts.map +1 -0
- package/core/uploads.d.ts +3 -0
- package/core/uploads.d.ts.map +1 -0
- package/core/uploads.js +6 -0
- package/core/uploads.js.map +1 -0
- package/core/uploads.mjs +2 -0
- package/core/uploads.mjs.map +1 -0
- package/error.d.mts +2 -0
- package/error.d.mts.map +1 -0
- package/error.d.ts +2 -0
- package/error.d.ts.map +1 -0
- package/error.js +6 -0
- package/error.js.map +1 -0
- package/error.mjs +2 -0
- package/error.mjs.map +1 -0
- package/index.d.mts +13 -0
- package/index.d.mts.map +1 -0
- package/index.d.ts +13 -0
- package/index.d.ts.map +1 -0
- package/index.js +29 -0
- package/index.js.map +1 -0
- package/index.mjs +5 -0
- package/index.mjs.map +1 -0
- package/internal/builtin-types.d.mts +73 -0
- package/internal/builtin-types.d.mts.map +1 -0
- package/internal/builtin-types.d.ts +73 -0
- package/internal/builtin-types.d.ts.map +1 -0
- package/internal/builtin-types.js +4 -0
- package/internal/builtin-types.js.map +1 -0
- package/internal/builtin-types.mjs +3 -0
- package/internal/builtin-types.mjs.map +1 -0
- package/internal/detect-platform.d.mts +15 -0
- package/internal/detect-platform.d.mts.map +1 -0
- package/internal/detect-platform.d.ts +15 -0
- package/internal/detect-platform.d.ts.map +1 -0
- package/internal/detect-platform.js +162 -0
- package/internal/detect-platform.js.map +1 -0
- package/internal/detect-platform.mjs +157 -0
- package/internal/detect-platform.mjs.map +1 -0
- package/internal/errors.d.mts +3 -0
- package/internal/errors.d.mts.map +1 -0
- package/internal/errors.d.ts +3 -0
- package/internal/errors.d.ts.map +1 -0
- package/internal/errors.js +41 -0
- package/internal/errors.js.map +1 -0
- package/internal/errors.mjs +36 -0
- package/internal/errors.mjs.map +1 -0
- package/internal/headers.d.mts +6 -0
- package/internal/headers.d.mts.map +1 -0
- package/internal/headers.d.ts +6 -0
- package/internal/headers.d.ts.map +1 -0
- package/internal/headers.js +79 -0
- package/internal/headers.js.map +1 -0
- package/internal/headers.mjs +74 -0
- package/internal/headers.mjs.map +1 -0
- package/internal/parse.d.mts +12 -0
- package/internal/parse.d.mts.map +1 -0
- package/internal/parse.d.ts +12 -0
- package/internal/parse.d.ts.map +1 -0
- package/internal/parse.js +35 -0
- package/internal/parse.js.map +1 -0
- package/internal/parse.mjs +32 -0
- package/internal/parse.mjs.map +1 -0
- package/internal/qs/formats.d.mts +7 -0
- package/internal/qs/formats.d.mts.map +1 -0
- package/internal/qs/formats.d.ts +7 -0
- package/internal/qs/formats.d.ts.map +1 -0
- package/internal/qs/formats.js +13 -0
- package/internal/qs/formats.js.map +1 -0
- package/internal/qs/formats.mjs +9 -0
- package/internal/qs/formats.mjs.map +1 -0
- package/internal/qs/index.d.mts +10 -0
- package/internal/qs/index.d.mts.map +1 -0
- package/internal/qs/index.d.ts +10 -0
- package/internal/qs/index.d.ts.map +1 -0
- package/internal/qs/index.js +14 -0
- package/internal/qs/index.js.map +1 -0
- package/internal/qs/index.mjs +10 -0
- package/internal/qs/index.mjs.map +1 -0
- package/internal/qs/stringify.d.mts +3 -0
- package/internal/qs/stringify.d.mts.map +1 -0
- package/internal/qs/stringify.d.ts +3 -0
- package/internal/qs/stringify.d.ts.map +1 -0
- package/internal/qs/stringify.js +277 -0
- package/internal/qs/stringify.js.map +1 -0
- package/internal/qs/stringify.mjs +274 -0
- package/internal/qs/stringify.mjs.map +1 -0
- package/internal/qs/types.d.mts +57 -0
- package/internal/qs/types.d.mts.map +1 -0
- package/internal/qs/types.d.ts +57 -0
- package/internal/qs/types.d.ts.map +1 -0
- package/internal/qs/types.js +3 -0
- package/internal/qs/types.js.map +1 -0
- package/internal/qs/types.mjs +2 -0
- package/internal/qs/types.mjs.map +1 -0
- package/internal/qs/utils.d.mts +15 -0
- package/internal/qs/utils.d.mts.map +1 -0
- package/internal/qs/utils.d.ts +15 -0
- package/internal/qs/utils.d.ts.map +1 -0
- package/internal/qs/utils.js +230 -0
- package/internal/qs/utils.js.map +1 -0
- package/internal/qs/utils.mjs +217 -0
- package/internal/qs/utils.mjs.map +1 -0
- package/internal/request-options.d.mts +75 -0
- package/internal/request-options.d.mts.map +1 -0
- package/internal/request-options.d.ts +75 -0
- package/internal/request-options.d.ts.map +1 -0
- package/internal/request-options.js +14 -0
- package/internal/request-options.js.map +1 -0
- package/internal/request-options.mjs +10 -0
- package/internal/request-options.mjs.map +1 -0
- package/internal/shim-types.d.mts +17 -0
- package/internal/shim-types.d.mts.map +1 -0
- package/internal/shim-types.d.ts +17 -0
- package/internal/shim-types.d.ts.map +1 -0
- package/internal/shim-types.js +4 -0
- package/internal/shim-types.js.map +1 -0
- package/internal/shim-types.mjs +3 -0
- package/internal/shim-types.mjs.map +1 -0
- package/internal/shims.d.mts +20 -0
- package/internal/shims.d.mts.map +1 -0
- package/internal/shims.d.ts +20 -0
- package/internal/shims.d.ts.map +1 -0
- package/internal/shims.js +92 -0
- package/internal/shims.js.map +1 -0
- package/internal/shims.mjs +85 -0
- package/internal/shims.mjs.map +1 -0
- package/internal/to-file.d.mts +45 -0
- package/internal/to-file.d.mts.map +1 -0
- package/internal/to-file.d.ts +45 -0
- package/internal/to-file.d.ts.map +1 -0
- package/internal/to-file.js +91 -0
- package/internal/to-file.js.map +1 -0
- package/internal/to-file.mjs +88 -0
- package/internal/to-file.mjs.map +1 -0
- package/internal/tslib.js +85 -0
- package/internal/tslib.mjs +17 -0
- package/internal/types.d.mts +69 -0
- package/internal/types.d.mts.map +1 -0
- package/internal/types.d.ts +69 -0
- package/internal/types.d.ts.map +1 -0
- package/internal/types.js +4 -0
- package/internal/types.js.map +1 -0
- package/internal/types.mjs +3 -0
- package/internal/types.mjs.map +1 -0
- package/internal/uploads.d.mts +42 -0
- package/internal/uploads.d.mts.map +1 -0
- package/internal/uploads.d.ts +42 -0
- package/internal/uploads.d.ts.map +1 -0
- package/internal/uploads.js +141 -0
- package/internal/uploads.js.map +1 -0
- package/internal/uploads.mjs +131 -0
- package/internal/uploads.mjs.map +1 -0
- package/internal/utils/base64.d.mts +3 -0
- package/internal/utils/base64.d.mts.map +1 -0
- package/internal/utils/base64.d.ts +3 -0
- package/internal/utils/base64.d.ts.map +1 -0
- package/internal/utils/base64.js +38 -0
- package/internal/utils/base64.js.map +1 -0
- package/internal/utils/base64.mjs +33 -0
- package/internal/utils/base64.mjs.map +1 -0
- package/internal/utils/bytes.d.mts +4 -0
- package/internal/utils/bytes.d.mts.map +1 -0
- package/internal/utils/bytes.d.ts +4 -0
- package/internal/utils/bytes.d.ts.map +1 -0
- package/internal/utils/bytes.js +31 -0
- package/internal/utils/bytes.js.map +1 -0
- package/internal/utils/bytes.mjs +26 -0
- package/internal/utils/bytes.mjs.map +1 -0
- package/internal/utils/env.d.mts +9 -0
- package/internal/utils/env.d.mts.map +1 -0
- package/internal/utils/env.d.ts +9 -0
- package/internal/utils/env.d.ts.map +1 -0
- package/internal/utils/env.js +22 -0
- package/internal/utils/env.js.map +1 -0
- package/internal/utils/env.mjs +18 -0
- package/internal/utils/env.mjs.map +1 -0
- package/internal/utils/log.d.mts +37 -0
- package/internal/utils/log.d.mts.map +1 -0
- package/internal/utils/log.d.ts +37 -0
- package/internal/utils/log.d.ts.map +1 -0
- package/internal/utils/log.js +85 -0
- package/internal/utils/log.js.map +1 -0
- package/internal/utils/log.mjs +79 -0
- package/internal/utils/log.mjs.map +1 -0
- package/internal/utils/path.d.mts +15 -0
- package/internal/utils/path.d.mts.map +1 -0
- package/internal/utils/path.d.ts +15 -0
- package/internal/utils/path.d.ts.map +1 -0
- package/internal/utils/path.js +79 -0
- package/internal/utils/path.js.map +1 -0
- package/internal/utils/path.mjs +74 -0
- package/internal/utils/path.mjs.map +1 -0
- package/internal/utils/sleep.d.mts +2 -0
- package/internal/utils/sleep.d.mts.map +1 -0
- package/internal/utils/sleep.d.ts +2 -0
- package/internal/utils/sleep.d.ts.map +1 -0
- package/internal/utils/sleep.js +7 -0
- package/internal/utils/sleep.js.map +1 -0
- package/internal/utils/sleep.mjs +3 -0
- package/internal/utils/sleep.mjs.map +1 -0
- package/internal/utils/uuid.d.mts +5 -0
- package/internal/utils/uuid.d.mts.map +1 -0
- package/internal/utils/uuid.d.ts +5 -0
- package/internal/utils/uuid.d.ts.map +1 -0
- package/internal/utils/uuid.js +19 -0
- package/internal/utils/uuid.js.map +1 -0
- package/internal/utils/uuid.mjs +15 -0
- package/internal/utils/uuid.mjs.map +1 -0
- package/internal/utils/values.d.mts +18 -0
- package/internal/utils/values.d.mts.map +1 -0
- package/internal/utils/values.d.ts +18 -0
- package/internal/utils/values.d.ts.map +1 -0
- package/internal/utils/values.js +112 -0
- package/internal/utils/values.js.map +1 -0
- package/internal/utils/values.mjs +94 -0
- package/internal/utils/values.mjs.map +1 -0
- package/internal/utils.d.mts +7 -0
- package/internal/utils.d.mts.map +1 -0
- package/internal/utils.d.ts +7 -0
- package/internal/utils.d.ts.map +1 -0
- package/internal/utils.js +11 -0
- package/internal/utils.js.map +1 -0
- package/internal/utils.mjs +8 -0
- package/internal/utils.mjs.map +1 -0
- package/lib/authorization.d.mts +87 -0
- package/lib/authorization.d.mts.map +1 -0
- package/lib/authorization.d.ts +87 -0
- package/lib/authorization.d.ts.map +1 -0
- package/lib/authorization.js +73 -0
- package/lib/authorization.js.map +1 -0
- package/lib/authorization.mjs +67 -0
- package/lib/authorization.mjs.map +1 -0
- package/lib/cryptography.d.mts +8 -0
- package/lib/cryptography.d.mts.map +1 -0
- package/lib/cryptography.d.ts +8 -0
- package/lib/cryptography.d.ts.map +1 -0
- package/lib/cryptography.js +72 -0
- package/lib/cryptography.js.map +1 -0
- package/lib/cryptography.mjs +67 -0
- package/lib/cryptography.mjs.map +1 -0
- package/lib/jwt-exchange.d.mts +9 -0
- package/lib/jwt-exchange.d.mts.map +1 -0
- package/lib/jwt-exchange.d.ts +9 -0
- package/lib/jwt-exchange.d.ts.map +1 -0
- package/lib/jwt-exchange.js +55 -0
- package/lib/jwt-exchange.js.map +1 -0
- package/lib/jwt-exchange.mjs +51 -0
- package/lib/jwt-exchange.mjs.map +1 -0
- package/lib/wallet-entropy.d.mts +7 -0
- package/lib/wallet-entropy.d.mts.map +1 -0
- package/lib/wallet-entropy.d.ts +7 -0
- package/lib/wallet-entropy.d.ts.map +1 -0
- package/lib/wallet-entropy.js +44 -0
- package/lib/wallet-entropy.js.map +1 -0
- package/lib/wallet-entropy.mjs +41 -0
- package/lib/wallet-entropy.mjs.map +1 -0
- package/package.json +46 -0
- package/pagination.d.mts +2 -0
- package/pagination.d.mts.map +1 -0
- package/pagination.d.ts +2 -0
- package/pagination.d.ts.map +1 -0
- package/pagination.js +6 -0
- package/pagination.js.map +1 -0
- package/pagination.mjs +2 -0
- package/pagination.mjs.map +1 -0
- package/public-api/PrivyClient.d.mts +33 -0
- package/public-api/PrivyClient.d.mts.map +1 -0
- package/public-api/PrivyClient.d.ts +33 -0
- package/public-api/PrivyClient.d.ts.map +1 -0
- package/public-api/PrivyClient.js +59 -0
- package/public-api/PrivyClient.js.map +1 -0
- package/public-api/PrivyClient.mjs +55 -0
- package/public-api/PrivyClient.mjs.map +1 -0
- package/public-api/services/ethereum.d.mts +39 -0
- package/public-api/services/ethereum.d.mts.map +1 -0
- package/public-api/services/ethereum.d.ts +39 -0
- package/public-api/services/ethereum.d.ts.map +1 -0
- package/public-api/services/ethereum.js +77 -0
- package/public-api/services/ethereum.js.map +1 -0
- package/public-api/services/ethereum.mjs +73 -0
- package/public-api/services/ethereum.mjs.map +1 -0
- package/public-api/services/key-quorums.d.mts +18 -0
- package/public-api/services/key-quorums.d.mts.map +1 -0
- package/public-api/services/key-quorums.d.ts +18 -0
- package/public-api/services/key-quorums.d.ts.map +1 -0
- package/public-api/services/key-quorums.js +51 -0
- package/public-api/services/key-quorums.js.map +1 -0
- package/public-api/services/key-quorums.mjs +47 -0
- package/public-api/services/key-quorums.mjs.map +1 -0
- package/public-api/services/policies.d.mts +27 -0
- package/public-api/services/policies.d.mts.map +1 -0
- package/public-api/services/policies.d.ts +27 -0
- package/public-api/services/policies.d.ts.map +1 -0
- package/public-api/services/policies.js +110 -0
- package/public-api/services/policies.js.map +1 -0
- package/public-api/services/policies.mjs +106 -0
- package/public-api/services/policies.mjs.map +1 -0
- package/public-api/services/solana.d.mts +42 -0
- package/public-api/services/solana.d.mts.map +1 -0
- package/public-api/services/solana.d.ts +42 -0
- package/public-api/services/solana.d.ts.map +1 -0
- package/public-api/services/solana.js +67 -0
- package/public-api/services/solana.js.map +1 -0
- package/public-api/services/solana.mjs +63 -0
- package/public-api/services/solana.mjs.map +1 -0
- package/public-api/services/transactions.d.mts +4 -0
- package/public-api/services/transactions.d.mts.map +1 -0
- package/public-api/services/transactions.d.ts +4 -0
- package/public-api/services/transactions.d.ts.map +1 -0
- package/public-api/services/transactions.js +8 -0
- package/public-api/services/transactions.js.map +1 -0
- package/public-api/services/transactions.mjs +4 -0
- package/public-api/services/transactions.mjs.map +1 -0
- package/public-api/services/types.d.mts +54 -0
- package/public-api/services/types.d.mts.map +1 -0
- package/public-api/services/types.d.ts +54 -0
- package/public-api/services/types.d.ts.map +1 -0
- package/public-api/services/types.js +3 -0
- package/public-api/services/types.js.map +1 -0
- package/public-api/services/types.mjs +2 -0
- package/public-api/services/types.mjs.map +1 -0
- package/public-api/services/users.d.mts +4 -0
- package/public-api/services/users.d.mts.map +1 -0
- package/public-api/services/users.d.ts +4 -0
- package/public-api/services/users.d.ts.map +1 -0
- package/public-api/services/users.js +8 -0
- package/public-api/services/users.js.map +1 -0
- package/public-api/services/users.mjs +4 -0
- package/public-api/services/users.mjs.map +1 -0
- package/public-api/services/utils.d.mts +26 -0
- package/public-api/services/utils.d.mts.map +1 -0
- package/public-api/services/utils.d.ts +26 -0
- package/public-api/services/utils.d.ts.map +1 -0
- package/public-api/services/utils.js +18 -0
- package/public-api/services/utils.js.map +1 -0
- package/public-api/services/utils.mjs +14 -0
- package/public-api/services/utils.mjs.map +1 -0
- package/public-api/services/wallets.d.mts +70 -0
- package/public-api/services/wallets.d.mts.map +1 -0
- package/public-api/services/wallets.d.ts +70 -0
- package/public-api/services/wallets.d.ts.map +1 -0
- package/public-api/services/wallets.js +145 -0
- package/public-api/services/wallets.js.map +1 -0
- package/public-api/services/wallets.mjs +141 -0
- package/public-api/services/wallets.mjs.map +1 -0
- package/resource.d.mts +2 -0
- package/resource.d.mts.map +1 -0
- package/resource.d.ts +2 -0
- package/resource.d.ts.map +1 -0
- package/resource.js +6 -0
- package/resource.js.map +1 -0
- package/resource.mjs +2 -0
- package/resource.mjs.map +1 -0
- package/resources/index.d.mts +6 -0
- package/resources/index.d.mts.map +1 -0
- package/resources/index.d.ts +6 -0
- package/resources/index.d.ts.map +1 -0
- package/resources/index.js +15 -0
- package/resources/index.js.map +1 -0
- package/resources/index.mjs +7 -0
- package/resources/index.mjs.map +1 -0
- package/resources/key-quorums.d.mts +106 -0
- package/resources/key-quorums.d.mts.map +1 -0
- package/resources/key-quorums.d.ts +106 -0
- package/resources/key-quorums.d.ts.map +1 -0
- package/resources/key-quorums.js +84 -0
- package/resources/key-quorums.js.map +1 -0
- package/resources/key-quorums.mjs +80 -0
- package/resources/key-quorums.mjs.map +1 -0
- package/resources/policies.d.mts +1283 -0
- package/resources/policies.d.mts.map +1 -0
- package/resources/policies.d.ts +1283 -0
- package/resources/policies.d.ts.map +1 -0
- package/resources/policies.js +228 -0
- package/resources/policies.js.map +1 -0
- package/resources/policies.mjs +224 -0
- package/resources/policies.mjs.map +1 -0
- package/resources/transactions.d.mts +29 -0
- package/resources/transactions.d.mts.map +1 -0
- package/resources/transactions.d.ts +29 -0
- package/resources/transactions.d.ts.map +1 -0
- package/resources/transactions.js +23 -0
- package/resources/transactions.js.map +1 -0
- package/resources/transactions.mjs +19 -0
- package/resources/transactions.mjs.map +1 -0
- package/resources/users.d.mts +766 -0
- package/resources/users.d.mts.map +1 -0
- package/resources/users.d.ts +766 -0
- package/resources/users.d.ts.map +1 -0
- package/resources/users.js +278 -0
- package/resources/users.js.map +1 -0
- package/resources/users.mjs +274 -0
- package/resources/users.mjs.map +1 -0
- package/resources/wallets/balance.d.mts +40 -0
- package/resources/wallets/balance.d.mts.map +1 -0
- package/resources/wallets/balance.d.ts +40 -0
- package/resources/wallets/balance.d.ts.map +1 -0
- package/resources/wallets/balance.js +24 -0
- package/resources/wallets/balance.js.map +1 -0
- package/resources/wallets/balance.mjs +20 -0
- package/resources/wallets/balance.mjs.map +1 -0
- package/resources/wallets/index.d.mts +4 -0
- package/resources/wallets/index.d.mts.map +1 -0
- package/resources/wallets/index.d.ts +4 -0
- package/resources/wallets/index.d.ts.map +1 -0
- package/resources/wallets/index.js +11 -0
- package/resources/wallets/index.js.map +1 -0
- package/resources/wallets/index.mjs +5 -0
- package/resources/wallets/index.mjs.map +1 -0
- package/resources/wallets/transactions.d.mts +73 -0
- package/resources/wallets/transactions.d.mts.map +1 -0
- package/resources/wallets/transactions.d.ts +73 -0
- package/resources/wallets/transactions.d.ts.map +1 -0
- package/resources/wallets/transactions.js +24 -0
- package/resources/wallets/transactions.js.map +1 -0
- package/resources/wallets/transactions.mjs +20 -0
- package/resources/wallets/transactions.mjs.map +1 -0
- package/resources/wallets/wallets.d.mts +1122 -0
- package/resources/wallets/wallets.d.mts.map +1 -0
- package/resources/wallets/wallets.d.ts +1122 -0
- package/resources/wallets/wallets.d.ts.map +1 -0
- package/resources/wallets/wallets.js +235 -0
- package/resources/wallets/wallets.js.map +1 -0
- package/resources/wallets/wallets.mjs +230 -0
- package/resources/wallets/wallets.mjs.map +1 -0
- package/resources/wallets.d.mts +2 -0
- package/resources/wallets.d.mts.map +1 -0
- package/resources/wallets.d.ts +2 -0
- package/resources/wallets.d.ts.map +1 -0
- package/resources/wallets.js +6 -0
- package/resources/wallets.js.map +1 -0
- package/resources/wallets.mjs +3 -0
- package/resources/wallets.mjs.map +1 -0
- package/resources.d.mts +2 -0
- package/resources.d.mts.map +1 -0
- package/resources.d.ts +2 -0
- package/resources.d.ts.map +1 -0
- package/resources.js +5 -0
- package/resources.js.map +1 -0
- package/resources.mjs +2 -0
- package/resources.mjs.map +1 -0
- package/src/api-promise.ts +2 -0
- package/src/client.ts +942 -0
- package/src/core/README.md +3 -0
- package/src/core/api-promise.ts +92 -0
- package/src/core/error.ts +130 -0
- package/src/core/pagination.ts +157 -0
- package/src/core/resource.ts +11 -0
- package/src/core/uploads.ts +2 -0
- package/src/error.ts +2 -0
- package/src/index.ts +34 -0
- package/src/internal/README.md +3 -0
- package/src/internal/builtin-types.ts +93 -0
- package/src/internal/detect-platform.ts +196 -0
- package/src/internal/errors.ts +33 -0
- package/src/internal/headers.ts +97 -0
- package/src/internal/parse.ts +50 -0
- package/src/internal/qs/LICENSE.md +13 -0
- package/src/internal/qs/README.md +3 -0
- package/src/internal/qs/formats.ts +10 -0
- package/src/internal/qs/index.ts +13 -0
- package/src/internal/qs/stringify.ts +385 -0
- package/src/internal/qs/types.ts +71 -0
- package/src/internal/qs/utils.ts +265 -0
- package/src/internal/request-options.ts +91 -0
- package/src/internal/shim-types.ts +26 -0
- package/src/internal/shims.ts +107 -0
- package/src/internal/to-file.ts +154 -0
- package/src/internal/types.ts +95 -0
- package/src/internal/uploads.ts +187 -0
- package/src/internal/utils/base64.ts +40 -0
- package/src/internal/utils/bytes.ts +32 -0
- package/src/internal/utils/env.ts +18 -0
- package/src/internal/utils/log.ts +126 -0
- package/src/internal/utils/path.ts +88 -0
- package/src/internal/utils/sleep.ts +3 -0
- package/src/internal/utils/uuid.ts +17 -0
- package/src/internal/utils/values.ts +105 -0
- package/src/internal/utils.ts +8 -0
- package/src/lib/.keep +4 -0
- package/src/lib/authorization.ts +153 -0
- package/src/lib/cryptography.ts +109 -0
- package/src/lib/jwt-exchange.ts +65 -0
- package/src/lib/wallet-entropy.ts +48 -0
- package/src/pagination.ts +2 -0
- package/src/public-api/PrivyClient.ts +91 -0
- package/src/public-api/services/ethereum.ts +134 -0
- package/src/public-api/services/key-quorums.ts +77 -0
- package/src/public-api/services/policies.ts +175 -0
- package/src/public-api/services/solana.ts +111 -0
- package/src/public-api/services/transactions.ts +3 -0
- package/src/public-api/services/types.ts +50 -0
- package/src/public-api/services/users.ts +3 -0
- package/src/public-api/services/utils.ts +40 -0
- package/src/public-api/services/wallets.ts +270 -0
- package/src/resource.ts +2 -0
- package/src/resources/index.ts +71 -0
- package/src/resources/key-quorums.ts +177 -0
- package/src/resources/policies.ts +1992 -0
- package/src/resources/transactions.ts +42 -0
- package/src/resources/users.ts +1312 -0
- package/src/resources/wallets/balance.ts +62 -0
- package/src/resources/wallets/index.ts +25 -0
- package/src/resources/wallets/transactions.ts +116 -0
- package/src/resources/wallets/wallets.ts +1609 -0
- package/src/resources/wallets.ts +3 -0
- package/src/resources.ts +1 -0
- package/src/tsconfig.json +11 -0
- package/src/uploads.ts +2 -0
- package/src/version.ts +1 -0
- package/uploads.d.mts +2 -0
- package/uploads.d.mts.map +1 -0
- package/uploads.d.ts +2 -0
- package/uploads.d.ts.map +1 -0
- package/uploads.js +6 -0
- package/uploads.js.map +1 -0
- package/uploads.mjs +2 -0
- package/uploads.mjs.map +1 -0
- package/version.d.mts +2 -0
- package/version.d.mts.map +1 -0
- package/version.d.ts +2 -0
- package/version.d.ts.map +1 -0
- package/version.js +5 -0
- package/version.js.map +1 -0
- package/version.mjs +2 -0
- package/version.mjs.map +1 -0
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
2
|
+
import { PrivyAPIError } from "../../core/error.mjs";
|
|
3
|
+
// https://url.spec.whatwg.org/#url-scheme-string
|
|
4
|
+
const startsWithSchemeRegexp = /^[a-z][a-z0-9+.-]*:/i;
|
|
5
|
+
export const isAbsoluteURL = (url) => {
|
|
6
|
+
return startsWithSchemeRegexp.test(url);
|
|
7
|
+
};
|
|
8
|
+
export let isArray = (val) => ((isArray = Array.isArray), isArray(val));
|
|
9
|
+
export let isReadonlyArray = isArray;
|
|
10
|
+
/** Returns an object if the given value isn't an object, otherwise returns as-is */
|
|
11
|
+
export function maybeObj(x) {
|
|
12
|
+
if (typeof x !== 'object') {
|
|
13
|
+
return {};
|
|
14
|
+
}
|
|
15
|
+
return x ?? {};
|
|
16
|
+
}
|
|
17
|
+
// https://stackoverflow.com/a/34491287
|
|
18
|
+
export function isEmptyObj(obj) {
|
|
19
|
+
if (!obj)
|
|
20
|
+
return true;
|
|
21
|
+
for (const _k in obj)
|
|
22
|
+
return false;
|
|
23
|
+
return true;
|
|
24
|
+
}
|
|
25
|
+
// https://eslint.org/docs/latest/rules/no-prototype-builtins
|
|
26
|
+
export function hasOwn(obj, key) {
|
|
27
|
+
return Object.prototype.hasOwnProperty.call(obj, key);
|
|
28
|
+
}
|
|
29
|
+
export function isObj(obj) {
|
|
30
|
+
return obj != null && typeof obj === 'object' && !Array.isArray(obj);
|
|
31
|
+
}
|
|
32
|
+
export const ensurePresent = (value) => {
|
|
33
|
+
if (value == null) {
|
|
34
|
+
throw new PrivyAPIError(`Expected a value to be given but received ${value} instead.`);
|
|
35
|
+
}
|
|
36
|
+
return value;
|
|
37
|
+
};
|
|
38
|
+
export const validatePositiveInteger = (name, n) => {
|
|
39
|
+
if (typeof n !== 'number' || !Number.isInteger(n)) {
|
|
40
|
+
throw new PrivyAPIError(`${name} must be an integer`);
|
|
41
|
+
}
|
|
42
|
+
if (n < 0) {
|
|
43
|
+
throw new PrivyAPIError(`${name} must be a positive integer`);
|
|
44
|
+
}
|
|
45
|
+
return n;
|
|
46
|
+
};
|
|
47
|
+
export const coerceInteger = (value) => {
|
|
48
|
+
if (typeof value === 'number')
|
|
49
|
+
return Math.round(value);
|
|
50
|
+
if (typeof value === 'string')
|
|
51
|
+
return parseInt(value, 10);
|
|
52
|
+
throw new PrivyAPIError(`Could not coerce ${value} (type: ${typeof value}) into a number`);
|
|
53
|
+
};
|
|
54
|
+
export const coerceFloat = (value) => {
|
|
55
|
+
if (typeof value === 'number')
|
|
56
|
+
return value;
|
|
57
|
+
if (typeof value === 'string')
|
|
58
|
+
return parseFloat(value);
|
|
59
|
+
throw new PrivyAPIError(`Could not coerce ${value} (type: ${typeof value}) into a number`);
|
|
60
|
+
};
|
|
61
|
+
export const coerceBoolean = (value) => {
|
|
62
|
+
if (typeof value === 'boolean')
|
|
63
|
+
return value;
|
|
64
|
+
if (typeof value === 'string')
|
|
65
|
+
return value === 'true';
|
|
66
|
+
return Boolean(value);
|
|
67
|
+
};
|
|
68
|
+
export const maybeCoerceInteger = (value) => {
|
|
69
|
+
if (value === undefined) {
|
|
70
|
+
return undefined;
|
|
71
|
+
}
|
|
72
|
+
return coerceInteger(value);
|
|
73
|
+
};
|
|
74
|
+
export const maybeCoerceFloat = (value) => {
|
|
75
|
+
if (value === undefined) {
|
|
76
|
+
return undefined;
|
|
77
|
+
}
|
|
78
|
+
return coerceFloat(value);
|
|
79
|
+
};
|
|
80
|
+
export const maybeCoerceBoolean = (value) => {
|
|
81
|
+
if (value === undefined) {
|
|
82
|
+
return undefined;
|
|
83
|
+
}
|
|
84
|
+
return coerceBoolean(value);
|
|
85
|
+
};
|
|
86
|
+
export const safeJSON = (text) => {
|
|
87
|
+
try {
|
|
88
|
+
return JSON.parse(text);
|
|
89
|
+
}
|
|
90
|
+
catch (err) {
|
|
91
|
+
return undefined;
|
|
92
|
+
}
|
|
93
|
+
};
|
|
94
|
+
//# sourceMappingURL=values.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"values.mjs","sourceRoot":"","sources":["../../src/internal/utils/values.ts"],"names":[],"mappings":"AAAA,sFAAsF;OAE/E,EAAE,aAAa,EAAE;AAExB,iDAAiD;AACjD,MAAM,sBAAsB,GAAG,sBAAsB,CAAC;AAEtD,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,GAAW,EAAW,EAAE;IACpD,OAAO,sBAAsB,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAC1C,CAAC,CAAC;AAEF,MAAM,CAAC,IAAI,OAAO,GAAG,CAAC,GAAY,EAAoB,EAAE,CAAC,CAAC,CAAC,OAAO,GAAG,KAAK,CAAC,OAAO,CAAC,EAAE,OAAO,CAAC,GAAG,CAAC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AAK,CAAC,CAAC;AAC9B,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,KAAc,EAAsB,EAAE;IACrE,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;QACxB,OAAO,SAAS,CAAC;IACnB,CAAC;IACD,OAAO,WAAW,CAAC,KAAK,CAAC,CAAC;AAC5B,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAC,KAAc,EAAuB,EAAE;IACxE,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;QACxB,OAAO,SAAS,CAAC;IACnB,CAAC;IACD,OAAO,aAAa,CAAC,KAAK,CAAC,CAAC;AAC9B,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,QAAQ,GAAG,CAAC,IAAY,EAAE,EAAE;IACvC,IAAI,CAAC;QACH,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IAC1B,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,OAAO,SAAS,CAAC;IACnB,CAAC;AACH,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.d.mts","sourceRoot":"","sources":["../src/internal/utils.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/internal/utils.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
const tslib_1 = require("./tslib.js");
|
|
5
|
+
tslib_1.__exportStar(require("./utils/values.js"), exports);
|
|
6
|
+
tslib_1.__exportStar(require("./utils/base64.js"), exports);
|
|
7
|
+
tslib_1.__exportStar(require("./utils/env.js"), exports);
|
|
8
|
+
tslib_1.__exportStar(require("./utils/log.js"), exports);
|
|
9
|
+
tslib_1.__exportStar(require("./utils/uuid.js"), exports);
|
|
10
|
+
tslib_1.__exportStar(require("./utils/sleep.js"), exports);
|
|
11
|
+
//# sourceMappingURL=utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../src/internal/utils.ts"],"names":[],"mappings":";AAAA,sFAAsF;;;AAEtF,4DAA+B;AAC/B,4DAA+B;AAC/B,yDAA4B;AAC5B,yDAA4B;AAC5B,0DAA6B;AAC7B,2DAA8B"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
2
|
+
export * from "./utils/values.mjs";
|
|
3
|
+
export * from "./utils/base64.mjs";
|
|
4
|
+
export * from "./utils/env.mjs";
|
|
5
|
+
export * from "./utils/log.mjs";
|
|
6
|
+
export * from "./utils/uuid.mjs";
|
|
7
|
+
export * from "./utils/sleep.mjs";
|
|
8
|
+
//# sourceMappingURL=utils.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.mjs","sourceRoot":"","sources":["../src/internal/utils.ts"],"names":[],"mappings":"AAAA,sFAAsF"}
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import { PrivyClient } from "../public-api/PrivyClient.mjs";
|
|
2
|
+
/**
|
|
3
|
+
* The authorization context should contain:
|
|
4
|
+
* - Any authorization private keys that must sign the request
|
|
5
|
+
* - The JWTs for any users that must sign the request
|
|
6
|
+
* - Any additional signatures you have computed for the request
|
|
7
|
+
*
|
|
8
|
+
* The Privy client will accept the authorization context, sign the request given the parameters,
|
|
9
|
+
* and include all signatures in the privy-authorization-signature header to the API.
|
|
10
|
+
*/
|
|
11
|
+
export interface AuthorizationContext {
|
|
12
|
+
/**
|
|
13
|
+
* The private keys to use for authorization.
|
|
14
|
+
* These should be base64-encoded PKCS8-formatted private keys, with no PEM headers.
|
|
15
|
+
*/
|
|
16
|
+
authorization_private_keys?: string[];
|
|
17
|
+
/**
|
|
18
|
+
* The JWTs for the users that should sign the request authorization.
|
|
19
|
+
* These should be valid JWTs for the user.
|
|
20
|
+
*/
|
|
21
|
+
user_jwts?: string[];
|
|
22
|
+
/**
|
|
23
|
+
* The signatures that should be used for authorization.
|
|
24
|
+
* These should be base64-encoded signatures.
|
|
25
|
+
*/
|
|
26
|
+
signatures?: string[];
|
|
27
|
+
/**
|
|
28
|
+
* Sign functions can be used to sign requests directly, by managing the private keys and signing
|
|
29
|
+
* logic externally.
|
|
30
|
+
*
|
|
31
|
+
* Sign functions should perform an ECDSA P-256 signature on the payload received, and return the
|
|
32
|
+
* base64-encoded signature.
|
|
33
|
+
*/
|
|
34
|
+
sign_fns?: AuthorizationContext.SignFn[];
|
|
35
|
+
}
|
|
36
|
+
export declare namespace AuthorizationContext {
|
|
37
|
+
type SignFn = (payload: Uint8Array) => Promise<string>;
|
|
38
|
+
}
|
|
39
|
+
export type WalletApiRequestSignatureInput = {
|
|
40
|
+
/** Signature version. 1 is currently the only valid version. */
|
|
41
|
+
version: 1;
|
|
42
|
+
/** Request method. Signatures are not required on 'GET' requests. */
|
|
43
|
+
method: 'POST' | 'PUT' | 'PATCH' | 'DELETE';
|
|
44
|
+
/** URL for the request. Should not contain a trailing slash. */
|
|
45
|
+
url: string;
|
|
46
|
+
/** Request body. */
|
|
47
|
+
body: any;
|
|
48
|
+
/** Privy-specific headers. */
|
|
49
|
+
headers: {
|
|
50
|
+
'privy-app-id': string;
|
|
51
|
+
'privy-idempotency-key'?: string;
|
|
52
|
+
};
|
|
53
|
+
};
|
|
54
|
+
/**
|
|
55
|
+
* Formats the request payload into the expected authorization payload, canconicalizes it,
|
|
56
|
+
* and encodes the JSON string into bytes.
|
|
57
|
+
*
|
|
58
|
+
* @param request The request to be formatted.
|
|
59
|
+
* @return The raw bytes representing the authorization payload.
|
|
60
|
+
*/
|
|
61
|
+
export declare function formatRequestForAuthorizationSignature(input: WalletApiRequestSignatureInput): Uint8Array;
|
|
62
|
+
/**
|
|
63
|
+
* Generates authorization signatures from the given authorization context and signable request.
|
|
64
|
+
* This method handles JWT exchange and private key signing.
|
|
65
|
+
*
|
|
66
|
+
* Manual signing of requests is intended for advanced use cases.
|
|
67
|
+
*
|
|
68
|
+
* @param authorizationContext The authorization context containing JWTs, private keys, and signatures.
|
|
69
|
+
* @param input The request payload to sign.
|
|
70
|
+
* @returns An array of authorization signatures.
|
|
71
|
+
*/
|
|
72
|
+
export declare function generateAuthorizationSignatures(client: PrivyClient, { authorizationContext, input, }: {
|
|
73
|
+
authorizationContext: AuthorizationContext;
|
|
74
|
+
input: WalletApiRequestSignatureInput;
|
|
75
|
+
}): Promise<string[]>;
|
|
76
|
+
/**
|
|
77
|
+
* Signs the given request with the provided private key.
|
|
78
|
+
*
|
|
79
|
+
* @param authorizationPrivateKey The base64-encoded PKCS8-formatted private key, with no PEM headers.
|
|
80
|
+
* @param input The request payload to sign, or one serialized using {@link formatRequestForAuthorizationSignature}.
|
|
81
|
+
* @return The authorization signature.
|
|
82
|
+
*/
|
|
83
|
+
export declare function generateAuthorizationSignature({ authorizationPrivateKey, input, }: {
|
|
84
|
+
authorizationPrivateKey: string;
|
|
85
|
+
input: WalletApiRequestSignatureInput | Uint8Array;
|
|
86
|
+
}): string;
|
|
87
|
+
//# sourceMappingURL=authorization.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"authorization.d.mts","sourceRoot":"","sources":["../src/lib/authorization.ts"],"names":[],"mappings":"OAKO,EAAE,WAAW,EAAE;AAEtB;;;;;;;;GAQG;AACH,MAAM,WAAW,oBAAoB;IACnC;;;OAGG;IACH,0BAA0B,CAAC,EAAE,MAAM,EAAE,CAAC;IACtC;;;OAGG;IACH,SAAS,CAAC,EAAE,MAAM,EAAE,CAAC;IACrB;;;OAGG;IACH,UAAU,CAAC,EAAE,MAAM,EAAE,CAAC;IACtB;;;;;;OAMG;IACH,QAAQ,CAAC,EAAE,oBAAoB,CAAC,MAAM,EAAE,CAAC;CAC1C;AAED,yBAAiB,oBAAoB,CAAC;IACpC,KAAY,MAAM,GAAG,CAAC,OAAO,EAAE,UAAU,KAAK,OAAO,CAAC,MAAM,CAAC,CAAC;CAC/D;AAED,MAAM,MAAM,8BAA8B,GAAG;IAC3C,gEAAgE;IAChE,OAAO,EAAE,CAAC,CAAC;IACX,qEAAqE;IACrE,MAAM,EAAE,MAAM,GAAG,KAAK,GAAG,OAAO,GAAG,QAAQ,CAAC;IAC5C,gEAAgE;IAChE,GAAG,EAAE,MAAM,CAAC;IACZ,oBAAoB;IACpB,IAAI,EAAE,GAAG,CAAC;IACV,8BAA8B;IAC9B,OAAO,EAAE;QACP,cAAc,EAAE,MAAM,CAAC;QACvB,uBAAuB,CAAC,EAAE,MAAM,CAAC;KAClC,CAAC;CACH,CAAC;AAEF;;;;;;GAMG;AACH,wBAAgB,sCAAsC,CAAC,KAAK,EAAE,8BAA8B,GAAG,UAAU,CAYxG;AAED;;;;;;;;;GASG;AACH,wBAAsB,+BAA+B,CACnD,MAAM,EAAE,WAAW,EACnB,EACE,oBAAoB,EACpB,KAAK,GACN,EAAE;IACD,oBAAoB,EAAE,oBAAoB,CAAC;IAC3C,KAAK,EAAE,8BAA8B,CAAC;CACvC,GACA,OAAO,CAAC,MAAM,EAAE,CAAC,CA4BnB;AAED;;;;;;GAMG;AACH,wBAAgB,8BAA8B,CAAC,EAC7C,uBAAuB,EACvB,KAAK,GACN,EAAE;IACD,uBAAuB,EAAE,MAAM,CAAC;IAChC,KAAK,EAAE,8BAA8B,GAAG,UAAU,CAAC;CACpD,GAAG,MAAM,CAOT"}
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import { PrivyClient } from "../public-api/PrivyClient.js";
|
|
2
|
+
/**
|
|
3
|
+
* The authorization context should contain:
|
|
4
|
+
* - Any authorization private keys that must sign the request
|
|
5
|
+
* - The JWTs for any users that must sign the request
|
|
6
|
+
* - Any additional signatures you have computed for the request
|
|
7
|
+
*
|
|
8
|
+
* The Privy client will accept the authorization context, sign the request given the parameters,
|
|
9
|
+
* and include all signatures in the privy-authorization-signature header to the API.
|
|
10
|
+
*/
|
|
11
|
+
export interface AuthorizationContext {
|
|
12
|
+
/**
|
|
13
|
+
* The private keys to use for authorization.
|
|
14
|
+
* These should be base64-encoded PKCS8-formatted private keys, with no PEM headers.
|
|
15
|
+
*/
|
|
16
|
+
authorization_private_keys?: string[];
|
|
17
|
+
/**
|
|
18
|
+
* The JWTs for the users that should sign the request authorization.
|
|
19
|
+
* These should be valid JWTs for the user.
|
|
20
|
+
*/
|
|
21
|
+
user_jwts?: string[];
|
|
22
|
+
/**
|
|
23
|
+
* The signatures that should be used for authorization.
|
|
24
|
+
* These should be base64-encoded signatures.
|
|
25
|
+
*/
|
|
26
|
+
signatures?: string[];
|
|
27
|
+
/**
|
|
28
|
+
* Sign functions can be used to sign requests directly, by managing the private keys and signing
|
|
29
|
+
* logic externally.
|
|
30
|
+
*
|
|
31
|
+
* Sign functions should perform an ECDSA P-256 signature on the payload received, and return the
|
|
32
|
+
* base64-encoded signature.
|
|
33
|
+
*/
|
|
34
|
+
sign_fns?: AuthorizationContext.SignFn[];
|
|
35
|
+
}
|
|
36
|
+
export declare namespace AuthorizationContext {
|
|
37
|
+
type SignFn = (payload: Uint8Array) => Promise<string>;
|
|
38
|
+
}
|
|
39
|
+
export type WalletApiRequestSignatureInput = {
|
|
40
|
+
/** Signature version. 1 is currently the only valid version. */
|
|
41
|
+
version: 1;
|
|
42
|
+
/** Request method. Signatures are not required on 'GET' requests. */
|
|
43
|
+
method: 'POST' | 'PUT' | 'PATCH' | 'DELETE';
|
|
44
|
+
/** URL for the request. Should not contain a trailing slash. */
|
|
45
|
+
url: string;
|
|
46
|
+
/** Request body. */
|
|
47
|
+
body: any;
|
|
48
|
+
/** Privy-specific headers. */
|
|
49
|
+
headers: {
|
|
50
|
+
'privy-app-id': string;
|
|
51
|
+
'privy-idempotency-key'?: string;
|
|
52
|
+
};
|
|
53
|
+
};
|
|
54
|
+
/**
|
|
55
|
+
* Formats the request payload into the expected authorization payload, canconicalizes it,
|
|
56
|
+
* and encodes the JSON string into bytes.
|
|
57
|
+
*
|
|
58
|
+
* @param request The request to be formatted.
|
|
59
|
+
* @return The raw bytes representing the authorization payload.
|
|
60
|
+
*/
|
|
61
|
+
export declare function formatRequestForAuthorizationSignature(input: WalletApiRequestSignatureInput): Uint8Array;
|
|
62
|
+
/**
|
|
63
|
+
* Generates authorization signatures from the given authorization context and signable request.
|
|
64
|
+
* This method handles JWT exchange and private key signing.
|
|
65
|
+
*
|
|
66
|
+
* Manual signing of requests is intended for advanced use cases.
|
|
67
|
+
*
|
|
68
|
+
* @param authorizationContext The authorization context containing JWTs, private keys, and signatures.
|
|
69
|
+
* @param input The request payload to sign.
|
|
70
|
+
* @returns An array of authorization signatures.
|
|
71
|
+
*/
|
|
72
|
+
export declare function generateAuthorizationSignatures(client: PrivyClient, { authorizationContext, input, }: {
|
|
73
|
+
authorizationContext: AuthorizationContext;
|
|
74
|
+
input: WalletApiRequestSignatureInput;
|
|
75
|
+
}): Promise<string[]>;
|
|
76
|
+
/**
|
|
77
|
+
* Signs the given request with the provided private key.
|
|
78
|
+
*
|
|
79
|
+
* @param authorizationPrivateKey The base64-encoded PKCS8-formatted private key, with no PEM headers.
|
|
80
|
+
* @param input The request payload to sign, or one serialized using {@link formatRequestForAuthorizationSignature}.
|
|
81
|
+
* @return The authorization signature.
|
|
82
|
+
*/
|
|
83
|
+
export declare function generateAuthorizationSignature({ authorizationPrivateKey, input, }: {
|
|
84
|
+
authorizationPrivateKey: string;
|
|
85
|
+
input: WalletApiRequestSignatureInput | Uint8Array;
|
|
86
|
+
}): string;
|
|
87
|
+
//# sourceMappingURL=authorization.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"authorization.d.ts","sourceRoot":"","sources":["../src/lib/authorization.ts"],"names":[],"mappings":"OAKO,EAAE,WAAW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AE,8BAA8B,GAAG,UAAU,CAAC;CACpD,GAAG,MAAM,CAOT"}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.formatRequestForAuthorizationSignature = formatRequestForAuthorizationSignature;
|
|
4
|
+
exports.generateAuthorizationSignatures = generateAuthorizationSignatures;
|
|
5
|
+
exports.generateAuthorizationSignature = generateAuthorizationSignature;
|
|
6
|
+
const tslib_1 = require("../internal/tslib.js");
|
|
7
|
+
const nist_1 = require("@noble/curves/nist");
|
|
8
|
+
const sha2_1 = require("@noble/hashes/sha2");
|
|
9
|
+
const canonicalize_1 = tslib_1.__importDefault(require("canonicalize"));
|
|
10
|
+
const error_1 = require("../core/error.js");
|
|
11
|
+
const cryptography_1 = require("./cryptography.js");
|
|
12
|
+
/**
|
|
13
|
+
* Formats the request payload into the expected authorization payload, canconicalizes it,
|
|
14
|
+
* and encodes the JSON string into bytes.
|
|
15
|
+
*
|
|
16
|
+
* @param request The request to be formatted.
|
|
17
|
+
* @return The raw bytes representing the authorization payload.
|
|
18
|
+
*/
|
|
19
|
+
function formatRequestForAuthorizationSignature(input) {
|
|
20
|
+
const body = input.body;
|
|
21
|
+
if (typeof body === 'object' && body !== null && Object.keys(body).length === 0) {
|
|
22
|
+
// This is a special case, where if the body is empty, we want to serialize it
|
|
23
|
+
// as an empty string.
|
|
24
|
+
input.body = '';
|
|
25
|
+
}
|
|
26
|
+
const serializedInput = (0, canonicalize_1.default)(input);
|
|
27
|
+
if (!serializedInput) {
|
|
28
|
+
throw new error_1.PrivyAPIError('Failed to serialize request for authorization signature');
|
|
29
|
+
}
|
|
30
|
+
return new TextEncoder().encode(serializedInput);
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Generates authorization signatures from the given authorization context and signable request.
|
|
34
|
+
* This method handles JWT exchange and private key signing.
|
|
35
|
+
*
|
|
36
|
+
* Manual signing of requests is intended for advanced use cases.
|
|
37
|
+
*
|
|
38
|
+
* @param authorizationContext The authorization context containing JWTs, private keys, and signatures.
|
|
39
|
+
* @param input The request payload to sign.
|
|
40
|
+
* @returns An array of authorization signatures.
|
|
41
|
+
*/
|
|
42
|
+
async function generateAuthorizationSignatures(client, { authorizationContext, input, }) {
|
|
43
|
+
const payload = formatRequestForAuthorizationSignature(input);
|
|
44
|
+
const userJwts = authorizationContext.user_jwts ?? [];
|
|
45
|
+
let userKeys = [];
|
|
46
|
+
if (userJwts.length > 0) {
|
|
47
|
+
userKeys = await Promise.all(userJwts.map((jwt) => client._jwtExchange().exchangeJwtForAuthorizationKey(jwt)));
|
|
48
|
+
}
|
|
49
|
+
/** These are the private keys provided by the caller, either directly or via JWT exchange */
|
|
50
|
+
const privateKeys = [...(authorizationContext.authorization_private_keys ?? []), ...userKeys];
|
|
51
|
+
/** These are the signatures calculated from the private keys */
|
|
52
|
+
const calculatedSignatures = privateKeys.map((sk) => generateAuthorizationSignature({ authorizationPrivateKey: sk, input: payload }));
|
|
53
|
+
/** These are the signatures calculated externally from the given sign functions */
|
|
54
|
+
const signFnSignatures = await Promise.all((authorizationContext.sign_fns ?? []).map((signFn) => signFn(payload)));
|
|
55
|
+
/** These are the signatures provided directly by the caller */
|
|
56
|
+
const providedRawSignatures = authorizationContext.signatures ?? [];
|
|
57
|
+
return [...providedRawSignatures, ...calculatedSignatures, ...signFnSignatures];
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Signs the given request with the provided private key.
|
|
61
|
+
*
|
|
62
|
+
* @param authorizationPrivateKey The base64-encoded PKCS8-formatted private key, with no PEM headers.
|
|
63
|
+
* @param input The request payload to sign, or one serialized using {@link formatRequestForAuthorizationSignature}.
|
|
64
|
+
* @return The authorization signature.
|
|
65
|
+
*/
|
|
66
|
+
function generateAuthorizationSignature({ authorizationPrivateKey, input, }) {
|
|
67
|
+
const payload = input instanceof Uint8Array ? input : formatRequestForAuthorizationSignature(input);
|
|
68
|
+
const privateKey = (0, cryptography_1.importPKCS8PrivateKey)(authorizationPrivateKey);
|
|
69
|
+
const signature = nist_1.p256.sign((0, sha2_1.sha256)(payload), privateKey).toBytes('der');
|
|
70
|
+
// We fall back to `Buffer` here as Uint8Array.toBase64 is not widely supported yet
|
|
71
|
+
return Buffer.from(signature).toString('base64');
|
|
72
|
+
}
|
|
73
|
+
//# sourceMappingURL=authorization.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"authorization.js","sourceRoot":"","sources":["../src/lib/authorization.ts"],"names":[],"mappings":";;AAqEA,wFAYC;AAYD,0EAqCC;AASD,wEAaC;;AAxJD,6CAA0C;AAC1C,6CAA4C;AAC5C,wEAAwC;AACxC,4CAA8C;AAC9C,oDAAuD;AA0DvD;;;;;;GAMG;AACH,SAAgB,sCAAsC,CAAC,KAAqC;IAC1F,MAAM,IAAI,GAAY,KAAK,CAAC,IAAI,CAAC;IACjC,IAAI,OAAO,IAAI,KAAK,QAAQ,IAAI,IAAI,KAAK,IAAI,IAAI,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QAChF,8EAA8E;QAC9E,sBAAsB;QACtB,KAAK,CAAC,IAAI,GAAG,EAAE,CAAC;IAClB,CAAC;IACD,MAAM,eAAe,GAAG,IAAA,sBAAY,EAAC,KAAK,CAAC,CAAC;IAC5C,IAAI,CAAC,eAAe,EAAE,CAAC;QACrB,MAAM,IAAI,qBAAa,CAAC,yDAAyD,CAAC,CAAC;IACrF,CAAC;IACD,OAAO,IAAI,WAAW,EAAE,CAAC,MAAM,CAAC,eAAe,CAAC,CAAC;AACnD,CAAC;AAED;;;;;;;;;GASG;AACI,KAAK,UAAU,+BAA+B,CACnD,MAAmB,EACnB,EACE,oBAAoB,EACpB,KAAK,GAIN;IAED,MAAM,OAAO,GAAG,sCAAsC,CAAC,KAAK,CAAC,CAAC;IAE9D,MAAM,QAAQ,GAAG,oBAAoB,CAAC,SAAS,I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B,EAAC,uBAAuB,CAAC,CAAC;IAElE,MAAM,SAAS,GAAG,WAAI,CAAC,IAAI,CAAC,IAAA,aAAM,EAAC,OAAO,CAAC,EAAE,UAAU,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;IACxE,mFAAmF;IACnF,OAAO,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;AACnD,CAAC"}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { p256 } from '@noble/curves/nist';
|
|
2
|
+
import { sha256 } from '@noble/hashes/sha2';
|
|
3
|
+
import canonicalize from 'canonicalize';
|
|
4
|
+
import { PrivyAPIError } from "../core/error.mjs";
|
|
5
|
+
import { importPKCS8PrivateKey } from "./cryptography.mjs";
|
|
6
|
+
/**
|
|
7
|
+
* Formats the request payload into the expected authorization payload, canconicalizes it,
|
|
8
|
+
* and encodes the JSON string into bytes.
|
|
9
|
+
*
|
|
10
|
+
* @param request The request to be formatted.
|
|
11
|
+
* @return The raw bytes representing the authorization payload.
|
|
12
|
+
*/
|
|
13
|
+
export function formatRequestForAuthorizationSignature(input) {
|
|
14
|
+
const body = input.body;
|
|
15
|
+
if (typeof body === 'object' && body !== null && Object.keys(body).length === 0) {
|
|
16
|
+
// This is a special case, where if the body is empty, we want to serialize it
|
|
17
|
+
// as an empty string.
|
|
18
|
+
input.body = '';
|
|
19
|
+
}
|
|
20
|
+
const serializedInput = canonicalize(input);
|
|
21
|
+
if (!serializedInput) {
|
|
22
|
+
throw new PrivyAPIError('Failed to serialize request for authorization signature');
|
|
23
|
+
}
|
|
24
|
+
return new TextEncoder().encode(serializedInput);
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Generates authorization signatures from the given authorization context and signable request.
|
|
28
|
+
* This method handles JWT exchange and private key signing.
|
|
29
|
+
*
|
|
30
|
+
* Manual signing of requests is intended for advanced use cases.
|
|
31
|
+
*
|
|
32
|
+
* @param authorizationContext The authorization context containing JWTs, private keys, and signatures.
|
|
33
|
+
* @param input The request payload to sign.
|
|
34
|
+
* @returns An array of authorization signatures.
|
|
35
|
+
*/
|
|
36
|
+
export async function generateAuthorizationSignatures(client, { authorizationContext, input, }) {
|
|
37
|
+
const payload = formatRequestForAuthorizationSignature(input);
|
|
38
|
+
const userJwts = authorizationContext.user_jwts ?? [];
|
|
39
|
+
let userKeys = [];
|
|
40
|
+
if (userJwts.length > 0) {
|
|
41
|
+
userKeys = await Promise.all(userJwts.map((jwt) => client._jwtExchange().exchangeJwtForAuthorizationKey(jwt)));
|
|
42
|
+
}
|
|
43
|
+
/** These are the private keys provided by the caller, either directly or via JWT exchange */
|
|
44
|
+
const privateKeys = [...(authorizationContext.authorization_private_keys ?? []), ...userKeys];
|
|
45
|
+
/** These are the signatures calculated from the private keys */
|
|
46
|
+
const calculatedSignatures = privateKeys.map((sk) => generateAuthorizationSignature({ authorizationPrivateKey: sk, input: payload }));
|
|
47
|
+
/** These are the signatures calculated externally from the given sign functions */
|
|
48
|
+
const signFnSignatures = await Promise.all((authorizationContext.sign_fns ?? []).map((signFn) => signFn(payload)));
|
|
49
|
+
/** These are the signatures provided directly by the caller */
|
|
50
|
+
const providedRawSignatures = authorizationContext.signatures ?? [];
|
|
51
|
+
return [...providedRawSignatures, ...calculatedSignatures, ...signFnSignatures];
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Signs the given request with the provided private key.
|
|
55
|
+
*
|
|
56
|
+
* @param authorizationPrivateKey The base64-encoded PKCS8-formatted private key, with no PEM headers.
|
|
57
|
+
* @param input The request payload to sign, or one serialized using {@link formatRequestForAuthorizationSignature}.
|
|
58
|
+
* @return The authorization signature.
|
|
59
|
+
*/
|
|
60
|
+
export function generateAuthorizationSignature({ authorizationPrivateKey, input, }) {
|
|
61
|
+
const payload = input instanceof Uint8Array ? input : formatRequestForAuthorizationSignature(input);
|
|
62
|
+
const privateKey = importPKCS8PrivateKey(authorizationPrivateKey);
|
|
63
|
+
const signature = p256.sign(sha256(payload), privateKey).toBytes('der');
|
|
64
|
+
// We fall back to `Buffer` here as Uint8Array.toBase64 is not widely supported yet
|
|
65
|
+
return Buffer.from(signature).toString('base64');
|
|
66
|
+
}
|
|
67
|
+
//# sourceMappingURL=authorization.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"authorization.mjs","sourceRoot":"","sources":["../src/lib/authorization.ts"],"names":[],"mappings":"OAAO,EAAE,IAAI,EAAE,MAAM,oBAAoB;OAClC,EAAE,MAAM,EAAE,MAAM,oBAAoB;OACpC,YAAY,MAAM,cAAc;OAChC,EAAE,aAAa,EAAE;OACjB,EAAE,qBAAqB,EAAE;AA0DhC;;;;;;GAMG;AACH,MAAM,UAAU,sCAAsC,CAAC,KAAqC;IAC1F,MAAM,IAAI,GAAY,KAAK,CAAC,IAAI,CAAC;IACjC,IAAI,OAAO,IAAI,KAAK,QAAQ,IAAI,IAAI,KAAK,IAAI,IAAI,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QAChF,8EAA8E;QAC9E,sBAAsB;QACtB,KAAK,CAAC,IAAI,GAAG,EAAE,CAAC;IAClB,CAAC;IACD,MAAM,eAAe,GAAG,YAAY,CAAC,KAAK,CAAC,CAAC;IAC5C,IAAI,CAAC,eAAe,EAAE,CAAC;QACrB,MAAM,IAAI,aAAa,CAAC,yDAAyD,CAAC,CAAC;IACrF,CAAC;IACD,OAAO,IAAI,WAAW,EAAE,CAAC,MAAM,CAAC,eAAe,CAAC,CAAC;AACnD,CAAC;AAED;;;;;;;;;GASG;AACH,MAAM,CAAC,KAAK,UAAU,+BAA+B,CACnD,MAAmB,EACnB,EACE,oBAAoB,EACpB,KAAK,GAIN;IAED,MAAM,OAAO,GAAG,sCAAsC,CAAC,KAAK,CAAC,CAAC;IAE9D,MAAM,QAAQ,GAAG,oBAAoB,CAAC,SAAS,IAAI,EAAE,CAAC;IACtD,IAA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;IAElE,MAAM,SAAS,GAAG,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,EAAE,UAAU,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;IACxE,mFAAmF;IACnF,OAAO,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;AACnD,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cryptography.d.mts","sourceRoot":"","sources":["../src/lib/cryptography.ts"],"names":[],"mappings":"AA+EA,yBAAiB,UAAU,CAAC;IAC1B,UAAiB,oBAAoB;QACnC,UAAU,EAAE,UAAU,CAAC;QACvB,eAAe,EAAE,UAAU,CAAC;KAC7B;CACF;AAED,wBAAsB,eAAe,IAAI,OAAO,CAAC,UAAU,CAAC,CAsB3D"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cryptography.d.ts","sourceRoot":"","sources":["../src/lib/cryptography.ts"],"names":[],"mappings":"AA+EA,yBAAiB,UAAU,CAAC;IAC1B,UAAiB,oBAAoB;QACnC,UAAU,EAAE,UAAU,CAAC;QACvB,eAAe,EAAE,UAAU,CAAC;KAC7B;CACF;AAED,wBAAsB,eAAe,IAAI,OAAO,CAAC,UAAU,CAAC,CAsB3D"}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.importPKCS8PrivateKey = importPKCS8PrivateKey;
|
|
4
|
+
exports.setupHPKERecipient = setupHPKERecipient;
|
|
5
|
+
exports.setupHPKESender = setupHPKESender;
|
|
6
|
+
const chacha20poly1305_1 = require("@hpke/chacha20poly1305");
|
|
7
|
+
const core_1 = require("@hpke/core");
|
|
8
|
+
const nist_1 = require("@noble/curves/nist");
|
|
9
|
+
/**
|
|
10
|
+
* Imports a P-256 private key for use with the `@noble/curves` library.
|
|
11
|
+
*
|
|
12
|
+
* @param privateKey - A base64-encoded PKCS8-formatted private key, with no PEM headers.
|
|
13
|
+
* @returns A private key object for the P-256 curve.
|
|
14
|
+
* @internal
|
|
15
|
+
*/
|
|
16
|
+
function importPKCS8PrivateKey(privateKey) {
|
|
17
|
+
// We fall back to `Buffer` here as Uint8Array.fromBase64 is not widely supported yet
|
|
18
|
+
const pkcs8Bytes = Buffer.from(privateKey, 'base64');
|
|
19
|
+
const privateKeyStart = pkcs8Bytes.indexOf(Buffer.from([0x04, 0x20]));
|
|
20
|
+
if (privateKeyStart === -1) {
|
|
21
|
+
throw new Error('Invalid wallet authorization private key');
|
|
22
|
+
}
|
|
23
|
+
const privateKeyBytes = pkcs8Bytes.subarray(privateKeyStart + 2, privateKeyStart + 34);
|
|
24
|
+
return nist_1.p256.Point.Fn.fromBytes(privateKeyBytes);
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Sets up HPKE for securely requesting a payload (as the recipient)
|
|
28
|
+
* from a sender (e.g. the Privy API).
|
|
29
|
+
* @returns The HPKE receiver object.
|
|
30
|
+
* @internal
|
|
31
|
+
*/
|
|
32
|
+
async function setupHPKERecipient() {
|
|
33
|
+
const suite = new core_1.CipherSuite({
|
|
34
|
+
kem: new core_1.DhkemP256HkdfSha256(),
|
|
35
|
+
kdf: new core_1.HkdfSha256(),
|
|
36
|
+
aead: new chacha20poly1305_1.Chacha20Poly1305(),
|
|
37
|
+
});
|
|
38
|
+
const keypair = await suite.kem.generateKeyPair();
|
|
39
|
+
const publicKeySpki = await crypto.subtle.exportKey('spki', keypair.publicKey);
|
|
40
|
+
return {
|
|
41
|
+
publicKeySpki: new Uint8Array(publicKeySpki),
|
|
42
|
+
decryptPayload: async (encapsulatedKey, ciphertext) => {
|
|
43
|
+
const recipient = await suite.createRecipientContext({
|
|
44
|
+
recipientKey: keypair.privateKey,
|
|
45
|
+
enc: encapsulatedKey,
|
|
46
|
+
});
|
|
47
|
+
const decodedBytes = await recipient.open(ciphertext);
|
|
48
|
+
return new Uint8Array(decodedBytes);
|
|
49
|
+
},
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
async function setupHPKESender() {
|
|
53
|
+
const suite = new core_1.CipherSuite({
|
|
54
|
+
kem: new core_1.DhkemP256HkdfSha256(),
|
|
55
|
+
kdf: new core_1.HkdfSha256(),
|
|
56
|
+
aead: new chacha20poly1305_1.Chacha20Poly1305(),
|
|
57
|
+
});
|
|
58
|
+
return {
|
|
59
|
+
encryptPayload: async (publicKey, payload) => {
|
|
60
|
+
const recipientPublicKey = await suite.kem.deserializePublicKey(publicKey);
|
|
61
|
+
const sender = await suite.createSenderContext({
|
|
62
|
+
recipientPublicKey,
|
|
63
|
+
});
|
|
64
|
+
const ciphertext = await sender.seal(payload);
|
|
65
|
+
return {
|
|
66
|
+
ciphertext: new Uint8Array(ciphertext),
|
|
67
|
+
encapsulatedKey: new Uint8Array(sender.enc),
|
|
68
|
+
};
|
|
69
|
+
},
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
//# sourceMappingURL=cryptography.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cryptography.js","sourceRoot":"","sources":["../src/lib/cryptography.ts"],"names":[],"mappings":";;AAYA,sDAUC;AAqBD,gDAuBC;AAoBD,0CAsBC;AA5GD,6DAA0D;AAC1D,qCAA0E;AAC1E,6CAA0C;AAG1C;;;;;;GAMG;AACH,SAAgB,qBAAqB,CAAC,UAAkB;IACtD,qFAAqF;IACrF,MAAM,UAAU,GAAG,MAAM,CAAC,IAAI,CAAC,UAAU,EAAE,QAAQ,CAAC,CAAC;IACrD,MAAM,eAAe,GAAG,UAAU,CAAC,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC;IAEtE,IAAI,eAAe,KAAK,CAAC,CAAC,EAAE,CAAC;QAC3B,MAAM,IAAI,KAAK,CAAC,0CAA0C,CAAC,CAAC;IAC9D,CAAC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