@agent-network-protocol/dsh-anp-identity 0.1.6 → 0.1.8

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 (116) hide show
  1. package/BOUNDARY.md +30 -5
  2. package/PUBLICATION.md +181 -0
  3. package/README.md +73 -1
  4. package/README.zh.md +44 -1
  5. package/V7-MANAGEMENT.md +18 -0
  6. package/cordis.patch.yml +9 -0
  7. package/examples/fresh-bootstrap.cordis.patch.yml +38 -0
  8. package/lib/authorization-types.d.ts +6 -0
  9. package/lib/authorization-types.d.ts.map +1 -1
  10. package/lib/authorization.d.ts.map +1 -1
  11. package/lib/authorization.js +23 -6
  12. package/lib/authorization.js.map +1 -1
  13. package/lib/catalog.d.ts +3 -1
  14. package/lib/catalog.d.ts.map +1 -1
  15. package/lib/catalog.js +15 -3
  16. package/lib/catalog.js.map +1 -1
  17. package/lib/client/controller.d.ts +18 -0
  18. package/lib/client/controller.d.ts.map +1 -1
  19. package/lib/client/controller.js +89 -5
  20. package/lib/client/controller.js.map +1 -1
  21. package/lib/client/views.d.ts.map +1 -1
  22. package/lib/client/views.js +37 -6
  23. package/lib/client/views.js.map +1 -1
  24. package/lib/client-metadata.d.ts +3 -0
  25. package/lib/client-metadata.d.ts.map +1 -0
  26. package/lib/client-metadata.js +11 -0
  27. package/lib/client-metadata.js.map +1 -0
  28. package/lib/client.js +260 -14
  29. package/lib/client.js.map +4 -4
  30. package/lib/host-management-secret.d.ts +41 -0
  31. package/lib/host-management-secret.d.ts.map +1 -0
  32. package/lib/host-management-secret.js +92 -0
  33. package/lib/host-management-secret.js.map +1 -0
  34. package/lib/index.d.ts +73 -3
  35. package/lib/index.d.ts.map +1 -1
  36. package/lib/index.js +331 -22
  37. package/lib/index.js.map +1 -1
  38. package/lib/initial-registration-proof.d.ts +13 -0
  39. package/lib/initial-registration-proof.d.ts.map +1 -0
  40. package/lib/initial-registration-proof.js +48 -0
  41. package/lib/initial-registration-proof.js.map +1 -0
  42. package/lib/installed-consumer.d.ts +25 -0
  43. package/lib/installed-consumer.d.ts.map +1 -0
  44. package/lib/installed-consumer.js +66 -0
  45. package/lib/installed-consumer.js.map +1 -0
  46. package/lib/management-credentials.d.ts +15 -0
  47. package/lib/management-credentials.d.ts.map +1 -0
  48. package/lib/management-credentials.js +126 -0
  49. package/lib/management-credentials.js.map +1 -0
  50. package/lib/management-driver.d.ts +83 -0
  51. package/lib/management-driver.d.ts.map +1 -0
  52. package/lib/management-driver.js +405 -0
  53. package/lib/management-driver.js.map +1 -0
  54. package/lib/management-remote.d.ts +27 -1
  55. package/lib/management-remote.d.ts.map +1 -1
  56. package/lib/management-remote.js +69 -3
  57. package/lib/management-remote.js.map +1 -1
  58. package/lib/management-types.d.ts +7 -0
  59. package/lib/management-types.d.ts.map +1 -1
  60. package/lib/pap-callback.d.ts +110 -0
  61. package/lib/pap-callback.d.ts.map +1 -0
  62. package/lib/pap-callback.js +51 -0
  63. package/lib/pap-callback.js.map +1 -0
  64. package/lib/protocol-bootstrap.d.ts +24 -0
  65. package/lib/protocol-bootstrap.d.ts.map +1 -0
  66. package/lib/protocol-bootstrap.js +34 -0
  67. package/lib/protocol-bootstrap.js.map +1 -0
  68. package/lib/protocol-client.d.ts +137 -0
  69. package/lib/protocol-client.d.ts.map +1 -0
  70. package/lib/protocol-client.js +11 -0
  71. package/lib/protocol-client.js.map +1 -0
  72. package/lib/provider-api.d.ts +6 -2
  73. package/lib/provider-api.d.ts.map +1 -1
  74. package/lib/provider-api.js.map +1 -1
  75. package/lib/publication-http.d.ts +19 -0
  76. package/lib/publication-http.d.ts.map +1 -0
  77. package/lib/publication-http.js +183 -0
  78. package/lib/publication-http.js.map +1 -0
  79. package/lib/publication-types.d.ts +161 -0
  80. package/lib/publication-types.d.ts.map +1 -0
  81. package/lib/publication-types.js +35 -0
  82. package/lib/publication-types.js.map +1 -0
  83. package/lib/publication.d.ts +21 -0
  84. package/lib/publication.d.ts.map +1 -0
  85. package/lib/publication.js +235 -0
  86. package/lib/publication.js.map +1 -0
  87. package/lib/registration-bootstrap.d.ts +56 -0
  88. package/lib/registration-bootstrap.d.ts.map +1 -0
  89. package/lib/registration-bootstrap.js +523 -0
  90. package/lib/registration-bootstrap.js.map +1 -0
  91. package/lib/registration-service-settings.d.ts +12 -0
  92. package/lib/registration-service-settings.d.ts.map +1 -0
  93. package/lib/registration-service-settings.js +124 -0
  94. package/lib/registration-service-settings.js.map +1 -0
  95. package/lib/registration-service-types.d.ts +11 -0
  96. package/lib/registration-service-types.d.ts.map +1 -0
  97. package/lib/registration-service-types.js +3 -0
  98. package/lib/registration-service-types.js.map +1 -0
  99. package/lib/remote.d.ts.map +1 -1
  100. package/lib/remote.js +11 -2
  101. package/lib/remote.js.map +1 -1
  102. package/lib/target-policy.d.ts +35 -0
  103. package/lib/target-policy.d.ts.map +1 -0
  104. package/lib/target-policy.js +319 -0
  105. package/lib/target-policy.js.map +1 -0
  106. package/lib/user-client.d.ts +6 -0
  107. package/lib/user-client.d.ts.map +1 -1
  108. package/lib/user-client.js.map +1 -1
  109. package/lib/user-operation.d.ts.map +1 -1
  110. package/lib/user-operation.js +9 -0
  111. package/lib/user-operation.js.map +1 -1
  112. package/lib/user-service.d.ts +8 -1
  113. package/lib/user-service.d.ts.map +1 -1
  114. package/lib/user-service.js +58 -4
  115. package/lib/user-service.js.map +1 -1
  116. package/package.json +51 -29
