lodash-es#isNil TypeScript Examples
The following examples show how to use
lodash-es#isNil.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: BaseNodeModel.ts From LogicFlow with Apache License 2.0 | 6 votes |
getAnchorInfo(anchorId: string) {
if (isNil(anchorId)) return;
for (let i = 0; i < this.anchors.length; i++) {
const anchor = this.anchors[i];
if (anchor.id === anchorId) {
return anchor;
}
}
}
Example #2
Source File: credentialaccessrequest.ts From Elastos.Essentials.App with MIT License | 6 votes |
/**
* Check if self proclaimed credentials are accepted
*/
acceptsSelfProclaimedCredentials(iss: any): boolean {
let response = true
if (!isNil(iss) && iss instanceof Object) {
response = iss["selfproclaimed"];
}
Logger.log('Identity', "acceptsSelfProclaimedCredentials", iss, response)
return response;
}
Example #3
Source File: credentialaccessrequest.ts From Elastos.Essentials.App with MIT License | 6 votes |
/**
* Check if credential issuer match with requested
*/
acceptsIssuer(iss: any, issuerDid: string): boolean {
Logger.log('Identity', "acceptsIssuer", iss, issuerDid)
if (isNil(iss)) return true;
let issuersAccepted: string[] = iss["did"] || []
return issuersAccepted.includes(issuerDid);
}
Example #4
Source File: requestcredentials.ts From Elastos.Essentials.App with MIT License | 6 votes |
/**
* NOTE: For now we assume that the credential name (fragment) is the same as the requested claim value.
* But this may not be true in the future: we would have to search inside credential properties one by one.
*/
/* getBasicProfileCredentialValue(credential: DIDPlugin.VerifiableCredential): any {
return credential.getSubject()[credential.getFragment()];
} */
/**
* Check if self proclaimed credentials are accepted
*/
acceptsSelfProclaimedCredentials(iss: any): boolean {
let response = true
if (!isNil(iss) && iss instanceof Object) {
response = iss["selfproclaimed"];
}
Logger.log('Identity', "acceptsSelfProclaimedCredentials", iss, response)
return response;
}
Example #5
Source File: requestcredentials.ts From Elastos.Essentials.App with MIT License | 6 votes |
/**
* Check if credential issuer match with requested
*/
acceptsIssuer(iss: any, issuerDid: string): boolean {
Logger.log('Identity', "acceptsIssuer", iss, issuerDid)
if (isNil(iss)) return true;
let issuersAccepted: string[] = iss["did"] || []
return issuersAccepted.includes(issuerDid);
}
Example #6
Source File: background.service.ts From Elastos.Essentials.App with MIT License | 6 votes |
private isExpirationAlreadyVerifiedToday(): Promise<boolean> {
return new Promise<boolean>((resolve, reject) => {
Logger.log("Identity", "Verify if expiration was already checked today");
this.localStorage.get(this.EXPIRATION_STORAGE_KEY).then(storedChecked => {
// Verify if was checked today
if (!isNil(storedChecked)) {
let lastCheckDate = moment(storedChecked.last_check, "YYYY-MM-DD");
resolve(moment({}).isSame(lastCheckDate, 'day'));
} else {
resolve(false)
}
}).catch(err => {
resolve(false)
})
});
}
Example #7
Source File: expiration.service.ts From Elastos.Essentials.App with MIT License | 6 votes |
public async verifyIssuerDIDExpiration(did: string, credential: DIDPlugin.VerifiableCredential, maxDaysToExpire: number): Promise<ExpiredItem> {
let issuerDID: string = credential.getIssuer();
if (isNil(issuerDID) || issuerDID === "" || issuerDID === did) return null
// Get issuer's DID document
let issuerDocument: DIDDocument = (await this.didDocumentsService.fetchOrAwaitDIDDocumentWithStatus(issuerDID)).document;
if (!issuerDocument) {
// For now, we don't handle this case. Consider the credential as OK.
// It is possible that the issuer did not publish his DID (which is useless but could happen).
return null;
}
// Verify if issuer's DID is about to expire
let daysToIssuerDIDExpire: number = this.daysToExpire(issuerDocument.getExpires())
Logger.log("identity", `Days to validator DID for ${this.getCredentialID(did, credential)} credential expire in `, daysToIssuerDIDExpire)
let issuerExpiredMessage: string = this.constructIssuerMessage(`The validator DID for ${this.getCredentialID(did, credential)} credential`, daysToIssuerDIDExpire);
// Add new expired item response for this issuer DID
return {
id: `${did}_${this.getCredentialID(did, credential)}_${issuerDID}}`,
did: issuerDID,
message: issuerExpiredMessage,
daysToExpire: daysToIssuerDIDExpire
}
}
Example #8
Source File: credentialdetails.page.ts From Elastos.Essentials.App with MIT License | 5 votes |
prepareCredential() {
Logger.log("identity", "Computing credential status");
this.iconLoaded = false;
this.credential = null;
this.segment = "validator";
// Issuer icon placeholder while fetching the real icon
this.issuerIcon = this.theme.darkMode ? 'assets/launcher/default/default-avatar.svg' : 'assets/launcher/default/darkmode/default-avatar.svg';
if (isNil(this.credentialId) || isNil(this.credentials) || this.credentials.length <= 0)
return;
let selected = this.credentials.filter(
(item) => item.pluginVerifiableCredential.getId() == this.credentialId
);
if (selected.length > 0)
this.credential = selected[0];
if (this.credential == null)
return;
this.checkIsCredentialInPublishedDIDDocument();
this.checkIsCredentialInLocalDIDDocument();
void this.globalCredentialTypesService.verifyCredential(this.credential.pluginVerifiableCredential).then(isFullyConform => {
this.conformityChecked = true;
this.isConform = isFullyConform;
});
// Prepare the credential for display
this.credential.onIconReady(iconSrc => {
this.zone.run(() => {
this.iconSrc = iconSrc;
this.iconLoaded = true;
})
});
this.credential.prepareForDisplay();
void this.didDocumentsService.fetchOrAwaitDIDDocumentWithStatus(this.credential.pluginVerifiableCredential.getIssuer()).then(issuerDocumentStatus => {
if (issuerDocumentStatus.checked && issuerDocumentStatus.document) {
// Issuer document fetched and non null: store it and
this.issuerDidDocument = issuerDocumentStatus.document;
// Get the issuer icon
let representativeIconSubject = this.didDocumentsService.getRepresentativeIcon(this.issuerDidDocument);
if (representativeIconSubject) {
// eslint-disable-next-line @typescript-eslint/no-misused-promises
representativeIconSubject.subscribe(async iconBuffer => {
if (iconBuffer) {
this.issuerIcon = await rawImageToBase64DataUrl(iconBuffer);
}
});
}
else {
// No icon in the document
}
// Get the issuer name
this.issuerName = this.didDocumentsService.getRepresentativeOwnerName(this.issuerDidDocument);
// Issuer DID for display
this.issuerDid = reducedDidString(this.issuerDidDocument.pluginDidDocument.getSubject().getDIDString());
}
});
//await this.isLocalCredSyncOnChain();
this.hasCheckedCredential = true;
}