@bifold/react-hooks 0.6.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.
Files changed (35) hide show
  1. package/README.md +24 -0
  2. package/build/AgentProvider.d.ts +13 -0
  3. package/build/AgentProvider.js +77 -0
  4. package/build/AgentProvider.js.map +1 -0
  5. package/build/BasicMessageProvider.d.ts +12 -0
  6. package/build/BasicMessageProvider.js +83 -0
  7. package/build/BasicMessageProvider.js.map +1 -0
  8. package/build/ConnectionProvider.d.ts +24 -0
  9. package/build/ConnectionProvider.js +106 -0
  10. package/build/ConnectionProvider.js.map +1 -0
  11. package/build/CredentialFormatDataProvider.d.ts +19 -0
  12. package/build/CredentialFormatDataProvider.js +121 -0
  13. package/build/CredentialFormatDataProvider.js.map +1 -0
  14. package/build/CredentialProvider.d.ts +15 -0
  15. package/build/CredentialProvider.js +101 -0
  16. package/build/CredentialProvider.js.map +1 -0
  17. package/build/ExchangesProvider.d.ts +8 -0
  18. package/build/ExchangesProvider.js +76 -0
  19. package/build/ExchangesProvider.js.map +1 -0
  20. package/build/ProofFormatDataProvider.d.ts +19 -0
  21. package/build/ProofFormatDataProvider.js +119 -0
  22. package/build/ProofFormatDataProvider.js.map +1 -0
  23. package/build/ProofProvider.d.ts +15 -0
  24. package/build/ProofProvider.js +107 -0
  25. package/build/ProofProvider.js.map +1 -0
  26. package/build/QuestionAnswerProvider.d.ts +14 -0
  27. package/build/QuestionAnswerProvider.js +98 -0
  28. package/build/QuestionAnswerProvider.js.map +1 -0
  29. package/build/index.d.ts +14 -0
  30. package/build/index.js +71 -0
  31. package/build/index.js.map +1 -0
  32. package/build/recordUtils.d.ts +22 -0
  33. package/build/recordUtils.js +81 -0
  34. package/build/recordUtils.js.map +1 -0
  35. package/package.json +44 -0
