@knocklabs/client 0.19.1 → 0.19.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/CHANGELOG.md +24 -0
- package/dist/cjs/api.js +1 -1
- package/dist/cjs/api.js.map +1 -1
- package/dist/cjs/clients/guide/client.js +1 -1
- package/dist/cjs/clients/guide/client.js.map +1 -1
- package/dist/cjs/knock.js +2 -2
- package/dist/cjs/knock.js.map +1 -1
- package/dist/esm/api.mjs +20 -17
- package/dist/esm/api.mjs.map +1 -1
- package/dist/esm/clients/guide/client.mjs +50 -49
- package/dist/esm/clients/guide/client.mjs.map +1 -1
- package/dist/esm/knock.mjs +20 -18
- package/dist/esm/knock.mjs.map +1 -1
- package/dist/types/api.d.ts +2 -0
- package/dist/types/api.d.ts.map +1 -1
- package/dist/types/clients/guide/client.d.ts +1 -1
- package/dist/types/clients/guide/client.d.ts.map +1 -1
- package/dist/types/interfaces.d.ts +1 -0
- package/dist/types/interfaces.d.ts.map +1 -1
- package/dist/types/knock.d.ts +1 -0
- package/dist/types/knock.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/api.ts +5 -0
- package/src/clients/guide/client.ts +3 -2
- package/src/interfaces.ts +1 -0
- package/src/knock.ts +3 -0
package/dist/esm/knock.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"knock.mjs","sources":["../../src/knock.ts"],"sourcesContent":["import { jwtDecode } from \"jwt-decode\";\n\nimport ApiClient from \"./api\";\nimport FeedClient from \"./clients/feed\";\nimport MessageClient from \"./clients/messages\";\nimport MsTeamsClient from \"./clients/ms-teams\";\nimport ObjectClient from \"./clients/objects\";\nimport Preferences from \"./clients/preferences\";\nimport SlackClient from \"./clients/slack\";\nimport UserClient from \"./clients/users\";\nimport {\n AuthenticateOptions,\n KnockOptions,\n LogLevel,\n UserId,\n UserIdOrUserWithProperties,\n UserTokenExpiringCallback,\n} from \"./interfaces\";\n\nconst DEFAULT_HOST = \"https://api.knock.app\";\n\nclass Knock {\n public host: string;\n private apiClient: ApiClient | null = null;\n public userId: string | undefined | null;\n public userToken?: string;\n public logLevel?: LogLevel;\n private tokenExpirationTimer: ReturnType<typeof setTimeout> | null = null;\n readonly feeds = new FeedClient(this);\n readonly objects = new ObjectClient(this);\n readonly preferences = new Preferences(this);\n readonly slack = new SlackClient(this);\n readonly msTeams = new MsTeamsClient(this);\n readonly user = new UserClient(this);\n readonly messages = new MessageClient(this);\n\n constructor(\n readonly apiKey: string,\n options: KnockOptions = {},\n ) {\n this.host = options.host || DEFAULT_HOST;\n this.logLevel = options.logLevel;\n\n this.log(\"Initialized Knock instance\");\n\n // Fail loudly if we're using the wrong API key\n if (this.apiKey && this.apiKey.startsWith(\"sk_\")) {\n throw new Error(\n \"[Knock] You are using your secret API key on the client. Please use the public key.\",\n );\n }\n }\n\n client() {\n // Initiate a new API client if we don't have one yet\n if (!this.apiClient) {\n this.apiClient = this.createApiClient();\n }\n\n return this.apiClient;\n }\n\n /**\n * @deprecated Passing `userId` as a `string` is deprecated and will be removed in a future version.\n * Please pass a `user` object instead containing an `id` value.\n * example:\n * ```ts\n * knock.authenticate({ id: \"user_123\" });\n * ```\n */\n authenticate(\n userIdOrUserWithProperties: UserId,\n userToken?: Knock[\"userToken\"],\n options?: AuthenticateOptions,\n ): never;\n authenticate(\n userIdOrUserWithProperties: UserIdOrUserWithProperties,\n userToken?: Knock[\"userToken\"],\n options?: AuthenticateOptions,\n ): void;\n authenticate(\n userIdOrUserWithProperties: UserIdOrUserWithProperties,\n userToken?: Knock[\"userToken\"],\n options?: AuthenticateOptions,\n ) {\n let reinitializeApi = false;\n const currentApiClient = this.apiClient;\n const userId = this.getUserId(userIdOrUserWithProperties);\n const identificationStrategy = options?.identificationStrategy || \"inline\";\n\n // If we've previously been initialized and the values have now changed, then we\n // need to reinitialize any stateful connections we have\n if (\n currentApiClient &&\n (this.userId !== userId || this.userToken !== userToken)\n ) {\n this.log(\"userId or userToken changed; reinitializing connections\");\n this.feeds.teardownInstances();\n this.teardown();\n reinitializeApi = true;\n }\n\n this.userId = userId;\n this.userToken = userToken;\n\n this.log(`Authenticated with userId ${userId}`);\n\n if (this.userToken && options?.onUserTokenExpiring instanceof Function) {\n this.maybeScheduleUserTokenExpiration(\n options.onUserTokenExpiring,\n options.timeBeforeExpirationInMs,\n );\n }\n\n // If we get the signal to reinitialize the api client, then we want to create a new client\n // and the reinitialize any existing feed real-time connections we have so everything continues\n // to work with the new credentials we've been given\n if (reinitializeApi) {\n this.apiClient = this.createApiClient();\n this.feeds.reinitializeInstances();\n this.log(\"Reinitialized real-time connections\");\n }\n\n // We explicitly skip the inline identification if the strategy is set to \"skip\"\n if (identificationStrategy === \"skip\") {\n this.log(\"Skipping inline user identification\");\n return;\n }\n\n // Inline identify the user if we've been given an object with an id\n // and the strategy is set to \"inline\".\n if (\n identificationStrategy === \"inline\" &&\n typeof userIdOrUserWithProperties === \"object\" &&\n userIdOrUserWithProperties?.id\n ) {\n this.log(`Identifying user ${userIdOrUserWithProperties.id} inline`);\n const { id, ...properties } = userIdOrUserWithProperties;\n this.user.identify(properties).catch((err) => {\n const errorMessage =\n err instanceof Error ? err.message : \"Unknown error\";\n\n this.log(\n `Error identifying user ${userIdOrUserWithProperties.id} inline:\\n${errorMessage}`,\n );\n });\n }\n\n return;\n }\n\n failIfNotAuthenticated() {\n if (!this.isAuthenticated()) {\n throw new Error(\"Not authenticated. Please call `authenticate` first.\");\n }\n }\n\n /*\n Returns whether or this Knock instance is authenticated. Passing `true` will check the presence\n of the userToken as well.\n */\n isAuthenticated(checkUserToken = false) {\n return checkUserToken ? !!(this.userId && this.userToken) : !!this.userId;\n }\n\n // Used to teardown any connected instances\n teardown() {\n if (this.tokenExpirationTimer) {\n clearTimeout(this.tokenExpirationTimer);\n }\n if (this.apiClient?.socket && this.apiClient.socket.isConnected()) {\n this.apiClient.socket.disconnect();\n }\n }\n\n log(message: string, force = false) {\n if (this.logLevel === \"debug\" || force) {\n console.log(`[Knock] ${message}`);\n }\n }\n\n /**\n * Initiates an API client\n */\n private createApiClient() {\n return new ApiClient({\n apiKey: this.apiKey,\n host: this.host,\n userToken: this.userToken,\n });\n }\n\n private async maybeScheduleUserTokenExpiration(\n callbackFn: UserTokenExpiringCallback,\n timeBeforeExpirationInMs: number = 30_000,\n ) {\n if (!this.userToken) return;\n\n const decoded = jwtDecode(this.userToken);\n const expiresAtMs = (decoded.exp ?? 0) * 1000;\n const nowMs = Date.now();\n\n // Expiration is in the future\n if (expiresAtMs && expiresAtMs > nowMs) {\n // Check how long until the token should be regenerated\n // | ----------------- | ----------------------- |\n // ^ now ^ expiration offset ^ expires at\n const msInFuture = expiresAtMs - timeBeforeExpirationInMs - nowMs;\n\n this.tokenExpirationTimer = setTimeout(async () => {\n const newToken = await callbackFn(this.userToken as string, decoded);\n\n // Reauthenticate which will handle reinitializing sockets\n if (typeof newToken === \"string\") {\n this.authenticate(this.userId!, newToken, {\n onUserTokenExpiring: callbackFn,\n timeBeforeExpirationInMs: timeBeforeExpirationInMs,\n });\n }\n }, msInFuture);\n }\n }\n\n /**\n * Returns the user id from the given userIdOrUserWithProperties\n * @param userIdOrUserWithProperties - The user id or user object\n * @returns The user id\n * @throws {Error} If the user object does not contain an `id` property\n */\n private getUserId(userIdOrUserWithProperties: UserIdOrUserWithProperties) {\n if (\n typeof userIdOrUserWithProperties === \"string\" ||\n !userIdOrUserWithProperties\n ) {\n return userIdOrUserWithProperties;\n }\n\n if (userIdOrUserWithProperties?.id) {\n return userIdOrUserWithProperties.id;\n }\n\n return undefined;\n }\n}\n\nexport default Knock;\n"],"names":["DEFAULT_HOST","Knock","apiKey","options","__publicField","FeedClient","ObjectClient","Preferences","SlackClient","MsTeamsClient","UserClient","MessageClient","userIdOrUserWithProperties","userToken","reinitializeApi","currentApiClient","userId","identificationStrategy","id","properties","err","errorMessage","checkUserToken","_a","message","force","ApiClient","callbackFn","timeBeforeExpirationInMs","decoded","jwtDecode","expiresAtMs","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AA;AAAA,EAMM,kBAAkB;AACxB,WAAO,IAAIE,EAAU;AAAA,MACnB,QAAQ,KAAK;AAAA,MACb,MAAM,KAAK;AAAA,MACX,WAAW,KAAK;AAAA,IAAA,CACjB;AAAA,EAAA;AAAA,EAGH,MAAc,iCACZC,GACAC,IAAmC,KACnC;AACI,QAAA,CAAC,KAAK,UAAW;AAEf,UAAAC,IAAUC,EAAU,KAAK,SAAS,GAClCC,KAAeF,EAAQ,OAAO,KAAK,KACnCG,IAAQ,KAAK,IAAI;AAGnB,QAAAD,KAAeA,IAAcC,GAAO;AAIhC,YAAAC,IAAaF,IAAcH,IAA2BI;AAEvD,WAAA,uBAAuB,WAAW,YAAY;AACjD,cAAME,IAAW,MAAMP,EAAW,KAAK,WAAqBE,CAAO;AAG/D,QAAA,OAAOK,KAAa,YACjB,KAAA,aAAa,KAAK,QAASA,GAAU;AAAA,UACxC,qBAAqBP;AAAA,UACrB,0BAAAC;AAAA,QAAA,CACD;AAAA,SAEFK,CAAU;AAAA,IAAA;AAAA,EACf;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EASM,UAAUrB,GAAwD;AACxE,QACE,OAAOA,KAA+B,YACtC,CAACA;AAEM,aAAAA;AAGT,QAAIA,KAAA,QAAAA,EAA4B;AAC9B,aAAOA,EAA2B;AAAA,EAG7B;AAEX;"}
|
|
1
|
+
{"version":3,"file":"knock.mjs","sources":["../../src/knock.ts"],"sourcesContent":["import { jwtDecode } from \"jwt-decode\";\n\nimport ApiClient from \"./api\";\nimport FeedClient from \"./clients/feed\";\nimport MessageClient from \"./clients/messages\";\nimport MsTeamsClient from \"./clients/ms-teams\";\nimport ObjectClient from \"./clients/objects\";\nimport Preferences from \"./clients/preferences\";\nimport SlackClient from \"./clients/slack\";\nimport UserClient from \"./clients/users\";\nimport {\n AuthenticateOptions,\n KnockOptions,\n LogLevel,\n UserId,\n UserIdOrUserWithProperties,\n UserTokenExpiringCallback,\n} from \"./interfaces\";\n\nconst DEFAULT_HOST = \"https://api.knock.app\";\n\nclass Knock {\n public host: string;\n private apiClient: ApiClient | null = null;\n public userId: string | undefined | null;\n public userToken?: string;\n public logLevel?: LogLevel;\n public readonly branch?: string;\n private tokenExpirationTimer: ReturnType<typeof setTimeout> | null = null;\n readonly feeds = new FeedClient(this);\n readonly objects = new ObjectClient(this);\n readonly preferences = new Preferences(this);\n readonly slack = new SlackClient(this);\n readonly msTeams = new MsTeamsClient(this);\n readonly user = new UserClient(this);\n readonly messages = new MessageClient(this);\n\n constructor(\n readonly apiKey: string,\n options: KnockOptions = {},\n ) {\n this.host = options.host || DEFAULT_HOST;\n this.logLevel = options.logLevel;\n this.branch = options.branch || undefined;\n\n this.log(\"Initialized Knock instance\");\n\n // Fail loudly if we're using the wrong API key\n if (this.apiKey && this.apiKey.startsWith(\"sk_\")) {\n throw new Error(\n \"[Knock] You are using your secret API key on the client. Please use the public key.\",\n );\n }\n }\n\n client() {\n // Initiate a new API client if we don't have one yet\n if (!this.apiClient) {\n this.apiClient = this.createApiClient();\n }\n\n return this.apiClient;\n }\n\n /**\n * @deprecated Passing `userId` as a `string` is deprecated and will be removed in a future version.\n * Please pass a `user` object instead containing an `id` value.\n * example:\n * ```ts\n * knock.authenticate({ id: \"user_123\" });\n * ```\n */\n authenticate(\n userIdOrUserWithProperties: UserId,\n userToken?: Knock[\"userToken\"],\n options?: AuthenticateOptions,\n ): never;\n authenticate(\n userIdOrUserWithProperties: UserIdOrUserWithProperties,\n userToken?: Knock[\"userToken\"],\n options?: AuthenticateOptions,\n ): void;\n authenticate(\n userIdOrUserWithProperties: UserIdOrUserWithProperties,\n userToken?: Knock[\"userToken\"],\n options?: AuthenticateOptions,\n ) {\n let reinitializeApi = false;\n const currentApiClient = this.apiClient;\n const userId = this.getUserId(userIdOrUserWithProperties);\n const identificationStrategy = options?.identificationStrategy || \"inline\";\n\n // If we've previously been initialized and the values have now changed, then we\n // need to reinitialize any stateful connections we have\n if (\n currentApiClient &&\n (this.userId !== userId || this.userToken !== userToken)\n ) {\n this.log(\"userId or userToken changed; reinitializing connections\");\n this.feeds.teardownInstances();\n this.teardown();\n reinitializeApi = true;\n }\n\n this.userId = userId;\n this.userToken = userToken;\n\n this.log(`Authenticated with userId ${userId}`);\n\n if (this.userToken && options?.onUserTokenExpiring instanceof Function) {\n this.maybeScheduleUserTokenExpiration(\n options.onUserTokenExpiring,\n options.timeBeforeExpirationInMs,\n );\n }\n\n // If we get the signal to reinitialize the api client, then we want to create a new client\n // and the reinitialize any existing feed real-time connections we have so everything continues\n // to work with the new credentials we've been given\n if (reinitializeApi) {\n this.apiClient = this.createApiClient();\n this.feeds.reinitializeInstances();\n this.log(\"Reinitialized real-time connections\");\n }\n\n // We explicitly skip the inline identification if the strategy is set to \"skip\"\n if (identificationStrategy === \"skip\") {\n this.log(\"Skipping inline user identification\");\n return;\n }\n\n // Inline identify the user if we've been given an object with an id\n // and the strategy is set to \"inline\".\n if (\n identificationStrategy === \"inline\" &&\n typeof userIdOrUserWithProperties === \"object\" &&\n userIdOrUserWithProperties?.id\n ) {\n this.log(`Identifying user ${userIdOrUserWithProperties.id} inline`);\n const { id, ...properties } = userIdOrUserWithProperties;\n this.user.identify(properties).catch((err) => {\n const errorMessage =\n err instanceof Error ? err.message : \"Unknown error\";\n\n this.log(\n `Error identifying user ${userIdOrUserWithProperties.id} inline:\\n${errorMessage}`,\n );\n });\n }\n\n return;\n }\n\n failIfNotAuthenticated() {\n if (!this.isAuthenticated()) {\n throw new Error(\"Not authenticated. Please call `authenticate` first.\");\n }\n }\n\n /*\n Returns whether or this Knock instance is authenticated. Passing `true` will check the presence\n of the userToken as well.\n */\n isAuthenticated(checkUserToken = false) {\n return checkUserToken ? !!(this.userId && this.userToken) : !!this.userId;\n }\n\n // Used to teardown any connected instances\n teardown() {\n if (this.tokenExpirationTimer) {\n clearTimeout(this.tokenExpirationTimer);\n }\n if (this.apiClient?.socket && this.apiClient.socket.isConnected()) {\n this.apiClient.socket.disconnect();\n }\n }\n\n log(message: string, force = false) {\n if (this.logLevel === \"debug\" || force) {\n console.log(`[Knock] ${message}`);\n }\n }\n\n /**\n * Initiates an API client\n */\n private createApiClient() {\n return new ApiClient({\n apiKey: this.apiKey,\n host: this.host,\n userToken: this.userToken,\n branch: this.branch,\n });\n }\n\n private async maybeScheduleUserTokenExpiration(\n callbackFn: UserTokenExpiringCallback,\n timeBeforeExpirationInMs: number = 30_000,\n ) {\n if (!this.userToken) return;\n\n const decoded = jwtDecode(this.userToken);\n const expiresAtMs = (decoded.exp ?? 0) * 1000;\n const nowMs = Date.now();\n\n // Expiration is in the future\n if (expiresAtMs && expiresAtMs > nowMs) {\n // Check how long until the token should be regenerated\n // | ----------------- | ----------------------- |\n // ^ now ^ expiration offset ^ expires at\n const msInFuture = expiresAtMs - timeBeforeExpirationInMs - nowMs;\n\n this.tokenExpirationTimer = setTimeout(async () => {\n const newToken = await callbackFn(this.userToken as string, decoded);\n\n // Reauthenticate which will handle reinitializing sockets\n if (typeof newToken === \"string\") {\n this.authenticate(this.userId!, newToken, {\n onUserTokenExpiring: callbackFn,\n timeBeforeExpirationInMs: timeBeforeExpirationInMs,\n });\n }\n }, msInFuture);\n }\n }\n\n /**\n * Returns the user id from the given userIdOrUserWithProperties\n * @param userIdOrUserWithProperties - The user id or user object\n * @returns The user id\n * @throws {Error} If the user object does not contain an `id` property\n */\n private getUserId(userIdOrUserWithProperties: UserIdOrUserWithProperties) {\n if (\n typeof userIdOrUserWithProperties === \"string\" ||\n !userIdOrUserWithProperties\n ) {\n return userIdOrUserWithProperties;\n }\n\n if (userIdOrUserWithProperties?.id) {\n return userIdOrUserWithProperties.id;\n }\n\n return undefined;\n }\n}\n\nexport default Knock;\n"],"names":["DEFAULT_HOST","Knock","apiKey","options","__publicField","FeedClient","ObjectClient","Preferences","SlackClient","MsTeamsClient","UserClient","MessageClient","userIdOrUserWithProperties","userToken","reinitializeApi","currentApiClient","userId","identificationStrategy","id","properties","err","errorMessage","checkUserToken","_a","message","force","ApiClient","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AO;AAC9B,KAAA,KAAK,aAAa,WAAWA,MACvB,QAAA,IAAI,WAAWD,CAAO,EAAE;AAAA,EAClC;AAAA;AAAA;AAAA;AAAA,EAMM,kBAAkB;AACxB,WAAO,IAAIE,EAAU;AAAA,MACnB,QAAQ,KAAK;AAAA,MACb,MAAM,KAAK;AAAA,MACX,WAAW,KAAK;AAAA,MAChB,QAAQ,KAAK;AAAA,IAAA,CACd;AAAA,EAAA;AAAA,EAGH,MAAc,iCACZC,GACAC,IAAmC,KACnC;AACI,QAAA,CAAC,KAAK,UAAW;AAEf,UAAAC,IAAUC,EAAU,KAAK,SAAS,GAClCC,KAAeF,EAAQ,OAAO,KAAK,KACnCG,IAAQ,KAAK,IAAI;AAGnB,QAAAD,KAAeA,IAAcC,GAAO;AAIhC,YAAAC,IAAaF,IAAcH,IAA2BI;AAEvD,WAAA,uBAAuB,WAAW,YAAY;AACjD,cAAME,IAAW,MAAMP,EAAW,KAAK,WAAqBE,CAAO;AAG/D,QAAA,OAAOK,KAAa,YACjB,KAAA,aAAa,KAAK,QAASA,GAAU;AAAA,UACxC,qBAAqBP;AAAA,UACrB,0BAAAC;AAAA,QAAA,CACD;AAAA,SAEFK,CAAU;AAAA,IAAA;AAAA,EACf;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EASM,UAAUrB,GAAwD;AACxE,QACE,OAAOA,KAA+B,YACtC,CAACA;AAEM,aAAAA;AAGT,QAAIA,KAAA,QAAAA,EAA4B;AAC9B,aAAOA,EAA2B;AAAA,EAG7B;AAEX;"}
|
package/dist/types/api.d.ts
CHANGED
|
@@ -4,6 +4,7 @@ type ApiClientOptions = {
|
|
|
4
4
|
host: string;
|
|
5
5
|
apiKey: string;
|
|
6
6
|
userToken: string | undefined;
|
|
7
|
+
branch?: string;
|
|
7
8
|
};
|
|
8
9
|
export interface ApiResponse {
|
|
9
10
|
error?: any;
|
|
@@ -15,6 +16,7 @@ declare class ApiClient {
|
|
|
15
16
|
private host;
|
|
16
17
|
private apiKey;
|
|
17
18
|
private userToken;
|
|
19
|
+
private branch;
|
|
18
20
|
private axiosClient;
|
|
19
21
|
socket: Socket | undefined;
|
|
20
22
|
constructor(options: ApiClientOptions);
|
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;
|
|
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;IAC9B,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB,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,MAAM,CAAgB;IAC9B,OAAO,CAAC,WAAW,CAAgB;IAE5B,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC;gBAEtB,OAAO,EAAE,gBAAgB;IAoC/B,WAAW,CAAC,GAAG,EAAE,kBAAkB,GAAG,OAAO,CAAC,WAAW,CAAC;IAwBhE,OAAO,CAAC,eAAe;IAwBvB,OAAO,CAAC,oBAAoB;CAQ7B;AAED,eAAe,SAAS,CAAC"}
|
|
@@ -59,6 +59,6 @@ export declare class KnockGuideClient {
|
|
|
59
59
|
private handleLocationChange;
|
|
60
60
|
private checkDebugStateChanged;
|
|
61
61
|
private listenForLocationChangesFromWindow;
|
|
62
|
-
|
|
62
|
+
removeLocationChangeEventListeners(): void;
|
|
63
63
|
}
|
|
64
64
|
//# sourceMappingURL=client.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../../../src/clients/guide/client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC/C,OAAO,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAC;AAIxC,OAAO,KAAK,MAAM,aAAa,CAAC;AAgBhC,OAAO,EACL,GAAG,EACH,eAAe,EAMf,SAAS,EAMT,aAAa,EAEb,UAAU,EACV,cAAc,EAKd,iBAAiB,EACjB,WAAW,EACX,kBAAkB,EAElB,UAAU,EACV,YAAY,EACb,MAAM,SAAS,CAAC;AAcjB,eAAO,MAAM,kBAAkB;;;CAG9B,CAAC;AAWF,eAAO,MAAM,iBAAiB,GAAI,QAAQ,MAAM,GAAG,SAAS,GAAG,IAAI,WACrC,CAAC;AAyK/B,qBAAa,gBAAgB;IA6BzB,QAAQ,CAAC,KAAK,EAAE,KAAK;IACrB,QAAQ,CAAC,SAAS,EAAE,MAAM;IAC1B,QAAQ,CAAC,YAAY,EAAE,YAAY;IACnC,QAAQ,CAAC,OAAO,EAAE,eAAe;IA/B5B,KAAK,EAAE,KAAK,CAAC,UAAU,EAAE,CAAC,KAAK,EAAE,UAAU,KAAK,UAAU,CAAC,CAAC;IAGnE,OAAO,CAAC,MA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EAAE,SAAS,EAChB,IAAI,EAAE,aAAa,EACnB,QAAQ,CAAC,EAAE,WAAW;IA0BlB,cAAc,CAAC,KAAK,EAAE,SAAS,EAAE,IAAI,EAAE,aAAa;IA6B1D,OAAO,CAAC,SAAS;IA4DjB,OAAO,CAAC,gBAAgB;IA4BxB,OAAO,CAAC,cAAc;IActB,OAAO,CAAC,mBAAmB;IAgD3B,OAAO,CAAC,8BAA8B;IAYtC,OAAO,CAAC,iBAAiB;IAYzB,OAAO,CAAC,WAAW;IASnB,OAAO,CAAC,sBAAsB;IAiC9B,OAAO,CAAC,kBAAkB;IAU1B,OAAO,CAAC,oBAAoB,CA6B1B;IAIF,OAAO,CAAC,sBAAsB;IAO9B,OAAO,CAAC,kCAAkC;IAyC1C,kCAAkC;CAgBnC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"interfaces.d.ts","sourceRoot":"","sources":["../../src/interfaces.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC/C,OAAO,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAExC,OAAO,KAAK,MAAM,SAAS,CAAC;AAE5B,MAAM,MAAM,QAAQ,GAAG,OAAO,CAAC;AAE/B,MAAM,WAAW,YAAY;IAC3B,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,QAAQ,CAAC;
|
|
1
|
+
{"version":3,"file":"interfaces.d.ts","sourceRoot":"","sources":["../../src/interfaces.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC/C,OAAO,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAExC,OAAO,KAAK,MAAM,SAAS,CAAC;AAE5B,MAAM,MAAM,QAAQ,GAAG,OAAO,CAAC;AAE/B,MAAM,WAAW,YAAY;IAC3B,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,QAAQ,C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,CAAC,KAAK,cAAyB;IACvC,QAAQ,CAAC,OAAO,gBAA2B;IAC3C,QAAQ,CAAC,IAAI,aAAwB;IACrC,QAAQ,CAAC,QAAQ,gBAA2B;gBAGjC,MAAM,EAAE,MAAM,EACvB,OAAO,GAAE,YAAiB;IAgB5B,MAAM;IASN;;;;;;;OAOG;IACH,YAAY,CACV,0BAA0B,EAAE,MAAM,EAClC,SAAS,CAAC,EAAE,KAAK,CAAC,WAAW,CAAC,EAC9B,OAAO,CAAC,EAAE,mBAAmB,GAC5B,KAAK;IACR,YAAY,CACV,0BAA0B,EAAE,0BAA0B,EACtD,SAAS,CAAC,EAAE,KAAK,CAAC,WAAW,CAAC,EAC9B,OAAO,CAAC,EAAE,mBAAmB,GAC5B,IAAI;IAwEP,sBAAsB;IAUtB,eAAe,CAAC,cAAc,UAAQ;IAKtC,QAAQ;IASR,GAAG,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,UAAQ;IAMlC;;OAEG;IACH,OAAO,CAAC,eAAe;YAST,gCAAgC;IA+B9C;;;;;OAKG;IACH,OAAO,CAAC,SAAS;CAclB;AAED,eAAe,KAAK,CAAC"}
|
package/package.json
CHANGED
package/src/api.ts
CHANGED
|
@@ -6,6 +6,7 @@ type ApiClientOptions = {
|
|
|
6
6
|
host: string;
|
|
7
7
|
apiKey: string;
|
|
8
8
|
userToken: string | undefined;
|
|
9
|
+
branch?: string;
|
|
9
10
|
};
|
|
10
11
|
|
|
11
12
|
export interface ApiResponse {
|
|
@@ -21,6 +22,7 @@ class ApiClient {
|
|
|
21
22
|
private host: string;
|
|
22
23
|
private apiKey: string;
|
|
23
24
|
private userToken: string | null;
|
|
25
|
+
private branch: string | null;
|
|
24
26
|
private axiosClient: AxiosInstance;
|
|
25
27
|
|
|
26
28
|
public socket: Socket | undefined;
|
|
@@ -29,6 +31,7 @@ class ApiClient {
|
|
|
29
31
|
this.host = options.host;
|
|
30
32
|
this.apiKey = options.apiKey;
|
|
31
33
|
this.userToken = options.userToken || null;
|
|
34
|
+
this.branch = options.branch || null;
|
|
32
35
|
|
|
33
36
|
// Create a retryable axios client
|
|
34
37
|
this.axiosClient = axios.create({
|
|
@@ -39,6 +42,7 @@ class ApiClient {
|
|
|
39
42
|
Authorization: `Bearer ${this.apiKey}`,
|
|
40
43
|
"X-Knock-User-Token": this.userToken,
|
|
41
44
|
"X-Knock-Client": this.getKnockClientHeader(),
|
|
45
|
+
"X-Knock-Branch": this.branch,
|
|
42
46
|
},
|
|
43
47
|
});
|
|
44
48
|
|
|
@@ -47,6 +51,7 @@ class ApiClient {
|
|
|
47
51
|
params: {
|
|
48
52
|
user_token: this.userToken,
|
|
49
53
|
api_key: this.apiKey,
|
|
54
|
+
branch_slug: this.branch,
|
|
50
55
|
},
|
|
51
56
|
});
|
|
52
57
|
}
|
|
@@ -341,7 +341,7 @@ export class KnockGuideClient {
|
|
|
341
341
|
|
|
342
342
|
cleanup() {
|
|
343
343
|
this.unsubscribe();
|
|
344
|
-
this.
|
|
344
|
+
this.removeLocationChangeEventListeners();
|
|
345
345
|
this.clearGroupStage();
|
|
346
346
|
this.clearCounterInterval();
|
|
347
347
|
}
|
|
@@ -1144,6 +1144,7 @@ export class KnockGuideClient {
|
|
|
1144
1144
|
|
|
1145
1145
|
// Define as an arrow func property to always bind this to the class instance.
|
|
1146
1146
|
private handleLocationChange = () => {
|
|
1147
|
+
this.knock.log(`[Guide] .handleLocationChange`);
|
|
1147
1148
|
const win = checkForWindow();
|
|
1148
1149
|
if (!win?.location) return;
|
|
1149
1150
|
|
|
@@ -1223,7 +1224,7 @@ export class KnockGuideClient {
|
|
|
1223
1224
|
}
|
|
1224
1225
|
}
|
|
1225
1226
|
|
|
1226
|
-
|
|
1227
|
+
removeLocationChangeEventListeners() {
|
|
1227
1228
|
const win = checkForWindow();
|
|
1228
1229
|
if (!win?.history) return;
|
|
1229
1230
|
|
package/src/interfaces.ts
CHANGED
package/src/knock.ts
CHANGED
|
@@ -25,6 +25,7 @@ class Knock {
|
|
|
25
25
|
public userId: string | undefined | null;
|
|
26
26
|
public userToken?: string;
|
|
27
27
|
public logLevel?: LogLevel;
|
|
28
|
+
public readonly branch?: string;
|
|
28
29
|
private tokenExpirationTimer: ReturnType<typeof setTimeout> | null = null;
|
|
29
30
|
readonly feeds = new FeedClient(this);
|
|
30
31
|
readonly objects = new ObjectClient(this);
|
|
@@ -40,6 +41,7 @@ class Knock {
|
|
|
40
41
|
) {
|
|
41
42
|
this.host = options.host || DEFAULT_HOST;
|
|
42
43
|
this.logLevel = options.logLevel;
|
|
44
|
+
this.branch = options.branch || undefined;
|
|
43
45
|
|
|
44
46
|
this.log("Initialized Knock instance");
|
|
45
47
|
|
|
@@ -187,6 +189,7 @@ class Knock {
|
|
|
187
189
|
apiKey: this.apiKey,
|
|
188
190
|
host: this.host,
|
|
189
191
|
userToken: this.userToken,
|
|
192
|
+
branch: this.branch,
|
|
190
193
|
});
|
|
191
194
|
}
|
|
192
195
|
|