@planningcenter/chat-react-native 3.20.1-rc.2 → 3.20.1-rc.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.
Files changed (59) hide show
  1. package/build/contexts/chat_context.d.ts +2 -0
  2. package/build/contexts/chat_context.d.ts.map +1 -1
  3. package/build/contexts/chat_context.js +40 -1
  4. package/build/contexts/chat_context.js.map +1 -1
  5. package/build/hooks/index.d.ts +1 -0
  6. package/build/hooks/index.d.ts.map +1 -1
  7. package/build/hooks/index.js +1 -0
  8. package/build/hooks/index.js.map +1 -1
  9. package/build/hooks/use_conversation.d.ts +1 -0
  10. package/build/hooks/use_conversation.d.ts.map +1 -1
  11. package/build/hooks/use_conversation.js +11 -2
  12. package/build/hooks/use_conversation.js.map +1 -1
  13. package/build/hooks/use_product_analytics.d.ts +9 -0
  14. package/build/hooks/use_product_analytics.d.ts.map +1 -0
  15. package/build/hooks/use_product_analytics.js +68 -0
  16. package/build/hooks/use_product_analytics.js.map +1 -0
  17. package/build/screens/conversation_screen.d.ts.map +1 -1
  18. package/build/screens/conversation_screen.js +6 -0
  19. package/build/screens/conversation_screen.js.map +1 -1
  20. package/build/screens/conversations/conversations_screen.d.ts.map +1 -1
  21. package/build/screens/conversations/conversations_screen.js +2 -1
  22. package/build/screens/conversations/conversations_screen.js.map +1 -1
  23. package/build/types/product_analytics.d.ts +6 -0
  24. package/build/types/product_analytics.d.ts.map +1 -0
  25. package/build/types/product_analytics.js +2 -0
  26. package/build/types/product_analytics.js.map +1 -0
  27. package/build/types/resources/analytics_metadata.d.ts +5 -0
  28. package/build/types/resources/analytics_metadata.d.ts.map +1 -0
  29. package/build/types/resources/analytics_metadata.js +2 -0
  30. package/build/types/resources/analytics_metadata.js.map +1 -0
  31. package/build/types/resources/conversation.d.ts +2 -0
  32. package/build/types/resources/conversation.d.ts.map +1 -1
  33. package/build/types/resources/conversation.js.map +1 -1
  34. package/build/types/resources/index.d.ts +1 -0
  35. package/build/types/resources/index.d.ts.map +1 -1
  36. package/build/types/resources/index.js +1 -0
  37. package/build/types/resources/index.js.map +1 -1
  38. package/build/utils/request/conversation.d.ts.map +1 -1
  39. package/build/utils/request/conversation.js +2 -1
  40. package/build/utils/request/conversation.js.map +1 -1
  41. package/build/utils/sha_256.d.ts +31 -0
  42. package/build/utils/sha_256.d.ts.map +1 -0
  43. package/build/utils/sha_256.js +195 -0
  44. package/build/utils/sha_256.js.map +1 -0
  45. package/package.json +2 -2
  46. package/src/__tests__/hooks/useTheme.tsx +40 -16
  47. package/src/contexts/chat_context.tsx +59 -2
  48. package/src/hooks/index.ts +1 -0
  49. package/src/hooks/use_conversation.ts +12 -2
  50. package/src/hooks/use_product_analytics.ts +107 -0
  51. package/src/screens/conversation_screen.tsx +11 -0
  52. package/src/screens/conversations/conversations_screen.tsx +3 -1
  53. package/src/types/product_analytics.ts +5 -0
  54. package/src/types/resources/analytics_metadata.ts +4 -0
  55. package/src/types/resources/conversation.ts +2 -0
  56. package/src/types/resources/index.ts +1 -0
  57. package/src/utils/__tests__/sha_256.test.ts +70 -0
  58. package/src/utils/request/conversation.ts +2 -1
  59. package/src/utils/sha_256.ts +229 -0