@@ -0,0 +1,8 @@
1
+ import type { RecordsState } from './recordUtils';
2
+ import type { BaseRecord } from '@credo-ts/core';
3
+ import type { PropsWithChildren } from 'react';
4
+ import * as React from 'react';
5
+ export declare const useExchanges: () => RecordsState<BaseRecord<import("@credo-ts/core").TagsBase, import("@credo-ts/core").TagsBase, {}>> | undefined;
6
+ export declare const useExchangesByConnectionId: (connectionId: string) => BaseRecord[] | undefined;
7
+ declare const ExchangesProvider: React.FC<PropsWithChildren>;
8
+ export default ExchangesProvider;
@@ -0,0 +1,76 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.useExchangesByConnectionId = exports.useExchanges = void 0;
37
+ const react_1 = require("react");
38
+ const React = __importStar(require("react"));
39
+ const BasicMessageProvider_1 = require("./BasicMessageProvider");
40
+ const CredentialProvider_1 = require("./CredentialProvider");
41
+ const ProofProvider_1 = require("./ProofProvider");
42
+ const ExchangesContext = (0, react_1.createContext)(undefined);
43
+ const useExchanges = () => {
44
+ const exchangesContext = (0, react_1.useContext)(ExchangesContext);
45
+ if (!ExchangesContext) {
46
+ throw new Error('useExchanges must be used within a ExchangesContextProvider');
47
+ }
48
+ return exchangesContext;
49
+ };
50
+ exports.useExchanges = useExchanges;
51
+ const useExchangesByConnectionId = (connectionId) => {
52
+ const basicMessages = (0, BasicMessageProvider_1.useBasicMessagesByConnectionId)(connectionId);
53
+ const proofMessages = (0, ProofProvider_1.useProofsByConnectionId)(connectionId);
54
+ const credentialMessages = (0, CredentialProvider_1.useCredentialsByConnectionId)(connectionId);
55
+ return [...basicMessages, ...proofMessages, ...credentialMessages];
56
+ };
57
+ exports.useExchangesByConnectionId = useExchangesByConnectionId;
58
+ const ExchangesProvider = ({ children }) => {
59
+ const [state, setState] = (0, react_1.useState)({
60
+ records: [],
61
+ loading: true,
62
+ });
63
+ const { records: basicMessages } = (0, BasicMessageProvider_1.useBasicMessages)();
64
+ const { records: proofs } = (0, ProofProvider_1.useProofs)();
65
+ const { records: credentials } = (0, CredentialProvider_1.useCredentials)();
66
+ const setInitialState = (0, react_1.useCallback)(() => {
67
+ const records = [...basicMessages, ...proofs, ...credentials];
68
+ setState({ records, loading: false });
69
+ }, [basicMessages, proofs, credentials]);
70
+ (0, react_1.useEffect)(() => {
71
+ setInitialState();
72
+ }, [setInitialState]);
73
+ return React.createElement(ExchangesContext.Provider, { value: state }, children);
74
+ };
75
+ exports.default = ExchangesProvider;
76
+ //# sourceMappingURL=ExchangesProvider.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ExchangesProvider.js","sourceRoot":"","sources":["../src/ExchangesProvider.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAIA,iCAAmF;AACnF,6CAA8B;AAE9B,iEAAyF;AACzF,6DAAmF;AACnF,mDAAoE;AAEpE,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GAAG,MAAM,EAAE,GAAG,WAAW,CAAiB,CAAA;QAC7E,QAAQ,CAAC,EAAE,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC,CAAA;IACvC,CAAC,EAAE,CAAC,aAAa,EAAE,MAAM,EAAE,WAAW,CAAC,CAAC,CAAA;IAExC,IAAA,iBAAS,EAAC,GAAG,EAAE;QACb,eAAe,EAAE,CAAA;IACnB,CAAC,EAAE,CAAC,eAAe,CAAC,CAAC,CAAA;IAErB,OAAO,oBAAC,gBAAgB,CAAC,QAAQ,IAAC,KAAK,EAAE,KAAK,IAAG,QAAQ,CAA6B,CAAA;AACxF,CAAC,CAAA;AAED,kBAAe,iBAAiB,CAAA"}
@@ -0,0 +1,19 @@
1
+ import type { Agent } from '@credo-ts/core';
2
+ import type { Awaited } from '@credo-ts/core/build/types';
3
+ import type { PropsWithChildren } from 'react';
4
+ import * as React from 'react';
5
+ type FormatReturn = Awaited<ReturnType<Agent['proofs']['getFormatData']>>;
6
+ export type ProofFormatData = FormatReturn & {
7
+ id: string;
8
+ };
9
+ type FormattedProofDataState = {
10
+ formattedData: Array<ProofFormatData>;
11
+ loading: boolean;
12
+ };
13
+ export declare const useProofsFormatData: () => FormattedProofDataState;
14
+ export declare const useProofFormatDataById: (id: string) => ProofFormatData | undefined;
15
+ interface Props {
16
+ agent: Agent;
17
+ }
18
+ declare const ProofFormatDataProvider: React.FC<PropsWithChildren<Props>>;
19
+ export default ProofFormatDataProvider;
@@ -0,0 +1,119 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.useProofFormatDataById = exports.useProofsFormatData = void 0;
37
+ const core_1 = require("@credo-ts/core");
38
+ const react_1 = require("react");
39
+ const React = __importStar(require("react"));
40
+ const recordUtils_1 = require("./recordUtils");
41
+ const addRecord = (record, state) => {
42
+ const newRecordsState = [...state.formattedData];
43
+ newRecordsState.unshift(record);
44
+ return {
45
+ loading: state.loading,
46
+ formattedData: newRecordsState,
47
+ };
48
+ };
49
+ const updateRecord = (record, state) => {
50
+ const newRecordsState = [...state.formattedData];
51
+ const index = newRecordsState.findIndex((r) => r.id === record.id);
52
+ if (index > -1) {
53
+ newRecordsState[index] = record;
54
+ }
55
+ return {
56
+ loading: state.loading,
57
+ formattedData: newRecordsState,
58
+ };
59
+ };
60
+ const removeRecord = (record, state) => {
61
+ const newRecordsState = state.formattedData.filter((r) => r.id !== record.id);
62
+ return {
63
+ loading: state.loading,
64
+ formattedData: newRecordsState,
65
+ };
66
+ };
67
+ const ProofFormatDataContext = (0, react_1.createContext)(undefined);
68
+ const useProofsFormatData = () => {
69
+ const proofFormatDataContext = (0, react_1.useContext)(ProofFormatDataContext);
70
+ if (!proofFormatDataContext) {
71
+ throw new Error('useProofFormatData must be used within a ProofFormatDataContextProvider');
72
+ }
73
+ return proofFormatDataContext;
74
+ };
75
+ exports.useProofsFormatData = useProofsFormatData;
76
+ const useProofFormatDataById = (id) => {
77
+ const { formattedData } = (0, exports.useProofsFormatData)();
78
+ return formattedData.find((c) => c.id === id);
79
+ };
80
+ exports.useProofFormatDataById = useProofFormatDataById;
81
+ const ProofFormatDataProvider = ({ agent, children }) => {
82
+ const [state, setState] = (0, react_1.useState)({
83
+ formattedData: [],
84
+ loading: true,
85
+ });
86
+ const setInitialState = (0, react_1.useCallback)(async () => {
87
+ const records = await agent.proofs.getAll();
88
+ const formattedData = [];
89
+ for (const record of records) {
90
+ const formatData = await agent.proofs.getFormatData(record.id);
91
+ formattedData.push(Object.assign(Object.assign({}, formatData), { id: record.id }));
92
+ }
93
+ setState({ formattedData, loading: false });
94
+ }, [agent]);
95
+ (0, react_1.useEffect)(() => {
96
+ void setInitialState();
97
+ }, [setInitialState]);
98
+ (0, react_1.useEffect)(() => {
99
+ if (state.loading)
100
+ return;
101
+ const proofAdded$ = (0, recordUtils_1.recordsAddedByType)(agent, core_1.ProofExchangeRecord).subscribe(async (record) => {
102
+ const formatData = await agent.proofs.getFormatData(record.id);
103
+ setState(addRecord(Object.assign(Object.assign({}, formatData), { id: record.id }), state));
104
+ });
105
+ const proofUpdate$ = (0, recordUtils_1.recordsUpdatedByType)(agent, core_1.ProofExchangeRecord).subscribe(async (record) => {
106
+ const formatData = await agent.proofs.getFormatData(record.id);
107
+ setState(updateRecord(Object.assign(Object.assign({}, formatData), { id: record.id }), state));
108
+ });
109
+ const proofRemove$ = (0, recordUtils_1.recordsRemovedByType)(agent, core_1.ProofExchangeRecord).subscribe((record) => setState(removeRecord(record, state)));
110
+ return () => {
111
+ proofAdded$.unsubscribe();
112
+ proofUpdate$.unsubscribe();
113
+ proofRemove$.unsubscribe();
114
+ };
115
+ }, [state, agent]);
116
+ return React.createElement(ProofFormatDataContext.Provider, { value: state }, children);
117
+ };
118
+ exports.default = ProofFormatDataProvider;
119
+ //# sourceMappingURL=ProofFormatDataProvider.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ProofFormatDataProvider.js","sourceRoot":"","sources":["../src/ProofFormatDataProvider.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAIA,yCAAoD;AACpD,iCAAmF;AACnF,6CAA8B;AAE9B,+CAA8F;AAW9F,MAAM,SAAS,GAAG,CAAC,MAAuB,EAAE,KAA8B,EAA2B,EAAE;IACrG,MAAM,eAAe,GAAG,CAAC,GAAG,KAAK,CAAC,aAAa,CAAC,CAAA;IAChD,eAAe,CAAC,OAAO,CAAC,MAAM,CAAC,CAAA;IAE/B,OAAO;QACL,OAAO,EAAE,KAAK,CAAC,OAAO;QACtB,aAAa,EAAE,eAAe;KAC/B,CAAA;AACH,CAAC,CAAA;AAED,MAAM,YAAY,GAAG,CAAC,MAAuB,EAAE,KAA8B,EAA2B,EAAE;IACxG,MAAM,eAAe,GAAG,CAAC,GAAG,KAAK,CAAC,aAAa,CAAC,CAAA;IAChD,MAAM,KAAK,GAAG,eAAe,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,KAAK,MAAM,CAAC,EAAE,CAAC,CAAA;IAElE,IAAI,KAAK,GAAG,CAAC,CAAC,EAAE,CAAC;QACf,eAAe,CAAC,KAAK,CAAC,GAAG,MAAM,CAAA;IACjC,CAAC;IAED,OAAO;QACL,OAAO,EAAE,KAAK,CAAC,OAAO;QACtB,aAAa,EAAE,eAAe;KAC/B,CAAA;AACH,CAAC,CAAA;AAED,MAAM,YAAY,GAAG,CAAC,MAA2B,EAAE,KAA8B,EAA2B,EAAE;IAC5G,MAAM,eAAe,GAAG,KAAK,CAAC,aAAa,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,C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0BAAmB,CAAC,CAAC,SAAS,CAAC,CAAC,MAAM,EAAE,EAAE,CACzF,QAAQ,CAAC,YAAY,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC,CACtC,CAAA;QAED,OAAO,GAAG,EAAE;YACV,WAAW,CAAC,WAAW,EAAE,CAAA;YACzB,YAAY,CAAC,WAAW,EAAE,CAAA;YAC1B,YAAY,CAAC,WAAW,EAAE,CAAA;QAC5B,CAAC,CAAA;IACH,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC,CAAA;IAElB,OAAO,oBAAC,sBAAsB,CAAC,QAAQ,IAAC,KAAK,EAAE,KAAK,IAAG,QAAQ,CAAmC,CAAA;AACpG,CAAC,CAAA;AAED,kBAAe,uBAAuB,CAAA"}
@@ -0,0 +1,15 @@
1
+ import type { RecordsState } from './recordUtils';
2
+ import type { Agent, ProofState } from '@credo-ts/core';
3
+ import type { PropsWithChildren } from 'react';
4
+ import { ProofExchangeRecord } from '@credo-ts/core';
5
+ import * as React from 'react';
6
+ export declare const useProofs: () => RecordsState<ProofExchangeRecord>;
7
+ export declare const useProofsByConnectionId: (connectionId: string) => ProofExchangeRecord[];
8
+ export declare const useProofById: (id: string) => ProofExchangeRecord | undefined;
9
+ export declare const useProofByState: (state: ProofState | ProofState[]) => ProofExchangeRecord[];
10
+ export declare const useProofNotInState: (state: ProofState | ProofState[]) => ProofExchangeRecord[];
11
+ interface Props {
12
+ agent: Agent;
13
+ }
14
+ declare const ProofProvider: React.FC<PropsWithChildren<Props>>;
15
+ export default ProofProvider;
@@ -0,0 +1,107 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.useProofNotInState = exports.useProofByState = exports.useProofById = exports.useProofsByConnectionId = exports.useProofs = void 0;
37
+ const core_1 = require("@credo-ts/core");
38
+ const react_1 = require("react");
39
+ const React = __importStar(require("react"));
40
+ const recordUtils_1 = require("./recordUtils");
41
+ const ProofContext = (0, react_1.createContext)(undefined);
42
+ const useProofs = () => {
43
+ const proofContext = (0, react_1.useContext)(ProofContext);
44
+ if (!proofContext) {
45
+ throw new Error('useProofs must be used within a ProofContextProvider');
46
+ }
47
+ return proofContext;
48
+ };
49
+ exports.useProofs = useProofs;
50
+ const useProofsByConnectionId = (connectionId) => {
51
+ const { records: proofs } = (0, exports.useProofs)();
52
+ return (0, react_1.useMemo)(() => proofs.filter((proof) => proof.connectionId === connectionId), [proofs, connectionId]);
53
+ };
54
+ exports.useProofsByConnectionId = useProofsByConnectionId;
55
+ const useProofById = (id) => {
56
+ const { records: proofs } = (0, exports.useProofs)();
57
+ return proofs.find((p) => p.id === id);
58
+ };
59
+ exports.useProofById = useProofById;
60
+ const useProofByState = (state) => {
61
+ const states = (0, react_1.useMemo)(() => (typeof state === 'string' ? [state] : state), [state]);
62
+ const { records: proofs } = (0, exports.useProofs)();
63
+ const filteredProofs = (0, react_1.useMemo)(() => proofs.filter((r) => {
64
+ if (states.includes(r.state))
65
+ return r;
66
+ }), [proofs, states]);
67
+ return filteredProofs;
68
+ };
69
+ exports.useProofByState = useProofByState;
70
+ const useProofNotInState = (state) => {
71
+ const states = (0, react_1.useMemo)(() => (typeof state === 'string' ? [state] : state), [state]);
72
+ const { records: proofs } = (0, exports.useProofs)();
73
+ const filteredProofs = (0, react_1.useMemo)(() => proofs.filter((r) => {
74
+ if (!states.includes(r.state))
75
+ return r;
76
+ }), [proofs, states]);
77
+ return filteredProofs;
78
+ };
79
+ exports.useProofNotInState = useProofNotInState;
80
+ const ProofProvider = ({ agent, children }) => {
81
+ const [state, setState] = (0, react_1.useState)({
82
+ records: [],
83
+ loading: true,
84
+ });
85
+ const setInitialState = (0, react_1.useCallback)(async () => {
86
+ const records = await agent.proofs.getAll();
87
+ setState({ records, loading: false });
88
+ }, [agent]);
89
+ (0, react_1.useEffect)(() => {
90
+ setInitialState();
91
+ }, [setInitialState]);
92
+ (0, react_1.useEffect)(() => {
93
+ if (state.loading)
94
+ return;
95
+ const proofAdded$ = (0, recordUtils_1.recordsAddedByType)(agent, core_1.ProofExchangeRecord).subscribe((record) => setState((0, recordUtils_1.addRecord)(record, state)));
96
+ const proofUpdated$ = (0, recordUtils_1.recordsUpdatedByType)(agent, core_1.ProofExchangeRecord).subscribe((record) => setState((0, recordUtils_1.updateRecord)(record, state)));
97
+ const proofRemoved$ = (0, recordUtils_1.recordsRemovedByType)(agent, core_1.ProofExchangeRecord).subscribe((record) => setState((0, recordUtils_1.removeRecord)(record, state)));
98
+ return () => {
99
+ proofAdded$ === null || proofAdded$ === void 0 ? void 0 : proofAdded$.unsubscribe();
100
+ proofUpdated$ === null || proofUpdated$ === void 0 ? void 0 : proofUpdated$.unsubscribe();
101
+ proofRemoved$ === null || proofRemoved$ === void 0 ? void 0 : proofRemoved$.unsubscribe();
102
+ };
103
+ }, [state, agent]);
104
+ return React.createElement(ProofContext.Provider, { value: state }, children);
105
+ };
106
+ exports.default = ProofProvider;
107
+ //# sourceMappingURL=ProofProvider.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ProofProvider.js","sourceRoot":"","sources":["../src/ProofProvider.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAIA,yCAAoD;AACpD,iCAA4F;AAC5F,6CAA8B;AAE9B,+CAOsB;AAEtB,MAAM,YAAY,GAAG,IAAA,qBAAa,EAAgD,SAAS,CAAC,CAAA;AAErF,MAAM,SAAS,GAAG,GAAG,EAAE;IAC5B,MAAM,YAAY,GAAG,IAAA,kBAAU,EAAC,YAAY,CAAC,CAAA;IAC7C,IAAI,CAAC,YAAY,EAAE,CAAC;QAClB,MAAM,IAAI,KAAK,CAAC,sDAAsD,CAAC,CAAA;IACzE,CAAC;IACD,OAAO,YAAY,CAAA;AACrB,CAAC,CAAA;AANY,QAAA,SAAS,aAMrB;AAEM,MAAM,uBAAuB,GAAG,CAAC,YAAoB,EAAyB,EAAE;IACrF,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,GAAG,IAAA,iBAAS,GAAE,CAAA;IACvC,OAAO,IAAA,eAAO,EACZ,GAAG,EAAE,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,KAA0B,EAAE,EAAE,CAAC,KAAK,CAAC,YAAY,KAAK,YAAY,CAAC,EACxF,CAAC,MAAM,EAAE,YAAY,CAAC,CACvB,CAAA;AACH,CAAC,CAAA;AANY,QAAA,uBAAuB,2BAMnC;AAEM,MAAM,YAAY,GAAG,CAAC,EAAU,EAAmC,EAAE;IAC1E,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,GAAG,IAAA,iBAAS,GAAE,CAAA;IACvC,OAAO,MAAM,CAAC,IA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AC,CACtC,CAAA;QAED,MAAM,aAAa,GAAG,IAAA,kCAAoB,EAAC,KAAK,EAAE,0BAAmB,CAAC,CAAC,SAAS,CAAC,CAAC,MAAM,EAAE,EAAE,CAC1F,QAAQ,CAAC,IAAA,0BAAY,EAAC,MAAM,EAAE,KAAK,CAAC,CAAC,CACtC,CAAA;QAED,OAAO,GAAG,EAAE;YACV,WAAW,aAAX,WAAW,uBAAX,WAAW,CAAE,WAAW,EAAE,CAAA;YAC1B,aAAa,aAAb,aAAa,uBAAb,aAAa,CAAE,WAAW,EAAE,CAAA;YAC5B,aAAa,aAAb,aAAa,uBAAb,aAAa,CAAE,WAAW,EAAE,CAAA;QAC9B,CAAC,CAAA;IACH,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC,CAAA;IAElB,OAAO,oBAAC,YAAY,CAAC,QAAQ,IAAC,KAAK,EAAE,KAAK,IAAG,QAAQ,CAAyB,CAAA;AAChF,CAAC,CAAA;AAED,kBAAe,aAAa,CAAA"}
@@ -0,0 +1,14 @@
1
+ import type { Agent } from '@credo-ts/core';
2
+ import type { QuestionAnswerRecord } from '@credo-ts/question-answer';
3
+ import type { PropsWithChildren } from 'react';
4
+ import * as React from 'react';
5
+ export declare const useQuestionAnswer: () => {
6
+ questionAnswerMessages: QuestionAnswerRecord[];
7
+ };
8
+ export declare const useQuestionAnswerByConnectionId: (connectionId: string) => QuestionAnswerRecord[];
9
+ export declare const useQuestionAnswerById: (id: string) => QuestionAnswerRecord | undefined;
10
+ interface Props {
11
+ agent: Agent;
12
+ }
13
+ declare const QuestionAnswerProvider: React.FC<PropsWithChildren<Props>>;
14
+ export default QuestionAnswerProvider;
@@ -0,0 +1,98 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.useQuestionAnswerById = exports.useQuestionAnswerByConnectionId = exports.useQuestionAnswer = void 0;
37
+ const question_answer_1 = require("@credo-ts/question-answer");
38
+ const react_1 = require("react");
39
+ const React = __importStar(require("react"));
40
+ const QuestionAnswerContext = (0, react_1.createContext)(undefined);
41
+ const useQuestionAnswer = () => {
42
+ const questionAnswerContext = (0, react_1.useContext)(QuestionAnswerContext);
43
+ if (!questionAnswerContext) {
44
+ throw new Error('useQuestionAnswer must be used within a QuestionAnswerContextProvider');
45
+ }
46
+ return questionAnswerContext;
47
+ };
48
+ exports.useQuestionAnswer = useQuestionAnswer;
49
+ const useQuestionAnswerByConnectionId = (connectionId) => {
50
+ const { questionAnswerMessages } = (0, exports.useQuestionAnswer)();
51
+ const messages = (0, react_1.useMemo)(() => questionAnswerMessages.filter((m) => m.connectionId === connectionId), [questionAnswerMessages, connectionId]);
52
+ return messages;
53
+ };
54
+ exports.useQuestionAnswerByConnectionId = useQuestionAnswerByConnectionId;
55
+ const useQuestionAnswerById = (id) => {
56
+ const { questionAnswerMessages } = (0, exports.useQuestionAnswer)();
57
+ return questionAnswerMessages.find((c) => c.id === id);
58
+ };
59
+ exports.useQuestionAnswerById = useQuestionAnswerById;
60
+ const QuestionAnswerProvider = ({ agent, children }) => {
61
+ const [questionAnswerState, setQuestionAnswerState] = (0, react_1.useState)({
62
+ questionAnswerMessages: [],
63
+ loading: true,
64
+ });
65
+ const setInitialState = (0, react_1.useCallback)(async () => {
66
+ const questAnswerApi = agent.dependencyManager.resolve(question_answer_1.QuestionAnswerApi);
67
+ const questionAnswerMessages = await questAnswerApi.getAll();
68
+ setQuestionAnswerState({ questionAnswerMessages, loading: false });
69
+ }, [agent]);
70
+ (0, react_1.useEffect)(() => {
71
+ setInitialState();
72
+ }, [setInitialState]);
73
+ (0, react_1.useEffect)(() => {
74
+ if (questionAnswerState.loading)
75
+ return;
76
+ const listener = (event) => {
77
+ const newQuestionAnswerState = [...questionAnswerState.questionAnswerMessages];
78
+ const index = newQuestionAnswerState.findIndex((questionAnswerMessage) => questionAnswerMessage.id === event.payload.questionAnswerRecord.id);
79
+ if (index > -1) {
80
+ newQuestionAnswerState[index] = event.payload.questionAnswerRecord;
81
+ }
82
+ else {
83
+ newQuestionAnswerState.unshift(event.payload.questionAnswerRecord);
84
+ }
85
+ setQuestionAnswerState({
86
+ loading: questionAnswerState.loading,
87
+ questionAnswerMessages: newQuestionAnswerState,
88
+ });
89
+ };
90
+ agent.events.on(question_answer_1.QuestionAnswerEventTypes.QuestionAnswerStateChanged, listener);
91
+ return () => {
92
+ agent.events.off(question_answer_1.QuestionAnswerEventTypes.QuestionAnswerStateChanged, listener);
93
+ };
94
+ }, [questionAnswerState, agent]);
95
+ return React.createElement(QuestionAnswerContext.Provider, { value: questionAnswerState }, children);
96
+ };
97
+ exports.default = QuestionAnswerProvider;
98
+ //# s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AK,CAAC,OAAO,CAAC,oBAAoB,CAAC,CAAA;YACpE,CAAC;YAED,sBAAsB,CAAC;gBACrB,OAAO,EAAE,mBAAmB,CAAC,OAAO;gBACpC,sBAAsB,EAAE,sBAAsB;aAC/C,CAAC,CAAA;QACJ,CAAC,CAAA;QAED,KAAK,CAAC,MAAM,CAAC,EAAE,CAAC,0CAAwB,CAAC,0BAA0B,EAAE,QAAQ,CAAC,CAAA;QAE9E,OAAO,GAAG,EAAE;YACV,KAAK,CAAC,MAAM,CAAC,GAAG,CAAC,0CAAwB,CAAC,0BAA0B,EAAE,QAAQ,CAAC,CAAA;QACjF,CAAC,CAAA;IACH,CAAC,EAAE,CAAC,mBAAmB,EAAE,KAAK,CAAC,CAAC,CAAA;IAEhC,OAAO,oBAAC,qBAAqB,CAAC,QAAQ,IAAC,KAAK,EAAE,mBAAmB,IAAG,QAAQ,CAAkC,CAAA;AAChH,CAAC,CAAA;AAED,kBAAe,sBAAsB,CAAA"}
@@ -0,0 +1,14 @@
1
+ import type { CredentialFormatData } from './CredentialFormatDataProvider';
2
+ import type { ProofFormatData } from './ProofFormatDataProvider';
3
+ import AgentProvider, { useAgent } from './AgentProvider';
4
+ import { useBasicMessages, useBasicMessagesByConnectionId } from './BasicMessageProvider';
5
+ import { useConnections, useConnectionById } from './ConnectionProvider';
6
+ import { useCredentialsFormatData, useCredentialFormatDataById } from './CredentialFormatDataProvider';
7
+ import { useCredentials, useCredentialById, useCredentialByState, useCredentialNotInState, useCredentialsByConnectionId } from './CredentialProvider';
8
+ import { useExchanges, useExchangesByConnectionId } from './ExchangesProvider';
9
+ import { useProofsFormatData, useProofFormatDataById } from './ProofFormatDataProvider';
10
+ import { useProofs, useProofById, useProofByState, useProofNotInState, useProofsByConnectionId } from './ProofProvider';
11
+ import { useQuestionAnswer, useQuestionAnswerByConnectionId, useQuestionAnswerById } from './QuestionAnswerProvider';
12
+ export type { ProofFormatData, CredentialFormatData };
13
+ export { useAgent, useBasicMessages, useBasicMessagesByConnectionId, useConnections, useConnectionById, useCredentials, useCredentialById, useCredentialByState, useCredentialNotInState, useCredentialsByConnectionId, useProofs, useProofById, useProofByState, useProofNotInState, useQuestionAnswer, useQuestionAnswerByConnectionId, useQuestionAnswerById, useExchanges, useExchangesByConnectionId, useProofsByConnectionId, useProofsFormatData, useProofFormatDataById, useCredentialFormatDataById, useCredentialsFormatData, };
14
+ export default AgentProvider;
package/build/index.js ADDED
@@ -0,0 +1,71 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.useCredentialsFormatData = exports.useCredentialFormatDataById = exports.useProofFormatDataById = exports.useProofsFormatData = exports.useProofsByConnectionId = exports.useExchangesByConnectionId = exports.useExchanges = exports.useQuestionAnswerById = exports.useQuestionAnswerByConnectionId = exports.useQuestionAnswer = exports.useProofNotInState = exports.useProofByState = exports.useProofById = exports.useProofs = exports.useCredentialsByConnectionId = exports.useCredentialNotInState = exports.useCredentialByState = exports.useCredentialById = exports.useCredentials = exports.useConnectionById = exports.useConnections = exports.useBasicMessagesByConnectionId = exports.useBasicMessages = exports.useAgent = void 0;
37
+ const AgentProvider_1 = __importStar(require("./AgentProvider"));
38
+ Object.defineProperty(exports, "useAgent", { enumerable: true, get: function () { return AgentProvider_1.useAgent; } });
39
+ const BasicMessageProvider_1 = require("./BasicMessageProvider");
40
+ Object.defineProperty(exports, "useBasicMessages", { enumerable: true, get: function () { return BasicMessageProvider_1.useBasicMessages; } });
41
+ Object.defineProperty(exports, "useBasicMessagesByConnectionId", { enumerable: true, get: function () { return BasicMessageProvider_1.useBasicMessagesByConnectionId; } });
42
+ const ConnectionProvider_1 = require("./ConnectionProvider");
43
+ Object.defineProperty(exports, "useConnections", { enumerable: true, get: function () { return ConnectionProvider_1.useConnections; } });
44
+ Object.defineProperty(exports, "useConnectionById", { enumerable: true, get: function () { return ConnectionProvider_1.useConnectionById; } });
45
+ const CredentialFormatDataProvider_1 = require("./CredentialFormatDataProvider");
46
+ Object.defineProperty(exports, "useCredentialsFormatData", { enumerable: true, get: function () { return CredentialFormatDataProvider_1.useCredentialsFormatData; } });
47
+ Object.defineProperty(exports, "useCredentialFormatDataById", { enumerable: true, get: function () { return CredentialFormatDataProvider_1.useCredentialFormatDataById; } });
48
+ const CredentialProvider_1 = require("./CredentialProvider");
49
+ Object.defineProperty(exports, "useCredentials", { enumerable: true, get: function () { return CredentialProvider_1.useCredentials; } });
50
+ Object.defineProperty(exports, "useCredentialById", { enumerable: true, get: function () { return CredentialProvider_1.useCredentialById; } });
51
+ Object.defineProperty(exports, "useCredentialByState", { enumerable: true, get: function () { return CredentialProvider_1.useCredentialByState; } });
52
+ Object.defineProperty(exports, "useCredentialNotInState", { enumerable: true, get: function () { return CredentialProvider_1.useCredentialNotInState; } });
53
+ Object.defineProperty(exports, "useCredentialsByConnectionId", { enumerable: true, get: function () { return CredentialProvider_1.useCredentialsByConnectionId; } });
54
+ const ExchangesProvider_1 = require("./ExchangesProvider");
55
+ Object.defineProperty(exports, "useExchanges", { enumerable: true, get: function () { return ExchangesProvider_1.useExchanges; } });
56
+ Object.defineProperty(exports, "useExchangesByConnectionId", { enumerable: true, get: function () { return ExchangesProvider_1.useExchangesByConnectionId; } });
57
+ const ProofFormatDataProvider_1 = require("./ProofFormatDataProvider");
58
+ Object.defineProperty(exports, "useProofsFormatData", { enumerable: true, get: function () { return ProofFormatDataProvider_1.useProofsFormatData; } });
59
+ Object.defineProperty(exports, "useProofFormatDataById", { enumerable: true, get: function () { return ProofFormatDataProvider_1.useProofFormatDataById; } });
60
+ const ProofProvider_1 = require("./ProofProvider");
61
+ Object.defineProperty(exports, "useProofs", { enumerable: true, get: function () { return ProofProvider_1.useProofs; } });
62
+ Object.defineProperty(exports, "useProofById", { enumerable: true, get: function () { return ProofProvider_1.useProofById; } });
63
+ Object.defineProperty(exports, "useProofByState", { enumerable: true, get: function () { return ProofProvider_1.useProofByState; } });
64
+ Object.defineProperty(exports, "useProofNotInState", { enumerable: true, get: function () { return ProofProvider_1.useProofNotInState; } });
65
+ Object.defineProperty(exports, "useProofsByConnectionId", { enumerable: true, get: function () { return ProofProvider_1.useProofsByConnectionId; } });
66
+ const QuestionAnswerProvider_1 = require("./QuestionAnswerProvider");
67
+ Object.defineProperty(exports, "useQuestionAnswer", { enumerable: true, get: function () { return QuestionAnswerProvider_1.useQuestionAnswer; } });
68
+ Object.defineProperty(exports, "useQuestionAnswerByConnectionId", { enumerable: true, get: function () { return QuestionAnswerProvider_1.useQuestionAnswerByConnectionId; } });
69
+ Object.defineProperty(exports, "useQuestionAnswerById", { enumerable: true, get: function () { return QuestionAnswerProvider_1.useQuestionAnswerById; } });
70
+ exports.default = AgentProvider_1.default;
71
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAGA,iEAAyD;AAmBvD,yFAnBsB,wBAAQ,OAmBtB;AAlBV,iEAAyF;AAmBvF,iGAnBO,uCAAgB,OAmBP;AAChB,+GApByB,qDAA8B,OAoBzB;AAnBhC,6DAAwE;AAoBtE,+FApBO,mCAAc,OAoBP;AACd,kGArBuB,sCAAiB,OAqBvB;AApBnB,iFAAsG;AAuCpG,yGAvCO,uDAAwB,OAuCP;AADxB,4GAtCiC,0DAA2B,OAsCjC;AArC7B,6DAM6B;AAc3B,+FAnBA,mCAAc,OAmBA;AACd,kGAnBA,sCAAiB,OAmBA;AACjB,qGAnBA,yCAAoB,OAmBA;AACpB,wGAnBA,4CAAuB,OAmBA;AACvB,6GAnBA,iDAA4B,OAmBA;AAjB9B,2DAA8E;AAyB5E,6FAzBO,gCAAY,OAyBP;AACZ,2GA1BqB,8CAA0B,OA0BrB;AAzB5B,uEAAuF;AA2BrF,oGA3BO,6CAAmB,OA2BP;AACnB,uGA5B4B,gDAAsB,OA4B5B;AA3BxB,mDAAuH;AAgBrH,0FAhBO,yBAAS,OAgBP;AACT,6FAjBkB,4BAAY,OAiBlB;AACZ,gGAlBgC,+BAAe,OAkBhC;AACf,mGAnBiD,kCAAkB,OAmBjD;AAMlB,wGAzBqE,uCAAuB,OAyBrE;AAxBzB,qEAAoH;AAmBlH,kGAnBO,0CAAiB,OAmBP;AACjB,gHApB0B,wDAA+B,OAoB1B;AAC/B,sGArB2D,8CAAqB,OAqB3D;AAUvB,kBAAe,uBAAa,CAAA"}
@@ -0,0 +1,22 @@
1
+ import type { BaseRecord, Agent } from '@credo-ts/core';
2
+ import type { Constructor } from '@credo-ts/core/build/utils/mixins';
3
+ export type BaseRecordAny = BaseRecord<any, any, any>;
4
+ type RecordClass<R extends BaseRecordAny> = Constructor<R> & {
5
+ type: string;
6
+ };
7
+ export interface RecordsState<R extends BaseRecordAny> {
8
+ loading: boolean;
9
+ records: R[];
10
+ }
11
+ export declare const addRecord: <R extends BaseRecordAny>(record: R, state: RecordsState<R>) => RecordsState<R>;
12
+ export declare const updateRecord: <R extends BaseRecordAny>(record: R, state: RecordsState<R>) => RecordsState<R>;
13
+ export declare const removeRecord: <R extends BaseRecordAny>(record: R | {
14
+ id: string;
15
+ type: R["type"];
16
+ }, state: RecordsState<R>) => RecordsState<R>;
17
+ export declare const recordsAddedByType: <R extends BaseRecordAny>(agent: Agent | undefined, recordClass: RecordClass<R>) => import("rxjs").Observable<R>;
18
+ export declare const recordsUpdatedByType: <R extends BaseRecordAny>(agent: Agent | undefined, recordClass: RecordClass<R>) => import("rxjs").Observable<R>;
19
+ export declare const recordsRemovedByType: <R extends BaseRecordAny>(agent: Agent | undefined, recordClass: RecordClass<R>) => import("rxjs").Observable<R>;
20
+ export declare const isModuleRegistered: (agent: Agent, ModuleClass: Constructor) => boolean;
21
+ export declare const useIsModuleRegistered: (agent: Agent, ModuleClass: Constructor) => boolean;
22
+ export {};