accounts 0.10.4 → 0.10.5

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 CHANGED
@@ -1,5 +1,16 @@
1
1
  # accounts
2
2
 
3
+ ## 0.10.5
4
+
5
+ ### Patch Changes
6
+
7
+ - b65893e: Renamed the `dangerous_secp256k1` adapter to `secp256k1`. The old name is preserved as a deprecated alias so existing imports keep working.
8
+
9
+ ```diff
10
+ - import { dangerous_secp256k1 } from 'accounts'
11
+ + import { secp256k1 } from 'accounts'
12
+ ```
13
+
3
14
  ## 0.10.4
4
15
 
5
16
  ### Patch Changes
@@ -70,7 +70,7 @@ export type Instance = {
70
70
  * wallet host's own Provider runs the orchestration instead of racing
71
71
  * the dapp-side Provider for the challenge.
72
72
  *
73
- * Wallet-host adapters (`local`, `webAuthn`, `dangerous_secp256k1`)
73
+ * Wallet-host adapters (`local`, `webAuthn`, `secp256k1`)
74
74
  * leave this unset.
75
75
  */
76
76
  forwardsAuth?: boolean | undefined;
@@ -0,0 +1,45 @@
1
+ import type { Hex } from 'viem';
2
+ import * as Adapter from '../Adapter.js';
3
+ /**
4
+ * Creates a secp256k1 adapter that signs in-process with a `secp256k1` private key.
5
+ *
6
+ * If `privateKey` is provided, the adapter pins that key as the signer (useful
7
+ * for server-side use, where the key is supplied by the host environment).
8
+ *
9
+ * If `privateKey` is omitted, the adapter generates a random key on first
10
+ * connect and persists it via the provider's storage adapter (e.g.
11
+ * `localStorage`, cookies). Storing keys in browser storage in plaintext is
12
+ * dangerous — only use the unpinned form for development, testing, or when the
13
+ * threat model allows it.
14
+ *
15
+ * Wraps the {@link local} adapter.
16
+ *
17
+ * @example
18
+ * ```ts
19
+ * import { secp256k1, Provider } from 'accounts'
20
+ *
21
+ * // Server-side (pinned key):
22
+ * const provider = Provider.create({
23
+ * adapter: secp256k1({ privateKey: process.env.PRIVATE_KEY }),
24
+ * })
25
+ *
26
+ * // Client-side (random key, persisted to storage):
27
+ * const provider = Provider.create({
28
+ * adapter: secp256k1(),
29
+ * })
30
+ * ```
31
+ */
32
+ export declare function secp256k1(options?: secp256k1.Options): Adapter.Adapter;
33
+ export declare namespace secp256k1 {
34
+ type Options = {
35
+ /** Data URI of the provider icon. @default Black 1×1 SVG. */
36
+ icon?: `data:image/${string}` | undefined;
37
+ /** Display name of the provider (e.g. `"My Wallet"`). @default "Injected Wallet" */
38
+ name?: string | undefined;
39
+ /** Fixed private key to expose instead of generating/loading one from storage. */
40
+ privateKey?: Hex | undefined;
41
+ /** Reverse DNS identifier. @default `com.{lowercase name}` */
42
+ rdns?: string | undefined;
43
+ };
44
+ }
45
+ //# sourceMappingURL=secp256k1.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"secp256k1.d.ts","sourceRoot":"","sources":["../../../src/core/adapters/secp256k1.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,MAAM,CAAA;AAG/B,OAAO,KAAK,OAAO,MAAM,eAAe,CAAA;AAGxC;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,wBAAgB,SAAS,CAAC,OAAO,GAAE,SAAS,CAAC,OAAY,GAAG,OAAO,CAAC,OAAO,CA6B1E;AAED,MAAM,CAAC,OAAO,WAAW,SAAS,CAAC;IACjC,KAAK,OAAO,GAAG;QACb,6DAA6D;QAC7D,IAAI,CAAC,EAAE,cAAc,MAAM,EAAE,GAAG,SAAS,CAAA;QACzC,oFAAoF;QACpF,IAAI,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;QACzB,kFAAkF;QAClF,UAAU,CAAC,EAAE,GAAG,GAAG,SAAS,CAAA;QAC5B,8DAA8D;QAC9D,IAAI,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;KAC1B,CAAA;CACF"}
@@ -2,23 +2,35 @@ import { Account as TempoAccount, Secp256k1 } from 'viem/tempo';
2
2
  import * as Adapter from '../Adapter.js';
3
3
  import { local } from './local.js';
4
4
  /**
5
- * Creates a secp256k1 adapter that generates random private keys and persists them to storage.
5
+ * Creates a secp256k1 adapter that signs in-process with a `secp256k1` private key.
6
6
  *
7
- * ⚠️ **Dangerous**: Private keys are stored in plaintext via the provider's storage adapter
8
- * (e.g. localStorage, cookies). Use only for development, testing, or when the threat model allows it.
7
+ * If `privateKey` is provided, the adapter pins that key as the signer (useful
8
+ * for server-side use, where the key is supplied by the host environment).
9
9
  *
10
- * Wraps the {@link local} adapter with automatic key generation.
10
+ * If `privateKey` is omitted, the adapter generates a random key on first
11
+ * connect and persists it via the provider's storage adapter (e.g.
12
+ * `localStorage`, cookies). Storing keys in browser storage in plaintext is
13
+ * dangerous — only use the unpinned form for development, testing, or when the
14
+ * threat model allows it.
15
+ *
16
+ * Wraps the {@link local} adapter.
11
17
  *
12
18
  * @example
13
19
  * ```ts
14
- * import { dangerous_secp256k1, Provider } from 'accounts'
20
+ * import { secp256k1, Provider } from 'accounts'
21
+ *
22
+ * // Server-side (pinned key):
23
+ * const provider = Provider.create({
24
+ * adapter: secp256k1({ privateKey: process.env.PRIVATE_KEY }),
25
+ * })
15
26
  *
27
+ * // Client-side (random key, persisted to storage):
16
28
  * const provider = Provider.create({
17
- * adapter: dangerous_secp256k1(),
29
+ * adapter: secp256k1(),
18
30
  * })
19
31
  * ```
20
32
  */
21
- export function dangerous_secp256k1(options = {}) {
33
+ export function secp256k1(options = {}) {
22
34
  const { icon, name, privateKey, rdns } = options;
23
35
  const fixed = privateKey
24
36
  ? {
@@ -47,4 +59,4 @@ export function dangerous_secp256k1(options = {}) {
47
59
  })(config);
48
60
  });
49
61
  }
