react-native-oauth-essentials 1.0.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.
Files changed (41) hide show
  1. package/LICENSE +20 -0
  2. package/OauthEssentials.podspec +22 -0
  3. package/README.md +30 -0
  4. package/android/build.gradle +74 -0
  5. package/android/src/main/AndroidManifest.xml +22 -0
  6. package/android/src/main/java/com/oauthessentials/CredentialError.kt +7 -0
  7. package/android/src/main/java/com/oauthessentials/CredentialFactory.kt +114 -0
  8. package/android/src/main/java/com/oauthessentials/CustomTabsActivity.kt +133 -0
  9. package/android/src/main/java/com/oauthessentials/OauthEssentialsModule.kt +603 -0
  10. package/android/src/main/java/com/oauthessentials/OauthEssentialsPackage.kt +33 -0
  11. package/android/src/main/java/com/oauthessentials/RCTPromiseSettler.kt +60 -0
  12. package/ios/AppleIdRetriever.swift +61 -0
  13. package/ios/CredentialError.swift +6 -0
  14. package/ios/CredentialFactory.swift +133 -0
  15. package/ios/CredentialsType.swift +7 -0
  16. package/ios/GoogleIdRetriever.swift +83 -0
  17. package/ios/HybridRetriever.swift +64 -0
  18. package/ios/OauthEssentials.h +8 -0
  19. package/ios/OauthEssentials.mm +104 -0
  20. package/ios/OauthEssentialsModule.swift +210 -0
  21. package/ios/PasskeyRetriever.swift +226 -0
  22. package/ios/PasswordRetriever.swift +72 -0
  23. package/ios/RCTPromiseSettler.swift +28 -0
  24. package/lib/module/NativeOauthEssentials.js +5 -0
  25. package/lib/module/NativeOauthEssentials.js.map +1 -0
  26. package/lib/module/index.js +148 -0
  27. package/lib/module/index.js.map +1 -0
  28. package/lib/module/package.json +1 -0
  29. package/lib/module/types.js +23 -0
  30. package/lib/module/types.js.map +1 -0
  31. package/lib/typescript/package.json +1 -0
  32. package/lib/typescript/src/NativeOauthEssentials.d.ts +60 -0
  33. package/lib/typescript/src/NativeOauthEssentials.d.ts.map +1 -0
  34. package/lib/typescript/src/index.d.ts +78 -0
  35. package/lib/typescript/src/index.d.ts.map +1 -0
  36. package/lib/typescript/src/types.d.ts +71 -0
  37. package/lib/typescript/src/types.d.ts.map +1 -0
  38. package/package.json +156 -0
  39. package/src/NativeOauthEssentials.ts +75 -0
  40. package/src/index.tsx +199 -0
  41. package/src/types.ts +79 -0