@@ -1 +1 @@
1
- {"version":3,"file":"conversations_screen.js","sourceRoot":"","sources":["../../../src/screens/conversations/conversations_screen.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAqB,aAAa,EAAE,MAAM,0BAA0B,CAAA;AAC3E,OAAO,KAAK,EAAE,EAAE,WAAW,EAAE,MAAM,OAAO,CAAA;AAC1C,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,cAAc,CAAA;AAC/C,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAA;AAC5D,OAAO,EAAE,YAAY,EAAE,MAAM,wCAAwC,CAAA;AACrE,OAAO,EAAE,4BAA4B,EAAE,MAAM,sCAAsC,CAAA;AACnF,OAAO,EAAE,yBAAyB,EAAE,MAAM,aAAa,CAAA;AAGv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CAAC,MAAM,CAAC;QACvB,SAAS,EAAE;YACT,IAAI,EAAE,CAAC;YACP,cAAc,EAAE,QAAQ;SACzB;KACF,CAAC,CAAA;AACJ,CAAC,CAAA","sourcesContent":["import { StaticScreenProps, useNavigation } from '@react-navigation/native'\nimport React, { useCallback } from 'react'\nimport { StyleSheet, View } from 'react-native'\nimport { Conversations, TextButton } from '../../components'\nimport { ActionButton } from '../../components/display/action_button'\nimport { ConversationsContextProvider } from '../../contexts/conversations_context'\nimport { useCanCreateConversations } from '../../hooks'\nimport { AppName } from '../../types/resources/app_name'\nimport { GraphId } from '../../types/resources/group_resource'\nimport { destructureChatGroupGraphId, MAX_FONT_SIZE_MULTIPLIER_LANDMARK } from '../../utils'\nimport { ListHeaderComponent } from './components/list_header_component'\nimport { useAppName } from '../../hooks/use_app_name'\n\nexport type ConversationsScreenProps = StaticScreenProps<{\n title?: string\n chat_group_graph_id?: GraphId\n group_source_app_name?: AppName\n}>\n\nexport function ConversationsScreen({ route }: ConversationsScreenProps) {\n const navigation = useNavigation()\n const canCreateConversations = useCanCreateConversations()\n const styles = useStyles()\n const appName = useAppName()\n\n const { chat_group_graph_id } = route.params || {}\n const { sourceAppName, sourceId } = destructureChatGroupGraphId(chat_group_graph_id)\n\n const handleNewConversationNavigation = () => {\n if (sourceAppName === 'Services') {\n return navigation.navigate('New', {\n screen: 'ConversationNew',\n params: {\n team_ids: sourceId ? [sourceId] : [],\n source_app_name: sourceAppName,\n ...route.params,\n },\n })\n }\n if (sourceAppName === 'Groups') {\n return navigation.navigate('New', {\n screen: 'ConversationNew',\n params: {\n group_id: sourceId,\n source_app_name: sourceAppName,\n ...route.params,\n },\n })\n }\n\n return navigation.navigate('New', {\n screen: 'ConversationSelectRecipients',\n params: {\n ...route.params,\n },\n })\n }\n\n const handleGetHelp = useCallback(() => {\n navigation.navigate('GetHelp', { type: 'chat' })\n }, [navigation])\n\n return (\n <View style={styles.container}>\n <ConversationsContextProvider args={route.params}>\n <Conversations ListHeaderComponent={ListHeaderComponent} />\n </ConversationsContextProvider>\n <ActionButton\n visible={canCreateConversations}\n title=\"New conversation\"\n onPress={handleNewConversationNavigation}\n buttonIconNameLeft=\"churchCenter.signups\"\n secondaryButton={appName === 'services' ? null : <GetHelpButton onPress={handleGetHelp} />}\n />\n </View>\n )\n}\n\nconst GetHelpButton = ({ onPress }: { onPress: () => void }) => {\n return (\n <TextButton\n variant=\"tertiary\"\n onPress={onPress}\n maxFontSizeMultiplier={MAX_FONT_SIZE_MULTIPLIER_LANDMARK}\n accessibilityShowsLargeContentViewer\n accessibilityLargeContentTitle=\"Get help\"\n >\n Get help\n </TextButton>\n )\n}\n\nconst useStyles = () => {\n return StyleSheet.create({\n container: {\n flex: 1,\n justifyContent: 'center',\n },\n })\n}\n"]}
1
+ {"version":3,"file":"conversations_screen.js","sourceRoot":"","sources":["../../../src/screens/conversations/conversations_screen.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAqB,aAAa,EAAE,MAAM,0BAA0B,CAAA;AAC3E,OAAO,KAAK,EAAE,EAAE,WAAW,EAAE,MAAM,OAAO,CAAA;AAC1C,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,cAAc,CAAA;AAC/C,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAA;AAC5D,OAAO,EAAE,YAAY,EAAE,MAAM,wCAAwC,CAAA;AACrE,OAAO,EAAE,4BAA4B,EAAE,MAAM,sCAAsC,CAAA;AACnF,OAAO,EAAE,yBAAyB,EAAE,+BAA+B,EAAE,MAAM,aAAa,CAAA;AAGxF,OAAO,EAAE,2BAA2B,EAAE,iCAAiC,EAAE,MAAM,aAAa,CAAA;AAC5F,OAAO,EAAE,mBAAmB,EAAE,MAAM,oCAAoC,CAAA;AACxE,OAAO,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAA;AAQrD,MAAM,UAAU,mBAAmB,CAAC,EAAE,KAAK,EAA4B;IACrE,MAAM,UAAU,GAAG,aAAa,E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,EAAE,CAAC,UAAU,CAAC,CAAC,CAAA;IAEhB,+BAA+B,CAAC,wCAAwC,CAAC,CAAA;IAEzE,OAAO,CACL,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,MAAM,CAAC,SAAS,CAAC,CAC5B;MAAA,CAAC,4BAA4B,CAAC,IAAI,CAAC,CAAC,KAAK,CAAC,MAAM,CAAC,CAC/C;QAAA,CAAC,aAAa,CAAC,mBAAmB,CAAC,CAAC,mBAAmB,CAAC,EAC1D;MAAA,EAAE,4BAA4B,CAC9B;MAAA,CAAC,YAAY,CACX,OAAO,CAAC,CAAC,sBAAsB,CAAC,CAChC,KAAK,CAAC,kBAAkB,CACxB,OAAO,CAAC,CAAC,+BAA+B,CAAC,CACzC,kBAAkB,CAAC,sBAAsB,CACzC,eAAe,CAAC,CAAC,OAAO,KAAK,UAAU,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,aAAa,CAAC,OAAO,CAAC,CAAC,aAAa,CAAC,EAAG,CAAC,EAE/F;IAAA,EAAE,IAAI,CAAC,CACR,CAAA;AACH,CAAC;AAED,MAAM,aAAa,GAAG,CAAC,EAAE,OAAO,EAA2B,EAAE,EAAE;IAC7D,OAAO,CACL,CAAC,UAAU,CACT,OAAO,CAAC,UAAU,CAClB,OAAO,CAAC,CAAC,OAAO,CAAC,CACjB,qBAAqB,CAAC,CAAC,iCAAiC,CAAC,CACzD,oCAAoC,CACpC,8BAA8B,CAAC,UAAU,CAEzC;;IACF,EAAE,UAAU,CAAC,CACd,CAAA;AACH,CAAC,CAAA;AAED,MAAM,SAAS,GAAG,GAAG,EAAE;IACrB,OAAO,UAAU,CAAC,MAAM,CAAC;QACvB,SAAS,EAAE;YACT,IAAI,EAAE,CAAC;YACP,cAAc,EAAE,QAAQ;SACzB;KACF,CAAC,CAAA;AACJ,CAAC,CAAA","sourcesContent":["import { StaticScreenProps, useNavigation } from '@react-navigation/native'\nimport React, { useCallback } from 'react'\nimport { StyleSheet, View } from 'react-native'\nimport { Conversations, TextButton } from '../../components'\nimport { ActionButton } from '../../components/display/action_button'\nimport { ConversationsContextProvider } from '../../contexts/conversations_context'\nimport { useCanCreateConversations, usePublishProductAnalyticsEvent } from '../../hooks'\nimport { AppName } from '../../types/resources/app_name'\nimport { GraphId } from '../../types/resources/group_resource'\nimport { destructureChatGroupGraphId, MAX_FONT_SIZE_MULTIPLIER_LANDMARK } from '../../utils'\nimport { ListHeaderComponent } from './components/list_header_component'\nimport { useAppName } from '../../hooks/use_app_name'\n\nexport type ConversationsScreenProps = StaticScreenProps<{\n title?: string\n chat_group_graph_id?: GraphId\n group_source_app_name?: AppName\n}>\n\nexport function ConversationsScreen({ route }: ConversationsScreenProps) {\n const navigation = useNavigation()\n const canCreateConversations = useCanCreateConversations()\n const styles = useStyles()\n const appName = useAppName()\n\n const { chat_group_graph_id } = route.params || {}\n const { sourceAppName, sourceId } = destructureChatGroupGraphId(chat_group_graph_id)\n\n const handleNewConversationNavigation = () => {\n if (sourceAppName === 'Services') {\n return navigation.navigate('New', {\n screen: 'ConversationNew',\n params: {\n team_ids: sourceId ? [sourceId] : [],\n source_app_name: sourceAppName,\n ...route.params,\n },\n })\n }\n if (sourceAppName === 'Groups') {\n return navigation.navigate('New', {\n screen: 'ConversationNew',\n params: {\n group_id: sourceId,\n source_app_name: sourceAppName,\n ...route.params,\n },\n })\n }\n\n return navigation.navigate('New', {\n screen: 'ConversationSelectRecipients',\n params: {\n ...route.params,\n },\n })\n }\n\n const handleGetHelp = useCallback(() => {\n navigation.navigate('GetHelp', { type: 'chat' })\n }, [navigation])\n\n usePublishProductAnalyticsEvent('chat.mobile.conversations.index.opened')\n\n return (\n <View style={styles.container}>\n <ConversationsContextProvider args={route.params}>\n <Conversations ListHeaderComponent={ListHeaderComponent} />\n </ConversationsContextProvider>\n <ActionButton\n visible={canCreateConversations}\n title=\"New conversation\"\n onPress={handleNewConversationNavigation}\n buttonIconNameLeft=\"churchCenter.signups\"\n secondaryButton={appName === 'services' ? null : <GetHelpButton onPress={handleGetHelp} />}\n />\n </View>\n )\n}\n\nconst GetHelpButton = ({ onPress }: { onPress: () => void }) => {\n return (\n <TextButton\n variant=\"tertiary\"\n onPress={onPress}\n maxFontSizeMultiplier={MAX_FONT_SIZE_MULTIPLIER_LANDMARK}\n accessibilityShowsLargeContentViewer\n accessibilityLargeContentTitle=\"Get help\"\n >\n Get help\n </TextButton>\n )\n}\n\nconst useStyles = () => {\n return StyleSheet.create({\n container: {\n flex: 1,\n justifyContent: 'center',\n },\n })\n}\n"]}
@@ -0,0 +1,6 @@
1
+ export interface ProductAnalyticsConfig {
2
+ token: string;
3
+ endpoint: string;
4
+ metadata: Record<string, unknown>;
5
+ }
6
+ //# sourceMappingURL=product_analytics.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"product_analytics.d.ts","sourceRoot":"","sources":["../../src/types/product_analytics.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,sBAAsB;IACrC,KAAK,EAAE,MAAM,CAAA;IACb,QAAQ,EAAE,MAAM,CAAA;IAChB,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;CAClC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=product_analytics.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"product_analytics.js","sourceRoot":"","sources":["../../src/types/product_analytics.ts"],"names":[],"mappings":"","sourcesContent":["export interface ProductAnalyticsConfig {\n token: string\n endpoint: string\n metadata: Record<string, unknown>\n}\n"]}
@@ -0,0 +1,5 @@
1
+ export interface AnalyticsMetadataResource {
2
+ id: number;
3
+ metadata: Record<string, unknown>;
4
+ }
5
+ //# sourceMappingURL=analytics_metadata.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"analytics_metadata.d.ts","sourceRoot":"","sources":["../../../src/types/resources/analytics_metadata.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,yBAAyB;IACxC,EAAE,EAAE,MAAM,CAAA;IACV,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;CAClC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=analytics_metadata.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"analytics_metadata.js","sourceRoot":"","sources":["../../../src/types/resources/analytics_metadata.ts"],"names":[],"mappings":"","sourcesContent":["export interface AnalyticsMetadataResource {\n id: number\n metadata: Record<string, unknown>\n}\n"]}
@@ -1,3 +1,4 @@
1
+ import type { AnalyticsMetadataResource } from './analytics_metadata';
1
2
  import { ConversationBadgeResource } from './conversation_badge';
2
3
  import { GroupResource } from './group_resource';
3
4
  import { MemberAbilityResource } from './member_ability';
@@ -5,6 +6,7 @@ export interface ConversationResource {
5
6
  type: 'Conversation';
6
7
  id: number;
7
8
  badges?: ConversationBadgeResource[];
9
+ analyticsMetadata?: AnalyticsMetadataResource;
8
10
  conversationMembership?: {
9
11
  lastReadMessageSortKey: string;
10
12
  };
@@ -1 +1 @@
1
- {"version":3,"file":"conversation.d.ts","sourceRoot":"","sources":["../../../src/types/resources/conversation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,yBAAyB,EAAE,MAAM,sBAAsB,CAAA;AAChE,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAA;AAChD,OAAO,EAAE,qBAAqB,EAAE,MAAM,kBAAkB,CAAA;AAExD,MAAM,WAAW,oBAAoB;IACnC,IAAI,EAAE,cAAc,CAAA;IACpB,EAAE,EAAE,MAAM,CAAA;IACV,MAAM,CAAC,EAAE,yBAAyB,EAAE,CAAA;IACpC,sBAAsB,CAAC,EAAE;QACvB,sBAAsB,EAAE,MAAM,CAAA;KAC/B,CAAA;IACD,SAAS,EAAE,MAAM,CAAA;IACjB,OAAO,CAAC,EAAE,OAAO,CAAA;IACjB,MAAM,CAAC,EAAE,aAAa,EAAE,CAAA;IACxB,iBAAiB,CAAC,EAAE,MAAM,EAAE,CAAA;IAC5B,mBAAmB,C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wBAAwB,CAAC,EAAE,MAAM,CAAA;IACjC,aAAa,CAAC,EAAE,qBAAqB,CAAA;IACrC,KAAK,EAAE,OAAO,CAAA;IACd,eAAe,EAAE,OAAO,CAAA;IACxB,KAAK,EAAE,MAAM,CAAA;IACb,WAAW,EAAE,MAAM,CAAA;IACnB,SAAS,EAAE,MAAM,CAAA;CAClB"}
@@ -1 +1 @@
1
- {"version":3,"file":"conversation.js","sourceRoot":"","sources":["../../../src/types/resources/conversation.ts"],"names":[],"mappings":"","sourcesContent":["import { ConversationBadgeResource } from './conversation_badge'\nimport { GroupResource } from './group_resource'\nimport { MemberAbilityResource } from './member_ability'\n\nexport interface ConversationResource {\n type: 'Conversation'\n id: number\n badges?: ConversationBadgeResource[]\n conversationMembership?: {\n lastReadMessageSortKey: string\n }\n createdAt: string\n deleted?: boolean\n groups?: GroupResource[]\n previewAvatarUrls?: string[]\n lastMessageAuthorId?: string\n lastMessageAuthorName?: string\n lastMessageCreatedAt?: string\n lastMessageTextPreview?: string\n latestReadMessageSortKey?: string\n memberAbility?: MemberAbilityResource\n muted: boolean\n repliesDisabled: boolean\n title: string\n unreadCount: number\n updatedAt: string\n}\n"]}
1
+ {"version":3,"file":"conversation.js","sourceRoot":"","sources":["../../../src/types/resources/conversation.ts"],"names":[],"mappings":"","sourcesContent":["import type { AnalyticsMetadataResource } from './analytics_metadata'\nimport { ConversationBadgeResource } from './conversation_badge'\nimport { GroupResource } from './group_resource'\nimport { MemberAbilityResource } from './member_ability'\n\nexport interface ConversationResource {\n type: 'Conversation'\n id: number\n badges?: ConversationBadgeResource[]\n analyticsMetadata?: AnalyticsMetadataResource\n conversationMembership?: {\n lastReadMessageSortKey: string\n }\n createdAt: string\n deleted?: boolean\n groups?: GroupResource[]\n previewAvatarUrls?: string[]\n lastMessageAuthorId?: string\n lastMessageAuthorName?: string\n lastMessageCreatedAt?: string\n lastMessageTextPreview?: string\n latestReadMessageSortKey?: string\n memberAbility?: MemberAbilityResource\n muted: boolean\n repliesDisabled: boolean\n title: string\n unreadCount: number\n updatedAt: string\n}\n"]}
@@ -1,3 +1,4 @@
1
+ export * from './analytics_metadata';
1
2
  export * from './conversation';
2
3
  export * from './member';
3
4
  export * from './message';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/types/resources/index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAA;AAC9B,cAAc,UAAU,CAAA;AACxB,cAAc,WAAW,CAAA;AACzB,cAAc,eAAe,CAAA;AAC7B,cAAc,UAAU,CAAA;AACxB,cAAc,UAAU,CAAA;AACxB,cAAc,aAAa,CAAA;AAC3B,cAAc,YAAY,CAAA;AAC1B,cAAc,gBAAgB,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/types/resources/index.ts"],"names":[],"mappings":"AAAA,cAAc,sBAAsB,CAAA;AACpC,cAAc,gBAAgB,CAAA;AAC9B,cAAc,UAAU,CAAA;AACxB,cAAc,WAAW,CAAA;AACzB,cAAc,eAAe,CAAA;AAC7B,cAAc,UAAU,CAAA;AACxB,cAAc,UAAU,CAAA;AACxB,cAAc,aAAa,CAAA;AAC3B,cAAc,YAAY,CAAA;AAC1B,cAAc,gBAAgB,CAAA"}
@@ -1,3 +1,4 @@
1
+ export * from './analytics_metadata';
1
2
  export * from './conversation';
2
3
  export * from './member';
3
4
  export * from './message';
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/types/resources/index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAA;AAC9B,cAAc,UAAU,CAAA;AACxB,cAAc,WAAW,CAAA;AACzB,cAAc,eAAe,CAAA;AAC7B,cAAc,UAAU,CAAA;AACxB,cAAc,UAAU,CAAA;AACxB,cAAc,aAAa,CAAA;AAC3B,cAAc,YAAY,CAAA;AAC1B,cAAc,gBAAgB,CAAA","sourcesContent":["export * from './conversation'\nexport * from './member'\nexport * from './message'\nexport * from './oauth_token'\nexport * from './person'\nexport * from './groups'\nexport * from './app_grant'\nexport * from './services'\nexport * from './organization'\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/types/resources/index.ts"],"names":[],"mappings":"AAAA,cAAc,sBAAsB,CAAA;AACpC,cAAc,gBAAgB,CAAA;AAC9B,cAAc,UAAU,CAAA;AACxB,cAAc,WAAW,CAAA;AACzB,cAAc,eAAe,CAAA;AAC7B,cAAc,UAAU,CAAA;AACxB,cAAc,UAAU,CAAA;AACxB,cAAc,aAAa,CAAA;AAC3B,cAAc,YAAY,CAAA;AAC1B,cAAc,gBAAgB,CAAA","sourcesContent":["export * from './analytics_metadata'\nexport * from './conversation'\nexport * from './member'\nexport * from './message'\nexport * from './oauth_token'\nexport * from './person'\nexport * from './groups'\nexport * from './app_grant'\nexport * from './services'\nexport * from './organization'\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"conversation.d.ts","sourceRoot":"","sources":["../../../src/utils/request/conversation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,sCAAsC,CAAA;AAC9D,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAA;AAE5C,MAAM,WAAW,uBAAuB;IACtC,IAAI,EAAE,MAAM,CAAA;IACZ,mBAAmB,CAAC,EAAE,OAAO,CAAA;IAC7B,qBAAqB,CAAC,EAAE,MAAM,CAAA;CAC/B;AAED,eAAO,MAAM,2BAA2B,2DAIrC,OAAO,CAAC,uBAAuB,CAAC,KAAQ,UAsC1C,CAAA"}
1
+ {"version":3,"file":"conversation.d.ts","sourceRoot":"","sources":["../../../src/utils/request/conversation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,sCAAsC,CAAA;AAC9D,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAA;AAE5C,MAAM,WAAW,uBAAuB;IACtC,IAAI,EAAE,MAAM,CAAA;IACZ,mBAAmB,CAAC,EAAE,OAAO,CAAA;IAC7B,qBAAqB,CAAC,EAAE,MAAM,CAAA;CAC/B;AAED,eAAO,MAAM,2BAA2B,2DAIrC,OAAO,CAAC,uBAAuB,CAAC,KAAQ,UAuC1C,CAAA"}
@@ -30,9 +30,10 @@ export const getConversationsRequestArgs = ({ gids, chat_group_graph_id, group_s
30
30
  'unread_count',
31
31
  'updated_at',
32
32
  ],
33
+ AnalyticsMetadata: ['metadata'],
33
34
  ConversationBadge: ['app_name', 'pco_resource_type', 'text'],
34
35
  },
35
- include: ['badges'],
36
+ include: ['badges', 'analytics_metadata'],
36
37
  },
37
38
  };
38
39
  };
@@ -1 +1 @@
1
- {"version":3,"file":"conversation.js","sourceRoot":"","sources":["../../../src/utils/request/conversation.ts"],"names":[],"mappings":"AASA,MAAM,CAAC,MAAM,2BAA2B,GAAG,CAAC,EAC1C,IAAI,EACJ,mBAAmB,EACnB,qBAAqB,MACe,EAAE,EAAc,EAAE;IACtD,MAAM,MAAM,GAAG,mBAAmB;QAChC,CAAC,CAAC,OAAO;QACT,CAAC,CAAC,qBAAqB;YACrB,CAAC,CAAC,uBAAuB;YACzB,CAAC,CAAC,mBAAmB,CAAA;IAEzB,OAAO;QACL,GAAG,EAAE,mBAAmB;QACxB,IAAI,EAAE;YACJ,OAAO,EAAE,EAAE;YACX,KAAK,EAAE,eAAe;YACtB,MAAM;YACN,IAAI;YACJ,KAAK,EAAE,mBAAmB;YAC1B,qBAAqB;YACrB,MAAM,EAAE;gBACN,YAAY,EAAE;oBACZ,YAAY;oBACZ,QAAQ;oBACR,QAAQ;oBACR,wBAAwB;oBACxB,0BAA0B;oBAC1B,yBAAyB;oBACzB,2BAA2B;oBAC3B,qBAAqB;oBACrB,gBAAgB;oBAChB,OAAO;oBACP,kBAAkB;oBAClB,OAAO;oBACP,cAAc;oBACd,YAAY;iBACb;gBACD,iBAAiB,EAAE,CAAC,UAAU,EAAE,mBAAmB,EAAE,MAAM,CAAC;aAC7D;YACD,OAAO,EAAE,CAAC,QAAQ,CAAC;SACpB;KACF,CAAA;AACH,CAAC,CAAA","sourcesContent":["import { GraphId } from '../../types/resources/group_resource'\nimport { GetRequest } from '../client/types'\n\nexport interface ConversationRequestArgs {\n gids: string\n chat_group_graph_id?: GraphId\n group_source_app_name?: string\n}\n\nexport const getConversationsRequestArgs = ({\n gids,\n chat_group_graph_id,\n group_source_app_name,\n}: Partial<ConversationRequestArgs> = {}): GetRequest => {\n const filter = chat_group_graph_id\n ? 'group'\n : group_source_app_name\n ? 'group_source_app_name'\n : 'mine_or_not_empty'\n\n return {\n url: '/me/conversations',\n data: {\n perPage: 20,\n order: '-last_message',\n filter,\n gids,\n group: chat_group_graph_id,\n group_source_app_name,\n fields: {\n Conversation: [\n 'created_at',\n 'badges',\n 'groups',\n 'last_message_author_id',\n 'last_message_author_name',\n 'last_message_created_at',\n 'last_message_text_preview',\n 'preview_avatar_urls',\n 'member_ability',\n 'muted',\n 'replies_disabled',\n 'title',\n 'unread_count',\n 'updated_at',\n ],\n ConversationBadge: ['app_name', 'pco_resource_type', 'text'],\n },\n include: ['badges'],\n },\n }\n}\n"]}
1
+ {"version":3,"file":"conversation.js","sourceRoot":"","sources":["../../../src/utils/request/conversation.ts"],"names":[],"mappings":"AASA,MAAM,CAAC,MAAM,2BAA2B,GAAG,CAAC,EAC1C,IAAI,EACJ,mBAAmB,EACnB,qBAAqB,MACe,EAAE,EAAc,EAAE;IACtD,MAAM,MAAM,GAAG,mBAAmB;QAChC,CAAC,CAAC,OAAO;QACT,CAAC,CAAC,qBAAqB;YACrB,CAAC,CAAC,uBAAuB;YACzB,CAAC,CAAC,mBAAmB,CAAA;IAEzB,OAAO;QACL,GAAG,EAAE,mBAAmB;QACxB,IAAI,EAAE;YACJ,OAAO,EAAE,EAAE;YACX,KAAK,EAAE,eAAe;YACtB,MAAM;YACN,IAAI;YACJ,KAAK,EAAE,mBAAmB;YAC1B,qBAAqB;YACrB,MAAM,EAAE;gBACN,YAAY,EAAE;oBACZ,YAAY;oBACZ,QAAQ;oBACR,QAAQ;oBACR,wBAAwB;oBACxB,0BAA0B;oBAC1B,yBAAyB;oBACzB,2BAA2B;oBAC3B,qBAAqB;oBACrB,gBAAgB;oBAChB,OAAO;oBACP,kBAAkB;oBAClB,OAAO;oBACP,cAAc;oBACd,YAAY;iBACb;gBACD,iBAAiB,EAAE,CAAC,UAAU,CAAC;gBAC/B,iBAAiB,EAAE,CAAC,UAAU,EAAE,mBAAmB,EAAE,MAAM,CAAC;aAC7D;YACD,OAAO,EAAE,CAAC,QAAQ,EAAE,oBAAoB,CAAC;SAC1C;KACF,CAAA;AACH,CAAC,CAAA","sourcesContent":["import { GraphId } from '../../types/resources/group_resource'\nimport { GetRequest } from '../client/types'\n\nexport interface ConversationRequestArgs {\n gids: string\n chat_group_graph_id?: GraphId\n group_source_app_name?: string\n}\n\nexport const getConversationsRequestArgs = ({\n gids,\n chat_group_graph_id,\n group_source_app_name,\n}: Partial<ConversationRequestArgs> = {}): GetRequest => {\n const filter = chat_group_graph_id\n ? 'group'\n : group_source_app_name\n ? 'group_source_app_name'\n : 'mine_or_not_empty'\n\n return {\n url: '/me/conversations',\n data: {\n perPage: 20,\n order: '-last_message',\n filter,\n gids,\n group: chat_group_graph_id,\n group_source_app_name,\n fields: {\n Conversation: [\n 'created_at',\n 'badges',\n 'groups',\n 'last_message_author_id',\n 'last_message_author_name',\n 'last_message_created_at',\n 'last_message_text_preview',\n 'preview_avatar_urls',\n 'member_ability',\n 'muted',\n 'replies_disabled',\n 'title',\n 'unread_count',\n 'updated_at',\n ],\n AnalyticsMetadata: ['metadata'],\n ConversationBadge: ['app_name', 'pco_resource_type', 'text'],\n },\n include: ['badges', 'analytics_metadata'],\n },\n }\n}\n"]}
@@ -0,0 +1,31 @@
1
+ /**
2
+ * Pure JavaScript SHA-256 implementation
3
+ * Conforms to the crypto-js API for drop-in replacement
4
+ */
5
+ /** Hash result object with toString methods */
6
+ declare class HashResult {
7
+ private bytes;
8
+ constructor(bytes: number[]);
9
+ /** Convert hash to hexadecimal string */
10
+ toString(encoding?: {
11
+ stringify: (bytes: number[]) => string;
12
+ }): string;
13
+ }
14
+ /** Hex encoding object (mimics crypto-js enc.Hex) */
15
+ export declare const Hex: {
16
+ stringify: (bytes: number[]) => string;
17
+ };
18
+ /**
19
+ * Compute SHA-256 hash of a string
20
+ * @param message - The message to hash
21
+ * @returns HashResult object with toString method
22
+ */
23
+ export declare function SHA256(message: string): HashResult;
24
+ /** Encoding utilities (mimics crypto-js enc) */
25
+ export declare const enc: {
26
+ Hex: {
27
+ stringify: (bytes: number[]) => string;
28
+ };
29
+ };
30
+ export {};
31
+ //# sourceMappingURL=sha_256.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sha_256.d.ts","sourceRoot":"","sources":["../../src/utils/sha_256.ts"],"names":[],"mappings":"AAAA;;;GAGG;AA6LH,+CAA+C;AAC/C,cAAM,UAAU;IACd,OAAO,CAAC,KAAK,CAAU;gBAEX,KAAK,EAAE,MAAM,EAAE;IAI3B,yCAAyC;IACzC,QAAQ,CAAC,QAAQ,CAAC,EAAE;QAAE,SAAS,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,MAAM,CAAA;KAAE,GAAG,MAAM;CAOxE;AAED,qDAAqD;AACrD,eAAO,MAAM,GAAG;uBACK,MAAM,EAAE;CAC5B,CAAA;AAED;;;;GAIG;AACH,wBAAgB,MAAM,CAAC,OAAO,EAAE,MAAM,GAAG,UAAU,CAGlD;AAED,gDAAgD;AAChD,eAAO,MAAM,GAAG;;2BAdK,MAAM,EAAE;;CAgB5B,CAAA"}
@@ -0,0 +1,195 @@
1
+ /**
2
+ * Pure JavaScript SHA-256 implementation
3
+ * Conforms to the crypto-js API for drop-in replacement
4
+ */
5
+ /* eslint-disable no-bitwise */
6
+ // SHA-256 constants (first 32 bits of the fractional parts of the cube roots of the first 64 primes)
7
+ const K = [
8
+ 0x428a2f98, 0x71374491, 0xb5c0fbcf, 0xe9b5dba5, 0x3956c25b, 0x59f111f1, 0x923f82a4, 0xab1c5ed5,
9
+ 0xd807aa98, 0x12835b01, 0x243185be, 0x550c7dc3, 0x72be5d74, 0x80deb1fe, 0x9bdc06a7, 0xc19bf174,
10
+ 0xe49b69c1, 0xefbe4786, 0x0fc19dc6, 0x240ca1cc, 0x2de92c6f, 0x4a7484aa, 0x5cb0a9dc, 0x76f988da,
11
+ 0x983e5152, 0xa831c66d, 0xb00327c8, 0xbf597fc7, 0xc6e00bf3, 0xd5a79147, 0x06ca6351, 0x14292967,
12
+ 0x27b70a85, 0x2e1b2138, 0x4d2c6dfc, 0x53380d13, 0x650a7354, 0x766a0abb, 0x81c2c92e, 0x92722c85,
13
+ 0xa2bfe8a1, 0xa81a664b, 0xc24b8b70, 0xc76c51a3, 0xd192e819, 0xd6990624, 0xf40e3585, 0x106aa070,
14
+ 0x19a4c116, 0x1e376c08, 0x2748774c, 0x34b0bcb5, 0x391c0cb3, 0x4ed8aa4a, 0x5b9cca4f, 0x682e6ff3,
15
+ 0x748f82ee, 0x78a5636f, 0x84c87814, 0x8cc70208, 0x90befffa, 0xa4506ceb, 0xbef9a3f7, 0xc67178f2,
16
+ ];
17
+ // Initial hash values (first 32 bits of the fractional parts of the square roots of the first 8 primes)
18
+ const H = [
19
+ 0x6a09e667, 0xbb67ae85, 0x3c6ef372, 0xa54ff53a, 0x510e527f, 0x9b05688c, 0x1f83d9ab, 0x5be0cd19,
20
+ ];
21
+ /** Right rotate 32-bit integer */
22
+ function rotr(n, x) {
23
+ return (x >>> n) | (x << (32 - n));
24
+ }
25
+ /** SHA-256 choice function */
26
+ function ch(x, y, z) {
27
+ return (x & y) ^ (~x & z);
28
+ }
29
+ /** SHA-256 majority function */
30
+ function maj(x, y, z) {
31
+ return (x & y) ^ (x & z) ^ (y & z);
32
+ }
33
+ /** SHA-256 Σ0 function */
34
+ function sigma0(x) {
35
+ return rotr(2, x) ^ rotr(13, x) ^ rotr(22, x);
36
+ }
37
+ /** SHA-256 Σ1 function */
38
+ function sigma1(x) {
39
+ return rotr(6, x) ^ rotr(11, x) ^ rotr(25, x);
40
+ }
41
+ /** SHA-256 σ0 function */
42
+ function gamma0(x) {
43
+ return rotr(7, x) ^ rotr(18, x) ^ (x >>> 3);
44
+ }
45
+ /** SHA-256 σ1 function */
46
+ function gamma1(x) {
47
+ return rotr(17, x) ^ rotr(19, x) ^ (x >>> 10);
48
+ }
49
+ /** Convert string to UTF-8 byte array */
50
+ function stringToBytes(str) {
51
+ const bytes = [];
52
+ for (let i = 0; i < str.length; i++) {
53
+ let charCode = str.charCodeAt(i);
54
+ if (charCode < 0x80) {
55
+ bytes.push(charCode);
56
+ }
57
+ else if (charCode < 0x800) {
58
+ bytes.push(0xc0 | (charCode >> 6), 0x80 | (charCode & 0x3f));
59
+ }
60
+ else if (charCode < 0xd800 || charCode >= 0xe000) {
61
+ bytes.push(0xe0 | (charCode >> 12), 0x80 | ((charCode >> 6) & 0x3f), 0x80 | (charCode & 0x3f));
62
+ }
63
+ else {
64
+ // Surrogate pair
65
+ i++;
66
+ charCode = 0x10000 + (((charCode & 0x3ff) << 10) | (str.charCodeAt(i) & 0x3ff));
67
+ bytes.push(0xf0 | (charCode >> 18), 0x80 | ((charCode >> 12) & 0x3f), 0x80 | ((charCode >> 6) & 0x3f), 0x80 | (charCode & 0x3f));
68
+ }
69
+ }
70
+ return bytes;
71
+ }
72
+ /** Preprocess message: pad and convert to 512-bit blocks */
73
+ function preprocessMessage(message) {
74
+ const messageLength = message.length;
75
+ const bitLength = messageLength * 8;
76
+ // Append the '1' bit (plus zero padding to make 8 bits)
77
+ message.push(0x80);
78
+ // Append zeros until message length ≡ 448 (mod 512)
79
+ // This leaves 64 bits for the length
80
+ while (message.length % 64 !== 56) {
81
+ message.push(0x00);
82
+ }
83
+ // Append original message length as 64-bit big-endian integer
84
+ // JavaScript numbers are 53-bit safe, so we split into two 32-bit parts
85
+ const lengthHigh = Math.floor(bitLength / 0x100000000);
86
+ const lengthLow = bitLength >>> 0;
87
+ for (let i = 24; i >= 0; i -= 8) {
88
+ message.push((lengthHigh >>> i) & 0xff);
89
+ }
90
+ for (let i = 24; i >= 0; i -= 8) {
91
+ message.push((lengthLow >>> i) & 0xff);
92
+ }
93
+ // Convert byte array to 32-bit word array
94
+ const words = new Uint32Array(message.length / 4);
95
+ for (let i = 0; i < message.length; i += 4) {
96
+ words[i / 4] =
97
+ (message[i] << 24) | (message[i + 1] << 16) | (message[i + 2] << 8) | message[i + 3];
98
+ }
99
+ return words;
100
+ }
101
+ /** Process a single 512-bit chunk */
102
+ function processChunk(chunk, hash) {
103
+ const W = new Uint32Array(64);
104
+ // Prepare message schedule
105
+ for (let t = 0; t < 16; t++) {
106
+ W[t] = chunk[t];
107
+ }
108
+ for (let t = 16; t < 64; t++) {
109
+ W[t] = (gamma1(W[t - 2]) + W[t - 7] + gamma0(W[t - 15]) + W[t - 16]) >>> 0;
110
+ }
111
+ // Initialize working variables
112
+ let a = hash[0];
113
+ let b = hash[1];
114
+ let c = hash[2];
115
+ let d = hash[3];
116
+ let e = hash[4];
117
+ let f = hash[5];
118
+ let g = hash[6];
119
+ let h = hash[7];
120
+ // Main loop
121
+ for (let t = 0; t < 64; t++) {
122
+ const T1 = (h + sigma1(e) + ch(e, f, g) + K[t] + W[t]) >>> 0;
123
+ const T2 = (sigma0(a) + maj(a, b, c)) >>> 0;
124
+ h = g;
125
+ g = f;
126
+ f = e;
127
+ e = (d + T1) >>> 0;
128
+ d = c;
129
+ c = b;
130
+ b = a;
131
+ a = (T1 + T2) >>> 0;
132
+ }
133
+ // Add compressed chunk to current hash value
134
+ hash[0] = (hash[0] + a) >>> 0;
135
+ hash[1] = (hash[1] + b) >>> 0;
136
+ hash[2] = (hash[2] + c) >>> 0;
137
+ hash[3] = (hash[3] + d) >>> 0;
138
+ hash[4] = (hash[4] + e) >>> 0;
139
+ hash[5] = (hash[5] + f) >>> 0;
140
+ hash[6] = (hash[6] + g) >>> 0;
141
+ hash[7] = (hash[7] + h) >>> 0;
142
+ }
143
+ /** Compute SHA-256 hash and return as byte array */
144
+ function sha256Raw(message) {
145
+ const bytes = stringToBytes(message);
146
+ const preprocessed = preprocessMessage(bytes);
147
+ const hash = [...H]; // Copy initial hash values
148
+ // Process each 512-bit chunk
149
+ for (let i = 0; i < preprocessed.length; i += 16) {
150
+ const chunk = preprocessed.subarray(i, i + 16);
151
+ processChunk(chunk, hash);
152
+ }
153
+ // Convert hash to byte array
154
+ const result = [];
155
+ for (let i = 0; i < 8; i++) {
156
+ result.push((hash[i] >>> 24) & 0xff);
157
+ result.push((hash[i] >>> 16) & 0xff);
158
+ result.push((hash[i] >>> 8) & 0xff);
159
+ result.push(hash[i] & 0xff);
160
+ }
161
+ return result;
162
+ }
163
+ /** Hash result object with toString methods */
164
+ class HashResult {
165
+ bytes;
166
+ constructor(bytes) {
167
+ this.bytes = bytes;
168
+ }
169
+ /** Convert hash to hexadecimal string */
170
+ toString(encoding) {
171
+ if (encoding === Hex) {
172
+ return this.bytes.map(b => b.toString(16).padStart(2, '0')).join('');
173
+ }
174
+ // Default to hex if no encoding specified
175
+ return this.bytes.map(b => b.toString(16).padStart(2, '0')).join('');
176
+ }
177
+ }
178
+ /** Hex encoding object (mimics crypto-js enc.Hex) */
179
+ export const Hex = {
180
+ stringify: (bytes) => bytes.map(b => b.toString(16).padStart(2, '0')).join(''),
181
+ };
182
+ /**
183
+ * Compute SHA-256 hash of a string
184
+ * @param message - The message to hash
185
+ * @returns HashResult object with toString method
186
+ */
187
+ export function SHA256(message) {
188
+ const hash = sha256Raw(message);
189
+ return new HashResult(hash);
190
+ }
191
+ /** Encoding utilities (mimics crypto-js enc) */
192
+ export const enc = {
193
+ Hex,
194
+ };
195
+ //# sourceMappingURL=sha_256.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sha_256.js","sourceRoot":"","sources":["../../src/utils/sha_256.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,+BAA+B;AAE/B,qGAAqG;AACrG,MAAM,CAAC,GAAG;IACR,UAAU,EAA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AAG,SAAS,CAAC,OAAO,CAAC,CAAA;IAC/B,OAAO,IAAI,UAAU,CAAC,IAAI,CAAC,CAAA;AAC7B,CAAC;AAED,gDAAgD;AAChD,MAAM,CAAC,MAAM,GAAG,GAAG;IACjB,GAAG;CACJ,CAAA","sourcesContent":["/**\n * Pure JavaScript SHA-256 implementation\n * Conforms to the crypto-js API for drop-in replacement\n */\n\n/* eslint-disable no-bitwise */\n\n// SHA-256 constants (first 32 bits of the fractional parts of the cube roots of the first 64 primes)\nconst K = [\n 0x428a2f98, 0x71374491, 0xb5c0fbcf, 0xe9b5dba5, 0x3956c25b, 0x59f111f1, 0x923f82a4, 0xab1c5ed5,\n 0xd807aa98, 0x12835b01, 0x243185be, 0x550c7dc3, 0x72be5d74, 0x80deb1fe, 0x9bdc06a7, 0xc19bf174,\n 0xe49b69c1, 0xefbe4786, 0x0fc19dc6, 0x240ca1cc, 0x2de92c6f, 0x4a7484aa, 0x5cb0a9dc, 0x76f988da,\n 0x983e5152, 0xa831c66d, 0xb00327c8, 0xbf597fc7, 0xc6e00bf3, 0xd5a79147, 0x06ca6351, 0x14292967,\n 0x27b70a85, 0x2e1b2138, 0x4d2c6dfc, 0x53380d13, 0x650a7354, 0x766a0abb, 0x81c2c92e, 0x92722c85,\n 0xa2bfe8a1, 0xa81a664b, 0xc24b8b70, 0xc76c51a3, 0xd192e819, 0xd6990624, 0xf40e3585, 0x106aa070,\n 0x19a4c116, 0x1e376c08, 0x2748774c, 0x34b0bcb5, 0x391c0cb3, 0x4ed8aa4a, 0x5b9cca4f, 0x682e6ff3,\n 0x748f82ee, 0x78a5636f, 0x84c87814, 0x8cc70208, 0x90befffa, 0xa4506ceb, 0xbef9a3f7, 0xc67178f2,\n]\n\n// Initial hash values (first 32 bits of the fractional parts of the square roots of the first 8 primes)\nconst H = [\n 0x6a09e667, 0xbb67ae85, 0x3c6ef372, 0xa54ff53a, 0x510e527f, 0x9b05688c, 0x1f83d9ab, 0x5be0cd19,\n]\n\n/** Right rotate 32-bit integer */\nfunction rotr(n: number, x: number): number {\n return (x >>> n) | (x << (32 - n))\n}\n\n/** SHA-256 choice function */\nfunction ch(x: number, y: number, z: number): number {\n return (x & y) ^ (~x & z)\n}\n\n/** SHA-256 majority function */\nfunction maj(x: number, y: number, z: number): number {\n return (x & y) ^ (x & z) ^ (y & z)\n}\n\n/** SHA-256 Σ0 function */\nfunction sigma0(x: number): number {\n return rotr(2, x) ^ rotr(13, x) ^ rotr(22, x)\n}\n\n/** SHA-256 Σ1 function */\nfunction sigma1(x: number): number {\n return rotr(6, x) ^ rotr(11, x) ^ rotr(25, x)\n}\n\n/** SHA-256 σ0 function */\nfunction gamma0(x: number): number {\n return rotr(7, x) ^ rotr(18, x) ^ (x >>> 3)\n}\n\n/** SHA-256 σ1 function */\nfunction gamma1(x: number): number {\n return rotr(17, x) ^ rotr(19, x) ^ (x >>> 10)\n}\n\n/** Convert string to UTF-8 byte array */\nfunction stringToBytes(str: string): number[] {\n const bytes: number[] = []\n for (let i = 0; i < str.length; i++) {\n let charCode = str.charCodeAt(i)\n if (charCode < 0x80) {\n bytes.push(charCode)\n } else if (charCode < 0x800) {\n bytes.push(0xc0 | (charCode >> 6), 0x80 | (charCode & 0x3f))\n } else if (charCode < 0xd800 || charCode >= 0xe000) {\n bytes.push(0xe0 | (charCode >> 12), 0x80 | ((charCode >> 6) & 0x3f), 0x80 | (charCode & 0x3f))\n } else {\n // Surrogate pair\n i++\n charCode = 0x10000 + (((charCode & 0x3ff) << 10) | (str.charCodeAt(i) & 0x3ff))\n bytes.push(\n 0xf0 | (charCode >> 18),\n 0x80 | ((charCode >> 12) & 0x3f),\n 0x80 | ((charCode >> 6) & 0x3f),\n 0x80 | (charCode & 0x3f)\n )\n }\n }\n return bytes\n}\n\n/** Preprocess message: pad and convert to 512-bit blocks */\nfunction preprocessMessage(message: number[]): Uint32Array {\n const messageLength = message.length\n const bitLength = messageLength * 8\n\n // Append the '1' bit (plus zero padding to make 8 bits)\n message.push(0x80)\n\n // Append zeros until message length ≡ 448 (mod 512)\n // This leaves 64 bits for the length\n while (message.length % 64 !== 56) {\n message.push(0x00)\n }\n\n // Append original message length as 64-bit big-endian integer\n // JavaScript numbers are 53-bit safe, so we split into two 32-bit parts\n const lengthHigh = Math.floor(bitLength / 0x100000000)\n const lengthLow = bitLength >>> 0\n\n for (let i = 24; i >= 0; i -= 8) {\n message.push((lengthHigh >>> i) & 0xff)\n }\n for (let i = 24; i >= 0; i -= 8) {\n message.push((lengthLow >>> i) & 0xff)\n }\n\n // Convert byte array to 32-bit word array\n const words = new Uint32Array(message.length / 4)\n for (let i = 0; i < message.length; i += 4) {\n words[i / 4] =\n (message[i] << 24) | (message[i + 1] << 16) | (message[i + 2] << 8) | message[i + 3]\n }\n\n return words\n}\n\n/** Process a single 512-bit chunk */\nfunction processChunk(chunk: Uint32Array, hash: number[]): void {\n const W = new Uint32Array(64)\n\n // Prepare message schedule\n for (let t = 0; t < 16; t++) {\n W[t] = chunk[t]\n }\n for (let t = 16; t < 64; t++) {\n W[t] = (gamma1(W[t - 2]) + W[t - 7] + gamma0(W[t - 15]) + W[t - 16]) >>> 0\n }\n\n // Initialize working variables\n let a = hash[0]\n let b = hash[1]\n let c = hash[2]\n let d = hash[3]\n let e = hash[4]\n let f = hash[5]\n let g = hash[6]\n let h = hash[7]\n\n // Main loop\n for (let t = 0; t < 64; t++) {\n const T1 = (h + sigma1(e) + ch(e, f, g) + K[t] + W[t]) >>> 0\n const T2 = (sigma0(a) + maj(a, b, c)) >>> 0\n h = g\n g = f\n f = e\n e = (d + T1) >>> 0\n d = c\n c = b\n b = a\n a = (T1 + T2) >>> 0\n }\n\n // Add compressed chunk to current hash value\n hash[0] = (hash[0] + a) >>> 0\n hash[1] = (hash[1] + b) >>> 0\n hash[2] = (hash[2] + c) >>> 0\n hash[3] = (hash[3] + d) >>> 0\n hash[4] = (hash[4] + e) >>> 0\n hash[5] = (hash[5] + f) >>> 0\n hash[6] = (hash[6] + g) >>> 0\n hash[7] = (hash[7] + h) >>> 0\n}\n\n/** Compute SHA-256 hash and return as byte array */\nfunction sha256Raw(message: string): number[] {\n const bytes = stringToBytes(message)\n const preprocessed = preprocessMessage(bytes)\n const hash = [...H] // Copy initial hash values\n\n // Process each 512-bit chunk\n for (let i = 0; i < preprocessed.length; i += 16) {\n const chunk = preprocessed.subarray(i, i + 16)\n processChunk(chunk, hash)\n }\n\n // Convert hash to byte array\n const result: number[] = []\n for (let i = 0; i < 8; i++) {\n result.push((hash[i] >>> 24) & 0xff)\n result.push((hash[i] >>> 16) & 0xff)\n result.push((hash[i] >>> 8) & 0xff)\n result.push(hash[i] & 0xff)\n }\n\n return result\n}\n\n/** Hash result object with toString methods */\nclass HashResult {\n private bytes: number[]\n\n constructor(bytes: number[]) {\n this.bytes = bytes\n }\n\n /** Convert hash to hexadecimal string */\n toString(encoding?: { stringify: (bytes: number[]) => string }): string {\n if (encoding === Hex) {\n return this.bytes.map(b => b.toString(16).padStart(2, '0')).join('')\n }\n // Default to hex if no encoding specified\n return this.bytes.map(b => b.toString(16).padStart(2, '0')).join('')\n }\n}\n\n/** Hex encoding object (mimics crypto-js enc.Hex) */\nexport const Hex = {\n stringify: (bytes: number[]) => bytes.map(b => b.toString(16).padStart(2, '0')).join(''),\n}\n\n/**\n * Compute SHA-256 hash of a string\n * @param message - The message to hash\n * @returns HashResult object with toString method\n */\nexport function SHA256(message: string): HashResult {\n const hash = sha256Raw(message)\n return new HashResult(hash)\n}\n\n/** Encoding utilities (mimics crypto-js enc) */\nexport const enc = {\n Hex,\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@planningcenter/chat-react-native",
3
- "version": "3.20.1-rc.2",
3
+ "version": "3.20.1-rc.3",
4
4
  "description": "",
5
5
  "main": "build/index.js",
6
6
  "types": "build/index.d.ts",
@@ -58,5 +58,5 @@
58
58
  "react-native-url-polyfill": "^2.0.0",
59
59
  "typescript": "<5.6.0"
60
60
  },
61
- "gitHead": "4b05560e3db64829d1b96cf712b54b41b9201f25"
61
+ "gitHead": "7520f2d90eed9880665f5b10f74c99f2841dbf92"
62
62
  }
