@coasys/ad4m 0.11.1 → 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.
@@ -1,6 +1,6 @@
1
1
  import { ApolloClient } from "@apollo/client/core";
2
2
  import { Perspective, PerspectiveExpression } from "../perspectives/Perspective";
3
- import { RuntimeInfo, ExceptionInfo, SentMessage, NotificationInput, Notification, TriggeredNotification, ImportResult } from "./RuntimeResolver";
3
+ import { RuntimeInfo, ExceptionInfo, SentMessage, NotificationInput, Notification, TriggeredNotification, ImportResult, UserStatistics } from "./RuntimeResolver";
4
4
  export type MessageCallback = (message: PerspectiveExpression) => null;
5
5
  export type ExceptionCallback = (info: ExceptionInfo) => null;
6
6
  export type NotificationTriggeredCallback = (notification: TriggeredNotification) => null;
@@ -39,6 +39,14 @@ export declare class RuntimeClient {
39
39
  removeNotification(id: string): Promise<boolean>;
40
40
  exportPerspective(uuid: string, filePath: string): Promise<boolean>;
41
41
  importPerspective(filePath: string): Promise<boolean>;
42
+ multiUserEnabled(): Promise<boolean>;
43
+ setMultiUserEnabled(enabled: boolean): Promise<boolean>;
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>;
42
50
  addNotificationTriggeredCallback(cb: NotificationTriggeredCallback): void;
43
51
  subscribeNotificationTriggered(): void;
44
52
  addMessageCallback(cb: MessageCallback): void;
@@ -351,6 +351,78 @@ export class RuntimeClient {
351
351
  }));
352
352
  return runtimeImportPerspective;
353
353
  }
