@kubun/plugin-p2p 0.17.0 → 0.17.1

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 (2) hide show
  1. package/lib/schema.js +79 -0
  2. package/package.json +2 -2
package/lib/schema.js CHANGED
@@ -114,6 +114,11 @@ const CONTROL_REQUEST_KIND_TO_SDL = {
114
114
  invite: 'INVITE',
115
115
  remove: 'REMOVE'
116
116
  };
117
+ // Internal lowercase record-provisioning outcome -> SDL enum name.
118
+ const RECORD_PROVISIONING_STATUS_TO_SDL = {
119
+ recorded: 'RECORDED',
120
+ retry: 'RETRY'
121
+ };
117
122
  /** Project a control request into its SDL shape, mapping both enums to uppercase. */ function toControlRequestSDL(request) {
118
123
  return {
119
124
  ...request,
@@ -692,6 +697,33 @@ type CredentialProvisioningStatus {
692
697
  reason: String
693
698
  }
694
699
 
700
+ type BeginProvisioningExpectationPayload {
701
+ """
702
+ Freshly minted attempt id; pass it to recordProvisioningExpectation /
703
+ abandonProvisioningExpectation to close this attempt.
704
+ """
705
+ attemptId: ID!
706
+ }
707
+
708
+ enum RecordProvisioningExpectationStatus {
709
+ """The attempt's epoch bound the provisioning floor for this owner/grantor."""
710
+ RECORDED
711
+ """
712
+ A higher manifest already landed; the floor was not lowered. Re-run the grant
713
+ with minEpoch, then record the new attempt.
714
+ """
715
+ RETRY
716
+ }
717
+
718
+ type RecordProvisioningExpectationPayload {
719
+ status: RecordProvisioningExpectationStatus!
720
+ """
721
+ Present only on RETRY: the recipient's now-held epoch. Re-run the grant with
722
+ this as the new minEpoch.
723
+ """
724
+ minEpoch: Int
725
+ }
726
+
695
727
  extend type Mutation {
696
728
  connectPeer(url: String!): ConnectPeerPayload!
697
729
  sharePeerGroup(peerDID: ID!, groupID: ID, name: String, send: ShareInput, receive: ShareReceiveInput): SharePeerGroupPayload!
@@ -711,6 +743,27 @@ extend type Mutation {
711
743
  reprovision attempt always supersedes a manifest it already holds. Defaults to 0.
712
744
  """
713
745
  grantDeviceCredentials(groupID: ID!, recipientDID: DID!, ownerDID: DID!, minEpoch: Int): GrantDeviceCredentialsPayload!
746
+ """
747
+ Arm this device to converge a credential grant for ownerDID from grantorDID:
748
+ write the provisioning-expectation row that lets the credential-reconcile PULL
749
+ fetch that owner's buckets (a delegate-signed grant converges only via the
750
+ pull, never the live apply). Call before asking the grantor to grant, then
751
+ recordProvisioningExpectation once the grant returns its epoch. Mirrors the
752
+ credentialProvisioningStatus query's recipient-local surface.
753
+ """
754
+ beginProvisioningExpectation(ownerDID: DID!, grantorDID: DID!): BeginProvisioningExpectationPayload!
755
+ """
756
+ Bind the provisioning floor for an in-flight attempt to the epoch its grant was
757
+ signed under. Returns RECORDED when the floor binds, or RETRY with the held
758
+ epoch when a higher manifest already landed (re-grant with minEpoch, then record
759
+ the new attempt).
760
+ """
761
+ recordProvisioningExpectation(ownerDID: DID!, grantorDID: DID!, attemptId: ID!, epoch: Int!): RecordProvisioningExpectationPayload!
762
+ """
763
+ Stop tracking one provisioning attempt. Removes only this attemptId; never binds
764
+ or lowers a floor. Returns true.
765
+ """
766
+ abandonProvisioningExpectation(ownerDID: DID!, grantorDID: DID!, attemptId: ID!): Boolean!
714
767
  joinPeerGroup(peerDID: ID!, groupID: ID!): JoinPeerGroupPayload!
715
768
  """
716
769
  Apply one circle's desired sync end state. A null argument leaves that dimension
@@ -1043,6 +1096,32 @@ export function createP2PSchemaExtension(emitter, syncManager, logger = getKubun
1043
1096
  epoch
1044
1097
  };
1045
1098
  },
1099
+ beginProvisioningExpectation: async (_source, args, context)=>{
1100
+ return await requireP2P(context).peer.beginProvisioningExpectation({
1101
+ ownerDID: args.ownerDID,
1102
+ grantorDID: args.grantorDID
1103
+ });
1104
+ },
1105
+ recordProvisioningExpectation: async (_source, args, context)=>{
1106
+ const result = await requireP2P(context).peer.recordProvisioningExpectation({
1107
+ ownerDID: args.ownerDID,
1108
+ grantorDID: args.grantorDID,
1109
+ attemptId: args.attemptId,
1110
+ epoch: args.epoch
1111
+ });
1112
+ return {
1113
+ status: RECORD_PROVISIONING_STATUS_TO_SDL[result.status],
1114
+ minEpoch: result.status === 'retry' ? result.minEpoch : null
1115
+ };
1116
+ },
1117
+ abandonProvisioningExpectation: async (_source, args, context)=>{
1118
+ await requireP2P(context).peer.abandonProvisioningExpectation({
1119
+ ownerDID: args.ownerDID,
1120
+ grantorDID: args.grantorDID,
1121
+ attemptId: args.attemptId
1122
+ });
1123
+ return true;
1124
+ },
1046
1125
  joinPeerGroup: async (_source, args, context)=>{
1047
1126
  return await requireP2P(context).peer.joinPeerGroup({
1048
1127
  peerDID: args.peerDID,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kubun/plugin-p2p",
3
- "version": "0.17.0",
3
+ "version": "0.17.1",
4
4
  "license": "see LICENSE.md",
5
5
  "sideEffects": false,
6
6
  "type": "module",
@@ -74,7 +74,7 @@
74
74
  "@kubun/db-postgres": "^0.17.0",
75
75
  "@kubun/hub": "^0.17.0",
76
76
  "@kubun/plugin-blob": "^0.17.0",
77
- "@kubun/plugin-connector": "^0.17.0",
77
+ "@kubun/plugin-connector": "^0.17.1",
78
78
  "@kubun/plugin-service-server": "^0.17.0",
79
79
  "@kubun/plugin-workflow": "^0.17.0",
80
80
  "@kubun/service-graph-api": "^0.17.0",