mppx 0.6.21 → 0.6.22

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.
@@ -1 +1 @@
1
- {"version":3,"file":"html.gen.js","sourceRoot":"","sources":["../../../../src/tempo/server/internal/html.gen.ts"],"names":[],"mappings":"AAAA,2BAA2B;AAC3B,MAAM,CAAC,MAAM,IAAI,GAAG,s+teAAs+te,CAAA"}
1
+ {"version":3,"file":"html.gen.js","sourceRoot":"","sources":["../../../../src/tempo/server/internal/html.gen.ts"],"names":[],"mappings":"AAAA,2BAA2B;AAC3B,MAAM,CAAC,MAAM,IAAI,GAAG,8yteAA8yte,CAAA"}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "mppx",
3
3
  "type": "module",
4
- "version": "0.6.21",
4
+ "version": "0.6.22",
5
5
  "main": "./dist/index.js",
6
6
  "license": "MIT",
7
7
  "files": [
@@ -104,6 +104,57 @@ describe('tempo.subscription client', () => {
104
104
  )
105
105
  })
106
106
 
107
+ test('passes hex-encoded `scopes` and `limits` to wallet_authorizeAccessKey', async () => {
108
+ const challenge = createChallenge()
109
+ const keyAuthorization = await signSubscriptionKeyAuthorization({
110
+ accessKey,
111
+ account: selectedAccount,
112
+ chainId,
113
+ request: challenge.request,
114
+ })
115
+ if (!keyAuthorization) throw new Error('expected key authorization')
116
+
117
+ let capturedParams: Record<string, unknown> | undefined
118
+ const method = subscription({
119
+ account: selectedAccount.address,
120
+ getClient: async () =>
121
+ ({
122
+ request: async ({ params }: { params: readonly Record<string, unknown>[] }) => {
123
+ capturedParams = params[0]
124
+ return { keyAuthorization: KeyAuthorization.toRpc(keyAuthorization) }
125
+ },
126
+ }) as never,
127
+ })
128
+
129
+ await method.createCredential({ challenge, context: {} })
130
+
131
+ expect(capturedParams).toMatchObject({
132
+ address: accessKey.accessKeyAddress.toLowerCase(),
133
+ keyType: accessKey.keyType,
134
+ expiry: expect.any(Number),
135
+ limits: [
136
+ {
137
+ token: expect.stringMatching(/^0x[0-9a-fA-F]{40}$/),
138
+ limit: '0xf4240',
139
+ period: expect.any(Number),
140
+ },
141
+ ],
142
+ scopes: [
143
+ {
144
+ address: expect.stringMatching(/^0x[0-9a-fA-F]{40}$/),
145
+ selector: expect.stringMatching(/^0x/),
146
+ recipients: expect.any(Array),
147
+ },
148
+ {
149
+ address: expect.stringMatching(/^0x[0-9a-fA-F]{40}$/),
150
+ selector: expect.stringMatching(/^0x/),
151
+ recipients: expect.any(Array),
152
+ },
153
+ ],
154
+ })
155
+ expect(capturedParams).not.toHaveProperty('allowedCalls')
156
+ })
157
+
107
158
  test('rejects key authorizations signed by a different account', async () => {
108
159
  const challenge = createChallenge()
109
160
  const keyAuthorization = await signSubscriptionKeyAuthorization({
@@ -1,3 +1,4 @@
1
+ import { Hex } from 'ox'
1
2
  import { KeyAuthorization } from 'ox/tempo'
2
3
  import { isAddressEqual, type Address } from 'viem'
3
4
  import { tempo as tempo_chain } from 'viem/chains'
@@ -11,7 +12,7 @@ import * as z from '../../zod.js'
11
12
  import * as defaults from '../internal/defaults.js'
12
13
  import * as Methods from '../Methods.js'
13
14
  import {
14
- getSubscriptionRpcAllowedCalls,
15
+ getSubscriptionScopes,
15
16
  signSubscriptionKeyAuthorization,
16
17
  toSubscriptionExpiryDate,
17
18
  toSubscriptionExpirySeconds,
@@ -117,16 +118,16 @@ async function authorizeAccessKey(
117
118
  params: [
118
119
  {
119
120
  address: accessKey.accessKeyAddress,
120
- allowedCalls: getSubscriptionRpcAllowedCalls(request),
121
121
  expiry: toSubscriptionExpirySeconds(toSubscriptionExpiryDate(request.subscriptionExpires)),
122
122
  keyType: accessKey.keyType,
123
123
  limits: [
124
124
  {
125
125
  token: request.currency as Address,
126
- limit: BigInt(request.amount),
126
+ limit: Hex.fromNumber(BigInt(request.amount)),
127
127
  period: toSubscriptionPeriodSeconds(request),
128
128
  },
129
129
  ],
130
+ scopes: getSubscriptionScopes(request),
130
131
  },
131
132
  ],
132
133
  } as never)) as {