package/lib/client.js CHANGED
@@ -19704,6 +19704,52 @@ function date4(params) {
19704
19704
  return _coercedDate(ZodDate, params);
19705
19705
  }
19706
19706
 
19707
+ // src/publication-types.ts
19708
+ var LegacyPublicJwkSchema = external_exports.object({
19709
+ kty: external_exports.literal("OKP"),
19710
+ crv: external_exports.literal("Ed25519"),
19711
+ x: external_exports.string().regex(/^[A-Za-z0-9_-]{43}$/u),
19712
+ kid: external_exports.string().min(1).max(1024),
19713
+ alg: external_exports.literal("EdDSA"),
19714
+ use: external_exports.literal("sig")
19715
+ }).strict();
19716
+ var EcPublicJwkSchema = external_exports.object({
19717
+ kty: external_exports.literal("EC"),
19718
+ crv: external_exports.literal("P-256"),
19719
+ x: external_exports.string().regex(/^[A-Za-z0-9_-]{43}$/u),
19720
+ y: external_exports.string().regex(/^[A-Za-z0-9_-]{43}$/u),
19721
+ kid: external_exports.string().min(1).max(1024),
19722
+ alg: external_exports.literal("ES256"),
19723
+ use: external_exports.literal("sig")
19724
+ }).strict();
19725
+ var PublicJwkSchema = external_exports.union([LegacyPublicJwkSchema, EcPublicJwkSchema]);
19726
+ var PublicationCapabilitiesSchema = external_exports.object({
19727
+ mcpMachine: external_exports.boolean(),
19728
+ papSession: external_exports.boolean(),
19729
+ papAccount: external_exports.boolean()
19730
+ }).strict().refine((v) => (v.mcpMachine || v.papSession) && (!v.papAccount || v.papSession), "Invalid capability combination");
19731
+ var PublicationConfigSchema = external_exports.object({
19732
+ backend: external_exports.string().min(1).max(128),
19733
+ documentId: external_exports.string().regex(/^[A-Za-z0-9_-]{1,128}$/u),
19734
+ clientName: external_exports.string().trim().min(1).max(128),
19735
+ redirectUris: external_exports.array(external_exports.string().max(2048)).max(8),
19736
+ capabilities: PublicationCapabilitiesSchema.optional(),
19737
+ activeKid: external_exports.string().min(1).max(1024).optional()
19738
+ }).strict();
19739
+ var PublicationRecordSchema = external_exports.object({
19740
+ config: PublicationConfigSchema,
19741
+ operationId: external_exports.string().regex(/^[A-Za-z0-9_-]{1,128}$/u),
19742
+ expectedVersion: external_exports.number().int().nonnegative(),
19743
+ state: external_exports.enum(["awaiting_configuration", "publishing", "published", "failed"]),
19744
+ clientId: external_exports.string().max(2048),
19745
+ version: external_exports.number().int().nonnegative(),
19746
+ key: PublicJwkSchema,
19747
+ metadata: external_exports.string().max(16384).optional(),
19748
+ jwks: external_exports.string().max(16384).optional(),
19749
+ metadataSha256: external_exports.string().regex(/^[a-f0-9]{64}$/u).optional(),
19750
+ failure: external_exports.enum(["unavailable", "publication_failed", "material_mismatch"]).optional()
19751
+ }).strict().refine((value) => value.state !== "published" || !!value.metadata && !!value.jwks && !!value.metadataSha256 && value.version > 0, "Incomplete published materials");
19752
+
19707
19753
  // src/remote.ts
