@coasys/ad4m 0.11.2-dev-multi-user → 0.11.2-dev-multi-user-email-2
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 +233 -27
- package/lib/index.js +234 -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 +27 -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 +17 -0
- package/lib/src/runtime/RuntimeResolver.js +143 -0
- package/lib/src/schema.gql +23 -0
- package/lib/src/typeDefs.js +23 -0
- package/package.json +2 -1
- package/src/agent/Agent.ts +0 -17
- package/src/agent/AgentClient.ts +34 -4
- package/src/runtime/RuntimeClient.ts +47 -0
- package/src/runtime/RuntimeResolver.ts +99 -0
|
@@ -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,28 @@ 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
|
+
__decorate([
|
|
311
|
+
Field(),
|
|
312
|
+
__metadata("design:type", Boolean)
|
|
313
|
+
], VerificationRequestResult.prototype, "isExistingUser", void 0);
|
|
314
|
+
VerificationRequestResult = __decorate([
|
|
315
|
+
ObjectType()
|
|
316
|
+
], VerificationRequestResult);
|
|
317
|
+
export { VerificationRequestResult };
|
|
295
318
|
/**
|
|
296
319
|
* Resolver classes are used here to define the GraphQL schema
|
|
297
320
|
* (through the type-graphql annotations)
|
|
@@ -455,6 +478,51 @@ let RuntimeResolver = class RuntimeResolver {
|
|
|
455
478
|
perspectiveCount: 5
|
|
456
479
|
}];
|
|
457
480
|
}
|
|
481
|
+
runtimeRequestLoginVerification(email, appInfo) {
|
|
482
|
+
// For testing: simulate existing user
|
|
483
|
+
return {
|
|
484
|
+
success: true,
|
|
485
|
+
message: "Verification email sent",
|
|
486
|
+
requiresPassword: false,
|
|
487
|
+
isExistingUser: true
|
|
488
|
+
};
|
|
489
|
+
}
|
|
490
|
+
runtimeVerifyEmailCode(email, code, verificationType) {
|
|
491
|
+
// For testing: return a test JWT token
|
|
492
|
+
return "test-jwt-token-from-email-verification";
|
|
493
|
+
}
|
|
494
|
+
runtimeTestEmail(to) {
|
|
495
|
+
// For testing: simulate successful email send
|
|
496
|
+
return true;
|
|
497
|
+
}
|
|
498
|
+
runtimeCreateUser(email, password, appInfo) {
|
|
499
|
+
// For testing: simulate successful user creation (email verification flow)
|
|
500
|
+
return new UserCreationResult("did:key:test123", true);
|
|
501
|
+
}
|
|
502
|
+
runtimeLoginUser(email, password) {
|
|
503
|
+
// For testing: return a test JWT token
|
|
504
|
+
return "test-jwt-token-from-password-login";
|
|
505
|
+
}
|
|
506
|
+
runtimeEmailTestModeEnable() {
|
|
507
|
+
// For testing: enable test mode
|
|
508
|
+
return true;
|
|
509
|
+
}
|
|
510
|
+
runtimeEmailTestModeDisable() {
|
|
511
|
+
// For testing: disable test mode
|
|
512
|
+
return true;
|
|
513
|
+
}
|
|
514
|
+
runtimeEmailTestGetCode(email) {
|
|
515
|
+
// For testing: return a mock code
|
|
516
|
+
return "123456";
|
|
517
|
+
}
|
|
518
|
+
runtimeEmailTestClearCodes() {
|
|
519
|
+
// For testing: clear codes
|
|
520
|
+
return true;
|
|
521
|
+
}
|
|
522
|
+
runtimeEmailTestSetExpiry(email, verificationType, expiresAt) {
|
|
523
|
+
// For testing: simulate setting expiry (no-op in mock)
|
|
524
|
+
return true;
|
|
525
|
+
}
|
|
458
526
|
};
|
|
459
527
|
__decorate([
|
|
460
528
|
Mutation(returns => Boolean),
|
|
@@ -707,6 +775,81 @@ __decorate([
|
|
|
707
775
|
__metadata("design:paramtypes", []),
|
|
708
776
|
__metadata("design:returntype", Array)
|
|
709
777
|
], RuntimeResolver.prototype, "runtimeListUsers", null);
|
|
778
|
+
__decorate([
|
|
779
|
+
Mutation(returns => VerificationRequestResult),
|
|
780
|
+
__param(0, Arg("email")),
|
|
781
|
+
__param(1, Arg("appInfo", { nullable: true })),
|
|
782
|
+
__metadata("design:type", Function),
|
|
783
|
+
__metadata("design:paramtypes", [String, AuthInfoInput]),
|
|
784
|
+
__metadata("design:returntype", VerificationRequestResult)
|
|
785
|
+
], RuntimeResolver.prototype, "runtimeRequestLoginVerification", null);
|
|
786
|
+
__decorate([
|
|
787
|
+
Mutation(returns => String),
|
|
788
|
+
__param(0, Arg("email")),
|
|
789
|
+
__param(1, Arg("code")),
|
|
790
|
+
__param(2, Arg("verificationType")),
|
|
791
|
+
__metadata("design:type", Function),
|
|
792
|
+
__metadata("design:paramtypes", [String, String, String]),
|
|
793
|
+
__metadata("design:returntype", String)
|
|
794
|
+
], RuntimeResolver.prototype, "runtimeVerifyEmailCode", null);
|
|
795
|
+
__decorate([
|
|
796
|
+
Mutation(returns => Boolean),
|
|
797
|
+
__param(0, Arg("to")),
|
|
798
|
+
__metadata("design:type", Function),
|
|
799
|
+
__metadata("design:paramtypes", [String]),
|
|
800
|
+
__metadata("design:returntype", Boolean)
|
|
801
|
+
], RuntimeResolver.prototype, "runtimeTestEmail", null);
|
|
802
|
+
__decorate([
|
|
803
|
+
Mutation(returns => UserCreationResult),
|
|
804
|
+
__param(0, Arg("email")),
|
|
805
|
+
__param(1, Arg("password")),
|
|
806
|
+
__param(2, Arg("appInfo", { nullable: true })),
|
|
807
|
+
__metadata("design:type", Function),
|
|
808
|
+
__metadata("design:paramtypes", [String, String, AuthInfoInput]),
|
|
809
|
+
__metadata("design:returntype", UserCreationResult)
|
|
810
|
+
], RuntimeResolver.prototype, "runtimeCreateUser", null);
|
|
811
|
+
__decorate([
|
|
812
|
+
Mutation(returns => String),
|
|
813
|
+
__param(0, Arg("email")),
|
|
814
|
+
__param(1, Arg("password")),
|
|
815
|
+
__metadata("design:type", Function),
|
|
816
|
+
__metadata("design:paramtypes", [String, String]),
|
|
817
|
+
__metadata("design:returntype", String)
|
|
818
|
+
], RuntimeResolver.prototype, "runtimeLoginUser", null);
|
|
819
|
+
__decorate([
|
|
820
|
+
Mutation(returns => Boolean),
|
|
821
|
+
__metadata("design:type", Function),
|
|
822
|
+
__metadata("design:paramtypes", []),
|
|
823
|
+
__metadata("design:returntype", Boolean)
|
|
824
|
+
], RuntimeResolver.prototype, "runtimeEmailTestModeEnable", null);
|
|
825
|
+
__decorate([
|
|
826
|
+
Mutation(returns => Boolean),
|
|
827
|
+
__metadata("design:type", Function),
|
|
828
|
+
__metadata("design:paramtypes", []),
|
|
829
|
+
__metadata("design:returntype", Boolean)
|
|
830
|
+
], RuntimeResolver.prototype, "runtimeEmailTestModeDisable", null);
|
|
831
|
+
__decorate([
|
|
832
|
+
Mutation(returns => String, { nullable: true }),
|
|
833
|
+
__param(0, Arg("email")),
|
|
834
|
+
__metadata("design:type", Function),
|
|
835
|
+
__metadata("design:paramtypes", [String]),
|
|
836
|
+
__metadata("design:returntype", String)
|
|
837
|
+
], RuntimeResolver.prototype, "runtimeEmailTestGetCode", null);
|
|
838
|
+
__decorate([
|
|
839
|
+
Mutation(returns => Boolean),
|
|
840
|
+
__metadata("design:type", Function),
|
|
841
|
+
__metadata("design:paramtypes", []),
|
|
842
|
+
__metadata("design:returntype", Boolean)
|
|
843
|
+
], RuntimeResolver.prototype, "runtimeEmailTestClearCodes", null);
|
|
844
|
+
__decorate([
|
|
845
|
+
Mutation(returns => Boolean),
|
|
846
|
+
__param(0, Arg("email")),
|
|
847
|
+
__param(1, Arg("verificationType")),
|
|
848
|
+
__param(2, Arg("expiresAt")),
|
|
849
|
+
__metadata("design:type", Function),
|
|
850
|
+
__metadata("design:paramtypes", [String, String, Number]),
|
|
851
|
+
__metadata("design:returntype", Boolean)
|
|
852
|
+
], RuntimeResolver.prototype, "runtimeEmailTestSetExpiry", null);
|
|
710
853
|
RuntimeResolver = __decorate([
|
|
711
854
|
Resolver()
|
|
712
855
|
], 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,13 @@ type UserStatistics {
|
|
|
559
575
|
perspectiveCount: Int!
|
|
560
576
|
}
|
|
561
577
|
|
|
578
|
+
type VerificationRequestResult {
|
|
579
|
+
isExistingUser: Boolean!
|
|
580
|
+
message: String!
|
|
581
|
+
requiresPassword: Boolean!
|
|
582
|
+
success: Boolean!
|
|
583
|
+
}
|
|
584
|
+
|
|
562
585
|
input VoiceActivityParamsInput {
|
|
563
586
|
endThreshold: Float
|
|
564
587
|
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,13 @@ type UserStatistics {
|
|
|
555
571
|
perspectiveCount: Int!
|
|
556
572
|
}
|
|
557
573
|
|
|
574
|
+
type VerificationRequestResult {
|
|
575
|
+
isExistingUser: Boolean!
|
|
576
|
+
message: String!
|
|
577
|
+
requiresPassword: Boolean!
|
|
578
|
+
success: Boolean!
|
|
579
|
+
}
|
|
580
|
+
|
|
558
581
|
input VoiceActivityParamsInput {
|
|
559
582
|
endThreshold: Float
|
|
560
583
|
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-2"
|
|
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,33 @@ 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
|
+
isExistingUser
|
|
572
|
+
}
|
|
573
|
+
}`,
|
|
574
|
+
variables: { email, appInfo },
|
|
575
|
+
})
|
|
576
|
+
);
|
|
577
|
+
return runtimeRequestLoginVerification;
|
|
578
|
+
}
|
|
579
|
+
|
|
580
|
+
async verifyEmailCode(email: string, code: string, verificationType: string): Promise<string> {
|
|
581
|
+
const { runtimeVerifyEmailCode } = unwrapApolloResult(
|
|
582
|
+
await this.#apolloClient.mutate({
|
|
583
|
+
mutation: gql`mutation runtimeVerifyEmailCode($email: String!, $code: String!, $verificationType: String!) {
|
|
584
|
+
runtimeVerifyEmailCode(email: $email, code: $code, verificationType: $verificationType)
|
|
585
|
+
}`,
|
|
586
|
+
variables: { email, code, verificationType },
|
|
587
|
+
})
|
|
588
|
+
);
|
|
589
|
+
return runtimeVerifyEmailCode;
|
|
590
|
+
}
|
|
561
591
|
}
|
|
@@ -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
|
}
|
|
@@ -4,6 +4,7 @@ import { ExpressionProof } from "../expression/Expression";
|
|
|
4
4
|
import { LinkExpression } from "../links/Links";
|
|
5
5
|
import { ExceptionType } from "../Exception";
|
|
6
6
|
import { RUNTIME_MESSAGED_RECEIVED_TOPIC, EXCEPTION_OCCURRED_TOPIC, RUNTIME_NOTIFICATION_REQUESTED_TOPIC, RUNTIME_NOTIFICATION_TRIGGERED_TOPIC } from '../PubSub';
|
|
7
|
+
import { UserCreationResult, AuthInfoInput } from "../agent/Agent";
|
|
7
8
|
|
|
8
9
|
const testLink = new LinkExpression()
|
|
9
10
|
testLink.author = "did:ad4m:test"
|
|
@@ -207,6 +208,21 @@ export class UserStatistics {
|
|
|
207
208
|
perspectiveCount: number;
|
|
208
209
|
}
|
|
209
210
|
|
|
211
|
+
@ObjectType()
|
|
212
|
+
export class VerificationRequestResult {
|
|
213
|
+
@Field()
|
|
214
|
+
success: boolean;
|
|
215
|
+
|
|
216
|
+
@Field()
|
|
217
|
+
message: string;
|
|
218
|
+
|
|
219
|
+
@Field()
|
|
220
|
+
requiresPassword: boolean;
|
|
221
|
+
|
|
222
|
+
@Field()
|
|
223
|
+
isExistingUser: boolean;
|
|
224
|
+
}
|
|
225
|
+
|
|
210
226
|
/**
|
|
211
227
|
* Resolver classes are used here to define the GraphQL schema
|
|
212
228
|
* (through the type-graphql annotations)
|
|
@@ -461,5 +477,88 @@ export default class RuntimeResolver {
|
|
|
461
477
|
perspectiveCount: 5
|
|
462
478
|
}]
|
|
463
479
|
}
|
|
480
|
+
|
|
481
|
+
@Mutation(returns => VerificationRequestResult)
|
|
482
|
+
runtimeRequestLoginVerification(
|
|
483
|
+
@Arg("email") email: string,
|
|
484
|
+
@Arg("appInfo", { nullable: true }) appInfo?: AuthInfoInput
|
|
485
|
+
): VerificationRequestResult {
|
|
486
|
+
// For testing: simulate existing user
|
|
487
|
+
return {
|
|
488
|
+
success: true,
|
|
489
|
+
message: "Verification email sent",
|
|
490
|
+
requiresPassword: false,
|
|
491
|
+
isExistingUser: true
|
|
492
|
+
}
|
|
493
|
+
}
|
|
494
|
+
|
|
495
|
+
@Mutation(returns => String)
|
|
496
|
+
runtimeVerifyEmailCode(
|
|
497
|
+
@Arg("email") email: string,
|
|
498
|
+
@Arg("code") code: string,
|
|
499
|
+
@Arg("verificationType") verificationType: string
|
|
500
|
+
): string {
|
|
501
|
+
// For testing: return a test JWT token
|
|
502
|
+
return "test-jwt-token-from-email-verification"
|
|
503
|
+
}
|
|
504
|
+
|
|
505
|
+
@Mutation(returns => Boolean)
|
|
506
|
+
runtimeTestEmail(@Arg("to") to: string): boolean {
|
|
507
|
+
// For testing: simulate successful email send
|
|
508
|
+
return true
|
|
509
|
+
}
|
|
510
|
+
|
|
511
|
+
@Mutation(returns => UserCreationResult)
|
|
512
|
+
runtimeCreateUser(
|
|
513
|
+
@Arg("email") email: string,
|
|
514
|
+
@Arg("password") password: string,
|
|
515
|
+
@Arg("appInfo", { nullable: true }) appInfo?: AuthInfoInput
|
|
516
|
+
): UserCreationResult {
|
|
517
|
+
// For testing: simulate successful user creation (email verification flow)
|
|
518
|
+
return new UserCreationResult("did:key:test123", true)
|
|
519
|
+
}
|
|
520
|
+
|
|
521
|
+
@Mutation(returns => String)
|
|
522
|
+
runtimeLoginUser(
|
|
523
|
+
@Arg("email") email: string,
|
|
524
|
+
@Arg("password") password: string
|
|
525
|
+
): string {
|
|
526
|
+
// For testing: return a test JWT token
|
|
527
|
+
return "test-jwt-token-from-password-login"
|
|
528
|
+
}
|
|
529
|
+
|
|
530
|
+
@Mutation(returns => Boolean)
|
|
531
|
+
runtimeEmailTestModeEnable(): boolean {
|
|
532
|
+
// For testing: enable test mode
|
|
533
|
+
return true
|
|
534
|
+
}
|
|
535
|
+
|
|
536
|
+
@Mutation(returns => Boolean)
|
|
537
|
+
runtimeEmailTestModeDisable(): boolean {
|
|
538
|
+
// For testing: disable test mode
|
|
539
|
+
return true
|
|
540
|
+
}
|
|
541
|
+
|
|
542
|
+
@Mutation(returns => String, { nullable: true })
|
|
543
|
+
runtimeEmailTestGetCode(@Arg("email") email: string): string | null {
|
|
544
|
+
// For testing: return a mock code
|
|
545
|
+
return "123456"
|
|
546
|
+
}
|
|
547
|
+
|
|
548
|
+
@Mutation(returns => Boolean)
|
|
549
|
+
runtimeEmailTestClearCodes(): boolean {
|
|
550
|
+
// For testing: clear codes
|
|
551
|
+
return true
|
|
552
|
+
}
|
|
553
|
+
|
|
554
|
+
@Mutation(returns => Boolean)
|
|
555
|
+
runtimeEmailTestSetExpiry(
|
|
556
|
+
@Arg("email") email: string,
|
|
557
|
+
@Arg("verificationType") verificationType: string,
|
|
558
|
+
@Arg("expiresAt") expiresAt: number
|
|
559
|
+
): boolean {
|
|
560
|
+
// For testing: simulate setting expiry (no-op in mock)
|
|
561
|
+
return true
|
|
562
|
+
}
|
|
464
563
|
}
|
|
465
564
|
|