Repository Public
1/**2 * =============================================================================3 * SP BOUCHER | SOFTWARE & RESEARCH4 * ARTIFICIAL INTELLIGENCE • FINANCE • ENGINEERING5 * =============================================================================6 *7 * Project : SP Keyboard8 * File : Scripts/portal/create-app-ids.js9 * Description : Creates the explicit App IDs ai.spboucher.keyboard and10 * ai.spboucher.keyboard.extension with the App Groups11 * capability bound to group.ai.spboucher.keyboard, when12 * absent, then reads them back. Idempotent. Stops if the13 * group is missing.14 * Module : Scripts15 * Repository : https://git.spboucher.ai/sp-keyboard16 * Created : 2026-12-0117 * Last Modified : 2026-12-0118 *19 * Author : Simon-Pierre Boucher20 * Position : Professor of Finance21 * Institution : Université du Québec en Outaouais (UQO)22 * Organization : SP Boucher23 * Website : https://spboucher.ai24 * Git : https://git.spboucher.ai25 *26 * Preferred Contact: support@spboucher.ai27 * Development : dev@spboucher.ai28 * Support : support@spboucher.ai29 * Security/Admin : admin@spboucher.ai30 *31 * Copyright (c) 202632 * Simon-Pierre Boucher33 * All rights reserved where applicable. This file is governed by the34 * applicable project license, copyright notices and relevant law.35 * Existing third-party rights and notices remain unaffected.36 *37 * License : None specified (no license file in this repository)38 *39 * Do not embed credentials, private keys, access tokens,40 * certificates or confidential personal information.41 *42 * =============================================================================43 * END OF SP BOUCHER SOURCE HEADER44 * =============================================================================45 */4647async function main(){48 const team='3YM54G49SN', groupIdent='group.ai.spboucher.keyboard';49 const want=[['ai.spboucher.keyboard','SP Keyboard'],['ai.spboucher.keyboard.extension','SP Keyboard Extension']];50 const get={'Content-Type':'application/vnd.api+json','Accept':'application/vnd.api+json, application/json','X-HTTP-Method-Override':'GET','X-Requested-With':'XMLHttpRequest'};51 const form={'Content-Type':'application/x-www-form-urlencoded','Accept':'application/json','X-Requested-With':'XMLHttpRequest'};52 const gr=await (await fetch('/services-account/QH65B2/account/ios/identifiers/listApplicationGroups.action',{method:'POST',credentials:'include',headers:form,body:'teamId='+team+'&pageNumber=1&pageSize=500&sort=name%3Dasc'})).json();53 const group=(gr.applicationGroupList||[]).find(x=>x.identifier===groupIdent);54 if(!group) return 'STOP: app group missing';55 const list=async()=>{const r=await fetch('/services-account/v1/bundleIds',{method:'POST',credentials:'include',headers:get,body:JSON.stringify({urlEncodedQueryParams:'limit=1000',teamId:team})}); const j=await r.json(); return {r,data:j.data||[]};};56 const out=[];57 for(const [ident,name] of want){58 let s=await list(); let found=s.data.find(d=>d.attributes.identifier===ident);59 if(found){ out.push({ident,action:'exists',id:found.id}); continue; }60 const h={'Content-Type':'application/vnd.api+json','Accept':'application/vnd.api+json, application/json','X-Requested-With':'XMLHttpRequest'};61 const c=s.r.headers.get('csrf'), ts=s.r.headers.get('csrf_ts'); if(c){h['csrf']=c; h['csrf_ts']=ts;}62 const body={data:{type:'bundleIds',attributes:{identifier:ident,name:name,seedId:team,teamId:team},relationships:{bundleIdCapabilities:{data:[63 {type:'bundleIdCapabilities',attributes:{enabled:true,settings:[]},relationships:{capability:{data:{type:'capabilities',id:'APP_GROUPS'}},appGroups:{data:[{type:'appGroups',id:group.applicationGroup}]}}}]}}}};64 const r=await fetch('/services-account/v1/bundleIds',{method:'POST',credentials:'include',headers:h,body:JSON.stringify(body)});65 const t=await r.text(); let j={}; try{j=JSON.parse(t)}catch(e){}66 s=await list(); found=s.data.find(d=>d.attributes.identifier===ident);67 out.push({ident,action:'create',status:r.status,errors:(j.errors||[]).map(e=>(e.detail||e.title)),verifiedId:found&&found.id,raw:found?undefined:t.slice(0,300)});68 if(!found) break;69 }70 return JSON.stringify(out);71}72