Repository Public
1/**2 * =============================================================================3 * SP BOUCHER | SOFTWARE & RESEARCH4 * ARTIFICIAL INTELLIGENCE • FINANCE • ENGINEERING5 * =============================================================================6 *7 * Project : SP Keyboard8 * File : Scripts/portal/create-app-group.js9 * Description : Creates the App Group group.ai.spboucher.keyboard when10 * absent, then reads it back. Idempotent: run again, it11 * answers 'exists'.12 * Module : Scripts13 * Repository : https://git.spboucher.ai/sp-keyboard14 * Created : 2026-12-0115 * Last Modified : 2026-12-0116 *17 * Author : Simon-Pierre Boucher18 * Position : Professor of Finance19 * Institution : Université du Québec en Outaouais (UQO)20 * Organization : SP Boucher21 * Website : https://spboucher.ai22 * Git : https://git.spboucher.ai23 *24 * Preferred Contact: support@spboucher.ai25 * Development : dev@spboucher.ai26 * Support : support@spboucher.ai27 * Security/Admin : admin@spboucher.ai28 *29 * Copyright (c) 202630 * Simon-Pierre Boucher31 * All rights reserved where applicable. This file is governed by the32 * applicable project license, copyright notices and relevant law.33 * Existing third-party rights and notices remain unaffected.34 *35 * License : None specified (no license file in this repository)36 *37 * Do not embed credentials, private keys, access tokens,38 * certificates or confidential personal information.39 *40 * =============================================================================41 * END OF SP BOUCHER SOURCE HEADER42 * =============================================================================43 */4445async function main(){46 const team='3YM54G49SN', ident='group.ai.spboucher.keyboard', name='SP Keyboard';47 const form={'Content-Type':'application/x-www-form-urlencoded','Accept':'application/json','X-Requested-With':'XMLHttpRequest'};48 const list=async()=>{const r=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'}); const j=await r.json(); return {r,found:(j.applicationGroupList||[]).filter(x=>x.identifier===ident)};};49 let s=await list();50 if(s.found.length) return JSON.stringify({action:'exists',group:s.found.map(x=>[x.identifier,x.name,x.applicationGroup])});51 const h=Object.assign({},form); const c=s.r.headers.get('csrf'), ts=s.r.headers.get('csrf_ts'); if(c){h['csrf']=c; h['csrf_ts']=ts;}52 const r=await fetch('/services-account/QH65B2/account/ios/identifiers/addApplicationGroup.action',{method:'POST',credentials:'include',headers:h,body:'teamId='+team+'&name='+encodeURIComponent(name)+'&identifier='+encodeURIComponent(ident)});53 const t=await r.text(); let j={}; try{j=JSON.parse(t)}catch(e){}54 s=await list();55 return JSON.stringify({action:'create',status:r.status,resultCode:j.resultCode,resultString:j.resultString,userString:j.userString,hadCsrf:!!c,verified:s.found.map(x=>[x.identifier,x.name,x.applicationGroup]),raw:s.found.length?undefined:t.slice(0,300)});56}57