@rabby-wallet/rabby-api 0.9.21 → 0.9.23-beta.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.
@@ -1,19 +1,19 @@
1
- import type { AxiosRequestConfig } from 'axios';
2
- export declare type InitOptions = {
3
- /**
4
- * @deprecated legacy option, don't need to use it anymore
5
- */
6
- webHf?: string;
7
- };
8
- export interface RabbyApiPlugin {
9
- onInitiateAsync?: (options?: InitOptions) => Promise<void>;
10
- onInitiate?: (options?: InitOptions) => Promise<void>;
11
- onSignRequest: (ctx: {
12
- axiosRequestConfig: AxiosRequestConfig<any>;
13
- parsed: {
14
- params: any;
15
- method: string;
16
- url: string;
17
- };
18
- }) => Promise<void>;
19
- }
1
+ import type { AxiosRequestConfig } from 'axios';
2
+ export declare type InitOptions = {
3
+ /**
4
+ * @deprecated legacy option, don't need to use it anymore
5
+ */
6
+ webHf?: string;
7
+ };
8
+ export interface RabbyApiPlugin {
9
+ onInitiateAsync?: (options?: InitOptions) => Promise<void>;
10
+ onInitiate?: (options?: InitOptions) => Promise<void>;
11
+ onSignRequest: (ctx: {
12
+ axiosRequestConfig: AxiosRequestConfig<any>;
13
+ parsed: {
14
+ params: any;
15
+ method: string;
16
+ url: string;
17
+ };
18
+ }) => Promise<void>;
19
+ }
@@ -1 +1 @@
1
- export {};
1
+ export {};
@@ -1,2 +1,2 @@
1
- import { RabbyApiPlugin } from './intf';
2
- export declare const WebSignApiPlugin: RabbyApiPlugin;
1
+ import { RabbyApiPlugin } from './intf';
2
+ export declare const WebSignApiPlugin: RabbyApiPlugin;
@@ -1,39 +1,39 @@
1
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
- return new (P || (P = Promise))(function (resolve, reject) {
4
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
- step((generator = generator.apply(thisArg, _arguments || [])).next());
8
- });
9
- };
10
- import * as sign from '@rabby-wallet/rabby-sign/umd/sign-wasm-rabby';
11
- import { SIGN_HDS } from '../const';
12
- function getWebHf() {
13
- var _a, _b, _c, _d;
14
- const hf = typeof chrome === 'undefined'
15
- ? ''
16
- : ((_b = (_a = chrome === null || chrome === void 0 ? void 0 : chrome.runtime) === null || _a === void 0 ? void 0 : _a.getURL) === null || _b === void 0 ? void 0 : _b.call(_a, 'bridge.html')) ||
17
- ((_d = (_c = chrome === null || chrome === void 0 ? void 0 : chrome.extension) === null || _c === void 0 ? void 0 : _c.getURL) === null || _d === void 0 ? void 0 : _d.call(_c, 'bridge.html')) ||
18
- '';
19
- return hf;
20
- }
21
- export const WebSignApiPlugin = {
22
- onInitiateAsync(options) {
23
- return __awaiter(this, void 0, void 0, function* () {
24
- yield sign.lW((options === null || options === void 0 ? void 0 : options.webHf) || getWebHf());
25
- });
26
- },
27
- onSignRequest(ctx) {
28
- return __awaiter(this, void 0, void 0, function* () {
29
- const { parsed, axiosRequestConfig: config } = ctx;
30
- const { method, url, params } = parsed;
31
- const res = sign.cattleGsW(params, method, url);
32
- config.headers = config.headers || {};
33
- config.headers[SIGN_HDS[0]] = encodeURIComponent(res.ts);
34
- config.headers[SIGN_HDS[1]] = encodeURIComponent(res.nonce);
35
- config.headers[SIGN_HDS[2]] = encodeURIComponent(res.version);
36
- config.headers[SIGN_HDS[3]] = encodeURIComponent(res.signature);
37
- });
38
- },
39
- };
1
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
+ return new (P || (P = Promise))(function (resolve, reject) {
4
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
8
+ });
9
+ };
10
+ import * as sign from '@rabby-wallet/rabby-sign/umd/sign-wasm-rabby';
11
+ import { SIGN_HDS } from '../const';
12
+ function getWebHf() {
13
+ var _a, _b, _c, _d;
14
+ const hf = typeof chrome === 'undefined'
15
+ ? ''
16
+ : ((_b = (_a = chrome === null || chrome === void 0 ? void 0 : chrome.runtime) === null || _a === void 0 ? void 0 : _a.getURL) === null || _b === void 0 ? void 0 : _b.call(_a, 'bridge.html')) ||
17
+ ((_d = (_c = chrome === null || chrome === void 0 ? void 0 : chrome.extension) === null || _c === void 0 ? void 0 : _c.getURL) === null || _d === void 0 ? void 0 : _d.call(_c, 'bridge.html')) ||
18
+ '';
19
+ return hf;
20
+ }
21
+ export const WebSignApiPlugin = {
22
+ onInitiateAsync(options) {
23
+ return __awaiter(this, void 0, void 0, function* () {
24
+ yield sign.lW((options === null || options === void 0 ? void 0 : options.webHf) || getWebHf());
25
+ });
26
+ },
27
+ onSignRequest(ctx) {
28
+ return __awaiter(this, void 0, void 0, function* () {
29
+ const { parsed, axiosRequestConfig: config } = ctx;
30
+ const { method, url, params } = parsed;
31
+ const res = sign.cattleGsW(params, method, url);
32
+ config.headers = config.headers || {};
33
+ config.headers[SIGN_HDS[0]] = encodeURIComponent(res.ts);
34
+ config.headers[SIGN_HDS[1]] = encodeURIComponent(res.nonce);
35
+ config.headers[SIGN_HDS[2]] = encodeURIComponent(res.version);
36
+ config.headers[SIGN_HDS[3]] = encodeURIComponent(res.signature);
37
+ });
38
+ },
39
+ };