354
+ async multiUserEnabled() {
355
+ const { runtimeMultiUserEnabled } = unwrapApolloResult(await __classPrivateFieldGet(this, _RuntimeClient_apolloClient, "f").query({
356
+ query: gql `query runtimeMultiUserEnabled {
357
+ runtimeMultiUserEnabled
358
+ }`,
359
+ }));
360
+ return runtimeMultiUserEnabled;
361
+ }
362
+ async setMultiUserEnabled(enabled) {
363
+ const { runtimeSetMultiUserEnabled } = unwrapApolloResult(await __classPrivateFieldGet(this, _RuntimeClient_apolloClient, "f").mutate({
364
+ mutation: gql `mutation runtimeSetMultiUserEnabled($enabled: Boolean!) {
365
+ runtimeSetMultiUserEnabled(enabled: $enabled)
366
+ }`,
367
+ variables: { enabled }
368
+ }));
369
+ return runtimeSetMultiUserEnabled;
370
+ }
371
+ async listUsers() {
372
+ const { runtimeListUsers } = unwrapApolloResult(await __classPrivateFieldGet(this, _RuntimeClient_apolloClient, "f").query({
373
+ query: gql `query runtimeListUsers {
374
+ runtimeListUsers {
375
+ email
376
+ did
377
+ lastSeen
378
+ perspectiveCount
379
+ }
380
+ }`
381
+ }));
382
+ return runtimeListUsers;
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
+ }
354
426
  addNotificationTriggeredCallback(cb) {
355
427
  __classPrivateFieldGet(this, _RuntimeClient_notificationTriggeredCallbacks, "f").push(cb);
356
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;
@@ -62,6 +63,17 @@ export declare class ImportResult {
62
63
  trustedAgents: ImportStats;
63
64
  knownLinkLanguages: ImportStats;
64
65
  }
66
+ export declare class UserStatistics {
67
+ email: string;
68
+ did: string;
69
+ lastSeen?: string;
70
+ perspectiveCount: number;
71
+ }
72
+ export declare class VerificationRequestResult {
73
+ success: boolean;
74
+ message: string;
75
+ requiresPassword: boolean;
76
+ }
65
77
  /**
66
78
  * Resolver classes are used here to define the GraphQL schema
67
79
  * (through the type-graphql annotations)
@@ -103,4 +115,17 @@ export default class RuntimeResolver {
103
115
  runtimeImportDb(filePath: string): boolean;
104
116
  runtimeExportPerspective(perspectiveUuid: string, filePath: string): boolean;
105
117
  runtimeImportPerspective(filePath: string): boolean;
118
+ runtimeMultiUserEnabled(): boolean;
119
+ runtimeSetMultiUserEnabled(enabled: boolean): boolean;
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;
106
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();
@@ -270,6 +271,46 @@ ImportResult = __decorate([
270
271
  ObjectType()
271
272
  ], ImportResult);
272
273
  export { ImportResult };
274
+ let UserStatistics = class UserStatistics {
275
+ };
276
+ __decorate([
277
+ Field(),
278
+ __metadata("design:type", String)
279
+ ], UserStatistics.prototype, "email", void 0);
280
+ __decorate([
281
+ Field(),
282
+ __metadata("design:type", String)
283
+ ], UserStatistics.prototype, "did", void 0);
284
+ __decorate([
285
+ Field({ nullable: true }),
286
+ __metadata("design:type", String)
287
+ ], UserStatistics.prototype, "lastSeen", void 0);
288
+ __decorate([
289
+ Field(type => Int),
290
+ __metadata("design:type", Number)
291
+ ], UserStatistics.prototype, "perspectiveCount", void 0);
292
+ UserStatistics = __decorate([
293
+ ObjectType()
294
+ ], UserStatistics);
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 };
273
314
  /**
274
315
  * Resolver classes are used here to define the GraphQL schema
275
316
  * (through the type-graphql annotations)
@@ -419,6 +460,64 @@ let RuntimeResolver = class RuntimeResolver {
419
460
  runtimeImportPerspective(filePath) {
420
461
  return true;
421
462
  }
463
+ runtimeMultiUserEnabled() {
464
+ return false;
465
+ }
466
+ runtimeSetMultiUserEnabled(enabled) {
467
+ return enabled;
468
+ }
469
+ runtimeListUsers() {
470
+ return [{
471
+ email: "test@example.com",
472
+ did: "did:key:test123",
473
+ lastSeen: new Date().toISOString(),
474
+ perspectiveCount: 5
475
+ }];
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
+ }
422
521
  };
423
522
  __decorate([
424
523
  Mutation(returns => Boolean),
@@ -652,6 +751,100 @@ __decorate([
652
751
  __metadata("design:paramtypes", [String]),
653
752
  __metadata("design:returntype", Boolean)
654
753
  ], RuntimeResolver.prototype, "runtimeImportPerspective", null);
754
+ __decorate([
755
+ Query(returns => Boolean),
756
+ __metadata("design:type", Function),
757
+ __metadata("design:paramtypes", []),
758
+ __metadata("design:returntype", Boolean)
759
+ ], RuntimeResolver.prototype, "runtimeMultiUserEnabled", null);
760
+ __decorate([
761
+ Mutation(returns => Boolean),
762
+ __param(0, Arg("enabled")),
763
+ __metadata("design:type", Function),
764
+ __metadata("design:paramtypes", [Boolean]),
765
+ __metadata("design:returntype", Boolean)
766
+ ], RuntimeResolver.prototype, "runtimeSetMultiUserEnabled", null);
767
+ __decorate([
768
+ Query(returns => [UserStatistics]),
769
+ __metadata("design:type", Function),
770
+ __metadata("design:paramtypes", []),
771
+ __metadata("design:returntype", Array)
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);
655
848
  RuntimeResolver = __decorate([
656
849
  Resolver()
657
850
  ], RuntimeResolver);
@@ -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,15 +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!
383
+ runtimeSetMultiUserEnabled(enabled: Boolean!): Boolean!
375
384
  runtimeSetStatus(status: PerspectiveInput!): Boolean!
385
+ runtimeTestEmail(to: String!): Boolean!
376
386
  runtimeUpdateNotification(id: String!, notification: NotificationInput!): Boolean!
387
+ runtimeVerifyEmailCode(code: String!, email: String!, verificationType: String!): String!
377
388
  }
378
389
 
379
390
  type Neighbourhood {
@@ -431,6 +442,7 @@ type PerspectiveExpression {
431
442
  type PerspectiveHandle {
432
443
  name: String!
433
444
  neighbourhood: NeighbourhoodExpression
445
+ owners: [String!]
434
446
  sharedUrl: String
435
447
  state: String!
436
448
  uuid: String!
@@ -479,8 +491,10 @@ type Query {
479
491
  runtimeHcAgentInfos: String!
480
492
  runtimeInfo: RuntimeInfo!
481
493
  runtimeKnownLinkLanguageTemplates: [String!]!
494
+ runtimeListUsers: [UserStatistics!]!
482
495
  runtimeMessageInbox(filter: String): [PerspectiveExpression!]!
483
496
  runtimeMessageOutbox(filter: String): [SentMessage!]!
497
+ runtimeMultiUserEnabled: Boolean!
484
498
  runtimeNotifications: [Notification!]!
485
499
  runtimeVerifyStringSignedByDid(data: String!, did: String!, didSigningKeyId: String!, signedData: String!): Boolean!
486
500
  }
@@ -548,6 +562,25 @@ type TriggeredNotification {
548
562
  triggerMatch: String!
549
563
  }
550
564
 
565
+ type UserCreationResult {
566
+ did: String!
567
+ error: String
568
+ success: Boolean!
569
+ }
570
+
571
+ type UserStatistics {
572
+ did: String!
573
+ email: String!
574
+ lastSeen: String
575
+ perspectiveCount: Int!
576
+ }
577
+
578
+ type VerificationRequestResult {
579
+ message: String!
580
+ requiresPassword: Boolean!
581
+ success: Boolean!
582
+ }
583
+
551
584
  input VoiceActivityParamsInput {
552
585
  endThreshold: Float
553
586
  endWindow: Float
@@ -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,15 +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!
379
+ runtimeSetMultiUserEnabled(enabled: Boolean!): Boolean!
371
380
  runtimeSetStatus(status: PerspectiveInput!): Boolean!
381
+ runtimeTestEmail(to: String!): Boolean!
372
382
  runtimeUpdateNotification(id: String!, notification: NotificationInput!): Boolean!
383
+ runtimeVerifyEmailCode(code: String!, email: String!, verificationType: String!): String!
373
384
  }
374
385
 
375
386
  type Neighbourhood {
@@ -427,6 +438,7 @@ type PerspectiveExpression {
427
438
  type PerspectiveHandle {
428
439
  name: String!
429
440
  neighbourhood: NeighbourhoodExpression
441
+ owners: [String!]
430
442
  sharedUrl: String
431
443
  state: String!
432
444
  uuid: String!
@@ -475,8 +487,10 @@ type Query {
475
487
  runtimeHcAgentInfos: String!
476
488
  runtimeInfo: RuntimeInfo!
477
489
  runtimeKnownLinkLanguageTemplates: [String!]!
490
+ runtimeListUsers: [UserStatistics!]!
478
491
  runtimeMessageInbox(filter: String): [PerspectiveExpression!]!
479
492
  runtimeMessageOutbox(filter: String): [SentMessage!]!
493
+ runtimeMultiUserEnabled: Boolean!
480
494
  runtimeNotifications: [Notification!]!
481
495
  runtimeVerifyStringSignedByDid(data: String!, did: String!, didSigningKeyId: String!, signedData: String!): Boolean!
482
496
  }
@@ -544,6 +558,25 @@ type TriggeredNotification {
544
558
  triggerMatch: String!
545
559
  }
546
560
 
561
+ type UserCreationResult {
562
+ did: String!
563
+ error: String
564
+ success: Boolean!
565
+ }
566
+
567
+ type UserStatistics {
568
+ did: String!
569
+ email: String!
570
+ lastSeen: String
571
+ perspectiveCount: Int!
572
+ }
573
+
574
+ type VerificationRequestResult {
575
+ message: String!
576
+ requiresPassword: Boolean!
577
+ success: Boolean!
578
+ }
579
+
547
580
  input VoiceActivityParamsInput {
548
581
  endThreshold: Float
549
582
  endWindow: Float
package/package.json CHANGED
@@ -5,7 +5,7 @@
5
5
  "module": "lib/index.js",
6
6
  "types": "lib/src/index.d.ts",
7
7
  "type": "module",
8
- "private": false,
8
+
9
9
  "scripts": {
10
10
  "build": "patch-package && tsc && pnpm run buildSchema && pnpm run bundle",
11
11
  "buildSchema": "node --es-module-specifier-resolution=node lib/src/buildSchema.js",
@@ -69,5 +69,5 @@
69
69
  "graphql@15.7.2": "patches/graphql@15.7.2.patch"
70
70
  }
71
71
  },
72
- "version": "0.11.1"
72
+ "version": "0.11.2-dev-multi-user-email"
73
73
  }
@@ -291,3 +291,22 @@ export class AuthInfoInput {
291
291
  this.appIconPath = appIconPath;
292
292
  }
293
293
  }
294
+
295
+
296
+ @ObjectType()
297
+ export class UserCreationResult {
298
+ @Field()
299
+ did: string;
300
+
301
+ @Field()
302
+ success: boolean;
303
+
304
+ @Field({ nullable: true })
305
+ error?: string;
306
+
307
+ constructor(did: string, success: boolean, error?: string) {
308
+ this.did = did;
309
+ this.success = success;
310
+ this.error = error;
311
+ }
312
+ }
@@ -8,10 +8,12 @@ import {
8
8
  AuthInfoInput,
9
9
  EntanglementProof,
10
10
  EntanglementProofInput,
11
+ UserCreationResult,
11
12
  } from "./Agent";
12
13
  import { AgentStatus } from "./AgentStatus";
13
14
  import { LinkMutations } from "../links/Links";
14
15
  import { PerspectiveClient } from "../perspectives/PerspectiveClient";
16
+ import { VerificationRequestResult } from "../runtime/RuntimeResolver";
15
17
 
16
18
  const AGENT_SUBITEMS = `
17
19
  did
@@ -528,4 +530,61 @@ export class AgentClient {
528
530
  );
529
531
  return agentSignMessage;
530
532
  }
533
+
534
+ // Multi-user methods
535
+ async createUser(email: string, password: string, appInfo?: AuthInfoInput): Promise<UserCreationResult> {
536
+ const { runtimeCreateUser } = unwrapApolloResult(
537
+ await this.#apolloClient.mutate({
538
+ mutation: gql`mutation runtimeCreateUser($email: String!, $password: String!, $appInfo: AuthInfoInput) {
539
+ runtimeCreateUser(email: $email, password: $password, appInfo: $appInfo) {
540
+ did
541
+ success
542
+ error
543
+ }
544
+ }`,
545
+ variables: { email, password, appInfo },
546
+ })
547
+ );
548
+ return runtimeCreateUser;
549
+ }
550
+
551
+ async loginUser(email: string, password: string): Promise<string> {
552
+ const { runtimeLoginUser } = unwrapApolloResult(
553
+ await this.#apolloClient.mutate({
554
+ mutation: gql`mutation runtimeLoginUser($email: String!, $password: String!) {
555
+ runtimeLoginUser(email: $email, password: $password)
556
+ }`,
557
+ variables: { email, password },
558
+ })
559
+ );
560
+ return runtimeLoginUser;
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
+ }
531
590
  }
@@ -168,10 +168,10 @@ export interface LinkSyncAdapter {
168
168
  /** What revision are we on now -> what changes are included in output of render() */
169
169
  currentRevision(): Promise<string>;
170
170
 
171
- /**
172
- * Check for and get new changes,
171
+ /**
172
+ * Check for and get new changes,
173
173
  * notify others of local changes.
174
- * This function will be called every
174
+ * This function will be called every
175
175
  * few seconds by the ad4m-executor.
176
176
  * */
177
177
  sync(): Promise<PerspectiveDiff>;
@@ -187,6 +187,18 @@ export interface LinkSyncAdapter {
187
187
 
188
188
  /** Add a sync state callback method */
189
189
  addSyncStateChangeCallback(callback: SyncStateChangeObserver);
190
+
191
+ /**
192
+ * Set the local agents (DIDs) that own this perspective/neighbourhood.
193
+ * This is used to determine which agents should be registered in the DHT.
194
+ * Optional - if not implemented, all local agents may be registered.
195
+ *
196
+ * This is a temporary hack to support multiple users on one node joining the same neighbourhood.
197
+ * Once we migrate the LanguageController to Rust and run Languages per user, each user will get their
198
+ * own language instance and we won't need to explicitly set local agents. This will provide better
199
+ * isolation and avoid the need to share language state between users.
200
+ */
201
+ setLocalAgents?(agents: DID[]): void;
190
202
  }
191
203
 
192
204
  export type MessageCallback = (message: PerspectiveExpression) => void;
@@ -255,7 +267,7 @@ export class OnlineAgent {
255
267
  status: PerspectiveExpression
256
268
  }
257
269
 
258
- export type TelepresenceSignalCallback = (payload: PerspectiveExpression) => void;
270
+ export type TelepresenceSignalCallback = (payload: PerspectiveExpression, recipientDid?: string) => void;
259
271
  export interface TelepresenceAdapter {
260
272
  setOnlineStatus(status: PerspectiveExpression): Promise<void>;
261
273
  getOnlineAgents(): Promise<OnlineAgent[]>;
@@ -25,6 +25,7 @@ uuid
25
25
  name
26
26
  sharedUrl
27
27
  state
28
+ owners
28
29
  neighbourhood {
29
30
  data {
30
31
  linkLanguage