@metamask/claims-controller 0.1.0
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 +25 -0
- package/LICENSE +20 -0
- package/README.md +15 -0
- package/dist/ClaimsController.cjs +108 -0
- package/dist/ClaimsController.cjs.map +1 -0
- package/dist/ClaimsController.d.cts +48 -0
- package/dist/ClaimsController.d.cts.map +1 -0
- package/dist/ClaimsController.d.mts +48 -0
- package/dist/ClaimsController.d.mts.map +1 -0
- package/dist/ClaimsController.mjs +103 -0
- package/dist/ClaimsController.mjs.map +1 -0
- package/dist/ClaimsService.cjs +115 -0
- package/dist/ClaimsService.cjs.map +1 -0
- package/dist/ClaimsService.d.cts +74 -0
- package/dist/ClaimsService.d.cts.map +1 -0
- package/dist/ClaimsService.d.mts +74 -0
- package/dist/ClaimsService.d.mts.map +1 -0
- package/dist/ClaimsService.mjs +111 -0
- package/dist/ClaimsService.mjs.map +1 -0
- package/dist/constants.cjs +50 -0
- package/dist/constants.cjs.map +1 -0
- package/dist/constants.d.cts +33 -0
- package/dist/constants.d.cts.map +1 -0
- package/dist/constants.d.mts +33 -0
- package/dist/constants.d.mts.map +1 -0
- package/dist/constants.mjs +47 -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/dist/types.cjs +3 -0
- package/dist/types.cjs.map +1 -0
- package/dist/types.d.cts +54 -0
- package/dist/types.d.cts.map +1 -0
- package/dist/types.d.mts +54 -0
- package/dist/types.d.mts.map +1 -0
- package/dist/types.mjs +2 -0
- package/dist/types.mjs.map +1 -0
- package/package.json +76 -0
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import type { Messenger } from "@metamask/messenger";
|
|
2
|
+
import type { AuthenticationController } from "@metamask/profile-sync-controller";
|
|
3
|
+
import type { Hex } from "@metamask/utils";
|
|
4
|
+
import { type Env, HttpContentTypeHeader, SERVICE_NAME } from "./constants.mjs";
|
|
5
|
+
import type { Claim, GenerateSignatureMessageResponse } from "./types.mjs";
|
|
6
|
+
export type ClaimsServiceGetClaimsAction = {
|
|
7
|
+
type: `${typeof SERVICE_NAME}:getClaims`;
|
|
8
|
+
handler: ClaimsService['getClaims'];
|
|
9
|
+
};
|
|
10
|
+
export type ClaimsServiceGetClaimByIdAction = {
|
|
11
|
+
type: `${typeof SERVICE_NAME}:getClaimById`;
|
|
12
|
+
handler: ClaimsService['getClaimById'];
|
|
13
|
+
};
|
|
14
|
+
export type ClaimsServiceGetRequestHeadersAction = {
|
|
15
|
+
type: `${typeof SERVICE_NAME}:getRequestHeaders`;
|
|
16
|
+
handler: ClaimsService['getRequestHeaders'];
|
|
17
|
+
};
|
|
18
|
+
export type ClaimsServiceGetClaimsApiUrlAction = {
|
|
19
|
+
type: `${typeof SERVICE_NAME}:getClaimsApiUrl`;
|
|
20
|
+
handler: ClaimsService['getClaimsApiUrl'];
|
|
21
|
+
};
|
|
22
|
+
export type ClaimsServiceGenerateMessageForClaimSignatureAction = {
|
|
23
|
+
type: `${typeof SERVICE_NAME}:generateMessageForClaimSignature`;
|
|
24
|
+
handler: ClaimsService['generateMessageForClaimSignature'];
|
|
25
|
+
};
|
|
26
|
+
export type ClaimsServiceActions = ClaimsServiceGetClaimsAction | ClaimsServiceGetClaimByIdAction | ClaimsServiceGetRequestHeadersAction | ClaimsServiceGetClaimsApiUrlAction | ClaimsServiceGenerateMessageForClaimSignatureAction;
|
|
27
|
+
export type AllowedActions = AuthenticationController.AuthenticationControllerGetBearerToken;
|
|
28
|
+
export type ClaimsServiceEvents = never;
|
|
29
|
+
export type ClaimsServiceMessenger = Messenger<typeof SERVICE_NAME, ClaimsServiceActions | AllowedActions>;
|
|
30
|
+
export type ClaimsServiceConfig = {
|
|
31
|
+
env: Env;
|
|
32
|
+
messenger: ClaimsServiceMessenger;
|
|
33
|
+
fetchFunction: typeof fetch;
|
|
34
|
+
};
|
|
35
|
+
export declare class ClaimsService {
|
|
36
|
+
#private;
|
|
37
|
+
readonly name = "ClaimsService";
|
|
38
|
+
constructor({ env, messenger, fetchFunction }: ClaimsServiceConfig);
|
|
39
|
+
/**
|
|
40
|
+
* Get the claims for the current user.
|
|
41
|
+
*
|
|
42
|
+
* @returns The claims for the current user.
|
|
43
|
+
*/
|
|
44
|
+
getClaims(): Promise<Claim[]>;
|
|
45
|
+
/**
|
|
46
|
+
* Get the claim by id.
|
|
47
|
+
*
|
|
48
|
+
* @param id - The id of the claim to get.
|
|
49
|
+
* @returns The claim by id.
|
|
50
|
+
*/
|
|
51
|
+
getClaimById(id: string): Promise<Claim>;
|
|
52
|
+
/**
|
|
53
|
+
* Generate a message to be signed by the user for the claim request.
|
|
54
|
+
*
|
|
55
|
+
* @param chainId - The chain id of the claim.
|
|
56
|
+
* @param walletAddress - The impacted wallet address of the claim.
|
|
57
|
+
* @returns The message for the claim signature.
|
|
58
|
+
*/
|
|
59
|
+
generateMessageForClaimSignature(chainId: number, walletAddress: Hex): Promise<GenerateSignatureMessageResponse>;
|
|
60
|
+
/**
|
|
61
|
+
* Create the headers for the current request.
|
|
62
|
+
*
|
|
63
|
+
* @param contentType - The content type of the request. Defaults to 'application/json'.
|
|
64
|
+
* @returns The headers for the current request.
|
|
65
|
+
*/
|
|
66
|
+
getRequestHeaders(contentType?: HttpContentTypeHeader): Promise<Record<string, string>>;
|
|
67
|
+
/**
|
|
68
|
+
* Get the URL for the claims API for the current environment.
|
|
69
|
+
*
|
|
70
|
+
* @returns The URL for the claims API for the current environment.
|
|
71
|
+
*/
|
|
72
|
+
getClaimsApiUrl(): string;
|
|
73
|
+
}
|
|
74
|
+
//# sourceMappingURL=ClaimsService.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ClaimsService.d.mts","sourceRoot":"","sources":["../src/ClaimsService.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,4BAA4B;AACrD,OAAO,KAAK,EAAE,wBAAwB,EAAE,0CAA0C;AAClF,OAAO,KAAK,EAAE,GAAG,EAAE,wBAAwB;AAE3C,OAAO,EAGL,KAAK,GAAG,EACR,qBAAqB,EACrB,YAAY,EACb,wBAAoB;AACrB,OAAO,KAAK,EAAE,KAAK,EAAE,gCAAgC,EAAE,oBAAgB;AAEvE,MAAM,MAAM,4BAA4B,GAAG;IACzC,IAAI,EAAE,GAAG,OAAO,YAAY,YAAY,CAAC;IACzC,OAAO,EAAE,aAAa,CAAC,WAAW,CAAC,CAAC;CACrC,CAAC;AAEF,MAAM,MAAM,+BAA+B,GAAG;IAC5C,IAAI,EAAE,GAAG,OAAO,YAAY,eAAe,CAAC;IAC5C,OAAO,EAAE,aAAa,CAAC,cAAc,CAAC,CAAC;CACxC,CAAC;AAEF,MAAM,MAAM,oCAAoC,GAAG;IACjD,IAAI,EAAE,GAAG,OAAO,YAAY,oBAAoB,CAAC;IACjD,OAAO,EAAE,aAAa,CAAC,mBAAmB,CAAC,CAAC;CAC7C,CAAC;AAEF,MAAM,MAAM,kCAAkC,GAAG;IAC/C,IAAI,EAAE,GAAG,OAAO,YAAY,kBAAkB,CAAC;IAC/C,OAAO,EAAE,aAAa,CAAC,iBAAiB,CAAC,CAAC;CAC3C,CAAC;AAEF,MAAM,MAAM,mDAAmD,GAAG;IAChE,IAAI,EAAE,GAAG,OAAO,YAAY,mCAAmC,CAAC;IAChE,OAAO,EAAE,aAAa,CAAC,kCAAkC,CAAC,CAAC;CAC5D,CAAC;AAEF,MAAM,MAAM,oBAAoB,GAC5B,4BAA4B,GAC5B,+BAA+B,GAC/B,oCAAoC,GACpC,kCAAkC,GAClC,mDAAmD,CAAC;AAExD,MAAM,MAAM,cAAc,GACxB,wBAAwB,CAAC,sCAAsC,CAAC;AAElE,MAAM,MAAM,mBAAmB,GAAG,KAAK,CAAC;AAExC,MAAM,MAAM,sBAAsB,GAAG,SAAS,CAC5C,OAAO,YAAY,EACnB,oBAAoB,GAAG,cAAc,CACtC,CAAC;AAEF,MAAM,MAAM,mBAAmB,GAAG;IAChC,GAAG,EAAE,GAAG,CAAC;IACT,SAAS,EAAE,sBAAsB,CAAC;IAClC,aAAa,EAAE,OAAO,KAAK,CAAC;CAC7B,CAAC;AAEF,qBAAa,aAAa;;IACxB,QAAQ,CAAC,IAAI,mBAAgB;gBAQjB,EAAE,GAAG,EAAE,SAAS,EAAE,aAAa,EAAE,EAAE,mBAAmB;IA2BlE;;;;OAIG;IACG,SAAS,IAAI,OAAO,CAAC,KAAK,EAAE,CAAC;IAenC;;;;;OAKG;IACG,YAAY,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,KAAK,CAAC;IAe9C;;;;;;OAMG;IACG,gCAAgC,CACpC,OAAO,EAAE,MAAM,EACf,aAAa,EAAE,GAAG,GACjB,OAAO,CAAC,gCAAgC,CAAC;IAsB5C;;;;;OAKG;IACG,iBAAiB,CACrB,WAAW,GAAE,qBAA8D,GAC1E,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAUlC;;;;OAIG;IACH,eAAe,IAAI,MAAM;CAG1B"}
|
|
@@ -0,0 +1,111 @@
|
|
|
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 _ClaimsService_env, _ClaimsService_fetch, _ClaimsService_messenger;
|
|
13
|
+
import { CLAIMS_API_URL, ClaimsServiceErrorMessages, HttpContentTypeHeader, SERVICE_NAME } from "./constants.mjs";
|
|
14
|
+
export class ClaimsService {
|
|
15
|
+
constructor({ env, messenger, fetchFunction }) {
|
|
16
|
+
this.name = SERVICE_NAME; // required for Modular Initialization
|
|
17
|
+
_ClaimsService_env.set(this, void 0);
|
|
18
|
+
_ClaimsService_fetch.set(this, void 0);
|
|
19
|
+
_ClaimsService_messenger.set(this, void 0);
|
|
20
|
+
__classPrivateFieldSet(this, _ClaimsService_env, env, "f");
|
|
21
|
+
__classPrivateFieldSet(this, _ClaimsService_messenger, messenger, "f");
|
|
22
|
+
__classPrivateFieldSet(this, _ClaimsService_fetch, fetchFunction, "f");
|
|
23
|
+
__classPrivateFieldGet(this, _ClaimsService_messenger, "f").registerActionHandler(`${SERVICE_NAME}:getClaims`, this.getClaims.bind(this));
|
|
24
|
+
__classPrivateFieldGet(this, _ClaimsService_messenger, "f").registerActionHandler(`${SERVICE_NAME}:getClaimById`, this.getClaimById.bind(this));
|
|
25
|
+
__classPrivateFieldGet(this, _ClaimsService_messenger, "f").registerActionHandler(`${SERVICE_NAME}:getRequestHeaders`, this.getRequestHeaders.bind(this));
|
|
26
|
+
__classPrivateFieldGet(this, _ClaimsService_messenger, "f").registerActionHandler(`${SERVICE_NAME}:getClaimsApiUrl`, this.getClaimsApiUrl.bind(this));
|
|
27
|
+
__classPrivateFieldGet(this, _ClaimsService_messenger, "f").registerActionHandler(`${SERVICE_NAME}:generateMessageForClaimSignature`, this.generateMessageForClaimSignature.bind(this));
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Get the claims for the current user.
|
|
31
|
+
*
|
|
32
|
+
* @returns The claims for the current user.
|
|
33
|
+
*/
|
|
34
|
+
async getClaims() {
|
|
35
|
+
const headers = await this.getRequestHeaders();
|
|
36
|
+
const url = `${this.getClaimsApiUrl()}/claims`;
|
|
37
|
+
const response = await __classPrivateFieldGet(this, _ClaimsService_fetch, "f").call(this, url, {
|
|
38
|
+
headers,
|
|
39
|
+
});
|
|
40
|
+
if (!response.ok) {
|
|
41
|
+
throw new Error(ClaimsServiceErrorMessages.FAILED_TO_GET_CLAIMS);
|
|
42
|
+
}
|
|
43
|
+
const claims = await response.json();
|
|
44
|
+
return claims;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Get the claim by id.
|
|
48
|
+
*
|
|
49
|
+
* @param id - The id of the claim to get.
|
|
50
|
+
* @returns The claim by id.
|
|
51
|
+
*/
|
|
52
|
+
async getClaimById(id) {
|
|
53
|
+
const headers = await this.getRequestHeaders();
|
|
54
|
+
const url = `${this.getClaimsApiUrl()}/claims/byId/${id}`;
|
|
55
|
+
const response = await __classPrivateFieldGet(this, _ClaimsService_fetch, "f").call(this, url, {
|
|
56
|
+
headers,
|
|
57
|
+
});
|
|
58
|
+
if (!response.ok) {
|
|
59
|
+
throw new Error(ClaimsServiceErrorMessages.FAILED_TO_GET_CLAIM_BY_ID);
|
|
60
|
+
}
|
|
61
|
+
const claim = await response.json();
|
|
62
|
+
return claim;
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Generate a message to be signed by the user for the claim request.
|
|
66
|
+
*
|
|
67
|
+
* @param chainId - The chain id of the claim.
|
|
68
|
+
* @param walletAddress - The impacted wallet address of the claim.
|
|
69
|
+
* @returns The message for the claim signature.
|
|
70
|
+
*/
|
|
71
|
+
async generateMessageForClaimSignature(chainId, walletAddress) {
|
|
72
|
+
const headers = await this.getRequestHeaders();
|
|
73
|
+
const url = `${this.getClaimsApiUrl()}/signature/generateMessage`;
|
|
74
|
+
const response = await __classPrivateFieldGet(this, _ClaimsService_fetch, "f").call(this, url, {
|
|
75
|
+
headers,
|
|
76
|
+
method: 'POST',
|
|
77
|
+
body: JSON.stringify({
|
|
78
|
+
chainId,
|
|
79
|
+
walletAddress,
|
|
80
|
+
}),
|
|
81
|
+
});
|
|
82
|
+
if (!response.ok) {
|
|
83
|
+
throw new Error(ClaimsServiceErrorMessages.SIGNATURE_MESSAGE_GENERATION_FAILED);
|
|
84
|
+
}
|
|
85
|
+
const message = await response.json();
|
|
86
|
+
return message;
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* Create the headers for the current request.
|
|
90
|
+
*
|
|
91
|
+
* @param contentType - The content type of the request. Defaults to 'application/json'.
|
|
92
|
+
* @returns The headers for the current request.
|
|
93
|
+
*/
|
|
94
|
+
async getRequestHeaders(contentType = HttpContentTypeHeader.APPLICATION_JSON) {
|
|
95
|
+
const bearerToken = await __classPrivateFieldGet(this, _ClaimsService_messenger, "f").call('AuthenticationController:getBearerToken');
|
|
96
|
+
return {
|
|
97
|
+
Authorization: `Bearer ${bearerToken}`,
|
|
98
|
+
'Content-Type': contentType,
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* Get the URL for the claims API for the current environment.
|
|
103
|
+
*
|
|
104
|
+
* @returns The URL for the claims API for the current environment.
|
|
105
|
+
*/
|
|
106
|
+
getClaimsApiUrl() {
|
|
107
|
+
return `${CLAIMS_API_URL[__classPrivateFieldGet(this, _ClaimsService_env, "f")]}`;
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
_ClaimsService_env = new WeakMap(), _ClaimsService_fetch = new WeakMap(), _ClaimsService_messenger = new WeakMap();
|
|
111
|
+
//# sourceMappingURL=ClaimsService.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ClaimsService.mjs","sourceRoot":"","sources":["../src/ClaimsService.ts"],"names":[],"mappings":"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","sourcesContent":["import type { Messenger } from '@metamask/messenger';\nimport type { AuthenticationController } from '@metamask/profile-sync-controller';\nimport type { Hex } from '@metamask/utils';\n\nimport {\n CLAIMS_API_URL,\n ClaimsServiceErrorMessages,\n type Env,\n HttpContentTypeHeader,\n SERVICE_NAME,\n} from './constants';\nimport type { Claim, GenerateSignatureMessageResponse } from './types';\n\nexport type ClaimsServiceGetClaimsAction = {\n type: `${typeof SERVICE_NAME}:getClaims`;\n handler: ClaimsService['getClaims'];\n};\n\nexport type ClaimsServiceGetClaimByIdAction = {\n type: `${typeof SERVICE_NAME}:getClaimById`;\n handler: ClaimsService['getClaimById'];\n};\n\nexport type ClaimsServiceGetRequestHeadersAction = {\n type: `${typeof SERVICE_NAME}:getRequestHeaders`;\n handler: ClaimsService['getRequestHeaders'];\n};\n\nexport type ClaimsServiceGetClaimsApiUrlAction = {\n type: `${typeof SERVICE_NAME}:getClaimsApiUrl`;\n handler: ClaimsService['getClaimsApiUrl'];\n};\n\nexport type ClaimsServiceGenerateMessageForClaimSignatureAction = {\n type: `${typeof SERVICE_NAME}:generateMessageForClaimSignature`;\n handler: ClaimsService['generateMessageForClaimSignature'];\n};\n\nexport type ClaimsServiceActions =\n | ClaimsServiceGetClaimsAction\n | ClaimsServiceGetClaimByIdAction\n | ClaimsServiceGetRequestHeadersAction\n | ClaimsServiceGetClaimsApiUrlAction\n | ClaimsServiceGenerateMessageForClaimSignatureAction;\n\nexport type AllowedActions =\n AuthenticationController.AuthenticationControllerGetBearerToken;\n\nexport type ClaimsServiceEvents = never;\n\nexport type ClaimsServiceMessenger = Messenger<\n typeof SERVICE_NAME,\n ClaimsServiceActions | AllowedActions\n>;\n\nexport type ClaimsServiceConfig = {\n env: Env;\n messenger: ClaimsServiceMessenger;\n fetchFunction: typeof fetch;\n};\n\nexport class ClaimsService {\n readonly name = SERVICE_NAME; // required for Modular Initialization\n\n readonly #env: Env;\n\n readonly #fetch: typeof fetch;\n\n readonly #messenger: ClaimsServiceMessenger;\n\n constructor({ env, messenger, fetchFunction }: ClaimsServiceConfig) {\n this.#env = env;\n this.#messenger = messenger;\n this.#fetch = fetchFunction;\n\n this.#messenger.registerActionHandler(\n `${SERVICE_NAME}:getClaims`,\n this.getClaims.bind(this),\n );\n this.#messenger.registerActionHandler(\n `${SERVICE_NAME}:getClaimById`,\n this.getClaimById.bind(this),\n );\n this.#messenger.registerActionHandler(\n `${SERVICE_NAME}:getRequestHeaders`,\n this.getRequestHeaders.bind(this),\n );\n this.#messenger.registerActionHandler(\n `${SERVICE_NAME}:getClaimsApiUrl`,\n this.getClaimsApiUrl.bind(this),\n );\n this.#messenger.registerActionHandler(\n `${SERVICE_NAME}:generateMessageForClaimSignature`,\n this.generateMessageForClaimSignature.bind(this),\n );\n }\n\n /**\n * Get the claims for the current user.\n *\n * @returns The claims for the current user.\n */\n async getClaims(): Promise<Claim[]> {\n const headers = await this.getRequestHeaders();\n const url = `${this.getClaimsApiUrl()}/claims`;\n const response = await this.#fetch(url, {\n headers,\n });\n\n if (!response.ok) {\n throw new Error(ClaimsServiceErrorMessages.FAILED_TO_GET_CLAIMS);\n }\n\n const claims = await response.json();\n return claims;\n }\n\n /**\n * Get the claim by id.\n *\n * @param id - The id of the claim to get.\n * @returns The claim by id.\n */\n async getClaimById(id: string): Promise<Claim> {\n const headers = await this.getRequestHeaders();\n const url = `${this.getClaimsApiUrl()}/claims/byId/${id}`;\n const response = await this.#fetch(url, {\n headers,\n });\n\n if (!response.ok) {\n throw new Error(ClaimsServiceErrorMessages.FAILED_TO_GET_CLAIM_BY_ID);\n }\n\n const claim = await response.json();\n return claim;\n }\n\n /**\n * Generate a message to be signed by the user for the claim request.\n *\n * @param chainId - The chain id of the claim.\n * @param walletAddress - The impacted wallet address of the claim.\n * @returns The message for the claim signature.\n */\n async generateMessageForClaimSignature(\n chainId: number,\n walletAddress: Hex,\n ): Promise<GenerateSignatureMessageResponse> {\n const headers = await this.getRequestHeaders();\n const url = `${this.getClaimsApiUrl()}/signature/generateMessage`;\n const response = await this.#fetch(url, {\n headers,\n method: 'POST',\n body: JSON.stringify({\n chainId,\n walletAddress,\n }),\n });\n\n if (!response.ok) {\n throw new Error(\n ClaimsServiceErrorMessages.SIGNATURE_MESSAGE_GENERATION_FAILED,\n );\n }\n\n const message = await response.json();\n return message;\n }\n\n /**\n * Create the headers for the current request.\n *\n * @param contentType - The content type of the request. Defaults to 'application/json'.\n * @returns The headers for the current request.\n */\n async getRequestHeaders(\n contentType: HttpContentTypeHeader = HttpContentTypeHeader.APPLICATION_JSON,\n ): Promise<Record<string, string>> {\n const bearerToken = await this.#messenger.call(\n 'AuthenticationController:getBearerToken',\n );\n return {\n Authorization: `Bearer ${bearerToken}`,\n 'Content-Type': contentType,\n };\n }\n\n /**\n * Get the URL for the claims API for the current environment.\n *\n * @returns The URL for the claims API for the current environment.\n */\n getClaimsApiUrl(): string {\n return `${CLAIMS_API_URL[this.#env]}`;\n }\n}\n"]}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ClaimsServiceErrorMessages = exports.ClaimsControllerErrorMessages = exports.HttpContentTypeHeader = exports.CLAIMS_API_URL = exports.ClaimStatusEnum = exports.Env = exports.SERVICE_NAME = exports.CONTROLLER_NAME = void 0;
|
|
4
|
+
exports.CONTROLLER_NAME = 'ClaimsController';
|
|
5
|
+
exports.SERVICE_NAME = 'ClaimsService';
|
|
6
|
+
var Env;
|
|
7
|
+
(function (Env) {
|
|
8
|
+
Env["DEV"] = "dev";
|
|
9
|
+
Env["UAT"] = "uat";
|
|
10
|
+
Env["PRD"] = "prd";
|
|
11
|
+
})(Env || (exports.Env = Env = {}));
|
|
12
|
+
var ClaimStatusEnum;
|
|
13
|
+
(function (ClaimStatusEnum) {
|
|
14
|
+
// created but not yet submitted to Intercom
|
|
15
|
+
ClaimStatusEnum["CREATED"] = "created";
|
|
16
|
+
// submitted to Intercom
|
|
17
|
+
ClaimStatusEnum["SUBMITTED"] = "submitted";
|
|
18
|
+
// in progress by Intercom
|
|
19
|
+
ClaimStatusEnum["IN_PROGRESS"] = "in_progress";
|
|
20
|
+
// waiting for customer reply
|
|
21
|
+
ClaimStatusEnum["WAITING_FOR_CUSTOMER"] = "waiting_for_customer";
|
|
22
|
+
// approved by Intercom
|
|
23
|
+
ClaimStatusEnum["APPROVED"] = "approved";
|
|
24
|
+
// rejected by Intercom
|
|
25
|
+
ClaimStatusEnum["REJECTED"] = "rejected";
|
|
26
|
+
// unknown status
|
|
27
|
+
ClaimStatusEnum["UNKNOWN"] = "unknown";
|
|
28
|
+
})(ClaimStatusEnum || (exports.ClaimStatusEnum = ClaimStatusEnum = {}));
|
|
29
|
+
exports.CLAIMS_API_URL = {
|
|
30
|
+
[Env.DEV]: 'https://claims.dev-api.cx.metamask.io',
|
|
31
|
+
[Env.UAT]: 'https://claims.uat-api.cx.metamask.io',
|
|
32
|
+
[Env.PRD]: 'https://claims.api.cx.metamask.io',
|
|
33
|
+
};
|
|
34
|
+
var HttpContentTypeHeader;
|
|
35
|
+
(function (HttpContentTypeHeader) {
|
|
36
|
+
HttpContentTypeHeader["APPLICATION_JSON"] = "application/json";
|
|
37
|
+
HttpContentTypeHeader["MULTIPART_FORM_DATA"] = "multipart/form-data";
|
|
38
|
+
})(HttpContentTypeHeader || (exports.HttpContentTypeHeader = HttpContentTypeHeader = {}));
|
|
39
|
+
exports.ClaimsControllerErrorMessages = {
|
|
40
|
+
CLAIM_ALREADY_SUBMITTED: 'Claim already submitted',
|
|
41
|
+
INVALID_CLAIM_SIGNATURE: 'Invalid claim signature',
|
|
42
|
+
INVALID_SIGNATURE_MESSAGE: 'Invalid signature message',
|
|
43
|
+
};
|
|
44
|
+
exports.ClaimsServiceErrorMessages = {
|
|
45
|
+
FAILED_TO_GET_CLAIMS: 'Failed to get claims',
|
|
46
|
+
FAILED_TO_GET_CLAIM_BY_ID: 'Failed to get claim by id',
|
|
47
|
+
SIGNATURE_MESSAGE_GENERATION_FAILED: 'Failed to generate message for claim signature',
|
|
48
|
+
CLAIM_SIGNATURE_VERIFICATION_REQUEST_FAILED: 'Failed to verify claim signature',
|
|
49
|
+
};
|
|
50
|
+
//# sourceMappingURL=constants.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.cjs","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":";;;AAAa,QAAA,eAAe,GAAG,kBAAkB,CAAC;AAErC,QAAA,YAAY,GAAG,eAAe,CAAC;AAE5C,IAAY,GAIX;AAJD,WAAY,GAAG;IACb,kBAAW,CAAA;IACX,kBAAW,CAAA;IACX,kBAAW,CAAA;AACb,CAAC,EAJW,GAAG,mBAAH,GAAG,QAId;AAED,IAAY,eAeX;AAfD,WAAY,eAAe;IACzB,4CAA4C;IAC5C,sCAAmB,CAAA;IACnB,wBAAwB;IACxB,0CAAuB,CAAA;IACvB,0BAA0B;IAC1B,8CAA2B,CAAA;IAC3B,6BAA6B;IAC7B,gEAA6C,CAAA;IAC7C,uBAAuB;IACvB,wCAAqB,CAAA;IACrB,uBAAuB;IACvB,wCAAqB,CAAA;IACrB,iBAAiB;IACjB,sCAAmB,CAAA;AACrB,CAAC,EAfW,eAAe,+BAAf,eAAe,QAe1B;AAEY,QAAA,cAAc,GAAwB;IACjD,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,uCAAuC;IAClD,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,uCAAuC;IAClD,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,mCAAmC;CAC/C,CAAC;AAEF,IAAY,qBAGX;AAHD,WAAY,qBAAqB;IAC/B,8DAAqC,CAAA;IACrC,oEAA2C,CAAA;AAC7C,CAAC,EAHW,qBAAqB,qCAArB,qBAAqB,QAGhC;AAEY,QAAA,6BAA6B,GAAG;IAC3C,uBAAuB,EAAE,yBAAyB;IAClD,uBAAuB,EAAE,yBAAyB;IAClD,yBAAyB,EAAE,2BAA2B;CACvD,CAAC;AAEW,QAAA,0BAA0B,GAAG;IACxC,oBAAoB,EAAE,sBAAsB;IAC5C,yBAAyB,EAAE,2BAA2B;IACtD,mCAAmC,EACjC,gDAAgD;IAClD,2CAA2C,EACzC,kCAAkC;CACrC,CAAC","sourcesContent":["export const CONTROLLER_NAME = 'ClaimsController';\n\nexport const SERVICE_NAME = 'ClaimsService';\n\nexport enum Env {\n DEV = 'dev',\n UAT = 'uat',\n PRD = 'prd',\n}\n\nexport enum ClaimStatusEnum {\n // created but not yet submitted to Intercom\n CREATED = 'created',\n // submitted to Intercom\n SUBMITTED = 'submitted',\n // in progress by Intercom\n IN_PROGRESS = 'in_progress',\n // waiting for customer reply\n WAITING_FOR_CUSTOMER = 'waiting_for_customer',\n // approved by Intercom\n APPROVED = 'approved',\n // rejected by Intercom\n REJECTED = 'rejected',\n // unknown status\n UNKNOWN = 'unknown',\n}\n\nexport const CLAIMS_API_URL: Record<Env, string> = {\n [Env.DEV]: 'https://claims.dev-api.cx.metamask.io',\n [Env.UAT]: 'https://claims.uat-api.cx.metamask.io',\n [Env.PRD]: 'https://claims.api.cx.metamask.io',\n};\n\nexport enum HttpContentTypeHeader {\n APPLICATION_JSON = 'application/json',\n MULTIPART_FORM_DATA = 'multipart/form-data',\n}\n\nexport const ClaimsControllerErrorMessages = {\n CLAIM_ALREADY_SUBMITTED: 'Claim already submitted',\n INVALID_CLAIM_SIGNATURE: 'Invalid claim signature',\n INVALID_SIGNATURE_MESSAGE: 'Invalid signature message',\n};\n\nexport const ClaimsServiceErrorMessages = {\n FAILED_TO_GET_CLAIMS: 'Failed to get claims',\n FAILED_TO_GET_CLAIM_BY_ID: 'Failed to get claim by id',\n SIGNATURE_MESSAGE_GENERATION_FAILED:\n 'Failed to generate message for claim signature',\n CLAIM_SIGNATURE_VERIFICATION_REQUEST_FAILED:\n 'Failed to verify claim signature',\n};\n"]}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
export declare const CONTROLLER_NAME = "ClaimsController";
|
|
2
|
+
export declare const SERVICE_NAME = "ClaimsService";
|
|
3
|
+
export declare enum Env {
|
|
4
|
+
DEV = "dev",
|
|
5
|
+
UAT = "uat",
|
|
6
|
+
PRD = "prd"
|
|
7
|
+
}
|
|
8
|
+
export declare enum ClaimStatusEnum {
|
|
9
|
+
CREATED = "created",
|
|
10
|
+
SUBMITTED = "submitted",
|
|
11
|
+
IN_PROGRESS = "in_progress",
|
|
12
|
+
WAITING_FOR_CUSTOMER = "waiting_for_customer",
|
|
13
|
+
APPROVED = "approved",
|
|
14
|
+
REJECTED = "rejected",
|
|
15
|
+
UNKNOWN = "unknown"
|
|
16
|
+
}
|
|
17
|
+
export declare const CLAIMS_API_URL: Record<Env, string>;
|
|
18
|
+
export declare enum HttpContentTypeHeader {
|
|
19
|
+
APPLICATION_JSON = "application/json",
|
|
20
|
+
MULTIPART_FORM_DATA = "multipart/form-data"
|
|
21
|
+
}
|
|
22
|
+
export declare const ClaimsControllerErrorMessages: {
|
|
23
|
+
CLAIM_ALREADY_SUBMITTED: string;
|
|
24
|
+
INVALID_CLAIM_SIGNATURE: string;
|
|
25
|
+
INVALID_SIGNATURE_MESSAGE: string;
|
|
26
|
+
};
|
|
27
|
+
export declare const ClaimsServiceErrorMessages: {
|
|
28
|
+
FAILED_TO_GET_CLAIMS: string;
|
|
29
|
+
FAILED_TO_GET_CLAIM_BY_ID: string;
|
|
30
|
+
SIGNATURE_MESSAGE_GENERATION_FAILED: string;
|
|
31
|
+
CLAIM_SIGNATURE_VERIFICATION_REQUEST_FAILED: string;
|
|
32
|
+
};
|
|
33
|
+
//# sourceMappingURL=constants.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.d.cts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,eAAe,qBAAqB,CAAC;AAElD,eAAO,MAAM,YAAY,kBAAkB,CAAC;AAE5C,oBAAY,GAAG;IACb,GAAG,QAAQ;IACX,GAAG,QAAQ;IACX,GAAG,QAAQ;CACZ;AAED,oBAAY,eAAe;IAEzB,OAAO,YAAY;IAEnB,SAAS,cAAc;IAEvB,WAAW,gBAAgB;IAE3B,oBAAoB,yBAAyB;IAE7C,QAAQ,aAAa;IAErB,QAAQ,aAAa;IAErB,OAAO,YAAY;CACpB;AAED,eAAO,MAAM,cAAc,EAAE,MAAM,CAAC,GAAG,EAAE,MAAM,CAI9C,CAAC;AAEF,oBAAY,qBAAqB;IAC/B,gBAAgB,qBAAqB;IACrC,mBAAmB,wBAAwB;CAC5C;AAED,eAAO,MAAM,6BAA6B;;;;CAIzC,CAAC;AAEF,eAAO,MAAM,0BAA0B;;;;;CAOtC,CAAC"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
export declare const CONTROLLER_NAME = "ClaimsController";
|
|
2
|
+
export declare const SERVICE_NAME = "ClaimsService";
|
|
3
|
+
export declare enum Env {
|
|
4
|
+
DEV = "dev",
|
|
5
|
+
UAT = "uat",
|
|
6
|
+
PRD = "prd"
|
|
7
|
+
}
|
|
8
|
+
export declare enum ClaimStatusEnum {
|
|
9
|
+
CREATED = "created",
|
|
10
|
+
SUBMITTED = "submitted",
|
|
11
|
+
IN_PROGRESS = "in_progress",
|
|
12
|
+
WAITING_FOR_CUSTOMER = "waiting_for_customer",
|
|
13
|
+
APPROVED = "approved",
|
|
14
|
+
REJECTED = "rejected",
|
|
15
|
+
UNKNOWN = "unknown"
|
|
16
|
+
}
|
|
17
|
+
export declare const CLAIMS_API_URL: Record<Env, string>;
|
|
18
|
+
export declare enum HttpContentTypeHeader {
|
|
19
|
+
APPLICATION_JSON = "application/json",
|
|
20
|
+
MULTIPART_FORM_DATA = "multipart/form-data"
|
|
21
|
+
}
|
|
22
|
+
export declare const ClaimsControllerErrorMessages: {
|
|
23
|
+
CLAIM_ALREADY_SUBMITTED: string;
|
|
24
|
+
INVALID_CLAIM_SIGNATURE: string;
|
|
25
|
+
INVALID_SIGNATURE_MESSAGE: string;
|
|
26
|
+
};
|
|
27
|
+
export declare const ClaimsServiceErrorMessages: {
|
|
28
|
+
FAILED_TO_GET_CLAIMS: string;
|
|
29
|
+
FAILED_TO_GET_CLAIM_BY_ID: string;
|
|
30
|
+
SIGNATURE_MESSAGE_GENERATION_FAILED: string;
|
|
31
|
+
CLAIM_SIGNATURE_VERIFICATION_REQUEST_FAILED: string;
|
|
32
|
+
};
|
|
33
|
+
//# sourceMappingURL=constants.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.d.mts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,eAAe,qBAAqB,CAAC;AAElD,eAAO,MAAM,YAAY,kBAAkB,CAAC;AAE5C,oBAAY,GAAG;IACb,GAAG,QAAQ;IACX,GAAG,QAAQ;IACX,GAAG,QAAQ;CACZ;AAED,oBAAY,eAAe;IAEzB,OAAO,YAAY;IAEnB,SAAS,cAAc;IAEvB,WAAW,gBAAgB;IAE3B,oBAAoB,yBAAyB;IAE7C,QAAQ,aAAa;IAErB,QAAQ,aAAa;IAErB,OAAO,YAAY;CACpB;AAED,eAAO,MAAM,cAAc,EAAE,MAAM,CAAC,GAAG,EAAE,MAAM,CAI9C,CAAC;AAEF,oBAAY,qBAAqB;IAC/B,gBAAgB,qBAAqB;IACrC,mBAAmB,wBAAwB;CAC5C;AAED,eAAO,MAAM,6BAA6B;;;;CAIzC,CAAC;AAEF,eAAO,MAAM,0BAA0B;;;;;CAOtC,CAAC"}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
export const CONTROLLER_NAME = 'ClaimsController';
|
|
2
|
+
export const SERVICE_NAME = 'ClaimsService';
|
|
3
|
+
export var Env;
|
|
4
|
+
(function (Env) {
|
|
5
|
+
Env["DEV"] = "dev";
|
|
6
|
+
Env["UAT"] = "uat";
|
|
7
|
+
Env["PRD"] = "prd";
|
|
8
|
+
})(Env || (Env = {}));
|
|
9
|
+
export var ClaimStatusEnum;
|
|
10
|
+
(function (ClaimStatusEnum) {
|
|
11
|
+
// created but not yet submitted to Intercom
|
|
12
|
+
ClaimStatusEnum["CREATED"] = "created";
|
|
13
|
+
// submitted to Intercom
|
|
14
|
+
ClaimStatusEnum["SUBMITTED"] = "submitted";
|
|
15
|
+
// in progress by Intercom
|
|
16
|
+
ClaimStatusEnum["IN_PROGRESS"] = "in_progress";
|
|
17
|
+
// waiting for customer reply
|
|
18
|
+
ClaimStatusEnum["WAITING_FOR_CUSTOMER"] = "waiting_for_customer";
|
|
19
|
+
// approved by Intercom
|
|
20
|
+
ClaimStatusEnum["APPROVED"] = "approved";
|
|
21
|
+
// rejected by Intercom
|
|
22
|
+
ClaimStatusEnum["REJECTED"] = "rejected";
|
|
23
|
+
// unknown status
|
|
24
|
+
ClaimStatusEnum["UNKNOWN"] = "unknown";
|
|
25
|
+
})(ClaimStatusEnum || (ClaimStatusEnum = {}));
|
|
26
|
+
export const CLAIMS_API_URL = {
|
|
27
|
+
[Env.DEV]: 'https://claims.dev-api.cx.metamask.io',
|
|
28
|
+
[Env.UAT]: 'https://claims.uat-api.cx.metamask.io',
|
|
29
|
+
[Env.PRD]: 'https://claims.api.cx.metamask.io',
|
|
30
|
+
};
|
|
31
|
+
export var HttpContentTypeHeader;
|
|
32
|
+
(function (HttpContentTypeHeader) {
|
|
33
|
+
HttpContentTypeHeader["APPLICATION_JSON"] = "application/json";
|
|
34
|
+
HttpContentTypeHeader["MULTIPART_FORM_DATA"] = "multipart/form-data";
|
|
35
|
+
})(HttpContentTypeHeader || (HttpContentTypeHeader = {}));
|
|
36
|
+
export const ClaimsControllerErrorMessages = {
|
|
37
|
+
CLAIM_ALREADY_SUBMITTED: 'Claim already submitted',
|
|
38
|
+
INVALID_CLAIM_SIGNATURE: 'Invalid claim signature',
|
|
39
|
+
INVALID_SIGNATURE_MESSAGE: 'Invalid signature message',
|
|
40
|
+
};
|
|
41
|
+
export const ClaimsServiceErrorMessages = {
|
|
42
|
+
FAILED_TO_GET_CLAIMS: 'Failed to get claims',
|
|
43
|
+
FAILED_TO_GET_CLAIM_BY_ID: 'Failed to get claim by id',
|
|
44
|
+
SIGNATURE_MESSAGE_GENERATION_FAILED: 'Failed to generate message for claim signature',
|
|
45
|
+
CLAIM_SIGNATURE_VERIFICATION_REQUEST_FAILED: 'Failed to verify claim signature',
|
|
46
|
+
};
|
|
47
|
+
//# sourceMappingURL=constants.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.mjs","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,eAAe,GAAG,kBAAkB,CAAC;AAElD,MAAM,CAAC,MAAM,YAAY,GAAG,eAAe,CAAC;AAE5C,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,CAAN,IAAY,eAeX;AAfD,WAAY,eAAe;IACzB,4CAA4C;IAC5C,sCAAmB,CAAA;IACnB,wBAAwB;IACxB,0CAAuB,CAAA;IACvB,0BAA0B;IAC1B,8CAA2B,CAAA;IAC3B,6BAA6B;IAC7B,gEAA6C,CAAA;IAC7C,uBAAuB;IACvB,wCAAqB,CAAA;IACrB,uBAAuB;IACvB,wCAAqB,CAAA;IACrB,iBAAiB;IACjB,sCAAmB,CAAA;AACrB,CAAC,EAfW,eAAe,KAAf,eAAe,QAe1B;AAED,MAAM,CAAC,MAAM,cAAc,GAAwB;IACjD,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,uCAAuC;IAClD,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,uCAAuC;IAClD,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,mCAAmC;CAC/C,CAAC;AAEF,MAAM,CAAN,IAAY,qBAGX;AAHD,WAAY,qBAAqB;IAC/B,8DAAqC,CAAA;IACrC,oEAA2C,CAAA;AAC7C,CAAC,EAHW,qBAAqB,KAArB,qBAAqB,QAGhC;AAED,MAAM,CAAC,MAAM,6BAA6B,GAAG;IAC3C,uBAAuB,EAAE,yBAAyB;IAClD,uBAAuB,EAAE,yBAAyB;IAClD,yBAAyB,EAAE,2BAA2B;CACvD,CAAC;AAEF,MAAM,CAAC,MAAM,0BAA0B,GAAG;IACxC,oBAAoB,EAAE,sBAAsB;IAC5C,yBAAyB,EAAE,2BAA2B;IACtD,mCAAmC,EACjC,gDAAgD;IAClD,2CAA2C,EACzC,kCAAkC;CACrC,CAAC","sourcesContent":["export const CONTROLLER_NAME = 'ClaimsController';\n\nexport const SERVICE_NAME = 'ClaimsService';\n\nexport enum Env {\n DEV = 'dev',\n UAT = 'uat',\n PRD = 'prd',\n}\n\nexport enum ClaimStatusEnum {\n // created but not yet submitted to Intercom\n CREATED = 'created',\n // submitted to Intercom\n SUBMITTED = 'submitted',\n // in progress by Intercom\n IN_PROGRESS = 'in_progress',\n // waiting for customer reply\n WAITING_FOR_CUSTOMER = 'waiting_for_customer',\n // approved by Intercom\n APPROVED = 'approved',\n // rejected by Intercom\n REJECTED = 'rejected',\n // unknown status\n UNKNOWN = 'unknown',\n}\n\nexport const CLAIMS_API_URL: Record<Env, string> = {\n [Env.DEV]: 'https://claims.dev-api.cx.metamask.io',\n [Env.UAT]: 'https://claims.uat-api.cx.metamask.io',\n [Env.PRD]: 'https://claims.api.cx.metamask.io',\n};\n\nexport enum HttpContentTypeHeader {\n APPLICATION_JSON = 'application/json',\n MULTIPART_FORM_DATA = 'multipart/form-data',\n}\n\nexport const ClaimsControllerErrorMessages = {\n CLAIM_ALREADY_SUBMITTED: 'Claim already submitted',\n INVALID_CLAIM_SIGNATURE: 'Invalid claim signature',\n INVALID_SIGNATURE_MESSAGE: 'Invalid signature message',\n};\n\nexport const ClaimsServiceErrorMessages = {\n FAILED_TO_GET_CLAIMS: 'Failed to get claims',\n FAILED_TO_GET_CLAIM_BY_ID: 'Failed to get claim by id',\n SIGNATURE_MESSAGE_GENERATION_FAILED:\n 'Failed to generate message for claim signature',\n CLAIM_SIGNATURE_VERIFICATION_REQUEST_FAILED:\n 'Failed to verify claim signature',\n};\n"]}
|
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ClaimsControllerErrorMessages = exports.Env = exports.ClaimStatusEnum = exports.ClaimsService = exports.getDefaultClaimsControllerState = exports.ClaimsController = void 0;
|
|
4
|
+
var ClaimsController_1 = require("./ClaimsController.cjs");
|
|
5
|
+
Object.defineProperty(exports, "ClaimsController", { enumerable: true, get: function () { return ClaimsController_1.ClaimsController; } });
|
|
6
|
+
Object.defineProperty(exports, "getDefaultClaimsControllerState", { enumerable: true, get: function () { return ClaimsController_1.getDefaultClaimsControllerState; } });
|
|
7
|
+
var ClaimsService_1 = require("./ClaimsService.cjs");
|
|
8
|
+
Object.defineProperty(exports, "ClaimsService", { enumerable: true, get: function () { return ClaimsService_1.ClaimsService; } });
|
|
9
|
+
var constants_1 = require("./constants.cjs");
|
|
10
|
+
Object.defineProperty(exports, "ClaimStatusEnum", { enumerable: true, get: function () { return constants_1.ClaimStatusEnum; } });
|
|
11
|
+
Object.defineProperty(exports, "Env", { enumerable: true, get: function () { return constants_1.Env; } });
|
|
12
|
+
Object.defineProperty(exports, "ClaimsControllerErrorMessages", { enumerable: true, get: function () { return constants_1.ClaimsControllerErrorMessages; } });
|
|
13
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.cjs","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAAA,2DAG4B;AAF1B,oHAAA,gBAAgB,OAAA;AAChB,mIAAA,+BAA+B,OAAA;AAYjC,qDAAgD;AAAvC,8GAAA,aAAa,OAAA;AAYtB,6CAIqB;AAHnB,4GAAA,eAAe,OAAA;AACf,gGAAA,GAAG,OAAA;AACH,0HAAA,6BAA6B,OAAA","sourcesContent":["export {\n ClaimsController,\n getDefaultClaimsControllerState,\n} from './ClaimsController';\n\nexport type {\n ClaimsControllerGetStateAction,\n ClaimsControllerActions,\n ClaimsControllerStateChangeEvent,\n ClaimsControllerMessenger,\n} from './ClaimsController';\n\nexport type { Claim, ClaimsControllerState, Attachment } from './types';\n\nexport { ClaimsService } from './ClaimsService';\n\nexport type {\n ClaimsServiceGetClaimsAction,\n ClaimsServiceGetRequestHeadersAction,\n ClaimsServiceGetClaimsApiUrlAction,\n ClaimsServiceGetClaimByIdAction,\n ClaimsServiceGenerateMessageForClaimSignatureAction,\n ClaimsServiceActions,\n ClaimsServiceMessenger,\n} from './ClaimsService';\n\nexport {\n ClaimStatusEnum,\n Env,\n ClaimsControllerErrorMessages,\n} from './constants';\n"]}
|
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export { ClaimsController, getDefaultClaimsControllerState, } from "./ClaimsController.cjs";
|
|
2
|
+
export type { ClaimsControllerGetStateAction, ClaimsControllerActions, ClaimsControllerStateChangeEvent, ClaimsControllerMessenger, } from "./ClaimsController.cjs";
|
|
3
|
+
export type { Claim, ClaimsControllerState, Attachment } from "./types.cjs";
|
|
4
|
+
export { ClaimsService } from "./ClaimsService.cjs";
|
|
5
|
+
export type { ClaimsServiceGetClaimsAction, ClaimsServiceGetRequestHeadersAction, ClaimsServiceGetClaimsApiUrlAction, ClaimsServiceGetClaimByIdAction, ClaimsServiceGenerateMessageForClaimSignatureAction, ClaimsServiceActions, ClaimsServiceMessenger, } from "./ClaimsService.cjs";
|
|
6
|
+
export { ClaimStatusEnum, Env, ClaimsControllerErrorMessages, } 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,OAAO,EACL,gBAAgB,EAChB,+BAA+B,GAChC,+BAA2B;AAE5B,YAAY,EACV,8BAA8B,EAC9B,uBAAuB,EACvB,gCAAgC,EAChC,yBAAyB,GAC1B,+BAA2B;AAE5B,YAAY,EAAE,KAAK,EAAE,qBAAqB,EAAE,UAAU,EAAE,oBAAgB;AAExE,OAAO,EAAE,aAAa,EAAE,4BAAwB;AAEhD,YAAY,EACV,4BAA4B,EAC5B,oCAAoC,EACpC,kCAAkC,EAClC,+BAA+B,EAC/B,mDAAmD,EACnD,oBAAoB,EACpB,sBAAsB,GACvB,4BAAwB;AAEzB,OAAO,EACL,eAAe,EACf,GAAG,EACH,6BAA6B,GAC9B,wBAAoB"}
|
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export { ClaimsController, getDefaultClaimsControllerState, } from "./ClaimsController.mjs";
|
|
2
|
+
export type { ClaimsControllerGetStateAction, ClaimsControllerActions, ClaimsControllerStateChangeEvent, ClaimsControllerMessenger, } from "./ClaimsController.mjs";
|
|
3
|
+
export type { Claim, ClaimsControllerState, Attachment } from "./types.mjs";
|
|
4
|
+
export { ClaimsService } from "./ClaimsService.mjs";
|
|
5
|
+
export type { ClaimsServiceGetClaimsAction, ClaimsServiceGetRequestHeadersAction, ClaimsServiceGetClaimsApiUrlAction, ClaimsServiceGetClaimByIdAction, ClaimsServiceGenerateMessageForClaimSignatureAction, ClaimsServiceActions, ClaimsServiceMessenger, } from "./ClaimsService.mjs";
|
|
6
|
+
export { ClaimStatusEnum, Env, ClaimsControllerErrorMessages, } 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,OAAO,EACL,gBAAgB,EAChB,+BAA+B,GAChC,+BAA2B;AAE5B,YAAY,EACV,8BAA8B,EAC9B,uBAAuB,EACvB,gCAAgC,EAChC,yBAAyB,GAC1B,+BAA2B;AAE5B,YAAY,EAAE,KAAK,EAAE,qBAAqB,EAAE,UAAU,EAAE,oBAAgB;AAExE,OAAO,EAAE,aAAa,EAAE,4BAAwB;AAEhD,YAAY,EACV,4BAA4B,EAC5B,oCAAoC,EACpC,kCAAkC,EAClC,+BAA+B,EAC/B,mDAAmD,EACnD,oBAAoB,EACpB,sBAAsB,GACvB,4BAAwB;AAEzB,OAAO,EACL,eAAe,EACf,GAAG,EACH,6BAA6B,GAC9B,wBAAoB"}
|
package/dist/index.mjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.mjs","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,gBAAgB,EAChB,+BAA+B,EAChC,+BAA2B;AAW5B,OAAO,EAAE,aAAa,EAAE,4BAAwB;AAYhD,OAAO,EACL,eAAe,EACf,GAAG,EACH,6BAA6B,EAC9B,wBAAoB","sourcesContent":["export {\n ClaimsController,\n getDefaultClaimsControllerState,\n} from './ClaimsController';\n\nexport type {\n ClaimsControllerGetStateAction,\n ClaimsControllerActions,\n ClaimsControllerStateChangeEvent,\n ClaimsControllerMessenger,\n} from './ClaimsController';\n\nexport type { Claim, ClaimsControllerState, Attachment } from './types';\n\nexport { ClaimsService } from './ClaimsService';\n\nexport type {\n ClaimsServiceGetClaimsAction,\n ClaimsServiceGetRequestHeadersAction,\n ClaimsServiceGetClaimsApiUrlAction,\n ClaimsServiceGetClaimByIdAction,\n ClaimsServiceGenerateMessageForClaimSignatureAction,\n ClaimsServiceActions,\n ClaimsServiceMessenger,\n} from './ClaimsService';\n\nexport {\n ClaimStatusEnum,\n Env,\n ClaimsControllerErrorMessages,\n} from './constants';\n"]}
|
package/dist/types.cjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.cjs","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"","sourcesContent":["import type { Hex } from '@metamask/utils';\n\nimport type { ClaimStatusEnum } from './constants';\n\nexport type Attachment = {\n publicUrl: string;\n contentType: string;\n originalname: string;\n};\n\nexport type Claim = {\n id: string;\n shortId: string;\n chainId: string;\n email: string;\n impactedWalletAddress: Hex;\n impactedTxHash: Hex;\n reimbursementWalletAddress: Hex;\n description: string;\n signature: Hex;\n attachments?: Attachment[];\n status: ClaimStatusEnum;\n createdAt: string;\n updatedAt: string;\n intercomId?: string;\n};\n\nexport type CreateClaimRequest = Omit<\n Claim,\n 'id' | 'shortId' | 'createdAt' | 'updatedAt' | 'intercomId' | 'status'\n>;\n\nexport type ClaimsControllerState = {\n claims: Claim[];\n};\n\nexport type SubmitClaimConfig = {\n /**\n * The sanitized and validated data to be submitted.\n */\n data: CreateClaimRequest;\n /**\n * The headers to be used in the request.\n */\n headers: Record<string, string>;\n /**\n * The HTTP method to submit.\n */\n method: 'POST';\n /**\n * The URL to submit the claim to.\n */\n url: string;\n};\n\nexport type GenerateSignatureMessageResponse = {\n message: string;\n nonce: string;\n};\n\nexport type VerifyClaimSignatureResponse = {\n message: string;\n success: boolean;\n};\n"]}
|
package/dist/types.d.cts
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import type { Hex } from "@metamask/utils";
|
|
2
|
+
import type { ClaimStatusEnum } from "./constants.cjs";
|
|
3
|
+
export type Attachment = {
|
|
4
|
+
publicUrl: string;
|
|
5
|
+
contentType: string;
|
|
6
|
+
originalname: string;
|
|
7
|
+
};
|
|
8
|
+
export type Claim = {
|
|
9
|
+
id: string;
|
|
10
|
+
shortId: string;
|
|
11
|
+
chainId: string;
|
|
12
|
+
email: string;
|
|
13
|
+
impactedWalletAddress: Hex;
|
|
14
|
+
impactedTxHash: Hex;
|
|
15
|
+
reimbursementWalletAddress: Hex;
|
|
16
|
+
description: string;
|
|
17
|
+
signature: Hex;
|
|
18
|
+
attachments?: Attachment[];
|
|
19
|
+
status: ClaimStatusEnum;
|
|
20
|
+
createdAt: string;
|
|
21
|
+
updatedAt: string;
|
|
22
|
+
intercomId?: string;
|
|
23
|
+
};
|
|
24
|
+
export type CreateClaimRequest = Omit<Claim, 'id' | 'shortId' | 'createdAt' | 'updatedAt' | 'intercomId' | 'status'>;
|
|
25
|
+
export type ClaimsControllerState = {
|
|
26
|
+
claims: Claim[];
|
|
27
|
+
};
|
|
28
|
+
export type SubmitClaimConfig = {
|
|
29
|
+
/**
|
|
30
|
+
* The sanitized and validated data to be submitted.
|
|
31
|
+
*/
|
|
32
|
+
data: CreateClaimRequest;
|
|
33
|
+
/**
|
|
34
|
+
* The headers to be used in the request.
|
|
35
|
+
*/
|
|
36
|
+
headers: Record<string, string>;
|
|
37
|
+
/**
|
|
38
|
+
* The HTTP method to submit.
|
|
39
|
+
*/
|
|
40
|
+
method: 'POST';
|
|
41
|
+
/**
|
|
42
|
+
* The URL to submit the claim to.
|
|
43
|
+
*/
|
|
44
|
+
url: string;
|
|
45
|
+
};
|
|
46
|
+
export type GenerateSignatureMessageResponse = {
|
|
47
|
+
message: string;
|
|
48
|
+
nonce: string;
|
|
49
|
+
};
|
|
50
|
+
export type VerifyClaimSignatureResponse = {
|
|
51
|
+
message: string;
|
|
52
|
+
success: boolean;
|
|
53
|
+
};
|
|
54
|
+
//# sourceMappingURL=types.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.cts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,wBAAwB;AAE3C,OAAO,KAAK,EAAE,eAAe,EAAE,wBAAoB;AAEnD,MAAM,MAAM,UAAU,GAAG;IACvB,SAAS,EAAE,MAAM,CAAC;IAClB,WAAW,EAAE,MAAM,CAAC;IACpB,YAAY,EAAE,MAAM,CAAC;CACtB,CAAC;AAEF,MAAM,MAAM,KAAK,GAAG;IAClB,EAAE,EAAE,MAAM,CAAC;IACX,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,MAAM,CAAC;IACd,qBAAqB,EAAE,GAAG,CAAC;IAC3B,cAAc,EAAE,GAAG,CAAC;IACpB,0BAA0B,EAAE,GAAG,CAAC;IAChC,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,EAAE,GAAG,CAAC;IACf,WAAW,CAAC,EAAE,UAAU,EAAE,CAAC;IAC3B,MAAM,EAAE,eAAe,CAAC;IACxB,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB,CAAC;AAEF,MAAM,MAAM,kBAAkB,GAAG,IAAI,CACnC,KAAK,EACL,IAAI,GAAG,SAAS,GAAG,WAAW,GAAG,WAAW,GAAG,YAAY,GAAG,QAAQ,CACvE,CAAC;AAEF,MAAM,MAAM,qBAAqB,GAAG;IAClC,MAAM,EAAE,KAAK,EAAE,CAAC;CACjB,CAAC;AAEF,MAAM,MAAM,iBAAiB,GAAG;IAC9B;;OAEG;IACH,IAAI,EAAE,kBAAkB,CAAC;IACzB;;OAEG;IACH,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAChC;;OAEG;IACH,MAAM,EAAE,MAAM,CAAC;IACf;;OAEG;IACH,GAAG,EAAE,MAAM,CAAC;CACb,CAAC;AAEF,MAAM,MAAM,gCAAgC,GAAG;IAC7C,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,MAAM,CAAC;CACf,CAAC;AAEF,MAAM,MAAM,4BAA4B,GAAG;IACzC,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,OAAO,CAAC;CAClB,CAAC"}
|
package/dist/types.d.mts
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import type { Hex } from "@metamask/utils";
|
|
2
|
+
import type { ClaimStatusEnum } from "./constants.mjs";
|
|
3
|
+
export type Attachment = {
|
|
4
|
+
publicUrl: string;
|
|
5
|
+
contentType: string;
|
|
6
|
+
originalname: string;
|
|
7
|
+
};
|
|
8
|
+
export type Claim = {
|
|
9
|
+
id: string;
|
|
10
|
+
shortId: string;
|
|
11
|
+
chainId: string;
|
|
12
|
+
email: string;
|
|
13
|
+
impactedWalletAddress: Hex;
|
|
14
|
+
impactedTxHash: Hex;
|
|
15
|
+
reimbursementWalletAddress: Hex;
|
|
16
|
+
description: string;
|
|
17
|
+
signature: Hex;
|
|
18
|
+
attachments?: Attachment[];
|
|
19
|
+
status: ClaimStatusEnum;
|
|
20
|
+
createdAt: string;
|
|
21
|
+
updatedAt: string;
|
|
22
|
+
intercomId?: string;
|
|
23
|
+
};
|
|
24
|
+
export type CreateClaimRequest = Omit<Claim, 'id' | 'shortId' | 'createdAt' | 'updatedAt' | 'intercomId' | 'status'>;
|
|
25
|
+
export type ClaimsControllerState = {
|
|
26
|
+
claims: Claim[];
|
|
27
|
+
};
|
|
28
|
+
export type SubmitClaimConfig = {
|
|
29
|
+
/**
|
|
30
|
+
* The sanitized and validated data to be submitted.
|
|
31
|
+
*/
|
|
32
|
+
data: CreateClaimRequest;
|
|
33
|
+
/**
|
|
34
|
+
* The headers to be used in the request.
|
|
35
|
+
*/
|
|
36
|
+
headers: Record<string, string>;
|
|
37
|
+
/**
|
|
38
|
+
* The HTTP method to submit.
|
|
39
|
+
*/
|
|
40
|
+
method: 'POST';
|
|
41
|
+
/**
|
|
42
|
+
* The URL to submit the claim to.
|
|
43
|
+
*/
|
|
44
|
+
url: string;
|
|
45
|
+
};
|
|
46
|
+
export type GenerateSignatureMessageResponse = {
|
|
47
|
+
message: string;
|
|
48
|
+
nonce: string;
|
|
49
|
+
};
|
|
50
|
+
export type VerifyClaimSignatureResponse = {
|
|
51
|
+
message: string;
|
|
52
|
+
success: boolean;
|
|
53
|
+
};
|
|
54
|
+
//# sourceMappingURL=types.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.mts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,wBAAwB;AAE3C,OAAO,KAAK,EAAE,eAAe,EAAE,wBAAoB;AAEnD,MAAM,MAAM,UAAU,GAAG;IACvB,SAAS,EAAE,MAAM,CAAC;IAClB,WAAW,EAAE,MAAM,CAAC;IACpB,YAAY,EAAE,MAAM,CAAC;CACtB,CAAC;AAEF,MAAM,MAAM,KAAK,GAAG;IAClB,EAAE,EAAE,MAAM,CAAC;IACX,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,MAAM,CAAC;IACd,qBAAqB,EAAE,GAAG,CAAC;IAC3B,cAAc,EAAE,GAAG,CAAC;IACpB,0BAA0B,EAAE,GAAG,CAAC;IAChC,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,EAAE,GAAG,CAAC;IACf,WAAW,CAAC,EAAE,UAAU,EAAE,CAAC;IAC3B,MAAM,EAAE,eAAe,CAAC;IACxB,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB,CAAC;AAEF,MAAM,MAAM,kBAAkB,GAAG,IAAI,CACnC,KAAK,EACL,IAAI,GAAG,SAAS,GAAG,WAAW,GAAG,WAAW,GAAG,YAAY,GAAG,QAAQ,CACvE,CAAC;AAEF,MAAM,MAAM,qBAAqB,GAAG;IAClC,MAAM,EAAE,KAAK,EAAE,CAAC;CACjB,CAAC;AAEF,MAAM,MAAM,iBAAiB,GAAG;IAC9B;;OAEG;IACH,IAAI,EAAE,kBAAkB,CAAC;IACzB;;OAEG;IACH,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAChC;;OAEG;IACH,MAAM,EAAE,MAAM,CAAC;IACf;;OAEG;IACH,GAAG,EAAE,MAAM,CAAC;CACb,CAAC;AAEF,MAAM,MAAM,gCAAgC,GAAG;IAC7C,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,MAAM,CAAC;CACf,CAAC;AAEF,MAAM,MAAM,4BAA4B,GAAG;IACzC,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,OAAO,CAAC;CAClB,CAAC"}
|
package/dist/types.mjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.mjs","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"","sourcesContent":["import type { Hex } from '@metamask/utils';\n\nimport type { ClaimStatusEnum } from './constants';\n\nexport type Attachment = {\n publicUrl: string;\n contentType: string;\n originalname: string;\n};\n\nexport type Claim = {\n id: string;\n shortId: string;\n chainId: string;\n email: string;\n impactedWalletAddress: Hex;\n impactedTxHash: Hex;\n reimbursementWalletAddress: Hex;\n description: string;\n signature: Hex;\n attachments?: Attachment[];\n status: ClaimStatusEnum;\n createdAt: string;\n updatedAt: string;\n intercomId?: string;\n};\n\nexport type CreateClaimRequest = Omit<\n Claim,\n 'id' | 'shortId' | 'createdAt' | 'updatedAt' | 'intercomId' | 'status'\n>;\n\nexport type ClaimsControllerState = {\n claims: Claim[];\n};\n\nexport type SubmitClaimConfig = {\n /**\n * The sanitized and validated data to be submitted.\n */\n data: CreateClaimRequest;\n /**\n * The headers to be used in the request.\n */\n headers: Record<string, string>;\n /**\n * The HTTP method to submit.\n */\n method: 'POST';\n /**\n * The URL to submit the claim to.\n */\n url: string;\n};\n\nexport type GenerateSignatureMessageResponse = {\n message: string;\n nonce: string;\n};\n\nexport type VerifyClaimSignatureResponse = {\n message: string;\n success: boolean;\n};\n"]}
|