@voipsdk/react-native-voipcloud 0.2.1 → 1.0.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/README.md +181 -117
- package/android/build.gradle +7 -7
- package/android/src/main/java/com/voipcloud/sdk/rn/VoipCloudModule.java +148 -204
- package/android/src/main/java/com/voipcloud/sdk/rn/internal/BridgeGuard.java +74 -0
- package/android/src/main/java/com/voipcloud/sdk/rn/internal/Events.java +7 -2
- package/android/src/main/libs/voipcloud-release.aar +0 -0
- package/ios/VoipCloud.mm +8 -8
- package/lib/commonjs/VoipCloud.js +29 -47
- package/lib/commonjs/VoipCloud.js.map +1 -1
- package/lib/commonjs/events.js +13 -7
- package/lib/commonjs/events.js.map +1 -1
- package/lib/commonjs/index.js +2 -3
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/nativeModule.js +18 -0
- package/lib/commonjs/nativeModule.js.map +1 -0
- package/lib/module/VoipCloud.js +30 -47
- package/lib/module/VoipCloud.js.map +1 -1
- package/lib/module/events.js +9 -8
- package/lib/module/events.js.map +1 -1
- package/lib/module/index.js +1 -2
- package/lib/module/index.js.map +1 -1
- package/lib/module/nativeModule.js +13 -0
- package/lib/module/nativeModule.js.map +1 -0
- package/lib/typescript/VoipCloud.d.ts +5 -30
- package/lib/typescript/events.d.ts +6 -2
- package/lib/typescript/index.d.ts +2 -3
- package/lib/typescript/nativeModule.d.ts +7 -0
- package/lib/typescript/types.d.ts +1 -17
- package/package.json +5 -4
- package/react-native-voipcloud.podspec +7 -5
- package/src/VoipCloud.ts +37 -48
- package/src/events.ts +9 -8
- package/src/index.ts +1 -3
- package/src/nativeModule.ts +17 -0
- package/src/types.ts +1 -18
- package/lib/commonjs/License.js +0 -51
- package/lib/commonjs/License.js.map +0 -1
- package/lib/module/License.js +0 -45
- package/lib/module/License.js.map +0 -1
- package/lib/typescript/License.d.ts +0 -31
- package/src/License.ts +0 -52
|
@@ -1,16 +1,18 @@
|
|
|
1
1
|
require "json"
|
|
2
2
|
|
|
3
3
|
package = JSON.parse(File.read(File.join(__dir__, "package.json")))
|
|
4
|
+
npm_name = package["name"]
|
|
5
|
+
pod_name = npm_name.include?("/") ? npm_name.split("/").last : npm_name
|
|
4
6
|
|
|
5
7
|
Pod::Spec.new do |s|
|
|
6
|
-
s.name =
|
|
8
|
+
s.name = pod_name
|
|
7
9
|
s.version = package["version"]
|
|
8
10
|
s.summary = package["description"]
|
|
9
|
-
s.homepage = "
|
|
10
|
-
s.license = "
|
|
11
|
-
s.authors = { "
|
|
11
|
+
s.homepage = package["homepage"]
|
|
12
|
+
s.license = package["license"]
|
|
13
|
+
s.authors = { package["author"]["name"] => package["author"]["email"] }
|
|
12
14
|
s.platforms = { :ios => "13.0" }
|
|
13
|
-
s.source = { :git => "
|
|
15
|
+
s.source = { :git => package["repository"]["url"] + ".git", :tag => "v#{s.version}" }
|
|
14
16
|
s.source_files = "ios/**/*.{h,m,mm,swift}"
|
|
15
17
|
s.dependency "React-Core"
|
|
16
18
|
end
|
package/src/VoipCloud.ts
CHANGED
|
@@ -1,98 +1,87 @@
|
|
|
1
|
-
import { NativeModules } from 'react-native';
|
|
2
1
|
import type { AccountConfig, InitConfig } from './types';
|
|
3
|
-
import {
|
|
2
|
+
import { NativeVoipCloud } from './nativeModule';
|
|
4
3
|
import { on } from './events';
|
|
5
4
|
|
|
6
|
-
|
|
5
|
+
/** Thrown as Promise rejection — never crashes at import time. */
|
|
6
|
+
function rejectNotLinked(): Promise<never> {
|
|
7
|
+
return Promise.reject(
|
|
8
|
+
Object.assign(
|
|
9
|
+
new Error(
|
|
10
|
+
'@voipsdk/react-native-voipcloud native module is not linked. ' +
|
|
11
|
+
'Install the package, rebuild the Android app ' +
|
|
12
|
+
'(./gradlew clean assembleDebug), and ensure voipcloud-release.aar is packaged.',
|
|
13
|
+
),
|
|
14
|
+
{ code: 'VC_NOT_LINKED' },
|
|
15
|
+
),
|
|
16
|
+
);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
function callNative<T>(fn: () => Promise<T>): Promise<T> {
|
|
20
|
+
if (!NativeVoipCloud) return rejectNotLinked();
|
|
21
|
+
return fn();
|
|
22
|
+
}
|
|
7
23
|
|
|
8
24
|
/**
|
|
9
|
-
* Top-level VoIP SDK. Workflow:
|
|
25
|
+
* Top-level VoIP SDK for {@code @voipsdk/react-native-voipcloud}. Workflow:
|
|
10
26
|
*
|
|
11
|
-
* 1. {@link
|
|
12
|
-
* 2. {@link
|
|
13
|
-
* 3. {@link
|
|
14
|
-
* 4. {@link makeCall} / {@link answer} / {@link hangup}.
|
|
27
|
+
* 1. {@link init} — start the PJSIP endpoint.
|
|
28
|
+
* 2. {@link register} — get an `accountId` back.
|
|
29
|
+
* 3. {@link makeCall} / {@link answer} / {@link hangup}.
|
|
15
30
|
*
|
|
16
|
-
* Every method returns a Promise.
|
|
17
|
-
* Promise rejection with `code = "VC_<NAME>"` matching the
|
|
18
|
-
* `PJ_EVOIPCLOUD_*` enum from `voipcloud_errno.h`.
|
|
31
|
+
* Every method returns a Promise. Failures reject with a `VC_*` code.
|
|
19
32
|
*/
|
|
20
33
|
export const VoipCloud = {
|
|
21
|
-
// ---------------------- License ---------------------------------
|
|
22
|
-
License,
|
|
23
|
-
|
|
24
|
-
// ---------------------- Lifecycle -------------------------------
|
|
25
34
|
init(cfg: InitConfig = {}): Promise<void> {
|
|
26
|
-
return
|
|
35
|
+
return callNative(() => NativeVoipCloud.init(cfg ?? {}));
|
|
27
36
|
},
|
|
28
37
|
|
|
29
38
|
shutdown(): Promise<void> {
|
|
30
|
-
return
|
|
39
|
+
return callNative(() => NativeVoipCloud.shutdown());
|
|
31
40
|
},
|
|
32
41
|
|
|
33
|
-
// ---------------------- Accounts --------------------------------
|
|
34
|
-
/** Register a new SIP account. Resolves with the account id. */
|
|
35
42
|
register(account: AccountConfig): Promise<number> {
|
|
36
|
-
return
|
|
43
|
+
return callNative(() => NativeVoipCloud.register(account));
|
|
37
44
|
},
|
|
38
45
|
|
|
39
46
|
unregister(accountId: number): Promise<void> {
|
|
40
|
-
return
|
|
47
|
+
return callNative(() => NativeVoipCloud.unregister(accountId));
|
|
41
48
|
},
|
|
42
49
|
|
|
43
|
-
// ---------------------- Calls -----------------------------------
|
|
44
|
-
/** Place an outbound call. Resolves with the new callId. */
|
|
45
50
|
makeCall(accountId: number, destinationUri: string): Promise<number> {
|
|
46
|
-
return
|
|
51
|
+
return callNative(() => NativeVoipCloud.makeCall(accountId, destinationUri));
|
|
47
52
|
},
|
|
48
53
|
|
|
49
54
|
answer(callId: number): Promise<void> {
|
|
50
|
-
return
|
|
55
|
+
return callNative(() => NativeVoipCloud.answer(callId));
|
|
51
56
|
},
|
|
52
57
|
|
|
53
58
|
hangup(callId: number): Promise<void> {
|
|
54
|
-
return
|
|
59
|
+
return callNative(() => NativeVoipCloud.hangup(callId));
|
|
55
60
|
},
|
|
56
61
|
|
|
57
62
|
hold(callId: number): Promise<void> {
|
|
58
|
-
return
|
|
63
|
+
return callNative(() => NativeVoipCloud.hold(callId));
|
|
59
64
|
},
|
|
60
65
|
|
|
61
66
|
unhold(callId: number): Promise<void> {
|
|
62
|
-
return
|
|
67
|
+
return callNative(() => NativeVoipCloud.unhold(callId));
|
|
63
68
|
},
|
|
64
69
|
|
|
65
|
-
/**
|
|
66
|
-
* Mute / unmute the local microphone for a call. Implemented by
|
|
67
|
-
* stopping / starting the capture device's transmission to the
|
|
68
|
-
* call's active audio media — independent of `hold`. A
|
|
69
|
-
* `callMediaState` event fires after the toggle so the UI can
|
|
70
|
-
* mirror the new `isMuted` flag without polling.
|
|
71
|
-
*/
|
|
72
70
|
mute(callId: number, on: boolean): Promise<void> {
|
|
73
|
-
return
|
|
71
|
+
return callNative(() => NativeVoipCloud.mute(callId, on));
|
|
74
72
|
},
|
|
75
73
|
|
|
76
74
|
sendDtmf(callId: number, digits: string): Promise<void> {
|
|
77
|
-
return
|
|
75
|
+
return callNative(() => NativeVoipCloud.sendDtmf(callId, digits));
|
|
78
76
|
},
|
|
79
77
|
|
|
80
|
-
/**
|
|
81
|
-
* Blind-transfer a call (SIP REFER) to a new destination. The
|
|
82
|
-
* local leg moves to DISCONNECTED once the remote party accepts.
|
|
83
|
-
*/
|
|
84
78
|
transferCall(callId: number, destinationUri: string): Promise<void> {
|
|
85
|
-
return
|
|
79
|
+
return callNative(() => NativeVoipCloud.transferCall(callId, destinationUri));
|
|
86
80
|
},
|
|
87
81
|
|
|
88
|
-
/**
|
|
89
|
-
* End every active call. Each call still emits its own
|
|
90
|
-
* `callState` event with state=DISCONNECTED.
|
|
91
|
-
*/
|
|
92
82
|
hangupAllCalls(): Promise<void> {
|
|
93
|
-
return
|
|
83
|
+
return callNative(() => NativeVoipCloud.hangupAllCalls());
|
|
94
84
|
},
|
|
95
85
|
|
|
96
|
-
// ---------------------- Events ----------------------------------
|
|
97
86
|
on,
|
|
98
87
|
};
|
package/src/events.ts
CHANGED
|
@@ -1,15 +1,13 @@
|
|
|
1
|
-
import { NativeEventEmitter
|
|
1
|
+
import { NativeEventEmitter } from 'react-native';
|
|
2
2
|
import type { EventMap, Subscription } from './types';
|
|
3
|
+
import { NATIVE_MODULE_NAME, NativeVoipCloud } from './nativeModule';
|
|
3
4
|
|
|
4
|
-
const
|
|
5
|
-
|
|
6
|
-
// Lazy emitter — must point at the module to satisfy the contract
|
|
7
|
-
// NativeEventEmitter expects on RN 0.65+.
|
|
8
|
-
const emitter = Native ? new NativeEventEmitter(Native) : null;
|
|
5
|
+
const emitter = NativeVoipCloud ? new NativeEventEmitter(NativeVoipCloud) : null;
|
|
9
6
|
|
|
10
7
|
/**
|
|
11
|
-
* Subscribe to a typed event
|
|
12
|
-
* be called from a React `useEffect`
|
|
8
|
+
* Subscribe to a typed event from {@code @voipsdk/react-native-voipcloud}.
|
|
9
|
+
* Returns a handle whose `remove()` must be called from a React `useEffect`
|
|
10
|
+
* cleanup to avoid leaks.
|
|
13
11
|
*/
|
|
14
12
|
export function on<K extends keyof EventMap>(
|
|
15
13
|
name: K,
|
|
@@ -21,3 +19,6 @@ export function on<K extends keyof EventMap>(
|
|
|
21
19
|
const sub = emitter.addListener(name, callback as (e: unknown) => void);
|
|
22
20
|
return { remove: () => sub.remove() };
|
|
23
21
|
}
|
|
22
|
+
|
|
23
|
+
/** Native module name registered with React Native (for debugging). */
|
|
24
|
+
export { NATIVE_MODULE_NAME };
|
package/src/index.ts
CHANGED
|
@@ -1,11 +1,9 @@
|
|
|
1
1
|
export { VoipCloud } from './VoipCloud';
|
|
2
|
-
export {
|
|
3
|
-
export { on as addEventListener } from './events';
|
|
2
|
+
export { on as addEventListener, NATIVE_MODULE_NAME } from './events';
|
|
4
3
|
export type {
|
|
5
4
|
Transport,
|
|
6
5
|
InitConfig,
|
|
7
6
|
AccountConfig,
|
|
8
|
-
LicenseStatus,
|
|
9
7
|
RegistrationStateEvent,
|
|
10
8
|
IncomingCallEvent,
|
|
11
9
|
CallState,
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { NativeModules } from 'react-native';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Native module name — must match {@code VoipCloudModule.getName()} on Android
|
|
5
|
+
* and the future iOS RCT export. Derived from npm package
|
|
6
|
+
* {@code @voipsdk/react-native-voipcloud}.
|
|
7
|
+
*/
|
|
8
|
+
export const NATIVE_MODULE_NAME = 'VoipsdkReactNativeVoipcloud';
|
|
9
|
+
|
|
10
|
+
export const NativeVoipCloud = NativeModules[NATIVE_MODULE_NAME];
|
|
11
|
+
|
|
12
|
+
if (!NativeVoipCloud) {
|
|
13
|
+
console.warn(
|
|
14
|
+
'[@voipsdk/react-native-voipcloud] Native module not linked. ' +
|
|
15
|
+
'Methods will reject with VC_NOT_LINKED until the app is rebuilt.',
|
|
16
|
+
);
|
|
17
|
+
}
|
package/src/types.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Public types for react-native-voipcloud.
|
|
2
|
+
* Public types for @voipsdk/react-native-voipcloud.
|
|
3
3
|
* Keep these stable across versions — they form the API contract.
|
|
4
4
|
*/
|
|
5
5
|
|
|
@@ -36,23 +36,6 @@ export interface AccountConfig {
|
|
|
36
36
|
transport: Transport;
|
|
37
37
|
}
|
|
38
38
|
|
|
39
|
-
export interface LicenseStatus {
|
|
40
|
-
/** True if voipcloud_license_is_valid() returned 1 at call time. */
|
|
41
|
-
valid: boolean;
|
|
42
|
-
/** Server-side label: "active" | "trial" | "suspended" | "expired" | "unset". */
|
|
43
|
-
status: string;
|
|
44
|
-
/** Customer identifier embedded in the token. */
|
|
45
|
-
customerId: string;
|
|
46
|
-
/** Concurrent-call ceiling allowed by the license. */
|
|
47
|
-
ccu: number;
|
|
48
|
-
/** Current count of active calls held by the gate. */
|
|
49
|
-
currentCalls: number;
|
|
50
|
-
/** Token expiry (unix seconds). 0 if unbounded. */
|
|
51
|
-
expiry: number;
|
|
52
|
-
/** Last clock-skew anchor pushed by the refresher (unix seconds). 0 if none yet. */
|
|
53
|
-
serverTime: number;
|
|
54
|
-
}
|
|
55
|
-
|
|
56
39
|
export interface RegistrationStateEvent {
|
|
57
40
|
accountId: number;
|
|
58
41
|
/** SIP response code (200 = registered, 401/407 = auth, etc.). */
|
package/lib/commonjs/License.js
DELETED
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.License = void 0;
|
|
7
|
-
var _reactNative = require("react-native");
|
|
8
|
-
const Native = _reactNative.NativeModules.VoipCloud;
|
|
9
|
-
if (!Native) {
|
|
10
|
-
// Defer the error: only thrown if the consumer actually calls a
|
|
11
|
-
// method, so importing the package never crashes at load time.
|
|
12
|
-
console.warn('[react-native-voipcloud] Native module not linked. ' + 'Did you rebuild the Android app after adding the package?');
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
/**
|
|
16
|
-
* License management — all SDK functionality is gated behind a valid
|
|
17
|
-
* token. Customers paste their token (issued by your server) into the
|
|
18
|
-
* app; the app calls {@link set} once at startup and the SDK handles
|
|
19
|
-
* everything else, including periodic refresh.
|
|
20
|
-
*/
|
|
21
|
-
const License = exports.License = {
|
|
22
|
-
/**
|
|
23
|
-
* Apply a license token. Resolves on success, rejects with one of
|
|
24
|
-
* the granular `VC_*` codes if the token is malformed, signed by
|
|
25
|
-
* the wrong key, expired, suspended, or for a different app bundle.
|
|
26
|
-
*
|
|
27
|
-
* Side-effect: if the token's payload includes a `ref` field, the
|
|
28
|
-
* background refresher is started (or restarted with the new URL)
|
|
29
|
-
* automatically — the consumer never types a refresh URL.
|
|
30
|
-
*/
|
|
31
|
-
set(token) {
|
|
32
|
-
return Native.setLicense(token);
|
|
33
|
-
},
|
|
34
|
-
/**
|
|
35
|
-
* Query the current license state. Safe to call before `set`
|
|
36
|
-
* (returns valid=false, status="unset").
|
|
37
|
-
*/
|
|
38
|
-
status() {
|
|
39
|
-
return Native.getLicenseStatus();
|
|
40
|
-
},
|
|
41
|
-
/**
|
|
42
|
-
* Cancel the background refresher. Optional: most apps will
|
|
43
|
-
* never call this. Useful when the user logs out or the SDK is
|
|
44
|
-
* being torn down and you do not want a long-running daemon
|
|
45
|
-
* thread sitting in the process.
|
|
46
|
-
*/
|
|
47
|
-
stopRefresh() {
|
|
48
|
-
return Native.stopLicenseRefresh();
|
|
49
|
-
}
|
|
50
|
-
};
|
|
51
|
-
//# sourceMappingURL=License.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["_reactNative","require","Native","NativeModules","VoipCloud","console","warn","License","exports","set","token","setLicense","status","getLicenseStatus","stopRefresh","stopLicenseRefresh"],"sourceRoot":"../../src","sources":["License.ts"],"mappings":";;;;;;AAAA,IAAAA,YAAA,GAAAC,OAAA;AAGA,MAAMC,MAAM,GAAGC,0BAAa,CAACC,SAAS;AAEtC,IAAI,CAACF,MAAM,EAAE;EACT;EACA;EACAG,OAAO,CAACC,IAAI,CACR,qDAAqD,GACrD,2DACJ,CAAC;AACL;;AAEA;AACA;AACA;AACA;AACA;AACA;AACO,MAAMC,OAAO,GAAAC,OAAA,CAAAD,OAAA,GAAG;EACnB;AACJ;AACA;AACA;AACA;AACA;AACA;AACA;AACA;EACIE,GAAGA,CAACC,KAAa,EAAiB;IAC9B,OAAOR,MAAM,CAACS,UAAU,CAACD,KAAK,CAAC;EACnC,CAAC;EAED;AACJ;AACA;AACA;EACIE,MAAMA,CAAA,EAA2B;IAC7B,OAAOV,MAAM,CAACW,gBAAgB,CAAC,CAAC;EACpC,CAAC;EAED;AACJ;AACA;AACA;AACA;AACA;EACIC,WAAWA,CAAA,EAAkB;IACzB,OAAOZ,MAAM,CAACa,kBAAkB,CAAC,CAAC;EACtC;AACJ,CAAC","ignoreList":[]}
|
package/lib/module/License.js
DELETED
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
import { NativeModules } from 'react-native';
|
|
2
|
-
const Native = NativeModules.VoipCloud;
|
|
3
|
-
if (!Native) {
|
|
4
|
-
// Defer the error: only thrown if the consumer actually calls a
|
|
5
|
-
// method, so importing the package never crashes at load time.
|
|
6
|
-
console.warn('[react-native-voipcloud] Native module not linked. ' + 'Did you rebuild the Android app after adding the package?');
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
* License management — all SDK functionality is gated behind a valid
|
|
11
|
-
* token. Customers paste their token (issued by your server) into the
|
|
12
|
-
* app; the app calls {@link set} once at startup and the SDK handles
|
|
13
|
-
* everything else, including periodic refresh.
|
|
14
|
-
*/
|
|
15
|
-
export const License = {
|
|
16
|
-
/**
|
|
17
|
-
* Apply a license token. Resolves on success, rejects with one of
|
|
18
|
-
* the granular `VC_*` codes if the token is malformed, signed by
|
|
19
|
-
* the wrong key, expired, suspended, or for a different app bundle.
|
|
20
|
-
*
|
|
21
|
-
* Side-effect: if the token's payload includes a `ref` field, the
|
|
22
|
-
* background refresher is started (or restarted with the new URL)
|
|
23
|
-
* automatically — the consumer never types a refresh URL.
|
|
24
|
-
*/
|
|
25
|
-
set(token) {
|
|
26
|
-
return Native.setLicense(token);
|
|
27
|
-
},
|
|
28
|
-
/**
|
|
29
|
-
* Query the current license state. Safe to call before `set`
|
|
30
|
-
* (returns valid=false, status="unset").
|
|
31
|
-
*/
|
|
32
|
-
status() {
|
|
33
|
-
return Native.getLicenseStatus();
|
|
34
|
-
},
|
|
35
|
-
/**
|
|
36
|
-
* Cancel the background refresher. Optional: most apps will
|
|
37
|
-
* never call this. Useful when the user logs out or the SDK is
|
|
38
|
-
* being torn down and you do not want a long-running daemon
|
|
39
|
-
* thread sitting in the process.
|
|
40
|
-
*/
|
|
41
|
-
stopRefresh() {
|
|
42
|
-
return Native.stopLicenseRefresh();
|
|
43
|
-
}
|
|
44
|
-
};
|
|
45
|
-
//# sourceMappingURL=License.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["NativeModules","Native","VoipCloud","console","warn","License","set","token","setLicense","status","getLicenseStatus","stopRefresh","stopLicenseRefresh"],"sourceRoot":"../../src","sources":["License.ts"],"mappings":"AAAA,SAASA,aAAa,QAAQ,cAAc;AAG5C,MAAMC,MAAM,GAAGD,aAAa,CAACE,SAAS;AAEtC,IAAI,CAACD,MAAM,EAAE;EACT;EACA;EACAE,OAAO,CAACC,IAAI,CACR,qDAAqD,GACrD,2DACJ,CAAC;AACL;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMC,OAAO,GAAG;EACnB;AACJ;AACA;AACA;AACA;AACA;AACA;AACA;AACA;EACIC,GAAGA,CAACC,KAAa,EAAiB;IAC9B,OAAON,MAAM,CAACO,UAAU,CAACD,KAAK,CAAC;EACnC,CAAC;EAED;AACJ;AACA;AACA;EACIE,MAAMA,CAAA,EAA2B;IAC7B,OAAOR,MAAM,CAACS,gBAAgB,CAAC,CAAC;EACpC,CAAC;EAED;AACJ;AACA;AACA;AACA;AACA;EACIC,WAAWA,CAAA,EAAkB;IACzB,OAAOV,MAAM,CAACW,kBAAkB,CAAC,CAAC;EACtC;AACJ,CAAC","ignoreList":[]}
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import type { LicenseStatus } from './types';
|
|
2
|
-
/**
|
|
3
|
-
* License management — all SDK functionality is gated behind a valid
|
|
4
|
-
* token. Customers paste their token (issued by your server) into the
|
|
5
|
-
* app; the app calls {@link set} once at startup and the SDK handles
|
|
6
|
-
* everything else, including periodic refresh.
|
|
7
|
-
*/
|
|
8
|
-
export declare const License: {
|
|
9
|
-
/**
|
|
10
|
-
* Apply a license token. Resolves on success, rejects with one of
|
|
11
|
-
* the granular `VC_*` codes if the token is malformed, signed by
|
|
12
|
-
* the wrong key, expired, suspended, or for a different app bundle.
|
|
13
|
-
*
|
|
14
|
-
* Side-effect: if the token's payload includes a `ref` field, the
|
|
15
|
-
* background refresher is started (or restarted with the new URL)
|
|
16
|
-
* automatically — the consumer never types a refresh URL.
|
|
17
|
-
*/
|
|
18
|
-
set(token: string): Promise<void>;
|
|
19
|
-
/**
|
|
20
|
-
* Query the current license state. Safe to call before `set`
|
|
21
|
-
* (returns valid=false, status="unset").
|
|
22
|
-
*/
|
|
23
|
-
status(): Promise<LicenseStatus>;
|
|
24
|
-
/**
|
|
25
|
-
* Cancel the background refresher. Optional: most apps will
|
|
26
|
-
* never call this. Useful when the user logs out or the SDK is
|
|
27
|
-
* being torn down and you do not want a long-running daemon
|
|
28
|
-
* thread sitting in the process.
|
|
29
|
-
*/
|
|
30
|
-
stopRefresh(): Promise<void>;
|
|
31
|
-
};
|
package/src/License.ts
DELETED
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
import { NativeModules } from 'react-native';
|
|
2
|
-
import type { LicenseStatus } from './types';
|
|
3
|
-
|
|
4
|
-
const Native = NativeModules.VoipCloud;
|
|
5
|
-
|
|
6
|
-
if (!Native) {
|
|
7
|
-
// Defer the error: only thrown if the consumer actually calls a
|
|
8
|
-
// method, so importing the package never crashes at load time.
|
|
9
|
-
console.warn(
|
|
10
|
-
'[react-native-voipcloud] Native module not linked. ' +
|
|
11
|
-
'Did you rebuild the Android app after adding the package?',
|
|
12
|
-
);
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
/**
|
|
16
|
-
* License management — all SDK functionality is gated behind a valid
|
|
17
|
-
* token. Customers paste their token (issued by your server) into the
|
|
18
|
-
* app; the app calls {@link set} once at startup and the SDK handles
|
|
19
|
-
* everything else, including periodic refresh.
|
|
20
|
-
*/
|
|
21
|
-
export const License = {
|
|
22
|
-
/**
|
|
23
|
-
* Apply a license token. Resolves on success, rejects with one of
|
|
24
|
-
* the granular `VC_*` codes if the token is malformed, signed by
|
|
25
|
-
* the wrong key, expired, suspended, or for a different app bundle.
|
|
26
|
-
*
|
|
27
|
-
* Side-effect: if the token's payload includes a `ref` field, the
|
|
28
|
-
* background refresher is started (or restarted with the new URL)
|
|
29
|
-
* automatically — the consumer never types a refresh URL.
|
|
30
|
-
*/
|
|
31
|
-
set(token: string): Promise<void> {
|
|
32
|
-
return Native.setLicense(token);
|
|
33
|
-
},
|
|
34
|
-
|
|
35
|
-
/**
|
|
36
|
-
* Query the current license state. Safe to call before `set`
|
|
37
|
-
* (returns valid=false, status="unset").
|
|
38
|
-
*/
|
|
39
|
-
status(): Promise<LicenseStatus> {
|
|
40
|
-
return Native.getLicenseStatus();
|
|
41
|
-
},
|
|
42
|
-
|
|
43
|
-
/**
|
|
44
|
-
* Cancel the background refresher. Optional: most apps will
|
|
45
|
-
* never call this. Useful when the user logs out or the SDK is
|
|
46
|
-
* being torn down and you do not want a long-running daemon
|
|
47
|
-
* thread sitting in the process.
|
|
48
|
-
*/
|
|
49
|
-
stopRefresh(): Promise<void> {
|
|
50
|
-
return Native.stopLicenseRefresh();
|
|
51
|
-
},
|
|
52
|
-
};
|