maintain static method

Future<void> maintain({
  1. required String clientId,
  2. required String clientSecret,
  3. required String redirectUri,
  4. String? deviceName,
  5. String? state,
  6. Directory? savedBridgesDir,
  7. String stateEncrypter(
    1. String plaintext
    )?,
  8. String tokenEncrypter(
    1. String plaintext
    )?,
  9. String tokenDecrypter(
    1. String ciphertext
    )?,
  10. String bridgeDecrypter(
    1. String ciphertext
    )?,
  11. bool reAuthOnFail = true,
})

This is the general method to maintain all of the data that is stored locally.

clientId Identifies the client that is making the request. The value passed in this parameter must exactly match the value you receive from hue.

clientSecret The client secret you have received from Hue when registering for the Hue Remote API.

redirectUri This parameter must exactly match the one configured in your hue developer account.

deviceName The device name should be the name of the app or device accessing the remote API. The deviceName is used in the user’s “My Apps” overview in the Hue Account (visualized as: “

state Provides any state that might be useful to your application upon receipt of the response. The Hue Authorization Server round-trips this parameter, so your application receives the same value it sent. To mitigate against cross-site request forgery (CSRF), a long (30+ digit), random number is prepended to state. When the response is received from Hue, it is recommended that you compare the string returned from this method, to the one that is returned from Hue.

savedBridgesDir The directory where the bridge data will be saved. If this is not provided, the default directory will be used.

stateEncrypter When the state value is stored locally, it is encrypted. This parameter allows you to provide your own encryption method. This will be used in addition to the default encryption method. This will be performed before the default encryption method.

tokenEncrypter When the token is stored locally, it is encrypted. This parameter allows you to provide your own encryption method. This will be used in addition to the default encryption method. This will be performed before the default encryption method.

tokenDecrypter When the old tokens are read from local storage, they are decrypted. This parameter allows you to provide your own decryption method. This will be used in addition to the default decryption method. This will be performed after the default decryption method.

bridgeDecrypter When the bridge data is read from local storage, it is decrypted. This parameter allows you to provide your own decryption method. This will be used in addition to the default decryption method. This will be performed after the default decryption method.

reAuthOnFail If this is set to true, then if the token is expired, then the user will be re-authenticated. If this is set to false, then the ReauthRequiredException will be thrown.

Implementation

static Future<void> maintain({
  required String clientId,
  required String clientSecret,
  required String redirectUri,
  String? deviceName,
  String? state,
  Directory? savedBridgesDir,
  String Function(String plaintext)? stateEncrypter,
  String Function(String plaintext)? tokenEncrypter,
  String Function(String ciphertext)? tokenDecrypter,
  String Function(String ciphertext)? bridgeDecrypter,
  bool reAuthOnFail = true,
}) async {
  await maintainToken(
    clientId: clientId,
    clientSecret: clientSecret,
    redirectUri: redirectUri,
    deviceName: deviceName,
    state: state,
    stateEncrypter: stateEncrypter,
    tokenEncrypter: tokenEncrypter,
    tokenDecrypter: tokenDecrypter,
    reAuthOnFail: reAuthOnFail,
  );

  await maintainBridges(
    savedBridgesDir: savedBridgesDir,
    decrypter: bridgeDecrypter,
  );
}