nspcc-dev / neofs-sdk-go

Go implementation of NeoFS SDK
Apache License 2.0
5 stars 14 forks source link

Issue deleting object with Wallet Connect as the signature generator #530

Open amlwwalker opened 8 months ago

amlwwalker commented 8 months ago

Trying to delete an object for a container while using an intermediary key and signing 'out of band'

    pl, err := m.Pool(false)
    if err != nil {
        log.Println("error retrieving pool ", err)
        return nil, err
    }
    cliSdk, err := pl.RawClient()
    if err != nil {
        log.Println("delete could not get client")
        return nil, err
    }
    gateSigner := user.NewAutoIDSignerRFC6979(m.gateAccount.PrivateKey().PrivateKey)
    netInfo, err := cliSdk.NetworkInfo(context.Background(), client.PrmNetworkInfo{})
    if err != nil {
        return nil, fmt.Errorf("read current network info: %w", err)
    }

    var sessionToken session.Object
    sessionToken.SetAuthKey(gateSigner.Public()) 
    sessionToken.SetID(uuid.New())
    sessionToken.SetIat(netInfo.CurrentEpoch())
    sessionToken.SetNbf(netInfo.CurrentEpoch())
    sessionToken.SetExp(netInfo.CurrentEpoch() + 100) // or particular exp value
    sessionToken.BindContainer(cnrID)
    sessionToken.ForVerb(session.VerbObjectDelete)
    if err := m.TemporarySignObjectTokenWithPrivateKey(&sessionToken); err != nil {
        log.Println("error signing session token to create a object", err)
        return nil, err
    }

    var prmDelete client.PrmObjectDelete
    prmDelete.WithinSession(sessionToken)
    if _, err := pl.ObjectDelete(m.ctx, cnrID, objID, gateSigner, prmDelete); err != nil {
        ...
    }

gives me the error

Object xxxx could not be deleted: status: code = 4096 message = session token not found and could not be deleted: status: code = 4096 message = session token not found map[]

I have this working for creating/listing/downloading objects but for some reason can't get working for deleting. Any obvious mistake I've made here?

amlwwalker commented 7 months ago

Any progress here by any chance?

roman-khimov commented 7 months ago

@carpawell, could it be related to https://github.com/nspcc-dev/neofs-node/issues/2261?

carpawell commented 7 months ago

Hi @amlwwalker, sorry for the huge delay. Can you, please, provide the version you used?

Also, can you, please, provide the exact error message you got? Is Object xxxx could not be deleted from the SDK? session token not found map[] too (especially map[])?

Could you briefly describe what are you trying to do? What does TemporarySignObjectTokenWithPrivateKey do? Could you, please, provide the ACL settings of the container you used (container itself and an eACL policy if set)?

I have this working for creating

The code succeed looks almost the same but ObjectPutInit instead of Delete? What payload size did you use?

amlwwalker commented 6 months ago

Hi @carpawell - Apologies, I've been working on the Wallet Connect stuff and haven't looked back at this bug. Once my app is rebuilt I'll get you these answers!