@propxchain/core-client 0.1.0-canary.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 (85) hide show
  1. package/README.md +115 -0
  2. package/dist/canisters/document_storage/document_storage.did.d.ts +7 -0
  3. package/dist/canisters/document_storage/document_storage.did.d.ts.map +1 -0
  4. package/dist/canisters/document_storage/document_storage.did.js +82 -0
  5. package/dist/canisters/document_storage/document_storage.did.js.map +1 -0
  6. package/dist/canisters/document_storage/index.d.ts +4 -0
  7. package/dist/canisters/document_storage/index.d.ts.map +1 -0
  8. package/dist/canisters/document_storage/index.js +2 -0
  9. package/dist/canisters/document_storage/index.js.map +1 -0
  10. package/dist/canisters/ledger_manager/index.d.ts +4 -0
  11. package/dist/canisters/ledger_manager/index.d.ts.map +1 -0
  12. package/dist/canisters/ledger_manager/index.js +2 -0
  13. package/dist/canisters/ledger_manager/index.js.map +1 -0
  14. package/dist/canisters/ledger_manager/ledger_manager.did.d.ts +7 -0
  15. package/dist/canisters/ledger_manager/ledger_manager.did.d.ts.map +1 -0
  16. package/dist/canisters/ledger_manager/ledger_manager.did.js +138 -0
  17. package/dist/canisters/ledger_manager/ledger_manager.did.js.map +1 -0
  18. package/dist/canisters/transaction_manager/index.d.ts +4 -0
  19. package/dist/canisters/transaction_manager/index.d.ts.map +1 -0
  20. package/dist/canisters/transaction_manager/index.js +2 -0
  21. package/dist/canisters/transaction_manager/index.js.map +1 -0
  22. package/dist/canisters/transaction_manager/transaction_manager.did.d.ts +7 -0
  23. package/dist/canisters/transaction_manager/transaction_manager.did.d.ts.map +1 -0
  24. package/dist/canisters/transaction_manager/transaction_manager.did.js +515 -0
  25. package/dist/canisters/transaction_manager/transaction_manager.did.js.map +1 -0
  26. package/dist/canisters/user_management/index.d.ts +4 -0
  27. package/dist/canisters/user_management/index.d.ts.map +1 -0
  28. package/dist/canisters/user_management/index.js +2 -0
  29. package/dist/canisters/user_management/index.js.map +1 -0
  30. package/dist/canisters/user_management/user_management.did.d.ts +7 -0
  31. package/dist/canisters/user_management/user_management.did.d.ts.map +1 -0
  32. package/dist/canisters/user_management/user_management.did.js +137 -0
  33. package/dist/canisters/user_management/user_management.did.js.map +1 -0
  34. package/dist/client.d.ts +13 -0
  35. package/dist/client.d.ts.map +1 -0
  36. package/dist/client.js +41 -0
  37. package/dist/client.js.map +1 -0
  38. package/dist/errors.d.ts +8 -0
  39. package/dist/errors.d.ts.map +1 -0
  40. package/dist/errors.js +22 -0
  41. package/dist/errors.js.map +1 -0
  42. package/dist/index.d.ts +7 -0
  43. package/dist/index.d.ts.map +1 -0
  44. package/dist/index.js +7 -0
  45. package/dist/index.js.map +1 -0
  46. package/dist/mock.d.ts +22 -0
  47. package/dist/mock.d.ts.map +1 -0
  48. package/dist/mock.js +94 -0
  49. package/dist/mock.js.map +1 -0
  50. package/dist/retry.d.ts +11 -0
  51. package/dist/retry.d.ts.map +1 -0
  52. package/dist/retry.js +22 -0
  53. package/dist/retry.js.map +1 -0
  54. package/dist/stubs.d.ts +34 -0
  55. package/dist/stubs.d.ts.map +1 -0
  56. package/dist/stubs.js +17 -0
  57. package/dist/stubs.js.map +1 -0
  58. package/dist/types.d.ts +30 -0
  59. package/dist/types.d.ts.map +1 -0
  60. package/dist/types.js +7 -0
  61. package/dist/types.js.map +1 -0
  62. package/package.json +58 -0
  63. package/src/canisters/document_storage/document_storage.did +89 -0
  64. package/src/canisters/document_storage/document_storage.did.d.ts +82 -0
  65. package/src/canisters/document_storage/document_storage.did.js +121 -0
  66. package/src/canisters/document_storage/index.ts +5 -0
  67. package/src/canisters/ledger_manager/index.ts +5 -0
  68. package/src/canisters/ledger_manager/ledger_manager.did +154 -0
  69. package/src/canisters/ledger_manager/ledger_manager.did.d.ts +139 -0
  70. package/src/canisters/ledger_manager/ledger_manager.did.js +181 -0
  71. package/src/canisters/transaction_manager/index.ts +5 -0
  72. package/src/canisters/transaction_manager/transaction_manager.did +599 -0
  73. package/src/canisters/transaction_manager/transaction_manager.did.d.ts +517 -0
  74. package/src/canisters/transaction_manager/transaction_manager.did.js +638 -0
  75. package/src/canisters/user_management/index.ts +5 -0
  76. package/src/canisters/user_management/user_management.did +147 -0
  77. package/src/canisters/user_management/user_management.did.d.ts +148 -0
  78. package/src/canisters/user_management/user_management.did.js +192 -0
  79. package/src/client.ts +77 -0
  80. package/src/errors.ts +31 -0
  81. package/src/index.ts +30 -0
  82. package/src/mock.ts +120 -0
  83. package/src/retry.ts +44 -0
  84. package/src/stubs.ts +60 -0
  85. package/src/types.ts +44 -0
