@metamask-previews/profile-metrics-controller 0.0.0-preview-e0d310b4
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 +14 -0
- package/LICENSE +20 -0
- package/README.md +13 -0
- package/dist/ProfileMetricsController.cjs +230 -0
- package/dist/ProfileMetricsController.cjs.map +1 -0
- package/dist/ProfileMetricsController.d.cts +120 -0
- package/dist/ProfileMetricsController.d.cts.map +1 -0
- package/dist/ProfileMetricsController.d.mts +120 -0
- package/dist/ProfileMetricsController.d.mts.map +1 -0
- package/dist/ProfileMetricsController.mjs +225 -0
- package/dist/ProfileMetricsController.mjs.map +1 -0
- package/dist/ProfileMetricsService-method-action-types.cjs +7 -0
- package/dist/ProfileMetricsService-method-action-types.cjs.map +1 -0
- package/dist/ProfileMetricsService-method-action-types.d.cts +20 -0
- package/dist/ProfileMetricsService-method-action-types.d.cts.map +1 -0
- package/dist/ProfileMetricsService-method-action-types.d.mts +20 -0
- package/dist/ProfileMetricsService-method-action-types.d.mts.map +1 -0
- package/dist/ProfileMetricsService-method-action-types.mjs +6 -0
- package/dist/ProfileMetricsService-method-action-types.mjs.map +1 -0
- package/dist/ProfileMetricsService.cjs +144 -0
- package/dist/ProfileMetricsService.cjs.map +1 -0
- package/dist/ProfileMetricsService.d.cts +120 -0
- package/dist/ProfileMetricsService.d.cts.map +1 -0
- package/dist/ProfileMetricsService.d.mts +120 -0
- package/dist/ProfileMetricsService.d.mts.map +1 -0
- package/dist/ProfileMetricsService.mjs +140 -0
- package/dist/ProfileMetricsService.mjs.map +1 -0
- package/dist/constants.cjs +29 -0
- package/dist/constants.cjs.map +1 -0
- package/dist/constants.d.cts +14 -0
- package/dist/constants.d.cts.map +1 -0
- package/dist/constants.d.mts +14 -0
- package/dist/constants.d.mts.map +1 -0
- package/dist/constants.mjs +25 -0
- package/dist/constants.mjs.map +1 -0
- package/dist/index.cjs +13 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +7 -0
- package/dist/index.d.cts.map +1 -0
- package/dist/index.d.mts +7 -0
- package/dist/index.d.mts.map +1 -0
- package/dist/index.mjs +4 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +82 -0
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
import type { CreateServicePolicyOptions, ServicePolicy } from "@metamask/controller-utils";
|
|
2
|
+
import type { Messenger } from "@metamask/messenger";
|
|
3
|
+
import type { AuthenticationController } from "@metamask/profile-sync-controller";
|
|
4
|
+
import { type ProfileMetricsServiceMethodActions, Env } from "./index.mjs";
|
|
5
|
+
/**
|
|
6
|
+
* The name of the {@link ProfileMetricsService}, used to namespace the
|
|
7
|
+
* service's actions and events.
|
|
8
|
+
*/
|
|
9
|
+
export declare const serviceName = "ProfileMetricsService";
|
|
10
|
+
/**
|
|
11
|
+
* An account address along with its associated scopes.
|
|
12
|
+
*/
|
|
13
|
+
export type AccountWithScopes = {
|
|
14
|
+
address: string;
|
|
15
|
+
scopes: `${string}:${string}`[];
|
|
16
|
+
};
|
|
17
|
+
/**
|
|
18
|
+
* The shape of the request object for updating the user profile.
|
|
19
|
+
*/
|
|
20
|
+
export type ProfileMetricsUpdateRequest = {
|
|
21
|
+
metametricsId: string;
|
|
22
|
+
entropySourceId?: string | null;
|
|
23
|
+
accounts: AccountWithScopes[];
|
|
24
|
+
};
|
|
25
|
+
/**
|
|
26
|
+
* Actions that {@link ProfileMetricsService} exposes to other consumers.
|
|
27
|
+
*/
|
|
28
|
+
export type ProfileMetricsServiceActions = ProfileMetricsServiceMethodActions;
|
|
29
|
+
/**
|
|
30
|
+
* Actions from other messengers that {@link ProfileMetricsService} calls.
|
|
31
|
+
*/
|
|
32
|
+
type AllowedActions = AuthenticationController.AuthenticationControllerGetBearerToken;
|
|
33
|
+
/**
|
|
34
|
+
* Events that {@link ProfileMetricsService} exposes to other consumers.
|
|
35
|
+
*/
|
|
36
|
+
export type ProfileMetricsServiceEvents = never;
|
|
37
|
+
/**
|
|
38
|
+
* Events from other messengers that {@link ProfileMetricsService} subscribes
|
|
39
|
+
* to.
|
|
40
|
+
*/
|
|
41
|
+
type AllowedEvents = never;
|
|
42
|
+
/**
|
|
43
|
+
* The messenger which is restricted to actions and events accessed by
|
|
44
|
+
* {@link ProfileMetricsService}.
|
|
45
|
+
*/
|
|
46
|
+
export type ProfileMetricsServiceMessenger = Messenger<typeof serviceName, ProfileMetricsServiceActions | AllowedActions, ProfileMetricsServiceEvents | AllowedEvents>;
|
|
47
|
+
export declare class ProfileMetricsService {
|
|
48
|
+
#private;
|
|
49
|
+
/**
|
|
50
|
+
* The name of the service.
|
|
51
|
+
*/
|
|
52
|
+
readonly name: typeof serviceName;
|
|
53
|
+
/**
|
|
54
|
+
* Constructs a new ProfileMetricsService object.
|
|
55
|
+
*
|
|
56
|
+
* @param args - The constructor arguments.
|
|
57
|
+
* @param args.messenger - The messenger suited for this service.
|
|
58
|
+
* @param args.fetch - A function that can be used to make an HTTP request. If
|
|
59
|
+
* your JavaScript environment supports `fetch` natively, you'll probably want
|
|
60
|
+
* to pass that; otherwise you can pass an equivalent (such as `fetch` via
|
|
61
|
+
* `node-fetch`).
|
|
62
|
+
* @param args.policyOptions - Options to pass to `createServicePolicy`, which
|
|
63
|
+
* is used to wrap each request. See {@link CreateServicePolicyOptions}.
|
|
64
|
+
* @param args.env - The environment to determine the correct API endpoints.
|
|
65
|
+
*/
|
|
66
|
+
constructor({ messenger, fetch: fetchFunction, policyOptions, env, }: {
|
|
67
|
+
messenger: ProfileMetricsServiceMessenger;
|
|
68
|
+
fetch: typeof fetch;
|
|
69
|
+
policyOptions?: CreateServicePolicyOptions;
|
|
70
|
+
env?: Env;
|
|
71
|
+
});
|
|
72
|
+
/**
|
|
73
|
+
* Registers a handler that will be called after a request returns a non-500
|
|
74
|
+
* response, causing a retry. Primarily useful in tests where timers are being
|
|
75
|
+
* mocked.
|
|
76
|
+
*
|
|
77
|
+
* @param listener - The handler to be called.
|
|
78
|
+
* @returns An object that can be used to unregister the handler. See
|
|
79
|
+
* {@link CockatielEvent}.
|
|
80
|
+
* @see {@link createServicePolicy}
|
|
81
|
+
*/
|
|
82
|
+
onRetry(listener: Parameters<ServicePolicy['onRetry']>[0]): import("cockatiel").IDisposable;
|
|
83
|
+
/**
|
|
84
|
+
* Registers a handler that will be called after a set number of retry rounds
|
|
85
|
+
* prove that requests to the API endpoint consistently return a 5xx response.
|
|
86
|
+
*
|
|
87
|
+
* @param listener - The handler to be called.
|
|
88
|
+
* @returns An object that can be used to unregister the handler. See
|
|
89
|
+
* {@link CockatielEvent}.
|
|
90
|
+
* @see {@link createServicePolicy}
|
|
91
|
+
*/
|
|
92
|
+
onBreak(listener: Parameters<ServicePolicy['onBreak']>[0]): import("cockatiel").IDisposable;
|
|
93
|
+
/**
|
|
94
|
+
* Registers a handler that will be called under one of two circumstances:
|
|
95
|
+
*
|
|
96
|
+
* 1. After a set number of retries prove that requests to the API
|
|
97
|
+
* consistently result in one of the following failures:
|
|
98
|
+
* 1. A connection initiation error
|
|
99
|
+
* 2. A connection reset error
|
|
100
|
+
* 3. A timeout error
|
|
101
|
+
* 4. A non-JSON response
|
|
102
|
+
* 5. A 502, 503, or 504 response
|
|
103
|
+
* 2. After a successful request is made to the API, but the response takes
|
|
104
|
+
* longer than a set duration to return.
|
|
105
|
+
*
|
|
106
|
+
* @param listener - The handler to be called.
|
|
107
|
+
* @returns An object that can be used to unregister the handler. See
|
|
108
|
+
* {@link CockatielEvent}.
|
|
109
|
+
*/
|
|
110
|
+
onDegraded(listener: Parameters<ServicePolicy['onDegraded']>[0]): import("cockatiel").IDisposable;
|
|
111
|
+
/**
|
|
112
|
+
* Makes a request to the API in order to update the user profile.
|
|
113
|
+
*
|
|
114
|
+
* @param data - The data to send in the profile update request.
|
|
115
|
+
* @returns The response from the API.
|
|
116
|
+
*/
|
|
117
|
+
updateProfile(data: ProfileMetricsUpdateRequest): Promise<void>;
|
|
118
|
+
}
|
|
119
|
+
export {};
|
|
120
|
+
//# sourceMappingURL=ProfileMetricsService.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ProfileMetricsService.d.mts","sourceRoot":"","sources":["../src/ProfileMetricsService.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,0BAA0B,EAC1B,aAAa,EACd,mCAAmC;AAEpC,OAAO,KAAK,EAAE,SAAS,EAAE,4BAA4B;AACrD,OAAO,KAAK,EAAE,wBAAwB,EAAE,0CAA0C;AAElF,OAAO,EAAE,KAAK,kCAAkC,EAAE,GAAG,EAAa,oBAAU;AAI5E;;;GAGG;AACH,eAAO,MAAM,WAAW,0BAA0B,CAAC;AAEnD;;GAEG;AACH,MAAM,MAAM,iBAAiB,GAAG;IAC9B,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,GAAG,MAAM,IAAI,MAAM,EAAE,EAAE,CAAC;CACjC,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,2BAA2B,GAAG;IACxC,aAAa,EAAE,MAAM,CAAC;IACtB,eAAe,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAChC,QAAQ,EAAE,iBAAiB,EAAE,CAAC;CAC/B,CAAC;AAMF;;GAEG;AACH,MAAM,MAAM,4BAA4B,GAAG,kCAAkC,CAAC;AAE9E;;GAEG;AACH,KAAK,cAAc,GACjB,wBAAwB,CAAC,sCAAsC,CAAC;AAElE;;GAEG;AACH,MAAM,MAAM,2BAA2B,GAAG,KAAK,CAAC;AAEhD;;;GAGG;AACH,KAAK,aAAa,GAAG,KAAK,CAAC;AAE3B;;;GAGG;AACH,MAAM,MAAM,8BAA8B,GAAG,SAAS,CACpD,OAAO,WAAW,EAClB,4BAA4B,GAAG,cAAc,EAC7C,2BAA2B,GAAG,aAAa,CAC5C,CAAC;AAIF,qBAAa,qBAAqB;;IAChC;;OAEG;IACH,QAAQ,CAAC,IAAI,EAAE,OAAO,WAAW,CAAC;IA4BlC;;;;;;;;;;;;OAYG;gBACS,EACV,SAAS,EACT,KAAK,EAAE,aAAa,EACpB,aAAkB,EAClB,GAAa,GACd,EAAE;QACD,SAAS,EAAE,8BAA8B,CAAC;QAC1C,KAAK,EAAE,OAAO,KAAK,CAAC;QACpB,aAAa,CAAC,EAAE,0BAA0B,CAAC;QAC3C,GAAG,CAAC,EAAE,GAAG,CAAC;KACX;IAaD;;;;;;;;;OASG;IACH,OAAO,CAAC,QAAQ,EAAE,UAAU,CAAC,aAAa,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC;IAIzD;;;;;;;;OAQG;IACH,OAAO,CAAC,QAAQ,EAAE,UAAU,CAAC,aAAa,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC;IAKzD;;;;;;;;;;;;;;;;OAgBG;IAEH,UAAU,CAAC,QAAQ,EAAE,UAAU,CAAC,aAAa,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,CAAC;IAI/D;;;;;OAKG;IACG,aAAa,CAAC,IAAI,EAAE,2BAA2B,GAAG,OAAO,CAAC,IAAI,CAAC;CA2BtE"}
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
|
|
2
|
+
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
3
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
4
|
+
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");
|
|
5
|
+
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
6
|
+
};
|
|
7
|
+
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
8
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
9
|
+
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");
|
|
10
|
+
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
11
|
+
};
|
|
12
|
+
var _a, _ProfileMetricsService_messenger, _ProfileMetricsService_fetch, _ProfileMetricsService_policy, _ProfileMetricsService_baseURL;
|
|
13
|
+
import { createServicePolicy, HttpError } from "@metamask/controller-utils";
|
|
14
|
+
import { Env, getEnvUrl } from "./index.mjs";
|
|
15
|
+
// === GENERAL ===
|
|
16
|
+
/**
|
|
17
|
+
* The name of the {@link ProfileMetricsService}, used to namespace the
|
|
18
|
+
* service's actions and events.
|
|
19
|
+
*/
|
|
20
|
+
export const serviceName = 'ProfileMetricsService';
|
|
21
|
+
// === MESSENGER ===
|
|
22
|
+
const MESSENGER_EXPOSED_METHODS = ['updateProfile'];
|
|
23
|
+
// === SERVICE DEFINITION ===
|
|
24
|
+
export class ProfileMetricsService {
|
|
25
|
+
/**
|
|
26
|
+
* Constructs a new ProfileMetricsService object.
|
|
27
|
+
*
|
|
28
|
+
* @param args - The constructor arguments.
|
|
29
|
+
* @param args.messenger - The messenger suited for this service.
|
|
30
|
+
* @param args.fetch - A function that can be used to make an HTTP request. If
|
|
31
|
+
* your JavaScript environment supports `fetch` natively, you'll probably want
|
|
32
|
+
* to pass that; otherwise you can pass an equivalent (such as `fetch` via
|
|
33
|
+
* `node-fetch`).
|
|
34
|
+
* @param args.policyOptions - Options to pass to `createServicePolicy`, which
|
|
35
|
+
* is used to wrap each request. See {@link CreateServicePolicyOptions}.
|
|
36
|
+
* @param args.env - The environment to determine the correct API endpoints.
|
|
37
|
+
*/
|
|
38
|
+
constructor({ messenger, fetch: fetchFunction, policyOptions = {}, env = Env.DEV, }) {
|
|
39
|
+
/**
|
|
40
|
+
* The messenger suited for this service.
|
|
41
|
+
*/
|
|
42
|
+
_ProfileMetricsService_messenger.set(this, void 0);
|
|
43
|
+
/**
|
|
44
|
+
* A function that can be used to make an HTTP request.
|
|
45
|
+
*/
|
|
46
|
+
_ProfileMetricsService_fetch.set(this, void 0);
|
|
47
|
+
/**
|
|
48
|
+
* The policy that wraps the request.
|
|
49
|
+
*
|
|
50
|
+
* @see {@link createServicePolicy}
|
|
51
|
+
*/
|
|
52
|
+
_ProfileMetricsService_policy.set(this, void 0);
|
|
53
|
+
/**
|
|
54
|
+
* The API base URL environment.
|
|
55
|
+
*/
|
|
56
|
+
_ProfileMetricsService_baseURL.set(this, void 0);
|
|
57
|
+
this.name = serviceName;
|
|
58
|
+
__classPrivateFieldSet(this, _ProfileMetricsService_messenger, messenger, "f");
|
|
59
|
+
__classPrivateFieldSet(this, _ProfileMetricsService_fetch, fetchFunction, "f");
|
|
60
|
+
__classPrivateFieldSet(this, _ProfileMetricsService_policy, createServicePolicy(policyOptions), "f");
|
|
61
|
+
__classPrivateFieldSet(this, _ProfileMetricsService_baseURL, getEnvUrl(env), "f");
|
|
62
|
+
__classPrivateFieldGet(this, _ProfileMetricsService_messenger, "f").registerMethodActionHandlers(this, MESSENGER_EXPOSED_METHODS);
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Registers a handler that will be called after a request returns a non-500
|
|
66
|
+
* response, causing a retry. Primarily useful in tests where timers are being
|
|
67
|
+
* mocked.
|
|
68
|
+
*
|
|
69
|
+
* @param listener - The handler to be called.
|
|
70
|
+
* @returns An object that can be used to unregister the handler. See
|
|
71
|
+
* {@link CockatielEvent}.
|
|
72
|
+
* @see {@link createServicePolicy}
|
|
73
|
+
*/
|
|
74
|
+
onRetry(listener) {
|
|
75
|
+
return __classPrivateFieldGet(this, _ProfileMetricsService_policy, "f").onRetry(listener);
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Registers a handler that will be called after a set number of retry rounds
|
|
79
|
+
* prove that requests to the API endpoint consistently return a 5xx response.
|
|
80
|
+
*
|
|
81
|
+
* @param listener - The handler to be called.
|
|
82
|
+
* @returns An object that can be used to unregister the handler. See
|
|
83
|
+
* {@link CockatielEvent}.
|
|
84
|
+
* @see {@link createServicePolicy}
|
|
85
|
+
*/
|
|
86
|
+
onBreak(listener) {
|
|
87
|
+
return __classPrivateFieldGet(this, _ProfileMetricsService_policy, "f").onBreak(listener);
|
|
88
|
+
}
|
|
89
|
+
/* eslint-disable jsdoc/check-indentation */
|
|
90
|
+
/**
|
|
91
|
+
* Registers a handler that will be called under one of two circumstances:
|
|
92
|
+
*
|
|
93
|
+
* 1. After a set number of retries prove that requests to the API
|
|
94
|
+
* consistently result in one of the following failures:
|
|
95
|
+
* 1. A connection initiation error
|
|
96
|
+
* 2. A connection reset error
|
|
97
|
+
* 3. A timeout error
|
|
98
|
+
* 4. A non-JSON response
|
|
99
|
+
* 5. A 502, 503, or 504 response
|
|
100
|
+
* 2. After a successful request is made to the API, but the response takes
|
|
101
|
+
* longer than a set duration to return.
|
|
102
|
+
*
|
|
103
|
+
* @param listener - The handler to be called.
|
|
104
|
+
* @returns An object that can be used to unregister the handler. See
|
|
105
|
+
* {@link CockatielEvent}.
|
|
106
|
+
*/
|
|
107
|
+
/* eslint-enable jsdoc/check-indentation */
|
|
108
|
+
onDegraded(listener) {
|
|
109
|
+
return __classPrivateFieldGet(this, _ProfileMetricsService_policy, "f").onDegraded(listener);
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* Makes a request to the API in order to update the user profile.
|
|
113
|
+
*
|
|
114
|
+
* @param data - The data to send in the profile update request.
|
|
115
|
+
* @returns The response from the API.
|
|
116
|
+
*/
|
|
117
|
+
async updateProfile(data) {
|
|
118
|
+
const authToken = await __classPrivateFieldGet(this, _ProfileMetricsService_messenger, "f").call('AuthenticationController:getBearerToken', data.entropySourceId || undefined);
|
|
119
|
+
await __classPrivateFieldGet(this, _ProfileMetricsService_policy, "f").execute(async () => {
|
|
120
|
+
const url = new URL(`${__classPrivateFieldGet(this, _ProfileMetricsService_baseURL, "f")}/profile/accounts`);
|
|
121
|
+
const localResponse = await __classPrivateFieldGet(this, _ProfileMetricsService_fetch, "f").call(this, url, {
|
|
122
|
+
method: 'PUT',
|
|
123
|
+
headers: {
|
|
124
|
+
Authorization: `Bearer ${authToken}`,
|
|
125
|
+
'Content-Type': 'application/json',
|
|
126
|
+
},
|
|
127
|
+
body: JSON.stringify({
|
|
128
|
+
metametrics_id: data.metametricsId,
|
|
129
|
+
accounts: data.accounts,
|
|
130
|
+
}),
|
|
131
|
+
});
|
|
132
|
+
if (!localResponse.ok) {
|
|
133
|
+
throw new HttpError(localResponse.status, `Fetching '${url.toString()}' failed with status '${localResponse.status}'`);
|
|
134
|
+
}
|
|
135
|
+
return localResponse;
|
|
136
|
+
});
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
_a = ProfileMetricsService, _ProfileMetricsService_messenger = new WeakMap(), _ProfileMetricsService_fetch = new WeakMap(), _ProfileMetricsService_policy = new WeakMap(), _ProfileMetricsService_baseURL = new WeakMap();
|
|
140
|
+
//# sourceMappingURL=ProfileMetricsService.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ProfileMetricsService.mjs","sourceRoot":"","sources":["../src/ProfileMetricsService.ts"],"names":[],"mappings":";;;;;;;;;;;;AAIA,OAAO,EAAE,mBAAmB,EAAE,SAAS,EAAE,mCAAmC;AAI5E,OAAO,EAA2C,GAAG,EAAE,SAAS,EAAE,oBAAU;AAE5E,kBAAkB;AAElB;;;GAGG;AACH,MAAM,CAAC,MAAM,WAAW,GAAG,uBAAuB,CAAC;AAmBnD,oBAAoB;AAEpB,MAAM,yBAAyB,GAAG,CAAC,eAAe,CAAU,CAAC;AAkC7D,6BAA6B;AAE7B,MAAM,OAAO,qBAAqB;IAgChC;;;;;;;;;;;;OAYG;IACH,YAAY,EACV,SAAS,EACT,KAAK,EAAE,aAAa,EACpB,aAAa,GAAG,EAAE,EAClB,GAAG,GAAG,GAAG,CAAC,GAAG,GAMd;QAjDD;;WAEG;QACM,mDAES;QAElB;;WAEG;QACM,+CAEK;QAEd;;;;WAIG;QACM,gDAAuB;QAEhC;;WAEG;QACM,iDAAiB;QA0BxB,IAAI,CAAC,IAAI,GAAG,WAAW,CAAC;QACxB,uBAAA,IAAI,oCAAc,SAAS,MAAA,CAAC;QAC5B,uBAAA,IAAI,gCAAU,aAAa,MAAA,CAAC;QAC5B,uBAAA,IAAI,iCAAW,mBAAmB,CAAC,aAAa,CAAC,MAAA,CAAC;QAClD,uBAAA,IAAI,kCAAY,SAAS,CAAC,GAAG,CAAC,MAAA,CAAC;QAE/B,uBAAA,IAAI,wCAAW,CAAC,4BAA4B,CAC1C,IAAI,EACJ,yBAAyB,CAC1B,CAAC;IACJ,CAAC;IAED;;;;;;;;;OASG;IACH,OAAO,CAAC,QAAiD;QACvD,OAAO,uBAAA,IAAI,qCAAQ,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;IACxC,CAAC;IAED;;;;;;;;OAQG;IACH,OAAO,CAAC,QAAiD;QACvD,OAAO,uBAAA,IAAI,qCAAQ,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;IACxC,CAAC;IAED,4CAA4C;IAC5C;;;;;;;;;;;;;;;;OAgBG;IACH,2CAA2C;IAC3C,UAAU,CAAC,QAAoD;QAC7D,OAAO,uBAAA,IAAI,qCAAQ,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC;IAC3C,CAAC;IAED;;;;;OAKG;IACH,KAAK,CAAC,aAAa,CAAC,IAAiC;QACnD,MAAM,SAAS,GAAG,MAAM,uBAAA,IAAI,wCAAW,CAAC,IAAI,CAC1C,yCAAyC,EACzC,IAAI,CAAC,eAAe,IAAI,SAAS,CAClC,CAAC;QACF,MAAM,uBAAA,IAAI,qCAAQ,CAAC,OAAO,CAAC,KAAK,IAAI,EAAE;YACpC,MAAM,GAAG,GAAG,IAAI,GAAG,CAAC,GAAG,uBAAA,IAAI,sCAAS,mBAAmB,CAAC,CAAC;YACzD,MAAM,aAAa,GAAG,MAAM,uBAAA,IAAI,oCAAO,MAAX,IAAI,EAAQ,GAAG,EAAE;gBAC3C,MAAM,EAAE,KAAK;gBACb,OAAO,EAAE;oBACP,aAAa,EAAE,UAAU,SAAS,EAAE;oBACpC,cAAc,EAAE,kBAAkB;iBACnC;gBACD,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC;oBACnB,cAAc,EAAE,IAAI,CAAC,aAAa;oBAClC,QAAQ,EAAE,IAAI,CAAC,QAAQ;iBACxB,CAAC;aACH,CAAC,CAAC;YACH,IAAI,CAAC,aAAa,CAAC,EAAE,EAAE,CAAC;gBACtB,MAAM,IAAI,SAAS,CACjB,aAAa,CAAC,MAAM,EACpB,aAAa,GAAG,CAAC,QAAQ,EAAE,yBAAyB,aAAa,CAAC,MAAM,GAAG,CAC5E,CAAC;YACJ,CAAC;YACD,OAAO,aAAa,CAAC;QACvB,CAAC,CAAC,CAAC;IACL,CAAC;CACF","sourcesContent":["import type {\n CreateServicePolicyOptions,\n ServicePolicy,\n} from '@metamask/controller-utils';\nimport { createServicePolicy, HttpError } from '@metamask/controller-utils';\nimport type { Messenger } from '@metamask/messenger';\nimport type { AuthenticationController } from '@metamask/profile-sync-controller';\n\nimport { type ProfileMetricsServiceMethodActions, Env, getEnvUrl } from '.';\n\n// === GENERAL ===\n\n/**\n * The name of the {@link ProfileMetricsService}, used to namespace the\n * service's actions and events.\n */\nexport const serviceName = 'ProfileMetricsService';\n\n/**\n * An account address along with its associated scopes.\n */\nexport type AccountWithScopes = {\n address: string;\n scopes: `${string}:${string}`[];\n};\n\n/**\n * The shape of the request object for updating the user profile.\n */\nexport type ProfileMetricsUpdateRequest = {\n metametricsId: string;\n entropySourceId?: string | null;\n accounts: AccountWithScopes[];\n};\n\n// === MESSENGER ===\n\nconst MESSENGER_EXPOSED_METHODS = ['updateProfile'] as const;\n\n/**\n * Actions that {@link ProfileMetricsService} exposes to other consumers.\n */\nexport type ProfileMetricsServiceActions = ProfileMetricsServiceMethodActions;\n\n/**\n * Actions from other messengers that {@link ProfileMetricsService} calls.\n */\ntype AllowedActions =\n AuthenticationController.AuthenticationControllerGetBearerToken;\n\n/**\n * Events that {@link ProfileMetricsService} exposes to other consumers.\n */\nexport type ProfileMetricsServiceEvents = never;\n\n/**\n * Events from other messengers that {@link ProfileMetricsService} subscribes\n * to.\n */\ntype AllowedEvents = never;\n\n/**\n * The messenger which is restricted to actions and events accessed by\n * {@link ProfileMetricsService}.\n */\nexport type ProfileMetricsServiceMessenger = Messenger<\n typeof serviceName,\n ProfileMetricsServiceActions | AllowedActions,\n ProfileMetricsServiceEvents | AllowedEvents\n>;\n\n// === SERVICE DEFINITION ===\n\nexport class ProfileMetricsService {\n /**\n * The name of the service.\n */\n readonly name: typeof serviceName;\n\n /**\n * The messenger suited for this service.\n */\n readonly #messenger: ConstructorParameters<\n typeof ProfileMetricsService\n >[0]['messenger'];\n\n /**\n * A function that can be used to make an HTTP request.\n */\n readonly #fetch: ConstructorParameters<\n typeof ProfileMetricsService\n >[0]['fetch'];\n\n /**\n * The policy that wraps the request.\n *\n * @see {@link createServicePolicy}\n */\n readonly #policy: ServicePolicy;\n\n /**\n * The API base URL environment.\n */\n readonly #baseURL: string;\n\n /**\n * Constructs a new ProfileMetricsService object.\n *\n * @param args - The constructor arguments.\n * @param args.messenger - The messenger suited for this service.\n * @param args.fetch - A function that can be used to make an HTTP request. If\n * your JavaScript environment supports `fetch` natively, you'll probably want\n * to pass that; otherwise you can pass an equivalent (such as `fetch` via\n * `node-fetch`).\n * @param args.policyOptions - Options to pass to `createServicePolicy`, which\n * is used to wrap each request. See {@link CreateServicePolicyOptions}.\n * @param args.env - The environment to determine the correct API endpoints.\n */\n constructor({\n messenger,\n fetch: fetchFunction,\n policyOptions = {},\n env = Env.DEV,\n }: {\n messenger: ProfileMetricsServiceMessenger;\n fetch: typeof fetch;\n policyOptions?: CreateServicePolicyOptions;\n env?: Env;\n }) {\n this.name = serviceName;\n this.#messenger = messenger;\n this.#fetch = fetchFunction;\n this.#policy = createServicePolicy(policyOptions);\n this.#baseURL = getEnvUrl(env);\n\n this.#messenger.registerMethodActionHandlers(\n this,\n MESSENGER_EXPOSED_METHODS,\n );\n }\n\n /**\n * Registers a handler that will be called after a request returns a non-500\n * response, causing a retry. Primarily useful in tests where timers are being\n * mocked.\n *\n * @param listener - The handler to be called.\n * @returns An object that can be used to unregister the handler. See\n * {@link CockatielEvent}.\n * @see {@link createServicePolicy}\n */\n onRetry(listener: Parameters<ServicePolicy['onRetry']>[0]) {\n return this.#policy.onRetry(listener);\n }\n\n /**\n * Registers a handler that will be called after a set number of retry rounds\n * prove that requests to the API endpoint consistently return a 5xx response.\n *\n * @param listener - The handler to be called.\n * @returns An object that can be used to unregister the handler. See\n * {@link CockatielEvent}.\n * @see {@link createServicePolicy}\n */\n onBreak(listener: Parameters<ServicePolicy['onBreak']>[0]) {\n return this.#policy.onBreak(listener);\n }\n\n /* eslint-disable jsdoc/check-indentation */\n /**\n * Registers a handler that will be called under one of two circumstances:\n *\n * 1. After a set number of retries prove that requests to the API\n * consistently result in one of the following failures:\n * 1. A connection initiation error\n * 2. A connection reset error\n * 3. A timeout error\n * 4. A non-JSON response\n * 5. A 502, 503, or 504 response\n * 2. After a successful request is made to the API, but the response takes\n * longer than a set duration to return.\n *\n * @param listener - The handler to be called.\n * @returns An object that can be used to unregister the handler. See\n * {@link CockatielEvent}.\n */\n /* eslint-enable jsdoc/check-indentation */\n onDegraded(listener: Parameters<ServicePolicy['onDegraded']>[0]) {\n return this.#policy.onDegraded(listener);\n }\n\n /**\n * Makes a request to the API in order to update the user profile.\n *\n * @param data - The data to send in the profile update request.\n * @returns The response from the API.\n */\n async updateProfile(data: ProfileMetricsUpdateRequest): Promise<void> {\n const authToken = await this.#messenger.call(\n 'AuthenticationController:getBearerToken',\n data.entropySourceId || undefined,\n );\n await this.#policy.execute(async () => {\n const url = new URL(`${this.#baseURL}/profile/accounts`);\n const localResponse = await this.#fetch(url, {\n method: 'PUT',\n headers: {\n Authorization: `Bearer ${authToken}`,\n 'Content-Type': 'application/json',\n },\n body: JSON.stringify({\n metametrics_id: data.metametricsId,\n accounts: data.accounts,\n }),\n });\n if (!localResponse.ok) {\n throw new HttpError(\n localResponse.status,\n `Fetching '${url.toString()}' failed with status '${localResponse.status}'`,\n );\n }\n return localResponse;\n });\n }\n}\n"]}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getEnvUrl = exports.Env = void 0;
|
|
4
|
+
var Env;
|
|
5
|
+
(function (Env) {
|
|
6
|
+
Env["DEV"] = "dev";
|
|
7
|
+
Env["UAT"] = "uat";
|
|
8
|
+
Env["PRD"] = "prd";
|
|
9
|
+
})(Env || (exports.Env = Env = {}));
|
|
10
|
+
const ENV_URLS = {
|
|
11
|
+
dev: 'https://authentication.dev-api.cx.metamask.io/api/v2',
|
|
12
|
+
uat: 'https://authentication.uat-api.cx.metamask.io/api/v2',
|
|
13
|
+
prd: 'https://authentication.api.cx.metamask.io/api/v2',
|
|
14
|
+
};
|
|
15
|
+
/**
|
|
16
|
+
* Validates and returns correct environment endpoints
|
|
17
|
+
*
|
|
18
|
+
* @param env - environment field
|
|
19
|
+
* @returns the correct environment url
|
|
20
|
+
* @throws on invalid environment passed
|
|
21
|
+
*/
|
|
22
|
+
function getEnvUrl(env) {
|
|
23
|
+
if (!ENV_URLS[env]) {
|
|
24
|
+
throw new Error('invalid environment configuration');
|
|
25
|
+
}
|
|
26
|
+
return ENV_URLS[env];
|
|
27
|
+
}
|
|
28
|
+
exports.getEnvUrl = getEnvUrl;
|
|
29
|
+
//# sourceMappingURL=constants.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.cjs","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":";;;AAAA,IAAY,GAIX;AAJD,WAAY,GAAG;IACb,kBAAW,CAAA;IACX,kBAAW,CAAA;IACX,kBAAW,CAAA;AACb,CAAC,EAJW,GAAG,mBAAH,GAAG,QAId;AAED,MAAM,QAAQ,GAAwB;IACpC,GAAG,EAAE,sDAAsD;IAC3D,GAAG,EAAE,sDAAsD;IAC3D,GAAG,EAAE,kDAAkD;CACxD,CAAC;AAEF;;;;;;GAMG;AACH,SAAgB,SAAS,CAAC,GAAQ;IAChC,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE,CAAC;QACnB,MAAM,IAAI,KAAK,CAAC,mCAAmC,CAAC,CAAC;IACvD,CAAC;IACD,OAAO,QAAQ,CAAC,GAAG,CAAC,CAAC;AACvB,CAAC;AALD,8BAKC","sourcesContent":["export enum Env {\n DEV = 'dev',\n UAT = 'uat',\n PRD = 'prd',\n}\n\nconst ENV_URLS: Record<Env, string> = {\n dev: 'https://authentication.dev-api.cx.metamask.io/api/v2',\n uat: 'https://authentication.uat-api.cx.metamask.io/api/v2',\n prd: 'https://authentication.api.cx.metamask.io/api/v2',\n};\n\n/**\n * Validates and returns correct environment endpoints\n *\n * @param env - environment field\n * @returns the correct environment url\n * @throws on invalid environment passed\n */\nexport function getEnvUrl(env: Env): string {\n if (!ENV_URLS[env]) {\n throw new Error('invalid environment configuration');\n }\n return ENV_URLS[env];\n}\n"]}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export declare enum Env {
|
|
2
|
+
DEV = "dev",
|
|
3
|
+
UAT = "uat",
|
|
4
|
+
PRD = "prd"
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* Validates and returns correct environment endpoints
|
|
8
|
+
*
|
|
9
|
+
* @param env - environment field
|
|
10
|
+
* @returns the correct environment url
|
|
11
|
+
* @throws on invalid environment passed
|
|
12
|
+
*/
|
|
13
|
+
export declare function getEnvUrl(env: Env): string;
|
|
14
|
+
//# sourceMappingURL=constants.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.d.cts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA,oBAAY,GAAG;IACb,GAAG,QAAQ;IACX,GAAG,QAAQ;IACX,GAAG,QAAQ;CACZ;AAQD;;;;;;GAMG;AACH,wBAAgB,SAAS,CAAC,GAAG,EAAE,GAAG,GAAG,MAAM,CAK1C"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export declare enum Env {
|
|
2
|
+
DEV = "dev",
|
|
3
|
+
UAT = "uat",
|
|
4
|
+
PRD = "prd"
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* Validates and returns correct environment endpoints
|
|
8
|
+
*
|
|
9
|
+
* @param env - environment field
|
|
10
|
+
* @returns the correct environment url
|
|
11
|
+
* @throws on invalid environment passed
|
|
12
|
+
*/
|
|
13
|
+
export declare function getEnvUrl(env: Env): string;
|
|
14
|
+
//# sourceMappingURL=constants.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.d.mts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA,oBAAY,GAAG;IACb,GAAG,QAAQ;IACX,GAAG,QAAQ;IACX,GAAG,QAAQ;CACZ;AAQD;;;;;;GAMG;AACH,wBAAgB,SAAS,CAAC,GAAG,EAAE,GAAG,GAAG,MAAM,CAK1C"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
export var Env;
|
|
2
|
+
(function (Env) {
|
|
3
|
+
Env["DEV"] = "dev";
|
|
4
|
+
Env["UAT"] = "uat";
|
|
5
|
+
Env["PRD"] = "prd";
|
|
6
|
+
})(Env || (Env = {}));
|
|
7
|
+
const ENV_URLS = {
|
|
8
|
+
dev: 'https://authentication.dev-api.cx.metamask.io/api/v2',
|
|
9
|
+
uat: 'https://authentication.uat-api.cx.metamask.io/api/v2',
|
|
10
|
+
prd: 'https://authentication.api.cx.metamask.io/api/v2',
|
|
11
|
+
};
|
|
12
|
+
/**
|
|
13
|
+
* Validates and returns correct environment endpoints
|
|
14
|
+
*
|
|
15
|
+
* @param env - environment field
|
|
16
|
+
* @returns the correct environment url
|
|
17
|
+
* @throws on invalid environment passed
|
|
18
|
+
*/
|
|
19
|
+
export function getEnvUrl(env) {
|
|
20
|
+
if (!ENV_URLS[env]) {
|
|
21
|
+
throw new Error('invalid environment configuration');
|
|
22
|
+
}
|
|
23
|
+
return ENV_URLS[env];
|
|
24
|
+
}
|
|
25
|
+
//# sourceMappingURL=constants.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.mjs","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA,MAAM,CAAN,IAAY,GAIX;AAJD,WAAY,GAAG;IACb,kBAAW,CAAA;IACX,kBAAW,CAAA;IACX,kBAAW,CAAA;AACb,CAAC,EAJW,GAAG,KAAH,GAAG,QAId;AAED,MAAM,QAAQ,GAAwB;IACpC,GAAG,EAAE,sDAAsD;IAC3D,GAAG,EAAE,sDAAsD;IAC3D,GAAG,EAAE,kDAAkD;CACxD,CAAC;AAEF;;;;;;GAMG;AACH,MAAM,UAAU,SAAS,CAAC,GAAQ;IAChC,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE,CAAC;QACnB,MAAM,IAAI,KAAK,CAAC,mCAAmC,CAAC,CAAC;IACvD,CAAC;IACD,OAAO,QAAQ,CAAC,GAAG,CAAC,CAAC;AACvB,CAAC","sourcesContent":["export enum Env {\n DEV = 'dev',\n UAT = 'uat',\n PRD = 'prd',\n}\n\nconst ENV_URLS: Record<Env, string> = {\n dev: 'https://authentication.dev-api.cx.metamask.io/api/v2',\n uat: 'https://authentication.uat-api.cx.metamask.io/api/v2',\n prd: 'https://authentication.api.cx.metamask.io/api/v2',\n};\n\n/**\n * Validates and returns correct environment endpoints\n *\n * @param env - environment field\n * @returns the correct environment url\n * @throws on invalid environment passed\n */\nexport function getEnvUrl(env: Env): string {\n if (!ENV_URLS[env]) {\n throw new Error('invalid environment configuration');\n }\n return ENV_URLS[env];\n}\n"]}
|
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Env = exports.getEnvUrl = exports.serviceName = exports.ProfileMetricsService = exports.getDefaultProfileMetricsControllerState = exports.ProfileMetricsController = void 0;
|
|
4
|
+
var ProfileMetricsController_1 = require("./ProfileMetricsController.cjs");
|
|
5
|
+
Object.defineProperty(exports, "ProfileMetricsController", { enumerable: true, get: function () { return ProfileMetricsController_1.ProfileMetricsController; } });
|
|
6
|
+
Object.defineProperty(exports, "getDefaultProfileMetricsControllerState", { enumerable: true, get: function () { return ProfileMetricsController_1.getDefaultProfileMetricsControllerState; } });
|
|
7
|
+
var ProfileMetricsService_1 = require("./ProfileMetricsService.cjs");
|
|
8
|
+
Object.defineProperty(exports, "ProfileMetricsService", { enumerable: true, get: function () { return ProfileMetricsService_1.ProfileMetricsService; } });
|
|
9
|
+
Object.defineProperty(exports, "serviceName", { enumerable: true, get: function () { return ProfileMetricsService_1.serviceName; } });
|
|
10
|
+
var constants_1 = require("./constants.cjs");
|
|
11
|
+
Object.defineProperty(exports, "getEnvUrl", { enumerable: true, get: function () { return constants_1.getEnvUrl; } });
|
|
12
|
+
Object.defineProperty(exports, "Env", { enumerable: true, get: function () { return constants_1.Env; } });
|
|
13
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.cjs","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAQA,2EAGoC;AAFlC,oIAAA,wBAAwB,OAAA;AACxB,mJAAA,uCAAuC,OAAA;AAQzC,qEAA6E;AAApE,8HAAA,qBAAqB,OAAA;AAAE,oHAAA,WAAW,OAAA;AAE3C,6CAA6C;AAApC,sGAAA,SAAS,OAAA;AAAE,gGAAA,GAAG,OAAA","sourcesContent":["export type {\n ProfileMetricsControllerActions,\n ProfileMetricsControllerEvents,\n ProfileMetricsControllerGetStateAction,\n ProfileMetricsControllerMessenger,\n ProfileMetricsControllerState,\n ProfileMetricsControllerStateChangeEvent,\n} from './ProfileMetricsController';\nexport {\n ProfileMetricsController,\n getDefaultProfileMetricsControllerState,\n} from './ProfileMetricsController';\nexport type {\n ProfileMetricsServiceActions,\n ProfileMetricsServiceEvents,\n ProfileMetricsServiceMessenger,\n ProfileMetricsUpdateRequest,\n} from './ProfileMetricsService';\nexport { ProfileMetricsService, serviceName } from './ProfileMetricsService';\nexport type { ProfileMetricsServiceMethodActions } from './ProfileMetricsService-method-action-types';\nexport { getEnvUrl, Env } from './constants';\n"]}
|
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export type { ProfileMetricsControllerActions, ProfileMetricsControllerEvents, ProfileMetricsControllerGetStateAction, ProfileMetricsControllerMessenger, ProfileMetricsControllerState, ProfileMetricsControllerStateChangeEvent, } from "./ProfileMetricsController.cjs";
|
|
2
|
+
export { ProfileMetricsController, getDefaultProfileMetricsControllerState, } from "./ProfileMetricsController.cjs";
|
|
3
|
+
export type { ProfileMetricsServiceActions, ProfileMetricsServiceEvents, ProfileMetricsServiceMessenger, ProfileMetricsUpdateRequest, } from "./ProfileMetricsService.cjs";
|
|
4
|
+
export { ProfileMetricsService, serviceName } from "./ProfileMetricsService.cjs";
|
|
5
|
+
export type { ProfileMetricsServiceMethodActions } from "./ProfileMetricsService-method-action-types.cjs";
|
|
6
|
+
export { getEnvUrl, Env } from "./constants.cjs";
|
|
7
|
+
//# sourceMappingURL=index.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.cts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,YAAY,EACV,+BAA+B,EAC/B,8BAA8B,EAC9B,sCAAsC,EACtC,iCAAiC,EACjC,6BAA6B,EAC7B,wCAAwC,GACzC,uCAAmC;AACpC,OAAO,EACL,wBAAwB,EACxB,uCAAuC,GACxC,uCAAmC;AACpC,YAAY,EACV,4BAA4B,EAC5B,2BAA2B,EAC3B,8BAA8B,EAC9B,2BAA2B,GAC5B,oCAAgC;AACjC,OAAO,EAAE,qBAAqB,EAAE,WAAW,EAAE,oCAAgC;AAC7E,YAAY,EAAE,kCAAkC,EAAE,wDAAoD;AACtG,OAAO,EAAE,SAAS,EAAE,GAAG,EAAE,wBAAoB"}
|
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export type { ProfileMetricsControllerActions, ProfileMetricsControllerEvents, ProfileMetricsControllerGetStateAction, ProfileMetricsControllerMessenger, ProfileMetricsControllerState, ProfileMetricsControllerStateChangeEvent, } from "./ProfileMetricsController.mjs";
|
|
2
|
+
export { ProfileMetricsController, getDefaultProfileMetricsControllerState, } from "./ProfileMetricsController.mjs";
|
|
3
|
+
export type { ProfileMetricsServiceActions, ProfileMetricsServiceEvents, ProfileMetricsServiceMessenger, ProfileMetricsUpdateRequest, } from "./ProfileMetricsService.mjs";
|
|
4
|
+
export { ProfileMetricsService, serviceName } from "./ProfileMetricsService.mjs";
|
|
5
|
+
export type { ProfileMetricsServiceMethodActions } from "./ProfileMetricsService-method-action-types.mjs";
|
|
6
|
+
export { getEnvUrl, Env } from "./constants.mjs";
|
|
7
|
+
//# sourceMappingURL=index.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.mts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,YAAY,EACV,+BAA+B,EAC/B,8BAA8B,EAC9B,sCAAsC,EACtC,iCAAiC,EACjC,6BAA6B,EAC7B,wCAAwC,GACzC,uCAAmC;AACpC,OAAO,EACL,wBAAwB,EACxB,uCAAuC,GACxC,uCAAmC;AACpC,YAAY,EACV,4BAA4B,EAC5B,2BAA2B,EAC3B,8BAA8B,EAC9B,2BAA2B,GAC5B,oCAAgC;AACjC,OAAO,EAAE,qBAAqB,EAAE,WAAW,EAAE,oCAAgC;AAC7E,YAAY,EAAE,kCAAkC,EAAE,wDAAoD;AACtG,OAAO,EAAE,SAAS,EAAE,GAAG,EAAE,wBAAoB"}
|
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export { ProfileMetricsController, getDefaultProfileMetricsControllerState } from "./ProfileMetricsController.mjs";
|
|
2
|
+
export { ProfileMetricsService, serviceName } from "./ProfileMetricsService.mjs";
|
|
3
|
+
export { getEnvUrl, Env } from "./constants.mjs";
|
|
4
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.mjs","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAQA,OAAO,EACL,wBAAwB,EACxB,uCAAuC,EACxC,uCAAmC;AAOpC,OAAO,EAAE,qBAAqB,EAAE,WAAW,EAAE,oCAAgC;AAE7E,OAAO,EAAE,SAAS,EAAE,GAAG,EAAE,wBAAoB","sourcesContent":["export type {\n ProfileMetricsControllerActions,\n ProfileMetricsControllerEvents,\n ProfileMetricsControllerGetStateAction,\n ProfileMetricsControllerMessenger,\n ProfileMetricsControllerState,\n ProfileMetricsControllerStateChangeEvent,\n} from './ProfileMetricsController';\nexport {\n ProfileMetricsController,\n getDefaultProfileMetricsControllerState,\n} from './ProfileMetricsController';\nexport type {\n ProfileMetricsServiceActions,\n ProfileMetricsServiceEvents,\n ProfileMetricsServiceMessenger,\n ProfileMetricsUpdateRequest,\n} from './ProfileMetricsService';\nexport { ProfileMetricsService, serviceName } from './ProfileMetricsService';\nexport type { ProfileMetricsServiceMethodActions } from './ProfileMetricsService-method-action-types';\nexport { getEnvUrl, Env } from './constants';\n"]}
|
package/package.json
ADDED
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@metamask-previews/profile-metrics-controller",
|
|
3
|
+
"version": "0.0.0-preview-e0d310b4",
|
|
4
|
+
"description": "Sample package to illustrate best practices for controllers",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"MetaMask",
|
|
7
|
+
"Ethereum"
|
|
8
|
+
],
|
|
9
|
+
"homepage": "https://github.com/MetaMask/core/tree/main/packages/profile-metrics-controller#readme",
|
|
10
|
+
"bugs": {
|
|
11
|
+
"url": "https://github.com/MetaMask/core/issues"
|
|
12
|
+
},
|
|
13
|
+
"repository": {
|
|
14
|
+
"type": "git",
|
|
15
|
+
"url": "https://github.com/MetaMask/core.git"
|
|
16
|
+
},
|
|
17
|
+
"license": "MIT",
|
|
18
|
+
"sideEffects": false,
|
|
19
|
+
"exports": {
|
|
20
|
+
".": {
|
|
21
|
+
"import": {
|
|
22
|
+
"types": "./dist/index.d.mts",
|
|
23
|
+
"default": "./dist/index.mjs"
|
|
24
|
+
},
|
|
25
|
+
"require": {
|
|
26
|
+
"types": "./dist/index.d.cts",
|
|
27
|
+
"default": "./dist/index.cjs"
|
|
28
|
+
}
|
|
29
|
+
},
|
|
30
|
+
"./package.json": "./package.json"
|
|
31
|
+
},
|
|
32
|
+
"main": "./dist/index.cjs",
|
|
33
|
+
"types": "./dist/index.d.cts",
|
|
34
|
+
"files": [
|
|
35
|
+
"dist/"
|
|
36
|
+
],
|
|
37
|
+
"scripts": {
|
|
38
|
+
"build": "ts-bridge --project tsconfig.build.json --verbose --clean --no-references",
|
|
39
|
+
"build:all": "ts-bridge --project tsconfig.build.json --verbose --clean",
|
|
40
|
+
"build:docs": "typedoc",
|
|
41
|
+
"changelog:update": "../../scripts/update-changelog.sh @metamask/profile-metrics-controller",
|
|
42
|
+
"changelog:validate": "../../scripts/validate-changelog.sh @metamask/profile-metrics-controller",
|
|
43
|
+
"publish:preview": "yarn npm publish --tag preview",
|
|
44
|
+
"since-latest-release": "../../scripts/since-latest-release.sh",
|
|
45
|
+
"test": "NODE_OPTIONS=--experimental-vm-modules jest --reporters=jest-silent-reporter",
|
|
46
|
+
"test:clean": "NODE_OPTIONS=--experimental-vm-modules jest --clearCache",
|
|
47
|
+
"test:verbose": "NODE_OPTIONS=--experimental-vm-modules jest --verbose",
|
|
48
|
+
"test:watch": "NODE_OPTIONS=--experimental-vm-modules jest --watch"
|
|
49
|
+
},
|
|
50
|
+
"dependencies": {
|
|
51
|
+
"@metamask/accounts-controller": "^35.0.0",
|
|
52
|
+
"@metamask/base-controller": "^9.0.0",
|
|
53
|
+
"@metamask/controller-utils": "^11.16.0",
|
|
54
|
+
"@metamask/keyring-controller": "^25.0.0",
|
|
55
|
+
"@metamask/messenger": "^0.3.0",
|
|
56
|
+
"@metamask/polling-controller": "^16.0.0",
|
|
57
|
+
"@metamask/profile-sync-controller": "^27.0.0",
|
|
58
|
+
"@metamask/utils": "^11.8.1",
|
|
59
|
+
"async-mutex": "^0.5.0"
|
|
60
|
+
},
|
|
61
|
+
"devDependencies": {
|
|
62
|
+
"@metamask/auto-changelog": "^3.4.4",
|
|
63
|
+
"@metamask/keyring-internal-api": "^9.0.0",
|
|
64
|
+
"@ts-bridge/cli": "^0.6.4",
|
|
65
|
+
"@types/jest": "^27.4.1",
|
|
66
|
+
"deepmerge": "^4.2.2",
|
|
67
|
+
"jest": "^27.5.1",
|
|
68
|
+
"nock": "^13.3.1",
|
|
69
|
+
"sinon": "^9.2.4",
|
|
70
|
+
"ts-jest": "^27.1.4",
|
|
71
|
+
"typedoc": "^0.24.8",
|
|
72
|
+
"typedoc-plugin-missing-exports": "^2.0.0",
|
|
73
|
+
"typescript": "~5.3.3"
|
|
74
|
+
},
|
|
75
|
+
"engines": {
|
|
76
|
+
"node": "^18.18 || >=20"
|
|
77
|
+
},
|
|
78
|
+
"publishConfig": {
|
|
79
|
+
"access": "public",
|
|
80
|
+
"registry": "https://registry.npmjs.org/"
|
|
81
|
+
}
|
|
82
|
+
}
|