19708
19754
  var reference = external_exports.object({
19709
19755
  storeId: external_exports.string().min(1),
@@ -19724,10 +19770,15 @@ var decision = version2.extend({
19724
19770
  external_exports.enum(["identity:read", "identity:sign", "identity:http-auth"])
19725
19771
  ),
19726
19772
  signingPurposes: external_exports.array(external_exports.string()),
19727
- httpOrigins: external_exports.array(external_exports.string())
19773
+ httpOrigins: external_exports.array(external_exports.string()),
19774
+ oauthAudiences: external_exports.array(external_exports.string()).optional()
19728
19775
  }).strict().optional()
19729
19776
  }).strict();
19730
19777
  var methods = [
19778
+ ["registrationBootstrapStatus", void 0],
19779
+ ["registrationServiceSettings", void 0],
19780
+ ["configureRegistrationService", external_exports.object({ origin: external_exports.string().min(1).max(2048), expectedVersion: external_exports.number().int().nonnegative() }).strict()],
19781
+ ["submitRegistrationOtp", external_exports.object({ code: external_exports.string().regex(/^[0-9]{6}$/u) }).strict()],
19731
19782
  ["listIdentities", void 0],
19732
19783
  ["listRequests", external_exports.boolean().optional()],
19733
19784
  ["getRequest", external_exports.string().min(1)],
@@ -19741,6 +19792,9 @@ var methods = [
19741
19792
  }).strict()
19742
19793
  ],
19743
19794
  ["publicDocument", reference],
19795
+ ["publicationStatus", reference],
19796
+ ["retryPublication", reference],
19797
+ ["publishIdentity", external_exports.object({ reference, config: PublicationConfigSchema }).strict()],
19744
19798
  [
19745
19799
  "deleteIdentity",
19746
19800
  external_exports.object({ reference, confirmationName: external_exports.string().min(1) }).strict()
@@ -19765,14 +19819,14 @@ var contribution = {
19765
19819
  codec: {
19766
19820
  mode: "strict",
19767
19821
  typeSymbol: `anp-identity/manager#${method}Input`,
19768
- schema
19822
+ create: () => schema
19769
19823
  }
19770
19824
  }
19771
19825
  ],
19772
19826
  result: {
19773
19827
  mode: "strict",
19774
19828
  typeSymbol: `anp-identity/manager#${method}Result`,
19775
- schema: external_exports.json().nullable()
19829
+ create: () => external_exports.json().nullable()
19776
19830
  }
19777
19831
  }))
19778
19832
  };
