• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1/*
2 * Copyright (c) 2021 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
16import { hasComplete } from "../utils"
17
18export function mockCipher() {
19
20  const CipherResponse = {
21	text: '[PC preview] unknow text',
22  }
23  const CipherRsaOptions = {
24	action: '[PC preview] unknow action',
25	text: '[PC preview] unknow text',
26	key: '[PC preview] unknow key',
27	transformation: '[PC preview] unknow ransformation',
28	success: '[PC preview] unknow success',
29	fail: '[PC preview] unknow fail',
30	complete: '[PC preview] unknow complete',
31  }
32  const CipherAesOptions = {
33	action: '[PC preview] unknow action',
34	text: '[PC preview] unknow text',
35	key: '[PC preview] unknow key',
36	transformation: '[PC preview] unknow transformation',
37	iv: '[PC preview] unknow iv',
38	ivOffset: '[PC preview] unknow ivOffset',
39	ivLen: '[PC preview] unknow ivLen',
40	success: '[PC preview] unknow success',
41	fail: '[PC preview] unknow fail',
42	complete: '[PC preview] unknow complete',
43  }
44  const Cipher = {
45    rsa: function (...args) {
46      console.warn("cipher.rsa interface mocked in the Previewer. How this interface works on the Previewer may be" +
47        " different from that on a real device.")
48      const result = '[PC preview] rsa xxxxxxxxxxxxx'
49      args[0].success(result)
50      hasComplete(args[0].complete)
51    },
52    aes: function (...args) {
53      console.warn("cipher.aes interface mocked in the Previewer. How this interface works on the Previewer may be" +
54        " different from that on a real device.")
55      const result = '[PC preview] aes xxxxxxxxxxxxx'
56      args[0].success(result)
57      hasComplete(args[0].complete)
58    },
59  }
60  return cipher
61}