@pyrocancode/react-native-vk-auth 0.4.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.
Files changed (35) hide show
  1. package/LICENSE +22 -0
  2. package/README.md +302 -0
  3. package/android/build.gradle +155 -0
  4. package/android/gradle.properties +5 -0
  5. package/android/src/main/AndroidManifest.xml +4 -0
  6. package/android/src/main/java/com/vkauth/VkAuthModule.kt +72 -0
  7. package/android/src/main/java/com/vkauth/VkAuthPackage.kt +23 -0
  8. package/android/src/main/java/com/vkauth/vkid/AuthDelegate.kt +123 -0
  9. package/android/src/main/java/com/vkauth/vkid/InitDelegate.kt +13 -0
  10. package/android/src/main/java/com/vkauth/vkid/JSSilentTokenExchanger.kt +33 -0
  11. package/android/src/main/java/com/vkauth/vkid/SuperAppKitInitUtils.kt +75 -0
  12. package/android/src/main/java/com/vkauth/vkid/dto/AcessToken.kt +19 -0
  13. package/android/src/main/java/com/vkauth/vkid/dto/DtoExt.kt +24 -0
  14. package/android/src/main/java/com/vkauth/vkid/dto/SilentAuthInfo.kt +22 -0
  15. package/android/src/main/java/com/vkauth/vkid/dto/Token.kt +15 -0
  16. package/android/src/main/java/com/vkauth/vkid/dto/UserSession.kt +28 -0
  17. package/android/src/main/java/com/vkauth/vkid/jsinput/App.kt +17 -0
  18. package/android/src/main/java/com/vkauth/vkid/jsinput/Credentials.kt +17 -0
  19. package/android/src/main/java/com/vkauth/vkid/jsinput/Links.kt +19 -0
  20. package/android/src/main/java/com/vkauth/vkid/jsinput/Mode.kt +13 -0
  21. package/android/src/main/java/com/vkauth/vkid/jsinput/VKID.kt +21 -0
  22. package/android/src/main/java/com/vkauth/vkid/jstutils/JsCbSender.kt +16 -0
  23. package/android/src/main/java/com/vkauth/vkid/jstutils/JsOutputParam.kt +7 -0
  24. package/android/src/main/java/com/vkauth/vkid/onetapbutton/OneTapButtonManager.kt +169 -0
  25. package/android/src/main/res/drawable/ic_launcher.xml +2 -0
  26. package/android/src/main/res/values/strings.xml +5 -0
  27. package/ios/Event.swift +70 -0
  28. package/ios/RCTDomain.swift +26 -0
  29. package/ios/VkAuth-Bridging-Header.h +3 -0
  30. package/ios/VkAuth.m +60 -0
  31. package/ios/VkAuth.swift +180 -0
  32. package/ios/VkAuth.xcodeproj/project.pbxproj +315 -0
  33. package/package.json +128 -0
  34. package/react-native-vk-auth.podspec +35 -0
  35. package/src/index.tsx +331 -0
