(
extensionId: string
)
| 53 | } |
| 54 | |
| 55 | async function requestKernelAccessImpl( |
| 56 | extensionId: string |
| 57 | ): Promise<{ result: 'allowed' | 'denied' | 'learnMore' | 'cancelled' }> { |
| 58 | const accessInfo = await getAccessForExtensionsFromStore(); |
| 59 | if (accessInfo.get(extensionId) === true) { |
| 60 | return { result: 'allowed' }; |
| 61 | } |
| 62 | if (accessInfo.get(extensionId) === false) { |
| 63 | logger.warn(`Kernel API access already revoked for extension ${extensionId}`); |
| 64 | return { result: 'denied' }; |
| 65 | } |
| 66 | const displayName = extensions.getExtension(extensionId)?.packageJSON?.displayName; |
| 67 | if (!displayName) { |
| 68 | logger.error(`Kernel API access revoked, as extension ${extensionId} does not exist!`); |
| 69 | return { result: 'denied' }; |
| 70 | } |
| 71 | const allow = l10n.t('Allow'); |
| 72 | const deny = l10n.t('Deny'); |
| 73 | const result = await window.showInformationMessage( |
| 74 | l10n.t('Do you want to grant Kernel access to the extension {0} ({1})?', displayName, extensionId), |
| 75 | { |
| 76 | modal: true, |
| 77 | detail: l10n.t('This allows the extension to execute code against Jupyter Kernels.') |
| 78 | }, |
| 79 | allow, |
| 80 | Common.learnMore, |
| 81 | deny |
| 82 | ); |
| 83 | |
| 84 | if (result === Common.learnMore) { |
| 85 | env.openExternal(Uri.parse('https://aka.ms/vscodeJupyterKernelApiAccess')).then(noop, noop); |
| 86 | } else if (result === allow || result === deny) { |
| 87 | await updateIndividualExtensionAccessInStore(extensionId, result === allow); |
| 88 | } |
| 89 | switch (result) { |
| 90 | case allow: |
| 91 | return { result: 'allowed' }; |
| 92 | case Common.learnMore: |
| 93 | return { result: 'learnMore' }; |
| 94 | case deny: { |
| 95 | logger.error(`Kernel API access revoked for extension ${extensionId}`); |
| 96 | return { result: 'denied' }; |
| 97 | } |
| 98 | default: |
| 99 | return { result: 'cancelled' }; |
| 100 | } |
| 101 | } |
| 102 | |
| 103 | export async function getExtensionAccessListForManagement() { |
| 104 | const extensionsWithoutAccess = new Set<string>(); |
no test coverage detected