@@ -0,0 +1,71 @@
1
+ export type GoogleSignInOptions = {
2
+ authorizedAccounts?: boolean;
3
+ autoSelectEnabled?: boolean;
4
+ };
5
+ export type PasskeyOptions = {
6
+ requestJson: string;
7
+ preferImmediatelyAvailableCredentials?: boolean;
8
+ isConditional?: boolean;
9
+ };
10
+ export type PassKeyCredentialResult = {
11
+ type: CredentialsType.PASSKEY;
12
+ data: string;
13
+ };
14
+ export type PasswordCredentialResult = {
15
+ type: CredentialsType.PASSWORD;
16
+ data: {
17
+ username: string;
18
+ password: string;
19
+ };
20
+ };
21
+ export type GoogleIdCredentialResult = {
22
+ type: CredentialsType.GOOGLE_ID;
23
+ data: {
24
+ id: string;
25
+ idToken: string;
26
+ displayName: string;
27
+ givenName: string;
28
+ familyName: string;
29
+ profilePictureUri?: string | null;
30
+ phoneNumber?: string | null;
31
+ };
32
+ };
33
+ export type CancelledCredentialResult = {
34
+ type: CredentialsType.CANCELLED;
35
+ data: null;
36
+ };
37
+ export type AppleIdCredentialResult = {
38
+ type: CredentialsType.APPLE_ID;
39
+ data: {
40
+ idToken: string;
41
+ authorizationCode: string;
42
+ user: string;
43
+ email: string;
44
+ fullName: string;
45
+ likelyReal: boolean;
46
+ };
47
+ };
48
+ export type WebAppleIdCredentialResult = {
49
+ type: CredentialsType.WEB_APPLE_ID;
50
+ data: {
51
+ url: string;
52
+ scheme: string | null;
53
+ host: string | null;
54
+ path: string | null;
55
+ query: string | null;
56
+ };
57
+ };
58
+ export declare enum CredentialsType {
59
+ GOOGLE_ID = "GOOGLE_ID",// GoogleId credentials type
60
+ PASSWORD = "PASSWORD",// Password credentials type
61
+ APPLE_ID = "APPLE_ID",// IOS AppleId credentials type
62
+ WEB_APPLE_ID = "WEB_APPLE_ID",// Android AppleId credentials type
63
+ CANCELLED = "CANCELLED",// type when the user cancels it
64
+ PASSKEY = "PASSKEY"
65
+ }
66
+ export declare enum CredentialError {
67
+ NO_PLAY_SERVICES_ERROR = "NO_PLAY_SERVICES_ERROR",
68
+ NO_ACTIVITY_ERROR = "NO_ACTIVITY_ERROR",
69
+ INVALID_RESULT_ERROR = "INVALID_RESULT_ERROR"
70
+ }
71
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,mBAAmB,GAAG;IAChC,kBAAkB,CAAC,EAAE,OAAO,CAAC;IAC7B,iBAAiB,CAAC,EAAE,OAAO,CAAC;CAC7B,CAAC;AAEF,MAAM,MAAM,cAAc,GAAG;IAC3B,WAAW,EAAE,MAAM,CAAC;IACpB,qCAAqC,CAAC,EAAE,OAAO,CAAC;IAChD,aAAa,CAAC,EAAE,OAAO,CAAC;CACzB,CAAC;AAEF,MAAM,MAAM,uBAAuB,GAAG;IACpC,IAAI,EAAE,eAAe,CAAC,OAAO,CAAC;IAC9B,IAAI,EAAE,MAAM,CAAC;CACd,CAAC;AAEF,MAAM,MAAM,wBAAwB,GAAG;IACrC,IAAI,EAAE,eAAe,CAAC,QAAQ,CAAC;IAC/B,IAAI,EAAE;QACJ,QAAQ,EAAE,MAAM,CAAC;QACjB,QAAQ,EAAE,MAAM,CAAC;KAClB,CAAC;CACH,CAAC;AAEF,MAAM,MAAM,wBAAwB,GAAG;IACrC,IAAI,EAAE,eAAe,CAAC,SAAS,CAAC;IAChC,IAAI,EAAE;QACJ,EAAE,EAAE,MAAM,CAAC;QACX,OAAO,EAAE,MAAM,CAAC;QAChB,WAAW,EAAE,MAAM,CAAC;QACpB,SAAS,EAAE,MAAM,CAAC;QAClB,UAAU,EAAE,MAAM,CAAC;QACnB,iBAAiB,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;QAClC,WAAW,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;KAC7B,CAAC;CACH,CAAC;AAEF,MAAM,MAAM,yBAAyB,GAAG;IACtC,IAAI,EAAE,eAAe,CAAC,SAAS,CAAC;IAChC,IAAI,EAAE,IAAI,CAAC;CACZ,CAAC;AAEF,MAAM,MAAM,uBAAuB,GAAG;IACpC,IAAI,EAAE,eAAe,CAAC,QAAQ,CAAC;IAC/B,IAAI,EAAE;QACJ,OAAO,EAAE,MAAM,CAAC;QAChB,iBAAiB,EAAE,MAAM,CAAC;QAC1B,IAAI,EAAE,MAAM,CAAC;QACb,KAAK,EAAE,MAAM,CAAC;QACd,QAAQ,EAAE,MAAM,CAAC;QACjB,UAAU,EAAE,OAAO,CAAC;KACrB,CAAC;CACH,CAAC;AAEF,MAAM,MAAM,0BAA0B,GAAG;IACvC,IAAI,EAAE,eAAe,CAAC,YAAY,CAAC;IACnC,IAAI,EAAE;QACJ,GAAG,EAAE,MAAM,CAAC;QACZ,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;QACtB,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;QACpB,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;QACpB,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;KACtB,CAAC;CACH,CAAC;AAEF,oBAAY,eAAe;IACzB,SAAS,cAAc,CAAE,4BAA4B;IACrD,QAAQ,aAAa,CAAE,4BAA4B;IACnD,QAAQ,aAAa,CAAE,+BAA+B;IACtD,YAAY,iBAAiB,CAAE,mCAAmC;IAClE,SAAS,cAAc,CAAE,gCAAgC;IACzD,OAAO,YAAY;CACpB;AAED,oBAAY,eAAe;IACzB,sBAAsB,2BAA2B;IACjD,iBAAiB,sBAAsB;IACvC,oBAAoB,yBAAyB;CAC9C"}
package/package.json ADDED
@@ -0,0 +1,156 @@
1
+ {
2
+ "name": "react-native-oauth-essentials",
3
+ "version": "1.0.2",
4
+ "description": "Essential oauth tools for every app.need.",
5
+ "main": "./lib/module/index.js",
6
+ "types": "./lib/typescript/src/index.d.ts",
7
+ "exports": {
8
+ ".": {
9
+ "source": "./src/index.tsx",
10
+ "types": "./lib/typescript/src/index.d.ts",
11
+ "default": "./lib/module/index.js"
12
+ },
13
+ "./package.json": "./package.json"
14
+ },
15
+ "files": [
16
+ "src",
17
+ "lib",
18
+ "android",
19
+ "ios",
20
+ "cpp",
21
+ "*.podspec",
22
+ "react-native.config.js",
23
+ "!ios/build",
24
+ "!android/build",
25
+ "!android/gradle",
26
+ "!android/gradlew",
27
+ "!android/gradlew.bat",
28
+ "!android/local.properties",
29
+ "!**/__tests__",
30
+ "!**/__fixtures__",
31
+ "!**/__mocks__",
32
+ "!**/.*"
33
+ ],
34
+ "scripts": {
35
+ "example": "yarn workspace react-native-oauth-essentials-example",
36
+ "clean": "del-cli android/build example/android/build example/android/app/build example/ios/build lib",
37
+ "prepare": "bob build",
38
+ "typecheck": "tsc",
39
+ "lint": "eslint \"**/*.{js,ts,tsx}\"",
40
+ "test": "jest",
41
+ "prerelease": "yarn typecheck && yarn lint && yarn test",
42
+ "release": "release-it",
43
+ "release:patch": "release-it patch",
44
+ "release:minor": "release-it minor",
45
+ "release:major": "release-it major",
46
+ "release:dry": "release-it --dry-run"
47
+ },
48
+ "keywords": [
49
+ "react-native",
50
+ "ios",
51
+ "android"
52
+ ],
53
+ "repository": {
54
+ "type": "git",
55
+ "url": "git+https://github.com/lucaswitch/react-native-oauth-essentials.git"
56
+ },
57
+ "author": "Lucas Alves <lucas.developing@gmail.com> (https://github.com/lucaswitch)",
58
+ "license": "MIT",
59
+ "bugs": {
60
+ "url": "https://github.com/lucaswitch/react-native-oauth-essentials/issues"
61
+ },
62
+ "homepage": "https://github.com/lucaswitch/react-native-oauth-essentials#readme",
63
+ "publishConfig": {
64
+ "registry": "https://registry.npmjs.org/"
65
+ },
66
+ "devDependencies": {
67
+ "@commitlint/config-conventional": "^19.8.1",
68
+ "@eslint/compat": "^1.3.2",
69
+ "@eslint/eslintrc": "^3.3.1",
70
+ "@eslint/js": "^9.35.0",
71
+ "@react-native/babel-preset": "0.83.0",
72
+ "@react-native/eslint-config": "0.83.0",
73
+ "@release-it/conventional-changelog": "10.0.1",
74
+ "@types/jest": "^29.5.14",
75
+ "@types/react": "^19.2.0",
76
+ "commitlint": "^19.8.1",
77
+ "del-cli": "^6.0.0",
78
+ "eslint": "^9.35.0",
79
+ "eslint-config-prettier": "^10.1.8",
80
+ "eslint-plugin-prettier": "^5.5.4",
81
+ "jest": "^29.7.0",
82
+ "lefthook": "^2.0.3",
83
+ "prettier": "^2.8.8",
84
+ "react": "19.2.0",
85
+ "react-native": "0.83.0",
86
+ "react-native-builder-bob": "^0.40.13",
87
+ "release-it": "^19.0.4",
88
+ "turbo": "^2.5.6",
89
+ "typescript": "^5.9.2"
90
+ },
91
+ "peerDependencies": {
92
+ "react": "*",
93
+ "react-native": "*"
94
+ },
95
+ "workspaces": [
96
+ "example",
97
+ "docs"
98
+ ],
99
+ "packageManager": "yarn@4.11.0",
100
+ "react-native-builder-bob": {
101
+ "source": "src",
102
+ "output": "lib",
103
+ "targets": [
104
+ [
105
+ "module",
106
+ {
107
+ "esm": true
108
+ }
109
+ ],
110
+ [
111
+ "typescript",
112
+ {
113
+ "project": "tsconfig.build.json"
114
+ }
115
+ ]
116
+ ]
117
+ },
118
+ "codegenConfig": {
119
+ "name": "OauthEssentialsSpec",
120
+ "type": "modules",
121
+ "jsSrcsDir": "src",
122
+ "android": {
123
+ "javaPackageName": "com.oauthessentials"
124
+ }
125
+ },
126
+ "prettier": {
127
+ "quoteProps": "consistent",
128
+ "singleQuote": true,
129
+ "tabWidth": 2,
130
+ "trailingComma": "es5",
131
+ "useTabs": false
132
+ },
133
+ "jest": {
134
+ "preset": "react-native",
135
+ "modulePathIgnorePatterns": [
136
+ "<rootDir>/example/node_modules",
137
+ "<rootDir>/lib/"
138
+ ]
139
+ },
140
+ "commitlint": {
141
+ "extends": [
142
+ "@commitlint/config-conventional"
143
+ ]
144
+ },
145
+ "create-react-native-library": {
146
+ "type": "turbo-module",
147
+ "languages": "kotlin-objc",
148
+ "tools": [
149
+ "eslint",
150
+ "jest",
151
+ "lefthook",
152
+ "release-it"
153
+ ],
154
+ "version": "0.57.0"
155
+ }
156
+ }
@@ -0,0 +1,75 @@
1
+ import {
2
+ type CodegenTypes,
3
+ type TurboModule,
4
+ TurboModuleRegistry,
5
+ } from 'react-native';
6
+
7
+ export interface Spec extends TurboModule {
8
+ // Events
9
+ readonly onCredentialSuccess: CodegenTypes.EventEmitter<CredentialSuccessEvent>;
10
+ readonly onCredentialFailure: CodegenTypes.EventEmitter<CredentialErrorEvent>;
11
+
12
+ getConstants(): {
13
+ readonly GOOGLE_PLAY_SERVICES_SUPPORTED: boolean;
14
+ readonly PASSWORD_SUPPORTED: boolean;
15
+ readonly GOOGLE_ID_SUPPORTED: boolean;
16
+ readonly APPLE_ID_SUPPORTED: boolean;
17
+ readonly HYBRID_SUPPORTED: boolean;
18
+ readonly PASSKEYS_SUPPORTED: boolean;
19
+ };
20
+
21
+ /**
22
+ * Performs the google sign in.
23
+ * @param androidAndIOSClientId
24
+ * @param options
25
+ */
26
+ googleSignIn(androidAndIOSClientId: string, options: Object): Promise<Object>;
27
+
28
+ /**
29
+ * Sign ins with apple.
30
+ * @param androidWebUrl
31
+ */
32
+ appleSignIn(androidWebUrl?: string): Promise<Object>;
33
+
34
+ /**
35
+ * Saves the username/password credential
36
+ * @param username
37
+ * @param password
38
+ */
39
+ passwordSignIn(username: string, password: string): Promise<boolean>;
40
+
41
+ /**
42
+ * Gets the saved password.
43
+ */
44
+ getPassword(): Promise<Object>;
45
+
46
+ /**
47
+ * Performs the called so "hybrid sign in"
48
+ * @param googleClientId
49
+ * @param options
50
+ */
51
+ hybridSignIn(googleClientId: string, options: Object): Promise<Object>;
52
+
53
+ /**
54
+ * Creates the passkey.
55
+ */
56
+ createPassKey(options: Object): Promise<Object>;
57
+
58
+ /**
59
+ * Gets the passkey
60
+ * @param options
61
+ */
62
+ getPassKey(options: Object): Promise<Object>;
63
+ }
64
+
65
+ export default TurboModuleRegistry.getEnforcing<Spec>('OauthEssentials');
66
+
67
+ type CredentialSuccessEvent = {
68
+ type: string;
69
+ data: Object;
70
+ };
71
+
72
+ type CredentialErrorEvent = {
73
+ code: string;
74
+ message: string;
75
+ };
package/src/index.tsx ADDED
@@ -0,0 +1,199 @@
1
+ import OauthEssentials from './NativeOauthEssentials';
2
+ import { Platform } from 'react-native';
3
+ import {
4
+ type AppleIdCredentialResult,
5
+ type CancelledCredentialResult,
6
+ CredentialsType,
7
+ type GoogleIdCredentialResult,
8
+ type GoogleSignInOptions,
9
+ type PassKeyCredentialResult,
10
+ type PasskeyOptions,
11
+ type PasswordCredentialResult,
12
+ type WebAppleIdCredentialResult,
13
+ } from './types';
14
+
15
+ export * from './types';
16
+ const APPLE_ID_CACHED_RESULTS = new Map<
17
+ string,
18
+ AppleIdCredentialResult['data']
19
+ >();
20
+
21
+ /**
22
+ * Performs the google sign in.
23
+ * @param webClientId
24
+ * @param options
25
+ *
26
+ * You should rely on GOOGLE_ID_SUPPORTED constant to check if you can use this method.
27
+ * [Available on Android and IOS].
28
+ */
29
+ export async function googleSignIn(
30
+ webClientId: string,
31
+ options?: GoogleSignInOptions
32
+ ): Promise<GoogleIdCredentialResult | CancelledCredentialResult> {
33
+ return (await OauthEssentials.googleSignIn(
34
+ webClientId,
35
+ parseGoogleIdOptions(options)
36
+ )) as GoogleIdCredentialResult;
37
+ }
38
+
39
+ /**
40
+ * Gets the stored password.
41
+ * If does not have an stored password, returns false.
42
+ *
43
+ * You should rely on PASSWORD_SUPPORTED constant to check if you can use this method.
44
+ * [Available on Android and IOS].
45
+ */
46
+ export async function getPassword(): Promise<false | PasswordCredentialResult> {
47
+ const result = await OauthEssentials.getPassword();
48
+ return (result as PasswordCredentialResult) || false;
49
+ }
50
+
51
+ /**
52
+ * Performs the password sign in.
53
+ * Cannot be a already stored password.
54
+ * @param {string} username
55
+ * @param {string} password
56
+ *
57
+ * You should rely on PASSWORD_SUPPORTED constant to check if you can use this method.
58
+ * [Available on Android and IOS].
59
+ */
60
+ export async function passwordSignIn(
61
+ username: string,
62
+ password: string
63
+ ): Promise<boolean> {
64
+ return await OauthEssentials.passwordSignIn(username, password);
65
+ }
66
+
67
+ /**
68
+ * Initiates the Apple Sign-In process.
69
+ * On IOS devices it handles it smoothly using the latest UI workflow.
70
+ * On Android it dispatches the androidWebUrl to device default browser for handling it.
71
+ * you need to implement on your backend the redirect logic and validation accordingly to the link below
72
+ * @see [Apple Sign In REST API Documentation](https://developer.apple.com/documentation/signinwithapplerestapi)
73
+ *
74
+ * @param {string} androidWebUrl - The web URL on Android where the user will complete the OAuth flow. **[Android only]**
75
+ *
76
+ * @returns {AppleIdCredentialResult|WebAppleIdCredentialResult} Returns AppleIdCredentialResult on IOS devices and WebAppleIdCredentialResult on android.
77
+ */
78
+ export async function appleSignIn(
79
+ androidWebUrl?: string
80
+ ): Promise<AppleIdCredentialResult | WebAppleIdCredentialResult> {
81
+ const result = (await OauthEssentials.appleSignIn(
82
+ Platform.select({
83
+ ios: undefined,
84
+ android: androidWebUrl,
85
+ })
86
+ )) as AppleIdCredentialResult | WebAppleIdCredentialResult;
87
+ if (result.type === CredentialsType.APPLE_ID) {
88
+ if (APPLE_ID_CACHED_RESULTS.has(result.data.user)) {
89
+ // Reuse the fullName and email provided
90
+ const cached = APPLE_ID_CACHED_RESULTS.get(
91
+ result.data.user
92
+ ) as AppleIdCredentialResult['data'];
93
+
94
+ const data = result.data;
95
+ if (!data.fullName) {
96
+ data.fullName = cached.fullName;
97
+ }
98
+ if (!data.email) {
99
+ data.email = cached.email;
100
+ }
101
+ } else {
102
+ APPLE_ID_CACHED_RESULTS.set(result.data.user, result.data);
103
+ }
104
+ return result as AppleIdCredentialResult;
105
+ } else {
106
+ return result as WebAppleIdCredentialResult;
107
+ }
108
+ }
109
+
110
+ /**
111
+ * Performs all sign in methods available on the platform at once.
112
+ * This is supposed to be used on app start to get any existing sign in.
113
+ */
114
+ export async function hybridSignIn(
115
+ googleClientId: string,
116
+ options?: GoogleSignInOptions
117
+ ): Promise<
118
+ | AppleIdCredentialResult
119
+ | GoogleIdCredentialResult
120
+ | PasswordCredentialResult
121
+ | CancelledCredentialResult
122
+ > {
123
+ return (await OauthEssentials.hybridSignIn(
124
+ googleClientId,
125
+ parseGoogleIdOptions(options)
126
+ )) as
127
+ | AppleIdCredentialResult
128
+ | GoogleIdCredentialResult
129
+ | PasswordCredentialResult;
130
+ }
131
+
132
+ /**
133
+ * Creates a passkey.
134
+ * @param options
135
+ */
136
+ export async function createPassKey(
137
+ options: PasskeyOptions
138
+ ): Promise<PassKeyCredentialResult> {
139
+ return (await OauthEssentials.createPassKey(
140
+ options
141
+ )) as PassKeyCredentialResult;
142
+ }
143
+
144
+ function parseGoogleIdOptions(options?: any) {
145
+ const bridgeOptions: GoogleSignInOptions = {
146
+ authorizedAccounts: false,
147
+ autoSelectEnabled: false,
148
+ };
149
+
150
+ const hasOptions =
151
+ options && typeof options === 'object' && Object.keys(options).length > 0;
152
+
153
+ if (hasOptions) {
154
+ if (Platform.OS === 'android') {
155
+ if (options.hasOwnProperty('authorizedAccounts')) {
156
+ bridgeOptions.authorizedAccounts = options.authorizedAccounts === true;
157
+ }
158
+ if (options.hasOwnProperty('autoSelectEnabled')) {
159
+ bridgeOptions.autoSelectEnabled = options.autoSelectEnabled === true;
160
+ }
161
+ }
162
+ }
163
+ return bridgeOptions;
164
+ }
165
+
166
+ const CONSTANTS = OauthEssentials.getConstants();
167
+
168
+ /**
169
+ * Google Play are supported.
170
+ * It always false on IOS, cause IOS does not use Google Play Services.
171
+ */
172
+ export const GOOGLE_PLAY_SERVICES_SUPPORTED =
173
+ CONSTANTS.GOOGLE_PLAY_SERVICES_SUPPORTED;
174
+
175
+ /**
176
+ * The password method is supported.
177
+ */
178
+ export const PASSWORD_SUPPORTED = CONSTANTS.PASSWORD_SUPPORTED;
179
+
180
+ /**
181
+ * Google Play id sign in is supported.
182
+ * You should mainly rely on this constant to check if you can use google sign in.
183
+ */
184
+ export const GOOGLE_ID_SUPPORTED = CONSTANTS.GOOGLE_ID_SUPPORTED;
185
+
186
+ /**
187
+ * Gets if Apple id sign in is supported.
188
+ */
189
+ export const APPLE_ID_SUPPORTED = CONSTANTS.APPLE_ID_SUPPORTED;
190
+
191
+ /**
192
+ * Gets if "hybrid" is supported in this platform.
193
+ */
194
+ export const HYBRID_SUPPORTED = CONSTANTS.HYBRID_SUPPORTED;
195
+
196
+ /**
197
+ * Gets if passkeys are supported.
198
+ */
199
+ export const PASSKEYS_SUPPORTED = CONSTANTS.PASSKEYS_SUPPORTED;
package/src/types.ts ADDED
@@ -0,0 +1,79 @@
1
+ export type GoogleSignInOptions = {
2
+ authorizedAccounts?: boolean;
3
+ autoSelectEnabled?: boolean;
4
+ };
5
+
6
+ export type PasskeyOptions = {
7
+ requestJson: string;
8
+ preferImmediatelyAvailableCredentials?: boolean; // [Android only]
9
+ isConditional?: boolean; // [Android only]
10
+ };
11
+
12
+ export type PassKeyCredentialResult = {
13
+ type: CredentialsType.PASSKEY;
14
+ data: string; // JSON platform public key
15
+ };
16
+
17
+ export type PasswordCredentialResult = {
18
+ type: CredentialsType.PASSWORD;
19
+ data: {
20
+ username: string;
21
+ password: string;
22
+ };
23
+ };
24
+
25
+ export type GoogleIdCredentialResult = {
26
+ type: CredentialsType.GOOGLE_ID;
27
+ data: {
28
+ id: string;
29
+ idToken: string;
30
+ displayName: string;
31
+ givenName: string;
32
+ familyName: string;
33
+ profilePictureUri?: string | null;
34
+ phoneNumber?: string | null;
35
+ };
36
+ };
37
+
38
+ export type CancelledCredentialResult = {
39
+ type: CredentialsType.CANCELLED;
40
+ data: null;
41
+ };
42
+
43
+ export type AppleIdCredentialResult = {
44
+ type: CredentialsType.APPLE_ID;
45
+ data: {
46
+ idToken: string;
47
+ authorizationCode: string;
48
+ user: string;
49
+ email: string;
50
+ fullName: string;
51
+ likelyReal: boolean;
52
+ };
53
+ };
54
+
55
+ export type WebAppleIdCredentialResult = {
56
+ type: CredentialsType.WEB_APPLE_ID;
57
+ data: {
58
+ url: string;
59
+ scheme: string | null;
60
+ host: string | null;
61
+ path: string | null;
62
+ query: string | null;
63
+ };
64
+ };
65
+
66
+ export enum CredentialsType {
67
+ GOOGLE_ID = 'GOOGLE_ID', // GoogleId credentials type
68
+ PASSWORD = 'PASSWORD', // Password credentials type
69
+ APPLE_ID = 'APPLE_ID', // IOS AppleId credentials type
70
+ WEB_APPLE_ID = 'WEB_APPLE_ID', // Android AppleId credentials type
71
+ CANCELLED = 'CANCELLED', // type when the user cancels it
72
+ PASSKEY = 'PASSKEY', // Passkey credential type
73
+ }
74
+
75
+ export enum CredentialError {
76
+ NO_PLAY_SERVICES_ERROR = 'NO_PLAY_SERVICES_ERROR',
77
+ NO_ACTIVITY_ERROR = 'NO_ACTIVITY_ERROR',
78
+ INVALID_RESULT_ERROR = 'INVALID_RESULT_ERROR',
79
+ }