@rhinestone/sdk 1.4.2 → 2.0.0-beta.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.
Files changed (202) hide show
  1. package/README.md +89 -1
  2. package/dist/src/accounts/error.d.ts +1 -1
  3. package/dist/src/accounts/error.js +1 -19
  4. package/dist/src/accounts/index.d.ts +5 -5
  5. package/dist/src/accounts/index.js +121 -157
  6. package/dist/src/accounts/json-rpc/index.d.ts +1 -1
  7. package/dist/src/accounts/json-rpc/index.js +8 -10
  8. package/dist/src/accounts/json-rpc/providers.d.ts +1 -1
  9. package/dist/src/accounts/json-rpc/providers.js +4 -7
  10. package/dist/src/accounts/kernel.d.ts +3 -3
  11. package/dist/src/accounts/kernel.js +66 -75
  12. package/dist/src/accounts/nexus.d.ts +3 -3
  13. package/dist/src/accounts/nexus.js +62 -73
  14. package/dist/src/accounts/passport.d.ts +3 -3
  15. package/dist/src/accounts/passport.js +9 -13
  16. package/dist/src/accounts/safe.d.ts +3 -3
  17. package/dist/src/accounts/safe.js +54 -63
  18. package/dist/src/accounts/signing/common.d.ts +10 -4
  19. package/dist/src/accounts/signing/common.d.ts.map +1 -1
  20. package/dist/src/accounts/signing/common.js +30 -36
  21. package/dist/src/accounts/signing/message.d.ts +2 -2
  22. package/dist/src/accounts/signing/message.js +10 -12
  23. package/dist/src/accounts/signing/passkeys.js +11 -17
  24. package/dist/src/accounts/signing/typedData.d.ts +1 -1
  25. package/dist/src/accounts/signing/typedData.js +6 -8
  26. package/dist/src/accounts/startale.d.ts +3 -3
  27. package/dist/src/accounts/startale.js +37 -47
  28. package/dist/src/accounts/utils.d.ts +2 -2
  29. package/dist/src/accounts/utils.js +22 -28
  30. package/dist/src/accounts/walletClient.js +4 -8
  31. package/dist/src/actions/compact.d.ts +1 -1
  32. package/dist/src/actions/compact.js +22 -35
  33. package/dist/src/actions/deployment.d.ts +1 -1
  34. package/dist/src/actions/deployment.js +11 -13
  35. package/dist/src/actions/ecdsa.d.ts +1 -1
  36. package/dist/src/actions/ecdsa.js +14 -20
  37. package/dist/src/actions/index.d.ts +2 -2
  38. package/dist/src/actions/index.js +6 -10
  39. package/dist/src/actions/mfa.d.ts +1 -1
  40. package/dist/src/actions/mfa.js +18 -24
  41. package/dist/src/actions/passkeys.d.ts +2 -2
  42. package/dist/src/actions/passkeys.js +14 -20
  43. package/dist/src/actions/recovery.d.ts +1 -1
  44. package/dist/src/actions/recovery.js +25 -29
  45. package/dist/src/actions/smart-sessions.d.ts +1 -1
  46. package/dist/src/actions/smart-sessions.js +8 -12
  47. package/dist/src/auth/provider.d.ts +7 -0
  48. package/dist/src/auth/provider.d.ts.map +1 -0
  49. package/dist/src/auth/provider.js +38 -0
  50. package/dist/src/errors/index.d.ts +3 -3
  51. package/dist/src/errors/index.js +10 -54
  52. package/dist/src/execution/compact.d.ts +3 -3
  53. package/dist/src/execution/compact.js +10 -18
  54. package/dist/src/execution/error.js +1 -11
  55. package/dist/src/execution/index.d.ts +9 -8
  56. package/dist/src/execution/index.d.ts.map +1 -1
  57. package/dist/src/execution/index.js +54 -67
  58. package/dist/src/execution/permit2.d.ts +5 -5
  59. package/dist/src/execution/permit2.js +8 -13
  60. package/dist/src/execution/singleChainOps.d.ts +2 -2
  61. package/dist/src/execution/singleChainOps.js +1 -3
  62. package/dist/src/execution/types.d.ts +1 -1
  63. package/dist/src/execution/types.js +1 -2
  64. package/dist/src/execution/utils.d.ts +10 -6
  65. package/dist/src/execution/utils.d.ts.map +1 -1
  66. package/dist/src/execution/utils.js +159 -162
  67. package/dist/src/index.d.ts +10 -10
  68. package/dist/src/index.d.ts.map +1 -1
  69. package/dist/src/index.js +57 -67
  70. package/dist/src/jwt-server/digest.d.ts +11 -0
  71. package/dist/src/jwt-server/digest.d.ts.map +1 -0
  72. package/dist/src/jwt-server/digest.js +19 -0
  73. package/dist/src/jwt-server/express.d.ts +16 -0
  74. package/dist/src/jwt-server/express.d.ts.map +1 -0
  75. package/dist/src/jwt-server/express.js +23 -0
  76. package/dist/src/jwt-server/handlers.d.ts +10 -0
  77. package/dist/src/jwt-server/handlers.d.ts.map +1 -0
  78. package/dist/src/jwt-server/handlers.js +37 -0
  79. package/dist/src/jwt-server/index.d.ts +8 -0
  80. package/dist/src/jwt-server/index.d.ts.map +1 -0
  81. package/dist/src/jwt-server/index.js +7 -0
  82. package/dist/src/jwt-server/jcs.d.ts +12 -0
  83. package/dist/src/jwt-server/jcs.d.ts.map +1 -0
  84. package/dist/src/jwt-server/jcs.js +57 -0
  85. package/dist/src/jwt-server/signer.d.ts +18 -0
  86. package/dist/src/jwt-server/signer.d.ts.map +1 -0
  87. package/dist/src/jwt-server/signer.js +68 -0
  88. package/dist/src/jwt-server/sponsorship.d.ts +19 -0
  89. package/dist/src/jwt-server/sponsorship.d.ts.map +1 -0
  90. package/dist/src/jwt-server/sponsorship.js +51 -0
  91. package/dist/src/jwt-server/web.d.ts +4 -0
  92. package/dist/src/jwt-server/web.d.ts.map +1 -0
  93. package/dist/src/jwt-server/web.js +23 -0
  94. package/dist/src/modules/abi/smart-session-emissary.js +1 -3
  95. package/dist/src/modules/abi/smart-sessions.js +1 -4
  96. package/dist/src/modules/chain-abstraction.js +1 -5
  97. package/dist/src/modules/common.d.ts +1 -1
  98. package/dist/src/modules/common.js +1 -13
  99. package/dist/src/modules/index.d.ts +5 -5
  100. package/dist/src/modules/index.js +35 -50
  101. package/dist/src/modules/legacy.d.ts +2 -2
  102. package/dist/src/modules/legacy.js +11 -14
  103. package/dist/src/modules/read.d.ts +1 -1
  104. package/dist/src/modules/read.js +11 -15
  105. package/dist/src/modules/validators/core.d.ts +2 -2
  106. package/dist/src/modules/validators/core.js +26 -44
  107. package/dist/src/modules/validators/index.d.ts +2 -2
  108. package/dist/src/modules/validators/index.js +3 -19
  109. package/dist/src/modules/validators/policies/claim/permit2.d.ts +1 -1
  110. package/dist/src/modules/validators/policies/claim/permit2.js +39 -44
  111. package/dist/src/modules/validators/policies/claim/types.js +11 -14
  112. package/dist/src/modules/validators/smart-sessions.d.ts +4 -4
  113. package/dist/src/modules/validators/smart-sessions.d.ts.map +1 -1
  114. package/dist/src/modules/validators/smart-sessions.js +77 -97
  115. package/dist/src/orchestrator/client.d.ts +10 -5
  116. package/dist/src/orchestrator/client.d.ts.map +1 -1
  117. package/dist/src/orchestrator/client.js +73 -66
  118. package/dist/src/orchestrator/consts.d.ts +1 -1
  119. package/dist/src/orchestrator/consts.d.ts.map +1 -1
  120. package/dist/src/orchestrator/consts.js +2 -8
  121. package/dist/src/orchestrator/error.js +1 -33
  122. package/dist/src/orchestrator/index.d.ts +8 -7
  123. package/dist/src/orchestrator/index.d.ts.map +1 -1
  124. package/dist/src/orchestrator/index.js +8 -57
  125. package/dist/src/orchestrator/registry.d.ts +2 -2
  126. package/dist/src/orchestrator/registry.js +19 -33
  127. package/dist/src/orchestrator/types.d.ts +5 -1
  128. package/dist/src/orchestrator/types.d.ts.map +1 -1
  129. package/dist/src/orchestrator/types.js +1 -17
  130. package/dist/src/orchestrator/utils.js +1 -3
  131. package/dist/src/types.d.ts +29 -5
  132. package/dist/src/types.d.ts.map +1 -1
  133. package/dist/src/types.js +1 -2
  134. package/dist/src/utils/index.d.ts +2 -2
  135. package/dist/src/utils/index.js +9 -15
  136. package/package.json +29 -98
  137. package/dist/src/accounts/index.test.d.ts +0 -2
  138. package/dist/src/accounts/index.test.d.ts.map +0 -1
  139. package/dist/src/accounts/index.test.js +0 -33
  140. package/dist/src/accounts/json-rpc/index.test.d.ts +0 -2
  141. package/dist/src/accounts/json-rpc/index.test.d.ts.map +0 -1
  142. package/dist/src/accounts/json-rpc/index.test.js +0 -35
  143. package/dist/src/accounts/json-rpc/providers.test.d.ts +0 -2
  144. package/dist/src/accounts/json-rpc/providers.test.d.ts.map +0 -1
  145. package/dist/src/accounts/json-rpc/providers.test.js +0 -43
  146. package/dist/src/accounts/kernel.test.d.ts +0 -2
  147. package/dist/src/accounts/kernel.test.d.ts.map +0 -1
  148. package/dist/src/accounts/kernel.test.js +0 -132
  149. package/dist/src/accounts/nexus.test.d.ts +0 -2
  150. package/dist/src/accounts/nexus.test.d.ts.map +0 -1
  151. package/dist/src/accounts/nexus.test.js +0 -118
  152. package/dist/src/accounts/safe.test.d.ts +0 -2
  153. package/dist/src/accounts/safe.test.d.ts.map +0 -1
  154. package/dist/src/accounts/safe.test.js +0 -168
  155. package/dist/src/accounts/signing/passkeys.test.d.ts +0 -2
  156. package/dist/src/accounts/signing/passkeys.test.d.ts.map +0 -1
  157. package/dist/src/accounts/signing/passkeys.test.js +0 -88
  158. package/dist/src/accounts/startale.test.d.ts +0 -2
  159. package/dist/src/accounts/startale.test.d.ts.map +0 -1
  160. package/dist/src/accounts/startale.test.js +0 -189
  161. package/dist/src/accounts/utils.test.d.ts +0 -2
  162. package/dist/src/accounts/utils.test.d.ts.map +0 -1
  163. package/dist/src/accounts/utils.test.js +0 -49
  164. package/dist/src/actions/ecdsa.test.d.ts +0 -2
  165. package/dist/src/actions/ecdsa.test.d.ts.map +0 -1
  166. package/dist/src/actions/ecdsa.test.js +0 -99
  167. package/dist/src/actions/passkeys.test.d.ts +0 -2
  168. package/dist/src/actions/passkeys.test.d.ts.map +0 -1
  169. package/dist/src/actions/passkeys.test.js +0 -54
  170. package/dist/src/actions/recovery.test.d.ts +0 -2
  171. package/dist/src/actions/recovery.test.d.ts.map +0 -1
  172. package/dist/src/actions/recovery.test.js +0 -168
  173. package/dist/src/execution/signing.test.d.ts +0 -2
  174. package/dist/src/execution/signing.test.d.ts.map +0 -1
  175. package/dist/src/execution/signing.test.js +0 -465
  176. package/dist/src/execution/utils.test.d.ts +0 -2
  177. package/dist/src/execution/utils.test.d.ts.map +0 -1
  178. package/dist/src/execution/utils.test.js +0 -388
  179. package/dist/src/modules/index.test.d.ts +0 -2
  180. package/dist/src/modules/index.test.d.ts.map +0 -1
  181. package/dist/src/modules/index.test.js +0 -81
  182. package/dist/src/modules/validators/core.test.d.ts +0 -2
  183. package/dist/src/modules/validators/core.test.d.ts.map +0 -1
  184. package/dist/src/modules/validators/core.test.js +0 -101
  185. package/dist/src/modules/validators/policies/claim/permit2.test.d.ts +0 -2
  186. package/dist/src/modules/validators/policies/claim/permit2.test.d.ts.map +0 -1
  187. package/dist/src/modules/validators/policies/claim/permit2.test.js +0 -519
  188. package/dist/src/modules/validators/smart-sessions.test.d.ts +0 -2
  189. package/dist/src/modules/validators/smart-sessions.test.d.ts.map +0 -1
  190. package/dist/src/modules/validators/smart-sessions.test.js +0 -311
  191. package/dist/src/orchestrator/registry.test.d.ts +0 -2
  192. package/dist/src/orchestrator/registry.test.d.ts.map +0 -1
  193. package/dist/src/orchestrator/registry.test.js +0 -154
  194. package/dist/src/utils/index.test.d.ts +0 -2
  195. package/dist/src/utils/index.test.d.ts.map +0 -1
  196. package/dist/src/utils/index.test.js +0 -42
  197. package/dist/test/consts.d.ts +0 -10
  198. package/dist/test/consts.d.ts.map +0 -1
  199. package/dist/test/consts.js +0 -22
  200. package/dist/test/utils/utils.d.ts +0 -5
  201. package/dist/test/utils/utils.d.ts.map +0 -1
  202. package/dist/test/utils/utils.js +0 -20