package/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2022 Nikita Likhachev
4
+ Copyright (c) 2026 pyrocancode
5
+
6
+ Permission is hereby granted, free of charge, to any person obtaining a copy
7
+ of this software and associated documentation files (the "Software"), to deal
8
+ in the Software without restriction, including without limitation the rights
9
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
+ copies of the Software, and to permit persons to whom the Software is
11
+ furnished to do so, subject to the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be included in all
14
+ copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,302 @@
1
+ # @pyrocancode/react-native-vk-auth
2
+
3
+ React Native VK ID Auth.
4
+
5
+ Форк библиотеки [@devsomersets/react-native-vk-auth](https://www.npmjs.com/package/@devsomersets/react-native-vk-auth) ([исходный репозиторий](https://github.com/somersets/react-native-vk-auth), автор Nikita Likhachev). Разработка ведётся в [pyrocancode/react-native-vk-auth](https://github.com/pyrocancode/react-native-vk-auth).
6
+
7
+ ## Installation
8
+
9
+ Из npm (после публикации пакета):
10
+
11
+ ```sh
12
+ npm install @pyrocancode/react-native-vk-auth
13
+ ```
14
+
15
+ Установка напрямую из GitHub:
16
+
17
+ ```sh
18
+ npm install github:pyrocancode/react-native-vk-auth
19
+ ```
20
+
21
+ ## Настройка iOS проекта
22
+
23
+ Шаг 1. Установка Cocoapods
24
+
25
+ ```sh
26
+ cd ios && pod install
27
+ ```
28
+
29
+ Шаг 2. Поддержка URL схемы
30
+ Чтобы пользователь мог авторизоваться бесшовно, SDK взаимодействует с клиентом VK на устройстве пользователя. Если в клиенте есть активная сессия, пользователь увидит свои данные (имя, аватарку и телефон) в кнопках и шторке. Авторизация завершится в один клик по кнопке "Продолжить как 'username'".
31
+
32
+ Чтобы переход за авторизацией в клиент VK работал, необходимо поддержать схему URL. Для этого добавьте схему vkauthorize-silent в ключ LSApplicationQueriesSchemes в Info.plist.
33
+
34
+ #### Пример записи схемы в Info.plist
35
+
36
+ ```xml
37
+ <key>LSApplicationQueriesSchemes</key>
38
+ <array>
39
+ <string>vkauthorize-silent</string>
40
+ </array>
41
+ ```
42
+
43
+ #### Universal Link
44
+ Для работы бесшовной авторизации необходимо поддержать Universal Link. При создании приложения на сайте платформы, вам нужно было указать Universal Link, по которому клиент VK будет открывать ваше приложение.
45
+
46
+ Для этого вам необходимо поддержать Universal Links в вашем проекте.
47
+
48
+ #### Deep Link
49
+ Иногда iOS некорректно обрабатывает Universal Links и они перестают работать в приложении. В этом случае нужны Deep Links, чтобы вернуть пользователя из приложения VK, так как они работают всегда. В этом случае в ваше приложение не будет передана информация о пользователе, но он вернется из клиента VK. Вам нужно поддержать Deep Link вида: vkAPP_ID://, где, APP_ID — идентификатор приложения
50
+
51
+ #### Пример записи DeepLink в Info.plist
52
+ ```xml
53
+ <key>CFBundleURLTypes</key>
54
+ <array>
55
+ <dict>
56
+ <key>CFBundleTypeRole</key>
57
+ <string>Editor</string>
58
+ <key>CFBundleURLName</key>
59
+ <string>demo_app</string>
60
+ <key>CFBundleURLSchemes</key>
61
+ <array>
62
+ <string>vk123456</string>
63
+ </array>
64
+ </dict>
65
+ </array>
66
+ ```
67
+
68
+ #### Обработка ссылки авторизации
69
+
70
+ В классе ApplicationDelegate вам необходимо добавить менеджер обработки ссылок
71
+
72
+ ```objective-c
73
+ #import <React/RCTLinkingManager.h>
74
+
75
+ - (BOOL)application:(UIApplication *)application
76
+ openURL:(NSURL *)url
77
+ options:(NSDictionary<UIApplicationOpenURLOptionsKey,id> *)options
78
+ {
79
+ return [RCTLinkingManager application:application openURL:url options:options];
80
+ }
81
+
82
+ - (BOOL)application:(UIApplication *)application continueUserActivity:(nonnull NSUserActivity *)userActivity
83
+ restorationHandler:(nonnull void (^)(NSArray<id<UIUserActivityRestoring>> * _Nullable))restorationHandler
84
+ {
85
+ return [RCTLinkingManager application:application
86
+ continueUserActivity:userActivity
87
+ restorationHandler:restorationHandler];
88
+ }
89
+ ```
90
+
91
+ Затем в Typescript необходимо импортировать класс Linking при помощи которого вы сможете подписаться на события открытия ссылок и в месте обработки ссылок вызвать метод openURL у класса VK.
92
+ ```javascript
93
+ React.useEffect(() => {
94
+ Linking.getInitialURL().then((url) => {
95
+ if (url) {
96
+ handleOpenURL({'url': url});
97
+ }
98
+ }).catch(err => {
99
+ console.warn('An error occurred', err);
100
+ });
101
+ Linking.addEventListener('url', handleOpenURL);
102
+ });
103
+
104
+ function handleOpenURL(event: { url: string }) {
105
+ VK.openURL(event.url);
106
+ }
107
+ ```
108
+
109
+ ## Minimal setup guide for Android part:
110
+ 1. Добавить ваши credentials от артифактори в build.gradle проекта
111
+
112
+ ```gradle
113
+ // project build.gradle
114
+ buildscript { }
115
+ allProjects {
116
+ repositories {
117
+ maven {
118
+ url("https://artifactory-external.vkpartner.ru/artifactory/superappkit-maven-public/")
119
+ }
120
+ }
121
+ }
122
+ ```
123
+
124
+ 2. Добавить VkExternalAuthRedirectScheme и VkExternalAuthRedirectHost в build.gradle application’a:
125
+ ```gradle
126
+ // app build.gradle
127
+ android { }
128
+ android.defaultConfig.manifestPlaceholders = [
129
+ 'VkExternalAuthRedirectScheme' : 'vk<ClientId>',
130
+ 'VkExternalAuthRedirectHost' : 'vk.com',
131
+ ]
132
+
133
+ dependencies { }
134
+ ```
135
+
136
+ 3. Добавить client_id, client_secret, vk_external_oauth_redirect_url и vk_account_manager_id в strings.xml:
137
+ ```xml
138
+ <integer name="com_vk_sdk_AppId">your_client_id</integer>
139
+
140
+ <string name="vk_client_secret" translatable="false">your_client_secret</string>
141
+
142
+ <!-- Template: vk<ClientId>://vk.com -->
143
+ <string name="vk_external_oauth_redirect_url" translatable="false">vk<ClientId>://vk.com</string>
144
+
145
+ <!-- Template: your.package.account -->
146
+ <string name="vk_account_manager_id" translatable="false">your.package.account</string>
147
+ ```
148
+
149
+ ## Minimal common setup guide:
150
+ 1. Initialization
151
+
152
+ ```javascript
153
+ import { VK, VKID } from 'react-native-superappkit-pub';
154
+
155
+ // must be initialized only once
156
+ let logo = Image.resolveAssetSource(require('./sample_logo.png'));
157
+ let vkid = new VKID(
158
+ 'Superappkit pub',
159
+ '1.0',
160
+ logo,
161
+ {
162
+ serviceUserAgreement: 'https://help.mail.ru/legal/terms/common/ua',
163
+ servicePrivacyPolicy: 'https://help.mail.ru/legal/terms/common/privacy',
164
+ serviceSupport: null,
165
+ },
166
+ new SilentTokenExchanger()
167
+ );
168
+
169
+ VK.initialize(
170
+ {
171
+ credentials: {
172
+ clientId: 'your-client-id',
173
+ clientSecret: 'your-client-secret',
174
+ },
175
+ mode: VK.Mode.DEBUG,
176
+ },
177
+ vkid
178
+ );
179
+ ```
180
+
181
+ 2. Auth
182
+ ```javascript
183
+ // App.tsx
184
+
185
+ // 1. Silent Token Exchanger
186
+ class SilentTokenExchanger implements VKID.SilentTokenExchanger {
187
+ exchange(silentData: VKID.SilentToken): Promise<VKID.TokenExchangeResult<VKID.AccessToken, Error>> {
188
+ return fetch('your_endpoint_for_exchange_token', {
189
+ method: 'POST',
190
+ headers: {'Content-Type': 'application/json; charset=UTF-8'},
191
+ })
192
+ .then((response) => response.json())
193
+ .then((body) => {
194
+ let accessToken = 'received access_token';
195
+ let userId = 'received user_id';
196
+ let result: VKID.TokenExchangeResult = {
197
+ ok: true,
198
+ accessToken: {
199
+ token: new VKID.Token(accessToken),
200
+ userID: new VKID.UserID(userId),
201
+ }
202
+ };
203
+ return result;
204
+ });
205
+ }
206
+ }
207
+
208
+ //2. Set observer for auth state changing
209
+ vkid.setOnAuthChanged(new class implements VKID.AuthChangedCallback {
210
+ onAuth(userSession: VKID.Session.UserSession): void {
211
+ if (userSession instanceof VKID.Session.Authorized) {
212
+ // user was successfuly authorized, so show authorized flow or get user profile info
213
+ userSession.userProfile.then((profileInfo) => {
214
+ setProfileInfo("Profile info: " + profileInfo.userID.value + " " + profileInfo.firstName);
215
+ })
216
+ }
217
+ }
218
+
219
+ onLogout(): void {
220
+ // logout
221
+ }
222
+ })
223
+
224
+ // 2.1 Use One Tap Loggin button
225
+ import { VKOneTapButton } from 'react-native-superappkit-pub';
226
+ <VKOneTapButton />
227
+
228
+ // 2.2 OR use start auth manually
229
+ <Button title={'Auth by VK'} onPress={() => auth()} />
230
+ function auth() {
231
+ vkid.startAuth();
232
+ }
233
+
234
+ // You may use force close
235
+ function forceCloseAuth() {
236
+ vkid.closeAuth();
237
+ }
238
+
239
+ // Logout
240
+ function logout() {
241
+ vkid.logout();
242
+ }
243
+
244
+ // Check is logged in
245
+ async function isLoggedIn() {
246
+ let sessions = await vkid.getUserSessions();
247
+ let isLoggedIn = sessions.some((session) => session instanceof VKID.UserSession.Authorized)
248
+ }
249
+ ```
250
+
251
+ ### One Tap Button customization
252
+ ```javascript
253
+ import { VKOneTapButton, VKOneTapButtonSpace } from 'react-native-superappkit-pub';
254
+ <VKOneTapButton
255
+ style={styles.vkView}
256
+ backgroundStyle={{
257
+ style: VKOneTapButtonSpace.BgColor.CUSTOM, /* or 'BLUE' (default) or 'WHITE' */
258
+ customVkIconColor: '#your-color-if-using-custom-style',
259
+ customBackgroundColor: '#your-color-if-using-custom-style',
260
+ customTextColor: '#your-color-if-using-custom-style'
261
+ }}
262
+ iconGravity={
263
+ // 'START' (by default) or 'TEXT'
264
+ VKOneTapButtonSpace.IconGravity.START
265
+ }
266
+ firstLineFieldType={
267
+ // 'NONE' (by default) or 'ACTION' or 'PHONE'
268
+ VKOneTapButtonSpace.LineFieldType.ACTION
269
+ }
270
+ secondLineFieldType={
271
+ // 'NONE' (by default) or 'ACTION' or 'PHONE'
272
+ VKOneTapButtonSpace.LineFieldType.PHONE
273
+ }
274
+ texts={{
275
+ noUserText: 'Login as VK',
276
+ actionText: 'Login as {firstName} {lastName}', /* {firstName} and {lastName} are templates that will be replaced by real user names */
277
+ phoneText: 'With phone {phone}', /* {phone} is a template that will be replaced by user phone */
278
+ }}
279
+ oneLineTextSize={ 16 }
280
+ firstLineTextSize={ 16 }
281
+ secondLineTextSize={ 14 }
282
+ avatarSize={ 64 }
283
+ iconSize={ 64 }
284
+ progressSize={ 56 }
285
+ />
286
+ ```
287
+
288
+ ## Usage
289
+
290
+ Раздел в разработке.
291
+
292
+ ## Contributing
293
+
294
+ See the [contributing guide](CONTRIBUTING.md) to learn how to contribute to the repository and the development workflow.
295
+
296
+ ## License
297
+
298
+ [MIT](LICENSE). Исходный код Nikita Likhachev (2022); изменения и сопровождение форка — pyrocancode (2026). См. полный текст в файле `LICENSE`.
299
+
300
+ ---
301
+
302
+ Made with [create-react-native-library](https://github.com/callstack/react-native-builder-bob)
@@ -0,0 +1,155 @@
1
+ buildscript {
2
+ // Buildscript is evaluated before everything else so we can't use getExtOrDefault
3
+ def kotlin_version = rootProject.ext.has('kotlinVersion') ? rootProject.ext.get('kotlinVersion') : project.properties['VkAuth_kotlinVersion']
4
+
5
+ repositories {
6
+ google()
7
+ mavenCentral()
8
+ }
9
+
10
+ dependencies {
11
+ classpath 'com.android.tools.build:gradle:3.5.3'
12
+ // noinspection DifferentKotlinGradleVersion
13
+ classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
14
+ }
15
+ }
16
+
17
+ def isNewArchitectureEnabled() {
18
+ return rootProject.hasProperty("newArchEnabled") && rootProject.getProperty("newArchEnabled") == "true"
19
+ }
20
+
21
+ apply plugin: 'com.android.library'
22
+ apply plugin: 'kotlin-android'
23
+
24
+ if (isNewArchitectureEnabled()) {
25
+ apply plugin: 'com.facebook.react'
26
+ }
27
+
28
+ def getExtOrDefault(name) {
29
+ return rootProject.ext.has(name) ? rootProject.ext.get(name) : project.properties['VkAuth_' + name]
30
+ }
31
+
32
+ def getExtOrIntegerDefault(name) {
33
+ return rootProject.ext.has(name) ? rootProject.ext.get(name) : (project.properties['VkAuth_' + name]).toInteger()
34
+ }
35
+
36
+
37
+ android {
38
+ compileSdkVersion getExtOrIntegerDefault('compileSdkVersion')
39
+
40
+ defaultConfig {
41
+ minSdkVersion getExtOrIntegerDefault('minSdkVersion')
42
+ targetSdkVersion getExtOrIntegerDefault('targetSdkVersion')
43
+ buildConfigField "boolean", "IS_NEW_ARCHITECTURE_ENABLED", isNewArchitectureEnabled().toString()
44
+ }
45
+ buildTypes {
46
+ release {
47
+ minifyEnabled false
48
+ }
49
+ }
50
+
51
+ lintOptions {
52
+ disable 'GradleCompatible'
53
+ }
54
+
55
+ compileOptions {
56
+ sourceCompatibility JavaVersion.VERSION_1_8
57
+ targetCompatibility JavaVersion.VERSION_1_8
58
+ }
59
+
60
+ }
61
+
62
+ repositories {
63
+ mavenCentral()
64
+ google()
65
+ maven {
66
+ url = "https://artifactory-external.vkpartner.ru/artifactory/superappkit-maven-public/"
67
+ }
68
+
69
+ def found = false
70
+ def defaultDir = null
71
+ def androidSourcesName = 'React Native sources'
72
+
73
+ if (rootProject.ext.has('reactNativeAndroidRoot')) {
74
+ defaultDir = rootProject.ext.get('reactNativeAndroidRoot')
75
+ } else {
76
+ defaultDir = new File(
77
+ projectDir,
78
+ '/../../../node_modules/react-native/android'
79
+ )
80
+ }
81
+
82
+ if (defaultDir.exists()) {
83
+ maven {
84
+ url defaultDir.toString()
85
+ name androidSourcesName
86
+ }
87
+
88
+ logger.info(":${project.name}:reactNativeAndroidRoot ${defaultDir.canonicalPath}")
89
+ found = true
90
+ } else {
91
+ def parentDir = rootProject.projectDir
92
+
93
+ 1.upto(5, {
94
+ if (found) return true
95
+ parentDir = parentDir.parentFile
96
+
97
+ def androidSourcesDir = new File(
98
+ parentDir,
99
+ 'node_modules/react-native'
100
+ )
101
+
102
+ def androidPrebuiltBinaryDir = new File(
103
+ parentDir,
104
+ 'node_modules/react-native/android'
105
+ )
106
+
107
+ if (androidPrebuiltBinaryDir.exists()) {
108
+ maven {
109
+ url androidPrebuiltBinaryDir.toString()
110
+ name androidSourcesName
111
+ }
112
+
113
+ logger.info(":${project.name}:reactNativeAndroidRoot ${androidPrebuiltBinaryDir.canonicalPath}")
114
+ found = true
115
+ } else if (androidSourcesDir.exists()) {
116
+ maven {
117
+ url androidSourcesDir.toString()
118
+ name androidSourcesName
119
+ }
120
+
121
+ logger.info(":${project.name}:reactNativeAndroidRoot ${androidSourcesDir.canonicalPath}")
122
+ found = true
123
+ }
124
+ })
125
+ }
126
+
127
+ if (!found) {
128
+ throw new GradleException(
129
+ "${project.name}: unable to locate React Native android sources. " +
130
+ "Ensure you have you installed React Native as a dependency in your project and try again."
131
+ )
132
+ }
133
+ }
134
+
135
+ def kotlin_version = getExtOrDefault('kotlinVersion')
136
+ def vkSdkVersion = "0.104-24412"
137
+
138
+ dependencies {
139
+ //noinspection GradleDynamicVersion
140
+ implementation "com.facebook.react:react-native:+"
141
+ implementation "com.vk:oauth-vk:${vkSdkVersion}"
142
+ implementation "com.vk:vksdk-pub:${vkSdkVersion}"
143
+ implementation "androidx.appcompat:appcompat:1.6.1"
144
+
145
+ implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
146
+ // From node_modules
147
+ }
148
+
149
+ if (isNewArchitectureEnabled()) {
150
+ react {
151
+ jsRootDir = file("../src/")
152
+ libraryName = "VkAuth"
153
+ codegenJavaPackageName = "com.vkauth"
154
+ }
155
+ }
@@ -0,0 +1,5 @@
1
+ VkAuth_kotlinVersion=1.7.0
2
+ VkAuth_minSdkVersion=21
3
+ VkAuth_targetSdkVersion=31
4
+ VkAuth_compileSdkVersion=31
5
+ VkAuth_ndkversion=21.4.7075529
@@ -0,0 +1,4 @@
1
+ <manifest xmlns:android="http://schemas.android.com/apk/res/android"
2
+ package="com.vkauth">
3
+
4
+ </manifest>
@@ -0,0 +1,72 @@
1
+ package com.vkauth
2
+
3
+ import com.facebook.react.bridge.*
4
+ import com.vkauth.vkid.AuthDelegate
5
+ import com.vkauth.vkid.InitDelegate
6
+ import com.vkauth.vkid.jsinput.App
7
+ import com.vkauth.vkid.jsinput.VKID
8
+
9
+ class VkAuthModule(
10
+ reactContext: ReactApplicationContext,
11
+ private val initDelegate: InitDelegate,
12
+ private val authDelegate: AuthDelegate
13
+ ) :
14
+ ReactContextBaseJavaModule(reactContext) {
15
+
16
+ override fun getName(): String {
17
+ return "VkAuth"
18
+ }
19
+
20
+ @ReactMethod
21
+ fun initialize(app: ReadableMap, vkid: ReadableMap) {
22
+ initDelegate.initialize(App.fromMap(app), VKID.fromMap(vkid))
23
+ }
24
+
25
+ @ReactMethod
26
+ fun startAuth() {
27
+ authDelegate.startAuth()
28
+ }
29
+
30
+ @ReactMethod
31
+ fun closeAuth() {
32
+ authDelegate.closeAuth()
33
+ }
34
+
35
+ // to ignore react warning
36
+ @ReactMethod
37
+ fun addListener(eventName: String) {
38
+ }
39
+
40
+ @ReactMethod
41
+ fun removeAllListeners() {
42
+ }
43
+
44
+ @ReactMethod
45
+ fun removeListeners(type: Int?) {
46
+ }
47
+
48
+ @ReactMethod
49
+ fun accessTokenChangedSuccess(token: String, userId: Int) {
50
+ authDelegate.accessTokenChangedSuccess(token, userId)
51
+ }
52
+
53
+ @ReactMethod
54
+ fun accessTokenChangedFailed(error: ReadableMap) {
55
+ authDelegate.accessTokenChangedFailed()
56
+ }
57
+
58
+ @ReactMethod
59
+ fun logout() {
60
+ authDelegate.logout()
61
+ }
62
+
63
+ @ReactMethod
64
+ fun getUserSessions(promise: Promise) {
65
+ authDelegate.getUserSessions(promise)
66
+ }
67
+
68
+ @ReactMethod
69
+ fun getUserProfile(promise: Promise) {
70
+ authDelegate.getUserProfile(promise)
71
+ }
72
+ }
@@ -0,0 +1,23 @@
1
+ package com.vkauth
2
+
3
+ import com.facebook.react.ReactPackage
4
+ import com.facebook.react.bridge.NativeModule
5
+ import com.facebook.react.bridge.ReactApplicationContext
6
+ import com.facebook.react.uimanager.ViewManager
7
+ import com.vkauth.vkid.AuthDelegate
8
+ import com.vkauth.vkid.InitDelegate
9
+ import com.vkauth.vkid.onetapbutton.OneTabButtonManager
10
+
11
+
12
+ class VkAuthPackage : ReactPackage {
13
+ override fun createNativeModules(reactContext: ReactApplicationContext): List<NativeModule> {
14
+ return listOf(VkAuthModule(reactContext,
15
+ InitDelegate(reactContext),
16
+ AuthDelegate(reactContext)
17
+ ))
18
+ }
19
+
20
+ override fun createViewManagers(reactContext: ReactApplicationContext): List<ViewManager<*, *>> {
21
+ return listOf(OneTabButtonManager())
22
+ }
23
+ }