@@ -19785,12 +19839,24 @@ var IdentityController = class {
19785
19839
  constructor(remote) {
19786
19840
  this.remote = remote;
19787
19841
  }
19842
+ /** Submit the code only to the authenticated manager; never retain it in view state. */
19843
+ async submitRegistrationOtp(code) {
19844
+ await this.action(async () => {
19845
+ if (!this.remote.submitRegistrationOtp) throw new Error("SMS registration is unavailable");
19846
+ const result = await this.remote.submitRegistrationOtp({ code });
19847
+ if (!result.ok) throw new Error("SMS verification could not be submitted");
19848
+ await this.refresh();
19849
+ });
19850
+ }
19788
19851
  view = {
19852
+ registrationService: null,
19789
19853
  loading: true,
19854
+ bootstraps: [],
19790
19855
  identities: [],
19791
19856
  requests: [],
19792
19857
  history: [],
19793
19858
  selectedKey: null,
19859
+ publication: null,
19794
19860
  grants: [],
19795
19861
  document: null,
19796
19862
  documentOpen: false,
@@ -19838,21 +19904,31 @@ var IdentityController = class {
19838
19904
  if (this.refreshing || this.disposed) return;
19839
19905
  this.refreshing = true;
19840
19906
  try {
19841
- const [identities, requests] = await Promise.all([
19907
+ const [identities, requests, bootstrapResult, settingsResult] = await Promise.all([
19842
19908
  this.call("listIdentities"),
19843
- this.call("listRequests", false)
19909
+ this.call("listRequests", false),
19910
+ this.remote.registrationBootstrapStatus?.(),
19911
+ this.remote.registrationServiceSettings?.()
19844
19912
  ]);
19913
+ if (settingsResult && !settingsResult.ok) throw new Error("Unable to read registration service settings");
19914
+ if (bootstrapResult && !bootstrapResult.ok) throw new Error("Unable to read protocol registration status");
19845
19915
  const selectedKey = identities.some(
19846
19916
  (i) => identityKey(identityReference(i)) === this.view.selectedKey
19847
19917
  ) ? this.view.selectedKey : identities[0] ? identityKey(identityReference(identities[0])) : null;
19848
19918
  const changed = selectedKey !== this.view.selectedKey;
19849
19919
  this.patch({
19850
19920
  loading: false,
19921
+ registrationService: settingsResult?.ok ? settingsResult.value : null,
19922
+ bootstraps: bootstrapResult?.ok ? bootstrapResult.value ?? [] : [],
19851
19923
  identities,
19852
19924
  requests: requests.filter((r) => r.status === "pending").sort((a, b) => b.createdAt - a.createdAt),
19853
19925
  selectedKey,
19854
- ...changed ? { grants: [], document: null, documentOpen: false } : {}
19926
+ ...changed ? { publication: null, grants: [], document: null, documentOpen: false } : {}
19855
19927
  });
19928
+ const modal = this.view.modal;
19929
+ if (modal?.kind === "request" && !this.view.pending && !requests.some((r) => r.id === modal.review.request.id && r.status === "pending" && r.version === modal.review.request.version)) {
19930
+ this.closeStaleRequest();
19931
+ }
19856
19932
  await this.loadGrants();
19857
19933
  if (!this.pauseQueue && this.view.modal === null) {
19858
19934
  const next = this.view.requests.find((r) => !r.prompted);
@@ -19867,10 +19943,28 @@ var IdentityController = class {
19867
19943
  this.refreshing = false;
19868
19944
  }
19869
19945
  }
19946
+ async configureRegistrationService(origin, expectedVersion) {
19947
+ if (this.view.pending || !this.remote.configureRegistrationService) return false;
19948
+ this.patch({ pending: true, error: null });
19949
+ try {
19950
+ const result = await this.remote.configureRegistrationService({ origin, expectedVersion });
19951
+ if (!result.ok) throw new Error(result.error.message);
19952
+ this.patch({ registrationService: result.value, notice: "\u8EAB\u4EFD\u670D\u52A1\u5730\u5740\u5DF2\u4FDD\u5B58\uFF0C\u4EC5\u7528\u4E8E\u540E\u7EED\u65B0\u6CE8\u518C\uFF1B\u5DF2\u6709\u8EAB\u4EFD\u548C\u6B63\u5728\u8FDB\u884C\u7684\u6D41\u7A0B\u4E0D\u4F1A\u8FC1\u79FB\u3002" });
19953
+ return true;
19954
+ } catch (error62) {
19955
+ const conflict = error62 instanceof Error && error62.message === "registration_service_conflict";
19956
+ if (conflict) await this.refresh();
19957
+ this.patch({ error: conflict ? "\u914D\u7F6E\u5DF2\u5728\u5176\u4ED6\u9875\u9762\u66F4\u65B0\uFF0C\u8BF7\u5237\u65B0\u540E\u91CD\u65B0\u786E\u8BA4\u3002" : "\u4FDD\u5B58\u5931\u8D25\uFF0C\u8BF7\u586B\u5199\u4E0D\u542B\u8DEF\u5F84\u3001\u53C2\u6570\u6216\u8D26\u6237\u4FE1\u606F\u7684 HTTPS \u670D\u52A1\u6839\u5730\u5740\u3002" });
19958
+ return false;
19959
+ } finally {
19960
+ this.patch({ pending: false });
19961
+ }
19962
+ }
19870
19963
  async selectIdentity(key) {
19871
19964
  this.selectionVersion++;
19872
19965
  this.patch({
19873
19966
  selectedKey: key,
19967
+ publication: null,
19874
19968
  grants: [],
19875
19969
  document: null,
19876
19970
  documentOpen: false,
@@ -19891,9 +19985,12 @@ var IdentityController = class {
19891
19985
  const selected = this.selected();
19892
19986
  if (!selected) return;
19893
19987
  const key = this.view.selectedKey;
19894
- const grants = await this.call("grants", identityReference(selected));
19988
+ const [grants, publication] = await Promise.all([
19989
+ this.call("grants", identityReference(selected)),
19990
+ selected.catalogState === "active" ? this.call("publicationStatus", identityReference(selected)).catch(() => ({ state: "failed", did: selected.reference.did })) : Promise.resolve(null)
19991
+ ]);
19895
19992
  if (this.view.selectedKey === key) {
19896
- this.patch({ grants: grants.filter((g) => g.status === "active") });
19993
+ this.patch({ publication, grants: grants.filter((g) => g.status === "active") });
19897
19994
  const modal = this.view.modal;
19898
19995
  if ((modal?.kind === "permissions" || modal?.kind === "revoke") && !grants.some(
19899
19996
  (g) => g.id === modal.grant.id && g.status === "active" && g.version === modal.grant.version
@@ -19943,6 +20040,11 @@ var IdentityController = class {
19943
20040
  if (focus?.isConnected) focus.focus();
19944
20041
  });
19945
20042
  }
20043
+ closeStaleRequest() {
20044
+ this.patch({ pending: false });
20045
+ this.closeModal();
20046
+ this.patch({ notice: "\u6B64\u6388\u6743\u8BF7\u6C42\u5DF2\u5904\u7406\u3001\u5DF2\u8FC7\u671F\u6216\u5DF2\u53D8\u66F4\uFF0C\u65E7\u5F39\u7A97\u5DF2\u5173\u95ED\u3002\u8BF7\u67E5\u770B\u6388\u6743\u8BF7\u6C42\u7684\u6700\u65B0\u72B6\u6001\uFF1B\u4E0D\u4F1A\u81EA\u52A8\u91CD\u590D\u6388\u6743\u3002" });
20047
+ }
19946
20048
  async decide(decision2) {
19947
20049
  const modal = this.view.modal;
19948
20050
  if (modal?.kind !== "request" || this.view.pending) return;
@@ -19960,7 +20062,12 @@ var IdentityController = class {
19960
20062
  this.closeModal(false);
19961
20063
  await this.refresh();
19962
20064
  } catch (error62) {
19963
- this.fail(error62);
20065
+ if (error62 instanceof Error && ["request_conflict", "request_not_pending", "request_not_found"].includes(error62.message)) {
20066
+ this.closeStaleRequest();
20067
+ await this.refresh();
20068
+ } else {
20069
+ this.fail(error62);
20070
+ }
19964
20071
  } finally {
19965
20072
  this.patch({ pending: false });
19966
20073
  }
@@ -20022,6 +20129,19 @@ var IdentityController = class {
20022
20129
  await this.refresh();
20023
20130
  });
20024
20131
  }
20132
+ async retryPublication() {
20133
+ const selected = this.selected();
20134
+ if (!selected || this.view.pending) return;
20135
+ this.patch({ pending: true, error: null });
20136
+ try {
20137
+ await this.call("retryPublication", identityReference(selected));
20138
+ await this.refresh();
20139
+ } catch {
20140
+ this.patch({ error: "\u8EAB\u4EFD\u53D1\u5E03\u5C1A\u672A\u5B8C\u6210\uFF0C\u8BF7\u68C0\u67E5\u8EAB\u4EFD\u6258\u7BA1\u914D\u7F6E\u540E\u91CD\u8BD5\u3002" });
20141
+ } finally {
20142
+ this.patch({ pending: false });
20143
+ }
20144
+ }
20025
20145
  async toggleDocument() {
20026
20146
  if (this.view.documentOpen) {
20027
20147
  this.patch({ documentOpen: false, document: null });
@@ -20146,13 +20266,64 @@ function Scope({
20146
20266
  "\u7B7E\u540D\u7528\u9014\uFF1A",
20147
20267
  snapshot.signingPurposes.join("\u3001") || "\u65E0"
20148
20268
  ] }),
20269
+ !!snapshot.oauthAudiences?.length && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("p", { children: [
20270
+ "OAuth \u76EE\u6807\uFF1A",
20271
+ snapshot.oauthAudiences.join("\u3001")
20272
+ ] }),
20149
20273
  /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("p", { className: "anpi-break", children: [
20150
20274
  "\u7F51\u7AD9\uFF1A",
20151
- snapshot.httpOrigins.join("\u3001") || "\u65E0"
20275
+ snapshot.httpOrigins.includes("*") ? "\u5168\u90E8 HTTPS \u57DF\u540D\uFF08\u901A\u914D\u6743\u9650\uFF09" : snapshot.httpOrigins.join("\u3001") || "\u65E0"
20152
20276
  ] })
20153
20277
  ] }) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { children: "\u65E0\u6CD5\u8BFB\u53D6\u6743\u9650\u8303\u56F4\uFF0C\u6682\u4E0D\u80FD\u6388\u6743\u3002" }),
20154
20278
  /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { className: "anpi-small", children: FULL_PERMISSION_NOTICE }),
20155
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { className: "anpi-small", children: "\u7B7E\u540D\u53EF\u5728\u5916\u90E8\u4F7F\u7528\uFF0C\u4E0D\u53D7\u7F51\u7AD9\u5217\u8868\u9650\u5236\u3002" })
20279
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { className: "anpi-small", children: snapshot?.capabilities.includes("identity:sign") ? "\u7B7E\u540D\u53EF\u5728\u5916\u90E8\u4F7F\u7528\uFF0C\u4E0D\u53D7\u7F51\u7AD9\u5217\u8868\u9650\u5236\u3002" : "\u4EC5\u5141\u8BB8\u516C\u5F00\u8EAB\u4EFD\u8BFB\u53D6\u4E0E\u7CBE\u786E HTTP \u8BF7\u6C42\u8BA4\u8BC1\uFF0C\u4E0D\u63D0\u4F9B\u8BBE\u5907\u65AD\u8A00\u6216\u901A\u7528\u7B7E\u540D\u6743\u9650\u3002" })
20280
+ ] });
20281
+ }
20282
+ function RegistrationServiceForm({ controller, settings, pending }) {
20283
+ const [draft, setDraft] = (0, import_react.useState)(settings.origin);
20284
+ const [version3, setVersion] = (0, import_react.useState)(settings.version);
20285
+ const [dirty, setDirty] = (0, import_react.useState)(false);
20286
+ (0, import_react.useEffect)(() => {
20287
+ if (!dirty) {
20288
+ setDraft(settings.origin);
20289
+ setVersion(settings.version);
20290
+ }
20291
+ }, [settings.origin, settings.version, dirty]);
20292
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "anpi-section", children: [
20293
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("h3", { children: "\u8EAB\u4EFD\u670D\u52A1" }),
20294
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("form", { onSubmit: (event) => {
20295
+ event.preventDefault();
20296
+ void controller.configureRegistrationService(draft, version3).then((saved) => {
20297
+ if (saved) setDirty(false);
20298
+ });
20299
+ }, children: [
20300
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("label", { children: [
20301
+ "\u8EAB\u4EFD\u670D\u52A1\u5730\u5740 ",
20302
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
20303
+ "input",
20304
+ {
20305
+ "aria-label": "\u8EAB\u4EFD\u670D\u52A1\u5730\u5740",
20306
+ type: "url",
20307
+ required: true,
20308
+ value: draft,
20309
+ placeholder: "https://awiki.me",
20310
+ disabled: pending,
20311
+ onChange: (event) => {
20312
+ setDraft(event.target.value);
20313
+ setDirty(true);
20314
+ }
20315
+ }
20316
+ )
20317
+ ] }),
20318
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_dsh_client_ui_primitives.Button, { disabled: pending || !dirty || !draft.trim(), type: "submit", children: "\u4FDD\u5B58\u670D\u52A1\u5730\u5740" }),
20319
+ dirty && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_dsh_client_ui_primitives.Button, { disabled: pending, type: "button", onClick: () => {
20320
+ setDraft(settings.origin);
20321
+ setVersion(settings.version);
20322
+ setDirty(false);
20323
+ }, children: "\u91CD\u65B0\u8F7D\u5165\u5DF2\u4FDD\u5B58\u5730\u5740" })
20324
+ ] }),
20325
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { className: "anpi-small", children: "\u9ED8\u8BA4 https://awiki.me\u3002\u8FD9\u91CC\u53EA\u4FDD\u5B58\u65B0\u6CE8\u518C\u4F7F\u7528\u7684 HTTPS \u6839\u5730\u5740\uFF0C\u4E0D\u53D1\u9001\u9A8C\u8BC1\u7801\u3001\u4E0D\u521B\u5EFA\u8EAB\u4EFD\u3002" }),
20326
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { className: "anpi-small", children: "\u5DF2\u6709\u8EAB\u4EFD\u548C\u6B63\u5728\u8FDB\u884C\u7684\u6CE8\u518C\u7EE7\u7EED\u4F7F\u7528\u539F\u670D\u52A1\u3002\u8DE8\u670D\u52A1\u6CE8\u518C\u5FC5\u987B\u521B\u5EFA\u65B0\u7684\u8EAB\u4EFD\u53CA\u6CE8\u518C\u6D41\u7A0B\uFF0C\u4E0D\u80FD\u53EA\u4FEE\u6539\u5DF2\u6709 DID \u7684\u57DF\u540D\u3002" })
20156
20327
  ] });
