open-index/open-npm huggingface dataset:
npm package: @survicate/survicate-web-package
Description: Survicate Web Package
Author: Survicate
Latest version: 28.22.9-npm

# Survicate Web Package

This package enables you to integrate Survicate surveys into your web application. Built with [Preact](https://github.com/preactjs/preact), [TypeScript](https://github.com/Microsoft/TypeScript), and [CSS Modules](https://github.com/css-modules/css-modules).

## Installation

Install the package using NPM:

```bash
npm install @survicate/survicate-web-package --save
```

## Initialization

To initialize Survicate, you'll need your workspace key, which can be found in the [Survicate Panel](https://panel.survicate.com/o/0/w/0/settings/access-keys).

```javascript
import Survicate from '@survicate/survicate-web-package/survicate_widget';

// Replace with your actual workspace key
const workspaceKey = 'Your workspace key';

Survicate.init({ workspaceKey });
```

## Usage Examples

Here are some common methods you can utilize:

```javascript
import Survicate from '@survicate/survicate-web-package/survicate_widget';

// Initialize Survicate and provide user attributes
const config = {
  workspaceKey: 'Your workspace key',
  traits: {
    'user_id': 'Your user ID here',
    'company_name': 'Value here',
    'subscription_status': 'Value here',
    'signed_up': 'Value here'
  }
};

Survicate.init(config);

// Force display a specific survey
Survicate.showSurvey('survey id', { forceDisplay: true });

// Set visitor attributes and retarget afterwards
Survicate.setVisitorTraits({
  email: 'john_doe@example.com',
  first_name: 'John',
  last_name: 'Doe',
});

Survicate.retarget();

// Add an event listener for when a question is answered
Survicate.addEventListener(Survicate.ApiEvent.questionAnswered, (surveyId, surveyName) => {
  console.log(`A question was answered - survey: ${surveyName} ${surveyId}`);
});

// Remove the event listener
Survicate.removeEventListener(Survicate.ApiEvent.questionAnswered);
```

For a list of available methods and their detailed usage, please refer to the [Survicate JavaScript API Documentation](https://developers.survicate.com/javascript/methods/).

## Changelog

Stay updated with the latest changes and improvements by reviewing the [Survicate JavaScript SDK Changelog](https://developers.survicate.com/javascript/js-sdk-changelog/).
npm package: @survicate/survicate-web-surveys-wrapper
Description: Public Survicate web surveys wrapper
Author: Survicate
Latest version: 1.7.0

# Survicate Web Surveys Wrapper

This package is a wrapper which allows you to install the Survicate tracking code and use API methods directly in your code.
It's built on top of [Preact](https://github.com/preactjs/preact) using [Typescript](https://github.com/Microsoft/TypeScript)

# Installation

`npm install @survicate/survicate-web-surveys-wrapper --save`

# Initialization

Find your workspace key in the [Survicate Panel](https://panel.survicate.com/o/0/w/0/settings/access-keys).

Initialize Survicate using `initSurvicate`

**Please note:** *`initSurvicate` is asynchronous, so the user has to await its resolution. This should be done once. Handling asynchronous code depends on the use case.*


```javascript
import { initSurvicate, getSurvicateInstance, ApiEvent } from '@survicate/survicate-web-surveys-wrapper/widget_wrapper';

  const config = { workspaceKey: 'workspace key' };

  await initSurvicate(config).then(() => {
    const survicate = getSurvicateInstance();
    survicate.addEventListener(ApiEvent.questionAnswered, () => console.log('questionAnswered'));
  })

```

To define user attributes on Survicate initialization, pass it to `initSurvicate`

```javascript
const config = { workspaceKey: 'workspace key', traits: { name: 'John Doe', email: 'doe@john.com'} };

await initSurvicate(config);

```
<br/>

## Examples:

Usage in React:

```jsx
//Main component
import { getSurvicateInstance, initSurvicate } from '@survicate/survicate-web-surveys-wrapper/widget_wrapper';
import { Survicate } from '@survicate/survicate-web-surveys-wrapper';

function App() {
  const [survicate, setSurvicate] = useState<Survicate | null>(null);

  useEffect(() => {
    initSurvicate({ workspaceKey: 'workspace key' }).then(() => {
      setSurvicate(getSurvicateInstance());
    });
  }, []);

  return (
    <div className="App">
      <header className="App-header">
        <ChildComponent survicate={ survicate }/>
      </header>
    </div>
  );
}

export default App;

//Child component
import { Survicate } from '@survicate/survicate-web-surveys-wrapper';
import { ApiEvent } from '@survicate/survicate-web-surveys-wrapper/widget_wrapper';

interface Props {
  survicate: Survicate | null;
}

export const ChildComponent = ({survicate}: Props ) => {

useEffect(() => {
  if (!survicate) {
    return
  }

  survicate.addEventListener(ApiEvent.questionAnswered, () => console.log('questionAnswered'))
}, [survicate])

  return (
    <div>
      <h1>ChildComponent</h1>
    </div>
  )
}

```
<br/>

To call available methods:

```jsx
import  { getSurvicateInstance , ApiEvent } from '@survicate/survicate-web-surveys-wrapper/widget_wrapper';

//Initialize survicate, then use:
const survicate = getSurvicateInstance();

// Set user attributes
survicate.setVisitorTraits({newName: 'newName', newEmail: 'newEmail'});

```
*Please refer to the [documentation](https://developers.survicate.com/javascript/methods/) for the rest of the methods.*
npm package: @survivorshield/shield
Description: Drop-in SDK for Shield Router Oracle — risk-aware execution control for Solana
Author: SURVIVOR
Latest version: 1.0.1

# @survivorshield/shield

Drop-in SDK for [Shield Router Oracle](https://survivor-oracle-production.up.railway.app/docs) — risk-aware execution control for Solana.

Zero dependencies. Works in Node 16+.

## Install
```bash
npm install @survivorshield/shield
```

## Quick Start
```js
const { createShield } = require("@survivorshield/shield");

const shield = createShield({
  apiKey: process.env.SURVIVOR_KEY,
});

// Gate a swap in 3 lines
const gate = await shield.attestAndGate({
  mint: "DezXAZ8z7PnrnRJjz3wXBoRgixCa6xjnB7YaB1pPB263",
  amountUsd: 2500,
});

if (gate.allow) {
  executeSwap();
} else if (gate.challenge) {
  reducePosition(gate.limits.max_amount_usd);
} else {
  console.log("DENY:", gate.reasonCodes);
}
```

## Get an API Key

1. `GET /billing/plans` — view credit packages
2. `POST /billing/checkout {"plan":"starter"}` — get Stripe checkout URL
3. Complete payment — receive API key + 1,000 credits

## API

### `createShield(opts)`

| Option | Type | Required | Default |
|--------|------|----------|---------|
| `apiKey` | string | yes | — |
| `baseUrl` | string | no | Production URL |
| `routerProgramId` | string | no | Shield Router v1 |
| `timeoutMs` | number | no | 10000 |

### `shield.attestAndGate(params)` — Primary method
```js
const gate = await shield.attestAndGate({
  mint: "TOKEN_MINT",
  amountUsd: 500,
  throwOnDeny: true,
});
// gate.allow, gate.challenge, gate.deny
// gate.score, gate.riskLevel, gate.limits
// gate.charged, gate.creditsRemaining
// gate.attestation, gate.signature
```

### `shield.attest(mint)` — Raw attestation

### `shield.quote({ score, amountUsd })` — Preflight (no charge)

### `shield.balance()` — Check credits

### `shield.verify(response)` — Verify attestation

### `shield.whoami()` / `shield.ledger()` / `shield.pricing()` / `shield.plans()`

## Credit Costs

| Risk Level | Multiplier | Calm | Mania |
|-----------|-----------|------|-------|
| LOW       | 1x        | 1    | 2     |
| MEDIUM    | 1.5x      | 2    | 3     |
| HIGH      | 2.5x      | 3    | 4     |
| VERY_HIGH | 4x        | 4    | 6     |
| EXTREME   | 8x        | 8    | 12    |

## Error Handling
```js
try {
  const gate = await shield.attestAndGate({ mint, throwOnDeny: true });
} catch (err) {
  if (err.status === 402) console.log("Out of credits");
  if (err.status === 429) console.log("Rate limited");
  if (err.gate) console.log("Denied:", err.gate.reasonCodes);
}
```

## Links

- [API Docs](https://survivor-oracle-production.up.railway.app/docs)
- [Buy Credits](https://survivor-oracle-production.up.railway.app/billing/plans)
- Built by [@youngs_modulus](https://x.com/youngs_modulus)