50
- //# sourceMappingURL=dangerous_secp256k1.js.map
62
+ //# sourceMappingURL=secp256k1.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"secp256k1.js","sourceRoot":"","sources":["../../../src/core/adapters/secp256k1.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,IAAI,YAAY,EAAE,SAAS,EAAE,MAAM,YAAY,CA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ACF,CAAC,CAAC,MAAM,CAAC,CAAA;IACZ,CAAC,CAAC,CAAA;AACJ,CAAC"}
package/dist/index.d.ts CHANGED
@@ -15,5 +15,7 @@ export { dialog, dialog as tempoWallet } from './core/adapters/dialog.js';
15
15
  export { local } from './core/adapters/local.js';
16
16
  export { turnkey } from './core/adapters/turnkey.js';
17
17
  export { webAuthn } from './core/adapters/webAuthn.js';
18
- export { dangerous_secp256k1 } from './core/adapters/dangerous_secp256k1.js';
18
+ export { secp256k1,
19
+ /** @deprecated Use `secp256k1` instead. */
20
+ secp256k1 as dangerous_secp256k1, } from './core/adapters/secp256k1.js';
19
21
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,oBAAoB,MAAM,gCAAgC,CAAA;AACtE,OAAO,KAAK,MAAM,MAAM,kBAAkB,CAAA;AAC1C,OAAO,KAAK,cAAc,MAAM,0BAA0B,CAAA;AAC1D,OAAO,KAAK,SAAS,MAAM,qBAAqB,CAAA;AAChD,OAAO,KAAK,MAAM,MAAM,kBAAkB,CAAA;AAC1C,OAAO,KAAK,QAAQ,MAAM,oBAAoB,CAAA;AAC9C,OAAO,KAAK,MAAM,MAAM,kBAAkB,CAAA;AAC1C,OAAO,KAAK,MAAM,MAAM,kBAAkB,CAAA;AAC1C,OAAO,KAAK,GAAG,MAAM,mBAAmB,CAAA;AACxC,OAAO,KAAK,KAAK,MAAM,iBAAiB,CAAA;AACxC,OAAO,KAAK,OAAO,MAAM,mBAAmB,CAAA;AAC5C,OAAO,KAAK,YAAY,MAAM,wBAAwB,CAAA;AACtD,OAAO,KAAK,gBAAgB,MAAM,4BAA4B,CAAA;AAC9D,OAAO,EAAE,MAAM,EAAE,MAAM,IAAI,WAAW,EAAE,MAAM,2BAA2B,CAAA;AACzE,OAAO,EAAE,KAAK,EAAE,MAAM,0BAA0B,CAAA;AAChD,OAAO,EAAE,OAAO,EAAE,MAAM,4BAA4B,CAAA;AACpD,OAAO,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAA;AACtD,OAAO,EAAE,mBAAmB,EAAE,MAAM,wCAAwC,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,oBAAoB,MAAM,gCAAgC,CAAA;AACtE,OAAO,KAAK,MAAM,MAAM,kBAAkB,CAAA;AAC1C,OAAO,KAAK,cAAc,MAAM,0BAA0B,CAAA;AAC1D,OAAO,KAAK,SAAS,MAAM,qBAAqB,CAAA;AAChD,OAAO,KAAK,MAAM,MAAM,kBAAkB,CAAA;AAC1C,OAAO,KAAK,QAAQ,MAAM,oBAAoB,CAAA;AAC9C,OAAO,KAAK,MAAM,MAAM,kBAAkB,CAAA;AAC1C,OAAO,KAAK,MAAM,MAAM,kBAAkB,CAAA;AAC1C,OAAO,KAAK,GAAG,MAAM,mBAAmB,CAAA;AACxC,OAAO,KAAK,KAAK,MAAM,iBAAiB,CAAA;AACxC,OAAO,KAAK,OAAO,MAAM,mBAAmB,CAAA;AAC5C,OAAO,KAAK,YAAY,MAAM,wBAAwB,CAAA;AACtD,OAAO,KAAK,gBAAgB,MAAM,4BAA4B,CAAA;AAC9D,OAAO,EAAE,MAAM,EAAE,MAAM,IAAI,WAAW,EAAE,MAAM,2BAA2B,CAAA;AACzE,OAAO,EAAE,KAAK,EAAE,MAAM,0BAA0B,CAAA;AAChD,OAAO,EAAE,OAAO,EAAE,MAAM,4BAA4B,CAAA;AACpD,OAAO,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAA;AACtD,OAAO,EACL,SAAS;AACT,2CAA2C;AAC3C,SAAS,IAAI,mBAAmB,GACjC,MAAM,8BAA8B,CAAA"}
package/dist/index.js CHANGED
@@ -15,5 +15,7 @@ export { dialog, dialog as tempoWallet } from './core/adapters/dialog.js';
15
15
  export { local } from './core/adapters/local.js';
