Skip to content

Commit 17e958f

Browse files
[AUT-3288] Add performAttestation support to QR and Push addCredential
1 parent 0f4edd5 commit 17e958f

10 files changed

Lines changed: 26 additions & 12 deletions

android/src/main/java/com/authsignal/react/AuthsignalPushModule.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,10 +54,11 @@ class AuthsignalPushModule(private val reactContext: ReactApplicationContext) :
5454
token: String?,
5555
_requireUserAuthentication: Boolean,
5656
_keychainAccess: String?,
57+
performAttestation: Boolean,
5758
promise: Promise
5859
) {
5960
launch(promise) {
60-
val response = it.addCredential(token, null)
61+
val response = it.addCredential(token, null, performAttestation = performAttestation)
6162

6263
if (response.error != null) {
6364
val errorCode = response.errorCode ?: defaultError

android/src/main/java/com/authsignal/react/AuthsignalQRCodeModule.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,10 +54,11 @@ class AuthsignalQRCodeModule(private val reactContext: ReactApplicationContext)
5454
token: String?,
5555
_requireUserAuthentication: Boolean,
5656
_keychainAccess: String?,
57+
performAttestation: Boolean,
5758
promise: Promise
5859
) {
5960
launch(promise) {
60-
val response = it.addCredential(token, null)
61+
val response = it.addCredential(token, null, performAttestation = performAttestation)
6162

6263
if (response.error != null) {
6364
val errorCode = response.errorCode ?: defaultError

ios/AuthsignalPushModule.m

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ @interface RCT_EXTERN_MODULE(AuthsignalPushModule, NSObject)
1414
RCT_EXTERN_METHOD(addCredential:(NSString)token
1515
withRequireUserAuthentication:(BOOL)requireUserAuthentication
1616
withKeychainAccess:(NSString)keychainAccess
17+
withPerformAttestation:(BOOL)performAttestation
1718
resolve:(RCTPromiseResolveBlock)resolve
1819
reject:(RCTPromiseRejectBlock)reject)
1920

ios/AuthsignalPushModule.swift

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,23 +55,25 @@ class AuthsignalPushModule: NSObject {
5555
_ token: NSString?,
5656
withRequireUserAuthentication requireUserAuthentication: Bool,
5757
withKeychainAccess keychainAccess: NSString?,
58+
withPerformAttestation performAttestation: Bool,
5859
resolve: @escaping RCTPromiseResolveBlock,
5960
reject: @escaping RCTPromiseRejectBlock
6061
) -> Void {
6162
guard let authsignal = authsignal else {
6263
resolve(nil)
6364
return
6465
}
65-
66+
6667
let tokenStr = token as String?
6768
let requireAuthentication = requireUserAuthentication as Bool
6869
let keychainAccess = getKeychainAccess(value: keychainAccess as String?)
69-
70+
7071
Task.init {
7172
let response = await authsignal.addCredential(
7273
token: tokenStr,
7374
keychainAccess: keychainAccess,
74-
userPresenceRequired: requireAuthentication
75+
userPresenceRequired: requireAuthentication,
76+
performAttestation: performAttestation
7577
)
7678

7779
if let error = response.error {

ios/AuthsignalQRModule.m

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ @interface RCT_EXTERN_MODULE(AuthsignalQRCodeModule, NSObject)
1414
RCT_EXTERN_METHOD(addCredential:(NSString)token
1515
withRequireUserAuthentication:(BOOL)requireUserAuthentication
1616
withKeychainAccess:(NSString)keychainAccess
17+
withPerformAttestation:(BOOL)performAttestation
1718
resolve:(RCTPromiseResolveBlock)resolve
1819
reject:(RCTPromiseRejectBlock)reject)
1920

ios/AuthsignalQRModule.swift

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,23 +55,25 @@ class AuthsignalQRCodeModule: NSObject {
5555
_ token: NSString?,
5656
withRequireUserAuthentication requireUserAuthentication: Bool,
5757
withKeychainAccess keychainAccess: NSString?,
58+
withPerformAttestation performAttestation: Bool,
5859
resolve: @escaping RCTPromiseResolveBlock,
5960
reject: @escaping RCTPromiseRejectBlock
6061
) -> Void {
6162
guard let authsignal = authsignal else {
6263
resolve(nil)
6364
return
6465
}
65-
66+
6667
let tokenStr = token as String?
6768
let userPresenceRequired = requireUserAuthentication as Bool
6869
let keychainAccess = getKeychainAccess(value: keychainAccess as String?)
69-
70+
7071
Task.init {
7172
let response = await authsignal.addCredential(
7273
token: tokenStr,
7374
keychainAccess: keychainAccess,
74-
userPresenceRequired: userPresenceRequired
75+
userPresenceRequired: userPresenceRequired,
76+
performAttestation: performAttestation
7577
)
7678

7779
if let error = response.error {

src/NativeAuthsignalPushModule.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@ export interface Spec extends TurboModule {
66
addCredential(
77
token: string | null,
88
withRequireUserAuthentication: boolean,
9-
withKeychainAccess: string | null
9+
withKeychainAccess: string | null,
10+
withPerformAttestation: boolean
1011
): Promise<Object | null>;
1112
removeCredential(): Promise<boolean>;
1213
getChallenge(): Promise<Object | null>;

src/NativeAuthsignalQRCodeModule.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@ export interface Spec extends TurboModule {
66
addCredential(
77
token: string | null,
88
withRequireUserAuthentication: boolean,
9-
withKeychainAccess: string | null
9+
withKeychainAccess: string | null,
10+
withPerformAttestation: boolean
1011
): Promise<Object | null>;
1112
removeCredential(): Promise<boolean>;
1213
claimChallenge(challengeId: string): Promise<Object | null>;

src/push.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,14 +58,16 @@ export class AuthsignalPush {
5858
token,
5959
requireUserAuthentication = false,
6060
keychainAccess,
61+
performAttestation,
6162
}: AddCredentialInput = {}): Promise<AuthsignalResponse<AppCredential>> {
6263
await this.ensureModuleIsInitialized();
6364

6465
try {
6566
const data = (await AuthsignalPushModule.addCredential(
6667
token ?? null,
6768
requireUserAuthentication,
68-
keychainAccess ?? null
69+
keychainAccess ?? null,
70+
performAttestation ?? false
6971
)) as AppCredential;
7072

7173
return { data };

src/qr.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,14 +59,16 @@ export class AuthsignalQrCode {
5959
token,
6060
requireUserAuthentication = false,
6161
keychainAccess,
62+
performAttestation,
6263
}: AddCredentialInput = {}): Promise<AuthsignalResponse<AppCredential>> {
6364
await this.ensureModuleIsInitialized();
6465

6566
try {
6667
const data = (await AuthsignalQRCodeModule.addCredential(
6768
token ?? null,
6869
requireUserAuthentication,
69-
keychainAccess ?? null
70+
keychainAccess ?? null,
71+
performAttestation ?? false
7072
)) as AppCredential;
7173

7274
return { data };

0 commit comments

Comments
 (0)