@metamask-previews/chomp-api-service 6.0.1-preview-cbae429b5 → 6.0.1-preview-66aa9ab6e
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 +24 -0
- package/dist/chomp-api-service-method-action-types.d.ts +90 -13
- package/dist/chomp-api-service-method-action-types.d.ts.map +1 -1
- package/dist/chomp-api-service-method-action-types.js.map +1 -1
- package/dist/chomp-api-service.d.ts +93 -10
- package/dist/chomp-api-service.d.ts.map +1 -1
- package/dist/chomp-api-service.js +268 -25
- package/dist/chomp-api-service.js.map +1 -1
- package/dist/index.d.ts +3 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/types.d.ts +109 -6
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js.map +1 -1
- package/package.json +15 -16
package/CHANGELOG.md
CHANGED
|
@@ -7,6 +7,30 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
7
7
|
|
|
8
8
|
## [Unreleased]
|
|
9
9
|
|
|
10
|
+
### Added
|
|
11
|
+
|
|
12
|
+
- Add `getDerivedIdentities` method, also expose it through the messenger as `ChompApiService:getDerivedIdentities` ([#10695](https://github.com/MetaMask/core/pull/10695))
|
|
13
|
+
- Add `getDerivedIdentityByAddress` method, and expose it through the messenger as `ChompApiService:getDerivedIdentityByAddress` ([#10695](https://github.com/MetaMask/core/pull/10695))
|
|
14
|
+
- Add `disassociateAddress` method for `DELETE /v1/auth/address`, and expose it through the messenger as `ChompApiService:disassociateAddress` ([#10695](https://github.com/MetaMask/core/pull/10695))
|
|
15
|
+
- For an address linked as a successor, this cancels the Money Account migration and unfreezes its predecessor. CHOMP rejects this with `LINK_COMPLETE` once a funds-transfer request exists for the migration.
|
|
16
|
+
- The request is never retried.
|
|
17
|
+
- Add `AddressIdentityResponse`, `DerivedIdentitiesResponse`, `DerivedIdentity`, `DerivedIdentityAddressRole`, `DerivedIdentityMigration`, `DerivedIdentityStatus`, `MigrationStep`, `MigrationStepState`, `MigrationTransfer`, `ChompApiServiceDisassociateAddressAction`, `ChompApiServiceGetDerivedIdentitiesAction`, and `ChompApiServiceGetDerivedIdentityByAddressAction` types ([#10695](https://github.com/MetaMask/core/pull/10695))
|
|
18
|
+
- Add `createAddressChallenge` method for `POST /v2/auth/address/challenge`, and expose it through the messenger as `ChompApiService:createAddressChallenge` ([#10687](https://github.com/MetaMask/core/pull/10687))
|
|
19
|
+
- Returns a single-use SIWE message bound to the profile, chain, purpose and address. The `ASSOCIATE_SUCCESSOR` purpose takes a `predecessorAddress` to link the address as the successor of an existing Money Account.
|
|
20
|
+
- Add `associateAddressV2` method for `POST /v2/auth/address`, and expose it through the messenger as `ChompApiService:associateAddressV2` ([#10687](https://github.com/MetaMask/core/pull/10687))
|
|
21
|
+
- Submits the signed challenge message to associate the address.
|
|
22
|
+
- Add `ChompApiError`, thrown for non-2xx responses, which exposes the CHOMP error code from the response body as `code` ([#10687](https://github.com/MetaMask/core/pull/10687))
|
|
23
|
+
- Add `AssociationPurpose`, `CreateAddressChallengeParams`, `CreateAddressChallengeResponse`, `AssociateAddressV2Params`, `ChompApiServiceCreateAddressChallengeAction`, and `ChompApiServiceAssociateAddressV2Action` types ([#10687](https://github.com/MetaMask/core/pull/10687))
|
|
24
|
+
- Add support for Node.js 26 ([#10981](https://github.com/MetaMask/core/pull/10981))
|
|
25
|
+
|
|
26
|
+
### Changed
|
|
27
|
+
|
|
28
|
+
- Bump `@metamask/utils` from `^12.0.0` to `^12.0.1` ([#11107](https://github.com/MetaMask/core/pull/11107))
|
|
29
|
+
|
|
30
|
+
### Removed
|
|
31
|
+
|
|
32
|
+
- **BREAKING:** Remove the `associateAddress` method and `ChompApiService:associateAddress` messenger action (`POST /v1/auth/address`), along with the `AssociateAddressParams` and `ChompApiServiceAssociateAddressAction` types ([#10687](https://github.com/MetaMask/core/pull/10687))
|
|
33
|
+
|
|
10
34
|
## [6.0.1]
|
|
11
35
|
|
|
12
36
|
### Changed
|
|
@@ -4,20 +4,61 @@
|
|
|
4
4
|
*/
|
|
5
5
|
import type { ChompApiService } from './chomp-api-service.js';
|
|
6
6
|
/**
|
|
7
|
-
*
|
|
7
|
+
* Requests a single-use challenge for associating an address through the v2
|
|
8
|
+
* flow. Sign the returned `message` exactly as received, using
|
|
9
|
+
* `personal_sign` with the address being associated, then submit it with
|
|
10
|
+
* {@link ChompApiService.associateAddressV2} before `expiresAt`. Requesting
|
|
11
|
+
* a new challenge for the same address replaces the previous one.
|
|
8
12
|
*
|
|
9
|
-
* POST /
|
|
13
|
+
* POST /v2/auth/address/challenge
|
|
10
14
|
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
* @
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
|
|
15
|
+
* Each call issues a new challenge, so the result is never cached.
|
|
16
|
+
*
|
|
17
|
+
* @param params - The address to associate and the association purpose.
|
|
18
|
+
* `ASSOCIATE_SUCCESSOR` also requires the predecessor address.
|
|
19
|
+
* @returns The challenge ID, the message to sign, and when it expires.
|
|
20
|
+
*/
|
|
21
|
+
export type ChompApiServiceCreateAddressChallengeAction = {
|
|
22
|
+
type: `ChompApiService:createAddressChallenge`;
|
|
23
|
+
handler: ChompApiService['createAddressChallenge'];
|
|
24
|
+
};
|
|
25
|
+
/**
|
|
26
|
+
* Associates an address with a CHOMP profile by submitting the signature of
|
|
27
|
+
* a challenge from {@link ChompApiService.createAddressChallenge}. The
|
|
28
|
+
* address, purpose and predecessor come from the challenge. For
|
|
29
|
+
* `ASSOCIATE_SUCCESSOR`, the association and the link to the predecessor
|
|
30
|
+
* are written atomically.
|
|
31
|
+
*
|
|
32
|
+
* POST /v2/auth/address
|
|
33
|
+
*
|
|
34
|
+
* @param params - The challenge ID and its signature.
|
|
35
|
+
* @returns The profile association result: `status: 'created'` when the
|
|
36
|
+
* association or link was written, `status: 'active'` when the address was
|
|
37
|
+
* already associated with the authenticated profile. Throws on 400
|
|
38
|
+
* `CHALLENGE_INVALID_OR_EXPIRED` (request a new challenge), on 409 when the
|
|
39
|
+
* address is associated with a different profile, and on link validation
|
|
40
|
+
* errors.
|
|
17
41
|
*/
|
|
18
|
-
export type
|
|
19
|
-
type: `ChompApiService:
|
|
20
|
-
handler: ChompApiService['
|
|
42
|
+
export type ChompApiServiceAssociateAddressV2Action = {
|
|
43
|
+
type: `ChompApiService:associateAddressV2`;
|
|
44
|
+
handler: ChompApiService['associateAddressV2'];
|
|
45
|
+
};
|
|
46
|
+
/**
|
|
47
|
+
* Removes an address association from the authenticated profile.
|
|
48
|
+
* When called with an addresses that is linked as successors it will only succeed
|
|
49
|
+
* if the chomp migration has not yet created a funds-transfer request. Otherwise
|
|
50
|
+
* CHOMP will reject the request with `LINK_COMPLETE`
|
|
51
|
+
*
|
|
52
|
+
* DELETE /v1/auth/address
|
|
53
|
+
*
|
|
54
|
+
* Executed as a mutation so it is never retried: a retry after a lost
|
|
55
|
+
* response would hit an already-removed address and fail with a 404.
|
|
56
|
+
*
|
|
57
|
+
* @param address - The address to disassociate.
|
|
58
|
+
*/
|
|
59
|
+
export type ChompApiServiceDisassociateAddressAction = {
|
|
60
|
+
type: `ChompApiService:disassociateAddress`;
|
|
61
|
+
handler: ChompApiService['disassociateAddress'];
|
|
21
62
|
};
|
|
22
63
|
/**
|
|
23
64
|
* Fetches the addresses associated with the authenticated profile.
|
|
@@ -99,7 +140,8 @@ export type ChompApiServiceCreateIntentsAction = {
|
|
|
99
140
|
* is always fetched fresh (`staleTime: 0`).
|
|
100
141
|
*
|
|
101
142
|
* @param address - The address to look up intents for.
|
|
102
|
-
* @returns The array of intents for the address
|
|
143
|
+
* @returns The array of intents for the address, omitting any with an
|
|
144
|
+
* intent type this service does not recognise.
|
|
103
145
|
*/
|
|
104
146
|
export type ChompApiServiceGetIntentsByAddressAction = {
|
|
105
147
|
type: `ChompApiService:getIntentsByAddress`;
|
|
@@ -132,8 +174,43 @@ export type ChompApiServiceGetServiceDetailsAction = {
|
|
|
132
174
|
type: `ChompApiService:getServiceDetails`;
|
|
133
175
|
handler: ChompApiService['getServiceDetails'];
|
|
134
176
|
};
|
|
177
|
+
/**
|
|
178
|
+
* Fetches the Money Account identities of the authenticated profile, including
|
|
179
|
+
* status and migration steps information. Calling this will start migrations.
|
|
180
|
+
*
|
|
181
|
+
* GET /v1/money-account/identities
|
|
182
|
+
*
|
|
183
|
+
* Profile-scoped and used to drive migrations, so it is always fetched
|
|
184
|
+
* fresh and keyed by a digest of the bearer token, like
|
|
185
|
+
* {@link ChompApiService.getAssociatedAddresses}.
|
|
186
|
+
*
|
|
187
|
+
* @returns The identities; empty when the profile has no Money Account.
|
|
188
|
+
* Addresses are lowercased.
|
|
189
|
+
*/
|
|
190
|
+
export type ChompApiServiceGetDerivedIdentitiesAction = {
|
|
191
|
+
type: `ChompApiService:getDerivedIdentities`;
|
|
192
|
+
handler: ChompApiService['getDerivedIdentities'];
|
|
193
|
+
};
|
|
194
|
+
/**
|
|
195
|
+
* Fetches the identity containing an address, along with where the address
|
|
196
|
+
* sits in it.
|
|
197
|
+
*
|
|
198
|
+
* GET /v1/money-account/identities/address/:address
|
|
199
|
+
*
|
|
200
|
+
* Always fetched fresh and keyed by a digest of the bearer token.
|
|
201
|
+
*
|
|
202
|
+
* @param address - The address to look up.
|
|
203
|
+
* @returns The identity and address details, or `null` when CHOMP responds
|
|
204
|
+
* with `ADDRESS_NOT_ASSOCIATED`
|
|
205
|
+
*
|
|
206
|
+
* Addresses are lowercased.
|
|
207
|
+
*/
|
|
208
|
+
export type ChompApiServiceGetDerivedIdentityByAddressAction = {
|
|
209
|
+
type: `ChompApiService:getDerivedIdentityByAddress`;
|
|
210
|
+
handler: ChompApiService['getDerivedIdentityByAddress'];
|
|
211
|
+
};
|
|
135
212
|
/**
|
|
136
213
|
* Union of all ChompApiService action types.
|
|
137
214
|
*/
|
|
138
|
-
export type ChompApiServiceMethodActions =
|
|
215
|
+
export type ChompApiServiceMethodActions = ChompApiServiceCreateAddressChallengeAction | ChompApiServiceAssociateAddressV2Action | ChompApiServiceDisassociateAddressAction | ChompApiServiceGetAssociatedAddressesAction | ChompApiServiceCreateUpgradeAction | ChompApiServiceGetUpgradesAction | ChompApiServiceVerifyDelegationAction | ChompApiServiceCreateIntentsAction | ChompApiServiceGetIntentsByAddressAction | ChompApiServiceCreateWithdrawalAction | ChompApiServiceGetServiceDetailsAction | ChompApiServiceGetDerivedIdentitiesAction | ChompApiServiceGetDerivedIdentityByAddressAction;
|
|
139
216
|
//# sourceMappingURL=chomp-api-service-method-action-types.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"chomp-api-service-method-action-types.d.ts","sourceRoot":"","sources":["../src/chomp-api-service-method-action-types.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAE9D
|
|
1
|
+
{"version":3,"file":"chomp-api-service-method-action-types.d.ts","sourceRoot":"","sources":["../src/chomp-api-service-method-action-types.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAE9D;;;;;;;;;;;;;;GAcG;AACH,MAAM,MAAM,2CAA2C,GAAG;IACxD,IAAI,EAAE,wCAAwC,CAAC;IAC/C,OAAO,EAAE,eAAe,CAAC,wBAAwB,CAAC,CAAC;CACpD,CAAC;AAEF;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,MAAM,uCAAuC,GAAG;IACpD,IAAI,EAAE,oCAAoC,CAAC;IAC3C,OAAO,EAAE,eAAe,CAAC,oBAAoB,CAAC,CAAC;CAChD,CAAC;AAEF;;;;;;;;;;;;GAYG;AACH,MAAM,MAAM,wCAAwC,GAAG;IACrD,IAAI,EAAE,qCAAqC,CAAC;IAC5C,OAAO,EAAE,eAAe,CAAC,qBAAqB,CAAC,CAAC;CACjD,CAAC;AAEF;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AyC,GAAG;IACtD,IAAI,EAAE,sCAAsC,CAAC;IAC7C,OAAO,EAAE,eAAe,CAAC,sBAAsB,CAAC,CAAC;CAClD,CAAC;AAEF;;;;;;;;;;;;;GAaG;AACH,MAAM,MAAM,gDAAgD,GAAG;IAC7D,IAAI,EAAE,6CAA6C,CAAC;IACpD,OAAO,EAAE,eAAe,CAAC,6BAA6B,CAAC,CAAC;CACzD,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,4BAA4B,GACpC,2CAA2C,GAC3C,uCAAuC,GACvC,wCAAwC,GACxC,2CAA2C,GAC3C,kCAAkC,GAClC,gCAAgC,GAChC,qCAAqC,GACrC,kCAAkC,GAClC,wCAAwC,GACxC,qCAAqC,GACrC,sCAAsC,GACtC,yCAAyC,GACzC,gDAAgD,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"chomp-api-service-method-action-types.js","sourceRoot":"","sources":["../src/chomp-api-service-method-action-types.ts"],"names":[],"mappings":"AAAA;;;GAGG","sourcesContent":["/**\n * This file is auto generated.\n * Do not edit manually.\n */\n\nimport type { ChompApiService } from './chomp-api-service.js';\n\n/**\n *
|
|
1
|
+
{"version":3,"file":"chomp-api-service-method-action-types.js","sourceRoot":"","sources":["../src/chomp-api-service-method-action-types.ts"],"names":[],"mappings":"AAAA;;;GAGG","sourcesContent":["/**\n * This file is auto generated.\n * Do not edit manually.\n */\n\nimport type { ChompApiService } from './chomp-api-service.js';\n\n/**\n * Requests a single-use challenge for associating an address through the v2\n * flow. Sign the returned `message` exactly as received, using\n * `personal_sign` with the address being associated, then submit it with\n * {@link ChompApiService.associateAddressV2} before `expiresAt`. Requesting\n * a new challenge for the same address replaces the previous one.\n *\n * POST /v2/auth/address/challenge\n *\n * Each call issues a new challenge, so the result is never cached.\n *\n * @param params - The address to associate and the association purpose.\n * `ASSOCIATE_SUCCESSOR` also requires the predecessor address.\n * @returns The challenge ID, the message to sign, and when it expires.\n */\nexport type ChompApiServiceCreateAddressChallengeAction = {\n type: `ChompApiService:createAddressChallenge`;\n handler: ChompApiService['createAddressChallenge'];\n};\n\n/**\n * Associates an address with a CHOMP profile by submitting the signature of\n * a challenge from {@link ChompApiService.createAddressChallenge}. The\n * address, purpose and predecessor come from the challenge. For\n * `ASSOCIATE_SUCCESSOR`, the association and the link to the predecessor\n * are written atomically.\n *\n * POST /v2/auth/address\n *\n * @param params - The challenge ID and its signature.\n * @returns The profile association result: `status: 'created'` when the\n * association or link was written, `status: 'active'` when the address was\n * already associated with the authenticated profile. Throws on 400\n * `CHALLENGE_INVALID_OR_EXPIRED` (request a new challenge), on 409 when the\n * address is associated with a different profile, and on link validation\n * errors.\n */\nexport type ChompApiServiceAssociateAddressV2Action = {\n type: `ChompApiService:associateAddressV2`;\n handler: ChompApiService['associateAddressV2'];\n};\n\n/**\n * Removes an address association from the authenticated profile.\n * When called with an addresses that is linked as successors it will only succeed\n * if the chomp migration has not yet created a funds-transfer request. Otherwise\n * CHOMP will reject the request with `LINK_COMPLETE`\n *\n * DELETE /v1/auth/address\n *\n * Executed as a mutation so it is never retried: a retry after a lost\n * response would hit an already-removed address and fail with a 404.\n *\n * @param address - The address to disassociate.\n */\nexport type ChompApiServiceDisassociateAddressAction = {\n type: `ChompApiService:disassociateAddress`;\n handler: ChompApiService['disassociateAddress'];\n};\n\n/**\n * Fetches the addresses associated with the authenticated profile.\n *\n * GET /v1/auth/address\n *\n * The result is scoped to the authenticated profile and consumers use it\n * to decide whether an association already exists, so it is always fetched\n * fresh (`staleTime: 0`) and evicted as soon as the call settles\n * (`gcTime: 0`). The query key carries a SHA-256 digest of the bearer\n * token — the same token the request is made with — so concurrent calls\n * only share an in-flight request when they are for the same profile. The\n * digest, not the token, is used because query keys leave the service via\n * the `cacheUpdated` messenger events.\n *\n * @returns The active address associations; empty array if none exist.\n * Addresses are lowercased.\n */\nexport type ChompApiServiceGetAssociatedAddressesAction = {\n type: `ChompApiService:getAssociatedAddresses`;\n handler: ChompApiService['getAssociatedAddresses'];\n};\n\n/**\n * Creates an account upgrade request.\n *\n * POST /v1/account-upgrade\n *\n * @param params - The upgrade params containing signature components and\n * chain details.\n * @returns The upgrade result.\n */\nexport type ChompApiServiceCreateUpgradeAction = {\n type: `ChompApiService:createUpgrade`;\n handler: ChompApiService['createUpgrade'];\n};\n\n/**\n * Fetches all EIP-7702 upgrade authorizations for a given address (one per\n * chain).\n *\n * GET /v1/account-upgrade/:address\n *\n * @param address - The address to look up.\n * @returns The upgrade entries; empty array if none exist.\n */\nexport type ChompApiServiceGetUpgradesAction = {\n type: `ChompApiService:getUpgrades`;\n handler: ChompApiService['getUpgrades'];\n};\n\n/**\n * Verifies a delegation signature.\n *\n * POST /v1/intent/verify-delegation\n *\n * @param params - The delegation verification params.\n * @returns The verification result including validity and optional errors.\n */\nexport type ChompApiServiceVerifyDelegationAction = {\n type: `ChompApiService:verifyDelegation`;\n handler: ChompApiService['verifyDelegation'];\n};\n\n/**\n * Submits one or more intents to the CHOMP API.\n *\n * POST /v1/intent\n *\n * @param intents - The array of intents to submit.\n * @returns The array of intent responses.\n */\nexport type ChompApiServiceCreateIntentsAction = {\n type: `ChompApiService:createIntents`;\n handler: ChompApiService['createIntents'];\n};\n\n/**\n * Fetches intents associated with a given address.\n *\n * GET /v1/intent/account/:address\n *\n * Callers use the result to decide whether an intent already exists, so it\n * is always fetched fresh (`staleTime: 0`).\n *\n * @param address - The address to look up intents for.\n * @returns The array of intents for the address, omitting any with an\n * intent type this service does not recognise.\n */\nexport type ChompApiServiceGetIntentsByAddressAction = {\n type: `ChompApiService:getIntentsByAddress`;\n handler: ChompApiService['getIntentsByAddress'];\n};\n\n/**\n * Creates a withdrawal for card spend flows.\n *\n * POST /v1/withdrawal\n *\n * @param params - The withdrawal params containing chainId, amount\n * (decimal or hex string), and account address.\n * @returns The withdrawal result.\n */\nexport type ChompApiServiceCreateWithdrawalAction = {\n type: `ChompApiService:createWithdrawal`;\n handler: ChompApiService['createWithdrawal'];\n};\n\n/**\n * Retrieves service details including delegation redeemer addresses and DeFi\n * contract details for signing delegations for auto-deposit functionality.\n *\n * GET /v1/chomp\n *\n * @param chainIds - Array of chain IDs (0x-prefixed hex strings) to retrieve\n * details for.\n * @returns The service details for the requested chains.\n */\nexport type ChompApiServiceGetServiceDetailsAction = {\n type: `ChompApiService:getServiceDetails`;\n handler: ChompApiService['getServiceDetails'];\n};\n\n/**\n * Fetches the Money Account identities of the authenticated profile, including\n * status and migration steps information. Calling this will start migrations.\n *\n * GET /v1/money-account/identities\n *\n * Profile-scoped and used to drive migrations, so it is always fetched\n * fresh and keyed by a digest of the bearer token, like\n * {@link ChompApiService.getAssociatedAddresses}.\n *\n * @returns The identities; empty when the profile has no Money Account.\n * Addresses are lowercased.\n */\nexport type ChompApiServiceGetDerivedIdentitiesAction = {\n type: `ChompApiService:getDerivedIdentities`;\n handler: ChompApiService['getDerivedIdentities'];\n};\n\n/**\n * Fetches the identity containing an address, along with where the address\n * sits in it.\n *\n * GET /v1/money-account/identities/address/:address\n *\n * Always fetched fresh and keyed by a digest of the bearer token.\n *\n * @param address - The address to look up.\n * @returns The identity and address details, or `null` when CHOMP responds\n * with `ADDRESS_NOT_ASSOCIATED`\n *\n * Addresses are lowercased.\n */\nexport type ChompApiServiceGetDerivedIdentityByAddressAction = {\n type: `ChompApiService:getDerivedIdentityByAddress`;\n handler: ChompApiService['getDerivedIdentityByAddress'];\n};\n\n/**\n * Union of all ChompApiService action types.\n */\nexport type ChompApiServiceMethodActions =\n | ChompApiServiceCreateAddressChallengeAction\n | ChompApiServiceAssociateAddressV2Action\n | ChompApiServiceDisassociateAddressAction\n | ChompApiServiceGetAssociatedAddressesAction\n | ChompApiServiceCreateUpgradeAction\n | ChompApiServiceGetUpgradesAction\n | ChompApiServiceVerifyDelegationAction\n | ChompApiServiceCreateIntentsAction\n | ChompApiServiceGetIntentsByAddressAction\n | ChompApiServiceCreateWithdrawalAction\n | ChompApiServiceGetServiceDetailsAction\n | ChompApiServiceGetDerivedIdentitiesAction\n | ChompApiServiceGetDerivedIdentityByAddressAction;\n"]}
|
|
@@ -1,16 +1,35 @@
|
|
|
1
1
|
import { BaseDataService } from '@metamask/base-data-service';
|
|
2
2
|
import type { DataServiceCacheUpdatedEvent, DataServiceGranularCacheUpdatedEvent, DataServiceInvalidateQueriesAction } from '@metamask/base-data-service';
|
|
3
3
|
import type { CreateServicePolicyOptions } from '@metamask/controller-utils';
|
|
4
|
+
import { HttpError } from '@metamask/controller-utils';
|
|
4
5
|
import type { Messenger } from '@metamask/messenger';
|
|
5
6
|
import type { Hex } from '@metamask/utils';
|
|
6
7
|
import type { QueryClientConfig } from '@tanstack/query-core';
|
|
7
8
|
import type { ChompApiServiceMethodActions } from './chomp-api-service-method-action-types.js';
|
|
8
|
-
import type {
|
|
9
|
+
import type { AddressIdentityResponse, AssociateAddressResponse, AssociateAddressV2Params, CreateAddressChallengeParams, CreateAddressChallengeResponse, ProfileAddressEntry, CreateUpgradeParams, CreateUpgradeResponse, UpgradeEntry, CreateWithdrawalParams, CreateWithdrawalResponse, DerivedIdentitiesResponse, IntentEntry, SendIntentParams, SendIntentResponse, ServiceDetailsResponse, VerifyDelegationParams, VerifyDelegationResponse } from './types.js';
|
|
9
10
|
/**
|
|
10
11
|
* The name of the {@link ChompApiService}, used to namespace the service's
|
|
11
12
|
* actions and events.
|
|
12
13
|
*/
|
|
13
14
|
export declare const serviceName = "ChompApiService";
|
|
15
|
+
/**
|
|
16
|
+
* Thrown when the CHOMP API responds with a non-2xx status.
|
|
17
|
+
*/
|
|
18
|
+
export declare class ChompApiError extends HttpError {
|
|
19
|
+
/**
|
|
20
|
+
* The CHOMP error code from the response body (e.g.
|
|
21
|
+
* `PREDECESSOR_HAS_OPEN_WITHDRAWALS`), if one was provided.
|
|
22
|
+
*/
|
|
23
|
+
readonly code: string | undefined;
|
|
24
|
+
/**
|
|
25
|
+
* Construct a CHOMP API error.
|
|
26
|
+
*
|
|
27
|
+
* @param status - The HTTP response status.
|
|
28
|
+
* @param message - The error message.
|
|
29
|
+
* @param code - The CHOMP error code from the response body.
|
|
30
|
+
*/
|
|
31
|
+
constructor(status: number, message: string, code?: string);
|
|
32
|
+
}
|
|
14
33
|
/**
|
|
15
34
|
* Invalidates cached queries for {@link ChompApiService}.
|
|
16
35
|
*/
|
|
@@ -72,18 +91,53 @@ export declare class ChompApiService extends BaseDataService<typeof serviceName,
|
|
|
72
91
|
policyOptions?: CreateServicePolicyOptions;
|
|
73
92
|
});
|
|
74
93
|
/**
|
|
75
|
-
*
|
|
94
|
+
* Requests a single-use challenge for associating an address through the v2
|
|
95
|
+
* flow. Sign the returned `message` exactly as received, using
|
|
96
|
+
* `personal_sign` with the address being associated, then submit it with
|
|
97
|
+
* {@link ChompApiService.associateAddressV2} before `expiresAt`. Requesting
|
|
98
|
+
* a new challenge for the same address replaces the previous one.
|
|
99
|
+
*
|
|
100
|
+
* POST /v2/auth/address/challenge
|
|
101
|
+
*
|
|
102
|
+
* Each call issues a new challenge, so the result is never cached.
|
|
103
|
+
*
|
|
104
|
+
* @param params - The address to associate and the association purpose.
|
|
105
|
+
* `ASSOCIATE_SUCCESSOR` also requires the predecessor address.
|
|
106
|
+
* @returns The challenge ID, the message to sign, and when it expires.
|
|
107
|
+
*/
|
|
108
|
+
createAddressChallenge(params: CreateAddressChallengeParams): Promise<CreateAddressChallengeResponse>;
|
|
109
|
+
/**
|
|
110
|
+
* Associates an address with a CHOMP profile by submitting the signature of
|
|
111
|
+
* a challenge from {@link ChompApiService.createAddressChallenge}. The
|
|
112
|
+
* address, purpose and predecessor come from the challenge. For
|
|
113
|
+
* `ASSOCIATE_SUCCESSOR`, the association and the link to the predecessor
|
|
114
|
+
* are written atomically.
|
|
115
|
+
*
|
|
116
|
+
* POST /v2/auth/address
|
|
117
|
+
*
|
|
118
|
+
* @param params - The challenge ID and its signature.
|
|
119
|
+
* @returns The profile association result: `status: 'created'` when the
|
|
120
|
+
* association or link was written, `status: 'active'` when the address was
|
|
121
|
+
* already associated with the authenticated profile. Throws on 400
|
|
122
|
+
* `CHALLENGE_INVALID_OR_EXPIRED` (request a new challenge), on 409 when the
|
|
123
|
+
* address is associated with a different profile, and on link validation
|
|
124
|
+
* errors.
|
|
125
|
+
*/
|
|
126
|
+
associateAddressV2(params: AssociateAddressV2Params): Promise<AssociateAddressResponse>;
|
|
127
|
+
/**
|
|
128
|
+
* Removes an address association from the authenticated profile.
|
|
129
|
+
* When called with an addresses that is linked as successors it will only succeed
|
|
130
|
+
* if the chomp migration has not yet created a funds-transfer request. Otherwise
|
|
131
|
+
* CHOMP will reject the request with `LINK_COMPLETE`
|
|
132
|
+
*
|
|
133
|
+
* DELETE /v1/auth/address
|
|
76
134
|
*
|
|
77
|
-
*
|
|
135
|
+
* Executed as a mutation so it is never retried: a retry after a lost
|
|
136
|
+
* response would hit an already-removed address and fail with a 404.
|
|
78
137
|
*
|
|
79
|
-
* @param
|
|
80
|
-
* and address.
|
|
81
|
-
* @returns The profile association result: `status: 'created'` for a new
|
|
82
|
-
* association, `status: 'active'` when the address was already associated
|
|
83
|
-
* with the authenticated profile. Throws on 409, which indicates the
|
|
84
|
-
* address is associated with a different profile.
|
|
138
|
+
* @param address - The address to disassociate.
|
|
85
139
|
*/
|
|
86
|
-
|
|
140
|
+
disassociateAddress(address: Hex): Promise<void>;
|
|
87
141
|
/**
|
|
88
142
|
* Fetches the addresses associated with the authenticated profile.
|
|
89
143
|
*
|
|
@@ -174,6 +228,35 @@ export declare class ChompApiService extends BaseDataService<typeof serviceName,
|
|
|
174
228
|
* @returns The service details for the requested chains.
|
|
175
229
|
*/
|
|
176
230
|
getServiceDetails(chainIds: Hex[]): Promise<ServiceDetailsResponse>;
|
|
231
|
+
/**
|
|
232
|
+
* Fetches the Money Account identities of the authenticated profile, including
|
|
233
|
+
* status and migration steps information. Calling this will start migrations.
|
|
234
|
+
*
|
|
235
|
+
* GET /v1/money-account/identities
|
|
236
|
+
*
|
|
237
|
+
* Profile-scoped and used to drive migrations, so it is always fetched
|
|
238
|
+
* fresh and keyed by a digest of the bearer token, like
|
|
239
|
+
* {@link ChompApiService.getAssociatedAddresses}.
|
|
240
|
+
*
|
|
241
|
+
* @returns The identities; empty when the profile has no Money Account.
|
|
242
|
+
* Addresses are lowercased.
|
|
243
|
+
*/
|
|
244
|
+
getDerivedIdentities(): Promise<DerivedIdentitiesResponse>;
|
|
245
|
+
/**
|
|
246
|
+
* Fetches the identity containing an address, along with where the address
|
|
247
|
+
* sits in it.
|
|
248
|
+
*
|
|
249
|
+
* GET /v1/money-account/identities/address/:address
|
|
250
|
+
*
|
|
251
|
+
* Always fetched fresh and keyed by a digest of the bearer token.
|
|
252
|
+
*
|
|
253
|
+
* @param address - The address to look up.
|
|
254
|
+
* @returns The identity and address details, or `null` when CHOMP responds
|
|
255
|
+
* with `ADDRESS_NOT_ASSOCIATED`
|
|
256
|
+
*
|
|
257
|
+
* Addresses are lowercased.
|
|
258
|
+
*/
|
|
259
|
+
getDerivedIdentityByAddress(address: Hex): Promise<AddressIdentityResponse | null>;
|
|
177
260
|
}
|
|
178
261
|
export {};
|
|
179
262
|
//# sourceMappingURL=chomp-api-service.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"chomp-api-service.d.ts","sourceRoot":"","sources":["../src/chomp-api-service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAC;AAC9D,OAAO,KAAK,EACV,4BAA4B,EAC5B,oCAAoC,EACpC,kCAAkC,EACnC,MAAM,6BAA6B,CAAC;AACrC,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,4BAA4B,CAAC;
|
|
1
|
+
{"version":3,"file":"chomp-api-service.d.ts","sourceRoot":"","sources":["../src/chomp-api-service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAC;AAC9D,OAAO,KAAK,EACV,4BAA4B,EAC5B,oCAAoC,EACpC,kCAAkC,EACnC,MAAM,6BAA6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