@seamapi/http 0.25.1 → 0.25.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.
- package/README.md +18 -2
- package/dist/connect.cjs +8 -1
- package/dist/connect.cjs.map +1 -1
- package/lib/seam/connect/seam-http-request.js +11 -1
- package/lib/seam/connect/seam-http-request.js.map +1 -1
- package/lib/version.d.ts +1 -1
- package/lib/version.js +1 -1
- package/package.json +2 -2
- package/src/lib/seam/connect/seam-http-request.ts +11 -1
- package/src/lib/version.ts +1 -1
package/README.md
CHANGED
|
@@ -74,13 +74,29 @@ $ npm install -D @seamapi/types@latest
|
|
|
74
74
|
|
|
75
75
|
## Usage
|
|
76
76
|
|
|
77
|
+
### Examples
|
|
78
|
+
|
|
79
|
+
_These examples assume `SEAM_API_KEY` is set in your environment._
|
|
80
|
+
|
|
81
|
+
#### List devices
|
|
82
|
+
|
|
77
83
|
```ts
|
|
78
84
|
import { SeamHttp } from '@seamapi/http/connect'
|
|
79
85
|
|
|
80
|
-
const seam = new SeamHttp(
|
|
86
|
+
const seam = new SeamHttp()
|
|
81
87
|
const devices = await seam.devices.list()
|
|
82
88
|
```
|
|
83
89
|
|
|
90
|
+
#### Unlock a door
|
|
91
|
+
|
|
92
|
+
```ts
|
|
93
|
+
import { SeamHttp } from '@seamapi/http/connect'
|
|
94
|
+
|
|
95
|
+
const seam = new SeamHttp()
|
|
96
|
+
const lock = await seam.locks.get({ name: 'Front Door' })
|
|
97
|
+
await seam.locks.unlockDoor({ device_id: lock.device_id })
|
|
98
|
+
```
|
|
99
|
+
|
|
84
100
|
### Authentication Methods
|
|
85
101
|
|
|
86
102
|
The SDK supports several authentication mechanisms.
|
|
@@ -124,7 +140,7 @@ const seam = SeamHttp.fromClientSessionToken('some-client-session-token')
|
|
|
124
140
|
|
|
125
141
|
The client session token may be updated using
|
|
126
142
|
|
|
127
|
-
```
|
|
143
|
+
```ts
|
|
128
144
|
const seam = SeamHttp.fromClientSessionToken('some-client-session-token')
|
|
129
145
|
|
|
130
146
|
await seam.updateClientSessionToken('some-new-client-session-token')
|
package/dist/connect.cjs
CHANGED
|
@@ -721,7 +721,7 @@ _a = Symbol.toStringTag;
|
|
|
721
721
|
_parent = new WeakMap();
|
|
722
722
|
_config = new WeakMap();
|
|
723
723
|
var getUrlPrefix = (input) => {
|
|
724
|
-
if (
|
|
724
|
+
if (canParseUrl(input)) {
|
|
725
725
|
const url = new URL(input).toString();
|
|
726
726
|
if (url.endsWith("/"))
|
|
727
727
|
return url.slice(0, -1);
|
|
@@ -735,6 +735,13 @@ var getUrlPrefix = (input) => {
|
|
|
735
735
|
`Cannot resolve origin from ${input} in a non-browser environment`
|
|
736
736
|
);
|
|
737
737
|
};
|
|
738
|
+
var canParseUrl = (input) => {
|
|
739
|
+
try {
|
|
740
|
+
return new URL(input) != null;
|
|
741
|
+
} catch {
|
|
742
|
+
return false;
|
|
743
|
+
}
|
|
744
|
+
};
|
|
738
745
|
|
|
739
746
|
// src/lib/seam/connect/routes/client-sessions.ts
|
|
740
747
|
var SeamHttpClientSessions = class _SeamHttpClientSessions {
|