@seaverse/data-service-sdk 0.3.0 → 0.4.0
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/README.md +91 -0
- package/dist/browser.js +4177 -0
- package/dist/browser.js.map +1 -0
- package/dist/browser.umd.js +4188 -0
- package/dist/browser.umd.js.map +1 -0
- package/package.json +7 -1
package/README.md
CHANGED
|
@@ -41,6 +41,48 @@ These fields are enforced by Firestore Security Rules and ensure proper data iso
|
|
|
41
41
|
npm install @seaverse/data-service-sdk
|
|
42
42
|
```
|
|
43
43
|
|
|
44
|
+
## Browser vs Node.js Usage
|
|
45
|
+
|
|
46
|
+
### For Build Tools (Webpack/Vite/Parcel)
|
|
47
|
+
|
|
48
|
+
The SDK automatically uses the correct version:
|
|
49
|
+
|
|
50
|
+
```javascript
|
|
51
|
+
import { DataServiceClient } from '@seaverse/data-service-sdk';
|
|
52
|
+
// Bundler will automatically use the browser version
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
### For Direct Browser Use (Without Build Tools)
|
|
56
|
+
|
|
57
|
+
**Option 1: ES Module (Recommended)**
|
|
58
|
+
|
|
59
|
+
```html
|
|
60
|
+
<script type="module">
|
|
61
|
+
import { DataServiceClient } from 'https://unpkg.com/@seaverse/data-service-sdk/dist/browser.js';
|
|
62
|
+
|
|
63
|
+
const client = new DataServiceClient();
|
|
64
|
+
// Use the client...
|
|
65
|
+
</script>
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
**Option 2: UMD via Script Tag**
|
|
69
|
+
|
|
70
|
+
```html
|
|
71
|
+
<script src="https://unpkg.com/@seaverse/data-service-sdk/dist/browser.umd.js"></script>
|
|
72
|
+
<script>
|
|
73
|
+
const client = new SeaVerseDataService.DataServiceClient();
|
|
74
|
+
// Use the client...
|
|
75
|
+
</script>
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
### For Node.js
|
|
79
|
+
|
|
80
|
+
```javascript
|
|
81
|
+
const { DataServiceClient } = require('@seaverse/data-service-sdk');
|
|
82
|
+
// or
|
|
83
|
+
import { DataServiceClient } from '@seaverse/data-service-sdk';
|
|
84
|
+
```
|
|
85
|
+
|
|
44
86
|
## Quick Start
|
|
45
87
|
|
|
46
88
|
### For Authenticated Users
|
|
@@ -521,6 +563,55 @@ For issues and questions, please visit:
|
|
|
521
563
|
- GitHub: https://github.com/seaverseai/sv-sdk
|
|
522
564
|
- Email: support@seaverse.com
|
|
523
565
|
|
|
566
|
+
## Browser Example (Vanilla JavaScript)
|
|
567
|
+
|
|
568
|
+
Here's a complete example for using the SDK directly in the browser without any build tools:
|
|
569
|
+
|
|
570
|
+
```html
|
|
571
|
+
<!DOCTYPE html>
|
|
572
|
+
<html>
|
|
573
|
+
<head>
|
|
574
|
+
<title>SeaVerse Data Service SDK - Browser Example</title>
|
|
575
|
+
</head>
|
|
576
|
+
<body>
|
|
577
|
+
<h1>Firestore Token Demo</h1>
|
|
578
|
+
<button id="getGuestToken">Get Guest Token</button>
|
|
579
|
+
<pre id="output"></pre>
|
|
580
|
+
|
|
581
|
+
<script type="module">
|
|
582
|
+
// Import from CDN
|
|
583
|
+
import { DataServiceClient } from 'https://unpkg.com/@seaverse/data-service-sdk/dist/browser.js';
|
|
584
|
+
|
|
585
|
+
const output = document.getElementById('output');
|
|
586
|
+
const client = new DataServiceClient();
|
|
587
|
+
|
|
588
|
+
document.getElementById('getGuestToken').addEventListener('click', async () => {
|
|
589
|
+
try {
|
|
590
|
+
output.textContent = 'Getting guest token...';
|
|
591
|
+
|
|
592
|
+
const guestToken = await client.generateGuestFirestoreToken({
|
|
593
|
+
app_id: 'my-app-123'
|
|
594
|
+
});
|
|
595
|
+
|
|
596
|
+
output.textContent = JSON.stringify({
|
|
597
|
+
custom_token: guestToken.custom_token.substring(0, 50) + '...',
|
|
598
|
+
user_id: guestToken.user_id,
|
|
599
|
+
role: guestToken.role,
|
|
600
|
+
project_id: guestToken.project_id,
|
|
601
|
+
expires_in: guestToken.expires_in
|
|
602
|
+
}, null, 2);
|
|
603
|
+
|
|
604
|
+
// Now you can use this token with Firebase SDK
|
|
605
|
+
console.log('Guest token received:', guestToken);
|
|
606
|
+
} catch (error) {
|
|
607
|
+
output.textContent = 'Error: ' + error.message;
|
|
608
|
+
}
|
|
609
|
+
});
|
|
610
|
+
</script>
|
|
611
|
+
</body>
|
|
612
|
+
</html>
|
|
613
|
+
```
|
|
614
|
+
|
|
524
615
|
## Related SDKs
|
|
525
616
|
|
|
526
617
|
- [@seaverse/auth-sdk](../auth-sdk) - User authentication and account management
|