@sap/xssec
Version:
XS Advanced Container Security API for node.js
63 lines (47 loc) • 1.26 kB
JavaScript
const Token = require("./Token");
class XsuaaToken extends Token {
get azAttributes() {
return this.payload.az_attr;
}
get extAttributes() {
return this.payload.ext_attr;
}
get logonName() {
return this.payload.user_name;
}
get scopes() {
return this.payload.scope ?? [];
}
get serviceInstanceId() {
return this.payload.ext_attr?.serviceinstanceid;
}
get subAccountId() {
return this.payload.ext_attr?.subaccountid || this.zid;
}
get userId() {
return super.userId || this.payload.sub;
}
get xsUserAttributes() {
return this.payload.ext_cxt?.['xs.user.attributes'] ?? this.payload['xs.user.attributes'];
}
get xsSystemAttributes() {
return this.payload.ext_cxt?.['xs.system.attributes'] ?? this.payload['xs.system.attributes'];
}
get zid() {
return this.payload.zid;
}
getXsUserAttribute(name) {
return this.xsUserAttributes?.[name];
}
// Methods for backward-compatibility
getAppTID() {
return this.zid;
}
getCustomIssuer() {
return this.issuer;
}
getZoneId() {
return this.zid;
}
}
module.exports = XsuaaToken;