20157
20328
  }
20158
20329
  function IdentitySettings({
@@ -20164,11 +20335,65 @@ function IdentitySettings({
20164
20335
  );
20165
20336
  const [tab, setTab] = (0, import_react.useState)("identities");
20166
20337
  const [history, setHistory] = (0, import_react.useState)(false);
20338
+ const [otp, setOtp] = (0, import_react.useState)("");
20167
20339
  const identity = controller.selected();
20168
20340
  const blocked = identity?.deleteBlockedReason || (view.grants.length || identity?.integrations.length ? "\u8BF7\u5148\u89E3\u9664\u63D2\u4EF6\u548C\u96C6\u6210\u5173\u8054" : "");
20169
20341
  return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("section", { className: "anpi", children: [
20170
20342
  /* @__PURE__ */ (0, import_jsx_runtime.jsx)("h2", { children: "\u8EAB\u4EFD" }),
20171
20343
  /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { className: "anpi-muted", children: "\u7BA1\u7406\u6B64 DSH \u4E2D\u4FDD\u5B58\u7684\u8EAB\u4EFD" }),
20344
+ view.registrationService && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(RegistrationServiceForm, { controller, settings: view.registrationService, pending: view.pending }),
20345
+ view.bootstraps.map((bootstrap) => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "anpi-section", role: "status", children: [
20346
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("h3", { children: "\u534F\u8BAE\u8EAB\u4EFD\u6CE8\u518C" }),
20347
+ bootstrap.origin && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("p", { className: "anpi-small", children: [
20348
+ "\u6CE8\u518C\u670D\u52A1\uFF1A",
20349
+ bootstrap.origin
20350
+ ] }),
20351
+ bootstrap.clientVersion && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("p", { className: "anpi-small", children: [
20352
+ "\u5BA2\u6237\u7AEF\u7248\u672C\u5934\uFF1A",
20353
+ bootstrap.clientVersion
20354
+ ] }),
20355
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { children: {
20356
+ awaiting_approval: "\u7B49\u5F85\u521B\u5EFA\u5BA1\u6279",
20357
+ awaiting_email_verification: "\u7B49\u5F85\u90AE\u7BB1\u6FC0\u6D3B\u786E\u8BA4",
20358
+ awaiting_phone_verification: "\u7B49\u5F85\u77ED\u4FE1\u9A8C\u8BC1\u7801",
20359
+ registering: "\u6CE8\u518C\u4E2D",
20360
+ publishing: "\u53D1\u5E03\u4E2D",
20361
+ published: "\u5DF2\u53D1\u5E03",
20362
+ registration_uncertain: "\u6CE8\u518C\u7ED3\u679C\u4E0D\u786E\u5B9A\uFF0C\u9700\u8981\u7BA1\u7406\u5904\u7406",
20363
+ blocked: "\u6CE8\u518C\u6682\u4E0D\u53EF\u7528",
20364
+ disposed: "\u5DF2\u505C\u6B62"
20365
+ }[bootstrap.phase] }),
20366
+ bootstrap.phase === "published" && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { className: "anpi-small", children: "\u6CE8\u518C\u4E0E\u53D1\u5E03\u5DF2\u5B8C\u6210\uFF1B\u8FD8\u9700\u7531 Host \u914D\u7F6E\u534F\u8BAE\u7528\u9014\u8BB8\u53EF\u548C\u6D88\u8D39\u8005\u8FDE\u63A5\u3002" }),
20367
+ bootstrap.reason === "client_upgrade_required" && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { className: "anpi-small", children: "\u670D\u52A1\u7AEF\u8FD4\u56DE client.upgrade_required\uFF0C\u4E0D\u80FD\u5C06 HTTP 200 \u89C6\u4E3A\u6210\u529F\u3002\u8BF7\u6838\u5BF9\u4E0A\u65B9\u6CE8\u518C\u670D\u52A1\u548C\u5BA2\u6237\u7AEF\u7248\u672C\uFF0C\u5B8C\u6210\u51C6\u5165\u914D\u7F6E\u6216\u5347\u7EA7\u3002" }),
20368
+ bootstrap.reason === "phone_unavailable" && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { className: "anpi-small", children: "\u77ED\u4FE1\u9A8C\u8BC1\u7801\u8BF7\u6C42\u672A\u786E\u8BA4\u6210\u529F\uFF0C\u8BF7\u68C0\u67E5\u670D\u52A1\u7AEF\u624B\u673A\u53F7\u6CE8\u518C\u914D\u7F6E\u3002\u4E0D\u4F1A\u81EA\u52A8\u91CD\u53D1\u6216\u7ED5\u8FC7\u9A8C\u8BC1\u3002" }),
20369
+ bootstrap.phase === "awaiting_phone_verification" && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("form", { onSubmit: (event) => {
20370
+ event.preventDefault();
20371
+ const code = otp;
20372
+ setOtp("");
20373
+ void controller.submitRegistrationOtp(code);
20374
+ }, children: [
20375
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { className: "anpi-small", children: "\u53D1\u9001\u8BF7\u6C42\u5DF2\u53D7\u7406\u4E0D\u7B49\u4E8E\u77ED\u4FE1\u5DF2\u9001\u8FBE\u3002\u8BF7\u4F7F\u7528\u6B64\u6CE8\u518C\u670D\u52A1\u4E3A\u5F53\u524D Handle \u7B7E\u53D1\u7684\u9A8C\u8BC1\u7801\uFF0C\u4E0D\u80FD\u590D\u7528\u5176\u4ED6\u73AF\u5883\u6216\u767B\u5F55\u6D41\u7A0B\u7684\u9A8C\u8BC1\u7801\u3002" }),
20376
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("label", { children: [
20377
+ "\u77ED\u4FE1\u9A8C\u8BC1\u7801 ",
20378
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
20379
+ "input",
20380
+ {
20381
+ "aria-label": "\u77ED\u4FE1\u9A8C\u8BC1\u7801",
20382
+ type: "password",
20383
+ inputMode: "numeric",
20384
+ autoComplete: "one-time-code",
20385
+ maxLength: 6,
20386
+ value: otp,
20387
+ onChange: (event) => setOtp(event.target.value)
20388
+ }
20389
+ )
20390
+ ] }),
20391
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", { type: "submit", disabled: view.pending || !/^[0-9]{6}$/u.test(otp), children: "\u9A8C\u8BC1\u5E76\u6CE8\u518C" })
20392
+ ] }),
20393
+ bootstrap.reference && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(CopyRow, { label: "DID", value: bootstrap.reference.did, controller }),
20394
+ bootstrap.reference && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(CopyRow, { label: "\u672C\u5730\u8EAB\u4EFD\u5F15\u7528", value: JSON.stringify(bootstrap.reference), controller }),
20395
+ bootstrap.clientId && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(CopyRow, { label: "CIMD", value: bootstrap.clientId, controller })
20396
+ ] }, bootstrap.id)),
20172
20397
  /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "anpi-tabs", role: "tablist", "aria-label": "\u8EAB\u4EFD\u7BA1\u7406", children: [
20173
20398
  /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
20174
20399
  "button",
@@ -20269,6 +20494,19 @@ function IdentitySettings({
20269
20494
  }
20270
20495
  )
20271
20496
  ] }),
