@knocklabs/react-core 0.9.2 → 0.10.1

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 CHANGED
@@ -1,5 +1,24 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.10.1
4
+
5
+ ### Patch Changes
6
+
7
+ - 74366b3: export useStore from react-core to include in use client directive
8
+ - Updated dependencies [74366b3]
9
+ - @knocklabs/client@0.18.1
10
+
11
+ ## 0.10.0
12
+
13
+ ### Minor Changes
14
+
15
+ - 5fc0af9: feat: adds `identificationStrategy` option for user identification control
16
+
17
+ ### Patch Changes
18
+
19
+ - Updated dependencies [5fc0af9]
20
+ - @knocklabs/client@0.18.0
21
+
3
22
  ## 0.9.2
4
23
 
5
24
  ### Patch Changes
package/dist/cjs/index.js CHANGED
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("./modules/core/context/KnockProvider.js"),c=require("./modules/core/hooks/useAuthenticatedKnockClient.js"),a=require("./modules/core/hooks/useStableOptions.js"),d=require("./modules/core/constants.js"),e=require("./modules/core/utils.js"),n=require("./modules/feed/context/KnockFeedProvider.js"),l=require("./modules/feed/hooks/useNotifications.js"),k=require("./modules/feed/hooks/useFeedSettings.js"),o=require("./modules/feed/hooks/useNotificationStore.js"),r=require("./modules/guide/context/KnockGuideProvider.js"),C=require("./modules/guide/hooks/useGuide.js"),K=require("./modules/guide/hooks/useGuides.js"),S=require("./modules/guide/hooks/useGuideContext.js"),t=require("./modules/ms-teams/context/KnockMsTeamsProvider.js"),m=require("./modules/ms-teams/hooks/useMsTeamsConnectionStatus.js"),q=require("./modules/ms-teams/hooks/useMsTeamsAuth.js"),P=require("./modules/ms-teams/hooks/useMsTeamsTeams.js"),v=require("./modules/ms-teams/hooks/useMsTeamsChannels.js"),T=require("./modules/ms-teams/hooks/useConnectedMsTeamsChannels.js"),i=require("./modules/slack/context/KnockSlackProvider.js"),f=require("./modules/slack/hooks/useSlackConnectionStatus.js"),M=require("./modules/slack/hooks/useSlackChannels.js"),h=require("./modules/slack/hooks/useConnectedSlackChannels.js"),G=require("./modules/slack/hooks/useSlackAuth.js"),u=require("./modules/i18n/context/KnockI18nProvider.js"),F=require("./modules/i18n/hooks/useTranslations.js"),x=require("./modules/i18n/languages/index.js"),y=require("./modules/preferences/hooks/usePreferences.js");exports.KnockProvider=s.KnockProvider;exports.useKnockClient=s.useKnockClient;exports.useAuthenticatedKnockClient=c;exports.useStableOptions=a;exports.FilterStatus=d.FilterStatus;exports.feedProviderKey=e.feedProviderKey;exports.formatBadgeCount=e.formatBadgeCount;exports.formatTimestamp=e.formatTimestamp;exports.msTeamsProviderKey=e.msTeamsProviderKey;exports.renderNodeOrFallback=e.renderNodeOrFallback;exports.slackProviderKey=e.slackProviderKey;exports.toSentenceCase=e.toSentenceCase;exports.KnockFeedProvider=n.KnockFeedProvider;exports.useKnockFeed=n.useKnockFeed;exports.useNotifications=l;exports.useFeedSettings=k;exports.useCreateNotificationStore=o.useCreateNotificationStore;exports.useNotificationStore=o.default;exports.KnockGuideContext=r.KnockGuideContext;exports.KnockGuideProvider=r.KnockGuideProvider;exports.useGuide=C.useGuide;exports.useGuides=K.useGuides;exports.useGuideContext=S.useGuideContext;exports.KnockMsTeamsProvider=t.KnockMsTeamsProvider;exports.useKnockMsTeamsClient=t.useKnockMsTeamsClient;exports.useMsTeamsConnectionStatus=m;exports.useMsTeamsAuth=q;exports.useMsTeamsTeams=P;exports.useMsTeamsChannels=v;exports.useConnectedMsTeamsChannels=T;exports.KnockSlackProvider=i.KnockSlackProvider;exports.useKnockSlackClient=i.useKnockSlackClient;exports.useSlackConnectionStatus=f;exports.useSlackChannels=M;exports.useConnectedSlackChannels=h;exports.useSlackAuth=G;exports.I18nContext=u.I18nContext;exports.KnockI18nProvider=u.KnockI18nProvider;exports.useTranslations=F.useTranslations;exports.locales=x.locales;exports.usePreferences=y.usePreferences;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("./modules/core/context/KnockProvider.js"),c=require("./modules/core/hooks/useAuthenticatedKnockClient.js"),a=require("./modules/core/hooks/useStableOptions.js"),d=require("./modules/core/constants.js"),e=require("./modules/core/utils.js"),n=require("./modules/feed/context/KnockFeedProvider.js"),l=require("./modules/feed/hooks/useNotifications.js"),k=require("./modules/feed/hooks/useFeedSettings.js"),r=require("./modules/feed/hooks/useNotificationStore.js"),o=require("./modules/guide/context/KnockGuideProvider.js"),C=require("./modules/guide/hooks/useGuide.js"),K=require("./modules/guide/hooks/useGuides.js"),S=require("./modules/guide/hooks/useGuideContext.js"),t=require("./modules/ms-teams/context/KnockMsTeamsProvider.js"),m=require("./modules/ms-teams/hooks/useMsTeamsConnectionStatus.js"),q=require("./modules/ms-teams/hooks/useMsTeamsAuth.js"),P=require("./modules/ms-teams/hooks/useMsTeamsTeams.js"),v=require("./modules/ms-teams/hooks/useMsTeamsChannels.js"),T=require("./modules/ms-teams/hooks/useConnectedMsTeamsChannels.js"),u=require("./modules/slack/context/KnockSlackProvider.js"),f=require("./modules/slack/hooks/useSlackConnectionStatus.js"),M=require("./modules/slack/hooks/useSlackChannels.js"),h=require("./modules/slack/hooks/useConnectedSlackChannels.js"),G=require("./modules/slack/hooks/useSlackAuth.js"),i=require("./modules/i18n/context/KnockI18nProvider.js"),F=require("./modules/i18n/hooks/useTranslations.js"),y=require("./modules/i18n/languages/index.js"),b=require("./modules/preferences/hooks/usePreferences.js"),x=require("@tanstack/react-store");exports.KnockProvider=s.KnockProvider;exports.useKnockClient=s.useKnockClient;exports.useAuthenticatedKnockClient=c;exports.useStableOptions=a;exports.FilterStatus=d.FilterStatus;exports.feedProviderKey=e.feedProviderKey;exports.formatBadgeCount=e.formatBadgeCount;exports.formatTimestamp=e.formatTimestamp;exports.msTeamsProviderKey=e.msTeamsProviderKey;exports.renderNodeOrFallback=e.renderNodeOrFallback;exports.slackProviderKey=e.slackProviderKey;exports.toSentenceCase=e.toSentenceCase;exports.KnockFeedProvider=n.KnockFeedProvider;exports.useKnockFeed=n.useKnockFeed;exports.useNotifications=l;exports.useFeedSettings=k;exports.useCreateNotificationStore=r.useCreateNotificationStore;exports.useNotificationStore=r.default;exports.KnockGuideContext=o.KnockGuideContext;exports.KnockGuideProvider=o.KnockGuideProvider;exports.useGuide=C.useGuide;exports.useGuides=K.useGuides;exports.useGuideContext=S.useGuideContext;exports.KnockMsTeamsProvider=t.KnockMsTeamsProvider;exports.useKnockMsTeamsClient=t.useKnockMsTeamsClient;exports.useMsTeamsConnectionStatus=m;exports.useMsTeamsAuth=q;exports.useMsTeamsTeams=P;exports.useMsTeamsChannels=v;exports.useConnectedMsTeamsChannels=T;exports.KnockSlackProvider=u.KnockSlackProvider;exports.useKnockSlackClient=u.useKnockSlackClient;exports.useSlackConnectionStatus=f;exports.useSlackChannels=M;exports.useConnectedSlackChannels=h;exports.useSlackAuth=G;exports.I18nContext=i.I18nContext;exports.KnockI18nProvider=i.KnockI18nProvider;exports.useTranslations=F.useTranslations;exports.locales=y.locales;exports.usePreferences=b.usePreferences;Object.defineProperty(exports,"useStore",{enumerable:!0,get:()=>x.useStore});
2
2
  //# sourceMappingURL=index.js.map
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const b=require("react"),K=require("../../i18n/context/KnockI18nProvider.js"),P=require("../hooks/useAuthenticatedKnockClient.js");require("fast-deep-equal");function m(e){if(e&&typeof e=="object"&&"default"in e)return e;const n=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const t in e)if(t!=="default"){const o=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(n,t,o.get?o:{enumerable:!0,get:()=>e[t]})}}return n.default=e,Object.freeze(n)}const r=m(b),a=r.createContext(null),v=({apiKey:e,host:n,logLevel:t,userToken:o,onUserTokenExpiring:u,timeBeforeExpirationInMs:i,children:s,i18n:l,...c})=>{const d=(c==null?void 0:c.user)||(c==null?void 0:c.userId),k=r.useMemo(()=>({host:n,onUserTokenExpiring:u,timeBeforeExpirationInMs:i,logLevel:t}),[n,u,i,t]),f=P(e??"",d,o,k);return r.createElement(a.Provider,{value:{knock:f}},r.createElement(K.KnockI18nProvider,{i18n:l},s))},C=()=>{const e=r.useContext(a);if(!e)throw new Error("useKnockClient must be used within a KnockProvider");return e.knock};exports.KnockProvider=v;exports.useKnockClient=C;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const K=require("react"),P=require("../../i18n/context/KnockI18nProvider.js"),m=require("../hooks/useAuthenticatedKnockClient.js");require("fast-deep-equal");function v(e){if(e&&typeof e=="object"&&"default"in e)return e;const n=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const t in e)if(t!=="default"){const o=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(n,t,o.get?o:{enumerable:!0,get:()=>e[t]})}}return n.default=e,Object.freeze(n)}const r=v(K),s=r.createContext(null),C=({apiKey:e,host:n,logLevel:t,userToken:o,onUserTokenExpiring:u,timeBeforeExpirationInMs:i,children:l,i18n:d,identificationStrategy:a,...c})=>{const k=(c==null?void 0:c.user)||(c==null?void 0:c.userId),f=r.useMemo(()=>({host:n,onUserTokenExpiring:u,timeBeforeExpirationInMs:i,logLevel:t,identificationStrategy:a}),[n,u,i,t,a]),b=m(e??"",k,o,f);return r.createElement(s.Provider,{value:{knock:b}},r.createElement(P.KnockI18nProvider,{i18n:d},l))},O=()=>{const e=r.useContext(s);if(!e)throw new Error("useKnockClient must be used within a KnockProvider");return e.knock};exports.KnockProvider=C;exports.useKnockClient=O;
2
2
  //# sourceMappingURL=KnockProvider.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"KnockProvider.js","sources":["../../../../../src/modules/core/context/KnockProvider.tsx"],"sourcesContent":["import Knock, {\n AuthenticateOptions,\n LogLevel,\n UserWithProperties,\n} from \"@knocklabs/client\";\nimport * as React from \"react\";\nimport { PropsWithChildren } from \"react\";\n\nimport { I18nContent, KnockI18nProvider } from \"../../i18n\";\nimport { useAuthenticatedKnockClient } from \"../hooks\";\n\nexport interface KnockProviderState {\n knock: Knock;\n}\n\nconst KnockContext = React.createContext<KnockProviderState | null>(null);\n\nexport type KnockProviderProps = {\n // Knock client props\n apiKey: string | undefined;\n host?: string;\n userToken?: Knock[\"userToken\"];\n onUserTokenExpiring?: AuthenticateOptions[\"onUserTokenExpiring\"];\n timeBeforeExpirationInMs?: AuthenticateOptions[\"timeBeforeExpirationInMs\"];\n // i18n translations\n i18n?: I18nContent;\n logLevel?: LogLevel;\n} & (\n | {\n /**\n * @deprecated The `userId` prop is deprecated and will be removed in a future version.\n * Please pass the `user` prop instead containing an `id` value.\n * example:\n * ```ts\n * <KnockProvider user={{ id: \"user_123\" }}></KnockProvider>\n * ```\n */\n userId: Knock[\"userId\"];\n user?: never;\n }\n | {\n user: UserWithProperties;\n /**\n * @deprecated The `userId` prop is deprecated and will be removed in a future version.\n * Please pass the `user` prop instead containing an `id` value.\n * example:\n * ```ts\n * <KnockProvider user={{ id: \"user_123\" }}></KnockProvider>\n * ```\n */\n userId?: never;\n }\n);\n\nexport const KnockProvider: React.FC<PropsWithChildren<KnockProviderProps>> = ({\n apiKey,\n host,\n logLevel,\n userToken,\n onUserTokenExpiring,\n timeBeforeExpirationInMs,\n children,\n i18n,\n ...props\n}) => {\n const userIdOrUserWithProperties = props?.user || props?.userId;\n\n // We memoize the options here so that we don't create a new object on every re-render\n const authenticateOptions = React.useMemo(\n () => ({\n host,\n onUserTokenExpiring,\n timeBeforeExpirationInMs,\n logLevel,\n }),\n [host, onUserTokenExpiring, timeBeforeExpirationInMs, logLevel],\n );\n\n const knock = useAuthenticatedKnockClient(\n apiKey ?? \"\",\n userIdOrUserWithProperties,\n userToken,\n authenticateOptions,\n );\n\n return (\n <KnockContext.Provider value={{ knock }}>\n <KnockI18nProvider i18n={i18n}>{children}</KnockI18nProvider>\n </KnockContext.Provider>\n );\n};\n\nexport const useKnockClient = (): Knock => {\n const context = React.useContext(KnockContext);\n if (!context) {\n throw new Error(\"useKnockClient must be used within a KnockProvider\");\n }\n return context.knock;\n};\n"],"names":["KnockContext","React","createContext","KnockProvider","apiKey","host","logLevel","userToken","onUserTokenExpiring","timeBeforeExpirationInMs","children","i18n","props","userIdOrUserWithProperties","user","userId","authenticateOptions","useMemo","knock","useAuthenticatedKnockClient","KnockI18nProvider","useKnockClient","context","useContext","Error"],"mappings":"yjBAeMA,EAAeC,EAAMC,cAAyC,IAAI,EAuC3DC,EAAiEA,CAAC,CAC7EC,OAAAA,EACAC,KAAAA,EACAC,SAAAA,EACAC,UAAAA,EACAC,oBAAAA,EACAC,yBAAAA,EACAC,SAAAA,EACAC,KAAAA,EACA,GAAGC,CACL,IAAM,CACEC,MAAAA,GAA6BD,GAAAA,YAAAA,EAAOE,QAAQF,GAAAA,YAAAA,EAAOG,QAGnDC,EAAsBf,EAAMgB,QAChC,KAAO,CACLZ,KAAAA,EACAG,oBAAAA,EACAC,yBAAAA,EACAH,SAAAA,IAEF,CAACD,EAAMG,EAAqBC,EAA0BH,CAAQ,CAChE,EAEMY,EAAQC,EACZf,GAAU,GACVS,EACAN,EACAS,CACF,EAEA,OACGf,EAAA,cAAAD,EAAa,SAAb,CAAsB,MAAO,CAAEkB,MAAAA,CAAAA,CAC9B,EAAAjB,EAAA,cAACmB,EAAAA,kBAAkB,CAAA,KAAAT,CAAA,EAAaD,CAAS,CAC3C,CAEJ,EAEaW,EAAiBA,IAAa,CACnCC,MAAAA,EAAUrB,EAAMsB,WAAWvB,CAAY,EAC7C,GAAI,CAACsB,EACG,MAAA,IAAIE,MAAM,oDAAoD,EAEtE,OAAOF,EAAQJ,KACjB"}
