Chris Muller uploaded a new version of WebClient-Core to project The Inbox: http://source.squeak.org/inbox/WebClient-Core-cmm.136.mcz
==================== Summary ====================
Name: WebClient-Core-cmm.136 Author: cmm Time: 18 May 2024, 6:30:21.417414 pm UUID: f4f5030f-e94f-4a8c-a3c3-0ef5be3ca97d Ancestors: WebClient-Core-tpr.135
base64 and base64url encoding convenience methods.
=============== Diff against WebClient-Core-tpr.135 ===============
Item was added: + ----- Method: WebUtils class>>base64Decode: (in category 'decoding') ----- + base64Decode: aString + "Decode previously-encoded aString back to its original ByteArray." + ^ (Base64MimeConverter mimeDecodeToBytes: aString readStream) contents!
Item was added: + ----- Method: WebUtils class>>base64DecodeString: (in category 'decoding') ----- + base64DecodeString: aString + "Decode previously-encded aString back to its original String value." + ^ (Base64MimeConverter mimeDecodeToChars: aString readStream) contents!
Item was added: + ----- Method: WebUtils class>>base64Encode: (in category 'decoding') ----- + base64Encode: aByteArray + "Encode a String, ByteArray, or Integer." + ^ (Base64MimeConverter mimeEncode: aByteArray asByteArray readStream multiLine: false) contents!
Item was added: + ----- Method: WebUtils class>>base64UrlDecode: (in category 'decoding') ----- + base64UrlDecode: aString + "Decode a ByteArray that was previously encoded with base64UrlEncode." + | base64 | + base64 := String streamContents: [ : stream | |missingPadding | + aString do: + [ : each | |nextChar | + nextChar := each + caseOf: + { [$_] -> [$/]. + [$-] -> [$+] } + otherwise: [ each ]. + stream nextPut: nextChar ]. + "Now reapply original padding." + missingPadding := (4-(aString size\4)) \ 4. + missingPadding timesRepeat: [ stream nextPut: $= ] ]. + ^ self base64Decode: base64!
Item was added: + ----- Method: WebUtils class>>base64UrlEncode: (in category 'decoding') ----- + base64UrlEncode: aByteArray + "Convert aByteArray to a valid filename. Base64 encode, replace +' with '-' and '/' with '_', and strip == padding. Restore with #base64UrlDecode:." + ^ String streamContents: + [ : stream | + (WebUtils base64Encode: aByteArray) do: + [ : each | each + caseOf: + { [$+] -> [stream nextPut: $-]. + [$/] -> [stream nextPut: $_ ]. + [$=] -> ["skip"] } + otherwise: + [ stream nextPut: each ] ] ]!
squeak-dev@lists.squeakfoundation.org