@aspect-wallet/sdk 0.1.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 (164) hide show
  1. package/CHANGELOG.md +24 -0
  2. package/LICENSE +21 -0
  3. package/README.md +708 -0
  4. package/dist/audit/history.d.ts +44 -0
  5. package/dist/audit/history.d.ts.map +1 -0
  6. package/dist/audit/history.js +80 -0
  7. package/dist/audit/history.js.map +1 -0
  8. package/dist/auth/email.d.ts +52 -0
  9. package/dist/auth/email.d.ts.map +1 -0
  10. package/dist/auth/email.js +66 -0
  11. package/dist/auth/email.js.map +1 -0
  12. package/dist/auth/oauth.d.ts +47 -0
  13. package/dist/auth/oauth.d.ts.map +1 -0
  14. package/dist/auth/oauth.js +103 -0
  15. package/dist/auth/oauth.js.map +1 -0
  16. package/dist/auth/passkey-auth.d.ts +39 -0
  17. package/dist/auth/passkey-auth.d.ts.map +1 -0
  18. package/dist/auth/passkey-auth.js +108 -0
  19. package/dist/auth/passkey-auth.js.map +1 -0
  20. package/dist/auth/session.d.ts +30 -0
  21. package/dist/auth/session.d.ts.map +1 -0
  22. package/dist/auth/session.js +61 -0
  23. package/dist/auth/session.js.map +1 -0
  24. package/dist/chain/registry.d.ts +25 -0
  25. package/dist/chain/registry.d.ts.map +1 -0
  26. package/dist/chain/registry.js +46 -0
  27. package/dist/chain/registry.js.map +1 -0
  28. package/dist/core/client.d.ts +78 -0
  29. package/dist/core/client.d.ts.map +1 -0
  30. package/dist/core/client.js +129 -0
  31. package/dist/core/client.js.map +1 -0
  32. package/dist/core/config.d.ts +22 -0
  33. package/dist/core/config.d.ts.map +1 -0
  34. package/dist/core/config.js +91 -0
  35. package/dist/core/config.js.map +1 -0
  36. package/dist/core/errors.d.ts +32 -0
  37. package/dist/core/errors.d.ts.map +1 -0
  38. package/dist/core/errors.js +95 -0
  39. package/dist/core/errors.js.map +1 -0
  40. package/dist/index.d.ts +55 -0
  41. package/dist/index.d.ts.map +1 -0
  42. package/dist/index.js +64 -0
  43. package/dist/index.js.map +1 -0
  44. package/dist/mfa/guardian.d.ts +27 -0
  45. package/dist/mfa/guardian.d.ts.map +1 -0
  46. package/dist/mfa/guardian.js +37 -0
  47. package/dist/mfa/guardian.js.map +1 -0
  48. package/dist/mfa/multisig.d.ts +28 -0
  49. package/dist/mfa/multisig.d.ts.map +1 -0
  50. package/dist/mfa/multisig.js +40 -0
  51. package/dist/mfa/multisig.js.map +1 -0
  52. package/dist/mfa/tiers.d.ts +34 -0
  53. package/dist/mfa/tiers.d.ts.map +1 -0
  54. package/dist/mfa/tiers.js +66 -0
  55. package/dist/mfa/tiers.js.map +1 -0
  56. package/dist/mfa/timelock.d.ts +32 -0
  57. package/dist/mfa/timelock.d.ts.map +1 -0
  58. package/dist/mfa/timelock.js +47 -0
  59. package/dist/mfa/timelock.js.map +1 -0
  60. package/dist/recovery/devices.d.ts +31 -0
  61. package/dist/recovery/devices.d.ts.map +1 -0
  62. package/dist/recovery/devices.js +33 -0
  63. package/dist/recovery/devices.js.map +1 -0
  64. package/dist/recovery/export.d.ts +33 -0
  65. package/dist/recovery/export.d.ts.map +1 -0
  66. package/dist/recovery/export.js +44 -0
  67. package/dist/recovery/export.js.map +1 -0
  68. package/dist/recovery/rotation.d.ts +26 -0
  69. package/dist/recovery/rotation.d.ts.map +1 -0
  70. package/dist/recovery/rotation.js +31 -0
  71. package/dist/recovery/rotation.js.map +1 -0
  72. package/dist/recovery/social.d.ts +33 -0
  73. package/dist/recovery/social.d.ts.map +1 -0
  74. package/dist/recovery/social.js +36 -0
  75. package/dist/recovery/social.js.map +1 -0
  76. package/dist/security/freeze.d.ts +34 -0
  77. package/dist/security/freeze.d.ts.map +1 -0
  78. package/dist/security/freeze.js +42 -0
  79. package/dist/security/freeze.js.map +1 -0
  80. package/dist/security/revoke.d.ts +27 -0
  81. package/dist/security/revoke.d.ts.map +1 -0
  82. package/dist/security/revoke.js +27 -0
  83. package/dist/security/revoke.js.map +1 -0
  84. package/dist/security/watchtower.d.ts +34 -0
  85. package/dist/security/watchtower.d.ts.map +1 -0
  86. package/dist/security/watchtower.js +38 -0
  87. package/dist/security/watchtower.js.map +1 -0
  88. package/dist/session-keys/manager.d.ts +40 -0
  89. package/dist/session-keys/manager.d.ts.map +1 -0
  90. package/dist/session-keys/manager.js +65 -0
  91. package/dist/session-keys/manager.js.map +1 -0
  92. package/dist/session-keys/permissions.d.ts +44 -0
  93. package/dist/session-keys/permissions.d.ts.map +1 -0
  94. package/dist/session-keys/permissions.js +63 -0
  95. package/dist/session-keys/permissions.js.map +1 -0
  96. package/dist/session-keys/templates.d.ts +49 -0
  97. package/dist/session-keys/templates.d.ts.map +1 -0
  98. package/dist/session-keys/templates.js +65 -0
  99. package/dist/session-keys/templates.js.map +1 -0
  100. package/dist/signer/eoa.d.ts +24 -0
  101. package/dist/signer/eoa.d.ts.map +1 -0
  102. package/dist/signer/eoa.js +32 -0
  103. package/dist/signer/eoa.js.map +1 -0
  104. package/dist/signer/interface.d.ts +60 -0
  105. package/dist/signer/interface.d.ts.map +1 -0
  106. package/dist/signer/interface.js +47 -0
  107. package/dist/signer/interface.js.map +1 -0
  108. package/dist/signer/multisig.d.ts +38 -0
  109. package/dist/signer/multisig.d.ts.map +1 -0
  110. package/dist/signer/multisig.js +56 -0
  111. package/dist/signer/multisig.js.map +1 -0
  112. package/dist/signer/passkey.d.ts +35 -0
  113. package/dist/signer/passkey.d.ts.map +1 -0
  114. package/dist/signer/passkey.js +112 -0
  115. package/dist/signer/passkey.js.map +1 -0
  116. package/dist/signer/session.d.ts +24 -0
  117. package/dist/signer/session.d.ts.map +1 -0
  118. package/dist/signer/session.js +32 -0
  119. package/dist/signer/session.js.map +1 -0
  120. package/dist/sponsor/paymaster.d.ts +27 -0
  121. package/dist/sponsor/paymaster.d.ts.map +1 -0
  122. package/dist/sponsor/paymaster.js +43 -0
  123. package/dist/sponsor/paymaster.js.map +1 -0
  124. package/dist/transport/api.d.ts +25 -0
  125. package/dist/transport/api.d.ts.map +1 -0
  126. package/dist/transport/api.js +79 -0
  127. package/dist/transport/api.js.map +1 -0
  128. package/dist/transport/bundler.d.ts +52 -0
  129. package/dist/transport/bundler.d.ts.map +1 -0
  130. package/dist/transport/bundler.js +109 -0
  131. package/dist/transport/bundler.js.map +1 -0
  132. package/dist/transport/iframe.d.ts +33 -0
  133. package/dist/transport/iframe.d.ts.map +1 -0
  134. package/dist/transport/iframe.js +131 -0
  135. package/dist/transport/iframe.js.map +1 -0
  136. package/dist/types.d.ts +366 -0
  137. package/dist/types.d.ts.map +1 -0
  138. package/dist/types.js +6 -0
  139. package/dist/types.js.map +1 -0
  140. package/dist/userop/builder.d.ts +75 -0
  141. package/dist/userop/builder.d.ts.map +1 -0
  142. package/dist/userop/builder.js +150 -0
  143. package/dist/userop/builder.js.map +1 -0
  144. package/dist/userop/encoding.d.ts +44 -0
  145. package/dist/userop/encoding.d.ts.map +1 -0
  146. package/dist/userop/encoding.js +99 -0
  147. package/dist/userop/encoding.js.map +1 -0
  148. package/dist/userop/gas.d.ts +35 -0
  149. package/dist/userop/gas.d.ts.map +1 -0
  150. package/dist/userop/gas.js +53 -0
  151. package/dist/userop/gas.js.map +1 -0
  152. package/dist/userop/hash.d.ts +34 -0
  153. package/dist/userop/hash.d.ts.map +1 -0
  154. package/dist/userop/hash.js +55 -0
  155. package/dist/userop/hash.js.map +1 -0
  156. package/dist/userop/nonce.d.ts +53 -0
  157. package/dist/userop/nonce.d.ts.map +1 -0
  158. package/dist/userop/nonce.js +79 -0
  159. package/dist/userop/nonce.js.map +1 -0
  160. package/dist/wallet/factory.d.ts +63 -0
  161. package/dist/wallet/factory.d.ts.map +1 -0
  162. package/dist/wallet/factory.js +63 -0
  163. package/dist/wallet/factory.js.map +1 -0
  164. package/package.json +70 -0
