@metamask-previews/message-manager 14.1.1-preview-548bdd1d9 → 14.1.1-preview-60aa3d02f
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
CHANGED
|
@@ -11,7 +11,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
11
11
|
|
|
12
12
|
- Bump `@metamask/controller-utils` from `^11.19.0` to `^11.20.0` ([#8344](https://github.com/MetaMask/core/pull/8344))
|
|
13
13
|
- Bump `@metamask/messenger` from `^1.0.0` to `^1.1.1` ([#8364](https://github.com/MetaMask/core/pull/8364), [#8373](https://github.com/MetaMask/core/pull/8373))
|
|
14
|
-
- Bump `@metamask/base-controller` from `^9.0.1` to `^9.1.0` ([#8457](https://github.com/MetaMask/core/pull/8457))
|
|
15
14
|
|
|
16
15
|
## [14.1.1]
|
|
17
16
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DecryptMessageManager.cjs","sourceRoot":"","sources":["../src/DecryptMessageManager.ts"],"names":[],"mappings":";;;AAIA,iEAA0D;AAY1D,yEAAkE;AAClE,uCAA6E;AAE7E,MAAM,WAAW,GAAG,uBAAuB,CAAC;
|
|
1
|
+
{"version":3,"file":"DecryptMessageManager.cjs","sourceRoot":"","sources":["../src/DecryptMessageManager.ts"],"names":[],"mappings":";;;AAIA,iEAA0D;AAY1D,yEAAkE;AAClE,uCAA6E;AAE7E,MAAM,WAAW,GAAG,uBAAuB,CAAC;AAiF5C;;GAEG;AACH,MAAa,qBAAsB,SAAQ,+CAM1C;IACC,YAAY,EACV,wBAAwB,EACxB,SAAS,EACT,uBAAuB,EACvB,KAAK,GACwB;QAC7B,KAAK,CAAC;YACJ,wBAAwB;YACxB,SAAS;YACT,IAAI,EAAE,WAAW;YACjB,uBAAuB;YACvB,KAAK;SACN,CAAC,CAAC;IACL,CAAC;IAED;;;;;;;OAOG;IACH,KAAK,CAAC,yBAAyB,C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AAC,CAAC;QACnC,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,GAAG,WAAW,oBAAoB,EAAE;YACzD,GAAG,oBAAoB;YACvB,UAAU,EAAE,SAAS;SACtB,CAAC,CAAC;QACH,OAAO,SAAS,CAAC;IACnB,CAAC;IAED;;;;;;OAMG;IACH,qBAAqB,CACnB,aAA2C;QAE3C,OAAO,aAAa,CAAC,UAAU,CAAC;QAChC,OAAO,OAAO,CAAC,OAAO,CAAC,aAAa,CAAC,CAAC;IACxC,CAAC;CACF;AAvHD,sDAuHC","sourcesContent":["import type {\n ControllerGetStateAction,\n ControllerStateChangeEvent,\n} from '@metamask/base-controller';\nimport { ApprovalType } from '@metamask/controller-utils';\nimport type { Messenger } from '@metamask/messenger';\nimport {} from '@metamask/messenger';\n\nimport type {\n AbstractMessage,\n AbstractMessageParams,\n AbstractMessageParamsMetamask,\n MessageManagerState,\n MessageRequest,\n SecurityProviderRequest,\n} from './AbstractMessageManager';\nimport { AbstractMessageManager } from './AbstractMessageManager';\nimport { normalizeMessageData, validateDecryptedMessageData } from './utils';\n\nconst managerName = 'DecryptMessageManager';\n\nexport type DecryptMessageManagerState = MessageManagerState<DecryptMessage>;\n\nexport type DecryptMessageManagerUnapprovedMessageAddedEvent = {\n type: `${typeof managerName}:unapprovedMessage`;\n payload: [AbstractMessageParamsMetamask];\n};\n\nexport type DecryptMessageManagerUpdateBadgeEvent = {\n type: `${typeof managerName}:updateBadge`;\n payload: [];\n};\n\ntype DecryptMessageManagerActions = ControllerGetStateAction<\n typeof managerName,\n DecryptMessageManagerState\n>;\n\ntype DecryptMessageManagerEvents =\n | ControllerStateChangeEvent<typeof managerName, DecryptMessageManagerState>\n | DecryptMessageManagerUnapprovedMessageAddedEvent\n | DecryptMessageManagerUpdateBadgeEvent;\n\nexport type DecryptMessageManagerMessenger = Messenger<\n typeof managerName,\n DecryptMessageManagerActions,\n DecryptMessageManagerEvents\n>;\n\ntype DecryptMessageManagerOptions = {\n messenger: DecryptMessageManagerMessenger;\n securityProviderRequest?: SecurityProviderRequest;\n state?: MessageManagerState<DecryptMessage>;\n additionalFinishStatuses?: string[];\n};\n\n/**\n * @type DecryptMessage\n *\n * Represents and contains data about a 'eth_decrypt' type signature request.\n * These are created when a signature for an eth_decrypt call is requested.\n *\n * @property id - An id to track and identify the message object\n * @property messageParams - The parameters to pass to the eth_decrypt method once the request is approved\n * @property type - The json-prc signing method for which a signature request has been made.\n * A 'DecryptMessage' which always has a 'eth_decrypt' type\n */\nexport type DecryptMessage = AbstractMessage & {\n messageParams: DecryptMessageParams;\n};\n\n/**\n * @type DecryptMessageParams\n *\n * Represents the parameters to pass to the eth_decrypt method once the request is approved.\n * @property data - A hex string conversion of the raw buffer data of the signature request\n */\nexport type DecryptMessageParams = AbstractMessageParams & {\n data: string;\n};\n\n/**\n * @type DecryptMessageParamsMetamask\n *\n * Represents the parameters to pass to the eth_decrypt method once the request is approved\n * plus data added by MetaMask.\n *\n * @property metamaskId - Added for tracking and identification within MetaMask\n * @property data - A hex string conversion of the raw buffer data of the signature request\n * @property from - Address to sign this message from\n * @property origin? - Added for request origin identification\n */\n// This interface was created before this ESLint rule was added.\n// Convert to a `type` in a future major version.\n// eslint-disable-next-line @typescript-eslint/consistent-type-definitions\nexport interface DecryptMessageParamsMetamask\n extends AbstractMessageParamsMetamask {\n data: string;\n}\n\n/**\n * Controller in charge of managing - storing, adding, removing, updating - DecryptMessages.\n */\nexport class DecryptMessageManager extends AbstractMessageManager<\n typeof managerName,\n DecryptMessage,\n DecryptMessageParams,\n DecryptMessageParamsMetamask,\n DecryptMessageManagerMessenger\n> {\n constructor({\n additionalFinishStatuses,\n messenger,\n securityProviderRequest,\n state,\n }: DecryptMessageManagerOptions) {\n super({\n additionalFinishStatuses,\n messenger,\n name: managerName,\n securityProviderRequest,\n state,\n });\n }\n\n /**\n * Creates a new Message with an 'unapproved' status using the passed messageParams.\n * this.addMessage is called to add the new Message to this.messages, and to save the unapproved Messages.\n *\n * @param messageParams - The params for the personal_sign call to be made after the message is approved.\n * @param req - The original request object possibly containing the origin.\n * @returns Promise resolving to the raw data of the signature request.\n */\n async addUnapprovedMessageAsync(\n messageParams: DecryptMessageParams,\n req?: MessageRequest,\n ): Promise<string> {\n validateDecryptedMessageData(messageParams);\n const messageId = await this.addUnapprovedMessage(messageParams, req);\n\n return new Promise((resolve, reject) => {\n this.internalEvents.once(\n `${messageId}:finished`,\n (data: DecryptMessage) => {\n switch (data.status) {\n case 'decrypted':\n return resolve(data.rawSig as string);\n case 'rejected':\n return reject(\n new Error(\n 'MetaMask DecryptMessage: User denied message decryption.',\n ),\n );\n case 'errored':\n return reject(\n new Error(\n 'MetaMask DecryptMessage: This message cannot be decrypted.',\n ),\n );\n default:\n return reject(\n new Error(\n `MetaMask DecryptMessage: Unknown problem: ${JSON.stringify(\n messageParams,\n )}`,\n ),\n );\n }\n },\n );\n });\n }\n\n /**\n * Creates a new Message with an 'unapproved' status using the passed messageParams.\n * this.addMessage is called to add the new Message to this.messages, and to save the\n * unapproved Messages.\n *\n * @param messageParams - The params for the personal_sign call to be made after the message\n * is approved.\n * @param req - The original request object possibly containing the origin.\n * @returns The id of the newly created message.\n */\n async addUnapprovedMessage(\n messageParams: DecryptMessageParams,\n req?: MessageRequest,\n ) {\n const updatedMessageParams = this.addRequestToMessageParams(\n messageParams,\n req,\n ) satisfies DecryptMessageParams;\n messageParams.data = normalizeMessageData(messageParams.data);\n\n const messageData = this.createUnapprovedMessage(\n updatedMessageParams,\n ApprovalType.EthDecrypt,\n req,\n ) satisfies DecryptMessage;\n\n const messageId = messageData.id;\n\n await this.addMessage(messageData);\n this.messenger.publish(`${managerName}:unapprovedMessage`, {\n ...updatedMessageParams,\n metamaskId: messageId,\n });\n return messageId;\n }\n\n /**\n * Removes the metamaskId property from passed messageParams and returns a promise which\n * resolves the updated messageParams.\n *\n * @param messageParams - The messageParams to modify.\n * @returns Promise resolving to the messageParams with the metamaskId property removed.\n */\n prepMessageForSigning(\n messageParams: DecryptMessageParamsMetamask,\n ): Promise<DecryptMessageParams> {\n delete messageParams.metamaskId;\n return Promise.resolve(messageParams);\n }\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DecryptMessageManager.d.cts","sourceRoot":"","sources":["../src/DecryptMessageManager.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,wBAAwB,EACxB,0BAA0B,EAC3B,kCAAkC;AAEnC,OAAO,KAAK,EAAE,SAAS,EAAE,4BAA4B;AAGrD,OAAO,KAAK,EACV,eAAe,EACf,qBAAqB,EACrB,6BAA6B,EAC7B,mBAAmB,EACnB,cAAc,EACd,uBAAuB,EACxB,qCAAiC;AAClC,OAAO,EAAE,sBAAsB,EAAE,qCAAiC;AAGlE,QAAA,MAAM,WAAW,0BAA0B,CAAC;AAE5C,MAAM,MAAM,0BAA0B,GAAG,mBAAmB,CAAC,cAAc,CAAC,CAAC;AAE7E,MAAM,MAAM,gDAAgD,GAAG;IAC7D,IAAI,EAAE,GAAG,OAAO,WAAW,oBAAoB,CAAC;IAChD,OAAO,EAAE,CAAC,6BAA6B,CAAC,CAAC;CAC1C,CAAC;AAEF,MAAM,MAAM,qCAAqC,GAAG;IAClD,IAAI,EAAE,GAAG,OAAO,WAAW,cAAc,CAAC;IAC1C,OAAO,EAAE,EAAE,CAAC;CACb,CAAC;AAEF,KAAK,4BAA4B,GAAG,wBAAwB,CAC1D,OAAO,WAAW,EAClB,0BAA0B,CAC3B,CAAC;AAEF,KAAK,2BAA2B,GAC5B,0BAA0B,CAAC,OAAO,WAAW,EAAE,0BAA0B,CAAC,GAC1E,gDAAgD,GAChD,qCAAqC,CAAC;AAE1C,MAAM,MAAM,8BAA8B,GAAG,SAAS,CACpD,OAAO,WAAW,EAClB,4BAA4B,EAC5B,2BAA2B,CAC5B,CAAC;AAEF,KAAK,4BAA4B,GAAG;IAClC,SAAS,EAAE,8BAA8B,CAAC;IAC1C,uBAAuB,CAAC,EAAE,uBAAuB,CAAC;IACl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ACZ,OAAO,MAAM,CACX,IAAI,KAAK,CACP,4DAA4D,CAC7D,CACF,CAAC;oBACJ;wBACE,OAAO,MAAM,CACX,IAAI,KAAK,CACP,6CAA6C,IAAI,CAAC,SAAS,CACzD,aAAa,CACd,EAAE,CACJ,CACF,CAAC;gBACN,CAAC;YACH,CAAC,CACF,CAAC;QACJ,CAAC,CAAC,CAAC;IACL,CAAC;IAED;;;;;;;;;OASG;IACH,KAAK,CAAC,oBAAoB,CACxB,aAAmC,EACnC,GAAoB;QAEpB,MAAM,oBAAoB,GAAG,IAAI,CAAC,yBAAyB,CACzD,aAAa,EACb,GAAG,CAC2B,CAAC;QACjC,aAAa,CAAC,IAAI,GAAG,oBAAoB,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC;QAE9D,MAAM,WAAW,GAAG,IAAI,CAAC,uBAAuB,CAC9C,oBAAoB,EACpB,YAAY,CAAC,UAAU,EACvB,GAAG,CACqB,CAAC;QAE3B,MAAM,SAAS,GAAG,WAAW,CAAC,EAAE,CAAC;QAEjC,MAAM,IAAI,CAAC,UAAU,CAAC,WAAW,CAAC,CAAC;QACnC,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,GAAG,WAAW,oBAAoB,EAAE;YACzD,GAAG,oBAAoB;YACvB,UAAU,EAAE,SAAS;SACtB,CAAC,CAAC;QACH,OAAO,SAAS,CAAC;IACnB,CAAC;IAED;;;;;;OAMG;IACH,qBAAqB,CACnB,aAA2C;QAE3C,OAAO,aAAa,CAAC,UAAU,CAAC;QAChC,OAAO,OAAO,CAAC,OAAO,CAAC,aAAa,CAAC,CAAC;IACxC,CAAC;CACF","sourcesContent":["import type {\n ControllerGetStateAction,\n ControllerStateChangeEvent,\n} from '@metamask/base-controller';\nimport { ApprovalType } from '@metamask/controller-utils';\nimport type { Messenger } from '@metamask/messenger';\nimport {} from '@metamask/messenger';\n\nimport type {\n AbstractMessage,\n AbstractMessageParams,\n AbstractMessageParamsMetamask,\n MessageManagerState,\n MessageRequest,\n SecurityProviderRequest,\n} from './AbstractMessageManager';\nimport { AbstractMessageManager } from './AbstractMessageManager';\nimport { normalizeMessageData, validateDecryptedMessageData } from './utils';\n\nconst managerName = 'DecryptMessageManager';\n\nexport type DecryptMessageManagerState = MessageManagerState<DecryptMessage>;\n\nexport type DecryptMessageManagerUnapprovedMessageAddedEvent = {\n type: `${typeof managerName}:unapprovedMessage`;\n payload: [AbstractMessageParamsMetamask];\n};\n\nexport type DecryptMessageManagerUpdateBadgeEvent = {\n type: `${typeof managerName}:updateBadge`;\n payload: [];\n};\n\ntype DecryptMessageManagerActions = ControllerGetStateAction<\n typeof managerName,\n DecryptMessageManagerState\n>;\n\ntype DecryptMessageManagerEvents =\n | ControllerStateChangeEvent<typeof managerName, DecryptMessageManagerState>\n | DecryptMessageManagerUnapprovedMessageAddedEvent\n | DecryptMessageManagerUpdateBadgeEvent;\n\nexport type DecryptMessageManagerMessenger = Messenger<\n typeof managerName,\n DecryptMessageManagerActions,\n DecryptMessageManagerEvents\n>;\n\ntype DecryptMessageManagerOptions = {\n messenger: DecryptMessageManagerMessenger;\n securityProviderRequest?: SecurityProviderRequest;\n state?: MessageManagerState<DecryptMessage>;\n additionalFinishStatuses?: string[];\n};\n\n/**\n * @type DecryptMessage\n *\n * Represents and contains data about a 'eth_decrypt' type signature request.\n * These are created when a signature for an eth_decrypt call is requested.\n *\n * @property id - An id to track and identify the message object\n * @property messageParams - The parameters to pass to the eth_decrypt method once the request is approved\n * @property type - The json-prc signing method for which a signature request has been made.\n * A 'DecryptMessage' which always has a 'eth_decrypt' type\n */\nexport type DecryptMessage = AbstractMessage & {\n messageParams: DecryptMessageParams;\n};\n\n/**\n * @type DecryptMessageParams\n *\n * Represents the parameters to pass to the eth_decrypt method once the request is approved.\n * @property data - A hex string conversion of the raw buffer data of the signature request\n */\nexport type DecryptMessageParams = AbstractMessageParams & {\n data: string;\n};\n\n/**\n * @type DecryptMessageParamsMetamask\n *\n * Represents the parameters to pass to the eth_decrypt method once the request is approved\n * plus data added by MetaMask.\n *\n * @property metamaskId - Added for tracking and identification within MetaMask\n * @property data - A hex string conversion of the raw buffer data of the signature request\n * @property from - Address to sign this message from\n * @property origin? - Added for request origin identification\n */\n// This interface was created before this ESLint rule was added.\n// Convert to a `type` in a future major version.\n// eslint-disable-next-line @typescript-eslint/consistent-type-definitions\nexport interface DecryptMessageParamsMetamask\n extends AbstractMessageParamsMetamask {\n data: string;\n}\n\n/**\n * Controller in charge of managing - storing, adding, removing, updating - DecryptMessages.\n */\nexport class DecryptMessageManager extends AbstractMessageManager<\n typeof managerName,\n DecryptMessage,\n DecryptMessageParams,\n DecryptMessageParamsMetamask,\n DecryptMessageManagerMessenger\n> {\n constructor({\n additionalFinishStatuses,\n messenger,\n securityProviderRequest,\n state,\n }: DecryptMessageManagerOptions) {\n super({\n additionalFinishStatuses,\n messenger,\n name: managerName,\n securityProviderRequest,\n state,\n });\n }\n\n /**\n * Creates a new Message with an 'unapproved' status using the passed messageParams.\n * this.addMessage is called to add the new Message to this.messages, and to save the unapproved Messages.\n *\n * @param messageParams - The params for the personal_sign call to be made after the message is approved.\n * @param req - The original request object possibly containing the origin.\n * @returns Promise resolving to the raw data of the signature request.\n */\n async addUnapprovedMessageAsync(\n messageParams: DecryptMessageParams,\n req?: MessageRequest,\n ): Promise<string> {\n validateDecryptedMessageData(messageParams);\n const messageId = await this.addUnapprovedMessage(messageParams, req);\n\n return new Promise((resolve, reject) => {\n this.internalEvents.once(\n `${messageId}:finished`,\n (data: DecryptMessage) => {\n switch (data.status) {\n case 'decrypted':\n return resolve(data.rawSig as string);\n case 'rejected':\n return reject(\n new Error(\n 'MetaMask DecryptMessage: User denied message decryption.',\n ),\n );\n case 'errored':\n return reject(\n new Error(\n 'MetaMask DecryptMessage: This message cannot be decrypted.',\n ),\n );\n default:\n return reject(\n new Error(\n `MetaMask DecryptMessage: Unknown problem: ${JSON.stringify(\n messageParams,\n )}`,\n ),\n );\n }\n },\n );\n });\n }\n\n /**\n * Creates a new Message with an 'unapproved' status using the passed messageParams.\n * this.addMessage is called to add the new Message to this.messages, and to save the\n * unapproved Messages.\n *\n * @param messageParams - The params for the personal_sign call to be made after the message\n * is approved.\n * @param req - The original request object possibly containing the origin.\n * @returns The id of the newly created message.\n */\n async addUnapprovedMessage(\n messageParams: DecryptMessageParams,\n req?: MessageRequest,\n ) {\n const updatedMessageParams = this.addRequestToMessageParams(\n messageParams,\n req,\n ) satisfies DecryptMessageParams;\n messageParams.data = normalizeMessageData(messageParams.data);\n\n const messageData = this.createUnapprovedMessage(\n updatedMessageParams,\n ApprovalType.EthDecrypt,\n req,\n ) satisfies DecryptMessage;\n\n const messageId = messageData.id;\n\n await this.addMessage(messageData);\n this.messenger.publish(`${managerName}:unapprovedMessage`, {\n ...updatedMessageParams,\n metamaskId: messageId,\n });\n return messageId;\n }\n\n /**\n * Removes the metamaskId property from passed messageParams and returns a promise which\n * resolves the updated messageParams.\n *\n * @param messageParams - The messageParams to modify.\n * @returns Promise resolving to the messageParams with the metamaskId property removed.\n */\n prepMessageForSigning(\n messageParams: DecryptMessageParamsMetamask,\n ): Promise<DecryptMessageParams> {\n delete messageParams.metamaskId;\n return Promise.resolve(messageParams);\n }\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,26 +1,21 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@metamask-previews/message-manager",
|
|
3
|
-
"version": "14.1.1-preview-
|
|
3
|
+
"version": "14.1.1-preview-60aa3d02f",
|
|
4
4
|
"description": "Stores and manages interactions with signing requests",
|
|
5
5
|
"keywords": [
|
|
6
|
-
"
|
|
7
|
-
"
|
|
6
|
+
"MetaMask",
|
|
7
|
+
"Ethereum"
|
|
8
8
|
],
|
|
9
9
|
"homepage": "https://github.com/MetaMask/core/tree/main/packages/message-manager#readme",
|
|
10
10
|
"bugs": {
|
|
11
11
|
"url": "https://github.com/MetaMask/core/issues"
|
|
12
12
|
},
|
|
13
|
-
"license": "MIT",
|
|
14
13
|
"repository": {
|
|
15
14
|
"type": "git",
|
|
16
15
|
"url": "https://github.com/MetaMask/core.git"
|
|
17
16
|
},
|
|
18
|
-
"
|
|
19
|
-
"dist/"
|
|
20
|
-
],
|
|
17
|
+
"license": "MIT",
|
|
21
18
|
"sideEffects": false,
|
|
22
|
-
"main": "./dist/index.cjs",
|
|
23
|
-
"types": "./dist/index.d.cts",
|
|
24
19
|
"exports": {
|
|
25
20
|
".": {
|
|
26
21
|
"import": {
|
|
@@ -34,10 +29,11 @@
|
|
|
34
29
|
},
|
|
35
30
|
"./package.json": "./package.json"
|
|
36
31
|
},
|
|
37
|
-
"
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
32
|
+
"main": "./dist/index.cjs",
|
|
33
|
+
"types": "./dist/index.d.cts",
|
|
34
|
+
"files": [
|
|
35
|
+
"dist/"
|
|
36
|
+
],
|
|
41
37
|
"scripts": {
|
|
42
38
|
"build": "ts-bridge --project tsconfig.build.json --verbose --clean --no-references",
|
|
43
39
|
"build:all": "ts-bridge --project tsconfig.build.json --verbose --clean",
|
|
@@ -51,7 +47,7 @@
|
|
|
51
47
|
"test:watch": "NODE_OPTIONS=--experimental-vm-modules jest --watch"
|
|
52
48
|
},
|
|
53
49
|
"dependencies": {
|
|
54
|
-
"@metamask/base-controller": "^9.1
|
|
50
|
+
"@metamask/base-controller": "^9.0.1",
|
|
55
51
|
"@metamask/controller-utils": "^11.20.0",
|
|
56
52
|
"@metamask/eth-sig-util": "^8.2.0",
|
|
57
53
|
"@metamask/messenger": "^1.1.1",
|
|
@@ -61,7 +57,7 @@
|
|
|
61
57
|
"uuid": "^8.3.2"
|
|
62
58
|
},
|
|
63
59
|
"devDependencies": {
|
|
64
|
-
"@metamask/auto-changelog": "^
|
|
60
|
+
"@metamask/auto-changelog": "^3.4.4",
|
|
65
61
|
"@ts-bridge/cli": "^0.6.4",
|
|
66
62
|
"@types/jest": "^29.5.14",
|
|
67
63
|
"deepmerge": "^4.2.2",
|
|
@@ -73,5 +69,9 @@
|
|
|
73
69
|
},
|
|
74
70
|
"engines": {
|
|
75
71
|
"node": "^18.18 || >=20"
|
|
72
|
+
},
|
|
73
|
+
"publishConfig": {
|
|
74
|
+
"access": "public",
|
|
75
|
+
"registry": "https://registry.npmjs.org/"
|
|
76
76
|
}
|
|
77
77
|
}
|