@@ -1,13 +1,6 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.addOwner = addOwner;
4
- exports.removeOwner = removeOwner;
5
- exports.changeThreshold = changeThreshold;
6
- exports.disable = disable;
7
- exports.enable = enable;
8
- const viem_1 = require("viem");
9
- const accounts_1 = require("../accounts");
10
- const core_1 = require("../modules/validators/core");
1
+ import { encodeFunctionData } from 'viem';
2
+ import { getModuleInstallationCalls, getModuleUninstallationCalls, } from '../accounts/index.js';
3
+ import { getOwnableValidator, OWNABLE_VALIDATOR_ADDRESS, } from '../modules/validators/core.js';
11
4
  /**
12
5
  * Enable ECDSA authentication
13
6
  * @param owners Owners to use for authentication
@@ -15,10 +8,10 @@ const core_1 = require("../modules/validators/core");
15
8
  * @returns Calls to enable ECDSA authentication
16
9
  */
17
10
  function enable(owners, threshold = 1) {
18
- const module = (0, core_1.getOwnableValidator)(threshold, owners);
11
+ const module = getOwnableValidator(threshold, owners);
19
12
  return {
20
13
  async resolve({ config }) {
21
- return (0, accounts_1.getModuleInstallationCalls)(config, module);
14
+ return getModuleInstallationCalls(config, module);
22
15
  },
23
16
  };
24
17
  }