1
+ {"version":3,"file":"KnockProvider.js","sources":["../../../../../src/modules/core/context/KnockProvider.tsx"],"sourcesContent":["import Knock, {\n AuthenticateOptions,\n LogLevel,\n UserWithProperties,\n} from \"@knocklabs/client\";\nimport * as React from \"react\";\nimport { PropsWithChildren } from \"react\";\n\nimport { I18nContent, KnockI18nProvider } from \"../../i18n\";\nimport { useAuthenticatedKnockClient } from \"../hooks\";\n\nexport interface KnockProviderState {\n knock: Knock;\n}\n\nconst KnockContext = React.createContext<KnockProviderState | null>(null);\n\nexport type KnockProviderProps = {\n // Knock client props\n apiKey: string | undefined;\n host?: string;\n userToken?: Knock[\"userToken\"];\n onUserTokenExpiring?: AuthenticateOptions[\"onUserTokenExpiring\"];\n timeBeforeExpirationInMs?: AuthenticateOptions[\"timeBeforeExpirationInMs\"];\n // i18n translations\n i18n?: I18nContent;\n logLevel?: LogLevel;\n} & (\n | {\n /**\n * @deprecated The `userId` prop is deprecated and will be removed in a future version.\n * Please pass the `user` prop instead containing an `id` value.\n * example:\n * ```ts\n * <KnockProvider user={{ id: \"user_123\" }}></KnockProvider>\n * ```\n */\n userId: Knock[\"userId\"];\n user?: never;\n identificationStrategy?: never;\n }\n | {\n user: UserWithProperties;\n identificationStrategy?: AuthenticateOptions[\"identificationStrategy\"];\n /**\n * @deprecated The `userId` prop is deprecated and will be removed in a future version.\n * Please pass the `user` prop instead containing an `id` value.\n * example:\n * ```ts\n * <KnockProvider user={{ id: \"user_123\" }}></KnockProvider>\n * ```\n */\n userId?: never;\n }\n);\n\nexport const KnockProvider: React.FC<PropsWithChildren<KnockProviderProps>> = ({\n apiKey,\n host,\n logLevel,\n userToken,\n onUserTokenExpiring,\n timeBeforeExpirationInMs,\n children,\n i18n,\n identificationStrategy,\n ...props\n}) => {\n const userIdOrUserWithProperties = props?.user || props?.userId;\n\n // We memoize the options here so that we don't create a new object on every re-render\n const authenticateOptions = React.useMemo(\n () => ({\n host,\n onUserTokenExpiring,\n timeBeforeExpirationInMs,\n logLevel,\n identificationStrategy,\n }),\n [\n host,\n onUserTokenExpiring,\n timeBeforeExpirationInMs,\n logLevel,\n identificationStrategy,\n ],\n );\n\n const knock = useAuthenticatedKnockClient(\n apiKey ?? \"\",\n userIdOrUserWithProperties,\n userToken,\n authenticateOptions,\n );\n\n return (\n <KnockContext.Provider value={{ knock }}>\n <KnockI18nProvider i18n={i18n}>{children}</KnockI18nProvider>\n </KnockContext.Provider>\n );\n};\n\nexport const useKnockClient = (): Knock => {\n const context = React.useContext(KnockContext);\n if (!context) {\n throw new Error(\"useKnockClient must be used within a KnockProvider\");\n }\n return context.knock;\n};\n"],"names":["KnockContext","React","createContext","KnockProvider","apiKey","host","logLevel","userToken","onUserTokenExpiring","timeBeforeExpirationInMs","children","i18n","identificationStrategy","props","userIdOrUserWithProperties","user","userId","authenticateOptions","useMemo","knock","useAuthenticatedKnockClient","KnockI18nProvider","useKnockClient","context","useContext","Error"],"mappings":"yjBAeMA,EAAeC,EAAMC,cAAyC,IAAI,EAyC3DC,EAAiEA,CAAC,CAC7EC,OAAAA,EACAC,KAAAA,EACAC,SAAAA,EACAC,UAAAA,EACAC,oBAAAA,EACAC,yBAAAA,EACAC,SAAAA,EACAC,KAAAA,EACAC,uBAAAA,EACA,GAAGC,CACL,IAAM,CACEC,MAAAA,GAA6BD,GAAAA,YAAAA,EAAOE,QAAQF,GAAAA,YAAAA,EAAOG,QAGnDC,EAAsBhB,EAAMiB,QAChC,KAAO,CACLb,KAAAA,EACAG,oBAAAA,EACAC,yBAAAA,EACAH,SAAAA,EACAM,uBAAAA,CAAAA,GAEF,CACEP,EACAG,EACAC,EACAH,EACAM,CAAsB,CAE1B,EAEMO,EAAQC,EACZhB,GAAU,GACVU,EACAP,EACAU,CACF,EAEA,OACGhB,EAAA,cAAAD,EAAa,SAAb,CAAsB,MAAO,CAAEmB,MAAAA,CAAAA,CAC9B,EAAAlB,EAAA,cAACoB,EAAAA,kBAAkB,CAAA,KAAAV,CAAA,EAAaD,CAAS,CAC3C,CAEJ,EAEaY,EAAiBA,IAAa,CACnCC,MAAAA,EAAUtB,EAAMuB,WAAWxB,CAAY,EAC7C,GAAI,CAACuB,EACG,MAAA,IAAIE,MAAM,oDAAoD,EAEtE,OAAOF,EAAQJ,KACjB"}
@@ -1,2 +1,2 @@
1
- "use strict";const h=require("@knocklabs/client"),g=require("react");require("../context/KnockProvider.js");const s=require("./useStableOptions.js");require("date-fns");const d=e=>e&&typeof e=="object"&&"default"in e?e:{default:e},q=d(h),f=d(g);function l(e,i,c,t={}){e.authenticate(i,c,{onUserTokenExpiring:t==null?void 0:t.onUserTokenExpiring,timeBeforeExpirationInMs:t==null?void 0:t.timeBeforeExpirationInMs})}function x(e,i,c,t={}){const a=f.default.useRef(void 0),u=s(t),n=s(i);return f.default.useMemo(()=>{const k=typeof n=="string"?n:n==null?void 0:n.id,r=a.current;if(r&&r.isAuthenticated()&&(r.userId!==k||r.userToken!==c))return l(r,n,c,u),r;r&&r.teardown();const o=new q.default(e,{host:u.host,logLevel:u.logLevel});return l(o,n,c,u),a.current=o,o},[e,n,c,u])}module.exports=x;
1
+ "use strict";const g=require("@knocklabs/client"),h=require("react");require("../context/KnockProvider.js");const o=require("./useStableOptions.js");require("date-fns");const l=t=>t&&typeof t=="object"&&"default"in t?t:{default:t},q=l(g),d=l(h);function s(t,i,c,e={}){t.authenticate(i,c,{onUserTokenExpiring:e==null?void 0:e.onUserTokenExpiring,timeBeforeExpirationInMs:e==null?void 0:e.timeBeforeExpirationInMs,identificationStrategy:e==null?void 0:e.identificationStrategy})}function x(t,i,c,e={}){const f=d.default.useRef(void 0),u=o(e),n=o(i);return d.default.useMemo(()=>{const k=typeof n=="string"?n:n==null?void 0:n.id,r=f.current;if(r&&r.isAuthenticated()&&(r.userId!==k||r.userToken!==c))return s(r,n,c,u),r;r&&r.teardown();const a=new q.default(t,{host:u.host,logLevel:u.logLevel});return s(a,n,c,u),f.current=a,a},[t,n,c,u])}module.exports=x;
2
2
  //# sourceMappingURL=useAuthenticatedKnockClient.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"useAuthenticatedKnockClient.js","sources":["../../../../../src/modules/core/hooks/useAuthenticatedKnockClient.ts"],"sourcesContent":["import Knock, {\n AuthenticateOptions,\n KnockOptions,\n UserId,\n UserIdOrUserWithProperties,\n} from \"@knocklabs/client\";\nimport React from \"react\";\n\nimport { useStableOptions } from \"../../core\";\n\nfunction authenticateWithOptions(\n knock: Knock,\n userIdOrUserWithProperties: UserIdOrUserWithProperties,\n userToken?: Knock[\"userToken\"],\n options: AuthenticateOptions = {},\n) {\n knock.authenticate(userIdOrUserWithProperties, userToken, {\n onUserTokenExpiring: options?.onUserTokenExpiring,\n timeBeforeExpirationInMs: options?.timeBeforeExpirationInMs,\n });\n}\n\nexport type AuthenticatedKnockClientOptions = KnockOptions &\n AuthenticateOptions;\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 * useAuthenticatedKnockClient(\"pk_test_12345\", { id: \"user_123\" });\n * ```\n */\nfunction useAuthenticatedKnockClient(\n apiKey: string,\n userIdOrUserWithProperties: UserId,\n userToken?: Knock[\"userToken\"],\n options?: AuthenticatedKnockClientOptions,\n): Knock;\nfunction useAuthenticatedKnockClient(\n apiKey: string,\n userIdOrUserWithProperties: UserIdOrUserWithProperties,\n userToken?: Knock[\"userToken\"],\n options?: AuthenticatedKnockClientOptions,\n): Knock;\nfunction useAuthenticatedKnockClient(\n apiKey: string,\n userIdOrUserWithProperties: UserIdOrUserWithProperties,\n userToken?: Knock[\"userToken\"],\n options: AuthenticatedKnockClientOptions = {},\n) {\n const knockRef = React.useRef<Knock | undefined>(undefined);\n\n const stableOptions = useStableOptions(options);\n const stableUserIdOrObject = useStableOptions(userIdOrUserWithProperties);\n\n return React.useMemo(() => {\n const userId =\n typeof stableUserIdOrObject === \"string\"\n ? stableUserIdOrObject\n : stableUserIdOrObject?.id;\n\n const currentKnock = knockRef.current;\n\n // If the userId and the userToken changes then just reauth\n if (\n currentKnock &&\n currentKnock.isAuthenticated() &&\n (currentKnock.userId !== userId || currentKnock.userToken !== userToken)\n ) {\n authenticateWithOptions(\n currentKnock,\n stableUserIdOrObject,\n userToken,\n stableOptions,\n );\n return currentKnock;\n }\n\n if (currentKnock) {\n currentKnock.teardown();\n }\n\n // Otherwise instantiate a new Knock client\n const knock = new Knock(apiKey, {\n host: stableOptions.host,\n logLevel: stableOptions.logLevel,\n });\n\n authenticateWithOptions(\n knock,\n stableUserIdOrObject,\n userToken,\n stableOptions,\n );\n knockRef.current = knock;\n\n return knock;\n }, [apiKey, stableUserIdOrObject, userToken, stableOptions]);\n}\n\nexport default useAuthenticatedKnockClient;\n"],"names":["authenticateWithOptions","knock","userIdOrUserWithProperties","userToken","options","authenticate","onUserTokenExpiring","timeBeforeExpirationInMs","useAuthenticatedKnockClient","apiKey","knockRef","React","useRef","undefined","stableOptions","useStableOptions","stableUserIdOrObject","useMemo","userId","id","currentKnock","current","isAuthenticated","teardown","Knock","host","logLevel"],"mappings":"qPAUA,SAASA,EACPC,EACAC,EACAC,EACAC,EAA+B,CAAA,EAC/B,CACMC,EAAAA,aAAaH,EAA4BC,EAAW,CACxDG,oBAAqBF,GAAAA,YAAAA,EAASE,oBAC9BC,yBAA0BH,GAAAA,YAAAA,EAASG,wBAAAA,CACpC,CACH,CAyBA,SAASC,EACPC,EACAP,EACAC,EACAC,EAA2C,CAAA,EAC3C,CACMM,MAAAA,EAAWC,EAAAA,QAAMC,OAA0BC,MAAS,EAEpDC,EAAgBC,EAAiBX,CAAO,EACxCY,EAAuBD,EAAiBb,CAA0B,EAEjES,OAAAA,EAAAA,QAAMM,QAAQ,IAAM,CACzB,MAAMC,EACJ,OAAOF,GAAyB,SAC5BA,EACAA,GAAAA,YAAAA,EAAsBG,GAEtBC,EAAeV,EAASW,QAI5BD,GAAAA,GACAA,EAAaE,gBAAgB,IAC5BF,EAAaF,SAAWA,GAAUE,EAAajB,YAAcA,GAG5DiB,OAAAA,EAAAA,EACAJ,EACAb,EACAW,CACF,EACOM,EAGLA,GACFA,EAAaG,SAAS,EAIlBtB,MAAAA,EAAQ,IAAIuB,EAAAA,QAAMf,EAAQ,CAC9BgB,KAAMX,EAAcW,KACpBC,SAAUZ,EAAcY,QAAAA,CACzB,EAGCzB,OAAAA,EAAAA,EACAe,EACAb,EACAW,CACF,EACAJ,EAASW,QAAUpB,EAEZA,GACN,CAACQ,EAAQO,EAAsBb,EAAWW,CAAa,CAAC,CAC7D"}