20497
+ view.publication && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "anpi-section", children: [
20498
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("h3", { children: "\u5BF9\u5916\u8EAB\u4EFD" }),
20499
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { children: { local: "\u5C1A\u672A\u53D1\u5E03", awaiting_configuration: "\u7B49\u5F85\u8EAB\u4EFD\u6258\u7BA1\u914D\u7F6E", publishing: "\u53D1\u5E03\u4E2D", published: "\u5DF2\u53D1\u5E03", failed: "\u53D1\u5E03\u672A\u5B8C\u6210" }[view.publication.state] }),
20500
+ view.publication.capabilities && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { children: [
20501
+ view.publication.capabilities.mcpMachine ? "MCP \u673A\u5668\u8BBF\u95EE\uFF08\u65E0\u9700\u56DE\u8C03\u5730\u5740\uFF09" : "",
20502
+ view.publication.capabilities.papSession ? "PAP \u4F1A\u8BDD" : "",
20503
+ view.publication.capabilities.papAccount ? "PAP \u8D26\u6237\u6388\u6743" : ""
20504
+ ].filter(Boolean).join(" \xB7 ") }),
20505
+ view.publication.clientId && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(CopyRow, { label: "CIMD", value: view.publication.clientId, controller }),
20506
+ view.publication.state === "failed" && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_dsh_client_ui_primitives.Button, { disabled: view.pending, onClick: () => {
20507
+ void controller.retryPublication();
20508
+ }, children: "\u91CD\u8BD5\u53D1\u5E03" })
20509
+ ] }),
20272
20510
  /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "anpi-section", children: [
20273
20511
  /* @__PURE__ */ (0, import_jsx_runtime.jsx)("h3", { children: "\u4F60\u6388\u6743\u7684\u63D2\u4EF6" }),
20274
20512
  view.grants.length === 0 && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { className: "anpi-muted", children: "\u6682\u65E0\u6388\u6743\u7684\u63D2\u4EF6" }),
