@mochabug/adapt-web 1.0.1-rc.29 → 1.0.1-rc.30

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.
package/dist/README.md CHANGED
@@ -6,7 +6,7 @@ Embed Adapt automations in any website.
6
6
  npm install @mochabug/adapt-web
7
7
  ```
8
8
 
9
- **CDN base:** `https://cdn.mochabug.com/adapt/web/1.0.1-rc.29/`
9
+ **CDN base:** `https://cdn.mochabug.com/adapt/web/1.0.1-rc.30/`
10
10
 
11
11
  | Bundle | File | Includes |
12
12
  |--------|------|----------|
@@ -20,8 +20,8 @@ npm install @mochabug/adapt-web
20
20
  Bundles merge into a single `MbAdapt` global, so you can combine them. For example, headless + Cap for automations that need proof-of-work but no UI:
21
21
 
22
22
  ```html
23
- <script src="https://cdn.mochabug.com/adapt/web/1.0.1-rc.29/adapt-core.min.js"></script>
24
- <script src="https://cdn.mochabug.com/adapt/web/1.0.1-rc.29/adapt-web.cap.min.js"></script>
23
+ <script src="https://cdn.mochabug.com/adapt/web/1.0.1-rc.30/adapt-core.min.js"></script>
24
+ <script src="https://cdn.mochabug.com/adapt/web/1.0.1-rc.30/adapt-web.cap.min.js"></script>
25
25
  <script>
26
26
  // MbAdapt has exports from both scripts
27
27
  var client = MbAdapt.createAdaptClient(
@@ -43,12 +43,12 @@ Preload the script and load the stylesheet in `<head>` to eliminate flash of uns
43
43
 
44
44
  ```html
45
45
  <head>
46
- <link rel="preload" href="https://cdn.mochabug.com/adapt/web/1.0.1-rc.29/adapt-web.min.js" as="script">
47
- <link rel="stylesheet" href="https://cdn.mochabug.com/adapt/web/1.0.1-rc.29/styles.css">
46
+ <link rel="preload" href="https://cdn.mochabug.com/adapt/web/1.0.1-rc.30/adapt-web.min.js" as="script">
47
+ <link rel="stylesheet" href="https://cdn.mochabug.com/adapt/web/1.0.1-rc.30/styles.css">
48
48
  </head>
49
49
  <body>
50
50
  <adapt-automation automation-id="YOUR_ID" requires-challenge style="height: 600px"></adapt-automation>
51
- <script src="https://cdn.mochabug.com/adapt/web/1.0.1-rc.29/adapt-web.min.js"></script>
51
+ <script src="https://cdn.mochabug.com/adapt/web/1.0.1-rc.30/adapt-web.min.js"></script>
52
52
  </body>
53
53
  ```
54
54
 
@@ -56,12 +56,12 @@ No challenges? Use the core bundle and drop `requires-challenge`:
56
56
 
57
57
  ```html
58
58
  <head>
59
- <link rel="preload" href="https://cdn.mochabug.com/adapt/web/1.0.1-rc.29/adapt-web.core.min.js" as="script">
60
- <link rel="stylesheet" href="https://cdn.mochabug.com/adapt/web/1.0.1-rc.29/styles.css">
59
+ <link rel="preload" href="https://cdn.mochabug.com/adapt/web/1.0.1-rc.30/adapt-web.core.min.js" as="script">
60
+ <link rel="stylesheet" href="https://cdn.mochabug.com/adapt/web/1.0.1-rc.30/styles.css">
61
61
  </head>
62
62
  <body>
63
63
  <adapt-automation automation-id="YOUR_ID" style="height: 600px"></adapt-automation>
64
- <script src="https://cdn.mochabug.com/adapt/web/1.0.1-rc.29/adapt-web.core.min.js"></script>
64
+ <script src="https://cdn.mochabug.com/adapt/web/1.0.1-rc.30/adapt-web.core.min.js"></script>
65
65
  </body>
66
66
  ```
67
67
 
@@ -71,14 +71,14 @@ Just the element and script. CSS is auto-injected at runtime.
71
71
 
72
72
  ```html
73
73
  <adapt-automation automation-id="YOUR_ID" requires-challenge style="height: 600px"></adapt-automation>
74
- <script src="https://cdn.mochabug.com/adapt/web/1.0.1-rc.29/adapt-web.min.js"></script>
74
+ <script src="https://cdn.mochabug.com/adapt/web/1.0.1-rc.30/adapt-web.min.js"></script>
75
75
  ```
76
76
 
77
77
  Without challenges:
78
78
 
79
79
  ```html
