@dynamic-labs/sdk-react-core 5.3.2 → 5.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 +22 -0
- package/package.cjs +2 -2
- package/package.js +2 -2
- package/package.json +14 -14
- package/src/index.cjs +2 -0
- package/src/index.d.ts +1 -1
- package/src/index.js +1 -0
- package/src/lib/utils/hooks/index.d.ts +1 -0
- package/src/lib/utils/hooks/useDynamicWaas/useDynamicWaas.cjs +2 -1
- package/src/lib/utils/hooks/useDynamicWaas/useDynamicWaas.d.ts +3 -1
- package/src/lib/utils/hooks/useDynamicWaas/useDynamicWaas.js +2 -1
- package/src/lib/utils/hooks/usePolicies/index.d.ts +1 -0
- package/src/lib/utils/hooks/usePolicies/usePolicies.cjs +64 -0
- package/src/lib/utils/hooks/usePolicies/usePolicies.d.ts +36 -0
- package/src/lib/utils/hooks/usePolicies/usePolicies.js +60 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,4 +1,26 @@
|
|
|
1
1
|
|
|
2
|
+
## [5.4.0](https://github.com/dynamic-labs/dynamic-auth/compare/v5.3.2...v5.4.0) (2026-08-25)
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
### Features
|
|
6
|
+
|
|
7
|
+
* **aleo:** wire up signMessage on the WaaS Aleo connector ([#12235](https://github.com/dynamic-labs/dynamic-auth/issues/12235)) ([e56cbf5](https://github.com/dynamic-labs/dynamic-auth/commit/e56cbf5546bdcc21ce916dece43ae36dcea9b808))
|
|
8
|
+
* **waas:** thread isRawScalarImport through importPrivateKey for ed25519 chains ([#12220](https://github.com/dynamic-labs/dynamic-auth/issues/12220)) ([ced9efa](https://github.com/dynamic-labs/dynamic-auth/commit/ced9efac5fa5a4a1280383419f56fe22733722cd))
|
|
9
|
+
* **webview:** add policies message contract and controller ([#12248](https://github.com/dynamic-labs/dynamic-auth/issues/12248)) ([8557c1e](https://github.com/dynamic-labs/dynamic-auth/commit/8557c1ed3861e12f1f06b2bb610184813b577daa))
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
### Bug Fixes
|
|
13
|
+
|
|
14
|
+
* **bitcoin:** pass the wallet's address type when signing ([#12265](https://github.com/dynamic-labs/dynamic-auth/issues/12265)) ([b8a8eab](https://github.com/dynamic-labs/dynamic-auth/commit/b8a8eab7e4cc294cc307fb10ea6814e76111a274))
|
|
15
|
+
* remediate high-severity tar vulnerability and prune a dead override ([#12268](https://github.com/dynamic-labs/dynamic-auth/issues/12268)) ([6b1b343](https://github.com/dynamic-labs/dynamic-auth/commit/6b1b343e7947e8da30012446677e342ae9bfe14a))
|
|
16
|
+
* **waas-svm:** fix retry-classification and environmentId gaps in [#12240](https://github.com/dynamic-labs/dynamic-auth/issues/12240) ([#12247](https://github.com/dynamic-labs/dynamic-auth/issues/12247)) ([e79cecc](https://github.com/dynamic-labs/dynamic-auth/commit/e79ceccd424c48c3a7f45fdd6ea288c269ac0171))
|
|
17
|
+
* **wallet-connect:** reopen WalletConnect IndexedDB when the browser closes the connection ([#12262](https://github.com/dynamic-labs/dynamic-auth/issues/12262)) ([1a20dde](https://github.com/dynamic-labs/dynamic-auth/commit/1a20ddeaeec590ae3390c9e47ef3c14738379b83))
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
### Performance Improvements
|
|
21
|
+
|
|
22
|
+
* **ethereum-gasless-core:** parallel 7702 auth signing and long-poll sponsored-tx status ([#12225](https://github.com/dynamic-labs/dynamic-auth/issues/12225)) ([53ca916](https://github.com/dynamic-labs/dynamic-auth/commit/53ca91668f8dd839c52d55a0e5d7bb5257f7f415))
|
|
23
|
+
|
|
2
24
|
### [5.3.2](https://github.com/dynamic-labs/dynamic-auth/compare/v5.3.1...v5.3.2) (2026-08-19)
|
|
3
25
|
|
|
4
26
|
|
package/package.cjs
CHANGED
|
@@ -3,10 +3,10 @@
|
|
|
3
3
|
|
|
4
4
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
5
5
|
|
|
6
|
-
var version = "5.
|
|
6
|
+
var version = "5.4.0";
|
|
7
7
|
var dependencies = {
|
|
8
8
|
"@dynamic-labs/sdk-api-core": "0.12.0",
|
|
9
|
-
"@dynamic-labs-sdk/client": "1.
|
|
9
|
+
"@dynamic-labs-sdk/client": "1.29.0",
|
|
10
10
|
"@dynamic-labs-wallet/browser-wallet-client": "1.0.106",
|
|
11
11
|
"@dynamic-labs-wallet/forward-mpc-client": "1.0.1",
|
|
12
12
|
"@hcaptcha/react-hcaptcha": "1.4.4",
|
package/package.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
'use client'
|
|
2
|
-
var version = "5.
|
|
2
|
+
var version = "5.4.0";
|
|
3
3
|
var dependencies = {
|
|
4
4
|
"@dynamic-labs/sdk-api-core": "0.12.0",
|
|
5
|
-
"@dynamic-labs-sdk/client": "1.
|
|
5
|
+
"@dynamic-labs-sdk/client": "1.29.0",
|
|
6
6
|
"@dynamic-labs-wallet/browser-wallet-client": "1.0.106",
|
|
7
7
|
"@dynamic-labs-wallet/forward-mpc-client": "1.0.1",
|
|
8
8
|
"@hcaptcha/react-hcaptcha": "1.4.4",
|
package/package.json
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dynamic-labs/sdk-react-core",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.4.0",
|
|
4
4
|
"dependencies": {
|
|
5
5
|
"@dynamic-labs/sdk-api-core": "0.12.0",
|
|
6
|
-
"@dynamic-labs-sdk/client": "1.
|
|
6
|
+
"@dynamic-labs-sdk/client": "1.29.0",
|
|
7
7
|
"@dynamic-labs-wallet/browser-wallet-client": "1.0.106",
|
|
8
8
|
"@dynamic-labs-wallet/forward-mpc-client": "1.0.1",
|
|
9
9
|
"@hcaptcha/react-hcaptcha": "1.4.4",
|
|
@@ -18,18 +18,18 @@
|
|
|
18
18
|
"react-i18next": "13.5.0",
|
|
19
19
|
"react-international-phone": "4.5.0",
|
|
20
20
|
"yup": "0.32.11",
|
|
21
|
-
"@dynamic-labs/assert-package-version": "5.
|
|
22
|
-
"@dynamic-labs/iconic": "5.
|
|
23
|
-
"@dynamic-labs/legacy-client": "5.
|
|
24
|
-
"@dynamic-labs/locale": "5.
|
|
25
|
-
"@dynamic-labs/logger": "5.
|
|
26
|
-
"@dynamic-labs/multi-wallet": "5.
|
|
27
|
-
"@dynamic-labs/rpc-providers": "5.
|
|
28
|
-
"@dynamic-labs/store": "5.
|
|
29
|
-
"@dynamic-labs/types": "5.
|
|
30
|
-
"@dynamic-labs/utils": "5.
|
|
31
|
-
"@dynamic-labs/wallet-book": "5.
|
|
32
|
-
"@dynamic-labs/wallet-connector-core": "5.
|
|
21
|
+
"@dynamic-labs/assert-package-version": "5.4.0",
|
|
22
|
+
"@dynamic-labs/iconic": "5.4.0",
|
|
23
|
+
"@dynamic-labs/legacy-client": "5.4.0",
|
|
24
|
+
"@dynamic-labs/locale": "5.4.0",
|
|
25
|
+
"@dynamic-labs/logger": "5.4.0",
|
|
26
|
+
"@dynamic-labs/multi-wallet": "5.4.0",
|
|
27
|
+
"@dynamic-labs/rpc-providers": "5.4.0",
|
|
28
|
+
"@dynamic-labs/store": "5.4.0",
|
|
29
|
+
"@dynamic-labs/types": "5.4.0",
|
|
30
|
+
"@dynamic-labs/utils": "5.4.0",
|
|
31
|
+
"@dynamic-labs/wallet-book": "5.4.0",
|
|
32
|
+
"@dynamic-labs/wallet-connector-core": "5.4.0",
|
|
33
33
|
"eventemitter3": "5.0.1"
|
|
34
34
|
},
|
|
35
35
|
"devDependencies": {
|
package/src/index.cjs
CHANGED
|
@@ -184,6 +184,7 @@ var useSignEip7702Authorization = require('./lib/utils/hooks/useSignEip7702Autho
|
|
|
184
184
|
var useTelegramLogin = require('./lib/utils/hooks/useTelegramLogin/useTelegramLogin.cjs');
|
|
185
185
|
var useDeleteUserAccount = require('./lib/utils/hooks/useDeleteUserAccount/useDeleteUserAccount.cjs');
|
|
186
186
|
var useBusinessAccounts = require('./lib/utils/hooks/useBusinessAccounts/useBusinessAccounts.cjs');
|
|
187
|
+
var usePolicies = require('./lib/utils/hooks/usePolicies/usePolicies.cjs');
|
|
187
188
|
var useExchangeAccounts = require('./lib/utils/hooks/useExchangeAccounts/useExchangeAccounts.cjs');
|
|
188
189
|
var usePayWithDynamic = require('./lib/utils/hooks/usePayWithDynamic/usePayWithDynamic.cjs');
|
|
189
190
|
var useGetPasskeys = require('./lib/utils/hooks/useGetPasskeys/useGetPasskeys.cjs');
|
|
@@ -353,6 +354,7 @@ exports.useSignEip7702Authorization = useSignEip7702Authorization.useSignEip7702
|
|
|
353
354
|
exports.useTelegramLogin = useTelegramLogin.useTelegramLogin;
|
|
354
355
|
exports.useDeleteUserAccount = useDeleteUserAccount.useDeleteUserAccount;
|
|
355
356
|
exports.useBusinessAccounts = useBusinessAccounts.useBusinessAccounts;
|
|
357
|
+
exports.usePolicies = usePolicies.usePolicies;
|
|
356
358
|
exports.useExchangeAccounts = useExchangeAccounts.useExchangeAccounts;
|
|
357
359
|
exports.usePayWithDynamic = usePayWithDynamic.usePayWithDynamic;
|
|
358
360
|
exports.useGetPasskeys = useGetPasskeys.useGetPasskeys;
|
package/src/index.d.ts
CHANGED
|
@@ -123,7 +123,7 @@ export { FilterAndSortWallets, FilterBridgeChainsName, FilterChain, FilterWallet
|
|
|
123
123
|
export {
|
|
124
124
|
/** @deprecated */
|
|
125
125
|
DynamicWidgetContextProvider, } from './lib/widgets/DynamicWidget/context';
|
|
126
|
-
export { useWalletItemActions, useAuthenticateConnectedUser, useSocialAccounts, useEmbeddedReveal, useIsLoggedIn, useDynamicModals, useMfa, useTokenBalances, useMultichainTokenBalances, usePrivateTokenBalances, useSwitchWallet, useRpcProviders, useRefreshUser, useRefreshAuth, useResetWaasSession, useWalletOptions, useSmartWallets, useSignEip7702Authorization, useTelegramLogin, useEVMTransactionSimulation, useSVMTransactionSimulation, useDeleteUserAccount, useDynamicWaas, useBusinessAccounts, useGetPasskeys, useDeletePasskey, useRegisterPasskey, useAuthenticatePasskeyMFA, useGetUserMfaMethods, usePromptMfaAuth, useGetMfaToken, useGetWalletPassword, useIsPasswordEncrypted, useWalletPassword, useIsMfaRequiredForAction, useWalletDelegation, DelegationError, type DelegationOperation, type DelegationWalletRef, useWalletBackup, useBackupWallets, isWalletBackedUp, BackupError, CloudBackupProvider, GOOGLE_DRIVE_BACKUP_REQUIRED_SCOPES, findMissingGoogleDriveBackupScopes, hasAllGoogleDriveBackupScopes, isInsufficientGoogleDriveScopesError, useGoogleDriveBackupReadiness, useExchangeAccounts, useStepUpAuthentication, } from './lib/utils/hooks';
|
|
126
|
+
export { useWalletItemActions, useAuthenticateConnectedUser, useSocialAccounts, useEmbeddedReveal, useIsLoggedIn, useDynamicModals, useMfa, useTokenBalances, useMultichainTokenBalances, usePrivateTokenBalances, useSwitchWallet, useRpcProviders, useRefreshUser, useRefreshAuth, useResetWaasSession, useWalletOptions, useSmartWallets, useSignEip7702Authorization, useTelegramLogin, useEVMTransactionSimulation, useSVMTransactionSimulation, useDeleteUserAccount, useDynamicWaas, useBusinessAccounts, usePolicies, useGetPasskeys, useDeletePasskey, useRegisterPasskey, useAuthenticatePasskeyMFA, useGetUserMfaMethods, usePromptMfaAuth, useGetMfaToken, useGetWalletPassword, useIsPasswordEncrypted, useWalletPassword, useIsMfaRequiredForAction, useWalletDelegation, DelegationError, type DelegationOperation, type DelegationWalletRef, useWalletBackup, useBackupWallets, isWalletBackedUp, BackupError, CloudBackupProvider, GOOGLE_DRIVE_BACKUP_REQUIRED_SCOPES, findMissingGoogleDriveBackupScopes, hasAllGoogleDriveBackupScopes, isInsufficientGoogleDriveScopesError, useGoogleDriveBackupReadiness, useExchangeAccounts, useStepUpAuthentication, } from './lib/utils/hooks';
|
|
127
127
|
export type { GoogleDriveBackupAccessError, GoogleDriveBackupReadiness, GoogleDriveBackupReadinessStatus, UseGoogleDriveBackupReadinessReturn, UsePrivateTokenBalancesArgs, UsePrivateTokenBalancesReturn, } from './lib/utils/hooks';
|
|
128
128
|
export type { IsStepUpRequiredParams, PromptMfaParams, StepUpAuthenticationState, UseStepUpAuthenticationParams, UseStepUpAuthenticationReturn, VerifyOtpParams, VerifyPasskeyMfaParams, VerifyRecoveryCodeParams, VerifySocialParams, VerifyTotpMfaParams, VerifyWalletParams, } from './lib/utils/hooks';
|
|
129
129
|
export { useOnramp } from './lib/utils/hooks/useOnramp';
|
package/src/index.js
CHANGED
|
@@ -180,6 +180,7 @@ export { useSignEip7702Authorization } from './lib/utils/hooks/useSignEip7702Aut
|
|
|
180
180
|
export { useTelegramLogin } from './lib/utils/hooks/useTelegramLogin/useTelegramLogin.js';
|
|
181
181
|
export { useDeleteUserAccount } from './lib/utils/hooks/useDeleteUserAccount/useDeleteUserAccount.js';
|
|
182
182
|
export { useBusinessAccounts } from './lib/utils/hooks/useBusinessAccounts/useBusinessAccounts.js';
|
|
183
|
+
export { usePolicies } from './lib/utils/hooks/usePolicies/usePolicies.js';
|
|
183
184
|
export { useExchangeAccounts } from './lib/utils/hooks/useExchangeAccounts/useExchangeAccounts.js';
|
|
184
185
|
export { usePayWithDynamic } from './lib/utils/hooks/usePayWithDynamic/usePayWithDynamic.js';
|
|
185
186
|
export { useGetPasskeys } from './lib/utils/hooks/useGetPasskeys/useGetPasskeys.js';
|
|
@@ -76,6 +76,7 @@ export { useAggregateWalletEvents } from './useAggregateWalletEvents';
|
|
|
76
76
|
export { useDeleteUserAccount } from './useDeleteUserAccount';
|
|
77
77
|
export { useDynamicWaas } from './useDynamicWaas';
|
|
78
78
|
export { useBusinessAccounts } from './useBusinessAccounts';
|
|
79
|
+
export { usePolicies } from './usePolicies';
|
|
79
80
|
export { useSyncDynamicWaas } from './useSyncDynamicWaas';
|
|
80
81
|
export { useExchangeAccounts } from './useExchangeAccounts';
|
|
81
82
|
export { useConnectExchangeForFunding } from './useConnectExchangeForFunding';
|
|
@@ -435,13 +435,14 @@ const useDynamicWaas = () => {
|
|
|
435
435
|
automaticEmbeddedWalletCreationForExternalEnabled,
|
|
436
436
|
enabledChainNames,
|
|
437
437
|
]);
|
|
438
|
-
const importPrivateKey = (_g) => _tslib.__awaiter(void 0, [_g], void 0, function* ({ chainName, privateKey, addressType, legacyWalletId, password, }) {
|
|
438
|
+
const importPrivateKey = (_g) => _tslib.__awaiter(void 0, [_g], void 0, function* ({ chainName, privateKey, addressType, legacyWalletId, password, isRawScalarImport, }) {
|
|
439
439
|
const walletConnector = getWaasWalletConnector(chainName);
|
|
440
440
|
if (!walletConnector)
|
|
441
441
|
return;
|
|
442
442
|
yield walletConnector.importPrivateKey({
|
|
443
443
|
addressType,
|
|
444
444
|
chainName,
|
|
445
|
+
isRawScalarImport,
|
|
445
446
|
legacyWalletId,
|
|
446
447
|
password,
|
|
447
448
|
privateKey,
|
|
@@ -44,12 +44,14 @@ export declare const useDynamicWaas: () => {
|
|
|
44
44
|
getWaasWalletConnector: (chainName: string) => IDynamicWaasConnector | undefined;
|
|
45
45
|
getWaasWallets: () => import("@dynamic-labs/wallet-connector-core").Wallet<import("@dynamic-labs/wallet-connector-core").WalletConnectorCore.WalletConnector>[];
|
|
46
46
|
getWaasWalletsByCredentials: () => import("@dynamic-labs/sdk-api-core").JwtVerifiedCredential[];
|
|
47
|
-
importPrivateKey: ({ chainName, privateKey, addressType, legacyWalletId, password, }: {
|
|
47
|
+
importPrivateKey: ({ chainName, privateKey, addressType, legacyWalletId, password, isRawScalarImport, }: {
|
|
48
48
|
chainName: ChainEnum;
|
|
49
49
|
privateKey: string;
|
|
50
50
|
addressType?: string;
|
|
51
51
|
legacyWalletId?: string;
|
|
52
52
|
password?: string;
|
|
53
|
+
/** ed25519 chains only: `privateKey` is a raw 32-byte scalar (hex). */
|
|
54
|
+
isRawScalarImport?: boolean;
|
|
53
55
|
}) => Promise<void>;
|
|
54
56
|
initializeWaas: ({ forceClientRebuild, }?: {
|
|
55
57
|
forceClientRebuild?: boolean;
|
|
@@ -431,13 +431,14 @@ const useDynamicWaas = () => {
|
|
|
431
431
|
automaticEmbeddedWalletCreationForExternalEnabled,
|
|
432
432
|
enabledChainNames,
|
|
433
433
|
]);
|
|
434
|
-
const importPrivateKey = (_g) => __awaiter(void 0, [_g], void 0, function* ({ chainName, privateKey, addressType, legacyWalletId, password, }) {
|
|
434
|
+
const importPrivateKey = (_g) => __awaiter(void 0, [_g], void 0, function* ({ chainName, privateKey, addressType, legacyWalletId, password, isRawScalarImport, }) {
|
|
435
435
|
const walletConnector = getWaasWalletConnector(chainName);
|
|
436
436
|
if (!walletConnector)
|
|
437
437
|
return;
|
|
438
438
|
yield walletConnector.importPrivateKey({
|
|
439
439
|
addressType,
|
|
440
440
|
chainName,
|
|
441
|
+
isRawScalarImport,
|
|
441
442
|
legacyWalletId,
|
|
442
443
|
password,
|
|
443
444
|
privateKey,
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './usePolicies';
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
5
|
+
|
|
6
|
+
var _tslib = require('../../../../../_virtual/_tslib.cjs');
|
|
7
|
+
var React = require('react');
|
|
8
|
+
var client$1 = require('@dynamic-labs-sdk/client');
|
|
9
|
+
var waas = require('@dynamic-labs-sdk/client/waas');
|
|
10
|
+
var client = require('../../../client/client.cjs');
|
|
11
|
+
|
|
12
|
+
const usePolicies = () => {
|
|
13
|
+
const dynamicClient = client.useDynamicClient();
|
|
14
|
+
const getWalletAccount = React.useCallback((walletId) => {
|
|
15
|
+
const walletAccount = client$1.getWalletAccounts(dynamicClient).find((account) => account.verifiedCredentialId === walletId || account.id === walletId);
|
|
16
|
+
if (!walletAccount) {
|
|
17
|
+
throw new Error(`Wallet account with id ${walletId} not found`);
|
|
18
|
+
}
|
|
19
|
+
if (walletAccount.verifiedCredentialId === null) {
|
|
20
|
+
throw new Error(`Wallet account with id ${walletId} is not verified`);
|
|
21
|
+
}
|
|
22
|
+
return walletAccount;
|
|
23
|
+
}, [dynamicClient]);
|
|
24
|
+
const createPolicy = React.useCallback((input) => waas.createPolicy(input, dynamicClient), [dynamicClient]);
|
|
25
|
+
const getPolicy = React.useCallback((input) => waas.getPolicy(input, dynamicClient), [dynamicClient]);
|
|
26
|
+
const removePolicyRules = React.useCallback((input) => waas.removePolicyRules(input, dynamicClient), [dynamicClient]);
|
|
27
|
+
const getWalletPolicyLayer = React.useCallback((_a) => _tslib.__awaiter(void 0, [_a], void 0, function* ({ walletId }) {
|
|
28
|
+
return waas.getWalletPolicyLayer({ walletAccount: getWalletAccount(walletId) }, dynamicClient);
|
|
29
|
+
}), [dynamicClient, getWalletAccount]);
|
|
30
|
+
const getSignerPolicyLayer = React.useCallback((_b) => _tslib.__awaiter(void 0, [_b], void 0, function* ({ shareSetId, walletId }) {
|
|
31
|
+
return waas.getSignerPolicyLayer({ shareSetId, walletAccount: getWalletAccount(walletId) }, dynamicClient);
|
|
32
|
+
}), [dynamicClient, getWalletAccount]);
|
|
33
|
+
const getAccountPolicyLayer = React.useCallback((input) => waas.getAccountPolicyLayer(input, dynamicClient), [dynamicClient]);
|
|
34
|
+
const upsertWalletPolicyRule = React.useCallback((_c) => _tslib.__awaiter(void 0, [_c], void 0, function* ({ rule, walletId }) {
|
|
35
|
+
return waas.upsertWalletPolicyRule({ rule, walletAccount: getWalletAccount(walletId) }, dynamicClient);
|
|
36
|
+
}), [dynamicClient, getWalletAccount]);
|
|
37
|
+
const upsertSignerPolicyRule = React.useCallback((_d) => _tslib.__awaiter(void 0, [_d], void 0, function* ({ rule, shareSetId, walletId }) {
|
|
38
|
+
return waas.upsertSignerPolicyRule({ rule, shareSetId, walletAccount: getWalletAccount(walletId) }, dynamicClient);
|
|
39
|
+
}), [dynamicClient, getWalletAccount]);
|
|
40
|
+
const upsertAccountPolicyRule = React.useCallback((input) => waas.upsertAccountPolicyRule(input, dynamicClient), [dynamicClient]);
|
|
41
|
+
const removeWalletPolicyRule = React.useCallback((_e) => _tslib.__awaiter(void 0, [_e], void 0, function* ({ ruleId, walletId }) {
|
|
42
|
+
return waas.removeWalletPolicyRule({ ruleId, walletAccount: getWalletAccount(walletId) }, dynamicClient);
|
|
43
|
+
}), [dynamicClient, getWalletAccount]);
|
|
44
|
+
const removeSignerPolicyRule = React.useCallback((_f) => _tslib.__awaiter(void 0, [_f], void 0, function* ({ ruleId, shareSetId, walletId }) {
|
|
45
|
+
return waas.removeSignerPolicyRule({ ruleId, shareSetId, walletAccount: getWalletAccount(walletId) }, dynamicClient);
|
|
46
|
+
}), [dynamicClient, getWalletAccount]);
|
|
47
|
+
const removeAccountPolicyRule = React.useCallback((input) => waas.removeAccountPolicyRule(input, dynamicClient), [dynamicClient]);
|
|
48
|
+
return {
|
|
49
|
+
createPolicy,
|
|
50
|
+
getAccountPolicyLayer,
|
|
51
|
+
getPolicy,
|
|
52
|
+
getSignerPolicyLayer,
|
|
53
|
+
getWalletPolicyLayer,
|
|
54
|
+
removeAccountPolicyRule,
|
|
55
|
+
removePolicyRules,
|
|
56
|
+
removeSignerPolicyRule,
|
|
57
|
+
removeWalletPolicyRule,
|
|
58
|
+
upsertAccountPolicyRule,
|
|
59
|
+
upsertSignerPolicyRule,
|
|
60
|
+
upsertWalletPolicyRule,
|
|
61
|
+
};
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
exports.usePolicies = usePolicies;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { createPolicy as createPolicyFromSDK, getAccountPolicyLayer as getAccountPolicyLayerFromSDK, getPolicy as getPolicyFromSDK, getSignerPolicyLayer as getSignerPolicyLayerFromSDK, getWalletPolicyLayer as getWalletPolicyLayerFromSDK, removeAccountPolicyRule as removeAccountPolicyRuleFromSDK, removePolicyRules as removePolicyRulesFromSDK, removeSignerPolicyRule as removeSignerPolicyRuleFromSDK, removeWalletPolicyRule as removeWalletPolicyRuleFromSDK, upsertAccountPolicyRule as upsertAccountPolicyRuleFromSDK, upsertSignerPolicyRule as upsertSignerPolicyRuleFromSDK, upsertWalletPolicyRule as upsertWalletPolicyRuleFromSDK } from '@dynamic-labs-sdk/client/waas';
|
|
2
|
+
type WithWalletId<T> = Omit<T, 'walletAccount'> & {
|
|
3
|
+
walletId: string;
|
|
4
|
+
};
|
|
5
|
+
export type CreatePolicyInput = Parameters<typeof createPolicyFromSDK>[0];
|
|
6
|
+
export type GetPolicyInput = Parameters<typeof getPolicyFromSDK>[0];
|
|
7
|
+
export type RemovePolicyRulesInput = Parameters<typeof removePolicyRulesFromSDK>[0];
|
|
8
|
+
export type GetWalletPolicyLayerInput = WithWalletId<Parameters<typeof getWalletPolicyLayerFromSDK>[0]>;
|
|
9
|
+
export type GetSignerPolicyLayerInput = WithWalletId<Parameters<typeof getSignerPolicyLayerFromSDK>[0]>;
|
|
10
|
+
export type GetAccountPolicyLayerInput = Parameters<typeof getAccountPolicyLayerFromSDK>[0];
|
|
11
|
+
export type UpsertWalletPolicyRuleInput = WithWalletId<Parameters<typeof upsertWalletPolicyRuleFromSDK>[0]>;
|
|
12
|
+
export type UpsertSignerPolicyRuleInput = WithWalletId<Parameters<typeof upsertSignerPolicyRuleFromSDK>[0]>;
|
|
13
|
+
export type UpsertAccountPolicyRuleInput = Parameters<typeof upsertAccountPolicyRuleFromSDK>[0];
|
|
14
|
+
export type RemoveWalletPolicyRuleInput = WithWalletId<Parameters<typeof removeWalletPolicyRuleFromSDK>[0]>;
|
|
15
|
+
export type RemoveSignerPolicyRuleInput = WithWalletId<Parameters<typeof removeSignerPolicyRuleFromSDK>[0]>;
|
|
16
|
+
export type RemoveAccountPolicyRuleInput = Parameters<typeof removeAccountPolicyRuleFromSDK>[0];
|
|
17
|
+
export declare const usePolicies: () => {
|
|
18
|
+
createPolicy: (input: CreatePolicyInput) => Promise<import("@dynamic-labs-sdk/client/waas").WaasPolicyLayerResponse>;
|
|
19
|
+
getAccountPolicyLayer: (input: GetAccountPolicyLayerInput) => Promise<import("@dynamic-labs-sdk/client/waas").WaasPolicyLayerResponse>;
|
|
20
|
+
getPolicy: (input: GetPolicyInput) => Promise<{
|
|
21
|
+
layerId: string;
|
|
22
|
+
rules: import("@dynamic-labs-sdk/client/waas").PolicyRules;
|
|
23
|
+
unmapped: import("@dynamic-labs-sdk/client/waas").WaasPolicyRule[];
|
|
24
|
+
updatedAt: Date;
|
|
25
|
+
}>;
|
|
26
|
+
getSignerPolicyLayer: ({ shareSetId, walletId }: GetSignerPolicyLayerInput) => Promise<import("@dynamic-labs-sdk/client/waas").WaasPolicyLayerResponse>;
|
|
27
|
+
getWalletPolicyLayer: ({ walletId }: GetWalletPolicyLayerInput) => Promise<import("@dynamic-labs-sdk/client/waas").WaasPolicyLayerResponse>;
|
|
28
|
+
removeAccountPolicyRule: (input: RemoveAccountPolicyRuleInput) => Promise<import("@dynamic-labs-sdk/client/waas").WaasPolicyLayerResponse>;
|
|
29
|
+
removePolicyRules: (input: RemovePolicyRulesInput) => Promise<import("@dynamic-labs-sdk/client/waas").WaasPolicyLayerResponse>;
|
|
30
|
+
removeSignerPolicyRule: ({ ruleId, shareSetId, walletId }: RemoveSignerPolicyRuleInput) => Promise<import("@dynamic-labs-sdk/client/waas").WaasPolicyLayerResponse>;
|
|
31
|
+
removeWalletPolicyRule: ({ ruleId, walletId }: RemoveWalletPolicyRuleInput) => Promise<import("@dynamic-labs-sdk/client/waas").WaasPolicyLayerResponse>;
|
|
32
|
+
upsertAccountPolicyRule: (input: UpsertAccountPolicyRuleInput) => Promise<import("@dynamic-labs-sdk/client/waas").WaasPolicyLayerResponse>;
|
|
33
|
+
upsertSignerPolicyRule: ({ rule, shareSetId, walletId }: UpsertSignerPolicyRuleInput) => Promise<import("@dynamic-labs-sdk/client/waas").WaasPolicyLayerResponse>;
|
|
34
|
+
upsertWalletPolicyRule: ({ rule, walletId }: UpsertWalletPolicyRuleInput) => Promise<import("@dynamic-labs-sdk/client/waas").WaasPolicyLayerResponse>;
|
|
35
|
+
};
|
|
36
|
+
export {};
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
import { __awaiter } from '../../../../../_virtual/_tslib.js';
|
|
3
|
+
import { useCallback } from 'react';
|
|
4
|
+
import { getWalletAccounts } from '@dynamic-labs-sdk/client';
|
|
5
|
+
import { createPolicy, getPolicy, removePolicyRules, getAccountPolicyLayer, upsertAccountPolicyRule, removeAccountPolicyRule, getWalletPolicyLayer, getSignerPolicyLayer, upsertWalletPolicyRule, upsertSignerPolicyRule, removeWalletPolicyRule, removeSignerPolicyRule } from '@dynamic-labs-sdk/client/waas';
|
|
6
|
+
import { useDynamicClient } from '../../../client/client.js';
|
|
7
|
+
|
|
8
|
+
const usePolicies = () => {
|
|
9
|
+
const dynamicClient = useDynamicClient();
|
|
10
|
+
const getWalletAccount = useCallback((walletId) => {
|
|
11
|
+
const walletAccount = getWalletAccounts(dynamicClient).find((account) => account.verifiedCredentialId === walletId || account.id === walletId);
|
|
12
|
+
if (!walletAccount) {
|
|
13
|
+
throw new Error(`Wallet account with id ${walletId} not found`);
|
|
14
|
+
}
|
|
15
|
+
if (walletAccount.verifiedCredentialId === null) {
|
|
16
|
+
throw new Error(`Wallet account with id ${walletId} is not verified`);
|
|
17
|
+
}
|
|
18
|
+
return walletAccount;
|
|
19
|
+
}, [dynamicClient]);
|
|
20
|
+
const createPolicy$1 = useCallback((input) => createPolicy(input, dynamicClient), [dynamicClient]);
|
|
21
|
+
const getPolicy$1 = useCallback((input) => getPolicy(input, dynamicClient), [dynamicClient]);
|
|
22
|
+
const removePolicyRules$1 = useCallback((input) => removePolicyRules(input, dynamicClient), [dynamicClient]);
|
|
23
|
+
const getWalletPolicyLayer$1 = useCallback((_a) => __awaiter(void 0, [_a], void 0, function* ({ walletId }) {
|
|
24
|
+
return getWalletPolicyLayer({ walletAccount: getWalletAccount(walletId) }, dynamicClient);
|
|
25
|
+
}), [dynamicClient, getWalletAccount]);
|
|
26
|
+
const getSignerPolicyLayer$1 = useCallback((_b) => __awaiter(void 0, [_b], void 0, function* ({ shareSetId, walletId }) {
|
|
27
|
+
return getSignerPolicyLayer({ shareSetId, walletAccount: getWalletAccount(walletId) }, dynamicClient);
|
|
28
|
+
}), [dynamicClient, getWalletAccount]);
|
|
29
|
+
const getAccountPolicyLayer$1 = useCallback((input) => getAccountPolicyLayer(input, dynamicClient), [dynamicClient]);
|
|
30
|
+
const upsertWalletPolicyRule$1 = useCallback((_c) => __awaiter(void 0, [_c], void 0, function* ({ rule, walletId }) {
|
|
31
|
+
return upsertWalletPolicyRule({ rule, walletAccount: getWalletAccount(walletId) }, dynamicClient);
|
|
32
|
+
}), [dynamicClient, getWalletAccount]);
|
|
33
|
+
const upsertSignerPolicyRule$1 = useCallback((_d) => __awaiter(void 0, [_d], void 0, function* ({ rule, shareSetId, walletId }) {
|
|
34
|
+
return upsertSignerPolicyRule({ rule, shareSetId, walletAccount: getWalletAccount(walletId) }, dynamicClient);
|
|
35
|
+
}), [dynamicClient, getWalletAccount]);
|
|
36
|
+
const upsertAccountPolicyRule$1 = useCallback((input) => upsertAccountPolicyRule(input, dynamicClient), [dynamicClient]);
|
|
37
|
+
const removeWalletPolicyRule$1 = useCallback((_e) => __awaiter(void 0, [_e], void 0, function* ({ ruleId, walletId }) {
|
|
38
|
+
return removeWalletPolicyRule({ ruleId, walletAccount: getWalletAccount(walletId) }, dynamicClient);
|
|
39
|
+
}), [dynamicClient, getWalletAccount]);
|
|
40
|
+
const removeSignerPolicyRule$1 = useCallback((_f) => __awaiter(void 0, [_f], void 0, function* ({ ruleId, shareSetId, walletId }) {
|
|
41
|
+
return removeSignerPolicyRule({ ruleId, shareSetId, walletAccount: getWalletAccount(walletId) }, dynamicClient);
|
|
42
|
+
}), [dynamicClient, getWalletAccount]);
|
|
43
|
+
const removeAccountPolicyRule$1 = useCallback((input) => removeAccountPolicyRule(input, dynamicClient), [dynamicClient]);
|
|
44
|
+
return {
|
|
45
|
+
createPolicy: createPolicy$1,
|
|
46
|
+
getAccountPolicyLayer: getAccountPolicyLayer$1,
|
|
47
|
+
getPolicy: getPolicy$1,
|
|
48
|
+
getSignerPolicyLayer: getSignerPolicyLayer$1,
|
|
49
|
+
getWalletPolicyLayer: getWalletPolicyLayer$1,
|
|
50
|
+
removeAccountPolicyRule: removeAccountPolicyRule$1,
|
|
51
|
+
removePolicyRules: removePolicyRules$1,
|
|
52
|
+
removeSignerPolicyRule: removeSignerPolicyRule$1,
|
|
53
|
+
removeWalletPolicyRule: removeWalletPolicyRule$1,
|
|
54
|
+
upsertAccountPolicyRule: upsertAccountPolicyRule$1,
|
|
55
|
+
upsertSignerPolicyRule: upsertSignerPolicyRule$1,
|
|
56
|
+
upsertWalletPolicyRule: upsertWalletPolicyRule$1,
|
|
57
|
+
};
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
export { usePolicies };
|