(raw, options = {})
| 106 | } |
| 107 | |
| 108 | function normalizeIcloudAliasRecord(raw, options = {}) { |
| 109 | const usedEmails = toNormalizedEmailSet(options.usedEmails); |
| 110 | const preservedEmails = toNormalizedEmailSet(options.preservedEmails); |
| 111 | const anonymousId = String(raw?.anonymousId || raw?.id || '').trim(); |
| 112 | const email = String( |
| 113 | raw?.hme |
| 114 | || raw?.email |
| 115 | || raw?.alias |
| 116 | || raw?.address |
| 117 | || raw?.metaData?.hme |
| 118 | || '' |
| 119 | ).trim().toLowerCase(); |
| 120 | |
| 121 | if (!email || !email.includes('@')) return null; |
| 122 | |
| 123 | const label = String(raw?.label || raw?.metaData?.label || '').trim(); |
| 124 | const note = String(raw?.note || raw?.metaData?.note || '').trim(); |
| 125 | const state = String(raw?.state || raw?.status || '').trim().toLowerCase(); |
| 126 | const createdAt = raw?.createTimestamp |
| 127 | || raw?.createTime |
| 128 | || raw?.createdAt |
| 129 | || raw?.createdDate |
| 130 | || null; |
| 131 | |
| 132 | return { |
| 133 | anonymousId, |
| 134 | email, |
| 135 | label, |
| 136 | note, |
| 137 | state, |
| 138 | active: raw?.active !== false && raw?.isActive !== false && state !== 'inactive' && state !== 'deleted', |
| 139 | used: usedEmails.has(email), |
| 140 | preserved: preservedEmails.has(email), |
| 141 | createdAt, |
| 142 | }; |
| 143 | } |
| 144 | |
| 145 | function normalizeIcloudAliasList(response, options = {}) { |
| 146 | const aliases = findIcloudAliasArray(response); |
no test coverage detected