@capawesome/capacitor-android-sms-retriever 0.0.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.
- package/CapawesomeCapacitorAndroidSmsRetriever.podspec +17 -0
- package/LICENSE +21 -0
- package/Package.swift +28 -0
- package/README.md +206 -0
- package/android/build.gradle +62 -0
- package/android/src/main/AndroidManifest.xml +1 -0
- package/android/src/main/java/io/capawesome/capacitorjs/plugins/androidsmsretriever/AndroidSmsRetriever.java +194 -0
- package/android/src/main/java/io/capawesome/capacitorjs/plugins/androidsmsretriever/AndroidSmsRetrieverPlugin.java +153 -0
- package/android/src/main/java/io/capawesome/capacitorjs/plugins/androidsmsretriever/classes/CustomException.java +20 -0
- package/android/src/main/java/io/capawesome/capacitorjs/plugins/androidsmsretriever/classes/CustomExceptions.java +17 -0
- package/android/src/main/java/io/capawesome/capacitorjs/plugins/androidsmsretriever/classes/options/RetrieveSmsOptions.java +25 -0
- package/android/src/main/java/io/capawesome/capacitorjs/plugins/androidsmsretriever/classes/results/RequestPhoneNumberResult.java +23 -0
- package/android/src/main/java/io/capawesome/capacitorjs/plugins/androidsmsretriever/classes/results/RetrieveSmsResult.java +23 -0
- package/android/src/main/java/io/capawesome/capacitorjs/plugins/androidsmsretriever/interfaces/Callback.java +5 -0
- package/android/src/main/java/io/capawesome/capacitorjs/plugins/androidsmsretriever/interfaces/NonEmptyResultCallback.java +7 -0
- package/android/src/main/java/io/capawesome/capacitorjs/plugins/androidsmsretriever/interfaces/Result.java +7 -0
- package/android/src/main/res/.gitkeep +0 -0
- package/dist/docs.json +147 -0
- package/dist/esm/definitions.d.ts +105 -0
- package/dist/esm/definitions.js +37 -0
- package/dist/esm/definitions.js.map +1 -0
- package/dist/esm/index.d.ts +4 -0
- package/dist/esm/index.js +7 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/web.d.ts +6 -0
- package/dist/esm/web.js +10 -0
- package/dist/esm/web.js.map +1 -0
- package/dist/plugin.cjs.js +61 -0
- package/dist/plugin.cjs.js.map +1 -0
- package/dist/plugin.js +64 -0
- package/dist/plugin.js.map +1 -0
- package/ios/Plugin/AndroidSmsRetrieverPlugin.swift +24 -0
- package/ios/Plugin/Info.plist +24 -0
- package/package.json +91 -0
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
package io.capawesome.capacitorjs.plugins.androidsmsretriever.classes;
|
|
2
|
+
|
|
3
|
+
import androidx.annotation.NonNull;
|
|
4
|
+
import androidx.annotation.Nullable;
|
|
5
|
+
|
|
6
|
+
public class CustomException extends Exception {
|
|
7
|
+
|
|
8
|
+
@Nullable
|
|
9
|
+
private final String code;
|
|
10
|
+
|
|
11
|
+
public CustomException(@Nullable String code, @NonNull String message) {
|
|
12
|
+
super(message);
|
|
13
|
+
this.code = code;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
@Nullable
|
|
17
|
+
public String getCode() {
|
|
18
|
+
return code;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
package io.capawesome.capacitorjs.plugins.androidsmsretriever.classes;
|
|
2
|
+
|
|
3
|
+
public class CustomExceptions {
|
|
4
|
+
|
|
5
|
+
public static final CustomException CANCELED = new CustomException("CANCELED", "The operation was canceled.");
|
|
6
|
+
public static final CustomException OPERATION_IN_PROGRESS = new CustomException(null, "An SMS retrieval is already in progress.");
|
|
7
|
+
public static final CustomException PHONE_NUMBER_HINT_FAILED = new CustomException(
|
|
8
|
+
"PHONE_NUMBER_HINT_FAILED",
|
|
9
|
+
"The phone number could not be requested."
|
|
10
|
+
);
|
|
11
|
+
public static final CustomException RETRIEVE_FAILED = new CustomException("RETRIEVE_FAILED", "The SMS message could not be retrieved.");
|
|
12
|
+
public static final CustomException TIMEOUT = new CustomException("TIMEOUT", "No SMS message was received within the time window.");
|
|
13
|
+
public static final CustomException USER_DENIED = new CustomException(
|
|
14
|
+
"USER_DENIED",
|
|
15
|
+
"The user denied consent to read the SMS message."
|
|
16
|
+
);
|
|
17
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
package io.capawesome.capacitorjs.plugins.androidsmsretriever.classes.options;
|
|
2
|
+
|
|
3
|
+
import androidx.annotation.NonNull;
|
|
4
|
+
import androidx.annotation.Nullable;
|
|
5
|
+
import com.getcapacitor.PluginCall;
|
|
6
|
+
|
|
7
|
+
public class RetrieveSmsOptions {
|
|
8
|
+
|
|
9
|
+
@Nullable
|
|
10
|
+
private final String senderPhoneNumber;
|
|
11
|
+
|
|
12
|
+
public RetrieveSmsOptions(@NonNull PluginCall call) {
|
|
13
|
+
this.senderPhoneNumber = getSenderPhoneNumberFromCall(call);
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
@Nullable
|
|
17
|
+
public String getSenderPhoneNumber() {
|
|
18
|
+
return senderPhoneNumber;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
@Nullable
|
|
22
|
+
private static String getSenderPhoneNumberFromCall(@NonNull PluginCall call) {
|
|
23
|
+
return call.getString("senderPhoneNumber");
|
|
24
|
+
}
|
|
25
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
package io.capawesome.capacitorjs.plugins.androidsmsretriever.classes.results;
|
|
2
|
+
|
|
3
|
+
import androidx.annotation.NonNull;
|
|
4
|
+
import com.getcapacitor.JSObject;
|
|
5
|
+
import io.capawesome.capacitorjs.plugins.androidsmsretriever.interfaces.Result;
|
|
6
|
+
|
|
7
|
+
public class RequestPhoneNumberResult implements Result {
|
|
8
|
+
|
|
9
|
+
@NonNull
|
|
10
|
+
private final String phoneNumber;
|
|
11
|
+
|
|
12
|
+
public RequestPhoneNumberResult(@NonNull String phoneNumber) {
|
|
13
|
+
this.phoneNumber = phoneNumber;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
@Override
|
|
17
|
+
@NonNull
|
|
18
|
+
public JSObject toJSObject() {
|
|
19
|
+
JSObject result = new JSObject();
|
|
20
|
+
result.put("phoneNumber", phoneNumber);
|
|
21
|
+
return result;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
package io.capawesome.capacitorjs.plugins.androidsmsretriever.classes.results;
|
|
2
|
+
|
|
3
|
+
import androidx.annotation.NonNull;
|
|
4
|
+
import com.getcapacitor.JSObject;
|
|
5
|
+
import io.capawesome.capacitorjs.plugins.androidsmsretriever.interfaces.Result;
|
|
6
|
+
|
|
7
|
+
public class RetrieveSmsResult implements Result {
|
|
8
|
+
|
|
9
|
+
@NonNull
|
|
10
|
+
private final String message;
|
|
11
|
+
|
|
12
|
+
public RetrieveSmsResult(@NonNull String message) {
|
|
13
|
+
this.message = message;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
@Override
|
|
17
|
+
@NonNull
|
|
18
|
+
public JSObject toJSObject() {
|
|
19
|
+
JSObject result = new JSObject();
|
|
20
|
+
result.put("message", message);
|
|
21
|
+
return result;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
File without changes
|
package/dist/docs.json
ADDED
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
{
|
|
2
|
+
"api": {
|
|
3
|
+
"name": "AndroidSmsRetrieverPlugin",
|
|
4
|
+
"slug": "androidsmsretrieverplugin",
|
|
5
|
+
"docs": "",
|
|
6
|
+
"tags": [],
|
|
7
|
+
"methods": [
|
|
8
|
+
{
|
|
9
|
+
"name": "requestPhoneNumber",
|
|
10
|
+
"signature": "() => Promise<RequestPhoneNumberResult>",
|
|
11
|
+
"parameters": [],
|
|
12
|
+
"returns": "Promise<RequestPhoneNumberResult>",
|
|
13
|
+
"tags": [
|
|
14
|
+
{
|
|
15
|
+
"name": "since",
|
|
16
|
+
"text": "0.1.0"
|
|
17
|
+
}
|
|
18
|
+
],
|
|
19
|
+
"docs": "Request the user's phone number via the Phone Number Hint API.\n\nA system bottom sheet is displayed that lets the user pick one of the\nphone numbers associated with the device. The selected phone number is\nreturned so it can be used to prefill a phone number input field.\n\nOnly available on Android.",
|
|
20
|
+
"complexTypes": [
|
|
21
|
+
"RequestPhoneNumberResult"
|
|
22
|
+
],
|
|
23
|
+
"slug": "requestphonenumber"
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
"name": "retrieveSms",
|
|
27
|
+
"signature": "(options?: RetrieveSmsOptions | undefined) => Promise<RetrieveSmsResult>",
|
|
28
|
+
"parameters": [
|
|
29
|
+
{
|
|
30
|
+
"name": "options",
|
|
31
|
+
"docs": "",
|
|
32
|
+
"type": "RetrieveSmsOptions | undefined"
|
|
33
|
+
}
|
|
34
|
+
],
|
|
35
|
+
"returns": "Promise<RetrieveSmsResult>",
|
|
36
|
+
"tags": [
|
|
37
|
+
{
|
|
38
|
+
"name": "since",
|
|
39
|
+
"text": "0.1.0"
|
|
40
|
+
}
|
|
41
|
+
],
|
|
42
|
+
"docs": "Retrieve an incoming verification SMS via the SMS User Consent API.\n\nA system consent dialog is displayed when a matching SMS is received.\nThe promise resolves with the full message text once the user consents,\nso the app can extract the one-time code itself.\n\nThe underlying broadcast waits up to 5 minutes for a matching SMS. If no\nSMS is received within this time, the promise rejects with the error\ncode `TIMEOUT`.\n\nOnly available on Android.",
|
|
43
|
+
"complexTypes": [
|
|
44
|
+
"RetrieveSmsResult",
|
|
45
|
+
"RetrieveSmsOptions"
|
|
46
|
+
],
|
|
47
|
+
"slug": "retrievesms"
|
|
48
|
+
}
|
|
49
|
+
],
|
|
50
|
+
"properties": []
|
|
51
|
+
},
|
|
52
|
+
"interfaces": [
|
|
53
|
+
{
|
|
54
|
+
"name": "RequestPhoneNumberResult",
|
|
55
|
+
"slug": "requestphonenumberresult",
|
|
56
|
+
"docs": "",
|
|
57
|
+
"tags": [
|
|
58
|
+
{
|
|
59
|
+
"text": "0.1.0",
|
|
60
|
+
"name": "since"
|
|
61
|
+
}
|
|
62
|
+
],
|
|
63
|
+
"methods": [],
|
|
64
|
+
"properties": [
|
|
65
|
+
{
|
|
66
|
+
"name": "phoneNumber",
|
|
67
|
+
"tags": [
|
|
68
|
+
{
|
|
69
|
+
"text": "'+12025550123'",
|
|
70
|
+
"name": "example"
|
|
71
|
+
},
|
|
72
|
+
{
|
|
73
|
+
"text": "0.1.0",
|
|
74
|
+
"name": "since"
|
|
75
|
+
}
|
|
76
|
+
],
|
|
77
|
+
"docs": "The phone number selected by the user.",
|
|
78
|
+
"complexTypes": [],
|
|
79
|
+
"type": "string"
|
|
80
|
+
}
|
|
81
|
+
]
|
|
82
|
+
},
|
|
83
|
+
{
|
|
84
|
+
"name": "RetrieveSmsResult",
|
|
85
|
+
"slug": "retrievesmsresult",
|
|
86
|
+
"docs": "",
|
|
87
|
+
"tags": [
|
|
88
|
+
{
|
|
89
|
+
"text": "0.1.0",
|
|
90
|
+
"name": "since"
|
|
91
|
+
}
|
|
92
|
+
],
|
|
93
|
+
"methods": [],
|
|
94
|
+
"properties": [
|
|
95
|
+
{
|
|
96
|
+
"name": "message",
|
|
97
|
+
"tags": [
|
|
98
|
+
{
|
|
99
|
+
"text": "'Your verification code is 123456.'",
|
|
100
|
+
"name": "example"
|
|
101
|
+
},
|
|
102
|
+
{
|
|
103
|
+
"text": "0.1.0",
|
|
104
|
+
"name": "since"
|
|
105
|
+
}
|
|
106
|
+
],
|
|
107
|
+
"docs": "The full text of the retrieved SMS message.\n\nThe app is responsible for extracting the one-time code from the message.",
|
|
108
|
+
"complexTypes": [],
|
|
109
|
+
"type": "string"
|
|
110
|
+
}
|
|
111
|
+
]
|
|
112
|
+
},
|
|
113
|
+
{
|
|
114
|
+
"name": "RetrieveSmsOptions",
|
|
115
|
+
"slug": "retrievesmsoptions",
|
|
116
|
+
"docs": "",
|
|
117
|
+
"tags": [
|
|
118
|
+
{
|
|
119
|
+
"text": "0.1.0",
|
|
120
|
+
"name": "since"
|
|
121
|
+
}
|
|
122
|
+
],
|
|
123
|
+
"methods": [],
|
|
124
|
+
"properties": [
|
|
125
|
+
{
|
|
126
|
+
"name": "senderPhoneNumber",
|
|
127
|
+
"tags": [
|
|
128
|
+
{
|
|
129
|
+
"text": "'+12025550123'",
|
|
130
|
+
"name": "example"
|
|
131
|
+
},
|
|
132
|
+
{
|
|
133
|
+
"text": "0.1.0",
|
|
134
|
+
"name": "since"
|
|
135
|
+
}
|
|
136
|
+
],
|
|
137
|
+
"docs": "The phone number of the sender to filter incoming messages by.\n\nIf not provided, the SMS from any sender is retrieved.",
|
|
138
|
+
"complexTypes": [],
|
|
139
|
+
"type": "string | undefined"
|
|
140
|
+
}
|
|
141
|
+
]
|
|
142
|
+
}
|
|
143
|
+
],
|
|
144
|
+
"enums": [],
|
|
145
|
+
"typeAliases": [],
|
|
146
|
+
"pluginConfigs": []
|
|
147
|
+
}
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
export interface AndroidSmsRetrieverPlugin {
|
|
2
|
+
/**
|
|
3
|
+
* Request the user's phone number via the Phone Number Hint API.
|
|
4
|
+
*
|
|
5
|
+
* A system bottom sheet is displayed that lets the user pick one of the
|
|
6
|
+
* phone numbers associated with the device. The selected phone number is
|
|
7
|
+
* returned so it can be used to prefill a phone number input field.
|
|
8
|
+
*
|
|
9
|
+
* Only available on Android.
|
|
10
|
+
*
|
|
11
|
+
* @since 0.1.0
|
|
12
|
+
*/
|
|
13
|
+
requestPhoneNumber(): Promise<RequestPhoneNumberResult>;
|
|
14
|
+
/**
|
|
15
|
+
* Retrieve an incoming verification SMS via the SMS User Consent API.
|
|
16
|
+
*
|
|
17
|
+
* A system consent dialog is displayed when a matching SMS is received.
|
|
18
|
+
* The promise resolves with the full message text once the user consents,
|
|
19
|
+
* so the app can extract the one-time code itself.
|
|
20
|
+
*
|
|
21
|
+
* The underlying broadcast waits up to 5 minutes for a matching SMS. If no
|
|
22
|
+
* SMS is received within this time, the promise rejects with the error
|
|
23
|
+
* code `TIMEOUT`.
|
|
24
|
+
*
|
|
25
|
+
* Only available on Android.
|
|
26
|
+
*
|
|
27
|
+
* @since 0.1.0
|
|
28
|
+
*/
|
|
29
|
+
retrieveSms(options?: RetrieveSmsOptions): Promise<RetrieveSmsResult>;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* @since 0.1.0
|
|
33
|
+
*/
|
|
34
|
+
export interface RequestPhoneNumberResult {
|
|
35
|
+
/**
|
|
36
|
+
* The phone number selected by the user.
|
|
37
|
+
*
|
|
38
|
+
* @example '+12025550123'
|
|
39
|
+
* @since 0.1.0
|
|
40
|
+
*/
|
|
41
|
+
phoneNumber: string;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* @since 0.1.0
|
|
45
|
+
*/
|
|
46
|
+
export interface RetrieveSmsOptions {
|
|
47
|
+
/**
|
|
48
|
+
* The phone number of the sender to filter incoming messages by.
|
|
49
|
+
*
|
|
50
|
+
* If not provided, the SMS from any sender is retrieved.
|
|
51
|
+
*
|
|
52
|
+
* @example '+12025550123'
|
|
53
|
+
* @since 0.1.0
|
|
54
|
+
*/
|
|
55
|
+
senderPhoneNumber?: string;
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* @since 0.1.0
|
|
59
|
+
*/
|
|
60
|
+
export interface RetrieveSmsResult {
|
|
61
|
+
/**
|
|
62
|
+
* The full text of the retrieved SMS message.
|
|
63
|
+
*
|
|
64
|
+
* The app is responsible for extracting the one-time code from the message.
|
|
65
|
+
*
|
|
66
|
+
* @example 'Your verification code is 123456.'
|
|
67
|
+
* @since 0.1.0
|
|
68
|
+
*/
|
|
69
|
+
message: string;
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* @since 0.1.0
|
|
73
|
+
*/
|
|
74
|
+
export declare enum ErrorCode {
|
|
75
|
+
/**
|
|
76
|
+
* The user canceled the operation.
|
|
77
|
+
*
|
|
78
|
+
* @since 0.1.0
|
|
79
|
+
*/
|
|
80
|
+
Canceled = "CANCELED",
|
|
81
|
+
/**
|
|
82
|
+
* The phone number could not be requested via the Phone Number Hint API.
|
|
83
|
+
*
|
|
84
|
+
* @since 0.1.0
|
|
85
|
+
*/
|
|
86
|
+
PhoneNumberHintFailed = "PHONE_NUMBER_HINT_FAILED",
|
|
87
|
+
/**
|
|
88
|
+
* The incoming SMS message could not be retrieved.
|
|
89
|
+
*
|
|
90
|
+
* @since 0.1.0
|
|
91
|
+
*/
|
|
92
|
+
RetrieveFailed = "RETRIEVE_FAILED",
|
|
93
|
+
/**
|
|
94
|
+
* No matching SMS message was received within the 5 minute time window.
|
|
95
|
+
*
|
|
96
|
+
* @since 0.1.0
|
|
97
|
+
*/
|
|
98
|
+
Timeout = "TIMEOUT",
|
|
99
|
+
/**
|
|
100
|
+
* The user denied consent to read the incoming SMS message.
|
|
101
|
+
*
|
|
102
|
+
* @since 0.1.0
|
|
103
|
+
*/
|
|
104
|
+
UserDenied = "USER_DENIED"
|
|
105
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @since 0.1.0
|
|
3
|
+
*/
|
|
4
|
+
export var ErrorCode;
|
|
5
|
+
(function (ErrorCode) {
|
|
6
|
+
/**
|
|
7
|
+
* The user canceled the operation.
|
|
8
|
+
*
|
|
9
|
+
* @since 0.1.0
|
|
10
|
+
*/
|
|
11
|
+
ErrorCode["Canceled"] = "CANCELED";
|
|
12
|
+
/**
|
|
13
|
+
* The phone number could not be requested via the Phone Number Hint API.
|
|
14
|
+
*
|
|
15
|
+
* @since 0.1.0
|
|
16
|
+
*/
|
|
17
|
+
ErrorCode["PhoneNumberHintFailed"] = "PHONE_NUMBER_HINT_FAILED";
|
|
18
|
+
/**
|
|
19
|
+
* The incoming SMS message could not be retrieved.
|
|
20
|
+
*
|
|
21
|
+
* @since 0.1.0
|
|
22
|
+
*/
|
|
23
|
+
ErrorCode["RetrieveFailed"] = "RETRIEVE_FAILED";
|
|
24
|
+
/**
|
|
25
|
+
* No matching SMS message was received within the 5 minute time window.
|
|
26
|
+
*
|
|
27
|
+
* @since 0.1.0
|
|
28
|
+
*/
|
|
29
|
+
ErrorCode["Timeout"] = "TIMEOUT";
|
|
30
|
+
/**
|
|
31
|
+
* The user denied consent to read the incoming SMS message.
|
|
32
|
+
*
|
|
33
|
+
* @since 0.1.0
|
|
34
|
+
*/
|
|
35
|
+
ErrorCode["UserDenied"] = "USER_DENIED";
|
|
36
|
+
})(ErrorCode || (ErrorCode = {}));
|
|
37
|
+
//# sourceMappingURL=definitions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"definitions.js","sourceRoot":"","sources":["../../src/definitions.ts"],"names":[],"mappings":"AA0EA;;GAEG;AACH,MAAM,CAAN,IAAY,SA+BX;AA/BD,WAAY,SAAS;IACnB;;;;OAIG;IACH,kCAAqB,CAAA;IACrB;;;;OAIG;IACH,+DAAkD,CAAA;IAClD;;;;OAIG;IACH,+CAAkC,CAAA;IAClC;;;;OAIG;IACH,gCAAmB,CAAA;IACnB;;;;OAIG;IACH,uCAA0B,CAAA;AAC5B,CAAC,EA/BW,SAAS,KAAT,SAAS,QA+BpB","sourcesContent":["export interface AndroidSmsRetrieverPlugin {\n /**\n * Request the user's phone number via the Phone Number Hint API.\n *\n * A system bottom sheet is displayed that lets the user pick one of the\n * phone numbers associated with the device. The selected phone number is\n * returned so it can be used to prefill a phone number input field.\n *\n * Only available on Android.\n *\n * @since 0.1.0\n */\n requestPhoneNumber(): Promise<RequestPhoneNumberResult>;\n /**\n * Retrieve an incoming verification SMS via the SMS User Consent API.\n *\n * A system consent dialog is displayed when a matching SMS is received.\n * The promise resolves with the full message text once the user consents,\n * so the app can extract the one-time code itself.\n *\n * The underlying broadcast waits up to 5 minutes for a matching SMS. If no\n * SMS is received within this time, the promise rejects with the error\n * code `TIMEOUT`.\n *\n * Only available on Android.\n *\n * @since 0.1.0\n */\n retrieveSms(options?: RetrieveSmsOptions): Promise<RetrieveSmsResult>;\n}\n\n/**\n * @since 0.1.0\n */\nexport interface RequestPhoneNumberResult {\n /**\n * The phone number selected by the user.\n *\n * @example '+12025550123'\n * @since 0.1.0\n */\n phoneNumber: string;\n}\n\n/**\n * @since 0.1.0\n */\nexport interface RetrieveSmsOptions {\n /**\n * The phone number of the sender to filter incoming messages by.\n *\n * If not provided, the SMS from any sender is retrieved.\n *\n * @example '+12025550123'\n * @since 0.1.0\n */\n senderPhoneNumber?: string;\n}\n\n/**\n * @since 0.1.0\n */\nexport interface RetrieveSmsResult {\n /**\n * The full text of the retrieved SMS message.\n *\n * The app is responsible for extracting the one-time code from the message.\n *\n * @example 'Your verification code is 123456.'\n * @since 0.1.0\n */\n message: string;\n}\n\n/**\n * @since 0.1.0\n */\nexport enum ErrorCode {\n /**\n * The user canceled the operation.\n *\n * @since 0.1.0\n */\n Canceled = 'CANCELED',\n /**\n * The phone number could not be requested via the Phone Number Hint API.\n *\n * @since 0.1.0\n */\n PhoneNumberHintFailed = 'PHONE_NUMBER_HINT_FAILED',\n /**\n * The incoming SMS message could not be retrieved.\n *\n * @since 0.1.0\n */\n RetrieveFailed = 'RETRIEVE_FAILED',\n /**\n * No matching SMS message was received within the 5 minute time window.\n *\n * @since 0.1.0\n */\n Timeout = 'TIMEOUT',\n /**\n * The user denied consent to read the incoming SMS message.\n *\n * @since 0.1.0\n */\n UserDenied = 'USER_DENIED',\n}\n"]}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { registerPlugin } from '@capacitor/core';
|
|
2
|
+
const AndroidSmsRetriever = registerPlugin('AndroidSmsRetriever', {
|
|
3
|
+
web: () => import('./web').then(m => new m.AndroidSmsRetrieverWeb()),
|
|
4
|
+
});
|
|
5
|
+
export * from './definitions';
|
|
6
|
+
export { AndroidSmsRetriever };
|
|
7
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAIjD,MAAM,mBAAmB,GAAG,cAAc,CACxC,qBAAqB,EACrB;IACE,GAAG,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC,sBAAsB,EAAE,CAAC;CACrE,CACF,CAAC;AAEF,cAAc,eAAe,CAAC;AAC9B,OAAO,EAAE,mBAAmB,EAAE,CAAC","sourcesContent":["import { registerPlugin } from '@capacitor/core';\n\nimport type { AndroidSmsRetrieverPlugin } from './definitions';\n\nconst AndroidSmsRetriever = registerPlugin<AndroidSmsRetrieverPlugin>(\n 'AndroidSmsRetriever',\n {\n web: () => import('./web').then(m => new m.AndroidSmsRetrieverWeb()),\n },\n);\n\nexport * from './definitions';\nexport { AndroidSmsRetriever };\n"]}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { WebPlugin } from '@capacitor/core';
|
|
2
|
+
import type { AndroidSmsRetrieverPlugin, RequestPhoneNumberResult, RetrieveSmsResult } from './definitions';
|
|
3
|
+
export declare class AndroidSmsRetrieverWeb extends WebPlugin implements AndroidSmsRetrieverPlugin {
|
|
4
|
+
requestPhoneNumber(): Promise<RequestPhoneNumberResult>;
|
|
5
|
+
retrieveSms(): Promise<RetrieveSmsResult>;
|
|
6
|
+
}
|
package/dist/esm/web.js
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { WebPlugin } from '@capacitor/core';
|
|
2
|
+
export class AndroidSmsRetrieverWeb extends WebPlugin {
|
|
3
|
+
async requestPhoneNumber() {
|
|
4
|
+
throw this.unimplemented('Not implemented on web.');
|
|
5
|
+
}
|
|
6
|
+
async retrieveSms() {
|
|
7
|
+
throw this.unimplemented('Not implemented on web.');
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
//# sourceMappingURL=web.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"web.js","sourceRoot":"","sources":["../../src/web.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAQ5C,MAAM,OAAO,sBACX,SAAQ,SAAS;IAGjB,KAAK,CAAC,kBAAkB;QACtB,MAAM,IAAI,CAAC,aAAa,CAAC,yBAAyB,CAAC,CAAC;IACtD,CAAC;IAED,KAAK,CAAC,WAAW;QACf,MAAM,IAAI,CAAC,aAAa,CAAC,yBAAyB,CAAC,CAAC;IACtD,CAAC;CACF","sourcesContent":["import { WebPlugin } from '@capacitor/core';\n\nimport type {\n AndroidSmsRetrieverPlugin,\n RequestPhoneNumberResult,\n RetrieveSmsResult,\n} from './definitions';\n\nexport class AndroidSmsRetrieverWeb\n extends WebPlugin\n implements AndroidSmsRetrieverPlugin\n{\n async requestPhoneNumber(): Promise<RequestPhoneNumberResult> {\n throw this.unimplemented('Not implemented on web.');\n }\n\n async retrieveSms(): Promise<RetrieveSmsResult> {\n throw this.unimplemented('Not implemented on web.');\n }\n}\n"]}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var core = require('@capacitor/core');
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* @since 0.1.0
|
|
7
|
+
*/
|
|
8
|
+
exports.ErrorCode = void 0;
|
|
9
|
+
(function (ErrorCode) {
|
|
10
|
+
/**
|
|
11
|
+
* The user canceled the operation.
|
|
12
|
+
*
|
|
13
|
+
* @since 0.1.0
|
|
14
|
+
*/
|
|
15
|
+
ErrorCode["Canceled"] = "CANCELED";
|
|
16
|
+
/**
|
|
17
|
+
* The phone number could not be requested via the Phone Number Hint API.
|
|
18
|
+
*
|
|
19
|
+
* @since 0.1.0
|
|
20
|
+
*/
|
|
21
|
+
ErrorCode["PhoneNumberHintFailed"] = "PHONE_NUMBER_HINT_FAILED";
|
|
22
|
+
/**
|
|
23
|
+
* The incoming SMS message could not be retrieved.
|
|
24
|
+
*
|
|
25
|
+
* @since 0.1.0
|
|
26
|
+
*/
|
|
27
|
+
ErrorCode["RetrieveFailed"] = "RETRIEVE_FAILED";
|
|
28
|
+
/**
|
|
29
|
+
* No matching SMS message was received within the 5 minute time window.
|
|
30
|
+
*
|
|
31
|
+
* @since 0.1.0
|
|
32
|
+
*/
|
|
33
|
+
ErrorCode["Timeout"] = "TIMEOUT";
|
|
34
|
+
/**
|
|
35
|
+
* The user denied consent to read the incoming SMS message.
|
|
36
|
+
*
|
|
37
|
+
* @since 0.1.0
|
|
38
|
+
*/
|
|
39
|
+
ErrorCode["UserDenied"] = "USER_DENIED";
|
|
40
|
+
})(exports.ErrorCode || (exports.ErrorCode = {}));
|
|
41
|
+
|
|
42
|
+
const AndroidSmsRetriever = core.registerPlugin('AndroidSmsRetriever', {
|
|
43
|
+
web: () => Promise.resolve().then(function () { return web; }).then(m => new m.AndroidSmsRetrieverWeb()),
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
class AndroidSmsRetrieverWeb extends core.WebPlugin {
|
|
47
|
+
async requestPhoneNumber() {
|
|
48
|
+
throw this.unimplemented('Not implemented on web.');
|
|
49
|
+
}
|
|
50
|
+
async retrieveSms() {
|
|
51
|
+
throw this.unimplemented('Not implemented on web.');
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
var web = /*#__PURE__*/Object.freeze({
|
|
56
|
+
__proto__: null,
|
|
57
|
+
AndroidSmsRetrieverWeb: AndroidSmsRetrieverWeb
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
exports.AndroidSmsRetriever = AndroidSmsRetriever;
|
|
61
|
+
//# sourceMappingURL=plugin.cjs.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plugin.cjs.js","sources":["esm/definitions.js","esm/index.js","esm/web.js"],"sourcesContent":["/**\n * @since 0.1.0\n */\nexport var ErrorCode;\n(function (ErrorCode) {\n /**\n * The user canceled the operation.\n *\n * @since 0.1.0\n */\n ErrorCode[\"Canceled\"] = \"CANCELED\";\n /**\n * The phone number could not be requested via the Phone Number Hint API.\n *\n * @since 0.1.0\n */\n ErrorCode[\"PhoneNumberHintFailed\"] = \"PHONE_NUMBER_HINT_FAILED\";\n /**\n * The incoming SMS message could not be retrieved.\n *\n * @since 0.1.0\n */\n ErrorCode[\"RetrieveFailed\"] = \"RETRIEVE_FAILED\";\n /**\n * No matching SMS message was received within the 5 minute time window.\n *\n * @since 0.1.0\n */\n ErrorCode[\"Timeout\"] = \"TIMEOUT\";\n /**\n * The user denied consent to read the incoming SMS message.\n *\n * @since 0.1.0\n */\n ErrorCode[\"UserDenied\"] = \"USER_DENIED\";\n})(ErrorCode || (ErrorCode = {}));\n//# sourceMappingURL=definitions.js.map","import { registerPlugin } from '@capacitor/core';\nconst AndroidSmsRetriever = registerPlugin('AndroidSmsRetriever', {\n web: () => import('./web').then(m => new m.AndroidSmsRetrieverWeb()),\n});\nexport * from './definitions';\nexport { AndroidSmsRetriever };\n//# sourceMappingURL=index.js.map","import { WebPlugin } from '@capacitor/core';\nexport class AndroidSmsRetrieverWeb extends WebPlugin {\n async requestPhoneNumber() {\n throw this.unimplemented('Not implemented on web.');\n }\n async retrieveSms() {\n throw this.unimplemented('Not implemented on web.');\n }\n}\n//# sourceMappingURL=web.js.map"],"names":["ErrorCode","registerPlugin","WebPlugin"],"mappings":";;;;AAAA;AACA;AACA;AACWA;AACX,CAAC,UAAU,SAAS,EAAE;AACtB;AACA;AACA;AACA;AACA;AACA,IAAI,SAAS,CAAC,UAAU,CAAC,GAAG,UAAU;AACtC;AACA;AACA;AACA;AACA;AACA,IAAI,SAAS,CAAC,uBAAuB,CAAC,GAAG,0BAA0B;AACnE;AACA;AACA;AACA;AACA;AACA,IAAI,SAAS,CAAC,gBAAgB,CAAC,GAAG,iBAAiB;AACnD;AACA;AACA;AACA;AACA;AACA,IAAI,SAAS,CAAC,SAAS,CAAC,GAAG,SAAS;AACpC;AACA;AACA;AACA;AACA;AACA,IAAI,SAAS,CAAC,YAAY,CAAC,GAAG,aAAa;AAC3C,CAAC,EAAEA,iBAAS,KAAKA,iBAAS,GAAG,EAAE,CAAC,CAAC;;AClC5B,MAAC,mBAAmB,GAAGC,mBAAc,CAAC,qBAAqB,EAAE;AAClE,IAAI,GAAG,EAAE,MAAM,mDAAe,CAAC,IAAI,CAAC,CAAC,IAAI,IAAI,CAAC,CAAC,sBAAsB,EAAE,CAAC;AACxE,CAAC;;ACFM,MAAM,sBAAsB,SAASC,cAAS,CAAC;AACtD,IAAI,MAAM,kBAAkB,GAAG;AAC/B,QAAQ,MAAM,IAAI,CAAC,aAAa,CAAC,yBAAyB,CAAC;AAC3D,IAAI;AACJ,IAAI,MAAM,WAAW,GAAG;AACxB,QAAQ,MAAM,IAAI,CAAC,aAAa,CAAC,yBAAyB,CAAC;AAC3D,IAAI;AACJ;;;;;;;;;"}
|
package/dist/plugin.js
ADDED
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
var capacitorSim = (function (exports, core) {
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* @since 0.1.0
|
|
6
|
+
*/
|
|
7
|
+
exports.ErrorCode = void 0;
|
|
8
|
+
(function (ErrorCode) {
|
|
9
|
+
/**
|
|
10
|
+
* The user canceled the operation.
|
|
11
|
+
*
|
|
12
|
+
* @since 0.1.0
|
|
13
|
+
*/
|
|
14
|
+
ErrorCode["Canceled"] = "CANCELED";
|
|
15
|
+
/**
|
|
16
|
+
* The phone number could not be requested via the Phone Number Hint API.
|
|
17
|
+
*
|
|
18
|
+
* @since 0.1.0
|
|
19
|
+
*/
|
|
20
|
+
ErrorCode["PhoneNumberHintFailed"] = "PHONE_NUMBER_HINT_FAILED";
|
|
21
|
+
/**
|
|
22
|
+
* The incoming SMS message could not be retrieved.
|
|
23
|
+
*
|
|
24
|
+
* @since 0.1.0
|
|
25
|
+
*/
|
|
26
|
+
ErrorCode["RetrieveFailed"] = "RETRIEVE_FAILED";
|
|
27
|
+
/**
|
|
28
|
+
* No matching SMS message was received within the 5 minute time window.
|
|
29
|
+
*
|
|
30
|
+
* @since 0.1.0
|
|
31
|
+
*/
|
|
32
|
+
ErrorCode["Timeout"] = "TIMEOUT";
|
|
33
|
+
/**
|
|
34
|
+
* The user denied consent to read the incoming SMS message.
|
|
35
|
+
*
|
|
36
|
+
* @since 0.1.0
|
|
37
|
+
*/
|
|
38
|
+
ErrorCode["UserDenied"] = "USER_DENIED";
|
|
39
|
+
})(exports.ErrorCode || (exports.ErrorCode = {}));
|
|
40
|
+
|
|
41
|
+
const AndroidSmsRetriever = core.registerPlugin('AndroidSmsRetriever', {
|
|
42
|
+
web: () => Promise.resolve().then(function () { return web; }).then(m => new m.AndroidSmsRetrieverWeb()),
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
class AndroidSmsRetrieverWeb extends core.WebPlugin {
|
|
46
|
+
async requestPhoneNumber() {
|
|
47
|
+
throw this.unimplemented('Not implemented on web.');
|
|
48
|
+
}
|
|
49
|
+
async retrieveSms() {
|
|
50
|
+
throw this.unimplemented('Not implemented on web.');
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
var web = /*#__PURE__*/Object.freeze({
|
|
55
|
+
__proto__: null,
|
|
56
|
+
AndroidSmsRetrieverWeb: AndroidSmsRetrieverWeb
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
exports.AndroidSmsRetriever = AndroidSmsRetriever;
|
|
60
|
+
|
|
61
|
+
return exports;
|
|
62
|
+
|
|
63
|
+
})({}, capacitorExports);
|
|
64
|
+
//# sourceMappingURL=plugin.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plugin.js","sources":["esm/definitions.js","esm/index.js","esm/web.js"],"sourcesContent":["/**\n * @since 0.1.0\n */\nexport var ErrorCode;\n(function (ErrorCode) {\n /**\n * The user canceled the operation.\n *\n * @since 0.1.0\n */\n ErrorCode[\"Canceled\"] = \"CANCELED\";\n /**\n * The phone number could not be requested via the Phone Number Hint API.\n *\n * @since 0.1.0\n */\n ErrorCode[\"PhoneNumberHintFailed\"] = \"PHONE_NUMBER_HINT_FAILED\";\n /**\n * The incoming SMS message could not be retrieved.\n *\n * @since 0.1.0\n */\n ErrorCode[\"RetrieveFailed\"] = \"RETRIEVE_FAILED\";\n /**\n * No matching SMS message was received within the 5 minute time window.\n *\n * @since 0.1.0\n */\n ErrorCode[\"Timeout\"] = \"TIMEOUT\";\n /**\n * The user denied consent to read the incoming SMS message.\n *\n * @since 0.1.0\n */\n ErrorCode[\"UserDenied\"] = \"USER_DENIED\";\n})(ErrorCode || (ErrorCode = {}));\n//# sourceMappingURL=definitions.js.map","import { registerPlugin } from '@capacitor/core';\nconst AndroidSmsRetriever = registerPlugin('AndroidSmsRetriever', {\n web: () => import('./web').then(m => new m.AndroidSmsRetrieverWeb()),\n});\nexport * from './definitions';\nexport { AndroidSmsRetriever };\n//# sourceMappingURL=index.js.map","import { WebPlugin } from '@capacitor/core';\nexport class AndroidSmsRetrieverWeb extends WebPlugin {\n async requestPhoneNumber() {\n throw this.unimplemented('Not implemented on web.');\n }\n async retrieveSms() {\n throw this.unimplemented('Not implemented on web.');\n }\n}\n//# sourceMappingURL=web.js.map"],"names":["ErrorCode","registerPlugin","WebPlugin"],"mappings":";;;IAAA;IACA;IACA;AACWA;IACX,CAAC,UAAU,SAAS,EAAE;IACtB;IACA;IACA;IACA;IACA;IACA,IAAI,SAAS,CAAC,UAAU,CAAC,GAAG,UAAU;IACtC;IACA;IACA;IACA;IACA;IACA,IAAI,SAAS,CAAC,uBAAuB,CAAC,GAAG,0BAA0B;IACnE;IACA;IACA;IACA;IACA;IACA,IAAI,SAAS,CAAC,gBAAgB,CAAC,GAAG,iBAAiB;IACnD;IACA;IACA;IACA;IACA;IACA,IAAI,SAAS,CAAC,SAAS,CAAC,GAAG,SAAS;IACpC;IACA;IACA;IACA;IACA;IACA,IAAI,SAAS,CAAC,YAAY,CAAC,GAAG,aAAa;IAC3C,CAAC,EAAEA,iBAAS,KAAKA,iBAAS,GAAG,EAAE,CAAC,CAAC;;AClC5B,UAAC,mBAAmB,GAAGC,mBAAc,CAAC,qBAAqB,EAAE;IAClE,IAAI,GAAG,EAAE,MAAM,mDAAe,CAAC,IAAI,CAAC,CAAC,IAAI,IAAI,CAAC,CAAC,sBAAsB,EAAE,CAAC;IACxE,CAAC;;ICFM,MAAM,sBAAsB,SAASC,cAAS,CAAC;IACtD,IAAI,MAAM,kBAAkB,GAAG;IAC/B,QAAQ,MAAM,IAAI,CAAC,aAAa,CAAC,yBAAyB,CAAC;IAC3D,IAAI;IACJ,IAAI,MAAM,WAAW,GAAG;IACxB,QAAQ,MAAM,IAAI,CAAC,aAAa,CAAC,yBAAyB,CAAC;IAC3D,IAAI;IACJ;;;;;;;;;;;;;;;"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import Foundation
|
|
2
|
+
import Capacitor
|
|
3
|
+
|
|
4
|
+
@objc(AndroidSmsRetrieverPlugin)
|
|
5
|
+
public class AndroidSmsRetrieverPlugin: CAPPlugin, CAPBridgedPlugin {
|
|
6
|
+
public let identifier = "AndroidSmsRetrieverPlugin"
|
|
7
|
+
public let jsName = "AndroidSmsRetriever"
|
|
8
|
+
public let pluginMethods: [CAPPluginMethod] = [
|
|
9
|
+
CAPPluginMethod(name: "requestPhoneNumber", returnType: CAPPluginReturnPromise),
|
|
10
|
+
CAPPluginMethod(name: "retrieveSms", returnType: CAPPluginReturnPromise)
|
|
11
|
+
]
|
|
12
|
+
|
|
13
|
+
@objc func requestPhoneNumber(_ call: CAPPluginCall) {
|
|
14
|
+
rejectCallAsUnimplemented(call)
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
@objc func retrieveSms(_ call: CAPPluginCall) {
|
|
18
|
+
rejectCallAsUnimplemented(call)
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
private func rejectCallAsUnimplemented(_ call: CAPPluginCall) {
|
|
22
|
+
call.unimplemented("This method is not available on this platform.")
|
|
23
|
+
}
|
|
24
|
+
}
|