@hanwha-ss1/plugin 0.2.0 → 0.2.2
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/README.md +3 -5
- package/dist/esm/definitions.d.ts +2 -5
- package/dist/esm/definitions.js.map +1 -1
- package/dist/esm/web.d.ts +1 -1
- package/dist/esm/web.js +1 -1
- package/dist/esm/web.js.map +1 -1
- package/dist/plugin.cjs.js +1 -1
- package/dist/plugin.cjs.js.map +1 -1
- package/dist/plugin.js +1 -1
- package/dist/plugin.js.map +1 -1
- package/ios/Plugin/Auth/AuthPlugin.swift +15 -0
- package/ios/Plugin/Auth/AuthService.swift +59 -0
- package/ios/Plugin/{ContactPlugin.swift → Contact/ContactPlugin.swift} +3 -34
- package/ios/Plugin/{Contact.swift → Contact/ContactService.swift} +1 -1
- package/ios/Plugin/{ContactPlugin.m → Plugin.m} +2 -0
- package/ios/Plugin/Plugin.swift +30 -0
- package/package.json +1 -1
- /package/ios/Plugin/{Contact.h → Plugin.h} +0 -0
package/README.md
CHANGED
|
@@ -11,7 +11,7 @@ npx cap sync
|
|
|
11
11
|
```javascript
|
|
12
12
|
import { HanwhaPlugin } from "@hanwha-ss1/plugin"
|
|
13
13
|
|
|
14
|
-
// 앱 실행
|
|
14
|
+
// 앱 실행 (Only: Android)
|
|
15
15
|
await HanwhaPlugin.executeApp({
|
|
16
16
|
package: "패키지명"
|
|
17
17
|
})
|
|
@@ -25,10 +25,8 @@ await HanwhaPlugin.addContact({
|
|
|
25
25
|
ext: "내선"
|
|
26
26
|
})
|
|
27
27
|
|
|
28
|
-
//
|
|
29
|
-
await HanwhaPlugin.
|
|
30
|
-
disabled: "true"
|
|
31
|
-
})
|
|
28
|
+
// 생체인증
|
|
29
|
+
await HanwhaPlugin.auth()
|
|
32
30
|
```
|
|
33
31
|
|
|
34
32
|
## API
|
|
@@ -26,12 +26,9 @@ export interface Plugin {
|
|
|
26
26
|
value: string;
|
|
27
27
|
}>;
|
|
28
28
|
/**
|
|
29
|
-
*
|
|
30
|
-
* @param options disabled : 캡쳐 방지 여부 (true, false)
|
|
29
|
+
* TouchID, FaceID
|
|
31
30
|
*/
|
|
32
|
-
|
|
33
|
-
disabled: string;
|
|
34
|
-
}): Promise<{
|
|
31
|
+
auth(): Promise<{
|
|
35
32
|
value: string;
|
|
36
33
|
}>;
|
|
37
34
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"definitions.js","sourceRoot":"","sources":["../../src/definitions.ts"],"names":[],"mappings":"","sourcesContent":["export interface Plugin {\n /**\n * 앱 실행\n * @param options package : 패키지명\n */\n executeApp(options: {\n package: string;\n }): Promise<{ value: string }>;\n\n /**\n * 연락처 저장\n * @param options name : 성명\n * @param options phone : 전화번호\n * @param options email : 이메일\n * @param options dept : 소속\n * @param options ext : 내선번호\n */\n addContact(options: {\n name: string;\n phone: string;\n email: string;\n dept: string;\n ext: string;\n }): Promise<{ value: string }>;\n\n
|
|
1
|
+
{"version":3,"file":"definitions.js","sourceRoot":"","sources":["../../src/definitions.ts"],"names":[],"mappings":"","sourcesContent":["export interface Plugin {\n /**\n * 앱 실행\n * @param options package : 패키지명\n */\n executeApp(options: {\n package: string;\n }): Promise<{ value: string }>;\n\n /**\n * 연락처 저장\n * @param options name : 성명\n * @param options phone : 전화번호\n * @param options email : 이메일\n * @param options dept : 소속\n * @param options ext : 내선번호\n */\n addContact(options: {\n name: string;\n phone: string;\n email: string;\n dept: string;\n ext: string;\n }): Promise<{ value: string }>;\n\n /**\n * TouchID, FaceID\n */\n auth(): Promise<{ value: string }>;\n}\n\n"]}
|
package/dist/esm/web.d.ts
CHANGED
package/dist/esm/web.js
CHANGED
package/dist/esm/web.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"web.js","sourceRoot":"","sources":["../../src/web.ts"],"names":[],"mappings":"AAAA,sDAAsD;AACtD,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAE5C,MAAM,OAAO,SAAU,SAAQ,SAAS;IAEtC,KAAK,CAAC,UAAU;QACd,OAAO,EAAE,OAAO,EAAE,EAAE,EAAE,CAAC;IACzB,CAAC;IAED,KAAK,CAAC,UAAU;QACd,OAAO,EAAE,OAAO,EAAE,EAAE,EAAE,CAAC;IACzB,CAAC;IAED,KAAK,CAAC,
|
|
1
|
+
{"version":3,"file":"web.js","sourceRoot":"","sources":["../../src/web.ts"],"names":[],"mappings":"AAAA,sDAAsD;AACtD,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAE5C,MAAM,OAAO,SAAU,SAAQ,SAAS;IAEtC,KAAK,CAAC,UAAU;QACd,OAAO,EAAE,OAAO,EAAE,EAAE,EAAE,CAAC;IACzB,CAAC;IAED,KAAK,CAAC,UAAU;QACd,OAAO,EAAE,OAAO,EAAE,EAAE,EAAE,CAAC;IACzB,CAAC;IAED,KAAK,CAAC,IAAI;QACR,OAAO,EAAE,OAAO,EAAE,EAAE,EAAE,CAAC;IACzB,CAAC;CACF","sourcesContent":["/* eslint-disable @typescript-eslint/no-unused-vars */\nimport { WebPlugin } from '@capacitor/core';\nimport type { Plugin } from './definitions';\nexport class PluginWeb extends WebPlugin implements Plugin {\n\n async executeApp(): Promise<any> {\n return { results: {} };\n }\n\n async addContact(): Promise<any> {\n return { results: {} };\n }\n\n async auth(): Promise<any> {\n return { results: {} };\n }\n}\n"]}
|
package/dist/plugin.cjs.js
CHANGED
package/dist/plugin.cjs.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin.cjs.js","sources":["esm/index.js","esm/web.js"],"sourcesContent":["import { registerPlugin } from '@capacitor/core';\nconst HanwhaPlugin = registerPlugin('Plugin', {\n web: () => import('./web').then(m => new m.PluginWeb()),\n});\nexport * from './definitions';\nexport { HanwhaPlugin };\n//# sourceMappingURL=index.js.map","/* eslint-disable @typescript-eslint/no-unused-vars */\nimport { WebPlugin } from '@capacitor/core';\nexport class PluginWeb extends WebPlugin {\n async executeApp() {\n return { results: {} };\n }\n async addContact() {\n return { results: {} };\n }\n async
|
|
1
|
+
{"version":3,"file":"plugin.cjs.js","sources":["esm/index.js","esm/web.js"],"sourcesContent":["import { registerPlugin } from '@capacitor/core';\nconst HanwhaPlugin = registerPlugin('Plugin', {\n web: () => import('./web').then(m => new m.PluginWeb()),\n});\nexport * from './definitions';\nexport { HanwhaPlugin };\n//# sourceMappingURL=index.js.map","/* eslint-disable @typescript-eslint/no-unused-vars */\nimport { WebPlugin } from '@capacitor/core';\nexport class PluginWeb extends WebPlugin {\n async executeApp() {\n return { results: {} };\n }\n async addContact() {\n return { results: {} };\n }\n async auth() {\n return { results: {} };\n }\n}\n//# sourceMappingURL=web.js.map"],"names":["registerPlugin","WebPlugin"],"mappings":";;;;;;AACK,MAAC,YAAY,GAAGA,mBAAc,CAAC,QAAQ,EAAE;AAC9C,IAAI,GAAG,EAAE,MAAM,mDAAe,CAAC,IAAI,CAAC,CAAC,IAAI,IAAI,CAAC,CAAC,SAAS,EAAE,CAAC;AAC3D,CAAC;;ACHD;AAEO,MAAM,SAAS,SAASC,cAAS,CAAC;AACzC,IAAI,MAAM,UAAU,GAAG;AACvB,QAAQ,OAAO,EAAE,OAAO,EAAE,EAAE,EAAE,CAAC;AAC/B,KAAK;AACL,IAAI,MAAM,UAAU,GAAG;AACvB,QAAQ,OAAO,EAAE,OAAO,EAAE,EAAE,EAAE,CAAC;AAC/B,KAAK;AACL,IAAI,MAAM,IAAI,GAAG;AACjB,QAAQ,OAAO,EAAE,OAAO,EAAE,EAAE,EAAE,CAAC;AAC/B,KAAK;AACL;;;;;;;;;"}
|
package/dist/plugin.js
CHANGED
package/dist/plugin.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin.js","sources":["esm/index.js","esm/web.js"],"sourcesContent":["import { registerPlugin } from '@capacitor/core';\nconst HanwhaPlugin = registerPlugin('Plugin', {\n web: () => import('./web').then(m => new m.PluginWeb()),\n});\nexport * from './definitions';\nexport { HanwhaPlugin };\n//# sourceMappingURL=index.js.map","/* eslint-disable @typescript-eslint/no-unused-vars */\nimport { WebPlugin } from '@capacitor/core';\nexport class PluginWeb extends WebPlugin {\n async executeApp() {\n return { results: {} };\n }\n async addContact() {\n return { results: {} };\n }\n async
|
|
1
|
+
{"version":3,"file":"plugin.js","sources":["esm/index.js","esm/web.js"],"sourcesContent":["import { registerPlugin } from '@capacitor/core';\nconst HanwhaPlugin = registerPlugin('Plugin', {\n web: () => import('./web').then(m => new m.PluginWeb()),\n});\nexport * from './definitions';\nexport { HanwhaPlugin };\n//# sourceMappingURL=index.js.map","/* eslint-disable @typescript-eslint/no-unused-vars */\nimport { WebPlugin } from '@capacitor/core';\nexport class PluginWeb extends WebPlugin {\n async executeApp() {\n return { results: {} };\n }\n async addContact() {\n return { results: {} };\n }\n async auth() {\n return { results: {} };\n }\n}\n//# sourceMappingURL=web.js.map"],"names":["registerPlugin","WebPlugin"],"mappings":";;;AACK,UAAC,YAAY,GAAGA,mBAAc,CAAC,QAAQ,EAAE;IAC9C,IAAI,GAAG,EAAE,MAAM,mDAAe,CAAC,IAAI,CAAC,CAAC,IAAI,IAAI,CAAC,CAAC,SAAS,EAAE,CAAC;IAC3D,CAAC;;ICHD;IAEO,MAAM,SAAS,SAASC,cAAS,CAAC;IACzC,IAAI,MAAM,UAAU,GAAG;IACvB,QAAQ,OAAO,EAAE,OAAO,EAAE,EAAE,EAAE,CAAC;IAC/B,KAAK;IACL,IAAI,MAAM,UAAU,GAAG;IACvB,QAAQ,OAAO,EAAE,OAAO,EAAE,EAAE,EAAE,CAAC;IAC/B,KAAK;IACL,IAAI,MAAM,IAAI,GAAG;IACjB,QAAQ,OAAO,EAAE,OAAO,EAAE,EAAE,EAAE,CAAC;IAC/B,KAAK;IACL;;;;;;;;;;;;;;;;;"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import Foundation
|
|
2
|
+
import Capacitor
|
|
3
|
+
import Contacts
|
|
4
|
+
/**
|
|
5
|
+
* Please read the Capacitor iOS Plugin Development Guide
|
|
6
|
+
* here: https://capacitorjs.com/docs/plugins/ios
|
|
7
|
+
*/
|
|
8
|
+
public class AuthPlugin: CAPPlugin {
|
|
9
|
+
private let implementation = AuthService()
|
|
10
|
+
|
|
11
|
+
@objc func auth(_ call: CAPPluginCall) {
|
|
12
|
+
implementation.authService(call: call)
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import Foundation
|
|
2
|
+
import UIKit
|
|
3
|
+
import LocalAuthentication
|
|
4
|
+
import Capacitor
|
|
5
|
+
|
|
6
|
+
public class AuthService: NSObject {
|
|
7
|
+
public func authService(call: CAPPluginCall) {
|
|
8
|
+
|
|
9
|
+
let context = LAContext()
|
|
10
|
+
var error: NSError?
|
|
11
|
+
|
|
12
|
+
// Face ID 또는 Touch ID 사용 가능 여부 확인
|
|
13
|
+
if context.canEvaluatePolicy(.deviceOwnerAuthentication, error: &error) {
|
|
14
|
+
let reason = "생체 인식을 사용하여 로그인합니다."
|
|
15
|
+
|
|
16
|
+
// Face ID 또는 Touch ID 인증 시도
|
|
17
|
+
context.evaluatePolicy(.deviceOwnerAuthentication, localizedReason: reason) { success, error in
|
|
18
|
+
DispatchQueue.main.async {
|
|
19
|
+
if success {
|
|
20
|
+
// 인증 성공
|
|
21
|
+
call.resolve(self.settingResult(result: true, message: "생체 인식에 성공 하였습니다."))
|
|
22
|
+
} else {
|
|
23
|
+
// 인증 실패
|
|
24
|
+
if let error = error as NSError? {
|
|
25
|
+
let message: String
|
|
26
|
+
switch error.code {
|
|
27
|
+
case LAError.authenticationFailed.rawValue:
|
|
28
|
+
message = "인증에 실패했습니다."
|
|
29
|
+
case LAError.userCancel.rawValue:
|
|
30
|
+
message = "사용자가 취소했습니다."
|
|
31
|
+
case LAError.userFallback.rawValue:
|
|
32
|
+
message = "비밀번호를 입력하여 로그인하세요."
|
|
33
|
+
case LAError.biometryNotAvailable.rawValue:
|
|
34
|
+
message = "생체 인식을 사용할 수 없습니다."
|
|
35
|
+
case LAError.biometryNotEnrolled.rawValue:
|
|
36
|
+
message = "생체 인식이 등록되어 있지 않습니다."
|
|
37
|
+
case LAError.biometryLockout.rawValue:
|
|
38
|
+
message = "생체 인식이 잠겼습니다. 잠시 후 다시 시도하세요."
|
|
39
|
+
default:
|
|
40
|
+
message = "생체 인식에 실패했습니다."
|
|
41
|
+
}
|
|
42
|
+
call.resolve(self.settingResult(result: false, message: message))
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
} else {
|
|
48
|
+
call.resolve(self.settingResult(result: false, message: "생체 인식을 사용할 수 없습니다."))
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
func settingResult(result: Bool, message: String) -> [String: Any] {
|
|
54
|
+
return [
|
|
55
|
+
"result": result,
|
|
56
|
+
"message": message
|
|
57
|
+
]
|
|
58
|
+
}
|
|
59
|
+
}
|
|
@@ -1,13 +1,9 @@
|
|
|
1
1
|
import Foundation
|
|
2
2
|
import Capacitor
|
|
3
3
|
import Contacts
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
*/
|
|
8
|
-
@objc(Plugin)
|
|
9
|
-
public class Plugin: CAPPlugin {
|
|
10
|
-
private let implementation = Contact()
|
|
4
|
+
|
|
5
|
+
public class ContactPlugin: CAPPlugin {
|
|
6
|
+
private let implementation = ContactService()
|
|
11
7
|
|
|
12
8
|
@objc func addContact(_ call: CAPPluginCall) {
|
|
13
9
|
let name = call.getString("name") ?? ""
|
|
@@ -113,32 +109,5 @@ public class Plugin: CAPPlugin {
|
|
|
113
109
|
|
|
114
110
|
return result
|
|
115
111
|
}
|
|
116
|
-
//
|
|
117
|
-
// let store = CNContactStore()
|
|
118
|
-
// let keysToFetch: [CNKeyDescriptor] = [CNContactGivenNameKey as CNKeyDescriptor, CNContactFamilyNameKey as CNKeyDescriptor, CNContactPhoneNumbersKey as CNKeyDescriptor]
|
|
119
|
-
//
|
|
120
|
-
// // 전화번호에 일치하는 연락처를 검색하기 위한 NSPredicate를 생성
|
|
121
|
-
// let predicate = CNContact.predicateForContacts(withIdentifiers: [phoneNumber])
|
|
122
|
-
//
|
|
123
|
-
// do {
|
|
124
|
-
// // 모든 연락처 가져오기
|
|
125
|
-
// let allContacts = try store.unifiedContacts(matching: predicate, keysToFetch: keysToFetch)
|
|
126
|
-
//
|
|
127
|
-
// // 전화번호와 일치하는 연락처를 선택
|
|
128
|
-
// for contact in allContacts {
|
|
129
|
-
// for phoneNumberValue in contact.phoneNumbers {
|
|
130
|
-
// let number = phoneNumberValue.value
|
|
131
|
-
// if number.stringValue.contains(phoneNumber) {
|
|
132
|
-
// matchingContacts.append(contact)
|
|
133
|
-
// break
|
|
134
|
-
// }
|
|
135
|
-
// }
|
|
136
|
-
// }
|
|
137
|
-
// } catch {
|
|
138
|
-
// // 검색 중 오류 처리
|
|
139
|
-
// }
|
|
140
|
-
//
|
|
141
|
-
// return matchingContacts
|
|
142
|
-
// }
|
|
143
112
|
}
|
|
144
113
|
|
|
@@ -3,6 +3,8 @@
|
|
|
3
3
|
|
|
4
4
|
// Define the plugin using the CAP_PLUGIN Macro, and
|
|
5
5
|
// each method the plugin supports using the CAP_PLUGIN_METHOD macro.
|
|
6
|
+
|
|
6
7
|
CAP_PLUGIN(Plugin, "Plugin",
|
|
8
|
+
CAP_PLUGIN_METHOD(auth, CAPPluginReturnPromise);
|
|
7
9
|
CAP_PLUGIN_METHOD(addContact, CAPPluginReturnPromise);
|
|
8
10
|
)
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import Foundation
|
|
2
|
+
import Capacitor
|
|
3
|
+
import Contacts
|
|
4
|
+
/**
|
|
5
|
+
* Please read the Capacitor iOS Plugin Development Guide
|
|
6
|
+
* here: https://capacitorjs.com/docs/plugins/ios
|
|
7
|
+
*/
|
|
8
|
+
@objc(Plugin)
|
|
9
|
+
public class Plugin: CAPPlugin {
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
안드로이드에서만 사용
|
|
13
|
+
*/
|
|
14
|
+
@objc func executeApp(_ call: CAPPluginCall) {
|
|
15
|
+
call.resolve([
|
|
16
|
+
"result": true,
|
|
17
|
+
"message": "완료"
|
|
18
|
+
])
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
@objc func auth(_ call: CAPPluginCall) {
|
|
22
|
+
AuthPlugin().auth(call)
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
@objc func addContact(_ call: CAPPluginCall) {
|
|
26
|
+
ContactPlugin().addContact(call)
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
}
|
|
30
|
+
|
package/package.json
CHANGED
|
File without changes
|