Skip to content

Commit 910bd7b

Browse files
authored
Send SDK version info (#26)
This is intended primarily to allow the backend to warn about critical updates Fixes #5
1 parent d45f42e commit 910bd7b

File tree

3 files changed

+11
-1
lines changed

3 files changed

+11
-1
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@snapauth/sdk",
3-
"version": "0.1.1",
3+
"version": "0.1.2",
44
"description": "SnapAuth JS/TS SDK",
55
"main": "dist/index.js",
66
"types": "dist/index.d.ts",

src/SDK.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
// This constant is set by webpack during the build process
2+
declare var VERSION: string
3+
14
import {
25
base64URLToArrayBuffer,
36
arrayBufferToBase64URL,
@@ -154,6 +157,7 @@ class SDK {
154157
Accept: 'application/json',
155158
'Content-type': 'application/json',
156159
Authorization: `Basic ${btoa(this.apiKey + ':')}`,
160+
'X-SDK': `js/${VERSION}`,
157161
})
158162

159163
const request = new Request(this.host + path, {

webpack.config.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
const path = require('path')
2+
const webpack = require('webpack')
23

34
module.exports = {
45
entry: './src/index.ts',
@@ -10,6 +11,11 @@ module.exports = {
1011
library: 'SnapAuth',
1112
libraryTarget: 'umd',
1213
},
14+
plugins: [
15+
new webpack.DefinePlugin({
16+
VERSION: JSON.stringify(require('./package.json').version),
17+
}),
18+
],
1319
module: {
1420
rules: [
1521
{

0 commit comments

Comments
 (0)