feature: decode session credentials and save onto session instances

This commit is contained in:
Randall Morey committed 2021-06-23 16:36:05 -04:00
1 parent 28963a75cc
commit 33e6515749
4 files changed
+99 -2

No files matched your search

+36
View File
@@ -2,14 +2,46 @@ import GeneratedSessionModel from '../generated/models/session';
import { computed } from '@ember/object';
import { equal } from '@ember/object/computed';
import { tracked } from '@glimmer/tracking';
import { A } from '@ember/array';
class SessionCredential {
// =attributes
rawCredential;
credential_library_id;
credential_library_name;
credential_library_description;
credential_library_type;
purpose;
#secret;
get secret() {
return atob(this.#secret);
}
// =methods
constructor(cred) {
this.rawCredential = cred;
this.credential_library_id = cred.credential_library.id;
this.credential_library_name = cred.credential_library.name;
this.credential_library_description = cred.credential_library.description;
this.credential_library_type = cred.credential_library.type;
this.purpose = cred.purpose;
this.#secret = cred.secret;
}
}
export default class SessionModel extends GeneratedSessionModel {
// =attributes
// These transient attributes are used for values that come from the CLI
// `connect` command as triggered by Desktop. These attributes represent
// transient read-only values.
@tracked acknowledged;
@tracked started_desktop_client;
@tracked proxy_address;
@tracked proxy_port;
credentials = A();
@equal('status', 'active') isActive;
@equal('status', 'pending') isPending;
@@ -43,6 +75,10 @@ export default class SessionModel extends GeneratedSessionModel {
// =methods
addCredential(cred) {
this.credentials.pushObject(new SessionCredential(cred));
}
/**
* Cancels the session via the `cancel` method.
* See serializer and adapter for more information.