The administration of Mayor Bill de Blasio — who has promised to shield New Yorkers from a threatened immigration crackdown by a Trump presidency — nevertheless plans to retain data submitted by cardholders of the city’s regardless-of-immigration-status municipal ID card, according to testimony Thursday.

De Blasio’s lawyers were on Staten Island trying to persuade a judge to let the city to destroy nearly two years of scanned copies of documents collected to establish applicants’ identity and city residency.

“We are keeping name, address, signature, photo,” Nisha Agarwal, commissioner of the mayor’s office of immigrant affairs, testified at the hearing. All information on the application will be retained, she said.

(Cardholder data would be disclosed only by judicial order, de Blasio spokeswoman Rosemary Boeglin said afterward.)

On Dec. 7 the city exercised its right under the legislation creating the program — called IDNYC — to stop retaining copies of the documents and to purge what had been collected since the program began in January 2015.

Two GOP assembly members from the borough have sued to challenge the mayor. The politicians, Nicole Malliotakis and Ron Castorina Jr., say that de Blasio has exceeded his legal authority, violated state open records laws, facilitated identity theft, and empowered terrorists who can use the card to open accounts at banks.

“American blood is at stake here,” said Castorina Jr., who said he is especially alarmed that the city accepts expired foreign passports as proof of identity.

But John Miller, the NYPD’s deputy commissioner for counterterrorism and intelligence, said that the cards benefit public safety.

“I hope every terrorist opens a bank account,” an action that generates reams of data, Miller said. Of 21 thwarted terrorist plots against New York City, he noted, none involved a terrorist cardholder.

Moreover, Miller testified, the cards bring New Yorkers out of the shadows to help interact with government agencies like the NYPD.

One estimate puts the number of New York City residents who are living in the country illegally as high as 1 million.

Of the nearly 1 million IDNYC cards issued so far, there had been four cards involved in identity-theft cases. He said that purging the underlying documents is also a way of guarding against hackers obtaining the documents to commit identity theft.

Philip Minardo, the case judge who temporarily ordered the city to preserve the documents, did not issue a ruling Thursday.

Castorina Jr. said he hopes to introduce legislation restricting how the ID cards could be used and banning some forms of proof to obtain the ID.

The cards also offer benefits like free museum admittance. Such benefits are meant to encourage all New York City residents to apply for the IDs, regardless of immigration status, to prevent the cards from being a scarlet letter.