@onairosofficial/onairos-capacitor 0.1.3 → 0.1.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (95) hide show
  1. package/OnairosofficialOnairosCapacitor.podspec +1 -1
  2. package/README.md +1 -1
  3. package/dist/onairos.capacitor.esm.js +509 -1
  4. package/dist/onairos.capacitor.esm.turbopack.js +509 -1
  5. package/ios/Sources/OnairosNativeConnectorsPlugin/OnairosChatGPTNativePlugin.swift +187 -945
  6. package/ios/Sources/OnairosNativeConnectorsPlugin/OnairosRNScrapers.swift +1800 -0
  7. package/ios/Sources/OnairosNativeConnectorsPlugin/OnairosSpotifyNativePlugin.swift +180 -629
  8. package/onairos.d.ts +24 -0
  9. package/package.json +5 -2
  10. package/src/assets/connectors/Linkedinicon.png +0 -0
  11. package/src/assets/connectors/Redditicon.png +0 -0
  12. package/src/assets/connectors/YouTubeicon2.png +0 -0
  13. package/src/assets/connectors/chatgpt.png +0 -0
  14. package/src/assets/connectors/claude.png +0 -0
  15. package/src/assets/connectors/instagram.png +0 -0
  16. package/src/assets/connectors/netflix.png +0 -0
  17. package/src/assets/connectors/pinterest.png +0 -0
  18. package/src/assets/connectors/sephora.png +0 -0
  19. package/src/assets/connectors/spotify.png +0 -0
  20. package/src/assets/connectors/tiktok.png +0 -0
  21. package/src/assets/permissions/onairos.png +0 -0
  22. package/src/assets/permissions/personalization.png +0 -0
  23. package/src/assets/permissions/public-profile-person.png +0 -0
  24. package/src/assets/permissions/raw-memories.png +0 -0
  25. package/src/capacitorConnectorCatalog.js +2 -6
  26. package/src/components/DataRequest.jsx +96 -532
  27. package/src/components/EmailAuth.jsx +4 -116
  28. package/src/components/PinSetup.jsx +39 -226
  29. package/src/components/SDKDesignPreview.jsx +33 -0
  30. package/src/components/SessionUserBar.jsx +2 -1
  31. package/src/components/TrainingScreen.jsx +18 -12
  32. package/src/components/UniversalOnboarding.jsx +191 -424
  33. package/src/components/WelcomeScreen.jsx +19 -12
  34. package/src/components/parity/NativeConnections.jsx +136 -0
  35. package/src/components/parity/NativeScreens.jsx +48 -0
  36. package/src/components/ui/PageLayout.jsx +7 -3
  37. package/src/nativeImport/ConnectorLoading.jsx +13 -0
  38. package/src/nativeImport/CustomImportSession.js +115 -0
  39. package/src/nativeImport/ImportIcon.jsx +29 -0
  40. package/src/nativeImport/ImportProgress.jsx +24 -0
  41. package/src/nativeImport/ImportStatus.jsx +9 -0
  42. package/src/nativeImport/NativeChatImport.jsx +28 -0
  43. package/src/nativeImport/NativeImportSession.js +123 -0
  44. package/src/nativeImport/NativeScraperImport.jsx +57 -0
  45. package/src/nativeImport/SmartFilter.jsx +28 -0
  46. package/src/nativeImport/customPayload.js +37 -0
  47. package/src/nativeImport/netflixExport.js +30 -0
  48. package/src/nativeImport/netflixHistory.js +28 -0
  49. package/src/nativeImport/netflixSession.js +59 -0
  50. package/src/nativeImport/rawHandoff.js +7 -0
  51. package/src/nativeImport/rn/config/api.js +5 -0
  52. package/src/nativeImport/rn/services/apiKeyService.js +2 -0
  53. package/src/nativeImport/rn/services/hingePayload.js +37 -0
  54. package/src/nativeImport/rn/services/nativeConversationImport.js +138 -0
  55. package/src/nativeImport/rn/services/nativeFileTransfer.js +127 -0
  56. package/src/nativeImport/rn/services/nativeRawRedaction.js +136 -0
  57. package/src/nativeImport/rn/services/netflixPayload.js +70 -0
  58. package/src/nativeImport/rn/services/rawMemoryPolicy.js +38 -0
  59. package/src/nativeImport/rn/services/sephoraPayload.js +166 -0
  60. package/src/nativeImport/rn/services/spotifyPayload.js +99 -0
  61. package/src/nativeImport/rn/source-manifest.json +45 -0
  62. package/src/nativeImport/rn/utils/importedFiles.js +74 -0
  63. package/src/nativeImport/rn/utils/nativeImportDates.js +45 -0
  64. package/src/nativeImport/rn/utils/nativeImportFileReceiver.js +51 -0
  65. package/src/nativeImport/rn/utils/nativeImportMetadata.js +74 -0
  66. package/src/nativeImport/rn/utils/nativeImportTopics.js +56 -0
  67. package/src/nativeImport/rn/utils/rawExportDelivery.js +12 -0
  68. package/src/nativeImport/rn/utils/webviewScripts/chatgptDiscovery.js +99 -0
  69. package/src/nativeImport/rn/utils/webviewScripts/claude.js +349 -0
  70. package/src/nativeImport/rn/utils/webviewScripts/gemini.js +356 -0
  71. package/src/nativeImport/rn/utils/webviewScripts/hinge.js +375 -0
  72. package/src/nativeImport/rn/utils/webviewScripts/instagram.js +152 -0
  73. package/src/nativeImport/rn/utils/webviewScripts/linkedin.js +825 -0
  74. package/src/nativeImport/rn/utils/webviewScripts/nativeChatGPTImport.js +202 -0
  75. package/src/nativeImport/rn/utils/webviewScripts/nativeChatGPTSession.js +63 -0
  76. package/src/nativeImport/rn/utils/webviewScripts/nativeImportFiles.js +132 -0
  77. package/src/nativeImport/rn/utils/webviewScripts/nativeImportProviders.js +80 -0
  78. package/src/nativeImport/rn/utils/webviewScripts/nativeLoginViewport.js +28 -0
  79. package/src/nativeImport/rn/utils/webviewScripts/netflix.js +257 -0
  80. package/src/nativeImport/rn/utils/webviewScripts/sephora.js +862 -0
  81. package/src/nativeImport/rn/utils/webviewScripts/sephoraSession.js +160 -0
  82. package/src/nativeImport/rn/utils/webviewScripts/spotify.js +1868 -0
  83. package/src/nativeImport/rn/utils/webviewScripts/telegram.js +630 -0
  84. package/src/nativeImport/rn/utils/webviewScripts/tiktok.js +2920 -0
  85. package/src/onairos.capacitor.jsx +14 -2
  86. package/src/onairos.core.jsx +3 -0
  87. package/src/onairosButton.jsx +23 -17
  88. package/src/styles/onairos-fonts.css +20 -0
  89. package/src/styles/onairos-native.css +709 -0
  90. package/src/styles/onairos-rn-parity.css +175 -0
  91. package/src/styles/sdkCssRegistry.js +83 -1
  92. package/src/styles/tailwind.capacitor.css +6 -0
  93. package/src/utils/capacitorPlugins.js +20 -12
  94. package/src/utils/nativeConnectorSession.js +18 -0
  95. package/src/utils/parityPolicy.js +41 -0
