@metamask/snaps-rpc-methods 4.1.0 → 6.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +24 -2
- package/dist/cjs/endowments/caveats/generic.js +40 -0
- package/dist/cjs/endowments/caveats/generic.js.map +1 -0
- package/dist/cjs/endowments/caveats/index.js +21 -0
- package/dist/cjs/endowments/caveats/index.js.map +1 -0
- package/dist/cjs/endowments/caveats/requestTime.js +99 -0
- package/dist/cjs/endowments/caveats/requestTime.js.map +1 -0
- package/dist/cjs/endowments/cronjob.js +100 -0
- package/dist/cjs/endowments/cronjob.js.map +1 -0
- package/dist/cjs/endowments/enum.js +26 -0
- package/dist/cjs/endowments/enum.js.map +1 -0
- package/dist/cjs/endowments/ethereum-provider.js +43 -0
- package/dist/cjs/endowments/ethereum-provider.js.map +1 -0
- package/dist/cjs/endowments/home-page.js +37 -0
- package/dist/cjs/endowments/home-page.js.map +1 -0
- package/dist/cjs/endowments/index.js +121 -0
- package/dist/cjs/endowments/index.js.map +1 -0
- package/dist/cjs/endowments/keyring.js +104 -0
- package/dist/cjs/endowments/keyring.js.map +1 -0
- package/dist/cjs/endowments/lifecycle-hooks.js +37 -0
- package/dist/cjs/endowments/lifecycle-hooks.js.map +1 -0
- package/dist/cjs/endowments/name-lookup.js +148 -0
- package/dist/cjs/endowments/name-lookup.js.map +1 -0
- package/dist/cjs/endowments/network-access.js +44 -0
- package/dist/cjs/endowments/network-access.js.map +1 -0
- package/dist/cjs/endowments/rpc.js +103 -0
- package/dist/cjs/endowments/rpc.js.map +1 -0
- package/dist/cjs/endowments/signature-insight.js +110 -0
- package/dist/cjs/endowments/signature-insight.js.map +1 -0
- package/dist/cjs/endowments/transaction-insight.js +111 -0
- package/dist/cjs/endowments/transaction-insight.js.map +1 -0
- package/dist/cjs/endowments/web-assembly.js +42 -0
- package/dist/cjs/endowments/web-assembly.js.map +1 -0
- package/dist/cjs/index.js +3 -1
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/permissions.js +62 -0
- package/dist/cjs/permissions.js.map +1 -0
- package/dist/cjs/permitted/createInterface.js +68 -0
- package/dist/cjs/permitted/createInterface.js.map +1 -0
- package/dist/cjs/permitted/getClientStatus.js +40 -0
- package/dist/cjs/permitted/getClientStatus.js.map +1 -0
- package/dist/cjs/permitted/getFile.js +1 -1
- package/dist/cjs/permitted/getFile.js.map +1 -1
- package/dist/cjs/permitted/getInterfaceState.js +67 -0
- package/dist/cjs/permitted/getInterfaceState.js.map +1 -0
- package/dist/cjs/permitted/handlers.js +9 -1
- package/dist/cjs/permitted/handlers.js.map +1 -1
- package/dist/cjs/permitted/index.js.map +1 -1
- package/dist/cjs/permitted/invokeKeyring.js +2 -3
- package/dist/cjs/permitted/invokeKeyring.js.map +1 -1
- package/dist/cjs/permitted/updateInterface.js +70 -0
- package/dist/cjs/permitted/updateInterface.js.map +1 -0
- package/dist/cjs/restricted/dialog.js +51 -24
- package/dist/cjs/restricted/dialog.js.map +1 -1
- package/dist/cjs/restricted/index.js +3 -0
- package/dist/cjs/restricted/index.js.map +1 -1
- package/dist/cjs/restricted/manageState.js +4 -13
- package/dist/cjs/restricted/manageState.js.map +1 -1
- package/dist/esm/endowments/caveats/generic.js +40 -0
- package/dist/esm/endowments/caveats/generic.js.map +1 -0
- package/dist/esm/endowments/caveats/index.js +4 -0
- package/dist/esm/endowments/caveats/index.js.map +1 -0
- package/dist/esm/endowments/caveats/requestTime.js +93 -0
- package/dist/esm/endowments/caveats/requestTime.js.map +1 -0
- package/dist/esm/endowments/cronjob.js +99 -0
- package/dist/esm/endowments/cronjob.js.map +1 -0
- package/dist/esm/endowments/enum.js +16 -0
- package/dist/esm/endowments/enum.js.map +1 -0
- package/dist/esm/endowments/ethereum-provider.js +33 -0
- package/dist/esm/endowments/ethereum-provider.js.map +1 -0
- package/dist/esm/endowments/home-page.js +27 -0
- package/dist/esm/endowments/home-page.js.map +1 -0
- package/dist/esm/endowments/index.js +68 -0
- package/dist/esm/endowments/index.js.map +1 -0
- package/dist/esm/endowments/keyring.js +95 -0
- package/dist/esm/endowments/keyring.js.map +1 -0
- package/dist/esm/endowments/lifecycle-hooks.js +27 -0
- package/dist/esm/endowments/lifecycle-hooks.js.map +1 -0
- package/dist/esm/endowments/name-lookup.js +146 -0
- package/dist/esm/endowments/name-lookup.js.map +1 -0
- package/dist/esm/endowments/network-access.js +34 -0
- package/dist/esm/endowments/network-access.js.map +1 -0
- package/dist/esm/endowments/rpc.js +92 -0
- package/dist/esm/endowments/rpc.js.map +1 -0
- package/dist/esm/endowments/signature-insight.js +103 -0
- package/dist/esm/endowments/signature-insight.js.map +1 -0
- package/dist/esm/endowments/transaction-insight.js +104 -0
- package/dist/esm/endowments/transaction-insight.js.map +1 -0
- package/dist/esm/endowments/web-assembly.js +32 -0
- package/dist/esm/endowments/web-assembly.js.map +1 -0
- package/dist/esm/index.js +3 -1
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/permissions.js +51 -0
- package/dist/esm/permissions.js.map +1 -0
- package/dist/esm/permitted/createInterface.js +58 -0
- package/dist/esm/permitted/createInterface.js.map +1 -0
- package/dist/esm/permitted/getClientStatus.js +32 -0
- package/dist/esm/permitted/getClientStatus.js.map +1 -0
- package/dist/esm/permitted/getFile.js +1 -1
- package/dist/esm/permitted/getFile.js.map +1 -1
- package/dist/esm/permitted/getInterfaceState.js +57 -0
- package/dist/esm/permitted/getInterfaceState.js.map +1 -0
- package/dist/esm/permitted/handlers.js +9 -1
- package/dist/esm/permitted/handlers.js.map +1 -1
- package/dist/esm/permitted/index.js.map +1 -1
- package/dist/esm/permitted/invokeKeyring.js +2 -3
- package/dist/esm/permitted/invokeKeyring.js.map +1 -1
- package/dist/esm/permitted/updateInterface.js +60 -0
- package/dist/esm/permitted/updateInterface.js.map +1 -0
- package/dist/esm/restricted/dialog.js +55 -29
- package/dist/esm/restricted/dialog.js.map +1 -1
- package/dist/esm/restricted/index.js +1 -0
- package/dist/esm/restricted/index.js.map +1 -1
- package/dist/esm/restricted/manageState.js +1 -1
- package/dist/esm/restricted/manageState.js.map +1 -1
- package/dist/types/endowments/caveats/generic.d.ts +19 -0
- package/dist/types/endowments/caveats/index.d.ts +2 -0
- package/dist/types/endowments/caveats/requestTime.d.ts +29 -0
- package/dist/types/endowments/cronjob.d.ts +51 -0
- package/dist/types/endowments/enum.d.ts +13 -0
- package/dist/types/endowments/ethereum-provider.d.ts +14 -0
- package/dist/types/endowments/home-page.d.ts +15 -0
- package/dist/types/endowments/index.d.ts +131 -0
- package/dist/types/endowments/keyring.d.ts +39 -0
- package/dist/types/endowments/lifecycle-hooks.d.ts +15 -0
- package/dist/types/endowments/name-lookup.d.ts +49 -0
- package/dist/types/endowments/network-access.d.ts +14 -0
- package/dist/types/endowments/rpc.d.ts +38 -0
- package/dist/types/endowments/signature-insight.d.ts +39 -0
- package/dist/types/endowments/transaction-insight.d.ts +39 -0
- package/dist/types/endowments/web-assembly.d.ts +14 -0
- package/dist/types/index.d.ts +4 -2
- package/dist/types/permissions.d.ts +16 -0
- package/dist/types/permitted/createInterface.d.ts +150 -0
- package/dist/types/permitted/getClientStatus.d.ts +13 -0
- package/dist/types/permitted/getInterfaceState.d.ts +18 -0
- package/dist/types/permitted/handlers.d.ts +5 -1
- package/dist/types/permitted/index.d.ts +5 -1
- package/dist/types/permitted/invokeKeyring.d.ts +3 -3
- package/dist/types/permitted/updateInterface.d.ts +152 -0
- package/dist/types/restricted/dialog.d.ts +776 -14
- package/dist/types/restricted/index.d.ts +1 -0
- package/dist/types/restricted/manageState.d.ts +18 -0
- package/package.json +8 -8
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { PermissionConstraint, PermissionValidatorConstraint } from '@metamask/permission-controller';
|
|
2
|
+
import type { Json } from '@metamask/utils';
|
|
3
|
+
export declare type CaveatMapperReturnValue = Pick<PermissionConstraint, 'caveats'>;
|
|
4
|
+
export declare type CaveatMapperFunction = (value: Json) => CaveatMapperReturnValue;
|
|
5
|
+
/**
|
|
6
|
+
* Create a generic permission validator that validates the presence of certain caveats.
|
|
7
|
+
*
|
|
8
|
+
* This validator only validates the types of the caveats, not the values.
|
|
9
|
+
*
|
|
10
|
+
* @param caveatsToValidate - A list of objects that represent caveats.
|
|
11
|
+
* @param caveatsToValidate.type - The string defining the caveat type.
|
|
12
|
+
* @param caveatsToValidate.optional - An optional boolean flag that defines
|
|
13
|
+
* whether the caveat is optional or not.
|
|
14
|
+
* @returns A function that validates a permission.
|
|
15
|
+
*/
|
|
16
|
+
export declare function createGenericPermissionValidator(caveatsToValidate: {
|
|
17
|
+
type: string;
|
|
18
|
+
optional?: boolean;
|
|
19
|
+
}[]): PermissionValidatorConstraint;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { CaveatSpecificationConstraint, PermissionConstraint } from '@metamask/permission-controller';
|
|
2
|
+
import { SnapCaveatType } from '@metamask/snaps-utils';
|
|
3
|
+
import type { Json } from '@metamask/utils';
|
|
4
|
+
import type { CaveatMapperFunction, CaveatMapperReturnValue } from './generic';
|
|
5
|
+
/**
|
|
6
|
+
* Map a raw value from the `initialPermissions` to a caveat specification.
|
|
7
|
+
* Note that this function does not do any validation, that's handled by the
|
|
8
|
+
* PermissionsController when the permission is requested.
|
|
9
|
+
*
|
|
10
|
+
* @param value - The raw value from the `initialPermissions`.
|
|
11
|
+
* @returns The caveat specification.
|
|
12
|
+
*/
|
|
13
|
+
export declare function getMaxRequestTimeCaveatMapper(value: Json): CaveatMapperReturnValue;
|
|
14
|
+
/**
|
|
15
|
+
* Creates a wrapping caveat mapper that creates the `maxRequestTime` caveat
|
|
16
|
+
* and merges it with any other caveats created by the mapper function.
|
|
17
|
+
*
|
|
18
|
+
* @param mapper - Another caveat mapper function.
|
|
19
|
+
* @returns The caveat specification.
|
|
20
|
+
*/
|
|
21
|
+
export declare function createMaxRequestTimeMapper(mapper: CaveatMapperFunction): CaveatMapperFunction;
|
|
22
|
+
/**
|
|
23
|
+
* Getter function to get the {@link MaxRequestTime} caveat value from a permission if specified.
|
|
24
|
+
*
|
|
25
|
+
* @param permission - The permission to get the caveat value from.
|
|
26
|
+
* @returns The caveat value if present, otherwise null.
|
|
27
|
+
*/
|
|
28
|
+
export declare function getMaxRequestTimeCaveat(permission?: PermissionConstraint): number | null;
|
|
29
|
+
export declare const maxRequestTimeCaveatSpecifications: Record<SnapCaveatType.MaxRequestTime, CaveatSpecificationConstraint>;
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import type { PermissionSpecificationBuilder, PermissionConstraint, Caveat, CaveatSpecificationConstraint } from '@metamask/permission-controller';
|
|
2
|
+
import { PermissionType } from '@metamask/permission-controller';
|
|
3
|
+
import type { CronjobSpecification } from '@metamask/snaps-utils';
|
|
4
|
+
import { SnapCaveatType } from '@metamask/snaps-utils';
|
|
5
|
+
import type { Json, NonEmptyArray } from '@metamask/utils';
|
|
6
|
+
import { SnapEndowments } from './enum';
|
|
7
|
+
declare const permissionName = SnapEndowments.Cronjob;
|
|
8
|
+
export declare const cronjobEndowmentBuilder: Readonly<{
|
|
9
|
+
readonly targetName: SnapEndowments.Cronjob;
|
|
10
|
+
readonly specificationBuilder: PermissionSpecificationBuilder<PermissionType.Endowment, any, {
|
|
11
|
+
permissionType: PermissionType.Endowment;
|
|
12
|
+
targetName: typeof permissionName;
|
|
13
|
+
endowmentGetter: (_options?: any) => undefined;
|
|
14
|
+
allowedCaveats: Readonly<NonEmptyArray<string>> | null;
|
|
15
|
+
}>;
|
|
16
|
+
}>;
|
|
17
|
+
/**
|
|
18
|
+
* Map a raw value from the `initialPermissions` to a caveat specification.
|
|
19
|
+
* Note that this function does not do any validation, that's handled by the
|
|
20
|
+
* PermissionsController when the permission is requested.
|
|
21
|
+
*
|
|
22
|
+
* @param value - The raw value from the `initialPermissions`.
|
|
23
|
+
* @returns The caveat specification.
|
|
24
|
+
*/
|
|
25
|
+
export declare function getCronjobCaveatMapper(value: Json): Pick<PermissionConstraint, 'caveats'>;
|
|
26
|
+
/**
|
|
27
|
+
* Getter function to get the cronjobs from a permission.
|
|
28
|
+
*
|
|
29
|
+
* This does basic validation of the caveat, but does not validate the type or
|
|
30
|
+
* value of the namespaces object itself, as this is handled by the
|
|
31
|
+
* `PermissionsController` when the permission is requested.
|
|
32
|
+
*
|
|
33
|
+
* @param permission - The permission to get the keyring namespaces from.
|
|
34
|
+
* @returns The cronjobs, or `null` if the permission does not have a
|
|
35
|
+
* cronjob caveat.
|
|
36
|
+
*/
|
|
37
|
+
export declare function getCronjobCaveatJobs(permission?: PermissionConstraint): CronjobSpecification[] | null;
|
|
38
|
+
/**
|
|
39
|
+
* Validate the cronjob specification values associated with a caveat.
|
|
40
|
+
* This validates that the value is a non-empty array with valid
|
|
41
|
+
* cronjob expression and request object.
|
|
42
|
+
*
|
|
43
|
+
* @param caveat - The caveat to validate.
|
|
44
|
+
* @throws If the value is invalid.
|
|
45
|
+
*/
|
|
46
|
+
export declare function validateCronjobCaveat(caveat: Caveat<string, any>): void;
|
|
47
|
+
/**
|
|
48
|
+
* Caveat specification for the Cronjob.
|
|
49
|
+
*/
|
|
50
|
+
export declare const cronjobCaveatSpecifications: Record<SnapCaveatType.SnapCronjob, CaveatSpecificationConstraint>;
|
|
51
|
+
export {};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export declare enum SnapEndowments {
|
|
2
|
+
NetworkAccess = "endowment:network-access",
|
|
3
|
+
SignatureInsight = "endowment:signature-insight",
|
|
4
|
+
TransactionInsight = "endowment:transaction-insight",
|
|
5
|
+
Cronjob = "endowment:cronjob",
|
|
6
|
+
EthereumProvider = "endowment:ethereum-provider",
|
|
7
|
+
Rpc = "endowment:rpc",
|
|
8
|
+
WebAssemblyAccess = "endowment:webassembly",
|
|
9
|
+
NameLookup = "endowment:name-lookup",
|
|
10
|
+
LifecycleHooks = "endowment:lifecycle-hooks",
|
|
11
|
+
Keyring = "endowment:keyring",
|
|
12
|
+
HomePage = "endowment:page-home"
|
|
13
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { PermissionSpecificationBuilder } from '@metamask/permission-controller';
|
|
2
|
+
import { PermissionType } from '@metamask/permission-controller';
|
|
3
|
+
import { SnapEndowments } from './enum';
|
|
4
|
+
declare const permissionName = SnapEndowments.EthereumProvider;
|
|
5
|
+
export declare const ethereumProviderEndowmentBuilder: Readonly<{
|
|
6
|
+
readonly targetName: SnapEndowments.EthereumProvider;
|
|
7
|
+
readonly specificationBuilder: PermissionSpecificationBuilder<PermissionType.Endowment, any, {
|
|
8
|
+
permissionType: PermissionType.Endowment;
|
|
9
|
+
targetName: typeof permissionName;
|
|
10
|
+
endowmentGetter: (_options?: any) => ['ethereum'];
|
|
11
|
+
allowedCaveats: null;
|
|
12
|
+
}>;
|
|
13
|
+
}>;
|
|
14
|
+
export {};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { PermissionSpecificationBuilder, EndowmentGetterParams } from '@metamask/permission-controller';
|
|
2
|
+
import { PermissionType } from '@metamask/permission-controller';
|
|
3
|
+
import type { NonEmptyArray } from '@metamask/utils';
|
|
4
|
+
import { SnapEndowments } from './enum';
|
|
5
|
+
declare const permissionName = SnapEndowments.HomePage;
|
|
6
|
+
export declare const homePageEndowmentBuilder: Readonly<{
|
|
7
|
+
readonly targetName: SnapEndowments.HomePage;
|
|
8
|
+
readonly specificationBuilder: PermissionSpecificationBuilder<PermissionType.Endowment, any, {
|
|
9
|
+
permissionType: PermissionType.Endowment;
|
|
10
|
+
targetName: typeof permissionName;
|
|
11
|
+
endowmentGetter: (_options?: EndowmentGetterParams) => undefined;
|
|
12
|
+
allowedCaveats: Readonly<NonEmptyArray<string>> | null;
|
|
13
|
+
}>;
|
|
14
|
+
}>;
|
|
15
|
+
export {};
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
import type { PermissionConstraint } from '@metamask/permission-controller';
|
|
2
|
+
import { HandlerType } from '@metamask/snaps-utils';
|
|
3
|
+
import type { Json } from '@metamask/utils';
|
|
4
|
+
export declare const endowmentPermissionBuilders: {
|
|
5
|
+
readonly "endowment:network-access": Readonly<{
|
|
6
|
+
readonly targetName: import("./enum").SnapEndowments.NetworkAccess;
|
|
7
|
+
readonly specificationBuilder: import("@metamask/permission-controller").PermissionSpecificationBuilder<import("@metamask/permission-controller").PermissionType.Endowment, any, {
|
|
8
|
+
permissionType: import("@metamask/permission-controller").PermissionType.Endowment;
|
|
9
|
+
targetName: import("./enum").SnapEndowments.NetworkAccess;
|
|
10
|
+
endowmentGetter: (_options?: any) => ["fetch", "Request", "Headers", "Response"];
|
|
11
|
+
allowedCaveats: null;
|
|
12
|
+
}>;
|
|
13
|
+
}>;
|
|
14
|
+
readonly "endowment:transaction-insight": Readonly<{
|
|
15
|
+
readonly targetName: import("./enum").SnapEndowments.TransactionInsight;
|
|
16
|
+
readonly specificationBuilder: import("@metamask/permission-controller").PermissionSpecificationBuilder<import("@metamask/permission-controller").PermissionType.Endowment, any, {
|
|
17
|
+
permissionType: import("@metamask/permission-controller").PermissionType.Endowment;
|
|
18
|
+
targetName: import("./enum").SnapEndowments.TransactionInsight;
|
|
19
|
+
endowmentGetter: (_options?: import("@metamask/permission-controller").EndowmentGetterParams | undefined) => undefined;
|
|
20
|
+
allowedCaveats: readonly [string, ...string[]] | null;
|
|
21
|
+
validator: import("@metamask/permission-controller").PermissionValidatorConstraint;
|
|
22
|
+
}>;
|
|
23
|
+
}>;
|
|
24
|
+
readonly "endowment:cronjob": Readonly<{
|
|
25
|
+
readonly targetName: import("./enum").SnapEndowments.Cronjob;
|
|
26
|
+
readonly specificationBuilder: import("@metamask/permission-controller").PermissionSpecificationBuilder<import("@metamask/permission-controller").PermissionType.Endowment, any, {
|
|
27
|
+
permissionType: import("@metamask/permission-controller").PermissionType.Endowment;
|
|
28
|
+
targetName: import("./enum").SnapEndowments.Cronjob;
|
|
29
|
+
endowmentGetter: (_options?: any) => undefined;
|
|
30
|
+
allowedCaveats: readonly [string, ...string[]] | null;
|
|
31
|
+
}>;
|
|
32
|
+
}>;
|
|
33
|
+
readonly "endowment:ethereum-provider": Readonly<{
|
|
34
|
+
readonly targetName: import("./enum").SnapEndowments.EthereumProvider;
|
|
35
|
+
readonly specificationBuilder: import("@metamask/permission-controller").PermissionSpecificationBuilder<import("@metamask/permission-controller").PermissionType.Endowment, any, {
|
|
36
|
+
permissionType: import("@metamask/permission-controller").PermissionType.Endowment;
|
|
37
|
+
targetName: import("./enum").SnapEndowments.EthereumProvider;
|
|
38
|
+
endowmentGetter: (_options?: any) => ["ethereum"];
|
|
39
|
+
allowedCaveats: null;
|
|
40
|
+
}>;
|
|
41
|
+
}>;
|
|
42
|
+
readonly "endowment:rpc": Readonly<{
|
|
43
|
+
readonly targetName: import("./enum").SnapEndowments.Rpc;
|
|
44
|
+
readonly specificationBuilder: import("@metamask/permission-controller").PermissionSpecificationBuilder<import("@metamask/permission-controller").PermissionType.Endowment, {}, {
|
|
45
|
+
permissionType: import("@metamask/permission-controller").PermissionType.Endowment;
|
|
46
|
+
targetName: import("./enum").SnapEndowments.Rpc;
|
|
47
|
+
endowmentGetter: (_options?: any) => undefined;
|
|
48
|
+
allowedCaveats: readonly [string, ...string[]] | null;
|
|
49
|
+
validator: import("@metamask/permission-controller").PermissionValidatorConstraint;
|
|
50
|
+
subjectTypes: readonly import("@metamask/permission-controller").SubjectType[];
|
|
51
|
+
}>;
|
|
52
|
+
}>;
|
|
53
|
+
readonly "endowment:webassembly": Readonly<{
|
|
54
|
+
readonly targetName: import("./enum").SnapEndowments.WebAssemblyAccess;
|
|
55
|
+
readonly specificationBuilder: import("@metamask/permission-controller").PermissionSpecificationBuilder<import("@metamask/permission-controller").PermissionType.Endowment, any, {
|
|
56
|
+
permissionType: import("@metamask/permission-controller").PermissionType.Endowment;
|
|
57
|
+
targetName: import("./enum").SnapEndowments.WebAssemblyAccess;
|
|
58
|
+
endowmentGetter: (_options?: any) => ["WebAssembly"];
|
|
59
|
+
allowedCaveats: null;
|
|
60
|
+
}>;
|
|
61
|
+
}>;
|
|
62
|
+
readonly "endowment:name-lookup": Readonly<{
|
|
63
|
+
readonly targetName: import("./enum").SnapEndowments.NameLookup;
|
|
64
|
+
readonly specificationBuilder: import("@metamask/permission-controller").PermissionSpecificationBuilder<import("@metamask/permission-controller").PermissionType.Endowment, any, {
|
|
65
|
+
permissionType: import("@metamask/permission-controller").PermissionType.Endowment;
|
|
66
|
+
targetName: import("./enum").SnapEndowments.NameLookup;
|
|
67
|
+
endowmentGetter: (_options?: import("@metamask/permission-controller").EndowmentGetterParams | undefined) => undefined;
|
|
68
|
+
allowedCaveats: readonly [string, ...string[]] | null;
|
|
69
|
+
validator: import("@metamask/permission-controller").PermissionValidatorConstraint;
|
|
70
|
+
}>;
|
|
71
|
+
}>;
|
|
72
|
+
readonly "endowment:lifecycle-hooks": Readonly<{
|
|
73
|
+
readonly targetName: import("./enum").SnapEndowments.LifecycleHooks;
|
|
74
|
+
readonly specificationBuilder: import("@metamask/permission-controller").PermissionSpecificationBuilder<import("@metamask/permission-controller").PermissionType.Endowment, any, {
|
|
75
|
+
permissionType: import("@metamask/permission-controller").PermissionType.Endowment;
|
|
76
|
+
targetName: import("./enum").SnapEndowments.LifecycleHooks;
|
|
77
|
+
endowmentGetter: (_options?: import("@metamask/permission-controller").EndowmentGetterParams | undefined) => undefined;
|
|
78
|
+
allowedCaveats: readonly [string, ...string[]] | null;
|
|
79
|
+
}>;
|
|
80
|
+
}>;
|
|
81
|
+
readonly "endowment:keyring": Readonly<{
|
|
82
|
+
readonly targetName: import("./enum").SnapEndowments.Keyring;
|
|
83
|
+
readonly specificationBuilder: import("@metamask/permission-controller").PermissionSpecificationBuilder<import("@metamask/permission-controller").PermissionType.Endowment, any, {
|
|
84
|
+
permissionType: import("@metamask/permission-controller").PermissionType.Endowment;
|
|
85
|
+
targetName: import("./enum").SnapEndowments.Keyring;
|
|
86
|
+
endowmentGetter: (_options?: import("@metamask/permission-controller").EndowmentGetterParams | undefined) => undefined;
|
|
87
|
+
allowedCaveats: readonly [string, ...string[]] | null;
|
|
88
|
+
validator: import("@metamask/permission-controller").PermissionValidatorConstraint;
|
|
89
|
+
subjectTypes: readonly import("@metamask/permission-controller").SubjectType[];
|
|
90
|
+
}>;
|
|
91
|
+
}>;
|
|
92
|
+
readonly "endowment:page-home": Readonly<{
|
|
93
|
+
readonly targetName: import("./enum").SnapEndowments.HomePage;
|
|
94
|
+
readonly specificationBuilder: import("@metamask/permission-controller").PermissionSpecificationBuilder<import("@metamask/permission-controller").PermissionType.Endowment, any, {
|
|
95
|
+
permissionType: import("@metamask/permission-controller").PermissionType.Endowment;
|
|
96
|
+
targetName: import("./enum").SnapEndowments.HomePage;
|
|
97
|
+
endowmentGetter: (_options?: import("@metamask/permission-controller").EndowmentGetterParams | undefined) => undefined;
|
|
98
|
+
allowedCaveats: readonly [string, ...string[]] | null;
|
|
99
|
+
}>;
|
|
100
|
+
}>;
|
|
101
|
+
readonly "endowment:signature-insight": Readonly<{
|
|
102
|
+
readonly targetName: import("./enum").SnapEndowments.SignatureInsight;
|
|
103
|
+
readonly specificationBuilder: import("@metamask/permission-controller").PermissionSpecificationBuilder<import("@metamask/permission-controller").PermissionType.Endowment, any, {
|
|
104
|
+
permissionType: import("@metamask/permission-controller").PermissionType.Endowment;
|
|
105
|
+
targetName: import("./enum").SnapEndowments.SignatureInsight;
|
|
106
|
+
endowmentGetter: (_options?: import("@metamask/permission-controller").EndowmentGetterParams | undefined) => undefined;
|
|
107
|
+
allowedCaveats: readonly [string, ...string[]] | null;
|
|
108
|
+
validator: import("@metamask/permission-controller").PermissionValidatorConstraint;
|
|
109
|
+
}>;
|
|
110
|
+
}>;
|
|
111
|
+
};
|
|
112
|
+
export declare const endowmentCaveatSpecifications: {
|
|
113
|
+
maxRequestTime: import("@metamask/permission-controller").CaveatSpecificationConstraint;
|
|
114
|
+
signatureOrigin: import("@metamask/permission-controller").CaveatSpecificationConstraint;
|
|
115
|
+
keyringOrigin: import("@metamask/permission-controller").CaveatSpecificationConstraint;
|
|
116
|
+
chainIds: import("@metamask/permission-controller").CaveatSpecificationConstraint;
|
|
117
|
+
lookupMatchers: import("@metamask/permission-controller").CaveatSpecificationConstraint;
|
|
118
|
+
rpcOrigin: import("@metamask/permission-controller").CaveatSpecificationConstraint;
|
|
119
|
+
transactionOrigin: import("@metamask/permission-controller").CaveatSpecificationConstraint;
|
|
120
|
+
snapCronjob: import("@metamask/permission-controller").CaveatSpecificationConstraint;
|
|
121
|
+
};
|
|
122
|
+
export declare const endowmentCaveatMappers: Record<string, (value: Json) => Pick<PermissionConstraint, 'caveats'>>;
|
|
123
|
+
export declare const handlerEndowments: Record<HandlerType, string | null>;
|
|
124
|
+
export * from './enum';
|
|
125
|
+
export { getRpcCaveatOrigins } from './rpc';
|
|
126
|
+
export { getSignatureOriginCaveat } from './signature-insight';
|
|
127
|
+
export { getTransactionOriginCaveat } from './transaction-insight';
|
|
128
|
+
export { getChainIdsCaveat, getLookupMatchersCaveat } from './name-lookup';
|
|
129
|
+
export { getKeyringCaveatOrigins } from './keyring';
|
|
130
|
+
export { getMaxRequestTimeCaveat } from './caveats';
|
|
131
|
+
export { getCronjobCaveatJobs } from './cronjob';
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import type { CaveatSpecificationConstraint, EndowmentGetterParams, PermissionConstraint, PermissionSpecificationBuilder, PermissionValidatorConstraint } from '@metamask/permission-controller';
|
|
2
|
+
import { PermissionType, SubjectType } from '@metamask/permission-controller';
|
|
3
|
+
import type { KeyringOrigins } from '@metamask/snaps-utils';
|
|
4
|
+
import { SnapCaveatType } from '@metamask/snaps-utils';
|
|
5
|
+
import type { Json, NonEmptyArray } from '@metamask/utils';
|
|
6
|
+
import { SnapEndowments } from './enum';
|
|
7
|
+
declare const permissionName = SnapEndowments.Keyring;
|
|
8
|
+
export declare const keyringEndowmentBuilder: Readonly<{
|
|
9
|
+
readonly targetName: SnapEndowments.Keyring;
|
|
10
|
+
readonly specificationBuilder: PermissionSpecificationBuilder<PermissionType.Endowment, any, {
|
|
11
|
+
permissionType: PermissionType.Endowment;
|
|
12
|
+
targetName: typeof permissionName;
|
|
13
|
+
endowmentGetter: (_options?: EndowmentGetterParams) => undefined;
|
|
14
|
+
allowedCaveats: Readonly<NonEmptyArray<string>> | null;
|
|
15
|
+
validator: PermissionValidatorConstraint;
|
|
16
|
+
subjectTypes: readonly SubjectType[];
|
|
17
|
+
}>;
|
|
18
|
+
}>;
|
|
19
|
+
/**
|
|
20
|
+
* Map a raw value from the `initialPermissions` to a caveat specification.
|
|
21
|
+
* Note that this function does not do any validation, that's handled by the
|
|
22
|
+
* PermissionsController when the permission is requested.
|
|
23
|
+
*
|
|
24
|
+
* @param value - The raw value from the `initialPermissions`.
|
|
25
|
+
* @returns The caveat specification.
|
|
26
|
+
*/
|
|
27
|
+
export declare function getKeyringCaveatMapper(value: Json): Pick<PermissionConstraint, 'caveats'>;
|
|
28
|
+
/**
|
|
29
|
+
* Getter function to get the {@link KeyringOrigins} caveat value from a
|
|
30
|
+
* permission.
|
|
31
|
+
*
|
|
32
|
+
* @param permission - The permission to get the caveat value from.
|
|
33
|
+
* @returns The caveat value.
|
|
34
|
+
* @throws If the permission does not have a valid {@link KeyringOrigins}
|
|
35
|
+
* caveat.
|
|
36
|
+
*/
|
|
37
|
+
export declare function getKeyringCaveatOrigins(permission?: PermissionConstraint): KeyringOrigins | null;
|
|
38
|
+
export declare const keyringCaveatSpecifications: Record<SnapCaveatType.KeyringOrigin, CaveatSpecificationConstraint>;
|
|
39
|
+
export {};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { PermissionSpecificationBuilder, EndowmentGetterParams } from '@metamask/permission-controller';
|
|
2
|
+
import { PermissionType } from '@metamask/permission-controller';
|
|
3
|
+
import type { NonEmptyArray } from '@metamask/utils';
|
|
4
|
+
import { SnapEndowments } from './enum';
|
|
5
|
+
declare const permissionName = SnapEndowments.LifecycleHooks;
|
|
6
|
+
export declare const lifecycleHooksEndowmentBuilder: Readonly<{
|
|
7
|
+
readonly targetName: SnapEndowments.LifecycleHooks;
|
|
8
|
+
readonly specificationBuilder: PermissionSpecificationBuilder<PermissionType.Endowment, any, {
|
|
9
|
+
permissionType: PermissionType.Endowment;
|
|
10
|
+
targetName: typeof permissionName;
|
|
11
|
+
endowmentGetter: (_options?: EndowmentGetterParams) => undefined;
|
|
12
|
+
allowedCaveats: Readonly<NonEmptyArray<string>> | null;
|
|
13
|
+
}>;
|
|
14
|
+
}>;
|
|
15
|
+
export {};
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import type { EndowmentGetterParams, PermissionSpecificationBuilder, PermissionValidatorConstraint, CaveatSpecificationConstraint, PermissionConstraint } from '@metamask/permission-controller';
|
|
2
|
+
import { PermissionType } from '@metamask/permission-controller';
|
|
3
|
+
import { SnapCaveatType } from '@metamask/snaps-utils';
|
|
4
|
+
import type { Json, NonEmptyArray } from '@metamask/utils';
|
|
5
|
+
import { SnapEndowments } from './enum';
|
|
6
|
+
declare const permissionName = SnapEndowments.NameLookup;
|
|
7
|
+
export declare const nameLookupEndowmentBuilder: Readonly<{
|
|
8
|
+
readonly targetName: SnapEndowments.NameLookup;
|
|
9
|
+
readonly specificationBuilder: PermissionSpecificationBuilder<PermissionType.Endowment, any, {
|
|
10
|
+
permissionType: PermissionType.Endowment;
|
|
11
|
+
targetName: typeof permissionName;
|
|
12
|
+
endowmentGetter: (_options?: EndowmentGetterParams) => undefined;
|
|
13
|
+
allowedCaveats: Readonly<NonEmptyArray<string>> | null;
|
|
14
|
+
validator: PermissionValidatorConstraint;
|
|
15
|
+
}>;
|
|
16
|
+
}>;
|
|
17
|
+
/**
|
|
18
|
+
* Map a raw value from the `initialPermissions` to a caveat specification.
|
|
19
|
+
* Note that this function does not do any validation, that's handled by the
|
|
20
|
+
* PermissionsController when the permission is requested.
|
|
21
|
+
*
|
|
22
|
+
* @param value - The raw value from the `initialPermissions`.
|
|
23
|
+
* @returns The caveat specification.
|
|
24
|
+
*/
|
|
25
|
+
export declare function getNameLookupCaveatMapper(value: Json): Pick<PermissionConstraint, 'caveats'>;
|
|
26
|
+
/**
|
|
27
|
+
* Getter function to get the chainIds caveat from a permission.
|
|
28
|
+
*
|
|
29
|
+
* This does basic validation of the caveat, but does not validate the type or
|
|
30
|
+
* value of the namespaces object itself, as this is handled by the
|
|
31
|
+
* `PermissionsController` when the permission is requested.
|
|
32
|
+
*
|
|
33
|
+
* @param permission - The permission to get the `chainIds` caveat from.
|
|
34
|
+
* @returns An array of `chainIds` that the snap supports.
|
|
35
|
+
*/
|
|
36
|
+
export declare function getChainIdsCaveat(permission?: PermissionConstraint): string[] | null;
|
|
37
|
+
/**
|
|
38
|
+
* Getter function to get the matchers caveat from a permission.
|
|
39
|
+
*
|
|
40
|
+
* This does basic validation of the caveat, but does not validate the type or
|
|
41
|
+
* value of the namespaces object itself, as this is handled by the
|
|
42
|
+
* `PermissionsController` when the permission is requested.
|
|
43
|
+
*
|
|
44
|
+
* @param permission - The permission to get the `matchers` caveat from.
|
|
45
|
+
* @returns A `matchers` object that defines the input that the snap supports.
|
|
46
|
+
*/
|
|
47
|
+
export declare function getLookupMatchersCaveat(permission?: PermissionConstraint): Record<string, string[]> | null;
|
|
48
|
+
export declare const nameLookupCaveatSpecifications: Record<SnapCaveatType.ChainIds | SnapCaveatType.LookupMatchers, CaveatSpecificationConstraint>;
|
|
49
|
+
export {};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { PermissionSpecificationBuilder } from '@metamask/permission-controller';
|
|
2
|
+
import { PermissionType } from '@metamask/permission-controller';
|
|
3
|
+
import { SnapEndowments } from './enum';
|
|
4
|
+
declare const permissionName = SnapEndowments.NetworkAccess;
|
|
5
|
+
export declare const networkAccessEndowmentBuilder: Readonly<{
|
|
6
|
+
readonly targetName: SnapEndowments.NetworkAccess;
|
|
7
|
+
readonly specificationBuilder: PermissionSpecificationBuilder<PermissionType.Endowment, any, {
|
|
8
|
+
permissionType: PermissionType.Endowment;
|
|
9
|
+
targetName: typeof permissionName;
|
|
10
|
+
endowmentGetter: (_options?: any) => ['fetch', 'Request', 'Headers', 'Response'];
|
|
11
|
+
allowedCaveats: null;
|
|
12
|
+
}>;
|
|
13
|
+
}>;
|
|
14
|
+
export {};
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import type { CaveatSpecificationConstraint, PermissionConstraint, PermissionSpecificationBuilder, PermissionValidatorConstraint } from '@metamask/permission-controller';
|
|
2
|
+
import { PermissionType, SubjectType } from '@metamask/permission-controller';
|
|
3
|
+
import type { RpcOrigins } from '@metamask/snaps-utils';
|
|
4
|
+
import { SnapCaveatType } from '@metamask/snaps-utils';
|
|
5
|
+
import type { Json, NonEmptyArray } from '@metamask/utils';
|
|
6
|
+
import { SnapEndowments } from './enum';
|
|
7
|
+
declare const targetName = SnapEndowments.Rpc;
|
|
8
|
+
declare type RpcSpecificationBuilderOptions = {};
|
|
9
|
+
export declare const rpcEndowmentBuilder: Readonly<{
|
|
10
|
+
readonly targetName: SnapEndowments.Rpc;
|
|
11
|
+
readonly specificationBuilder: PermissionSpecificationBuilder<PermissionType.Endowment, RpcSpecificationBuilderOptions, {
|
|
12
|
+
permissionType: PermissionType.Endowment;
|
|
13
|
+
targetName: typeof targetName;
|
|
14
|
+
endowmentGetter: (_options?: any) => undefined;
|
|
15
|
+
allowedCaveats: Readonly<NonEmptyArray<string>> | null;
|
|
16
|
+
validator: PermissionValidatorConstraint;
|
|
17
|
+
subjectTypes: readonly SubjectType[];
|
|
18
|
+
}>;
|
|
19
|
+
}>;
|
|
20
|
+
/**
|
|
21
|
+
* Map a raw value from the `initialPermissions` to a caveat specification.
|
|
22
|
+
* Note that this function does not do any validation, that's handled by the
|
|
23
|
+
* PermissionsController when the permission is requested.
|
|
24
|
+
*
|
|
25
|
+
* @param value - The raw value from the `initialPermissions`.
|
|
26
|
+
* @returns The caveat specification.
|
|
27
|
+
*/
|
|
28
|
+
export declare function getRpcCaveatMapper(value: Json): Pick<PermissionConstraint, 'caveats'>;
|
|
29
|
+
/**
|
|
30
|
+
* Getter function to get the {@link RpcOrigins} caveat value from a permission.
|
|
31
|
+
*
|
|
32
|
+
* @param permission - The permission to get the caveat value from.
|
|
33
|
+
* @returns The caveat value.
|
|
34
|
+
* @throws If the permission does not have a valid {@link RpcOrigins} caveat.
|
|
35
|
+
*/
|
|
36
|
+
export declare function getRpcCaveatOrigins(permission?: PermissionConstraint): RpcOrigins | null;
|
|
37
|
+
export declare const rpcCaveatSpecifications: Record<SnapCaveatType.RpcOrigin, CaveatSpecificationConstraint>;
|
|
38
|
+
export {};
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import type { PermissionSpecificationBuilder, EndowmentGetterParams, PermissionValidatorConstraint, PermissionConstraint, CaveatSpecificationConstraint } from '@metamask/permission-controller';
|
|
2
|
+
import { PermissionType } from '@metamask/permission-controller';
|
|
3
|
+
import { SnapCaveatType } from '@metamask/snaps-utils';
|
|
4
|
+
import type { Json, NonEmptyArray } from '@metamask/utils';
|
|
5
|
+
import { SnapEndowments } from './enum';
|
|
6
|
+
declare const permissionName = SnapEndowments.SignatureInsight;
|
|
7
|
+
export declare const signatureInsightEndowmentBuilder: Readonly<{
|
|
8
|
+
readonly targetName: SnapEndowments.SignatureInsight;
|
|
9
|
+
readonly specificationBuilder: PermissionSpecificationBuilder<PermissionType.Endowment, any, {
|
|
10
|
+
permissionType: PermissionType.Endowment;
|
|
11
|
+
targetName: typeof permissionName;
|
|
12
|
+
endowmentGetter: (_options?: EndowmentGetterParams) => undefined;
|
|
13
|
+
allowedCaveats: Readonly<NonEmptyArray<string>> | null;
|
|
14
|
+
validator: PermissionValidatorConstraint;
|
|
15
|
+
}>;
|
|
16
|
+
}>;
|
|
17
|
+
/**
|
|
18
|
+
* Map a raw value from the `initialPermissions` to a caveat specification.
|
|
19
|
+
* Note that this function does not do any validation, that's handled by the
|
|
20
|
+
* PermissionController when the permission is requested.
|
|
21
|
+
*
|
|
22
|
+
* @param value - The raw value from the `initialPermissions`.
|
|
23
|
+
* @returns The caveat specification.
|
|
24
|
+
*/
|
|
25
|
+
export declare function getSignatureInsightCaveatMapper(value: Json): Pick<PermissionConstraint, 'caveats'>;
|
|
26
|
+
/**
|
|
27
|
+
* Getter function to get the signature origin caveat from a permission.
|
|
28
|
+
*
|
|
29
|
+
* This does basic validation of the caveat, but does not validate the type or
|
|
30
|
+
* value of the namespaces object itself, as this is handled by the
|
|
31
|
+
* `PermissionsController` when the permission is requested.
|
|
32
|
+
*
|
|
33
|
+
* @param permission - The permission to get the signature origin caveat from.
|
|
34
|
+
* @returns The signature origin, or `null` if the permission does not have a
|
|
35
|
+
* signature origin caveat.
|
|
36
|
+
*/
|
|
37
|
+
export declare function getSignatureOriginCaveat(permission?: PermissionConstraint): boolean | null;
|
|
38
|
+
export declare const signatureInsightCaveatSpecifications: Record<SnapCaveatType.SignatureOrigin, CaveatSpecificationConstraint>;
|
|
39
|
+
export {};
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import type { PermissionSpecificationBuilder, EndowmentGetterParams, PermissionValidatorConstraint, PermissionConstraint, CaveatSpecificationConstraint } from '@metamask/permission-controller';
|
|
2
|
+
import { PermissionType } from '@metamask/permission-controller';
|
|
3
|
+
import { SnapCaveatType } from '@metamask/snaps-utils';
|
|
4
|
+
import type { Json, NonEmptyArray } from '@metamask/utils';
|
|
5
|
+
import { SnapEndowments } from './enum';
|
|
6
|
+
declare const permissionName = SnapEndowments.TransactionInsight;
|
|
7
|
+
export declare const transactionInsightEndowmentBuilder: Readonly<{
|
|
8
|
+
readonly targetName: SnapEndowments.TransactionInsight;
|
|
9
|
+
readonly specificationBuilder: PermissionSpecificationBuilder<PermissionType.Endowment, any, {
|
|
10
|
+
permissionType: PermissionType.Endowment;
|
|
11
|
+
targetName: typeof permissionName;
|
|
12
|
+
endowmentGetter: (_options?: EndowmentGetterParams) => undefined;
|
|
13
|
+
allowedCaveats: Readonly<NonEmptyArray<string>> | null;
|
|
14
|
+
validator: PermissionValidatorConstraint;
|
|
15
|
+
}>;
|
|
16
|
+
}>;
|
|
17
|
+
/**
|
|
18
|
+
* Map a raw value from the `initialPermissions` to a caveat specification.
|
|
19
|
+
* Note that this function does not do any validation, that's handled by the
|
|
20
|
+
* PermissionsController when the permission is requested.
|
|
21
|
+
*
|
|
22
|
+
* @param value - The raw value from the `initialPermissions`.
|
|
23
|
+
* @returns The caveat specification.
|
|
24
|
+
*/
|
|
25
|
+
export declare function getTransactionInsightCaveatMapper(value: Json): Pick<PermissionConstraint, 'caveats'>;
|
|
26
|
+
/**
|
|
27
|
+
* Getter function to get the transaction origin caveat from a permission.
|
|
28
|
+
*
|
|
29
|
+
* This does basic validation of the caveat, but does not validate the type or
|
|
30
|
+
* value of the namespaces object itself, as this is handled by the
|
|
31
|
+
* `PermissionsController` when the permission is requested.
|
|
32
|
+
*
|
|
33
|
+
* @param permission - The permission to get the transaction origin caveat from.
|
|
34
|
+
* @returns The transaction origin, or `null` if the permission does not have a
|
|
35
|
+
* transaction origin caveat.
|
|
36
|
+
*/
|
|
37
|
+
export declare function getTransactionOriginCaveat(permission?: PermissionConstraint): boolean | null;
|
|
38
|
+
export declare const transactionInsightCaveatSpecifications: Record<SnapCaveatType.TransactionOrigin, CaveatSpecificationConstraint>;
|
|
39
|
+
export {};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { PermissionSpecificationBuilder } from '@metamask/permission-controller';
|
|
2
|
+
import { PermissionType } from '@metamask/permission-controller';
|
|
3
|
+
import { SnapEndowments } from './enum';
|
|
4
|
+
declare const permissionName = SnapEndowments.WebAssemblyAccess;
|
|
5
|
+
export declare const webAssemblyEndowmentBuilder: Readonly<{
|
|
6
|
+
readonly targetName: SnapEndowments.WebAssemblyAccess;
|
|
7
|
+
readonly specificationBuilder: PermissionSpecificationBuilder<PermissionType.Endowment, any, {
|
|
8
|
+
permissionType: PermissionType.Endowment;
|
|
9
|
+
targetName: typeof permissionName;
|
|
10
|
+
endowmentGetter: (_options?: any) => ['WebAssembly'];
|
|
11
|
+
allowedCaveats: null;
|
|
12
|
+
}>;
|
|
13
|
+
}>;
|
|
14
|
+
export {};
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
|
-
export type { PermittedRpcMethodHooks } from './permitted';
|
|
2
1
|
export { handlers as permittedMethods, createSnapsMethodMiddleware, } from './permitted';
|
|
3
|
-
export
|
|
2
|
+
export type { PermittedRpcMethodHooks } from './permitted';
|
|
4
3
|
export { SnapCaveatType } from '@metamask/snaps-utils';
|
|
5
4
|
export { selectHooks } from './utils';
|
|
5
|
+
export * from './endowments';
|
|
6
|
+
export * from './permissions';
|
|
7
|
+
export * from './restricted';
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { PermissionConstraint, PermissionSpecificationConstraint } from '@metamask/permission-controller';
|
|
2
|
+
import type { SnapPermissions } from '@metamask/snaps-utils';
|
|
3
|
+
/**
|
|
4
|
+
* Map initial permissions as defined in a Snap manifest to something that can
|
|
5
|
+
* be processed by the PermissionsController. Each caveat mapping function
|
|
6
|
+
* should return a valid permission caveat value.
|
|
7
|
+
*
|
|
8
|
+
* This function does not validate the caveat values, since that is done by
|
|
9
|
+
* the PermissionsController itself, upon requesting the permissions.
|
|
10
|
+
*
|
|
11
|
+
* @param initialPermissions - The initial permissions to process.
|
|
12
|
+
* @returns The processed permissions.
|
|
13
|
+
*/
|
|
14
|
+
export declare function processSnapPermissions(initialPermissions: SnapPermissions): Record<string, Pick<PermissionConstraint, 'caveats'>>;
|
|
15
|
+
export declare const buildSnapEndowmentSpecifications: (excludedEndowments: string[]) => Record<string, PermissionSpecificationConstraint>;
|
|
16
|
+
export declare const buildSnapRestrictedMethodSpecifications: (excludedPermissions: string[], hooks: Record<string, unknown>) => Record<string, PermissionSpecificationConstraint>;
|