@metamask-previews/authenticated-user-storage 3.0.2-preview-b13d916 → 3.0.2-preview-4f4c98e

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 (64) hide show
  1. package/CHANGELOG.md +1 -0
  2. package/dist/{authenticated-user-storage-method-action-types.d.mts → authenticated-user-storage-method-action-types.d.ts} +2 -2
  3. package/dist/authenticated-user-storage-method-action-types.d.ts.map +1 -0
  4. package/dist/{authenticated-user-storage-method-action-types.mjs → authenticated-user-storage-method-action-types.js} +1 -1
  5. package/dist/authenticated-user-storage-method-action-types.js.map +1 -0
  6. package/dist/{authenticated-user-storage.d.cts → authenticated-user-storage.d.ts} +8 -8
  7. package/dist/authenticated-user-storage.d.ts.map +1 -0
  8. package/dist/{authenticated-user-storage.mjs → authenticated-user-storage.js} +5 -5
  9. package/dist/authenticated-user-storage.js.map +1 -0
  10. package/dist/{env.d.cts → env.d.ts} +1 -1
  11. package/dist/env.d.ts.map +1 -0
  12. package/dist/{env.mjs → env.js} +1 -1
  13. package/dist/env.js.map +1 -0
  14. package/dist/{index.d.cts → index.d.ts} +8 -8
  15. package/dist/index.d.ts.map +1 -0
  16. package/dist/index.js +4 -0
  17. package/dist/index.js.map +1 -0
  18. package/dist/{types.d.cts → types.d.ts} +3 -3
  19. package/dist/types.d.ts.map +1 -0
  20. package/dist/types.js +2 -0
  21. package/dist/types.js.map +1 -0
  22. package/dist/{validators.d.cts → validators.d.ts} +3 -3
  23. package/dist/validators.d.ts.map +1 -0
  24. package/dist/{validators.mjs → validators.js} +2 -2
  25. package/dist/validators.js.map +1 -0
  26. package/package.json +14 -18
  27. package/dist/authenticated-user-storage-method-action-types.cjs +0 -7
  28. package/dist/authenticated-user-storage-method-action-types.cjs.map +0 -1
  29. package/dist/authenticated-user-storage-method-action-types.d.cts +0 -83
  30. package/dist/authenticated-user-storage-method-action-types.d.cts.map +0 -1
  31. package/dist/authenticated-user-storage-method-action-types.d.mts.map +0 -1
  32. package/dist/authenticated-user-storage-method-action-types.mjs.map +0 -1
  33. package/dist/authenticated-user-storage.cjs +0 -282
  34. package/dist/authenticated-user-storage.cjs.map +0 -1
  35. package/dist/authenticated-user-storage.d.cts.map +0 -1
  36. package/dist/authenticated-user-storage.d.mts +0 -142
  37. package/dist/authenticated-user-storage.d.mts.map +0 -1
  38. package/dist/authenticated-user-storage.mjs.map +0 -1
  39. package/dist/env.cjs +0 -24
  40. package/dist/env.cjs.map +0 -1
  41. package/dist/env.d.cts.map +0 -1
  42. package/dist/env.d.mts +0 -10
  43. package/dist/env.d.mts.map +0 -1
  44. package/dist/env.mjs.map +0 -1
  45. package/dist/index.cjs +0 -13
  46. package/dist/index.cjs.map +0 -1
  47. package/dist/index.d.cts.map +0 -1
  48. package/dist/index.d.mts +0 -8
  49. package/dist/index.d.mts.map +0 -1
  50. package/dist/index.mjs +0 -4
  51. package/dist/index.mjs.map +0 -1
  52. package/dist/types.cjs +0 -3
  53. package/dist/types.cjs.map +0 -1
  54. package/dist/types.d.cts.map +0 -1
  55. package/dist/types.d.mts +0 -107
  56. package/dist/types.d.mts.map +0 -1
  57. package/dist/types.mjs +0 -2
  58. package/dist/types.mjs.map +0 -1
  59. package/dist/validators.cjs +0 -173
  60. package/dist/validators.cjs.map +0 -1
  61. package/dist/validators.d.cts.map +0 -1
  62. package/dist/validators.d.mts +0 -84
  63. package/dist/validators.d.mts.map +0 -1
  64. package/dist/validators.mjs.map +0 -1