16
16
  export { turnkey } from './core/adapters/turnkey.js';
17
17
  export { webAuthn } from './core/adapters/webAuthn.js';
18
- export { dangerous_secp256k1 } from './core/adapters/dangerous_secp256k1.js';
18
+ export { secp256k1,
19
+ /** @deprecated Use `secp256k1` instead. */
20
+ secp256k1 as dangerous_secp256k1, } from './core/adapters/secp256k1.js';
19
21
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,oBAAoB,MAAM,gCAAgC,CAAA;AACtE,OAAO,KAAK,MAAM,MAAM,kBAAkB,CAAA;AAC1C,OAAO,KAAK,cAAc,MAAM,0BAA0B,CAAA;AAC1D,OAAO,KAAK,SAAS,MAAM,qBAAqB,CAAA;AAChD,OAAO,KAAK,MAAM,MAAM,kBAAkB,CAAA;AAC1C,OAAO,KAAK,QAAQ,MAAM,oBAAoB,CAAA;AAC9C,OAAO,KAAK,MAAM,MAAM,kBAAkB,CAAA;AAC1C,OAAO,KAAK,MAAM,MAAM,kBAAkB,CAAA;AAC1C,OAAO,KAAK,GAAG,MAAM,mBAAmB,CAAA;AACxC,OAAO,KAAK,KAAK,MAAM,iBAAiB,CAAA;AACxC,OAAO,KAAK,OAAO,MAAM,mBAAmB,CAAA;AAC5C,OAAO,KAAK,YAAY,MAAM,wBAAwB,CAAA;AACtD,OAAO,KAAK,gBAAgB,MAAM,4BAA4B,CAAA;AAC9D,OAAO,EAAE,MAAM,EAAE,MAAM,IAAI,WAAW,EAAE,MAAM,2BAA2B,CAAA;AACzE,OAAO,EAAE,KAAK,EAAE,MAAM,0BAA0B,CAAA;AAChD,OAAO,EAAE,OAAO,EAAE,MAAM,4BAA4B,CAAA;AACpD,OAAO,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAA;AACtD,OAAO,EAAE,mBAAmB,EAAE,MAAM,wCAAwC,CAAA"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,oBAAoB,MAAM,gCAAgC,CAAA;AACtE,OAAO,KAAK,MAAM,MAAM,kBAAkB,CAAA;AAC1C,OAAO,KAAK,cAAc,MAAM,0BAA0B,CAAA;AAC1D,OAAO,KAAK,SAAS,MAAM,qBAAqB,CAAA;AAChD,OAAO,KAAK,MAAM,MAAM,kBAAkB,CAAA;AAC1C,OAAO,KAAK,QAAQ,MAAM,oBAAoB,CAAA;AAC9C,OAAO,KAAK,MAAM,MAAM,kBAAkB,CAAA;AAC1C,OAAO,KAAK,MAAM,MAAM,kBAAkB,CAAA;AAC1C,OAAO,KAAK,GAAG,MAAM,mBAAmB,CAAA;AACxC,OAAO,KAAK,KAAK,MAAM,iBAAiB,CAAA;AACxC,OAAO,KAAK,OAAO,MAAM,mBAAmB,CAAA;AAC5C,OAAO,KAAK,YAAY,MAAM,wBAAwB,CAAA;AACtD,OAAO,KAAK,gBAAgB,MAAM,4BAA4B,CAAA;AAC9D,OAAO,EAAE,MAAM,EAAE,MAAM,IAAI,WAAW,EAAE,MAAM,2BAA2B,CAAA;AACzE,OAAO,EAAE,KAAK,EAAE,MAAM,0BAA0B,CAAA;AAChD,OAAO,EAAE,OAAO,EAAE,MAAM,4BAA4B,CAAA;AACpD,OAAO,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAA;AACtD,OAAO,EACL,SAAS;AACT,2CAA2C;AAC3C,SAAS,IAAI,mBAAmB,GACjC,MAAM,8BAA8B,CAAA"}
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "accounts",
3
3
  "description": "Tempo Accounts SDK",
