@metamask-previews/claims-controller 0.6.1-preview-4f4c98e → 0.6.1-preview-eb263b0ee

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (106) hide show
  1. package/CHANGELOG.md +0 -1
  2. package/dist/ClaimsController-method-action-types.cjs +7 -0
  3. package/dist/ClaimsController-method-action-types.cjs.map +1 -0
  4. package/dist/{ClaimsController-method-action-types.d.ts → ClaimsController-method-action-types.d.cts} +2 -2
  5. package/dist/ClaimsController-method-action-types.d.cts.map +1 -0
  6. package/dist/ClaimsController-method-action-types.d.mts +93 -0
  7. package/dist/ClaimsController-method-action-types.d.mts.map +1 -0
  8. package/dist/{ClaimsController-method-action-types.js → ClaimsController-method-action-types.mjs} +1 -1
  9. package/dist/ClaimsController-method-action-types.mjs.map +1 -0
  10. package/dist/ClaimsController.cjs +221 -0
  11. package/dist/ClaimsController.cjs.map +1 -0
  12. package/dist/{ClaimsController.d.ts → ClaimsController.d.cts} +9 -9
  13. package/dist/ClaimsController.d.cts.map +1 -0
  14. package/dist/ClaimsController.d.mts +84 -0
  15. package/dist/ClaimsController.d.mts.map +1 -0
  16. package/dist/{ClaimsController.js → ClaimsController.mjs} +5 -5
  17. package/dist/ClaimsController.mjs.map +1 -0
  18. package/dist/ClaimsService-method-action-types.cjs +7 -0
  19. package/dist/ClaimsService-method-action-types.cjs.map +1 -0
  20. package/dist/{ClaimsService-method-action-types.d.ts → ClaimsService-method-action-types.d.cts} +2 -2
  21. package/dist/ClaimsService-method-action-types.d.cts.map +1 -0
  22. package/dist/ClaimsService-method-action-types.d.mts +67 -0
  23. package/dist/ClaimsService-method-action-types.d.mts.map +1 -0
  24. package/dist/{ClaimsService-method-action-types.js → ClaimsService-method-action-types.mjs} +1 -1
  25. package/dist/ClaimsService-method-action-types.mjs.map +1 -0
  26. package/dist/ClaimsService-structs.cjs +36 -0
  27. package/dist/ClaimsService-structs.cjs.map +1 -0
  28. package/dist/{ClaimsService-structs.d.ts → ClaimsService-structs.d.cts} +8 -8
  29. package/dist/ClaimsService-structs.d.cts.map +1 -0
  30. package/dist/ClaimsService-structs.d.mts +71 -0
  31. package/dist/ClaimsService-structs.d.mts.map +1 -0
  32. package/dist/{ClaimsService-structs.js → ClaimsService-structs.mjs} +3 -3
  33. package/dist/ClaimsService-structs.mjs.map +1 -0
  34. package/dist/ClaimsService.cjs +229 -0
  35. package/dist/ClaimsService.cjs.map +1 -0
  36. package/dist/{ClaimsService.d.ts → ClaimsService.d.cts} +12 -12
  37. package/dist/ClaimsService.d.cts.map +1 -0
  38. package/dist/ClaimsService.d.mts +108 -0
  39. package/dist/ClaimsService.d.mts.map +1 -0
  40. package/dist/{ClaimsService.js → ClaimsService.mjs} +7 -7
  41. package/dist/ClaimsService.mjs.map +1 -0
  42. package/dist/constants.cjs +59 -0
  43. package/dist/constants.cjs.map +1 -0
  44. package/dist/{constants.d.ts → constants.d.cts} +1 -1
  45. package/dist/constants.d.cts.map +1 -0
  46. package/dist/constants.d.mts +37 -0
  47. package/dist/constants.d.mts.map +1 -0
  48. package/dist/{constants.js → constants.mjs} +2 -2
  49. package/dist/constants.mjs.map +1 -0
  50. package/dist/index.cjs +16 -0
  51. package/dist/index.cjs.map +1 -0
  52. package/dist/{index.d.ts → index.d.cts} +9 -9
  53. package/dist/index.d.cts.map +1 -0
  54. package/dist/index.d.mts +9 -0
  55. package/dist/index.d.mts.map +1 -0
  56. package/dist/index.mjs +4 -0
  57. package/dist/index.mjs.map +1 -0
  58. package/dist/logger.cjs +8 -0
  59. package/dist/logger.cjs.map +1 -0
  60. package/dist/logger.d.cts +5 -0
  61. package/dist/logger.d.cts.map +1 -0
  62. package/dist/logger.d.mts +5 -0
  63. package/dist/logger.d.mts.map +1 -0
  64. package/dist/logger.mjs +5 -0
  65. package/dist/logger.mjs.map +1 -0
  66. package/dist/types.cjs +3 -0
  67. package/dist/types.cjs.map +1 -0
  68. package/dist/{types.d.ts → types.d.cts} +3 -3
  69. package/dist/types.d.cts.map +1 -0
  70. package/dist/types.d.mts +85 -0
  71. package/dist/types.d.mts.map +1 -0
  72. package/dist/types.mjs +2 -0
  73. package/dist/types.mjs.map +1 -0
  74. package/dist/utils.cjs +49 -0
  75. package/dist/utils.cjs.map +1 -0
  76. package/dist/{utils.d.ts → utils.d.cts} +1 -1
  77. package/dist/utils.d.cts.map +1 -0
  78. package/dist/utils.d.mts +16 -0
  79. package/dist/utils.d.mts.map +1 -0
  80. package/dist/{utils.js → utils.mjs} +1 -1
  81. package/dist/utils.mjs.map +1 -0
  82. package/package.json +16 -12
  83. package/dist/ClaimsController-method-action-types.d.ts.map +0 -1
  84. package/dist/ClaimsController-method-action-types.js.map +0 -1
  85. package/dist/ClaimsController.d.ts.map +0 -1
  86. package/dist/ClaimsController.js.map +0 -1
  87. package/dist/ClaimsService-method-action-types.d.ts.map +0 -1
  88. package/dist/ClaimsService-method-action-types.js.map +0 -1
  89. package/dist/ClaimsService-structs.d.ts.map +0 -1
  90. package/dist/ClaimsService-structs.js.map +0 -1
  91. package/dist/ClaimsService.d.ts.map +0 -1
  92. package/dist/ClaimsService.js.map +0 -1
  93. package/dist/constants.d.ts.map +0 -1
  94. package/dist/constants.js.map +0 -1
  95. package/dist/index.d.ts.map +0 -1
  96. package/dist/index.js +0 -4
  97. package/dist/index.js.map +0 -1
  98. package/dist/logger.d.ts +0 -4
  99. package/dist/logger.d.ts.map +0 -1
  100. package/dist/logger.js +0 -5
  101. package/dist/logger.js.map +0 -1
  102. package/dist/types.d.ts.map +0 -1
  103. package/dist/types.js +0 -2
  104. package/dist/types.js.map +0 -1
  105. package/dist/utils.d.ts.map +0 -1
  106. package/dist/utils.js.map +0 -1
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ClaimsService-method-action-types.d.cts","sourceRoot":"","sources":["../src/ClaimsService-method-action-types.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,4BAA2B;AAExD;;;;GAIG;AACH,MAAM,MAAM,4CAA4C,GAAG;IACzD,IAAI,EAAE,yCAAyC,CAAC;IAChD,OAAO,EAAE,aAAa,CAAC,2BAA2B,CAAC,CAAC;CACrD,CAAC;AAEF;;;;GAIG;AACH,MAAM,MAAM,4BAA4B,GAAG;IACzC,IAAI,EAAE,yBAAyB,CAAC;IAChC,OAAO,EAAE,aAAa,CAAC,WAAW,CAAC,CAAC;CACrC,CAAC;AAEF;;;;;GAKG;AACH,MAAM,MAAM,+BAA+B,GAAG;IAC5C,IAAI,EAAE,4BAA4B,CAAC;IACnC,OAAO,EAAE,aAAa,CAAC,cAAc,CAAC,CAAC;CACxC,CAAC;AAEF;;;;;;GAMG;AACH,MAAM,MAAM,mDAAmD,GAAG;IAChE,IAAI,EAAE,gDAAgD,CAAC;IACvD,OAAO,EAAE,aAAa,CAAC,kCAAkC,CAAC,CAAC;CAC5D,CAAC;AAEF;;;;GAIG;AACH,MAAM,MAAM,oCAAoC,GAAG;IACjD,IAAI,EAAE,iCAAiC,CAAC;IACxC,OAAO,EAAE,aAAa,CAAC,mBAAmB,CAAC,CAAC;CAC7C,CAAC;AAEF;;;;GAIG;AACH,MAAM,MAAM,kCAAkC,GAAG;IAC/C,IAAI,EAAE,+BAA+B,CAAC;IACtC,OAAO,EAAE,aAAa,CAAC,iBAAiB,CAAC,CAAC;CAC3C,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,0BAA0B,GAClC,4CAA4C,GAC5C,4BAA4B,GAC5B,+BAA+B,GAC/B,mDAAmD,GACnD,oCAAoC,GACpC,kCAAkC,CAAC"}
@@ -0,0 +1,67 @@
1
+ /**
2
+ * This file is auto generated.
3
+ * Do not edit manually.
4
+ */
5
+ import type { ClaimsService } from "./ClaimsService.mjs";
6
+ /**
7
+ * Fetch required configurations for the claims service.
8
+ *
9
+ * @returns The required configurations for the claims service.
10
+ */
11
+ export type ClaimsServiceFetchClaimsConfigurationsAction = {
12
+ type: `ClaimsService:fetchClaimsConfigurations`;
13
+ handler: ClaimsService['fetchClaimsConfigurations'];
14
+ };
15
+ /**
16
+ * Get the claims for the current user.
17
+ *
18
+ * @returns The claims for the current user.
19
+ */
20
+ export type ClaimsServiceGetClaimsAction = {
21
+ type: `ClaimsService:getClaims`;
22
+ handler: ClaimsService['getClaims'];
23
+ };
24
+ /**
25
+ * Get the claim by id.
26
+ *
27
+ * @param id - The id of the claim to get.
28
+ * @returns The claim by id.
29
+ */
30
+ export type ClaimsServiceGetClaimByIdAction = {
31
+ type: `ClaimsService:getClaimById`;
32
+ handler: ClaimsService['getClaimById'];
33
+ };
34
+ /**
35
+ * Generate a message to be signed by the user for the claim request.
36
+ *
37
+ * @param chainId - The chain id of the claim.
38
+ * @param walletAddress - The impacted wallet address of the claim.
39
+ * @returns The message for the claim signature.
40
+ */
41
+ export type ClaimsServiceGenerateMessageForClaimSignatureAction = {
42
+ type: `ClaimsService:generateMessageForClaimSignature`;
43
+ handler: ClaimsService['generateMessageForClaimSignature'];
44
+ };
45
+ /**
46
+ * Create the headers for the current request.
47
+ *
48
+ * @returns The headers for the current request.
49
+ */
50
+ export type ClaimsServiceGetRequestHeadersAction = {
51
+ type: `ClaimsService:getRequestHeaders`;
52
+ handler: ClaimsService['getRequestHeaders'];
53
+ };
54
+ /**
55
+ * Get the URL for the claims API for the current environment.
56
+ *
57
+ * @returns The URL for the claims API for the current environment.
58
+ */
59
+ export type ClaimsServiceGetClaimsApiUrlAction = {
60
+ type: `ClaimsService:getClaimsApiUrl`;
61
+ handler: ClaimsService['getClaimsApiUrl'];
62
+ };
63
+ /**
64
+ * Union of all ClaimsService action types.
65
+ */
66
+ export type ClaimsServiceMethodActions = ClaimsServiceFetchClaimsConfigurationsAction | ClaimsServiceGetClaimsAction | ClaimsServiceGetClaimByIdAction | ClaimsServiceGenerateMessageForClaimSignatureAction | ClaimsServiceGetRequestHeadersAction | ClaimsServiceGetClaimsApiUrlAction;
67
+ //# sourceMappingURL=ClaimsService-method-action-types.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ClaimsService-method-action-types.d.mts","sourceRoot":"","sources":["../src/ClaimsService-method-action-types.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,4BAA2B;AAExD;;;;GAIG;AACH,MAAM,MAAM,4CAA4C,GAAG;IACzD,IAAI,EAAE,yCAAyC,CAAC;IAChD,OAAO,EAAE,aAAa,CAAC,2BAA2B,CAAC,CAAC;CACrD,CAAC;AAEF;;;;GAIG;AACH,MAAM,MAAM,4BAA4B,GAAG;IACzC,IAAI,EAAE,yBAAyB,CAAC;IAChC,OAAO,EAAE,aAAa,CAAC,WAAW,CAAC,CAAC;CACrC,CAAC;AAEF;;;;;GAKG;AACH,MAAM,MAAM,+BAA+B,GAAG;IAC5C,IAAI,EAAE,4BAA4B,CAAC;IACnC,OAAO,EAAE,aAAa,CAAC,cAAc,CAAC,CAAC;CACxC,CAAC;AAEF;;;;;;GAMG;AACH,MAAM,MAAM,mDAAmD,GAAG;IAChE,IAAI,EAAE,gDAAgD,CAAC;IACvD,OAAO,EAAE,aAAa,CAAC,kCAAkC,CAAC,CAAC;CAC5D,CAAC;AAEF;;;;GAIG;AACH,MAAM,MAAM,oCAAoC,GAAG;IACjD,IAAI,EAAE,iCAAiC,CAAC;IACxC,OAAO,EAAE,aAAa,CAAC,mBAAmB,CAAC,CAAC;CAC7C,CAAC;AAEF;;;;GAIG;AACH,MAAM,MAAM,kCAAkC,GAAG;IAC/C,IAAI,EAAE,+BAA+B,CAAC;IACtC,OAAO,EAAE,aAAa,CAAC,iBAAiB,CAAC,CAAC;CAC3C,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,0BAA0B,GAClC,4CAA4C,GAC5C,4BAA4B,GAC5B,+BAA+B,GAC/B,mDAAmD,GACnD,oCAAoC,GACpC,kCAAkC,CAAC"}
@@ -3,4 +3,4 @@
3
3
  * Do not edit manually.