@@ -20580,7 +20818,15 @@ function IdentityModal({
20580
20818
  /* @__PURE__ */ (0, import_jsx_runtime.jsx)("dt", { children: "DID \u57DF\u540D" }),
20581
20819
  /* @__PURE__ */ (0, import_jsx_runtime.jsx)("dd", { children: request.parameters.domain }),
20582
20820
  /* @__PURE__ */ (0, import_jsx_runtime.jsx)("dt", { children: "\u8EAB\u4EFD\u8DEF\u5F84" }),
20583
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("dd", { children: request.parameters.path })
20821
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("dd", { children: request.parameters.path }),
20822
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("dt", { children: "\u7528\u9014" }),
20823
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("dd", { children: request.parameters.usage === "protocol" ? "MCP / PAP \u534F\u8BAE\u8EAB\u4EFD\uFF08\u72EC\u7ACB\u8BBE\u5907\u6743\u9650\uFF09" : "\u666E\u901A\u63D2\u4EF6\u8EAB\u4EFD" }),
20824
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("dt", { children: "\u8EAB\u4EFD\u65B9\u6CD5" }),
20825
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("dd", { children: request.parameters.profile ?? "e1" }),
20826
+ request.parameters.usage === "protocol" && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
20827
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("dt", { children: "\u8BBE\u5907\u80FD\u529B" }),
20828
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("dd", { children: request.parameters.identityOnly ? "\u4EC5\u516C\u5171\u8EAB\u4EFD\uFF08\u4E0D\u542B\u6D88\u606F\u80FD\u529B\uFF09" : "\u8EAB\u4EFD\u4E0E\u6D88\u606F\u80FD\u529B" })
20829
+ ] })
20584
20830
  ] }),