@@ -1,4 +1,5 @@
1
1
  import { renderHook } from '@testing-library/react-native'
2
+ import { QueryClient, QueryClientProvider } from '@tanstack/react-query'
2
3
  import { useTheme } from '../../hooks'
3
4
  import { ChatProvider, CreateChatThemeProps } from '../../contexts/chat_context'
4
5
  import React from 'react'
@@ -10,24 +11,47 @@ let themeProps: CreateChatThemeProps = {
10
11
  colorScheme: 'light',
11
12
  }
12
13
 
14
+ let queryClient: QueryClient
15
+
16
+ beforeEach(() => {
17
+ queryClient = new QueryClient({
18
+ defaultOptions: {
19
+ queries: {
20
+ retry: false,
21
+ refetchInterval: false, // Disable refetch intervals in tests
22
+ refetchOnWindowFocus: false,
23
+ refetchOnReconnect: false,
24
+ },
25
+ },
26
+ })
27
+ })
28
+
29
+ afterEach(() => {
30
+ queryClient.clear()
31
+ queryClient.cancelQueries()
32
+ queryClient.removeQueries()
33
+ })
34
+
13
35
  const Wrapper = ({ children }: { children: React.ReactNode }) => {
14
36
  return (
15
- <ChatProvider
16
- value={{
17
- token: {
18
- access_token: '',
19
- created_at: 0,
20
- expires_in: 0,
21
- scope: '',
22
- refresh_token: '',
23
- token_type: '',
24
- },
25
- onUnauthorizedResponse: () => {},
26
- theme: themeProps,
27
- }}
28
- >
29
- {children}
30
- </ChatProvider>
37
+ <QueryClientProvider client={queryClient}>
38
+ <ChatProvider
39
+ value={{
40
+ token: {
41
+ access_token: '',
42
+ created_at: 0,
43
+ expires_in: 0,
44
+ scope: '',
45
+ refresh_token: '',
46
+ token_type: '',
47
+ },
48
+ onUnauthorizedResponse: () => {},
49
+ theme: themeProps,
50
+ }}
51
+ >
52
+ {children}
53
+ </ChatProvider>
54
+ </QueryClientProvider>
31
55
  )
32
56
  }
