# Local ID Scan Journey

A React component for GBG ID verification and document scanning with bundled SDK files.

## Installation

```bash
npm install local-id-scan-journey
```

## TypeScript Support

This package includes full TypeScript declarations. After installation, you should be able to import and use the component with full type safety:

```typescript
import { LocalIdScanJourney, IdScanJourneyProps } from "local-id-scan-journey";
```

## SDK Files Setup

The package includes GBG SDK files that need to be available in your project's public directory.

### Automatic Setup (Recommended)

The package includes a postinstall script that automatically copies SDK files to your public directory. If this doesn't work automatically, you can run:

```bash
npx local-id-scan-journey/scripts/postinstall.js
```

Or using the npm script:

```bash
npm run copy-sdk --prefix node_modules/local-id-scan-journey
```

### Manual Setup

If automatic setup fails, manually copy these files from `node_modules/local-id-scan-journey/dist/` to your `public/` directory:

- `idesmicro_asm.wasm`
- `idesmicro_asm.js`
- Any `vendor.*.js` files
- Any `idscan-jcs-*.js` files
- Any `ides-micro.*.js` files

## Usage

```typescript
import React from "react";
import { LocalIdScanJourney } from "local-id-scan-journey";

function App() {
  const handleScanComplete = (result: any) => {
    console.log("Scan completed:", result);
  };

  return (
    <div className="App">
      <LocalIdScanJourney
        onScanComplete={handleScanComplete}
        // ... other props
      />
    </div>
  );
}

export default App;
```

## Troubleshooting

### TypeScript Declaration Issues

If you see errors like:

```
Could not find a declaration file for module 'local-id-scan-journey'
```

1. Ensure you're using the latest version of the package
2. Check that `dist/index.d.ts` exists in `node_modules/local-id-scan-journey/`
3. Try clearing your TypeScript cache and rebuilding:
   ```bash
   rm -rf node_modules/.cache
   npm run build
   ```

### SDK File Loading Errors

If you see errors like:

```
Failed to load script: /vendor.axios.*.js
```

1. Run the SDK copy script manually:

   ```bash
   npx local-id-scan-journey/scripts/postinstall.js
   ```

2. Verify the files exist in your `public/` directory

3. Check your build process isn't excluding these files

### Next.js Configuration

For Next.js projects, you may need to add SDK files to your `next.config.js`:

```javascript
/** @type {import('next').NextConfig} */
const nextConfig = {
  webpack: (config) => {
    config.resolve.fallback = {
      ...config.resolve.fallback,
      fs: false,
    };
    return config;
  },
  // Ensure public files are served correctly
  async rewrites() {
    return [
      {
        source: "/idesmicro_asm.wasm",
        destination: "/idesmicro_asm.wasm",
      },
    ];
  },
};

module.exports = nextConfig;
```

## Development

To rebuild the package:

```bash
npm run build
```

To watch for changes:

```bash
npm run dev
```

## License

MIT
