-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
send auth and proof notifications (#57)
* send auth and proof notifications * add constructor for create contract invoke message
- Loading branch information
1 parent
0200e3b
commit a4998d8
Showing
4 changed files
with
87 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
package transport | ||
|
||
import ( | ||
"context" | ||
"encoding/json" | ||
|
||
"github.com/iden3/go-schema-processor/verifiable" | ||
"github.com/iden3/iden3comm/protocol" | ||
"github.com/iden3/iden3comm/transport/notification" | ||
"github.com/pkg/errors" | ||
) | ||
|
||
// SendPushAuthRequest sends authorization request to the user via a push notification. | ||
func SendPushAuthRequest( | ||
ctx context.Context, | ||
diddoc verifiable.DIDDocument, | ||
authMsg protocol.AuthorizationRequestMessage, | ||
) (*notification.UserNotificationResult, error) { | ||
authMsgBytes, err := json.Marshal(authMsg) | ||
if err != nil { | ||
return nil, errors.WithStack(err) | ||
} | ||
return notification.Notify( | ||
ctx, | ||
authMsgBytes, | ||
diddoc, | ||
nil, | ||
) | ||
} | ||
|
||
// SendPushContractInvokeRequest sends a contract invoke request to the user via a push notification. | ||
func SendPushContractInvokeRequest( | ||
ctx context.Context, | ||
diddoc verifiable.DIDDocument, | ||
contractInvokeMsg protocol.ContractInvokeRequestMessage, | ||
) (*notification.UserNotificationResult, error) { | ||
ciMsgBytes, err := json.Marshal(contractInvokeMsg) | ||
if err != nil { | ||
return nil, errors.WithStack(err) | ||
} | ||
return notification.Notify( | ||
ctx, | ||
ciMsgBytes, | ||
diddoc, | ||
nil, | ||
) | ||
} |