@portkey/onboarding 1.4.0-alpha.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.
Files changed (71) hide show
  1. package/LICENSE +674 -0
  2. package/README.md +39 -0
  3. package/dist/commonjs/browser.d.ts +5 -0
  4. package/dist/commonjs/browser.js +36 -0
  5. package/dist/commonjs/constants/index.d.ts +9 -0
  6. package/dist/commonjs/constants/index.js +12 -0
  7. package/dist/commonjs/evokeApp/evoke.d.ts +5 -0
  8. package/dist/commonjs/evokeApp/evoke.js +79 -0
  9. package/dist/commonjs/evokeApp/generate.d.ts +5 -0
  10. package/dist/commonjs/evokeApp/generate.js +62 -0
  11. package/dist/commonjs/evokeApp/index.d.ts +13 -0
  12. package/dist/commonjs/evokeApp/index.js +112 -0
  13. package/dist/commonjs/evokeApp/types.d.ts +37 -0
  14. package/dist/commonjs/evokeApp/types.js +2 -0
  15. package/dist/commonjs/evokePortkey/checkPortkeyExtension.d.ts +1 -0
  16. package/dist/commonjs/evokePortkey/checkPortkeyExtension.js +30 -0
  17. package/dist/commonjs/evokePortkey/evokePortkeyApp.d.ts +16 -0
  18. package/dist/commonjs/evokePortkey/evokePortkeyApp.js +32 -0
  19. package/dist/commonjs/evokePortkey/index.d.ts +2 -0
  20. package/dist/commonjs/evokePortkey/index.js +18 -0
  21. package/dist/commonjs/index.d.ts +3 -0
  22. package/dist/commonjs/index.js +32 -0
  23. package/dist/commonjs/package.json +1 -0
  24. package/dist/commonjs/utils/index.d.ts +1 -0
  25. package/dist/commonjs/utils/index.js +23 -0
  26. package/dist/esm/browser.d.ts +5 -0
  27. package/dist/esm/browser.js +31 -0
  28. package/dist/esm/constants/index.d.ts +9 -0
  29. package/dist/esm/constants/index.js +9 -0
  30. package/dist/esm/evokeApp/evoke.d.ts +5 -0
  31. package/dist/esm/evokeApp/evoke.js +72 -0
  32. package/dist/esm/evokeApp/generate.d.ts +5 -0
  33. package/dist/esm/evokeApp/generate.js +55 -0
  34. package/dist/esm/evokeApp/index.d.ts +13 -0
  35. package/dist/esm/evokeApp/index.js +85 -0
  36. package/dist/esm/evokeApp/types.d.ts +37 -0
  37. package/dist/esm/evokeApp/types.js +1 -0
  38. package/dist/esm/evokePortkey/checkPortkeyExtension.d.ts +1 -0
  39. package/dist/esm/evokePortkey/checkPortkeyExtension.js +26 -0
  40. package/dist/esm/evokePortkey/evokePortkeyApp.d.ts +16 -0
  41. package/dist/esm/evokePortkey/evokePortkeyApp.js +28 -0
  42. package/dist/esm/evokePortkey/index.d.ts +2 -0
  43. package/dist/esm/evokePortkey/index.js +2 -0
  44. package/dist/esm/index.d.ts +3 -0
  45. package/dist/esm/index.js +3 -0
  46. package/dist/esm/package.json +1 -0
  47. package/dist/esm/utils/index.d.ts +1 -0
  48. package/dist/esm/utils/index.js +16 -0
  49. package/dist/types/browser.d.ts +6 -0
  50. package/dist/types/browser.d.ts.map +1 -0
  51. package/dist/types/constants/index.d.ts +10 -0
  52. package/dist/types/constants/index.d.ts.map +1 -0
  53. package/dist/types/evokeApp/evoke.d.ts +6 -0
  54. package/dist/types/evokeApp/evoke.d.ts.map +1 -0
  55. package/dist/types/evokeApp/generate.d.ts +6 -0
  56. package/dist/types/evokeApp/generate.d.ts.map +1 -0
  57. package/dist/types/evokeApp/index.d.ts +14 -0
  58. package/dist/types/evokeApp/index.d.ts.map +1 -0
  59. package/dist/types/evokeApp/types.d.ts +38 -0
  60. package/dist/types/evokeApp/types.d.ts.map +1 -0
  61. package/dist/types/evokePortkey/checkPortkeyExtension.d.ts +2 -0
  62. package/dist/types/evokePortkey/checkPortkeyExtension.d.ts.map +1 -0
  63. package/dist/types/evokePortkey/evokePortkeyApp.d.ts +17 -0
  64. package/dist/types/evokePortkey/evokePortkeyApp.d.ts.map +1 -0
  65. package/dist/types/evokePortkey/index.d.ts +3 -0
  66. package/dist/types/evokePortkey/index.d.ts.map +1 -0
  67. package/dist/types/index.d.ts +4 -0
  68. package/dist/types/index.d.ts.map +1 -0
  69. package/dist/types/utils/index.d.ts +2 -0
  70. package/dist/types/utils/index.d.ts.map +1 -0
  71. package/package.json +49 -0