@@ -0,0 +1,202 @@
1
+ // Synced from RN utils/webviewScripts/nativeChatGPTImport.ts by scripts/sync-rn-connectors.cjs.
2
+ import { importTimestamp } from "../nativeImportDates.js";
3
+ import { isNativeImportOrigin, NATIVE_IMPORT_PROVIDERS } from "./nativeImportProviders.js";
4
+ import { NATIVE_IMPORT_FILES_SCRIPT, NATIVE_FILE_BRIDGE_SCRIPT } from "./nativeImportFiles.js";
5
+ import { base64ByteLength, utf8ByteLength, IMPORTED_FILE_MAX_BYTES, IMPORTED_FILE_PREVIEW_BYTES, IMPORTED_FILE_CHUNK_BYTES } from "../importedFiles.js";
6
+ import { NATIVE_METADATA_SCRIPT, sanitizeNativeMetadata } from "../nativeImportMetadata.js";
7
+ const NATIVE_IMPORT_LIMIT = 100;
8
+ function parseNativeImportMessage(raw, origin, requestId, platform = "chatgpt") {
9
+ if (!requestId || !isNativeImportOrigin(origin, platform) || raw.length > 4e6) return null;
10
+ try {
11
+ const data = JSON.parse(raw);
12
+ if (data.channel !== "onairos-native-import" || data.requestId !== requestId) return null;
13
+ if (["file_start", "file_chunk", "file_end"].includes(data.type) && validId(data.conversationId) && Number.isInteger(data.sequence) && data.sequence > 0) {
14
+ if (data.type === "file_start") {
15
+ const f = data.file;
16
+ if (!f || typeof f.id !== "string" || f.id.length > 128 || typeof f.name !== "string" || !f.name || f.name.length > 300 || typeof f.mimeType !== "string" || f.mimeType.length > 200 || !Number.isInteger(f.sizeBytes) || f.sizeBytes < 0 || f.sizeBytes > 26214400 || f.messageId !== void 0 && (typeof f.messageId !== "string" || f.messageId.length > 128)) return null;
17
+ }
18
+ if (data.type === "file_chunk" && (!Number.isInteger(data.index) || data.index < 0 || typeof data.data !== "string" || !data.data.length || data.data.length > 262144 || !/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/.test(data.data))) return null;
19
+ return { type: data.type, sequence: data.sequence, conversationId: data.conversationId, file: data.type === "file_start" ? { id: data.file.id, name: data.file.name, mimeType: data.file.mimeType, sizeBytes: data.file.sizeBytes, messageId: data.file.messageId, extracted: data.file.extracted === true } : void 0, index: data.index, data: data.data };
20
+ }
21
+ if (data.type === "titles") {
22
+ if (!Array.isArray(data.items) || data.items.length > NATIVE_IMPORT_LIMIT) return null;
23
+ if (!data.items.every((item) => validId(item?.id) && typeof item.title === "string" && item.title.length <= 500)) return null;
24
+ return { type: "titles", items: [...new Map(data.items.map((item) => [item.id, {
25
+ id: item.id,
26
+ title: item.title,
27
+ ...importTimestamp(item.createdAt) !== void 0 ? { createdAt: item.createdAt } : {},
28
+ ...importTimestamp(item.updatedAt) !== void 0 ? { updatedAt: item.updatedAt } : {}
29
+ }])).values()] };
30
+ }
31
+ if (data.type === "conversation") {
32
+ const c = data.conversation;
33
+ if (!validId(c?.conversationId) || typeof c.title !== "string" || c.title.length > 500 || !Array.isArray(c.messages) || c.messages.length > 1e4 || !c.messages.every((m) => typeof m?.id === "string" && m.id.length <= 128 && ["user", "assistant"].includes(m.role) && typeof m.content === "string" && m.content.length <= 1e6 && (m.timestamp === void 0 || typeof m.timestamp === "number"))) return null;
34
+ return { type: "conversation", conversation: {
35
+ conversationId: c.conversationId,
36
+ title: c.title,
37
+ platform,
38
+ ...importDetails(c),
39
+ messages: c.messages.map((m) => ({ id: m.id, role: m.role, content: m.content, ...importDetails(m), ...m.timestamp !== void 0 ? { timestamp: m.timestamp } : {} }))
40
+ } };
41
+ }
42
+ if (data.type === "file_chunk" && validId(data.transferId) && Number.isInteger(data.index) && data.index >= 0 && data.index < 140 && typeof data.data === "string" && data.data.length <= IMPORTED_FILE_CHUNK_BYTES / 3 * 4 && base64ByteLength(data.data) > 0) {
43
+ return { type: "file_chunk", transferId: data.transferId, index: data.index, data: data.data };
44
+ }
45
+ if (data.type === "file_end" && validId(data.transferId)) return { type: "file_end", transferId: data.transferId };
46
+ if ((data.type === "file" || data.type === "file_start") && validId(data.conversationId)) {
47
+ const f = data.file;
48
+ if (!f || typeof f.id !== "string" || f.id.length > 128 || typeof f.name !== "string" || f.name.length > 300 || !["imported", "unavailable", "too_large", "limit_reached"].includes(f.status)) return null;
49
+ if (data.type === "file_start") {
50
+ if (!validId(data.transferId) || f.status !== "imported" || f.encoding !== "base64" || !Number.isInteger(f.sizeBytes) || f.sizeBytes < 0 || f.sizeBytes > IMPORTED_FILE_MAX_BYTES || typeof f.mimeType !== "string" || f.mimeType.length > 200) return null;
51
+ return { type: "file_start", conversationId: data.conversationId, transferId: data.transferId, file: { id: f.id, name: f.name, status: "imported", encoding: "base64", sizeBytes: f.sizeBytes, mimeType: f.mimeType, extracted: f.extracted === true } };
52
+ }
53
+ if (f.status !== "imported") return { type: "file", conversationId: data.conversationId, file: { id: f.id, name: f.name, status: f.status } };
54
+ if (!["text", "base64"].includes(f.encoding) || typeof f.data !== "string" || f.data.length > 14e5 || !Number.isInteger(f.sizeBytes) || f.sizeBytes < 0 || f.sizeBytes > IMPORTED_FILE_PREVIEW_BYTES || typeof f.mimeType !== "string" || f.mimeType.length > 200) return null;
55
+ if ((f.encoding === "base64" ? base64ByteLength(f.data) : utf8ByteLength(f.data)) !== f.sizeBytes) return null;
56
+ return { type: "file", conversationId: data.conversationId, file: { id: f.id, name: f.name, status: "imported", encoding: f.encoding, data: f.data, sizeBytes: f.sizeBytes, mimeType: f.mimeType, extracted: f.extracted === true } };
57
+ }
58
+ if (data.type === "progress" && Number.isInteger(data.completed) && Number.isInteger(data.total) && data.completed >= 0 && data.completed <= data.total && data.total <= NATIVE_IMPORT_LIMIT) return { type: "progress", completed: data.completed, total: data.total };
59
+ if (data.type === "item" && validId(data.id) && ["importing", "done", "empty"].includes(data.status)) return { type: "item", id: data.id, status: data.status };
60
+ if (data.type === "cooldown" && Number.isFinite(data.retryAt) && data.retryAt > 0) return { type: "cooldown", retryAt: data.retryAt };
61
+ if (data.type === "complete") return { type: "complete" };
62
+ if (data.type === "error") return { type: "error", code: ["sign_in", "timeout", "network", "rate_limited", "provider_error", "invalid_response", "conversation_unavailable"].includes(data.code) ? data.code : "unavailable" };
63
+ } catch {
64
+ }
65
+ return null;
66
+ }
67
+ function importDetails(value) {
68
+ const result = {};
69
+ for (const key of ["modelSlug", "prevMessageId", "contentType", "channel", "recipient", "status"]) if (typeof value[key] === "string" && value[key].length <= 256) result[key] = value[key];
70
+ for (const key of ["createdAt", "updatedAt"]) if (typeof value[key] === "number" && Number.isFinite(value[key]) || typeof value[key] === "string" && value[key].length <= 64) result[key] = value[key];
71
+ const metadata = sanitizeNativeMetadata(value.metadata);
72
+ if (metadata) result.metadata = metadata;
73
+ return result;
74
+ }
75
+ const validId = (value) => typeof value === "string" && /^[a-zA-Z0-9-]{1,128}$/.test(value);
76
+ const CANCEL_NATIVE_IMPORT = `(function(){if((location.origin==='https://chatgpt.com'||location.origin==='https://claude.ai') && window.__onairosNativeImport){window.__onairosNativeImport.abort();delete window.__onairosNativeImport;}})();true;`;
77
+ function createNativeImportScript(requestId, selected, options = {}) {
78
+ const platform = options.platform || "chatgpt";
79
+ const provider = NATIVE_IMPORT_PROVIDERS[platform];
80
+ if (selected && (selected.length > NATIVE_IMPORT_LIMIT || selected.some((item) => !validId(item.id)))) throw new Error("Invalid import selection");
81
+ return `
82
+ (function(){
83
+ if(location.origin !== ${JSON.stringify(provider.origin)} || window.top !== window.self) return;
84
+ if(window.__onairosNativeImport) window.__onairosNativeImport.abort();
85
+ var controller = new AbortController(); window.__onairosNativeImport = controller;
86
+ var token = null, timedOut = false,orgId=null;
87
+ var importRequestId=${JSON.stringify(requestId)};
88
+ var platform=${JSON.stringify(platform)},includeFiles=${options.includeFiles === true};
89
+ var timer = setTimeout(function(){timedOut=true;controller.abort();}, ${selected ? options.includeFiles ? 9e5 : Math.min(9e5, Math.max(12e4, selected.length * 22e3)) : 25e3});
90
+ var requestId=importRequestId;
91
+ function send(value){if(JSON.stringify(value).length>3900000)throw new Error('unavailable');if(window.__onairosNativeImport===controller && (!controller.signal.aborted || timedOut)) window.ReactNativeWebView.postMessage(JSON.stringify(Object.assign({channel:'onairos-native-import',requestId:${JSON.stringify(requestId)}},value)));}
92
+ var cooldownUntil=0;
93
+ function wait(ms){return new Promise(function(resolve,reject){
94
+ var onAbort=function(){clearTimeout(timeout);reject(new Error('cancelled'));};
95
+ var timeout=setTimeout(function(){controller.signal.removeEventListener('abort',onAbort);resolve();},ms);
96
+ controller.signal.addEventListener('abort',onAbort,{once:true});
97
+ if(controller.signal.aborted)onAbort();
98
+ });}
99
+ async function read(path, authenticated){
100
+ for(var attempt=0;attempt<2;attempt++){
101
+ if(controller.signal.aborted)throw new Error('cancelled');
102
+ if(cooldownUntil>Date.now())await wait(cooldownUntil-Date.now());
103
+ var local=new AbortController();
104
+ var abort=function(){local.abort();};controller.signal.addEventListener('abort',abort,{once:true});
105
+ var requestTimer=setTimeout(function(){local.abort();},20000);
106
+ try{
107
+ var response=await fetch(path,{credentials:'include',redirect:'error',signal:local.signal,headers:authenticated?{Accept:'application/json',Authorization:'Bearer '+token}:{Accept:'application/json'}});
108
+ if(response.status===429 && attempt===0){
109
+ var retry=response.headers.get('Retry-After'), seconds=Number(retry);
110
+ var delay=retry && Number.isFinite(seconds)?seconds*1000:Math.max(0,Date.parse(retry)-Date.now())||2000;
111
+ if(delay>30000)throw new Error('rate_limited');
112
+ cooldownUntil=Math.max(cooldownUntil,Date.now()+Math.max(1000,delay));
113
+ send({type:'cooldown',retryAt:cooldownUntil});continue;
114
+ }
115
+ if(response.status>=500 && response.status<=599 && attempt===0){await wait(1000);continue;}
116
+ if(!response.ok)throw new Error(response.status===401 || response.status===403?'sign_in':response.status===429?'rate_limited':response.status===404?'conversation_unavailable':'provider_error');
117
+ try{return await response.json();}catch(parseError){if(local.signal.aborted)throw parseError;throw new Error('invalid_response');}
118
+ }catch(error){if(local.signal.aborted && !controller.signal.aborted)throw new Error('timeout');if(error.name==='TypeError')throw new Error('network');throw error;}
119
+ finally{clearTimeout(requestTimer);controller.signal.removeEventListener('abort',abort);}
120
+ }
121
+ }
122
+ ${NATIVE_METADATA_SCRIPT}
123
+ ${options.includeFiles ? NATIVE_IMPORT_FILES_SCRIPT + (options.fileDelivery === "temporary" ? NATIVE_FILE_BRIDGE_SCRIPT : "") : ""}
124
+ (async function(){try{
125
+ if(platform==='claude'){
126
+ var orgPayload=await read('/api/organizations',false),orgs=Array.isArray(orgPayload)?orgPayload:orgPayload.organizations||[];
127
+ var activeOrg=(document.cookie.match(/(?:^|; )lastActiveOrg=([^;]+)/)||[])[1];
128
+ var org=orgs.find(function(o){return (o.uuid||o.id)===activeOrg;})||orgs[0];orgId=org&&(org.uuid||org.id);orgPayload=null;orgs=null;
129
+ if(!orgId)throw new Error('sign_in');
130
+ }else{
131
+ var session=await read('/api/auth/session',false);token=session.accessToken;session=null;
132
+ if(typeof token!=='string' || !token) throw new Error('sign_in');
133
+ }
134
+ var selected=${JSON.stringify(selected ?? null)};
135
+ if(selected===null){
136
+ var items=[],seen={};
137
+ var pageSize=platform==='claude'?30:50;
138
+ for(var offset=0;offset<${NATIVE_IMPORT_LIMIT};offset+=pageSize){
139
+ var list=await read(platform==='claude'?'/api/organizations/'+encodeURIComponent(orgId)+'/chat_conversations?offset='+offset+'&limit='+pageSize:'/backend-api/conversations?offset='+offset+'&limit='+pageSize+'&order=updated',platform==='chatgpt');
140
+ if(platform==='claude')list={items:(Array.isArray(list)?list:list.chat_conversations||list.conversations||list.items||[]).map(function(c){return {id:c.uuid||c.id,title:c.name||c.title,create_time:c.created_at,update_time:c.updated_at};})};
141
+ if(!Array.isArray(list.items)) throw new Error('unavailable');
142
+ list.items.forEach(function(item){if(typeof item.id==='string' && /^[a-zA-Z0-9-]{1,128}$/.test(item.id) && !seen[item.id]){seen[item.id]=true;var preview={id:item.id,title:String(item.title||'Untitled conversation').slice(0,500)};[['createdAt',item.create_time],['updatedAt',item.update_time]].forEach(function(pair){if(typeof pair[1]==='number'||(typeof pair[1]==='string'&&pair[1].length<=64))preview[pair[0]]=pair[1];});items.push(preview);}});
143
+ if(list.items.length<pageSize || (typeof list.total==='number' && offset+pageSize>=list.total))break;
144
+ }
145
+ send({type:'titles',items:items.slice(0,${NATIVE_IMPORT_LIMIT})});return;
146
+ }
147
+ var next=0,completed=0;
148
+ async function worker(){while(next<selected.length && !controller.signal.aborted){
149
+ var item=selected[next++];
150
+ send({type:'item',id:item.id,status:'importing'});
151
+ var detail=await read(platform==='claude'?'/api/organizations/'+encodeURIComponent(orgId)+'/chat_conversations/'+encodeURIComponent(item.id)+'?tree=true&rendering_mode=messages&render_all_tools=true':'/backend-api/conversation/'+encodeURIComponent(item.id),platform==='chatgpt');
152
+ var sourceMessages=[],parents={};
153
+ if(platform==='chatgpt'){
154
+ if(!detail.mapping || !detail.current_node)throw new Error('invalid_response');
155
+ var nodes=[],cursor=detail.current_node,visited={};
156
+ while(cursor && detail.mapping[cursor] && !visited[cursor]){visited[cursor]=true;var node=detail.mapping[cursor];nodes.push(node);if(node.message)parents[node.message.id]=node.parent;cursor=node.parent;}
157
+ sourceMessages=nodes.reverse().map(function(node){return node.message;}).filter(Boolean);
158
+ }else{
159
+ var root=detail.conversation||detail.data||detail;
160
+ sourceMessages=root.chat_messages||root.messages||[];
161
+ if(!Array.isArray(sourceMessages))throw new Error('unavailable');
162
+ if(root.current_leaf_message_uuid){
163
+ var byId={},branch=[],seenNodes={};sourceMessages.forEach(function(m){byId[m.uuid||m.id]=m;});
164
+ var cursor=root.current_leaf_message_uuid;
165
+ while(cursor && byId[cursor] && !seenNodes[cursor]){seenNodes[cursor]=true;var m=byId[cursor];branch.push(m);cursor=m.parent_message_uuid||m.parent_uuid;}
166
+ if(branch.length)sourceMessages=branch.reverse();
167
+ }
168
+ }
169
+ var messages=sourceMessages.map(function(m){
170
+ var role=m.author?.role||m.sender||m.role;role=role==='human'?'user':role;
171
+ if(!['user','assistant'].includes(role))return null;
172
+ if(platform==='chatgpt' && /reasoning|thought|analysis/.test(m.content?.content_type||m.channel||''))return null;
173
+ var content=platform==='chatgpt'?(m.content?.parts||[]).filter(function(part){return typeof part==='string';}).join('\\n'):
174
+ typeof m.text==='string' && m.text.trim()?m.text:(Array.isArray(m.content)?m.content:[]).filter(function(block){return block.type==='text' && typeof block.text==='string';}).map(function(block){return block.text;}).join('\\n');
175
+ if(!content.trim())return null;
176
+ var timestamp=typeof m.create_time==='number'?m.create_time:Date.parse(m.created_at)/1000;
177
+ return {...extraMessageFields(m,parents[m.id]),id:String(m.id||m.uuid).slice(0,128),role:role,content:content,...(Number.isFinite(timestamp)?{timestamp:timestamp}:{})};
178
+ }).filter(Boolean);
179
+ var refs=includeFiles?collectFiles(sourceMessages):[];
180
+ var chatRoot=detail.conversation||detail.data||detail;
181
+ var chatMeta=cleanMetadata(Object.assign({},chatRoot.metadata||{},{modelSlug:chatRoot.model_slug||chatRoot.model||chatRoot.metadata?.modelSlug,defaultModelSlug:chatRoot.default_model_slug||chatRoot.metadata?.defaultModelSlug,safeUrls:chatRoot.safe_urls,currentNode:chatRoot.current_node,summary:chatRoot.summary}));
182
+ if(messages.length||refs.length)send({type:'conversation',conversation:{conversationId:item.id,title:item.title,platform:platform,messages:messages,metadata:chatMeta,modelSlug:chatMeta.modelSlug,createdAt:chatRoot.create_time||chatRoot.created_at,updatedAt:chatRoot.update_time||chatRoot.updated_at}});
183
+ var importedFiles=0;
184
+ for(var fi=0;fi<refs.length && !controller.signal.aborted;fi++){
185
+ var file=await queueFile(refs[fi],item.id);if(file.status==='imported')importedFiles++;
186
+ }
187
+ send({type:'item',id:item.id,status:messages.length||importedFiles?'done':'empty'});
188
+ send({type:'progress',completed:++completed,total:selected.length});
189
+ detail=null;
190
+ }}
191
+ await Promise.all(Array.from({length:Math.min(includeFiles?1:3,selected.length)},worker));
192
+ send({type:'complete'});
193
+ }catch(error){send({type:'error',code:timedOut || error.message==='timeout'?'timeout':['sign_in','network','rate_limited','provider_error','invalid_response','conversation_unavailable'].includes(error.message)?error.message:'unavailable'});controller.abort();}
194
+ finally{token=null;clearTimeout(timer);if(window.__onairosNativeImport===controller)delete window.__onairosNativeImport;}})();
195
+ })();true;`;
196
+ }
197
+ export {
198
+ CANCEL_NATIVE_IMPORT,
199
+ NATIVE_IMPORT_LIMIT,
200
+ createNativeImportScript,
201
+ parseNativeImportMessage
202
+ };
@@ -0,0 +1,63 @@
1
+ // Synced from RN utils/webviewScripts/nativeChatGPTSession.ts by scripts/sync-rn-connectors.cjs.
2
+ import { isNativeImportOrigin, NATIVE_IMPORT_PROVIDERS } from "./nativeImportProviders.js";
3
+ import { isDiscoveryNavigationAllowed } from "./chatgptDiscovery.js";
4
+ function parseNativeSessionMessage(raw, origin, channelId, platform = "chatgpt") {
5
+ if (raw.length > 512 || !isDiscoveryNavigationAllowed(origin) && !isNativeImportOrigin(origin, platform)) return null;
6
+ try {
7
+ const data = JSON.parse(raw);
8
+ if (data.channel !== "onairos-native-session" || data.channelId !== channelId) return null;
9
+ if (data.type === "authenticated") return isNativeImportOrigin(origin, platform) ? data.type : null;
10
+ return data.type === "page_ready" || data.type === "page_pending" || data.type === "validation_required" || data.type === "validation_cleared" ? data.type : null;
11
+ } catch {
12
+ return null;
13
+ }
14
+ }
15
+ function createNativeSessionScript(channelId, platform = "chatgpt") {
16
+ const provider = NATIVE_IMPORT_PROVIDERS[platform];
17
+ return `(function(){
18
+ if(window.top!==window.self) return;
19
+ if(window.__onairosSessionObserver){window.__onairosSessionObserver();return;}
20
+ var stopped=false, authenticated=false, ready=null, validationPending=false, timer, polling=false, loginController;
21
+ function send(type){if(!stopped)window.ReactNativeWebView.postMessage(JSON.stringify({channel:'onairos-native-session',channelId:${JSON.stringify(channelId)},type:type}));}
22
+ function checkPage(){
23
+ var body=document.body;
24
+ // Auth redirects can finish loading before their SPA has painted a form.
25
+ var visible=!!body && Array.from(body.querySelectorAll('input:not([type="hidden"]),button,h1,h2,[role="button"],iframe')).some(function(el){
26
+ var rect=el.getBoundingClientRect();return rect.width>0 && rect.height>0 && (!el.checkVisibility || el.checkVisibility({opacityProperty:true,visibilityProperty:true}));
27
+ });
28
+ if(visible!==ready){ready=visible;send(visible?'page_ready':'page_pending');}
29
+ }
30
+ function onInvalid(event){
31
+ var target=event.target;
32
+ if(validationPending || !target || !target.matches || !target.matches('input,select,textarea'))return;
33
+ validationPending=true;send('validation_required');
34
+ }
35
+ function onInput(){if(validationPending){validationPending=false;send('validation_cleared');}}
36
+ async function checkSession(){
37
+ if(stopped || authenticated || polling || location.origin!==${JSON.stringify(provider.origin)})return;
38
+ polling=true;
39
+ var controller=new AbortController(), timeout=setTimeout(function(){controller.abort();},4000);
40
+ loginController=controller;
41
+ try{
42
+ var response=await fetch(${JSON.stringify(provider.sessionPath)},{credentials:'include',redirect:'error',signal:controller.signal,headers:{Accept:'application/json'}});
43
+ if(response.ok){var session=await response.json();authenticated=${platform === "claude" ? "(Array.isArray(session)?session:session.organizations||[]).some(function(org){return typeof (org.uuid||org.id)==='string';})" : "typeof session.accessToken==='string' && !!session.accessToken"};session=null;if(authenticated){if(${platform === "claude" ? "location.pathname==='/login'" : "/^\\/auth(?:\\/|$)/.test(location.pathname)"}){location.replace(${JSON.stringify(provider.origin + (platform === "claude" ? "/new" : "/"))});return;}send('authenticated');}}
44
+ }catch(_){}finally{polling=false;if(loginController===controller)loginController=null;clearTimeout(timeout);}
45
+ }
46
+ function tick(){if(stopped)return;checkPage();void checkSession();timer=setTimeout(tick,1500);}
47
+ window.__onairosSessionObserver=function(){
48
+ if(stopped){stopped=false;authenticated=false;ready=null;clearTimeout(timer);observe();tick();return;}
49
+ ready=null;checkPage();void checkSession();
50
+ };
51
+ var observer=new MutationObserver(checkPage);
52
+ function observe(){if(document.documentElement)observer.observe(document.documentElement,{childList:true,subtree:true,attributes:true,attributeFilter:['class','style','hidden']});}
53
+ observe();document.addEventListener('DOMContentLoaded',observe,{once:true});
54
+ document.addEventListener('invalid',onInvalid,true);document.addEventListener('input',onInput,true);
55
+ window.addEventListener('pagehide',function(){stopped=true;clearTimeout(timer);if(loginController)loginController.abort();observer.disconnect();});
56
+ window.addEventListener('pageshow',function(){if(stopped)window.__onairosSessionObserver();});
57
+ tick();
58
+ })();true;`;
59
+ }
60
+ export {
61
+ createNativeSessionScript,
62
+ parseNativeSessionMessage
63
+ };
@@ -0,0 +1,132 @@
1
+ // Synced from RN utils/webviewScripts/nativeImportFiles.ts by scripts/sync-rn-connectors.cjs.
2
+ const NATIVE_IMPORT_FILES_SCRIPT = String.raw`
3
+ var fileBytes=0,fileCount=0;
4
+ var MAX_FILE_BYTES=26214400,MAX_FILE_TOTAL=104857600,PREVIEW_BYTES=1048576,CHUNK_BYTES=196608;
5
+ var fileQueue=Promise.resolve(),transferSerial=0;
6
+ function collectFiles(messages){
7
+ var refs=[],seen={},currentMessageId;
8
+ function visit(value,depth){
9
+ if(!value || depth>5 || refs.length>=100)return;
10
+ if(Array.isArray(value)){value.slice(0,50).forEach(function(v){visit(v,depth+1);});return;}
11
+ if(typeof value!=='object')return;
12
+ var id=value.file_id||value.fileId||value.file_uuid||value.asset_id||value.assetId||value.uuid||value.id;
13
+ var name=value.file_name||value.fileName||value.filename||value.name||value.display_name||value.displayName;
14
+ var mime=value.mime_type||value.mimeType||value.content_type||value.contentType||value.source&&value.source.media_type;
15
+ var pointer=typeof value.asset_pointer==='string' && /^file-service:\/\//.test(value.asset_pointer)?value.asset_pointer.slice(15):null;
16
+ if(pointer)id=pointer;
17
+ if(!name && (pointer || value.source&&value.source.type==='base64' || id && mime && /^(image|audio|video|application|text)\//.test(mime))){
18
+ var ext=mime==='image/png'?'png':mime==='image/jpeg'?'jpg':mime==='application/pdf'?'pdf':'bin';
19
+ name='attachment-'+String(id||refs.length+1)+'.'+ext;
20
+ }
21
+ if(typeof name==='string' && name && (id || value.extracted_content || value.source || value.download_url || value.url)){
22
+ var key=String(id||name),seenKey=currentMessageId+':'+key;if(!seen[seenKey]){seen[seenKey]=true;refs.push({ref:Object.assign({},value,{file_id:id,mime_type:mime}),id:key.slice(0,128),name:name.slice(0,300),messageId:currentMessageId});}return;
23
+ }
24
+ Object.keys(value).forEach(function(key){if(/^(attachments|files|assets|metadata|content|parts|source|file|attachment|document|images)$/.test(key))visit(value[key],depth+1);});
25
+ }
26
+ messages.forEach(function(m){currentMessageId=String(m.id||m.uuid||'').slice(0,128);visit(m,0);});return refs;
27
+ }
28
+ function encodeBytes(bytes){var binary='';for(var i=0;i<bytes.length;i+=32768)binary+=String.fromCharCode.apply(null,bytes.subarray(i,i+32768));return btoa(binary);}
29
+ async function readFileUrl(value,local,depth,metadata){
30
+ if(depth>2)return null;
31
+ var url=new URL(value,location.origin),same=url.origin===location.origin;
32
+ // Signed URLs stay in the page. Never send cookies or bearer credentials to a download host.
33
+ if(url.protocol!=='https:' || url.username || url.password || (!same && !/(^|\.)(oaiusercontent\.com|openai\.com|claude\.ai|anthropic\.com|oaistatic\.com)$/.test(url.hostname)))return null;
34
+ var response=await fetch(url.href,{credentials:same?'include':'omit',redirect:'error',signal:local.signal,headers:same&&token?{Authorization:'Bearer '+token}:{}});
35
+ if(!response.ok)return null;
36
+ var mime=response.headers.get('content-type')||'application/octet-stream';
37
+ if(Number(response.headers.get('content-length'))>MAX_FILE_BYTES)throw Error('too_large');
38
+ // Stream with a hard bound rather than allocating an unbounded attachment body.
39
+ if(!response.body || !response.body.getReader)throw Error('unavailable');
40
+ var reader=response.body.getReader(),chunks=[],size=0;
41
+ try{while(true){var part=await reader.read();if(part.done)break;size+=part.value.byteLength;if(size>MAX_FILE_BYTES)throw Error('too_large');chunks.push(part.value);}}
42
+ finally{await reader.cancel().catch(function(){});}
43
+ var bytes=new Uint8Array(size),offset=0;chunks.forEach(function(chunk){bytes.set(chunk,offset);offset+=chunk.length;});
44
+ if(metadata && /json/i.test(mime) && !/attachment/i.test(response.headers.get('content-disposition')||'')){
45
+ var json=JSON.parse(new TextDecoder().decode(bytes)),next=json.download_url||json.downloadUrl||json.file_url||json.signed_url||json.url;
46
+ if(next)return readFileUrl(next,local,depth+1,false);
47
+ if(typeof json.base64==='string')return {encoding:'base64',data:json.base64,sizeBytes:base64Size(json.base64),mimeType:json.mime_type||mime};
48
+ }
49
+ return {encoding:'base64',data:encodeBytes(bytes),sizeBytes:size,mimeType:mime.split(';')[0]};
50
+ }
51
+ async function importFile(entry,conversationId){
52
+ var file={id:entry.id,name:entry.name,messageId:entry.messageId,status:'unavailable'},ref=entry.ref;
53
+ if(++fileCount>20 || fileBytes>=MAX_FILE_TOTAL){file.status='limit_reached';return file;}
54
+ if(Number(ref.sizeBytes||ref.size||ref.file_size||ref.size_bytes||ref.byteSize||ref.byte_size)>MAX_FILE_BYTES){file.status='too_large';return file;}
55
+ var local=new AbortController(),abort=function(){local.abort();};controller.signal.addEventListener('abort',abort,{once:true});
56
+ if(controller.signal.aborted)local.abort();
57
+ var timer=setTimeout(abort,60000);
58
+ try{
59
+ var result=null,inline=ref.base64||ref.data_base64||(ref.source&&ref.source.type==='base64'&&ref.source.data);
60
+ if(typeof inline==='string' && base64Size(inline)>=0)result={encoding:'base64',data:inline,sizeBytes:base64Size(inline),mimeType:ref.mime_type||ref.content_type||ref.source?.media_type||'application/octet-stream'};
61
+ var text=ref.extracted_content||ref.plain_text;
62
+ var urls=[ref.download_url,ref.downloadUrl,ref.file_url,ref.signed_url,ref.signedUrl,ref.url,ref.source&&ref.source.url].filter(function(v){return typeof v==='string';});
63
+ var id=ref.file_id||ref.fileId||ref.file_uuid||ref.uuid||ref.id;
64
+ if(id){var base=platform==='claude'?'/api/organizations/'+encodeURIComponent(orgId)+'/files/':'/backend-api/files/';urls.push(base+encodeURIComponent(id)+'/download',base+encodeURIComponent(id)+'/content',base+encodeURIComponent(id));
65
+ if(platform==='claude'){var attachments='/api/organizations/'+encodeURIComponent(orgId)+'/attachments/'+encodeURIComponent(id);urls.push(attachments+'/download',attachments+'/content',attachments);}}
66
+ for(var i=0;!result && i<urls.length && !local.signal.aborted;i++)result=await readFileUrl(urls[i],local,0,/^\/(backend-api|api)\//.test(urls[i]) && !/\/content$/.test(urls[i])).catch(function(error){if(error.message==='too_large')throw error;return null;});
67
+ if(!result && typeof text==='string')result={encoding:'text',data:text,sizeBytes:new TextEncoder().encode(text).length,mimeType:'text/plain',extracted:true};
68
+ if(!result || result.sizeBytes<0)return file;
69
+ if(result.sizeBytes>MAX_FILE_BYTES){file.status='too_large';return file;}
70
+ if(fileBytes+result.sizeBytes>MAX_FILE_TOTAL){file.status='limit_reached';return file;}
71
+ fileBytes+=result.sizeBytes;return Object.assign(file,result,{status:'imported'});
72
+ }catch(error){file.status=error.message==='too_large'?'too_large':'unavailable';return file;}
73
+ finally{clearTimeout(timer);controller.signal.removeEventListener('abort',abort);}
74
+ }
75
+ function base64Size(value){
76
+ if(value.length%4 || !/^[A-Za-z0-9+/]*={0,2}$/.test(value))return -1;
77
+ return value.length/4*3-(value.endsWith('==')?2:value.endsWith('=')?1:0);
78
+ }
79
+ // Acknowledgements bound the bridge queue; only one file is decoded/transferred at a time.
80
+ function transferPart(message,key){return new Promise(function(resolve,reject){
81
+ var cleanup=function(){clearTimeout(timeout);controller.signal.removeEventListener('abort',abort);delete controller.fileAck;};
82
+ var abort=function(){cleanup();reject(new Error('cancelled'));};
83
+ var timeout=setTimeout(function(){cleanup();reject(new Error('timeout'));},15000);
84
+ controller.fileAck=function(ack,ok){if(ack!==requestId+':'+key)return;cleanup();ok?resolve():reject(new Error('unavailable'));};
85
+ controller.signal.addEventListener('abort',abort,{once:true});
86
+ if(controller.signal.aborted){abort();return;}send(message);
87
+ });}
88
+ async function deliverFile(file,conversationId){
89
+ if(file.status!=='imported' || file.sizeBytes<=PREVIEW_BYTES){send({type:'file',conversationId:conversationId,file:file});return;}
90
+ var transferId='file-'+(++transferSerial),data=file.encoding==='text'?encodeBytes(new TextEncoder().encode(file.data)):file.data;
91
+ var metadata={id:file.id,name:file.name,status:file.status,encoding:'base64',sizeBytes:file.sizeBytes,mimeType:file.mimeType,extracted:file.extracted===true};
92
+ await transferPart({type:'file_start',transferId:transferId,conversationId:conversationId,file:metadata},transferId+':start');
93
+ var chars=CHUNK_BYTES/3*4;
94
+ for(var offset=0,index=0;offset<data.length;offset+=chars,index++)await transferPart({type:'file_chunk',transferId:transferId,index:index,data:data.slice(offset,offset+chars)},transferId+':'+index);
95
+ await transferPart({type:'file_end',transferId:transferId},transferId+':end');
96
+ }
97
+ function queueFile(entry,conversationId){
98
+ var next=fileQueue.then(async function(){
99
+ if(controller.signal.aborted)throw new Error('cancelled');
100
+ var file=await importFile(entry,conversationId);
101
+ if(typeof transferFile==='function' && file.status==='imported')await transferFile(file,conversationId);else await deliverFile(file,conversationId);
102
+ return {status:file.status};
103
+ });fileQueue=next;return next;
104
+ }
105
+ `;
106
+ const NATIVE_FILE_BRIDGE_SCRIPT = String.raw`
107
+ var bridgeSequence=0;
108
+ async function fileBridge(value){
109
+ var sequence=++bridgeSequence;
110
+ return new Promise(function(resolve,reject){
111
+ var timeout=setTimeout(function(){cleanup();reject(Error('timeout'));},90000);
112
+ function cleanup(){clearTimeout(timeout);controller.signal.removeEventListener('abort',aborted);delete window.__onairosFileAck;}
113
+ function aborted(){cleanup();reject(Error('cancelled'));}
114
+ controller.signal.addEventListener('abort',aborted,{once:true});
115
+ window.__onairosFileAck=function(request,seq,ok){if(request!==importRequestId||seq!==sequence)return;cleanup();ok?resolve():reject(Error('unavailable'));};
116
+ send(Object.assign({sequence:sequence},value));
117
+ });
118
+ }
119
+ async function transferFile(file,conversationId){
120
+ var encoded=file.encoding==='text'?encodeBytes(new TextEncoder().encode(file.data)):file.data;
121
+ var size=Math.floor(encoded.length*3/4)-(encoded.endsWith('==')?2:encoded.endsWith('=')?1:0);
122
+ await fileBridge({type:'file_start',conversationId:conversationId,file:{id:file.id,name:file.name,messageId:file.messageId||undefined,sizeBytes:size,mimeType:file.mimeType,extracted:file.extracted===true}});
123
+ // 196608 bytes is a multiple of three: chunks concatenate without intermediate padding.
124
+ for(var offset=0,index=0;offset<encoded.length;offset+=262144,index++)await fileBridge({type:'file_chunk',conversationId:conversationId,index:index,data:encoded.slice(offset,offset+262144)});
125
+ await fileBridge({type:'file_end',conversationId:conversationId});
126
+ file.data=null;encoded=null;
127
+ }
128
+ `;
129
+ export {
130
+ NATIVE_FILE_BRIDGE_SCRIPT,
131
+ NATIVE_IMPORT_FILES_SCRIPT
132
+ };
@@ -0,0 +1,80 @@
1
+ // Synced from RN utils/webviewScripts/nativeImportProviders.ts by scripts/sync-rn-connectors.cjs.
2
+ const NATIVE_IMPORT_PROVIDERS = {
3
+ chatgpt: { name: "ChatGPT", origin: "https://chatgpt.com", loginUrl: "https://chatgpt.com/auth/login", sessionPath: "/api/auth/session" },
4
+ claude: { name: "Claude", origin: "https://claude.ai", loginUrl: "https://claude.ai/login", sessionPath: "/api/organizations" }
5
+ };
6
+ function isNativeImportOrigin(value, platform) {
7
+ try {
8
+ return new URL(value).origin === NATIVE_IMPORT_PROVIDERS[platform].origin;
9
+ } catch {
10
+ return false;
11
+ }
12
+ }
13
+ function createNativeSignOutScript(platform, channelId) {
14
+ const send = platform === "claude" ? `call('/api/auth/logout', {method:'POST', headers:{'Content-Type':'application/json'}, body:'{}'})
15
+ .then(function(r) { report(!!r && r.ok, r && r.status); })` : `call('/api/auth/csrf').then(function(r) {
16
+ if (!r || !r.ok) { report(false, r && r.status); return null; }
17
+ return r.json();
18
+ }).then(function(body) {
19
+ if (!body) return;
20
+ var token = typeof body.csrfToken === 'string' ? body.csrfToken : '';
21
+ if (!token) { report(false, 0); return; }
22
+ return call('/api/auth/signout', {
23
+ method:'POST', headers:{'Content-Type':'application/x-www-form-urlencoded'},
24
+ body:'csrfToken=' + encodeURIComponent(token) + '&callbackUrl=%2F&json=true'
25
+ }).then(function(r) {
26
+ if (!r || !r.ok) { report(false, r && r.status); return; }
27
+ return r.json().then(function(body) {
28
+ report(!!body && typeof body.url === 'string' && !!body.url && !/[?&](?:error|csrf)=/.test(body.url), r.status);
29
+ }, function() { report(false, r.status); });
30
+ });
31
+ })`;
32
+ return `(function() {
33
+ try {
34
+ var origin = ${JSON.stringify(NATIVE_IMPORT_PROVIDERS[platform].origin)};
35
+ if (location.origin !== origin) return;
36
+ var abort = typeof AbortController === 'function' ? new AbortController() : null;
37
+ var reported = false;
38
+ var report = function(ok, status) {
39
+ if (reported) return;
40
+ reported = true;
41
+ clearTimeout(timer);
42
+ try {
43
+ window.ReactNativeWebView.postMessage(JSON.stringify({
44
+ channel:'onairos-native-signout', channelId:${JSON.stringify(channelId)},
45
+ ok:ok === true, status:typeof status === 'number' ? status : 0
46
+ }));
47
+ } catch (_) {}
48
+ };
49
+ var timer = setTimeout(function() {
50
+ try { if (abort) abort.abort(); } catch (_) {}
51
+ report(false, 0);
52
+ }, 3000);
53
+ var call = function(path, init) {
54
+ if (reported) return Promise.reject(new Error('Sign-out finished'));
55
+ init = init || {};
56
+ init.credentials = 'same-origin'; init.mode = 'same-origin';
57
+ init.cache = 'no-store'; init.redirect = 'manual'; init.keepalive = true;
58
+ if (abort) init.signal = abort.signal;
59
+ return fetch(origin + path, init);
60
+ };
61
+ ${send}.then(function() { report(false, 0); }, function() { report(false, 0); });
62
+ } catch (_) { try { report(false, 0); } catch (_) {} }
63
+ })();true;`;
64
+ }
65
+ function parseNativeSignOutMessage(raw, origin, channelId, platform) {
66
+ if (typeof raw !== "string" || raw.length > 256 || !isNativeImportOrigin(origin, platform)) return null;
67
+ try {
68
+ const data = JSON.parse(raw);
69
+ if (!data || data.channel !== "onairos-native-signout" || data.channelId !== channelId || typeof data.ok !== "boolean") return null;
70
+ return { ok: data.ok, status: Number.isInteger(data.status) && data.status >= 0 && data.status <= 599 ? data.status : 0 };
71
+ } catch {
72
+ return null;
73
+ }
74
+ }
75
+ export {
76
+ NATIVE_IMPORT_PROVIDERS,
77
+ createNativeSignOutScript,
78
+ isNativeImportOrigin,
79
+ parseNativeSignOutMessage
80
+ };
@@ -0,0 +1,28 @@
1
+ // Synced from RN utils/webviewScripts/nativeLoginViewport.ts by scripts/sync-rn-connectors.cjs.
2
+ const NATIVE_LOGIN_VIEWPORT_SCRIPT = `(function(){
3
+ if(window.top!==window.self || window.__onairosLoginInputSizing)return;
4
+ var allowed=location.origin==='https://auth.openai.com' ||
5
+ (location.origin==='https://chatgpt.com' && /^\\/auth(?:\\/|$)/.test(location.pathname));
6
+ if(!allowed)return;
7
+ window.__onairosLoginInputSizing=true;
8
+ function sizeInput(element){
9
+ if(!element || !element.matches || !element.matches('input:not([type="hidden"]):not([type="checkbox"]):not([type="radio"]):not([type="submit"]):not([type="button"]),textarea,select'))return;
10
+ var size=parseFloat(window.getComputedStyle(element).fontSize);
11
+ if(Number.isFinite(size) && size>=0 && size<16 &&
12
+ (element.style.getPropertyValue('font-size')!=='16px' || element.style.getPropertyPriority('font-size')!=='important')){
13
+ element.style.setProperty('font-size','16px','important');
14
+ }
15
+ }
16
+ function scan(){document.querySelectorAll('input,textarea,select').forEach(sizeInput);}
17
+ function focus(event){sizeInput(event.target);}
18
+ var observer=new MutationObserver(scan);
19
+ function observe(){if(document.documentElement)observer.observe(document.documentElement,{childList:true,subtree:true,attributes:true,attributeFilter:['class','style','type']});scan();}
20
+ document.addEventListener('focus',focus,true);
21
+ document.addEventListener('pointerdown',focus,true);
22
+ document.addEventListener('DOMContentLoaded',observe,{once:true});
23
+ window.addEventListener('pagehide',function(){observer.disconnect();document.removeEventListener('focus',focus,true);document.removeEventListener('pointerdown',focus,true);},{once:true});
24
+ observe();
25
+ })();true;`;
26
+ export {
27
+ NATIVE_LOGIN_VIEWPORT_SCRIPT
28
+ };