1
+ {"version":3,"file":"useAuthenticatedKnockClient.js","sources":["../../../../../src/modules/core/hooks/useAuthenticatedKnockClient.ts"],"sourcesContent":["import Knock, {\n AuthenticateOptions,\n KnockOptions,\n UserId,\n UserIdOrUserWithProperties,\n} from \"@knocklabs/client\";\nimport React from \"react\";\n\nimport { useStableOptions } from \"../../core\";\n\nfunction authenticateWithOptions(\n knock: Knock,\n userIdOrUserWithProperties: UserIdOrUserWithProperties,\n userToken?: Knock[\"userToken\"],\n options: AuthenticateOptions = {},\n) {\n knock.authenticate(userIdOrUserWithProperties, userToken, {\n onUserTokenExpiring: options?.onUserTokenExpiring,\n timeBeforeExpirationInMs: options?.timeBeforeExpirationInMs,\n identificationStrategy: options?.identificationStrategy,\n });\n}\n\nexport type AuthenticatedKnockClientOptions = KnockOptions &\n AuthenticateOptions;\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 * useAuthenticatedKnockClient(\"pk_test_12345\", { id: \"user_123\" });\n * ```\n */\nfunction useAuthenticatedKnockClient(\n apiKey: string,\n userIdOrUserWithProperties: UserId,\n userToken?: Knock[\"userToken\"],\n options?: AuthenticatedKnockClientOptions,\n): Knock;\nfunction useAuthenticatedKnockClient(\n apiKey: string,\n userIdOrUserWithProperties: UserIdOrUserWithProperties,\n userToken?: Knock[\"userToken\"],\n options?: AuthenticatedKnockClientOptions,\n): Knock;\nfunction useAuthenticatedKnockClient(\n apiKey: string,\n userIdOrUserWithProperties: UserIdOrUserWithProperties,\n userToken?: Knock[\"userToken\"],\n options: AuthenticatedKnockClientOptions = {},\n) {\n const knockRef = React.useRef<Knock | undefined>(undefined);\n\n const stableOptions = useStableOptions(options);\n const stableUserIdOrObject = useStableOptions(userIdOrUserWithProperties);\n\n return React.useMemo(() => {\n const userId =\n typeof stableUserIdOrObject === \"string\"\n ? stableUserIdOrObject\n : stableUserIdOrObject?.id;\n\n const currentKnock = knockRef.current;\n\n // If the userId and the userToken changes then just reauth\n if (\n currentKnock &&\n currentKnock.isAuthenticated() &&\n (currentKnock.userId !== userId || currentKnock.userToken !== userToken)\n ) {\n authenticateWithOptions(\n currentKnock,\n stableUserIdOrObject,\n userToken,\n stableOptions,\n );\n return currentKnock;\n }\n\n if (currentKnock) {\n currentKnock.teardown();\n }\n\n // Otherwise instantiate a new Knock client\n const knock = new Knock(apiKey, {\n host: stableOptions.host,\n logLevel: stableOptions.logLevel,\n });\n\n authenticateWithOptions(\n knock,\n stableUserIdOrObject,\n userToken,\n stableOptions,\n );\n knockRef.current = knock;\n\n return knock;\n }, [apiKey, stableUserIdOrObject, userToken, stableOptions]);\n}\n\nexport default useAuthenticatedKnockClient;\n"],"names":["authenticateWithOptions","knock","userIdOrUserWithProperties","userToken","options","authenticate","onUserTokenExpiring","timeBeforeExpirationInMs","identificationStrategy","useAuthenticatedKnockClient","apiKey","knockRef","React","useRef","undefined","stableOptions","useStableOptions","stableUserIdOrObject","useMemo","userId","id","currentKnock","current","isAuthenticated","teardown","Knock","host","logLevel"],"mappings":"qPAUA,SAASA,EACPC,EACAC,EACAC,EACAC,EAA+B,CAAA,EAC/B,CACMC,EAAAA,aAAaH,EAA4BC,EAAW,CACxDG,oBAAqBF,GAAAA,YAAAA,EAASE,oBAC9BC,yBAA0BH,GAAAA,YAAAA,EAASG,yBACnCC,uBAAwBJ,GAAAA,YAAAA,EAASI,sBAAAA,CAClC,CACH,CAyBA,SAASC,EACPC,EACAR,EACAC,EACAC,EAA2C,CAAA,EAC3C,CACMO,MAAAA,EAAWC,EAAAA,QAAMC,OAA0BC,MAAS,EAEpDC,EAAgBC,EAAiBZ,CAAO,EACxCa,EAAuBD,EAAiBd,CAA0B,EAEjEU,OAAAA,EAAAA,QAAMM,QAAQ,IAAM,CACzB,MAAMC,EACJ,OAAOF,GAAyB,SAC5BA,EACAA,GAAAA,YAAAA,EAAsBG,GAEtBC,EAAeV,EAASW,QAI5BD,GAAAA,GACAA,EAAaE,gBAAgB,IAC5BF,EAAaF,SAAWA,GAAUE,EAAalB,YAAcA,GAG5DkB,OAAAA,EAAAA,EACAJ,EACAd,EACAY,CACF,EACOM,EAGLA,GACFA,EAAaG,SAAS,EAIlBvB,MAAAA,EAAQ,IAAIwB,EAAAA,QAAMf,EAAQ,CAC9BgB,KAAMX,EAAcW,KACpBC,SAAUZ,EAAcY,QAAAA,CACzB,EAGC1B,OAAAA,EAAAA,EACAgB,EACAd,EACAY,CACF,EACAJ,EAASW,QAAUrB,EAEZA,GACN,CAACS,EAAQO,EAAsBd,EAAWY,CAAa,CAAC,CAC7D"}
@@ -2,7 +2,7 @@ import { KnockProvider as t, useKnockClient as r } from "./modules/core/context/
2
2
  import { default as a } from "./modules/core/hooks/useAuthenticatedKnockClient.mjs";
