@hive-ng/web-sdk 0.1.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 +85 -0
- package/dist/chunk-NWQONJK2.js +898 -0
- package/dist/chunk-NWQONJK2.js.map +1 -0
- package/dist/hive-ng.global.js +3 -0
- package/dist/hive-ng.global.js.map +1 -0
- package/dist/index.cjs +909 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +1676 -0
- package/dist/index.d.ts +1676 -0
- package/dist/index.js +3 -0
- package/dist/index.js.map +1 -0
- package/dist/react/index.cjs +982 -0
- package/dist/react/index.cjs.map +1 -0
- package/dist/react/index.d.cts +33 -0
- package/dist/react/index.d.ts +33 -0
- package/dist/react/index.js +105 -0
- package/dist/react/index.js.map +1 -0
- package/package.json +70 -0
package/README.md
ADDED
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
# HIVE-NG Web SDK
|
|
2
|
+
|
|
3
|
+
Browser SDK for HIVE-NG game clients.
|
|
4
|
+
|
|
5
|
+
## Install
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install @hive-ng/web-sdk
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Basic Usage
|
|
12
|
+
|
|
13
|
+
```ts
|
|
14
|
+
import { createHiveNg } from "@hive-ng/web-sdk";
|
|
15
|
+
|
|
16
|
+
const hive = createHiveNg({
|
|
17
|
+
gatewayUrl: "https://gateway.example.com",
|
|
18
|
+
projectId: "project-id",
|
|
19
|
+
apiKey: "api-key",
|
|
20
|
+
persistSession: true,
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
await hive.init();
|
|
24
|
+
|
|
25
|
+
const loginProviders = await hive.auth.getLoginProviders();
|
|
26
|
+
const player = await hive.auth.loginAsGuest("device-id");
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
## React
|
|
30
|
+
|
|
31
|
+
```tsx
|
|
32
|
+
import { HiveProvider, useAuth } from "@hive-ng/web-sdk/react";
|
|
33
|
+
|
|
34
|
+
function App() {
|
|
35
|
+
return (
|
|
36
|
+
<HiveProvider
|
|
37
|
+
config={{
|
|
38
|
+
gatewayUrl: "https://gateway.example.com",
|
|
39
|
+
projectId: "project-id",
|
|
40
|
+
apiKey: "api-key",
|
|
41
|
+
persistSession: true,
|
|
42
|
+
}}
|
|
43
|
+
>
|
|
44
|
+
<Login />
|
|
45
|
+
</HiveProvider>
|
|
46
|
+
);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
function Login() {
|
|
50
|
+
const { ready, player, loginAsGuest } = useAuth();
|
|
51
|
+
|
|
52
|
+
if (!ready) {
|
|
53
|
+
return null;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
return (
|
|
57
|
+
<button onClick={() => loginAsGuest("device-id")}>
|
|
58
|
+
{player ? player.nickname : "Login as guest"}
|
|
59
|
+
</button>
|
|
60
|
+
);
|
|
61
|
+
}
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
## CDN
|
|
65
|
+
|
|
66
|
+
```html
|
|
67
|
+
<script src="https://cdn.jsdelivr.net/npm/@hive-ng/web-sdk"></script>
|
|
68
|
+
<script>
|
|
69
|
+
const hive = HiveNg.createHiveNg({
|
|
70
|
+
gatewayUrl: "https://gateway.example.com",
|
|
71
|
+
projectId: "project-id",
|
|
72
|
+
apiKey: "api-key",
|
|
73
|
+
});
|
|
74
|
+
</script>
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
## API
|
|
78
|
+
|
|
79
|
+
- `createHiveNg(config)`
|
|
80
|
+
- `hive.init()`
|
|
81
|
+
- `hive.auth.getLoginProviders(countryOverride?)`
|
|
82
|
+
- `hive.auth.loginWithGoogle(idToken)`
|
|
83
|
+
- `hive.auth.loginAsGuest(deviceId)`
|
|
84
|
+
- `hive.auth.logout()`
|
|
85
|
+
- `hive.auth.currentPlayer()`
|