@knocklabs/client 0.15.1 → 0.15.2
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/CHANGELOG.md +6 -0
- package/dist/cjs/api.js +1 -1
- package/dist/cjs/api.js.map +1 -1
- package/dist/esm/api.mjs +5 -1
- package/dist/esm/api.mjs.map +1 -1
- package/dist/types/api.d.ts +1 -0
- package/dist/types/api.d.ts.map +1 -1
- package/package.json +2 -2
- package/src/api.ts +10 -0
package/CHANGELOG.md
CHANGED
package/dist/cjs/api.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var a=Object.defineProperty;var n=(t,e,s)=>e in t?a(t,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[e]=s;var r=(t,e,s)=>n(t,typeof e!="symbol"?e+"":e,s);Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const u=require("axios"),l=require("axios-retry"),c=require("phoenix"),i=t=>t&&typeof t=="object"&&"default"in t?t:{default:t},h=i(u),o=i(l);class p{constructor(e){r(this,"host");r(this,"apiKey");r(this,"userToken");r(this,"axiosClient");r(this,"socket");this.host=e.host,this.apiKey=e.apiKey,this.userToken=e.userToken||null,this.axiosClient=h.default.create({baseURL:this.host,headers:{Accept:"application/json","Content-Type":"application/json",Authorization:`Bearer ${this.apiKey}`,"X-Knock-User-Token":this.userToken,"User-Agent":this.getUserAgent()}}),typeof window<"u"&&(this.socket=new c.Socket(`${this.host.replace("http","ws")}/ws/v1`,{params:{user_token:this.userToken,api_key:this.apiKey}})),o.default(this.axiosClient,{retries:3,retryCondition:this.canRetryRequest,retryDelay:o.default.exponentialDelay})}async makeRequest(e){try{const s=await this.axiosClient(e);return{statusCode:s.status<300?"ok":"error",body:s.data,error:void 0,status:s.status}}catch(s){return console.error(s),{statusCode:"error",status:500,body:void 0,error:s}}}canRetryRequest(e){return o.default.isNetworkError(e)?!0:e.response?e.response.status>=500&&e.response.status<=599||e.response.status===429:!1}getUserAgent(){return"Knock/ClientJS 0.15.2"}}exports.default=p;
|
|
2
2
|
//# sourceMappingURL=api.js.map
|
package/dist/cjs/api.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"api.js","sources":["../../src/api.ts"],"sourcesContent":["import axios, { AxiosError, AxiosInstance, AxiosRequestConfig } from \"axios\";\nimport axiosRetry from \"axios-retry\";\nimport { Socket } from \"phoenix\";\n\ntype ApiClientOptions = {\n host: string;\n apiKey: string;\n userToken: string | undefined;\n};\n\nexport interface ApiResponse {\n // eslint-disable-next-line\n error?: any;\n // eslint-disable-next-line\n body?: any;\n statusCode: \"ok\" | \"error\";\n status: number;\n}\n\nclass ApiClient {\n private host: string;\n private apiKey: string;\n private userToken: string | null;\n private axiosClient: AxiosInstance;\n\n public socket: Socket | undefined;\n\n constructor(options: ApiClientOptions) {\n this.host = options.host;\n this.apiKey = options.apiKey;\n this.userToken = options.userToken || null;\n\n // Create a retryable axios client\n this.axiosClient = axios.create({\n baseURL: this.host,\n headers: {\n Accept: \"application/json\",\n \"Content-Type\": \"application/json\",\n Authorization: `Bearer ${this.apiKey}`,\n \"X-Knock-User-Token\": this.userToken,\n },\n });\n\n if (typeof window !== \"undefined\") {\n this.socket = new Socket(`${this.host.replace(\"http\", \"ws\")}/ws/v1`, {\n params: {\n user_token: this.userToken,\n api_key: this.apiKey,\n },\n });\n }\n\n axiosRetry(this.axiosClient, {\n retries: 3,\n retryCondition: this.canRetryRequest,\n retryDelay: axiosRetry.exponentialDelay,\n });\n }\n\n async makeRequest(req: AxiosRequestConfig): Promise<ApiResponse> {\n try {\n const result = await this.axiosClient(req);\n\n return {\n statusCode: result.status < 300 ? \"ok\" : \"error\",\n body: result.data,\n error: undefined,\n status: result.status,\n };\n\n // eslint:disable-next-line\n } catch (e: unknown) {\n console.error(e);\n\n return {\n statusCode: \"error\",\n status: 500,\n body: undefined,\n error: e,\n };\n }\n }\n\n private canRetryRequest(error: AxiosError) {\n // Retry Network Errors.\n if (axiosRetry.isNetworkError(error)) {\n return true;\n }\n\n if (!error.response) {\n // Cannot determine if the request can be retried\n return false;\n }\n\n // Retry Server Errors (5xx).\n if (error.response.status >= 500 && error.response.status <= 599) {\n return true;\n }\n\n // Retry if rate limited.\n if (error.response.status === 429) {\n return true;\n }\n\n return false;\n }\n}\n\nexport default ApiClient;\n"],"names":["ApiClient","options","__publicField","axios","Socket","axiosRetry","req","result","e","error"],"mappings":"6ZAmBA,MAAMA,CAAU,CAQd,YAAYC,EAA2B,CAP/BC,EAAA,aACAA,EAAA,eACAA,EAAA,kBACAA,EAAA,oBAEDA,EAAA,eAGL,KAAK,KAAOD,EAAQ,KACpB,KAAK,OAASA,EAAQ,OACjB,KAAA,UAAYA,EAAQ,WAAa,KAGjC,KAAA,YAAcE,UAAM,OAAO,CAC9B,QAAS,KAAK,KACd,QAAS,CACP,OAAQ,mBACR,eAAgB,mBAChB,cAAe,UAAU,KAAK,MAAM,GACpC,qBAAsB,KAAK,
|
|
1
|
+
{"version":3,"file":"api.js","sources":["../../src/api.ts"],"sourcesContent":["import axios, { AxiosError, AxiosInstance, AxiosRequestConfig } from \"axios\";\nimport axiosRetry from \"axios-retry\";\nimport { Socket } from \"phoenix\";\n\ntype ApiClientOptions = {\n host: string;\n apiKey: string;\n userToken: string | undefined;\n};\n\nexport interface ApiResponse {\n // eslint-disable-next-line\n error?: any;\n // eslint-disable-next-line\n body?: any;\n statusCode: \"ok\" | \"error\";\n status: number;\n}\n\nclass ApiClient {\n private host: string;\n private apiKey: string;\n private userToken: string | null;\n private axiosClient: AxiosInstance;\n\n public socket: Socket | undefined;\n\n constructor(options: ApiClientOptions) {\n this.host = options.host;\n this.apiKey = options.apiKey;\n this.userToken = options.userToken || null;\n\n // Create a retryable axios client\n this.axiosClient = axios.create({\n baseURL: this.host,\n headers: {\n Accept: \"application/json\",\n \"Content-Type\": \"application/json\",\n Authorization: `Bearer ${this.apiKey}`,\n \"X-Knock-User-Token\": this.userToken,\n \"User-Agent\": this.getUserAgent(),\n },\n });\n\n if (typeof window !== \"undefined\") {\n this.socket = new Socket(`${this.host.replace(\"http\", \"ws\")}/ws/v1`, {\n params: {\n user_token: this.userToken,\n api_key: this.apiKey,\n },\n });\n }\n\n axiosRetry(this.axiosClient, {\n retries: 3,\n retryCondition: this.canRetryRequest,\n retryDelay: axiosRetry.exponentialDelay,\n });\n }\n\n async makeRequest(req: AxiosRequestConfig): Promise<ApiResponse> {\n try {\n const result = await this.axiosClient(req);\n\n return {\n statusCode: result.status < 300 ? \"ok\" : \"error\",\n body: result.data,\n error: undefined,\n status: result.status,\n };\n\n // eslint:disable-next-line\n } catch (e: unknown) {\n console.error(e);\n\n return {\n statusCode: \"error\",\n status: 500,\n body: undefined,\n error: e,\n };\n }\n }\n\n private canRetryRequest(error: AxiosError) {\n // Retry Network Errors.\n if (axiosRetry.isNetworkError(error)) {\n return true;\n }\n\n if (!error.response) {\n // Cannot determine if the request can be retried\n return false;\n }\n\n // Retry Server Errors (5xx).\n if (error.response.status >= 500 && error.response.status <= 599) {\n return true;\n }\n\n // Retry if rate limited.\n if (error.response.status === 429) {\n return true;\n }\n\n return false;\n }\n\n private getUserAgent() {\n // Note: we're following format used in our Stainless SDKs:\n // https://github.com/knocklabs/knock-node/blob/main/src/client.ts#L335\n // If we add the env var to turbo.json, it caches it so the version\n // never actually updates.\n // eslint-disable-next-line turbo/no-undeclared-env-vars\n return `Knock/ClientJS ${process.env.CLIENT_PACKAGE_VERSION}`;\n }\n}\n\nexport default ApiClient;\n"],"names":["ApiClient","options","__publicField","axios","Socket","axiosRetry","req","result","e","error"],"mappings":"6ZAmBA,MAAMA,CAAU,CAQd,YAAYC,EAA2B,CAP/BC,EAAA,aACAA,EAAA,eACAA,EAAA,kBACAA,EAAA,oBAEDA,EAAA,eAGL,KAAK,KAAOD,EAAQ,KACpB,KAAK,OAASA,EAAQ,OACjB,KAAA,UAAYA,EAAQ,WAAa,KAGjC,KAAA,YAAcE,UAAM,OAAO,CAC9B,QAAS,KAAK,KACd,QAAS,CACP,OAAQ,mBACR,eAAgB,mBAChB,cAAe,UAAU,KAAK,MAAM,GACpC,qBAAsB,KAAK,UAC3B,aAAc,KAAK,aAAa,CAAA,CAClC,CACD,EAEG,OAAO,OAAW,MACf,KAAA,OAAS,IAAIC,EAAA,OAAO,GAAG,KAAK,KAAK,QAAQ,OAAQ,IAAI,CAAC,SAAU,CACnE,OAAQ,CACN,WAAY,KAAK,UACjB,QAAS,KAAK,MAAA,CAChB,CACD,GAGHC,EAAA,QAAW,KAAK,YAAa,CAC3B,QAAS,EACT,eAAgB,KAAK,gBACrB,WAAYA,EAAAA,QAAW,gBAAA,CACxB,CAAA,CAGH,MAAM,YAAYC,EAA+C,CAC3D,GAAA,CACF,MAAMC,EAAS,MAAM,KAAK,YAAYD,CAAG,EAElC,MAAA,CACL,WAAYC,EAAO,OAAS,IAAM,KAAO,QACzC,KAAMA,EAAO,KACb,MAAO,OACP,OAAQA,EAAO,MACjB,QAGOC,EAAY,CACnB,eAAQ,MAAMA,CAAC,EAER,CACL,WAAY,QACZ,OAAQ,IACR,KAAM,OACN,MAAOA,CACT,CAAA,CACF,CAGM,gBAAgBC,EAAmB,CAErC,OAAAJ,EAAA,QAAW,eAAeI,CAAK,EAC1B,GAGJA,EAAM,SAMPA,EAAM,SAAS,QAAU,KAAOA,EAAM,SAAS,QAAU,KAKzDA,EAAM,SAAS,SAAW,IATrB,EAaF,CAGD,cAAe,CAMd,MAAA,uBAAoD,CAE/D"}
|
package/dist/esm/api.mjs
CHANGED
|
@@ -17,7 +17,8 @@ class y {
|
|
|
17
17
|
Accept: "application/json",
|
|
18
18
|
"Content-Type": "application/json",
|
|
19
19
|
Authorization: `Bearer ${this.apiKey}`,
|
|
20
|
-
"X-Knock-User-Token": this.userToken
|
|
20
|
+
"X-Knock-User-Token": this.userToken,
|
|
21
|
+
"User-Agent": this.getUserAgent()
|
|
21
22
|
}
|
|
22
23
|
}), typeof window < "u" && (this.socket = new u(`${this.host.replace("http", "ws")}/ws/v1`, {
|
|
23
24
|
params: {
|
|
@@ -51,6 +52,9 @@ class y {
|
|
|
51
52
|
canRetryRequest(e) {
|
|
52
53
|
return o.isNetworkError(e) ? !0 : e.response ? e.response.status >= 500 && e.response.status <= 599 || e.response.status === 429 : !1;
|
|
53
54
|
}
|
|
55
|
+
getUserAgent() {
|
|
56
|
+
return "Knock/ClientJS 0.15.2";
|
|
57
|
+
}
|
|
54
58
|
}
|
|
55
59
|
export {
|
|
56
60
|
y as default
|
package/dist/esm/api.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"api.mjs","sources":["../../src/api.ts"],"sourcesContent":["import axios, { AxiosError, AxiosInstance, AxiosRequestConfig } from \"axios\";\nimport axiosRetry from \"axios-retry\";\nimport { Socket } from \"phoenix\";\n\ntype ApiClientOptions = {\n host: string;\n apiKey: string;\n userToken: string | undefined;\n};\n\nexport interface ApiResponse {\n // eslint-disable-next-line\n error?: any;\n // eslint-disable-next-line\n body?: any;\n statusCode: \"ok\" | \"error\";\n status: number;\n}\n\nclass ApiClient {\n private host: string;\n private apiKey: string;\n private userToken: string | null;\n private axiosClient: AxiosInstance;\n\n public socket: Socket | undefined;\n\n constructor(options: ApiClientOptions) {\n this.host = options.host;\n this.apiKey = options.apiKey;\n this.userToken = options.userToken || null;\n\n // Create a retryable axios client\n this.axiosClient = axios.create({\n baseURL: this.host,\n headers: {\n Accept: \"application/json\",\n \"Content-Type\": \"application/json\",\n Authorization: `Bearer ${this.apiKey}`,\n \"X-Knock-User-Token\": this.userToken,\n },\n });\n\n if (typeof window !== \"undefined\") {\n this.socket = new Socket(`${this.host.replace(\"http\", \"ws\")}/ws/v1`, {\n params: {\n user_token: this.userToken,\n api_key: this.apiKey,\n },\n });\n }\n\n axiosRetry(this.axiosClient, {\n retries: 3,\n retryCondition: this.canRetryRequest,\n retryDelay: axiosRetry.exponentialDelay,\n });\n }\n\n async makeRequest(req: AxiosRequestConfig): Promise<ApiResponse> {\n try {\n const result = await this.axiosClient(req);\n\n return {\n statusCode: result.status < 300 ? \"ok\" : \"error\",\n body: result.data,\n error: undefined,\n status: result.status,\n };\n\n // eslint:disable-next-line\n } catch (e: unknown) {\n console.error(e);\n\n return {\n statusCode: \"error\",\n status: 500,\n body: undefined,\n error: e,\n };\n }\n }\n\n private canRetryRequest(error: AxiosError) {\n // Retry Network Errors.\n if (axiosRetry.isNetworkError(error)) {\n return true;\n }\n\n if (!error.response) {\n // Cannot determine if the request can be retried\n return false;\n }\n\n // Retry Server Errors (5xx).\n if (error.response.status >= 500 && error.response.status <= 599) {\n return true;\n }\n\n // Retry if rate limited.\n if (error.response.status === 429) {\n return true;\n }\n\n return false;\n }\n}\n\nexport default ApiClient;\n"],"names":["ApiClient","options","__publicField","axios","Socket","axiosRetry","req","result","e","error"],"mappings":";;;;;;AAmBA,MAAMA,EAAU;AAAA,EAQd,YAAYC,GAA2B;AAP/B,IAAAC,EAAA;AACA,IAAAA,EAAA;AACA,IAAAA,EAAA;AACA,IAAAA,EAAA;AAED,IAAAA,EAAA;AAGL,SAAK,OAAOD,EAAQ,MACpB,KAAK,SAASA,EAAQ,QACjB,KAAA,YAAYA,EAAQ,aAAa,MAGjC,KAAA,cAAcE,EAAM,OAAO;AAAA,MAC9B,SAAS,KAAK;AAAA,MACd,SAAS;AAAA,QACP,QAAQ;AAAA,QACR,gBAAgB;AAAA,QAChB,eAAe,UAAU,KAAK,MAAM;AAAA,QACpC,sBAAsB,KAAK;AAAA,MAAA;AAAA,
|
|
1
|
+
{"version":3,"file":"api.mjs","sources":["../../src/api.ts"],"sourcesContent":["import axios, { AxiosError, AxiosInstance, AxiosRequestConfig } from \"axios\";\nimport axiosRetry from \"axios-retry\";\nimport { Socket } from \"phoenix\";\n\ntype ApiClientOptions = {\n host: string;\n apiKey: string;\n userToken: string | undefined;\n};\n\nexport interface ApiResponse {\n // eslint-disable-next-line\n error?: any;\n // eslint-disable-next-line\n body?: any;\n statusCode: \"ok\" | \"error\";\n status: number;\n}\n\nclass ApiClient {\n private host: string;\n private apiKey: string;\n private userToken: string | null;\n private axiosClient: AxiosInstance;\n\n public socket: Socket | undefined;\n\n constructor(options: ApiClientOptions) {\n this.host = options.host;\n this.apiKey = options.apiKey;\n this.userToken = options.userToken || null;\n\n // Create a retryable axios client\n this.axiosClient = axios.create({\n baseURL: this.host,\n headers: {\n Accept: \"application/json\",\n \"Content-Type\": \"application/json\",\n Authorization: `Bearer ${this.apiKey}`,\n \"X-Knock-User-Token\": this.userToken,\n \"User-Agent\": this.getUserAgent(),\n },\n });\n\n if (typeof window !== \"undefined\") {\n this.socket = new Socket(`${this.host.replace(\"http\", \"ws\")}/ws/v1`, {\n params: {\n user_token: this.userToken,\n api_key: this.apiKey,\n },\n });\n }\n\n axiosRetry(this.axiosClient, {\n retries: 3,\n retryCondition: this.canRetryRequest,\n retryDelay: axiosRetry.exponentialDelay,\n });\n }\n\n async makeRequest(req: AxiosRequestConfig): Promise<ApiResponse> {\n try {\n const result = await this.axiosClient(req);\n\n return {\n statusCode: result.status < 300 ? \"ok\" : \"error\",\n body: result.data,\n error: undefined,\n status: result.status,\n };\n\n // eslint:disable-next-line\n } catch (e: unknown) {\n console.error(e);\n\n return {\n statusCode: \"error\",\n status: 500,\n body: undefined,\n error: e,\n };\n }\n }\n\n private canRetryRequest(error: AxiosError) {\n // Retry Network Errors.\n if (axiosRetry.isNetworkError(error)) {\n return true;\n }\n\n if (!error.response) {\n // Cannot determine if the request can be retried\n return false;\n }\n\n // Retry Server Errors (5xx).\n if (error.response.status >= 500 && error.response.status <= 599) {\n return true;\n }\n\n // Retry if rate limited.\n if (error.response.status === 429) {\n return true;\n }\n\n return false;\n }\n\n private getUserAgent() {\n // Note: we're following format used in our Stainless SDKs:\n // https://github.com/knocklabs/knock-node/blob/main/src/client.ts#L335\n // If we add the env var to turbo.json, it caches it so the version\n // never actually updates.\n // eslint-disable-next-line turbo/no-undeclared-env-vars\n return `Knock/ClientJS ${process.env.CLIENT_PACKAGE_VERSION}`;\n }\n}\n\nexport default ApiClient;\n"],"names":["ApiClient","options","__publicField","axios","Socket","axiosRetry","req","result","e","error"],"mappings":";;;;;;AAmBA,MAAMA,EAAU;AAAA,EAQd,YAAYC,GAA2B;AAP/B,IAAAC,EAAA;AACA,IAAAA,EAAA;AACA,IAAAA,EAAA;AACA,IAAAA,EAAA;AAED,IAAAA,EAAA;AAGL,SAAK,OAAOD,EAAQ,MACpB,KAAK,SAASA,EAAQ,QACjB,KAAA,YAAYA,EAAQ,aAAa,MAGjC,KAAA,cAAcE,EAAM,OAAO;AAAA,MAC9B,SAAS,KAAK;AAAA,MACd,SAAS;AAAA,QACP,QAAQ;AAAA,QACR,gBAAgB;AAAA,QAChB,eAAe,UAAU,KAAK,MAAM;AAAA,QACpC,sBAAsB,KAAK;AAAA,QAC3B,cAAc,KAAK,aAAa;AAAA,MAAA;AAAA,IAClC,CACD,GAEG,OAAO,SAAW,QACf,KAAA,SAAS,IAAIC,EAAO,GAAG,KAAK,KAAK,QAAQ,QAAQ,IAAI,CAAC,UAAU;AAAA,MACnE,QAAQ;AAAA,QACN,YAAY,KAAK;AAAA,QACjB,SAAS,KAAK;AAAA,MAAA;AAAA,IAChB,CACD,IAGHC,EAAW,KAAK,aAAa;AAAA,MAC3B,SAAS;AAAA,MACT,gBAAgB,KAAK;AAAA,MACrB,YAAYA,EAAW;AAAA,IAAA,CACxB;AAAA,EAAA;AAAA,EAGH,MAAM,YAAYC,GAA+C;AAC3D,QAAA;AACF,YAAMC,IAAS,MAAM,KAAK,YAAYD,CAAG;AAElC,aAAA;AAAA,QACL,YAAYC,EAAO,SAAS,MAAM,OAAO;AAAA,QACzC,MAAMA,EAAO;AAAA,QACb,OAAO;AAAA,QACP,QAAQA,EAAO;AAAA,MACjB;AAAA,aAGOC,GAAY;AACnB,qBAAQ,MAAMA,CAAC,GAER;AAAA,QACL,YAAY;AAAA,QACZ,QAAQ;AAAA,QACR,MAAM;AAAA,QACN,OAAOA;AAAA,MACT;AAAA,IAAA;AAAA,EACF;AAAA,EAGM,gBAAgBC,GAAmB;AAErC,WAAAJ,EAAW,eAAeI,CAAK,IAC1B,KAGJA,EAAM,WAMPA,EAAM,SAAS,UAAU,OAAOA,EAAM,SAAS,UAAU,OAKzDA,EAAM,SAAS,WAAW,MATrB;AAAA,EAaF;AAAA,EAGD,eAAe;AAMd,WAAA;AAAA,EAAoD;AAE/D;"}
|
package/dist/types/api.d.ts
CHANGED
package/dist/types/api.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"api.d.ts","sourceRoot":"","sources":["../../src/api.ts"],"names":[],"mappings":"AAAA,OAAc,EAA6B,kBAAkB,EAAE,MAAM,OAAO,CAAC;AAE7E,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AAEjC,KAAK,gBAAgB,GAAG;IACtB,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,MAAM,GAAG,SAAS,CAAC;CAC/B,CAAC;AAEF,MAAM,WAAW,WAAW;IAE1B,KAAK,CAAC,EAAE,GAAG,CAAC;IAEZ,IAAI,CAAC,EAAE,GAAG,CAAC;IACX,UAAU,EAAE,IAAI,GAAG,OAAO,CAAC;IAC3B,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,cAAM,SAAS;IACb,OAAO,CAAC,IAAI,CAAS;IACrB,OAAO,CAAC,MAAM,CAAS;IACvB,OAAO,CAAC,SAAS,CAAgB;IACjC,OAAO,CAAC,WAAW,CAAgB;IAE5B,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC;gBAEtB,OAAO,EAAE,gBAAgB;
|
|
1
|
+
{"version":3,"file":"api.d.ts","sourceRoot":"","sources":["../../src/api.ts"],"names":[],"mappings":"AAAA,OAAc,EAA6B,kBAAkB,EAAE,MAAM,OAAO,CAAC;AAE7E,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AAEjC,KAAK,gBAAgB,GAAG;IACtB,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,MAAM,GAAG,SAAS,CAAC;CAC/B,CAAC;AAEF,MAAM,WAAW,WAAW;IAE1B,KAAK,CAAC,EAAE,GAAG,CAAC;IAEZ,IAAI,CAAC,EAAE,GAAG,CAAC;IACX,UAAU,EAAE,IAAI,GAAG,OAAO,CAAC;IAC3B,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,cAAM,SAAS;IACb,OAAO,CAAC,IAAI,CAAS;IACrB,OAAO,CAAC,MAAM,CAAS;IACvB,OAAO,CAAC,SAAS,CAAgB;IACjC,OAAO,CAAC,WAAW,CAAgB;IAE5B,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC;gBAEtB,OAAO,EAAE,gBAAgB;IAiC/B,WAAW,CAAC,GAAG,EAAE,kBAAkB,GAAG,OAAO,CAAC,WAAW,CAAC;IAwBhE,OAAO,CAAC,eAAe;IAwBvB,OAAO,CAAC,YAAY;CAQrB;AAED,eAAe,SAAS,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@knocklabs/client",
|
|
3
|
-
"version": "0.15.
|
|
3
|
+
"version": "0.15.2",
|
|
4
4
|
"description": "The clientside library for interacting with Knock",
|
|
5
5
|
"homepage": "https://github.com/knocklabs/javascript/tree/main/packages/client",
|
|
6
6
|
"author": "@knocklabs",
|
|
@@ -77,7 +77,7 @@
|
|
|
77
77
|
"eventemitter2": "^6.4.5",
|
|
78
78
|
"jwt-decode": "^4.0.0",
|
|
79
79
|
"nanoid": "^3.3.11",
|
|
80
|
-
"phoenix": "1.7.
|
|
80
|
+
"phoenix": "1.7.21",
|
|
81
81
|
"urlpattern-polyfill": "^10.0.0"
|
|
82
82
|
}
|
|
83
83
|
}
|
package/src/api.ts
CHANGED
|
@@ -38,6 +38,7 @@ class ApiClient {
|
|
|
38
38
|
"Content-Type": "application/json",
|
|
39
39
|
Authorization: `Bearer ${this.apiKey}`,
|
|
40
40
|
"X-Knock-User-Token": this.userToken,
|
|
41
|
+
"User-Agent": this.getUserAgent(),
|
|
41
42
|
},
|
|
42
43
|
});
|
|
43
44
|
|
|
@@ -104,6 +105,15 @@ class ApiClient {
|
|
|
104
105
|
|
|
105
106
|
return false;
|
|
106
107
|
}
|
|
108
|
+
|
|
109
|
+
private getUserAgent() {
|
|
110
|
+
// Note: we're following format used in our Stainless SDKs:
|
|
111
|
+
// https://github.com/knocklabs/knock-node/blob/main/src/client.ts#L335
|
|
112
|
+
// If we add the env var to turbo.json, it caches it so the version
|
|
113
|
+
// never actually updates.
|
|
114
|
+
// eslint-disable-next-line turbo/no-undeclared-env-vars
|
|
115
|
+
return `Knock/ClientJS ${process.env.CLIENT_PACKAGE_VERSION}`;
|
|
116
|
+
}
|
|
107
117
|
}
|
|
108
118
|
|
|
109
119
|
export default ApiClient;
|