@@ -27,10 +20,10 @@ function enable(owners, threshold = 1) {
27
20
  * @returns Calls to disable ECDSA authentication
28
21
  */
29
22
  function disable() {
30
- const module = (0, core_1.getOwnableValidator)(1, []);
23
+ const module = getOwnableValidator(1, []);
31
24
  return {
32
25
  async resolve({ config }) {
33
- return (0, accounts_1.getModuleUninstallationCalls)(config, module);
26
+ return getModuleUninstallationCalls(config, module);
34
27
  },
35
28
  };
36
29
  }
@@ -41,9 +34,9 @@ function disable() {
41
34
  */
42
35
  function addOwner(owner) {
43
36
  return {
44
- to: core_1.OWNABLE_VALIDATOR_ADDRESS,
37
+ to: OWNABLE_VALIDATOR_ADDRESS,
45
38
  value: 0n,
46
- data: (0, viem_1.encodeFunctionData)({
39
+ data: encodeFunctionData({
47
40
  abi: [
48
41
  {
49
42
  inputs: [{ internalType: 'address', name: 'owner', type: 'address' }],
@@ -66,9 +59,9 @@ function addOwner(owner) {
66
59
  */
67
60
  function removeOwner(prevOwner, ownerToRemove) {
68
61
  return {
69
- to: core_1.OWNABLE_VALIDATOR_ADDRESS,
62
+ to: OWNABLE_VALIDATOR_ADDRESS,
70
63
  value: 0n,
71
- data: (0, viem_1.encodeFunctionData)({
64
+ data: encodeFunctionData({
72
65
  abi: [
73
66
  {
74
67
  inputs: [
@@ -93,9 +86,9 @@ function removeOwner(prevOwner, ownerToRemove) {
93
86
  */
94
87
  function changeThreshold(newThreshold) {
95
88
  return {
96
- to: core_1.OWNABLE_VALIDATOR_ADDRESS,
89
+ to: OWNABLE_VALIDATOR_ADDRESS,
97
90
  value: 0n,
98
- data: (0, viem_1.encodeFunctionData)({
91
+ data: encodeFunctionData({
99
92
  abi: [
100
93
  {
101
94
  inputs: [
@@ -112,3 +105,4 @@ function changeThreshold(newThreshold) {
112
105
  }),
113
106
  };
114
107
  }
108
+ export { addOwner, removeOwner, changeThreshold, disable, enable };
@@ -1,5 +1,5 @@
1
- import type { RhinestoneAccount } from '../index';
2
- import type { LazyCallInput, ModuleInput } from '../types';
1
+ import type { RhinestoneAccount } from '../index.js';
2
+ import type { LazyCallInput, ModuleInput } from '../types.js';
3
3
  /**
4
4
  * Install a custom module
5
5
  * @param module Module to install
@@ -1,10 +1,5 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.installModule = installModule;
4
- exports.uninstallModule = uninstallModule;
5
- exports.deploy = deploy;
6
- const accounts_1 = require("../accounts");
7
- const common_1 = require("../modules/common");
1
+ import { getModuleInstallationCalls, getModuleUninstallationCalls, } from '../accounts/index.js';
2
+ import { toModuleTypeId } from '../modules/common.js';
8
3
  /**
9
4
  * Install a custom module
10
5
  * @param module Module to install
@@ -14,7 +9,7 @@ function installModule(module) {
14
9
  const moduleData = getModule(module);
15
10
  return {
16
11
  async resolve({ config }) {
17
- return (0, accounts_1.getModuleInstallationCalls)(config, moduleData);
12
+ return getModuleInstallationCalls(config, moduleData);
18
13
  },
19
14
  };
20
15
  }
@@ -27,13 +22,13 @@ function uninstallModule(module) {
27
22
  const moduleData = getModule(module);
28
23
  return {
29
24
  async resolve({ config }) {
30
- return (0, accounts_1.getModuleUninstallationCalls)(config, moduleData);
25
+ return getModuleUninstallationCalls(config, moduleData);
31
26
  },
32
27
  };
33
28
  }
34
29
  function getModule(module) {
35
30
  return {
36
- type: (0, common_1.toModuleTypeId)(module.type),
31
+ type: toModuleTypeId(module.type),
37
32
  address: module.address,
38
33
  initData: module.initData ?? '0x',
39
34
  deInitData: module.deInitData ?? '0x',
@@ -51,3 +46,4 @@ function deploy(account) {
51
46
  },
52
47
  };
53
48
  }
49
+ export { installModule, uninstallModule, deploy };
@@ -1,5 +1,5 @@
1
1
  import { type Hex } from 'viem';
2
- import type { CalldataInput, LazyCallInput, OwnableValidatorConfig, WebauthnValidatorConfig } from '../types';
2
+ import type { CalldataInput, LazyCallInput, OwnableValidatorConfig, WebauthnValidatorConfig } from '../types.js';
3
3
  /**
4
4
  * Enable multi-factor authentication
5
5
  * @param validators List of validators to use
@@ -1,13 +1,6 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.enable = enable;
4
- exports.changeThreshold = changeThreshold;
5
- exports.disable = disable;
6
- exports.setSubValidator = setSubValidator;
7
- exports.removeSubValidator = removeSubValidator;
8
- const viem_1 = require("viem");
9
- const accounts_1 = require("../accounts");
10
- const core_1 = require("../modules/validators/core");
1
+ import { encodeFunctionData, padHex, toHex } from 'viem';
2
+ import { getModuleInstallationCalls, getModuleUninstallationCalls, } from '../accounts/index.js';
3
+ import { getMultiFactorValidator, getValidator, MULTI_FACTOR_VALIDATOR_ADDRESS, } from '../modules/validators/core.js';
11
4
  /**
12
5
  * Enable multi-factor authentication
13
6
  * @param validators List of validators to use
@@ -15,10 +8,10 @@ const core_1 = require("../modules/validators/core");
15
8
  * @returns Calls to enable multi-factor authentication
16
9
  */
17
10
  function enable(validators, threshold = 1) {
18
- const module = (0, core_1.getMultiFactorValidator)(threshold, validators);
11
+ const module = getMultiFactorValidator(threshold, validators);
19
12
  return {
20
13
  async resolve({ config }) {
21
- return (0, accounts_1.getModuleInstallationCalls)(config, module);
14
+ return getModuleInstallationCalls(config, module);
22
15
  },
23
16
  };
24
17
  }
@@ -29,9 +22,9 @@ function enable(validators, threshold = 1) {
29
22
  */
30
23
  function changeThreshold(newThreshold) {
31
24
  return {
32
- to: core_1.MULTI_FACTOR_VALIDATOR_ADDRESS,
25
+ to: MULTI_FACTOR_VALIDATOR_ADDRESS,
33
26
  value: 0n,
34
- data: (0, viem_1.encodeFunctionData)({
27
+ data: encodeFunctionData({
35
28
  abi: [
36
29
  {
37
30
  inputs: [{ internalType: 'uint8', name: 'threshold', type: 'uint8' }],
@@ -52,10 +45,10 @@ function changeThreshold(newThreshold) {
52
45
  * @returns Calls to disable multi-factor authentication
53
46
  */
54
47
  function disable() {
55
- const module = (0, core_1.getMultiFactorValidator)(1, []);
48
+ const module = getMultiFactorValidator(1, []);
56
49
  return {
57
50
  async resolve({ config }) {
58
- return (0, accounts_1.getModuleUninstallationCalls)(config, module);
51
+ return getModuleUninstallationCalls(config, module);
59
52
  },
60
53
  };
61
54
  }
@@ -66,12 +59,12 @@ function disable() {
66
59
  * @returns Call to set the sub-validator
67
60
  */
68
61
  function setSubValidator(id, validator) {
69
- const validatorId = (0, viem_1.padHex)((0, viem_1.toHex)(id), { size: 12 });
70
- const validatorModule = (0, core_1.getValidator)(validator);
62
+ const validatorId = padHex(toHex(id), { size: 12 });
63
+ const validatorModule = getValidator(validator);
71
64
  return {
72
- to: core_1.MULTI_FACTOR_VALIDATOR_ADDRESS,
65
+ to: MULTI_FACTOR_VALIDATOR_ADDRESS,
73
66
  value: 0n,
74
- data: (0, viem_1.encodeFunctionData)({
67
+ data: encodeFunctionData({
75
68
  abi: [
76
69
  {
77
70
  type: 'function',
@@ -104,12 +97,12 @@ function setSubValidator(id, validator) {
104
97
  * @returns Call to remove the sub-validator
105
98
  */
106
99
  function removeSubValidator(id, validator) {
107
- const validatorId = (0, viem_1.padHex)((0, viem_1.toHex)(id), { size: 12 });
108
- const validatorModule = (0, core_1.getValidator)(validator);
100
+ const validatorId = padHex(toHex(id), { size: 12 });
101
+ const validatorModule = getValidator(validator);
109
102
  return {
110
- to: core_1.MULTI_FACTOR_VALIDATOR_ADDRESS,
103
+ to: MULTI_FACTOR_VALIDATOR_ADDRESS,
111
104
  value: 0n,
112
- data: (0, viem_1.encodeFunctionData)({
105
+ data: encodeFunctionData({
113
106
  abi: [
114
107
  {
115
108
  type: 'function',
@@ -131,3 +124,4 @@ function removeSubValidator(id, validator) {
131
124
  }),
132
125
  };
133
126
  }
127
+ export { enable, changeThreshold, disable, setSubValidator, removeSubValidator };
@@ -1,5 +1,5 @@
1
- import { type WebauthnCredential } from '../modules/validators/core';
2
- import type { CalldataInput, LazyCallInput } from '../types';
1
+ import { type WebauthnCredential } from '../modules/validators/core.js';
2
+ import type { CalldataInput, LazyCallInput } from '../types.js';
3
3
  /**
4
4
  * Enable passkeys authentication
5
5
  * @param pubKey Public key for the passkey
@@ -1,13 +1,6 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.addOwner = addOwner;
4
- exports.removeOwner = removeOwner;
5
- exports.changeThreshold = changeThreshold;
6
- exports.disable = disable;
7
- exports.enable = enable;
8
- const viem_1 = require("viem");
9
- const accounts_1 = require("../accounts");
10
- const core_1 = require("../modules/validators/core");
1
+ import { encodeFunctionData } from 'viem';
2
+ import { getModuleInstallationCalls, getModuleUninstallationCalls, } from '../accounts/index.js';
3
+ import { getWebAuthnValidator, WEBAUTHN_VALIDATOR_ADDRESS, } from '../modules/validators/core.js';
11
4
  /**
12
5
  * Enable passkeys authentication
13
6
  * @param pubKey Public key for the passkey
@@ -15,10 +8,10 @@ const core_1 = require("../modules/validators/core");
15
8
  * @returns Calls to enable passkeys authentication
16
9
  */
17
10
  function enable(credential) {
18
- const module = (0, core_1.getWebAuthnValidator)(1, [credential]);
11
+ const module = getWebAuthnValidator(1, [credential]);
19
12
  return {
20
13
  async resolve({ config }) {
21
- return (0, accounts_1.getModuleInstallationCalls)(config, module);
14
+ return getModuleInstallationCalls(config, module);
22
15
  },
23
16
  };
24
17
  }
@@ -27,7 +20,7 @@ function enable(credential) {
27
20
  * @returns Calls to disable passkeys authentication
28
21
  */
29
22
  function disable() {
30
- const module = (0, core_1.getWebAuthnValidator)(1, [
23
+ const module = getWebAuthnValidator(1, [
31
24
  {
32
25
  // Mocked values
33
26
  pubKey: '0x580a9af0569ad3905b26a703201b358aa0904236642ebe79b22a19d00d3737637d46f725a5427ae45a9569259bf67e1e16b187d7b3ad1ed70138c4f0409677d1',
@@ -36,7 +29,7 @@ function disable() {
36
29
  ]);
37
30
  return {
38
31
  async resolve({ config }) {
39
- return (0, accounts_1.getModuleUninstallationCalls)(config, module);
32
+ return getModuleUninstallationCalls(config, module);
40
33
  },
41
34
  };
42
35
  }
@@ -49,9 +42,9 @@ function disable() {
49
42
  */
50
43
  function addOwner(pubKeyX, pubKeyY, requireUserVerification) {
51
44
  return {
52
- to: core_1.WEBAUTHN_VALIDATOR_ADDRESS,
45
+ to: WEBAUTHN_VALIDATOR_ADDRESS,
53
46
  value: 0n,
54
- data: (0, viem_1.encodeFunctionData)({
47
+ data: encodeFunctionData({
55
48
  abi: [
56
49
  {
57
50
  inputs: [
@@ -81,9 +74,9 @@ function addOwner(pubKeyX, pubKeyY, requireUserVerification) {
81
74
  */
82
75
  function removeOwner(pubKeyX, pubKeyY) {
83
76
  return {
84
- to: core_1.WEBAUTHN_VALIDATOR_ADDRESS,
77
+ to: WEBAUTHN_VALIDATOR_ADDRESS,
85
78
  value: 0n,
86
- data: (0, viem_1.encodeFunctionData)({
79
+ data: encodeFunctionData({
87
80
  abi: [
88
81
  {
89
82
  inputs: [
@@ -108,9 +101,9 @@ function removeOwner(pubKeyX, pubKeyY) {
108
101
  */
109
102
  function changeThreshold(newThreshold) {
110
103
  return {
111
- to: core_1.WEBAUTHN_VALIDATOR_ADDRESS,
104
+ to: WEBAUTHN_VALIDATOR_ADDRESS,
112
105
  value: 0n,
113
- data: (0, viem_1.encodeFunctionData)({
106
+ data: encodeFunctionData({
114
107
  abi: [
115
108
  {
116
109
  inputs: [
@@ -127,3 +120,4 @@ function changeThreshold(newThreshold) {
127
120
  }),
128
121
  };
129
122
  }
123
+ export { addOwner, removeOwner, changeThreshold, disable, enable };
@@ -1,5 +1,5 @@
1
1
  import { type Account, type Address, type Chain } from 'viem';
2
- import type { CalldataInput, LazyCallInput, OwnableValidatorConfig, RhinestoneConfig, WebauthnValidatorConfig } from '../types';
2
+ import type { CalldataInput, LazyCallInput, OwnableValidatorConfig, RhinestoneConfig, WebauthnValidatorConfig } from '../types.js';
3
3
  /**
4
4
  * Set up social recovery
5
5
  * @param guardians Guardians to use for recovery
@@ -1,15 +1,10 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.enable = enable;
4
- exports.recoverEcdsaOwnership = recoverEcdsaOwnership;
5
- exports.recoverPasskeyOwnership = recoverPasskeyOwnership;
6
- const viem_1 = require("viem");
7
- const accounts_1 = require("../accounts");
8
- const json_rpc_1 = require("../accounts/json-rpc");
9
- const utils_1 = require("../execution/utils");
10
- const core_1 = require("../modules/validators/core");
11
- const ecdsa_1 = require("./ecdsa");
12
- const passkeys_1 = require("./passkeys");
1
+ import { createPublicClient, } from 'viem';
2
+ import { getModuleInstallationCalls } from '../accounts/index.js';
3
+ import { createTransport } from '../accounts/json-rpc/index.js';
4
+ import { resolveCallInputs } from '../execution/utils.js';
5
+ import { getSocialRecoveryValidator, OWNABLE_VALIDATOR_ADDRESS, WEBAUTHN_VALIDATOR_ADDRESS, } from '../modules/validators/core.js';
6
+ import { addOwner, changeThreshold, removeOwner } from './ecdsa.js';
7
+ import { addOwner as addPasskeyOwner, changeThreshold as changePasskeyThreshold, removeOwner as removePasskeyOwner, } from './passkeys.js';
13
8
  /**
14
9
  * Set up social recovery
15
10
  * @param guardians Guardians to use for recovery
@@ -17,10 +12,10 @@ const passkeys_1 = require("./passkeys");
17
12
  * @returns Calls to set up social recovery
18
13
  */
19
14
  function enable(guardians, threshold = 1) {
20
- const module = (0, core_1.getSocialRecoveryValidator)(guardians, threshold);
15
+ const module = getSocialRecoveryValidator(guardians, threshold);
21
16
  return {
22
17
  async resolve({ config }) {
23
- return (0, accounts_1.getModuleInstallationCalls)(config, module);
18
+ return getModuleInstallationCalls(config, module);
24
19
  },
25
20
  };
26
21
  }
@@ -33,15 +28,15 @@ function enable(guardians, threshold = 1) {
33
28
  * @returns Calls to recover ownership
34
29
  */
35
30
  async function recoverEcdsaOwnership(address, newOwners, chain, config) {
36
- const publicClient = (0, viem_1.createPublicClient)({
31
+ const publicClient = createPublicClient({
37
32
  chain,
38
- transport: (0, json_rpc_1.createTransport)(chain, config.provider),
33
+ transport: createTransport(chain, config.provider),
39
34
  });
40
35
  // Read the existing config
41
36
  const results = await publicClient.multicall({
42
37
  contracts: [
43
38
  {
44
- address: core_1.OWNABLE_VALIDATOR_ADDRESS,
39
+ address: OWNABLE_VALIDATOR_ADDRESS,
45
40
  abi: [
46
41
  {
47
42
  inputs: [
@@ -63,7 +58,7 @@ async function recoverEcdsaOwnership(address, newOwners, chain, config) {
63
58
  args: [address],
64
59
  },
65
60
  {
66
- address: core_1.OWNABLE_VALIDATOR_ADDRESS,
61
+ address: OWNABLE_VALIDATOR_ADDRESS,
67
62
  abi: [
68
63
  {
69
64
  inputs: [
@@ -96,7 +91,7 @@ async function recoverEcdsaOwnership(address, newOwners, chain, config) {
96
91
  const newThreshold = newOwners.threshold ?? 1;
97
92
  // Check if threshold needs to be updated
98
93
  if (Number(existingThreshold) !== newThreshold) {
99
- callInputs.push((0, ecdsa_1.changeThreshold)(newThreshold));
94
+ callInputs.push(changeThreshold(newThreshold));
100
95
  }
101
96
  const ownersToAdd = newOwnerAddresses.filter((owner) => !normalizedExistingOwners.includes(owner));
102
97
  const ownersToRemove = normalizedExistingOwners.filter((owner) => !newOwnerAddresses.includes(owner));
@@ -104,7 +99,7 @@ async function recoverEcdsaOwnership(address, newOwners, chain, config) {
104
99
  // Note: new owners are added to the START of the linked list
105
100
  let currentOwners = [...normalizedExistingOwners];
106
101
  for (const owner of ownersToAdd) {
107
- callInputs.push((0, ecdsa_1.addOwner)(owner));
102
+ callInputs.push(addOwner(owner));
108
103
  currentOwners.unshift(owner);
109
104
  }
110
105
  for (const ownerToRemove of ownersToRemove) {
@@ -117,10 +112,10 @@ async function recoverEcdsaOwnership(address, newOwners, chain, config) {
117
112
  else {
118
113
  prevOwner = currentOwners[ownerIndex - 1];
119
114
  }
120
- callInputs.push((0, ecdsa_1.removeOwner)(prevOwner, ownerToRemove));
115
+ callInputs.push(removeOwner(prevOwner, ownerToRemove));
121
116
  currentOwners = currentOwners.filter((owner) => owner !== ownerToRemove);
122
117
  }
123
- const calls = await (0, utils_1.resolveCallInputs)(callInputs, config, chain, address);
118
+ const calls = await resolveCallInputs(callInputs, config, chain, address);
124
119
  return calls;
125
120
  }
126
121
  /**
@@ -133,12 +128,12 @@ async function recoverEcdsaOwnership(address, newOwners, chain, config) {
133
128
  * @returns Calls to recover ownership
134
129
  */
135
130
  async function recoverPasskeyOwnership(address, oldCredentials, newOwners, chain, config) {
136
- const publicClient = (0, viem_1.createPublicClient)({
131
+ const publicClient = createPublicClient({
137
132
  chain,
138
- transport: (0, json_rpc_1.createTransport)(chain, config.provider),
133
+ transport: createTransport(chain, config.provider),
139
134
  });
140
135
  const existingThreshold = await publicClient.readContract({
141
- address: core_1.WEBAUTHN_VALIDATOR_ADDRESS,
136
+ address: WEBAUTHN_VALIDATOR_ADDRESS,
142
137
  abi: [
143
138
  {
144
139
  inputs: [{ internalType: 'address', name: 'account', type: 'address' }],
@@ -171,7 +166,7 @@ async function recoverPasskeyOwnership(address, oldCredentials, newOwners, chain
171
166
  const newThreshold = newOwners.threshold ?? 1;
172
167
  // Check if threshold needs to be updated
173
168
  if (Number(existingThreshold) !== newThreshold) {
174
- callInputs.push((0, passkeys_1.changeThreshold)(newThreshold));
169
+ callInputs.push(changePasskeyThreshold(newThreshold));
175
170
  }
176
171
  // Compare existing and new credentials to determine what to add/remove
177
172
  const existingCredentialKeys = oldCredentials.map((cred) => `${cred.pubKeyX.toString()}-${cred.pubKeyY.toString()}`);
@@ -182,12 +177,13 @@ async function recoverPasskeyOwnership(address, oldCredentials, newOwners, chain
182
177
  const credentialsToRemove = oldCredentials.filter((cred) => !newCredentialKeys.includes(`${cred.pubKeyX.toString()}-${cred.pubKeyY.toString()}`));
183
178
  // Remove old credentials first (important for security in recovery scenarios)
184
179
  for (const credential of credentialsToRemove) {
185
- callInputs.push((0, passkeys_1.removeOwner)(credential.pubKeyX, credential.pubKeyY));
180
+ callInputs.push(removePasskeyOwner(credential.pubKeyX, credential.pubKeyY));
186
181
  }
187
182
  // Then add new credentials
188
183
  for (const credential of credentialsToAdd) {
189
- callInputs.push((0, passkeys_1.addOwner)(credential.pubKeyX, credential.pubKeyY, credential.requireUV));
184
+ callInputs.push(addPasskeyOwner(credential.pubKeyX, credential.pubKeyY, credential.requireUV));
190
185
  }
191
- const calls = await (0, utils_1.resolveCallInputs)(callInputs, config, chain, address);
186
+ const calls = await resolveCallInputs(callInputs, config, chain, address);
192
187
  return calls;
193
188
  }
189
+ export { enable, recoverEcdsaOwnership, recoverPasskeyOwnership };
@@ -1,5 +1,5 @@
1
1
  import type { Hex } from 'viem';
2
- import type { LazyCallInput, SessionInput } from '../types';
2
+ import type { LazyCallInput, SessionInput } from '../types.js';
3
3
  /**
4
4
  * Enable smart sessions
5
5
  * @returns Calls to enable smart sessions
@@ -1,10 +1,5 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.experimental_disable = experimental_disable;
4
- exports.experimental_enable = experimental_enable;
5
- exports.experimental_enableSession = experimental_enableSession;
6
- const accounts_1 = require("../accounts");
7
- const smart_sessions_1 = require("../modules/validators/smart-sessions");
1
+ import { getModuleInstallationCalls, getModuleUninstallationCalls, } from '../accounts/index.js';
2
+ import { getEnableSessionCall, getSmartSessionValidator, } from '../modules/validators/smart-sessions.js';
8
3
  /**
9
4
  * Enable smart sessions
10
5
  * @returns Calls to enable smart sessions
@@ -12,11 +7,11 @@ const smart_sessions_1 = require("../modules/validators/smart-sessions");
12
7
  function experimental_enable() {
13
8
  return {
14
9
  async resolve({ config }) {
15
- const module = (0, smart_sessions_1.getSmartSessionValidator)(config);
10
+ const module = getSmartSessionValidator(config);
16
11
  if (!module) {
17
12
  return [];
18
13
  }
19
- return (0, accounts_1.getModuleInstallationCalls)(config, module);
14
+ return getModuleInstallationCalls(config, module);
20
15
  },
21
16
  };
22
17
  }
@@ -27,11 +22,11 @@ function experimental_enable() {
27
22
  function experimental_disable() {
28
23
  return {
29
24
  async resolve({ config }) {
30
- const module = (0, smart_sessions_1.getSmartSessionValidator)(config);
25
+ const module = getSmartSessionValidator(config);
31
26
  if (!module) {
32
27
  return [];
33
28
  }
34
- return (0, accounts_1.getModuleUninstallationCalls)(config, module);
29
+ return getModuleUninstallationCalls(config, module);
35
30
  },
36
31
  };
37
32
  }
@@ -43,10 +38,11 @@ function experimental_disable() {
43
38
  function experimental_enableSession(session, enableSessionSignature, hashesAndChainIds, sessionToEnableIndex) {
44
39
  return {
45
40
  async resolve({ accountAddress, chain, config }) {
46
- return (0, smart_sessions_1.getEnableSessionCall)(accountAddress, {
41
+ return getEnableSessionCall(accountAddress, {
47
42
  ...session,
48
43
  chain,
49
44
  }, enableSessionSignature, hashesAndChainIds, sessionToEnableIndex, config.useDevContracts);
50
45
  },
51
46
  };
52
47
  }
48
+ export { experimental_disable, experimental_enable, experimental_enableSession };
@@ -0,0 +1,7 @@
1
+ import type { RhinestoneConfig, RhinestoneSDKConfig } from '../types.js';
2
+ export interface AuthProvider {
3
+ getHeaders(): Promise<Record<string, string>>;
4
+ getSubmitHeaders(intentInput: unknown, isSponsored: boolean): Promise<Record<string, string>>;
5
+ }
6
+ export declare function createAuthProvider(config: RhinestoneSDKConfig | RhinestoneConfig): AuthProvider;
7
+ //# sourceMappingURL=provider.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"provider.d.ts","sourceRoot":"","sources":["../../../auth/provider.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAEV,gBAAgB,EAChB,mBAAmB,EACpB,MAAM,UAAU,CAAA;AAEjB,MAAM,WAAW,YAAY;IAC3B,UAAU,IAAI,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAA;IAC7C,gBAAgB,CACd,WAAW,EAAE,OAAO,EACpB,WAAW,EAAE,OAAO,GACnB,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAA;CACnC;AAED,wBAAgB,kBAAkB,CAChC,MAAM,EAAE,mBAAmB,GAAG,gBAAgB,GAC7C,YAAY,CAqCd"}
@@ -0,0 +1,38 @@
1
+ export function createAuthProvider(config) {
2
+ const resolved = resolveAuth(config);
3
+ if (resolved.mode === 'apiKey') {
4
+ const headers = { 'x-api-key': resolved.apiKey };
5
+ return {
6
+ getHeaders: async () => headers,
7
+ getSubmitHeaders: async () => headers,
8
+ };
9
+ }
10
+ const { accessToken, getIntentExtensionToken } = resolved;
11
+ const resolveAccessToken = async () => typeof accessToken === 'function' ? await accessToken() : accessToken;
12
+ return {
13
+ async getHeaders() {
14
+ const token = await resolveAccessToken();
15
+ return { Authorization: `Bearer ${token}`, 'x-api-key': 'jwt' };
16
+ },
17
+ async getSubmitHeaders(intentInput, isSponsored) {
18
+ const token = await resolveAccessToken();
19
+ const headers = {
20
+ Authorization: `Bearer ${token}`,
21
+ 'x-api-key': 'jwt',
22
+ };
23
+ if (isSponsored && getIntentExtensionToken) {
24
+ const extensionToken = await getIntentExtensionToken(intentInput);
25
+ headers['X-Intent-Extension'] = `Bearer ${extensionToken}`;
26
+ }
27
+ return headers;
28
+ },
29
+ };
30
+ }
31
+ function resolveAuth(config) {
32
+ if ('auth' in config && config.auth)
33
+ return config.auth;
34
+ if ('apiKey' in config && config.apiKey) {
35
+ return { mode: 'apiKey', apiKey: config.apiKey };
36
+ }
37
+ throw new Error('RhinestoneSDK requires either `apiKey` or `auth` in config');
38
+ }
@@ -1,5 +1,5 @@
1
- import { AccountConfigurationNotSupportedError, AccountError, Eip712DomainNotAvailableError, Eip7702AccountMustHaveEoaError, Eip7702NotSupportedForAccountError, EoaAccountMustHaveAccountError, ExistingEip7702AccountsNotSupportedError, FactoryArgsNotAvailableError, isAccountError, SigningNotSupportedForAccountError, SmartSessionsNotEnabledError, WalletClientNoConnectedAccountError } from '../accounts';
2
- import { ExecutionError, IntentFailedError, isExecutionError, OrderPathRequiredForIntentsError, SessionChainRequiredError, SignerNotSupportedError } from '../execution';
3
- import { AuthenticationRequiredError, BadRequestError, BodyParserError, ConflictError, ForbiddenError, InsufficientBalanceError, InsufficientLiquidityError, IntentNotFoundError, InternalServerError, InvalidApiKeyError, InvalidIntentSignatureError, isAuthError, isOrchestratorError, isRateLimited, isRetryable, isValidationError, NoPathFoundError, OnlyOneTargetTokenAmountCanBeUnsetError, OrchestratorError, RateLimitedError, ResourceNotFoundError, SchemaValidationError, ServiceUnavailableError, SimulationFailedError, TokenNotSupportedError, UnauthorizedError, UnprocessableEntityError, UnsupportedChainError, UnsupportedChainIdError, UnsupportedTokenError } from '../orchestrator';
1
+ import { AccountConfigurationNotSupportedError, AccountError, Eip712DomainNotAvailableError, Eip7702AccountMustHaveEoaError, Eip7702NotSupportedForAccountError, EoaAccountMustHaveAccountError, ExistingEip7702AccountsNotSupportedError, FactoryArgsNotAvailableError, isAccountError, SigningNotSupportedForAccountError, SmartSessionsNotEnabledError, WalletClientNoConnectedAccountError } from '../accounts/index.js';
2
+ import { ExecutionError, IntentFailedError, isExecutionError, OrderPathRequiredForIntentsError, SessionChainRequiredError, SignerNotSupportedError } from '../execution/index.js';
3
+ import { AuthenticationRequiredError, BadRequestError, BodyParserError, ConflictError, ForbiddenError, InsufficientBalanceError, InsufficientLiquidityError, IntentNotFoundError, InternalServerError, InvalidApiKeyError, InvalidIntentSignatureError, isAuthError, isOrchestratorError, isRateLimited, isRetryable, isValidationError, NoPathFoundError, OnlyOneTargetTokenAmountCanBeUnsetError, OrchestratorError, RateLimitedError, ResourceNotFoundError, SchemaValidationError, ServiceUnavailableError, SimulationFailedError, TokenNotSupportedError, UnauthorizedError, UnprocessableEntityError, UnsupportedChainError, UnsupportedChainIdError, UnsupportedTokenError } from '../orchestrator/index.js';
4
4
  export { isAccountError, AccountError, AccountConfigurationNotSupportedError, Eip712DomainNotAvailableError, Eip7702AccountMustHaveEoaError, EoaAccountMustHaveAccountError, ExistingEip7702AccountsNotSupportedError, FactoryArgsNotAvailableError, SmartSessionsNotEnabledError, SigningNotSupportedForAccountError, Eip7702NotSupportedForAccountError, WalletClientNoConnectedAccountError, isExecutionError, ExecutionError, IntentFailedError, OrderPathRequiredForIntentsError, SessionChainRequiredError, SignerNotSupportedError, isOrchestratorError, isRetryable, isAuthError, isValidationError, isRateLimited, AuthenticationRequiredError, BadRequestError, BodyParserError, ConflictError, ForbiddenError, InsufficientBalanceError, InsufficientLiquidityError, InvalidApiKeyError, InvalidIntentSignatureError, NoPathFoundError, OnlyOneTargetTokenAmountCanBeUnsetError, OrchestratorError, IntentNotFoundError, InternalServerError, ResourceNotFoundError, RateLimitedError, SchemaValidationError, ServiceUnavailableError, SimulationFailedError, UnprocessableEntityError, UnauthorizedError, TokenNotSupportedError, UnsupportedChainError, UnsupportedChainIdError, UnsupportedTokenError, };
5
5
  //# sourceMappingURL=index.d.ts.map