3
3
  import { default as u } from "./modules/core/hooks/useStableOptions.mjs";
4
4
  import { FilterStatus as m } from "./modules/core/constants.mjs";
5
- import { feedProviderKey as l, formatBadgeCount as i, formatTimestamp as c, msTeamsProviderKey as x, renderNodeOrFallback as p, slackProviderKey as k, toSentenceCase as C } from "./modules/core/utils.mjs";
5
+ import { feedProviderKey as l, formatBadgeCount as i, formatTimestamp as x, msTeamsProviderKey as c, renderNodeOrFallback as p, slackProviderKey as k, toSentenceCase as C } from "./modules/core/utils.mjs";
6
6
  import { KnockFeedProvider as S, useKnockFeed as T } from "./modules/feed/context/KnockFeedProvider.mjs";
7
7
  import { default as v } from "./modules/feed/hooks/useNotifications.mjs";
8
8
  import { default as M } from "./modules/feed/hooks/useFeedSettings.mjs";
@@ -24,8 +24,9 @@ import { default as se } from "./modules/slack/hooks/useConnectedSlackChannels.m
24
24
  import { default as ne } from "./modules/slack/hooks/useSlackAuth.mjs";
25
25
  import { I18nContext as fe, KnockI18nProvider as me } from "./modules/i18n/context/KnockI18nProvider.mjs";
26
26
  import { useTranslations as le } from "./modules/i18n/hooks/useTranslations.mjs";
27
- import { locales as ce } from "./modules/i18n/languages/index.mjs";
27
+ import { locales as xe } from "./modules/i18n/languages/index.mjs";
28
28
  import { usePreferences as pe } from "./modules/preferences/hooks/usePreferences.mjs";