4
4
  "type": "module",
5
- "version": "0.10.4",
5
+ "version": "0.10.5",
6
6
  "dependencies": {
7
7
  "hono": "^4.12.18",
8
8
  "idb-keyval": "^6.2.2",
@@ -132,7 +132,7 @@ export type Instance = {
132
132
  * wallet host's own Provider runs the orchestration instead of racing
133
133
  * the dapp-side Provider for the challenge.
134
134
  *
135
- * Wallet-host adapters (`local`, `webAuthn`, `dangerous_secp256k1`)
135
+ * Wallet-host adapters (`local`, `webAuthn`, `secp256k1`)
136
136
  * leave this unset.
137
137
  */
138
138
  forwardsAuth?: boolean | undefined
@@ -3,14 +3,14 @@ import { describe, expect, test } from 'vp/test'
3
3
  import { accounts, privateKeys } from '../../../test/config.js'
4
4
  import * as Provider from '../Provider.js'
5
5
  import * as Storage from '../Storage.js'
6
- import { dangerous_secp256k1 } from './dangerous_secp256k1.js'
6
+ import { secp256k1 } from './secp256k1.js'
7
7
 
8
- describe('dangerous_secp256k1', () => {
8
+ describe('secp256k1', () => {
9
9
  test('behavior: privateKey option pins the connected account', async () => {
10
10
  const account = accounts[1]!
11
11
  const provider = Provider.create({
12
- adapter: dangerous_secp256k1({ privateKey: privateKeys[1]! }),
13
- storage: Storage.memory({ key: 'dangerous-secp256k1-private-key' }),
12
+ adapter: secp256k1({ privateKey: privateKeys[1]! }),
13
+ storage: Storage.memory({ key: 'secp256k1-private-key' }),
14
14
  })
15
15
 
16
16
  const result = await provider.request({ method: 'wallet_connect' })
@@ -5,23 +5,35 @@ import * as Adapter from '../Adapter.js'
5
5
  import { local } from './local.js'
6
6
 
7
7
  /**
8
- * Creates a secp256k1 adapter that generates random private keys and persists them to storage.
8
+ * Creates a secp256k1 adapter that signs in-process with a `secp256k1` private key.
9
9
  *
10
- * ⚠️ **Dangerous**: Private keys are stored in plaintext via the provider's storage adapter
11
- * (e.g. localStorage, cookies). Use only for development, testing, or when the threat model allows it.
10
+ * If `privateKey` is provided, the adapter pins that key as the signer (useful
11
+ * for server-side use, where the key is supplied by the host environment).
12
12
  *
13
- * Wraps the {@link local} adapter with automatic key generation.
13
+ * If `privateKey` is omitted, the adapter generates a random key on first
14
+ * connect and persists it via the provider's storage adapter (e.g.
15
+ * `localStorage`, cookies). Storing keys in browser storage in plaintext is
16
+ * dangerous — only use the unpinned form for development, testing, or when the
17
+ * threat model allows it.
18
+ *
19
+ * Wraps the {@link local} adapter.
14
20
  *
15
21
  * @example
16
22
  * ```ts
17
- * import { dangerous_secp256k1, Provider } from 'accounts'
23
+ * import { secp256k1, Provider } from 'accounts'
24
+ *
25
+ * // Server-side (pinned key):
26
+ * const provider = Provider.create({
27
+ * adapter: secp256k1({ privateKey: process.env.PRIVATE_KEY }),
28
+ * })
18
29
  *
30
+ * // Client-side (random key, persisted to storage):
19
31
  * const provider = Provider.create({
20
- * adapter: dangerous_secp256k1(),
32
+ * adapter: secp256k1(),
21
33
  * })
22
34
  * ```
23
35
  */
24
- export function dangerous_secp256k1(options: dangerous_secp256k1.Options = {}): Adapter.Adapter {
36
+ export function secp256k1(options: secp256k1.Options = {}): Adapter.Adapter {
25
37
  const { icon, name, privateKey, rdns } = options
26
38
  const fixed = privateKey
27
39
  ? {
@@ -52,7 +64,7 @@ export function dangerous_secp256k1(options: dangerous_secp256k1.Options = {}):
52
64
  })
53
65
  }
54
66
 
55
- export declare namespace dangerous_secp256k1 {
67
+ export declare namespace secp256k1 {
56
68
  type Options = {
57
69
  /** Data URI of the provider icon. @default Black 1×1 SVG. */
58
70
  icon?: `data:image/${string}` | undefined
@@ -292,27 +292,55 @@ declare namespace setup {
292
292
  }
293
293
 
294
294
  function createClient(options: setup.Options = {}) {
295
- const client = {
295
+ type WalletShape = { accounts: { address: string; addressFormat: string }[] }
296
+ const state = {
296
297
  fetchCalls: 0,
297
298
  initCalls: 0,
298
299
  loadCalls: 0,
299
300
  signPayloads: [] as Hex.Hex[],
300
301
  signWith: [] as string[],
301
- wallets: [{ accounts: [{ address, addressFormat: 'ADDRESS_FORMAT_ETHEREUM' }] }],
302
- async fetchWallets() {
303
- client.fetchCalls++
304
- return client.wallets
302
+ wallets: [
303
+ { accounts: [{ address, addressFormat: 'ADDRESS_FORMAT_ETHEREUM' }] },
304
+ ] as WalletShape[],
305
+ }
306
+ const client = {
307
+ get fetchCalls() {
308
+ return state.fetchCalls
305
309
  },
306
- async getSession() {
307
- return options.session === undefined
308
- ? { expiry: Math.floor(Date.now() / 1000) + 60 }
309
- : options.session
310
+ get initCalls() {
311
+ return state.initCalls
312
+ },
313
+ get loadCalls() {
314
+ return state.loadCalls
315
+ },
316
+ set loadCalls(value: number) {
317
+ state.loadCalls = value
310
318
  },
319
+ get signPayloads() {
320
+ return state.signPayloads
321
+ },
322
+ get signWith() {
323
+ return state.signWith
324
+ },
325
+ get wallets() {
326
+ return state.wallets
327
+ },
328
+ set wallets(value: WalletShape[]) {
329
+ state.wallets = value
330
+ },
331
+ fetchWallets: async () => {
332
+ state.fetchCalls++
333
+ return state.wallets as readonly turnkey.Wallet[]
334
+ },
335
+ getSession: async () =>
336
+ options.session === undefined
337
+ ? { expiry: Math.floor(Date.now() / 1000) + 60 }
338
+ : options.session,
311
339
  httpClient: {
312
- async signRawPayload(parameters: turnkey.SignRawPayloadParameters) {
340
+ signRawPayload: async (parameters: turnkey.SignRawPayloadParameters) => {
313
341
  if (options.signError) throw options.signError
314
- client.signPayloads.push(parameters.payload)
315
- client.signWith.push(parameters.signWith)
342
+ state.signPayloads.push(parameters.payload)
343
+ state.signWith.push(parameters.signWith)
316
344
  return {
317
345
  r: Hex.padLeft('0x11', 32),
318
346
  s: Hex.padLeft('0x22', 32),
@@ -320,17 +348,17 @@ function createClient(options: setup.Options = {}) {
320
348
  }
321
349
  },
322
350
  },
323
- init() {
324
- client.initCalls++
351
+ init: () => {
352
+ state.initCalls++
325
353
  },
326
- logout() {},
354
+ logout: () => {},
327
355
  } satisfies turnkey.Client & {
328
356
  fetchCalls: number
329
357
  initCalls: number
330
358
  loadCalls: number
331
359
  signPayloads: Hex.Hex[]
332
360
  signWith: string[]
333
- wallets: turnkey.Wallet[]
361
+ wallets: WalletShape[]
334
362
  }
335
363
 
336
364
  return client
package/src/index.ts CHANGED
@@ -15,4 +15,8 @@ export { dialog, dialog as tempoWallet } from './core/adapters/dialog.js'
15
15
  export { local } from './core/adapters/local.js'
16
16
  export { turnkey } from './core/adapters/turnkey.js'
17
17
  export { webAuthn } from './core/adapters/webAuthn.js'
18
- export { dangerous_secp256k1 } from './core/adapters/dangerous_secp256k1.js'
18
+ export {
19
+ secp256k1,
20
+ /** @deprecated Use `secp256k1` instead. */
21
+ secp256k1 as dangerous_secp256k1,
22
+ } from './core/adapters/secp256k1.js'
@@ -355,7 +355,7 @@ describe('behavior: with feePayer.feeToken', () => {
355
355
  const { transaction } = await fillTransaction(client, {
356
356
  account: userAccount.address,
357
357
  calls: [transferCall()],
358
- feePayer: false,
358
+ feePayer: false as never,
359
359
  feeToken: addresses.alphaUsd as Address,
360
360
  })
361
361
  expect(transaction.feeToken?.toLowerCase()).toBe(addresses.alphaUsd.toLowerCase())
@@ -1,33 +0,0 @@
1
- import type { Hex } from 'viem';
2
- import * as Adapter from '../Adapter.js';
3
- /**
4
- * Creates a secp256k1 adapter that generates random private keys and persists them to storage.
5
- *
6
- * ⚠️ **Dangerous**: Private keys are stored in plaintext via the provider's storage adapter
7
- * (e.g. localStorage, cookies). Use only for development, testing, or when the threat model allows it.
8
- *
9
- * Wraps the {@link local} adapter with automatic key generation.
10
- *
11
- * @example
12
- * ```ts
13
- * import { dangerous_secp256k1, Provider } from 'accounts'
14
- *
15
- * const provider = Provider.create({
16
- * adapter: dangerous_secp256k1(),
17
- * })
18
- * ```
19
- */
20
- export declare function dangerous_secp256k1(options?: dangerous_secp256k1.Options): Adapter.Adapter;
21
- export declare namespace dangerous_secp256k1 {
22
- type Options = {
23
- /** Data URI of the provider icon. @default Black 1×1 SVG. */
24
- icon?: `data:image/${string}` | undefined;
25
- /** Display name of the provider (e.g. `"My Wallet"`). @default "Injected Wallet" */
26
- name?: string | undefined;
27
- /** Fixed private key to expose instead of generating/loading one from storage. */
28
- privateKey?: Hex | undefined;
29
- /** Reverse DNS identifier. @default `com.{lowercase name}` */
30
- rdns?: string | undefined;
31
- };
32
- }
33
- //# sourceMappingURL=dangerous_secp256k1.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"dangerous_secp256k1.d.ts","sourceRoot":"","sources":["../../../src/core/adapters/dangerous_secp256k1.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,MAAM,CAAA;AAG/B,OAAO,KAAK,OAAO,MAAM,eAAe,CAAA;AAGxC;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,mBAAmB,CAAC,OAAO,GAAE,mBAAmB,CAAC,OAAY,GAAG,OAAO,CAAC,OAAO,CA6B9F;AAED,MAAM,CAAC,OAAO,WAAW,mBAAmB,CAAC;IAC3C,KAAK,OAAO,GAAG;QACb,6DAA6D;QAC7D,IAAI,CAAC,EAAE,cAAc,MAAM,EAAE,GAAG,SAAS,CAAA;QACzC,oFAAoF;QACpF,IAAI,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;QACzB,kFAAkF;QAClF,UAAU,CAAC,EAAE,GAAG,GAAG,SAAS,CAAA;QAC5B,8DAA8D;QAC9D,IAAI,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;KAC1B,CAAA;CACF"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"dangerous_secp256k1.js","sourceRoot":"","sources":["../../../src/core/adapters/dangerous_secp256k1.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,IAAI,YAAY,EAAE,SAAS,EAAE,MAAM,YAAY,CAAA;AAE/D,OAAO,KAAK,OAAO,MAAM,eAAe,CAAA;AACxC,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAA;AAElC;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,UAAU,mBAAmB,CAAC,UAAuC,EAAE;IAC3E,MAAM,EAAE,IAAI,EAAE,IAAI,EAAE,UAAU,EAAE,IAAI,EAAE,GAAG,OAAO,CAAA;IAChD,MAAM,KAAK,GAAG,UAAU;QACtB,CAAC,CAAC;YACE,OAAO,EAAE,YAAY,CAAC,aAAa,CAAC,UAAU,CAAC,CAAC,OAAO;YACvD,OAAO,EAAE,WAAoB;YAC7B,UAAU;SACX;QACH,CAAC,CAA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