@@ -62,10 +62,26 @@ export function getTenantId(
6262 return decodedJwt . zid || decodedJwt . app_tid || undefined ;
6363}
6464
65+ /**
66+ * Check if the given JWT is not an IAS token.
67+ * Currently, there are only two domains for IAS tokens:
68+ * `accounts.ondemand.com` and `accounts400.onemand.com`.
69+ * @param decodedJwt - The decoded JWT to check.
70+ * @returns Whether the given JWT is not an IAS token.
71+ */
72+ function isNotIasToken ( decodedJwt : JwtPayload ) : boolean {
73+ return (
74+ ! decodedJwt . iss ?. includes ( 'accounts.ondemand.com' ) &&
75+ ! decodedJwt . iss ?. includes ( 'accounts400.ondemand.com' )
76+ ) ;
77+ }
78+
6579/**
6680 * @internal
67- * Retrieve the subdomain from the decoded XSUAA JWT. If the JWT is not in XSUAA format, returns `undefined`.
68- * @param jwt - JWT to retrieve the subdomain from.
81+ * Retrieve the subdomain from the decoded XSUAA JWT or ISS object.
82+ * If it is an IAS JWT, or the passed object doesn't contain an ISS propety,
83+ * returns `undefined`.
84+ * @param jwt - JWT or ISS object to retrieve the subdomain from.
6985 * @returns The subdomain, if available.
7086 */
7187export function getSubdomain (
@@ -74,7 +90,7 @@ export function getSubdomain(
7490 const decodedJwt = jwt ? decodeJwt ( jwt ) : { } ;
7591 return (
7692 decodedJwt ?. ext_attr ?. zdn ||
77- ( isXsuaaToken ( decodedJwt ) ? getIssuerSubdomain ( decodedJwt ) : undefined )
93+ ( isNotIasToken ( decodedJwt ) ? getIssuerSubdomain ( decodedJwt ) : undefined )
7894 ) ;
7995}
8096
0 commit comments