@insure-os/client 0.0.3

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.
@@ -0,0 +1,379 @@
1
+ # NPM Publishing Guide
2
+
3
+ Complete guide for publishing `@insure-os/scripts` to NPM registry.
4
+
5
+ ## ๐Ÿ“ฆ Package Information
6
+
7
+ - **Package Name**: `@insure-os/scripts`
8
+ - **NPM Organization**: [@insure-os](https://www.npmjs.com/settings/insure-os/packages)
9
+ - **Registry**: https://registry.npmjs.org/
10
+ - **Access**: Public
11
+
12
+ ## ๐Ÿš€ Quick Publish
13
+
14
+ ### Publish Everything (CDN + NPM)
15
+
16
+ ```bash
17
+ pnpm release
18
+ ```
19
+
20
+ This will:
21
+ 1. Bump patch version (0.0.0 โ†’ 0.0.1)
22
+ 2. Build production bundle
23
+ 3. Deploy to CDN (cdn.os.insure)
24
+ 4. Publish to NPM registry
25
+
26
+ ### Publish to NPM Only
27
+
28
+ ```bash
29
+ # Build and publish
30
+ pnpm release:npm
31
+
32
+ # Or manually
33
+ npm version patch
34
+ pnpm build:prod
35
+ pnpm publish:npm
36
+ ```
37
+
38
+ ### Publish to CDN Only
39
+
40
+ ```bash
41
+ pnpm release:cdn
42
+ ```
43
+
44
+ ## ๐Ÿ” Authentication Setup
45
+
46
+ ### First Time Setup
47
+
48
+ 1. **Login to NPM** (if not already logged in):
49
+ ```bash
50
+ npm login
51
+ ```
52
+
53
+ Enter your NPM credentials:
54
+ - Username: (your NPM username)
55
+ - Password: (your NPM password)
56
+ - Email: (your email)
57
+ - 2FA code: (if enabled)
58
+
59
+ 2. **Verify you're a member of @insure-os org**:
60
+ ```bash
61
+ npm org ls insure-os
62
+ ```
63
+
64
+ You should see your username in the list.
65
+
66
+ 3. **Test authentication**:
67
+ ```bash
68
+ npm whoami
69
+ ```
70
+
71
+ ### Using NPM Access Tokens (CI/CD)
72
+
73
+ For automated publishing in CI/CD:
74
+
75
+ 1. **Generate NPM token**:
76
+ - Go to https://www.npmjs.com/settings/YOUR_USERNAME/tokens
77
+ - Click "Generate New Token"
78
+ - Select "Automation" type
79
+ - Copy the token
80
+
81
+ 2. **Set environment variable**:
82
+ ```bash
83
+ export NPM_TOKEN=your_token_here
84
+ ```
85
+
86
+ 3. **Create `.npmrc` in CI**:
87
+ ```bash
88
+ echo "//registry.npmjs.org/:_authToken=${NPM_TOKEN}" > ~/.npmrc
89
+ ```
90
+
91
+ ## ๐Ÿ“‹ Pre-Publish Checklist
92
+
93
+ Before publishing, ensure:
94
+
95
+ - [ ] All tests pass: `pnpm test`
96
+ - [ ] Code is linted: `pnpm lint`
97
+ - [ ] Types are valid: `pnpm typecheck`
98
+ - [ ] Bundle builds successfully: `pnpm build:prod`
99
+ - [ ] Bundle size is acceptable: `pnpm size:detailed`
100
+ - [ ] README is up to date
101
+ - [ ] CHANGELOG is updated (if you maintain one)
102
+ - [ ] Version number is correct
103
+
104
+ **Note**: The `prepublishOnly` script automatically runs `build:prod`, `test`, and `lint` before publishing.
105
+
106
+ ## ๐Ÿงช Dry Run (Test Publish)
107
+
108
+ Always test before publishing:
109
+
110
+ ```bash
111
+ pnpm publish:npm:dry
112
+ ```
113
+
114
+ This will:
115
+ - Show you what files will be published
116
+ - Display package tarball contents
117
+ - Validate package.json
118
+ - **NOT** actually publish to NPM
119
+
120
+ Review the output carefully!
121
+
122
+ ## ๐Ÿ“ฆ What Gets Published
123
+
124
+ The following files/folders are included in the NPM package:
125
+
126
+ ```
127
+ @insure-os/scripts/
128
+ โ”œโ”€โ”€ dist/
129
+ โ”‚ โ”œโ”€โ”€ index.esm.js # ES Module
130
+ โ”‚ โ”œโ”€โ”€ index.esm.js.map # Source map
131
+ โ”‚ โ”œโ”€โ”€ index.cjs # CommonJS
132
+ โ”‚ โ”œโ”€โ”€ index.cjs.map # Source map
133
+ โ”‚ โ”œโ”€โ”€ index.umd.js # UMD (for CDN)
134
+ โ”‚ โ”œโ”€โ”€ index.umd.js.map # Source map
135
+ โ”‚ โ””โ”€โ”€ index.d.ts # TypeScript definitions
136
+ โ”œโ”€โ”€ README.md # User documentation
137
+ โ”œโ”€โ”€ DEPLOYMENT.md # Deployment guide
138
+ โ”œโ”€โ”€ CDN_SETUP.md # CDN setup guide
139
+ โ”œโ”€โ”€ package.json
140
+ โ””โ”€โ”€ LICENSE (if present)
141
+ ```
142
+
143
+ **Excluded** (via .npmignore or package.json files field):
144
+ - `src/` - Source code
145
+ - `node_modules/`
146
+ - `.env` - Credentials
147
+ - Test files
148
+ - Build configuration
149
+
150
+ ## ๐Ÿ”ข Version Management
151
+
152
+ ### Semantic Versioning
153
+
154
+ Follow [semver](https://semver.org/):
155
+
156
+ ```bash
157
+ npm version patch # 0.0.1 โ†’ 0.0.2 (bug fixes)
158
+ npm version minor # 0.1.0 โ†’ 0.2.0 (new features, backwards compatible)
159
+ npm version major # 1.0.0 โ†’ 2.0.0 (breaking changes)
160
+ ```
161
+
162
+ ### Pre-release Versions
163
+
164
+ For beta/alpha releases:
165
+
166
+ ```bash
167
+ npm version prerelease --preid=beta # 0.0.1 โ†’ 0.0.2-beta.0
168
+ npm version prerelease --preid=alpha # 0.0.1 โ†’ 0.0.2-alpha.0
169
+ ```
170
+
171
+ Publish with tag:
172
+
173
+ ```bash
174
+ npm publish --tag beta
175
+ npm publish --tag alpha
176
+ ```
177
+
178
+ Users install with:
179
+
180
+ ```bash
181
+ npm install @insure-os/scripts@beta
182
+ npm install @insure-os/scripts@alpha
183
+ ```
184
+
185
+ ## ๐Ÿ“Š After Publishing
186
+
187
+ ### Verify Publication
188
+
189
+ 1. **Check NPM registry**:
190
+ ```bash
191
+ npm view @insure-os/scripts
192
+ ```
193
+
194
+ 2. **Visit NPM page**:
195
+ https://www.npmjs.com/package/@insure-os/scripts
196
+
197
+ 3. **Test installation**:
198
+ ```bash
199
+ # In a test directory
200
+ mkdir test-install && cd test-install
201
+ npm init -y
202
+ npm install @insure-os/scripts
203
+ ```
204
+
205
+ 4. **Test import** (create `test.js`):
206
+ ```javascript
207
+ import { InsureOS } from '@insure-os/scripts';
208
+ console.log('InsureOS imported successfully:', InsureOS);
209
+ ```
210
+
211
+ ### Update Documentation
212
+
213
+ After publishing a new version:
214
+
215
+ 1. Update any version-specific documentation
216
+ 2. Create a GitHub release (if using GitHub)
217
+ 3. Notify team/customers if needed
218
+ 4. Update CHANGELOG (if maintained)
219
+
220
+ ## ๐Ÿšจ Troubleshooting
221
+
222
+ ### "You do not have permission to publish"
223
+
224
+ **Problem**: Not a member of @insure-os org or not logged in.
225
+
226
+ **Solution**:
227
+ ```bash
228
+ # Login
229
+ npm login
230
+
231
+ # Verify membership
232
+ npm org ls insure-os
233
+
234
+ # Contact org owner to add you if not listed
235
+ ```
236
+
237
+ ### "Version X already exists"
238
+
239
+ **Problem**: Trying to publish same version twice.
240
+
241
+ **Solution**:
242
+ ```bash
243
+ # Bump version first
244
+ npm version patch
245
+
246
+ # Then publish
247
+ pnpm publish:npm
248
+ ```
249
+
250
+ ### "prepublishOnly script failed"
251
+
252
+ **Problem**: Tests, build, or lint failed.
253
+
254
+ **Solution**:
255
+ ```bash
256
+ # Fix the issues
257
+ pnpm test
258
+ pnpm lint
259
+ pnpm build:prod
260
+
261
+ # Then try publishing again
262
+ ```
263
+
264
+ ### Package too large
265
+
266
+ **Problem**: Package size exceeds limits.
267
+
268
+ **Solution**:
269
+ - Check what's being included: `pnpm publish:npm:dry`
270
+ - Ensure `src/`, `node_modules/`, tests are excluded
271
+ - Review `files` field in package.json
272
+
273
+ ## ๐Ÿ“ NPM Scripts Reference
274
+
275
+ ```bash
276
+ # Publishing
277
+ pnpm publish:npm # Publish to NPM
278
+ pnpm publish:npm:dry # Dry run (test)
279
+ pnpm publish:cdn # Publish to CDN only
280
+ pnpm release:npm # Build + publish to NPM
281
+ pnpm release:cdn # Build + publish to CDN
282
+ pnpm release:all # Build + publish to both
283
+ pnpm release # Version + build + publish all
284
+
285
+ # Version management
286
+ npm version patch # Bump patch version
287
+ npm version minor # Bump minor version
288
+ npm version major # Bump major version
289
+ npm version prerelease # Bump prerelease version
290
+
291
+ # Pre-publish checks (run automatically)
292
+ pnpm build:prod # Build for production
293
+ pnpm test # Run tests
294
+ pnpm lint # Lint code
295
+ pnpm typecheck # Check TypeScript types
296
+
297
+ # Verification
298
+ pnpm size:detailed # Check bundle sizes
299
+ npm view @insure-os/scripts # View published package
300
+ ```
301
+
302
+ ## ๐Ÿ”„ Complete Release Workflow
303
+
304
+ ### Standard Release (Patch)
305
+
306
+ ```bash
307
+ # 1. Ensure clean working directory
308
+ git status
309
+
310
+ # 2. Pull latest changes
311
+ git pull origin main
312
+
313
+ # 3. Run all checks
314
+ pnpm test
315
+ pnpm lint
316
+ pnpm build:prod
317
+
318
+ # 4. Release (bumps version, builds, publishes to CDN + NPM)
319
+ pnpm release
320
+
321
+ # 5. Push version commit and tag
322
+ git push origin main --tags
323
+
324
+ # 6. Verify on NPM
325
+ npm view @insure-os/scripts
326
+
327
+ # 7. Test installation
328
+ cd /tmp
329
+ npm install @insure-os/scripts
330
+ ```
331
+
332
+ ### Manual Step-by-Step
333
+
334
+ ```bash
335
+ # 1. Bump version
336
+ npm version patch # or minor/major
337
+
338
+ # 2. Build
339
+ pnpm build:prod
340
+
341
+ # 3. Dry run to verify
342
+ pnpm publish:npm:dry
343
+
344
+ # 4. Publish to NPM
345
+ pnpm publish:npm
346
+
347
+ # 5. Publish to CDN
348
+ pnpm publish:cdn
349
+
350
+ # 6. Push to git
351
+ git push origin main --tags
352
+ ```
353
+
354
+ ## ๐Ÿ” Security Best Practices
355
+
356
+ 1. **Never commit NPM tokens** to git
357
+ 2. **Use 2FA** on your NPM account
358
+ 3. **Rotate tokens** periodically
359
+ 4. **Review package contents** with dry-run before publishing
360
+ 5. **Use automation tokens** for CI/CD, not user tokens
361
+ 6. **Audit dependencies** regularly: `npm audit`
362
+
363
+ ## ๐Ÿ“š Related Documentation
364
+
365
+ - [DEPLOYMENT.md](./DEPLOYMENT.md) - Quick deployment reference
366
+ - [CDN_SETUP.md](./CDN_SETUP.md) - CDN configuration guide
367
+ - [README.md](./README.md) - User-facing documentation
368
+ - [NPM Documentation](https://docs.npmjs.com/packages-and-modules/contributing-packages-to-the-registry)
369
+
370
+ ## ๐Ÿ†˜ Getting Help
371
+
372
+ - **NPM Support**: https://www.npmjs.com/support
373
+ - **Check package status**: `npm view @insure-os/scripts`
374
+ - **Organization settings**: https://www.npmjs.com/settings/insure-os/packages
375
+ - **Team lead**: Contact for organization access issues
376
+
377
+ ---
378
+
379
+ **Last Updated**: 2025-10-02
package/README.md ADDED
@@ -0,0 +1,299 @@
1
+ # @insure-os/scripts
2
+
3
+ A lightweight JavaScript client library for integrating InsureOS quote functionality into external websites. This library provides two simple integration methods: script tag with auto-initialization or NPM import with programmatic control.
4
+
5
+ ---
6
+
7
+ ## ๐Ÿš€ Quick Start for Developers
8
+
9
+ ### Publishing to NPM + CDN
10
+
11
+ ```bash
12
+ # Publish to both NPM and CDN in one command
13
+ pnpm release
14
+ ```
15
+
16
+ This will:
17
+ 1. Bump patch version (0.0.0 โ†’ 0.0.1)
18
+ 2. Build production bundles
19
+ 3. Deploy to CDN: `https://cdn.os.insure`
20
+ 4. Publish to NPM: `@insure-os/scripts`
21
+
22
+ **NPM Package:**
23
+ - Install: `npm install @insure-os/scripts`
24
+ - View: https://www.npmjs.com/package/@insure-os/scripts
25
+
26
+ **CDN URLs:**
27
+ - Versioned: `https://cdn.os.insure/v{version}/insureos.min.js`
28
+ - Major version: `https://cdn.os.insure/v{major}/insureos.min.js`
29
+ - Latest: `https://cdn.os.insure/latest/insureos.min.js`
30
+
31
+ ๐Ÿ“– **Full guides:**
32
+ - [DEPLOYMENT.md](./DEPLOYMENT.md) - Quick deployment reference
33
+ - [NPM_PUBLISHING.md](./NPM_PUBLISHING.md) - NPM publishing guide
34
+ - [CDN_SETUP.md](./CDN_SETUP.md) - CDN configuration
35
+ - [DOCS_INDEX.md](./DOCS_INDEX.md) - All documentation
36
+
37
+ ---
38
+
39
+ ## Features
40
+
41
+ - ๐Ÿš€ **Simple Integration** - Two easy ways to integrate: script tag or NPM import
42
+ - ๐ŸŽฏ **Auto-initialization** - Script tag automatically creates quote intents and renders buttons
43
+ - ๐ŸŽจ **Customizable Styling** - Well-named CSS classes for easy styling
44
+ - ๐Ÿ”’ **Secure Authentication** - Built-in organization-based authentication
45
+ - โšก **Lightweight** - Minimal bundle size with essential functionality only
46
+
47
+ ## Installation & Usage
48
+
49
+ ### Method 1: Script Tag (CDN - Recommended for external sites)
50
+
51
+ Add a script tag from our CDN. This is the easiest way for external websites to integrate InsureOS.
52
+
53
+ ```html
54
+ <!DOCTYPE html>
55
+ <html>
56
+ <head>
57
+ <title>Insurance Quote</title>
58
+ <style>
59
+ /* Style the button with well-named CSS classes */
60
+ .insureos-submit-btn {
61
+ background-color: #007bff;
62
+ color: white;
63
+ border: none;
64
+ padding: 12px 24px;
65
+ font-size: 16px;
66
+ border-radius: 6px;
67
+ cursor: pointer;
68
+ font-family: system-ui, sans-serif;
69
+ }
70
+
71
+ .insureos-submit-btn:hover:not(:disabled) {
72
+ background-color: #0056b3;
73
+ }
74
+
75
+ .insureos-loading {
76
+ background-color: #6c757d;
77
+ cursor: not-allowed;
78
+ }
79
+
80
+ .insureos-error {
81
+ color: #dc3545;
82
+ padding: 12px;
83
+ border: 1px solid #dc3545;
84
+ border-radius: 4px;
85
+ background-color: #f8d7da;
86
+ }
87
+ </style>
88
+ </head>
89
+ <body>
90
+ <h1>Get Your Insurance Quote</h1>
91
+
92
+ <!-- Load InsureOS from CDN (use specific version for production) -->
93
+ <script
94
+ src="https://cdn.os.insure/v0.0.0/insureos.min.js"
95
+ integrity="sha384-x6rqyvqpRkF+stuy4Ydnp+gou2baQOQFXkfw7bt/NVtF2I0VJiXV8neu2iIDSLzf"
96
+ crossorigin="anonymous">
97
+ </script>
98
+
99
+ <script>
100
+ // Initialize InsureOS and mount to container
101
+ const client = new InsureOSScripts.InsureOS({
102
+ apiKey: 'your-api-key',
103
+ environment: 'production',
104
+ });
105
+
106
+ client.mount('#insureos-container', {
107
+ quoteIntentId: 'your-quote-intent-id',
108
+ });
109
+ </script>
110
+ </body>
111
+ </html>
112
+ ```
113
+
114
+ ### Method 2: NPM Import with mount()
115
+
116
+ Install the package and use the `InsureOS.mount()` method for programmatic control.
117
+
118
+ ```bash
119
+ npm install @insure-os/scripts
120
+ ```
121
+
122
+ ```javascript
123
+ import { InsureOS } from "@insure-os/scripts";
124
+
125
+ // Mount to a specific DOM element
126
+ const container = document.getElementById("quote-container");
127
+ InsureOS.mount(container, {
128
+ orgId: "your-org-id",
129
+ });
130
+ ```
131
+
132
+ ```html
133
+ <!DOCTYPE html>
134
+ <html>
135
+ <head>
136
+ <title>Insurance Quote</title>
137
+ <style>
138
+ .insureos-submit-btn {
139
+ background-color: #007bff;
140
+ color: white;
141
+ border: none;
142
+ padding: 12px 24px;
143
+ font-size: 16px;
144
+ border-radius: 6px;
145
+ cursor: pointer;
146
+ }
147
+ </style>
148
+ </head>
149
+ <body>
150
+ <h1>Get Your Insurance Quote</h1>
151
+ <div id="quote-container"></div>
152
+
153
+ <script type="module" src="./main.js"></script>
154
+ </body>
155
+ </html>
156
+ ```
157
+
158
+ ## API Reference
159
+
160
+ ### InsureOS.mount()
161
+
162
+ Mounts InsureOS quote functionality to a DOM element.
163
+
164
+ ```typescript
165
+ InsureOS.mount(element: HTMLElement, config: MountConfig): Promise<void>
166
+ ```
167
+
168
+ **Parameters:**
169
+
170
+ - `element` - DOM element to mount the quote button to
171
+ - `config` - Configuration object
172
+
173
+ **MountConfig:**
174
+
175
+ ```typescript
176
+ interface MountConfig {
177
+ orgId: string; // Required: Your organization ID
178
+ apiBaseUrl?: string; // Optional: Custom API base URL (defaults to https://api.os.insure)
179
+ }
180
+ ```
181
+
182
+ **Example:**
183
+
184
+ ```javascript
185
+ import { InsureOS } from "@insure-os/scripts";
186
+
187
+ // Basic usage
188
+ InsureOS.mount(document.getElementById("quote-btn"), {
189
+ orgId: "123",
190
+ });
191
+
192
+ // With custom API URL (for development)
193
+ InsureOS.mount(document.getElementById("quote-btn"), {
194
+ orgId: "123",
195
+ apiBaseUrl: "http://localhost:3000/dev",
196
+ });
197
+ ```
198
+
199
+ ## How It Works
200
+
201
+ 1. **Initialization**: The library initializes with your organization ID
202
+ 2. **Quote Intent Creation**: Automatically creates a blank quote intent via API call
203
+ 3. **Button Rendering**: Renders a submit button with loading states
204
+ 4. **User Interaction**: When clicked, redirects user to the signed quote URL
205
+
206
+ ## CSS Classes for Styling
207
+
208
+ The library uses well-named CSS classes that you can style:
209
+
210
+ - `.insureos-submit-btn` - Main submit button
211
+ - `.insureos-loading` - Loading state (added to button)
212
+ - `.insureos-error` - Error message display
213
+
214
+ ## Examples
215
+
216
+ ### React Integration
217
+
218
+ ```jsx
219
+ import React, { useEffect, useRef } from "react";
220
+ import { InsureOS } from "@insure-os/scripts";
221
+
222
+ function QuoteButton({ orgId }) {
223
+ const containerRef = useRef(null);
224
+
225
+ useEffect(() => {
226
+ if (containerRef.current) {
227
+ InsureOS.mount(containerRef.current, { orgId });
228
+ }
229
+ }, [orgId]);
230
+
231
+ return <div ref={containerRef} />;
232
+ }
233
+ ```
234
+
235
+ ### Vue.js Integration
236
+
237
+ ```vue
238
+ <template>
239
+ <div ref="quoteContainer"></div>
240
+ </template>
241
+
242
+ <script>
243
+ import { InsureOS } from "@insure-os/scripts";
244
+
245
+ export default {
246
+ props: ["orgId"],
247
+ mounted() {
248
+ InsureOS.mount(this.$refs.quoteContainer, {
249
+ orgId: this.orgId,
250
+ });
251
+ },
252
+ };
253
+ </script>
254
+ ```
255
+
256
+ ### Multiple Buttons
257
+
258
+ ```javascript
259
+ import { InsureOS } from "@insure-os/scripts";
260
+
261
+ // Mount multiple buttons for different organizations
262
+ InsureOS.mount(document.getElementById("quote-1"), { orgId: "123" });
263
+ InsureOS.mount(document.getElementById("quote-2"), { orgId: "456" });
264
+ InsureOS.mount(document.getElementById("quote-3"), { orgId: "789" });
265
+ ```
266
+
267
+ ## Error Handling
268
+
269
+ The library handles errors gracefully:
270
+
271
+ - **Network errors**: Shows error message with retry capability
272
+ - **API errors**: Displays user-friendly error messages
273
+ - **Configuration errors**: Clear error messages for missing orgId
274
+
275
+ Errors are displayed using the `.insureos-error` CSS class.
276
+
277
+ ## Browser Support
278
+
279
+ - **Modern Browsers**: Chrome 60+, Firefox 55+, Safari 12+, Edge 79+
280
+ - **Required Features**: Fetch API, Promises, ES2017 syntax
281
+
282
+ ## TypeScript Support
283
+
284
+ Full TypeScript definitions are included:
285
+
286
+ ```typescript
287
+ import { InsureOS, MountConfig, QuoteIntentResponse } from "@insure-os/scripts";
288
+
289
+ const config: MountConfig = {
290
+ orgId: "your-org-id",
291
+ apiBaseUrl: "https://api.os.insure",
292
+ };
293
+
294
+ InsureOS.mount(element, config);
295
+ ```
296
+
297
+ ## License
298
+
299
+ MIT License - see [LICENSE](LICENSE) file for details.
@@ -0,0 +1,26 @@
1
+ {
2
+ "timestamp": "2025-10-08T21:15:14.577Z",
3
+ "maxSizeKB": "1024.00",
4
+ "bundles": {
5
+ "es": {
6
+ "fileName": "index.esm.js",
7
+ "size": 280493,
8
+ "gzippedSize": 84396,
9
+ "sizeKB": "273.92",
10
+ "gzippedSizeKB": "82.42"
11
+ }
12
+ },
13
+ "summary": {
14
+ "totalBundles": 1,
15
+ "largestBundle": {
16
+ "format": "es",
17
+ "fileName": "index.esm.js",
18
+ "size": 280493,
19
+ "gzippedSize": 84396,
20
+ "sizeKB": "273.92",
21
+ "gzippedSizeKB": "82.42"
22
+ },
23
+ "totalSize": 280493,
24
+ "totalGzippedSize": 84396
25
+ }
26
+ }