===============
LIBRARY RULES
===============
From library maintainers:
- CANARY extends spoken-token with duress detection — a wrong token signals coercion without alerting the coercer.
- Verification is bilateral — both parties prove liveness, not just the subject.
- Group verification supports M-of-N threshold checks.
### Explain Account Path Choices
Source: https://github.com/forgesworn/canary-kit/blob/main/canary.html
Provides an explanation for choosing between different account derivation paths, specifically mentioning `nsec` roots and mnemonic-backed roots for `nsec-tree` hierarchy. Useful for guiding users on account setup.
```html
Which path should I choose?
Both imported nsec roots and mnemonic-backed roots can derive the full nsec-tree hierarchy.
```
--------------------------------
### Install canary-kit
Source: https://github.com/forgesworn/canary-kit/blob/main/llms.txt
Command to install the library via npm.
```bash
npm install canary-kit
```
--------------------------------
### Run Beacon Encryption Example
Source: https://github.com/forgesworn/canary-kit/blob/main/examples/README.md
Execute the encrypted location beacons example script. Requires Node.js 22+.
```bash
node examples/04-beacon-encryption.ts
```
--------------------------------
### Run Phone Verification Example
Source: https://github.com/forgesworn/canary-kit/blob/main/examples/README.md
Execute the phone verification example script. Requires Node.js 22+ and tsx/ts-node.
```bash
node examples/01-phone-verification.ts
```
```bash
npx tsx examples/01-phone-verification.ts
```
--------------------------------
### Initialize Project Environment
Source: https://github.com/forgesworn/canary-kit/blob/main/CONTRIBUTING.md
Commands to clone the repository and install necessary dependencies.
```bash
git clone https://github.com/forgesworn/canary-kit.git
cd canary-kit
npm install
```
--------------------------------
### Run Duress Detection Example
Source: https://github.com/forgesworn/canary-kit/blob/main/examples/README.md
Execute the duress detection example script for silent alerting. Requires Node.js 22+.
```bash
node examples/03-duress-detection.ts
```
--------------------------------
### Build Canary Kit Library
Source: https://github.com/forgesworn/canary-kit/blob/main/examples/README.md
Compile the library before running examples. Assumes Node.js 22+.
```bash
npm run build
```
--------------------------------
### Run Family Group Example
Source: https://github.com/forgesworn/canary-kit/blob/main/examples/README.md
Execute the family group example script, demonstrating safe words and duress detection. Requires Node.js 22+.
```bash
node examples/02-family-group.ts
```
--------------------------------
### Run Nostr Events Example
Source: https://github.com/forgesworn/canary-kit/blob/main/examples/README.md
Execute the example script for building Nostr events for the CANARY protocol. Requires Node.js 22+.
```bash
node examples/05-nostr-events.ts
```
--------------------------------
### Initialize Constants
Source: https://github.com/forgesworn/canary-kit/blob/main/canary.html
Initializes constants and performs necessary setup for the library. This should be called once before using other functions.
```javascript
var dA,fA,pA=o((()=>{
am(),
A(),
vm(),
Ah(),
nl(),
LT(),
dA=25519,
fA=35520
}))
```
--------------------------------
### Initialize Canary Kit
Source: https://github.com/forgesworn/canary-kit/blob/main/canary.html
Initializes the Canary Kit by calling various setup functions and initializing global state variables.
```javascript
var FE,IE,LE,RE,zE,BE,VE=o(((()=>{am(),A(),vm(),Bp(),Qg(),y(),Ru(),FE=new Map,IE=new Map,LE=6e4,RE=new Set,zE=[`wss://purplepag.es`,`wss://relay.damus.io`,`wss://nos.lol`],BE=zE}));
```
--------------------------------
### Developer Derivation Example
Source: https://github.com/forgesworn/canary-kit/blob/main/canary.html
This example demonstrates how to derive child identities. It requires a local key; browser extensions cannot be used here as they keep the secret key hidden.
```html
Developer derivation example
Enter up to three tree levels plus explicit indices and canary-kit recreates the deterministic child identity, including its npub and nsec.
${s&&s.length<=3?:
`}
${
[0,1,2].map(e=>`
Level ${e+1}
`).join(
`
`)}
${s?
`Selected path: ${Y(s.map(e=>`${e.name}@${e.index??0}`).join(` / `))}${s.length>3?
` — this example only exposes the first three tree levels, so fill it manually if you need a deeper path.`:
`}`:
`Tip: select a persona in the tree, then load it here to show that the same derivation inputs recreate the same identity. Change indices to match rotated personas.`}
${zM()}
```
```html
Developer derivation example
This needs a local key. Browser extensions keep the raw secret hidden, so canary-kit cannot recreate child identities here.
```
--------------------------------
### Initialize Canary Kit
Source: https://github.com/forgesworn/canary-kit/blob/main/canary.html
Initializes the entire Canary Kit, including personas, hashing, and other utilities. This is a one-time setup call.
```javascript
var U,Lu,Ru=o((()=>{nu(),hu(),ts(),yu(),A(),U=null,Lu=new Map}))
```
--------------------------------
### Initialize Canary Kit
Source: https://github.com/forgesworn/canary-kit/blob/main/canary.html
Initializes canary-kit by calling setup functions for various components. Sets up regular expressions and constants for group management.
```javascript
var Nl,Pl,Fl=o(((()=>{nl(),pl(),Cl(),Tl(),Nl=/^\x5B0-9a-f\x5D{64}$/,Pl=100})))
```
--------------------------------
### Initialize Login Screen UI
Source: https://github.com/forgesworn/canary-kit/blob/main/canary.html
Sets up the main application container and renders the login screen UI, including options for connecting with Nostr or a quick start.
```javascript
function yF(){let e=document.getElementById(`app`);e.innerHTML=`
CANARY
Deepfake-proof identity verification
Connect with Nostr
Sync groups across devices via relays.
Quick Start
No Nostr account needed.
```
--------------------------------
### Session-based Phone Verification Example
Source: https://github.com/forgesworn/canary-kit/blob/main/llms.txt
Example of creating and using a session for phone verification, typically used in call centers.
```APIDOC
## Quick Examples: Session-based Phone Verification
```typescript
// --- Session-based phone verification (bank/insurance call centre) ---
import { createSession } from 'canary-kit/session'
const session = createSession({
secret: sharedSecretHex,
namespace: 'aviva',
roles: ['caller', 'agent'],
myRole: 'agent',
preset: 'call', // 30-second rotation, tolerance 1, directional
theirIdentity: customerId, // enables duress detection
})
// The caller speaks session.theirToken() — the agent hears and verifies:
const result = session.verify(spokenWord)
// result.status === 'valid' | 'duress' | 'invalid'
// result.identities → who signalled duress (if any)
```
```
--------------------------------
### Initialize Crypto Utilities
Source: https://github.com/forgesworn/canary-kit/blob/main/canary.html
Initializes cryptographic utilities, including checking for available crypto APIs like `getRandomValues`. This setup is necessary before using cryptographic functions.
```javascript
var sv,cv,lv,uv,dv=o(((()=>{U_(),sv=typeof Uint8Array.from([]).toHex==`function`&&typeof Uint8Array.fromHex==`function`,cv=Array.from({length:256},(e,t)=>t.toString(16).padStart(2,`0`)),lv={_0:48,_9:57,A:65,F:70,a:97,f:102},uv=class{}})))\n
```
--------------------------------
### Initialize Constants and Utilities
Source: https://github.com/forgesworn/canary-kit/blob/main/canary.html
Initializes constants and utility functions for hex encoding/decoding and other internal operations. This is part of the library's setup.
```javascript
var Qu,$u,ed,td,nd=o((()=>{Qu=typeof Uint8Array.from(\[\]).toHex==\`function\`&&typeof Uint8Array.fromHex==\`function\`,$u=Array.from({length:256},(e,t)=>t.toString(16).padStart(2,\`0\`)),ed={\_0:48,\_9:57,A:65,F:70,a:97,f:102},td=e=>({oid:Uint8Array.from(\[6,9,96,134,72,1,101,3,4,2,e\])}))}))
```
--------------------------------
### Initialize Application and Load Data
Source: https://github.com/forgesworn/canary-kit/blob/main/canary.html
Initializes the application by calling various setup functions and loading necessary data. This is typically the entry point for the application's frontend logic.
```javascript
var wA,TA=o((',()=>{A(),LD(),Sk(),Pk(),CO(),y(),tA(),dE(),BT(),pA(),uE(),Cl(),HD(),VE(),wA=[210,140,30,280,60,330,170,0]})),EA=\`0123456789bcdefghjkmnpqrstuvwxyz\`,DA=Object.create(null);for(let e=0;e<32;e++)DA[EA[e]]=e
```
--------------------------------
### Group-based Family Verification Example
Source: https://github.com/forgesworn/canary-kit/blob/main/llms.txt
Example of creating and using a group for family verification with rotating passphrases.
```APIDOC
## Quick Examples: Group-based Family Verification
```typescript
// --- Group-based family verification (weekly rotating passphrase) ---
import { createGroup, getCurrentWord, getCurrentDuressWord, verifyWord, getCounter } from 'canary-kit'
const group = createGroup({ preset: 'family', members: [alicePubkey, bobPubkey] })
const word = getCurrentWord(group) // e.g. "granite"
// On a call, Alice says the current word. Bob verifies:
const counter = getCounter(Math.floor(Date.now() / 1000), group.rotationInterval)
const result = verifyWord(spokenWord, group.seed, group.members, counter, group.wordCount)
// result.status === 'verified' | 'duress' | 'stale' | 'failed'
// If Alice is under coercion, she says her duress word instead:
const duressWord = getCurrentDuressWord(group, alicePubkey) // always distinct from the normal word
```
```
--------------------------------
### Full ECDSA Setup
Source: https://github.com/forgesworn/canary-kit/blob/main/canary.html
Combines curve, hash, and ECDSA options for a complete cryptographic setup. Used for initializing signing and verification contexts.
```javascript
function $y(e){let{CURVE:t,curveOpts:n,hash:r,ecdsaOpts:i}=Zy(e);return Qy(e,Yy(Gy(t,n),r,i))}
```
--------------------------------
### Handle User Login and Identity Setup
Source: https://github.com/forgesworn/canary-kit/blob/main/canary.html
Handles user login by decoding a bech32-encoded private key, setting up the identity, and dispatching a resync event. Optionally publishes a Kind 0 event if a display name is provided.
```typescript
function $D(e,t,n){try{let r=e.data;let i=XE(r),a=ZE({pubkey:hm(r),privkey:i,signerType:
`local`,
displayName:t??`You`},n);return oE(),S({identity:a,groups:{},activeGroupId:null}),YE(),document.dispatchEvent(new CustomEvent(`canary:resync`)),t&&t!==`You`&&X(async()=>{let{publishKind0:e}=await Promise.resolve().then(()=>(VE(),wE));return{publishKind0:e}},void 0,import.meta.url).then(({publishKind0:e})=>e(t,i)),!0}catch{return alert(`Invalid nsec format.`),!1}}
```
--------------------------------
### Initialize Application State
Source: https://github.com/forgesworn/canary-kit/blob/main/canary.html
Sets up the initial state of the application, including default settings and known relays.
```javascript
var D,O,k,A=o((()=>{
y(),D={
view:
`groups`
,groups:{},activeGroupId:null,identity:null,settings:{theme:
`dark`
,pinEnabled:!1,autoLockMinutes:5,knownRelays:p(
[v,..._]
),defaultRelays:[
v
],
defaultReadRelays:[
..._,
v
],
defaultWriteRelays:[
v
]
},personas:{},activePersonaId:null,deletedGroupIds:[
]
},O=structuredClone(D),k=new Set})))
```
--------------------------------
### Get Signet Signer
Source: https://github.com/forgesworn/canary-kit/blob/main/canary.html
Retrieves a Signet signer, ensuring it's available and capable of signing. If not interactive, it throws an error. Use this to get a signer for cryptographic operations.
```typescript
async function OT(e,t={}){if(!bT(e))throw Error(`Signet signer requested for a local identity.`);let n=await ET();if(n?.pubkey===e.pubkey&&_T(n.signer))return n.signer;if(!t.interactive)throw Error(`Signet signer is not available. Sign in with Signet again.`);let r=await TT({preferredMethod:yT(e),theme:t.theme,displayNameFallback:e.displayName});if(!r||!IT)throw Error(`Signet login was cancelled.`);if(r.pubkey!==e.pubkey)throw await DT(),Error(`Signet returned a different public key. Switch back to the original account and try again.`);return IT.signer}
```
--------------------------------
### Configure Connection Options
Source: https://github.com/forgesworn/canary-kit/blob/main/canary.html
Sets up connection options, including relay URLs, challenge, timeout, and preferred connection methods. It ensures valid inputs and provides defaults.
```javascript
function Iw(e){let t=e.relayUrls??(e.relayUrl?[e.relayUrl]:[Jh.relayUrl]);return t.map(e=>e.trim()).filter(Boolean).length>0?t:[Jh.relayUrl]}
function Lw(e){let t=e.challenge??hw();if(!/^\p{Xan}+$/iu.test(t))throw Error("challenge-must-be-64-hex");let n=typeof window<"u"?window.location.origin:`http://localhost`,r=Math.max(5e3,Math.min(e.timeout??Jh.timeout,6e5)),i=Iw(e),a=Fw(e),o={appName:e.appName,challenge:t.toLowerCase(),origin:n,methods:a.methods,advancedMethods:a.advancedMethods,relayUrl:i[0],relayUrls:i,nostrConnectPerms:e.nostrConnectPerms??Kw,theme:e.theme??Jh.theme,timeout:r,signetAppOrigin:e.signetAppOrigin??Jh.signetAppOrigin};return e.preferredMethod!==void 0&&(o.preferredMethod=e.preferredMethod),e.redirectCallback!==void 0&&(o.redirectCallback=e.redirectCallback),o}
```
--------------------------------
### Get Signer Method Name
Source: https://github.com/forgesworn/canary-kit/blob/main/canary.html
Returns a human-readable name for the signer method.
```typescript
function ST(e){switch(e){case`nip07`:return`Browser extension`;case`bunker`:return`NIP-46 bunker`;case`redirect`:return`Signet`;case`amber`:return`Amber`;case`nsec`:return`nsec`;default:return`Signet`}}
```
--------------------------------
### Initialize crypto constants and helpers
Source: https://github.com/forgesworn/canary-kit/blob/main/canary.html
Sets up internal constants and checks for the availability of toHex/fromHex methods on Uint8Array. This is an initialization step for crypto utilities.
```javascript
var px,mx,hx,gx,_x=o((()=>{Yb(),px=typeof Uint8Array.from([]).toHex===\`function\&&typeof Uint8Array.fromHex===\`function\`,mx=Array.from({length:256},(e,t)=>t.toString(16).padStart(2,\`0\`)),hx={\_0:48,\_9:57,A:65,F:70,a:97,f:102},gx=class{}}));
```
--------------------------------
### Get Public Key
Source: https://github.com/forgesworn/canary-kit/blob/main/canary.html
Derives the public key from a given private key.
```APIDOC
## getPublicKey
### Description
Derives the public key from a given private key.
### Parameters
#### Path Parameters
- **privateKey** (Uint8Array) - The private key.
### Returns
- **Uint8Array** - The corresponding public key.
```
--------------------------------
### Get session tokens
Source: https://github.com/forgesworn/canary-kit/blob/main/llms-full.txt
Retrieves the token to present or the token expected from the other party.
```typescript
session.myToken(): string // e.g. 'marble'
session.theirToken(): string // e.g. 'lantern'
```
--------------------------------
### Initialize and Start Auto-Lock
Source: https://github.com/forgesworn/canary-kit/blob/main/canary.html
Attaches event listeners for pointerdown and keydown to trigger the auto-lock sequence and calls QP() to set the initial timer. Also ensures eF() is called on cleanup.
```javascript
function $P(){document.addEventListener(
`pointerdown`,
QP,
{passive:!0}
),
document.addEventListener(
`keydown`,
QP,
{passive:!0}
),
QP()}
```
--------------------------------
### Get Current State
Source: https://github.com/forgesworn/canary-kit/blob/main/canary.html
Returns the current application state, with sensitive identity information redacted.
```javascript
function x(){return O}
```
--------------------------------
### Perform Initialization
Source: https://github.com/forgesworn/canary-kit/blob/main/canary.html
Ensures all necessary Canary Kit modules and configurations are loaded and ready. This should be called before using other Canary Kit functions.
```typescript
function wD=o((()=>{
lD(),pl(),uD(),Cl(),nl(),Fl(),Tl(),CD()
}))
```
--------------------------------
### Initialize Canary Kit
Source: https://github.com/forgesworn/canary-kit/blob/main/canary.html
Initializes the Canary Kit, setting up global event handlers and exposing the Signet API to the window object. This should be called once on application load.
```javascript
var qb=o(((()=>{Mb(),Pb(),dv(),Ah(),typeof window<\`u\&&(window.Signet={verifyAge:Hb,waitForAuthResponse:Kb})})),Jb,Yb=o(((()=>{Jb=typeof globalThis==\`object\&&\`crypto\`in globalThis?globalThis.crypto:void 0})));
```
--------------------------------
### Get Node Type
Source: https://github.com/forgesworn/canary-kit/blob/main/canary.html
Returns the node type, defaulting to 'persona' if the nodeType property is not present.
```javascript
function h(e){return e.nodeType?e.nodeType:
`persona`
}
```
--------------------------------
### Get Shared Secret
Source: https://github.com/forgesworn/canary-kit/blob/main/canary.html
Computes the shared secret between two parties using their public and private keys.
```APIDOC
## getSharedSecret
### Description
Computes the shared secret between two parties using their public and private keys.
### Parameters
#### Path Parameters
- **privateKey** (Uint8Array) - Your private key.
- **publicKey** (Uint8Array) - The other party's public key.
### Returns
- **Uint8Array** - The computed shared secret.
```
--------------------------------
### Initialize Default Relays
Source: https://github.com/forgesworn/canary-kit/blob/main/canary.html
Sets up default relay lists and a fallback relay URL.
```javascript
var _,
v,
y=o((()=>{
_=[`wss://nos.lol`,`wss://relay.damus.io`,`wss://relay.nostr.band`,`wss://relay.primal.net`,`wss://relay.ditto.pub`],
v=`wss://relay.trotters.cc`
})))
```
--------------------------------
### Get Display Name for Node Type
Source: https://github.com/forgesworn/canary-kit/blob/main/canary.html
Returns 'Account' for 'account' node types and 'Persona' for others.
```javascript
function g(e){return h(e)===
`account`
?
`Account`
:
`Persona`
}
```
--------------------------------
### Get Current Theme
Source: https://github.com/forgesworn/canary-kit/blob/main/canary.html
Determines the current theme (light or dark) based on the `data-theme` attribute of the document element.
```javascript
function HE(){return document.documentElement.getAttribute(`data-theme`)===\`light\`?`light`:`dark`}
```
--------------------------------
### Display and Copy Welcome Message
Source: https://github.com/forgesworn/canary-kit/blob/main/canary.html
Renders the UI for the 'Send Welcome' step, allowing users to copy an encrypted welcome message. It also includes an optional field for the member's name and a 'Done' button to finalize the process.
```javascript
function c(t,n){a.innerHTML=`
Step 3 of 3: Send Welcome
Copy this encrypted message and send it back to them.
This is encrypted — only they can read it.
`,
a.querySelector(`#remote-copy-welcome`)?.addEventListener(`click`,async e=>{let n=e.currentTarget;try{await navigator.clipboard.writeText(t),n.textContent=`Copied!`,n.classList.add(`btn--copied`),setTimeout(()=>{n.textContent=`Copy Welcome Message`,n.classList.remove(`btn--copied`)
)},2e3)}catch{}}),a.querySelector(`#remote-done`)?.addEventListener(`click`,()=>{try{let t=x().groups\[e.id\];if(t&&!t.members.includes(n)){let t=a.querySelector(`#remote-joiner-name`)?.value.trim()??`
`;MD(e.id,n,t),J(t?
`${t} added to group`:
`Member added to group`,
`success`
)}}
catch(e){J(e instanceof Error?e.message:
`Failed to add member`,
`error`
)}
fk(),ok(),a.close()
})}
```
--------------------------------
### Get Default Window Size
Source: https://github.com/forgesworn/canary-kit/blob/main/canary.html
Returns the default window size for scalar multiplication, which is 1 if not otherwise specified.
```javascript
function FS(e) { return WS.get(e) || 1; }
```
--------------------------------
### Get Signature Bytes
Source: https://github.com/forgesworn/canary-kit/blob/main/canary.html
Extracts the byte representation of a signature scalar. This is a utility function for handling signature data.
```javascript
function or(e){return rr(e).bytes}
```
--------------------------------
### Get Session Tokens
Source: https://github.com/forgesworn/canary-kit/blob/main/llms-full.txt
Retrieves both caller and agent tokens for a session. Useful for establishing a secure communication channel.
```typescript
session.pair(): DirectionalPair
```
```typescript
session.pair()
// { caller: 'marble', agent: 'lantern' }
```
--------------------------------
### Prepare and Fire Subscription
Source: https://github.com/forgesworn/canary-kit/blob/main/canary.html
Prepares a new subscription with specified filters and options, then fires the request to the relay. Handles potential abort signals.
```typescript
subscribe(e, t) {
t.label !== `` && (this.idleSince = void 0, this.ongoingOperations++);
let n = this.prepareSubscription(e, t);
return n.fire(), t.abort && (t.abort.onabort = () => n.close(String(t.abort.reason || ``))), n;
}
```
--------------------------------
### Initialize Personas
Source: https://github.com/forgesworn/canary-kit/blob/main/canary.html
Initializes the personas system with a master private key and an optional array of persona configurations. Clears existing personas.
```javascript
function Tu(e,t){if(!e.privkey||e.signerType===\`nip07\`)return{};U&&(U.destroy(),U=null,Lu.clear()),U=ko(xu(e.privkey));let n={};if(t&&t.length>0)for(let e of t){let t=Yo(U,e,0),r=Su(t);Lu.set(r.id,t),n[r.id]=r}return n}
```
--------------------------------
### Get Index of Word
Source: https://github.com/forgesworn/canary-kit/blob/main/llms-full.txt
Finds the index of a given word within the wordlist. Returns -1 if the word is not found.
```typescript
indexOf(word: string): number
```
```typescript
indexOf('marble') // e.g. 1103
```
```typescript
indexOf('unknown') // -1
```
--------------------------------
### Meshtastic Payload Design
Source: https://github.com/forgesworn/canary-kit/blob/main/WALKTHROUGH.md
Example payload structures for beacon, liveness, and duress messages optimized for LoRa bandwidth constraints.
```text
Beacon: "b:gcpuuz:1709571200" (~25 bytes)
Liveness: "l:1709571200" (~15 bytes)
Duress: "d:gcpuuzzx:1709571200" (~25 bytes — high-precision geohash)
```
--------------------------------
### Initialize Canary Kit Components
Source: https://github.com/forgesworn/canary-kit/blob/main/canary.html
Initializes core components of the Canary Kit, including cryptographic functions and state management. This is a foundational step for using the kit.
```javascript
var ID,LD=o((()=>{wD(),A(),uE(),y(),ID=/^\\\[0-9a-f\\\\]{64}$/}));cD(),LD(),A();
```
--------------------------------
### Handle Sign-in Method Selection
Source: https://github.com/forgesworn/canary-kit/blob/main/canary.html
Manages the display and selection of sign-in methods, including primary and advanced options. It sets up event listeners for button clicks to initiate the chosen sign-in flow.
```javascript
function Dw(e,t){let n=gw(t.theme),r=n?`#888`:`#666`;return new Promise(i=>{let a=!1,o=qw.filter(Tw),s=new Set(t.advancedMethods.map(Cw)),c=o.filter(e=>!s.has(Cw(e))),l=o.filter(e=>s.has(Cw(e))),u=()=>{e.dialog.querySelectorAll(`button[data-choice]`).forEach(e=>{e.addEventListener(`click`,()=>{let t=e.dataset.choice;i(t)})}),e.dialog.querySelector(`[data-action="advanced"]`)?.addEventListener(`click`,()=>{a=!0,d()})},d=()=>{let i=a||c.length===0,s=c.map((e,t)=>Ew(e,n,r,t===0)).join(``),d=i?l.map((e,t)=>Ew(e,n,r,c.length===0&&t===0)).join(``):``,f=l.length>0&&!i?``:``,p=o.length===0?
No configured sign-in methods are available on this device.
`:``;e.dialog.innerHTML=`
Sign in to ${mw(t.appName)}
Choose how you want to sign in. Your keys never leave your control.
${p} ${s} ${f} ${d}
`,u()};d()})}
```
--------------------------------
### Reed-Solomon Decoder Initialization
Source: https://github.com/forgesworn/canary-kit/blob/main/canary.html
Initializes a Reed-Solomon decoder with a given generator polynomial and message data. This setup is necessary before decoding.
```javascript
function c(e,t){var n=new Uint8ClampedArray(e.length);n.set(e);for(var c=new r.default(285,256,0),l=new i.default(c,n),u=new Uint8ClampedArray(t),d=!1,f=0;f()=>(e&&(t=e(e=0)),t),s=(e,t)=>()=>(t||(e((t={exports:{}}).exports,t),e=null),t.exports),c=(e,n)=>{let r={};for(var i in e)t(r,i,{get:e[i],enumerable:!0});return n||t(r,Symbol.toStringTag,{value:
`Module`
}),r},l=(e,i,o,s)=>{if(i&&typeof i==`object`||typeof i==`function`)for(var c=r(i),l=0,u=c.length,d;li[e]).bind(null,d),enumerable:!(s=n(i,d))||s.enumerable});return e},u=(n,r,a)=>(a=n==null?{}:e(i(n)),l(r||!n||!n.__esModule?t(a,
`default`
,{value:n,enumerable:!0}):a,n));(function(){let e=document.createElement(`link`).relList;if(e&&e.supports&&e.supports(
`modulepreload`
))return;for(let e of document.querySelectorAll(`link[rel="modulepreload"]`))n(e);new MutationObserver(e=>{
for(let t of e)if(t.type===
`childList`
)for(let e of t.addedNodes)e.tagName===
`LINK`
&&e.rel===
`modulepreload`
&&n(e)
}).observe(document,{childList:!0,subtree:!0});function t(e){let t={};
return e.integrity&&(t.integrity=e.integrity),e.referrerPolicy&&(t.referrerPolicy=e.referrerPolicy),e.crossOrigin===
`use-credentials`
?t.credentials=
`include`
:e.crossOrigin===
`anonymous`
?t.credentials=
`omit`
:t.credentials=
`same-origin`
,t}
function n(e){if(e.ep)return;e.ep=!0;let n=t(e);fetch(e.href,n)}
})();
```
--------------------------------
### Get Identity Type
Source: https://github.com/forgesworn/canary-kit/blob/main/canary.html
Returns a description of the identity type, indicating whether it's a local key or managed by Signet.
```typescript
function CT(e){return e?e.privkey||e.signerType===\`local\`?
`Local key`:
`Signet (${ST(e.signerMethod)})
`:
`None`}
```
--------------------------------
### Create Welcome Envelope
Source: https://github.com/forgesworn/canary-kit/blob/main/canary.html
Constructs a welcome envelope for a new member joining a group. This can be done using a local private key or a Signet signer.
```typescript
async function dk(e,t){let{identity:n}=x();if(!n?.pubkey)throw Error("No identity — sign in first.");if(!xk)throw Error("No active remote invite session — cannot create welcome envelope.");let r=lk(e,xk.inviteId);if(n.privkey)return MO({welcome:r,adminPrivkey:n.privkey,joinerPubkey:t});if(bT(n))return AT(n,t,JSON.stringify(r),{interactive:!0});throw Error("No local key or Signet signer — cannot create welcome envelope.")}
```
--------------------------------
### Get Persona by Name
Source: https://github.com/forgesworn/canary-kit/blob/main/canary.html
Retrieves a persona by its name, optionally specifying an index. If the persona is not found by name, it attempts to derive it.
```javascript
function ku(e,t=0){if(!U)throw Error(\`Personas not initialised — call initPersonas() first\`);let n=\_u(x().personas,e);if(n){let t=Lu.get(n.id);if(t)return t;let r=Yo(U,e,n.index);return Lu.set(n.id,r),r}let r=\`\_name:${e}:${t}\
e=Lu.get(r);return i||(i=Yo(U,e,t),Lu.set(r,i)),i}
```
--------------------------------
### Get Current Verification Word
Source: https://github.com/forgesworn/canary-kit/blob/main/llms-full.txt
Retrieves the current verification word or phrase for all members of a group based on the provided state.
```typescript
getCurrentWord(state: GroupState): string
```
```typescript
getCurrentWord(state) // e.g. 'marble' or 'marble lantern' (if wordCount=2)
```
--------------------------------
### SHA-256 Constants and Initialization
Source: https://github.com/forgesworn/canary-kit/blob/main/canary.html
Initializes SHA-256 constants and sets up the environment for hashing. This includes defining the initial hash values and round constants.
```javascript
var wc,Tc,Ec,Dc,Oc=o((()=>{
wc=[1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225],
Tc=new Uint32Array([
1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,
3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,
3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,
2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,
666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,
2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,
430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,
1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298
]),
Ec=64,
Dc=new TextEncoder()
}))
```
--------------------------------
### Import Specific Canary Kit Modules
Source: https://github.com/forgesworn/canary-kit/blob/main/README.md
Demonstrates how to import individual modules from Canary Kit for efficient tree-shaking. Each import targets a specific functionality.
```typescript
import { createSession } from 'canary-kit/session'
import { deriveToken } from 'canary-kit/token'
import { encodeAsWords } from 'canary-kit/encoding'
import { WORDLIST } from 'canary-kit/wordlist'
import { buildGroupStateEvent } from 'canary-kit/nostr'
import { encryptBeacon } from 'canary-kit/beacon'
import { applySyncMessage } from 'canary-kit/sync'
```
--------------------------------
### Check String Prefix Match
Source: https://github.com/forgesworn/canary-kit/blob/main/canary.html
Checks if a given string, after trimming and converting to lowercase, starts with any of the prefixes in a provided array.
```javascript
function xw(e,t){let n=e.trim().toLowerCase();return t.some(e=>n.startsWith(e))}
```
--------------------------------
### jsQR Library Initialization
Source: https://github.com/forgesworn/canary-kit/blob/main/canary.html
Initializes the jsQR library, making it available globally or via module systems.
```javascript
(function(n,r){typeof e==`object`&&typeof t==`object`?t.exports=r():typeof define==`function`&&define.amd?define([],r):typeof e==`object`?e.jsQR=r():n.jsQR=r()})(typeof self<`u`?self:e,function(){return(function(e){var t={};function n(r){if(t[r])return t[r].exports;var i=t[r]={i:r,l:!1,exports:{}};return e[r].call(i.exports,i,i.exports,n),i.l=!0,i.exports}return n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{configurable:!1,enumerable:!0,get:r})},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,`a`,t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p=`
`,n(n.s=3)})([(function(e,t,n){Object.defineProperty(t,"__esModule",{value:!0}),t.BitMatrix=function(){function e(e,t){this.width=t,this.height=e.length/t,this.data=e}return e.createEmpty=function(t,n){return new e(new Uint8ClampedArray(t*n),t)},e.prototype.get=function(e,t){return e<0||e>=this.width||t<0||t>=this.height?!1:!!this.data[t*this.width+e]},e.prototype.set=function(e,t,n){this.data[t*this.width+e]=+!!n},e.prototype.setRegion=function(e,t,n,r,i){for(var a=t;a=this.size&&(i=(i^this.primitive)&this.size-1);for(var a=0;a{Pm(),Xm=class{
blockLen=16;
outputLen=16;
buffer=new Uint8Array(16);
r=new Uint16Array(10);
h=new Uint16Array(10);
pad=new Uint16Array(8);
pos=0;
finished=!1;
constructor(e){e=Nm(Sm(e,32,
`key`
));let t=Jm(e,0),n=Jm(e,2),r=Jm(e,4),i=Jm(e,6),a=Jm(e,8),o=Jm(e,10),s=Jm(e,12),c=Jm(e,14);
this.r[0]=t&8191,this.r[1]=(t>>>13|n<<3)&8191,this.r[2]=(n>>>10|r<<6)&7939,this.r[3]=(r>>>7|i<<9)&8191,this.r[4]=(i>>>4|a<<12)&255,this.r[5]=a>>>1&8190,this.r[6]=(a>>>14|o<<2)&8191,this.r[7]=(o>>>11|s<<5)&8065,this.r[8]=(s>>>8|c<<8)&8191,this.r[9]=c>>>5&127;
for(let t=0;t<8;t++)this.pad[t]=Jm(e,16+2*t)}
process(e,t,n=!1){let
```
--------------------------------
### Initialize Canary Kit UI Components
Source: https://github.com/forgesworn/canary-kit/blob/main/canary.html
Initializes various UI components for the Canary Kit, including rendering modals and setting up event listeners. This should be called once on page load.
```javascript
var vP,yP,bP=o(((()=>{Ru(),A(),yu(),dE(),yE(),y(),nu(),fu(),Qg(),vP=`linkage-prove-dialog`,yP=`linkage-verify-dialog`})()))
```
--------------------------------
### Get Persona Type Description
Source: https://github.com/forgesworn/canary-kit/blob/main/canary.html
Returns a descriptive string for a given persona type. Currently supports 'account' with a specific description.
```javascript
function jM(e){return h(e)===`account`?`A standalone child key you can export as an nsec account.`:`A `
```
--------------------------------
### Initialize Canary Kit Modules
Source: https://github.com/forgesworn/canary-kit/blob/main/canary.html
Initializes various modules and constants required for the Canary Kit's operation, including regular expressions and key encodings.
```typescript
var yD,bD,xD,SD,CD=o((()=>{
nl(),yD=/^[
0-9a-f]]{64}$/,
bD=/^[
0-9b-hjkmnp-z]]{1,11}$/,
xD=new TextEncoder().encode(
`canary:beacon:key`
),
SD=new TextEncoder().encode(
`canary:duress:key`
)
}))
```
--------------------------------
### constructor
Source: https://github.com/forgesworn/canary-kit/blob/main/canary.html
Initializes a new instance of the Relay Manager. It accepts an options object to configure various aspects of the relay connection and event handling.
```APIDOC
## constructor
### Description
Initializes a new instance of the Relay Manager. It accepts an options object to configure various aspects of the relay connection and event handling.
### Parameters
- **e** (object) - Options object for configuration:
- **verifyEvent** (function) - Function to verify events.
- **websocketImplementation** (object) - The WebSocket implementation to use.
- **enablePing** (boolean) - Whether to enable ping messages.
- **enableReconnect** (boolean) - Whether to enable automatic reconnection (defaults to false).
- **automaticallyAuth** (function) - Function to handle automatic authentication.
- **onRelayConnectionFailure** (function) - Callback for connection failures.
- **onRelayConnectionSuccess** (function) - Callback for successful connections.
- **allowConnectingToRelay** (function) - Function to control relay connection.
- **maxWaitForConnection** (number) - Maximum time to wait for a connection (defaults to 3000ms).
```
--------------------------------
### Get Best Mode for Data
Source: https://github.com/forgesworn/canary-kit/blob/main/canary.html
Determines the most efficient data mode (Numeric, Alphanumeric, Kanji, or Byte) for the given input data.
```javascript
e.getBestModeForData = function(t) {
return n.testNumeric(t) ? e.NUMERIC : n.testAlphanumeric(t) ? e.ALPHANUMERIC : n.testKanji(t) ? e.KANJI : e.BYTE
}
```