@@ -1,282 +0,0 @@
1
- "use strict";
2
- var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
3
- if (kind === "m") throw new TypeError("Private method is not writable");
4
- if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
5
- if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
6
- return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
7
- };
8
- var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
9
- if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
10
- if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
11
- return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
12
- };
13
- var _AuthenticatedUserStorageService_instances, _AuthenticatedUserStorageService_environment, _AuthenticatedUserStorageService_getHeaders;
14
- Object.defineProperty(exports, "__esModule", { value: true });
15
- exports.AuthenticatedUserStorageService = exports.getAuthenticatedStorageUrl = exports.serviceName = void 0;
16
- const base_data_service_1 = require("@metamask/base-data-service");
17
- const controller_utils_1 = require("@metamask/controller-utils");
18
- const env_js_1 = require("./env.cjs");
19
- const validators_js_1 = require("./validators.cjs");
20
- // === GENERAL ===
21
- /**
22
- * The name of the {@link AuthenticatedUserStorageService} service, used to
23
- * namespace the service's actions and events.
24
- */
25
- exports.serviceName = 'AuthenticatedUserStorageService';
26
- /**
27
- * Builds the versioned API base URL for a given environment.
28
- *
29
- * @param environment - The target environment.
30
- * @returns The base URL including the `/api/v1` path segment.
31
- */
32
- function getAuthenticatedStorageUrl(environment) {
33
- return `${(0, env_js_1.getUserStorageApiUrl)(environment)}/api/v1`;
34
- }
35
- exports.getAuthenticatedStorageUrl = getAuthenticatedStorageUrl;
36
- // === MESSENGER ===
37
- const MESSENGER_EXPOSED_METHODS = [
38
- 'listDelegations',
39
- 'createDelegation',
40
- 'revokeDelegation',
41
- 'getNotificationPreferences',
42
- 'putNotificationPreferences',
43
- 'getAssetsWatchlist',
44
- 'setAssetsWatchlist',
45
- ];
46
- // === SERVICE ===
47
- /**
48
- * Data service wrapping authenticated user-storage API endpoints.
49
- *
50
- * Provides methods for managing delegations and notification preferences
51
- * for the authenticated user.
52
- */
53
- class AuthenticatedUserStorageService extends base_data_service_1.BaseDataService {
54
- /**
55
- * Constructs a new AuthenticatedUserStorageService.
56
- *
57
- * @param args - The constructor arguments.
58
- * @param args.messenger - The messenger suited for this service.
59
- * @param args.environment - The target environment (dev, uat, prod).
60
- * @param args.policyOptions - Options to pass to `createServicePolicy`, which
61
- * is used to wrap each request. See {@link CreateServicePolicyOptions}.
62
- */
63
- constructor({ messenger, environment, policyOptions, }) {
64
- super({ name: exports.serviceName, messenger, policyOptions });
65
- _AuthenticatedUserStorageService_instances.add(this);
66
- _AuthenticatedUserStorageService_environment.set(this, void 0);
67
- __classPrivateFieldSet(this, _AuthenticatedUserStorageService_environment, environment, "f");
68
- this.messenger.registerMethodActionHandlers(this, MESSENGER_EXPOSED_METHODS);
69
- }
70
- /**
71
- * Returns all delegation records belonging to the authenticated user.
72
- *
73
- * @returns An array of delegation records, or an empty array if none exist.
74
- */
75
- async listDelegations() {
76
- const url = `${getAuthenticatedStorageUrl(__classPrivateFieldGet(this, _AuthenticatedUserStorageService_environment, "f"))}/delegations`;
77
- const data = await this.fetchQuery({
78
- queryKey: [`${this.name}:listDelegations`],
79
- queryFn: async () => {
80
- const headers = await __classPrivateFieldGet(this, _AuthenticatedUserStorageService_instances, "m", _AuthenticatedUserStorageService_getHeaders).call(this);
81
- const response = await fetch(url, { headers });
82
- if (!response.ok) {
83
- throw new controller_utils_1.HttpError(response.status, `Failed to list delegations: ${response.status}`);
84
- }
85
- return response.json();
86
- },
87
- });
88
- (0, validators_js_1.assertDelegationResponseArray)(data);
89
- return data;
90
- }
91
- /**
92
- * Stores a signed delegation record for the authenticated user.
93
- *
94
- * @param submission - The signed delegation and its metadata.
95
- * @param clientType - Optional client type header.
96
- */
97
- async createDelegation(submission, clientType) {
98
- const url = `${getAuthenticatedStorageUrl(__classPrivateFieldGet(this, _AuthenticatedUserStorageService_environment, "f"))}/delegations`;
99
- await this.fetchQuery({
100
- queryKey: [
101
- `${this.name}:createDelegation`,
102
- submission.metadata.delegationHash,
103
- ],
104
- staleTime: 0,
105
- queryFn: async () => {
106
- const headers = await __classPrivateFieldGet(this, _AuthenticatedUserStorageService_instances, "m", _AuthenticatedUserStorageService_getHeaders).call(this, clientType);
107
- const response = await fetch(url, {
108
- method: 'POST',
109
- headers,
110
- body: JSON.stringify(submission),
111
- });
112
- if (!response.ok) {
113
- throw new controller_utils_1.HttpError(response.status, `Failed to create delegation: ${response.status}`);
114
- }
115
- return null;
116
- },
117
- });
118
- await this.invalidateQueries({
119
- queryKey: [`${this.name}:listDelegations`],
120
- });
121
- }
122
- /**
123
- * Revokes (deletes) a delegation record.
124
- *
125
- * @param delegationHash - The unique hash identifying the delegation.
126
- */
127
- async revokeDelegation(delegationHash) {
128
- const url = `${getAuthenticatedStorageUrl(__classPrivateFieldGet(this, _AuthenticatedUserStorageService_environment, "f"))}/delegations/${encodeURIComponent(delegationHash)}`;
129
- await this.fetchQuery({
130
- queryKey: [`${this.name}:revokeDelegation`, delegationHash],
131
- staleTime: 0,
132
- queryFn: async () => {
133
- const headers = await __classPrivateFieldGet(this, _AuthenticatedUserStorageService_instances, "m", _AuthenticatedUserStorageService_getHeaders).call(this);
134
- const response = await fetch(url, {
135
- method: 'DELETE',
136
- headers,
137
- });
138
- if (!response.ok) {
139
- throw new controller_utils_1.HttpError(response.status, `Failed to revoke delegation: ${response.status}`);
140
- }
141
- return null;
142
- },
143
- });
144
- await this.invalidateQueries({
145
- queryKey: [`${this.name}:listDelegations`],
146
- });
147
- }
148
- /**
149
- * Returns the notification preferences for the authenticated user.
150
- *
151
- * @returns The notification preferences object, or `null` if none have been
152
- * set (404).
153
- */
154
- async getNotificationPreferences() {
155
- const url = `${getAuthenticatedStorageUrl(__classPrivateFieldGet(this, _AuthenticatedUserStorageService_environment, "f"))}/preferences/notifications`;
156
- const data = await this.fetchQuery({
157
- queryKey: [`${this.name}:getNotificationPreferences`],
158
- queryFn: async () => {
159
- const headers = await __classPrivateFieldGet(this, _AuthenticatedUserStorageService_instances, "m", _AuthenticatedUserStorageService_getHeaders).call(this);
160
- const response = await fetch(url, { headers });
161
- if (response.status === 404) {
162
- return null;
163
- }
164
- if (!response.ok) {
165
- throw new controller_utils_1.HttpError(response.status, `Failed to get notification preferences: ${response.status}`);
166
- }
167
- return response.json();
168
- },
169
- });
170
- if (data === null) {
171
- return null;
172
- }
173
- (0, validators_js_1.assertNotificationPreferences)(data);
174
- return data;
175
- }
176
- /**
177
- * Creates or updates the notification preferences for the authenticated user.
178
- *
179
- * @param prefs - The full notification preferences object.
180
- * @param clientType - Optional client type header.
181
- */
182
- async putNotificationPreferences(prefs, clientType) {
183
- const url = `${getAuthenticatedStorageUrl(__classPrivateFieldGet(this, _AuthenticatedUserStorageService_environment, "f"))}/preferences/notifications`;
184
- await this.fetchQuery({
185
- queryKey: [
186
- `${this.name}:putNotificationPreferences`,
187
- prefs,
188
- ],
189
- staleTime: 0,
190
- queryFn: async () => {
191
- const headers = await __classPrivateFieldGet(this, _AuthenticatedUserStorageService_instances, "m", _AuthenticatedUserStorageService_getHeaders).call(this, clientType);
192
- const response = await fetch(url, {
193
- method: 'PUT',
194
- headers,
195
- body: JSON.stringify(prefs),
196
- });
197
- if (!response.ok) {
198
- throw new controller_utils_1.HttpError(response.status, `Failed to put notification preferences: ${response.status}`);
199
- }
200
- return null;
201
- },
202
- });
203
- await this.invalidateQueries({
204
- queryKey: [`${this.name}:getNotificationPreferences`],
205
- });
206
- }
207
- /**
208
- * Returns the assets-watchlist for the authenticated user.
209
- *
210
- * @returns The assets-watchlist blob, or `null` if none has been set (404).
211
- */
212
- async getAssetsWatchlist() {
213
- const url = `${getAuthenticatedStorageUrl(__classPrivateFieldGet(this, _AuthenticatedUserStorageService_environment, "f"))}/preferences/assets-watchlist`;
214
- const data = await this.fetchQuery({
215
- queryKey: [`${this.name}:getAssetsWatchlist`],
216
- queryFn: async () => {
217
- const headers = await __classPrivateFieldGet(this, _AuthenticatedUserStorageService_instances, "m", _AuthenticatedUserStorageService_getHeaders).call(this);
218
- const response = await fetch(url, { headers });
219
- if (response.status === 404) {
220
- return null;
221
- }
222
- if (!response.ok) {
223
- throw new controller_utils_1.HttpError(response.status, `Failed to get assets watchlist: ${response.status}`);
224
- }
225
- return response.json();
226
- },
227
- });
228
- if (data === null) {
229
- return null;
230
- }
231
- (0, validators_js_1.assertAssetsWatchlistBlob)(data);
232
- return data;
233
- }
234
- /**
235
- * Creates or updates the assets-watchlist for the authenticated user.
236
- *
237
- * @param blob - The full assets-watchlist blob. The `assets` array may
238
- * contain at most `ASSETS_WATCHLIST_MAX_ASSETS` CAIP-19 asset identifiers;
239
- * this is enforced by `assertAssetsWatchlistBlobForWrite` before the
240
- * request is sent.
241
- * @param clientType - Optional client type header.
242
- * @throws A `StructError` from `@metamask/superstruct` if `blob` is
243
- * structurally invalid or `assets` exceeds the cap; an `HttpError` from
244
- * `@metamask/controller-utils` if the API responds with a non-2xx status.
245
- */
246
- async setAssetsWatchlist(blob, clientType) {
247
- (0, validators_js_1.assertAssetsWatchlistBlobForWrite)(blob);
248
- const url = `${getAuthenticatedStorageUrl(__classPrivateFieldGet(this, _AuthenticatedUserStorageService_environment, "f"))}/preferences/assets-watchlist`;
249
- await this.fetchQuery({
250
- queryKey: [`${this.name}:setAssetsWatchlist`, blob],
251
- staleTime: 0,
252
- queryFn: async () => {
253
- const headers = await __classPrivateFieldGet(this, _AuthenticatedUserStorageService_instances, "m", _AuthenticatedUserStorageService_getHeaders).call(this, clientType);
254
- const response = await fetch(url, {
255
- method: 'PUT',
256
- headers,
257
- body: JSON.stringify(blob),
258
- });
259
- if (!response.ok) {
260
- throw new controller_utils_1.HttpError(response.status, `Failed to put assets watchlist: ${response.status}`);
261
- }
262
- return null;
263
- },
264
- });
265
- await this.invalidateQueries({
266
- queryKey: [`${this.name}:getAssetsWatchlist`],
267
- });
268
- }
269
- }
270
- exports.AuthenticatedUserStorageService = AuthenticatedUserStorageService;
271
- _AuthenticatedUserStorageService_environment = new WeakMap(), _AuthenticatedUserStorageService_instances = new WeakSet(), _AuthenticatedUserStorageService_getHeaders = async function _AuthenticatedUserStorageService_getHeaders(clientType) {
272
- const accessToken = await this.messenger.call('AuthenticationController:getBearerToken');
273
- const headers = {
274
- 'Content-Type': 'application/json',
275
- Authorization: `Bearer ${accessToken}`,
276
- };
277
- if (clientType) {
278
- headers['X-Client-Type'] = clientType;
279
- }
280
- return headers;
281
- };
282
- //# sourceMappingURL=authenticated-user-storage.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"authenticated-user-storage.cjs","sourceRoot":"","sources":["../src/authenticated-user-storage.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAKA,mEAA8D;AAE9D,iEAAuD;AAMvD,sCAAgD;AAQhD,oDAKyB;AAEzB,kBAAkB;AAElB;;;GAGG;AACU,QAAA,WAAW,GAAG,iCAAiC,CAAC;AAE7D;;;;;GAKG;AACH,SAAgB,0BAA0B,CAAC,WAAwB;IACjE,OAAO,GAAG,IAAA,6BAAoB,EAAC,WAAW,CAAC,SAAS,CAAC;AACvD,CAAC;AAFD,gEAEC;AAED,oBAAoB;AAEpB,MAAM,yBAAyB,GAAG;IAChC,iBAAiB;IACjB,kBAAkB;IAClB,kBAAkB;IAClB,4BAA4B;IAC5B,4BAA4B;IAC5B,oBAAoB;IACpB,oBAAoB;CACZ,CAAC;AAoEX,kBAAkB;AAElB;;;;;GAKG;AACH,MAAa,+BAAgC,SAAQ,mCAGpD;IAGC;;;;;;;;OAQG;IACH,YAAY,EACV,SAAS,EACT,WAAW,EACX,aAAa,GAKd;QACC,KAAK,CAAC,EAAE,IAAI,EAAE,mBAAW,EAAE,SAAS,EAAE,aAAa,EAAE,CAAC,CAAC;;QApBhD,+DAA0B;QAqBjC,uBAAA,IAAI,gDAAgB,WAAW,MAAA,CAAC;QAEhC,IAAI,CAAC,SAAS,CAAC,4BAA4B,CACzC,IAAI,EACJ,yBAAyB,CAC1B,CAAC;IACJ,CAAC;IAED;;;;OAIG;IACH,KAAK,CAAC,eAAe;QACnB,MAAM,GAAG,GAAG,GAAG,0BAA0B,CAAC,uBAAA,IAAI,oDAAa,CAAC,cAAc,CAAC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AAM,IAAI,CAAC,iBAAiB,CAAC;YAC3B,QAAQ,EAAE,CAAC,GAAG,IAAI,CAAC,IAAI,qBAAqB,CAAC;SAC9C,CAAC,CAAC;IACL,CAAC;CAeF;AA3TD,0EA2TC;wKAbC,KAAK,sDAAa,UAAuB;IACvC,MAAM,WAAW,GAAG,MAAM,IAAI,CAAC,SAAS,CAAC,IAAI,CAC3C,yCAAyC,CAC1C,CAAC;IACF,MAAM,OAAO,GAA2B;QACtC,cAAc,EAAE,kBAAkB;QAClC,aAAa,EAAE,UAAU,WAAW,EAAE;KACvC,CAAC;IACF,IAAI,UAAU,EAAE,CAAC;QACf,OAAO,CAAC,eAAe,CAAC,GAAG,UAAU,CAAC;IACxC,CAAC;IACD,OAAO,OAAO,CAAC;AACjB,CAAC","sourcesContent":["import type {\n DataServiceCacheUpdatedEvent,\n DataServiceGranularCacheUpdatedEvent,\n DataServiceInvalidateQueriesAction,\n} from '@metamask/base-data-service';\nimport { BaseDataService } from '@metamask/base-data-service';\nimport type { CreateServicePolicyOptions } from '@metamask/controller-utils';\nimport { HttpError } from '@metamask/controller-utils';\nimport type { Messenger } from '@metamask/messenger';\nimport type { Json } from '@metamask/utils';\n\nimport type { AuthenticatedUserStorageServiceMethodActions } from './authenticated-user-storage-method-action-types.js';\nimport type { Environment } from './env.js';\nimport { getUserStorageApiUrl } from './env.js';\nimport type {\n AssetsWatchlistBlob,\n ClientType,\n DelegationResponse,\n DelegationSubmission,\n NotificationPreferences,\n} from './types.js';\nimport {\n assertAssetsWatchlistBlob,\n assertAssetsWatchlistBlobForWrite,\n assertDelegationResponseArray,\n assertNotificationPreferences,\n} from './validators.js';\n\n// === GENERAL ===\n\n/**\n * The name of the {@link AuthenticatedUserStorageService} service, used to\n * namespace the service's actions and events.\n */\nexport const serviceName = 'AuthenticatedUserStorageService';\n\n/**\n * Builds the versioned API base URL for a given environment.\n *\n * @param environment - The target environment.\n * @returns The base URL including the `/api/v1` path segment.\n */\nexport function getAuthenticatedStorageUrl(environment: Environment): string {\n return `${getUserStorageApiUrl(environment)}/api/v1`;\n}\n\n// === MESSENGER ===\n\nconst MESSENGER_EXPOSED_METHODS = [\n 'listDelegations',\n 'createDelegation',\n 'revokeDelegation',\n 'getNotificationPreferences',\n 'putNotificationPreferences',\n 'getAssetsWatchlist',\n 'setAssetsWatchlist',\n] as const;\n\n/**\n * Invalidates cached queries for {@link AuthenticatedUserStorageService}.\n */\nexport type AuthenticatedUserStorageInvalidateQueriesAction =\n DataServiceInvalidateQueriesAction<typeof serviceName>;\n\n/**\n * Actions that {@link AuthenticatedUserStorageService} exposes to other\n * consumers.\n */\nexport type AuthenticatedUserStorageActions =\n | AuthenticatedUserStorageServiceMethodActions\n | AuthenticatedUserStorageInvalidateQueriesAction;\n\n/**\n * Retrieves a bearer token from the `AuthenticationController`, logging in the\n * user if necessary.\n */\ntype AuthenticationControllerGetBearerTokenAction = {\n type: 'AuthenticationController:getBearerToken';\n handler: (entropySourceId?: string) => Promise<string>;\n};\n\n/**\n * Actions from other messengers that {@link AuthenticatedUserStorageService}\n * calls.\n */\ntype AllowedActions = AuthenticationControllerGetBearerTokenAction;\n\n/**\n * Published when {@link AuthenticatedUserStorageService}'s cache is updated.\n */\nexport type AuthenticatedUserStorageCacheUpdatedEvent =\n DataServiceCacheUpdatedEvent<typeof serviceName>;\n\n/**\n * Published when a key within {@link AuthenticatedUserStorageService}'s cache\n * is updated.\n */\nexport type AuthenticatedUserStorageGranularCacheUpdatedEvent =\n DataServiceGranularCacheUpdatedEvent<typeof serviceName>;\n\n/**\n * Events that {@link AuthenticatedUserStorageService} exposes to other\n * consumers.\n */\nexport type AuthenticatedUserStorageEvents =\n | AuthenticatedUserStorageCacheUpdatedEvent\n | AuthenticatedUserStorageGranularCacheUpdatedEvent;\n\n/**\n * Events from other messengers that\n * {@link AuthenticatedUserStorageService} subscribes to.\n */\ntype AllowedEvents = never;\n\n/**\n * The messenger which is restricted to actions and events accessed by\n * {@link AuthenticatedUserStorageService}.\n */\nexport type AuthenticatedUserStorageMessenger = Messenger<\n typeof serviceName,\n AuthenticatedUserStorageActions | AllowedActions,\n AuthenticatedUserStorageEvents | AllowedEvents\n>;\n\n// === SERVICE ===\n\n/**\n * Data service wrapping authenticated user-storage API endpoints.\n *\n * Provides methods for managing delegations and notification preferences\n * for the authenticated user.\n */\nexport class AuthenticatedUserStorageService extends BaseDataService<\n typeof serviceName,\n AuthenticatedUserStorageMessenger\n> {\n readonly #environment: Environment;\n\n /**\n * Constructs a new AuthenticatedUserStorageService.\n *\n * @param args - The constructor arguments.\n * @param args.messenger - The messenger suited for this service.\n * @param args.environment - The target environment (dev, uat, prod).\n * @param args.policyOptions - Options to pass to `createServicePolicy`, which\n * is used to wrap each request. See {@link CreateServicePolicyOptions}.\n */\n constructor({\n messenger,\n environment,\n policyOptions,\n }: {\n messenger: AuthenticatedUserStorageMessenger;\n environment: Environment;\n policyOptions?: CreateServicePolicyOptions;\n }) {\n super({ name: serviceName, messenger, policyOptions });\n this.#environment = environment;\n\n this.messenger.registerMethodActionHandlers(\n this,\n MESSENGER_EXPOSED_METHODS,\n );\n }\n\n /**\n * Returns all delegation records belonging to the authenticated user.\n *\n * @returns An array of delegation records, or an empty array if none exist.\n */\n async listDelegations(): Promise<DelegationResponse[]> {\n const url = `${getAuthenticatedStorageUrl(this.#environment)}/delegations`;\n\n const data = await this.fetchQuery({\n queryKey: [`${this.name}:listDelegations`],\n queryFn: async () => {\n const headers = await this.#getHeaders();\n const response = await fetch(url, { headers });\n\n if (!response.ok) {\n throw new HttpError(\n response.status,\n `Failed to list delegations: ${response.status}`,\n );\n }\n\n return response.json();\n },\n });\n\n assertDelegationResponseArray(data);\n return data;\n }\n\n /**\n * Stores a signed delegation record for the authenticated user.\n *\n * @param submission - The signed delegation and its metadata.\n * @param clientType - Optional client type header.\n */\n async createDelegation(\n submission: DelegationSubmission,\n clientType?: ClientType,\n ): Promise<void> {\n const url = `${getAuthenticatedStorageUrl(this.#environment)}/delegations`;\n\n await this.fetchQuery({\n queryKey: [\n `${this.name}:createDelegation`,\n submission.metadata.delegationHash,\n ],\n staleTime: 0,\n queryFn: async () => {\n const headers = await this.#getHeaders(clientType);\n const response = await fetch(url, {\n method: 'POST',\n headers,\n body: JSON.stringify(submission),\n });\n\n if (!response.ok) {\n throw new HttpError(\n response.status,\n `Failed to create delegation: ${response.status}`,\n );\n }\n\n return null;\n },\n });\n\n await this.invalidateQueries({\n queryKey: [`${this.name}:listDelegations`],\n });\n }\n\n /**\n * Revokes (deletes) a delegation record.\n *\n * @param delegationHash - The unique hash identifying the delegation.\n */\n async revokeDelegation(delegationHash: string): Promise<void> {\n const url = `${getAuthenticatedStorageUrl(this.#environment)}/delegations/${encodeURIComponent(delegationHash)}`;\n\n await this.fetchQuery({\n queryKey: [`${this.name}:revokeDelegation`, delegationHash],\n staleTime: 0,\n queryFn: async () => {\n const headers = await this.#getHeaders();\n const response = await fetch(url, {\n method: 'DELETE',\n headers,\n });\n\n if (!response.ok) {\n throw new HttpError(\n response.status,\n `Failed to revoke delegation: ${response.status}`,\n );\n }\n\n return null;\n },\n });\n\n await this.invalidateQueries({\n queryKey: [`${this.name}:listDelegations`],\n });\n }\n\n /**\n * Returns the notification preferences for the authenticated user.\n *\n * @returns The notification preferences object, or `null` if none have been\n * set (404).\n */\n async getNotificationPreferences(): Promise<NotificationPreferences | null> {\n const url = `${getAuthenticatedStorageUrl(this.#environment)}/preferences/notifications`;\n\n const data = await this.fetchQuery({\n queryKey: [`${this.name}:getNotificationPreferences`],\n queryFn: async () => {\n const headers = await this.#getHeaders();\n const response = await fetch(url, { headers });\n\n if (response.status === 404) {\n return null;\n }\n\n if (!response.ok) {\n throw new HttpError(\n response.status,\n `Failed to get notification preferences: ${response.status}`,\n );\n }\n\n return response.json();\n },\n });\n\n if (data === null) {\n return null;\n }\n\n assertNotificationPreferences(data);\n return data;\n }\n\n /**\n * Creates or updates the notification preferences for the authenticated user.\n *\n * @param prefs - The full notification preferences object.\n * @param clientType - Optional client type header.\n */\n async putNotificationPreferences(\n prefs: NotificationPreferences,\n clientType?: ClientType,\n ): Promise<void> {\n const url = `${getAuthenticatedStorageUrl(this.#environment)}/preferences/notifications`;\n\n await this.fetchQuery({\n queryKey: [\n `${this.name}:putNotificationPreferences`,\n prefs as unknown as Json,\n ],\n staleTime: 0,\n queryFn: async () => {\n const headers = await this.#getHeaders(clientType);\n const response = await fetch(url, {\n method: 'PUT',\n headers,\n body: JSON.stringify(prefs),\n });\n\n if (!response.ok) {\n throw new HttpError(\n response.status,\n `Failed to put notification preferences: ${response.status}`,\n );\n }\n\n return null;\n },\n });\n\n await this.invalidateQueries({\n queryKey: [`${this.name}:getNotificationPreferences`],\n });\n }\n\n /**\n * Returns the assets-watchlist for the authenticated user.\n *\n * @returns The assets-watchlist blob, or `null` if none has been set (404).\n */\n async getAssetsWatchlist(): Promise<AssetsWatchlistBlob | null> {\n const url = `${getAuthenticatedStorageUrl(this.#environment)}/preferences/assets-watchlist`;\n\n const data = await this.fetchQuery({\n queryKey: [`${this.name}:getAssetsWatchlist`],\n queryFn: async () => {\n const headers = await this.#getHeaders();\n const response = await fetch(url, { headers });\n\n if (response.status === 404) {\n return null;\n }\n\n if (!response.ok) {\n throw new HttpError(\n response.status,\n `Failed to get assets watchlist: ${response.status}`,\n );\n }\n\n return response.json();\n },\n });\n\n if (data === null) {\n return null;\n }\n\n assertAssetsWatchlistBlob(data);\n return data;\n }\n\n /**\n * Creates or updates the assets-watchlist for the authenticated user.\n *\n * @param blob - The full assets-watchlist blob. The `assets` array may\n * contain at most `ASSETS_WATCHLIST_MAX_ASSETS` CAIP-19 asset identifiers;\n * this is enforced by `assertAssetsWatchlistBlobForWrite` before the\n * request is sent.\n * @param clientType - Optional client type header.\n * @throws A `StructError` from `@metamask/superstruct` if `blob` is\n * structurally invalid or `assets` exceeds the cap; an `HttpError` from\n * `@metamask/controller-utils` if the API responds with a non-2xx status.\n */\n async setAssetsWatchlist(\n blob: AssetsWatchlistBlob,\n clientType?: ClientType,\n ): Promise<void> {\n assertAssetsWatchlistBlobForWrite(blob);\n\n const url = `${getAuthenticatedStorageUrl(this.#environment)}/preferences/assets-watchlist`;\n\n await this.fetchQuery({\n queryKey: [`${this.name}:setAssetsWatchlist`, blob as unknown as Json],\n staleTime: 0,\n queryFn: async () => {\n const headers = await this.#getHeaders(clientType);\n const response = await fetch(url, {\n method: 'PUT',\n headers,\n body: JSON.stringify(blob),\n });\n\n if (!response.ok) {\n throw new HttpError(\n response.status,\n `Failed to put assets watchlist: ${response.status}`,\n );\n }\n\n return null;\n },\n });\n\n await this.invalidateQueries({\n queryKey: [`${this.name}:getAssetsWatchlist`],\n });\n }\n\n async #getHeaders(clientType?: ClientType): Promise<Record<string, string>> {\n const accessToken = await this.messenger.call(\n 'AuthenticationController:getBearerToken',\n );\n const headers: Record<string, string> = {\n 'Content-Type': 'application/json',\n Authorization: `Bearer ${accessToken}`,\n };\n if (clientType) {\n headers['X-Client-Type'] = clientType;\n }\n return headers;\n }\n}\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"authenticated-user-storage.d.cts","sourceRoot":"","sources":["../src/authenticated-user-storage.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,4BAA4B,EAC5B,oCAAoC,EACpC,kCAAkC,EACnC,oCAAoC;AACrC,OAAO,EAAE,eAAe,EAAE,oCAAoC;AAC9D,OAAO,KAAK,EAAE,0BAA0B,EAAE,mCAAmC;AAE7E,OAAO,KAAK,EAAE,SAAS,EAAE,4BAA4B;AAGrD,OAAO,KAAK,EAAE,4CAA4C,EAAE,6DAA4D;AACxH,OAAO,KAAK,EAAE,WAAW,EAAE,kBAAiB;AAE5C,OAAO,KAAK,EACV,mBAAmB,EACnB,UAAU,EACV,kBAAkB,EAClB,oBAAoB,EACpB,uBAAuB,EACxB,oBAAmB;AAUpB;;;GAGG;AACH,eAAO,MAAM,WAAW,oCAAoC,CAAC;AAE7D;;;;;GAKG;AACH,wBAAgB,0BAA0B,CAAC,WAAW,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BAAoB,EAChC,UAAU,CAAC,EAAE,UAAU,GACtB,OAAO,CAAC,IAAI,CAAC;IAiChB;;;;OAIG;IACG,gBAAgB,CAAC,cAAc,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IA6B7D;;;;;OAKG;IACG,0BAA0B,IAAI,OAAO,CAAC,uBAAuB,GAAG,IAAI,CAAC;IAgC3E;;;;;OAKG;IACG,0BAA0B,CAC9B,KAAK,EAAE,uBAAuB,EAC9B,UAAU,CAAC,EAAE,UAAU,GACtB,OAAO,CAAC,IAAI,CAAC;IAiChB;;;;OAIG;IACG,kBAAkB,IAAI,OAAO,CAAC,mBAAmB,GAAG,IAAI,CAAC;IAgC/D;;;;;;;;;;;OAWG;IACG,kBAAkB,CACtB,IAAI,EAAE,mBAAmB,EACzB,UAAU,CAAC,EAAE,UAAU,GACtB,OAAO,CAAC,IAAI,CAAC;CA6CjB"}
@@ -1,142 +0,0 @@
1
- import type { DataServiceCacheUpdatedEvent, DataServiceGranularCacheUpdatedEvent, DataServiceInvalidateQueriesAction } from "@metamask/base-data-service";
2
- import { BaseDataService } from "@metamask/base-data-service";
3
- import type { CreateServicePolicyOptions } from "@metamask/controller-utils";
4
- import type { Messenger } from "@metamask/messenger";
5
- import type { AuthenticatedUserStorageServiceMethodActions } from "./authenticated-user-storage-method-action-types.mjs";
6
- import type { Environment } from "./env.mjs";
7
- import type { AssetsWatchlistBlob, ClientType, DelegationResponse, DelegationSubmission, NotificationPreferences } from "./types.mjs";
8
- /**
9
- * The name of the {@link AuthenticatedUserStorageService} service, used to
10
- * namespace the service's actions and events.
11
- */
12
- export declare const serviceName = "AuthenticatedUserStorageService";
13
- /**
14
- * Builds the versioned API base URL for a given environment.
15
- *
16
- * @param environment - The target environment.
17
- * @returns The base URL including the `/api/v1` path segment.
18
- */
19
- export declare function getAuthenticatedStorageUrl(environment: Environment): string;
20
- /**
21
- * Invalidates cached queries for {@link AuthenticatedUserStorageService}.
22
- */
23
- export type AuthenticatedUserStorageInvalidateQueriesAction = DataServiceInvalidateQueriesAction<typeof serviceName>;
24
- /**
25
- * Actions that {@link AuthenticatedUserStorageService} exposes to other
26
- * consumers.
27
- */
28
- export type AuthenticatedUserStorageActions = AuthenticatedUserStorageServiceMethodActions | AuthenticatedUserStorageInvalidateQueriesAction;
29
- /**
30
- * Retrieves a bearer token from the `AuthenticationController`, logging in the
31
- * user if necessary.
32
- */
33
- type AuthenticationControllerGetBearerTokenAction = {
34
- type: 'AuthenticationController:getBearerToken';
35
- handler: (entropySourceId?: string) => Promise<string>;
36
- };
37
- /**
38
- * Actions from other messengers that {@link AuthenticatedUserStorageService}
39
- * calls.
40
- */
41
- type AllowedActions = AuthenticationControllerGetBearerTokenAction;
42
- /**
43
- * Published when {@link AuthenticatedUserStorageService}'s cache is updated.
44
- */
45
- export type AuthenticatedUserStorageCacheUpdatedEvent = DataServiceCacheUpdatedEvent<typeof serviceName>;
46
- /**
47
- * Published when a key within {@link AuthenticatedUserStorageService}'s cache
48
- * is updated.
49
- */
50
- export type AuthenticatedUserStorageGranularCacheUpdatedEvent = DataServiceGranularCacheUpdatedEvent<typeof serviceName>;
51
- /**
52
- * Events that {@link AuthenticatedUserStorageService} exposes to other
53
- * consumers.
54
- */
55
- export type AuthenticatedUserStorageEvents = AuthenticatedUserStorageCacheUpdatedEvent | AuthenticatedUserStorageGranularCacheUpdatedEvent;
56
- /**
57
- * Events from other messengers that
58
- * {@link AuthenticatedUserStorageService} subscribes to.
59
- */
60
- type AllowedEvents = never;
61
- /**
62
- * The messenger which is restricted to actions and events accessed by
63
- * {@link AuthenticatedUserStorageService}.
64
- */
65
- export type AuthenticatedUserStorageMessenger = Messenger<typeof serviceName, AuthenticatedUserStorageActions | AllowedActions, AuthenticatedUserStorageEvents | AllowedEvents>;
66
- /**
67
- * Data service wrapping authenticated user-storage API endpoints.
68
- *
69
- * Provides methods for managing delegations and notification preferences
70
- * for the authenticated user.
71
- */
72
- export declare class AuthenticatedUserStorageService extends BaseDataService<typeof serviceName, AuthenticatedUserStorageMessenger> {
73
- #private;
74
- /**
75
- * Constructs a new AuthenticatedUserStorageService.
76
- *
77
- * @param args - The constructor arguments.
78
- * @param args.messenger - The messenger suited for this service.
79
- * @param args.environment - The target environment (dev, uat, prod).
80
- * @param args.policyOptions - Options to pass to `createServicePolicy`, which
81
- * is used to wrap each request. See {@link CreateServicePolicyOptions}.
82
- */
83
- constructor({ messenger, environment, policyOptions, }: {
84
- messenger: AuthenticatedUserStorageMessenger;
85
- environment: Environment;
86
- policyOptions?: CreateServicePolicyOptions;
87
- });
88
- /**
89
- * Returns all delegation records belonging to the authenticated user.
90
- *
91
- * @returns An array of delegation records, or an empty array if none exist.
92
- */
93
- listDelegations(): Promise<DelegationResponse[]>;
94
- /**
95
- * Stores a signed delegation record for the authenticated user.
96
- *
97
- * @param submission - The signed delegation and its metadata.
98
- * @param clientType - Optional client type header.
99
- */
100
- createDelegation(submission: DelegationSubmission, clientType?: ClientType): Promise<void>;
101
- /**
102
- * Revokes (deletes) a delegation record.
103
- *
104
- * @param delegationHash - The unique hash identifying the delegation.
105
- */
106
- revokeDelegation(delegationHash: string): Promise<void>;
107
- /**
108
- * Returns the notification preferences for the authenticated user.
109
- *
110
- * @returns The notification preferences object, or `null` if none have been
111
- * set (404).
112
- */
113
- getNotificationPreferences(): Promise<NotificationPreferences | null>;
114
- /**
115
- * Creates or updates the notification preferences for the authenticated user.
116
- *
117
- * @param prefs - The full notification preferences object.
118
- * @param clientType - Optional client type header.
119
- */
120
- putNotificationPreferences(prefs: NotificationPreferences, clientType?: ClientType): Promise<void>;
121
- /**
122
- * Returns the assets-watchlist for the authenticated user.
123
- *
124
- * @returns The assets-watchlist blob, or `null` if none has been set (404).
125
- */
126
- getAssetsWatchlist(): Promise<AssetsWatchlistBlob | null>;
127
- /**
128
- * Creates or updates the assets-watchlist for the authenticated user.
129
- *
130
- * @param blob - The full assets-watchlist blob. The `assets` array may
131
- * contain at most `ASSETS_WATCHLIST_MAX_ASSETS` CAIP-19 asset identifiers;
132
- * this is enforced by `assertAssetsWatchlistBlobForWrite` before the
133
- * request is sent.
134
- * @param clientType - Optional client type header.
135
- * @throws A `StructError` from `@metamask/superstruct` if `blob` is
136
- * structurally invalid or `assets` exceeds the cap; an `HttpError` from
137
- * `@metamask/controller-utils` if the API responds with a non-2xx status.
138
- */
139
- setAssetsWatchlist(blob: AssetsWatchlistBlob, clientType?: ClientType): Promise<void>;
140
- }
141
- export {};
142
- //# sourceMappingURL=authenticated-user-storage.d.mts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"authenticated-user-storage.d.mts","sourceRoot":"","sources":["../src/authenticated-user-storage.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,4BAA4B,EAC5B,oCAAoC,EACpC,kCAAkC,EACnC,oCAAoC;AACrC,OAAO,EAAE,eAAe,EAAE,oCAAoC;AAC9D,OAAO,KAAK,EAAE,0BAA0B,EAAE,mCAAmC;AAE7E,OAAO,KAAK,EAAE,SAAS,EAAE,4BAA4B;AAGrD,OAAO,KAAK,EAAE,4CAA4C,EAAE,6DAA4D;AACxH,OAAO,KAAK,EAAE,WAAW,EAAE,kBAAiB;AAE5C,OAAO,KAAK,EACV,mBAAmB,EACnB,UAAU,EACV,kBAAkB,EAClB,oBAAoB,EACpB,uBAAuB,EACxB,oBAAmB;AAUpB;;;GAGG;AACH,eAAO,MAAM,WAAW,oCAAoC,CAAC;AAE7D;;;;;GAKG;AACH,wBAAgB,0BAA0B,CAAC,WAAW,EAAE,WAAW,GAAG,MAAM,CAE3E;AAcD;;GAEG;AACH,MAAM,MAAM,+CAA+C,GACzD,kCAAkC,CAAC,OAAO,WAAW,CAAC,CAAC;AAEzD;;;GAGG;AACH,MAAM,MAAM,+BAA+B,GACvC,4CAA4C,GAC5C,+CAA+C,CAAC;AAEpD;;;GAGG;AACH,KAAK,4CAA4C,GAAG;IAClD,IAAI,EAAE,yCAAyC,CAAC;IAChD,OAAO,EAAE,CAAC,eAAe,CAAC,EA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AAC,EAAE,UAAU,GACtB,OAAO,CAAC,IAAI,CAAC;IAiChB;;;;OAIG;IACG,kBAAkB,IAAI,OAAO,CAAC,mBAAmB,GAAG,IAAI,CAAC;IAgC/D;;;;;;;;;;;OAWG;IACG,kBAAkB,CACtB,IAAI,EAAE,mBAAmB,EACzB,UAAU,CAAC,EAAE,UAAU,GACtB,OAAO,CAAC,IAAI,CAAC;CA6CjB"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"authenticated-user-storage.mjs","sourceRoot":"","sources":["../src/authenticated-user-storage.ts"],"names":[],"mappings":";;;;;;;;;;;;AAKA,OAAO,EAAE,eAAe,EAAE,oCAAoC;AAE9D,OAAO,EAAE,SAAS,EAAE,mCAAmC;AAMvD,OAAO,EAAE,oBAAoB,EAAE,kBAAiB;AAQhD,OAAO,EACL,yBAAyB,EACzB,iCAAiC,EACjC,6BAA6B,EAC7B,6BAA6B,EAC9B,yBAAwB;AAEzB,kBAAkB;AAElB;;;GAGG;AACH,MAAM,CAAC,MAAM,WAAW,GAAG,iCAAiC,CAAC;AAE7D;;;;;GAKG;AACH,MAAM,UAAU,0BAA0B,CAAC,WAAwB;IACjE,OAAO,GAAG,oBAAoB,CAAC,WAAW,CAAC,SAAS,CAAC;AACvD,CAAC;AAED,oBAAoB;AAEpB,MAAM,yBAAyB,GAAG;IAChC,iBAAiB;IACjB,kBAAkB;IAClB,kBAAkB;IAClB,4BAA4B;IAC5B,4BAA4B;IAC5B,oBAAoB;IACpB,oBAAoB;CACZ,CAAC;AAoEX,kBAAkB;AAElB;;;;;GAKG;AACH,MAAM,OAAO,+BAAgC,SAAQ,eAGpD;IAGC;;;;;;;;OAQG;IACH,YAAY,EACV,SAAS,EACT,WAAW,EACX,aAAa,GAKd;QACC,KAAK,CAAC,EAAE,IAAI,EAAE,WAAW,EAAE,SAAS,EAAE,aAAa,EAAE,CAAC,CAAC;;QApBhD,+DAA0B;QAqBjC,uBAAA,IAAI,gDAAgB,WAAW,MAAA,CAAC;QAE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;oBACjB,MAAM,IAAI,SAAS,CACjB,QAAQ,CAAC,MAAM,EACf,mCAAmC,QAAQ,CAAC,MAAM,EAAE,CACrD,CAAC;gBACJ,CAAC;gBAED,OAAO,IAAI,CAAC;YACd,CAAC;SACF,CAAC,CAAC;QAEH,MAAM,IAAI,CAAC,iBAAiB,CAAC;YAC3B,QAAQ,EAAE,CAAC,GAAG,IAAI,CAAC,IAAI,qBAAqB,CAAC;SAC9C,CAAC,CAAC;IACL,CAAC;CAeF;wKAbC,KAAK,sDAAa,UAAuB;IACvC,MAAM,WAAW,GAAG,MAAM,IAAI,CAAC,SAAS,CAAC,IAAI,CAC3C,yCAAyC,CAC1C,CAAC;IACF,MAAM,OAAO,GAA2B;QACtC,cAAc,EAAE,kBAAkB;QAClC,aAAa,EAAE,UAAU,WAAW,EAAE;KACvC,CAAC;IACF,IAAI,UAAU,EAAE,CAAC;QACf,OAAO,CAAC,eAAe,CAAC,GAAG,UAAU,CAAC;IACxC,CAAC;IACD,OAAO,OAAO,CAAC;AACjB,CAAC","sourcesContent":["import type {\n DataServiceCacheUpdatedEvent,\n DataServiceGranularCacheUpdatedEvent,\n DataServiceInvalidateQueriesAction,\n} from '@metamask/base-data-service';\nimport { BaseDataService } from '@metamask/base-data-service';\nimport type { CreateServicePolicyOptions } from '@metamask/controller-utils';\nimport { HttpError } from '@metamask/controller-utils';\nimport type { Messenger } from '@metamask/messenger';\nimport type { Json } from '@metamask/utils';\n\nimport type { AuthenticatedUserStorageServiceMethodActions } from './authenticated-user-storage-method-action-types.js';\nimport type { Environment } from './env.js';\nimport { getUserStorageApiUrl } from './env.js';\nimport type {\n AssetsWatchlistBlob,\n ClientType,\n DelegationResponse,\n DelegationSubmission,\n NotificationPreferences,\n} from './types.js';\nimport {\n assertAssetsWatchlistBlob,\n assertAssetsWatchlistBlobForWrite,\n assertDelegationResponseArray,\n assertNotificationPreferences,\n} from './validators.js';\n\n// === GENERAL ===\n\n/**\n * The name of the {@link AuthenticatedUserStorageService} service, used to\n * namespace the service's actions and events.\n */\nexport const serviceName = 'AuthenticatedUserStorageService';\n\n/**\n * Builds the versioned API base URL for a given environment.\n *\n * @param environment - The target environment.\n * @returns The base URL including the `/api/v1` path segment.\n */\nexport function getAuthenticatedStorageUrl(environment: Environment): string {\n return `${getUserStorageApiUrl(environment)}/api/v1`;\n}\n\n// === MESSENGER ===\n\nconst MESSENGER_EXPOSED_METHODS = [\n 'listDelegations',\n 'createDelegation',\n 'revokeDelegation',\n 'getNotificationPreferences',\n 'putNotificationPreferences',\n 'getAssetsWatchlist',\n 'setAssetsWatchlist',\n] as const;\n\n/**\n * Invalidates cached queries for {@link AuthenticatedUserStorageService}.\n */\nexport type AuthenticatedUserStorageInvalidateQueriesAction =\n DataServiceInvalidateQueriesAction<typeof serviceName>;\n\n/**\n * Actions that {@link AuthenticatedUserStorageService} exposes to other\n * consumers.\n */\nexport type AuthenticatedUserStorageActions =\n | AuthenticatedUserStorageServiceMethodActions\n | AuthenticatedUserStorageInvalidateQueriesAction;\n\n/**\n * Retrieves a bearer token from the `AuthenticationController`, logging in the\n * user if necessary.\n */\ntype AuthenticationControllerGetBearerTokenAction = {\n type: 'AuthenticationController:getBearerToken';\n handler: (entropySourceId?: string) => Promise<string>;\n};\n\n/**\n * Actions from other messengers that {@link AuthenticatedUserStorageService}\n * calls.\n */\ntype AllowedActions = AuthenticationControllerGetBearerTokenAction;\n\n/**\n * Published when {@link AuthenticatedUserStorageService}'s cache is updated.\n */\nexport type AuthenticatedUserStorageCacheUpdatedEvent =\n DataServiceCacheUpdatedEvent<typeof serviceName>;\n\n/**\n * Published when a key within {@link AuthenticatedUserStorageService}'s cache\n * is updated.\n */\nexport type AuthenticatedUserStorageGranularCacheUpdatedEvent =\n DataServiceGranularCacheUpdatedEvent<typeof serviceName>;\n\n/**\n * Events that {@link AuthenticatedUserStorageService} exposes to other\n * consumers.\n */\nexport type AuthenticatedUserStorageEvents =\n | AuthenticatedUserStorageCacheUpdatedEvent\n | AuthenticatedUserStorageGranularCacheUpdatedEvent;\n\n/**\n * Events from other messengers that\n * {@link AuthenticatedUserStorageService} subscribes to.\n */\ntype AllowedEvents = never;\n\n/**\n * The messenger which is restricted to actions and events accessed by\n * {@link AuthenticatedUserStorageService}.\n */\nexport type AuthenticatedUserStorageMessenger = Messenger<\n typeof serviceName,\n AuthenticatedUserStorageActions | AllowedActions,\n AuthenticatedUserStorageEvents | AllowedEvents\n>;\n\n// === SERVICE ===\n\n/**\n * Data service wrapping authenticated user-storage API endpoints.\n *\n * Provides methods for managing delegations and notification preferences\n * for the authenticated user.\n */\nexport class AuthenticatedUserStorageService extends BaseDataService<\n typeof serviceName,\n AuthenticatedUserStorageMessenger\n> {\n readonly #environment: Environment;\n\n /**\n * Constructs a new AuthenticatedUserStorageService.\n *\n * @param args - The constructor arguments.\n * @param args.messenger - The messenger suited for this service.\n * @param args.environment - The target environment (dev, uat, prod).\n * @param args.policyOptions - Options to pass to `createServicePolicy`, which\n * is used to wrap each request. See {@link CreateServicePolicyOptions}.\n */\n constructor({\n messenger,\n environment,\n policyOptions,\n }: {\n messenger: AuthenticatedUserStorageMessenger;\n environment: Environment;\n policyOptions?: CreateServicePolicyOptions;\n }) {\n super({ name: serviceName, messenger, policyOptions });\n this.#environment = environment;\n\n this.messenger.registerMethodActionHandlers(\n this,\n MESSENGER_EXPOSED_METHODS,\n );\n }\n\n /**\n * Returns all delegation records belonging to the authenticated user.\n *\n * @returns An array of delegation records, or an empty array if none exist.\n */\n async listDelegations(): Promise<DelegationResponse[]> {\n const url = `${getAuthenticatedStorageUrl(this.#environment)}/delegations`;\n\n const data = await this.fetchQuery({\n queryKey: [`${this.name}:listDelegations`],\n queryFn: async () => {\n const headers = await this.#getHeaders();\n const response = await fetch(url, { headers });\n\n if (!response.ok) {\n throw new HttpError(\n response.status,\n `Failed to list delegations: ${response.status}`,\n );\n }\n\n return response.json();\n },\n });\n\n assertDelegationResponseArray(data);\n return data;\n }\n\n /**\n * Stores a signed delegation record for the authenticated user.\n *\n * @param submission - The signed delegation and its metadata.\n * @param clientType - Optional client type header.\n */\n async createDelegation(\n submission: DelegationSubmission,\n clientType?: ClientType,\n ): Promise<void> {\n const url = `${getAuthenticatedStorageUrl(this.#environment)}/delegations`;\n\n await this.fetchQuery({\n queryKey: [\n `${this.name}:createDelegation`,\n submission.metadata.delegationHash,\n ],\n staleTime: 0,\n queryFn: async () => {\n const headers = await this.#getHeaders(clientType);\n const response = await fetch(url, {\n method: 'POST',\n headers,\n body: JSON.stringify(submission),\n });\n\n if (!response.ok) {\n throw new HttpError(\n response.status,\n `Failed to create delegation: ${response.status}`,\n );\n }\n\n return null;\n },\n });\n\n await this.invalidateQueries({\n queryKey: [`${this.name}:listDelegations`],\n });\n }\n\n /**\n * Revokes (deletes) a delegation record.\n *\n * @param delegationHash - The unique hash identifying the delegation.\n */\n async revokeDelegation(delegationHash: string): Promise<void> {\n const url = `${getAuthenticatedStorageUrl(this.#environment)}/delegations/${encodeURIComponent(delegationHash)}`;\n\n await this.fetchQuery({\n queryKey: [`${this.name}:revokeDelegation`, delegationHash],\n staleTime: 0,\n queryFn: async () => {\n const headers = await this.#getHeaders();\n const response = await fetch(url, {\n method: 'DELETE',\n headers,\n });\n\n if (!response.ok) {\n throw new HttpError(\n response.status,\n `Failed to revoke delegation: ${response.status}`,\n );\n }\n\n return null;\n },\n });\n\n await this.invalidateQueries({\n queryKey: [`${this.name}:listDelegations`],\n });\n }\n\n /**\n * Returns the notification preferences for the authenticated user.\n *\n * @returns The notification preferences object, or `null` if none have been\n * set (404).\n */\n async getNotificationPreferences(): Promise<NotificationPreferences | null> {\n const url = `${getAuthenticatedStorageUrl(this.#environment)}/preferences/notifications`;\n\n const data = await this.fetchQuery({\n queryKey: [`${this.name}:getNotificationPreferences`],\n queryFn: async () => {\n const headers = await this.#getHeaders();\n const response = await fetch(url, { headers });\n\n if (response.status === 404) {\n return null;\n }\n\n if (!response.ok) {\n throw new HttpError(\n response.status,\n `Failed to get notification preferences: ${response.status}`,\n );\n }\n\n return response.json();\n },\n });\n\n if (data === null) {\n return null;\n }\n\n assertNotificationPreferences(data);\n return data;\n }\n\n /**\n * Creates or updates the notification preferences for the authenticated user.\n *\n * @param prefs - The full notification preferences object.\n * @param clientType - Optional client type header.\n */\n async putNotificationPreferences(\n prefs: NotificationPreferences,\n clientType?: ClientType,\n ): Promise<void> {\n const url = `${getAuthenticatedStorageUrl(this.#environment)}/preferences/notifications`;\n\n await this.fetchQuery({\n queryKey: [\n `${this.name}:putNotificationPreferences`,\n prefs as unknown as Json,\n ],\n staleTime: 0,\n queryFn: async () => {\n const headers = await this.#getHeaders(clientType);\n const response = await fetch(url, {\n method: 'PUT',\n headers,\n body: JSON.stringify(prefs),\n });\n\n if (!response.ok) {\n throw new HttpError(\n response.status,\n `Failed to put notification preferences: ${response.status}`,\n );\n }\n\n return null;\n },\n });\n\n await this.invalidateQueries({\n queryKey: [`${this.name}:getNotificationPreferences`],\n });\n }\n\n /**\n * Returns the assets-watchlist for the authenticated user.\n *\n * @returns The assets-watchlist blob, or `null` if none has been set (404).\n */\n async getAssetsWatchlist(): Promise<AssetsWatchlistBlob | null> {\n const url = `${getAuthenticatedStorageUrl(this.#environment)}/preferences/assets-watchlist`;\n\n const data = await this.fetchQuery({\n queryKey: [`${this.name}:getAssetsWatchlist`],\n queryFn: async () => {\n const headers = await this.#getHeaders();\n const response = await fetch(url, { headers });\n\n if (response.status === 404) {\n return null;\n }\n\n if (!response.ok) {\n throw new HttpError(\n response.status,\n `Failed to get assets watchlist: ${response.status}`,\n );\n }\n\n return response.json();\n },\n });\n\n if (data === null) {\n return null;\n }\n\n assertAssetsWatchlistBlob(data);\n return data;\n }\n\n /**\n * Creates or updates the assets-watchlist for the authenticated user.\n *\n * @param blob - The full assets-watchlist blob. The `assets` array may\n * contain at most `ASSETS_WATCHLIST_MAX_ASSETS` CAIP-19 asset identifiers;\n * this is enforced by `assertAssetsWatchlistBlobForWrite` before the\n * request is sent.\n * @param clientType - Optional client type header.\n * @throws A `StructError` from `@metamask/superstruct` if `blob` is\n * structurally invalid or `assets` exceeds the cap; an `HttpError` from\n * `@metamask/controller-utils` if the API responds with a non-2xx status.\n */\n async setAssetsWatchlist(\n blob: AssetsWatchlistBlob,\n clientType?: ClientType,\n ): Promise<void> {\n assertAssetsWatchlistBlobForWrite(blob);\n\n const url = `${getAuthenticatedStorageUrl(this.#environment)}/preferences/assets-watchlist`;\n\n await this.fetchQuery({\n queryKey: [`${this.name}:setAssetsWatchlist`, blob as unknown as Json],\n staleTime: 0,\n queryFn: async () => {\n const headers = await this.#getHeaders(clientType);\n const response = await fetch(url, {\n method: 'PUT',\n headers,\n body: JSON.stringify(blob),\n });\n\n if (!response.ok) {\n throw new HttpError(\n response.status,\n `Failed to put assets watchlist: ${response.status}`,\n );\n }\n\n return null;\n },\n });\n\n await this.invalidateQueries({\n queryKey: [`${this.name}:getAssetsWatchlist`],\n });\n }\n\n async #getHeaders(clientType?: ClientType): Promise<Record<string, string>> {\n const accessToken = await this.messenger.call(\n 'AuthenticationController:getBearerToken',\n );\n const headers: Record<string, string> = {\n 'Content-Type': 'application/json',\n Authorization: `Bearer ${accessToken}`,\n };\n if (clientType) {\n headers['X-Client-Type'] = clientType;\n }\n return headers;\n }\n}\n"]}
package/dist/env.cjs DELETED
@@ -1,24 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getUserStorageApiUrl = void 0;
4
- const API_SUBDOMAINS = {
5
- dev: 'dev-api',
6
- uat: 'uat-api',
7
- prod: 'api',
8
- };
9
- /**
10
- * Returns the user-storage API base URL for the given environment.
11
- *
12
- * @param environment - The target environment.
13
- * @returns The base URL for the user-storage API.
14
- * @throws If the environment is invalid.
15
- */
16
- function getUserStorageApiUrl(environment) {
17
- const subdomain = API_SUBDOMAINS[environment];
18
- if (!subdomain) {
19
- throw new Error(`Invalid environment: ${String(environment)}`);
20
- }
21
- return `https://user-storage.${subdomain}.cx.metamask.io`;
22
- }
23
- exports.getUserStorageApiUrl = getUserStorageApiUrl;
24
- //# sourceMappingURL=env.cjs.map
package/dist/env.cjs.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"env.cjs","sourceRoot":"","sources":["../src/env.ts"],"names":[],"mappings":";;;AAEA,MAAM,cAAc,GAAG;IACrB,GAAG,EAAE,SAAS;IACd,GAAG,EAAE,SAAS;IACd,IAAI,EAAE,KAAK;CACmC,CAAC;AAEjD;;;;;;GAMG;AACH,SAAgB,oBAAoB,CAAC,WAAwB;IAC3D,MAAM,SAAS,GAAG,cAAc,CAAC,WAAW,CAAC,CAAC;IAC9C,IAAI,CAAC,SAAS,EAAE,CAAC;QACf,MAAM,IAAI,KAAK,CAAC,wBAAwB,MAAM,CAAC,WAAW,CAAC,EAAE,CAAC,CAAC;IACjE,CAAC;IACD,OAAO,wBAAwB,SAAS,iBAAiB,CAAC;AAC5D,CAAC;AAND,oDAMC","sourcesContent":["export type Environment = 'dev' | 'uat' | 'prod';\n\nconst API_SUBDOMAINS = {\n dev: 'dev-api',\n uat: 'uat-api',\n prod: 'api',\n} as const satisfies Record<Environment, string>;\n\n/**\n * Returns the user-storage API base URL for the given environment.\n *\n * @param environment - The target environment.\n * @returns The base URL for the user-storage API.\n * @throws If the environment is invalid.\n */\nexport function getUserStorageApiUrl(environment: Environment): string {\n const subdomain = API_SUBDOMAINS[environment];\n if (!subdomain) {\n throw new Error(`Invalid environment: ${String(environment)}`);\n }\n return `https://user-storage.${subdomain}.cx.metamask.io`;\n}\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"env.d.cts","sourceRoot":"","sources":["../src/env.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,WAAW,GAAG,KAAK,GAAG,KAAK,GAAG,MAAM,CAAC;AAQjD;;;;;;GAMG;AACH,wBAAgB,oBAAoB,CAAC,WAAW,EAAE,WAAW,GAAG,MAAM,CAMrE"}
package/dist/env.d.mts DELETED
@@ -1,10 +0,0 @@
1
- export type Environment = 'dev' | 'uat' | 'prod';
2
- /**
3
- * Returns the user-storage API base URL for the given environment.
4
- *
5
- * @param environment - The target environment.
6
- * @returns The base URL for the user-storage API.
7
- * @throws If the environment is invalid.
8
- */
9
- export declare function getUserStorageApiUrl(environment: Environment): string;
10
- //# sourceMappingURL=env.d.mts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"env.d.mts","sourceRoot":"","sources":["../src/env.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,WAAW,GAAG,KAAK,GAAG,KAAK,GAAG,MAAM,CAAC;AAQjD;;;;;;GAMG;AACH,wBAAgB,oBAAoB,CAAC,WAAW,EAAE,WAAW,GAAG,MAAM,CAMrE"}
package/dist/env.mjs.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"env.mjs","sourceRoot":"","sources":["../src/env.ts"],"names":[],"mappings":"AAEA,MAAM,cAAc,GAAG;IACrB,GAAG,EAAE,SAAS;IACd,GAAG,EAAE,SAAS;IACd,IAAI,EAAE,KAAK;CACmC,CAAC;AAEjD;;;;;;GAMG;AACH,MAAM,UAAU,oBAAoB,CAAC,WAAwB;IAC3D,MAAM,SAAS,GAAG,cAAc,CAAC,WAAW,CAAC,CAAC;IAC9C,IAAI,CAAC,SAAS,EAAE,CAAC;QACf,MAAM,IAAI,KAAK,CAAC,wBAAwB,MAAM,CAAC,WAAW,CAAC,EAAE,CAAC,CAAC;IACjE,CAAC;IACD,OAAO,wBAAwB,SAAS,iBAAiB,CAAC;AAC5D,CAAC","sourcesContent":["export type Environment = 'dev' | 'uat' | 'prod';\n\nconst API_SUBDOMAINS = {\n dev: 'dev-api',\n uat: 'uat-api',\n prod: 'api',\n} as const satisfies Record<Environment, string>;\n\n/**\n * Returns the user-storage API base URL for the given environment.\n *\n * @param environment - The target environment.\n * @returns The base URL for the user-storage API.\n * @throws If the environment is invalid.\n */\nexport function getUserStorageApiUrl(environment: Environment): string {\n const subdomain = API_SUBDOMAINS[environment];\n if (!subdomain) {\n throw new Error(`Invalid environment: ${String(environment)}`);\n }\n return `https://user-storage.${subdomain}.cx.metamask.io`;\n}\n"]}
package/dist/index.cjs DELETED
@@ -1,13 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getUserStorageApiUrl = exports.DEFAULT_PRICE_ALERT_PREFERENCES = exports.DEFAULT_AGENTIC_CLI_PREFERENCES = exports.ASSETS_WATCHLIST_MAX_ASSETS = exports.AuthenticatedUserStorageService = exports.getAuthenticatedStorageUrl = void 0;
4
- var authenticated_user_storage_js_1 = require("./authenticated-user-storage.cjs");
5
- Object.defineProperty(exports, "getAuthenticatedStorageUrl", { enumerable: true, get: function () { return authenticated_user_storage_js_1.getAuthenticatedStorageUrl; } });
6
- Object.defineProperty(exports, "AuthenticatedUserStorageService", { enumerable: true, get: function () { return authenticated_user_storage_js_1.AuthenticatedUserStorageService; } });
7
- var validators_js_1 = require("./validators.cjs");
8
- Object.defineProperty(exports, "ASSETS_WATCHLIST_MAX_ASSETS", { enumerable: true, get: function () { return validators_js_1.ASSETS_WATCHLIST_MAX_ASSETS; } });
9
- Object.defineProperty(exports, "DEFAULT_AGENTIC_CLI_PREFERENCES", { enumerable: true, get: function () { return validators_js_1.DEFAULT_AGENTIC_CLI_PREFERENCES; } });
10
- Object.defineProperty(exports, "DEFAULT_PRICE_ALERT_PREFERENCES", { enumerable: true, get: function () { return validators_js_1.DEFAULT_PRICE_ALERT_PREFERENCES; } });
11
- var env_js_1 = require("./env.cjs");
12
- Object.defineProperty(exports, "getUserStorageApiUrl", { enumerable: true, get: function () { return env_js_1.getUserStorageApiUrl; } });
13
- //# sourceMappingURL=index.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.cjs","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAAA,kFAGyC;AAFvC,2IAAA,0BAA0B,OAAA;AAC1B,gJAAA,+BAA+B,OAAA;AAEjC,kDAIyB;AAHvB,4HAAA,2BAA2B,OAAA;AAC3B,gIAAA,+BAA+B,OAAA;AAC/B,gIAAA,+BAA+B,OAAA;AAmBjC,oCAAgD;AAAvC,8GAAA,oBAAoB,OAAA","sourcesContent":["export {\n getAuthenticatedStorageUrl,\n AuthenticatedUserStorageService,\n} from './authenticated-user-storage.js';\nexport {\n ASSETS_WATCHLIST_MAX_ASSETS,\n DEFAULT_AGENTIC_CLI_PREFERENCES,\n DEFAULT_PRICE_ALERT_PREFERENCES,\n} from './validators.js';\nexport type {\n AuthenticatedUserStorageActions,\n AuthenticatedUserStorageCacheUpdatedEvent,\n AuthenticatedUserStorageEvents,\n AuthenticatedUserStorageGranularCacheUpdatedEvent,\n AuthenticatedUserStorageInvalidateQueriesAction,\n AuthenticatedUserStorageMessenger,\n} from './authenticated-user-storage.js';\nexport type {\n AuthenticatedUserStorageServiceListDelegationsAction,\n AuthenticatedUserStorageServiceCreateDelegationAction,\n AuthenticatedUserStorageServiceRevokeDelegationAction,\n AuthenticatedUserStorageServiceGetNotificationPreferencesAction,\n AuthenticatedUserStorageServicePutNotificationPreferencesAction,\n AuthenticatedUserStorageServiceGetAssetsWatchlistAction,\n AuthenticatedUserStorageServiceSetAssetsWatchlistAction,\n} from './authenticated-user-storage-method-action-types.js';\nexport { getUserStorageApiUrl } from './env.js';\nexport type { Environment } from './env.js';\nexport type {\n Caveat,\n SignedDelegation,\n DelegationMetadata,\n DelegationSubmission,\n DelegationResponse,\n WalletActivityAccount,\n WalletActivityPreference,\n MarketingPreference,\n PerpsWatchlistExchange,\n PerpsWatchlistMarkets,\n PerpsPreference,\n SocialAIPreference,\n AgenticCliPreference,\n PriceAlertPreference,\n NotificationPreferences,\n AssetsWatchlistBlob,\n ClientType,\n} from './types.js';\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.cts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,0BAA0B,EAC1B,+BAA+B,GAChC,yCAAwC;AACzC,OAAO,EACL,2BAA2B,EAC3B,+BAA+B,EAC/B,+BAA+B,GAChC,yBAAwB;AACzB,YAAY,EACV,+BAA+B,EAC/B,yCAAyC,EACzC,8BAA8B,EAC9B,iDAAiD,EACjD,+CAA+C,EAC/C,iCAAiC,GAClC,yCAAwC;AACzC,YAAY,EACV,oDAAoD,EACpD,qDAAqD,EACrD,qDAAqD,EACrD,+DAA+D,EAC/D,+DAA+D,EAC/D,uDAAuD,EACvD,uDAAuD,GACxD,6DAA4D;AAC7D,OAAO,EAAE,oBAAoB,EAAE,kBAAiB;AAChD,YAAY,EAAE,WAAW,EAAE,kBAAiB;AAC5C,YAAY,EACV,MAAM,EACN,gBAAgB,EAChB,kBAAkB,EAClB,oBAAoB,EACpB,kBAAkB,EAClB,qBAAqB,EACrB,wBAAwB,EACxB,mBAAmB,EACnB,sBAAsB,EACtB,qBAAqB,EACrB,eAAe,EACf,kBAAkB,EAClB,oBAAoB,EACpB,oBAAoB,EACpB,uBAAuB,EACvB,mBAAmB,EACnB,UAAU,GACX,oBAAmB"}
package/dist/index.d.mts DELETED
@@ -1,8 +0,0 @@
1
- export { getAuthenticatedStorageUrl, AuthenticatedUserStorageService, } from "./authenticated-user-storage.mjs";
2
- export { ASSETS_WATCHLIST_MAX_ASSETS, DEFAULT_AGENTIC_CLI_PREFERENCES, DEFAULT_PRICE_ALERT_PREFERENCES, } from "./validators.mjs";
3
- export type { AuthenticatedUserStorageActions, AuthenticatedUserStorageCacheUpdatedEvent, AuthenticatedUserStorageEvents, AuthenticatedUserStorageGranularCacheUpdatedEvent, AuthenticatedUserStorageInvalidateQueriesAction, AuthenticatedUserStorageMessenger, } from "./authenticated-user-storage.mjs";
4
- export type { AuthenticatedUserStorageServiceListDelegationsAction, AuthenticatedUserStorageServiceCreateDelegationAction, AuthenticatedUserStorageServiceRevokeDelegationAction, AuthenticatedUserStorageServiceGetNotificationPreferencesAction, AuthenticatedUserStorageServicePutNotificationPreferencesAction, AuthenticatedUserStorageServiceGetAssetsWatchlistAction, AuthenticatedUserStorageServiceSetAssetsWatchlistAction, } from "./authenticated-user-storage-method-action-types.mjs";
5
- export { getUserStorageApiUrl } from "./env.mjs";
6
- export type { Environment } from "./env.mjs";
7
- export type { Caveat, SignedDelegation, DelegationMetadata, DelegationSubmission, DelegationResponse, WalletActivityAccount, WalletActivityPreference, MarketingPreference, PerpsWatchlistExchange, PerpsWatchlistMarkets, PerpsPreference, SocialAIPreference, AgenticCliPreference, PriceAlertPreference, NotificationPreferences, AssetsWatchlistBlob, ClientType, } from "./types.mjs";
8
- //# sourceMappingURL=index.d.mts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.mts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,0BAA0B,EAC1B,+BAA+B,GAChC,yCAAwC;AACzC,OAAO,EACL,2BAA2B,EAC3B,+BAA+B,EAC/B,+BAA+B,GAChC,yBAAwB;AACzB,YAAY,EACV,+BAA+B,EAC/B,yCAAyC,EACzC,8BAA8B,EAC9B,iDAAiD,EACjD,+CAA+C,EAC/C,iCAAiC,GAClC,yCAAwC;AACzC,YAAY,EACV,oDAAoD,EACpD,qDAAqD,EACrD,qDAAqD,EACrD,+DAA+D,EAC/D,+DAA+D,EAC/D,uDAAuD,EACvD,uDAAuD,GACxD,6DAA4D;AAC7D,OAAO,EAAE,oBAAoB,EAAE,kBAAiB;AAChD,YAAY,EAAE,WAAW,EAAE,kBAAiB;AAC5C,YAAY,EACV,MAAM,EACN,gBAAgB,EAChB,kBAAkB,EAClB,oBAAoB,EACpB,kBAAkB,EAClB,qBAAqB,EACrB,wBAAwB,EACxB,mBAAmB,EACnB,sBAAsB,EACtB,qBAAqB,EACrB,eAAe,EACf,kBAAkB,EAClB,oBAAoB,EACpB,oBAAoB,EACpB,uBAAuB,EACvB,mBAAmB,EACnB,UAAU,GACX,oBAAmB"}
package/dist/index.mjs DELETED
@@ -1,4 +0,0 @@
1
- export { getAuthenticatedStorageUrl, AuthenticatedUserStorageService } from "./authenticated-user-storage.mjs";
2
- export { ASSETS_WATCHLIST_MAX_ASSETS, DEFAULT_AGENTIC_CLI_PREFERENCES, DEFAULT_PRICE_ALERT_PREFERENCES } from "./validators.mjs";
3
- export { getUserStorageApiUrl } from "./env.mjs";
4
- //# sourceMappingURL=index.mjs.map