@doordeck/headless-react-native-sdk 0.83.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/HeadlessReactNativeSdk.podspec +44 -0
- package/LICENSE +174 -0
- package/README.md +113 -0
- package/android/build.gradle +118 -0
- package/android/generated/java/com/doordeck/headlessreactnativesdk/NativeHeadlessReactNativeSdkSpec.java +62 -0
- package/android/generated/jni/CMakeLists.txt +36 -0
- package/android/generated/jni/RNHeadlessReactNativeSdkSpec-generated.cpp +68 -0
- package/android/generated/jni/RNHeadlessReactNativeSdkSpec.h +31 -0
- package/android/generated/jni/react/renderer/components/RNHeadlessReactNativeSdkSpec/RNHeadlessReactNativeSdkSpecJSI-generated.cpp +68 -0
- package/android/generated/jni/react/renderer/components/RNHeadlessReactNativeSdkSpec/RNHeadlessReactNativeSdkSpecJSI.h +307 -0
- package/android/gradle.properties +5 -0
- package/android/settings.gradle.kts +16 -0
- package/android/src/main/AndroidManifest.xml +3 -0
- package/android/src/main/AndroidManifestNew.xml +2 -0
- package/android/src/main/java/com/doordeck/headlessreactnativesdk/HeadlessReactNativeSdkModule.kt +176 -0
- package/android/src/main/java/com/doordeck/headlessreactnativesdk/HeadlessReactNativeSdkPackage.kt +43 -0
- package/ios/HeadlessReactNativeSdk.h +6 -0
- package/ios/HeadlessReactNativeSdk.mm +54 -0
- package/ios/HeadlessReactNativeSdkImpl.swift +210 -0
- package/ios/generated/RNHeadlessReactNativeSdkSpec/RNHeadlessReactNativeSdkSpec-generated.mm +81 -0
- package/ios/generated/RNHeadlessReactNativeSdkSpec/RNHeadlessReactNativeSdkSpec.h +81 -0
- package/ios/generated/RNHeadlessReactNativeSdkSpecJSI-generated.cpp +68 -0
- package/ios/generated/RNHeadlessReactNativeSdkSpecJSI.h +307 -0
- package/lib/commonjs/NativeHeadlessReactNativeSdk.js +9 -0
- package/lib/commonjs/NativeHeadlessReactNativeSdk.js.map +1 -0
- package/lib/commonjs/index.js +36 -0
- package/lib/commonjs/index.js.map +1 -0
- package/lib/module/NativeHeadlessReactNativeSdk.js +5 -0
- package/lib/module/NativeHeadlessReactNativeSdk.js.map +1 -0
- package/lib/module/index.js +25 -0
- package/lib/module/index.js.map +1 -0
- package/lib/typescript/commonjs/package.json +1 -0
- package/lib/typescript/commonjs/src/NativeHeadlessReactNativeSdk.d.ts +72 -0
- package/lib/typescript/commonjs/src/NativeHeadlessReactNativeSdk.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/index.d.ts +9 -0
- package/lib/typescript/commonjs/src/index.d.ts.map +1 -0
- package/lib/typescript/module/package.json +1 -0
- package/lib/typescript/module/src/NativeHeadlessReactNativeSdk.d.ts +72 -0
- package/lib/typescript/module/src/NativeHeadlessReactNativeSdk.d.ts.map +1 -0
- package/lib/typescript/module/src/index.d.ts +9 -0
- package/lib/typescript/module/src/index.d.ts.map +1 -0
- package/package.json +203 -0
- package/react-native.config.js +12 -0
- package/src/NativeHeadlessReactNativeSdk.ts +87 -0
- package/src/index.tsx +35 -0
package/package.json
ADDED
|
@@ -0,0 +1,203 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@doordeck/headless-react-native-sdk",
|
|
3
|
+
"version": "0.83.0",
|
|
4
|
+
"description": "Doordeck React Native headless SDK",
|
|
5
|
+
"source": "./src/index.tsx",
|
|
6
|
+
"main": "./lib/commonjs/index.js",
|
|
7
|
+
"module": "./lib/module/index.js",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"import": {
|
|
11
|
+
"types": "./lib/typescript/module/src/index.d.ts",
|
|
12
|
+
"default": "./lib/module/index.js"
|
|
13
|
+
},
|
|
14
|
+
"require": {
|
|
15
|
+
"types": "./lib/typescript/commonjs/src/index.d.ts",
|
|
16
|
+
"default": "./lib/commonjs/index.js"
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
},
|
|
20
|
+
"files": [
|
|
21
|
+
"src",
|
|
22
|
+
"lib",
|
|
23
|
+
"android",
|
|
24
|
+
"ios",
|
|
25
|
+
"cpp",
|
|
26
|
+
"*.podspec",
|
|
27
|
+
"react-native.config.js",
|
|
28
|
+
"!ios/build",
|
|
29
|
+
"!android/build",
|
|
30
|
+
"!android/gradle",
|
|
31
|
+
"!android/gradlew",
|
|
32
|
+
"!android/gradlew.bat",
|
|
33
|
+
"!android/local.properties",
|
|
34
|
+
"!**/__tests__",
|
|
35
|
+
"!**/__fixtures__",
|
|
36
|
+
"!**/__mocks__",
|
|
37
|
+
"!**/.*"
|
|
38
|
+
],
|
|
39
|
+
"scripts": {
|
|
40
|
+
"example": "yarn workspace @doordeck/headless-react-native-sdk-example",
|
|
41
|
+
"test": "jest",
|
|
42
|
+
"typecheck": "tsc",
|
|
43
|
+
"lint": "eslint \"**/*.{js,ts,tsx}\"",
|
|
44
|
+
"clean": "del-cli android/build example/android/build example/android/app/build example/ios/build lib",
|
|
45
|
+
"prepare": "bob build",
|
|
46
|
+
"release": "release-it"
|
|
47
|
+
},
|
|
48
|
+
"keywords": [
|
|
49
|
+
"react-native",
|
|
50
|
+
"ios",
|
|
51
|
+
"android"
|
|
52
|
+
],
|
|
53
|
+
"repository": {
|
|
54
|
+
"type": "git",
|
|
55
|
+
"url": "git+https://github.com/doordeck/doordeck-headless-sdk.git"
|
|
56
|
+
},
|
|
57
|
+
"author": "Doordeck <developers@doordeck.com> (https://doordeck.com)",
|
|
58
|
+
"license": "MIT",
|
|
59
|
+
"bugs": {
|
|
60
|
+
"url": "https://github.com/doordeck/doordeck-headless-sdk/issues"
|
|
61
|
+
},
|
|
62
|
+
"homepage": "https://github.com/doordeck/doordeck-headless-sdk#readme",
|
|
63
|
+
"publishConfig": {
|
|
64
|
+
"registry": "https://registry.npmjs.org/"
|
|
65
|
+
},
|
|
66
|
+
"devDependencies": {
|
|
67
|
+
"@commitlint/config-conventional": "^17.0.2",
|
|
68
|
+
"@evilmartians/lefthook": "^1.5.0",
|
|
69
|
+
"@react-native-community/cli": "15.0.1",
|
|
70
|
+
"@react-native/eslint-config": "^0.73.1",
|
|
71
|
+
"@release-it/conventional-changelog": "^9.0.2",
|
|
72
|
+
"@types/jest": "^29.5.5",
|
|
73
|
+
"@types/react": "^18.2.44",
|
|
74
|
+
"commitlint": "^17.0.2",
|
|
75
|
+
"del-cli": "^5.1.0",
|
|
76
|
+
"eslint": "^8.51.0",
|
|
77
|
+
"eslint-config-prettier": "^9.0.0",
|
|
78
|
+
"eslint-plugin-prettier": "^5.0.1",
|
|
79
|
+
"jest": "^29.7.0",
|
|
80
|
+
"prettier": "^3.0.3",
|
|
81
|
+
"react": "18.3.1",
|
|
82
|
+
"react-native": "0.77.1",
|
|
83
|
+
"react-native-builder-bob": "^0.37.0",
|
|
84
|
+
"release-it": "^17.10.0",
|
|
85
|
+
"turbo": "^1.10.7",
|
|
86
|
+
"typescript": "^5.2.2"
|
|
87
|
+
},
|
|
88
|
+
"resolutions": {
|
|
89
|
+
"@types/react": "^18.2.44"
|
|
90
|
+
},
|
|
91
|
+
"peerDependencies": {
|
|
92
|
+
"react": "*",
|
|
93
|
+
"react-native": "*"
|
|
94
|
+
},
|
|
95
|
+
"workspaces": [
|
|
96
|
+
"example"
|
|
97
|
+
],
|
|
98
|
+
"packageManager": "yarn@3.6.1",
|
|
99
|
+
"jest": {
|
|
100
|
+
"preset": "react-native",
|
|
101
|
+
"modulePathIgnorePatterns": [
|
|
102
|
+
"<rootDir>/example/node_modules",
|
|
103
|
+
"<rootDir>/lib/"
|
|
104
|
+
]
|
|
105
|
+
},
|
|
106
|
+
"commitlint": {
|
|
107
|
+
"extends": [
|
|
108
|
+
"@commitlint/config-conventional"
|
|
109
|
+
]
|
|
110
|
+
},
|
|
111
|
+
"release-it": {
|
|
112
|
+
"git": {
|
|
113
|
+
"commitMessage": "chore: release ${version}",
|
|
114
|
+
"tagName": "v${version}"
|
|
115
|
+
},
|
|
116
|
+
"npm": {
|
|
117
|
+
"publish": true
|
|
118
|
+
},
|
|
119
|
+
"github": {
|
|
120
|
+
"release": true
|
|
121
|
+
},
|
|
122
|
+
"plugins": {
|
|
123
|
+
"@release-it/conventional-changelog": {
|
|
124
|
+
"preset": "angular"
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
},
|
|
128
|
+
"eslintConfig": {
|
|
129
|
+
"root": true,
|
|
130
|
+
"extends": [
|
|
131
|
+
"@react-native",
|
|
132
|
+
"prettier"
|
|
133
|
+
],
|
|
134
|
+
"rules": {
|
|
135
|
+
"react/react-in-jsx-scope": "off",
|
|
136
|
+
"prettier/prettier": [
|
|
137
|
+
"error",
|
|
138
|
+
{
|
|
139
|
+
"quoteProps": "consistent",
|
|
140
|
+
"singleQuote": true,
|
|
141
|
+
"tabWidth": 2,
|
|
142
|
+
"trailingComma": "es5",
|
|
143
|
+
"useTabs": false
|
|
144
|
+
}
|
|
145
|
+
]
|
|
146
|
+
}
|
|
147
|
+
},
|
|
148
|
+
"eslintIgnore": [
|
|
149
|
+
"node_modules/",
|
|
150
|
+
"lib/"
|
|
151
|
+
],
|
|
152
|
+
"prettier": {
|
|
153
|
+
"quoteProps": "consistent",
|
|
154
|
+
"singleQuote": true,
|
|
155
|
+
"tabWidth": 2,
|
|
156
|
+
"trailingComma": "es5",
|
|
157
|
+
"useTabs": false
|
|
158
|
+
},
|
|
159
|
+
"react-native-builder-bob": {
|
|
160
|
+
"source": "src",
|
|
161
|
+
"output": "lib",
|
|
162
|
+
"targets": [
|
|
163
|
+
"codegen",
|
|
164
|
+
[
|
|
165
|
+
"commonjs",
|
|
166
|
+
{
|
|
167
|
+
"esm": true
|
|
168
|
+
}
|
|
169
|
+
],
|
|
170
|
+
[
|
|
171
|
+
"module",
|
|
172
|
+
{
|
|
173
|
+
"esm": true
|
|
174
|
+
}
|
|
175
|
+
],
|
|
176
|
+
[
|
|
177
|
+
"typescript",
|
|
178
|
+
{
|
|
179
|
+
"project": "tsconfig.build.json",
|
|
180
|
+
"esm": true
|
|
181
|
+
}
|
|
182
|
+
]
|
|
183
|
+
]
|
|
184
|
+
},
|
|
185
|
+
"codegenConfig": {
|
|
186
|
+
"name": "RNHeadlessReactNativeSdkSpec",
|
|
187
|
+
"type": "modules",
|
|
188
|
+
"jsSrcsDir": "src",
|
|
189
|
+
"outputDir": {
|
|
190
|
+
"ios": "ios/generated",
|
|
191
|
+
"android": "android/generated"
|
|
192
|
+
},
|
|
193
|
+
"android": {
|
|
194
|
+
"javaPackageName": "com.doordeck.headlessreactnativesdk"
|
|
195
|
+
},
|
|
196
|
+
"includesGeneratedCode": true
|
|
197
|
+
},
|
|
198
|
+
"create-react-native-library": {
|
|
199
|
+
"type": "turbo-module",
|
|
200
|
+
"languages": "kotlin-objc",
|
|
201
|
+
"version": "0.48.1"
|
|
202
|
+
}
|
|
203
|
+
}
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import type {TurboModule} from 'react-native';
|
|
2
|
+
import {TurboModuleRegistry} from 'react-native';
|
|
3
|
+
|
|
4
|
+
export interface Spec extends TurboModule {
|
|
5
|
+
/**
|
|
6
|
+
* @param email - email of the user
|
|
7
|
+
* @param password - password of the user
|
|
8
|
+
*
|
|
9
|
+
* @returns needsVerification [Promise] of [boolean] being this boolean whether the user needs to verify and
|
|
10
|
+
* an email was sent.
|
|
11
|
+
* Be aware that two consecutive logins with `needVerification == true` in less
|
|
12
|
+
* than one minute will result into a `NEEDS_VERIFICATION_ERROR` as there is a
|
|
13
|
+
* 60-second throttle for this operation
|
|
14
|
+
*/
|
|
15
|
+
login(
|
|
16
|
+
email: string,
|
|
17
|
+
password: string,
|
|
18
|
+
): Promise<AssistedRegisterEphemeralKeyResponse>;
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* @param authToken - token for this user
|
|
22
|
+
*
|
|
23
|
+
* @returns needsVerification [Promise] of [boolean] being this boolean whether the user needs to verify and
|
|
24
|
+
* an email was sent.
|
|
25
|
+
* Be aware that two consecutive logins with `needVerification == true` in less
|
|
26
|
+
* than one minute will result into a `NEEDS_VERIFICATION_ERROR` as there is a
|
|
27
|
+
* 60-second throttle for this operation
|
|
28
|
+
*/
|
|
29
|
+
setAuthToken(
|
|
30
|
+
authToken: string,
|
|
31
|
+
): Promise<AssistedRegisterEphemeralKeyResponse>;
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* @returns UserDetailsResponse if the user is logged in, otherwise null
|
|
35
|
+
*
|
|
36
|
+
* This method is useful to check if the user needs to verify 2fa login,
|
|
37
|
+
* or if the certificate chain or the token are about to expire.
|
|
38
|
+
*/
|
|
39
|
+
getUserDetails(): Promise<UserDetailsResponse>;
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* @param code - code sent for verification
|
|
43
|
+
*/
|
|
44
|
+
verify(code: string): Promise<void>
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* Logs out the user inside the SDK.
|
|
48
|
+
* This doesn't delete any local data generated by the React Native SDK.
|
|
49
|
+
*
|
|
50
|
+
* @return a Promise when it's done.
|
|
51
|
+
*/
|
|
52
|
+
logout(): Promise<void>
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* @param tileId - tile UUID usually scanned from a QR code or obtained from an NFC tag
|
|
56
|
+
*
|
|
57
|
+
* @returns TileLocksResponse where locks belonging to that tile can be found
|
|
58
|
+
*/
|
|
59
|
+
getLocksBelongingToTile(tileId: string): Promise<TileLocksResponse>;
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* @param lockId - lock UUID associated to a tile
|
|
63
|
+
*/
|
|
64
|
+
unlockDevice(lockId: string): Promise<void>;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
export type TileLocksResponse = {
|
|
68
|
+
siteId: string;
|
|
69
|
+
tileId: string;
|
|
70
|
+
deviceIds: string[];
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
export type AssistedRegisterEphemeralKeyResponse = {
|
|
74
|
+
requiresVerification: boolean;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
export type UserDetailsResponse = {
|
|
78
|
+
userId?: string;
|
|
79
|
+
publicKey: string;
|
|
80
|
+
email: string;
|
|
81
|
+
displayName?: string;
|
|
82
|
+
emailVerified: boolean;
|
|
83
|
+
certificateChainAboutToExpire: boolean;
|
|
84
|
+
tokenAboutToExpire: boolean;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
export default TurboModuleRegistry.getEnforcing<Spec>('HeadlessReactNativeSdk');
|
package/src/index.tsx
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import HeadlessReactNativeSdk, {
|
|
2
|
+
type AssistedRegisterEphemeralKeyResponse,
|
|
3
|
+
type TileLocksResponse, type UserDetailsResponse,
|
|
4
|
+
} from './NativeHeadlessReactNativeSdk';
|
|
5
|
+
|
|
6
|
+
export function login(email: string, password: string): Promise<AssistedRegisterEphemeralKeyResponse> {
|
|
7
|
+
return HeadlessReactNativeSdk.login(
|
|
8
|
+
email,
|
|
9
|
+
password,
|
|
10
|
+
);
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export function setAuthToken(authToken: string): Promise<AssistedRegisterEphemeralKeyResponse> {
|
|
14
|
+
return HeadlessReactNativeSdk.setAuthToken(authToken);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export function getUserDetails(): Promise<UserDetailsResponse> {
|
|
18
|
+
return HeadlessReactNativeSdk.getUserDetails();
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export function verify(code: string): Promise<void> {
|
|
22
|
+
return HeadlessReactNativeSdk.verify(code);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export function logout(): Promise<void> {
|
|
26
|
+
return HeadlessReactNativeSdk.logout();
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export function getLocksBelongingToTile(tileId: string): Promise<TileLocksResponse> {
|
|
30
|
+
return HeadlessReactNativeSdk.getLocksBelongingToTile(tileId);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export function unlockDevice(lockId: string): Promise<void> {
|
|
34
|
+
return HeadlessReactNativeSdk.unlockDevice(lockId);
|
|
35
|
+
}
|