react-native-authsignal 2.3.7 → 2.3.8
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/lib/commonjs/email.js +11 -18
- package/lib/commonjs/email.js.map +1 -1
- package/lib/commonjs/error.js +2 -4
- package/lib/commonjs/error.js.map +1 -1
- package/lib/commonjs/inapp.js +34 -46
- package/lib/commonjs/inapp.js.map +1 -1
- package/lib/commonjs/index.js +6 -19
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/passkey.js +21 -30
- package/lib/commonjs/passkey.js.map +1 -1
- package/lib/commonjs/push.js +15 -22
- package/lib/commonjs/push.js.map +1 -1
- package/lib/commonjs/qr.js +18 -26
- package/lib/commonjs/qr.js.map +1 -1
- package/lib/commonjs/sms.js +11 -18
- package/lib/commonjs/sms.js.map +1 -1
- package/lib/commonjs/totp.js +8 -14
- package/lib/commonjs/totp.js.map +1 -1
- package/lib/commonjs/types.js +2 -4
- package/lib/commonjs/types.js.map +1 -1
- package/lib/commonjs/whatsapp.js +8 -14
- package/lib/commonjs/whatsapp.js.map +1 -1
- package/lib/module/email.js +11 -18
- package/lib/module/email.js.map +1 -1
- package/lib/module/error.js.map +1 -1
- package/lib/module/inapp.js +34 -46
- package/lib/module/inapp.js.map +1 -1
- package/lib/module/index.js +6 -19
- package/lib/module/index.js.map +1 -1
- package/lib/module/passkey.js +21 -30
- package/lib/module/passkey.js.map +1 -1
- package/lib/module/push.js +15 -22
- package/lib/module/push.js.map +1 -1
- package/lib/module/qr.js +18 -26
- package/lib/module/qr.js.map +1 -1
- package/lib/module/sms.js +11 -18
- package/lib/module/sms.js.map +1 -1
- package/lib/module/totp.js +8 -14
- package/lib/module/totp.js.map +1 -1
- package/lib/module/types.js.map +1 -1
- package/lib/module/whatsapp.js +8 -14
- package/lib/module/whatsapp.js.map +1 -1
- package/package.json +5 -5
- package/.editorconfig +0 -15
- package/.gitattributes +0 -3
- package/.github/images/authsignal.png +0 -0
- package/.github/pull_request_template.md +0 -12
- package/.github/release-drafter-config.yml +0 -75
- package/.github/workflows/release-drafter.yml +0 -25
- package/.github/workflows/release-package.yml +0 -25
- package/.gitignore +0 -67
- package/.npmignore +0 -1
- package/.watchmanconfig +0 -1
- package/android/gradle/wrapper/gradle-wrapper.jar +0 -0
- package/android/gradle/wrapper/gradle-wrapper.properties +0 -7
- package/android/gradlew +0 -234
- package/android/gradlew.bat +0 -89
- package/babel.config.js +0 -3
- package/src/email.ts +0 -94
- package/src/error.ts +0 -28
- package/src/inapp.ts +0 -210
- package/src/index.tsx +0 -100
- package/src/passkey.ts +0 -179
- package/src/push.ts +0 -150
- package/src/qr.ts +0 -153
- package/src/sms.ts +0 -96
- package/src/totp.ts +0 -83
- package/src/types.ts +0 -151
- package/src/whatsapp.ts +0 -78
- package/tsconfig.build.json +0 -5
- package/tsconfig.json +0 -28
- package/yarn.lock +0 -6420
package/src/totp.ts
DELETED
|
@@ -1,83 +0,0 @@
|
|
|
1
|
-
import { NativeModules } from 'react-native';
|
|
2
|
-
import { handleErrorCodes, LINKING_ERROR } from './error';
|
|
3
|
-
import type { AuthsignalResponse, VerifyInput, VerifyResponse } from './types';
|
|
4
|
-
|
|
5
|
-
interface ConstructorArgs {
|
|
6
|
-
tenantID: string;
|
|
7
|
-
baseURL: string;
|
|
8
|
-
enableLogging: boolean;
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
interface EnrollTotpResponse {
|
|
12
|
-
uri: string;
|
|
13
|
-
secret: string;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
let initialized = false;
|
|
17
|
-
|
|
18
|
-
const AuthsignalTOTPModule = NativeModules.AuthsignalTOTPModule
|
|
19
|
-
? NativeModules.AuthsignalTOTPModule
|
|
20
|
-
: new Proxy(
|
|
21
|
-
{},
|
|
22
|
-
{
|
|
23
|
-
get() {
|
|
24
|
-
throw new Error(LINKING_ERROR);
|
|
25
|
-
},
|
|
26
|
-
}
|
|
27
|
-
);
|
|
28
|
-
|
|
29
|
-
export class AuthsignalTotp {
|
|
30
|
-
tenantID: string;
|
|
31
|
-
baseURL: string;
|
|
32
|
-
enableLogging: boolean;
|
|
33
|
-
|
|
34
|
-
constructor({ tenantID, baseURL, enableLogging }: ConstructorArgs) {
|
|
35
|
-
this.tenantID = tenantID;
|
|
36
|
-
this.baseURL = baseURL;
|
|
37
|
-
this.enableLogging = enableLogging;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
async enroll(): Promise<AuthsignalResponse<EnrollTotpResponse>> {
|
|
41
|
-
await this.ensureModuleIsInitialized();
|
|
42
|
-
|
|
43
|
-
try {
|
|
44
|
-
const data = await AuthsignalTOTPModule.enroll();
|
|
45
|
-
|
|
46
|
-
return { data };
|
|
47
|
-
} catch (ex) {
|
|
48
|
-
return this.handleError(ex);
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
async verify({
|
|
53
|
-
code,
|
|
54
|
-
}: VerifyInput): Promise<AuthsignalResponse<VerifyResponse>> {
|
|
55
|
-
await this.ensureModuleIsInitialized();
|
|
56
|
-
|
|
57
|
-
try {
|
|
58
|
-
const data = await AuthsignalTOTPModule.verify(code);
|
|
59
|
-
|
|
60
|
-
return { data };
|
|
61
|
-
} catch (ex) {
|
|
62
|
-
return this.handleError(ex);
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
private async ensureModuleIsInitialized() {
|
|
67
|
-
if (initialized) {
|
|
68
|
-
return;
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
await AuthsignalTOTPModule.initialize(this.tenantID, this.baseURL);
|
|
72
|
-
|
|
73
|
-
initialized = true;
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
private handleError(ex: unknown) {
|
|
77
|
-
if (this.enableLogging) {
|
|
78
|
-
console.log(ex);
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
return handleErrorCodes(ex);
|
|
82
|
-
}
|
|
83
|
-
}
|
package/src/types.ts
DELETED
|
@@ -1,151 +0,0 @@
|
|
|
1
|
-
import type { ErrorCode } from './error';
|
|
2
|
-
|
|
3
|
-
export interface AuthsignalResponse<T> {
|
|
4
|
-
data?: T;
|
|
5
|
-
error?: string;
|
|
6
|
-
errorCode?: ErrorCode | string;
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
export interface TokenPayload {
|
|
10
|
-
aud: string;
|
|
11
|
-
exp: number;
|
|
12
|
-
iat: number;
|
|
13
|
-
other: {
|
|
14
|
-
actionCode: string;
|
|
15
|
-
idempotencyKey: string;
|
|
16
|
-
publishableKey: string;
|
|
17
|
-
tenantId: string;
|
|
18
|
-
userId: string;
|
|
19
|
-
username: string;
|
|
20
|
-
};
|
|
21
|
-
scope?: string;
|
|
22
|
-
sub: string;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
export interface SignUpResponse {
|
|
26
|
-
token: string;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
export interface SignInResponse {
|
|
30
|
-
isVerified: boolean;
|
|
31
|
-
token?: string;
|
|
32
|
-
userId?: string;
|
|
33
|
-
userAuthenticatorId?: string;
|
|
34
|
-
username?: string;
|
|
35
|
-
displayName?: string;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
export interface VerifyInput {
|
|
39
|
-
code: string;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
export interface VerifyResponse {
|
|
43
|
-
isVerified: boolean;
|
|
44
|
-
token?: string;
|
|
45
|
-
failureReason?: string;
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
export interface AddCredentialInput {
|
|
49
|
-
token?: string;
|
|
50
|
-
requireUserAuthentication?: boolean;
|
|
51
|
-
keychainAccess?: KeychainAccess;
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
export interface AppChallenge {
|
|
55
|
-
challengeId: string;
|
|
56
|
-
actionCode?: string;
|
|
57
|
-
idempotencyKey?: string;
|
|
58
|
-
userAgent?: string;
|
|
59
|
-
deviceId?: string;
|
|
60
|
-
ipAddress?: string;
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
export interface AppCredential {
|
|
64
|
-
credentialId: string;
|
|
65
|
-
createdAt: string;
|
|
66
|
-
userId: string;
|
|
67
|
-
lastAuthenticatedAt?: string;
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
export interface ClaimChallengeInput {
|
|
71
|
-
challengeId: string;
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
export interface ClaimChallengeResponse {
|
|
75
|
-
success: boolean;
|
|
76
|
-
userAgent?: string;
|
|
77
|
-
ipAddress?: string;
|
|
78
|
-
actionCode?: string;
|
|
79
|
-
idempotencyKey?: string;
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
export interface UpdateChallengeInput {
|
|
83
|
-
challengeId: string;
|
|
84
|
-
approved: boolean;
|
|
85
|
-
verificationCode?: string | null;
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
export interface InAppGetCredentialInput {
|
|
89
|
-
username?: string;
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
export interface InAppAddCredentialInput extends AddCredentialInput {
|
|
93
|
-
username?: string;
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
export interface InAppRemoveCredentialInput {
|
|
97
|
-
username?: string;
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
export interface InAppVerifyInput {
|
|
101
|
-
action?: string;
|
|
102
|
-
username?: string;
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
export interface InAppVerifyResponse {
|
|
106
|
-
token: string;
|
|
107
|
-
userId: string;
|
|
108
|
-
userAuthenticatorId: string;
|
|
109
|
-
username?: string;
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
export interface CreatePinInput {
|
|
113
|
-
pin: string;
|
|
114
|
-
username: string;
|
|
115
|
-
token?: string;
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
export interface VerifyPinInput {
|
|
119
|
-
pin: string;
|
|
120
|
-
username: string;
|
|
121
|
-
action?: string;
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
export interface VerifyPinResponse {
|
|
125
|
-
isVerified: boolean;
|
|
126
|
-
token?: string;
|
|
127
|
-
userId?: string;
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
export interface DeletePinInput {
|
|
131
|
-
username: string;
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
export enum KeychainAccess {
|
|
135
|
-
afterFirstUnlock = 'afterFirstUnlock',
|
|
136
|
-
afterFirstUnlockThisDeviceOnly = 'afterFirstUnlockThisDeviceOnly',
|
|
137
|
-
whenUnlocked = 'whenUnlocked',
|
|
138
|
-
whenUnlockedThisDeviceOnly = 'whenUnlockedThisDeviceOnly',
|
|
139
|
-
whenPasscodeSetThisDeviceOnly = 'whenPasscodeSetThisDeviceOnly',
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
export enum UserActionState {
|
|
143
|
-
ALLOW = 'ALLOW',
|
|
144
|
-
BLOCK = 'BLOCK',
|
|
145
|
-
CHALLENGE_REQUIRED = 'CHALLENGE_REQUIRED',
|
|
146
|
-
CHALLENGE_SUCCEEDED = 'CHALLENGE_SUCCEEDED',
|
|
147
|
-
CHALLENGE_FAILED = 'CHALLENGE_FAILED',
|
|
148
|
-
REVIEW_REQUIRED = 'REVIEW_REQUIRED',
|
|
149
|
-
REVIEW_SUCCEEDED = 'REVIEW_SUCCEEDED',
|
|
150
|
-
REVIEW_FAILED = 'REVIEW_FAILED',
|
|
151
|
-
}
|
package/src/whatsapp.ts
DELETED
|
@@ -1,78 +0,0 @@
|
|
|
1
|
-
import { NativeModules } from 'react-native';
|
|
2
|
-
import { handleErrorCodes, LINKING_ERROR } from './error';
|
|
3
|
-
import type { AuthsignalResponse, VerifyInput, VerifyResponse } from './types';
|
|
4
|
-
|
|
5
|
-
interface ConstructorArgs {
|
|
6
|
-
tenantID: string;
|
|
7
|
-
baseURL: string;
|
|
8
|
-
enableLogging: boolean;
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
let initialized = false;
|
|
12
|
-
|
|
13
|
-
const AuthsignalWhatsappModule = NativeModules.AuthsignalWhatsappModule
|
|
14
|
-
? NativeModules.AuthsignalWhatsappModule
|
|
15
|
-
: new Proxy(
|
|
16
|
-
{},
|
|
17
|
-
{
|
|
18
|
-
get() {
|
|
19
|
-
throw new Error(LINKING_ERROR);
|
|
20
|
-
},
|
|
21
|
-
}
|
|
22
|
-
);
|
|
23
|
-
|
|
24
|
-
export class AuthsignalWhatsapp {
|
|
25
|
-
tenantID: string;
|
|
26
|
-
baseURL: string;
|
|
27
|
-
enableLogging: boolean;
|
|
28
|
-
|
|
29
|
-
constructor({ tenantID, baseURL, enableLogging }: ConstructorArgs) {
|
|
30
|
-
this.tenantID = tenantID;
|
|
31
|
-
this.baseURL = baseURL;
|
|
32
|
-
this.enableLogging = enableLogging;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
async challenge(): Promise<AuthsignalResponse<void>> {
|
|
36
|
-
await this.ensureModuleIsInitialized();
|
|
37
|
-
|
|
38
|
-
try {
|
|
39
|
-
await AuthsignalWhatsappModule.challenge();
|
|
40
|
-
|
|
41
|
-
return {};
|
|
42
|
-
} catch (ex) {
|
|
43
|
-
return this.handleError(ex);
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
async verify({
|
|
48
|
-
code,
|
|
49
|
-
}: VerifyInput): Promise<AuthsignalResponse<VerifyResponse>> {
|
|
50
|
-
await this.ensureModuleIsInitialized();
|
|
51
|
-
|
|
52
|
-
try {
|
|
53
|
-
const data = await AuthsignalWhatsappModule.verify(code);
|
|
54
|
-
|
|
55
|
-
return { data };
|
|
56
|
-
} catch (ex) {
|
|
57
|
-
return this.handleError(ex);
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
private async ensureModuleIsInitialized() {
|
|
62
|
-
if (initialized) {
|
|
63
|
-
return;
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
await AuthsignalWhatsappModule.initialize(this.tenantID, this.baseURL);
|
|
67
|
-
|
|
68
|
-
initialized = true;
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
private handleError(ex: unknown) {
|
|
72
|
-
if (this.enableLogging) {
|
|
73
|
-
console.log(ex);
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
return handleErrorCodes(ex);
|
|
77
|
-
}
|
|
78
|
-
}
|
package/tsconfig.build.json
DELETED
package/tsconfig.json
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"compilerOptions": {
|
|
3
|
-
"baseUrl": "./",
|
|
4
|
-
"paths": {
|
|
5
|
-
"react-native-authsignal": ["./src/index"]
|
|
6
|
-
},
|
|
7
|
-
"allowUnreachableCode": false,
|
|
8
|
-
"allowUnusedLabels": false,
|
|
9
|
-
"esModuleInterop": true,
|
|
10
|
-
"importsNotUsedAsValues": "error",
|
|
11
|
-
"forceConsistentCasingInFileNames": true,
|
|
12
|
-
"jsx": "react",
|
|
13
|
-
"lib": ["esnext"],
|
|
14
|
-
"module": "esnext",
|
|
15
|
-
"moduleResolution": "node",
|
|
16
|
-
"noFallthroughCasesInSwitch": true,
|
|
17
|
-
"noImplicitReturns": true,
|
|
18
|
-
"noImplicitUseStrict": false,
|
|
19
|
-
"noStrictGenericChecks": false,
|
|
20
|
-
"noUncheckedIndexedAccess": true,
|
|
21
|
-
"noUnusedLocals": true,
|
|
22
|
-
"noUnusedParameters": true,
|
|
23
|
-
"resolveJsonModule": true,
|
|
24
|
-
"skipLibCheck": true,
|
|
25
|
-
"strict": true,
|
|
26
|
-
"target": "esnext"
|
|
27
|
-
}
|
|
28
|
-
}
|