33
57
 
@@ -1,10 +1,12 @@
1
1
  import { merge } from 'lodash'
2
2
  import React, { createContext, useMemo } from 'react'
3
3
  import { ColorSchemeName, useColorScheme } from 'react-native'
4
- import { DeepPartial } from '../types'
5
- import { ENV, OauthType, PartialToken, ResponseError, Session } from '../utils'
4
+ import { useQuery } from '@tanstack/react-query'
5
+ import { ApiResource, DeepPartial } from '../types'
6
+ import { Client, ENV, OauthType, PartialToken, ResponseError, Session, Uri } from '../utils'
6
7
  import { ChatTheme, defaultTheme, DefaultTheme } from '../utils/theme'
7
8
  import { AgeCheckContactInfo } from '../screens/age_check/screen_props'
9
+ import { ProductAnalyticsConfig } from '../types/product_analytics'
8
10
 
9
11
  export interface ChatProviderProps {
10
12
  env?: ENV
@@ -21,6 +23,7 @@ export interface ChatContextValue extends Omit<ChatProviderProps, 'theme'> {
21
23
  session: Session
22
24
  theme: ChatTheme
23
25
  onAgeDisqualification: (params: AgeCheckContactInfo) => void
26
+ productAnalyticsConfig: ProductAnalyticsConfig | undefined
24
27
  }
25
28
 
26
29
  export const ChatContext = createContext<ChatContextValue>({
@@ -32,6 +35,7 @@ export const ChatContext = createContext<ChatContextValue>({
32
35
  theme: defaultTheme('light'),
33
36
  token: undefined,
34
37
  edgeToEdge: true,
38
+ productAnalyticsConfig: undefined,
35
39
  })
36
40
 
37
41
  export function ChatProvider({ children, value }: { children: any; value: ChatProviderProps }) {
@@ -50,7 +54,9 @@ export function ChatProvider({ children, value }: { children: any; value: ChatPr
50
54
  [env, token, tokenType]
51
55
  )
52
56
 
57
+ const productAnalyticsConfig = useProductAnalyticsConfig(session)
53
58
  const contextValue: ChatContextValue = {
59
+ ...value,
54
60
  edgeToEdge,
55
61
  env,
56
62
  giphyApiKey,
@@ -59,6 +65,7 @@ export function ChatProvider({ children, value }: { children: any; value: ChatPr
59
65
  session,
60
66
  theme,
61
67
  token,
68
+ productAnalyticsConfig,
62
69
  }
63
70
 
64
71
  return <ChatContext.Provider value={contextValue}>{children}</ChatContext.Provider>
@@ -89,3 +96,53 @@ export const useCreateChatTheme = ({
89
96
 
90
97
  return theme
91
98
  }
99
+
100
+ interface ProductAnalyticsTokenResponse {
101
+ type: 'ProductAnalyticsToken'
102
+ id: string
103
+ url: string
104
+ metadata: Record<string, unknown>
105
+ }
106
+
107
+ // expiry time comes from here:
108
+ // https://github.com/planningcenter/pco-product-analytics/blob/e5bbc4c31b715b3c329c06a162829ee6967d3094/lib/pco/product/analytics/client_token_provider.rb#L24
109
+ const TOKEN_EXPIRY_TIME = 604800 * 1000 // 7 days in milliseconds
110
+
111
+ const useProductAnalyticsConfig = (session: Session): ProductAnalyticsConfig | undefined => {
112
+ const uri = useMemo(() => new Uri({ session }), [session])
113
+ const apiClient = useMemo(
114
+ () =>
115
+ new Client({
116
+ root: uri.api(`/chat/v2`),
117
+ defaultHeaders: uri.headers,
118
+ version: '2018-11-01',
119
+ }),
120
+ [uri]
121
+ )
122
+
123
+ const { data: config } = useQuery<ProductAnalyticsConfig>({
124
+ queryKey: ['product-analytics-token'],
125
+ queryFn: () =>
126
+ apiClient
127
+ .post<ApiResource<ProductAnalyticsTokenResponse>>({
128
+ url: '/me/product_analytics_authorize',
129
+ data: {
130
+ data: {
131
+ type: 'ProductAnalyticsToken',
132
+ attributes: {},
133
+ },
134
+ },
135
+ })
136
+ .then(res => ({
137
+ token: res.data.id,
138
+ endpoint: res.data.url,
139
+ metadata: res.data.metadata,
140
+ })),
141
+ staleTime: TOKEN_EXPIRY_TIME,
142
+ gcTime: TOKEN_EXPIRY_TIME,
143
+ refetchInterval: TOKEN_EXPIRY_TIME,
144
+ enabled: process.env.NODE_ENV !== 'test',
145
+ })
146
+
147
+ return config
148
+ }
@@ -18,3 +18,4 @@ export * from './use_qualified_by_age'
18
18
  export * from './use_scalable_number_of_lines'
19
19
  export * from './use_submit_age_check'
20
20
  export * from './use_organization'
21
+ export * from './use_product_analytics'