Protect shortcodes, custom JS, and CSS from theme updates

I want my shortcodes and JS libraries to remain in place no matter if the theme updates, wordpress updates, or I change themes completely.

Normally the suitable place for such in WP would be a plugin or as variation of must use plugin.

More elaborate site might also use some other (generic PHP) methods, such as Composer packages.

Is there any way to protect/maintain changes to a theme’s header.php as well?

There is no way to “protect” a change to a template file. This should definitely be handled by a child theme — copy modified template to it and it will be picked over parent template.

If theme offers sufficient hooks it might be possible to inject logic with code, rather than making template changes. It depends.