SPB Git

Repository Public

create-asc-record.js 3.8 KB 64 lines javascript

1/**2 * =============================================================================3 *                  SP BOUCHER | SOFTWARE & RESEARCH4 *             ARTIFICIAL INTELLIGENCE • FINANCE • ENGINEERING5 * =============================================================================6 *7 * Project          : SP ID & Card Vault8 * File             : scripts/portal/create-asc-record.js9 * Module           : Scripts10 * Repository       : https://git.spboucher.ai/sp-id-card-vault11 * Project Website  : Not specified12 * Created          : 2026-12-0213 * Last Modified    : 2026-12-0214 *15 * Author           : Simon-Pierre Boucher16 * Position         : Professor of Finance17 * Institution      : Université du Québec en Outaouais (UQO)18 * Organization     : SP Boucher19 * Website          : https://spboucher.ai20 * Git              : https://git.spboucher.ai21 *22 * Preferred Contact: contact@spboucher.ai23 * Development      : dev@spboucher.ai24 * Support          : support@spboucher.ai25 * Security/Admin   : admin@spboucher.ai26 *27 * Copyright (c) 202628 * Simon-Pierre Boucher29 * All rights reserved where applicable. This file is governed by the30 * applicable project license, copyright notices and relevant law.31 * Existing third-party rights and notices remain unaffected.32 *33 * License          : None specified (no license file in this repository)34 *35 * Do not embed credentials, private keys, access tokens,36 * certificates or confidential personal information.37 *38 * =============================================================================39 * END OF SP BOUCHER SOURCE HEADER40 * =============================================================================41 */4243// Idempotent: creates the App Store Connect record of ai.spboucher.idcardvault (TestFlight only,44// never submitted for review). Tries the names in order until one is free.45async function main(){46  const bundleId='ai.spboucher.idcardvault', sku='spidcardvault-ios-001', names=['SP ID & Card Vault','SP ID Vault','SP ID & Card Vault — SP Boucher'];47  let r=await fetch('/iris/v1/apps?filter[bundleId]='+bundleId+'&fields[apps]=name,bundleId,sku',{credentials:'include'});48  if(r.status>=300) return 'LIST FAIL '+r.status+' (session?)';49  let j=await r.json(); const ex=(j.data||[]).filter(a=>a.attributes.bundleId===bundleId);50  if(ex.length) return 'EXISTS id='+ex[0].id+' name='+ex[0].attributes.name+' sku='+ex[0].attributes.sku;51  for(const name of names){52    const body={data:{type:"apps",attributes:{sku,primaryLocale:"en-CA",bundleId},relationships:{appStoreVersions:{data:[{type:"appStoreVersions",id:"${store-version-ios}"}]},appInfos:{data:[{type:"appInfos",id:"${new-appInfo-id}"}]}}},53      included:[{type:"appStoreVersions",id:"${store-version-ios}",attributes:{platform:"IOS",versionString:"1.0.0"},relationships:{appStoreVersionLocalizations:{data:[{type:"appStoreVersionLocalizations",id:"${new-appStoreVersionLocalization-id}"}]}}},54        {type:"appStoreVersionLocalizations",id:"${new-appStoreVersionLocalization-id}",attributes:{locale:"en-CA"}},55        {type:"appInfos",id:"${new-appInfo-id}",relationships:{appInfoLocalizations:{data:[{type:"appInfoLocalizations",id:"${new-appInfoLocalization-id}"}]}}},56        {type:"appInfoLocalizations",id:"${new-appInfoLocalization-id}",attributes:{locale:"en-CA",name}}]};57    r=await fetch('/iris/v1/apps',{method:'POST',credentials:'include',headers:{'Content-Type':'application/json','X-Csrf-Itc':'[asc-ui]'},body:JSON.stringify(body)});58    const t=await r.text();59    if(r.status<300){ const k=JSON.parse(t); return 'CREATED id='+k.data.id+' name='+name+' sku='+sku; }60    const msg=(()=>{try{return JSON.stringify(JSON.parse(t).errors.map(e=>[e.code,e.detail]))}catch(e){return t.slice(0,300)}})();61    if(!/name|NAME/.test(msg)||names.indexOf(name)===names.length-1) return 'FAIL '+r.status+' '+msg;62  }63}64
Files main
Menu

Theme