Skip to content

Commit e6d2a44

Browse files
committed
https://tools.ietf.org/html/rfc7009#section-2.1 the client might includes its authentication credentials
1 parent 2f3d7f6 commit e6d2a44

File tree

3 files changed

+16
-4
lines changed

3 files changed

+16
-4
lines changed

index.js

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import invariant from 'invariant';
22
import { NativeModules, Platform } from 'react-native';
3+
import base64 from 'react-native-base64';
34

45
const { RNAppAuth } = NativeModules;
56

@@ -167,8 +168,8 @@ export const refresh = (
167168
};
168169

169170
export const revoke = async (
170-
{ clientId, issuer, serviceConfiguration },
171-
{ tokenToRevoke, sendClientId = false }
171+
{ clientId, issuer, serviceConfiguration, clientSecret },
172+
{ tokenToRevoke, sendClientId = false, includeBasicAuthorization = false }
172173
) => {
173174
invariant(tokenToRevoke, 'Please include the token to revoke');
174175
validateClientId(clientId);
@@ -188,7 +189,10 @@ export const revoke = async (
188189

189190
revocationEndpoint = openidConfig.revocation_endpoint;
190191
}
191-
192+
let basicAuth;
193+
if (includeBasicAuthorization) {
194+
basicAuth = base64.encode(`${clientId}:${clientSecret}`);
195+
}
192196
/**
193197
Identity Server insists on client_id being passed in the body,
194198
but Google does not. According to the spec, Google is right
@@ -199,6 +203,7 @@ export const revoke = async (
199203
method: 'POST',
200204
headers: {
201205
'Content-Type': 'application/x-www-form-urlencoded',
206+
Authorization: `${includeBasicAuthorization ? `basic ${basicAuth}` : ''}`,
202207
},
203208
body: `token=${tokenToRevoke}${sendClientId ? `&client_id=${clientId}` : ''}`,
204209
}).catch(error => {

package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,5 +72,7 @@
7272
"react": "^16.1.1",
7373
"react-native": "^0.50.3"
7474
},
75-
"dependencies": {}
75+
"dependencies": {
76+
"react-native-base64": "^0.0.2"
77+
}
7678
}

yarn.lock

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4113,6 +4113,11 @@ react-devtools-core@^2.5.0:
41134113
shell-quote "^1.6.1"
41144114
ws "^2.0.3"
41154115

4116+
react-native-base64@^0.0.2:
4117+
version "0.0.2"
4118+
resolved "https://registry.yarnpkg.com/react-native-base64/-/react-native-base64-0.0.2.tgz#c28463c2c6779ac3ec5fdd12979ebc8c5f9b410a"
4119+
integrity sha512-Fu/J1a2y0X22EJDWqJR2oEa1fpP4gTFjYxk8ElJdt1Yak3HOXmFJ7EohLVHU2DaQkgmKfw8qb7u/48gpzveRbg==
4120+
41164121
react-native@^0.50.3:
41174122
version "0.50.3"
41184123
resolved "https://registry.yarnpkg.com/react-native/-/react-native-0.50.3.tgz#91282bd5356cc7d794969cdc443cc764389b9af4"

0 commit comments

Comments
 (0)