File tree 1 file changed +11
-2
lines changed
1 file changed +11
-2
lines changed Original file line number Diff line number Diff line change @@ -63,6 +63,15 @@ function randomNonce(length: number) {
63
63
return result ;
64
64
}
65
65
66
+ function sha256Hash ( input : string ) : string {
67
+ const sha256buffer = CC_SHA256 ( interop . handleof ( NSString . stringWithString ( input ) . UTF8String ) , input . length , interop . alloc ( input . length ) ) ;
68
+ let inputHashed = '' ;
69
+ for ( let i = 0 ; i < input . length ; i ++ ) {
70
+ inputHashed += parseInt ( sha256buffer [ i ] , 10 ) . toString ( 16 ) . padStart ( 2 , '0' ) ;
71
+ }
72
+ return inputHashed ;
73
+ }
74
+
66
75
export class SignIn {
67
76
static #controller: ASAuthorizationController ;
68
77
static #delegate: ASAuthorizationControllerDelegate ;
@@ -100,10 +109,10 @@ export class SignIn {
100
109
101
110
if ( options ?. useNonce ) {
102
111
if ( options . nonce ) {
103
- request . nonce = options . nonce ;
112
+ request . nonce = sha256Hash ( options . nonce ) ;
104
113
} else {
105
114
const nonce = randomNonce ( 32 ) ;
106
- request . nonce = nonce ;
115
+ request . nonce = sha256Hash ( nonce ) ;
107
116
( this . #delegate as any ) . _options . nonce = nonce ;
108
117
}
109
118
}
You can’t perform that action at this time.
0 commit comments