@@ -0,0 +1,26 @@
1
+ /**
2
+ * Two-step key rotation.
3
+ * Corresponds to SPEC-013 Section 10.1.
4
+ *
5
+ * Step 1: Current owner calls transferOwnership(newOwner) -> sets pendingOwner
6
+ * Step 2: New owner calls acceptOwnership() -> owner = newOwner
7
+ */
8
+ import type { Address } from '../types.js';
9
+ import { ApiClient } from '../transport/api.js';
10
+ /**
11
+ * Key rotation module.
12
+ * Implements the two-step ownership transfer pattern for security.
13
+ */
14
+ export declare class KeyRotation {
15
+ private readonly api;
16
+ constructor(api: ApiClient);
17
+ /** Step 1: Current owner initiates transfer to new key */
18
+ initiateKeyRotation(params: {
19
+ newOwner: Address;
20
+ }): Promise<void>;
21
+ /** Step 2: New owner accepts ownership (must sign from new key) */
22
+ acceptKeyRotation(): Promise<void>;
23
+ /** Check if there's a pending ownership transfer */
24
+ getPendingOwner(walletAddress: Address): Promise<Address | null>;
25
+ }
26
+ //# sourceMappingURL=rotation.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"rotation.d.ts","sourceRoot":"","sources":["../../src/recovery/rotation.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAC3C,OAAO,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAEhD;;;GAGG;AACH,qBAAa,WAAW;IACV,OAAO,CAAC,QAAQ,CAAC,GAAG;gBAAH,GAAG,EAAE,SAAS;IAE3C,0DAA0D;IACpD,mBAAmB,CAAC,MAAM,EAAE;QAAE,QAAQ,EAAE,OAAO,CAAA;KAAE,GAAG,OAAO,CAAC,IAAI,CAAC;IAIvE,mEAAmE;IAC7D,iBAAiB,IAAI,OAAO,CAAC,IAAI,CAAC;IAIxC,oDAAoD;IAC9C,eAAe,CAAC,aAAa,EAAE,OAAO,GAAG,OAAO,CAAC,OAAO,GAAG,IAAI,CAAC;CAOvE"}
@@ -0,0 +1,31 @@
1
+ /**
2
+ * Two-step key rotation.
3
+ * Corresponds to SPEC-013 Section 10.1.
4
+ *
5
+ * Step 1: Current owner calls transferOwnership(newOwner) -> sets pendingOwner
6
+ * Step 2: New owner calls acceptOwnership() -> owner = newOwner
7
+ */
8
+ /**
9
+ * Key rotation module.
10
+ * Implements the two-step ownership transfer pattern for security.
11
+ */
12
+ export class KeyRotation {
13
+ api;
14
+ constructor(api) {
15
+ this.api = api;
16
+ }
17
+ /** Step 1: Current owner initiates transfer to new key */
18
+ async initiateKeyRotation(params) {
19
+ await this.api.post('/recovery/rotate/initiate', params);
20
+ }
21
+ /** Step 2: New owner accepts ownership (must sign from new key) */
22
+ async acceptKeyRotation() {
23
+ await this.api.post('/recovery/rotate/accept', {});
24
+ }
25
+ /** Check if there's a pending ownership transfer */
26
+ async getPendingOwner(walletAddress) {
27
+ const result = await this.api.get('/recovery/rotate/pending', { wallet: walletAddress });
28
+ return result.pendingOwner;
29
+ }
30
+ }
31
+ //# sourceMappingURL=rotation.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"rotation.js","sourceRoot":"","sources":["../../src/recovery/rotation.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAKH;;;GAGG;AACH,MAAM,OAAO,WAAW;IACO;IAA7B,YAA6B,GAAc;QAAd,QAAG,GAAH,GAAG,CAAW;IAAG,CAAC;IAE/C,0DAA0D;IAC1D,KAAK,CAAC,mBAAmB,CAAC,MAA6B;QACrD,MAAM,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,2BAA2B,EAAE,MAAM,CAAC,CAAC;IAC3D,CAAC;IAED,mEAAmE;IACnE,KAAK,CAAC,iBAAiB;QACrB,MAAM,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,yBAAyB,EAAE,EAAE,CAAC,CAAC;IACrD,CAAC;IAED,oDAAoD;IACpD,KAAK,CAAC,eAAe,CAAC,aAAsB;QAC1C,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,GAAG,CAAC,GAAG,CAC/B,0BAA0B,EAC1B,EAAE,MAAM,EAAE,aAAa,EAAE,CAC1B,CAAC;QACF,OAAO,MAAM,CAAC,YAAY,CAAC;IAC7B,CAAC;CACF"}
@@ -0,0 +1,33 @@
1
+ /**
2
+ * Social recovery via guardians.
3
+ * Corresponds to SPEC-013 Section 10.2.
4
+ */
5
+ import type { Address, RecoveryStatus } from '../types.js';
6
+ import { ApiClient } from '../transport/api.js';
7
+ /**
8
+ * Social recovery module.
9
+ * Guardians can initiate recovery with timelock protection.
10
+ * Owner can cancel during timelock period.
11
+ */
12
+ export declare class SocialRecovery {
13
+ private readonly api;
14
+ constructor(api: ApiClient);
15
+ /** Guardian initiates recovery for a compromised account */
16
+ initiateRecovery(params: {
17
+ account: Address;
18
+ newOwner: Address;
19
+ }): Promise<void>;
20
+ /** Guardian approves an ongoing recovery */
21
+ approveRecovery(params: {
22
+ account: Address;
23
+ }): Promise<void>;
24
+ /** Execute recovery after timelock expires (anyone can call) */
25
+ executeRecovery(params: {
26
+ account: Address;
27
+ }): Promise<void>;
28
+ /** Owner cancels a malicious recovery during timelock */
29
+ cancelRecovery(): Promise<void>;
30
+ /** Get the status of any pending recovery */
31
+ getStatus(walletAddress: Address): Promise<RecoveryStatus>;
32
+ }
33
+ //# sourceMappingURL=social.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"social.d.ts","sourceRoot":"","sources":["../../src/recovery/social.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAC3D,OAAO,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAEhD;;;;GAIG;AACH,qBAAa,cAAc;IACb,OAAO,CAAC,QAAQ,CAAC,GAAG;gBAAH,GAAG,EAAE,SAAS;IAE3C,4DAA4D;IACtD,gBAAgB,CAAC,MAAM,EAAE;QAC7B,OAAO,EAAE,OAAO,CAAC;QACjB,QAAQ,EAAE,OAAO,CAAC;KACnB,GAAG,OAAO,CAAC,IAAI,CAAC;IAIjB,4CAA4C;IACtC,eAAe,CAAC,MAAM,EAAE;QAAE,OAAO,EAAE,OAAO,CAAA;KAAE,GAAG,OAAO,CAAC,IAAI,CAAC;IAIlE,gEAAgE;IAC1D,eAAe,CAAC,MAAM,EAAE;QAAE,OAAO,EAAE,OAAO,CAAA;KAAE,GAAG,OAAO,CAAC,IAAI,CAAC;IAIlE,yDAAyD;IACnD,cAAc,IAAI,OAAO,CAAC,IAAI,CAAC;IAIrC,6CAA6C;IACvC,SAAS,CAAC,aAAa,EAAE,OAAO,GAAG,OAAO,CAAC,cAAc,CAAC;CAGjE"}
@@ -0,0 +1,36 @@
1
+ /**
2
+ * Social recovery via guardians.
3
+ * Corresponds to SPEC-013 Section 10.2.
4
+ */
5
+ /**
6
+ * Social recovery module.
7
+ * Guardians can initiate recovery with timelock protection.
8
+ * Owner can cancel during timelock period.
9
+ */
10
+ export class SocialRecovery {
11
+ api;
12
+ constructor(api) {
13
+ this.api = api;
14
+ }
15
+ /** Guardian initiates recovery for a compromised account */
16
+ async initiateRecovery(params) {
17
+ await this.api.post('/recovery/initiate', params);
18
+ }
19
+ /** Guardian approves an ongoing recovery */
20
+ async approveRecovery(params) {
21
+ await this.api.post('/recovery/approve', params);
22
+ }
23
+ /** Execute recovery after timelock expires (anyone can call) */
24
+ async executeRecovery(params) {
25
+ await this.api.post('/recovery/execute', params);
26
+ }
27
+ /** Owner cancels a malicious recovery during timelock */
28
+ async cancelRecovery() {
29
+ await this.api.post('/recovery/cancel', {});
30
+ }
31
+ /** Get the status of any pending recovery */
32
+ async getStatus(walletAddress) {
33
+ return this.api.get('/recovery/status', { wallet: walletAddress });
34
+ }
35
+ }
36
+ //# sourceMappingURL=social.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"social.js","sourceRoot":"","sources":["../../src/recovery/social.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAKH;;;;GAIG;AACH,MAAM,OAAO,cAAc;IACI;IAA7B,YAA6B,GAAc;QAAd,QAAG,GAAH,GAAG,CAAW;IAAG,CAAC;IAE/C,4DAA4D;IAC5D,KAAK,CAAC,gBAAgB,CAAC,MAGtB;QACC,MAAM,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,oBAAoB,EAAE,MAAM,CAAC,CAAC;IACpD,CAAC;IAED,4CAA4C;IAC5C,KAAK,CAAC,eAAe,CAAC,MAA4B;QAChD,MAAM,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,mBAAmB,EAAE,MAAM,CAAC,CAAC;IACnD,CAAC;IAED,gEAAgE;IAChE,KAAK,CAAC,eAAe,CAAC,MAA4B;QAChD,MAAM,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,mBAAmB,EAAE,MAAM,CAAC,CAAC;IACnD,CAAC;IAED,yDAAyD;IACzD,KAAK,CAAC,cAAc;QAClB,MAAM,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,kBAAkB,EAAE,EAAE,CAAC,CAAC;IAC9C,CAAC;IAED,6CAA6C;IAC7C,KAAK,CAAC,SAAS,CAAC,aAAsB;QACpC,OAAO,IAAI,CAAC,GAAG,CAAC,GAAG,CAAiB,kBAAkB,EAAE,EAAE,MAAM,EAAE,aAAa,EAAE,CAAC,CAAC;IACrF,CAAC;CACF"}
@@ -0,0 +1,34 @@
1
+ /**
2
+ * Emergency account freeze.
3
+ * Corresponds to SPEC-013 Section 11.1.
4
+ *
5
+ * On freeze:
6
+ * - Revokes ALL session keys
7
+ * - Sets account to frozen state on-chain
8
+ * - Suspends all pending paymaster approvals
9
+ * - Alerts all guardians via watchtower
10
+ *
11
+ * Unfreeze requires MFA (Tier 3 or Tier 4).
12
+ */
13
+ import { ApiClient } from '../transport/api.js';
14
+ /**
15
+ * Emergency freeze/unfreeze for compromised accounts.
16
+ */
17
+ export declare class FreezeManager {
18
+ private readonly api;
19
+ constructor(api: ApiClient);
20
+ /**
21
+ * Freeze the account from any device with owner access.
22
+ * Immediately revokes all session keys and blocks operations.
23
+ */
24
+ freeze(params: {
25
+ reason: string;
26
+ }): Promise<void>;
27
+ /**
28
+ * Unfreeze the account (requires MFA -- Tier 3 or Tier 4).
29
+ */
30
+ unfreeze(): Promise<void>;
31
+ /** Check if the account is currently frozen */
32
+ isFrozen(walletAddress: string): Promise<boolean>;
33
+ }
34
+ //# sourceMappingURL=freeze.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"freeze.d.ts","sourceRoot":"","sources":["../../src/security/freeze.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAEhD;;GAEG;AACH,qBAAa,aAAa;IACZ,OAAO,CAAC,QAAQ,CAAC,GAAG;gBAAH,GAAG,EAAE,SAAS;IAE3C;;;OAGG;IACG,MAAM,CAAC,MAAM,EAAE;QAAE,MAAM,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC,IAAI,CAAC;IAIvD;;OAEG;IACG,QAAQ,IAAI,OAAO,CAAC,IAAI,CAAC;IAI/B,+CAA+C;IACzC,QAAQ,CAAC,aAAa,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;CAMxD"}
@@ -0,0 +1,42 @@
1
+ /**
2
+ * Emergency account freeze.
3
+ * Corresponds to SPEC-013 Section 11.1.
4
+ *
5
+ * On freeze:
6
+ * - Revokes ALL session keys
7
+ * - Sets account to frozen state on-chain
8
+ * - Suspends all pending paymaster approvals
9
+ * - Alerts all guardians via watchtower
10
+ *
11
+ * Unfreeze requires MFA (Tier 3 or Tier 4).
12
+ */
13
+ /**
14
+ * Emergency freeze/unfreeze for compromised accounts.
15
+ */
16
+ export class FreezeManager {
17
+ api;
18
+ constructor(api) {
19
+ this.api = api;
20
+ }
21
+ /**
22
+ * Freeze the account from any device with owner access.
23
+ * Immediately revokes all session keys and blocks operations.
24
+ */
25
+ async freeze(params) {
26
+ await this.api.post('/security/freeze', params);
27
+ }
28
+ /**
29
+ * Unfreeze the account (requires MFA -- Tier 3 or Tier 4).
30
+ */
31
+ async unfreeze() {
32
+ await this.api.post('/security/unfreeze', {});
33
+ }
34
+ /** Check if the account is currently frozen */
35
+ async isFrozen(walletAddress) {
36
+ const result = await this.api.get(`/security/freeze/status`, {
37
+ wallet: walletAddress,
38
+ });
39
+ return result.frozen;
40
+ }
41
+ }
42
+ //# sourceMappingURL=freeze.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"freeze.js","sourceRoot":"","sources":["../../src/security/freeze.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAIH;;GAEG;AACH,MAAM,OAAO,aAAa;IACK;IAA7B,YAA6B,GAAc;QAAd,QAAG,GAAH,GAAG,CAAW;IAAG,CAAC;IAE/C;;;OAGG;IACH,KAAK,CAAC,MAAM,CAAC,MAA0B;QACrC,MAAM,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,kBAAkB,EAAE,MAAM,CAAC,CAAC;IAClD,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,QAAQ;QACZ,MAAM,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,oBAAoB,EAAE,EAAE,CAAC,CAAC;IAChD,CAAC;IAED,+CAA+C;IAC/C,KAAK,CAAC,QAAQ,CAAC,aAAqB;QAClC,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,GAAG,CAAC,GAAG,CAAsB,yBAAyB,EAAE;YAChF,MAAM,EAAE,aAAa;SACtB,CAAC,CAAC;QACH,OAAO,MAAM,CAAC,MAAM,CAAC;IACvB,CAAC;CACF"}
@@ -0,0 +1,27 @@
1
+ /**
2
+ * Bulk session key revocation.
3
+ * Corresponds to SPEC-013 Section 11.2.
4
+ */
5
+ import { ApiClient } from '../transport/api.js';
6
+ /**
7
+ * Bulk session key revocation for emergency response.
8
+ */
9
+ export declare class RevokeManager {
10
+ private readonly api;
11
+ constructor(api: ApiClient);
12
+ /**
13
+ * Revoke ALL session keys at once.
14
+ * Sends batch UserOp: uninstallValidation for all session moduleIds.
15
+ */
16
+ revokeAllSessionKeys(): Promise<void>;
17
+ /**
18
+ * Revoke session keys matching specific criteria.
19
+ */
20
+ revokeSessionKeys(params: {
21
+ expiredOnly?: boolean;
22
+ olderThan?: number;
23
+ }): Promise<{
24
+ revokedCount: number;
25
+ }>;
26
+ }
27
+ //# sourceMappingURL=revoke.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"revoke.d.ts","sourceRoot":"","sources":["../../src/security/revoke.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAEhD;;GAEG;AACH,qBAAa,aAAa;IACZ,OAAO,CAAC,QAAQ,CAAC,GAAG;gBAAH,GAAG,EAAE,SAAS;IAE3C;;;OAGG;IACG,oBAAoB,IAAI,OAAO,CAAC,IAAI,CAAC;IAI3C;;OAEG;IACG,iBAAiB,CAAC,MAAM,EAAE;QAC9B,WAAW,CAAC,EAAE,OAAO,CAAC;QACtB,SAAS,CAAC,EAAE,MAAM,CAAC;KACpB,GAAG,OAAO,CAAC;QAAE,YAAY,EAAE,MAAM,CAAA;KAAE,CAAC;CAGtC"}
@@ -0,0 +1,27 @@
1
+ /**
2
+ * Bulk session key revocation.
3
+ * Corresponds to SPEC-013 Section 11.2.
4
+ */
5
+ /**
6
+ * Bulk session key revocation for emergency response.
7
+ */
8
+ export class RevokeManager {
9
+ api;
10
+ constructor(api) {
11
+ this.api = api;
12
+ }
13
+ /**
14
+ * Revoke ALL session keys at once.
15
+ * Sends batch UserOp: uninstallValidation for all session moduleIds.
16
+ */
17
+ async revokeAllSessionKeys() {
18
+ await this.api.post('/security/revoke/all-sessions', {});
19
+ }
20
+ /**
21
+ * Revoke session keys matching specific criteria.
22
+ */
23
+ async revokeSessionKeys(params) {
24
+ return this.api.post('/security/revoke/sessions', params);
25
+ }
26
+ }
27
+ //# sourceMappingURL=revoke.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"revoke.js","sourceRoot":"","sources":["../../src/security/revoke.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH;;GAEG;AACH,MAAM,OAAO,aAAa;IACK;IAA7B,YAA6B,GAAc;QAAd,QAAG,GAAH,GAAG,CAAW;IAAG,CAAC;IAE/C;;;OAGG;IACH,KAAK,CAAC,oBAAoB;QACxB,MAAM,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,+BAA+B,EAAE,EAAE,CAAC,CAAC;IAC3D,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,iBAAiB,CAAC,MAGvB;QACC,OAAO,IAAI,CAAC,GAAG,CAAC,IAAI,CAA2B,2BAA2B,EAAE,MAAM,CAAC,CAAC;IACtF,CAAC;CACF"}
@@ -0,0 +1,34 @@
1
+ /**
2
+ * Watchtower alert subscriptions.
3
+ * Corresponds to SPEC-013 Section 11.3.
4
+ */
5
+ import type { Address, WatchtowerSubscription, WatchtowerAlertType } from '../types.js';
6
+ import { ApiClient } from '../transport/api.js';
7
+ interface WatchtowerAlert {
8
+ id: string;
9
+ type: WatchtowerAlertType;
10
+ account: Address;
11
+ timestamp: number;
12
+ details: Record<string, unknown>;
13
+ }
14
+ /**
15
+ * Watchtower service client.
16
+ * Subscribe to security alerts and get notifications for suspicious activity.
17
+ */
18
+ export declare class WatchtowerClient {
19
+ private readonly api;
20
+ constructor(api: ApiClient);
21
+ /**
22
+ * Subscribe to security alerts for an account.
23
+ * Alerts are sent via email and/or webhook.
24
+ */
25
+ subscribe(subscription: WatchtowerSubscription): Promise<void>;
26
+ /** Unsubscribe from watchtower alerts */
27
+ unsubscribe(account: Address): Promise<void>;
28
+ /** Get recent security alerts for an account */
29
+ getAlerts(account: Address): Promise<WatchtowerAlert[]>;
30
+ /** Get the current subscription for an account */
31
+ getSubscription(account: Address): Promise<WatchtowerSubscription | null>;
32
+ }
33
+ export {};
34
+ //# sourceMappingURL=watchtower.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"watchtower.d.ts","sourceRoot":"","sources":["../../src/security/watchtower.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,sBAAsB,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AACxF,OAAO,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAEhD,UAAU,eAAe;IACvB,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,mBAAmB,CAAC;IAC1B,OAAO,EAAE,OAAO,CAAC;IACjB,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CAClC;AAED;;;GAGG;AACH,qBAAa,gBAAgB;IACf,OAAO,CAAC,QAAQ,CAAC,GAAG;gBAAH,GAAG,EAAE,SAAS;IAE3C;;;OAGG;IACG,SAAS,CAAC,YAAY,EAAE,sBAAsB,GAAG,OAAO,CAAC,IAAI,CAAC;IAIpE,yCAAyC;IACnC,WAAW,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC;IAIlD,gDAAgD;IAC1C,SAAS,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,eAAe,EAAE,CAAC;IAM7D,kDAAkD;IAC5C,eAAe,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,sBAAsB,GAAG,IAAI,CAAC;CAKhF"}
@@ -0,0 +1,38 @@
1
+ /**
2
+ * Watchtower alert subscriptions.
3
+ * Corresponds to SPEC-013 Section 11.3.
4
+ */
5
+ /**
6
+ * Watchtower service client.
7
+ * Subscribe to security alerts and get notifications for suspicious activity.
8
+ */
9
+ export class WatchtowerClient {
10
+ api;
11
+ constructor(api) {
12
+ this.api = api;
13
+ }
14
+ /**
15
+ * Subscribe to security alerts for an account.
16
+ * Alerts are sent via email and/or webhook.
17
+ */
18
+ async subscribe(subscription) {
19
+ await this.api.post('/security/watchtower/subscribe', subscription);
20
+ }
21
+ /** Unsubscribe from watchtower alerts */
22
+ async unsubscribe(account) {
23
+ await this.api.delete(`/security/watchtower/${account}`);
24
+ }
25
+ /** Get recent security alerts for an account */
26
+ async getAlerts(account) {
27
+ return this.api.get('/security/watchtower/alerts', {
28
+ account,
29
+ });
30
+ }
31
+ /** Get the current subscription for an account */
32
+ async getSubscription(account) {
33
+ return this.api.get('/security/watchtower/subscription', {
34
+ account,
35
+ });
36
+ }
37
+ }
38
+ //# sourceMappingURL=watchtower.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"watchtower.js","sourceRoot":"","sources":["../../src/security/watchtower.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAaH;;;GAGG;AACH,MAAM,OAAO,gBAAgB;IACE;IAA7B,YAA6B,GAAc;QAAd,QAAG,GAAH,GAAG,CAAW;IAAG,CAAC;IAE/C;;;OAGG;IACH,KAAK,CAAC,SAAS,CAAC,YAAoC;QAClD,MAAM,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,gCAAgC,EAAE,YAAY,CAAC,CAAC;IACtE,CAAC;IAED,yCAAyC;IACzC,KAAK,CAAC,WAAW,CAAC,OAAgB;QAChC,MAAM,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,wBAAwB,OAAO,EAAE,CAAC,CAAC;IAC3D,CAAC;IAED,gDAAgD;IAChD,KAAK,CAAC,SAAS,CAAC,OAAgB;QAC9B,OAAO,IAAI,CAAC,GAAG,CAAC,GAAG,CAAoB,6BAA6B,EAAE;YACpE,OAAO;SACR,CAAC,CAAC;IACL,CAAC;IAED,kDAAkD;IAClD,KAAK,CAAC,eAAe,CAAC,OAAgB;QACpC,OAAO,IAAI,CAAC,GAAG,CAAC,GAAG,CAAgC,mCAAmC,EAAE;YACtF,OAAO;SACR,CAAC,CAAC;IACL,CAAC;CACF"}
@@ -0,0 +1,40 @@
1
+ /**
2
+ * Session key lifecycle management.
3
+ * Corresponds to SPEC-013 Section 9.
4
+ */
5
+ import type { Address, SessionKeyInfo, SessionKeyPermissions, SessionKeyStatus, ExecutionResult, CallRequest } from '../types.js';
6
+ import { ApiClient } from '../transport/api.js';
7
+ import { SessionKeyTemplates } from './templates.js';
8
+ /**
9
+ * Manages session key creation, installation, execution, and revocation.
10
+ * Session keys are ephemeral keys with scoped permissions enforced on-chain.
11
+ */
12
+ export declare class SessionKeyManager {
13
+ private readonly api;
14
+ /** Pre-built permission templates */
15
+ readonly templates: typeof SessionKeyTemplates;
16
+ constructor(api: ApiClient);
17
+ /**
18
+ * Create and install a new session key with specified permissions.
19
+ * Generates an ephemeral keypair, installs validation module on-chain.
20
+ */
21
+ create(params: {
22
+ permissions: SessionKeyPermissions;
23
+ }): Promise<SessionKeyInfo>;
24
+ /**
25
+ * Execute a call using an active session key.
26
+ * The session key signs automatically -- no user interaction needed.
27
+ * All permission hooks are checked on-chain.
28
+ */
29
+ execute(moduleId: number, call: CallRequest): Promise<ExecutionResult>;
30
+ /** List all active session keys for a wallet */
31
+ list(walletAddress: Address): Promise<SessionKeyInfo[]>;
32
+ /** Get the status of a specific session key */
33
+ getStatus(moduleId: number): Promise<SessionKeyStatus>;
34
+ /**
35
+ * Revoke a session key (owner signs uninstall UserOp).
36
+ * The session key is immediately invalidated on-chain.
37
+ */
38
+ revoke(moduleId: number): Promise<void>;
39
+ }
40
+ //# sourceMappingURL=manager.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"manager.d.ts","sourceRoot":"","sources":["../../src/session-keys/manager.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EACV,OAAO,EAEP,cAAc,EACd,qBAAqB,EACrB,gBAAgB,EAChB,eAAe,EACf,WAAW,EACZ,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAChD,OAAO,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AAErD;;;GAGG;AACH,qBAAa,iBAAiB;IAIhB,OAAO,CAAC,QAAQ,CAAC,GAAG;IAHhC,qCAAqC;IACrC,QAAQ,CAAC,SAAS,6BAAuB;gBAEZ,GAAG,EAAE,SAAS;IAE3C;;;OAGG;IACG,MAAM,CAAC,MAAM,EAAE;QAAE,WAAW,EAAE,qBAAqB,CAAA;KAAE,GAAG,OAAO,CAAC,cAAc,CAAC;IAMrF;;;;OAIG;IACG,OAAO,CACX,QAAQ,EAAE,MAAM,EAChB,IAAI,EAAE,WAAW,GAChB,OAAO,CAAC,eAAe,CAAC;IAQ3B,gDAAgD;IAC1C,IAAI,CAAC,aAAa,EAAE,OAAO,GAAG,OAAO,CAAC,cAAc,EAAE,CAAC;IAI7D,+CAA+C;IACzC,SAAS,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,gBAAgB,CAAC;IAI5D;;;OAGG;IACG,MAAM,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;CAG9C"}
@@ -0,0 +1,65 @@
1
+ /**
2
+ * Session key lifecycle management.
3
+ * Corresponds to SPEC-013 Section 9.
4
+ */
5
+ import { SessionKeyTemplates } from './templates.js';
6
+ /**
7
+ * Manages session key creation, installation, execution, and revocation.
8
+ * Session keys are ephemeral keys with scoped permissions enforced on-chain.
9
+ */
10
+ export class SessionKeyManager {
11
+ api;
12
+ /** Pre-built permission templates */
13
+ templates = SessionKeyTemplates;
14
+ constructor(api) {
15
+ this.api = api;
16
+ }
17
+ /**
18
+ * Create and install a new session key with specified permissions.
19
+ * Generates an ephemeral keypair, installs validation module on-chain.
20
+ */
21
+ async create(params) {
22
+ return this.api.post('/session-keys', {
23
+ permissions: serialisePermissions(params.permissions),
24
+ });
25
+ }
26
+ /**
27
+ * Execute a call using an active session key.
28
+ * The session key signs automatically -- no user interaction needed.
29
+ * All permission hooks are checked on-chain.
30
+ */
31
+ async execute(moduleId, call) {
32
+ return this.api.post(`/session-keys/${moduleId}/execute`, {
33
+ target: call.target,
34
+ value: call.value.toString(),
35
+ data: call.data,
36
+ });
37
+ }
38
+ /** List all active session keys for a wallet */
39
+ async list(walletAddress) {
40
+ return this.api.get('/session-keys', { wallet: walletAddress });
41
+ }
42
+ /** Get the status of a specific session key */
43
+ async getStatus(moduleId) {
44
+ return this.api.get(`/session-keys/${moduleId}`);
45
+ }
46
+ /**
47
+ * Revoke a session key (owner signs uninstall UserOp).
48
+ * The session key is immediately invalidated on-chain.
49
+ */
50
+ async revoke(moduleId) {
51
+ await this.api.delete(`/session-keys/${moduleId}`);
52
+ }
53
+ }
54
+ function serialisePermissions(perms) {
55
+ return {
56
+ allowlist: perms.allowlist,
57
+ spendLimit: {
58
+ perTx: perms.spendLimit.perTx.toString(),
59
+ cumulative: perms.spendLimit.cumulative.toString(),
60
+ },
61
+ timeRange: perms.timeRange,
62
+ requiredPaymaster: perms.requiredPaymaster,
63
+ };
64
+ }
65
+ //# sourceMappingURL=manager.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"manager.js","sourceRoot":"","sources":["../../src/session-keys/manager.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAYH,OAAO,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AAErD;;;GAGG;AACH,MAAM,OAAO,iBAAiB;IAIC;IAH7B,qCAAqC;IAC5B,SAAS,GAAG,mBAAmB,CAAC;IAEzC,YAA6B,GAAc;QAAd,QAAG,GAAH,GAAG,CAAW;IAAG,CAAC;IAE/C;;;OAGG;IACH,KAAK,CAAC,MAAM,CAAC,MAA8C;QACzD,OAAO,IAAI,CAAC,GAAG,CAAC,IAAI,CAAiB,eAAe,EAAE;YACpD,WAAW,EAAE,oBAAoB,CAAC,MAAM,CAAC,WAAW,CAAC;SACtD,CAAC,CAAC;IACL,CAAC;IAED;;;;OAIG;IACH,KAAK,CAAC,OAAO,CACX,QAAgB,EAChB,IAAiB;QAEjB,OAAO,IAAI,CAAC,GAAG,CAAC,IAAI,CAAkB,iBAAiB,QAAQ,UAAU,EAAE;YACzE,MAAM,EAAE,IAAI,CAAC,MAAM;YACnB,KAAK,EAAE,IAAI,CAAC,KAAK,CAAC,QAAQ,EAAE;YAC5B,IAAI,EAAE,IAAI,CAAC,IAAI;SAChB,CAAC,CAAC;IACL,CAAC;IAED,gDAAgD;IAChD,KAAK,CAAC,IAAI,CAAC,aAAsB;QAC/B,OAAO,IAAI,CAAC,GAAG,CAAC,GAAG,CAAmB,eAAe,EAAE,EAAE,MAAM,EAAE,aAAa,EAAE,CAAC,CAAC;IACpF,CAAC;IAED,+CAA+C;IAC/C,KAAK,CAAC,SAAS,CAAC,QAAgB;QAC9B,OAAO,IAAI,CAAC,GAAG,CAAC,GAAG,CAAmB,iBAAiB,QAAQ,EAAE,CAAC,CAAC;IACrE,CAAC;IAED;;;OAGG;IACH,KAAK,CAAC,MAAM,CAAC,QAAgB;QAC3B,MAAM,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,iBAAiB,QAAQ,EAAE,CAAC,CAAC;IACrD,CAAC;CACF;AAED,SAAS,oBAAoB,CAAC,KAA4B;IACxD,OAAO;QACL,SAAS,EAAE,KAAK,CAAC,SAAS;QAC1B,UAAU,EAAE;YACV,KAAK,EAAE,KAAK,CAAC,UAAU,CAAC,KAAK,CAAC,QAAQ,EAAE;YACxC,UAAU,EAAE,KAAK,CAAC,UAAU,CAAC,UAAU,CAAC,QAAQ,EAAE;SACnD;QACD,SAAS,EAAE,KAAK,CAAC,SAAS;QAC1B,iBAAiB,EAAE,KAAK,CAAC,iBAAiB;KAC3C,CAAC;AACJ,CAAC"}
@@ -0,0 +1,44 @@
1
+ /**
2
+ * Permission template builder for session keys.
3
+ * Corresponds to SPEC-013 Section 9.1-9.2.
4
+ */
5
+ import type { Address, Hex, SessionKeyPermissions } from '../types.js';
6
+ /**
7
+ * Fluent builder for constructing session key permission sets.
8
+ *
9
+ * @example
10
+ * ```ts
11
+ * const perms = new PermissionBuilder()
12
+ * .allowContract(gameContract, ['0x12345678', '0xabcdef01'])
13
+ * .setSpendLimit({ perTx: 0n, cumulative: 0n })
14
+ * .setTimeRange({ duration: 4 * 3600 })
15
+ * .requirePaymaster(paymasterAddress)
16
+ * .build();
17
+ * ```
18
+ */
19
+ export declare class PermissionBuilder {
20
+ private allowlist;
21
+ private spendLimit;
22
+ private timeRange;
23
+ private paymaster?;
24
+ /** Allow specific function selectors on a target contract */
25
+ allowContract(target: Address, selectors: Hex[]): this;
26
+ /** Allow all functions on a target contract (wildcard selector) */
27
+ allowContractWildcard(target: Address): this;
28
+ /** Set native token (ETH) spend limits */
29
+ setSpendLimit(limits: {
30
+ perTx: bigint;
31
+ cumulative: bigint;
32
+ }): this;
33
+ /** Set the valid time range by start and end timestamps */
34
+ setTimeRange(params: {
35
+ validAfter?: number;
36
+ validUntil?: number;
37
+ duration?: number;
38
+ }): this;
39
+ /** Require a specific paymaster for all operations */
40
+ requirePaymaster(paymaster: Address): this;
41
+ /** Build the permission set */
42
+ build(): SessionKeyPermissions;
43
+ }
44
+ //# sourceMappingURL=permissions.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"permissions.d.ts","sourceRoot":"","sources":["../../src/session-keys/permissions.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,GAAG,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAC;AAEvE;;;;;;;;;;;;GAYG;AACH,qBAAa,iBAAiB;IAC5B,OAAO,CAAC,SAAS,CAAiD;IAClE,OAAO,CAAC,UAAU,CAAiC;IACnD,OAAO,CAAC,SAAS,CAAoC;IACrD,OAAO,CAAC,SAAS,CAAC,CAAU;IAE5B,6DAA6D;IAC7D,aAAa,CAAC,MAAM,EAAE,OAAO,EAAE,SAAS,EAAE,GAAG,EAAE,GAAG,IAAI;IAOtD,mEAAmE;IACnE,qBAAqB,CAAC,MAAM,EAAE,OAAO,GAAG,IAAI;IAK5C,0CAA0C;IAC1C,aAAa,CAAC,MAAM,EAAE;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,UAAU,EAAE,MAAM,CAAA;KAAE,GAAG,IAAI;IAKlE,2DAA2D;IAC3D,YAAY,CAAC,MAAM,EAAE;QAAE,UAAU,CAAC,EAAE,MAAM,CAAC;QAAC,UAAU,CAAC,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,EAAE,MAAM,CAAA;KAAE,GAAG,IAAI;IAQ3F,sDAAsD;IACtD,gBAAgB,CAAC,SAAS,EAAE,OAAO,GAAG,IAAI;IAK1C,+BAA+B;IAC/B,KAAK,IAAI,qBAAqB;CAQ/B"}
@@ -0,0 +1,63 @@
1
+ /**
2
+ * Permission template builder for session keys.
3
+ * Corresponds to SPEC-013 Section 9.1-9.2.
4
+ */
5
+ /**
6
+ * Fluent builder for constructing session key permission sets.
7
+ *
8
+ * @example
9
+ * ```ts
10
+ * const perms = new PermissionBuilder()
11
+ * .allowContract(gameContract, ['0x12345678', '0xabcdef01'])
12
+ * .setSpendLimit({ perTx: 0n, cumulative: 0n })
13
+ * .setTimeRange({ duration: 4 * 3600 })
14
+ * .requirePaymaster(paymasterAddress)
15
+ * .build();
16
+ * ```
17
+ */
18
+ export class PermissionBuilder {
19
+ allowlist = [];
20
+ spendLimit = { perTx: 0n, cumulative: 0n };
21
+ timeRange = { validAfter: 0, validUntil: 0 };
22
+ paymaster;
23
+ /** Allow specific function selectors on a target contract */
24
+ allowContract(target, selectors) {
25
+ for (const selector of selectors) {
26
+ this.allowlist.push({ target, selector });
27
+ }
28
+ return this;
29
+ }
30
+ /** Allow all functions on a target contract (wildcard selector) */
31
+ allowContractWildcard(target) {
32
+ this.allowlist.push({ target, selector: '0xffffffff' });
33
+ return this;
34
+ }
35
+ /** Set native token (ETH) spend limits */
36
+ setSpendLimit(limits) {
37
+ this.spendLimit = limits;
38
+ return this;
39
+ }
40
+ /** Set the valid time range by start and end timestamps */
41
+ setTimeRange(params) {
42
+ const now = Math.floor(Date.now() / 1000);
43
+ this.timeRange.validAfter = params.validAfter ?? now;
44
+ this.timeRange.validUntil =
45
+ params.validUntil ?? (params.duration ? now + params.duration : 0);
46
+ return this;
47
+ }
48
+ /** Require a specific paymaster for all operations */
49
+ requirePaymaster(paymaster) {
50
+ this.paymaster = paymaster;
51
+ return this;
52
+ }
53
+ /** Build the permission set */
54
+ build() {
55
+ return {
56
+ allowlist: this.allowlist,
57
+ spendLimit: this.spendLimit,
58
+ timeRange: this.timeRange,
59
+ requiredPaymaster: this.paymaster,
60
+ };
61
+ }
62
+ }
63
+ //# sourceMappingURL=permissions.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"permissions.js","sourceRoot":"","sources":["../../src/session-keys/permissions.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH;;;;;;;;;;;;GAYG;AACH,MAAM,OAAO,iBAAiB;IACpB,SAAS,GAA8C,EAAE,CAAC;IAC1D,UAAU,GAAG,EAAE,KAAK,EAAE,EAAE,EAAE,UAAU,EAAE,EAAE,EAAE,CAAC;IAC3C,SAAS,GAAG,EAAE,UAAU,EAAE,CAAC,EAAE,UAAU,EAAE,CAAC,EAAE,CAAC;IAC7C,SAAS,CAAW;IAE5B,6DAA6D;IAC7D,aAAa,CAAC,MAAe,EAAE,SAAgB;QAC7C,KAAK,MAAM,QAAQ,IAAI,SAAS,EAAE,CAAC;YACjC,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,EAAE,MAAM,EAAE,QAAQ,EAAE,CAAC,CAAC;QAC5C,CAAC;QACD,OAAO,IAAI,CAAC;IACd,CAAC;IAED,mEAAmE;IACnE,qBAAqB,CAAC,MAAe;QACnC,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,EAAE,MAAM,EAAE,QAAQ,EAAE,YAAY,EAAE,CAAC,CAAC;QACxD,OAAO,IAAI,CAAC;IACd,CAAC;IAED,0CAA0C;IAC1C,aAAa,CAAC,MAA6C;QACzD,IAAI,CAAC,UAAU,GAAG,MAAM,CAAC;QACzB,OAAO,IAAI,CAAC;IACd,CAAC;IAED,2DAA2D;IAC3D,YAAY,CAAC,MAAuE;QAClF,MAAM,GAAG,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,EAAE,GAAG,IAAI,CAAC,CAAC;QAC1C,IAAI,CAAC,SAAS,CAAC,UAAU,GAAG,MAAM,CAAC,UAAU,IAAI,GAAG,CAAC;QACrD,IAAI,CAAC,SAAS,CAAC,UAAU;YACvB,MAAM,CAAC,UAAU,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAC,GAAG,GAAG,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;QACrE,OAAO,IAAI,CAAC;IACd,CAAC;IAED,sDAAsD;IACtD,gBAAgB,CAAC,SAAkB;QACjC,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;QAC3B,OAAO,IAAI,CAAC;IACd,CAAC;IAED,+BAA+B;IAC/B,KAAK;QACH,OAAO;YACL,SAAS,EAAE,IAAI,CAAC,SAAS;YACzB,UAAU,EAAE,IAAI,CAAC,UAAU;YAC3B,SAAS,EAAE,IAAI,CAAC,SAAS;YACzB,iBAAiB,EAAE,IAAI,CAAC,SAAS;SAClC,CAAC;IACJ,CAAC;CACF"}