@appboxo/expo-boxo-sdk 0.1.0

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.
@@ -0,0 +1,118 @@
1
+ export type AuthEventPayload = {
2
+ appId: string;
3
+ };
4
+ export type PaymentData = {
5
+ appId: string;
6
+ transactionToken?: string;
7
+ miniappOrderId?: string;
8
+ amount?: number;
9
+ currency?: string;
10
+ extraParams?: Record<string, any>;
11
+ hostappOrderId?: string;
12
+ status?: string;
13
+ };
14
+ export type CustomEventData = {
15
+ appId: string;
16
+ requestId?: number;
17
+ type?: string;
18
+ errorType?: string;
19
+ payload?: Record<string, any>;
20
+ };
21
+ export type LifecycleData = {
22
+ appId: string;
23
+ /**
24
+ * onLaunch - Called when the miniapp will launch with Appboxo.open(...)
25
+ * onResume - Called when the miniapp will start interacting with the user
26
+ * onPause - Called when the miniapp loses foreground state
27
+ * onClose - Called when clicked close button in miniapp or when destroyed miniapp page
28
+ * onError - Called when miniapp fails to launch due to internet connection issues
29
+ * onUserInteraction - Called whenever touch event is dispatched to the miniapp page.
30
+ */
31
+ lifecycle: string;
32
+ error?: string;
33
+ };
34
+ export type ConfigOptions = {
35
+ /**
36
+ * your client id from dashboard
37
+ */
38
+ clientId: string;
39
+ /**
40
+ * hostapp userId, will be used for the Consent Management
41
+ */
42
+ userId?: string;
43
+ /**
44
+ * language value will be passed to the miniapp
45
+ */
46
+ language?: string;
47
+ /**
48
+ * switch to sandbox mode
49
+ */
50
+ sandboxMode?: boolean;
51
+ /**
52
+ * Each miniapp appears as a task in the Recents screen.
53
+ * !It works only on android devices.
54
+ */
55
+ multitaskMode?: boolean;
56
+ /**
57
+ * theme for splash screen and other native components used inside miniapp.
58
+ */
59
+ theme?: 'light' | 'dark' | 'system';
60
+ /**
61
+ * enables webview debugging
62
+ */
63
+ isDebug?: boolean;
64
+ /**
65
+ * use it to hide "Settings" from Miniapp menu
66
+ */
67
+ showPermissionsPage?: boolean;
68
+ /**
69
+ * use it to hide "Clear cache" from Miniapp menu
70
+ */
71
+ showClearCache?: boolean;
72
+ };
73
+ export type MiniappOptions = {
74
+ /**
75
+ * miniapp id
76
+ */
77
+ appId: string;
78
+ /**
79
+ * (optional) data as Map that is sent to miniapp
80
+ */
81
+ data?: Record<string, any>;
82
+ /**
83
+ * (optional) miniapp theme "dark" | "light" (by default is system theme)
84
+ */
85
+ theme?: string;
86
+ /**
87
+ * (optional) extra query params to append to miniapp URL (like: http://miniapp-url.com/?param=test)
88
+ */
89
+ extraUrlParams?: Record<string, string>;
90
+ /**
91
+ * (optional) suffix to append to miniapp URL (like: http://miniapp-url.com/?param=test)
92
+ */
93
+ urlSuffix?: string;
94
+ /**
95
+ * (optional) provide colors to miniapp if miniapp supports
96
+ */
97
+ colors?: Record<string, string>;
98
+ /**
99
+ * (optional) use to skip miniapp splash screen
100
+ */
101
+ enableSplash?: boolean;
102
+ /**
103
+ * (optional) use to save state on close miniapp
104
+ */
105
+ saveState?: boolean;
106
+ };
107
+ export type MiniappListResult = {
108
+ miniapps?: Array<MiniappData>;
109
+ error?: string;
110
+ };
111
+ export type MiniappData = {
112
+ appId: string;
113
+ name: string;
114
+ category: string;
115
+ description: string;
116
+ logo: string;
117
+ };
118
+ //# sourceMappingURL=ExpoBoxoSdk.types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ExpoBoxoSdk.types.d.ts","sourceRoot":"","sources":["../src/ExpoBoxoSdk.types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,gBAAgB,GAAG;IAC7B,KAAK,EAAE,MAAM,CAAC;CACf,CAAC;AAEF,MAAM,MAAM,WAAW,GAAG;IACxB,KAAK,EAAE,MAAM,CAAC;IACd,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,WAAW,CAAC,EAAE,MAAM,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OAEG;IACH,cAAc,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACxC;;OAEG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB;;OAEG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAChC;;OAEG;IACH,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB;;OAEG;IACH,SAAS,CAAC,EAAE,OAAO,CAAC;CACrB,CAAC;AAEF,MAAM,MAAM,iBAAiB,GAAG;IAC9B,QAAQ,CAAC,EAAE,KAAK,CAAC,WAAW,CAAC,CAAC;IAC9B,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB,CAAA;AAED,MAAM,MAAM,WAAW,GAAG;IACxB,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;IACjB,WAAW,EAAE,MAAM,CAAC;IACpB,IAAI,EAAE,MAAM,CAAC;CACd,CAAA"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=ExpoBoxoSdk.types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ExpoBoxoSdk.types.js","sourceRoot":"","sources":["../src/ExpoBoxoSdk.types.ts"],"names":[],"mappings":"","sourcesContent":["export type AuthEventPayload = {\n appId: string;\n};\n\nexport type PaymentData = {\n appId: string;\n transactionToken?: string;\n miniappOrderId?: string;\n amount?: number;\n currency?: string;\n extraParams?: Record<string, any>;\n hostappOrderId?: string;\n status?: string;\n};\n\nexport type CustomEventData = {\n appId: string;\n requestId?: number;\n type?: string;\n errorType?: string;\n payload?: Record<string, any>;\n};\n\nexport type LifecycleData = {\n appId: string;\n /**\n * onLaunch - Called when the miniapp will launch with Appboxo.open(...)\n * onResume - Called when the miniapp will start interacting with the user\n * onPause - Called when the miniapp loses foreground state\n * onClose - Called when clicked close button in miniapp or when destroyed miniapp page\n * onError - Called when miniapp fails to launch due to internet connection issues\n * onUserInteraction - Called whenever touch event is dispatched to the miniapp page.\n */\n lifecycle: string;\n error?: string\n};\n\nexport type ConfigOptions = {\n /**\n * your client id from dashboard\n */\n clientId: string;\n /**\n * hostapp userId, will be used for the Consent Management\n */\n userId?: string;\n /**\n * language value will be passed to the miniapp\n */\n language?: string;\n /**\n * switch to sandbox mode\n */\n sandboxMode?: boolean;\n /**\n * Each miniapp appears as a task in the Recents screen.\n * !It works only on android devices.\n */\n multitaskMode?: boolean;\n /**\n * theme for splash screen and other native components used inside miniapp.\n */\n theme?: 'light' | 'dark' | 'system';\n /**\n * enables webview debugging\n */\n isDebug?: boolean;\n /**\n * use it to hide \"Settings\" from Miniapp menu\n */\n showPermissionsPage?: boolean;\n /**\n * use it to hide \"Clear cache\" from Miniapp menu\n */\n showClearCache?: boolean;\n};\n\nexport type MiniappOptions = {\n /**\n * miniapp id\n */\n appId: string;\n /**\n * (optional) data as Map that is sent to miniapp\n */\n data?: Record<string, any>;\n /**\n * (optional) miniapp theme \"dark\" | \"light\" (by default is system theme)\n */\n theme?: string;\n /**\n * (optional) extra query params to append to miniapp URL (like: http://miniapp-url.com/?param=test)\n */\n extraUrlParams?: Record<string, string>;\n /**\n * (optional) suffix to append to miniapp URL (like: http://miniapp-url.com/?param=test)\n */\n urlSuffix?: string;\n /**\n * (optional) provide colors to miniapp if miniapp supports\n */\n colors?: Record<string, string>;\n /**\n * (optional) use to skip miniapp splash screen\n */\n enableSplash?: boolean;\n /**\n * (optional) use to save state on close miniapp\n */\n saveState?: boolean;\n};\n\nexport type MiniappListResult = {\n miniapps?: Array<MiniappData>;\n error?: string;\n}\n\nexport type MiniappData = {\n appId: string;\n name: string;\n category: string;\n description: string;\n logo: string;\n}\n\n"]}
@@ -0,0 +1,3 @@
1
+ declare const _default: any;
2
+ export default _default;
3
+ //# sourceMappingURL=ExpoBoxoSdkModule.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ExpoBoxoSdkModule.d.ts","sourceRoot":"","sources":["../src/ExpoBoxoSdkModule.ts"],"names":[],"mappings":";AAEA,wBAAkD"}
@@ -0,0 +1,3 @@
1
+ import { requireNativeModule } from 'expo-modules-core';
2
+ export default requireNativeModule('ExpoBoxoSdk');
3
+ //# sourceMappingURL=ExpoBoxoSdkModule.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ExpoBoxoSdkModule.js","sourceRoot":"","sources":["../src/ExpoBoxoSdkModule.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAExD,eAAe,mBAAmB,CAAC,aAAa,CAAC,CAAC","sourcesContent":["import { requireNativeModule } from 'expo-modules-core';\n\nexport default requireNativeModule('ExpoBoxoSdk');\n"]}
@@ -0,0 +1,46 @@
1
+ import { Subscription } from 'expo-modules-core';
2
+ import { MiniappListResult, MiniappData, LifecycleData, CustomEventData, PaymentData, AuthEventPayload, ConfigOptions, MiniappOptions } from './ExpoBoxoSdk.types';
3
+ /**
4
+ * Set global configs
5
+ */
6
+ export declare function setConfig(options: ConfigOptions): void;
7
+ /**
8
+ * Open miniapp with options
9
+ */
10
+ export declare function openMiniapp(options: MiniappOptions): void;
11
+ /**
12
+ * get AuthCode from hostapp backend and send it to miniapp
13
+ */
14
+ export declare function setAuthCode(appId: string, authCode: string): void;
15
+ /**
16
+ * send payment event to miniapp
17
+ */
18
+ export declare function sendPaymentEvent(paymentData: PaymentData): void;
19
+ /**
20
+ * send custom event to miniapp
21
+ */
22
+ export declare function sendCustomEvent(event: CustomEventData): void;
23
+ /**
24
+ * When host app user logs out, it is highly important to clear all miniapp storage data.
25
+ */
26
+ export declare function logout(): void;
27
+ /**
28
+ * Miniapp opens on a native screen. To show payment processing page need to hide miniapp screen.
29
+ * To use this function need to enable 'multitaskMode: true' in Appboxo.setConfigs()
30
+ */
31
+ export declare function hideMiniapps(): void;
32
+ /**
33
+ * close miniapp by appId
34
+ */
35
+ export declare function closeMiniapp(appId: string): void;
36
+ /**
37
+ * Get list of miniapps
38
+ */
39
+ export declare function getMiniapps(): void;
40
+ export declare function addAuthListener(listener: (event: AuthEventPayload) => void): Subscription;
41
+ export declare function addCustomEventListener(listener: (event: CustomEventData) => void): Subscription;
42
+ export declare function addPaymentEventListener(listener: (event: PaymentData) => void): Subscription;
43
+ export declare function addMiniappLifecycleListener(listener: (lifecycleData: LifecycleData) => void): Subscription;
44
+ export declare function addMiniappListListener(listener: (result: MiniappListResult) => void): Subscription;
45
+ export { MiniappListResult, MiniappData, LifecycleData, CustomEventData, PaymentData, AuthEventPayload, ConfigOptions, MiniappOptions };
46
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAoC,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAGnF,OAAO,EAAE,iBAAiB,EAAE,WAAW,EAAE,aAAa,EAAE,eAAe,EAAE,WAAW,EAAE,gBAAgB,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAEnK;;GAEG;AACH,wBAAgB,SAAS,CAAC,OAAO,EAAE,aAAa,QAE/C;AAED;;GAEG;AACH,wBAAgB,WAAW,CAAC,OAAO,EAAE,cAAc,QAElD;AAED;;GAEG;AACH,wBAAgB,WAAW,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,QAE1D;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,WAAW,EAAE,WAAW,QAExD;AAED;;GAEG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,eAAe,QAErD;AAED;;GAEG;AACH,wBAAgB,MAAM,SAErB;AAED;;;GAGG;AACH,wBAAgB,YAAY,SAE3B;AAED;;GAEG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE,MAAM,QAEzC;AAED;;GAEG;AACH,wBAAgB,WAAW,SAE1B;AAID,wBAAgB,eAAe,CAAC,QAAQ,EAAE,CAAC,KAAK,EAAE,gBAAgB,KAAK,IAAI,GAAG,YAAY,CAEzF;AAED,wBAAgB,sBAAsB,CAAC,QAAQ,EAAE,CAAC,KAAK,EAAE,eAAe,KAAK,IAAI,GAAG,YAAY,CAE/F;AAED,wBAAgB,uBAAuB,CAAC,QAAQ,EAAE,CAAC,KAAK,EAAE,WAAW,KAAK,IAAI,GAAG,YAAY,CAE5F;AAED,wBAAgB,2BAA2B,CAAC,QAAQ,EAAE,CAAC,aAAa,EAAE,aAAa,KAAK,IAAI,GAAG,YAAY,CAE1G;AAED,wBAAgB,sBAAsB,CAAC,QAAQ,EAAE,CAAC,MAAM,EAAE,iBAAiB,KAAK,IAAI,GAAG,YAAY,CAElG;AAED,OAAO,EAAE,iBAAiB,EAAE,WAAW,EAAE,aAAa,EAAE,eAAe,EAAE,WAAW,EAAE,gBAAgB,EAAE,aAAa,EAAE,cAAc,EAAE,CAAC"}
package/build/index.js ADDED
@@ -0,0 +1,74 @@
1
+ import { NativeModulesProxy, EventEmitter } from 'expo-modules-core';
2
+ import ExpoBoxoSdkModule from './ExpoBoxoSdkModule';
3
+ /**
4
+ * Set global configs
5
+ */
6
+ export function setConfig(options) {
7
+ ExpoBoxoSdkModule.setConfig(options);
8
+ }
9
+ /**
10
+ * Open miniapp with options
11
+ */
12
+ export function openMiniapp(options) {
13
+ ExpoBoxoSdkModule.openMiniapp(options);
14
+ }
15
+ /**
16
+ * get AuthCode from hostapp backend and send it to miniapp
17
+ */
18
+ export function setAuthCode(appId, authCode) {
19
+ ExpoBoxoSdkModule.setAuthCode(appId, authCode);
20
+ }
21
+ /**
22
+ * send payment event to miniapp
23
+ */
24
+ export function sendPaymentEvent(paymentData) {
25
+ ExpoBoxoSdkModule.sendPaymentEvent(paymentData);
26
+ }
27
+ /**
28
+ * send custom event to miniapp
29
+ */
30
+ export function sendCustomEvent(event) {
31
+ ExpoBoxoSdkModule.sendCustomEvent(event);
32
+ }
33
+ /**
34
+ * When host app user logs out, it is highly important to clear all miniapp storage data.
35
+ */
36
+ export function logout() {
37
+ ExpoBoxoSdkModule.logout();
38
+ }
39
+ /**
40
+ * Miniapp opens on a native screen. To show payment processing page need to hide miniapp screen.
41
+ * To use this function need to enable 'multitaskMode: true' in Appboxo.setConfigs()
42
+ */
43
+ export function hideMiniapps() {
44
+ ExpoBoxoSdkModule.hideMiniapps();
45
+ }
46
+ /**
47
+ * close miniapp by appId
48
+ */
49
+ export function closeMiniapp(appId) {
50
+ ExpoBoxoSdkModule.closeMiniapp(appId);
51
+ }
52
+ /**
53
+ * Get list of miniapps
54
+ */
55
+ export function getMiniapps() {
56
+ ExpoBoxoSdkModule.getMiniapps();
57
+ }
58
+ const emitter = new EventEmitter(ExpoBoxoSdkModule ?? NativeModulesProxy.ExpoBoxoSdk);
59
+ export function addAuthListener(listener) {
60
+ return emitter.addListener('onAuth', listener);
61
+ }
62
+ export function addCustomEventListener(listener) {
63
+ return emitter.addListener('customEvent', listener);
64
+ }
65
+ export function addPaymentEventListener(listener) {
66
+ return emitter.addListener('paymentEvent', listener);
67
+ }
68
+ export function addMiniappLifecycleListener(listener) {
69
+ return emitter.addListener('miniappLifecycle', listener);
70
+ }
71
+ export function addMiniappListListener(listener) {
72
+ return emitter.addListener('miniappList', listener);
73
+ }
74
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,YAAY,EAAgB,MAAM,mBAAmB,CAAC;AAEnF,OAAO,iBAAiB,MAAM,qBAAqB,CAAC;AAGpD;;GAEG;AACH,MAAM,UAAU,SAAS,CAAC,OAAsB;IAC9C,iBAAiB,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC;AACvC,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,WAAW,CAAC,OAAuB;IACjD,iBAAiB,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC;AACzC,CAAC;AAED;;GAEG;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WAAW,CAAgB,kBAAkB,EAAE,QAAQ,CAAC,CAAC;AAC1E,CAAC;AAED,MAAM,UAAU,sBAAsB,CAAC,QAA6C;IAClF,OAAO,OAAO,CAAC,WAAW,CAAoB,aAAa,EAAE,QAAQ,CAAC,CAAC;AACzE,CAAC","sourcesContent":["import { NativeModulesProxy, EventEmitter, Subscription } from 'expo-modules-core';\n\nimport ExpoBoxoSdkModule from './ExpoBoxoSdkModule';\nimport { MiniappListResult, MiniappData, LifecycleData, CustomEventData, PaymentData, AuthEventPayload, ConfigOptions, MiniappOptions } from './ExpoBoxoSdk.types';\n\n/**\n * Set global configs\n */\nexport function setConfig(options: ConfigOptions) {\n ExpoBoxoSdkModule.setConfig(options);\n}\n\n/**\n * Open miniapp with options\n */\nexport function openMiniapp(options: MiniappOptions) {\n ExpoBoxoSdkModule.openMiniapp(options);\n}\n\n/**\n * get AuthCode from hostapp backend and send it to miniapp\n */\nexport function setAuthCode(appId: string, authCode: string) {\n ExpoBoxoSdkModule.setAuthCode(appId, authCode);\n}\n\n/**\n * send payment event to miniapp\n */\nexport function sendPaymentEvent(paymentData: PaymentData) {\n ExpoBoxoSdkModule.sendPaymentEvent(paymentData);\n}\n\n/**\n * send custom event to miniapp\n */\nexport function sendCustomEvent(event: CustomEventData) {\n ExpoBoxoSdkModule.sendCustomEvent(event);\n}\n\n/**\n * When host app user logs out, it is highly important to clear all miniapp storage data.\n */\nexport function logout() {\n ExpoBoxoSdkModule.logout();\n}\n\n/**\n * Miniapp opens on a native screen. To show payment processing page need to hide miniapp screen.\n * To use this function need to enable 'multitaskMode: true' in Appboxo.setConfigs()\n */\nexport function hideMiniapps() {\n ExpoBoxoSdkModule.hideMiniapps();\n}\n\n/**\n * close miniapp by appId\n */\nexport function closeMiniapp(appId: string) {\n ExpoBoxoSdkModule.closeMiniapp(appId);\n}\n\n/**\n * Get list of miniapps\n */\nexport function getMiniapps() {\n ExpoBoxoSdkModule.getMiniapps();\n}\n\nconst emitter = new EventEmitter(ExpoBoxoSdkModule ?? NativeModulesProxy.ExpoBoxoSdk);\n\nexport function addAuthListener(listener: (event: AuthEventPayload) => void): Subscription {\n return emitter.addListener<AuthEventPayload>('onAuth', listener);\n}\n\nexport function addCustomEventListener(listener: (event: CustomEventData) => void): Subscription {\n return emitter.addListener<CustomEventData>('customEvent', listener);\n}\n\nexport function addPaymentEventListener(listener: (event: PaymentData) => void): Subscription {\n return emitter.addListener<PaymentData>('paymentEvent', listener);\n}\n\nexport function addMiniappLifecycleListener(listener: (lifecycleData: LifecycleData) => void): Subscription {\n return emitter.addListener<LifecycleData>('miniappLifecycle', listener);\n}\n\nexport function addMiniappListListener(listener: (result: MiniappListResult) => void): Subscription {\n return emitter.addListener<MiniappListResult>('miniappList', listener);\n}\n\nexport { MiniappListResult, MiniappData, LifecycleData, CustomEventData, PaymentData, AuthEventPayload, ConfigOptions, MiniappOptions };\n"]}
@@ -0,0 +1,9 @@
1
+ {
2
+ "platforms": ["ios", "tvos", "android", "web"],
3
+ "ios": {
4
+ "modules": ["ExpoBoxoSdkModule"]
5
+ },
6
+ "android": {
7
+ "modules": ["io.boxo.expo.ExpoBoxoSdkModule"]
8
+ }
9
+ }
@@ -0,0 +1,37 @@
1
+ //
2
+ // ConfigOptions.swift
3
+ // ExpoBoxoSdk
4
+ //
5
+ // Created by Azamat Kushmanov on 18/9/24.
6
+ //
7
+
8
+ import ExpoModulesCore
9
+
10
+ struct ConfigOptions: Record {
11
+ @Field
12
+ var clientId: String = ""
13
+
14
+ @Field
15
+ var userId: String = ""
16
+
17
+ @Field
18
+ var language: String = "en"
19
+
20
+ @Field
21
+ var sandboxMode: Bool = false
22
+
23
+ @Field
24
+ var multitaskMode: Bool = false
25
+
26
+ @Field
27
+ var theme: String = "system"
28
+
29
+ @Field
30
+ var isDebug: Bool = false
31
+
32
+ @Field
33
+ var showPermissionsPage: Bool = true
34
+
35
+ @Field
36
+ var showClearCache: Bool = true
37
+ }
@@ -0,0 +1,25 @@
1
+ //
2
+ // CustomEventData.swift
3
+ // ExpoBoxoSdk
4
+ //
5
+ // Created by Azamat Kushmanov on 18/9/24.
6
+ //
7
+
8
+ import ExpoModulesCore
9
+
10
+ struct CustomEventData : Record {
11
+ @Field
12
+ var appId: String = ""
13
+
14
+ @Field
15
+ var requestId: Int?
16
+
17
+ @Field
18
+ var type: String?
19
+
20
+ @Field
21
+ var errorType: String?
22
+
23
+ @Field
24
+ var payload: [String : Any]?
25
+ }
@@ -0,0 +1,28 @@
1
+ require 'json'
2
+
3
+ package = JSON.parse(File.read(File.join(__dir__, '..', 'package.json')))
4
+
5
+ Pod::Spec.new do |s|
6
+ s.name = 'ExpoBoxoSdk'
7
+ s.version = package['version']
8
+ s.summary = package['description']
9
+ s.description = package['description']
10
+ s.license = package['license']
11
+ s.author = package['author']
12
+ s.homepage = package['homepage']
13
+ s.platforms = { :ios => '13.4', :tvos => '13.4' }
14
+ s.swift_version = '5.4'
15
+ s.source = { git: 'https://github.com/Appboxo/expo-boxo-sdk' }
16
+ s.static_framework = true
17
+
18
+ s.dependency 'ExpoModulesCore'
19
+ s.dependency 'AppBoxoSDK', '1.5.12'
20
+
21
+ # Swift/Objective-C compatibility
22
+ s.pod_target_xcconfig = {
23
+ 'DEFINES_MODULE' => 'YES',
24
+ 'SWIFT_COMPILATION_MODE' => 'wholemodule'
25
+ }
26
+
27
+ s.source_files = "**/*.{h,m,swift}"
28
+ end
@@ -0,0 +1,229 @@
1
+ import ExpoModulesCore
2
+ import AppBoxoSDK
3
+
4
+ public class ExpoBoxoSdkModule: Module {
5
+
6
+ public func definition() -> ModuleDefinition {
7
+ Name("ExpoBoxoSdk")
8
+
9
+ Events("customEvent", "paymentEvent", "miniappLifecycle", "onAuth", "miniappList")
10
+
11
+ Function("setConfig") { (options : ConfigOptions) in
12
+ var globalTheme : Theme = .System
13
+ switch (options.theme) {
14
+ case "dark":
15
+ globalTheme = .Dark
16
+ case "light":
17
+ globalTheme = .Light
18
+ default:
19
+ globalTheme = .System
20
+ }
21
+
22
+ let config = Config(clientId: options.clientId, theme: globalTheme)
23
+ config.setUserId(id: options.userId)
24
+ config.language = options.language
25
+ config.sandboxMode = options.sandboxMode
26
+ config.permissionsPage = options.showPermissionsPage
27
+ config.showClearCache = options.showClearCache
28
+
29
+ Appboxo.shared.setConfig(config: config)
30
+ }
31
+
32
+ Function("openMiniapp") { (options : MiniappOptions) in
33
+ let miniApp = Appboxo.shared.getMiniapp(appId: options.appId)
34
+ miniApp.setData(data: options.data)
35
+ miniApp.delegate = self
36
+
37
+ let miniappConfig = MiniappConfig()
38
+ miniappConfig.saveState = options.saveState
39
+ miniappConfig.enableSplash(isSplashEnabled: options.enableSplash)
40
+ miniappConfig.setExtraParams(extraParams: options.extraUrlParams)
41
+
42
+ if let theme = options.theme {
43
+ switch theme {
44
+ case "dark":
45
+ miniappConfig.setTheme(theme: .Dark)
46
+ case "light":
47
+ miniappConfig.setTheme(theme: .Light)
48
+ case "system":
49
+ miniappConfig.setTheme(theme: .System)
50
+ default:
51
+ break
52
+ }
53
+ }
54
+
55
+ if let colors = options.colors {
56
+ miniappConfig.setColor(color: MiniappColor(primary: colors["primary_color"] ?? "", secondary: colors["secondary_color"] ?? "", tertiary: colors["tertiary_color"] ?? ""))
57
+ }
58
+
59
+ miniApp.setConfig(config: miniappConfig)
60
+ DispatchQueue.main.async {
61
+ miniApp.open(viewController: UIApplication.shared.delegate!.window!!.rootViewController!)
62
+ }
63
+ }
64
+
65
+ Function("setAuthCode") { (appId : String, authCode: String) in
66
+ DispatchQueue.main.async {
67
+ Appboxo.shared.getMiniapp(appId: appId).setAuthCode(authCode: authCode)
68
+ }
69
+ }
70
+
71
+ Function("sendCustomEvent") { (customEvent : CustomEventData) in
72
+ let event = CustomEvent()
73
+ event.requestId = customEvent.requestId ?? 0
74
+ event.type = customEvent.type ?? ""
75
+ event.errorType = customEvent.errorType ?? ""
76
+ event.payload = customEvent.payload
77
+
78
+ DispatchQueue.main.async {
79
+ Appboxo.shared.getMiniapp(appId: customEvent.appId).sendCustomEvent(customEvent: event)
80
+ }
81
+ }
82
+
83
+ Function("sendPaymentEvent") { (paymentEvent : PaymentEventData) in
84
+ let paymentData = PaymentData()
85
+ paymentData.transactionToken = paymentEvent.transactionToken ?? ""
86
+ paymentData.miniappOrderId = paymentEvent.miniappOrderId ?? ""
87
+ paymentData.amount = paymentEvent.amount ?? 0.0
88
+ paymentData.currency = paymentEvent.currency ?? ""
89
+ paymentData.status = paymentEvent.status ?? ""
90
+ paymentData.hostappOrderId = paymentEvent.hostappOrderId ?? ""
91
+ paymentData.extraParams = paymentEvent.extraParams
92
+
93
+ DispatchQueue.main.async {
94
+ Appboxo.shared.getMiniapp(appId: paymentEvent.appId).sendPaymentEvent(paymentData: paymentData)
95
+ }
96
+ }
97
+
98
+ Function("closeMiniapp") { (appId : String) in
99
+ if let miniapp = Appboxo.shared.getExistingMiniapp(appId: appId) {
100
+ DispatchQueue.main.async {
101
+ miniapp.close()
102
+ }
103
+ }
104
+ }
105
+
106
+ Function("hideMiniapps") {
107
+ DispatchQueue.main.async {
108
+ Appboxo.shared.hideMiniapps()
109
+ }
110
+ }
111
+
112
+ Function("logout") {
113
+ DispatchQueue.main.async {
114
+ Appboxo.shared.logout()
115
+ }
116
+ }
117
+
118
+ Function("getMiniapps") {
119
+ Appboxo.shared.getMiniapps { miniapps, error in
120
+ if let error = error {
121
+ self.sendEvent("miniappList", ["error" : error])
122
+ } else {
123
+ self.sendEvent("miniappList", ["miniapps" : miniapps.map { miniappData in
124
+ return [
125
+ "appId" : miniappData.appId,
126
+ "name" : miniappData.name,
127
+ "category" : miniappData.category,
128
+ "logo" : miniappData.logo,
129
+ "description" : miniappData.longDescription
130
+ ]
131
+ }])
132
+ }
133
+ }
134
+ }
135
+ }
136
+ }
137
+
138
+ extension ExpoBoxoSdkModule : MiniappDelegate {
139
+ public func didReceivePaymentEvent(miniapp: Miniapp, paymentData: PaymentData) {
140
+ let dict = [
141
+ "appId" : miniapp.appId,
142
+ "transactionToken" : paymentData.transactionToken,
143
+ "miniappOrderId" : paymentData.miniappOrderId,
144
+ "amount" : paymentData.amount,
145
+ "currency" : paymentData.currency,
146
+ "status" : paymentData.status,
147
+ "hostappOrderId" : paymentData.hostappOrderId,
148
+ "extraParams" : paymentData.extraParams ?? [String : Any]()
149
+ ] as [String: Any]
150
+
151
+ sendEvent("paymentEvent", dict)
152
+ }
153
+
154
+ public func didReceiveCustomEvent(miniapp: Miniapp, customEvent: CustomEvent) {
155
+ let dict = [
156
+ "appId" : miniapp.appId,
157
+ "requestId" : customEvent.requestId,
158
+ "type" : customEvent.type,
159
+ "errorType" : customEvent.errorType,
160
+ "payload" : customEvent.payload ?? [String : Any]()
161
+ ] as [String: Any]
162
+
163
+ sendEvent("customEvent", dict)
164
+ }
165
+
166
+ public func onLaunch(miniapp: Miniapp) {
167
+ let dict = [
168
+ "appId" : miniapp.appId,
169
+ "lifecycle" : "onLaunch"
170
+ ]
171
+
172
+ sendEvent("miniappLifecycle", dict)
173
+ }
174
+
175
+ public func onResume(miniapp: Miniapp) {
176
+ let dict = [
177
+ "appId" : miniapp.appId,
178
+ "lifecycle" : "onResume"
179
+ ]
180
+
181
+ sendEvent("miniappLifecycle", dict)
182
+ }
183
+
184
+ public func onPause(miniapp: Miniapp) {
185
+ let dict = [
186
+ "appId" : miniapp.appId,
187
+ "lifecycle" : "onPause"
188
+ ]
189
+
190
+ sendEvent("miniappLifecycle", dict)
191
+ }
192
+
193
+ public func onClose(miniapp: Miniapp) {
194
+ let dict = [
195
+ "appId" : miniapp.appId,
196
+ "lifecycle" : "onClose"
197
+ ]
198
+
199
+ sendEvent("miniappLifecycle", dict)
200
+ }
201
+
202
+ public func onError(miniapp: Miniapp, message: String) {
203
+ let dict = [
204
+ "appId" : miniapp.appId,
205
+ "lifecycle" : "onError",
206
+ "error" : message
207
+ ]
208
+
209
+ sendEvent("miniappLifecycle", dict)
210
+ }
211
+
212
+ public func onUserInteraction(miniapp: Miniapp) {
213
+ let dict = [
214
+ "appId" : miniapp.appId,
215
+ "lifecycle" : "onUserInteraction"
216
+ ]
217
+
218
+ sendEvent("miniappLifecycle", dict)
219
+ }
220
+
221
+ public func onAuth(miniapp: Miniapp) {
222
+ let dict = [
223
+ "appId" : miniapp.appId,
224
+ "lifecycle" : "onAuth"
225
+ ]
226
+
227
+ sendEvent("onAuth", dict)
228
+ }
229
+ }
@@ -0,0 +1,34 @@
1
+ //
2
+ // MiniappOptions.swift
3
+ // ExpoBoxoSdk
4
+ //
5
+ // Created by Azamat Kushmanov on 18/9/24.
6
+ //
7
+
8
+ import ExpoModulesCore
9
+
10
+ struct MiniappOptions: Record {
11
+ @Field
12
+ var appId: String = ""
13
+
14
+ @Field
15
+ var data: [String : Any]?
16
+
17
+ @Field
18
+ var theme: String?
19
+
20
+ @Field
21
+ var extraUrlParams: [String : String]?
22
+
23
+ @Field
24
+ var urlSuffix: String?
25
+
26
+ @Field
27
+ var colors: [String : String]?
28
+
29
+ @Field
30
+ var enableSplash: Bool = true
31
+
32
+ @Field
33
+ var saveState: Bool = true
34
+ }