@@ -0,0 +1,147 @@
1
+ type UserType =
2
+ variant {
3
+ admin;
4
+ assisted_buyer;
5
+ assisted_seller;
6
+ buyer;
7
+ conveyancer_managed;
8
+ conveyancer_transparent;
9
+ diy_buyer;
10
+ diy_seller;
11
+ estate_agent;
12
+ mortgage_broker;
13
+ platform_admin;
14
+ platform_support;
15
+ property_developer;
16
+ seller;
17
+ solicitor_client_linked;
18
+ solicitor_managed;
19
+ solicitor_platform_only;
20
+ solicitor_transparent;
21
+ };
22
+ type UserRole =
23
+ variant {
24
+ admin;
25
+ buyer;
26
+ guest;
27
+ seller;
28
+ solicitor;
29
+ };
30
+ type UserProfile =
31
+ record {
32
+ clientPrincipals: vec principal;
33
+ createdAt: Time;
34
+ email: text;
35
+ emailVerificationSentAt: opt Time;
36
+ emailVerificationToken: opt text;
37
+ emailVerified: bool;
38
+ isPlatformOnlySolicitor: bool;
39
+ isVerified: bool;
40
+ lawFirmAddress: opt text;
41
+ lawFirmName: opt text;
42
+ managedBySolicitor: opt principal;
43
+ mobile: text;
44
+ name: text;
45
+ "principal": principal;
46
+ role: opt UserRole;
47
+ solicitorLicenseNumber: opt text;
48
+ userType: UserType;
49
+ };
50
+ type TransactionProgress =
51
+ record {
52
+ blockingParties: vec principal;
53
+ completionPercentage: nat;
54
+ members: vec TransactionMember;
55
+ membersComplete: nat;
56
+ readyToExchange: bool;
57
+ totalMembers: nat;
58
+ transactionId: text;
59
+ };
60
+ type TransactionMember =
61
+ record {
62
+ canInviteOthers: bool;
63
+ canViewProgress: bool;
64
+ documentsComplete: bool;
65
+ joinedAt: Time;
66
+ lastActivityAt: Time;
67
+ "principal": principal;
68
+ requiredDocuments: vec text;
69
+ role: UserType;
70
+ transactionId: text;
71
+ uploadedDocuments: vec text;
72
+ };
73
+ type Time = int;
74
+ type Permission =
75
+ variant {
76
+ AdminManageUsers;
77
+ AdminViewAllTransactions;
78
+ InvitePartyToTransaction: text;
79
+ ManageClientAccess: principal;
80
+ UpdateMemberDocuments: record {
81
+ text;
82
+ principal;
83
+ };
84
+ ViewDevelopmentUnits: text;
85
+ ViewSharedTransaction: text;
86
+ ViewTransactionProgress: text;
87
+ };
88
+ type AuditLog =
89
+ record {
90
+ action: text;
91
+ actorPrincipal: principal;
92
+ id: nat;
93
+ metadata: text;
94
+ success: bool;
95
+ targetPrincipal: opt principal;
96
+ timestamp: Time;
97
+ transactionId: opt text;
98
+ };
99
+ service : {
100
+ addTransactionMember: (transactionId: text, memberPrincipal: principal,
101
+ role: UserType, canViewProgress: bool, canInviteOthers: bool, csrfToken:
102
+ text) -> (bool);
103
+ amIAdmin: () -> (bool) query;
104
+ bootstrapAdmin: (name: text, email: text) -> (bool);
105
+ canUserAccessTransaction: (user: principal, txId: text) -> (bool) query;
106
+ checkPermissionWithAudit: (permission: Permission) -> (bool);
107
+ createUserForPrincipal: (targetPrincipal: principal, name: text, email:
108
+ text, mobile: text, userTypeText: text, csrfToken: text) -> (bool);
109
+ deleteUserByPrincipal: (targetPrincipal: principal, csrfToken: text) ->
110
+ (bool);
111
+ generateCSRFToken: () -> (text);
112
+ getAllUsers: () -> (vec UserProfile) query;
113
+ getAuditLogs: (limit: nat) -> (vec AuditLog) query;
114
+ getCSRFToken: () -> (opt text) query;
115
+ getCycles: () -> (nat) query;
116
+ getMyManagingSolicitor: () -> (opt UserProfile) query;
117
+ getMyProfile: () -> (opt UserProfile) query;
118
+ getMyProfileUpdate: () -> (opt UserProfile);
119
+ getMySolicitorClients: () -> (vec UserProfile) query;
120
+ getTransactionMembers: (transactionId: text) ->
121
+ (opt vec TransactionMember) query;
122
+ getTransactionProgress: (transactionId: text) ->
123
+ (opt TransactionProgress) query;
124
+ getUserProfile: ("principal": principal) -> (opt UserProfile) query;
125
+ hasPermission: (permission: Permission) -> (bool) query;
126
+ initializeKnownAdmin: (name: text, email: text, mobile: text) -> (bool);
127
+ linkSolicitorToClient: (solicitorPrincipal: principal, consentGiven:
128
+ bool, csrfToken: text) -> (bool);
129
+ registerUser: (name: text, email: text, mobile: text, userType: text) ->
130
+ (bool);
131
+ registerUserV2: (name: text, email: text, mobile: text, userType: UserType,
132
+ solicitorLicenseNumber: opt text, lawFirmName: opt text, lawFirmAddress:
133
+ opt text, csrfToken: text) -> (bool);
134
+ resendVerificationEmail: (csrfToken: text) -> (bool);
135
+ revokeSolicitorAccess: (solicitorPrincipal: principal, csrfToken: text) ->
136
+ (bool);
137
+ updateMemberDocuments: (transactionId: text, uploadedDocumentName:
138
+ text, csrfToken: text) -> (bool);
139
+ updateTransactionMemberRequiredDocs: (transactionId: text,
140
+ documentsToRemove: vec text, csrfToken: text) -> (bool);
141
+ upgradeToAdmin: (targetPrincipal: principal, csrfToken: text) -> (bool);
142
+ validateAdmin: ("principal": principal) -> (bool) query;
143
+ validateCSRFToken: (token: text) -> (bool);
144
+ verifyEmail: (token: text, csrfToken: text) -> (bool);
145
+ verifyUser: (userPrincipal: principal, csrfToken: text) -> (bool);
146
+ whoAmI: () -> (principal) query;
147
+ }
@@ -0,0 +1,148 @@
1
+ import type { Principal } from '@dfinity/principal';
2
+ import type { ActorMethod } from '@dfinity/agent';
3
+ import type { IDL } from '@dfinity/candid';
4
+
5
+ export interface AuditLog {
6
+ 'id' : bigint,
7
+ 'action' : string,
8
+ 'metadata' : string,
9
+ 'targetPrincipal' : [] | [Principal],
10
+ 'timestamp' : Time,
11
+ 'success' : boolean,
12
+ 'actorPrincipal' : Principal,
13
+ 'transactionId' : [] | [string],
14
+ }
15
+ export type Permission = { 'ViewTransactionProgress' : string } |
16
+ { 'ViewSharedTransaction' : string } |
17
+ { 'ViewDevelopmentUnits' : string } |
18
+ { 'ManageClientAccess' : Principal } |
19
+ { 'InvitePartyToTransaction' : string } |
20
+ { 'AdminViewAllTransactions' : null } |
21
+ { 'AdminManageUsers' : null } |
22
+ { 'UpdateMemberDocuments' : [string, Principal] };
23
+ export type Time = bigint;
24
+ export interface TransactionMember {
25
+ 'uploadedDocuments' : Array<string>,
26
+ 'principal' : Principal,
27
+ 'requiredDocuments' : Array<string>,
28
+ 'joinedAt' : Time,
29
+ 'role' : UserType,
30
+ 'documentsComplete' : boolean,
31
+ 'canViewProgress' : boolean,
32
+ 'canInviteOthers' : boolean,
33
+ 'lastActivityAt' : Time,
34
+ 'transactionId' : string,
35
+ }
36
+ export interface TransactionProgress {
37
+ 'members' : Array<TransactionMember>,
38
+ 'completionPercentage' : bigint,
39
+ 'readyToExchange' : boolean,
40
+ 'membersComplete' : bigint,
41
+ 'totalMembers' : bigint,
42
+ 'blockingParties' : Array<Principal>,
43
+ 'transactionId' : string,
44
+ }
45
+ export interface UserProfile {
46
+ 'isPlatformOnlySolicitor' : boolean,
47
+ 'userType' : UserType,
48
+ 'principal' : Principal,
49
+ 'managedBySolicitor' : [] | [Principal],
50
+ 'emailVerified' : boolean,
51
+ 'name' : string,
52
+ 'createdAt' : Time,
53
+ 'role' : [] | [UserRole],
54
+ 'email' : string,
55
+ 'lawFirmName' : [] | [string],
56
+ 'isVerified' : boolean,
57
+ 'clientPrincipals' : Array<Principal>,
58
+ 'emailVerificationSentAt' : [] | [Time],
59
+ 'emailVerificationToken' : [] | [string],
60
+ 'mobile' : string,
61
+ 'solicitorLicenseNumber' : [] | [string],
62
+ 'lawFirmAddress' : [] | [string],
63
+ }
64
+ export type UserRole = { 'admin' : null } |
65
+ { 'solicitor' : null } |
66
+ { 'seller' : null } |
67
+ { 'guest' : null } |
68
+ { 'buyer' : null };
69
+ export type UserType = { 'solicitor_platform_only' : null } |
70
+ { 'admin' : null } |
71
+ { 'diy_buyer' : null } |
72
+ { 'solicitor_transparent' : null } |
73
+ { 'platform_admin' : null } |
74
+ { 'solicitor_client_linked' : null } |
75
+ { 'estate_agent' : null } |
76
+ { 'platform_support' : null } |
77
+ { 'mortgage_broker' : null } |
78
+ { 'seller' : null } |
79
+ { 'conveyancer_managed' : null } |
80
+ { 'diy_seller' : null } |
81
+ { 'assisted_seller' : null } |
82
+ { 'conveyancer_transparent' : null } |
83
+ { 'buyer' : null } |
84
+ { 'property_developer' : null } |
85
+ { 'solicitor_managed' : null } |
86
+ { 'assisted_buyer' : null };
87
+ export interface _SERVICE {
88
+ 'addTransactionMember' : ActorMethod<
89
+ [string, Principal, UserType, boolean, boolean, string],
90
+ boolean
91
+ >,
92
+ 'amIAdmin' : ActorMethod<[], boolean>,
93
+ 'bootstrapAdmin' : ActorMethod<[string, string], boolean>,
94
+ 'canUserAccessTransaction' : ActorMethod<[Principal, string], boolean>,
95
+ 'checkPermissionWithAudit' : ActorMethod<[Permission], boolean>,
96
+ 'createUserForPrincipal' : ActorMethod<
97
+ [Principal, string, string, string, string, string],
98
+ boolean
99
+ >,
100
+ 'deleteUserByPrincipal' : ActorMethod<[Principal, string], boolean>,
101
+ 'generateCSRFToken' : ActorMethod<[], string>,
102
+ 'getAllUsers' : ActorMethod<[], Array<UserProfile>>,
103
+ 'getAuditLogs' : ActorMethod<[bigint], Array<AuditLog>>,
104
+ 'getCSRFToken' : ActorMethod<[], [] | [string]>,
105
+ 'getCycles' : ActorMethod<[], bigint>,
106
+ 'getMyManagingSolicitor' : ActorMethod<[], [] | [UserProfile]>,
107
+ 'getMyProfile' : ActorMethod<[], [] | [UserProfile]>,
108
+ 'getMyProfileUpdate' : ActorMethod<[], [] | [UserProfile]>,
109
+ 'getMySolicitorClients' : ActorMethod<[], Array<UserProfile>>,
110
+ 'getTransactionMembers' : ActorMethod<
111
+ [string],
112
+ [] | [Array<TransactionMember>]
113
+ >,
114
+ 'getTransactionProgress' : ActorMethod<[string], [] | [TransactionProgress]>,
115
+ 'getUserProfile' : ActorMethod<[Principal], [] | [UserProfile]>,
116
+ 'hasPermission' : ActorMethod<[Permission], boolean>,
117
+ 'initializeKnownAdmin' : ActorMethod<[string, string, string], boolean>,
118
+ 'linkSolicitorToClient' : ActorMethod<[Principal, boolean, string], boolean>,
119
+ 'registerUser' : ActorMethod<[string, string, string, string], boolean>,
120
+ 'registerUserV2' : ActorMethod<
121
+ [
122
+ string,
123
+ string,
124
+ string,
125
+ UserType,
126
+ [] | [string],
127
+ [] | [string],
128
+ [] | [string],
129
+ string,
130
+ ],
131
+ boolean
132
+ >,
133
+ 'resendVerificationEmail' : ActorMethod<[string], boolean>,
134
+ 'revokeSolicitorAccess' : ActorMethod<[Principal, string], boolean>,
135
+ 'updateMemberDocuments' : ActorMethod<[string, string, string], boolean>,
136
+ 'updateTransactionMemberRequiredDocs' : ActorMethod<
137
+ [string, Array<string>, string],
138
+ boolean
139
+ >,
140
+ 'upgradeToAdmin' : ActorMethod<[Principal, string], boolean>,
141
+ 'validateAdmin' : ActorMethod<[Principal], boolean>,
142
+ 'validateCSRFToken' : ActorMethod<[string], boolean>,
143
+ 'verifyEmail' : ActorMethod<[string, string], boolean>,
144
+ 'verifyUser' : ActorMethod<[Principal, string], boolean>,
145
+ 'whoAmI' : ActorMethod<[], Principal>,
146
+ }
147
+ export declare const idlFactory: IDL.InterfaceFactory;
148
+ export declare const init: (args: { IDL: typeof IDL }) => IDL.Type[];
@@ -0,0 +1,192 @@
1
+ export const idlFactory = ({ IDL }) => {
2
+ const UserType = IDL.Variant({
3
+ 'solicitor_platform_only' : IDL.Null,
4
+ 'admin' : IDL.Null,
5
+ 'diy_buyer' : IDL.Null,
6
+ 'solicitor_transparent' : IDL.Null,
7
+ 'platform_admin' : IDL.Null,
8
+ 'solicitor_client_linked' : IDL.Null,
9
+ 'estate_agent' : IDL.Null,
10
+ 'platform_support' : IDL.Null,
11
+ 'mortgage_broker' : IDL.Null,
12
+ 'seller' : IDL.Null,
13
+ 'conveyancer_managed' : IDL.Null,
14
+ 'diy_seller' : IDL.Null,
15
+ 'assisted_seller' : IDL.Null,
16
+ 'conveyancer_transparent' : IDL.Null,
17
+ 'buyer' : IDL.Null,
18
+ 'property_developer' : IDL.Null,
19
+ 'solicitor_managed' : IDL.Null,
20
+ 'assisted_buyer' : IDL.Null,
21
+ });
22
+ const Permission = IDL.Variant({
23
+ 'ViewTransactionProgress' : IDL.Text,
24
+ 'ViewSharedTransaction' : IDL.Text,
25
+ 'ViewDevelopmentUnits' : IDL.Text,
26
+ 'ManageClientAccess' : IDL.Principal,
27
+ 'InvitePartyToTransaction' : IDL.Text,
28
+ 'AdminViewAllTransactions' : IDL.Null,
29
+ 'AdminManageUsers' : IDL.Null,
30
+ 'UpdateMemberDocuments' : IDL.Tuple(IDL.Text, IDL.Principal),
31
+ });
32
+ const Time = IDL.Int;
33
+ const UserRole = IDL.Variant({
34
+ 'admin' : IDL.Null,
35
+ 'solicitor' : IDL.Null,
36
+ 'seller' : IDL.Null,
37
+ 'guest' : IDL.Null,
38
+ 'buyer' : IDL.Null,
39
+ });
40
+ const UserProfile = IDL.Record({
41
+ 'isPlatformOnlySolicitor' : IDL.Bool,
42
+ 'userType' : UserType,
43
+ 'principal' : IDL.Principal,
44
+ 'managedBySolicitor' : IDL.Opt(IDL.Principal),
45
+ 'emailVerified' : IDL.Bool,
46
+ 'name' : IDL.Text,
47
+ 'createdAt' : Time,
48
+ 'role' : IDL.Opt(UserRole),
49
+ 'email' : IDL.Text,
50
+ 'lawFirmName' : IDL.Opt(IDL.Text),
51
+ 'isVerified' : IDL.Bool,
52
+ 'clientPrincipals' : IDL.Vec(IDL.Principal),
53
+ 'emailVerificationSentAt' : IDL.Opt(Time),
54
+ 'emailVerificationToken' : IDL.Opt(IDL.Text),
55
+ 'mobile' : IDL.Text,
56
+ 'solicitorLicenseNumber' : IDL.Opt(IDL.Text),
57
+ 'lawFirmAddress' : IDL.Opt(IDL.Text),
58
+ });
59
+ const AuditLog = IDL.Record({
60
+ 'id' : IDL.Nat,
61
+ 'action' : IDL.Text,
62
+ 'metadata' : IDL.Text,
63
+ 'targetPrincipal' : IDL.Opt(IDL.Principal),
64
+ 'timestamp' : Time,
65
+ 'success' : IDL.Bool,
66
+ 'actorPrincipal' : IDL.Principal,
67
+ 'transactionId' : IDL.Opt(IDL.Text),
68
+ });
69
+ const TransactionMember = IDL.Record({
70
+ 'uploadedDocuments' : IDL.Vec(IDL.Text),
71
+ 'principal' : IDL.Principal,
72
+ 'requiredDocuments' : IDL.Vec(IDL.Text),
73
+ 'joinedAt' : Time,
74
+ 'role' : UserType,
75
+ 'documentsComplete' : IDL.Bool,
76
+ 'canViewProgress' : IDL.Bool,
77
+ 'canInviteOthers' : IDL.Bool,
78
+ 'lastActivityAt' : Time,
79
+ 'transactionId' : IDL.Text,
80
+ });
81
+ const TransactionProgress = IDL.Record({
82
+ 'members' : IDL.Vec(TransactionMember),
83
+ 'completionPercentage' : IDL.Nat,
84
+ 'readyToExchange' : IDL.Bool,
85
+ 'membersComplete' : IDL.Nat,
86
+ 'totalMembers' : IDL.Nat,
87
+ 'blockingParties' : IDL.Vec(IDL.Principal),
88
+ 'transactionId' : IDL.Text,
89
+ });
90
+ return IDL.Service({
91
+ 'addTransactionMember' : IDL.Func(
92
+ [IDL.Text, IDL.Principal, UserType, IDL.Bool, IDL.Bool, IDL.Text],
93
+ [IDL.Bool],
94
+ [],
95
+ ),
96
+ 'amIAdmin' : IDL.Func([], [IDL.Bool], ['query']),
97
+ 'bootstrapAdmin' : IDL.Func([IDL.Text, IDL.Text], [IDL.Bool], []),
98
+ 'canUserAccessTransaction' : IDL.Func(
99
+ [IDL.Principal, IDL.Text],
100
+ [IDL.Bool],
101
+ ['query'],
102
+ ),
103
+ 'checkPermissionWithAudit' : IDL.Func([Permission], [IDL.Bool], []),
104
+ 'createUserForPrincipal' : IDL.Func(
105
+ [IDL.Principal, IDL.Text, IDL.Text, IDL.Text, IDL.Text, IDL.Text],
106
+ [IDL.Bool],
107
+ [],
108
+ ),
109
+ 'deleteUserByPrincipal' : IDL.Func(
110
+ [IDL.Principal, IDL.Text],
111
+ [IDL.Bool],
112
+ [],
113
+ ),
114
+ 'generateCSRFToken' : IDL.Func([], [IDL.Text], []),
115
+ 'getAllUsers' : IDL.Func([], [IDL.Vec(UserProfile)], ['query']),
116
+ 'getAuditLogs' : IDL.Func([IDL.Nat], [IDL.Vec(AuditLog)], ['query']),
117
+ 'getCSRFToken' : IDL.Func([], [IDL.Opt(IDL.Text)], ['query']),
118
+ 'getCycles' : IDL.Func([], [IDL.Nat], ['query']),
119
+ 'getMyManagingSolicitor' : IDL.Func([], [IDL.Opt(UserProfile)], ['query']),
120
+ 'getMyProfile' : IDL.Func([], [IDL.Opt(UserProfile)], ['query']),
121
+ 'getMyProfileUpdate' : IDL.Func([], [IDL.Opt(UserProfile)], []),
122
+ 'getMySolicitorClients' : IDL.Func([], [IDL.Vec(UserProfile)], ['query']),
123
+ 'getTransactionMembers' : IDL.Func(
124
+ [IDL.Text],
125
+ [IDL.Opt(IDL.Vec(TransactionMember))],
126
+ ['query'],
127
+ ),
128
+ 'getTransactionProgress' : IDL.Func(
129
+ [IDL.Text],
130
+ [IDL.Opt(TransactionProgress)],
131
+ ['query'],
132
+ ),
133
+ 'getUserProfile' : IDL.Func(
134
+ [IDL.Principal],
135
+ [IDL.Opt(UserProfile)],
136
+ ['query'],
137
+ ),
138
+ 'hasPermission' : IDL.Func([Permission], [IDL.Bool], ['query']),
139
+ 'initializeKnownAdmin' : IDL.Func(
140
+ [IDL.Text, IDL.Text, IDL.Text],
141
+ [IDL.Bool],
142
+ [],
143
+ ),
144
+ 'linkSolicitorToClient' : IDL.Func(
145
+ [IDL.Principal, IDL.Bool, IDL.Text],
146
+ [IDL.Bool],
147
+ [],
148
+ ),
149
+ 'registerUser' : IDL.Func(
150
+ [IDL.Text, IDL.Text, IDL.Text, IDL.Text],
151
+ [IDL.Bool],
152
+ [],
153
+ ),
154
+ 'registerUserV2' : IDL.Func(
155
+ [
156
+ IDL.Text,
157
+ IDL.Text,
158
+ IDL.Text,
159
+ UserType,
160
+ IDL.Opt(IDL.Text),
161
+ IDL.Opt(IDL.Text),
162
+ IDL.Opt(IDL.Text),
163
+ IDL.Text,
164
+ ],
165
+ [IDL.Bool],
166
+ [],
167
+ ),
168
+ 'resendVerificationEmail' : IDL.Func([IDL.Text], [IDL.Bool], []),
169
+ 'revokeSolicitorAccess' : IDL.Func(
170
+ [IDL.Principal, IDL.Text],
171
+ [IDL.Bool],
172
+ [],
173
+ ),
174
+ 'updateMemberDocuments' : IDL.Func(
175
+ [IDL.Text, IDL.Text, IDL.Text],
176
+ [IDL.Bool],
177
+ [],
178
+ ),
179
+ 'updateTransactionMemberRequiredDocs' : IDL.Func(
180
+ [IDL.Text, IDL.Vec(IDL.Text), IDL.Text],
181
+ [IDL.Bool],
182
+ [],
183
+ ),
184
+ 'upgradeToAdmin' : IDL.Func([IDL.Principal, IDL.Text], [IDL.Bool], []),
185
+ 'validateAdmin' : IDL.Func([IDL.Principal], [IDL.Bool], ['query']),
186
+ 'validateCSRFToken' : IDL.Func([IDL.Text], [IDL.Bool], []),
187
+ 'verifyEmail' : IDL.Func([IDL.Text, IDL.Text], [IDL.Bool], []),
188
+ 'verifyUser' : IDL.Func([IDL.Principal, IDL.Text], [IDL.Bool], []),
189
+ 'whoAmI' : IDL.Func([], [IDL.Principal], ['query']),
190
+ });
191
+ };
192
+ export const init = ({ IDL }) => { return []; };
package/src/client.ts ADDED
@@ -0,0 +1,77 @@
1
+ import { Actor, HttpAgent } from "@dfinity/agent";
2
+ import { idlFactory as transactionManagerIdl } from "./canisters/transaction_manager/index.js";
3
+ import { idlFactory as documentStorageIdl } from "./canisters/document_storage/index.js";
4
+ import { idlFactory as userManagementIdl } from "./canisters/user_management/index.js";
5
+ import { idlFactory as ledgerManagerIdl } from "./canisters/ledger_manager/index.js";
6
+ import type {
7
+ TransactionManagerService,
8
+ DocumentStorageService,
9
+ UserManagementService,
10
+ LedgerManagerService,
11
+ } from "./types.js";
12
+ import {
13
+ MAINNET_CANISTER_IDS,
14
+ type CanisterIds,
15
+ type PropXchainClientOptions,
16
+ type IPropXchainClient,
17
+ } from "./types.js";
18
+ import {
19
+ createAuditTrailStub,
20
+ createAgentHarnessStub,
21
+ type AuditTrailStub,
22
+ type AgentHarnessStub,
23
+ } from "./stubs.js";
24
+ import { wrapAgentError } from "./errors.js";
25
+
26
+ const DEFAULT_HOST = "https://icp-api.io";
27
+
28
+ export class PropXchainClient implements IPropXchainClient {
29
+ readonly transactionManager: TransactionManagerService;
30
+ readonly documentStorage: DocumentStorageService;
31
+ readonly userManagement: UserManagementService;
32
+ readonly ledgerManager: LedgerManagerService;
33
+ readonly auditTrail: AuditTrailStub;
34
+ readonly agentHarness: AgentHarnessStub;
35
+
36
+ constructor(options: PropXchainClientOptions = {}) {
37
+ const canisterIds: CanisterIds = {
38
+ ...MAINNET_CANISTER_IDS,
39
+ ...options.canisterIds,
40
+ };
41
+
42
+ const agent =
43
+ options.agent ??
44
+ HttpAgent.createSync({
45
+ host: options.host ?? DEFAULT_HOST,
46
+ identity: options.identity,
47
+ });
48
+
49
+ const isLocal = options.fetchRootKey ?? /127\.0\.0\.1|localhost/.test(
50
+ options.host ?? "",
51
+ );
52
+ if (isLocal) {
53
+ agent.fetchRootKey().catch((err) => {
54
+ throw wrapAgentError(err);
55
+ });
56
+ }
57
+
58
+ this.transactionManager = Actor.createActor<TransactionManagerService>(
59
+ transactionManagerIdl,
60
+ { agent, canisterId: canisterIds.transactionManager },
61
+ );
62
+ this.documentStorage = Actor.createActor<DocumentStorageService>(
63
+ documentStorageIdl,
64
+ { agent, canisterId: canisterIds.documentStorage },
65
+ );
66
+ this.userManagement = Actor.createActor<UserManagementService>(
67
+ userManagementIdl,
68
+ { agent, canisterId: canisterIds.userManagement },
69
+ );
70
+ this.ledgerManager = Actor.createActor<LedgerManagerService>(
71
+ ledgerManagerIdl,
72
+ { agent, canisterId: canisterIds.ledgerManager },
73
+ );
74
+ this.auditTrail = createAuditTrailStub();
75
+ this.agentHarness = createAgentHarnessStub();
76
+ }
77
+ }
package/src/errors.ts ADDED
@@ -0,0 +1,31 @@
1
+ export type CoreClientErrorCode =
2
+ | "NETWORK"
3
+ | "CANISTER_REJECT"
4
+ | "UNAUTHENTICATED"
5
+ | "TIMEOUT"
6
+ | "INVALID_ARGUMENT"
7
+ | "UNKNOWN";
8
+
9
+ export class CoreClientError extends Error {
10
+ readonly code: CoreClientErrorCode;
11
+ readonly cause?: unknown;
12
+
13
+ constructor(code: CoreClientErrorCode, message: string, cause?: unknown) {
14
+ super(message);
15
+ this.name = "CoreClientError";
16
+ this.code = code;
17
+ this.cause = cause;
18
+ }
19
+ }
20
+
21
+ export function wrapAgentError(err: unknown): CoreClientError {
22
+ if (err instanceof CoreClientError) return err;
23
+ const message = err instanceof Error ? err.message : String(err);
24
+ const code: CoreClientErrorCode =
25
+ /reject|trapped/i.test(message) ? "CANISTER_REJECT" :
26
+ /timeout|timed out/i.test(message) ? "TIMEOUT" :
27
+ /unauthoriz|unauthent|anonymous/i.test(message) ? "UNAUTHENTICATED" :
28
+ /network|fetch/i.test(message) ? "NETWORK" :
29
+ "UNKNOWN";
30
+ return new CoreClientError(code, message, err);
31
+ }
package/src/index.ts ADDED
@@ -0,0 +1,30 @@
1
+ export { PropXchainClient } from "./client.js";
2
+ export {
3
+ MockPropXchainClient,
4
+ isMockEnabled,
5
+ MOCK_ENV_FLAG,
6
+ } from "./mock.js";
7
+ export {
8
+ CoreClientError,
9
+ wrapAgentError,
10
+ type CoreClientErrorCode,
11
+ } from "./errors.js";
12
+ export { withRetry, type RetryOptions } from "./retry.js";
13
+ export {
14
+ createAuditTrailStub,
15
+ createAgentHarnessStub,
16
+ type AuditTrailStub,
17
+ type AgentHarnessStub,
18
+ type AuditEvent,
19
+ type AuditFilter,
20
+ } from "./stubs.js";
21
+ export {
22
+ MAINNET_CANISTER_IDS,
23
+ type CanisterIds,
24
+ type IPropXchainClient,
25
+ type PropXchainClientOptions,
26
+ type TransactionManagerService,
27
+ type DocumentStorageService,
28
+ type UserManagementService,
29
+ type LedgerManagerService,
30
+ } from "./types.js";