@metamask-previews/authenticated-user-storage 0.0.0-preview-8e9c439
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 +15 -0
- package/LICENSE +20 -0
- package/README.md +135 -0
- package/dist/authenticated-user-storage-method-action-types.cjs +7 -0
- package/dist/authenticated-user-storage-method-action-types.cjs.map +1 -0
- package/dist/authenticated-user-storage-method-action-types.d.cts +58 -0
- package/dist/authenticated-user-storage-method-action-types.d.cts.map +1 -0
- package/dist/authenticated-user-storage-method-action-types.d.mts +58 -0
- package/dist/authenticated-user-storage-method-action-types.d.mts.map +1 -0
- package/dist/authenticated-user-storage-method-action-types.mjs +6 -0
- package/dist/authenticated-user-storage-method-action-types.mjs.map +1 -0
- package/dist/authenticated-user-storage.cjs +218 -0
- package/dist/authenticated-user-storage.cjs.map +1 -0
- package/dist/authenticated-user-storage.d.cts +123 -0
- package/dist/authenticated-user-storage.d.cts.map +1 -0
- package/dist/authenticated-user-storage.d.mts +123 -0
- package/dist/authenticated-user-storage.d.mts.map +1 -0
- package/dist/authenticated-user-storage.mjs +213 -0
- package/dist/authenticated-user-storage.mjs.map +1 -0
- package/dist/env.cjs +24 -0
- package/dist/env.cjs.map +1 -0
- package/dist/env.d.cts +10 -0
- package/dist/env.d.cts.map +1 -0
- package/dist/env.d.mts +10 -0
- package/dist/env.d.mts.map +1 -0
- package/dist/env.mjs +20 -0
- package/dist/env.mjs.map +1 -0
- package/dist/index.cjs +9 -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 +3 -0
- package/dist/index.mjs.map +1 -0
- package/dist/types.cjs +3 -0
- package/dist/types.cjs.map +1 -0
- package/dist/types.d.cts +90 -0
- package/dist/types.d.cts.map +1 -0
- package/dist/types.d.mts +90 -0
- package/dist/types.d.mts.map +1 -0
- package/dist/types.mjs +2 -0
- package/dist/types.mjs.map +1 -0
- package/dist/validators.cjs +91 -0
- package/dist/validators.cjs.map +1 -0
- package/dist/validators.d.cts +16 -0
- package/dist/validators.d.cts.map +1 -0
- package/dist/validators.d.mts +16 -0
- package/dist/validators.d.mts.map +1 -0
- package/dist/validators.mjs +86 -0
- package/dist/validators.mjs.map +1 -0
- package/package.json +78 -0
|
@@ -0,0 +1,123 @@
|
|
|
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.cjs";
|
|
6
|
+
import type { Environment } from "./env.cjs";
|
|
7
|
+
import type { ClientType, DelegationResponse, DelegationSubmission, NotificationPreferences } from "./types.cjs";
|
|
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
|
+
export {};
|
|
123
|
+
//# sourceMappingURL=authenticated-user-storage.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
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,6DAAyD;AACrH,OAAO,KAAK,EAAE,WAAW,EAAE,kBAAc;AAEzC,OAAO,KAAK,EACV,UAAU,EACV,kBAAkB,EAClB,oBAAoB,EACpB,uBAAuB,EACxB,oBAAgB;AAQjB;;;GAGG;AACH,eAAO,MAAM,WAAW,oCAAoC,CAAC;AAE7D;;;;;GAKG;AACH,wBAAgB,0BAA0B,CAAC,WAAW,EAAE,WAAW,GAAG,MAAM,CAE3E;AAYD;;GAEG;AACH,MAAM,MAAM,+CAA+C,GACzD,kCAAkC,CAAC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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;CA8CjB"}
|
|
@@ -0,0 +1,123 @@
|
|
|
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 { 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
|
+
export {};
|
|
123
|
+
//# sourceMappingURL=authenticated-user-storage.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
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,6DAAyD;AACrH,OAAO,KAAK,EAAE,WAAW,EAAE,kBAAc;AAEzC,OAAO,KAAK,EACV,UAAU,EACV,kBAAkB,EAClB,oBAAoB,EACpB,uBAAuB,EACxB,oBAAgB;AAQjB;;;GAGG;AACH,eAAO,MAAM,WAAW,oCAAoC,CAAC;AAE7D;;;;;GAKG;AACH,wBAAgB,0BAA0B,CAAC,WAAW,EAAE,WAAW,GAAG,MAAM,CAE3E;AAYD;;GAEG;AACH,MAAM,MAAM,+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AAC;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;CA8CjB"}
|
|
@@ -0,0 +1,213 @@
|
|
|
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 _AuthenticatedUserStorageService_instances, _AuthenticatedUserStorageService_environment, _AuthenticatedUserStorageService_getHeaders;
|
|
13
|
+
import { BaseDataService } from "@metamask/base-data-service";
|
|
14
|
+
import { HttpError } from "@metamask/controller-utils";
|
|
15
|
+
import { getUserStorageApiUrl } from "./env.mjs";
|
|
16
|
+
import { assertDelegationResponseArray, assertNotificationPreferences } from "./validators.mjs";
|
|
17
|
+
// === GENERAL ===
|
|
18
|
+
/**
|
|
19
|
+
* The name of the {@link AuthenticatedUserStorageService} service, used to
|
|
20
|
+
* namespace the service's actions and events.
|
|
21
|
+
*/
|
|
22
|
+
export const serviceName = 'AuthenticatedUserStorageService';
|
|
23
|
+
/**
|
|
24
|
+
* Builds the versioned API base URL for a given environment.
|
|
25
|
+
*
|
|
26
|
+
* @param environment - The target environment.
|
|
27
|
+
* @returns The base URL including the `/api/v1` path segment.
|
|
28
|
+
*/
|
|
29
|
+
export function getAuthenticatedStorageUrl(environment) {
|
|
30
|
+
return `${getUserStorageApiUrl(environment)}/api/v1`;
|
|
31
|
+
}
|
|
32
|
+
// === MESSENGER ===
|
|
33
|
+
const MESSENGER_EXPOSED_METHODS = [
|
|
34
|
+
'listDelegations',
|
|
35
|
+
'createDelegation',
|
|
36
|
+
'revokeDelegation',
|
|
37
|
+
'getNotificationPreferences',
|
|
38
|
+
'putNotificationPreferences',
|
|
39
|
+
];
|
|
40
|
+
// === SERVICE ===
|
|
41
|
+
/**
|
|
42
|
+
* Data service wrapping authenticated user-storage API endpoints.
|
|
43
|
+
*
|
|
44
|
+
* Provides methods for managing delegations and notification preferences
|
|
45
|
+
* for the authenticated user.
|
|
46
|
+
*/
|
|
47
|
+
export class AuthenticatedUserStorageService extends BaseDataService {
|
|
48
|
+
/**
|
|
49
|
+
* Constructs a new AuthenticatedUserStorageService.
|
|
50
|
+
*
|
|
51
|
+
* @param args - The constructor arguments.
|
|
52
|
+
* @param args.messenger - The messenger suited for this service.
|
|
53
|
+
* @param args.environment - The target environment (dev, uat, prod).
|
|
54
|
+
* @param args.policyOptions - Options to pass to `createServicePolicy`, which
|
|
55
|
+
* is used to wrap each request. See {@link CreateServicePolicyOptions}.
|
|
56
|
+
*/
|
|
57
|
+
constructor({ messenger, environment, policyOptions, }) {
|
|
58
|
+
super({ name: serviceName, messenger, policyOptions });
|
|
59
|
+
_AuthenticatedUserStorageService_instances.add(this);
|
|
60
|
+
_AuthenticatedUserStorageService_environment.set(this, void 0);
|
|
61
|
+
__classPrivateFieldSet(this, _AuthenticatedUserStorageService_environment, environment, "f");
|
|
62
|
+
this.messenger.registerMethodActionHandlers(this, MESSENGER_EXPOSED_METHODS);
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Returns all delegation records belonging to the authenticated user.
|
|
66
|
+
*
|
|
67
|
+
* @returns An array of delegation records, or an empty array if none exist.
|
|
68
|
+
*/
|
|
69
|
+
async listDelegations() {
|
|
70
|
+
const url = `${getAuthenticatedStorageUrl(__classPrivateFieldGet(this, _AuthenticatedUserStorageService_environment, "f"))}/delegations`;
|
|
71
|
+
const data = await this.fetchQuery({
|
|
72
|
+
queryKey: [`${this.name}:listDelegations`],
|
|
73
|
+
queryFn: async () => {
|
|
74
|
+
const headers = await __classPrivateFieldGet(this, _AuthenticatedUserStorageService_instances, "m", _AuthenticatedUserStorageService_getHeaders).call(this);
|
|
75
|
+
const response = await fetch(url, { headers });
|
|
76
|
+
if (!response.ok) {
|
|
77
|
+
throw new HttpError(response.status, `Failed to list delegations: ${response.status}`);
|
|
78
|
+
}
|
|
79
|
+
return response.json();
|
|
80
|
+
},
|
|
81
|
+
});
|
|
82
|
+
assertDelegationResponseArray(data);
|
|
83
|
+
return data;
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Stores a signed delegation record for the authenticated user.
|
|
87
|
+
*
|
|
88
|
+
* @param submission - The signed delegation and its metadata.
|
|
89
|
+
* @param clientType - Optional client type header.
|
|
90
|
+
*/
|
|
91
|
+
async createDelegation(submission, clientType) {
|
|
92
|
+
const url = `${getAuthenticatedStorageUrl(__classPrivateFieldGet(this, _AuthenticatedUserStorageService_environment, "f"))}/delegations`;
|
|
93
|
+
await this.fetchQuery({
|
|
94
|
+
queryKey: [
|
|
95
|
+
`${this.name}:createDelegation`,
|
|
96
|
+
submission.metadata.delegationHash,
|
|
97
|
+
],
|
|
98
|
+
staleTime: 0,
|
|
99
|
+
queryFn: async () => {
|
|
100
|
+
const headers = await __classPrivateFieldGet(this, _AuthenticatedUserStorageService_instances, "m", _AuthenticatedUserStorageService_getHeaders).call(this, clientType);
|
|
101
|
+
const response = await fetch(url, {
|
|
102
|
+
method: 'POST',
|
|
103
|
+
headers,
|
|
104
|
+
body: JSON.stringify(submission),
|
|
105
|
+
});
|
|
106
|
+
if (!response.ok) {
|
|
107
|
+
throw new HttpError(response.status, `Failed to create delegation: ${response.status}`);
|
|
108
|
+
}
|
|
109
|
+
return null;
|
|
110
|
+
},
|
|
111
|
+
});
|
|
112
|
+
await this.invalidateQueries({
|
|
113
|
+
queryKey: [`${this.name}:listDelegations`],
|
|
114
|
+
});
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* Revokes (deletes) a delegation record.
|
|
118
|
+
*
|
|
119
|
+
* @param delegationHash - The unique hash identifying the delegation.
|
|
120
|
+
*/
|
|
121
|
+
async revokeDelegation(delegationHash) {
|
|
122
|
+
const url = `${getAuthenticatedStorageUrl(__classPrivateFieldGet(this, _AuthenticatedUserStorageService_environment, "f"))}/delegations/${encodeURIComponent(delegationHash)}`;
|
|
123
|
+
await this.fetchQuery({
|
|
124
|
+
queryKey: [`${this.name}:revokeDelegation`, delegationHash],
|
|
125
|
+
staleTime: 0,
|
|
126
|
+
queryFn: async () => {
|
|
127
|
+
const headers = await __classPrivateFieldGet(this, _AuthenticatedUserStorageService_instances, "m", _AuthenticatedUserStorageService_getHeaders).call(this);
|
|
128
|
+
const response = await fetch(url, {
|
|
129
|
+
method: 'DELETE',
|
|
130
|
+
headers,
|
|
131
|
+
});
|
|
132
|
+
if (!response.ok) {
|
|
133
|
+
throw new HttpError(response.status, `Failed to revoke delegation: ${response.status}`);
|
|
134
|
+
}
|
|
135
|
+
return null;
|
|
136
|
+
},
|
|
137
|
+
});
|
|
138
|
+
await this.invalidateQueries({
|
|
139
|
+
queryKey: [`${this.name}:listDelegations`],
|
|
140
|
+
});
|
|
141
|
+
}
|
|
142
|
+
/**
|
|
143
|
+
* Returns the notification preferences for the authenticated user.
|
|
144
|
+
*
|
|
145
|
+
* @returns The notification preferences object, or `null` if none have been
|
|
146
|
+
* set (404).
|
|
147
|
+
*/
|
|
148
|
+
async getNotificationPreferences() {
|
|
149
|
+
const url = `${getAuthenticatedStorageUrl(__classPrivateFieldGet(this, _AuthenticatedUserStorageService_environment, "f"))}/preferences/notifications`;
|
|
150
|
+
const data = await this.fetchQuery({
|
|
151
|
+
queryKey: [`${this.name}:getNotificationPreferences`],
|
|
152
|
+
queryFn: async () => {
|
|
153
|
+
const headers = await __classPrivateFieldGet(this, _AuthenticatedUserStorageService_instances, "m", _AuthenticatedUserStorageService_getHeaders).call(this);
|
|
154
|
+
const response = await fetch(url, { headers });
|
|
155
|
+
if (response.status === 404) {
|
|
156
|
+
return null;
|
|
157
|
+
}
|
|
158
|
+
if (!response.ok) {
|
|
159
|
+
throw new HttpError(response.status, `Failed to get notification preferences: ${response.status}`);
|
|
160
|
+
}
|
|
161
|
+
return response.json();
|
|
162
|
+
},
|
|
163
|
+
});
|
|
164
|
+
if (data === null) {
|
|
165
|
+
return null;
|
|
166
|
+
}
|
|
167
|
+
assertNotificationPreferences(data);
|
|
168
|
+
return data;
|
|
169
|
+
}
|
|
170
|
+
/**
|
|
171
|
+
* Creates or updates the notification preferences for the authenticated user.
|
|
172
|
+
*
|
|
173
|
+
* @param prefs - The full notification preferences object.
|
|
174
|
+
* @param clientType - Optional client type header.
|
|
175
|
+
*/
|
|
176
|
+
async putNotificationPreferences(prefs, clientType) {
|
|
177
|
+
const url = `${getAuthenticatedStorageUrl(__classPrivateFieldGet(this, _AuthenticatedUserStorageService_environment, "f"))}/preferences/notifications`;
|
|
178
|
+
await this.fetchQuery({
|
|
179
|
+
queryKey: [
|
|
180
|
+
`${this.name}:putNotificationPreferences`,
|
|
181
|
+
prefs,
|
|
182
|
+
],
|
|
183
|
+
staleTime: 0,
|
|
184
|
+
queryFn: async () => {
|
|
185
|
+
const headers = await __classPrivateFieldGet(this, _AuthenticatedUserStorageService_instances, "m", _AuthenticatedUserStorageService_getHeaders).call(this, clientType);
|
|
186
|
+
const response = await fetch(url, {
|
|
187
|
+
method: 'PUT',
|
|
188
|
+
headers,
|
|
189
|
+
body: JSON.stringify(prefs),
|
|
190
|
+
});
|
|
191
|
+
if (!response.ok) {
|
|
192
|
+
throw new HttpError(response.status, `Failed to put notification preferences: ${response.status}`);
|
|
193
|
+
}
|
|
194
|
+
return null;
|
|
195
|
+
},
|
|
196
|
+
});
|
|
197
|
+
await this.invalidateQueries({
|
|
198
|
+
queryKey: [`${this.name}:getNotificationPreferences`],
|
|
199
|
+
});
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
_AuthenticatedUserStorageService_environment = new WeakMap(), _AuthenticatedUserStorageService_instances = new WeakSet(), _AuthenticatedUserStorageService_getHeaders = async function _AuthenticatedUserStorageService_getHeaders(clientType) {
|
|
203
|
+
const accessToken = await this.messenger.call('AuthenticationController:getBearerToken');
|
|
204
|
+
const headers = {
|
|
205
|
+
'Content-Type': 'application/json',
|
|
206
|
+
Authorization: `Bearer ${accessToken}`,
|
|
207
|
+
};
|
|
208
|
+
if (clientType) {
|
|
209
|
+
headers['X-Client-Type'] = clientType;
|
|
210
|
+
}
|
|
211
|
+
return headers;
|
|
212
|
+
};
|
|
213
|
+
//# sourceMappingURL=authenticated-user-storage.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
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,kBAAc;AAO7C,OAAO,EACL,6BAA6B,EAC7B,6BAA6B,EAC9B,yBAAqB;AAEtB,kBAAkB;AAElB;;;GAGG;AACH,MAAM,CAAC,MAAM,WAAW,GAAG,iCAAiC,CAAC;AAE7D;;;;;GAKG;AACH,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F,CAAC,CAAC;QAEH,MAAM,IAAI,CAAC,iBAAiB,CAAC;YAC3B,QAAQ,EAAE,CAAC,GAAG,IAAI,CAAC,IAAI,6BAA6B,CAAC;SACtD,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';\nimport type { Environment } from './env';\nimport { getUserStorageApiUrl } from './env';\nimport type {\n ClientType,\n DelegationResponse,\n DelegationSubmission,\n NotificationPreferences,\n} from './types';\nimport {\n assertDelegationResponseArray,\n assertNotificationPreferences,\n} from './validators';\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] 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 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
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
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
ADDED
|
@@ -0,0 +1 @@
|
|
|
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"]}
|
package/dist/env.d.cts
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
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.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
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
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
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
|
|
@@ -0,0 +1 @@
|
|
|
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
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
const API_SUBDOMAINS = {
|
|
2
|
+
dev: 'dev-api',
|
|
3
|
+
uat: 'uat-api',
|
|
4
|
+
prod: 'api',
|
|
5
|
+
};
|
|
6
|
+
/**
|
|
7
|
+
* Returns the user-storage API base URL for the given environment.
|
|
8
|
+
*
|
|
9
|
+
* @param environment - The target environment.
|
|
10
|
+
* @returns The base URL for the user-storage API.
|
|
11
|
+
* @throws If the environment is invalid.
|
|
12
|
+
*/
|
|
13
|
+
export function getUserStorageApiUrl(environment) {
|
|
14
|
+
const subdomain = API_SUBDOMAINS[environment];
|
|
15
|
+
if (!subdomain) {
|
|
16
|
+
throw new Error(`Invalid environment: ${String(environment)}`);
|
|
17
|
+
}
|
|
18
|
+
return `https://user-storage.${subdomain}.cx.metamask.io`;
|
|
19
|
+
}
|
|
20
|
+
//# sourceMappingURL=env.mjs.map
|
package/dist/env.mjs.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
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
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getUserStorageApiUrl = exports.AuthenticatedUserStorageService = exports.getAuthenticatedStorageUrl = void 0;
|
|
4
|
+
var authenticated_user_storage_1 = require("./authenticated-user-storage.cjs");
|
|
5
|
+
Object.defineProperty(exports, "getAuthenticatedStorageUrl", { enumerable: true, get: function () { return authenticated_user_storage_1.getAuthenticatedStorageUrl; } });
|
|
6
|
+
Object.defineProperty(exports, "AuthenticatedUserStorageService", { enumerable: true, get: function () { return authenticated_user_storage_1.AuthenticatedUserStorageService; } });
|
|
7
|
+
var env_1 = require("./env.cjs");
|
|
8
|
+
Object.defineProperty(exports, "getUserStorageApiUrl", { enumerable: true, get: function () { return env_1.getUserStorageApiUrl; } });
|
|
9
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.cjs","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAAA,+EAGsC;AAFpC,wIAAA,0BAA0B,OAAA;AAC1B,6IAAA,+BAA+B,OAAA;AAiBjC,iCAA6C;AAApC,2GAAA,oBAAoB,OAAA","sourcesContent":["export {\n getAuthenticatedStorageUrl,\n AuthenticatedUserStorageService,\n} from './authenticated-user-storage';\nexport type {\n AuthenticatedUserStorageActions,\n AuthenticatedUserStorageCacheUpdatedEvent,\n AuthenticatedUserStorageEvents,\n AuthenticatedUserStorageGranularCacheUpdatedEvent,\n AuthenticatedUserStorageInvalidateQueriesAction,\n AuthenticatedUserStorageMessenger,\n} from './authenticated-user-storage';\nexport type {\n AuthenticatedUserStorageServiceListDelegationsAction,\n AuthenticatedUserStorageServiceCreateDelegationAction,\n AuthenticatedUserStorageServiceRevokeDelegationAction,\n AuthenticatedUserStorageServiceGetNotificationPreferencesAction,\n AuthenticatedUserStorageServicePutNotificationPreferencesAction,\n} from './authenticated-user-storage-method-action-types';\nexport { getUserStorageApiUrl } from './env';\nexport type { Environment } from './env';\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 NotificationPreferences,\n ClientType,\n} from './types';\n"]}
|
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export { getAuthenticatedStorageUrl, AuthenticatedUserStorageService, } from "./authenticated-user-storage.cjs";
|
|
2
|
+
export type { AuthenticatedUserStorageActions, AuthenticatedUserStorageCacheUpdatedEvent, AuthenticatedUserStorageEvents, AuthenticatedUserStorageGranularCacheUpdatedEvent, AuthenticatedUserStorageInvalidateQueriesAction, AuthenticatedUserStorageMessenger, } from "./authenticated-user-storage.cjs";
|
|
3
|
+
export type { AuthenticatedUserStorageServiceListDelegationsAction, AuthenticatedUserStorageServiceCreateDelegationAction, AuthenticatedUserStorageServiceRevokeDelegationAction, AuthenticatedUserStorageServiceGetNotificationPreferencesAction, AuthenticatedUserStorageServicePutNotificationPreferencesAction, } from "./authenticated-user-storage-method-action-types.cjs";
|
|
4
|
+
export { getUserStorageApiUrl } from "./env.cjs";
|
|
5
|
+
export type { Environment } from "./env.cjs";
|
|
6
|
+
export type { Caveat, SignedDelegation, DelegationMetadata, DelegationSubmission, DelegationResponse, WalletActivityAccount, WalletActivityPreference, MarketingPreference, PerpsWatchlistExchange, PerpsWatchlistMarkets, PerpsPreference, SocialAIPreference, NotificationPreferences, ClientType, } from "./types.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,OAAO,EACL,0BAA0B,EAC1B,+BAA+B,GAChC,yCAAqC;AACtC,YAAY,EACV,+BAA+B,EAC/B,yCAAyC,EACzC,8BAA8B,EAC9B,iDAAiD,EACjD,+CAA+C,EAC/C,iCAAiC,GAClC,yCAAqC;AACtC,YAAY,EACV,oDAAoD,EACpD,qDAAqD,EACrD,qDAAqD,EACrD,+DAA+D,EAC/D,+DAA+D,GAChE,6DAAyD;AAC1D,OAAO,EAAE,oBAAoB,EAAE,kBAAc;AAC7C,YAAY,EAAE,WAAW,EAAE,kBAAc;AACzC,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,uBAAuB,EACvB,UAAU,GACX,oBAAgB"}
|
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export { getAuthenticatedStorageUrl, AuthenticatedUserStorageService, } from "./authenticated-user-storage.mjs";
|
|
2
|
+
export type { AuthenticatedUserStorageActions, AuthenticatedUserStorageCacheUpdatedEvent, AuthenticatedUserStorageEvents, AuthenticatedUserStorageGranularCacheUpdatedEvent, AuthenticatedUserStorageInvalidateQueriesAction, AuthenticatedUserStorageMessenger, } from "./authenticated-user-storage.mjs";
|
|
3
|
+
export type { AuthenticatedUserStorageServiceListDelegationsAction, AuthenticatedUserStorageServiceCreateDelegationAction, AuthenticatedUserStorageServiceRevokeDelegationAction, AuthenticatedUserStorageServiceGetNotificationPreferencesAction, AuthenticatedUserStorageServicePutNotificationPreferencesAction, } from "./authenticated-user-storage-method-action-types.mjs";
|
|
4
|
+
export { getUserStorageApiUrl } from "./env.mjs";
|
|
5
|
+
export type { Environment } from "./env.mjs";
|
|
6
|
+
export type { Caveat, SignedDelegation, DelegationMetadata, DelegationSubmission, DelegationResponse, WalletActivityAccount, WalletActivityPreference, MarketingPreference, PerpsWatchlistExchange, PerpsWatchlistMarkets, PerpsPreference, SocialAIPreference, NotificationPreferences, ClientType, } from "./types.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,OAAO,EACL,0BAA0B,EAC1B,+BAA+B,GAChC,yCAAqC;AACtC,YAAY,EACV,+BAA+B,EAC/B,yCAAyC,EACzC,8BAA8B,EAC9B,iDAAiD,EACjD,+CAA+C,EAC/C,iCAAiC,GAClC,yCAAqC;AACtC,YAAY,EACV,oDAAoD,EACpD,qDAAqD,EACrD,qDAAqD,EACrD,+DAA+D,EAC/D,+DAA+D,GAChE,6DAAyD;AAC1D,OAAO,EAAE,oBAAoB,EAAE,kBAAc;AAC7C,YAAY,EAAE,WAAW,EAAE,kBAAc;AACzC,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,uBAAuB,EACvB,UAAU,GACX,oBAAgB"}
|