@idos-network/kwil-infra 3.0.1 → 5.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +42 -0
- package/README.md +1 -46
- package/dist/actions/index.d.mts +2 -2
- package/dist/actions/index.mjs +1 -1
- package/dist/actions/index.mjs.map +1 -1
- package/dist/{index-Bk8YCFlx.d.mts → index-Dc_rffi1.d.mts} +149 -69
- package/dist/index-Dc_rffi1.d.mts.map +1 -0
- package/dist/index.d.mts +2 -2
- package/dist/index.mjs +1 -1
- package/dist/index.mjs.map +1 -1
- package/dist/signature-verification/index.d.mts +1 -1
- package/package.json +2 -2
- package/src/actions/actions.test.ts +23 -5
- package/src/actions/actions.ts +389 -42
- package/src/create-kgw-authenticated-fetch.test.ts +46 -26
- package/src/create-kgw-authenticated-fetch.ts +14 -18
- package/src/create-kwil-client.test.ts +40 -0
- package/src/create-kwil-client.ts +25 -0
- package/src/create-kwil-signer.test.ts +2 -67
- package/src/create-kwil-signer.ts +2 -27
- package/src/index.ts +0 -1
- package/dist/index-Bk8YCFlx.d.mts.map +0 -1
- package/src/mm-token/create-mm-token-kwil-signer.test.ts +0 -148
- package/src/mm-token/create-mm-token-kwil-signer.ts +0 -166
package/src/actions/actions.ts
CHANGED
|
@@ -12,6 +12,11 @@ export const WALLET_TYPES = ["EVM", "NEAR", "XRPL", "Stellar", "FaceSign", "MM"]
|
|
|
12
12
|
export type WalletType = (typeof WALLET_TYPES)[number];
|
|
13
13
|
|
|
14
14
|
export const walletTypeSchema: z.ZodType<WalletType> = z.enum(WALLET_TYPES);
|
|
15
|
+
export const ADD_WALLET_TYPES = ["EVM", "NEAR", "XRPL", "Stellar", "FaceSign"] as const;
|
|
16
|
+
|
|
17
|
+
export type AddWalletType = (typeof ADD_WALLET_TYPES)[number];
|
|
18
|
+
|
|
19
|
+
export const addWalletTypeSchema: z.ZodType<AddWalletType> = z.enum(ADD_WALLET_TYPES);
|
|
15
20
|
export const ENCRYPTION_PASSWORD_STORES = ["user", "mpc", "mm"] as const;
|
|
16
21
|
|
|
17
22
|
export type EncryptionPasswordStore = (typeof ENCRYPTION_PASSWORD_STORES)[number];
|
|
@@ -165,6 +170,20 @@ export const actionSchema: Record<string, ActionSchemaElement[]> = {
|
|
|
165
170
|
type: DataType.Uuid,
|
|
166
171
|
},
|
|
167
172
|
],
|
|
173
|
+
credential_broader_message: [
|
|
174
|
+
{
|
|
175
|
+
name: "public_notes_signature",
|
|
176
|
+
type: DataType.Text,
|
|
177
|
+
},
|
|
178
|
+
{
|
|
179
|
+
name: "content_uri",
|
|
180
|
+
type: DataType.Text,
|
|
181
|
+
},
|
|
182
|
+
{
|
|
183
|
+
name: "recipient_wallet",
|
|
184
|
+
type: DataType.Text,
|
|
185
|
+
},
|
|
186
|
+
],
|
|
168
187
|
create_preliminary_credential: [
|
|
169
188
|
{
|
|
170
189
|
name: "request_id",
|
|
@@ -416,6 +435,100 @@ export const actionSchema: Record<string, ActionSchemaElement[]> = {
|
|
|
416
435
|
type: DataType.Text,
|
|
417
436
|
},
|
|
418
437
|
],
|
|
438
|
+
get_user_as_mm_operator: [
|
|
439
|
+
{
|
|
440
|
+
name: "storage_token",
|
|
441
|
+
type: DataType.Text,
|
|
442
|
+
},
|
|
443
|
+
],
|
|
444
|
+
create_user_as_mm_operator: [
|
|
445
|
+
{
|
|
446
|
+
name: "id",
|
|
447
|
+
type: DataType.Uuid,
|
|
448
|
+
},
|
|
449
|
+
{
|
|
450
|
+
name: "recipient_encryption_public_key",
|
|
451
|
+
type: DataType.Text,
|
|
452
|
+
},
|
|
453
|
+
{
|
|
454
|
+
name: "wallet_id",
|
|
455
|
+
type: DataType.Uuid,
|
|
456
|
+
},
|
|
457
|
+
{
|
|
458
|
+
name: "storage_token",
|
|
459
|
+
type: DataType.Text,
|
|
460
|
+
},
|
|
461
|
+
],
|
|
462
|
+
get_credentials_as_mm_operator: [
|
|
463
|
+
{
|
|
464
|
+
name: "user_id",
|
|
465
|
+
type: DataType.Uuid,
|
|
466
|
+
},
|
|
467
|
+
{
|
|
468
|
+
name: "storage_token",
|
|
469
|
+
type: DataType.Text,
|
|
470
|
+
},
|
|
471
|
+
],
|
|
472
|
+
create_preliminary_credential_as_mm_operator: [
|
|
473
|
+
{
|
|
474
|
+
name: "request_id",
|
|
475
|
+
type: DataType.Uuid,
|
|
476
|
+
},
|
|
477
|
+
{
|
|
478
|
+
name: "user_id",
|
|
479
|
+
type: DataType.Uuid,
|
|
480
|
+
},
|
|
481
|
+
{
|
|
482
|
+
name: "credential_id",
|
|
483
|
+
type: DataType.Uuid,
|
|
484
|
+
},
|
|
485
|
+
{
|
|
486
|
+
name: "issuer_auth_public_key",
|
|
487
|
+
type: DataType.Text,
|
|
488
|
+
},
|
|
489
|
+
{
|
|
490
|
+
name: "encryptor_public_key",
|
|
491
|
+
type: DataType.Text,
|
|
492
|
+
},
|
|
493
|
+
{
|
|
494
|
+
name: "content_uri",
|
|
495
|
+
type: DataType.Text,
|
|
496
|
+
},
|
|
497
|
+
{
|
|
498
|
+
name: "content_size",
|
|
499
|
+
type: DataType.Int,
|
|
500
|
+
},
|
|
501
|
+
{
|
|
502
|
+
name: "content_hash",
|
|
503
|
+
type: DataType.Text,
|
|
504
|
+
},
|
|
505
|
+
{
|
|
506
|
+
name: "public_notes",
|
|
507
|
+
type: DataType.Text,
|
|
508
|
+
},
|
|
509
|
+
{
|
|
510
|
+
name: "public_notes_signature",
|
|
511
|
+
type: DataType.Text,
|
|
512
|
+
},
|
|
513
|
+
{
|
|
514
|
+
name: "broader_signature",
|
|
515
|
+
type: DataType.Text,
|
|
516
|
+
},
|
|
517
|
+
{
|
|
518
|
+
name: "storage_token",
|
|
519
|
+
type: DataType.Text,
|
|
520
|
+
},
|
|
521
|
+
],
|
|
522
|
+
request_user_wipe_as_mm_operator: [
|
|
523
|
+
{
|
|
524
|
+
name: "user_id",
|
|
525
|
+
type: DataType.Uuid,
|
|
526
|
+
},
|
|
527
|
+
{
|
|
528
|
+
name: "storage_token",
|
|
529
|
+
type: DataType.Text,
|
|
530
|
+
},
|
|
531
|
+
],
|
|
419
532
|
add_attribute_as_inserter: [
|
|
420
533
|
{
|
|
421
534
|
name: "id",
|
|
@@ -736,7 +849,7 @@ export type GetUserAsInserterOutput = z.infer<typeof GetUserAsInserterOutputSche
|
|
|
736
849
|
export async function getUserAsInserter(
|
|
737
850
|
kwilClient: KwilActionClient,
|
|
738
851
|
params: GetUserAsInserterInput,
|
|
739
|
-
): Promise<GetUserAsInserterOutput> {
|
|
852
|
+
): Promise<GetUserAsInserterOutput | undefined> {
|
|
740
853
|
const inputs = GetUserAsInserterInputSchema.parse(params);
|
|
741
854
|
return await kwilClient
|
|
742
855
|
.call<GetUserAsInserterOutput[]>({
|
|
@@ -751,33 +864,27 @@ export const UpsertWalletAsInserterInputSchema: z.ZodObject<{
|
|
|
751
864
|
user_id: z.ZodUUID;
|
|
752
865
|
address: z.ZodString;
|
|
753
866
|
public_key: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
754
|
-
wallet_type: z.ZodType<
|
|
755
|
-
not_before: z.
|
|
756
|
-
not_after: z.
|
|
867
|
+
wallet_type: z.ZodType<AddWalletType>;
|
|
868
|
+
not_before: z.ZodISODateTime;
|
|
869
|
+
not_after: z.ZodISODateTime;
|
|
757
870
|
signature: z.ZodString;
|
|
758
|
-
}> = z
|
|
759
|
-
.
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
})
|
|
769
|
-
.refine((v) => (v.wallet_type === "MM") === (v.not_before == null), {
|
|
770
|
-
path: ["not_before"],
|
|
771
|
-
message: "not_before must be null when wallet_type is MM, and set otherwise",
|
|
772
|
-
})
|
|
773
|
-
.refine((v) => (v.wallet_type === "MM") === (v.not_after == null), {
|
|
774
|
-
path: ["not_after"],
|
|
775
|
-
message: "not_after must be null when wallet_type is MM, and set otherwise",
|
|
776
|
-
});
|
|
871
|
+
}> = z.object({
|
|
872
|
+
id: z.uuid(),
|
|
873
|
+
user_id: z.uuid(),
|
|
874
|
+
address: z.string(),
|
|
875
|
+
public_key: z.string().nullish(),
|
|
876
|
+
wallet_type: addWalletTypeSchema,
|
|
877
|
+
not_before: rfc3339DateTimeSchema,
|
|
878
|
+
not_after: rfc3339DateTimeSchema,
|
|
879
|
+
signature: z.string(),
|
|
880
|
+
});
|
|
777
881
|
|
|
778
882
|
export type UpsertWalletAsInserterInput = z.infer<typeof UpsertWalletAsInserterInputSchema>;
|
|
779
883
|
|
|
780
|
-
/**
|
|
884
|
+
/**
|
|
885
|
+
* WALLET ACTIONS
|
|
886
|
+
* Existing MM wallets count too: a key can't be both an MM wallet and another wallet.
|
|
887
|
+
*/
|
|
781
888
|
export async function upsertWalletAsInserter(
|
|
782
889
|
kwilClient: KwilActionClient,
|
|
783
890
|
params: UpsertWalletAsInserterInput,
|
|
@@ -792,13 +899,13 @@ export async function upsertWalletAsInserter(
|
|
|
792
899
|
|
|
793
900
|
export const AddWalletMessageInputSchema: z.ZodObject<{
|
|
794
901
|
address: z.ZodString;
|
|
795
|
-
wallet_type: z.ZodType<
|
|
902
|
+
wallet_type: z.ZodType<AddWalletType>;
|
|
796
903
|
user_id: z.ZodUUID;
|
|
797
904
|
not_before: z.ZodISODateTime;
|
|
798
905
|
not_after: z.ZodISODateTime;
|
|
799
906
|
}> = z.object({
|
|
800
907
|
address: z.string(),
|
|
801
|
-
wallet_type:
|
|
908
|
+
wallet_type: addWalletTypeSchema,
|
|
802
909
|
user_id: z.uuid(),
|
|
803
910
|
not_before: rfc3339DateTimeSchema,
|
|
804
911
|
not_after: rfc3339DateTimeSchema,
|
|
@@ -834,7 +941,7 @@ export const AddWalletInputSchema: z.ZodObject<{
|
|
|
834
941
|
id: z.ZodUUID;
|
|
835
942
|
address: z.ZodString;
|
|
836
943
|
public_key: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
837
|
-
wallet_type: z.ZodType<
|
|
944
|
+
wallet_type: z.ZodType<AddWalletType>;
|
|
838
945
|
not_before: z.ZodISODateTime;
|
|
839
946
|
not_after: z.ZodISODateTime;
|
|
840
947
|
signature: z.ZodString;
|
|
@@ -842,7 +949,7 @@ export const AddWalletInputSchema: z.ZodObject<{
|
|
|
842
949
|
id: z.uuid(),
|
|
843
950
|
address: z.string(),
|
|
844
951
|
public_key: z.string().nullish(),
|
|
845
|
-
wallet_type:
|
|
952
|
+
wallet_type: addWalletTypeSchema,
|
|
846
953
|
not_before: rfc3339DateTimeSchema,
|
|
847
954
|
not_after: rfc3339DateTimeSchema,
|
|
848
955
|
signature: z.string(),
|
|
@@ -868,7 +975,7 @@ export const GetWalletsOutputSchema: z.ZodObject<{
|
|
|
868
975
|
address: z.ZodString;
|
|
869
976
|
public_key: z.ZodNullable<z.ZodString>;
|
|
870
977
|
wallet_type: z.ZodType<WalletType>;
|
|
871
|
-
message: z.ZodString
|
|
978
|
+
message: z.ZodNullable<z.ZodString>;
|
|
872
979
|
signature: z.ZodString;
|
|
873
980
|
inserter: z.ZodNullable<z.ZodString>;
|
|
874
981
|
}> = z.object({
|
|
@@ -877,7 +984,7 @@ export const GetWalletsOutputSchema: z.ZodObject<{
|
|
|
877
984
|
address: z.string(),
|
|
878
985
|
public_key: z.string().nullable(),
|
|
879
986
|
wallet_type: walletTypeSchema,
|
|
880
|
-
message: z.string(),
|
|
987
|
+
message: z.string().nullable(),
|
|
881
988
|
signature: z.string(),
|
|
882
989
|
inserter: z.string().nullable(),
|
|
883
990
|
});
|
|
@@ -899,6 +1006,10 @@ export const RemoveWalletInputSchema: z.ZodObject<{
|
|
|
899
1006
|
|
|
900
1007
|
export type RemoveWalletInput = z.infer<typeof RemoveWalletInputSchema>;
|
|
901
1008
|
|
|
1009
|
+
/**
|
|
1010
|
+
* A user may have an MM wallet next to others (created before MM operators). Without it
|
|
1011
|
+
* the user is no longer an MM user, and its ukyc:// credentials could never be wiped.
|
|
1012
|
+
*/
|
|
902
1013
|
export async function removeWallet(
|
|
903
1014
|
kwilClient: KwilActionClient,
|
|
904
1015
|
params: RemoveWalletInput,
|
|
@@ -911,6 +1022,43 @@ export async function removeWallet(
|
|
|
911
1022
|
});
|
|
912
1023
|
}
|
|
913
1024
|
|
|
1025
|
+
export const CredentialBroaderMessageInputSchema: z.ZodObject<{
|
|
1026
|
+
public_notes_signature: z.ZodString;
|
|
1027
|
+
content_uri: z.ZodString;
|
|
1028
|
+
recipient_wallet: z.ZodString;
|
|
1029
|
+
}> = z.object({
|
|
1030
|
+
public_notes_signature: z.string(),
|
|
1031
|
+
content_uri: blobContentUriSchema,
|
|
1032
|
+
recipient_wallet: z.string(),
|
|
1033
|
+
});
|
|
1034
|
+
|
|
1035
|
+
export type CredentialBroaderMessageInput = z.infer<typeof CredentialBroaderMessageInputSchema>;
|
|
1036
|
+
|
|
1037
|
+
export const CredentialBroaderMessageOutputSchema: z.ZodObject<{
|
|
1038
|
+
message: z.ZodString;
|
|
1039
|
+
}> = z.object({
|
|
1040
|
+
message: z.string(),
|
|
1041
|
+
});
|
|
1042
|
+
|
|
1043
|
+
export type CredentialBroaderMessageOutput = z.infer<typeof CredentialBroaderMessageOutputSchema>;
|
|
1044
|
+
|
|
1045
|
+
/** CREDENTIAL ACTIONS */
|
|
1046
|
+
export async function credentialBroaderMessage(
|
|
1047
|
+
kwilClient: KwilActionClient,
|
|
1048
|
+
params: CredentialBroaderMessageInput,
|
|
1049
|
+
): Promise<CredentialBroaderMessageOutput> {
|
|
1050
|
+
const inputs = CredentialBroaderMessageInputSchema.parse(params);
|
|
1051
|
+
return await kwilClient
|
|
1052
|
+
.call<CredentialBroaderMessageOutput[]>({
|
|
1053
|
+
name: "credential_broader_message",
|
|
1054
|
+
inputs,
|
|
1055
|
+
})
|
|
1056
|
+
.then((result) => {
|
|
1057
|
+
if (!result[0]) throw new Error("credential_broader_message returned no rows");
|
|
1058
|
+
return result[0];
|
|
1059
|
+
});
|
|
1060
|
+
}
|
|
1061
|
+
|
|
914
1062
|
export const CreatePreliminaryCredentialInputSchema: z.ZodObject<{
|
|
915
1063
|
request_id: z.ZodUUID;
|
|
916
1064
|
credential_id: z.ZodUUID;
|
|
@@ -939,7 +1087,10 @@ export type CreatePreliminaryCredentialInput = z.infer<
|
|
|
939
1087
|
typeof CreatePreliminaryCredentialInputSchema
|
|
940
1088
|
>;
|
|
941
1089
|
|
|
942
|
-
/**
|
|
1090
|
+
/**
|
|
1091
|
+
* Refused for MM users, also when signed in with another wallet: their MM operator stages
|
|
1092
|
+
* their credentials (create_preliminary_credential_as_mm_operator), with their storage token.
|
|
1093
|
+
*/
|
|
943
1094
|
export async function createPreliminaryCredential(
|
|
944
1095
|
kwilClient: KwilActionClient,
|
|
945
1096
|
params: CreatePreliminaryCredentialInput,
|
|
@@ -1139,6 +1290,7 @@ export const SharePreliminaryCredentialInputSchema: z.ZodObject<{
|
|
|
1139
1290
|
|
|
1140
1291
|
export type SharePreliminaryCredentialInput = z.infer<typeof SharePreliminaryCredentialInputSchema>;
|
|
1141
1292
|
|
|
1293
|
+
/** Refused for MM users, also when signed in with another wallet: their credentials can't be shared. */
|
|
1142
1294
|
export async function sharePreliminaryCredential(
|
|
1143
1295
|
kwilClient: KwilActionClient,
|
|
1144
1296
|
params: SharePreliminaryCredentialInput,
|
|
@@ -1211,6 +1363,7 @@ export type CreatePreliminaryCredentialsByDwgInput = z.infer<
|
|
|
1211
1363
|
* Delegated write credential actions
|
|
1212
1364
|
* For access grant
|
|
1213
1365
|
* We will use the same ids for preliminary credentials as for credentials, so we need to check if they already exist
|
|
1366
|
+
* MM users are managed by their MM operator only.
|
|
1214
1367
|
* We capture gas upfront to prevent the real credential from being created if the gas is not enough
|
|
1215
1368
|
* The gas can be refunded fully or partially
|
|
1216
1369
|
* Temporary: an issuer is not an inserter/caller. A user grants a DWG to an issuer_key;
|
|
@@ -1260,7 +1413,7 @@ export type CredentialExistAsInserterOutput = z.infer<typeof CredentialExistAsIn
|
|
|
1260
1413
|
export async function credentialExistAsInserter(
|
|
1261
1414
|
kwilClient: KwilActionClient,
|
|
1262
1415
|
params: CredentialExistAsInserterInput,
|
|
1263
|
-
): Promise<CredentialExistAsInserterOutput> {
|
|
1416
|
+
): Promise<CredentialExistAsInserterOutput | undefined> {
|
|
1264
1417
|
const inputs = CredentialExistAsInserterInputSchema.parse(params);
|
|
1265
1418
|
return await kwilClient
|
|
1266
1419
|
.call<CredentialExistAsInserterOutput[]>({
|
|
@@ -1380,7 +1533,7 @@ export type GetSiblingCredentialIdOutput = z.infer<typeof GetSiblingCredentialId
|
|
|
1380
1533
|
export async function getSiblingCredentialId(
|
|
1381
1534
|
kwilClient: KwilActionClient,
|
|
1382
1535
|
params: GetSiblingCredentialIdInput,
|
|
1383
|
-
): Promise<GetSiblingCredentialIdOutput> {
|
|
1536
|
+
): Promise<GetSiblingCredentialIdOutput | undefined> {
|
|
1384
1537
|
const inputs = GetSiblingCredentialIdInputSchema.parse(params);
|
|
1385
1538
|
return await kwilClient
|
|
1386
1539
|
.call<GetSiblingCredentialIdOutput[]>({
|
|
@@ -1390,6 +1543,198 @@ export async function getSiblingCredentialId(
|
|
|
1390
1543
|
.then((result) => result[0]);
|
|
1391
1544
|
}
|
|
1392
1545
|
|
|
1546
|
+
export const GetUserAsMmOperatorInputSchema: z.ZodObject<{
|
|
1547
|
+
storage_token: z.ZodString;
|
|
1548
|
+
}> = z.object({
|
|
1549
|
+
storage_token: z.string(),
|
|
1550
|
+
});
|
|
1551
|
+
|
|
1552
|
+
export type GetUserAsMmOperatorInput = z.infer<typeof GetUserAsMmOperatorInputSchema>;
|
|
1553
|
+
|
|
1554
|
+
export const GetUserAsMmOperatorOutputSchema: z.ZodObject<{
|
|
1555
|
+
id: z.ZodUUID;
|
|
1556
|
+
recipient_encryption_public_key: z.ZodString;
|
|
1557
|
+
frozen: z.ZodBoolean;
|
|
1558
|
+
}> = z.object({
|
|
1559
|
+
id: z.uuid(),
|
|
1560
|
+
recipient_encryption_public_key: z.string(),
|
|
1561
|
+
frozen: z.boolean(),
|
|
1562
|
+
});
|
|
1563
|
+
|
|
1564
|
+
export type GetUserAsMmOperatorOutput = z.infer<typeof GetUserAsMmOperatorOutputSchema>;
|
|
1565
|
+
|
|
1566
|
+
/**
|
|
1567
|
+
* MM OPERATOR ACTIONS
|
|
1568
|
+
* An MM operator (see mm_operators) creates MM users, stages their ukyc:// credentials and
|
|
1569
|
+
* freezes them for a data wipe. It only acts on the MM users it created, and every action
|
|
1570
|
+
* also needs a valid UKYC storage token ($storage_token, the bare base64url envelope) minted
|
|
1571
|
+
* by the user's app: the operator key alone can't do anything to an MM user. Tokens are
|
|
1572
|
+
* verified at @block_timestamp (the last block's time in view calls).
|
|
1573
|
+
*/
|
|
1574
|
+
export async function getUserAsMmOperator(
|
|
1575
|
+
kwilClient: KwilActionClient,
|
|
1576
|
+
params: GetUserAsMmOperatorInput,
|
|
1577
|
+
): Promise<GetUserAsMmOperatorOutput[]> {
|
|
1578
|
+
const inputs = GetUserAsMmOperatorInputSchema.parse(params);
|
|
1579
|
+
return await kwilClient.call<GetUserAsMmOperatorOutput[]>({
|
|
1580
|
+
name: "get_user_as_mm_operator",
|
|
1581
|
+
inputs,
|
|
1582
|
+
});
|
|
1583
|
+
}
|
|
1584
|
+
|
|
1585
|
+
export const CreateUserAsMmOperatorInputSchema: z.ZodObject<{
|
|
1586
|
+
id: z.ZodUUID;
|
|
1587
|
+
recipient_encryption_public_key: z.ZodString;
|
|
1588
|
+
wallet_id: z.ZodUUID;
|
|
1589
|
+
storage_token: z.ZodString;
|
|
1590
|
+
}> = z.object({
|
|
1591
|
+
id: z.uuid(),
|
|
1592
|
+
recipient_encryption_public_key: z.string(),
|
|
1593
|
+
wallet_id: z.uuid(),
|
|
1594
|
+
storage_token: z.string(),
|
|
1595
|
+
});
|
|
1596
|
+
|
|
1597
|
+
export type CreateUserAsMmOperatorInput = z.infer<typeof CreateUserAsMmOperatorInputSchema>;
|
|
1598
|
+
|
|
1599
|
+
/** The MM wallet key is the storage token's signing key (write token). */
|
|
1600
|
+
export async function createUserAsMmOperator(
|
|
1601
|
+
kwilClient: KwilActionClient,
|
|
1602
|
+
params: CreateUserAsMmOperatorInput,
|
|
1603
|
+
): Promise<void> {
|
|
1604
|
+
const inputs = CreateUserAsMmOperatorInputSchema.parse(params);
|
|
1605
|
+
await kwilClient.execute({
|
|
1606
|
+
name: "create_user_as_mm_operator",
|
|
1607
|
+
inputs,
|
|
1608
|
+
description: "Create an MM user with its MM wallet as an MM operator",
|
|
1609
|
+
});
|
|
1610
|
+
}
|
|
1611
|
+
|
|
1612
|
+
export const GetCredentialsAsMmOperatorInputSchema: z.ZodObject<{
|
|
1613
|
+
user_id: z.ZodUUID;
|
|
1614
|
+
storage_token: z.ZodString;
|
|
1615
|
+
}> = z.object({
|
|
1616
|
+
user_id: z.uuid(),
|
|
1617
|
+
storage_token: z.string(),
|
|
1618
|
+
});
|
|
1619
|
+
|
|
1620
|
+
export type GetCredentialsAsMmOperatorInput = z.infer<typeof GetCredentialsAsMmOperatorInputSchema>;
|
|
1621
|
+
|
|
1622
|
+
export const GetCredentialsAsMmOperatorOutputSchema: z.ZodObject<{
|
|
1623
|
+
id: z.ZodUUID;
|
|
1624
|
+
user_id: z.ZodUUID;
|
|
1625
|
+
public_notes: z.ZodString;
|
|
1626
|
+
content_uri: z.ZodString;
|
|
1627
|
+
content_size: z.ZodNumber;
|
|
1628
|
+
encryptor_public_key: z.ZodString;
|
|
1629
|
+
issuer_auth_public_key: z.ZodString;
|
|
1630
|
+
inserter_type: z.ZodString;
|
|
1631
|
+
inserter_id: z.ZodString;
|
|
1632
|
+
}> = z.object({
|
|
1633
|
+
id: z.uuid(),
|
|
1634
|
+
user_id: z.uuid(),
|
|
1635
|
+
public_notes: z.string(),
|
|
1636
|
+
content_uri: z.string(),
|
|
1637
|
+
content_size: z.number(),
|
|
1638
|
+
encryptor_public_key: z.string(),
|
|
1639
|
+
issuer_auth_public_key: z.string(),
|
|
1640
|
+
inserter_type: z.string(),
|
|
1641
|
+
inserter_id: z.string(),
|
|
1642
|
+
});
|
|
1643
|
+
|
|
1644
|
+
export type GetCredentialsAsMmOperatorOutput = z.infer<
|
|
1645
|
+
typeof GetCredentialsAsMmOperatorOutputSchema
|
|
1646
|
+
>;
|
|
1647
|
+
|
|
1648
|
+
/** Needs a read token of the user for the user's storage. */
|
|
1649
|
+
export async function getCredentialsAsMmOperator(
|
|
1650
|
+
kwilClient: KwilActionClient,
|
|
1651
|
+
params: GetCredentialsAsMmOperatorInput,
|
|
1652
|
+
): Promise<GetCredentialsAsMmOperatorOutput[]> {
|
|
1653
|
+
const inputs = GetCredentialsAsMmOperatorInputSchema.parse(params);
|
|
1654
|
+
return await kwilClient.call<GetCredentialsAsMmOperatorOutput[]>({
|
|
1655
|
+
name: "get_credentials_as_mm_operator",
|
|
1656
|
+
inputs,
|
|
1657
|
+
});
|
|
1658
|
+
}
|
|
1659
|
+
|
|
1660
|
+
export const CreatePreliminaryCredentialAsMmOperatorInputSchema: z.ZodObject<{
|
|
1661
|
+
request_id: z.ZodUUID;
|
|
1662
|
+
user_id: z.ZodUUID;
|
|
1663
|
+
credential_id: z.ZodUUID;
|
|
1664
|
+
issuer_auth_public_key: z.ZodString;
|
|
1665
|
+
encryptor_public_key: z.ZodString;
|
|
1666
|
+
content_uri: z.ZodString;
|
|
1667
|
+
content_size: z.ZodNumber;
|
|
1668
|
+
content_hash: z.ZodString;
|
|
1669
|
+
public_notes: z.ZodString;
|
|
1670
|
+
public_notes_signature: z.ZodString;
|
|
1671
|
+
broader_signature: z.ZodString;
|
|
1672
|
+
storage_token: z.ZodString;
|
|
1673
|
+
}> = z.object({
|
|
1674
|
+
request_id: z.uuid(),
|
|
1675
|
+
user_id: z.uuid(),
|
|
1676
|
+
credential_id: z.uuid(),
|
|
1677
|
+
issuer_auth_public_key: z.string(),
|
|
1678
|
+
encryptor_public_key: z.string(),
|
|
1679
|
+
content_uri: blobContentUriSchema,
|
|
1680
|
+
content_size: contentSizeSchema,
|
|
1681
|
+
content_hash: z.string(),
|
|
1682
|
+
public_notes: z.string(),
|
|
1683
|
+
public_notes_signature: z.string(),
|
|
1684
|
+
broader_signature: z.string(),
|
|
1685
|
+
storage_token: z.string(),
|
|
1686
|
+
});
|
|
1687
|
+
|
|
1688
|
+
export type CreatePreliminaryCredentialAsMmOperatorInput = z.infer<
|
|
1689
|
+
typeof CreatePreliminaryCredentialAsMmOperatorInputSchema
|
|
1690
|
+
>;
|
|
1691
|
+
|
|
1692
|
+
/**
|
|
1693
|
+
* Like create_preliminary_credential, for an MM user. The issuer signs with the user's MM
|
|
1694
|
+
* wallet public key as the recipient wallet. Needs a write token of the user; the content URI's
|
|
1695
|
+
* storage must be the token's storage and the user's storage (the first credential defines it).
|
|
1696
|
+
*/
|
|
1697
|
+
export async function createPreliminaryCredentialAsMmOperator(
|
|
1698
|
+
kwilClient: KwilActionClient,
|
|
1699
|
+
params: CreatePreliminaryCredentialAsMmOperatorInput,
|
|
1700
|
+
): Promise<void> {
|
|
1701
|
+
const inputs = CreatePreliminaryCredentialAsMmOperatorInputSchema.parse(params);
|
|
1702
|
+
await kwilClient.execute({
|
|
1703
|
+
name: "create_preliminary_credential_as_mm_operator",
|
|
1704
|
+
inputs,
|
|
1705
|
+
description: "Create a preliminary ukyc:// credential for an MM user as its MM operator",
|
|
1706
|
+
});
|
|
1707
|
+
}
|
|
1708
|
+
|
|
1709
|
+
export const RequestUserWipeAsMmOperatorInputSchema: z.ZodObject<{
|
|
1710
|
+
user_id: z.ZodUUID;
|
|
1711
|
+
storage_token: z.ZodString;
|
|
1712
|
+
}> = z.object({
|
|
1713
|
+
user_id: z.uuid(),
|
|
1714
|
+
storage_token: z.string(),
|
|
1715
|
+
});
|
|
1716
|
+
|
|
1717
|
+
export type RequestUserWipeAsMmOperatorInput = z.infer<
|
|
1718
|
+
typeof RequestUserWipeAsMmOperatorInputSchema
|
|
1719
|
+
>;
|
|
1720
|
+
|
|
1721
|
+
/**
|
|
1722
|
+
* Freezes the MM user: no new credentials, no reads, no finalize. The gateway deletes the
|
|
1723
|
+
* user once the UKYC storage is deleted (finalize_mm_user_wipe_as_gateway). No cancel.
|
|
1724
|
+
* Needs a delete token of the user for the user's storage, also when already requested.
|
|
1725
|
+
*/
|
|
1726
|
+
export async function requestUserWipeAsMmOperator(
|
|
1727
|
+
kwilClient: KwilActionClient,
|
|
1728
|
+
params: RequestUserWipeAsMmOperatorInput,
|
|
1729
|
+
): Promise<void> {
|
|
1730
|
+
const inputs = RequestUserWipeAsMmOperatorInputSchema.parse(params);
|
|
1731
|
+
await kwilClient.execute({
|
|
1732
|
+
name: "request_user_wipe_as_mm_operator",
|
|
1733
|
+
inputs,
|
|
1734
|
+
description: "Request a data wipe of an MM user as its MM operator",
|
|
1735
|
+
});
|
|
1736
|
+
}
|
|
1737
|
+
|
|
1393
1738
|
export const AddAttributeAsInserterInputSchema: z.ZodObject<{
|
|
1394
1739
|
id: z.ZodUUID;
|
|
1395
1740
|
user_id: z.ZodUUID;
|
|
@@ -1573,7 +1918,7 @@ export type DwgMessageOutput = z.infer<typeof DwgMessageOutputSchema>;
|
|
|
1573
1918
|
export async function dwgMessage(
|
|
1574
1919
|
kwilClient: KwilActionClient,
|
|
1575
1920
|
params: DwgMessageInput,
|
|
1576
|
-
): Promise<DwgMessageOutput> {
|
|
1921
|
+
): Promise<DwgMessageOutput | undefined> {
|
|
1577
1922
|
const inputs = DwgMessageInputSchema.parse(params);
|
|
1578
1923
|
return await kwilClient
|
|
1579
1924
|
.call<DwgMessageOutput[]>({
|
|
@@ -1708,7 +2053,7 @@ export type GetAccessGrantsGrantedCountOutput = z.infer<
|
|
|
1708
2053
|
export async function getAccessGrantsGrantedCount(
|
|
1709
2054
|
kwilClient: KwilActionClient,
|
|
1710
2055
|
params: GetAccessGrantsGrantedCountInput,
|
|
1711
|
-
): Promise<GetAccessGrantsGrantedCountOutput> {
|
|
2056
|
+
): Promise<GetAccessGrantsGrantedCountOutput | undefined> {
|
|
1712
2057
|
const inputs = GetAccessGrantsGrantedCountInputSchema.parse(params);
|
|
1713
2058
|
return await kwilClient
|
|
1714
2059
|
.call<GetAccessGrantsGrantedCountOutput[]>({
|
|
@@ -1737,7 +2082,7 @@ export type HasLockedAccessGrantsOutput = z.infer<typeof HasLockedAccessGrantsOu
|
|
|
1737
2082
|
export async function hasLockedAccessGrants(
|
|
1738
2083
|
kwilClient: KwilActionClient,
|
|
1739
2084
|
params: HasLockedAccessGrantsInput,
|
|
1740
|
-
): Promise<HasLockedAccessGrantsOutput> {
|
|
2085
|
+
): Promise<HasLockedAccessGrantsOutput | undefined> {
|
|
1741
2086
|
const inputs = HasLockedAccessGrantsInputSchema.parse(params);
|
|
1742
2087
|
return await kwilClient
|
|
1743
2088
|
.call<HasLockedAccessGrantsOutput[]>({
|
|
@@ -1815,7 +2160,7 @@ export type HasProfileOutput = z.infer<typeof HasProfileOutputSchema>;
|
|
|
1815
2160
|
export async function hasProfile(
|
|
1816
2161
|
kwilClient: KwilActionClient,
|
|
1817
2162
|
params: HasProfileInput,
|
|
1818
|
-
): Promise<HasProfileOutput> {
|
|
2163
|
+
): Promise<HasProfileOutput | undefined> {
|
|
1819
2164
|
const inputs = HasProfileInputSchema.parse(params);
|
|
1820
2165
|
return await kwilClient
|
|
1821
2166
|
.call<HasProfileOutput[]>(
|
|
@@ -1867,7 +2212,7 @@ export type CheckCallerPayerOutput = z.infer<typeof CheckCallerPayerOutputSchema
|
|
|
1867
2212
|
export async function checkCallerPayer(
|
|
1868
2213
|
kwilClient: KwilActionClient,
|
|
1869
2214
|
params: CheckCallerPayerInput,
|
|
1870
|
-
): Promise<CheckCallerPayerOutput> {
|
|
2215
|
+
): Promise<CheckCallerPayerOutput | undefined> {
|
|
1871
2216
|
const inputs = CheckCallerPayerInputSchema.parse(params);
|
|
1872
2217
|
return await kwilClient
|
|
1873
2218
|
.call<CheckCallerPayerOutput[]>({
|
|
@@ -1918,7 +2263,7 @@ export type CheckBalanceOutput = z.infer<typeof CheckBalanceOutputSchema>;
|
|
|
1918
2263
|
export async function checkBalance(
|
|
1919
2264
|
kwilClient: KwilActionClient,
|
|
1920
2265
|
params: CheckBalanceInput,
|
|
1921
|
-
): Promise<CheckBalanceOutput> {
|
|
2266
|
+
): Promise<CheckBalanceOutput | undefined> {
|
|
1922
2267
|
const inputs = CheckBalanceInputSchema.parse(params);
|
|
1923
2268
|
return await kwilClient
|
|
1924
2269
|
.call<CheckBalanceOutput[]>({
|
|
@@ -1949,7 +2294,7 @@ export type GetWalletWithBalanceOutput = z.infer<typeof GetWalletWithBalanceOutp
|
|
|
1949
2294
|
export async function getWalletWithBalance(
|
|
1950
2295
|
kwilClient: KwilActionClient,
|
|
1951
2296
|
params: GetWalletWithBalanceInput,
|
|
1952
|
-
): Promise<GetWalletWithBalanceOutput> {
|
|
2297
|
+
): Promise<GetWalletWithBalanceOutput | undefined> {
|
|
1953
2298
|
const inputs = GetWalletWithBalanceInputSchema.parse(params);
|
|
1954
2299
|
return await kwilClient
|
|
1955
2300
|
.call<GetWalletWithBalanceOutput[]>({
|
|
@@ -1989,7 +2334,9 @@ export const GetAllowanceOutputSchema: z.ZodObject<{
|
|
|
1989
2334
|
export type GetAllowanceOutput = z.infer<typeof GetAllowanceOutputSchema>;
|
|
1990
2335
|
|
|
1991
2336
|
/** FaceSign should not be able to call this */
|
|
1992
|
-
export async function getAllowance(
|
|
2337
|
+
export async function getAllowance(
|
|
2338
|
+
kwilClient: KwilActionClient,
|
|
2339
|
+
): Promise<GetAllowanceOutput | undefined> {
|
|
1993
2340
|
return await kwilClient
|
|
1994
2341
|
.call<GetAllowanceOutput[]>({
|
|
1995
2342
|
name: "get_allowance",
|
|
@@ -2045,7 +2392,7 @@ export type GetIssuerFeeOutput = z.infer<typeof GetIssuerFeeOutputSchema>;
|
|
|
2045
2392
|
export async function getIssuerFee(
|
|
2046
2393
|
kwilClient: KwilActionClient,
|
|
2047
2394
|
params: GetIssuerFeeInput,
|
|
2048
|
-
): Promise<GetIssuerFeeOutput> {
|
|
2395
|
+
): Promise<GetIssuerFeeOutput | undefined> {
|
|
2049
2396
|
const inputs = GetIssuerFeeInputSchema.parse(params);
|
|
2050
2397
|
return await kwilClient
|
|
2051
2398
|
.call<GetIssuerFeeOutput[]>({
|