29
+ import { useStore as Ce } from "@tanstack/react-store";
29
30
  export {
30
31
  m as FilterStatus,
31
32
  fe as I18nContext,
@@ -38,9 +39,9 @@ export {
38
39
  Z as KnockSlackProvider,
39
40
  l as feedProviderKey,
40
41
  i as formatBadgeCount,
41
- c as formatTimestamp,
42
- ce as locales,
43
- x as msTeamsProviderKey,
42
+ x as formatTimestamp,
43
+ xe as locales,
44
+ c as msTeamsProviderKey,
44
45
  p as renderNodeOrFallback,
45
46
  k as slackProviderKey,
46
47
  C as toSentenceCase,
@@ -67,6 +68,7 @@ export {
67
68
  te as useSlackChannels,
68
69
  ee as useSlackConnectionStatus,
69
70
  u as useStableOptions,
71
+ Ce as useStore,
70
72
  le as useTranslations
71
73
  };
72
74
  //# sourceMappingURL=index.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"index.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
@@ -1,35 +1,37 @@
1
- import * as e from "react";
2
- import { KnockI18nProvider as l } from "../../i18n/context/KnockI18nProvider.mjs";
3
- import C from "../hooks/useAuthenticatedKnockClient.mjs";
1
+ import * as t from "react";
2
+ import { KnockI18nProvider as C } from "../../i18n/context/KnockI18nProvider.mjs";
3
+ import P from "../hooks/useAuthenticatedKnockClient.mjs";
4
4
  import "fast-deep-equal";
5
- const i = e.createContext(null), f = ({
5
+ const k = t.createContext(null), x = ({
6
6
  apiKey: n,
7
7
  host: c,
8
8
  logLevel: o,
9
- userToken: k,
9
+ userToken: m,
10
10
  onUserTokenExpiring: r,
11
11
  timeBeforeExpirationInMs: u,
12
- children: m,
12
+ children: s,
13
13
  i18n: a,
14
- ...t
14
+ identificationStrategy: i,
15
+ ...e
15
16
  }) => {
16
- const s = (t == null ? void 0 : t.user) || (t == null ? void 0 : t.userId), d = e.useMemo(() => ({
17
+ const d = (e == null ? void 0 : e.user) || (e == null ? void 0 : e.userId), K = t.useMemo(() => ({
17
18
  host: c,
18
19
  onUserTokenExpiring: r,
19
20
  timeBeforeExpirationInMs: u,
20
- logLevel: o
21
- }), [c, r, u, o]), K = C(n ?? "", s, k, d);
22
- return /* @__PURE__ */ e.createElement(i.Provider, { value: {
23
- knock: K
24
- } }, /* @__PURE__ */ e.createElement(l, { i18n: a }, m));
25
- }, w = () => {
26
- const n = e.useContext(i);
21
+ logLevel: o,
22
+ identificationStrategy: i
23
+ }), [c, r, u, o, i]), l = P(n ?? "", d, m, K);
24
+ return /* @__PURE__ */ t.createElement(k.Provider, { value: {
25
+ knock: l
26
+ } }, /* @__PURE__ */ t.createElement(C, { i18n: a }, s));
27
+ }, f = () => {
28
+ const n = t.useContext(k);
27
29
  if (!n)
28
30
  throw new Error("useKnockClient must be used within a KnockProvider");
29
31
  return n.knock;
30
32
  };
31
33
  export {
32
- f as KnockProvider,
33
- w as useKnockClient
34
+ x as KnockProvider,
35
+ f as useKnockClient
34
36
  };
35
37
  //# sourceMappingURL=KnockProvider.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"KnockProvider.mjs","sources":["../../../../../src/modules/core/context/KnockProvider.tsx"],"sourcesContent":["import Knock, {\n AuthenticateOptions,\n LogLevel,\n UserWithProperties,\n} from \"@knocklabs/client\";\nimport * as React from \"react\";\nimport { PropsWithChildren } from \"react\";\n\nimport { I18nContent, KnockI18nProvider } from \"../../i18n\";\nimport { useAuthenticatedKnockClient } from \"../hooks\";\n\nexport interface KnockProviderState {\n knock: Knock;\n}\n\nconst KnockContext = React.createContext<KnockProviderState | null>(null);\n\nexport type KnockProviderProps = {\n // Knock client props\n apiKey: string | undefined;\n host?: string;\n userToken?: Knock[\"userToken\"];\n onUserTokenExpiring?: AuthenticateOptions[\"onUserTokenExpiring\"];\n timeBeforeExpirationInMs?: AuthenticateOptions[\"timeBeforeExpirationInMs\"];\n // i18n translations\n i18n?: I18nContent;\n logLevel?: LogLevel;\n} & (\n | {\n /**\n * @deprecated The `userId` prop is deprecated and will be removed in a future version.\n * Please pass the `user` prop instead containing an `id` value.\n * example:\n * ```ts\n * <KnockProvider user={{ id: \"user_123\" }}></KnockProvider>\n * ```\n */\n userId: Knock[\"userId\"];\n user?: never;\n }\n | {\n user: UserWithProperties;\n /**\n * @deprecated The `userId` prop is deprecated and will be removed in a future version.\n * Please pass the `user` prop instead containing an `id` value.\n * example:\n * ```ts\n * <KnockProvider user={{ id: \"user_123\" }}></KnockProvider>\n * ```\n */\n userId?: never;\n }\n);\n\nexport const KnockProvider: React.FC<PropsWithChildren<KnockProviderProps>> = ({\n apiKey,\n host,\n logLevel,\n userToken,\n onUserTokenExpiring,\n timeBeforeExpirationInMs,\n children,\n i18n,\n ...props\n}) => {\n const userIdOrUserWithProperties = props?.user || props?.userId;\n\n // We memoize the options here so that we don't create a new object on every re-render\n const authenticateOptions = React.useMemo(\n () => ({\n host,\n onUserTokenExpiring,\n timeBeforeExpirationInMs,\n logLevel,\n }),\n [host, onUserTokenExpiring, timeBeforeExpirationInMs, logLevel],\n );\n\n const knock = useAuthenticatedKnockClient(\n apiKey ?? \"\",\n userIdOrUserWithProperties,\n userToken,\n authenticateOptions,\n );\n\n return (\n <KnockContext.Provider value={{ knock }}>\n <KnockI18nProvider i18n={i18n}>{children}</KnockI18nProvider>\n </KnockContext.Provider>\n );\n};\n\nexport const useKnockClient = (): Knock => {\n const context = React.useContext(KnockContext);\n if (!context) {\n throw new Error(\"useKnockClient must be used within a KnockProvider\");\n }\n return context.knock;\n};\n"],"names":["KnockContext","React","createContext","KnockProvider","apiKey","host","logLevel","userToken","onUserTokenExpiring","timeBeforeExpirationInMs","children","i18n","props","userIdOrUserWithProperties","user","userId","authenticateOptions","useMemo","knock","useAuthenticatedKnockClient","KnockI18nProvider","useKnockClient","context","useContext","Error"],"mappings":";;;;AAeA,MAAMA,IAAeC,EAAMC,cAAyC,IAAI,GAuC3DC,IAAiEA,CAAC;AAAA,EAC7EC,QAAAA;AAAAA,EACAC,MAAAA;AAAAA,EACAC,UAAAA;AAAAA,EACAC,WAAAA;AAAAA,EACAC,qBAAAA;AAAAA,EACAC,0BAAAA;AAAAA,EACAC,UAAAA;AAAAA,EACAC,MAAAA;AAAAA,EACA,GAAGC;AACL,MAAM;AACEC,QAAAA,KAA6BD,KAAAA,gBAAAA,EAAOE,UAAQF,KAAAA,gBAAAA,EAAOG,SAGnDC,IAAsBf,EAAMgB,QAChC,OAAO;AAAA,IACLZ,MAAAA;AAAAA,IACAG,qBAAAA;AAAAA,IACAC,0BAAAA;AAAAA,IACAH,UAAAA;AAAAA,MAEF,CAACD,GAAMG,GAAqBC,GAA0BH,CAAQ,CAChE,GAEMY,IAAQC,EACZf,KAAU,IACVS,GACAN,GACAS,CACF;AAEA,SACG,gBAAAf,EAAA,cAAAD,EAAa,UAAb,EAAsB,OAAO;AAAA,IAAEkB,OAAAA;AAAAA,EAAAA,EAC9B,GAAA,gBAAAjB,EAAA,cAACmB,GAAkB,EAAA,MAAAT,EAAA,GAAaD,CAAS,CAC3C;AAEJ,GAEaW,IAAiBA,MAAa;AACnCC,QAAAA,IAAUrB,EAAMsB,WAAWvB,CAAY;AAC7C,MAAI,CAACsB;AACG,UAAA,IAAIE,MAAM,oDAAoD;AAEtE,SAAOF,EAAQJ;AACjB;"}
1
+ {"version":3,"file":"KnockProvider.mjs","sources":["../../../../../src/modules/core/context/KnockProvider.tsx"],"sourcesContent":["import Knock, {\n AuthenticateOptions,\n LogLevel,\n UserWithProperties,\n} from \"@knocklabs/client\";\nimport * as React from \"react\";\nimport { PropsWithChildren } from \"react\";\n\nimport { I18nContent, KnockI18nProvider } from \"../../i18n\";\nimport { useAuthenticatedKnockClient } from \"../hooks\";\n\nexport interface KnockProviderState {\n knock: Knock;\n}\n\nconst KnockContext = React.createContext<KnockProviderState | null>(null);\n\nexport type KnockProviderProps = {\n // Knock client props\n apiKey: string | undefined;\n host?: string;\n userToken?: Knock[\"userToken\"];\n onUserTokenExpiring?: AuthenticateOptions[\"onUserTokenExpiring\"];\n timeBeforeExpirationInMs?: AuthenticateOptions[\"timeBeforeExpirationInMs\"];\n // i18n translations\n i18n?: I18nContent;\n logLevel?: LogLevel;\n} & (\n | {\n /**\n * @deprecated The `userId` prop is deprecated and will be removed in a future version.\n * Please pass the `user` prop instead containing an `id` value.\n * example:\n * ```ts\n * <KnockProvider user={{ id: \"user_123\" }}></KnockProvider>\n * ```\n */\n userId: Knock[\"userId\"];\n user?: never;\n identificationStrategy?: never;\n }\n | {\n user: UserWithProperties;\n identificationStrategy?: AuthenticateOptions[\"identificationStrategy\"];\n /**\n * @deprecated The `userId` prop is deprecated and will be removed in a future version.\n * Please pass the `user` prop instead containing an `id` value.\n * example:\n * ```ts\n * <KnockProvider user={{ id: \"user_123\" }}></KnockProvider>\n * ```\n */\n userId?: never;\n }\n);\n\nexport const KnockProvider: React.FC<PropsWithChildren<KnockProviderProps>> = ({\n apiKey,\n host,\n logLevel,\n userToken,\n onUserTokenExpiring,\n timeBeforeExpirationInMs,\n children,\n i18n,\n identificationStrategy,\n ...props\n}) => {\n const userIdOrUserWithProperties = props?.user || props?.userId;\n\n // We memoize the options here so that we don't create a new object on every re-render\n const authenticateOptions = React.useMemo(\n () => ({\n host,\n onUserTokenExpiring,\n timeBeforeExpirationInMs,\n logLevel,\n identificationStrategy,\n }),\n [\n host,\n onUserTokenExpiring,\n timeBeforeExpirationInMs,\n logLevel,\n identificationStrategy,\n ],\n );\n\n const knock = useAuthenticatedKnockClient(\n apiKey ?? \"\",\n userIdOrUserWithProperties,\n userToken,\n authenticateOptions,\n );\n\n return (\n <KnockContext.Provider value={{ knock }}>\n <KnockI18nProvider i18n={i18n}>{children}</KnockI18nProvider>\n </KnockContext.Provider>\n );\n};\n\nexport const useKnockClient = (): Knock => {\n const context = React.useContext(KnockContext);\n if (!context) {\n throw new Error(\"useKnockClient must be used within a KnockProvider\");\n }\n return context.knock;\n};\n"],"names":["KnockContext","React","createContext","KnockProvider","apiKey","host","logLevel","userToken","onUserTokenExpiring","timeBeforeExpirationInMs","children","i18n","identificationStrategy","props","userIdOrUserWithProperties","user","userId","authenticateOptions","useMemo","knock","useAuthenticatedKnockClient","KnockI18nProvider","useKnockClient","context","useContext","Error"],"mappings":";;;;AAeA,MAAMA,IAAeC,EAAMC,cAAyC,IAAI,GAyC3DC,IAAiEA,CAAC;AAAA,EAC7EC,QAAAA;AAAAA,EACAC,MAAAA;AAAAA,EACAC,UAAAA;AAAAA,EACAC,WAAAA;AAAAA,EACAC,qBAAAA;AAAAA,EACAC,0BAAAA;AAAAA,EACAC,UAAAA;AAAAA,EACAC,MAAAA;AAAAA,EACAC,wBAAAA;AAAAA,EACA,GAAGC;AACL,MAAM;AACEC,QAAAA,KAA6BD,KAAAA,gBAAAA,EAAOE,UAAQF,KAAAA,gBAAAA,EAAOG,SAGnDC,IAAsBhB,EAAMiB,QAChC,OAAO;AAAA,IACLb,MAAAA;AAAAA,IACAG,qBAAAA;AAAAA,IACAC,0BAAAA;AAAAA,IACAH,UAAAA;AAAAA,IACAM,wBAAAA;AAAAA,EAAAA,IAEF,CACEP,GACAG,GACAC,GACAH,GACAM,CAAsB,CAE1B,GAEMO,IAAQC,EACZhB,KAAU,IACVU,GACAP,GACAU,CACF;AAEA,SACG,gBAAAhB,EAAA,cAAAD,EAAa,UAAb,EAAsB,OAAO;AAAA,IAAEmB,OAAAA;AAAAA,EAAAA,EAC9B,GAAA,gBAAAlB,EAAA,cAACoB,GAAkB,EAAA,MAAAV,EAAA,GAAaD,CAAS,CAC3C;AAEJ,GAEaY,IAAiBA,MAAa;AACnCC,QAAAA,IAAUtB,EAAMuB,WAAWxB,CAAY;AAC7C,MAAI,CAACuB;AACG,UAAA,IAAIE,MAAM,oDAAoD;AAEtE,SAAOF,EAAQJ;AACjB;"}
@@ -1,29 +1,30 @@
1
- import l from "@knocklabs/client";
2
- import a from "react";
1
+ import g from "@knocklabs/client";
2
+ import o from "react";
3
3
  import "../context/KnockProvider.mjs";
4
- import s from "./useStableOptions.mjs";
4
+ import m from "./useStableOptions.mjs";
5
5
  import "date-fns";
6
- function m(o, c, r, t = {}) {
7
- o.authenticate(c, r, {
8
- onUserTokenExpiring: t == null ? void 0 : t.onUserTokenExpiring,
9
- timeBeforeExpirationInMs: t == null ? void 0 : t.timeBeforeExpirationInMs
6
+ function d(c, u, n, e = {}) {
7
+ c.authenticate(u, n, {
8
+ onUserTokenExpiring: e == null ? void 0 : e.onUserTokenExpiring,
9
+ timeBeforeExpirationInMs: e == null ? void 0 : e.timeBeforeExpirationInMs,
10
+ identificationStrategy: e == null ? void 0 : e.identificationStrategy
10
11
  });
11
12
  }
12
- function E(o, c, r, t = {}) {
13
- const f = a.useRef(void 0), i = s(t), e = s(c);
14
- return a.useMemo(() => {
15
- const d = typeof e == "string" ? e : e == null ? void 0 : e.id, n = f.current;
16
- if (n && n.isAuthenticated() && (n.userId !== d || n.userToken !== r))
17
- return m(n, e, r, i), n;
18
- n && n.teardown();
19
- const u = new l(o, {
13
+ function v(c, u, n, e = {}) {
14
+ const f = o.useRef(void 0), i = m(e), t = m(u);
15
+ return o.useMemo(() => {
16
+ const l = typeof t == "string" ? t : t == null ? void 0 : t.id, r = f.current;
17
+ if (r && r.isAuthenticated() && (r.userId !== l || r.userToken !== n))
18
+ return d(r, t, n, i), r;
19
+ r && r.teardown();
20
+ const a = new g(c, {
20
21
  host: i.host,
21
22
  logLevel: i.logLevel
22
23
  });
23
- return m(u, e, r, i), f.current = u, u;
24
- }, [o, e, r, i]);
24
+ return d(a, t, n, i), f.current = a, a;
25
+ }, [c, t, n, i]);
25
26
  }
26
27
  export {
27
- E as default
28
+ v as default
28
29
  };
29
30
  //# sourceMappingURL=useAuthenticatedKnockClient.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"useAuthenticatedKnockClient.mjs","sources":["../../../../../src/modules/core/hooks/useAuthenticatedKnockClient.ts"],"sourcesContent":["import Knock, {\n AuthenticateOptions,\n KnockOptions,\n UserId,\n UserIdOrUserWithProperties,\n} from \"@knocklabs/client\";\nimport React from \"react\";\n\nimport { useStableOptions } from \"../../core\";\n\nfunction authenticateWithOptions(\n knock: Knock,\n userIdOrUserWithProperties: UserIdOrUserWithProperties,\n userToken?: Knock[\"userToken\"],\n options: AuthenticateOptions = {},\n) {\n knock.authenticate(userIdOrUserWithProperties, userToken, {\n onUserTokenExpiring: options?.onUserTokenExpiring,\n timeBeforeExpirationInMs: options?.timeBeforeExpirationInMs,\n });\n}\n\nexport type AuthenticatedKnockClientOptions = KnockOptions &\n AuthenticateOptions;\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 * useAuthenticatedKnockClient(\"pk_test_12345\", { id: \"user_123\" });\n * ```\n */\nfunction useAuthenticatedKnockClient(\n apiKey: string,\n userIdOrUserWithProperties: UserId,\n userToken?: Knock[\"userToken\"],\n options?: AuthenticatedKnockClientOptions,\n): Knock;\nfunction useAuthenticatedKnockClient(\n apiKey: string,\n userIdOrUserWithProperties: UserIdOrUserWithProperties,\n userToken?: Knock[\"userToken\"],\n options?: AuthenticatedKnockClientOptions,\n): Knock;\nfunction useAuthenticatedKnockClient(\n apiKey: string,\n userIdOrUserWithProperties: UserIdOrUserWithProperties,\n userToken?: Knock[\"userToken\"],\n options: AuthenticatedKnockClientOptions = {},\n) {\n const knockRef = React.useRef<Knock | undefined>(undefined);\n\n const stableOptions = useStableOptions(options);\n const stableUserIdOrObject = useStableOptions(userIdOrUserWithProperties);\n\n return React.useMemo(() => {\n const userId =\n typeof stableUserIdOrObject === \"string\"\n ? stableUserIdOrObject\n : stableUserIdOrObject?.id;\n\n const currentKnock = knockRef.current;\n\n // If the userId and the userToken changes then just reauth\n if (\n currentKnock &&\n currentKnock.isAuthenticated() &&\n (currentKnock.userId !== userId || currentKnock.userToken !== userToken)\n ) {\n authenticateWithOptions(\n currentKnock,\n stableUserIdOrObject,\n userToken,\n stableOptions,\n );\n return currentKnock;\n }\n\n if (currentKnock) {\n currentKnock.teardown();\n }\n\n // Otherwise instantiate a new Knock client\n const knock = new Knock(apiKey, {\n host: stableOptions.host,\n logLevel: stableOptions.logLevel,\n });\n\n authenticateWithOptions(\n knock,\n stableUserIdOrObject,\n userToken,\n stableOptions,\n );\n knockRef.current = knock;\n\n return knock;\n }, [apiKey, stableUserIdOrObject, userToken, stableOptions]);\n}\n\nexport default useAuthenticatedKnockClient;\n"],"names":["authenticateWithOptions","knock","userIdOrUserWithProperties","userToken","options","authenticate","onUserTokenExpiring","timeBeforeExpirationInMs","useAuthenticatedKnockClient","apiKey","knockRef","React","useRef","undefined","stableOptions","useStableOptions","stableUserIdOrObject","useMemo","userId","id","currentKnock","current","isAuthenticated","teardown","Knock","host","logLevel"],"mappings":";;;;;AAUA,SAASA,EACPC,GACAC,GACAC,GACAC,IAA+B,CAAA,GAC/B;AACMC,EAAAA,EAAAA,aAAaH,GAA4BC,GAAW;AAAA,IACxDG,qBAAqBF,KAAAA,gBAAAA,EAASE;AAAAA,IAC9BC,0BAA0BH,KAAAA,gBAAAA,EAASG;AAAAA,EAAAA,CACpC;AACH;AAyBA,SAASC,EACPC,GACAP,GACAC,GACAC,IAA2C,CAAA,GAC3C;AACMM,QAAAA,IAAWC,EAAMC,OAA0BC,MAAS,GAEpDC,IAAgBC,EAAiBX,CAAO,GACxCY,IAAuBD,EAAiBb,CAA0B;AAEjES,SAAAA,EAAMM,QAAQ,MAAM;AACzB,UAAMC,IACJ,OAAOF,KAAyB,WAC5BA,IACAA,KAAAA,gBAAAA,EAAsBG,IAEtBC,IAAeV,EAASW;AAI5BD,QAAAA,KACAA,EAAaE,gBAAgB,MAC5BF,EAAaF,WAAWA,KAAUE,EAAajB,cAAcA;AAG5DiB,aAAAA,EAAAA,GACAJ,GACAb,GACAW,CACF,GACOM;AAGT,IAAIA,KACFA,EAAaG,SAAS;AAIlBtB,UAAAA,IAAQ,IAAIuB,EAAMf,GAAQ;AAAA,MAC9BgB,MAAMX,EAAcW;AAAAA,MACpBC,UAAUZ,EAAcY;AAAAA,IAAAA,CACzB;AAGCzB,WAAAA,EAAAA,GACAe,GACAb,GACAW,CACF,GACAJ,EAASW,UAAUpB,GAEZA;AAAAA,KACN,CAACQ,GAAQO,GAAsBb,GAAWW,CAAa,CAAC;AAC7D;"}
1
+ {"version":3,"file":"useAuthenticatedKnockClient.mjs","sources":["../../../../../src/modules/core/hooks/useAuthenticatedKnockClient.ts"],"sourcesContent":["import Knock, {\n AuthenticateOptions,\n KnockOptions,\n UserId,\n UserIdOrUserWithProperties,\n} from \"@knocklabs/client\";\nimport React from \"react\";\n\nimport { useStableOptions } from \"../../core\";\n\nfunction authenticateWithOptions(\n knock: Knock,\n userIdOrUserWithProperties: UserIdOrUserWithProperties,\n userToken?: Knock[\"userToken\"],\n options: AuthenticateOptions = {},\n) {\n knock.authenticate(userIdOrUserWithProperties, userToken, {\n onUserTokenExpiring: options?.onUserTokenExpiring,\n timeBeforeExpirationInMs: options?.timeBeforeExpirationInMs,\n identificationStrategy: options?.identificationStrategy,\n });\n}\n\nexport type AuthenticatedKnockClientOptions = KnockOptions &\n AuthenticateOptions;\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 * useAuthenticatedKnockClient(\"pk_test_12345\", { id: \"user_123\" });\n * ```\n */\nfunction useAuthenticatedKnockClient(\n apiKey: string,\n userIdOrUserWithProperties: UserId,\n userToken?: Knock[\"userToken\"],\n options?: AuthenticatedKnockClientOptions,\n): Knock;\nfunction useAuthenticatedKnockClient(\n apiKey: string,\n userIdOrUserWithProperties: UserIdOrUserWithProperties,\n userToken?: Knock[\"userToken\"],\n options?: AuthenticatedKnockClientOptions,\n): Knock;\nfunction useAuthenticatedKnockClient(\n apiKey: string,\n userIdOrUserWithProperties: UserIdOrUserWithProperties,\n userToken?: Knock[\"userToken\"],\n options: AuthenticatedKnockClientOptions = {},\n) {\n const knockRef = React.useRef<Knock | undefined>(undefined);\n\n const stableOptions = useStableOptions(options);\n const stableUserIdOrObject = useStableOptions(userIdOrUserWithProperties);\n\n return React.useMemo(() => {\n const userId =\n typeof stableUserIdOrObject === \"string\"\n ? stableUserIdOrObject\n : stableUserIdOrObject?.id;\n\n const currentKnock = knockRef.current;\n\n // If the userId and the userToken changes then just reauth\n if (\n currentKnock &&\n currentKnock.isAuthenticated() &&\n (currentKnock.userId !== userId || currentKnock.userToken !== userToken)\n ) {\n authenticateWithOptions(\n currentKnock,\n stableUserIdOrObject,\n userToken,\n stableOptions,\n );\n return currentKnock;\n }\n\n if (currentKnock) {\n currentKnock.teardown();\n }\n\n // Otherwise instantiate a new Knock client\n const knock = new Knock(apiKey, {\n host: stableOptions.host,\n logLevel: stableOptions.logLevel,\n });\n\n authenticateWithOptions(\n knock,\n stableUserIdOrObject,\n userToken,\n stableOptions,\n );\n knockRef.current = knock;\n\n return knock;\n }, [apiKey, stableUserIdOrObject, userToken, stableOptions]);\n}\n\nexport default useAuthenticatedKnockClient;\n"],"names":["authenticateWithOptions","knock","userIdOrUserWithProperties","userToken","options","authenticate","onUserTokenExpiring","timeBeforeExpirationInMs","identificationStrategy","useAuthenticatedKnockClient","apiKey","knockRef","React","useRef","undefined","stableOptions","useStableOptions","stableUserIdOrObject","useMemo","userId","id","currentKnock","current","isAuthenticated","teardown","Knock","host","logLevel"],"mappings":";;;;;AAUA,SAASA,EACPC,GACAC,GACAC,GACAC,IAA+B,CAAA,GAC/B;AACMC,EAAAA,EAAAA,aAAaH,GAA4BC,GAAW;AAAA,IACxDG,qBAAqBF,KAAAA,gBAAAA,EAASE;AAAAA,IAC9BC,0BAA0BH,KAAAA,gBAAAA,EAASG;AAAAA,IACnCC,wBAAwBJ,KAAAA,gBAAAA,EAASI;AAAAA,EAAAA,CAClC;AACH;AAyBA,SAASC,EACPC,GACAR,GACAC,GACAC,IAA2C,CAAA,GAC3C;AACMO,QAAAA,IAAWC,EAAMC,OAA0BC,MAAS,GAEpDC,IAAgBC,EAAiBZ,CAAO,GACxCa,IAAuBD,EAAiBd,CAA0B;AAEjEU,SAAAA,EAAMM,QAAQ,MAAM;AACzB,UAAMC,IACJ,OAAOF,KAAyB,WAC5BA,IACAA,KAAAA,gBAAAA,EAAsBG,IAEtBC,IAAeV,EAASW;AAI5BD,QAAAA,KACAA,EAAaE,gBAAgB,MAC5BF,EAAaF,WAAWA,KAAUE,EAAalB,cAAcA;AAG5DkB,aAAAA,EAAAA,GACAJ,GACAd,GACAY,CACF,GACOM;AAGT,IAAIA,KACFA,EAAaG,SAAS;AAIlBvB,UAAAA,IAAQ,IAAIwB,EAAMf,GAAQ;AAAA,MAC9BgB,MAAMX,EAAcW;AAAAA,MACpBC,UAAUZ,EAAcY;AAAAA,IAAAA,CACzB;AAGC1B,WAAAA,EAAAA,GACAgB,GACAd,GACAY,CACF,GACAJ,EAASW,UAAUrB,GAEZA;AAAAA,KACN,CAACS,GAAQO,GAAsBd,GAAWY,CAAa,CAAC;AAC7D;"}
@@ -6,4 +6,5 @@ export { KnockSlackProvider, type ContainerObject, type KnockSlackProviderProps,
6
6
  export { I18nContext, KnockI18nProvider, locales, type I18nContent, type KnockI18nProviderProps, type Translations, useTranslations, } from './modules/i18n';
7
7
  export { type RecipientObject } from './interfaces';
8
8
  export { usePreferences } from './modules/preferences';
9
+ export { useStore } from '@tanstack/react-store';
9
10
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,YAAY,EACZ,aAAa,EACb,eAAe,EACf,gBAAgB,EAChB,eAAe,EACf,kBAAkB,EAClB,oBAAoB,EACpB,gBAAgB,EAChB,cAAc,EACd,KAAK,SAAS,EACd,KAAK,kBAAkB,EACvB,KAAK,kBAAkB,EACvB,2BAA2B,EAC3B,cAAc,EACd,gBAAgB,GACjB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EACL,iBAAiB,EACjB,KAAK,sBAAsB,EAC3B,KAAK,sBAAsB,EAC3B,KAAK,QAAQ,EACb,0BAA0B,EAC1B,eAAe,EACf,YAAY,EACZ,oBAAoB,EACpB,gBAAgB,GACjB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EACL,kBAAkB,EAClB,iBAAiB,EACjB,KAAK,uBAAuB,EAC5B,QAAQ,EACR,SAAS,EACT,eAAe,GAChB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EACL,KAAK,0BAA0B,EAC/B,KAAK,uBAAuB,EAC5B,oBAAoB,EACpB,KAAK,yBAAyB,EAC9B,KAAK,yBAAyB,EAC9B,2BAA2B,EAC3B,qBAAqB,EACrB,cAAc,EACd,kBAAkB,EAClB,0BAA0B,EAC1B,eAAe,GAChB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EACL,kBAAkB,EAClB,KAAK,eAAe,EACpB,KAAK,uBAAuB,EAC5B,KAAK,uBAAuB,EAC5B,KAAK,wBAAwB,EAC7B,yBAAyB,EACzB,mBAAmB,EACnB,YAAY,EACZ,gBAAgB,EAChB,wBAAwB,GACzB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EACL,WAAW,EACX,iBAAiB,EACjB,OAAO,EACP,KAAK,WAAW,EAChB,KAAK,sBAAsB,EAC3B,KAAK,YAAY,EACjB,eAAe,GAChB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,KAAK,eAAe,EAAE,MAAM,cAAc,CAAC;AAEpD,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,YAAY,EACZ,aAAa,EACb,eAAe,EACf,gBAAgB,EAChB,eAAe,EACf,kBAAkB,EAClB,oBAAoB,EACpB,gBAAgB,EAChB,cAAc,EACd,KAAK,SAAS,EACd,KAAK,kBAAkB,EACvB,KAAK,kBAAkB,EACvB,2BAA2B,EAC3B,cAAc,EACd,gBAAgB,GACjB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EACL,iBAAiB,EACjB,KAAK,sBAAsB,EAC3B,KAAK,sBAAsB,EAC3B,KAAK,QAAQ,EACb,0BAA0B,EAC1B,eAAe,EACf,YAAY,EACZ,oBAAoB,EACpB,gBAAgB,GACjB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EACL,kBAAkB,EAClB,iBAAiB,EACjB,KAAK,uBAAuB,EAC5B,QAAQ,EACR,SAAS,EACT,eAAe,GAChB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EACL,KAAK,0BAA0B,EAC/B,KAAK,uBAAuB,EAC5B,oBAAoB,EACpB,KAAK,yBAAyB,EAC9B,KAAK,yBAAyB,EAC9B,2BAA2B,EAC3B,qBAAqB,EACrB,cAAc,EACd,kBAAkB,EAClB,0BAA0B,EAC1B,eAAe,GAChB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EACL,kBAAkB,EAClB,KAAK,eAAe,EACpB,KAAK,uBAAuB,EAC5B,KAAK,uBAAuB,EAC5B,KAAK,wBAAwB,EAC7B,yBAAyB,EACzB,mBAAmB,EACnB,YAAY,EACZ,gBAAgB,EAChB,wBAAwB,GACzB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EACL,WAAW,EACX,iBAAiB,EACjB,OAAO,EACP,KAAK,WAAW,EAChB,KAAK,sBAAsB,EAC3B,KAAK,YAAY,EACjB,eAAe,GAChB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,KAAK,eAAe,EAAE,MAAM,cAAc,CAAC;AAEpD,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAMvD,OAAO,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC"}
@@ -24,8 +24,10 @@ export type KnockProviderProps = {
24
24
  */
25
25
  userId: Knock["userId"];
26
26
  user?: never;
27
+ identificationStrategy?: never;
27
28
  } | {
28
29
  user: UserWithProperties;
30
+ identificationStrategy?: AuthenticateOptions["identificationStrategy"];
29
31
  /**
30
32
  * @deprecated The `userId` prop is deprecated and will be removed in a future version.
31
33
  * Please pass the `user` prop instead containing an `id` value.
@@ -1 +1 @@
1
- {"version":3,"file":"KnockProvider.d.ts","sourceRoot":"","sources":["../../../../../src/modules/core/context/KnockProvider.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EACZ,mBAAmB,EACnB,QAAQ,EACR,kBAAkB,EACnB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,iBAAiB,EAAE,MAAM,OAAO,CAAC;AAE1C,OAAO,EAAE,WAAW,EAAqB,MAAM,YAAY,CAAC;AAG5D,MAAM,WAAW,kBAAkB;IACjC,KAAK,EAAE,KAAK,CAAC;CACd;AAID,MAAM,MAAM,kBAAkB,GAAG;IAE/B,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC;IAC3B,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,SAAS,CAAC,EAAE,KAAK,CAAC,WAAW,CAAC,CAAC;IAC/B,mBAAmB,CAAC,EAAE,mBAAmB,CAAC,qBAAqB,CAAC,CAAC;IACjE,wBAAwB,CAAC,EAAE,mBAAmB,CAAC,0BAA0B,CAAC,CAAC;IAE3E,IAAI,CAAC,EAAE,WAAW,CAAC;IACnB,QAAQ,CAAC,EAAE,QAAQ,CAAC;CACrB,GAAG,CACA;IACE;;;;;;;OAOG;IACH,MAAM,EAAE,KAAK,CAAC,QAAQ,CAAC,CAAC;IACxB,IAAI,CAAC,EAAE,KAAK,CAAC;CACd,GACD;IACE,IAAI,EAAE,kBAAkB,CAAC;IACzB;;;;;;;OAOG;IACH,MAAM,CAAC,EAAE,KAAK,CAAC;CAChB,CACJ,CAAC;AAEF,eAAO,MAAM,aAAa,EAAE,KAAK,CAAC,EAAE,CAAC,iBAAiB,CAAC,kBAAkB,CAAC,CAoCzE,CAAC;AAEF,eAAO,MAAM,cAAc,QAAO,KAMjC,CAAC"}
1
+ {"version":3,"file":"KnockProvider.d.ts","sourceRoot":"","sources":["../../../../../src/modules/core/context/KnockProvider.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EACZ,mBAAmB,EACnB,QAAQ,EACR,kBAAkB,EACnB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,iBAAiB,EAAE,MAAM,OAAO,CAAC;AAE1C,OAAO,EAAE,WAAW,EAAqB,MAAM,YAAY,CAAC;AAG5D,MAAM,WAAW,kBAAkB;IACjC,KAAK,EAAE,KAAK,CAAC;CACd;AAID,MAAM,MAAM,kBAAkB,GAAG;IAE/B,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC;IAC3B,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,SAAS,CAAC,EAAE,KAAK,CAAC,WAAW,CAAC,CAAC;IAC/B,mBAAmB,CAAC,EAAE,mBAAmB,CAAC,qBAAqB,CAAC,CAAC;IACjE,wBAAwB,CAAC,EAAE,mBAAmB,CAAC,0BAA0B,CAAC,CAAC;IAE3E,IAAI,CAAC,EAAE,WAAW,CAAC;IACnB,QAAQ,CAAC,EAAE,QAAQ,CAAC;CACrB,GAAG,CACA;IACE;;;;;;;OAOG;IACH,MAAM,EAAE,KAAK,CAAC,QAAQ,CAAC,CAAC;IACxB,IAAI,CAAC,EAAE,KAAK,CAAC;IACb,sBAAsB,CAAC,EAAE,KAAK,CAAC;CAChC,GACD;IACE,IAAI,EAAE,kBAAkB,CAAC;IACzB,sBAAsB,CAAC,EAAE,mBAAmB,CAAC,wBAAwB,CAAC,CAAC;IACvE;;;;;;;OAOG;IACH,MAAM,CAAC,EAAE,KAAK,CAAC;CAChB,CACJ,CAAC;AAEF,eAAO,MAAM,aAAa,EAAE,KAAK,CAAC,EAAE,CAAC,iBAAiB,CAAC,kBAAkB,CAAC,CA4CzE,CAAC;AAEF,eAAO,MAAM,cAAc,QAAO,KAMjC,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"useAuthenticatedKnockClient.d.ts","sourceRoot":"","sources":["../../../../../src/modules/core/hooks/useAuthenticatedKnockClient.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EACZ,mBAAmB,EACnB,YAAY,EACZ,MAAM,EACN,0BAA0B,EAC3B,MAAM,mBAAmB,CAAC;AAiB3B,MAAM,MAAM,+BAA+B,GAAG,YAAY,GACxD,mBAAmB,CAAC;AAEtB;;;;;;;GAOG;AACH,iBAAS,2BAA2B,CAClC,MAAM,EAAE,MAAM,EACd,0BAA0B,EAAE,MAAM,EAClC,SAAS,CAAC,EAAE,KAAK,CAAC,WAAW,CAAC,EAC9B,OAAO,CAAC,EAAE,+BAA+B,GACxC,KAAK,CAAC;AACT,iBAAS,2BAA2B,CAClC,MAAM,EAAE,MAAM,EACd,0BAA0B,EAAE,0BAA0B,EACtD,SAAS,CAAC,EAAE,KAAK,CAAC,WAAW,CAAC,EAC9B,OAAO,CAAC,EAAE,+BAA+B,GACxC,KAAK,CAAC;AAyDT,eAAe,2BAA2B,CAAC"}
1
+ {"version":3,"file":"useAuthenticatedKnockClient.d.ts","sourceRoot":"","sources":["../../../../../src/modules/core/hooks/useAuthenticatedKnockClient.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EACZ,mBAAmB,EACnB,YAAY,EACZ,MAAM,EACN,0BAA0B,EAC3B,MAAM,mBAAmB,CAAC;AAkB3B,MAAM,MAAM,+BAA+B,GAAG,YAAY,GACxD,mBAAmB,CAAC;AAEtB;;;;;;;GAOG;AACH,iBAAS,2BAA2B,CAClC,MAAM,EAAE,MAAM,EACd,0BAA0B,EAAE,MAAM,EAClC,SAAS,CAAC,EAAE,KAAK,CAAC,WAAW,CAAC,EAC9B,OAAO,CAAC,EAAE,+BAA+B,GACxC,KAAK,CAAC;AACT,iBAAS,2BAA2B,CAClC,MAAM,EAAE,MAAM,EACd,0BAA0B,EAAE,0BAA0B,EACtD,SAAS,CAAC,EAAE,KAAK,CAAC,WAAW,CAAC,EAC9B,OAAO,CAAC,EAAE,+BAA+B,GACxC,KAAK,CAAC;AAyDT,eAAe,2BAA2B,CAAC"}
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@knocklabs/react-core",
3
3
  "description": "A set of React components to build notification experiences powered by Knock",
4
4
  "author": "@knocklabs",
5
- "version": "0.9.2",
5
+ "version": "0.10.1",
6
6
  "license": "MIT",
7
7
  "main": "dist/cjs/index.js",
8
8
  "module": "dist/esm/index.mjs",
@@ -47,7 +47,7 @@
47
47
  "react": "^16.11.0 || ^17.0.0 || ^18.0.0 || ^19.0.0"
48
48
  },
49
49
  "dependencies": {
50
- "@knocklabs/client": "^0.17.2",
50
+ "@knocklabs/client": "^0.18.1",
51
51
  "@tanstack/react-store": "^0.7.3",
52
52
  "date-fns": "^4.0.0",
53
53
  "fast-deep-equal": "^3.1.3",
package/src/index.ts CHANGED
@@ -71,3 +71,9 @@ export {
71
71
  export { type RecipientObject } from "./interfaces";
72
72
 
73
73
  export { usePreferences } from "./modules/preferences";
74
+
75
+ // Export the useStore hook from @tanstack/react-store library so that it can
76
+ // be available to be imported into the consumer package, and be part of the
77
+ // same module graph. This potentially helps Next.js App Router to bundle client
78
+ // side components together correctly.
79
+ export { useStore } from "@tanstack/react-store";
@@ -37,9 +37,11 @@ export type KnockProviderProps = {
37
37
  */
38
38
  userId: Knock["userId"];
39
39
  user?: never;
40
+ identificationStrategy?: never;
40
41
  }
41
42
  | {
42
43
  user: UserWithProperties;
44
+ identificationStrategy?: AuthenticateOptions["identificationStrategy"];
43
45
  /**
44
46
  * @deprecated The `userId` prop is deprecated and will be removed in a future version.
45
47
  * Please pass the `user` prop instead containing an `id` value.
@@ -61,6 +63,7 @@ export const KnockProvider: React.FC<PropsWithChildren<KnockProviderProps>> = ({
61
63
  timeBeforeExpirationInMs,
62
64
  children,
63
65
  i18n,
66
+ identificationStrategy,
64
67
  ...props
65
68
  }) => {
66
69
  const userIdOrUserWithProperties = props?.user || props?.userId;
@@ -72,8 +75,15 @@ export const KnockProvider: React.FC<PropsWithChildren<KnockProviderProps>> = ({
72
75
  onUserTokenExpiring,
73
76
  timeBeforeExpirationInMs,
74
77
  logLevel,
78
+ identificationStrategy,
75
79
  }),
76
- [host, onUserTokenExpiring, timeBeforeExpirationInMs, logLevel],
80
+ [
81
+ host,
82
+ onUserTokenExpiring,
83
+ timeBeforeExpirationInMs,
84
+ logLevel,
85
+ identificationStrategy,
86
+ ],
77
87
  );
78
88
 
79
89
  const knock = useAuthenticatedKnockClient(
@@ -17,6 +17,7 @@ function authenticateWithOptions(
17
17
  knock.authenticate(userIdOrUserWithProperties, userToken, {
18
18
  onUserTokenExpiring: options?.onUserTokenExpiring,
19
19
  timeBeforeExpirationInMs: options?.timeBeforeExpirationInMs,
20
+ identificationStrategy: options?.identificationStrategy,
20
21
  });
21
22
  }
22
23