normalizeKey function

List normalizeKey(
  1. Object key
)

Normalizes a polymorphic key input to parts.

Accepts:

Returns an unmodifiable, deep-copied List. This is the ONLY way QoraClient should process keys.

Throws ArgumentError if key type is invalid.

Implementation

List<dynamic> normalizeKey(Object key) {
  final List<dynamic> rawParts;

  // Extract raw parts based on input type
  if (key is QoraKey) {
    rawParts = key.parts;
  } else if (key is List) {
    rawParts = key;
  } else {
    throw ArgumentError(
      'Key must be QoraKey or List<dynamic>, got ${key.runtimeType}',
    );
  }

  // Validate and deep copy
  _validateKeyParts(rawParts);
  return List.unmodifiable(_deepCopy(rawParts) as Iterable);
}