1/* 2 * Copyright (c) 2023 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16let ExtensionContext = requireNapi('application.ExtensionContext'); 17let Caller = requireNapi('application.Caller'); 18 19const ERROR_CODE_INVALID_PARAM = 401; 20const ERROR_MSG_INVALID_PARAM = 'Invalid input parameter.'; 21class ParamError extends Error { 22 constructor() { 23 super(ERROR_MSG_INVALID_PARAM); 24 this.code = ERROR_CODE_INVALID_PARAM; 25 } 26} 27 28class VpnExtensionContext extends ExtensionContext { 29 constructor(obj) { 30 super(obj); 31 } 32 startVpnExtensionAbility(want, callback) { 33 console.log('startVpnExtensionAbility'); 34 return this.__context_impl__.startVpnExtensionAbility(want, callback); 35 } 36 37 38 stopVpnExtensionAbility(want, callback) { 39 console.log('stopVpnExtensionAbility'); 40 return this.__context_impl__.stopVpnExtensionAbility(want, callback); 41 } 42 43} 44 45export default VpnExtensionContext; 46