80
80
  <adapt-automation automation-id="YOUR_ID" style="height: 600px"></adapt-automation>
81
- <script src="https://cdn.mochabug.com/adapt/web/1.0.1-rc.29/adapt-web.core.min.js"></script>
81
+ <script src="https://cdn.mochabug.com/adapt/web/1.0.1-rc.30/adapt-web.core.min.js"></script>
82
82
  ```
83
83
 
84
84
  ### ESM
@@ -130,7 +130,7 @@ Initial JSON options can be written directly on the element:
130
130
  signals='{"key":"value"}'
131
131
  style="height: 600px"
132
132
  ></adapt-automation>
133
- <script src="https://cdn.mochabug.com/adapt/web/1.0.1-rc.29/adapt-web.core.min.js"></script>
133
+ <script src="https://cdn.mochabug.com/adapt/web/1.0.1-rc.30/adapt-web.core.min.js"></script>
134
134
  ```
135
135
 
136
136
  For complex values that are easier to build in JavaScript, set properties before loading the bundle:
@@ -142,7 +142,7 @@ For complex values that are easier to build in JavaScript, set properties before
142
142
  el.inheritFrom = { hash: 'mb_session' };
143
143
  el.signals = { key: 'value' };
144
144
  </script>
145
- <script src="https://cdn.mochabug.com/adapt/web/1.0.1-rc.29/adapt-web.core.min.js"></script>
145
+ <script src="https://cdn.mochabug.com/adapt/web/1.0.1-rc.30/adapt-web.core.min.js"></script>
146
146
  ```
147
147
 
148
148
  ### JS-only properties
@@ -186,12 +186,12 @@ Requires a `client` JS property — set it after the element is in the DOM.
186
186
 
187
187
  ```html
188
188
  <head>
189
- <link rel="preload" href="https://cdn.mochabug.com/adapt/web/1.0.1-rc.29/adapt-web.cap.min.js" as="script">
190
- <link rel="stylesheet" href="https://cdn.mochabug.com/adapt/web/1.0.1-rc.29/styles.css">
189
+ <link rel="preload" href="https://cdn.mochabug.com/adapt/web/1.0.1-rc.30/adapt-web.cap.min.js" as="script">
190
+ <link rel="stylesheet" href="https://cdn.mochabug.com/adapt/web/1.0.1-rc.30/styles.css">
191
191
  </head>
192
192
  <body>
193
193
  <adapt-cap automation-id="YOUR_ID"></adapt-cap>
194
- <script src="https://cdn.mochabug.com/adapt/web/1.0.1-rc.29/adapt-web.cap.min.js"></script>
194
+ <script src="https://cdn.mochabug.com/adapt/web/1.0.1-rc.30/adapt-web.cap.min.js"></script>
195
195
  <script>
196
196
  var el = document.querySelector('adapt-cap');
197
197
  el.client = MbAdapt.createConnectClient({ id: 'YOUR_ID' });
@@ -206,7 +206,7 @@ Requires a `client` JS property — set it after the element is in the DOM.
206
206
 
