@metamask/gator-permissions-controller 1.0.0 → 1.1.1
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 +24 -1
- package/dist/GatorPermissionsController.cjs +21 -1
- package/dist/GatorPermissionsController.cjs.map +1 -1
- package/dist/GatorPermissionsController.d.cts.map +1 -1
- package/dist/GatorPermissionsController.d.mts.map +1 -1
- package/dist/GatorPermissionsController.mjs +21 -1
- package/dist/GatorPermissionsController.mjs.map +1 -1
- package/dist/decodePermission/decodePermission.cjs +21 -1
- package/dist/decodePermission/decodePermission.cjs.map +1 -1
- package/dist/decodePermission/decodePermission.d.cts.map +1 -1
- package/dist/decodePermission/decodePermission.d.mts.map +1 -1
- package/dist/decodePermission/decodePermission.mjs +21 -1
- package/dist/decodePermission/decodePermission.mjs.map +1 -1
- package/dist/decodePermission/utils.cjs +2 -2
- package/dist/decodePermission/utils.cjs.map +1 -1
- package/dist/decodePermission/utils.d.cts +10 -10
- package/dist/decodePermission/utils.d.cts.map +1 -1
- package/dist/decodePermission/utils.d.mts +10 -10
- package/dist/decodePermission/utils.d.mts.map +1 -1
- package/dist/decodePermission/utils.mjs +2 -2
- package/dist/decodePermission/utils.mjs.map +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1 -1
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts +1 -1
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs.map +1 -1
- package/dist/types.cjs.map +1 -1
- package/dist/types.d.cts +15 -10
- package/dist/types.d.cts.map +1 -1
- package/dist/types.d.mts +15 -10
- package/dist/types.d.mts.map +1 -1
- package/dist/types.mjs.map +1 -1
- package/package.json +2 -2
|
@@ -18,15 +18,15 @@ export type PermissionRule = {
|
|
|
18
18
|
* @throws If the chain or an expected enforcer contract is not found.
|
|
19
19
|
*/
|
|
20
20
|
export declare const getChecksumEnforcersByChainId: (contracts: DeployedContractsByName) => {
|
|
21
|
-
erc20StreamingEnforcer:
|
|
22
|
-
erc20PeriodicEnforcer:
|
|
23
|
-
nativeTokenStreamingEnforcer:
|
|
24
|
-
nativeTokenPeriodicEnforcer:
|
|
25
|
-
exactCalldataEnforcer:
|
|
26
|
-
valueLteEnforcer:
|
|
27
|
-
timestampEnforcer:
|
|
28
|
-
nonceEnforcer:
|
|
29
|
-
allowedCalldataEnforcer:
|
|
21
|
+
erc20StreamingEnforcer: Hex;
|
|
22
|
+
erc20PeriodicEnforcer: Hex;
|
|
23
|
+
nativeTokenStreamingEnforcer: Hex;
|
|
24
|
+
nativeTokenPeriodicEnforcer: Hex;
|
|
25
|
+
exactCalldataEnforcer: Hex;
|
|
26
|
+
valueLteEnforcer: Hex;
|
|
27
|
+
timestampEnforcer: Hex;
|
|
28
|
+
nonceEnforcer: Hex;
|
|
29
|
+
allowedCalldataEnforcer: Hex;
|
|
30
30
|
};
|
|
31
31
|
/**
|
|
32
32
|
* Builds the canonical set of permission matching rules for a chain.
|
|
@@ -47,7 +47,7 @@ export declare const createPermissionRulesForChainId: (contracts: DeployedContra
|
|
|
47
47
|
* @param superset - The set expected to contain all elements of `subset`.
|
|
48
48
|
* @returns `true` if `subset` ⊆ `superset`, otherwise `false`.
|
|
49
49
|
*/
|
|
50
|
-
export declare const isSubset: <
|
|
50
|
+
export declare const isSubset: <TElement>(subset: Set<TElement>, superset: Set<TElement>) => boolean;
|
|
51
51
|
/**
|
|
52
52
|
* Gets the terms for a given enforcer from a list of caveats.
|
|
53
53
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.cts","sourceRoot":"","sources":["../../src/decodePermission/utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,kCAAkC;AAExD,OAAO,KAAK,EAAE,GAAG,EAAE,wBAAwB;AAE3C,OAAO,KAAK,EAAE,uBAAuB,EAAE,cAAc,EAAE,oBAAgB;AAEvE;;GAEG;AACH,MAAM,MAAM,cAAc,GAA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C;IACd,eAAe,CAAC,EAAE,gBAAgB,CAAC;CACpC,GAAG,gBAAgB,SAAS,IAAI,GAAG,GAAG,GAAG,GAAG,GAAG,IAAI,CAiBnD;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,QAAQ,CAAC,KAAK,EAAE,GAAG,EAAE,OAAO,EAAE,MAAM,EAAE,GAAG,GAAG,EAAE,CAU7D"}
|
|
@@ -18,15 +18,15 @@ export type PermissionRule = {
|
|
|
18
18
|
* @throws If the chain or an expected enforcer contract is not found.
|
|
19
19
|
*/
|
|
20
20
|
export declare const getChecksumEnforcersByChainId: (contracts: DeployedContractsByName) => {
|
|
21
|
-
erc20StreamingEnforcer:
|
|
22
|
-
erc20PeriodicEnforcer:
|
|
23
|
-
nativeTokenStreamingEnforcer:
|
|
24
|
-
nativeTokenPeriodicEnforcer:
|
|
25
|
-
exactCalldataEnforcer:
|
|
26
|
-
valueLteEnforcer:
|
|
27
|
-
timestampEnforcer:
|
|
28
|
-
nonceEnforcer:
|
|
29
|
-
allowedCalldataEnforcer:
|
|
21
|
+
erc20StreamingEnforcer: Hex;
|
|
22
|
+
erc20PeriodicEnforcer: Hex;
|
|
23
|
+
nativeTokenStreamingEnforcer: Hex;
|
|
24
|
+
nativeTokenPeriodicEnforcer: Hex;
|
|
25
|
+
exactCalldataEnforcer: Hex;
|
|
26
|
+
valueLteEnforcer: Hex;
|
|
27
|
+
timestampEnforcer: Hex;
|
|
28
|
+
nonceEnforcer: Hex;
|
|
29
|
+
allowedCalldataEnforcer: Hex;
|
|
30
30
|
};
|
|
31
31
|
/**
|
|
32
32
|
* Builds the canonical set of permission matching rules for a chain.
|
|
@@ -47,7 +47,7 @@ export declare const createPermissionRulesForChainId: (contracts: DeployedContra
|
|
|
47
47
|
* @param superset - The set expected to contain all elements of `subset`.
|
|
48
48
|
* @returns `true` if `subset` ⊆ `superset`, otherwise `false`.
|
|
49
49
|
*/
|
|
50
|
-
export declare const isSubset: <
|
|
50
|
+
export declare const isSubset: <TElement>(subset: Set<TElement>, superset: Set<TElement>) => boolean;
|
|
51
51
|
/**
|
|
52
52
|
* Gets the terms for a given enforcer from a list of caveats.
|
|
53
53
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.mts","sourceRoot":"","sources":["../../src/decodePermission/utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,kCAAkC;AAExD,OAAO,KAAK,EAAE,GAAG,EAAE,wBAAwB;AAE3C,OAAO,KAAK,EAAE,uBAAuB,EAAE,cAAc,EAAE,oBAAgB;AAEvE;;GAEG;AACH,MAAM,MAAM,cAAc,GAAG;IAC3B,cAAc,EAAE,cAAc,CAAC;IAC/B,iBAAiB,EAAE,GAAG,CAAC,GAAG,EAAE,MAAM,CAAC,CAAC;IACpC,iBAAiB,EAAE,GAAG,CAAC,GAAG,CAAC,CAAC;CAC7B,CAAC;AAiBF;;;;;;;GAOG;AACH,eAAO,MAAM,6BAA6B,cAC7B,uBAAuB
|
|
1
|
+
{"version":3,"file":"utils.d.mts","sourceRoot":"","sources":["../../src/decodePermission/utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,kCAAkC;AAExD,OAAO,KAAK,EAAE,GAAG,EAAE,wBAAwB;AAE3C,OAAO,KAAK,EAAE,uBAAuB,EAAE,cAAc,EAAE,oBAAgB;AAEvE;;GAEG;AACH,MAAM,MAAM,cAAc,GAAG;IAC3B,cAAc,EAAE,cAAc,CAAC;IAC/B,iBAAiB,EAAE,GAAG,CAAC,GAAG,EAAE,MAAM,CAAC,CAAC;IACpC,iBAAiB,EAAE,GAAG,CAAC,GAAG,CAAC,CAAC;CAC7B,CAAC;AAiBF;;;;;;;GAOG;AACH,eAAO,MAAM,6BAA6B,cAC7B,uBAAuB;4BAEV,GAAG;2BACJ,GAAG;kCACI,GAAG;iCACJ,GAAG;2BACT,GAAG;sBACR,GAAG;uBACF,GAAG;mBACP,GAAG;6BACO,GAAG;CAuD7B,CAAC;AAEF;;;;;;;;;;GAUG;AACH,eAAO,MAAM,+BAA+B,EAAE,CAC5C,SAAS,EAAE,uBAAuB,KAC/B,cAAc,EAiElB,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,QAAQ,gEAGlB,OAOF,CAAC;AAEF;;;;;;;;GAQG;AACH,wBAAgB,kBAAkB,CAAC,gBAAgB,SAAS,OAAO,GAAG,IAAI,EAAE,EAC1E,OAAO,EACP,QAAQ,EACR,eAAe,GAChB,EAAE;IACD,OAAO,EAAE,MAAM,CAAC,GAAG,CAAC,EAAE,CAAC;IACvB,QAAQ,EAAE,GAAG,CAAC;IACd,eAAe,CAAC,EAAE,gBAAgB,CAAC;CACpC,GAAG,gBAAgB,SAAS,IAAI,GAAG,GAAG,GAAG,GAAG,GAAG,IAAI,CAiBnD;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,QAAQ,CAAC,KAAK,EAAE,GAAG,EAAE,OAAO,EAAE,MAAM,EAAE,GAAG,GAAG,EAAE,CAU7D"}
|
|
@@ -124,8 +124,8 @@ export const createPermissionRulesForChainId = (contracts) => {
|
|
|
124
124
|
* @returns `true` if `subset` ⊆ `superset`, otherwise `false`.
|
|
125
125
|
*/
|
|
126
126
|
export const isSubset = (subset, superset) => {
|
|
127
|
-
for (const
|
|
128
|
-
if (!superset.has(
|
|
127
|
+
for (const element of subset) {
|
|
128
|
+
if (!superset.has(element)) {
|
|
129
129
|
return false;
|
|
130
130
|
}
|
|
131
131
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.mjs","sourceRoot":"","sources":["../../src/decodePermission/utils.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,kBAAkB,EAAE,wBAAwB;AAcrD;;GAEG;AACH,MAAM,uBAAuB,GAAG;IAC9B,2BAA2B,EAAE,6BAA6B;IAC1D,sBAAsB,EAAE,wBAAwB;IAChD,qBAAqB,EAAE,uBAAuB;IAC9C,iC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AAE,CAAC;QAC/B,MAAM,IAAI,KAAK,CAAC,iBAAiB,CAAC,CAAC;IACrC,CAAC;IAED,OAAO,eAAe,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC;AAClC,CAAC;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,UAAU,QAAQ,CAAC,KAAU,EAAE,OAAiB;IACpD,IAAI,KAAK,GAAG,CAAC,CAAC;IACd,MAAM,KAAK,GAAU,EAAE,CAAC;IACxB,KAAK,MAAM,UAAU,IAAI,OAAO,EAAE,CAAC;QACjC,MAAM,cAAc,GAAG,UAAU,GAAG,CAAC,CAAC;QACtC,MAAM,IAAI,GAAG,KAAK,CAAC,KAAK,CAAC,KAAK,EAAE,KAAK,GAAG,cAAc,CAAC,CAAC;QACxD,KAAK,IAAI,cAAc,CAAC;QACxB,KAAK,CAAC,IAAI,CAAC,KAAK,IAAI,EAAW,CAAC,CAAC;IACnC,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC","sourcesContent":["import type { Caveat } from '@metamask/delegation-core';\nimport { getChecksumAddress } from '@metamask/utils';\nimport type { Hex } from '@metamask/utils';\n\nimport type { DeployedContractsByName, PermissionType } from './types';\n\n/**\n * A rule that defines the required and allowed enforcers for a permission type.\n */\nexport type PermissionRule = {\n permissionType: PermissionType;\n requiredEnforcers: Map<Hex, number>;\n optionalEnforcers: Set<Hex>;\n};\n\n/**\n * The names of the enforcer contracts for each permission type.\n */\nconst ENFORCER_CONTRACT_NAMES = {\n ERC20PeriodTransferEnforcer: 'ERC20PeriodTransferEnforcer',\n ERC20StreamingEnforcer: 'ERC20StreamingEnforcer',\n ExactCalldataEnforcer: 'ExactCalldataEnforcer',\n NativeTokenPeriodTransferEnforcer: 'NativeTokenPeriodTransferEnforcer',\n NativeTokenStreamingEnforcer: 'NativeTokenStreamingEnforcer',\n TimestampEnforcer: 'TimestampEnforcer',\n ValueLteEnforcer: 'ValueLteEnforcer',\n NonceEnforcer: 'NonceEnforcer',\n AllowedCalldataEnforcer: 'AllowedCalldataEnforcer',\n};\n\n/**\n * Resolves and returns checksummed addresses of all known enforcer contracts\n * for a given `chainId` under the current delegation framework version.\n *\n * @param contracts - The deployed contracts for the chain.\n * @returns An object mapping enforcer names to checksummed contract addresses.\n * @throws If the chain or an expected enforcer contract is not found.\n */\nexport const getChecksumEnforcersByChainId = (\n contracts: DeployedContractsByName,\n) => {\n const getChecksumContractAddress = (contractName: string) => {\n const address = contracts[contractName];\n\n if (!address) {\n throw new Error(`Contract not found: ${contractName}`);\n }\n\n return getChecksumAddress(address);\n };\n\n // permission type specific enforcers\n const erc20StreamingEnforcer = getChecksumContractAddress(\n ENFORCER_CONTRACT_NAMES.ERC20StreamingEnforcer,\n );\n const erc20PeriodicEnforcer = getChecksumContractAddress(\n ENFORCER_CONTRACT_NAMES.ERC20PeriodTransferEnforcer,\n );\n const nativeTokenStreamingEnforcer = getChecksumContractAddress(\n ENFORCER_CONTRACT_NAMES.NativeTokenStreamingEnforcer,\n );\n const nativeTokenPeriodicEnforcer = getChecksumContractAddress(\n ENFORCER_CONTRACT_NAMES.NativeTokenPeriodTransferEnforcer,\n );\n\n // general enforcers\n const exactCalldataEnforcer = getChecksumContractAddress(\n ENFORCER_CONTRACT_NAMES.ExactCalldataEnforcer,\n );\n const valueLteEnforcer = getChecksumContractAddress(\n ENFORCER_CONTRACT_NAMES.ValueLteEnforcer,\n );\n const timestampEnforcer = getChecksumContractAddress(\n ENFORCER_CONTRACT_NAMES.TimestampEnforcer,\n );\n const nonceEnforcer = getChecksumContractAddress(\n ENFORCER_CONTRACT_NAMES.NonceEnforcer,\n );\n\n const allowedCalldataEnforcer = getChecksumContractAddress(\n ENFORCER_CONTRACT_NAMES.AllowedCalldataEnforcer,\n );\n\n return {\n erc20StreamingEnforcer,\n erc20PeriodicEnforcer,\n nativeTokenStreamingEnforcer,\n nativeTokenPeriodicEnforcer,\n exactCalldataEnforcer,\n valueLteEnforcer,\n timestampEnforcer,\n nonceEnforcer,\n allowedCalldataEnforcer,\n };\n};\n\n/**\n * Builds the canonical set of permission matching rules for a chain.\n *\n * Each rule specifies the `permissionType`, the set of `requiredEnforcers`\n * that must be present, and the set of `optionalEnforcers` that may appear in\n * addition to the required set.\n *\n * @param contracts - The deployed contracts for the chain.\n * @returns A list of permission rules used to identify permission types.\n * @throws Propagates any errors from resolving enforcer addresses.\n */\nexport const createPermissionRulesForChainId: (\n contracts: DeployedContractsByName,\n) => PermissionRule[] = (contracts: DeployedContractsByName) => {\n const {\n erc20StreamingEnforcer,\n erc20PeriodicEnforcer,\n nativeTokenStreamingEnforcer,\n nativeTokenPeriodicEnforcer,\n exactCalldataEnforcer,\n valueLteEnforcer,\n timestampEnforcer,\n nonceEnforcer,\n allowedCalldataEnforcer,\n } = getChecksumEnforcersByChainId(contracts);\n\n // the optional enforcers are the same for all permission types\n const optionalEnforcers = new Set<Hex>([timestampEnforcer]);\n\n const permissionRules: PermissionRule[] = [\n {\n requiredEnforcers: new Map<Hex, number>([\n [nativeTokenStreamingEnforcer, 1],\n [exactCalldataEnforcer, 1],\n [nonceEnforcer, 1],\n ]),\n optionalEnforcers,\n permissionType: 'native-token-stream',\n },\n {\n requiredEnforcers: new Map<Hex, number>([\n [nativeTokenPeriodicEnforcer, 1],\n [exactCalldataEnforcer, 1],\n [nonceEnforcer, 1],\n ]),\n optionalEnforcers,\n permissionType: 'native-token-periodic',\n },\n {\n requiredEnforcers: new Map<Hex, number>([\n [erc20StreamingEnforcer, 1],\n [valueLteEnforcer, 1],\n [nonceEnforcer, 1],\n ]),\n optionalEnforcers,\n permissionType: 'erc20-token-stream',\n },\n {\n requiredEnforcers: new Map<Hex, number>([\n [erc20PeriodicEnforcer, 1],\n [valueLteEnforcer, 1],\n [nonceEnforcer, 1],\n ]),\n optionalEnforcers,\n permissionType: 'erc20-token-periodic',\n },\n {\n requiredEnforcers: new Map<Hex, number>([\n [allowedCalldataEnforcer, 2],\n [valueLteEnforcer, 1],\n [nonceEnforcer, 1],\n ]),\n optionalEnforcers,\n permissionType: 'erc20-token-revocation',\n },\n ];\n\n return permissionRules;\n};\n\n/**\n * Determines whether all elements of `subset` are contained within `superset`.\n *\n * @param subset - The candidate subset to test.\n * @param superset - The set expected to contain all elements of `subset`.\n * @returns `true` if `subset` ⊆ `superset`, otherwise `false`.\n */\nexport const isSubset = <T>(subset: Set<T>, superset: Set<T>): boolean => {\n for (const x of subset) {\n if (!superset.has(x)) {\n return false;\n }\n }\n return true;\n};\n\n/**\n * Gets the terms for a given enforcer from a list of caveats.\n *\n * @param args - The arguments to this function.\n * @param args.throwIfNotFound - Whether to throw an error if no matching enforcer is found. Default is true.\n * @param args.caveats - The list of caveats to search.\n * @param args.enforcer - The enforcer to search for.\n * @returns The terms for the given enforcer.\n */\nexport function getTermsByEnforcer<TThrowIfNotFound extends boolean = true>({\n caveats,\n enforcer,\n throwIfNotFound,\n}: {\n caveats: Caveat<Hex>[];\n enforcer: Hex;\n throwIfNotFound?: TThrowIfNotFound;\n}): TThrowIfNotFound extends true ? Hex : Hex | null {\n const matchingCaveats = caveats.filter(\n (caveat) => caveat.enforcer === enforcer,\n );\n\n if (matchingCaveats.length === 0) {\n if (throwIfNotFound ?? true) {\n throw new Error('Invalid caveats');\n }\n return null as TThrowIfNotFound extends true ? Hex : Hex | null;\n }\n\n if (matchingCaveats.length > 1) {\n throw new Error('Invalid caveats');\n }\n\n return matchingCaveats[0].terms;\n}\n\n/**\n * Splits a 0x-prefixed hex string into parts according to the provided byte lengths.\n *\n * Each entry in `lengths` represents a part length in bytes; internally this is\n * multiplied by 2 to derive the number of hexadecimal characters to slice. The\n * returned substrings do not include the `0x` prefix and preserve leading zeros.\n *\n * Note: This function does not perform input validation (e.g., verifying the\n * payload length equals the sum of requested lengths). Callers are expected to\n * provide well-formed inputs.\n *\n * Example:\n * splitHex('0x12345678', [1, 3]) => ['0x12', '0x345678']\n *\n * @param value - The 0x-prefixed hex string to split.\n * @param lengths - The lengths of each part, in bytes.\n * @returns An array of hex substrings (each with `0x` prefix), one for each part.\n */\nexport function splitHex(value: Hex, lengths: number[]): Hex[] {\n let start = 2;\n const parts: Hex[] = [];\n for (const partLength of lengths) {\n const partCharLength = partLength * 2;\n const part = value.slice(start, start + partCharLength);\n start += partCharLength;\n parts.push(`0x${part}` as const);\n }\n return parts;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"utils.mjs","sourceRoot":"","sources":["../../src/decodePermission/utils.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,kBAAkB,EAAE,wBAAwB;AAcrD;;GAEG;AACH,MAAM,uBAAuB,GAAG;IAC9B,2BAA2B,EAAE,6BAA6B;IAC1D,sBAAsB,EAAE,wBAAwB;IAChD,qBAAqB,EAAE,uBAAuB;IAC9C,iCAAiC,EAAE,mCAAmC;IACtE,4BAA4B,EAAE,8BAA8B;IAC5D,iBAAiB,EAAE,mBAAmB;IACtC,gBAAgB,EAAE,kBAAkB;IACpC,aAAa,EAAE,eAAe;IAC9B,uBAAuB,EAAE,yBAAyB;CACnD,CAAC;AAEF;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,6BAA6B,GAAG,CAC3C,SAAkC,EAWlC,EAAE;IACF,MAAM,0BAA0B,GAAG,CAAC,YAAoB,EAAO,EAAE;QAC/D,MAAM,OAAO,GAAG,SAAS,CAAC,YAAY,CAAC,CAAC;QAExC,IAAI,CAAC,OAAO,EAAE,CAAC;YACb,MAAM,IAAI,KAAK,CAAC,uBAAuB,YAAY,EAAE,CAAC,CAAC;QACzD,CAAC;QAED,OAAO,kBAAkB,CAAC,OAAO,CAAC,CAAC;IACrC,CAAC,CAAC;IAEF,qCAAqC;IACrC,MAAM,sBAAsB,GAAG,0BAA0B,CACvD,uBAAuB,CAAC,sBAAsB,CAC/C,CAAC;IACF,MAAM,qBAAqB,GAAG,0BAA0B,CACtD,uBAAuB,CAAC,2BAA2B,CACpD,CAAC;IACF,MAAM,4BAA4B,GAAG,0BAA0B,CAC7D,uBAAuB,CAAC,4BAA4B,CACrD,CAA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AC;AAEF;;;;;;;;GAQG;AACH,MAAM,UAAU,kBAAkB,CAA0C,EAC1E,OAAO,EACP,QAAQ,EACR,eAAe,GAKhB;IACC,MAAM,eAAe,GAAG,OAAO,CAAC,MAAM,CACpC,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,QAAQ,KAAK,QAAQ,CACzC,CAAC;IAEF,IAAI,eAAe,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACjC,IAAI,eAAe,IAAI,IAAI,EAAE,CAAC;YAC5B,MAAM,IAAI,KAAK,CAAC,iBAAiB,CAAC,CAAC;QACrC,CAAC;QACD,OAAO,IAAwD,CAAC;IAClE,CAAC;IAED,IAAI,eAAe,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QAC/B,MAAM,IAAI,KAAK,CAAC,iBAAiB,CAAC,CAAC;IACrC,CAAC;IAED,OAAO,eAAe,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC;AAClC,CAAC;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,UAAU,QAAQ,CAAC,KAAU,EAAE,OAAiB;IACpD,IAAI,KAAK,GAAG,CAAC,CAAC;IACd,MAAM,KAAK,GAAU,EAAE,CAAC;IACxB,KAAK,MAAM,UAAU,IAAI,OAAO,EAAE,CAAC;QACjC,MAAM,cAAc,GAAG,UAAU,GAAG,CAAC,CAAC;QACtC,MAAM,IAAI,GAAG,KAAK,CAAC,KAAK,CAAC,KAAK,EAAE,KAAK,GAAG,cAAc,CAAC,CAAC;QACxD,KAAK,IAAI,cAAc,CAAC;QACxB,KAAK,CAAC,IAAI,CAAC,KAAK,IAAI,EAAW,CAAC,CAAC;IACnC,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC","sourcesContent":["import type { Caveat } from '@metamask/delegation-core';\nimport { getChecksumAddress } from '@metamask/utils';\nimport type { Hex } from '@metamask/utils';\n\nimport type { DeployedContractsByName, PermissionType } from './types';\n\n/**\n * A rule that defines the required and allowed enforcers for a permission type.\n */\nexport type PermissionRule = {\n permissionType: PermissionType;\n requiredEnforcers: Map<Hex, number>;\n optionalEnforcers: Set<Hex>;\n};\n\n/**\n * The names of the enforcer contracts for each permission type.\n */\nconst ENFORCER_CONTRACT_NAMES = {\n ERC20PeriodTransferEnforcer: 'ERC20PeriodTransferEnforcer',\n ERC20StreamingEnforcer: 'ERC20StreamingEnforcer',\n ExactCalldataEnforcer: 'ExactCalldataEnforcer',\n NativeTokenPeriodTransferEnforcer: 'NativeTokenPeriodTransferEnforcer',\n NativeTokenStreamingEnforcer: 'NativeTokenStreamingEnforcer',\n TimestampEnforcer: 'TimestampEnforcer',\n ValueLteEnforcer: 'ValueLteEnforcer',\n NonceEnforcer: 'NonceEnforcer',\n AllowedCalldataEnforcer: 'AllowedCalldataEnforcer',\n};\n\n/**\n * Resolves and returns checksummed addresses of all known enforcer contracts\n * for a given `chainId` under the current delegation framework version.\n *\n * @param contracts - The deployed contracts for the chain.\n * @returns An object mapping enforcer names to checksummed contract addresses.\n * @throws If the chain or an expected enforcer contract is not found.\n */\nexport const getChecksumEnforcersByChainId = (\n contracts: DeployedContractsByName,\n): {\n erc20StreamingEnforcer: Hex;\n erc20PeriodicEnforcer: Hex;\n nativeTokenStreamingEnforcer: Hex;\n nativeTokenPeriodicEnforcer: Hex;\n exactCalldataEnforcer: Hex;\n valueLteEnforcer: Hex;\n timestampEnforcer: Hex;\n nonceEnforcer: Hex;\n allowedCalldataEnforcer: Hex;\n} => {\n const getChecksumContractAddress = (contractName: string): Hex => {\n const address = contracts[contractName];\n\n if (!address) {\n throw new Error(`Contract not found: ${contractName}`);\n }\n\n return getChecksumAddress(address);\n };\n\n // permission type specific enforcers\n const erc20StreamingEnforcer = getChecksumContractAddress(\n ENFORCER_CONTRACT_NAMES.ERC20StreamingEnforcer,\n );\n const erc20PeriodicEnforcer = getChecksumContractAddress(\n ENFORCER_CONTRACT_NAMES.ERC20PeriodTransferEnforcer,\n );\n const nativeTokenStreamingEnforcer = getChecksumContractAddress(\n ENFORCER_CONTRACT_NAMES.NativeTokenStreamingEnforcer,\n );\n const nativeTokenPeriodicEnforcer = getChecksumContractAddress(\n ENFORCER_CONTRACT_NAMES.NativeTokenPeriodTransferEnforcer,\n );\n\n // general enforcers\n const exactCalldataEnforcer = getChecksumContractAddress(\n ENFORCER_CONTRACT_NAMES.ExactCalldataEnforcer,\n );\n const valueLteEnforcer = getChecksumContractAddress(\n ENFORCER_CONTRACT_NAMES.ValueLteEnforcer,\n );\n const timestampEnforcer = getChecksumContractAddress(\n ENFORCER_CONTRACT_NAMES.TimestampEnforcer,\n );\n const nonceEnforcer = getChecksumContractAddress(\n ENFORCER_CONTRACT_NAMES.NonceEnforcer,\n );\n\n const allowedCalldataEnforcer = getChecksumContractAddress(\n ENFORCER_CONTRACT_NAMES.AllowedCalldataEnforcer,\n );\n\n return {\n erc20StreamingEnforcer,\n erc20PeriodicEnforcer,\n nativeTokenStreamingEnforcer,\n nativeTokenPeriodicEnforcer,\n exactCalldataEnforcer,\n valueLteEnforcer,\n timestampEnforcer,\n nonceEnforcer,\n allowedCalldataEnforcer,\n };\n};\n\n/**\n * Builds the canonical set of permission matching rules for a chain.\n *\n * Each rule specifies the `permissionType`, the set of `requiredEnforcers`\n * that must be present, and the set of `optionalEnforcers` that may appear in\n * addition to the required set.\n *\n * @param contracts - The deployed contracts for the chain.\n * @returns A list of permission rules used to identify permission types.\n * @throws Propagates any errors from resolving enforcer addresses.\n */\nexport const createPermissionRulesForChainId: (\n contracts: DeployedContractsByName,\n) => PermissionRule[] = (contracts: DeployedContractsByName) => {\n const {\n erc20StreamingEnforcer,\n erc20PeriodicEnforcer,\n nativeTokenStreamingEnforcer,\n nativeTokenPeriodicEnforcer,\n exactCalldataEnforcer,\n valueLteEnforcer,\n timestampEnforcer,\n nonceEnforcer,\n allowedCalldataEnforcer,\n } = getChecksumEnforcersByChainId(contracts);\n\n // the optional enforcers are the same for all permission types\n const optionalEnforcers = new Set<Hex>([timestampEnforcer]);\n\n const permissionRules: PermissionRule[] = [\n {\n requiredEnforcers: new Map<Hex, number>([\n [nativeTokenStreamingEnforcer, 1],\n [exactCalldataEnforcer, 1],\n [nonceEnforcer, 1],\n ]),\n optionalEnforcers,\n permissionType: 'native-token-stream',\n },\n {\n requiredEnforcers: new Map<Hex, number>([\n [nativeTokenPeriodicEnforcer, 1],\n [exactCalldataEnforcer, 1],\n [nonceEnforcer, 1],\n ]),\n optionalEnforcers,\n permissionType: 'native-token-periodic',\n },\n {\n requiredEnforcers: new Map<Hex, number>([\n [erc20StreamingEnforcer, 1],\n [valueLteEnforcer, 1],\n [nonceEnforcer, 1],\n ]),\n optionalEnforcers,\n permissionType: 'erc20-token-stream',\n },\n {\n requiredEnforcers: new Map<Hex, number>([\n [erc20PeriodicEnforcer, 1],\n [valueLteEnforcer, 1],\n [nonceEnforcer, 1],\n ]),\n optionalEnforcers,\n permissionType: 'erc20-token-periodic',\n },\n {\n requiredEnforcers: new Map<Hex, number>([\n [allowedCalldataEnforcer, 2],\n [valueLteEnforcer, 1],\n [nonceEnforcer, 1],\n ]),\n optionalEnforcers,\n permissionType: 'erc20-token-revocation',\n },\n ];\n\n return permissionRules;\n};\n\n/**\n * Determines whether all elements of `subset` are contained within `superset`.\n *\n * @param subset - The candidate subset to test.\n * @param superset - The set expected to contain all elements of `subset`.\n * @returns `true` if `subset` ⊆ `superset`, otherwise `false`.\n */\nexport const isSubset = <TElement>(\n subset: Set<TElement>,\n superset: Set<TElement>,\n): boolean => {\n for (const element of subset) {\n if (!superset.has(element)) {\n return false;\n }\n }\n return true;\n};\n\n/**\n * Gets the terms for a given enforcer from a list of caveats.\n *\n * @param args - The arguments to this function.\n * @param args.throwIfNotFound - Whether to throw an error if no matching enforcer is found. Default is true.\n * @param args.caveats - The list of caveats to search.\n * @param args.enforcer - The enforcer to search for.\n * @returns The terms for the given enforcer.\n */\nexport function getTermsByEnforcer<TThrowIfNotFound extends boolean = true>({\n caveats,\n enforcer,\n throwIfNotFound,\n}: {\n caveats: Caveat<Hex>[];\n enforcer: Hex;\n throwIfNotFound?: TThrowIfNotFound;\n}): TThrowIfNotFound extends true ? Hex : Hex | null {\n const matchingCaveats = caveats.filter(\n (caveat) => caveat.enforcer === enforcer,\n );\n\n if (matchingCaveats.length === 0) {\n if (throwIfNotFound ?? true) {\n throw new Error('Invalid caveats');\n }\n return null as TThrowIfNotFound extends true ? Hex : Hex | null;\n }\n\n if (matchingCaveats.length > 1) {\n throw new Error('Invalid caveats');\n }\n\n return matchingCaveats[0].terms;\n}\n\n/**\n * Splits a 0x-prefixed hex string into parts according to the provided byte lengths.\n *\n * Each entry in `lengths` represents a part length in bytes; internally this is\n * multiplied by 2 to derive the number of hexadecimal characters to slice. The\n * returned substrings do not include the `0x` prefix and preserve leading zeros.\n *\n * Note: This function does not perform input validation (e.g., verifying the\n * payload length equals the sum of requested lengths). Callers are expected to\n * provide well-formed inputs.\n *\n * Example:\n * splitHex('0x12345678', [1, 3]) => ['0x12', '0x345678']\n *\n * @param value - The 0x-prefixed hex string to split.\n * @param lengths - The lengths of each part, in bytes.\n * @returns An array of hex substrings (each with `0x` prefix), one for each part.\n */\nexport function splitHex(value: Hex, lengths: number[]): Hex[] {\n let start = 2;\n const parts: Hex[] = [];\n for (const partLength of lengths) {\n const partCharLength = partLength * 2;\n const part = value.slice(start, start + partCharLength);\n start += partCharLength;\n parts.push(`0x${part}` as const);\n }\n return parts;\n}\n"]}
|
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;AAAA,+EAAqF;AAA5E,yJAAA,OAAO,OAA8B;AAC9C,qCAGiB;AAFf,qHAAA,4BAA4B,OAAA;AAC5B,uHAAA,8BAA8B,OAAA;AAmBhC,6CAA2D;AAAlD,yHAAA,4BAA4B,OAAA","sourcesContent":["export { default as GatorPermissionsController } from './GatorPermissionsController';\nexport {\n serializeGatorPermissionsMap,\n deserializeGatorPermissionsMap,\n} from './utils';\nexport type {\n GatorPermissionsControllerState,\n GatorPermissionsControllerMessenger,\n GatorPermissionsControllerGetStateAction,\n GatorPermissionsControllerDecodePermissionFromPermissionContextForOriginAction,\n GatorPermissionsControllerFetchAndUpdateGatorPermissionsAction,\n GatorPermissionsControllerEnableGatorPermissionsAction,\n GatorPermissionsControllerDisableGatorPermissionsAction,\n GatorPermissionsControllerSubmitRevocationAction,\n GatorPermissionsControllerAddPendingRevocationAction,\n GatorPermissionsControllerSubmitDirectRevocationAction,\n GatorPermissionsControllerIsPendingRevocationAction,\n GatorPermissionsControllerActions,\n GatorPermissionsControllerEvents,\n GatorPermissionsControllerStateChangeEvent,\n} from './GatorPermissionsController';\nexport type { DecodedPermission } from './decodePermission';\nexport { DELEGATION_FRAMEWORK_VERSION } from './constants';\nexport type {\n GatorPermissionsControllerErrorCode,\n GatorPermissionsSnapRpcMethod,\n CustomPermission,\n PermissionTypesWithCustom,\n PermissionRequest,\n PermissionResponse,\n PermissionResponseSanitized,\n StoredGatorPermission,\n StoredGatorPermissionSanitized,\n GatorPermissionsMap,\n SupportedGatorPermissionType,\n GatorPermissionsMapByPermissionType,\n GatorPermissionsListByPermissionTypeAndChainId,\n DelegationDetails,\n RevocationParams,\n} from './types';\n\nexport type {\n NativeTokenStreamPermission,\n NativeTokenPeriodicPermission,\n Erc20TokenStreamPermission,\n Erc20TokenPeriodicPermission,\n MetaMaskBasePermissionData,\n} from '@metamask/7715-permission-types';\n"]}
|
|
1
|
+
{"version":3,"file":"index.cjs","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;AAAA,+EAAqF;AAA5E,yJAAA,OAAO,OAA8B;AAC9C,qCAGiB;AAFf,qHAAA,4BAA4B,OAAA;AAC5B,uHAAA,8BAA8B,OAAA;AAmBhC,6CAA2D;AAAlD,yHAAA,4BAA4B,OAAA","sourcesContent":["export { default as GatorPermissionsController } from './GatorPermissionsController';\nexport {\n serializeGatorPermissionsMap,\n deserializeGatorPermissionsMap,\n} from './utils';\nexport type {\n GatorPermissionsControllerState,\n GatorPermissionsControllerMessenger,\n GatorPermissionsControllerGetStateAction,\n GatorPermissionsControllerDecodePermissionFromPermissionContextForOriginAction,\n GatorPermissionsControllerFetchAndUpdateGatorPermissionsAction,\n GatorPermissionsControllerEnableGatorPermissionsAction,\n GatorPermissionsControllerDisableGatorPermissionsAction,\n GatorPermissionsControllerSubmitRevocationAction,\n GatorPermissionsControllerAddPendingRevocationAction,\n GatorPermissionsControllerSubmitDirectRevocationAction,\n GatorPermissionsControllerIsPendingRevocationAction,\n GatorPermissionsControllerActions,\n GatorPermissionsControllerEvents,\n GatorPermissionsControllerStateChangeEvent,\n} from './GatorPermissionsController';\nexport type { DecodedPermission } from './decodePermission';\nexport { DELEGATION_FRAMEWORK_VERSION } from './constants';\nexport type {\n GatorPermissionsControllerErrorCode,\n GatorPermissionsSnapRpcMethod,\n CustomPermission,\n PermissionTypesWithCustom,\n PermissionRequest,\n PermissionResponse,\n PermissionResponseSanitized,\n StoredGatorPermission,\n StoredGatorPermissionSanitized,\n GatorPermissionsMap,\n SupportedGatorPermissionType,\n GatorPermissionsMapByPermissionType,\n GatorPermissionsListByPermissionTypeAndChainId,\n DelegationDetails,\n RevocationParams,\n RevocationMetadata,\n} from './types';\n\nexport type {\n NativeTokenStreamPermission,\n NativeTokenPeriodicPermission,\n Erc20TokenStreamPermission,\n Erc20TokenPeriodicPermission,\n MetaMaskBasePermissionData,\n} from '@metamask/7715-permission-types';\n"]}
|
package/dist/index.d.cts
CHANGED
|
@@ -3,6 +3,6 @@ export { serializeGatorPermissionsMap, deserializeGatorPermissionsMap, } from ".
|
|
|
3
3
|
export type { GatorPermissionsControllerState, GatorPermissionsControllerMessenger, GatorPermissionsControllerGetStateAction, GatorPermissionsControllerDecodePermissionFromPermissionContextForOriginAction, GatorPermissionsControllerFetchAndUpdateGatorPermissionsAction, GatorPermissionsControllerEnableGatorPermissionsAction, GatorPermissionsControllerDisableGatorPermissionsAction, GatorPermissionsControllerSubmitRevocationAction, GatorPermissionsControllerAddPendingRevocationAction, GatorPermissionsControllerSubmitDirectRevocationAction, GatorPermissionsControllerIsPendingRevocationAction, GatorPermissionsControllerActions, GatorPermissionsControllerEvents, GatorPermissionsControllerStateChangeEvent, } from "./GatorPermissionsController.cjs";
|
|
4
4
|
export type { DecodedPermission } from "./decodePermission/index.cjs";
|
|
5
5
|
export { DELEGATION_FRAMEWORK_VERSION } from "./constants.cjs";
|
|
6
|
-
export type { GatorPermissionsControllerErrorCode, GatorPermissionsSnapRpcMethod, CustomPermission, PermissionTypesWithCustom, PermissionRequest, PermissionResponse, PermissionResponseSanitized, StoredGatorPermission, StoredGatorPermissionSanitized, GatorPermissionsMap, SupportedGatorPermissionType, GatorPermissionsMapByPermissionType, GatorPermissionsListByPermissionTypeAndChainId, DelegationDetails, RevocationParams, } from "./types.cjs";
|
|
6
|
+
export type { GatorPermissionsControllerErrorCode, GatorPermissionsSnapRpcMethod, CustomPermission, PermissionTypesWithCustom, PermissionRequest, PermissionResponse, PermissionResponseSanitized, StoredGatorPermission, StoredGatorPermissionSanitized, GatorPermissionsMap, SupportedGatorPermissionType, GatorPermissionsMapByPermissionType, GatorPermissionsListByPermissionTypeAndChainId, DelegationDetails, RevocationParams, RevocationMetadata, } from "./types.cjs";
|
|
7
7
|
export type { NativeTokenStreamPermission, NativeTokenPeriodicPermission, Erc20TokenStreamPermission, Erc20TokenPeriodicPermission, MetaMaskBasePermissionData, } from "@metamask/7715-permission-types";
|
|
8
8
|
//# sourceMappingURL=index.d.cts.map
|
package/dist/index.d.cts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.cts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,0BAA0B,EAAE,yCAAqC;AACrF,OAAO,EACL,4BAA4B,EAC5B,8BAA8B,GAC/B,oBAAgB;AACjB,YAAY,EACV,+BAA+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C9C,iBAAiB,EACjB,gBAAgB,EAChB,kBAAkB,GACnB,oBAAgB;AAEjB,YAAY,EACV,2BAA2B,EAC3B,6BAA6B,EAC7B,0BAA0B,EAC1B,4BAA4B,EAC5B,0BAA0B,GAC3B,wCAAwC"}
|
package/dist/index.d.mts
CHANGED
|
@@ -3,6 +3,6 @@ export { serializeGatorPermissionsMap, deserializeGatorPermissionsMap, } from ".
|
|
|
3
3
|
export type { GatorPermissionsControllerState, GatorPermissionsControllerMessenger, GatorPermissionsControllerGetStateAction, GatorPermissionsControllerDecodePermissionFromPermissionContextForOriginAction, GatorPermissionsControllerFetchAndUpdateGatorPermissionsAction, GatorPermissionsControllerEnableGatorPermissionsAction, GatorPermissionsControllerDisableGatorPermissionsAction, GatorPermissionsControllerSubmitRevocationAction, GatorPermissionsControllerAddPendingRevocationAction, GatorPermissionsControllerSubmitDirectRevocationAction, GatorPermissionsControllerIsPendingRevocationAction, GatorPermissionsControllerActions, GatorPermissionsControllerEvents, GatorPermissionsControllerStateChangeEvent, } from "./GatorPermissionsController.mjs";
|
|
4
4
|
export type { DecodedPermission } from "./decodePermission/index.mjs";
|
|
5
5
|
export { DELEGATION_FRAMEWORK_VERSION } from "./constants.mjs";
|
|
6
|
-
export type { GatorPermissionsControllerErrorCode, GatorPermissionsSnapRpcMethod, CustomPermission, PermissionTypesWithCustom, PermissionRequest, PermissionResponse, PermissionResponseSanitized, StoredGatorPermission, StoredGatorPermissionSanitized, GatorPermissionsMap, SupportedGatorPermissionType, GatorPermissionsMapByPermissionType, GatorPermissionsListByPermissionTypeAndChainId, DelegationDetails, RevocationParams, } from "./types.mjs";
|
|
6
|
+
export type { GatorPermissionsControllerErrorCode, GatorPermissionsSnapRpcMethod, CustomPermission, PermissionTypesWithCustom, PermissionRequest, PermissionResponse, PermissionResponseSanitized, StoredGatorPermission, StoredGatorPermissionSanitized, GatorPermissionsMap, SupportedGatorPermissionType, GatorPermissionsMapByPermissionType, GatorPermissionsListByPermissionTypeAndChainId, DelegationDetails, RevocationParams, RevocationMetadata, } from "./types.mjs";
|
|
7
7
|
export type { NativeTokenStreamPermission, NativeTokenPeriodicPermission, Erc20TokenStreamPermission, Erc20TokenPeriodicPermission, MetaMaskBasePermissionData, } from "@metamask/7715-permission-types";
|
|
8
8
|
//# sourceMappingURL=index.d.mts.map
|
package/dist/index.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.mts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,0BAA0B,EAAE,yCAAqC;AACrF,OAAO,EACL,4BAA4B,EAC5B,8BAA8B,GAC/B,oBAAgB;AACjB,YAAY,EACV,+BAA+B,EAC/B,mCAAmC,EACnC,wCAAwC,EACxC,8EAA8E,EAC9E,8DAA8D,EAC9D,sDAAsD,EACtD,uDAAuD,EACvD,gDAAgD,EAChD,oDAAoD,EACpD,sDAAsD,EACtD,mDAAmD,EACnD,iCAAiC,EACjC,gCAAgC,EAChC,0CAA0C,GAC3C,yCAAqC;AACtC,YAAY,EAAE,iBAAiB,EAAE,qCAA2B;AAC5D,OAAO,EAAE,4BAA4B,EAAE,wBAAoB;AAC3D,YAAY,EACV,mCAAmC,EACnC,6BAA6B,EAC7B,gBAAgB,EAChB,yBAAyB,EACzB,iBAAiB,EACjB,kBAAkB,EAClB,2BAA2B,EAC3B,qBAAqB,EACrB,8BAA8B,EAC9B,mBAAmB,EACnB,4BAA4B,EAC5B,mCAAmC,EACnC,8CAA8C,EAC9C,iBAAiB,EACjB,gBAAgB,
|
|
1
|
+
{"version":3,"file":"index.d.mts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,0BAA0B,EAAE,yCAAqC;AACrF,OAAO,EACL,4BAA4B,EAC5B,8BAA8B,GAC/B,oBAAgB;AACjB,YAAY,EACV,+BAA+B,EAC/B,mCAAmC,EACnC,wCAAwC,EACxC,8EAA8E,EAC9E,8DAA8D,EAC9D,sDAAsD,EACtD,uDAAuD,EACvD,gDAAgD,EAChD,oDAAoD,EACpD,sDAAsD,EACtD,mDAAmD,EACnD,iCAAiC,EACjC,gCAAgC,EAChC,0CAA0C,GAC3C,yCAAqC;AACtC,YAAY,EAAE,iBAAiB,EAAE,qCAA2B;AAC5D,OAAO,EAAE,4BAA4B,EAAE,wBAAoB;AAC3D,YAAY,EACV,mCAAmC,EACnC,6BAA6B,EAC7B,gBAAgB,EAChB,yBAAyB,EACzB,iBAAiB,EACjB,kBAAkB,EAClB,2BAA2B,EAC3B,qBAAqB,EACrB,8BAA8B,EAC9B,mBAAmB,EACnB,4BAA4B,EAC5B,mCAAmC,EACnC,8CAA8C,EAC9C,iBAAiB,EACjB,gBAAgB,EAChB,kBAAkB,GACnB,oBAAgB;AAEjB,YAAY,EACV,2BAA2B,EAC3B,6BAA6B,EAC7B,0BAA0B,EAC1B,4BAA4B,EAC5B,0BAA0B,GAC3B,wCAAwC"}
|
package/dist/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,0BAA0B,EAAE,yCAAqC;AACrF,OAAO,EACL,4BAA4B,EAC5B,8BAA8B,EAC/B,oBAAgB;AAkBjB,OAAO,EAAE,4BAA4B,EAAE,wBAAoB","sourcesContent":["export { default as GatorPermissionsController } from './GatorPermissionsController';\nexport {\n serializeGatorPermissionsMap,\n deserializeGatorPermissionsMap,\n} from './utils';\nexport type {\n GatorPermissionsControllerState,\n GatorPermissionsControllerMessenger,\n GatorPermissionsControllerGetStateAction,\n GatorPermissionsControllerDecodePermissionFromPermissionContextForOriginAction,\n GatorPermissionsControllerFetchAndUpdateGatorPermissionsAction,\n GatorPermissionsControllerEnableGatorPermissionsAction,\n GatorPermissionsControllerDisableGatorPermissionsAction,\n GatorPermissionsControllerSubmitRevocationAction,\n GatorPermissionsControllerAddPendingRevocationAction,\n GatorPermissionsControllerSubmitDirectRevocationAction,\n GatorPermissionsControllerIsPendingRevocationAction,\n GatorPermissionsControllerActions,\n GatorPermissionsControllerEvents,\n GatorPermissionsControllerStateChangeEvent,\n} from './GatorPermissionsController';\nexport type { DecodedPermission } from './decodePermission';\nexport { DELEGATION_FRAMEWORK_VERSION } from './constants';\nexport type {\n GatorPermissionsControllerErrorCode,\n GatorPermissionsSnapRpcMethod,\n CustomPermission,\n PermissionTypesWithCustom,\n PermissionRequest,\n PermissionResponse,\n PermissionResponseSanitized,\n StoredGatorPermission,\n StoredGatorPermissionSanitized,\n GatorPermissionsMap,\n SupportedGatorPermissionType,\n GatorPermissionsMapByPermissionType,\n GatorPermissionsListByPermissionTypeAndChainId,\n DelegationDetails,\n RevocationParams,\n} from './types';\n\nexport type {\n NativeTokenStreamPermission,\n NativeTokenPeriodicPermission,\n Erc20TokenStreamPermission,\n Erc20TokenPeriodicPermission,\n MetaMaskBasePermissionData,\n} from '@metamask/7715-permission-types';\n"]}
|
|
1
|
+
{"version":3,"file":"index.mjs","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,0BAA0B,EAAE,yCAAqC;AACrF,OAAO,EACL,4BAA4B,EAC5B,8BAA8B,EAC/B,oBAAgB;AAkBjB,OAAO,EAAE,4BAA4B,EAAE,wBAAoB","sourcesContent":["export { default as GatorPermissionsController } from './GatorPermissionsController';\nexport {\n serializeGatorPermissionsMap,\n deserializeGatorPermissionsMap,\n} from './utils';\nexport type {\n GatorPermissionsControllerState,\n GatorPermissionsControllerMessenger,\n GatorPermissionsControllerGetStateAction,\n GatorPermissionsControllerDecodePermissionFromPermissionContextForOriginAction,\n GatorPermissionsControllerFetchAndUpdateGatorPermissionsAction,\n GatorPermissionsControllerEnableGatorPermissionsAction,\n GatorPermissionsControllerDisableGatorPermissionsAction,\n GatorPermissionsControllerSubmitRevocationAction,\n GatorPermissionsControllerAddPendingRevocationAction,\n GatorPermissionsControllerSubmitDirectRevocationAction,\n GatorPermissionsControllerIsPendingRevocationAction,\n GatorPermissionsControllerActions,\n GatorPermissionsControllerEvents,\n GatorPermissionsControllerStateChangeEvent,\n} from './GatorPermissionsController';\nexport type { DecodedPermission } from './decodePermission';\nexport { DELEGATION_FRAMEWORK_VERSION } from './constants';\nexport type {\n GatorPermissionsControllerErrorCode,\n GatorPermissionsSnapRpcMethod,\n CustomPermission,\n PermissionTypesWithCustom,\n PermissionRequest,\n PermissionResponse,\n PermissionResponseSanitized,\n StoredGatorPermission,\n StoredGatorPermissionSanitized,\n GatorPermissionsMap,\n SupportedGatorPermissionType,\n GatorPermissionsMapByPermissionType,\n GatorPermissionsListByPermissionTypeAndChainId,\n DelegationDetails,\n RevocationParams,\n RevocationMetadata,\n} from './types';\n\nexport type {\n NativeTokenStreamPermission,\n NativeTokenPeriodicPermission,\n Erc20TokenStreamPermission,\n Erc20TokenPeriodicPermission,\n MetaMaskBasePermissionData,\n} from '@metamask/7715-permission-types';\n"]}
|
package/dist/types.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.cjs","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":";;;AAcA;;GAEG;AACH,IAAY,mCAOX;AAPD,WAAY,mCAAmC;IAC7C,mGAA4D,CAAA;IAC5D,mGAA4D,CAAA;IAC5D,yGAAkE,CAAA;IAClE,0HAAmF,CAAA;IACnF,4FAAqD,CAAA;IACrD,yFAAkD,CAAA;AACpD,CAAC,EAPW,mCAAmC,mDAAnC,mCAAmC,QAO9C;AAED;;GAEG;AACH,IAAY,6BASX;AATD,WAAY,6BAA6B;IACvC;;OAEG;IACH,sHAAqF,CAAA;IACrF;;OAEG;IACH,4GAA2E,CAAA;AAC7E,CAAC,EATW,6BAA6B,6CAA7B,6BAA6B,QASxC","sourcesContent":["import type {\n PermissionTypes,\n BasePermission,\n NativeTokenStreamPermission,\n NativeTokenPeriodicPermission,\n Erc20TokenStreamPermission,\n Erc20TokenPeriodicPermission,\n Rule,\n MetaMaskBasePermissionData,\n Erc20TokenRevocationPermission,\n} from '@metamask/7715-permission-types';\nimport type { Delegation } from '@metamask/delegation-core';\nimport type { Hex } from '@metamask/utils';\n\n/**\n * Enum for the error codes of the gator permissions controller.\n */\nexport enum GatorPermissionsControllerErrorCode {\n GatorPermissionsFetchError = 'gator-permissions-fetch-error',\n GatorPermissionsNotEnabled = 'gator-permissions-not-enabled',\n GatorPermissionsProviderError = 'gator-permissions-provider-error',\n GatorPermissionsMapSerializationError = 'gator-permissions-map-serialization-error',\n PermissionDecodingError = 'permission-decoding-error',\n OriginNotAllowedError = 'origin-not-allowed-error',\n}\n\n/**\n * Enum for the RPC methods of the gator permissions provider snap.\n */\nexport enum GatorPermissionsSnapRpcMethod {\n /**\n * This method is used by the metamask to request a permissions provider to get granted permissions for all sites.\n */\n PermissionProviderGetGrantedPermissions = 'permissionsProvider_getGrantedPermissions',\n /**\n * This method is used by the metamask to submit a revocation to the permissions provider.\n */\n PermissionProviderSubmitRevocation = 'permissionsProvider_submitRevocation',\n}\n\n/**\n * Represents a custom permission that are not of the standard ERC-7715 permission types.\n */\nexport type CustomPermission = BasePermission & {\n type: 'custom';\n data: MetaMaskBasePermissionData & Record<string, unknown>;\n};\n\n/**\n * Represents the type of the ERC-7715 permissions that can be granted including custom permissions.\n */\nexport type PermissionTypesWithCustom = PermissionTypes | CustomPermission;\n\n/**\n * Represents a ERC-7715 permission request.\n *\n * @template to - The type of the signer provided, either an AccountSigner or WalletSigner.\n * @template Permission - The type of the permission provided.\n */\nexport type PermissionRequest<TPermission extends PermissionTypesWithCustom> = {\n /**\n * hex-encoding of uint256 defined the chain with EIP-155\n */\n chainId: Hex;\n\n /**\n *\n * The account being targeted for this permission request.\n * It is optional to let the user choose which account to grant permission from.\n */\n from?: Hex;\n\n /**\n * A field that identifies the DApp session account associated with the permission\n */\n to: Hex;\n\n /**\n * Defines the allowed behavior the `to` account can do on behalf of the `from` account.\n */\n permission: TPermission;\n\n rules?: Rule[] | null;\n};\n\n/**\n * Represents a ERC-7715 permission response.\n *\n * @template Permission - The type of the permission provided.\n */\nexport type PermissionResponse<TPermission extends PermissionTypesWithCustom> =\n PermissionRequest<TPermission> & {\n /**\n * Is a catch-all to identify a permission for revoking permissions or submitting\n * Defined in ERC-7710.\n */\n context: Hex;\n\n /**\n * The dependencyInfo field is required and contains information needed to deploy accounts.\n * Each entry specifies a factory contract and its associated deployment data.\n * If no account deployment is needed when redeeming the permission, this array must be empty.\n * When non-empty, DApps MUST deploy the accounts by calling the factory contract with factoryData as the calldata.\n * Defined in ERC-4337.\n */\n dependencies: {\n factory: Hex;\n factoryData: Hex;\n }[];\n\n /**\n * Is required as defined in ERC-7710.\n */\n delegationManager: Hex;\n };\n\n/**\n * Represents a sanitized version of the PermissionResponse type.\n * Internal fields (dependencies, to) are removed\n *\n * @template Permission - The type of the permission provided.\n */\nexport type PermissionResponseSanitized<\n TPermission extends PermissionTypesWithCustom,\n> = Omit<PermissionResponse<TPermission>, 'dependencies' | 'to'>;\n\n/**\n * Represents a gator ERC-7715 granted(ie. signed by
|
|
1
|
+
{"version":3,"file":"types.cjs","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":";;;AAcA;;GAEG;AACH,IAAY,mCAOX;AAPD,WAAY,mCAAmC;IAC7C,mGAA4D,CAAA;IAC5D,mGAA4D,CAAA;IAC5D,yGAAkE,CAAA;IAClE,0HAAmF,CAAA;IACnF,4FAAqD,CAAA;IACrD,yFAAkD,CAAA;AACpD,CAAC,EAPW,mCAAmC,mDAAnC,mCAAmC,QAO9C;AAED;;GAEG;AACH,IAAY,6BASX;AATD,WAAY,6BAA6B;IACvC;;OAEG;IACH,sHAAqF,CAAA;IACrF;;OAEG;IACH,4GAA2E,CAAA;AAC7E,CAAC,EATW,6BAA6B,6CAA7B,6BAA6B,QASxC","sourcesContent":["import type {\n PermissionTypes,\n BasePermission,\n NativeTokenStreamPermission,\n NativeTokenPeriodicPermission,\n Erc20TokenStreamPermission,\n Erc20TokenPeriodicPermission,\n Rule,\n MetaMaskBasePermissionData,\n Erc20TokenRevocationPermission,\n} from '@metamask/7715-permission-types';\nimport type { Delegation } from '@metamask/delegation-core';\nimport type { Hex } from '@metamask/utils';\n\n/**\n * Enum for the error codes of the gator permissions controller.\n */\nexport enum GatorPermissionsControllerErrorCode {\n GatorPermissionsFetchError = 'gator-permissions-fetch-error',\n GatorPermissionsNotEnabled = 'gator-permissions-not-enabled',\n GatorPermissionsProviderError = 'gator-permissions-provider-error',\n GatorPermissionsMapSerializationError = 'gator-permissions-map-serialization-error',\n PermissionDecodingError = 'permission-decoding-error',\n OriginNotAllowedError = 'origin-not-allowed-error',\n}\n\n/**\n * Enum for the RPC methods of the gator permissions provider snap.\n */\nexport enum GatorPermissionsSnapRpcMethod {\n /**\n * This method is used by the metamask to request a permissions provider to get granted permissions for all sites.\n */\n PermissionProviderGetGrantedPermissions = 'permissionsProvider_getGrantedPermissions',\n /**\n * This method is used by the metamask to submit a revocation to the permissions provider.\n */\n PermissionProviderSubmitRevocation = 'permissionsProvider_submitRevocation',\n}\n\n/**\n * Represents a custom permission that are not of the standard ERC-7715 permission types.\n */\nexport type CustomPermission = BasePermission & {\n type: 'custom';\n data: MetaMaskBasePermissionData & Record<string, unknown>;\n};\n\n/**\n * Represents the type of the ERC-7715 permissions that can be granted including custom permissions.\n */\nexport type PermissionTypesWithCustom = PermissionTypes | CustomPermission;\n\n/**\n * Represents a ERC-7715 permission request.\n *\n * @template to - The type of the signer provided, either an AccountSigner or WalletSigner.\n * @template Permission - The type of the permission provided.\n */\nexport type PermissionRequest<TPermission extends PermissionTypesWithCustom> = {\n /**\n * hex-encoding of uint256 defined the chain with EIP-155\n */\n chainId: Hex;\n\n /**\n *\n * The account being targeted for this permission request.\n * It is optional to let the user choose which account to grant permission from.\n */\n from?: Hex;\n\n /**\n * A field that identifies the DApp session account associated with the permission\n */\n to: Hex;\n\n /**\n * Defines the allowed behavior the `to` account can do on behalf of the `from` account.\n */\n permission: TPermission;\n\n rules?: Rule[] | null;\n};\n\n/**\n * Represents a ERC-7715 permission response.\n *\n * @template Permission - The type of the permission provided.\n */\nexport type PermissionResponse<TPermission extends PermissionTypesWithCustom> =\n PermissionRequest<TPermission> & {\n /**\n * Is a catch-all to identify a permission for revoking permissions or submitting\n * Defined in ERC-7710.\n */\n context: Hex;\n\n /**\n * The dependencyInfo field is required and contains information needed to deploy accounts.\n * Each entry specifies a factory contract and its associated deployment data.\n * If no account deployment is needed when redeeming the permission, this array must be empty.\n * When non-empty, DApps MUST deploy the accounts by calling the factory contract with factoryData as the calldata.\n * Defined in ERC-4337.\n */\n dependencies: {\n factory: Hex;\n factoryData: Hex;\n }[];\n\n /**\n * Is required as defined in ERC-7710.\n */\n delegationManager: Hex;\n };\n\n/**\n * Represents a sanitized version of the PermissionResponse type.\n * Internal fields (dependencies, to) are removed\n *\n * @template Permission - The type of the permission provided.\n */\nexport type PermissionResponseSanitized<\n TPermission extends PermissionTypesWithCustom,\n> = Omit<PermissionResponse<TPermission>, 'dependencies' | 'to'>;\n\n/**\n * Represents a gator ERC-7715 granted(ie. signed by a user's account) permission entry that is stored in profile sync.\n *\n * @template Permission - The type of the permission provided\n */\nexport type StoredGatorPermission<\n TPermission extends PermissionTypesWithCustom,\n> = {\n permissionResponse: PermissionResponse<TPermission>;\n siteOrigin: string;\n revocationMetadata?: RevocationMetadata;\n};\n\n/**\n * Represents a sanitized version of the StoredGatorPermission type. Some fields have been removed but the fields are still present in profile sync.\n *\n * @template Permission - The type of the permission provided.\n */\nexport type StoredGatorPermissionSanitized<\n TPermission extends PermissionTypesWithCustom,\n> = {\n permissionResponse: PermissionResponseSanitized<TPermission>;\n siteOrigin: string;\n revocationMetadata?: RevocationMetadata;\n};\n\n/**\n * Represents a map of gator permissions by chainId and permission type.\n */\nexport type GatorPermissionsMap = {\n 'erc20-token-revocation': {\n [\n chainId: Hex\n ]: StoredGatorPermissionSanitized<Erc20TokenRevocationPermission>[];\n };\n 'native-token-stream': {\n [\n chainId: Hex\n ]: StoredGatorPermissionSanitized<NativeTokenStreamPermission>[];\n };\n 'native-token-periodic': {\n [\n chainId: Hex\n ]: StoredGatorPermissionSanitized<NativeTokenPeriodicPermission>[];\n };\n 'erc20-token-stream': {\n [\n chainId: Hex\n ]: StoredGatorPermissionSanitized<Erc20TokenStreamPermission>[];\n };\n 'erc20-token-periodic': {\n [\n chainId: Hex\n ]: StoredGatorPermissionSanitized<Erc20TokenPeriodicPermission>[];\n };\n other: {\n [chainId: Hex]: StoredGatorPermissionSanitized<CustomPermission>[];\n };\n};\n\n/**\n * Represents the supported permission type(e.g. 'native-token-stream', 'native-token-periodic', 'erc20-token-stream', 'erc20-token-periodic') of the gator permissions map.\n */\nexport type SupportedGatorPermissionType = keyof GatorPermissionsMap;\n\n/**\n * Represents a map of gator permissions for a given permission type with key of chainId. The value being an array of gator permissions for that chainId.\n */\nexport type GatorPermissionsMapByPermissionType<\n TPermissionType extends SupportedGatorPermissionType,\n> = GatorPermissionsMap[TPermissionType];\n\n/**\n * Represents an array of gator permissions for a given permission type and chainId.\n */\nexport type GatorPermissionsListByPermissionTypeAndChainId<\n TPermissionType extends SupportedGatorPermissionType,\n> = GatorPermissionsMap[TPermissionType][Hex];\n\n/**\n * Represents the details of a delegation, that are required to decode a permission.\n */\nexport type DelegationDetails = Pick<\n Delegation<Hex>,\n 'caveats' | 'delegator' | 'delegate' | 'authority'\n>;\n\n/**\n * Represents the metadata for confirmed transaction revocation.\n */\nexport type RevocationMetadata = {\n // The timestamp at which the revocation was recorded in storage.\n recordedAt: number;\n // The hash of the transaction that was used to revoke the permission. Optional because we might not have submitted the transaction ourselves.\n txHash?: Hex | undefined;\n};\n\n/**\n * Parameters for the `permissionsProvider_submitRevocation` method\n */\nexport type RevocationParams = {\n /**\n * The permission context as a hex string that identifies the permission to revoke.\n */\n permissionContext: Hex;\n\n /**\n * The hash of the transaction that was used to revoke the permission. Optional because we might not have submitted the transaction ourselves.\n */\n txHash: Hex | undefined;\n};\n\n/**\n * Represents the parameters for adding a pending revocation.\n */\nexport type PendingRevocationParams = {\n /**\n * The transaction metadata ID to monitor.\n */\n txId: string;\n /**\n * The permission context as a hex string that identifies the permission to revoke.\n */\n permissionContext: Hex;\n};\n"]}
|
package/dist/types.d.cts
CHANGED
|
@@ -98,17 +98,14 @@ export type PermissionResponse<TPermission extends PermissionTypesWithCustom> =
|
|
|
98
98
|
*/
|
|
99
99
|
export type PermissionResponseSanitized<TPermission extends PermissionTypesWithCustom> = Omit<PermissionResponse<TPermission>, 'dependencies' | 'to'>;
|
|
100
100
|
/**
|
|
101
|
-
* Represents a gator ERC-7715 granted(ie. signed by
|
|
101
|
+
* Represents a gator ERC-7715 granted(ie. signed by a user's account) permission entry that is stored in profile sync.
|
|
102
102
|
*
|
|
103
103
|
* @template Permission - The type of the permission provided
|
|
104
104
|
*/
|
|
105
105
|
export type StoredGatorPermission<TPermission extends PermissionTypesWithCustom> = {
|
|
106
106
|
permissionResponse: PermissionResponse<TPermission>;
|
|
107
107
|
siteOrigin: string;
|
|
108
|
-
|
|
109
|
-
* Flag indicating whether this permission has been revoked.
|
|
110
|
-
*/
|
|
111
|
-
isRevoked?: boolean;
|
|
108
|
+
revocationMetadata?: RevocationMetadata;
|
|
112
109
|
};
|
|
113
110
|
/**
|
|
114
111
|
* Represents a sanitized version of the StoredGatorPermission type. Some fields have been removed but the fields are still present in profile sync.
|
|
@@ -118,10 +115,7 @@ export type StoredGatorPermission<TPermission extends PermissionTypesWithCustom>
|
|
|
118
115
|
export type StoredGatorPermissionSanitized<TPermission extends PermissionTypesWithCustom> = {
|
|
119
116
|
permissionResponse: PermissionResponseSanitized<TPermission>;
|
|
120
117
|
siteOrigin: string;
|
|
121
|
-
|
|
122
|
-
* Flag indicating whether this permission has been revoked.
|
|
123
|
-
*/
|
|
124
|
-
isRevoked?: boolean;
|
|
118
|
+
revocationMetadata?: RevocationMetadata;
|
|
125
119
|
};
|
|
126
120
|
/**
|
|
127
121
|
* Represents a map of gator permissions by chainId and permission type.
|
|
@@ -163,13 +157,24 @@ export type GatorPermissionsListByPermissionTypeAndChainId<TPermissionType exten
|
|
|
163
157
|
*/
|
|
164
158
|
export type DelegationDetails = Pick<Delegation<Hex>, 'caveats' | 'delegator' | 'delegate' | 'authority'>;
|
|
165
159
|
/**
|
|
166
|
-
* Represents the
|
|
160
|
+
* Represents the metadata for confirmed transaction revocation.
|
|
161
|
+
*/
|
|
162
|
+
export type RevocationMetadata = {
|
|
163
|
+
recordedAt: number;
|
|
164
|
+
txHash?: Hex | undefined;
|
|
165
|
+
};
|
|
166
|
+
/**
|
|
167
|
+
* Parameters for the `permissionsProvider_submitRevocation` method
|
|
167
168
|
*/
|
|
168
169
|
export type RevocationParams = {
|
|
169
170
|
/**
|
|
170
171
|
* The permission context as a hex string that identifies the permission to revoke.
|
|
171
172
|
*/
|
|
172
173
|
permissionContext: Hex;
|
|
174
|
+
/**
|
|
175
|
+
* The hash of the transaction that was used to revoke the permission. Optional because we might not have submitted the transaction ourselves.
|
|
176
|
+
*/
|
|
177
|
+
txHash: Hex | undefined;
|
|
173
178
|
};
|
|
174
179
|
/**
|
|
175
180
|
* Represents the parameters for adding a pending revocation.
|
package/dist/types.d.cts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.cts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,eAAe,EACf,cAAc,EACd,2BAA2B,EAC3B,6BAA6B,EAC7B,0BAA0B,EAC1B,4BAA4B,EAC5B,IAAI,EACJ,0BAA0B,EAC1B,8BAA8B,EAC/B,wCAAwC;AACzC,OAAO,KAAK,EAAE,UAAU,EAAE,kCAAkC;AAC5D,OAAO,KAAK,EAAE,GAAG,EAAE,wBAAwB;AAE3C;;GAEG;AACH,oBAAY,mCAAmC;IAC7C,0BAA0B,kCAAkC;IAC5D,0BAA0B,kCAAkC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AAM,uBAAuB,GAAG;IACpC;;OAEG;IACH,IAAI,EAAE,MAAM,CAAC;IACb;;OAEG;IACH,iBAAiB,EAAE,GAAG,CAAC;CACxB,CAAC"}
|
package/dist/types.d.mts
CHANGED
|
@@ -98,17 +98,14 @@ export type PermissionResponse<TPermission extends PermissionTypesWithCustom> =
|
|
|
98
98
|
*/
|
|
99
99
|
export type PermissionResponseSanitized<TPermission extends PermissionTypesWithCustom> = Omit<PermissionResponse<TPermission>, 'dependencies' | 'to'>;
|
|
100
100
|
/**
|
|
101
|
-
* Represents a gator ERC-7715 granted(ie. signed by
|
|
101
|
+
* Represents a gator ERC-7715 granted(ie. signed by a user's account) permission entry that is stored in profile sync.
|
|
102
102
|
*
|
|
103
103
|
* @template Permission - The type of the permission provided
|
|
104
104
|
*/
|
|
105
105
|
export type StoredGatorPermission<TPermission extends PermissionTypesWithCustom> = {
|
|
106
106
|
permissionResponse: PermissionResponse<TPermission>;
|
|
107
107
|
siteOrigin: string;
|
|
108
|
-
|
|
109
|
-
* Flag indicating whether this permission has been revoked.
|
|
110
|
-
*/
|
|
111
|
-
isRevoked?: boolean;
|
|
108
|
+
revocationMetadata?: RevocationMetadata;
|
|
112
109
|
};
|
|
113
110
|
/**
|
|
114
111
|
* Represents a sanitized version of the StoredGatorPermission type. Some fields have been removed but the fields are still present in profile sync.
|
|
@@ -118,10 +115,7 @@ export type StoredGatorPermission<TPermission extends PermissionTypesWithCustom>
|
|
|
118
115
|
export type StoredGatorPermissionSanitized<TPermission extends PermissionTypesWithCustom> = {
|
|
119
116
|
permissionResponse: PermissionResponseSanitized<TPermission>;
|
|
120
117
|
siteOrigin: string;
|
|
121
|
-
|
|
122
|
-
* Flag indicating whether this permission has been revoked.
|
|
123
|
-
*/
|
|
124
|
-
isRevoked?: boolean;
|
|
118
|
+
revocationMetadata?: RevocationMetadata;
|
|
125
119
|
};
|
|
126
120
|
/**
|
|
127
121
|
* Represents a map of gator permissions by chainId and permission type.
|
|
@@ -163,13 +157,24 @@ export type GatorPermissionsListByPermissionTypeAndChainId<TPermissionType exten
|
|
|
163
157
|
*/
|
|
164
158
|
export type DelegationDetails = Pick<Delegation<Hex>, 'caveats' | 'delegator' | 'delegate' | 'authority'>;
|
|
165
159
|
/**
|
|
166
|
-
* Represents the
|
|
160
|
+
* Represents the metadata for confirmed transaction revocation.
|
|
161
|
+
*/
|
|
162
|
+
export type RevocationMetadata = {
|
|
163
|
+
recordedAt: number;
|
|
164
|
+
txHash?: Hex | undefined;
|
|
165
|
+
};
|
|
166
|
+
/**
|
|
167
|
+
* Parameters for the `permissionsProvider_submitRevocation` method
|
|
167
168
|
*/
|
|
168
169
|
export type RevocationParams = {
|
|
169
170
|
/**
|
|
170
171
|
* The permission context as a hex string that identifies the permission to revoke.
|
|
171
172
|
*/
|
|
172
173
|
permissionContext: Hex;
|
|
174
|
+
/**
|
|
175
|
+
* The hash of the transaction that was used to revoke the permission. Optional because we might not have submitted the transaction ourselves.
|
|
176
|
+
*/
|
|
177
|
+
txHash: Hex | undefined;
|
|
173
178
|
};
|
|
174
179
|
/**
|
|
175
180
|
* Represents the parameters for adding a pending revocation.
|
package/dist/types.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.mts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,eAAe,EACf,cAAc,EACd,2BAA2B,EAC3B,6BAA6B,EAC7B,0BAA0B,EAC1B,4BAA4B,EAC5B,IAAI,EACJ,0BAA0B,EAC1B,8BAA8B,EAC/B,wCAAwC;AACzC,OAAO,KAAK,EAAE,UAAU,EAAE,kCAAkC;AAC5D,OAAO,KAAK,EAAE,GAAG,EAAE,wBAAwB;AAE3C;;GAEG;AACH,oBAAY,mCAAmC;IAC7C,0BAA0B,kCAAkC;IAC5D,0BAA0B,kCAAkC;IAC5D,6BAA6B,qCAAqC;IAClE,qCAAqC,8CAA8C;IACnF,uBAAuB,8BAA8B;IACrD,qBA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AAiB,EAAE,GAAG,CAAC;CACxB,CAAC"}
|
package/dist/types.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.mjs","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAcA;;GAEG;AACH,MAAM,CAAN,IAAY,mCAOX;AAPD,WAAY,mCAAmC;IAC7C,mGAA4D,CAAA;IAC5D,mGAA4D,CAAA;IAC5D,yGAAkE,CAAA;IAClE,0HAAmF,CAAA;IACnF,4FAAqD,CAAA;IACrD,yFAAkD,CAAA;AACpD,CAAC,EAPW,mCAAmC,KAAnC,mCAAmC,QAO9C;AAED;;GAEG;AACH,MAAM,CAAN,IAAY,6BASX;AATD,WAAY,6BAA6B;IACvC;;OAEG;IACH,sHAAqF,CAAA;IACrF;;OAEG;IACH,4GAA2E,CAAA;AAC7E,CAAC,EATW,6BAA6B,KAA7B,6BAA6B,QASxC","sourcesContent":["import type {\n PermissionTypes,\n BasePermission,\n NativeTokenStreamPermission,\n NativeTokenPeriodicPermission,\n Erc20TokenStreamPermission,\n Erc20TokenPeriodicPermission,\n Rule,\n MetaMaskBasePermissionData,\n Erc20TokenRevocationPermission,\n} from '@metamask/7715-permission-types';\nimport type { Delegation } from '@metamask/delegation-core';\nimport type { Hex } from '@metamask/utils';\n\n/**\n * Enum for the error codes of the gator permissions controller.\n */\nexport enum GatorPermissionsControllerErrorCode {\n GatorPermissionsFetchError = 'gator-permissions-fetch-error',\n GatorPermissionsNotEnabled = 'gator-permissions-not-enabled',\n GatorPermissionsProviderError = 'gator-permissions-provider-error',\n GatorPermissionsMapSerializationError = 'gator-permissions-map-serialization-error',\n PermissionDecodingError = 'permission-decoding-error',\n OriginNotAllowedError = 'origin-not-allowed-error',\n}\n\n/**\n * Enum for the RPC methods of the gator permissions provider snap.\n */\nexport enum GatorPermissionsSnapRpcMethod {\n /**\n * This method is used by the metamask to request a permissions provider to get granted permissions for all sites.\n */\n PermissionProviderGetGrantedPermissions = 'permissionsProvider_getGrantedPermissions',\n /**\n * This method is used by the metamask to submit a revocation to the permissions provider.\n */\n PermissionProviderSubmitRevocation = 'permissionsProvider_submitRevocation',\n}\n\n/**\n * Represents a custom permission that are not of the standard ERC-7715 permission types.\n */\nexport type CustomPermission = BasePermission & {\n type: 'custom';\n data: MetaMaskBasePermissionData & Record<string, unknown>;\n};\n\n/**\n * Represents the type of the ERC-7715 permissions that can be granted including custom permissions.\n */\nexport type PermissionTypesWithCustom = PermissionTypes | CustomPermission;\n\n/**\n * Represents a ERC-7715 permission request.\n *\n * @template to - The type of the signer provided, either an AccountSigner or WalletSigner.\n * @template Permission - The type of the permission provided.\n */\nexport type PermissionRequest<TPermission extends PermissionTypesWithCustom> = {\n /**\n * hex-encoding of uint256 defined the chain with EIP-155\n */\n chainId: Hex;\n\n /**\n *\n * The account being targeted for this permission request.\n * It is optional to let the user choose which account to grant permission from.\n */\n from?: Hex;\n\n /**\n * A field that identifies the DApp session account associated with the permission\n */\n to: Hex;\n\n /**\n * Defines the allowed behavior the `to` account can do on behalf of the `from` account.\n */\n permission: TPermission;\n\n rules?: Rule[] | null;\n};\n\n/**\n * Represents a ERC-7715 permission response.\n *\n * @template Permission - The type of the permission provided.\n */\nexport type PermissionResponse<TPermission extends PermissionTypesWithCustom> =\n PermissionRequest<TPermission> & {\n /**\n * Is a catch-all to identify a permission for revoking permissions or submitting\n * Defined in ERC-7710.\n */\n context: Hex;\n\n /**\n * The dependencyInfo field is required and contains information needed to deploy accounts.\n * Each entry specifies a factory contract and its associated deployment data.\n * If no account deployment is needed when redeeming the permission, this array must be empty.\n * When non-empty, DApps MUST deploy the accounts by calling the factory contract with factoryData as the calldata.\n * Defined in ERC-4337.\n */\n dependencies: {\n factory: Hex;\n factoryData: Hex;\n }[];\n\n /**\n * Is required as defined in ERC-7710.\n */\n delegationManager: Hex;\n };\n\n/**\n * Represents a sanitized version of the PermissionResponse type.\n * Internal fields (dependencies, to) are removed\n *\n * @template Permission - The type of the permission provided.\n */\nexport type PermissionResponseSanitized<\n TPermission extends PermissionTypesWithCustom,\n> = Omit<PermissionResponse<TPermission>, 'dependencies' | 'to'>;\n\n/**\n * Represents a gator ERC-7715 granted(ie. signed by
|
|
1
|
+
{"version":3,"file":"types.mjs","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAcA;;GAEG;AACH,MAAM,CAAN,IAAY,mCAOX;AAPD,WAAY,mCAAmC;IAC7C,mGAA4D,CAAA;IAC5D,mGAA4D,CAAA;IAC5D,yGAAkE,CAAA;IAClE,0HAAmF,CAAA;IACnF,4FAAqD,CAAA;IACrD,yFAAkD,CAAA;AACpD,CAAC,EAPW,mCAAmC,KAAnC,mCAAmC,QAO9C;AAED;;GAEG;AACH,MAAM,CAAN,IAAY,6BASX;AATD,WAAY,6BAA6B;IACvC;;OAEG;IACH,sHAAqF,CAAA;IACrF;;OAEG;IACH,4GAA2E,CAAA;AAC7E,CAAC,EATW,6BAA6B,KAA7B,6BAA6B,QASxC","sourcesContent":["import type {\n PermissionTypes,\n BasePermission,\n NativeTokenStreamPermission,\n NativeTokenPeriodicPermission,\n Erc20TokenStreamPermission,\n Erc20TokenPeriodicPermission,\n Rule,\n MetaMaskBasePermissionData,\n Erc20TokenRevocationPermission,\n} from '@metamask/7715-permission-types';\nimport type { Delegation } from '@metamask/delegation-core';\nimport type { Hex } from '@metamask/utils';\n\n/**\n * Enum for the error codes of the gator permissions controller.\n */\nexport enum GatorPermissionsControllerErrorCode {\n GatorPermissionsFetchError = 'gator-permissions-fetch-error',\n GatorPermissionsNotEnabled = 'gator-permissions-not-enabled',\n GatorPermissionsProviderError = 'gator-permissions-provider-error',\n GatorPermissionsMapSerializationError = 'gator-permissions-map-serialization-error',\n PermissionDecodingError = 'permission-decoding-error',\n OriginNotAllowedError = 'origin-not-allowed-error',\n}\n\n/**\n * Enum for the RPC methods of the gator permissions provider snap.\n */\nexport enum GatorPermissionsSnapRpcMethod {\n /**\n * This method is used by the metamask to request a permissions provider to get granted permissions for all sites.\n */\n PermissionProviderGetGrantedPermissions = 'permissionsProvider_getGrantedPermissions',\n /**\n * This method is used by the metamask to submit a revocation to the permissions provider.\n */\n PermissionProviderSubmitRevocation = 'permissionsProvider_submitRevocation',\n}\n\n/**\n * Represents a custom permission that are not of the standard ERC-7715 permission types.\n */\nexport type CustomPermission = BasePermission & {\n type: 'custom';\n data: MetaMaskBasePermissionData & Record<string, unknown>;\n};\n\n/**\n * Represents the type of the ERC-7715 permissions that can be granted including custom permissions.\n */\nexport type PermissionTypesWithCustom = PermissionTypes | CustomPermission;\n\n/**\n * Represents a ERC-7715 permission request.\n *\n * @template to - The type of the signer provided, either an AccountSigner or WalletSigner.\n * @template Permission - The type of the permission provided.\n */\nexport type PermissionRequest<TPermission extends PermissionTypesWithCustom> = {\n /**\n * hex-encoding of uint256 defined the chain with EIP-155\n */\n chainId: Hex;\n\n /**\n *\n * The account being targeted for this permission request.\n * It is optional to let the user choose which account to grant permission from.\n */\n from?: Hex;\n\n /**\n * A field that identifies the DApp session account associated with the permission\n */\n to: Hex;\n\n /**\n * Defines the allowed behavior the `to` account can do on behalf of the `from` account.\n */\n permission: TPermission;\n\n rules?: Rule[] | null;\n};\n\n/**\n * Represents a ERC-7715 permission response.\n *\n * @template Permission - The type of the permission provided.\n */\nexport type PermissionResponse<TPermission extends PermissionTypesWithCustom> =\n PermissionRequest<TPermission> & {\n /**\n * Is a catch-all to identify a permission for revoking permissions or submitting\n * Defined in ERC-7710.\n */\n context: Hex;\n\n /**\n * The dependencyInfo field is required and contains information needed to deploy accounts.\n * Each entry specifies a factory contract and its associated deployment data.\n * If no account deployment is needed when redeeming the permission, this array must be empty.\n * When non-empty, DApps MUST deploy the accounts by calling the factory contract with factoryData as the calldata.\n * Defined in ERC-4337.\n */\n dependencies: {\n factory: Hex;\n factoryData: Hex;\n }[];\n\n /**\n * Is required as defined in ERC-7710.\n */\n delegationManager: Hex;\n };\n\n/**\n * Represents a sanitized version of the PermissionResponse type.\n * Internal fields (dependencies, to) are removed\n *\n * @template Permission - The type of the permission provided.\n */\nexport type PermissionResponseSanitized<\n TPermission extends PermissionTypesWithCustom,\n> = Omit<PermissionResponse<TPermission>, 'dependencies' | 'to'>;\n\n/**\n * Represents a gator ERC-7715 granted(ie. signed by a user's account) permission entry that is stored in profile sync.\n *\n * @template Permission - The type of the permission provided\n */\nexport type StoredGatorPermission<\n TPermission extends PermissionTypesWithCustom,\n> = {\n permissionResponse: PermissionResponse<TPermission>;\n siteOrigin: string;\n revocationMetadata?: RevocationMetadata;\n};\n\n/**\n * Represents a sanitized version of the StoredGatorPermission type. Some fields have been removed but the fields are still present in profile sync.\n *\n * @template Permission - The type of the permission provided.\n */\nexport type StoredGatorPermissionSanitized<\n TPermission extends PermissionTypesWithCustom,\n> = {\n permissionResponse: PermissionResponseSanitized<TPermission>;\n siteOrigin: string;\n revocationMetadata?: RevocationMetadata;\n};\n\n/**\n * Represents a map of gator permissions by chainId and permission type.\n */\nexport type GatorPermissionsMap = {\n 'erc20-token-revocation': {\n [\n chainId: Hex\n ]: StoredGatorPermissionSanitized<Erc20TokenRevocationPermission>[];\n };\n 'native-token-stream': {\n [\n chainId: Hex\n ]: StoredGatorPermissionSanitized<NativeTokenStreamPermission>[];\n };\n 'native-token-periodic': {\n [\n chainId: Hex\n ]: StoredGatorPermissionSanitized<NativeTokenPeriodicPermission>[];\n };\n 'erc20-token-stream': {\n [\n chainId: Hex\n ]: StoredGatorPermissionSanitized<Erc20TokenStreamPermission>[];\n };\n 'erc20-token-periodic': {\n [\n chainId: Hex\n ]: StoredGatorPermissionSanitized<Erc20TokenPeriodicPermission>[];\n };\n other: {\n [chainId: Hex]: StoredGatorPermissionSanitized<CustomPermission>[];\n };\n};\n\n/**\n * Represents the supported permission type(e.g. 'native-token-stream', 'native-token-periodic', 'erc20-token-stream', 'erc20-token-periodic') of the gator permissions map.\n */\nexport type SupportedGatorPermissionType = keyof GatorPermissionsMap;\n\n/**\n * Represents a map of gator permissions for a given permission type with key of chainId. The value being an array of gator permissions for that chainId.\n */\nexport type GatorPermissionsMapByPermissionType<\n TPermissionType extends SupportedGatorPermissionType,\n> = GatorPermissionsMap[TPermissionType];\n\n/**\n * Represents an array of gator permissions for a given permission type and chainId.\n */\nexport type GatorPermissionsListByPermissionTypeAndChainId<\n TPermissionType extends SupportedGatorPermissionType,\n> = GatorPermissionsMap[TPermissionType][Hex];\n\n/**\n * Represents the details of a delegation, that are required to decode a permission.\n */\nexport type DelegationDetails = Pick<\n Delegation<Hex>,\n 'caveats' | 'delegator' | 'delegate' | 'authority'\n>;\n\n/**\n * Represents the metadata for confirmed transaction revocation.\n */\nexport type RevocationMetadata = {\n // The timestamp at which the revocation was recorded in storage.\n recordedAt: number;\n // The hash of the transaction that was used to revoke the permission. Optional because we might not have submitted the transaction ourselves.\n txHash?: Hex | undefined;\n};\n\n/**\n * Parameters for the `permissionsProvider_submitRevocation` method\n */\nexport type RevocationParams = {\n /**\n * The permission context as a hex string that identifies the permission to revoke.\n */\n permissionContext: Hex;\n\n /**\n * The hash of the transaction that was used to revoke the permission. Optional because we might not have submitted the transaction ourselves.\n */\n txHash: Hex | undefined;\n};\n\n/**\n * Represents the parameters for adding a pending revocation.\n */\nexport type PendingRevocationParams = {\n /**\n * The transaction metadata ID to monitor.\n */\n txId: string;\n /**\n * The permission context as a hex string that identifies the permission to revoke.\n */\n permissionContext: Hex;\n};\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@metamask/gator-permissions-controller",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.1.1",
|
|
4
4
|
"description": "Controller for managing gator permissions with profile sync integration",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"MetaMask",
|
|
@@ -56,7 +56,7 @@
|
|
|
56
56
|
"@metamask/snaps-controllers": "^17.2.0",
|
|
57
57
|
"@metamask/snaps-sdk": "^10.3.0",
|
|
58
58
|
"@metamask/snaps-utils": "^11.7.0",
|
|
59
|
-
"@metamask/transaction-controller": "^62.
|
|
59
|
+
"@metamask/transaction-controller": "^62.10.0",
|
|
60
60
|
"@metamask/utils": "^11.9.0"
|
|
61
61
|
},
|
|
62
62
|
"devDependencies": {
|