-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.js
130 lines (104 loc) · 2.53 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
const {
Authenticator,
UALError,
UALErrorType,
User
} = require('universal-authenticator-library')
const signatureResponse = {
wasBroadcast: true,
transactionId: 'transaction Id'
}
module.exports.VolentixUser = class VolentixUser extends User {
constructor(accountName, chains) {
super()
this.accountName = ''
this.chains = []
this.accountName = accountName
this.chains = chains
}
getKeys() {
return Promise.resolve([])
}
signTransaction(transaction, config) {
console.info('Requested signature config', config)
console.info('Requested signature for', transaction)
return Promise.resolve(signatureResponse)
}
getAccountName() {
return Promise.resolve(this.accountName)
}
getChainId() {
return Promise.resolve(this.chains[0].chainId)
}
signArbitrary(publicKey, data, helpText) {
return new Promise((resolve, reject) => {
reject(new UALError('Not implemented', UALErrorType.Signing, null, ' User'))
})
}
verifyKeyOwnership(_) {
return new Promise((resolve) => {
resolve(true)
})
}
}
module.exports.VolentixAuthenticator = class VolentixAuthenticator extends Authenticator {
constructor(chains) {
super(chains)
this.loading = true
}
getOnboardingLink() {
return 'https://localhost'
}
getStyle() {
return {
icon: '',
textColor: 'white',
background: 'blue',
text: ' Auths'
}
}
shouldRender() {
return true
}
shouldAutoLogin() {
return false
}
login(accountName) {
// alert('Login Authenticator Triggered')
console.info('Attempted login with ', accountName)
// Simulate login delay response
// return new Promise<[User]>((resolve) => {
// setTimeout(() => {
// resolve([new User(accountName || '', this.chains)])
// }, 4000)
// })
// return Promise.reject(new UALError('it broke', UALErrorType.Login, null, ' Authenticator'))
// Login without a delay response
return Promise.resolve([new User(accountName || '', this.chains)])
}
shouldRequestAccountName() {
return Promise.resolve(true)
}
logout() {
console.info('Logging out')
return Promise.resolve()
}
async init() {
this.loading = false
}
isLoading() {
return this.loading
}
isErrored() {
return false
}
getError() {
return new UALError('Initialization Error', UALErrorType.Initialization, null, 'this guy')
}
reset() {
console.info('resetting authenticator')
}
requiresGetKeyConfirmation() {
return false
}
}