@dxos/plugin-client 0.8.2-main.fbd8ed0 → 0.8.2-staging.42af850

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (96) hide show
  1. package/dist/lib/browser/{app-graph-builder-ROTCC3C4.mjs → app-graph-builder-CBRN2DMK.mjs} +3 -3
  2. package/dist/lib/browser/chunk-DCUIJY75.mjs +694 -0
  3. package/dist/lib/{node-esm/chunk-34X2AMVA.mjs.map → browser/chunk-DCUIJY75.mjs.map} +1 -1
  4. package/dist/lib/browser/{chunk-XPHDZ277.mjs → chunk-IA3AVM4I.mjs} +12 -6
  5. package/dist/lib/browser/chunk-IA3AVM4I.mjs.map +7 -0
  6. package/dist/lib/browser/{chunk-BGY6BSUC.mjs → chunk-PSSNS4C6.mjs} +2 -2
  7. package/dist/lib/{node-esm/chunk-K3KGGSJZ.mjs.map → browser/chunk-PSSNS4C6.mjs.map} +1 -1
  8. package/dist/lib/browser/{chunk-4PLF3BEB.mjs → chunk-UCVFWBKT.mjs} +2 -2
  9. package/dist/lib/{node-esm/chunk-BP56BGZR.mjs.map → browser/chunk-UCVFWBKT.mjs.map} +1 -1
  10. package/dist/lib/browser/{client-ICXXK55V.mjs → client-NMS3MSFP.mjs} +5 -4
  11. package/dist/lib/browser/client-NMS3MSFP.mjs.map +7 -0
  12. package/dist/lib/browser/index.mjs +9 -9
  13. package/dist/lib/browser/{intent-resolver-L4STUWGK.mjs → intent-resolver-KGM6A3BF.mjs} +7 -7
  14. package/dist/lib/browser/intent-resolver-KGM6A3BF.mjs.map +7 -0
  15. package/dist/lib/browser/meta.json +1 -1
  16. package/dist/lib/browser/{migrations-DYDZ7DVP.mjs → migrations-QRQV6ZAM.mjs} +2 -2
  17. package/dist/lib/browser/{react-context-WEH7SL4I.mjs → react-context-IE2O2OYK.mjs} +2 -2
  18. package/dist/lib/browser/{react-surface-VXFG7BEM.mjs → react-surface-CKZHHWY3.mjs} +3 -3
  19. package/dist/lib/browser/{schema-defs-QVXP2JGN.mjs → schema-defs-DNRDVQQJ.mjs} +2 -2
  20. package/dist/lib/browser/types.mjs +1 -1
  21. package/dist/lib/node/{app-graph-builder-DOHFMHXU.cjs → app-graph-builder-BEEYM3A5.cjs} +15 -15
  22. package/dist/lib/node/chunk-73HHNJMV.cjs +719 -0
  23. package/dist/lib/node/{chunk-FABH7MJ3.cjs.map → chunk-73HHNJMV.cjs.map} +1 -1
  24. package/dist/lib/node/{chunk-J5SQ5Q22.cjs → chunk-BL6EBWOS.cjs} +15 -9
  25. package/dist/lib/node/chunk-BL6EBWOS.cjs.map +7 -0
  26. package/dist/lib/node/{chunk-ZVQIICEN.cjs → chunk-CIYUKY3J.cjs} +5 -5
  27. package/dist/lib/node/{chunk-ZVQIICEN.cjs.map → chunk-CIYUKY3J.cjs.map} +1 -1
  28. package/dist/lib/node/{chunk-W64EOF2B.cjs → chunk-DNKJCPU7.cjs} +5 -5
  29. package/dist/lib/node/{chunk-W64EOF2B.cjs.map → chunk-DNKJCPU7.cjs.map} +1 -1
  30. package/dist/lib/node/{client-OUBG63HJ.cjs → client-Q3EQS4HA.cjs} +10 -9
  31. package/dist/lib/node/client-Q3EQS4HA.cjs.map +7 -0
  32. package/dist/lib/node/index.cjs +16 -16
  33. package/dist/lib/node/{intent-resolver-IDLAVEHS.cjs → intent-resolver-Q4QBA5B2.cjs} +33 -33
  34. package/dist/lib/node/intent-resolver-Q4QBA5B2.cjs.map +7 -0
  35. package/dist/lib/node/meta.json +1 -1
  36. package/dist/lib/node/{migrations-ZI52SX4M.cjs → migrations-6FEWMF7U.cjs} +7 -7
  37. package/dist/lib/node/{react-context-SF3M3YLR.cjs → react-context-JS7Y5ZOK.cjs} +6 -6
  38. package/dist/lib/node/{react-surface-UGXE6OAD.cjs → react-surface-GHKLUOKW.cjs} +24 -24
  39. package/dist/lib/node/{schema-defs-BYGBDKOU.cjs → schema-defs-TA52ARBO.cjs} +7 -7
  40. package/dist/lib/node/types.cjs +3 -3
  41. package/dist/lib/node/types.cjs.map +1 -1
  42. package/dist/lib/node-esm/{app-graph-builder-XMXJG5YT.mjs → app-graph-builder-OZEAAKNT.mjs} +3 -3
  43. package/dist/lib/node-esm/{chunk-K3KGGSJZ.mjs → chunk-37E3EI46.mjs} +2 -2
  44. package/dist/lib/{browser/chunk-BGY6BSUC.mjs.map → node-esm/chunk-37E3EI46.mjs.map} +1 -1
  45. package/dist/lib/node-esm/{chunk-BP56BGZR.mjs → chunk-FJYSQRBO.mjs} +2 -2
  46. package/dist/lib/{browser/chunk-4PLF3BEB.mjs.map → node-esm/chunk-FJYSQRBO.mjs.map} +1 -1
  47. package/dist/lib/node-esm/{chunk-V6SJNSKG.mjs → chunk-STGGUFV2.mjs} +12 -6
  48. package/dist/lib/node-esm/chunk-STGGUFV2.mjs.map +7 -0
  49. package/dist/lib/node-esm/chunk-ULXZABZ4.mjs +695 -0
  50. package/dist/lib/{browser/chunk-7OW22D2O.mjs.map → node-esm/chunk-ULXZABZ4.mjs.map} +1 -1
  51. package/dist/lib/node-esm/{client-YJNEHNUV.mjs → client-EBFQZRSF.mjs} +5 -4
  52. package/dist/lib/node-esm/client-EBFQZRSF.mjs.map +7 -0
  53. package/dist/lib/node-esm/index.mjs +9 -9
  54. package/dist/lib/node-esm/{intent-resolver-73FZIXX5.mjs → intent-resolver-2GCG4LCE.mjs} +7 -7
  55. package/dist/lib/node-esm/intent-resolver-2GCG4LCE.mjs.map +7 -0
  56. package/dist/lib/node-esm/meta.json +1 -1
  57. package/dist/lib/node-esm/{migrations-GHO52HKW.mjs → migrations-AK43ZE6G.mjs} +2 -2
  58. package/dist/lib/node-esm/{react-context-EAKKTE5A.mjs → react-context-6N7NMUJE.mjs} +2 -2
  59. package/dist/lib/node-esm/{react-surface-R65DYUV6.mjs → react-surface-UCUL26AF.mjs} +3 -3
  60. package/dist/lib/node-esm/{schema-defs-O4OHIIBN.mjs → schema-defs-O2KQQXJH.mjs} +2 -2
  61. package/dist/lib/node-esm/types.mjs +1 -1
  62. package/dist/types/src/capabilities/client.d.ts +1 -1
  63. package/dist/types/src/capabilities/client.d.ts.map +1 -1
  64. package/dist/types/src/types.d.ts +6 -0
  65. package/dist/types/src/types.d.ts.map +1 -1
  66. package/package.json +26 -25
  67. package/src/capabilities/client.ts +2 -1
  68. package/src/capabilities/intent-resolver.ts +2 -2
  69. package/src/types.ts +12 -3
  70. package/dist/lib/browser/chunk-7OW22D2O.mjs +0 -623
  71. package/dist/lib/browser/chunk-XPHDZ277.mjs.map +0 -7
  72. package/dist/lib/browser/client-ICXXK55V.mjs.map +0 -7
  73. package/dist/lib/browser/intent-resolver-L4STUWGK.mjs.map +0 -7
  74. package/dist/lib/node/chunk-FABH7MJ3.cjs +0 -648
  75. package/dist/lib/node/chunk-J5SQ5Q22.cjs.map +0 -7
  76. package/dist/lib/node/client-OUBG63HJ.cjs.map +0 -7
  77. package/dist/lib/node/intent-resolver-IDLAVEHS.cjs.map +0 -7
  78. package/dist/lib/node-esm/chunk-34X2AMVA.mjs +0 -624
  79. package/dist/lib/node-esm/chunk-V6SJNSKG.mjs.map +0 -7
  80. package/dist/lib/node-esm/client-YJNEHNUV.mjs.map +0 -7
  81. package/dist/lib/node-esm/intent-resolver-73FZIXX5.mjs.map +0 -7
  82. /package/dist/lib/browser/{app-graph-builder-ROTCC3C4.mjs.map → app-graph-builder-CBRN2DMK.mjs.map} +0 -0
  83. /package/dist/lib/browser/{migrations-DYDZ7DVP.mjs.map → migrations-QRQV6ZAM.mjs.map} +0 -0
  84. /package/dist/lib/browser/{react-context-WEH7SL4I.mjs.map → react-context-IE2O2OYK.mjs.map} +0 -0
  85. /package/dist/lib/browser/{react-surface-VXFG7BEM.mjs.map → react-surface-CKZHHWY3.mjs.map} +0 -0
  86. /package/dist/lib/browser/{schema-defs-QVXP2JGN.mjs.map → schema-defs-DNRDVQQJ.mjs.map} +0 -0
  87. /package/dist/lib/node/{app-graph-builder-DOHFMHXU.cjs.map → app-graph-builder-BEEYM3A5.cjs.map} +0 -0
  88. /package/dist/lib/node/{migrations-ZI52SX4M.cjs.map → migrations-6FEWMF7U.cjs.map} +0 -0
  89. /package/dist/lib/node/{react-context-SF3M3YLR.cjs.map → react-context-JS7Y5ZOK.cjs.map} +0 -0
  90. /package/dist/lib/node/{react-surface-UGXE6OAD.cjs.map → react-surface-GHKLUOKW.cjs.map} +0 -0
  91. /package/dist/lib/node/{schema-defs-BYGBDKOU.cjs.map → schema-defs-TA52ARBO.cjs.map} +0 -0
  92. /package/dist/lib/node-esm/{app-graph-builder-XMXJG5YT.mjs.map → app-graph-builder-OZEAAKNT.mjs.map} +0 -0
  93. /package/dist/lib/node-esm/{migrations-GHO52HKW.mjs.map → migrations-AK43ZE6G.mjs.map} +0 -0
  94. /package/dist/lib/node-esm/{react-context-EAKKTE5A.mjs.map → react-context-6N7NMUJE.mjs.map} +0 -0
  95. /package/dist/lib/node-esm/{react-surface-R65DYUV6.mjs.map → react-surface-UCUL26AF.mjs.map} +0 -0
  96. /package/dist/lib/node-esm/{schema-defs-O4OHIIBN.mjs.map → schema-defs-O2KQQXJH.mjs.map} +0 -0
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../../src/capabilities/client.ts"],
4
- "sourcesContent": ["//\n// Copyright 2025 DXOS.org\n//\n\nimport { contributes, type PluginContext } from '@dxos/app-framework';\nimport { Client } from '@dxos/react-client';\n\nimport { ClientCapabilities } from './capabilities';\nimport { ClientEvents } from '../events';\nimport { type ClientPluginOptions } from '../types';\n\ntype ClientCapabilityOptions = Omit<ClientPluginOptions, 'appKey' | 'invitationUrl' | 'invitationParam' | 'onReset'> & {\n context: PluginContext;\n};\n\nexport default async ({ context, onClientInitialized, ...options }: ClientCapabilityOptions) => {\n const client = new Client(options);\n await client.initialize();\n await onClientInitialized?.(context, client);\n\n // TODO(wittjosiah): Remove. This is a hack to get the app to boot with the new identity after a reset.\n client.reloaded.on(() => {\n client.halo.identity.subscribe(async (identity) => {\n if (identity) {\n window.location.href = window.location.origin;\n }\n });\n });\n\n const subscription = client.spaces.isReady.subscribe(async (ready) => {\n if (ready) {\n await context.activatePromise(ClientEvents.SpacesReady);\n }\n });\n\n return contributes(ClientCapabilities.Client, client, async () => {\n subscription.unsubscribe();\n await client.destroy();\n });\n};\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;AAIA,2BAAgD;AAChD,0BAAuB;AAUvB,IAAA,iBAAe,OAAO,EAAEA,SAASC,qBAAqB,GAAGC,QAAAA,MAAkC;AACzF,QAAMC,SAAS,IAAIC,2BAAOF,OAAAA;AAC1B,QAAMC,OAAOE,WAAU;AACvB,QAAMJ,sBAAsBD,SAASG,MAAAA;AAGrCA,SAAOG,SAASC,GAAG,MAAA;AACjBJ,WAAOK,KAAKC,SAASC,UAAU,OAAOD,aAAAA;AACpC,UAAIA,UAAU;AACZE,eAAOC,SAASC,OAAOF,OAAOC,SAASE;MACzC;IACF,CAAA;EACF,CAAA;AAEA,QAAMC,eAAeZ,OAAOa,OAAOC,QAAQP,UAAU,OAAOQ,UAAAA;AAC1D,QAAIA,OAAO;AACT,YAAMlB,QAAQmB,gBAAgBC,mCAAaC,WAAW;IACxD;EACF,CAAA;AAEA,aAAOC,kCAAYC,yCAAmBnB,QAAQD,QAAQ,YAAA;AACpDY,iBAAaS,YAAW;AACxB,UAAMrB,OAAOsB,QAAO;EACtB,CAAA;AACF;",
6
- "names": ["context", "onClientInitialized", "options", "client", "Client", "initialize", "reloaded", "on", "halo", "identity", "subscribe", "window", "location", "href", "origin", "subscription", "spaces", "isReady", "ready", "activatePromise", "ClientEvents", "SpacesReady", "contributes", "ClientCapabilities", "unsubscribe", "destroy"]
7
- }
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../../src/capabilities/intent-resolver.ts"],
4
- "sourcesContent": ["//\n// Copyright 2025 DXOS.org\n//\n\nimport { pipe } from 'effect';\n\nimport {\n Capabilities,\n chain,\n contributes,\n createIntent,\n createResolver,\n LayoutAction,\n type PluginContext,\n} from '@dxos/app-framework';\nimport { invariant } from '@dxos/invariant';\nimport { ObservabilityAction } from '@dxos/plugin-observability/types';\nimport { PublicKey } from '@dxos/react-client';\nimport { type JoinPanelProps } from '@dxos/shell/react';\n\nimport { ClientCapabilities } from './capabilities';\nimport { JOIN_DIALOG, RECOVERY_CODE_DIALOG, RESET_DIALOG } from '../components';\nimport { ClientEvents } from '../events';\nimport { Account, ClientAction } from '../types';\n\ntype IntentResolverOptions = {\n context: PluginContext;\n appName?: string;\n};\n\nconst RECOVER_IDENTITY_RPC_TIMEOUT = 20_000;\n\nexport default ({ context, appName = 'Composer' }: IntentResolverOptions) =>\n contributes(Capabilities.IntentResolver, [\n createResolver({\n intent: ClientAction.CreateIdentity,\n resolve: async () => {\n const manager = context.getCapability(Capabilities.PluginManager);\n const client = context.getCapability(ClientCapabilities.Client);\n const data = await client.halo.createIdentity();\n await manager.activate(ClientEvents.IdentityCreated);\n return {\n data,\n intents: [\n createIntent(ObservabilityAction.SendEvent, {\n name: 'identity.create',\n }),\n ],\n };\n },\n }),\n createResolver({\n intent: ClientAction.JoinIdentity,\n resolve: async (data) => {\n return {\n intents: [\n createIntent(LayoutAction.UpdateDialog, {\n part: 'dialog',\n subject: JOIN_DIALOG,\n options: {\n blockAlign: 'start',\n props: {\n initialInvitationCode: data.invitationCode,\n initialDisposition: 'accept-halo-invitation',\n },\n },\n }),\n ],\n };\n },\n }),\n createResolver({\n intent: ClientAction.ShareIdentity,\n resolve: async () => {\n return {\n intents: [\n pipe(\n createIntent(LayoutAction.SwitchWorkspace, {\n part: 'workspace',\n subject: Account.id,\n }),\n chain(LayoutAction.Open, {\n part: 'main',\n subject: [Account.Profile],\n }),\n ),\n createIntent(ObservabilityAction.SendEvent, {\n name: 'identity.share',\n }),\n ],\n };\n },\n }),\n createResolver({\n intent: ClientAction.RecoverIdentity,\n resolve: async () => {\n return {\n intents: [\n createIntent(LayoutAction.UpdateDialog, {\n part: 'dialog',\n subject: JOIN_DIALOG,\n options: {\n blockAlign: 'start',\n props: {\n initialDisposition: 'recover-identity',\n } satisfies Partial<JoinPanelProps>,\n },\n }),\n ],\n };\n },\n }),\n createResolver({\n intent: ClientAction.ResetStorage,\n resolve: async (data) => {\n return {\n intents: [\n createIntent(LayoutAction.UpdateDialog, {\n part: 'dialog',\n subject: RESET_DIALOG,\n options: {\n blockAlign: 'start',\n props: {\n mode: data.mode ?? 'reset storage',\n },\n },\n }),\n ],\n };\n },\n }),\n createResolver({\n intent: ClientAction.CreateAgent,\n resolve: async () => {\n const client = context.getCapability(ClientCapabilities.Client);\n invariant(client.services.services.EdgeAgentService, 'Missing EdgeAgentService');\n await client.services.services.EdgeAgentService.createAgent(null as any, { timeout: 10_000 });\n },\n }),\n createResolver({\n intent: ClientAction.CreateRecoveryCode,\n resolve: async () => {\n const client = context.getCapability(ClientCapabilities.Client);\n invariant(client.services.services.IdentityService, 'IdentityService not available');\n // TODO(wittjosiah): This needs a proper api.\n const { recoveryCode } = await client.services.services.IdentityService.createRecoveryCredential({});\n return {\n intents: [\n createIntent(LayoutAction.UpdateDialog, {\n part: 'dialog',\n subject: RECOVERY_CODE_DIALOG,\n options: {\n blockAlign: 'start',\n type: 'alert',\n props: { code: recoveryCode },\n },\n }),\n ],\n };\n },\n }),\n createResolver({\n intent: ClientAction.CreatePasskey,\n resolve: async () => {\n const client = context.getCapability(ClientCapabilities.Client);\n const identity = client.halo.identity.get();\n invariant(identity, 'Identity not available');\n\n // TODO(wittjosiah): Consider factoring out passkey creation to the halo api.\n const lookupKey = PublicKey.random();\n const credential = await navigator.credentials.create({\n publicKey: {\n challenge: new Uint8Array(),\n rp: { id: location.hostname, name: appName },\n user: {\n id: lookupKey.asUint8Array(),\n name: identity.did,\n displayName: identity.profile?.displayName ?? '',\n },\n pubKeyCredParams: [\n { type: 'public-key', alg: -8 }, // Ed25519 (not yet supported across all browsers)\n { type: 'public-key', alg: -7 }, // ES256\n ],\n // https://web.dev/articles/webauthn-discoverable-credentials#resident-key\n authenticatorSelection: {\n residentKey: 'required',\n requireResidentKey: true,\n },\n },\n });\n\n invariant(credential, 'Credential not available');\n const recoveryKey = PublicKey.from(new Uint8Array((credential as any).response.getPublicKey()));\n const algorithm = (credential as any).response.getPublicKeyAlgorithm() === -7 ? 'ES256' : 'ED25519';\n\n // TODO(wittjosiah): This needs a proper api.\n invariant(client.services.services.IdentityService, 'IdentityService not available');\n await client.services.services.IdentityService.createRecoveryCredential({\n data: {\n recoveryKey,\n algorithm,\n lookupKey,\n },\n });\n },\n }),\n createResolver({\n intent: ClientAction.RedeemPasskey,\n resolve: async () => {\n const client = context.getCapability(ClientCapabilities.Client);\n // TODO(wittjosiah): This needs a proper api.\n invariant(client.services.services.IdentityService, 'IdentityService not available');\n const { deviceKey, controlFeedKey, challenge } =\n await client.services.services.IdentityService.requestRecoveryChallenge();\n const credential = await navigator.credentials.get({\n publicKey: {\n challenge: Buffer.from(challenge, 'base64'),\n rpId: location.hostname,\n userVerification: 'required',\n },\n });\n const lookupKey = PublicKey.from(new Uint8Array((credential as any).response.userHandle));\n await client.services.services.IdentityService.recoverIdentity(\n {\n external: {\n lookupKey,\n deviceKey,\n controlFeedKey,\n signature: Buffer.from((credential as any).response.signature),\n clientDataJson: Buffer.from((credential as any).response.clientDataJSON),\n authenticatorData: Buffer.from((credential as any).response.authenticatorData),\n },\n },\n { timeout: RECOVER_IDENTITY_RPC_TIMEOUT },\n );\n },\n }),\n createResolver({\n intent: ClientAction.RedeemToken,\n resolve: async (data) => {\n const client = context.getCapability(ClientCapabilities.Client);\n // TODO(wittjosiah): This needs a proper api.\n invariant(client.services.services.IdentityService, 'IdentityService not available');\n await client.services.services.IdentityService.recoverIdentity(\n { token: data.token },\n { timeout: RECOVER_IDENTITY_RPC_TIMEOUT },\n );\n },\n }),\n ]);\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAIA,oBAAqB;AAErB,2BAQO;AACP,uBAA0B;AAC1B,mBAA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;UAClC0B,MAAMvB,SAASC;UACfuB,kBAAkB;QACpB;MACF,CAAA;AACA,YAAMnC,YAAYC,8BAAUuB,KAAK,IAAIf,WAAYN,WAAmBsB,SAASW,UAAU,CAAA;AACvF,YAAM1F,OAAOwC,SAASA,SAASK,gBAAgB8C,gBAC7C;QACEC,UAAU;UACRtC;UACA8B;UACAC;UACAQ,WAAWN,OAAOT,KAAMrB,WAAmBsB,SAASc,SAAS;UAC7DC,gBAAgBP,OAAOT,KAAMrB,WAAmBsB,SAASgB,cAAc;UACvEC,mBAAmBT,OAAOT,KAAMrB,WAAmBsB,SAASiB,iBAAiB;QAC/E;MACF,GACA;QAAErD,SAASzD;MAA6B,CAAA;IAE5C;EACF,CAAA;MACAM,qCAAe;IACbC,QAAQC,mCAAauG;IACrBrG,SAAS,OAAOO,SAAAA;AACd,YAAMH,SAASb,QAAQW,cAAcG,yCAAmBC,MAAM;AAE9DqC,sCAAUvC,OAAOwC,SAASA,SAASK,iBAAiB,iCAAA;;;;;;;;;AACpD,YAAM7C,OAAOwC,SAASA,SAASK,gBAAgB8C,gBAC7C;QAAEO,OAAO/F,KAAK+F;MAAM,GACpB;QAAEvD,SAASzD;MAA6B,CAAA;IAE5C;EACF,CAAA;CACD;",
6
- "names": ["RECOVER_IDENTITY_RPC_TIMEOUT", "context", "appName", "contributes", "Capabilities", "IntentResolver", "createResolver", "intent", "ClientAction", "CreateIdentity", "resolve", "manager", "getCapability", "PluginManager", "client", "ClientCapabilities", "Client", "data", "halo", "createIdentity", "activate", "ClientEvents", "IdentityCreated", "intents", "createIntent", "ObservabilityAction", "SendEvent", "name", "JoinIdentity", "LayoutAction", "UpdateDialog", "part", "subject", "JOIN_DIALOG", "options", "blockAlign", "props", "initialInvitationCode", "invitationCode", "initialDisposition", "ShareIdentity", "pipe", "SwitchWorkspace", "Account", "id", "chain", "Open", "Profile", "RecoverIdentity", "ResetStorage", "RESET_DIALOG", "mode", "CreateAgent", "invariant", "services", "EdgeAgentService", "createAgent", "timeout", "CreateRecoveryCode", "IdentityService", "recoveryCode", "createRecoveryCredential", "RECOVERY_CODE_DIALOG", "type", "code", "CreatePasskey", "identity", "get", "lookupKey", "PublicKey", "random", "credential", "navigator", "credentials", "create", "publicKey", "challenge", "Uint8Array", "rp", "location", "hostname", "user", "asUint8Array", "did", "displayName", "profile", "pubKeyCredParams", "alg", "authenticatorSelection", "residentKey", "requireResidentKey", "recoveryKey", "from", "response", "getPublicKey", "algorithm", "getPublicKeyAlgorithm", "RedeemPasskey", "deviceKey", "controlFeedKey", "requestRecoveryChallenge", "Buffer", "rpId", "userVerification", "userHandle", "recoverIdentity", "external", "signature", "clientDataJson", "clientDataJSON", "authenticatorData", "RedeemToken", "token"]
7
- }
@@ -1,624 +0,0 @@
1
- import { createRequire } from 'node:module';const require = createRequire(import.meta.url);
2
- import {
3
- ClientAction
4
- } from "./chunk-V6SJNSKG.mjs";
5
- import {
6
- CLIENT_PLUGIN
7
- } from "./chunk-HM7VB4ZV.mjs";
8
-
9
- // packages/plugins/plugin-client/src/components/DevicesContainer.tsx
10
- import { Check, X } from "@phosphor-icons/react";
11
- import React, { useCallback, useEffect, useState } from "react";
12
- import { QR } from "react-qr-rounded";
13
- import { createIntent, useIntentDispatcher } from "@dxos/app-framework";
14
- import { log } from "@dxos/log";
15
- import { useClient, useMulticastObservable } from "@dxos/react-client";
16
- import { useDevices } from "@dxos/react-client/halo";
17
- import { Invitation, InvitationEncoder } from "@dxos/react-client/invitations";
18
- import { useNetworkStatus } from "@dxos/react-client/mesh";
19
- import { Button, Clipboard, IconButton, List, useId, useTranslation } from "@dxos/react-ui";
20
- import { ControlFrame, ControlFrameItem, ControlGroup, ControlItem, ControlPage, ControlSection } from "@dxos/react-ui-form";
21
- import { StackItem } from "@dxos/react-ui-stack";
22
- import { getSize, mx } from "@dxos/react-ui-theme";
23
- import { AuthCode, Centered, DeviceListItem, Emoji, Viewport } from "@dxos/shell/react";
24
- import { hexToEmoji } from "@dxos/util";
25
- var __dxlog_file = "/home/runner/work/dxos/dxos/packages/plugins/plugin-client/src/components/DevicesContainer.tsx";
26
- var DevicesContainer = ({ createInvitationUrl }) => {
27
- const { t } = useTranslation("os");
28
- const { dispatchPromise: dispatch } = useIntentDispatcher();
29
- const devices = useDevices();
30
- const { swarm: connectionState } = useNetworkStatus();
31
- const handleResetStorage = useCallback(() => dispatch(createIntent(ClientAction.ResetStorage)), [
32
- dispatch
33
- ]);
34
- const handleRecover = useCallback(() => dispatch(createIntent(ClientAction.ResetStorage, {
35
- mode: "recover"
36
- })), [
37
- dispatch
38
- ]);
39
- const handleJoinNewIdentity = useCallback(() => dispatch(createIntent(ClientAction.ResetStorage, {
40
- mode: "join new identity"
41
- })), [
42
- dispatch
43
- ]);
44
- return /* @__PURE__ */ React.createElement(Clipboard.Provider, null, /* @__PURE__ */ React.createElement(StackItem.Content, {
45
- classNames: "block overflow-y-auto"
46
- }, /* @__PURE__ */ React.createElement(ControlPage, null, /* @__PURE__ */ React.createElement(ControlSection, {
47
- title: t("devices verbose label", {
48
- ns: CLIENT_PLUGIN
49
- }),
50
- description: t("devices description", {
51
- ns: CLIENT_PLUGIN
52
- })
53
- }, /* @__PURE__ */ React.createElement(ControlFrame, null, /* @__PURE__ */ React.createElement(ControlFrameItem, {
54
- title: t("devices label", {
55
- ns: CLIENT_PLUGIN
56
- })
57
- }, /* @__PURE__ */ React.createElement(List, null, devices.map((device) => {
58
- return /* @__PURE__ */ React.createElement(DeviceListItem, {
59
- key: device.deviceKey.toHex(),
60
- device,
61
- connectionState
62
- });
63
- }))), createInvitationUrl && /* @__PURE__ */ React.createElement(ControlFrameItem, {
64
- title: "Add device"
65
- }, /* @__PURE__ */ React.createElement(DeviceInvitation, {
66
- createInvitationUrl
67
- })))), /* @__PURE__ */ React.createElement(ControlSection, {
68
- title: t("danger zone title", {
69
- ns: CLIENT_PLUGIN
70
- }),
71
- description: t("danger zone description", {
72
- ns: CLIENT_PLUGIN
73
- })
74
- }, /* @__PURE__ */ React.createElement(ControlGroup, null, /* @__PURE__ */ React.createElement(ControlItem, {
75
- title: t("reset device label"),
76
- description: t("reset device description", {
77
- ns: CLIENT_PLUGIN
78
- })
79
- }, /* @__PURE__ */ React.createElement(Button, {
80
- variant: "destructive",
81
- onClick: handleResetStorage,
82
- "data-testid": "devicesContainer.reset"
83
- }, t("reset device label"))), /* @__PURE__ */ React.createElement(ControlItem, {
84
- title: t("recover identity label"),
85
- description: t("recover identity description", {
86
- ns: CLIENT_PLUGIN
87
- })
88
- }, /* @__PURE__ */ React.createElement(Button, {
89
- variant: "destructive",
90
- onClick: handleRecover,
91
- "data-testid": "devicesContainer.recover"
92
- }, t("recover identity label"))), /* @__PURE__ */ React.createElement(ControlItem, {
93
- title: t("join new identity label"),
94
- description: t("join new identity description", {
95
- ns: CLIENT_PLUGIN
96
- })
97
- }, /* @__PURE__ */ React.createElement(Button, {
98
- variant: "destructive",
99
- onClick: handleJoinNewIdentity,
100
- "data-testid": "devicesContainer.joinExisting"
101
- }, t("join new identity label"))))))));
102
- };
103
- var DeviceInvitation = (props) => {
104
- const client = useClient();
105
- const [invitation, setInvitation] = useState();
106
- const onInvitationCreate = useCallback(() => {
107
- const invitation2 = client.halo.share();
108
- if (client.config.values.runtime?.app?.env?.DX_ENVIRONMENT !== "production") {
109
- const subscription = invitation2.subscribe((invitation3) => {
110
- const invitationCode = InvitationEncoder.encode(invitation3);
111
- if (invitation3.state === Invitation.State.CONNECTING) {
112
- log.info(JSON.stringify({
113
- invitationCode,
114
- authCode: invitation3.authCode
115
- }), void 0, {
116
- F: __dxlog_file,
117
- L: 141,
118
- S: void 0,
119
- C: (f, a) => f(...a)
120
- });
121
- subscription.unsubscribe();
122
- }
123
- });
124
- }
125
- setInvitation(invitation2);
126
- }, [
127
- client
128
- ]);
129
- const onInvitationDone = useCallback(() => {
130
- setInvitation(void 0);
131
- }, []);
132
- if (invitation) {
133
- return /* @__PURE__ */ React.createElement(DeviceInvitationImpl, {
134
- ...props,
135
- invitation,
136
- onInvitationCreate,
137
- onInvitationDone
138
- });
139
- } else {
140
- return /* @__PURE__ */ React.createElement(InvitationSection, {
141
- ...props,
142
- onInvitationCreate,
143
- onInvitationDone
144
- });
145
- }
146
- };
147
- var DeviceInvitationImpl = ({ invitation: invitationObservable, createInvitationUrl, onInvitationDone, onInvitationCreate }) => {
148
- const invitation = useMulticastObservable(invitationObservable);
149
- const url = createInvitationUrl(InvitationEncoder.encode(invitation));
150
- useEffect(() => {
151
- if (invitation.state >= Invitation.State.SUCCESS) {
152
- onInvitationDone();
153
- }
154
- }, [
155
- invitation.state
156
- ]);
157
- return /* @__PURE__ */ React.createElement(InvitationSection, {
158
- ...invitation,
159
- url,
160
- onInvitationDone,
161
- onInvitationCreate
162
- });
163
- };
164
- var InvitationSection = ({ state = -1, authCode, invitationId = "never", url = "never", onInvitationDone = () => {
165
- }, onInvitationCreate = () => {
166
- } }) => {
167
- const { t } = useTranslation(CLIENT_PLUGIN);
168
- const activeView = state < 0 ? "init" : state >= Invitation.State.CANCELLED ? "complete" : state >= Invitation.State.READY_FOR_AUTHENTICATION && authCode ? "auth-code" : "qr-code";
169
- return activeView === "init" ? /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement("p", {
170
- className: "text-description mbe-2"
171
- }, t("add device description")), /* @__PURE__ */ React.createElement(IconButton, {
172
- icon: "ph--plus--regular",
173
- label: t("create device invitation label"),
174
- disabled: state >= 0,
175
- classNames: "is-full",
176
- "data-testid": "devicesContainer.createInvitation",
177
- onClick: onInvitationCreate
178
- })) : /* @__PURE__ */ React.createElement(Viewport.Root, {
179
- activeView
180
- }, /* @__PURE__ */ React.createElement(Viewport.Views, null, /* @__PURE__ */ React.createElement(Viewport.View, {
181
- id: "init"
182
- }), /* @__PURE__ */ React.createElement(Viewport.View, {
183
- id: "complete"
184
- }, /* @__PURE__ */ React.createElement(InvitationComplete, {
185
- statusValue: state
186
- })), /* @__PURE__ */ React.createElement(Viewport.View, {
187
- id: "auth-code"
188
- }, /* @__PURE__ */ React.createElement(InvitationAuthCode, {
189
- id: invitationId,
190
- code: authCode ?? "never",
191
- onCancel: onInvitationDone
192
- })), /* @__PURE__ */ React.createElement(Viewport.View, {
193
- id: "qr-code"
194
- }, /* @__PURE__ */ React.createElement(InvitationQR, {
195
- id: invitationId,
196
- url,
197
- onCancel: onInvitationDone
198
- }))));
199
- };
200
- var InvitationQR = ({ id, url, onCancel }) => {
201
- const { t } = useTranslation("os");
202
- const qrLabel = useId("devices-container__qr-code");
203
- const emoji = hexToEmoji(id);
204
- return /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement("p", {
205
- className: "text-description"
206
- }, t("qr code description", {
207
- ns: CLIENT_PLUGIN
208
- })), /* @__PURE__ */ React.createElement("div", {
209
- role: "group",
210
- className: "grid grid-cols-[1fr_min-content] mlb-2 gap-2"
211
- }, /* @__PURE__ */ React.createElement("div", {
212
- role: "none",
213
- className: "is-full aspect-square relative text-description"
214
- }, /* @__PURE__ */ React.createElement(QR, {
215
- rounding: 100,
216
- backgroundColor: "transparent",
217
- color: "currentColor",
218
- "aria-labelledby": qrLabel,
219
- errorCorrectionLevel: "Q",
220
- cutout: true
221
- }, url ?? "never"), /* @__PURE__ */ React.createElement(Centered, null, /* @__PURE__ */ React.createElement(Emoji, {
222
- text: emoji
223
- }))), /* @__PURE__ */ React.createElement("span", {
224
- id: qrLabel,
225
- className: "sr-only"
226
- }, t("qr label"))), /* @__PURE__ */ React.createElement("div", {
227
- className: "flex justify-center"
228
- }, /* @__PURE__ */ React.createElement("div", {
229
- className: "flex gap-2"
230
- }, /* @__PURE__ */ React.createElement(Clipboard.Button, {
231
- value: url ?? "never"
232
- }), /* @__PURE__ */ React.createElement(Button, {
233
- variant: "ghost",
234
- onClick: onCancel
235
- }, t("cancel label")))));
236
- };
237
- var InvitationAuthCode = ({ id, code, onCancel }) => {
238
- const { t } = useTranslation("os");
239
- const emoji = hexToEmoji(id);
240
- return /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement("p", {
241
- className: "text-description"
242
- }, t("auth other device emoji message")), emoji && /* @__PURE__ */ React.createElement(Emoji, {
243
- text: emoji,
244
- className: "mli-auto mlb-2 text-center"
245
- }), /* @__PURE__ */ React.createElement("p", {
246
- className: "text-description"
247
- }, t("auth code message")), /* @__PURE__ */ React.createElement(AuthCode, {
248
- code,
249
- large: true,
250
- classNames: "mli-auto mlb-2 text-center grow"
251
- }), /* @__PURE__ */ React.createElement(Button, {
252
- variant: "ghost",
253
- onClick: onCancel
254
- }, t("cancel label")));
255
- };
256
- var InvitationComplete = ({ statusValue }) => {
257
- return statusValue > 0 ? /* @__PURE__ */ React.createElement(Check, {
258
- className: mx("m-1.5", getSize(6))
259
- }) : /* @__PURE__ */ React.createElement(X, {
260
- className: mx("m-1.5", getSize(6))
261
- });
262
- };
263
-
264
- // packages/plugins/plugin-client/src/components/JoinDialog.tsx
265
- import React2, { useCallback as useCallback2 } from "react";
266
- import { createIntent as createIntent2, LayoutAction, useIntentDispatcher as useIntentDispatcher2 } from "@dxos/app-framework";
267
- import { ObservabilityAction } from "@dxos/plugin-observability/types";
268
- import { Dialog, useTranslation as useTranslation2 } from "@dxos/react-ui";
269
- import { JoinPanel } from "@dxos/shell/react";
270
- var JOIN_DIALOG = `${CLIENT_PLUGIN}/JoinDialog`;
271
- var JoinDialog = (props) => {
272
- const { dispatchPromise: dispatch } = useIntentDispatcher2();
273
- const { t } = useTranslation2(CLIENT_PLUGIN);
274
- const handleCancelResetStorage = useCallback2(() => dispatch(createIntent2(ClientAction.ShareIdentity)), [
275
- dispatch
276
- ]);
277
- const handleDone = useCallback2(async (result) => {
278
- if (result?.identityKey) {
279
- await Promise.all([
280
- dispatch(createIntent2(LayoutAction.UpdateDialog, {
281
- part: "dialog",
282
- options: {
283
- state: false
284
- }
285
- })),
286
- dispatch(createIntent2(ObservabilityAction.SendEvent, {
287
- name: props.initialDisposition === "recover-identity" ? "identity.recover" : "identity.join"
288
- }))
289
- ]);
290
- }
291
- }, [
292
- dispatch
293
- ]);
294
- return /* @__PURE__ */ React2.createElement(Dialog.Content, null, /* @__PURE__ */ React2.createElement(Dialog.Title, {
295
- classNames: "sr-only"
296
- }, t("join space label", {
297
- ns: "os"
298
- })), /* @__PURE__ */ React2.createElement(JoinPanel, {
299
- mode: "halo-only",
300
- ...props,
301
- exitActionParent: /* @__PURE__ */ React2.createElement(Dialog.Close, {
302
- asChild: true
303
- }),
304
- doneActionParent: /* @__PURE__ */ React2.createElement(Dialog.Close, {
305
- asChild: true
306
- }),
307
- onCancelResetStorage: handleCancelResetStorage,
308
- onDone: handleDone
309
- }));
310
- };
311
-
312
- // packages/plugins/plugin-client/src/components/ProfileContainer.tsx
313
- import { Schema } from "effect";
314
- import React3, { useCallback as useCallback3, useMemo, useState as useState2 } from "react";
315
- import { debounce } from "@dxos/async";
316
- import { useClient as useClient2 } from "@dxos/react-client";
317
- import { useIdentity } from "@dxos/react-client/halo";
318
- import { ButtonGroup, Clipboard as Clipboard2, Input, useTranslation as useTranslation3 } from "@dxos/react-ui";
319
- import { Form, ControlItem as ControlItem2, ControlItemInput, ControlSection as ControlSection2, ControlPage as ControlPage2 } from "@dxos/react-ui-form";
320
- import { EmojiPickerBlock, HuePicker } from "@dxos/react-ui-pickers";
321
- import { StackItem as StackItem2 } from "@dxos/react-ui-stack";
322
- import { hexToHue, hexToEmoji as hexToEmoji2 } from "@dxos/util";
323
- var getDefaultHueValue = (identity) => hexToHue(identity?.identityKey.toHex() ?? "0");
324
- var getDefaultEmojiValue = (identity) => hexToEmoji2(identity?.identityKey.toHex() ?? "0");
325
- var getHueValue = (identity) => identity?.profile?.data?.hue || getDefaultHueValue(identity);
326
- var getEmojiValue = (identity) => identity?.profile?.data?.emoji || getDefaultEmojiValue(identity);
327
- var ProfileContainer = () => {
328
- const { t } = useTranslation3(CLIENT_PLUGIN);
329
- const client = useClient2();
330
- const identity = useIdentity();
331
- const [displayName, setDisplayNameDirectly] = useState2(identity?.profile?.displayName ?? "");
332
- const [emoji, setEmojiDirectly] = useState2(getEmojiValue(identity));
333
- const [hue, setHueDirectly] = useState2(getHueValue(identity));
334
- const updateProfile = useMemo(() => debounce((profile) => client.halo.updateProfile({
335
- displayName: profile.displayName,
336
- data: {
337
- emoji: profile.emoji,
338
- hue: profile.hue
339
- }
340
- }), 2e3), []);
341
- const handleSave = useCallback3((profile) => {
342
- setDisplayNameDirectly(profile.displayName);
343
- setEmojiDirectly(profile.emoji);
344
- setHueDirectly(profile.hue);
345
- updateProfile(profile);
346
- }, [
347
- identity
348
- ]);
349
- const values = useMemo(() => ({
350
- displayName,
351
- emoji,
352
- hue,
353
- did: identity?.did
354
- }), [
355
- identity,
356
- displayName,
357
- emoji,
358
- hue
359
- ]);
360
- const customElements = useMemo(() => ({
361
- displayName: ({ type, label, getValue, onValueChange }) => {
362
- const handleChange = useCallback3(({ target: { value } }) => onValueChange(type, value), [
363
- onValueChange,
364
- type
365
- ]);
366
- return /* @__PURE__ */ React3.createElement(ControlItemInput, {
367
- title: label,
368
- description: t("display name description")
369
- }, /* @__PURE__ */ React3.createElement(Input.TextInput, {
370
- value: getValue(),
371
- onChange: handleChange,
372
- placeholder: t("display name input placeholder"),
373
- classNames: "min-is-64"
374
- }));
375
- },
376
- emoji: ({ type, label, getValue, onValueChange }) => {
377
- const handleChange = useCallback3((nextEmoji) => onValueChange(type, nextEmoji), [
378
- onValueChange,
379
- type
380
- ]);
381
- const handleEmojiReset = useCallback3(() => onValueChange(type, getDefaultEmojiValue(identity)), [
382
- onValueChange,
383
- type
384
- ]);
385
- return /* @__PURE__ */ React3.createElement(ControlItem2, {
386
- title: label,
387
- description: t("icon description")
388
- }, /* @__PURE__ */ React3.createElement(EmojiPickerBlock, {
389
- triggerVariant: "default",
390
- emoji: getValue(),
391
- onChangeEmoji: handleChange,
392
- onClickClear: handleEmojiReset,
393
- classNames: "justify-self-end"
394
- }));
395
- },
396
- hue: ({ type, label, getValue, onValueChange }) => {
397
- const handleChange = useCallback3((nextHue) => onValueChange(type, nextHue), [
398
- onValueChange,
399
- type
400
- ]);
401
- const handleHueReset = useCallback3(() => onValueChange(type, getDefaultHueValue(identity)), [
402
- onValueChange,
403
- type
404
- ]);
405
- return /* @__PURE__ */ React3.createElement(ControlItem2, {
406
- title: label,
407
- description: t("hue description")
408
- }, /* @__PURE__ */ React3.createElement(HuePicker, {
409
- value: getValue(),
410
- onChange: handleChange,
411
- onReset: handleHueReset,
412
- classNames: "[--hue-preview-size:1.5rem] justify-self-end"
413
- }));
414
- },
415
- // TODO(wittjosiah): We need text input annotations for disabled and copyable.
416
- did: ({ label, getValue }) => {
417
- return /* @__PURE__ */ React3.createElement(ControlItemInput, {
418
- title: label,
419
- description: t("did description")
420
- }, /* @__PURE__ */ React3.createElement(ButtonGroup, null, /* @__PURE__ */ React3.createElement(Input.TextInput, {
421
- value: getValue(),
422
- disabled: true,
423
- classNames: "min-is-64"
424
- }), /* @__PURE__ */ React3.createElement(Clipboard2.IconButton, {
425
- value: getValue() ?? ""
426
- })));
427
- }
428
- }), [
429
- t
430
- ]);
431
- return /* @__PURE__ */ React3.createElement(StackItem2.Content, {
432
- classNames: "block overflow-y-auto"
433
- }, /* @__PURE__ */ React3.createElement(ControlPage2, null, /* @__PURE__ */ React3.createElement(Clipboard2.Provider, null, /* @__PURE__ */ React3.createElement(ControlSection2, {
434
- title: t("profile label"),
435
- description: t("profile description")
436
- }, /* @__PURE__ */ React3.createElement(Form, {
437
- schema: ProfileSchema,
438
- values,
439
- autoSave: true,
440
- onSave: handleSave,
441
- Custom: customElements,
442
- classNames: 'p-0 container-max-width [&_[role="form"]]:grid [&_[role="form"]]:grid-cols-1 md:[&_[role="form"]]:grid-cols-[1fr_min-content] [&_[role="form"]]:gap-4'
443
- })))));
444
- };
445
- var ProfileSchema = Schema.Struct({
446
- displayName: Schema.String.annotations({
447
- title: "Display name"
448
- }),
449
- emoji: Schema.String.annotations({
450
- title: "Avatar"
451
- }),
452
- hue: Schema.String.annotations({
453
- title: "Color"
454
- }),
455
- did: Schema.String.annotations({
456
- title: "DID"
457
- })
458
- });
459
-
460
- // packages/plugins/plugin-client/src/components/RecoveryCodeDialog.tsx
461
- import React4, { useCallback as useCallback4, useState as useState3 } from "react";
462
- import { AlertDialog, Button as Button2, Clipboard as Clipboard3, Input as Input2, useTranslation as useTranslation4 } from "@dxos/react-ui";
463
- var RECOVERY_CODE_DIALOG = `${CLIENT_PLUGIN}/RecoveryCodeDialog`;
464
- var RecoveryCodeDialog = ({ code }) => {
465
- const { t } = useTranslation4(CLIENT_PLUGIN);
466
- const [confirmation, setConfirmation] = useState3(false);
467
- const handleConfirmation = useCallback4((checked) => setConfirmation(checked), []);
468
- return /* @__PURE__ */ React4.createElement(AlertDialog.Content, {
469
- classNames: "bs-content min-bs-[15rem] max-bs-full md:max-is-[40rem] overflow-hidden"
470
- }, /* @__PURE__ */ React4.createElement(AlertDialog.Title, null, t("recovery code dialog title")), /* @__PURE__ */ React4.createElement("p", {
471
- className: "py-4"
472
- }, t("recovery code dialog description")), /* @__PURE__ */ React4.createElement(Clipboard3.Provider, null, /* @__PURE__ */ React4.createElement(Code, {
473
- code
474
- })), /* @__PURE__ */ React4.createElement("div", {
475
- className: "flex flex-col py-4 gap-2"
476
- }, /* @__PURE__ */ React4.createElement("p", null, t("recovery code dialog warning 1")), /* @__PURE__ */ React4.createElement("p", null, t("recovery code dialog warning 2"))), /* @__PURE__ */ React4.createElement("div", {
477
- className: "flex items-center gap-2 pbe-4"
478
- }, /* @__PURE__ */ React4.createElement(Input2.Root, null, /* @__PURE__ */ React4.createElement(Input2.Checkbox, {
479
- "data-testid": "recoveryCode.confirm",
480
- checked: confirmation,
481
- onCheckedChange: handleConfirmation
482
- }), /* @__PURE__ */ React4.createElement(Input2.Label, null, t("recovery code confirmation label")))), /* @__PURE__ */ React4.createElement("div", {
483
- className: "flex justify-end"
484
- }, /* @__PURE__ */ React4.createElement(AlertDialog.Action, {
485
- asChild: true
486
- }, /* @__PURE__ */ React4.createElement(Button2, {
487
- "data-testid": "recoveryCode.continue",
488
- variant: "primary",
489
- disabled: !confirmation
490
- }, t("continue label")))));
491
- };
492
- var Code = ({ code }) => {
493
- const words = code.split(" ");
494
- return /* @__PURE__ */ React4.createElement("div", {
495
- className: "relative p-2 border border-separator rounded group"
496
- }, /* @__PURE__ */ React4.createElement(Clipboard3.IconButton, {
497
- value: code,
498
- classNames: "absolute top-2 right-2 invisible group-hover:visible"
499
- }), /* @__PURE__ */ React4.createElement("div", {
500
- className: "grid grid-cols-4"
501
- }, words.map((word, i) => /* @__PURE__ */ React4.createElement("div", {
502
- key: i,
503
- className: "flex items-center p-2 gap-2"
504
- }, /* @__PURE__ */ React4.createElement("div", {
505
- className: "w-4 text-xs text-center text-subdued"
506
- }, i + 1), /* @__PURE__ */ React4.createElement("div", {
507
- className: "text-sm"
508
- }, word)))));
509
- };
510
-
511
- // packages/plugins/plugin-client/src/components/RecoveryCredentialsContainer.tsx
512
- import React5 from "react";
513
- import { createIntent as createIntent3, useIntentDispatcher as useIntentDispatcher3 } from "@dxos/app-framework";
514
- import { useCredentials } from "@dxos/react-client/halo";
515
- import { Icon, IconButton as IconButton2, List as List2, ListItem, useTranslation as useTranslation5, Message } from "@dxos/react-ui";
516
- import { ControlGroup as ControlGroup2, ControlItem as ControlItem3, ControlPage as ControlPage3, ControlSection as ControlSection3 } from "@dxos/react-ui-form";
517
- import { StackItem as StackItem3 } from "@dxos/react-ui-stack";
518
- var MANAGE_CREDENTIALS_DIALOG = `${CLIENT_PLUGIN}/ManageCredentialsDialog`;
519
- var RecoveryCredentialsContainer = () => {
520
- const { t } = useTranslation5(CLIENT_PLUGIN);
521
- const { dispatchPromise: dispatch } = useIntentDispatcher3();
522
- const credentials = useCredentials();
523
- const recoveryCredentials = credentials.filter((credential) => credential.subject.assertion["@type"] === "dxos.halo.credentials.IdentityRecovery");
524
- return /* @__PURE__ */ React5.createElement(StackItem3.Content, {
525
- classNames: "block overflow-y-auto"
526
- }, /* @__PURE__ */ React5.createElement(ControlPage3, null, /* @__PURE__ */ React5.createElement(ControlSection3, {
527
- title: t("recovery setup dialog title"),
528
- description: t("recovery setup dialog description")
529
- }, /* @__PURE__ */ React5.createElement(ControlGroup2, null, /* @__PURE__ */ React5.createElement(ControlItem3, {
530
- title: t("create passkey label"),
531
- description: t("create passkey description")
532
- }, /* @__PURE__ */ React5.createElement(IconButton2, {
533
- label: t("create passkey label"),
534
- icon: "ph--key--duotone",
535
- variant: "primary",
536
- size: 5,
537
- onClick: () => dispatch(createIntent3(ClientAction.CreatePasskey))
538
- })), /* @__PURE__ */ React5.createElement(ControlItem3, {
539
- title: t("create recovery code label"),
540
- description: t("create recovery code description")
541
- }, /* @__PURE__ */ React5.createElement(IconButton2, {
542
- label: t("create recovery code label"),
543
- icon: "ph--receipt--duotone",
544
- variant: "default",
545
- size: 5,
546
- onClick: () => dispatch(createIntent3(ClientAction.CreateRecoveryCode))
547
- })))), /* @__PURE__ */ React5.createElement(ControlSection3, {
548
- title: t("credentials list label")
549
- }, recoveryCredentials.length < 1 ? /* @__PURE__ */ React5.createElement(Message.Root, {
550
- valence: "error",
551
- className: "container-max-width"
552
- }, /* @__PURE__ */ React5.createElement(Message.Title, null, /* @__PURE__ */ React5.createElement(Icon, {
553
- icon: "ph--shield-warning--duotone",
554
- size: 5,
555
- classNames: "inline-block align-top mbs-px mie-1"
556
- }), t("no credentials title")), /* @__PURE__ */ React5.createElement(Message.Body, null, t("no credentials message"))) : /* @__PURE__ */ React5.createElement(List2, {
557
- classNames: "container-max-width pli-2"
558
- }, recoveryCredentials.map((credential) => /* @__PURE__ */ React5.createElement(ListItem.Root, {
559
- key: credential.id?.toHex()
560
- }, /* @__PURE__ */ React5.createElement(ListItem.Endcap, null, /* @__PURE__ */ React5.createElement(Icon, {
561
- icon: "ph--key--regular",
562
- size: 5
563
- })), /* @__PURE__ */ React5.createElement(ListItem.Heading, null, credential.issuanceDate.toLocaleString())))))));
564
- };
565
-
566
- // packages/plugins/plugin-client/src/components/ResetDialog.tsx
567
- import React6, { useCallback as useCallback5 } from "react";
568
- import { createIntent as createIntent4, LayoutAction as LayoutAction2, useIntentDispatcher as useIntentDispatcher4 } from "@dxos/app-framework";
569
- import { useClient as useClient3 } from "@dxos/react-client";
570
- import { Dialog as Dialog2, useTranslation as useTranslation6 } from "@dxos/react-ui";
571
- import { ConfirmReset } from "@dxos/shell/react";
572
- var RESET_DIALOG = `${CLIENT_PLUGIN}/ResetDialog`;
573
- var ResetDialog = ({ mode, onReset }) => {
574
- const { t } = useTranslation6(CLIENT_PLUGIN);
575
- const { dispatchPromise: dispatch } = useIntentDispatcher4();
576
- const client = useClient3();
577
- const handleReset = useCallback5(async () => {
578
- await client.reset();
579
- const target = mode === "join new identity" ? "deviceInvitation" : mode === "recover" ? "recoverIdentity" : void 0;
580
- await onReset?.({
581
- target
582
- });
583
- }, [
584
- dispatch,
585
- client,
586
- mode,
587
- onReset
588
- ]);
589
- const handleCancel = useCallback5(() => {
590
- void dispatch(createIntent4(LayoutAction2.UpdateDialog, {
591
- part: "dialog",
592
- options: {
593
- state: false
594
- }
595
- }));
596
- }, [
597
- dispatch
598
- ]);
599
- return /* @__PURE__ */ React6.createElement(Dialog2.Content, {
600
- classNames: "bs-content min-bs-[15rem] max-bs-full md:max-is-[40rem] overflow-hidden"
601
- }, /* @__PURE__ */ React6.createElement(Dialog2.Title, {
602
- classNames: "sr-only"
603
- }, t("reset dialog title")), /* @__PURE__ */ React6.createElement(Dialog2.Description, {
604
- classNames: "sr-only"
605
- }, t("reset dialog description")), /* @__PURE__ */ React6.createElement(ConfirmReset, {
606
- active: true,
607
- mode,
608
- onConfirm: handleReset,
609
- onCancel: handleCancel
610
- }));
611
- };
612
-
613
- export {
614
- DevicesContainer,
615
- JOIN_DIALOG,
616
- JoinDialog,
617
- ProfileContainer,
618
- RECOVERY_CODE_DIALOG,
619
- RecoveryCodeDialog,
620
- RecoveryCredentialsContainer,
621
- RESET_DIALOG,
622
- ResetDialog
623
- };
624
- //# sourceMappingURL=chunk-34X2AMVA.mjs.map