StoreToken stores an encrypted access token and refresh token in the database. It returns the UUID of the stored token or an error if the operation fails. Parameters: - did: The decentralized identifier of the user. - accessToken: The access token to be encrypted and stored. - refreshToken: The ref
(did string, pds string, accessToken string, refreshToken string, encryptionKey string, accessExpiry float64, refreshExpiry float64)
| 151 | // - The UUID of the stored token. |
| 152 | // - An error if the operation fails. |
| 153 | func StoreToken(did string, pds string, accessToken string, refreshToken string, encryptionKey string, accessExpiry float64, refreshExpiry float64) (*string, error) { |
| 154 | // Check if token exists for this DID. |
| 155 | // Generate new UUID for new token |
| 156 | uuid, err := uuid.NewRandom() |
| 157 | if err != nil { |
| 158 | return nil, err |
| 159 | } |
| 160 | |
| 161 | // Update or create token |
| 162 | finalUUID, err := UpdateToken(uuid.String(), did, pds, accessToken, refreshToken, encryptionKey, accessExpiry, refreshExpiry, 2) |
| 163 | if err != nil { |
| 164 | return nil, err |
| 165 | } |
| 166 | |
| 167 | return finalUUID, nil |
| 168 | } |
| 169 | |
| 170 | func UpdateToken(uuid string, did string, pds string, accessToken string, refreshToken string, encryptionKey string, accessExpiry float64, refreshExpiry float64, tokenVersion int) (*string, error) { |
| 171 | encryptedAccess, err := authcrypt.Encrypt(accessToken, encryptionKey) |
no test coverage detected