@blueid/access-capacitor 1.1.0 → 1.4.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.
- package/android/build.gradle +7 -5
- package/android/settings.gradle +4 -0
- package/android/src/main/java/com/blueid/access/plugins/capacitor/BlueIDAccess.java +43 -1
- package/android/src/main/java/com/blueid/access/plugins/capacitor/BlueIDAccessPlugin.java +87 -1
- package/dist/esm/interop.js +3 -0
- package/dist/esm/interop.js.map +1 -1
- package/dist/plugin.cjs.js +3 -0
- package/dist/plugin.cjs.js.map +1 -1
- package/dist/plugin.js +3 -0
- package/dist/plugin.js.map +1 -1
- package/ios/CBlueIDAccess.xcframework/Info.plist +6 -6
- package/ios/CBlueIDAccess.xcframework/ios-arm64/libCBlueIDAccess.a +0 -0
- package/ios/CBlueIDAccess.xcframework/ios-arm64_x86_64-simulator/libCBlueIDAccess.a +0 -0
- package/ios/CBlueIDAccess.xcframework/macos-arm64_x86_64/libCBlueIDAccess.a +0 -0
- package/ios/Plugin/BlueIDAccessPlugin.swift +1 -1
- package/package.json +3 -1
package/android/build.gradle
CHANGED
|
@@ -11,7 +11,7 @@ buildscript {
|
|
|
11
11
|
mavenCentral()
|
|
12
12
|
}
|
|
13
13
|
dependencies {
|
|
14
|
-
classpath 'com.android.tools.build:gradle:8.
|
|
14
|
+
classpath 'com.android.tools.build:gradle:8.3.0'
|
|
15
15
|
}
|
|
16
16
|
}
|
|
17
17
|
|
|
@@ -19,10 +19,10 @@ apply plugin: 'com.android.library'
|
|
|
19
19
|
|
|
20
20
|
android {
|
|
21
21
|
namespace "com.blueid.access.plugins.capacitor"
|
|
22
|
-
compileSdkVersion project.hasProperty('compileSdkVersion') ? rootProject.ext.compileSdkVersion :
|
|
22
|
+
compileSdkVersion project.hasProperty('compileSdkVersion') ? rootProject.ext.compileSdkVersion : 34
|
|
23
23
|
defaultConfig {
|
|
24
|
-
minSdkVersion project.hasProperty('minSdkVersion') ? rootProject.ext.minSdkVersion :
|
|
25
|
-
targetSdkVersion project.hasProperty('targetSdkVersion') ? rootProject.ext.targetSdkVersion :
|
|
24
|
+
minSdkVersion project.hasProperty('minSdkVersion') ? rootProject.ext.minSdkVersion : 31
|
|
25
|
+
targetSdkVersion project.hasProperty('targetSdkVersion') ? rootProject.ext.targetSdkVersion : 34
|
|
26
26
|
versionCode 1
|
|
27
27
|
versionName "1.0"
|
|
28
28
|
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
|
@@ -45,12 +45,14 @@ android {
|
|
|
45
45
|
repositories {
|
|
46
46
|
google()
|
|
47
47
|
mavenCentral()
|
|
48
|
+
maven { url "./repo" }
|
|
48
49
|
}
|
|
49
50
|
|
|
50
51
|
|
|
51
52
|
dependencies {
|
|
52
|
-
implementation fileTree(dir: 'libs', include: ['*.jar'])
|
|
53
|
+
implementation fileTree(dir: 'libs', include: ['*.jar', '*.aar'])
|
|
53
54
|
implementation project(':capacitor-android')
|
|
55
|
+
implementation ('net.blueid:access:5.0@aar'){transitive=true}
|
|
54
56
|
implementation "androidx.appcompat:appcompat:$androidxAppCompatVersion"
|
|
55
57
|
testImplementation "junit:junit:$junitVersion"
|
|
56
58
|
androidTestImplementation "androidx.test.ext:junit:$androidxJunitVersion"
|
|
@@ -1,11 +1,53 @@
|
|
|
1
1
|
package com.blueid.access.plugins.capacitor;
|
|
2
2
|
|
|
3
|
+
import android.app.Application;
|
|
4
|
+
import android.content.Context;
|
|
3
5
|
import android.util.Log;
|
|
6
|
+
import android.widget.Toast;
|
|
7
|
+
|
|
8
|
+
import com.getcapacitor.App;
|
|
9
|
+
|
|
10
|
+
import java.util.Map;
|
|
11
|
+
|
|
12
|
+
import blueid.access.sdk.BluePlugin;
|
|
13
|
+
import blueid.access.sdk.Sdk;
|
|
14
|
+
import kotlin.jvm.functions.Function1;
|
|
15
|
+
|
|
4
16
|
|
|
5
17
|
public class BlueIDAccess {
|
|
6
18
|
|
|
19
|
+
Sdk sdk;
|
|
20
|
+
|
|
21
|
+
private static BlueIDAccess instance = null;
|
|
22
|
+
private static BluePlugin plugin = null;
|
|
23
|
+
private final Application application;
|
|
24
|
+
|
|
25
|
+
private BlueIDAccess(Application application) {
|
|
26
|
+
this.application = application;
|
|
27
|
+
Log.i("Capacitor:", "BlueIDAccess Loaded "+application.getPackageName());
|
|
28
|
+
sdk = Sdk.INSTANCE;
|
|
29
|
+
sdk.init(application);
|
|
30
|
+
plugin = new BluePlugin();
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
public static BlueIDAccess getInstance(Application context) {
|
|
34
|
+
|
|
35
|
+
if (instance == null) {
|
|
36
|
+
|
|
37
|
+
instance = new BlueIDAccess(context);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
return instance;
|
|
41
|
+
}
|
|
42
|
+
|
|
7
43
|
public String echo(String value) {
|
|
8
|
-
|
|
44
|
+
Toast.makeText(application, "Echo "+value, Toast.LENGTH_SHORT).show();
|
|
9
45
|
return value;
|
|
10
46
|
}
|
|
47
|
+
|
|
48
|
+
public void runCommand(String command, Object arg0, Object arg1, Object arg2, Function1<Map<String, ? extends Object>, Void> resolve,
|
|
49
|
+
Function1<Map<String, ? extends Object>, Void> reject) {
|
|
50
|
+
|
|
51
|
+
plugin.runCommand(command, arg0, arg1, arg2, resolve, reject);
|
|
52
|
+
}
|
|
11
53
|
}
|
|
@@ -1,15 +1,40 @@
|
|
|
1
1
|
package com.blueid.access.plugins.capacitor;
|
|
2
2
|
|
|
3
|
+
import android.app.Application;
|
|
4
|
+
import android.content.Context;
|
|
5
|
+
import android.util.Log;
|
|
6
|
+
|
|
3
7
|
import com.getcapacitor.JSObject;
|
|
4
8
|
import com.getcapacitor.Plugin;
|
|
5
9
|
import com.getcapacitor.PluginCall;
|
|
6
10
|
import com.getcapacitor.PluginMethod;
|
|
7
11
|
import com.getcapacitor.annotation.CapacitorPlugin;
|
|
8
12
|
|
|
13
|
+
import org.json.JSONException;
|
|
14
|
+
import org.json.JSONObject;
|
|
15
|
+
|
|
16
|
+
import java.util.Map;
|
|
17
|
+
|
|
18
|
+
import blueid.access.sdk.core.BlueError;
|
|
19
|
+
import blueid.access.sdk.pb.BlueCore;
|
|
20
|
+
import kotlin.jvm.functions.Function1;
|
|
21
|
+
|
|
9
22
|
@CapacitorPlugin(name = "BlueIDAccess")
|
|
10
23
|
public class BlueIDAccessPlugin extends Plugin {
|
|
11
24
|
|
|
12
|
-
private BlueIDAccess implementation
|
|
25
|
+
private BlueIDAccess implementation;
|
|
26
|
+
|
|
27
|
+
@Override
|
|
28
|
+
public void load() {
|
|
29
|
+
super.load();
|
|
30
|
+
|
|
31
|
+
Application appInstance = (Application) getContext().getApplicationContext();
|
|
32
|
+
implementation = BlueIDAccess.getInstance(appInstance);
|
|
33
|
+
|
|
34
|
+
Log.i("Capacitor:", "BlueIDAccessPlugin Loaded "+appInstance.getPackageName());
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
|
|
13
38
|
|
|
14
39
|
@PluginMethod
|
|
15
40
|
public void echo(PluginCall call) {
|
|
@@ -19,4 +44,65 @@ public class BlueIDAccessPlugin extends Plugin {
|
|
|
19
44
|
ret.put("value", implementation.echo(value));
|
|
20
45
|
call.resolve(ret);
|
|
21
46
|
}
|
|
47
|
+
|
|
48
|
+
@PluginMethod
|
|
49
|
+
public void runCommand(PluginCall call) {
|
|
50
|
+
|
|
51
|
+
String command = call.getString("command");
|
|
52
|
+
|
|
53
|
+
if (command == null || command.isEmpty()) {
|
|
54
|
+
call.reject("Missing or invalid command");
|
|
55
|
+
return;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
Object arg0 = null, arg1 = null, arg2 = null;
|
|
59
|
+
|
|
60
|
+
try {
|
|
61
|
+
arg0 = call.getData().get("arg0");
|
|
62
|
+
arg1 = call.getData().get("arg1");
|
|
63
|
+
arg2 = call.getData().get("arg2");
|
|
64
|
+
} catch (JSONException e) {
|
|
65
|
+
call.reject(e.getMessage());
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
Log.i("AndroidCapacitor:", "data: "+call.getData());
|
|
70
|
+
|
|
71
|
+
if (arg0 != null && arg0.toString().equals("null")){ // this is so important don't remove this
|
|
72
|
+
arg0 = null;
|
|
73
|
+
}
|
|
74
|
+
if (arg1 != null && arg1.toString().equals("null")){ // this is so important don't remove this
|
|
75
|
+
arg1 = null;
|
|
76
|
+
}
|
|
77
|
+
if (arg2 != null && arg2.toString().equals("null")){ // this is so important don't remove this
|
|
78
|
+
arg2 = null;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
|
|
82
|
+
implementation.runCommand(command, arg0, arg1, arg2, stringObjectMap -> {
|
|
83
|
+
|
|
84
|
+
if (stringObjectMap != null) {
|
|
85
|
+
JSONObject result = new JSONObject(stringObjectMap);
|
|
86
|
+
|
|
87
|
+
try {
|
|
88
|
+
call.resolve(JSObject.fromJSONObject(result));
|
|
89
|
+
} catch (JSONException e) {
|
|
90
|
+
throw new RuntimeException(e);
|
|
91
|
+
}
|
|
92
|
+
}else{
|
|
93
|
+
call.resolve();
|
|
94
|
+
}
|
|
95
|
+
return null;
|
|
96
|
+
}, stringObjectMap -> {
|
|
97
|
+
|
|
98
|
+
Object value = stringObjectMap.get("message");
|
|
99
|
+
String errorMsg = value instanceof String ? (String) value : "Unknown_error";
|
|
100
|
+
|
|
101
|
+
Object error = stringObjectMap.get("error");
|
|
102
|
+
|
|
103
|
+
int errorValue = (int) (error instanceof Integer ? error : -1);
|
|
104
|
+
call.reject(errorMsg, String.valueOf(errorValue));
|
|
105
|
+
return null;
|
|
106
|
+
});
|
|
107
|
+
}
|
|
22
108
|
}
|
package/dist/esm/interop.js
CHANGED
|
@@ -58,18 +58,21 @@ export class BlueIDAccessInterop {
|
|
|
58
58
|
if (!command) {
|
|
59
59
|
throw new Error("Missing valid command");
|
|
60
60
|
}
|
|
61
|
+
console.log('Starting command: ' + JSON.stringify(command));
|
|
61
62
|
const result = await this.runCommandFunc({
|
|
62
63
|
command,
|
|
63
64
|
arg0: encodeArgument(arg0),
|
|
64
65
|
arg1: encodeArgument(arg1),
|
|
65
66
|
arg2: encodeArgument(arg2),
|
|
66
67
|
});
|
|
68
|
+
console.log('Running command with result : ' + JSON.stringify(result));
|
|
67
69
|
if (!result) {
|
|
68
70
|
return null;
|
|
69
71
|
}
|
|
70
72
|
if (result.data && result.messageTypeName) {
|
|
71
73
|
return decodeResult(result.messageTypeName, result.data);
|
|
72
74
|
}
|
|
75
|
+
console.log('result from interop ' + command + ' : ' + JSON.stringify(result.data));
|
|
73
76
|
return result.data;
|
|
74
77
|
}
|
|
75
78
|
async terminalRunAll(deviceID, requests, timeoutSeconds = 10.0) {
|
package/dist/esm/interop.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"interop.js","sourceRoot":"","sources":["../../src/interop.ts"],"names":[],"mappings":"AAAA,EAAE;AACF,kFAAkF;AAClF,EAAE;;;;;;;;;;;;AAEF,OAAO,EAAE,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAE7D,OAAO,KAAK,MAAM,MAAM,UAAU,CAAC;AAEnC,OAAO,KAAK,QAAQ,MAAM,eAAe,CAAC;AAC1C,OAAO,KAAK,QAAQ,MAAM,eAAe,CAAC;AAC1C,OAAO,KAAK,OAAO,MAAM,cAAc,CAAC;AACxC,OAAO,KAAK,UAAU,MAAM,iBAAiB,CAAC;AAE9C,MAAM,YAAY,GAAG,CAAC,QAAQ,EAAE,QAAQ,EAAE,OAAO,EAAE,UAAU,CAAC,CAAC;AAE/D,MAAM,eAAe,GAAG,CAAC,eAAuB,EAAO,EAAE;IACvD,KAAK,MAAM,WAAW,IAAI,YAAY,EAAE,CAAC;QACvC,MAAM,MAAM,GAAI,WAAmB,CAAC,eAAe,CAAC,CAAC;QACrD,IAAI,MAAM,EAAE,CAAC;YACX,OAAO,MAAM,CAAC;QAChB,CAAC;IACH,CAAC;IAED,MAAM,IAAI,KAAK,CACb,4CAA4C,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AAY,CAAC,SAAS,CAAC,eAAe,EAAE,SAAS,CAAC,IAAI,CAAC,CAAC;gBACtE,CAAC;gBAED,QAAQ,CAAC,SAAS,CAAC,CAAC;YACtB,CAAC,CAAC,CAAC;QACL,CAAC;QACD,MAAM,IAAI,KAAK,CAAC,yBAAyB,CAAC,CAAC;IAC7C,CAAC;CACF;AAED,cAAc,eAAe,CAAC;AAC9B,cAAc,eAAe,CAAC;AAC9B,cAAc,cAAc,CAAC;AAC7B,cAAc,iBAAiB,CAAC","sourcesContent":["//\n// Utilities shared for typescript json-interfaces like react-native and capacitor\n//\n\nimport { Message, protoDelimited } from \"@bufbuild/protobuf\";\n\nimport * as base64 from \"./base64\";\n\nimport * as BlueCore from \"./BlueCore_pb\";\nimport * as BlueLock from \"./BlueLock_pb\";\nimport * as BlueSDK from \"./BlueSDK_pb\";\nimport * as BlueSystem from \"./BlueSystem_pb\";\n\nconst protoModules = [BlueCore, BlueLock, BlueSDK, BlueSystem];\n\nconst getMessageClass = (messageTypeName: string): any => {\n for (const protoModule of protoModules) {\n const result = (protoModule as any)[messageTypeName];\n if (result) {\n return result;\n }\n }\n\n throw new Error(\n `No message class found for message type '${messageTypeName}'`\n );\n};\n\nconst encodeArgument = (arg: any | null): any => {\n if (arg instanceof Message) {\n const binary = protoDelimited.enc(arg);\n\n const binaryString: string[] = [];\n for (let i = 0; i < binary.length; i++) {\n binaryString.push(String.fromCharCode(binary[i]!));\n }\n\n const base64String = base64.encode(binaryString.join(\"\"));\n return `message:${base64String}`;\n }\n return arg;\n};\n\nconst decodeResult = (\n messageTypeName: string,\n messageString: string | null\n): any => {\n const MessageClass = getMessageClass(messageTypeName);\n\n if (messageString == null || !messageString.startsWith(\"message:\")) {\n throw new Error(`Invalid message to decode: '${messageString}'`);\n }\n\n const binary = Uint8Array.from(\n base64.decode(messageString.substring(\"message:\".length)),\n (v: string) => v.charCodeAt(0)\n );\n\n return protoDelimited.dec(MessageClass, binary);\n};\n\nexport interface BlueAccessTerminalRequest {\n action: string;\n data: any | null;\n resultMessageTypeName: string | null;\n}\n\nexport interface BlueAccessTerminalResult {\n statusCode: BlueCore.BlueReturnCode;\n data: any | null;\n}\n\nexport interface RunCommandOptions {\n command: string;\n arg0: any | null;\n arg1: any | null;\n arg2: any | null;\n}\n\nexport interface TerminalRunOptions {\n deviceID: string;\n timeoutSeconds: number;\n requests: BlueAccessTerminalRequest[];\n}\n\nexport interface TerminalRunResult {\n results: BlueAccessTerminalResult[];\n}\n\nexport interface BlueAccessListener {\n remove(): Promise<void>;\n}\n\nexport class BlueIDAccessInterop {\n runCommandFunc: (options: RunCommandOptions) => Promise<any>;\n terminalRunFunc: (options: TerminalRunOptions) => Promise<TerminalRunResult>;\n addListenerFunc: (event: string, callback: (data: any) => void) => Promise<BlueAccessListener>;\n\n constructor(\n runCommandFunc: (options: RunCommandOptions) => Promise<any>,\n terminalRunFunc: (options: TerminalRunOptions) => Promise<TerminalRunResult>,\n addListenerFunc: (event: string, callback: (data: any) => void) => Promise<BlueAccessListener>\n ) {\n this.runCommandFunc = runCommandFunc;\n this.terminalRunFunc = terminalRunFunc;\n this.addListenerFunc = addListenerFunc;\n }\n\n async runCommand(\n command: string,\n arg0: any | null = null,\n arg1: any | null = null,\n arg2: any | null = null\n ): Promise<any | void> {\n if (!command) {\n throw new Error(\"Missing valid command\");\n }\n\n const result = await this.runCommandFunc({\n command,\n arg0: encodeArgument(arg0),\n arg1: encodeArgument(arg1),\n arg2: encodeArgument(arg2),\n });\n\n if (!result) {\n return null;\n }\n\n if (result.data && result.messageTypeName) {\n return decodeResult(result.messageTypeName, result.data);\n }\n\n return result.data;\n }\n\n async terminalRunAll(\n deviceID: string,\n requests: BlueAccessTerminalRequest[],\n timeoutSeconds = 10.0,\n ): Promise<BlueAccessTerminalResult[]> {\n if (!deviceID) {\n throw new Error(\"Invalid deviceID\");\n }\n\n if (timeoutSeconds <= 0) {\n throw new Error(\"Invalid timeout\");\n }\n\n if (!requests.length) {\n throw new Error(\"Invalid requests\");\n }\n\n const convertedRequests: BlueAccessTerminalRequest[] = requests.map(\n ({ data, ...otherProps }) => ({\n ...otherProps,\n data: encodeArgument(data),\n })\n );\n\n const runResult = await this.terminalRunFunc({\n deviceID,\n timeoutSeconds,\n requests: convertedRequests,\n });\n\n if (!runResult?.results?.length) {\n throw new Error(\"No results received\");\n }\n\n const results: BlueAccessTerminalResult[] = [];\n\n for (let index = 0; index < runResult.results.length; index += 1) {\n const request = convertedRequests[index];\n\n if (!request) {\n throw new Error(\"Invalid request\");\n }\n\n const result = runResult.results[index];\n\n if (!result) {\n throw new Error(\"Invalid result\");\n }\n\n if (request.resultMessageTypeName) {\n results.push({\n statusCode: result.statusCode,\n data: decodeResult(request.resultMessageTypeName, result.data),\n });\n } else if (\n typeof result.data === \"string\" &&\n result.data.startsWith(\"message:\") &&\n result.data !== \"message:\"\n ) {\n throw new Error(\n `Missing resultMessageTypeName for action '${request.action}'`\n );\n } else {\n results.push({ statusCode: result.statusCode, data: result.data });\n }\n }\n\n return results;\n }\n\n async terminalRun(\n deviceID: string,\n request: BlueAccessTerminalRequest,\n timeoutSeconds = 10.0,\n ): Promise<BlueAccessTerminalResult> {\n const results = await this.terminalRunAll(deviceID, [request], timeoutSeconds);\n \n if (results?.length !== 1 || !results[0]) {\n throw new Error('Unexpected results');\n }\n\n return results[0];\n }\n\n async addListener(event: string, callback: (data: any) => void): Promise<BlueAccessListener> {\n if (this.addListenerFunc) {\n return this.addListenerFunc(event, (data: any) => {\n let eventData = data;\n\n if (eventData?.data && eventData?.messageTypeName) {\n eventData = decodeResult(eventData.messageTypeName, eventData.data);\n }\n\n callback(eventData);\n });\n }\n throw new Error('No listeners supported.');\n }\n}\n\nexport * from \"./BlueCore_pb\";\nexport * from \"./BlueLock_pb\";\nexport * from \"./BlueSDK_pb\";\nexport * from \"./BlueSystem_pb\";\n"]}
|
|
1
|
+
{"version":3,"file":"interop.js","sourceRoot":"","sources":["../../src/interop.ts"],"names":[],"mappings":"AAAA,EAA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AC;AAC9B,cAAc,eAAe,CAAC;AAC9B,cAAc,cAAc,CAAC;AAC7B,cAAc,iBAAiB,CAAC","sourcesContent":["//\n// Utilities shared for typescript json-interfaces like react-native and capacitor\n//\n\nimport { Message, protoDelimited } from \"@bufbuild/protobuf\";\n\nimport * as base64 from \"./base64\";\n\nimport * as BlueCore from \"./BlueCore_pb\";\nimport * as BlueLock from \"./BlueLock_pb\";\nimport * as BlueSDK from \"./BlueSDK_pb\";\nimport * as BlueSystem from \"./BlueSystem_pb\";\n\nconst protoModules = [BlueCore, BlueLock, BlueSDK, BlueSystem];\n\nconst getMessageClass = (messageTypeName: string): any => {\n for (const protoModule of protoModules) {\n const result = (protoModule as any)[messageTypeName];\n if (result) {\n return result;\n }\n }\n\n throw new Error(\n `No message class found for message type '${messageTypeName}'`\n );\n};\n\nconst encodeArgument = (arg: any | null): any => {\n if (arg instanceof Message) {\n const binary = protoDelimited.enc(arg);\n\n const binaryString: string[] = [];\n for (let i = 0; i < binary.length; i++) {\n binaryString.push(String.fromCharCode(binary[i]!));\n }\n\n const base64String = base64.encode(binaryString.join(\"\"));\n return `message:${base64String}`;\n }\n return arg;\n};\n\nconst decodeResult = (\n messageTypeName: string,\n messageString: string | null\n): any => {\n const MessageClass = getMessageClass(messageTypeName);\n\n if (messageString == null || !messageString.startsWith(\"message:\")) {\n throw new Error(`Invalid message to decode: '${messageString}'`);\n }\n\n const binary = Uint8Array.from(\n base64.decode(messageString.substring(\"message:\".length)),\n (v: string) => v.charCodeAt(0)\n );\n\n return protoDelimited.dec(MessageClass, binary);\n};\n\nexport interface BlueAccessTerminalRequest {\n action: string;\n data: any | null;\n resultMessageTypeName: string | null;\n}\n\nexport interface BlueAccessTerminalResult {\n statusCode: BlueCore.BlueReturnCode;\n data: any | null;\n}\n\nexport interface RunCommandOptions {\n command: string;\n arg0: any | null;\n arg1: any | null;\n arg2: any | null;\n}\n\nexport interface TerminalRunOptions {\n deviceID: string;\n timeoutSeconds: number;\n requests: BlueAccessTerminalRequest[];\n}\n\nexport interface TerminalRunResult {\n results: BlueAccessTerminalResult[];\n}\n\nexport interface BlueAccessListener {\n remove(): Promise<void>;\n}\n\nexport class BlueIDAccessInterop {\n runCommandFunc: (options: RunCommandOptions) => Promise<any>;\n terminalRunFunc: (options: TerminalRunOptions) => Promise<TerminalRunResult>;\n addListenerFunc: (event: string, callback: (data: any) => void) => Promise<BlueAccessListener>;\n\n constructor(\n runCommandFunc: (options: RunCommandOptions) => Promise<any>,\n terminalRunFunc: (options: TerminalRunOptions) => Promise<TerminalRunResult>,\n addListenerFunc: (event: string, callback: (data: any) => void) => Promise<BlueAccessListener>\n ) {\n this.runCommandFunc = runCommandFunc;\n this.terminalRunFunc = terminalRunFunc;\n this.addListenerFunc = addListenerFunc;\n }\n\n async runCommand(\n command: string,\n arg0: any | null = null,\n arg1: any | null = null,\n arg2: any | null = null\n ): Promise<any | void> {\n if (!command) {\n throw new Error(\"Missing valid command\");\n }\n\n console.log('Starting command: '+ JSON.stringify(command));\n\n const result = await this.runCommandFunc({\n command,\n arg0: encodeArgument(arg0),\n arg1: encodeArgument(arg1),\n arg2: encodeArgument(arg2),\n });\n\n console.log('Running command with result : '+ JSON.stringify(result));\n\n if (!result) {\n return null;\n }\n\n if (result.data && result.messageTypeName) {\n return decodeResult(result.messageTypeName, result.data);\n }\n\n console.log('result from interop '+ command + ' : ' + JSON.stringify(result.data));\n\n return result.data;\n }\n\n async terminalRunAll(\n deviceID: string,\n requests: BlueAccessTerminalRequest[],\n timeoutSeconds = 10.0,\n ): Promise<BlueAccessTerminalResult[]> {\n if (!deviceID) {\n throw new Error(\"Invalid deviceID\");\n }\n\n if (timeoutSeconds <= 0) {\n throw new Error(\"Invalid timeout\");\n }\n\n if (!requests.length) {\n throw new Error(\"Invalid requests\");\n }\n\n const convertedRequests: BlueAccessTerminalRequest[] = requests.map(\n ({ data, ...otherProps }) => ({\n ...otherProps,\n data: encodeArgument(data),\n })\n );\n\n const runResult = await this.terminalRunFunc({\n deviceID,\n timeoutSeconds,\n requests: convertedRequests,\n });\n\n if (!runResult?.results?.length) {\n throw new Error(\"No results received\");\n }\n\n const results: BlueAccessTerminalResult[] = [];\n\n for (let index = 0; index < runResult.results.length; index += 1) {\n const request = convertedRequests[index];\n\n if (!request) {\n throw new Error(\"Invalid request\");\n }\n\n const result = runResult.results[index];\n\n if (!result) {\n throw new Error(\"Invalid result\");\n }\n\n if (request.resultMessageTypeName) {\n results.push({\n statusCode: result.statusCode,\n data: decodeResult(request.resultMessageTypeName, result.data),\n });\n } else if (\n typeof result.data === \"string\" &&\n result.data.startsWith(\"message:\") &&\n result.data !== \"message:\"\n ) {\n throw new Error(\n `Missing resultMessageTypeName for action '${request.action}'`\n );\n } else {\n results.push({ statusCode: result.statusCode, data: result.data });\n }\n }\n\n return results;\n }\n\n async terminalRun(\n deviceID: string,\n request: BlueAccessTerminalRequest,\n timeoutSeconds = 10.0,\n ): Promise<BlueAccessTerminalResult> {\n const results = await this.terminalRunAll(deviceID, [request], timeoutSeconds);\n \n if (results?.length !== 1 || !results[0]) {\n throw new Error('Unexpected results');\n }\n\n return results[0];\n }\n\n async addListener(event: string, callback: (data: any) => void): Promise<BlueAccessListener> {\n if (this.addListenerFunc) {\n return this.addListenerFunc(event, (data: any) => {\n let eventData = data;\n\n if (eventData?.data && eventData?.messageTypeName) {\n eventData = decodeResult(eventData.messageTypeName, eventData.data);\n }\n\n callback(eventData);\n });\n }\n throw new Error('No listeners supported.');\n }\n}\n\nexport * from \"./BlueCore_pb\";\nexport * from \"./BlueLock_pb\";\nexport * from \"./BlueSDK_pb\";\nexport * from \"./BlueSystem_pb\";\n"]}
|
package/dist/plugin.cjs.js
CHANGED
|
@@ -4215,18 +4215,21 @@ class BlueIDAccessInterop {
|
|
|
4215
4215
|
if (!command) {
|
|
4216
4216
|
throw new Error("Missing valid command");
|
|
4217
4217
|
}
|
|
4218
|
+
console.log('Starting command: ' + JSON.stringify(command));
|
|
4218
4219
|
const result = await this.runCommandFunc({
|
|
4219
4220
|
command,
|
|
4220
4221
|
arg0: encodeArgument(arg0),
|
|
4221
4222
|
arg1: encodeArgument(arg1),
|
|
4222
4223
|
arg2: encodeArgument(arg2),
|
|
4223
4224
|
});
|
|
4225
|
+
console.log('Running command with result : ' + JSON.stringify(result));
|
|
4224
4226
|
if (!result) {
|
|
4225
4227
|
return null;
|
|
4226
4228
|
}
|
|
4227
4229
|
if (result.data && result.messageTypeName) {
|
|
4228
4230
|
return decodeResult(result.messageTypeName, result.data);
|
|
4229
4231
|
}
|
|
4232
|
+
console.log('result from interop ' + command + ' : ' + JSON.stringify(result.data));
|
|
4230
4233
|
return result.data;
|
|
4231
4234
|
}
|
|
4232
4235
|
async terminalRunAll(deviceID, requests, timeoutSeconds = 10.0) {
|