20585
20831
  /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { children: "\u53C2\u6570\u7531\u63D2\u4EF6\u63D0\u4F9B\uFF0C\u8BF7\u786E\u8BA4\u540E\u7EE7\u7EED\u3002" }),
20586
20832
  /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { className: "anpi-small", children: "Handle \u7531\u7533\u8BF7\u63D2\u4EF6\u63D0\u4F9B\uFF0C\u4FDD\u5B58\u4E0D\u4EE3\u8868\u5DF2\u5728\u670D\u52A1\u7AEF\u6CE8\u518C\u6216\u9A8C\u8BC1\u3002" }),
@@ -20811,7 +21057,7 @@ function AccessForm({
20811
21057
  review.unavailableReason && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { role: "alert", children: review.unavailableReason }),
20812
21058
  /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "anpi-access-scope", children: [
20813
21059
  /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { className: "anpi-small", children: FULL_PERMISSION_NOTICE }),
20814
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { className: "anpi-small", children: "\u7B7E\u540D\u53EF\u5728\u5916\u90E8\u4F7F\u7528\uFF0C\u4E0D\u53D7\u7F51\u7AD9\u5217\u8868\u9650\u5236\u3002" }),
21060
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { className: "anpi-small", children: snapshot?.capabilities.includes("identity:sign") ? "\u7B7E\u540D\u53EF\u5728\u5916\u90E8\u4F7F\u7528\uFF0C\u4E0D\u53D7\u7F51\u7AD9\u5217\u8868\u9650\u5236\u3002" : "\u4EC5\u5141\u8BB8\u516C\u5F00\u8EAB\u4EFD\u8BFB\u53D6\u4E0E\u7CBE\u786E HTTP \u8BF7\u6C42\u8BA4\u8BC1\uFF0C\u4E0D\u63D0\u4F9B\u8BBE\u5907\u65AD\u8A00\u6216\u901A\u7528\u7B7E\u540D\u6743\u9650\u3002" }),
20815
21061
  /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("details", { children: [
20816
21062
  /* @__PURE__ */ (0, import_jsx_runtime.jsx)("summary", { children: "\u5168\u90E8\u4F7F\u7528\u6743\u9650 \xB7 \u67E5\u770B\u8303\u56F4" }),
20817
21063
  snapshot ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
@@ -20826,7 +21072,7 @@ function AccessForm({
20826
21072
  ] }),
20827
21073
  /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("p", { className: "anpi-small anpi-break", children: [
20828
21074
  "\u7F51\u7AD9\uFF1A",
20829
- snapshot?.httpOrigins.join("\u3001") || "\u65E0"
21075
+ snapshot?.httpOrigins.includes("*") ? "\u5168\u90E8 HTTPS \u57DF\u540D\uFF08\u901A\u914D\u6743\u9650\uFF09" : snapshot?.httpOrigins.join("\u3001") || "\u65E0"
20830
21076
  ] })
20831
21077
  ] }),
20832
21078
  /* @__PURE__ */ (0, import_jsx_runtime.jsx)(