saveIdpClientSecret function

({bool success, String? warning}) saveIdpClientSecret(
  1. String issuer,
  2. String secret
)

Save IdP client secret to the keychain. Returns (success, warning) tuple.

Implementation

({bool success, String? warning}) saveIdpClientSecret(
  String issuer,
  String secret,
) {
  // In a full implementation this would use the platform keychain.
  // For now, store in a local secure file.
  try {
    final home =
        Platform.environment['HOME'] ??
        Platform.environment['USERPROFILE'] ??
        '';
    final secretDir = Directory(p.join(home, '.neomage', 'secrets'));
    secretDir.createSync(recursive: true);
    final secretFile = File(
      p.join(secretDir.path, '${issuerKey(issuer)}.secret'),
    );
    secretFile.writeAsStringSync(secret);
    return (success: true, warning: null);
  } catch (e) {
    return (success: false, warning: e.toString());
  }
}