-
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.
- Loading branch information
Showing
2 changed files
with
82 additions
and
0 deletions.
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
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/v2/verifiable" | ||
"github.com/iden3/iden3comm/v2/protocol" | ||
"github.com/iden3/iden3comm/v2/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, | ||
) | ||
} |