@coasys/ad4m 0.11.2-dev-multi-user → 0.11.2-dev-multi-user-email
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/lib/index.cjs +226 -27
- package/lib/index.js +227 -28
- package/lib/src/agent/Agent.d.ts +0 -6
- package/lib/src/agent/Agent.js +0 -24
- package/lib/src/agent/AgentClient.d.ts +4 -1
- package/lib/src/agent/AgentClient.js +26 -4
- package/lib/src/runtime/RuntimeClient.d.ts +5 -0
- package/lib/src/runtime/RuntimeClient.js +42 -0
- package/lib/src/runtime/RuntimeResolver.d.ts +16 -0
- package/lib/src/runtime/RuntimeResolver.js +138 -0
- package/lib/src/schema.gql +22 -0
- package/lib/src/typeDefs.js +22 -0
- package/package.json +2 -1
- package/src/agent/Agent.ts +0 -17
- package/src/agent/AgentClient.ts +33 -4
- package/src/runtime/RuntimeClient.ts +47 -0
- package/src/runtime/RuntimeResolver.ts +95 -0
package/lib/src/agent/Agent.d.ts
CHANGED
|
@@ -101,12 +101,6 @@ export declare class AuthInfoInput {
|
|
|
101
101
|
capabilities?: CapabilityInput[];
|
|
102
102
|
constructor(appName: string, appDesc: string, appDomain: string, appUrl?: string, appIconPath?: string, capabilities?: CapabilityInput[]);
|
|
103
103
|
}
|
|
104
|
-
export declare class User {
|
|
105
|
-
username: string;
|
|
106
|
-
did: string;
|
|
107
|
-
password: string;
|
|
108
|
-
constructor(username: string, did: string, password: string);
|
|
109
|
-
}
|
|
110
104
|
export declare class UserCreationResult {
|
|
111
105
|
did: string;
|
|
112
106
|
success: boolean;
|
package/lib/src/agent/Agent.js
CHANGED
|
@@ -335,30 +335,6 @@ AuthInfoInput = __decorate([
|
|
|
335
335
|
__metadata("design:paramtypes", [String, String, String, String, String, Array])
|
|
336
336
|
], AuthInfoInput);
|
|
337
337
|
export { AuthInfoInput };
|
|
338
|
-
let User = class User {
|
|
339
|
-
constructor(username, did, password) {
|
|
340
|
-
this.username = username;
|
|
341
|
-
this.did = did;
|
|
342
|
-
this.password = password;
|
|
343
|
-
}
|
|
344
|
-
};
|
|
345
|
-
__decorate([
|
|
346
|
-
Field(),
|
|
347
|
-
__metadata("design:type", String)
|
|
348
|
-
], User.prototype, "username", void 0);
|
|
349
|
-
__decorate([
|
|
350
|
-
Field(),
|
|
351
|
-
__metadata("design:type", String)
|
|
352
|
-
], User.prototype, "did", void 0);
|
|
353
|
-
__decorate([
|
|
354
|
-
Field(),
|
|
355
|
-
__metadata("design:type", String)
|
|
356
|
-
], User.prototype, "password", void 0);
|
|
357
|
-
User = __decorate([
|
|
358
|
-
ObjectType(),
|
|
359
|
-
__metadata("design:paramtypes", [String, String, String])
|
|
360
|
-
], User);
|
|
361
|
-
export { User };
|
|
362
338
|
let UserCreationResult = class UserCreationResult {
|
|
363
339
|
constructor(did, success, error) {
|
|
364
340
|
this.did = did;
|
|
@@ -3,6 +3,7 @@ import { PerspectiveInput } from "../perspectives/Perspective";
|
|
|
3
3
|
import { Agent, Apps, AuthInfoInput, EntanglementProof, EntanglementProofInput, UserCreationResult } from "./Agent";
|
|
4
4
|
import { AgentStatus } from "./AgentStatus";
|
|
5
5
|
import { LinkMutations } from "../links/Links";
|
|
6
|
+
import { VerificationRequestResult } from "../runtime/RuntimeResolver";
|
|
6
7
|
export interface InitializeArgs {
|
|
7
8
|
did: string;
|
|
8
9
|
didDocument: string;
|
|
@@ -54,6 +55,8 @@ export declare class AgentClient {
|
|
|
54
55
|
revokeToken(requestId: string): Promise<Apps[]>;
|
|
55
56
|
isLocked(): Promise<boolean>;
|
|
56
57
|
signMessage(message: string): Promise<string>;
|
|
57
|
-
createUser(email: string, password: string): Promise<UserCreationResult>;
|
|
58
|
+
createUser(email: string, password: string, appInfo?: AuthInfoInput): Promise<UserCreationResult>;
|
|
58
59
|
loginUser(email: string, password: string): Promise<string>;
|
|
60
|
+
requestLoginVerification(email: string, appInfo?: AuthInfoInput): Promise<VerificationRequestResult>;
|
|
61
|
+
verifyEmailCode(email: string, code: string, verificationType: string): Promise<string>;
|
|
59
62
|
}
|
|
@@ -428,16 +428,16 @@ export class AgentClient {
|
|
|
428
428
|
return agentSignMessage;
|
|
429
429
|
}
|
|
430
430
|
// Multi-user methods
|
|
431
|
-
async createUser(email, password) {
|
|
431
|
+
async createUser(email, password, appInfo) {
|
|
432
432
|
const { runtimeCreateUser } = unwrapApolloResult(await __classPrivateFieldGet(this, _AgentClient_apolloClient, "f").mutate({
|
|
433
|
-
mutation: gql `mutation runtimeCreateUser($email: String!, $password: String
|
|
434
|
-
runtimeCreateUser(email: $email, password: $password) {
|
|
433
|
+
mutation: gql `mutation runtimeCreateUser($email: String!, $password: String!, $appInfo: AuthInfoInput) {
|
|
434
|
+
runtimeCreateUser(email: $email, password: $password, appInfo: $appInfo) {
|
|
435
435
|
did
|
|
436
436
|
success
|
|
437
437
|
error
|
|
438
438
|
}
|
|
439
439
|
}`,
|
|
440
|
-
variables: { email, password },
|
|
440
|
+
variables: { email, password, appInfo },
|
|
441
441
|
}));
|
|
442
442
|
return runtimeCreateUser;
|
|
443
443
|
}
|
|
@@ -450,5 +450,27 @@ export class AgentClient {
|
|
|
450
450
|
}));
|
|
451
451
|
return runtimeLoginUser;
|
|
452
452
|
}
|
|
453
|
+
async requestLoginVerification(email, appInfo) {
|
|
454
|
+
const { runtimeRequestLoginVerification } = unwrapApolloResult(await __classPrivateFieldGet(this, _AgentClient_apolloClient, "f").mutate({
|
|
455
|
+
mutation: gql `mutation runtimeRequestLoginVerification($email: String!, $appInfo: AuthInfoInput) {
|
|
456
|
+
runtimeRequestLoginVerification(email: $email, appInfo: $appInfo) {
|
|
457
|
+
success
|
|
458
|
+
message
|
|
459
|
+
requiresPassword
|
|
460
|
+
}
|
|
461
|
+
}`,
|
|
462
|
+
variables: { email, appInfo },
|
|
463
|
+
}));
|
|
464
|
+
return runtimeRequestLoginVerification;
|
|
465
|
+
}
|
|
466
|
+
async verifyEmailCode(email, code, verificationType) {
|
|
467
|
+
const { runtimeVerifyEmailCode } = unwrapApolloResult(await __classPrivateFieldGet(this, _AgentClient_apolloClient, "f").mutate({
|
|
468
|
+
mutation: gql `mutation runtimeVerifyEmailCode($email: String!, $code: String!, $verificationType: String!) {
|
|
469
|
+
runtimeVerifyEmailCode(email: $email, code: $code, verificationType: $verificationType)
|
|
470
|
+
}`,
|
|
471
|
+
variables: { email, code, verificationType },
|
|
472
|
+
}));
|
|
473
|
+
return runtimeVerifyEmailCode;
|
|
474
|
+
}
|
|
453
475
|
}
|
|
454
476
|
_AgentClient_apolloClient = new WeakMap(), _AgentClient_appsChangedCallback = new WeakMap(), _AgentClient_updatedCallbacks = new WeakMap(), _AgentClient_agentStatusChangedCallbacks = new WeakMap();
|
|
@@ -42,6 +42,11 @@ export declare class RuntimeClient {
|
|
|
42
42
|
multiUserEnabled(): Promise<boolean>;
|
|
43
43
|
setMultiUserEnabled(enabled: boolean): Promise<boolean>;
|
|
44
44
|
listUsers(): Promise<UserStatistics[]>;
|
|
45
|
+
emailTestModeEnable(): Promise<boolean>;
|
|
46
|
+
emailTestModeDisable(): Promise<boolean>;
|
|
47
|
+
emailTestGetCode(email: string): Promise<string | null>;
|
|
48
|
+
emailTestClearCodes(): Promise<boolean>;
|
|
49
|
+
emailTestSetExpiry(email: string, verificationType: string, expiresAt: number): Promise<boolean>;
|
|
45
50
|
addNotificationTriggeredCallback(cb: NotificationTriggeredCallback): void;
|
|
46
51
|
subscribeNotificationTriggered(): void;
|
|
47
52
|
addMessageCallback(cb: MessageCallback): void;
|
|
@@ -381,6 +381,48 @@ export class RuntimeClient {
|
|
|
381
381
|
}));
|
|
382
382
|
return runtimeListUsers;
|
|
383
383
|
}
|
|
384
|
+
async emailTestModeEnable() {
|
|
385
|
+
const { runtimeEmailTestModeEnable } = unwrapApolloResult(await __classPrivateFieldGet(this, _RuntimeClient_apolloClient, "f").mutate({
|
|
386
|
+
mutation: gql `mutation runtimeEmailTestModeEnable {
|
|
387
|
+
runtimeEmailTestModeEnable
|
|
388
|
+
}`
|
|
389
|
+
}));
|
|
390
|
+
return runtimeEmailTestModeEnable;
|
|
391
|
+
}
|
|
392
|
+
async emailTestModeDisable() {
|
|
393
|
+
const { runtimeEmailTestModeDisable } = unwrapApolloResult(await __classPrivateFieldGet(this, _RuntimeClient_apolloClient, "f").mutate({
|
|
394
|
+
mutation: gql `mutation runtimeEmailTestModeDisable {
|
|
395
|
+
runtimeEmailTestModeDisable
|
|
396
|
+
}`
|
|
397
|
+
}));
|
|
398
|
+
return runtimeEmailTestModeDisable;
|
|
399
|
+
}
|
|
400
|
+
async emailTestGetCode(email) {
|
|
401
|
+
const { runtimeEmailTestGetCode } = unwrapApolloResult(await __classPrivateFieldGet(this, _RuntimeClient_apolloClient, "f").mutate({
|
|
402
|
+
mutation: gql `mutation runtimeEmailTestGetCode($email: String!) {
|
|
403
|
+
runtimeEmailTestGetCode(email: $email)
|
|
404
|
+
}`,
|
|
405
|
+
variables: { email }
|
|
406
|
+
}));
|
|
407
|
+
return runtimeEmailTestGetCode;
|
|
408
|
+
}
|
|
409
|
+
async emailTestClearCodes() {
|
|
410
|
+
const { runtimeEmailTestClearCodes } = unwrapApolloResult(await __classPrivateFieldGet(this, _RuntimeClient_apolloClient, "f").mutate({
|
|
411
|
+
mutation: gql `mutation runtimeEmailTestClearCodes {
|
|
412
|
+
runtimeEmailTestClearCodes
|
|
413
|
+
}`
|
|
414
|
+
}));
|
|
415
|
+
return runtimeEmailTestClearCodes;
|
|
416
|
+
}
|
|
417
|
+
async emailTestSetExpiry(email, verificationType, expiresAt) {
|
|
418
|
+
const { runtimeEmailTestSetExpiry } = unwrapApolloResult(await __classPrivateFieldGet(this, _RuntimeClient_apolloClient, "f").mutate({
|
|
419
|
+
mutation: gql `mutation runtimeEmailTestSetExpiry($email: String!, $verificationType: String!, $expiresAt: Int!) {
|
|
420
|
+
runtimeEmailTestSetExpiry(email: $email, verificationType: $verificationType, expiresAt: $expiresAt)
|
|
421
|
+
}`,
|
|
422
|
+
variables: { email, verificationType, expiresAt }
|
|
423
|
+
}));
|
|
424
|
+
return runtimeEmailTestSetExpiry;
|
|
425
|
+
}
|
|
384
426
|
addNotificationTriggeredCallback(cb) {
|
|
385
427
|
__classPrivateFieldGet(this, _RuntimeClient_notificationTriggeredCallbacks, "f").push(cb);
|
|
386
428
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { Perspective, PerspectiveExpression, PerspectiveInput } from "../perspectives/Perspective";
|
|
2
2
|
import { ExceptionType } from "../Exception";
|
|
3
|
+
import { UserCreationResult, AuthInfoInput } from "../agent/Agent";
|
|
3
4
|
export declare class SentMessage {
|
|
4
5
|
recipient: string;
|
|
5
6
|
message: PerspectiveExpression;
|
|
@@ -68,6 +69,11 @@ export declare class UserStatistics {
|
|
|
68
69
|
lastSeen?: string;
|
|
69
70
|
perspectiveCount: number;
|
|
70
71
|
}
|
|
72
|
+
export declare class VerificationRequestResult {
|
|
73
|
+
success: boolean;
|
|
74
|
+
message: string;
|
|
75
|
+
requiresPassword: boolean;
|
|
76
|
+
}
|
|
71
77
|
/**
|
|
72
78
|
* Resolver classes are used here to define the GraphQL schema
|
|
73
79
|
* (through the type-graphql annotations)
|
|
@@ -112,4 +118,14 @@ export default class RuntimeResolver {
|
|
|
112
118
|
runtimeMultiUserEnabled(): boolean;
|
|
113
119
|
runtimeSetMultiUserEnabled(enabled: boolean): boolean;
|
|
114
120
|
runtimeListUsers(): UserStatistics[];
|
|
121
|
+
runtimeRequestLoginVerification(email: string, appInfo?: AuthInfoInput): VerificationRequestResult;
|
|
122
|
+
runtimeVerifyEmailCode(email: string, code: string, verificationType: string): string;
|
|
123
|
+
runtimeTestEmail(to: string): boolean;
|
|
124
|
+
runtimeCreateUser(email: string, password: string, appInfo?: AuthInfoInput): UserCreationResult;
|
|
125
|
+
runtimeLoginUser(email: string, password: string): string;
|
|
126
|
+
runtimeEmailTestModeEnable(): boolean;
|
|
127
|
+
runtimeEmailTestModeDisable(): boolean;
|
|
128
|
+
runtimeEmailTestGetCode(email: string): string | null;
|
|
129
|
+
runtimeEmailTestClearCodes(): boolean;
|
|
130
|
+
runtimeEmailTestSetExpiry(email: string, verificationType: string, expiresAt: number): boolean;
|
|
115
131
|
}
|
|
@@ -16,6 +16,7 @@ import { ExpressionProof } from "../expression/Expression";
|
|
|
16
16
|
import { LinkExpression } from "../links/Links";
|
|
17
17
|
import { ExceptionType } from "../Exception";
|
|
18
18
|
import { RUNTIME_MESSAGED_RECEIVED_TOPIC, EXCEPTION_OCCURRED_TOPIC, RUNTIME_NOTIFICATION_TRIGGERED_TOPIC } from '../PubSub';
|
|
19
|
+
import { UserCreationResult, AuthInfoInput } from "../agent/Agent";
|
|
19
20
|
const testLink = new LinkExpression();
|
|
20
21
|
testLink.author = "did:ad4m:test";
|
|
21
22
|
testLink.timestamp = Date.now();
|
|
@@ -292,6 +293,24 @@ UserStatistics = __decorate([
|
|
|
292
293
|
ObjectType()
|
|
293
294
|
], UserStatistics);
|
|
294
295
|
export { UserStatistics };
|
|
296
|
+
let VerificationRequestResult = class VerificationRequestResult {
|
|
297
|
+
};
|
|
298
|
+
__decorate([
|
|
299
|
+
Field(),
|
|
300
|
+
__metadata("design:type", Boolean)
|
|
301
|
+
], VerificationRequestResult.prototype, "success", void 0);
|
|
302
|
+
__decorate([
|
|
303
|
+
Field(),
|
|
304
|
+
__metadata("design:type", String)
|
|
305
|
+
], VerificationRequestResult.prototype, "message", void 0);
|
|
306
|
+
__decorate([
|
|
307
|
+
Field(),
|
|
308
|
+
__metadata("design:type", Boolean)
|
|
309
|
+
], VerificationRequestResult.prototype, "requiresPassword", void 0);
|
|
310
|
+
VerificationRequestResult = __decorate([
|
|
311
|
+
ObjectType()
|
|
312
|
+
], VerificationRequestResult);
|
|
313
|
+
export { VerificationRequestResult };
|
|
295
314
|
/**
|
|
296
315
|
* Resolver classes are used here to define the GraphQL schema
|
|
297
316
|
* (through the type-graphql annotations)
|
|
@@ -455,6 +474,50 @@ let RuntimeResolver = class RuntimeResolver {
|
|
|
455
474
|
perspectiveCount: 5
|
|
456
475
|
}];
|
|
457
476
|
}
|
|
477
|
+
runtimeRequestLoginVerification(email, appInfo) {
|
|
478
|
+
// For testing: simulate existing user
|
|
479
|
+
return {
|
|
480
|
+
success: true,
|
|
481
|
+
message: "Verification email sent",
|
|
482
|
+
requiresPassword: false
|
|
483
|
+
};
|
|
484
|
+
}
|
|
485
|
+
runtimeVerifyEmailCode(email, code, verificationType) {
|
|
486
|
+
// For testing: return a test JWT token
|
|
487
|
+
return "test-jwt-token-from-email-verification";
|
|
488
|
+
}
|
|
489
|
+
runtimeTestEmail(to) {
|
|
490
|
+
// For testing: simulate successful email send
|
|
491
|
+
return true;
|
|
492
|
+
}
|
|
493
|
+
runtimeCreateUser(email, password, appInfo) {
|
|
494
|
+
// For testing: simulate successful user creation (email verification flow)
|
|
495
|
+
return new UserCreationResult("did:key:test123", true);
|
|
496
|
+
}
|
|
497
|
+
runtimeLoginUser(email, password) {
|
|
498
|
+
// For testing: return a test JWT token
|
|
499
|
+
return "test-jwt-token-from-password-login";
|
|
500
|
+
}
|
|
501
|
+
runtimeEmailTestModeEnable() {
|
|
502
|
+
// For testing: enable test mode
|
|
503
|
+
return true;
|
|
504
|
+
}
|
|
505
|
+
runtimeEmailTestModeDisable() {
|
|
506
|
+
// For testing: disable test mode
|
|
507
|
+
return true;
|
|
508
|
+
}
|
|
509
|
+
runtimeEmailTestGetCode(email) {
|
|
510
|
+
// For testing: return a mock code
|
|
511
|
+
return "123456";
|
|
512
|
+
}
|
|
513
|
+
runtimeEmailTestClearCodes() {
|
|
514
|
+
// For testing: clear codes
|
|
515
|
+
return true;
|
|
516
|
+
}
|
|
517
|
+
runtimeEmailTestSetExpiry(email, verificationType, expiresAt) {
|
|
518
|
+
// For testing: simulate setting expiry (no-op in mock)
|
|
519
|
+
return true;
|
|
520
|
+
}
|
|
458
521
|
};
|
|
459
522
|
__decorate([
|
|
460
523
|
Mutation(returns => Boolean),
|
|
@@ -707,6 +770,81 @@ __decorate([
|
|
|
707
770
|
__metadata("design:paramtypes", []),
|
|
708
771
|
__metadata("design:returntype", Array)
|
|
709
772
|
], RuntimeResolver.prototype, "runtimeListUsers", null);
|
|
773
|
+
__decorate([
|
|
774
|
+
Mutation(returns => VerificationRequestResult),
|
|
775
|
+
__param(0, Arg("email")),
|
|
776
|
+
__param(1, Arg("appInfo", { nullable: true })),
|
|
777
|
+
__metadata("design:type", Function),
|
|
778
|
+
__metadata("design:paramtypes", [String, AuthInfoInput]),
|
|
779
|
+
__metadata("design:returntype", VerificationRequestResult)
|
|
780
|
+
], RuntimeResolver.prototype, "runtimeRequestLoginVerification", null);
|
|
781
|
+
__decorate([
|
|
782
|
+
Mutation(returns => String),
|
|
783
|
+
__param(0, Arg("email")),
|
|
784
|
+
__param(1, Arg("code")),
|
|
785
|
+
__param(2, Arg("verificationType")),
|
|
786
|
+
__metadata("design:type", Function),
|
|
787
|
+
__metadata("design:paramtypes", [String, String, String]),
|
|
788
|
+
__metadata("design:returntype", String)
|
|
789
|
+
], RuntimeResolver.prototype, "runtimeVerifyEmailCode", null);
|
|
790
|
+
__decorate([
|
|
791
|
+
Mutation(returns => Boolean),
|
|
792
|
+
__param(0, Arg("to")),
|
|
793
|
+
__metadata("design:type", Function),
|
|
794
|
+
__metadata("design:paramtypes", [String]),
|
|
795
|
+
__metadata("design:returntype", Boolean)
|
|
796
|
+
], RuntimeResolver.prototype, "runtimeTestEmail", null);
|
|
797
|
+
__decorate([
|
|
798
|
+
Mutation(returns => UserCreationResult),
|
|
799
|
+
__param(0, Arg("email")),
|
|
800
|
+
__param(1, Arg("password")),
|
|
801
|
+
__param(2, Arg("appInfo", { nullable: true })),
|
|
802
|
+
__metadata("design:type", Function),
|
|
803
|
+
__metadata("design:paramtypes", [String, String, AuthInfoInput]),
|
|
804
|
+
__metadata("design:returntype", UserCreationResult)
|
|
805
|
+
], RuntimeResolver.prototype, "runtimeCreateUser", null);
|
|
806
|
+
__decorate([
|
|
807
|
+
Mutation(returns => String),
|
|
808
|
+
__param(0, Arg("email")),
|
|
809
|
+
__param(1, Arg("password")),
|
|
810
|
+
__metadata("design:type", Function),
|
|
811
|
+
__metadata("design:paramtypes", [String, String]),
|
|
812
|
+
__metadata("design:returntype", String)
|
|
813
|
+
], RuntimeResolver.prototype, "runtimeLoginUser", null);
|
|
814
|
+
__decorate([
|
|
815
|
+
Mutation(returns => Boolean),
|
|
816
|
+
__metadata("design:type", Function),
|
|
817
|
+
__metadata("design:paramtypes", []),
|
|
818
|
+
__metadata("design:returntype", Boolean)
|
|
819
|
+
], RuntimeResolver.prototype, "runtimeEmailTestModeEnable", null);
|
|
820
|
+
__decorate([
|
|
821
|
+
Mutation(returns => Boolean),
|
|
822
|
+
__metadata("design:type", Function),
|
|
823
|
+
__metadata("design:paramtypes", []),
|
|
824
|
+
__metadata("design:returntype", Boolean)
|
|
825
|
+
], RuntimeResolver.prototype, "runtimeEmailTestModeDisable", null);
|
|
826
|
+
__decorate([
|
|
827
|
+
Mutation(returns => String, { nullable: true }),
|
|
828
|
+
__param(0, Arg("email")),
|
|
829
|
+
__metadata("design:type", Function),
|
|
830
|
+
__metadata("design:paramtypes", [String]),
|
|
831
|
+
__metadata("design:returntype", String)
|
|
832
|
+
], RuntimeResolver.prototype, "runtimeEmailTestGetCode", null);
|
|
833
|
+
__decorate([
|
|
834
|
+
Mutation(returns => Boolean),
|
|
835
|
+
__metadata("design:type", Function),
|
|
836
|
+
__metadata("design:paramtypes", []),
|
|
837
|
+
__metadata("design:returntype", Boolean)
|
|
838
|
+
], RuntimeResolver.prototype, "runtimeEmailTestClearCodes", null);
|
|
839
|
+
__decorate([
|
|
840
|
+
Mutation(returns => Boolean),
|
|
841
|
+
__param(0, Arg("email")),
|
|
842
|
+
__param(1, Arg("verificationType")),
|
|
843
|
+
__param(2, Arg("expiresAt")),
|
|
844
|
+
__metadata("design:type", Function),
|
|
845
|
+
__metadata("design:paramtypes", [String, String, Number]),
|
|
846
|
+
__metadata("design:returntype", Boolean)
|
|
847
|
+
], RuntimeResolver.prototype, "runtimeEmailTestSetExpiry", null);
|
|
710
848
|
RuntimeResolver = __decorate([
|
|
711
849
|
Resolver()
|
|
712
850
|
], RuntimeResolver);
|
package/lib/src/schema.gql
CHANGED
|
@@ -358,6 +358,12 @@ type Mutation {
|
|
|
358
358
|
perspectiveUpdateLink(batchId: String, newLink: LinkInput!, oldLink: LinkExpressionInput!, uuid: String!): LinkExpression!
|
|
359
359
|
runtimeAddFriends(dids: [String!]!): [String!]!
|
|
360
360
|
runtimeAddKnownLinkLanguageTemplates(addresses: [String!]!): [String!]!
|
|
361
|
+
runtimeCreateUser(appInfo: AuthInfoInput, email: String!, password: String!): UserCreationResult!
|
|
362
|
+
runtimeEmailTestClearCodes: Boolean!
|
|
363
|
+
runtimeEmailTestGetCode(email: String!): String
|
|
364
|
+
runtimeEmailTestModeDisable: Boolean!
|
|
365
|
+
runtimeEmailTestModeEnable: Boolean!
|
|
366
|
+
runtimeEmailTestSetExpiry(email: String!, expiresAt: Float!, verificationType: String!): Boolean!
|
|
361
367
|
runtimeExportDb(filePath: String!): Boolean!
|
|
362
368
|
runtimeExportPerspective(filePath: String!, perspectiveUuid: String!): Boolean!
|
|
363
369
|
runtimeFriendSendMessage(did: String!, message: PerspectiveInput!): Boolean!
|
|
@@ -365,16 +371,20 @@ type Mutation {
|
|
|
365
371
|
runtimeHcAddAgentInfos(agentInfos: String!): Boolean!
|
|
366
372
|
runtimeImportDb(filePath: String!): Boolean!
|
|
367
373
|
runtimeImportPerspective(filePath: String!): Boolean!
|
|
374
|
+
runtimeLoginUser(email: String!, password: String!): String!
|
|
368
375
|
runtimeOpenLink(url: String!): Boolean!
|
|
369
376
|
runtimeQuit: Boolean!
|
|
370
377
|
runtimeRemoveFriends(dids: [String!]!): [String!]!
|
|
371
378
|
runtimeRemoveKnownLinkLanguageTemplates(addresses: [String!]!): [String!]!
|
|
372
379
|
runtimeRemoveNotification(id: String!): Boolean!
|
|
373
380
|
runtimeRequestInstallNotification(notification: NotificationInput!): String!
|
|
381
|
+
runtimeRequestLoginVerification(appInfo: AuthInfoInput, email: String!): VerificationRequestResult!
|
|
374
382
|
runtimeRestartHolochain: Boolean!
|
|
375
383
|
runtimeSetMultiUserEnabled(enabled: Boolean!): Boolean!
|
|
376
384
|
runtimeSetStatus(status: PerspectiveInput!): Boolean!
|
|
385
|
+
runtimeTestEmail(to: String!): Boolean!
|
|
377
386
|
runtimeUpdateNotification(id: String!, notification: NotificationInput!): Boolean!
|
|
387
|
+
runtimeVerifyEmailCode(code: String!, email: String!, verificationType: String!): String!
|
|
378
388
|
}
|
|
379
389
|
|
|
380
390
|
type Neighbourhood {
|
|
@@ -552,6 +562,12 @@ type TriggeredNotification {
|
|
|
552
562
|
triggerMatch: String!
|
|
553
563
|
}
|
|
554
564
|
|
|
565
|
+
type UserCreationResult {
|
|
566
|
+
did: String!
|
|
567
|
+
error: String
|
|
568
|
+
success: Boolean!
|
|
569
|
+
}
|
|
570
|
+
|
|
555
571
|
type UserStatistics {
|
|
556
572
|
did: String!
|
|
557
573
|
email: String!
|
|
@@ -559,6 +575,12 @@ type UserStatistics {
|
|
|
559
575
|
perspectiveCount: Int!
|
|
560
576
|
}
|
|
561
577
|
|
|
578
|
+
type VerificationRequestResult {
|
|
579
|
+
message: String!
|
|
580
|
+
requiresPassword: Boolean!
|
|
581
|
+
success: Boolean!
|
|
582
|
+
}
|
|
583
|
+
|
|
562
584
|
input VoiceActivityParamsInput {
|
|
563
585
|
endThreshold: Float
|
|
564
586
|
endWindow: Float
|
package/lib/src/typeDefs.js
CHANGED
|
@@ -354,6 +354,12 @@ type Mutation {
|
|
|
354
354
|
perspectiveUpdateLink(batchId: String, newLink: LinkInput!, oldLink: LinkExpressionInput!, uuid: String!): LinkExpression!
|
|
355
355
|
runtimeAddFriends(dids: [String!]!): [String!]!
|
|
356
356
|
runtimeAddKnownLinkLanguageTemplates(addresses: [String!]!): [String!]!
|
|
357
|
+
runtimeCreateUser(appInfo: AuthInfoInput, email: String!, password: String!): UserCreationResult!
|
|
358
|
+
runtimeEmailTestClearCodes: Boolean!
|
|
359
|
+
runtimeEmailTestGetCode(email: String!): String
|
|
360
|
+
runtimeEmailTestModeDisable: Boolean!
|
|
361
|
+
runtimeEmailTestModeEnable: Boolean!
|
|
362
|
+
runtimeEmailTestSetExpiry(email: String!, expiresAt: Float!, verificationType: String!): Boolean!
|
|
357
363
|
runtimeExportDb(filePath: String!): Boolean!
|
|
358
364
|
runtimeExportPerspective(filePath: String!, perspectiveUuid: String!): Boolean!
|
|
359
365
|
runtimeFriendSendMessage(did: String!, message: PerspectiveInput!): Boolean!
|
|
@@ -361,16 +367,20 @@ type Mutation {
|
|
|
361
367
|
runtimeHcAddAgentInfos(agentInfos: String!): Boolean!
|
|
362
368
|
runtimeImportDb(filePath: String!): Boolean!
|
|
363
369
|
runtimeImportPerspective(filePath: String!): Boolean!
|
|
370
|
+
runtimeLoginUser(email: String!, password: String!): String!
|
|
364
371
|
runtimeOpenLink(url: String!): Boolean!
|
|
365
372
|
runtimeQuit: Boolean!
|
|
366
373
|
runtimeRemoveFriends(dids: [String!]!): [String!]!
|
|
367
374
|
runtimeRemoveKnownLinkLanguageTemplates(addresses: [String!]!): [String!]!
|
|
368
375
|
runtimeRemoveNotification(id: String!): Boolean!
|
|
369
376
|
runtimeRequestInstallNotification(notification: NotificationInput!): String!
|
|
377
|
+
runtimeRequestLoginVerification(appInfo: AuthInfoInput, email: String!): VerificationRequestResult!
|
|
370
378
|
runtimeRestartHolochain: Boolean!
|
|
371
379
|
runtimeSetMultiUserEnabled(enabled: Boolean!): Boolean!
|
|
372
380
|
runtimeSetStatus(status: PerspectiveInput!): Boolean!
|
|
381
|
+
runtimeTestEmail(to: String!): Boolean!
|
|
373
382
|
runtimeUpdateNotification(id: String!, notification: NotificationInput!): Boolean!
|
|
383
|
+
runtimeVerifyEmailCode(code: String!, email: String!, verificationType: String!): String!
|
|
374
384
|
}
|
|
375
385
|
|
|
376
386
|
type Neighbourhood {
|
|
@@ -548,6 +558,12 @@ type TriggeredNotification {
|
|
|
548
558
|
triggerMatch: String!
|
|
549
559
|
}
|
|
550
560
|
|
|
561
|
+
type UserCreationResult {
|
|
562
|
+
did: String!
|
|
563
|
+
error: String
|
|
564
|
+
success: Boolean!
|
|
565
|
+
}
|
|
566
|
+
|
|
551
567
|
type UserStatistics {
|
|
552
568
|
did: String!
|
|
553
569
|
email: String!
|
|
@@ -555,6 +571,12 @@ type UserStatistics {
|
|
|
555
571
|
perspectiveCount: Int!
|
|
556
572
|
}
|
|
557
573
|
|
|
574
|
+
type VerificationRequestResult {
|
|
575
|
+
message: String!
|
|
576
|
+
requiresPassword: Boolean!
|
|
577
|
+
success: Boolean!
|
|
578
|
+
}
|
|
579
|
+
|
|
558
580
|
input VoiceActivityParamsInput {
|
|
559
581
|
endThreshold: Float
|
|
560
582
|
endWindow: Float
|
package/package.json
CHANGED
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
"module": "lib/index.js",
|
|
6
6
|
"types": "lib/src/index.d.ts",
|
|
7
7
|
"type": "module",
|
|
8
|
+
|
|
8
9
|
"scripts": {
|
|
9
10
|
"build": "patch-package && tsc && pnpm run buildSchema && pnpm run bundle",
|
|
10
11
|
"buildSchema": "node --es-module-specifier-resolution=node lib/src/buildSchema.js",
|
|
@@ -68,5 +69,5 @@
|
|
|
68
69
|
"graphql@15.7.2": "patches/graphql@15.7.2.patch"
|
|
69
70
|
}
|
|
70
71
|
},
|
|
71
|
-
"version": "0.11.2-dev-multi-user"
|
|
72
|
+
"version": "0.11.2-dev-multi-user-email"
|
|
72
73
|
}
|
package/src/agent/Agent.ts
CHANGED
|
@@ -292,23 +292,6 @@ export class AuthInfoInput {
|
|
|
292
292
|
}
|
|
293
293
|
}
|
|
294
294
|
|
|
295
|
-
@ObjectType()
|
|
296
|
-
export class User {
|
|
297
|
-
@Field()
|
|
298
|
-
username: string;
|
|
299
|
-
|
|
300
|
-
@Field()
|
|
301
|
-
did: string;
|
|
302
|
-
|
|
303
|
-
@Field()
|
|
304
|
-
password: string;
|
|
305
|
-
|
|
306
|
-
constructor(username: string, did: string, password: string) {
|
|
307
|
-
this.username = username;
|
|
308
|
-
this.did = did;
|
|
309
|
-
this.password = password;
|
|
310
|
-
}
|
|
311
|
-
}
|
|
312
295
|
|
|
313
296
|
@ObjectType()
|
|
314
297
|
export class UserCreationResult {
|
package/src/agent/AgentClient.ts
CHANGED
|
@@ -13,6 +13,7 @@ import {
|
|
|
13
13
|
import { AgentStatus } from "./AgentStatus";
|
|
14
14
|
import { LinkMutations } from "../links/Links";
|
|
15
15
|
import { PerspectiveClient } from "../perspectives/PerspectiveClient";
|
|
16
|
+
import { VerificationRequestResult } from "../runtime/RuntimeResolver";
|
|
16
17
|
|
|
17
18
|
const AGENT_SUBITEMS = `
|
|
18
19
|
did
|
|
@@ -531,17 +532,17 @@ export class AgentClient {
|
|
|
531
532
|
}
|
|
532
533
|
|
|
533
534
|
// Multi-user methods
|
|
534
|
-
async createUser(email: string, password: string): Promise<UserCreationResult> {
|
|
535
|
+
async createUser(email: string, password: string, appInfo?: AuthInfoInput): Promise<UserCreationResult> {
|
|
535
536
|
const { runtimeCreateUser } = unwrapApolloResult(
|
|
536
537
|
await this.#apolloClient.mutate({
|
|
537
|
-
mutation: gql`mutation runtimeCreateUser($email: String!, $password: String
|
|
538
|
-
runtimeCreateUser(email: $email, password: $password) {
|
|
538
|
+
mutation: gql`mutation runtimeCreateUser($email: String!, $password: String!, $appInfo: AuthInfoInput) {
|
|
539
|
+
runtimeCreateUser(email: $email, password: $password, appInfo: $appInfo) {
|
|
539
540
|
did
|
|
540
541
|
success
|
|
541
542
|
error
|
|
542
543
|
}
|
|
543
544
|
}`,
|
|
544
|
-
variables: { email, password },
|
|
545
|
+
variables: { email, password, appInfo },
|
|
545
546
|
})
|
|
546
547
|
);
|
|
547
548
|
return runtimeCreateUser;
|
|
@@ -558,4 +559,32 @@ export class AgentClient {
|
|
|
558
559
|
);
|
|
559
560
|
return runtimeLoginUser;
|
|
560
561
|
}
|
|
562
|
+
|
|
563
|
+
async requestLoginVerification(email: string, appInfo?: AuthInfoInput): Promise<VerificationRequestResult> {
|
|
564
|
+
const { runtimeRequestLoginVerification } = unwrapApolloResult(
|
|
565
|
+
await this.#apolloClient.mutate({
|
|
566
|
+
mutation: gql`mutation runtimeRequestLoginVerification($email: String!, $appInfo: AuthInfoInput) {
|
|
567
|
+
runtimeRequestLoginVerification(email: $email, appInfo: $appInfo) {
|
|
568
|
+
success
|
|
569
|
+
message
|
|
570
|
+
requiresPassword
|
|
571
|
+
}
|
|
572
|
+
}`,
|
|
573
|
+
variables: { email, appInfo },
|
|
574
|
+
})
|
|
575
|
+
);
|
|
576
|
+
return runtimeRequestLoginVerification;
|
|
577
|
+
}
|
|
578
|
+
|
|
579
|
+
async verifyEmailCode(email: string, code: string, verificationType: string): Promise<string> {
|
|
580
|
+
const { runtimeVerifyEmailCode } = unwrapApolloResult(
|
|
581
|
+
await this.#apolloClient.mutate({
|
|
582
|
+
mutation: gql`mutation runtimeVerifyEmailCode($email: String!, $code: String!, $verificationType: String!) {
|
|
583
|
+
runtimeVerifyEmailCode(email: $email, code: $code, verificationType: $verificationType)
|
|
584
|
+
}`,
|
|
585
|
+
variables: { email, code, verificationType },
|
|
586
|
+
})
|
|
587
|
+
);
|
|
588
|
+
return runtimeVerifyEmailCode;
|
|
589
|
+
}
|
|
561
590
|
}
|
|
@@ -419,6 +419,53 @@ export class RuntimeClient {
|
|
|
419
419
|
return runtimeListUsers
|
|
420
420
|
}
|
|
421
421
|
|
|
422
|
+
async emailTestModeEnable(): Promise<boolean> {
|
|
423
|
+
const { runtimeEmailTestModeEnable } = unwrapApolloResult(await this.#apolloClient.mutate({
|
|
424
|
+
mutation: gql`mutation runtimeEmailTestModeEnable {
|
|
425
|
+
runtimeEmailTestModeEnable
|
|
426
|
+
}`
|
|
427
|
+
}))
|
|
428
|
+
return runtimeEmailTestModeEnable
|
|
429
|
+
}
|
|
430
|
+
|
|
431
|
+
async emailTestModeDisable(): Promise<boolean> {
|
|
432
|
+
const { runtimeEmailTestModeDisable } = unwrapApolloResult(await this.#apolloClient.mutate({
|
|
433
|
+
mutation: gql`mutation runtimeEmailTestModeDisable {
|
|
434
|
+
runtimeEmailTestModeDisable
|
|
435
|
+
}`
|
|
436
|
+
}))
|
|
437
|
+
return runtimeEmailTestModeDisable
|
|
438
|
+
}
|
|
439
|
+
|
|
440
|
+
async emailTestGetCode(email: string): Promise<string | null> {
|
|
441
|
+
const { runtimeEmailTestGetCode } = unwrapApolloResult(await this.#apolloClient.mutate({
|
|
442
|
+
mutation: gql`mutation runtimeEmailTestGetCode($email: String!) {
|
|
443
|
+
runtimeEmailTestGetCode(email: $email)
|
|
444
|
+
}`,
|
|
445
|
+
variables: { email }
|
|
446
|
+
}))
|
|
447
|
+
return runtimeEmailTestGetCode
|
|
448
|
+
}
|
|
449
|
+
|
|
450
|
+
async emailTestClearCodes(): Promise<boolean> {
|
|
451
|
+
const { runtimeEmailTestClearCodes } = unwrapApolloResult(await this.#apolloClient.mutate({
|
|
452
|
+
mutation: gql`mutation runtimeEmailTestClearCodes {
|
|
453
|
+
runtimeEmailTestClearCodes
|
|
454
|
+
}`
|
|
455
|
+
}))
|
|
456
|
+
return runtimeEmailTestClearCodes
|
|
457
|
+
}
|
|
458
|
+
|
|
459
|
+
async emailTestSetExpiry(email: string, verificationType: string, expiresAt: number): Promise<boolean> {
|
|
460
|
+
const { runtimeEmailTestSetExpiry } = unwrapApolloResult(await this.#apolloClient.mutate({
|
|
461
|
+
mutation: gql`mutation runtimeEmailTestSetExpiry($email: String!, $verificationType: String!, $expiresAt: Int!) {
|
|
462
|
+
runtimeEmailTestSetExpiry(email: $email, verificationType: $verificationType, expiresAt: $expiresAt)
|
|
463
|
+
}`,
|
|
464
|
+
variables: { email, verificationType, expiresAt }
|
|
465
|
+
}))
|
|
466
|
+
return runtimeEmailTestSetExpiry
|
|
467
|
+
}
|
|
468
|
+
|
|
422
469
|
addNotificationTriggeredCallback(cb: NotificationTriggeredCallback) {
|
|
423
470
|
this.#notificationTriggeredCallbacks.push(cb)
|
|
424
471
|
}
|