4
4
  */
5
5
  export {};
6
- //# sourceMappingURL=ClaimsService-method-action-types.js.map
6
+ //# sourceMappingURL=ClaimsService-method-action-types.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ClaimsService-method-action-types.mjs","sourceRoot":"","sources":["../src/ClaimsService-method-action-types.ts"],"names":[],"mappings":"AAAA;;;GAGG","sourcesContent":["/**\n * This file is auto generated.\n * Do not edit manually.\n */\n\nimport type { ClaimsService } from './ClaimsService.js';\n\n/**\n * Fetch required configurations for the claims service.\n *\n * @returns The required configurations for the claims service.\n */\nexport type ClaimsServiceFetchClaimsConfigurationsAction = {\n type: `ClaimsService:fetchClaimsConfigurations`;\n handler: ClaimsService['fetchClaimsConfigurations'];\n};\n\n/**\n * Get the claims for the current user.\n *\n * @returns The claims for the current user.\n */\nexport type ClaimsServiceGetClaimsAction = {\n type: `ClaimsService:getClaims`;\n handler: ClaimsService['getClaims'];\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 */\nexport type ClaimsServiceGetClaimByIdAction = {\n type: `ClaimsService:getClaimById`;\n handler: ClaimsService['getClaimById'];\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 */\nexport type ClaimsServiceGenerateMessageForClaimSignatureAction = {\n type: `ClaimsService:generateMessageForClaimSignature`;\n handler: ClaimsService['generateMessageForClaimSignature'];\n};\n\n/**\n * Create the headers for the current request.\n *\n * @returns The headers for the current request.\n */\nexport type ClaimsServiceGetRequestHeadersAction = {\n type: `ClaimsService:getRequestHeaders`;\n handler: ClaimsService['getRequestHeaders'];\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 */\nexport type ClaimsServiceGetClaimsApiUrlAction = {\n type: `ClaimsService:getClaimsApiUrl`;\n handler: ClaimsService['getClaimsApiUrl'];\n};\n\n/**\n * Union of all ClaimsService action types.\n */\nexport type ClaimsServiceMethodActions =\n | ClaimsServiceFetchClaimsConfigurationsAction\n | ClaimsServiceGetClaimsAction\n | ClaimsServiceGetClaimByIdAction\n | ClaimsServiceGenerateMessageForClaimSignatureAction\n | ClaimsServiceGetRequestHeadersAction\n | ClaimsServiceGetClaimsApiUrlAction;\n"]}
@@ -0,0 +1,36 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.GenerateSignatureMessageResponseStruct = exports.ClaimsConfigurationsResponseStruct = exports.ClaimStruct = void 0;
4
+ const superstruct_1 = require("@metamask/superstruct");
5
+ const constants_js_1 = require("./constants.cjs");
6
+ const HexStringStruct = (0, superstruct_1.string)();
7
+ const AttachmentStruct = (0, superstruct_1.type)({
8
+ publicUrl: (0, superstruct_1.string)(),
9
+ contentType: (0, superstruct_1.string)(),
10
+ originalname: (0, superstruct_1.string)(),
11
+ });
12
+ exports.ClaimStruct = (0, superstruct_1.type)({
13
+ id: (0, superstruct_1.string)(),
14
+ shortId: (0, superstruct_1.string)(),
15
+ chainId: (0, superstruct_1.string)(),
16
+ email: (0, superstruct_1.string)(),
17
+ impactedWalletAddress: HexStringStruct,
18
+ impactedTxHash: HexStringStruct,
19
+ reimbursementWalletAddress: HexStringStruct,
20
+ description: (0, superstruct_1.string)(),
21
+ signature: HexStringStruct,
22
+ attachments: (0, superstruct_1.optional)((0, superstruct_1.array)(AttachmentStruct)),
23
+ status: (0, superstruct_1.enums)(Object.values(constants_js_1.ClaimStatusEnum)),
24
+ createdAt: (0, superstruct_1.string)(),
25
+ updatedAt: (0, superstruct_1.string)(),
26
+ intercomId: (0, superstruct_1.optional)((0, superstruct_1.string)()),
27
+ });
28
+ exports.ClaimsConfigurationsResponseStruct = (0, superstruct_1.type)({
29
+ validSubmissionWindowDays: (0, superstruct_1.integer)(),
30
+ networks: (0, superstruct_1.array)((0, superstruct_1.integer)()),
31
+ });
32
+ exports.GenerateSignatureMessageResponseStruct = (0, superstruct_1.type)({
33
+ message: (0, superstruct_1.string)(),
34
+ nonce: (0, superstruct_1.string)(),
35
+ });
36
+ //# sourceMappingURL=ClaimsService-structs.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ClaimsService-structs.cjs","sourceRoot":"","sources":["../src/ClaimsService-structs.ts"],"names":[],"mappings":";;;AAAA,uDAO+B;AAE/B,kDAAiD;AAEjD,MAAM,eAAe,GAAG,IAAA,oBAAM,GAAE,CAAC;AAEjC,MAAM,gBAAgB,GAAG,IAAA,kBAAI,EAAC;IAC5B,SAAS,EAAE,IAAA,oBAAM,GAAE;IACnB,WAAW,EAAE,IAAA,oBAAM,GAAE;IACrB,YAAY,EAAE,IAAA,oBAAM,GAAE;CACvB,CAAC,CAAC;AAEU,QAAA,WAAW,GAAG,IAAA,kBAAI,EAAC;IAC9B,EAAE,EAAE,IAAA,oBAAM,GAAE;IACZ,OAAO,EAAE,IAAA,oBAAM,GAAE;IACjB,OAAO,EAAE,IAAA,oBAAM,GAAE;IACjB,KAAK,EAAE,IAAA,oBAAM,GAAE;IACf,qBAAqB,EAAE,eAAe;IACtC,cAAc,EAAE,eAAe;IAC/B,0BAA0B,EAAE,eAAe;IAC3C,WAAW,EAAE,IAAA,oBAAM,GAAE;IACrB,SAAS,EAAE,eAAe;IAC1B,WAAW,EAAE,IAAA,sBAAQ,EAAC,IAAA,mBAAK,EAAC,gBAAgB,CAAC,CAAC;IAC9C,MAAM,EAAE,IAAA,mBAAK,EAAC,MAAM,CAAC,MAAM,CAAC,8BAAe,CAAC,CAAC;IAC7C,SAAS,EAAE,IAAA,oBAAM,GAAE;IACnB,SAAS,EAAE,IAAA,oBAAM,GAAE;IACnB,UAAU,EAAE,IAAA,sBAAQ,EAAC,IAAA,oBAAM,GAAE,CAAC;CAC/B,CAAC,CAAC;AAEU,QAAA,kCAAkC,GAAG,IAAA,kBAAI,EAAC;IACrD,yBAAyB,EAAE,IAAA,qBAAO,GAAE;IACpC,QAAQ,EAAE,IAAA,mBAAK,EAAC,IAAA,qBAAO,GAAE,CAAC;CAC3B,CAAC,CAAC;AAEU,QAAA,sCAAsC,GAAG,IAAA,kBAAI,EAAC;IACzD,OAAO,EAAE,IAAA,oBAAM,GAAE;IACjB,KAAK,EAAE,IAAA,oBAAM,GAAE;CAChB,CAAC,CAAC","sourcesContent":["import {\n array,\n enums,\n integer,\n optional,\n string,\n type,\n} from '@metamask/superstruct';\n\nimport { ClaimStatusEnum } from './constants.js';\n\nconst HexStringStruct = string();\n\nconst AttachmentStruct = type({\n publicUrl: string(),\n contentType: string(),\n originalname: string(),\n});\n\nexport const ClaimStruct = type({\n id: string(),\n shortId: string(),\n chainId: string(),\n email: string(),\n impactedWalletAddress: HexStringStruct,\n impactedTxHash: HexStringStruct,\n reimbursementWalletAddress: HexStringStruct,\n description: string(),\n signature: HexStringStruct,\n attachments: optional(array(AttachmentStruct)),\n status: enums(Object.values(ClaimStatusEnum)),\n createdAt: string(),\n updatedAt: string(),\n intercomId: optional(string()),\n});\n\nexport const ClaimsConfigurationsResponseStruct = type({\n validSubmissionWindowDays: integer(),\n networks: array(integer()),\n});\n\nexport const GenerateSignatureMessageResponseStruct = type({\n message: string(),\n nonce: string(),\n});\n"]}
@@ -1,4 +1,4 @@
1
- import { ClaimStatusEnum } from './constants.js';
1
+ import { ClaimStatusEnum } from "./constants.cjs";
2
2
  export declare const ClaimStruct: import("@metamask/superstruct").Struct<{
3
3
  id: string;
4
4
  shortId: string;
@@ -9,14 +9,14 @@ export declare const ClaimStruct: import("@metamask/superstruct").Struct<{
9
9
  reimbursementWalletAddress: string;
10
10
  description: string;
11
11
  signature: string;
12
+ status: ClaimStatusEnum;
13
+ createdAt: string;
14
+ updatedAt: string;
12
15
  attachments?: {
13
16
  publicUrl: string;
14
17
  contentType: string;
15
18
  originalname: string;
16
19
  }[] | undefined;
17
- status: ClaimStatusEnum;
18
- createdAt: string;
19
- updatedAt: string;
20
20
  intercomId?: string | undefined;
21
21
  }, {
22
22
  id: import("@metamask/superstruct").Struct<string, null>;
@@ -42,13 +42,13 @@ export declare const ClaimStruct: import("@metamask/superstruct").Struct<{
42
42
  originalname: import("@metamask/superstruct").Struct<string, null>;
43
43
  }>>;
44
44
  status: import("@metamask/superstruct").Struct<ClaimStatusEnum, {
45
- approved: ClaimStatusEnum.APPROVED;
46
45
  created: ClaimStatusEnum.CREATED;
46
+ submitted: ClaimStatusEnum.SUBMITTED;
47
47
  in_progress: ClaimStatusEnum.IN_PROGRESS;
48
+ waiting_for_customer: ClaimStatusEnum.WAITING_FOR_CUSTOMER;
49
+ approved: ClaimStatusEnum.APPROVED;
48
50
  rejected: ClaimStatusEnum.REJECTED;
49
- submitted: ClaimStatusEnum.SUBMITTED;
50
51
  unknown: ClaimStatusEnum.UNKNOWN;
51
- waiting_for_customer: ClaimStatusEnum.WAITING_FOR_CUSTOMER;
52
52
  }>;
53
53
  createdAt: import("@metamask/superstruct").Struct<string, null>;
54
54
  updatedAt: import("@metamask/superstruct").Struct<string, null>;
@@ -68,4 +68,4 @@ export declare const GenerateSignatureMessageResponseStruct: import("@metamask/s
68
68
  message: import("@metamask/superstruct").Struct<string, null>;
69
69
  nonce: import("@metamask/superstruct").Struct<string, null>;
70
70
  }>;
71
- //# sourceMappingURL=ClaimsService-structs.d.ts.map
71
+ //# sourceMappingURL=ClaimsService-structs.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ClaimsService-structs.d.cts","sourceRoot":"","sources":["../src/ClaimsService-structs.ts"],"names":[],"mappings":"AASA,OAAO,EAAE,eAAe,EAAE,wBAAuB;AAUjD,eAAO,MAAM,WAAW;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAetB,CAAC;AAEH,eAAO,MAAM,kCAAkC;;;;;;EAG7C,CAAC;AAEH,eAAO,MAAM,sCAAsC;;;;;;EAGjD,CAAC"}
@@ -0,0 +1,71 @@
1
+ import { ClaimStatusEnum } from "./constants.mjs";
2
+ export declare const ClaimStruct: import("@metamask/superstruct").Struct<{
3
+ id: string;
4
+ shortId: string;
5
+ chainId: string;
6
+ email: string;
7
+ impactedWalletAddress: string;
8
+ impactedTxHash: string;
9
+ reimbursementWalletAddress: string;
10
+ description: string;
11
+ signature: string;
12
+ status: ClaimStatusEnum;
13
+ createdAt: string;
14
+ updatedAt: string;
15
+ attachments?: {
16
+ publicUrl: string;
17
+ contentType: string;
18
+ originalname: string;
19
+ }[] | undefined;
20
+ intercomId?: string | undefined;
21
+ }, {
22
+ id: import("@metamask/superstruct").Struct<string, null>;
23
+ shortId: import("@metamask/superstruct").Struct<string, null>;
24
+ chainId: import("@metamask/superstruct").Struct<string, null>;
25
+ email: import("@metamask/superstruct").Struct<string, null>;
26
+ impactedWalletAddress: import("@metamask/superstruct").Struct<string, null>;
27
+ impactedTxHash: import("@metamask/superstruct").Struct<string, null>;
28
+ reimbursementWalletAddress: import("@metamask/superstruct").Struct<string, null>;
29
+ description: import("@metamask/superstruct").Struct<string, null>;
30
+ signature: import("@metamask/superstruct").Struct<string, null>;
31
+ attachments: import("@metamask/superstruct").Struct<{
32
+ publicUrl: string;
33
+ contentType: string;
34
+ originalname: string;
35
+ }[] | undefined, import("@metamask/superstruct").Struct<{
36
+ publicUrl: string;
37
+ contentType: string;
38
+ originalname: string;
39
+ }, {
40
+ publicUrl: import("@metamask/superstruct").Struct<string, null>;
41
+ contentType: import("@metamask/superstruct").Struct<string, null>;
42
+ originalname: import("@metamask/superstruct").Struct<string, null>;
43
+ }>>;
44
+ status: import("@metamask/superstruct").Struct<ClaimStatusEnum, {
45
+ created: ClaimStatusEnum.CREATED;
46
+ submitted: ClaimStatusEnum.SUBMITTED;
47
+ in_progress: ClaimStatusEnum.IN_PROGRESS;
48
+ waiting_for_customer: ClaimStatusEnum.WAITING_FOR_CUSTOMER;
49
+ approved: ClaimStatusEnum.APPROVED;
50
+ rejected: ClaimStatusEnum.REJECTED;
51
+ unknown: ClaimStatusEnum.UNKNOWN;
52
+ }>;
53
+ createdAt: import("@metamask/superstruct").Struct<string, null>;
54
+ updatedAt: import("@metamask/superstruct").Struct<string, null>;
55
+ intercomId: import("@metamask/superstruct").Struct<string | undefined, null>;
56
+ }>;
57
+ export declare const ClaimsConfigurationsResponseStruct: import("@metamask/superstruct").Struct<{
58
+ validSubmissionWindowDays: number;
59
+ networks: number[];
60
+ }, {
61
+ validSubmissionWindowDays: import("@metamask/superstruct").Struct<number, null>;
62
+ networks: import("@metamask/superstruct").Struct<number[], import("@metamask/superstruct").Struct<number, null>>;
63
+ }>;
64
+ export declare const GenerateSignatureMessageResponseStruct: import("@metamask/superstruct").Struct<{
65
+ message: string;
66
+ nonce: string;
67
+ }, {
68
+ message: import("@metamask/superstruct").Struct<string, null>;
69
+ nonce: import("@metamask/superstruct").Struct<string, null>;
70
+ }>;
71
+ //# sourceMappingURL=ClaimsService-structs.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ClaimsService-structs.d.mts","sourceRoot":"","sources":["../src/ClaimsService-structs.ts"],"names":[],"mappings":"AASA,OAAO,EAAE,eAAe,EAAE,wBAAuB;AAUjD,eAAO,MAAM,WAAW;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAetB,CAAC;AAEH,eAAO,MAAM,kCAAkC;;;;;;EAG7C,CAAC;AAEH,eAAO,MAAM,sCAAsC;;;;;;EAGjD,CAAC"}
@@ -1,5 +1,5 @@
1
- import { array, enums, integer, optional, string, type, } from '@metamask/superstruct';
2
- import { ClaimStatusEnum } from './constants.js';
1
+ import { array, enums, integer, optional, string, type } from "@metamask/superstruct";
2
+ import { ClaimStatusEnum } from "./constants.mjs";
3
3
  const HexStringStruct = string();
4
4
  const AttachmentStruct = type({
5
5
  publicUrl: string(),
@@ -30,4 +30,4 @@ export const GenerateSignatureMessageResponseStruct = type({
30
30
  message: string(),
31
31
  nonce: string(),
32
32
  });
33
- //# sourceMappingURL=ClaimsService-structs.js.map
33
+ //# sourceMappingURL=ClaimsService-structs.mjs.map
@@ -0,0 +1 @@
1
+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E;CAChB,CAAC,CAAC","sourcesContent":["import {\n array,\n enums,\n integer,\n optional,\n string,\n type,\n} from '@metamask/superstruct';\n\nimport { ClaimStatusEnum } from './constants.js';\n\nconst HexStringStruct = string();\n\nconst AttachmentStruct = type({\n publicUrl: string(),\n contentType: string(),\n originalname: string(),\n});\n\nexport const ClaimStruct = type({\n id: string(),\n shortId: string(),\n chainId: string(),\n email: string(),\n impactedWalletAddress: HexStringStruct,\n impactedTxHash: HexStringStruct,\n reimbursementWalletAddress: HexStringStruct,\n description: string(),\n signature: HexStringStruct,\n attachments: optional(array(AttachmentStruct)),\n status: enums(Object.values(ClaimStatusEnum)),\n createdAt: string(),\n updatedAt: string(),\n intercomId: optional(string()),\n});\n\nexport const ClaimsConfigurationsResponseStruct = type({\n validSubmissionWindowDays: integer(),\n networks: array(integer()),\n});\n\nexport const GenerateSignatureMessageResponseStruct = type({\n message: string(),\n nonce: string(),\n});\n"]}
@@ -0,0 +1,229 @@
1
+ "use strict";
2
+ var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
3
+ if (kind === "m") throw new TypeError("Private method is not writable");
4
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
5
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
6
+ return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
7
+ };
8
+ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
9
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
10
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
11
+ return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
12
+ };
13
+ var _ClaimsService_instances, _ClaimsService_env, _ClaimsService_fetch, _ClaimsService_captureException, _ClaimsService_getAuthContext, _ClaimsService_headersForToken, _ClaimsService_validateResponse, _ClaimsService_handleError;
14
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ exports.ClaimsService = void 0;
16
+ const base_data_service_1 = require("@metamask/base-data-service");
17
+ const superstruct_1 = require("@metamask/superstruct");
18
+ const ClaimsService_structs_js_1 = require("./ClaimsService-structs.cjs");
19
+ const constants_js_1 = require("./constants.cjs");
20
+ const logger_js_1 = require("./logger.cjs");
21
+ const utils_js_1 = require("./utils.cjs");
22
+ const MESSENGER_EXPOSED_METHODS = [
23
+ 'fetchClaimsConfigurations',
24
+ 'getClaims',
25
+ 'getClaimById',
26
+ 'getRequestHeaders',
27
+ 'getClaimsApiUrl',
28
+ 'generateMessageForClaimSignature',
29
+ ];
30
+ const DEFAULT_POLICY_OPTIONS = {
31
+ maxRetries: 0,
32
+ };
33
+ const log = (0, logger_js_1.createModuleLogger)(logger_js_1.projectLogger, 'ClaimsService');
34
+ /**
35
+ * This service is responsible for communicating with the Claims API.
36
+ *
37
+ * All requests are authenticated via JWT Bearer tokens obtained from the
38
+ * `AuthenticationController:getBearerToken` messenger action. Cached GET
39
+ * queries are scoped by `profileId` from
40
+ * `AuthenticationController:getSessionProfile`.
41
+ */
42
+ class ClaimsService extends base_data_service_1.BaseDataService {
43
+ constructor({ env, messenger, fetchFunction = globalThis.fetch, captureException: captureExceptionFn, queryClientConfig = {}, policyOptions = {}, }) {
44
+ super({
45
+ name: constants_js_1.SERVICE_NAME,
46
+ messenger,
47
+ queryClientConfig,
48
+ policyOptions: { ...DEFAULT_POLICY_OPTIONS, ...policyOptions },
49
+ });
50
+ _ClaimsService_instances.add(this);
51
+ _ClaimsService_env.set(this, void 0);
52
+ _ClaimsService_fetch.set(this, void 0);
53
+ _ClaimsService_captureException.set(this, void 0);
54
+ __classPrivateFieldSet(this, _ClaimsService_env, env, "f");
55
+ __classPrivateFieldSet(this, _ClaimsService_fetch, fetchFunction, "f");
56
+ __classPrivateFieldSet(this, _ClaimsService_captureException, (error) => {
57
+ try {
58
+ (captureExceptionFn ?? messenger.captureException)?.(error);
59
+ }
60
+ catch {
61
+ // ignore error thrown when calling captureException
62
+ }
63
+ }, "f");
64
+ this.messenger.registerMethodActionHandlers(this, MESSENGER_EXPOSED_METHODS);
65
+ }
66
+ /**
67
+ * Fetch required configurations for the claims service.
68
+ *
69
+ * @returns The required configurations for the claims service.
70
+ */
71
+ async fetchClaimsConfigurations() {
72
+ try {
73
+ const { bearerToken, profileId } = await __classPrivateFieldGet(this, _ClaimsService_instances, "m", _ClaimsService_getAuthContext).call(this);
74
+ return await this.fetchQuery({
75
+ queryKey: [`${this.name}:fetchClaimsConfigurations`, profileId],
76
+ queryFn: async () => {
77
+ const url = `${this.getClaimsApiUrl()}/configurations`;
78
+ const response = await __classPrivateFieldGet(this, _ClaimsService_fetch, "f").call(this, url, {
79
+ headers: __classPrivateFieldGet(this, _ClaimsService_instances, "m", _ClaimsService_headersForToken).call(this, bearerToken),
80
+ });
81
+ if (!response.ok) {
82
+ throw await (0, utils_js_1.getErrorFromResponse)(response);
83
+ }
84
+ const configurations = await response.json();
85
+ return __classPrivateFieldGet(this, _ClaimsService_instances, "m", _ClaimsService_validateResponse).call(this, configurations, ClaimsService_structs_js_1.ClaimsConfigurationsResponseStruct, constants_js_1.ClaimsServiceErrorMessages.FAILED_TO_FETCH_CONFIGURATIONS);
86
+ },
87
+ });
88
+ }
89
+ catch (error) {
90
+ return __classPrivateFieldGet(this, _ClaimsService_instances, "m", _ClaimsService_handleError).call(this, 'fetchClaimsConfigurations', constants_js_1.ClaimsServiceErrorMessages.FAILED_TO_FETCH_CONFIGURATIONS, error);
91
+ }
92
+ }
93
+ /**
94
+ * Get the claims for the current user.
95
+ *
96
+ * @returns The claims for the current user.
97
+ */
98
+ async getClaims() {
99
+ try {
100
+ const { bearerToken, profileId } = await __classPrivateFieldGet(this, _ClaimsService_instances, "m", _ClaimsService_getAuthContext).call(this);
101
+ return await this.fetchQuery({
102
+ queryKey: [`${this.name}:getClaims`, profileId],
103
+ // TODO: Restore default staleTime once claim reads are invalidated
104
+ // after a successful external submit (not in getSubmitClaimConfig).
105
+ staleTime: 0,
106
+ queryFn: async () => {
107
+ const url = `${this.getClaimsApiUrl()}/claims`;
108
+ const response = await __classPrivateFieldGet(this, _ClaimsService_fetch, "f").call(this, url, {
109
+ headers: __classPrivateFieldGet(this, _ClaimsService_instances, "m", _ClaimsService_headersForToken).call(this, bearerToken),
110
+ });
111
+ if (!response.ok) {
112
+ throw await (0, utils_js_1.getErrorFromResponse)(response);
113
+ }
114
+ const claims = await response.json();
115
+ return __classPrivateFieldGet(this, _ClaimsService_instances, "m", _ClaimsService_validateResponse).call(this, claims, (0, superstruct_1.array)(ClaimsService_structs_js_1.ClaimStruct), constants_js_1.ClaimsServiceErrorMessages.FAILED_TO_GET_CLAIMS);
116
+ },
117
+ });
118
+ }
119
+ catch (error) {
120
+ return __classPrivateFieldGet(this, _ClaimsService_instances, "m", _ClaimsService_handleError).call(this, 'getClaims', constants_js_1.ClaimsServiceErrorMessages.FAILED_TO_GET_CLAIMS, error);
121
+ }
122
+ }
123
+ /**
124
+ * Get the claim by id.
125
+ *
126
+ * @param id - The id of the claim to get.
127
+ * @returns The claim by id.
128
+ */
129
+ async getClaimById(id) {
130
+ try {
131
+ const { bearerToken, profileId } = await __classPrivateFieldGet(this, _ClaimsService_instances, "m", _ClaimsService_getAuthContext).call(this);
132
+ return await this.fetchQuery({
133
+ queryKey: [`${this.name}:getClaimById`, id, profileId],
134
+ // TODO: Restore default staleTime once claim reads are invalidated
135
+ // after a successful external submit (not in getSubmitClaimConfig).
136
+ staleTime: 0,
137
+ queryFn: async () => {
138
+ const url = `${this.getClaimsApiUrl()}/claims/byId/${id}`;
139
+ const response = await __classPrivateFieldGet(this, _ClaimsService_fetch, "f").call(this, url, {
140
+ headers: __classPrivateFieldGet(this, _ClaimsService_instances, "m", _ClaimsService_headersForToken).call(this, bearerToken),
141
+ });
142
+ if (!response.ok) {
143
+ throw await (0, utils_js_1.getErrorFromResponse)(response);
144
+ }
145
+ const claim = await response.json();
146
+ return __classPrivateFieldGet(this, _ClaimsService_instances, "m", _ClaimsService_validateResponse).call(this, claim, ClaimsService_structs_js_1.ClaimStruct, constants_js_1.ClaimsServiceErrorMessages.FAILED_TO_GET_CLAIM_BY_ID);
147
+ },
148
+ });
149
+ }
150
+ catch (error) {
151
+ return __classPrivateFieldGet(this, _ClaimsService_instances, "m", _ClaimsService_handleError).call(this, 'getClaimById', constants_js_1.ClaimsServiceErrorMessages.FAILED_TO_GET_CLAIM_BY_ID, error);
152
+ }
153
+ }
154
+ /**
155
+ * Generate a message to be signed by the user for the claim request.
156
+ *
157
+ * @param chainId - The chain id of the claim.
158
+ * @param walletAddress - The impacted wallet address of the claim.
159
+ * @returns The message for the claim signature.
160
+ */
161
+ async generateMessageForClaimSignature(chainId, walletAddress) {
162
+ try {
163
+ const headers = await this.getRequestHeaders();
164
+ const url = `${this.getClaimsApiUrl()}/signature/generateMessage`;
165
+ const response = await __classPrivateFieldGet(this, _ClaimsService_fetch, "f").call(this, url, {
166
+ method: 'POST',
167
+ headers: {
168
+ ...headers,
169
+ 'Content-Type': 'application/json',
170
+ },
171
+ body: JSON.stringify({
172
+ chainId,
173
+ walletAddress,
174
+ }),
175
+ });
176
+ if (!response.ok) {
177
+ throw await (0, utils_js_1.getErrorFromResponse)(response);
178
+ }
179
+ const message = await response.json();
180
+ return __classPrivateFieldGet(this, _ClaimsService_instances, "m", _ClaimsService_validateResponse).call(this, message, ClaimsService_structs_js_1.GenerateSignatureMessageResponseStruct, constants_js_1.ClaimsServiceErrorMessages.SIGNATURE_MESSAGE_GENERATION_FAILED);
181
+ }
182
+ catch (error) {
183
+ return __classPrivateFieldGet(this, _ClaimsService_instances, "m", _ClaimsService_handleError).call(this, 'generateMessageForClaimSignature', constants_js_1.ClaimsServiceErrorMessages.SIGNATURE_MESSAGE_GENERATION_FAILED, error);
184
+ }
185
+ }
186
+ /**
187
+ * Create the headers for the current request.
188
+ *
189
+ * @returns The headers for the current request.
190
+ */
191
+ async getRequestHeaders() {
192
+ const bearerToken = await this.messenger.call('AuthenticationController:getBearerToken');
193
+ return __classPrivateFieldGet(this, _ClaimsService_instances, "m", _ClaimsService_headersForToken).call(this, bearerToken);
194
+ }
195
+ /**
196
+ * Get the URL for the claims API for the current environment.
197
+ *
198
+ * @returns The URL for the claims API for the current environment.
199
+ */
200
+ getClaimsApiUrl() {
201
+ return `${constants_js_1.CLAIMS_API_URL_MAP[__classPrivateFieldGet(this, _ClaimsService_env, "f")]}`;
202
+ }
203
+ }
204
+ exports.ClaimsService = ClaimsService;
205
+ _ClaimsService_env = new WeakMap(), _ClaimsService_fetch = new WeakMap(), _ClaimsService_captureException = new WeakMap(), _ClaimsService_instances = new WeakSet(), _ClaimsService_getAuthContext = async function _ClaimsService_getAuthContext() {
206
+ const [bearerToken, sessionProfile] = await Promise.all([
207
+ this.messenger.call('AuthenticationController:getBearerToken'),
208
+ this.messenger.call('AuthenticationController:getSessionProfile'),
209
+ ]);
210
+ return {
211
+ bearerToken,
212
+ profileId: sessionProfile.profileId,
213
+ };
214
+ }, _ClaimsService_headersForToken = function _ClaimsService_headersForToken(token) {
215
+ return {
216
+ Authorization: `Bearer ${token}`,
217
+ };
218
+ }, _ClaimsService_validateResponse = function _ClaimsService_validateResponse(responseData, struct, errorMessage) {
219
+ const [error, validatedResponseData] = (0, superstruct_1.validate)(responseData, struct);
220
+ if (error) {
221
+ throw new Error(`${errorMessage}: ${error.message}`);
222
+ }
223
+ return validatedResponseData;
224
+ }, _ClaimsService_handleError = function _ClaimsService_handleError(methodName, errorMessage, error) {
225
+ log(methodName, error);
226
+ __classPrivateFieldGet(this, _ClaimsService_captureException, "f")?.call(this, (0, utils_js_1.createSentryError)(errorMessage, error));
227
+ throw new Error(errorMessage);
228
+ };
229
+ //# sourceMappingURL=ClaimsService.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ClaimsService.cjs","sourceRoot":"","sources":["../src/ClaimsService.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AC;AACJ,CAAC,2EAEgB,KAAa;IAC5B,OAAO;QACL,aAAa,EAAE,UAAU,KAAK,EAAE;KACjC,CAAC;AACJ,CAAC,6EAYC,YAAqB,EACrB,MAA0B,EAC1B,YAAoB;IAEpB,MAAM,CAAC,KAAK,EAAE,qBAAqB,CAAC,GAAG,IAAA,sBAAQ,EAAC,YAAY,EAAE,MAAM,CAAC,CAAC;IACtE,IAAI,KAAK,EAAE,CAAC;QACV,MAAM,IAAI,KAAK,CAAC,GAAG,YAAY,KAAK,KAAK,CAAC,OAAO,EAAE,CAAC,CAAC;IACvD,CAAC;IAED,OAAO,qBAAqB,CAAC;AAC/B,CAAC,mEAGC,UAAkB,EAClB,YAAoB,EACpB,KAAc;IAEd,GAAG,CAAC,UAAU,EAAE,KAAK,CAAC,CAAC;IACvB,uBAAA,IAAI,uCAAkB,EAAE,KAAxB,IAAI,EAAqB,IAAA,4BAAiB,EAAC,YAAY,EAAE,KAAc,CAAC,CAAC,CAAC;IAC1E,MAAM,IAAI,KAAK,CAAC,YAAY,CAAC,CAAC;AAChC,CAAC","sourcesContent":["import { BaseDataService } from '@metamask/base-data-service';\nimport type {\n DataServiceCacheUpdatedEvent,\n DataServiceGranularCacheUpdatedEvent,\n DataServiceInvalidateQueriesAction,\n} from '@metamask/base-data-service';\nimport type { CreateServicePolicyOptions } from '@metamask/controller-utils';\nimport type { Messenger } from '@metamask/messenger';\nimport type { AuthenticationController } from '@metamask/profile-sync-controller';\nimport { array, validate } from '@metamask/superstruct';\nimport type { Struct } from '@metamask/superstruct';\nimport type { Hex } from '@metamask/utils';\nimport type { QueryClientConfig } from '@tanstack/query-core';\n\nimport type { ClaimsServiceMethodActions } from './ClaimsService-method-action-types.js';\nimport {\n ClaimStruct,\n ClaimsConfigurationsResponseStruct,\n GenerateSignatureMessageResponseStruct,\n} from './ClaimsService-structs.js';\nimport {\n CLAIMS_API_URL_MAP,\n ClaimsServiceErrorMessages,\n SERVICE_NAME,\n} from './constants.js';\nimport type { Env } from './constants.js';\nimport { createModuleLogger, projectLogger } from './logger.js';\nimport type {\n Claim,\n ClaimsConfigurationsResponse,\n GenerateSignatureMessageResponse,\n} from './types.js';\nimport { createSentryError, getErrorFromResponse } from './utils.js';\n\nconst MESSENGER_EXPOSED_METHODS = [\n 'fetchClaimsConfigurations',\n 'getClaims',\n 'getClaimById',\n 'getRequestHeaders',\n 'getClaimsApiUrl',\n 'generateMessageForClaimSignature',\n] as const;\n\nconst DEFAULT_POLICY_OPTIONS: CreateServicePolicyOptions = {\n maxRetries: 0,\n};\n\n/**\n * Invalidates cached queries for {@link ClaimsService}.\n */\nexport type ClaimsServiceInvalidateQueriesAction =\n DataServiceInvalidateQueriesAction<typeof SERVICE_NAME>;\n\n/**\n * Actions that {@link ClaimsService} exposes to other consumers.\n */\nexport type ClaimsServiceActions =\n | ClaimsServiceMethodActions\n | ClaimsServiceInvalidateQueriesAction;\n\n/**\n * Actions from other messengers that {@link ClaimsService} calls.\n */\nexport type AllowedActions =\n | AuthenticationController.AuthenticationControllerGetBearerTokenAction\n | AuthenticationController.AuthenticationControllerGetSessionProfileAction;\n\n/**\n * Published when {@link ClaimsService}'s cache is updated.\n */\nexport type ClaimsServiceCacheUpdatedEvent = DataServiceCacheUpdatedEvent<\n typeof SERVICE_NAME\n>;\n\n/**\n * Published when a key within {@link ClaimsService}'s cache is updated.\n */\nexport type ClaimsServiceGranularCacheUpdatedEvent =\n DataServiceGranularCacheUpdatedEvent<typeof SERVICE_NAME>;\n\n/**\n * Events that {@link ClaimsService} exposes to other consumers.\n */\nexport type ClaimsServiceEvents =\n | ClaimsServiceCacheUpdatedEvent\n | ClaimsServiceGranularCacheUpdatedEvent;\n\n/**\n * Events from other messengers that {@link ClaimsService} subscribes to.\n */\ntype AllowedEvents = never;\n\n/**\n * The messenger which is restricted to actions and events accessed by\n * {@link ClaimsService}.\n */\nexport type ClaimsServiceMessenger = Messenger<\n typeof SERVICE_NAME,\n ClaimsServiceActions | AllowedActions,\n ClaimsServiceEvents | AllowedEvents\n>;\n\nexport type ClaimsServiceConfig = {\n env: Env;\n messenger: ClaimsServiceMessenger;\n /**\n * The `fetch` function to use for requests. Defaults to the global `fetch`.\n */\n fetchFunction?: typeof fetch;\n captureException?: (error: Error) => void;\n queryClientConfig?: QueryClientConfig;\n policyOptions?: CreateServicePolicyOptions;\n};\n\nconst log = createModuleLogger(projectLogger, 'ClaimsService');\n\n/**\n * This service is responsible for communicating with the Claims API.\n *\n * All requests are authenticated via JWT Bearer tokens obtained from the\n * `AuthenticationController:getBearerToken` messenger action. Cached GET\n * queries are scoped by `profileId` from\n * `AuthenticationController:getSessionProfile`.\n */\nexport class ClaimsService extends BaseDataService<\n typeof SERVICE_NAME,\n ClaimsServiceMessenger\n> {\n readonly #env: Env;\n\n readonly #fetch: typeof fetch;\n\n readonly #captureException?: (error: Error) => void;\n\n constructor({\n env,\n messenger,\n fetchFunction = globalThis.fetch,\n captureException: captureExceptionFn,\n queryClientConfig = {},\n policyOptions = {},\n }: ClaimsServiceConfig) {\n super({\n name: SERVICE_NAME,\n messenger,\n queryClientConfig,\n policyOptions: { ...DEFAULT_POLICY_OPTIONS, ...policyOptions },\n });\n\n this.#env = env;\n this.#fetch = fetchFunction;\n this.#captureException = (error: Error): void => {\n try {\n (captureExceptionFn ?? messenger.captureException)?.(error);\n } catch {\n // ignore error thrown when calling captureException\n }\n };\n\n this.messenger.registerMethodActionHandlers(\n this,\n MESSENGER_EXPOSED_METHODS,\n );\n }\n\n /**\n * Fetch required configurations for the claims service.\n *\n * @returns The required configurations for the claims service.\n */\n async fetchClaimsConfigurations(): Promise<ClaimsConfigurationsResponse> {\n try {\n const { bearerToken, profileId } = await this.#getAuthContext();\n\n return await this.fetchQuery({\n queryKey: [`${this.name}:fetchClaimsConfigurations`, profileId],\n queryFn: async () => {\n const url = `${this.getClaimsApiUrl()}/configurations`;\n const response = await this.#fetch(url, {\n headers: this.#headersForToken(bearerToken),\n });\n\n if (!response.ok) {\n throw await getErrorFromResponse(response);\n }\n\n const configurations = await response.json();\n\n return this.#validateResponse(\n configurations,\n ClaimsConfigurationsResponseStruct,\n ClaimsServiceErrorMessages.FAILED_TO_FETCH_CONFIGURATIONS,\n );\n },\n });\n } catch (error) {\n return this.#handleError(\n 'fetchClaimsConfigurations',\n ClaimsServiceErrorMessages.FAILED_TO_FETCH_CONFIGURATIONS,\n error,\n );\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 try {\n const { bearerToken, profileId } = await this.#getAuthContext();\n\n return await this.fetchQuery({\n queryKey: [`${this.name}:getClaims`, profileId],\n // TODO: Restore default staleTime once claim reads are invalidated\n // after a successful external submit (not in getSubmitClaimConfig).\n staleTime: 0,\n queryFn: async () => {\n const url = `${this.getClaimsApiUrl()}/claims`;\n const response = await this.#fetch(url, {\n headers: this.#headersForToken(bearerToken),\n });\n\n if (!response.ok) {\n throw await getErrorFromResponse(response);\n }\n\n const claims = await response.json();\n\n return this.#validateResponse(\n claims,\n array(ClaimStruct),\n ClaimsServiceErrorMessages.FAILED_TO_GET_CLAIMS,\n );\n },\n });\n } catch (error) {\n return this.#handleError(\n 'getClaims',\n ClaimsServiceErrorMessages.FAILED_TO_GET_CLAIMS,\n error,\n );\n }\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 try {\n const { bearerToken, profileId } = await this.#getAuthContext();\n\n return await this.fetchQuery({\n queryKey: [`${this.name}:getClaimById`, id, profileId],\n // TODO: Restore default staleTime once claim reads are invalidated\n // after a successful external submit (not in getSubmitClaimConfig).\n staleTime: 0,\n queryFn: async () => {\n const url = `${this.getClaimsApiUrl()}/claims/byId/${id}`;\n const response = await this.#fetch(url, {\n headers: this.#headersForToken(bearerToken),\n });\n\n if (!response.ok) {\n throw await getErrorFromResponse(response);\n }\n\n const claim = await response.json();\n\n return this.#validateResponse(\n claim,\n ClaimStruct,\n ClaimsServiceErrorMessages.FAILED_TO_GET_CLAIM_BY_ID,\n );\n },\n });\n } catch (error) {\n return this.#handleError(\n 'getClaimById',\n ClaimsServiceErrorMessages.FAILED_TO_GET_CLAIM_BY_ID,\n error,\n );\n }\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 try {\n const headers = await this.getRequestHeaders();\n const url = `${this.getClaimsApiUrl()}/signature/generateMessage`;\n const response = await this.#fetch(url, {\n method: 'POST',\n headers: {\n ...headers,\n 'Content-Type': 'application/json',\n },\n body: JSON.stringify({\n chainId,\n walletAddress,\n }),\n });\n\n if (!response.ok) {\n throw await getErrorFromResponse(response);\n }\n\n const message = await response.json();\n\n return this.#validateResponse(\n message,\n GenerateSignatureMessageResponseStruct,\n ClaimsServiceErrorMessages.SIGNATURE_MESSAGE_GENERATION_FAILED,\n );\n } catch (error) {\n return this.#handleError(\n 'generateMessageForClaimSignature',\n ClaimsServiceErrorMessages.SIGNATURE_MESSAGE_GENERATION_FAILED,\n error,\n );\n }\n }\n\n /**\n * Create the headers for the current request.\n *\n * @returns The headers for the current request.\n */\n async getRequestHeaders(): Promise<Record<string, string>> {\n const bearerToken = await this.messenger.call(\n 'AuthenticationController:getBearerToken',\n );\n return this.#headersForToken(bearerToken);\n }\n\n async #getAuthContext(): Promise<{\n bearerToken: string;\n profileId: string;\n }> {\n const [bearerToken, sessionProfile] = await Promise.all([\n this.messenger.call('AuthenticationController:getBearerToken'),\n this.messenger.call('AuthenticationController:getSessionProfile'),\n ]);\n\n return {\n bearerToken,\n profileId: sessionProfile.profileId,\n };\n }\n\n #headersForToken(token: string): Record<string, string> {\n return {\n Authorization: `Bearer ${token}`,\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_MAP[this.#env]}`;\n }\n\n #validateResponse<TValidated>(\n responseData: unknown,\n struct: Struct<TValidated>,\n errorMessage: string,\n ): TValidated {\n const [error, validatedResponseData] = validate(responseData, struct);\n if (error) {\n throw new Error(`${errorMessage}: ${error.message}`);\n }\n\n return validatedResponseData;\n }\n\n #handleError(\n methodName: string,\n errorMessage: string,\n error: unknown,\n ): never {\n log(methodName, error);\n this.#captureException?.(createSentryError(errorMessage, error as Error));\n throw new Error(errorMessage);\n }\n}\n"]}
@@ -1,14 +1,14 @@
1
- import { BaseDataService } from '@metamask/base-data-service';
2
- import type { DataServiceCacheUpdatedEvent, DataServiceGranularCacheUpdatedEvent, DataServiceInvalidateQueriesAction } from '@metamask/base-data-service';
3
- import type { CreateServicePolicyOptions } from '@metamask/controller-utils';
4
- import type { Messenger } from '@metamask/messenger';
5
- import type { AuthenticationController } from '@metamask/profile-sync-controller';
6
- import type { Hex } from '@metamask/utils';
7
- import type { QueryClientConfig } from '@tanstack/query-core';
8
- import type { ClaimsServiceMethodActions } from './ClaimsService-method-action-types.js';
9
- import { SERVICE_NAME } from './constants.js';
10
- import type { Env } from './constants.js';
11
- import type { Claim, ClaimsConfigurationsResponse, GenerateSignatureMessageResponse } from './types.js';
1
+ import { BaseDataService } from "@metamask/base-data-service";
2
+ import type { DataServiceCacheUpdatedEvent, DataServiceGranularCacheUpdatedEvent, DataServiceInvalidateQueriesAction } from "@metamask/base-data-service";
3
+ import type { CreateServicePolicyOptions } from "@metamask/controller-utils";
4
+ import type { Messenger } from "@metamask/messenger";
5
+ import type { AuthenticationController } from "@metamask/profile-sync-controller";
6
+ import type { Hex } from "@metamask/utils";
7
+ import type { QueryClientConfig } from "@tanstack/query-core";
8
+ import type { ClaimsServiceMethodActions } from "./ClaimsService-method-action-types.cjs";
9
+ import { SERVICE_NAME } from "./constants.cjs";
10
+ import type { Env } from "./constants.cjs";
11
+ import type { Claim, ClaimsConfigurationsResponse, GenerateSignatureMessageResponse } from "./types.cjs";
12
12
  /**
13
13
  * Invalidates cached queries for {@link ClaimsService}.
14
14
  */
@@ -105,4 +105,4 @@ export declare class ClaimsService extends BaseDataService<typeof SERVICE_NAME,
105
105
  getClaimsApiUrl(): string;
106
106
  }
107
107
  export {};
108
- //# sourceMappingURL=ClaimsService.d.ts.map
108
+ //# sourceMappingURL=ClaimsService.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ClaimsService.d.cts","sourceRoot":"","sources":["../src/ClaimsService.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,oCAAoC;AAC9D,OAAO,KAAK,EACV,4BAA4B,EAC5B,oCAAoC,EACpC,kCAAkC,EACnC,oCAAoC;AACrC,OAAO,KAAK,EAAE,0BAA0B,EAAE,mCAAmC;AAC7E,OAAO,KAAK,EAAE,SAAS,EAAE,4BAA4B;AACrD,OAAO,KAAK,EAAE,wBAAwB,EAAE,0CAA0C;AAGlF,OAAO,KAAK,EAAE,GAAG,EAAE,wBAAwB;AAC3C,OAAO,KAAK,EAAE,iBAAiB,EAAE,6BAA6B;AAE9D,OAAO,KAAK,EAAE,0BAA0B,EAAE,gDAA+C;AAMzF,OAAO,EAGL,YAAY,EACb,wBAAuB;AACxB,OAAO,KAAK,EAAE,GAAG,EAAE,wBAAuB;AAE1C,OAAO,KAAK,EACV,KAAK,EACL,4BAA4B,EAC5B,gCAAgC,EACjC,oBAAmB;AAgBpB;;GAEG;AACH,MAAM,MAAM,oCAAoC,GAC9C,kCAAkC,CAAC,OAAO,YAAY,CAAC,CAAC;AAE1D;;GAEG;AACH,MAAM,MAAM,oBAAoB,GAC5B,0BAA0B,GAC1B,oCAAoC,CAAC;AAEzC;;GAEG;AACH,MAAM,MAAM,cAAc,GACtB,wBAAwB,CAAC,4CAA4C,GACrE,wBAAwB,CAAC,+CAA+C,CAAC;AAE7E;;GAEG;AACH,MAAM,MAAM,8BAA8B,GAAG,4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