207
207
  ```html
208
208
  <adapt-cap automation-id="YOUR_ID"></adapt-cap>
209
- <script src="https://cdn.mochabug.com/adapt/web/1.0.1-rc.29/adapt-web.cap.min.js"></script>
209
+ <script src="https://cdn.mochabug.com/adapt/web/1.0.1-rc.30/adapt-web.cap.min.js"></script>
210
210
  <script>
211
211
  var el = document.querySelector('adapt-cap');
212
212
  el.client = MbAdapt.createConnectClient({ id: 'YOUR_ID' });
@@ -1 +1 @@
1
- typeof window<"u"&&!window.CAP_CUSTOM_WASM_URL&&(window.CAP_CUSTOM_WASM_URL=new URL("https://cdn.mochabug.com/adapt/web/1.0.1-rc.29/cap_wasm_bg.wasm",window.location.href).href);import{timestampDate}from"@bufbuild/protobuf/wkt";let currentClient=null,currentAutomationId=null;const verificationTokens=new Map,redeemedChallengeExpirations=new Map;async function createChallenge(client,id){const response=await client.createChallenge({id}),instrumentation=response.instrumentation;return{count:response.count,size:response.size,difficulty:response.difficulty,expires:response.expires?timestampDate(response.expires):new Date,token:response.token,verificationToken:response.verificationToken,...instrumentation?{instrumentation}:{}}}async function redeemChallenge(client,id,verificationToken,solutions,options={}){const request={id,verificationToken,solutions,...options.instrumentation?{instrumentation:options.instrumentation}:{},...options.instrumentationBlocked?{instrumentationBlocked:!0}:{},...options.instrumentationTimeout?{instrumentationTimeout:!0}:{}},response=await client.redeemChallenge(request);return{token:response.token,expires:response.expires?timestampDate(response.expires):new Date}}function takeRedeemedChallengeExpiration(automationId){const expires=redeemedChallengeExpirations.get(automationId)??null;return expires&&redeemedChallengeExpirations.delete(automationId),expires}typeof window<"u"&&(window.CAP_CUSTOM_FETCH=async(url,options)=>{const urlStr=url.toString();if(urlStr.endsWith("/challenge")){if(!currentClient||!currentAutomationId)return new Response(JSON.stringify({error:"Cap adapter not initialized"}),{status:500,headers:{"Content-Type":"application/json"}});try{const challengeInfo=await createChallenge(currentClient,currentAutomationId);return verificationTokens.set(currentAutomationId,challengeInfo.verificationToken),redeemedChallengeExpirations.delete(currentAutomationId),new Response(JSON.stringify({challenge:{c:challengeInfo.count,s:challengeInfo.size,d:challengeInfo.difficulty},token:challengeInfo.token,expires:challengeInfo.expires.toISOString(),...challengeInfo.instrumentation?{instrumentation:challengeInfo.instrumentation}:{}}),{status:200,headers:{"Content-Type":"application/json"}})}catch(error){return new Response(JSON.stringify({error:String(error)}),{status:500,headers:{"Content-Type":"application/json"}})}}if(urlStr.endsWith("/redeem")){if(!currentClient||!currentAutomationId)return new Response(JSON.stringify({error:"Cap adapter not initialized"}),{status:500,headers:{"Content-Type":"application/json"}});const verificationToken=verificationTokens.get(currentAutomationId);if(!verificationToken)return new Response(JSON.stringify({error:"No verification token found - challenge must be created first"}),{status:400,headers:{"Content-Type":"application/json"}});try{const body=options?.body?JSON.parse(options.body):{},solutions=(body.solutions||[]).map(s=>BigInt(s)),instrumentationBlocked=body.instr_blocked===!0||body.instr?.__blocked===!0,instrumentationTimeout=body.instr_timeout===!0||body.instr?.__timeout===!0,instrumentation=body.instr&&!instrumentationBlocked&&!instrumentationTimeout?body.instr:void 0,redeemed=await redeemChallenge(currentClient,currentAutomationId,verificationToken,solutions,{...instrumentation?{instrumentation}:{},...instrumentationBlocked?{instrumentationBlocked}:{},...instrumentationTimeout?{instrumentationTimeout}:{}});return redeemedChallengeExpirations.set(currentAutomationId,redeemed.expires),verificationTokens.delete(currentAutomationId),new Response(JSON.stringify({success:!0,token:redeemed.token,expires:redeemed.expires.toISOString()}),{status:200,headers:{"Content-Type":"application/json"}})}catch(error){return new Response(JSON.stringify({error:String(error)}),{status:500,headers:{"Content-Type":"application/json"}})}}return fetch(url,options)});function setupCapAdapter(client,automationId){currentAutomationId&&currentAutomationId!==automationId&&(verificationTokens.delete(currentAutomationId),redeemedChallengeExpirations.delete(currentAutomationId)),currentClient=client,currentAutomationId=automationId,redeemedChallengeExpirations.delete(automationId)}function cleanupCapAdapter(){currentAutomationId&&(verificationTokens.delete(currentAutomationId),redeemedChallengeExpirations.delete(currentAutomationId)),currentClient=null,currentAutomationId=null}export{cleanupCapAdapter,createChallenge,redeemChallenge,setupCapAdapter,takeRedeemedChallengeExpiration};
1
+ typeof window<"u"&&!window.CAP_CUSTOM_WASM_URL&&(window.CAP_CUSTOM_WASM_URL=new URL("https://cdn.mochabug.com/adapt/web/1.0.1-rc.30/cap_wasm_bg.wasm",window.location.href).href);import{timestampDate}from"@bufbuild/protobuf/wkt";let currentClient=null,currentAutomationId=null;const verificationTokens=new Map,redeemedChallengeExpirations=new Map;async function createChallenge(client,id){const response=await client.createChallenge({id}),instrumentation=response.instrumentation;return{count:response.count,size:response.size,difficulty:response.difficulty,expires:response.expires?timestampDate(response.expires):new Date,token:response.token,verificationToken:response.verificationToken,...instrumentation?{instrumentation}:{}}}async function redeemChallenge(client,id,verificationToken,solutions,options={}){const request={id,verificationToken,solutions,...options.instrumentation?{instrumentation:options.instrumentation}:{},...options.instrumentationBlocked?{instrumentationBlocked:!0}:{},...options.instrumentationTimeout?{instrumentationTimeout:!0}:{}},response=await client.redeemChallenge(request);return{token:response.token,expires:response.expires?timestampDate(response.expires):new Date}}function takeRedeemedChallengeExpiration(automationId){const expires=redeemedChallengeExpirations.get(automationId)??null;return expires&&redeemedChallengeExpirations.delete(automationId),expires}typeof window<"u"&&(window.CAP_CUSTOM_FETCH=async(url,options)=>{const urlStr=url.toString();if(urlStr.endsWith("/challenge")){if(!currentClient||!currentAutomationId)return new Response(JSON.stringify({error:"Cap adapter not initialized"}),{status:500,headers:{"Content-Type":"application/json"}});try{const challengeInfo=await createChallenge(currentClient,currentAutomationId);return verificationTokens.set(currentAutomationId,challengeInfo.verificationToken),redeemedChallengeExpirations.delete(currentAutomationId),new Response(JSON.stringify({challenge:{c:challengeInfo.count,s:challengeInfo.size,d:challengeInfo.difficulty},token:challengeInfo.token,expires:challengeInfo.expires.toISOString(),...challengeInfo.instrumentation?{instrumentation:challengeInfo.instrumentation}:{}}),{status:200,headers:{"Content-Type":"application/json"}})}catch(error){return new Response(JSON.stringify({error:String(error)}),{status:500,headers:{"Content-Type":"application/json"}})}}if(urlStr.endsWith("/redeem")){if(!currentClient||!currentAutomationId)return new Response(JSON.stringify({error:"Cap adapter not initialized"}),{status:500,headers:{"Content-Type":"application/json"}});const verificationToken=verificationTokens.get(currentAutomationId);if(!verificationToken)return new Response(JSON.stringify({error:"No verification token found - challenge must be created first"}),{status:400,headers:{"Content-Type":"application/json"}});try{const body=options?.body?JSON.parse(options.body):{},solutions=(body.solutions||[]).map(s=>BigInt(s)),instrumentationBlocked=body.instr_blocked===!0||body.instr?.__blocked===!0,instrumentationTimeout=body.instr_timeout===!0||body.instr?.__timeout===!0,instrumentation=body.instr&&!instrumentationBlocked&&!instrumentationTimeout?body.instr:void 0,redeemed=await redeemChallenge(currentClient,currentAutomationId,verificationToken,solutions,{...instrumentation?{instrumentation}:{},...instrumentationBlocked?{instrumentationBlocked}:{},...instrumentationTimeout?{instrumentationTimeout}:{}});return redeemedChallengeExpirations.set(currentAutomationId,redeemed.expires),verificationTokens.delete(currentAutomationId),new Response(JSON.stringify({success:!0,token:redeemed.token,expires:redeemed.expires.toISOString()}),{status:200,headers:{"Content-Type":"application/json"}})}catch(error){return new Response(JSON.stringify({error:String(error)}),{status:500,headers:{"Content-Type":"application/json"}})}}return fetch(url,options)});function setupCapAdapter(client,automationId){currentAutomationId&&currentAutomationId!==automationId&&(verificationTokens.delete(currentAutomationId),redeemedChallengeExpirations.delete(currentAutomationId)),currentClient=client,currentAutomationId=automationId,redeemedChallengeExpirations.delete(automationId)}function cleanupCapAdapter(){currentAutomationId&&(verificationTokens.delete(currentAutomationId),redeemedChallengeExpirations.delete(currentAutomationId)),currentClient=null,currentAutomationId=null}export{cleanupCapAdapter,createChallenge,redeemChallenge,setupCapAdapter,takeRedeemedChallengeExpiration};