@@ -0,0 +1,9 @@
1
+ export const APP_DOWNLOAD_URL = {
2
+ APP_STORE: 'https://apps.apple.com/us/app/portkey-ca-wallet-crypto-nft/id6445808228',
3
+ CHROME_STORE: 'https://play.google.com/store/apps/details?id=com.portkey.did',
4
+ };
5
+ export const EXTENSION_DOWNLOAD_URL = {
6
+ CHROME: 'https://chrome.google.com/webstore/detail/portkey-did-crypto-nft/hpjiiechbbhefmpggegmahejiiphbmij',
7
+ EDGE: 'https://chrome.google.com/webstore/detail/portkey-did-crypto-nft/hpjiiechbbhefmpggegmahejiiphbmij',
8
+ DEFAULT: 'https://portkey.finance/download',
9
+ };
@@ -0,0 +1,5 @@
1
+ import { OpenStatus } from './types.js';
2
+ export declare function evokeByLocation(uri: string): void;
3
+ export declare function evokeByTagA(uri: string): void;
4
+ export declare function evokeByIFrame(uri: string): void;
5
+ export declare function checkOpen(callback: (status: OpenStatus) => void, timeout: number): void;
@@ -0,0 +1,72 @@
1
+ let hidden = 'hidden';
2
+ let visibilityChange = 'visibilitychange';
3
+ let iframe;
4
+ function getSupportedProperty() {
5
+ if (typeof document === 'undefined')
6
+ return;
7
+ if (typeof document.hidden !== 'undefined') {
8
+ hidden = 'hidden';
9
+ visibilityChange = 'visibilitychange';
10
+ }
11
+ else if (typeof document.msHidden !== 'undefined') {
12
+ hidden = 'msHidden';
13
+ visibilityChange = 'msvisibilitychange';
14
+ }
15
+ else if (typeof document.webkitHidden !== 'undefined') {
16
+ hidden = 'webkitHidden';
17
+ visibilityChange = 'webkitvisibilitychange';
18
+ }
19
+ }
20
+ getSupportedProperty();
21
+ function isPageHidden() {
22
+ if (typeof document === 'undefined')
23
+ return false;
24
+ if (typeof hidden === 'undefined')
25
+ return false;
26
+ return document[hidden];
27
+ }
28
+ export function evokeByLocation(uri) {
29
+ if (window.top)
30
+ window.top.location.href = uri;
31
+ else
32
+ window.location.href = uri;
33
+ }
34
+ export function evokeByTagA(uri) {
35
+ const tagA = document.createElement('a');
36
+ tagA.setAttribute('href', uri);
37
+ tagA.style.display = 'none';
38
+ document.body.appendChild(tagA);
39
+ tagA.click();
40
+ }
41
+ export function evokeByIFrame(uri) {
42
+ if (!iframe) {
43
+ iframe = document.createElement('iframe');
44
+ iframe.style.cssText = 'display:none;border:0;width:0;height:0;';
45
+ document.body.appendChild(iframe);
46
+ }
47
+ iframe.src = uri;
48
+ }
49
+ export function checkOpen(callback, timeout) {
50
+ const timer = setTimeout(() => {
51
+ const pageHidden = isPageHidden();
52
+ if (!pageHidden) {
53
+ callback('failure');
54
+ if (typeof visibilityChange !== 'undefined') {
55
+ document.removeEventListener(visibilityChange, visibilityListenHandler);
56
+ }
57
+ else {
58
+ window.removeEventListener('pagehide', visibilityListenHandler);
59
+ }
60
+ }
61
+ }, timeout);
62
+ const visibilityListenHandler = () => {
63
+ clearTimeout(timer);
64
+ callback('success');
65
+ };
66
+ if (typeof visibilityChange !== 'undefined') {
67
+ document.addEventListener(visibilityChange, visibilityListenHandler);
68
+ }
69
+ else {
70
+ window.addEventListener('pagehide', visibilityListenHandler);
71
+ }
72
+ }
@@ -0,0 +1,5 @@
1
+ import { EvokeAppConfig, EvokeAppOptions } from './types.js';
2
+ export declare function buildScheme(config: EvokeAppConfig, options: EvokeAppOptions): string;
3
+ export declare function generateScheme(config: EvokeAppConfig, options: EvokeAppOptions): string;
4
+ export declare function generateIntent(config: EvokeAppConfig, options: EvokeAppOptions): string;
5
+ export declare function generateUniversalLink(config: EvokeAppConfig, options: EvokeAppOptions): string;
@@ -0,0 +1,55 @@
1
+ import { stringifyUrl } from 'query-string';
2
+ export function buildScheme(config, options) {
3
+ const { path, param } = config;
4
+ const { scheme, buildScheme: customBuildScheme } = options;
5
+ if (typeof customBuildScheme !== 'undefined') {
6
+ return customBuildScheme(config, options);
7
+ }
8
+ const { domain, protocol } = scheme;
9
+ return stringifyUrl({
10
+ url: `${protocol}://${domain}/${path}`,
11
+ query: param,
12
+ }, { encode: true });
13
+ }
14
+ export function generateScheme(config, options) {
15
+ const { outChain } = options;
16
+ let uri = buildScheme(config, options);
17
+ if (typeof outChain !== 'undefined' && outChain) {
18
+ const { protocol, path, key } = outChain;
19
+ uri = `${protocol}://${path}?${key}=${encodeURIComponent(uri)}`;
20
+ }
21
+ return uri;
22
+ }
23
+ export function generateIntent(config, options) {
24
+ const { outChain } = options;
25
+ const { intent, fallback } = options;
26
+ if (typeof intent === 'undefined')
27
+ return '';
28
+ const keys = Object.keys(intent);
29
+ const intentParam = keys.map(key => `${key}=${intent[key]};`).join('');
30
+ const intentTail = `#Intent;${intentParam}S.browser_fallback_url=${encodeURIComponent(fallback || '')};end;`;
31
+ let urlPath = buildScheme(config, options);
32
+ if (typeof outChain !== 'undefined' && outChain) {
33
+ const { path, key } = outChain;
34
+ return `intent://${path}?${key}=${encodeURIComponent(urlPath)}${intentTail}`;
35
+ }
36
+ urlPath = urlPath.slice(urlPath.indexOf('//') + 2);
37
+ return `intent://${urlPath}${intentTail}`;
38
+ }
39
+ export function generateUniversalLink(config, options) {
40
+ const { universal } = options;
41
+ if (typeof universal === 'undefined')
42
+ return '';
43
+ const { domain, pathKey } = universal;
44
+ const { path, param } = config;
45
+ const protocol = 'https';
46
+ const newUniversalLink = stringifyUrl({
47
+ url: `${protocol}://${domain}/${path}`,
48
+ query: param,
49
+ }, { encode: true });
50
+ const oldUniversalLink = stringifyUrl({
51
+ url: `${protocol}://${domain}/${path}`,
52
+ query: pathKey ? Object.assign({ [pathKey]: path }, param) : param,
53
+ }, { encode: true });
54
+ return pathKey ? oldUniversalLink : newUniversalLink;
55
+ }
@@ -0,0 +1,13 @@
1
+ import { EvokeAppConfig, EvokeAppOptions } from './types.js';
2
+ export declare class EvokeApp {
3
+ private readonly options;
4
+ constructor(options: EvokeAppOptions);
5
+ generateScheme(config: EvokeAppConfig): string;
6
+ generateIntent(config: EvokeAppConfig): string;
7
+ generateUniversalLink(config: EvokeAppConfig): string;
8
+ checkOpen(): Promise<unknown>;
9
+ fallToAppStore(): void;
10
+ fallToFbUrl(): void;
11
+ fallToCustomCb(callback: () => void): void;
12
+ open(config: EvokeAppConfig): void;
13
+ }
@@ -0,0 +1,85 @@
1
+ import * as Browser from '../browser.js';
2
+ import { evokeByLocation, evokeByIFrame, checkOpen, evokeByTagA } from './evoke.js';
3
+ import * as generate from './generate.js';
4
+ export class EvokeApp {
5
+ constructor(options) {
6
+ const defaultOptions = { timeout: 4000 };
7
+ this.options = Object.assign(defaultOptions, options);
8
+ }
9
+ generateScheme(config) {
10
+ return generate.generateScheme(config, this.options);
11
+ }
12
+ generateIntent(config) {
13
+ return generate.generateIntent(config, this.options);
14
+ }
15
+ generateUniversalLink(config) {
16
+ return generate.generateUniversalLink(config, this.options);
17
+ }
18
+ checkOpen() {
19
+ const { logFunc, timeout } = this.options;
20
+ return new Promise((resolve, reject) => {
21
+ checkOpen(status => {
22
+ logFunc === null || logFunc === void 0 ? void 0 : logFunc(status);
23
+ if (status === 'success')
24
+ return resolve(status);
25
+ reject(status);
26
+ }, timeout);
27
+ });
28
+ }
29
+ fallToAppStore() {
30
+ this.checkOpen().catch(() => evokeByLocation(this.options.appStore));
31
+ }
32
+ fallToFbUrl() {
33
+ this.checkOpen().catch(() => {
34
+ if (!this.options.fallback)
35
+ return;
36
+ evokeByLocation(this.options.fallback);
37
+ });
38
+ }
39
+ fallToCustomCb(callback) {
40
+ this.checkOpen().catch(callback);
41
+ }
42
+ open(config) {
43
+ const { universal, logFunc, intent } = this.options;
44
+ const { callback } = config;
45
+ const supportUniversal = typeof universal !== 'undefined';
46
+ const schemeURL = this.generateScheme(config);
47
+ let checkOpenFall;
48
+ if (typeof logFunc !== 'undefined') {
49
+ logFunc('pending');
50
+ }
51
+ if (Browser.isIos) {
52
+ if (Browser.getIOSVersion() < 9) {
53
+ evokeByIFrame(schemeURL);
54
+ checkOpenFall = this.fallToAppStore;
55
+ }
56
+ else if (!supportUniversal) {
57
+ evokeByTagA(schemeURL);
58
+ checkOpenFall = this.fallToAppStore;
59
+ }
60
+ else {
61
+ evokeByLocation(this.generateUniversalLink(config));
62
+ }
63
+ }
64
+ else if (Browser.isOriginalChrome) {
65
+ if (typeof intent !== 'undefined') {
66
+ evokeByLocation(this.generateIntent(config));
67
+ }
68
+ else {
69
+ evokeByLocation(schemeURL);
70
+ checkOpenFall = this.fallToFbUrl;
71
+ }
72
+ }
73
+ else {
74
+ evokeByIFrame(schemeURL);
75
+ checkOpenFall = this.fallToFbUrl;
76
+ }
77
+ if (typeof callback !== 'undefined') {
78
+ this.fallToCustomCb(callback);
79
+ return;
80
+ }
81
+ if (!checkOpenFall)
82
+ return;
83
+ checkOpenFall.call(this);
84
+ }
85
+ }
@@ -0,0 +1,37 @@
1
+ import { StringifiableRecord } from 'query-string';
2
+ export interface EvokeAppConfig<Params = StringifiableRecord> {
3
+ path: string;
4
+ param?: Params;
5
+ callback?: () => void;
6
+ }
7
+ export interface EvokeAppOptions {
8
+ scheme: {
9
+ protocol: string;
10
+ domain: string;
11
+ };
12
+ outChain?: {
13
+ protocol: string;
14
+ path: string;
15
+ key: string;
16
+ };
17
+ intent?: Intent;
18
+ universal?: {
19
+ domain: string;
20
+ pathKey?: string;
21
+ };
22
+ appStore: string;
23
+ fallback?: string;
24
+ timeout?: number;
25
+ logFunc?: (status: 'pending' | 'failure' | 'success') => void;
26
+ buildScheme?: (config: EvokeAppConfig, options: EvokeAppOptions) => string;
27
+ }
28
+ export interface Intent {
29
+ package: string;
30
+ scheme: string;
31
+ action?: string;
32
+ category?: string;
33
+ component?: string;
34
+ }
35
+ export type Hidden = 'hidden' | 'webkitHidden' | 'msHidden' | undefined;
36
+ export type VisibilityChange = 'visibilitychange' | 'webkitvisibilitychange' | 'msvisibilitychange' | undefined;
37
+ export type OpenStatus = 'failure' | 'success';
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export declare const checkPortkeyExtension: () => Promise<boolean>;
@@ -0,0 +1,26 @@
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 { sleep } from '@portkey/utils';
11
+ import { detectBrowserName } from '../utils/index.js';
12
+ import { EXTENSION_DOWNLOAD_URL } from '../constants/index.js';
13
+ export const checkPortkeyExtension = () => __awaiter(void 0, void 0, void 0, function* () {
14
+ if (typeof window === 'undefined')
15
+ return false;
16
+ const _window = window;
17
+ if (_window.portkey)
18
+ return true;
19
+ yield sleep(1000);
20
+ if (_window.portkey)
21
+ return true;
22
+ const browserName = detectBrowserName();
23
+ const downloadURL = EXTENSION_DOWNLOAD_URL[browserName] || EXTENSION_DOWNLOAD_URL.DEFAULT;
24
+ _window.open(downloadURL, '_blank');
25
+ return false;
26
+ });
@@ -0,0 +1,16 @@
1
+ import { scheme as schemeUtils } from '@portkey/utils';
2
+ import { PartialOption } from '@portkey/types';
3
+ import { EvokeAppOptions } from '../evokeApp/types.js';
4
+ export interface IBaseEvokeAppOption {
5
+ timeout?: number;
6
+ customFailureCallback?: () => void;
7
+ onStatusChange?: EvokeAppOptions['logFunc'];
8
+ }
9
+ export type EvokePortkeyByLogin = PartialOption<Omit<schemeUtils.ILoginHandleSchemeParams, 'scheme'>, 'domain'> & IBaseEvokeAppOption;
10
+ type EvokePortkeyByLinkDapp = PartialOption<Omit<schemeUtils.ILinkDappHandleSchemeParams, 'scheme'>, 'domain'> & IBaseEvokeAppOption;
11
+ export interface IEvokePortkeyApp {
12
+ evokePortkeyApp(params: EvokePortkeyByLogin): void;
13
+ evokePortkeyApp(params: EvokePortkeyByLinkDapp): void;
14
+ }
15
+ export declare const evokePortkeyApp: IEvokePortkeyApp['evokePortkeyApp'];
16
+ export {};
@@ -0,0 +1,28 @@
1
+ import { scheme as schemeUtils } from '@portkey/utils';
2
+ import { EvokeApp } from '../evokeApp/index.js';
3
+ import { APP_DOWNLOAD_URL } from '../constants/index.js';
4
+ export const evokePortkeyApp = ({ domain, custom, action, timeout = 4000, customFailureCallback, onStatusChange, }) => {
5
+ const callLib = new EvokeApp({
6
+ scheme: {
7
+ protocol: schemeUtils.DID_APP_SCHEMA,
8
+ domain: domain || window.location.host,
9
+ },
10
+ timeout,
11
+ appStore: APP_DOWNLOAD_URL.APP_STORE,
12
+ fallback: APP_DOWNLOAD_URL.CHROME_STORE,
13
+ logFunc: onStatusChange,
14
+ buildScheme: (config, options) => {
15
+ return schemeUtils.formatScheme({
16
+ scheme: schemeUtils.DID_APP_SCHEMA,
17
+ action: action,
18
+ domain: options.scheme.domain,
19
+ custom: config.param,
20
+ });
21
+ },
22
+ });
23
+ callLib.open({
24
+ path: action,
25
+ param: custom,
26
+ callback: customFailureCallback,
27
+ });
28
+ };
@@ -0,0 +1,2 @@
1
+ export * from './evokePortkeyApp.js';
2
+ export * from './checkPortkeyExtension.js';
@@ -0,0 +1,2 @@
1
+ export * from './evokePortkeyApp.js';
2
+ export * from './checkPortkeyExtension.js';
@@ -0,0 +1,3 @@
1
+ export * from './evokeApp/index.js';
2
+ export * as Browser from './browser.js';
3
+ export * from './evokePortkey/index.js';
@@ -0,0 +1,3 @@
1
+ export * from './evokeApp/index.js';
2
+ export * as Browser from './browser.js';
3
+ export * from './evokePortkey/index.js';
@@ -0,0 +1 @@
1
+ {"type": "module"}
@@ -0,0 +1 @@
1
+ export declare const detectBrowserName: () => string;
@@ -0,0 +1,16 @@
1
+ import Bowser from 'bowser';
2
+ export const detectBrowserName = () => {
3
+ if (typeof navigator === 'undefined')
4
+ return '';
5
+ const browserInfo = Bowser.parse(window.navigator.userAgent);
6
+ if (browserInfo.browser.name === 'Firefox') {
7
+ return 'FIREFOX';
8
+ }
9
+ else if (['Chrome', 'Chromium'].includes(browserInfo.browser.name || '')) {
10
+ return 'CHROME';
11
+ }
12
+ else if (browserInfo.browser.name === 'Microsoft Edge') {
13
+ return 'EDGE';
14
+ }
15
+ return browserInfo.browser.name || '';
16
+ };
@@ -0,0 +1,6 @@
1
+ export declare const semverCompare: (verionA: string, versionB: string) => -1 | 0 | 1;
2
+ export declare const getIOSVersion: () => number;
3
+ export declare const isAndroid: boolean;
4
+ export declare const isIos: boolean;
5
+ export declare const isOriginalChrome: boolean;
6
+ //# sourceMappingURL=browser.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"browser.d.ts","sourceRoot":"","sources":["../../src/browser.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,aAAa,YAAa,MAAM,YAAY,MAAM,KAAG,CAAC,CAAC,GAAG,CAAC,GAAG,CAkB1E,CAAC;AAEF,eAAO,MAAM,aAAa,cAOzB,CAAC;AAEF,eAAO,MAAM,SAAS,SAAsB,CAAC;AAE7C,eAAO,MAAM,KAAK,SAA+B,CAAC;AAElD,eAAO,MAAM,gBAAgB,SAC+D,CAAC"}
@@ -0,0 +1,10 @@
1
+ export declare const APP_DOWNLOAD_URL: {
2
+ APP_STORE: string;
3
+ CHROME_STORE: string;
4
+ };
5
+ export declare const EXTENSION_DOWNLOAD_URL: {
6
+ CHROME: string;
7
+ EDGE: string;
8
+ DEFAULT: string;
9
+ };
10
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/constants/index.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,gBAAgB;;;CAG5B,CAAC;AACF,eAAO,MAAM,sBAAsB;;;;CAIlC,CAAC"}
@@ -0,0 +1,6 @@
1
+ import { OpenStatus } from './types';
2
+ export declare function evokeByLocation(uri: string): void;
3
+ export declare function evokeByTagA(uri: string): void;
4
+ export declare function evokeByIFrame(uri: string): void;
5
+ export declare function checkOpen(callback: (status: OpenStatus) => void, timeout: number): void;
6
+ //# sourceMappingURL=evoke.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"evoke.d.ts","sourceRoot":"","sources":["../../../src/evokeApp/evoke.ts"],"names":[],"mappings":"AAAA,OAAO,EAAU,UAAU,EAAoB,MAAM,SAAS,CAAC;AAqC/D,wBAAgB,eAAe,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,CAIjD;AAMD,wBAAgB,WAAW,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,CAQ7C;AAMD,wBAAgB,aAAa,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,CAQ/C;AAOD,wBAAgB,SAAS,CAAC,QAAQ,EAAE,CAAC,MAAM,EAAE,UAAU,KAAK,IAAI,EAAE,OAAO,EAAE,MAAM,GAAG,IAAI,CAuBvF"}
@@ -0,0 +1,6 @@
1
+ import { EvokeAppConfig, EvokeAppOptions } from './types';
2
+ export declare function buildScheme(config: EvokeAppConfig, options: EvokeAppOptions): string;
3
+ export declare function generateScheme(config: EvokeAppConfig, options: EvokeAppOptions): string;
4
+ export declare function generateIntent(config: EvokeAppConfig, options: EvokeAppOptions): string;
5
+ export declare function generateUniversalLink(config: EvokeAppConfig, options: EvokeAppOptions): string;
6
+ //# sourceMappingURL=generate.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"generate.d.ts","sourceRoot":"","sources":["../../../src/evokeApp/generate.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,eAAe,EAAU,MAAM,SAAS,CAAC;AAGlE,wBAAgB,WAAW,CAAC,MAAM,EAAE,cAAc,EAAE,OAAO,EAAE,eAAe,GAAG,MAAM,CAiBpF;AAGD,wBAAgB,cAAc,CAAC,MAAM,EAAE,cAAc,EAAE,OAAO,EAAE,eAAe,GAAG,MAAM,CAUvF;AAGD,wBAAgB,cAAc,CAAC,MAAM,EAAE,cAAc,EAAE,OAAO,EAAE,eAAe,GAAG,MAAM,CAkBvF;AAGD,wBAAgB,qBAAqB,CAAC,MAAM,EAAE,cAAc,EAAE,OAAO,EAAE,eAAe,GAAG,MAAM,CA0B9F"}
@@ -0,0 +1,14 @@
1
+ import { EvokeAppConfig, EvokeAppOptions } from './types';
2
+ export declare class EvokeApp {
3
+ private readonly options;
4
+ constructor(options: EvokeAppOptions);
5
+ generateScheme(config: EvokeAppConfig): string;
6
+ generateIntent(config: EvokeAppConfig): string;
7
+ generateUniversalLink(config: EvokeAppConfig): string;
8
+ checkOpen(): Promise<unknown>;
9
+ fallToAppStore(): void;
10
+ fallToFbUrl(): void;
11
+ fallToCustomCb(callback: () => void): void;
12
+ open(config: EvokeAppConfig): void;
13
+ }
14
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/evokeApp/index.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAE1D,qBAAa,QAAQ;IACnB,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAwC;gBAGpD,OAAO,EAAE,eAAe;IAS7B,cAAc,CAAC,MAAM,EAAE,cAAc,GAAG,MAAM;IAI9C,cAAc,CAAC,MAAM,EAAE,cAAc,GAAG,MAAM;IAI9C,qBAAqB,CAAC,MAAM,EAAE,cAAc,GAAG,MAAM;IAI5D,SAAS;IAYT,cAAc,IAAI,IAAI;IAKtB,WAAW,IAAI,IAAI;IAQnB,cAAc,CAAC,QAAQ,EAAE,MAAM,IAAI,GAAG,IAAI;IAQ1C,IAAI,CAAC,MAAM,EAAE,cAAc,GAAG,IAAI;CA2CnC"}
@@ -0,0 +1,38 @@
1
+ import { StringifiableRecord } from 'query-string';
2
+ export interface EvokeAppConfig<Params = StringifiableRecord> {
3
+ path: string;
4
+ param?: Params;
5
+ callback?: () => void;
6
+ }
7
+ export interface EvokeAppOptions {
8
+ scheme: {
9
+ protocol: string;
10
+ domain: string;
11
+ };
12
+ outChain?: {
13
+ protocol: string;
14
+ path: string;
15
+ key: string;
16
+ };
17
+ intent?: Intent;
18
+ universal?: {
19
+ domain: string;
20
+ pathKey?: string;
21
+ };
22
+ appStore: string;
23
+ fallback?: string;
24
+ timeout?: number;
25
+ logFunc?: (status: 'pending' | 'failure' | 'success') => void;
26
+ buildScheme?: (config: EvokeAppConfig, options: EvokeAppOptions) => string;
27
+ }
28
+ export interface Intent {
29
+ package: string;
30
+ scheme: string;
31
+ action?: string;
32
+ category?: string;
33
+ component?: string;
34
+ }
35
+ export type Hidden = 'hidden' | 'webkitHidden' | 'msHidden' | undefined;
36
+ export type VisibilityChange = 'visibilitychange' | 'webkitvisibilitychange' | 'msvisibilitychange' | undefined;
37
+ export type OpenStatus = 'failure' | 'success';
38
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/evokeApp/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC;AAEnD,MAAM,WAAW,cAAc,CAAC,MAAM,GAAG,mBAAmB;IAC1D,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,MAAM,IAAI,CAAC;CACvB;AAED,MAAM,WAAW,eAAe;IAC9B,MAAM,EAAE;QACN,QAAQ,EAAE,MAAM,CAAC;QACjB,MAAM,EAAE,MAAM,CAAC;KAChB,CAAC;IACF,QAAQ,CAAC,EAAE;QACT,QAAQ,EAAE,MAAM,CAAC;QACjB,IAAI,EAAE,MAAM,CAAC;QACb,GAAG,EAAE,MAAM,CAAC;KACb,CAAC;IACF,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,SAAS,CAAC,EAAE;QACV,MAAM,EAAE,MAAM,CAAC;QACf,OAAO,CAAC,EAAE,MAAM,CAAC;KAClB,CAAC;IACF,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE,CAAC,MAAM,EAAE,SAAS,GAAG,SAAS,GAAG,SAAS,KAAK,IAAI,CAAC;IAC9D,WAAW,CAAC,EAAE,CAAC,MAAM,EAAE,cAAc,EAAE,OAAO,EAAE,eAAe,KAAK,MAAM,CAAC;CAC5E;AAED,MAAM,WAAW,MAAM;IACrB,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,MAAM,MAAM,GAAG,QAAQ,GAAG,cAAc,GAAG,UAAU,GAAG,SAAS,CAAC;AAExE,MAAM,MAAM,gBAAgB,GAAG,kBAAkB,GAAG,wBAAwB,GAAG,oBAAoB,GAAG,SAAS,CAAC;AAEhH,MAAM,MAAM,UAAU,GAAG,SAAS,GAAG,SAAS,CAAC"}
@@ -0,0 +1,2 @@
1
+ export declare const checkPortkeyExtension: () => Promise<boolean>;
2
+ //# sourceMappingURL=checkPortkeyExtension.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"checkPortkeyExtension.d.ts","sourceRoot":"","sources":["../../../src/evokePortkey/checkPortkeyExtension.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,qBAAqB,wBAYjC,CAAC"}
@@ -0,0 +1,17 @@
1
+ import { scheme as schemeUtils } from '@portkey/utils';
2
+ import { PartialOption } from '@portkey/types';
3
+ import { EvokeAppOptions } from '../evokeApp/types';
4
+ export interface IBaseEvokeAppOption {
5
+ timeout?: number;
6
+ customFailureCallback?: () => void;
7
+ onStatusChange?: EvokeAppOptions['logFunc'];
8
+ }
9
+ export type EvokePortkeyByLogin = PartialOption<Omit<schemeUtils.ILoginHandleSchemeParams, 'scheme'>, 'domain'> & IBaseEvokeAppOption;
10
+ type EvokePortkeyByLinkDapp = PartialOption<Omit<schemeUtils.ILinkDappHandleSchemeParams, 'scheme'>, 'domain'> & IBaseEvokeAppOption;
11
+ export interface IEvokePortkeyApp {
12
+ evokePortkeyApp(params: EvokePortkeyByLogin): void;
13
+ evokePortkeyApp(params: EvokePortkeyByLinkDapp): void;
14
+ }
15
+ export declare const evokePortkeyApp: IEvokePortkeyApp['evokePortkeyApp'];
16
+ export {};
17
+ //# sourceMappingURL=evokePortkeyApp.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"evokePortkeyApp.d.ts","sourceRoot":"","sources":["../../../src/evokePortkey/evokePortkeyApp.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,IAAI,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAEvD,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAE/C,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAEpD,MAAM,WAAW,mBAAmB;IAClC,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,qBAAqB,CAAC,EAAE,MAAM,IAAI,CAAC;IACnC,cAAc,CAAC,EAAE,eAAe,CAAC,SAAS,CAAC,CAAC;CAC7C;AAED,MAAM,MAAM,mBAAmB,GAAG,aAAa,CAAC,IAAI,CAAC,WAAW,CAAC,wBAAwB,EAAE,QAAQ,CAAC,EAAE,QAAQ,CAAC,GAC7G,mBAAmB,CAAC;AACtB,KAAK,sBAAsB,GAAG,aAAa,CAAC,IAAI,CAAC,WAAW,CAAC,2BAA2B,EAAE,QAAQ,CAAC,EAAE,QAAQ,CAAC,GAC5G,mBAAmB,CAAC;AAEtB,MAAM,WAAW,gBAAgB;IAC/B,eAAe,CAAC,MAAM,EAAE,mBAAmB,GAAG,IAAI,CAAC;IACnD,eAAe,CAAC,MAAM,EAAE,sBAAsB,GAAG,IAAI,CAAC;CACvD;AACD,eAAO,MAAM,eAAe,EAAE,gBAAgB,CAAC,iBAAiB,CAgC/D,CAAC"}
@@ -0,0 +1,3 @@
1
+ export * from './evokePortkeyApp';
2
+ export * from './checkPortkeyExtension';
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/evokePortkey/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAC;AAClC,cAAc,yBAAyB,CAAC"}
@@ -0,0 +1,4 @@
1
+ export * from './evokeApp';
2
+ export * as Browser from './browser';
3
+ export * from './evokePortkey';
4
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B,OAAO,KAAK,OAAO,MAAM,WAAW,CAAC;AACrC,cAAc,gBAAgB,CAAC"}
@@ -0,0 +1,2 @@
1
+ export declare const detectBrowserName: () => string;
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/utils/index.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,iBAAiB,cAW7B,CAAC"}
package/package.json ADDED
@@ -0,0 +1,49 @@
1
+ {
2
+ "name": "@portkey/onboarding",
3
+ "version": "1.4.0-alpha.1",
4
+ "description": "",
5
+ "main": "./dist/commonjs/index.js",
6
+ "module": "./dist/esm/index.js",
7
+ "exports": {
8
+ ".": {
9
+ "types": "./dist/types/index.d.ts",
10
+ "import": "./dist/esm/index.js",
11
+ "require": "./dist/commonjs/index.js"
12
+ }
13
+ },
14
+ "author": "",
15
+ "license": "ISC",
16
+ "publishConfig": {
17
+ "access": "public",
18
+ "registry": "https://registry.npmjs.org"
19
+ },
20
+ "files": [
21
+ "dist/*"
22
+ ],
23
+ "homepage": "https://portkey.finance/",
24
+ "repository": {
25
+ "type": "git",
26
+ "url": "https://github.com/Portkey-Wallet/portkey-web.git",
27
+ "directory": "packages/utils"
28
+ },
29
+ "scripts": {
30
+ "clean": "rm -rf dist",
31
+ "prebuild": "yarn clean",
32
+ "build": "yarn build:cjs & yarn build:esm & yarn build:types",
33
+ "build:cjs": "tsc && echo '{\"type\": \"commonjs\"}' > ./dist/commonjs/package.json",
34
+ "build:esm": "tsc --build tsconfig.esm.json && echo '{\"type\": \"module\"}' > ./dist/esm/package.json && yarn esm:fix",
35
+ "build:types": "tsc --build tsconfig.types.json",
36
+ "esm:fix": "node ../../scripts/fix-esm.js dist/esm",
37
+ "lint": "eslint --ext .js,.ts .",
38
+ "lint:fix": "eslint --fix --ext .js,.ts .",
39
+ "format": "prettier --write '**/*'",
40
+ "start": "tsc --watch"
41
+ },
42
+ "dependencies": {
43
+ "@portkey/types": "^1.4.0-alpha.1",
44
+ "@portkey/utils": "^1.4.0-alpha.1",
45
+ "bowser": "^2.11.0",
46
+ "query-string": "^7.1.1"
47
+ },
48
+ "gitHead": "b79bbe7c365f46bc71fe1baccf60411be9a3986c"
49
+ }